From dbc49bab59df7548fb4a1075d6fa95f85458ceab Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Sat, 20 Jun 2026 10:23:42 +0200 Subject: [PATCH] Import full nss --- include/nwnss/comnSA/comnDataStream.h | 6 +- include/nwnss/comnSA/comnLock.h | 32 +- include/nwnss/comnSA/contextHandle.h | 4 +- include/nwnss/comnSA/fileHandle.h | 41 +- include/nwnss/comnSA/intmem.h | 322 + include/nwnss/comnSA/msgLock.h | 4 +- include/nwnss/comnSA/name.h | 24 +- include/nwnss/comnSA/pssConnection.h | 10 +- include/nwnss/comnSA/psslib.h | 2 +- include/nwnss/comnSA/sAgentHandle.h | 4 +- include/nwnss/comnSA/sysimp.h | 78 +- include/nwnss/comnSA/zFriends.h | 16 +- include/nwnss/include/DisplayVersion.h | 2 +- include/nwnss/include/Moab.imp | 1999 ++++ include/nwnss/include/WithMPKSpinLock.h | 229 + include/nwnss/include/adminVolume.h | 236 - include/nwnss/include/admindrv.h | 50 + include/nwnss/include/afpAuthInfo.h | 119 + include/nwnss/include/alarm.h | 25 +- include/nwnss/include/asyncio.h | 12 +- include/nwnss/include/cduncomp.h | 153 - include/nwnss/include/cifs.imp | 35 + include/nwnss/include/cifsAuth.h | 305 + include/nwnss/include/cifsAuthp.h | 214 + include/nwnss/include/cifsManage.h | 498 + include/nwnss/include/cifsMemChunk.h | 95 + include/nwnss/include/cifsPdc.h | 157 + include/nwnss/include/cifsPdcp.h | 109 + include/nwnss/include/cifsStypes.h | 110 + include/nwnss/include/cmAlgoMan.h | 36 +- include/nwnss/include/cmControl.h | 48 +- include/nwnss/include/cmNSS.h | 28 +- include/nwnss/include/comnAuthorize.h | 18 +- include/nwnss/include/comnBeastClass.h | 6 +- include/nwnss/include/comnBeasts.h | 176 +- include/nwnss/include/comnIO.h | 4 +- include/nwnss/include/comnMacShortName.h | 13 +- include/nwnss/include/comnParams.h | 114 +- include/nwnss/include/comnPublics.h | 122 +- include/nwnss/include/comnTask.h | 12 +- include/nwnss/include/comnVariableData.h | 8 +- include/nwnss/include/comnZAS.h | 10 +- include/nwnss/include/control.h | 8 +- include/nwnss/include/dbgView.h | 112 + include/nwnss/include/dfi.h | 377 + include/nwnss/include/dfsLib.h | 99 + include/nwnss/include/dfsLib.imp | 5 + include/nwnss/include/dfsnds.h | 91 + include/nwnss/include/eDir.h | 2 +- include/nwnss/include/eventSys.h | 274 +- include/nwnss/include/evs.h | 6 +- include/nwnss/include/extAttrBeast.h | 4 +- include/nwnss/include/fsm.h | 12 +- include/nwnss/include/fsmsg.h | 6 +- include/nwnss/include/fullDirectoryInfo.h | 4 +- include/nwnss/include/guid.h | 4 +- include/nwnss/include/hardLinkBeast.h | 10 +- include/nwnss/include/histogram.h | 118 +- include/nwnss/include/hmc.h | 7 +- include/nwnss/include/http.imp | 38 + include/nwnss/include/id.h | 4 +- include/nwnss/include/inst.h | 4 +- include/nwnss/include/ipuAccess.h | 215 + include/nwnss/include/jsdebug.h | 247 + include/nwnss/include/jsmsgMessageMgmt.h | 148 + include/nwnss/include/jsmsgPresInt.h | 140 + include/nwnss/include/jsmsgPresentation.h | 65 + include/nwnss/include/jsmsgSessInt.h | 112 + include/nwnss/include/jsmsgSession.h | 100 + include/nwnss/include/latch.h | 50 +- include/nwnss/include/linuxmpk.h | 50 + include/nwnss/include/lsa.h | 11 +- include/nwnss/include/mailbox.h | 2 +- include/nwnss/include/mal.h | 4 +- include/nwnss/include/manage.h | 32 +- include/nwnss/include/manageNDS.h | 66 + include/nwnss/include/manageNlm.h | 20 +- include/nwnss/include/managePool.h | 71 + .../include/{comnAudit.h => manageServer.h} | 50 +- include/nwnss/include/manageUserSpaceRestr.h | 72 + include/nwnss/include/manageVolume.h | 128 + include/nwnss/include/mdb_dev.h | 75 + include/nwnss/include/mpk.h | 833 ++ include/nwnss/include/mpkatomic.h | 223 + include/nwnss/include/mpkerrno.h | 78 + include/nwnss/include/mpkmisc.h | 185 + include/nwnss/include/mpkutil.h | 525 ++ include/nwnss/include/msg.h | 8 +- include/nwnss/include/msgGen.h | 14 +- include/nwnss/include/msgIO.h | 10 +- include/nwnss/include/name.h | 476 - include/nwnss/include/nameSpace.h | 40 +- include/nwnss/include/napi.h | 78 + include/nwnss/include/ndp_app.h | 29 - include/nwnss/include/ndp_comn.h | 5 +- include/nwnss/include/ndp_guids.h | 3 +- include/nwnss/include/ndp_idbroker.h | 35 +- include/nwnss/include/ndp_messagehandler.h | 11 +- include/nwnss/include/ndp_msg.h | 5 +- include/nwnss/include/nebprivate.h | 359 + include/nwnss/include/nebpub.h | 87 - include/nwnss/include/nssAdminLib.h | 1 + include/nwnss/include/nssCOMN.imp | 400 + include/nwnss/include/nssErrorTable.h | 1 + include/nwnss/include/nssLOADER.imp | 445 + include/nwnss/include/nssMAL.imp | 10 + include/nwnss/include/nssMANAGE.imp | 11 + include/nwnss/include/nssRegistration.h | 159 + include/nwnss/include/nssZLSS.imp | 12 + include/nwnss/include/nsskr.h | 711 ++ include/nwnss/include/ntlib.h | 65 + include/nwnss/include/nwcommon.h | 132 + include/nwnss/include/nwcore.h | 130 + include/nwnss/include/objectIDStore.h | 138 - include/nwnss/include/opLock.h | 6 +- include/nwnss/include/osmpkhdrs.h | 67 + include/nwnss/include/parse.h | 34 +- include/nwnss/include/pssConfig.h | 380 - include/nwnss/include/pssDebug.h | 16 +- include/nwnss/include/pssmpk.h | 239 +- include/nwnss/include/register.h | 4 +- include/nwnss/include/repair.h | 12 +- include/nwnss/include/repairRAVUser.h | 45 +- include/nwnss/include/repairUser.h | 5 +- include/nwnss/include/reserveResources.h | 10 +- include/nwnss/include/risupprt.imp | 9 + include/nwnss/include/sbi.h | 134 + include/nwnss/include/sbsMFL.h | 95 - include/nwnss/include/schedule.h | 153 +- include/nwnss/include/sdBasic.h | 242 + include/nwnss/include/sdNSS.h | 283 + include/nwnss/include/searchMap.h | 12 +- include/nwnss/include/slab.h | 10 +- include/nwnss/include/snp.h | 132 + include/nwnss/include/switchboard.h | 4 +- include/nwnss/include/tcpip.imp | 82 + include/nwnss/include/threads.imp | 624 ++ include/nwnss/include/unssLOADER.imp | 75 + include/nwnss/include/utc.h | 42 +- include/nwnss/include/uxaction.h | 27 +- include/nwnss/include/vcu.h | 252 + include/nwnss/include/vdbe.h | 241 + include/nwnss/include/vdbe.imp | 19 + include/nwnss/include/virtualIO.h | 14 +- include/nwnss/include/vldb.h | 98 + include/nwnss/include/vldb.imp | 5 + include/nwnss/include/vldbcfg.h | 77 + include/nwnss/include/vldbdefs.h | 77 + include/nwnss/include/vldberr.h | 102 + include/nwnss/include/vldbmsg.h | 738 ++ include/nwnss/include/vldbrpr.h | 67 + include/nwnss/include/vlrpc.h | 184 + include/nwnss/include/vlrpc.imp | 28 + include/nwnss/include/vlrprif.h | 123 + include/nwnss/include/vmrpc.h | 382 + include/nwnss/include/vmrpc.imp | 31 + include/nwnss/include/volman.h | 141 + include/nwnss/include/volmnmsg.h | 975 ++ include/nwnss/include/volsms.h | 176 + include/nwnss/include/volume.h | 232 +- include/nwnss/include/wio.h | 33 +- include/nwnss/include/ws2nlm.imp | 85 + include/nwnss/include/xAdminVolume.h | 2 +- include/nwnss/include/xCache.h | 76 +- include/nwnss/include/xError.h | 16 +- include/nwnss/include/zapi_library.h | 52 + include/nwnss/internal/NssPageRuntime.h | 106 - include/nwnss/internal/NssUaccessRuntime.h | 26 - include/nwnss/internal/adminVolume.h | 8 +- include/nwnss/internal/cacheControl.h | 13 +- .../nwnss/{include => internal}/cmCompFile.h | 14 +- include/nwnss/internal/cmDefs.h | 12 +- include/nwnss/internal/comnCompress.h | 14 +- include/nwnss/internal/dirQuotas.h | 2 +- include/nwnss/internal/jio.imp | 31 + include/nwnss/internal/jni_md.h | 45 + include/nwnss/internal/lsaXattrUserspace.h | 63 - include/nwnss/internal/macNSpace.h | 6 +- include/nwnss/internal/macNSpaceUserspace.h | 62 - include/nwnss/internal/mediaManager.imp | 4 + include/nwnss/internal/mgmt.h | 188 +- include/nwnss/internal/msgName.h | 166 +- include/nwnss/internal/nCache.h | 2 +- include/nwnss/internal/nssFSHooks.h | 14 +- .../nwnss/{include => internal}/nssOSAPIs.h | 38 +- include/nwnss/internal/nssSourceCompat.h | 314 - include/nwnss/internal/nssUnicodeUserspace.h | 41 - include/nwnss/internal/nssUserspaceProvider.h | 61 - include/nwnss/internal/nssUserspaceQuota.h | 101 - include/nwnss/internal/nssZosCompat.h | 90 - .../{support/lnxmbINC => internal}/nwInKeys.h | 2 +- .../nwnss/{include => internal}/nwInProc.h | 6 +- include/nwnss/internal/pssConfig.h | 26 +- include/nwnss/internal/rintface.h | 400 + include/nwnss/internal/sbsMFL.h | 12 +- include/nwnss/internal/spinlock.h | 54 - include/nwnss/internal/stdio.h | 80 + .../{include/seqUpdater.h => internal/time.h} | 24 +- include/nwnss/internal/unixAuthModel.h | 8 +- include/nwnss/internal/unixNSpace.h | 20 +- include/nwnss/internal/windowAPIs.h | 373 + include/nwnss/internal/windows.h | 47 + include/nwnss/{include => internal}/xMsg.h | 51 +- include/nwnss/internal/xlss.imp | 3 + .../{include => internal}/zasAuthModel.h | 20 +- include/nwnss/internal/zlssDevUserIO.h | 19 - include/nwnss/library/bit.h | 6 +- include/nwnss/library/bitmap.h | 8 +- include/nwnss/library/clock.h | 105 + include/nwnss/library/crc.h | 2 +- include/nwnss/library/ctype.h | 4 +- include/nwnss/library/format.h | 42 +- include/nwnss/library/hash.h | 4 +- include/nwnss/library/inlines.h | 6 +- include/nwnss/library/libNSS.imp | 158 + include/nwnss/library/nssDebug.h | 4 +- include/nwnss/library/omni.h | 12 +- include/nwnss/library/que.h | 306 +- include/nwnss/library/rand.h | 2 +- include/nwnss/library/rbpTree.h | 6 +- include/nwnss/library/regmodules.h | 51 + include/nwnss/library/setjmp.h | 62 + include/nwnss/library/sort.h | 68 + include/nwnss/library/stdlib.h | 4 +- include/nwnss/library/string.h | 15 +- include/nwnss/library/timeline.h | 52 + include/nwnss/library/xLimits.h | 2 +- include/nwnss/library/xSetjmp.h | 58 + include/nwnss/library/xStdio.h | 2 +- include/nwnss/library/xStdlib.h | 14 +- include/nwnss/library/xString.h | 126 +- include/nwnss/library/xUnicode.h | 20 +- include/nwnss/public/chunk.h | 2 +- include/nwnss/public/dfsguids.h | 72 + include/nwnss/public/ipc2ncp.h | 52 + include/nwnss/public/jsmsg.h | 248 + include/nwnss/public/jsmsg.imp | 25 + include/nwnss/public/neb.h | 8 +- include/nwnss/public/neb.imp | 6 + include/nwnss/public/nfsLock.h | 14 +- include/nwnss/public/nssPubs.h | 10 +- include/nwnss/public/psa.imp | 23 + include/nwnss/public/psaPublic.h | 303 + include/nwnss/public/uneb.h | 175 + include/nwnss/public/virtualIO.imp | 21 + include/nwnss/public/xmlTags.h | 2 +- include/nwnss/public/zError.h | 44 +- include/nwnss/public/zEvent.h | 470 +- include/nwnss/public/zFsMsg.h | 8 +- include/nwnss/public/zMigrate.h | 2 +- include/nwnss/public/zMsg.h | 4 +- include/nwnss/public/zOmni.h | 6 +- include/nwnss/public/zParams.h | 266 +- include/nwnss/public/zPool.h | 5 +- include/nwnss/public/zPool.imp | 6 + include/nwnss/public/zPublics.h | 22 +- include/nwnss/public/zPublics.imp | 91 + include/nwnss/public/zXattr.h | 8 +- include/nwnss/support/lnxmbINC/aesproc.h | 1 - include/nwnss/support/lnxmbINC/alert.h | 247 - include/nwnss/support/lnxmbINC/bindery.h | 194 - include/nwnss/support/lnxmbINC/bits.h | 183 - include/nwnss/support/lnxmbINC/command.h | 1 - include/nwnss/support/lnxmbINC/config.h | 86 - include/nwnss/support/lnxmbINC/connect.h | 300 - include/nwnss/support/lnxmbINC/connexp.h | 465 - include/nwnss/support/lnxmbINC/doscalls.h | 1 - include/nwnss/support/lnxmbINC/enable.h | 294 - include/nwnss/support/lnxmbINC/encp.h | 2375 ----- include/nwnss/support/lnxmbINC/errors.h | 280 - include/nwnss/support/lnxmbINC/event.h | 1331 --- include/nwnss/support/lnxmbINC/fshooks.h | 81 - include/nwnss/support/lnxmbINC/fsproto.h | 411 - include/nwnss/support/lnxmbINC/ins.h | 55 - include/nwnss/support/lnxmbINC/lanconf.h | 1 - include/nwnss/support/lnxmbINC/lfsproto.h | 308 - include/nwnss/support/lnxmbINC/loader.h | 885 -- include/nwnss/support/lnxmbINC/maapi.h | 50 - include/nwnss/support/lnxmbINC/manss.h | 35 - include/nwnss/support/lnxmbINC/masv.h | 259 - include/nwnss/support/lnxmbINC/mmpublic.h | 1763 ---- include/nwnss/support/lnxmbINC/modify.h | 124 - include/nwnss/support/lnxmbINC/mpktypes.h | 96 - include/nwnss/support/lnxmbINC/nameserv.h | 387 - include/nwnss/support/lnxmbINC/nmevents.h | 1 - include/nwnss/support/lnxmbINC/nspace.h | 68 - include/nwnss/support/lnxmbINC/nwreg.h | 377 - include/nwnss/support/lnxmbINC/portable.h | 1263 --- include/nwnss/support/lnxmbINC/procdefs.h | 23 - include/nwnss/support/lnxmbINC/scs.h | 1 - include/nwnss/support/lnxmbINC/setparms.h | 253 - include/nwnss/support/lnxmbINC/subjects.h | 58 - include/nwnss/support/lnxmbINC/task.h | 59 - include/nwnss/support/lnxmbINC/version.h | 4 - include/nwnss/support/lnxmbINC/volstruc.h | 336 - include/nwnss/support/ndssdkINC_kern/dconst.h | 264 - include/nwnss/support/ndssdkINC_kern/dtypes.h | 58 - .../nwnss/support/ndssdkINC_kern/nwdserr.h | 495 - src/nwnss/Makefile | 57 + src/nwnss/admindrv/Makefile | 32 + src/nwnss/admindrv/Module.supported | 1 + src/nwnss/admindrv/admindrvLKM.c | 281 + src/nwnss/admindrv/admindrvModules.mk | 276 + src/nwnss/comn/Makefile | 32 + src/nwnss/comn/Module.supported | 1 + {include => src}/nwnss/comn/aes.h | 9 +- src/nwnss/comn/aes/aes_cbc.c | 9 +- src/nwnss/comn/aes/aes_core.c | 137 +- {include => src}/nwnss/comn/aes/aes_locl.h | 2 +- src/nwnss/comn/authsys/authorize.c | 213 +- src/nwnss/comn/authsys/unixAuthModel.c | 13 +- src/nwnss/comn/authsys/unixAuthSpace.c | 18 +- .../nwnss/comn/authsys}/unixAuthSpace.h | 2 +- src/nwnss/comn/authsys/unixDecision.c | 22 +- src/nwnss/comn/authsys/zasAuthModel.c | 26 +- src/nwnss/comn/authsys/zasAuthSpace.c | 36 +- .../nwnss/comn/authsys}/zasAuthSpace.h | 2 +- src/nwnss/comn/authsys/zasDecision.c | 40 +- {include => src}/nwnss/comn/checker.h | 0 src/nwnss/comn/common/adminVolFile.c | 213 + src/nwnss/comn/common/adminVolume.c | 196 +- src/nwnss/comn/common/authBeast.c | 149 + src/nwnss/comn/common/avolSimpleDir.c | 116 +- .../nwnss/comn/common}/avolSimpleDir.h | 6 +- src/nwnss/comn/common/beastClass.c | 124 +- .../nwnss/comn/common/beastClass.h | 2 +- src/nwnss/comn/common/beastDelete.c | 114 +- src/nwnss/comn/common/beastHash.c | 177 +- src/nwnss/comn/common/beastIO.c | 178 +- src/nwnss/comn/common/beastRelease.c | 23 +- src/nwnss/comn/common/beastStartup.c | 470 + .../nwnss/comn/common/beastStartup.h | 2 +- src/nwnss/comn/common/cSA.c | 224 +- src/nwnss/comn/common/cSAcache.c | 23 +- src/nwnss/comn/common/cSAmanager.c | 28 +- src/nwnss/comn/common/checker.c | 112 +- src/nwnss/comn/common/cmdLineRecovery.c | 252 +- src/nwnss/comn/common/comnAudit.c | 44 +- src/nwnss/comn/common/comnDSI.c | 1001 ++ src/nwnss/comn/common/comnDataStream.c | 14 +- src/nwnss/comn/common/comnEFL.c | 76 +- src/nwnss/comn/common/comnEvent.c | 115 +- src/nwnss/comn/common/comnFile.c | 725 +- src/nwnss/comn/common/comnIO.c | 375 +- src/nwnss/comn/common/comnLib.c | 23 +- src/nwnss/comn/common/comnLock.c | 230 +- src/nwnss/comn/common/comnLog.c | 6 + src/nwnss/comn/common/comnLookup.c | 292 +- src/nwnss/comn/common/comnMacShortName.c | 104 +- src/nwnss/comn/common/comnMacintosh.c | 23 +- src/nwnss/comn/common/comnOpLock.c | 33 +- src/nwnss/comn/common/comnPool.c | 182 +- src/nwnss/comn/common/comnRename.c | 133 +- src/nwnss/comn/common/comnStartup.c | 8 +- src/nwnss/comn/common/comnTask.c | 32 +- src/nwnss/comn/common/comnUnicode.c | 2 + src/nwnss/comn/common/comnVariableData.c | 39 +- src/nwnss/comn/common/comnVol.c | 650 +- src/nwnss/comn/common/comnWild.c | 54 +- src/nwnss/comn/common/comnXaction.c | 15 +- src/nwnss/comn/common/contextHandle.c | 24 +- src/nwnss/comn/common/cro.c | 50 +- src/nwnss/comn/common/csaLease.c | 97 +- .../nwnss/comn/common}/csaLease.h | 7 +- src/nwnss/comn/common/csaManage.c | 484 + src/nwnss/comn/common/csaManage.h | 58 + src/nwnss/comn/common/dirQuotas.c | 195 +- src/nwnss/comn/common/eflMgmt.c | 348 +- src/nwnss/comn/common/extAttrBeast.c | 26 +- src/nwnss/comn/common/fileBeast.c | 1936 ++++ src/nwnss/comn/common/fileHandle.c | 177 +- src/nwnss/comn/common/fsmsg.c | 712 +- src/nwnss/comn/common/hardLinkBeast.c | 15 +- src/nwnss/comn/common/hmc.c | 77 +- src/nwnss/comn/common/mgmt.c | 2 +- src/nwnss/comn/common/mgmtFiles.c | 165 +- src/nwnss/comn/common/mgmtPool.c | 98 +- src/nwnss/comn/common/mgmtVol.c | 325 +- src/nwnss/comn/common/name.c | 278 +- src/nwnss/comn/common/nameCache.c | 64 +- src/nwnss/comn/common/nameLookup.c | 34 +- src/nwnss/comn/common/nameScan.c | 153 +- src/nwnss/comn/common/nameScanDebug.c | 264 + src/nwnss/comn/common/namedBeast.c | 2007 ++++ src/nwnss/comn/common/objectIDStore.c | 136 +- src/nwnss/comn/common/pssConnection.c | 84 +- src/nwnss/comn/common/registerLSS.c | 6 +- src/nwnss/comn/common/repair.c | 88 +- src/nwnss/comn/common/restartCount.c | 51 + src/nwnss/comn/common/rootBeast.c | 2029 +++++ src/nwnss/comn/common/sAgentHandle.c | 9 +- src/nwnss/comn/common/sazLib.c | 13 +- .../nwnss/comn/common}/sazlib.h | 2 +- src/nwnss/comn/common/searchMap.c | 32 +- src/nwnss/comn/common/seqUpdater.c | 10 +- src/nwnss/comn/common/uxaction.c | 608 +- src/nwnss/comn/common/virtualIO.c | 2 +- src/nwnss/comn/common/volBeast.c | 2092 +++++ src/nwnss/comn/common/volStartup.c | 4 +- src/nwnss/comn/common/zAPI.c | 156 +- src/nwnss/comn/common/zFriends.c | 486 + src/nwnss/comn/common/zPool.c | 1660 ++-- src/nwnss/comn/common/zPublics.c | 237 + .../comn/main => src/nwnss/comn}/comnAudit.h | 1 + {include => src}/nwnss/comn/comnCmdline.h | 8 +- src/nwnss/comn/comnModules.mk | 490 + src/nwnss/comn/comnVersion.c | 2 +- .../nwnss/comn/compression}/cdcommon.h | 111 +- src/nwnss/comn/compression/cdcomp.c | 1549 ++-- .../nwnss/comn/compression}/cdcomp.h | 85 +- src/nwnss/comn/compression/cdcompa.c | 45 +- .../nwnss/comn/compression}/cdnetwar.h | 10 +- .../nwnss/comn/compression}/cdreada.h | 9 +- src/nwnss/comn/compression/cduncomp.c | 1229 +-- src/nwnss/comn/compression/cduncomp.h | 154 + src/nwnss/comn/compression/cduncompa.c | 558 +- src/nwnss/comn/compression/cmActivity.c | 182 +- .../nwnss/comn/compression}/cmActivity.h | 10 +- src/nwnss/comn/compression/cmAlgoMan.c | 94 +- src/nwnss/comn/compression/cmBgCompress.c | 93 +- src/nwnss/comn/compression/cmCompDecomp.c | 1010 +- src/nwnss/comn/compression/cmCompFile.c | 229 +- src/nwnss/comn/compression/cmControl.c | 10 +- src/nwnss/comn/compression/cmRuntime.c | 318 +- .../nwnss/comn/compression}/cmRuntime.h | 6 +- src/nwnss/comn/compression/comnCompress.c | 655 +- src/nwnss/comn/compression/copyAlgo.c | 164 + src/nwnss/comn/compression/nwAlgo.c | 80 +- .../nwnss/comn/compression}/nwAlgo.h | 2 +- .../nwnss/include => src/nwnss/comn}/cro.h | 1 + .../nwnss/include => src/nwnss/comn}/csa.h | 17 +- src/nwnss/comn/main/comnCmdline.c | 214 +- src/nwnss/comn/main/comnLKM.c | 249 + src/nwnss/comn/main/comnsaSDKSym.c | 45 + src/nwnss/comn/main/marshal.c | 338 + src/nwnss/comn/main/nssCOMNSym.c | 502 + src/nwnss/comn/main/pssNLM.c | 190 + src/nwnss/comn/main/pssStartup.c | 1103 +++ src/nwnss/comn/main/qdiv.c | 412 + src/nwnss/comn/main/unssCOMNSym.c | 43 + src/nwnss/comn/main/xlssSym.c | 45 + src/nwnss/comn/main/zPoolSym.c | 50 + src/nwnss/comn/main/zPublicsSym.c | 114 + {include => src}/nwnss/comn/nameScan.h | 2 +- src/nwnss/comn/namespace/dataStreamNSpace.c | 78 +- .../nwnss/comn/namespace/dataStreamNSpace.h | 6 +- src/nwnss/comn/namespace/dosNSWild.c | 14 +- src/nwnss/comn/namespace/dosNSpace.c | 196 +- .../nwnss/comn/namespace/dosNSpace.h | 10 +- src/nwnss/comn/namespace/extAttrNSpace.c | 76 +- .../nwnss/comn/namespace/extAttrNSpace.h | 6 +- src/nwnss/comn/namespace/longNSpace.c | 136 +- .../nwnss/comn/namespace/longNSpace.h | 6 +- src/nwnss/comn/namespace/macNSpace.c | 95 +- src/nwnss/comn/namespace/nameSpace.c | 18 +- .../nwnss/comn/namespace/nspaceStartup.h | 2 +- src/nwnss/comn/namespace/unixNSpace.c | 85 +- {include => src}/nwnss/comn/pssStartup.h | 6 +- .../include => src/nwnss/comn}/purgeDir.h | 0 src/nwnss/comn/sbs/sbsMFL.c | 40 +- src/nwnss/comn/sbs/sbsMgmt.c | 104 +- .../comn/main => src/nwnss/comn}/seqUpdater.h | 0 .../include => src/nwnss/comn}/zasAuthCache.h | 4 +- src/nwnss/library/Makefile | 43 + src/nwnss/library/Module.supported | 1 + src/nwnss/library/debug/DebugHexDump.c | 134 + src/nwnss/library/debug/DebugPrintf.c | 1074 +++ src/nwnss/library/debug/assert.c | 96 + src/nwnss/library/debug/dbgerror.c | 58 + src/nwnss/library/debug/dbgfatal.c | 67 + src/nwnss/library/debug/dbginit.c | 1 + src/nwnss/library/debug/dfi.c | 1056 +++ src/nwnss/library/debug/enterDebug.c | 330 + src/nwnss/library/debug/ncpTrAsm.386 | 66 + src/nwnss/library/debug/ncpTrace.c | 417 + src/nwnss/library/debug/pssDebug.c | 30 +- src/nwnss/library/debug/sdBasic.c | 370 + src/nwnss/library/debug/sdNSS.c | 1668 ++++ src/nwnss/library/debug/snp.c | 528 ++ src/nwnss/library/debug/warn.c | 64 + src/nwnss/library/eDir/getDSGuid.c | 1 + src/nwnss/library/eDir/parseDSObjectName.c | 6 +- src/nwnss/library/fsm/fsmnw.c | 52 +- src/nwnss/library/functionPtrs.c | 8 + src/nwnss/library/guid/guid.c | 3 +- src/nwnss/library/id/id.c | 10 +- {include => src}/nwnss/library/intlatch.h | 2 +- src/nwnss/library/latch/intlatch.c | 5 +- src/nwnss/library/latch/latch.c | 104 +- src/nwnss/library/libraryLKM.c | 97 + src/nwnss/library/libraryModules.mk | 494 + src/nwnss/library/libraryVersion.c | 46 + .../library/linux/napiFormatDateAndTime.c | 457 + src/nwnss/library/linux/napiUnitTests.c | 343 + src/nwnss/library/misc/.cvsignore | 1 + src/nwnss/library/misc/GetInstLen.c | 1750 ++++ .../library/misc/NW_NCPFuncBoundaryError.c | 80 + src/nwnss/library/misc/NW_NCPLengthError.c | 75 + .../library/misc/NW_NCPSubFuncLengthError.c | 80 + .../library/misc/NW_WriteBranchTableEntry.c | 58 + src/nwnss/library/misc/displayVersion.c | 10 +- src/nwnss/library/misc/format.c | 222 +- src/nwnss/library/misc/histogram.c | 241 +- src/nwnss/library/misc/lbVolume.c | 22 +- src/nwnss/library/misc/register.c | 32 +- src/nwnss/library/misc/sysimp.c | 2 +- src/nwnss/library/misc/timeline.c | 131 + src/nwnss/library/misc/xmlNSS2.c | 7 +- src/nwnss/library/nssLIBRARYSym.c | 402 + src/nwnss/library/os/ZOS_IsNLMLoaded.c | 50 + src/nwnss/library/os/aeswork.c | 176 + src/nwnss/library/os/alarm.c | 81 +- src/nwnss/library/os/config.c | 41 +- src/nwnss/library/os/crthread.c | 200 + src/nwnss/library/os/delay.c | 138 +- src/nwnss/library/os/inst.c | 8 +- src/nwnss/library/os/mailbox.c | 8 +- src/nwnss/library/os/pssmpk.c | 418 +- src/nwnss/library/os/snooze.c | 14 +- src/nwnss/library/os/worktodo.c | 8 +- src/nwnss/library/parse/pcmdline.c | 139 +- src/nwnss/library/qdiv.c | 829 +- src/nwnss/library/stdio/aprintf.c | 3 +- src/nwnss/library/stdio/errprintf.c | 17 +- src/nwnss/library/stdio/getchar.c | 46 + src/nwnss/library/stdio/gets.c | 50 + src/nwnss/library/stdio/printf.c | 3 +- src/nwnss/library/stdio/snprintf.c | 237 +- .../nwnss/library/stdio/snprintf.h | 7 +- src/nwnss/library/stdio/sprintf.c | 7 +- src/nwnss/library/stdio/vaprintf.c | 2 +- src/nwnss/library/stdio/vprintf.c | 2 +- src/nwnss/library/stdio/vsprintf.c | 6 +- src/nwnss/library/stdlib/exit.c | 82 +- src/nwnss/library/stdlib/free.c | 353 +- src/nwnss/library/stdlib/freeForNCPReply.c | 72 +- src/nwnss/library/stdlib/freePage.c | 76 +- src/nwnss/library/stdlib/malloc.c | 276 +- src/nwnss/library/stdlib/mallocForNCPReply.c | 97 +- src/nwnss/library/stdlib/mallocPage.c | 101 +- .../library/stdlib/mallocPageWithFlags.c | 116 +- src/nwnss/library/stdlib/realloc.c | 113 +- src/nwnss/library/stdlib/zalloc.c | 146 +- src/nwnss/library/stdlib/zallocPage.c | 102 +- src/nwnss/library/stdlib/zrealloc.c | 163 +- src/nwnss/library/unicode/ByteToUnicode.c | 28 +- src/nwnss/library/unicode/LenByteToUnicode.c | 24 +- .../library/unicode/LenMacByteToUnicode.c | 24 +- src/nwnss/library/unicode/MacByteToUnicode.c | 28 +- .../unicode/RegisterUnicodeConverter.c | 20 +- .../unicode/UnRegisterUnicodeConverter.c | 19 +- src/nwnss/library/unicode/UnicodeToByte.c | 22 +- src/nwnss/library/unicode/UnicodeToMacByte.c | 22 +- .../library/unicode/UnicodeToUntermByte.c | 16 +- .../library/unicode/UnicodeToUntermMacByte.c | 16 +- src/nwnss/library/unicode/componentUnicpy.c | 4 +- src/nwnss/library/unicode/componentUnilen.c | 2 +- .../library/unicode/getMacCodePageName.c | 8 +- .../library/unicode/getNssUnicodeVersion.c | 11 +- src/nwnss/library/unicode/unicat.c | 2 +- src/nwnss/library/unicode/unicmp.c | 2 +- src/nwnss/library/unicode/unicodeInit.c | 309 +- src/nwnss/library/unicode/unicodeParse.c | 20 +- src/nwnss/library/unicode/unicpy.c | 2 +- src/nwnss/library/unicode/uniicmp.c | 2 +- src/nwnss/library/unicode/uniicmpmac.c | 2 +- src/nwnss/library/unicode/unilen.c | 2 +- src/nwnss/library/unicode/unilwr.c | 9 +- src/nwnss/library/unicode/unimcpy.c | 2 +- src/nwnss/library/unicode/uninicmp.c | 2 +- src/nwnss/library/unicode/unitolower.c | 10 +- src/nwnss/library/unicode/unitoupper.c | 10 +- src/nwnss/library/unicode/uniupr.c | 9 +- src/nwnss/library/unicode/utf8LenToUniChar.c | 16 +- src/nwnss/library/unicode/utf8ToUniChar.c | 6 +- src/nwnss/library/unicode/utf_tolower.c | 6 +- .../nwnss => src/nwnss/library}/unicodeInit.h | 8 +- src/nwnss/library/unssLIBRARYSym.c | 122 + src/nwnss/library/utc/default.dsc | Bin 0 -> 2571 bytes src/nwnss/library/utc/dos2str.c | 2 +- src/nwnss/library/utc/dos2utc.c | 30 +- src/nwnss/library/utc/dosd2str.c | 2 +- src/nwnss/library/utc/dost2str.c | 2 +- src/nwnss/library/utc/gethres.386 | 63 + src/nwnss/library/utc/getutctime.c | 2 +- src/nwnss/library/utc/local2utc.c | 15 +- src/nwnss/library/utc/msTime2utc.c | 26 +- src/nwnss/library/utc/sec2utc.c | 28 +- src/nwnss/library/utc/secsDiff.c | 4 +- src/nwnss/library/utc/str2dos.c | 8 +- src/nwnss/library/utc/str2dosd.c | 4 +- src/nwnss/library/utc/str2dost.c | 6 +- src/nwnss/library/utc/str2utc.c | 22 +- src/nwnss/library/utc/utc2dos.c | 36 +- src/nwnss/library/utc/utc2local.c | 8 +- src/nwnss/library/utc/utc2msTime.c | 12 +- src/nwnss/library/utc/utc2sec.c | 10 +- src/nwnss/library/utc/utc2str.c | 24 +- src/nwnss/library/utc/utcdata.c | 140 +- .../nwnss => src/nwnss/library}/utcData.h | 2 +- src/nwnss/library/wio/lnxLog.c | 13 +- src/nwnss/library/wio/nssUI.c | 745 +- src/nwnss/library/wio/wSetStdio.c | 52 + src/nwnss/library/wio/wWrapString.c | 21 +- src/nwnss/library/wio/wactivate.c | 51 + src/nwnss/library/wio/waprintf.c | 3 +- src/nwnss/library/wio/wcenter.c | 67 + .../nwnss/library/wio/wclose.c | 54 +- src/nwnss/library/wio/wclrscr.c | 50 + src/nwnss/library/wio/wgetc.c | 135 + src/nwnss/library/wio/wgetdim.c | 64 + src/nwnss/library/wio/wgetpos.c | 5 +- src/nwnss/library/wio/wgets.c | 79 + src/nwnss/library/wio/wio.c | 25 +- src/nwnss/library/wio/wlock.c | 63 + src/nwnss/library/wio/wopen.c | 78 + src/nwnss/library/wio/wpause.c | 3 +- src/nwnss/library/wio/wprintf.c | 3 +- src/nwnss/library/wio/wpromptYesNo.c | 172 + src/nwnss/library/wio/wsetpos.c | 5 +- src/nwnss/library/wio/wsyncin.c | 61 + src/nwnss/library/wio/wvprintf.c | 2 +- src/nwnss/lsa/Makefile | 32 + src/nwnss/lsa/Module.supported | 2 + src/nwnss/lsa/lsa.c | 81 + src/nwnss/lsa/lsaAid.h | 93 + src/nwnss/lsa/lsaCmdline.c | 120 + src/nwnss/lsa/lsaComn.c | 95 +- src/nwnss/lsa/lsaErr.c | 3 +- src/nwnss/lsa/lsaLKM.c | 568 ++ src/nwnss/lsa/lsaModules.mk | 290 + src/nwnss/lsa/lsaNSSKR.c | 1009 ++ {include => src}/nwnss/lsa/lsaPrivate.h | 4 - src/nwnss/lsa/lsaStartup.c | 59 + {include => src}/nwnss/lsa/lsaStartup.h | 0 src/nwnss/lsa/lsaSuper.c | 2631 ++++++ src/nwnss/lsa/lsaSuperPool.c | 602 ++ src/nwnss/lsa/lsaSuperVol.c | 1164 +++ src/nwnss/lsa/lsaUser.c | 31 +- src/nwnss/lsa/lsaVersion.c | 47 + src/nwnss/lsa/lsaXattr.c | 103 +- src/nwnss/manage/Makefile | 32 + src/nwnss/manage/Module.supported | 2 + src/nwnss/manage/manage.c | 1 + src/nwnss/manage/manageAFP.c | 394 + src/nwnss/manage/manageAdapter.c | 398 + src/nwnss/manage/manageCmdline.c | 89 + src/nwnss/manage/manageFile.c | 4841 ++++++++++ src/nwnss/manage/manageLKM.c | 255 + src/nwnss/manage/manageLinux.c | 1040 +++ src/nwnss/manage/manageModules.mk | 305 + src/nwnss/manage/manageNDS.c | 1 + src/nwnss/manage/manageNLM.c | 195 + src/nwnss/manage/managePartition.c | 1 + src/nwnss/manage/managePool.c | 2 + src/nwnss/manage/manageServer.c | 1 + src/nwnss/manage/manageStartup.c | 73 + src/nwnss/manage/manageStartup.h | 81 + src/nwnss/manage/manageUserSpaceRestr.c | 1 + src/nwnss/manage/manageUserSpaceRestr.h | 72 + src/nwnss/manage/manageVcu.c | 495 + src/nwnss/manage/manageVersion.c | 47 + src/nwnss/manage/manageVolMN.c | 2405 +++++ src/nwnss/manage/manageVolume.c | 1 + src/nwnss/manage/nssMANAGESym.c | 94 + src/nwnss/ndpmod/Makefile | 32 + src/nwnss/ndpmod/Module.supported | 1 + src/nwnss/ndpmod/NDPDEBUG.NOTES | 21 + src/nwnss/ndpmod/ndp_comn.c | 2 + src/nwnss/ndpmod/ndp_guids.c | 2 + src/nwnss/ndpmod/ndp_idbroker.c | 2 + src/nwnss/ndpmod/ndp_messagehandler.c | 2 + src/nwnss/ndpmod/ndp_mod.c | 695 ++ src/nwnss/ndpmod/ndp_mod.h | 85 + src/nwnss/ndpmod/ndpmodModules.mk | 264 + src/nwnss/ndpmod/ndpmodVersion.c | 45 + src/nwnss/nebdrv/Makefile | 31 + src/nwnss/nebdrv/Module.supported | 1 + src/nwnss/nebdrv/nebdrvModules.mk | 274 + src/nwnss/nebdrv/nebdrvVersion.c | 46 + src/nwnss/nebdrv/unebdrvLKM.c | 66 + src/nwnss/nebdrv/unebserv.c | 1076 +++ src/nwnss/nss/Makefile | 32 + src/nwnss/nss/Module.supported | 1 + src/nwnss/nss/cache/asyncio.c | 20 +- src/nwnss/nss/cache/bond.c | 40 +- src/nwnss/nss/cache/cache.c | 4216 ++++++++- src/nwnss/nss/cache/control.c | 59 +- src/nwnss/nss/cache/work.c | 102 +- src/nwnss/nss/dbgView.c | 2110 +++++ src/nwnss/nss/lib/bitmap.c | 18 +- src/nwnss/nss/lib/crc.c | 40 +- src/nwnss/nss/lib/hash.c | 10 +- src/nwnss/nss/lib/setErrno.c | 21 +- src/nwnss/nss/msg/msg.c | 93 +- src/nwnss/nss/msg/slab.c | 36 +- src/nwnss/nss/msg/switchboard.c | 571 +- src/nwnss/nss/nssCmdline.c | 1935 ++++ src/nwnss/nss/nssLKM.c | 407 + src/nwnss/nss/nssLoadNLMs.c | 668 ++ src/nwnss/nss/nssLog.c | 389 + src/nwnss/nss/nssModules.mk | 314 + src/nwnss/nss/nssNLM.c | 412 + src/nwnss/nss/nssNSSSym.c | 225 + src/nwnss/nss/nssRegistration.c | 2523 +++++ src/nwnss/nss/nssStartup.c | 713 ++ src/nwnss/nss/nssStartup.h | 190 + src/nwnss/nss/nssVersion.c | 46 + src/nwnss/nss/setcmd.h | 102 + src/nwnss/nss/setcmd/setcmd.c | 326 + src/nwnss/nss/trustees.xml | 23 + src/nwnss/nss/unssNSSSym.c | 44 + src/nwnss/nsslnxlib/Makefile | 32 + src/nwnss/nsslnxlib/Module.supported | 1 + src/nwnss/nsslnxlib/allocRTag.c | 62 + src/nwnss/nsslnxlib/kfile.c | 119 + src/nwnss/nsslnxlib/kfile.h | 45 + src/nwnss/nsslnxlib/microSecondTimer.c | 54 + src/nwnss/nsslnxlib/nssLnxDummy.c | 526 ++ src/nwnss/nsslnxlib/nssLnxLib.h | 68 + src/nwnss/nsslnxlib/nssLnxLibLKM.c | 223 + src/nwnss/nsslnxlib/nssNSSLNXLIBSym.c | 95 + src/nwnss/nsslnxlib/nsslnxlibModules.mk | 280 + src/nwnss/nsslnxlib/nsslnxlibVersion.c | 46 + {include => src}/nwnss/nsslnxlib/nssunilib.h | 25 +- src/nwnss/nsslnxlib/nwlocale.c | 232 +- src/nwnss/nsslnxlib/procdefslnx.c | 206 + src/nwnss/nsslnxlib/unilib.c | 60 +- .../nwnss/nsslnxlib/unssNSSLNXLIBSym.c | 48 +- src/nwnss/nwraid/Makefile | 10 + src/nwnss/nwraid/Module.supported | 1 + src/nwnss/nwraid/dmio.c | 135 + src/nwnss/nwraid/dmio.h | 41 + src/nwnss/nwraid/nwraid.h | 327 + src/nwnss/nwraid/nwraid0.c | 2470 +++++ src/nwnss/nwraid/nwraid1.c | 3120 +++++++ src/nwnss/nwraid/nwraid5.c | 4217 +++++++++ src/nwnss/nwraid/nwraidModules.mk | 280 + src/nwnss/sharedsrc/README | 12 + src/nwnss/sharedsrc/dbginit.c.h | 7 +- src/nwnss/sharedsrc/getDSGuid.c.h | 128 + src/nwnss/sharedsrc/guid.c.h | 92 +- src/nwnss/sharedsrc/manage.c.h | 2093 +++++ src/nwnss/sharedsrc/manageDevice.c.h | 6138 +++++++++++++ src/nwnss/sharedsrc/manageNDS.c.h | 3426 +++++++ src/nwnss/sharedsrc/managePartition.c.h | 4033 ++++++++ src/nwnss/sharedsrc/managePool.c.h | 8083 +++++++++++++++++ src/nwnss/sharedsrc/manageRAID.c.h | 2462 +++++ src/nwnss/sharedsrc/manageServer.c.h | 1679 ++++ src/nwnss/sharedsrc/manageUserSpaceRestr.c.h | 1284 +++ src/nwnss/sharedsrc/manageVolume.c.h | 6301 +++++++++++++ src/nwnss/sharedsrc/mgmt.c.h | 615 +- src/nwnss/sharedsrc/ndp_comn.c.h | 1 + src/nwnss/sharedsrc/ndp_guids.c.h | 1 + src/nwnss/sharedsrc/ndp_idbroker.c.h | 93 +- src/nwnss/sharedsrc/ndp_messagehandler.c.h | 3 +- src/nwnss/sharedsrc/otherErrorTables.c.h | 5 +- src/nwnss/sharedsrc/parseDSObjectName.c.h | 9 +- src/nwnss/sharedsrc/que.c.h | 13 +- src/nwnss/sharedsrc/sysimp.c.h | 103 +- src/nwnss/sharedsrc/uni2utf.c.h | 4 +- src/nwnss/sharedsrc/unicat.c.h | 2 +- src/nwnss/sharedsrc/unicmp.c.h | 3 +- src/nwnss/sharedsrc/unicpy.c.h | 4 +- src/nwnss/sharedsrc/unilen.c.h | 4 +- src/nwnss/sharedsrc/unimcpy.c.h | 5 +- src/nwnss/sharedsrc/utf2uni.c.h | 2 +- src/nwnss/sharedsrc/virtualIO.c.h | 164 +- src/nwnss/sharedsrc/xmlNSS.c.h | 25 +- src/nwnss/zlss/Makefile | 32 + src/nwnss/zlss/Module.supported | 2 + src/nwnss/zlss/beastTree.c | 489 +- src/nwnss/zlss/beastTree.h | 338 +- src/nwnss/zlss/btree.c | 4 +- src/nwnss/zlss/dfsIO.c | 88 +- src/nwnss/zlss/dir.h | 14 +- src/nwnss/zlss/dirTree.c | 249 +- src/nwnss/zlss/dirTree.h | 254 +- src/nwnss/zlss/dir_ops.c | 370 +- src/nwnss/zlss/dlog.c | 304 +- src/nwnss/zlss/dlog.h | 36 +- src/nwnss/zlss/eflLog.c | 182 +- src/nwnss/zlss/eflLog.h | 276 +- src/nwnss/zlss/eflTree.c | 639 +- src/nwnss/zlss/eflTree.h | 296 +- src/nwnss/zlss/mflBTree.h | 6 +- src/nwnss/zlss/mfl_if.c | 56 +- src/nwnss/zlss/mfl_if.h | 30 +- src/nwnss/zlss/myBTree.c | 255 +- src/nwnss/zlss/myBTree.h | 180 +- src/nwnss/zlss/nameTree.c | 136 +- src/nwnss/zlss/nameTree.h | 46 +- src/nwnss/zlss/node.c | 459 +- src/nwnss/zlss/node.h | 42 +- src/nwnss/zlss/nssZLSSSym.c | 129 + src/nwnss/zlss/overflow.c | 368 +- src/nwnss/zlss/purgeLog.c | 4556 +++++----- src/nwnss/zlss/purgeLog.h | 180 +- src/nwnss/zlss/purgeTree.c | 302 +- src/nwnss/zlss/purgeTree.h | 22 +- src/nwnss/zlss/purgeTree_if.h | 47 +- src/nwnss/zlss/purgeTree_new.c | 414 +- src/nwnss/zlss/purgeTree_new.h | 6 +- src/nwnss/zlss/qdiv.c | 412 + src/nwnss/zlss/repairBtree.c | 82 +- src/nwnss/zlss/repairDisplay.c | 262 +- src/nwnss/zlss/repairFMtree.c | 86 +- src/nwnss/zlss/repairFtree.c | 46 +- src/nwnss/zlss/repairMFL.c | 25 +- src/nwnss/zlss/repairMain.c | 625 +- src/nwnss/zlss/repairMain.h | 26 +- src/nwnss/zlss/repairMap.c | 102 +- src/nwnss/zlss/repairNames.c | 104 +- src/nwnss/zlss/repairNtree.c | 25 +- src/nwnss/zlss/repairPtree.c | 26 +- src/nwnss/zlss/repairRAV.c | 24 +- src/nwnss/zlss/repairRAVDebug.c | 6 +- src/nwnss/zlss/repairRAVDebug.h | 2 +- src/nwnss/zlss/repairReZid.c | 205 +- src/nwnss/zlss/repairSRTree.c | 142 +- src/nwnss/zlss/repairUpgrade.c | 88 +- src/nwnss/zlss/repairWidgets.c | 67 +- src/nwnss/zlss/repairZRP.c | 85 +- src/nwnss/zlss/repairZRP.h | 21 +- src/nwnss/zlss/repairZVP.c | 100 +- src/nwnss/zlss/repairZVP.h | 11 +- src/nwnss/zlss/salvageLog.c | 7 +- src/nwnss/zlss/sbi.c | 1940 ++++ src/nwnss/zlss/sbiNT.c | 555 ++ src/nwnss/zlss/sdZLSS.c | 3189 +++++++ src/nwnss/zlss/sdZLSS.h | 718 +- src/nwnss/zlss/underflow.c | 172 +- src/nwnss/zlss/userTree.c | 548 +- src/nwnss/zlss/userTree.h | 476 +- src/nwnss/zlss/xaction.c | 775 +- src/nwnss/zlss/xaction.h | 1700 ++-- src/nwnss/zlss/z_aes.h | 40 +- src/nwnss/zlss/z_aes_cbc.c | 113 + src/nwnss/zlss/z_aes_core.c | 1260 +++ src/nwnss/zlss/z_aes_locl.h | 2 +- src/nwnss/zlss/zedExport.c | 174 + src/nwnss/zlss/zedExport.h | 6 +- src/nwnss/zlss/zfs.c | 54 +- src/nwnss/zlss/zfs.h | 2418 ++--- src/nwnss/zlss/zfsAsyncio.h | 8 +- src/nwnss/zlss/zfsFileMap.c | 1514 ++- src/nwnss/zlss/zfsFileMap.h | 147 +- src/nwnss/zlss/zfsPool.c | 1657 ++-- src/nwnss/zlss/zfsSuperBlk.c | 871 +- src/nwnss/zlss/zfsSuperBlk.h | 1028 +-- src/nwnss/zlss/zfsVol.c | 500 +- src/nwnss/zlss/zfsVolumeData.c | 400 +- src/nwnss/zlss/zfsXTree.c | 1236 +-- src/nwnss/zlss/zfsXTree.h | 352 +- src/nwnss/zlss/zfsdefs.h | 144 +- src/nwnss/zlss/zio.c | 594 +- src/nwnss/zlss/zlog.c | 2490 +++-- src/nwnss/zlss/zlog.h | 2718 +++--- src/nwnss/zlss/zlogDebug.c | 333 + src/nwnss/zlss/zlogFtest.h | 18 +- src/nwnss/zlss/zlogUnitTest.c | 646 ++ src/nwnss/zlss/zlssCmdline.c | 249 +- src/nwnss/zlss/zlssConsumer.c | 920 ++ src/nwnss/zlss/zlssConsumer.h | 124 +- src/nwnss/zlss/zlssDev.c | 41 +- src/nwnss/zlss/zlssIOPerformance.c | 79 +- src/nwnss/zlss/zlssIOPerformance.h | 4 +- src/nwnss/zlss/zlssLKM.c | 245 + src/nwnss/zlss/zlssLSSOps.c | 1924 ++++ src/nwnss/zlss/zlssLVAIPU.c | 702 +- src/nwnss/zlss/zlssLogicalVolume.c | 2459 +++-- src/nwnss/zlss/zlssLogicalVolume.h | 1594 ++-- src/nwnss/zlss/zlssMSAP.c | 167 +- src/nwnss/zlss/zlssMSAP.h | 368 +- src/nwnss/zlss/zlssManage.c | 403 +- src/nwnss/zlss/zlssManage.h | 132 +- src/nwnss/zlss/zlssModules.mk | 385 + src/nwnss/zlss/zlssNLM.c | 195 + src/nwnss/zlss/zlssStartup.c | 554 ++ src/nwnss/zlss/zlssStartup.h | 102 +- src/nwnss/zlss/zlssStorPool.c | 17 +- src/nwnss/zlss/zlssUpgrade.c | 792 +- src/nwnss/zlss/zlssUpgrade.h | 80 +- src/nwnss/zlss/zlssVersion.c | 2 +- src/nwnss/zlss/zstoreConfig.c | 8 +- src/nwnss/zlss/zstoreConfig.h | 46 +- 886 files changed, 178797 insertions(+), 52491 deletions(-) create mode 100644 include/nwnss/comnSA/intmem.h create mode 100644 include/nwnss/include/Moab.imp create mode 100644 include/nwnss/include/WithMPKSpinLock.h delete mode 100644 include/nwnss/include/adminVolume.h create mode 100644 include/nwnss/include/admindrv.h create mode 100644 include/nwnss/include/afpAuthInfo.h delete mode 100644 include/nwnss/include/cduncomp.h create mode 100644 include/nwnss/include/cifs.imp create mode 100644 include/nwnss/include/cifsAuth.h create mode 100644 include/nwnss/include/cifsAuthp.h create mode 100644 include/nwnss/include/cifsManage.h create mode 100644 include/nwnss/include/cifsMemChunk.h create mode 100644 include/nwnss/include/cifsPdc.h create mode 100644 include/nwnss/include/cifsPdcp.h create mode 100644 include/nwnss/include/cifsStypes.h mode change 100644 => 100755 include/nwnss/include/comnMacShortName.h create mode 100644 include/nwnss/include/dbgView.h create mode 100644 include/nwnss/include/dfi.h create mode 100644 include/nwnss/include/dfsLib.h create mode 100644 include/nwnss/include/dfsLib.imp create mode 100644 include/nwnss/include/dfsnds.h create mode 100644 include/nwnss/include/http.imp create mode 100644 include/nwnss/include/ipuAccess.h create mode 100644 include/nwnss/include/jsdebug.h create mode 100644 include/nwnss/include/jsmsgMessageMgmt.h create mode 100644 include/nwnss/include/jsmsgPresInt.h create mode 100644 include/nwnss/include/jsmsgPresentation.h create mode 100644 include/nwnss/include/jsmsgSessInt.h create mode 100644 include/nwnss/include/jsmsgSession.h create mode 100644 include/nwnss/include/linuxmpk.h create mode 100644 include/nwnss/include/manageNDS.h create mode 100644 include/nwnss/include/managePool.h rename include/nwnss/include/{comnAudit.h => manageServer.h} (66%) create mode 100644 include/nwnss/include/manageUserSpaceRestr.h create mode 100644 include/nwnss/include/manageVolume.h create mode 100644 include/nwnss/include/mdb_dev.h create mode 100644 include/nwnss/include/mpk.h create mode 100644 include/nwnss/include/mpkatomic.h create mode 100644 include/nwnss/include/mpkerrno.h create mode 100644 include/nwnss/include/mpkmisc.h create mode 100644 include/nwnss/include/mpkutil.h delete mode 100644 include/nwnss/include/name.h create mode 100644 include/nwnss/include/napi.h delete mode 100644 include/nwnss/include/ndp_app.h create mode 100644 include/nwnss/include/nebprivate.h delete mode 100644 include/nwnss/include/nebpub.h create mode 100644 include/nwnss/include/nssCOMN.imp create mode 100644 include/nwnss/include/nssLOADER.imp create mode 100644 include/nwnss/include/nssMAL.imp create mode 100644 include/nwnss/include/nssMANAGE.imp create mode 100644 include/nwnss/include/nssRegistration.h create mode 100644 include/nwnss/include/nssZLSS.imp create mode 100644 include/nwnss/include/nsskr.h create mode 100644 include/nwnss/include/ntlib.h create mode 100644 include/nwnss/include/nwcommon.h create mode 100644 include/nwnss/include/nwcore.h delete mode 100644 include/nwnss/include/objectIDStore.h create mode 100644 include/nwnss/include/osmpkhdrs.h delete mode 100644 include/nwnss/include/pssConfig.h create mode 100644 include/nwnss/include/risupprt.imp create mode 100644 include/nwnss/include/sbi.h delete mode 100644 include/nwnss/include/sbsMFL.h create mode 100644 include/nwnss/include/sdBasic.h create mode 100644 include/nwnss/include/sdNSS.h create mode 100644 include/nwnss/include/snp.h create mode 100644 include/nwnss/include/tcpip.imp create mode 100644 include/nwnss/include/threads.imp create mode 100644 include/nwnss/include/unssLOADER.imp create mode 100644 include/nwnss/include/vcu.h create mode 100644 include/nwnss/include/vdbe.h create mode 100644 include/nwnss/include/vdbe.imp create mode 100644 include/nwnss/include/vldb.h create mode 100644 include/nwnss/include/vldb.imp create mode 100644 include/nwnss/include/vldbcfg.h create mode 100644 include/nwnss/include/vldbdefs.h create mode 100644 include/nwnss/include/vldberr.h create mode 100644 include/nwnss/include/vldbmsg.h create mode 100644 include/nwnss/include/vldbrpr.h create mode 100644 include/nwnss/include/vlrpc.h create mode 100644 include/nwnss/include/vlrpc.imp create mode 100644 include/nwnss/include/vlrprif.h create mode 100644 include/nwnss/include/vmrpc.h create mode 100644 include/nwnss/include/vmrpc.imp create mode 100644 include/nwnss/include/volman.h create mode 100644 include/nwnss/include/volmnmsg.h create mode 100644 include/nwnss/include/volsms.h create mode 100644 include/nwnss/include/ws2nlm.imp create mode 100644 include/nwnss/include/zapi_library.h delete mode 100644 include/nwnss/internal/NssPageRuntime.h delete mode 100644 include/nwnss/internal/NssUaccessRuntime.h rename include/nwnss/{include => internal}/cmCompFile.h (96%) create mode 100644 include/nwnss/internal/jio.imp create mode 100644 include/nwnss/internal/jni_md.h delete mode 100644 include/nwnss/internal/lsaXattrUserspace.h delete mode 100644 include/nwnss/internal/macNSpaceUserspace.h create mode 100644 include/nwnss/internal/mediaManager.imp rename include/nwnss/{include => internal}/nssOSAPIs.h (98%) delete mode 100644 include/nwnss/internal/nssSourceCompat.h delete mode 100644 include/nwnss/internal/nssUnicodeUserspace.h delete mode 100644 include/nwnss/internal/nssUserspaceProvider.h delete mode 100644 include/nwnss/internal/nssUserspaceQuota.h delete mode 100644 include/nwnss/internal/nssZosCompat.h rename include/nwnss/{support/lnxmbINC => internal}/nwInKeys.h (99%) rename include/nwnss/{include => internal}/nwInProc.h (99%) create mode 100644 include/nwnss/internal/rintface.h delete mode 100644 include/nwnss/internal/spinlock.h create mode 100644 include/nwnss/internal/stdio.h rename include/nwnss/{include/seqUpdater.h => internal/time.h} (80%) create mode 100644 include/nwnss/internal/windowAPIs.h create mode 100644 include/nwnss/internal/windows.h rename include/nwnss/{include => internal}/xMsg.h (96%) create mode 100644 include/nwnss/internal/xlss.imp rename include/nwnss/{include => internal}/zasAuthModel.h (97%) delete mode 100644 include/nwnss/internal/zlssDevUserIO.h create mode 100644 include/nwnss/library/clock.h create mode 100644 include/nwnss/library/libNSS.imp create mode 100644 include/nwnss/library/regmodules.h create mode 100644 include/nwnss/library/setjmp.h create mode 100644 include/nwnss/library/sort.h create mode 100644 include/nwnss/library/timeline.h create mode 100644 include/nwnss/library/xSetjmp.h create mode 100644 include/nwnss/public/dfsguids.h create mode 100644 include/nwnss/public/ipc2ncp.h create mode 100644 include/nwnss/public/jsmsg.h create mode 100644 include/nwnss/public/jsmsg.imp create mode 100644 include/nwnss/public/neb.imp create mode 100644 include/nwnss/public/psa.imp create mode 100644 include/nwnss/public/psaPublic.h create mode 100644 include/nwnss/public/uneb.h create mode 100644 include/nwnss/public/virtualIO.imp create mode 100644 include/nwnss/public/zPool.imp create mode 100644 include/nwnss/public/zPublics.imp delete mode 100644 include/nwnss/support/lnxmbINC/aesproc.h delete mode 100644 include/nwnss/support/lnxmbINC/alert.h delete mode 100644 include/nwnss/support/lnxmbINC/bindery.h delete mode 100644 include/nwnss/support/lnxmbINC/bits.h delete mode 100644 include/nwnss/support/lnxmbINC/command.h delete mode 100644 include/nwnss/support/lnxmbINC/config.h delete mode 100644 include/nwnss/support/lnxmbINC/connect.h delete mode 100644 include/nwnss/support/lnxmbINC/connexp.h delete mode 100644 include/nwnss/support/lnxmbINC/doscalls.h delete mode 100644 include/nwnss/support/lnxmbINC/enable.h delete mode 100644 include/nwnss/support/lnxmbINC/encp.h delete mode 100644 include/nwnss/support/lnxmbINC/errors.h delete mode 100644 include/nwnss/support/lnxmbINC/event.h delete mode 100644 include/nwnss/support/lnxmbINC/fshooks.h delete mode 100644 include/nwnss/support/lnxmbINC/fsproto.h delete mode 100644 include/nwnss/support/lnxmbINC/ins.h delete mode 100644 include/nwnss/support/lnxmbINC/lanconf.h delete mode 100644 include/nwnss/support/lnxmbINC/lfsproto.h delete mode 100644 include/nwnss/support/lnxmbINC/loader.h delete mode 100644 include/nwnss/support/lnxmbINC/maapi.h delete mode 100644 include/nwnss/support/lnxmbINC/manss.h delete mode 100644 include/nwnss/support/lnxmbINC/masv.h delete mode 100644 include/nwnss/support/lnxmbINC/mmpublic.h delete mode 100644 include/nwnss/support/lnxmbINC/modify.h delete mode 100644 include/nwnss/support/lnxmbINC/mpktypes.h delete mode 100644 include/nwnss/support/lnxmbINC/nameserv.h delete mode 100644 include/nwnss/support/lnxmbINC/nmevents.h delete mode 100644 include/nwnss/support/lnxmbINC/nspace.h delete mode 100644 include/nwnss/support/lnxmbINC/nwreg.h delete mode 100644 include/nwnss/support/lnxmbINC/portable.h delete mode 100644 include/nwnss/support/lnxmbINC/procdefs.h delete mode 100644 include/nwnss/support/lnxmbINC/scs.h delete mode 100644 include/nwnss/support/lnxmbINC/setparms.h delete mode 100644 include/nwnss/support/lnxmbINC/subjects.h delete mode 100644 include/nwnss/support/lnxmbINC/task.h delete mode 100644 include/nwnss/support/lnxmbINC/version.h delete mode 100644 include/nwnss/support/lnxmbINC/volstruc.h delete mode 100644 include/nwnss/support/ndssdkINC_kern/dconst.h delete mode 100644 include/nwnss/support/ndssdkINC_kern/dtypes.h delete mode 100644 include/nwnss/support/ndssdkINC_kern/nwdserr.h create mode 100644 src/nwnss/Makefile create mode 100644 src/nwnss/admindrv/Makefile create mode 100644 src/nwnss/admindrv/Module.supported create mode 100644 src/nwnss/admindrv/admindrvLKM.c create mode 100644 src/nwnss/admindrv/admindrvModules.mk create mode 100644 src/nwnss/comn/Makefile create mode 100644 src/nwnss/comn/Module.supported rename {include => src}/nwnss/comn/aes.h (97%) rename {include => src}/nwnss/comn/aes/aes_locl.h (99%) rename {include/nwnss/include => src/nwnss/comn/authsys}/unixAuthSpace.h (98%) rename {include/nwnss/include => src/nwnss/comn/authsys}/zasAuthSpace.h (98%) rename {include => src}/nwnss/comn/checker.h (100%) create mode 100644 src/nwnss/comn/common/adminVolFile.c create mode 100644 src/nwnss/comn/common/authBeast.c rename {include/nwnss/include => src/nwnss/comn/common}/avolSimpleDir.h (97%) rename {include => src}/nwnss/comn/common/beastClass.h (98%) create mode 100644 src/nwnss/comn/common/beastStartup.c rename {include => src}/nwnss/comn/common/beastStartup.h (99%) create mode 100644 src/nwnss/comn/common/comnDSI.c rename {include/nwnss/include => src/nwnss/comn/common}/csaLease.h (99%) create mode 100644 src/nwnss/comn/common/csaManage.c create mode 100644 src/nwnss/comn/common/csaManage.h create mode 100644 src/nwnss/comn/common/fileBeast.c create mode 100644 src/nwnss/comn/common/nameScanDebug.c create mode 100644 src/nwnss/comn/common/namedBeast.c create mode 100644 src/nwnss/comn/common/restartCount.c create mode 100644 src/nwnss/comn/common/rootBeast.c rename {include/nwnss/include => src/nwnss/comn/common}/sazlib.h (99%) mode change 100644 => 100755 src/nwnss/comn/common/seqUpdater.c create mode 100644 src/nwnss/comn/common/volBeast.c create mode 100644 src/nwnss/comn/common/zFriends.c create mode 100644 src/nwnss/comn/common/zPublics.c rename {include/nwnss/comn/main => src/nwnss/comn}/comnAudit.h (99%) rename {include => src}/nwnss/comn/comnCmdline.h (96%) create mode 100644 src/nwnss/comn/comnModules.mk rename {include/nwnss/include => src/nwnss/comn/compression}/cdcommon.h (79%) rename {include/nwnss/include => src/nwnss/comn/compression}/cdcomp.h (84%) rename {include/nwnss/include => src/nwnss/comn/compression}/cdnetwar.h (94%) rename {include/nwnss/include => src/nwnss/comn/compression}/cdreada.h (96%) create mode 100644 src/nwnss/comn/compression/cduncomp.h rename {include/nwnss/include => src/nwnss/comn/compression}/cmActivity.h (96%) rename {include/nwnss/include => src/nwnss/comn/compression}/cmRuntime.h (98%) create mode 100644 src/nwnss/comn/compression/copyAlgo.c rename {include/nwnss/include => src/nwnss/comn/compression}/nwAlgo.h (98%) rename {include/nwnss/include => src/nwnss/comn}/cro.h (99%) rename {include/nwnss/include => src/nwnss/comn}/csa.h (95%) create mode 100644 src/nwnss/comn/main/comnLKM.c create mode 100644 src/nwnss/comn/main/comnsaSDKSym.c create mode 100644 src/nwnss/comn/main/marshal.c create mode 100644 src/nwnss/comn/main/nssCOMNSym.c create mode 100644 src/nwnss/comn/main/pssNLM.c create mode 100644 src/nwnss/comn/main/pssStartup.c create mode 100644 src/nwnss/comn/main/qdiv.c create mode 100644 src/nwnss/comn/main/unssCOMNSym.c create mode 100644 src/nwnss/comn/main/xlssSym.c create mode 100644 src/nwnss/comn/main/zPoolSym.c create mode 100644 src/nwnss/comn/main/zPublicsSym.c rename {include => src}/nwnss/comn/nameScan.h (99%) rename {include => src}/nwnss/comn/namespace/dataStreamNSpace.h (98%) rename {include => src}/nwnss/comn/namespace/dosNSpace.h (97%) rename {include => src}/nwnss/comn/namespace/extAttrNSpace.h (98%) rename {include => src}/nwnss/comn/namespace/longNSpace.h (98%) rename {include => src}/nwnss/comn/namespace/nspaceStartup.h (98%) rename {include => src}/nwnss/comn/pssStartup.h (98%) rename {include/nwnss/include => src/nwnss/comn}/purgeDir.h (100%) rename {include/nwnss/comn/main => src/nwnss/comn}/seqUpdater.h (100%) rename {include/nwnss/include => src/nwnss/comn}/zasAuthCache.h (98%) create mode 100644 src/nwnss/library/Makefile create mode 100644 src/nwnss/library/Module.supported create mode 100644 src/nwnss/library/debug/DebugHexDump.c create mode 100644 src/nwnss/library/debug/DebugPrintf.c create mode 100644 src/nwnss/library/debug/assert.c create mode 100644 src/nwnss/library/debug/dbgerror.c create mode 100644 src/nwnss/library/debug/dbgfatal.c create mode 100644 src/nwnss/library/debug/dbginit.c create mode 100644 src/nwnss/library/debug/dfi.c create mode 100644 src/nwnss/library/debug/enterDebug.c create mode 100644 src/nwnss/library/debug/ncpTrAsm.386 create mode 100644 src/nwnss/library/debug/ncpTrace.c create mode 100644 src/nwnss/library/debug/sdBasic.c create mode 100644 src/nwnss/library/debug/sdNSS.c create mode 100644 src/nwnss/library/debug/snp.c create mode 100644 src/nwnss/library/debug/warn.c create mode 100644 src/nwnss/library/eDir/getDSGuid.c rename {include => src}/nwnss/library/intlatch.h (98%) create mode 100644 src/nwnss/library/libraryLKM.c create mode 100644 src/nwnss/library/libraryModules.mk create mode 100644 src/nwnss/library/libraryVersion.c create mode 100644 src/nwnss/library/linux/napiFormatDateAndTime.c create mode 100644 src/nwnss/library/linux/napiUnitTests.c create mode 100644 src/nwnss/library/misc/.cvsignore create mode 100644 src/nwnss/library/misc/GetInstLen.c create mode 100644 src/nwnss/library/misc/NW_NCPFuncBoundaryError.c create mode 100644 src/nwnss/library/misc/NW_NCPLengthError.c create mode 100644 src/nwnss/library/misc/NW_NCPSubFuncLengthError.c create mode 100644 src/nwnss/library/misc/NW_WriteBranchTableEntry.c create mode 100644 src/nwnss/library/misc/timeline.c create mode 100644 src/nwnss/library/nssLIBRARYSym.c create mode 100644 src/nwnss/library/os/ZOS_IsNLMLoaded.c create mode 100644 src/nwnss/library/os/aeswork.c create mode 100644 src/nwnss/library/os/crthread.c create mode 100644 src/nwnss/library/stdio/getchar.c create mode 100644 src/nwnss/library/stdio/gets.c rename {include => src}/nwnss/library/stdio/snprintf.h (99%) rename {include/nwnss => src/nwnss/library}/unicodeInit.h (97%) create mode 100644 src/nwnss/library/unssLIBRARYSym.c create mode 100644 src/nwnss/library/utc/default.dsc create mode 100644 src/nwnss/library/utc/gethres.386 rename {include/nwnss => src/nwnss/library}/utcData.h (98%) create mode 100644 src/nwnss/library/wio/wSetStdio.c create mode 100644 src/nwnss/library/wio/wactivate.c create mode 100644 src/nwnss/library/wio/wcenter.c rename include/nwnss/include/nameScan.h => src/nwnss/library/wio/wclose.c (60%) create mode 100644 src/nwnss/library/wio/wclrscr.c create mode 100644 src/nwnss/library/wio/wgetc.c create mode 100644 src/nwnss/library/wio/wgetdim.c create mode 100644 src/nwnss/library/wio/wgets.c create mode 100644 src/nwnss/library/wio/wlock.c create mode 100644 src/nwnss/library/wio/wopen.c create mode 100644 src/nwnss/library/wio/wpromptYesNo.c create mode 100644 src/nwnss/library/wio/wsyncin.c create mode 100644 src/nwnss/lsa/Makefile create mode 100644 src/nwnss/lsa/Module.supported create mode 100644 src/nwnss/lsa/lsa.c create mode 100644 src/nwnss/lsa/lsaAid.h create mode 100644 src/nwnss/lsa/lsaCmdline.c create mode 100644 src/nwnss/lsa/lsaLKM.c create mode 100644 src/nwnss/lsa/lsaModules.mk create mode 100644 src/nwnss/lsa/lsaNSSKR.c rename {include => src}/nwnss/lsa/lsaPrivate.h (98%) create mode 100644 src/nwnss/lsa/lsaStartup.c rename {include => src}/nwnss/lsa/lsaStartup.h (100%) create mode 100644 src/nwnss/lsa/lsaSuper.c create mode 100644 src/nwnss/lsa/lsaSuperPool.c create mode 100644 src/nwnss/lsa/lsaSuperVol.c create mode 100644 src/nwnss/lsa/lsaVersion.c create mode 100644 src/nwnss/manage/Makefile create mode 100644 src/nwnss/manage/Module.supported create mode 100644 src/nwnss/manage/manage.c create mode 100644 src/nwnss/manage/manageAFP.c create mode 100644 src/nwnss/manage/manageAdapter.c create mode 100644 src/nwnss/manage/manageCmdline.c create mode 100644 src/nwnss/manage/manageFile.c create mode 100644 src/nwnss/manage/manageLKM.c create mode 100644 src/nwnss/manage/manageLinux.c create mode 100644 src/nwnss/manage/manageModules.mk create mode 100644 src/nwnss/manage/manageNDS.c create mode 100644 src/nwnss/manage/manageNLM.c create mode 100644 src/nwnss/manage/managePartition.c create mode 100644 src/nwnss/manage/managePool.c create mode 100644 src/nwnss/manage/manageServer.c create mode 100644 src/nwnss/manage/manageStartup.c create mode 100644 src/nwnss/manage/manageStartup.h create mode 100644 src/nwnss/manage/manageUserSpaceRestr.c create mode 100644 src/nwnss/manage/manageUserSpaceRestr.h create mode 100644 src/nwnss/manage/manageVcu.c create mode 100644 src/nwnss/manage/manageVersion.c create mode 100644 src/nwnss/manage/manageVolMN.c create mode 100644 src/nwnss/manage/manageVolume.c create mode 100644 src/nwnss/manage/nssMANAGESym.c create mode 100644 src/nwnss/ndpmod/Makefile create mode 100644 src/nwnss/ndpmod/Module.supported create mode 100644 src/nwnss/ndpmod/NDPDEBUG.NOTES create mode 100644 src/nwnss/ndpmod/ndp_comn.c create mode 100644 src/nwnss/ndpmod/ndp_guids.c create mode 100644 src/nwnss/ndpmod/ndp_idbroker.c create mode 100644 src/nwnss/ndpmod/ndp_messagehandler.c create mode 100644 src/nwnss/ndpmod/ndp_mod.c create mode 100644 src/nwnss/ndpmod/ndp_mod.h create mode 100644 src/nwnss/ndpmod/ndpmodModules.mk create mode 100644 src/nwnss/ndpmod/ndpmodVersion.c create mode 100644 src/nwnss/nebdrv/Makefile create mode 100644 src/nwnss/nebdrv/Module.supported create mode 100644 src/nwnss/nebdrv/nebdrvModules.mk create mode 100644 src/nwnss/nebdrv/nebdrvVersion.c create mode 100644 src/nwnss/nebdrv/unebdrvLKM.c create mode 100644 src/nwnss/nebdrv/unebserv.c create mode 100644 src/nwnss/nss/Makefile create mode 100644 src/nwnss/nss/Module.supported create mode 100644 src/nwnss/nss/dbgView.c create mode 100644 src/nwnss/nss/nssCmdline.c create mode 100644 src/nwnss/nss/nssLKM.c create mode 100644 src/nwnss/nss/nssLoadNLMs.c create mode 100644 src/nwnss/nss/nssLog.c create mode 100644 src/nwnss/nss/nssModules.mk create mode 100644 src/nwnss/nss/nssNLM.c create mode 100644 src/nwnss/nss/nssNSSSym.c create mode 100644 src/nwnss/nss/nssRegistration.c create mode 100644 src/nwnss/nss/nssStartup.c create mode 100644 src/nwnss/nss/nssStartup.h create mode 100644 src/nwnss/nss/nssVersion.c create mode 100644 src/nwnss/nss/setcmd.h create mode 100644 src/nwnss/nss/setcmd/setcmd.c create mode 100644 src/nwnss/nss/trustees.xml create mode 100644 src/nwnss/nss/unssNSSSym.c create mode 100644 src/nwnss/nsslnxlib/Makefile create mode 100644 src/nwnss/nsslnxlib/Module.supported create mode 100644 src/nwnss/nsslnxlib/allocRTag.c create mode 100644 src/nwnss/nsslnxlib/kfile.c create mode 100644 src/nwnss/nsslnxlib/kfile.h create mode 100644 src/nwnss/nsslnxlib/microSecondTimer.c create mode 100644 src/nwnss/nsslnxlib/nssLnxDummy.c create mode 100644 src/nwnss/nsslnxlib/nssLnxLib.h create mode 100644 src/nwnss/nsslnxlib/nssLnxLibLKM.c create mode 100644 src/nwnss/nsslnxlib/nssNSSLNXLIBSym.c create mode 100644 src/nwnss/nsslnxlib/nsslnxlibModules.mk create mode 100644 src/nwnss/nsslnxlib/nsslnxlibVersion.c rename {include => src}/nwnss/nsslnxlib/nssunilib.h (72%) create mode 100644 src/nwnss/nsslnxlib/procdefslnx.c rename include/nwnss/support/lnxmbINC/locks.h => src/nwnss/nsslnxlib/unssNSSLNXLIBSym.c (58%) create mode 100644 src/nwnss/nwraid/Makefile create mode 100644 src/nwnss/nwraid/Module.supported create mode 100644 src/nwnss/nwraid/dmio.c create mode 100644 src/nwnss/nwraid/dmio.h create mode 100644 src/nwnss/nwraid/nwraid.h create mode 100644 src/nwnss/nwraid/nwraid0.c create mode 100644 src/nwnss/nwraid/nwraid1.c create mode 100644 src/nwnss/nwraid/nwraid5.c create mode 100644 src/nwnss/nwraid/nwraidModules.mk create mode 100644 src/nwnss/sharedsrc/README create mode 100644 src/nwnss/sharedsrc/getDSGuid.c.h create mode 100644 src/nwnss/sharedsrc/manage.c.h create mode 100644 src/nwnss/sharedsrc/manageDevice.c.h create mode 100644 src/nwnss/sharedsrc/manageNDS.c.h create mode 100644 src/nwnss/sharedsrc/managePartition.c.h create mode 100644 src/nwnss/sharedsrc/managePool.c.h create mode 100644 src/nwnss/sharedsrc/manageRAID.c.h create mode 100644 src/nwnss/sharedsrc/manageServer.c.h create mode 100644 src/nwnss/sharedsrc/manageUserSpaceRestr.c.h create mode 100644 src/nwnss/sharedsrc/manageVolume.c.h create mode 100644 src/nwnss/zlss/Makefile create mode 100644 src/nwnss/zlss/Module.supported create mode 100644 src/nwnss/zlss/nssZLSSSym.c create mode 100644 src/nwnss/zlss/qdiv.c create mode 100644 src/nwnss/zlss/sbi.c create mode 100644 src/nwnss/zlss/sbiNT.c create mode 100644 src/nwnss/zlss/sdZLSS.c create mode 100644 src/nwnss/zlss/z_aes_cbc.c create mode 100644 src/nwnss/zlss/z_aes_core.c create mode 100644 src/nwnss/zlss/zedExport.c create mode 100644 src/nwnss/zlss/zlogDebug.c create mode 100644 src/nwnss/zlss/zlogUnitTest.c create mode 100644 src/nwnss/zlss/zlssConsumer.c create mode 100644 src/nwnss/zlss/zlssLKM.c create mode 100644 src/nwnss/zlss/zlssLSSOps.c create mode 100644 src/nwnss/zlss/zlssModules.mk create mode 100644 src/nwnss/zlss/zlssNLM.c create mode 100644 src/nwnss/zlss/zlssStartup.c diff --git a/include/nwnss/comnSA/comnDataStream.h b/include/nwnss/comnSA/comnDataStream.h index 2aaec34..a91748b 100644 --- a/include/nwnss/comnSA/comnDataStream.h +++ b/include/nwnss/comnSA/comnDataStream.h @@ -53,11 +53,11 @@ extern "C" { * streams, this structure will never be present. However, if the file beast * does have extended attributes or data streams, this structure will be * allocated when the first attempt is made to access this information. - * + * * The first attempt to read or modify the data stream info will detect * that dataStreamCount == DSI_COUNT_INVALID, and will calculate at that time - * the correct data stream counts and sizes. All subsequent attempts to - * read or modify the info will modify it directly. + * the correct data stream counts and sizes. All subsequent attempts to + * read or modify the info will modify it directly. * * Likewise, the extended attribute info is handled the same way. * diff --git a/include/nwnss/comnSA/comnLock.h b/include/nwnss/comnSA/comnLock.h index 9d507d1..a5f15e9 100644 --- a/include/nwnss/comnSA/comnLock.h +++ b/include/nwnss/comnSA/comnLock.h @@ -24,11 +24,11 @@ | |--------------------------------------------------------------------------- | - | $Author: taysom $ - | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ | | $RCSfile$ - | $Revision: 465 $ + | $Revision: 465 $ | |--------------------------------------------------------------------------- | This module is used to: @@ -45,19 +45,19 @@ #define _COMNLOCK_H_ #ifndef _OMNI_H -#include +#include #endif #ifndef _RBPTREE_H_ -#include +#include #endif #ifndef _COMNBEASTS_H_ -#include +#include #endif #ifndef _PSSCONNECTION_H_ -#include +#include #endif #ifdef __cplusplus @@ -222,7 +222,7 @@ BOOL LOCK_IsExclusiveByteRange ( QUAD length); BOOL LOCK_IsExclusiveByteRangeMandatory ( - NamedBeast_s *beast, + NamedBeast_s *beast, QUAD start, QUAD length); @@ -262,7 +262,7 @@ ByteRangeLock_s *allocByteRangeLock ( BOOL checkDeadLockByFH( - FileHandle_s *waiter, + FileHandle_s *waiter, FileHandle_s *holder, BOOL setWaitFor); @@ -297,19 +297,19 @@ extern STATUS LOCK_Startup(void); extern void LOCK_Shutdown(void); extern Lock_s *COMN_LookupLock( - BYTE *key, + BYTE *key, NINT keyBytes, - BOOL allocIfNotThere); + BOOL allocIfNotThere); extern BOOL COMN_LockFunc( - BYTE *key, - NINT keyBytes, - NINT mode, + BYTE *key, + NINT keyBytes, + NINT mode, SLONG msecs); extern void COMN_UnLockFunc( - BYTE *key, - NINT keyBytes); + BYTE *key, + NINT keyBytes); diff --git a/include/nwnss/comnSA/contextHandle.h b/include/nwnss/comnSA/contextHandle.h index 794113d..fbbb8f5 100644 --- a/include/nwnss/comnSA/contextHandle.h +++ b/include/nwnss/comnSA/contextHandle.h @@ -44,11 +44,11 @@ #define _CONTEXTHANDLE_H_ #ifndef _OMNI_H_ -#include +#include #endif #ifndef _COMNPARAMS_H_ -#include +#include #endif #ifdef __cplusplus diff --git a/include/nwnss/comnSA/fileHandle.h b/include/nwnss/comnSA/fileHandle.h index abe74c5..c981fe2 100644 --- a/include/nwnss/comnSA/fileHandle.h +++ b/include/nwnss/comnSA/fileHandle.h @@ -33,7 +33,7 @@ |--------------------------------------------------------------------------- | This module is used to: | This defines the interfaces into the PSS portion of the connection - | structure. + | structure. | | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! | @@ -45,23 +45,23 @@ #define _FILEHANDLE_H_ #ifndef _COMNPARAMS_H_ -#include +#include #endif #ifndef _NSS_MSG_H_ -#include +#include #endif #ifndef _FSMSG_H_ -#include +#include #endif #ifndef _UTC_H_ -#include +#include #endif #ifndef _HARDLINK_H_ -#include +#include #endif #ifdef __cplusplus @@ -89,7 +89,7 @@ struct FileHandle_s HardLinkBeast_s *hlFile; /* if non-zero, pointer to hardlink beast that was parsed while opening this file */ NamedBeast_s *dataStream; /* the dataStream ptr for the open file */ RootBeast_s *compBeast; /* Compressed beast for this datastream - * Valid only when reading/writing compressed + * Valid only when reading/writing compressed * stream */ Zid_t fileParentZid; /* The ZID of the file's parent container */ NINT fileNameUniquifier; /* Name uniquifier for the dirFile */ @@ -102,9 +102,9 @@ struct FileHandle_s BYTE dataStreamNameSpaceID; /* the nameSpace the dataStream was opened in*/ BYTE dataStreamNameType; /* The nameType the dataStream was opened in*/ WORD fhState; /* state of the fileHandle */ - WORD parentIsImmCompress; /* Immediate Compress flag is set on + WORD parentIsImmCompress; /* Immediate Compress flag is set on * parent Directory */ -// WORD cm_closeAction; /* Compression-related action to perform +// WORD cm_closeAction; /* Compression-related action to perform // * on COMN_Close; Opcodes in cmNSS.h */ VirtInfo_s *virtInfo; /* pointer to info for a virtual file */ NSSConnection_s *pssConn; /* pss connection structure pointer */ @@ -121,12 +121,12 @@ struct FileHandle_s DQhead_t fhWaiters; /* open requests that is blocked because of */ /* conflicting file lock held by this handle*/ struct inode *fh_inode; /* Inode this fh got a count on */ - struct CROAccessLease_s *FH_accessLease; /* If volume is a slave, then - * the access lease that this - * fH is using + struct CROAccessLease_s *FH_accessLease; /* If volume is a slave, then + * the access lease that this + * fH is using */ struct CsaVolumeDoor_s *FH_csaVolObj; /* When on Master and state - * is FH_CFS_OPEN, this + * is FH_CFS_OPEN, this * points to the CSAVolObj * identifying the slave that * that opened this file. @@ -169,9 +169,9 @@ struct FileHandle_s #define FH_CFS_OPEN 0x10 /* The open was done for a CFS slave on * the master. */ -#define FH_CFS_ASYNC_CLOSE 0x20 /* Pre-Close -- decrementing the +#define FH_CFS_ASYNC_CLOSE 0x20 /* Pre-Close -- decrementing the * the grantedRights counts has been - * done synchronously, now do the + * done synchronously, now do the * async part of the close */ @@ -221,7 +221,7 @@ extern BOOL FH_FreeOpenFile( FileHandle_s *fileHandle); extern STATUS FH_SetOpenFileGrantedRights( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, OpenMsg_s *openMsg, FileHandleIDP_s *fhIDP, NINT grantedRights); @@ -279,13 +279,6 @@ void FH_DeleteRights(FileHandle_s *fileHandle); extern Key_t hackKey(Key_t key); -#ifndef KERNEL_VERSION -#define KERNEL_VERSION(_major, _minor, _patch) (((_major) << 16) + ((_minor) << 8) + (_patch)) -#endif -#ifndef LINUX_VERSION_CODE -#define LINUX_VERSION_CODE KERNEL_VERSION(2,6,32) -#endif - #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) #define CONN_KEY(_connNum, _nwHandle) ((((Key_t)(_connNum)) << 32) \ | (_nwHandle)) @@ -305,7 +298,7 @@ extern Key_t hackKey(Key_t key); ((_status) == zERR_CANT_DENY_WRITE_LOCK) || \ ((_status) == zERR_FILE_WRITE_LOCKED)) \ - + #ifdef __cplusplus } #endif diff --git a/include/nwnss/comnSA/intmem.h b/include/nwnss/comnSA/intmem.h new file mode 100644 index 0000000..ac46a04 --- /dev/null +++ b/include/nwnss/comnSA/intmem.h @@ -0,0 +1,322 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: gpachner $ + | $Date: 2005-03-18 23:26:41 +0530 (Fri, 18 Mar 2005) $ + | + | $RCSfile$ + | $Revision: 879 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | THIS FILE IS ONLY USED BY ROUTINES in STDLIB and should NOT be + | included by any routine outside of that. + | + | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + | + | This header file should ONLY be used for NSS internal development. + | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). + | Any other use may cause conflicts which NSS will NOT fix. + +-------------------------------------------------------------------------*/ +#ifndef _INTMEM_H_ +#define _INTMEM_H_ + +//#ifndef _OMNI_H_ +//#include +//#endif +#ifndef _QUE_H_ +#include +#endif +#ifndef _NSS_STRING_H_ +#include +#endif +#ifndef _PSSDEBUG_H_ +#include +#endif +#ifndef _NSS_STDIO_H_ +#include +#endif +#ifndef _UTC_H_ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_MALLOC (64*1024*1024) /* set to 64 MEG */ +#define FILL_PATTERN 0xbad4babe + +/*------------------------------------------------------------------------- + * Macros that control if we should keep our own list of memory that we + * have allocated. + *-------------------------------------------------------------------------*/ + +#if NSS_DEBUG IS_ENABLED + +#define NSS_MEMREPORT_CALLERS 8 /* Number of callers to display + * into debug buffer as the alloc/free + * is called. If more than 8 adjust + * code that displays them. + */ + +extern void GetClosestSymbol(BYTE *buffer, LONG address); +extern NINT NSS_StoreCallers (void **buffer, NINT bufferCount, SNINT skipCount); +extern BOOL MKL_Symbols; + +#ifdef IAPX386 +#define GET_RETURN_ADDR(to,firstParam) ((to) = ((LONG *)&(firstParam))[-1]) +#else +#define GET_RETURN_ADDR(to,firstParam) ((to) = 0) +#endif + +#endif + +#if MEM_KEEP_LIST IS_ENABLED + + +#define NSS_MKL_CALLERS 7 /* Number of callers to store into + * MKL for later viewing. + */ +extern BOOL MKL_ImmediateFree; +extern BOOL MKL_FreeScheduled; +extern BOOL MKL_StoreCallers; + +extern QUAD MKL_Insert; +extern QUAD MKL_Remove; +extern QUAD MKL_FreeToNSS; +extern QUAD MKL_FreeToOS; + +/* + * As of Oct 2002, this structure has been moved from the end of a user's + * block of memory to in front of the memory. This way if the user frees + * the memory via the OS directly they will get an error. + * You need to have "set alloc memory check flag = on" for the OS to detect + * the improper free. + * + */ +typedef struct MKL_Header_s { + DQlink_t MH_link; + BYTE MH_allocCallersNumber; + BYTE MH_freeCallersNumber; + WORD MH_Reserved; + Time_t MH_allocTime; + Time_t MH_freeTime; + void* MH_allocCallers[NSS_MKL_CALLERS]; + void* MH_freeCallers[NSS_MKL_CALLERS]; + LONG MH_signature; /* At end as more likily to be poked */ +#define MKL_SIGN_ALLOC 0x56415656 /* "VAVV" */ +#define MKL_SIGN_FREE 0x57465757 /* "WFWW" */ +} MKL_Header_s; + +extern DQhead_t MKL_head; +extern DQhead_t MKL_FreeHead; + +void MKL_AllocStart( void ); +void MKL_AllocStop( void ); + +#define UMEM_TO_MKL(_uMem) ( (void *)(((ADDR)(_uMem)) - sizeof(MKL_Header_s) ) ) +#define MKL_TO_UMEM(_mkl) ( (void *)(((ADDR)(_mkl)) + sizeof(MKL_Header_s) ) ) +#define MKL_NEW_SIZE(size) ((size) + sizeof(MKL_Header_s)) +#define MKL_ORIG_SIZE(size) ((size) - sizeof(MKL_Header_s)) +#define MKL_INSERT(__mkl, _firstParam) \ +{ \ + MKL_Header_s *_mkl = (MKL_Header_s *)(__mkl); \ + zASSERT( _mkl != 0 ); \ + bzero( _mkl, sizeof( *_mkl ) ); \ + NULLIFY( &_mkl->MH_link ); \ + _mkl->MH_signature = MKL_SIGN_ALLOC; \ + _mkl->MH_Reserved = (WORD)MKL_SIGN_ALLOC; \ + _mkl->MH_allocTime = GetUTCTime(); \ + DQ_ENQ(&MKL_head,_mkl,MH_link); \ + ++MKL_Insert; \ + if ( MKL_StoreCallers ) \ + { \ + _mkl->MH_allocCallersNumber = 0;\ + } \ + else \ + { \ + _mkl->MH_freeCallersNumber = 0; \ + } \ +} + +/* + * Oct 2002, no longer FILL_PATTERN MKL part of block. This was + * done to aid in debugging when OS catches someone writing to + * freed memory. In this case we should still have our caller + * information stored. + */ +#define MKL_REMOVE(_uMem) \ +{ \ + NINT _length; \ + MKL_Header_s *_mkl = (MKL_Header_s *)((ADDR)(_uMem) - \ + sizeof(MKL_Header_s)); \ + \ + zASSERT( _uMem != 0 ); \ + zASSERT( _mkl->MH_signature == MKL_SIGN_ALLOC ); \ + _length = MKL_ORIG_SIZE(SizeOfAllocBlock(_mkl)); \ + DQ_RMV(_mkl,MH_link); \ + ++MKL_Remove; \ + _mkl->MH_freeTime = GetUTCTime(); \ + _mkl->MH_signature = MKL_SIGN_FREE; \ + if ( MKL_StoreCallers ) \ + { \ + _mkl->MH_freeCallersNumber = 0;\ + } \ + else \ + { \ + _mkl->MH_freeCallersNumber = 0; \ + } \ + memlset((_uMem),FILL_PATTERN,(_length/sizeof(LONG))); \ +} + +/* + * MKL_FREE - + * Will either free the memory directly to the OS or place + * on the MKL_FreeHead list so that it can be freed in a little bit. + */ +#define MKL_FREE(__mkl) \ +{ \ + MKL_Header_s *_mkl = (MKL_Header_s *)__mkl; \ + zASSERT( _mkl->MH_signature == MKL_SIGN_FREE ); \ + if ( MKL_ImmediateFree ) \ + { \ + ZOS_Free(_mkl) \ + } \ + else \ + { \ + DQ_ENQ( &MKL_FreeHead, _mkl, MH_link ); \ + ++MKL_FreeToNSS; \ + } \ + /* Wierd check to handle setting of MKL_ImmediateFree to TRUE */ \ + if ( (DQ_NOT_EMPTY( &MKL_FreeHead )) && (!MKL_FreeScheduled) ) \ + { \ + MKL_ScheduleFree(); \ + } \ +} + +extern void LB_CHECK_FREE_LIST(void); + + +#else /* MEM_KEEP_LIST IS_DISABLED*/ + +#define UMEM_TO_MKL(_uMem) (_uMem) +#define MKL_NEW_SIZE(size) (size) +#define MKL_TO_UMEM(_mkl) (_mkl) +#define MKL_ORIG_SIZE(size) (size) +#define MKL_OLD_SIZE(size) (size) +#define MKL_INSERT(mem,firstParam) ((void)0) +#if NSS_DEBUG IS_ENABLED +# define MKL_REMOVE(_uMem) \ + { \ + memlset((_uMem),FILL_PATTERN,(SizeOfAllocBlock(_uMem)/sizeof(LONG))); \ + } +#else +# define MKL_REMOVE(_uMem) ((void)0) +#endif + +#define MKL_FREE(_mkl) ZOS_Free(_mkl) +#define LB_CHECK_FREE_LIST() ((void)0) + +#endif /* MEM_KEEP_LIST IS_DISABLED*/ + + +/**************************************************************************** + * Report memory usage + *****************************************************************************/ +#define MALLOC_TRACE ENABLE + +extern BOOL MallocTraceEnable; + +#if MALLOC_TRACE IS_ENABLED && NSS_DEBUG IS_ENABLED + + +extern void LB_MEMORY_DISPLAY_SETUP(void); +extern void LB_MEMORY_DISPLAY_SHUTDOWN(void); + + +#define LB_MEMREPORT(name,_addr,firstParam) \ +{ \ + if (MallocTraceEnable) \ + { \ + NINT length=0; \ + if (_addr != NULL) \ + { \ + length = MKL_ORIG_SIZE(SizeOfAllocBlock(_addr)); \ + } \ + DBG_DebugPrintf(LGRAY,"%s: %08x(%x)\n", name,_addr,length); \ + { \ + NINT index; \ + NINT MH_callersNumber; \ + BYTE buffer[514]; \ + void* MH_callers[NSS_MEMREPORT_CALLERS]; \ + MH_callersNumber = 0;\ + for ( index = 0; index < MH_callersNumber; ++index ) \ + { \ + if ( MKL_Symbols ) \ + { /* This next function is very slow */ \ + DBG_DebugPrintf(LGRAY, MSGNot(" %s"),buffer); \ + } \ + else \ + { \ + DBG_DebugPrintf(LGRAY, MSGNot(" %08x"), \ + MH_callers[index]); \ + } \ + } \ + if ( (!MKL_Symbols) && (MH_callersNumber != 0) ) \ + { \ + DBG_DebugPrintf(LGRAY, "\n"); \ + } \ + } \ + } \ +} + + +#define LB_MEMREPORTPAGE(name,_addr,numPages,firstParam) \ +{ \ + if (MallocTraceEnable) \ + { \ + NINT where; \ + GET_RETURN_ADDR(where,firstParam); \ + DBG_DebugPrintf(LGRAY,"%s: %08x %d where=%08x\n", \ + name,_addr,numPages,where); \ + } \ +} + +#else + +#define LB_MEMORY_DISPLAY_SETUP() ((void)0) +#define LB_MEMORY_DISPLAY_SHUTDOWN() ((void)0) +#define LB_MEMREPORT(name,_addr,firstParam) ((void)0) +#define LB_MEMREPORTPAGE(name,_addr,numPages,firstParam) ((void)0) + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _INTMEM_H_ */ diff --git a/include/nwnss/comnSA/msgLock.h b/include/nwnss/comnSA/msgLock.h index bd87af1..3990bba 100644 --- a/include/nwnss/comnSA/msgLock.h +++ b/include/nwnss/comnSA/msgLock.h @@ -45,11 +45,11 @@ #define _MSGLOCK_H_ #ifndef _OMNI_H_ -#include +#include #endif #ifndef _XLIMITS_H_ -#include +#include #endif #ifdef __cplusplus diff --git a/include/nwnss/comnSA/name.h b/include/nwnss/comnSA/name.h index cd627f3..5558d52 100644 --- a/include/nwnss/comnSA/name.h +++ b/include/nwnss/comnSA/name.h @@ -44,14 +44,14 @@ #define _NAME_H_ #ifndef _COMNBEASTS_H_ -#include +#include #endif #ifndef _NAMESPACE_H_ -#include +#include #endif -#include +#include #ifdef __cplusplus @@ -67,7 +67,7 @@ struct FullDirectoryInfo_s; /* preferably prime numbers since these numbers are used for hashing */ #define MIN_NAME_CACHE_SIZE 17 /* The minimum number of entries that */ - /* can be set for the name cache. */ + /* can be set for the name cache. */ #define DEFAULT_NAME_CACHE_SIZE 2111 /* The maximum number of entries that */ /* can be set for the name cache. */ #define DEFAULT_MAX_NAME_CACHE_SIZE 100000 /* Default maximum size of the name cache */ @@ -110,7 +110,7 @@ typedef struct NameCacheCtrl_s NINT minValidSize; /* minimum value of maxEntries before an invalidate should occur */ NINT maxValidSize; /* minimum value of maxEntries before an invalidate should occur */ NINT lastInvalidateSize; /* value of maxEntries at last invalidate */ - Latch_s latch; /* latch to control changes in this structure */ + Latch_s latch; /* latch to control changes in this structure */ NINT numHashEntries; /* number of entries in each hash table */ DQhead_t *uniHash; /* pointer to unicode hash array */ DQhead_t *asciiHash; /* pointer to ASCII hash array */ @@ -177,10 +177,10 @@ extern STATUS NAME_InsertAndMangleName( NINT *retDirNamesAdded); /*Optional--Null is allowed */ #define INSNAMEFL_NULL_FLAG 0x00000000 -#define INSNAMEFL_NEW_PARENT_AUTH 0x00000001 /* If set, the names are for +#define INSNAMEFL_NEW_PARENT_AUTH 0x00000001 /* If set, the names are for * a new parent so the authorization * info should be updated */ -#define INSNAMEFL_DIRECTORY_ONLY 0x00000002 /* If set, the names are only +#define INSNAMEFL_DIRECTORY_ONLY 0x00000002 /* If set, the names are only * added in directory, there'll be no * name operations on beast. This is * useful for some LSS (such as CD9660) @@ -188,8 +188,8 @@ extern STATUS NAME_InsertAndMangleName( * instead of create all file beasts */ extern STATUS NAME_WillAddToSalvage( - struct NamedBeast_s *beast, - struct NamedBeast_s *dir, + struct NamedBeast_s *beast, + struct NamedBeast_s *dir, NINT flags, struct ParentEntry_s *pentry); @@ -219,7 +219,7 @@ extern STATUS NAME_doAddName( #define REMNAMEFL_KEEP_BEAST_NAMES 0x00000001 /* if SET, keep the beast names * and only remove names from the * parent directory. */ -#define REMNAMEFL_KEEP_PARENT_ENTRY 0x00000002 /* if SET, keep the empty +#define REMNAMEFL_KEEP_PARENT_ENTRY 0x00000002 /* if SET, keep the empty * parent entry in the beast because we * are renaming and we will shortly * re-insert names back into the @@ -228,7 +228,7 @@ extern STATUS NAME_doAddName( * be atomic, either all of the name * entries will be removed, or none * of them will. */ -#define REMNAMEFL_REMOVE_PARENT_AUTH 0x00000008 /* If set, the names are for +#define REMNAMEFL_REMOVE_PARENT_AUTH 0x00000008 /* If set, the names are for * a parent that is being removed, so * the authorization info should be * updated */ @@ -390,7 +390,7 @@ extern void NAME_AddNameToCache( unicode_t *uniName, NINT asciiNameLen, /* May be 0 */ char *asciiName, /* May be NULL if asciiNameLen is 0 */ - Zid_t zid + Zid_t zid /* cnt NINT nameUniquifier*/); extern Zid_t NAME_GetNameFromCacheUnicode( diff --git a/include/nwnss/comnSA/pssConnection.h b/include/nwnss/comnSA/pssConnection.h index e1a3eb4..bd63bf1 100644 --- a/include/nwnss/comnSA/pssConnection.h +++ b/include/nwnss/comnSA/pssConnection.h @@ -33,7 +33,7 @@ |--------------------------------------------------------------------------- | This module is used to: | This defines the interfaces into the NSS portion of the connection - | structure. + | structure. | | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! | @@ -45,13 +45,13 @@ #define _PSSCONNECTION_H_ #ifndef _OMNI_H_ -#include +#include #endif #ifndef _QUE_H_ -#include +#include #endif #ifndef _MSGGEN_H_ -#include +#include #endif #ifndef _CONTEXTHANDLE_H_ #include "contextHandle.h" @@ -63,7 +63,7 @@ #include "searchMap.h" #endif #ifndef _COMNPUBLICS_H_ -#include +#include #endif #ifndef _SAGENTHANDLE_H_ #include "sAgentHandle.h" diff --git a/include/nwnss/comnSA/psslib.h b/include/nwnss/comnSA/psslib.h index c47f097..8c9879e 100644 --- a/include/nwnss/comnSA/psslib.h +++ b/include/nwnss/comnSA/psslib.h @@ -44,7 +44,7 @@ #define _PSSLIB_H_ #ifndef _OMNI_H_ -#include +#include #endif /* Pre-declare the following structure(s) */ diff --git a/include/nwnss/comnSA/sAgentHandle.h b/include/nwnss/comnSA/sAgentHandle.h index 5a529b9..4bc13a4 100644 --- a/include/nwnss/comnSA/sAgentHandle.h +++ b/include/nwnss/comnSA/sAgentHandle.h @@ -33,7 +33,7 @@ |--------------------------------------------------------------------------- | This module is used to: | This defines the interfaces into the PSS portion of the connection - | structure. + | structure. | | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! | @@ -45,7 +45,7 @@ #define _SAGENTHANDLE_H_ #ifndef _COMNPARAMS_H_ -#include +#include #endif #ifdef __cplusplus diff --git a/include/nwnss/comnSA/sysimp.h b/include/nwnss/comnSA/sysimp.h index 1cf81ff..71a1961 100644 --- a/include/nwnss/comnSA/sysimp.h +++ b/include/nwnss/comnSA/sysimp.h @@ -44,10 +44,10 @@ #define _SYSIMP_H_ #ifndef _OMNI_H_ -#include +#include #endif -#if !defined(__KERNEL__) && !defined(NSS_USERSPACE) +#if !defined(__KERNEL__) #ifndef __DDSAPI_H #include #endif @@ -59,10 +59,10 @@ #if zNETWARE || (zLINUX && defined(__KERNEL__)) #ifndef _MPKTYPES_H_ -#include +#include #endif -#include /* NetWare Include*/ +#include /* NetWare Include*/ #endif #ifdef __cplusplus @@ -99,7 +99,7 @@ extern LONG NDSEventHandlerHandle; extern DDSAPI int(*DDSGetLocalAgentInfoPtr)(NINT *state, void *treeName); extern DDSAPI int(*DDSGetLocalEntryNamePtr)(NINT entryid, int FormFlags, unicode_t *dn); #endif -#if !defined(__KERNEL__) && !defined(NSS_USERSPACE) +#if !defined(__KERNEL__) extern DDSAPI int(*DDCCreateContextPtr)(SAL_ModHandle taskID, int *context); extern DDSAPI int(*DDCDuplicateContextPtr)(int oldContext, int *newContext); extern DDSAPI int(*DDCResolveNamePtr)(int context, uint32 flags, const void *dn); @@ -137,58 +137,6 @@ extern DDSAPI uint32(*DDCContextEntryIDPtr)(int context); extern DDSAPI int(*DDCPingPtr)(int context, uint32 *dsVersion, uint32 *rootMostEntryDepth, char *treeName, uint32 *flags, unicode *uTree); #endif -#if defined(NSS_USERSPACE) -/* - * Userspace NSS needs the NSS locale table layout for namespace code. - * This is the original LocaleTableStruct block from the NetWare/kernel - * sysimp import area below, exposed without enabling disk/VFS import - * function pointers. - */ -struct LocaleTableStruct -{ - /*BYTE LocaleTableSgnature[12];*/ /* "LoCaLe Table" */ - /* the address we get from the OS starts HERE*/ - /* LCONFIG.SYS relative offset */ - LONG OSLanguageID; /* 0 */ - LONG OSDoubleBytePresentFlag; /* 4 */ - LONG OSDoubleByteSpace; /* 8 */ - - LONG OSUpperCaseTableID; /* 12 */ - - /* WARNING - util.386 assumes OSUpperCaseTable is at offset 16 */ - BYTE OSUpperCaseTable[256]; /* 16 */ - - LONG OSSortTableID; /* 272 */ - BYTE OSSortTable[256]; /* 276 */ - - LONG OSLineDrawCharTableID; /* 532 */ - BYTE OSLineDrawCharTable[8 * 6]; /* 536 */ - - LONG OSDoubleByteTableID; /* 584 */ - BYTE OSFirstByteBitMap[256 / 8]; /* 588 */ - - /* DOS Flavor Tables */ - - LONG DOSType; /* 620 */ - - BYTE DOSValidCharBitMap[256/8]; /* 624 */ - - BYTE DOSValidCharBitMapNoLower[256/8];/* 656 */ - - BYTE DOSFirstByteBitMap[256/8]; /* 688 */ - - BYTE DOSSecondByteBitMap[256/8]; /* 720 */ - - /* WARNING - util.386 assumes DOSUpperCaseTable is at offset 752 */ - BYTE DOSUpperCaseTable[256]; /* 752 */ - - BYTE DOSToMAC[256]; /* 1008 */ - - BYTE MACToDOS[256]; /* 1264 */ -}; -extern struct LocaleTableStruct *NW_LocaleTable; -#endif - #if zNETWARE || (zLINUX && defined(__KERNEL__)) extern STATUS (*zClosePtr)( Key_t key); @@ -210,7 +158,7 @@ extern STATUS (*zOpenPtr)( extern STATUS (*zReadPtr)( Key_t key, - Xid_t xid, + Xid_t xid, QUAD startingOffset, NINT bytesToRead, void *retBuffer, @@ -222,7 +170,7 @@ extern STATUS (*zRootKeyPtr)( extern STATUS (*zWritePtr)( Key_t key, - Xid_t xid, + Xid_t xid, QUAD startingOffset, NINT bytesToWrite, const void *buffer, @@ -334,11 +282,11 @@ extern BYTE *NW_DebuggerActive; #ifndef __linux__ extern THREAD (*kStartThreadWithModuleHandlePtr)( - BYTE *pThreadName, + BYTE *pThreadName, void *(*StartAddress)(THREAD, void *), - void *StackAddressHigh, - LONG StackSize, - void *Argument, + void *StackAddressHigh, + LONG StackSize, + void *Argument, uint32 ModuleHandle); /*--------------------------------------------------------------------------- @@ -390,7 +338,7 @@ struct NW_BranchTableEntry /* from NSIMMU.H */ extern void NW_WriteBranchTableEntry( /* from NSIMMU.C */ NINT instruction, - struct NW_BranchTableEntry *entry, + struct NW_BranchTableEntry *entry, void *branchRoutine); #define CALL_INST 0xE8 @@ -489,7 +437,7 @@ LONG NW_CallAsm2d(void *RoutineAddress, void *parm1, void *parm2); /*------------------------------------------------------------------------- - * + * *-------------------------------------------------------------------------*/ #if zNETWARE diff --git a/include/nwnss/comnSA/zFriends.h b/include/nwnss/comnSA/zFriends.h index 81606fe..9383a34 100644 --- a/include/nwnss/comnSA/zFriends.h +++ b/include/nwnss/comnSA/zFriends.h @@ -38,15 +38,15 @@ #define _ZFRIENDS_H_ #ifndef _ZOMNI_H_ -# include +# include #endif #ifndef _ZPARAMS_H_ -# include +# include #endif #ifndef _CHUNK_H_ -# include +# include #endif @@ -62,7 +62,7 @@ STATUS zChangeConnection( STATUS zReadPageChunks( Key_t key, - Xid_t xid, + Xid_t xid, QUAD startingOffset, NINT bytesToRead, NSSChunk_s *chunks, @@ -75,7 +75,7 @@ STATUS zReleasePageChunks( STATUS zZIDCreate( Key_t key, - NINT taskID, + NINT taskID, Xid_t xid, NINT nameSpace, VolumeID_t *volumeID, @@ -138,7 +138,7 @@ DOSTime_t xUTC2dosTime(Time_t utc); Time_t xDOS2utcTime(DOSTime_t dosTime); STATUS xPoolGUIDToName( - VolumeID_t *poolID, + VolumeID_t *poolID, unicode_t *poolName, NINT poolNameSizeInUnicode); @@ -147,11 +147,11 @@ STATUS xPoolNameToGUID( VolumeID_t *poolID); STATUS xPoolGetEnabledFeatures( - VolumeID_t *poolID, + VolumeID_t *poolID, QUAD *enabledFeatures ); STATUS xVolumeGUIDToName( - VolumeID_t *volumeID, + VolumeID_t *volumeID, unicode_t *volumeName, NINT volumeNameSizeInUnicode); diff --git a/include/nwnss/include/DisplayVersion.h b/include/nwnss/include/DisplayVersion.h index 6a3ece4..e2df329 100644 --- a/include/nwnss/include/DisplayVersion.h +++ b/include/nwnss/include/DisplayVersion.h @@ -44,7 +44,7 @@ #define _DISPLAYVERSION_H_ #ifndef _ZOMNI_H_ -# include +# include #endif #ifdef __cplusplus diff --git a/include/nwnss/include/Moab.imp b/include/nwnss/include/Moab.imp new file mode 100644 index 0000000..5c2d846 --- /dev/null +++ b/include/nwnss/include/Moab.imp @@ -0,0 +1,1999 @@ +CMovFast +CMovFastCache +kDelayThread +Abend +AccelerateConnectionShutDown +AccountCharge +AccountHold +AccountNote +ActivateDevice +ActivateModule +ActivatePopUpScreen +ActivateScreen +AddConnectionHighPrivileges +AddConnectionSecondAuthentication +AddDiskDevice +AddDiskSystem +AddFSMonitorHook +AddKey +AddNameSpaceToVolume +AddNewLanguage +AddPartitionToMirrorGroup +AddPollingProcedureRTag +AddToFATFATChain +AddTrusteeRights +AddUserRestriction +AdjustRealModeInterruptMask +AdrDSAltCR3 +AdrDSCR3 +AdrDSOSCode +AdrDSOSCR3 +AdrDSOSData +AESLicenseErrorAlert +AlertDevice +Alloc +AllocateConnectionNumber +AllocateConnectionTasks +AllocateExtendedDirectorySpace +AllocateFileHandle +AllocateMappedPages +AllocateMessage +AllocateNCPDirHandle +AllocatePhysicalPages +AllocateResourceTag +AllocBufferBelow16Meg +AllocGarbageCollect +AllocMovableCacheMemory +AllocNonMovableCacheMemory +AllocNonMovableCacheNoSleep +AllocSleepOK +AsciiToInt +AsciiToIntWithPointer +AssemblyAbend +ASyncDoInternalReadFile +ASyncDoInternalWriteFile +ASyncStartInternalReadFile +ASyncStartInternalWriteFile +AttachQServer +AuthenticateConnection +BindProtocolToBoard +BindProtocolToDriver +BIOSReadDriveParameters +BIOSReadSectors +BIOSWriteSectors +BitClear +BitSet +BitTest +BitTestAndClear +BitTestAndSet +BroadcastPacket +BytesToBlocks +CAdjustRealModeInterruptMask +CalcDays +CalcMinutes +CAllocSemaphore +CancelInterruptTimeCallBack +CancelNoSleepAESProcessEvent +CancelSleepAESProcessEvent +CanEventBlock +CaseInsensitiveCompareStrings +CCancelInterruptTimeCallBack +CCancelWorkToDo +CCDDecompressBuildFile +CCDDecompressIsDone +CCDFreeReadAheadBuffer +CCDGetReadAheadBuffer +CCDGetReadCacheBlock +CCDGetWriteCacheBlock +CCDReturnReadCacheBlock +CCDReturnWriteCacheBlock +CCDSetFileSize +CCDStartReadAhead +CCDStopReadAhead +CCDUpdateDecompressPosition +CCheckHardwareInterrupt +CCmpB +CCmpD +CDeAllocateSemaphore +CDestroyProcess +CDFreeReadAheadBuffer +CDGetReadAheadBuffer +CDisableHardwareInterrupt +CDoEndOfInterrupt +CEnableHardwareInterrupt +CEvaluateExpression +CEvaluateNumericExpression +CExamineSemaphore +CFindB +CFindD +CFindW +CFindResourceTag +CFreeUpProcessFromSemaphore +CFreeUpProcessFromSpecificSem +CGetIpxMib +CGetMyProcessID +CGetSymbolFromValue +CGetThreadHandicapAmount +CGetValueFromSymbol +ChangeConnectionAuthenticationStatus +ChangeFATChainToLimbo +ChangeLockDirectoryNumber +ChangeLoggedInConsoleUser +ChangeLimboFATChainToFile +ChangeNCPDirectoryHandles +ChangeToAlternateConsoleScreen +ChangeToSystemConsoleScreen +ChargeForFileServices +ChargeUser +CheckAndGetDirectoryEntry +CheckAnyUse +CheckConnectionState +CheckConnTableForObjectID +CheckDataStream +CheckDeletedDataStream +CheckDirectoryEntryLock +CheckDiskCard +CheckDiskDevice +CheckForActiveMigrationHandle +CheckForObjectID +CheckForRegisteredEvent +CheckHardwareInterrupt +CheckHardwareOptions +CheckIfScreenActive +CheckInterruptTimeEventLimit +CheckKeyStatus +CheckNCPDirectoryHandles +CheckPhysicalDevice +CheckSerial +CheckSlot +ChecksumInternalSendPacket +CheckUse +CheckVolumeNumber +CIPXCancelECB +CIPXCheckForSocket +CIPXCloseSocket +CIPXGetConfiguration +CIPXGetFSAddress +CIPXGetInternetworkAddress +CIPXGetLocalTarget +CIPXListen +CIPXOpenSocketESR +CIPXOpenSocketRTag +CIPXOpenSocketSystem +CIPXRoutePacketDirectly +CIPXSendPacket +CIPXSendPacketSkipChkSum +CIPXSetConfiguration +ClearDirectoryHandles +ClearOpenCallback +ClaimExtendedDirectorySpace +ClearExceptionHandler +ClearFLocks +ClearHandle +ClearHardwareInterrupt +ClearLockWait +ClearNCPDirectoryHandles +ClearNCPVolumeDirectoryHandles +ClearRLocks +ClearScreen +ClearStampWait +ClearTaskWait +ClearVolumeFlags +CloseEAHandle +CloseFile +CloseLock +CloseScreen +CloseTNode +CLSLAddProtocolID +CLSLBindStack +CLSLControlStackFilter +CLSLDeRegisterDefaultChain +CLSLDeRegisterPreScanRxChain +CLSLDeRegisterPreScanTxChain +CLSLDeRegisterStack +CLSLGetBoundBoardInfo +CLSLGetMLIDControlEntry +CLSLGetPhysicalNodeAddress +CLSLGetPIDFromStackIDBoard +CLSLGetProtocolControlEntry +CLSLGetRcvECBRTag +CLSLGetStackIDFromName +CLSLGetStartChain +CLSLModifyStackFilter +CLSLRegisterDefaultChain +CLSLRegisterPreScanRxChain +CLSLRegisterPreScanTxChain +CLSLRegisterStackRTag +CLSLReSubmitDefaultECB +CLSLReSubmitPreScanRxECB +CLSLReSubmitPreScanTxECB +CLSLReturnRcvECB +CLSLSendPacket +CLSLUnbindStack +CMakeProcess +CMakeSignature +CMovB +CMovD +CMovW +CNFindB +CNFindD +CommandLineProcess +CommitExpandedVolumeTables +CommitFile +CommitSessionKey +CompleteMessage +ConnectionIsLoggedIn +ConsoleAudit +ConvertBinderyPattern +ConvertDirectoryToNCP +ConvertDOSToSecondsRelative +ConvertPathString +ConvertPathToDirEntry +ConvertPathToNCP +ConvertSecondsRelativeToDOS +ConvertSecondsToTicks +ConvertStringToCountPathVolume +ConvertStringToUnsignedLong +ConvertTicksToSeconds +ConvertToUpperCase +CopyFileToFile +CountHashIndex +CountHashLinks +CountOwnedFilesAndDirectories +CPSemaphore +CReadByteFromDomain +CReadEISAConfig +CReadLongFromDomain +CreateAndOpenFile +CreateBranchEntry +CreateBranchEntryByAddress +CreateDataMigratedFileEntry +CreateDirectory +CreateEAHandleForClient +CreateFile +CreateMigratedDirectory +CreateMirror +CreateNetWarePartition +CreateQueueDirectory +CreateRedirection +CRescheduleFromInterrupt +CryptSymbolStruct +CScheduleDelayedWorkToDo +CScheduleInterruptTimeCallBack +CScheduleWorkToDo +CScheduleFastWorkToDo +CSemaphoreReleaseAll +CSetABreakpoint +CSetB +CSetD +CSetThreadHandicapAmount +CSetW +CSleepUntilInterrupt +CSpecifyWorkerThreadStackSize +CSPXAbortConnection +CSPXCancelECB +CSPXCancelSessionListen +CSPXCheckInstallation +CSPXEstablishConnection +CSPXGetConnectionStatus +CSPXGetConnectionStatus2 +CSPXGetTimersAndCounters +CSPXListenForConnectedPacket +CSPXListenForConnection +CSPXListenForSequencedPacket +CSPXSendSequencedPacket +CSPXSetTimersAndCounters +CSPXTerminateConnection +CStrCmp +CStrCpy +CStriCmp +CStrLen +CUnAdjustRealModeInterruptMask +CurrentContextSaveRestore +CurrentNumberOfCacheBuffers +CurrentTime +CValidateMappedAddress +CVSemaphore +CWildMatch +CWriteByteToDomain +CWriteLongToDomain +CYieldIfNeeded +CYieldWithDelay +CYieldUntilIdle +DAI_AddAdapter +DAI_AddDevice +DAI_AddLogicalPartition +DAI_AddPartition +DAI_RemoveAdapter +DAI_RemoveDevice +DAI_RemoveLogicalPartition +DAI_RemovePartition +DAI_ReturnAdapter +DAI_ReturnDevice +DAI_ReturnLogicalPartition +DAI_ReturnPartition +DeactivateDevice +DeAllocateMappedPages +DeAllocatePhysicalPages +debuggerActive +DecDebuggerActiveCount +DecNestedInterruptLevel +DecodePass +DecrementScreenActiveCount +DelayMyself +DeleteAnyPartition +DeleteBranchEntry +DeleteDirectory +DeleteDiskDevice +DeleteDiskSystem +DeleteEAHandle +DeleteMirror +DeletePartitionFromMirrorGroup +DeleteQueueDirectory +DeleteRedirection +DeleteSearchPath +DeleteTrusteeRights +DeleteUserRestriction +DeregisterAuditService +DeRegisterCommand +DeRegisterCommandLineInfo +DeRegisterDMSupportModule +DeRegisterEventType +DeRegisterHardwareOptions +DeregisterNameService +DeRegisterNCPExtension +DeRegisterRouter +DeRegisterRTDataMigrationNLM +DeRegisterSetableParameter +DestroyDirectoryHandle +DestroyQ +DeviceBlockingIO +DeviceBlockingIOCTL +DeviceIO +DeviceIOCTL +DeviceLock +DeviceRelease +DirectorySearch +DirectReadFile +DirectReadFileNoWait +DirectWriteFile +DirectWriteFileNoWait +Disable +DisableAndRetFlags +DisableExtendedNMI +DisableHardwareInterrupt +DisableInputCursor +DisableLoggedInUserAccount +DismountDevice +DismountEAHandlesByVolume +DismountVolume +DisplayDriveName +DisplayLANBoardConfiguration +DisplayLicenseInfoAESProcedure +DisplayProductName +DisplayScreenLine +DisplayScreenText +DisplayScreenTextWithAttribute +DisplayServerVersion +DMFileInformation +DMSupportModuleInformation +DoCallTraceWithInfo +DoCoreDump +DoEndOfInterrupt +DoRealModeInterrupt +DoRealModeInterrupt32 +DoRescheduleFromInterruptNoSave +DOSCreateWithAttributes +DOSFindDirectoryEntry +DOSGetInternalDirectoryHandle +DOSOpenWithAccess +DOSWildMatch +DriverInitComplete +DupEA +EditQEntry +Enable +EnableExtendedNMI +EnableHardwareInterrupt +EnableInputCursor +EncryptPass +EndPopUpScreen +EndScreenUpdateGroup +EndSleepNotAllowed +EndVolumeExpansion +EndVolumeSync +EnterDebugger +EnumEA +EraseFile +ESMAlloc +ESMAllocAbove4Gig +ESMCopy +ESMFree +ESMQuery +EventCheck +EventReport +EventTypeSearch +ExecuteNCPPacket +ExceptionEvent +ExpandFileInContiguousBlocks +ExpandMovableCacheMemory +ExpandVolumeTables +ExpandVolumeVectors +ExpediteBroadcasts +ExportPublicSymbol +ExtendedGetBroadcastMessage +ExtractFormattedDate +ExtractFormattedDateAndTime +ExtractFormattedTime +FillScreenArea +FillScreenAreaAttribute +FindAlternateMessageFile +FindConnectionsUsingNetAddress +FindDirectoryHandle +FindLastComponent +FindNextTrusteeReference +FindPublicRecordStructure +FlushTLB +FlushVolume +ForceDirectoryUpdate +FormatCurrentDate +FormatCurrentDateAndTime +FormatCurrentTime +FormatDate +FormatDateAndTime +FormatTime +Free +FreeBufferBelow16Meg +FreeConnectionTasks +FreeDirectoryEntry +FreeLimboVolumeSpace +FreeLogKey +FreeMovableCacheMemory +FreeNonMovableCacheMemory +FreeUpProcessFromSemaphore +FreeUpProcessFromSpecificSemaph +F3AddTrustees +F3AllocDirHandle +F3ContinueFileSearch +F3DeleteTrustees +F3EraseFile +F3GetDirBase +F3GetDirHandleInfoAndParent +F3GetEffectiveDirectoryRights +F3GetFileHandleInfoAndParent +F3GetFullPathString +F3GetHugeInfo +F3GetNameSpaceList +F3GetNSSpecificInfo +F3GetPathString +F3InitFileSearch +F3ModifyDOSAttributes +F3ModifyInfo +F3ModifyNSSpecificInfo +F3PurgeSalvageableFile +F3PurgeSalvageFileList +F3ObtainFileInfo +F3OpenCreate +F3QueryNameSpaceInfo +F3RecoverSalvagedFiles +F3RenameFile +F3ScanForTrustees +F3ScanSalvagedFiles +F3ScanSalvageFileList +F3SearchSet +F3SetDirHandle +F3SetHugeInfo +GenerateHashValue +GenNSAddTrustees +GenNSAllocDirHandle +GenNSAllocateDirHandle +GenNSContinueFileSearch +GenNSDeleteTrustees +GenNSEffectiveDirectoryRights +GenNSErase +GenNSGetDirBase +GenNSGetFullPathString +GenNSGetNameSpaceList +GenNSGetPathString +GenNSGetSpecificInfo +GenNSInitFileSearch +GenNSModifyInfo +GenNSModifySpecificInfo +GenNSObtainInfo +GenNSOpenCreate +GenNSOpenCreateFile +GenNSPurgeSalvageableFile +GenNSQueryNameSpaceInfo +GenNSRecoverSalvageableFile +GenNSRename +GenNSRenameMove +GenNSScanForTrustees +GenNSScanSalvageableFiles +GenNSSetDirHandle +GenParsePath +GetAcceptBroadcastMessages +GetAccessRights +GetAccessRightsFromIDs +GetAccountingVersionNumber +GetActiveScreen +GetActiveVolumeIOs +GetActualAvailableDiskSpace +GetActualFileSize +GetActualScreenSize +GetAllowUnencryptedPasswords +GetApplication +GetBellWasRung +GetBinderyOpen +GetBusName +GetBusTag +GetBusType +GetCacheBufferSize +GetCacheCounters +GetClosestSymbol +GetCommandLineInfo +GetCompanyName +GetConnectionAuthenticatedIdentity +GetConnectionAuthenticatedIDs +GetConnectionAuthenticationState +GetConnectionLicensesInUse +GetConnectionListHasChanged +GetConnectionServiceInformation +GetConnectionsInUse +GetConnectionStatistics +GetConnectionStatus +GetConnectionTime +GetConnectionTransportAddress +GetConnectionType +GetCopyrightNotice +GetCurrentClock +GetCurrentDiskUsedAmount +GetCurrentNonCacheMemory +GetCurrentNumberOfCacheBuffers +GetCurrentNumberOfRestrictedStations +GetCurrentNumberOfTransactions +GetCurrentSecondsRelative +GetZeroSecondsRelative +GetCurrentTime +GetCurrentUsedWorkDynamicMemory +GetCurrNonMovableCacheBuffersCount +GetCurrReturnableCacheBuffersCount +GetCursorStyle +GetCustomDataBufferAddress +GetCustomScreenInfoPointer +GetDebuggerActiveCount +VMGetDirectoryEntry +GetDirectoryEntryNoSleep +GetDirectoryEntryAndSleepStatus +GetDirectoryInformation +GetDirectoryLengthInBlocks +GetDirectoryStatusInformation +GetDiskIOsPending +GetDOSDateAndTime +GetDOSFirstByteBitMap +GetDOSOpenFileCount +GetDOSSecondByteBitMap +GetDOSNameSpaceType +GetDOSUpperCaseTable +GetDOSValidCharBitMap +GetEntryFromPathStringBase +GetExtendedDirectoryInfo +GetFailedAllocRequestCount +GetFATChainLength +GetFATWriteVectorTable +GetFileAccessRights +GetFileHoles +GetFileServerMajorVersionNumber +GetFileServerMinorVersionNumber +GetFileServerRevisionNumber +GetFileSize +GetFileStatusInformation +GetFileSystemVersion +GetFLocksCount +GetFLocksMax +GetFSEngineInternalNetNumber +GetFullNameFromID +GetGDTLimit +GetHandleInfo +GetHandleInfoData +GetHardwareBusType +GetHashIndexMaskTable +GetHighResolutionTimer +GetHistogramPublics +GetHugeInformation +GetInIOEngineFlag +GetInputCursorPosition +GetIOCTL +GetIOEngineMajorVersionNumber +GetIOEngineMinorVersionNumber +GetIOEngineRevisionNumber +GetIPXNetNumberTableEntry +GetIPXVersion +GetKey +GetLastVolumeMountErrorString +GetLicenseApplicationNumber +GetLicenseFlags +GetLicenseSerialNumber +GetLoaderCommandLine +GetLoaderSupportedTypes +GetLoaderType +GetLogAllowed +GetLogicalPageInfo +GetLogKey +GetLong +GetMACRootIDs +GetMaximumNumberOfConnections +GetMaximumNumberOfMLIDBoards +GetMaximumNumberOfNameSpaces +GetMaximumNumberOfPollingLoops +GetMaximumNumberOfVolumes +GetMaximumReplyBufferSize +GetMaximumSubdirectoryTreeDepth +GetMaximumUserRestriction +GetMaxNumberOfRemoteConnections +GetMemoryNode +GetMLIDConfigurationTable +GetMLIDConfigurationTableEntry +GetMLIDLoadedHandleTableEntry +GetMountedVolumeList +GetMSEngineInternalNet +GetNDirtyBlocks +GetNestedInterruptLevel +GetNextCommandLineHandle +GetNextLoadedListEntry +GetNextRemirrorBlock +GetNextScreen +GetNLMNames +GetNLMVersionInfo +GetNumberOfConnectionLicenses +GetNumberOfDirectoryCacheBuffers +GetNumberOfLANs +GetNumberOfPollingLoops +GetNumberOfReferencedExports +GetNumberOfRestrictedStations +GetNumberOfServerProcesses +GetNumberOfVolumes +GetOpenCount +GetOpenFileFlags +GetOriginalInfo +GetOriginalNameSpace +GetOriginalNumberOfCacheBuffers +GetOSFirstByteBitMap +GetOSDoubleByteSpace +GetOSGeneralWorkAllocTag +GetOSLineDrawCharTable +GetOSShortTermAllocTag +GetOSUpperCaseTable +GetOtherCachePagesCount +GetOtherNameSpaceEntry +GetOutputCursorPosition +GetParentDirectoryNumber +GetPassKey +GetPatentNotice +GetPCBDirectoryServicesStuff +GetPCBStackLimit +GetPeakConnectionLicensesUsed +GetPeakConnectionsUsed +GetPeakNumberOfTransactions +GetPeakStationsInUseCount +GetPreviousScreen +GetPrimaryProcessorID +GetPrivs +GetProcessorSpeedRating +GetProcessSwitchCount +GetProtocolNameTableEntry +GetPublicAddress +GetQJobs +GetQJobsByFormList +GetQServStatus +GetQueueingVersionNumber +GetRawFileSize +GetReadAfterWriteVerifyStatus +GetRealModeInterruptMask +GetRealModeWorkSpace +GetReceiveBuffersCount +GetReferenceCount +GetReferenceCountFromEntry +GetReplyBuffer +GetRequest +GetRestrictionBlocksPerVolume +GetRLocksCount +GetRLocksMax +GetRunningProcess +GetScreenAddress +GetScreenName +GetScreenSize +GetSearchPathElement +GetSectorsPerCacheBuffer +GetSecurityRestrictionsLevel +GetSerialNumber +GetServerConfigurationType +GetServerPhysicalOffset +GetSetDefaultSupportModule +GetSetableParameterValue +GetSFTLevel +GetSharedMemoryLinearAddress +GetShort +GetSignalDebuggerOptions +GetSoftwareDate +GetSoftwareRevision +GetStationFileIOStats +GetStationPacketIOStats +GetStationsInUseCount +GetSubDirAccessRights +GetSuperHighResolutionTimer +GetSyncClockFields +GetSystemConsoleScreen +GetSystemMemoryMap +GetTotalWorkDynamicMemory +GetTimeAndDateVector +GetTimeInMinutes +GetTimeZone +GetTTSLevel +GetUnsignedNumber +GetUsedDirectoryEntriesCount +GetVAPVersionNumber +GetVirtualConsoleVersionNumber +GetVolumeFreeBlocks +GetVolumeLastModifiedDateAndTime +GetVolumeMountedFlag +GetVolumeNameTableEntry +GrantSupervisorMailDirectoryAccess +GrantUserConsoleOperatorPrivileges +GTransFlags +GTTaskFlags +HitFATDirtyBit +HJ_Media_Request +HJ_Media_Request_Ack +HookNCPVerb +HookSetBinderyContext +ICmpB +ImportPublicSymbol +IncDebuggerActiveCount +IncNestedInterruptLevel +IncrementScreenActiveCount +InitializeBootTable +InitializeDiskCard +InitializeSignature +InputFromKeyboard +InputFromScreen +InsertKey +InsertSearchPath +Internal_Object_Blocking_IO +Internal_Object_IO +InternalDelaySendPacket +InternalDeviceBlockingIO +InternalDeviceBlockingIOCTL +InternalDeviceIO +InternalDeviceIOCTL +InternalDiskRelease +InternalLogicalPartitionBlockingIO +InternalLogicalPartitionIO +InternalMountVolume +InternalPartitionBlockingIO +InternalPartitionIO +InternalReadFile +InternalSendPacket +InternalSystemBlockingIOCTL +InternalSystemIOCTL +InternalWriteFile +InvertLong +InvertShort +INWClearFile +INWCReadEISAConfig +INWDOSChangeFileMode +INWDOSClose +INWDOSCreate +INWDOSCreateDirectory +INWDOSDiskReset +INWDOSFindFirstFile +INWDOSFindNextFile +INWDOSGetCurrentDirectory +INWDOSGetDefaultDrive +INWDOSGetDriveType +INWDOSIsFloppy +INWDOSIsNetwork +INWDOSLSeek +INWDOSOpen +INWDOSRead +INWDOSRemoveDirectory +INWDOSRename +INWDOSSetDateAndTime +INWDOSSetDefaultDrive +INWDOSShutOffFloppyDrive +INWDOSUnlink +INWDOSWrite +INWGetAccountStatus +INWGetBroadcastMessage +INWGetVolumeInformation +INWLockVolume +INWLogFile +INWNewGetVolumeInfo +INWReleaseFile +INWSendBroadcastMessage +INWsprintf +INWTTSAbortTransaction +INWTTSBeginTransaction +INWTTSEndTransaction +INWUnLockVolume +IPXCancelECB +IPXChainVectors +IPXUnChainVectors +IPXCloseSocket +IPXGetInternetworkAddress +IPXGetLocalTarget +IPXListen +IPXOpenSocketESR +IPXOpenSocketRTag +IPXRouterReceiveHandler +IPXSendPacket +IsConsoleOperator +IsDataMigrationAllowed +IsDOSPresent +IsDoubleByteSpace +IsEquivalent +IsKeyInSet +IsNullKey +IsSupervisor +IsWorkGroupManager +KeepDeletedDataStream +kEnterNetWare +kExitNetWare +KeyboardPollProcedure +KillDirRights +KillMe +KillQEntry +KillStation +LicenseErrorReportStruct +LDOSClose +LDOSOpen +LDOSRead +LDOSSetCurrentDirectory +LDOSWrite +DOSLSeek +LFileSet +LinkHandle +LinkRelOpenCallback +LoadModule +LoadModuleInSameDomain +LockDevice +LockDirectoryEntry +LockFile +LockPRecSet +LogBroadcastMessage +LoggedRealUserID +LoggedUserID +LogicalPartitionBlockingIO +LogicalPartitionIO +LogicalPartitionLock +LogicalPartitionRelease +LoginUser +LogoutConnection +LogPRec +LogRec +LRecSet +LSLAddProtocolID +LSLBindStack +LSLCancelAESEventRTag +LSLCheckBackReceiveBuffer +LSLCheckOutReceiveBuffer +LSLControlStackFilter +LSLDeFragmentECB +LSLDeRegisterDefaultChain +LSLDeRegisterDefaultStack +LSLDeRegisterMLID +LSLDeRegisterPreScanRxChain +LSLDeRegisterPreScanStack +LSLDeRegisterPreScanTxChain +LSLDeRegisterStack +LSLEndCriticalSection +LSLEnqueueSend +LSLFastRcvEvent +LSLFastSendComplete +LSLGetBoundBoardInfo +LSLGetCheckedOutBuffersPercent +LSLGetCriticalSectionStatus +LSLGetIntervalMarker +LSLGetLinkSupportStatistics +LSLGetMaximumPacketSize +LSLGetMLIDControlEntry +LSLGetNextSend +LSLGetPIDFromStackIDBoard +LSLGetProtocolControlEntry +LSLGetRcvECBRTag +LSLGetSizedRcvECBRTag +LSLGetStackIDFromName +LSLGetStartChain +LSLHoldRcvEvent +LSLKeepCheckOutReceiveBuffer +LSLModifyStackFilter +LSLRegisterDefaultChain +LSLRegisterDefaultStackRTag +LSLRegisterMLIDRTag +LSLRegisterPreScanRxChain +LSLRegisterPreScanStackRTag +LSLRegisterPreScanTxChain +LSLRegisterStackRTag +LSLRelinquishControl +LSLReSubmitDefaultECB +LSLReSubmitPreScanRxECB +LSLReSubmitPreScanTxECB +LSLReturnRcvECB +LSLReturnRcvECBNoSave +LSLScheduleAESEventRTag +LSLSendComplete +LSLSendPacket +LSLSendProtocolInfoToOtherEngine +LSLSendProtocolInfoToPartner +LSLServiceEvents +LSLStartCriticalSection +LSLUnbindStack +LSLUnBindThenDeRegisterMLID +LStrCmp +LStrCpy +LStrToUpperCase +MacDelete +MacEnumerate +MacGetEntryID +MacGetEntryInformation +MacMakeDirectory +MacMakeDOSHandle +MacMakeFile +MacMapFileHandleToID +MacOpen +MacRename +MacSetInfo +MakeQ +MakeQEntry +MapAbsoluteAddressToCodeOffset +MapAbsoluteAddressToDataOffset +MapCodeOffsetToAbsoluteAddress +MapConnectionToInternetAddress +MapDataOffsetToAbsoluteAddress +MapDirectoryNumberToPath +MapDirectoryToAnyHandle +MapEventNameToEventTypeID +MapEventTypeIDToEventName +MapExternalToInternalDirNumber +MapFileHandleToFCB +MapInternalToExternalDirNumber +MapMacIDToNetWare +MapObjectToStationList +MapPathToDirectoryNumber +MapPathToDirectoryNumberOrPhantom +MapShortNameToMacID +MapSubdirectoryToSpaceNode +MapUserToStationList +MapUserToStn +MapVolumeNameToNumber +MarkDirectoryEntryChanged +MM_Abort_Function +MM_AddMessageToExecuteList +MM_ActivateObject +MM_Attach_Filter +MM_Check_For_Pending_Aborts +MM_CheckCacheBuffer +MM_CheckDevice +MM_Create_Media_Object +MM_DeactivateObject +MM_DecrementAbortsPending +MM_DecrementIOsPending +MM_DecrementNotifiesPending +MM_DecrementScansPending +MM_Delete_Media_Object +MM_Detach_Filter +MM_ExecuteMessages +MM_Find_Identifier +MM_Find_Object_Type +MM_GetCacheBuffer +MM_GetCacheBufferNoWait +MM_IncrementAbortsPending +MM_IncrementIOsPending +MM_IncrementNotifiesPending +MM_IncrementScansPending +MM_IdentifyMedia +MM_InvalidateCacheBuffer +MM_Object_Blocking_IO +MM_Object_IO +MM_ObjectManagerFunction +MM_Register_Application +MM_Register_Attribute +MM_Register_Identification_Routines +MM_Register_Notify_Routine +MM_Register_Cache_Extender +MM_RegisterObject +MM_RegisterObjectManager +MM_ReleaseCacheBuffer +MM_Release_Object +MM_Release_Unload_Semaphore +MM_RemoveMessageFromExecuteList +MM_Rename_Object +MM_ReplaceObjectManager +MM_Reserve_Object +MM_Return_Identifier_Info +MM_Return_Media_Manager_Statistics +MM_Return_Object_Attribute +MM_Return_Object_Generic_Info +MM_Return_Object_Mapping_Info +MM_Return_Object_Specific_Info +MM_Return_Object_Table_Size +MM_Return_Objects_Attributes +MM_ScanForNewDevices +MM_ScanForNewPartitions +MM_Set_Object_Attribute +MM_Set_Unload_Semaphore +MM_Special_Object_Blocking_IO +MM_Unregister_Application +MM_Unregister_Cache_Extender +MM_Unregister_Identification_Routines +MM_Unregister_Notify_Routine +MM_UnregisterObject +MM_UnregisterObjectManager +ModifyBranchTableEntry +ModifyDirectoryEntry +ModifyDOSAttributes +ModifyGlobalBranchEntry +MountDevice +MountVolume +MoveFileDataFromDM +MoveFileDataToDM +MoveQEntry +NCPBoundaryError +NCPComponentError +NCPTablesAllocTag +NDSCreateStreamFile +NDSDeleteStreamFile +NDSOpenStreamFile +NetManAddNLMSubject +NetManGetNumOfSubjects +NetManGetSubjectIDList +NetManGetSubjectItemCount +NetManGetSubjectItemIDList +NetManGetSubjectItemIDFList +NetManGetSubjectItemInfo +NetManGetSubjectItemInfo2 +NetManIDEventGroupListFunction +NetManIDGetAlertFlags +NetManIDGetAlertNotifyBits +NetManIDGetLocalValue +NetManIDGetRoutine +NetManIDSetAlertFlags +NetManIDSetAlertNotifyBits +NetManIDSetRoutine +NetManIDUpdate +NetManRemoveNLMSubject +NetManReplaceUpdateRoutine +NetManResetUpdateRoutine +NetWareAlert +NewLogKey +NextGlobalBranchPDE +NMIDisableParity +NMIEnableParity +NullCheck +NVMGetHighestPhysicalAddress +NWAuditNLMAddRecord +NWAuditRegisterIDName +NWAuditSetProcessID +NVMKernelLock +NVMKernelUnlock +OldEditQEntry +OldGetQJobs +OldMakeQEntry +OldReadQEntry +OldReadQStatus +OldServiceQ +OpenCustomScreen +OpenEAHandle +OpenFile +OpenFileUsingSearchPath +OpenLock +OpenPopUpScreen +OpenScreen +OSAbend +OSCompareStrings +OSConvertStringToUpperCase +OSGetChar +OSGetCollationTable +OSGetCountryInfo +OSGetCodePage +OSGetDBCSVector +OSIsDoubleByteCharacter +OSIsDoubleByteUsed +OSPutChar +OSScanForTimeOffset +OSStrChr +OSStrCSpn +OSStrNCat +OSStrPBrk +OSStrRChr +OStime +OSTZSet +OutputToScreen +OutputToScreenInMargins +OutputToScreenNoAttribute +OutputToScreenPointerAttribute +OutputToScreenWithAttribute +OutputToScreenWithPointer +OutputToString +OutputToStringWithPointer +OutputWithPointerNoAttribute +ParseCommand +ParseDriverParameters +ParseTree +PartitionBlockingIO +PartitionIO +PartitionLock +PartitionRelease +Pause +PauseWithEscape +PeekDMFileData +PositionInputCursor +PositionOutputCursor +PositionRawCursor +ProcessMountVolume +ProcessNCPPacket +ProcessNCPPacketWithLength +ProcessRemoteDisableTTSCommand +ProcessRemoteEnableTTSCommand +PromptForUnsignedNumber +PromptForYesOrNo +PSSRegister +PurgeDeletedFile +PurgeTrustee +PutIOCTL +PutRequest +QJobSize +QueueEventReport +QueueEventReportWithPointer +RawHookINT7 +RawUnHookINT7 +ReadEAData +ReadEISAConfig +ReadExtendedDirectorySpace +ReadFile +ReadLoggedInConsoleUser +ReadPhysicalMemory +ReadQEntry +ReadQStatus +ReadScreenCharacter +RealTimeDataMigratorInfo +ReEnableConnection +RegisterAlternateKeyHandler +RegisterAuditService +RegisterBroadcastNotification +RegisterCommand +RegisterCommandLineInfo +RegisterCompressionAlgorithm +RegisterConnectionPolicy411 +RegisterConsoleCommand +RegisterContextSaveRestore +RegisterDebugCommandParser +RegisterDebuggerRTag +RegisterDecompressionAlgorithm +RegisterDMSupportModule +RegisterEventType +RegisterFileLockSWait +RegisterFileLockWait +RegisterForEventNotification +RegisterHardwareOptions +RegisterMarshallingCode +RegisterNameService +RegisterNCPExtension +RegisterNCPSecurityExtender +RegisterNSSFlushAPIs +RegisterNSSMemoryAPIs +RegisterOpenCallBack +RegisterOSCoredumpHandler +RegisterPage +RegisterPagesWithNLM +RegisterRecordLockWait +RegisterRouter +RegisterRTDataMigrationNLM +RegisterScreenHandler +RegisterScreenInputRoutine +RegisterServiceSendMessage +RegisterServiceFreeRoutine +RegisterSetableParameter +RegisterSpecificNCPExtension +RegisterSystemCall +RegisterTrackedResource +ReleaseNCPVerb +ReleasePRec +ReleaseRecord +RelFileSet +RelPRecLocks +RelRecSet +RelTNode +RemoveConnectionHighPrivileges +RemoveConnectionSecondAuthentication +RemoveDiskDevice +RemoveFSMonitorHook +RemovePollingProcedure +RemoveScreenKeyboardOwner +RenameEntry +RenameNameSpaceEntry +ReplyCompletionCodeOnly +ReplyKeep +ReplyUsingBuffer +RescheduleFromInterruptNoSave +RescheduleLast +ReserveABreakpointRTag +ResetRemirrorBlock +ResetRouter +ResetStation +RestartServer +RestoreBranchTableEntry +RestoreFullScreen +RestoreGlobalBranchEntry +RestoreLoginState +RestoreScreenArea +RestoreScreenKeyboardOwner +RetryXFSLock +ReturnAConnectionNumber +ReturnBinderyContext +ReturnBootTableInfo +ReturnConnectionSigningLevel +ReturnDataStreamName +ReturnDefaultGlobalDataPDE +ReturnDeviceCount +ReturnDeviceHandleMMObjectID +ReturnDeviceInfo +ReturnDirectoryHandle +ReturnDirectorySpaceRestrictions +ReturnDriveName +ReturnExtendedDirectorySpace +ReturnFATChain +ReturnFileHandle +ReturnFileMappingInformation +ReturnFileServerName +ReturnHardwareLoaderID +ReturnIOEngineName +ReturnIOInternalNetNumber +ReturnLogicalPartitionCount +ReturnLogicalPartitionInfo +ReturnMappedMemory +ReturnMessage +ReturnMessageInformation +ReturnMirrorInfo +ReturnMovableCacheMemorySize +ReturnNameSpaceName +ReturnNetWareVolumeInfo +ReturnNotChargedFATChain +ReturnOSLanguageID +ReturnOSLanguageName +ReturnOtherIOEngineName +ReturnOtherIOInternalNetNumber +ReturnPartitionCount +ReturnPartitionInfo +ReturnRedirectionInfo +ReturnReplyBuffer +ReturnScreenType +ReturnServerSigningLevel +ReturnSetParameterCategoryInfo +ReturnSystemCount +ReturnSystemInfo +ReturnVolumeBlockInformation +ReturnVolumeMappingInformation +ReturnVolumeMappingTableSize +RevokeFileHandleRights +RevokeSupervisorMailDirectoryAccess +RevokeUserConsoleOperatorPrivileges +RingTheBell +RIPDisplayTable +RIPGetControlAdaptor +RIPGetKnownNetworks +RIPGetNetEntry +RIPGetNetRouters +RIPReset +RIPScanControlAdaptor +RIPSetControlAdaptor +RIPTrackOff +RIPTrackOn +RTDMRequest +SalvageDeletedFile +SAPAddFilter +SAPDeleteFilter +SAPDisplayTable +SAPGetControlAdaptor +SAPGetKnownServers +SAPGetServerEntry +SAPGetServerSources +SAPRefreshBindery +SAPReset +SAPScanControlAdaptor +SAPScanFilters +SAPSetControlAdaptor +SAPTrackOff +SAPTrackOn +SaveFullScreen +SaveScreenArea +ScanBitBlocks +ScanBits +ScanBusInfo +ScanClearedBits +ScanDeletedFiles +ScanForEAHandle +ScanForNewDevices +ScanForNewPartitions +ScanSetableParameters +ScanTrusteeRights +ScanUserRestrictionNodes +ScanVolumeForTrustee +ScheduleInterruptTimeCallBack +ScheduleNoSleepAESProcessEvent +ScheduleSleepAESProcessEvent +SCloseSem +SCreateSemaphore +ScrollScreenArea +SendBroadcastMessageToList +SendConnectionMessage +SendPacket +ServerProcessBeingReturned +ServiceQ +ServiceQByFormList +ServQAbort +ServQAttach +ServQDetach +ServQFinish +SetABreakpoint +SetAcceptBroadcastMessages +SetBellWasRung +SetBinderyContext +SetClrNameSpaceName +SetCMCLoaderSymbols +SetCompressedFileSize +SetConnectionListHasChanged +SetConnectionObjectName +SetConnectionServiceInformation +SetConnectionTransportAddress +SetCursorStyle +SetDeviceDescription +SetDirectoryStatusInformation +SetExceptionHandler +SetFaultSignal +SetFileSize +SetFlags +SetHardwareInterrupt +SetHugeInformation +SetInputToOutputCursorPosition +SetLocalTimeFromUTC +SetLocalTimeVectorFromUTC +SetLogAllowed +SetLogicalPartitionDescription +SetOSLanguageID +SetOwningNameSpace +SetPMPrivateSymbolHandler +SetPartitionDescription +SetPCBDirectoryServicesStuff +SetPublicAddress +SetQPriority +SetQServStatus +SetQStatus +SetScreenPhysicalAddress +SetSetableParameterValue +SetSignalDebuggerOptions +SetSyncClockFields +SetSystemDescription +SetTimeFromVector +SetTimeZone +SetTransFlags +SetTTaskFlags +SetUTCTimeFromLocal +SetVolumeFlags +SetVolumeObjectID +SExamineSemaphore +SGUIDReturnServerGUID +ShrinkMovableCacheMemory +SignalDebuggerEvent +SignalFault +SizeOfAllocBlock +SkipReceiveBufferReturn +SleepUntilInterrupt +sprintfWithPointer +SPSemaphore +SPXAbortConnection +SPXCancelSessionListen +SPXCheckInstallation +SPXEstablishConnection +SPXFindSession +SPXGetConnectionStatus +SPXListenForConnectedPacket +SPXListenForConnection +SPXListenForSequencedPacket +SPXSendSequencedPacket +SPXSequencedPacketReceived +SPXTerminateConnection +StartQEntry +StartVolumeSync +StartScreenUpdateGroup +StartSleepNotAllowed +StartVolumeExpansion +StopBell +StopServer +StuffValue +SuspendProcessWaitingForInput +SuspendProcessWaitingForScreen +SVSemaphore +SwapServRights +SwitchSearchPathToSYSVolume +SwitchStacksAndCall +SwitchStacksAndCallWithPointer +SwitchToDirectFileMode +SynchronizeMirroredPartition +SystemBlockingIOCTL +SystemIOCTL +SystemLock +SystemRelease +TemporarilyDisableConnection +TotalKnownSystemMemory +TransferInfoTable +TTrackAbort +TTrackOff +TTrackOn +TTSCheck +TTSCheckTransaction +TTSSetTransaction +TTSState +UnAdjustRealModeInterruptMask +UnBindProtocolFromDriver +UnExpandVolumeTables +UnformattedOutputNoAttribute +UnformattedOutputToScreen +UnformattedOutputWithAttribute +UngetKey +UnImportPublicSymbol +UnloadModule +UnlockDevice +UnLockDirectoryEntry +UnlockRec +UnRegisterAlternateKeyHandler +UnRegisterBroadcastNotification +UnRegisterConsoleCommand +UnRegisterCompressionAlgorithm +UnRegisterDebugCommandParser +UnRegisterDebugger +UnRegisterDecompressionAlgorithm +UnRegisterEventNotification +UnRegisterNCPSecurityExtender +UnRegisterPage +UnRegisterPagesWithNLM +UnRegisterScreenHandler +UnRegisterScreenInputRoutine +UnRegisterServiceSendMessage +UnRegisterServiceFreeRoutine +UnRegisterTrackedResource +UnReserveABreakpoint +UnregisterMarshallingCode +UnregisterSystemCall +UnsetCMCLoaderSymbols +UnsynchronizeMirroredPartition +UpdateDirectory +UpdateUserSecurityEquivalences +UpTimeInSeconds +ValidateModuleHandle +VCFilePhyLocks +VCFileTasks +VCLRecTasks +VCSemaphoreTasks +VCStnFiles +VCStnLockStatus +VCStnLRecs +VCStnPhyLocks +VCStnSems +VerifyConnectionSecurityLevel +VerifyDataStreamNumber +VerifyNameSpaceNumber +VerifyNetWarePartition +VM_Change_Volume_Status +VM_Find_Next_Volume +VM_Get_Volume_ID +VM_Register_Volume +VM_Return_Volume_Info +VM_Unregister_Volume +VM_Volume_Abort_Request +VM_Volume_Request +VM_Volume_Request_Complete +VMMapVolumeNameToNumber +VolClean +VolumeDMInformation +VolumeRead +VolumeReadAndWait +VolumeWrite +VolumeWriteAndWait +WaitForBroadcastsToClear +WaitOnRemoveSemaphore +WriteEAData +WriteExtendedDirectorySpace +WriteFile +WriteLastFATSector +WritePhysicalMemory +WriteScreenCharacter +YieldIfNeeded +YieldWithDelay +YieldUntilIdle + + + +AbortVolumeMount +ActivePCBsList +AlternateProcess +AlternateProcessPCB +AlternateProcessPDE +AsciiToUnicode +AuditService +breakOnLoadFlag +CacheByteToBlockShiftFactor +ChangeDataStream +ChangeStreamsToLimbo +ChangeToPhantomEntry +CheckAndConvertName +CheckNameIgnoreLocks +ClearExtraNameSpaceEntries +CompareFileNames +CompressionLowerLimit +CompressMinimumPercentageGain +CreateArchiveChanged +CurrentDebuggerDomain +CurrentDomain +CurrentDR7 +DebuggerSymbolList +DelayedWorkToDoList +DeleteLimboFile +DirectoryEntryUsed +DirectoryLengthInBlocks +DiskList +DOSToMAC +DoVolumeDismount +DupFileHook +EAAccessTable +EndVolumeMount +EntryLockedBitTable +ExhumeLimboFile +ExtBranchTable +ExtBranchTableEnd +ExternalPublicList +FastVolumeMountFlag +FindDirectoryEntry +FindDirectoryEntryOrPhantom +FirstRPCStackPage +FixedFieldsMask +FSEngineDebug +GenerateUniqueName +GetDataStream +GetDirectoryHandle +GetExtendedInfo +GetHugeInfo +GetName +GetNameLength +GetPath +GetSpaceUtilized +GlobalCode +GlobalCodeEnd +GlobalCodePDE +GlobalData +GlobalDataPDE +GrowDirectoryTables +HashSearchListTable +haveConfigInformation +HighMovableMemory +HighMovableMemoryEnd +HugeFieldsMask +inDebuggerOrISRFlag +InternalModuleList +InternalOldPublicList +InternalPublicList +LocalNodeAddressTable +IOConfigurationList +LowPriorityCheckPCB +LowPriorityRunListHead +MACToDOS +MapDataStreamToNameSpace +MapNameSpaceToPosition +MapPositionToNameSpace +MarkDeletedFile +MatchAttributes +MaximumByteCount +MaximumByteMask +MaximumDiskIOBufferSize +MessageMappingTable +MessageMappingTableSize +MLIDProtocolListByBoard +ModifyDirectoryFields +NameService +NameSpaceLoadedVector +NameSpaceFlags +NCPBoundCheckFlag +NeedsCreateArchiveNoticeTable +NestedInterruptCount +NextBlockListTable +NFSTOC +NSFieldsLengthTable +NumberOfDefinedNameSpaces +ObjectMappingTable +ObjectMappingTableSize +OSBroadcastAllocTag +OSInternalTable +OSInternalTabPDE +OSInternalTabPTE +OSShortTermAllocTag +OSTimerResourceTag +PatchStamp +preParseRoutine +RealModeStack +RemoveEntryName +RemoveInfoFromLimboFile +RemoveOtherInfo +relinquishControlWarningFlag +RenameEntryName +ResourceSignatureList +RPCCodeArea +RPCCodeEnd +RPCCodePDE +RPCCodePTE +RunningDomainDCB +RunningDomainMAP +ScreenAddress +ServerMemBytesNotInPageList +ServerMemBlocksNotInPageList +SetDeletedFileEntryName +SetEntryName +SetHighLevelHugeInfo +SetLowLevelHugeInfo +SetRestOfFileEntry +SetRestOfSubDirEntry +StartNameSpaceAdditionToVolume +StartVolumeMount +StatisticsList +StopCompressionTable +SubdirectoryBitTable +SubdirectoryNumberVectorTable +SynchronizedClock +systemConsoleScreen +TimeInMinutes +titleBarSaveBuffer +TransferFileNameAndInfoToLimbo +TransferInfo +TransferLimboInfoToFile +TransferOnlyInfoToLimbo +UnConvertName +UnicodeToAscii +UPSConfigurationPointer +ValidateAddressRangePresent +VariableFieldsMask +VerifyDeletedFile +VerifyOnlyName +VerifyOtherFields +VolumeDriveStartVector +VolumeMountedFlag +VolumePartitionIDVectorTable +VolumeStartingSectorVectorTable +WildCardPattern +WildReplace +WildSearchDirectory +WildSearchDirectoryEntry +WildSearchDirFromInfo +UTCTime +connectionTable +numberOfConnectionSlots +SwitchVector +NumberOfVolumes +StationAttemptedToUseBadPacket +OSHandle +StationUsedBadPacket +NCPHasBadSubFunctionLength +NCPUsedBadSubFunctionLength +NCPBoundCheckFailed +NCPCompCheckFailed +NCPBoundWarningFlag +NCPCompCheckFlag +NCPCompWarningFlag +ErrCase +MLIDMaximumPacketSize +PBInternalSendPacketWithSignatures +WriteActiveList +PBInternalDelaySendPacketWithSignatures +WriteControlAvailList +LocaleTable +GetDebugScreenID +MaximumNumberOfServerProcesses +MinimumNumberOfServerProcesses +RegisterSetParameterCategory +DeRegisterSetParameterCategory +RegisterSetParameter +DeRegisterSetParameter +IsNLMLoaded +DecrementResourceTagResourceCount +GetDefinedResourceTypeCount +GetInternalModuleList +GetLoadedModuleCount +GetLoadedModuleList +GetModuleInfo +GetModuleResourceTagCount +GetModuleResourceTagInfo +GetModuleResourceTagList +GetModuleResourceTagListByResourceType +GetResourceTypeDefinitionInfo +GetResourceTypeDefinitionList +IncrementResourceTagResourceCount +kCancelCallOut +kClearCurrentThreadCallingFromUserSpace +kClearHighWaterThreadTime +kClearThreadCallingFromUserSpace +kCMakeProcess +kContextSwitchMonitor +kCVAlloc +kCVBroadcast +kCVDestroy +kCVSignal +kCVTimedWait +kCVWait +kDisableContextSwitchMonitor +kDoublyLinkedListAddElement +kDoublyLinkedListAddElementNoLock +kDoublyLinkedListAlloc +kDoublyLinkedListGetFirstElementNoLock +kDoublyLinkedListDeleteElement +kDoublyLinkedListDeleteElementNoLock +kDoublyLinkedListFree +kDoublyLinkedListInit +kDoublyLinkedListReadLock +kDoublyLinkedListReadUnlock +kDoublyLinkedListWriteLock +kDoublyLinkedListWriteUnlock +kEnableContextSwitchMonitor +kEnterCriticalSection +kExitCriticalSection +kGetCPUUtilization +kGetCriticalSectionStatus +kGetHighWaterThreadTime +kGetThreadAddressSpaceID +kGetThreadAuditUserID +kGetThreadJavaData +kGetThreadLibraryContext +kGetThreadLoadHandle +kGetThreadNDSData +kGetThreadOnCpu +kGetThreadResourceTagValue +kGetThreadState +kGetThreadSuspendReason +kGetThreadWinSockData +kGetThreshold +kGetTotalThreadTime +kGetWorkerThreadFlag +kMutexCount +kMutexQuery +kQueValidate +kQueLightValidate +kRegisterPoll +kResumePoll +kRWUnlock +kScheduleCallOut +kSemaphoreCount +kSemaphoreQuery +kSemaphoreSignalAll +kSetApplicationPolicy +kSetExSetShimRetAddress +kSetCurrentThreadCallingFromUserSpace +kSetThreadArgument +kSetThreadAuditUserID +kSetThreadCallingFromUserSpace +kSetThreadJavaData +kSetThreadLibraryContext +kSetThreadLoadHandle +kSetThreadNDSData +kSetThreadWinSockData +kSetThreshold +kSleep +kSpinLock +kSpinLockDisable +kSpinLockInit +kSpinRWLockAlloc +kSpinRWLockFree +kSpinRWReadLock +kSpinRWReadUnlock +kSpinRWLockValidate +kSpinRWWriteLock +kSpinRWWriteUnlock +kSpinTryLock +kSpinTryLockDisable +kSpinUnlock +kSpinUnlockRestore +kSuspendPoll +kSuspendThreadNonBlocking +kThreadAcquireAuditGenerateRecordFlag +kThreadAcquireAuditIDNameFlag +kThreadReleaseAuditGenerateRecordFlag +kThreadReleaseAuditIDNameFlag +kTraceGetInterface +kTraceRecordEvent +kTraceRecordTraceEvent +kUnblockThreadWithResume +kUnblockThreadNoResume +kUnregisterPoll +kWakeUp +atomic_add +atomic_bts +atomic_btr +atomic_dec +atomic_inc +atomic_sub +atomic_xchg +GetTimerMinorTicksPerSecond +kAllocExSetStateSaveArea +kAllocQue +kAllocQueLight +kBarrierAlloc +kBarrierDecrement +kBarrierFree +kBarrierIncrement +kBarrierThreadCount +kBarrierWait +kBarrierWaitCount +kBindExSet +kBindThread +kCancelWorkToDo +kConditionAlloc +kConditionBroadcast +kConditionDestroy +kConditionSignal +kConditionTimedWait +kConditionWait +kCreateApplication +kCreateExSet +kCreateThread +kCreateThreadInitTime +kCurrentExSetBinding +kCurrentThread +kCurrentThreadBinding +kDelayThread +kDeQue +kDeQueAll +kDeQueAllNoLock +kDeQueByQLINK +kDeQueByQLINKNoLock +kDeQueLight +kDeQueLightAll +kDeQueLightAllNoLock +kDeQueLightByQueLink +kDeQueLightByQueLinkNoLock +kDeQueLightNoLock +kDeQueLightWait +kDeQueLightWaitNoLock +kDeQueNoLock +kDeQueWait +kDeQueWaitNoLock +kDestroyApplication +kDestroyExSet +kDestroyThread +kEnQue +kEnQueLight +kEnQueLightNoLock +kEnQueNoLock +kEnQueOrdered +kEnQueOrderedNoLock +kEnterExSet +kEnterNetWare +kEnterNetWareExSet +kExitClassicNetWare +kExitExSet +kExitNetWare +kExitNetWareExSet +kExitThread +kFirstQueLinkLightNoLock +kFirstQLINKNoLock +kFreeExSetStateSaveArea +kFreeQue +kFreeQueLight +kGetAppExecutionTime +kGetApplicationHandle +kGetApplicationList +kGetApplicationName +kGetApplicationShare +kGetApplicationThreadCount +kGetCurrentAvailableStackSize +kGetEffectiveBinding +kGetExSetHandle +kGetNumberOfApplications +kGetProcessorStatus +kGetThreadApplication +kGetThreadAttributes +kGetThreadContext +kGetThreadExitCode +kGetThreadList +kGetThreadName +kGetThreadPriority +kGetThreadProcessorAssignment +kGetThreadStackInfo +kGetThreadUserData +kGetUserStackInfo +kMutexAlloc +kMutexCount +kMutexFree +kMutexRecursiveCount +kMutexLock +kMutexQuery +kMutexTimedWait +kMutexTryLock +kMutexUnlock +kMutexWaitCount +kPushQue +kPushQueLight +kPushQueLightNoLock +kPushQueNoLock +kPushQueOrdered +kPushQueOrderedNoLock +kQueCount +kQueLightCount +kRestoreExSetState +kResumeThread +kReturnCurrentProcessorID +kReturnOnLineProcessorCount +kReturnPhysicalProcessorCount +kRWLockAlloc +kRWLockFree +kRWLockInfo +kRWReaderToWriter +kRWReadLock +kRWReadTryLock +kRWReadUnlock +kRWWriteLock +kRWWriterToReader +kRWWriteTryLock +kRWWriteUnlock +kSaveExSetState +kScheduleFastWorkToDo +kScheduleFastWorkToDoDirected +kScheduleFastWorkToDoLocal +kScheduleThread +kScheduleWorkToDo +kScheduleWorkToDoDirected +kSemaphoreAlloc +kSemaphoreExamineCount +kSemaphoreFree +kSemaphoreSignal +kSemaphoreTimedWait +kSemaphoreTry +kSemaphoreWait +kSemaphoreWaitCount +kSetApplicationPolicy +kSetApplicationShare +kSetThreadApplication +kSetThreadAttributes +kSetThreadKernelStackInfo +kSetThreadUserData +kSetThreadName +kSetThreadPriority +kStartProcessor +kStartThread +kStopProcessor +kSuspendThread +kThreadCheckForSuspendKill +kUnbindExSet +kUnbindThread +kWorkToDoInExSet +kYieldThread +RunningProcess +IsConnectionValid +GetConnectionPSS +GetConnectionAuthIDsList +SetConnectionPSS +SetConnectionStatus +ReturnConnectionNCPHandleValue +CreateAndAddNCPHandleToConnection +ModifyConnectionNCPHandle +ConnectionDestroyNCPHandle +ClearConnectionNCPHandlesForVolume +ClearConnectionNCPHandlesVolumeDirBase +RegCloseKey +RegCreateKeyEx +RegDeleteKey +RegEnumKeyEx +RegOpenKeyEx +RegQueryInfoKey +RegQueryValueEx +RegSetValueEx +GetAllBoundNetWorkInfo +ReturnResourceTag +CpuCurrentProcessor +open_logfile +logger_set_property +close_logfile +logger diff --git a/include/nwnss/include/WithMPKSpinLock.h b/include/nwnss/include/WithMPKSpinLock.h new file mode 100644 index 0000000..7bb1235 --- /dev/null +++ b/include/nwnss/include/WithMPKSpinLock.h @@ -0,0 +1,229 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) / Distributed File Services (DFS) + | + |--------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2005-04-13 22:08:08 +0530 (Wed, 13 Apr 2005) $ + | + | $RCSfile$ + | $Revision: 927 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Provide a means for an NSS NLM that is internally MPK safe to operate + | without holding the NSS MPK Spin Lock except where required for + | specific NSS function calls as defined by the macros below. + +-------------------------------------------------------------------------*/ + +#ifndef _WITHMPKSPINLOCK_H_ +#define _WITHMPKSPINLOCK_H_ + + +/* If we are compiling six pack code for Cobra */ +#ifdef NSS_ON_NW56_MODE + +/* Include the MPK headers */ +#include +#include + +/* Function style macros */ +#define ASSERT_MPKNSS_LOCK() /* Fake the assert on the NSS MPK lock for the pre-MP version of NSS */ +#define MPKNSS_LOCK() /* Fake the NSS MPK lock for the pre-MP version of NSS */ +#define MPKNSS_UNLOCK() /* Fake the NSS MPK unlock for the pre-MPK version of NSS */ + +#define microSecondTimer() ((QUAD)GetHighResClock() * (QUAD)100) + +#endif + + +#ifdef TOTALALLOCS +/* + These need to be defined in the source for the NLM being compiled with the TOTALALLOCS macro enabled +*/ +extern LONG AllocBytes; +extern LONG AllocPages; +#endif + + +/* + Manifest constants +*/ + + +/* New types */ + + +/* Function style macros */ +#define NOZOS_UnRegisterEventNotification(_p1) \ + UnRegisterEventNotification(_p1); + +#define WithMPKLock_ByteToUnicode(_ret, _arg1, _arg2, _arg3, _arg4, _arg5) \ + { \ + MPKNSS_LOCK(); \ + _ret = LB_ByteToUnicode(_arg1, _arg2, _arg3, _arg4, _arg5); \ + MPKNSS_UNLOCK(); \ + } +#define WithMPKLock_COMN_NameToUnicode(_ret, _arg1, _arg2, _arg3, _arg4, _arg5) \ + { \ + MPKNSS_LOCK(); \ + _ret = COMN_NameToUnicode(_arg1, _arg2, _arg3, _arg4, _arg5); \ + MPKNSS_UNLOCK(); \ + } + +#define WithMPKLock_exitMyselfAndReturn(_arg1, _arg2) \ + { \ + MPKNSS_LOCK(); \ + LB_exitMyselfAndReturn(_arg1, _arg2); \ + MPKNSS_UNLOCK(); \ + } + +#if zNETWARE +#ifndef TOTALALLOCS +#define WithMPKLock_free(_arg1) { \ + MPKNSS_LOCK(); \ + free(_arg1); \ + MPKNSS_UNLOCK(); \ + } +#else +#define WithMPKLock_free(_arg1) { \ + MPKNSS_LOCK(); \ + atomic_sub(&AllocBytes, *(((LONG *)_arg1)-1)); \ + free(((LONG *)_arg1)-1); \ + MPKNSS_UNLOCK(); \ + } +#endif +#else +#define WithMPKLock_free(_arg1) free(_arg1); +#endif + +#ifndef TOTALALLOCS +#define WithMPKLock_freePage(_arg1, _arg2) { \ + MPKNSS_LOCK(); \ + freePage(_arg1, _arg2); \ + MPKNSS_UNLOCK(); \ + } +#else +#define WithMPKLock_freePage(_arg1, _arg2) { \ + MPKNSS_LOCK(); \ + freePage(_arg1, _arg2); \ + atomic_sub(&AllocPages, _arg2); \ + MPKNSS_UNLOCK(); \ + } +#endif + +#define WithMPKLock_LB_GUIDGenerate(_arg1) { \ + MPKNSS_LOCK(); \ + LB_GUIDGenerate(_arg1); \ + MPKNSS_UNLOCK(); \ + } + +#define WithMPKLock_LB_GUIDToString(_ret, _arg1, _arg2, _arg3) \ + { \ + MPKNSS_LOCK(); \ + _ret = LB_GUIDToString(_arg1, _arg2, _arg3); \ + MPKNSS_UNLOCK(); \ + } + +#if zNETWARE +#ifndef TOTALALLOCS +#define WithMPKLock_malloc(_ret, _arg1) { \ + MPKNSS_LOCK(); \ + _ret = malloc(_arg1); \ + MPKNSS_UNLOCK(); \ + } +#else +#define WithMPKLock_malloc(_ret, _arg1) { \ + MPKNSS_LOCK(); \ + _ret = malloc((_arg1) + 4); \ + *(LONG *)_ret = _arg1; \ + _ret = (void *)(&((LONG *)_ret)[1]); \ + atomic_add(&AllocBytes, _arg1); \ + MPKNSS_UNLOCK(); \ + } +#endif +#else +#define WithMPKLock_malloc(_ret, _arg1) _ret = malloc(_arg1); +#endif + +#ifndef TOTALALLOCS +#define WithMPKLock_mallocPage(_ret, _arg1) { \ + MPKNSS_LOCK(); \ + _ret = mallocPage(_arg1); \ + MPKNSS_UNLOCK(); \ + } +#else +#define WithMPKLock_mallocPage(_ret, _arg1) { \ + MPKNSS_LOCK(); \ + _ret = mallocPage(_arg1); \ + atomic_add(&AllocPages, _arg1); \ + MPKNSS_UNLOCK(); \ + } +#endif + +#ifndef TOTALALLOCS +#define WithMPKLock_realloc(_ret, _arg1, _arg2) \ + { \ + MPKNSS_LOCK(); \ + _ret = realloc(_arg1, _arg2); \ + MPKNSS_UNLOCK(); \ + } +#else +#define WithMPKLock_realloc(_ret, _arg1, _arg2) \ + { \ + MPKNSS_LOCK(); \ + atomic_sub(&AllocBytes, *(((LONG *)_arg1)-1); \ + _ret = realloc(((LONG *)_arg1)-1, _arg2 + 4); \ + *(LONG *)_ret = arg2; \ + _ret = (void *)(&((LONG *)_ret)[1]); \ + atomic_add(&AllocBytes, arg2); \ + MPKNSS_UNLOCK(); \ + } +#endif + +#define WithMPKLock_UnicodeToByte(_ret, _arg1, _arg2, _arg3, _arg4, _arg5) \ + { \ + MPKNSS_LOCK(); \ + _ret = LB_UnicodeToByte(_arg1, _arg2, _arg3, _arg4, _arg5); \ + MPKNSS_UNLOCK(); \ + } + +#define WithMPKLock_uniupr(_ret, _arg1) { \ + MPKNSS_LOCK(); \ + _ret = uniupr(_arg1); \ + MPKNSS_UNLOCK(); \ + } + +#define WithMPKLock_UTCTime2Str(_ret, _arg1, _arg2) \ + { \ + MPKNSS_LOCK(); \ + _ret = UTCTime2Str(_arg1, _arg2); \ + MPKNSS_UNLOCK(); \ + } + +/* Function prototypes */ + + + +#endif diff --git a/include/nwnss/include/adminVolume.h b/include/nwnss/include/adminVolume.h deleted file mode 100644 index 5735aa7..0000000 --- a/include/nwnss/include/adminVolume.h +++ /dev/null @@ -1,236 +0,0 @@ -/**************************************************************************** - | - | (C) Copyright 1995-1998 Novell, Inc. - | All Rights Reserved. - | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. - | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. - | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. - | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com - | - |*************************************************************************** - | - | NetWare Advance File Services (NSS) module - | - |--------------------------------------------------------------------------- - | - | $Author: taysom $ - | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - | - | $RCSfile$ - | $Revision: 465 $ - | - |--------------------------------------------------------------------------- - | This module is used to: - | Support routines for processing legacy operations by NCPs and NLMs - +-------------------------------------------------------------------------*/ -#ifndef _ADMINVOLUME_H_ -#define _ADMINVOLUME_H_ -#include - -#ifndef _QUE_H_ -#include -#endif - -#ifndef _VOLUME_H_ -#include "volume.h" -#endif - -#ifndef _XADMINVOLUME_H_ -#include "xAdminVolume.h" -#endif - -/* Pre-define struct(s) so Linux compiler doesn't complain */ -struct PCLSwitchDef_s; - -#define AVOL_BLOCK_SHIFT 12 /* has 4K blocks */ -#define AVOL_DEFAULT_NUM_BLOCKS 1024 /* has 1meg worth of blocks */ -#define AVOL_MAX_BEAST_SIZE 4096 /* the biggest beast allowed */ -#define AVOL_REALLOC_AMOUNT 8 /* number of block entries to be added on a realloc */ - -typedef enum adminStorageState_e -{ - INIT_STATE = 0, - PERSIST_DATA = 1, -} adminStorageState_e; - -typedef struct AdminVolStorageInfo_s -{ - StorageInfo_s comnInfo; - adminStorageState_e state; - NINT numBlocks; - NINT numEntriesAlloced; - union - { - BYTE *memBlocks[1]; - Blknum_t diskBlocks[1]; - } u; -} AdminVolStorageInfo_s; - -/**************************************************************************** - * ADMIN VOLUME Beast - * - * All of the definitions specific to the admin volume - *****************************************************************************/ -typedef struct AdminVolume_s -{ - Volume_s vol; /* derived from a volume*/ - Zid_t nextZID; /* next ZID to allocate*/ -} AdminVolume_s; - -#define AVOLroot vol.avfile.file.auth.named.root -#define AVOLnamed vol.avfile.file.auth.named -#define AVOLauth vol.avfile.file.auth -#define AVOLfile vol.avfile.file -#define AVOLavfile vol.avfile -#define AVOLvol vol - -#define AVOLzid AVOLroot.zid -#define AVOLbeastClass AVOLroot.beastClass -#define AVOLbeastLatch AVOLroot.mycache.agent.latch -#define AVOLuseCount AVOLroot.useCount -#define AVOLcomnBeastOps AVOLbeastClass->comnOps -#define AVOLcomnVolOps AVOLbeastClass->comnVolOps - -#define AVOLfirstParentZid AVOLnamed.firstParent.p.zid - -#define AVOLrootdir AVOLvol.rootdir -#define AVOLbeastList AVOLvol.beastList -#define AVOLauthModel AVOLvol.authModel -#define AVOLauthModelIndex AVOLvol.authModelIndex -#define AVOLstate AVOLvol.state -#define AVOLagent AVOLvol.agent -#define AVOLstorageIndex AVOLvol.storageIndex -#define AVOLmaxBeastSize AVOLvol.maxBeastSize -#define AVOLsupportedAttributes AVOLvol.supportedAttributes -#define AVOLmaximumFileSize AVOLvol.maximumFileSize - -#define AVOLvolumeID AVOLvol.VOLvolumeID -#define AVOLnameSpaceMask AVOLvol.p.nameSpaceMask -#define AVOLblockSize AVOLvol.p.blockSize -#define AVOLblockShift AVOLvol.p.blockShift -#define AVOLenabledAttributes AVOLvol.p.enabledAttributes - -#define AVOLnextZid AVOLvol.logged.nextZid -#define AVOLtotalBlocks AVOLvol.logged.totalBlocks -#define AVOLinUseBlocks AVOLvol.logged.inUseBlocks -#define AVOLnumFiles AVOLvol.logged.numFiles -#define AVOLnumObjects AVOLvol.logged.numObjects - -/**************************************************************************** - * Globals - *****************************************************************************/ - -/*--------------------------------------------------------------------------- - * Defines the admin volume for the system - *---------------------------------------------------------------------------*/ -extern AdminVolume_s AdminVolume; -extern Volume_s *PersistAdminVolume; -extern Key_t SwapRootKey; -extern Key_t SwapKey; -extern BOOL AdminVolumeIsUsable; - -/*--------------------------------------------------------------------------- - * Well Known ZIDs for the Admin Volume's first level directories - *---------------------------------------------------------------------------*/ -//#define ADMVOL_STORAGE_POOL_ZID (zINVALID_ZID+3) /* Directory for all physical storage */ - - -STATUS ADMINVOL_InitPersistentStorage( - struct GeneralMsg_s *genMsg); - -File_s *COMN_AVOL_ResolveLink( - struct GeneralMsg_s *genMsg, - struct NamedBeast_s *beast); - -void AVOL_PolicySetLoadTimeActivateVolume( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); - -void AVOL_PolicySetLoadTimeDeactivateVolume( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); - -void AVOL_PolicySetLoadTimeVerifyVolume( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); - - -NINT AVOL_PolicyObtainLoadTimeVolumeState( - Volume_s *volume ); - -//NINT AVOL_PolicyObtainLoadTimeVerify( -// Volume_s *volume ); - - -void AVOL_PolicySetLoadTimeActivatePool( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); - -void AVOL_PolicySetLoadTimeDeactivatePool( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); - -void AVOL_PolicySetLoadTimeMaintenancePool( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); - -void AVOL_PolicyDisplayLoadTimePool( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); - -void AVOL_PolicyDisplayLoadTimeVolume( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); - -void AVOL_PolicySetLoadTimeVerifyPool( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); - - -NINT AVOL_PolicyObtainLoadTimePoolState( - Pool_s *volume, - BOOL verbose ); - -NINT AVOL_PolicyObtainLoadTimeVerifyPool( - Pool_s *volume ); - -void AVOL_PolicyShutdown(); -void AVOL_PolicyStartup(); - -extern unicode_t *AVOL_PolicyLoadTimeDeactivePool; -extern unicode_t *AVOL_PolicyLoadTimeMaintenancePool; -extern unicode_t *AVOL_PolicyLoadTimeVerifyPool; -extern unicode_t *AVOL_PolicyLoadTimeActivePool; - -extern unicode_t *AVOL_PolicyLoadTimeDeactivePoolPolicyDefault; -extern unicode_t *AVOL_PolicyLoadTimeMaintenancePoolPolicyDefault; -extern unicode_t *AVOL_PolicyLoadTimeVerifyPoolPolicyDefault; -extern unicode_t *AVOL_PolicyLoadTimeActivePoolPolicyDefault; - -extern unicode_t *AVOL_PolicyLoadTimeDeactiveVolume; -extern unicode_t *AVOL_PolicyLoadTimeActiveVolume; - -extern unicode_t *AVOL_PolicyLoadTimeDeactiveVolumePolicyDefault; -extern unicode_t *AVOL_PolicyLoadTimeActiveVolumePolicyDefault; - -#endif /* _ADMINVOLUME_H_ */ diff --git a/include/nwnss/include/admindrv.h b/include/nwnss/include/admindrv.h new file mode 100644 index 0000000..743247c --- /dev/null +++ b/include/nwnss/include/admindrv.h @@ -0,0 +1,50 @@ +/**************************************************************************** + | + | (C) Copyright 2004 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Define strutures needed by admin upcall driver. + | + +-------------------------------------------------------------------------*/ +#ifndef _ADMINDRV_H_ +#define _ADMINDRV_H_ + +#define ADMD_DEVICE_NAME "admindrv" + +int admd_request( + int requestLen, + char *request, + int *replyLen, + char **reply); + + +#endif diff --git a/include/nwnss/include/afpAuthInfo.h b/include/nwnss/include/afpAuthInfo.h new file mode 100644 index 0000000..c1194d2 --- /dev/null +++ b/include/nwnss/include/afpAuthInfo.h @@ -0,0 +1,119 @@ +/**************************************************************************** + | + | (C) Copyright 1988-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This header shares login data types between AFPTCP and LSMAFP3 modules. + +-------------------------------------------------------------------------*/ +#ifndef AFP_AUTH_INFO_H +#define AFP_AUTH_INFO_H + +#include // MAX_DN_CHARS, MAX_TREE_NAME_CHARS +#include // NWDSContextHandle + + +typedef enum authRequest_e +{ + AUTHREQ_GUEST, + AUTHREQ_CLEARTEXT, + AUTHREQ_RANDOMNUM, + AUTHREQ_TWOWAYRANDOMNUM, + AUTHREQ_RANDOMNUMCONT, + AUTHREQ_TWOWAYRANDOMNUMCONT, + CHANGEPASSWRD_CLEARTEXT, + CHANGEPASSWRD_RANDOMNUM, + SETSIMPLEPASSWORD, + SET_UNIVERSAL_PASSWORD, + AUTHREQ_DHX, + AUTHREQ_DHX_CONT, + AUTHREQ_DHX2, + AUTHREQ_DHX2_CONT, + AUTHREQ_KERBEROS, + AUTHREQ_KERBEROS_V4_CONT, + AUTHREQ_KERBEROS_V5_CONT +} authRequest_t; + +#define AUTH_INFO_HEADER_LEN 6 /* size of authInfoSize + authInfoVersion */ +#define AUTH_INFO_VERSION_1 1 +#define AUTH_INFO_VERSION_2 2 + +// Authentication state +#define AUTH_STATE_OFF 0x0000 // NOT authenticated at all +#define AUTH_STATE_ON 0x0001 // fully authenticated for all FPCommands +#define AUTH_STATE_PARTIAL 0x0002 // partially authenticated for change password, logout, etc. +#define AUTH_STATE_SET_NDS_PASSWORD 0x0004 // Universal password not enabled, simple password set, now set NDS password +#define AUTH_STATE_CORP_USER 0x0008 // User is in remote.appusers and must be authenticated with HQ (CORP tree) +#define AUTH_STATE_PWD_TOO_SHORT 0x0010 // err from change password +#define AUTH_STATE_PWD_POLICY_ERR 0x0020 // err from change password +#define AUTH_STATE_PWD_SAME_ERR 0x0040 // err from change password + +// These constants define the password length in BYTES. (Apple isn't counting unicode chars.) +#define LENGTH_OF_AFP_PASSWORD 8 +//#define LENGTH_OF_AFP_DHX_PASSWORD 64 +//#define LENGTH_OF_AFP_DHX2_PASSWORD 256 +#define AFP_USER_NAME_AREA_SIZE 255*6 /* max for 1 char in UTF8 is 6 bytes, although US ascii always takes 1 byte */ + +#define AFP_BYTE_USER_NAME_LENGTH MAX_DN_CHARS + 1 +#define AFP_UNI_USER_NAME_LENGTH 256 +#define AFP_RESERVED_AREA AFP_USER_NAME_AREA_SIZE - (AFP_BYTE_USER_NAME_LENGTH + AFP_UNI_USER_NAME_LENGTH * 2) + +typedef struct authInfo_v1 +{ + /* header fields */ + nint32 authInfoSize; + WORD authInfoVersion; + /* end of header fields */ + + char password[LENGTH_OF_AFP_PASSWORD+1]; // password is null terminated string without leading string length + char newPassword[LENGTH_OF_AFP_PASSWORD+1]; + char userName[AFP_BYTE_USER_NAME_LENGTH]; // 256 bytes + NULL terminator + WORD uniUserName[AFP_UNI_USER_NAME_LENGTH]; // will be stored as UTF16 ) + BYTE reserved [AFP_RESERVED_AREA]; + BYTE randomNum[8]; + BYTE userAuthMethod; // no auth, cleartext, rand num, 2-way rand num, DHX, DHX2, Kerberos + int authenticated; // authentication state + BYTE request; + WORD loginID; + BYTE blobData[8]; + BYTE userRandNum[8]; + BYTE userBlobData[8]; + nint32 mafHandle; + nint32 nmasHandle; + NWDSContextHandle DSContext; + +}authInfo_v1; + + +typedef struct authInfo +{ + union + { + authInfo_v1 v1; + }; +}authInfo; + +#endif diff --git a/include/nwnss/include/alarm.h b/include/nwnss/include/alarm.h index 95a1180..96bfcf5 100644 --- a/include/nwnss/include/alarm.h +++ b/include/nwnss/include/alarm.h @@ -43,8 +43,12 @@ #ifndef _ALARM_H_ #define _ALARM_H_ +#if zLINUX +#include "linux/time.h" +#endif + #ifndef _QUE_H_ -# include +# include #endif #ifdef __cplusplus @@ -54,39 +58,36 @@ extern "C" { typedef struct OneShot_s OneShot_s; typedef struct Cyclic_s Cyclic_s; -typedef void (*OneShotFunc_t)(OneShot_s *alarm); -typedef void (*CyclicFunc_t)(Cyclic_s *alarm); - struct OneShot_s { DQlink_t link; NINT firetime; - OneShotFunc_t function; + void (*function)(OneShot_s *); }; struct Cyclic_s { OneShot_s oneShot; NINT length; - CyclicFunc_t function; + void (*function)(Cyclic_s *); }; extern void fireAlarm(void); extern void alarmInit(void); extern void alarmStart(void); extern void alarmStop(void); -extern void setOneShot(OneShot_s *alarm, LONG ticks, OneShotFunc_t function); -extern void setCyclic(Cyclic_s *alarm, LONG ticks, CyclicFunc_t function); +extern void setOneShot(OneShot_s *alarm, LONG ticks, void (*function)()); +extern void setCyclic(Cyclic_s *alarm, LONG ticks, void (*function)()); #define MSEC2TICK(_x) (((_x) * 182) / 10000) #define SEC2TICK(_x) (((_x) * 182) / 10) #define MIN2TICK(_x) ((_x) * (182 * 6)) #define MILLISEC_PER_TICK 55 -#define msecOneShot(_a, _t, _f) setOneShot((_a), MSEC2TICK(_t), (OneShotFunc_t)(_f)) -#define msecCyclic(_a, _t, _f) setCyclic((_a), MSEC2TICK(_t), (CyclicFunc_t)(_f)) -#define secOneShot(_a, _t, _f) setOneShot((_a), SEC2TICK(_t), (OneShotFunc_t)(_f)) -#define secCyclic(_a, _t, _f) setCyclic((_a), SEC2TICK(_t), (CyclicFunc_t)(_f)) +#define msecOneShot(_a, _t, _f) setOneShot((_a), MSEC2TICK(_t), (_f)) +#define msecCyclic(_a, _t, _f) setCyclic((_a), MSEC2TICK(_t), (_f)) +#define secOneShot(_a, _t, _f) setOneShot((_a), SEC2TICK(_t), (_f)) +#define secCyclic(_a, _t, _f) setCyclic((_a), SEC2TICK(_t), (_f)) #define INIT_ONESHOT(_s) (NULLIFY( &(_s).link)) #define ONESHOT_SET(_s) (QMEMBER( &(_s).link)) diff --git a/include/nwnss/include/asyncio.h b/include/nwnss/include/asyncio.h index 72a6b53..b02c011 100644 --- a/include/nwnss/include/asyncio.h +++ b/include/nwnss/include/asyncio.h @@ -63,8 +63,8 @@ typedef struct BioReq_s { #define AIO_FILL_PATTERN 0xdeadbeef #if NSS_DEBUG IS_ENABLED -# define AIO_FILL(_aio) \ - (zASSERT((sizeof(DefaultAsyncio_s) & (sizeof(LONG)-1)) == 0), \ +# define AIO_FILL(_aio) \ + (zASSERT((sizeof(DefaultAsyncio_s) & (sizeof(LONG)-1)) == 0), \ zASSERT((_aio)->fsm.sp == &(_aio)->stack[1]), \ LB_memlset((&(_aio)->status), \ AIO_FILL_PATTERN, \ @@ -97,7 +97,7 @@ typedef struct Asyncio_s BYTE align[3]; AgentSignalFunc_t flush; /* routine to call when writting buffer */ voidfunc_t action; /* callback when getting a buffer */ - BioReq_s bioReq; + BioReq_s bioReq; } Asyncio_s; #define INIT_AIO_BASIC(_asyncio) \ @@ -172,7 +172,7 @@ typedef struct AioChunk_s struct NSSChunk_s *chunk; } AioChunk_s; -#define INIT_AIO_COMNRW(_asyncio, _data, _offset, _length) \ +#define INIT_AIO_COMNRW(_asyncio, _data, _offset, _length) \ { \ (_asyncio)->comn.data = (_data); \ (_asyncio)->comn.offset = (_offset); \ @@ -185,9 +185,9 @@ typedef struct AioChunk_s *---------------------------------------------------------------------------*/ //typedef void (*AsyncCallBackFunc_t)( -// ADDR callBackContext, +// ADDR callBackContext, // STATUS completionCode, -// NINT bytesRead, +// NINT bytesRead, // PubBuffer_s *releaseBuffer); typedef struct OpsAsyncRead_s diff --git a/include/nwnss/include/cduncomp.h b/include/nwnss/include/cduncomp.h deleted file mode 100644 index 76d0e36..0000000 --- a/include/nwnss/include/cduncomp.h +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** - | - | (C) Copyright 1985, 1991, 1993, 1996-1999 Novell, Inc. - | All Rights Reserved. - | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. - | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. - | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. - | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com - | - |*************************************************************************** - | - | Netware file compression algorithm ported to NSS - | - |--------------------------------------------------------------------------- - | - | $Author: vandana $ - | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ - | - | $RCSfile$ - | $Revision: 1177 $ - | - |--------------------------------------------------------------------------- - | Module Description: - | - +-------------------------------------------------------------------------*/ -#ifndef __CDUNCOMP_H__ -#define __CDUNCOMP_H__ - -#define UNCOMPRESS_READ_CACHE_BUFFER_RANGE 1 -#define UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE 3 - -#define UNCOMPRESS_MAX_LENGTH_VALUE 0xFE - -#define UNCOMPRESS_ERROR_OUT_OF_RAM 10001 -#define UNCOMPRESS_ERROR_READ_ZERO_BYTES 10002 -#define UNCOMPRESS_ERROR_READ_BEYOND_EOF 10003 -#define UNCOMPRESS_ERROR_ABORTED 10004 -#define UNCOMPRESS_ERROR_INVALID_DATA_COUNT 10005 /* tree count */ -#define UNCOMPRESS_ERROR_INVALID_LENGTH_COUNT 10006 /* tree count */ -#define UNCOMPRESS_ERROR_INVALID_OFFSET_COUNT 10007 /* tree count */ -#define UNCOMPRESS_ERROR_HOLE_COUNT_MISMATCH 10008 -#define UNCOMPRESS_ERROR_UNKNOWN_VERSION 10009 -#define UNCOMPRESS_ERROR_FILE_TOO_SMALL 10010 -#define UNCOMPRESS_ERROR_TREE_TOO_BIG 10011 -#define UNCOMPRESS_ERROR_INVALID_HOLES 10012 -#define UNCOMPRESS_ERROR_INVALID_OFFSET 10013 -#define UNCOMPRESS_ERROR_INVALID_LENGTH 10014 -#define UNCOMPRESS_ERROR_WRITE_BEYOND_EOF 10015 -#define UNCOMPRESS_ERROR_INVALID_HEADER 10016 -#define UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE 10017 -#define UNCOMPRESS_ERROR_TRY_AGAIN 10018 /* also defined in FILER2.C */ -#define UNCOMPRESS_ERROR_TRY_AGAIN_FOREVER 10019 /* also defined in FILER2.C */ - -/*#define UNCOMPRESS_ERROR_COUNT 15 DEFINED in CONFIG.H */ - -#define UNCOMPRESS_DOS_NAME_SIZE 16 - -typedef struct decompressHoleMark_s { - - struct decompressHoleMark_s * next; - LONG offset; - LONG size; - -} decompressHoleMark_t, *decompressHoleMark_tp, **decompressHoleMark_tpp; - -typedef struct uncompressNode_s { - - struct uncompressNode_s *left; - struct uncompressNode_s *right; - LONG value; /* Byte value */ - -} uncompressNode_t, *uncompressNode_tp, * *uncompressNode_tpp; - -typedef struct uncompressData_s { - - LONG BitBufferIndex; - LONG BitBuffer; - LONG *BitMapCurrentPointer; - LONG *BitMapCurrentEnd; - - IoHandle_t WriteHandle; - LONG WriteFileSize; - BYTE *WriteCurrentPointer; - BYTE *WriteCurrentBufferBegin; - - BYTE *WriteCurrentBufferEnd; - LONG BytesInWriteCacheSoFar; - LONG WriteCacheBufferCount; - LONG WriteCacheNextBlockToGet; - - BYTE *WriteCachePointers [ UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE ]; - BYTE *WriteCacheBufferEnd [ UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE ]; - LONG WriteCacheHandle [ UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE ]; - LONG WriteCacheBlockNumber[ UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE ]; - - uncompressNode_tp DataTree; - uncompressNode_tp OffsetTree; - uncompressNode_tp LengthTree; - readCache_tp ReadCache; - - compressFileHeader_tp Header; - LONG ThreadExitNow; - decompressHoleMark_tp HoleListHead; - BYTE * WriteEOFPointer; - - BYTE * WritePreviousBufferEnd; - LONG WritePreviousBufferIndex; - LONG CompressedFileSize; - - BYTE DosName[ UNCOMPRESS_DOS_NAME_SIZE ]; - - LONG Volume; - - DecompressStatusNode_t decompressStatus; - - LONG beginHighTickCount; - -} uncompressData_t, *uncompressData_tp, * *uncompressData_tpp; - -#if 0 -typedef struct decompressWorkToDo_s { - - struct WorkToDoStructure DWTD; - uncompressData_tp ucp; - -} decompressWorkToDo_t, *decompressWorkToDo_tp, **decompressWorkToDo_tpp; -#endif - - -LONG -CCDStartDecompress( - IoHandle_t inHandle, - IoHandle_t outHandle, - ADDR *decompressHandle, - BYTE *dosName, - LONG volume, - LONG directoryNumber); - -#endif - -/****************************************************************************/ -/****************************************************************************/ diff --git a/include/nwnss/include/cifs.imp b/include/nwnss/include/cifs.imp new file mode 100644 index 0000000..61d8082 --- /dev/null +++ b/include/nwnss/include/cifs.imp @@ -0,0 +1,35 @@ +DCNCInitPdcGatherUsersGroupInfo +DCNCPdcGatherUsersGroupStatus +DCNCGetDomianName +DCNCGetImportContext + +CIFSProxyAwaitRequest +CIFSProxyLoadNotify +CIFSProxyUnloadNotify +CIFSSignalAuthComplete +CIFSCopySecblob +CIFSNDSGetRID +AUTHAllocInfo +AUTHFreeInfo +AUTHDoDomainAuth +AUTHGetNLMAuthType + +CIFS_AddDomainACL +CIFS_AddShare +CIFS_CreateDomain +CIFS_DeleteDomain +CIFS_GetDomainConfiguration +CIFS_GetServerConfiguration +CIFS_GetShareProperties +CIFS_JoinDomain +CIFS_LeaveDomain +CIFS_ListDomainControllers +CIFS_ListShares +CIFS_ModifyShare +CIFS_RemoveShare +CIFS_SetDomainConfiguration +CIFS_SetServerConfiguration + +RegisterCIFSCallbackMonitor +RegisterCIFSDomainAddOn +UnRegisterCIFSDomainAddOn diff --git a/include/nwnss/include/cifsAuth.h b/include/nwnss/include/cifsAuth.h new file mode 100644 index 0000000..b86025e --- /dev/null +++ b/include/nwnss/include/cifsAuth.h @@ -0,0 +1,305 @@ +/**************************************************************************** + | + | (C) Copyright 1995-2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | CIFS module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + +-------------------------------------------------------------------------*/ +/*************************************************************************** + * + * Definitions exported by all the modules relating to authentication + * + **************************************************************************/ +#ifndef _CIFSAUTH_H_ +#define _CIFSAUTH_H_ + +#include + +#include "cifsStypes.h" +#include "que.h" + +#define RID_BLOCK_SIZE 1000 +#define RID_INCREMENT_SIZE 10 + +/* Define well-known Group RIDs */ +#define DOMAIN_ADMINS_RID 512 +#define DOMAIN_USERS_RID 513 +#define DOMAIN_GUESTS_RID 514 + +/* Well-known Unicode Group Names */ +#define GROUP_DOMAIN_ADMINS L"Domain Admins" +#define GROUP_DOMAIN_USERS L"Domain Users" +#define GROUP_DOMAIN_GUESTS L"Domain Guests" + + +/*--------------------------------------------------------------------------- + * Login types used by CIFS + *---------------------------------------------------------------------------*/ +typedef enum +{ + guest, + user, + supervisor, + undefined, + nulluser +} LoginType; + +/*--------------------------------------------------------------------------- + * authInfo_t structure definitions and values + *---------------------------------------------------------------------------*/ +typedef enum authRequest_e +{ + AUTHREQ_GETSECBLOB, + AUTHREQ_AUTHENTICATE, + AUTHREQ_CHANGE_PW, + AUTHREQ_LOGOUT, + AUTHREQ_GETNONCE, + AUTHREQ_CHANGE_MACHINE_PW, + AUTHREQ_GETSESKEY, + AUTHREQ_GET_MACHINE_PW, + AUTHREQ_SAM_LOGON, + AUTHREQ_GETRID, + AUTHREQ_GET_ACCOUNT_DN, + AUTHREQ_GETNAME +} authRequest_t; + +typedef enum authResult_e +{ + AUTHRES_UNDEFINED, + AUTHRES_FAILURE, + AUTHRES_INPROGRESS, + AUTHRES_INVALID_OLD_PW, + AUTHRES_INVALID_USER, + AUTHRES_INVALID_NEW_PW, + AUTHRES_SUCCESS +} authResult_t; + +typedef enum authType_e +{ + AUTHTYPE_LOCAL, + AUTHTYPE_DOMAIN, + AUTHTYPE_NONE, + AUTHTYPE_BRANCH +} authType_t; + +typedef enum authClient_e +{ + AUTHCLIENT_SUCCESS, + AUTHCLIENT_FAIL, + AUTHCLIENT_NONE +} authClient_t; + + +#define PWDINFO_CHARMAX 64 +#define PWDINFO_BUFSIZE PWDINFO_CHARMAX * 2 /* 2 = sizeof(unicode_t) */ + +typedef struct pwdInfoTag_s +{ + int clearTextPresent; + BYTE clrTxtOldPwd[16]; + BYTE clrTxtNewPwd[16]; + BYTE ntnew [516]; + BYTE ntoldhash [16]; + BYTE lmnew [516]; + BYTE lmoldhash [16]; + BYTE account[PWDINFO_BUFSIZE]; /* could be char, could be unicode */ + int stringsAreUnicode; + int cifsError; + int ntHashPresent; +} pwdInfoTag_s; + + +/*--------------------------------------------------------------------------- + * Parameters of a session + *---------------------------------------------------------------------------*/ +typedef struct sesParamTag_s +{ + unsigned short tid; + unsigned short mid; + unsigned short uid; +} sesParamTag_s; + + +/*--------------------------------------------------------------------------- + * Substruct for authInfo, below. Used when request == AUTHREQ_GETNONCE. + *---------------------------------------------------------------------------*/ +typedef struct nonceDataTag_s +{ + int nonceLength; + unsigned char nonce[ 8 ]; + int responseLength; + unsigned char response[ 8 ]; +} nonceDataTag_s; + + +/*--------------------------------------------------------------------------- + * Substruct for authInfo, below. Used when request == AUTHREQ_GETSECBLOB. + *---------------------------------------------------------------------------*/ +typedef struct secblobDataTag_s +{ + int secblobLength; + unsigned char secblob[ 8 ]; +} secblobDataTag_s; + + +/*--------------------------------------------------------------------------- + * Substruct for authInfo, below. Used when request == AUTHREQ_AUTHENTICATE. + *---------------------------------------------------------------------------*/ +typedef struct authDataTag_s +{ + /* input data */ + int pwLen; +/* Note to absolute numbers, DB021100: we currently use different NDK + * headers for the CIFS NLM and CIFS NMAS NLM's, and this causes the use of + * literals to give us problems. During this (hopefully temporary) + * situation, absolute numbers, ironically, assures all NLM's have the same + * structure. + */ + char pw[32]; + char account[64]; + char domain[64]; + unicode_t unicodeAccount[64]; + unicode_t unicodeDomain[64]; + unicode_t uAccountDn[MAX_DN_CHARS]; + +#ifdef ADDRESS_RESTRICTIONS + LONG ipAddress; +#endif + + /* output data */ + int nwdsContext; + LONG nmasHandle; + unsigned long nwStationNumber; + int nwTaskID; + LoginType loginType; /* guest | user */ + + + /* Internal bookkeeping */ + struct sesParamTag_s pdcSesParams; /* PDC session parameters and status + * of most recent command to the + * pdc when doing passthrough + * authentication. + */ +} authDataTag_s; + + +/*--------------------------------------------------------------------------- + * Substruct for authInfo, below. Used when request == AUTHREQ_CHANGE_PW + *---------------------------------------------------------------------------*/ +typedef struct pwChangeDataTag_s +{ + /*flag to indicate presence/absence of MD4 password block */ + char md4Present; + + /*flag to indicate presence/absence of clear text password */ + char clearTextPresent; + + /*MD4 password block(next 2 strings): + * Used only by 'samr'(SamrChangePasswordUser) request from WinNT/W2K + * clients. When 'SamOemChangePassword' request is received from Win9X, + * this block is filled with NULL. + */ + unsigned char encNewMd4Password[516]; + unsigned char encOldMd4Hash[16]; + + /*LM password block(next 2 strings): + * Used by both Win9X and WinNT/W2K clients. + * Win9X clients provide it in RAP request(SamOemChangePassword) + * WinNT/W2K clients provide it in 'samr'(SamrChangePasswordUser) + * request. + */ + unsigned char encNewLmPassword[516]; + unsigned char encOldLmHash[16]; + + + /*The following two clear text passwords are present only when 'clearTextPresent' flag is TRUE + * These are used only while servicing password + * change RAP request from a Win 9X client. The following two data elements + * are not used while servicing password change request received on 'samr' + * pipe(from Win NT/W2K clients). + */ + char ClearTextOldPassword[16]; + char ClearTextNewPassword[16]; + + /* The following two null terminated ASCII strings are returned by LSMCIFS login method + * when the return status from LSMCIFS is AUTHRES_SUCCESS. These two passwords + * are for the use of CIFSPROX to update the NDS password. + */ + char OldPwdFromLsm[128]; + char NewPwdFromLsm[128]; +} pwChangeDataTag_s; + + + +/*--------------------------------------------------------------------------- + * The data structure passed between the NMAS proxy and LSM + *---------------------------------------------------------------------------*/ +typedef struct authInfoTag_s +{ + /* Admin stuff */ + DQlink_t link; + LONG authComplete; + LONG pdcComplete; + void *context; + authType_t type; /* DOMAIN or LOCAL */ + authRequest_t request; /* GETSECBLOB or AUTHENTICATE */ + authResult_t status; + authClient_t authClient; + int nwError; /* NetWare error - needs translation */ + /* to CIFS for reply */ + unsigned long cifsError; /* CIFS error - use directly in */ + /* reply if available */ + unsigned char wtdBuf[64]; /* Leave this as a buffer rather than + * an explicit zWorkProc_s structure, + * because this is included by + * cifsProx and it doesn't know about + * zWorkProc_s structures. */ + + /* The data itself. Both secblob and auth data are included because */ + /* local login requires both in one request. */ + secblobDataTag_s secblobData; + authDataTag_s authData; + pwChangeDataTag_s pwChangeData; + nonceDataTag_s nonceData; +} authInfoTag_s; + + + +typedef struct authContextTag_s +{ + struct authContextTag_s *prev; + struct authContextTag_s *next; + unsigned long nwStationNumber; + LONG ndsContext; /* Kept around for logout only */ + LONG nmasHandle; /* Kept around for logout only */ + int userHandle; /* Kept around for logout only */ +} authContextTag_s; + + +#endif /* _CIFSAUTH_H_ */ diff --git a/include/nwnss/include/cifsAuthp.h b/include/nwnss/include/cifsAuthp.h new file mode 100644 index 0000000..2ee64ce --- /dev/null +++ b/include/nwnss/include/cifsAuthp.h @@ -0,0 +1,214 @@ +/**************************************************************************** + | + | (C) Copyright 1995-2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | CIFS module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + +-------------------------------------------------------------------------*/ +/**************************************************************************** + * Definitions exported by the "AUTH" directory + *****************************************************************************/ +#ifndef _CIFSAUTHP_H_ +#define _CIFSAUTHP_H_ + +#include "cifsAuth.h" + +extern char *AUTHAccount( + struct authInfoTag_s *info ); + +extern struct authInfoTag_s *AUTHAllocInfo( + void *context, + int stringsAreUnicode, + char *account, + int accountHasPad, + int pwLen, + char *pw, + int pwMD4, + char *domain, + int domainHasPad, + BYTE *secBlob, + int secblobLength, + LONG ipAddress); + +extern struct authInfoTag_s *AUTHAllocInfoChgPwd( + void *context, + struct pwdInfoTag_s *pwdInfo ); + +extern struct authInfoTag_s *AUTHAllocInfoLogout( + void *context, + unsigned long nwStationNumber); + +extern struct authInfoTag_s *AUTHAllocInfoSamLogon( + void *context, + unicode_t *uniAcctName, + LONG acctNameLen, + unicode_t *uniDomName, + LONG domNameLen, + BYTE *ntlmChal, + BYTE *ntCred, + BYTE *lmCred, + LONG ntlmCredLen); + +extern struct authInfoTag_s *AUTHAllocInfoSecblob( + void *context ); + +extern authResult_t AUTHChangeMachinePassword( + struct pwdInfoTag_s *pwdInfo); + +extern authResult_t AUTHChangePassword( + struct pwdInfoTag_s *pwdInfo, + LONG *nwError); + +extern char *AUTHDomain( + struct authInfoTag_s *info ); + +extern void AUTHDomainRestart( + LONG mode, + BOOL isPDC ); + +extern void AUTHFreeInfo( + struct authInfoTag_s *info ); + +extern authResult_t AUTHGetAccountDN( + unicode_t *acctNameUni, + unicode_t *acctDNUni ); + +extern authResult_t AUTHGetGroups( + unicode_t *uniAcctName, + unicode_t *uniAcctDN, + LONG *numGroups, + struct domainGroupInfoTag_s **groupList); + +extern authType_t AUTHGetNLMAuthType( void ); + +extern authResult_t AUTHGetMachinePassword( + struct pwdInfoTag_s *pwdInfo, + BYTE *buffer, + int bufLength ); + +extern authResult_t AUTHGetName( + LONG rid, + unicode_t *acctNameUni, + LONG *type ); + +extern authResult_t AUTHGetRID( + unicode_t *acctNameUni, + LONG *rid, + LONG *type ); + +extern authResult_t AUTHGetSecblob( + BYTE *buffer, + int bufLength ); + +extern authResult_t AUTHGetSeskey( + BYTE *acctName, + BYTE *buffer, + int bufLength ); + +extern void AUTHInit( void ); + +extern void AUTHLogout( + unsigned long nwStationNumber); + +extern void AUTHPdcComplete( + struct authInfoTag_s *info, + authResult_t result, + int nwError, + LONG cifsError ); + +extern struct sesParamTag_s *AUTHPdcSesParams( + struct authInfoTag_s *info ); + +extern WORD AUTHPdcSesUid( + struct authInfoTag_s *info ); + +extern char *AUTHPw( + struct authInfoTag_s *info ); + +extern int AUTHPwLen( + struct authInfoTag_s *info ); + +extern authResult_t AUTHSamLogon( + unicode_t *uniAcctName, + LONG acctNameLen, + unicode_t *uniDomName, + LONG domNameLen, + BYTE *ntlmChal, + BYTE *ntCred, + BYTE *lmCred, + LONG ntlmCredLen, + LONG *rid, + LONG *numGroups, + struct domainGroupInfoTag_s **groupList, + LONG *nwError); + +extern void AUTHSetRequest( + struct authInfoTag_s *info, + authRequest_t request); + +extern unsigned char AUTHSetSecMode( void ); + +extern void AUTHSetType( + struct authInfoTag_s *info, + authType_t type ); + +extern void AUTHShutdown( void ); + +extern authResult_t AUTHStart( + struct authInfoTag_s *info ); + +extern struct authInfoTag_s *CIFSProxyDequeueRequest( void ); + +extern void CIFSProxyEnqueueRequest( + struct authInfoTag_s *element ); + + +/* + * Functions called by the NMAS PROXY + */ + +extern authResult_t CIFSCopySecblob( + char *buffer, + int bufLength ); + +extern STATUS CIFSNDSGetRID( + unicode_t *userUDN, + LONG *rid, + LONG *type); + +extern authInfoTag_s *CIFSProxyAwaitRequest( void ); + +extern void CIFSProxyLoadNotify( void ); + +extern void CIFSProxyUnloadNotify( void ); + +extern void CIFSSignalAuthComplete( + authInfoTag_s *authInfo ); + +#endif /* _CIFSAUTHP_H_ */ diff --git a/include/nwnss/include/cifsManage.h b/include/nwnss/include/cifsManage.h new file mode 100644 index 0000000..b4eb9a6 --- /dev/null +++ b/include/nwnss/include/cifsManage.h @@ -0,0 +1,498 @@ +/**************************************************************************** + | + | (C) Copyright 1995-2002 Novell, Inc. + | All Rights Reserved. + | + | This program is an unpublished copyrighted work which is proprietary + | to Novell, Inc. and contains confidential information that is not + | to be reproduced or disclosed to any other person or entity without + | prior written consent from Novell, Inc. in each and every instance. + | + | WARNING: Unauthorized reproduction of this program as well as + | unauthorized preparation of derivative works based upon the + | program or distribution of copies by sale, rental, lease or + | lending are violations of federal copyright laws and state trade + | secret laws, punishable by civil and criminal penalties. + | + |*************************************************************************** + | + | CIFS module + | + |--------------------------------------------------------------------------- + | + | $Author: dpary $ + | $Modtime: 13 Feb 2006 13:14:44 $ + | + | $Workfile: cifsManage.h $ + | $Revision: 2437 $ + | + +-------------------------------------------------------------------------*/ +/*************************************************************************** + * + * cifsManage.h + * + * Functions used for managing CIFS via XML commands + * + **************************************************************************/ + +#ifndef _CIFSMANAGE_H_ +#define _CIFSMANAGE_H_ + +#include "cifsStypes.h" +#include +#include "xUnicode.h" + + +#include +#include +#include +//#include +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Since we communicate with utf8, the strings need to be bigger than they + * might need to be in unicode. A single unicode character can require as + * many as three bytes in utf8. + */ +#define UTF8_FACTOR 3 + +/* This structure is used to return info about a share point */ +typedef struct CifsShareInfo_s +{ + utf8_t shareName[MAX_CIFS_SHARE_NAME * UTF8_FACTOR]; + utf8_t sharePath[zMAX_FULL_NAME * UTF8_FACTOR]; + utf8_t shareComment[MAX_CIFS_COMMENT * UTF8_FACTOR]; +} CifsShareInfo_s; + + +typedef struct ContextInfoList_s +{ + u_int32_t numofContext; + utf8_t **ContextListBuf; +}ContextInfoList_s; + +/* Values for modifyMask on CIFS_ModifyShare */ +#define CIFS_MOD_SHARE_NAME 0x00000001 +#define CIFS_MOD_SHARE_PATH 0x00000002 +#define CIFS_MOD_SHARE_COMMENT 0x00000004 + + +/* This structure is used to return info about a server's configuration */ +typedef struct CifsServerInfo_s +{ + utf8_t serverName[MAX_CIFS_SERVER_NAME * UTF8_FACTOR]; + utf8_t serverComment[MAX_CIFS_COMMENT * UTF8_FACTOR]; + utf8_t groupName[MAX_CIFS_WORKGROUP_NAME * UTF8_FACTOR]; /* Workgroup or Domain name */ + + LONG numAttachIPAddresses; + LONG attachIPAddress[6]; + + u_int32_t isOnlineServer; + u_int32_t isVirtualServer; + + /* Fields from here down are not filled in if this is a virtual server */ + LONG authMode; + LONG winsIPAddress; + LONG pdcIPAddress; + utf8_t pdcName[MAX_CIFS_PDC_NAME * UTF8_FACTOR]; + + u_int32_t oplocksEnabled; + u_int32_t dfsEnabled; + u_int32_t shareVolsByDefaultEnabled; + u_int32_t pdcEnabled; + + utf8_t domainDN[(MAX_DN_CHARS+2) * UTF8_FACTOR]; + LONG beginRID; + LONG endRID; + LONG signatureMode; +} CifsServerInfo_s; + +/* Values for CifsServerInfo_s.authentication Mode */ +#define CIFS_AUTH_MODE_DOMAIN_PASSTHRU 0 +#define CIFS_AUTH_MODE_LOCAL 1 +#define CIFS_AUTH_MODE_UNKNOWN 2 +#define CIFS_AUTH_MODE_BRANCH_OFFICE 3 +#define CIFS_AUTH_MODE_DOMAIN_CONTROLLER 4 +#define CIFS_AUTH_MODE_DOMAIN_MEMBER 5 + +/* Values for modifyMask on CIFS_SetServerConfiguration */ +#define CIFS_MOD_SERVER_NAME 0x00000001 +#define CIFS_MOD_SERVER_COMMENT 0x00000002 +#define CIFS_MOD_GROUP_NAME 0x00000004 +#define CIFS_MOD_ATTACH_IP 0x00000008 +#define CIFS_MOD_AUTH_MODE 0x00000010 +#define CIFS_MOD_WINS_IP 0x00000020 +#define CIFS_MOD_PDC_IP 0x00000040 +#define CIFS_MOD_PDC_NAME 0x00000080 +#define CIFS_MOD_OPLOCKS_ENABLED 0x00000100 +#define CIFS_MOD_DFS_ENABLED 0x00000200 +#define CIFS_MOD_SHARE_VOLS_BY_DEFAULT 0x00000400 +#define CIFS_MOD_PDC_ENABLED 0x00000800 +#define CIFS_MOD_BEGIN_RID 0x00001000 +#define CIFS_MOD_END_RID 0x00002000 +#define CIFS_MOD_SIGNATURES 0x00004000 + + +/* Values for modifyMask on CIFS_SetDomainConfiguration */ +/* These first values can be modified by the system administrator */ +#define CIFS_MOD_DOMAIN_COMMENT 0x00000001 +#define CIFS_MOD_PDC_DN 0x00000002 +/* These remaining values can only be modified by internal code */ +#define CIFS_MOD_DOMAIN_NAME 0x00000004 +#define CIFS_MOD_GROUP_DN 0x00000008 +#define CIFS_MOD_DOMAIN_SID 0x00000010 +#define CIFS_MOD_NEXT_RID 0x00000020 +#define CIFS_MOD_EPOCH 0x00000040 + +/* Values for CifsServerInfo_s.signature Mode */ +#define CIFS_NLM_SIGN_DISABLED 0 +#define CIFS_NLM_SIGN_OPTIONAL 1 +#define CIFS_NLM_SIGN_MANDATORY 2 + +/* This structure is used to return info about a domains's configuration */ +typedef struct CifsDomainInfo_s +{ + utf8_t domainName[MAX_CIFS_WORKGROUP_NAME * UTF8_FACTOR]; + utf8_t domainComment[MAX_CIFS_COMMENT * UTF8_FACTOR]; + utf8_t pdcDN[(MAX_DN_CHARS+2) * UTF8_FACTOR]; + utf8_t groupDN[(MAX_DN_CHARS+2) * UTF8_FACTOR]; + + BYTE domainSID[DOMAIN_SID_LEN]; + LONG nextRID; + LONG epoch; + +} CifsDomainInfo_s; + +/* An array of these structures is used to return a list of domain controllers + * for a domain + */ +typedef struct CifsDomainList_s +{ + utf8_t serverDN[(MAX_DN_CHARS+2) * UTF8_FACTOR]; +} CifsDomainList_s; + + +/*===========================================================================*/ + +extern STATUS CIFS_Utf8ToByte( + char *byteOutput, + NINT outputBufLen, /* Length in bytes */ + unicode_t *tempUniBuf, + NINT tempUniBufLen, /* Length in bytes */ + utf8_t *utf8Input, + NINT *retActualLength); /* Length in bytes */ + +extern STATUS CIFS_ByteToUtf8( + utf8_t *utf8Output, + NINT outputBufLen, /* Length in bytes */ + unicode_t *tempUniBuf, + NINT tempUniBufLen, /* Length in unicode characters */ + char *byteInput, + NINT *retActualLength); /* Length in bytes */ + +extern STATUS CIFS_AddDomainACL( + utf8_t *domainDN, + utf8_t *aclContextDN, + utf8_t *userDN, + utf8_t *password, + BYTE *unp, + NINT unpLen); + +extern STATUS CIFS_AddShare( + utf8_t *shareName, + utf8_t *serverDN, /* Optional - default is phys server */ + utf8_t *serverTree, /* Optional - default is phys tree */ + utf8_t *shareVolumeNameAndPath, + utf8_t *shareComment); + +extern STATUS CIFS_CreateDomain( + utf8_t *domainName, + utf8_t *serverDN, /* Optional - default is phys server */ + utf8_t *domainContext, + utf8_t *domainComment, + utf8_t *userDN, + utf8_t *password, + BYTE *unp, + NINT unpLen); + +extern STATUS CIFS_DeleteDomain( + utf8_t *serverDN, /* Optional - default is phys server */ + utf8_t *domainDN, + utf8_t *userDN, + utf8_t *password, + BYTE *unp, + NINT unpLen); + +extern STATUS CIFS_GetDomainConfiguration( + utf8_t *domainDN, + utf8_t *userDN, + utf8_t *password, + BYTE *unp, + NINT unpLen, + CifsDomainInfo_s *domainInfo); + +extern STATUS CIFS_GetServerConfiguration( + utf8_t *serverDN, + utf8_t *serverTree, + CifsServerInfo_s *serverInfo); + +extern STATUS CIFS_GetShareProperties( + utf8_t *shareName, + utf8_t *serverDN, /* Optional - default is phys server */ + utf8_t *serverTree, /* Optional - default is phys tree */ + CifsShareInfo_s *shareInfo); + +extern STATUS CIFS_JoinDomain( + utf8_t *serverDN, /* Optional - default is phys server */ + utf8_t *domainDN, + NINT authMode, + utf8_t *userDN, + utf8_t *password, + BYTE *unp, + NINT unpLen); + +extern STATUS CIFS_LeaveDomain( + utf8_t *serverDN, /* Optional - default is phys server */ + utf8_t *domainDN, + utf8_t *userDN, + utf8_t *password, + BYTE *unp, + NINT unpLen); + +extern STATUS CIFS_ListDomainControllers( + utf8_t *domainDN, + utf8_t *userDN, + utf8_t *password, + BYTE *unp, + NINT unpLen, + NINT startControllerIdx, + NINT numControllers, + CifsDomainList_s *dcList, + NINT *retNumControllers); + +extern STATUS CIFS_ListShares( + utf8_t *serverDN, + utf8_t *serverTree, + NINT startShareIdx, + NINT numShares, + CifsShareInfo_s *shareInfo, /* bufSize = (numShares * sizeof CifsShareInfo_s) */ + NINT *retNumShares); + +extern STATUS CIFS_ModifyShare( + utf8_t *shareName, + utf8_t *serverDN, /* Optional - default is phys server */ + utf8_t *serverTree, /* Optional - default is phys tree */ + NINT modifyMask, + CifsShareInfo_s *newShareInfo); + +extern STATUS CIFS_RemoveShare( + utf8_t *shareName, + utf8_t *serverDN, /* Optional - default is phys server */ + utf8_t *serverTree); /* Optional - default is phys tree */ + +extern STATUS CIFS_SetDomainConfiguration( + utf8_t *domainDN, + NINT modifyMask, + utf8_t *userDN, + utf8_t *password, + BYTE *unp, + NINT unpLen, + CifsDomainInfo_s *domainInfo); + +extern STATUS CIFS_SetServerConfiguration( + utf8_t *serverDN, + utf8_t *serverTree, + NINT modifyMask, + CifsServerInfo_s *serverInfo); + +/***************************************************************************************************************************** +* Change for the Unix domain Support * +******************************************************************************************************************************/ + + +/* Function Ids for iManager */ +# define Fid_CIFS_AddDomainACL 0 +# define Fid_CIFS_AddShare 1 +# define Fid_CIFS_CreateDomain 2 +# define Fid_CIFS_DeleteDomain 3 +# define Fid_CIFS_GetDomainConfiguration 4 +# define Fid_CIFS_GetServerConfiguration 5 +# define Fid_CIFS_GetShareProperties 6 +# define Fid_CIFS_JoinDomain 7 +# define Fid_CIFS_LeaveDomain 8 +# define Fid_CIFS_ListDomainControllers 9 +# define Fid_CIFS_ListShares 10 +# define Fid_CIFS_ModifyShare 11 +# define Fid_CIFS_RemoveShare 12 +# define Fid_CIFS_SetDomainConfiguration 13 +# define Fid_CIFS_ListContexts 14 +# define Fid_CIFS_AddContext 15 +# define Fid_CIFS_RemoveContext 16 +# define Fid_CIFS_SetServerConfiguration 17 +# define End_of_iManager_Fid Fid_CIFS_SetServerConfiguration + + +/* Error Codes for the Response of the CIFS server*/ + +# define E_SHARE_ALREADY_EXIST 1 +# define E_SHARE_NOT_EXIST 2 +# define E_EDIRECTORY_FAILURE 3 +# define E_SERVER_NOT_REACHABLE 4 +# define E_NO_DUMP_DATA 5 +# define E_REQUIRED_SHARE_POINT_NOT_EXISTS 6 +# define E_GIVEN_INPUT_NOT_PROPER 7 +# define E_INSERT_DATA_TO_PKT_FAIL 8 +# define E_OPERPARM__NOT_EXISTS 9 +# define E_REMOVING_SHARE_FAIL 10 +# define E_ADDING_SHARE_FAIL 11 +# define E_CONN_COUNT_RETRIEVAL_FAIL 12 +# define E_SHARE_EMPTY 13 + +# define NUMBER_OF_ERR_CODES E_SHARE_EMPTY + +#define CMD_SUCCESS 0 + +#define ENABLE_DEBUG 1 +#define DISABLE_DEBUG 0 + +/* This structure will contain all the given parameters of the iManager. */ + +typedef struct CifsiManagerData +{ + unsigned char cid; + unsigned char fid; + utf8_t *serverDN; + utf8_t *serverTree; + CifsServerInfo_s *serverInfo; + int modifyMask; + NINT startShareIdx; + NINT numShares; + CifsShareInfo_s *shareInfo; + utf8_t *context; + struct ContextInfoList_s *contextInfo; + NINT retnumShares; + utf8_t *shareNameUtf8; + utf8_t *shareVolumeNameAndPathUtf8; + utf8_t *shareCommentUtf8; + +}CifsiManagerData; + + + +#define CLI_COMPONENT 0 +#define IMANAGER_COMPONENT 1 + +/* All fields length of Request and response packet are defined here */ +#define REQ_PACKET_HDR_LENGTH (sizeof(CifsReqPktHDR_t)) +#define RESP_PACKET_HDR_LENGTH (sizeof(CifsRespPktHDR_t)) +#define INITIAL_REQ_PACKET_SIZE 1024 +#define INITIAL_RESP_PACKET_SIZE 1024 + + +#define INVALID_NO_OF_DATA 0xff +#define INVALID_CONN_COUNT -1 + +/* Type field of the request and response packet will be filled by + this macros */ +#define TYPE_SHARE_NAME 1 +#define TYPE_SHARE_PATH 2 +#define TYPE_CONN_LIMIT 3 +#define TYPE_COMMENT 4 +#define TYPE_SMB_STATUS 5 +#define TYPE_SHARE_DETAIL 6 +#define TYPE_OPER_PARAM_DETAIL 7 +#define TYPE_ACTV_CONN_COUNT 8 +#define TYPE_SERVER_NAME 9 +#define TYPE_ENABLE_DEBUG_STATUS 10 + +#define TYPE_SERVER_DN 20 +#define TYPE_SERVER_TREE 21 +#define TYPE_CIFSSERVER_INFO 22 +#define TYPE_MODIFY_MASK 23 +#define TYPE_STARTSHAREIDX 24 +#define TYPE_NUMSHARES 25 +#define TYPE_CIFSSHARE_INFO 26 +#define TYPE_RETNUMSHARES 27 +#define TYPE_ENABLE_INFO_STATUS 28 +#define TYPE_CONTEXT 29 + +typedef struct CifsReqPktHDR +{ + unsigned char cid; + unsigned char fid; + unsigned char no_of_data; + unsigned int totdata_len; +}CifsReqPktHDR_t; + +/*typedef struct CifsReqPktFormat +{ + CifsReqPktHDR_t hdr; + void *reqdata; +}CifsReqPktFormat_t;*/ +typedef struct DataHDR +{ + unsigned char type; + unsigned int len; +}DataHDR_t; +typedef struct DataFormat +{ + DataHDR_t hdr; + void *databuf; +}DataFormat_t; + +typedef struct CifsRespPktHDR +{ + STATUS status; + unsigned char no_of_data; + unsigned int totdata_len; +}CifsRespPktHDR_t; + +/*typedef struct CifsRespPktFormat +{ + CifsRespPktHDR_t hdr; + void *respdata; +}CifsRespPktFormat_t;*/ + +typedef struct PacketStruct +{ + char *buf; + unsigned int length; + char *currptr; +}PacketStruct_t; + +typedef unsigned char uint8; +typedef unsigned short int uint16; + + +/* Alll defined functions in cifspktstruct.c are prototyped here */ + +PacketStruct_t *ReqPktInsertComponentID(uint8 cid); +PacketStruct_t *ReqPktInsertFunctionID(PacketStruct_t *pktbuf, uint8 fid); +PacketStruct_t *ReqPktInsertData(PacketStruct_t *pktbuf, uint8 type, unsigned int length, void *data); +PacketStruct_t *ReqPktSetNumberOfData(PacketStruct_t *pktbuf, uint8 no_of_data); +PacketStruct_t *RespPktSetNumberOfData(PacketStruct_t *pktbuf, uint8 no_of_data); +unsigned char ReqPktGetNumberOfData(PacketStruct_t *pktbuf); +void *RespPktGetNextData(PacketStruct_t *respPkt, unsigned int *length, unsigned char *type); +void *RespPktGetFirstData(PacketStruct_t *respPkt, unsigned int *length, unsigned char *type); +void *ReqPktGetFirstData(PacketStruct_t *reqPkt, unsigned int *length, unsigned char *type); +void *ReqPktGetNextData(PacketStruct_t *reqPkt, unsigned int *length, unsigned char *type); + +unsigned char RespPktGetNumberOfData(PacketStruct_t *pktbuf); +PacketStruct_t *RespPktInsertStatus(uint8 status); +PacketStruct_t *RespPktInsertData(PacketStruct_t *pktbuf, uint8 type, unsigned int length, void *data); +void DispPacketStruct(PacketStruct_t *pktbuf); +unsigned char ReqPktGetComponentID(PacketStruct_t *pktbuf); +unsigned char ReqPktGetFunctionID(PacketStruct_t *pktbuf); + + + + +#ifdef __cplusplus +} +#endif +#endif /* _CIFSMANAGE_H_ */ diff --git a/include/nwnss/include/cifsMemChunk.h b/include/nwnss/include/cifsMemChunk.h new file mode 100644 index 0000000..ab87410 --- /dev/null +++ b/include/nwnss/include/cifsMemChunk.h @@ -0,0 +1,95 @@ +/**************************************************************************** + | + | (C) Copyright 1995-2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | CIFS module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + +-------------------------------------------------------------------------*/ +/*************************************************************************** + * + * Definitions of the genobj data structure, which is a header that is + * present in many of the CIFS NLM data structures. + * + * Also definitions for the memory chunks from which these objects are + * allocated. + * + * NOTE: Annoying problem- Requires stypes.h to be present ahead of + * its include. + * + **************************************************************************/ +#ifndef _CIFSMEMCHUNK_H_ +#define _CIFSMEMCHUNK_H_ + +#include "cifsStypes.h" +#include "que.h" + +/*--------------------------------------------------------------------------- + * genObj definitions + *---------------------------------------------------------------------------*/ +typedef enum genObjStateTag +{ + genObjFree, + genObjAlloc, + genObjShutdown +} GenObjState_t; + +#pragma pack (push, 4) +typedef struct GenObjectTag_s +{ + DQlink_t link; + int myIndex; + struct genChunkHeadTag_s *head; + int allocCount; + int incarnation; /* updated at alloc and free to inform wtd's */ + /* waking after the data structure is freed that */ + /* they should not complete their operation. */ + int referenceCount; + GenObjState_t state; + BYTE *data; +} GenObjectTag_s; +#pragma pack (pop) + +/*--------------------------------------------------------------------------- + * chunk definitions + *---------------------------------------------------------------------------*/ +#pragma pack (push, 4) +typedef struct genChunkHeadTag_s +{ + char name[20]; + void *objCache; + void **index2ObjectTable; + int *freeIndexTable; + int retrievalIndex; /*Index to freeIndexTable for retrieval of free Index */ + int returnIndex; /*Index to freeIndexTable for returning free Index */ + int genObjSize; +} genChunkHeadTag_s; +#pragma pack (pop) + +#endif /* _CIFSMEMCHUNK_H_ */ + diff --git a/include/nwnss/include/cifsPdc.h b/include/nwnss/include/cifsPdc.h new file mode 100644 index 0000000..02f5e61 --- /dev/null +++ b/include/nwnss/include/cifsPdc.h @@ -0,0 +1,157 @@ +/**************************************************************************** + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + +-------------------------------------------------------------------------*/ +/* + + NOTE: This is code cut straight from Samba source code. The only + modifications made were debug macros. + + Unix SMB/CIFS implementation. + + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Jeremy Allison 1999. + + HMAC MD5 code for use in NTLMv2 + + Copyright (C) Luke Kenneth Casson Leighton 1996-2000 + + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "ctype.h" +#include "string.h" +#include "stdio.h" + +#define uchar unsigned char + +/* get single value from an SMB buffer */ +#define SVAL(buf,pos) (*(const WORD *)((const char *)(buf) + (pos))) +#define SVAL_NC(buf,pos) (*(WORD *)((char *)(buf) + (pos))) /* Non const version of above. */ +#define IVAL(buf,pos) (*(const LONG *)((const char *)(buf) + (pos))) +#define IVAL_NC(buf,pos) (*(LONG *)((char *)(buf) + (pos))) /* Non const version of above. */ +#define SVALS(buf,pos) (*(const short *)((const char *)(buf) + (pos))) +#define SVALS_NC(buf,pos) (*(short *)((char *)(buf) + (pos))) /* Non const version of above. */ +#define IVALS(buf,pos) (*(const long *)((const char *)(buf) + (pos))) +#define IVALS_NC(buf,pos) (*(long *)((char *)(buf) + (pos))) /* Non const version of above. */ + +/* store single value in an SMB buffer */ +#define SSVAL(buf,pos,val) SVAL_NC(buf,pos)=((WORD)(val)) +#define SIVAL(buf,pos,val) IVAL_NC(buf,pos)=((LONG)(val)) +#define SSVALS(buf,pos,val) SVALS_NC(buf,pos)=((short)(val)) +#define SIVALS(buf,pos,val) IVALS_NC(buf,pos)=((long)(val)) + +/* now the reverse routines - these are used in nmb packets (mostly) */ +#define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF)) +#define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16))) + +#define RSVAL(buf,pos) SREV(SVAL(buf,pos)) +#define RSVALS(buf,pos) SREV(SVALS(buf,pos)) +#define RIVAL(buf,pos) IREV(IVAL(buf,pos)) +#define RIVALS(buf,pos) IREV(IVALS(buf,pos)) +#define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val)) +#define RSSVALS(buf,pos,val) SSVALS(buf,pos,SREV(val)) +#define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val)) +#define RSIVALS(buf,pos,val) SIVALS(buf,pos,IREV(val)) + +#ifndef MIN +/* A macro to return the minimum of two values */ +#define MIN( a, b ) ((a) <= (b) ? (a) : (b)) +#endif + + +typedef struct msrpcSecChanVerify_s +{ + BYTE sig[8]; /* 77 00 7a 00 ff ff 00 00 */ + BYTE seq_num[8]; /* verifier, seq num */ + BYTE packet_digest[8]; /* checksum over the packet, MD5'ed with session key */ + BYTE data8[8]; /* random 8-byte nonce */ +} msrpcSecChanVerify_s; + +enum netsec_direction +{ + SENDER_IS_INITIATOR, + SENDER_IS_ACCEPTOR +}; + +/* Internal Flags to indicate what type of authentication on the pipe */ +#define AUTH_PIPE_SIGN 0x0001 +#define AUTH_PIPE_SEAL 0x0002 +#define AUTH_PIPE_NTLMSSP 0x0004 +#define AUTH_PIPE_NETSEC 0x0008 + +typedef struct rpcString_s +{ + LONG maxCount; + LONG offset; + LONG actualCount; +} rpcString_s; + + +#define FSTRING_LEN 256 +typedef char fstring[FSTRING_LEN]; + +/* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */ +typedef struct time_info +{ + LONG time; +} UTIME; + +/* DOM_CHAL - challenge info */ +typedef struct chal_info +{ + BYTE data[8]; /* credentials */ +} DOM_CHAL; + +/* DOM_CREDs - timestamped client or server credentials */ +typedef struct cred_info +{ + DOM_CHAL challenge; /* credentials */ + UTIME timestamp; /* credential time-stamp */ +} DOM_CRED; + +/* Domain controller authentication protocol info */ +struct dcinfo +{ + DOM_CHAL clnt_chal; /* Initial challenge received from client */ + DOM_CHAL srv_chal; /* Initial server challenge */ + DOM_CRED clnt_cred; /* Last client credential */ + DOM_CRED srv_cred; /* Last server credential */ + + BYTE sess_key[8]; /* Session key */ + BYTE md4pw[16]; /* md4(machine password) */ + + fstring mach_acct; /* Machine name we've authenticated. */ + + fstring remote_machine; /* Machine name we've authenticated. */ + + BOOL challenge_sent; + BOOL got_session_key; + BOOL authenticated; + +}; + +struct netsec_auth_struct +{ + BYTE sess_key[16]; + LONG seq_num; +}; + diff --git a/include/nwnss/include/cifsPdcp.h b/include/nwnss/include/cifsPdcp.h new file mode 100644 index 0000000..8af408e --- /dev/null +++ b/include/nwnss/include/cifsPdcp.h @@ -0,0 +1,109 @@ +/**************************************************************************** + | + | (C) Copyright 1995-2004 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | CIFS module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + +-------------------------------------------------------------------------*/ +/**************************************************************************** + * Exports for use by CIFS PDC/Domain add-on modules + *****************************************************************************/ +#ifndef _CIFSPDCP_H_ +#define _CIFSPDCP_H_ + +#include "cifsPdc.h" + +typedef struct domAddOnRegInfoTag_s +{ + int (*credAssert)( + DOM_CHAL *, + uchar *, + DOM_CHAL *, + UTIME); + + void (*credCreate)( + uchar *, + DOM_CHAL *, + UTIME, + DOM_CHAL *); + + void (*credSessionKey)( + const DOM_CHAL *, + const DOM_CHAL *, + const uchar *, + uchar *); + + char * (*credToStr)( + const uchar *); + + BOOL (*dealWithCreds)( + uchar *, + DOM_CRED *, + DOM_CRED *, + DOM_CRED *); + + void (*dumpData)( + int, + uchar *, + int); + + void (*mdFour)( + uchar *, + const uchar *, + int); + + BOOL (*netsecDecode)( + struct netsec_auth_struct *, + int, + enum netsec_direction, + msrpcSecChanVerify_s *, + char *, + LONG); + + void (*netsecEncode)( + struct netsec_auth_struct *, + int, + enum netsec_direction, + msrpcSecChanVerify_s *, + char *, + LONG); + + void (*samOEMHash)( + uchar *, + const uchar *, + int); + +} domAddOnRegInfoTag_s; + +extern int RegisterCIFSDomainAddOn( + struct domAddOnRegInfoTag_s *regInfo ); + +extern void UnRegisterCIFSDomainAddOn(void); + +#endif /* _CIFSPDCP_H_ */ diff --git a/include/nwnss/include/cifsStypes.h b/include/nwnss/include/cifsStypes.h new file mode 100644 index 0000000..ea8a79a --- /dev/null +++ b/include/nwnss/include/cifsStypes.h @@ -0,0 +1,110 @@ +/**************************************************************************** + | + | (C) Copyright 1995-2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | CIFS module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + +-------------------------------------------------------------------------*/ +/*************************************************************************** + * + * sypes.h + * + * Header file with definitions from references + * + **************************************************************************/ + +#ifndef _CIFSSTYPES_H_ +#define _CIFSSTYPES_H_ + +#undef BOOL +#include "omni.h" + +/*************************************************************************** + * + * General typedefs from ref. 1, sec. 3.2 + * + **************************************************************************/ + +typedef struct { + LONG LowPart; + SLONG HighPart; +} LARGE_INTEGER; /* 64 bits of data */ + + +#define PTRINDX(base,offset) ((char*)(base) + (offset)) +#define PTRDIFF(aAddr,bAddr) ((char*)aAddr > (char*)bAddr) ? ((char*)(aAddr)) - ((char*)(bAddr)) : ((char*)(bAddr)) - ((char*)(aAddr)) +#define ODD_DIFF(a,b) ((int) ( ((LONG)(a) ^ (LONG)(b)) ) & 1) + +#ifndef MIN +#define MIN( a, b ) ((a) <= (b) ? (a) : (b)) +#endif + +/**************************************************************************** + * Multi purpose return values. + *****************************************************************************/ +#define ESUCCESS 0 +#define EFAILURE (-1) + +/**************************************************************************** + * Maximum string/name sizes. + *****************************************************************************/ +#define MAX_CIFS_SERVER_NAME 16 /* Includes the trailing NULL */ +#define MAX_CIFS_USER_NAME 21 /* Includes the trailing NULL */ +#define MAX_CIFS_GROUP_NAME 65 /* Includes the trailing NULL */ +#define MAX_CIFS_COMMENT 48 /* Includes the trailing NULL */ +#define MAX_CIFS_WORKGROUP_NAME 48 /* Includes the trailing NULL */ +#define MAX_CIFS_PDC_NAME 48 /* Includes the trailing NULL */ +#define MAX_CIFS_SHARE_NAME 81 /* Includes the trailing NULL */ + +/**************************************************************************** + * Domain related defines + *****************************************************************************/ +#define DOMAIN_SID_LEN 24 +#define MAX_USER_GROUPS 30 +/* + * NOTE: If you change MAX_USER_GROUPS you will also need to increase the + * size of the SAMR_GET_GROUPS and NETLOGON_SAM_LOGON reply buffers + * to make room for MAX_USER_GROUPS Group RIDS. + */ + +#define MAX_LOOKUP_SIDS 10 +/* + * NOTE: If you change MAX_LOOKUP_SIDS you will also need to increase the + * size of the LSARPC_LOOKUP_SIDS_LEVEL1 reply buffers to make room for + * up to MAX_LOOKUP_SIDS return entries. + */ + +/* SID/RID Types */ +#define SID_USER 1 +#define SID_GROUP 2 +#define SID_BUILTIN 4 +#define SID_UNKNOWN 8 + + +#endif /* _CIFSSTYPES_H_ */ diff --git a/include/nwnss/include/cmAlgoMan.h b/include/nwnss/include/cmAlgoMan.h index ac49b65..468d4e5 100644 --- a/include/nwnss/include/cmAlgoMan.h +++ b/include/nwnss/include/cmAlgoMan.h @@ -42,14 +42,14 @@ #endif #ifndef _XCACHE_H_ -#include +#include #endif #if NSS_DEBUG IS_ENABLED /* * If this is the debug version of NSS, - * Set INSIDE_CM to be able to get at structures referred to by + * Set INSIDE_CM to be able to get at structures referred to by * opaque handles below for easy debugging. */ #ifndef INSIDE_CM @@ -89,12 +89,12 @@ typedef STATUS (*CompAlgoStartupFn_t)(); /* * Compression Algorithm's interface exported to the Compression Manager */ -typedef struct CompAlgoIF_s +typedef struct CompAlgoIF_s { STATUS (* init)(); STATUS (* compressStream)( - BYTE algoVersion, + BYTE algoVersion, CMStream_t inStreamHandle, /* read-only */ CMStream_t outStreamHandle, /* write */ CMStream_t tempStreamHandle, /* read/write @@ -102,19 +102,19 @@ typedef struct CompAlgoIF_s BYTE minPercentGain); STATUS (* uncompressStream)( - BYTE algoVersion, - CMStream_t inStreamHandle, + BYTE algoVersion, + CMStream_t inStreamHandle, CMStream_t outStreamHandle); void (* uninit)(); /* Algorithm's destructor called by CM */ } CompAlgoIF_s; -/* +/* * The Algorithm calls this to register itself with the CM soon after it is - * loaded + * loaded */ -extern STATUS +extern STATUS ALGOMGR_registerCompAlgo(BYTE algoID, CompAlgoIF_s *algoIF); /* Called by NSS before unloading an algorithm */ @@ -122,7 +122,7 @@ extern STATUS ALGOMGR_unregisterCompAlgo(BYTE algoID, BOOL abortOngoingActivities, BOOL wait); /* Invoked by CM to request NSS to load an algorithm */ -extern STATUS +extern STATUS loadCompAlgo(BYTE algoID); /* Invoked by CM to init/uninit Algorithm management for given volume, if any */ @@ -140,13 +140,13 @@ ALGOMGR_uninit(void *voidVol, BOOL abortOngoingActivities, BOOL wait); * given logical offset. * Returns a buffer and a pointer and size of valid data in the supplied buffer. * On error, none of the out parameters are valid. - * If isHole is set, the cmBuf handle is invalid; + * If isHole is set, the cmBuf handle is invalid; * so no need to call releaseStreamBuf :-) */ -extern STATUS +extern STATUS ALGOMGR_fetchStreamBuf( - CMStream_t streamHandle, - QUAD offset, + CMStream_t streamHandle, + QUAD offset, CMBuffer_t *cmbuf, /* out; to be passed to releaseStreamBuf when * done */ LONG mode, @@ -159,16 +159,16 @@ ALGOMGR_fetchStreamBuf( void SET_STREAM_BUF_DIRTY(_cmbuf); /* Will be a macro */ #endif -extern STATUS +extern STATUS ALGOMGR_releaseStreamBuf( - CMStream_t streamHandle, - CMBuffer_t cmbuf, + CMStream_t streamHandle, + CMBuffer_t cmbuf, BOOL isdirty); extern QUAD ALGOMGR_getStreamSize(CMStream_t streamHandle); -extern STATUS +extern STATUS ALGOMGR_setStreamSize(CMStream_t streamHandle, QUAD size); extern STATUS ALGOMGR_setStreamPosition(CMStream_t streamHandle, QUAD offset); diff --git a/include/nwnss/include/cmControl.h b/include/nwnss/include/cmControl.h index 51598b1..2e76745 100644 --- a/include/nwnss/include/cmControl.h +++ b/include/nwnss/include/cmControl.h @@ -38,28 +38,28 @@ #define _CM_CONTROL_H_ #ifndef _QUE_H_ -#include +#include #endif /* _QUE_H_ */ /* * Resource Control Interface * Netware Set-parameters for compression */ -typedef struct CMCompControlParams_s +typedef struct CMCompControlParams_s { /* CPU Utilization Parameters */ LONG dailyCheckStartTime; LONG dailyCheckStopTime; LONG maxCompressions; - LONG maxCmActivities; /* Max. # of simultaneous ongoing comp/decomp - * activities allowed + LONG maxCmActivities; /* Max. # of simultaneous ongoing comp/decomp + * activities allowed * i.e., max threads allowed for comp/decomp */ QUAD minFileIdleTime; /* for compression */ QUAD minDeletedFileIdleTime; /* for compression */ BOOL compEnabled; /* Space Utilization parameters */ - LONG maxZidsQueuedForCompression; /* Max # of Beast ZIDs queued in memory + LONG maxZidsQueuedForCompression; /* Max # of Beast ZIDs queued in memory for (background) compression */ LONG minPercentGain; SLONG decompOption; @@ -119,7 +119,7 @@ extern void CM_bgCompressResetTimer(); #define NSS_MAX_COMP_ALGORITHMS 64 /* Currently can't be more than 64 */ /* Compression Management statistics */ -typedef struct CMCompStatistics_s +typedef struct CMCompStatistics_s { Latch_s latch; /* Compression allows multiple threads, use this * latch when any of the following need to be @@ -134,14 +134,14 @@ typedef struct CMCompStatistics_s NINT numQueuedCompReqs; /* # of ZIDs queued for normal compression */ NINT numQueuedBGCompReqs; /* # of ZIDs queued for background compression */ // BYTE averageCompRatio[NSS_MAX_COMP_ALGORITHMS]; - LONG averageCompRatio; /* Average compression ratio achieved for all + LONG averageCompRatio; /* Average compression ratio achieved for all * of the algorithms. */ } CMCompStatistics_s; extern CMCompStatistics_s CM_curCompStatistics; extern STATUS getCompStatistics(CMCompStatistics_s *stats /* inout */); /* Per-volume compression attributes */ -typedef struct VolumeCompAttr_s +typedef struct VolumeCompAttr_s { BYTE ImplMajorVersion; /* Identifies which compression implementation * does this volume use (it's like a version # */ @@ -152,12 +152,12 @@ typedef struct VolumeCompAttr_s BYTE algoVersion; /* Default compression Algorithm Version */ LONG compFlags; /* Cumulative */ //#define VOL_COMP_FLAGS_ENABLE_COMPRESS 0x0002 /* Allow compression */ -#define VOL_COMP_FLAGS_IMMEDIATE_COMPRESS 0x0001 /* Always Keep files +#define VOL_COMP_FLAGS_IMMEDIATE_COMPRESS 0x0001 /* Always Keep files * compressed */ #define VOL_COMP_FLAGS_UPGRADE_START 0x4000 /* LSS has given permission * to start upgrading comp beasts */ -#define VOL_COMP_FLAGS_UPGRADE_FINISHED 0x8000 /* all compressed beasts are +#define VOL_COMP_FLAGS_UPGRADE_FINISHED 0x8000 /* all compressed beasts are * upgraded from rootbeast_s to * compbeast_s */ @@ -176,12 +176,12 @@ extern STATUS volSetCompAttr(Volume_s *volume, VolumeCompAttr_s *newAttr); * structure to hold MAX_COMP_REQS_PER_SCOOP zids. We make sure that * sizeof(CompRequestScoop_s) == 4Kbytes */ -typedef struct CompRequest_s +typedef struct CompRequest_s { Zid_t zid; } CompRequest_s; -typedef struct CompRequestScoop_s +typedef struct CompRequestScoop_s { SQlink_t requestQLink; WORD firstFreeInd; @@ -191,17 +191,17 @@ typedef struct CompRequestScoop_s #define COMP_REQUEST_SCOOP_UNUSED_WORD 3 #else #define COMP_REQUEST_SCOOP_UNUSED_WORD \ - ((sizeof(CompRequest_s) - \ - ((offsetof(struct CompRequestScoop_s, removedQueues) + sizeof(WORD)) \ - % sizeof(CompRequest_s))) / sizeof(WORD)) + ((sizeof(CompRequest_s) - \ + ((offsetof(struct CompRequestScoop_s, removedQueues) + sizeof(WORD)) \ + % sizeof(CompRequest_s))) / sizeof(WORD)) #endif WORD unused[COMP_REQUEST_SCOOP_UNUSED_WORD]; #ifdef COMPILER_NO_INCOMPLETE_OFFSETOF #define MAX_COMP_REQS_PER_SCOOP 510 #else -#define MAX_COMP_REQS_PER_SCOOP \ - ((4096 - (offsetof(struct CompRequestScoop_s, unused) \ - + (sizeof(WORD) * COMP_REQUEST_SCOOP_UNUSED_WORD))) \ +#define MAX_COMP_REQS_PER_SCOOP \ + ((4096 - (offsetof(struct CompRequestScoop_s, unused) \ + + (sizeof(WORD) * COMP_REQUEST_SCOOP_UNUSED_WORD))) \ / sizeof(CompRequest_s)) #endif CompRequest_s req[MAX_COMP_REQS_PER_SCOOP]; @@ -210,25 +210,25 @@ typedef struct CompRequestScoop_s #define MAX_ZIDS_QUEUED_FOR_COMPRESSION \ (MAX_COMP_REQS_PER_SCOOP * MAX_COMP_REQ_SCOOPS) -typedef struct CMVolumeState_s +typedef struct CMVolumeState_s { - BOOL compActive; /* Compression Management is currently + BOOL compActive; /* Compression Management is currently * active in this volume */ SQhead_t compRequestQHead; /* queue head for requests initiated by - * normal file operations. + * normal file operations. */ Latch_s latch; SQhead_t compRequestBGQHead; /* queue head for requests initiated by - * background compression + * background compression */ Latch_s BGlatch; } CMVolumeState_s; /* the following defines different reasons to initiate compression request. - * Currently, the main purpose is just to clean up all the request initiated - * by background compression when stop timer popps + * Currently, the main purpose is just to clean up all the request initiated + * by background compression when stop timer popps */ #define COMP_NORMAL 0x0001 /* by normal file operation */ #define COMP_BACKGROUND 0x0002 /* by background compression thread */ diff --git a/include/nwnss/include/cmNSS.h b/include/nwnss/include/cmNSS.h index c347452..90136fe 100644 --- a/include/nwnss/include/cmNSS.h +++ b/include/nwnss/include/cmNSS.h @@ -38,7 +38,7 @@ #define _CM_NSS_H_ #ifndef _CM_CONTROL_H_ -#include +#include #endif /* Compression Manager startup/shutdown */ @@ -47,13 +47,13 @@ void CM_shutdown(BOOL abortOngoingActivities, BOOL wait); /* Command line operation */ extern STATUS CM_screenDisplay(); -extern void CM_stopCompression(NINT reason); +extern void CM_stopCompression(); /* Per-volume Compression startup/shutdown */ extern STATUS CM_volumeActivate(Volume_s *volume); STATUS CM_initVolumeRuntime(Volume_s *volume); void CM_uninitVolumeRuntime(Volume_s *volume); -extern void CM_volumeDeactivate(Volume_s *volume, +extern void CM_volumeDeactivate(Volume_s *volume, BOOL abortOngoingActivities, BOOL wait); extern void CM_resetVolumeCompState(Volume_s *volume); extern void CM_initVolumeCompState(Volume_s *volume); @@ -75,12 +75,12 @@ STATUS decompressNoRights ( void addLeaveCompressedToGrantedRights( RootBeast_s *beast); -STATUS +STATUS CM_uncompressFileRange( GeneralMsg_s *genMsg, - RootBeast_s *uncompBeast, - QUAD offset, - QUAD size, + RootBeast_s *uncompBeast, + QUAD offset, + QUAD size, NINT accessMode, NINT latchType, Xaction_s *xaction, @@ -88,11 +88,11 @@ CM_uncompressFileRange( BOOL wait, BOOL *isDone); /* out */ -STATUS +STATUS CM_compressFileRange( GeneralMsg_s *genMsg, - RootBeast_s *uncompBeast, - QUAD offset, + RootBeast_s *uncompBeast, + QUAD offset, QUAD size, NINT latchType, Xaction_s *xaction, @@ -101,12 +101,12 @@ CM_compressFileRange( BOOL *isDone, NINT reason); /* out */ -BOOL +BOOL CM_checkParentDirForCompressOK( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, File_s *beast); -STATUS +STATUS CM_compressFileAsync( GeneralMsg_s *genMsg, RootBeast_s *uncompBeast, @@ -166,7 +166,7 @@ CM_accessCompFileDone( STATUS CM_cleanupBeast( GeneralMsg_s *genMsg, - RootBeast_s *uncompBeast, + RootBeast_s *uncompBeast, Xaction_s *xaction); STATUS fixCompFlags( diff --git a/include/nwnss/include/comnAuthorize.h b/include/nwnss/include/comnAuthorize.h index ac15609..ad6e609 100644 --- a/include/nwnss/include/comnAuthorize.h +++ b/include/nwnss/include/comnAuthorize.h @@ -43,25 +43,25 @@ #ifndef _COMNAUTHORIZE_H_ #define _COMNAUTHORIZE_H_ -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) #ifndef _COMNBEASTCLASS_H_ -#include +#include #endif -#include +#include #ifndef _OMNI_H_ -#include +#include #endif #endif #ifndef _GUID_H_ -#include +#include #endif -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) #ifndef _COMNPARAMS_H_ -#include +#include #endif #endif @@ -75,7 +75,7 @@ extern "C" { #define zINVALID_USERID zINVALID_GUID #define zSUPERVISOR_ID zSUPERVISOR_USERID -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) /*------------------------------------------------------------------------- * * The following define the authorization system types @@ -633,7 +633,7 @@ extern STATUS ZAS_FixVisibility( extern STATUS VAUTH_PassedMAC( struct GeneralMsg_s *genMsg, - struct NSSConnection_s *pssConn, + struct NSSConnection_s *pssConn, struct AuthBeast_s *authBeast, NINT operation); diff --git a/include/nwnss/include/comnBeastClass.h b/include/nwnss/include/comnBeastClass.h index 1927360..9413e1d 100644 --- a/include/nwnss/include/comnBeastClass.h +++ b/include/nwnss/include/comnBeastClass.h @@ -44,10 +44,10 @@ #define _COMNBEASTCLASS_H_ #ifndef _COMNBEASTS_H_ -# include +# include #endif -#include +#include #ifdef __cplusplus extern "C" { @@ -115,7 +115,7 @@ extern NINT BST_getPackedSizeIndex( struct RootBeast_s *beast, NINT storageIndex); -extern void BST_doPackIndex( +extern void BST_doPackIndex( struct RootBeast_s *beast, void *data, NINT packedLen, diff --git a/include/nwnss/include/comnBeasts.h b/include/nwnss/include/comnBeasts.h index aee62d9..3096cc8 100644 --- a/include/nwnss/include/comnBeasts.h +++ b/include/nwnss/include/comnBeasts.h @@ -44,11 +44,11 @@ #define _COMNBEASTS_H_ #ifndef _ZOMNI_H_ -# include +# include #endif #ifndef _ZPARAMS_H_ -# include +# include #endif #if 0 @@ -58,19 +58,19 @@ #endif #ifndef _LATCH_H_ -# include +# include #endif #ifndef _XCACHE_H_ -#include +#include #endif #ifndef _XCACHE_H_ -# include +# include #endif #ifndef _EFLDEFS_H_ -# include +# include #endif #ifdef __cplusplus @@ -118,7 +118,7 @@ typedef struct Xaction_s * Structures for use with the purge log calls. *-------------------------------------------------------------------------*/ -#define MAX_PLOG_LOCATION_SIZE 4 /* This is the max size in "LONGs" +#define MAX_PLOG_LOCATION_SIZE 4 /* This is the max size in "LONGs" * that the PurgeLogLocation structure * can be */ @@ -164,7 +164,7 @@ typedef struct FixVisibMsg_s } FixVisibMsg_s; #define SETUP_FIX_VISIBILITY_PURGE_LOG(_msg, _loc, _action, _pzid, _uid) \ ( (_msg)->visib.purgeLogLoc = (_loc), \ - (_msg)->visib.action = (_action), \ + (_msg)->visib.action = (_action), \ (_msg)->visib.parentZID = (_pzid), \ (_msg)->visib.trusteeID = (_uid) ) @@ -264,7 +264,7 @@ typedef union PurgeLogMsg_s #define PLOG_TRUNCATE 2 /* truncate a file */ #define PLOG_BLOCK_FREE 3 /* delete a block (add to the free tree) */ #define PLOG_BEAST_COMP_CLEANUP 4 /* Cleanup extra beast compression state */ -#define PLOG_FIX_VISIBILITY 5 /* add/remove visibility up the tree */ +#define PLOG_FIX_VISIBILITY 5 /* add/remove visibility up the tree */ #define PLOG_SCAN_USER_NAMES 6 /* update names in the user tree from a volume */ #define PLOG_REMOVE_DIR_TREE 7 /* remove the directory tree from a volume */ #define PLOG_DIR_QUOTA_USED 8 /* fill in used amount for a directory quota entry */ @@ -296,7 +296,7 @@ typedef struct StorageInfo_s typedef struct GetStorageInfo_s { QUAD physicalEOF; /* Physical EOF */ - QUAD filePhysSize; /* Physical size of the file in bytes */ + QUAD filePhysSize; /* Physical size of the file in bytes */ QUAD metaDataPhysSize; /* Physical size of the metadata in bytes */ } GetStorageInfo_s; @@ -343,11 +343,11 @@ typedef struct RootBeast_s * given volume*/ DQlink_t hash; /* used by beast cache hash table*/ DQlink_t notInUseLink; /* link used to keep track of NOTINUSE beasts*/ - struct RootBeast_s *fileSnapshotBeast; /* Points to the snapshot beast + struct RootBeast_s *fileSnapshotBeast; /* Points to the snapshot beast * if COW is enabled and file is * open for write */ - NINT *bitMap; /* A pointer to in memory bit map of - * blocks of the file that have been + NINT *bitMap; /* A pointer to in memory bit map of + * blocks of the file that have been * snapshotted. */ Blknum_t bitCount; /* Number of valid bits in bitMap */ @@ -424,13 +424,13 @@ typedef struct RootBeast_s * new version number (this one) is put in as the current version. */ #define BEAST_VERSION_1 1 /* this version supports 32 bit IDs */ -#define BEAST_VERSION_2 2 /* this version supports other parent lists */ +#define BEAST_VERSION_2 2 /* this version supports other parent lists */ #define BEAST_VERSION_3 3 /* this version supports new hard links */ #define BEAST_VERSION_KEIPPER 57 /* this is a temp version for a one-time fix for Keipper */ #define CURRENT_BEAST_VERSION 3 /* this version support new style of hardlinks */ /* * Beast version 2 Converts all 32 bit NDS IDs to 128 bit NDS GUIDs. - * Moves the owner ID to the root. + * Moves the owner ID to the root. */ @@ -444,7 +444,7 @@ typedef struct RootBeast_s * inserted into the volume yet*/ #define BST_STATE_TOSSING 0x00000010 /* beast is being tossed */ #define BST_STATE_PURGING 0x00000020 /* beast is being purged */ -#define BST_STATE_FULL_FLUSH 0x00000040 /* if set, we want to flush the +#define BST_STATE_FULL_FLUSH 0x00000040 /* if set, we want to flush the * beast as well as the data * blocks. If this is not set, * and you request to write the @@ -479,9 +479,9 @@ typedef struct RootBeast_s #define BST_STATE_TOSS_ON_RELEASE 0x00010000 /* Toss the beast when released * Don't save it in memory -- * Used by NFS Gateway */ -#define BST_STATE_DATA_CHANGED 0x00020000 /* Set to indicate the actual +#define BST_STATE_DATA_CHANGED 0x00020000 /* Set to indicate the actual * data in the beast changed */ -#define BST_STATE_METADATA_CHANGED 0x00040000 /* Set to indicate meta data +#define BST_STATE_METADATA_CHANGED 0x00040000 /* Set to indicate meta data * we care about has changed */ /**************************************************************************** @@ -510,7 +510,7 @@ typedef struct PersistentNameEntry_s * forced it to upper case. */ #define NAMEovflow 0x4000 /* duplicate names stored in fflow * blocks (ZFS naming B-tree-specific) */ -#define NAMEdup 0x2000 /* Duplicate names exist +#define NAMEdup 0x2000 /* Duplicate names exist * (ZFS naming B-tree-specific) */ #define NAMEool 0x1000 /* name field points to an out-of-line * array (ZFS naming B-tree-specific) */ @@ -661,7 +661,7 @@ typedef struct NamedBeast_s WORD denyReaderCount; /* NOT PERSISTENT - Number of current deny readers */ WORD denyWriterCount; /* NOT PERSISTENT - Number of current deny writers */ WORD dontDeleteWhileOpenCount; /* NOT PERSISTENT - Number of "don't delete" opens */ - WORD reserved1; /* cnt WORD lastNameUniquifier; NOT PERSISTENT - value of largest nameUniquifier */ + WORD reserved1; /* cnt WORD lastNameUniquifier; NOT PERSISTENT - value of largest nameUniquifier */ WORD snapReaderCount; /* NOT PERSISTENT - number of backup readers currently reading either the real file or snapshot file. */ WORD pad; struct CROAccessLeaseList_s *NB_alList; /* List of Access Leases */ @@ -669,20 +669,20 @@ typedef struct NamedBeast_s /* If either of these two nameFlag bits is set, the dataStreamInfo field in the * non-persistent file beast will be calculated as needed at runtime.*/ -#define NFL_HAS_DATA_STREAMS 0x0001 /* nameFlag bit, set if file has +#define NFL_HAS_DATA_STREAMS 0x0001 /* nameFlag bit, set if file has * data streams */ -#define NFL_HAS_EXTENDED_ATTRIBUTES 0x0002 /* nameFlag bit, set if file had +#define NFL_HAS_EXTENDED_ATTRIBUTES 0x0002 /* nameFlag bit, set if file had * extended attributes */ -#define NFL_ADDED_TO_SALVAGE_TREE 0x0100 /* File was added to the +#define NFL_ADDED_TO_SALVAGE_TREE 0x0100 /* File was added to the * salvage tree */ -#define NFL_BLKS_NOT_IN_PURGEABLE_CNT 0x0200 /* File was added to the +#define NFL_BLKS_NOT_IN_PURGEABLE_CNT 0x0200 /* File was added to the * salvage tree, but its blocks - * were not added to the - * purgeableCount as the file + * were not added to the + * purgeableCount as the file * was still open. */ -#define NFL_PURGED_FROM_SALVAGE_TREE 0x0400 /* File was purged from salvage tree - */ +#define NFL_PURGED_FROM_SALVAGE_TREE 0x0400 /* File was purged from salvage tree + */ #define NAMEDroot root @@ -726,7 +726,7 @@ typedef struct NamedBeast_s #define NAMEDdenyReaderCount denyReaderCount #define NAMEDdenyWriterCount denyWriterCount #define NAMEDdontDeleteWhileOpenCount dontDeleteWhileOpenCount -#define NAMEDsnapReaderCount snapReaderCount +#define NAMEDsnapReaderCount snapReaderCount #define NAMEDopenFlags openFlags /**************************************************************************** @@ -822,7 +822,7 @@ typedef struct PersistentFile_s * salvage area), it is the deletion time*/ Time_t archivedTime; /* PERSISTENT - Last time file was archived */ UserID_t modifierID; /* PERSISTENT - ID of the last modifier */ - UserID_t metaDataModifierID; /* PERSISTENT - ID of the last modifier of + UserID_t metaDataModifierID; /* PERSISTENT - ID of the last modifier of * the metadata */ UserID_t archiverID; /* PERSISTENT - ID of the last archiver */ } NSS_MEDIA_STRUCTURE(PersistentFile_s,archiverID) PersistentFile_s; @@ -842,7 +842,7 @@ typedef struct V1_PersistentFile_s * salvage area), it is the deletion time*/ Time_t archivedTime; /* PERSISTENT - Last time file was archived */ LONG modifierID; /* PERSISTENT - ID of the last modifier */ - LONG metaDataModifierID; /* PERSISTENT - ID of the last modifier of + LONG metaDataModifierID; /* PERSISTENT - ID of the last modifier of * the metadata */ LONG archiverID; /* PERSISTENT - ID of the last archiver */ } NSS_MEDIA_STRUCTURE(V1_PersistentFile_s,archiverID) V1_PersistentFile_s; @@ -939,7 +939,7 @@ typedef struct File_s *========================================================================= * BEAST OPERATIONS * - * + * * This defines the operations that are common across all objects in the * system. These operations are always directed to the object being * acted upon. @@ -977,7 +977,7 @@ typedef struct CommonBeastOps_s // cnt struct GeneralMsg_s *genMsg, // cnt NamedBeast_s *beast); - /* ALLOCATE and initialize the TypeSpecificPersistentParentEntry_s + /* ALLOCATE and initialize the TypeSpecificPersistentParentEntry_s * structure pointed to by the parentEntry->t field. The common layer * currently only uses this field for salvage metadata, and the default * functionality provided by the NamedBeast supports this default salvage @@ -1008,7 +1008,7 @@ typedef struct CommonBeastOps_s /* is the given directory empty*/ /* LSS must implement this */ BOOL (*BST_isDirectoryEmpty)( - struct GeneralMsg_s *genMsg, + struct GeneralMsg_s *genMsg, NamedBeast_s *directory, NINT nameType); @@ -1081,7 +1081,7 @@ typedef struct CommonBeastOps_s /* This locates the curName and curNameSpaceMask in the directory, via * an exact binary match. Then it replaces the nameSpacemask with - * the newNameSpacemask. NOTE--This function does not validate the + * the newNameSpacemask. NOTE--This function does not validate the * new nameSpacemask, it blindly obeys. All validity checking must * be done by the caller previous to calling this function. ALSO, * this function may not be used to set the nameSpaceMask to 0. */ @@ -1111,7 +1111,7 @@ typedef struct CommonBeastOps_s NINT nameType, unicode_t *name, // cnt NINT nameUniquifier, /* Caller passes zFNU_UNDEFINED if not known */ - NINT newMatchAttributes, /* Same as MA_xxx defines above */ + NINT newMatchAttributes, /* Same as MA_xxx defines above */ Xaction_s *xaction); /* Optional xaction, may be NULL */ /* this is called to locate a name in a directory via wildcarding*/ @@ -1163,7 +1163,7 @@ typedef struct CommonBeastOps_s /* * Get the real physical extent for the object. We are going to - * do it one at a time for now. + * do it one at a time for now. */ STATUS (*BST_getPhysicalExtent)( struct zNSSMsg_s *msg, @@ -1274,7 +1274,7 @@ typedef struct CommonBeastOps_s RootBeast_s *beast, NINT bufLen, utf8_t *buf, - Xaction_s *xaction, + Xaction_s *xaction, BOOL doChange); /** New functions should be added at the end of this structure */ @@ -1306,12 +1306,12 @@ typedef struct COMNDirQuota_s */ typedef Time_t Epoch_t; -typedef struct MFLKey_s +typedef struct MFLKey_s { Zid_t zid; /* file's ZID */ } NSS_MEDIA_STRUCTURE(MFLKey_s,zid) MFLKey_s; -typedef struct MFLValue_s +typedef struct MFLValue_s { Epoch_t epoch; LONG reserved; /* to set value size to multiple of 64-bit word */ @@ -1488,12 +1488,12 @@ typedef struct FCNTL_Out_s * Defines for newHardLinkFlags in FCNTL_SetHardLinkFlags_s structure. * This is stored as a single BYTE */ -#define HL_FLAG_IS_VALID 0x80 /* If set, the other "HL_FLAG_IS_HARD_LINK" +#define HL_FLAG_IS_VALID 0x80 /* If set, the other "HL_FLAG_IS_HARD_LINK" * flag can be assumed to be accurate. * If this is zero, the "HL_FLAG_IS_HARD_LINK" * bit must also be zero. */ -#define HL_FLAG_IS_HARD_LINK 0x40 /* If "HL_FLAG_IS_VALID" is set, then +#define HL_FLAG_IS_HARD_LINK 0x40 /* If "HL_FLAG_IS_VALID" is set, then * this indicates if the name belongs * to a hard link. */ @@ -1591,7 +1591,7 @@ typedef struct *========================================================================= * VOLUME OPERATIONS * - * + * * This defines volume specific operations that are only sent to a * VOLUME object which means they must be implemented by LSSs. *========================================================================= @@ -1613,7 +1613,7 @@ typedef struct CommonVolumeOps_s // cnt struct GeneralMsg_s *genMsg, // cnt NamedBeast_s *beast); - /* ALLOCATE and initialize the TypeSpecificPersistentParentEntry_s + /* ALLOCATE and initialize the TypeSpecificPersistentParentEntry_s * structure pointed to by the parentEntry->t field. The common layer * currently only uses this field for salvage metadata, and the default * functionality provided by the NamedBeast supports this default salvage @@ -1643,7 +1643,7 @@ typedef struct CommonVolumeOps_s /* is the given directory empty*/ /* LSS must implement this */ BOOL (*VOL_isDirectoryEmpty)( - struct GeneralMsg_s *genMsg, + struct GeneralMsg_s *genMsg, NamedBeast_s *directory, NINT nameType); @@ -1694,7 +1694,7 @@ typedef struct CommonVolumeOps_s /* This locates the curName and curNameSpaceMask in the directory, via * an exact binary match. Then it replaces the nameSpacemask with - * the newNameSpacemask. NOTE--This function does not validate the + * the newNameSpacemask. NOTE--This function does not validate the * new nameSpacemask, it blindly obeys. All validity checking must * be done by the caller previous to calling this function. ALSO, * this function may not be used to set the nameSpaceMask to 0. */ @@ -1777,7 +1777,7 @@ typedef struct CommonVolumeOps_s Blknum_t *retNextBlock); /* * Get the real physical extent for the object. We are going to - * do it one at a time for now. + * do it one at a time for now. */ STATUS (*VOL_getPhysicalExtent)( struct zNSSMsg_s *msg, @@ -1840,8 +1840,8 @@ typedef struct CommonVolumeOps_s #define X_CF_OK_TO_THROTTLE 0x00000002 /* When set this transaction can be * throttled. */ -#define X_CF_DEFAULT (X_CF_COMMON_LAYER | X_CF_OK_TO_THROTTLE) - /* Default value to pass into +#define X_CF_DEFAULT (X_CF_COMMON_LAYER | X_CF_OK_TO_THROTTLE) + /* Default value to pass into * beginXLocal common op function */ /* This is called to end a transaction. */ @@ -1996,8 +1996,8 @@ typedef struct CommonVolumeOps_s * in those purged files in the salvage system. * This function will return with at least numberOfBlocks free on the * volume, or else it will return an error. - * Purge asynchronously if the asyncPurge flag is set. If number of - * blocks is zero and asyncPurge is set, purge upto the high threshold. + * Purge asynchronously if the asyncPurge flag is set. If number of + * blocks is zero and asyncPurge is set, purge upto the high threshold. * LSS must implement this if it supports salvage */ STATUS (*VOL_makeVolumeFreeSpace)( struct GeneralMsg_s *genMsg, @@ -2012,12 +2012,12 @@ typedef struct CommonVolumeOps_s * the selectionCriteria. * * The LSS should fill the beastZids array with the next numBeastsRequested - * beasts after lastReturnedBeastZid attempting to satisfy specified + * beasts after lastReturnedBeastZid attempting to satisfy specified * selectionCriteria, and return the number actually supplied via the * numBeastsReturned parameter. It should also update the lastBeastReturned * cookie to be presented during the next browse call. Initially - * INVALID_ZID is passed in as the cookie. The condition - * (numBeastsReturned < numBeastsRequested) + * INVALID_ZID is passed in as the cookie. The condition + * (numBeastsReturned < numBeastsRequested) * indicates that there are no more beasts available to browse. * * NOTE: Selection Criteria are only a hint to the LSS on why the common @@ -2032,7 +2032,7 @@ typedef struct CommonVolumeOps_s Zid_t *lastBeastReturned, /* inout */ Zid_t *beastZids, /* out */ NINT *numBeastsReturned); /* out */ -/* bits are defined in nssPubs.h for Linux userspace access */ +/* bits are defined in nssPubs.h for Linux userspace access */ //#define SELECT_BEASTS_ALL 0x00000000 //#define SELECT_BEASTS_FOR_COMPRESSION 0x00000001 //#define SELECT_BEASTS_SALVAGEABLE 0x00000002 @@ -2074,7 +2074,7 @@ typedef struct CommonVolumeOps_s struct Xaction_s *xAction, struct RootBeast_s *beast, SQUAD usedAdjustment); - + /* * This routine removes a user from user space restrictions. * @@ -2103,49 +2103,49 @@ typedef struct CommonVolumeOps_s struct GeneralMsg_s *genMsg, struct Volume_s *volume, NINT numEntriesRequested, - UserID_t *lastUserReturned, + UserID_t *lastUserReturned, COMNUserRest_s *userEntries, NINT *numUsersReturned, LONG allUsersFlag); /** allUsersFlag defines **/ - /** GET_USED_OR_RESTRICTED: Default behavior if neither of the + /** GET_USED_OR_RESTRICTED: Default behavior if neither of the ** next 2 flags are set then we return the users ** that have a used amount or if they have a restriction. - ** GET_ALL : Get all the users with/without restrictions, + ** GET_ALL : Get all the users with/without restrictions, ** with/without used amounts ** GET_ONLY_RESTRICTED: Get only those users that have a restriction. ** ** GET_COUNT: Get the count of users. Honor the first 2 flags. - ** - ** START_AT_COUNT: Return the users, but skip the first n users. + ** + ** START_AT_COUNT: Return the users, but skip the first n users. **/ #define BROWSE_USERS_GET_USED_OR_RESTRICTED 0x00000000 #define BROWSE_USERS_GET_ALL 0x00000001 #define BROWSE_USERS_GET_ONLY_RESTRICTED 0x00000002 #define BROWSE_USERS_GET_COUNT 0x00000004 #define BROWSE_USERS_START_AT_COUNT 0x00000008 - + STATUS (* VOL_insertMFLEntry)( struct GeneralMsg_s *genMsg, struct Volume_s *volume, Zid_t zid, Epoch_t epoch, struct Xaction_s *xaction); - + STATUS (* VOL_deleteMFLEntry)( struct GeneralMsg_s *genMsg, struct Volume_s *volume, Zid_t zid, Epoch_t *epoch, /* out */ struct Xaction_s *xaction); - + STATUS (* VOL_lookupMFLEntry)( struct GeneralMsg_s *genMsg, struct Volume_s *volume, Zid_t zid, Epoch_t *epoch); /* out */ - + STATUS (* VOL_enumerateMFL)( struct GeneralMsg_s *genMsg, struct Volume_s *volume, @@ -2172,17 +2172,17 @@ typedef struct CommonVolumeOps_s * that the Volume_s volume ops are called. The Volume_s fucntion * releases the useCount on the 'beast' and then returns the NSS * error zERR_NOT_SUPPORTED. - * + * * The return status should either be zOK or a valid NSS error code. * * parmLen The length of parm in bytes. - * + * * parm A pointer to a buffer which contains the contents of * the command element. If the LSS does not support the * given command element then the LSS should return * the NSS error zERR_NOT_SUPPORTED. - * - * dataLen The length of commandData in bytes. + * + * dataLen The length of commandData in bytes. * * commandData A pointer to a buffer where the data for the command is found. * @@ -2193,7 +2193,7 @@ typedef struct CommonVolumeOps_s * retBuf A pointer to a buffer to be used in returning a response to * the command. The contents of this buffer are copied to * the response buffer to satisfy subsequent reads. - * + * * retLen The length, in bytes, of the data in retBuf. * * NOTE - If the LSS supports this comn op it must do COMN_Release(&beast) @@ -2259,7 +2259,7 @@ typedef struct CommonVolumeOps_s struct Volume_s *volume, Zid_t dirZid, SQUAD usedAdjustment); - + /* * This routine removes a directory from the directory quotas. * @@ -2289,7 +2289,7 @@ typedef struct CommonVolumeOps_s struct GeneralMsg_s *genMsg, struct Volume_s *volume, NINT numEntriesRequested, - Zid_t *lastDirReturned, + Zid_t *lastDirReturned, COMNDirQuota_s *dirEntries, NINT *numDirsReturned); @@ -2327,7 +2327,7 @@ typedef struct CommonVolumeOps_s NINT action, unicode_t *name, struct Xaction_s *xaction); - + STATUS (*VOL_deleteEFLEntry)( struct GeneralMsg_s *genMsg, struct Volume_s *volume, @@ -2363,10 +2363,10 @@ typedef struct CommonVolumeOps_s #define VOL_EFL_ADMIN_REMOVE_EPOCH 2 #define VOL_EFL_ADMIN_RESET_EFL 3 #define VOL_EFL_ADMIN_LIST_EPOCHS 4 -#define VOL_EFL_ADMIN_GET_NAME_SPACE_ID 5 -#define VOL_EFL_ADMIN_SET_NAME_SPACE_ID 6 -#define VOL_EFL_ADMIN_GET_INACTIVE_EPOCH_INTERVAL 7 -#define VOL_EFL_ADMIN_SET_INACTIVE_EPOCH_INTERVAL 8 +#define VOL_EFL_ADMIN_GET_NAME_SPACE_ID 5 +#define VOL_EFL_ADMIN_SET_NAME_SPACE_ID 6 +#define VOL_EFL_ADMIN_GET_INACTIVE_EPOCH_INTERVAL 7 +#define VOL_EFL_ADMIN_SET_INACTIVE_EPOCH_INTERVAL 8 #define VOL_EFL_ADMIN_PING_EPOCH 9 #define VOL_EFL_ADMIN_CHECK_EPOCH 10 #define VOL_EFL_GET_STATUS 11 @@ -2405,12 +2405,12 @@ typedef struct LSSSpecificPackUnpackOps_s */ /* calculates PACKED size of beast*/ - NINT (*packedSize)( + NINT (*packedSize)( void *beast); /* beast to get the size of*/ /* pack the given beast into the given data buffer, returns the updated * DATA pointer after packing*/ - BYTE *(*pack)( + BYTE *(*pack)( void *beast, /* beast we are packing*/ BYTE *data); /* address to copy too*/ @@ -2440,7 +2440,7 @@ typedef struct LSSSpecificPackUnpackOps_s typedef struct AdminVolFile_s { File_s file; /* derived from a file*/ - Key_t specialBeastDirKey; /* If not zero then it is the key to the + Key_t specialBeastDirKey; /* If not zero then it is the key to the * directory were the beast is found */ } AdminVolFile_s; @@ -2492,7 +2492,7 @@ typedef struct AdminVolFile_s typedef struct PersistentComp_s { Zid_t uncompZid; /* zid of the uncompressed beast */ - LONG unused[4]; + LONG unused[4]; } NSS_MEDIA_STRUCTURE(PersistentComp_s,unused[4]) PersistentComp_s; @@ -2605,7 +2605,7 @@ extern void BST_tossAsync( extern STATUS BST_flush(void *beast); -extern STATUS BST_truncate( +extern STATUS BST_truncate( struct GeneralMsg_s *genMsg, void *beast, Blknum_t block, @@ -2632,14 +2632,14 @@ extern void NAMED_BeastCleanupNames(NamedBeast_s *beast, BOOL beastIsLatched); ((_volume)->VOLcomnVolOps.VOL_getBeastFromVolume((_genmsg), (_zid), (_volume))) #define BST_UNLINK_FROM_ALL_LISTS_NO_TIMER(_beast) \ - { \ + { \ BEASTHASH_Remove((_beast)); \ if (QMEMBER(&(_beast)->volLink)) \ DQ_RMV((_beast),volLink); \ } -#define BST_UNLINK_FROM_ALL_LISTS(_beast) \ - { \ +#define BST_UNLINK_FROM_ALL_LISTS(_beast) \ + { \ CANCEL_ALARM((_beast)->mycache.agent.timer); \ BST_UNLINK_FROM_ALL_LISTS_NO_TIMER((_beast)); \ } @@ -2661,10 +2661,10 @@ extern void BST_MarkCleanAndNotNew(RootBeast_s *beast); #define BST_UNUSE_BEAST(_beast) \ (zASSERT((_beast)->useCount > 0),(_beast)->useCount--) /* this MUST only be used internally in very special cases*/ -#define BST_CLEAR_WRITING_STATE(_beast) \ +#define BST_CLEAR_WRITING_STATE(_beast) \ { \ - (_beast)->bstState &= ~(BST_STATE_FLUSHING | \ - BST_STATE_FLUSHING_BY_TIMER | \ + (_beast)->bstState &= ~(BST_STATE_FLUSHING | \ + BST_STATE_FLUSHING_BY_TIMER | \ BST_STATE_FULL_FLUSH); \ } diff --git a/include/nwnss/include/comnIO.h b/include/nwnss/include/comnIO.h index ee51710..d541f04 100644 --- a/include/nwnss/include/comnIO.h +++ b/include/nwnss/include/comnIO.h @@ -69,7 +69,7 @@ extern Buffer_s *COMN_GetFileBlkOrHole( GeneralMsg_s *genMsg, IoMsg_s *ioMsg, Blknum_t *holeBlks); - + #define IS_BLOCK_BOUNDARY(_offset, _dataStream) \ ((((_offset) >> (_dataStream)->NAMEDmycache.bufSizeShift) \ << (_dataStream)->NAMEDmycache.bufSizeShift) == (_offset)) @@ -97,7 +97,7 @@ extern STATUS COMN_CopyFilemapToSnapshot( GeneralMsg_s *genMsg, RootBeast_s *beast, Blknum_t blknum); - + extern BOOL COMN_ReadSnapOrDontCopyToSnap( RootBeast_s *beast, Blknum_t bitNumber); diff --git a/include/nwnss/include/comnMacShortName.h b/include/nwnss/include/comnMacShortName.h old mode 100644 new mode 100755 index 8190350..a9b96cd --- a/include/nwnss/include/comnMacShortName.h +++ b/include/nwnss/include/comnMacShortName.h @@ -32,9 +32,9 @@ | |--------------------------------------------------------------------------- | This module is used to: - | Share functions to create mangled Mac names (31 char names) from - | extended Mac names and to find a zid embedded in a mangled Mac - | file name. + | Share functions to create mangled Mac names (31 char names) from + | extended Mac names and to find a zid embedded in a mangled Mac + | file name. +-------------------------------------------------------------------------*/ #ifndef _COMN_MAC_SHORT_NAME_H_ #define _COMN_MAC_SHORT_NAME_H_ @@ -44,15 +44,15 @@ extern "C" { #endif extern STATUS COMN_MakeShortMacFileName ( - zInfo_s * zSrcInfo, - unicode_t * shortFileName, + zInfo_s * zSrcInfo, + unicode_t * shortFileName, BYTE * MacByteName); extern LONG COMN_GetZidFromMangledName ( unicode_t * fileName); extern BOOL COMN_VerifyMangledMacName ( - unicode_t * mangledName, + unicode_t * mangledName, unicode_t * fileName); @@ -61,3 +61,4 @@ extern BOOL COMN_VerifyMangledMacName ( #endif #endif + diff --git a/include/nwnss/include/comnParams.h b/include/nwnss/include/comnParams.h index b2d6eb1..e80e69f 100644 --- a/include/nwnss/include/comnParams.h +++ b/include/nwnss/include/comnParams.h @@ -45,19 +45,19 @@ #define _COMNPARAMS_H_ #ifndef _MSGGEN_H_ -# include +# include #endif #ifndef _XUNICODE_H_ -#include +#include #endif #ifndef _COMNBEASTS_H_ -# include +# include #endif #ifndef _ZPARAMS_H_ -# include +# include #endif #ifdef __cplusplus @@ -90,14 +90,14 @@ typedef struct UserXaction_s UserXaction_s; #define zSAGENT_Z 1 #define zSAGENT_NETWARE 2 #define zSAGENT_NFS 3 -#define zSAGENT_HTTP 4 -#define zSAGENT_CIFS 5 +#define zSAGENT_HTTP 4 +#define zSAGENT_CIFS 5 #define zSAGENT_LSA 6 #define zSAGENT_MAX_ID 32 /* the volevent subsystem keeps an array indexed * by semantic agent ID. This is the size of * that array. If we ever need to support more - * than this number of semantic agents, this + * than this number of semantic agents, this * number needes to be expanded. */ #if BLKNUM_64 IS_DISABLED @@ -204,7 +204,7 @@ typedef struct COMNVersionInformation_s NINT minorVersion; /* 0-nn */ NINT subVersion; /* 0-nn */ NINT buildNumber; /* 1-nnnn */ - NINT apiVersion; /* 1-x */ + NINT apiVersion; /* 1-x */ NINT debugEnabled; /* TRUE or FALSE */ NINT reserved[10]; } COMNVersionInformation_s; @@ -266,7 +266,7 @@ typedef struct DeleteMsg_s *---------------------------------------------------------------------------*/ typedef struct FileMapMsg_s { - QUAD startingOffset; /* start offset for the map */ + QUAD startingOffset; /* start offset for the map */ NINT extentListCount; /* num elements to fit in ret list */ NINT extentListFormat; /* format for the return extent list */ void *ret_extentList; /* return buffer for the extents */ @@ -287,11 +287,11 @@ typedef struct FileMapMsg_s typedef struct GetNameMsg_s { /* Info for FileType-generic information */ - NINT getNameMask; /* which optional path info to get */ - NINT internalFlags; /* Internal only flags for get file name */ - NINT pathFormat; /* path format to get name in */ - NINT nameSpaceID; /* namespace to get name in */ - NINT sizeRetGetName; /* sz of buf to receive info */ + NINT getNameMask; /* which optional path info to get */ + NINT internalFlags; /* Internal only flags for get file name */ + NINT pathFormat; /* path format to get name in */ + NINT nameSpaceID; /* namespace to get name in */ + NINT sizeRetGetName; /* sz of buf to receive info */ struct zGetName_s *ret_getName; /* buffer to put path info into */ } GetNameMsg_s; @@ -312,9 +312,9 @@ typedef struct GetNameMsg_s ((_info)->infoVersion = (_version), \ (_info)->totalBytes = (_size), \ ((_info)->nextByte = \ - ((_version) == zINFO_VERSION_A) ? \ + ((_version) == zINFO_VERSION_A) ? \ offsetof(zInfo_s, variableData) : \ - (((_version) == zINFO_VERSION_B) ? \ + (((_version) == zINFO_VERSION_B) ? \ offsetof(zInfoB_s, variableData) : \ (((_version) == zINFO_VERSION_C) ? \ offsetof(zInfoC_s, variableData) : \ @@ -329,16 +329,16 @@ typedef struct GetNameMsg_s typedef struct GetInfoMsg_s { /* Info for FileType-generic information */ - NINT getInfoMask; /* which optional info to get */ + NINT getInfoMask; /* which optional info to get */ struct zInfo_s *ret_getInfo; /* buffer to put info into */ - NINT nameSpaceID; /* namespace to get name in */ - struct HardLinkBeast_s *hlFile; /* point to a hardlink file that contains the desired name */ + NINT nameSpaceID; /* namespace to get name in */ + struct HardLinkBeast_s *hlFile; /* point to a hardlink file that contains the desired name */ /* cnt nameUniquifier; name uniquifier - for name options */ /* Info for FileType-specific information */ - NINT getTypeInfoMask; /* which type-specific optional info */ - NINT sizeRetGetTypeInfo; /* sz of buf for type-specific info */ - void *ret_getTypeInfo; /* buffer for type-specific info */ + NINT getTypeInfoMask; /* which type-specific optional info */ + NINT sizeRetGetTypeInfo; /* sz of buf for type-specific info */ + void *ret_getTypeInfo; /* buffer for type-specific info */ BOOL snapShotFileInfo; /* set to get info on snapshot file */ } GetInfoMsg_s; @@ -393,7 +393,7 @@ typedef struct GetInfoMsg_s (_infoMsg)->sizeRetGetTypeInfo = (_retTypeInfoSize), \ (_infoMsg)->ret_getTypeInfo = (_retTypeInfoBuf), \ (_infoMsg)->ret_getInfo = 0, \ - (_infoMsg)->snapShotFileInfo = FALSE) + (_infoMsg)->snapShotFileInfo = FALSE) extern STATUS COMN_InfoInitFileName( zInfo_s *info, @@ -420,26 +420,26 @@ typedef struct LinkMsg_s /*--------------------------------------------------------------------------- * This defines the message structure for opening a beast *---------------------------------------------------------------------------*/ -/* Whoever wishes OPEN call to be suspended and tried later due to a +/* Whoever wishes OPEN call to be suspended and tried later due to a * conflicting file lock should use OpenWaiting_s as the first field * in their userData passed by OpenMsg */ typedef struct OpenWaiting_s -{ - DQlink_t link; - NINT state; - UserXaction_s *xaction; /* Xaction that is waiting */ +{ + DQlink_t link; + NINT state; + UserXaction_s *xaction; /* Xaction that is waiting */ - void (*openResumeCallback)( /* If the open request allows open */ - struct OpenWaiting_s **openWaiting); /* to be suspended because of */ - /* conflicting file locks, this is */ - /* the function to call back when */ - /* open is resumed and finished */ + void (*openResumeCallback)( /* If the open request allows open */ + struct OpenWaiting_s **openWaiting); /* to be suspended because of */ + /* conflicting file locks, this is */ + /* the function to call back when */ + /* open is resumed and finished */ }OpenWaiting_s; -#define OPEN_WAITING 0x01 /* flag on when file open is suspended*/ - /* because of conflicting file locks */ +#define OPEN_WAITING 0x01 /* flag on when file open is suspended*/ + /* because of conflicting file locks */ #define OPEN_RESUMING 0x02 /* Suspended open is during resuming */ #define OPEN_CANCELLED 0x04 /* Suspended open is cancelled */ @@ -447,21 +447,21 @@ typedef struct OpenWaiting_s typedef struct OpenMsg_s { NINT requestedRights; /* (create and open) see pssparms.h*/ - void *openParms; /* type specific information */ + void *openParms; /* type specific information */ OpenWaiting_s *openWaiting; /* userData to call back after open*/ /* is resumed */ } OpenMsg_s; -#define COMN_SETUP_OPEN_FILE_MSG(_openMsg, _rights, _opParms) \ - ((_openMsg)->requestedRights = (_rights), \ - (_openMsg)->openParms = (_opParms), \ +#define COMN_SETUP_OPEN_FILE_MSG(_openMsg, _rights, _opParms) \ + ((_openMsg)->requestedRights = (_rights), \ + (_openMsg)->openParms = (_opParms), \ (_openMsg)->openWaiting = NULL) #define COMN_SETUP_RETRY_OPEN_FILE_MSG(_openMsg, _rights, _opParms, _openWaiting) \ - ((_openMsg)->requestedRights = (_rights), \ - (_openMsg)->openParms = (_opParms), \ + ((_openMsg)->requestedRights = (_rights), \ + (_openMsg)->openParms = (_opParms), \ (_openMsg)->openWaiting = (_openWaiting)) @@ -535,7 +535,7 @@ typedef struct RenameMsg_s typedef struct SearchMsg_s { SearchMapIDP_s srchMap; /* holds ID of searchmap*/ - NINT srchSeqNum; /* holds current sequence number, + NINT srchSeqNum; /* holds current sequence number, * receives next sequence number*/ NINT srchOpt; /* search options (see PSSCOMN.H)*/ NINT nameType; /* name type to search for */ @@ -621,7 +621,7 @@ typedef struct SearchMsg_s * because it used the wrong searchMap */ #define SMAPOPT_notReusable 0x00040000 /* if SET, the search map will be * malloc'd when it is created and - * it will be free'd when it is + * it will be free'd when it is * closed. This should only be * used by semantic agents which * guarantee to cleanup all search @@ -638,8 +638,8 @@ typedef struct SearchMsg_s * called. This option is automatically * cleared after each use*/ #define SMAPOPT_doRootdirFlag 0x00200000 /* if SET, then the high nible of the - * MAPID is set to 0xf000 if this is the - * rootdirectory, else it is zero*/ + * MAPID is set to 0xf000 if this is the + * rootdirectory, else it is zero*/ #define SMAPOPT_seqNumber 0x00400000 /* if SET, generate a sequence number*/ #define SMAPOPT_searchAllDirs 0x00800000 /* if SET, this searches an entire * subtree. The default is to return @@ -653,7 +653,7 @@ typedef struct SearchMsg_s * files are returned before returning * their containing directories. */ #define SMAPOPT_usedDOSafterLONG 0x10000000 /* if SET, this search map was used on - * a wildcard search with a long + * a wildcard search with a long * namespace, but the long did not * match, so we tried DOS name space * and it worked. Until this search @@ -664,13 +664,13 @@ typedef struct SearchMsg_s * are located, return the access * denied error */ #define SMAPOPT_atEndOfDir 0x40000000 /* if set, this search map has - * reached the end of the directory - * and returned an error--so subsequent - * searches should fail) - * (internal, only set by NSS */ + * reached the end of the directory + * and returned an error--so subsequent + * searches should fail) + * (internal, only set by NSS */ #define SMAPOPT_inactive 0x80000000 /* if set, this search map is on the - * INACTIVE list (internal, only set - * by NSS)*/ + * INACTIVE list (internal, only set + * by NSS)*/ #define SMAPOPT_MODE(mode) ((mode) & 0x0000ffff) /* used to extract the mode * portion of the searchmap operations*/ @@ -712,7 +712,7 @@ extern NINT NameTypeNameSpaces[zNTYPE_MAX_DEFINED]; /* Internal only */ (((_nType) > zNTYPE_MAX_DEFINED) ? 0 : NameTypeNameSpaces[(_nType)]) /*--------------------------------------------------------------------------- - * Routine for getting given datastream's physical storage info + * Routine for getting given datastream's physical storage info * including that of its compressed stream (if any) * (used to be a macro) *---------------------------------------------------------------------------*/ @@ -722,12 +722,12 @@ extern STATUS COMN_GetStorageInfo( GetStorageInfo_s *getStorageInfo); /*--------------------------------------------------------------------------- - * Get the # blocks currently contributed by given beast to the + * Get the # blocks currently contributed by given beast to the * Volume's purgeableBlk count. *---------------------------------------------------------------------------*/ STATUS COMN_GetPurgeableBlksCnt( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, void *voidBeast, QUAD *purgeableBlks); /* out */ @@ -737,10 +737,10 @@ COMN_GetPurgeableBlksCnt( *---------------------------------------------------------------------------*/ void COMN_saveBeastPurgeableBlksCnt( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamedBeast_s *beast, RootBeast_s *compBeast, - Blknum_t purgeableBlks); + Blknum_t purgeableBlks); /*--------------------------------------------------------------------------- * Macros for getting physical storage info. It differs from COMN_GetStorageInfo diff --git a/include/nwnss/include/comnPublics.h b/include/nwnss/include/comnPublics.h index 3720ac4..188eaea 100644 --- a/include/nwnss/include/comnPublics.h +++ b/include/nwnss/include/comnPublics.h @@ -44,34 +44,34 @@ #ifndef _COMNPUBLICS_H_ #define _COMNPUBLICS_H_ -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) #ifndef _COMNPARAMS_H_ -# include +# include #endif -#include +#include #ifndef _FSMSG_H_ -# include +# include #endif #ifndef _MSGIO_H_ -# include +# include #endif #ifndef _VOLUME_H_ -# include +# include #endif #endif #if zLINUX && !defined(__KERNEL__) -#include +#include #endif #ifdef __cplusplus extern "C" { #endif -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) /* Pre-define struct(s) so Linux compiler doesn't complain */ struct BeastClassRegisterInfo_s; @@ -79,7 +79,7 @@ struct BeastClassRegisterInfo_s; | | SPECIAL NOTE: | - | NO function can be promoted from the common area to public that + | NO function can be promoted from the common area to public that | returns a structure, you must copy the data to a return buffer or | change the function to return an external info structure. All | public function should return STATUS. @@ -105,8 +105,8 @@ extern STATUS COMN_GetMACDataStreamPtr( BOOL *newlyLatched); extern STATUS COMN_ResetNameMsgToSearchPattern( - GeneralMsg_s *genMsg, - NamingMsg_s *nameMsg); + GeneralMsg_s *genMsg, + NamingMsg_s *nameMsg); extern void *COMN_GetPathNameWorkBuffer( GeneralMsg_s *genMsg); @@ -115,7 +115,7 @@ extern void COMN_ReleasePathNameWorkBufferInternal( void *workBuffer); /********** COMN_ReleasePathNameWorkBuffer(void **workBuffer) ***********/ -#define COMN_ReleasePathNameWorkBuffer(_workBuffer) \ +#define COMN_ReleasePathNameWorkBuffer(_workBuffer) \ { \ COMN_ReleasePathNameWorkBufferInternal(*(_workBuffer)); \ *(_workBuffer)=NULL; \ @@ -137,7 +137,7 @@ extern STATUS COMN_CreateWithCallback( GeneralMsg_s *genMsg, NamingMsg_s *nameMsg, CreateMsg_s *createMsg, - FileHandleIDP_s *retFileHandle, + FileHandleIDP_s *retFileHandle, void *userParam, STATUS (*createCallBack)(GeneralMsg_s *genMsg, NamingMsg_s *nameMsg, @@ -233,8 +233,8 @@ extern STATUS COMN_SetEOF(zNSSMsg_s *msg); * FileIO prototypes *---------------------------------------------------------------------------*/ extern PubBuffer_s *COMN_FastReadCache( - MyCache_s *mycache, - Blknum_t fileBlk); + MyCache_s *mycache, + Blknum_t fileBlk); extern STATUS COMN_AsyncRead(zNSSMsg_s *msg); @@ -338,7 +338,7 @@ extern ContextHandleInfo_s *COMN_DoResolveContextHandle( ContextHandleIDP_s *cxhIDP); /* See comments on COMN_DoResolveContextHandle. This releases the use count - * on a context handle. It must be called to release any context handle + * on a context handle. It must be called to release any context handle * pointed to by a non-NULL ContextHandleIDP_s */ extern void COMN_DoReleaseContextHandleIDP( ContextHandleIDP_s *cxhIDP); @@ -532,9 +532,9 @@ STATUS COMN_PoolEvent( NINT state ); extern STATUS COMN_VolumeAlert( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, RootBeast_s *beast, - Volume_s *volume, + Volume_s *volume, struct Buffer_s *buffer, Blknum_t fileBlock, Blknum_t volumeBlock, @@ -571,8 +571,8 @@ extern STATUS COMN_BrowseBeastsInVolume( BOOL onlineOnly, NINT selectionCriteria, NINT numBeastsRequested, - Zid_t *lastZidReturned, /* inout */ - Zid_t *beastZids, /* out */ + Zid_t *lastZidReturned, /* inout */ + Zid_t *beastZids, /* out */ NINT *numBeastsReturned); /* out */ extern STATUS COMN_FixVolumeCompStats( @@ -646,7 +646,7 @@ extern SAHandle_s *COMN_DoResolveSemanticAgentHandle( SAHandleIDP_s *sahIDP); /* See comments on COMN_DoResolveContextHandle. This releases the use count - * on a context handle. It must be called to release any context handle + * on a context handle. It must be called to release any context handle * pointed to by a non-NULL ContextHandleIDP_s */ extern void COMN_DoReleaseSAgentHandleIDP( SAHandleIDP_s *sahIDP); @@ -711,12 +711,12 @@ extern STATUS COMN_GetNameFromBeast( /* Requires pre-latch, returns name only */ NINT nameSpaceID, NINT retNameSize, /* size in unicode characters, not in bytes */ unicode_t *retName, - NINT *retNameLen); /* this may be NULL if you don't want the length */ + NINT *retNameLen); /* this may be NULL if you don't want the length */ extern STATUS COMN_GetFileNameFromZid( GeneralMsg_s *genMsg, Volume_s *volume, - Zid_t zid, + Zid_t zid, NINT nameSpaceID, unicode_t *name, BOOL appendSeperator); @@ -724,14 +724,14 @@ extern STATUS COMN_GetFileNameFromZid( extern STATUS COMN_GetFileNameFromZid2( GeneralMsg_s *genMsg, Volume_s *volume, - Zid_t zid, - NINT nameSpaceID, + Zid_t zid, + NINT nameSpaceID, unicode_t *name, BOOL appendSeperator); extern STATUS COMN_ZidToFileName( VolumeID_t *volume, - Zid_t zid, + Zid_t zid, NINT nameSpaceID, unicode_t *fileName, unicode_t *volName); @@ -739,7 +739,7 @@ extern STATUS COMN_ZidToFileName( extern STATUS EFL_GetNameFromZid( GeneralMsg_s *genMsg, Volume_s *volume, - Zid_t zid, + Zid_t zid, NINT nameSpaceID, unicode_t *name, NINT *objectType); @@ -852,7 +852,7 @@ extern NINT SYSHotFixSize; extern STATUS DisplayFreePartitions(); extern STATUS SalvageSys(); extern STATUS ChangeSysQuota( - utf8_t quota[]); + utf8_t quota[]); extern STATUS ExpandSys( utf8_t passedPartitionID[]); extern STATUS RenameToSys( @@ -874,7 +874,7 @@ extern STATUS COMN_RegisterBeastClass( extern STATUS COMN_RegisterBeastClassList( GeneralMsg_s *genMsg, - struct BeastClassRegisterInfo_s *beastClassList); + struct BeastClassRegisterInfo_s *beastClassList); extern STATUS COMN_UnregisterBeastClass( NINT beastClassID); @@ -958,22 +958,22 @@ extern STATUS COMN_GetBeastFullName( *---------------------------------------------------------------------------*/ extern void *COMN_LookupByZid( GeneralMsg_s *genMsg, - void *volume, - Zid_t zid, + void *volume, + Zid_t zid, NINT latchType, BOOL dontDoVisibilityCheck); extern void *COMN_LookupByZidInBeastHash( GeneralMsg_s *genMsg, - void *volume, - Zid_t zid, + void *volume, + Zid_t zid, NINT latchType, BOOL dontDoVisibilityCheck); extern void *COMN_LookupByZidWhileWildcarding( GeneralMsg_s *genMsg, - void *volume, - Zid_t zid, + void *volume, + Zid_t zid, NINT latchType); extern STATUS COMN_FlushAndTossBeast( @@ -983,13 +983,13 @@ extern STATUS COMN_FlushAndTossBeast( extern void *COMN_LookupByZidInBeastHashAndToss( GeneralMsg_s *genMsg, - void *volume, - Zid_t zid, + void *volume, + Zid_t zid, NINT latchType); extern void *COMN_BeastTossOldNotInUseBeasts( - void *volume, - RootBeast_s *beast); + void *volume, + RootBeast_s *beast); #ifdef DEBUG_BEAST_USE_COUNT /*--------------------------------------------------------------------------- @@ -999,7 +999,7 @@ extern void COMN_ReleaseInternal( void *voidBeast); /********* COMN_Release(void **voidBeast) *************/ -#define COMN_Release(_voidBeast) \ +#define COMN_Release(_voidBeast) \ { \ RootBeast_s *rb = (RootBeast_s *)*(_voidBeast); \ if (rb->rb_whereRelPtr >= RB_NUM_WHERES_TO_KEEP) rb->rb_whereRelPtr = 0; \ @@ -1015,13 +1015,13 @@ extern void COMN_UnlatchAndReleaseInternal( NINT latchType); /********* COMN_UnlatchAndRelease(void **voidBeast, latchType) *************/ -#define COMN_UnlatchAndRelease(_voidBeast,_latchType) \ +#define COMN_UnlatchAndRelease(_voidBeast,_latchType) \ { \ RootBeast_s *rb = (RootBeast_s *)*(_voidBeast); \ if (rb->rb_whereRelPtr >= RB_NUM_WHERES_TO_KEEP) rb->rb_whereRelPtr = 0; \ rb->rb_whereRel[rb->rb_whereRelPtr++] = WHERE; \ rb->rb_whereTotalRel++; \ - COMN_UnlatchAndReleaseInternal(*(_voidBeast),(_latchType)); \ + COMN_UnlatchAndReleaseInternal(*(_voidBeast),(_latchType)); \ *(_voidBeast)=NULL; \ } @@ -1049,7 +1049,7 @@ extern void COMN_ReleaseInternal( void *voidBeast); /********* COMN_Release(void **voidBeast) *************/ -#define COMN_Release(_voidBeast) \ +#define COMN_Release(_voidBeast) \ { \ COMN_ReleaseInternal(*(_voidBeast)); \ *(_voidBeast)=NULL; \ @@ -1061,9 +1061,9 @@ extern void COMN_UnlatchAndReleaseInternal( NINT latchType); /********* COMN_UnlatchAndRelease(void **voidBeast, latchType) *************/ -#define COMN_UnlatchAndRelease(_voidBeast,_latchType) \ +#define COMN_UnlatchAndRelease(_voidBeast,_latchType) \ { \ - COMN_UnlatchAndReleaseInternal(*(_voidBeast),(_latchType)); \ + COMN_UnlatchAndReleaseInternal(*(_voidBeast),(_latchType)); \ *(_voidBeast)=NULL; \ } @@ -1092,7 +1092,7 @@ extern void BST_MarkXLocal(RootBeast_s *beast,Xaction_s *xaction); #define COMN_MARK_BEAST_XLOCAL(_bst,_xaction) \ (BST_MarkXLocal((_bst),(_xaction))) -#define COMN_MARK_BEAST_MESSY(_bst) \ +#define COMN_MARK_BEAST_MESSY(_bst) \ { \ zASSERT(!((_bst)->ROOTvolume->VOLenabledAttributes & zATTR_READONLY)); \ (((_bst)->bstState |= BST_STATE_MESSY)); \ @@ -1101,9 +1101,9 @@ extern void BST_MarkXLocal(RootBeast_s *beast,Xaction_s *xaction); #define COMN_GET_FILE_ATTRIBUTES(nameMsg) \ ((nameMsg)->curFile->FILEattributes) -#define COMN_ENABLE() \ +#define COMN_ENABLE() \ { \ - Enable(); \ + Enable(); \ PERIODIC_YIELD(); \ } @@ -1147,7 +1147,7 @@ extern utf8_t *GetErrorFromNumber( BOOL COMN_ClusterSoftwareIsCheckingPoolStateChanges( void ); -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) /*--------------------------------------------------------------------------- * Management Virtual File Prototypes *---------------------------------------------------------------------------*/ @@ -1205,34 +1205,34 @@ extern STATUS zUpdateVolumeObjectInNDS( unicode_t *volNameNew, UserID_t *ndsObjectId); -extern STATUS COMN_SetupDSIAndLogin(BYTE *LoginObject, BYTE *LoginPassword); -extern void COMN_CleanupCallToDSI(void); +extern STATUS COMN_SetupDSIAndLogin(BYTE *LoginObject, BYTE *LoginPassword); +extern void COMN_CleanupCallToDSI(void); -extern STATUS COMN_AsyncSetupDSIAndUpdateInNDS( +extern STATUS COMN_AsyncSetupDSIAndUpdateInNDS( NINT updateAction, unicode_t *volNameExisting, unicode_t *volNameNew, UserID_t *ndsObjectId, BYTE *ndsLogin, - BYTE *ndsPassword); + BYTE *ndsPassword); #define zCOMN_SetupDSIAndLogin(_p1, _p2, _p3) \ { \ - MPKNSS_LOCK(); \ - _p1 = COMN_SetupDSIAndLogin(_p2, _p3); \ + MPKNSS_LOCK(); \ + _p1 = COMN_SetupDSIAndLogin(_p2, _p3); \ MPKNSS_UNLOCK(); \ } #define zCOMN_CleanupCallToDSI() \ { \ - MPKNSS_LOCK(); \ - COMN_CleanupCallToDSI(); \ + MPKNSS_LOCK(); \ + COMN_CleanupCallToDSI(); \ MPKNSS_UNLOCK(); \ } #define zCOMN_AsyncSetupDSIAndUpdateInNDS(_p1, _p2, _p3, _p4, _p5, _p6, _p7) \ { \ - MPKNSS_LOCK(); \ + MPKNSS_LOCK(); \ _p1 = COMN_AsyncSetupDSIAndUpdateInNDS(_p2, _p3, _p4, _p5, _p6, _p7); \ MPKNSS_UNLOCK(); \ } @@ -1259,11 +1259,11 @@ extern NINT COMN_IncludeType; /* BitMask of which type of volumes/pools #define COMN_IT_DEFAULT (COMN_IT_LOCAL | COMN_IT_SHARED) #define COMN_CmdSwitchIncludePresent() (COMN_IncludeType & COMN_IT_PRESENT) -#define COMN_CmdSwitchIncludeLocal() (COMN_IncludeType & COMN_IT_LOCAL) +#define COMN_CmdSwitchIncludeLocal() (COMN_IncludeType & COMN_IT_LOCAL) #define COMN_CmdSwitchIncludeShared() (COMN_IncludeType & COMN_IT_SHARED) -#define COMN_CmdSwitchIncludeGet() (COMN_IncludeType) +#define COMN_CmdSwitchIncludeGet() (COMN_IncludeType) -extern NINT COMN_OverrideType; /* BitMask of overrides that a user can +extern NINT COMN_OverrideType; /* BitMask of overrides that a user can * specify that modifies how a command works. * Legal bits COMN_OT_SHARED, COMN_OT_CORRUPT * and COMN_OT_QUESTIONS. This diff --git a/include/nwnss/include/comnTask.h b/include/nwnss/include/comnTask.h index 3f11c6c..dea8c81 100644 --- a/include/nwnss/include/comnTask.h +++ b/include/nwnss/include/comnTask.h @@ -24,11 +24,11 @@ | |--------------------------------------------------------------------------- | - | $Author: taysom $ - | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ | | $RCSfile$ - | $Revision: 465 $ + | $Revision: 465 $ | |--------------------------------------------------------------------------- | This module is used to: @@ -156,7 +156,7 @@ extern DQhead_t HomeTimeOrderList; extern Task_s *lookupTask(Master_s *master, NINT taskID); extern UserXaction_s *lookupXaction(Xid_t xid); extern UserXaction_s *lookupActiveXaction(Xid_t xid); -extern UserXaction_s *lookupDefaultXaction (Master_s *master, NINT taskID); +extern UserXaction_s *lookupDefaultXaction (Master_s *master, NINT taskID); extern Task_s *allocTask(Master_s *master, NINT taskID); extern UserXaction_s *allocUserXaction(Task_s *task, UserXaction_s *parentXaction); extern HomeXaction_s *allocHomeXaction(UserXaction_s *uxaction); @@ -183,12 +183,12 @@ extern void COMN_CleanupMaster(Master_s *master); extern STATUS COMN_BeginTask ( GeneralMsg_s *genMsg, - Master_s *master, + Master_s *master, NINT *taskID); extern STATUS COMN_EndTask ( GeneralMsg_s *genMsg, - Master_s *master, + Master_s *master, NINT taskID); #endif diff --git a/include/nwnss/include/comnVariableData.h b/include/nwnss/include/comnVariableData.h index c3fe67a..1311b8e 100644 --- a/include/nwnss/include/comnVariableData.h +++ b/include/nwnss/include/comnVariableData.h @@ -45,7 +45,7 @@ #define _COMNVARIABLEDATA_H_ #ifndef _COMNPARAMS_H_ -# include +# include #endif #ifdef __cplusplus @@ -102,7 +102,7 @@ typedef STATUS (*RVD_SetXMLInfoFunc_t)( RootBeast_s *beast, NINT bufLen, utf8_t *buf, - Xaction_s *xaction, + Xaction_s *xaction, BOOL doChange); /**************************************************************************** @@ -135,9 +135,9 @@ extern STATUS COMN_SetRootVariableDataXMLInfo( RootBeast_s *beast, NINT bufLen, utf8_t *buf, - Xaction_s *xaction, + Xaction_s *xaction, BOOL doChange); - + /**************************************************************************** * These are functions that may be called by the LSS root beast pack routines. diff --git a/include/nwnss/include/comnZAS.h b/include/nwnss/include/comnZAS.h index 4b054ed..f248aa8 100644 --- a/include/nwnss/include/comnZAS.h +++ b/include/nwnss/include/comnZAS.h @@ -44,7 +44,7 @@ #define _COMNZAS_H_ #ifndef _OMNI_H_ -#include +#include #endif //#ifndef _COMNAUTHORIZE_H_ @@ -78,7 +78,7 @@ extern "C" { typedef struct ACLEntry_s { /* an access control list entry */ UserID_t trusteeID; /* an authenticated ID */ - WORD rights; /* the rights mask */ + WORD rights; /* the rights mask */ WORD attributes; /* the mode and status bits */ } NSS_MEDIA_STRUCTURE(ACLEntry_s,attributes) ACLEntry_s; @@ -90,7 +90,7 @@ typedef struct ACLEntry_s typedef struct VisEntry_s { /* a visiblity list entry */ UserID_t trusteeID; /* an authenticated ID */ - LONG count; /* count of times used below this entry */ + LONG count; /* count of times used below this entry */ } NSS_MEDIA_STRUCTURE(VisEntry_s,count) VisEntry_s; /* @@ -102,14 +102,14 @@ typedef struct VisEntry_s typedef struct V1_ACLEntry_s { /* an access control list entry (beast version 1)*/ LONG trusteeID; /* an authenticated ID */ - WORD rights; /* the rights mask */ + WORD rights; /* the rights mask */ WORD attributes; /* the mode and status bits */ } NSS_MEDIA_STRUCTURE(V1_ACLEntry_s,attributes) V1_ACLEntry_s; typedef struct V1_VisEntry_s { /* a visiblity list entry (beast version 1)*/ LONG trusteeID; /* an authenticated ID */ - LONG count; /* count of times used below this entry */ + LONG count; /* count of times used below this entry */ } NSS_MEDIA_STRUCTURE(V1_VisEntry_s,count) V1_VisEntry_s; diff --git a/include/nwnss/include/control.h b/include/nwnss/include/control.h index b9c99b1..b8f4130 100644 --- a/include/nwnss/include/control.h +++ b/include/nwnss/include/control.h @@ -45,17 +45,17 @@ #define _CONTROL_H_ #ifndef _QUE_H_ -# include +# include #endif #if HISTOGRAM IS_ENABLED #ifndef _HISTOGRAM_H_ -# include +# include #endif #endif #ifndef _ALARM_H_ -# include +# include #endif #ifdef __cplusplus @@ -133,7 +133,7 @@ typedef struct ControlStore_s * if it gets very high, the next block * it permanantly added. */ - + #if HISTOGRAM IS_ENABLED Histogram_s histogram; #endif diff --git a/include/nwnss/include/dbgView.h b/include/nwnss/include/dbgView.h new file mode 100644 index 0000000..9be67b1 --- /dev/null +++ b/include/nwnss/include/dbgView.h @@ -0,0 +1,112 @@ +/**************************************************************************** + | + | (C) Copyright 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | View NSS items from the assembly debugger. + +-------------------------------------------------------------------------*/ + + +#include "dfi.h" +#include "sdBasic.h" + +typedef struct CommandViewInfo_s { + /*** Caller must fill in BEFORE register call ***/ + char *CVI_OwnerName; /* E.G. 'NSS' or 'ZLSS' or 'DPSFAT' */ + SDM_Table_s *CVI_Table; /* Pointer to table of 'subcommands' that owner supports. */ + /*** Internal items that register will fill in ***/ + unsigned int CVI_Index; +} CommandViewInfo_s; + + + +extern DFI_CallerOptions_s *NSSCo; + +STATUS DBG_CV_Register( + CommandViewInfo_s *cvi ); /* Pointer must be valid UNTIL after unregister is called */ +STATUS DBG_CV_Unregister( + CommandViewInfo_s *cvi ); /* Pointer must be valid UNTIL after unregister is called */ + +STATUS DBG_CV_DisplayHelp( + struct ScreenStruct *screen ); + +STATUS DBG_CV_DisplayItem( + struct ScreenStruct *screen, + CommandViewInfo_s *cvi, + SDM_Table_s *table, + LONG *linesUsed ); + +LONG DBG_CheckForPause( + struct ScreenStruct *screen, + LONG *linesUsed, + LONG linesNeeded); + +STATUS DBG_CommandView( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame ); + +STATUS DBG_CommandViewCommand( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame, + BOOL onAttempt ); + +STATUS DBG_CommandViewHelp( + struct ScreenStruct *screen, + char **commandL ); + +STATUS DBG_CommandViewMemory( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame ); + +BOOL DBG_CommandViewMemoryParse( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame, + char *structureName, + unsigned int structureNameSize, /* Must be at least 3 */ + ADDR *address ); + +STATUS DBG_CommandViewAlpha( + struct ScreenStruct *screen, + char **commandL ); + +STATUS DBG_CommandViewView( + struct ScreenStruct *screen, + char **commandL ); + +STATUS DBG_CommandViewSize( + struct ScreenStruct *screen, + char **commandL ); + diff --git a/include/nwnss/include/dfi.h b/include/nwnss/include/dfi.h new file mode 100644 index 0000000..537a6cd --- /dev/null +++ b/include/nwnss/include/dfi.h @@ -0,0 +1,377 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | DFI - Generic code that understands how to display information + / in XML format given the information structure definition + / (as described by a DFI_DataFormatInformation_s)/ + | + |--------------------------------------------------------------------------- + | + | $Author: gpachner $ + | $Date: 2007-06-15 04:11:12 +0530 (Fri, 15 Jun 2007) $ + | + | $RCSfile$ + | $Revision: 2059 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | + +-------------------------------------------------------------------------*/ +#ifndef _DFI_H_ +#define _DFI_H_ + +//#ifndef _NWGREENRIVER_ +//#define _NWGREENRIVER_ /* This define helps asyncio.h */ +//#endif + +#ifdef NTLIB +#include +#endif + +#include "zOmni.h" +#include "omni.h" +#include "snp.h" + +/* Pre-declare the following structure(s) */ +struct DFI_CallerOptions_s; +struct DFI_DataFormatInformation_s; + +typedef signed int SIZEOF; /* Typedef used to ensure routines are + * returning a size and not an error. + */ + +#define DFI_OK 0 +#define DFI_ERROR_CALLER_OPTION_STRUCTURE_NULL 19000 +#define DFI_ERROR_CALLER_OPTION_STRUCTURE_SIGNATURE_BAD 19001 + + + /* Generic ErrorTracking structure and macros */ +typedef struct ErrorTracking_s { + STATUS ET_Errno; + char *ET_ErrnoSetter; +} ErrorTracking_s; + +#define ET_SetErrno( _et, _error ) ( ((_et)->ET_Errno = _error), ((_et)->ET_ErrnoSetter = (WHERE)) ) +#define ET_SetErrnoAndWhere( _et, _error, _where ) ( ((_et)->ET_Errno = _error), ((_et)->ET_ErrnoSetter = (_where)) ) +#define ET_ClearErrno(_et) ( ((_et)->ET_Errno = zOK), ((_et)->ET_ErrnoSetter = (WHERE)) ) +#define ET_GetErrno(_et) ((_et)->ET_Errno) +#define ET_GetErrnoSetter(_et) ((_et)->ET_ErrnoSetter) + + + + /* Macros to set errno in ErrorTracking item in a DFI */ +#define DFI_SetErrno( _dfi, _error ) (ET_SetErrno( &((_dfi)->DCO_Errno), _error )) +#define DFI_SetErrnoAndWhere( _dfi, _error, _where ) (ET_SetErrno( &((_dfi)->DCO_Errno), _error )) +#define DFI_ClearErrno(_dfi) (ET_ClearErrno( &((_dfi)->DCO_Errno) )) +#define DFI_GetErrno(_dfi) (ET_GetErrno( &((_dfi)->DCO_Errno) )) +#define DFI_GetErrnoSetter(_dfi) (ET_GetErrnoSetter( &((_dfi)->DCO_Errno) )) + + + +/* Pre-declare circular type dependencies that exist below */ +typedef struct DFI_CallerOptions_s DFI_CallerOptions_s; +typedef struct DFI_DataFormatInformation_s DFI_DataFormatInformation_s; + +typedef STATUS (*DFI_RoutineStructure_t)( DFI_CallerOptions_s *co, DFI_DataFormatInformation_s *dfi, BYTE *buffer, NINT offset, NINT index ); + +struct DFI_DataFormatInformation_s { + NINT DFI_Type; // See DFI_TYPE_xxx below +// STATUS (*DFI_Routine); // Handles abnormal types + DFI_RoutineStructure_t DFI_Routine; + NINT DFI_Offset; // Not going to work on variable length structures + char *DFI_Name; // Name to display + NINT DFI_ArrayElements; // Non-zero indicates an ARRAY of DFI_Type types + char *DFI_Name2; // If DFI_TYPE_STRUCT_PTR or DFI_TYPE_STRUCT + // then the name of the structure. + NINT DFI_SizeOf; // If DFI_TYPE_STRUCT then the sizeof the structure + struct DFI_DataFormatInformation_s *DFI_List; /* Address of array of DFI's that ends must + * end with a DFI_TYPE_END entry. Used only by + * the 'standard' handler. + */ +}; + +/* This defines NATIVE types that DFI supports. We support numerous + * NATIVE types so that UIs may take advantage of a type. E.G. + * a UI may wish to VALID DFI_TYPE_VolumeID_t items or do lookups + * on DFI_TYPE_Zid_t. + */ +#define DFI_TYPE_END 0x0000 +#define DFI_TYPE_LONG 0x0001 +#define DFI_TYPE_SLONG DFI_TYPE_LONG // FixFixFix really do a signed then AT LEAST a TYPE name difference +#define DFI_TYPE_Blkcnt_t DFI_TYPE_LONG // FixFixFix really own type????? +#define DFI_TYPE_WORD 0x0002 +#define DFI_TYPE_SWORD DFI_TYPE_WORD // FixFixFix really do a signed then AT LEAST a TYPE name difference +#define DFI_TYPE_SQUAD 0x0003 +#define DFI_TYPE_QUAD 0x0004 +#define DFI_TYPE_Time_t 0x0005 +#define DFI_TYPE_unicode_t 0x0006 +#define DFI_TYPE_GUID_t 0x0007 +#define DFI_TYPE_VolumeID_t 0x0008 +#define DFI_TYPE_Lsn_t 0x0009 +#define DFI_TYPE_Blknum_t 0x000a +#define DFI_TYPE_QBlknum_t 0x000b /* A QUAD/SQUAD Blknum_t. Used to indicate a Block Number */ +#define DFI_TYPE_unicode_t_STR 0x000c /* An array that MUST have a NULL terminate unicode string. + * This is different that a Unicode_t * in that we known + * the buffer size (i.e. the number of elements in the array). + */ +#define DFI_TYPE_BYTE 0x000d +#define DFI_TYPE_Zid_t 0x000e +#define DFI_TYPE_unicode_t_ARRAY 0x000f /* Array of unicode_t */ +#define DFI_TYPE_UserID_t 0x0010 +#define DFI_TYPE_char_STR 0x0011 /* An array that MUST have a NULL terminate string. + * This is different that a char * in that we known + * the buffer size (i.e. the number of elements in the array). + */ +#define DFI_TYPE_EFLEpochMask_t DFI_TYPE_LONG + +#define DFI_TYPE_STRUCT_PTR 0x0112 /* Pointer to a well known structure */ +#define DFI_TYPE_BYTE_PTR DFI_TYPE_STRUCT_PTR +#define DFI_TYPE_NINT_PTR DFI_TYPE_STRUCT_PTR +#define DFI_TYPE_PTR_PTR DFI_TYPE_STRUCT_PTR /* Pointer to a pointer */ +#define DFI_TYPE_unicode_t_PTR DFI_TYPE_STRUCT_PTR +#define DFI_TYPE_char_PTR DFI_TYPE_STRUCT_PTR +#define DFI_TYPE_UserID_t_PTR DFI_TYPE_STRUCT_PTR +#define DFI_TYPE_FUNC_PTR DFI_TYPE_STRUCT_PTR /* FixFixFix - this really shold indicate a FUNCTION pointer */ +#define DFI_TYPE_STRUCT 0x0113 /* Well known structure */ + +#define DFI_TYPE_UNION_HEADER 0x0214 +#define DFI_TYPE_UNION_TAIL 0x0215 + + +#define DFI_TYPE_Key_t DFI_TYPE_SQUAD // Could have its own type +#ifdef __LP64__ +#define DFI_TYPE_DOSTime_t DFI_TYPE_QUAD // Should be made into its own type +#define DFI_TYPE_ADDR DFI_TYPE_QUAD +#else +#define DFI_TYPE_DOSTime_t DFI_TYPE_LONG // Should be made into its own type +#define DFI_TYPE_ADDR DFI_TYPE_LONG +#endif +#define DFI_TYPE_BOOL DFI_TYPE_NINT // Should be made into its own type +#define DFI_TYPE_Seq_t DFI_TYPE_SLONG // Could be made into its own type + +#if BITS_PER_NINT == 32 +#define DFI_TYPE_NINT DFI_TYPE_LONG +#define DFI_TYPE_SNINT DFI_TYPE_SLONG +#endif + +#if BITS_PER_NINT == 64 +#define DFI_TYPE_NINT DFI_TYPE_QUAD +#define DFI_TYPE_SNINT DFI_TYPE_SQUAD +#endif + +#define DFI_TYPE_STATUS DFI_TYPE_LONG + + +/* + * Used to track options that caller desires. + */ +struct DFI_CallerOptions_s { + NINT DCO_Signature1; +#define DCO_SIGNATURE1 0x45497579 + NINT DCO_OutputType; +#define DCO_OUTPUT_TYPE_XML 0x0001 /* Output will be in XML format */ +#define DCO_OUTPUT_TYPE_ASCII 0x0002 /* Standard output */ +#define DCO_OUTPUT_TYPE_XML_SHORT 0x0003 /* Output will be in LONG XML format. Attributes names are readable/meaningfull. */ + NINT DCO_Details; +#define DCO_DETAILS_NAME 0x0001 /* Output names of elements. */ +#define DCO_DETAILS_VALUE 0x0002 /* Output value of elements. */ +#define DCO_DETAILS_TYPE 0x0004 /* Output type of elements. */ +#define DCO_DETAILS_ADDRESS 0x0008 /* Output address information of elements. */ +#define DCO_DETAILS_SIZE 0x0010 /* Output size information of elements. */ +#define DCO_DETAILS_INDEX 0x0020 /* Output index information of elements. */ + NINT DCO_ArraySize; /* Non-zero value will cause limit to the number of + * array elements displayed. + */ + NINT DCO_ExpandLevel; /* Number of levels to expand. */ + void *DCO_LocalAddress; /* Address data is being processed from. */ + void *DCO_SourceAddress; /* Address that memory is really from. In case of + * VDB this is the memory we read in the coredump. + * For others it can be the same as the local + * buffer address or 0. Block reads would use + * zero. + */ + SNP_PrintBuffer_s *DCO_SNPOutput; /* Normal place to output. */ + SNP_PrintBuffer_s *DCO_SNPErrors; /* Place to output error messages. */ + ErrorTracking_s DCO_Errno; + Zid_t DCO_Zid; /* Non-zero if looking for a ZID. */ + NINT DCO_AuthType; /* The auth model type */ +#define DCO_AUTHTYPE_ZAS 0 +#define DCO_AUTHTYPE_UNIX 1 + /* DCO_XML... Points to the strings that caller wishes to use in the + * XML file. Added Sep 2003 so I could have a 'short' version of each name + * as some zedremote /next of the bt leaf produce multiple GB files. + */ + /*** Tags ***/ + char *DCO_XMLTagBasic; + char *DCO_XMLTagStructure; + /*** Attributes ***/ + char *DCO_XMLAttributeAddress; + char *DCO_XMLAttributeArrayElements; + char *DCO_XMLAttributeDate; + char *DCO_XMLAttributeIndex; + char *DCO_XMLAttributeName; + char *DCO_XMLAttributeSize; + char *DCO_XMLAttributeType; + char *DCO_XMLAttributeTypeCount; + char *DCO_XMLAttributeValue; + char *DCO_XMLAttributeValueCount; + NINT DCO_Signature2; +#define DCO_SIGNATURE2 0x444c4c73 +}; + + +#define DCO_DETAILS_FULL (DCO_DETAILS_NAME|DCO_DETAILS_VALUE|DCO_DETAILS_INDEX|DCO_DETAILS_TYPE|DCO_DETAILS_ADDRESS|DCO_DETAILS_SIZE) +#define DCO_DETAILS_DETAIL (DCO_DETAILS_NAME|DCO_DETAILS_VALUE|DCO_DETAILS_INDEX|DCO_DETAILS_TYPE) +#define DCO_DETAILS_BRIEF (DCO_DETAILS_NAME|DCO_DETAILS_VALUE|DCO_DETAILS_INDEX) +#define DCO_DETAILS_NONE (0) + + +#define DFI_NAME_NONE "NoNameSpecified" +#define DFI_VARIABLE_SIZE_INKNOWN 0 + + +STATUS DFI_DisplayStructure( // Official API routine + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer ); + +STATUS DFI_Close( // Official API routine + DFI_CallerOptions_s *co ); + +STATUS DFI_SNPToStatus( + DFI_CallerOptions_s *co, /* Place to stick the error */ + SNP_PrintBuffer_s *pb, /* Print object the rc is from */ + int rc, + char *where ); + +DFI_CallerOptions_s *DFI_Open( // Official API routine + SNP_PrintBuffer_s *pbOutput, + SNP_PrintBuffer_s *pbErrors, + int outputType, + int details, + int arraySize, + int expandLevel, + void *localAddress, + void *sourceAddress ); + +STATUS DFI_Display( // Official API routine + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset ); + +int DFI_Display_Type_Blknum_t_ARRAY_With_Count_Blkcnt_t( + DFI_CallerOptions_s *co, + char *tag, + int index, + Blknum_t *block, + Blkcnt_t *count ); + + + +char *DFI_UTCTime2Str( +#ifdef NTLIB +// time_t cTime, + LONG cTime, +#else + Time_t cTime, +#endif + char *buffer, + NINT bufLen ); + +SIZEOF DFI_DisplayElement( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF DFI_DisplayElementXML( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +STATUS DFI_DisplayElementASCII( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + + +STATUS DFI_COValidate( + DFI_CallerOptions_s *co ); + +SIZEOF DFI_DisplayXML( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset ); + + +STATUS DFI_Display_Header_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + char *typeName, + unsigned int arrayElements, + unsigned int arraySize, + void *address ); + +STATUS DFI_Display_Tail_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + char *typeName ); + + +STATUS DFI_Display_Header_Structure( + DFI_CallerOptions_s *co, + char *tag, + char *structureName, + unsigned int index, + unsigned int arrayElements, + unsigned int structureSize, /* As defined by sizeof */ + void *address ); + +STATUS DFI_Display_Tail_Structure( + DFI_CallerOptions_s *co, + char *structureName, + unsigned int structureSize, /* As defined by sizeof */ + void *address ); + +STATUS DFI_Display_Tail_Union( + DFI_CallerOptions_s *co, + char *unionName, + unsigned int unionSize, /* As defined by sizeof */ + void *address ); + +STATUS DFI_Display_Header_Union( + DFI_CallerOptions_s *co, + char *name, + char *unionName, + unsigned int index, + unsigned int arrayElements, + unsigned int unionSize, /* As defined by sizeof */ + void *address ); + +#endif diff --git a/include/nwnss/include/dfsLib.h b/include/nwnss/include/dfsLib.h new file mode 100644 index 0000000..57db8c7 --- /dev/null +++ b/include/nwnss/include/dfsLib.h @@ -0,0 +1,99 @@ +/**************************************************************************** + | + | (C) Copyright 1999, 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS)/Distributed File Services (DFS) Module + | + |--------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2005-04-13 22:08:08 +0530 (Wed, 13 Apr 2005) $ + | + | $RCSfile$ + | $Revision: 927 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | DFS Common Library declarations + +-------------------------------------------------------------------------*/ + +#ifndef __DFSLIB_H__ +#define __DFSLIB_H__ + +/* Dependencies */ +#ifndef _ZOMNI_H_ +# include +#endif + + +/* Function like macros */ + +/* Macro to yield the CPU at a fixed frequency based on a loop counter */ +#define DFS_YIELD_AT_MODn_ITERATIONS(_yieldcounter, _yieldperiod) \ + { \ + if (((_yieldcounter) % (_yieldperiod)) == ((_yieldperiod) - 1)) \ + { \ + kYieldThread(); \ + } \ + } + +/* Macros to set and reset the current thread name */ +#ifndef __linux__ +#if zNETWARE && NSS_DEBUG IS_ENABLED +#define DFS_SAVE_THREAD_NAME() \ + BOOL threadNameSaved; \ + BYTE oldThreadName[MAX_NAME_LENGTH + 1]; \ + threadNameSaved = (kGetThreadName(kCurrentThread(), oldThreadName, MAX_NAME_LENGTH + 1) == kSUCCESS); + +#define DFS_SET_THREAD_NAME(NewName) \ + kSetThreadName(kCurrentThread(), NewName); + +#define DFS_RESTORE_THREAD_NAME() \ + if (threadNameSaved) \ + { \ + (void)kSetThreadName(kCurrentThread(), oldThreadName); \ + } +#else +#define DFS_SAVE_THREAD_NAME() + +#define DFS_SET_THREAD_NAME(NewName) + +#define DFS_RESTORE_THREAD_NAME() +#endif +#else +#define DFS_SAVE_THREAD_NAME() + +#define DFS_SET_THREAD_NAME(NewName) + +#define DFS_RESTORE_THREAD_NAME() +#endif + + + +/* Prototypes */ +void DFS_DelayThread(LONG DelayTime); /* Delay a thread by a specified time */ +STATUS DFS_MakeDNTypeless(unicode_t *DSName); /* Strip type identifiers from a DS distinguishes name */ +NINT DFS_ResolveName(NINT context, NINT flags, const void *dn); /* Resolve an NDS name & authenticate the connection */ +BOOL DFS_ThreadNameIs(BYTE *NewName, BYTE *OldName); /* Rename a thread and store the original name in caller supplied data */ +STATUS DFS_YieldAtTimeout(QUAD *LastYieldedAt, LONG Timeout); /* Yield a thread if it has been running for a specified time */ + + +#endif diff --git a/include/nwnss/include/dfsLib.imp b/include/nwnss/include/dfsLib.imp new file mode 100644 index 0000000..b061c12 --- /dev/null +++ b/include/nwnss/include/dfsLib.imp @@ -0,0 +1,5 @@ +DFS_DelayThread +DFS_MakeDNTypeless +DFS_ResolveName +DFS_ThreadNameIs +DFS_YieldAtTimeout \ No newline at end of file diff --git a/include/nwnss/include/dfsnds.h b/include/nwnss/include/dfsnds.h new file mode 100644 index 0000000..7051783 --- /dev/null +++ b/include/nwnss/include/dfsnds.h @@ -0,0 +1,91 @@ +/*************************************************************************** + | + | (C) Copyright 2001, 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Distributed File Services (DFS) module + | + |-------------------------------------------------------------------------- + | + | $Author: nbalachandran $ + | $Date: 2007-09-22 14:52:05 +0530 (Sat, 22 Sep 2007) $ + | + | $RCSfile$ + | $Revision: 2221 $ + | + |-------------------------------------------------------------------------- + | This module is used to: + | Define NDS Class and Attribute names used by DFS + | All names are UNICODE strings. + | Standard NDS names are prfixed with NDS_ + | DFS schema extensions are prefixed with DFS_ + +------------------------------------------------------------------------*/ + +#ifndef _DFSNDS_H_ +#define _DFSNDS_H_ + +/* Standard NDS names are defined in another .h file, but as regular */ +/* text strings */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* A little preprocessor magic to convert a regular text string */ +/* to a unicode string */ +#define PREFIX_STRING(text) L ## text +#define UNICODE_STRING(text) PREFIX_STRING(text) + +/* NDS attribute names */ +#define NDS_ATTR_RESOURCE_NAME UNICODE_STRING(A_HOST_RESOURCE_NAME) +#define NDS_ATTR_HOST_SERVER UNICODE_STRING(A_HOST_SERVER) +#define NDS_ATTR_OBJECT_CLASS UNICODE_STRING(A_OBJECT_CLASS) +#define NDS_ATTR_DESCRIPTION UNICODE_STRING(A_DESCRIPTION) +#define NDS_ATTR_ACL UNICODE_STRING(A_ACL) + +/* NDS Rights special "attribute name" strings */ +#define NDS_RIGHTS_ENTRY_RIGHTS UNICODE_STRING("[Entry Rights]") +#define NDS_RIGHTS_ALL_ATTRS_RIGHTS UNICODE_STRING("[All Attributes Rights]") + +/* DFS attribute names */ +#define DFS_ATTR_DFS_GUID UNICODE_STRING("DFS-Volume-Guid") +#define DFS_ATTR_VLDB_HOSTS UNICODE_STRING("DFS-VLDB-Hosts") +#define DFS_ATTR_VLDB_BACKEND UNICODE_STRING("VLDB-BackEnd-ID") +#define DFS_NET_ADDRESS_ATTR_NAME UNICODE_STRING("Network Address") + +/* NDS back-end VLDB-specific attributes: */ +#define DFS_ATTR_SERVER_LIST UNICODE_STRING("VLDB-BackEnd-NDS-ServerList") + +/* NDS object class names */ +#define NDS_CLASS_VOLUME_OBJECT UNICODE_STRING(C_VOLUME) +#define NDS_CLASS_SERVER_OBJECT UNICODE_STRING(C_NCP_SERVER) +#define NDS_CLASS_OU_OBJECT UNICODE_STRING(C_ORGANIZATIONAL_UNIT) +#define NDS_CLASS_ORG_OBJECT UNICODE_STRING(C_ORGANIZATION) + +/* DFS (NDS back-end VLDB) object class names */ +#define DFS_CLASS_CONTAINER_OBJECT UNICODE_STRING("VLDB-BackEnd-NDS-Container") +#define DFS_CLASS_RECORD_OBJECT UNICODE_STRING("VLDB-BackEnd-NDS-Record") + +#ifdef __cplusplus +} +#endif + +#endif /* _DFSNDS_H_ */ diff --git a/include/nwnss/include/eDir.h b/include/nwnss/include/eDir.h index 02fdb37..c5e1da3 100644 --- a/include/nwnss/include/eDir.h +++ b/include/nwnss/include/eDir.h @@ -48,7 +48,7 @@ extern "C" { #endif #ifndef _ZOMNI_H_ -#include +#include #endif STATUS LB_GetDSGUID( diff --git a/include/nwnss/include/eventSys.h b/include/nwnss/include/eventSys.h index 3630c47..94fb824 100644 --- a/include/nwnss/include/eventSys.h +++ b/include/nwnss/include/eventSys.h @@ -44,15 +44,15 @@ #define _EVENTSYS_H_ #ifndef _REGISTER_H_ -# include +# include #endif #ifndef _ZEVENT_H_ -# include +# include #endif -#include -#include +#include +#include /* Pre-define struct(s) so Linux compiler doesn't complain */ struct NamingMsg_s; @@ -65,14 +65,14 @@ typedef LONG (*EventWarnProc)(void (*OutputRoutine)(void *controlString,...), LONG parameter,LONG userParameter); typedef void (*EventReportProc)(LONG parameter,LONG userParameter); -#ifdef __linux__ +#ifdef __linux__ #define ZOS_EventNotificationReg(_rtn,eventType,warnProc,reportProc) \ { \ MPKNSS_UNLOCK(); \ _rtn = RegisterForEventNotification( \ NULL, \ (eventType), \ - EVENT_PRIORITY_OS, \ + EVENT_PRIORITY_OS, \ (EventWarnProc)(warnProc), \ (EventReportProc)(reportProc), \ 0); \ @@ -85,7 +85,7 @@ typedef void (*EventReportProc)(LONG parameter,LONG userParameter); _rtn = RegisterForEventNotification( \ COMN_Resource.eventRTag, \ (eventType), \ - EVENT_PRIORITY_OS, \ + EVENT_PRIORITY_OS, \ (EventWarnProc)(warnProc), \ (EventReportProc)(reportProc), \ 0); \ @@ -111,7 +111,7 @@ typedef void (*EventReportProc)(LONG parameter,LONG userParameter); * registered for this event, and if we generate this event we have * to always create the DirectoryEntry. The only person using this that * we have found so far is NFS.NAM (and NSS does not use this module and - * wants NFS.NAM to ignore the event for NSS volumes). Thus, we have + * wants NFS.NAM to ignore the event for NSS volumes). Thus, we have * decided NOT to generate this event until we find someone that uses * it and needs it. * @@ -135,14 +135,14 @@ extern STATUS NWSA_EvRep_TrusteeChange( extern STATUS NWSA_EvRep_CloseFile( struct FileHandle_s *fileHandle); -extern LONG COMN_SendNSSEvent( +extern LONG COMN_SendNSSEvent( NINT event, void *data, int dataLength, LONG *denyCode); /* the return code if Operation is Denied */ /*------------------------------------------------------------------------- - * NSS Event system defines and structures + * NSS Event system defines and structures *-------------------------------------------------------------------------*/ #define EVENT_Delete_Enter 0 /* "NSS.Delete.Enter" */ @@ -171,30 +171,30 @@ extern LONG COMN_SendNSSEvent( #define EVENT_Link_Exit 23 /* "NSS.Link.Exit" */ #define EVENT_ChangePoolState_Enter 24 /* "NSS.ChangePoolState.Enter" */ #define EVENT_ChangePoolState_Exit 25 /* "NSS.ChangePoolState.Exit" */ -#define EVENT_PoolCreate_Enter 26 /* "NSS.PoolCreate.Enter" */ -#define EVENT_PoolCreate_Exit 27 /* "NSS.PoolCreate.Exit" */ -#define EVENT_PoolDelete_Enter 28 /* "NSS.PoolDelete.Enter" */ -#define EVENT_PoolDelete_Exit 29 /* "NSS.PoolDelete.Exit" */ -#define EVENT_PoolResize_Enter 30 /* "NSS.PoolResize.Enter" */ -#define EVENT_PoolResize_Exit 31 /* "NSS.PoolResize.Exit" */ -#define EVENT_PoolRename_Enter 32 /* "NSS.PoolRename.Enter" */ -#define EVENT_PoolRename_Exit 33 /* "NSS.PoolRename.Exit" */ +#define EVENT_PoolCreate_Enter 26 /* "NSS.PoolCreate.Enter" */ +#define EVENT_PoolCreate_Exit 27 /* "NSS.PoolCreate.Exit" */ +#define EVENT_PoolDelete_Enter 28 /* "NSS.PoolDelete.Enter" */ +#define EVENT_PoolDelete_Exit 29 /* "NSS.PoolDelete.Exit" */ +#define EVENT_PoolResize_Enter 30 /* "NSS.PoolResize.Enter" */ +#define EVENT_PoolResize_Exit 31 /* "NSS.PoolResize.Exit" */ +#define EVENT_PoolRename_Enter 32 /* "NSS.PoolRename.Enter" */ +#define EVENT_PoolRename_Exit 33 /* "NSS.PoolRename.Exit" */ #define EVENT_ChangePoolShared_Enter 34 /* "NSS.ChangePoolShared.Enter" */ -#define EVENT_ChangePoolShared_Exit 35 /* "NSS.ChangePoolShared.Exit" */ -#define EVENT_LVolCreate_Enter 36 /* "NSS.LVolumeCreate.Enter" */ -#define EVENT_LVolCreate_Exit 37 /* "NSS.LVolumeCreate.Exit" */ -#define EVENT_LVolDelete_Enter 38 /* "NSS.LVolumeDelete.Enter" */ -#define EVENT_LVolDelete_Exit 39 /* "NSS.LVolumeDelete.Exit" */ -#define EVENT_LVolRename_Enter 40 /* "NSS.LVolumeRename.Enter" */ -#define EVENT_LVolRename_Exit 41 /* "NSS.LVolumeRename.Exit" */ -#define EVENT_LVolSalvage_Enter 42 /* "NSS.LVolumeSalvage.Enter" */ -#define EVENT_LVolSalvage_Exit 43 /* "NSS.LVolumeSalvage.Exit" */ -#define EVENT_LVolPurge_Enter 44 /* "NSS.LVolumePurge.Enter" */ -#define EVENT_LVolPurge_Exit 45 /* "NSS.LVolumePurge.Exit" */ -#define EVENT_LVolSnapshot_Enter 46 /* "NSS.LVolumeSnapshot.Enter" */ -#define EVENT_LVolSnapshot_Exit 47 /* "NSS.LVolumeSnapshot.Exit" */ -#define EVENT_PoolFreeze 48 /* "NSS.PoolFreeze" */ -#define EVENT_PoolThaw 49 /* "NSS.PoolThaw" */ +#define EVENT_ChangePoolShared_Exit 35 /* "NSS.ChangePoolShared.Exit" */ +#define EVENT_LVolCreate_Enter 36 /* "NSS.LVolumeCreate.Enter" */ +#define EVENT_LVolCreate_Exit 37 /* "NSS.LVolumeCreate.Exit" */ +#define EVENT_LVolDelete_Enter 38 /* "NSS.LVolumeDelete.Enter" */ +#define EVENT_LVolDelete_Exit 39 /* "NSS.LVolumeDelete.Exit" */ +#define EVENT_LVolRename_Enter 40 /* "NSS.LVolumeRename.Enter" */ +#define EVENT_LVolRename_Exit 41 /* "NSS.LVolumeRename.Exit" */ +#define EVENT_LVolSalvage_Enter 42 /* "NSS.LVolumeSalvage.Enter" */ +#define EVENT_LVolSalvage_Exit 43 /* "NSS.LVolumeSalvage.Exit" */ +#define EVENT_LVolPurge_Enter 44 /* "NSS.LVolumePurge.Enter" */ +#define EVENT_LVolPurge_Exit 45 /* "NSS.LVolumePurge.Exit" */ +#define EVENT_LVolSnapshot_Enter 46 /* "NSS.LVolumeSnapshot.Enter" */ +#define EVENT_LVolSnapshot_Exit 47 /* "NSS.LVolumeSnapshot.Exit" */ +#define EVENT_PoolFreeze 48 /* "NSS.PoolFreeze" */ +#define EVENT_PoolThaw 49 /* "NSS.PoolThaw" */ #define MAX_NSS_EVENTS 50 @@ -215,15 +215,15 @@ extern void UnregisterNSSEventProducers(); extern void ReportProduceEventError(char *name,STATUS status); /** Macros for the NEB interface **/ -#define REG_EVENT_PROD(_reg, _name, _parm, _flags) \ -{ \ - STATUS _status; \ +#define REG_EVENT_PROD(_reg, _name, _parm, _flags) \ +{ \ + STATUS _status; \ \ - _reg.PRIVersion = NEB_PRODUCER_VERSION1; \ + _reg.PRIVersion = NEB_PRODUCER_VERSION1; \ _reg.PRIProducerName = MSGNot("NSS"); \ _reg.PRIEventName = _name; \ _reg.PRIUserParameter = (void *)_parm; \ - _reg.PRIEventFlags = _flags; \ + _reg.PRIEventFlags = _flags; \ _reg.PRIOwnerID = COMN_Resource.moduleHandle; \ _reg.PRIProducerESR = (void *)EventProducerCallback; \ _reg.PRISecurityToken = 0; \ @@ -238,11 +238,11 @@ extern void ReportProduceEventError(char *name,STATUS status); } \ NEBEventInfo[_parm].producerID = (NINT)_reg.PRIProducerID; \ NEBEventInfo[_parm].eventID = (NINT)_reg.PRIEventID; \ -} +} #define INIT_EVENT_BLOCK(_evblk, _parm, _data) \ { \ - _evblk.EBVersion = NEB_EVENT_VERSION1; \ + _evblk.EBVersion = NEB_EVENT_VERSION1; \ _evblk.EBStamp = EVENT_BLOCK_STAMP; \ _evblk.EBRTag = COMN_Resource.eventBlkRTag; \ _evblk.EBProducerID = (void *)NEBEventInfo[_parm].producerID; \ @@ -253,7 +253,7 @@ extern void ReportProduceEventError(char *name,STATUS status); #define INIT_EVENT_BLOCK2(_evblk, _parm, _data, _length) \ { \ - _evblk.EBVersion = NEB_EVENT_VERSION1; \ + _evblk.EBVersion = NEB_EVENT_VERSION1; \ _evblk.EBStamp = EVENT_BLOCK_STAMP; \ _evblk.EBRTag = COMN_Resource.eventBlkRTag; \ _evblk.EBProducerID = (void *)NEBEventInfo[_parm].producerID; \ @@ -262,78 +262,78 @@ extern void ReportProduceEventError(char *name,STATUS status); _evblk.EBEventData = (void *)_data; \ } -#define INIT_EVENT_ID_STATUS(_id, _status) \ +#define INIT_EVENT_ID_STATUS(_id, _status) \ { \ EnterExitEventID++; \ _id = EnterExitEventID; \ _status = ENTER_EVENT_SUCCESS; \ } -#define INIT_PATH_INFO(_data, _namemsg) \ -{ \ - _data.volID = (_namemsg->curvol) ? \ - _namemsg->curvol->VOLvolumeID : \ - _namemsg->volumeID; \ - _data.zid = (_namemsg->curDataStream) ? \ - _namemsg->curDataStream->NAMEDzid : \ +#define INIT_PATH_INFO(_data, _namemsg) \ +{ \ + _data.volID = (_namemsg->curvol) ? \ + _namemsg->curvol->VOLvolumeID : \ + _namemsg->volumeID; \ + _data.zid = (_namemsg->curDataStream) ? \ + _namemsg->curDataStream->NAMEDzid : \ _namemsg->dataStreamZid; \ } -#define INIT_SRC_PATH_INFO(_data, _namemsg) \ -{ \ - _data.srcVolID = (_namemsg->curvol) ? \ - _namemsg->curvol->VOLvolumeID : \ - _namemsg->volumeID; \ - _data.srcZid = (_namemsg->curDataStream) ? \ - _namemsg->curDataStream->NAMEDzid : \ +#define INIT_SRC_PATH_INFO(_data, _namemsg) \ +{ \ + _data.srcVolID = (_namemsg->curvol) ? \ + _namemsg->curvol->VOLvolumeID : \ + _namemsg->volumeID; \ + _data.srcZid = (_namemsg->curDataStream) ? \ + _namemsg->curDataStream->NAMEDzid : \ _namemsg->dataStreamZid; \ } -#define INIT_DST_PATH_INFO(_data, _namemsg) \ -{ \ - _data.dstVolID = (_namemsg->curvol) ? \ - _namemsg->curvol->VOLvolumeID : \ - _namemsg->volumeID; \ - _data.dstZid = (_namemsg->curDataStream) ? \ - _namemsg->curDataStream->NAMEDzid : \ +#define INIT_DST_PATH_INFO(_data, _namemsg) \ +{ \ + _data.dstVolID = (_namemsg->curvol) ? \ + _namemsg->curvol->VOLvolumeID : \ + _namemsg->volumeID; \ + _data.dstZid = (_namemsg->curDataStream) ? \ + _namemsg->curDataStream->NAMEDzid : \ _namemsg->dataStreamZid; \ } -#define INIT_TIME_INFO(_times, _bst) \ +#define INIT_TIME_INFO(_times, _bst) \ { \ - if ((_bst != NULL) && (COMN_IsDerivedFrom(_bst, zFTYPE_FILE))) \ + if ((_bst != NULL) && (COMN_IsDerivedFrom(_bst, zFTYPE_FILE))) \ { \ - _times.accessedTime =((File_s *)_bst)->FILEaccessedTime; \ - _times.createdTime =((File_s *)_bst)->FILEcreatedTime; \ - _times.modifiedTime =((File_s *)_bst)->FILEmodifiedTime; \ + _times.accessedTime =((File_s *)_bst)->FILEaccessedTime; \ + _times.createdTime =((File_s *)_bst)->FILEcreatedTime; \ + _times.modifiedTime =((File_s *)_bst)->FILEmodifiedTime; \ _times.metaDataModifiedTime=((File_s *)_bst)->FILEmetaDataModifiedTime;\ } \ else \ { \ - _times.accessedTime = INVALID_UTC_TIME; \ - _times.createdTime = INVALID_UTC_TIME; \ - _times.modifiedTime = INVALID_UTC_TIME; \ - _times.metaDataModifiedTime = INVALID_UTC_TIME; \ + _times.accessedTime = INVALID_UTC_TIME; \ + _times.createdTime = INVALID_UTC_TIME; \ + _times.modifiedTime = INVALID_UTC_TIME; \ + _times.metaDataModifiedTime = INVALID_UTC_TIME; \ } \ } #define INIT_ENTER_EVENT(_genmsg, _namemsg, _evblk, _parm, _enter, _id) \ { \ _enter.enterExitID = _id; \ - _enter.connID = _genmsg->pssConn.id; \ - _enter.taskID = _genmsg->taskID; \ + _enter.connID = _genmsg->pssConn.id; \ + _enter.taskID = _genmsg->taskID; \ INIT_PATH_INFO(_enter, _namemsg); \ INIT_EVENT_BLOCK(_evblk, _parm, &_enter); \ } -#define INIT_RENAME_ENTER_EVENT(_genmsg, _srcnamemsg, _evblk, \ - _parm, _enter, _id, _newname, _renmsg, _targetDirZid) \ -{ \ +#define INIT_RENAME_ENTER_EVENT(_genmsg, _srcnamemsg, _evblk, \ + _parm, _enter, _id, _newname, _renmsg, _targetDirZid) \ +{ \ _enter.enterExitID = _id; \ - _enter.connID = _genmsg->pssConn.id; \ - _enter.taskID = _genmsg->taskID; \ + _enter.connID = _genmsg->pssConn.id; \ + _enter.taskID = _genmsg->taskID; \ INIT_SRC_PATH_INFO(_enter, _srcnamemsg); \ - _enter.dstZid = _targetDirZid; \ + _enter.dstZid = _targetDirZid; \ _enter.dstName = _newname; \ _enter.renameFlags = _renmsg->renameFlags; \ INIT_EVENT_BLOCK(_evblk, _parm, &_enter); \ @@ -345,21 +345,21 @@ extern void ReportProduceEventError(char *name,STATUS status); { \ if (_evblk.EBConsumingConsumer != NULL) \ { \ - SetErrno(_genmsg, (NINT)_evblk.EBParm1); \ + SetErrno(_genmsg, (NINT)_evblk.EBParm1); \ if (_evblk.EBParm0 == zOK) \ _status = zOK; \ else \ - _status = zFAILURE; \ + _status = zFAILURE; \ goto _retlabel; \ } \ } \ else if (_status == OPERATION_DENIED) \ { \ - SetErrno(_genmsg, (NINT)_evblk.EBParm1); \ + SetErrno(_genmsg, (NINT)_evblk.EBParm1); \ if (_evblk.EBParm1 == zOK) \ _status = zOK; \ else \ - _status = zFAILURE; \ + _status = zFAILURE; \ goto _retlabel; \ } \ else if ((_status == EVENT_DENIED) || (_status == INVALID_PARAMETER)) \ @@ -368,7 +368,7 @@ extern void ReportProduceEventError(char *name,STATUS status); } \ } -#define INIT_EXIT_EVENT(_status, _genmsg, _evblk, _parm, _exit, _id) \ +#define INIT_EXIT_EVENT(_status, _genmsg, _evblk, _parm, _exit, _id) \ { \ _exit.enterExitID = _id; \ zASSERT((_status == zOK) || (GetErrno((_genmsg)) != zOK)); \ @@ -376,20 +376,20 @@ extern void ReportProduceEventError(char *name,STATUS status); INIT_EVENT_BLOCK(_evblk, _parm, &_exit); \ } -#define INIT_CREATE_ENTER_EVENT(_genmsg, _namemsg, _evblk, _parm, _enter, \ +#define INIT_CREATE_ENTER_EVENT(_genmsg, _namemsg, _evblk, _parm, _enter, \ _id, _bname, _createmsg, _retfilehandle) \ { \ - _enter.enterExitID = (_id); \ - _enter.connID = (_genmsg)->pssConn.id; \ - _enter.taskID = (_genmsg)->taskID; \ + _enter.enterExitID = (_id); \ + _enter.connID = (_genmsg)->pssConn.id; \ + _enter.taskID = (_genmsg)->taskID; \ INIT_PATH_INFO(_enter, (_namemsg)); \ - _enter.name = (_bname); \ - _enter.fileType = (_createmsg)->beastClassID; \ - _enter.fileAttributes = (_createmsg)->attributes; \ - _enter.createFlags = (_createmsg)->createFlags; \ - _enter.createParms = (_createmsg)->createParms; \ - _enter.requestedRights = (_createmsg)->requestedRights; \ - _enter.createAndOpen = (NINT)(_retfilehandle); \ + _enter.name = (_bname); \ + _enter.fileType = (_createmsg)->beastClassID; \ + _enter.fileAttributes = (_createmsg)->attributes; \ + _enter.createFlags = (_createmsg)->createFlags; \ + _enter.createParms = (_createmsg)->createParms; \ + _enter.requestedRights = (_createmsg)->requestedRights; \ + _enter.createAndOpen = (NINT)(_retfilehandle); \ INIT_EVENT_BLOCK(_evblk, _parm, &_enter); \ } @@ -399,45 +399,45 @@ extern void ReportProduceEventError(char *name,STATUS status); if (_status == zOK) \ { \ _exit.retOpenCreateAction = (_createmsg)->ret_openCreateAction; \ - _exit.retKey = (_retfilehandle) ? (_retfilehandle)->key : 0; \ - _exit.retZid = (_namemsg)->curDataStream->NAMEDzid; \ - _exit.retVolID = (_namemsg)->curvol->VOLvolumeID; \ + _exit.retKey = (_retfilehandle) ? (_retfilehandle)->key : 0; \ + _exit.retZid = (_namemsg)->curDataStream->NAMEDzid; \ + _exit.retVolID = (_namemsg)->curvol->VOLvolumeID; \ INIT_TIME_INFO(_exit.times, (_namemsg)->curFile); \ } \ else \ { \ - _exit.retOpenCreateAction = 0; \ - _exit.retKey = 0; \ + _exit.retOpenCreateAction = 0; \ + _exit.retKey = 0; \ INIT_TIME_INFO(_exit.times, NULL); \ } \ } -#define INIT_OPEN_ENTER_EVENT(_enter, _openmsg) \ -{ \ - _enter.requestedRights = (_openmsg)->requestedRights; \ - _enter.openParms = (_openmsg)->openParms; \ +#define INIT_OPEN_ENTER_EVENT(_enter, _openmsg) \ +{ \ + _enter.requestedRights = (_openmsg)->requestedRights; \ + _enter.openParms = (_openmsg)->openParms; \ } #define INIT_OPEN_EXIT_EVENT(_exit, _status, _namemsg, _retfilehandle) \ { \ - if (_status == zOK) \ + if (_status == zOK) \ { \ - _exit.retKey = _retfilehandle ? (_retfilehandle)->key : 0; \ - _exit.retZid = (_namemsg)->curDataStream->NAMEDzid; \ - _exit.retVolID = (_namemsg)->curvol->VOLvolumeID; \ + _exit.retKey = _retfilehandle ? (_retfilehandle)->key : 0; \ + _exit.retZid = (_namemsg)->curDataStream->NAMEDzid; \ + _exit.retVolID = (_namemsg)->curvol->VOLvolumeID; \ INIT_TIME_INFO(_exit.times, (_namemsg)->curFile); \ } \ else \ { \ - _exit.retKey = 0; \ + _exit.retKey = 0; \ INIT_TIME_INFO(_exit.times, NULL); \ } \ } -#define INIT_CLOSE_ENTER_EVENT(_genmsg, _evblk, _parm, _enter, _fh, _id) \ -{ \ +#define INIT_CLOSE_ENTER_EVENT(_genmsg, _evblk, _parm, _enter, _fh, _id) \ +{ \ _enter.enterExitID = _id; \ - _enter.connID = (_genmsg)->pssConn.id; \ + _enter.connID = (_genmsg)->pssConn.id; \ _enter.key = (_fh)->door.dr_key; \ _enter.fhState = (_fh)->fhState; \ INIT_TIME_INFO(_enter.times, (_fh)->file); \ @@ -446,23 +446,23 @@ extern void ReportProduceEventError(char *name,STATUS status); #define INIT_CLOSE_EXIT_EVENT(_exit, _filedel, _status) \ { \ - _exit.opRetCode = _status; \ - _exit.fileDeleted = _filedel; \ + _exit.opRetCode = _status; \ + _exit.fileDeleted = _filedel; \ } #define INIT_MODIFY_ENTER_EVENT(_infomsg, _enter) \ { \ - _enter.modifyInfoMask = _infomsg->modifyInfoMask; \ - _enter.modifyTypeInfoMask = _infomsg->modifyTypeInfoMask; \ - _enter.modifyInfo = _infomsg->modifyInfo; \ - _enter.modifyTypeInfo = _infomsg->modifyTypeInfo; \ + _enter.modifyInfoMask = _infomsg->modifyInfoMask; \ + _enter.modifyTypeInfoMask = _infomsg->modifyTypeInfoMask; \ + _enter.modifyInfo = _infomsg->modifyInfo; \ + _enter.modifyTypeInfo = _infomsg->modifyTypeInfo; \ } -#define INIT_SIZE_ENTER_EVENT(_genmsg, _evblk, _parm, _enter, _fh, \ - _flags, _cureof, _neweof, _id) \ -{ \ +#define INIT_SIZE_ENTER_EVENT(_genmsg, _evblk, _parm, _enter, _fh, \ + _flags, _cureof, _neweof, _id) \ +{ \ _enter.enterExitID = _id; \ - _enter.connID = _genmsg->pssConn.id; \ + _enter.connID = _genmsg->pssConn.id; \ _enter.key = _fh->door.dr_key; \ _enter.setSizeFlags = _flags; \ _enter.curEOF = _cureof; \ @@ -477,14 +477,14 @@ extern void ReportProduceEventError(char *name,STATUS status); #define INIT_ADD_TRUSTEE_ENTER_EVENT(_enter, _trusteeId, _rights, _attr) \ { \ - _enter.trusteeID = _trusteeId; \ + _enter.trusteeID = _trusteeId; \ _enter.rights = _rights; \ _enter.attributes = _attr; \ } #define INIT_REMOVE_TRUSTEE_ENTER_EVENT(_enter, _trusteeId, _flag) \ { \ - _enter.trusteeID = _trusteeId; \ + _enter.trusteeID = _trusteeId; \ _enter.purgedFileFlag = _flag; \ } @@ -494,9 +494,9 @@ extern void ReportProduceEventError(char *name,STATUS status); _enter.authorizeFlag = _flag; \ } -#define INIT_VOL_STATE_ENTER_EVENT( _evblk, _parm, _enter, _id, _vol, \ +#define INIT_VOL_STATE_ENTER_EVENT( _evblk, _parm, _enter, _id, _vol, \ _oState, _nState, _mode) \ -{ \ +{ \ _enter.enterExitID = _id; \ _enter.oldState = _oState; \ _enter.newState = _nState; \ @@ -513,8 +513,8 @@ extern void ReportProduceEventError(char *name,STATUS status); INIT_EVENT_BLOCK(_evblk, _parm, &_enter); \ } -#define INIT_VOL_STATE_EXIT_EVENT(_exit, _vol, _oState, _mode) \ -{ \ +#define INIT_VOL_STATE_EXIT_EVENT(_exit, _vol, _oState, _mode) \ +{ \ _exit.oldState = _oState; \ _exit.newState = _vol->state; \ _exit.mode = _mode; \ @@ -529,12 +529,12 @@ extern void ReportProduceEventError(char *name,STATUS status); } \ } -#define INIT_LINK_ENTER_EVENT(_genmsg, _srcnamemsg, _dstnamemsg, \ +#define INIT_LINK_ENTER_EVENT(_genmsg, _srcnamemsg, _dstnamemsg, \ _evblk, _parm, _enter, _id, _newname, _linkmsg) \ -{ \ +{ \ _enter.enterExitID = _id; \ - _enter.connID = _genmsg->pssConn.id; \ - _enter.taskID = _genmsg->taskID; \ + _enter.connID = _genmsg->pssConn.id; \ + _enter.taskID = _genmsg->taskID; \ INIT_SRC_PATH_INFO(_enter, _srcnamemsg); \ INIT_DST_PATH_INFO(_enter, _dstnamemsg); \ _enter.dstName = _newname; \ @@ -544,17 +544,17 @@ extern void ReportProduceEventError(char *name,STATUS status); #define INIT_POOL_STATE_ENTER_EVENT(_evblk, _parm, _enter, _id, _pool, \ _oState, _nState, _mode) \ -{ \ +{ \ _enter.enterExitID = _id; \ _enter.oldState = _oState; \ _enter.newState = _nState; \ _enter.mode = _mode; \ - _enter.poolID = _pool->POOLvolumeID; \ + _enter.poolID = _pool->POOLvolumeID; \ INIT_EVENT_BLOCK(_evblk, _parm, &_enter); \ } -#define INIT_POOL_STATE_EXIT_EVENT(_exit, _pool, _oState, _mode) \ -{ \ +#define INIT_POOL_STATE_EXIT_EVENT(_exit, _pool, _oState, _mode) \ +{ \ _exit.oldState = _oState; \ _exit.newState = _pool->state; \ _exit.mode = _mode; \ diff --git a/include/nwnss/include/evs.h b/include/nwnss/include/evs.h index 688d2ab..3a60611 100644 --- a/include/nwnss/include/evs.h +++ b/include/nwnss/include/evs.h @@ -49,7 +49,7 @@ #define MIN_BUFS_PER_ENCRYPTED_VOLUME (1) #define MAX_BUFS_PER_ENCRYPTED_VOLUME (1000) -#if zNETWARE || (zLINUX && defined(__KERNEL__)) || defined(NSS_USERSPACE) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) extern NINT Pages_Per_Encrypted_Volume; /* This is no more than a structure to define a linked list of buffers used to @@ -61,7 +61,7 @@ typedef struct EncryptedBufPage_s } EncryptedBufPage_s; #endif -/* This structure contains info needed to support encrypted volumes. A pointer to this stucture +/* This structure contains info needed to support encrypted volumes. A pointer to this stucture is provided in Volume_s->v_crypt and if non-null, points to this structure */ typedef struct PersistentVolumeCrypt_s { @@ -77,7 +77,7 @@ typedef struct PersistentVolumeCrypt_s { } NSS_MEDIA_STRUCTURE(PersistentVolumeCrypt_s,macLen) PersistentVolumeCrypt_s; typedef struct VolumeKey_s { - BYTE key[ENCRYPTED_VOLUME_KEY_LENGTH]; /* 128-bit AES key */ + BYTE key[ENCRYPTED_VOLUME_KEY_LENGTH]; /* 128-bit AES key */ BYTE iv[16]; /* 128-bit IV for AES */ NINT numCryptBuffers; /* number of buffers allocated for crypt work */ PersistentVolumeCrypt_s p; /* persistent data, created at volume init time */ diff --git a/include/nwnss/include/extAttrBeast.h b/include/nwnss/include/extAttrBeast.h index 02f6035..9fd01b9 100644 --- a/include/nwnss/include/extAttrBeast.h +++ b/include/nwnss/include/extAttrBeast.h @@ -44,11 +44,11 @@ #define _EXTATTRBEAST_H_ #ifndef _COMNPARAMS_H_ -#include +#include #endif #ifndef _COMNBEASTS_H_ -#include +#include #endif #ifdef __cplusplus diff --git a/include/nwnss/include/fsm.h b/include/nwnss/include/fsm.h index 4b7b8bb..5c7e7b9 100644 --- a/include/nwnss/include/fsm.h +++ b/include/nwnss/include/fsm.h @@ -44,11 +44,11 @@ #define _FSM_H_ #ifndef _QUE_H_ -# include +# include #endif #ifndef _MAILBOX_H_ -# include +# include #endif #ifdef __cplusplus @@ -90,7 +90,7 @@ extern "C" {
Pop ITEM off the FSM stack. Converts ITEM to TYPE passed in. Used to retrive arguments or return values placed on stack. -
FSM_DELETE(fsm) +
FSM_DELETE(fsm)
Just deletes an item from stack. Does not retieve it.
FSM_RUN(fsm)
Pops top of stack and immediately calls the function thus @@ -103,7 +103,7 @@ extern "C" { fast path.
FSM_RUN_VALUE(fsm, value)
Like FSM_RUN but lets us "return" a value to the called function. - Note: VALUE + Note: VALUE
FSM_READY_VALUE(fsm, value)
Like FSM_READY but lets us "return" a value to the requestor.
FSM_READY_ALL(queue) @@ -227,7 +227,7 @@ extern NINT fsmKick(); { \ FsmLite_s *Fsm = (FsmLite_s *)(_f); \ \ - Fsm->action = (voidfunc_t)(_action); \ + Fsm->action = (_action); \ zASSERT(Fsm->action != NULL); \ FSM_ENQ(Fsm); \ } @@ -324,7 +324,7 @@ typedef struct FsmInst_s { NINT mailDone; NINT fsmDone; -}FsmInst_s; +}FsmInst_s; extern FsmInst_s FsmInst; diff --git a/include/nwnss/include/fsmsg.h b/include/nwnss/include/fsmsg.h index d000d76..342cfa4 100644 --- a/include/nwnss/include/fsmsg.h +++ b/include/nwnss/include/fsmsg.h @@ -39,15 +39,15 @@ #define _FSMSG_H_ #ifndef _ZOMNI_H_ -# include +# include #endif #ifndef _NSS_MSG_H_ -# include +# include #endif #ifndef _ZFSMSG_H_ -# include +# include #endif extern mManager_s *FileMgr; diff --git a/include/nwnss/include/fullDirectoryInfo.h b/include/nwnss/include/fullDirectoryInfo.h index 3269cce..1c65423 100644 --- a/include/nwnss/include/fullDirectoryInfo.h +++ b/include/nwnss/include/fullDirectoryInfo.h @@ -43,10 +43,10 @@ #ifndef _FULLDIRECTORYINFO_H_ #define _FULLDIRECTORYINFO_H_ -#include +#include #ifndef _OMNI_H_ -#include +#include #endif #ifdef __cplusplus diff --git a/include/nwnss/include/guid.h b/include/nwnss/include/guid.h index 422aa89..f92a4e0 100644 --- a/include/nwnss/include/guid.h +++ b/include/nwnss/include/guid.h @@ -49,7 +49,7 @@ extern "C" { #ifndef _ZOMNI_H_ -#include +#include #endif #ifndef _NSS_STRING_H_ @@ -138,8 +138,6 @@ extern void LB_GUIDGenerate( GUID_t *retGuid ); (memcmp((_guid1),(_guid2),sizeof(GUID_t))) */ -extern QUAD GUID_getTime(void); -extern void GUID_init(void); extern int LB_GUIDValidate( GUID_t *TESTGuid ); STATUS LB_GUIDFromUTF8( utf8_t *p, GUID_t *guid ); diff --git a/include/nwnss/include/hardLinkBeast.h b/include/nwnss/include/hardLinkBeast.h index ab68d84..e8a81a5 100644 --- a/include/nwnss/include/hardLinkBeast.h +++ b/include/nwnss/include/hardLinkBeast.h @@ -38,15 +38,15 @@ #define _HARDLINK_H_ #ifndef _COMNBEASTS_H_ -#include +#include #endif #ifndef _MSGGEN_H_ -#include +#include #endif #ifndef _VOLUME_H_ -#include +#include #endif @@ -109,7 +109,7 @@ extern HardLinkBeast_s *HL_doCreateHardLinkBeast( Xaction_s *xaction); extern STATUS HL_doDestroyHardLinkBeast( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, HardLinkBeast_s *hlBeast, File_s *inodeBeast, Xaction_s *xaction); @@ -120,7 +120,7 @@ extern File_s *HL_CheckIfHardlinkAndReturnPrimary( NINT latchType); extern CommonBeastOps_s HardLinkBeastComnOps; -extern const char Module[]; +extern const char Module[]; extern NINT HL_NewLocalVolumeBeastVersion; extern NINT HL_NewSharedVolumeBeastVersion; extern void HL_StartUpgradeProcess(Volume_s *switchDef, NINT shareFlags); diff --git a/include/nwnss/include/histogram.h b/include/nwnss/include/histogram.h index d3306a0..a960dcd 100644 --- a/include/nwnss/include/histogram.h +++ b/include/nwnss/include/histogram.h @@ -3,20 +3,20 @@ | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | @@ -43,7 +43,15 @@ #define _HISTOGRAM_H_ #ifndef _OMNI_H_ -#include +#include +#endif + +#ifndef _INLINES_H_ +#include +#endif + +#ifndef _PARSE_H_ +#include #endif #ifdef __cplusplus @@ -52,7 +60,6 @@ extern "C" { /* Pre-define struct(s) so Linux compiler doesn't complain */ struct ScreenStruct; -struct PCLSwitchDef_s; typedef struct Histogram_s { @@ -75,44 +82,44 @@ STATUS registerHistogram( BOOL *isEnabled, Histogram_s *histogram); -STATUS doDisplayHistogram( +STATUS doDisplayHistogram ( struct PCLSwitchDef_s *switchDef, NINT options, void *userParm); -STATUS doDisableHistogram( +STATUS doDisableHistogram ( struct PCLSwitchDef_s *switchDef, NINT options, void *userParm); -STATUS doClearHistogram( +STATUS doClearHistogram ( struct PCLSwitchDef_s *switchDef, NINT options, void *userParm); -STATUS doListHistograms( +STATUS doListHistograms ( struct PCLSwitchDef_s *switchDef, NINT options, void *userParm); -STATUS doEnableHistogram( +STATUS doEnableHistogram ( struct PCLSwitchDef_s *switchDef, NINT options, void *userParm); #if HISTOGRAM IS_ENABLED -#define INC_HISTOGRAM(_hist) (incHistogram(&(_hist))) -#define DEC_HISTOGRAM(_hist) (--((_hist).currentCount)) -#define ZERO_HISTOGRAM(_hist) (bzero(&(_hist), sizeof(Histogram_s))) -#define EVENT_HISTOGRAM(_hist, _event) (eventHistogram(&(_hist), (_event))) +#define INC_HISTOGRAM(_hist) (incHistogram( &(_hist))) +#define DEC_HISTOGRAM(_hist) (--((_hist).currentCount)) +#define ZERO_HISTOGRAM(_hist) (bzero( &(_hist), sizeof(Histogram_s))) +#define EVENT_HISTOGRAM(_hist, _event) (eventHistogram( &(_hist), (_event))) #else -#define INC_HISTOGRAM(_hist) ((void)0) -#define DEC_HISTOGRAM(_hist) ((void)0) -#define ZERO_HISTOGRAM(_hist) ((void)0) -#define EVENT_HISTOGRAM(_hist, _event) ((void)0) +#define INC_HISTOGRAM(_hist) ((void) 0) +#define DEC_HISTOGRAM(_hist) ((void) 0) +#define ZERO_HISTOGRAM(_hist) ((void) 0) +#define EVENT_HISTOGRAM(_hist) ((void) 0) #endif @@ -132,7 +139,64 @@ typedef struct Timer_s NINT suspended; } Timer_s; -extern Timer_s *CurrentTimer; +extern Timer_s *CurrentTimer; + +#define TIMER Timer_s tiMer +#define SAVE_TIMER Timer_s *saveTiMer + +#define START_TIMER() \ +{ \ + zASSERT(CurrentTimer == NULL); \ + \ + tiMer.running = 0; \ + tiMer.suspended = 0; \ + CurrentTimer = &tiMer; \ + tiMer.start = LB_CycleCount(); \ +} + +#define STOP_TIMER(_histRunning, _histSuspended) \ +{ \ + if (CurrentTimer) \ + { \ + NINT end; \ + \ + zASSERT(CurrentTimer == &tiMer); \ + \ + end = LB_CycleCount(); \ + CurrentTimer->running += end - CurrentTimer->start; \ + eventHistogram( &(_histRunning), CurrentTimer->running); \ + if (CurrentTimer->suspended) \ + { \ + eventHistogram( &(_histSuspended), CurrentTimer->suspended);\ + } \ + CurrentTimer = NULL; \ + } \ +} + +#define SUSPEND_TIMER() \ +{ \ + if (CurrentTimer) \ + { \ + NINT end; \ + \ + end = LB_CycleCount(); \ + CurrentTimer->running += end - CurrentTimer->start; \ + CurrentTimer->start = end; \ + saveTiMer = CurrentTimer; \ + CurrentTimer = NULL; \ + } \ +} + +#define RESUME_TIMER() \ +{ \ + NINT end; \ + \ + zASSERT(CrrentTimer == NULL); \ + end = LB_CycleCount(); \ + CurrentTimer = saveTiMer; \ + CurrentTimer->suspended += end - CurrentTimer->start; \ + CurrentTimer->start = end; \ +} #ifdef __cplusplus } diff --git a/include/nwnss/include/hmc.h b/include/nwnss/include/hmc.h index f0c653b..15a6165 100644 --- a/include/nwnss/include/hmc.h +++ b/include/nwnss/include/hmc.h @@ -33,11 +33,11 @@ #define _HMC_H_ #ifndef _OMNI_H_ -# include +# include #endif -#ifndef _QUE_H_ -# include +#ifndef _MSGGEN_H_ +# include #endif struct Buffer_s; @@ -82,3 +82,4 @@ void HMC_UpdatePrivateCacheSizeUI(NINT newBlockTotal); const char *HMC_CacheName(void); #endif /* ifndef _HMC_H_ */ + diff --git a/include/nwnss/include/http.imp b/include/nwnss/include/http.imp new file mode 100644 index 0000000..4f5d39f --- /dev/null +++ b/include/nwnss/include/http.imp @@ -0,0 +1,38 @@ + HttpQueryInfo + HttpReturnString + HttpReturnPathBuffers + HttpReturnDataAvailBuffer + HttpReturnDataTxBuffer + HttpReturnHeaderVersion + HttpSendDataSprintf + HttpOpenResponseHeaderTag + HttpAddResponseHeaderTags + HttpAddResponseHeaderDateTag + HttpAddResponseHeaderContentTypeTag + HttpAddResponseHeaderLastModifiedTag + HttpSendResponseHeader + HttpAddResponseHeaderStringContentType + HttpAddResponseHeaderContentLengthTag + HttpSendSuccessfulResponse + HttpSendErrorResponse + HttpSendDataResponse + HttpSendDataFlush + HttpEndDataResponse + RegisterServiceMethod + DeRegisterServiceMethod + RegisterFileSystemServiceMethodEx + DeRegisterFileSystemServiceMethod + serviceGetConnectionNumber + HttpGetContext + HttpSetContext + HttpExtractInternetTimeFromString + HttpLocalTimeToInternetTime + HttpInternetTimeToString + HttpCheckIfModifiedSinceTime + HttpStackIpInformation + HttpSendDataTxBuffer + HttpUnConvertName + HttpConvertName + HttpScanServiceMethods + HttpReturnRequestMethod + HttpReturnPostDataBuffer \ No newline at end of file diff --git a/include/nwnss/include/id.h b/include/nwnss/include/id.h index 554b13c..193a660 100644 --- a/include/nwnss/include/id.h +++ b/include/nwnss/include/id.h @@ -38,7 +38,7 @@ #define _ID_H_ #ifndef _OMNI_H_ -#include +#include "omni.h" #endif /* @@ -46,8 +46,6 @@ * for trustee ids. */ -#define zINVALID_USERID zINVALID_GUID - #define MAX_IDS 0x800000 /* Max number of ids we will try * to handle. */ diff --git a/include/nwnss/include/inst.h b/include/nwnss/include/inst.h index c772c34..8738479 100644 --- a/include/nwnss/include/inst.h +++ b/include/nwnss/include/inst.h @@ -44,7 +44,7 @@ #define _INST_H_ #ifndef _ZOMNI_H_ -# include +# include #endif #ifdef __cplusplus @@ -162,7 +162,7 @@ typedef struct PageInst_s QUAD pgRequest; /* Pages given back by xRequestPage */ QUAD pgContig; /* Pages given back by xRequestContiguousPages */ } PageInst_s; - + extern Inst_s Inst; extern PageInst_s PageInst; diff --git a/include/nwnss/include/ipuAccess.h b/include/nwnss/include/ipuAccess.h new file mode 100644 index 0000000..6656a61 --- /dev/null +++ b/include/nwnss/include/ipuAccess.h @@ -0,0 +1,215 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | + | + +-------------------------------------------------------------------------*/ +#ifndef _IPUACCESS_H_ +#define _IPUACCESS_H_ + + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*--- ipuAccess ------------------------------------------------------------- + | + +-------------------------------------------------------------------------*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + +/*--------------------------------------------------------------------------- + | Global definitions + +-------------------------------------------------------------------------*/ +/*- defined message types -*/ +#define IPU_MSG_PROCESSPHASE 1 // process the next phase +#define IPU_MSG_STATUS 2 // get status of ipu +#define IPU_MSG_CONFIG 3 // set process information + +/*- config message mask bits -*/ +#define IPU_SET_TYPE 0x00000001 // mask to set conversion type +#define IPU_SET_NWVOLNAME 0x00000002 // mask to set nw volume name +#define IPU_SET_NSSVOLNAME 0x00000004 // mask to set nss volume name +#define IPU_SET_VOLCONFIRM 0x00000008 // mask to confirm volume selection +#define IPU_SET_VOLPURGE 0x00000010 // mask to activate purge phase +#define IPU_SET_DECOMPRESS 0x00000020 // mask to activate decompress phase +#define IPU_SET_FINALCONFIRM 0x00000040 // mask to confirm final conversion +#define IPU_SET_ABORT 0x00000080 // mask to activate abort sequence +#define IPU_SET_RESET 0x00000100 // mask to reset ipu process + +/*- message return code -*/ +#define IPU_ERR_INVALIDMSGTYPE 51000 // (C738h) invalid message type + +/*- defined return message completed codes -*/ +#define IPU_INFO_OK 50100 // (C3B4h) valid information +#define IPU_INFO_FAILURE 50101 // (C3B5h) invalid information +#define IPU_INFO_PROCESSED 50102 // (C3B6h) phase has been processed + +/*- defined completion status -*/ +#define IPU_STATUS_OK 50500 // (C544h) success on last action +#define IPU_STATUS_IDLE 50501 // (C545h) ipu not working (waiting) +#define IPU_STATUS_WORKING 50502 // (C546h) conversion in progress + +#define IPU_STATUS_INPROGRESS 50503 // (C547h) working on this phase +#define IPU_STATUS_INITFAILED 50504 // (C548h) phase failed +#define IPU_STATUS_UPDATEFAILED 50505 // (C549h) phase failed +#define IPU_STATUS_UPGRTYPEFAILED 50506 // (C54Ah) phase failed +#define IPU_STATUS_NWVERIFYFAILED 50507 // (C54Bh) phase failed +#define IPU_STATUS_NSSVERIFYFAILED 50508 // (C54Ch) phase failed +#define IPU_STATUS_MOUNTFAILED 50509 // (C54Dh) phase failed +#define IPU_STATUS_READFATFAILED 50510 // (C54Eh) phase failed +#define IPU_STATUS_PURGEFAILED 50511 // (C54Fh) phase failed +#define IPU_STATUS_DECOMPFAILED 50512 // (C550h) phase failed +#define IPU_STATUS_COUNTFATFAILED 50513 // (C551h) phase failed +#define IPU_STATUS_FREESPACEFAILED 50514 // (C552h) phase failed +#define IPU_STATUS_SACHAINFAILED 50515 // (C553h) phase failed +#define IPU_STATUS_BLKSNEEDEDFAILED 50516 // (C554h) phase failed +#define IPU_STATUS_STARTUPGRFAILED 50517 // (C555h) phase failed +#define IPU_STATUS_FLUSHNSSFAILED 50518 // (C556h) phase failed +#define IPU_STATUS_ABORTED 50519 // (C557h) abort conversion process +#define IPU_STATUS_CONFORMATION 50520 // (C558h) must set the confirm bit + +/*- ipu conversion can be stopped -*/ +#define IPU_SAFETOSTOP 50800 // (C670h) safe to abort or restart + + +/*- ipu state machine phase types -*/ +#define IPU_PHASE_INIT 0 // value of phase and phasedone +#define IPU_PHASE_UPDATE 1 // value of phase and phasedone +#define IPU_PHASE_TYPEVERIFY 2 // value of phase and phasedone +#define IPU_PHASE_NWVOLVERIFY 3 // value of phase and phasedone +#define IPU_PHASE_NSSVOLVERIFY 4 // value of phase and phasedone +#define IPU_PHASE_NWVOLMOUNT1 5 // value of phase and phasedone +#define IPU_PHASE_NWVOLREADFAT1 6 // value of phase and phasedone +#define IPU_PHASE_NWVOLPURGE 7 // value of phase and phasedone +#define IPU_PHASE_NWVOLREADFAT2 8 // value of phase and phasedone +#define IPU_PHASE_NWVOLDECOMPRESS 9 // value of phase and phasedone +#define IPU_PHASE_NWVOLREADFAT3 10 // value of phase and phasedone +#define IPU_PHASE_NWVOLFATCOUNT 11 // value of phase and phasedone +#define IPU_PHASE_SETFREESPACE 12 // value of phase and phasedone +#define IPU_PHASE_NWVOLSACHAININIT 13 // value of phase and phasedone +#define IPU_PHASE_BLOCKSNEEDED 14 // value of phase and phasedone +#define IPU_PHASE_NWVOLMOUNT2 15 // value of phase and phasedone +#define IPU_PHASE_STARTUPGRADE 16 // value of phase and phasedone +#define IPU_PHASE_FLUSHNSS 17 // value of phase and phasedone +#define IPU_PHASE_NOFLUSHNSS 18 // value of phase and phasedone +#define IPU_PHASE_CLEANUP 19 // value of phase and phasedone +#define IPU_PHASE_EXIT 20 // value of phase and phasedone + +/*- ipu upgrade types -*/ +#define IPU_COPY_TYPE 0 // copy conversion type +#define IPU_UPGRADE_TYPE 1 // inplace upgrade conversion type +#define IPU_INVALID_TYPE -1 // invalid conversion type + +/*--------------------------------------------------------------------------- + | Data Prototypes needed + +-------------------------------------------------------------------------*/ + +/*- this is the header for all messages -*/ +typedef struct IPUAccMsg_s +{ + LONG msg_type; // std. - message type + LONG msg_step; // std. - message single step if not zOK + LONG ret_code; // std. - message return code +} IPUAccMsg_s; + +/*- this is the status message -*/ +typedef struct ipuMsgStatus_s +{ + IPUAccMsg_s msg; // header and master message object + + LONG status; // ipu status + + LONG phase; // (set internal) current or next phase + LONG phasedone; // (set internal) last phase completed + LONG safetoquit; // (set internal) flag - safe to abort or reset + LONG abortflag; // (set user/internal) flag - abort status + LONG upgradetype; // (set user) type of upgrade + LONG blocksfree; // (set internal) source volume free blocks + LONG blocksneeded; // (set internal) source free blocks needed + char namesrc[32]; // (set user) netware source volume name + char namedest[128]; // (set user) nss destination volume name + LONG volconfirm; // (set user) confirm volume selection + LONG dopurge; // (set user) purge all deleted files + LONG dodecompress; // (set user) decompress all files + LONG finalconfirm; // (set user) confirm final media conversion + LONG initstatus; // (set internal) phase status + LONG updatestatus; // (set internal) phase status + LONG typestatus; // (set internal) phase status + LONG nwvolverifystatus; // (set internal) phase status + LONG nssvolverifystatus; // (set internal) phase status + LONG mountstatus; // (set internal) phase status + LONG readfatstatus; // (set internal) phase status + LONG purgestatus; // (set internal) phase status + LONG decompressstatus; // (set internal) phase status + LONG volfatcountstatus; // (set internal) phase status + LONG freespacestatus; // (set internal) phase status + LONG sachaininitstatus; // (set internal) phase status + LONG blocksneededstatus; // (set internal) phase status + LONG startupgradestatus; // (set internal) phase status + LONG flushnssstatus; // (set internal) phase status + LONG noflushstatus; // (set internal) phase status + LONG cleanupstatus; // (set internal) phase status + LONG exitstatus; // (set internal) phase status + LONG nwtotaldircnt; // (set internal) total directories to process + LONG nwtotalfilecnt; // (set internal) total files to process + LONG nwdirsdone; // (set internal) process count of directory + LONG nwfilesdone; // (set internal) process count of files +} ipuMsgStatus_s; + +/*- this is the config message -*/ +typedef struct ipuMsgConfig_s +{ + IPUAccMsg_s msg; // header and master message object + + LONG setinfomask; // config mask bits + + LONG upgradetype; // upgrade type + char namesrc[32]; // netware source volume name (16 char name) + char namedest[128]; // nss destination volume name (64 char name) + +} ipuMsgConfig_s; + + +/*--------------------------------------------------------------------------- + | Function Prototypes needed + +-------------------------------------------------------------------------*/ +extern STATUS zIPU_Access(IPUAccMsg_s *msg); // ipu command input + +#define ZOS_CloseFileIPU(_p1,_p2,_p3,_p4) \ +{ \ + MPKNSS_UNLOCK(); \ + _p1 = CloseFile(_p2,_p3, _p4); \ + MPKNSS_LOCK(); \ +} + + +#endif /* _IPUACCESS_H_ */ diff --git a/include/nwnss/include/jsdebug.h b/include/nwnss/include/jsdebug.h new file mode 100644 index 0000000..f68ba4b --- /dev/null +++ b/include/nwnss/include/jsdebug.h @@ -0,0 +1,247 @@ +/**************************************************************************** + | + | (C) Copyright 1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) / Distributed File Services (DFS) + | + |--------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2005-04-13 22:08:08 +0530 (Wed, 13 Apr 2005) $ + | + | $RCSfile$ + | $Revision: 927 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | DFS communications declarations - TCP transport + +-------------------------------------------------------------------------*/ +#ifndef _JSDEBUG_H_ +#define _JSDEBUG_H_ + +/* Global dependencies */ +#if zNETWARE +#ifndef __PROCDEFS_H__ +#include +#endif +#endif +#ifndef _OMNI_H_ +#include +#endif +#if zNETWARE +#ifndef _COMNPUBLICS_H_ +#include +#endif +#endif + + +/* Debug macro */ +#if zNETWARE && NSS_DEBUG IS_ENABLED + +/* Debug only dependencies */ + + +// Default debug message colour +#define DEBUG_COLOUR YELLOW + +/* + There MUST be a storage declaration for the following + two screen structures in a source file for any module + that uses macros/functions in this header file. +*/ +extern struct ScreenStruct *ScreenID; /* Debug screen */ +extern struct ScreenStruct *StatScreenID; /* Debug statistics screen */ +extern SPINLOCK StatScrSync; /* Synchronisation object for statistics screen */ + +void JS_InitDebugScreens(void); +void JS_CloseDebugScreens(void); +void JSTCP_InitDebugScreens(void); +void JSTCP_CloseDebugScreens(void); +void JSMSG_InitDebugScreens(void); +void JSMSG_CloseDebugScreens(void); + +#define DEBUG_TEXT0(dbgFormat) if (ScreenID != NULL) \ +{ \ + OutputToScreenWithAttribute(ScreenID, \ + DEBUG_COLOUR, \ + dbgFormat); \ +} +#define DEBUG_TEXT1(dbgFormat, dbgArg1) if (ScreenID != NULL) \ +{ \ + OutputToScreenWithAttribute(ScreenID, \ + DEBUG_COLOUR, \ + dbgFormat, \ + dbgArg1); \ +} +#define DEBUG_TEXT2(dbgFormat, dbgArg1, dbgArg2) if (ScreenID != NULL) \ +{ \ + OutputToScreenWithAttribute(ScreenID, \ + DEBUG_COLOUR, \ + dbgFormat, \ + dbgArg1, \ + dbgArg2); \ +} +#define DEBUG_TEXT3(dbgFormat, dbgArg1, dbgArg2, dbgArg3) if (ScreenID != NULL) \ +{ \ + OutputToScreenWithAttribute(ScreenID, \ + DEBUG_COLOUR, \ + dbgFormat, \ + dbgArg1, \ + dbgArg2, \ + dbgArg3); \ +} +#define DEBUG_TEXT4(dbgFormat, dbgArg1, dbgArg2, dbgArg3, dbgArg4) if (ScreenID != NULL) \ +{ \ + OutputToScreenWithAttribute(ScreenID, \ + DEBUG_COLOUR, \ + dbgFormat, \ + dbgArg1, \ + dbgArg2, \ + dbgArg3, \ + dbgArg4); \ +} + + +#define DEBUG_STAT0(dbgFormat) if (StatScreenID != NULL) \ +{ \ + kMutexLock(StatScrSync); \ + OutputToScreenWithAttribute(StatScreenID, \ + LGREEN, \ + dbgFormat); \ + kMutexUnlock(StatScrSync); \ +} +#define DEBUG_STAT1(dbgFormat, dbgArg1) if (StatScreenID != NULL) \ +{ \ + kMutexLock(StatScrSync); \ + OutputToScreenWithAttribute(StatScreenID, \ + LGREEN, \ + dbgFormat, \ + dbgArg1); \ + kMutexUnlock(StatScrSync); \ +} +#define DEBUG_STAT2(dbgFormat, dbgArg1, dbgArg2) if (StatScreenID != NULL) \ +{ \ + kMutexLock(StatScrSync); \ + OutputToScreenWithAttribute(StatScreenID, \ + LGREEN, \ + dbgFormat, \ + dbgArg1, \ + dbgArg2); \ + kMutexUnlock(StatScrSync); \ +} +#define DEBUG_STAT3(dbgFormat, dbgArg1, dbgArg2, dbgArg3) if (StatScreenID != NULL) \ +{ \ + kMutexLock(StatScrSync); \ + OutputToScreenWithAttribute(StatScreenID, \ + LGREEN, \ + dbgFormat, \ + dbgArg1, \ + dbgArg2, \ + dbgArg3); \ + kMutexUnlock(StatScrSync); \ +} +#define DEBUG_STAT4(dbgFormat, dbgArg1, dbgArg2, dbgArg3, dbgArg4) if (StatScreenID != NULL) \ +{ \ + kMutexLock(StatScrSync); \ + OutputToScreenWithAttribute(StatScreenID, \ + LGREEN, \ + dbgFormat, \ + dbgArg1, \ + dbgArg2, \ + dbgArg3, \ + dbgArg4); \ + kMutexUnlock(StatScrSync); \ +} +#define DEBUG_STAT_XY0(x, y, dbgFormat) if (StatScreenID != NULL) \ +{ \ + kMutexLock(StatScrSync); \ + PositionOutputCursor(StatScreenID, y, x); \ + OutputToScreenWithAttribute(StatScreenID, \ + LGREEN, \ + dbgFormat); \ + kMutexUnlock(StatScrSync); \ +} +#define DEBUG_STAT_XY1(x, y, dbgFormat, dbgArg1) if (StatScreenID != NULL) \ +{ \ + kMutexLock(StatScrSync); \ + PositionOutputCursor(StatScreenID, y, x); \ + OutputToScreenWithAttribute(StatScreenID, \ + LGREEN, \ + dbgFormat, \ + dbgArg1); \ + kMutexUnlock(StatScrSync); \ +} +#define DEBUG_STAT_XY2(x, y, dbgFormat, dbgArg1, dbgArg2) if (StatScreenID != NULL) \ +{ \ + kMutexLock(StatScrSync); \ + PositionOutputCursor(StatScreenID, y, x); \ + OutputToScreenWithAttribute(StatScreenID, \ + LGREEN, \ + dbgFormat, \ + dbgArg1, \ + dbgArg2); \ + kMutexUnlock(StatScrSync); \ +} +#define DEBUG_STAT_XY3(x, y, dbgFormat, dbgArg1, dbgArg2, dbgArg3) if (StatScreenID != NULL) \ +{ \ + kMutexLock(StatScrSync); \ + PositionOutputCursor(StatScreenID, y, x); \ + OutputToScreenWithAttribute(StatScreenID, \ + LGREEN, \ + dbgFormat, \ + dbgArg1, \ + dbgArg2, \ + dbgArg3); \ + kMutexUnlock(StatScrSync); \ +} +#define DEBUG_STAT_XY4(x, y, dbgFormat, dbgArg1, dbgArg2, dbgArg3, dbgArg4) if (StatScreenID != NULL) \ +{ \ + kMutexLock(StatScrSync); \ + PositionOutputCursor(StatScreenID, y, x); \ + OutputToScreenWithAttribute(StatScreenID, \ + LGREEN, \ + dbgFormat, \ + dbgArg1, \ + dbgArg2, \ + dbgArg3, \ + dbgArg4); \ + kMutexUnlock(StatScrSync); \ +} +#else +#define DEBUG_TEXT0(dbgFormat) +#define DEBUG_TEXT1(dbgFormat, dbgArg1) +#define DEBUG_TEXT2(dbgFormat, dbgArg1, dbgArg2) +#define DEBUG_TEXT3(dbgFormat, dbgArg1, dbgArg2, dbgArg3) +#define DEBUG_TEXT4(dbgFormat, dbgArg1, dbgArg2, dbgArg3, dbgArg4) +#define DEBUG_STAT0(dbgFormat) +#define DEBUG_STAT1(dbgFormat, dbgArg1) +#define DEBUG_STAT2(dbgFormat, dbgArg1, dbgArg2) +#define DEBUG_STAT3(dbgFormat, dbgArg1, dbgArg2, dbgArg3) +#define DEBUG_STAT4(dbgFormat, dbgArg1, dbgArg2, dbgArg3, dbgArg4) +#define DEBUG_STAT_XY0(x, y, dbgFormat) +#define DEBUG_STAT_XY1(x, y, dbgFormat, dbgArg1) +#define DEBUG_STAT_XY2(x, y, dbgFormat, dbgArg1, dbgArg2) +#define DEBUG_STAT_XY3(x, y, dbgFormat, dbgArg1, dbgArg2, dbgArg3) +#define DEBUG_STAT_XY4(x, y, dbgFormat, dbgArg1, dbgArg2, dbgArg3, dbgArg4) +#endif + + +#endif diff --git a/include/nwnss/include/jsmsgMessageMgmt.h b/include/nwnss/include/jsmsgMessageMgmt.h new file mode 100644 index 0000000..ae5a44e --- /dev/null +++ b/include/nwnss/include/jsmsgMessageMgmt.h @@ -0,0 +1,148 @@ +/**************************************************************************** + | + | (C) Copyright 1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) / Distributed File Services (DFS) + | + |--------------------------------------------------------------------------- + | + | $Author: nbalachandran $ + | $Date: 2007-07-11 17:00:46 +0530 (Wed, 11 Jul 2007) $ + | + | $RCSfile$ + | $Revision: 2086 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Internal definitions and declarations required + / by free message list management routines + +-------------------------------------------------------------------------*/ + + + +#ifndef _JSMSGMESSAGEMGMT_H_ +#define _JSMSGMESSAGEMGMT_H_ + + +/* Dependencies */ +#ifndef _OMNI_H_ +#include +#endif +#ifndef _JSMSG_H_ +#include +#endif + + +/* Manifest constants */ +#ifndef __linux__ +#define JS_MAX_LARGE_BUFFERS (192) /* Default high water mark for messages with large buffers */ +#define JS_MAX_MEDIUM_BUFFERS (1024) /* Default high water mark for messages with medium buffers */ +#define JS_MAX_SMALL_BUFFERS (8192) /* Default high water mark for messages with small buffers */ +#else +#define JS_MAX_LARGE_BUFFERS (4) /* Default high water mark for messages with large buffers */ +#define JS_MAX_MEDIUM_BUFFERS (64) /* Default high water mark for messages with medium buffers */ +#define JS_MAX_SMALL_BUFFERS (256) /* Default high water mark for messages with small buffers */ +#endif +#define JS_MESSAGE_SIZE_COUNT (3) /* The number of default message sizes */ +#define JS_MESSAGE_SIZE_INDEX_LARGE (2) /* The index number for the element to store information on messages with large buffers in arrays of message related data */ +#define JS_MESSAGE_SIZE_INDEX_MEDIUM (1) /* The index number for the element to store information on messages with medium buffers in arrays of message related data */ +#define JS_MESSAGE_SIZE_INDEX_SMALL (0) /* The index number for the element to store information on messages with small buffers in arrays of message related data */ +#ifndef __linux__ +#define JS_MIN_LARGE_BUFFERS (2) /* Default low water mark for messages with large buffers */ +#define JS_MIN_MEDIUM_BUFFERS (32) /* Default low water mark for messages with medium buffers */ +#define JS_MIN_SMALL_BUFFERS (128) /* Default low water mark for messages with small buffers */ +#else +#define JS_MIN_LARGE_BUFFERS JS_MAX_LARGE_BUFFERS /* Default low water mark for messages with large buffers */ +#define JS_MIN_MEDIUM_BUFFERS JS_MAX_MEDIUM_BUFFERS /* Default low water mark for messages with medium buffers */ +#define JS_MIN_SMALL_BUFFERS JS_MAX_SMALL_BUFFERS /* Default low water mark for messages with small buffers */ +#endif +#define JS_CPU_PAGE_LENGTH_BYTES (0x1000) /* The number of bytes in a CPU page */ +#define JS_CPU_PAGE_SIZE_MASK (0x0FFF) /* AND mask to select offset in a page when used with a memory address */ + +#define JS_ALLOC_HWM_LOCK_NAME "JS HWM Lock: " /* The default name for an allocation high water mark access semaphore (lock size is appended to this string when used) */ +#define JS_ALLOC_HWM_LOCK_NAME_LEN_BYTES (20) /* The length in bytes of the longest allocation high water mark name */ + +#define JS_ALLOC_MESSAGE_LIST_LOCK_NAME "JS Alloc Msg Lock" /* The name for the lock that is used to control access to the allocated message list */ + +#define JS_FREE_MESSAGE_LIST_LOCK_NAME "JS Free Queue Lock: " /* The default name for a free message list access lock (lock size is appended to this string when used) */ +#define JS_FREE_MESSAGE_LIST_LOCK_NAME_LEN_BYTES (27) /* The length in bytes of the longest free message list access lock name */ + +#define JS_SIZE_LARGE_NAME "Large" /* The text name for messages with large buffers */ +#define JS_SIZE_MEDIUM_NAME "Medium" /* The text name for messages with medium buffers */ +#define JS_SIZE_SMALL_NAME "Small" /* The text name for messages with small buffers */ + + +#define JS_UNKNOWN_NAME "Unknown" /* Used when a size parameter does not match the default supoprted sizes */ + +#define JS_THREAD_NAME_ALLOC "JSMSG: Allocate Message" /* Name used to rename a thread when it calls JS_AllocateMessage() */ +#define JS_THREAD_NAME_DUP_MSG "JSMSG: Duplicate Message" /* Name used to rename a thread when it calls JS_DuplicateMessage() */ +#define JS_THREAD_NAME_GET_DEF_MSG_SIZES "JSMSG: Get Default Message Sizes" /* Name used to rename a thread when it calls JS_GetDefaultMessageSizes() */ +#define JS_THREAD_NAME_RETIRE "JSMSG: Retire Message" /* Name used to rename a thread when it calls JS_RetireMessage() */ + + +/* + New types +*/ + +/* The general communication message type */ +typedef struct JS_MESSAGE_s +{ + JS_CommMsg_s Msg; /* The message as it is seen by consumers */ + LONG Pages; /* The number of CPU pages that the message is stored in (if it is an exact multiple of the page size), or zero */ + BOOL ExternalBuffer; /* TRUE if the Msg.MessageData field was not allocated by Jetstream */ + GUID_t OwnerID; /* Set to the original owner of the message when an external buffer is used */ + QUAD TimeQueued; /* Set to the current time when a message is placed in a queue */ + BOOL Allocated; /* Set to FALSE when message is on a free list */ + DQlink_t AllocList; /* Links allocated messages */ + void *Allocator; /* Points to the caller that allocated the message */ +} JS_MESSAGE_t; + + +/* + Function prototypes - Internal only + + Prototypes for exported functions can be found in jsmsg.h. If any exported + functions are added to jsmsgMessageMgmt.c do not put their prototypes here, + put them in jsmsg.h +*/ +STATUS JS_AddMessageToFreeList(JS_CommMsg_s * Message); /* Place a message on the appropriate free message list */ +STATUS JS_CleanFreeMessageLists(void); /* Empty the contents of the free message lists */ +STATUS JS_CreateFreeMessageListLocks(void); /* Create access locks for the free message lists */ +JS_CommMsg_s * JS_CreateMessage(size_t MessageSize); /* Create a jetstream message */ +STATUS JS_DestroyFreeMessageListLocks(void); /* Free the access locks for the free message lists */ +STATUS JS_DestroyMessage(JS_CommMsg_s * Message); /* Free a Jetstream message */ +JS_CommMsg_s * JS_FastAllocateMessage(size_t MessageSize, LONG MaxTimeToWait, BOOL IgnoreHWM); /* Minimal cost message allocation - FOR INTERNAL USE ONLY */ +STATUS JS_InitialiseBufferManager(void); /* Initialise the state of the message management module */ +void JS_LockFreeMessageList(LONG ListIndex); /* Exercise the access lock for a free message list */ +LONG JS_PopulateFreeMessageList(LONG MessageSize, LONG NumberToCreate, LONG SizeIndex); /* Initialise the free message lists to the low water mark counts */ +void JS_ResetMessageContents(JS_CommMsg_s * Message); /* Reset the contents of a message */ +JS_CommMsg_s * JS_TakeMessage(size_t MessageSize, LONG MaxTimeToWait, BOOL IgnoreHWM); /* Remove a message from a free message list or create a new one */ +void JS_UnlockFreeMessageList(LONG ListIndex); /* Release an access lock held on a free message list */ +STATUS JS_CreateAllocHWMLocks(void); +STATUS JS_DestroyAllocHWMLocks(void); +STATUS JS_SignalHWMLock(NINT listIndex); +BOOL JS_WaitOnHWMLock(NINT listIndex, LONG maxTimeToWait); + +/* Deletes the SHM and SEM that are still present in the system, usually after an Jet Stream kill */ +void JS_CleanupMsgMgmtResources(void); + +#endif + diff --git a/include/nwnss/include/jsmsgPresInt.h b/include/nwnss/include/jsmsgPresInt.h new file mode 100644 index 0000000..a7a4fc2 --- /dev/null +++ b/include/nwnss/include/jsmsgPresInt.h @@ -0,0 +1,140 @@ +/**************************************************************************** + | + | (C) Copyright 1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) / Distributed File Services (DFS) Module + | + |--------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2005-04-13 22:08:08 +0530 (Wed, 13 Apr 2005) $ + | + | $RCSfile$ + | $Revision: 927 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Provide internal definitions for jsmsgPresentation.c + +-------------------------------------------------------------------------*/ + +#ifndef _JSMSGPRESINT_H_ +#define _JSMSGPRESINT_H_ + +/* Dependencies */ +#ifndef _JSMSGSESSION_H_ +#include +#endif + +/* New types */ + +/* + This structure implements the state information for sessions for which + a consumer wants isolated receive queueing. Each entry in the vertical + list (linked by SessionLink) is a queue of messages received on a + particular session for the consumer state object that holds the head of + the queue. +*/ +typedef struct JS_SessionQNode_s +{ + unicode_t *Session; /* Session ID for which a dispatched receive queue is required */ + DQlink_t SessionLink; /* Links all dispatched sessions for a consumer into a list */ + DQhead_t MessageQueue; /* Received mesasge queue for the dispatched session */ + LONG Messages; /* Number of messages in the receive queue */ + SEMAPHORE RxSignal; /* Trigger to wake-up the consumer if a message is received for the session associated with this instance of this structure and the consumer requested a receive event */ + BOOL EventModeEnabled; /* TRUE if the consumer requested a receive event for this dispatched session */ +} JS_SESSION_Q_NODE_s; + +/* + Internal format of connect and disconnect messages +*/ +typedef struct JS_ConnectMessage_s +{ + GUID_t SourceModule; /* Module ID of module making the connection */ + LONG Address; /* IP address to connect to (network byte order */ + SEMAPHORE Trigger; /* Signaled when the connection is created or connect failed */ + unicode_t * Session; /* Session created */ + BOOL CallerTimeout; /* Caller sets to TRUE if it has timed out waiting for the connect */ +} JS_ConnectMessage_s; + +typedef struct JS_DisconnectMessage_s +{ + GUID_t SourceModule; /* Module ID of the module making the disconnection */ + SEMAPHORE Trigger; /* Signaled when the disconnect completes or fails */ + BOOL Waiting; /* TRUE while the consumer is still waiting for the completion of the disconnect */ + JS_SESSION_t * Session; /* The session to disconnect */ +} JS_DisconnectMessage_s; + + +// manifest constants +#define JS_THREAD_NAME_ALLOC "JSMSG: Allocate Message" /* Name used to rename a thread when it calls JS_AllocateMessage() */ +#define JS_THREAD_NAME_DEQ "JSMSG: De-queue Message" /* Name used to rename a thread when it calls JS_DequeueMessage() */ +#define JS_THREAD_NAME_DEREG "JSMSG: Module De-register" /* Name used to rename a thread when it calls JS_DeregisterModule() */ +#define JS_THREAD_NAME_FAIL_DISCONN "JSMSG: Disconnect for failed connect" /* Name used for a thread that disconencts a physical session for which a logical session could not be created */ +#define JS_THREAD_NAME_EVT "JSMSG: Request Receive Event" /* Name used to rename a thread when it calls JS_RequestReceiveEvent() */ +#define JS_THREAD_NAME_Q "JSMSG: Queue Message" /* Name used to rename a thread when it calls JS_QueueMessage() */ +#define JS_THREAD_NAME_SDEQ "JSMSG: De-queue a Dispatched Message" /* Name used to rename a thread when it calls JS_DequeueDispatchedMessage() */ +#define JS_THREAD_NAME_SDISP "JSMSG: Dispatch Session" /* Name used to rename a thread when it calls JS_DispatchSession() */ +#define JS_THREAD_NAME_SET_MSG_SESSION "JSMSG: Set Message Session" /* Name used to rename a thread when it calls JS_SetMessageSession() */ +#define JS_THREAD_NAME_SEVT "JSMSG: Request Event on Dispatch Queue" /* Name used to rename a thread when it calls JS_RequestDispatchedSessionReceiveEvent() */ +#define JS_THREAD_NAME_SUNDISP "JSMSG: Undispatch Session" /* Name used to rename a thread when it calls JS_UndispatchSession() */ + +#define JS_CONNECT_TIMEOUT (3000) /* Time to wait for a connect to complete, 3 seconds */ +#define JS_DEFAULT_STACK_SIZE_BYTES (8192 - 16) /* Default stack size for a new thread created by Jetstream */ + + +/* Global data */ + + +/* Function prototypes */ +STATUS JS_CleanFreeQueues(void); /* Empty the contents of the free message pools */ +#if zNETWARE +void * JS_FailureDisconnect(THREAD ThreadHandle, void *Argument); /* Disconnect a physical session for which a logical session could not be created */ +#else +void * JS_FailureDisconnect(void *Argument); /* Disconnect a physical session for which a logical session could not be created */ +#endif + +STATUS JS_InitialiseBufferManager(void); /* Setup the free message pools */ +STATUS JS_InitialisePresentationInterface(void); /* Initialise the consumer interfaces */ + +/* Free queue locking */ +STATUS JS_CreateFreeQueueLocks(void); /* Create the access locks for the free message pools */ +STATUS JS_DestroyFreeQueueLocks(void); /* Destroy the access locks for the free message pools */ + +/* Consumer list management */ +JS_SESSION_Q_NODE_s * JS_CreateSessionNode(unicode_t *Session, SEMAPHORE RxSignal); /* Create an entry in the dispatched session list for a consumer */ +void JS_NewIncarnation(void); /* Generate a new incarnation number for Jetstream in response to a state change */ + +/* Transport and module list locking */ +STATUS JS_LockTransportAndModuleQueues(void); /* Lock both the transport and consumer lists */ +STATUS JS_UnlockTransportAndModuleQueues(void); /* Unlock both the transport and consumer lists */ + +/* Internal message processing */ +STATUS JS_ProcessConnectResponse(JS_ConnectMessage_s * ConnectMessage); /* Process a JIC connect response */ +STATUS JS_ProcessDDisconnectResponse(JS_DisconnectMessage_s * DisconnectMessage); /* Process a JIC disconnect response */ +STATUS JS_QueueMessageForConsumer(GUID_t TargetModule, JS_CommMsg_s * Message); +STATUS JS_QueueMessageForLocalTarget(GUID_t TargetID, JS_CommMsg_s * Message); +STATUS JS_QueueMessageForTransport(GUID_t TransportID, JS_CommMsg_s * Message); /* Place a message in the send queue for a transport */ +STATUS JS_ShutdownPresentationInterface(void); /* Cleanup the consumer interfaces */ + + + + +#endif diff --git a/include/nwnss/include/jsmsgPresentation.h b/include/nwnss/include/jsmsgPresentation.h new file mode 100644 index 0000000..c716a45 --- /dev/null +++ b/include/nwnss/include/jsmsgPresentation.h @@ -0,0 +1,65 @@ +/**************************************************************************** + | + | (C) Copyright 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) / Distributed File Services (DFS) + | + |--------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2005-04-13 22:08:08 +0530 (Wed, 13 Apr 2005) $ + | + | $RCSfile$ + | $Revision: 927 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Provide session interfaces to presentation layer (consumer) modules + +-------------------------------------------------------------------------*/ + +#ifndef _JSMSGPRESENTATION_H_ +#define _JSMSGPRESENTATION_H_ + +/* Dependencies */ +#ifndef _JSMSG_H_ +#include +#endif +#ifndef _JSMSGMESSAGEMGMT_H_ +#include +#endif + +/* + Manifest constants +*/ + + +/* New types */ +#ifndef __linux__ +typedef struct JS_SESSION_t JS_SESSION_t; /* Pre-declare a place holder type for logical sessions */ +#endif + + +/* Declarations for globals with extern access */ +extern const GUID_t JS_PRESENTATION_LAYER_ID; /* GUID of the Jetstream internal consumer */ +extern const GUID_t JS_NO_MODULE; /* GUID indicating no specific module is supplied */ + + +#endif diff --git a/include/nwnss/include/jsmsgSessInt.h b/include/nwnss/include/jsmsgSessInt.h new file mode 100644 index 0000000..ecbf386 --- /dev/null +++ b/include/nwnss/include/jsmsgSessInt.h @@ -0,0 +1,112 @@ +/**************************************************************************** + | + | (C) Copyright 1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) / Distributed File Services (DFS) + | + |--------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2005-04-13 22:08:08 +0530 (Wed, 13 Apr 2005) $ + | + | $RCSfile$ + | $Revision: 927 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Provide session interfaces to a transport layer module, internal + / definitions + +-------------------------------------------------------------------------*/ + +#ifndef _JSMSGSESSINT_H_ +#define _JSMSGSESSINT_H_ + +#ifdef __linux__ +#include "jsmsgSession.h" +#endif + +/* New types */ +typedef struct JS_TRANSPORT_NODE_s +{ + DQlink_t TransportLink; + DQhead_t SendQ; +#ifndef __linux__ + LONG Messages; +#endif + GUID_t TransportID; + SEMAPHORE TxSignal; + BOOL EventModeEnabled; +#ifndef __linux__ + LONG BuffersControlled; +#endif +}JS_TRANSPORT_NODE_s; + +typedef struct JS_SESSION_NODE_t +{ + DQlink_t Link; + JS_SESSION_t * Session; +} JS_SESSION_NODE_t; + + +/* Manifest constants */ +#define JS_CONNECT_SEMAPHORE_NAME "JSMSG Connect" /* Name for a semaphore used to signal connect completion */ +#define JS_DISCONNECT_SEMAPHORE_NAME "JSMSG Disconnect" /* Name for a semaphore used to signal disconnect completion */ +#define JS_THREAD_NAME_CONN "JSMSG: Connect" /* Name used to rename a thread when it calls JS_Connect() */ +#define JS_THREAD_NAME_DISCONN "JSMSG: Disconnect" /* Name used to rename a thread when it calls JS_Disconnect() */ +#define JS_THREAD_NAME_FIND_LOG_SESSION "JSMSG: Find Logical Session" /* Name used to rename a thread when it calls JS_FindLogicalSession() */ +#define JS_THREAD_NAME_GETTXMSG "JSMSG: Dequeue a Tx Message" /* Name used to rename a thread when it calls JS_GetTxMessage() */ +#define JS_THREAD_NAME_REQTXEVT "JSMSG: Request a Tx Event" /* Name used to rename a thread when it calls JS_RequestTransmitEvent() */ +#define JS_THREAD_NAME_RXMSG "JSMSG: Receive Message" /* Name used to rename a thread when it calls JS_ReceiveMessage() */ +#define JS_THREAD_NAME_TDEREG "JSMSG: De-register Transport" /* Name used to rename a thread when it calls JS_DeregisterTransport() */ +#define JS_THREAD_NAME_TREG "JSMSG: Register Transport" /* Name used to rename a thread when it calls JS_RegisterTransport() */ +#define JS_THREAD_NAME_UPDT_LOG_SESSION "JSMSG: Update Logical Session" /* Name used to rename a thread when it calls JS_UpdateLogicalSessionState() */ + +#define JS_CONTROL_FAILURE (0xFFFFFFFF) /* General failure COntrolCode for messages */ +#define JS_CONTROL_CONNECT_REQ (0x00000001) /* ControlCode for a connect request */ +#define JS_CONTROL_CONNECT_RESP (0x00000002) /* ControlCode for a connect response */ +#define JS_CONTROL_DISCONNECT_REQ (0x00000003) /* ControlCode for a disconnect request */ +#define JS_CONTROL_DISCONNECT_RESP (0x00000004) /* ControlCode for a disconnect response */ + +#define JS_DEFAULT_SESSION_BIT_RATE (28800) /* Assumed bit rate for sessions until actual rate is discovered */ +#define JS_NAME_OFFSET_IN_SESSION (offsetof(JS_SESSION_t, ObjectName)) /* Offset in bytes from start of a session to the consumer session field */ +#define JS_TO_SESSION_LIST_HEAD_TRIGGER_LEVEL (10) /* Number of iterations to find a session before it is moved to the list head */ + +// Generated GUID for TCP Module ID {C383455E-4E83-11d3-AB6E-0008C7D3AF2D} +extern const GUID_t JS_TCP_MODULE_ID; /* Extern access to the module ID for the TCP transport */ + + +/* Function prototypes */ +STATUS JS_ConnectLogicalSession(JS_SESSION_t *Session, GUID_t TransportID, void * TransportSession, BOOL MadeHere); /* Create a logical session for a physical session */ +JS_SESSION_t * JS_CreateLogicalSession(void); /* Create an empty logical session */ +JS_TRANSPORT_NODE_s * JS_CreateTransportNode(GUID_t ModuleID, SEMAPHORE TxSignal); /* Create a transport list entry */ +STATUS JS_DestroyLogicalSession(JS_SESSION_t *Session); /* Destroy a logical session */ +void JS_DetachMessageFromSession(JS_CommMsg_s * Message); /* Disociate a message from a session */ +STATUS JS_DisconnectLogicalSession(JS_SESSION_t * Session); /* Begin the disconnect process for a session */ +JS_TRANSPORT_NODE_s * JS_FindTransportID(GUID_t ModuleID); /* Find a transport module's list node */ +STATUS JS_InitialiseSessionInterface(void); /* Initialise the transport interfaces */ +BOOL JS_IsSessionInSessionList(JS_SESSION_t *Session); /* Confirms a session is in the session list */ +JS_SESSION_t * JS_LogicalSessionFromAppSession(unicode_t *AppSession); /* Convert a consumer session ID to a logical session */ +STATUS JS_MoveLogicalSessionToListHead(JS_SESSION_t * Session); /* Move a logical session to the head of the session list (speeds finding it) */ +STATUS JS_SetSessionName(unicode_t *Session, unicode_t *NewName); /* Set the authenticated name of the remote end of a session */ +STATUS JS_ShutdownSessionInterface(void); /* Closedown the transport interfaces */ + + +#endif diff --git a/include/nwnss/include/jsmsgSession.h b/include/nwnss/include/jsmsgSession.h new file mode 100644 index 0000000..4636ef1 --- /dev/null +++ b/include/nwnss/include/jsmsgSession.h @@ -0,0 +1,100 @@ +/**************************************************************************** + | + | (C) Copyright 1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) / Distributed File Services (DFS) module + | + |--------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2006-08-10 04:52:08 +0530 (Thu, 10 Aug 2006) $ + | + | $RCSfile$ + | $Revision: 1470 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Provide session interfaces to a transport layer module + +-------------------------------------------------------------------------*/ + +#ifndef _JSMSGSESSION_H_ +#define _JSMSGSESSION_H_ + +/* Dependencies */ +#ifndef _JSMSG_H_ +#include +#endif + +/* New types */ + +/* + This structure defines a Jetstream logical session. + The address of the ObjectName field is the consumer logical session +*/ +typedef struct JS_SESSION_t +{ + DQlink_t Link; /* Link between sessions */ + DQlink_t DebugLink; + GUID_t TransportID; /* GUID of the transport that hosts the physical session associated with the logical session represented by an instance of this structure */ + void * TransportSession; /* The address of the physical session, only used to allow transport modules to find a logical session for a physical one */ + BOOL Connected; /* TRUE if no attempt has been made to disconnect the session, actual disconnect may happen long after request */ + BOOL ConnectionMadeHere; /* TRUE if the connection was made from this node */ + BOOL Disconnecting; /* TRUE if a disconnect is in progress */ + LONG UseCount; /* Count of the number of messages associated with this session */ + BOOL Destroy; /* TRUE if a disconnect was requested and the use count has reached zero */ + LONG LastSendDuration; /* Time in milliseconds that it took to complete the last send */ + LONG PendingSends; /* Count of pending sends when LastSendDuration was updated */ + LONG PendingBits; /* Number of bits pending send */ + LONG LastReceiveQDelay; /* Time in milliseconds that the last message taken from a consumer receive queue spent on that queue */ + LONG SessionBitRate; /* The average bit rate for recent transmissions on this session */ + unicode_t ObjectName[256]; /* This must be the last field in this structure */ +} JS_SESSION_t; + + +/* Function prototypes */ + +/* Module Registration */ +STATUS JS_RegisterTransport(GUID_t ModuleID, SEMAPHORE TxSignal); /* Register a transport module */ +STATUS JS_DeregisterTransport(GUID_t ModuleID); /* De-register a transport module */ + +/* Communications management */ +STATUS JS_Connect(GUID_t TransportID, void * TransportSession, BOOL MadeHere); /* Used by a transport to create a logical session associated with a physical session */ +STATUS JS_Disconnect(void * Session, BOOL FromHere); /* Used by a transport to indicate a physical session has been closed */ + +/* Message Communication */ +STATUS JS_RequestTransmitEvent(GUID_t ModuleID); /* Used by a transport module to request an event when a message is available in its transmit queue */ +JS_CommMsg_s * JS_GetTxMessage(GUID_t ModuleID); /* Used by a transport module to obtain a message for transmission */ +STATUS JS_RxMessage(JS_CommMsg_s * Message, GUID_t TargetModule); /* Used by a transport module to supply a received message to a consumer */ + +/* Message Management */ +STATUS JS_SetMessageSession(JS_CommMsg_s * Message, unicode_t * Session); /* Used to set the logical session a message is associated with */ + +/* Session management */ +JS_SESSION_t * JS_FindLogicalSession(void * TransportSession); /* Used by a transport module to find the logical session associated with a physical session */ +STATUS JS_UpdateLogicalSessionState(GUID_t TransportID, /* Called by a transport to notify logical session state changes, e.g. sends completing, etc. */ + void *PhysicalSession, + LONG CompleteSends, + LONG CompleteBits, + LONG NewBitRate, + BOOL InstantaneousBitRate); +void JS_ReleaseSession(JS_SESSION_t *session); /* Decrement session's use count */ + +#endif diff --git a/include/nwnss/include/latch.h b/include/nwnss/include/latch.h index 70b0f19..f506dd1 100644 --- a/include/nwnss/include/latch.h +++ b/include/nwnss/include/latch.h @@ -44,23 +44,23 @@ #define _LATCH_H_ #ifndef _PSSMPK_H_ -# include +# include #endif #ifndef _QUE_H_ -# include +# include #endif #ifndef _PSSDEBUG_H_ -# include +# include #endif #ifndef _FSM_H_ -# include +# include #endif #ifndef _PARSE_H_ -#include +#include #endif #ifdef __cplusplus @@ -297,14 +297,6 @@ typedef struct Latch_s // Under Linux RunningProcess is a macro extern ADDR RunningProcess; #endif -#if defined(__linux__) && !defined(__KERNEL__) -#ifndef _SCHEDULE_H_ -# include -#endif -#ifndef RunningProcess -# define RunningProcess ThreadId() -#endif -#endif #define CLEAR_THREAD(_latch) ((_latch)->L_thread = 0) #define SET_THREAD(_latch) ((_latch)->L_thread = RunningProcess) @@ -517,18 +509,18 @@ extern void LBL_xSignal(Latch_s *); { \ _latch->count = 1; \ SET_FSM(_latch, fsm); \ - ((void (*)(struct FsmLite_s *))(action))(fsm); \ + action(fsm); \ } \ else if ((_latch->count > IDLE_LATCH_STATE) \ && (CIR_EMPTY(_latch->waiting))) \ { \ ++_latch->count; \ CLEAR_THREAD(_latch); \ - ((void (*)(struct FsmLite_s *))(action))(fsm); \ + action(fsm); \ } \ else \ { \ - LBL_fsmSwait(_latch, fsm, (voidfunc_t)(action)); \ + LBL_fsmSwait(_latch, fsm, action); \ } \ } @@ -587,11 +579,11 @@ extern void LBL_xSignal(Latch_s *); { \ _latch->count = X_LATCH_STATE; \ SET_FSM(_latch, fsm); \ - ((void (*)(struct FsmLite_s *))(action))(fsm); \ + action(fsm); \ } \ else \ { \ - LBL_fsmXwait(_latch, fsm, (voidfunc_t)(action)); \ + LBL_fsmXwait(_latch, fsm, action); \ } \ } @@ -674,17 +666,17 @@ extern void LBL_xSignal(Latch_s *); { \ _latch->count = X_LATCH_STATE; \ SET_FSM(_latch, fsm); \ - ((void (*)(struct FsmLite_s *))(action))(fsm); \ + action(fsm); \ } \ else \ { \ LBL_sSignal(_latch); \ - LBL_fsmXwait(_latch, fsm, (voidfunc_t)(action)); \ + LBL_fsmXwait(_latch, fsm, action); \ } \ } \ else \ { \ - LBL_fsmXwait(_latch, fsm, (voidfunc_t)(action)); \ + LBL_fsmXwait(_latch, fsm, action); \ } \ } @@ -893,18 +885,18 @@ extern void LBL_unLatch(Latch_s * STRING_ARG); #define S_LATCH(latch) ((void)LBL_sLatch(latch WHENCE)) #define S_NOWAIT(latch, rtn) (rtn = LBL_sNoWait(latch WHENCE)) #define FSM_S_LATCH(latch, fsm, action) \ - ((void)LBL_fsmSlatch(latch,fsm,(voidfunc_t)(action) WHENCE)) + ((void)LBL_fsmSlatch(latch,fsm,action WHENCE)) #define X_LATCH(latch) ((void)LBL_xLatch(latch WHENCE)) #define X_NOWAIT(latch, rtn) (rtn = LBL_xNoWait(latch WHENCE)) #define FSM_X_LATCH(latch, fsm, action) \ - ((void)LBL_fsmXlatch(latch,fsm,(voidfunc_t)(action) WHENCE)) + ((void)LBL_fsmXlatch(latch,fsm,action WHENCE)) #define X_BARRIER(latch) ((void)LBL_xBarrier(latch WHENCE)) #define UP_LATCH(latch) ((void)LBL_upLatch(latch WHENCE)) #define UP_NOWAIT(latch, rtn) (rtn = LBL_upNoWait(latch WHENCE)) #define FSM_UP_LATCH(latch, fsm, action) \ - ((void)LBL_fsmUpLatch(latch,fsm,(voidfunc_t)(action) WHENCE)) + ((void)LBL_fsmUpLatch(latch,fsm,action WHENCE)) #define DOWN_LATCH(latch) LBL_downLatch(latch WHENCE) #define UNS_LATCH(latch) LBL_unsLatch(latch WHENCE) @@ -955,17 +947,17 @@ extern void DBGL_DumpLatches( char **commandL); #define LATCH_HASH_COUNT (1<<10) /** 1024 **/ -#define LATCH_HASH_MASK (LATCH_HASH_COUNT-1) +#define LATCH_HASH_MASK (LATCH_HASH_COUNT-1) extern STKtop_t DBGL_LatchPages; - + #endif /* NSS_DEBUG */ -extern NINT Latch_All(); -extern NINT Latch_Free(); +extern NINT Latch_All(); +extern NINT Latch_Free(); extern NINT Latch_Holder(); -extern NINT Latch_Waiter(); +extern NINT Latch_Waiter(); STATUS doLatchInstDisplay ( struct PCLSwitchDef_s *switchDef, diff --git a/include/nwnss/include/linuxmpk.h b/include/nwnss/include/linuxmpk.h new file mode 100644 index 0000000..0e06dc4 --- /dev/null +++ b/include/nwnss/include/linuxmpk.h @@ -0,0 +1,50 @@ +/**************************************************************************** + | + | Copyright (C) 2002-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |***************************************************************************/ +/**************************************************************************** + * + * File Name: linuxmpk.h + * + * File Created: 07/07/2003 + * + * Engineering Contact: K.Y. Srinivasan + * + * Target Platform: COMMON_SOURCE + * + * + * File Description: + * An implementation of the NetWare MP in the Linux Kernel. We have + * initially imlemented a subset of the APIs and semantics. + **************************************************************************** + */ + +#ifndef LINUX_MPK_H +#define LINUX_MPK_H + +#include "mpk.h" +#include "mpkmisc.h" +#include "mpkerrno.h" +#include "nebmpk.h" +#include "nebprivate.h" +#include "mpkutil.h" + + +#endif /* LINUX_MPK_H */ diff --git a/include/nwnss/include/lsa.h b/include/nwnss/include/lsa.h index 926f043..bfe59f4 100644 --- a/include/nwnss/include/lsa.h +++ b/include/nwnss/include/lsa.h @@ -39,7 +39,7 @@ #define _LSA_H_ #ifndef _ZOMNI_H_ -#include +#include #endif #ifndef _LINUX_LIMIS_H @@ -64,7 +64,7 @@ enum { LSA_ROOT_INO = 1, LSA_NAME_LEN = (3*NAME_MAX), /* Account for UTF 8 names */ LSA_MAX_FILE_SIZE = 1LL << 43, - LSA_VERSION = 1, /* Increment when on disk inode format changes */ + LSA_VERSION = 1, /* Increment when on disk inode format changes */ LSA_MAGIC_SB = 1853059840 }; @@ -91,7 +91,7 @@ struct LsaSuper_s struct inode *sb_inode; #define LSA_ROOT_PATH 6 /* Add 6 for _IV_ and :/ */ - BYTE sb_volName[zMAX_COMPONENT_NAME+LSA_ROOT_PATH]; /* volume/pool + BYTE sb_volName[zMAX_COMPONENT_NAME+LSA_ROOT_PATH]; /* volume/pool name with :/ added */ }; @@ -121,11 +121,7 @@ extern int LSA_GetOptions( typedef struct LsaInode_s { struct File_s *li_beast; -#ifdef NSS_USERSPACE - struct inode *li_inode; -#else struct inode li_inode; -#endif } LsaInode_s; @@ -256,3 +252,4 @@ extern struct inode *lsa_get_inode(VolumeID_t *volID, Zid_t zid); extern struct inode *(*Ptr_lsa_get_inode)(VolumeID_t *volID, Zid_t zid); #endif + diff --git a/include/nwnss/include/mailbox.h b/include/nwnss/include/mailbox.h index 6ac81b7..0e41edc 100644 --- a/include/nwnss/include/mailbox.h +++ b/include/nwnss/include/mailbox.h @@ -44,7 +44,7 @@ #define _MAILBOX_H_ #ifndef _OMNI_H_ -# include +# include #endif #ifdef __cplusplus diff --git a/include/nwnss/include/mal.h b/include/nwnss/include/mal.h index 17f2ec5..0d99cc2 100644 --- a/include/nwnss/include/mal.h +++ b/include/nwnss/include/mal.h @@ -80,7 +80,7 @@ extern "C" { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -/*- Deposit Message Type Defined +/*- Deposit Message Type Defined | | +-------------------------------------------------------------------------*/ @@ -118,3 +118,5 @@ extern STATUS ZLSS_SetPoolShared(struct block_device *dev, BOOL sharedstate); #endif #endif /* _MAL_H_ */ + + diff --git a/include/nwnss/include/manage.h b/include/nwnss/include/manage.h index f8dfb57..582607c 100644 --- a/include/nwnss/include/manage.h +++ b/include/nwnss/include/manage.h @@ -39,27 +39,21 @@ #define _MANAGE_H_ #ifndef _XMLNSS_H_ -# include +# include #endif #ifndef _ZPARAMS_H_ -# include +# include #endif #if zLINUX && !defined(__KERNEL__) -#ifndef MPKNSS_LOCK #define MPKNSS_LOCK() ((void) 0) -#endif -#ifndef MPKNSS_UNLOCK #define MPKNSS_UNLOCK() ((void) 0) -#endif -#ifndef ASSERT_MPKNSS_LOCK #define ASSERT_MPKNSS_LOCK() ((void) 0) -#endif // The following comes from clstrlib.h -#define NWCLSTR_LIBNAME "libncssdk.so" +#define NWCLSTR_LIBNAME "libncssdk.so" typedef enum _CLSTR_ERRORS { CLSTR_OK, CLSTR_UNKNOWN, @@ -134,15 +128,15 @@ typedef struct FreezeThawEntry_s * indicates that FTE_ThawStatus is valid. Also * indicates that FTE_ThawOpRetCode is valid. */ - STATUS FTE_ThawStatus; /* Status from zPoolThaw call (valid - * when FTE_ThawIsDone is TRUE). - */ + STATUS FTE_ThawStatus; /* Status from zPoolThaw call (valid + * when FTE_ThawIsDone is TRUE). + */ BOOL FTE_FreezeIsDone; /* TRUE when zPoolFreeze is done and indicates * that FTE_FreezeStatus is valid. */ - STATUS FTE_FreezeStatus; /* Status from zPoolFreeze call (valid - * when FTE_FreezeIsDone is TRUE). - */ + STATUS FTE_FreezeStatus; /* Status from zPoolFreeze call (valid + * when FTE_FreezeIsDone is TRUE). + */ // OneShot_s FI_Timer; /* Timer used for timeout generation */ // FsmLite_s FTE_zPoolFreezeFSMLite; BOOL FTE_ThreadScheduled; @@ -163,7 +157,7 @@ typedef struct FreezeThawEntry_s LONG FTE_TimeOut; LONG FTE_TimeOutUTCTime; /* UTC of when time out should occur */ struct FreezeApplicationStatus_s *FTE_FreezeApplicationStatus; - void *FTE_ThawKey; + void *FTE_ThawKey; unicode_t FTE_PoolName[zMAX_COMPONENT_NAME]; } FreezeThawEntry_s; @@ -216,7 +210,7 @@ void MANAGE_Shutdown(); #if zLINUX && !defined(__KERNEL__) STATUS LINUX_GetPoolSnapshotType( - BOOL openEVMSEngine, + BOOL openEVMSEngine, utf8_t *poolName, POOLSNAP_TYPE *snapshotType); #endif @@ -234,8 +228,8 @@ STATUS MNSS_GetTagContents( STATUS MNSS_ProcessElements( struct VirtInfo_s *virtInfo, utf8_t *parentTag, - struct XML_ElementInfo_s *parentElement, - struct SiblingElements_s *elements); + struct XML_ElementInfo_s *parentElement, + struct SiblingElements_s *elements); STATUS MANAGE_nssCommand( NINT parmLen, diff --git a/include/nwnss/include/manageNDS.h b/include/nwnss/include/manageNDS.h new file mode 100644 index 0000000..2cc2d29 --- /dev/null +++ b/include/nwnss/include/manageNDS.h @@ -0,0 +1,66 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Prototypes for kernel functions in ManageNDS.c + | + +-------------------------------------------------------------------------*/ + +#ifndef _MANAGE_NDS_H_ +#define _MANAGE_NDS_H_ + +#ifndef _ZPARAMS_H_ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern STATUS MNDS_CheckVolumesPool( + char *volName, + utf8_t *poolName, + BOOL *matchedPool); + +extern STATUS DoesPoolExist(utf8_t *poolName, VolumeID_t *poolID, NDSid_t *ndsID); + +extern STATUS DoesVolumeExist(utf8_t *volName); + +extern STATUS SetNDSInfoOnPool(unicode_t *uniPoolName, zInfo_s *info); + +#ifdef __cplusplus +} +#endif + +#endif /* _MANAGE_NDS_H_ */ + diff --git a/include/nwnss/include/manageNlm.h b/include/nwnss/include/manageNlm.h index ffd2d6a..72ac1f6 100644 --- a/include/nwnss/include/manageNlm.h +++ b/include/nwnss/include/manageNlm.h @@ -39,22 +39,22 @@ #define _MANAGENLM_H_ #ifndef _MGMT_H_ -# include +# include #endif #ifndef _XMLNSS_H_ -# include +# include #endif #if zNETWARE || (zLINUX && defined(__KERNEL__)) #ifndef _MMPUBLIC_H_ -#include +#include #endif #endif #if zNETWARE || (zLINUX && defined(__KERNEL__)) #ifndef _VOLUME_H_ -#include +#include #endif #ifndef _CLSTRLIB_H_ @@ -137,7 +137,7 @@ typedef struct Partition_Info_s NINT type; OBID devID; OBID mirrorID; - OBID partID; + OBID partID; LONG devStatus; LONG devUnitSize; QUAD freeSpaceSize; @@ -149,7 +149,7 @@ typedef struct Pool_Segment_s { DQlink_t next; OBID devID; - OBID partID; // In the case of mirroring, this is the mirrorID + OBID partID; // In the case of mirroring, this is the mirrorID QUAD offset; QUAD numSector; LONG devUnitSize; @@ -331,7 +331,7 @@ STATUS GetBeastInfoXML( BOOL getCompBeastInfo, Zid_t zid, NINT typeOfInfo, /* in */ - NINT *bufLen, /* in/out */ + NINT *bufLen, /* in/out */ utf8_t *buf); STATUS SetBeastInfoXML( @@ -340,7 +340,7 @@ STATUS SetBeastInfoXML( Zid_t zid, BOOL ignoreOpenFile, BOOL oldDataMatch, - NINT bufLen, /* in */ + NINT bufLen, /* in */ utf8_t *buf); STATUS DeleteBeast( @@ -466,13 +466,13 @@ extern char *MLIB_GetPoolStateName( #if zLINUX && !defined(__KERNEL__) extern STATUS LINUX_GetPoolSharedState( BOOL openEVMSEngine, - utf8_t *poolName, + utf8_t *poolName, BOOL *isShared); #endif #if zNETWARE || (zLINUX && defined(__KERNEL__)) extern STATUS MLIB_GetPoolSharedState( - const utf8_t *poolName, + const utf8_t *poolName, BOOL *isShared); extern STATUS ModifyNFAPAutoExec( diff --git a/include/nwnss/include/managePool.h b/include/nwnss/include/managePool.h new file mode 100644 index 0000000..d722b0f --- /dev/null +++ b/include/nwnss/include/managePool.h @@ -0,0 +1,71 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: gpachner $ + | $Date: 2007-09-12 01:30:36 +0530 (Wed, 12 Sep 2007) $ + | + | $RCSfile$ + | $Revision: 2198 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Prototypes for kernel functions in ManageNDS.c + | + +-------------------------------------------------------------------------*/ + +#ifndef _MANAGE_POOL_H_ +#define _MANAGE_POOL_H_ + +#ifndef _ZPARAMS_H_ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define EVMS_DEVICE_PATH "/dev/evms/" + +extern NINT GetPoolLSSType(unicode_t *uniPoolName); + +extern STATUS ChangePoolState(unicode_t *uniPoolName, NINT newPoolState, NINT mode); + +extern STATUS GetPoolID(unicode_t *uni_poolName, VolumeID_t *poolID); + +extern NINT GetPoolState(unicode_t *uniPoolName); + +extern STATUS GetNextVolumeInfo(unicode_t *uniPoolName, BOOL firstTime, BOOL deletedVolume, GUID_t *cookie, unicode_t *uniVolName, NINT uniVolNameLen); + +extern STATUS GetLSSFeatures(LONG lssID, QUAD *volSupportedFeatures, QUAD *volDefaultEnabledFeatures, QUAD *volChangableFeatures); + +extern STATUS DismountAndRemovePoolVolumesEntries(utf8_t *poolName, BOOL removeMountPointFolder); + +#ifdef __cplusplus +} +#endif + +#endif /* _MANAGE_POOL_H_ */ + diff --git a/include/nwnss/include/comnAudit.h b/include/nwnss/include/manageServer.h similarity index 66% rename from include/nwnss/include/comnAudit.h rename to include/nwnss/include/manageServer.h index 749435a..ea7aada 100644 --- a/include/nwnss/include/comnAudit.h +++ b/include/nwnss/include/manageServer.h @@ -1,6 +1,6 @@ /**************************************************************************** | - | (C) Copyright 2001-2002 Novell, Inc. + | (C) Copyright 2001-2003 Novell, Inc. | All Rights Reserved. | | This program is free software; you can redistribute it and/or @@ -20,49 +20,45 @@ | |*************************************************************************** | - | NetWare Loadable Storage Services (LSS) module + | Novell Storage Services (NSS) support module | |--------------------------------------------------------------------------- | - | $Author: $ - | $Date: $ + | $Author: ajack $ + | $Date: 2006-12-14 21:29:37 +0530 (Thu, 14 Dec 2006) $ | | $RCSfile$ - | $Revision: $ + | $Revision: 1770 $ | |--------------------------------------------------------------------------- | This module is used to: + | Prototypes for kernel functions in ManageServer.c + | +-------------------------------------------------------------------------*/ -#ifndef _COMNAUDIT_H_ -#define _COMNAUDIT_H_ +#ifndef _MANAGE_SERVER_H_ +#define _MANAGE_SERVER_H_ + +#ifndef _ZPARAMS_H_ +#include +#endif #ifdef __cplusplus extern "C" { #endif -#ifndef AUDIT_KERNEL_OTHER -#define AUDIT_KERNEL_OTHER 1316 -#endif - -extern BOOL NSSLAF_AuditEnabled; - -extern void NSSLAF_LogTrusteeChange( - GeneralMsg_s *genMsg, - NamingMsg_s *nameMsg, - LONG mode, - UserID_t *trustee, - NINT rights, - NINT attributes, - NINT inheritedRights); - -#define NSSLAF_MODE_ADD_TRUSTEE 1 -#define NSSLAF_MODE_REMOVE_TRUSTEE 2 -#define NSSLAF_MODE_SET_INHERITED_RIGHTS 3 - +extern STATUS GetNextPoolName(BOOL firstTime, + SQUAD *cookie, + unicode_t *uniName, + NINT uniNameLen, + BOOL noSnapshot, + NINT *poolState, + BOOL *isShared, + QUAD *enabledAttr); #ifdef __cplusplus } #endif -#endif /* #ifdef _COMNAUDIT_H_ */ +#endif /* _MANAGE_SERVER_H_ */ + diff --git a/include/nwnss/include/manageUserSpaceRestr.h b/include/nwnss/include/manageUserSpaceRestr.h new file mode 100644 index 0000000..c308f6e --- /dev/null +++ b/include/nwnss/include/manageUserSpaceRestr.h @@ -0,0 +1,72 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Prototypes for kernel functions in manageUserSpaceRestr.c + | + +-------------------------------------------------------------------------*/ +#ifndef _MANAGE_USERSPACERESTR_H_ +#define _MANAGE_USERSPACERESTR_H_ + +/*#ifndef _ZPARAMS_H_ +#include +#endif +*/ +#ifdef __cplusplus +extern "C" { +#endif + +extern STATUS GetNextUserInVolume( + unicode_t *uniVolName, + UserID_t *lastUser, + SQUAD *restrictionAmount, + SQUAD *usedAmount, + NINT *numEntries); + +extern STATUS SetUserSpaceRestriction( + unicode_t *uniVolName, + NDSid_t userGUID, + SQUAD quota); + +extern STATUS GetUserSpaceRestriction( + unicode_t *uniVolName, + NDSid_t userGUID, + SQUAD *usedAmount, + SQUAD *restrictionAmount); + +#ifdef __cplusplus +} +#endif + +#endif /* _MANAGE_USERSPACERESTR_H_ */ + diff --git a/include/nwnss/include/manageVolume.h b/include/nwnss/include/manageVolume.h new file mode 100644 index 0000000..85e047f --- /dev/null +++ b/include/nwnss/include/manageVolume.h @@ -0,0 +1,128 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: gpachner $ + | $Date: 2007-09-12 01:30:36 +0530 (Wed, 12 Sep 2007) $ + | + | $RCSfile$ + | $Revision: 2198 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Prototypes for kernel functions in ManageVolume.c + | + +-------------------------------------------------------------------------*/ + +#ifndef _MANAGE_VOLUME_H_ +#define _MANAGE_VOLUME_H_ + +#ifndef _ZPARAMS_H_ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define MANAGE_VOLUME_ERROR_FINDING_POOL 0 +#define MANAGE_VOLUME_ERROR_CREATING_VOLUME 1 +#define MANAGE_VOLUME_ERROR_FINDING_VOLUME 2 +#define MANAGE_VOLUME_ERROR_LOCK_VOLUME 3 +#define MANAGE_VOLUME_ERROR_SETTING_VOLUME_ATTRS 4 +#define MANAGE_VOLUME_ERROR_GET_ROOT_KEY 5 +#define MANAGE_VOLUME_ERROR_OPEN_ADMIN 6 +#define MANAGE_VOLUME_ERROR_GETTING_VOLUME_INFO 7 +#define MANAGE_VOLUME_ERROR_CONVERT_VOL_PASSWORD 8 +#define MANAGE_VOLUME_ERROR_ACTIVATING_VOLUME 9 +#define MANAGE_VOLUME_ERROR_DEACTIVATING_VOLUME 10 +#define MANAGE_VOLUME_ERROR_VOLUME_NOT_ACTIVE 11 +#define MANAGE_VOLUME_ERROR_REMOVING_USER 12 +#define MANAGE_VOLUME_ERROR_OUT_OF_MEMORY 13 +#define MANAGE_VOLUME_ERROR_IOCTL_FAILED 14 + +typedef enum +{ + DELETE_ACTION_SALVAGE, + DELETE_ACTION_PAUSE, + DELETE_ACTION_CONTINUE, + DELETE_ACTION_PURGE +} deletedVolumeAction_t; + +extern NINT GetAuthModelID(utf8_t *name); +extern STATUS CreateVolumeInPool(unicode_t *poolName, + unicode_t *volumeName, + NINT authModelID, + GUID_t volumeGUID, + unicode_t *password, + BOOL *isClustered, + NINT *errIndex); +extern STATUS SetNDSInfoOnVolume(unicode_t *uniVolName, zVolumeInfo_s *info, BOOL lock, BOOL onlineOnly); +extern STATUS ModifyVolumeAttributes(unicode_t *uniVolName, + NINT modifyInfoMask, + zVolumeInfo_s *info, + NINT readAhead, + NINT *errIndex); +extern STATUS GetNSSVolumeHostPool(utf8_t *volumeName, utf8_t *poolName); +extern STATUS GetDeletedVolumeLSSInfo( + utf8_t *volumeName, + unicode_t *uni_volName, + utf8_t *buf, + NINT bufLen, + NINT *retLen); +extern STATUS NSSVolumeFound(unicode_t *uni_volName, + BOOL include_internal, + BOOL *isDeleted, + NINT *readAhead, + NINT *volumeState, + utf8_t *authModelName, + UserID_t *volNameGUID); +extern STATUS GetZInfo(BYTE *path, QUAD getInfoMask, zInfo_s *info, NINT *errIndex); +extern STATUS RemoveNSSVolume(unicode_t *uniVolName); +extern STATUS GetNDSNameFromGUID(unicode_t *uniVolName, utf8_t *objectName); +extern STATUS RenameNSSVolume(unicode_t *uniVolName, unicode_t *uniNewName); +extern STATUS ChangeVolumeState(unicode_t *uniVolName, + BOOL activateVolume, + utf8_t *volumePassword, + NINT *errIndex); +extern STATUS PerformDeletedVolumeAction(unicode_t *uniVolName, deletedVolumeAction_t action); +extern STATUS RenameSalvagedVolume(unicode_t *uniVolName, unicode_t *uniNewName, NINT *state); +extern STATUS RemoveUserFromIDStore(unicode_t *volumeName, UserID_t *userID, NINT *errIndex); +extern STATUS GetNextVolumeName(BOOL firstTime, + SQUAD *cookie, + unicode_t *uniName, + NINT uniNameLen, + BOOL *isLogical); +extern STATUS DismountAndRemoveVolumeEntries(utf8_t *volumeName, + utf8_t **returnMsg, + BOOL lazyUmount, + BOOL removeMountPointFolder); + +#ifdef __cplusplus +} +#endif + +#endif /* _MANAGE_VOLUME_H_ */ + diff --git a/include/nwnss/include/mdb_dev.h b/include/nwnss/include/mdb_dev.h new file mode 100644 index 0000000..6f0d21f --- /dev/null +++ b/include/nwnss/include/mdb_dev.h @@ -0,0 +1,75 @@ +/**************************************************************************** + | + | (C) Copyright 2007 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (PSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-30 12:40:58 -0700 (Thu, 30 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Defines structures and commands for the + | character special device for reading/writing + | kernel memory for debugging tools. + +-------------------------------------------------------------------------*/ +#ifndef _MDB_DEV_H_ +#define _MDB_DEV_H_ 1 + +#define DEV_NAME "kmdb" +#define FULL_DEV_NAME "/dev/" DEV_NAME + +enum { MDB_READ, /* Read size bytes from kernel memory */ + MDB_WRITE, /* Write size bytes of data to kernel memory */ + MDB_PID2TASK, /* Convert a pid to a task pointer */ + MDB_PAGE_READ, /* Read data from an unmapped page */ + MDB_PAGE_WRITE, /* Write data to an unmapped page */ + MDB_OPS }; + +typedef struct Mdb_s { + unsigned mdb_cmd; /* Command */ + union { + struct { + unsigned mdb_size; /* Size of user buffer */ + unsigned long mdb_buf; /* User buffer */ + unsigned long mdb_addr; /* Address to read/write */ + }; + struct { + unsigned pid_pid; /* Pid to convert */ + unsigned long pid_task; /* Task for pid */ + }; + struct { + unsigned pg_size; /* Size of user buffer */ + unsigned long pg_buf; /* User buffer */ + unsigned long pg_addr; /* struct page address */ + unsigned long pg_offset; /* Offset in page */ + }; + }; +} Mdb_s; + + +#endif + diff --git a/include/nwnss/include/mpk.h b/include/nwnss/include/mpk.h new file mode 100644 index 0000000..5f7056b --- /dev/null +++ b/include/nwnss/include/mpk.h @@ -0,0 +1,833 @@ +/**************************************************************************** + | + | (C) Copyright 2002-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | File Name: mpk.h + | + | File Created: 07/07/2003 + | + | Engineering Contact: K.Y. Srinivasan + | + | Target Platform: COMMON_SOURCE + | + | + | File Description: + | An implementation of the NetWare MP in the Linux Kernel. We have + | initially imlemented a subset of the APIs and semantics. + |*************************************************************************** + | + | $Author: rjorgensen $ + | $Date: 2006-05-23 21:57:29 +0530 (Tue, 23 May 2006) $ + | + | $RCSfile$ + | $Revision: 1370 $ + | + ****************************************************************************/ + +#ifndef MPK_H +#define MPK_H + + + +#include +#include +#include +#include +#include +#include + +#ifdef _OMNI_H_ +#ifdef PAGE_SIZE +#undef PAGE_SIZE +#endif +#endif + +#include "nwcore.h" + +/* + * MPK type definitions. + */ +#ifdef ADDR +#undef ADDR +#endif + +#define MAX_NAME_LENGTH 103 /* Must be 1 less than a + * multiple of 4 + * to force proper alignment of + * structs + */ +#define MPK_MAX_CONCURRENCY 128 +#define THREAD_ATTRIBUTE_JOINABLE 0x00000001 +#define NOT_BOUND_TO_CPU -1 + +/* + * One of Paul's files zomni.h defines these types. + */ + +#ifndef _ZOMNI_H_ + +typedef unsigned char BYTE; +typedef unsigned short WORD; +typedef unsigned int LONG; +typedef unsigned long ADDR; +#endif + +#ifdef _OMNI_H_ +#define PAGE_SIZE 4096 +#endif +typedef int BOOLEAN; + +typedef int ERROR; +typedef unsigned int UINT32; +typedef unsigned int UINT; +typedef unsigned int PROCESSOR; +typedef unsigned long FLAGS; +typedef void CONTEXT; + + +#define TRUE 1 +#define FALSE 0 + +#define MPK_MAX_MODULES 10 + +typedef struct mpkPrivateData { + unsigned long size; + char *lowAddr; + char *highAddr; + char *nextAlloc; + char *nextFree; + unsigned long nextFreeSize; +} mpkPrivateData_t; + + +typedef struct mpkModuleMgmt { + void (*mainFunc)(void *); + void *arg; + int inUse; +}mpkModuleMgmt_t; + +typedef struct workMgmtStruct { + spinlock_t lock; + int numWorkElements; + int numWorkThreads; + int numWorkThreadsActive; + struct WorkToDoStructure *first; + struct WorkToDoStructure *last; + struct semaphore sema; + struct WorkToDoStructure *prioFirst; + struct WorkToDoStructure *prioLast; + unsigned int numPrioWorksActive; +} workMgmt_t; + +#define COND_SIGNATURE 0x99999999 +typedef struct kCondition { + char name[MAX_NAME_LENGTH + 1]; + long numWaiters; + unsigned long condSignature; + struct semaphore sema; +} kCondition_t; + +typedef kCondition_t *CONDITION; +typedef kCondition_t *KCONDITION; + +#define CALLOUT_SIGNATURE 0x77777777 + +typedef struct callOutStruct { + unsigned long coutSignature; + void (*pFunction)(void *); // function to call + void *FunctionArgument; // function arg + UINT32 TimeOutValue; // timeout value in ticks (1tick = 10ms) + char fired; + char scheduled; + struct timer_list linuxTimer; +} CALLOUT_STRUCT; + + +#define RWMUTEX_SIGNATURE 0x88888888 + +typedef struct structRwMutex { + unsigned long rwMutexSignature; + spinlock_t lock; + char name[MAX_NAME_LENGTH + 1]; + unsigned int numReaders; + unsigned int numReadersWaiting; + unsigned int lockState; /*0: free; 1: reader; 2: writer*/ + pid_t owner; + int writerBlocked; + struct semaphore readerSema; + struct semaphore writerSema; +} rwMutex_t; + +typedef rwMutex_t * RWLOCK; + + +#define BARRIER_SIGNATURE 0x66666666 +typedef struct structBarrier { + spinlock_t lock; + unsigned long barrierSignature; + unsigned int barrierCount; + unsigned int numCheckedIn; + char name[MAX_NAME_LENGTH + 1]; + struct semaphore sema; +} barrier_t; +typedef barrier_t *BARRIER; + + +#define RWSPIN_LOCK_SIGNATURE 0x55555555 +typedef struct structRwSpinLock { + char name[MAX_NAME_LENGTH + 1]; + unsigned long rwSpinLockSignature; + rwlock_t rwLock; +} rwSpinLock_t; + +typedef rwSpinLock_t *SPINRWLOCK; + +#define SPIN_LOCK_SIGNATURE 0x44444444 +typedef struct structSpinLock { + char name[MAX_NAME_LENGTH + 1]; + unsigned long spinLockSignature; + spinlock_t lock; +} SPINLOCK; + +struct WorkToDoStructure; + +typedef void WorkHandler(struct WorkToDoStructure *); + +typedef struct WorkToDoStructure { + struct WorkToDoStructure *next; + WorkHandler *ProcedureToCall; + unsigned long wtdSignature; + LONG PollCountAmount; + void *arg; +} workToDo_t; + +#define MPK_MUTEX_SIGNATURE 0x33333333 +#define MUTEX_NO_OWNER -1 + +typedef struct structMutex { + unsigned long mutexSignature; + pid_t owner; + int recursionDepth; + struct semaphore sema; + char name[MAX_NAME_LENGTH + 1]; +} mpkMutex_t; + +typedef mpkMutex_t * MUTEX; + + +#define MPK_SEMAPHORE_SIGNATURE 0x22222222 + +typedef struct structSemaphore { + unsigned long semaSignature; + struct semaphore sema; + char name[MAX_NAME_LENGTH + 1]; +} mpkSema_t; + +typedef mpkSema_t *SEMAPHORE; + + +typedef struct LoadDefinitionStructure { + int TBD; +} LoadDefinitionStructure_t; + + +#define MPK_THREAD_SIGNATURE 0x11111111 +typedef struct structThread{ + unsigned long threadSignature; + nwPid_t idState; + int numSuspenders; + int legacyEnterCount; + int error; + char name[MAX_NAME_LENGTH+1]; + char inInitState; + char inSuspension; + char suspendRequest; + char exitRequest; + char threadDetached; + char joinRequest; + char foreignThread; + char anonThread; + unsigned long flags; + void *(*func)(struct structThread *, void *); + void *arg; + void *exitStatus; + void *privData; + struct semaphore threadSema; + struct semaphore threadSuspendSema; + struct semaphore threadExitSema; + struct completion threadExited; + struct timer_list threadTimer; + mpkPrivateData_t threadPrivState; + unsigned long mpkEnterCount; + sigset_t mpkOldMask; + struct semaphore *semaHandle; + int semaError; +} mpkThread_t; + +typedef mpkThread_t *THREAD; + + +/* + * int initThreadPrivState(mpkThread_t *thisThread, unsigned long size) + * Initialize the thread private state. The parameter "size" specifies + * the arena size. The function returns 0 to indicate success; a non-zero + * value is returned to indicate failure. + * + * Calling/Exit State: + * May block. + */ + +int initThreadPrivState(mpkThread_t *thisThread, unsigned long size); + +/* + * void deInitThreadPrivState(mpkThread_t *thisThread) + * De-initialize the private state associated with the thread. + * + * Calling/Exit State: + * May block. + */ + +void deInitThreadPrivState(mpkThread_t *thisThread); + +/* + * int mpkReSizeThreadPrivateState(unsigned long size) + * Resize the the thread private arena. The parameter "size" specifies the + * new arena size. The function returns 0 to indicate success; a non-zero + * value is returned to indicate failure. The function will fail, if the + * private area currently associated with the thread is being used. + * + * Calling/Exit State: + * May block. + * + * Remarks: On failure, the previous state will not be changed. It is legal to + * invoke this API on a thread that may not have any private area associated + * with it. + */ + +int mpkReSizeThreadPrivateState(unsigned long size); + +/* + * unsigned int mpkGetPrivateAreaSize(void) + * Get the size of the private area. + * + * Calling/Exit State: None. + */ + +unsigned int mpkGetPrivateAreaSize(void); + +/* + * unsigned int mpkGetPrivateFreeSize(void) + * Get the size of the free space in the private area. + * + * Calling/Exit State: None. + */ + +unsigned int mpkGetPrivateFreeSize(void); + +/* + * void *mpkPrivateAlloc(unsigned long size) + * Allocate the specified number of bytes from the thread private. + * + * Calling/Exit State: + * Does not block. + * + * Remarks: + * The private arena will be managed as a stack (LIFO). + */ + +void *mpkPrivateAlloc(unsigned long size); + +/* + * void mpkPrivateFree(void *ptr, unsigned long size) + * Free a previously allocatted memory. + * + * Calling/Exit State: + * Does not block. + * + * Remarks: + * The stack force LIFO - the memory being freed must have been the once + * allocatted last. + */ + +void mpkPrivateFree(void *ptr, unsigned long size); + +void linuxMpkInit(void); +void linuxMpkDeInit(void); + +/* + * Subset of the MPK APIs. + */ + +/* + * Create a thread. A non-NUL value is returned on success; a NULL value + * is returned on failure. + */ +THREAD kStartThread(BYTE *ThreadName, // Name of the thread + void *(*func)(THREAD, void *), // start function + void *stackAddress, // Ignored on Linux + LONG StackSize, // Ignored on Linux + void *argument // Arg to the start function + ); + +/* + * Create a thread and put it in an initial state; without scheduling it. + * A non-NULL returns + */ + +THREAD kCreateThread(BYTE *ThreadName, // Name of the thread + void *(*func)(THREAD, void *), // start function + void *stackAddress, // Ignored on Linux + LONG StackSize, // Ignored on Linux + void *argument // Arg to the start function + ); + +/* + * Schedule a thread created via kCreateThread() + */ + +ERROR kScheduleThread(THREAD handle); + +/* + * Get the handle on the calling thread + */ + +THREAD kCurrentThread(void); + +/* + * Get the name of the specified thread. + */ + +ERROR kGetThreadName(THREAD handle, // specified thread + BYTE *buffer, // buffer to fill the name + LONG bufSize // size of buffer + ); + +/* + * Set the thread name. + */ + +ERROR kSetThreadName( THREAD handle, // specified thread + BYTE *newName // new name + ); + +/* + * Yield the calling thread. + */ + +void kYieldThread(void); + +/* + * Delay the calling thread. + * + */ + +ERROR kDelayThread(UINT delayAmount //delay in milliseconds + ); + +/* + * Suspend the specified thread. + */ + +ERROR kSuspendThread(THREAD handle // specified thread + ); + +/* + * Resume the specified thread. + */ + +ERROR kResumeThread(THREAD handle // specified thread + ); + +/* + * Post state to destroy (kill) a thread. If a NULL handle is passed, + * the calling thread is specified. + */ + +ERROR kDestroyThread(THREAD handle // specified thread + ); + +/* + * Terminate the calling thread. + */ + +void kExitThread(void *ExitStatus // exit status + ); + +/* + * Join a thread. + */ + +ERROR kGetThreadExitCode(THREAD handle, // + void **exitStatus); + + +/* + * Check for suspension or kill. + */ + +ERROR kThreadCheckForSuspendKill(void); + +/* + * Get the thread attributes. + */ + +ERROR kGetThreadAttributes(THREAD handle, // specified thread + UINT32 *attributes + ); + +/* + * Set thread attributes. + */ + +ERROR kSetThreadAttributes(THREAD handle, // specified thread + UINT32 attributes + ); + +/* + * Get thread specific data. + */ + +void *kGetUserThreadData(THREAD handle); + +/* + * Set thread specific data. + */ + +ERROR kSetUserThreadData(THREAD handle, //specified thread + void *data + ); + +/* + * Bind the thread to the specified processor; not supported initially + */ + +ERROR kBindThread(THREAD handle, // specified thread + PROCESSOR cpu // specified processor + ); + +/* + * Unbind the specified thread. Not supported initially. + */ + +ERROR kUnbindThread(THREAD handle); + +/* + * Get current binding. Not supported initially. + */ + +PROCESSOR kCurrentThreadBinding(THREAD handle); + +/* + * Get efective binding; not supported initially. + */ + +ERROR kGetEffectiveBinding(THREAD handle, LONG *binding); + +/* + * Get the register state. not supported initially. + */ + +ERROR kGetThreadContext(THREAD handle, CONTEXT *contextp); + +/* + * Get the stack information for the specified thread. Not supported + * initially + */ + +ERROR kGetThreadStackInfo(THREAD handle, LONG *stackp, LONG *stkSize); + +/* + * Set the kernel stack for the calling thread; not supported. + */ + +ERROR kSetThreadKernelStackInfo(LONG stackp, LONG stkSize); + +/* + * Get the available stack space. + */ + +LONG kGetCurrentAvailableStackSize(void); + +/* + * Netware binding management (legacy code support) + */ + +void kExitNetWare(void); + +void kEnterNetWare(void); + +/* + * Preemption management; not supported initially. + */ + +ERROR kSetNLMPreemption( + struct LoadDefinitionStructure *ModuleHandle, + BOOLEAN PreemptionFlag); + + +/* + * Manage preemption on code segments. Not supported initially. + */ +ERROR kSetCodePreemption(ADDR startAddr, LONG length, BOOLEAN prmptFlag); + +/* + * Turn off preemption. + */ + +ERROR kEnterCriticalSection(void); + +/* + * Enable preemption; + */ + +ERROR kExitCriticalSection(void); + +/* + * Check to see if the calling thread is in a critical section; + */ + +BOOLEAN kGetCriticalSectionStatus(void); + +/* + * Synch primitives; spin locks. + */ + +ERROR kSpinLockInit(SPINLOCK *lockp); + +void kSpinLock(SPINLOCK *lockp); + +ERROR kSpinTryLock(SPINLOCK *lockp); + +void kSpinUnlock(SPINLOCK *lockp); + +FLAGS kSpinLockDisable(SPINLOCK *lockp); + +ERROR kSpinTryLockDisable(SPINLOCK *lockp, FLAGS *flags); + +void kSpinUnlockRestore(SPINLOCK *lockp, FLAGS flags); + +/* + * Synch primitives; sleep locks. + */ + +MUTEX kMutexAlloc(BYTE *MutexName); +ERROR kMutexFree(MUTEX handle); +ERROR kMutexLock(MUTEX lock); +ERROR kMutexTryLock(MUTEX lock); +ERROR kMutexUnlock(MUTEX lock); +UINT kMutexWaitCount(MUTEX lock); + +/* + * Synch primitives; semaphores. + */ + +SEMAPHORE kSemaphoreAlloc(BYTE *name, UINT count); +ERROR kSemaphoreFree(SEMAPHORE sema); +ERROR kSemaphoreWait(SEMAPHORE sema); +ERROR kSemaphoreTry(SEMAPHORE sema); +/* + * semaTimedWait not currently supported. + */ +ERROR kSemaphoreTimedWait(SEMAPHORE sema, UINT timeout); //timeout in ms. +ERROR kSemaphoreSignal(SEMAPHORE sema); +UINT kSemaphoreExamineCount(SEMAPHORE sema); +UINT kSemaphoreWaitCount(SEMAPHORE sema); + +/* + * Synch primitives; read/write sleep lock. + */ + +RWLOCK kRWLockAlloc(BYTE *RWLockName); + +ERROR kRWLockFree(RWLOCK handle); + +ERROR kRWReadLock(RWLOCK handle); + +ERROR kRWReadTryLock(RWLOCK handle); + +ERROR kRWReadUnlock(RWLOCK handle); + +ERROR kRWWriteLock(RWLOCK handle); + +ERROR kRWWriteTryLock(RWLOCK handle); + +ERROR kRWWriteUnlock(RWLOCK handle); + +ERROR kRWWriterToReader(RWLOCK handle); + +ERROR kRWReaderToWriter(RWLOCK handle); + +/* + * Synch primitives; read/write spin lock: not implemented. + */ + +SPINRWLOCK kSpinRWLockAlloc(BYTE *name); + +ERROR kSpinRWLockFree(SPINRWLOCK handle); + +ERROR kSpinRWReadLock(SPINRWLOCK handle); + +ERROR kSpinRWReadUnlock(SPINRWLOCK handle); + +ERROR kSpinRWWriteLock(SPINRWLOCK handle); + +ERROR kSpinRWWriteUnlock(SPINRWLOCK handle); + + +/* + * Synch primitives; Condition variables. + */ + +ERROR kCVAlloc(BYTE *name, KCONDITION *handle); +ERROR kCVDestroy(KCONDITION handle); +ERROR kCVWait(KCONDITION handle, SPINLOCK *lp); +ERROR kCVTimedWait(KCONDITION handle, SPINLOCK *lp, LONG timeOut); +ERROR kCVSignal(KCONDITION handle); +ERROR kCVBroadcast(KCONDITION handle); + +/* + * Synch primitives; Barriers. + */ + +BARRIER kBarrierAlloc(BYTE *name, UINT value); + +ERROR kBarrierFree(BARRIER handle); + +ERROR kBarrierWait(BARRIER handle); + +ERROR kBarrierIncrement(BARRIER handle); + +ERROR kBarrierDecrement(BARRIER handle); + +ERROR kBarrierThreadCount(BARRIER handle, UINT *count); + +ERROR kBarrierWaitCount(BARRIER handle, UINT *count); + +/* + * Atomic functions: to be implemented. + */ + +#include "mpkatomic.h" + +/* + * Sleep wakeup primitives. + */ + +void kSleep(void); +ERROR kWakeUp(THREAD handle); + +/* + * Queue and list APIs: Not implemented; the application can implement this. + */ + +/* + * Timeout APIs; call out will be made in the timer interrupt context. + */ + +ERROR kScheduleCallOut(CALLOUT_STRUCT *cp); + +ERROR kCancelCallOut(CALLOUT_STRUCT *cp); + +/* + * Get the granularity of ticks. + */ + +UINT GetTimerMinorTicksPerSecond(void); + +/* + * Polling functions; not implemented. + */ + +/* + * worktodo apis. + */ + +ERROR kScheduleWorkToDo(struct WorkToDoStructure *work); +ERROR kSchedulePrioWorkToDo(struct WorkToDoStructure *work); + +ERROR kScheduleWorkToDoDirected(struct WorkToDoStructure *work, + PROCESSOR cpuNumber); + +ERROR kCancelWorkToDo(struct WorkToDoStructure *work); + +ERROR kScheduleFastWorkToDo(struct WorkToDoStructure *work); + +ERROR kScheduleFastWorkToDoLocal(struct WorkToDoStructure *work); + +ERROR kScheduleFastWorkToDoDirected(struct WorkToDoStructure *work, + PROCESSOR cpuNumber); + +/* + * Processor management APIs: partially implemented. + */ + +/* + * Get the CPU ID on which the calling thread is executing. + */ + +PROCESSOR kReturnCurrentProcessorID(void); + +/* + * Get the number of processors in the system. + */ + +LONG kReturnPhysicalProcessorCount(void); + +/* + * An Api to register a module with MPK. The registered function will be + * invoked in the context of an MPK thread, + */ + +void mpkRegisterMainFunc(void (*mainFunc)(void *), void *, char *name); + +/* + * Linux thread migration APIs. + */ + +/* + * void mpkEnter(void) + * Transform a standard Linux (thread/process) to an MPK thread. This function + * needs to be called before executing code written to the MPK on Linux. + * The function may block. + * + * Calling/Exit State: + * The function may block. + * + * Remarks: + * We will support recurssive invocation of this function on the same thread. + */ + +void mpkEnter(void); + +/* + * void mpkExit(void) + * Migrate the thread out of the MPK environment. The function does not block. + * Prior to returning from the MPK environment, invoke this API. + */ + +void mpkExit(void); + +int nkEventBusInit(void); +int nkEventBusDeInit(void); +void mpkSemaphoreInit(mpkSema_t *sema, char *name, int count); + + +#endif /* MPK_H*/ diff --git a/include/nwnss/include/mpkatomic.h b/include/nwnss/include/mpkatomic.h new file mode 100644 index 0000000..38d13e0 --- /dev/null +++ b/include/nwnss/include/mpkatomic.h @@ -0,0 +1,223 @@ +/**************************************************************************** + | + | (C) Copyright 2002-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | File Name: mpkatomic.h + | + | File Created: 07/07/2003 + | + | Engineering Contact: K.Y. Srinivasan + | + | Target Platform: COMMON_SOURCE + | + | + | File Description: + | An implementation of the NetWare MP in the Linux Kernel. We have + | initially imlemented a subset of the APIs and semantics. + |*************************************************************************** + | + | $Author: blarsen $ + | $Date: 2006-09-06 03:03:38 +0530 (Wed, 06 Sep 2006) $ + | + | $RCSfile$ + | $Revision: 1522 $ + | + ****************************************************************************/ + +#ifndef MPK_ATOMIC_H +#define MPK_ATOMIC_H + +#ifndef LOCK +#if defined (CONFIG_SMP) || defined (MPK_DEBUG) +#define LOCK "lock ; " +#else +#define LOCK "" +#endif +#endif +#include + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,6)) +#include +#endif + + +/* + * void atomic_inc(LONG *loc) + * Atomically increment the location pointed to by loc. + */ + +static +__inline__ void mpk_atomic_inc(LONG *loc) +{ + __asm__ __volatile__( + LOCK "incl %0" + :"=m" (*loc) + :"m" (*loc) + : "memory", "flags"); +} + +/* + * void atomic_dec(LONG *loc) + * Atomically decrement the location pointed to by loc. + */ + +static +__inline__ void mpk_atomic_dec(LONG *loc) +{ + __asm__ __volatile__( + LOCK "decl %0" + :"=m" (*loc) + :"m" (*loc) + : "memory", "flags"); +} + +/* + * void atomic_add(LONG *loc, LONG val) + * Atomically add value to the location pointed to by loc. + */ + +static +__inline__ void mpk_atomic_add(LONG *loc, LONG val) +{ + __asm__ __volatile__( + LOCK "addl %1,%0" + :"=m" (*loc) + :"ir" (val), "m" (*loc) + : "memory", "flags"); +} + +/* + * void atomic_sub(LONG *loc, LONG val) + * Atomically add value to the location pointed to by loc. + */ + +static +__inline__ void mpk_atomic_sub(LONG *loc, LONG val) +{ + __asm__ __volatile__( + LOCK "subl %1,%0" + :"=m" (*loc) + :"ir" (val), "m" (*loc) + : "memory", "flags"); +} + +/* + * LONG atomic_bts(LONG *bitBase, LONG bitOffset) + * Atomically set the specified bit position in the word pointed to by + * bitBase. Return the original value of the bit. + */ + +static +__inline__ LONG atomic_bts(LONG *base, LONG bitOffset) +{ + LONG retVal; + __asm__ __volatile__( + LOCK "btsl %2, %1\n\t" + "movl $0, %0\n\t" + "adcl %0, %0" + :"=r" (retVal), "+m" (*base) + :"rI" (bitOffset) + : "memory", "flags"); + return (retVal); +} + +/* + * LONG atomic_btr(LONG *bitBase, LONG bitOffset) + * Atomically clear the specified bit position in the word pointed to by + * bitBase. Return the original value of the bit. + */ + +static +__inline__ LONG atomic_btr(LONG *base, LONG bitOffset) +{ + LONG retVal; + __asm__ __volatile__( + LOCK "btrl %2, %1\n\t" + "movl $0, %0\n\t" + "adcl %0, %0" + :"=r" (retVal), "+m" (*base) + :"rI" (bitOffset) + : "memory", "flags"); + return (retVal); +} + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) +/* + * LONG atomic_xchg(LONG *loc, LONG *value) + * Atomically exchange the value at memory location "loc" with the value at + * the location at "value". The original value at "loc" will be returned. + */ + +static +__inline__ LONG atomic_xchg(LONG *loc, LONG *value) +{ + LONG oldValue; + __asm__ __volatile__( + LOCK "xchgl %1,%0\n\t" + : "=r" (oldValue), "+m" (*loc) + : "0" (*value) + : "memory"); + return (oldValue); +} +#endif + +/* + * LONG atomic_addAndReturn(LONG *loc, LONG value) + * Atomically add the value to the location pointed to by loc. The new + * value is returned. + */ + +static +__inline__ LONG atomic_addAndReturn(LONG *loc, LONG value) +{ + LONG oldValue; + __asm__ __volatile__( + "movl %1, %2\n\t" + LOCK "xaddl %1,%0\n\t" + "addl %1, %2" + : "+m" (*loc), "+r" (value), "+r" (oldValue) + : + : "memory"); + return (oldValue); +} + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) +/* + * LONG atomic_cmpxchg(LONG *loc, LONG compareValue, LONG newValue) + * Atomically compare the "compareValue" with value pointed to by "loc"; + * if they are same, exchange the value at "loc" with the new value. + * In all cases, the original value at "loc" is returned. + */ + +static +__inline__ LONG atomic_cmpxchg(LONG *loc, LONG compareValue, LONG newValue) +{ + LONG oldValue; + __asm__ __volatile__( + LOCK "cmpxchgl %2, %1" + : "=a" (oldValue), "+m" (*loc) + : "r" (newValue), "0" (compareValue) + : "memory", "flags"); + return (oldValue); +} +#endif + +#endif /* MPK_ATOMIC_H*/ diff --git a/include/nwnss/include/mpkerrno.h b/include/nwnss/include/mpkerrno.h new file mode 100644 index 0000000..fcca69a --- /dev/null +++ b/include/nwnss/include/mpkerrno.h @@ -0,0 +1,78 @@ +/**************************************************************************** + | + | (C) Copyright 2002-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | File Name: mpkerrno.h + | + | File Created: 07/07/2003 + | + | Engineering Contact: K.Y. Srinivasan + | + | Target Platform: COMMON_SOURCE + | + | + | File Description: + | An implementation of the NetWare MP in the Linux Kernel. We have + | initially imlemented a subset of the APIs and semantics. + |*************************************************************************** + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + ****************************************************************************/ + +#ifndef MPK_ERRNO_H +#define MPK_ERRNO_H + +#define kSUCCESS 0 +#define ERROR_INVALID_THREAD 1 +#define ERROR_REQUEST_DENIED 2 +#define ERROR_THREAD_DETACHED 3 +#define ERROR_FAILURE 4 +#define ERROR_INVALID_PARAMETER 5 +#define ERROR_CPU_NUMBER_INVALID 6 +#define ERROR_STACK_OVERFLOW 7 +#define ERROR_STACK_POINTER_OUT_OF_RANGE 7 +#define kBUSY -1 +#define ERROR_INVALID_MUTEX 8 +#define ERROR_NOT_LOCK_OWNER 9 +#define ERROR_INVALID_SEMAPHORE 10 +#define ERROR_INVALID_CALLOUT 11 +#define ERROR_INVALID_RESOURCE_TAG 12 +#define ERROR_INVALID_SPIN_RWLOCK 13 +#define ERROR_INVALID_BARRIER 14 +#define ERROR_INVALID_RWLOCK 15 +#define ERROR_ALREADY_OWNER 16 +#define ERROR_INVALID_KERNEL_CV 17 + +/* + * Error codes for lists ans queues. + */ +#define ERROR_INVALID_LIST 18 +#define ERROR_NO_MEMORY 19 +#define ERROR_INVALID_QUE 20 +#define ERROR_INVALID_QUE_LIGHT 21 + +#define ERROR_TIMEOUT 22 +#endif /* MPK_ERRNO_H */ diff --git a/include/nwnss/include/mpkmisc.h b/include/nwnss/include/mpkmisc.h new file mode 100644 index 0000000..8ca48b6 --- /dev/null +++ b/include/nwnss/include/mpkmisc.h @@ -0,0 +1,185 @@ +/**************************************************************************** + | + | (C) Copyright 2002-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | File Name: mpkmisc.h + | + | File Created: 07/07/2003 + | + | Engineering Contact: K.Y. Srinivasan + | + | Target Platform: COMMON_SOURCE + | + | + | File Description: + | An implementation of the NetWare MP in the Linux Kernel. We have + | initially imlemented a subset of the APIs and semantics. + |*************************************************************************** + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + ****************************************************************************/ + +#ifndef MPK_MISC_H +#define MPK_MISC_H + +#include +#include "mpk.h" +/* + * Memory Management. + */ + +typedef struct memAcct { + void (*func)(unsigned int); +} memAcct_t; + + +void memMgmtInit(void); + +/* + * Flags for allocation. + */ + +#define MPK_SLEEP_OK GFP_KERNEL +#define MPK_SLEEP_NOT_OK GFP_ATOMIC + +/* + * Byte allocator. + */ + + +void *mpkAlloc(size_t, int); + +void mpkFree(const void *); + +/* + * Page allocator + */ + +void *mpkPageAlloc(unsigned long, int); +void mpkPageFree(void *); + +/* + * int + * mpkRegisterMemPressureCallBack + * (void (*callBack)(unsigned int pagesNeeded)) + * This API registers a callback with the system. This function will be + * invoked in a thread context when memory pressure in the system is acute. + * The argument passed to the callback function will specify the number of + * pages to be given back to the system. + */ + +int mpkRegisterMemPressureCallBack(void (*callBack)(unsigned int pagesNeeded)); +void mpkDeRegisterMemPressureCallBack(void); + +/* + * AESPROC support. + */ + +typedef struct AESProcessStructure { + void (*AProcessToCall)(struct AESProcessStructure *); + LONG AWakeUpDelayAmount; + struct callOutStruct timeout; + struct WorkToDoStructure work; +} AESProcessStruct_t; + +void ScheduleSleepAESProcessEvent(AESProcessStruct_t *aesp); +void ScheduleNoSleepAESProcessEvent(AESProcessStruct_t *aesp); + +void CancelSleepAESProcessEvent(AESProcessStruct_t *aesp); +void CancelNoSleepAESProcessEvent(AESProcessStruct_t *aesp); + +/* + * Other misc functions and data symbols. + */ + +void Abend(const char *message); +void EnterDebugger(void); + +struct DateTimeStruct /* Also defined in UTILA.ASM */ +{ + unsigned int year; + unsigned int month; + unsigned int day; + unsigned int hour; + unsigned int minute; + unsigned int second; + int timeZoneAdjust; /* Must set for + ConvertToSecondsRelative1970 */ + unsigned int dayOfWeek; /* Returned by ConvertSecondsToDateTime */ +}; + +/* + * Flags passed to date and time formatting routines + */ + +#define EN_INCLUDE_SECONDS 0x01 /* Include seconds in time*/ +#define EN_INCLUDE_WEEKDAY 0x02 /*Include the day of the week in date*/ +#define EN_USE_ALPHA_MONTH 0x04 /*Use month name, not number*/ +#define EN_USE_4_DIGIT_YEAR 0x08 /* Print four digit year*/ +#define EN_USE_ABBREV_MONTH 0x10 /*Use month abbreviation, not number*/ + +void FormatDateAndTime( + BYTE *buffer, + LONG year, + LONG month, + LONG day, + LONG hour, + LONG minute, + LONG second, + LONG flags); + +long long GetSuperHighResolutionTimer(void); + +//size_t SizeOfAllocBlock(void *addr); + +#define MMU_ERROR 1 +/* + * Access types. + */ +#define MMU_SUPERVISOR_READ 5 +#define MMU_SUPERVISOR_WRITE 5 + + +LONG ValidateAddressRangePresent(void *address, LONG range, LONG flag); + +LONG NVMGetHighestPhysivalAddress(void); + +/* + * Global variables (a subset) exposed by NetWare. + */ + +extern volatile LONG UpTimeInSeconds; + +extern LONG CurrentNumberOfCacheBuffers; + +extern LONG NestedInterruptCount; + +#define RunningProcess ((ADDR)kCurrentThread()) + + + + +#endif /* MPK_MISC_H */ diff --git a/include/nwnss/include/mpkutil.h b/include/nwnss/include/mpkutil.h new file mode 100644 index 0000000..98b02c2 --- /dev/null +++ b/include/nwnss/include/mpkutil.h @@ -0,0 +1,525 @@ +/**************************************************************************** + | + | (C) Copyright 2002-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | File Name: mpkutil.h + | + | File Created: 07/07/2003 + | + | Engineering Contact: K.Y. Srinivasan + | + | Target Platform: COMMON_SOURCE + | + | + | File Description: + | Utilities for supporting MPK on Linux. + |*************************************************************************** + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + ****************************************************************************/ +#include +#include +#include "mpk.h" + +typedef void * HANDLE; + +typedef long long SINT64; + +/* + * Signatures for lists and qs. + */ + +#define MPK_DOUBLY_LINKED_LIST_SIGNATURE 0x88888888 +#define MPK_QUEUE_SIGNATURE 0x99999999 +#define MPK_QUEUE_LIGHT_SIGNATURE 0xAAAAAAAA + +/* + * Definition of a singly linked list node. + */ +typedef struct _listNode { + struct _listNode *next; + struct _listNode *prev; +} LIST_NODE; + +/* + * Doubly linked list head. + */ + +typedef struct doublyLinkedListHead { + LIST_NODE *first; + LIST_NODE *last; + unsigned int nodeCount; + unsigned long signature; + rwMutex_t *rwLock; +} doublyLinkedListHead_t; + + +/* + * Allocate a doubly linked list head. + */ + +ERROR kDoublyLinkedListAlloc(HANDLE *listHeadHandle); + +/* + * Free the list head. + */ + +ERROR kDoublyLinkedListFree(HANDLE listHeadHandle); + +/* + * Initialize the specified doubly linked list. + */ + +ERROR kDoublyLinkedListInit(HANDLE listHeadHandle); + +/* + * Add an element to the list. + */ + +ERROR kDoublyLinkedListAddElement(HANDLE listHeadHandle, + LIST_NODE *node); + +/* + * Add an element without acquiring the lock. + */ + +ERROR kDoublyLinkedListAddElementNoLock(HANDLE listHeadHandle, + LIST_NODE *node); + +/* + * Delete an element from the list. + */ + +ERROR kDoublyLinkedListDeleteElement(HANDLE listHeadHandle, + LIST_NODE *node); + +/* + * Delete an element without acquiring the lock. + */ +ERROR kDoublyLinkedListDeleteElementNoLock(HANDLE listHeadHandle, + LIST_NODE *node); + +/* + * Acquire the read lock on the list. + */ + +ERROR kDoublyLinkedListReadLock(HANDLE listHeadHandle); + +/* + * Release the read lock on the list. + */ + +ERROR kDoublyLinkedListReadUnlock(HANDLE listHeadHandle); + +/* + * Acquire the write lock on the list. + */ + +ERROR kDoublyLinkedListWriteLock(HANDLE listHeadHandle); + +/* + * Release the write lock on the list. + */ + +ERROR kDoublyLinkedListWriteUnlock(HANDLE listHeadHandle); + +/* + * Get the first element of a list. + */ + +ERROR kDoublyLinkedListGetFirstElementNoLock(HANDLE listHeadHandle, + LIST_NODE **node); + +/* + * Given an element of a list return the next element. + */ + +#define kDoublyLinkedListGetNextElement(node) \ +((node)->next) + +/* + * Given an element of a list return the previous element. + */ + +#define kDoublyLinkedListGetPrevElement(node) \ +((node)->prev) + +/* + * Queue functions. + */ + +typedef struct qlink { + + struct qlink *link; + void *ptr; + SINT64 value; +} QLINK; + +typedef struct queueHeader { + QLINK *first; + QLINK *last; + SPINLOCK lock; + unsigned long signature; + unsigned long nodeCount; + KCONDITION condVar; +} queueHeader_t; + +typedef void * QUE; + +/* + * Allocate a queue. + */ +QUE kAllocQue(void); + +/* + * Allocate a queue; the caller cannot block + */ + +QUE kAllocQueNoSleep(void); + +/* + * Free a previously allocated queue. + */ + +ERROR kFreeQue(QUE QueHandle); + +/* + * Retrieve the number of elements in the queue. + */ + +LONG kQueCount(QUE QueHandle); + +/* + * Retrieve the number of elements in the queue; without any checks. + */ + +LONG kQueCountNoCheck(QUE QueHandle); + +/* + * Enqueue an element on the queue. + */ + +ERROR kEnQue(QUE QueHandle, QLINK *newNode); + +/* + * Enqueue an element without acquiring the lock. + */ + +ERROR kEnQueNoLock(QUE QueHandle, QLINK *newNode); + +/* + * Enqueue the element using the key to locate the position to enqueue. + */ + +ERROR kEnQueOrdered(QUE QueHandle, QLINK *newNode, SINT64 value); + +/* + * Enqueue the element using the key to locate the position to enqueue. + * Does not acquire the lock. + */ + +ERROR kEnQueOrderedNoLock(QUE QueHandle, QLINK *newNode, SINT64 value); + +/* + * Add a new element at the head of the queue. + */ + +ERROR kPushQue(QUE QueHandle, QLINK *newNode); + +/* + * Add a new element at the head of the queue without acquiring the lock. + */ + +ERROR kPushQueNoLock(QUE QueHandle, QLINK *newNode); + +/* + * Push the element using the key to order the queue; ascending order. + */ + +ERROR +kPushQueOrdered(QUE QueHandle, QLINK *newNode, SINT64 value); + + +/* + * Push the element using the key to order the queue; ascending order without + * acquiring the lock. + */ + +ERROR kPushQueOrderedNoLock(QUE QueHandle, QLINK *newNode, SINT64 value ); + +/* + * Dequeue the node at the head of the queue. + */ + +QLINK *kDeQue(QUE QueHandle); + +/* + * Dequeue the node at the head of the queue; without acquiring the lock. + */ + +QLINK *kDeQueNoLock(QUE QueHandle ); + +/* + * Dequeue the specified element. + */ + +QLINK *kDeQueByQLINK(QUE QueHandle, QLINK *node); + +/* + * Dequeue the specified element, without acquiring the lock. + */ + +QLINK *kDeQueByQLINKNoLock(QUE QueHandle, QLINK *newNode); + +/* + * Dequeue an element from the head of the queue. If no the queue is + * empty, block. + */ + +QLINK *kDeQueWait(QUE QueHandle); + + +/* + * Dequeue an element from the head of the queue. If no the queue is + * empty, block. We will not acquire the lock on the queue. + */ +QLINK *kDeQueWaitNoLock(QUE QueHandle); + +/* + * Dequeue all elements in the queue. + */ + +QLINK *kDeQueAll(QUE QueHandle); + + +/* + * Dequeue all elements in the queue. The queue lock is not acquired. + */ + +QLINK *kDeQueAllNoLock(QUE QueHandle); + +/* + * Return the first elementin the quue without acquiring the lock. + * The element is NOT removed from the queue. + */ + +QLINK *kFirstQLINKNoLock(QUE QueHandle); + + +/* + * Light-weight queues! Singly linked. + */ + +typedef struct qlinkLight { + struct qlinkLight *next; +} QLINK_LIGHT; + +/* + * The header structure. + */ + +typedef struct queueLightHeader { + QLINK_LIGHT *first; + QLINK_LIGHT *last; + SPINLOCK lock; + unsigned long signature; + unsigned int nodeCount; + KCONDITION condVar; +} queueLightHeader_t; + +typedef void * QUE_LIGHT; + +/* + * Allocate a light-weight queue. + */ + +QUE_LIGHT kAllocQueLight(void); + +/* + * Allocate a light-weight queue without blocking. + */ + +QUE_LIGHT kAllocQueLightNoSleep(void); + +/* + * Free a previously allocated light-weight queue. + */ + +ERROR kFreeQueLight(QUE_LIGHT queue); + +/* + * Return the number of elements in the queue. + */ +UINT kQueLightCount(QUE_LIGHT queue); + +/* + * Enqueue the specified element on the queue. + */ + +ERROR kEnQueLight(QUE_LIGHT queue, QLINK_LIGHT *newNode); + +/* + * Enqueue the specified element on the queue; without acquiring the lock. + */ + +ERROR kEnQueLightNoLock( QUE_LIGHT queue, QLINK_LIGHT *newNode ); + +/* + * Enqueue the element at the head of the list. + */ + +ERROR kPushQueLight(QUE_LIGHT queue, QLINK_LIGHT *newNode); + +/* + * Enqueue the element at the head of the list without acquiring the lock. + */ + +ERROR kPushQueLightNoLock(QUE_LIGHT queue, QLINK_LIGHT *newNode); + +/* + * Dequeue an element from the queue. + */ + +QLINK_LIGHT *kDeQueLight(QUE_LIGHT queue); + + +/* + * Dequeue an element from the queue; without acquiring the lock. + */ + +QLINK_LIGHT *kDeQueLightNoLock(QUE_LIGHT queue); + +/* + * Dequeue the specified element. + */ + +QLINK_LIGHT *kDeQueLightByQueLink(QUE_LIGHT queue, QLINK_LIGHT *newNode); + +/* + * Dequeue the specified element without acquiring the lock. + */ + +QLINK_LIGHT +*kDeQueLightByQueLinkNoLock(QUE_LIGHT queue, QLINK_LIGHT *new); + + +/* + * Attempt to dequue an element; if the queue is empty block. + */ +QLINK_LIGHT *kDeQueLightWait(QUE_LIGHT queue); + + +/* + * Attempt to dequue an element; if the queue is empty block. No locks + * are acquired. + */ + +QLINK_LIGHT *kDeQueLightWaitNoLock(QUE_LIGHT queue); + +/* + * Dequeue all the elements in the queue. + */ + +QLINK_LIGHT *kDeQueLightAll(QUE_LIGHT queue); + +/* + * Dequeue all the elements in the queue without acquiring the lock. + */ + +QLINK_LIGHT *kDeQueLightAllNoLock(QUE_LIGHT queue); + +/* + * Get the first element of the queue without acquiring the lock. The element + * is NOT dequeued. + */ + +QLINK_LIGHT *kFirstQueLinkLightNoLock(QUE_LIGHT queue); + +/* + * File I/O APIs from MPK. + * The return value will be -1 to indicate a failure; we will + * support a per-thread errno; where additional error value will + * be stored. + * + */ + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +#ifndef SEEK_CUR +#define SEEK_CUR 1 +#endif + +#ifndef SEEK_END +#define SEEK_END 2 +#endif + + +/* + * Error management functions: + */ + +void mpkSetErrno(int error); + +int mpkGetErrno(void); + +#define errno mpkGetErrno() + +/* + * Open the specified file. + * Refer to the open manual page for details. + */ + +int mpkOpen(char *name, int flags, int mode); + +/* + * Close an open file. + * Refer to the manual page for close(2) for details + */ + +int mpkClose(int fd); + +/* + * read a file. + * Refer to the read(2) manual page for details. + */ + +ssize_t mpkRead(int fd, void *buf, size_t count); + +/* + * Write to an open file. + * Refer to the write(2) manual page for details. + */ + +ssize_t mpkWrite(int fd, const void *buf, size_t count); + +/* + * seek into a file. + * Refer to lseek(2) manual page for details. + */ + +off_t mpkSeek(int fd, off_t offset, int whence); diff --git a/include/nwnss/include/msg.h b/include/nwnss/include/msg.h index 8fc4cb3..87ca3ce 100644 --- a/include/nwnss/include/msg.h +++ b/include/nwnss/include/msg.h @@ -39,19 +39,19 @@ #define _NSS_MSG_H_ #ifndef _ZOMNI_H_ -# include +# include #endif #ifndef _ZMSG_H_ -# include +# include #endif #ifndef _QUE_H_ -# include +# include #endif #ifndef _SLAB_H -# include +# include #endif typedef void *(*objfunc_t)(); /* Function returns a pointer to an object */ diff --git a/include/nwnss/include/msgGen.h b/include/nwnss/include/msgGen.h index 03348e8..b9000cb 100644 --- a/include/nwnss/include/msgGen.h +++ b/include/nwnss/include/msgGen.h @@ -45,19 +45,19 @@ #define _MSGGEN_H_ #ifndef _ZOMNI_H_ -# include +# include #endif #ifndef _XSTRING_H_ -# include +# include #endif #ifndef _LATCH_H_ -# include +# include #endif #ifndef _XERROR_H_ -# include +# include #endif #ifdef __cplusplus @@ -220,7 +220,7 @@ typedef struct GeneralMsg_s * about Logical Volumes in a Pool. */ #define ALLOW_INACTIVE_VOLUME 0x0080 /* Set by purgeLog processing to - * cause volume lookups to not + * cause volume lookups to not * require the volume to be active */ #define UPDATE_EXISTING_BEAST 0x0200 /* When unpacking the beast, it is @@ -229,7 +229,7 @@ typedef struct GeneralMsg_s * used by XLSS. */ #define DO_NOT_CHECK_SPACE_QUOTA 0x0400 /* If set, do not check for user space - * restriction and directory space + * restriction and directory space * restriction */ #define ALLOW_BST_STATE_PURGING 0x0800 /* WARNING --- DO NOT USE THIS @@ -239,7 +239,7 @@ typedef struct GeneralMsg_s * to be looked up even if it's * state is BST_STATE_PURGING, but * only if it has a non-zero use - * count. + * count. */ #define COMN_GENMSG_RESOLVE_CONNECTION(genMsg) \ diff --git a/include/nwnss/include/msgIO.h b/include/nwnss/include/msgIO.h index 267763f..d40e393 100644 --- a/include/nwnss/include/msgIO.h +++ b/include/nwnss/include/msgIO.h @@ -45,19 +45,19 @@ #define _MSGIO_H_ #ifndef _MSGGEN_H_ -# include +# include #endif #ifndef _LATCH_H_ -# include +# include #endif #ifndef _FSM_H_ -# include +# include #endif #ifndef _ZPARAMS_H_ -# include +# include #endif #ifdef __cplusplus @@ -207,7 +207,7 @@ typedef struct IoMsg_s * ahead all requested blocks */ #define ALLOC_BLOCKS_CONTIGUOUS 0x04 /* If set, allocate the blocks - * contiguously + * contiguously */ diff --git a/include/nwnss/include/name.h b/include/nwnss/include/name.h deleted file mode 100644 index cd627f3..0000000 --- a/include/nwnss/include/name.h +++ /dev/null @@ -1,476 +0,0 @@ -/**************************************************************************** - | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. - | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. - | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. - | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. - | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com - | - |*************************************************************************** - | - | NetWare Advance File Services (NSS) module - | - |--------------------------------------------------------------------------- - | - | $Author: blarsen $ - | $Date: 2006-01-21 04:09:53 +0530 (Sat, 21 Jan 2006) $ - | - | $RCSfile$ - | $Revision: 1315 $ - | - |--------------------------------------------------------------------------- - | This module is used to: - | This defines the interface into name spaces. - | - | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! - | - | This header file should ONLY be used for NSS internal development. - | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). - | Any other use may cause conflicts which NSS will NOT fix. - +-------------------------------------------------------------------------*/ -#ifndef _NAME_H_ -#define _NAME_H_ - -#ifndef _COMNBEASTS_H_ -#include -#endif - -#ifndef _NAMESPACE_H_ -#include -#endif - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - -/* Pre-define struct(s) so Linux compiler doesn't complain */ -struct FullDirectoryInfo_s; - -/*--------------------------------------------------------------------------- - * Defines - *---------------------------------------------------------------------------*/ - -/* preferably prime numbers since these numbers are used for hashing */ -#define MIN_NAME_CACHE_SIZE 17 /* The minimum number of entries that */ - /* can be set for the name cache. */ -#define DEFAULT_NAME_CACHE_SIZE 2111 /* The maximum number of entries that */ - /* can be set for the name cache. */ -#define DEFAULT_MAX_NAME_CACHE_SIZE 100000 /* Default maximum size of the name cache */ -#define MAX_NAME_CACHE_SIZE 1000000 /* The largest maximum size that can be set */ - /* for the name cache. */ -#define DEFAULT_CACHE_NAME_LEN 110 /* length of nameBuffer in default name cache entry */ - /* Long enough for one 36 character null terminated */ - /* unicode string and one 36 character unterminated */ - /* ASCII string */ -#define NAME_CACHE_OPTIMIZE_PERIOD 300 /* Interval between name cache optimizer executions */ - -/*--------------------------------------------------------------------------- - * Structures - *---------------------------------------------------------------------------*/ - -/* when you add fields to this structure update the init area in nameCache.c */ -typedef struct NameCacheCtrl_s -{ - QUAD changeCount; /* incremented each time an entry is added */ - QUAD uniGets; /* number of unicode cache gets */ - QUAD uniHits; /* number of unicode cache hits */ - QUAD uniPositiveHits; /* number of unicode cache hits for existing beasts */ - QUAD uniNegativeHits; /* number of unicode cache hits for non-existing beasts */ - QUAD asciiGets; /* number of ASCII cache gets */ - QUAD asciiHits; /* number of ASCII cache hits */ - QUAD asciiPositiveHits; /* number of ASCII cache hits for existing beasts */ - QUAD asciiNegativeHits; /* number of ASCII cache hits for non-existing beasts */ - QUAD numAllocs; /* number of times we allocated a packet */ - QUAD numNegativeAdds; /* number of adds of a negative entry */ - QUAD unusedEntryHit; /* number of times we got an entry from the unused list */ - QUAD numUnusedFrees; /* number of times we freed a packet from the unused list */ - QUAD numCountChanged; /* number of times the count had changed during add */ - QUAD numAlreadyAdded; /* number of times an entry was already added when we went to add */ - QUAD numVictimSelected; /* number of entries that have been victim selected */ - QUAD numRemoved; /* number of entries removed (not victom selected) */ - NINT maxEntries; /* max allowed entries in the cache */ - NINT maxSize; /* max value that maxEntries can grow to */ - NINT numEntries; /* number of entries in the cache */ - NINT numUnusedEntries; /* number of unused cache entries */ - NINT minValidSize; /* minimum value of maxEntries before an invalidate should occur */ - NINT maxValidSize; /* minimum value of maxEntries before an invalidate should occur */ - NINT lastInvalidateSize; /* value of maxEntries at last invalidate */ - Latch_s latch; /* latch to control changes in this structure */ - NINT numHashEntries; /* number of entries in each hash table */ - DQhead_t *uniHash; /* pointer to unicode hash array */ - DQhead_t *asciiHash; /* pointer to ASCII hash array */ - DQhead_t LRUqueue; /* head of the Least Recently Used queue */ - DQhead_t unusedQueue; /* head of the unused cache packets queue */ - FsmLite_s fsm; /* FSM for optimiser */ - OneShot_s nameOptAlarm; /* One shot event structure used to periodically trigger a re-size */ - LONG nameOptFlags; /* Flags to determine if Optimizer has been - * scheduled, if unload is in progress - */ -#define NAME_OPT_FLAGS_SCHEDULED 0x00000001 -#define NAME_OPT_FLAGS_UNINIT 0x00000002 -} NameCacheCtrl_s; - -typedef struct NameCacheNode_s -{ - DQlink_t uniHashLink; /* unicode hash list link field (used by unusedQueue too) */ - DQlink_t asciiHashLink; /* ASCII hash list link field */ - DQlink_t LRUlink; /* LRU link field */ - Zid_t zid; /* zid for the entry (value to return)*/ - Zid_t parentZid; /* parent zid for the entry (key)*/ - VolumeID_t volGuid; /* guid for the volume (key)*/ - NINT nameSpaceID; /* name space mask for the entry (key)*/ - NINT nameType; /* name Type for the entry (key)*/ - unicode_t *uniName; /* Pointer to the unicode name */ - NINT asciiNameLen; /* length of the ASCII name */ - char *asciiName; /* Pointer to the ASCII Name */ - NINT nameBufferLen; /* length of the nameBuffer in Bytes */ - BYTE nameBuffer[1]; /* buffer which holds the names (keys)*/ -} NameCacheNode_s; - -struct nameCacheOptimizerStats_s -{ - NINT resizeCount; /* Number of times we've re-sized the name cache */ - NINT noResizeCount; /* Number of times we've executed the optimiser and not re-sized the cache */ - NINT optimizeCount; /* Number of times we've invalidated the name cache on re-size */ - NINT maxSize; /* Maximum size the name cache has been */ - NINT minSize; /* Minimum size the name cache has been */ - NINT maxChange; /* Largest change in size in the name cache */ - NINT minChange; /* Smallest change in size in the name cache */ - NINT maxInvalidateChange; /* Maximum change in size that caused an invalidate */ - NINT minInvalidateChange; /* Smallest change in size that caused an invalidate */ - NINT maxPctInvalidateChange; /* Largest percentage change in cache size */ - NINT maxReqdNodeDestroys; /* Maximum number of cache nodes that needed to be destroyed following a re-size */ -}; -extern struct nameCacheOptimizerStats_s NameCacheOptimizerStats; - - -/*--------------------------------------------------------------------------- - * Functions for manipulating names in beasts - *---------------------------------------------------------------------------*/ -extern STATUS NAME_InsertAndMangleName( - struct GeneralMsg_s *genMsg, - void *beast, /*beast to insert*/ - void *primaryBeast, /*primary, if beast is a hardlink */ - void *directory, /*directory to insert into*/ - NINT primaryNameSpaceID, - NINT nameType, - unicode_t *name, - NINT flags, - Xaction_s *xaction, -// cnt NINT *retNameUniquifier, - NINT *retBeastNamesAdded, /*Optional--NULL is allowed */ - NINT *retDirNamesAdded); /*Optional--Null is allowed */ - -#define INSNAMEFL_NULL_FLAG 0x00000000 -#define INSNAMEFL_NEW_PARENT_AUTH 0x00000001 /* If set, the names are for - * a new parent so the authorization - * info should be updated */ -#define INSNAMEFL_DIRECTORY_ONLY 0x00000002 /* If set, the names are only - * added in directory, there'll be no - * name operations on beast. This is - * useful for some LSS (such as CD9660) - * which only want to unpack file names - * instead of create all file beasts - */ -extern STATUS NAME_WillAddToSalvage( - struct NamedBeast_s *beast, - struct NamedBeast_s *dir, - NINT flags, - struct ParentEntry_s *pentry); - -extern STATUS NAME_RemoveAllNames( - struct GeneralMsg_s *genMsg, - void *beast, /*beast to insert*/ - void *primaryBeast, /*primary beast if one exists */ - void *directory, /*directory to remove from*/ - NINT flags, /*flags passed to beast remove routine*/ - Xaction_s *xaction, - NINT *retBeastNamesRemoved, /*Optional--NULL is allowed */ - NINT *retDirNamesRemoved, /*Optional--Null is allowed */ - ParentEntry_s *savedParentEntry); /*Optional--Null is allow, if non-null original parent entry is returned */ - -extern STATUS NAME_doAddName( - GeneralMsg_s *genMsg, - NamedBeast_s *beast, - ParentEntry_s *pentry, - NINT nameSpaceMask, - unicode_t *name, - NINT nsFlags); - -#define REMNAMEFL_REMOVE_ALL_NAMES 0x00000000 /* default -- names will be - * removed from the beast and the - * parent directory, and the parent - * entry is deleted. */ -#define REMNAMEFL_KEEP_BEAST_NAMES 0x00000001 /* if SET, keep the beast names - * and only remove names from the - * parent directory. */ -#define REMNAMEFL_KEEP_PARENT_ENTRY 0x00000002 /* if SET, keep the empty - * parent entry in the beast because we - * are renaming and we will shortly - * re-insert names back into the - * parrent*/ -#define REMNAMEFL_ATOMIC 0x00000004 /* If SET, the remove will - * be atomic, either all of the name - * entries will be removed, or none - * of them will. */ -#define REMNAMEFL_REMOVE_PARENT_AUTH 0x00000008 /* If set, the names are for - * a parent that is being removed, so - * the authorization info should be - * updated */ -#define REMNAMEFL_ADD_TO_SALVAGE 0x00000010 /* If set, the name will be - * added to the salvage system if - * it is appropriate to do so */ -#define REMNAMEFL_ERROR_BACKOUT 0x00000020 /* If set, the names are being - * removed as part of an error backout - * and it is OK if a name is not in - * the directory. */ - -extern STATUS NAME_MoveDeletedNames( - GeneralMsg_s *genMsg, - void *voidBeast, /*beast whose names are to be moved*/ - void *voidSrcDir, /*directory to move from */ - void *voidTargetDir, /*directory to insert into*/ -/* cnt NINT srcNameUniquifier, uniquifier of srcNames to be moved */ - Xaction_s *xaction -/* cnt NINT *retNameUniquifier*/); - -extern BOOL NAME_HasThisParentZID( - void *beast, - Zid_t parentZid); - -extern BOOL NAME_HasThisNameUniquifier( - void *beast -/* cnt NINT nameUniquifier*/); - -extern STATUS NAME_GetParentZid( - struct GeneralMsg_s *genMsg, - void *beast, -/* cnt NINT nameUniquifier, */ - Zid_t *retParentZid, - NINT *retNameType); - -extern ParentEntry_s *NAME_GetParentEntry( - struct GeneralMsg_s *genMsg, - void *beast -/* cnt NINT nameUniquifier*/); - -extern STATUS NAME_GetNameTypeInfo( - struct GeneralMsg_s *genMsg, - void *beast, -/* cnt NINT nameUniquifier, */ - TypeSpecificPersistentParentEntry_s **nameTypeInfo); - -extern BOOL NAME_BeastHasNameInParent( - void *beast, - Zid_t parentZid, - NINT nameSpaceID, - NINT nameType, - unicode_t *name); - -extern BOOL NAME_AllNamesInSalvage( - void *void_beast); - -BOOL NAME_ThisIsLastUndeletedName( - ParentEntry_s *pentry, - NamedBeast_s *beast); - -//extern BOOL NAME_BeastHasWildcardName( -// void *void_beast, -// NINT nameUniquifier, -// NINT nameSpaceID, -// NINT nameType, -// unicode_t *wildcardPattern); - -extern STATUS NAME_GetFirstNameFromBeast( - struct GeneralMsg_s *genMsg, - void *voidBeast, - NINT retNameSize, /* may be 0 */ - unicode_t *retName, /* may be NULL */ - NINT *retNameSpaceID, /* may be NULL */ - NINT *retNameType, /* may be NULL */ - NINT *retNameLen); /* may be NULL */ - -extern STATUS NAME_RenameBeast( - struct GeneralMsg_s *genMsg, - void *srcBeast, - void *primaryBeast, - void *srcDir, - void *targetDir, - unicode_t *srcName, - unicode_t *newName, - struct NameSpace_s *nameSpace, - NINT srcNameType, - NINT newNameType, - struct RenameMsg_s *renMsg, - Xaction_s *xaction); /* May be NULL -- In fact is usually NULL */ - -extern void *NAME_FindNameInAsciiNameCache( - struct GeneralMsg_s *genMsg, - struct File_s *directory, - struct NameSpace_s *nameSpace, - NINT nameType, - NINT asciiNameLen, - char *asciiName, - NINT latchType, - BOOL dontDoVisibilityCheck -/* cnt NINT *retNameUniquifier*/); - -extern Zid_t NAME_FindZidForNameInDir( - struct GeneralMsg_s *genMsg, - void *directory, - struct NameSpace_s *nameSpace, - NINT nameType, - unicode_t *name, - NINT asciiNameLen, /* May be 0. If non-zero, will add ASCII name to name Cache */ - char *asciiName, /* May be NULL if asciiNameLen is 0 */ - BOOL negativeNameCacheFlag -/* cnt NINT *retNameUniquifier*/); - - -extern void *NAME_FindNameInDir( - struct GeneralMsg_s *genMsg, - void *directory, - struct NameSpace_s *nameSpace, - NINT nameType, - unicode_t *name, - NINT asciiNameLen, /* May be 0. If non-zero, will add ASCII name to name Cache */ - char *asciiName, /* May be NULL if asciiNameLen is 0 */ - NINT latchType, - BOOL negativeNameCacheFlag, - BOOL dontDoVisibilityCheck -/* cnt NINT *retNameUniquifier*/); - -extern void *NAME_FindNameInDirSpecialRules( - struct GeneralMsg_s *genMsg, - struct NamingMsg_s *nameMsg, - struct NameSpace_s **dosNameSpace, - BOOL negativeNameCacheFlag, - BOOL dontDoVisibilityCheck -/* cnt NINT *retNameUniquifier*/); - -extern STATUS NAME_RemoveBeastlessNameFromDir( - struct GeneralMsg_s *genMsg, - Zid_t badzid, - void *directory, - struct NameSpace_s *nameSpace, - NINT nameType, - struct FullDirectoryInfo_s *nameInfo); - -extern void NAME_RemoveStrandedParentEntry( - struct GeneralMsg_s *genMsg, - struct NamedBeast_s *beast, - struct ParentEntry_s *pentry, - struct Xaction_s *xaction); - -extern STATUS NAME_CacheInit(); - -extern void NAME_CacheUninit(); - -extern void NAME_AddNameToCache( - QUAD count, - Volume_s *volume, - Zid_t parentZid, - struct NameSpace_s *nameSpace, - NINT nameType, - unicode_t *uniName, - NINT asciiNameLen, /* May be 0 */ - char *asciiName, /* May be NULL if asciiNameLen is 0 */ - Zid_t zid -/* cnt NINT nameUniquifier*/); - -extern Zid_t NAME_GetNameFromCacheUnicode( - VolumeID_t *volume, - Zid_t parentZid, - struct NameSpace_s *nameSpace, - NINT nameType, - unicode_t *uniName, - BOOL *negativeEntryFlag, - QUAD *count -/* cnt NINT *retNameUniquifier*/ ); - -extern Zid_t NAME_GetNameFromCacheAscii( - VolumeID_t *volume, - Zid_t parentZid, - struct NameSpace_s *nameSpace, - NINT nameType, - NINT asciiNameLen, - char *asciiName, - BOOL *negativeEntryFlag, - QUAD *count -/* cnt NINT *retNameUniquifier*/); - - -extern STATUS NAME_RemoveNameFromCache( - struct GeneralMsg_s *genMsg, - Volume_s *volume, - Zid_t parentZid, - NINT nameSpaceMask, - NINT nameType, - unicode_t *uniName, - NINT nsFlag); - -extern BOOL NAME_MatchAttributes( - NINT beastAttributes, - struct zMatchAttr_s *matchAttr); - -extern STATUS NAME_HardLinkSetMatchAttributesInDirectory( - struct GeneralMsg_s *genMsg, - struct File_s *curFile, - struct File_s *curDir, - NINT newFileAttributes, - NINT oldFileAttributes, - struct Xaction_s *xaction); - -extern STATUS NAME_SetMatchAttributesInDirectory( - struct GeneralMsg_s *genMsg, - struct File_s *curFile, - struct File_s *curDir, -/* cnt NINT fileNameUniquifier, */ - NINT newFileAttributes, - NINT oldFileAttributes, - struct Xaction_s *xaction); - - -extern void NAME_InvalidateCacheEntriesForVolume( - VolumeID_t *volume); - -extern void NAME_InvalidateCacheEntriesForDirectory( - VolumeID_t *volume, - Zid_t directoryZid); - -extern void NAME_Reoptimize( - void); - -extern void NAME_ReoptimizeStarter( - void); - -extern NameCacheCtrl_s NameCache; - -#if NSS_DEBUG IS_ENABLED -extern CONST unicode_t *NAME_GetFirstNameForDebug(void *voidBeast); -extern void ZAS_DisplayNameCache(void); -#endif - -extern BOOL NameCacheEnabled; -extern BOOL AsciiNameCacheEnabled; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/nwnss/include/nameSpace.h b/include/nwnss/include/nameSpace.h index 3bcc3bc..d028432 100644 --- a/include/nwnss/include/nameSpace.h +++ b/include/nwnss/include/nameSpace.h @@ -42,14 +42,14 @@ +-------------------------------------------------------------------------*/ #ifndef _NAMESPACE_H_ #define _NAMESPACE_H_ -#include +#include #ifndef _COMNPARAMS_H_ -# include +# include #endif #ifndef _COMNBEASTS_H_ -# include +# include #endif #ifdef __cplusplus @@ -81,7 +81,7 @@ struct NameSpace_s { AdminVolFile_s avfile; /* derived from*/ NINT nSpaceID; /* name space ID*/ - unicode_t *name; /* pointer to name of namespace*/ + unicode_t *name; /* pointer to name of namespace*/ NINT flags; /* name space flags, defined below */ NameSpaceOps_s *nSpaceOps; /* Pointer to Name Space Specific Ops */ }; @@ -106,7 +106,7 @@ struct NameSpace_s * This structure is used to track the parsing status of a path string. The * original source path string can be NULL-terminated ASCII, ASCII with a * length or NULL-terminated unicode. - * + * * This structure is used to track the parsing of the path, one component * at a time. Each component may be optionally returned in ASCII with length * or NULL-terminate unicode. The content of the component determines which @@ -116,11 +116,11 @@ struct NameSpace_s * bypass the translation to unicode and skip the full unicode validation if * the partially validated ASCII component string exists in the ASCII name * cache. - * + * *---------------------------------------------------------------------------*/ typedef struct ScanComponentMsg_s { - NINT scanFlags; /* These flags maintain state information + NINT scanFlags; /* These flags maintain state information * across the entire path parsing process. */ /*------------------------------------------------------------------------ @@ -129,7 +129,7 @@ typedef struct ScanComponentMsg_s * not set. *-----------------------------------------------------------------------*/ char *asciiSrcPath; /* Input ASCII Source path */ - NINT asciiSrcLength; /* Length of asciiSrcPath. This should be -1 + NINT asciiSrcLength; /* Length of asciiSrcPath. This should be -1 * if asciiSrcPath NULL Terminated */ NINT uniConversionType; /* if == NSS_UNI_CONVERSION_NSPACE_DEFAULT then * use the nameSpace default ascii to unicode @@ -156,7 +156,7 @@ typedef struct ScanComponentMsg_s unicode_t *uniSrcPath; /* Input unicode source path buffer. This could * point to a buffer originally passed in as * unicode, or it could point to a unicode - * component which has been translated from + * component which has been translated from * ASCII */ unicode_t *uniWorkBuffer2; /* Must point to a work buffer which can be used * to store the final scanned uincode component. @@ -189,7 +189,7 @@ typedef struct ScanComponentMsg_s * next component is scanned. The common layer * resets them each time it calls the name * space to scan the next component */ - unicode_t *retUniSrcPath; /* This is filled in with a ptr to any + unicode_t *retUniSrcPath; /* This is filled in with a ptr to any * remaining unicode unscanned path data. It is * set to a NULL if no more unicode path data * is left to be scanned. */ @@ -214,7 +214,7 @@ typedef struct ScanComponentMsg_s #define NSSFL_asciiBreakNotSpecial 0x00000008 #define NSSFL_insertAsciiBreaks 0x00000010 #define NSSFL_parsingFirstComponent 0x00000020 -#define NSSFL_volumeNameOverrideAllowed 0x00000040 +#define NSSFL_volumeNameOverrideAllowed 0x00000040 #define NSSFL_noPathSeparatorsAllowed 0x00000080 #define NSSFL_moreComponentsFollow 0x00000100 #define NSSFL_forceConvertToUnicode 0x00000200 @@ -252,11 +252,11 @@ typedef struct ScanComponentMsg_s (_scanMsg)->asciiValidCharBitMap = (_bitMap), \ (_scanMsg)->asciiWorkBuffer = (char *)(_workBuf), \ (_scanMsg)->uniWorkBuffer1 = \ - (unicode_t *)((_workBuf) + zMAX_COMPONENT_NAME), \ + (unicode_t *)((_workBuf) + zMAX_COMPONENT_NAME), \ (_scanMsg)->uniSrcPath = NULL, \ (_scanMsg)->uniWorkBuffer2 = \ - (unicode_t *)((_workBuf) + zMAX_COMPONENT_NAME + \ - (zMAX_COMPONENT_NAME * sizeof(unicode_t)))) + (unicode_t *)((_workBuf) + zMAX_COMPONENT_NAME + \ + (zMAX_COMPONENT_NAME * sizeof(unicode_t)))) /* This macro is used to setup a scanMsg for scanning a unicode string */ #define NSPACE_SETUP_UNICODE_SCAN_MSG(_scanMsg,_sFlags,_srcPath,_workBuf) \ @@ -266,10 +266,10 @@ typedef struct ScanComponentMsg_s (_scanMsg)->uniSrcPath = (_srcPath), \ (_scanMsg)->asciiWorkBuffer = (char *)(_workBuf), \ (_scanMsg)->uniWorkBuffer1 = \ - (unicode_t *)((_workBuf) + zMAX_COMPONENT_NAME), \ + (unicode_t *)((_workBuf) + zMAX_COMPONENT_NAME), \ (_scanMsg)->uniWorkBuffer2 = \ - (unicode_t *)((_workBuf) + zMAX_COMPONENT_NAME + \ - (zMAX_COMPONENT_NAME * sizeof(unicode_t)))) + (unicode_t *)((_workBuf) + zMAX_COMPONENT_NAME + \ + (zMAX_COMPONENT_NAME * sizeof(unicode_t)))) /* This macro is used to setup a scanMsg for scanning a UTF8 string */ #define NSPACE_SETUP_UTF8_SCAN_MSG(_scanMsg,_sFlags,_srcPath,_srcLen,_workBuf) \ @@ -280,11 +280,11 @@ typedef struct ScanComponentMsg_s (_scanMsg)->asciiValidCharBitMap = NULL, \ (_scanMsg)->asciiWorkBuffer = (char *)(_workBuf), \ (_scanMsg)->uniWorkBuffer1 = \ - (unicode_t *)((_workBuf) + zMAX_COMPONENT_NAME), \ + (unicode_t *)((_workBuf) + zMAX_COMPONENT_NAME), \ (_scanMsg)->uniSrcPath = NULL, \ (_scanMsg)->uniWorkBuffer2 = \ - (unicode_t *)((_workBuf) + zMAX_COMPONENT_NAME + \ - (zMAX_COMPONENT_NAME * sizeof(unicode_t)))) + (unicode_t *)((_workBuf) + zMAX_COMPONENT_NAME + \ + (zMAX_COMPONENT_NAME * sizeof(unicode_t)))) /*------------------------------------------------------------------------- * Definition of Name Space Ops code. diff --git a/include/nwnss/include/napi.h b/include/nwnss/include/napi.h new file mode 100644 index 0000000..c5b5903 --- /dev/null +++ b/include/nwnss/include/napi.h @@ -0,0 +1,78 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Defines/structures and prototypes that users of nssLnxLib need. + +-------------------------------------------------------------------------*/ + +#include "omni.h" + + // Unit tests +#define FDAT_UNIT_TEST + +void FormatDateAndTime( + BYTE *buffer, /* Buffer for results */ + LONG year, /* Year */ + LONG month, /* Month */ + LONG day, /* Day */ + LONG hour, /* Hour */ + LONG minute, /* Minute */ + LONG second, /* Second */ + LONG flags); /* Format flags */ + +/* + Flags passed to date and time formatting routines +*/ +#define EN_INCLUDE_SECONDS 0x01 /* Include seconds in time */ +#define EN_INCLUDE_WEEKDAY 0x02 /* Include the day of the week in date */ +#define EN_USE_ALPHA_MONTH 0x04 /* Use month name, not number */ +#define EN_USE_4_DIGIT_YEAR 0x08 /* Print four digit year */ +#define EN_USE_ABBREV_MONTH 0x10 /* Use month abbreviation, not number */ + +/* + Buffer lengths required for formatting dates and times. The numeric + format lengths are known, but those with text for the day of the week + and the month are padded, since we don't know how long they may be + after translation +*/ +#define EN_TIME_LEN 11 /* HH:MM:SSam */ +#define EN_DATE_LEN 11 /* MM/DD/YYYY */ +#define EN_DATE_TIME_LEN 23 /* MM/DD/YYYY HH:MM:SSam */ +#define EN_TEXT_DATE_LEN 80 /* Wednesday September 31, 1990 HH:MM:SSam*/ + + + +#ifdef FDAT_UNIT_TEST +int FDAT_UnitTest(); +#endif + diff --git a/include/nwnss/include/ndp_app.h b/include/nwnss/include/ndp_app.h deleted file mode 100644 index ea25a6d..0000000 --- a/include/nwnss/include/ndp_app.h +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************************** - | NSS userspace NDP application context compatibility. - | - | The original NDP shared sources include on the application side, - | but the delivered source snapshot only carries the equivalent ndpmod context - | layout. Keep this header limited to the context fields used by the shared - | NDP sources so the Novell shared *.c.h files can be wrapped unchanged. - +-------------------------------------------------------------------------*/ - -#ifndef NDP_APP_H -#define NDP_APP_H - -#include - -typedef struct ndpAppOptions_t { - /* Use the shared ndp_debug global instead of per-context debug state. */ - int unused; -} ndpAppOptions_t; - -typedef struct ndpContext_t { - char *appName; - GUID_t appGuid; - GUID_t appGuidPrime; - ndpAppOptions_t options; - ndp_guidmsgcontext_t *ndpMsgQueueContext; - ndp_guidlistcontext_t *guidListContext; -} ndpContext_t; - -#endif /* NDP_APP_H */ diff --git a/include/nwnss/include/ndp_comn.h b/include/nwnss/include/ndp_comn.h index a22ec18..658a063 100644 --- a/include/nwnss/include/ndp_comn.h +++ b/include/nwnss/include/ndp_comn.h @@ -161,13 +161,13 @@ #endif /* ((defined(__KERNEL__) && defined(NO_MOD_LOCKING)) \ || (! defined(__KERNEL__) && defined(NO_APP_LOCKING))) */ -#include /* for "GUID_t" --- DO NOT USE zOmni.h !!! */ +#include /* for "GUID_t" --- DO NOT USE zOmni.h !!! */ #undef QUE_MACRO #define QUE_MACRO ENABLE #undef QUE_CHECK #define QUE_CHECK DISABLE -#include /* for queue NSS definitions/macros */ +#include /* for queue NSS definitions/macros */ /****************************************************************************** ******************************************************************************* @@ -723,3 +723,4 @@ void ndp_deregisterGuid( GUID_t *guidPrime); #endif /* NDP_COMN_H */ + diff --git a/include/nwnss/include/ndp_guids.h b/include/nwnss/include/ndp_guids.h index 9850dcf..c410740 100644 --- a/include/nwnss/include/ndp_guids.h +++ b/include/nwnss/include/ndp_guids.h @@ -54,7 +54,7 @@ BYTE node[6]; }; #else -# include /* for "GUID_t" --- DO NOT USE zOmni.h !!! */ +# include /* for "GUID_t" --- DO NOT USE zOmni.h !!! */ #endif /****************************************************************************** @@ -67,3 +67,4 @@ extern GUID_t ndpAppGuid; extern GUID_t ndpModGuid; #endif /* NDP_GUIDS_H */ + diff --git a/include/nwnss/include/ndp_idbroker.h b/include/nwnss/include/ndp_idbroker.h index 9b40ac5..be93f95 100644 --- a/include/nwnss/include/ndp_idbroker.h +++ b/include/nwnss/include/ndp_idbroker.h @@ -42,7 +42,7 @@ # include #endif -// Not in Here // #include +// Not in Here // #include /***************************************************************************** * Unless otherwise stated, DNs are in: @@ -58,7 +58,7 @@ * The NDP ID Broker Message Handling Routine * These routines run in their own threads... ******************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ void *ndp_idBroker_messagehandler( THREAD thread, void *_threadContext); @@ -106,7 +106,7 @@ int ndp_cleanup_idBroker(void); /***************************************************************************** * uid To FDN *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_namGetUserFDNfromUID( int uid, unicode_t **userFDN); @@ -120,7 +120,7 @@ int ndp_namGetUserFDNfromUID_handler( /***************************************************************************** * DN To GUID - with create flag *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPMapDNToGUID( int create, unicode_t *dn, @@ -135,7 +135,7 @@ int ndp_NCPMapDNToGUID_handler( /***************************************************************************** * Return Tree Name (unicode) *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPLocalTreeName( size_t treeNameSize, unicode_t *treeName); @@ -154,7 +154,7 @@ int ndp_NCPLocalTreeName_handler( * ERR_INSUFFICIENT_BUFFER. guidSevCount will be the count of guids which * exist. *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPMapDNToSEV( unicode_t *dn, size_t *guidSEVCount, @@ -170,7 +170,7 @@ int ndp_NCPMapDNToSEV_handler( /***************************************************************************** * GUID To Management Level *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPMapGUIDToMgtLevel( size_t guidCount, GUID_t *guids, @@ -186,7 +186,7 @@ int ndp_NCPMapGUIDToMgtLevel_handler( /***************************************************************************** * Map GUID To DN *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPMapGUIDToDN( GUID_t *guid, size_t dnSize, @@ -201,7 +201,7 @@ int ndp_NCPMapGUIDToDN_handler( /***************************************************************************** * GUID To UID *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPMapGUIDToUID( GUID_t *guid, LONG *uid); @@ -215,7 +215,7 @@ int ndp_NCPMapGUIDToUID_handler( /***************************************************************************** * UID To GUID *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPMapUIDToGUID( LONG uid, GUID_t *guid); @@ -229,7 +229,7 @@ int ndp_NCPMapUIDToGUID_handler( /***************************************************************************** * Get UID From Name *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_GetUIDFromName( unsigned char *name, LONG *uid); @@ -243,7 +243,7 @@ int ndp_GetUIDFromName_handler( /***************************************************************************** * Generate Volume Key Info for an encrypted volume *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_GenerateVolumeKeyInfo( unicode_t *volumePassword, /* volume password for the new volume */ BYTE *retKey, /* ptr to 16 byte buffer to receive the new key */ @@ -258,7 +258,7 @@ int ndp_GenerateVolumeKeyInfo_handler( /***************************************************************************** * Extract Volume Key Info for an encrypted volume *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_ExtractVolumeKeyInfo( unicode_t *volumePassword, /* volume password for the new volume */ BYTE *volP, /* ptr to 128 byte persistent portion of VolumeKey_s */ @@ -278,7 +278,7 @@ int ndp_ExtractVolumeKeyInfo_handler( * if already registered (-2) * if invalid function pointer (-1) *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_register_NCPNotifyDNChange( void (*NCPNotifyDNChange)(unicode_t *oldDN, unicode_t *newDN) ); #endif @@ -287,7 +287,7 @@ int ndp_register_NCPNotifyDNChange( * Notification If DN Has Been Renamed Or Deleted * If newDN is 0, the object has been deleted *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPNotifyDNChange_handler( GUID_t *srcGuid, LONG length, @@ -305,7 +305,7 @@ int ndp_NCPNotifyDNChange_handler( * if already registered (-2) * if invalid function pointer (-1) *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_register_NCPNotifySEVChange( void (*NCPNotifySEVChange)(GUID_t *guid) ); #endif @@ -313,7 +313,7 @@ int ndp_register_NCPNotifySEVChange( /***************************************************************************** * Notification If SEV (Security Equivalence Vector) Has Been Changed *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPNotifySEVChange_handler( GUID_t *srcGuid, LONG length, @@ -324,3 +324,4 @@ int ndp_NCPNotifySEVChange_handler( */ #endif /* NDP_IDBROKER_H */ + diff --git a/include/nwnss/include/ndp_messagehandler.h b/include/nwnss/include/ndp_messagehandler.h index 9dc7b47..6d105c7 100644 --- a/include/nwnss/include/ndp_messagehandler.h +++ b/include/nwnss/include/ndp_messagehandler.h @@ -40,16 +40,16 @@ #ifdef __KERNEL__ -# include +# include # include #else /* NOTE: ndp_comn.h needs included before anything else in application land */ -# include -# include -# include +# include +# include +# include #endif -#include +#include /****************************************************************************** ******************************************************************************* @@ -69,3 +69,4 @@ void ndp_messagehandler( unsigned char *data); #endif /* NDP_MESSAGEHANDLER_H */ + diff --git a/include/nwnss/include/ndp_msg.h b/include/nwnss/include/ndp_msg.h index 7e5af6f..d249ecf 100644 --- a/include/nwnss/include/ndp_msg.h +++ b/include/nwnss/include/ndp_msg.h @@ -38,8 +38,8 @@ #ifndef NDP_MSG_H #define NDP_MSG_H -#include -// Not in Here // #include +#include +// Not in Here // #include #include #include @@ -216,3 +216,4 @@ int ndpmsgop_NCPNotifySEVChange( GUID_t *guid); #endif /* NDP_MSG_H */ + diff --git a/include/nwnss/include/nebprivate.h b/include/nwnss/include/nebprivate.h new file mode 100644 index 0000000..c7cbc77 --- /dev/null +++ b/include/nwnss/include/nebprivate.h @@ -0,0 +1,359 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | File Name: nkeventpri.h + | Created by: Clyde Griffin + | Date created: 11/1/1998 + | + | %version: 6 % + | %derived_by: cgriffin % + | %date_modified: Fri Oct 19 17:54:39 2001 % + | + *****************************************************************************/ + +#ifndef __NKEVENTPRI_H__ +#define __NKEVENTPRI_H__ + +#ifdef __KERNEL__ +#include +#else +#include +#endif +/***************************************************************************/ +/****************************** include files ******************************/ +/***************************************************************************/ + + +/***************************************************************************/ +/*************************** macro definitions *****************************/ +/***************************************************************************/ + +#ifndef NEB_STATUS +#define NEB_STATUS int +#endif + +#ifdef __KERNEL__ +typedef unsigned int *uintptr_t; +#endif + + +#define NEB_EVENT_VERSION1 1 +#define NEB_PRODUCER_VERSION1 1 +#define NEB_CONSUMER_VERSION1 1 +#define NEB_FILTER_VERSION1 1 + +#define EVENT_BLOCK_STAMP 0x4B4C4245 /* 'KLBE' */ + +#define EVENT_BLOCK_SIGNATURE 0x42545645 /* 'BTVE' */ + +#define MAX_EVENT_USER_NAME_LENGTH 80 /* Includes NULL terminator */ + +#define MAX_FILTER_NAME_LENGTH 80 /* Includes NULL terminator */ + +#define MAX_EVENT_NAME_LENGTH 256 /* Included NULL terminator */ + + /* Event flags */ +#define MAY_NOT_SLEEP_BIT 0x00000001 +#define SORT_LOW_TO_HIGH_BIT 0x00000002 +#define CONSUMABLE_BIT 0x00000004 +#define NO_SA_BIT 0x00000008 +#define NO_AUDITOR_BIT 0x00000010 +#define NO_CHECK_BIT 0x00000020 + /* Data is NESL encapsulated data */ +#define NESL_DATA_BIT 0x00000040 + /* NESL shim's way of telling neb how to resolve bit definitions */ + /* with regular NEB components. */ +#define NESL_SHIM_BIT 0x00000080 +#define EF_UNDEFINED_MASK !(MAY_NOT_SLEEP_BIT | SORT_LOW_TO_HIGH_BIT | \ + CONSUMABLE_BIT | NO_SA_BIT | NO_AUDITOR_BIT | NO_CHECK_BIT | \ + NESL_DATA_BIT | NESL_SHIM_BIT) +#define DATA_FILTERED_BIT 0x80000000 + + /* ProducerFlags */ +#define UNIQUE_PRODUCER_BIT 0x00000001 + + /* ConsumerFlags */ +#define CONSUMABLE_CONSUMER_BIT 0x00000001 +#define ACCESS_CONTROL_CHECK_BIT 0x00000002 + + /* Shared (Producer/Consumer)Flags */ +#define EVENT_CLASS_BIT 0x40000000 +#define SMP_ENABLED_BIT 0x80000000 + + /* User types */ +#define PRODUCER 0 +#define SECURITY_AUTHORITY_CONSUMER 1 +#define AUDITOR_CONSUMER 2 +#define CHECK_CONSUMER 3 +#define SYNCHRONOUS_CONSUMER 4 +#define ASYNCHRONOUS_CONSUMER 5 +#define DEBUG_CONSUMER 6 +#define RESERVED 7 + + /* Consumer Notify type codes */ +#define NOTIFY_AUDITOR 0 + +#define VALIDATE_PRODUCER_REGISTRATION 1 +#define VALIDATE_CHECK_CONSUMER_REGISTRATION 2 +#define VALIDATE_SYNC_CONSUMER_REGISTRATION 3 +#define VALIDATE_ASYNC_CONSUMER_REGISTRATION 4 + +#define NOTIFY_SECURITY_AUTHORITY 5 +#define VERIFY_CHECK_CONSUMER 6 +#define VERIFY_SYNC_CONSUMER 7 +#define VERIFY_ASYNC_CONSUMER 8 + +#define NOTIFY_CHECK_CONSUMER 9 +#define NOTIFY_SYNCHRONOUS_CONSUMER 10 +#define NOTIFY_ASYNCHRONOUS_CONSUMER 11 +#define NOTIFY_DEBUGGER 12 + +#define NOTIFY_PRODUCER_UNREGISTRATION 13 +#define NOTIFY_CHECK_CONSUMER_UNREGISTRATION 14 +#define NOTIFY_SYNC_CONSUMER_UNREGISTRATION 15 +#define NOTIFY_ASYNC_CONSUMER_UNREGISTRATION 16 + +#define NOTIFY_REGISTRATION_FAILED 17 + +#define NOTIFY_PROD_OF_CONS_REG 18 +#define NOTIFY_PROD_OF_CONS_UNREG 19 + +#define NOTIFY_CONS_OF_PROD_REG 20 +#define NOTIFY_CONS_OF_PROD_UNREG 21 + +#define ADD_CONS_TO_FILTER 22 +#define REMOVE_CONS_FROM_FILTER 23 +#define VALIDATE_FILTER 24 +#define NOTIFY_FILTER 25 + +#define SIDE_BAND_MESSAGE 26 + +#define NOTIFY_CHECK_OPERATION_DENIED 27 + + /* Consumer ESR ccodes */ + /* Security Authority, Auditor, and Check Consumers ESR ccodes bits */ +#define ACCESS_APPROVED 0x00000000 +#define ACCESS_DENIED 0x00000001 +#define AUDITOR_APPROVED 0x00000000 +#define AUDITOR_DENIED 0x00000002 +#define CCODE_RESERVED 0x7F0000FC +#define USER_DEFINABLE 0x00FFFF00 +#define FUNCTION_NOT_SUPPORTED 0x80000000 + + /* Synchronous consumer ESR ccodes */ +#define EVENT_NOT_CONSUMED 0x00000000 +#define EVENT_CONSUMED 0x00000001 +#define FUNCTION_NOT_SUPPORTED 0x80000000 + + /* Produce Event ccodes */ +#define SUCCESS 0 +#define INVALID_PARAMETER -1 +#define EVENT_DENIED -2 +#define OPERATION_DENIED -3 + + /* Send Event ccodes */ +#define SUCCESS 0 +#define INVALID_PARAMETER -1 +#define SIDEBAND_NOT_SUPPORTED -2 + + /* RegisterProducer ccodes */ +#define SUCCESS 0 +#define INVALID_PARAMETER -1 +#define OUT_OF_RESOURCES -2 +#define EVENT_CONFLICT -3 +#define REGISTRATION_DENIED -4 +#define PRODUCER_NOT_UNIQUE -5 + + /* RegisterConsumer ccodes */ +#define SUCCESS 0 +#define INVALID_PARAMETER -1 +#define OUT_OF_RESOURCES -2 +#define EVENT_CONFLICT -3 +#define REGISTRATION_DENIED -4 +#define CONSUMER_ALREADY_REGISTERED -5 +#define INVALID_CONSUMER_TYPE -6 +#define INVALID_FILTER -7 + + /* RegisterFilter ccodes */ +#define SUCCESS 0 +#define INVALID_PARAMETER -1 +#define OUT_OF_RESOURCES -2 +#define DUPLICATE_FILTER -3 + +/***************************************************************************/ +/******************** imported type and tag declarations *******************/ +/***************************************************************************/ + +/***************************************************************************/ +/******************* exported type and tag declarations ********************/ +/***************************************************************************/ + +struct EventBlock +{ + uint32_t EBVersion; + uint32_t EBStamp; + struct EventBlock *EBILink; + struct ResourceTagStructure *EBRTag; + + void *EBLink; + void *EBProducerID; + void *EBProducerWorkSpace; + void *EBConsumingConsumer; + + uint32_t EBEventDataLength; + void *EBEventData; + union DataBlock + { + uint8_t B8[16]; + uint16_t B16[8]; + uint32_t B32[4]; + } EBShortData; + + uint32_t EBEventNotifyType; + void *EBUserParameter; + + void *EBParm0; + void *EBParm1; + uint32_t EBEventFlags; + uint32_t EBReserved[1]; +}; + +struct ProducerRegistrationInfo +{ + uint32_t PRIVersion; + char *PRIProducerName; + char *PRIEventName; + void *PRIUserParameter; + uint32_t PRIEventFlags; + struct LoadDefinitionStructure *PRIOwnerID; + NEB_STATUS (*PRIProducerESR)( + struct EventBlock *eventBlock); + void *PRISecurityToken; + uint32_t PRIProducerFlags; + uint32_t PRIPriority; + void *PRIEventID; + void *PRIProducerID; +}; + +struct ConsumerRegistrationInfo +{ + uint32_t CRIVersion; + char *CRIConsumerName; + char *CRIEventName; + void *CRIUserParameter; + uint32_t CRIEventFlags; + struct LoadDefinitionStructure *CRIOwnerID; + NEB_STATUS (*CRIConsumerESR)( + struct EventBlock *eventBlock); + void *CRISecurityToken; + uint32_t CRIConsumerFlags; + char *CRIFilterName; + uint32_t CRIFilterDataLength; + void *CRIFilterData; + NEB_STATUS (*CRIConsumerCallback)( + struct EventBlock *eventBlock); + uint32_t CRIConsumerType; + uint32_t CRIOrder; + void *CRIConsumerID; +}; + +struct FilterRegistrationInfo +{ + uint32_t FRIVersion; + char *FRIFilterName; + struct LoadDefinitionStructure *FRIOwnerID; + NEB_STATUS (*FRIFilterESR)( + struct EventBlock *eventBlock); + void *FRIFilterID; +}; + +struct EventInformation +{ + uint32_t numberOfProducers; + uint32_t numberOfSynchronousConsumers; + uint32_t numberOfAsynchronousConsumers; + uint32_t eventFlags; + uint32_t eventProducedCount; + char *eventName; +}; + +/***************************************************************************/ +/******************** imported data object declarations ********************/ +/***************************************************************************/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#ifdef __cplusplus +} +#endif + +/***************************************************************************/ +/******************* exported data object definitions **********************/ +/***************************************************************************/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#ifdef __cplusplus +} +#endif + +/***************************************************************************/ +/******************** imported function declarations ***********************/ +/***************************************************************************/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#ifdef __cplusplus +} +#endif + +/***************************************************************************/ +/******************** exported function declarations ***********************/ +/***************************************************************************/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#ifdef __cplusplus +} +#endif + +/***************************************************************************/ +/****************************** end of file ********************************/ +/***************************************************************************/ +#endif /* __NKEVENTPRI_H__ */ + diff --git a/include/nwnss/include/nebpub.h b/include/nwnss/include/nebpub.h deleted file mode 100644 index 43c24c6..0000000 --- a/include/nwnss/include/nebpub.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** - | - | (C) Copyright 2001 Novell, Inc. - | All Rights Reserved. - | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. - | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. - | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. - | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com - | - |*************************************************************************** - | - | $RCSfile$ - | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - | $Revision: 465 $ - | - +***************************************************************************/ - -#ifndef _NEBPUB_H_ -#define _NEBPUB_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef __NKEVENT_H__ - -extern LONG GetConsumerName( - void *consumerID, - BYTE *consumerName); - -extern struct EventBlock *GetEventBlocks( - void *ownerID, - LONG numberOfEventBlocksToGet); - -extern LONG GetProducersEventName( - void *producerID, - BYTE *eventName); - -extern LONG GetProducerName( - void *producerID, - BYTE *producerName); - -extern LONG ReturnEventBlocks( - struct EventBlock *eventBlock); - -extern LONG ProduceEvent( - struct EventBlock *eventBlock); - -extern LONG RegisterConsumer( - struct ConsumerRegistrationInfo *regConsumer); - -extern LONG RegisterFilter( - struct FilterRegistrationInfo *regFilter); - -extern LONG RegisterProducer( - struct ProducerRegistrationInfo *regProducer); - -extern LONG UnRegisterConsumer( - void *consumerID, - void *userParameter); - -extern LONG UnRegisterFilter( - void *filterID); - - -extern LONG UnRegisterProducer( - void *producerID, - void *userParameter); - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/nwnss/include/nssAdminLib.h b/include/nwnss/include/nssAdminLib.h index 607440f..e7b44a5 100755 --- a/include/nwnss/include/nssAdminLib.h +++ b/include/nwnss/include/nssAdminLib.h @@ -50,3 +50,4 @@ void CloseNSSAdminLib(void); /*===========================================================================*/ #endif + diff --git a/include/nwnss/include/nssCOMN.imp b/include/nwnss/include/nssCOMN.imp new file mode 100644 index 0000000..3df1525 --- /dev/null +++ b/include/nwnss/include/nssCOMN.imp @@ -0,0 +1,400 @@ +AdminVolDirs +asyncReadAhead +asyncReadFileBlk +attrBitsToCheck +attrTags +AUTHSYS_VolInit +AuthModelIDMap +AuthModels +BEASTHASH_Insert +BEASTHASH_LookupByZid +BEASTHASH_incrementUseCount +BST_ArrayIndex2ClassID +BST_ClassID2ArrayIndex +BST_cleanupDeletedFile +BST_doPackIndex +BST_doUnpackIndex +BST_flush +BST_free +BST_getPackedSizeIndex +BST_MarkCleanAndNotNew +BST_MarkDirty +BST_MarkXLocal +BST_new +BST_noPackCleanupIndex +BST_PurgeFileName +BST_releaseAndFree +BST_truncate +CM_cleanupBeast +CM_compressFileRange +CM_curCompStatistics +CM_prepareToTruncateFile +CM_prepareToWriteCompFile +CM_resetVolumeCompState +CM_tossUncompBeastData +CM_uncompressFileRange +CM_StartUpgradeProcess +NSSUT_DisplayAll +COMN_AbortUserXaction +COMN_AbortXLocal +COMN_AddMACDataStreamToNameMsg +COMN_AllocSemanticAgentHandle +COMN_AsyncRead +COMN_AsyncReleaseBuffer +COMN_AsyncSetupDSIAndUpdateInNDS +COMN_BeginUserXaction +COMN_BeginXLocal +COMN_BrowseBeastsInVolume +COMN_ChangeContextHandle +COMN_ChangePoolState +COMN_ChangePoolStateByName +COMN_ChangeSingleVolumeStateByName +COMN_ChangeStateCommandLineSwitches +COMN_ChangeVolumeState +COMN_ChangeVolumeStateByName +COMN_CheckLowSpace +COMN_CleanupCallToDSI +COMN_CleanupNameMsg +COMN_CleanupSAgentOnVolume +COMN_CleanupSearchMsg +COMN_ClearLSSOpsForBeastClass +COMN_ClearTaskBasedContextHandles +COMN_Close +COMN_ClusterIDGet +COMN_ClusterSoftwareIsCheckingPoolStateChanges +COMN_CommitUserXaction +COMN_CopyFileToFile +COMN_Create +COMN_CreateWithCallback +COMN_D_Buf +COMN_E_Buf +COMN_EndXLocal +COMN_Delete +COMN_DeleteBeast +COMN_DestroyContextHandle +COMN_DirectReadFile +COMN_DirectWriteFile +COMN_DisableEncryptedVolume +COMN_DoReleaseContextHandleIDP +COMN_DoReleaseSAgentHandleIDP +COMN_DoResolveConnection +COMN_DoResolveContextHandle +COMN_DoResolveFileHandle +COMN_DoResolveSemanticAgentHandle +COMN_EnableEncryptedVolume +COMN_Encrypted_Page_Head +COMN_EndOfTaskCleanup +COMN_FastReadCache +COMN_FindAuthModelByName +COMN_FindDefaultXaction +COMN_FixVolumeCompStats +COMN_Flush +COMN_FlushVolume +COMN_FlushAndTossBeast +COMN_ForceBeastWrite +COMN_FreeRootVariableData +COMN_FreeSemanticAgentHandle +COMN_GetAdminVolume +COMN_GetFileBlk +COMN_GetFileMap +COMN_GetFileNameFromZid +COMN_ZidToFileName +COMN_GetBeastFullName +COMN_GetBeastInfoXML +COMN_GetInfo +COMN_GetInfoByBeastPtr +COMN_GetMACDataStreamPtr +COMN_GetManagementLevel +COMN_GetName +COMN_GetNameFromBeast +COMN_GetNextParentBeastComnOp +COMN_GetNextParentVolumeComnOp +COMN_GetNextVolume +COMN_GetPathNameWorkBuffer +COMN_GetPoolName +COMN_GetPhysicalSizeOfSnap +COMN_GetPurgeableBlksCnt +COMN_GetRegisteredLSSFeatures +COMN_GetStorageInfo +COMN_GetUserID +COMN_GetVersionInformation +COMN_GetVolumeName +COMN_GetZidFromMangledName +COMN_GetFileNameFromZid2; +COMN_IncludeType +COMN_InitDataStreamInfo +COMN_InitEncryptedVolume +COMN_InitRootVariableData +COMN_GenerateUniqueName +COMN_InsertAndMangleName +COMN_IsDenyReaderWriterNotMe +COMN_IsDerivedFrom +COMN_IsIDDerivedFrom +COMN_ListOpenFilesOnVolume +COMN_LockByteRange +COMN_LockByteRangeSet +COMN_LockVolumeActive +COMN_LockVolumeDeactive +COMN_Lookup +COMN_LookupByZid +COMN_LookupByZidInBeastHashAndToss +COMN_LookupByZidInBeastHash +COMN_BeastTossOldNotInUseBeasts +COMN_LPNameToUnicode +COMN_MakeShortMacFileName +COMN_MakeVolumeFreeSpace +COMN_MapNDSGUIDToID +COMN_MapNDSGUIDToIDWithNameMsg +COMN_MapNDSIDToGUID +COMN_ModifyInfo +COMN_NameSpaceIDLookup +COMN_NameToUnicode +COMN_Open +COMN_OverrideType +COMN_PackedSizeRootVariableData +COMN_PackRootVariableData +COMN_PoolActiveLock +COMN_PoolActiveUnlock +COMN_PoolEvent +COMN_PoolIDLookup +COMN_PoolNameLookup +COMN_RegisterBeastClassList +COMN_RegisterForVolumeEvents +COMN_RegisterLSSFeatures +COMN_RegisterRootVariableDataType +COMN_ReleaseInternal +COMN_ReleaseChunks +COMN_ReleasePathNameWorkBufferInternal +COMN_RemoveIDsFromAllVolumes +COMN_Rename +COMN_ResetNameMsgToSearchPattern +COMN_Resource +COMN_SendNSSEvent +COMN_SetBeastInfoXML +COMN_SetDataSize +COMN_SetLSSOpsForBeastClass +COMN_SetupContextHandle +COMN_ServerIDGet +COMN_SetupDSIAndLogin +COMN_StartUXactionSupportOnVolume +COMN_FVPW +COMN_SVPW +COMN_SVKY +COMN_SwitchToDirectFileMode +COMN_UnicodeToLPName +COMN_UnicodeToName +COMN_UnlatchAndReleaseInternal +COMN_UnlockByteRange +COMN_UnlockByteRangeSet +COMN_UnlockVolumeActive +COMN_UnlockVolumeDeactive +COMN_UnpackRootVariableData +COMN_UnregisterBeastClass +COMN_UnRegisterForVolumeEvents +COMN_UnregisterLSSFeatures +COMN_UnRegisterRootVariableDataType +COMN_ValidateNameSpace +COMN_VolumeAlert +COMN_VolumeAttributesChanged +COMN_VolumeCommonOpsViaVirtualFile +COMN_VolumeEvent +COMN_VolumeIDLookup +COMN_VolumeMaintenance +COMN_VolumeNameLookup +COMN_WildClose +COMN_WildFindOpenContainerWithZID +COMN_WildOpen +COMN_WildRead +COMN_WildRewind +COMN_WildSetupReread +COMN_Write +CSA_Stats +DIRQ_AdjustUsedDirSpace +DIRQ_ChangeVolumeDirectoryQuotasByName +DIRQ_CheckDirQuotas +DIRQ_ComputeUsedAmount +DIRQ_DisableDirectoryQuotas +DIRQ_GetADirectoryQuota +DIRQ_GetDirectoryQuotas +DIRQ_RemoveDirectoryQuota +DIRQ_SetDirectoryQuota +DIRQ_ChangeDirQuotaAttribute +displayFileCounts +EA_Open +EFL_ControlReadFunc +EFL_ControlWriteFunc +EFL_GetNameFromZid +FH_AddRights +FH_AreRightsCompatible +FH_DeleteRights +FH_SetOpenFileGrantedRights +fixCompFlags +FSHooksCall +FSHooksList +hackKey +LB_PoolNameAcceptable +LB_VolumeFindMMVolume +LB_VolumeNameAcceptable +LegacyEventReport +LOCK_IsExclusiveByteRange +LOCK_IsSharedByteRange +LSSOpsIDMap +MaxRegisteredNameSpaceID +MGMT_BuildResultElement +MGMT_CopyToWorkingBuffer +MGMT_FindFirstElement +MGMT_MakeCommandVirtualFile +MGMT_MakeCommandVirtualFileWithHelp +MGMT_MakeFunctionVirtualFile +MGMT_MakeFunctionVirtualFileWithHelp +MGMTS_MakeCommandVirtualFile +MGMTS_MakeCommandVirtualFileWithHelp +MGMTS_MakeFunctionVirtualFile +MGMTS_MakeFunctionVirtualFileWithHelp +MGMT_readOverride +MGMT_ReturnError +MGMT_ReturnResultNSS +MGMT_ReturnResultNSSWithSetter +MNSS_BuildResult2 +MNSS_ConvertBitsToTags +MNSS_ConvertNameSpaceTagsToValue +MNSS_ConvertNameTypeTagsToValue +MNSS_ConvertTagsToBits +MNSS_FillInAnID +MNSS_FillUTCTime +MNSS_FindUserIDByDN +MNSS_GetGUIDFromName +MNSS_GetNDSNameFromGUID +MNSS_GetTagContents +MNSS_ReturnResult2 +NameTypeNameSpaces +NAME_doAddName +NAME_GetFirstNameFromBeast +NAME_InvalidateCacheEntriesForDirectory +NAME_RemoveNameFromCache +NAMED_BeastCleanupNames +NSSDummy_DSIAlert +NSSDummy_DSIEndWait +NSSDummy_DSIInformation +NSSDummy_DSIStartWait +NSSDummy_EndObjectUpgradeDisplay +NSSDummy_InstallAlloc +NSSDummy_InstallCheckForAbort +NSSDummy_InstallFree +NSSDummy_InstallResolveDSConflicts +NSSDummy_InstallReturnFileServerName +NSSDummy_InstallTrace +NSSDummy_ObjectUpgradeStatus +NSSDummy_StartObjectUpgradeDisplay +NSSLOG_EventLogWithPool +NSSLOG_EventLogWithPoolAndGenMsg +NSSLOG_EventLogWithVolume +NSSLOG_EventLogWithVolumeAndGenMsg +NSSMasterPoolList +NSSMasterVolumeList +OID_InitObjectInfo +OID_InvalidateObjectIDCache +OID_SaveObjectID +OS_setParmRead +OS_setParmCommand +pool_blockSize +POOL_BstNew +POOL_Rename +pool_salFreeableSize +pool_salHighWaterMark +pool_salLowWaterMark +pool_salMaxKeepSeconds +pool_salMinKeepSeconds +pool_salNonFreeableSize +pool_info +pool_volumes +resolveXaction +SBS_enumerateMFL +SBS_markFileModified +SBS_markFileUnmodified +SBS_volumeMFLControlReadFunc +SBS_volumeMFLControlWriteFunc +TestScanComponents +UXactionActivateThread +UXactionSystemInited +UXAS_StoreIDInGUID +UXASindex +VAUTH_MayIDoThis +VIRT_AddAttribute +VIRT_AddResultCDataElement +VIRT_AddResultData +VIRT_AddResultElement +VIRT_AddResultTag +VIRT_AddResultTagForAttribute +VIRT_AddUnicode +VFS_AddUnicode +VIRT_CheckResultSize +VIRT_FinishVirtualFile +VIRT_InitVirtualFile +VIRT_MakeDataTypeDataStream +VIRT_MakeReadWriteFuncDataStream +VIRT_MakeResultsImportant +VIRT_MakeResultsNormal +VIRT_Read +VIRT_ResetResult +VFS_ssprintf +VIRT_ssprintf +VIRT_test +VIRT_testCommand +VIRT_testCookieRead +VIRT_testRead +VIRT_testWrite +volume_dirInfo +volume_getInfo +volume_getExtendedInfo +volume_trusteeInfo +volume_userInfo +VOL_Activate +VOL_AdjustUsedUserSpace +VOL_BrowseUsersInVolume +VOL_BstNew +VOL_BstNew2 +VOL_ChangeUserSpaceAttribute +VOL_ChangeVolumeSalvageByName +VOL_CheckUserSpace +VOL_Deactivate +VOL_DisableUserSpaceRestrictions +VOL_DisableVolume +VOL_FlushVolume +VOL_GetUserSpaceInfo +VOL_InitUserSpaceRestrictionData +VOL_insertEFLEntry +VOL_Rename +VOL_SendDeactivateEventToSAgents +VOL_SetUserSpaceRestriction +VP_ClearChecking +VP_ClearRepairing +VP_MarkAsChecking +VP_MarkAsRepairing +WriteXactionMarker +ZASindex +ZAS_AddACLEntry +ZAS_FixVisibility +ZAS_InvalidateEACLCacheEntries +ZAS_InvalidateEntireEACLCache +ZAS_RemoveACLEntry +zPoolVerify +zUpdateVolumeObjectInNDS +OpLockInst +OpLockVerbose +OPLOCK_AllocExclusive +OPLOCK_AllocShared +OPLOCK_Break +OPLOCK_BreakExclusive +OPLOCK_BreakFailed +OPLOCK_BreakShared +OPLOCK_Free +OPLOCK_MakeShared +OPLOCK_WaitForBreak +NW_ClientFileCachingEnabledFlag +NW_Level2OpLocksEnabledFlag +CRO_ProcessErrorAndRequestRetry +CRO_AccessLeaseSync +CRO_AccessLeaseToss +CRO_AccessLeaseValidate +xAdjustQuotaFileLen diff --git a/include/nwnss/include/nssErrorTable.h b/include/nwnss/include/nssErrorTable.h index 47ed77f..055eba2 100644 --- a/include/nwnss/include/nssErrorTable.h +++ b/include/nwnss/include/nssErrorTable.h @@ -73,3 +73,4 @@ extern ErrorTable_s MM_ErrorTable[]; #endif /* #ifndef _NSSERRORTABLE_H_ */ + diff --git a/include/nwnss/include/nssLOADER.imp b/include/nwnss/include/nssLOADER.imp new file mode 100644 index 0000000..a5997d0 --- /dev/null +++ b/include/nwnss/include/nssLOADER.imp @@ -0,0 +1,445 @@ +AVFileMgmtDir +AVFileMgmtDirLen +AVFileOSMgmtDir +AVFileOSMgmtDirLen +AdminVolAsciiName +AdminVolNameLen +AdminVolUnicodeName +BEASTHASH_InvalidateDOSTimesPtr +CACHE_Shutdown +CACHE_SparseBuffer +CACHE_Startup +COMN_RegisterLibraryOwner +COMN_RegisterLibraryResourceTags +COMN_Resource +COMN_UnregisterLibraryOwner +CONTROL_Shutdown +CONTROL_Startup +CONTROL_get +CONTROL_getNoAllocNoWait +Cache +Config +crc +CurrentTimer +DBG_DumpSpinLock +DBG_fatal +DBG_RestoreSpinLock +DBG_SaveSpinLock +DDCAuthenticateConnectionPtr +DDCCheckConsoleOperatorPtr +DDCConnectToReferralPtr +DDCContextEntryIDPtr +DDCCreateContextPtr +DDCCreateEntryPtr +DDCDuplicateContextPtr +DDCFreeContextPtr +DDCGenerateKeyPairPtr +DDCGetEffectivePrivilegesPtr +DDCGetEntryInfoPtr +DDCGetServerNamePtr +DDCListToBufferPtr +DDCLogoutPtr +DDCModifyEntryPtr +DDCModifyRDNPtr +DDCNameToIDPtr +DDCPingPtr +DDCReadToBufferPtr +DDCReadToCBPtr +DDCRemoveAttributePtr +DDCRemoveEntryPtr +DDCResolveNamePtr +DDCSetContextBaseDNPtr +DDCSetContextEntryIDPtr +DDCSetContextFlagsPtr +DDSGetLocalAgentInfoPtr +DDSGetLocalEntryNamePtr +DDCLoginPtr +DDSLoginAsServerPtr +DOSDateTime2Str +DOS2utcTime +DSTStartInfo +DSTStopInfo +DisplayVersionInformation +eventHistogram +formatNumber +formatTime +FsmInst +FsmReadyQ +GetErrorFromNumber +GetInstLen +hashLowerString +hashLowerUnicode +hashString +hashUnicode +IgnoreTimeZone +Inst +InterruptMailbox +LBL_cntSignal +LBL_cntWait +LBL_fsmCntWait +LBL_fsmSwait +LBL_fsmXwait +LBL_sSignal +LBL_sWait +LBL_xBarrier +LBL_xSignal +LBL_xWait +LB_ByteToUnicode +LB_DisplayCmdlineHelp +LB_GetNssUnicodeVersion +LB_GUIDFromUTF8 +LB_GUIDGenerate +LB_GUIDTimeToShortVolumeName +LB_GUIDToString +LB_GUIDToVolumeName +LB_GUIDValidate +LB_ImportNDSPublics +LB_ImportOptionalUnixlibStuff +LB_InitializeSystemImports +LB_LenByteToUnicode +LB_LenMacByteToUnicode +LB_MacByteToUnicode +LB_ParseCmdline +LB_RegisterUnicodeConverter +LB_UTF8ToUniChar +LB_UTF8LenToUniChar +LB_UnRegisterUnicodeConverter +LB_UnicodeShutdown +LB_UnicodeStartup +LB_UnicodeToByte +LB_UnicodeToMacByte +LB_UnicodeToUntermByte +LB_UnicodeToUntermMacByte +LB_UnimportOptionalUnixlibStuff +LB_UninitializeSystemImports +LB_VolumeNameToAutoRenameName +LB_VolumeNameToPoolName +LB_VolumeNameToSnapshotName +LB_VolumeNameValid +LB_VolumeRenameOK +LB__wioCreateWFile +LB_aprintf +LB_bind +LB_componentUnicpy +LB_componentUnilen +LB_continueFlush +LB_defaultFlush +LB_defaultFlushWait +LB_defaultSignal +LB_delay +LB_errPrintf +LB_exitMyselfAndReturn +LB_free +LB_freeAsyncio +LB_freeAsyncioRA +LB_freeForNCPReply +LB_freePage +LB_getAsyncio +LB_getAsyncioNoWait +LB_getAsyncioNoWaitRA +LB_getchar +LB_GetDSGUID +LB_GetMacCodePageName +LB_gets +LB_lazyFlush +LB_malloc +LB_mallocForNCPReply +LB_mallocPage +LB_mallocPageWithFlags +LB_mallocWithFlags +LB_ParseDSObjectName +LB_printf +LB_realloc +LB_snprintf +LB_sprintf +LB_unicat +LB_unichr +LB_unicmp +LB_unicpy +LB_uniicmp +LB_uniicmpMac +LB_unilen +LB_unilwr +LB_unimcpy +LB_unincat +LB_unincmp +LB_unincpy +LB_uninicmp +LB_unitolower +LB_unitoupper +LB_unirchr +LB_uniupr +LB_vsnprintf +LB_vsprintf +LB_wAPrintf +LB_wClose +LB_wGetPos +LB_wGetc +LB_wPause +LB_wPrintf +LB_wPromptForYesOrNo +LB_wSetPos +LB_zalloc +LB_zallocPage +LB_zrealloc +Latch_All +Latch_Free +Latch_Holder +Latch_Waiter +LocalUtc2UTCTime +lowerStringCRC +MSG_BreakDoor +MSG_BreakSetOfDoors +MSG_Call +MSG_Send +MSG_SendKey +MSG_ChangeOwner +MSG_CreateDoor +MSG_CreateObject +MSG_DestroyKey +MSG_DestroySetOfKeys +MSG_KillManager +MSG_LookupShortKey +MSG_NextDoor +MSG_RegisterType +MSG_ReleaseObject +MSG_SetStatus +MSG_UnregisterType +msgFreeDoor +MallocTraceEnable +Manager +ManagerType +MSTime2utcTime +MyCacheID +NDSDeleteEventFunc +NDSEventHandlerHandle +NDSRenameEventFunc +NSSDoubleByteToUnicodeTable +NSSMPK_InitNsslock +NSSMPK_LockNss +NSSMPK_LockNssNoInterrupts +NSSMPK_UnlockNss +NSSMPK_spinlock +NSSSingleByteToUnicodeTable +NSSUniToLower +NSSUniToUpper +NSSUnicodeFF +NSSUnicodeIsDoubleByteAsciiBitMap +NSSUnicodeIsDoubleByteMacAsciiBitMap +NSSUnicodeMappableToAsciiBitMap +NSSUnicodeMappableToMacAsciiBitMap +NSSUnicodeToByteTable +NSS_LoadNLMs +NSS_RegisterExternalNLM +NSS_ResetTimeCaches +NSS_SetIgnoreTimeZone +NSS_StoreCallers +NSS_UnRegisterExternalNLM +NSS_UnloadNLMs +NSS_doMenuLoad +NW_DebuggerActive +NW_ErrCase +NW_LocaleTable +NW_MLIDMaximumPacketSize +NW_MaximumNumberOfServerProcesses +NW_MinimumNumberOfServerProcesses +NW_NCPFuncBoundaryError +NW_NCPLengthError +NW_NCPSubFuncLengthError +NW_NestedInterruptCount +NW_NumberOfVolumes +NW_OSHandle +NW_PBInternalDelaySendPacketWithSignatures +NW_PBInternalSendPacketWithSignatures +NW_SkipReceiveBufferReturn +NW_SwitchVector +NW_WriteActiveList +NW_WriteBranchTableEntry +NW_WriteControlAvailList +NW_connectionTable +NW_numberOfConnectionSlots +NdsPublicsLoaded +NullMethod +PendingWork +PersistAdminVolUnicodeName +QueuedThreads +QueuedThreadsHigh +RNLM_readFunction +ReserveResource +ResetTimeCache +Sec20002utcTime +stringCRC +Ticks +TimeToYield +UNIXLIB_MapDOSToNFSforNewNSSFilePtr +UNIXLIB_isLoaded +UNIXLIB_isUnloading +UNIXLIB_useCount +updateCRC +updateCRCFromString +updateCRCFromLowerString +updateCRCFromLowerStringWithLen +updateCRCFromLowerUnicode +updateCRCFromUnicode +UTC2Sec2000Time +UTC2dosTime +UTC2LocalUtcTime +UTC2msTime +UTCTime2Str +UTCTime2UniversalStr +WORK_Queue +WORK_Schedule +WORK_Schedule_HIGH +WORK_WaitForPending +WorkControl +WorkHighWaitingCount +WorkInst +WorkWaitingCount +ZOS_IsNLMLoaded +asyncCacheAllocBuffer +asyncCacheAllocBufferForUserData +cacheAllocBuffer +cacheAllocBufferForUserData +cacheBalance +cacheFind +cacheFlushMyCache +cacheFlushMyCacheBufs +cacheLookup +cacheMarkDirty +cacheMoveMyCacheBufList +cachePrepareToFlush +cacheRelease +cacheReleaseToss +cacheSignalRelease +cacheSignalReleaseToss +cacheToss +cacheTossAll +cacheTossIfThere +cacheTruncateMyCache +cacheFlushAndTossMyCacheUserData +cacheUnpin +cacheUnpinned +changeCacheBuffers +checkMyCache +checkOrSetDSTConversionResults +clearBits +configStartup +ESMSize +ESMCache_Get +ESMCache_Put +ESMCache_Invalidate +fastReadCache +fillInWork +findBits +findDoor +findId +findSmallestId +freeIds +fsmKick +getDSTChangeRules +harvestInst +hashApply +hashDelete +hashDestroy +hashFind +hashGrow +hashInit +hashInsert +hashShrink +hashStats +initAgent +initIds +initMyCache +isCached +kSleep +kStartThreadWithModuleHandlePtr +kWakeUp +mailInterrupt +mbInit +mbSetHigh +microSecondsDiffToStr +newBitMap +NSSLOG_EventLog +NSSLOG_printf +objCacheAlloc +objCacheCreate +objCacheDestroy +objCacheFree +prHistogram +registerHistogram +resetInst +roust +secondsDiffToStr +setBits +setCyclic +setOneShot +snoozeSec +UniversalStr2utcTime +xAvailableCacheBuffers +xOldestCacheBuffer +xRequestContiguousPages +xRequestPage +XML_UTF8ToGUID +XML_UTF8ToQUAD +XML_UTF8ToSQUAD +XML_UTF8ToUlong +XML_SingleNameToUnicodeName +XML_GetTagElementAtCurrentLevel +XML_Display +zADMINVOL_GUID +zANYONE_USERID +zINVALID_GUID +zMSG_Call +zSECURE_CONNECTION_USERID +zSUPERVISOR_USERID +zTREENAME_ID +zZERO_GUID +SDM_Structure +DBG_CV_Register +DBG_CV_Unregister +DBG_UTCTime2Str +DFI_Close +DFI_Display +DFI_DisplayStructure +DFI_Display_Header_ARRAY +DFI_Display_Header_Structure +DFI_Display_Tail_ARRAY +DFI_Display_Tail_Structure +DFI_Open +DFI_NotUsed_s +DFI_File_s +DFI_Buffer_s +DFI_DQhead_t +DFI_Latch_s +DFI_zWorkProc_s +DFI_OneShot_s +DFI_Volume_s +DFI_Pool_s +DFI_FsmLite_s +SNP_snprintf +ZSD_Display_Type_BYTE +ZSD_Display_Type_LONG +ZSD_Display_Type_SLONG +ZSD_Display_Type_QUAD +ZSD_Display_Type_QUAD_ARRAY +ZSD_Display_Type_SWORD +ZSD_Display_Type_Time_t +ZSD_Display_Type_Time_t_ARRAY +ZSD_Display_Type_WORD +ZSD_Display_Type_Zid_t +MSG_RegisterXIPC +MSG_UnregisterXIPC +SWBD_DemandKey +SWBD_KillClient +SWBD_SupplyAll +SWBD_SupplyKey +SWBD_SupplyLocal +SWBD_SupplyRemote +SWBD_NewClient +SWBD_DumpSwitchboard +allocMsgBuf +freeMsgBuf +LB_SetErrno +DoorType +makeAESP +utf_tolower diff --git a/include/nwnss/include/nssMAL.imp b/include/nwnss/include/nssMAL.imp new file mode 100644 index 0000000..bfd4776 --- /dev/null +++ b/include/nwnss/include/nssMAL.imp @@ -0,0 +1,10 @@ +zMALAccess +zMALFillIOMsg +zMALFinishIOMsg +zMALAllocReqMsg +zMALAllocReqMsgFsm +zMALFreeReqMsg +zMALSendReqMsg +zMALMegToUnits +zMALUnitsToMeg +MMReserveObject diff --git a/include/nwnss/include/nssMANAGE.imp b/include/nwnss/include/nssMANAGE.imp new file mode 100644 index 0000000..5ba091b --- /dev/null +++ b/include/nwnss/include/nssMANAGE.imp @@ -0,0 +1,11 @@ +MANAGE_nssCommand +MANAGE_ndsCommand +MANAGE_fileCommand +MANAGE_ReadDataStream +MANAGE_WriteDataStream +MNSS_GetTagContents +MNDS_ResolveName +getManageVCUAbort +getManageVCUAnswer +setManageVCUCopyStatus +setManageVCUProcessMsg \ No newline at end of file diff --git a/include/nwnss/include/nssRegistration.h b/include/nwnss/include/nssRegistration.h new file mode 100644 index 0000000..bcc2c96 --- /dev/null +++ b/include/nwnss/include/nssRegistration.h @@ -0,0 +1,159 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996-1998 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) Initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: srvijayaragavan $ + | $Date: 2008-05-16 15:50:16 +0530 (Fri, 16 May 2008) $ + | + | $RCSfile$ + | $Revision: 2345 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Definition all of the NLM Registration APIs for NSS + | + | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + | + | This header file should ONLY be used for NSS internal development. + | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). + | Any other use may cause conflicts which NSS will NOT fix. + +-------------------------------------------------------------------------*/ +#ifndef _NSSREGISTRATION_H_ +#define _NSSREGISTRATION_H_ + +#ifndef _OMNI_H_ +# include +#endif + +#ifndef _DISPLAYVERSION_H_ +# include +#endif + +#ifndef _ZPARAMS_H_ +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Pre-define struct(s) so Linux compiler doesn't complain */ +struct PCLSwitchDef_s; + +#define NSS_SNAPDATE 0x20080911 +/*------------------------------------------------------------------------- + * Current API definition number plus current DEBUG state + *-------------------------------------------------------------------------*/ +#define NSSAPI_VERSION 56 /* Brenda changed it from 53 to 54 - + * 21September2004 */ + /* Vandana changed it from 54 to 55 - + * March 7th 2005, because I added a + * pointer to inode in RootBeast_s */ + /* Craig changed it to 56 on 8/30/05 */ + +#if NSS_DEBUG IS_ENABLED +# define NSS_DEBUG_STATE TRUE +#else +# define NSS_DEBUG_STATE FALSE +#endif + +#if MPK_REAL IS_ENABLED +# define NSS_MP_FLAG TRUE +#else +# define NSS_MP_FLAG FALSE +#endif + +/*------------------------------------------------------------------------- + * Definition of external Callbacks + *-------------------------------------------------------------------------*/ +typedef struct NSSRegistrationCallBacks_s +{ + /* This is called by NSS when the NLM should initialize itself. */ + STATUS (*startup)(void); /* this must be defined */ + /* This is called when the SERVER is being downed (not NSS being unloaded)*/ + void (*downServer)(void); /* this may be NULL */ +} NSSRegistrationCallBacks_s; + +/*------------------------------------------------------------------------- + * This is called when an EXTERNAL NLM loads and wishes to register with + * NSS. It should make this call as part of the generic startup routine. + * The EXTERNAL NLM should do no other NSS initialization until NSS + * calls its STARTUP routine. + *-------------------------------------------------------------------------*/ +extern STATUS NSS_RegisterExternalNLM( + char *moduleName, /* case insensitive */ + void *moduleHandle, + char **messageTable, /* language enabled message table */ + NINT moduleType, + NINT registrationFlags, + VersionInformation_s *versionInfo, + NINT APIVersion, + NINT snapDate, /* Date the NLMs are snapshotted for Cadence build */ + NINT debugEnabled, + NINT mpEnabled, + struct PCLSwitchDef_s *commandLineSwitches, + NSSRegistrationCallBacks_s *callBacks); + +/* Types of NLMs that can register */ +#define NSSMODULETYPE_INVALID 0 +#define NSSMODULETYPE_COMMON 1 +#define NSSMODULETYPE_LSS 2 +#define NSSMODULETYPE_SEMANTIC_AGENT 3 +#define NSSMODULETYPE_NAMESPACE 4 +#define NSSMODULETYPE_PROVIDER 5 +#define NSSMODULETYPE_MENU 6 +#define NSSMODULETYPE_DFS 7 + +/* options for loading the NLM */ +#define NSSREGFLAG_REQUIRED 0x00000001 /* if this NLM doesn't init + * NSS should unload */ +#define NSSREGFLAG_OPTIONAL 0x00000000 /* is this NLM doesn't init + * continue processing other + * NLMS */ + + +/*------------------------------------------------------------------------- + * This is called to inform NSS that an EXTERNAL NLM is unloading. This + * must be the last thing called before the NLM unloaded. It is assumed + * that all other NSS cleanup has already been performed by the given + * NLM. + *-------------------------------------------------------------------------*/ +extern STATUS NSS_UnRegisterExternalNLM(char *moduleName); + +extern STATUS NSS_LoadNLMs(char *nlmname, char *newcmds); +extern STATUS NSS_UnloadNLMs(char *nlmname); + +void NSS_doMenuLoad(LONG startmenu, char *cmdline); + +STATUS RNLM_readFunction( + NINT parmLen, + utf8_t *parm, + VirtInfo_s *virtInfo); + +#ifdef __cplusplus +} +#endif + +#endif /* _NSSREGISTRATION_H_ */ diff --git a/include/nwnss/include/nssZLSS.imp b/include/nwnss/include/nssZLSS.imp new file mode 100644 index 0000000..b10643f --- /dev/null +++ b/include/nwnss/include/nssZLSS.imp @@ -0,0 +1,12 @@ +GetZedStuff +ZLOG_RecoveryInfoGet +ZLSS_PhysicalIOXML +ZLSS_PhysicalIOXMLGlobal +ZLSS_VCF_InternalCmd +ZLSS_ZLogReadMetadataXML +ZLSS_ZLogReadMetadata +COMPFIX_VerifyAndLoadLVSystemBeasts +COMPFIX_verify_FlushVolVolumeBuffers +COMPFIX_UnloadlvSystemBeasts +RAVGSInitItems +ZLSS_MSAPItemsXML diff --git a/include/nwnss/include/nsskr.h b/include/nwnss/include/nsskr.h new file mode 100644 index 0000000..8c229a4 --- /dev/null +++ b/include/nwnss/include/nsskr.h @@ -0,0 +1,711 @@ +/**************************************************************************** + | + | (C) Copyright 2004 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: ajack $ + | $Date: 2006-12-14 21:29:37 +0530 (Thu, 14 Dec 2006) $ + | + | $RCSfile$ + | $Revision: 1770 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library Routine + | Make kernel functions available in user space on Linux + | + | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + | + | This header file should ONLY be used for NSS internal development. + | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). + | Any other use may cause conflicts which NSS will NOT fix. + +-------------------------------------------------------------------------*/ +#ifndef _KERNELREQ_H_ +#define _KERNELREQ_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ZOMNI_H_ +#include +#endif + +#ifndef _ZPARAMS_H_ +#include +#endif + +#ifndef DCONST_H +#include +#endif + +#ifndef _MANAGE_VOLUME_H_ +#include +#endif + +//#ifndef _COMNBEASTS_H_ +//#include +//#endif + +#ifndef _EVS_H_ +#include +#endif + +#ifdef __linux__ +#define POOL_MAXNAME 64 /* Need to include mal.h */ +#define MAX_AUTH_MODEL_NAME_SIZE 32 /* Need to include comnAuthorize.h */ +#endif + +/* These definitions are used to make kernel-space NSS calls available to + * the manage code which runs in user space. + * Requests are made by opening the _admin volume and issuing an ioctl call. + * + * All requests from NSSULIB use the same request value in the ioctl call. + * The specific request is contained in the header of the request message. + */ + +/* Signature value */ +/* This is used to give some confidence that the request is actually for the */ +/* correct service, and also includes an (8-bit) API version in case things */ +/* change in the future... */ +#define NSSKR_VERSION 0x01 +#define NSSKR_SIGNATURE (('N' << 24) | ('S' << 16) | ('S' << 8) | NSSKR_VERSION) + +/* The ioctl request value */ +#define NSSKR_REQUEST 0x8008 /* FixFixFix: Use a properly assigned value */ + +/* Opcode definitions */ +enum nsskr +{ + NSSKR_NOP, /* No op */ + NSSKR_BrowseBeastsInVolume, /* COMN_browseBeastsInVolume */ + + NSSKR_ClusterSoftwareIsCheckingPoolStateChanges, + /* COMN_ClusterSoftwareIsCheckingPoolStateChanges */ + NSSKR_FindAuthModelByName, /* COMN_FindAuthModelByName */ + NSSKR_GetRegisteredLSSFeatures, /* COMN_GetRegisteredLSSFeatures */ + NSSKR_GUIDGenerate, /* LB_GUIDGenerate */ + NSSKR_VolumeNameAcceptable, /* LB_VolumeNameAcceptable */ + NSSKR_VolumeNameValid, /* LB_VolumeNameValid */ + NSSKR_PoolNameAcceptable, /* LB_PoolNameAcceptable */ + NSSKR_Reserved, /* no longer used */ + + NSSKR_GetAuthModelID, /* GetAuthModelID */ + NSSKR_GetBeastInfo, /* GetBeastInfo */ + NSSKR_SetBeastInfo, /* SetBeastInfo */ + NSSKR_DeleteBeast, /* DeleteBeast */ + NSSKR_GetBeastFullName, /* GetBeastFullName */ + NSSKR_FixVolumeCompStats, /* FixVolumeCompStats */ + NSSKR_CreateVolumeInPool, /* CreateVolumeInPool */ + NSSKR_SetNDSInfoOnVolume, /* SetNDSInfoOnVolume */ + NSSKR_SetNDSInfoOnPool, /* SetNDSInfoOnPool */ + NSSKR_ModifyVolumeAttributes, /* ModifyVolumeAttributes */ + NSSKR_GetNSSVolumeHostPool, /* GetNSSVolumeHostPool */ + NSSKR_GetDeletedVolumeLSSInfo, /* GetDeleteVolumeLSSInfo */ + NSSKR_NSSVolumeFound, /* NSSVolumeFound */ + NSSKR_GetZInfo, /* GetZInfo */ + NSSKR_RemoveNSSVolume, /* RemoveNSSVolume */ + NSSKR_RenameNSSVolume, /* RenameNSSVolume */ + NSSKR_ChangeVolumeState, /* ChangeVolumeState */ + NSSKR_PerformDeletedVolAction, /* PerformDeletedVolumeAction */ + NSSKR_RenameSalvagedVolume, /* RenameSalvagedVolume */ + NSSKR_RemoveUserFromIDStore, /* RemoveUserFromIDStore */ + NSSKR_GetNextVolumeName, /* GetNextVolumeName */ + NSSKR_UTCTime2Str, /* UTCTime2Str */ + NSSKR_CheckVolumesPool, /* MNDS_CheckVolumesPool */ + NSSKR_DoesPoolExist, /* DoesPoolExist */ + NSSKR_DoesVolumeExist, /* DoesVolumeExist */ + NSSKR_GetPoolLSSType, /* GetPoolLSSType */ + NSSKR_ChangePoolState, /* ChangePoolState */ + NSSKR_GetPoolState, /* GetPoolState */ + NSSKR_GetNextPoolName, /* GetNextPoolName */ + NSSKR_GetNextVolumeInfo, /* GetNextVolumeInfo */ + NSSKR_GetLSSFeatures, /* GetLSSFeatures */ + NSSKR_GetPoolID, /* GetPoolID */ + NSSKR_GetNextUserInVolume, /* GetNextUserInVolume */ + NSSKR_SetUserSpaceRestriction, /* SetUserSpaceRestriction */ + NSSKR_GetUserSpaceRestriction, /* GetUserSpaceRestriction */ + NSSKR_ZPoolVerify /* zPoolVerify */ +}; + +/* Generic form of request/response buffer. */ +/* All buffers have common header */ +typedef struct _nsskr_generic_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ +} nsskr_generic_t; + +typedef struct _nsskr_ClusterSoftwareIsChecking_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + BOOL result; /* Result value (output) */ +} nsskr_ClusterSoftwareIsChecking_t; + +typedef struct _nsskr_FindAuthModelByName_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + utf8_t name[MAX_AUTH_MODEL_NAME_SIZE]; + /* Authorization model name (input) */ + SNINT result; /* Array index (output) */ +} nsskr_FindAuthModelByName_t; + +typedef struct _nsskr_GetRegisteredLSSFeatures_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + NINT bufSize; /* Buffer size in bytes (input) */ + STATUS rc; /* Function return code (output) */ + LONG error_num; /* errno if zFAILURE (output) */ + NINT numberOfLSSs; /* Number of returned LSSs (output) */ + BYTE buffer[1]; /* LSSInfo buffer (output) */ + /* actual buffer size given by .bufSize */ +} nsskr_GetRegisteredLSSFeatures_t; + +typedef struct _nsskr_GUIDGenerate_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + GUID_t guid; /* New GUID value (output) */ +} nsskr_GUIDGenerate_t; + +typedef struct _nsskr_VolumeNameAcceptable_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Volume name (input) */ + STATUS status; /* Result (output) */ +} nsskr_VolumeNameAcceptable_t; + +typedef struct _nsskr_VolumeNameValid_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Volume name (input) */ + STATUS status; /* Result (output) */ +} nsskr_VolumeNameValid_t; + +typedef struct _nsskr_PoolNameAcceptable_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + /* Pool name (input) */ + STATUS status; /* Result (output) */ +} nsskr_PoolNameAcceptable_t; + +typedef struct _nsskr_GetAuthModelID_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + utf8_t name[MAX_AUTH_MODEL_NAME_SIZE]; + /* Authorization model name (input) */ + NINT id; /* The ID (output) */ +} nsskr_GetAuthModelID_t; + +typedef struct _nsskr_CreateVolumeInPool_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + /* Pool name (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Volume name (input) */ + NINT authModelID; /* Authorization model (input) */ + GUID_t volumeGUID; /* Volume's GUID (input) */ + STATUS status; /* Return code (output) */ + BOOL isClustered; /* Clustered pool or not (output) */ + NINT errIndex; /* Error index (output) */ + unicode_t uniPassword[ENCRYPTED_VOLUME_PASSWORD_LENGTH+1]; /* Optional password */ +} nsskr_CreateVolumeInPool_t; + +typedef struct _nsskr_SetNDSInfoOnVolume_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Volume name (input) */ + zVolumeInfo_s info; /* Volume Info (input) */ + BOOL lock; /* Lock flag (input) */ + BOOL onlineOnly; /* Online only (input) */ + STATUS status; /* Result (output) */ +} nsskr_SetNDSInfoOnVolume_t; + +typedef struct _nsskr_SetNDSInfoOnPool_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + /* Pool name (input) */ + zInfo_s info; /* Pool info (input) */ + STATUS status; /* Result (output) */ +} nsskr_SetNDSInfoOnPool_t; + +typedef struct _nsskr_ModifyVolumeAttributes_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Volume name (input) */ + NINT modifyInfoMask; /* Modify info mask (input) */ + zVolumeInfo_s info; /* Volume Info (input) */ + NINT readAhead; /* Read ahead value (input) */ + STATUS status; /* Result (output) */ + NINT errIndex; /* Error index (output) */ +} nsskr_ModifyVolumeAttributes_t; + +typedef struct _nsskr_GetNSSVolumeHostPool_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + utf8_t volumeName[zMAX_COMPONENT_NAME]; + /* Volume name (input) */ + STATUS status; /* Result (output) */ + utf8_t poolName[zMAX_COMPONENT_NAME]; + /* Pool name (output) */ +} nsskr_GetNSSVolumeHostPool_t; + +typedef struct _nsskr_GetDeletedVolumeLSSInfo_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + utf8_t volumeName[zMAX_COMPONENT_NAME]; + /* Deleted volume name (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Unicode volume name (input) */ + NINT bufLen; /* Buffer size (input) */ + STATUS status; /* Result (output) */ + NINT retLen; /* Return length (output) */ + utf8_t buf[1]; /* Buffer (output) */ + /* Actual length specified in bufLen */ +} nsskr_GetDeletedVolumeLSSInfo_t; + +typedef struct _nsskr_ZPoolVerify_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + + STATUS NZPV_Status; /* Status of zPoolVerify operation */ + int NZPV_Action; /* zPoolVerify action */ + unsigned int NZPV_BufferSize; /* Buffer size (input) */ + BYTE NZPV_Buffer[1]; /* Buffer (input/output) */ + /* Actual length specified in NZPV_BufferSize */ + /* NZPV_Buffer must be LAST */ +} nsskr_ZPoolVerify_t; + +typedef struct _nsskr_NSSVolumeFound_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Volume name (input) */ + BOOL include_internal; /* Include internal volumes (input) */ + STATUS status; /* Result (output) */ + BOOL isDeleted; /* Deleted volume (output) */ + NINT readAhead; /* Read ahead (output) */ + NINT volumeState; /* Current volume state (output) */ + utf8_t authModelName[MAX_AUTH_MODEL_NAME_SIZE]; + /* Authorization model (output) */ + UserID_t volNameGUID; /* NDS object GUID (output) */ +} nsskr_NSSVolumeFound_t; + +typedef struct _nsskr_GetZInfo_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + QUAD getInfoMask; /* Info mask (input) */ + utf8_t path[zMAX_FULL_NAME]; + /* Path name (input) */ + STATUS status; /* Result (output) */ + zInfo_s info; /* Volume info (output) */ + NINT errIndex; /* Error index (output) */ +} nsskr_GetZInfo_t; + +typedef struct _nsskr_RemoveNSSVolume_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Volume name (input) */ + STATUS status; /* Result (output) */ +} nsskr_RemoveNSSVolume_t; + +typedef struct _nsskr_RenameNSSVolume_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Old volume name (input) */ + unicode_t uniNewName[zMAX_COMPONENT_NAME]; + /* New volume name (input) */ + STATUS status; /* Result (output) */ +} nsskr_RenameNSSVolume_t; + +typedef struct _nsskr_ChangeVolumeState_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Unicode volume name (input) */ + BOOL activateVolume; /* Whether to activate (input) */ + utf8_t volumePassword[ENCRYPTED_VOLUME_PASSWORD_LENGTH + 2]; + /* Volume password (input) */ + STATUS status; /* Result (output) */ + NINT errIndex; /* Error index (output) */ +} nsskr_ChangeVolumeState_t; + +typedef struct _nsskr_PerformDeletedVolAction_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Volume name (input) */ + deletedVolumeAction_t action; /* Action (input) */ + STATUS status; /* Result (output) */ +} nsskr_PerformDeletedVolAction_t; + +typedef struct _nsskr_RenameSalvagedVolume_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Volume name (input) */ + unicode_t uniNewName[zMAX_COMPONENT_NAME]; + /* New name (input) */ + STATUS status; /* Result (output) */ + NINT state; /* Volume state (output) */ +} nsskr_RenameSalvagedVolume_t; + +typedef struct _nsskr_RemoveUserFromIDStore_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Unicode volume name (input) */ + UserID_t userID; /* User ID (input) */ + STATUS status; /* Result (output) */ + NINT errIndex; /* Error index (output) */ +} nsskr_RemoveUserFromIDStore_t; + +typedef struct _nsskr_GetNextVolumeName_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + BOOL firstTime; /* Get first/Get next (input) */ + NINT uniNameLen; /* Buffer size (input) */ + SQUAD cookie; /* Cookie value (input/output) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* Volume name (output) */ + STATUS status; /* Result (output) */ + BOOL isLogical; /* Logical volume flag (output) */ +} nsskr_GetNextVolumeName_t; + +typedef struct _nsskr_UTCTime2Str_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + Time_t utcTime; /* UTC Time (input) */ + char str[zMAX_COMPONENT_NAME]; /* Time string (output) */ +} nsskr_UTCTime2Str_t; + +typedef struct _nsskr_CheckVolumesPool_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + char volName[zMAX_COMPONENT_NAME]; + /* Volume name (input) */ + utf8_t poolName[zMAX_COMPONENT_NAME]; + /* Pool name (input) */ + STATUS status; /* Result (output) */ + BOOL matchedPool; /* Volume in pool (output) */ +} nsskr_CheckVolumesPool_t; + +typedef struct _nsskr_DoesPoolExist_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + utf8_t poolName[zMAX_COMPONENT_NAME]; + /* Pool name (input) */ + STATUS status; /* Result (output) */ + VolumeID_t poolID; /* Pool ID (output) */ + NDSid_t ndsID; /* NDS object ID (output) */ +} nsskr_DoesPoolExist_t; + +typedef struct _nsskr_DoesVolumeExist_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + utf8_t volName[zMAX_COMPONENT_NAME]; + /* Volume name (input) */ + STATUS status; /* Result (output) */ +} nsskr_DoesVolumeExist_t; + +typedef struct _nsskr_GetPoolLSSType_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + /* Pool name (input) */ + NINT LSStype; /* LSS type (output) */ +} nsskr_GetPoolLSSType_t; + +typedef struct _nsskr_ChangePoolState_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + /* Pool name (input) */ + NINT newPoolState; /* New pool state (input) */ + NINT mode; /* Mode (input) */ + STATUS status; /* Reault (output) */ +} nsskr_ChangePoolState_t; + +typedef struct _nsskr_GetPoolState_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + /* Pool name (input) */ + NINT poolState; /* Pool state (output) */ +} nsskr_GetPoolState_t; + +typedef struct _nsskr_GetNextPoolName_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + BOOL noSnapshot; /* Do not include snapshot pools (input) */ + BOOL firstTime; /* Get first/Get next (input) */ + NINT uniNameLen; /* Buffer size (input) */ + SQUAD cookie; /* Cookie value (input/output) */ + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + /* Volume name (output) */ + STATUS status; /* Result (output) */ + NINT poolState; /* Pool State (output) */ + BOOL isShared; /* Shared for clustering (output) */ + QUAD enabledAttr; /* Enabled pool function bits (output) */ +} nsskr_GetNextPoolName_t; + +typedef struct _nsskr_GetNextVolumeInfo_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; /* pool name (input) */ + BOOL firstTime; /* Get first/Get next (input) */ + BOOL deletedVolume; /* whether to get the deleted volume (input) */ + NINT uniVolNameLen; /* Buffer size (input) */ + GUID_t cookie; /* Cookie value (input/output) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; /* volume name (output) */ + STATUS status; /* Result (output) */ +} nsskr_GetNextVolumeInfo_t; + +typedef struct _nsskr_GetLSSFeatures_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + LONG lssID; /* lss ID (input) */ + QUAD volSupportedFeatures; /* volSupportedFeatures (output) */ + QUAD volDefaultEnabledFeatures; /* volDefaultEnabledFeatures (output) */ + QUAD volChangableFeatures; /* volChangableFeatures (output) */ + STATUS status; /* Result (output) */ +} nsskr_GetLSSFeatures_t; + +typedef struct _nsskr_GetPoolID_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + /* Pool name (input) */ + STATUS status; /* Result (output) */ + VolumeID_t poolID; /* Pool ID (output) */ +} nsskr_GetPoolID_t; + +typedef struct _nsskr_GetNextUserInVolume_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + /* volume name (input) */ + UserID_t lastUser; /* The userID (input/output) */ + SQUAD restrictionAmount; /* restrictionAmout (output) */ + SQUAD usedAmount; /* usedAmount (output) */ + NINT numEntries; /* numEntries (output) */ + STATUS status; /* Result (output) */ +} nsskr_GetNextUserInVolume_t; + +typedef struct _nsskr_SetUserSpaceRestriction_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; /* input */ + NDSid_t userGUID; /* input */ + SQUAD quota; /* input */ + STATUS status; /* Result (output) */ +} nsskr_SetUserSpaceRestriction_t; + +typedef struct _nsskr_GetUserSpaceRestriction_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; /* input */ + NDSid_t userGUID; /* input */ + SQUAD usedAmount; /* output */ + SQUAD restrictionAmount; /* output */ + STATUS status; /* Result (output) */ +} nsskr_GetUserSpaceRestriction_t; + +typedef struct _nsskr_BrowseBeastsInVolume_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; /* input */ + BOOL onlineOnly; /* if TRUE, only look up active volume */ + NINT selectionCriteria; /* input */ + NINT numBeastsRequested; /* input */ + STATUS status; /* Result (output) */ + Zid_t lastZidReturned; /* input/putput */ + NINT numBeastsReturned; /* output */ + BYTE zidsBuffer[1]; /* Buffer (output) */ + /* Actual length dependent on numRequestedZids */ + /* zidsBuffer must be LAST */ +} nsskr_BrowseBeastsInVolume_t; + +typedef struct _nsskr_GetBeastInfo_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; /* input */ + BOOL onlineOnly; /* if TRUE, only look up active volume */ + BOOL getCompBeastInfo; /* if TRUE, get compBeast info if file is compressed */ + Zid_t zid; /* beast zid (input) */ + STATUS status; /* Result (output) */ + NINT typeOfInfo; /* input */ + NINT bufLen; /* input/output */ + utf8_t buffer[1]; /* Buffer (output) */ + /* Actual length dependent on bufLen */ + /* buffer must be LAST */ +} nsskr_GetBeastInfo_t; + +typedef struct _nsskr_SetBeastInfo_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; /* input */ + BOOL onlineOnly; /* if TRUE, only look up active volume */ + Zid_t zid; /* beast zid (input) */ + BOOL ignoreOpenFile; /* if TRUE, don't do anything if file is opened by any process */ + BOOL oldDataMatch; /* if TRUE, old value can't be changed */ + STATUS status; /* Result (output) */ + NINT bufLen; /* input */ + utf8_t buffer[1]; /* Buffer (output) */ + /* Actual length dependent on bufLen */ + /* buffer must be LAST */ +} nsskr_SetBeastInfo_t; + +typedef struct _nsskr_DeleteBeast_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; /* input */ + BOOL onlineOnly; /* if TRUE, only look up active volume */ + Zid_t zid; /* beast zid (input) */ + STATUS status; /* Result (output) */ +} nsskr_DeleteBeast_t; + +typedef struct _nsskr_GetBeastFullName_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; /* input */ + BOOL onlineOnly; /* if TRUE, only look up active volume */ + Zid_t zid; /* beast zid (input) */ + NINT nameSpaceID; /* name space id (input) */ + STATUS status; /* Result (output) */ + NINT bufLen; /* input/output */ + utf8_t buffer[1]; /* Buffer (output) */ + /* Actual length dependent on bufLen */ + /* buffer must be LAST */ +} nsskr_GetBeastFullName_t; + +typedef struct _nsskr_FixVolumeCompStats_t +{ + NINT len; /* Buffer length (input) */ + LONG signature; /* Signature/version (input) */ + enum nsskr opcode; /* Request opcode (input) */ + unicode_t uniVolName[zMAX_COMPONENT_NAME]; /* input */ + STATUS status; /* Result (output) */ +} nsskr_FixVolumeCompStats_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _KERNELREQ_H_ */ diff --git a/include/nwnss/include/ntlib.h b/include/nwnss/include/ntlib.h new file mode 100644 index 0000000..ad55207 --- /dev/null +++ b/include/nwnss/include/ntlib.h @@ -0,0 +1,65 @@ +/**************************************************************************** + | + | (C) Copyright 2001, 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | + | Warning - This file is used by NT Utilities like zedRemote, ZlogGet and + | etc. DO NOT ADD NSS specific code. The define NTLIB is only defined + | when source file is compiled with NT Utilities. + +-------------------------------------------------------------------------*/ +#ifndef _NTLIB_H_ +#define _NTLIB_H_ + +#include "zOmni.h" +#include "zError.h" + +#ifndef GUID_FORMAT_SIZE +#define GUID_FORMAT_SIZE 38 /* Size needed to hold the standard GUID formatted string */ +#endif + +int qradix_value( char c ); + +STATUS LB_GUIDToString( const GUID_t *guid, unsigned int bufferSize, char *buffer ); + +SQUAD LB_strtoq( const char *nptr, char **endptr, int base ); + +QUAD LB_strtouq( const char *nptr, char **endptr, int base ); + + +char *LB_strmcpy( + char *dest, + const char *src, + size_t destSize); + + +#endif diff --git a/include/nwnss/include/nwcommon.h b/include/nwnss/include/nwcommon.h new file mode 100644 index 0000000..83df592 --- /dev/null +++ b/include/nwnss/include/nwcommon.h @@ -0,0 +1,132 @@ +/**************************************************************************** + | + | (C) Copyright 2002-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + ****************************************************************************/ +#ifndef _NETWARE_COMMON_H_ +#define _NETWARE_COMMON_H_ 1 + + +#define EVMS_OEM_NOVELL 0x4E49 // 'N'ovell 'I'nc +#define MM_PDATA_SIGNATURE 0x4D4D736D // MMsg + +/* Some defines for the sys_ind field of the partition record */ +#define FREE_PARTITION 0x100 +#define NETWARE_286_PARTITION 0x164 +#define NETWARE_PARTITION 0x165 +#define NSS_PARTITION 0x169 +#define VIRTUAL_DEVICE_PARTITION 0x1CF +#define SBD_PARTITION 0x1AD +#define REMOTE_STORAGE_PARTITION 0x1AE +#define ISCSI_PARTITION 0x17F + +#define FREE_PARTITION_NAME_STRING "Free" +#define NETWARE_286_PARTITION_NAME_STRING "286" +#define NETWARE_PARTITION_NAME_STRING "Traditional" +#define NSS_PARTITION_NAME_STRING "NSS" +#define VIRTUAL_DEVICE_PARTITION_NAME_STRING "RAID0/5" +#define SBD_PARTITION_NAME_STRING "SBD" +#define REMOTE_STORAGE_PARTITION_NAME_STRING "Remote Storage" +#define ISCSI_PARTITION_NAME_STRING "ISCSI" + +/************************ status flag defines **********************/ +#define STATUS_NETWARE 0x00000001 +#define STATUS_SHARED 0x00000002 +#define STATUS_BOOT 0x00000004 +#define STATUS_LOGICAL_PART 0x00000008 +#define STATUS_MULTI_PATH 0x00000010 +#define STATUS_MIRRORED 0x00000020 +#define STATUS_RAID 0x00000040 +#define STATUS_HOTFIX 0x00000080 +#define STATUS_RESTRIPE 0x00000100 +#define STATUS_RESTRIPE_ENABLE 0x00000200 +#define STATUS_RAID_INSYNC 0x00000400 + +#define FLAG_COUNT 11 + +#define INHERITED_STATUS (STATUS_NETWARE | STATUS_LOGICAL_PART | STATUS_SHARED) + +/************************ Plug in functions ************************/ +/* Common Plugin Functions */ +#define NW_READ_HEADER (EVMS_Task_Plugin_Function+1) +#define NW_WRITE_HEADER (EVMS_Task_Plugin_Function+2) +#define NW_REMOVE_HEADER (EVMS_Task_Plugin_Function+3) +#define RENAME_FUNCTION (EVMS_Task_Plugin_Function+4) +#define MM_Task_Plugin_Function (EVMS_Task_Plugin_Function+5) + +#define NW_READ_HEADER_INDEX 0 +#define NW_WRITE_HEADER_INDEX 1 +#define NW_REMOVE_HEADER_INDEX 2 + +#define NW_FUNCTION_COUNT 3 + +#define HEADER_START_NUMBER 0 +#define HEADER_COUNT_NUMBER 1 +#define HEADER_BUFFER_NUMBER 2 + +#define HEADER_START "start sector" +#define HEADER_COUNT "sector count" +#define HEADER_BUFFER "buffer" + +#define NW_HEADER_OPTION_COUNT 3 + +/* Segment Plugin Functions */ +#define SEG_ADD_MIRROR MM_Task_Plugin_Function +#define SEG_CHANGE_SHARED (MM_Task_Plugin_Function+1) +#define SEG_LABEL_INDEX 0 +#define SEG_SHARED_INDEX 1 +#define SEG_ADD_MIRROR_INDEX 2 +#define SEG_FUNCTION_COUNT 3 + +/* Mirror Plugin functions */ +#define R1_ADD_ELEMENT MM_Task_Plugin_Function +#define R1_DELETE_ELEMENT (MM_Task_Plugin_Function+1) +#define R1_REMIRROR (MM_Task_Plugin_Function+2) +#define R1_ADD_ELEMENT_INDEX 0 +#define R1_DELETE_ELEMENT_INDEX 1 +#define R1_RENAME_INDEX 2 +#define R1_REMIRROR_INDEX 3 +#define R1_FUNCTION_COUNT 4 + +/* RAID Plugin functions */ +#define RAID_ADD_ELEMENT MM_Task_Plugin_Function +#define RAID_REMOVE_ELEMENT (MM_Task_Plugin_Function+1) +#define RAID_RESTRIPE (MM_Task_Plugin_Function+2) +#define RAID_RENAME_INDEX 0 +#define RAID_ADD_ELEMENT_INDEX 1 +#define RAID_RESTRIPE_INDEX 2 +#define RAID_REMOVE_ELEMENT_INDEX 3 +#define RAID0_FUNCTION_COUNT 3 +#define RAID5_FUNCTION_COUNT 4 + +/* NSS Plugin functions */ +#define NSS_RENAME_INDEX 0 +#define NSS_FUNCTION_COUNT 1 + + +#endif + diff --git a/include/nwnss/include/nwcore.h b/include/nwnss/include/nwcore.h new file mode 100644 index 0000000..665a134 --- /dev/null +++ b/include/nwnss/include/nwcore.h @@ -0,0 +1,130 @@ +/**************************************************************************** + | + | (C) Copyright 2002-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | File Name: nwcore.h + | + | File Created: 07/07/2003 + | + | Engineering Contact: K.Y. Srinivasan + | + | Target Platform: COMMON_SOURCE + | + | + | File Description: + | An implementation of the NetWare MP in the Linux Kernel. We have + | initially imlemented a subset of the APIs and semantics. + |*************************************************************************** + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + ****************************************************************************/ + +#ifndef NWCORE_H +#define NWCORE_H + + +#include +#include + +void assert_wait(void); +#define ASSERT(e) \ +if (!(e)) {\ + printk("ASSERTION FAILED\n");\ + printk("File is: %s\n", __FILE__);\ + printk("Line Number is: %d\n", __LINE__);\ + assert_wait();\ +} + + +typedef struct nwPid{ + pid_t id; + struct nwPid *next; + void *private; +} nwPid_t; + +/* + * Mapping between a pid and struct nwPid- a simple hashing scheme: Low order + * 10 bits used to hash the pids. + */ + +typedef struct pidHashHead { + spinlock_t lock; + struct nwPid *first; +} pidHashHead_t; + +#define NUM_HASH_BUCKETS 256 +#define NUM_HASH_BITS 8 + + +/* + * Initialize the core component. + */ + +void initNwCore(void); +/* + * Enq a fully initialized pi structure. + */ + +void enqPid(nwPid_t *newPid); + +/* + * Deq a pid structure. + */ + +void deqPid(nwPid_t *newPid); + +/* + * Serach a Pid. Function returns with the hash lock held. + */ + +nwPid_t *getPidRef(pid_t id); + +/* + * Release reference on the Pid. On entry hash lock is held. This lock is + * released prior to returning. + */ + +void relPidRef(nwPid_t *pidp); + +/* + * Get the private handle given the pid. + */ + +void *getPidPrivHandle(pid_t pid); + +/* + * Enter legacy code. + */ + +void enterLegacyGate(void); + +/* + * Exit legacy code. + */ + +void exitLegacyGate(void); + +#endif /* NWCORE_H*/ diff --git a/include/nwnss/include/objectIDStore.h b/include/nwnss/include/objectIDStore.h deleted file mode 100644 index 7f33bac..0000000 --- a/include/nwnss/include/objectIDStore.h +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** - | - | (C) Copyright 2001 Novell, Inc. - | All Rights Reserved. - | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. - | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. - | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. - | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com - | - |*************************************************************************** - | - | Novell Storage Services (NSS) module - | - |--------------------------------------------------------------------------- - | - | $Author: randys $ - | $Date: 2006-11-16 04:42:23 +0530 (Thu, 16 Nov 2006) $ - | - | $RCSfile$ - | $Revision: 1657 $ - | - |--------------------------------------------------------------------------- - | This module is used to: - +-------------------------------------------------------------------------*/ -#ifndef _OBJECTIDSTORE_H_ -#define _OBJECTIDSTORE_H_ - -/**************************************************************************** - * Main object ID caching structure - *****************************************************************************/ -typedef struct ObjectIDCacheCtrl_s -{ - QUAD gets; /* number of times we did gets on the cache */ - QUAD hits; /* number of cache hits */ - Latch_s latch; /* latch to control changes in this structure */ - NINT numHashEntries; /* number of entries in the has table */ - DQhead_t (*hash)[]; /* pointer to hash array */ - DQhead_t LRUqueue; /* head of the Least Recently Used queue */ - DQhead_t unusedQueue; /* head of the unused cache packets queue */ - NINT maxEntries; /* max allowed entries in the cache */ - NINT numEntries; /* number of entries in the cache */ - NINT numUnusedEntries; /* number of unused cache entries */ - NINT numAdded; /* incremented each time an entry is added */ - NINT numRemoved; /* number of entries removed (not victom selected) */ - NINT numVictimSelected; /* number of entries that have been victim selected */ - NINT unusedEntryHit; /* number of time we found an unused entry when adding */ - NINT dupAdds; /* number of times same add occured while adding */ -} ObjectIDCacheCtrl_s; - -extern ObjectIDCacheCtrl_s ObjectIDCache; - -#define DEFAULT_OID_CACHE_SIZE 4096 - -typedef struct ObjectIDCacheNode_s -{ - DQlink_t hashLink; /* hash list link field */ - DQlink_t LRUlink; /* LRU link field */ - Zid_t volume; /* volume for the entry */ - UserID_t objectID; /* the ID for the object */ -} ObjectIDCacheNode_s; - -/**************************************************************************** - * Event queue structures - *****************************************************************************/ -typedef struct EventEntry_s -{ - SQlink_t next; - NINT type; - union { - struct - { - unicode_t *oldName; - unicode_t *newName; - } ren; - struct - { -// NDSid_t ndsID; - unicode_t *name; - } del; - } u; -} EventEntry_s; - -#define NDS_RENAME 0 -#define NDS_DELETE 1 - -/**************************************************************************** - * - * Function Prototypes - * - ****************************************************************************/ -STATUS OID_Startup(void); - -void OID_Shutdown(void); - -STATUS OID_AddEntryIfNotThere( - struct GeneralMsg_s *genMsg, - struct Volume_s *vol, - UserID_t *objectID); - -void OID_SaveObjectID( - struct Volume_s *vol, - UserID_t *objectID); - -STATUS OID_GetObjectName( - struct GeneralMsg_s *genMsg, - struct Volume_s *vol, - UserID_t *objectID, - unicode_t *name); - -void OID_InitObjectIDStoreByName( - struct GeneralMsg_s *genMsg, - unicode_t *name, - BOOL reset, - BOOL scan); - -STATUS OID_InitObjectInfo( - struct GeneralMsg_s *genMsg, - struct Volume_s *vol); - -void OID_InvalidateObjectIDCache( - Volume_s *volume); - -void OID_ExportVolGUIDsToLinux( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume); - -#endif diff --git a/include/nwnss/include/opLock.h b/include/nwnss/include/opLock.h index d821b44..3fffb96 100644 --- a/include/nwnss/include/opLock.h +++ b/include/nwnss/include/opLock.h @@ -32,7 +32,7 @@ | |--------------------------------------------------------------------------- | This module is used to: - | Define the Semantic Agent side of OpLocks. + | Define the Semantic Agent side of OpLocks. | | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! | @@ -176,7 +176,7 @@ typedef struct OpLockControl_s typedef struct OpLock_s { - DQlink_t opLink; + DQlink_t opLink; statusfunc_t opCallback; /* Function to call in S.A. */ FileHandle_s *fileHandle; /* File handle for OpLock */ OpLockControl_s *control; @@ -226,7 +226,7 @@ STATUS OPLOCK_Break( * 4. Thread hasn't blocked from the return in step 1 thru step 3. * 5. If you were trying to also break shared oplocks, you'll have * to call OPLOCK_BreakShared - */ + */ STATUS OPLOCK_WaitForBreak( GeneralMsg_s *genMsg, File_s *file); diff --git a/include/nwnss/include/osmpkhdrs.h b/include/nwnss/include/osmpkhdrs.h new file mode 100644 index 0000000..fc67b73 --- /dev/null +++ b/include/nwnss/include/osmpkhdrs.h @@ -0,0 +1,67 @@ +/**************************************************************************** + | + | (C) Copyright 1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Include all OS MPK header files + | + | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + | + | This header file should ONLY be used for NSS internal development. + | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). + | Any other use may cause conflicts which NSS will NOT fix. + +-------------------------------------------------------------------------*/ + +#ifndef _OSMPKHDRS_H_ +#define _OSMPKHDRS_H_ + +#ifndef _MPKTYPES_H_ +#include +#endif + +#ifndef _MPKOSLIB_H_ +#include +#endif + +#ifndef _MPKLIB_H_ +#include +#endif + +#ifndef _MPKAPIS_H_ +#include +#endif + +#ifndef _MPKERROR_H_ +#include +#endif + +#endif diff --git a/include/nwnss/include/parse.h b/include/nwnss/include/parse.h index cbd65ac..780e59a 100644 --- a/include/nwnss/include/parse.h +++ b/include/nwnss/include/parse.h @@ -44,7 +44,7 @@ #define _PARSE_H_ #ifndef _OMNI_H_ -# include +# include #endif #ifdef __cplusplus @@ -89,14 +89,14 @@ typedef STATUS (*PCLFunction_t)( typedef struct PCLSwitchDef_s { char *name; /* The name of this switch*/ - char *setParmName; /* The name of this switch in set parameters + char *setParmName; /* The name of this switch in set parameters * Set to NULL if the option does not require * a OS set parameter entry */ NINT type; /* Type and options for the switch (see below) */ NINT setParmType; /* Type of the switch as passed to setParms */ NINT setParmFlags; /* Optional flags as defined in setparms.h */ - /* Currently we don't support the process + /* Currently we don't support the process * option for set parameters. Another * setParmProcess field will need to be * added to do this. @@ -271,20 +271,20 @@ extern LONG NSSSetParmCategory; * they will appear under each category during a help display. If no bit * is set, the command line will not appear in the help list(s). If additional * categories are added, additional titles must be added to the array - * CmdLineCategories in pcmdline.c. These bits MUST be contiguouos if new + * CmdLineCategories in pcmdline.c. These bits MUST be contiguouos if new * categories are added. *-------------------------------------------------------------------------*/ -#define SWHELP_CAT_MAINT 0x01000000 /* if set, display switch in the - * maintenance category */ -#define SWHELP_CAT_STATUS 0x02000000 /* if set, display switch in the - * status category */ -#define SWHELP_CAT_CONTROL 0x04000000 /* if set, display switch in the - * control category */ -#define SWHELP_CAT_TUNING 0x08000000 /* if set, display switch in the - * tuning category */ -#define SWHELP_CAT_MISC 0x10000000 /* if set, display switch in the - * maintenance category */ +#define SWHELP_CAT_MAINT 0x01000000 /* if set, display switch in the + * maintenance category */ +#define SWHELP_CAT_STATUS 0x02000000 /* if set, display switch in the + * status category */ +#define SWHELP_CAT_CONTROL 0x04000000 /* if set, display switch in the + * control category */ +#define SWHELP_CAT_TUNING 0x08000000 /* if set, display switch in the + * tuning category */ +#define SWHELP_CAT_MISC 0x10000000 /* if set, display switch in the + * maintenance category */ #define SWHELP_CAT_FIRST SWHELP_CAT_MAINT #define SWHELP_CAT_COUNT 5 /* number of help categories */ @@ -321,9 +321,9 @@ extern LONG NSSSetParmCategory; #define SWPRV_GROUP_ACTIVE 0x00000400 /* if SET this group switch is now * active, only set on child members*/ #define SWPRV_SPECIFIED 0x00000800 /* this is SET by the parsing routine - * for each switch that has a value - * it is cleared for each switch that - * does NOT have a value.*/ + * for each switch that has a value + * it is cleared for each switch that + * does NOT have a value.*/ /*------------------------------------------------------------------------- * This is a mask that is used to set the TYPE field to the list of diff --git a/include/nwnss/include/pssConfig.h b/include/nwnss/include/pssConfig.h deleted file mode 100644 index 572b11e..0000000 --- a/include/nwnss/include/pssConfig.h +++ /dev/null @@ -1,380 +0,0 @@ -/**************************************************************************** - | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. - | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. - | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. - | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. - | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com - | - |*************************************************************************** - | - | NetWare Advance File Services (NSS) Initialization module - | - |--------------------------------------------------------------------------- - | - | $Author: gpachner $ - | $Date: 2007-06-07 02:25:28 +0530 (Thu, 07 Jun 2007) $ - | - | $RCSfile$ - | $Revision: 2044 $ - | - |--------------------------------------------------------------------------- - | This module is used to: - | Define configuration values for the Z file system - | - | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! - | - | This header file should ONLY be used for NSS internal development. - | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). - | Any other use may cause conflicts which NSS will NOT fix. - +-------------------------------------------------------------------------*/ - -#ifndef _PSSCONFIG_H_ -#define _PSSCONFIG_H_ - -#ifndef _OMNI_H_ -#include -#endif - -#include "hmc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern NINT WorkWaitingCount; -extern NINT WorkHighWaitingCount; - -#define CACHE_BALANCE_TIMER_SECS 30 -#define MIN_OS_FREE_CACHE_BUFS 256 -#define DEFAULT_NUM_BUFFERS_PER_SESSION 1024 - -#define PERCENT_OF_OS_BUFS(_num) (((_num)*Config.cache.percentOfOSFree)/100) -#define BALANCE_CACHE_MIN 16 - -#define MAX_PERCENT_FOR_USER_PAGES 50 - -#if defined(__i386__) -#define DEFAULT_HMC_CACHE_TYPE HMC_CT_PRIVATE -#endif -#if defined(__x86_64__) -#define DEFAULT_HMC_CACHE_TYPE HMC_CT_NONE -#endif -#define DEFAULT_PRIVATE_CACHE_PAGES 1 /* Calculated in HMC_Startup */ - - - -/** Set Maximum value to zero if there is no Maximum limit for the variable **/ -/** Set Minimum value to zero if the variable can be set to zero **/ - -/* Range definitions*/ -//#define MIN_NUM_BUFFERS 8 /* See debug area */ -#define MAX_NUM_BUFFERS 1048576 /* Upto 4 GB of memory */ - -#define MIN_NUM_ASYNCIOS 4 -#define MAX_NUM_ASYNCIOS 65536 - -#define MIN_NUM_BONDS (2 * MIN_NUM_BUFFERS) -#define MAX_NUM_BONDS (2 * MAX_NUM_BUFFERS) - -//#define MIN_CACHE_HASH_SHIFT 8 -//#define MAX_CACHE_HASH_SHIFT 20 - -#define MIN_NOT_IN_USE_BEASTS 16 -#define MAX_NOT_IN_USE_BEASTS 1000000 -#define MIN_BEASTS_TO_RETURN 16 /* Always return at least this many */ - -#define MIN_BEAST_HASH_SHIFT 8 -#define MAX_BEAST_HASH_SHIFT 25 - -#define MIN_SIZE_MAILBOX 256 -#define MAX_SIZE_MAILBOX 65536 - -#define MIN_SEC 1 -#define MAX_SEC 3600 - -#define MIN_WORK_LIMIT 5 -#define MAX_WORK_LIMIT 100 - -#define MIN_NUM_XACTIONS 4 -#define MAX_NUM_XACTIONS 65536 - -#define MIN_NUM_XDELETES 4 -#define MAX_NUM_XDELETES 65536 - -#define MIN_STORAGE_ALARM_THRESHOLD 0 -#define MAX_STORAGE_ALARM_THRESHOLD 1000000 - -#define MIN_STORAGE_RESET_THRESHOLD 0 -#define MAX_STORAGE_RESET_THRESHOLD 1000000 - -#define DEFAULT_BEAST_PERCENT_MEM 45 - -#define DEFAULT_BEAST_BALANCE_SEC 1 - -#define MIN_ALLOC_AHEAD_WRITE 0 -#define DEFAULT_ALLOC_AHEAD_WRITE 0 // On linux most applications on - // server and ncp and probably cifs - // do larger writes (not network - // packet size writes). So we get - // better performance without - // allocahead. -#define MAX_ALLOC_AHEAD_WRITE 63 - - -#if NSS_DEBUG IS_ENABLED - /* - * DEBUG values - */ -#define PERCENT_OS_FREE_CACHE 99 -#define PRERESERVE_FOR_BEAST_FLUSH 64 -#define CACHE_HYSTERESIS 16 /* Have to have at least this many OS - * buffers that we can take before we - * take any. - */ -#define MIN_NUM_BUFFERS (CACHE_HYSTERESIS + PRERESERVE_FOR_BEAST_FLUSH) - -#define DEFAULT_NUM_BONDS 5000 /*(2 * DEFAULT_NUM_BUFFERS)*/ -#define DEFAULT_NUM_BUFFERS 512 -#define DEFAULT_NUM_ASYNCIOS 2048 -#define DEFAULT_NUM_DELAYED_BEASTS 40 -//#define DEFAULT_CACHE_HASH_SHIFT 10 -#define DEFAULT_NOT_IN_USE_BEASTS 100000 -//#define DEFAULT_BEAST_HASH_SHIFT 12 -#define DEFAULT_SIZE_MAILBOX 512 -#define DEFAULT_SEC_BEAST 10 -#define DEFAULT_SEC_XACTION 20 -#define DEFAULT_SEC_CHKPT 30 -#define DEFAULT_SEC_OPLOCKWAIT 30 -#define DEFAULT_WORK_LIMIT 30 -#define DEFAULT_NUM_XACTIONS 50 -#define DEFAULT_NUM_XDELETES 10 -#define DEFAULT_STORAGE_ALARM_THRESHOLD 1 /* in kbytes */ -#define DEFAULT_STORAGE_RESET_THRESHOLD 2 /* in kbytes */ -#define DEFAULT_STORAGE_SEND_ALERT 1 /* boolean */ -#else - /* - * PRODUCTION values - */ -#define PERCENT_OS_FREE_CACHE 85 -#define PRERESERVE_FOR_BEAST_FLUSH 128 -#define CACHE_HYSTERESIS 256 /* Have to have at least this many OS - * buffers that we can take before we - * take any. - */ -#define MIN_NUM_BUFFERS (CACHE_HYSTERESIS + PRERESERVE_FOR_BEAST_FLUSH) - -#define DEFAULT_NUM_BONDS 5000 /*(2 * DEFAULT_NUM_BUFFERS)*/ -#define DEFAULT_NUM_BUFFERS 512 -#define DEFAULT_NUM_ASYNCIOS 2048 -#define DEFAULT_NUM_DELAYED_BEASTS 40 -//#define DEFAULT_CACHE_HASH_SHIFT 13 -#define DEFAULT_NOT_IN_USE_BEASTS 100000 -//#define DEFAULT_BEAST_HASH_SHIFT 16 -#define DEFAULT_SIZE_MAILBOX 512 -#define DEFAULT_SEC_BEAST 10 -#define DEFAULT_SEC_XACTION 20 -#define DEFAULT_SEC_CHKPT 30 -#define DEFAULT_SEC_OPLOCKWAIT 30 -#define DEFAULT_WORK_LIMIT 50 -#define DEFAULT_NUM_XACTIONS 5000 -#define DEFAULT_NUM_XDELETES 1000 -#define DEFAULT_STORAGE_ALARM_THRESHOLD 10 /* in megabytes */ -#define DEFAULT_STORAGE_RESET_THRESHOLD 15 /* in megabytes */ -#define DEFAULT_STORAGE_SEND_ALERT 1 /* boolean */ -#endif - -#define DEFAULT_SEC_JOURNAL_GROUP_WRITE 1 -#define DEFAULT_SEC_METADATA_GROUP_WRITE 40 -#define DEFAULT_SEC_USER_DATA_GROUP_WRITE 3 -#define DEFAULT_METADATA_GROUP_WRITE_LIMIT 20000 /* Really a limit target */ - -#define DEFAULT_CHECKER TRUE -#define DEFAULT_FORCE_CHECKER FALSE -#define DEFAULT_WORK_DELAY_CNT 100 -#define DEFAULT_MSEC_WORK_WAIT 100 - -#define DEFAULT_MAX_WORK_WAITING 1000 -#define DEFAULT_MAX_HIGH_WORK_WAITING 50 - -#define DEFAULT_LV_PURGE_DELAY_AFTER_DELETE_SECONDS (60 * 60 * 24 * 4) /* 4 days (was 2 days, but increased so to stay around over LONG weekend)*/ -#define DEFAULT_LV_PURGE_DELAY_AFTER_LOAD_SECONDS (60 * 60 * 2) /* 2 hour */ -#define DEFAULT_LV_PURGE_DELAY_AFTER_LAST_ENTRY_SECONDS (60 * 15) /* 15 minutes */ - -#if zLINUX -#define DEFAULT_SECURITY_EQUIV_UPDATER TRUE -#define DEFAULT_FORCE_SECURITY_EQUIV_UPDATER FALSE -#define DEFAULT_SECURITY_EQUIV_UPDATER_SECONDS (((60 * 60) * 2) + 37) /* 2 hours and 37 seconds */ -#define DEFAULT_SECURITY_EQUIV_UPDATER_CHANGED FALSE -#endif - -/* min/max values for the high/low watermarks used to control purge limits */ -#define zMAX_HIGHWATERMARK 100 -#define zMIN_HIGHWATERMARK 2 -#define zMAX_LOWWATERMARK 98 -#define zMIN_LOWWATERMARK 0 - -typedef struct Config_s -{ - struct Cache_s - { - NINT numBuffers; - NINT numBonds; - NINT numAsyncios; -// NINT hashShift; - NINT hashSize; - NINT hashMask; - - BOOL usePercentMemory; - NINT percentOfOSFree; - NINT balanceTimerSecs; - NINT minOSFree; - NINT numPagesAllocated; - NINT maxNumBuffersToAddPerBalance; - NINT userPages; /* number of pages used for user data */ - NINT percentUserPages; /* percentage of total pages for user */ - NINT hmcCacheType; /* HMC_CT_LINUX, HMC_CT_NONE, or - HMC_CT_PRIVATE. Needed on servers with limited low - memory, but lots of high memory. In which case, - NSS will use high memory as a secondary cache for - its meta-data blocks unless user turns off. */ - NINT privateHashSize; - NINT privateHashMask; - NINT privateCachePageBuffers; /* Number of page buffers that are - currently in the private cache. */ - NINT privateCachePages; /* Number of pages that are currently - attached to our page buffers. */ - NINT privateCacheSizeRequest; /* For HMC_CT_PRIVATE. Number of - pages buffers to have in the private cache. The - actual number of page buffers that we have is - in privateCachePageBuffers. */ - BOOL privateCacheSizeRequestStartup; /* Indicates that user - set privateCacheSizeRequest at startup time. */ - NINT metadataBlocksReadyForGroupWriteLimit; /* Limits the number - of metadata blocks that are on the metadata - group write list. This limits the amount of - time needed to play the journal after a crash. */ - NINT metadataBlocksReadyForGroupWrite; /* Current count of - metadata blocks that are on the metadata group - write list. */ - } cache; - struct Os_s - { - NINT sizeMailbox; - NINT workLimit; - NINT workDelayCnt; - } os; - struct Bst_s - { - NINT notInUseMax; /* Max beasts allowed to be not in use */ - NINT percentMemory; /* Max % memory to be used by beasts */ - NINT balanceTimerSecs; /* Balance beasts with memory */ -// NINT hashShift; - NINT hashSize; -// NINT hashMask; - NINT notInUseLimit; /* Current limit for not in use beasts */ - NINT total; /* Total number of beasts in memory */ - NINT notInUse; /* Number of closed beasts not in use */ - SNINT remainingLimit; /* Remaining limit of beasts */ - } bst; - struct Sec_s - { - NINT beast; - NINT xaction; - NINT chkpt; - NINT opLockWait; - NINT journalGroupWriteTime; - NINT metadataGroupWriteTime; - NINT userDataGroupWriteTime; - } sec; - struct Msec_s - { - NINT workWait; - } msec_s; - struct Tick_s - { - NINT beast; - NINT xaction; - NINT chkpt; - NINT opLockWait; - } tick; - struct NumWork_s - { - NINT waiting; - NINT waitingHigh; - } work; - struct Xact_s - { - NINT numDelayed; - } xact; - struct Zfs_s - { - NINT numXactions; - NINT numXdeletes; - } zfs; - struct Storage - { - NINT alarmThreshold; - NINT resetThreshold; - BOOL sendAlert; - NINT allocAhead; - BOOL checker; /* TRUE if the background checker is to be run */ - BOOL forceChecker; /* TRUE if the background checker is to be forced to run */ - } Storage; - struct LV_s - { - NINT PurgeDelayAfterDeleteSeconds; /* Number of seconds that - a volume is non-purgeable. */ - NINT PurgeDelayAfterLoadSeconds; /* Number of seconds that - a volume will not be purged in - after NSS loads. Used to give the - ADMIN some time to change state of - a deleted volume after load. */ - NINT PurgeDelayAfterLastEntrySeconds; /* Number of seconds that - a volume is non-purgeable after - its last entry into purgeable state. - E.G. if a LV is paused then - un-paused after its normal purge - time then it will not be purgeable - for the number of seconds indicated - by this element. */ - } lv; -#if zLINUX - struct SecEquiv_s - { - BOOL updater; /* TRUE if the security equivalence - * background updater is to be run */ - BOOL forceUpdater; /* TRUE if the security equivalence - * background updater is to be - * forced to be run */ - NINT updaterInterval; /* Number of seconds that we delay - * after finishing a security - * equivalence update and before - * starting a new one.*/ - BOOL intervalChanged; /* TRUE if the security equivalence - * background interval was changed */ - } SecEquiv; -#endif -} Config_s; - -extern Config_s Config; - -void configStartup(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/nwnss/include/pssDebug.h b/include/nwnss/include/pssDebug.h index a635913..f926e20 100644 --- a/include/nwnss/include/pssDebug.h +++ b/include/nwnss/include/pssDebug.h @@ -47,22 +47,20 @@ extern "C" { #endif -#ifndef _OMNI_H_ -# include +#ifndef _SCHEDULE_H_ +# include #endif -#if NSS_DEBUG IS_ENABLED -#ifndef _SCHEDULE_H_ -# include -#endif +#ifndef _OMNI_H_ +# include #endif #ifndef _XSTDIO_H_ -# include +# include #endif #ifndef _INLINES_H_ -# include +# include #endif /* Pre-define struct(s) so Linux compiler doesn't complain */ @@ -171,7 +169,7 @@ extern LONG DBG_DoNSSDebuggerCommand( struct ScreenStruct *debugScreen, char *commandLine, struct StackFrame *StkFrm); - + //extern void printBitMap(NINT *map, NINT numBits); diff --git a/include/nwnss/include/pssmpk.h b/include/nwnss/include/pssmpk.h index 2f2afb0..742e1fa 100644 --- a/include/nwnss/include/pssmpk.h +++ b/include/nwnss/include/pssmpk.h @@ -1,23 +1,26 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996-1998 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996-1998 Novell, Inc. + | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) Initialization module + | NetWare Advance File Services (NSS) Initialization module | |--------------------------------------------------------------------------- | @@ -28,77 +31,189 @@ | $Revision: 1853 $ | |--------------------------------------------------------------------------- - | This module is used to: - | This contains the Spinlock defines used to incorporate SMP - | feature in Novell Storage Services. The code calling the - | following routines grabs or releases the global spinlock named - | MPKNSS_LOCK before accessing shared code or data. + | This module is used to: + | This contains the Spinlock defines used to incorporate SMP feature + | in Novell Storage Serivces. The code calling the following routines + | will grab or release for the Global Spinlock named MPKNSS_LOCK and + | acoordingly access shared code or data as and it is necessary. +-------------------------------------------------------------------------*/ #ifndef _PSSMPK_H_ #define _PSSMPK_H_ -#ifndef _OMNI_H_ -# include -#endif - -#ifndef MARS_NWE_CORE_SPINLOCK_H -# include -#endif - -#ifndef _HISTOGRAM_H_ -# include -#endif - #ifdef __cplusplus extern "C" { #endif -/* - * mars-nwe is a Linux userspace port. The original NSS header pulled in - * NetWare/Linux-kernel MPK and spinlock headers here. Keep the NSS API and - * structure shape local to the userspace NSS runtime, but map the lock backend to the Linux - * pthread spinlock wrapper from include/nwnss/internal/spinlock.h. - */ +#ifndef _SCHEDULE_H_ +# include +#endif + +#ifndef _MPKAPIS_H +# include +#endif + +#ifndef _OMNI_H_ +# include +#endif + +#ifndef __LINUX_SPINLOCK_H +# include +#endif + +/* Pre-define struct(s) so Linux compiler doesn't complain */ +struct ScreenStruct; + +#if MPK_REAL IS_ENABLED /* this is the FLAG that gets enabled when + * MP targets are specified in the build + * engine both debug and optimised versions + */ + /* + * the NSS global spinlock structure + */ typedef struct NSSMPK_Spinlock_t { #define USE_SPINLOCK - spinlock_t NSL_spinlock; - ADDR NSL_owner; +#ifdef USE_SPINLOCK + spinlock_t NSL_spinlock; +// SPINLOCK NSL_spinlock; /* The MPK SpinLock */ +// MUTEX NSL_mutex; +#else + mpkSema_t NSL_semaphore; +#endif +// FLAGS NSL_flags; // This goes wiht SPINLOCK + ADDR NSL_owner; /* Thread that holds this lock */ + +#if NSS_DEBUG IS_ENABLED + /* + * debugging information to find the last callers of the Spinlock code + */ +#define NSSSPINLOCK_CALLERS_MAX 5 + + NINT NSL_callersNumber; /* Number of filled in callers */ + void* NSL_callers[NSSSPINLOCK_CALLERS_MAX]; + /* Holders callers addresses (really return + * addresses) + */ + + LONG NSL_initialized;/* Set to 1 if the SpinLock is Initialized*/ + LONG NSL_islockheld; /* Set to 1 if held or 0 if released*/ + LONG NSL_currentcpu; /* The processor from which the owner asked for it*/ + LONG NSL_timeStamp; /* Time stamp when lock was aquired */ + LONG NSL_timeHeld; /* How long the lock was last held */ +#endif + } NSSMPK_Spinlock_t; -extern NSSMPK_Spinlock_t NSSMPK_spinlock; -extern Histogram_s SpinLockHeld; -extern Histogram_s SpinLockWait; -extern NINT SpinHeldStart; -extern BOOL MeasureSpinLock; +extern NSSMPK_Spinlock_t NSSMPK_spinlock; -extern void NSSMPK_InitNsslock(void); -extern NINT NSSMPK_LockNss(void); -extern NINT NSSMPK_LockNssNoInterrupts(void); -extern NINT NSSMPK_UnlockNss(void); -extern BOOL NSSMPK_IOwnSpinlock(void); +#if NSS_DEBUG IS_ENABLED -#define MPKNSS_INIT_LOCK() NSSMPK_InitNsslock() -#define MPKNSS_LOCK() NSSMPK_LockNss() -#define MPKNSS_LOCK_NO_INTERRUPTS() NSSMPK_LockNssNoInterrupts() -#define MPKNSS_UNLOCK() NSSMPK_UnlockNss() -#define MPKNSS_I_OWN_SPINLOCK() NSSMPK_IOwnSpinlock() -#define ASSERT_MPKNSS_LOCK() ((void)0) -#define ASSERT_I_DONT_HAVE_MPKNSS_LOCK() ((void)0) -#define WARN_MPKNSS_LOCK() ((void)0) +extern void NSSMPK_InitNsslock(char *); +extern NINT NSSMPK_LockNss(char *); +extern NINT NSSMPK_LockNssNoInterrupts(char *); +extern NINT NSSMPK_UnlockNss(char *); -struct ScreenStruct; -extern void DBG_SaveSpinLock(void); -extern void DBG_RestoreSpinLock(void); +#define MPKNSS_INIT_LOCK() NSSMPK_InitNsslock(WHERE) +#define MPKNSS_LOCK() NSSMPK_LockNss(WHERE) +#define MPKNSS_LOCK_NO_INTERRUPTS() NSSMPK_LockNssNoInterrupts(WHERE) +#define MPKNSS_UNLOCK() NSSMPK_UnlockNss(WHERE) + +#else + +extern void NSSMPK_InitNsslock(void); +extern NINT NSSMPK_LockNss(void); +extern NINT NSSMPK_LockNssNoInterrupts(void); +extern NINT NSSMPK_UnlockNss(void); + +#define MPKNSS_INIT_LOCK() NSSMPK_InitNsslock() +#define MPKNSS_LOCK() NSSMPK_LockNss() +#define MPKNSS_LOCK_NO_INTERRUPTS() NSSMPK_LockNssNoInterrupts() +#define MPKNSS_UNLOCK() NSSMPK_UnlockNss() + +#endif + +#ifdef __linux__ +#define MPKNSS_I_OWN_SPINLOCK() ( \ + (NSSMPK_spinlock.NSL_owner == (ADDR)current)) +#endif + +#if zNETWARE +#define MPKNSS_I_OWN_SPINLOCK() ( \ + NSSMPK_spinlock.NSL_spinlock \ + && (NSSMPK_spinlock.NSL_owner == RunningProcess)) +#endif + +#if NSS_DEBUG IS_ENABLED + +#if zNETWARE + // Under Linux RunningProcess is a macro +extern LONG RunningProcess; +#endif + +#if zNETWARE +# define ASSERT_MPKNSS_LOCK() \ + ASSERTMP((NSSMPK_spinlock.NSL_islockheld == 1) \ + && (RunningProcess == (ADDR)NSSMPK_spinlock.NSL_owner)) + +# define ASSERT_I_DONT_HAVE_MPKNSS_LOCK() \ + ASSERTMP(RunningProcess != (ADDR)NSSMPK_spinlock.NSL_owner) + +# define WARN_MPKNSS_LOCK() WARN(NSSMPK_spinlock.NSL_islockheld == 1) + +#endif + +#ifdef __linux__ +# define ASSERT_MPKNSS_LOCK() \ + ASSERTMP(NSSMPK_spinlock.NSL_owner == (ADDR)current) + +# define ASSERT_I_DONT_HAVE_MPKNSS_LOCK() \ + ASSERTMP(NSSMPK_spinlock.NSL_owner != (ADDR)current) + +# define WARN_MPKNSS_LOCK() \ + WARN(NSSMPK_spinlock.NSL_owner == (ADDR)current) +#endif + +#else /* optimised MP NSS */ + +#if 1 +# define ASSERT_MPKNSS_LOCK() ((void)0) +#else +# define MYASSERT(_e_) \ + ((void)((_e_) || (DBG_AssertError_MP(WHERE " (" # _e_ ")"), \ + (DBG_DebugBreak && (EnterDebugger(), DBG_AssertErrorStub()))))) +# define ASSERT_MPKNSS_LOCK() \ + MYASSERT(((ADDR)current == (ADDR)NSSMPK_spinlock.NSL_owner)) +#endif +# define WARN_MPKNSS_LOCK() ((void)0) +# define ASSERT_I_DONT_HAVE_MPKNSS_LOCK() ((void)0) + +#endif + +#else + /* we are building SP modules + */ +#define MPKNSS_INIT_LOCK() ((void)0) +#define MPKNSS_LOCK() ((void)0) +#define MPKNSS_LOCK_NO_INTERRUPTS() ((void)0) +#define MPKNSS_UNLOCK() ((void)0) +#define ASSERT_MPKNSS_LOCK() ((void)0) +#define WARN_MPKNSS_LOCK() ((void)0) +#define MPKNSS_I_OWN_SPINLOCK() (TRUE) + +#endif + +extern void DBG_SaveSpinLock(void); +extern void DBG_RestoreSpinLock(void); extern void DBG_DumpSpinLock(struct ScreenStruct *debugScreen); -extern void nssInitializeSpinLockCode(void); -extern void nssSpinLock(void); -extern void nssSpinUnlock(void); +extern void nssInitializeSpinLockCode(); +extern void nssSpinLock(); +extern void nssSpinUnlock(); + #ifdef __cplusplus } #endif -#endif /* _PSSMPK_H_ */ +#endif diff --git a/include/nwnss/include/register.h b/include/nwnss/include/register.h index 4faad5e..3cbf69b 100644 --- a/include/nwnss/include/register.h +++ b/include/nwnss/include/register.h @@ -44,11 +44,11 @@ #define _REGISTER_H_ #ifndef _OMNI_H_ -# include +# include #endif #ifndef _DISPLAYVERSION_H_ -# include +# include #endif #ifdef __cplusplus diff --git a/include/nwnss/include/repair.h b/include/nwnss/include/repair.h index 6bdeeec..ad6c0f8 100644 --- a/include/nwnss/include/repair.h +++ b/include/nwnss/include/repair.h @@ -38,25 +38,25 @@ #define _REPAIR_H_ //#if zNETWARE || (zLINUX && defined(__KERNEL__)) -//#include +//#include //#include //#endif #ifndef _MPKTYPES_H_ -# include +# include #endif -#include +#include #ifndef _QUE_H_ -# include +# include #endif #ifndef _VOLUME_H_ -# include +# include #endif -#include +#include #define CheckProcessPriority 50 diff --git a/include/nwnss/include/repairRAVUser.h b/include/nwnss/include/repairRAVUser.h index 66d4251..1c815c0 100644 --- a/include/nwnss/include/repairRAVUser.h +++ b/include/nwnss/include/repairRAVUser.h @@ -40,7 +40,7 @@ #define _REPAIRZVPUSER_H_ -#include +#include #if zLINUX #define RAV_MEDIA_STRUCTURE() __attribute__((packed)) @@ -83,7 +83,7 @@ typedef QUAD Lsn_t; #define ZV_SALVAGE_LEAF_BIT_BUCKET_RANGE 10 #define ZV_UBT_BRANCH_BIT_BUCKET_RANGE 50 #define ZV_UBT_LEAF_BIT_BUCKET_RANGE 25 -#define ZV_DBT_BRANCH_BIT_BUCKET_RANGE 50 +#define ZV_DBT_BRANCH_BIT_BUCKET_RANGE 50 #define ZV_DBT_LEAF_BIT_BUCKET_RANGE 25 #define ZV_BEAST_BRANCH_BIT_BUCKET_RANGE 50 #define ZV_BEAST_LEAF_BIT_BUCKET_RANGE 1 @@ -264,7 +264,7 @@ typedef struct STDS_unaccBlks_s // --- ZSS_TYPE_ST_unaccBlks } RAV_MEDIA_STRUCTURE() STDS_unaccBlks_s; -// Used to record the NAME and PZID of the NT object that we can not find in the BT. +// Used to record the NAME and PZID of the NT object that we can not find in the BT. // (or the object that is not a NAMED BEAST). This information can be used before/after a // rebuild to obtain the full path of items that may need to to restored from backup. // Note, that the list may include MANY files that do not need to be restored. E.G. @@ -397,7 +397,7 @@ typedef struct CommonBlockStats_s QUAD CBS_BadChecksum; // Number of blocks with incorrect checksums. QUAD CBS_BadRead; // Number of blocks that we where unable to read. QUAD CBS_BadMisc; // 'Validate' routine found some other issue with block. - QUAD CBS_InvalidBlock; // Total invalid blocks in object Was numBTBadNodes, numSTBadNodes, + QUAD CBS_InvalidBlock; // Total invalid blocks in object Was numBTBadNodes, numSTBadNodes, QUAD CBS_NextLeafExpected; // Expected value of the next 'leaf' QUAD CBS_NextLeafInvalid; // Total invalid next leaf in object @@ -551,9 +551,9 @@ typedef struct BTStats_s /* Beast Tree Stats */ NINT numDataStreamCount; // data streams, ea's etc. //l NINT numBeastObjectCount; // Objects //l NINT numSpecialObjectCount; // Special Objects now --> BTSS_cBS.CBS_LevelLeaf.LI_ObjectCount - NINT numBeastFileCount; // Beast Files // + NINT numBeastFileCount; // Beast Files // NINT numFileCount; // User Files // > Total Files (sum of the three) - NINT numDirCount; // User Dirs // + NINT numDirCount; // User Dirs // NINT numBeastTotallyOrphaned_OptValid; // BT ents with no parents for any name in NT -- Not tracked if ZPS_Option_CrossValidateBT is FALSE NINT numBeastOrphanedEnts_OptValid; // BT ents with no parent for each name in NT -- Not tracked if ZPS_Option_CrossValidateBT is FALSE NINT numBeastMissingParents_OptValid; // Total missing parents in NT -- Not tracked if ZPS_Option_CrossValidateBT is FALSE @@ -592,9 +592,9 @@ typedef struct BTStats_s /* Beast Tree Stats */ NINT BTnumNTBadFiles_OptValid; // -- Not tracked if ZPS_Option_CrossValidateBT is FALSE -//g NINT BTLeafSize[ZV_MAX_TREE_LEAF_BIT_BUCKETS+1]; // +//g NINT BTLeafSize[ZV_MAX_TREE_LEAF_BIT_BUCKETS+1]; // //g NINT BTBranchSize[ZV_MAX_TREE_BRANCH_BIT_BUCKETS+1]; // > Histogram stuff -//g NINT BTLevelEntries[ZV_MAX_TREE_LEVELS+1]; // +//g NINT BTLevelEntries[ZV_MAX_TREE_LEVELS+1]; // //g Zid_t DuplicateZids[20]; //g Zid_t BranchDuplicateZids[20]; @@ -663,12 +663,12 @@ typedef struct STStats_s /* Salvage Tree Stats */ //l NINT numSTLeafNodes; //l NINT numSTLeafEntries; // Leaf Ents Now CBS_LevelLeaf.LI_ObjectCount - + //l NINT numSTBranchNodes; //l NINT numSTBranchEntries; // Brch Ents -//l NINT STLeafSize[ZV_MAX_TREE_LEAF_BIT_BUCKETS+1]; // +//l NINT STLeafSize[ZV_MAX_TREE_LEAF_BIT_BUCKETS+1]; // //l NINT STBranchSize[ZV_MAX_TREE_BRANCH_BIT_BUCKETS+1]; // > Histogram stuff -//l NINT STLevelEntries[ZV_MAX_TREE_LEVELS+1]; // +//l NINT STLevelEntries[ZV_MAX_TREE_LEVELS+1]; // NINT STParentEntsNotInBT_OptValid; // Salvage tree Parents that are NOT in the Beast tree -- Not tracked if ZPS_Option_CrossValidateST is FALSE NINT STParentEntsNotInNT_OptValid; // Salvage tree Parents that are NOT in the Name tree -- Not tracked if ZPS_Option_CrossValidateST is FALSE @@ -736,9 +736,9 @@ typedef struct EFLStats_s /* EFL Tree Stats */ //l NINT numEFLLeafEntries; // Leaf Ents //l NINT numEFLBranchNodes; //l NINT numEFLBranchEntries; // Brch Ents -//l NINT EFLLeafSize[ZV_MAX_TREE_LEAF_BIT_BUCKETS+1]; // +//l NINT EFLLeafSize[ZV_MAX_TREE_LEAF_BIT_BUCKETS+1]; // //l NINT EFLBranchSize[ZV_MAX_TREE_BRANCH_BIT_BUCKETS+1]; // > Histogram stuff -//l NINT EFLLevelEntries[ZV_MAX_TREE_LEVELS+1]; // +//l NINT EFLLevelEntries[ZV_MAX_TREE_LEVELS+1]; // //g NINT EFLEntsNotInBT; // EFL tree entries that are NOT in the Beast tree Not tracked //g NINT EFLEntsNotModified; /* EFL entries whose beasts don't have archive bits set */ Not tracked @@ -765,9 +765,9 @@ typedef struct UBTStats_s /* UBT Stats */ //l NINT numUBTBadNodes; //l NINT numUBTBranchNodes; //l NINT numUBTBranchEntries; // Brch Ents -//l NINT UBTLeafSize[ZV_MAX_TREE_LEAF_BIT_BUCKETS+1]; // +//l NINT UBTLeafSize[ZV_MAX_TREE_LEAF_BIT_BUCKETS+1]; // //l NINT UBTBranchSize[ZV_MAX_TREE_BRANCH_BIT_BUCKETS+1]; // > Histogram stuff -//l NINT UBTLevelEntries[ZV_MAX_TREE_LEVELS+1]; // +//l NINT UBTLevelEntries[ZV_MAX_TREE_LEVELS+1]; // //g Blknum_t UBTNextNode; //g NINT UBTNextNodeErrors; @@ -793,9 +793,9 @@ typedef struct DBTStats_s /* DBT Stats */ //g NINT numDBTBadNodes; //l NINT numDBTBranchNodes; not used //l NINT numDBTBranchEntries; // Brch Ents not used -//l NINT DBTLeafSize[ZV_MAX_TREE_LEAF_BIT_BUCKETS+1]; // +//l NINT DBTLeafSize[ZV_MAX_TREE_LEAF_BIT_BUCKETS+1]; // //l NINT DBTBranchSize[ZV_MAX_TREE_BRANCH_BIT_BUCKETS+1]; // > Histogram stuff -//l NINT DBTLevelEntries[ZV_MAX_TREE_LEVELS+1]; // +//l NINT DBTLevelEntries[ZV_MAX_TREE_LEVELS+1]; // //z Blknum_t DBTNextNode; //g NINT DBTNextNodeErrors; @@ -1223,7 +1223,7 @@ typedef struct ZVP_VersionInformation_s // 1.0 - Original OES ship // 1.01 - Original OES ship (via ZVI_XMLVersionMinor because of bug) // 1.11 2005Mar14 - Added logKeyRemove, debugKeyRemove and detailKeyRemove XML tags. - WORD ZVI_XMLVersionMinor; + WORD ZVI_XMLVersionMinor; #define RAV_XML_MINOR_VERSION 11 // Minor version. Small backward compatible change made. @@ -1236,7 +1236,7 @@ typedef struct ZVP_VersionInformation_s Format of XML files used to transfer information between RAV kernel and user space. I have stuck the version numbers in the ZVP_VersionInformation_s to make it easy on the UI to get. The - XML version numbers are also in the XML files. The Tags used are and + XML version numbers are also in the XML files. The Tags used are and . This version applies to the following XML files. @@ -1306,10 +1306,10 @@ typedef struct ZRP_TODRecord_s // Was ZLSSRepairTempLogRecord_s #define RAV_TLF_UNFINISHED_DELETE 0x00000002 /* Prior to Aug 2005 was _PARENT_BAD and never set. */ #define RAV_TLF_REASON_CORRUPT 0x00000003 #define RAV_TLF_REASON_NEXTBLOCK_BAD 0x00000004 -#define RAV_TLF_REASON_COMPRESSION 0x00000005 +#define RAV_TLF_REASON_COMPRESSION 0x00000005 #define RAV_TLF_REASON_VISIBILITY 0x00000006 /* Normal cleanup of visibility items. UI generally should not display. */ -#define RAV_TLF_REASON_LOCATOR 0x00000007 -#define RAV_TLF_REASON_LOCATOR2 0x00000008 +#define RAV_TLF_REASON_LOCATOR 0x00000007 +#define RAV_TLF_REASON_LOCATOR2 0x00000008 #define RAV_TLF_REASON_NAMED_SELF 0x00000009 /* Named object points to self */ #define RAV_TLF_REASON_OVERFLOW_SELF 0x0000000a /* Overflow object points to self */ #define RAV_TLF_REASON_OVERFLOW_LOOP 0x0000000b /* Overflow object points back into list */ @@ -1329,3 +1329,4 @@ typedef struct ZRP_TODRecord_s // Was ZLSSRepairTempLogRecord_s } RAV_MEDIA_STRUCTURE() ZRP_TODRecord_s; #endif // #ifndef _REPAIRZVPUSER_H_ + diff --git a/include/nwnss/include/repairUser.h b/include/nwnss/include/repairUser.h index eeb5301..d172a1a 100644 --- a/include/nwnss/include/repairUser.h +++ b/include/nwnss/include/repairUser.h @@ -55,7 +55,7 @@ #define ZRP_DEBUG_LOG_IO_WRITES 0x00000004 #define ZRP_DEBUG_LOG_IO_READS 0x00000008 #define ZRP_DEBUG_LOG_IO (ZRP_DEBUG_LOG_IO_READS|ZRP_DEBUG_LOG_IO_WRITES|ZRP_DEBUG_LOG_IO_CACHE_HITS) -#define ZRP_DEBUG_LOG_GENERAL_INFO 0x00000010 // General Information +#define ZRP_DEBUG_LOG_GENERAL_INFO 0x00000010 // General Information #define ZRP_DEBUG_LOG_GENERAL_WARNING 0x00000020 #define ZRP_DEBUG_LOG_GENERAL_ERROR 0x00000040 #define ZRP_DEBUG_LOG_GENERAL (ZRP_DEBUG_LOG_GENERAL_INFO|ZRP_DEBUG_LOG_GENERAL_WARNING|ZRP_DEBUG_LOG_GENERAL_ERROR) @@ -66,9 +66,10 @@ typedef struct ZSR_LossLimits_s BOOL ZLL_PruneUnknownLosses; // Default should be FALSE. It is best to get user input as unknown files may be destroyed!!! //g QUAD ZLL_BlockLossMax; // Currently not used as Rebuild does not track. At prune decission time we // have not counted NT blocks (and other trees we rebuld) therefore we really - // do not know how many blocks we have lost. + // do not know how many blocks we have lost. QUAD ZLL_FileLossMax; // Maximum number of files to lose per VOLUME. If rebuild detects that more files // than this will be lost then rebuild ABORTS. } RAV_MEDIA_STRUCTURE() ZSR_LossLimits_s; #endif + diff --git a/include/nwnss/include/reserveResources.h b/include/nwnss/include/reserveResources.h index bdcaa84..14f450a 100644 --- a/include/nwnss/include/reserveResources.h +++ b/include/nwnss/include/reserveResources.h @@ -50,7 +50,7 @@ #define _RESERVERESOURCES_H_ #ifndef _LATCH_H_ -#include +#include "latch.h" #endif #ifdef __cplusplus @@ -83,11 +83,11 @@ extern Latch_s ReserveResource; /* Used to pre-alloc or reserve * cache buffers */ -#if 1 +#if 0 #define RESERVE_RSRC(_num) GRAB( &ReserveResource, (_num)) #define RELEASE_RSRC(_num) DROP( &ReserveResource, (_num)) #define FSM_RESERVE_RSRC(_num, _fsm, _action) \ - FSM_GRAB( &ReserveResource, (_num), (_fsm), (voidfunc_t)(_action)) + FSM_GRAB( &ReserveResource, (_num), (_fsm), (_action)) #else #define RESERVE_RSRC(_num) ((void) 0) #define RELEASE_RSRC(_num) ((void) 0) @@ -97,8 +97,8 @@ extern Latch_s ReserveResource; /* Used to pre-alloc or reserve #define INC_RSRC(_num) INC_COUNT( &ReserveResource, (_num)) #define INC_RSRC_CHECK(_num) INC_COUNT_CHECK( &ReserveResource, (_num)) #define DEC_RSRC(_num) DEC_COUNT( &ReserveResource, (_num)) -#define HAVE_RESOURCES(_n) (ReserveResource.count > (_n)) -#define NUM_RESOURCES() (ReserveResource.count) +#define HAVE_RESOURCES(_n) (ReserveResource.count > (_n)) +#define NUM_RESOURCES() (ReserveResource.count) #define NAME_RESERVE 16 /* Number of blocks we should reserve for naming * related APIs diff --git a/include/nwnss/include/risupprt.imp b/include/nwnss/include/risupprt.imp new file mode 100644 index 0000000..55bc194 --- /dev/null +++ b/include/nwnss/include/risupprt.imp @@ -0,0 +1,9 @@ + RegisterReplicationModule + DeregisterReplicationModule + RI_Get_Work_Volume_name + RI_Delete_Mounted_Volume + RI_Volume_Is_Ready + RI_Volume_has_Been_Deleted + RemoveReplicatedVolume + ReplicateVolume + RI_Create_And_Mount_Volume diff --git a/include/nwnss/include/sbi.h b/include/nwnss/include/sbi.h new file mode 100644 index 0000000..92b71da --- /dev/null +++ b/include/nwnss/include/sbi.h @@ -0,0 +1,134 @@ +/**************************************************************************** + | + | (C) Copyright 2001, 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Display ZLSS 3.00 metadata blocks in XML form. + / + / Warning - This file is used by NT Utilities like zedRemote, ZlogGet and + / etc. DO NOT ADD NSS specific code. The define NTLIB is only defined + / when source file is compiled with NT Utilities. + +-------------------------------------------------------------------------*/ +#ifndef _SBI_H_ +#define _SBI_H_ + +#ifndef _NWGREENRIVER_ +#define _NWGREENRIVER_ /* This define helps asyncio.h */ +#endif + +#include "omni.h" +#include "zParams.h" +#include "zError.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /*** + *** + *** Offical Exported API + *** + ***/ + +typedef struct ZED_SystemBlockInfo_s { + LONG selected; /* Should blocks with this magic number be dumped? */ + char *SSBI_name; + LONG magic; + QUAD SSBI_countGuid; /* Number of blocks found (that match 1st GUID) */ + QUAD SSBI_count; /* Number of blocks found */ + STATUS (*SSBI_displayBlock)( struct ZED_SystemBlockInfo_s *, BYTE *blockBuffer, struct DFI_CallerOptions_s *co, Blknum_t *nextBlockHint ); +} ZED_SystemBlockInfo_s; + +STATUS SSBI_displayBlock( + struct ZED_SystemBlockInfo_s *sbi, + BYTE *buffer, + struct SNP_PrintBuffer_s *pb, + Blknum_t currentBlock, + Blknum_t *nextBlockHint, + void *localAddress, + void *sourceAddress, + Zid_t zid ); + +ZED_SystemBlockInfo_s *SBI_SystemBlock( BYTE *buffer ); + +STATUS SBI_DisplayBlockZlss( + struct DFI_CallerOptions_s *co, + BYTE *buffer ); + + /*** + *** + *** Internal API + *** + ***/ + +LONG ZED_CheckpointCalculateChecksum( LONG *buffer, NINT numberOfLONGs ); +LONG ZED_SuperBlockHeaderCalculateChecksum( LONG *buffer, NINT numberOfLONGs ); + + +STATUS SBI_DisplayBlockDefault( ZED_SystemBlockInfo_s *sbi, BYTE *, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); + +STATUS SBI_DisplayBlockBTBranch( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockBTLeaf( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockCheckpoint( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockEFLBranch( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockEFLLeaf( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockEFLLog( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockFMAPBranch( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockFMAPLeaf( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockFMAPRoot( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockFTBranch( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockFTLeaf( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockMSAP( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockNameTree( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockPoolDataBlock( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockPoolLoggedDataBlock( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockPT( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockPurgeLog( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockSNAPAdmin( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockSNAPHeader( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockSNAPMap( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockSNAPLeaf( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockSuperBlockHeader( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockVolumeDataBlock( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); +STATUS SBI_DisplayBlockVolumeLoggedDataBlock( ZED_SystemBlockInfo_s *sbi, BYTE *block, struct DFI_CallerOptions_s *, Blknum_t *nextBlockHint ); + +void SBI_DisplayBlockHex( struct SNP_PrintBuffer_s *pb, BYTE *block ); +void ZED_HexDump( void *userArea, int length, int size ); + + +#ifdef __cplusplus +} +#endif + + +#endif // #ifndef _SBI_H_ + diff --git a/include/nwnss/include/sbsMFL.h b/include/nwnss/include/sbsMFL.h deleted file mode 100644 index 2460a51..0000000 --- a/include/nwnss/include/sbsMFL.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** - | - | (C) Copyright 1995-2000 Novell, Inc. - | All Rights Reserved. - | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. - | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. - | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. - | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com - | - |*************************************************************************** - | - | NetWare Advance File Services (NSS) Initialization module - | - |--------------------------------------------------------------------------- - | - | $Author: taysom $ - | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - | - | $RCSfile$ - | $Revision: 465 $ - | - |--------------------------------------------------------------------------- - | This module is used to: - | Common Layer MFL interface - +-------------------------------------------------------------------------*/ -#ifndef _SBS_MFL_H_ -#define _SBS_MFL_H_ - -typedef struct ModifiedFileDesc_s -{ - Zid_t fileZid; - WORD size; /* Size of this descriptor (including pathName size */ - WORD pathNameBytes; /* path name length in bytes */ - BYTE pathName[1]; -} ModifiedFileDesc_s; - -typedef struct MFLCursor_s -{ - Zid_t lastZidReturned; -} MFLCursor_s; - -void SBS_markFileModified( - struct File_s *file, - NINT archiveBitsToSet, - struct Xaction_s *xaction); -void SBS_markFileModifiedAsync(struct File_s *file); -void SBS_markFileUnmodified(struct File_s *file); -void SBS_markFileUnmodifiedAsync(struct File_s *file); - -#define MAX_MFL_ENTRIES_PER_SCOOP 50 - -#define SBS_MFL_ENABLED(_volume) \ - (((_volume)->VOLenabledAttributes & zATTR_MFL) != 0) - -STATUS -SBS_enumerateMFL( - GeneralMsg_s *genMsg, - struct Volume_s *volume, /* Returns entries with epoch < volume's epoch */ - NINT nameSpaceID, /* use this name space for returning path names */ - NINT pathFormat, /* Character encoding to use for path names */ - BOOL resetCursor, /* Reset cursor to point to start of MFL - * (also indicates start of enumeration) */ - MFLCursor_s *cursor, /* inout */ - NINT numFilesRequested, - NINT bufSize, /* size of dataBuf in bytes */ - BYTE *dataBuf, /* out */ - NINT *dataSizeReturned, /* out size of data returned in bytes */ - NINT *numFilesReturned, /* out # files returned */ - BOOL *isMFLincomplete); /* out set if ptr non-zero */ - -STATUS SBS_volumeMFLControlReadFunc( - NINT parmLen, - utf8_t *parm, - VirtInfo_s *virtInfo); - -STATUS SBS_volumeMFLControlWriteFunc( - NINT parmLen, - utf8_t *parm, - NINT dataLen, - BYTE *data, - NINT offset, - VirtInfo_s *virtInfo); - -#endif /* _SBS_MFL_H_ */ diff --git a/include/nwnss/include/schedule.h b/include/nwnss/include/schedule.h index 7a7656d..a96750e 100644 --- a/include/nwnss/include/schedule.h +++ b/include/nwnss/include/schedule.h @@ -43,129 +43,36 @@ #ifndef _SCHEDULE_H_ #define _SCHEDULE_H_ +#if zLINUX +#include "linuxmpk.h" +#endif + #ifndef _ZOMNI_H_ -# include +# include #endif -#ifdef NSS_USERSPACE -#ifndef _PSSMPK_H_ -# include -#endif - -/* nssOSAPIs.h may have been included first and defines these as Linux-kernel - * macros. The userspace scheduler port provides real functions instead. */ -# undef ZOS_Sleep -# undef ZOS_WakeUp -# undef ZOS_YieldThread -# undef ZOS_ScheduleWorkToDo -# undef ZOS_ScheduleFastWorkToDo -# undef ZOS_CancelWorkToDo -#ifdef __cplusplus -extern "C" { -#endif - -/* Linux userspace port: keep the NSS delay/scheduler API surface available - * without pulling in the NetWare/kernel scheduler runtime. The broader - * scheduler/FSM runtime is imported bottom-up when real users need it. */ -typedef ADDR THREAD; - -extern void LB_delay( - NINT millisec); - -extern THREAD kCurrentThread(void); -#define ThreadId() (ADDR)kCurrentThread() - -extern void ZOS_Sleep(void); -extern void ZOS_WakeUp(THREAD thread); -extern void ZOS_YieldThread(void); -extern LONG GetSuperHighResolutionTimer(void); - -/* Linux userspace port: expose the NSS WorkToDo record layout so imported - * callers can prepare work items without pulling in the NetWare/kernel - * scheduler runtime. */ -struct ResourceTagStructure; -struct WorkToDoStructure; - -typedef struct zWork_s -{ - LONG osReserved; - voidfunc_t ProcedureToCall; - struct ResourceTagStructure *WorkResourceTag; - LONG reserved[2]; -} zWork_s; - -typedef struct zWorkProc_s -{ - struct zWork_s zwork; - void *info; -} zWorkProc_s; - -typedef struct zWorkProc2_s -{ - struct zWork_s zwork; - void *info; - void *info2; -} zWorkProc2_s; - -extern void fillInWork( - void *process, - voidfunc_t procedureToCall, - void *userParameter); - -extern STATUS ZOS_ScheduleWorkToDo(struct WorkToDoStructure *work); -extern STATUS ZOS_ScheduleFastWorkToDo(struct WorkToDoStructure *work, int priority); -extern STATUS ZOS_CancelWorkToDo(struct WorkToDoStructure *work); - -#define ScheduleWork(_work) \ - ZOS_ScheduleWorkToDo((struct WorkToDoStructure *)(_work)) -#define ScheduleFastWork(_work) \ - ZOS_ScheduleFastWorkToDo((struct WorkToDoStructure *)(_work), 1) -#define CancelWork(_work) \ - ZOS_CancelWorkToDo((struct WorkToDoStructure *)(_work)) - -#ifndef PERIODIC_YIELD_COUNT -#define PERIODIC_YIELD_COUNT 50 -#endif -#ifndef PERIODIC_YIELD -#define PERIODIC_YIELD() Yield() -#endif -#ifndef CHECK_INTERRUPTS -#define CHECK_INTERRUPTS() ((void)0) -#endif - -#define Wait() ZOS_Sleep() -#define Continue(pid) ZOS_WakeUp((THREAD)(pid)) -#define Yield() ZOS_YieldThread() -#define WORK_PROCESS_INIT() ((void)0) - -#ifdef __cplusplus -} -#endif - -#else - #ifndef _PSSDEBUG_H_ -# include +# include #endif #ifndef _INST_H_ -# include +# include #endif #ifndef _PSSMPK_H_ -# include +# include #endif #ifndef _NSSOSAPIS_H_ -# include +# include #endif #ifndef _INLINES_H_ -# include +# include #endif #ifndef _QUE_H_ -#include +#include #endif #ifndef _OSMPKHDRS_H_ @@ -257,14 +164,14 @@ extern STATUS DestroyThread( LONG threadID); /* MP APIs*/ -extern STATUS kDestroyThread(THREAD ThreadHandle); +extern ERROR kDestroyThread(THREAD ThreadHandle); -extern THREAD kCurrentThread(void); -extern STATUS kDelayThread(unsigned int); +extern THREAD kCurrentThread(void); +extern ERROR kDelayThread(unsigned int); #define ThreadId() (ADDR)kCurrentThread() - -extern STATUS kWakeUp(THREAD); + +extern ERROR kWakeUp(THREAD); extern void kSleep(); extern void kYieldThread(); @@ -312,11 +219,11 @@ extern void CYieldUntilIdle(void); { \ DEBUG_PRINTF(TYIELDS,DBG_BOTH_NOINDENT, \ (LRED, "Yielding Thread(%08x):%s\n", ThreadId(), WHERE)); \ - ZOS_YieldThread(); \ + ZOS_YieldThread(); \ DEBUG_PRINTF(TYIELDS, DBG_BOTH_NOINDENT, \ (LRED, "Returning from YIELD(%08x):%s\n", ThreadId(), WHERE)); \ } - + #ifdef __linux__ # define EnableInts() sti() #else @@ -426,30 +333,30 @@ typedef struct zWorkProc2_s * Following are the changes to the library schedule routines which * has been made to be compatible with the MPK APIS which are SMP * aware. - * - * These APIS are to be added to the .imp file and put in the + * + * These APIS are to be added to the .imp file and put in the * Modules.bld file - * + * * The header files MPKAPIS.h, MPKLIB.h, MPKtypes.h, MPKOSLIB.h * are to be included in the include search path in our environment - * + * **************************************************************************/ + + - - - extern STATUS kScheduleWorkToDo(struct WorkToDoStructure *); - extern STATUS kScheduleFastWorkTo(struct WorkToDoStructure *); - extern STATUS kCancelWorkToDo(struct WorkToDoStructure *); + extern ERROR kScheduleWorkToDo(struct WorkToDoStructure *); + extern ERROR kScheduleFastWorkTo(struct WorkToDoStructure *); + extern ERROR kCancelWorkToDo(struct WorkToDoStructure *); #define ScheduleWork(_work) \ ZOS_ScheduleWorkToDo((struct WorkToDoStructure *)_work) #define ScheduleFastWork(_work) \ - ZOS_ScheduleFastWorkToDo((struct WorkToDoStructure *)_work,1) + ZOS_ScheduleFastWorkToDo((struct WorkToDoStructure *)_work,1) #define CancelWork(_work) \ - ZOS_CancelWorkToDo((struct WorkToDoStructure *)_work) + ZOS_CancelWorkToDo((struct WorkToDoStructure *)_work) /* When you use the CHECK macros uncomment the SIGNAL macros from the @@ -492,6 +399,4 @@ typedef struct zWorkProc2_s } #endif -#endif /* NSS_USERSPACE */ - #endif /* _SCHEDULE_H_ */ diff --git a/include/nwnss/include/sdBasic.h b/include/nwnss/include/sdBasic.h new file mode 100644 index 0000000..ea3118d --- /dev/null +++ b/include/nwnss/include/sdBasic.h @@ -0,0 +1,242 @@ +/**************************************************************************** + | + | (C) Copyright 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | sdBasic - Structure Display Basic. + / Displays Basic data types. + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-01-21 04:09:53 +0530 (Sat, 21 Jan 2006) $ + | + | $RCSfile$ + | $Revision: 1315 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Display NSS 3.00 memory structures. + / + / Warning - This file is used by NT Utilities like zedRemote, ZlogGet and + / etc. DO NOT ADD NSS specific code. The define NTLIB is only defined + / when source file is compiled with NT Utilities. + +-------------------------------------------------------------------------*/ + +#ifndef _SDBASIC_H_ +#define _SDBASIC_H_ + +#ifndef _NWGREENRIVER_ +#define _NWGREENRIVER_ /* This define helps asyncio.h */ +#endif + +//#include + +#include "zParams.h" +#include "zError.h" +//#include "zlog.h" +//#include "zfs.h" +//#include "zasAuthModel.h" + +//#include "eventSys.h" +//#include "zEvent.h" +//#include "volume.h" +//#include "comnPublics.h" +//#include "zfsSuperBlk.h" +//#define NAMETREE_MAGIC 0x48726944 /* Can't include nametree.h because dup structures */ +//#ifndef SAI_NT +//#include "beastTree.h" +//#endif +//#include "purgeTree_new.h" +//#include "purgeLog.h" +//#include "zlog.h" +//#include "mflBTree.h" +//#include "zfsXTree.h" +//#include "zlssLogicalVolume.h" +#include "guid.h" + +#ifdef DFI_INTERNAL +#include "comnCompress.h" +#include "nameSpace.h" +#include "macNSpace.h" +#include "unixNSpace.h" +#include "hardLinkBeast.h" +#endif + +#include "snp.h" +#include "dfi.h" + + + +typedef struct SDM_Table_s { + char *ST_Name; // Name of structure or union to display + unsigned int ST_SizeOf; + DFI_RoutineStructure_t ST_Routine; // Routine that can display structure/union + DFI_DataFormatInformation_s *ST_DFIList; /* Used if ST_Routine is SDM_Structure */ +} SDM_Table_s; + +SIZEOF SDM_Structure( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +STATUS SDM_Display( +#ifndef NTLIB + struct ScreenStruct *screen, +#endif + SDM_Table_s *table, + DFI_CallerOptions_s *co, + char *objectName, + NINT arrayElements, + BYTE *buffer, + unsigned int bufferSize ); + +STATUS SDM_DisplayAll( + DFI_CallerOptions_s *co, + char *objectName, + NINT arrayElements, + BYTE *buffer, + unsigned int bufferSize ); + +#ifdef NTLIB +STATUS SDM_DisplayHelpAll( + DFI_CallerOptions_s *co ); + +STATUS SDM_DisplayHelp( + char *tableName, + SDM_Table_s *table, + DFI_CallerOptions_s *co ); +#else +STATUS SDM_DisplayHelp( + struct ScreenStruct *screen, + char *tableName, + SDM_Table_s *table, + DFI_CallerOptions_s *co ); +#endif + +SIZEOF SDM_NotUsed_s( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + + + + + + + + + +int ZSD_Display_Type_BYTE( + DFI_CallerOptions_s *co, + char *tag, + BYTE *data ); + +int ZSD_Display_Type_WORD( + DFI_CallerOptions_s *co, + char *tag, + WORD *aWord ); + +int ZSD_Display_Type_SWORD( + DFI_CallerOptions_s *co, + char *tag, + SWORD *aWord ); + +int ZSD_Display_Type_LONG( + DFI_CallerOptions_s *co, + char *tag, + LONG *data ); + +int ZSD_Display_Type_SLONG( + DFI_CallerOptions_s *co, + char *tag, + SLONG *data ); + +int ZSD_Display_Type_QUAD( + DFI_CallerOptions_s *co, + char *tag, + QUAD *data ); + +int ZSD_Display_Type_QUAD_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, /* Number of array elements */ + QUAD *aQuad ); + +int ZSD_Display_Type_Zid_t( + DFI_CallerOptions_s *co, + char *tag, + Zid_t *zid ); + +int ZSD_Display_Type_Time_t( + DFI_CallerOptions_s *co, + char *tag, + Time_t *time ); + +int ZSD_Display_Type_Time_t_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, /* Number of array elements */ + Time_t *time ); + +int ZSD_Display_Struct_Lsn_t( + DFI_CallerOptions_s *co, + char *tag, + Lsn_t *lsn ); + +int ZSD_Display_Struct_GUID_t( + DFI_CallerOptions_s *co, + char *tag, + GUID_t *guid ); + +int ZSD_Display_Struct_UserID_t( + DFI_CallerOptions_s *co, + char *tag, + UserID_t *userID ); + +int ZSD_Display_Struct_VolumeID_t( + DFI_CallerOptions_s *co, + char *tag, + VolumeID_t *volumeID ); + +int ZSD_Display_Type_Blkcnt_t( + struct DFI_CallerOptions_s *co, + char *tag, + Blkcnt_t *block ); + +int ZSD_Display_Type_Blknum_t( + struct DFI_CallerOptions_s *co, + char *tag, + Blknum_t *block ); + +int ZSD_Display_Type_Blknum_t_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + int index, + Blknum_t *block ); + + + +#endif // #ifndef _SDBASIC_H_ + diff --git a/include/nwnss/include/sdNSS.h b/include/nwnss/include/sdNSS.h new file mode 100644 index 0000000..ed893db --- /dev/null +++ b/include/nwnss/include/sdNSS.h @@ -0,0 +1,283 @@ +/**************************************************************************** + | + | (C) Copyright 2002, 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | sdBasic - Structure Display Basic. + / Displays Basic data types. + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2006-12-22 04:32:59 +0530 (Fri, 22 Dec 2006) $ + | + | $RCSfile$ + | $Revision: 1796 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Display NSS 3.00 memory structures. + / + / Warning - This file is used by NT Utilities like zedRemote, ZlogGet and + / etc. DO NOT ADD NSS specific code. The define NTLIB is only defined + / when source file is compiled with NT Utilities. + +-------------------------------------------------------------------------*/ +#ifndef _SDNSS_H_ +#define _SDNSS_H_ + +#ifndef _NWGREENRIVER_ +#define _NWGREENRIVER_ /* This define helps asyncio.h */ +#endif + + +#include "zParams.h" +#include "zError.h" +#include "zasAuthModel.h" +#include "unixAuthModel.h" + +#include "eventSys.h" +#include "zEvent.h" +#include "volume.h" +#include "comnPublics.h" +#include "guid.h" + +#ifdef DFI_INTERNAL +#include "comnCompress.h" +#include "nameSpace.h" +#include "macNSpace.h" +#include "unixNSpace.h" +#endif + +#include "snp.h" +#include "dfi.h" +#include "sdBasic.h" + + +extern SDM_Table_s SDM_TableNSS[]; + + +extern DFI_DataFormatInformation_s DFI_ACLEntry_s[]; +extern DFI_DataFormatInformation_s DFI_AdminVolFile_s[]; +extern DFI_DataFormatInformation_s DFI_Agent_s[]; +extern DFI_DataFormatInformation_s DFI_Asyncio_s[]; +extern DFI_DataFormatInformation_s DFI_AuthBeast_s[]; +extern DFI_DataFormatInformation_s DFI_AuthCtrl_s[]; +extern DFI_DataFormatInformation_s DFI_BioReq_s[]; +extern DFI_DataFormatInformation_s DFI_Buffer_s[]; +extern DFI_DataFormatInformation_s DFI_CIRhead_t[]; +extern DFI_DataFormatInformation_s DFI_CIRlink_s[]; +extern DFI_DataFormatInformation_s DFI_CIRlink_t[]; +extern DFI_DataFormatInformation_s DFI_CMVolumeState_s[]; +extern DFI_DataFormatInformation_s DFI_CacheControl_s[]; +extern DFI_DataFormatInformation_s DFI_Config_s[]; +extern DFI_DataFormatInformation_s DFI_ConnectionIDP_s[]; +extern DFI_DataFormatInformation_s DFI_ContextHandleIDP_s[]; +extern DFI_DataFormatInformation_s DFI_ContextHandleCtrl_s[]; +extern DFI_DataFormatInformation_s DFI_ContextHandleInfo_s[]; +extern DFI_DataFormatInformation_s DFI_DQhead_t[]; +extern DFI_DataFormatInformation_s DFI_DQlink_t[]; +extern DFI_DataFormatInformation_s DFI_RBP_Node_s[]; +extern DFI_DataFormatInformation_s DFI_DeletedPersistentParentEntry_s[]; +extern DFI_DataFormatInformation_s DFI_FileHandleIDP_s[]; +extern DFI_DataFormatInformation_s DFI_FileHandle_s[]; +extern DFI_DataFormatInformation_s DFI_File_s[]; +extern DFI_DataFormatInformation_s DFI_FsmLite_s[]; +extern DFI_DataFormatInformation_s DFI_Fsm_s[]; +extern DFI_DataFormatInformation_s DFI_GeneralMsg_s[]; +extern DFI_DataFormatInformation_s DFI_Histogram_s[]; +extern DFI_DataFormatInformation_s DFI_Latch_s[]; +extern DFI_DataFormatInformation_s DFI_LoggedPersistentPool_s[]; +extern DFI_DataFormatInformation_s DFI_LoggedPersistentVolume_s[]; +extern DFI_DataFormatInformation_s DFI_MyCache_s[]; +extern DFI_DataFormatInformation_s DFI_NSSConnection_s[]; +extern DFI_DataFormatInformation_s DFI_NamedBeast_s[]; +extern DFI_DataFormatInformation_s DFI_NamingMsg_s[]; +extern DFI_DataFormatInformation_s DFI_NotUsed_s[]; +extern DFI_DataFormatInformation_s DFI_ObjCache_s[]; +extern DFI_DataFormatInformation_s DFI_OneShot_s[]; +extern DFI_DataFormatInformation_s DFI_OpLockControl_s[]; +extern DFI_DataFormatInformation_s DFI_OpLock_s[]; +extern DFI_DataFormatInformation_s DFI_PageBuffer_s[]; +extern DFI_DataFormatInformation_s DFI_ParentEntry_s[]; +extern DFI_DataFormatInformation_s DFI_PersistentFile_s[]; +extern DFI_DataFormatInformation_s DFI_PersistentNamed_s[]; +extern DFI_DataFormatInformation_s DFI_PersistentParentEntry_s[]; +extern DFI_DataFormatInformation_s DFI_PersistentPool_s[]; +extern DFI_DataFormatInformation_s DFI_PersistentVolume_s[]; +extern DFI_DataFormatInformation_s DFI_PoolOwnership_s[]; +extern DFI_DataFormatInformation_s DFI_Pool_s[]; +extern DFI_DataFormatInformation_s DFI_PubBuffer_s[]; +extern DFI_DataFormatInformation_s DFI_RootBeast_s[]; +extern DFI_DataFormatInformation_s DFI_SAgentHandleCtrl_s[]; +extern DFI_DataFormatInformation_s DFI_SEThead_t[]; +extern DFI_DataFormatInformation_s DFI_SETlink_t[]; +extern DFI_DataFormatInformation_s DFI_SQhead_t[]; +extern DFI_DataFormatInformation_s DFI_SQlink_s[]; +extern DFI_DataFormatInformation_s DFI_SQlink_t[]; +extern DFI_DataFormatInformation_s DFI_STKlink_s[]; +extern DFI_DataFormatInformation_s DFI_STKlink_t[]; +extern DFI_DataFormatInformation_s DFI_STKtop_t[]; +extern DFI_DataFormatInformation_s DFI_ScanComponentMsg_s[]; +extern DFI_DataFormatInformation_s DFI_SearchMapCtrl_s[]; +extern DFI_DataFormatInformation_s DFI_UXASAuthorizeInfo_s[]; +extern DFI_DataFormatInformation_s DFI_UXASPersistentAuthInfo_s[]; +extern DFI_DataFormatInformation_s DFI_TypeSpecificPersistentParentEntry_s[]; +extern DFI_DataFormatInformation_s DFI_UserXactionLogMetaData_s[]; +extern DFI_DataFormatInformation_s DFI_VisEntry_s[]; +extern DFI_DataFormatInformation_s DFI_Volume_s[]; +extern DFI_DataFormatInformation_s DFI_Xaction_s[]; +extern DFI_DataFormatInformation_s DFI_ZASAuthorizeInfo_s[]; +extern DFI_DataFormatInformation_s DFI_ZASPersistentAuthInfo_s[]; +extern DFI_DataFormatInformation_s DFI_mDataArea_s[]; +extern DFI_DataFormatInformation_s DFI_mDoor_s[]; +extern DFI_DataFormatInformation_s DFI_mManager_s[]; +extern DFI_DataFormatInformation_s DFI_mObject_s[]; +extern DFI_DataFormatInformation_s DFI_mSystemMsg_s[]; +extern DFI_DataFormatInformation_s DFI_mTypeHeader_s[]; +extern DFI_DataFormatInformation_s DFI_mType_s[]; +extern DFI_DataFormatInformation_s DFI_zInfo_s[]; +extern DFI_DataFormatInformation_s DFI_zMacInfo_s[]; +extern DFI_DataFormatInformation_s DFI_zNSSMsg_s[]; +extern DFI_DataFormatInformation_s DFI_zPoolInfo_s[]; +extern DFI_DataFormatInformation_s DFI_zUnixInfo_s[]; +extern DFI_DataFormatInformation_s DFI_zVolumeInfo_s[]; +extern DFI_DataFormatInformation_s DFI_zWorkProc_s[]; +extern DFI_DataFormatInformation_s DFI_zWork_s[]; + + +SIZEOF SDM_CIRlink_t( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_CIRlink_s( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_CIRhead_t( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_CMVolumeState_s( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_DeletedPersistentParentEntry_s( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + + +SIZEOF SDM_DQhead_t( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_DQlink_t( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_File_s( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_SEThead_t( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_SETlink_t( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_STKlink_s( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_STKlink_t( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_STKtop_t( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_SQhead_t( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_SQlink_t( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SIZEOF SDM_SQlink_s( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); + +SDM_Table_s *SDM_TableLookup( + char *objectName, + SDM_Table_s *table ); + + +#endif // #ifndef _SDNSS_H_ diff --git a/include/nwnss/include/searchMap.h b/include/nwnss/include/searchMap.h index e5ecb1a..eb8c18e 100644 --- a/include/nwnss/include/searchMap.h +++ b/include/nwnss/include/searchMap.h @@ -33,7 +33,7 @@ |--------------------------------------------------------------------------- | This module is used to: | This defines the SearchMap structures used for managing wildcard - | searches in PSS. + | searches in PSS. | | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! | @@ -44,8 +44,8 @@ #ifndef _SEARCHMAP_H_ #define _SEARCHMAP_H_ -#include -#include +#include +#include #ifdef __cplusplus extern "C" { @@ -93,12 +93,12 @@ typedef struct XLSSSearchCtrl_s { Key_t XSC_masterVolKey; Zid_t XSC_zid; /* ZID of the last entry returned */ /* This field is used during reconnect. - * We use the zid of the last entry + * We use the zid of the last entry * returned to reestablish a search map * when we have a new master. */ } XLSSSearchCtrl_s; - + typedef void (*SearchMapCleanup_t)(struct SearchMap_s *smap); @@ -157,7 +157,7 @@ typedef struct SearchMap_s { BYTE wdata[24]; /* this is guaranteed to be at least this big*/ DefaultSearchCtrl_s dfltNext; /* fields for Default wildcard control*/ - ZFSNameSearchCtrl_s zfsNext; /* Fields for ZFS naming system + ZFSNameSearchCtrl_s zfsNext; /* Fields for ZFS naming system * Wildcard control */ XLSSSearchCtrl_s xlssNext; /* Fields for XLSS */ NINT avNext; /* fields for ADMIN VOL wildcard control*/ diff --git a/include/nwnss/include/slab.h b/include/nwnss/include/slab.h index 15f1489..de85f5e 100644 --- a/include/nwnss/include/slab.h +++ b/include/nwnss/include/slab.h @@ -41,23 +41,23 @@ #define _NSS_SLAB_H_ #ifndef _LATCH_H_ -#include +#include #endif #ifndef _OMNI_H_ -#include +#include #endif #ifndef _QUE_H_ -#include +#include #endif #ifndef _HISTOGRAM_H_ -#include +#include #endif #ifndef _XCACHE_H_ -#include +#include #endif #define SMALL_OBJECT (PAGE_SIZE / 8) diff --git a/include/nwnss/include/snp.h b/include/nwnss/include/snp.h new file mode 100644 index 0000000..fcd58b9 --- /dev/null +++ b/include/nwnss/include/snp.h @@ -0,0 +1,132 @@ +/**************************************************************************** + | + | (C) Copyright 2001, 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2006-12-20 02:34:42 +0530 (Wed, 20 Dec 2006) $ + | + | $RCSfile$ + | $Revision: 1780 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Define printf that does a automatic buffer grow. + / + / Warning - This file is used by NT Utilities like zedRemote, ZlogGet and + / etc. DO NOT ADD NSS specific code. The define NTLIB is only defined + / when source file is compiled with NT Utilities. + +-------------------------------------------------------------------------*/ + + +#ifndef _SNP_H_ +#define _SNP_H_ + +#ifndef _ZWHERE_H_ +#include +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +//#define SNP_UNIT_TEST +//#define SNP_TRACE printf("%s\n",WHERE) +#define SNP_TRACE + +#define LB_VSN_PRINTF_LIMIT 64*1024 + + + +extern int SNP_DisplayOnScreen; /* Caller of Library can set so items get placed on screen also */ + +/* SNP_PrintBuffer_s - + * Holds items needed to hold a concatanation of 'printf' items. Modeled + * after NSS XML virtual file code. + * + * + */ +typedef struct SNP_PrintBuffer_s +{ + long SPB_Signature; +#define SNP_SPB_SIGNATURE 0x4548495a +#define SNP_SPB_SIGNATURE_DESTRUCT 0x5558594a + char *SPB_Data; /* Data buffer that holds print string. */ + size_t SPB_Size; /* Size of data buffer that holds string */ + size_t SPB_StringLength; /* String length(excludes the NULL) of string in buffer */ + char *SPB_ConstructSetter; + int SPB_LastEncodeError; + char *SPB_LastEncodeErrorSetter; + int SPB_LastSizeError; /* How much more space was needed on last size error */ + char *SPB_LastSizeErrorSetter; + int (*SPB_Alloc)( struct SNP_PrintBuffer_s *, size_t ); + /* If NULL no Alloc routine. SPB_Free must also be NULL. */ + int (*SPB_Free)( struct SNP_PrintBuffer_s * ); + /* If NULL no Free routine. SPB_Alloc must also be NULL. */ + void *SPB_CallerPointer; /* Can be used by 'caller' to store caller specific information. */ +} SNP_PrintBuffer_s; + + + +SNP_PrintBuffer_s *SNP_Construct1( + char *where, + SNP_PrintBuffer_s *pb, + char *data, + size_t size, + void *callerPointer ); + +SNP_PrintBuffer_s *SNP_Construct2( + char *where, + SNP_PrintBuffer_s *pb, + int (*allocRoutine)( struct SNP_PrintBuffer_s *, size_t ), + int (*freeRoutine)( struct SNP_PrintBuffer_s * ), + size_t size, + void *callerPointer ); + +void SNP_Destruct( + char *where, + SNP_PrintBuffer_s *pb ); + +int SNP_DataDelete( + char *where, + SNP_PrintBuffer_s *pb ); + +int SNP_snprintf( + char *where, + SNP_PrintBuffer_s *pb, + const char *format, + ...); + +void SNP_Display( + char *where, + SNP_PrintBuffer_s *pb); + +#ifdef __cplusplus +} +#endif + + +#endif /* #ifndef _SNP_H_ */ diff --git a/include/nwnss/include/switchboard.h b/include/nwnss/include/switchboard.h index 197e952..5dc6b1b 100644 --- a/include/nwnss/include/switchboard.h +++ b/include/nwnss/include/switchboard.h @@ -39,7 +39,7 @@ #define _SWITCHBOARD_H_ #ifndef _NSS_MSG_H_ -#include +#include #endif #define MAX_SWBRD_NAME 256 @@ -86,6 +86,6 @@ extern STATUS SWBD_DemandKey(SWBDClient_s *client, unicode_t *name, Key_t key); extern STATUS SWBD_SupplyLocal(SWBDClient_s *client, unicode_t *name, Key_t key); extern STATUS SWBD_SupplyRemote(SWBDClient_s *client, unicode_t *name, Key_t key); extern STATUS SWBD_SupplyAll(Key_t key); -extern void SWBD_DumpSwitchboard(char *buf, int bufLen); +extern void SWBD_DumpSwitchboard (); #endif diff --git a/include/nwnss/include/tcpip.imp b/include/nwnss/include/tcpip.imp new file mode 100644 index 0000000..e132d3b --- /dev/null +++ b/include/nwnss/include/tcpip.imp @@ -0,0 +1,82 @@ +TCPAbort +TCPBind +TCPClose +TCPConnect +TCPDeregister +TCPGetOption +TCPLastSendData +TCPListen +TCPMinAdvertisedWindow +TCPNewSendData +TCPNewWindow +TCPRegister +TCPRegisterWithParameters +TCPSetOption +TCPSetKeepAlive +TCPSetRxLimit +MapNetToBSDSock +UDPAllocRcvECB +UDPAllocSmallECB +UDPChksumECB +UDPIPXChksumECB +UDPDeregister +UDPFreeRcvECB +UDPFreeSmallECB +UDPReturnPacket +UDPRegister +UDPSend +UDPIPXSend +UDPSendToIF +IPDeregister +IPFindRoute +IPLocalAddrCheck +IPRegister +IPSend +IPSendToIF +IPToProcess +IPJoinGroup +IPLeaveGroup +IPJoinMulticast +IPLeaveMulticast +IPAllocRouteBlock +IPDeregGateway +IPFreeRouteBlock +IPRegGateway +ipRouteInfo +IP_Gateway_Handler +ARPMakeTempEntry +ARPMakeTempEntryWithIF +ICMPRedirectHandler +IPAddDefaultRoute +IPDehashRouteEntry +IPFindIF +IPFindBestIF +IPPrimaryIF +IPInboundIF +IPStaticRouteIF +IPFindOrCreateRoute +IPFindOrCreateWithMask +IPIdentifyIF +IPExtendedIFInfo +IPGetIFInfo +IPGetLocalAddr +IPGetRouteInfo +IPInvalidateRoute +IPLookupRoute +IPScanForRoute +IP_Interface_df +IP_Random +IPParseAddr +IPPrintAddr +IPntoa +IPntoaX +IPPrintMsg +icmpMIB +ipMaskArray +ipMIB +tcpMIB +tcp_pcb_list +tcp_trace_on +udpInfo +udpMIB +udpExMIB diff --git a/include/nwnss/include/threads.imp b/include/nwnss/include/threads.imp new file mode 100644 index 0000000..d3387be --- /dev/null +++ b/include/nwnss/include/threads.imp @@ -0,0 +1,624 @@ + Alloc + AllocateResourceTag + BitClear + BitSet + BitTest + BitTestAndClear + BitTestAndSet + CancelNoSleepAESProcessEvent + CancelSleepAESProcessEvent + DisableAndRetFlags + EnterDebugger + Free + GetHighResolutionTimer + GetLoaderType + GetNumberOfVolumes + GetSetableParameterValue + GetSuperHighResolutionTimer + LoginUser + MM_Abort_Function + MM_AddMirrorObjectToMirrorGroup + MM_Check_For_Pending_Aborts + MM_Create_Media_Object + MM_CreateHotFix + MM_CreateMirror + MM_CreatePartition + MM_Delete_Media_Object + MM_DeleteHotFix + MM_DeleteMirror + MM_DeletePartition + MM_DelPartitionFromMirrorGroup + MM_Find_Object_Type + MM_ForceMirrorGroupInSync + MM_InitializePartitionTable + MM_Object_Blocking_IO + MM_Object_IO + MM_Register_Application + MM_Register_Identification_Routines + MM_Register_Notify_Routine + MM_Release_Object + MM_Release_Unload_Semaphore + MM_RemirrorGroup + MM_Rename_Object + MM_Reserve_Object + MM_Return_Object_Attribute + MM_Return_Object_Generic_Info + MM_Return_Object_Mapping_Info + MM_Return_Object_Specific_Info + MM_Return_Object_Table_Size + MM_Return_Objects_Attributes + MM_ReturnMirrorInfo + MM_ReturnPartitionTableInfo + MM_Set_Object_Attribute + MM_Set_Unload_Semaphore + MM_Special_Object_Blocking_IO + MM_Unregister_Application + MM_Unregister_Identification_Routines + MM_Unregister_Notify_Routine + RegisterConsoleCommand + RingTheBell + ScanBits + ScanClearedBits + ScanSetableParameters + ScheduleNoSleepAESProcessEvent + ScheduleSleepAESProcessEvent + SetFlags + SetHardwareInterrupt + SetSetableParameterValue + UnRegisterConsoleCommand + atomic_inc + atomic_dec + atomic_add + atomic_sub + atomic_bts + atomic_btr + atomic_xchg + ASCIIZToLenStr + ASCIIZToMaxLenStr + AllocShMemCtrlStruct + AllocateCLIBHandle + AllocateCLIBHandleStruct + AtUnload + BeginThread + BeginThreadGroup + BeginThreadGroup_500 + BlockedOnSleep + BuildDBCSTableFromVector + CLibAlloc + CLibRealloc + CheckForCancellation + CheckIfScreenDisplayed + ClearNLMDontUnloadFlag + CloseLocalSemaphore + ConvertScrHandleToScrStruct + CopyFromScreenMemory + CopyToScreenMemory + CountAndFlushLibStats + CreateChildProcess + CreateLibraryContext + CreateScreen + CurrentProcess + DeLinkTCSFromTGCS + DeallocateCLIBHandle + DestroyLibraryContext + DestroyScreen + DestroyThread + DetectIPProtocols + DetectIPXProtocols + DisplayInputCursor + DisplayScreen + DropPopUpScreen + EnterCritSec + ExamineLocalSemaphore + ExitCritSec + ExitThread + FindCancelRecInList + FindNLMHandle + FindNLMHandleInAddressSpace + FreeShMemCtrlStruct + GetCLIBHandleStruct + GetContext + GetCurrentAddressSpaceID + GetCurrentScreen + GetCursorCouplingMode + GetCursorShape + GetCursorSize + GetCustomThreadDataArea + GetFirstShMemCtrlStruct + GetLibraryFunction + GetNCSAllocRTag + GetNCSProfileInfo + GetNCSVersionFlag + GetNCSsizeof_long_double + GetNLMHandle + GetNLMID + GetNLMIDFromNLMHandle + GetNLMIDFromThreadID + GetNLMLP + GetNLMNameFromNLMHandle + GetNLMNameFromNLMID + GetOFSAccessNShare + GetOFSConnection + GetOFSNWHandle + GetOFSPosition + GetOFSStdConsole + GetOFSTask + GetOFSThreadID + GetOFSType + GetPositionOfOutputCursor + GetProcessContext + GetPrty + GetScreenInfo + GetSizeOfScreen + GetSyntheticVersion + GetTCSProfileInfo + GetTGLP + GetThLP + GetThreadAddressSpaceID + GetThreadContextSpecifier + GetThreadDataAreaPtr + GetThreadFromThreadGroup + GetThreadGroupID + GetThreadHandicap + GetThreadID + GetThreadName + GetThreadSuspendFlags + HideInputCursor + InProtectedAddressSpace + InitializeConsoleOFS + InternalBeginThread + InternalBeginThreadGroup + InternalGetNLMID + InternalGetNLMsAllocRTag + InternalGetNLMsSemaRTag + InternalStartNLM + InternalTrackSemaphore + InternalUnTrackSemaphore + IsColorMonitor + IsThreadSuspended + KillChildProcess + LLAToI + LLDecStrToNum + LLGetToken + LLGetTokenTypeStr + LLHexStrToAddr + LLInitTokenRec + LLIntToBinStr + LLOutputToScreen + LLUngetToken + LLZeroToken + LenStrCat + LenStrCmp + LenStrCpy + LenToASCIIZStr + Lib3Globals + LibraryFunctionRegistryStats + LinkTCSToTGCS + MPAllocMutex + MPDeallocMutex + MPLockMutex + MPUnlockMutex + MPKAllocQue + MPKAllocQueLite + MPKAllocQueLiteNoSleep + MPKBarrierAlloc + MPKBarrierDecrement + MPKBarrierFree + MPKBarrierIncrement + MPKBarrierThreadCount + MPKBarrierWait + MPKBarrierWaitCount + MPKCreateThread + MPKCurrentThread + MPKDeQue + MPKDeQueAll + MPKDeQueAllNoLock + MPKDeQueByQLink + MPKDeQueByQLinkNoLock + MPKDeQueLite + MPKDeQueLiteAll + MPKDeQueLiteAllNoLock + MPKDeQueLiteByQueLink + MPKDeQueLiteByQueLinkNoLock + MPKDeQueLiteNoLock + MPKDeQueLiteWait + MPKDeQueLiteWaitNoLock + MPKDeQueNoLock + MPKDeQueWait + MPKDeQueWaitNoLock + MPKDestroyThread + MPKEnQue + MPKEnQueLite + MPKEnQueLiteNoLock + MPKEnQueNoLock + MPKEnQueOrdered + MPKEnQueOrderedNoLock + MPKEnterNetWare + MPKExitClassicNetWare + MPKExitNetWare + MPKFirstQLinkNoLock + MPKFirstQueLinkLiteNoLock + MPKFreeQue + MPKFreeQueLite + MPKFunc + MPKFunc_kCurrentThread + MPKFunc_kGetNPLThreadData + MPKFunc_kGetThreadLibraryContext + MPKFunc_kSetNPLThreadData + MPKFunc_kSetThreadLibraryContext + MPKGetThreadName + MPKGetThreadPriority + MPKMutexAlloc + MPKMutexFree + MPKMutexLock + MPKMutexTryLock + MPKMutexUnlock + MPKMutexWaitCount + MPKPushQue + MPKPushQueLite + MPKPushQueLiteNoLock + MPKPushQueNoLock + MPKPushQueOrdered + MPKPushQueOrderedNoLock + MPKQueCount + MPKQueLiteCount + MPKRWLockAlloc + MPKRWLockFree + MPKRWLockInfo + MPKRWReadLock + MPKRWReadTryLock + MPKRWReadUnlock + MPKRWWriteLock + MPKRWWriteTryLock + MPKRWWriteUnlock + MPKResumeThread + MPKScheduleThread + MPKSemaphoreAlloc + MPKSemaphoreExamineCount + MPKSemaphoreFree + MPKSemaphoreSignal + MPKSemaphoreTimedWait + MPKSemaphoreTry + MPKSemaphoreWait + MPKSemaphoreWaitCount + MPKSetThreadName + MPKSetThreadPriority + MPKStartThread + MPKSuspendThread + MPKVar_RunningProcess + MPKVar_kNPLThreadData + MPKVar_kThreadLibraryContext + MPKYieldThread + MTAllocMutex + MTDeallocMutex + MTLockMutex + MTUnlockMutex + MTAllocRwLock + MTDeallocRwLock + MTReadRwLock + MTWriteRwLock + MTReadRwUnlock + MTWriteRwUnlock + MapNLMIDToHandle + MapScreenIDToHandle + MoveData + NVMFunc + NWCharType + NWGarbageCollect + NWGetAllocPageOverhead + NWGetAvailableMemory + NWGetPageSize + NWMemorySizeAddressable + NWSMPRWLockAlloc + NWNumberOfRegisteredProcessors + NWSMPBarrierAlloc + NWSMPBarrierDestroy + NWSMPBarrierWait + NWSMPCondAlloc + NWSMPCondBroadcast + NWSMPCondDestroy + NWSMPCondSignal + NWSMPCondWait + NWSMPIsAvailable + NWSMPIsLoaded + NWSMPMutexDestroy + NWSMPMutexLock + NWSMPRMutexOwner + NWSMPMutexSleepAlloc + NWSMPMutexTryLock + NWSMPMutexUnlock + NWSMPRMutexAlloc + NWSMPRMutexDestroy + NWSMPRMutexLock + NWSMPRMutexTryLock + NWSMPRMutexUnlock + NWSMPRWLockDestroy + NWSMPRWReadLock + NWSMPRWTryReadLock + NWSMPRWTryWriteLock + NWSMPRWUnlock + NWSMPRWWriteLock + NWSMPSpinAlloc + NWSMPSpinDestroy + NWSMPSpinLock + NWSMPSpinTryLock + NWSMPSpinUnlock + NWSMPThreadToMP + NWSMPThreadToNetWare + NWThreadToMP + NWThreadToNetWare + NotifyThreadsOfInterfaces + OFSFromDescriptor + OSAddressSpaceID + OSFunc + OSVar + OpenLocalSemaphore + OpenStandardConsoleOFS + OptimalPageUseSize + PopThreadCleanup + PopThreadGroupCleanup + PressAnyKeyToContinue + PressEscapeToQuit + PrintLibError + ProcessFromThreadID + PushThreadCleanup + PushThreadGroupCleanup + PutLibraryFunction + RBAddToReadSuspendList + RBAddToWriteSuspendList + RBBufferIOState + RBBufferPeek + RBClose + RBOpen + RBRead + RBRemoveThreadFromPipe + RBReset + RBResumeReaders + RBResumeWriters + RBSetBufferSize + RBWrite + RecordNWErrnoAndErrno + RedirectFrontEndedAddresses + RegisterForThreadSwitchEvent + RegisterProfiler + RenameThread + ReqFunc + ReqFunc_IPFindRoute + ReqFunc_NWgethostbyname + ReqFunc_SAPGetServerEntry + ReqFunc_SLPDeregisterClient + ReqFunc_SLPReadAttributes + ReqFunc_SLPRegisterClient + ReqFunc_TCPAbort + ReqFunc_TCPBind + ReqFunc_TCPClose + ReqFunc_TCPConnect + ReqFunc_TCPDeregister + ReqFunc_TCPGetOption + ReqFunc_TCPLastSendData + ReqFunc_TCPListen + ReqFunc_TCPNewSendData + ReqFunc_TCPNewWindow + ReqFunc_TCPRegister + ReqFunc_TCPSetOption + ReqFunc_UDPDeregister + ReqFunc_UDPRegister + ReqFunc_UDPReturnPacket + ReqFunc_UDPSend + ResumeThread + SaveThreadDataAreaPtr + ScanScreens + ScheduleWorkToDo + ScrollScreenRegionDown + ScrollScreenRegionUp + ScrollWindowScreenRegionDown + ScrollWindowScreenRegionUp + SetAutoScreenDestructionMode + SetCLIBHandleStruct + SetCLIBTCSBlockCode + SetCtrlCharCheckMode + SetCurrentScreen + SetCursorCouplingMode + SetCursorShape + SetCustomThreadDataArea + SetThreadHandicap + SetInputAtOutputCursorPosition + SetNCSProfileInfo + SetNLMDontUnloadFlag + SetNLMID + SetOFSPosition + SetOutputAtInputCursorPosition + SetPositionOfInputCursor + SetProcessContext + SetPrty + SetScreenAreaAttribute + SetScreenCharacterAttribute + SetScreenRegionAttribute + SetSyntheticVersion + SetTCSProfileInfo + SetThreadContextSpecifier + SetThreadGroupID + SignalLocalSemaphore + StackAvail + StackLimit + SuspendThread + SyntheticVersion + SystemConsoleScreen + TCSFromThreadID + ThreadSwitch + ThreadSwitchLowPriority + ThreadSwitchWithDelay + ThreadsGlobals + TimedWaitOnLocalSemaphore + ToolsFunc + ToolsVar + TryLocalSemaphore + UnRegisterForThreadSwitchEvent + UnRegisterProfiler + UnimportIPProtocols + UnimportIPXProtocols + ValidateCLIBHandle + ValidateMappedAddress + WaitOnChildProcess + WaitOnLocalSemaphore + _AllocMutex + _AllocRwLock + _AllocSemaphore + _AllocSleepOK + _CreateCallBackBlock + _DBCSVector + _DeallocMutex + _DeallocRwLock + _DeallocSemaphore + _DefaultSignalHandler + _DestroyCallBackBlock + _DestroyThread + _DestroyThreadGroup + _ExamineSemaphore + _FillStructure + _FreeUpProcessFromSemaphore + _FreeUpProcessFromSpecRwLock + _FreeUpProcessFromSpecificMutex + _FreeUpProcessFromSpecificSemaphore + _GetCurrentClock + _GetSyncClockFields + _InternalSuspendOrStop + _LockMutex + _LockMutexNoCancel + _NWLstrchr + _NWLstrcoll + _NWLstrupr + _NWOSMajorVersion + _NWOSMinorVersion + _NWPrevChar + _OSTZSet + _OwnerMutex + _OwnerRwLock + _PUSH_CANCELLATION + _ParseArgs + _ReadRwLock + _ReleaseAllSemaphore + _SignalSemaphore + _SizeOfAllocBlock + _StartNLM + _SuspendOrStop + _TerminateNLM + _TryLockMutex + _TryReadRwLock + _TryWaitOnSemaphore + _TryWriteRwLock + _UnlockMutex + _UnlockRwLock + _UnlockSpecificMutex + _WaitOnSemaphore + _WriteRwLock + __CHK + __EPI + __GETDS + __GetCLIBNLMPrefixSize + __GetScreenID + __Must_Have_Three_One_Or_Greater + __STK + __cputs + __delink + __get_NWErrno + __get_NWErrno_ptr + __get_cin + __get_cout + __get_errno_ptr + __get_stderr + __get_stdin + __get_stdout + __get_t_errno_ptr + __qcalloc + __qmalloc + __qrealloc + __screenOutput + _exit + _get_NWErrno + _get_errno + _isDOSPrint + _msize + _set_NWErrno + _set_errno + abort + atexit + calloc + cgets + clrscr + cputs + delay + exit + free + gBeginCLibNLM + gBeginCLibThread + gBeginCLibThreadGroup + gDummyContext + gEndCLibThread + gEndCLibThreadGroup + gEndNoContextCLibNLM + gNCPDisconnect + gPostEndCLibNLM + gPreEndCLibNLM + gReleaseFileResourcesForThread + gRequestrTGCSTearDown + gStreamCancel + getch + getche + getcmd + gotoxy + inp + inpd + inpw + itoa + itoab + kbhit + ltoa + malloc + memchr + memcmp + memcpy + memicmp + memmove + memset + outp + outpd + outpw + putch + realloc + spawnlp + spawnvp + stackavail + strcat + strchr + strcmp + strcmpi + strcpy + strcspn + strdup + stricmp + strlen + strlist + strlwr + strncat + strncmp + strncpy + strnicmp + strnset + strpbrk + strrchr + strrev + strset + strspn + strstr + strtok_r + strtol + strtoul + strupr + swab + swaw + ultoa + ungetch + utoa + wherex + wherey diff --git a/include/nwnss/include/unssLOADER.imp b/include/nwnss/include/unssLOADER.imp new file mode 100644 index 0000000..6cd4522 --- /dev/null +++ b/include/nwnss/include/unssLOADER.imp @@ -0,0 +1,75 @@ +DBG_AssertError +DBG_AssertError_MP +DBG_AssertErrorStub +DBG_AssertWarning +DBG_DebugBreak +DBG_DebugFlag +DBG_DebugFormatBinary +DBG_DebugHexDump +DBG_DebugMask +DBG_debugLogMask +DBG_DebugPrintf +DBG_Denter +DBG_Dindent +DBG_DoNSSDebuggerCommand +DBG_DrtnNINT +DBG_DrtnPtr +DBG_DrtnStatus +DBG_DrtnVoid +DBG_debugLogBuffer +DBG_DebugLogBufferSize +DBG_debugLogBufferInsert +DBG_debugLogBufferRemove +DBG_DumpSpinLock +DBG_error +DBG_fatal +DBG_HookNCPLog +DBG_HookNCPTrace +DBG_InitDebug +DBG_NotImpDbgMsg +DBG_PageSize +DBG_Paging +DBG_prseq +DBG_RestoreSpinLock +DBG_SavedDebugFlag +DBG_SavedTraceFlag +DBG_SaveSpinLock +DBG_ScreenAPrintf +DBG_ScreenSwitches +DBG_Shutdown +DBG_Startup +DBG_Stub +DBG_TraceFlag +DBG_UnHookNCPLog +DBG_UnHookNCPTrace +DBG_UninitDebug +fsmInit +LBL_sForce +LBL_xForce +LBL_addLatch +LBL_initLatch +LBL_initSlatch +LBL_initXlatch +LBL_sLatch +LBL_sNoWait +LBL_fsmSlatch +LBL_xLatch +LBL_xNoWait +LBL_fsmXlatch +LBL_upLatch +LBL_upNoWait +LBL_fsmUpLatch +LBL_downLatch +LBL_unsLatch +LBL_unxLatch +LBL_unLatch +LBL_initCount +LBL_incCount +LBL_decCount +LBL_grab +LBL_drop +LBL_fsmGrab +LBQ_QAssertError +DBG_DebugEnabled +DBG_TraceEnabled +DBG_ScreenDebug diff --git a/include/nwnss/include/utc.h b/include/nwnss/include/utc.h index 3318390..89da92c 100644 --- a/include/nwnss/include/utc.h +++ b/include/nwnss/include/utc.h @@ -51,8 +51,8 @@ #endif -#ifndef _OMNI_H_ -# include +#ifndef _ZOMNI_H_ +# include #endif #ifdef __cplusplus @@ -110,7 +110,7 @@ typedef struct Time_s * Get current UTC time *---------------------------------------------------------------------------*/ /* extern Time_t GetUTCTime(void); using directy macro - This #ifdef cannot work unless we change the library + This #ifdef cannot work unless we change the library build process to build separate libs for MOAB and GreenRiver. */ @@ -121,11 +121,11 @@ typedef struct Time_s # define GetUTCTime() (UTCTime) #endif #ifdef _NWGREENRIVER_ - extern volatile struct Synchronized_Clock_T SynchronizedClock; + extern volatile struct Synchronized_Clock_T SynchronizedClock; # define GetUTCTime() (*(Time_t *)&SynchronizedClock) #endif - - but until then the following code works ... */ + + but until then the following code works ... */ extern volatile LONG UpTimeInSeconds; @@ -138,7 +138,7 @@ extern BOOL IgnoreTimeZone; extern NINT ResetTimeCache; #if zNETWARE -extern volatile struct Synchronized_Clock_T SynchronizedClock; +extern volatile struct Synchronized_Clock_T SynchronizedClock; #define GetUTCTime() (*(Time_t *)&SynchronizedClock) #define NSS_TimeZoneOffset SynchronizedClock.timezoneOffset #define NSS_DaylightOnOff SynchronizedClock.daylightOnOff @@ -146,24 +146,32 @@ extern volatile struct Synchronized_Clock_T SynchronizedClock; #endif #ifdef __linux__ -#if defined(__KERNEL__) // // linux/kernel/time.c has the kernel time functions in it. // date command uses environment variable TZ and if not set then /etc/localtime +// linux/time.h +//struct timeval { +// time_t tv_sec; /* seconds */ +// suseconds_t tv_usec; /* microseconds */ +//}; // +// linux/time.h +//struct timezone { +// int tz_minuteswest; /* minutes west of Greenwich */ +// int tz_dsttime; /* type of dst correction */ // man of gettimeofday says that tz_dsttime has never been used as if it is used is a bug +//}; +// + +//extern volatile struct timeval xtime; // UTC time on Linux??? #ifdef i386 extern volatile struct timezone sys_tz; // TZ info on Linux??? #endif + #define GetUTCTime() (*(Time_t *)&xtime.tv_sec) +//#define GetUTCTime() (CURRENT_TIME) #define NSS_TimeZoneOffset (sys_tz.tz_minuteswest*60) #define NSS_DaylightOnOff 0 #define NSS_DaylightOffset 0 -#else -extern Time_t GetUTCTime(void); -extern LONG NSS_TimeZoneOffset; -extern NINT NSS_DaylightOnOff; -extern LONG NSS_DaylightOffset; -#endif #endif /*------------------------------------------------------------------------- @@ -344,15 +352,15 @@ char *secondsDiffToStr( char *buf); /*--------------------------------------------------------------------------- - * Structures and global variables that are used to determine if the input + * Structures and global variables that are used to determine if the input * UTC time is in the summer time *---------------------------------------------------------------------------*/ typedef struct ChangeDate_s { NINT month; /* month since January -- [1-12] */ NINT day; /* days since Sunday -- [0-6] */ - NINT which; /* if afterBeforeOrdina= ORDINAL, which ordinal - * week of month -- [kNone-kLast], otherwise, + NINT which; /* if afterBeforeOrdina= ORDINAL, which ordinal + * week of month -- [kNone-kLast], otherwise, * after or before which day in the month*/ NINT hour; /* hours since midnight -- [0-23] in seconds */ NINT date; /* date in the month */ diff --git a/include/nwnss/include/uxaction.h b/include/nwnss/include/uxaction.h index c0d236f..79d78c4 100644 --- a/include/nwnss/include/uxaction.h +++ b/include/nwnss/include/uxaction.h @@ -24,11 +24,11 @@ | |--------------------------------------------------------------------------- | - | $Author: cteerlink $ - | $Date: 2005-12-17 04:38:41 +0530 (Sat, 17 Dec 2005) $ + | $Author: cteerlink $ + | $Date: 2005-12-17 04:38:41 +0530 (Sat, 17 Dec 2005) $ | | $RCSfile$ - | $Revision: 1293 $ + | $Revision: 1293 $ | |--------------------------------------------------------------------------- | This module is used to: @@ -87,7 +87,7 @@ enum { LOGRECTYPE_BEGIN, LOGRECTYPE_COMMIT, LOGRECTYPE_ABORT, - LOGRECTYPE_DATA, + LOGRECTYPE_DATA, LOGRECTYPE_TRUNCATE, LOGRECTYPE_END }; /* type of logrec */ @@ -113,24 +113,23 @@ typedef struct UserXactionLogBuffer_s extern void AbortOldestTransactions(Volume_s *vol); extern STATUS COMN_AbortUserXaction ( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, UserXaction_s *xaction); extern STATUS COMN_BeginUserXaction ( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, UserXaction_s *xaction); extern STATUS COMN_CommitUserXaction ( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, UserXaction_s *xaction); extern STATUS COMN_StartUXactionSupportOnVolume( Volume_s *vol); extern void UXactionActivateThread( - FsmLite_s *fsm, + FsmLite_s *fsm, Volume_s *vol); -extern void HomeXactionLogFile ( - Volume_s *vol); +extern void HomeXactionLogFile (); extern void UXACTION_Startup(); extern void UXACTION_Shutdown(); extern LONG UXChangeVolStateEnterCallBack( @@ -140,8 +139,8 @@ extern LONG UXChangeVolStateExitCallBack( struct EventBlock *evBlk); extern STATUS WriteXactionMarker( - NINT marker, - UserXaction_s *xidPtr, + NINT marker, + UserXaction_s *xidPtr, Buffer_s *latchedBuf); extern STATUS LogUserData( @@ -156,8 +155,8 @@ extern STATUS LogUserData( extern STATUS LogTruncateData ( GeneralMsg_s *genMsg, FileHandleIDP_s *fileHandleIDP, - QUAD truncatePos, - QUAD curEOF, + QUAD truncatePos, + QUAD curEOF, Xid_t xid); #endif diff --git a/include/nwnss/include/vcu.h b/include/nwnss/include/vcu.h new file mode 100644 index 0000000..f17598b --- /dev/null +++ b/include/nwnss/include/vcu.h @@ -0,0 +1,252 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (PSS) Initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This contains the top level internal file interfaces. All external + | interfaces call these routines. + +-------------------------------------------------------------------------*/ + +#ifndef _VCU_H_ +#define _VCU_H_ + + +#ifndef _ZOMNI_H_ +#include "zOmni.h" +#endif + + +//#define VCU_DEBUG + + +/* + * IFU defines + */ +#define DIR_SEARCH_BITS (HIDDEN_BIT | SYSTEM_BIT | SUBDIRECTORY_BIT) +#define FILE_SEARCH_BITS (HIDDEN_BIT | SYSTEM_BIT) + +// This are defines from NSS!!! +#define IFU_NSS_BLOCK_SIZE 4096 + +//#define MAX_NAME (256+2) /* Length proceeded and NULL terminated */ +#define VOL_NAME 64 +#define MAX_TRUSTEES 20 + + +extern struct ScreenStruct *ScreenID; +extern struct ScreenStruct *ConsoleScreen; + + + +/* + * Extended Attribute Typedef + * Values for EA stuff that was never put into include files in the OS. + * These are defines taken from "filer4.c" in the OS base + */ + +/* mask values actually */ +#define EADirBaseBit 0 +#define EAOpenFileBit 1 +#define EAHandleBit 2 + + + + +typedef struct Data_Stream_s { + LONG IDS_DataStreamNumber; + LONG IDS_DataStreamSize; +} Data_Stream_s; + + + // This is the items that we request when calling GenNSContinueFileSearch() +typedef struct Netware_Info_s +{ + LONG FilledInMask; /* Specifies what fields are valid. */ + LONG DiskSpaceAllocated; /* Returned by RSize bit */ + LONG Attributes; /* Returned by RAttributes bit */ + WORD Flags; + + LONG DataStreamSize; /* Filled in if RDataStreamInfo bit set + * (Size of Primary Data stream in bytes.) + */ + LONG TotalDataStreamsSize; /* Filled in by RTotalDataStreamSize bit + * (Actual size of all data streams, + * represented as a number of 4K pages.) + */ + + WORD NumberOfDataStreams; + + LONG ExtendedAttributesValueSize;/* Returned by REAInfo bit */ + LONG ExtendedAttributesCount; + LONG ExtendedAttributesKeySize; + + WORD ArchivedTime; /* Returned by RArchiveInfo bit */ + WORD ArchivedDate; + LONG ArchiversID; + + WORD ModifiedTime; /* Returned by RModifyInfo bit */ + WORD ModifiedDate; + LONG ModifiersID; + WORD LastAccessedDate; + + WORD CreationTime; /* Returned by RCreationInfo bit */ + WORD CreationDate; + LONG CreatorsID; + + LONG CreatorNameSpaceNumber; /* Returned by RNameSpaceInfo bit */ + LONG DirectoryEntryNumber; /* Returned by RDirectoryInfo bit */ + LONG DOSDirectoryEntryNumber; + LONG VolumeNumber; + + WORD MaximumRightsMask; /* Returned by RRights bit */ + WORD CurrentReferenceID; /* Returned by RReferenceID */ + LONG FileAttributes; /* Returned by RNSAttribute */ + LONG NumberOfDataStreamsActual; /* Returned by RDataStreamActual + * (Actual number of 512 byte + * sectors occupied by each data + * stream.) + */ + Data_Stream_s *DataStreamsActual; + + LONG NumberOfDataStreamsLogical; /* Returned by RDataStreamLogical + * (Number of logical bytes (EOF) + * of each data stream.) + */ + Data_Stream_s *DataStreamsLogical; + + LONG SecondsRelativeToTheYear2000; /* Returned by + * RLastUpdatedInSeconds + */ + BYTE DOSNameLength; /* Returned by RDOSName */ + BYTE *DOSName; + + LONG FlushTime; /* Returned by RFlushTime */ + LONG ParentBaseID; /* Returned by RParentBaseID */ + BYTE MacFinderInfo[32]; /* Returned by RMacFinderInfo */ + LONG SiblingCount; /* Returned by RSiblingCount */ + LONG EffectiveRights; /* Returned by REffectiveRights */ + LONG MACCreateTime; /* Returned by RMACDateTimes */ + LONG MACBackupTime; + BYTE FileNameLength; /* Returned by RFileName */ + BYTE *FileName; /* NULL terminated */ + + LONG BufferIndex; + BYTE Buffer[512]; /* Variable Items go Here */ +} Netware_Info_s; + + + + /* + * Global information needed to upgrade a volume. + */ +typedef struct VolInfo_s +{ + BYTE volName[VOL_NAME + 4]; /* Name of volume */ + LONG volNum; /* Volume number */ +} VolInfo_s; + + +extern VolInfo_s Src; +extern VolInfo_s Dst; + +//extern BOOL DeletedFile; +extern BOOL CompressFile; +extern BOOL PrintScreen; +extern BOOL LogFile; +extern BOOL ImmComp; +extern BOOL GUIuse; + +extern BOOL UserAbort; + +/* + * Externs for instrumentation + */ +extern LONG NumFiles; +extern LONG NumDirs; +extern LONG NumDelFiles; +extern QUAD NumBytes; +extern LONG Errors; + +extern Time_t StartUTC; + +extern THREAD VCU_threadID; + +void MoveRootTree(void); + +void pr( + NINT stage, + BOOL isErrMsg, + BOOL userInput, + char *format, ...); +void printNumber(LONG num); +void printTime(LONG time); +void prepareScreen(); +void writeScreen( + BYTE *name, + BYTE *parentName, + LONG fileSize, + LONG level); +BOOL checkForAbort(); + +extern VersionInformation_s VCU_VersionInfo; + + +extern BOOL getManageVCUAbort(); +BOOL getManageVCUAnswer(); + +extern void setManageVCUCopyStatus( + BYTE *fileName, /* in dos format */ + BYTE *parent, /* in dos format */ + NINT dirDepth, + QUAD fileSize, + QUAD movedDir, + QUAD movedFile, + QUAD errors); + +extern void setManageVCUProcessMsg( + NINT stage, + BOOL isErrMsg, + THREAD waitingThread, + BOOL userInput, + BYTE *format, + void *args); + +enum VCUProcessStage_e +{ + VCU_BEFORE_COPY, + VCU_COPY_FILE, + VCU_AFTER_COPY, + VCU_FINISHED +}; + + + +#endif diff --git a/include/nwnss/include/vdbe.h b/include/nwnss/include/vdbe.h new file mode 100644 index 0000000..a135cfa --- /dev/null +++ b/include/nwnss/include/vdbe.h @@ -0,0 +1,241 @@ +/*************************************************************************** + | + | (C) Copyright 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) module + | + |-------------------------------------------------------------------------- + | + | $Author: nbalachandran $ + | $Date: 2007-08-14 11:26:00 +0530 (Tue, 14 Aug 2007) $ + | + | $RCSfile$ + | $Revision: 2149 $ + | + |-------------------------------------------------------------------------- + | This module is used to: + | Define constants & structures for the VLDB back-end database + +------------------------------------------------------------------------*/ +#ifndef _VDBE_H_ +#define _VDBE_H_ + +#ifndef _MPKTYPES_H_ +# include +#endif +#ifndef _ZOMNI_H_ +# include +#endif +#if zNETWARE +#ifndef _XUNICODE_H_ +# include +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define DB_PRIMARY_NAME_LENGTH (sizeof (GUID_t)) + +/* Generic VLDB Back-End Configuration Parameters */ +/* Defined range is 0x00008000-0x0000FFFF */ +#define VLDB_CONFIG_VDBE_DB_PATH 0x00008000 + +/* This structure allows the message layer to request that an operation */ +/* in progress be aborted. One of these structures is passed in to every */ +/* (abortable) back-end operation, and the back-end database SHOULD check */ +/* for the CANCEL_REQUESTED flag at convenient times during processing to */ +/* keep the system responsive. Always use the spinlock when accessing the */ +/* flags, as this stuff runs in an MP environment! The function */ +/* VLDBWasRequestAborted has been provided to help here... */ +/* The value passed in to a function may be NULL, in which case you don't */ +/* have to worry about dealing with it... */ +/* The BackEndData fields are for the back end's use, and will not be set */ +/* or examined by the message layer. */ +typedef struct VLDBAbortFlags_s +{ + LONG flags; /* Flags for Abort (see below) */ + SPINLOCK flag_lock; /* Lock for accessing flags */ + union + { + void *ptrval; + LONG longval; + } BackEndData1; + union + { + void *ptrval; + LONG longval; + } BackEndData2; +} VLDBAbortFlags_s; + +/* Flag values: */ +#define VLDB_ABORT_FLAG_CANNOT_CANCEL 0x00000001 +#define VLDB_ABORT_FLAG_CANCEL_REQUESTED 0x00000002 +#define VLDB_ABORT_FLAG_IN_BACK_END 0x00000004 + +/* This structure is used to return server name lists in a LOOKUP call, */ +/* and to pass them in in a WRITE call. It is defined so that the buffer */ +/* passed back by a LOOKUP can be used directly in the response message */ +/* and the received WRITE message can be used directly to call the */ +/* low-level WRITE function... */ +/* Note: as per the spec, name is always a null-terminated UNICODE string */ +/* and namelen specifies the length of the buffer that contains it, which */ +/* should be padded to a 64-bit boundary */ +/* Note also that this structure is identical to the */ +/* VLDB_MSG_InstanceInfo_s structure defined in vldbmsg.h -- That is */ +/* intentional as it saves us some data copying. If this structure ever */ +/* needs to change, the other structure must be changed to match!!! */ +typedef struct ServerInfo_s +{ + LONG volume_type; // Volume type (R/W, R/O, COW, ...) + unicode_t phys_name[16]; // The physical volume name + LONG namelen; // Name length in bytes + unicode_t name[1]; // The server name +} ServerInfo_s; +#define SERVER_INFO_HDR_SIZE (2*sizeof(LONG) + 32) + +/* Volume type definitions */ +#define VOL_INVALID 0x00 // Invalid (not used) +#define VOL_RDWR 0x01 // Read-Write volume +#define VOL_RDONLY 0x02 // Read-only volume +#define VOL_COW 0x03 // Copy-on-Write volume + +/* This structure is used to return volume name lists in */ +/* an Enumerate call */ +/* Note also that this structure is identical to the */ +/* VLDB_MSG_VolumeInfo_s structure defined in vldbmsg.h -- That is */ +/* intentional as it saves us some data copying. If this structure ever */ +/* needs to change, the other structure must be changed to match!!! */ +typedef struct VolumeInfo_s +{ + BYTE primaryName[DB_PRIMARY_NAME_LENGTH]; // Primary Volume Name (GUID) +} VolumeInfo_s; + +/* This structure is used to return statistics in a VLDBGetStatistics call */ +/* All statistics are 32-bit values */ +typedef struct VLDBStats_s +{ + LONG type; + LONG value; +} VLDBStats_s; + +/* Generic VLDB back-end statistics */ +#define VLDB_STATS_VDBE_RELEASE_LEVEL 0x00008000 + +/* This structure is used to define configuration parameters */ +typedef struct TLV +{ + LONG type; + LONG length; + BYTE value[1]; // actual size specified by length +} TLV; + +/* This structure is used to return the status of a repair */ +typedef struct VLDBStatus_s +{ + NINT state; // Repair State + NINT level; // Current or last completed repair level + NINT pct_complete; // 0-100 +} VLDBStatus_s; + +/* Values for state: */ +#define REPAIR_STATE_NOT_REPAIRING 0 +#define REPAIR_STATE_REPAIRING 1 +#define REPAIR_STATE_COMPLETE 2 +#define REPAIR_STATE_FAILED 3 + +/* Values for level: */ +#define REPAIR_LEVEL_LOW_LEVEL 1 // low-level repair +#define REPAIR_LEVEL_REFRESH_FROM_BUDDY 2 // get from another replica + +/* Database types for init/open: */ +#define DBTYPE_PRIMARY 0 +#define DBTYPE_REPAIR 1 +#define DBTYPE_SNAPSHOT 2 +#define DBTYPE_REPLICA 3 + +/* Function Prototypes */ +/* Initialize a database for the specified management context */ +LONG VLDBInitializeDatabase(NINT dbType,VLDBAbortFlags_s *abortFlags); + +/* Open the database for the specified management context */ +LONG VLDBOpenDatabase(NINT dbType, LONG *handle,VLDBAbortFlags_s *abortFlags); + +/* Close an open database */ +LONG VLDBCloseDatabase(LONG handle,VLDBAbortFlags_s *abortFlags); + +/* Find a volume in the database & return servers that support it */ +LONG VLDBLookup(LONG handle,BYTE *primaryVolumeName, + LONG *numReturned,NINT bufSize,ServerInfo_s *buffer, + VLDBAbortFlags_s *abortFlags); + +/* Add/Update a volume entry */ +LONG VLDBWrite(LONG handle,BYTE *primaryVolumeName, + LONG numItems,ServerInfo_s *serverList, + VLDBAbortFlags_s *abortFlags); + +/* Delete a volume entry */ +LONG VLDBDelete(LONG handle,BYTE *primaryVolumeName,VLDBAbortFlags_s *abortFlags); + +/* Lock a volume entry */ +LONG VLDBLock(LONG handle,BYTE *primaryVolumeName,VLDBAbortFlags_s *abortFlags); + +/* Unlock a volume entry */ +LONG VLDBUnlock(LONG handle,BYTE *primaryVolumeName,VLDBAbortFlags_s *abortFlags); + +/* List all volume entries */ +LONG VLDBEnumerate(LONG handle,LONG *cookie,unicode_t *serverName, + LONG *numReturned,NINT bufSize,VolumeInfo_s *volInfo, + VLDBAbortFlags_s *abortFlags); + +/* Get back-end specific statistics */ +LONG VLDBGetStatistics(NINT *numItems,VLDBStats_s *itemList,VLDBAbortFlags_s *abortFlags); + +/* Set configuration parameters */ +LONG VLDBSetConfig(NINT numItems,TLV *itemList,VLDBAbortFlags_s *abortFlags); + +/* Get current configuration parameter settings */ +LONG VLDBGetConfig(NINT bufSize,NINT *numItems,TLV *itemList,VLDBAbortFlags_s *abortFlags); + +/* Start a database repair */ +typedef void (*CALLBACK_FUNC)(LONG status,LONG retcode); +LONG VLDBRepairStart(NINT level,CALLBACK_FUNC callback,VLDBAbortFlags_s *abortFlags); + +/* Stop a database repair */ +LONG VLDBRepairStop(VLDBAbortFlags_s *abortFlags); + +/* Check the status of a database repair */ +LONG VLDBRepairStatus(VLDBStatus_s *status,VLDBAbortFlags_s *abortFlags); + +/* Activate a repaired database */ +LONG VLDBActivateRepairDatabase(LONG handle,VLDBAbortFlags_s *abortFlags); + +/* Add a VLDB replica */ +LONG VLDBAddReplica(unicode_t *server_name,VLDBAbortFlags_s *abortFlags); + +/* Remove a VLDB replica */ +LONG VLDBRemoveReplica(unicode_t *server_name,VLDBAbortFlags_s *abortFlags); + +#ifdef __cplusplus +} +#endif + +#endif /* _VDBE_H_ */ diff --git a/include/nwnss/include/vdbe.imp b/include/nwnss/include/vdbe.imp new file mode 100644 index 0000000..aa8d591 --- /dev/null +++ b/include/nwnss/include/vdbe.imp @@ -0,0 +1,19 @@ + VLDBInitializeDatabase + VLDBOpenDatabase + VLDBCloseDatabase + VLDBLookup + VLDBWrite + VLDBDelete + VLDBLock + VLDBUnlock + VLDBEnumerate + VLDBSetConfig + VLDBGetConfig + VLDBRepairStart + VLDBRepairStop + VLDBRepairStatus + VLDBActivateRepairDatabase + VLDBAddReplica + VLDBRemoveReplica + VLDBGetStatistics + diff --git a/include/nwnss/include/virtualIO.h b/include/nwnss/include/virtualIO.h index ec35c60..efe4587 100644 --- a/include/nwnss/include/virtualIO.h +++ b/include/nwnss/include/virtualIO.h @@ -54,7 +54,7 @@ #define VIRT_RESULT_BUFFER_SIZE 8192 #define VIRT_RESULT_REALLOC_AMOUNT 4096 -#if zNETWARE || defined(__KERNEL__) || defined(NSS_USERSPACE) +#if zNETWARE || defined(__KERNEL__) /**************************************************************************** * @@ -77,7 +77,7 @@ #define VIRT_ACTUAL_EOF(_beast, _buffer) \ (*(LONG *)&(_buffer)[MAX_VIRTUAL_FILE_SIZE(_beast)]) #define MAX_VIRT_SYMBOL_LEN 63 -#define MAX_TEXT_UNIT 1024 +#define MAX_TEXT_UNIT 1024 #define ADJUST_OFFSET(_offset, _adjustment) \ { \ @@ -105,7 +105,7 @@ #define VIRT_TYPE_USER 1 #define VIRT_TYPE_JAVA 2 -#if zNETWARE || (zLINUX && defined(__KERNEL__)) || defined(NSS_USERSPACE) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) /**************************************************************************** * * Structures @@ -138,9 +138,9 @@ typedef struct CompiledTemplate_s struct { NINT locSymIdx; - LONG (*locSymPtr)(); /* this is setup as a function pointer even - * though it is not a function so it can - * be passed to functions dealing with + LONG (*locSymPtr)(); /* this is setup as a function pointer even + * though it is not a function so it can + * be passed to functions dealing with * symbols */ NINT locOffset; NINT locLeadingTextLen; @@ -332,7 +332,7 @@ STATUS VIRT_testWrite( #endif /* __KERNEL__ */ -#include +#include STATUS VIRT_CheckResultSize ( VirtInfo_s *virtInfo, diff --git a/include/nwnss/include/vldb.h b/include/nwnss/include/vldb.h new file mode 100644 index 0000000..31ee0a8 --- /dev/null +++ b/include/nwnss/include/vldb.h @@ -0,0 +1,98 @@ +/**************************************************************************** + | + | (C) Copyright 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | define VLDB constants that are used across modules + +-------------------------------------------------------------------------*/ + +#ifndef _VLDB_H_ +#define _VLDB_H_ + +#ifndef _ZOMNI_H_ +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/**************************************************************************** + * The length of a primary volume name. The primary volume name is really + * a GUID, but VLDB doesn't need to know that - it just treats it as a + * bunch of bytes... + ***************************************************************************/ +#define DFS_PRIMARY_VOLUME_NAME_LENGTH sizeof(GUID_t) + +/**************************************************************************** + * The maximum number of replicas that a volume can have: + ***************************************************************************/ +#define DFS_MAX_VOLUME_REPLICAS 16 + +/**************************************************************************** + * The maximum number of VLDB Servers for a management context: + * (Specific implementations may have lower limits) + ***************************************************************************/ +#define DFS_MAX_VLDB_SERVERS 16 + +/**************************************************************************** + * Special cookie values for ENUMERATE operations: + ***************************************************************************/ +#define VLDB_COOKIE_INITIAL 0 /* Initial request */ +#define VLDB_COOKIE_NO_MORE_ENTRIES 0xFFFFFFFF /* No more entries to return */ + +/**************************************************************************** + * Repair related defines: + ***************************************************************************/ + +/* Repair Levels: */ +#define VLDB_REPAIR_LEVEL_NONE 0 /* Reserved */ +#define VLDB_REPAIR_LEVEL_LOW_LEVEL 1 /* Try to fix bad file data */ +#define VLDB_REPAIR_LEVEL_REFRESH 2 /* Get DB from another replica */ +#define VLDB_REPAIR_LEVEL_REBUILD 3 /* Rebuild by walking NDS tree */ + +/* Values for repair state: */ +#define VLDB_REPAIR_STATE_NOT_REPAIRING 0 +#define VLDB_REPAIR_STATE_REPAIRING 1 +#define VLDB_REPAIR_STATE_COMPLETE 2 +#define VLDB_REPAIR_STATE_FAILED 3 + +/* Values for completion status field: */ +#define VLDB_REPAIR_STATUS_SUCCESS 1 +#define VLDB_REPAIR_STATUS_FAILED 2 +#define VLDB_REPAIR_STATUS_ABORTED 3 + +#ifdef __cplusplus +} +#endif + +#endif /* _VLDB_H_ */ diff --git a/include/nwnss/include/vldb.imp b/include/nwnss/include/vldb.imp new file mode 100644 index 0000000..1b1ccbb --- /dev/null +++ b/include/nwnss/include/vldb.imp @@ -0,0 +1,5 @@ + VLDBGetManagementContext + VLDBGetNumServers + VLDBGetServerList + VLDBWasRequestAborted + diff --git a/include/nwnss/include/vldbcfg.h b/include/nwnss/include/vldbcfg.h new file mode 100644 index 0000000..cca4f12 --- /dev/null +++ b/include/nwnss/include/vldbcfg.h @@ -0,0 +1,77 @@ +/**************************************************************************** + | + | (C) Copyright 1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | define VLDB repair constants + +-------------------------------------------------------------------------*/ + +#ifndef _VLDBCFG_H_ +#define _VLDBCFG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct VLDB_Config_Info_s +{ + LONG record_type; + LONG data_size; + void *data_ptr; +} VLDB_Config_Info_s; + +struct CfgFileRec_s +{ + LONG type; // This record's type + LONG length; // Length of following data (0 is valid!) + BYTE value[1]; // Actual size determined by length +}; + +/* Type definitions: */ +#define CFG_RECORD_TYPE_AUTO_START 0x0100 +#define CFG_RECORD_TYPE_NUM_THREADS 0x0101 + +#define CFG_RECORD_TYPE_LAST_LEVEL 0x0200 +#define CFG_RECORD_TYPE_START_TIME 0x0201 +#define CFG_RECORD_TYPE_END_TIME 0x0202 +#define CFG_RECORD_TYPE_LAST_STATUS 0x0203 +#define CFG_RECORD_TYPE_LAST_ERROR 0x0204 + +#define CFG_RECORD_TYPE_INC_NUM 0x0300 + +#define CFG_RECORD_TYPE_EOF 0xFFFF + +#ifdef __cplusplus +} +#endif + +#endif /* _VLDBCFG_H_ */ diff --git a/include/nwnss/include/vldbdefs.h b/include/nwnss/include/vldbdefs.h new file mode 100644 index 0000000..c1a8186 --- /dev/null +++ b/include/nwnss/include/vldbdefs.h @@ -0,0 +1,77 @@ +/*************************************************************************** + | + | (C) Copyright 1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) module + | + |-------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2006-12-12 01:39:13 +0530 (Tue, 12 Dec 2006) $ + | + | $RCSfile$ + | $Revision: 1738 $ + | + |-------------------------------------------------------------------------- + | This module is used to: + | Define constants & exports for the VLDB NLM + +------------------------------------------------------------------------*/ +#ifndef _VLDBDEFS_H_ +#define _VLDBDEFS_H_ + +#if zNETWARE +#ifndef _XUNICODE_H_ +# include +#endif +#endif +#ifndef _VDBE_H_ +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Defines */ +/* The default working directory for VLDB. This is where the database + * file is stored, as well as the VLDB configuration file. */ +#define DEFAULT_VLDB_DIR "/var/opt/novell/dfs" + +/* Function Prototypes */ +/* Get the management context for this server */ +extern STATUS VLDBGetManagementContext(size_t nchars,unicode_t *outputbuf); + +/* Get the number of servers that exist in this management context */ +extern SLONG VLDBGetNumServers(void); + +/* Get the list of servers for this management context */ +extern SLONG VLDBGetServerList(BOOL include_local, + LONG max_entries, + unicode_t **serverlist); + +/* Check for an abort request on an operation in progress */ +extern BOOL VLDBWasRequestAborted(VLDBAbortFlags_s *abort_info); + +#ifdef __cplusplus +} +#endif + +#endif /* _VLDBDEFS_H_ */ diff --git a/include/nwnss/include/vldberr.h b/include/nwnss/include/vldberr.h new file mode 100644 index 0000000..75c8791 --- /dev/null +++ b/include/nwnss/include/vldberr.h @@ -0,0 +1,102 @@ +/**************************************************************************** + | + | (C) Copyright 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) module + | + |--------------------------------------------------------------------------- + | + | $Author: nbalachandran $ + | $Date: 2007-08-13 14:05:48 +0530 (Mon, 13 Aug 2007) $ + | + | $RCSfile$ + | $Revision: 2136 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | define error codes for the VLDB + +-------------------------------------------------------------------------*/ + +#ifndef _VLDBERR_H_ +#define _VLDBERR_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* VLDB Error Codes */ +#define VLDB_SUCCESS (0) +#define VLDB_ERR_INVALID_INCARNATION_NUMBER (-1) +#define VLDB_ERR_INVALID_PARAMETERS (-2) +#define VLDB_ERR_REQUEST_WAS_ABORTED (-3) +#define VLDB_ERR_DATABASE_IS_CORRUPT (-4) +#define VLDB_ERR_INSUFFICIENT_RIGHTS (-5) +#define VLDB_ERR_TRANSACTION_NOT_FOUND (-6) +#define VLDB_ERR_COULD_NOT_CANCEL (-7) +#define VLDB_ERR_NO_MORE_ENTRIES (-8) +#define VLDB_ERR_ENTRY_NOT_FOUND (-9) +#define VLDB_ERR_ENTRY_ALREADY_EXISTS (-10) +#define VLDB_ERR_INVALID_OPCODE (-11) +#define VLDB_ERR_OPERATION_NOT_SUPPORTED (-12) +#define VLDB_ERR_INSUFFICIENT_RESOURCES (-13) +#define VLDB_ERR_MAX_SERVERS_EXCEEDED (-14) +#define VLDB_ERR_SERVICE_IS_STOPPED (-15) +#define VLDB_ERR_SERVICE_IS_NOT_STOPPED (-16) +#define VLDB_ERR_DATABASE_UNDER_REPAIR (-17) +#define VLDB_ERR_DATABASE_NOT_UNDER_REPAIR (-18) +#define VLDB_ERR_IMPOSSIBLE (-19) +#define VLDB_ERR_NOT_ALL_ENTRIES_DELETED (-20) + + +#define VLDB_ERR_SERVER_NOT_IN_MC (-31) + +/* VLRPC-specific errors: */ +#define VLDB_ERR_NO_MANAGEMENT_CONTEXT (-1000) +#define VLDB_ERR_CANNOT_CONNECT (-1001) +#define VLDB_ERR_CANNOT_DISCONNECT (-1002) +#define VLDB_ERR_NDS_ERROR (-1003) +#define VLDB_ERR_CANT_LOGIN_AS_SERVER (-1004) +#define VLDB_ERR_REQUEST_TIMED_OUT (-1005) +#define VLDB_ERR_SERVICE_IS_NOT_RUNNING (-1006) + +/* Repair-specific errors: */ +#define VLDB_ERR_CANT_CONNECT_TO_HIGHER_LEVEL_VLDB (-2000) +#define VLDB_ERR_CANT_READ_HIGHER_LEVEL_VLDB (-2001) + +/* Back-end DB-specific error codes: */ +#define VLDB_ERR_NO_SUCH_DATABASE (-3000) +#define VLDB_ERR_OUT_OF_DISK_SPACE (-3001) +#define VLDB_ERR_RECORD_IS_LOCKED (-3002) +#define VLDB_ERR_RECORD_NOT_LOCKED (-3003) +#define VLDB_ERR_DATABASE_IS_OPEN (-3004) +#define VLDB_ERR_NO_MEMORY (-3005) +#define VLDB_ERR_REPAIR_LEVEL_NOT_SUPPORTED (-3008) +#define VLDB_ERR_CANNOT_STOP_REPAIR (-3009) +#define VLDB_ERR_PRIMARY_DB_IS_OPEN (-3010) +#define VLDB_ERR_MAX_REPLICAS_DEFINED (-3011) +#define VLDB_ERR_RECORD_WAS_DELETED (-3012) +#define VLDB_ERR_NO_REPLICA (-3013) + +#ifdef __cplusplus +} +#endif + +#endif /* _VLDBERR_H_ */ diff --git a/include/nwnss/include/vldbmsg.h b/include/nwnss/include/vldbmsg.h new file mode 100644 index 0000000..60b6918 --- /dev/null +++ b/include/nwnss/include/vldbmsg.h @@ -0,0 +1,738 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | define VLDB message formats, opcodes, and error codes + +-------------------------------------------------------------------------*/ + +#ifndef _VLDBMSG_H_ +#define _VLDBMSG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_NCPLTYPE_H_) || defined(WIN32) +#define UNSIGNED_16 WORD +#define UNSIGNED_32 UINT32 +#define SIGNED_32 INT32 +#define UNSIGNED_64 UINT64 +#define SIGNED_64 INT64 +#define UNICODE_CHAR WCHAR +#define GUID_t GUID +#else +#include + +#define UNSIGNED_16 WORD +#define UNSIGNED_32 LONG +#define SIGNED_32 SLONG +#define UNICODE_CHAR unicode_t +#endif + +#define VLDB_MSG_PRIMARY_VOLUME_NAME_SIZE (sizeof (GUID_t)) + +/*------------------------------------------------------------------------- + * Message opcodes + *-------------------------------------------------------------------------*/ +#define VLDB_MSG_OP_INVALID 0x00 +#define VLDB_MSG_OP_PROBE 0x01 +#define VLDB_MSG_OP_ABORT 0x02 +#define VLDB_MSG_OP_STATUS 0x03 + +#define VLDB_MSG_OP_CREATE 0x10 +#define VLDB_MSG_OP_DELETE 0x11 +#define VLDB_MSG_OP_ADD 0x12 +#define VLDB_MSG_OP_REMOVE 0x13 +#define VLDB_MSG_OP_MODIFY 0x14 + +#define VLDB_MSG_OP_LOOKUP 0x20 +#define VLDB_MSG_OP_ENUMERATE 0x21 + +#define VLDB_MSG_OP_GETSTATS 0x30 +#define VLDB_MSG_OP_SETCONFIG 0x31 +#define VLDB_MSG_OP_GETCONFIG 0x32 +#define VLDB_MSG_OP_START_SERVICE 0x33 +#define VLDB_MSG_OP_STOP_SERVICE 0x34 +#define VLDB_MSG_OP_INITIALIZE_DB 0x35 +#define VLDB_MSG_OP_ACTIVATE_DB 0x36 + +#define VLDB_MSG_OP_CALLBACKS_DROPPED 0x40 +#define VLDB_MSG_OP_REPLICA_CHANGE 0x41 + +#define VLDB_MSG_OP_START_REPAIR 0x50 +#define VLDB_MSG_OP_STOP_REPAIR 0x51 +#define VLDB_MSG_OP_GET_REPAIR_STATUS 0x52 + +/*------------------------------------------------------------------------- + * Quality of Service Options + *-------------------------------------------------------------------------*/ +#define VLDB_MSG_QOS_NORMAL 0x0000 +#define VLDB_MSG_QOS_BACKGROUND 0x0001 +#define VLDB_MSG_QOS_REPAIR 0x4000 +#define VLDB_MSG_QOS_AUTH_BLOB 0x2000 /* User/password supplied as blob */ + +/*------------------------------------------------------------------------- + * Common Request header + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_Request_s +{ + UNSIGNED_16 opcode; /* Opcode of this request */ + UNSIGNED_16 qos; /* Requested quality of service */ + UNSIGNED_32 transaction_id; /* Transaction ID of this request */ + UNSIGNED_32 requester_incarnation; /* Incarnation # of requesting node */ + UNSIGNED_32 responder_incarnation; /* Expected incarnation # of responder */ +} VLDB_MSG_Request_s; + +/*------------------------------------------------------------------------- + * Common Response header + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_Response_s +{ + SIGNED_32 status; /* SUCCESS/Error code */ + UNSIGNED_32 transaction_id; /* Matches request transaction ID */ + UNSIGNED_32 requester_incarnation; /* Incarnation # of requesting node */ + UNSIGNED_32 responder_incarnation; /* Incarnation # of responding node */ +} VLDB_MSG_Response_s; + +/*------------------------------------------------------------------------- + * PROBE OPERATION + * Note: the version number in the response is encoded in a LONG but + * really consists of 3 fields: byte 0 = 'v', byte 1 = Major Version #, + * bytes 2/3 (treated as an UNSIGNED_16) = Minor version # + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_ProbeRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_PROBE */ +} VLDB_MSG_ProbeRequest_s; + +typedef struct VLDB_MSG_ProbeResponse_s +{ + VLDB_MSG_Response_s hdr; + UNSIGNED_32 version; /* Protocol Version */ + UNSIGNED_32 max_buffer_size; /* Maximum receive buffer size (bytes) */ +} VLDB_MSG_ProbeResponse_s; + +#define VLDB_CURRENT_PROTOCOL_VERSION 0x00000176 /* v1.00 */ + +/*------------------------------------------------------------------------- + * ABORT OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_AbortRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_ABORT */ + UNSIGNED_32 abort_tid; /* tid of request to be aborted */ +} VLDB_MSG_AbortRequest_s; + +typedef struct VLDB_MSG_AbortResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_AbortResponse_s; + +/*------------------------------------------------------------------------- + * REQUEST STATUS OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_StatusRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_STATUS */ + UNSIGNED_32 request_tid; /* tid of original request */ +} VLDB_MSG_StatusRequest_s; + +typedef struct VLDB_MSG_StatusResponse_s +{ + VLDB_MSG_Response_s hdr; + UNSIGNED_32 percent_complete; /* Estimated % complete (0-100) */ +} VLDB_MSG_StatusResponse_s; + +/*------------------------------------------------------------------------- + * CREATE ENTRY OPERATION + * Note: This structure cannot be used to access the servers fields + * directly! You must use the secondary_name_len value to find out where + * the first server entry actually starts, and use the name_length field + * within each server instance to find out where the next one starts! + *-------------------------------------------------------------------------*/ +/* Note: if this structure ever changes, the ServerInfo_s structure defined */ +/* in vdbe.h must be changed to match!!! */ +typedef struct VLDB_MSG_InstanceInfo_s +{ + UNSIGNED_32 volume_type; /* The type of this volume */ + UNICODE_CHAR phys_name[16]; /* The physical volume name */ + UNSIGNED_32 name_length; /* Length of name only (in bytes) */ + UNICODE_CHAR server_name[1]; +} VLDB_MSG_InstanceInfo_s; + +typedef struct VLDB_MSG_CreateRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_CREATE */ + UNSIGNED_32 num_servers; /* Number of servers in list */ + UNSIGNED_32 arg2; /* reserved */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + BYTE primary_name[VLDB_MSG_PRIMARY_VOLUME_NAME_SIZE]; + VLDB_MSG_InstanceInfo_s servers[1]; + /* Actual number specified by num_servers */ +} VLDB_MSG_CreateRequest_s; + +typedef struct VLDB_MSG_CreateResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_CreateResponse_s; + +/*------------------------------------------------------------------------- + * DELETE ENTRY OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_DeleteRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_DELETE */ + UNSIGNED_32 count; /* Primary Name Count */ + UNSIGNED_32 arg2; /* reserved */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + BYTE primary_name[VLDB_MSG_PRIMARY_VOLUME_NAME_SIZE]; + /* Additional Primary Name entries go here */ + /* Actual # specified in count field */ +} VLDB_MSG_DeleteRequest_s; + +typedef struct VLDB_MSG_DeleteResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_DeleteResponse_s; + +/*------------------------------------------------------------------------- + * UPDATE ENTRY:ADD OPERATION + * Note: This structure cannot be used to access the servers fields + * directly! You must use the secondary_name_len value to find out where + * the first server entry actually starts, and use the name_length field + * within each server instance to find out where the next one starts! + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_AddRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_ADD */ + UNSIGNED_32 num_servers; /* Number of servers in list */ + UNSIGNED_32 arg2; /* reserved */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + BYTE primary_name[VLDB_MSG_PRIMARY_VOLUME_NAME_SIZE]; + VLDB_MSG_InstanceInfo_s servers[1]; + /* Actual number specified by num_servers */ +} VLDB_MSG_AddRequest_s; + +typedef struct VLDB_MSG_AddResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_AddResponse_s; + +/*------------------------------------------------------------------------- + * UPDATE ENTRY:REMOVE OPERATION + * Note: This structure cannot be used to access the servers fields + * directly! You must use the secondary_name_len value to find out where + * the first server entry actually starts, and use the name_length field + * within each server instance to find out where the next one starts! + * Note: The volume instance type field is ignored. + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_RemoveRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_REMOVE */ + UNSIGNED_32 num_servers; /* Number of servers in list */ + UNSIGNED_32 arg2; /* reserved */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + BYTE primary_name[VLDB_MSG_PRIMARY_VOLUME_NAME_SIZE]; + VLDB_MSG_InstanceInfo_s servers[1]; + /* Actual number specified by num_servers */ +} VLDB_MSG_RemoveRequest_s; + +typedef struct VLDB_MSG_RemoveResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_RemoveResponse_s; + +/*------------------------------------------------------------------------- + * UPDATE ENTRY:MODIFY OPERATION + * Note: This structure cannot be used to access the servers fields + * directly! You must use the secondary_name_len value to find out where + * the first server entry actually starts, and use the name_length field + * within each server instance to find out where the next one starts! + * Note: The volume instance type field is ignored. + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_ModifyRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_MODIFY */ + UNSIGNED_32 num_servers; /* Number of servers in list */ + UNSIGNED_32 arg2; /* reserved */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + BYTE primary_name[VLDB_MSG_PRIMARY_VOLUME_NAME_SIZE]; + VLDB_MSG_InstanceInfo_s servers[1]; + /* Actual number specified by num_servers */ +} VLDB_MSG_ModifyRequest_s; + +typedef struct VLDB_MSG_ModifyResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_ModifyResponse_s; + +/*------------------------------------------------------------------------- + * LOOKUP ENTRY OPERATION + * Note: The response structure cannot be used to access the servers + * fields directly! You must use the secondary_name_len value to find out + * where the first server entry actually starts, and use the name_length + * field within each server instance to find out where the next one starts! + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_LookupRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_LOOKUP */ + UNSIGNED_32 max_servers; /* Max server entries to include in reply */ + UNSIGNED_32 flags; /* Flags (defined below) */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + BYTE primary_name[VLDB_MSG_PRIMARY_VOLUME_NAME_SIZE]; +} VLDB_MSG_LookupRequest_s; + +/* Values for flags field */ +#define VLDB_MSG_NO_CALLBACK_REQUEST 0x00 +#define VLDB_MSG_CALLBACK_REQUEST 0x01 + +typedef struct VLDB_MSG_LookupResponse_s +{ + VLDB_MSG_Response_s hdr; + UNSIGNED_32 num_servers; /* Number of servers in list */ + UNSIGNED_32 total_servers; /* Number of servers supporting this volume */ + UNSIGNED_32 flags; /* Flags (defined below) */ + UNSIGNED_32 arg4; /* reserved */ + BYTE primary_name[VLDB_MSG_PRIMARY_VOLUME_NAME_SIZE]; + VLDB_MSG_InstanceInfo_s servers[1]; + /* Actual number specified by num_servers */ +} VLDB_MSG_LookupResponse_s; + +#define VLDB_MSG_CALLBACK_NOT_GRANTED 0x00 +#define VLDB_MSG_CALLBACK_GRANTED 0x01 + +/*------------------------------------------------------------------------- + * ENUMERATE ENTRIES OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_EnumerateRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_ENUMERATE */ + UNSIGNED_32 cookie; /* Indicates where we are in the list */ + UNSIGNED_32 max_entries; /* max # entries to return */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + UNSIGNED_32 server_name_len; /* Length of (optional) server name (in bytes) */ + UNICODE_CHAR server_name[1]; +} VLDB_MSG_EnumerateRequest_s; + +/* Note: if this structure ever changes, the VolumeInfo_s structure defined */ +/* in vdbe.h must be changed to match!!! */ +typedef struct VLDB_MSG_VolumeInfo_s +{ + BYTE primary_name[VLDB_MSG_PRIMARY_VOLUME_NAME_SIZE]; +} VLDB_MSG_VolumeInfo_s; + +typedef struct VLDB_MSG_EnumerateResponse_s +{ + VLDB_MSG_Response_s hdr; + UNSIGNED_32 cookie; /* New cookie for next call */ + UNSIGNED_32 num_entries; /* Number of volumes returned */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + VLDB_MSG_VolumeInfo_s volumes[1]; + /* Actual number specified by num_entries */ +} VLDB_MSG_EnumerateResponse_s; + +#define VLDB_MSG_ENUMERATE_HDR_SIZE (sizeof(VLDB_MSG_EnumerateResponse_s) - sizeof(VLDB_MSG_VolumeInfo_s)) + +/*------------------------------------------------------------------------- + * GET STATISTICS OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_GetStatsRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_GETSTATS */ +} VLDB_MSG_GetStatsRequest_s; + +typedef struct VLDB_MSG_Stats_s +{ + UNSIGNED_32 type; /* This value's type (defined below) */ + UNSIGNED_32 value; +} VLDB_MSG_Stats_s; + +/* Defined types */ +#define VLDB_MSG_STATS_CREATE_COUNT 1 +#define VLDB_MSG_STATS_DELETE_COUNT 2 +#define VLDB_MSG_STATS_MODIFY_COUNT 3 +#define VLDB_MSG_STATS_LOOKUP_COUNT 4 +#define VLDB_MSG_STATS_TOTAL_REQUESTS 5 +#define VLDB_MSG_STATS_ERROR_COUNT 6 +#define VLDB_MSG_STATS_AUTH_ERRORS 7 +#define VLDB_MSG_STATS_QUEUE_LENGTH 8 +#define VLDB_MSG_STATS_AVE_CREATE_TIME 9 +#define VLDB_MSG_STATS_AVE_DELETE_TIME 10 +#define VLDB_MSG_STATS_AVE_MODIFY_TIME 11 +#define VLDB_MSG_STATS_AVE_LOOKUP_TIME 12 +#define VLDB_MSG_STATS_AVE_QUEUED_TIME 13 + +#define VLDB_MSG_STATS_CURRENT_STATE 100 +#define VLDB_MSG_STATS_RELEASE_LEVEL 101 +#define VLDB_MSG_STATS_BUILD_DATE 102 +#define VLDB_MSG_STATS_LOAD_TIME 103 +#define VLDB_MSG_STATS_AUTO_RESTART 104 +#define VLDB_MSG_STATS_NUM_THREADS 105 + +/* Values for Current State */ +/*** MOVE THESE TO ANOTHER .H FILE!!! ***/ +#define VLDB_STATE_INITIALIZING 0 /* Should never be returned in msg */ +#define VLDB_STATE_STOPPED 1 +#define VLDB_STATE_RUNNING 2 +#define VLDB_STATE_BROKEN 3 +#define VLDB_STATE_UNDER_REPAIR 4 + +typedef struct VLDB_MSG_GetStatsResponse_s +{ + VLDB_MSG_Response_s hdr; + UNSIGNED_32 num_entries; /* Number of list entries */ + UNSIGNED_32 arg2; /* reserved */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + VLDB_MSG_Stats_s stats[1]; /* The statistics info (actual number */ + /* of entries specified by num_entries) */ +} VLDB_MSG_GetStatsResponse_s; + +/*------------------------------------------------------------------------- + * SET CONFIGURATION PARAMETERS OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_TLV_s +{ + UNSIGNED_32 type; + UNSIGNED_32 length; + BYTE value[1]; +} VLDB_MSG_TLV_s; + +/* Types */ +#define VLDB_CONFIG_TYPE_PAD 0 +#define VLDB_CONFIG_TYPE_NUMTHREADS 1 + +typedef struct VLDB_MSG_SetConfigRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_SETCONFIG */ + UNSIGNED_32 num_entries; /* Number of (t/l/v) entries in list */ + UNSIGNED_32 arg2; /* reserved */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + VLDB_MSG_TLV_s tlv; /* list of config parameters */ +} VLDB_MSG_SetConfigRequest_s; + +typedef struct VLDB_MSG_SetConfigResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_SetConfigResponse_s; + +/*------------------------------------------------------------------------- + * GET CONFIGURATION PARAMETERS OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_GetConfigRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_GETCONFIG */ +} VLDB_MSG_GetConfigRequest_s; + +typedef struct VLDB_MSG_GetConfigResponse_s +{ + VLDB_MSG_Response_s hdr; + UNSIGNED_32 num_entries; /* Number of (t/l/v) entries in list */ + UNSIGNED_32 arg2; /* reserved */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + VLDB_MSG_TLV_s tlv; /* list of config parameters */ +} VLDB_MSG_GetConfigResponse_s; +#define VLDB_MSG_GETCONFIG_HDR_SIZE (sizeof(VLDB_MSG_GetConfigResponse_s) - sizeof(VLDB_MSG_TLV_s)) + +/*------------------------------------------------------------------------- + * START SERVICE OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_StartServiceRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_START_SERVICE */ + UNSIGNED_32 flags; +} VLDB_MSG_StartServiceRequest_s; + +typedef struct VLDB_MSG_StartServiceResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_StartServiceResponse_s; + +/* Flags */ +#define VLDB_START_SERVICE_TEMPORARY 0x01 + +/*------------------------------------------------------------------------- + * STOP SERVICE OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_StopServiceRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_STOP_SERVICE */ + UNSIGNED_32 flags; +} VLDB_MSG_StopServiceRequest_s; + +typedef struct VLDB_MSG_StopServiceResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_StopServiceResponse_s; + +/* Flags */ +#define VLDB_STOP_SERVICE_PERMANENTLY 0x01 + +/*------------------------------------------------------------------------- + * ACTIVATE DATABASE OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_ActivateDBRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_ACTIVATE_DB */ +} VLDB_MSG_ActivateDBRequest_s; + +typedef struct VLDB_MSG_ActivateDBResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_ActivateDBResponse_s; + +/*------------------------------------------------------------------------- + * CALLBACKS DROPPED OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_CallbacksDroppedRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_CALLBACKS_DROPPED */ + UNSIGNED_32 num_entries; /* Number of primary names in list */ + UNSIGNED_32 arg2; /* reserved */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + BYTE primary_name[VLDB_MSG_PRIMARY_VOLUME_NAME_SIZE]; + /* First primary volume name */ +} VLDB_MSG_CallbacksDroppedRequest_s; + +typedef struct VLDB_MSG_CallbacksDroppedResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_CallbacksDroppedResponse_s; + +/*------------------------------------------------------------------------- + * REPLICA CHANGE OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_ReplicaChangeRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_REPLICA_CHANGE */ + UNSIGNED_32 flags; /* this server was added or removed */ + UNSIGNED_32 arg2; /* reserved */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + UNSIGNED_32 server_name_len; /* Length of server name (in bytes) */ + UNICODE_CHAR server_name[1]; +} VLDB_MSG_ReplicaChangeRequest_s; + +/* Flags */ +#define VLDB_ADD_REPLICA 0x00 +#define VLDB_DELETE_REPLICA 0x01 + +typedef struct VLDB_MSG_ReplicaChangeResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_ReplicaChangeResponse_s; + +/*------------------------------------------------------------------------- + * START REPAIR OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_StartRepairRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_START_REPAIR */ + UNSIGNED_32 level; /* Requested repair level */ + /* ----- Optional fields added for Nakoma ----- */ + /* ----- If not included, will continue to login ----- */ + /* ----- as file server when running repair ----- */ + UNSIGNED_32 reserved; /* Reserved (must be zero) */ + UNSIGNED_32 name_len; /* Length of user name (in bytes) */ + UNICODE_CHAR user_name[1]; /* User name or blob */ + /* actual length specified by name_len */ + UNSIGNED_32 pw_len; /* Length of password (in bytes) MUST COMPUTE OFFSET! */ + BYTE password[1]; /* Password (if not blob) MUST COMPUTE OFFSET! */ + /* actual length specified by pw_len */ +} VLDB_MSG_StartRepairRequest_s; + +typedef struct VLDB_MSG_StartRepairResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_StartRepairResponse_s; + +/* Repair Levels: */ +#define VLDB_MSG_REPAIR_NONE 0 /* Reserved */ +#define VLDB_MSG_REPAIR_LOW_LEVEL 1 /* Try to fix bad file data */ +#define VLDB_MSG_REPAIR_REFRESH 2 /* Get DB from another replica */ +#define VLDB_MSG_REPAIR_REBUILD 3 /* Rebuild from NDS */ + +/*------------------------------------------------------------------------- + * STOP REPAIR OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_StopRepairRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_STOP_REPAIR */ +} VLDB_MSG_StopRepairRequest_s; + +typedef struct VLDB_MSG_StopRepairResponse_s +{ + VLDB_MSG_Response_s hdr; +} VLDB_MSG_StopRepairResponse_s; + +/*------------------------------------------------------------------------- + * GET REPAIR STATUS OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VLDB_MSG_RepairStatusRequest_s +{ + VLDB_MSG_Request_s hdr; /* opcode = VLDB_MSG_OP_GET_REPAIR_STATUS */ +} VLDB_MSG_RepairStatusRequest_s; + +typedef struct VLDB_MSG_RepairStatusResponse_s +{ + VLDB_MSG_Response_s hdr; + UNSIGNED_32 state; /* Current repair state */ + UNSIGNED_32 pct_complete; /* estimated % complete */ + UNSIGNED_32 level; /* repair level */ + UNSIGNED_32 start_time; /* repair start time */ + UNSIGNED_32 end_time; /* last repair completion time */ + UNSIGNED_32 last_status; + UNSIGNED_32 last_error; +} VLDB_MSG_RepairStatusResponse_s; + +/*------------------------------------------------------------------------- + * All VLDB request messages + *-------------------------------------------------------------------------*/ +typedef union VLDB_MSG_Request_u +{ + VLDB_MSG_Request_s generic; + VLDB_MSG_ProbeRequest_s probe; + VLDB_MSG_AbortRequest_s abort; + VLDB_MSG_StatusRequest_s status; + VLDB_MSG_CreateRequest_s create; + VLDB_MSG_AddRequest_s add; + VLDB_MSG_RemoveRequest_s remove; + VLDB_MSG_ModifyRequest_s modify; + VLDB_MSG_LookupRequest_s lookup; + VLDB_MSG_EnumerateRequest_s enumerate; + VLDB_MSG_GetStatsRequest_s getstats; + VLDB_MSG_SetConfigRequest_s setconfig; + VLDB_MSG_GetConfigRequest_s getconfig; + VLDB_MSG_StartServiceRequest_s start; + VLDB_MSG_StopServiceRequest_s stop; + VLDB_MSG_ActivateDBRequest_s activate; + VLDB_MSG_CallbacksDroppedRequest_s callbacks_dropped; + VLDB_MSG_ReplicaChangeRequest_s replica_change; + VLDB_MSG_StartRepairRequest_s start_repair; + VLDB_MSG_StopRepairRequest_s stop_repair; + VLDB_MSG_RepairStatusRequest_s repair_status; +} VLDB_MSG_Request_u; + +/*------------------------------------------------------------------------- + * All VLDB response messages + *-------------------------------------------------------------------------*/ +typedef union VLDB_MSG_Response_u +{ + VLDB_MSG_Response_s generic; + VLDB_MSG_ProbeResponse_s probe; + VLDB_MSG_AbortResponse_s abort; + VLDB_MSG_StatusResponse_s status; + VLDB_MSG_CreateResponse_s create; + VLDB_MSG_AddResponse_s add; + VLDB_MSG_RemoveResponse_s remove; + VLDB_MSG_ModifyResponse_s modify; + VLDB_MSG_LookupResponse_s lookup; + VLDB_MSG_EnumerateResponse_s enumerate; + VLDB_MSG_GetStatsResponse_s getstats; + VLDB_MSG_SetConfigResponse_s setconfig; + VLDB_MSG_GetConfigResponse_s getconfig; + VLDB_MSG_StartServiceResponse_s start; + VLDB_MSG_StopServiceResponse_s stop; + VLDB_MSG_ActivateDBResponse_s activate; + VLDB_MSG_CallbacksDroppedResponse_s callbacks_dropped; + VLDB_MSG_ReplicaChangeResponse_s replica_change; + VLDB_MSG_StartRepairResponse_s start_repair; + VLDB_MSG_StopRepairResponse_s stop_repair; + VLDB_MSG_RepairStatusResponse_s repair_status; +} VLDB_MSG_Response_u; + +/*------------------------------------------------------------------------- + * All VLDB messages + *-------------------------------------------------------------------------*/ +typedef union VLDB_MSG_Message_u +{ + VLDB_MSG_Request_u request; + VLDB_MSG_Response_u response; + VLDB_MSG_ProbeRequest_s probe_request; + VLDB_MSG_ProbeResponse_s probe_response; + VLDB_MSG_AbortRequest_s abort_request; + VLDB_MSG_AbortResponse_s abort_response; + VLDB_MSG_StatusRequest_s status_request; + VLDB_MSG_StatusResponse_s status_response; + VLDB_MSG_CreateRequest_s create_request; + VLDB_MSG_CreateResponse_s create_response; + VLDB_MSG_AddRequest_s add_request; + VLDB_MSG_AddResponse_s add_response; + VLDB_MSG_RemoveRequest_s remove_request; + VLDB_MSG_RemoveResponse_s remove_response; + VLDB_MSG_ModifyRequest_s modify_request; + VLDB_MSG_ModifyResponse_s modify_response; + VLDB_MSG_LookupRequest_s lookup_request; + VLDB_MSG_LookupResponse_s lookup_response; + VLDB_MSG_EnumerateRequest_s enumerate_request; + VLDB_MSG_EnumerateResponse_s enumerate_response; + VLDB_MSG_GetStatsRequest_s getstats_request; + VLDB_MSG_GetStatsResponse_s getstats_response; + VLDB_MSG_SetConfigRequest_s setconfig_request; + VLDB_MSG_SetConfigResponse_s setconfig_response; + VLDB_MSG_GetConfigRequest_s getconfig_request; + VLDB_MSG_GetConfigResponse_s getconfig_response; + VLDB_MSG_StartServiceRequest_s start_request; + VLDB_MSG_StartServiceResponse_s start_response; + VLDB_MSG_StopServiceRequest_s stop_request; + VLDB_MSG_StopServiceResponse_s stop_response; + VLDB_MSG_ActivateDBRequest_s activate_request; + VLDB_MSG_ActivateDBResponse_s activate_response; + VLDB_MSG_CallbacksDroppedRequest_s callbacks_dropped_request; + VLDB_MSG_CallbacksDroppedResponse_s callbacks_dropped_response; + VLDB_MSG_ReplicaChangeRequest_s replica_change_request; + VLDB_MSG_ReplicaChangeResponse_s replica_change_response; + VLDB_MSG_StartRepairRequest_s start_repair_request; + VLDB_MSG_StartRepairResponse_s start_repair_response; + VLDB_MSG_StopRepairRequest_s stop_repair_request; + VLDB_MSG_StopRepairResponse_s stop_repair_response; + VLDB_MSG_RepairStatusRequest_s repair_status_request; + VLDB_MSG_RepairStatusResponse_s repair_status_response; +} VLDB_MSG_Message_u; + +#ifdef __cplusplus +} +#endif + +#endif /* _VLDBMSG_H_ */ diff --git a/include/nwnss/include/vldbrpr.h b/include/nwnss/include/vldbrpr.h new file mode 100644 index 0000000..da070da --- /dev/null +++ b/include/nwnss/include/vldbrpr.h @@ -0,0 +1,67 @@ +/**************************************************************************** + | + | (C) Copyright 1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File System (DFS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | define VLDB repair constants + +-------------------------------------------------------------------------*/ + +#ifndef _VLDBRPR_H_ +#define _VLDBRPR_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Repair Levels: */ +#define VLDB_REPAIR_LEVEL_NONE 0 // Reserved +#define VLDB_REPAIR_LEVEL_LOW_LEVEL 1 // Try to fix bad file data +#define VLDB_REPAIR_LEVEL_REFRESH 2 // Get DB from another replica +#define VLDB_REPAIR_LEVEL_REBUILD 3 // Rebuild from NDS + +/* Values for repair state: */ +#define VLDB_REPAIR_STATE_NOT_REPAIRING 0 +#define VLDB_REPAIR_STATE_REPAIRING 1 +#define VLDB_REPAIR_STATE_COMPLETE 2 +#define VLDB_REPAIR_STATE_FAILED 3 + +/* Values for completion status field: */ +#define VLDB_REPAIR_STATUS_SUCCESS 1 +#define VLDB_REPAIR_STATUS_FAILED 2 +#define VLDB_REPAIR_STATUS_ABORTED 3 +#define VLDB_REPAIR_STATUS_COMPLETED_WITH_ERRORS 4 + +#ifdef __cplusplus +} +#endif + +#endif /* _VLDBRPR_H_ */ diff --git a/include/nwnss/include/vlrpc.h b/include/nwnss/include/vlrpc.h new file mode 100644 index 0000000..3efca63 --- /dev/null +++ b/include/nwnss/include/vlrpc.h @@ -0,0 +1,184 @@ +/**************************************************************************** + | + | (C) Copyright 2000, 2002, 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | define remote procedure call parameters & functions + +-------------------------------------------------------------------------*/ + +#ifndef _VLRPC_H_ +#define _VLRPC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Structure to hold Management Context information */ +struct VLDBMCInfo +{ + unicode_t *mcName; /* NDS name of Management Context */ + unicode_t *backEndName; /* Name of back-end database for this M.C. */ + unicode_t *localServer; /* NDS name of this server */ + BOOL isVLDBServer; /* TRUE if the local server is a VLDB server */ + NINT serverCount; /* Number of VLDB Servers for this M.C. */ + unicode_t *serverName[1]; /* Actual array size given by serverCount */ +}; + +/* Structure to hold statistics information */ +struct VLDBStatistics +{ + LONG current_state; /* VLDB service's state (running, stopped, ...) */ + LONG release_level; /* Software version (Message Layer) */ + LONG build_date; /* Module build date (UTC time) */ + LONG load_time; /* Service start time (UTC time) */ + LONG auto_start; /* Auto start on load or not */ + LONG num_threads; /* # of running processing threads */ + LONG create_count; /* # volumes created since NLM load */ + LONG delete_count; /* # volumes deleted since NLM load */ + LONG modify_count; /* # volume entries modified " " " */ + LONG lookup_count; /* # of successful LOOKUP requests */ + LONG total_requests; /* total # of requests received */ + LONG error_count; /* total invalid requests received */ + LONG auth_errors; /* # of authentication errors */ + LONG backend_release; /* Software version (back-end DB) */ +}; + +/* Structure to hold configuration information */ +struct VLDBConfig +{ + LONG flags; /* See below */ + LONG num_threads; /* Requested number of processing threads */ +}; + +/* Flags: */ +#define VLDB_CONFIG_FLAG_NUM_THREADS 0x00000001 + +/* Structure to hold Repair Status information */ +/* level, state and status field values are defined in vldbrpr.h */ +struct VLDBRepairStatus +{ + LONG state; /* Repair state (repair running or not) */ + LONG pct_complete; /* Estimated % complete of repair-in-progress */ + LONG level; /* Current or last repair level */ + LONG start_time; /* Time current or last repair was started (UTC time) */ + LONG end_time; /* Time last repair completed (UTC time) */ + LONG last_status; /* Whether last repair succeeded, failed, or was cancelled */ + LONG last_error; /* Completion code of last repair */ +}; + +/* Function prototypes */ +extern STATUS VLDB_Connect(unicode_t *managementContext, + void **handle, + unicode_t *userName, + char *password); +extern STATUS VLDB_ConnectToHost(unicode_t *server, + void **handle, + unicode_t *userName, + char *password); +extern STATUS VLDB_Disconnect(void *session); +extern STATUS VLDB_CreateVolume(void *session, + BYTE *primaryVolumeName, + unicode_t *serverName, + unicode_t *physName); +extern STATUS VLDB_DeleteVolume(void *session, + BYTE *primaryVolumeName); +extern STATUS VLDB_Probe(void *session,LONG *version,LONG *maxbuf,LONG *incnum); +extern STATUS VLDB_AddVolumeServer(void *session, + BYTE *primaryVolumeName, + unicode_t *serverName, + unicode_t *physName); +extern STATUS VLDB_RemoveVolumeServer(void *session, + BYTE *primaryVolumeName, + unicode_t *serverName, + unicode_t *physName); +extern STATUS VLDB_LookupVolume(void *session, + BYTE *primaryVolumeName, + NINT *numEntries, + unicode_t **serverName, + unicode_t **physName); +extern STATUS VLDB_EnumerateVolumes(void *session, + unicode_t *server_name, + LONG *cookie, + LONG *numEntries, + BYTE *volumeGUIDs[]); + +extern STATUS VLDB_GetStatistics(void *session, + struct VLDBStatistics *stats); + +extern STATUS VLDB_GetConfig(void *session, + struct VLDBConfig *config); + +extern STATUS VLDB_GetDBLocation(void *handle,unicode_t *buf); + +extern STATUS VLDB_SetConfig(void *session, + struct VLDBConfig *config); + +extern STATUS VLDB_SetDBLocation(void *handle,unicode_t *buf); + +extern STATUS VLDB_StartService(void *session,LONG flags); + +extern STATUS VLDB_StopService(void *session,LONG flags); + +extern STATUS VLDB_StartRepair(void *session,LONG level); + +extern STATUS VLDB_StartRepairWithAuth(void *session, + LONG level, + unicode_t *userName, + char *password); + +extern STATUS VLDB_StartRepairAuthBlob(void *session, + LONG level, + NINT blobLen, + char *blob); + +extern STATUS VLDB_StopRepair(void *session); + +extern STATUS VLDB_GetRepairStatus(void *session, + struct VLDBRepairStatus *status); + +extern STATUS VLDB_ActivateDatabase(void *session); + +extern STATUS VLDB_ReplicaChange(void *session, + LONG flags, + unicode_t *server_name); + +extern STATUS VLDB_SetQoS(void *handle,WORD qos); + +extern STATUS VLDB_GetMCInfo(struct VLDBMCInfo **info); + +extern STATUS VLDB_FreeMCInfo(struct VLDBMCInfo *info); + +#ifdef __cplusplus +} +#endif + +#endif /* _VLRPC_H_ */ diff --git a/include/nwnss/include/vlrpc.imp b/include/nwnss/include/vlrpc.imp new file mode 100644 index 0000000..8a9f8ec --- /dev/null +++ b/include/nwnss/include/vlrpc.imp @@ -0,0 +1,28 @@ + VLDB_Connect + VLDB_ConnectToHost + VLDB_Disconnect + VLDB_Probe + VLDB_CreateVolume + VLDB_DeleteVolume + VLDB_DeleteVolumeList + VLDB_AddVolumeServer + VLDB_RemoveVolumeServer + VLDB_LookupVolume + VLDB_EnumerateVolumes + VLDB_GetStatistics + VLDB_GetConfig + VLDB_SetConfig + VLDB_GetDBLocation + VLDB_SetDBLocation + VLDB_StartService + VLDB_StopService + VLDB_StartRepair + VLDB_StartRepairWithAuth + VLDB_StartRepairAuthBlob + VLDB_StopRepair + VLDB_GetRepairStatus + VLDB_ActivateDatabase + VLDB_ReplicaChange + VLDB_SetQoS + VLDB_GetMCInfo + VLDB_FreeMCInfo diff --git a/include/nwnss/include/vlrprif.h b/include/nwnss/include/vlrprif.h new file mode 100644 index 0000000..cc4bacc --- /dev/null +++ b/include/nwnss/include/vlrprif.h @@ -0,0 +1,123 @@ +/**************************************************************************** + | + | (C) Copyright 2002, 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-30 12:40:58 -0700 (Thu, 30 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | define the interface between VLMSG.NLM & VLRPR.NLM + +-------------------------------------------------------------------------*/ + +#ifndef _VLRPRIF_H_ +#define _VLRPRIF_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* This structure is used to pass information to VLRPR.NLM from VLMSG.NLM */ +struct VLDBRepairInfo_s +{ + LONG repairLevel; + LONG flags; + LONG userNameLen; + LONG passwordLen; + unicode_t userName[MAX_DN_BYTES]; + char password[MAX_DN_BYTES]; +}; +/* Values for flags field: */ +#define VLDB_REPAIR_FLAG_LOGIN_AS_SERVER 1 +#define VLDB_REPAIR_FLAG_AUTH_BLOB 2 + + +#if zLINUX +#define VLRPR_MSG_Q_ID ('R' | ('P' << 8) | ('R' << 16) | ('Q' << 24)) +#define VLRPR_STATUS_Q_ID ('R' | ('P' << 8) | ('S' << 16) | ('Q' << 24)) +#define MSG_TYPE_REPAIR_INFO ('I' | ('N' << 8) | ('F' << 16) | ('O' << 24)) +#define MSG_TYPE_REPAIR_COMPLETE ('D' | ('O' << 8) | ('N' << 16) | ('E' << 24)) +#define MSG_TYPE_STATUS_REQ ('S' | ('T' << 8) | ('S' << 16) | ('Q' << 24)) +#define MSG_TYPE_STATUS_REPLY ('S' | ('T' << 8) | ('S' << 16) | ('Y' << 24)) +#define MSG_TYPE_STOPRPR_REQ ('S' | ('T' << 8) | ('R' << 16) | ('Q' << 24)) +#define MSG_TYPE_STOPRPR_REPLY ('S' | ('T' << 8) | ('R' << 16) | ('Y' << 24)) + +struct ipc_request +{ + long mtype; + struct VLDBRepairInfo_s info; +}; + +struct ipc_response +{ + long mtype; + LONG status; + LONG retcode; +}; + +struct status_request +{ + long mtype; + int reply_to_q; +}; + +struct status_response +{ + long mtype; + LONG retcode; + LONG pct_complete; +}; + +struct stoprpr_request +{ + long mtype; + int reply_to_q; +}; + +struct stoprpr_response +{ + long mtype; + LONG retcode; +}; +#endif + +/*------------------------------------------------------------------------ + * Function Prototypes + *------------------------------------------------------------------------*/ +#if zNETWARE +extern void ProcessRepairCompleteCallback(LONG status,LONG retcode); +#endif +extern LONG VLMSG_GetRepairInfo(struct VLDBRepairInfo_s *info); + +#ifdef __cplusplus +} +#endif + +#endif /* _VLRPRIF_H_ */ diff --git a/include/nwnss/include/vmrpc.h b/include/nwnss/include/vmrpc.h new file mode 100644 index 0000000..50d83ad --- /dev/null +++ b/include/nwnss/include/vmrpc.h @@ -0,0 +1,382 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) module + | + |--------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2006-09-22 21:30:00 +0530 (Fri, 22 Sep 2006) $ + | + | $RCSfile$ + | $Revision: 1535 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | define remote procedure call parameters & functions + +-------------------------------------------------------------------------*/ + +#ifndef _VMRPC_H_ +#define _VMRPC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_VOLUME_NAME_SIZE 16 + +/************************************************************************* + * Structure to hold returned volume information from ENUMERATE + **************************************************************************/ + +struct VOLMAN_VolumeInfo +{ + VolumeID_t volume_guid; /* The volume's DFS GUID */ + unicode_t volume_name[MAX_VOLUME_NAME_SIZE + 2]; + /* The physical volume name */ + /* +2 for null & padding */ +}; + +/************************************************************************* + * Structure to hold statistics information + * + * If new statistics are added to the end of this structure, some amount of + * forward compatibility is provided by the bufsize argument in the + * VOLMAN_GetStatistics call + **************************************************************************/ +struct VOLMANStatistics +{ + LONG current_state; /* Volume Manager's state (running, stopped, ...) */ + LONG release_level; /* Software version */ + LONG build_date; /* Module build date (UTC time) */ + LONG load_time; /* Service start time (UTC time) */ + LONG num_threads; /* # of running processing threads */ + LONG copy_count; /* # volumes copied since NLM load */ + LONG move_count; /* # volumes moved to another server since NLM load */ + LONG split_count; /* # volumes split since NLM load */ + LONG total_requests; /* total # of requests received */ + LONG error_count; /* total invalid requests received */ + LONG auth_errors; /* # of authentication errors */ + LONG queue_length; /* Current request queue length */ + LONG average_copy_time; /* Average COPY operation time (units?) */ + LONG average_move_time; /* Average MOVE operation time */ + LONG average_split_time;/* Average SPLIT operation time */ + LONG average_queued_time;/* Average time requests wait on queue */ + LONG flush_count; /* # of volume flush requests received */ + LONG average_flush_time;/* Average volume flush operation time */ + LONG getmc_count; /* # of get management context requests received */ + LONG average_getmc_time;/* Average get management context operation time */ + LONG delete_count; /* # of delete file requests received */ + LONG average_delete_time;/* Average file delete time */ + LONG rename_count; /* # of rename file requests received */ + LONG average_rename_time;/* Average file rename time */ +}; + +/************************************************************************* + * Structure to hold configuration information + * + * The flags field indicates which items you are setting or are to be + * delivered if you get the config params. On return from a GET, the + * setting of the flags indicates which parameters were actually delivered. + * To get all parameters, use the defined value VOLMAN_CONFIG_FLAGS_ALL rather + * than -1 to allow for forward compatibility + * If a newer client makes a request against an older server it may not get + * all that it expects. + * New fields should always be added to the end of the structure + * + * Notes on Time Restrictions: + * The 42-byte field is essentially a bit string. + * Each bit represents a half-hour period, starting with Midnight + * Sunday (morning). A bit value of 0 means transfers are permitted + * during this interval, a value of 1 means they are not allowed. + * Given the weekday (0=Sunday, 6=Saturday) and the half-hour period in the + * day (a value between 0 & 47 inclusive), the byte offset is found by: + * offset = (weekday * 6) + (halfhour / BITS_PER_BYTE); + * The bit withing the byte is found by: + * (1 << (halfhour % BITS_PER_BYTE)) + **************************************************************************/ + +struct VOLMANConfig +{ + LONG flags; /* See below */ + LONG num_threads; /* Requested number of processing threads */ + BYTE time_restrictions[42]; /* Time restrictions */ +}; + +/* Flags: */ +#define VOLMAN_CONFIG_FLAG_NUM_THREADS 0x00000001 +#define VOLMAN_CONFIG_FLAG_TIME_RESTRICTIONS 0x00000002 +#define VOLMAN_CONFIG_FLAGS_ALL (VOLMAN_CONFIG_FLAG_NUM_THREADS | \ + VOLMAN_CONFIG_FLAG_TIME_RESTRICTIONS) + +/************************************************************************* + * Structure to hold status of an operation + **************************************************************************/ + +struct VOLMNStatus +{ + LONG operation_id; /* Operation ID of operation */ + WORD opcode; /* Type of operation */ + WORD state; /* Current state */ + LONG pct_complete; /* Estimated % complete (0-100) */ + union + { + QUAD start; /* Scheduled (re)Start time (UTC time) */ + QUAD finish; /* Completion Time (UTC Time) */ + } time; /* Check opcode to determine which time to use */ + QUAD skipped; /* # of files that could not be moved */ + QUAD file_count; /* # of data sets for this job */ + LONG eflAttempt; /* EFL retry attempt # */ + unicode_t src_path[zMAX_FULL_NAME]; + unicode_t comment[256]; /* Comment text (null-terminated) */ +}; + +/************************************************************************* + * Structure to hold job description for new-style APIs + **************************************************************************/ + +struct up +{ + char *userName; + char *password; +}; + +struct blob +{ + LONG blobLen; + char *blob; +}; + +struct jobDesc +{ + QUAD startTime; + VolumeID_t *volumeGUID; + unicode_t *pathName; /* Only used for Split */ + unicode_t *physName; + unicode_t *serverName; + LONG flags; + union + { + struct up up; + struct blob blob; + } userInfo; + unicode_t *tgtSubdir; /* Only if VOLMAN_FLAG_TO_SUBDIR is set */ +}; + +/* Flag values */ +/* These match the defines in volmnmsg.h & volsms.h... */ +#define VOLMAN_FLAG_NONE (0) +#define VOLMAN_FLAG_UNUSED (1) +#define VOLMAN_FLAG_AUTH_BLOB (2) +#define VOLMAN_FLAG_PURGE_IMMEDIATE (4) +#define VOLMAN_FLAG_TO_SUBDIR (8) + +/************************************************************************* + * Error Codes + * + * These match the codes used elsewhere in VLDB - need to consolidate them + * somehow! + **************************************************************************/ + +#define VMRPC_SUCCESS (STATUS) 0 +#define VMRPC_ERR_INVALID_INCARNATION_NUMBER (STATUS) -10001 +#define VMRPC_ERR_INVALID_PARAMETERS (STATUS) -10002 +#define VMRPC_ERR_REQUEST_WAS_ABORTED (STATUS) -10003 +#define VMRPC_ERR_DATABASE_IS_CORRUPT (STATUS) -10004 +#define VMRPC_ERR_INSUFFICIENT_RIGHTS (STATUS) -10005 +#define VMRPC_ERR_TRANSACTION_NOT_FOUND (STATUS) -10006 +#define VMRPC_ERR_COULD_NOT_CANCEL (STATUS) -10007 +#define VMRPC_ERR_NO_MORE_ENTRIES (STATUS) -10008 +#define VMRPC_ERR_ENTRY_NOT_FOUND (STATUS) -10009 +#define VMRPC_ERR_ENTRY_ALREADY_EXISTS (STATUS) -10010 +#define VMRPC_ERR_INVALID_OPCODE (STATUS) -10011 +#define VMRPC_ERR_OPERATION_NOT_SUPPORTED (STATUS) -10012 +#define VMRPC_ERR_INSUFFICIENT_RESOURCES (STATUS) -10013 +#define VMRPC_ERR_MAX_SERVERS_EXCEEDED (STATUS) -10014 +#define VMRPC_ERR_SERVICE_IS_STOPPED (STATUS) -10015 +#define VMRPC_ERR_SERVICE_IS_NOT_STOPPED (STATUS) -10016 +#define VMRPC_ERR_GUID_ALREADY_SET (STATUS) -10017 +#define VMRPC_ERR_GUID_NOT_SET (STATUS) -10018 +#define VMRPC_ERR_IMPOSSIBLE (STATUS) -10019 +#define VMRPC_ERR_OPERATION_NOT_FOUND (STATUS) -10020 +#define VMRPC_ERR_OPERATION_NOT_PAUSABLE (STATUS) -10021 +#define VMRPC_ERR_OPERATION_NOT_PAUSED (STATUS) -10022 +#define VMRPC_ERR_CANT_MOVE_SYS_VOL (STATUS) -10023 +#define VMPRC_ERR_CONFLICTING_REQUEST (STATUS) -10024 +#define VMRPC_ERR_INVALID_SPLIT_PATH (STATUS) -10025 +#define VMRPC_ERR_NO_MANAGEMENT_CONTEXT (STATUS) -10026 + +/* VMRPC-specific errors: */ +/* obsolete (deprecated, even) (STATUS) -1000 */ +#define VMRPC_ERR_CANNOT_CONNECT (STATUS) -1001 +#define VMRPC_ERR_CANNOT_DISCONNECT (STATUS) -1002 +#define VMRPC_ERR_NDS_ERROR (STATUS) -1003 +#define VMRPC_ERR_CANT_LOGIN_AS_SERVER (STATUS) -1004 +#define VMRPC_ERR_REQUEST_TIMED_OUT (STATUS) -1005 +#define VMRPC_ERR_SERVICE_IS_NOT_RUNNING (STATUS) -1006 +#define VMRPC_ERR_BUFFER_TOO_SMALL (STATUS) -1007 + +/************************************************************************* + * Function prototypes + **************************************************************************/ + +extern STATUS VOLMAN_ConnectToHost(unicode_t *server,void **handle, + unicode_t *userName,char *password); + +extern STATUS VOLMAN_Disconnect(void *handle); + +extern STATUS VOLMAN_CopyVolume(void *handle, + LONG *operationID, + QUAD startTime, + VolumeID_t *volumeGUID, + unicode_t *physName, + unicode_t *serverName, + char *userName, + char *password); + +extern STATUS VOLMAN_CopyVolumeAuthBlob(void *handle, + LONG *operationID, + QUAD startTime, + VolumeID_t *volumeGUID, + unicode_t *physName, + unicode_t *serverName, + NINT blobLen, + char *blob); + +extern STATUS VOLMAN_CopyVolume2(void *handle, + LONG *operationID, + struct jobDesc *jobInfo); + +extern STATUS VOLMAN_MoveVolume(void *handle, + LONG *operationID, + QUAD startTime, + VolumeID_t *volumeGUID, + unicode_t *physName, + unicode_t *serverName, + char *userName, + char *password); + +extern STATUS VOLMAN_MoveVolumeAuthBlob(void *handle, + LONG *operationID, + QUAD startTime, + VolumeID_t *volumeGUID, + unicode_t *physName, + unicode_t *serverName, + NINT blobLen, + char *blob); + +extern STATUS VOLMAN_MoveVolume2(void *handle, + LONG *operationID, + struct jobDesc *jobInfo); + +extern STATUS VOLMAN_SplitVolume(void *handle, + LONG *operationID, + QUAD startTime, + VolumeID_t *volumeGUID, + unicode_t *pathName, + unicode_t *physName, + unicode_t *serverName, + char *userName, + char *password); + +extern STATUS VOLMAN_SplitVolumeAuthBlob(void *handle, + LONG *operationID, + QUAD startTime, + VolumeID_t *volumeGUID, + unicode_t *pathName, + unicode_t *physName, + unicode_t *serverName, + NINT blobLen, + char *blob); + +extern STATUS VOLMAN_SplitVolume2(void *handle, + LONG *operationID, + struct jobDesc *jobInfo); + +extern STATUS VOLMAN_FlushVolume(void *handle, unicode_t *physName); + +extern STATUS VOLMAN_Probe(void *handle,LONG *version,LONG *maxbuf); + +extern STATUS VOLMAN_Pause(void *handle, LONG operationID, unicode_t *comment); + +extern STATUS VOLMAN_Resume(void *handle, LONG operationID); + +extern STATUS VOLMAN_Schedule(void *handle, LONG operationID, QUAD startTime); + +extern STATUS VOLMAN_GetOperationStatus(void *handle, + LONG operationID, + struct VOLMNStatus *status); + +extern STATUS VOLMAN_AbortOperation(void *handle, LONG operationID); + +extern STATUS VOLMAN_EnumerateVolumes(void *handle, + LONG *cookie, + LONG *numEntries, + struct VOLMAN_VolumeInfo *volinfo[]); + +extern STATUS VOLMAN_MapGUIDToVolume(void *handle, + GUID_t *volumeGUID, + unicode_t *volumeName); + +extern STATUS VOLMAN_MapVolumeToGUID(void *handle, + unicode_t *volumeName, + GUID_t *volumeGUID); + +extern STATUS VOLMAN_SetInitialGUID(void *handle, + unicode_t *volumeName, + VolumeID_t *volumeGUID); + +extern STATUS VOLMAN_GetStatistics(void *handle, + size_t bufsize, + struct VOLMANStatistics *stats); + +extern STATUS VOLMAN_GetConfig(void *handle, + struct VOLMANConfig *config); + +extern STATUS VOLMAN_SetConfig(void *handle, + struct VOLMANConfig *config); + +extern STATUS VOLMAN_ListOperations(void *handle, + LONG *numEntries, + LONG operationList[]); + +extern STATUS VOLMAN_GetManagementContext(void *handle, + LONG bufsize, + unicode_t *buffer); + +extern STATUS VOLMAN_GetFileNameList(void *handle, + LONG operationID, + LONG *cookie, + LONG bufsize, + unicode_t *buffer); + +extern STATUS VOLMAN_DeleteFile(void *handle, + unicode_t *pathName); + +extern STATUS VOLMAN_RenameFile(void *handle, + unicode_t *pathName, + unicode_t *newName); +#ifdef __cplusplus +} +#endif + +#endif /* _VMRPC_H_ */ diff --git a/include/nwnss/include/vmrpc.imp b/include/nwnss/include/vmrpc.imp new file mode 100644 index 0000000..eb964fd --- /dev/null +++ b/include/nwnss/include/vmrpc.imp @@ -0,0 +1,31 @@ + VOLMAN_ConnectToHost + VOLMAN_Disconnect + VOLMAN_Probe + VOLMAN_CopyVolume + VOLMAN_CopyVolumeAuthBlob + VOLMAN_CopyVolume2 + VOLMAN_MoveVolume + VOLMAN_MoveVolumeAuthBlob + VOLMAN_MoveVolume2 + VOLMAN_SplitVolume + VOLMAN_SplitVolumeAuthBlob + VOLMAN_SplitVolume2 + VOLMAN_FlushVolume + VOLMAN_Pause + VOLMAN_Resume + VOLMAN_Schedule + VOLMAN_EnumerateVolumes + VOLMAN_MapGUIDToVolume + VOLMAN_MapVolumeToGUID + VOLMAN_SetInitialGUID + VOLMAN_GetStatistics + VOLMAN_GetConfig + VOLMAN_SetConfig + VOLMAN_GetOperationStatus + VOLMAN_AbortOperation + VOLMAN_ListOperations + VOLMAN_GetManagementContext + VOLMAN_GetFileNameList + VOLMAN_DeleteFile + VOLMAN_RenameFile + diff --git a/include/nwnss/include/volman.h b/include/nwnss/include/volman.h new file mode 100644 index 0000000..29540b5 --- /dev/null +++ b/include/nwnss/include/volman.h @@ -0,0 +1,141 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | define Volume Manager constants that are used across modules + +-------------------------------------------------------------------------*/ + +#ifndef _VOLMAN_H_ +#define _VOLMAN_H_ + +#ifndef _ZOMNI_H_ +# include +#endif + +#ifndef _VOLSMS_H_ +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/**************************************************************************** + * Special cookie values for ENUMERATE operations: + ***************************************************************************/ +#define VOLMAN_COOKIE_INITIAL 0 /* Initial request */ +#define VOLMAN_COOKIE_NO_MORE_ENTRIES 0xFFFFFFFF /* No more entries to return */ + + +/**************************************************************************** + * Service States + ***************************************************************************/ + +#define VOLMN_SERVICE_INITIALIZING (0) /* Should never be returned in msg */ +#define VOLMN_SERVICE_STOPPED (1) +#define VOLMN_SERVICE_RUNNING (2) +#define VOLMN_SERVICE_BROKEN (3) + +/**************************************************************************** + * Process States + ***************************************************************************/ + +#define VOLMN_PROC_INVALID (0x0000) +#define VOLMN_PROC_RUNNING (0x0001) +#define VOLMN_PROC_COMPLETED (0x0002) +#define VOLMN_PROC_PRESCAN (0x0003) /* (Phantom state) */ +#define VOLMN_PROC_CANCELLED (0x0004) +#define VOLMN_PROC_PAUSED (0x0005) +#define VOLMN_PROC_SCHEDULED (0x0006) +#define VOLMN_PROC_UPDATING (0x0007) /* Modifying VLDB entry for MOVEd volume */ +#define VOLMN_PROC_NAME_SELECT (0x0008) /* Selecting name to rename subdirectory */ +#define VOLMN_PROC_RENAMING (0x0009) /* Renaming subdirectory from SPLIT */ +#define VOLMN_PROC_CREATE_JUNC (0x000A) /* Creating a junction to replace subdirectory */ +#define VOLMN_PROC_CLEANUP (0x000B) /* Deleting Volume or subdir tree */ +#define VOLMN_PROC_REPLAYING_LOG (0x000C) /* Retrying copy of files that were previously skipped */ +#define VOLMN_PROC_PAUSED2 (0x000D) /* Paused from REPLAYING_LOG state */ +#define VOLMN_PROC_RENAME_LOGFILE (0x000E) /* Renaming log file */ +#define VOLMN_PROC_NEW_LOGFILE (0x000F) /* Creating new log file */ +#define VOLMN_PROC_MOVE_TRUSTEES (0x0010) /* Moving trustees from subdir to junction */ +#define VOLMN_PROC_NEW_EFL (0x0011) /* Creating a new EFL epoch */ +#define VOLMN_PROC_REPLAYING_EFL (0x0012) /* Replaying changes from EFL */ +#define VOLMN_PROC_PAUSED3 (0x0013) /* Paused from REPLAYING_EFL state */ + +#define VOLMN_PROC_STARTING (0x0101) +#define VOLMN_PROC_CANCELLING (0x0104) +#define VOLMN_PROC_PAUSING (0x0105) +#define VOLMN_PROC_SUSPENDING (0x0106) +#define VOLMN_PROC_RETRY_UPDATING (0x0107) +#define VOLMN_PROC_RETRY_NAME_SELECT (0x0108) +#define VOLMN_PROC_RETRY_RENAMING (0x0109) +#define VOLMN_PROC_RETRY_CREATE_JUNC (0x010A) +#define VOLMN_PROC_RETRY_CLEANUP (0x010B) +#define VOLMN_PROC_RETRY_REPLAY (0x010C) +#define VOLMN_PROC_PAUSING2 (0x010D) +#define VOLMN_PROC_RETRY_RENAME_LOGFILE (0x010E) +#define VOLMN_PROC_RETRY_NEW_LOGFILE (0x010F) +#define VOLMN_PROC_RETRY_MOVE_TRUSTEES (0x0110) +#define VOLMN_PROC_RETRY_NEW_EFL (0x0111) +#define VOLMN_PROC_RETRY_REPLAY_EFL (0x0112) +#define VOLMN_PROC_PAUSING3 (0x0113) + +#define VOLMN_PROC_FILES_SKIPPED (0x0201) +#define VOLMN_PROC_CLEANUP_FAILED (0x020B) + +#define VOLMN_PROC_FAILED (0x8000) +#define VOLMN_PROC_FAILED_FILE_READ (VOLMN_PROC_FAILED | 0x0001) +#define VOLMN_PROC_FAILED_FILE_RESTORE (VOLMN_PROC_FAILED | 0x0002) +#define VOLMN_PROC_FAILED_BEGIN_BACKUP (VOLMN_PROC_FAILED | 0x0003) +#define VOLMN_PROC_FAILED_LOGIN (VOLMN_PROC_FAILED | 0x0004) +#define VOLMN_PROC_FAILED_TARGET_VERSION (VOLMN_PROC_FAILED | 0x0005) +#define VOLMN_PROC_FAILED_NO_MANAGEMENT_CONTEXT (VOLMN_PROC_FAILED | 0x0006) + /* Source server not in a DFS management context */ +#define VOLMN_PROC_FAILED_NOT_SAME_MANAGEMENT_CONTEXT (VOLMN_PROC_FAILED | 0x0007) + /* Target server not in same management context as source */ +#define VOLMN_PROC_FAILED_LOG_FILE (VOLMN_PROC_FAILED | 0x0008) + /* Log file error (not found or can't access) */ + +/* Special versions */ +#define VOLMN_MIN_MOVE_PROTOCOL_VERSION 0x01000176 /* v1.01 */ + +/* Exported Function Prototypes: */ +extern STATUS VOLMN_Register(struct VOLSMSEntry_s *FuncList, unicode_t *serverName); +extern void VOLMN_Deregister(struct VOLSMSEntry_s *FuncList); +extern void VOLMN_OperationComplete(LONG operationID, WORD state, QUAD skipped); +extern BOOL VOLMN_GetLocalServersManagementContext(unicode_t *buffer); + +#ifdef __cplusplus +} +#endif + +#endif /* _VOLMAN_H_ */ diff --git a/include/nwnss/include/volmnmsg.h b/include/nwnss/include/volmnmsg.h new file mode 100644 index 0000000..0fcf637 --- /dev/null +++ b/include/nwnss/include/volmnmsg.h @@ -0,0 +1,975 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) module + | + |--------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2006-09-22 21:30:00 +0530 (Fri, 22 Sep 2006) $ + | + | $RCSfile$ + | $Revision: 1535 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | define Volume Manager message formats, opcodes, and error codes + +-------------------------------------------------------------------------*/ + +#ifndef _VOLMNMSG_H_ +#define _VOLMNMSG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_NCPLTYPE_H_) || defined(WIN32) +#define UNSIGNED_16 WORD +#define UNSIGNED_32 UINT32 +#define SIGNED_32 INT32 +#define UNSIGNED_64 UINT64 +#define SIGNED_64 INT64 +#define UNICODE_CHAR WCHAR +#define GUID_t GUID +#else +#include + +#define UNSIGNED_16 WORD +#define UNSIGNED_32 LONG +#define SIGNED_32 SLONG +#define UNSIGNED_64 QUAD +#define SIGNED_64 SQUAD +#define UNICODE_CHAR unicode_t +#endif + +/*** THIS DEFINE IS IN 2 PLACES: HERE & VMRPC.H. NEED TO GET IT TO ONE ***/ +/*** PLACE THAT IS USED BY BOTH (VOLMN.H?) ***/ +#define MAX_VOLUME_NAME_SIZE 16 + +/*------------------------------------------------------------------------- + * Message opcodes + *-------------------------------------------------------------------------*/ +#define VOLMN_MSG_OP_INVALID 0x00 +#define VOLMN_MSG_OP_PROBE 0x01 +#define VOLMN_MSG_OP_REQUEST_ABORT 0x02 +#define VOLMN_MSG_OP_REQUEST_STATUS 0x03 +#define VOLMN_MSG_OP_OPERATION_ABORT 0x04 +#define VOLMN_MSG_OP_OPERATION_STATUS 0x05 +#define VOLMN_MSG_OP_OPERATION_PAUSE 0x06 +#define VOLMN_MSG_OP_OPERATION_RESUME 0x07 +#define VOLMN_MSG_OP_OPERATION_SCHEDULE 0x08 +#define VOLMN_MSG_OP_FILE_LIST 0x09 + +#define VOLMN_MSG_OP_VOLUME_COPY 0x10 +#define VOLMN_MSG_OP_VOLUME_MOVE 0x11 +#define VOLMN_MSG_OP_VOLUME_SPLIT 0x12 +#define VOLMN_MSG_OP_VOLUME_FLUSH 0x13 + +#define VOLMN_MSG_OP_ENUMERATE 0x20 +#define VOLMN_MSG_OP_MAP_GUID_TO_VOLUME 0x21 +#define VOLMN_MSG_OP_MAP_VOLUME_TO_GUID 0x22 +#define VOLMN_MSG_OP_SET_INITIAL_GUID 0x23 +#define VOLMN_MSG_OP_GET_MOUNTPOINT 0x24 + +#define VOLMN_MSG_OP_GETSTATS 0x30 +#define VOLMN_MSG_OP_SETCONFIG 0x31 +#define VOLMN_MSG_OP_GETCONFIG 0x32 +#define VOLMN_MSG_OP_LIST_OPERATIONS 0x33 +#define VOLMN_MSG_OP_GET_MANAGEMENT_CONTEXT 0x34 + +#define VOLMN_MSG_OP_DELETE_FILE 0x40 +#define VOLMN_MSG_OP_RENAME_FILE 0x41 + +#define VOLMN_MSG_OP_OPERATION_STATUS2 0x85 + +#define VOLMN_MSG_OP_VOLUME_COPY2 0x90 +#define VOLMN_MSG_OP_VOLUME_MOVE2 0x91 +#define VOLMN_MSG_OP_VOLUME_SPLIT2 0x92 + +/*------------------------------------------------------------------------- + * Quality of Service Options + *-------------------------------------------------------------------------*/ +#define VOLMN_MSG_QOS_NORMAL 0x0000 +#define VOLMN_MSG_QOS_BACKGROUND 0x0001 +#define VOLMN_MSG_QOS_AUTH_BLOB 0x2000 /* User/password supplied as blob */ + +/*------------------------------------------------------------------------- + * Operation Status codes + *-------------------------------------------------------------------------*/ +#define VOLMN_MSG_SUCCESS (SIGNED_32) 0 +#define VOLMN_MSG_ERR_INVALID_PARAMETERS (SIGNED_32) -10002 +#define VOLMN_MSG_ERR_REQUEST_WAS_ABORTED (SIGNED_32) -10003 +#define VOLMN_MSG_ERR_INSUFFICIENT_RIGHTS (SIGNED_32) -10005 +#define VOLMN_MSG_ERR_TRANSACTION_NOT_FOUND (SIGNED_32) -10006 +#define VOLMN_MSG_ERR_COULD_NOT_CANCEL (SIGNED_32) -10007 +#define VOLMN_MSG_ERR_NO_MORE_ENTRIES (SIGNED_32) -10008 +#define VOLMN_MSG_ERR_ENTRY_NOT_FOUND (SIGNED_32) -10009 +#define VOLMN_MSG_ERR_ENTRY_ALREADY_EXISTS (SIGNED_32) -10010 +#define VOLMN_MSG_ERR_INVALID_OPCODE (SIGNED_32) -10011 +#define VOLMN_MSG_ERR_OPERATION_NOT_SUPPORTED (SIGNED_32) -10012 +#define VOLMN_MSG_ERR_INSUFFICIENT_RESOURCES (SIGNED_32) -10013 +#define VOLMN_MSG_ERR_SERVICE_IS_STOPPED (SIGNED_32) -10015 +#define VOLMN_MSG_ERR_GUID_ALREADY_SET (SIGNED_32) -10017 +#define VOLMN_MSG_ERR_GUID_NOT_SET (SIGNED_32) -10018 +#define VOLMN_MSG_ERR_IMPOSSIBLE (SIGNED_32) -10019 +#define VOLMN_MSG_ERR_OPERATION_NOT_FOUND (SIGNED_32) -10020 +#define VOLMN_MSG_ERR_OPERATION_NOT_PAUSABLE (SIGNED_32) -10021 +#define VOLMN_MSG_ERR_OPERATION_NOT_PAUSED (SIGNED_32) -10022 +#define VOLMN_MSG_ERR_CANT_MOVE_SYS_VOL (SIGNED_32) -10023 +#define VOLMN_MSG_ERR_CONFLICTING_REQUEST (SIGNED_32) -10024 +#define VOLMN_MSG_ERR_INVALID_SPLIT_PATH (SIGNED_32) -10025 +#define VOLMN_MSG_ERR_NO_MANAGEMENT_CONTEXT (SIGNED_32) -10026 +#define VOLMN_MSG_ERR_COULD_NOT_DELETE (SIGNED_32) -10027 +#define VOLMN_MSG_ERR_COULD_NOT_RENAME (SIGNED_32) -10028 + +/*------------------------------------------------------------------------- + * Common Request header + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_Request_s +{ + UNSIGNED_16 opcode; /* Opcode of this request */ + UNSIGNED_16 qos; /* Requested quality of service */ + UNSIGNED_32 transaction_id; /* Transaction ID of this request */ +} VOLMN_MSG_Request_s; + +/*------------------------------------------------------------------------- + * Common Response header + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_Response_s +{ + SIGNED_32 status; /* SUCCESS/Error code */ + UNSIGNED_32 transaction_id; /* Matches request transaction ID */ +} VOLMN_MSG_Response_s; + +/*------------------------------------------------------------------------- + * PROBE OPERATION + * Note: the version number in the response is encoded in a LONG but + * really consists of 3 fields: byte 0 = 'v', byte 1 = Major Version #, + * bytes 2/3 (treated as an UNSIGNED_16) = Minor version # + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_ProbeRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_PROBE */ +} VOLMN_MSG_ProbeRequest_s; + +typedef struct VOLMN_MSG_ProbeResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 version; /* Protocol Version */ + UNSIGNED_32 max_buffer_size; /* Maximum receive buffer size (bytes) */ +} VOLMN_MSG_ProbeResponse_s; + +#define VOLMN_CURRENT_PROTOCOL_VERSION 0x02000176 /* v1.02 */ + +/*------------------------------------------------------------------------- + * ABORT REQUEST OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_RequestAbortRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_REQUEST_ABORT */ + UNSIGNED_32 abort_tid; /* tid of request to be aborted */ +} VOLMN_MSG_RequestAbortRequest_s; + +typedef struct VOLMN_MSG_RequestAbortResponse_s +{ + VOLMN_MSG_Response_s hdr; +} VOLMN_MSG_RequestAbortResponse_s; + +/*------------------------------------------------------------------------- + * REQUEST STATUS OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_RequestStatusRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_REQUEST_STATUS */ + UNSIGNED_32 request_tid; /* tid of original request */ +} VOLMN_MSG_RequestStatusRequest_s; + +typedef struct VOLMN_MSG_RequestStatusResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 percent_complete; /* Estimated % complete (0-100) */ +} VOLMN_MSG_RequestStatusResponse_s; + +/*------------------------------------------------------------------------- + * ABORT OPERATION OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_OperationAbortRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_OPERATION_ABORT */ + UNSIGNED_32 abort_opid; /* operation id of request to be aborted */ +} VOLMN_MSG_OperationAbortRequest_s; + +typedef struct VOLMN_MSG_OperationAbortResponse_s +{ + VOLMN_MSG_Response_s hdr; +} VOLMN_MSG_OperationAbortResponse_s; + +/*------------------------------------------------------------------------- + * OPERATION STATUS OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_OperationStatusRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_OPERATION_STATUS */ + /* or VOLMN_MSG_OP_OPERATION_STATUS2 */ + UNSIGNED_32 request_opid; /* operation id of original request */ +} VOLMN_MSG_OperationStatusRequest_s; + +/* Old-style response. We have to keep it for backward compatibility */ +typedef struct VOLMN_MSG_OperationStatusResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 request_opid; /* Operation ID of original request */ + UNSIGNED_16 opcode; /* Opcode of this operation */ + UNSIGNED_16 state; /* Current state */ + UNSIGNED_32 percent_complete; /* Estimated % complete (0-100) */ + union + { + UNSIGNED_64 start; /* Scheduled (re)Start Time (64-bit UTC time) */ + UNSIGNED_64 finish; /* Completion Time (64-bit UTC time) */ + } time; + UNSIGNED_64 skipped; /* # of files that could not be moved */ + UNSIGNED_32 srcPath_len; /* Length of srcPath field in bytes */ + UNICODE_CHAR srcPath[1]; /* actual length given by srcpath_len */ + UNSIGNED_32 comment_length; /* Length of comment field in bytes */ + UNICODE_CHAR comment[1]; /* Comment text (null-terminated) */ + /* actual length given by comment_length */ +} VOLMN_MSG_OperationStatusResponse_s; + +/* New-style response. Add new fields at end of each section & code that doesn't */ +/* know about new fields will just ignore them. */ +typedef struct VOLMN_MSG_OperationStatus2Response_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 request_opid; /* Operation ID of original request */ + UNSIGNED_32 variable_offset; /* Start of variable-length data */ + UNSIGNED_16 opcode; /* Opcode of this operation */ + UNSIGNED_16 state; /* Current state */ + UNSIGNED_32 percent_complete; /* Estimated % complete (0-100) */ + union + { + UNSIGNED_64 start; /* Scheduled (re)Start Time (64-bit UTC time) */ + UNSIGNED_64 finish; /* Completion Time (64-bit UTC time) */ + } time; + UNSIGNED_64 skipped; /* # of files that could not be moved */ + UNSIGNED_64 file_count; /* # of files for this job */ + UNSIGNED_32 efl_attempt; /* EFL retry # */ + + /* Variable-length data starts here */ + UNSIGNED_32 srcPath_len; /* Length of srcPath field in bytes */ + UNICODE_CHAR srcPath[1]; /* actual length given by srcpath_len */ + UNSIGNED_32 comment_length; /* Length of comment field in bytes */ + UNICODE_CHAR comment[1]; /* Comment text (null-terminated) */ + /* actual length given by comment_length */ +} VOLMN_MSG_OperationStatus2Response_s; + +/*------------------------------------------------------------------------- + * OPERATION PAUSE OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_OperationPauseRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_OPERATION_PAUSE */ + UNSIGNED_32 request_opid; /* operation id of original request */ + UNSIGNED_32 comment_length; /* Length of comment field in bytes */ + UNICODE_CHAR comment[1]; /* Comment text (null-terminated) */ + /* actual length given by comment_length */ +} VOLMN_MSG_OperationPauseRequest_s; + +typedef struct VOLMN_MSG_OperationPauseResponse_s +{ + VOLMN_MSG_Response_s hdr; +} VOLMN_MSG_OperationPauseResponse_s; + +/*------------------------------------------------------------------------- + * OPERATION RESUME OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_OperationResumeRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_OPERATION_RESUME */ + UNSIGNED_32 request_opid; /* operation id of original request */ +} VOLMN_MSG_OperationResumeRequest_s; + +typedef struct VOLMN_MSG_OperationResumeResponse_s +{ + VOLMN_MSG_Response_s hdr; +} VOLMN_MSG_OperationResumeResponse_s; + +/*------------------------------------------------------------------------- + * OPERATION SCHEDULE OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_OperationScheduleRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_OPERATION_SCHEDULE */ + UNSIGNED_32 request_opid; /* operation id of original request */ + UNSIGNED_64 start_time; /* Scheduled Start Time (64-bit UTC time) */ +} VOLMN_MSG_OperationScheduleRequest_s; + +/* Note on start_time field: A value of zero (0) means to start as soon */ +/* as possible. If transfers are not allowed at the current time, the */ +/* operation will resume at the next transfer window. */ +/*** TBD: Use QoS to override and force immediate start? ***/ + +typedef struct VOLMN_MSG_OperationScheduleResponse_s +{ + VOLMN_MSG_Response_s hdr; +} VOLMN_MSG_OperationScheduleResponse_s; + +/*------------------------------------------------------------------------- + * LIST FILES OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_ListFilesRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_FILE_LIST */ + UNSIGNED_32 request_opid; /* operation id of original request */ + UNSIGNED_32 cookie; /* Cookie. 0=start */ +} VOLMN_MSG_ListFilesRequest_s; + +typedef struct VOLMN_MSG_ListFilesResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 cookie; /* New cookie value, 0xFFFFFFFF=done */ + UNSIGNED_32 list_length; /* Length (in bytes) of name list */ + UNICODE_CHAR file_list[1]; /* File list (multiple names, each name null-terminated) */ + /* actual length given by list_length */ +} VOLMN_MSG_ListFilesResponse_s; + +/*------------------------------------------------------------------------- + * COPY VOLUME OPERATION + *-------------------------------------------------------------------------*/ + +typedef struct VOLMN_MSG_VolumeCopyRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_VOLUME_COPY */ + UNSIGNED_64 start_time; /* Scheduled Start Time (64-bit UTC time) */ + VolumeID_t volume_guid; /* The NSS GUID for this volume */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The physical volume name */ + UNSIGNED_32 name_length; /* Length of server name (in bytes) */ + UNICODE_CHAR server_name[1]; /* Target server name (null-terminated) */ + /* actual length given by name_length */ + /* The following structure fields cannot be accessed directly!!! */ + UNSIGNED_32 user_name_length; /* Length of user name MUST COMPUTE OFFSET! */ + BYTE user_name[1]; /* User name or blob MUST COMPUTE OFFSET! */ + /* actual length given by user_name_length */ + UNSIGNED_32 password_length; /* Length of password MUST COMPUTE OFFSET! */ + BYTE password[1]; /* Password (if not blob) MUST COMPUTE OFFSET! */ + /* actual length given by password_length */ +} VOLMN_MSG_VolumeCopyRequest_s; + +typedef struct VOLMN_MSG_VolumeCopy2Request_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_VOLUME_COPY2 */ + UNSIGNED_64 start_time; /* Scheduled Start Time (64-bit UTC time) */ + VolumeID_t volume_guid; /* The NSS GUID for this volume */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The physical volume name */ + UNSIGNED_32 variable_offset; /* Start of variable-length data */ + UNSIGNED_32 flags; /* Flags (see below) */ + + /* Variable-length data starts here */ + /* The following structure fields cannot be accessed directly!!! */ + UNSIGNED_32 name_length; /* Length of server name (in bytes) */ + UNICODE_CHAR server_name[1]; /* Target server name (null-terminated) */ + /* actual length given by name_length */ + UNSIGNED_32 user_name_length; /* Length of user name MUST COMPUTE OFFSET! */ + BYTE user_name[1]; /* User name or blob MUST COMPUTE OFFSET! */ + /* actual length given by user_name_length */ + UNSIGNED_32 password_length; /* Length of password MUST COMPUTE OFFSET! */ + BYTE password[1]; /* Password (if not blob) MUST COMPUTE OFFSET! */ + /* actual length given by password_length */ +} VOLMN_MSG_VolumeCopy2Request_s; + +/* 7-SEP-2000: DMair suggests having option to do read-after-write verify */ +/* of COPY operation (also applies to MOVE & SPLIT) -- */ + +typedef struct VOLMN_MSG_VolumeCopyResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 operation_id; +} VOLMN_MSG_VolumeCopyResponse_s; + +/*------------------------------------------------------------------------- + * MOVE VOLUME OPERATION + *-------------------------------------------------------------------------*/ + +typedef struct VOLMN_MSG_VolumeMoveRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_VOLUME_MOVE */ + UNSIGNED_64 start_time; /* Scheduled Start Time (64-bit UTC time) */ + VolumeID_t volume_guid; /* The NSS GUID for this volume */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The target volume name */ + UNSIGNED_32 name_length; /* Length of server name (in bytes) */ + UNICODE_CHAR server_name[1]; /* Target server name (null-terminated) */ + /* actual length given by name_length */ + /* The following structure fields cannot be accessed directly!!! */ + UNSIGNED_32 user_name_length; /* Length of user name MUST COMPUTE OFFSET! */ + BYTE user_name[1]; /* User name or blob MUST COMPUTE OFFSET! */ + /* actual length given by user_name_length */ + UNSIGNED_32 password_length; /* Length of password MUST COMPUTE OFFSET! */ + BYTE password[1]; /* Password (if not blob) MUST COMPUTE OFFSET! */ + /* actual length given by password_length */ +} VOLMN_MSG_VolumeMoveRequest_s; + +typedef struct VOLMN_MSG_VolumeMove2Request_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_VOLUME_MOVE2 */ + UNSIGNED_64 start_time; /* Scheduled Start Time (64-bit UTC time) */ + VolumeID_t volume_guid; /* The NSS GUID for this volume */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The target volume name */ + UNSIGNED_32 variable_offset; /* Start of variable-length data */ + UNSIGNED_32 flags; /* Flags (see below) */ + + /* Variable-length data starts here */ + /* The following structure fields cannot be accessed directly!!! */ + UNSIGNED_32 name_length; /* Length of server name (in bytes) */ + UNICODE_CHAR server_name[1]; /* Target server name (null-terminated) */ + /* actual length given by name_length */ + UNSIGNED_32 user_name_length; /* Length of user name MUST COMPUTE OFFSET! */ + BYTE user_name[1]; /* User name or blob MUST COMPUTE OFFSET! */ + /* actual length given by user_name_length */ + UNSIGNED_32 password_length; /* Length of password MUST COMPUTE OFFSET! */ + BYTE password[1]; /* Password (if not blob) MUST COMPUTE OFFSET! */ + /* actual length given by password_length */ +} VOLMN_MSG_VolumeMove2Request_s; + +typedef struct VOLMN_MSG_VolumeMoveResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 operation_id; +} VOLMN_MSG_VolumeMoveResponse_s; + +/*------------------------------------------------------------------------- + * SPLIT VOLUME OPERATION + *-------------------------------------------------------------------------*/ + +typedef struct VOLMN_MSG_VolumeSplitRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_VOLUME_SPLIT */ + UNSIGNED_64 start_time; /* Scheduled Start Time (64-bit UTC time) */ + VolumeID_t volume_guid; /* The NSS GUID for this volume */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The target volume name */ + UNSIGNED_32 path_length; /* Path name length (in bytes) */ + UNICODE_CHAR path_name[1]; + /* Source path not including volume name (null-terminated) */ + /* actual length given by path_length */ + /* The following structure fields cannot be accessed directly!!! */ + /* Use the path_length field to compute the offset of the name_length */ + /* field! */ + UNSIGNED_32 name_length; /* Length of server name (in bytes) */ + UNICODE_CHAR server_name[1]; /* Target server name (null-terminated) */ + /* actual length given by name_length */ + UNSIGNED_32 user_name_length; /* Length of user name MUST COMPUTE OFFSET! */ + BYTE user_name[1]; /* User name or blob MUST COMPUTE OFFSET! */ + /* actual length given by user_name_length */ + UNSIGNED_32 password_length; /* Length of password MUST COMPUTE OFFSET! */ + BYTE password[1]; /* Password (if not blob) MUST COMPUTE OFFSET! */ + /* actual length given by password_length */ +} VOLMN_MSG_VolumeSplitRequest_s; + +typedef struct VOLMN_MSG_VolumeSplit2Request_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_VOLUME_SPLIT2 */ + UNSIGNED_64 start_time; /* Scheduled Start Time (64-bit UTC time) */ + VolumeID_t volume_guid; /* The NSS GUID for this volume */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The target volume name */ + UNSIGNED_32 variable_offset; /* Start of variable-length data */ + UNSIGNED_32 flags; /* Flags (see below) */ + + /* Variable-length data starts here */ + /* The following structure fields cannot be accessed directly!!! */ + UNSIGNED_32 path_length; /* Path name length (in bytes) */ + UNICODE_CHAR path_name[1]; + /* Source path not including volume name (null-terminated) */ + /* actual length given by path_length */ + UNSIGNED_32 name_length; /* Length of server name (in bytes) */ + UNICODE_CHAR server_name[1]; /* Target server name (null-terminated) */ + /* actual length given by name_length */ + UNSIGNED_32 user_name_length; /* Length of user name MUST COMPUTE OFFSET! */ + BYTE user_name[1]; /* User name or blob MUST COMPUTE OFFSET! */ + /* actual length given by user_name_length */ + UNSIGNED_32 password_length; /* Length of password MUST COMPUTE OFFSET! */ + BYTE password[1]; /* Password (if not blob) MUST COMPUTE OFFSET! */ + /* actual length given by password_length */ + UNSIGNED_32 tgt_subdir_length; /* Length of subdir name MUST COMPUTE OFFSET! */ + BYTE tgt_subdir[1]; /* Subdirectory (if split to subdir) MUST COMPUTE OFFSET! */ + /* actual length given by tgt_subdir_length */ +} VOLMN_MSG_VolumeSplit2Request_s; + +typedef struct VOLMN_MSG_VolumeSplitResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 operation_id; +} VOLMN_MSG_VolumeSplitResponse_s; + +/* Flag values for Copy/Move/Split */ +/* See also: VOLSMS_CREATE_FLAG values in volsms.h and VOLMAN_FLAG values in vmprc.h */ +#define VOLMN_MSG_FLAG_NONE (0) +#define VOLMN_MSG_FLAG_UNUSED (1) /* Unused by VOLMN. Used by VOLSMS */ +#define VOLMN_MSG_FLAG_AUTH_BLOB (2) /* Use instead of QOS flag with ...2 requests */ +#define VOLMN_MSG_FLAG_PURGE_IMMEDIATE (4) /* Move/Split only */ +#define VOLMN_MSG_FLAG_TO_SUBDIR (8) /* Split to subdirectory */ + +/*------------------------------------------------------------------------- + * FLUSH VOLUME OPERATION + *-------------------------------------------------------------------------*/ + +typedef struct VOLMN_MSG_VolumeFlushRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_VOLUME_FLUSH */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The target volume name */ +} VOLMN_MSG_VolumeFlushRequest_s; + +typedef struct VOLMN_MSG_VolumeFlushResponse_s +{ + VOLMN_MSG_Response_s hdr; +} VOLMN_MSG_VolumeFlushResponse_s; + +/*------------------------------------------------------------------------- + * ENUMERATE ENTRIES OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_EnumerateRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_ENUMERATE */ + UNSIGNED_32 cookie; /* Indicates where we are in the list */ + UNSIGNED_32 max_entries; /* max # entries to return */ +} VOLMN_MSG_EnumerateRequest_s; + +typedef struct VOLMN_MSG_VolumeInfo_s +{ + VolumeID_t volume_guid; /* The volume's NSS GUID */ + /* Need name length here??? */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The physical volume name (null-terminated) */ +} VOLMN_MSG_VolumeInfo_s; + +typedef struct VOLMN_MSG_EnumerateResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 cookie; /* New cookie for next call */ + UNSIGNED_32 num_entries; /* Number of volumes returned */ + VOLMN_MSG_VolumeInfo_s volumes[1]; + /* Actual number specified by num_entries */ +} VOLMN_MSG_EnumerateResponse_s; + +#define VOLMN_MSG_ENUMERATE_HDR_SIZE (sizeof(VOLMN_MSG_EnumerateResponse_s) - sizeof(VOLMN_MSG_VolumeInfo_s)) + +/*------------------------------------------------------------------------- + * MAP GUID TO VOLUME OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_MapGUIDToVolumeRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_MAP_GUID_TO_VOLUME */ + UNSIGNED_32 arg1; /* Reserved */ + UNSIGNED_32 arg2; /* Reserved */ + VolumeID_t volume_guid; /* The volume's NSS GUID */ +} VOLMN_MSG_MapGUIDToVolumeRequest_s; + +typedef struct VOLMN_MSG_MapGUIDToVolumeResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 arg1; /* Reserved */ + UNSIGNED_32 arg2; /* Reserved */ + VolumeID_t volume_guid; /* The volume's NSS GUID */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The physical volume name (null-terminated) */ +} VOLMN_MSG_MapGUIDToVolumeResponse_s; + +/*------------------------------------------------------------------------- + * MAP VOLUME TO GUID OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_MapVolumeToGUIDRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_MAP_VOLUME_TO_GUID */ + UNSIGNED_32 arg1; /* Reserved */ + UNSIGNED_32 arg2; /* Reserved */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The physical volume name (null-terminated) */ +} VOLMN_MSG_MapVolumeToGUIDRequest_s; + +typedef struct VOLMN_MSG_MapVolumeToGUIDResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 arg1; /* Reserved */ + UNSIGNED_32 arg2; /* Reserved */ + VolumeID_t volume_guid; /* The volume's NSS GUID */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The physical volume name (null-terminated) */ +} VOLMN_MSG_MapVolumeToGUIDResponse_s; + +/*------------------------------------------------------------------------- + * SET INITIAL DFS GUID OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_SetInitialGUIDRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_SET_INITIAL_GUID */ + UNSIGNED_32 arg1; /* Reserved */ + UNSIGNED_32 arg2; /* Reserved */ + VolumeID_t volume_guid; /* The volume's NSS GUID */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The physical volume name (null-terminated) */ +} VOLMN_MSG_SetInitialGUIDRequest_s; + +typedef struct VOLMN_MSG_SetInitialGUIDResponse_s +{ + VOLMN_MSG_Response_s hdr; +} VOLMN_MSG_SetInitialGUIDResponse_s; + +/*------------------------------------------------------------------------- + * GET VOLUME MOUNT POINT OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_GetMountPointRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_GET_MOUNTPOINT */ + UNSIGNED_32 arg1; /* Reserved */ + UNSIGNED_32 arg2; /* Reserved */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The physical volume name (null-terminated) */ +} VOLMN_MSG_GetMountPointRequest_s; + +typedef struct VOLMN_MSG_GetMountPointResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 arg1; /* Reserved */ + UNSIGNED_32 arg2; /* Reserved */ + UNICODE_CHAR volume_name[MAX_VOLUME_NAME_SIZE]; + /* The physical volume name (null-terminated) */ + UNSIGNED_32 path_length; /* Length of mount point string (in bytes) */ + UNICODE_CHAR mount_point[1]; + /* The volume's mount point (null-terminated) */ + /* Actual length given by path_length */ +} VOLMN_MSG_GetMountPointResponse_s; + +/*------------------------------------------------------------------------- + * GET STATISTICS OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_GetStatsRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_GETSTATS */ +} VOLMN_MSG_GetStatsRequest_s; + +typedef struct VOLMN_MSG_Stats_s +{ + UNSIGNED_32 type; /* This value's type (defined below) */ + UNSIGNED_32 value; +} VOLMN_MSG_Stats_s; + +/* Defined types */ +#define VOLMN_MSG_STATS_COPY_COUNT 1 +#define VOLMN_MSG_STATS_MOVE_COUNT 2 +#define VOLMN_MSG_STATS_SPLIT_COUNT 3 +#define VOLMN_MSG_STATS_TOTAL_REQUESTS 4 +#define VOLMN_MSG_STATS_ERROR_COUNT 5 +#define VOLMN_MSG_STATS_AUTH_ERRORS 6 +#define VOLMN_MSG_STATS_QUEUE_LENGTH 7 +#define VOLMN_MSG_STATS_AVE_COPY_TIME 8 +#define VOLMN_MSG_STATS_AVE_MOVE_TIME 9 +#define VOLMN_MSG_STATS_AVE_SPLIT_TIME 10 +#define VOLMN_MSG_STATS_AVE_QUEUED_TIME 11 +#define VOLMN_MSG_STATS_FLUSH_COUNT 12 +#define VOLMN_MSG_STATS_AVE_FLUSH_TIME 13 +#define VOLMN_MSG_STATS_GETMC_COUNT 14 +#define VOLMN_MSG_STATS_AVE_GETMC_TIME 15 +#define VOLMN_MSG_STATS_DELETE_COUNT 16 +#define VOLMN_MSG_STATS_AVE_DELETE_TIME 17 +#define VOLMN_MSG_STATS_RENAME_COUNT 18 +#define VOLMN_MSG_STATS_AVE_RENAME_TIME 19 + +#define VOLMN_MSG_STATS_CURRENT_STATE 100 +#define VOLMN_MSG_STATS_RELEASE_LEVEL 101 +#define VOLMN_MSG_STATS_BUILD_DATE 102 +#define VOLMN_MSG_STATS_LOAD_TIME 103 +#define VOLMN_MSG_STATS_NUM_THREADS 105 + +typedef struct VOLMN_MSG_GetStatsResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 num_entries; /* Number of list entries */ + UNSIGNED_32 arg2; /* reserved */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + VOLMN_MSG_Stats_s stats[1]; /* The statistics info (actual number */ + /* of entries specified by num_entries) */ +} VOLMN_MSG_GetStatsResponse_s; + +/*------------------------------------------------------------------------- + * SET CONFIGURATION PARAMETERS OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_TLV_s +{ + UNSIGNED_32 type; + UNSIGNED_32 length; + BYTE value[1]; +} VOLMN_MSG_TLV_s; + +/* Types */ +#define VOLMN_CONFIG_TYPE_PAD 0 +#define VOLMN_CONFIG_TYPE_NUMTHREADS 1 +#define VOLMN_CONFIG_TYPE_TIME_RESTRICT 2 +/*** THIS ONE SHOULD REALLY BE IN AN INTERNAL .H FILE ***/ +#define VOLMN_GUID 0xFFFF + +typedef struct VOLMN_MSG_SetConfigRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_SETCONFIG */ + UNSIGNED_32 num_entries; /* Number of (t/l/v) entries in list*/ + UNSIGNED_32 arg2; /* reserved */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + VOLMN_MSG_TLV_s tlv; /* list of config parameters */ +} VOLMN_MSG_SetConfigRequest_s; + +typedef struct VOLMN_MSG_SetConfigResponse_s +{ + VOLMN_MSG_Response_s hdr; +} VOLMN_MSG_SetConfigResponse_s; + +/*------------------------------------------------------------------------- + * GET CONFIGURATION PARAMETERS OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_GetConfigRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_GETCONFIG */ +} VOLMN_MSG_GetConfigRequest_s; + +typedef struct VOLMN_MSG_GetConfigResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 num_entries; /* Number of (t/l/v) entries in list */ + UNSIGNED_32 arg2; /* reserved */ + UNSIGNED_32 arg3; /* reserved */ + UNSIGNED_32 arg4; /* reserved */ + VOLMN_MSG_TLV_s tlv; /* list of config parameters */ +} VOLMN_MSG_GetConfigResponse_s; +#define VOLMN_MSG_GETCONFIG_HDR_SIZE (sizeof(VOLMN_MSG_GetConfigResponse_s) - sizeof(VOLMN_MSG_TLV_s)) + +/*------------------------------------------------------------------------- + * LIST OPERATIONS OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_ListOperationsRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_LIST_OPERATIONS */ +} VOLMN_MSG_ListOperationsRequest_s; + +typedef struct VOLMN_MSG_ListOperationsResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 num_entries; /* Number of operation ID entries in list */ + UNSIGNED_32 operation_id[1]; /* List of operation IDs (actual number */ + /* specified by num_entries) */ +} VOLMN_MSG_ListOperationsResponse_s; + +/*------------------------------------------------------------------------- + * GET MANAGEMENT CONTEXT OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_GetManagementContextRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_GET_MANAGEMENT_CONTEXT */ +} VOLMN_MSG_GetManagementContextRequest_s; + +typedef struct VOLMN_MSG_GetManagementContextResponse_s +{ + VOLMN_MSG_Response_s hdr; + UNSIGNED_32 rsvd; /* Reserved */ + UNSIGNED_32 name_length; /* Length of management context (in bytes) */ + UNICODE_CHAR context[1]; /* This server's management context (null-terminated) */ + /* actual length given by name_length */ +} VOLMN_MSG_GetManagementContextResponse_s; + +/*------------------------------------------------------------------------- + * DELETE FILE OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_DeleteFileRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_DELETE_FILE */ + UNSIGNED_32 reserved; /* Reserved (must be zero) */ + UNSIGNED_32 name_len; + UNICODE_CHAR file_name[1]; /* Path name including volume (e.g. FOO:BAR\XYZZY.TXT) */ + /* actual length given by name_len */ +} VOLMN_MSG_DeleteFileRequest_s; + +typedef struct VOLMN_MSG_DeleteFileResponse_s +{ + VOLMN_MSG_Response_s hdr; +} VOLMN_MSG_DeleteFileResponse_s; + +/*------------------------------------------------------------------------- + * RENAME FILE OPERATION + *-------------------------------------------------------------------------*/ +typedef struct VOLMN_MSG_RenameFileRequest_s +{ + VOLMN_MSG_Request_s hdr; /* opcode = VOLMN_MSG_OP_RENAME_FILE */ + UNSIGNED_32 reserved; /* Reserved (must be zero) */ + UNSIGNED_32 name_len; + UNICODE_CHAR file_name[1]; /* Path name including volume (e.g. FOO:BAR\XYZZY.TXT) */ + /* actual length given by name_len */ + UNSIGNED_32 new_name_len; + UNICODE_CHAR new_name[1]; /* New path name including volume (e.g., FOO:BAR\XYZZY.SAV) */ + /* actual length given by new_name_len */ +} VOLMN_MSG_RenameFileRequest_s; + +typedef struct VOLMN_MSG_RenameFileResponse_s +{ + VOLMN_MSG_Response_s hdr; +} VOLMN_MSG_RenameFileResponse_s; + +/*------------------------------------------------------------------------- + * All Volume Manager request messages + *-------------------------------------------------------------------------*/ +typedef union VOLMN_MSG_Request_u +{ + VOLMN_MSG_Request_s generic; + VOLMN_MSG_ProbeRequest_s probe; + VOLMN_MSG_RequestAbortRequest_s reqabort; + VOLMN_MSG_RequestStatusRequest_s reqstatus; + VOLMN_MSG_OperationAbortRequest_s opabort; + VOLMN_MSG_OperationStatusRequest_s opstatus; + VOLMN_MSG_OperationPauseRequest_s oppause; + VOLMN_MSG_OperationResumeRequest_s opresume; + VOLMN_MSG_OperationScheduleRequest_s opschedule; + VOLMN_MSG_ListFilesRequest_s listfiles; + VOLMN_MSG_VolumeCopyRequest_s volcopy; + VOLMN_MSG_VolumeCopy2Request_s volcopy2; + VOLMN_MSG_VolumeMoveRequest_s volmove; + VOLMN_MSG_VolumeMove2Request_s volmove2; + VOLMN_MSG_VolumeSplitRequest_s volsplit; + VOLMN_MSG_VolumeSplit2Request_s volsplit2; + VOLMN_MSG_VolumeFlushRequest_s volflush; + VOLMN_MSG_EnumerateRequest_s enumerate; + VOLMN_MSG_MapGUIDToVolumeRequest_s mapguid; + VOLMN_MSG_MapVolumeToGUIDRequest_s mapvolume; + VOLMN_MSG_SetInitialGUIDRequest_s setguid; + VOLMN_MSG_GetMountPointRequest_s getmount; + VOLMN_MSG_GetStatsRequest_s getstats; + VOLMN_MSG_SetConfigRequest_s setconfig; + VOLMN_MSG_GetConfigRequest_s getconfig; + VOLMN_MSG_ListOperationsRequest_s listoperations; + VOLMN_MSG_GetManagementContextRequest_s getmanagementcontext; + VOLMN_MSG_DeleteFileRequest_s deletefile; + VOLMN_MSG_RenameFileRequest_s renamefile; +} VOLMN_MSG_Request_u; + +/*------------------------------------------------------------------------- + * All Volume Manager response messages + *-------------------------------------------------------------------------*/ +typedef union VOLMN_MSG_Response_u +{ + VOLMN_MSG_Response_s generic; + VOLMN_MSG_ProbeResponse_s probe; + VOLMN_MSG_RequestAbortResponse_s reqabort; + VOLMN_MSG_RequestStatusResponse_s reqstatus; + VOLMN_MSG_OperationAbortResponse_s opabort; + VOLMN_MSG_OperationStatusResponse_s opstatus; + VOLMN_MSG_OperationStatus2Response_s opstatus2; + VOLMN_MSG_OperationPauseResponse_s oppause; + VOLMN_MSG_OperationResumeResponse_s opresume; + VOLMN_MSG_OperationScheduleResponse_s opschedule; + VOLMN_MSG_ListFilesResponse_s listfiles; + VOLMN_MSG_VolumeCopyResponse_s volcopy; + VOLMN_MSG_VolumeMoveResponse_s volmove; + VOLMN_MSG_VolumeSplitResponse_s volsplit; + VOLMN_MSG_VolumeFlushResponse_s volflush; + VOLMN_MSG_EnumerateResponse_s enumerate; + VOLMN_MSG_MapGUIDToVolumeResponse_s mapguid; + VOLMN_MSG_MapVolumeToGUIDResponse_s mapvolume; + VOLMN_MSG_SetInitialGUIDResponse_s setguid; + VOLMN_MSG_GetMountPointResponse_s getmount; + VOLMN_MSG_GetStatsResponse_s getstats; + VOLMN_MSG_SetConfigResponse_s setconfig; + VOLMN_MSG_GetConfigResponse_s getconfig; + VOLMN_MSG_ListOperationsResponse_s listoperations; + VOLMN_MSG_GetManagementContextResponse_s getmanagementcontext; + VOLMN_MSG_DeleteFileResponse_s deletefile; + VOLMN_MSG_RenameFileResponse_s renamefile; +} VOLMN_MSG_Response_u; + +/*------------------------------------------------------------------------- + * All Volume Manager messages + *-------------------------------------------------------------------------*/ +typedef union VOLMN_MSG_Message_u +{ + VOLMN_MSG_Request_u request; + VOLMN_MSG_Response_u response; + VOLMN_MSG_ProbeRequest_s probe_request; + VOLMN_MSG_ProbeResponse_s probe_response; + VOLMN_MSG_RequestAbortRequest_s reqabort_request; + VOLMN_MSG_RequestAbortResponse_s reqabort_response; + VOLMN_MSG_RequestStatusRequest_s reqstatus_request; + VOLMN_MSG_RequestStatusResponse_s reqstatus_response; + VOLMN_MSG_OperationAbortRequest_s opabort_request; + VOLMN_MSG_OperationAbortResponse_s opabort_response; + VOLMN_MSG_OperationStatusRequest_s opstatus_request; + VOLMN_MSG_OperationStatusResponse_s opstatus_response; + VOLMN_MSG_OperationStatus2Response_s opstatus2_response; + VOLMN_MSG_OperationPauseRequest_s oppause_request; + VOLMN_MSG_OperationPauseResponse_s oppause_response; + VOLMN_MSG_OperationResumeRequest_s opresume_request; + VOLMN_MSG_OperationResumeResponse_s opresume_response; + VOLMN_MSG_OperationScheduleRequest_s opschedule_request; + VOLMN_MSG_OperationScheduleResponse_s opschedule_response; + VOLMN_MSG_ListFilesRequest_s listfiles_request; + VOLMN_MSG_ListFilesResponse_s listfiles_response; + VOLMN_MSG_VolumeCopyRequest_s volcopy_request; + VOLMN_MSG_VolumeCopy2Request_s volcopy2_request; + VOLMN_MSG_VolumeCopyResponse_s volcopy_response; + VOLMN_MSG_VolumeMoveRequest_s volmove_request; + VOLMN_MSG_VolumeMove2Request_s volmove2_request; + VOLMN_MSG_VolumeMoveResponse_s volmove_response; + VOLMN_MSG_VolumeSplitRequest_s volsplit_request; + VOLMN_MSG_VolumeSplit2Request_s volsplit2_request; + VOLMN_MSG_VolumeSplitResponse_s volsplit_response; + VOLMN_MSG_VolumeFlushRequest_s volflush_request; + VOLMN_MSG_VolumeFlushResponse_s volflush_response; + VOLMN_MSG_EnumerateRequest_s enumerate_request; + VOLMN_MSG_EnumerateResponse_s enumerate_response; + VOLMN_MSG_MapGUIDToVolumeRequest_s mapguid_request; + VOLMN_MSG_MapGUIDToVolumeResponse_s mapguid_response; + VOLMN_MSG_MapVolumeToGUIDRequest_s mapvolume_request; + VOLMN_MSG_MapVolumeToGUIDResponse_s mapvolume_response; + VOLMN_MSG_SetInitialGUIDRequest_s setguid_request; + VOLMN_MSG_SetInitialGUIDResponse_s setguid_response; + VOLMN_MSG_GetMountPointRequest_s getmount_request; + VOLMN_MSG_GetMountPointResponse_s getmount_response; + VOLMN_MSG_GetStatsRequest_s getstats_request; + VOLMN_MSG_GetStatsResponse_s getstats_response; + VOLMN_MSG_SetConfigRequest_s setconfig_request; + VOLMN_MSG_SetConfigResponse_s setconfig_response; + VOLMN_MSG_GetConfigRequest_s getconfig_request; + VOLMN_MSG_GetConfigResponse_s getconfig_response; + VOLMN_MSG_ListOperationsRequest_s listoperations_request; + VOLMN_MSG_ListOperationsResponse_s listoperations_response; + VOLMN_MSG_GetManagementContextRequest_s getmanagementcontext_request; + VOLMN_MSG_GetManagementContextResponse_s getmanagementcontext_response; + VOLMN_MSG_DeleteFileRequest_s deletefile_request; + VOLMN_MSG_DeleteFileResponse_s deletefile_response; + VOLMN_MSG_RenameFileRequest_s renamefile_request; + VOLMN_MSG_RenameFileResponse_s renamefile_response; +} VOLMN_MSG_Message_u; + +#ifdef __cplusplus +} +#endif + +#endif /* _VOLMNMSG_H_ */ diff --git a/include/nwnss/include/volsms.h b/include/nwnss/include/volsms.h new file mode 100644 index 0000000..5caea0a --- /dev/null +++ b/include/nwnss/include/volsms.h @@ -0,0 +1,176 @@ +/**************************************************************************** + | + | (C) Copyright 2002, 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) module + | + |--------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2006-09-22 21:30:00 +0530 (Fri, 22 Sep 2006) $ + | + | $RCSfile$ + | $Revision: 1535 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | define Volume Manager constants that are used across modules + +-------------------------------------------------------------------------*/ + +#ifndef _VOLSMS_H_ +#define _VOLSMS_H_ + +#ifndef _ZOMNI_H_ +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/**************************************************************************** + * Process States + * These values match the Volume Manager state values defined in volman.h + ***************************************************************************/ + +#define VOLSMS_PROC_INVALID (WORD)(0x0000) /* Should never see this! */ +#define VOLSMS_PROC_RUNNING (WORD)(0x0001) /* Copying files */ +#define VOLSMS_PROC_COMPLETED (WORD)(0x0002) /* Finished MOVE or SPLIT operation */ +#define VOLSMS_PROC_PRESCAN (WORD)(0x0003) /* Counting data sets (phantom state) */ +#define VOLSMS_PROC_CANCELLED (WORD)(0x0004) /* Admin cancelled operation */ +#define VOLSMS_PROC_PAUSED (WORD)(0x0005) /* Admin paused operation */ +#define VOLSMS_PROC_SCHEDULED (WORD)(0x0006) /* Will run later */ +#define VOLSMS_PROC_UPDATING (WORD)(0x0007) /* Modifying VLDB entry for MOVEd volume */ +#define VOLSMS_PROC_NAME_SELECT (WORD)(0x0008) /* Selecting name to rename subdirectory */ +#define VOLSMS_PROC_RENAMING (WORD)(0x0009) /* Renaming subdirectory from SPLIT */ +#define VOLSMS_PROC_CREATE_JUNC (WORD)(0x000A) /* Creating a junction to replace subdirectory */ +#define VOLSMS_PROC_CLEANUP (WORD)(0x000B) /* Deleting Volume or subdir tree */ +#define VOLSMS_PROC_REPLAYING_LOG (WORD)(0x000C) /* Retrying copy of files that were previously skipped */ +#define VOLSMS_PROC_PAUSED2 (WORD)(0x000D) /* Paused from REPLAYING_LOG state */ +#define VOLSMS_PROC_RENAME_LOGFILE (WORD)(0x000E) /* Renaming log file */ +#define VOLSMS_PROC_NEW_LOGFILE (WORD)(0x000F) /* Creating new log file */ +#define VOLSMS_PROC_MOVE_TRUSTEES (WORD)(0x0010) /* Moving trustees from subdir to junction */ +#define VOLSMS_PROC_NEW_EFL (WORD)(0x0011) /* Creating a new EFL epoch */ +#define VOLSMS_PROC_REPLAYING_EFL (WORD)(0x0012) /* Replaying changes from EFL */ +#define VOLSMS_PROC_PAUSED3 (WORD)(0x0013) /* Paused from REPLAYING_EFL state */ + +/* Transitory states */ +#define VOLSMS_PROC_STARTING (WORD)(0x0101) +#define VOLSMS_PROC_CANCELLING (WORD)(0x0104) +#define VOLSMS_PROC_PAUSING (WORD)(0x0105) +#define VOLSMS_PROC_SUSPENDING (WORD)(0x0106) +#define VOLSMS_PROC_RETRY_UPDATING (WORD)(0x0107) +#define VOLSMS_PROC_RETRY_NAME_SELECT (WORD)(0x0108) +#define VOLSMS_PROC_RETRY_RENAMING (WORD)(0x0109) +#define VOLSMS_PROC_RETRY_CREATE_JUNC (WORD)(0x010A) +#define VOLSMS_PROC_RETRY_CLEANUP (WORD)(0x010B) +#define VOLSMS_PROC_RETRY_REPLAY (WORD)(0x010C) +#define VOLSMS_PROC_PAUSING2 (WORD)(0x010D) +#define VOLSMS_PROC_RETRY_RENAME_LOGFILE (WORD)(0x010E) +#define VOLSMS_PROC_RETRY_NEW_LOGFILE (WORD)(0x010F) +#define VOLSMS_PROC_RETRY_MOVE_TRUSTEES (WORD)(0x0110) +#define VOLSMS_PROC_RETRY_NEW_EFL (WORD)(0x0111) +#define VOLSMS_PROC_RETRY_REPLAY_EFL (WORD)(0x0112) +#define VOLSMS_PROC_PAUSING3 (WORD)(0x0113) + +/* Non-fatal failure states that can be retried */ +#define VOLSMS_PROC_FILES_SKIPPED (WORD)(0x0201) +#define VOLSMS_PROC_CLEANUP_FAILED (WORD)(0x020B) + +/* Fatal failure states */ +#define VOLSMS_PROC_FAILED (WORD)(0x8000) /* Got an error */ +#define VOLSMS_PROC_FAILED_FILE_READ (WORD)(VOLSMS_PROC_FAILED | 0x0001) + /* Couldn't read a file */ +#define VOLSMS_PROC_FAILED_FILE_RESTORE (WORD)(VOLSMS_PROC_FAILED | 0x0002) + /* Couldn't restore a file */ +#define VOLSMS_PROC_FAILED_BEGIN_BACKUP (WORD)(VOLSMS_PROC_FAILED | 0x0003) + /* Couldn't Begin Backup in SMS */ +#define VOLSMS_PROC_FAILED_LOGIN (WORD)(VOLSMS_PROC_FAILED | 0x0004) + /* Couldn't authenticate with SMS */ +#define VOLSMS_PROC_FAILED_TARGET_VERSION (WORD)(VOLSMS_PROC_FAILED | 0x0005) + /* Target server does not support requested operation */ +#define VOLSMS_PROC_FAILED_NO_MANAGEMENT_CONTEXT (WORD)(VOLSMS_PROC_FAILED | 0x0006) + /* Source server not in a DFS management context */ +#define VOLSMS_PROC_FAILED_NOT_SAME_MANAGEMENT_CONTEXT (WORD)(VOLSMS_PROC_FAILED | 0x0007) + /* Target server not in same management context as source */ +#define VOLSMS_PROC_FAILED_LOG_FILE (WORD)(VOLSMS_PROC_FAILED | 0x0008) + /* Log file error (not found or can't access) */ + +/**************************************************************************** + * This structure lists the current requests that the SMS layer knows + * about. + ***************************************************************************/ + +typedef struct VOLSMSRequestList_s +{ + struct VOLSMSRequestList_s *next; + + /* Actual request state begins here (on a QUAD boundary) */ + LONG operationID; /* This request's operation ID */ + LONG pctComplete; /* Estimated % complete */ + LONG eflAttempt; /* EFL retry attempt # */ + WORD state; /* Current state */ + WORD rsvd; /* For padding */ + QUAD startTime; /* Scheduled start time */ + QUAD skipped; /* # files that could not be moved */ + QUAD totalDataSets; /* Total # data sets found */ + char srcVol[zMAX_FULL_NAME]; /* Source Volume name (path) */ + char dstVol[zMAX_COMPONENT_NAME]; /* Destination Volume name */ + unicode_t comment[256]; +} VOLSMSRequestList_s; + +/**************************************************************************** + * Structure to define the entry points of the SMS layer + ***************************************************************************/ + +struct VOLSMSEntry_s +{ + LONG (*createRequest)(QUAD startTime, char *srcVol, char *dstVol, + unicode_t *dstServer, char *subdir, + unicode_t *comment, char *userName, + char *password, LONG blobLen, LONG flags); + STATUS (*cancelProcess)(LONG operationID); + STATUS (*startProcessing)(LONG operationID); + STATUS (*suspendProcessing)(LONG operationID); + STATUS (*pauseProcess)(LONG operationID, unicode_t *comment); + STATUS (*resumeProcess)(LONG operationID, BOOL startNow); + VOLSMSRequestList_s *(*listRequests)(LONG operationID); + void (*destroyList)(VOLSMSRequestList_s *theList); + STATUS (*rescheduleProcess)(LONG operationID, QUAD startTime); + STATUS (*fileList)(LONG operationID, LONG *cookie, char *buffer, LONG bufsize); +}; + +/* Special operationID value passed to listRequests entry to request list */ +/* of all known requests */ +#define OPERATION_ID_LIST_ALL (0) + +/* Flag values for createRequest. These mostly correspond to the VOLMN_MSG_FLAG values */ +/* defined in volmnmsg.h and the VOLMAN_FLAG values in vmrpc.h */ +#define VOLSMS_CREATE_FLAG_NONE (0) +#define VOLSMS_CREATE_FLAG_START_NOW (1) +#define VOLSMS_CREATE_FLAG_AUTH_BLOB (2) +#define VOLSMS_CREATE_FLAG_PURGE_IMMEDIATE (4) + +#ifdef __cplusplus +} +#endif + +#endif /* _VOLSMS_H_ */ diff --git a/include/nwnss/include/volume.h b/include/nwnss/include/volume.h index be2f050..67ea538 100644 --- a/include/nwnss/include/volume.h +++ b/include/nwnss/include/volume.h @@ -42,14 +42,14 @@ +-------------------------------------------------------------------------*/ #ifndef _VOLUME_H_ #define _VOLUME_H_ -#include -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#include +#if zNETWARE || (zLINUX && defined(__KERNEL__)) #ifndef _COMNPARAMS_H_ -# include +# include #endif #ifndef _COMNBEASTS_H_ -# include +# include #endif #ifndef _CM_CONTROL_H_ @@ -70,7 +70,7 @@ extern "C" { #endif -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) /**************************************************************************** * Queue of volumes and pools known to the system *****************************************************************************/ @@ -95,13 +95,13 @@ extern SEThead_t NSSMasterPoolList; * are in the process of trying to * cleanup because of a serious error. */ -#define VOLMODE_VERBOSE 0x0002 /* Indicates that progress messages +#define VOLMODE_VERBOSE 0x0002 /* Indicates that progress messages * should be displayed on the system * console. */ #define VOLMODE_OVERRIDE 0x0004 /* When set the change volume code will * do exactly what was requested. In - * normal cases when a volume is + * normal cases when a volume is * activated the volume can be placed * in the MAINTENANCE state due to * the stateAttribute in the Volume_s. @@ -170,7 +170,7 @@ extern SEThead_t NSSMasterPoolList; * that it is now being requested to * UNDO a partial state change. */ -#define iVOLMODE_MUST_SUCCEED 0x2000 /* Internal - COMN_ChangeVolumeState +#define iVOLMODE_MUST_SUCCEED 0x2000 /* Internal - COMN_ChangeVolumeState * uses to inform LSSes that they are * not allowed to fail the state change. */ @@ -184,7 +184,7 @@ extern SEThead_t NSSMasterPoolList; #define iVOLMODE_NSS_UNLOADING 0x4000 /* Internal - COMN_ChangeVolumeState * uses to inform LSSes that this - * volume state change was caused by + * volume state change was caused by * NSS being unloaded */ #define iVOLMODE_ATTRIBUTE_CHANGE 0x8000 /* Internal - OES code uses to indicate @@ -214,13 +214,13 @@ extern SEThead_t NSSMasterPoolList; -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) /**************************************************************************** * VOLUME Beast * * This is used to define all VOLUMES in the SYSTEM. * - * Volume is a virtual class used to derive the storage system + * Volume is a virtual class used to derive the storage system * specific volumes. *****************************************************************************/ @@ -232,7 +232,7 @@ extern SEThead_t NSSMasterPoolList; * decide where this is pointed too. *-------------------------------------------------------------------------*/ -/* NOTE--If this structure needs to grow, keep it QUAD aligned, and steal +/* NOTE--If this structure needs to grow, keep it QUAD aligned, and steal * equivalent space from the reserved field in the PersistentVolume_s struct */ typedef struct LoggedPersistentVolume_s { @@ -241,17 +241,17 @@ typedef struct LoggedPersistentVolume_s QUAD numObjects; /* how many objects are on the volume */ QUAD totalBlocks; /* total number of blocks allowed on volume*/ QUAD inUseBlocks; /* number of blocks being used by this volume */ - QUAD purgeableBlocks; /* number of purgeable blocks in the salvage system */ + QUAD purgeableBlocks; /* number of purgeable blocks in the salvage system */ QUAD nonPurgeableBlocks; /* number of non-purgeable blocks in the salvage system */ QUAD numDeletedFiles; /* number of deleted files on the volume */ - LONG renameSeqNum; /* Sequence number to prevent wildcard rename recursion*/ + LONG renameSeqNum; /* Sequence number to prevent wildcard rename recursion*/ LONG reserved1; QUAD numCompressedFiles; /* number of compressed-not-deleted files */ QUAD numCompDelFiles; /* number of deleted-and-compressed files */ QUAD numUncompressibleFiles; /* number of uncompressible files */ - QUAD numCompressedFileBlocks; /* number of file blocks occupied by + QUAD numCompressedFileBlocks; /* number of file blocks occupied by * compressed files */ - QUAD numPreCompressedFileBlocks; /* FixFixFix find out what this + QUAD numPreCompressedFileBlocks; /* FixFixFix find out what this * means */ Time_t epoch; /* Volume backup/COW epoch timestamp */ LONG reservedEpoch; /* reserved for expansion of epoch to 64 bits */ @@ -259,11 +259,11 @@ typedef struct LoggedPersistentVolume_s * If you have an LSS that does not do logging (e.g. * DOS and CDROM LSS) you might be better off writing the reserved * area. If you do this you will not have change your LSS if - * NSS uses this reserved area. This does not apply to + * NSS uses this reserved area. This does not apply to * logging LSSs because they will have to change to LOG * the new data. */ - LONG LPV_reserved[32-30]; /* QUAD ALIGN and Filler for future growth */ + LONG LPV_reserved[32-30]; /* QUAD ALIGN and Filler for future growth */ /* The logged data is 128 bytes long */ } NSS_MEDIA_STRUCTURE(LoggedPersistentVolume_s,LPV_reserved[32-30]) LoggedPersistentVolume_s; @@ -306,7 +306,7 @@ typedef struct VolInfoLog_s /* structure for transaction logging */ * The volume can be successfully placed * into ACTIVE state. The LSS sets and * resets this bit. - */ + */ #define VOLSTATEATTR_REPAIRING 0x00000004 /* The volume is currently being * repaired. This bit is usually used so * that repair can be informed after a @@ -328,11 +328,11 @@ typedef struct VolInfoLog_s /* structure for transaction logging */ * in SP4). In 6-pack when we upgrade the * volume from SP4 we need to take this into * consideration. - * This bit is not used in 6-pack after + * This bit is not used in 6-pack after * the volume has beed upgraded to 6-pack * media format. */ -#define VOLSTATEATTR_REZID 0x00000020 /* This is set when rezid has been +#define VOLSTATEATTR_REZID 0x00000020 /* This is set when rezid has been * started but not completed. We keep this * field persistently so that if we crash * in the middle of rezid, we can continue @@ -342,16 +342,16 @@ typedef struct VolInfoLog_s /* structure for transaction logging */ typedef struct PersistentVolume_s { - VolumeID_t NUvolumeID; /* Not Used!!!! unique volume ID (guid)*/ + VolumeID_t NUvolumeID; /* Not Used!!!! unique volume ID (guid)*/ QUAD beastVersionMask; /* bitmask of which beast versions are in volume.*/ LONG blockSize; /* size of a block on this volume*/ LONG blockShift; /* shift factor for block size*/ LONG oldVolAttributes; /* This should no longer be used. * The first time we come up, if enabledAttributes - * is 0, we upgrade this field to the + * is 0, we upgrade this field to the * enabledAttributes field. */ LONG nameSpaceMask; /* bitmask of which namespaces are supported */ - BYTE mac[32]; /* Mandatory Access Control Area*/ + BYTE mac[32]; /* Mandatory Access Control Area*/ LONG authModelID; /* ID of the authorization system for this volume */ LONG minKeepSeconds; /* Salvage: Min number of seconds before auto purge */ LONG maxKeepSeconds; /* Salvage: Max number of seconds before auto purge */ @@ -362,7 +362,7 @@ typedef struct PersistentVolume_s LONG stateAttributes; /* Attributes that apply to the volumes * current volume state. */ - LONG rebuildCount; /* Number of times the volume has been + LONG rebuildCount; /* Number of times the volume has been * rebuilt. */ NDSid_t ndsObjectID; /* NDS's object ID for this volume. */ @@ -375,20 +375,20 @@ typedef struct PersistentVolume_s * way. We use LONGs because each LSS may have slightly * different requirements. */ - LONG PV_mediaFormatMajor; /*** LSS should fill in ***/ + LONG PV_mediaFormatMajor; /*** LSS should fill in ***/ /* Zero indicates that minor has special * meaning. */ - LONG PV_mediaFormatMinor; /*** LSS should fill in ***/ + LONG PV_mediaFormatMinor; /*** LSS should fill in ***/ /* If major is zero then * 0 - media format not supported * 1 - media format not known yet. */ - LONG PV_mediaFormatMajorCreate; /*** LSS should fill in ***/ + LONG PV_mediaFormatMajorCreate; /*** LSS should fill in ***/ /* Zero indicates that minor has special * meaning. */ - LONG PV_mediaFormatMinorCreate; /*** LSS should fill in ***/ + LONG PV_mediaFormatMinorCreate; /*** LSS should fill in ***/ /* If major is zero then * 0 - create media format not supported * 1 - create media format not known yet. @@ -426,12 +426,12 @@ typedef struct PersistentVolume_s /* This structure hosts "meta-data" about the structure of a user transaction - log file. This was originally defined in UXAction.h, but at that time user - transactions were only supported on a single active volume (so the single - instance of this structure was a global). The need to support transactions - on multiple volumes required that each active volume have an instance of this - structure. #including UXAction.h does not work because it effectively #includes - comnPublics.h which requires definitions in this file. Therefore it was + log file. This was originally defined in UXAction.h, but at that time user + transactions were only supported on a single active volume (so the single + instance of this structure was a global). The need to support transactions + on multiple volumes required that each active volume have an instance of this + structure. #including UXAction.h does not work because it effectively #includes + comnPublics.h which requires definitions in this file. Therefore it was decided to move this structure here. */ typedef struct UserXactionLogMetaData_s @@ -439,7 +439,7 @@ typedef struct UserXactionLogMetaData_s Seq_t lastLSN; /* log sequence number of next UserXactionLogRecord */ LONG curBlk; /* buffer address (in blocks) of next buffer to write */ LONG lastBlk; /* buffer address (in blocks) of oldest block - * containing log data + * containing log data * if next == last, the log is empty, * if incrementing next gives you last, * the log is full @@ -463,15 +463,15 @@ struct Volume_s QUAD supportedAttributes;/* Attributes this volume is capable of supporting */ QUAD maximumFileSize; /* Maximum size for any file on this volume */ Zid_t zidInProcess; /* Used when enabling user space restrictions to indicate the zid being processed */ - NINT storageIndex; /* index for storage system specific routines */ + NINT storageIndex; /* index for storage system specific routines */ NINT authModelIndex; /* index into the Auth model ID map*/ struct AuthModelBeast_s *authModel; /* authModel for volume*/ File_s *rootdir; /* pointer to root dir*/ - VolumeID_t volumeID; /* unique volume ID (guid)*/ + VolumeID_t volumeID; /* unique volume ID (guid)*/ SETlink_t masterVolLink; /* link for all volumes in system*/ DQhead_t beastList; /* list of all memory resident beasts on this volume*/ NINT state; /* current state of volume - * + * * See COMN_ChangeVolumeState for a detailed * description of the STATEs. * @@ -480,7 +480,7 @@ struct Volume_s * 1) cvsLatch - must be owned to change * the value of the state. * 2) stateLatch - must be owned to access - * the value of the state. + * the value of the state. * * Note that both latches are required to * change the state. The cvsLatch must be @@ -525,13 +525,13 @@ struct Volume_s NINT freeBlockAdjustment;/* number of blocks the free blocks needs to be adjusted by -- filled in by the storage system volume constructor */ BOOL storageAlertHasBeenSent;/* set when an alert has been sent -- reset when enough space has been freed */ NINT nextTimeToCheck; /* the next time to check to see if the disk is still full */ - NINT v_statusFlag; /* Bitmask to be used by anyone needing + NINT v_statusFlag; /* Bitmask to be used by anyone needing * non-persistent state information. Bits * definitions start with VOL_SF_xxx. */ NINT v_keepActiveUseCount; /* Count of how many current APIs and/or * asynchronous threads are currently - * running on this volume. We need to set + * running on this volume. We need to set * the VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP * bit in v_statusFlag and then wait for * this count to go to zero before removing @@ -539,7 +539,7 @@ struct Volume_s */ NINT v_keepDeactiveUseCount; /* Count of how many current APIs and/or * asynchronous threads are currently - * running on this volume. We need to set + * running on this volume. We need to set * the VOL_SF_LEAVING_DEACTIVE_STATE_CLEANUP * bit in v_statusFlag and then wait for * this count to go to zero before removing @@ -566,8 +566,8 @@ struct Volume_s zWorkProc_s v_disableWorkToDoStructure; /* Protected by disable schedule bit in v_statusFlag. - * WorkToDo for NSS Library schedule API - ScheduleWork(). - */ + * WorkToDo for NSS Library schedule API - ScheduleWork(). + */ #else FsmLite_s v_disableWorkToDoFsm; /* Protected by disable schedule bit in v_statusFlag. @@ -594,7 +594,7 @@ struct Volume_s NINT v_alertListCount; /* Number of alerts that are queued. Used * to limit maximum count to 40. This is * done to limit resource usage. - */ + */ DQhead_t v_alertList; /* List of all ALERTs that are queued * for the ALERT work-to-do to * perform. The work-to-do is for @@ -611,10 +611,10 @@ struct Volume_s * owns the LV. */ // struct ZlssPool_s *ZP_ZlssPool; /* Points to the pool */ - struct Pool_s *v_pool; /* Points to the pool that owns the - * volume. Only valid for volumes - * marked as VOL_SF_LOGICAL_VOLUME. - */ + struct Pool_s *v_pool; /* Points to the pool that owns the + * volume. Only valid for volumes + * marked as VOL_SF_LOGICAL_VOLUME. + */ struct { QUAD IO_user_readSize; /* IO read size (user data) */ @@ -633,8 +633,8 @@ struct Volume_s LONG IO_system_write_failure;/* IO write failure count */ /* (system data) */ #endif - }v_stats; - CMVolumeState_s cmVolumeState; /* Per-volume Non-persistent + }v_stats; + CMVolumeState_s cmVolumeState; /* Per-volume Non-persistent * compression mgmt state */ LONG v_pState; /* Persistent volume state that MUST BE * VALID ALL THE TIME. This means just @@ -646,27 +646,27 @@ struct Volume_s * by setting state during VOL_BstNew() * to zVOL_PSTATE_CREATED */ - Time_t decompFreeSpaceWarningTime; /* The time we issued last warning - * message that compressed file - * can't be converted to - * uncompressed status permanently + Time_t decompFreeSpaceWarningTime; /* The time we issued last warning + * message that compressed file + * can't be converted to + * uncompressed status permanently * due to insufficient resource */ - - FileHandleIDP_s UXactionLogFileHandleIDP; /* file handle for + + FileHandleIDP_s UXactionLogFileHandleIDP; /* file handle for * xaction logfile*/ - UserXactionLogMetaData_s UXMetaData; /* Meta-data for user + UserXactionLogMetaData_s UXMetaData; /* Meta-data for user * transaction log file */ DQhead_t HomeTimeOrderList; /* Homed transaction list */ - NINT readAheadBlocks; /* how many blocks to read - * ahead if lss supports + NINT readAheadBlocks; /* how many blocks to read + * ahead if lss supports * this feature */ struct CsaVolumeInfo_s *v_csaVolInfo; /* Contains keys that * reference active slave * volumes */ - struct CroVolumeDoor_s *v_croVolDoor; /* This is a Cluster + struct CroVolumeDoor_s *v_croVolDoor; /* This is a Cluster * Read Only volume, and * has reference to a * Master Volume. @@ -675,7 +675,7 @@ struct Volume_s * Spin Lock. This makes the function * COMN_VolumeNameLookup much faster. */ - VolumeKey_s v_key; /* structure for encryption data if it is present */ + VolumeKey_s v_key; /* structure for encryption data if it is present */ }; #define CSA_SLAVE_VOLUMES_FOUND(_volume) ((_volume)->v_csaVolInfo != NULL) @@ -737,10 +737,10 @@ struct Volume_s * need to check to see if the directory * tree changed. */ -#define VOL_SF_RECONNECT 0x00002000 /* Indicates the volume +#define VOL_SF_RECONNECT 0x00002000 /* Indicates the volume * is being activated, and we are in the * reconnect stages. Slave volumes can - * attempt to reconnect, while this + * attempt to reconnect, while this * bit is set. After the bit is cleared * slaves can connect to this volume only * if they are newly activated (in sync) @@ -751,7 +751,7 @@ struct Volume_s #define VOL_SF_KEY_INFO_TO_WRITE 0x00008000 /* indicates that the * data in the PersistentZfsVolumeCrypt_s needs * to be written */ - + /* The VOL_ACCESSIBLE macros are used to determine if a * volume is accessible. Internal volumes are not accessible * unless the caller has set a specical bit in the genMsg. This @@ -845,8 +845,8 @@ struct Volume_s #define VOLblockSize p.blockSize #define VOLblockShift p.blockShift #define VOLauthModelID p.authModelID -#define VOLminKeepSeconds p.minKeepSeconds -#define VOLmaxKeepSeconds p.maxKeepSeconds +#define VOLminKeepSeconds p.minKeepSeconds +#define VOLmaxKeepSeconds p.maxKeepSeconds #define VOLlowWaterMark p.lowWaterMark #define VOLhighWaterMark p.highWaterMark #define VOLndsObjectID p.ndsObjectID @@ -877,7 +877,7 @@ struct Volume_s #define VOLnumUncompressibleFiles logged.numUncompressibleFiles #define VOLnumCompressedFileBlocks logged.numCompressedFileBlocks #define VOLnumPreCompressedFileBlocks logged.numPreCompressedFileBlocks -#define VOLepoch logged.epoch +#define VOLepoch logged.epoch #define CVA_SYSTEM_DATA 0x00000001 /* Else USER data */ @@ -890,7 +890,7 @@ struct Volume_s #define CVA_VOLUME_ALERT 0x00000010 /* Else No volume ALERT */ #define CVA_POOL_ALERT 0x00000020 /* Else No pool ALERT */ #define CVA_REZID_NEEDED 0x00000040 /* We are out of zids in - * the 32-bit range, so + * the 32-bit range, so * volume needs to be * re-zid. */ @@ -927,8 +927,8 @@ typedef struct NSSVolumeAlert_s * NVA_FLAG_UNKNOWN_STATION is set. */ NINT nva_flags; /* Flags - * - Note that current - * NVA_FLAG_UNKNOWN_STATION is always + * - Note that current + * NVA_FLAG_UNKNOWN_STATION is always * set because the CACHEING system * does not track station. */ @@ -995,7 +995,7 @@ extern STATUS VOL_DoFlushSystemBeasts( Volume_s *vol, BOOL deactivating); /* if TRUE we are deactivating the pool, else flushing*/ -extern void *VOL_BstNew( +extern void *VOL_BstNew( GeneralMsg_s *genMsg, NINT beastClassID, void *voidOwnerVol, @@ -1014,7 +1014,7 @@ extern void *VOL_BstNew( #define zVOL_PSTATE_DELETION 3 /* Volume is being deleted */ -extern void *VOL_BstNew2( +extern void *VOL_BstNew2( GeneralMsg_s *genMsg, NINT beastClassID, void *voidOwnerVol, @@ -1036,7 +1036,7 @@ extern void formattedSize( void POOL_DisplayPools(void); STATUS POOL_FlushPool( - struct GeneralMsg_s *genMsg, + struct GeneralMsg_s *genMsg, struct Pool_s *pool); STATUS POOL_Rename( @@ -1057,11 +1057,11 @@ extern void COMN_CheckLowSpace( Blkcnt_t numFreeBlocks); STATUS VOL_DisableVolume( - struct GeneralMsg_s *genMsg, + struct GeneralMsg_s *genMsg, struct Volume_s *volume ); STATUS POOL_DisablePool( - struct GeneralMsg_s *genMsg, + struct GeneralMsg_s *genMsg, struct Pool_s *pool ); extern BOOL NW_PurgeImmediateFlag; @@ -1079,32 +1079,32 @@ NINT LB_VolumeFindMMVolume( unicode_t *volumeName ); STATUS LB_VolumeNameValid( unicode_t *volumeName ); STATUS LB_VolumeRenameOK( unicode_t *volumeName ); -STATUS LB_VolumeNameToPoolName( +STATUS LB_VolumeNameToPoolName( CONST unicode_t *volName, /* Current pool name */ NINT *mangleKey, /* (input/output)Mangle key pointer, must point to 0 on first call */ - NINT uniSize, /* Number of unicode poolName can hold */ + NINT uniSize, /* Number of unicode poolName can hold */ unicode_t *poolName ); /* (output)New mangled name */ -STATUS LB_VolumeNameToAutoRenameName( +STATUS LB_VolumeNameToAutoRenameName( CONST unicode_t *volName, /* Current volume name */ NINT *mangleKey, /* (input/output)Mangle key pointer, must point to 0 on first call */ - NINT uniSize, /* Number of unicode newName can hold */ + NINT uniSize, /* Number of unicode newName can hold */ unicode_t *newName ); /* (output)New mangled name */ -STATUS LB_VolumeNameToSnapshotName( +STATUS LB_VolumeNameToSnapshotName( CONST unicode_t *volName, /* Current volume name */ NINT *mangleKey, /* (input/output)Mangle key pointer, must point to 0 on first call */ - NINT uniSize, /* Number of unicode snapName can hold */ + NINT uniSize, /* Number of unicode snapName can hold */ unicode_t *snapName ); /* (output)New mangled name */ -STATUS LB_VolumeNameToQSName( +STATUS LB_VolumeNameToQSName( CONST unicode_t *volName, /* Current volume name */ NINT *mangleKey, /* (input/output)Mangle key pointer, must point to 0 on first call */ - NINT uniSize, /* Number of unicode newName can hold */ + NINT uniSize, /* Number of unicode newName can hold */ unicode_t *newName ); /* (output)New mangled name */ -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) extern void VOL_ChangeVolumeExtendedMacByName( GeneralMsg_s *genMsg, unicode_t *name, @@ -1215,32 +1215,32 @@ extern STATUS VOL_ChangeUserSpaceAttribute( extern STATUS VOL_ChangeVolumeDataShredByName( GeneralMsg_s *genMsg, - unicode_t *name, + unicode_t *name, BOOL enableShredding); //extern STATUS VOL_ChangePoolSharedByName( // GeneralMsg_s *genMsg, -// unicode_t *name, +// unicode_t *name, // BOOL enableShared); extern STATUS VOL_ChangeVolumeHighIntegrityByName( GeneralMsg_s *genMsg, - unicode_t *name, + unicode_t *name, BOOL enableHighIntegrity); extern STATUS VOL_ChangeVolumeCFSMasterByName( GeneralMsg_s *genMsg, - unicode_t *name, + unicode_t *name, BOOL enableCFSMasterommunal); extern STATUS VOL_ChangeVolumeCOWByName( GeneralMsg_s *genMsg, - unicode_t *name, + unicode_t *name, BOOL cowOn); extern STATUS VOL_ChangeVolumeReadAheadByName( GeneralMsg_s *genMsg, - unicode_t *name); + unicode_t *name); extern STATUS VOL_InitUserSpaceRestrictionData( GeneralMsg_s *genMsg, @@ -1271,8 +1271,8 @@ void vol_DisableWorkToDoRoutine( struct FsmLite_s *workToDoFsm ); #endif -STATUS comn_VolumeAlert( - GeneralMsg_s *genMsg, +STATUS comn_VolumeAlert( + GeneralMsg_s *genMsg, RootBeast_s *beast, Volume_s *volume, Buffer_s *buffer, @@ -1302,12 +1302,12 @@ typedef struct PersistentPool_s */ LONG PP_blockSize; /* size of a block on this pool */ LONG PP_blockShift; /* size of a block on this pool */ - LONG PP_rebuildCount; /* Number of times the pool has been + LONG PP_rebuildCount; /* Number of times the pool has been * rebuilt. */ LONG PP_reserved0; - BYTE PP_mac[32]; /* Mandatory Access Control Area*/ + BYTE PP_mac[32]; /* Mandatory Access Control Area*/ LONG PP_minKeepSeconds; /* Salvage: Min number of seconds before auto purge */ LONG PP_maxKeepSeconds; /* Salvage: Max number of seconds before auto purge */ @@ -1325,23 +1325,23 @@ typedef struct PersistentPool_s QUAD PP_enabledFeatures; /* This bit mask contains a bit for each * feature which is enabled on the pool */ - LONG PP_mediaFormatMajor;/* Zero indicates that minor has special + LONG PP_mediaFormatMajor;/* Zero indicates that minor has special * meaning. */ - LONG PP_mediaFormatMinor; /* If major is zero then + LONG PP_mediaFormatMinor; /* If major is zero then 0 - media format not supported 1 - media format not known yet. */ NDSid_t PP_ndsObjectID; /* NDS's object ID for this pool. */ - LONG PP_reserved[64-22-4]; /* QUAD align and future growth of data */ + LONG PP_reserved[64-22-4]; /* QUAD align and future growth of data */ /* The above data is 256 bytes in length */ /* * End of the persistent area of the pool. **/ } NSS_MEDIA_STRUCTURE(PersistentPool_s,PP_reserved[64-22-4]) PersistentPool_s; - + typedef struct LoggedPersistentPool_s { /** @@ -1354,11 +1354,11 @@ typedef struct LoggedPersistentPool_s // QUAD LPP_numObjects; /* how many objects are on the pool */ QUAD LPP_totalBlocks; /* total number of blocks in pool */ QUAD LPP_inUseBlocks; /* number of blocks used in this pool */ - QUAD LPP_purgeableBlocks; /* number of purgeable blocks in the salvage system */ + QUAD LPP_purgeableBlocks; /* number of purgeable blocks in the salvage system */ QUAD LPP_nonPurgeableBlocks; /* number of non-purgeable blocks in the salvage system */ // QUAD LPP_numDeletedFiles; /* number of deleted files on the pool */ // QUAD LPP_numLogicalVolumes; /* Number of logical volumes in pool. Shoud we track????? */ -// LONG LPP_renameSeqNum; /* Sequence number to prevent wildcard rename recursion*/ +// LONG LPP_renameSeqNum; /* Sequence number to prevent wildcard rename recursion*/ LONG LPP_reserved[64-8]; /* QUAD align and future growth of LOGGED data */ /* The above data is 256 bytes in length */ /* @@ -1375,15 +1375,15 @@ typedef struct Pool_s LoggedPersistentPool_s logged; /* contains persistent information that is logged*/ QUAD supportedFeatures; /* Features this pool is capable of supporting */ // QUAD maximumFileSize; /* Maximum size for any file on this volume */ - NINT storageIndex; /* index for storage system specific routines */ + NINT storageIndex; /* index for storage system specific routines */ // NINT authModelIndex; /* index into the Auth model ID map*/ // struct AuthModelBeast_s *authModel; /* authModel for volume*/ // File_s *rootdir; /* pointer to root dir*/ - VolumeID_t volumeID; /* unique volume ID (guid)*/ + VolumeID_t volumeID; /* unique volume ID (guid)*/ SETlink_t masterPoolLink; /* link for all pools in the system */ // DQhead_t beastList; /* list of all memory resident beasts on this volume*/ NINT state; /* current state of pool - * + * * See COMN_ChangeVolumeState for a detailed * description of the STATEs. * @@ -1392,7 +1392,7 @@ typedef struct Pool_s * 1) cvsLatch - must be owned to change * the value of the state. * 2) stateLatch - must be owned to access - * the value of the state. + * the value of the state. * * Note that both latches are required to * change the state. The cvsLatch must be @@ -1441,14 +1441,14 @@ typedef struct Pool_s NINT freeBlockAdjustment;/* number of blocks the free blocks needs to be adjusted by -- filled in by the storage system volume constructor */ // BOOL storageAlertHasBeenSent;/* set when an alert has been sent -- reset when enough space has been freed */ NINT nextTimeToCheck; /* the next time to check to see if the disk is still full */ - NINT v_statusFlag; /* Bitmask to be used by anyone needing + NINT v_statusFlag; /* Bitmask to be used by anyone needing * non-persistent state information. Bits * definitions start with VOL_SF_xxx. */ NINT v_keepActiveUseCount; /* Count of how many current APIs and/or * asynchronous threads are currently - * running on this volume. We need to set + * running on this volume. We need to set * the VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP * bit in v_statusFlag and then wait for * this count to go to zero before removing @@ -1473,8 +1473,8 @@ typedef struct Pool_s #if VOL_DISABLE_USE_SYSTEMS_WORK_TO_DO zWorkProc_s v_disableWorkToDoStructure; /* Protected by disable schedule bit in v_statusFlag. - * WorkToDo for NSS Library schedule API - ScheduleWork(). - */ + * WorkToDo for NSS Library schedule API - ScheduleWork(). + */ #else FsmLite_s v_disableWorkToDoFsm; /* Protected by disable schedule bit in v_statusFlag. @@ -1495,7 +1495,7 @@ typedef struct Pool_s /* Number of alerts that are queued. Used * to limit maximum count to 40. This is * done to limit resource usage. - */ + */ DQhead_t v_alertList; /* List of all ALERTs that are queued * for the ALERT work-to-do to @@ -1518,7 +1518,7 @@ typedef struct Pool_s * we can not own the stateLatch of the * pool. */ - Volume_s *P_VolumeInternal; /* Vandana and Greg added in Nakoma so + Volume_s *P_VolumeInternal; /* Vandana and Greg added in Nakoma so * that we could flush a complete pool * from the common layer. This field * can be zero if the LSS does not support @@ -1532,7 +1532,7 @@ typedef struct Pool_s * can be outstanding at a time. */ void *P_FreezeThawKey; /* This the the key to access the freeze/thaw - * structure. This field will be used by + * structure. This field will be used by * zPoolThawByName(). */ Latch_s P_MaintenaceLatch; /* This is the latch to serialize I/O to a pool @@ -1607,7 +1607,7 @@ typedef struct Pool_s * must ensure that the pools cvsLatch is owned. */ #define POOL_FOR_EACH_LOADED_VOLUME( _pool, _lv ) \ - ASSERT_XLATCH( &_pool->cvsLatch ); \ + ASSERT_XLATCH( &_pool->cvsLatch ); \ DQ_FOREACH( &(_pool)->P_VolumeList, _lv, Volume_s, v_poolVolLink ) /* @@ -1631,8 +1631,8 @@ void pool_DisableWorkToDoRoutine( struct FsmLite_s *workToDoFsm ); #endif -STATUS comn_PoolAlert( - GeneralMsg_s *genMsg, +STATUS comn_PoolAlert( + GeneralMsg_s *genMsg, RootBeast_s *beast, Volume_s *volume, Pool_s *pool, diff --git a/include/nwnss/include/wio.h b/include/nwnss/include/wio.h index 9298b1a..59fc02c 100644 --- a/include/nwnss/include/wio.h +++ b/include/nwnss/include/wio.h @@ -44,30 +44,17 @@ #define _WIO_H_ #ifndef _ZOMNI_H_ -# include +# include #endif -#ifndef _STDARG_H_ -# include -#endif -#ifndef _XSTDIO_H_ -# include -#endif -#ifndef __linux__ #ifndef _LATCH_H_ -# include +# include #endif #ifndef _REGISTER_H_ -# include +# include #endif #ifndef _QUE_H_ -# include +# include #endif -#endif - -/* Several WIO prototypes take screen handles by pointer only. Keep the - * type forward-declared so modern compilers do not warn that the struct - * is declared inside a parameter list. */ -struct ScreenStruct; #ifdef __cplusplus @@ -82,9 +69,9 @@ typedef struct WFile_s int WF_NotUsed; } WFile_s; -/* Linux userspace port: the NSS Linux path only supports console output. */ -#define wStdin ((WFile_s *)0) -#define wStdout ((WFile_s *)0) +extern WFile_s *wStdout; // In the DEMO LKM we will not support any Input/Output that does not + // go directly to the NSS SCA. + // In ship, NSS LKM will not do any UI! It can use printk and syslog #define KEY_ENTER 0343 // TODO: From ncurses remove after DEMO @@ -168,7 +155,7 @@ extern void LB__wioOutput( *======================================================================== *========================================================================*/ -#if zLINUX && !defined(NSS_USERSPACE) +#if zLINUX //extern spinlock_t consoleLock; extern struct semaphore consoleSema; #endif @@ -176,10 +163,8 @@ extern struct semaphore consoleSema; /*------------------------------------------------------------------------- * Standard IO definitions *-------------------------------------------------------------------------*/ -#ifndef __linux__ #define wStdin COMN_Resource.stdio #define wStdout COMN_Resource.stdio -#endif /*------------------------------------------------------------------------- * Function prototypes @@ -271,7 +256,7 @@ extern void LB_wWrapString( char *string); /*------------------------------------------------------------------------- - * + * *-------------------------------------------------------------------------*/ #define wActivate(p1) LB_wActivate(p1) #define wAPrintf LB_wAPrintf diff --git a/include/nwnss/include/ws2nlm.imp b/include/nwnss/include/ws2nlm.imp new file mode 100644 index 0000000..43fd572 --- /dev/null +++ b/include/nwnss/include/ws2nlm.imp @@ -0,0 +1,85 @@ + WS2_32_bind + WS2_32_closesocket + WS2_32_getpeername + WS2_32_getsockname + WS2_32_getsockopt + WS2_32_htonl + WS2_32_htons + WS2_32_ioctlsocket + WS2_32_listen + WS2_32_ntohl + WS2_32_ntohs + WS2_32_recv + WS2_32_recvfrom + WS2_32_select + WS2_32_send + WS2_32_sendto + WS2_32_setsockopt + WS2_32_shutdown + WS2_32_socket + WSAAccept + WSACancelBlockingCall + WSACleanup + WSACloseEvent + WSAConnect + WSACreateEvent + WSCEnableNSProvider + WSAEnumNetworkEvents + WSAEnumProtocolsA + WSAEnumProtocolsW + WSAEventSelect + WSAGetLastError + WSAGetOverlappedResult + WSAGetQOSByName + WSAHtonl + WSAHtons + WSAIoctl + WSAJoinLeaf + WSANtohl + WSANtohs + WSARecv + WSARecvDisconnect + WSARecvFrom + WSAResetEvent + WSASend + WSASendDisconnect + WSASendTo + WSASetEvent + WSASetLastError + WSASocketA + WSASocketW + WSAStartup + WSAWaitForMultipleEvents + WSAAddressToStringA + WSAAddressToStringW + WSAEnumNameSpaceProvidersA + WSAEnumNameSpaceProvidersW + WSAGetServiceClassInfoA + WSAGetServiceClassInfoW + WSAGetServiceClassNameByClassIdA + WSAGetServiceClassNameByClassIdW + WSAInstallServiceClassA + WSAInstallServiceClassW + WSALookupServiceBeginA + WSALookupServiceBeginW + WSALookupServiceEnd + WSALookupServiceNextA + WSALookupServiceNextW + WSARemoveServiceClass + WSASetServiceA + WSASetServiceW + WSAStringToAddressA + WSAStringToAddressW + WSCUnInstallNameSpace + WSCInstallNameSpace + WS2_32_gethostbyaddr + WS2_32_gethostbyname + WS2_32_gethostname + WS2_32_getprotobyname + WS2_32_getprotobynumber + WS2_32_getservbyname + WS2_32_getservbyport + WS2_32_inet_addr + WS2_32_inet_ntoa + __WSAFDIsSet + diff --git a/include/nwnss/include/xAdminVolume.h b/include/nwnss/include/xAdminVolume.h index 03a6a34..189868f 100644 --- a/include/nwnss/include/xAdminVolume.h +++ b/include/nwnss/include/xAdminVolume.h @@ -42,7 +42,7 @@ +-------------------------------------------------------------------------*/ #ifndef _XADMINVOLUME_H_ #define _XADMINVOLUME_H_ -#include +#include #ifdef __cplusplus extern "C" { diff --git a/include/nwnss/include/xCache.h b/include/nwnss/include/xCache.h index 8a14b13..67e0c17 100644 --- a/include/nwnss/include/xCache.h +++ b/include/nwnss/include/xCache.h @@ -44,23 +44,23 @@ #define _XCACHE_H_ #ifndef _LATCH_H_ -# include +# include #endif #ifndef _QUE_H_ -# include +# include #endif #ifndef _ALARM_H_ -# include +# include #endif #ifndef _CONTROL_H_ -# include +# include #endif #ifndef _FSM_H_ -# include +# include #endif @@ -78,7 +78,7 @@ struct Pool_s; typedef void (*AgentSignalFunc_t)(struct Agent_s *agent); #ifndef _ASYNCIO_H_ -# include +# include #endif @@ -93,20 +93,20 @@ typedef void (*AgentSignalFunc_t)(struct Agent_s *agent); * the toss but do remove it from the hash list. On the last release, * we put it at the head of the LRU queue. */ -#define CACHE_CLEAR 0 /* No flags set */ +#define CACHE_CLEAR 0 /* No flags set */ #define CACHE_DIRTY 0x1 /* Needs to be flushed to disk */ #define CACHE_VICTIM 0x2 /* Was selected as a victim but - * was dirty and needed to be - * written. Put at front of LRU - * queue when done. - */ + * was dirty and needed to be + * written. Put at front of LRU + * queue when done. + */ #define CACHE_TOSS 0x4 /* When this cache buffer is released, * just toss it even if it is dirty. * (It has already been removed from * the hash list). */ #define CACHE_LOG_TEST 0x8 /* Used while undo/redo testing for - * recovery to not release buffers + * recovery to not release buffers */ #define CACHE_MEMORY_BUFFER 0x10 /* Used by admin volume to indicate * whether a buffer should be flushed @@ -121,15 +121,15 @@ typedef void (*AgentSignalFunc_t)(struct Agent_s *agent); * user data. */ #define CACHE_FAKE_BUFFER 0x80 /* Used while waiting to alloc a - * cache buffer, so that another - * requesting this same buffer + * cache buffer, so that another + * requesting this same buffer * knows about it. */ #define CACHE_HAS_LINUX_PAGE 0x100 /* This buffer has a page associated * with a inode that Linux is * managing. If this buffer is not - * dirty and/or bonded, we can - * return the page to the linux + * dirty and/or bonded, we can + * return the page to the linux * cache and we will look for it * there. */ @@ -140,20 +140,20 @@ typedef void (*AgentSignalFunc_t)(struct Agent_s *agent); // * Linux cache and if found, associate // * it with this buffer again. // */ -#define CACHE_STATE_INVALID 0x400 -#define CACHE_DATA_VALID 0x800 /* The data in the page +#define CACHE_STATE_INVALID 0x400 +#define CACHE_DATA_VALID 0x800 /* The data in the page * pointed to by this buffer is - * valid. No need to read from + * valid. No need to read from * disk again. */ - + /* * Access modes for cache */ #define CACHE_READ 0 /* Going to read -> shared access */ #define CACHE_WRITE 1 /* Going to write whole block -> exlusive */ #define CACHE_UPDATE 2 /* Going to update part of block ->exlusive */ - + /*------------------------------------------------------------------------- @@ -172,16 +172,16 @@ typedef struct Agent_s Agent_s; /* These are values for Agent_s state */ /* the values 0xFFFF0000 are reserved for local use by the object which * contains the agent */ -#define AGENT_FLUSHING 0x0001 /* The agent wants to be flushed +#define AGENT_FLUSHING 0x0001 /* The agent wants to be flushed */ -#define AGENT_AWAIT_SIGNALS 0x0002 /* Waiting for dependent signals - * before flushing. */ +#define AGENT_AWAIT_SIGNALS 0x0002 /* Waiting for dependent signals + * before flushing. */ #define AGENT_WAIT_FOR_COMMIT 0x0004 /* Wait for the ZLOG buffer to which - * the EndXLocal gets written to + * the EndXLocal gets written to * commit */ #define AGENT_LOCAL_STATE_FLAGS 0xFFFF0000 /* The values in the high word of - * state are reserved for local use by the + * state are reserved for local use by the * object which contains the agent */ struct Agent_s @@ -218,7 +218,7 @@ typedef struct Bond_s typedef struct MyCache_s { DQhead_t bufList; /* Buffers owned by beast */ - Agent_s agent; /* Agent that is dependent */ + Agent_s agent; /* Agent that is dependent */ BYTE bufSizeShift; /* Size file cache buffer log 2 */ BYTE reserved[1]; /* Align structure */ WORD state; /* State of the mycache */ @@ -230,11 +230,11 @@ typedef struct MyCache_s * should be reflected in zBuffer_s in zParams.h * zBuffer_s specifies fileBlk to be a QUAD, and if Blknum_t * is changed to be 64-bit, the pad from this strucuture should be - * removed + * removed *-------------------------------------------------------------------------*/ typedef struct PubBuffer_s { - BYTE *data; /* Place first so other layers + BYTE *data; /* Place first so other layers * can access it with out knowing * details. */ @@ -256,7 +256,7 @@ typedef struct Buffer_s SQUAD volBlk; /* Location in volume */ #endif - Agent_s agent; /* Agent for buffer */ + Agent_s agent; /* Agent for buffer */ DQlink_t hashLink; /* Link for hash queue */ DQlink_t lruLink; /* Link for LRU list */ @@ -266,7 +266,7 @@ typedef struct Buffer_s * delayed on. Used by ZLOG to delay signals * until all previous log buffers have been * flushed. - */ + */ AgentSignalFunc_t writeDone;/* if non-zero, when a write completes this * routine should be called instead of doing * the standard processing which consists of @@ -332,7 +332,7 @@ extern Buffer_s CACHE_SparseBuffer; /* Used for sparse files */ #define CACHE_MARK_DIRTY(_buf) \ cacheMarkDirty(_buf) \ - + #define CACHE_CLEAN(_buf) \ ((_buf)->state &= ~CACHE_DIRTY) @@ -356,7 +356,7 @@ extern Buffer_s CACHE_SparseBuffer; /* Used for sparse files */ #define CACHE_MARK_DIRTY(_buf) \ cacheMarkDirty(_buf) \ - + #define CACHE_CLEAN(_buf) \ ((_buf)->state &= ~CACHE_DIRTY) @@ -395,13 +395,13 @@ extern Buffer_s CACHE_SparseBuffer; /* Used for sparse files */ #define CACHE_UNPIN(_buf) \ ((void)(zASSERT((_buf)->pinned != 0),((--(_buf)->pinned) || cacheUnpinned(_buf)))) -extern void initMyCache( +extern void initMyCache( MyCache_s *mycache, AgentSignalFunc_t signal, NINT bufSizeShift, char *name); -extern void checkMyCache( +extern void checkMyCache( MyCache_s *mycache); @@ -424,12 +424,12 @@ extern void cacheFlushMyCacheBufs( MyCache_s *mycache); extern void asyncCacheAllocBuffer( - Asyncio_s *asyncio, + Asyncio_s *asyncio, voidfunc_t action, AgentSignalFunc_t signal ); extern void asyncCacheAllocBufferForUserData( - Asyncio_s *asyncio, + Asyncio_s *asyncio, voidfunc_t action, AgentSignalFunc_t signal ); @@ -534,7 +534,7 @@ extern void cacheGiveBuffer(Buffer_s *buffer); #define NO_SIGNALS(_d) (STK_EMPTY((_d)->signalList)) extern void initAgent( - Agent_s *agent, + Agent_s *agent, AgentSignalFunc_t signal, char *name); diff --git a/include/nwnss/include/xError.h b/include/nwnss/include/xError.h index e2076a4..6d7c878 100644 --- a/include/nwnss/include/xError.h +++ b/include/nwnss/include/xError.h @@ -45,7 +45,7 @@ #define _XERROR_H_ #ifndef _ZOMNI_H_ -# include +# include #endif #ifdef __cplusplus @@ -107,18 +107,18 @@ extern void MSG_SetStatus( /*--------------------------------------------------------------------- * Internal development-only error codes *---------------------------------------------------------------------*/ -#define zERR_FAILURE 24999/* use this if you want - * to return an error but - * don't want to find the - * exact error now. - * These should all go - * away before a release*/ +#define zERR_FAILURE 24999/* use this if you want + * to return an error but + * don't want to find the + * exact error now. + * These should all go + * away before a release*/ /*------------------------------------------------------------------------- * Include the error codes *-------------------------------------------------------------------------*/ #ifndef _ZERROR_H_ -# include +# include #endif #ifdef __cplusplus diff --git a/include/nwnss/include/zapi_library.h b/include/nwnss/include/zapi_library.h new file mode 100644 index 0000000..19c0db2 --- /dev/null +++ b/include/nwnss/include/zapi_library.h @@ -0,0 +1,52 @@ +/**************************************************************************** + | + | (C) Copyright 1995 - 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2006-08-17 14:23:17 -0600 (Thu, 17 Aug 2006) $ + | + | $RCSfile$ + | $Revision: 1489 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Header file to define interface between the zapi + | driver and the zapi library (zapi, libzapi). + +-------------------------------------------------------------------------*/ + +#ifndef _ZAPI_LIBRARY_H_ +#define _ZAPI_LIBRARY_H_ + +/* + * Operations not covered by the list in public/zFsMsg.h + */ +typedef enum Special_ops_e { + SPL_ROOTKEY = 1000, + SPL_CLOSE, + SPL_READ, + SPL_LAST_OP, + SPL_NUM_OPS = SPL_LAST_OP - SPL_ROOTKEY} Special_ops_e; + +#endif diff --git a/include/nwnss/internal/NssPageRuntime.h b/include/nwnss/internal/NssPageRuntime.h deleted file mode 100644 index ffd611d..0000000 --- a/include/nwnss/internal/NssPageRuntime.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef NSS_INTERNAL_PAGE_RUNTIME_H -#define NSS_INTERNAL_PAGE_RUNTIME_H - -#if defined(NSS_USERSPACE) - -#include -#include - -struct page { - void *data; -}; - -struct super_block { - void *s_fs_info; -}; - -struct NssRuntimeTime_s { - long tv_sec; - long tv_nsec; -}; - -struct inode { - void *i_mapping; - struct super_block *i_sb; - unsigned long i_ino; - void *i_private; - long i_mode; - long i_uid; - struct NssRuntimeTime_s i_atime; - struct NssRuntimeTime_s i_ctime; - struct NssRuntimeTime_s i_mtime; -}; - -struct dentry { - struct inode *d_inode; -}; - -typedef struct NssRuntimeKmemCache_s { - size_t objectSize; -} kmem_cache_t; - -#ifndef SLAB_KERNEL -#define SLAB_KERNEL 0 -#endif -#ifndef GFP_HIGHUSER -#define GFP_HIGHUSER 0 -#endif - -#ifndef GFP_KERNEL -#define GFP_KERNEL 0 -#endif -#ifndef __cacheline_aligned_in_smp -#define __cacheline_aligned_in_smp -#endif -#ifndef KM_USER0 -#define KM_USER0 0 -#endif -#ifndef KM_USER1 -#define KM_USER1 1 -#endif - -kmem_cache_t *NssRuntimeKmemCacheCreate(const char *name, - size_t objectSize, - size_t align, - unsigned long flags, - void *ctor, - void *dtor); -void *NssRuntimeKmemCacheAlloc(kmem_cache_t *cache, int flags); -void NssRuntimeKmemCacheFree(kmem_cache_t *cache, void *object); -void NssRuntimeKmemCacheDestroy(kmem_cache_t *cache); - -struct page *NssRuntimeAllocPage(int flags); -void NssRuntimeFreePage(struct page *page); -void *NssRuntimeKmapAtomic(struct page *page, int kmType); -void NssRuntimeKunmapAtomic(void *addr, int kmType); -struct page *NssRuntimeFindGetPage(void *mapping, unsigned long index); -struct page *NssRuntimeGrabCachePage(void *mapping, unsigned long index); -void NssRuntimeSiMeminfo(struct sysinfo *si); - -#define kmem_cache_create(_name, _size, _align, _flags, _ctor, _dtor) \ - NssRuntimeKmemCacheCreate((_name), (_size), (_align), (_flags), \ - (_ctor), (_dtor)) -#define kmem_cache_alloc(_cache, _flags) \ - NssRuntimeKmemCacheAlloc((_cache), (_flags)) -#define kmem_cache_free(_cache, _object) \ - NssRuntimeKmemCacheFree((_cache), (_object)) -#define kmem_cache_destroy(_cache) NssRuntimeKmemCacheDestroy((_cache)) -#define kmalloc(_size, _flags) zalloc((_size)) -#define alloc_page(_flags) NssRuntimeAllocPage((_flags)) -#define __free_page(_page) NssRuntimeFreePage((_page)) -#define PageHighMem(_page) TRUE -#define kmap_atomic(_page, _kmType) NssRuntimeKmapAtomic((_page), (_kmType)) -#define kunmap_atomic(_addr, _kmType) NssRuntimeKunmapAtomic((_addr), (_kmType)) -#define kmap(_page) NssRuntimeKmapAtomic((_page), KM_USER0) -#define kunmap(_page) NssRuntimeKunmapAtomic((_page) ? (_page)->data : NULL, KM_USER0) -#define find_get_page(_mapping, _index) NssRuntimeFindGetPage((_mapping), (_index)) -#define grab_cache_page(_mapping, _index) NssRuntimeGrabCachePage((_mapping), (_index)) -#define invalidate_inode_pages(_mapping) ((void)(_mapping)) -#define mark_page_accessed(_page) ((void)(_page)) -#define page_cache_release(_page) ((void)(_page)) -#define unlock_page(_page) ((void)(_page)) -#define si_meminfo(_si) NssRuntimeSiMeminfo((_si)) - -#endif /* NSS_USERSPACE */ - -#endif /* NSS_INTERNAL_PAGE_RUNTIME_H */ diff --git a/include/nwnss/internal/NssUaccessRuntime.h b/include/nwnss/internal/NssUaccessRuntime.h deleted file mode 100644 index cca278d..0000000 --- a/include/nwnss/internal/NssUaccessRuntime.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef NSS_INTERNAL_UACCESS_RUNTIME_H -#define NSS_INTERNAL_UACCESS_RUNTIME_H - -#if defined(NSS_USERSPACE) - -#include - -typedef int mm_segment_t; - -mm_segment_t NssRuntimeGetFs(void); -mm_segment_t NssRuntimeGetDs(void); -void NssRuntimeSetFs(mm_segment_t fs); -int NssRuntimeCopyToUser(void *dst, const void *src, size_t len); -int NssRuntimeCopyFromUser(void *dst, const void *src, size_t len); - -#define get_fs() NssRuntimeGetFs() -#define get_ds() NssRuntimeGetDs() -#define set_fs(_fs) NssRuntimeSetFs((_fs)) -#define copy_to_user(_dst, _src, _len) \ - NssRuntimeCopyToUser((_dst), (_src), (_len)) -#define copy_from_user(_dst, _src, _len) \ - NssRuntimeCopyFromUser((_dst), (_src), (_len)) - -#endif /* NSS_USERSPACE */ - -#endif /* NSS_INTERNAL_UACCESS_RUNTIME_H */ diff --git a/include/nwnss/internal/adminVolume.h b/include/nwnss/internal/adminVolume.h index 3387793..a61bfb1 100644 --- a/include/nwnss/internal/adminVolume.h +++ b/include/nwnss/internal/adminVolume.h @@ -36,18 +36,18 @@ +-------------------------------------------------------------------------*/ #ifndef _ADMINVOLUME_H_ #define _ADMINVOLUME_H_ -#include +#include #ifndef _QUE_H_ -#include +#include #endif #ifndef _VOLUME_H_ -#include +#include "volume.h" #endif #ifndef _XADMINVOLUME_H_ -#include +#include "xAdminVolume.h" #endif /* Pre-define struct(s) so Linux compiler doesn't complain */ diff --git a/include/nwnss/internal/cacheControl.h b/include/nwnss/internal/cacheControl.h index 9c495aa..aa4f11f 100644 --- a/include/nwnss/internal/cacheControl.h +++ b/include/nwnss/internal/cacheControl.h @@ -47,19 +47,15 @@ #define _CACHECONTROL_H_ #ifndef _QUE_H_ -#include +#include "que.h" #endif #ifndef _FSM_H_ -#include +#include "fsm.h" #endif -#ifndef _ALARM_H_ -#include -#endif - -#ifndef _LATCH_H_ -#include +#ifndef _FSM_H_ +#include "alarm.h" #endif #ifdef __cplusplus @@ -130,3 +126,4 @@ extern void cacheBalance(void); #endif #endif + diff --git a/include/nwnss/include/cmCompFile.h b/include/nwnss/internal/cmCompFile.h similarity index 96% rename from include/nwnss/include/cmCompFile.h rename to include/nwnss/internal/cmCompFile.h index dcd54c3..d15a3fd 100644 --- a/include/nwnss/include/cmCompFile.h +++ b/include/nwnss/internal/cmCompFile.h @@ -47,7 +47,7 @@ #define NCHUNKS_PER_PAGE(_beast) ((1 << (_beast)->blkSizeShift) * NCHUNKS_PER_BYTE) /* Made to look identical to the start of Legacy Netware's header */ -typedef struct CompFileLayoutID_s +typedef struct CompFileLayoutID_s { BYTE endian; BYTE majorVersion; @@ -68,7 +68,7 @@ extern CompFileLayoutID_s NSS_compFileLayout_ID; #define IS_COMPFILE_LAYOUT_NSS(_layoutId) \ ((_layoutId).majorVersion == NSS_COMPFILE_MAJOR_VERSION) -typedef struct CompFileHdr_s +typedef struct CompFileHdr_s { CompFileLayoutID_s fileLayout_ID; BYTE algoID; @@ -77,14 +77,14 @@ typedef struct CompFileHdr_s LONG nvalidChunks; /* # of chunks whose state is maintained currently */ #define DIRECT_CHUNK_VECTOR_BYTES 8 #define NUM_DIRECT_CHUNKS (DIRECT_CHUNK_VECTOR_BYTES * NCHUNKS_PER_BYTE) - BYTE chunkStateVector[DIRECT_CHUNK_VECTOR_BYTES]; + BYTE chunkStateVector[DIRECT_CHUNK_VECTOR_BYTES]; /* Bitmap indicating which chunks are compressed */ } NSS_MEDIA_STRUCTURE(CompFileHdr_s,chunkStateVector[DIRECT_CHUNK_VECTOR_BYTES]) CompFileHdr_s; -typedef struct CompChunkHdr_s +typedef struct CompChunkHdr_s { LONG compChunkSize; /* Size of compressed chunk */ - LONG holeVector; /* Bitmap indicating which (4k) blocks in the chunk + LONG holeVector; /* Bitmap indicating which (4k) blocks in the chunk * are holes; limits chunk size to 32 * 4K = 128kbytes */ BYTE algoID; BYTE algoVersion; @@ -148,7 +148,7 @@ CM_tossBeastCompChunk( _chunkSize, _dataOffset, _dataSize) \ setBeastChunkValidRange(_genMsg, _beast, _chunkSize, _dataOffset, \ _dataSize) - + STATUS setBeastChunkValidRange( GeneralMsg_s *genMsg, @@ -164,7 +164,7 @@ CM_tossUncompBeastData( RootBeast_s *compBeast, BOOL recovery); -STATUS +STATUS CM_tossCompBeastData( GeneralMsg_s *genMsg, RootBeast_s *uncompBeast, diff --git a/include/nwnss/internal/cmDefs.h b/include/nwnss/internal/cmDefs.h index 7c4a229..ce5c070 100644 --- a/include/nwnss/internal/cmDefs.h +++ b/include/nwnss/internal/cmDefs.h @@ -45,18 +45,14 @@ #include #include #include -#include +#include #define INSIDE_CM 1 -#ifdef NSS_USERSPACE -#include -#else #include "mpkapis.h" -#endif -#include -#include -#include +#include "comnPublics.h" +#include "xError.h" +#include "que.h" #define TRUNC(_value, _size) (((_value) / (_size)) * (_size)) diff --git a/include/nwnss/internal/comnCompress.h b/include/nwnss/internal/comnCompress.h index fbf0400..f30560b 100644 --- a/include/nwnss/internal/comnCompress.h +++ b/include/nwnss/internal/comnCompress.h @@ -43,12 +43,12 @@ * Stored in the rootBeast's RootVariableData area of uncompressed data streams. */ /* Persistent portion */ -typedef struct PersistentCompressInfo_s +typedef struct PersistentCompressInfo_s { Zid_t compZid; /* ZID of the compressed stream's rootBeast */ LONG chunkSize; /* Compression Chunk size (0 means whole file) */ - /* + /* * An (un)compressed version of a chunk is precious if it contains valid * user data and should not be discarded, either because it is the only * valid copy, or because the user told us not to discard it (eg, by @@ -57,7 +57,7 @@ typedef struct PersistentCompressInfo_s LONG UCprecious; /* # precious uncompressed chunks */ LONG Cprecious; /* # precious compressed chunks */ Blknum_t purgeableBlks; /* # purgeable blocks currently contributed - * by this beast to the volume's + * by this beast to the volume's * VOLpurgeableBlks count */ BYTE algoID; /* Algorithm ID (Compression Manager-specific) */ BYTE algoVersion; @@ -92,14 +92,14 @@ typedef struct PackedCompInfo_s PersistentCompressInfo_s cmInfo; } NSS_MEDIA_STRUCTURE(PackedCompInfo_s,cmInfo) PackedCompInfo_s; -typedef struct CompressInfo_s +typedef struct CompressInfo_s { PersistentCompressInfo_s p; /* Persistent portion */ /* Non-persistent portion */ DQhead_t CM_activities; /* Head of list of ongoing (de)compression * activities for this beast */ - DQhead_t dataWaiters; /* Head of list of all threads waiting for + DQhead_t dataWaiters; /* Head of list of all threads waiting for * uncompressed data to become available */ } CompressInfo_s; @@ -145,7 +145,7 @@ decompCleanup( BOOL recovery, Xaction_s *xaction); -Buffer_s * +Buffer_s * CM_fetchFileBlk( GeneralMsg_s *genMsg, RootBeast_s *beast, @@ -155,7 +155,7 @@ CM_fetchFileBlk( void updateBeastPurgeableBlksCnt( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamedBeast_s *beast, RootBeast_s *compBeast, BOOL includeCompBeastInfo, /* Include compBeast's blks also (if any) */ diff --git a/include/nwnss/internal/dirQuotas.h b/include/nwnss/internal/dirQuotas.h index 8e8158f..9067913 100644 --- a/include/nwnss/internal/dirQuotas.h +++ b/include/nwnss/internal/dirQuotas.h @@ -174,7 +174,7 @@ void DIRQ_FixSetQuotaQueue( STATUS DIRQ_Startup(); void DIRQ_Shutdown(); - + #if NSS_DEBUG IS_ENABLED /* Pre-define struct(s) so Linux compiler doesn't complain */ struct PCLSwitchDef_s; diff --git a/include/nwnss/internal/jio.imp b/include/nwnss/internal/jio.imp new file mode 100644 index 0000000..c8f77bd --- /dev/null +++ b/include/nwnss/internal/jio.imp @@ -0,0 +1,31 @@ +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zAbortXaction +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zAddTrustee +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zBeginTask +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zBeginXaction +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zClose +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zCommitXaction +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zCreate +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zDelete +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zDeleteTrustee +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zDIORead +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zDIOWrite +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zEndTask +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zFlush +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zGetFileMap +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zGetInfo +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zGetInheritedRightsMask +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zGetTrustee +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zLink +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zLockByteRange +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zModifyInfo +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zOpen +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zPrepareToCommitXaction +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zRead +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zRename +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zRootKey +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zSetEOF +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zSetInheritedRightsMask +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zUnlockByteRange +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zWildRead +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zWildRewind +Java_com_novell_service_file_nss_rmi_ZAPIImpl__1zWrite diff --git a/include/nwnss/internal/jni_md.h b/include/nwnss/internal/jni_md.h new file mode 100644 index 0000000..aad74bb --- /dev/null +++ b/include/nwnss/internal/jni_md.h @@ -0,0 +1,45 @@ +/* + * @(#)jni_md.h 1.17 03/01/23 + * + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +#ifndef _JAVASOFT_JNI_MD_H_ +#define _JAVASOFT_JNI_MD_H_ + +#define JNIEXPORT +#define JNIIMPORT +#define JNICALL + +typedef void FILE; +typedef long jint; +typedef QUAD jlong; +typedef signed char jbyte; + +/* + * the next turns off the NETWARE style of varargs and changes them to + * use the ABI style of varargs... -- fixes C++ users for JNI + */ + +#if !(defined(_STDARG_H_) || defined(__STDARG_H__) || defined(_STDARG_H_INCLUDED)) +#define _STDARG_H_ +#define _STDARG_H_INCLUDED +#define __STDARG_H__ + +#ifndef __linux__ +typedef char * va_list; +#endif + +#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) ) + +#if defined(va_start) || defined(va_arg) || defined(va_end) +// For now, use an else clause ... However we may want to undef and use ours +#else +#define va_start(ap,v) ( ap = (va_list)&v + _INTSIZEOF(v) ) +#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) ) +#define va_end(ap) ( ap = (va_list)0 ) +#endif + +#endif +#endif /* !_JAVASOFT_JNI_MD_H_ */ diff --git a/include/nwnss/internal/lsaXattrUserspace.h b/include/nwnss/internal/lsaXattrUserspace.h deleted file mode 100644 index 6ab5095..0000000 --- a/include/nwnss/internal/lsaXattrUserspace.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef NSS_INTERNAL_LSA_XATTR_USERSPACE_H -#define NSS_INTERNAL_LSA_XATTR_USERSPACE_H - -#if defined(NSS_USERSPACE) - -#include -#include - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct NssLsaXattrUserspace_s { - struct super_block superBlock; - LsaSuper_s lsaSuper; - LsaInode_s lsaInode; - struct inode inode; - struct dentry dentry; - NssUserspaceProvider_s provider; -} NssLsaXattrUserspace_s; - -void NssLsaXattrUserspaceInit(NssLsaXattrUserspace_s *xattr, - VolumeID_t volumeId, - NINT nameSpace, - Zid_t zid); -int NssLsaXattrUserspaceInitOtherfsPath(NssLsaXattrUserspace_s *xattr, - const char *path); -struct dentry *NssLsaXattrUserspaceDentry(NssLsaXattrUserspace_s *xattr); -void NssLsaXattrUserspaceSetProvider(NssLsaXattrUserspace_s *xattr, - NssUserspaceProviderKind_e provider); -NssUserspaceProviderKind_e -NssLsaXattrUserspaceGetProvider(const NssLsaXattrUserspace_s *xattr); -const NssUserspaceProvider_s * -NssLsaXattrUserspaceProvider(const NssLsaXattrUserspace_s *xattr); -const char *NssLsaXattrUserspaceNssName(const char *name); -int NssLsaXattrUserspaceOtherfsName(const char *name, - char *buffer, - size_t bufferSize); -ssize_t NssLsaXattrUserspaceGet(NssLsaXattrUserspace_s *xattr, - const char *name, - void *value, - size_t size); -ssize_t NssLsaXattrUserspaceSet(NssLsaXattrUserspace_s *xattr, - const char *name, - const void *value, - size_t size); -int NssLsaXattrUserspaceRemove(NssLsaXattrUserspace_s *xattr, - const char *name); -LsaInode_s *NssLsaXattrUserspaceInodePrivate(struct inode *inode); - -#ifdef __cplusplus -} -#endif - -#endif /* NSS_USERSPACE */ - -#endif /* NSS_INTERNAL_LSA_XATTR_USERSPACE_H */ diff --git a/include/nwnss/internal/macNSpace.h b/include/nwnss/internal/macNSpace.h index dcbd8a5..76fbfc5 100644 --- a/include/nwnss/internal/macNSpace.h +++ b/include/nwnss/internal/macNSpace.h @@ -38,7 +38,7 @@ #define _MACNSPACE_H_ #ifndef _OMNI_H_ -#include +#include #endif /*--------------------------------------------------------------------------- @@ -46,7 +46,7 @@ *---------------------------------------------------------------------------*/ /***** fixfixfix@nextMediaFormatChange begin *******/ #define MACNS_NAME_LIMIT 255 // Changed from 31 to 255 to support AFP 3.1 9/04 -#define MACNS_LEGACY_NAME_LIMIT 31 +#define MACNS_LEGACY_NAME_LIMIT 31 /***** fixfixfix@nextMediaFormatChange end *******/ /*--------------------------------------------------------------------------- @@ -133,7 +133,7 @@ extern NINT MACNS_generateUniqueName( extern STATUS MACNS_getSeparator( GeneralMsg_s *genMsg, - NINT type, + NINT type, unicode_t **retStr, NINT *retLen); diff --git a/include/nwnss/internal/macNSpaceUserspace.h b/include/nwnss/internal/macNSpaceUserspace.h deleted file mode 100644 index 9270bf7..0000000 --- a/include/nwnss/internal/macNSpaceUserspace.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** - | - | Userspace boundary for NSS Macintosh namespace metadata. - | - | The NSS MAC namespace stores Finder metadata as RVD_MAC_META_DATA and - | resource forks as the data stream named MAC_RF. This boundary maps those - | semantics to Netatalk's adouble:ea host representation for OtherFS userspace - | providers, per object, without extending netware.metadata. - +-------------------------------------------------------------------------*/ -#ifndef _MACNSPACE_USERSPACE_H_ -#define _MACNSPACE_USERSPACE_H_ - -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define NSS_MAC_NETATALK_METADATA_XATTR "org.netatalk.Metadata" -#define NSS_MAC_NETATALK_RESOURCE_XATTR "org.netatalk.ResourceFork" -#define NSS_MAC_NETATALK_METADATA_HOST_XATTR "user.org.netatalk.Metadata" -#define NSS_MAC_NETATALK_RESOURCE_HOST_XATTR "user.org.netatalk.ResourceFork" -#define NSS_MAC_RESOURCE_FORK_STREAM_NAME "MAC_RF" - -#define NSS_MAC_NETATALK_AD_MAGIC 0x00051607u -#define NSS_MAC_NETATALK_AD_VERSION_EA 0x00020002u -#define NSS_MAC_NETATALK_METADATA_SIZE 402u -#define NSS_MAC_NETATALK_FINDER_INFO_SIZE 32u - -const char *NssMacUserspaceMetadataXattrName(void); -const char *NssMacUserspaceResourceForkXattrName(void); -const char *NssMacUserspaceMetadataHostXattrName(void); -const char *NssMacUserspaceResourceForkHostXattrName(void); -const char *NssMacUserspaceResourceForkStreamName(void); - -void NssMacUserspaceInitDefaultMacInfo(zMacInfo_s *macInfo, int isDirectory); -int NssMacUserspaceBuildNetatalkMetadata(const zMacInfo_s *macInfo, - unsigned char *buffer, - size_t bufferSize); -int NssMacUserspaceParseNetatalkMetadata(const unsigned char *buffer, - size_t bufferSize, - zMacInfo_s *macInfo); - -int NssMacUserspaceWriteNetatalkMetadata(const char *path, - const zMacInfo_s *macInfo); -int NssMacUserspaceReadNetatalkMetadata(const char *path, - zMacInfo_s *macInfo); -int NssMacUserspaceWriteResourceFork(const char *path, - const void *data, - size_t dataSize); -ssize_t NssMacUserspaceReadResourceFork(const char *path, - void *data, - size_t dataSize); - -#ifdef __cplusplus -} -#endif - -#endif /* _MACNSPACE_USERSPACE_H_ */ diff --git a/include/nwnss/internal/mediaManager.imp b/include/nwnss/internal/mediaManager.imp new file mode 100644 index 0000000..af050bc --- /dev/null +++ b/include/nwnss/internal/mediaManager.imp @@ -0,0 +1,4 @@ +MM_Return_Object_Generic_Info +MM_Return_Object_Specific_Info +MM_Return_Object_Mapping_Info +MM_Find_Object_Type diff --git a/include/nwnss/internal/mgmt.h b/include/nwnss/internal/mgmt.h index 9b753dd..cb34f26 100644 --- a/include/nwnss/internal/mgmt.h +++ b/include/nwnss/internal/mgmt.h @@ -37,23 +37,18 @@ #ifndef _MGMT_H_ #define _MGMT_H_ -#ifdef NSS_USERSPACE -typedef struct Volume_s Volume_s; -typedef struct Pool_s Pool_s; -#endif - #ifndef _MANAGE_H_ -#include +#include #endif #if zNETWARE || (zLINUX && defined(__KERNEL__)) #ifndef _ADMINVOLUME_H_ -#include +#include #endif #ifndef _XMLNSS_H_ -#include +#include #endif #endif @@ -65,7 +60,7 @@ extern "C" { //extern BOOL ComnMgmtFileSetup; #define MAX_UTF8_BUF_SIZE ((zMAX_FULL_NAME + 1) * sizeof(utf8_t) * 3) -#if zNETWARE || zLINUX +#if zNETWARE || (zLINUX && defined(__KERNEL__)) /**************************************************************************** * Type definition used by Management files * ****************************************************************************/ @@ -86,7 +81,7 @@ typedef struct AVFileLink_s /*--------------------------------------------------------------------------* - * Functions for virtual files + * Functions for virtual files *--------------------------------------------------------------------------*/ void MGMT_BuildResultNSS( STATUS result, @@ -109,9 +104,9 @@ STATUS DBG_EqualS( #endif /*--------------------------------------------------------------------------* - * Functions for NSS static management files * + * Functions for NSS static management files * *--------------------------------------------------------------------------*/ -#if zNETWARE || zLINUX +#if zNETWARE || (zLINUX && defined(__KERNEL__)) STATUS AVFileAddLink( DQhead_t *RegMgmtFilesHead, BYTE *pathStr); @@ -122,14 +117,14 @@ STATUS AVFileRemoveLink( /*--------------------------------------------------------------------------* - * Functions for NSS static management files * + * Functions for NSS static management files * *--------------------------------------------------------------------------*/ extern STATUS MGMT_StartupReadInsts( struct GeneralMsg_s *genMsg); extern void MGMT_ShutdownReadInsts(); /*--------------------------------------------------------------------------* - * Functions for volume management files * + * Functions for volume management files * *--------------------------------------------------------------------------*/ extern STATUS addVolumeMgmtFile(GeneralMsg_s *genMsg, unicode_t *volumeName); extern void removeVolumeMgmtFileByName(GeneralMsg_s *genMsg, unicode_t *volName); @@ -139,41 +134,41 @@ STATUS findVolume( Volume_s **volume); /* out */ /*--------------------------------------------------------------------------* - * Functions for pool management files * + * Functions for pool management files * *--------------------------------------------------------------------------*/ extern STATUS addPoolMgmtFile(GeneralMsg_s *genMsg, unicode_t *poolName); extern void removePoolMgmtFileByName(GeneralMsg_s *genMsg, unicode_t *poolName); extern void removePoolMgmtFile(GeneralMsg_s *genMsg, void *pool); /*--------------------------------------------------------------------------* - * Functions for server management files * + * Functions for server management files * *--------------------------------------------------------------------------*/ extern STATUS MGMT_StartupOS(); extern void MGMT_ShutdownOS(); /*--------------------------------------------------------------------------* - * Functions for connection management files * + * Functions for connection management files * *--------------------------------------------------------------------------*/ extern void CNCT_addMgmtFile(SNINT connNum); #ifdef ADMIN_NSS ///*--------------------------------------------------------------------------* -// * Functions for NSS XSL file * +// * Functions for NSS XSL file * // *--------------------------------------------------------------------------*/ ///* NSS data type tag, tags are always appear as pairs. */ //#define NSSNONE 0 /* every element is preformatted */ -//#define NSSNUMBER 2 /* the tag will be */ -//#define NSSSTRING 4 /* the tag will be */ +//#define NSSNUMBER 2 /* the tag will be */ +//#define NSSSTRING 4 /* the tag will be */ //#define NSSPERCENT 6 /* the tag will be */ // //extern BYTE *NSStag[]; // ///* XML Form method */ -//#define NONE 0 -//#define PUT 1 -//#define POST 2 -//#define GET 3 +//#define NONE 0 +//#define PUT 1 +//#define POST 2 +//#define GET 3 // //typedef struct XML_s //{ @@ -197,8 +192,8 @@ extern void CNCT_addMgmtFile(SNINT connNum); // /* if type is NSSNUMBER, it adds label element */ // /* for the purpose of display of percent */ // /* attribute. */ -// /* if type is NSSNONE, it's assumed to be preformatted */ -// /* and will be used directly */ +// /* if type is NSSNONE, it's assumed to be preformatted */ +// /* and will be used directly */ // }data; // struct /* if this file needs a way to write */ // { /* By default, we provide a FORM method to write */ @@ -224,18 +219,18 @@ extern void CNCT_addMgmtFile(SNINT connNum); // NINT method, // BYTE *action, // BYTE *done, -// BYTE *prompt, +// BYTE *prompt, // BYTE *buffer, // NINT bufferLength); -// +// //extern void XMLUnConvert( -// BYTE *buffer, +// BYTE *buffer, // size_t bufLen, -// BYTE *content, -// size_t *retLen, -// void *number, -// BOOL *isQuad, -// NINT *type); +// BYTE *content, +// size_t *retLen, +// void *number, +// BOOL *isQuad, +// NINT *type); #endif @@ -393,12 +388,12 @@ STATUS MNSS_GetSpecificTemplate( XML_ElementInfo_s *resultInfo ); STATUS MNSS_GetResultTemplate( utf8_t *tagString, /* Must be "..." */ - NINT templateLen, + NINT templateLen, utf8_t *template, XML_ElementInfo_s *resultInfo ); STATUS MNSS_GetResultValueAttribute( utf8_t *tagString, /* Must be "..." */ - NINT templateLen, + NINT templateLen, utf8_t *template, SQUAD *sqValue ); /* Output - Value of Results 'value' * attribute. @@ -447,7 +442,7 @@ STATUS MNSS_ConvertBitsToTags( NINT bufLen, utf8_t *buf, NINT *dataLen); - + QUAD MNSS_ConvertTagsToBits( QUAD bitsToCheck, utf8_t **tags, @@ -462,11 +457,11 @@ SNINT MNSS_ConvertNameTypeTagsToValue( #if zNETWARE || (zLINUX && !defined(__KERNEL__)) void LogoutFromNDS( - int context, + int context, int agentIdentityHandle); NINT LoginToNDS( - int context, + int context, int *agentIdentityHandle); void MNSS_ConvertToRootLeft( @@ -479,18 +474,18 @@ STATUS MNSS_GetObjectIDFromName( LONG *objectID); #define MNDS_GetObjectIDFromName MNSS_GetObjectIDFromName #endif - + STATUS MNSS_GetNDSNameFromGUID( // Volume_s *volume, void *volume, UserID_t *guid, utf8_t *objectName); -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) #if zLINUX STATUS MNSS_FindUserIDByDN( unsigned char *context, - unsigned char *dn, + unsigned char *dn, UserID_t *userID); #define MFILE_FindUserIDByDN MNSS_FindUserIDByDN #endif @@ -508,26 +503,26 @@ STATUS MNSS_FillInAnID( NINT bufLen, utf8_t *buf, NINT *dataLen); - + STATUS MNSS_GetGUIDFromName( - utf8_t *name, + utf8_t *name, UserID_t *ndsGUID); STATUS getModifyValue( - GeneralMsg_s *genMsg, - XML_ElementInfo_s *element, + GeneralMsg_s *genMsg, + XML_ElementInfo_s *element, utf8_t **oldValueStr, utf8_t **newValueStr); STATUS modifyInfoTimeStr( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, void *beast, - ADDR address, - XML_ElementInfo_s *element, + ADDR address, + XML_ElementInfo_s *element, Xaction_s *xaction, BOOL doChange); - + STATUS modifyTimeXML( GeneralMsg_s *genMsg, void *beast, @@ -545,59 +540,59 @@ STATUS modifyIDXML( BOOL doChange); STATUS modifyInfoBOOL( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, void *beast, - ADDR address, - XML_ElementInfo_s *element, + ADDR address, + XML_ElementInfo_s *element, Xaction_s *xaction, - BOOL doChange); + BOOL doChange); + - -#define modifyInfoNumber(genMsg, beast, type, isSigned, address, element) \ -{ \ - type oldValue; \ - type newValue; \ +#define modifyInfoNumber(genMsg, beast, type, isSigned, address, element) \ +{ \ + type oldValue; \ + type newValue; \ utf8_t *oldValueStr = NULL; \ utf8_t *newValueStr = NULL; \ \ getModifyValue(genMsg, element, &oldValueStr, &newValueStr); \ if (status == zOK) \ { \ - if (!newValueStr || !oldValueStr) \ - { \ - SetErrno(genMsg, zERR_XML_IS_BAD); \ - status = zFAILURE; \ - } \ - else \ + if (!newValueStr || !oldValueStr) \ + { \ + SetErrno(genMsg, zERR_XML_IS_BAD); \ + status = zFAILURE; \ + } \ + else \ { \ - if (sizeof(type) == sizeof(QUAD)) \ - { \ - if (isSigned) \ - { \ - oldValue = strtoq(oldValueStr, NULL, 10); \ - newValue = strtoq(newValueStr, NULL, 10); \ - } \ - else \ - { \ - oldValue = strtouq(oldValueStr, NULL, 10); \ - newValue = strtouq(newValueStr, NULL, 10); \ - } \ - } \ - else if (sizeof(type) <= sizeof(LONG)) \ - { \ - if (isSigned) \ - { \ - oldValue = strtol(oldValueStr, NULL, 10); \ - newValue = strtol(newValueStr, NULL, 10); \ - } \ - else \ - { \ - oldValue = strtoul(oldValueStr, NULL, 10); \ - newValue = strtoul(newValueStr, NULL, 10); \ - } \ - } \ - \ - setNumberValueXML(genMsg, beast, type, address, NULL); \ + if (sizeof(type) == sizeof(QUAD)) \ + { \ + if (isSigned) \ + { \ + oldValue = strtoq(oldValueStr, NULL, 10); \ + newValue = strtoq(newValueStr, NULL, 10); \ + } \ + else \ + { \ + oldValue = strtouq(oldValueStr, NULL, 10); \ + newValue = strtouq(newValueStr, NULL, 10); \ + } \ + } \ + else if (sizeof(type) <= sizeof(LONG)) \ + { \ + if (isSigned) \ + { \ + oldValue = strtol(oldValueStr, NULL, 10); \ + newValue = strtol(newValueStr, NULL, 10); \ + } \ + else \ + { \ + oldValue = strtoul(oldValueStr, NULL, 10); \ + newValue = strtoul(newValueStr, NULL, 10); \ + } \ + } \ + \ + setNumberValueXML(genMsg, beast, type, address, NULL); \ } \ } \ if (status != zOK) \ @@ -606,8 +601,6 @@ STATUS modifyInfoBOOL( } \ } -typedef STATUS (*mgmt_change_func_t)(GeneralMsg_s *, void *, void *, void *, Xaction_s *); - #define setNumberValueXML(genMsg, beast, type, address, changeFunc) \ { \ if (!doChange) \ @@ -621,9 +614,9 @@ typedef STATUS (*mgmt_change_func_t)(GeneralMsg_s *, void *, void *, void *, Xac else \ { \ memcpy((void *)address, (void *)&newValue, sizeof(type)); \ - if (((mgmt_change_func_t)changeFunc) != NULL) \ + if (((statusfunc_t)changeFunc) != NULL) \ { \ - status = ((mgmt_change_func_t)changeFunc)(genMsg, beast, &oldValue, &newValue, xaction); \ + status = ((statusfunc_t)changeFunc)(genMsg, beast, &oldValue, &newValue, xaction); \ } \ } \ } @@ -665,3 +658,4 @@ typedef STATUS (*mgmt_change_func_t)(GeneralMsg_s *, void *, void *, void *, Xac #endif #endif + diff --git a/include/nwnss/internal/msgName.h b/include/nwnss/internal/msgName.h index 6090a56..0b6133e 100644 --- a/include/nwnss/internal/msgName.h +++ b/include/nwnss/internal/msgName.h @@ -44,18 +44,18 @@ #ifndef _MSGNAME_H_ #define _MSGNAME_H_ -#include +#include #ifndef _MSGGEN_H_ -#include +#include #endif #ifndef _NAMESPACE_H_ -#include +#include #endif #ifndef _HARDLINK_H_ -#include +#include #endif #ifdef __cplusplus @@ -81,30 +81,30 @@ struct NamingMsg_s { /* INPUT fields */ - BYTE handlePathType; /* Type of input information specified */ + BYTE handlePathType; /* Type of input information specified */ BYTE pathFormat; /* The format of the path (i.e. ASCII, unicode_t, ...) */ - BYTE parseMode; /* mode for path string parsing */ + BYTE parseMode; /* mode for path string parsing */ BYTE pathCount; /* path component count for zPFMT_ASCII_COUNTED strings only */ - WORD parseFlags; /* flags for nameMsg parsing */ + WORD parseFlags; /* flags for nameMsg parsing */ BYTE retParseFlags; /* OUTPUT: flags returned from nameMsg parsing */ - BYTE latchType; /* Type of latch to get on curFile and curDataStream -- defined in latch.h */ + BYTE latchType; /* Type of latch to get on curFile and curDataStream -- defined in latch.h */ NINT pathLength; /* path length for zPFMT_ASCII_LEN strings only */ ContextHandleIDP_s contextHandle; /* valid if pathType == zHPT_CONTEXT */ VolumeID_t volumeID; /* valid if pathType = zHPT_VOLUME or zHPT_VOLUME_ZID */ - struct Volume_s *curvol; /* after lookup, points to volumeID (locked) + struct Volume_s *curvol; /* after lookup, points to volumeID (locked) * NOTE -- This pointer has two associated use - * counts that must be incremented if this + * counts that must be incremented if this * pointer is non-NULL. The basic useCount which * locks the beast in memory, and the keepActiveUseCount * which locks the beast in the ACTIVATED state */ FileHandleIDP_s fileHandle; /* valid if pathType = zHPT_FILEHANDLEID */ - Zid_t fileParentZid; /* Contains parentZid of the file */ + Zid_t fileParentZid; /* Contains parentZid of the file */ NINT fileNameType; /* The name type associated with fileNameUniquifier */ - NINT zidNameType; /* Only set if path is rooted on a starting ZID. + NINT zidNameType; /* Only set if path is rooted on a starting ZID. * This must match the nameType of the beast * identified by that starting ZID. */ - Zid_t fileZid; /* if curFile==NULL, may contain zid of the file */ + Zid_t fileZid; /* if curFile==NULL, may contain zid of the file */ struct File_s *curFile; /* after lookup, points to file beast (locked) * this object is now returned latched by * "COMN_Lookup". Use this beast for authorization @@ -139,7 +139,7 @@ struct NamingMsg_s * filled in with the volumeID of the boundary */ unicode_t *retPath; /* if parsing stops at a volume boundary, is * filled in with the remaining unparsed path*/ - + /* INTERNAL ONLY fields to Naming System*/ unicode_t *workBuffer; /* points to buffer optionally used to store @@ -150,7 +150,7 @@ struct NamingMsg_s BYTE workNameType; /* current name type */ BYTE workPathCount; /* remaining count for ASCII counted Path Strings.*/ BYTE reserved; - + char *lastAsciiSrcPath; /* Saved each time before calling scan of next * ASCII component. */ NINT lastAsciiSrcPathLen; /* Length of lastAsciiSrcPath or -1 */ @@ -160,7 +160,7 @@ struct NamingMsg_s * path component. This maintains state for * the parsing as it is done one component * at a time. */ - + STATUS (*scanNextComponent)( /* This is a shortcut function Ptr */ struct GeneralMsg_s *genMsg, /* used to point to a function that */ struct NamingMsg_s *nameMsg);/* is tailored to know how to scan */ @@ -174,129 +174,129 @@ struct NamingMsg_s * latch, else both are latched/unlatched. If a hardlink beast is present, * it is also latched. *---------------------------------------------------------------------------*/ -#define COMN_LATCH_NAMEMSG_BEASTS(_nameMsg,_latchType) \ -{ \ +#define COMN_LATCH_NAMEMSG_BEASTS(_nameMsg,_latchType) \ +{ \ (_nameMsg)->latchType = _latchType; \ if ((NamedBeast_s *)(_nameMsg)->curFile == (_nameMsg)->curDataStream) \ - { \ + { \ COND_LATCH(&(_nameMsg)->curFile->FILEbeastLatch, (_nameMsg)->latchType); \ - } \ - else \ - { \ + } \ + else \ + { \ COND_LATCH(&(_nameMsg)->curFile->FILEbeastLatch, (_nameMsg)->latchType); \ COND_LATCH(&(_nameMsg)->curDataStream->NAMEDbeastLatch, (_nameMsg)->latchType); \ } \ - if ((_nameMsg)->hlFile != NULL) \ + if ((_nameMsg)->hlFile != NULL) \ COND_LATCH(&(_nameMsg)->hlFile->HARDLbeastLatch, (_nameMsg)->latchType); \ } #define COMN_UPLATCH_NAMEMSG_BEASTS(_nameMsg) \ { \ zASSERT((_nameMsg)->latchType == SLATCHED); \ - (_nameMsg)->latchType = XLATCHED; \ - if ((_nameMsg)->hlFile != NULL) \ + (_nameMsg)->latchType = XLATCHED; \ + if ((_nameMsg)->hlFile != NULL) \ UNS_LATCH(&(_nameMsg)->hlFile->HARDLbeastLatch); \ - if ((NamedBeast_s *)(_nameMsg)->curFile == (_nameMsg)->curDataStream) \ + if ((NamedBeast_s *)(_nameMsg)->curFile == (_nameMsg)->curDataStream) \ { \ UP_LATCH(&(_nameMsg)->curFile->FILEbeastLatch); \ - } \ - else \ - { \ + } \ + else \ + { \ UNS_LATCH(&(_nameMsg)->curFile->FILEbeastLatch); \ UNS_LATCH(&(_nameMsg)->curDataStream->NAMEDbeastLatch); \ X_LATCH(&(_nameMsg)->curFile->FILEbeastLatch); \ X_LATCH(&(_nameMsg)->curDataStream->NAMEDbeastLatch); \ - } \ - if ((_nameMsg)->hlFile != NULL) \ + } \ + if ((_nameMsg)->hlFile != NULL) \ X_LATCH(&(_nameMsg)->hlFile->HARDLbeastLatch); \ } #define COMN_DOWNLATCH_NAMEMSG_BEASTS(_nameMsg) \ { \ zASSERT((_nameMsg)->latchType == XLATCHED); \ - (_nameMsg)->latchType = SLATCHED; \ - if ((_nameMsg)->hlFile != NULL) \ + (_nameMsg)->latchType = SLATCHED; \ + if ((_nameMsg)->hlFile != NULL) \ DOWN_LATCH(&(_nameMsg)->hlFile->HARDLbeastLatch); \ - if ((NamedBeast_s *)(_nameMsg)->curFile == (_nameMsg)->curDataStream) \ + if ((NamedBeast_s *)(_nameMsg)->curFile == (_nameMsg)->curDataStream) \ { \ DOWN_LATCH(&(_nameMsg)->curFile->FILEbeastLatch); \ - } \ - else \ - { \ + } \ + else \ + { \ DOWN_LATCH(&(_nameMsg)->curDataStream->NAMEDbeastLatch); \ DOWN_LATCH(&(_nameMsg)->curFile->FILEbeastLatch); \ - } \ + } \ } -#define COMN_UNLATCH_NAMEMSG_BEASTS_KEEP_LATCHTYPE(_nameMsg) \ -{ \ - if ((NamedBeast_s *) (_nameMsg)->hlFile != NULL) \ +#define COMN_UNLATCH_NAMEMSG_BEASTS_KEEP_LATCHTYPE(_nameMsg) \ +{ \ + if ((NamedBeast_s *) (_nameMsg)->hlFile != NULL) \ COND_UNLATCH(&(_nameMsg)->hlFile->HARDLbeastLatch, (_nameMsg)->latchType); \ if ((NamedBeast_s *)(_nameMsg)->curFile == (_nameMsg)->curDataStream) \ - { \ + { \ if ((NamedBeast_s *)(_nameMsg)->curFile != NULL) \ COND_UNLATCH(&(_nameMsg)->curFile->FILEbeastLatch, (_nameMsg)->latchType); \ - } \ - else \ - { \ + } \ + else \ + { \ if ((NamedBeast_s *)(_nameMsg)->curFile != NULL) \ COND_UNLATCH(&(_nameMsg)->curFile->FILEbeastLatch, (_nameMsg)->latchType); \ if ((NamedBeast_s *)(_nameMsg)->curDataStream != NULL) \ COND_UNLATCH(&(_nameMsg)->curDataStream->NAMEDbeastLatch, (_nameMsg)->latchType); \ - } \ + } \ } -#define COMN_UNLATCH_NAMEMSG_BEASTS(_nameMsg,_latchType) \ -{ \ +#define COMN_UNLATCH_NAMEMSG_BEASTS(_nameMsg,_latchType) \ +{ \ COMN_UNLATCH_NAMEMSG_BEASTS_KEEP_LATCHTYPE(_nameMsg); \ *(_latchType) = (_nameMsg)->latchType; \ - (_nameMsg)->latchType = NOTLATCHED; \ + (_nameMsg)->latchType = NOTLATCHED; \ } #define COMN_LATCH_AND_USE_NAMEMSG_BEASTS(_nameMsg,_latchType) \ -{ \ +{ \ COMN_USE_BEAST(&(_nameMsg)->curFile->FILEroot); \ COMN_USE_BEAST(&(_nameMsg)->curDataStream->NAMEDroot); \ if ((_nameMsg)->hlFile != NULL) \ COMN_USE_BEAST(&(_nameMsg)->hlFile->HARDLroot); \ (_nameMsg)->latchType = (_latchType); \ if ((NamedBeast_s *)(_nameMsg)->curFile == (_nameMsg)->curDataStream) \ - { \ + { \ COND_LATCH(&(_nameMsg)->curFile->FILEbeastLatch, (_nameMsg)->latchType);\ - } \ - else \ - { \ + } \ + else \ + { \ COND_LATCH(&(_nameMsg)->curFile->FILEbeastLatch, (_nameMsg)->latchType); \ COND_LATCH(&(_nameMsg)->curDataStream->NAMEDbeastLatch, (_nameMsg)->latchType); \ - } \ + } \ if ((_nameMsg)->hlFile != NULL) \ COND_LATCH(&(_nameMsg)->hlFile->HARDLbeastLatch, (_nameMsg)->latchType); \ } -#define COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS_KEEP_LATCHTYPE(_nameMsg) \ -{ \ +#define COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS_KEEP_LATCHTYPE(_nameMsg) \ +{ \ if ((NamedBeast_s *)(_nameMsg)->curFile == (_nameMsg)->curDataStream) \ - { \ + { \ if ((NamedBeast_s *)(_nameMsg)->curFile != NULL) \ COMN_UnlatchAndRelease(&(_nameMsg)->curFile, (_nameMsg)->latchType); \ COMN_Release(&(_nameMsg)->curDataStream); \ - } \ - else \ - { \ + } \ + else \ + { \ if ((NamedBeast_s *)(_nameMsg)->curFile != NULL) \ COMN_UnlatchAndRelease(&(_nameMsg)->curFile, (_nameMsg)->latchType); \ if ((NamedBeast_s *)(_nameMsg)->curDataStream != NULL) \ COMN_UnlatchAndRelease(&(_nameMsg)->curDataStream, (_nameMsg)->latchType); \ - } \ + } \ if ((NamedBeast_s *)(_nameMsg)->hlFile != NULL) \ COMN_UnlatchAndRelease(&(_nameMsg)->hlFile, (_nameMsg)->latchType); \ } -#define COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS(_nameMsg,_latchType) \ -{ \ +#define COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS(_nameMsg,_latchType) \ +{ \ COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS_KEEP_LATCHTYPE(_nameMsg); \ *(_latchType) = (_nameMsg)->latchType; \ - (_nameMsg)->latchType = NOTLATCHED; \ + (_nameMsg)->latchType = NOTLATCHED; \ } /*--------------------------------------------------------------------------- @@ -419,7 +419,7 @@ struct NamingMsg_s (_nameMsg)->nameType = (_nType), \ (_nameMsg)->match = (_pMatch)) -/* For zHPT_FILEHANDLEID - This identifies a file object based on a +/* For zHPT_FILEHANDLEID - This identifies a file object based on a * fileHandleID. */ #define COMN_SETUP_NAMING_MSG_FILEHANDLEID(_nameMsg,_fhID,_latchType,_nsid, \ _nType) \ @@ -532,7 +532,7 @@ struct NamingMsg_s (_nameMsg)->handlePathType = zHPT_VOLUME_ZID_PATH, \ (_nameMsg)->workBuffer = (_workBuf), \ NSPACE_SETUP_UNICODE_SCAN_MSG(&(_nameMsg)->scanMsg,0,NULL, \ - (_workBuf)), \ + (_workBuf)), \ (_nameMsg)->scanMsg.retUnicodeComp = (_workBuf), \ (_nameMsg)->scanMsg.retScanFlags = NSRETSFL_componentIsUnicode, \ (_nameMsg)->retParseFlags = (NAMRETPFL_haveAParsedComponent | \ @@ -584,7 +584,7 @@ struct NamingMsg_s #define COMN_SET_NAMING_MSG_ASCII_CONVERT_OVERRIDES(_nameMsg,_convType,_bMap) \ ((_nameMsg)->scanMsg.uniConversionType = (_convType), \ (_nameMsg)->scanMsg.asciiValidCharBitMap = (_bMap)) - + /* Use this to disable uppercasing of ascii strings during the validation * Only use this when the string is already guaranteed to be upper case */ #define COMN_SET_NAMING_MSG_DONT_UPPERCASE_ASCII(_nameMsg) \ @@ -645,16 +645,16 @@ struct NamingMsg_s * These are the parseMode and parseFlag defines for naming *------------------------------------------------------------------------- * NamingMsg.parseMode - These modes control how the path string in - * "nameMsg->path" is processed. As the path string is parsed the - * separate name components are validated and copied into the - * "nameMsg->workName" buffer. The purpose of the name parsing routines + * "nameMsg->path" is processed. As the path string is parsed the + * separate name components are validated and copied into the + * "nameMsg->workName" buffer. The purpose of the name parsing routines * is to get the address of the beast structure that is associated with * the given name. This structure is returned in "nameMsg->curBeast". * * Definition of terms: * leaf name - The last name component on a filename string *-------------------------------------------------------------------------*/ -#define NAMPMODE_Undefined 0 +#define NAMPMODE_Undefined 0 /* undefined mode */ #define NAMPMODE_DoNotResolveLeafName 1 @@ -667,18 +667,18 @@ struct NamingMsg_s * in "nameMsg->curBeast". */ #define NAMPMODE_FullyResolveAny 2 - /* Fully resolve the path string + /* Fully resolve the path string * to the final component. The final beast * may be either a container or a * non-container */ #define NAMPMODE_FullyResolveNonDirectory 3 - /* Fully resolve the path string + /* Fully resolve the path string * to the final component. The final beast * must be a non-directory container. */ #define NAMPMODE_FullyResolveDirectory 4 - /* Fully resolve the path string + /* Fully resolve the path string * to the final component. The final beast * must be a directory container. */ @@ -696,14 +696,14 @@ struct NamingMsg_s * do any rights checking. This flag can * only be set by internal APIs -- never * by an external NCP */ -#define NAMPFL_allowWildcardChars 0x0004 +#define NAMPFL_allowWildcardChars 0x0004 /* If SET, allow wildcard chars in the * leaf name during name validation*/ #define NAMPFL_mustBeFullyQualified 0x0008 /* If SET, the nameMsg must contain a * fully qualified path. */ #define NAMPFL_nameMsgValidated 0x0010 - /* If SET, the NMSG_ValidateNameMsg + /* If SET, the NMSG_ValidateNameMsg * function has already been called on * this nameMsg and it does not need to * be called again. */ @@ -720,7 +720,7 @@ struct NamingMsg_s instead of the object to which the link refers. */ #define NAMPFL_dontLockVolumeActive 0x0080 - /* If SET, the curvol pointer in the + /* If SET, the curvol pointer in the * nameMsg will not be required to point * to an ACTIVE volume, and it will not * have its keepActiveUseCount incremented */ @@ -745,7 +745,7 @@ struct NamingMsg_s * on the inode and no need for the fh to * point to this inode. VFS layer knows the * file is open and will keep a use count on - * the inode. The reason we need this is + * the inode. The reason we need this is * because the file lease code assumes a * direct corelation between the i_count * value and number of times the file is open. @@ -761,10 +761,10 @@ struct NamingMsg_s #define NAMRETPFL_lastComponent 0x02 /* If SET, we have processed the last * component in a path string */ -#define NAMRETPFL_hasDeletedNameType 0x04 - /* if SET, the deleted name type was +#define NAMRETPFL_hasDeletedNameType 0x04 + /* if SET, the deleted name type was * encountered in the path parsing, meaning - * that the file is in the deleted + * that the file is in the deleted * salvage system and cannot be modified */ #define NAMRETPFL_changeNameSpace 0x08 /* If SET, the last component parsed included @@ -777,7 +777,7 @@ struct NamingMsg_s #define NAMRETPFL_foundDOSNameWithLong 0x40 /* (This bit is not set by the namespace * parsing code.) It is set by - * NAME_FindNameInDirSpecialRules if a + * NAME_FindNameInDirSpecialRules if a * lookup finds a name in the DOS namespace * when LONG was specified. */ #define NAMRETPFL_parentIsImmCompress 0x80 diff --git a/include/nwnss/internal/nCache.h b/include/nwnss/internal/nCache.h index 186ec77..c9db385 100644 --- a/include/nwnss/internal/nCache.h +++ b/include/nwnss/internal/nCache.h @@ -44,7 +44,7 @@ #define _NCACHE_H_ #ifndef _XCACHE_H_ -# include +# include #endif #ifdef __cplusplus diff --git a/include/nwnss/internal/nssFSHooks.h b/include/nwnss/internal/nssFSHooks.h index a2a69a4..01ec660 100644 --- a/include/nwnss/internal/nssFSHooks.h +++ b/include/nwnss/internal/nssFSHooks.h @@ -44,8 +44,8 @@ #ifdef __cplusplus extern "C" { #endif -#include -#include +#include +#include /* * Hook Number @@ -150,7 +150,7 @@ extern LONG NW_FSHookVersion; #define FSHOOKS_OR_EVENTS(_hookindex, _eventindex) \ (*(FSHooksList[_hookindex].HookLinkNamePtr) || \ - (NEBEventInfo[_eventindex].consumers)) + (NEBEventInfo[_eventindex].consumers)) #define CHECK_FSHOOKS_CLOSE_ENTER(_index,_parms,_genmsg,_key) \ { \ @@ -292,7 +292,7 @@ extern LONG NW_FSHookVersion; if (FSHooksCall[_index]) \ { \ _st = FSHooksCall[_index](_genmsg, HOOKENTER, _parms, \ - _namemsg, _rights, _minfo); \ + _namemsg, _rights, _minfo); \ if (_st != zOK) \ goto _golab; \ } \ @@ -356,7 +356,7 @@ extern LONG NW_FSHookVersion; NINT _latchtype; \ COMN_UNLATCH_NAMEMSG_BEASTS(_namemsg, &_latchtype); \ _st = FSHooksCall[_index](_genmsg, HOOKENTER, _parms, \ - _namemsg, _searchmsg); \ + _namemsg, _searchmsg); \ COMN_LATCH_NAMEMSG_BEASTS(_namemsg, _latchtype); \ if (_st != zOK) \ goto _golab; \ @@ -377,7 +377,7 @@ extern LONG NW_FSHookVersion; NINT _latchtype; \ COMN_UNLATCH_NAMEMSG_BEASTS(_namemsg, &_latchtype); \ FSHooksCall[_index](_genmsg, HOOKEXIT, _parms, \ - _namemsg, _searchmsg); \ + _namemsg, _searchmsg); \ COMN_LATCH_NAMEMSG_BEASTS(_namemsg, _latchtype); \ } \ } \ @@ -439,7 +439,7 @@ extern LONG NW_FSHookVersion; #else #define FSHOOKS_OR_EVENTS(_hookindex, _eventindex) \ - (NEBEventInfo[_eventindex].consumers) + (NEBEventInfo[_eventindex].consumers) #define CHECK_FSHOOKS_CLOSE_ENTER(_index, _parms, _genmsg, _key) \ UNUSED_PARAM(*_parms) #define CHECK_FSHOOKS_CLOSE_EXIT(_index, _parms, _genmsg, _key) \ diff --git a/include/nwnss/include/nssOSAPIs.h b/include/nwnss/internal/nssOSAPIs.h similarity index 98% rename from include/nwnss/include/nssOSAPIs.h rename to include/nwnss/internal/nssOSAPIs.h index d22212b..26c770f 100644 --- a/include/nwnss/include/nssOSAPIs.h +++ b/include/nwnss/internal/nssOSAPIs.h @@ -43,45 +43,35 @@ #ifndef _NSSOSAPIS_H_ #define _NSSOSAPIS_H_ -#ifdef NSS_USERSPACE -#ifndef KERNEL_VERSION -#define KERNEL_VERSION(_major, _minor, _patch) \ - (((_major) << 16) + ((_minor) << 8) + (_patch)) -#endif -#ifndef LINUX_VERSION_CODE -#define LINUX_VERSION_CODE 0 -#endif -#endif - #ifndef _ZOMNI_H_ -# include +# include #endif #ifndef _PSSDEBUG_H_ -# include +# include #endif #ifndef _INST_H_ -# include +# include #endif #ifndef _PSSMPK_H_ -# include +# include #endif #ifndef _INLINES_H_ -# include +# include #endif #ifndef _QUE_H_ -#include +#include #endif #ifndef _LINUX_SCHED_H #include #endif -#if !(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) && !defined(NSS_USERSPACE) +#if !(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) #ifndef _ADMINFSPUB_H_ # include #endif @@ -92,18 +82,18 @@ extern "C" { #endif /************************************************************************ - * + * * This header file contains all the macros used by NSS for indirectly * referring to OS APIs and other APIs which NSS imports today. * These macros should be used by NSS henceforth. These macros are MT-safe * and should function perfectly in a MT environment. They should also have * no overhead in UP environment. * - * Abhijit 4/21/99 MPK changes. + * Abhijit 4/21/99 MPK changes. * ***********************************************************************/ // review -- 1. Underscore everywhere -- done - // 5/14/99 2. FixFixFix6 Name the arguments + // 5/14/99 2. FixFixFix6 Name the arguments // 3. FixFixFix6 We need to review the Unicode API interfaces #define ZOS_ActivateScreen(_p1) \ @@ -1167,7 +1157,7 @@ do { \ #define ZOS_CPSemaphore(_p1); \ { \ - MPKNSS_UNLOCK(); \ + MPKNSS_UNLOCK(); \ CPSemaphore(_p1); \ MPKNSS_LOCK(); \ } @@ -1991,11 +1981,6 @@ do { \ - -#ifdef NSS_USERSPACE -#include -#endif - extern LONG ZOS_IsNLMLoaded(BYTE *nlmName); #ifdef __cplusplus @@ -2004,3 +1989,4 @@ extern LONG ZOS_IsNLMLoaded(BYTE *nlmName); #endif #endif /* _NSSOSPAIS_H_ */ + diff --git a/include/nwnss/internal/nssSourceCompat.h b/include/nwnss/internal/nssSourceCompat.h deleted file mode 100644 index a4a152e..0000000 --- a/include/nwnss/internal/nssSourceCompat.h +++ /dev/null @@ -1,314 +0,0 @@ -#ifndef NSS_SOURCE_COMPAT_H -#define NSS_SOURCE_COMPAT_H - -#include - -/* - * Private build-environment compatibility for imported NSS sources. - * The original Linux-kernel NSS build got these NSS libc-like aliases from - * its kernel/header environment. Keep this private to the userspace NSS runtime so public - * consumers keep the normal userspace libc headers. - */ -#include -#include - - -#ifndef READ -#define READ 0 -#endif -#ifndef WRITE -#define WRITE 1 -#endif -#ifndef GFP_USER -#define GFP_USER 0 -#endif - -#ifndef likely -#define likely(_expr) __builtin_expect(!!(_expr), 1) -#endif -#ifndef unlikely -#define unlikely(_expr) __builtin_expect(!!(_expr), 0) -#endif - -#ifdef NSS_USERSPACE -extern void abort(void); -static inline void nssUserspaceAbend(const char *message) -{ - (void)message; - abort(); -} -#ifndef Abend -#define Abend(_message) nssUserspaceAbend((_message)) -#endif -#endif - -/* - * Do not include from this global -include header. - * xStdlib.h intentionally keeps Novell's RAND_MAX value, which conflicts - * with host libc in userspace port files. Individual imported - * sources include the original NSS header when they need its ABI; private - * libc helpers used only by compat macros are declared here instead. - */ -extern void free(void *); -extern void *zalloc(size_t size); -extern void *zrealloc(void *ptr, size_t size); -extern void *mallocPage(size_t numPages); -extern void *mallocPageWithFlags(size_t numPages, unsigned int flags); -extern void *zallocPage(size_t numPages); -extern void freePage(void *page, size_t numPages); -#include -#include -#include - -LONG GetCurrentTime(void); -LONG GetHighResolutionTimer(void); - -#ifdef wPause -#undef wPause -#define wPause(_file, _mode) LB_wPause((WFile_s *)(void *)(_file), (_mode)) -#endif - -#ifndef UINT32 -typedef LONG UINT32; -#endif - -#ifndef aprintf -#define aprintf LB_aprintf -#endif - -#ifndef KERN_INFO -#define KERN_INFO "" -#endif -#ifndef KERN_WARNING -#define KERN_WARNING "" -#endif -#ifndef KERN_NOTICE -#define KERN_NOTICE "" -#endif -#ifndef KERN_ERR -#define KERN_ERR "" -#endif -#ifndef KERN_ALERT -#define KERN_ALERT "" -#endif -#ifndef printk -#define printk(...) fprintf(stderr, __VA_ARGS__) -#endif - -#ifndef kfree -#define kfree free -#endif - - -#ifndef ZOS_zRead -#define ZOS_zRead(_status, _key, _flags, _offset, _len, _data, _retLen) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (_status) = zRead((_key), (_flags), (_offset), (_len), (_data), (_retLen)); \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif - -#ifndef ZOS_zWrite -#define ZOS_zWrite(_status, _key, _flags, _offset, _len, _data, _retLen) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (_status) = zWrite((_key), (_flags), (_offset), (_len), (_data), (_retLen)); \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif - -#include - -/* - * Original ZOS macros release the global NSS MPK lock around calls that may - * enter the OS, event layer, module-symbol loader or file backend. The - * userspace compat header is force-included into imported sources that do not - * see the full kernel nssOSAPIs.h macro set, so keep the same lock boundary - * locally without assuming every caller currently owns the lock. - */ -#define NSS_MPK_BOUNDARY_BEGIN(_owned) \ - do { \ - (_owned) = MPKNSS_I_OWN_SPINLOCK(); \ - if (_owned) \ - { \ - MPKNSS_UNLOCK(); \ - } \ - } while (0) -#define NSS_MPK_BOUNDARY_END(_owned) \ - do { \ - if (_owned) \ - { \ - MPKNSS_LOCK(); \ - } \ - } while (0) - - -#ifndef ZOS_StartThread -#define ZOS_StartThread(_thread, _name, _func, _stack, _prio, _arg) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (void)(_name); (void)(_func); (void)(_stack); (void)(_prio); (void)(_arg); \ - (_thread) = 0; \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif - -#ifndef ZOS_StartThreadWithModuleHandle -#define ZOS_StartThreadWithModuleHandle(_thread, _name, _func, _stack, _prio, _arg, _module) \ - do { (void)(_module); ZOS_StartThread((_thread), (_name), (_func), (_stack), (_prio), (_arg)); } while (0) -#endif - -#ifndef ZOS_RegisterConsumer -#define ZOS_RegisterConsumer(_reg) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (void)RegisterConsumer((_reg)); \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif - -#ifndef ZOS_UnRegisterConsumer -#define ZOS_UnRegisterConsumer(_consumer, _event) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (void)UnRegisterConsumer((_consumer), (_event)); \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif - -#ifndef ZOS_ImportPublicSymbol -#define ZOS_ImportPublicSymbol(_target, _module, _name) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (void)(_module); (void)(_name); (_target) = NULL; \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif - -#ifndef ZOS_UnImportPublicSymbol -#define ZOS_UnImportPublicSymbol(_module, _name) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (void)(_module); (void)(_name); \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif - -#ifndef EXPORT_SYMBOL -#define EXPORT_SYMBOL(_sym) -#endif - -#ifndef THIS_MODULE -#define THIS_MODULE NULL -#endif -#ifndef nss_register_module -#define nss_register_module(_name, _sym, _module) ((void)(_name), (void)(_sym), (void)(_module)) -#endif -#ifndef nss_unregister_module -#define nss_unregister_module(_name) ((void)(_name)) -#endif - -#ifndef ZOS_zClose -#define ZOS_zClose(_status, _key) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (_status) = zClose((_key)); \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif -#ifndef ZOS_zOpen -#define ZOS_zOpen(_status, _rootKey, _task, _flags, _path, _rights, _outKey) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (_status) = zOpen((_rootKey), (_task), (_flags), (_path), (_rights), (_outKey)); \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif -#ifndef ZOS_zDelete -#define ZOS_zDelete(_status, _rootKey, _task, _flags, _path, _rights, _cb) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (void)(_cb); \ - (_status) = zDelete((_rootKey), (_task), (_flags), (_path), (_rights), NULL); \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif -#ifndef ZOS_zCreate -#define ZOS_zCreate(_status, _rootKey, _task, _flags, _nameSpace, _path, _fileType, _attr, _createFlags, _rights, _outKey) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (_status) = zCreate((_rootKey), (_task), (_flags), (_nameSpace), (_path), (_fileType), (_attr), (_createFlags), (_rights), (_outKey)); \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif -#ifndef ZOS_zDIORead -#define ZOS_zDIORead(_status, _key, _offset, _count, _flags, _cb, _buf) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (_status) = zDIORead((_key), (_offset), (_count), (_flags), (_cb), (_buf)); \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif -#ifndef ZOS_zDIOWrite -#define ZOS_zDIOWrite(_status, _key, _offset, _count, _flags, _cb, _buf) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (_status) = zDIOWrite((_key), (_offset), (_count), (_flags), (_cb), (_buf)); \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif -#ifndef ZOS_zRootKey -#define ZOS_zRootKey(_status, _flags, _outKey) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (_status) = zRootKey((_flags), (_outKey)); \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif -#ifndef ZOS_zSetEOF -#define ZOS_zSetEOF(_status, _key, _offset, _size, _flags) \ - do { \ - BOOL _nss_mpk_owned; \ - NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \ - (_status) = zSetEOF((_key), (_offset), (_size), (_flags)); \ - NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \ - } while (0) -#endif - -#ifndef errPrintf -#define errPrintf LB_errPrintf -#endif - -#ifdef NSS_USERSPACE -typedef LONG SAL_ModHandle; -#ifndef DS_CREATE_ID -#define DS_CREATE_ID 1 -#endif -#ifndef DSI_ENTRY_ID -#define DSI_ENTRY_ID 1 -#endif -extern int (*DDCCreateContextPtr)(SAL_ModHandle taskID, int *context); -extern int (*DDCNameToIDPtr)(int context, UINT32 flags, const void *dn); -extern int (*DDCGetEntryInfoPtr)(int context, UINT32 infoflags, size_t bufsize, void *buffer); -extern void (*DDCFreeContextPtr)(int context); -extern int (*DDCLogoutPtr)(int context); -#endif - -void freePage(void *page, size_t numPages); - -#endif /* NSS_SOURCE_COMPAT_H */ diff --git a/include/nwnss/internal/nssUnicodeUserspace.h b/include/nwnss/internal/nssUnicodeUserspace.h deleted file mode 100644 index 5123bb0..0000000 --- a/include/nwnss/internal/nssUnicodeUserspace.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef NSS_UNICODE_USERSPACE_H -#define NSS_UNICODE_USERSPACE_H - -#include -#include -#include - -#include - -#ifndef PAGE_SIZE -#define PAGE_SIZE 4096 -#endif - -#ifndef MPK_SLEEP_OK -#define MPK_SLEEP_OK 0 -#endif - -struct file { - FILE *stream; - long f_pos; -}; - -void mpkEnter(void); -void mpkExit(void); -void *mpkPageAlloc(unsigned int bytes, int flags); -void mpkPageFree(void *ptr); -void *kMutexAlloc(const char *name); -void kMutexFree(void *lock); -void kMutexLock(void *lock); -void kMutexUnlock(void *lock); -struct file *kFileOpen(const char *path, int flags, int mode); -int kFileRead(struct file *filep, void *buf, unsigned int count); -void klseek(struct file *filep, unsigned int pos, int whence); -int filp_close(struct file *filep, void *unused); -LONG OSGetCodePage(void); - -#ifndef IS_ERR -#define IS_ERR(ptr) ((ptr) == NULL) -#endif - -#endif /* NSS_UNICODE_USERSPACE_H */ diff --git a/include/nwnss/internal/nssUserspaceProvider.h b/include/nwnss/internal/nssUserspaceProvider.h deleted file mode 100644 index 4c7048e..0000000 --- a/include/nwnss/internal/nssUserspaceProvider.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef NSS_INTERNAL_NSS_USERSPACE_PROVIDER_H -#define NSS_INTERNAL_NSS_USERSPACE_PROVIDER_H - -#if defined(NSS_USERSPACE) - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define NSS_USERSPACE_PROVIDER_PATH_MAX 4096 - -typedef enum NssUserspaceProviderKind_e { - NSS_USERSPACE_PROVIDER_UNSET = 0, - NSS_USERSPACE_PROVIDER_NSS_VOLUME, - NSS_USERSPACE_PROVIDER_OTHERFS_XATTR, - NSS_USERSPACE_PROVIDER_OTHERFS_SIDECAR, - NSS_USERSPACE_PROVIDER_UNSUPPORTED -} NssUserspaceProviderKind_e; - -typedef enum NssUserspaceProviderFeature_e { - NSS_USERSPACE_PROVIDER_FEATURE_XATTR = 1u << 0, - NSS_USERSPACE_PROVIDER_FEATURE_TRUSTEES = 1u << 1, - NSS_USERSPACE_PROVIDER_FEATURE_QUOTA = 1u << 2, - NSS_USERSPACE_PROVIDER_FEATURE_SALVAGE = 1u << 3, - NSS_USERSPACE_PROVIDER_FEATURE_NAMESPACE = 1u << 4, - NSS_USERSPACE_PROVIDER_FEATURE_IO = 1u << 5 -} NssUserspaceProviderFeature_e; - -typedef struct NssUserspaceProvider_s { - NssUserspaceProviderKind_e kind; - unsigned int features; - long hostFsType; - char path[NSS_USERSPACE_PROVIDER_PATH_MAX]; -} NssUserspaceProvider_s; - -void NssUserspaceProviderInit(NssUserspaceProvider_s *provider); -void NssUserspaceProviderSetKind(NssUserspaceProvider_s *provider, - NssUserspaceProviderKind_e kind); -NssUserspaceProviderKind_e -NssUserspaceProviderGetKind(const NssUserspaceProvider_s *provider); -void NssUserspaceProviderEnableFeature(NssUserspaceProvider_s *provider, - NssUserspaceProviderFeature_e feature); -int NssUserspaceProviderSupports(const NssUserspaceProvider_s *provider, - NssUserspaceProviderFeature_e feature); -int NssUserspaceProviderInitOtherfsPath(NssUserspaceProvider_s *provider, - const char *path); -const char *NssUserspaceProviderPath(const NssUserspaceProvider_s *provider); -long NssUserspaceProviderHostFsType(const NssUserspaceProvider_s *provider); -int NssUserspaceProviderHostXattrName(const char *nssName, - char *buffer, - size_t bufferSize); - -#ifdef __cplusplus -} -#endif - -#endif /* NSS_USERSPACE */ - -#endif /* NSS_INTERNAL_NSS_USERSPACE_PROVIDER_H */ diff --git a/include/nwnss/internal/nssUserspaceQuota.h b/include/nwnss/internal/nssUserspaceQuota.h deleted file mode 100644 index 2b7ce3d..0000000 --- a/include/nwnss/internal/nssUserspaceQuota.h +++ /dev/null @@ -1,101 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef _NSS_USERSPACE_QUOTA_H_ -#define _NSS_USERSPACE_QUOTA_H_ 1 - -#include -#include - -#define NSS_QUOTA_LINUX_CAP_USER 0x00000001U -#define NSS_QUOTA_LINUX_CAP_GROUP 0x00000002U -#define NSS_QUOTA_LINUX_CAP_PROJECT 0x00000004U -#define NSS_QUOTA_NWQUOTA_CAPABLE 0x00010000U - -#include -#include - -#define NSS_QUOTA_OK 0 -#define NSS_QUOTA_ERR_INVAL (-1) -#define NSS_QUOTA_ERR_RANGE (-2) -#define NSS_QUOTA_ERR_VERSION (-3) -#define NSS_QUOTA_ERR_BYTEORDER (-4) - -#define NSS_QUOTA_UNLIMITED_4K 0x7fffffffU -#define NSS_METADATA_FIXED_SIZE offsetof(zNW_metadata_s, nwm_trustee) -#define NSS_USERQUOTA_FIXED_SIZE offsetof(zNW_user_quota_s, nwuq_user) -#define NSS_USERQUOTA_XATTR zNW_USERQUOTA ".0" - -uint32_t NssQuotaBlocksForBytes(uint64_t bytes); - -int NssDirQuotaLimit4KToMetadata(uint32_t limit4k, SQUAD *quotaLimit); -int NssDirQuotaMetadataToLimit4K(SQUAD quotaLimit, uint32_t *limit4k); -int NssDirQuotaMetadataIsLimited(SQUAD quotaLimit); -uint32_t NssDirQuotaAvailable4K(uint32_t limit4k, uint32_t used4k); -int NssDirQuotaWouldExceed(uint32_t limit4k, uint32_t used4k, - uint32_t add4k); - -void NssQuotaInit(zNW_quota_s *quota); -int NssQuotaValidate(const zNW_quota_s *quota, size_t size); -int NssQuotaSetSnapshot(zNW_quota_s *quota, SQUAD userUsed, - SQUAD userLimit, SQUAD dirLeft, SQUAD dirQuota); - -void NssMetadataInit(zNW_metadata_s *metadata); -int NssMetadataValidate(const zNW_metadata_s *metadata, size_t size); -size_t NssMetadataSizeForTrustees(LONG trusteeNum); -LONG NssMetadataMaxTrusteesForSize(size_t size); -int NssMetadataSetQuotaLimit(zNW_metadata_s *metadata, SQUAD quotaLimit); -int NssMetadataGetQuotaLimit(const zNW_metadata_s *metadata, - SQUAD *quotaLimit); - -void NssUserQuotaInit(zNW_user_quota_s *userQuota); -int NssUserQuotaValidate(const zNW_user_quota_s *userQuota, size_t size); -size_t NssUserQuotaSizeForUsers(LONG userNum); -LONG NssUserQuotaMaxUsersForSize(size_t size); -int NssUserQuotaFindUserGuid(const zNW_user_quota_s *userQuota, - const GUID_t *userGuid); -int NssUserQuotaSetRestrictionForGuid(zNW_user_quota_s *userQuota, - const GUID_t *userGuid, - uint32_t quota4k); -int NssUserQuotaGetRestrictionForGuid(const zNW_user_quota_s *userQuota, - const GUID_t *userGuid, - uint32_t *quota4k); - -typedef enum NssQuotaProviderKind_e { - NSS_QUOTA_PROVIDER_UNSET = 0, - NSS_QUOTA_PROVIDER_OTHERFS_LINUX_QUOTA, - NSS_QUOTA_PROVIDER_OTHERFS_LINUX_USER_QUOTA, - NSS_QUOTA_PROVIDER_OTHERFS_LINUX_PROJECT_QUOTA, - NSS_QUOTA_PROVIDER_OTHERFS_NWQUOTA, - NSS_QUOTA_PROVIDER_NSS_VOLUME -} NssQuotaProviderKind_e; - -typedef enum NssQuotaCheckResult_e { - NSS_QUOTA_CHECK_OK = 0, - NSS_QUOTA_CHECK_UNSUPPORTED, - NSS_QUOTA_CHECK_USER_EXCEEDED, - NSS_QUOTA_CHECK_DIR_EXCEEDED, - NSS_QUOTA_CHECK_VOLUME_EXCEEDED, - NSS_QUOTA_CHECK_INVALID -} NssQuotaCheckResult_e; - -typedef struct NssQuotaWriteView_s { - NssQuotaProviderKind_e provider; - uint32_t add4k; - uint32_t userLimit4k; - uint32_t userUsed4k; - uint32_t dirLimit4k; - uint32_t dirUsed4k; - uint32_t volumeLimit4k; - uint32_t volumeUsed4k; -} NssQuotaWriteView_s; - -const char *NssQuotaProviderName(NssQuotaProviderKind_e provider); -int NssQuotaProviderIsUserspace(NssQuotaProviderKind_e provider); -int NssQuotaProviderIsLinuxQuota(NssQuotaProviderKind_e provider); -int NssQuotaProviderIsNwQuota(NssQuotaProviderKind_e provider); -int NssQuotaProviderIsOtherfsApproximation(NssQuotaProviderKind_e provider); -NssQuotaProviderKind_e NssQuotaProviderForOtherfsCapabilities(uint32_t caps); -int NssQuotaProbeLinuxQuotaCapabilitiesFd(int fd, uint32_t *caps); -NssQuotaCheckResult_e NssQuotaCheckWrite(const NssQuotaWriteView_s *view); -const char *NssQuotaCheckResultName(NssQuotaCheckResult_e result); - -#endif diff --git a/include/nwnss/internal/nssZosCompat.h b/include/nwnss/internal/nssZosCompat.h deleted file mode 100644 index f2d06c3..0000000 --- a/include/nwnss/internal/nssZosCompat.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Private userspace overrides for ZOS_* OS/NEB/virtual-IO macros used by - * imported NSS sources. - * - * This header is intentionally re-includable: nssOSAPIs.h defines the - * original Linux-kernel ZOS_* macro bodies after normal header inclusion. - * libnwnss includes this file again at the end of nssOSAPIs.h so the - * userspace overrides win without editing imported NSS source files. - * - * Keep NSS source files and public Novell headers otherwise original; do not - * grow NSS business logic in this compatibility header. - */ -#ifdef NSS_USERSPACE - -/* - * Scheduler primitives are real userspace functions declared by schedule.h. - * If nssOSAPIs.h has already installed the Linux-kernel macro bodies, remove - * those macros after schedule.h is visible so Wait()/Continue()/ScheduleWork() - * call the userspace functions rather than kSleep/kWakeUp/kScheduleWorkToDo. - */ -#ifdef _SCHEDULE_H_ -#undef ZOS_Sleep -#undef ZOS_WakeUp -#undef ZOS_YieldThread -#undef ZOS_ScheduleWorkToDo -#undef ZOS_ScheduleFastWorkToDo -#undef ZOS_CancelWorkToDo -#endif - -#undef ZOS_ProduceEvent -#define ZOS_ProduceEvent(_status, _event) \ - do { (_status) = ProduceEvent((_event)); } while (0) - -#undef ZOS_RegisterProducer -#define ZOS_RegisterProducer(_status, _reg) \ - do { (_status) = RegisterProducer((_reg)); } while (0) - -#undef ZOS_UnRegisterProducer -#define ZOS_UnRegisterProducer(_producer, _event) \ - do { (void)UnRegisterProducer((_producer), (_event)); } while (0) - -#undef ZOS_RegisterConsumer -#define ZOS_RegisterConsumer(_reg) \ - do { (void)RegisterConsumer((_reg)); } while (0) - -#undef ZOS_UnRegisterConsumer -#define ZOS_UnRegisterConsumer(_consumer, _event) \ - do { (void)UnRegisterConsumer((_consumer), (_event)); } while (0) - -#undef ZOS_ImportPublicSymbol -#define ZOS_ImportPublicSymbol(_target, _module, _name) \ - do { (void)(_module); (void)(_name); (_target) = NULL; } while (0) - -#undef ZOS_UnImportPublicSymbol -#define ZOS_UnImportPublicSymbol(_module, _name) \ - do { (void)(_module); (void)(_name); } while (0) - -#undef ZOS_zClose -#define ZOS_zClose(_status, _key) \ - do { (_status) = zClose((_key)); } while (0) - -#undef ZOS_zOpen -#define ZOS_zOpen(_status, _rootKey, _task, _flags, _path, _rights, _outKey) \ - do { (_status) = zOpen((_rootKey), (_task), (_flags), (_path), (_rights), (_outKey)); } while (0) - -#undef ZOS_zDelete -#define ZOS_zDelete(_status, _rootKey, _task, _flags, _path, _rights, _cb) \ - do { (void)(_cb); (_status) = zDelete((_rootKey), (_task), (_flags), (_path), (_rights), NULL); } while (0) - -#undef ZOS_zCreate -#define ZOS_zCreate(_status, _rootKey, _task, _flags, _nameSpace, _path, _fileType, _attr, _createFlags, _rights, _outKey) \ - do { (_status) = zCreate((_rootKey), (_task), (_flags), (_nameSpace), (_path), (_fileType), (_attr), (_createFlags), (_rights), (_outKey)); } while (0) - -#undef ZOS_zDIORead -#define ZOS_zDIORead(_status, _key, _offset, _count, _flags, _cb, _buf) \ - do { (_status) = zDIORead((_key), (_offset), (_count), (_flags), (_cb), (_buf)); } while (0) - -#undef ZOS_zDIOWrite -#define ZOS_zDIOWrite(_status, _key, _offset, _count, _flags, _cb, _buf) \ - do { (_status) = zDIOWrite((_key), (_offset), (_count), (_flags), (_cb), (_buf)); } while (0) - -#undef ZOS_zRootKey -#define ZOS_zRootKey(_status, _flags, _outKey) \ - do { (_status) = zRootKey((_flags), (_outKey)); } while (0) - -#undef ZOS_zSetEOF -#define ZOS_zSetEOF(_status, _key, _offset, _size, _flags) \ - do { (_status) = zSetEOF((_key), (_offset), (_size), (_flags)); } while (0) - -#endif /* NSS_USERSPACE */ diff --git a/include/nwnss/support/lnxmbINC/nwInKeys.h b/include/nwnss/internal/nwInKeys.h similarity index 99% rename from include/nwnss/support/lnxmbINC/nwInKeys.h rename to include/nwnss/internal/nwInKeys.h index 5994f31..de4e1a7 100644 --- a/include/nwnss/support/lnxmbINC/nwInKeys.h +++ b/include/nwnss/internal/nwInKeys.h @@ -105,7 +105,7 @@ extern "C" { #define SHFTF8 (FKEYMASK | 0x12) #define SHFTF9 (FKEYMASK | 0x13) #define SHFTF10 (FKEYMASK | 0x14) - + #define CTRLF1 (FKEYMASK | 0x15) #define CTRLF2 (FKEYMASK | 0x16) #define CTRLF3 (FKEYMASK | 0x17) diff --git a/include/nwnss/include/nwInProc.h b/include/nwnss/internal/nwInProc.h similarity index 99% rename from include/nwnss/include/nwInProc.h rename to include/nwnss/internal/nwInProc.h index 54e5fa7..dd8ccb5 100644 --- a/include/nwnss/include/nwInProc.h +++ b/include/nwnss/internal/nwInProc.h @@ -23,7 +23,7 @@ | ASCII Window Library file | |--------------------------------------------------------------------------- - | + | | $Author: vandana $ | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ | @@ -84,7 +84,7 @@ extern "C" { #define BRIGHT 8 #define DIM 0 -struct winmenu +struct winmenu { BYTE *menuName; BYTE **menuSelect; @@ -153,7 +153,7 @@ extern LONG HideWindow(LONG window); extern void InitFieldList(LONG window); -extern LONG LoadHelpFile(LONG FileHandle, LONG (*ReadRoutine)(), +extern LONG LoadHelpFile(LONG FileHandle, LONG (*ReadRoutine)(), LONG HelpDataOffset, LONG HelpDataSize, BYTE *FileName, BYTE NoOfHelpPages, WORD StartHelpKey, WORD ExitHelpKey); diff --git a/include/nwnss/internal/pssConfig.h b/include/nwnss/internal/pssConfig.h index d5b11dc..5132902 100644 --- a/include/nwnss/internal/pssConfig.h +++ b/include/nwnss/internal/pssConfig.h @@ -45,10 +45,10 @@ #define _PSSCONFIG_H_ #ifndef _OMNI_H_ -#include +#include #endif -#include +#include "hmc.h" #ifdef __cplusplus extern "C" { @@ -106,7 +106,7 @@ extern NINT WorkHighWaitingCount; #define MAX_SEC 3600 #define MIN_WORK_LIMIT 5 -#define MAX_WORK_LIMIT 100 +#define MAX_WORK_LIMIT 100 #define MIN_NUM_XACTIONS 4 #define MAX_NUM_XACTIONS 65536 @@ -119,17 +119,17 @@ extern NINT WorkHighWaitingCount; #define MIN_STORAGE_RESET_THRESHOLD 0 #define MAX_STORAGE_RESET_THRESHOLD 1000000 - + #define DEFAULT_BEAST_PERCENT_MEM 45 #define DEFAULT_BEAST_BALANCE_SEC 1 #define MIN_ALLOC_AHEAD_WRITE 0 -#define DEFAULT_ALLOC_AHEAD_WRITE 0 // On linux most applications on - // server and ncp and probably cifs - // do larger writes (not network - // packet size writes). So we get - // better performance without +#define DEFAULT_ALLOC_AHEAD_WRITE 0 // On linux most applications on + // server and ncp and probably cifs + // do larger writes (not network + // packet size writes). So we get + // better performance without // allocahead. #define MAX_ALLOC_AHEAD_WRITE 63 @@ -149,7 +149,7 @@ extern NINT WorkHighWaitingCount; #define DEFAULT_NUM_BONDS 5000 /*(2 * DEFAULT_NUM_BUFFERS)*/ #define DEFAULT_NUM_BUFFERS 512 #define DEFAULT_NUM_ASYNCIOS 2048 -#define DEFAULT_NUM_DELAYED_BEASTS 40 +#define DEFAULT_NUM_DELAYED_BEASTS 40 //#define DEFAULT_CACHE_HASH_SHIFT 10 #define DEFAULT_NOT_IN_USE_BEASTS 100000 //#define DEFAULT_BEAST_HASH_SHIFT 12 @@ -243,7 +243,7 @@ typedef struct Config_s NINT minOSFree; NINT numPagesAllocated; NINT maxNumBuffersToAddPerBalance; - NINT userPages; /* number of pages used for user data */ + NINT userPages; /* number of pages used for user data */ NINT percentUserPages; /* percentage of total pages for user */ NINT hmcCacheType; /* HMC_CT_LINUX, HMC_CT_NONE, or HMC_CT_PRIVATE. Needed on servers with limited low @@ -360,8 +360,8 @@ typedef struct Config_s * background updater is to be * forced to be run */ NINT updaterInterval; /* Number of seconds that we delay - * after finishing a security - * equivalence update and before + * after finishing a security + * equivalence update and before * starting a new one.*/ BOOL intervalChanged; /* TRUE if the security equivalence * background interval was changed */ diff --git a/include/nwnss/internal/rintface.h b/include/nwnss/internal/rintface.h new file mode 100644 index 0000000..3e22dba --- /dev/null +++ b/include/nwnss/internal/rintface.h @@ -0,0 +1,400 @@ +/**************************************************************************** + | + | (C) Copyright 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File System (DFS) module + | + |--------------------------------------------------------------------------- + | + | $Author: Changju Gao + | $Date: 5/19/1999 + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | provide definitins for auto-installation + +-------------------------------------------------------------------------*/ + +#ifndef _RINTFACE_ +#define _RINTFACE_ + +#include +#include + +/* return type definition */ +typedef int RI_RET; + +/* type registration ID */ +typedef long registration_ID_t; + +/* general return values */ +#define RI_OK (0) +#define RI_ERROR (-1) +#define RI_YES (1) +#define RI_NO (0) + +#define RI_ERROR_CODE_BASE (0xff0000) + +/* max length for names and descriptions */ + + +#define RI_MODULE_NAME_MAX_LEN (64) /* FUTURE: use NSS definitions */ +#define RI_MODULE_PATH_MAX_LEN (256) +#define RI_MODULE_DESC_MAX_LEN (256) +#define MAX_REPICATION_MODULE_NUM (16) + +/* Replication Transaction ID */ +typedef long REP_TranxID_t; + +#ifndef _ZOMNI_H_ +typedef struct GUID_t /* holds GUIDs*/ +{ + LONG timeLow; + WORD timeMid; + WORD timeHighAndVersion; + BYTE clockSeqHighAndReserved; + BYTE clockSeqLow; + BYTE node[6]; +} GUID_t; +#endif + +/* module ID, only one of the three + * is required. + * The order of looking up is + * regID, moduleID, and moduleName + */ +typedef struct RI_Module_IDs_s +{ + registration_ID_t regID; + GUID_t moduleID; + char moduleName[RI_MODULE_NAME_MAX_LEN]; +} RI_Module_IDs_s; + +/* module information for ADM + */ +typedef struct RI_ADM_Module_Info_s +{ + RI_Module_IDs_s moduleIDs; + char moduleDescriptions[RI_MODULE_DESC_MAX_LEN]; +} RI_ADM_Module_Info_s; + +/* callback function and data */ +typedef struct RM_callback_s +{ + REP_TranxID_t (*callback_function)(); + /* the pointer to the function */ + BOOL synchrounous_invocattion; + /* sync or async calls + * not use currently (all calls are sync) + * FUTURE: take advantage of this field + */ + char* dataBuffer; + /* anything understandable by both sides */ +} RM_callback_s; + +/* callbacks requried by the RI */ +typedef struct RI_callbacks_s +{ + RM_callback_s accept_delivery_callback; + /* to accept notification */ + RM_callback_s check_RM_state_callback; + /* return the state of a module */ + RM_callback_s replicate_volume_callback; + /* ask RM to replicate a volume */ + RM_callback_s stop_replicate_volume_callback; + /* stop replicating a volume */ + RM_callback_s move_volume_callback; + /* ask RM to move a volume */ + RM_callback_s split_volume_callback; + /* ask RM to split a volume */ + RM_callback_s check_progress_callback; + /* check the progress of an ongoing op */ + RM_callback_s abort_operation_callback; + /* abort an operation */ + RM_callback_s get_replicated_vol_num_callback; + /* num of replicated volumes by a RM */ + RM_callback_s get_replicated_vol_list_callback; + /* return list of volumes */ + RM_callback_s get_RM_statistics_callback; + /* return statistical info */ + RM_callback_s shutdown_RM_callback; + /* shut down a RM, + * the RI won't update the tables + * the RM must deregister + */ +} RI_callbacks_s; + +/* data buffers for various callbacks */ + +/* volume operations */ +typedef struct RI_volume_access_data_s +{ + long signature; + /* kind of ID, could be anything, currently not used */ + LONG opcode; + /* The operation being requested */ + char volumeName[RI_MODULE_NAME_MAX_LEN]; + /* volume Name, + * FUTURE: use NSS definition + */ + + unicode_t desNameString[MAX_DN_CHARS]; + /* could be one of three things: + * NDS name, DNS name, or IP string + */ + char dirPath[RI_MODULE_DESC_MAX_LEN]; + /* directory path name for SPLIT */ +} RI_volume_access_data_s; + +/* Volume operations */ +#define RI_OPCODE_REPLICATE_VOLUME (1) +#define RI_OPCODE_REMOVE_VOLUME (2) +#define RI_OPCODE_MOVE_VOLUME (3) +#define RI_OPCODE_SPLIT_VOLUME (4) +#define RI_OPCODE_ABORT_OPERATION (100) + +/* open operations for testing */ +typedef struct RI_open_per_volume_data_s +{ + long signature; + VolumeID_t volumeNameID; + Zid_t fileZid; + LONG requestedRights; +} RI_open_per_volume_data_s; + +/* detection options for a replication module + */ +typedef struct RI_detection_options_s +{ + long managedVolumes; + long typeOfNotifications; +} RI_detection_options_s; + +/* external module struct */ +typedef struct RI_replication_module_s +{ + registration_ID_t registrationID; + GUID_t moduleGUID; + RI_callbacks_s RMcallbacks; + LONG activeTraxID; + RI_detection_options_s detectionOptions; + char moduleName[RI_MODULE_NAME_MAX_LEN]; + char moduleDescriptions[RI_MODULE_DESC_MAX_LEN]; +} RI_replication_module_s; + +/* error codes for the next function */ + +#define RI_PROBE_RI_IS_MOSTLY_IDLE (1) +#define RI_PROBE_RI_IS_EXTREMELY_BUSY (99) + +/* function call to test whehter the infrastructure is alive + * in case of having not received any notifications for a long + * time, replication module may call this function to check + * Return Value: 1-99 Indicating how busy RI is (1=idle; 99=busiest). + */ + +extern int ProbeReplicationInfrastructure(); + +/* error codes for the next function */ +#define RI_REG_ERROR_TOO_MANY_MODULES (-1) +#define RI_REG_ERROR_ALLOCATE_TABLE_ENTRY (-2) +#define RI_REG_ERROR_LOCK_FAILED (-2) + +/* register a replication module + return value: + positive value - successful, and value = ID representing this registration + negative value - error. + */ +extern registration_ID_t +RegisterReplicationModule( + char* moduleName, + GUID_t moduleGUID, + char* LaunchCmd, + RI_callbacks_s* callbacks +); + +/* error codes for the next function */ +#define RI_REG_ERROR_INVALID_IDS (-1) +#define RI_REG_ERROR_ENTRY_NOT_FOUND (-2) + +/* de-register a replication module + */ +extern RI_RET +DeregisterReplicationModule( + RI_Module_IDs_s* module +); + +/* find a registered module + */ +int Find_Registered_Module( + RI_Module_IDs_s* module +); + +/* typedef: RI_filter_s */ + +typedef unsigned long RI_filter_t; + +/* criteria */ +#define RI_REG_PRE_NOTIFICATION (0x80000000) /* pre-notifications as well */ + +#define RI_REG_NOTIFY_MODIFIED (0x00000001) /* file/dir has been modified */ +#define RI_REG_NOTIFY_RENAME (0x00000002) /* rename file/dir */ +#define RI_REG_NOTIFY_DELETE (0x00000004) /* delete file/dir */ +#define RI_REG_NOTIFY_OPEN (0x00000008) /* open file/dir */ +#define RI_REG_NOTIFY_CLOSE (0x00000010) /* close file/dir */ +#define RI_REG_NOTIFY_WRITE (0x00000020) /* write part of a filee/dir */ +#define RI_REG_NOTIFY_READ (0x00000040) /* rename file/dir */ +#define RI_REG_NOTIFY_ATTR_MOD (0x00000080) /* modify file/dir attributes */ +#define RI_REG_NOTIFY_ATTR_READ (0x00000100) /* read file/dir attributes */ + +/* submit the criteria for incoming notifications */ +extern RI_RET +SubmitNotificationCriteria( + registration_ID_t registrationID, + RI_filter_t notificationCriteria +); + +/* states of a replication module */ +#define RM_STATE_UNKNOWN (-1) /* RM is unknown */ +#define RM_STATE_UNINSTALLED (1) /* RM is uninstalled */ +#define RM_STATE_UNLOADED (2) /* RM is unloaded */ +#define RM_STATE_COMING_UP (3) /* RM is coming up */ +#define RM_STATE_GOING_DOWN (4) /* RM is going down */ +#define RM_STATE_LOADED (5) /* RM is running */ + +/* report state change of a replication module */ +extern RI_RET +ReportChangeOfState ( + registration_ID_t registrationID, + long newState +); + +/* Operation ID returned by various async functions */ +typedef long operation_ID_t; + +/* report asyn replication is completed */ +extern RI_RET +AsyncInitialReplicationCompletion( + operation_ID_t OperationID, + RI_RET returnedValue +); + +/* perform a file system operation which will not be + intercepted by RI recursively + */ +extern RI_RET +PerformExemptedOperation( + void (*fileSystemOperation)(), + ... /* parameters required by the file system operation */ +); + +/* function to get the number of registered replication modules + * FUTURE: if we want to install modules using the GUI, we may + * need to keep track of all the known modules. + */ +extern int GetReplicationModuleNumber(); + +/* function to get the list of of registered replication modules + * the number of registered modules may change between calls to + * get the number and the list. So, return values are used to + * indicate whether all modules have been retrieved. + + return value: + positive value or 0 : successful, entries put in the buffer + negative value : error + */ +extern RI_RET +GetReplicationModuleList( + int entriesInList, + int* ret_entryNum, + RI_replication_module_s* ret_moduleList +); + +/* get the state of a replication module + only one of the parameters is required + */ +extern long +GetReplicationModuleState( + RI_Module_IDs_s* module, /* -> module to replicate the volume */ + long* retState /* -> return state - optional */ +); + +/* load a replication module + only one of the paramenters is required + GUID is the preferred parameter + */ +extern RI_RET +LoadReplicationModule( + RI_Module_IDs_s* module +); + +/* unload a replication module + only one of the paramenters is required + registration ID is the preferred parameter + */ +extern RI_RET +UnlaodReplicationModule( + RI_Module_IDs_s* module, + int waitSeconds +); + +/* install a replication module + only one of the first two paramenters is required + */ +extern RI_RET +InstallReplicationModule( + RI_Module_IDs_s* module, + BOOL loadAfterInstallation +); + +/* temporary volume operations + * FUTURE: replace them with Logical Volume operations + */ +extern RI_RET RI_Create_And_Mount_Volume( char* volumeName, LONG volumeSize ); +extern RI_RET RI_Delete_Mounted_Volume( char* volumeName ); + +/* export the working volume name for replication modules */ +extern int RI_Get_Work_Volume_name( char* volumeName, int size ); + +/* +extern BOOLEAN RI_Check_Stop_Flag(); +*/ + +/* used to report that a replicated volume is ready for use + */ +extern int RI_Volume_Is_Ready( char* volumeName, char* dirPath, + unicode_t* serverName, LONG opcode ); + +/* used to report that a replicated volume has been deleted + */ +extern int RI_Volume_has_Been_Deleted( char* volumeName, unicode_t* serverName, LONG opcode ); + +#ifdef RI_FUTURE_USE +/* Shut down the infrastructure and all + the replication modules + */ +extern void +ShutDownInfrastructure(); +#endif + +#endif \ No newline at end of file diff --git a/include/nwnss/internal/sbsMFL.h b/include/nwnss/internal/sbsMFL.h index 2460a51..7a6ed61 100644 --- a/include/nwnss/internal/sbsMFL.h +++ b/include/nwnss/internal/sbsMFL.h @@ -37,12 +37,12 @@ #ifndef _SBS_MFL_H_ #define _SBS_MFL_H_ -typedef struct ModifiedFileDesc_s -{ - Zid_t fileZid; +typedef struct ModifiedFileDesc_s +{ + Zid_t fileZid; WORD size; /* Size of this descriptor (including pathName size */ - WORD pathNameBytes; /* path name length in bytes */ - BYTE pathName[1]; + WORD pathNameBytes; /* path name length in bytes */ + BYTE pathName[1]; } ModifiedFileDesc_s; typedef struct MFLCursor_s @@ -51,7 +51,7 @@ typedef struct MFLCursor_s } MFLCursor_s; void SBS_markFileModified( - struct File_s *file, + struct File_s *file, NINT archiveBitsToSet, struct Xaction_s *xaction); void SBS_markFileModifiedAsync(struct File_s *file); diff --git a/include/nwnss/internal/spinlock.h b/include/nwnss/internal/spinlock.h deleted file mode 100644 index 338b386..0000000 --- a/include/nwnss/internal/spinlock.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef MARS_NWE_CORE_SPINLOCK_H -#define MARS_NWE_CORE_SPINLOCK_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Linux userspace backend for NSS runtime spin locks. - * - * The imported NSS common-layer headers were written for NetWare/NLM and - * Linux-kernel style spinlock APIs. mars-nwe now targets Linux userspace, so - * keep the primitive in libnwnss and map it directly to POSIX pthread - * spinlocks instead of carrying a fake NWFS-local shim. - */ -typedef pthread_spinlock_t spinlock_t; - -static inline void -spin_lock_init(spinlock_t *lock) -{ - (void)pthread_spin_init(lock, PTHREAD_PROCESS_PRIVATE); -} - -static inline void -spin_lock_destroy(spinlock_t *lock) -{ - (void)pthread_spin_destroy(lock); -} - -static inline void -spin_lock(spinlock_t *lock) -{ - (void)pthread_spin_lock(lock); -} - -static inline void -spin_unlock(spinlock_t *lock) -{ - (void)pthread_spin_unlock(lock); -} - -static inline int -spin_trylock(spinlock_t *lock) -{ - return pthread_spin_trylock(lock) == 0; -} - -#ifdef __cplusplus -} -#endif - -#endif /* MARS_NWE_CORE_SPINLOCK_H */ diff --git a/include/nwnss/internal/stdio.h b/include/nwnss/internal/stdio.h new file mode 100644 index 0000000..e154628 --- /dev/null +++ b/include/nwnss/internal/stdio.h @@ -0,0 +1,80 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library file + | + | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + | + | This header file should ONLY be used for NSS internal development. + | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). + | Any other use may cause conflicts which NSS will NOT fix. + +-------------------------------------------------------------------------*/ +#ifndef _NSS_STDIO_H_ +#define _NSS_STDIO_H_ + +#ifndef _XSTDIO_H_ +# include +#endif + +#ifndef _WIO_H_ +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define stdin wStdin +#define stdout wStdout + +#define getchar(p1) LB_getchar(p1) +#define gets(p1) LB_gets(p1) +#define printf LB_printf +#define sprintf LB_sprintf +#define vaprintf(p1,p2,p3) LB_vaprintf(p1,p2,p3) +#define vprintf(p1,p2) LB_vprintf(p1,p2) +#define vsprintf(p1,p2,p3) LB_vsprintf(p1,p2,p3) + +/*------------------------------ NSS Routines -----------------------------*/ + +#define TEST_MODULE 100000 /* Error number for all tests using errPrintf */ + +#define aprintf LB_aprintf +#define errPrintf LB_errPrintf + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/nwnss/include/seqUpdater.h b/include/nwnss/internal/time.h similarity index 80% rename from include/nwnss/include/seqUpdater.h rename to include/nwnss/internal/time.h index 94d83cb..8049211 100644 --- a/include/nwnss/include/seqUpdater.h +++ b/include/nwnss/internal/time.h @@ -1,6 +1,6 @@ /**************************************************************************** | - | (C) Copyright 2001 Novell, Inc. + | (C) Copyright 2002 Novell, Inc. | All Rights Reserved. | | This program is free software; you can redistribute it and/or @@ -32,16 +32,20 @@ | |--------------------------------------------------------------------------- | This module is used to: - | This defines globals and prototypes for the background checker. + | NSS Library file +-------------------------------------------------------------------------*/ -#ifndef _SEQUPDATER_H_ -#define _SEQUPDATER_H_ +#ifndef _NSS_TIME_H_ +#define _NSS_TIME_H_ -#if zLINUX -extern void SEQ_StartProcess(void); -extern void SEQ_StopProcess(void); -extern void SEQ_Sleep(NINT seconds); -extern void SEQ_Wakeup(void); + + +#ifdef __cplusplus +extern "C" { #endif -#endif /* _SEQUPDATER_H_ */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/nwnss/internal/unixAuthModel.h b/include/nwnss/internal/unixAuthModel.h index aafcb27..6aa39f3 100644 --- a/include/nwnss/internal/unixAuthModel.h +++ b/include/nwnss/internal/unixAuthModel.h @@ -38,19 +38,19 @@ #define _UXASAUTHMODEL_H_ #ifndef _OMNI_H_ -#include +#include #endif #ifndef _LATCH_H_ -#include +#include #endif #ifndef _COMNBEASTS_H_ -#include +#include "comnBeasts.h" #endif #ifndef _COMNAUTHORIZE_H_ -#include +#include "comnAuthorize.h" #endif /*------------------------------------------------------------------------- diff --git a/include/nwnss/internal/unixNSpace.h b/include/nwnss/internal/unixNSpace.h index 6ecdcd9..1524eab 100644 --- a/include/nwnss/internal/unixNSpace.h +++ b/include/nwnss/internal/unixNSpace.h @@ -38,7 +38,7 @@ #define _UNIXNSPACE_H_ #ifndef _OMNI_H_ -#include +#include #endif /*--------------------------------------------------------------------------- @@ -60,14 +60,14 @@ typedef struct zUnixInfo_Layout1_s { - LONG groupID; - LONG userID; - LONG fMode; - LONG rDev; - LONG myFlags; - BYTE acsFlags; - BYTE firstCreated; - BYTE filler[2]; + LONG groupID; + LONG userID; + LONG fMode; + LONG rDev; + LONG myFlags; + BYTE acsFlags; + BYTE firstCreated; + BYTE filler[2]; } NSS_MEDIA_STRUCTURE(zUnixInfo_Layout1_s,filler[2]) zUnixInfo_Layout1_s; typedef struct PackedUnixInfo_Layout1_s @@ -148,7 +148,7 @@ extern NINT UNIXNS_generateUniqueName( extern STATUS UNIXNS_getSeparator( GeneralMsg_s *genMsg, - NINT type, + NINT type, unicode_t **retStr, NINT *retLen); diff --git a/include/nwnss/internal/windowAPIs.h b/include/nwnss/internal/windowAPIs.h new file mode 100644 index 0000000..576abf5 --- /dev/null +++ b/include/nwnss/internal/windowAPIs.h @@ -0,0 +1,373 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + | + | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + | + | This header file should ONLY be used for NSS internal development. + | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). + | Any other use may cause conflicts which NSS will NOT fix. + +-------------------------------------------------------------------------*/ +#ifndef _WINDOWAPIS_H_ +#define _WINDOWAPIS_H_ + +#ifndef _ZOMNI_H_ +# include +#endif + +#ifndef _PSSDEBUG_H_ +# include +#endif + +#ifndef _INST_H_ +# include +#endif + +#ifndef _PSSMPK_H_ +# include +#endif + +#ifndef _INLINES_H_ +# include +#endif + +#ifndef _QUE_H_ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZOS_PutWinCursor(_p1,_p2,_p3) \ +{ \ + MPKNSS_UNLOCK(); \ + PutWinCursor(_p1,_p2,_p3); \ + MPKNSS_LOCK(); \ +} + + #define ZOS_WinPrintf(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + WinPrintf _p1; \ + MPKNSS_LOCK(); \ +} + +#define ZOS_ClearWindow(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + ClearWindow(_p1); \ + MPKNSS_LOCK(); \ +} + +#define ZOS_NWMakeWindow(_p1,_p2,_p3,_p4,_p5,_p6) \ + { \ + MPKNSS_UNLOCK(); \ + NWMakeWindow(_p1,_p2,_p3,_p4,_p5,_p6); \ + MPKNSS_LOCK(); \ +} + +#define ZOS_SetColors(_p1,_p2,_p3,_p4,_p5) \ + { \ + MPKNSS_UNLOCK(); \ + SetColors(_p1,_p2,_p3,_p4,_p5); \ + MPKNSS_LOCK(); \ +} + +#define ZOS_SetTitle(_p1,_p2) \ + { \ + MPKNSS_UNLOCK(); \ + SetTitle(_p1,_p2); \ + MPKNSS_LOCK(); \ +} + +#define ZOS_DisplayWindow(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + DisplayWindow(_p1); \ + MPKNSS_LOCK(); \ +} + +#define ZOS_GetCharSem(_p1,_p2,_p3) \ + { \ + MPKNSS_UNLOCK(); \ + GetCharSem(_p1,_p2,_p3); \ + MPKNSS_LOCK(); \ +} + +#define ZOS_DeleteWindow(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + DeleteWindow(_p1); \ + MPKNSS_LOCK(); \ +} + +#define ZOS_SetCharDisplayToAccent(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + SetCharDisplayToAccent(_p1); \ + MPKNSS_LOCK(); \ +} + +#define ZOS_SetCharDisplayToNormal(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + SetCharDisplayToNormal(_p1); \ + MPKNSS_LOCK(); \ +} + +#define ZOS_GetNWWinScreen(_p1,_p2,_p3) \ +{ \ + MPKNSS_UNLOCK(); \ + _p1 = GetNWWinScreen(_p2,_p3); \ + MPKNSS_LOCK(); \ +} + + +#define ZOS_PutNWWinScreen(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + PutNWWinScreen(_p1); \ + MPKNSS_LOCK(); \ +} + +#define ZOS_ActivateWinScreen(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + ActivateWinScreen(_p1); \ + MPKNSS_LOCK(); \ +} + + +#define ZOS_AddScrollElement(_p1,_p2) \ + { \ + MPKNSS_UNLOCK(); \ + AddScrollElement(_p1,_p2); \ + MPKNSS_LOCK(); \ +} +#define ZOS_ClearErrorMessage(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + ClearErrorMessage(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_ClearFieldData(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + ClearFieldData(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_ClearScrollList(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + ClearScrollList(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_CreateScrollList(_p1,_p2,_p3) \ + { \ + MPKNSS_UNLOCK(); \ + CreateScrollList(_p1,_p2,_p3); \ + MPKNSS_LOCK(); \ +} +#define ZOS_DeleteScrollList(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + DeleteScrollList(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_DisplayAllFieldData(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + DisplayAllFieldData(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_DisplayErrorMessage(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + DisplayErrorMessage(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_DisplayPrompt(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + DisplayPrompt(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_DisplayScrollArea(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + DisplayScrollArea(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_GetChar(_p1,_p2) \ + { \ + MPKNSS_UNLOCK(); \ + GetChar(_p1,_p2); \ + MPKNSS_LOCK(); \ +} +#define ZOS_GetFieldData(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + GetFieldData(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_UnLoadHelp(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + UnLoadHelp(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_WinChrDisplay(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + WinChrDisplay(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_SetSeparatorLine(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + SetSeparatorLine(_p1); \ + MPKNSS_LOCK(); \ +} + +#define ZOS_MoveWindowRelative(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + MoveWindowRelative(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_MakeField(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + MakeField(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_DisplayColHeader(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + DisplayColHeader(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_LoadHelpFile(_p1,_p2,_p3,_p4,_p5,_p6,_p7,p8) \ + { \ + MPKNSS_UNLOCK(); \ + LoadHelpFile(_p1,_p2,_p3,_p4,_p5,_p6,_p7,p8); \ + MPKNSS_LOCK(); \ +} +#define ZOS_InitFieldList(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + InitFieldList(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_HideWindow(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + HideWindow(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_GetTextWidth(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + GetTextWidth(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_GetTextHeight(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + GetTextHeight(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_SetIntensity(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + SetIntensity(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_SetHelpPage(_p1,_p2,_p3,_p4) \ + { \ + MPKNSS_UNLOCK(); \ + SetHelpPage(_p1,_p2,_p3,_p4); \ + MPKNSS_LOCK(); \ +} +#define ZOS_SetFieldHelpWindow(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + SetFieldHelpWindow(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_SetBorder(_p1,_p2) \ + { \ + MPKNSS_UNLOCK(); \ + SetBorder(_p1,_p2); \ + MPKNSS_LOCK(); \ +} +#define ZOS_SelectWinMenuElement(_p1,_p2,_p3,_p4,_p5) \ + { \ + MPKNSS_UNLOCK(); \ + SelectWinMenuElement(_p1,_p2,_p3,_p4,_p5); \ + MPKNSS_LOCK(); \ +} +#define ZOS_ReturnScrollElement(_p1,_p2,_p3,_p4) \ + { \ + MPKNSS_UNLOCK(); \ + ReturnScrollElement(_p1,_p2,_p3,_p4); \ + MPKNSS_LOCK(); \ +} +#define ZOS_PutWindowInRear(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + PutWindowInRear(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_PutWindowInFront(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + PutWindowInFront(_p1); \ + MPKNSS_LOCK(); \ +} +#define ZOS_NWMakeMenuAndSelect(_p1) \ + { \ + MPKNSS_UNLOCK(); \ + NWMakeMenuAndSelect(_p1); \ + MPKNSS_LOCK(); \ +} +#ifdef __cplusplus +} + +#endif + +#endif /* _WINDOWAPIS_H_ */ + diff --git a/include/nwnss/internal/windows.h b/include/nwnss/internal/windows.h new file mode 100644 index 0000000..c684ae5 --- /dev/null +++ b/include/nwnss/internal/windows.h @@ -0,0 +1,47 @@ +/**************************************************************************** + | + | (C) Copyright 1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) / Distributed File Services (DFS) + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Novell's WINSOCK2.H file conditionally includes a file called + | WINDOWS.H (The Windows SDK main header file). In normal NSS + | compilation the condition is never satisfied and no attempt is + | made to include WINDOWS.H. However, the dependency generator for + | NSS only searches for source lines beginning #include... Thus, + | without a file called WINDOWS.H an attempt to build the dependencies + | for the Jetstream TCP transport module (which depends on WINSOCK2.H) + | fails because there is no WINDOWS.H file in the NSS build environment. + | Therefore, this empty WINDOWS.H exists to satisfy the requirement + | of building dependencies when WINSOCK2.H is a dependency. + +-------------------------------------------------------------------------*/ + + diff --git a/include/nwnss/include/xMsg.h b/include/nwnss/internal/xMsg.h similarity index 96% rename from include/nwnss/include/xMsg.h rename to include/nwnss/internal/xMsg.h index e1b4688..75cf6a7 100644 --- a/include/nwnss/include/xMsg.h +++ b/include/nwnss/internal/xMsg.h @@ -43,27 +43,27 @@ extern "C" { #endif #ifndef _OMNI_H_ -#include +#include #endif #ifndef _XUNICODE_H_ -#include +#include #endif #ifndef _ZMSG_H_ -#include +#include #endif #ifndef _NSS_MSG_H_ -#include +#include #endif #ifndef _VOLUME_H_ -#include +#include #endif #ifndef _FULLDIRECTORYINFO_H_ -#include +#include #endif /* FixFixFix(CFS) - Remove in OPT code before SP1 */ @@ -123,7 +123,7 @@ typedef struct CroVolumeDoor_s /**************************************************************************/ -#define INVALID_BEAST_LEASE_ID 0 +#define INVALID_BEAST_LEASE_ID 0 #define CRO_RECONNECT_STATE_NOT_IN_SYNC 1 #define CRO_RECONNECT_STATE_SYNC_PHASE1 2 @@ -144,7 +144,7 @@ typedef struct XLSSBeastLeaseList_s { CSALeaseID_t XBLL_beastLeaseID; LONG XBLL_dataSeqNum; } XLSSBeastLeaseList_s; - + #define XLSS_MAX_ZIDS_TO_SYNC 50 @@ -162,7 +162,7 @@ typedef struct CSA_GeneralMsg_s{ } CSA_GeneralMsg_s; -/* FixFixFix - This inits taskID, flags and saID TWICE */ +/* FixFixFix - This inits taskID, flags and saID TWICE */ #define CSA_REMOTE_GENMSG_TO_LOCAL_GENMSG(_pktGenMsg, _genMsg) \ { \ if (_pktGenMsg == NULL) \ @@ -188,7 +188,7 @@ typedef struct CSA_GeneralMsg_s{ { \ (_pktGenMsg)->XS_errStatus = GetErrno((_genMsg)); \ } \ -} +} #define XLSS_REMOTE_GENMSG_TO_LOCAL_GENMSG(_status, _pktGenMsg, _genMsg) \ { \ @@ -208,7 +208,7 @@ typedef struct CSA_GeneralMsg_s{ (_pktGenMsg)->XL_taskID = (_genMsg)->taskID; \ (_pktGenMsg)->XL_saID = (_genMsg)->saID; \ (_pktGenMsg)->XL_flags = (_genMsg)->flags; \ -} +} /***************************************************************************/ @@ -223,8 +223,8 @@ typedef struct CSA_BeastLeaseBreakMsg_s Zid_t CBLM_zid; /* Zid of beast that needs its Beast * Lease broken. */ - LONG CBLM_delayHint; /* Number of milliseconds before - * XLSS should attempt to get the + LONG CBLM_delayHint; /* Number of milliseconds before + * XLSS should attempt to get the * Beast Lease again. */ } CSA_BeastLeaseBreakMsg_s; @@ -282,7 +282,7 @@ typedef struct XLSS_LookupByNameMsg_s LONG XLBM_nameType; LONG XLBM_nameUniquifier; /* msg->sys.data[0].start */ -// unicode_t XLBM_name[zMAX_COMPONENT_NAME]; +// unicode_t XLBM_name[zMAX_COMPONENT_NAME]; } XLSS_LookupByNameMsg_s; typedef struct CSA_LookupByNameMsg_s @@ -291,7 +291,7 @@ typedef struct CSA_LookupByNameMsg_s LONG CLBM_nameUniquifier; Zid_t CLBM_zid; /* msg->sys.data[1].start */ -// FullDirectoryInfo_s CLBM_dirInfo; +// FullDirectoryInfo_s CLBM_dirInfo; } CSA_LookupByNameMsg_s; /***************************************************************************/ @@ -504,7 +504,7 @@ typedef struct CSA_NameCacheInvalidateMsg_s LONG CNCM_nameType; LONG CNCM_nsFlag; /* msg->sys.data[0].start */ -// unicode_t CNCM_name[zMAX_COMPONENT_NAME]; +// unicode_t CNCM_name[zMAX_COMPONENT_NAME]; } CSA_NameCacheInvalidateMsg_s; @@ -518,7 +518,7 @@ typedef struct CSA_AuthCacheInvalidateMsg_s /***************************************************************************/ -typedef struct CSA_VolGetAuthModelIDMsg_s +typedef struct CSA_VolGetAuthModelIDMsg_s { LONG CCGM_authModelID; XlssMasterVolumeInfo_s CGCM_volInfo; @@ -526,14 +526,14 @@ typedef struct CSA_VolGetAuthModelIDMsg_s /***************************************************************************/ -typedef struct CSA_BeastStatePurgingMsg_s +typedef struct CSA_BeastStatePurgingMsg_s { Zid_t CBPM_zid; } CSA_BeastStatePurgingMsg_s; /***************************************************************************/ -typedef struct XLSS_AccessLeaseOpenMsg_s +typedef struct XLSS_AccessLeaseOpenMsg_s { XLSS_GeneralMsg_s XALM_genMsg; LONG XALM_fileNameUniquifier; @@ -546,7 +546,7 @@ typedef struct XLSS_AccessLeaseOpenMsg_s LONG XALM_parseFlags; } XLSS_AccessLeaseOpenMsg_s; -typedef struct CSA_AccessLeaseOpenMsg_s +typedef struct CSA_AccessLeaseOpenMsg_s { CSA_GeneralMsg_s CALM_genMsg; Key_t CALM_masterFHKey; @@ -906,8 +906,8 @@ typedef struct CROAccessLeaseList_s DQhead_t CALL_accessLeaseHead; Latch_s CALL_latch; } CROAccessLeaseList_s; - - + + typedef struct CROAccessLease_s { DQlink_t CAL_aLLink; @@ -941,7 +941,7 @@ BOOL CRO_AccessLeaseValidate( NamedBeast_s *beast, Key_t masterFHKey ); (_vol)->VOLnumDeletedFiles = (_volInfo)->XMVI_numDeletedFiles; \ if ((_volInfo)->XMVI_enabledAttributes & zATTR_SALVAGE) \ { \ - (_vol)->VOLenabledAttributes |= zATTR_SALVAGE; \ + (_vol)->VOLenabledAttributes |= zATTR_SALVAGE; \ } \ else \ { \ @@ -954,7 +954,7 @@ BOOL CRO_AccessLeaseValidate( NamedBeast_s *beast, Key_t masterFHKey ); { \ (_volInfo)->XMVI_numFiles = (_vol)->VOLnumFiles; \ (_volInfo)->XMVI_numObjects = (_vol)->VOLnumObjects; \ - (_volInfo)->XMVI_totalBlocks = (_vol)->VOLtotalBlocks; \ + (_volInfo)->XMVI_totalBlocks = (_vol)->VOLtotalBlocks; \ (_volInfo)->XMVI_inUseBlocks = (_vol)->VOLinUseBlocks; \ (_volInfo)->XMVI_purgeableBlocks = (_vol)->VOLpurgeableBlocks; \ (_volInfo)->XMVI_numDeletedFiles = (_vol)->VOLnumDeletedFiles; \ @@ -963,7 +963,7 @@ BOOL CRO_AccessLeaseValidate( NamedBeast_s *beast, Key_t masterFHKey ); { \ if ((_vol)->v_pool != NULL) \ { \ - (_volInfo)->XMVI_totalBlocks = (_vol)->v_pool->POOLtotalBlocks; \ + (_volInfo)->XMVI_totalBlocks = (_vol)->v_pool->POOLtotalBlocks; \ } \ } \ }; @@ -975,3 +975,4 @@ BOOL CRO_AccessLeaseValidate( NamedBeast_s *beast, Key_t masterFHKey ); #endif #endif + diff --git a/include/nwnss/internal/xlss.imp b/include/nwnss/internal/xlss.imp new file mode 100644 index 0000000..7c4008c --- /dev/null +++ b/include/nwnss/internal/xlss.imp @@ -0,0 +1,3 @@ + +XLSSArrayIndex + diff --git a/include/nwnss/include/zasAuthModel.h b/include/nwnss/internal/zasAuthModel.h similarity index 97% rename from include/nwnss/include/zasAuthModel.h rename to include/nwnss/internal/zasAuthModel.h index 79f82c2..4118aa1 100644 --- a/include/nwnss/include/zasAuthModel.h +++ b/include/nwnss/internal/zasAuthModel.h @@ -38,11 +38,11 @@ #define _ZASAUTHMODEL_H_ #ifndef _OMNI_H_ -#include +#include #endif #ifndef _LATCH_H_ -#include +#include #endif #ifndef _COMNBEASTS_H_ @@ -67,7 +67,7 @@ //#define ACLO_SMALL ENABLE #if ACLO_SMALL IS_ENABLED && NSS_DEBUG IS_ENABLED -#define MAX_ACL_OVERFLOW_ENTRIES 10 +#define MAX_ACL_OVERFLOW_ENTRIES 10 #else #define MAX_ACL_OVERFLOW_ENTRIES 50 #endif @@ -76,7 +76,7 @@ //#define VISO_SMALL ENABLE #if VISO_SMALL IS_ENABLED && NSS_DEBUG IS_ENABLED -#define MAX_VIS_OVERFLOW_ENTRIES 10 +#define MAX_VIS_OVERFLOW_ENTRIES 10 #else #define MAX_VIS_OVERFLOW_ENTRIES 50 #endif @@ -132,7 +132,7 @@ typedef struct V1_ZASPersistentAuthInfo_s } NSS_MEDIA_STRUCTURE(V1_ZASPersistentAuthInfo_s,numVisibilityTrusteesAssigned) V1_ZASPersistentAuthInfo_s; /* - * NOTE: The latch used here keeps the cacheIndex, restartCount and signature + * NOTE: The latch used here keeps the cacheIndex, restartCount and signature * from being read out of sync. It is not being checked when a beast is flushed * to disk. This works because the restart count will invalidate these fields * if we crash with only half of them written out. @@ -168,7 +168,7 @@ typedef struct FixVisibPurgeLogFsm_s AuthBeast_s *parentBeast; FixVisibPLog_s *purgeLogLocations; NINT trusteeCount; - UserID_t *trusteeID; + UserID_t *trusteeID; struct Volume_s *volume; } FixVisibPurgeLogFsm_s; @@ -222,9 +222,9 @@ extern STATUS ZAS_FindVisibilityTrustee( extern STATUS ZAS_GetVisibilityEntries( struct GeneralMsg_s *genMsg, - struct AuthBeast_s *authBeast, - NINT maxEntries, - struct VisEntry_s *visEntries, + struct AuthBeast_s *authBeast, + NINT maxEntries, + struct VisEntry_s *visEntries, NINT *numReturned); extern STATUS VAUTH_AddAuthInfo( @@ -371,7 +371,7 @@ extern STATUS ZAS_InvalidateEACLCacheEntries( struct GeneralMsg_s *genMsg, UserID_t *trusteeID, BOOL checkXLSS); - + extern STATUS ZAS_InvalidateEntireEACLCache( struct GeneralMsg_s *genMsg, BOOL checkXLSS); diff --git a/include/nwnss/internal/zlssDevUserIO.h b/include/nwnss/internal/zlssDevUserIO.h deleted file mode 100644 index 152f8b5..0000000 --- a/include/nwnss/internal/zlssDevUserIO.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef NWNSS_INTERNAL_ZLSS_DEV_USER_IO_H -#define NWNSS_INTERNAL_ZLSS_DEV_USER_IO_H - -/* - * Userspace companion for the original NSS ZLSS device/BIO entry points. - * - * Keep the public/original function names in zfs.h as the contract used by the - * imported ZLSS/COMN code. In NSS_USERSPACE builds the implementations live in - * zlssDevUserIO.c instead of the kernel BIO implementation in zlssDev.c. - * - * This boundary is intentionally I/O-centric: future NSS volume/image access - * is implemented here using Linux userspace pread/pwrite/fsync semantics. It - * must not globally intercept libc read/write or the higher-level NSS beast, - * pool, volume, or namespace algorithms. - */ - -#include - -#endif /* NWNSS_INTERNAL_ZLSS_DEV_USER_IO_H */ diff --git a/include/nwnss/library/bit.h b/include/nwnss/library/bit.h index 372f2cf..c013228 100644 --- a/include/nwnss/library/bit.h +++ b/include/nwnss/library/bit.h @@ -44,13 +44,11 @@ #define _BIT_H_ #ifndef _OMNI_H_ -#include +#include #endif -#ifdef _WATCOMC_ #ifndef _INLINES_H_ -#include -#endif +#include #endif #ifdef __cplusplus diff --git a/include/nwnss/library/bitmap.h b/include/nwnss/library/bitmap.h index 75a646a..d493534 100644 --- a/include/nwnss/library/bitmap.h +++ b/include/nwnss/library/bitmap.h @@ -38,7 +38,7 @@ #define _NSS_BITMAP_H_ #ifndef _ZOMNI_H_ -# include +# include #endif typedef struct BitMap_s { @@ -50,9 +50,9 @@ typedef struct BitMap_s { extern NINT getMaxBits (BitMap_s *bitMap); extern BOOL testABit (BitMap_s *bitMap, NINT bitNum); extern void setAbit (BitMap_s *bitMap, NINT bitNum); -extern void clearAbit(BitMap_s *bitMap, NINT bitNum); -extern void setBits(BitMap_s *bitMap, NINT startBit, NINT numBits); -extern void clearBits(BitMap_s *bitMap, NINT startBit, NINT numBits); +extern void clearAbit(BitMap_s *bitMap, NINT bitNum); +extern void setBits(BitMap_s *bitMap, NINT startBit, NINT numBits); +extern void clearBits(BitMap_s *bitMap, NINT startBit, NINT numBits); extern NINT countBits(BitMap_s *bitMap); extern SNINT findBits(BitMap_s *bitMap, NINT bitsNeeded); diff --git a/include/nwnss/library/clock.h b/include/nwnss/library/clock.h new file mode 100644 index 0000000..75b2d74 --- /dev/null +++ b/include/nwnss/library/clock.h @@ -0,0 +1,105 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (PSS) Initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: Header for Clock Victim Selection Alg. + +-------------------------------------------------------------------------*/ + +#ifndef _CLOCK_H_ +#define _CLOCK_H_ + +#ifndef _OMNI_H_ +#include +#endif + +/* + * Clock algorithm for managing caches. + * + * The clock algorithm is a cheaper mechanism than LRU for victim + * selection in a cache. It can also be easily tuned to age entries + * so they don't hang around forever. + * + * To use: + * 1. Object type to be cached must have a BYTE field to be used as + * the "use" flag. + * 2. When the the object is referenced, must set the use flag. The + * macro USE_CLOCK should be used to do this. + */ + +typedef struct Clock_s +{ + BYTE **start; + BYTE **end; + BYTE **hand; + void (*slay)(BYTE *); + + NINT added; + NINT rmv; + NINT slain; + NINT died; + NINT aged; + NINT adv; + + NINT use; + NINT try; +} Clock_s; + +#define USE_VICTIM(_victimField) ((*(_victimField)) = FALSE) +#define CLEAR_SLOT(_pslot) (*(_pslot) = NULL) + +extern STATUS initClock( + Clock_s *clock, + NINT numSlots, + BYTE **slots, + void (*slay)(BYTE *victim)); + +extern BYTE **addToClock( + Clock_s *clock, + BYTE *victim); + +BOOL rmvFromClock( + Clock_s *clock, + BYTE **pslot, + BYTE *victim); + +extern void advanceClock( + Clock_s *clock); + +extern void scanClock( + Clock_s *clock, + voidfunc_t f, + void *userdata); + +extern void prClock( + Clock_s *clock, + void (*prSlot)(NINT slotNum, BYTE *victim)); + +#endif diff --git a/include/nwnss/library/crc.h b/include/nwnss/library/crc.h index f98d6b8..8da9153 100644 --- a/include/nwnss/library/crc.h +++ b/include/nwnss/library/crc.h @@ -36,7 +36,7 @@ #define _CRC_H_ #ifndef _ZOMNI_H_ -#include +#include #endif typedef LONG crc_t; diff --git a/include/nwnss/library/ctype.h b/include/nwnss/library/ctype.h index 9e60c78..26a09b5 100644 --- a/include/nwnss/library/ctype.h +++ b/include/nwnss/library/ctype.h @@ -44,7 +44,7 @@ #define _NSS_CTYPE_H_ #ifndef _XCTYPE_H_ -#include +#include #endif #ifdef __linux__ @@ -52,7 +52,7 @@ #ifdef __KERNEL__ #include "linux/ctype.h" #else -#include_next +#include "sys/../ctype.h" #endif #else // #ifdef __linux diff --git a/include/nwnss/library/format.h b/include/nwnss/library/format.h index 29a774b..d16a8d6 100644 --- a/include/nwnss/library/format.h +++ b/include/nwnss/library/format.h @@ -1,26 +1,26 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) Initialization module + | NetWare Advance File Services (NSS) Initialization module | |--------------------------------------------------------------------------- | @@ -31,22 +31,22 @@ | $Revision: 465 $ | |--------------------------------------------------------------------------- - | This module is used to: - | Header file for generic version of quick sort. + | This module is used to: + | Header file for generic version of quick sort. +-------------------------------------------------------------------------*/ #ifndef _FORMAT_H_ #define _FORMAT_H_ #ifndef _ZOMNI_H_ -#include +#include #endif void formatNumber( - QUAD time, - BYTE *str); + QUAD time, + BYTE *str); void formatTime( - LONG time, - BYTE *str); + LONG time, + BYTE *str); #endif diff --git a/include/nwnss/library/hash.h b/include/nwnss/library/hash.h index 160b266..3e92097 100644 --- a/include/nwnss/library/hash.h +++ b/include/nwnss/library/hash.h @@ -36,11 +36,11 @@ #define _NSS_HASH_H_ #ifndef _ZOMNI_H_ -#include "public/zOmni.h" +#include "zOmni.h" #endif #ifndef _CRC_H_ -#include "library/crc.h" +#include "crc.h" #endif typedef struct HashRecord_s { diff --git a/include/nwnss/library/inlines.h b/include/nwnss/library/inlines.h index ed40c52..390cce7 100644 --- a/include/nwnss/library/inlines.h +++ b/include/nwnss/library/inlines.h @@ -45,10 +45,10 @@ #ifndef _INLINES_H_ #define _INLINES_H_ -#include +#include #ifndef _ZOMNI_H_ -# include +# include #endif #ifdef __cplusplus @@ -159,7 +159,7 @@ extern void inline_movebwd( modify exact [eax edi esi ecx]; /*--------------------------------------------------------------------------- - * + * *---------------------------------------------------------------------------*/ extern void inline_movebwd_bytesOnly( void *dst, diff --git a/include/nwnss/library/libNSS.imp b/include/nwnss/library/libNSS.imp new file mode 100644 index 0000000..525cecd --- /dev/null +++ b/include/nwnss/library/libNSS.imp @@ -0,0 +1,158 @@ +CMovFast +CMovFastCache +insertionSort +LB_atoi +LB_atol +LB_atoq +LB_bzero +LB_CountBits +LB_findHighBit +LB_findLowBit +LB_initstate +LB_IsTable +LB_itoa +LB_LongJmp +LB_memchr +LB_memcmp +LB_memcpy +LB_memicmp +LB_memlset +LB_memmove +LB_memset +LB_rand +LB_random +LB_RotateLeft +LB_RotateRight +LB_SetJmp +LB_srand +LB_srandom +LB_setstate +LB_strcat +LB_strchr +LB_strcmp +LB_strcpy +LB_stricmp +LB_strlen +LB_strlwr +LB_strmcpy +LB_strncmp +LB_strncpy +LB_strnicmp +LB_strrchr +LB_strrev +LB_strset +LB_strstr +LB_strtol +LB_strtoq +LB_strtoul +LB_strtouq +LB_strupr +LB_tolower +LB_toupper +LB_utoa +LBQ_CIRappend +LBQ_CIRcnt +LBQ_CIRdeq +LBQ_CIRdeqNoCheck +LBQ_CIRdrop +LBQ_CIRenq +LBQ_CIRfind +LBQ_CIRinitElements +LBQ_CIRprepend +LBQ_CIRpush +LBQ_CIRrmv +LBQ_DQappend +LBQ_DQcnt +LBQ_DQdeq +LBQ_DQdeqNoCheck +LBQ_DQdrop +LBQ_DQenq +LBQ_DQfind +LBQ_DQinitElements +LBQ_DQprepend +LBQ_DQpush +LBQ_DQrmv +LBQ_DQtake +LBQ_SETapply +LBQ_SETcnt +LBQ_SETdeq +LBQ_SETdeqNoCheck +LBQ_SETdrop +LBQ_SETenq +LBQ_SETfind +LBQ_SETinitElements +LBQ_SETpush +LBQ_SETrmv +LBQ_SETtake +LBQ_QAssertError +LBQ_SQappend +LBQ_SQcnt +LBQ_SQdeq +LBQ_SQdeqNoCheck +LBQ_SQdrop +LBQ_SQenq +LBQ_SQfind +LBQ_SQinitElements +LBQ_SQprepend +LBQ_SQpush +LBQ_SQrmv +LBQ_STKdrop +LBQ_STKinitElements +LBQ_STKpop +LBQ_STKpopNoCheck +LBQ_STKpush +LBQ_STKrmv +microSecondTimer +NSS_DQAuditCallback +NSS_QAssertErrorCallback +nssInitializeSpinLockCode +nssSpinLock +nssSpinUnlock +quickSort +randQuad +rndQuad +seedRandQuad +srndQuad +uni2utf +utf2uni +XML_BackwardFindEndTag +XML_FindEndOfElement +XML_findEndOfNonWhiteSpace +XML_ForwardFindTag +XML_GetNextTag +XML_GetTagAttribute +XML_GetTagElement +XML_isWhiteSpace +XML_skipWhiteSpace +initClock +addToClock +advanceClock +rmvFromClock +scanClock +isPattern +isMatch +RBP_Audit +RBP_Delete +RBP_DestroyTree +RBP_InOrder +RBP_Insert +RBP_Find +RBP_FindCeiling +RBP_FindFloor +RBP_Max +RBP_Min +RBP_PostOrder +RBP_Pred +RBP_Succ +prdelay +pr +prd +prp +prq +prs +pru +prx +prmem +DebugIsOn +DebugFilter +DebugDelay diff --git a/include/nwnss/library/nssDebug.h b/include/nwnss/library/nssDebug.h index 76f5d22..60b250a 100644 --- a/include/nwnss/library/nssDebug.h +++ b/include/nwnss/library/nssDebug.h @@ -39,7 +39,7 @@ #define _NSSDEBUG_H_ #ifndef _ZWHERE_H_ -#include +#include #endif /* @@ -48,7 +48,7 @@ */ #if zNETWARE #ifndef _ZOMNI_H_ -#include +#include #endif #endif diff --git a/include/nwnss/library/omni.h b/include/nwnss/library/omni.h index 26fd6b2..cee3306 100644 --- a/include/nwnss/library/omni.h +++ b/include/nwnss/library/omni.h @@ -45,7 +45,7 @@ #define _OMNI_H_ #ifndef _ZOMNI_H_ -#include +#include #endif #ifdef __cplusplus @@ -66,7 +66,7 @@ extern "C" { * six main conditionals. One and only one of these conditionals should * be set to ENABLE. Both uni and multi processor configurations are defined. *---------------------------------------------------------------------------*/ -#ifdef UNOPT +#ifdef UNOPT #ifdef MPK # define NSS_UNI_OPTIMAL DISABLE /* ENABLE for uni-processor production code*/ # define NSS_UNI_DEBUG DISABLE //ENABLE /* ENABLE for development*/ @@ -360,7 +360,7 @@ typedef NINT CFS_t; /* holds the Compressed File Size (CFS)*/ #endif #ifndef _SIZE_T -# include +# include #endif #if BLKNUM_64 IS_ENABLED @@ -570,7 +570,7 @@ void seedRandQuad (SQUAD x); /*------------------------------------------------------------------------- * This macro will ASSERT if interrupts are not enabled. *-------------------------------------------------------------------------*/ -#if ((MPK_REAL IS_DISABLED) && (NSS_DEBUG IS_ENABLED)) +#if ((MPK_REAL IS_DISABLED) && (NSS_DEBUG IS_ENABLED)) #define CHECK_INTERRUPTS() zASSERT(IntsEnabled()); #else #define CHECK_INTERRUPTS() @@ -703,7 +703,7 @@ typedef struct LangEnabledStruct_s { \ OutputToScreen(errorScreen, \ MSGNot("\nError loading message table\n")); \ - } + } #else /* Language Enabling turned OFF */ # define MSG(s,id) s @@ -732,7 +732,7 @@ typedef struct LangEnabledStruct_s * { * DQlink_t *abc = &Xyzzy.link; * Xyz_s *efg; - * + * * efg = STRUCT(abc, Xyz_s, link); * } */ diff --git a/include/nwnss/library/que.h b/include/nwnss/library/que.h index 1f0318b..a57eaa4 100644 --- a/include/nwnss/library/que.h +++ b/include/nwnss/library/que.h @@ -47,7 +47,7 @@ # include #endif #ifndef _OMNI_H_ -# include +# include #endif #ifdef __cplusplus @@ -63,35 +63,35 @@ extern "C" { | list structure being used. The link field can be any place in the | structure though being placed at the front of the structure generates | slightly better code. - | + | | We support four types of linked list. - | + | | 1. A stack (STK) | 2. A singly linked list (SQ) | 3. A singly linked circular list (CIR) | 4. A doubly linked circular list (DQ) - | + | | The following sections describe each of these link types in | detail and how to use the various operations and under what | circumstances they should be used. - | + | | You have several compile time options to ENABLE or DISABLE to | select how these routines are implemented in your system. - | + | | MCCABE ENABLE Sets rest of options to minimize complexity | measures from the MCCABE tools. | DISABLE Use options set by developer. - | + | | QUE_NULL ENABLE NULL out next pointer after dequeuing | DISABLE Next pointer is not nulled, thus QMEMBER | and QUE_CHECK are not available. - | + | | QUE_CHECK ENABLE Make sure 'next' is NULL when putting an | element into a linked list. This should | be ENABLED during development but should | be DISABLED for maximum performance. | DISABLE No checking done. - | + | | QUE_MACRO ENABLE Use the macro (in-line) versions. Because | of locality in caches, it may be more | efficient to use the function version of @@ -99,30 +99,30 @@ extern "C" { | DISABLE Use the function versions. Makes it | easier to step over queuing functions | when debugging. - | + | | The generic macros work across all linked list types. The following | parameters are the same for all the macros. - | + | | type | INPUT: The type of the structure pointed to by 'item'. | linkField | INPUT: The field allocated in the structure to be | used as the link field for the linked list. It should | be declared to be of appropriate for the linked list. - | + | | Definitions used in USAGE sections: - | + | | typedef struct Xyz_s | { | int field_a; | DQlink_t link; | int field_b; | } Xyz_s; - | + | | DQhead_t Head; | Zyz_s Xyzzy; | Zyz_s *xyz; - | + | | FRONTADDR(item, type, linkField) | Because the link field can be any place in the structure, | sometimes you have a pointer to the link field and want @@ -135,10 +135,10 @@ extern "C" { | USAGE: | { | Xyz_s *abc = (Xyz_s *)&Xyzzy.link; - | + | | FRONTADDR(abc, Xyz_s, link); | } - | + | | STRUCT(item, type, linkField) | Same as FRONTADDR but rather than updating 'item', lets | the new pointer be assigned to a variable of your choice. @@ -148,10 +148,10 @@ extern "C" { | { | DQlink_t *abc = &Xyzzy.link; | Xyz_s *efg; - | + | | efg = STRUCT(abc, Xyz_s, link); | } - | + | | NEXT(item) | Gets the next item in a linked list. In this case, | item points to the link field of the structure. @@ -162,11 +162,11 @@ extern "C" { | DQlink_t *abc = &Xyzzy.link; | DQlink_t *next; | Xyz_s *efg; - | + | | next = NEXT(abc); | efg = STRUCT(next, Xyz_s, link); | } - | + | | ONEXT(item, type, linkField) | Gets the next item in a linked list. In this case, | assumes item is pointing to the front of the structure @@ -178,14 +178,14 @@ extern "C" { | { | Xyz_s *abc = &Xyzzy; | Xyz_s *next; - | + | | next = NEXT(abc, Xyz_s, link); | } - | + | | PREV and OPREV only apply to doubly linked lists which have | a previous element pointer but are included here because they | complement NEXT and ONEXT. - | + | | PREV(item) | Gets the previous item in a doubly linked list. In | this case, item points to the link field of the structure. @@ -198,11 +198,11 @@ extern "C" { | DQlink_t *abc = &Xyzzy.link; | DQlink_t *prev; | Xyz_s *efg; - | + | | prev = PREV(abc); | efg = STRUCT(prev, Xyz_s, link); | } - | + | | OPREV(item, type, linkField) | Gets the previous item in a doubly linked list. In | this case, it assumes item is pointing to the front @@ -214,10 +214,10 @@ extern "C" { | { | Xyz_s *abc = &Xyzzy; | Xyz_s *prev; - | + | | prev = PREV(abc, Xyz_s, link); | } - | + | | NULLIFY(link) | Used internally by link list routines to set the | 'next' field to NULL if QUE_NULL is ENABLED. Can @@ -229,7 +229,7 @@ extern "C" { | { | NULLIFY( &Xyzzy.link); | } - | + | | QMEMBER(link) | Used to test if linkField is in a linked list. It does | this by comparing the linkField to NULL. Only works if @@ -242,17 +242,17 @@ extern "C" { | { | DQ_RMV( &Xyzzy, link); | } - | + | | Stack: STK | A stack is a singly linked list that supports Last-In-First-Out | (LIFO) order access to its members. The last element on the | list points to NULL. - | + | | Empty Head | +-------+ | | NULL | | +-------+ - | + | | +-------+ | | Top +-------+ | +-------+ | @@ -275,60 +275,60 @@ extern "C" { | --+-- | --- | - - | + | | typedef struct Xyz_s | { | int field_a; | STKlink_t stkLink; | int field_b; | } Xyz_s; - | + | | zyzzy() | { | STKtop_t Top; | Xyz_s A, B, C; | Xyz_s *a, *b, *c; - | + | | STK_INIT(Top); - | + | | STK_PUSH(Top, &C, stkLink); | STK_PUSH(Top, &B, stkLink); | STK_PUSH(Top, &A, stkLink); - | + | | STK_POP(Top, a, Xyz_s, stkLink); | STK_POP(Top, b, Xyz_s, stkLink); | STK_POP(Top, c, Xyz_s, stkLink); | } - | + | | Stacks are useful for handling free lists of resources. The link fields | have been designed so that a structure that normally resides on some | other type of linked data structure, can be stored on a free list managed | by the stack macros. - | + | | Typedefs: - | + | | STKlink_t Use the STKlink_t typedef to define the link field | in the structures to be managed as a stack. This | field must be initialized to zero either by zeroing | the whole structure or calling NULLIFY with the field. - | + | | STKtop_t Use the STKtop_t typedef to define the top of the | stack or LIFO. The top must be initialized by either | using STK_INIT or STK_INIT_ELEMENTS. - | + | | Macros: - | + | | STK_INIT(top) | Initialize the top of the stack. | top | OUTPUT: A variable of type STKtop_t used for the | top of the stack. - | + | | STK_STATIC_INIT() | Uses compile time initialization to initialize the head. | USAGE: | STKtop_t Top = STK_STATIC_INIT(); - | + | | STK_INIT_ELEMENTS(top, data, numElements, typeElement, linkField) | Used to take an array of items and initialize all of them | and push them onto the stack. A nice way to build a free @@ -350,10 +350,10 @@ extern "C" { | { | Xyz_s Xyz[10]; | STKtop_t Top; - | + | | STK_INIT_ELEMENTS(Top, Xyz, 10, Xyz_s, link); | } - | + | | STK_EMPTY(top) | Is True, if top of stack is empty, otherwise is False. | Used to test if there are any items left on the stack. @@ -361,7 +361,7 @@ extern "C" { | INPUT: The top of the stack. | USAGE: | if (STK_EMPTY(Top)) { ... } - | + | | STK_NOT_EMPTY(top) | Is False, if top of stack is empty, otherwise is True. | Easier to understand then "if (!STK_EMPTY(top))...". @@ -369,7 +369,7 @@ extern "C" { | INPUT: The top of the stack. | USAGE: | if (STK_NOT_EMPTY(Top)) { ... } - | + | | STK_PUSH(top, item, linkField) | Push an item on to the stack. If the stack is immediately | popped, this item will come off first. @@ -379,7 +379,7 @@ extern "C" { | INPUT: Pointer to a structure to be put in the stack. | The 'linkField' of 'item' is set to the current structure | pointer in 'top' and 'top' points to 'item'. - | + | | STK_POP(top, item, type, linkField) | Pop the top item off the stack. If the stack is empty, | item is set to NULL, otherwise it has the top structure @@ -392,7 +392,7 @@ extern "C" { | OUTPUT: Pointer to a structure of type 'type'. Set | to NULL if the stack is empty, otherwise set to a | pointer to the structure pointed to by top. - | + | | STK_POP_NO_CHECK(top, item, type, linkField) | STK_POP_NO_CHECK is just like STK_POP except we know | something is on the stack having done a STK_NOT_EMPTY @@ -404,7 +404,7 @@ extern "C" { | OUTPUT: Pointer to a structure of type 'type'. Set | to NULL if the stack is empty, otherwise set to a | pointer to the structure pointed to by top. - | + | | STK_PEEK(top, item, type, linkField) | Sets 'item' to the first element at the top of the stack | but does not remove it from the stack. Good for checking @@ -416,7 +416,7 @@ extern "C" { | OUTPUT: Pointer to a structure of type 'type'. Set | to NULL if the stack is empty, otherwise set to a | pointer to the structure pointed to by top. - | + | | STK_DROP(top, item, type, linkField) | Used to drop or remove 'item' from the top of the stack. | Normally, 'item' is obtained by using STK_PEEK. @@ -427,7 +427,7 @@ extern "C" { | OUTPUT: Pointer to a structure of type 'type'. Set | to NULL if the stack is empty, otherwise set to a | pointer to the structure pointed to by top. - | + | | STK_RMV(top, item, linkField) | Removes the designated 'item' from the stack by starting | at the head of the stack and scanning the stack linearly @@ -441,7 +441,7 @@ extern "C" { | RETURNS: | TRUE: found the item in the stack and removed it. | FALSE: did not find the item in the stack and did nothing. - | + | | STK_FOREACH(head, item, type, linkField) | Used to scan through the stack to process it or search for | a particular element in the stack. It is really a 'for' loop @@ -454,7 +454,7 @@ extern "C" { | { | extern STKtop_t Top; | Xyz_s *x; - | + | | STK_FOREACH(Top, x, Xyz_s, stkLink) | { | if (x->field_a == 42) return x; @@ -468,7 +468,7 @@ extern "C" { | we support. The head does take more space than the circular linked | lists (CIR). Elements can be inserted at either the head or the tail | of the queue but can only be take from the head. - | + | | Empty Head | +-------+ | | next |<------+ @@ -477,7 +477,7 @@ extern "C" { | +---+---+ | | | | | +-----------+ - | + | | Head | +-------+ | | next +-------+ @@ -499,59 +499,59 @@ extern "C" { | | +-------+ | +------>| C | last item on list | +-------+ - | + | | typedef struct Xyz_s | { | int field_a; | SQlink_t sqLink; | int field_b; | } Xyz_s; - | + | | zyzzy() | { | SQhead_t Head; | Xyz_s A, B, C; | Xyz_s *a, *b, *c; - | + | | SQ_INIT( &Head); - | + | | SQ_ENQ( &Head, &A, sqLink); | SQ_ENQ( &Head, &B, sqLink); | SQ_ENQ( &Head, &C, sqLink); - | + | | SQ_DEQ( &Head, a, Xyz_s, sqLink); | SQ_DEQ( &Head, b, Xyz_s, sqLink); | SQ_DEQ( &Head, c, Xyz_s, sqLink); | } - | + | | Singly linked queues can quickly process queues that are normally | accessed in FIFO order and elements are rarely or never removed | from the middle of the queue. To remove an element from the middle | of the queue requires starting a scan at the head and following the | links until the desired element is found. - | + | | Typedefs: - | + | | SQlink_t Use the SQlink_t typedef to define the link field | in the structures to be managed as a singly linked | queue. This field must be initialized to zero either | by zeroing the whole structure or calling NULLIFY | with the field. - | + | | SQhead_t Use the SQhead_t typedef to define the head of the | singly linked queue. The head must be initialized by | either using SQ_INIT or SQ_INIT_ELEMENTS. - | + | | Macros: - | + | | SQ_INIT(head) | Initialize the head of the queue. | head | OUTPUT: A pointer to a variable of type SQhead_t. - | + | | SQ_INIT_ELEMENTS(head, data, numElements, typeElement, linkField) | Used to take an array of items and initialize all of them - | and enqueue them in the queue. + | and enqueue them in the queue. | head | OUTPUT: A variable of type SQhead_t used for the | head of the queue. Assumed to be uninitialized. @@ -568,10 +568,10 @@ extern "C" { | { | Xyz_s Xyz[10]; | SQhead_t Head; - | + | | SQ_INIT_ELEMENTS(Head, Xyz, 10, Xyz_s, link); | } - | + | | SQ_EMPTY(head) | Is True, if queue is empty, otherwise is False. | Used to test if there are any items left in the queue. @@ -579,7 +579,7 @@ extern "C" { | INPUT: A pointer to the head of the queue. | USAGE: | if (SQ_EMPTY(Head)) { ... } - | + | | SQ_NOT_EMPTY(head) | Is False, if queue is empty, otherwise is True. | Easier to understand then "if (!SQ_EMPTY(head))...". @@ -587,7 +587,7 @@ extern "C" { | INPUT: A pointer to the head of the queue. | USAGE: | if (SQ_NOT_EMPTY(Head)) { ... } - | + | | SQ_ENQ(head, item, linkField) | Enqueue an item on to the tail of the queue. | head @@ -596,7 +596,7 @@ extern "C" { | item | INPUT: Pointer to the element to be inserted at the | tail of the queue. - | + | | SQ_PUSH(head, item, linkField) | Push an item on to the front of the queue. If the queue | is immediately dequeued, this item will come off. Useful @@ -608,7 +608,7 @@ extern "C" { | UPDATE: Pointer to the element to be inserted at the head | of the queue. The link field of 'item' points to what | the 'head' did. - | + | | SQ_DEQ(head, item, type, linkField) | Dequeue the first item off the queue. If the queue is | empty, item is set to NULL, otherwise it has the oldest @@ -621,7 +621,7 @@ extern "C" { | OUTPUT: Pointer to a structure of type 'type'. Set | to NULL if the queue is empty, otherwise set to a | pointer to the structure pointed to by head. - | + | | SQ_DEQ_NO_CHECK(head, item, type, linkField) | SQ_DEQ_NO_CHECK is just like SQ_DEQ except we know | something is on the queue having done a SQ_NOT_EMPTY @@ -632,7 +632,7 @@ extern "C" { | item | OUTPUT: Pointer to a structure of type 'type'. Set | to a pointer to the structure pointed to by head. - | + | | SQ_PEEK(head, item, type, linkField) | Sets 'item' to the first element at the head of the queue | but does not remove it from the queue. Good for checking @@ -644,7 +644,7 @@ extern "C" { | OUTPUT: Pointer to a structure of type 'type'. Set | to a pointer to the structure pointed to by head. If | queue is empty, it is set to NULL. - | + | | SQ_PEEK_LAST(head, item, type, linkField) | Sets 'item' to the element at the tail of the queue | but does not remove it from the queue. @@ -654,7 +654,7 @@ extern "C" { | OUTPUT: Pointer to a structure of type 'type'. Set | to a pointer to the structure pointed to by head. If | queue is empty, it is set to NULL. - | + | | SQ_DROP(head, item, linkField) | Used to drop or remove 'item' from the head of the queue. | Normally, 'item' is obtained by using SQ_PEEK. @@ -664,7 +664,7 @@ extern "C" { | item | UPDATE: Pointer to a structure of type 'type'. 'item' | was obtained by doing a SQ_PEEK. - | + | | SQ_RMV(head, item, linkField) | Removes the designated 'item' from the queue by starting | at the head of the queue and scanning the queue linearly @@ -676,7 +676,7 @@ extern "C" { | item | INPUT: Pointer to a structure of type 'type'. LinkField | will be set to NULL, if QUE_NULL is enabled. - | + | | SQ_APPEND(head, appendee) | Used to append one queue to another queue. All the | elements in the appendee queue are placed at the tail @@ -689,7 +689,7 @@ extern "C" { | UPDATE: A pointer to the head of the queue that will be | attached to the end of the head queue. 'appendee' is | made an empty queue. - | + | | SQ_PREPEND(head, prependee) | Used to prepend one queue to another queue. All the | elements in the prepend queue are placed at the front @@ -702,14 +702,14 @@ extern "C" { | UPDATE: A pointer to the head of the queue that will be | attached to the beginning of the head queue. The 'prependee' | is made an empty queue. - | + | | SQ_FIND(head, item, linkField) | Returns TRUE if it finds 'item' in the queue, otherwise | returns FALSE. Does a linear search of the queue to find | the 'item'. | head | INPUT: A pointer to the head of the queue. - | + | | SQ_CNT(head) | Returns the number of elements in the queue. | head @@ -720,12 +720,12 @@ extern "C" { | head element. It is a little more costly to manipulate than the | singly linked queue described above but it only uses one pointer | for the head so can be used when many instances of queues are needed. - | + | | Empty Head | +-------+ | | 0 | | +-------+ - | + | | +-------+ | | Head +-------+ | +-------+ | @@ -744,53 +744,53 @@ extern "C" { | | +-------+ | +-------+ B | | +-------+ - | + | | typedef struct Xyz_s | { | int field_a; | CIRlink_t cirLink; | int field_b; | } Xyz_s; - | + | | zyzzy() | { | CIRhead_t Head; | Xyz_s A, B, C; | Xyz_s *a, *b, *c; - | + | | CIR_INIT(Head); - | + | | CIR_ENQ(Head, &A, cirLink); | CIR_ENQ(Head, &B, cirLink); | CIR_ENQ(Head, &C, cirLink); - | + | | CIR_DEQ(Head, a, Xyz_s, cirLink); | CIR_DEQ(Head, b, Xyz_s, cirLink); | CIR_DEQ(Head, c, Xyz_s, cirLink); | } | | Typedefs: - | + | | CIRlink_t Use the CIRlink_t typedef to define the link field | in the structures to be managed as a singly linked | circular queue. This field must be initialized to | zero either by zeroing the whole structure or calling | NULLIFY with the field. - | + | | CIRhead_t Use the CIRhead_t typedef to define the head of the | singly linked circular queue. The head must be | initialized by either using CIR_INIT or CIR_INIT_ELEMENTS. - | + | | Macros: - | + | | CIR_INIT(head) | Initialize the head of the queue. | head | OUTPUT: A variable of type CIRhead_t initialized to NULL. - | + | | CIR_INIT_ELEMENTS(head, data, numElements, typeElement, linkField) | Used to take an array of items and initialize all of them - | and enqueue them in the queue. + | and enqueue them in the queue. | head | OUTPUT: A variable of type CIRhead_t used for the | head of the queue. Assumed to be uninitialized. @@ -807,10 +807,10 @@ extern "C" { | { | Xyz_s Xyz[10]; | CIRhead_t Head; - | + | | CIR_INIT_ELEMENTS(Head, Xyz, 10, Xyz_s, link); | } - | + | | CIR_EMPTY(head) | Is True, if queue is empty, otherwise is False. | Used to test if there are any items left in the queue. @@ -818,7 +818,7 @@ extern "C" { | INPUT: The head of the queue. | USAGE: | if (CIR_EMPTY(Head)) { ... } - | + | | CIR_NOT_EMPTY(head) | Is False, if queue is empty, otherwise is True. | Easier to understand then "if (!CIR_EMPTY(head))...". @@ -826,7 +826,7 @@ extern "C" { | INPUT: The head of the queue. | USAGE: | if (CIR_NOT_EMPTY(Head)) { ... } - | + | | CIR_ENQ(head, item, linkField) | Enqueue an item on to the tail of the queue. | head @@ -836,7 +836,7 @@ extern "C" { | item | UPDATE: Pointer to element to be inserted at tail of queue. | Its link field is updated to point to the head element. - | + | | CIR_PUSH(head, item, linkField) | Push an item on to the front of the queue. If the queue | is immediately dequeued, this item will come off. Useful @@ -849,7 +849,7 @@ extern "C" { | item | UPDATE: Pointer to element to be inserted at head of queue. | Its link field is updated to point to the old head element. - | + | | CIR_DEQ(head, item, type, linkField) | Dequeue the first item off the queue. If the queue is | empty, item is set to NULL, otherwise it has the oldest @@ -864,7 +864,7 @@ extern "C" { | to NULL if the queue is empty, otherwise set to a | pointer to the structure pointed to by the tail element | pointed to by 'head'. - | + | | CIR_DEQ_NO_CHECK(head, item, type, linkField) | CIR_DEQ_NO_CHECK is just like CIR_DEQ except we know | something is on the queue having done a CIR_NOT_EMPTY @@ -878,7 +878,7 @@ extern "C" { | to NULL if the queue is empty, otherwise set to a | pointer to the structure pointed to by the tail element | pointed to by 'head'. - | + | | CIR_PEEK(head, item, type, linkField) | Sets 'item' to the first element at the head of the queue | but does not remove it from the queue. Good for checking @@ -891,7 +891,7 @@ extern "C" { | to the first element of the queue which is pointed | to by tail element which is pointed to by head. If | queue is empty, it is set to NULL. - | + | | CIR_DROP(head, item, linkField) | Used to drop or remove 'item' from the head of the queue. | Normally, 'item' is obtained by using CIR_PEEK. @@ -902,7 +902,7 @@ extern "C" { | item | UPDATE: Pointer to a structure of type 'type'. 'item' | was obtained by doing a CIR_PEEK. - | + | | CIR_RMV(head, item, linkField) | Removes the designated 'item' from the queue by starting | at the head of the queue and scanning the queue linearly @@ -913,7 +913,7 @@ extern "C" { | item | INPUT: Pointer to a structure of type 'type'. LinkField | will be set to NULL, if QUE_NULL is enabled. - | + | | CIR_APPEND(head, appendee) | Used to append one queue to another queue. All the | elements in the appendee queue are placed at the tail @@ -925,7 +925,7 @@ extern "C" { | UPDATE: The head of the queue that will be attached to | the end of the head queue. 'appendee' is made an empty | queue. - | + | | CIR_PREPEND(head, prependee) | Used to prepend one queue to another queue. All the | elements in the prepend queue are placed at the front @@ -938,14 +938,14 @@ extern "C" { | UPDATE: The head of the queue that will be attached to | the beginning of the head queue. The 'prependee' is made | an empty queue. - | + | | CIR_FIND(head, item, linkField) | Returns TRUE if it finds 'item' in the queue, otherwise | returns FALSE. Does a linear search of the queue to find | the 'item'. | head | INPUT: A pointer to the head of the queue. - | + | | CIR_CNT(head) | Returns the number of elements in the queue. | head @@ -956,14 +956,14 @@ extern "C" { | store. The head of a doubly linked queue appears as a member of the | queue. It has a 'next' and 'previous' pointer and can be traversed | in either direction. The queue is empty when the head points to itself. - | + | | Empty Head | +-------+ | +-->| next +---+ | | +-------+ | | +---+ prev |<--+ | +-------+ - | + | | Head | +-->+-------+<---------------+ | | | next +-------+ | @@ -991,68 +991,68 @@ extern "C" { | +-------+ | | | +----+ | +-------+ - | + | | typedef struct Xyz_s | { | int field_a; | DQlink_t dqLink; | int field_b; | } Xyz_s; - | + | | zyzzy() | { | DQhead_t Head; | Xyz_s A, B, C; | Xyz_s *a, *b, *c; - | + | | DQ_INIT( &Head); - | + | | DQ_ENQ( &Head, &A, dqLink); | DQ_ENQ( &Head, &B, dqLink); | DQ_ENQ( &Head, &C, dqLink); - | + | | DQ_DEQ( &Head, a, Xyz_s, dqLink); | DQ_DEQ( &Head, b, Xyz_s, dqLink); | DQ_DEQ( &Head, c, Xyz_s, dqLink); | } - | + | | Their biggest advantages are easy removal of an item from the middle | of a list (you don't even have to know the head) and simple routines | for scanning the list. For data structures that need to use multiple | linked lists, this is the queue of choice because once you have found | the element on one list, you can easily remove it from other lists. - | + | | Typedefs: - | + | | DQlink_t Use the DQlink_t typedef to define the link field | in the structures to be managed as doubly linked | queue. This field must be initialized to zero either | by zeroing the whole structure or calling NULLIFY | with the field. - | + | | DQhead_t Use the DQhead_t typedef to define the head of the | doubly linked queue. The head must be initialized by | either using DQ_INIT or DQ_INIT_ELEMENTS. - | + | | Macros: - | + | | DQ_INIT(head) | Initialize the head of the queue. | head | OUTPUT: A pointer to a variable of type DQhead_t. | USAGE: | DQ_INIT( &Head); - | + | | DQ_STATIC_INIT(head) | Uses compile time initialization to initialize the head. | head | OUTPUT: A variable of type DQhead_t. | USAGE: | DQhead_t Head = DQ_STATIC_INIT(Head); - | + | | DQ_INIT_ELEMENTS(head, data, numElements, typeElement, linkField) | Used to take an array of items and initialize all of them - | and enqueue them in the queue. + | and enqueue them in the queue. | head | OUTPUT: A variable of type DQhead_t used for the | head of the queue. Assumed to be uninitialized. @@ -1069,10 +1069,10 @@ extern "C" { | { | Xyz_s Xyz[10]; | DQhead_t Head; - | + | | DQ_INIT_ELEMENTS(Head, Xyz, 10, Xyz_s, link); | } - | + | | DQ_EMPTY(head) | Is True, if queue is empty, otherwise is False. | Used to test if there are any items left in the queue. @@ -1080,7 +1080,7 @@ extern "C" { | INPUT: A pointer to the head of the queue. | USAGE: | if (DQ_EMPTY(Head)) { ... } - | + | | DQ_NOT_EMPTY(head) | Is False, if queue is empty, otherwise is True. | Easier to understand then "if (!DQ_EMPTY(head))...". @@ -1088,7 +1088,7 @@ extern "C" { | INPUT: A pointer to the head of the queue. | USAGE: | if (DQ_NOT_EMPTY(Head)) { ... } - | + | | DQ_IS_MORE_THAN_ONE(head) | Is True, if more than one item on queue, otherwise is False. | It is easy to test if there is only 0 or 1 items on a DQ. @@ -1108,7 +1108,7 @@ extern "C" { | tail of the queue. Its 'next' pointer will point to | the 'head' and its 'previous' pointer will point to | the old tail. - | + | | DQ_PUSH(head, item, linkField) | Push an item on to the front of the queue. If the queue | is immediately dequeued, this item will come off. Useful @@ -1121,7 +1121,7 @@ extern "C" { | of the queue. The 'previous' field of 'item' will point | to the 'head' and the 'next' field will point to the old | head element of the queue. - | + | | DQ_DEQ(head, item, type, linkField) | Dequeue the first item off the queue. If the queue is | empty, item is set to NULL, otherwise it has the oldest @@ -1134,7 +1134,7 @@ extern "C" { | OUTPUT: Pointer to a structure of type 'type'. Set | to NULL if the queue is empty, otherwise set to a | pointer to the structure pointed to by head. - | + | | DQ_DEQ_NO_CHECK(head, item, type, linkField) | DQ_DEQ_NO_CHECK is just like DQ_DEQ except we know | something is on the queue having done a DQ_NOT_EMPTY @@ -1145,7 +1145,7 @@ extern "C" { | item | OUTPUT: Pointer to a structure of type 'type'. Set | to a pointer to the structure pointed to by head. - | + | | DQ_TAKE(head, item, type, linkField) | Dequeue the last item off the queue (which is normally the | the last item inserted). If the queue is empty, item is set @@ -1171,11 +1171,11 @@ extern "C" { | OUTPUT: Pointer to a structure of type 'type'. Set | to a pointer to the structure pointed to by head. If | queue is empty, it is set to NULL. - | + | | DQ_PEEK_END(head, item, type, linkField) | Sets 'item' to the LAST element at the head of the queue | but does not remove it from the queue. Good for checking - | resources before committing them. + | resources before committing them. | head | INPUT: A pointer to the head of the queue. | item @@ -1192,7 +1192,7 @@ extern "C" { | item | UPDATE: Pointer to a structure of type 'type'. 'item' | was obtained by doing a DQ_PEEK. - | + | | DQ_RMV(item, linkField) | Removes the designated 'item' from the queue. Because | we have a 'next' and 'previous' pointers, this operation @@ -1203,7 +1203,7 @@ extern "C" { | will be set to NULL, if QUE_NULL is enabled. Its successor | and predecessor elements in the queue will now point | to each others - | + | | DQ_APPEND(head, appendee) | Used to append one queue to another queue. All the | elements in the appendee queue are placed at the tail @@ -1216,7 +1216,7 @@ extern "C" { | UPDATE: A pointer to the head of the queue that will be | attached to the end of the head queue. 'appendee' is | made an empty queue. - | + | | DQ_PREPEND(head, prependee) | Used to prepend one queue to another queue. All the | elements in the prepend queue are placed at the front @@ -1229,7 +1229,7 @@ extern "C" { | UPDATE: A pointer to the head of the queue that will be | attached to the beginning of the head queue. The 'prependee' | is made an empty queue. - | + | | DQ_FOREACH(head, item, type, linkField) | Used to scan through the queue to process it or search for | a particular element in the queue. It is really a 'for' loop @@ -1242,13 +1242,13 @@ extern "C" { | { | extern DQhead_t Head; | Xyz_s *x; - | + | | DQ_FOREACH( &Head, x, Xyz_s, dqLink) | { | if (x->field_a == 42) return x; | } | } - | + | | DQ_ISHEADNEXT(head, item, type, linkField) | Can be used to check if you are at the last item in the | list. @@ -1260,7 +1260,7 @@ extern "C" { | { | extern DQhead_t Head; | Xyz_s *x; - | + | | DQ_FOREACH( &Head, x, Xyz_s, dqLink) | { | if (x->field_a == 42) return x; @@ -1271,7 +1271,7 @@ extern "C" { | } | } | } - | + | | DQ_NEXT(head, item, type, linkField) | Get the next 'item' in the queue. If you reach the head, | 'item' is set to NULL. Useful for more generic scanning. @@ -1283,7 +1283,7 @@ extern "C" { | { | extern DQhead_t Head; | Xyz_s *x; - | + | | x = STRUCT( &Head, Xyz_s, dqLink); | x = DQ_NEXT( &Head, x, Xyz_s, dqLink); | while (x != NULL) @@ -1293,7 +1293,7 @@ extern "C" { | } | return NULL; | } - | + | | DQ_PREV(head, item, type, linkField) | Get the previous 'item' in the queue. If you reach the head, | 'item' is set to NULL. @@ -1305,7 +1305,7 @@ extern "C" { | { | extern DQhead_t Head; | Xyz_s *x; - | + | | x = STRUCT( &Head, Xyz_s, dqLink); | x = DQ_PREV( &Head, x, Xyz_s, dqLink); | for(;;) @@ -1314,14 +1314,14 @@ extern "C" { | x = DQ_PREV( &Head, x, Xyz_s, dqLink); | } | } - | + | | DQ_FIND(head, item, linkField) | Returns TRUE if it finds 'item' in the queue, otherwise | returns FALSE. Does a linear search of the queue to find | the 'item'. | head | INPUT: A pointer to the head of the queue. - | + | | DQ_CNT(head) | Returns the number of elements in the queue. | head @@ -1473,7 +1473,7 @@ extern ADDR LBQ_STKpopNoCheck(STKtop_t *top, NINT offset); extern void LBQ_STKdrop(STKtop_t *); extern int LBQ_STKrmv(STKtop_t *, STKlink_t); extern void LBQ_STKinitElements(STKtop_t *stacktop, ADDR start,NINT num, NINT size); - + #define STK_INIT(top) ((top) = NULL) diff --git a/include/nwnss/library/rand.h b/include/nwnss/library/rand.h index e2ff54c..7aa21fd 100644 --- a/include/nwnss/library/rand.h +++ b/include/nwnss/library/rand.h @@ -38,7 +38,7 @@ #define _RAND_H_ #ifndef _ZOMNI_H_ -#include +#include #endif void srndLong(QUAD); diff --git a/include/nwnss/library/rbpTree.h b/include/nwnss/library/rbpTree.h index 842d6dd..5230bbd 100644 --- a/include/nwnss/library/rbpTree.h +++ b/include/nwnss/library/rbpTree.h @@ -68,7 +68,7 @@ * modified temporarily during delete operations, you must have separate * RBP_Tree_s for each tree that can be updated independently. * - * + * * RBP_Init Initialize a red-black tree. * * tree: Pointer to type of tree being initialized @@ -106,7 +106,7 @@ * node: User node to inserted to the tree. All key fields must * be filled in. Note: node is a pointer to the beginning * of the sturcture, not the RBP_Node_s field in the structure. - * + * * */ @@ -114,7 +114,7 @@ #define _RBPTREE_H_ #ifndef _OMNI_H_ -#include +#include #endif typedef struct RBP_Node_s RBP_Node_s; diff --git a/include/nwnss/library/regmodules.h b/include/nwnss/library/regmodules.h new file mode 100644 index 0000000..31661a1 --- /dev/null +++ b/include/nwnss/library/regmodules.h @@ -0,0 +1,51 @@ +/**************************************************************************** + | + | (C) Copyright 2006 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NSS kernel include + | + |--------------------------------------------------------------------------- + | + | $Id: regmodules.h 1790 2006-12-21 17:24:51Z randys $ + | + |--------------------------------------------------------------------------- + | + | This module contains the prototypes and structures for module registration + | + +-------------------------------------------------------------------------*/ +#ifndef _REGMODULES_H_ +#define _REGMODULES_H_ + +// +// module registration functions +// +int nss_register_module ( + const unsigned char *name, + const void *func_ptr, + struct module *module); + +void nss_unregister_module(const unsigned char *name); + +const void *nss_get_module(const unsigned char *name); + +void nss_put_module(const unsigned char *name); + +#endif /* _REGMODULES_H_ */ diff --git a/include/nwnss/library/setjmp.h b/include/nwnss/library/setjmp.h new file mode 100644 index 0000000..42245a6 --- /dev/null +++ b/include/nwnss/library/setjmp.h @@ -0,0 +1,62 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library Routine + | + | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + | + | This header file should ONLY be used for NSS internal development. + | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). + | Any other use may cause conflicts which NSS will NOT fix. + +-------------------------------------------------------------------------*/ +#ifndef _NSS_SETJMP_H_ +#define _NSS_SETJMP_H_ + +#ifndef _XSETJMP_H_ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define jmp_buf LB_jmp_buf +#define setjmp(jmpbuf) LB_SetJmp(jmpbuf) +#define longjmp(jmpbuf,val) LB_LongJmp(jmpbuf,val) + +#ifdef __cplusplus +} +#endif + +#endif /* _NSS_SETJMP_H_ */ diff --git a/include/nwnss/library/sort.h b/include/nwnss/library/sort.h new file mode 100644 index 0000000..6783daf --- /dev/null +++ b/include/nwnss/library/sort.h @@ -0,0 +1,68 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) Initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Header file for generic version of quick sort. + +-------------------------------------------------------------------------*/ +#ifndef _NSS_SORT_H_ +#define _NSS_SORT_H_ + +#ifndef _ZOMNI_H_ +#include +#endif + +/* + * Sort algorithms based on Robert Sedgewick, "Algorithms in C." + * Insertion sort is used as the final phase of quick sort but + * can be used independently for small files or files that are + * nearly sorted. + * + * These sort routines expect three arguments: + * void *a[] : an a array of pointers to the items to be sorted. + * NINT n : the number of pointers in the array a. + * cmpfunc_t cmp : function that compares two items from a. + */ + + /* + * Function used by the sort routines to compare two items being + * sorted. Must return a signed integer: + * <0 : a is less than b + * 0 : a is equal to b + * >0 : a is greater than b + */ +typedef SNINT (*cmpfunc_t)(const void *a, const void *b); + +void insertionSort(void *a[], NINT n, cmpfunc_t cmp); +void quickSort(void *a[], NINT n, cmpfunc_t cmp); + +#endif diff --git a/include/nwnss/library/stdlib.h b/include/nwnss/library/stdlib.h index c076589..eb5a12f 100644 --- a/include/nwnss/library/stdlib.h +++ b/include/nwnss/library/stdlib.h @@ -43,14 +43,14 @@ #ifndef _NSS_STDLIB_H_ #define _NSS_STDLIB_H_ -#if defined(__linux__) && !defined(__KERNEL__) && !defined(NSS_USERSPACE) +#if defined(__linux__) && ! defined(__KERNEL__) #include #else // #ifdef linux #ifndef _XSTDLIB_H_ -#include +#include #endif #ifdef __cplusplus diff --git a/include/nwnss/library/string.h b/include/nwnss/library/string.h index 8574887..0c431d1 100644 --- a/include/nwnss/library/string.h +++ b/include/nwnss/library/string.h @@ -45,17 +45,16 @@ #ifdef __linux__ -#if defined(NSS_USERSPACE) && !defined(__KERNEL__) -#include_next -#include -#define stricmp(p1,p2) strcasecmp(p1,p2) -#define strnicmp(p1,p2,p3) strncasecmp(p1,p2,p3) -#elif defined(__KERNEL__) +#ifdef __KERNEL__ #include "linux/string.h" +#else +#include "sys/../string.h" +#endif + +#ifdef __KERNEL__ #define bzero(p1,p2) LB_bzero(p1,p2) #define stricmp(p1,p2) LB_stricmp(p1,p2) #else -#include "sys/../string.h" #define stricmp(p1,p2) strcasecmp(p1,p2) #endif #define strmcpy(p1,p2,p3) LB_strmcpy(p1,p2,p3) @@ -77,7 +76,7 @@ void CMovFastCache( void* dest, void* source, int byteCount); #else #ifndef _XSTRING_H_ -#include +#include #endif #ifdef __cplusplus diff --git a/include/nwnss/library/timeline.h b/include/nwnss/library/timeline.h new file mode 100644 index 0000000..b210bda --- /dev/null +++ b/include/nwnss/library/timeline.h @@ -0,0 +1,52 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996, 1998 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Head file for timeline code + +-------------------------------------------------------------------------*/ + +#ifndef _TIMELINE_H_ +#define _TIMELINE_H_ + +#ifndef _ZOMNI_H_ +#include +#endif + +extern void addWhat( + NINT what); /* "what" should be a number to identify the incident */ + +extern void addWho( + NINT what, /* "what" should be a number to identify the incident */ + void *who); + +#endif diff --git a/include/nwnss/library/xLimits.h b/include/nwnss/library/xLimits.h index d4da272..55bf10b 100644 --- a/include/nwnss/library/xLimits.h +++ b/include/nwnss/library/xLimits.h @@ -44,7 +44,7 @@ #define _XLIMITS_H_ #ifndef _OMNI_H_ -# include +# include #endif #if zNETWARE diff --git a/include/nwnss/library/xSetjmp.h b/include/nwnss/library/xSetjmp.h new file mode 100644 index 0000000..fb23a52 --- /dev/null +++ b/include/nwnss/library/xSetjmp.h @@ -0,0 +1,58 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library Routine + | + | WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + | + | This header file should ONLY be used for NSS internal development. + | This includes Semantic Agents (SA) and Loadable Storage Services (LSS). + | Any other use may cause conflicts which NSS will NOT fix. + +-------------------------------------------------------------------------*/ +#ifndef _XSETJMP_H_ +#define _XSETJMP_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int LB_jmp_buf[8]; +extern int LB_SetJmp(LB_jmp_buf); +extern void LB_LongJmp(LB_jmp_buf,int); + +#ifdef __cplusplus +} +#endif + +#endif /* _XSETJMP_H_ */ diff --git a/include/nwnss/library/xStdio.h b/include/nwnss/library/xStdio.h index 461eec1..398799e 100644 --- a/include/nwnss/library/xStdio.h +++ b/include/nwnss/library/xStdio.h @@ -48,7 +48,7 @@ #endif #ifndef _SIZE_T -# include +# include #endif #ifdef __cplusplus diff --git a/include/nwnss/library/xStdlib.h b/include/nwnss/library/xStdlib.h index 3fcd288..308b568 100644 --- a/include/nwnss/library/xStdlib.h +++ b/include/nwnss/library/xStdlib.h @@ -44,10 +44,10 @@ #define _XSTDLIB_H_ #ifndef _SIZE_T -# include +# include #endif -#include +#include #ifdef __cplusplus extern "C" { @@ -106,16 +106,6 @@ extern QUAD LB_strtouq( /*------------------------------ RAND Routines -----------------------------*/ -#ifdef NSS_USERSPACE -/* - * Host libc headers may have defined RAND_MAX before this original NSS header - * is included. Keep the Novell-visible value below, but remove the host macro - * first so userspace builds do not warn about a redefinition. - */ -#ifdef RAND_MAX -#undef RAND_MAX -#endif -#endif #define RAND_MAX 0x7fff extern int LB_rand(void); extern void LB_srand(unsigned int __seed ); diff --git a/include/nwnss/library/xString.h b/include/nwnss/library/xString.h index 467002a..60b4c79 100644 --- a/include/nwnss/library/xString.h +++ b/include/nwnss/library/xString.h @@ -45,7 +45,7 @@ #define _XSTRING_H_ #ifndef _SIZE_T -# include +# include #endif #ifdef NULL @@ -57,69 +57,69 @@ extern "C" { #endif -void *LB_memchr( - const void *__s, - int __c, +void *LB_memchr( + const void *__s, + int __c, size_t __n ); -//PJT int LB_memcmp( -//PJT const void *__s1, -//PJT const void *__s2, +//PJT int LB_memcmp( +//PJT const void *__s1, +//PJT const void *__s2, //PJT size_t __n ); -void *LB_memcpy( +void *LB_memcpy( void *__dest, const void *__src, size_t __n); -void *LB_memmove( +void *LB_memmove( void *__dest, const void *__src, size_t __n); -void *LB_memset( - void *__dest, - int __c, +void *LB_memset( + void *__dest, + int __c, size_t __n); -void *LB_memlset( - void *__dest, - long __l, +void *LB_memlset( + void *__dest, + long __l, size_t __n); -char *LB_strcat( - char *__s1, +char *LB_strcat( + char *__s1, const char *__s2); -char *LB_strchr( - const char *__s, +char *LB_strchr( + const char *__s, int __c); -int LB_strcmp( - const char *__s1, +int LB_strcmp( + const char *__s1, const char *__s2); -//int LB_strcoll( -// const char *__s1, +//int LB_strcoll( +// const char *__s1, // const char *__s2); -char *LB_strcpy( - char *__s1, +char *LB_strcpy( + char *__s1, const char *__s2); -//size_t LB_strcspn( -// const char *__s1, +//size_t LB_strcspn( +// const char *__s1, // const char *__s2); -//char *LB_strerror( +//char *LB_strerror( // int __errnum); -//PJT size_t LB_strlen( +//PJT size_t LB_strlen( //PJT const char *__s); -char *LB_strmcpy( - char *__s1, - const char *__s2, +char *LB_strmcpy( + char *__s1, + const char *__s2, size_t __n); int LB_strncmp( @@ -127,9 +127,9 @@ int LB_strncmp( const char *s2, size_t n); -char *LB_strncpy( - char *__s1, - const char *__s2, +char *LB_strncpy( + char *__s1, + const char *__s2, size_t __n ); int LB_strnicmp( @@ -137,60 +137,60 @@ int LB_strnicmp( const char *s2, size_t n); -//char *LB_strpbrk( -// const char *__s1, +//char *LB_strpbrk( +// const char *__s1, // const char *__s2); -char *LB_strrchr( - const char *__s, +char *LB_strrchr( + const char *__s, int __c); -//size_t LB_strspn( -// const char *__s1, +//size_t LB_strspn( +// const char *__s1, // const char *__s2); -char *LB_strstr( - const char *__s1, +char *LB_strstr( + const char *__s1, const char *__s2); -//char *LB_strtok( -// char *__s1, +//char *LB_strtok( +// char *__s1, // const char *__s2); -//size_t LB_strxfrm( -// char *__s1, -// const char *__s2, +//size_t LB_strxfrm( +// char *__s1, +// const char *__s2, // size_t __n); -int LB_memicmp( - const void *__s1, - const void *__s2, +int LB_memicmp( + const void *__s1, + const void *__s2, size_t __n); -//int LB_strcmpi( -// const char *__s1, +//int LB_strcmpi( +// const char *__s1, // const char *__s2); -//char *LB_strdup( +//char *LB_strdup( // const char *__string); -int LB_stricmp( - const char *__s1, +int LB_stricmp( + const char *__s1, const char *__s2); //char *LB_strlist( char *, const char *, ...); -char *LB_strlwr( +char *LB_strlwr( char *__string); -char *LB_strrev( +char *LB_strrev( char *__string); -char *LB_strset( - char *__string, +char *LB_strset( + char *__string, int __c); -char *LB_strupr( +char *LB_strupr( char *__string); @@ -223,8 +223,8 @@ char *LB_strupr( #define LB_LPSTRCPY(dest, src) \ (LB_memcpy((dest), (src), (BYTE)(*(src))+1)) -void LB_bzero( - void *__s, +void LB_bzero( + void *__s, size_t __n); extern int isPattern(char *p); diff --git a/include/nwnss/library/xUnicode.h b/include/nwnss/library/xUnicode.h index 866d336..05fa866 100644 --- a/include/nwnss/library/xUnicode.h +++ b/include/nwnss/library/xUnicode.h @@ -45,7 +45,7 @@ #define _XUNICODE_H_ #ifndef _OMNI_H_ -# include +# include #endif #ifdef __cplusplus @@ -299,7 +299,7 @@ extern STATUS LB_UTF8LenToUniChar( #define NSS_UNI_CONVERSION_RAW 2 /* No wildCard handling, noMap -> [xxxx] */ #define NSS_UNI_CONVERSION_WILD_DOS 3 /* Default NSS converter type with default wildcard handling, DOS FF handling */ -#if defined(_NSS_INTERNAL_) || defined(NSS_UNICODE) +#ifdef _NSS_INTERNAL_ # define NSS_UNI_CONVERSION_LAST_DEFINED 3 /* Highest Number of pre-defined types */ # define NSS_UNI_CONVERSION_COUNT 16 /* Max registerable converter types */ @@ -307,11 +307,11 @@ extern STATUS LB_UTF8LenToUniChar( * Tables to store mapped single or double bytes to unicode *---------------------------------------------------------------------------*/ extern unicode_t *NSSSingleByteToUnicodeTable[NSS_UNI_CONVERSION_COUNT]; - + extern unicode_t *NSSDoubleByteToUnicodeTable[NSS_UNI_CONVERSION_COUNT]; extern unicode_t *NSSMacSingleByteToUnicodeTable; - + extern unicode_t *NSSMacDoubleByteToUnicodeTable; /*--------------------------------------------------------------------------- @@ -356,7 +356,7 @@ extern unicode_t *LB_unimcpy( // CONST unicode_t *src1, // CONST char *src2); -#if zNETWARE || defined(__KERNEL__) || defined(NSS_UNICODE) +#if zNETWARE || defined(__KERNEL__) /*------------------------------------------------------------------------- * Case conversion Routines (not in standard library) *-------------------------------------------------------------------------*/ @@ -371,15 +371,13 @@ extern unicode_t LB_unitoupper( extern unicode_t NSSUniToLower[]; extern unicode_t LB_unitolower( CONST unicode_t c); -extern void LB_UnicodeCaseStartup(void); -extern void LB_UnicodeLowerStartup(void); #define unilwr(str) LB_unilwr(str) -extern unicode_t *LB_unilwr( +extern unicode_t *LB_unilwr( unicode_t *string); #define uniupr(str) LB_uniupr(str) -extern unicode_t *LB_uniupr( +extern unicode_t *LB_uniupr( unicode_t *string); extern int utf_tolower( @@ -480,7 +478,7 @@ extern int LB_unincmp( /* Unicode length compare */ const unicode_t *s2, size_t len); -#if zNETWARE || defined(__KERNEL__) || defined(NSS_UNICODE) +#if zNETWARE || defined(__KERNEL__) #undef uniicmp #define uniicmp(s1, s2) LB_uniicmp(s1, s2) extern int LB_uniicmp( @@ -537,7 +535,7 @@ typedef BOOL (*UNI_OverrideUni2ByteFunc_t)( * set of tables for translating unicode. * The "conversionType" is used to uniquely identify the new tables. * The overrideByte2Uni and overrideUni2Byte functions are used to specify - * translation overrides for the new tables. + * translation overrides for the new tables. *---------------------------------------------------------------------------*/ #define RegisterUnicodeConverter(type,ovByte2Uni,ovUni2Byte) \ LB_RegisterUnicodeConverter(type,ovByte2Uni,ovUni2Byte) diff --git a/include/nwnss/public/chunk.h b/include/nwnss/public/chunk.h index 17f9a68..f23ac4f 100644 --- a/include/nwnss/public/chunk.h +++ b/include/nwnss/public/chunk.h @@ -38,7 +38,7 @@ #define _CHUNK_H_ #ifndef _ZOMNI_H_ -# include +# include #endif typedef struct NSSChunk_s diff --git a/include/nwnss/public/dfsguids.h b/include/nwnss/public/dfsguids.h new file mode 100644 index 0000000..000c6e2 --- /dev/null +++ b/include/nwnss/public/dfsguids.h @@ -0,0 +1,72 @@ +/*************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) public GUID definitions + | + |-------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |-------------------------------------------------------------------------- + | This module is used to: + | Define well-known GUID values used in Novell Distributed File Services + +------------------------------------------------------------------------*/ + +#ifndef _DFSGUIDS_H_ +#define _DFSGUIDS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************** + * Note: Values defined in this file are intended to be used as + * initializers for variables of type GUID_t defined in the file + ***************************************************************************/ + +/* GUID for the Volume Location Database Service: */ +#define DFS_GUID_VLDB {0x80BE8C84, 0x50DC, 0x11D3, 0xAB, 0x6E, {0x00, 0x08, 0xC7, 0xD3, 0xAF, 0x2D}} + +/* GUID for the Volume Location Service Remote Procedure Call module: */ +#define DFS_GUID_VLRPC {0x80BE8C85, 0x50DC, 0x11D3, 0xAB, 0x6E, {0x00, 0x08, 0xC7, 0xD3, 0xAF, 0x2D}} + +/* GUID for the VLDB VDQAD back-end replication module: */ +#define DFS_GUID_VDQAD_REPL {0x80BE8C86, 0x50DC, 0x11D3, 0xAB, 0x6E, {0x00, 0x08, 0xC7, 0xD3, 0xAF, 0x2D}} + +/* GUID for the VLDB Repair module: */ +#define DFS_GUID_VLDB_REPAIR {0x80BE8C87, 0x50DC, 0x11D3, 0xAB, 0x6E, {0x00, 0x08, 0xC7, 0xD3, 0xAF, 0x2D}} + +/* GUID for the Volume Manager Service: */ +#define DFS_GUID_VOLMAN {0x80BE8C88, 0x50DC, 0x11D3, 0xAB, 0x6E, {0x00, 0x08, 0xC7, 0xD3, 0xAF, 0x2D}} + +/* GUID for the Volume Manager Remote Procedure Call module: */ +#define DFS_GUID_VMRPC {0x8B4534B8, 0x7F5B, 0x01D4, 0x80, 0x01, {0x00, 0xC0, 0x4F, 0xA3, 0x35, 0XE0}} + +#ifdef __cplusplus +} +#endif + +#endif /* _DFSGUIDS_H_ */ diff --git a/include/nwnss/public/ipc2ncp.h b/include/nwnss/public/ipc2ncp.h new file mode 100644 index 0000000..596b4fa --- /dev/null +++ b/include/nwnss/public/ipc2ncp.h @@ -0,0 +1,52 @@ +/**************************************************************************** + | + | (C) Copyright 2007 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2006-11-13 17:27:30 -0700 (Mon, 13 Nov 2006) $ + | + | $RCSfile$ + | $Revision: 1632 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Define message interface between NSS and NCP + +-------------------------------------------------------------------------*/ + +#ifndef _IPC2NPC_H_ +#define _IPC2NPC_H_ 1 + +#ifndef _LINUX_TYPES_H +#include +#endif + +typedef struct IPC_NCP_request_head_s { + __u32 ipc_signature; + __u32 ipc_request_num; + __u32 ipc_payload_len; + __u8 ipc_data[0]; +} IPC_NCP_request_head_s; + +#endif diff --git a/include/nwnss/public/jsmsg.h b/include/nwnss/public/jsmsg.h new file mode 100644 index 0000000..87d9999 --- /dev/null +++ b/include/nwnss/public/jsmsg.h @@ -0,0 +1,248 @@ +/**************************************************************************** + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Distributed File Services (DFS) + | + |--------------------------------------------------------------------------- + | + | $Author: stoner $ + | $Date: 2006-08-10 04:52:34 +0530 (Thu, 10 Aug 2006) $ + | + | $RCSfile$ + | $Revision: 1471 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | DFS communications declarations/interfaces for applications + +-------------------------------------------------------------------------*/ + +#ifndef _JSMSG_H_ +#define _JSMSG_H_ + +/* Dependencies */ +#ifndef _OMNI_H_ +#include /* Defines types required by Jetstream, including GUID_t */ +#endif +#if zNETWARE +#ifndef _OSMPKHDRS_H_ +#include /* Includes OS MPK definitions/declarations */ +#endif +#endif +#ifndef _QUE_H_ +#include +#endif + +#ifdef __cplusplus +extern "c" +{ +#endif + + +#ifdef __linux__ +#define THREAD pthread_t +typedef int SEMAPHORE; +#define MAX_NAME_LENGTH 100 +#endif + +/* + Manifest constants +*/ +#define JS_LARGE_BUFFER_BYTES (0x10000) /* Jetstream's default large buffer size (in bytes) */ +#define JS_MEDIUM_BUFFER_BYTES (0x1000) /* Jetstream's default medium buffer size (in bytes) */ +#define JS_SMALL_BUFFER_BYTES (0x100) /* Jetstream's default small buffer size (in bytes) */ +#define JS_WAIT_FOREVER (0xFFFFFFFF) /* Used in functions that take a delay value (e.g. JS_AllocateMessage) to indicate the function should block */ +#define JS_ARRAY_STAT_BIT (0x40000000) /* Bit that indicates an array statistic in statistic IDs */ +#define JS_PEAK_STAT_BIT (0x20000000) /* Bit that indicates a peak statistic in statistic IDs */ +#define JS_ARRAY_STAT_MASK (~JS_ARRAY_STAT_BIT) /* AND mask to remove the ARRAY_STAT_BIT */ +#define JS_PEAK_STAT_MASK (~JS_PEAK_STAT_BIT) /* AND mask to remove the PEAK_STAT_BIT */ +#define JS_NAMED_CONNECT_REQUEST (0x10) /* ControlCode for a named connect initial request */ +#define JS_NAMED_CONNECT_RESPONSE (0x11) /* ControlCode for a named connect initial response */ +#define JS_PHYSICAL_CONNECT_REQUEST (0x12) /* ControlCode for a physical connect request */ +#define JS_PHYSICAL_CONNECT_RESPONSE (0x13) /* ControlCode for a physical connect response */ +#define JS_AUTHENTICATE_ME_AS_1 (0x14) /* Control code for a connector to request the remote identity while supplying its own identity */ +#define JS_AUTHENTICATE_ME_AS_2 (0x15) /* Control code for a response to a JS_AUTHENTICATE_ME_AS_1 message */ +#define JS_CONNECT_COMPLETE (0x16) /* ControlCode for a message containing a connection complete message */ +#define JS_DISCONNECT_REQUEST (0x20) /* ControlCode for a disconnect session intial request */ +#define JS_DISCONNECT_RESPONSE (0x21) /* ControlCode for a disconnect session response */ +#define JS_DISCONNECT_COMPLETE (0x22) /* ControlCode to indicate to a consumer that an asynchronous disconnect is complete */ +#define JS_DESTROY_USER_BUFFER (0x30) /* ControlCode to indicate to a consumer or transport that the message has a user buffer and it must be destroyed */ +#define JS_GET_STATISTICS_IDS (0x40) /* ControlCode to indicate a request for the list of supported statistics */ +#define JS_STATISTICS_IDS (0x41) /* ControlCode to indicate a response containing the list of supported statistics */ +#define JS_GET_STATISTICS_VALUES (0x42) /* ControlCode to retrieve a particular set of statistics values */ +#define JS_STATISTICS_VALUES (0x43) /* ControlCode to indicate a response containing the list of requested statistics */ + +/* Error codes */ +#define JS_GENERAL_ERROR (0xFFFFFFFF) /* Non-specific error code for message control code field or function return values */ +#define JS_ERR_INVALID_SESSION (0xFFFFFFFE) /* Supplied session is not found in the Jetstream session list or is disconnected */ +#define JS_ERR_MESSAGE_ALLOCATION_FAILED (0xFFFFFFFD) /* An attempt to allocate a Jetstream message failed */ +#define JS_ERR_TRANSPORT_LIST_FAILURE (0xFFFFFFFC) /* The access controls for the registered transport list have failed */ +#define JS_ERR_TRANSPORT_NOT_FOUND (0xFFFFFFFB) /* The transport module that created the supplied session is no longer registered */ +#define JS_ERR_INTERNAL_FAILURE (0xFFFFFFFA) /* Internal failure that may prevent further Jetstream operation */ +#define JS_ERR_OPERATION_WILL_NOT_COMPLETE (0xFFFFFFF9) /* Requested operation will not complete, probably due to Jetstream shutdown in progress */ +#define JS_ERR_CONSUMER_NOT_FOUND (0xFFFFFFF8) /* The consumer identified in the request is not not registered */ + + +/* + The following macros define constant of type GUID_t used in Jetstream. + Due to limitations of the language it is not possible to use these + constants in assignments or in arguments. They may only be used as + initializers in declarations, e.g. the following example use is allowed: + + GUID_t pres_id = JS_PRESENTATION_LAYER_ID_INITIALIZER; + + SomeFunc(pres_id); + + + but the following example uses are not and will fail to compile: + + GUID_t pres_id; + + pres_id = JS_PRESENTATION_LAYER_ID_INITIALIZER; + SomeFunc(JS_PRESENTATION_LAYER_ID_INITIALIZER); + +*/ +#define JS_PRESENTATION_LAYER_ID_INITIALIZER {0x36662a8a, 0x9170, 0x11d3, 0xab, 0x89, {0x0, 0x8, 0xc7, 0xd3, 0xaf, 0x2d}} /* ID for the Jetstream internal consumer */ +#define JS_NO_MODULE_INITIALIZER {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0}} /* ID indicating no specific ID */ + + +/* New types */ +typedef struct JS_CommMsg_s /* A Jetstream message */ +{ + DQlink_t QueueLink; /* Doubly linked list node pointers */ + unicode_t * Session; /* Jetstream logical session the message is to be (was) transported with */ + GUID_t SourceModule; /* Source consumer's module ID */ + GUID_t TargetModule; /* Target consumer's module ID */ + SLONG ControlCode; /* Message control (positive) or error (negative) code */ + LONG BufferLength; /* The number of bytes available in MessageData */ + LONG MessageLength; /* The number of bytes in use in MessageData */ + void * MessageData; /* The message payload */ + union + { + void * Ptr1; + LONG Long1; + } OwnerData1; /* For consumer use */ + union + { + void * Ptr2; + LONG Long2; + } OwnerData2; /* For consumer use */ +} JS_CommMsg_s; + +typedef struct JS_NamedConnectReq_s +{ + GUID_t TransactionID; /* Transaction ID of this request */ + unicode_t Name[1]; /* First character of name, remainder of name extends beyond C structure */ +} JS_NAMED_CONN_REQ_t; + +typedef struct JS_TransportNamedConnectResp_s +{ + GUID_t TransactionID; /* Transaction ID of the original request */ + GUID_t TransportID; /* ID of the transport that resolved the name */ + BOOL Resolved; /* TRUE if this response indicates the name was resolved */ + LONG ConnectDataLen; /* Length of the following data */ + char ConnectData[1]; /* First byte of the physical connect request data, remainder of data extends beyond C structure */ +} JS_TRANSPORT_NAMED_CONN_RESP_t; + +typedef struct JS_PhysicalConnectReq_s +{ + GUID_t TransactionID; /* Transaction ID of the original request */ + LONG ConnectDataLen; /* Length of the following data */ + char ConnectData[1]; /* First byte of the physical connect request data, remainder of data extends beyond C structure */ +} JS_PHYSICAL_CONN_REQ_t; + +typedef struct JS_PhysicalConnectResp_s +{ + GUID_t TransactionID; /* Transaction ID of original connect request */ + BOOL Connected; /* TRUE if connection was made */ +} JS_PHYSICAL_CONN_RESP_t; + +typedef struct JS_ConsumerNamedConnectResp_s +{ + GUID_t TransactionID; /* Transaction ID of the original request */ + BOOL Connected; /* TRUE if connection was made */ +} JS_CONSUMER_NAMED_CONN_RESP_t; + +typedef struct JS_DisconnectRequest_s +{ + GUID_t TransactionID; /* Transaction ID of original request */ + void *TransportSession; /* Transport suppled session identity */ +} JS_DISCONNECT_REQ_t; + +typedef struct JS_DisconnectResponse_s +{ + GUID_t TransactionID; /* Transaction ID of original request */ + STATUS status; /* zOK if disconnected */ +} JS_DISCONNECT_RESP_t; + +typedef struct JS_ConnNameIsMsg_s +{ + GUID_t TransactionID; /* Transaction ID of original request */ + LONG NameLen; /* Length of connection name string in bytes (including any null terminator) */ + unicode_t ConnName[1]; /* Name of connection. NB: data extends beyond end of structure as defined */ +} JS_CONN_NAME_IS_t; + + +/* Function prototypes */ + +/* Module Registration */ +STATUS JS_RegisterConsumer(GUID_t ConsumerID, SEMAPHORE RxSignal); /* Register a Jetstream consumer */ +STATUS JS_DeregisterConsumer(GUID_t ModuleID, JS_CommMsg_s *ShutdownMessage); /* De-register a Jetstream consumer */ + +/* Connection management */ +unicode_t *JS_ConnectToHost(GUID_t OriginatorID, unicode_t *TargetHostName, GUID_t TransactionID, BOOL Asynchronous, BOOL MutualAuth, unicode_t *UserID, char *Password, LONG Timeout); + /* Connect to a named host */ +STATUS JS_DisconnectSession(GUID_t ConsumerID, unicode_t *Session, GUID_t TransactionID, BOOL Asynchronous); + /* Disconnect a session */ +/* Message Communication */ +JS_CommMsg_s *JS_DequeueMessage(GUID_t ModuleID); /* Used by a consumer to retrieve messages sent to it */ +STATUS JS_QueueMessage(GUID_t SourceModule, JS_CommMsg_s * Message, GUID_t TargetModule); /* Used by a consumer to transmit messages */ +STATUS JS_RequestReceiveEvent(GUID_t ModuleID); /* Used by a consumer to indicate it requires a semaphore signal when received data is available */ + +/* Dispatched session message communication */ +JS_CommMsg_s *JS_DequeueDispatchedMessage(GUID_t ModuleID, unicode_t *Session); /* Used by a consumer to receive messages for a particular session independently of messages for other sessions */ +STATUS JS_DispatchSession(GUID_t ModuleID, unicode_t *Session, SEMAPHORE RxSignal); /* Used by a consumer to indicate that messages received on the supplied session should be queued for the consumer independently of those for other sessions */ +STATUS JS_RequestDispatchedMessageReceiveEvent(GUID_t ModuleID, unicode_t *Session); /* Used by a consumer to indicate that it requires a semaphore to be signaled when received data is available on a particular session */ +STATUS JS_UndispatchSession(GUID_t ModuleID, unicode_t *Session, BOOL Discard); /* Used by Jetstream to stop receiveing messages for a particular session independently of those for other sessions */ + +/* Message Management */ +JS_CommMsg_s *JS_AllocateMessage(GUID_t ModuleID, size_t MessageSize, LONG MaxTimeToWait); /* Supply a free message on demand */ +STATUS JS_DuplicateMessage(JS_CommMsg_s *DestMsg, JS_CommMsg_s * SrcMsg); /* Copy one message to another */ +STATUS JS_GetDefaultMessageSizes(LONG *Sizes, LONG *Count); /* Get the list of message size allocations that Jetstream supports */ +STATUS JS_RetireMessage(GUID_t ModuleID, JS_CommMsg_s * Message); /* Free a reviously allocated message */ +STATUS JS_SetMessageSession(JS_CommMsg_s * Message, unicode_t * Session); /* Associate a message with a logical session */ + +#if zLINUX +extern SEMAPHORE kSemaphoreAlloc(BYTE *pSemaName, NINT SemaCount); +extern int kSemaphoreFree(SEMAPHORE SemaHandle); +extern int kSemaphoreWait(SEMAPHORE SemaHandle); +extern int kSemaphoreTimedWait(SEMAPHORE SemaHandle, NINT timeout); +extern int kSemaphoreSignal(SEMAPHORE SemaHandle); + +#define kSUCCESS 0 +#define ERROR_INVALID_SEMAPHORE -10 +#define ERROR_TIMEOUT -22 +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/nwnss/public/jsmsg.imp b/include/nwnss/public/jsmsg.imp new file mode 100644 index 0000000..65dcc11 --- /dev/null +++ b/include/nwnss/public/jsmsg.imp @@ -0,0 +1,25 @@ + JS_AllocateMessage + JS_Connect + JS_ConnectToHost + JS_DequeueDispatchedMessage + JS_DequeueMessage + JS_DeregisterConsumer + JS_DeregisterTransport + JS_Disconnect + JS_DisconnectSession + JS_DispatchSession + JS_DuplicateMessage + JS_FindLogicalSession + JS_GetTxMessage + JS_QueueMessage + JS_RegisterConsumer + JS_RegisterTransport + JS_RequestDispatchedMessageReceiveEvent + JS_RequestReceiveEvent + JS_RequestTransmitEvent + JS_RetireMessage + JS_RxMessage + JS_SetMessageSession + JS_UndispatchSession + JS_UpdateLogicalSessionState + JS_GetDefaultMessageSizes \ No newline at end of file diff --git a/include/nwnss/public/neb.h b/include/nwnss/public/neb.h index c18b4d5..e584c56 100644 --- a/include/nwnss/public/neb.h +++ b/include/nwnss/public/neb.h @@ -30,13 +30,9 @@ #ifndef _NEB_H_ #define _NEB_H_ -#if defined(NSS_USERSPACE) && !defined(NEB_STATUS) -#define NEB_STATUS LONG -#endif - #if defined(__linux__) && defined(__KERNEL__) #ifndef __NKEVENT_H__ -#include +#include #endif #else @@ -94,7 +90,7 @@ extern "C" { #define CHECK_CONSUMER 3 #define SYNCHRONOUS_CONSUMER 4 #define ASYNCHRONOUS_CONSUMER 5 -#define DEBUG_CONSUMER 6 +#define DEBUG_CONSUMER 6 #define RESERVED 7 /* Consumer Notify type codes */ diff --git a/include/nwnss/public/neb.imp b/include/nwnss/public/neb.imp new file mode 100644 index 0000000..df15fe3 --- /dev/null +++ b/include/nwnss/public/neb.imp @@ -0,0 +1,6 @@ +RegisterProducer +UnRegisterProducer +RegisterConsumer +UnRegisterConsumer +ProduceEvent +GetConsumerName diff --git a/include/nwnss/public/nfsLock.h b/include/nwnss/public/nfsLock.h index 21bca62..82c1679 100644 --- a/include/nwnss/public/nfsLock.h +++ b/include/nwnss/public/nfsLock.h @@ -47,11 +47,11 @@ # include #endif #ifndef _OMNI_H_ -# include +# include #endif #ifndef _NFSAPIS_H_ -# include +# include #endif #ifdef __cplusplus @@ -99,16 +99,16 @@ typedef struct NetObj_s } NetObj_s; -/* +/* * In the NLM version 3 protocol, the length and offset are 32 bits wide, while - * they are 64 bits wide in the NLM version 4 protocol. NLM version 3 should + * they are 64 bits wide in the NLM version 4 protocol. NLM version 3 should * cast them to 64 bits. */ typedef struct LkMgrLock_s { BYTE *callerName; /* NULL terminated byte string, case insensitive */ NFSHandle_s *fh; - NetObj_s *oh; + NetObj_s *oh; LONG svid; QUAD offset; QUAD len; @@ -201,7 +201,7 @@ STATUS LkMgrUnlock( STATUS LkMgrShare( BYTE *callerName, /* NULL terminated byte string */ NFSHandle_s *fh, - NetObj_s *oh, + NetObj_s *oh, FshMode_t mode, FshAccess_t access); @@ -212,7 +212,7 @@ STATUS LkMgrShare( STATUS LkMgrUnshare( BYTE *callerName, /* NULL terminated byte string */ NFSHandle_s *fh, - NetObj_s *oh, + NetObj_s *oh, FshMode_t mode, FshAccess_t access); diff --git a/include/nwnss/public/nssPubs.h b/include/nwnss/public/nssPubs.h index 44ceaf0..9ccf9d6 100644 --- a/include/nwnss/public/nssPubs.h +++ b/include/nwnss/public/nssPubs.h @@ -240,7 +240,7 @@ STATUS VIRT_AddResultCDataElement ( * Structures *-------------------------------------------------------------------------*/ -#if zNETWARE || (zLINUX && defined(__KERNEL__)) || defined(NSS_USERSPACE) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) typedef struct VisibilityEntry_s { UserID_t trusteeID; @@ -263,7 +263,7 @@ extern LONG GetVisibilityList( LONG volume, VisibilityEntry_s *trusteeVector, LONG *numTrustees); /** Specify the trusteeVector array size **/ - /** The returned value has the size with + /** The returned value has the size with ** data filled in.**/ @@ -274,10 +274,10 @@ extern LONG GetVisibilityList( * by newIDs. If callBack is non NULL and callBackFrequency is not * zero, the callBack routine is called after after every n files are * processed (n is the value specified by callbackFrequency) - * + * * If the callBack routine returns a non-zero value the function is - * aborted. This will result in a partial update of IDs and an - * inconsistent state. + * aborted. This will result in a partial update of IDs and an + * inconsistent state. * ************************************************************************/ extern LONG SwitchNSSTrusteeIDs ( diff --git a/include/nwnss/public/psa.imp b/include/nwnss/public/psa.imp new file mode 100644 index 0000000..5d260f1 --- /dev/null +++ b/include/nwnss/public/psa.imp @@ -0,0 +1,23 @@ +pAudit +pChdir +pChmod +pClose +pEndContext +pFstat +pGetcwd +pGetdirentries +pLink +pNewContext +pOpen +pRead +pRealName +pRename +pStat +pUnlink +pWrite +pClosedir +pMkdir +pOpendir +pReaddir +pRewinddir +pRmdir diff --git a/include/nwnss/public/psaPublic.h b/include/nwnss/public/psaPublic.h new file mode 100644 index 0000000..fdc2df5 --- /dev/null +++ b/include/nwnss/public/psaPublic.h @@ -0,0 +1,303 @@ +/**************************************************************************** + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: Posix Semantic Agent, PSA, Public Header File. + +-------------------------------------------------------------------------*/ +/*- + * Copyright (c) 1982, 1986, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)types.h 8.4 (Berkeley) 1/21/94 + * $Id: psaPublic.h 465 2004-12-30 19:40:58Z taysom $ + */ + +#ifndef _PSAPUBLIC_H_ +#define _PSAPUBLIC_H_ + +#ifndef _ZOMNI_H_ +#include +#endif + + +/* Ensure C++ compilers generate code with unmangled linkage */ +#ifdef __cplusplus +extern "C" { +#endif + + + +#ifndef _DEV_T +#define _DEV_T +typedef unsigned long dev_t; /* device number */ +#endif + +#ifndef _GID_T +#define _GID_T +typedef unsigned long gid_t; /* group id */ +#endif + +#ifndef _INO_T +#define _INO_T +typedef unsigned long ino_t; /* inode number */ +#endif + +#ifndef _MODE_T +#define _MODE_T +typedef unsigned short mode_t; /* permissions */ +#endif + +#ifndef _NLINK_T +#define _NLINK_T +typedef unsigned short nlink_t; /* link count */ +#endif + +#ifndef _OFF_T +#define _OFF_T +typedef SQUAD off_t; /* file offset */ +#endif + +#ifndef _SIZE_T +#define _SIZE_T +# ifndef _SIZE_T_DEFINED +# define _SIZE_T_DEFINED +# ifndef _SIZE_T_DEFINED_ +# define _SIZE_T_DEFINED_ + typedef LONG size_t; /* buffer sizes */ +# endif +# endif +#endif + +#ifndef _SSIZE_T +#define _SSIZE_T +typedef SLONG ssize_t; /* buffer size plus return codes */ +#endif + +#ifndef _UID_T +#define _UID_T +typedef unsigned long uid_t; /* user id */ +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef unsigned long time_t; /* time */ +#endif + +typedef LONG pTicket_t; +typedef LONG pContext_t; + +/* + * File status flags: these are used by open(2), fcntl(2). + */ +/* open-only flags */ +#define pO_RDONLY 0x0000 /* open for reading only */ +#define pO_WRONLY 0x0001 /* open for writing only */ +#define pO_RDWR 0x0002 /* open for reading and writing */ +#define pO_ACCMODE 0x0003 /* mask for above modes */ + +#define pO_NONBLOCK 0x0004 /* no delay */ +#define pO_APPEND 0x0008 /* set append mode */ +#define pO_SHLOCK 0x0010 /* open with shared file lock */ +#define pO_EXLOCK 0x0020 /* open with exclusive file lock */ +#define pO_CREAT 0x0200 /* create if nonexistant */ +#define pO_TRUNC 0x0400 /* truncate to zero length */ +#define pO_EXCL 0x0800 /* error if already exists */ + + +/* + * Structure defined by POSIX.4 to be like a timeval. + */ + +typedef struct pStat_s { + ino_t st_ino; /* inode's number */ + mode_t st_mode; /* inode protection mode */ + nlink_t st_nlink; /* number of hard links */ + uid_t st_uid; /* user ID of the file's owner */ + time_t st_atime; /* time of last access */ + time_t st_mtime; /* time of last data modification */ + time_t st_ctime; /* time of last file status change */ + off_t st_size; /* file size, in bytes */ + quad_t st_blocks; /* blocks allocated for file */ + unsigned long st_blksize; /* optimal blocksize for I/O */ +} pStat_s; + +#define pS_IFMT 0170000 /* type of file mask */ +#define pS_IFIFO 0010000 /* named pipe (fifo) */ +#define pS_IFCHR 0020000 /* character special */ +#define pS_IFDIR 0040000 /* directory */ +#define pS_IFBLK 0060000 /* block special */ +#define pS_IFREG 0100000 /* regular */ +#define pS_IFLNK 0120000 /* symbolic link */ +#define pS_IFSOCK 0140000 /* socket */ + +#define pUNIX_NAME_SPACE 0 /* Unix name space */ +#define pLONG_NAME_SPACE 1 /* NT name space */ + +extern STATUS pAudit(void); + +extern STATUS pNewContext( + long connection, + int nameSpace, + const char *volume, + pContext_t *pcontext); + +extern void pEndContext( + pContext_t context); + +extern STATUS pChdir( + pContext_t context, + const char *path); + +extern STATUS pChmod( + pContext_t context, + const char *path, + mode_t mode); + +extern STATUS pClose( + pTicket_t ticket); + +extern STATUS pFstat( + pTicket_t ticket, + pStat_s *sb); + +extern STATUS pGetcwd( + pContext_t context, + char *buf, + size_t bufSize); + +extern STATUS pLink( + pContext_t context, + const char *from, + const char *to); + +extern STATUS pOpen( + pContext_t context, + const char *path, + int flags, + mode_t mode, + pTicket_t *pticket); + +extern STATUS pRename( + pContext_t context, + const char *from, + const char *to); + +extern STATUS pRead( + pTicket_t ticket, + off_t offset, + void *buf, + size_t nbytes, + size_t *bytesRead); + +extern STATUS pRealName( + pContext_t context, + const char *path, + char *buf, + size_t bufSize); + +extern STATUS pStat( + pContext_t context, + const char *path, + pStat_s *sb); + +extern STATUS pUnlink( + pContext_t context, + const char *path); + +extern STATUS pWrite( + pTicket_t ticket, + off_t offset, + const void *buf, + size_t nbytes, + size_t *bytesWritten); + +/* + * Directory operations + */ + +#define pIFTODT(_mode) (((_mode) & pS_IFMT) >> 12) + +#define pDT_UNKNOWN 0 +#define pDT_FIFO pIFTODT(pS_IFIFO) +#define pDT_CHR pIFTODT(pS_IFCHR) +#define pDT_DIR pIFTODT(pS_IFDIR) +#define pDT_BLK pIFTODT(pS_IFBLK) +#define pDT_REG pIFTODT(pS_IFREG) +#define pDT_LNK pIFTODT(pS_IFLNK) +#define pDT_SOCK pIFTODT(pS_IFSOCK) +//#define DT_WHT pIFTODT(pS_IFWHT) + +typedef struct pDirent_s { + ino_t d_fileno; /* file number of entry */ + WORD d_type; /* file type, see below */ + WORD d_namlen; /* length of string in d_name */ +#define pMAXNAMLEN (3*255) /* Account for UTF-8 names */ + char d_name[pMAXNAMLEN + 1]; /* name must be no longer than this */ +} pDirent_s; + +extern STATUS pClosedir( + pTicket_t ticket); + +extern STATUS pMkdir( + pContext_t context, + const char *path, + mode_t mode); + +extern STATUS pOpendir( + pContext_t context, + const char *path, + pTicket_t *pticket); + +extern STATUS pReaddir( + pTicket_t ticket, + pDirent_s *dirent); + +extern STATUS pRewinddir( + pTicket_t ticket); + +extern STATUS pRmdir( + pContext_t context, + const char *path); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/include/nwnss/public/uneb.h b/include/nwnss/public/uneb.h new file mode 100644 index 0000000..08206f9 --- /dev/null +++ b/include/nwnss/public/uneb.h @@ -0,0 +1,175 @@ +/**************************************************************************** + | + | (C) Copyright 2004 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + +-------------------------------------------------------------------------*/ +#ifndef _UNEB_H_73456gehY7_34f +#define _UNEB_H_73456gehY7_34f + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef NEB_STATUS +#define NEB_STATUS LONG +#endif + +#define UNEB_MAX_EVENT_USER_NAME_LENGTH 256 +#define UNEB_MAX_EVENT_NAME_LENGTH 80 + +/* + * State to manage the client registration of events. + */ + +typedef struct consumerInfo { + char consumerName[UNEB_MAX_EVENT_USER_NAME_LENGTH]; + char eventName[UNEB_MAX_EVENT_NAME_LENGTH]; + void *consumerCookie; + unsigned long eventFlags; + NEB_STATUS (*callBack)(struct EventBlock *eventBlock); + unsigned long consumerFlags; + unsigned int consumerType; + unsigned int consumerOrder; +} consumerInfo_t; + + +/* + Defines the data that the library will pass to the kernel. + */ +typedef struct unebClientStatus_s { + NEB_STATUS UCS_NEBStatus; + void *UCS_NEBParm0; + void *UCS_NEBParm1; +} unebClientStatus_s; + + +/* + * int userNebDeveloper( int flag ); + * + * Enables debug messages to be displayed on stderr. To turn on pass in true (non-zero). + * To disable pass in false(0). By default, debug messages are off. + * + * Debug messages are enabled/disabled on a process level. + * + * Returns previous setting. + */ +int userNebDeveloper( int flag ); + +/* + * NEB_STATUS userNebRegisterConsumer(struct ConsumerRegistrationInfo *regInfo) + * + * Register the caller as a consumer based on the specified registration. + * The semantics of this call are described in the NEB manual pages: + * refer to the documentation for RegisterConsumer(). + * + * While we support the NEB specified consumer registration information + * structure, we impose a number of restrictions for user mode NEB: + * + * ACCESS_CONTROL_CHECK_BIT flag cannot be set in CRIConsumerFlags. + * + * CRIConsumerESR() and CRIConsumerCallback() should point to the same function + * and should be non-NULL. + * + * The field CRIOwnerID will be ignored. + * + * Filters are not supported: The fields CRIFilterName, CRIFilterDataLength + * and CRIFilterData will be ignored. CRIFilterName and CRIFilterData must + * be NULL and CRIFilterDataLength must be 0. + * + * The field CRISecurityToken must be set NULL. + * + * + * Calling/Exit State: + * The function may block. + */ + +NEB_STATUS userNebRegisterConsumer(struct ConsumerRegistrationInfo *regInfo); + + +/* + * int userNebUnRegisterConsumer(void *consumerID, void *userParameter) + * + * Unregister the consumer for the specified event. + * + * Calling/Exit State: + * The function may block. + */ + +int +userNebUnRegisterConsumer(void *consumerID, void *userParameter); + + +/* + * Name of the UNEB device. + */ + +#define UNEB_SERV_NAME "/dev/userModeNebDrv" + + +/* + * Marshalling format + */ +typedef struct NEBMarshallInfo_s +{ + int NMI_SizeOf; /* size of info (for possible variable sizes). */ + int NMI_NumberOfOffsets; /* Number of offsets that need to be fixed up. */ + int NMI_Offsets[2]; /* Offsets that need to be fixed up. Kernel and user space can decide + * what these are relative to. + */ +} NEBMarshallInfo_s; + + +/* + * IOCTL for the user neb device. + */ + +/* + * IOCTL for the MPK RPC module + */ + +#define UNEBDRV_IOCTL_MAGIC 0xa8 + +#define UNEBDRV_IOCTL_GET_EVENT \ + _IOWR(UNEBDRV_IOCTL_MAGIC, 1, char *) + +#define UNEBDRV_IOCTL_REGISTER_CONSUMER \ + _IOWR(UNEBDRV_IOCTL_MAGIC, 2, char *) + +#define UNEBDRV_IOCTL_UNREGISTER_CONSUMER \ + _IOWR(UNEBDRV_IOCTL_MAGIC, 3, char *) + +#define UNEBDRV_IOCTL_REPORT_STATUS \ + _IOWR(UNEBDRV_IOCTL_MAGIC, 4, int) + +#define UNEBDRV_IOCTL_MAXNR 4 + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _UNEB_H_73456gehY7_34f + diff --git a/include/nwnss/public/virtualIO.imp b/include/nwnss/public/virtualIO.imp new file mode 100644 index 0000000..8b7d8aa --- /dev/null +++ b/include/nwnss/public/virtualIO.imp @@ -0,0 +1,21 @@ +MGMT_CopyToWorkingBuffer +MGMT_FindFirstElement +MGMT_MakeCommandVirtualFile +MGMT_MakeCommandVirtualFileWithHelp +MGMT_MakeFunctionVirtualFile +MGMT_ReturnError +VIRT_AddResultData +VIRT_AddResultElement +VIRT_AddResultTag +VIRT_MakeDataTypeDataStream +VIRT_MakeReadWriteFuncDataStream +VIRT_MakeResultsImportant +VIRT_MakeResultsNormal +VIRT_ResetResult +XML_BackwardFindEndTag +XML_FindEndOfElement +XML_findEndOfNonWhiteSpace +XML_GetNextTag +XML_GetTagAttribute +XML_GetTagElement +XML_skipWhiteSpace \ No newline at end of file diff --git a/include/nwnss/public/xmlTags.h b/include/nwnss/public/xmlTags.h index d5f5086..416626f 100644 --- a/include/nwnss/public/xmlTags.h +++ b/include/nwnss/public/xmlTags.h @@ -501,7 +501,7 @@ #define TAG_JUNCTIONNAME "junctionName" #define TAG_JUNCTIONPATH "junctionPath" #define TAG_LABEL "label" -#define TAG_LASTCOMPRATIO "lastCompressionRatio" +#define TAG_LASTCOMPRATIO "lastCompressionRatio" #define TAG_LASTNAMEUNIQUIFIER "lastNameUniquifier" #define TAG_LASTSTATUS "lastStatus" #define TAG_LASTSTATUSSETTER "lastStatusSetter" diff --git a/include/nwnss/public/zError.h b/include/nwnss/public/zError.h index c23b9eb..ffb0f97 100644 --- a/include/nwnss/public/zError.h +++ b/include/nwnss/public/zError.h @@ -45,8 +45,8 @@ extern "C" { /*------------------------------------------------------------------------- * Defined error range for NSS *-------------------------------------------------------------------------*/ -#define ERR_NSS_FIRST_ERROR 20000 -#define ERR_NSS_LAST_ERROR 24999 +#define ERR_NSS_FIRST_ERROR 20000 +#define ERR_NSS_LAST_ERROR 24999 /*========================================================================= @@ -252,7 +252,7 @@ extern "C" { #define zERR_INVALID_DATA_STREAM 20550 /* the data stream is invalid */ #define zERR_CANT_MOD_DATA_STREAM_METADATA 20551 /* data stream's metadata may not be modified */ -/* Semantic Agent handle errors */ +/* Semantic Agent handle errors */ #define zERR_INVALID_SA_HANDLE 20601 /* invalid semantic agent handle */ #define zERR_SA_HANDLE_TOO_SMALL 20602 /* An attempt was made to allocate an SA Handle that was too small */ @@ -264,8 +264,8 @@ extern "C" { /* DFS/DIO (Direct FS I/O) errors */ #define zERR_FILE_NOT_IN_DIO_MODE 20650 /* file was not switched to DIO mode */ -#define zERR_HOLE_IN_DIO_FILE 20651 /* DIO files cannot have holes*/ -#define zERR_BEYOND_EOF 20652 /* DIO files cannot be read beyond EOF*/ +#define zERR_HOLE_IN_DIO_FILE 20651 /* DIO files cannot have holes*/ +#define zERR_BEYOND_EOF 20652 /* DIO files cannot be read beyond EOF*/ #define zERR_FILE_IN_DIO_MODE 20653 /* DIO file is in DIO mode*/ #define zERR_FILE_DETACHED 20654 /* DIO file is in DIO mode*/ #define zERR_DIO_BAD_PARAMETER 20655 /* DIO bad parameter(unit count is zero) */ @@ -285,8 +285,8 @@ extern "C" { /* volume and pool errors */ #define zERR_NICI_SUPPORT 20798 /* Encrypted volume support libraries returned an error */ #define zERR_INVALID_VOLUME_PASSWORD 20799 /* password supplied for encrypted volume use is invalid */ -#define zERR_BAD_VOLUME_NAME 20800 /* the given volume name is syntactically incorrect */ -#define zERR_VOLUME_NOT_FOUND 20801 /* the given volume name could not be found */ +#define zERR_BAD_VOLUME_NAME 20800 /* the given volume name is syntactically incorrect */ +#define zERR_VOLUME_NOT_FOUND 20801 /* the given volume name could not be found */ #define zERR_DEACTIVATING_ADMINVOL 20802 /* can not deactivate the NSS_ADMIN volume */ #define zERR_VOLUME_STATE_CHANGE_ABORTED 20803 /* had to abort the volume state change */ #define zERR_DATA_MIGRATION_NOT_ENABLED 20804 /* NSS does not support data migration */ @@ -301,7 +301,7 @@ extern "C" { #define zERR_VOLUME_SCHEDULED_FOR_MAINT 20809 /* The volume is already scheduled for MAINTANENCE */ #define zERR_VOLUME_SHOULD_NOT_ACTIVATE 20810 /* Volume should not be activated (LSS can return if corrupt or rebuilding) */ #define zERR_VOLUME_NOT_IN_ACTIVE_STATE 20811 /* the given volume is not in ACTIVE state */ -#define zERR_POOL_NOT_FOUND 20812 /* the given pool name could not be found */ +#define zERR_POOL_NOT_FOUND 20812 /* the given pool name could not be found */ #define zERR_POOL_STATE_INCOMPATIBLE 20813 /* A Volume change STATE has failed becuase the volume's pool is * not in a compatible state. For example, if a pool is DEACTIVE * and the volume wants to be ACTIVE this error would be returned. @@ -353,7 +353,7 @@ extern "C" { * within the MAL. */ #define zERR_VOLUME_IS_DEACTIVE 20838 /* Operation could not be completed because the volume is deactive */ #define zERR_POOL_IS_DEACTIVE 20839 /* Operation could not be completed because the pool is deactive */ - + /** DSI and adding volume to NDS errors **/ #define zERR_IMPORT_DSI_SYMBOL_FAILED 20840 @@ -368,7 +368,7 @@ extern "C" { #define zERR_VOL_UNAVAILABLE 20849 /* Authorization errors */ -#define zERR_NO_SET_PRIVILEGE 20850 /* does not have rights to modify metadata */ +#define zERR_NO_SET_PRIVILEGE 20850 /* does not have rights to modify metadata */ #define zERR_NO_CREATE_PRIVILEGE 20851 /* does not have rights to create an object */ #define zERR_INVALID_AUTHORIZE_SPACE 20852 /* bad authorization space */ #define zERR_INVALID_AUTHORIZE_MODEL 20853 /* bad authorization model */ @@ -422,7 +422,7 @@ extern "C" { /* Locking-related Errors */ #define zERR_IOLOCK_ERROR 20900 /* tried to do read/write on a locked range of a file */ -#define zERR_LOCK_ERROR 20901 /* general lock error */ +#define zERR_LOCK_ERROR 20901 /* general lock error */ #define zERR_LOCK_COLLISION 20902 /* tried to lock a range that was already locked */ #define zERR_LOCK_WAITING 20903 /* timed out waiting for a lock */ #define zERR_NONEXISTENT_LOCK 20904 /* tried to release a lock that doesn't exist */ @@ -635,7 +635,7 @@ extern "C" { /* Event Log Errors */ #define zERR_EFL_ILLEGAL_STATE 21900 /* The state of an event log entry is illegal */ #define zERR_EFL_NO_EPOCH_AVAILABLE 21901 /* EFL tree doesn't have unused epoch available */ -#define zERR_EFL_EPOCH_NOT_FOUND 21902 /* EFL epoch is not found in the eTree */ +#define zERR_EFL_EPOCH_NOT_FOUND 21902 /* EFL epoch is not found in the eTree */ #define zERR_EFL_NO_LOG_HEADER 21903 /* The header block for the EFL log is not found */ #define zERR_EFL_NO_LOG_HEADER_READ_ERROR 21904 /* The header block for the EFL log cannot be read */ #define zERR_EFL_BAD_LOG 21905 /* Unable to find the EFL log */ @@ -773,7 +773,7 @@ extern "C" { #define zERR_CANNOT_UNMOUNT_VOLUME 22702 /* The volume cannot be unmounted */ #define zERR_CANNOT_MOUNT_VOLUME 22703 /* The volume cannot be mounted */ #define zERR_VOLUME_NOT_MOUNTED 22704 /* The volume is not mounted */ - + /*========================================================================= * NSS Java interface reserved error codes (Range 22900-22999) *=========================================================================*/ @@ -835,7 +835,7 @@ extern "C" { #define zERR_NO_NODE 24800 /* No node at the requested block location. */ #define zERR_BAD_LOG_RECORD 24801 /* bad log record found */ #define zERR_BEAST_TOO_BIG 24802 /* the beast is too big to fit in the b-tree */ -#define zERR_TREE_LEAF_CORRUPT 24803 /* Returned when the free size stored in a B-Tree +#define zERR_TREE_LEAF_CORRUPT 24803 /* Returned when the free size stored in a B-Tree * does not agree with the size of all the * free chunks in the leaf. */ @@ -848,19 +848,19 @@ extern "C" { #define zERR_ZLOG_BAD_RECORD_COUNT 24823 /* ZLOG file's log block log record count is invalid */ #define zERR_ZLOG_BAD_RECORD_SIZE 24824 /* ZLOG file's record size is invalid */ #define zERR_ZLOG_BAD_LSN 24825 /* ZLOG file's log record LSN is invalid */ -#define zERR_ZLOG_FILE_INIT_FAILED 24826 /* ZLOG could not create ZLOG file during POOL initialize */ +#define zERR_ZLOG_FILE_INIT_FAILED 24826 /* ZLOG could not create ZLOG file during POOL initialize */ #define zERR_ZLOG_BAD_BEAST_SIGNATURE 24827 /* ZLOG beast's signature is invalid */ -#define zERR_ZLOG_UNSUPPORTED_BEAST_VERSION 24828 /* ZLOG code does not support ZLOG Beast version in persistent storage */ +#define zERR_ZLOG_UNSUPPORTED_BEAST_VERSION 24828 /* ZLOG code does not support ZLOG Beast version in persistent storage */ #define zERR_ZLOG_UNSUPPORTED_FILE_VERSION 24829 /* ZLOG code does not support ZLOG File version * in persistent storage. If user does a clean * shutdown with previos nss.nlm then this error * will go away. Otherwise, a reset is required. - */ + */ #define zERR_ZLOG_FILE_FULL 24830 /* ZLOG file is full - file too small for transaction rate */ #define zERR_ZLOG_NO_MORE_RECORDS 24831 /* No more ZLOG recovery information (Not a USER error) */ /* ZVL Errors (ZLSS Volume Locator) */ -#define zERR_ZVL_UNSUPPORTED_BEAST_VERSION 24838 /* ZLSS Volume Locator code does not support ZVL Beast version in persistent storage */ +#define zERR_ZVL_UNSUPPORTED_BEAST_VERSION 24838 /* ZLSS Volume Locator code does not support ZVL Beast version in persistent storage */ #define zERR_ZVL_BAD_BEAST_SIGNATURE 24839 /* ZLSS Volume Locator(ZVL) beast's signature is invalid */ /* ZFSVOL/ZLSSPOOL volume data Errors */ @@ -880,15 +880,15 @@ extern "C" { #define zERR_CHECKPOINT_BAD_CHECKSUM 24850 /* Checkpoint checksum error */ #define zERR_CHECKPOINT_BAD_BLOCK_SIGNATURE 24851 /* Checkpoint block signature is invalid */ #define zERR_CHECKPOINT_BAD_BLOCK_SIZE 24852 /* Checkpoint block size is invalid */ -#define zERR_CHECKPOINT_UNSUPPORTED_VERSION 24853 /* Checkpoint code does not support version in checkpoint */ +#define zERR_CHECKPOINT_UNSUPPORTED_VERSION 24853 /* Checkpoint code does not support version in checkpoint */ /* Superblock Errors */ #define zERR_SUPERBLOCK_BAD_CHECKSUM 24860 /* Superblock checksum error */ #define zERR_SUPERBLOCK_BAD_BLOCK_SIGNATURE 24861 /* Superblock block signature is invalid */ #define zERR_SUPERBLOCK_BAD_BLOCK_SIZE 24862 /* Superblock block size is invalid */ -#define zERR_SUPERBLOCK_UNSUPPORTED_VERSION 24863 /* Superblock code does not support version in superblock header */ -#define zERR_SUPERBLOCK_UNSUPPORTED_MEDIA 24864 /* Media version not supported */ -#define zERR_SUPERBLOCK_MISMATCH 24865 /* Two or more valid superblock headers do not match each other */ +#define zERR_SUPERBLOCK_UNSUPPORTED_VERSION 24863 /* Superblock code does not support version in superblock header */ +#define zERR_SUPERBLOCK_UNSUPPORTED_MEDIA 24864 /* Media version not supported */ +#define zERR_SUPERBLOCK_MISMATCH 24865 /* Two or more valid superblock headers do not match each other */ #define zERR_SUPERBLOCK_UNDESIRED_LOCATION 24866 /* A super block is not in desired mathamatical location */ #define zERR_SUPERBLOCK_NOT_ENOUGH 24867 /* Not enough valid super block headers */ #define zERR_SUPERBLOCK_CORRUPTED 24868 /* Valid super block header has bad information in it */ diff --git a/include/nwnss/public/zEvent.h b/include/nwnss/public/zEvent.h index ab06e71..c3294a2 100644 --- a/include/nwnss/public/zEvent.h +++ b/include/nwnss/public/zEvent.h @@ -37,10 +37,10 @@ #ifndef _ZEVENT_H_ #define _ZEVENT_H_ -//#include +//#include #ifndef _ZPARAMS_H_ -# include +# include #endif #ifdef __cplusplus @@ -51,16 +51,16 @@ extern "C" { /* "NSS.StartupCompleted" */ -/* "NSS.Delete.Enter" */ -/* "NSS.Delete.Exit" */ -/* "NSS.Create.Enter" */ -/* "NSS.Create.Exit" */ -/* "NSS.Open.Enter" */ -/* "NSS.Open.Exit" */ -/* "NSS.Close.Enter" */ -/* "NSS.Close.Exit" */ -/* "NSS.Rename.Enter" */ -/* "NSS.Rename.Exit" */ +/* "NSS.Delete.Enter" */ +/* "NSS.Delete.Exit" */ +/* "NSS.Create.Enter" */ +/* "NSS.Create.Exit" */ +/* "NSS.Open.Enter" */ +/* "NSS.Open.Exit" */ +/* "NSS.Close.Enter" */ +/* "NSS.Close.Exit" */ +/* "NSS.Rename.Enter" */ +/* "NSS.Rename.Exit" */ /* "NSS.ModifyInfo.Enter" */ /* "NSS.ModifyInfo.Exit" */ /* "NSS.SetDataSize.Enter" */ @@ -77,25 +77,25 @@ extern "C" { /* "NSS.Link.Exit" */ /* "NSS.ChangePoolState.Enter" */ /* "NSS.ChangePoolState.Exit" */ -/* "NSS.PoolCreate.Enter" */ -/* "NSS.PoolCreate.Exit" */ -/* "NSS.PoolDelete.Enter" */ -/* "NSS.PoolDelete.Exit" */ -/* "NSS.PoolResize.Enter" */ -/* "NSS.PoolResize.Exit" */ -/* "NSS.PoolRename.Enter" */ -/* "NSS.PoolRename.Exit" */ +/* "NSS.PoolCreate.Enter" */ +/* "NSS.PoolCreate.Exit" */ +/* "NSS.PoolDelete.Enter" */ +/* "NSS.PoolDelete.Exit" */ +/* "NSS.PoolResize.Enter" */ +/* "NSS.PoolResize.Exit" */ +/* "NSS.PoolRename.Enter" */ +/* "NSS.PoolRename.Exit" */ /* "NSS.ChangePoolShared.Enter" */ -/* "NSS.ChangePoolShared.Exit" */ +/* "NSS.ChangePoolShared.Exit" */ /* "NSS.LVolumeCreate.Enter" */ -/* "NSS.LVolumeCreate.Exit" */ +/* "NSS.LVolumeCreate.Exit" */ /* "NSS.LVolumeDelete.Enter" */ -/* "NSS.LVolumeDelete.Exit" */ +/* "NSS.LVolumeDelete.Exit" */ /* "NSS.LVolumeRename.Enter" */ -/* "NSS.LVolumeRename.Exit" */ +/* "NSS.LVolumeRename.Exit" */ /* "NSS.LVolumeSalvage.Enter" */ /* "NSS.LVolumeSalvage.Exit" */ -/* "NSS.LVolumePurge.Enter" */ +/* "NSS.LVolumePurge.Enter" */ /* "NSS.LVolumePurge.Exit" */ /* "NSS.LVolumeSnapshot.Enter" */ /* "NSS.LVolumeSnapshot.Exit" */ @@ -111,211 +111,211 @@ typedef struct TimeInfo_s Time_t accessedTime; /* Last time file was accessed*/ Time_t createdTime; /* Time file was created */ Time_t modifiedTime; /* Last time data was changed */ - Time_t metaDataModifiedTime; /* Last time metadata was changed. */ + Time_t metaDataModifiedTime; /* Last time metadata was changed. */ } TimeInfo_s; typedef struct EventDeleteEnter_s { - NINT enterExitID; - NINT connID; - NINT taskID; + NINT enterExitID; + NINT connID; + NINT taskID; Zid_t zid; VolumeID_t volID; } EventDeleteEnter_s; typedef struct EventDeleteExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; } EventDeleteExit_s; typedef struct EventCreateEnter_s { - NINT enterExitID; - NINT connID; - NINT taskID; + NINT enterExitID; + NINT connID; + NINT taskID; Zid_t zid; VolumeID_t volID; - unicode_t *name; - NINT fileType; - NINT fileAttributes; - NINT createFlags; - void *createParms; - NINT requestedRights; - NINT createAndOpen; + unicode_t *name; + NINT fileType; + NINT fileAttributes; + NINT createFlags; + void *createParms; + NINT requestedRights; + NINT createAndOpen; } EventCreateEnter_s; typedef struct EventCreateExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - NINT retOpenCreateAction; - Key_t retKey; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + NINT retOpenCreateAction; + Key_t retKey; Zid_t retZid; VolumeID_t retVolID; - TimeInfo_s times; + TimeInfo_s times; } EventCreateExit_s; typedef struct EventOpenEnter_s { - NINT enterExitID; - NINT connID; - NINT taskID; + NINT enterExitID; + NINT connID; + NINT taskID; Zid_t zid; VolumeID_t volID; - NINT requestedRights; - void *openParms; + NINT requestedRights; + void *openParms; } EventOpenEnter_s; typedef struct EventOpenExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - Key_t retKey; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + Key_t retKey; Zid_t retZid; VolumeID_t retVolID; - TimeInfo_s times; + TimeInfo_s times; } EventOpenExit_s; typedef struct EventCloseEnter_s { - NINT enterExitID; - NINT connID; - Key_t key; - NINT fhState; - TimeInfo_s times; + NINT enterExitID; + NINT connID; + Key_t key; + NINT fhState; + TimeInfo_s times; } EventCloseEnter_s; typedef struct EventCloseExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - NINT fileDeleted; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + NINT fileDeleted; } EventCloseExit_s; typedef struct EventRenameEnter_s { - NINT enterExitID; - NINT connID; - NINT taskID; + NINT enterExitID; + NINT connID; + NINT taskID; Zid_t srcZid; VolumeID_t srcVolID; Zid_t dstZid; - unicode_t *dstName; - NINT renameFlags; + unicode_t *dstName; + NINT renameFlags; } EventRenameEnter_s; typedef struct EventRenameExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; } EventRenameExit_s; typedef struct EventModifyInfoEnter_s { - NINT enterExitID; - NINT connID; - NINT taskID; + NINT enterExitID; + NINT connID; + NINT taskID; Zid_t zid; VolumeID_t volID; - NINT modifyInfoMask; - NINT modifyTypeInfoMask; - zInfo_s *modifyInfo; - void *modifyTypeInfo; + NINT modifyInfoMask; + NINT modifyTypeInfoMask; + zInfo_s *modifyInfo; + void *modifyTypeInfo; } EventModifyInfoEnter_s; typedef struct EventModifyInfoExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; } EventModifyInfoExit_s; typedef struct EventSetDataSizeEnter_s { - NINT enterExitID; - NINT connID; - Key_t key; - QUAD curEOF; - QUAD newEOF; - NINT setSizeFlags; + NINT enterExitID; + NINT connID; + Key_t key; + QUAD curEOF; + QUAD newEOF; + NINT setSizeFlags; } EventSetDataSizeEnter_s; typedef struct EventSetDataSizeExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - QUAD newEOF; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + QUAD newEOF; } EventSetDataSizeExit_s; typedef struct EventAddTrusteeEnter_s { - NINT enterExitID; - NINT connID; - NINT taskID; + NINT enterExitID; + NINT connID; + NINT taskID; Zid_t zid; VolumeID_t volID; - UserID_t trusteeID; - NINT rights; - NINT attributes; + UserID_t trusteeID; + NINT rights; + NINT attributes; } EventAddTrusteeEnter_s; typedef struct EventAddTrusteeExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; } EventAddTrusteeExit_s; typedef struct EventRemoveTrusteeEnter_s { - NINT enterExitID; - NINT connID; - NINT taskID; + NINT enterExitID; + NINT connID; + NINT taskID; Zid_t zid; VolumeID_t volID; - UserID_t trusteeID; - NINT purgedFileFlag; + UserID_t trusteeID; + NINT purgedFileFlag; } EventRemoveTrusteeEnter_s; typedef struct EventRemoveTrusteeExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; } EventRemoveTrusteeExit_s; typedef struct EventSetInheritedRightsEnter_s { - NINT enterExitID; - NINT connID; - NINT taskID; + NINT enterExitID; + NINT connID; + NINT taskID; Zid_t zid; VolumeID_t volID; - NINT inheritedRights; - BOOL authorizeFlag; + NINT inheritedRights; + BOOL authorizeFlag; } EventSetInheritedRightsEnter_s; typedef struct EventSetInheritedRightsExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; } EventSetInheritedRightsExit_s; typedef struct EventChangeVolStateEnter_s { - NINT enterExitID; - WORD oldState; - WORD newState; - NINT mode; + NINT enterExitID; + WORD oldState; + WORD newState; + NINT mode; #define zVOLMODE_MUST_SUCCEED 0x2000 /* If set, event must not be failed by check consumers. */ #define zVOLMODE_ATTRIBUTE_CHANGE 0x8000 /* If set, then event was generated to inform that some * attributes changed. The 'oldState' will ALWAYS equal @@ -328,12 +328,12 @@ typedef struct EventChangeVolStateEnter_s typedef struct EventChangeVolStateExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - WORD oldState; - WORD newState; - NINT mode; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + WORD oldState; + WORD newState; + NINT mode; VolumeID_t volID; VolumeID_t poolID; } EventChangeVolStateExit_s; @@ -341,97 +341,97 @@ typedef struct EventChangeVolStateExit_s typedef struct EventLinkEnter_s { - NINT enterExitID; - NINT connID; - NINT taskID; + NINT enterExitID; + NINT connID; + NINT taskID; Zid_t srcZid; VolumeID_t srcVolID; Zid_t dstZid; VolumeID_t dstVolID; - unicode_t *dstName; - NINT linkFlags; + unicode_t *dstName; + NINT linkFlags; } EventLinkEnter_s; typedef struct EventLinkExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; } EventLinkExit_s; typedef struct EventChangePoolStateEnter_s { - NINT enterExitID; - WORD oldState; - WORD newState; - NINT mode; + NINT enterExitID; + WORD oldState; + WORD newState; + NINT mode; VolumeID_t poolID; } EventChangePoolStateEnter_s; typedef struct EventChangePoolStateExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - WORD oldState; - WORD newState; - NINT mode; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + WORD oldState; + WORD newState; + NINT mode; VolumeID_t poolID; } EventChangePoolStateExit_s; typedef struct EventPoolCreateEnter_s { - NINT enterExitID; - unicode_t *poolName; + NINT enterExitID; + unicode_t *poolName; BOOL shared; } EventPoolCreateEnter_s; typedef struct EventPoolCreateExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - unicode_t *poolName; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + unicode_t *poolName; VolumeID_t poolID; BOOL shared; } EventPoolCreateExit_s; typedef struct EventPoolDeleteEnter_s { - NINT enterExitID; - unicode_t *poolName; + NINT enterExitID; + unicode_t *poolName; VolumeID_t poolID; BOOL shared; } EventPoolDeleteEnter_s; typedef struct EventPoolDeleteExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - unicode_t *poolName; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + unicode_t *poolName; VolumeID_t poolID; BOOL shared; } EventPoolDeleteExit_s; typedef struct EventPoolFreeze_s { - NINT enterExitID; /* Id to match paired 'freeze' and 'thaw' + NINT enterExitID; /* Id to match paired 'freeze' and 'thaw' * events. */ - unicode_t *poolName; + unicode_t *poolName; VolumeID_t poolID; BOOL shared; /* True if a clustered pool */ NINT timeOutSeconds; /* Number of seconds that freeze must complete in */ void *key; /* Key to pass to PoolNotify and PoolNotifyQueistRequired */ - STATUS (*poolEventReceived)( + STATUS (*poolEventReceived)( void *key, void *nebConsumerId ); /* Function to call right when you recieve a * freeze event. Must be called once and only * once for each 'Freeze' event. */ - STATUS (*poolNotifyQuiescent)( + STATUS (*poolNotifyQuiescent)( void *key, void *nebConsumerId, STATUS completionCode, @@ -442,20 +442,20 @@ typedef struct EventPoolFreeze_s * once and only once for each 'Freeze' * event. */ - STATUS (*poolNotifyQuiescentRequired)( + STATUS (*poolNotifyQuiescentRequired)( void *key, void *nebConsumerId ); - /* Use this function if your application takes - * a while (more than a second) to Quiescent its - * data. When this function returns non-zero - * your application must stop its quiescent - * attempt and call poolNotifyQuiescent. + /* Use this function if your application takes + * a while (more than a second) to Quiescent its + * data. When this function returns non-zero + * your application must stop its quiescent + * attempt and call poolNotifyQuiescent. * In this case call poolNotifyQuiescent with the * return code from poolNotifyQuiescentRequired as * 'completionCode'. * - * This function should be called at least 2 times - * a second between the app recieving a freeze EVENT + * This function should be called at least 2 times + * a second between the app recieving a freeze EVENT * and the apps call to poolNotifyQuiescent. * Once poolNotifyQuiescent is called you MUST * not call PoolNotifyRequired again. @@ -469,11 +469,11 @@ typedef struct EventPoolFreeze_s typedef struct EventPoolThaw_s { - NINT enterExitID; /* Id to match paired 'freeze' and 'thaw' + NINT enterExitID; /* Id to match paired 'freeze' and 'thaw' * events. */ - STATUS opRetCode; /* Return code from the caller of zPoolFreeze. */ - unicode_t *poolName; + STATUS opRetCode; /* Return code from the caller of zPoolFreeze. */ + unicode_t *poolName; VolumeID_t poolID; BOOL shared; /* True if a clustered pool */ void *key; @@ -481,8 +481,8 @@ typedef struct EventPoolThaw_s typedef struct EventPoolResizeEnter_s { - NINT enterExitID; - unicode_t *poolName; + NINT enterExitID; + unicode_t *poolName; VolumeID_t poolID; BOOL shared; QUAD addSectors; @@ -490,10 +490,10 @@ typedef struct EventPoolResizeEnter_s typedef struct EventPoolResizeExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - unicode_t *poolName; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + unicode_t *poolName; VolumeID_t poolID; BOOL shared; QUAD newSizeInSectors; @@ -501,56 +501,56 @@ typedef struct EventPoolResizeExit_s typedef struct EventPoolRenameEnter_s { - NINT enterExitID; - unicode_t *oldName; - unicode_t *newName; + NINT enterExitID; + unicode_t *oldName; + unicode_t *newName; VolumeID_t poolID; BOOL shared; } EventPoolRenameEnter_s; typedef struct EventPoolRenameExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - unicode_t *oldName; - unicode_t *newName; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + unicode_t *oldName; + unicode_t *newName; VolumeID_t poolID; BOOL shared; } EventPoolRenameExit_s; typedef struct EventChangePoolSharedEnter_s { - NINT enterExitID; - unicode_t *poolName; + NINT enterExitID; + unicode_t *poolName; VolumeID_t poolID; BOOL shared; /* TRUE if shared state is requested */ } EventChangePoolSharedEnter_s; typedef struct EventChangePoolSharedExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - unicode_t *poolName; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + unicode_t *poolName; VolumeID_t poolID; BOOL shared; /* Final state of shared */ } EventChangePoolSharedExit_s; typedef struct EventLVolCreateEnter_s { - NINT enterExitID; - unicode_t *volName; + NINT enterExitID; + unicode_t *volName; QUAD volSize; VolumeID_t poolID; } EventLVolCreateEnter_s; typedef struct EventLVolCreateExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - unicode_t *volName; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + unicode_t *volName; VolumeID_t volID; QUAD volSize; VolumeID_t poolID; @@ -558,17 +558,17 @@ typedef struct EventLVolCreateExit_s typedef struct EventLVolDeleteEnter_s { - NINT enterExitID; - unicode_t *volName; + NINT enterExitID; + unicode_t *volName; VolumeID_t volID; VolumeID_t poolID; } EventLVolDeleteEnter_s; typedef struct EventLVolDeleteExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; VolumeID_t oldVolID; /* Note: During delete vol may get a new GUID */ VolumeID_t newVolID; VolumeID_t poolID; @@ -576,19 +576,19 @@ typedef struct EventLVolDeleteExit_s typedef struct EventLVolRenameEnter_s { - NINT enterExitID; - unicode_t *oldName; - unicode_t *newName; + NINT enterExitID; + unicode_t *oldName; + unicode_t *newName; VolumeID_t volID; VolumeID_t poolID; } EventLVolRenameEnter_s; typedef struct EventLVolRenameExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - unicode_t *volName; /* final name (new or old based on + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + unicode_t *volName; /* final name (new or old based on * if rename was successful) */ VolumeID_t volID; VolumeID_t poolID; @@ -596,50 +596,50 @@ typedef struct EventLVolRenameExit_s typedef struct EventLVolSalvageEnter_s { - NINT enterExitID; - unicode_t *volName; + NINT enterExitID; + unicode_t *volName; VolumeID_t volID; VolumeID_t poolID; } EventLVolSalvageEnter_s; typedef struct EventLVolSalvageExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - unicode_t *volName; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + unicode_t *volName; VolumeID_t volID; VolumeID_t poolID; } EventLVolSalvageExit_s; typedef struct EventLVolPurgeEnter_s { - NINT enterExitID; - unicode_t *volName; + NINT enterExitID; + unicode_t *volName; VolumeID_t volID; VolumeID_t poolID; } EventLVolPurgeEnter_s; typedef struct EventLVolPurgeExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; - unicode_t *volName; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; + unicode_t *volName; VolumeID_t volID; VolumeID_t poolID; } EventLVolPurgeExit_s; typedef struct EventLVolSnapshotEnter_s { - NINT enterExitID; + NINT enterExitID; LONG volPersistentState; /* Persistent state of volume. A three * indicates that the two deleted * items are valid. */ - unicode_t *oldVolName; /* Old volume name. */ - unicode_t *oldPoolName; /* Old Pool name. */ - unicode_t *poolName; /* Current Pool Name. */ + unicode_t *oldVolName; /* Old volume name. */ + unicode_t *oldPoolName; /* Old Pool name. */ + unicode_t *poolName; /* Current Pool Name. */ VolumeID_t oldPoolID; /* Old Pool ID */ VolumeID_t poolID; /* Current Pool ID */ VolumeID_t oldVolID; /* Old volume ID */ @@ -671,13 +671,13 @@ typedef struct EventLVolSnapshotEnter_s typedef struct EventLVolSnapshotExit_s { - NINT enterExitID; - STATUS enterRetStatus; - STATUS opRetCode; + NINT enterExitID; + STATUS enterRetStatus; + STATUS opRetCode; LONG volPersistentState; /* Persistent state of volume */ - unicode_t *oldVolName; /* Old volume name. */ - unicode_t *oldPoolName; /* Old Pool ID. */ - unicode_t *poolName; /* Current Pool name. */ + unicode_t *oldVolName; /* Old volume name. */ + unicode_t *oldPoolName; /* Old Pool ID. */ + unicode_t *poolName; /* Current Pool name. */ VolumeID_t oldPoolID; /* Old Pool ID */ VolumeID_t poolID; /* Current Pool Name */ VolumeID_t oldVolID; /* Old volume ID */ diff --git a/include/nwnss/public/zFsMsg.h b/include/nwnss/public/zFsMsg.h index 9e5053d..cd041e9 100644 --- a/include/nwnss/public/zFsMsg.h +++ b/include/nwnss/public/zFsMsg.h @@ -39,15 +39,15 @@ #define _ZFSMSG_H_ #ifndef _ZOMNI_H_ -# include +# include #endif #ifndef _ZMSG_H_ -# include +# include #endif #ifndef _CHUNK_H_ -# include +# include #endif #ifdef __cplusplus @@ -313,7 +313,7 @@ typedef struct zNSSMsg_s struct create_s { struct name_s name; - + LONG requestedRights; /* Rights on the open file */ LONG fileType; /* Type of file to create */ LONG fileAttributes; /* Attributes for file */ diff --git a/include/nwnss/public/zMigrate.h b/include/nwnss/public/zMigrate.h index 191d1a1..2271a4d 100644 --- a/include/nwnss/public/zMigrate.h +++ b/include/nwnss/public/zMigrate.h @@ -37,7 +37,7 @@ #define _ZMIGRATE_H_ #ifndef _ZOMNI_H_ -# include +# include #endif #ifdef __cplusplus diff --git a/include/nwnss/public/zMsg.h b/include/nwnss/public/zMsg.h index ab80af2..90a06ed 100644 --- a/include/nwnss/public/zMsg.h +++ b/include/nwnss/public/zMsg.h @@ -39,7 +39,7 @@ #define _ZMSG_H_ #ifndef _ZOMNI_H_ -# include +# include #endif #ifdef __cplusplus @@ -151,7 +151,7 @@ enum { DATA_AREA_CORRECT = SYSTEM_MSG_CORRECT = 1 / (sizeof(struct kernelSystemMsg_s) == sizeof(struct userSystemMsg_s)) }; - + /* This number should be small but engineered to the * system, so the message can be passed in registers diff --git a/include/nwnss/public/zOmni.h b/include/nwnss/public/zOmni.h index d82785e..99c25d8 100644 --- a/include/nwnss/public/zOmni.h +++ b/include/nwnss/public/zOmni.h @@ -38,7 +38,7 @@ #define _ZOMNI_H_ #ifndef _ZWHERE_H_ -#include +#include #endif #ifdef __cplusplus @@ -98,7 +98,7 @@ extern "C" { # if defined(__GNUC__) || defined(__MWERKS__) typedef unsigned long long QUAD; # else - typedef unsigned __int64 QUAD; + typedef unsigned __int64 QUAD; # endif # else typedef unsigned int QUAD; @@ -322,7 +322,7 @@ typedef SLONG Seq_t; /* Sequence number */ * a file name string (like a directory/file * name) */ -#define zMAX_FULL_NAME 1024 /* maximum length of a fully qualified file +#define zMAX_FULL_NAME 1024 /* maximum length of a fully qualified file * name string. This must be * >= zMAX_COMPONENT_NAME */ diff --git a/include/nwnss/public/zParams.h b/include/nwnss/public/zParams.h index ab7538f..5e03c74 100644 --- a/include/nwnss/public/zParams.h +++ b/include/nwnss/public/zParams.h @@ -38,7 +38,7 @@ #define _ZPARAMS_H_ #ifndef _ZOMNI_H_ -# include +# include #endif #ifdef __cplusplus @@ -64,7 +64,7 @@ extern "C" { #define zATTR_SALVAGE 0x00000001 #define zATTR_USER_SPACE_RESTRICTIONS 0x00000002 #define zATTR_READONLY 0x00000004 -#define zATTR_COMPRESSION 0x00000008 +#define zATTR_COMPRESSION 0x00000008 #define zATTR_EXTENDED_ATTRIBUTES 0x00000010 #define zATTR_DATA_STREAMS 0x00000020 #define zATTR_DOS_METADATA 0x00000040 @@ -81,15 +81,15 @@ extern "C" { #define zATTR_REBUILD 0x00020000 #define zATTR_COW 0x00040000 #define zATTR_VIRTUAL_FILES 0x00080000 -#define zATTR_USER_TRANSACTION 0x00100000 /* indicates the volume - * can be transactioned on +#define zATTR_USER_TRANSACTION 0x00100000 /* indicates the volume + * can be transactioned on * next activate */ -#define zATTR_USER_TRANSACTION_ACTIVE 0x00200000 /* indicates the volume is - * currently being +#define zATTR_USER_TRANSACTION_ACTIVE 0x00200000 /* indicates the volume is + * currently being * transactioned */ -#define zATTR_DONT_BACKUP 0x00400000 /* Don't backup this +#define zATTR_DONT_BACKUP 0x00400000 /* Don't backup this * volume */ -#define zATTR_MFL 0x00800000 /* Volume maintains MFL +#define zATTR_MFL 0x00800000 /* Volume maintains MFL * data structure */ #define zATTR_DIR_QUOTAS 0x01000000 #define zATTR_SHRED_DATA 0x02000000 @@ -161,10 +161,10 @@ extern "C" { */ #define zPOOL_FEATURE_LIST \ ( zPOOL_FEATURE_PERSISTENT_FEATURES | \ - zPOOL_FEATURE_SHARED_CLUSTER | \ + zPOOL_FEATURE_SHARED_CLUSTER | \ zPOOL_FEATURE_READ_ONLY | \ - zPOOL_FEATURE_VERIFY | \ - zPOOL_FEATURE_REBUILD | \ + zPOOL_FEATURE_VERIFY | \ + zPOOL_FEATURE_REBUILD | \ zPOOL_FEATURE_MULTIPLE_VOLUMES | \ zPOOL_FEATURE_SNAPSHOT | \ zPOOL_FEATURE_MSAP ) @@ -240,21 +240,21 @@ extern "C" { /*------------------------------------------------------------------------- * Definition of file attributes *-------------------------------------------------------------------------*/ -#define zFA_READ_ONLY 0x00000001 -#define zFA_HIDDEN 0x00000002 -#define zFA_SYSTEM 0x00000004 +#define zFA_READ_ONLY 0x00000001 +#define zFA_HIDDEN 0x00000002 +#define zFA_SYSTEM 0x00000004 #define zFA_EXECUTE 0x00000008 -#define zFA_SUBDIRECTORY 0x00000010 +#define zFA_SUBDIRECTORY 0x00000010 #define zFA_ARCHIVE 0x00000020 -#define zFA_SHAREABLE 0x00000080 -#define zFA_SMODE_BITS 0x00000700 +#define zFA_SHAREABLE 0x00000080 +#define zFA_SMODE_BITS 0x00000700 #define zFA_NO_SUBALLOC 0x00000800 #define zFA_TRANSACTION 0x00001000 #define zFA_NOT_VIRTUAL_FILE 0x00002000 /* only valid on a volume with the zATTR_VIRTUAL_FILES attribute */ #define zFA_IMMEDIATE_PURGE 0x00010000 -#define zFA_RENAME_INHIBIT 0x00020000 -#define zFA_DELETE_INHIBIT 0x00040000 -#define zFA_COPY_INHIBIT 0x00080000 +#define zFA_RENAME_INHIBIT 0x00020000 +#define zFA_DELETE_INHIBIT 0x00040000 +#define zFA_COPY_INHIBIT 0x00080000 #define zFA_IS_ADMIN_LINK 0x00100000 /* if set then the file contains persistent admin link info */ #define zFA_IS_LINK 0x00200000 #define zFS_REMOTE_DATA_ACCESS 0x00400000 /* file has been migrated */ @@ -264,7 +264,7 @@ extern "C" { #define zFA_DO_NOT_COMPRESS_FILE 0x08000000 #define zFA_HARDLINK 0x10000000 /* if set, this is a hardlink beast, real inode is pointed to by FILE */ #define zFA_CANT_COMPRESS_DATA_STREAM 0x20000000 /* can't save any space by compressiong this data stream */ -#define zFA_ATTR_ARCHIVE 0x40000000 +#define zFA_ATTR_ARCHIVE 0x40000000 #define zFA_VOLATILE 0x80000000 /* Data is volatile (no oplocks) */ #ifdef _NSS_INTERNAL_ @@ -369,7 +369,7 @@ typedef struct zPhysicalExtent_s * Definition of fileNameUniquifier * * A file may have multiple parents, and multiple names within each parent. - * This is an ID which uniquely identifies which parent/name is being + * This is an ID which uniquely identifies which parent/name is being * referred to for a given file. * * A well known value of zFNU_FIRST_PARENT will always map to the first @@ -380,7 +380,7 @@ typedef struct zPhysicalExtent_s #define zFNU_FIRST_PARENT zFNU_UNDEFINED #ifdef _NSS_INTERNAL_ - #define zFNU_INVALID_NAME_UNIQUIFIER 0xFFFF + #define zFNU_INVALID_NAME_UNIQUIFIER 0xFFFF #endif /* @@ -416,7 +416,7 @@ typedef enum FileType_t { #define zFTYPE_ROOT_BEAST 0 #define zFTYPE_NAMED_DATA_STREAM 1 #define zFTYPE_AUTH_BEAST 2 -#define zFTYPE_FILE 3 +#define zFTYPE_FILE 3 #define zFTYPE_ADMIN_VOL_FILE 4 #define zFTYPE_VOLUME 5 #define zFTYPE_ADMIN_VOL 6 @@ -459,7 +459,7 @@ typedef enum FileType_t { #define zFTYPE_ZLSS_USER_TREE 50 #define zFTYPE_ZLSS_VOLUME_LOCATOR 51 #define zFTYPE_ZLSS_LOGICAL_POOL 52 -#define zFTYPE_ZLSS_MFL 53 +#define zFTYPE_ZLSS_MFL 53 #define zFTYPE_ZLSS_DIR_TREE 54 #define zFTYPE_ZLSS_EFL 55 @@ -471,7 +471,7 @@ typedef enum FileType_t { /* The next two IDs are assigned to Novell, Inc. Contact NSS@Novell.com * They are used in Novell's ISO 9660 CD LSS */ -#define zFTYPE_ISO9660_VOLUME 72 /* DOS LSS Volume ID */ +#define zFTYPE_ISO9660_VOLUME 72 /* DOS LSS Volume ID */ /* The next two IDs are assigned to Novell, Inc. Contact NSS@Novell.com * They are used in Novell's DOS LSS @@ -522,7 +522,7 @@ typedef enum FileType_t { /******************************************************************************/ /* current maximum supported value*/ -#define zFTYPE_MAX 255 +#define zFTYPE_MAX 255 /*------------------------------------------------------------------------- * Definition of LSS ID Types @@ -536,7 +536,7 @@ typedef enum FileType_t { #define zLSS_ID_INVALID -1 #define zLSS_ID_ADMIN 10 /* Owned by Novell */ -#define zLSS_ID_ZLSS 20 /* Owned by Novell */ +#define zLSS_ID_ZLSS 20 /* Owned by Novell */ #define zLSS_ID_FAT 30 /* Owned by Novell */ #define zLSS_ID_ISO9660 40 /* Owned by Novell */ #define zLSS_ID_HFSCD 50 /* Owned by Novell */ @@ -601,7 +601,7 @@ enum zGetInfoMask_t */ zGET_PRIMARY_NAMESPACE = 0x8, /* - * Get the various time stamps associated with the file object + * Get the various time stamps associated with the file object * in seconds. Though time is returned in seconds, the underlying * system may only keep a resolution of 2 seconds. */ @@ -677,7 +677,7 @@ enum zGetInfoMask_t */ zGET_POOL_INFO = 0x40000, /* - * If the file object is a directory, this bit returns the + * If the file object is a directory, this bit returns the * directory quota information for the directory. */ zGET_DIR_QUOTA = 0x80000, @@ -697,7 +697,7 @@ enum zGetInfoMask_t zGET_TIMES_IN_MICROS | zGET_IDS | zGET_STORAGE_USED | zGET_BLOCK_SIZE | zGET_COUNTS | zGET_DATA_STREAM_INFO | zGET_DELETED_INFO | zGET_MAC_METADATA | zGET_UNIX_METADATA | - zGET_VOLUME_INFO | zGET_VOL_SALVAGE_INFO | zGET_POOL_INFO | + zGET_VOLUME_INFO | zGET_VOL_SALVAGE_INFO | zGET_POOL_INFO | zGET_DIR_QUOTA | zGET_INH_RIGHTS_MASK | zGET_ALL_TRUSTEES ) #endif }; @@ -705,15 +705,15 @@ enum zGetInfoMask_t /*------------------------------------------------------------------------- - * Definition of handlePathType + * Definition of handlePathType *-------------------------------------------------------------------------*/ #define zHPT_SIMPLE 1 #define zHPT_FULL 2 #define zHPT_CONTEXT 3 #define zHPT_VOLUME 4 #define zHPT_VOLUME_ZID 5 -#define zHPT_ADMIN_VOLUME 6 -#define zHPT_ADMIN_VOLUME_ZID 7 +#define zHPT_ADMIN_VOLUME 6 +#define zHPT_ADMIN_VOLUME_ZID 7 #define zHPT_FILEHANDLEID 8 #define zHPT_SEARCH_PATTERN 9 #define zHPT_BEAST 10 @@ -734,7 +734,7 @@ enum zGetInfoMask_t #ifdef _NSS_INTERNAL_ #define zVALID_LINK_FLAGS (zLF_HARD_LINK | zLF_KEEP_VFS_CACHE) #endif - + /*--------------------------------------------------------------------------- * Definition of matchFlags in zMatchAttr_s *---------------------------------------------------------------------------*/ @@ -758,7 +758,7 @@ enum zGetInfoMask_t * directories and other files will * match. If neither is set, nothing * will match. - */ + */ #define zMATCH_SYSTEM 0x10 /* Match if a system file. */ #define zMATCH_NON_SYSTEM 0x20 /* Match if NOT a system file. * If both zMATCH_NON_SYSTEM and @@ -822,7 +822,7 @@ enum zGetInfoMask_t | zMOD_INH_RIGHTS_MASK \ | zMOD_ALL_TRUSTEES) -#define zMAX_READ_AHEAD_COUNT 1024 +#define zMAX_READ_AHEAD_COUNT 1024 #ifdef _NSS_INTERNAL_ @@ -871,14 +871,14 @@ enum zGetInfoMask_t * environments in the same directory container. *---------------------------------------------------------------------------*/ #define zNTYPE_FILE 0 -#define zNTYPE_DATA_STREAM 1 +#define zNTYPE_DATA_STREAM 1 #define zNTYPE_EXTENDED_ATTRIBUTE 2 #define zNTYPE_DELETED_FILE 3 #ifdef _NSS_INTERNAL_ #define zNTYPE_MAX_DEFINED 3 - /*#define zNTYPE_DELETED_DATA_STREAM 4 */ + /*#define zNTYPE_DELETED_DATA_STREAM 4 */ /*#define zNTYPE_DELETED_EXTENDED_ATTRIBUTE 5 */ #define zNTYPE_INVALID (-1) @@ -890,7 +890,7 @@ enum zGetInfoMask_t #define zNSPACE_DOS 0 #define zNSPACE_MAC 1 #define zNSPACE_UNIX 2 -/*#define zNSPACE_FTAM 3 not supported*/ +/*#define zNSPACE_FTAM 3 not supported*/ #define zNSPACE_LONG 4 #define zNSPACE_DATA_STREAM 6 #define zNSPACE_EXTENDED_ATTRIBUTE 7 @@ -961,7 +961,7 @@ enum zGetInfoMask_t #define zRENAME_COMPATABILITY 0x00000002 /* Matches a traditional NW value */ #define zRENAME_DONT_RENAME_FILES 0x00000010 #define zRENAME_DONT_RENAME_DIRECTORIES 0x00000020 - #define zRENAME_TARGET_IS_PATTERN 0x00000040 + #define zRENAME_TARGET_IS_PATTERN 0x00000040 #define zVALID_RENAME_FLAGS \ @@ -1063,46 +1063,46 @@ enum zGetInfoMask_t #ifdef _NSS_INTERNAL_ - #define zVALID_FILE_REQ_RIGHTS \ - (zRR_READ_ACCESS | \ - zRR_WRITE_ACCESS | \ - zRR_DENY_READ | \ - zRR_DENY_WRITE | \ - zRR_SCAN_ACCESS | \ - zRR_ENABLE_IO_ON_COMPRESSED_DATA | \ - zRR_LEAVE_FILE_COMPRESSED | \ - zRR_DELETE_FILE_ON_CLOSE | \ - zRR_FLUSH_ON_CLOSE | \ - zRR_PURGE_IMMEDIATE_ON_CLOSE | \ - zRR_DIO_MODE | \ - zRR_ALLOW_SECURE_DIRECTORY_ACCESS | \ + #define zVALID_FILE_REQ_RIGHTS \ + (zRR_READ_ACCESS | \ + zRR_WRITE_ACCESS | \ + zRR_DENY_READ | \ + zRR_DENY_WRITE | \ + zRR_SCAN_ACCESS | \ + zRR_ENABLE_IO_ON_COMPRESSED_DATA | \ + zRR_LEAVE_FILE_COMPRESSED | \ + zRR_DELETE_FILE_ON_CLOSE | \ + zRR_FLUSH_ON_CLOSE | \ + zRR_PURGE_IMMEDIATE_ON_CLOSE | \ + zRR_DIO_MODE | \ + zRR_ALLOW_SECURE_DIRECTORY_ACCESS | \ zRR_TRANSACTION_ACTIVE | \ zRR_PSA_CACHE | \ zRR_MASK_READ_IN_DROP_BOXES | \ zRR_READ_ACCESS_TO_SNAPSHOT | \ - zRR_DENY_RW_OPENER_CAN_REOPEN | \ - zRR_CREATE_WITHOUT_READ_ACCESS | \ - zRR_OPENER_CAN_DELETE_WHILE_OPEN | \ - zRR_CANT_DELETE_WHILE_OPEN | \ + zRR_DENY_RW_OPENER_CAN_REOPEN | \ + zRR_CREATE_WITHOUT_READ_ACCESS | \ + zRR_OPENER_CAN_DELETE_WHILE_OPEN | \ + zRR_CANT_DELETE_WHILE_OPEN | \ zRR_DONT_UPDATE_ACCESS_TIME) - #define zVALID_READ_ONLY_FILE_REQ_RIGHTS \ - (zRR_READ_ACCESS | \ - zRR_DENY_READ | \ - zRR_DENY_WRITE | \ - zRR_SCAN_ACCESS | \ - zRR_ENABLE_IO_ON_COMPRESSED_DATA | \ - zRR_LEAVE_FILE_COMPRESSED | \ - zRR_DIO_MODE | \ - zRR_ALLOW_SECURE_DIRECTORY_ACCESS | \ + #define zVALID_READ_ONLY_FILE_REQ_RIGHTS \ + (zRR_READ_ACCESS | \ + zRR_DENY_READ | \ + zRR_DENY_WRITE | \ + zRR_SCAN_ACCESS | \ + zRR_ENABLE_IO_ON_COMPRESSED_DATA | \ + zRR_LEAVE_FILE_COMPRESSED | \ + zRR_DIO_MODE | \ + zRR_ALLOW_SECURE_DIRECTORY_ACCESS | \ zRR_PSA_CACHE | \ zRR_MASK_READ_IN_DROP_BOXES | \ zRR_READ_ACCESS_TO_SNAPSHOT | \ - zRR_DENY_RW_OPENER_CAN_REOPEN | \ + zRR_DENY_RW_OPENER_CAN_REOPEN | \ zRR_CREATE_WITHOUT_READ_ACCESS | \ - zRR_OPENER_CAN_DELETE_WHILE_OPEN | \ - zRR_CANT_DELETE_WHILE_OPEN | \ + zRR_OPENER_CAN_DELETE_WHILE_OPEN | \ + zRR_CANT_DELETE_WHILE_OPEN | \ zRR_DONT_UPDATE_ACCESS_TIME) #endif @@ -1111,9 +1111,9 @@ enum zGetInfoMask_t * Definition of setSizeFlags *-------------------------------------------------------------------------*/ #define zSETSIZE_NON_SPARSE_FILE 0x00000001 /* Alloc blocks to extend the * - * file */ + * file */ #define zSETSIZE_NO_ZERO_FILL 0x00000002 /* Do not zero fill the newly * - * allocated blocks */ + * allocated blocks */ #define zSETSIZE_UNDO_ON_ERR 0x00000004 /* In non sparse cases truncate * * back to original eof if an * * error occurs. */ @@ -1132,7 +1132,7 @@ enum zGetInfoMask_t #ifdef _NSS_INTERNAL_ #define zVALID_SETSIZE_FLAGS \ (zSETSIZE_NON_SPARSE_FILE | zSETSIZE_PHYSICAL_ONLY | \ - zSETSIZE_UNDO_ON_ERR | zSETSIZE_NO_ZERO_FILL | \ + zSETSIZE_UNDO_ON_ERR | zSETSIZE_NO_ZERO_FILL | \ zSETSIZE_LOGICAL_ONLY | zSETSIZE_COMPRESSED | zSETSIZE_CONTIGUOUS ) #endif @@ -1147,7 +1147,7 @@ enum zGetInfoMask_t /*----------------------------------------------------------------------- * Definition of volumeState *-----------------------------------------------------------------------*/ -#define zVOLSTATE_UNKNOWN 0 /* Volume is new and not available */ +#define zVOLSTATE_UNKNOWN 0 /* Volume is new and not available */ #define zVOLSTATE_DEACTIVE 2 /* Volume is not currently activated */ #define zVOLSTATE_MAINTENANCE 3 /* Volume is in a maintenance mode */ #define zVOLSTATE_ACTIVE 6 /* Volume is active and available */ @@ -1211,28 +1211,28 @@ enum { typedef struct zMacInfo_s { - BYTE finderInfo[32]; - BYTE proDOSInfo[6]; + BYTE finderInfo[32]; + BYTE proDOSInfo[6]; BYTE filler[2]; LONG dirRightsMask; } NSS_MEDIA_STRUCTURE(zMacInfo_s,dirRightsMask) zMacInfo_s; typedef struct zUnixInfo_s { - LONG fMode; - LONG rDev; - LONG myFlags; - LONG nfsUID; - LONG nfsGID; + LONG fMode; + LONG rDev; + LONG myFlags; + LONG nfsUID; + LONG nfsGID; LONG nwUID; LONG nwGID; LONG nwEveryone; LONG nwUIDRights; LONG nwGIDRights; LONG nwEveryoneRights; - BYTE acsFlags; - BYTE firstCreated; - SWORD variableSize; + BYTE acsFlags; + BYTE firstCreated; + SWORD variableSize; /* If variableSize is non-zero, there will be "variableSize" number of * additional bytes of meta data associated with this file. The format * of this variable data is unknown to NSS @@ -1245,7 +1245,7 @@ typedef struct zUnixInfo_s typedef struct zVolumeInfo_s { VolumeID_t volumeID; /* 128 bit GUID that identifies volume. */ - NDSid_t ndsObjectID; /* zMOD_VOL_NDS_OBJECT_ID + NDSid_t ndsObjectID; /* zMOD_VOL_NDS_OBJECT_ID * 128 bit Object Id assigned by eDir */ LONG volumeState; /* Current state of the volume, ACTIVE (6), * DEACTIVE (2), MAINTENANCE (3) */ @@ -1257,7 +1257,7 @@ typedef struct zVolumeInfo_s * Mask of features that should be changed. */ QUAD supported; /* Features that can be supported by volume */ } zPACKED features; - QUAD maximumFileSize;/* Maximum file size supported by volume. */ + QUAD maximumFileSize;/* Maximum file size supported by volume. */ QUAD totalSpaceQuota;/* zMOD_VOL_QUOTA * Maximum size of this volume * (may over book pool) */ @@ -1391,17 +1391,17 @@ typedef struct zInfo_s * than it needs, this marks of the end of * extra data blocks */ - QUAD dataBytes; /* Storage used by user data */ - QUAD metaDataBytes; /* Storage used by Meta-data */ + QUAD dataBytes; /* Storage used by user data */ + QUAD metaDataBytes; /* Storage used by Meta-data */ } zPACKED storageUsed; LONG primaryNameSpaceID; /* zGET_PRIMARY_NAMESPACE */ /* zMOD_PRIMARY_NAMESPACE */ - LONG nameStart; /* zGET_NAME - index into variableData */ + LONG nameStart; /* zGET_NAME - index into variableData */ struct { /* zGET_ALL_NAMES */ - LONG numEntries; - LONG fileNameArray; /* Index of the array of indicies in + LONG numEntries; + LONG fileNameArray; /* Index of the array of indicies in * the variableData area */ } zPACKED names; @@ -1415,10 +1415,10 @@ typedef struct zInfo_s } zPACKED time; struct { /* zGET_IDS */ - UserID_t owner; /* zMOD_OWNER_ID */ - UserID_t archiver; /* zMOD_ARCHIVER_ID */ - UserID_t modifier; /* zMOD_MODIFIER_ID */ - UserID_t metaDataModifier; /* zMOD_METADATA_MODIFIER_ID */ + UserID_t owner; /* zMOD_OWNER_ID */ + UserID_t archiver; /* zMOD_ARCHIVER_ID */ + UserID_t modifier; /* zMOD_MODIFIER_ID */ + UserID_t metaDataModifier; /* zMOD_METADATA_MODIFIER_ID */ } zPACKED id; struct { /* zGET_BLOCK_SIZE */ @@ -1493,17 +1493,17 @@ typedef struct zInfoB_s * than it needs, this marks of the end of * extra data blocks */ - QUAD dataBytes; /* Storage used by user data */ - QUAD metaDataBytes; /* Storage used by Meta-data */ + QUAD dataBytes; /* Storage used by user data */ + QUAD metaDataBytes; /* Storage used by Meta-data */ } zPACKED storageUsed; LONG primaryNameSpaceID; /* zGET_PRIMARY_NAMESPACE */ /* zMOD_PRIMARY_NAMESPACE */ - LONG nameStart; /* zGET_NAME - index into variableData */ + LONG nameStart; /* zGET_NAME - index into variableData */ struct { /* zGET_ALL_NAMES */ - LONG numEntries; - LONG fileNameArray; /* Index of the array of indicies in + LONG numEntries; + LONG fileNameArray; /* Index of the array of indicies in * the variableData area */ } zPACKED names; @@ -1517,10 +1517,10 @@ typedef struct zInfoB_s } zPACKED time; struct { /* zGET_IDS */ - UserID_t owner; /* zMOD_OWNER_ID */ - UserID_t archiver; /* zMOD_ARCHIVER_ID */ - UserID_t modifier; /* zMOD_MODIFIER_ID */ - UserID_t metaDataModifier; /* zMOD_METADATA_MODIFIER_ID */ + UserID_t owner; /* zMOD_OWNER_ID */ + UserID_t archiver; /* zMOD_ARCHIVER_ID */ + UserID_t modifier; /* zMOD_MODIFIER_ID */ + UserID_t metaDataModifier; /* zMOD_METADATA_MODIFIER_ID */ } zPACKED id; struct { /* zGET_BLOCK_SIZE */ @@ -1571,8 +1571,8 @@ typedef struct zInfoB_s SQUAD quota; /* zMOD_DIR_QUOTA */ SQUAD usedAmount; } zPACKED dirQuota; - - + + /* The variable portion will contain all variable size optional data */ BYTE variableData[zGET_INFO_VARIABLE_DATA_SIZE]; @@ -1600,17 +1600,17 @@ typedef struct zInfoC_s * than it needs, this marks of the end of * extra data blocks */ - QUAD dataBytes; /* Storage used by user data */ - QUAD metaDataBytes; /* Storage used by Meta-data */ + QUAD dataBytes; /* Storage used by user data */ + QUAD metaDataBytes; /* Storage used by Meta-data */ } zPACKED storageUsed; LONG primaryNameSpaceID; /* zGET_PRIMARY_NAMESPACE */ /* zMOD_PRIMARY_NAMESPACE */ - LONG nameStart; /* zGET_NAME - index into variableData */ + LONG nameStart; /* zGET_NAME - index into variableData */ struct { /* zGET_ALL_NAMES */ - LONG numEntries; - LONG fileNameArray; /* Index of the array of indicies in + LONG numEntries; + LONG fileNameArray; /* Index of the array of indicies in * the variableData area */ } zPACKED names; @@ -1624,10 +1624,10 @@ typedef struct zInfoC_s } zPACKED time; struct { /* zGET_IDS */ - UserID_t owner; /* zMOD_OWNER_ID */ - UserID_t archiver; /* zMOD_ARCHIVER_ID */ - UserID_t modifier; /* zMOD_MODIFIER_ID */ - UserID_t metaDataModifier; /* zMOD_METADATA_MODIFIER_ID */ + UserID_t owner; /* zMOD_OWNER_ID */ + UserID_t archiver; /* zMOD_ARCHIVER_ID */ + UserID_t modifier; /* zMOD_MODIFIER_ID */ + UserID_t metaDataModifier; /* zMOD_METADATA_MODIFIER_ID */ } zPACKED id; struct { /* zGET_BLOCK_SIZE */ @@ -1678,14 +1678,14 @@ typedef struct zInfoC_s SQUAD quota; /* zMOD_DIR_QUOTA */ SQUAD usedAmount; } zPACKED dirQuota; - + LONG inheritedRightsMask; /* zGET_INH_RIGHTS_MASK */ /* zMOD_INH_RIGHTS_MASK */ struct { /* zGET_ALL_TRUSTEES */ /* zMOD_ALL_TRUSTEES */ - LONG numEntries; - LONG trusteeArray; /* Index of the array of zTrusteeInfo_s + LONG numEntries; + LONG trusteeArray; /* Index of the array of zTrusteeInfo_s * structures in the variableData area */ } zPACKED trustees; @@ -1716,17 +1716,17 @@ typedef struct zInfoD_s * than it needs, this marks of the end of * extra data blocks */ - QUAD dataBytes; /* Storage used by user data */ - QUAD metaDataBytes; /* Storage used by Meta-data */ + QUAD dataBytes; /* Storage used by user data */ + QUAD metaDataBytes; /* Storage used by Meta-data */ } zPACKED storageUsed; LONG primaryNameSpaceID; /* zGET_PRIMARY_NAMESPACE */ /* zMOD_PRIMARY_NAMESPACE */ - LONG nameStart; /* zGET_NAME - index into variableData */ + LONG nameStart; /* zGET_NAME - index into variableData */ struct { /* zGET_ALL_NAMES */ - LONG numEntries; - LONG fileNameArray; /* Index of the array of indicies in + LONG numEntries; + LONG fileNameArray; /* Index of the array of indicies in * the variableData area */ } zPACKED names; @@ -1740,10 +1740,10 @@ typedef struct zInfoD_s } zPACKED time; struct { /* zGET_IDS */ - UserID_t owner; /* zMOD_OWNER_ID */ - UserID_t archiver; /* zMOD_ARCHIVER_ID */ - UserID_t modifier; /* zMOD_MODIFIER_ID */ - UserID_t metaDataModifier; /* zMOD_METADATA_MODIFIER_ID */ + UserID_t owner; /* zMOD_OWNER_ID */ + UserID_t archiver; /* zMOD_ARCHIVER_ID */ + UserID_t modifier; /* zMOD_MODIFIER_ID */ + UserID_t metaDataModifier; /* zMOD_METADATA_MODIFIER_ID */ } zPACKED id; struct { /* zGET_BLOCK_SIZE */ @@ -1794,14 +1794,14 @@ typedef struct zInfoD_s SQUAD quota; /* zMOD_DIR_QUOTA */ SQUAD usedAmount; } zPACKED dirQuota; - + LONG inheritedRightsMask; /* zGET_INH_RIGHTS_MASK */ /* zMOD_INH_RIGHTS_MASK */ struct { /* zGET_ALL_TRUSTEES */ /* zMOD_ALL_TRUSTEES */ - LONG numEntries; - LONG trusteeArray; /* Index of the array of zTrusteeInfo_s + LONG numEntries; + LONG trusteeArray; /* Index of the array of zTrusteeInfo_s * structures in the variableData area */ } zPACKED trustees; @@ -1961,7 +1961,7 @@ typedef struct zMatchAttr_s NINT matchFlags; NINT matchFileType; - NINT matchFileAttrSet; + NINT matchFileAttrSet; NINT matchFileAttrNotSet; NINT matchTypeAttrSet; @@ -1974,7 +1974,7 @@ typedef struct zMatchAttr_s * Buffer definition for the buffer returned by AsyncRead calls *---------------------------------------------------------------------------*/ /*** This Buffer matches PubBuffer_s. Any modifications made here - *** should be reflected in PubBuffer_s in xCache.h + *** should be reflected in PubBuffer_s in xCache.h ***/ typedef struct zBuffer_s { @@ -2047,3 +2047,5 @@ typedef struct VirtInfo_s #endif #endif /* _ZPARAMS_H_ */ + + diff --git a/include/nwnss/public/zPool.h b/include/nwnss/public/zPool.h index 1c23a61..41e0ae9 100644 --- a/include/nwnss/public/zPool.h +++ b/include/nwnss/public/zPool.h @@ -39,7 +39,7 @@ #define _ZPOOL_H_ #ifndef _ZPUBLICS_H_ -# include +# include #endif #ifdef __cplusplus @@ -107,3 +107,6 @@ STATUS zPoolOwnershipGet( #endif /* _ZPOOL_H_ */ + + + diff --git a/include/nwnss/public/zPool.imp b/include/nwnss/public/zPool.imp new file mode 100644 index 0000000..85be4d2 --- /dev/null +++ b/include/nwnss/public/zPool.imp @@ -0,0 +1,6 @@ +zPoolFreeze +zPoolOwnershipGet +zPoolOwnershipRelease +zPoolThaw +zPoolThawByName +zPoolThawRequired diff --git a/include/nwnss/public/zPublics.h b/include/nwnss/public/zPublics.h index cd3792a..0d9c259 100644 --- a/include/nwnss/public/zPublics.h +++ b/include/nwnss/public/zPublics.h @@ -38,11 +38,11 @@ #define _ZPUBLICS_H_ #ifndef _ZOMNI_H_ -# include +# include #endif #ifndef _ZPARAMS_H_ -# include +# include #endif @@ -84,7 +84,7 @@ STATUS zCommitXaction( STATUS zCreate( Key_t key, - NINT taskID, + NINT taskID, Xid_t xid, NINT nameSpace, const void *path, @@ -147,8 +147,8 @@ STATUS zEnumerate( STATUS zFlush( Key_t key); -STATUS zGetEffectiveRights(Key_t key, - GUID_t objId, +STATUS zGetEffectiveRights(Key_t key, + GUID_t objId, NINT *effectiveRights); STATUS zGetFileMap( @@ -201,7 +201,7 @@ STATUS zLink( STATUS zLockByteRange( Key_t key, - Xid_t xid, + Xid_t xid, NINT mode, QUAD startingOffset, QUAD length, @@ -239,7 +239,7 @@ STATUS zOpen( STATUS zRead( Key_t key, - Xid_t xid, + Xid_t xid, QUAD startingOffset, NINT bytesToRead, void *retBuffer, @@ -261,7 +261,7 @@ STATUS zRootKey( STATUS zSetEOF( Key_t key, - Xid_t xid, + Xid_t xid, QUAD startingOffset, NINT flags); @@ -272,7 +272,7 @@ STATUS zSetInheritedRightsMask( STATUS zUnlockByteRange( Key_t key, - Xid_t xid, + Xid_t xid, QUAD startingOffset, QUAD length); @@ -292,7 +292,7 @@ STATUS zWildRewind( STATUS zWrite( Key_t key, - Xid_t xid, + Xid_t xid, QUAD startingOffset, NINT bytesToWrite, const void *buffer, @@ -330,7 +330,7 @@ STATUS zZIDRename( BOOL zIsNSSVolume(const utf8_t *path); STATUS zSetDataSize( - SLONG unused, + SLONG unused, NINT connectionID, NINT fileHandleID, QUAD startingOffset, diff --git a/include/nwnss/public/zPublics.imp b/include/nwnss/public/zPublics.imp new file mode 100644 index 0000000..fefd42c --- /dev/null +++ b/include/nwnss/public/zPublics.imp @@ -0,0 +1,91 @@ + LkMgrCancel + LkMgrCleanup + LkMgrFreeAll + LkMgrFreeAllWithState + LkMgrLock + LkMgrNmLock + LkMgrShare + LkMgrTest + LkMgrUnlock + LkMgrUnshare + nfssBeginReadDir + nfssChunkyRead + nfssCreate + nfssEndReadDir + nfssFsInfo + nfssFsStat + nfssGetAttr + nfssGetEffectiveRights + nfssGetRootHandle + nfssLink + nfssLookup + nfssNextReadDir + nfssRead + nfssRemove + nfssRename + nfssSetAttr + nfssUnpinChunks + nfssWrite + xDOS2utcTime + xForceVolumeUpgrade + xGuidToId + xIdToGuid + xIsVolumeUpgraded + xMangleConnection + xPoolGetEnabledFeatures + xPoolGUIDToName + xPoolNameToGUID + xSharedOpLock + xUTC2dosTime + xVolumeGUIDToName + xVolumeNameToGUID + zAbortXaction + zAddTrustee + zBeginTask + zBeginXaction + zBrowseUsers + zChangeConnection + zClose + zCommitXaction + zCreate + zDelete + zDeleteTrustee + zDIORead + zDIOWrite + zEndTask + zEnumerate + zFlush + zGetEffectiveRights + zGetFileMap + zGetInfo + zGetInheritedRightsMask + zGetNSSVolumeLabel + zGetTrustee + zInfoGetFileName + zIsNSSVolume + zLink + zLockByteRange + zModifyInfo + zNewConnection + zOpen + zOpenByZid + zRead + zReadChunks + zReleaseChunks + zRename + zRootKey + zSetEOF + zSetInheritedRightsMask + zSetNSSVolumeLabel + zUnlockByteRange + zWildRead + zWildRewind + zWrite + zSetDataSize + zRegisterDemigrateFunction + zUnregisterDemigrateFunction + zZIDCreate + zZIDDelete + zZIDLink + zZIDOpen + zZIDRename diff --git a/include/nwnss/public/zXattr.h b/include/nwnss/public/zXattr.h index 6d19ae7..b4e310c 100644 --- a/include/nwnss/public/zXattr.h +++ b/include/nwnss/public/zXattr.h @@ -104,8 +104,8 @@ typedef struct zNW_quota_s { QUAD nwq_dir_quota; /* Quota set on the directory */ } zNW_quota_s; -/* - * We have picked a value for zMAX_TRUSTEES that will let the +/* + * We have picked a value for zMAX_TRUSTEES that will let the * structure fit in 64K. */ #define zMAX_TRUSTEES 2043 @@ -144,8 +144,8 @@ typedef struct zNW_metadata_s { zNW_trustee_s nwm_trustee[zMAX_TRUSTEES]; } zNW_metadata_s; -/* - * We have picked a value for zMAX_USERS that will let the +/* + * We have picked a value for zMAX_USERS that will let the * structure fit in 64K. */ #define zMAX_XATTR_USERS 2047 diff --git a/include/nwnss/support/lnxmbINC/aesproc.h b/include/nwnss/support/lnxmbINC/aesproc.h deleted file mode 100644 index 8b13789..0000000 --- a/include/nwnss/support/lnxmbINC/aesproc.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/nwnss/support/lnxmbINC/alert.h b/include/nwnss/support/lnxmbINC/alert.h deleted file mode 100644 index 83a146e..0000000 --- a/include/nwnss/support/lnxmbINC/alert.h +++ /dev/null @@ -1,247 +0,0 @@ -#ifndef __ALERT_H__ -#define __ALERT_H__ - -/***************************************************************************** - * - * (C) Copyright 1988-1997 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Revision: 465 $ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Author: taysom $ - * - ****************************************************************************/ - - -// -// An Alert ID is comprised of two parts: -// A unique ModuleNumber (which is allotted) and an alert # -// which is under the control of the developer. -// -// The Alert module # specifies which module is generating the -// alert and the alert # can then be used for a specific alert -// generated by that module. -// - -#define ALERT_ID(ModuleNumber, AlertNumber) ((ModuleNumber) | (AlertNumber)) - -#define GET_MODULE_NUMBER_FROM_ALERTID(ALERTID) ((ALERTID) >> 16) - -// -// -// NLM developers may use any ModuleNumber in the range -// 0x8000???? to 0xffff????. The range 0x0001???? to 0x7fff???? -// is reserved for Novell. The value 0x0000???? is considered -// an invalid Alert ID and is used for all legacy alerts. -// - -// -// Allotted ModuleNumbers: -// - -#define ALERT_BINDERY 0x01020000 /* Bindery Subject in BINDERY.NLM */ -#define ALERT_OS 0x01030000 /* OS Event Subject */ -#define ALERT_LLC 0x01040000 /* Sunnyvale, Kitty Shih, LLC */ -#define ALERT_SDLC 0x01050000 /* Sunnyvale, Kitty Shih, SDLC stack */ -#define ALERT_REMOTE 0x01060000 /* RCONSOLE NLM */ -#define ALERT_MLID 0x01070000 /* Provo, MLID Lan Drivers (Don Shulz) */ -#define ALERT_QLLC 0x01080000 /* Sunnyvale, Kitty Shih, QLLC */ -#define ALERT_UPS 0x01090000 /* UPS monitor nlm*/ -#define ALERT_DS 0x010a0000 /* Directory Service in DS.NLM */ -#define ALERT_RSPX 0x010c0000 /* RSPX NLM */ -#define ALERT_R232 0x010d0000 /* R232 NLM */ -#define ALERT_TIME_SYNC 0x010e0000 /* TIMESYNC NLM */ -#define ALERT_CLIB 0x010f0000 /* CLIB NLM */ -#define ALERT_PRINT 0x01100000 /* Print Team */ -#define ALERT_NRS 0x01200000 /* Novell Replication Services */ -#define ALERT_DNS 0x01300000 /* IP/Domain Name Services */ -#define ALERT_DHCP 0x01400000 /* DHCP Services */ -#define ALERT_MM 0x01500000 /* Media Manager */ - - -// -// WARNING!!!: -// If You change these size or structures you must make the -// change in event.h also. -// - -#define AlertMessageBufferSize 256 -#define MaxStationsInList 32 - -/* Pre-declare the following structure(s) */ -struct LoadDefinitionStructure; - -typedef struct -{ - void *pNetworkManagementAttribute; - LONG nwAlertFlags; - LONG nwTargetStation; // Valid only if - // NOTIFY_CONNECTION_BIT - // bit is set. Specifies a - // a single station if - // TargetStationIsAPointer bit - // is NOT set, else points to - // a station count preceeded - // list of stations to be notified. - LONG nwTargetNotificationBits; - LONG nwAlertID; - LONG nwAlertLocus; - LONG nwAlertClass; - LONG nwAlertSeverity; - void *nwAlertDataPtr; // For legacy APIs. - void (*nwAlertDataFree)(void *nwAlertDataPtr); // For Legacy APIs. - BYTE *nwControlString; - LONG nwControlStringMessageNumber; -} NetWareAlertStructure; - -// -// Note that these alert codes are also defined in ALERTS.INC. -// - -// -// Values for nwAlertFlags field. -// - -#define QueueThisAlertMask 0x00000001 /* bit 0 */ -#define AlertIDValidMask 0x00000002 /* bit 1 */ -#define AlertLocusValidMask 0x00000004 /* bit 2 */ -#define AlertEventNotifyOnlyMask 0x00000008 /* bit 3 */ -#define AlertNoEventNotifyMask 0x00000010 /* bit 4 */ -#define AlertMessageNumberValid 0x00010000 /* bit 16 */ -#define NoDisplayAlertUID 0x00200000 /* bit 21 */ -#define AlertNoRingBell 0x00400000 /* bit 22 */ -#define AlertIDNotUniqueBit 0x00800000 /* bit 23 */ -#define OldStyleSystemAlertMask 0x01000000 /* bit 24 */ -#define OldStyleINWSystemAlertMask 0x02000000 /* bit 25 */ -#define OverloadMessageNumFieldBit 0x04000000 /* bit 26 -- used to indicate message number field can be ptr or number */ -#define NoDisplayLocusBit 0x10000000 /* bit 28 */ -#define NoDisplayAlertIDBit 0x20000000 /* bit 29 */ -#define OverrideNotificationBits 0x40000000 /* bit 30 - Netman */ -#define TargetStationIsAPointer 0x80000000 /* bit 31 */ - -#define Alert300Mask (AlertIDValidMask | AlertLocusValidMask | \ - OldStyleSystemAlertMask) -#define Alert311Mask (AlertIDValidMask | OldStyleINWSystemAlertMask) -#define Alert320Mask (AlertIDValidMask | AlertMessageNumberValid | \ - AlertLocusValidMask | NoDisplayAlertIDBit) -#define QAlertMask (AlertIDValidMask | AlertLocusValidMask | \ - NoDisplayAlertIDBit | QueueThisAlertMask) -#define QAlert320Mask (Alert320Mask | QueueThisAlertMask) - -// -// CONSUMER ERROR NOTIFICATION. -// Values for nwTargetNotificationBits field. -// - -#define NOTIFY_CONNECTION_BIT 0x00000001 -#define NOTIFY_EVERYONE_BIT 0x00000002 -#define NOTIFY_ERROR_LOG_BIT 0x00000004 -#define NOTIFY_CONSOLE_BIT 0x00000008 -#define NOTIFY_QUEUE_MESSAGE 0x10000000 // Use if alert is to be queued. -#define DONT_NOTIFY_NMAGENT 0x80000000 - - -// -// ERROR LOCUS IDENTIFIERS. -// Values for nwAlertLocus field. -// - -#define LOCUS_UNKNOWN 0 -#define LOCUS_MEMORY 1 -#define LOCUS_FILESYSTEM 2 -#define LOCUS_DISKS 3 -#define LOCUS_LANBOARDS 4 -#define LOCUS_COMSTACKS 5 -#define LOCUS_TTS 7 -#define LOCUS_BINDERY 8 -#define LOCUS_STATION 9 -#define LOCUS_ROUTER 10 -#define LOCUS_LOCKS 11 -#define LOCUS_KERNEL 12 -#define LOCUS_UPS 13 -#define LOCUS_SERVICE_PROTOCOL 14 -#define LOCUS_SFT_III 15 -#define LOCUS_RESOURCE_TRACKING 16 -#define LOCUS_NLM 17 -#define LOCUS_OS_INFORMATION 18 -#define LOCUS_CACHE 19 - -// -// ERROR CLASSES. -// Values for nwAlertClass field. -// - -#define CLASS_UNKNOWN 0 -#define CLASS_OUT_OF_RESOURCE 1 -#define CLASS_TEMP_SITUATION 2 -#define CLASS_AUTHORIZATION_FAILURE 3 -#define CLASS_INTERNAL_ERROR 4 -#define CLASS_HARDWARE_FAILURE 5 -#define CLASS_SYSTEM_FAILURE 6 -#define CLASS_REQUEST_ERROR 7 -#define CLASS_NOT_FOUND 8 -#define CLASS_BAD_FORMAT 9 -#define CLASS_LOCKED 10 -#define CLASS_MEDIA_FAILURE 11 -#define CLASS_ITEM_EXISTS 12 -#define CLASS_STATION_FAILURE 13 -#define CLASS_LIMIT_EXCEEDED 14 -#define CLASS_CONFIGURATION_ERROR 15 -#define CLASS_LIMIT_ALMOST_EXCEEDED 16 -#define CLASS_SECURITY_AUDIT_INFO 17 -#define CLASS_DISK_INFORMATION 18 -#define CLASS_GENERAL_INFORMATION 19 -#define CLASS_FILE_COMPRESSION 20 -#define CLASS_PROTECTION_VIOLATION 21 -#define CLASS_VIRTUAL_MEMORY 22 - -// -// ERROR SEVERITY LEVELS. -// Values for nwAlertSeverity field. -// - -#define SEVERITY_INFORMATIONAL 0 // Counters or Gauges reached thresholds. -#define SEVERITY_WARNING 1 // Configuration errors, etc. No Damage. -#define SEVERITY_RECOVERABLE 2 // Hot Fix disk, etc. Work-around made. -#define SEVERITY_CRITICAL 3 // Disk Mirror failure, etc. Fix-up - // attempted -#define SEVERITY_FATAL 4 // Resource fatally affected--shut down. -#define SEVERITY_OPERATION_ABORTED 5 // The operation cannot complete... - // ramifications unknown. -#define SEVERITY_NONOS_UNRECOVERABLE 6 // Operation cannot complete... - // ramifications will not affect OS. - - -typedef struct -{ - LONG stationCount; - LONG stationList[MaxStationsInList]; -} StationListStruct; - -struct LoadDefinitionStructure; -void NetWareAlert(struct LoadDefinitionStructure *nlm, - NetWareAlertStructure *nwAlert, - LONG ParameterCount, ...); - - -#endif /* __ALERT_H__ */ - -// ************************************************************************ -// ************************** END OF FILE ********************************* -// ************************************************************************ diff --git a/include/nwnss/support/lnxmbINC/bindery.h b/include/nwnss/support/lnxmbINC/bindery.h deleted file mode 100644 index 31d5d17..0000000 --- a/include/nwnss/support/lnxmbINC/bindery.h +++ /dev/null @@ -1,194 +0,0 @@ -#ifndef __BINDERY_H__ -#define __BINDERY_H__ -/***************************************************************************** - * - * (C) Copyright 1986-1994 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Revision: 465 $ - * - ****************************************************************************/ - -/* - BINDERY DEFINITION - NETWARE 386 -*/ - - -#define ITEMPROP 0 -#define GROUPPROP 2 - -struct ObjectStructure -{ - LONG ObjectID; /* Unique ID number of object (0=FREE) */ - WORD ObjectType; /* Object type */ - BYTE ObjectName [48]; /* Object name */ - BYTE ObjectFlags; /* Bits as follows: - 0x01 Set = Dynamic, Clear = Static */ - BYTE ObjectSecurity; /* (Same as propstruct.security) below */ - LONG FirstPropertyID; /* ID of first property of object */ - LONG HashLink; -}; - -struct PropertyStructure -{ - LONG PropertyID; /* Unique ID of property (0=FREE) */ - BYTE PropertyName[16]; - BYTE PropertyFlags; /* 0x01 Set = Dynamic, Clear = Static - 0x02 Set = Group, Clear = Item/non-group */ - BYTE PropertySecurity; /* Read security: - 0xn0 = R by anyone - 0xn1 = R by anyone logged in - 0xn2 = R by Object or Supervisor - 0xn3 = R by Supervisor only - 0xn4 = R by Bindery only - - Write Security: - 0x0n = W by anyone - 0x1n = W by anyone logged in - 0x2n = W by Object or Supervisor - 0x3n = W by Supervisor only - 0x4n = W by Bindery only - */ - - LONG OwnerObjectID; /* Unique ID of owning object */ - LONG NextPropertyID; /* Link to next property node */ - LONG FirstValueID; /* Unique ID of first value node */ -}; - -struct ValueStructure -{ - LONG ValueID; - LONG OwnerPropertyID; /* Offset of owning property head */ - LONG NextValueID; /* Link to next value field */ - WORD SetNumber; /* Set number (1-0xFFFF) of this value node */ - BYTE ValueData[128]; /* portion ((set# - 1) * 128) of value */ -}; - -/* Definition of bindery login control structure */ -struct PassCtrlStruct -{ - BYTE Exp_Date[3]; - BYTE Acct_Expired; - BYTE Pass_Date[3]; - BYTE Pass_Grace; - WORD Exp_Interval; - BYTE Grace_Reset; - BYTE Min_Pass_Length; - WORD Max_Connections; - BYTE Time_BitMap[42]; - BYTE Last_Log_Time[6]; - BYTE RestrictionFlags; - BYTE UnknownInfo; - LONG MaxDiskBlocks; - WORD BadLogCount; - LONG NextResetTime; - BYTE BadStnAddress[12]; -}; - -/****************************************************************************/ -/* BIT DEFINITIONS */ - -#define READ_RIGHTS_MASK 0x0F -#define RFREE 0x00 -#define RANYONE 0x01 -#define ROBJECT 0x02 -#define RSUPER 0x03 -#define RBINDER 0x04 - -#define WRITE_RIGHTS_MASK 0xF0 -#define WFREE 0x00 -#define WANYONE 0x10 -#define WOBJECT 0x20 -#define WSUPER 0x30 -#define WBINDER 0x40 - -#define RMASK 0x0F -#define WMASK 0xF0 - -#define FDYNAMIC 0x01 -#define FGROUP 0x02 - -#define CHECK 0xFF -#define NOCHECK 0x00 - -/****************************************************************************/ -/* TYPE DEFINITIONS FOR OBJECTS */ - -#define TUNKNOWN 0 -#define TUSER 0x0100 -#define TUSERGROUP 0x0200 -#define TPRINTQ 0x0300 -#define TFILE_SERVER 0x0400 -#define TWILDCARD -1 - - -#define STATIC 0 -#define DYNAMIC 1 - - -/****************************************************************************/ - -/* External variable definitions */ - -extern BYTE BinderyOpen; -extern BYTE EnableAccounting; -extern LONG BinderSem; -extern LONG SuperID; -extern LONG ServerID; -extern int *BindHashTable; -extern LONG NumObjects; -extern int ObjectAvailQueue; -extern LONG NumProperties; -extern int PropertyAvailQueue; -extern LONG NumValues; -extern int ValueAvailQueue; - -extern BYTE *ACCT_LOCKOUT; -extern BYTE *BACK_LINKS; -extern BYTE *BALANCE; -extern BYTE *BLOCKS_READ; -extern BYTE *BLOCKS_WRITTEN; -extern BYTE *CONNECT_TIME; -extern BYTE *DISK_STORAGE; -extern BYTE *HOLD; -extern BYTE *HOME_DIRECTORY; -extern BYTE *LOG_CONTROL; -extern BYTE *MANAGERS; -extern BYTE *MEMBERS; -extern BYTE *MYGROUPPROP; -extern BYTE *NET_ADDRESS; -extern BYTE *NODE_CONTROL; -extern BYTE *OBJ_SUPERVISORS; -extern BYTE *OLDPASSPROP; -extern BYTE *OPERATORS; -extern BYTE *PASSPROP; -extern BYTE *Q_DIRECTORY; -extern BYTE *Q_OPERATORS; -extern BYTE *Q_SERVERS; -extern BYTE *Q_USERS; -extern BYTE *REQUESTS_MADE; -extern BYTE *SECURITY_EQUALS; - -/****************************************************************************/ -/****************************************************************************/ - - -#endif /* __BINDERY_H__ */ diff --git a/include/nwnss/support/lnxmbINC/bits.h b/include/nwnss/support/lnxmbINC/bits.h deleted file mode 100644 index 9d7bf7d..0000000 --- a/include/nwnss/support/lnxmbINC/bits.h +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** - | - | (C) Copyright 2004 Novell, Inc. - | All Rights Reserved. - | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. - | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. - | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. - | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com - | - |***************************************************************************/ - -/* define the DFlags bits */ - -#define OldDeletedFileBit 0x01 -#define PhantomEntryBit 0x02 -#define SubdirectoryEntryBit 0x04 -#define ExplicitlyNamedBit 0x08 -#define PrimaryNameBit 0x10 -#define NewDeletedFileBit 0x20 -#define HardLinkedEntryBit 0x40 - -/* */ - -#define READ_ACCESS_BIT 0x00000001 -#define WRITE_ACCESS_BIT 0x00000002 - -/* define the NameSpace values */ - -#define DOSNameSpace 0 -#define MACNameSpace 1 - -/* define the data stream values */ - -#define PrimaryDataStream 0 -#define MACResourceForkDataStream 1 -#define FTAMDataStream 2 - -/* The AFP SPG assumes these are the positions for these bits */ -#define MAC_DATA_FORK_OPEN 0x0100 -#define MAC_RES_FORK_OPEN 0x0200 -#define MAC_COPY_INHIBIT_BIT 0x0800 -#define MAC_RENAME_INHIBIT_BIT 0x4000 -#define MAC_DELETE_INHIBIT_BIT 0x8000 - -/* Attribute bits that can be set and returned by 286 calls */ -#define OLD_MAC_ATTRIBUTE_MASK 0x000017FF -#define OLD_DOS_ATTRIBUTE_MASK 0x000017FF - -/* definition of file attribute bits */ - -#define READ_ONLY_BIT 0x00000001 -#define HIDDEN_BIT 0x00000002 -#define SYSTEM_BIT 0x00000004 -#define EXECUTE_BIT 0x00000008 -#define SUBDIRECTORY_BIT 0x00000010 -#define ARCHIVE_BIT 0x00000020 -#define SHAREABLE_BIT 0x00000080 -#define OLD_PRIVATE_BIT 0x00000080 -#define NO_SUBALLOC_BIT 0x00000800 -#define SMODE_BITS 0x00000700 -#define TRANSACTION_BIT 0x00001000 -#define READ_AUDIT_BIT 0x00004000 -#define WRITE_AUDIT_BIT 0x00008000 -#define IMMEDIATE_PURGE_BIT 0x00010000 -#define RENAME_INHIBIT_BIT 0x00020000 -#define DELETE_INHIBIT_BIT 0x00040000 -#define COPY_INHIBIT_BIT 0x00080000 -#define FILE_AUDITING_BIT 0x00100000 -#define REMOTE_DATA_ACCESS_BIT 0x00400000 -#define REMOTE_DATA_INHIBIT_BIT 0x00800000 -#define REMOTE_DATA_SAVE_KEY_BIT 0x01000000 -#define COMPRESS_FILE_IMMEDIATELY_BIT 0x02000000 -#define DATA_STREAM_IS_COMPRESSED_BIT 0x04000000 -#define DO_NOT_COMPRESS_FILE_BIT 0x08000000 -#define CANT_COMPRESS_DATA_STREAM_BIT 0x20000000 -#define ATTR_ARCHIVE_BIT 0x40000000 -#define ZFS_VOLATILE_BIT 0x80000000 - - -#define DefinedAccessRightsBits 0x01FB /* all the bits currently used. */ -#define MaximumDirectoryAccessBits 0x01FF /* all the defined bits for access privileges */ -#define AllValidAccessBits 0x100001FF /* all the bits that are valid in CreateDirectory */ - -/* Attribute bits that can be set and returned by 386 calls */ -#define VALID_ATTRIBUTE_MASK 0x4ADF1FFF -#define INHERITED_DATA_STREAM_MASK ~DATA_STREAM_IS_COMPRESSED_BIT - - -/* note that some of these bits are defined in DIRCACHE.386, dstruct.inc., fileio.386 */ - -#define DELETE_FILE_ON_CREATE_BIT 0x0001 -#define NO_RIGHTS_CHECK_ON_CREATE_BIT 0x0002 - -/* bits used with Open File (besides the compatability bits defined in LOCKS.H). */ - -#define READ_ACCESS_BIT 0x00000001 -#define WRITE_ACCESS_BIT 0x00000002 -#define DENY_READ_BIT 0x00000004 -#define DENY_WRITE_BIT 0x00000008 -#define COMPATABILITY_MODE_BIT 0x00000010 -#define FILE_WRITE_THROUGH_BIT 0x00000040 -#define FILE_READ_THROUGH_BIT 0x00000080 - -#define ENABLE_IO_ON_COMPRESSED_DATA_BIT 0x00000100 -#define LEAVE_FILE_COMPRESSED_BIT 0x00000200 -#define DELETE_FILE_ON_CLOSE_BIT 0x00000400 -#define NO_UPDATE_LAST_ACCESSED_ON_CLOSE_BIT 0x80000000 /* Matches NSS definition in 6 pack*/ - -#define ALWAYS_READ_AHEAD_BIT 0x00001000 /* these two read ahead bits are mutually exclusive */ -#define NEVER_READ_AHEAD_BIT 0x00002000 /* if neither is set then NORMAL read ahead is used */ - -#define NO_RIGHTS_CHECK_ON_OPEN_BIT 0x00010000 - -#define ALLOW_SECURE_DIRECTORY_ACCESS_BIT 0x00020000 - -#define BIT_USED_BY_NSS_AFTER_NW65 0x00200000 - -#define OPEN_FILE_READ_WRITE_BITS (READ_ACCESS_BIT | WRITE_ACCESS_BIT | DENY_READ_BIT | DENY_WRITE_BIT | COMPATABILITY_MODE_BIT) -#define OPEN_FILE_EXCLUSIVE_BITS (READ_ACCESS_BIT | WRITE_ACCESS_BIT | DENY_READ_BIT | DENY_WRITE_BIT) -#define OPEN_FILE_COMPATABILITY_BITS (READ_ACCESS_BIT | WRITE_ACCESS_BIT | COMPATABILITY_MODE_BIT) -#define OPEN_FILE_PASS_THRU (FILE_WRITE_THROUGH_BIT | FILE_READ_THROUGH_BIT) -#define OPEN_FILE_READ_AHEAD_BITS (NEVER_READ_AHEAD_BIT | ALWAYS_READ_AHEAD_BIT) - -#define ALL_RIGHTS_BITS_MASK (OPEN_FILE_READ_WRITE_BITS | FILE_WRITE_THROUGH_BIT) - - -/* definition of access privledge bits for a given directory area */ - -#define ReadExistingFileBit 0x0001 -#define WriteExistingFileBit 0x0002 -#define OldOpenExistingFileBit 0x0004 -#define CreateNewEntryBit 0x0008 -#define DeleteExistingEntryBit 0x0010 -#define ChangeAccessControlBit 0x0020 -#define SeeFilesBit 0x0040 -#define ModifyEntryBit 0x0080 -#define SupervisorPrivilegesBit 0x0100 /* also defined in Dircache.386 */ - -/* used by create dir. or create file (both are OS Internal only) */ -#define CreateHardLinkEntryBit 0x10000000 -#define HasFileWritePrivilegeBit 0x2000 /* pass into AddFile ONLY */ - -#define DefinedAccessRightsBits 0x01FB /* all the bits currently used. */ -#define MaximumDirectoryAccessBits 0x01FF /* all the defined bits for access privileges */ -#define AllValidAccessBits 0x100001FF /* all the bits that are valid in CreateDirectory */ - -/* used by create directory only (DesigedAccessRights) Jim A. Nicolet*/ -#define ReqSystemBit 0x00100000 -#define ReqHiddenBit 0x00200000 -#define ReqDeleteInhibitBit 0x00400000 -#define ReqRenameInhibitBit 0x00800000 -#define ReqPurgeImmediateBit 0x01000000 -#define ReqImmediateCompressBit 0x02000000 -#define ReqDontCompressBit 0x04000000 - -#define ReqBitsMask1 (ReqSystemBit | ReqHiddenBit | ReqDeleteInhibitBit | ReqRenameInhibitBit | ReqPurgeImmediateBit) -#define ReqBitsMask (ReqBitsMask1 | ReqImmediateCompressBit | ReqDontCompressBit) - -/* Secure Directory Access Mask (_NETWARE) */ -#define SecureDirectoryAccessMask (ReqSystemBit | ReqHiddenBit | ReqPurgeImmediateBit) - -/* define the RDVolumeFlag bits */ - -#define VOLUME_AUDITING_BIT 0x01 /* system auditing */ -#define SUB_ALLOCATION_ENABLED_BIT 0x02 /* sub allocation units valid on this volume */ -#define FILE_COMPRESSION_ENABLED_BIT 0x04 /* file compression enabled on this volume */ -#define DATA_MIGRATION_ENABLED_BIT 0x08 /* data migration is allowed on this volume */ -#define NEW_TRUSTEE_COUNT_BIT 0x10 /* 3.2 Volumes have only 4 trustee entries per volume - instead of 6 */ -#define DIR_SVCS_OBJ_UPGRADED_BIT 0x20 /* Modify 3.2 volume DirObjId to - new position */ -#define VOLUME_IMMEDIATE_PURGE_ENABLED_BIT 0x40 /* Volume is marked as immediate purge */ diff --git a/include/nwnss/support/lnxmbINC/command.h b/include/nwnss/support/lnxmbINC/command.h deleted file mode 100644 index 8b13789..0000000 --- a/include/nwnss/support/lnxmbINC/command.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/nwnss/support/lnxmbINC/config.h b/include/nwnss/support/lnxmbINC/config.h deleted file mode 100644 index a9348c0..0000000 --- a/include/nwnss/support/lnxmbINC/config.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef __NSS_CONFIG_H__ -#define __NSS_CONFIG_H__ -/***************************************************************************** - * - * (C) Copyright 1988-1994 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $ - * $Revision: 1325 $ - * - ****************************************************************************/ - -/* 10 name spaces are the top end of allowable name spaces */ -#define MaximumNumberOfNameSpaces 6 -#define MaximumNumberOfVolumes 64 - -/* Leave room in ServerProcessStackSize for the memory management headers to - * be allocated in the same 4K block so we don't end up allocating another - * 4K block of memory.*/ -#define ServerProcessStackSize ((4096 * 8) - 128) -#define ServerProcessPriority 50 - -//Brenda -//#if ((FSEngine) || (IOEngine)) -////#define MaximumNumberOfIOLans 2048 - 16 -//#define MaximumNumberOfIOLans 256 - 16 -// -//#endif /* (FSEngine or IOEngine) */ - -//Brenda -//#if (IOEngine) -//#define MaximumNumberOfMSLs 8 -//#endif /* (IOEngine) */ - -//#define MaximumNumberOfLans 2048 -#define MaximumNumberOfLans 256 -#define MaximumNumberOfMediaTypes 32 -#define MaximumNumberOfProtocols 16 - -#define MAXMaximumSubdirectoryTreeDepth 100 -#define MaximumNumberOfDataStreams 3 -#define MaximumNumberOfSpoolPrinters 5 - -#define RestrictedServers 1 - -#define PseudoPreEmptionEnabled -1 -#define RealModeInterruptSupport -1 - -/* really defined in ipxparm.inc */ -#define MaximumNumberOfSockets 100 - -/* used in CDMAIN.C & NETMANC.C */ -#define COMPRESS_ERROR_COUNT 18 -#define UNCOMPRESS_ERROR_COUNT 18 - -/* used in FSHOOKS.C & NETMANC.C */ -#define NumberOfHookRoutines 23 - - -/******* - * No longer used in the server, only here for extern modules that may - * include this file - */ -#define HistogramEnabled 0 - -/****************************************************************************/ -/****************************************************************************/ - - -#endif /* __NSS_CONFIG_H__ */ diff --git a/include/nwnss/support/lnxmbINC/connect.h b/include/nwnss/support/lnxmbINC/connect.h deleted file mode 100644 index 05c0c39..0000000 --- a/include/nwnss/support/lnxmbINC/connect.h +++ /dev/null @@ -1,300 +0,0 @@ -#ifndef __CONNECT_H__ -#define __CONNECT_H__ -/***************************************************************************** - * - * (C) Copyright 1992-2000 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Revision: 465 $ - * - ****************************************************************************/ - -#define LegacyConnectionTag 0x4e4f434c /* LCON */ - -//////////////////////////////////////////////////////////////////////////////// -// Security Flags Definition // -// Used by --> LoginUser API // -//////////////////////////////////////////////////////////////////////////////// -#define CHECK_SECURITY 0x01 -#define AUTHENTICATE_INTERNAL 0x02 - - -//////////////////////////////////////////////////////////////////////////////// -// Connection Service Type Definitions // -//////////////////////////////////////////////////////////////////////////////// -#define RESERVED_OS_CONNECTION_TYPE 0 -#define RESERVED_CLIB_CONNECTION_TYPE 1 -#define NCP_CONNECTION_TYPE 2 -#define NLM_CONNECTION_TYPE 3 -#define AFP_CONNECTION_TYPE 4 -#define FTAM_CONNECTION_TYPE 5 -#define ANCP_CONNECTION_TYPE 6 -#define NCT_CONNECTION_TYPE 7 -#define SMB_CONNECTION_TYPE 8 -#define WINSOCK_CONNECTION_TYPE 9 -#define HTTP_CONNECTION_TYPE 10 -#define UDP_CONNECTION_TYPE 11 - -#define MAXIMUM_CONNECTION_SERVICE_TYPES 15 - -//////////////////////////////////////////////////////////////////////////////// -// Transport Address Type Definitions // -//////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_SERVER_ADDRESS 0 -#define IPX_TRANSPORT_ADDRESS 1 -#define IP_TRANSPORT_ADDRESS 2 -#define DDP_TRANSPORT_ADDRESS 3 -#define NETBEUI_TRANSPORT_ADDRESS 4 -#define TCP_TRANSPORT_ADDRESS 5 -#define UDP_TRANSPORT_ADDRESS 6 -#define MAC_IP_TRANSPORT_ADDRESS 7 - -#define MAXIMUM_TRANSPORT_ADDRESS_TYPES 8 - -//////////////////////////////////////////////////////////////////////////////// -// Control Flags Definition // -// Used when calling --> CheckConnectionLicense API // -// --> AuthenticateConnection API // -//////////////////////////////////////////////////////////////////////////////// -#define NOT_CONNECTED 1 -#define NOT_AUTHENTICATED 2 -#define TEMPORARY_AUTHENTICATED 3 -#define PERMANENT_AUTHENTICATED 4 -#define INTERNAL_AUTHENTICATED 5 - -#define PERMANENT_CONNECTION 0x00 -#define TEMPORARY_CONNECTION 0x01 -#define LOGIN_WITH_HIGH_PRIVILEGES 0x02 -#define INTERNAL_CONNECTION 0x04 - -////////////////////////////////////////////////////////////////////////////// -// Connection Privileges Bit Definitions - // -////////////////////////////////////////////////////////////////////////////// -#define SUPERVISOR 0x00000001 -#define CONSOLE_OPERATOR 0x00000002 -#define AUDITOR 0x00000004 -#define HIGH_PRIVILEGES 0x00000008 -#define SECOND_AUTHENTICATION 0x00000010 -#define SECOND_HIGH_PRIVILEGES 0x00000020 - - -////////////////////////////////////////////////////////////////////////// -// Connection Status Definitions - // -////////////////////////////////////////////////////////////////////////// -#define LOGGED_IN 0x00000001 -#define BEING_ABORTED 0x00000002 -#define AUDITED 0x00000004 -#define NEEDS_SECURITY_CHANGE 0x00000008 -#define MAC_STATION 0x00000010 -#define AUTHENTICATED_TEMPORARY 0x00000020 -#define AUDIT_CONNECTION_RECORDED 0x00000040 -#define DSAUDIT_CONNECTION_RECORDED 0x00000080 -#define LOGOUT_IN_PROGRESS 0x00000100 -#define INTERNAL_LOGIN 0x00000200 -#define BINDERY_CONNECTION 0x00000400 -#define AUTHENTICATE_IN_PROGRESS 0x00000800 -#define UTF8_NCP_STRINGS_ENABLED 0x00001000 -#define STATION_ACTIVE_NDSID_CACHE 0x40000000 -#define REMOTE_EVENTS_CONNECTION 0x80000000 - -//////////////////////////////////////////////////////////////////////////////// -// File System Write Control Flags // -//////////////////////////////////////////////////////////////////////////////// -#define ACTIVE_FILE_TO_FILE_WRITE 0x01 -#define STOP_FILE_TO_FILE_WRITE 0x02 - - -//////////////////////////////////////////////////////////////////////////////// -// ClearNCPExtension Caller ID // -//////////////////////////////////////////////////////////////////////////////// -#define Case255Called 0x01101001 -#define NCPKillStaCalled 0x02202002 -#define LogoutConnCalled 0x03303003 -#define RtnAConnCalled 0x04404004 - -//////////////////////////////////////////////////////////////////////////////// -// Lock Type Flag // -//////////////////////////////////////////////////////////////////////////////// -#define USAGE_LOCK_FLAG 0x00000001 -#define EXCLUSIVE_LOCK_FLAG 0x00000002 - - -//////////////////////////////////////////////////////////////////////////////// -///// Used by the Legacy File System ///// -//////////////////////////////////////////////////////////////////////////////// -struct LockWaitStructure -{ -/* 0000 */ struct ConnectionStructure *myConnection; -/* 0004 */ struct LockWaitStructure *connectionWaitLink; -/* 0008 */ struct LockWaitStructure *queueLink; -/* 000c */ struct FLockNode *waitNode; -/* 0010 */ struct LockWaitStructure *delayLink; -/* 0014 */ LONG waitTask; -/* 0018 */ WORD waitType; -/* 001a */ WORD waitState; -/* 001c */ LONG recordStamp; -/* 0020 */ LONG waketime; -/* 0024 */ void (*reply)(LONG connectionNumber, LONG completionCode, LONG taskNumber); -/* 0028 */ LONG queueStamp; -/* 002c */ struct LockWaitStructure *relQueueLink; -/* 0030 */ struct PRecNode *waitRecord; -/* 0034 */ struct PListNode *waitListRecord; -/* 0038 */ LONG XFSwaitVol; -/* 003c */ LONG XFSwaitID; -}; - - -/* ----------------------------------------------------------------------- */ -/* Case 72 Control structures for Transport Independence -- allocated by the AllocateConnectionSlot routine */ -struct LargeReadControlStruc -{ - LONG LRCreqpck; /* ;current request packet */ - LONG LRCstationNumber; - LONG LRCreplyvector; /* reply vector pointer */ - LONG LRCcompletionCode; /* completion code */ - LONG LRCstartingOffset; /* where to read from */ - LONG LRCcacheCount; /* number of cache buffers used */ - LONG LRCleftToBeDone; /* amount left to be processed */ -}; - -struct LRCaSyncControlStruc -{ - LONG lrcAESRAddress; - LONG lrcACacheBufferDataOffset; - LONG lrcACacheReleaseHandle; - LONG lrcAAmountOfDataRead; - LONG lrcCSIpointer; - LONG lrcASyncDummy[3]; -}; - -struct LargeReadNodeStruc -{ - struct LargeReadControlStruc cNode; - struct LRCaSyncControlStruc asyncNodes[32]; // max 16 + 3 + frag0 + frag1 -}; - -#ifndef UINT64 -#define UINT64 long long -#endif - -/////////////////////////////////////////////////////////////////////////////// -//// Processor 0 Connection Structure Definition //// -/////////////////////////////////////////////////////////////////////////////// -struct ConnectionStructure -{ -// The following fields are READ ONLY from any processor - LONG signature; // READ ONLY - LONG connectionNumber; // READ ONLY - LONG connectionServiceType; // READ ONLY - -// Jim A. Nicolet - 9-7-2000 - Moved these here for NSS direct access - UINT64 totalBytesRead; - UINT64 totalBytesWritten; - LONG totalRequests; - - -/* File and lock control */ - struct ASyncLockWaitStructure *lockWaitList; - - /* These two list heads and count must be contiguous in memory */ - struct DirectoryHandleStructure *activeDirectoryHandles; - struct DirectoryHandleStructure *freeDirectoryHandles; - LONG freeDirectoryHandlesCount; - LONG directoryHandleAllocLock; - - LONG *extendedAttributeHandles; - - struct LockWaitStructure lockWait; /* size == 64 (0x40) bytes */ - - LONG transactionFlag; - LONG logicalLockThreshold; - LONG recordLockThreshold; - LONG fileWriteFlags; /* Includes active and stop bits */ - LONG fileWriteState; - WORD searchMapNumber; - WORD searchFiller; - struct DanglingSearchStructure *danglingSearchList; - struct SearchMapStructure *searchMapList; - LONG nextNCPSearchLimitNotifyTime; - struct FileListNode *fileLockList; - struct RecListNode *recordLockList; - struct SemListNode *sems; - struct TransListNode *lockTransactionList; - WORD fileLockCount; - WORD recordLockCount; - struct FileControlBlockStructuredef *openFileFCBs; - - /* Transaction tracking */ - struct TransactionNodeStructure *activeTransactions; - - /* Printing */ -/* */ BYTE printFlags; -/* */ BYTE printTabSize; -/* */ BYTE numberOfPrintCopies; -/* */ BYTE printToFileFlag; -/* */ BYTE printBanner[14]; -/* */ BYTE targetPrinter; -/* */ BYTE formType; -/* */ LONG printSpoolVolume; -/* */ LONG printSpoolEntryNumber; -/* */ LONG printSpoolHandle; -/* */ LONG printSpoolIOCount; - - /* Accounting */ -/* */ LONG holdTime; -/* */ LONG holdAmount; -/* */ LONG chargeAmount; -/* */ LONG heldConnectTimeInMinutes; -/* */ LONG heldRequests; -/* */ BYTE heldBytesRead[6]; -/* */ BYTE heldBytesWritten[6]; - - /* Auditing */ -/* */ LONG auditVolume; -/* */ LONG auditContainer; -/* */ WORD auditLoginAttempts; -/* */ BYTE auditPrevFileNumber; -/* */ BYTE auditTemp; -/* */ LONG auditRightsCacheSize; -/* */ LONG *auditRightsCache; - -/* Security */ -/* */ LONG sessionKey[2]; -/* */ LONG messageDigest[4]; -/* */ LONG oldMessageDigest[4]; - -/* Session */ -/* */ LONG completionFlagBits; -/* */ LONG sessionActiveFlags; -/* */ void *serviceInfo; -/* */ LONG (*ServiceInfoFunction)(LONG connectionNumber, LONG function, void *serviceInfo, ...); - - /* Misc. Control */ -/* */ LONG NumberOfEAHandles; /* used to generate an id for a client */ -/* */ LONG NCPDataSize; /* default is 538 */ -/* */ LONG maxNumberOfReadCacheBuffers; /* does not include the 3 extra buffers needed for sub alloc */ -/* */ void *largeReadControl; /* pointer to struct LargeReadControlStruc * */ -/* */ struct LargeReadNodeStruc readNode; //object cache -/* */ void *idCache; -}; - -#endif /* __CONNECT_H__ */ diff --git a/include/nwnss/support/lnxmbINC/connexp.h b/include/nwnss/support/lnxmbINC/connexp.h deleted file mode 100644 index 487270c..0000000 --- a/include/nwnss/support/lnxmbINC/connexp.h +++ /dev/null @@ -1,465 +0,0 @@ -#ifndef __CONNEXPLNX_H__ -#define __CONNEXPLNX_H__ -/***************************************************************************** - * - * (C) Copyright 2000 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - ****************************************************************************/ -struct ConnectionStructure; -struct BroadcastMessageStructure; -struct ResourceTagStructure; - -/***************************************************************************** - * - * InfoRequestMask definitions for EnumConnectionInformation API - * - ****************************************************************************/ -#define irmTransportInfo 0x00000001 -#define irmTimeInfo 0x00000002 -#define irmNameInfo 0x00000004 -#define irmLockInfo 0x00000008 -#define irmPrintInfo 0x00000010 -#define irmStatsInfo 0x00000020 -#define irmAccountingInfo 0x00000040 -#define irmAuthenticationInfo 0x00000080 -#define irmLanguageInfo 0x00000100 - -#define irmMask (irmTransportInfo | irmTimeInfo | irmNameInfo | irmLockInfo | irmPrintInfo | irmStatsInfo | irmAccountingInfo | irmAuthenticationInfo | irmLanguageInfo) - -/***************************************************************************** - * - * Module: cmgrTable.c - * - ****************************************************************************/ - -extern struct ConnectionStructure *MapStationToConnectionStructure(LONG connectionNumber); - -extern LONG numberOfConnectionSlots; - -extern LONG EnumConnectionInformation( - LONG infoRequestMask, - LONG ListCount, - LONG *connList, - LONG BufferSize, - LONG *infoItems, - BYTE *buffer, - LONG *bytesUsed); - -extern BYTE GetConnectionType(LONG connectionNumber); - -extern LONG GetConnectionTime( - LONG connectionNumber, - LONG *connectTimeInMinutes, /* Optional: NULL */ - BYTE *connectionLoginTime); /* Optional: NULL or 7 bytes */ - -extern LONG GetConnectionTimeEx( - LONG connectionNumber, - LONG *connectTimeInMinutes, /* Optional: NULL */ - BYTE *connectionLoginTime, /* Optional: NULL or 7 bytes */ - LONG *connectionExpirationTime); /* Optional: NULL */ - -extern LONG GetConnectionStatistics( - LONG connectionNumber, - LONG *totalRequests, /* Optional: NULL */ - BYTE *totalBytesRead, /* Optional: NULL */ - BYTE *totalBytesWritten); /* Optional: NULL */ - -extern LONG GetConnectionUseCount(LONG connectionNumber); - -extern LONG GetConnectionPSS(LONG connectionNumber, void **pOld); - -extern LONG SetConnectionPSS(LONG connectionNumber, void *pNewPSSAddress, void **pOld); - -extern LONG SetConnectionCodePage(LONG Station, LONG CodePage); - -extern LONG MapConnectionToInternetAddress(LONG stationNumber, BYTE *address); - -extern LONG AdjustWatchdogInterval(LONG connectionNumber, LONG delayIntervalInMinutes); - -extern LONG AllocateConnectionSlot( - struct ResourceTagStructure *connectionResourceTag, - LONG connectionServiceType, - LONG userData, /* user supplied data field */ - LONG (*connectionInitializationFunction)(LONG newConnectionNumber, LONG userData), - LONG *returnNewConnectionNumber); - -extern LONG ReturnAConnectionNumber(LONG connectionNumber, BYTE connectionServiceType); - -extern LONG GetConnectionTransportAddress( - LONG connectionNumber, - LONG *transportAddressType, - LONG *transportAddressLength, - LONG transportBufferLength, - BYTE *transportAddressBuffer); - - -/***************************************************************************** - * - * Module: cmgrMisc.c - * - ****************************************************************************/ - -extern LONG GetNumberOfRestrictedStations(void); - -extern LONG GetLicenseSerialNumber(void); - -extern LONG GetLicenseApplicationNumber(void); - -extern LONG CheckSerial(BYTE *serialNumber); - -extern LONG GetConnectionLicensesInUse(void); - -extern LONG GetPeakConnectionLicensesUsed(void); - -extern void GetSerialNumber(LONG *serialNumber); - -extern void GetApplication(WORD *applicationNumber); - -/***************************************************************************** - * - * Module: cmgrStatus.c - * - ****************************************************************************/ - -extern LONG GetConnectionStatus(LONG connectionNumber, LONG *status); - -extern LONG SetConnectionStatus(LONG connectionNumber, LONG newStatus); - -extern LONG ClearConnectionStatus(LONG connectionNumber, LONG statusMask); - -/***************************************************************************** - * - * Module: cmgrIdentity.c - * - ****************************************************************************/ - -extern LONG UpdateConnectionZeroIds(LONG ServerID, LONG SuperID); - -extern void UpdateConnectionZeroIdentity(LONG serverObjectID, LONG supervisorObjectID); - -extern LONG ConnectionIsLoggedIn(LONG connectionNumber); - -extern LONG IsSupervisor(LONG connectionNumber); - -extern LONG IsEquivalent(LONG station, LONG ID); - -extern LONG IsConnectionValid(LONG connectionNumber); - -extern LONG IsConsoleOperator(LONG connectionNumber); - -extern LONG ChangeConnectionAuthenticationStatus(LONG connectionNumber, BYTE requestCode); - -extern LONG GetConnectionAuthenticationState(LONG connectionNumber); - -extern LONG GetConnectionAuthenticatedIdentity( - LONG connectionNumber, - BYTE *objectNameBuffer, /* Optional: NULL */ - LONG *objectType, /* Optional: NULL */ - LONG *objectID); /* Optional: NULL */ - -extern LONG GetConnectionAuthIDsList( - LONG connectionNumber, - void *allocRTag, - LONG *numberOfAuthenticatedIDs, - LONG **pAuthIDsList); - -extern LONG LoggedUserID(LONG connectionNumber); - -extern LONG LoggedRealUserID(LONG connectionNumber); - -extern LONG MapUserToStn( - LONG connectionNumber, - BYTE *objectName, - LONG objectType, - BYTE *answerBuffer); - -extern LONG MapUserToStationList( - LONG connectionNumber, - BYTE *objectName, - LONG objectType, - LONG lastConnection, - LONG bufferSize, - BYTE *answerBuffer); - -extern LONG MapObjectToStationList( - LONG objectID, - LONG lastConnection, - LONG bufferSize, - BYTE *answerBuffer); - -/***************************************************************************** - * - * Module: cmgrAccount.c - * - ****************************************************************************/ - -extern LONG GetAccountingVersionNumber(void); - -extern LONG AccountCharge( - LONG station, - LONG serviceType, - LONG clientID, - long chargeAmount, - long holdCancelAmount, - WORD commentType, - WORD commentLen, - void *comment); - -extern LONG AccountHold( - LONG station, - LONG clientID, - int holdAmount); - -extern LONG AccountNote( - LONG station, - LONG serviceType, - LONG clientID, - WORD commentType, - WORD commentLen, - BYTE *comment); - -extern LONG INWGetAccountStatus( - LONG station, - LONG clientID, - BYTE *accountInfo); - -extern LONG AccountRequest( - LONG station, - LONG request, - BYTE *info, - BYTE *ans, - LONG *answerLength, - LONG packetSubFunctionLength); - -/***************************************************************************** - * - * Module: cmgrBroadcast.c - * - ****************************************************************************/ - -extern LONG INWSendBroadcastMessage( - BYTE *TextMessage, - LONG TextLength, - LONG TargetStationCount, - LONG *TargetStationList, - LONG AllStations); - -extern LONG LogBroadcastMessage( - LONG TargetStation, - struct BroadcastMessageStructure *Message, - LONG SystemMessageFlag); - -extern LONG INWGetBroadcastMessage( - LONG Station, - BYTE *Text); - -extern LONG SetAcceptBroadcastMessages( - LONG connectionNumber, - BYTE acceptBroadcastMessageFlag); - -extern LONG ExtendedLogBroadcastMessage( - LONG targetStation, - struct BroadcastMessageStructure *message, - LONG systemMessageFlag); - -extern LONG ExtendedGetBroadcastMessage( - LONG station, - BYTE *text); - -extern void WaitForBroadcastsToClear(void); - -/***************************************************************************** - * - * Module: cmgrMessage.c - * - ****************************************************************************/ - -#define MESSAGE_LOCK_ENGINE_TYPE 0x3131 -#define MESSAGE_EVENT_CALLBACK_TYPE 0x2626 - -extern LONG SendConnectionMessage( - LONG connectionNumber, - LONG messageLength, - void *message); - -extern LONG ConnectionMessageControl( - LONG Station, - LONG ControlBits, - LONG listCount, - LONG *connectionListPtr, - LONG connectionType); - -/***************************************************************************** - * - * Module: cmgr97.c - * - ****************************************************************************/ - -extern LONG GetConnectionCase97Info(LONG connection, LONG flag, void *pECB, void *pRequest, LONG LIPflag, void *pAnswerBuffer); - -extern LONG GetConnectionMaximumPacketSize(LONG connection, void *pECB, LONG *pRtnSize); - -extern LONG ConnectionServiceInfoFunction(LONG connectionNumber, LONG function); - -extern LONG GetMaximumReplyBufferSize(LONG connectionNumber); - -/***************************************************************************** - * - * Module: cmgrLogin.c - * - ****************************************************************************/ - -extern LONG CheckConnectionState(LONG stationNumber); - -extern LONG RestoreLoginState(LONG connectionNumber); - -extern LONG LogoutConnection(LONG connectionNumber); - -extern LONG LoginUser( - LONG connectionNumber, - BYTE *objectName, - LONG objectType, - BYTE *password, - LONG passwordEncryptedFlag, - LONG enforceSecurityFlag); - -extern LONG GetLocalLoginInfo(LONG *pInfo); - -extern LONG KillStation2(LONG station, LONG connectionNumber, LONG suicideFlag); - -extern LONG KillStation(LONG connectionNumber, LONG suicideFlag); - -extern LONG GetLogAllowed(void); - -extern LONG SetLogAllowed(LONG newLogAllowedValue); - -/***************************************************************************** - * - * Module: cmgrHandle.c - * - ****************************************************************************/ - -extern LONG InitializeConnectionNCPHandle(LONG connectionNumber, LONG LoginDirectoryNumber, void *pCallbackFunction); - -extern LONG FreeConnectionTempNCPHandles(LONG connectionNumber, LONG Task); - -extern LONG FreeConnectionNCPHandles(LONG connectionNumber); - -extern LONG ClearConnectionNCPHandlesForVolume(LONG connectionNumber, LONG volumeNumber); - -extern LONG CheckNCPDirectoryHandles( - LONG checkingConnectionNumber, - LONG Volume, - LONG DirectoryNumber); - -extern LONG ClearConnectionNCPHandlesVolumeDirBase(LONG connectionNumber, LONG volumeNumber, LONG directoryNumber); - -extern LONG ChangeConnectionNCPHandles(LONG connectionNumber, LONG volumeNumber, LONG OldDirectoryNumber, LONG NewDirectoryNumber); - -extern LONG ReturnConnectionNCPHandleValue( - LONG connectionNumber, - LONG Task, - LONG handleType, - LONG volumeNumber, - LONG DirectoryNumber, - LONG *pDirectoryHandleValue); - -extern LONG CreateAndAddNCPHandleToConnection( - LONG connectionNumber, - LONG *pnewDirectoryHandleValue, - LONG handleType, - LONG Task, - LONG volumeNumber, - LONG DOSDirectoryNumber, - LONG DirectoryNumber, - LONG NameSpace, - void (*pDestructionNotifyCallback)(LONG directoryHandleValue, LONG myConnectionNumber)); - -extern LONG ConnectionDestroyNCPHandle(LONG connectionNumber, LONG DirectoryHandleValue); - -extern LONG ModifyConnectionNCPHandle( - LONG connectionNumber, - LONG DirectoryHandleValue, - LONG modifyHandleTypeFlag, - LONG HandleType, - LONG modifyTaskFlag, - LONG Task, - LONG modifyVolumeFlag, - LONG Volume, - LONG modifyDOSDirectoryBaseFlag, - LONG DOSDirectoryBase, - LONG modifyDirectoryBaseFlag, - LONG DirectoryBase, - LONG modifyNameSpaceFlag, - LONG NameSpace, - LONG modifyCallbackAddress, - void (*newCallbackAddress)(LONG, LONG)); - -extern LONG CheckConnectionNCPHandleUseCount(LONG connectionNumber, LONG DirectoryHandleValue, LONG *pUseCount); - -extern LONG ReturnConnectionNCPHandleInfo( - LONG connectionNumber, - LONG DirectoryHandleValue, - LONG *pHandleType, - LONG *pTask, - LONG *pVolume, - LONG *pDOSDirectoryBase, - LONG *pDirectoryBase, - LONG *pNameSpace); - -/***************************************************************************** - * - * Module: cmgrTasks.c - * - ****************************************************************************/ - -extern LONG AllocateConnectionTasks( - LONG connectionNumber, - LONG numberOfTasks, - LONG *firstTaskNumber, - struct ResourceTagStructure *resourceTag); - -extern LONG FreeConnectionTasks( - LONG numberOfTasks, - LONG firstTaskNumber, - LONG connectionNumber, - struct ResourceTagStructure *resourceTag); - -/***************************************************************************** - * - * Module: cmgrEncrypt.c - * - ****************************************************************************/ - -extern LONG NewLogKey(LONG stationNumber, BYTE *ans); - -extern LONG GetLogKey(LONG connectionNumber, BYTE *loginChallengeKeyBuffer); - -extern void FreeLogKey(LONG connectionNumber); - -extern LONG IsNullKey(LONG connectionNumber, LONG objectID, BYTE *Key); - -/***************************************************************************** - * - * Module: - * - ****************************************************************************/ - -#endif // __CONNEXPLNX_H__ - diff --git a/include/nwnss/support/lnxmbINC/doscalls.h b/include/nwnss/support/lnxmbINC/doscalls.h deleted file mode 100644 index 8b13789..0000000 --- a/include/nwnss/support/lnxmbINC/doscalls.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/nwnss/support/lnxmbINC/enable.h b/include/nwnss/support/lnxmbINC/enable.h deleted file mode 100644 index 69c2677..0000000 --- a/include/nwnss/support/lnxmbINC/enable.h +++ /dev/null @@ -1,294 +0,0 @@ -#ifndef __ENABLE_H__ -#define __ENABLE_H__ -/***************************************************************************** - * - * (C) Copyright 1988-1994 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Revision: 465 $ - * - ****************************************************************************/ - -/* - NetWare/386 - Header file for language enabling - - Written by: Lloyd Honomichl - Date: January 16, 1991 -*/ - -/****************************************************************************/ - -/* - number of defined languages as well as their ID numbers -*/ - -#define CanadianFrenchLanguageID 0 -#define ChineseLanguageID 1 /* simplified */ -#define DanishLanguageID 2 -#define DutchLanguageID 3 -#define EnglishLanguageID 4 -#define FinnishLanguageID 5 -#define FrenchLanguageID 6 -#define GermanLanguageID 7 -#define ItalianLanguageID 8 -#define JapaneseLanguageID 9 -#define KoreanLanguageID 10 -#define NorwegianLanguageID 11 -#define PortugueseLanguageID 12 /* Brazil */ -#define RussianLanguageID 13 -#define SpanishLanguageID 14 /* Latin America */ -#define SwedishLanguageID 15 -#define ChineseTradLanguageID 16 /* traditional */ -#define PolishLanguageID 17 -#define PortuguesePortLanguageID 18 /* Portugal */ -#define SpanishSpainLanguageID 19 /* Spain */ -#define HungarianLanguageID 20 /* HUNGARIAN */ -#define CzechLanguageID 21 /* Czech */ -#define ArabicLanguageID 22 /* Arabic */ -#define HebrewLanguageID 23 /* Hebrew */ -#define ThaiLanguageID 24 /* Thai */ -#define TurkeyLanguageID 25 /* Turkey */ -#define GreekLanguageID 26 /* Greek */ - -#define NumberOfPreDefinedLanguages 27 - -/* extra languague number range, not inclusive (valid is 100-999) */ -#define MIN_LANGUAGE_ID 99 -#define MAX_LANGUAGE_ID 1000 - -/* - The os language table (indexed by language ID) -*/ - -extern BYTE *OSLanguageName[NumberOfPreDefinedLanguages]; - -/* - Extra Language list structure -*/ -struct ExtraLanguageStructure -{ - struct ExtraLanguageStructure *next; - struct ExtraLanguageStructure *prev; - int LanguageID; - BYTE *LanguageName; -}; - -extern struct ExtraLanguageStructure *ExtraLanguageListHead; - -/* - DOS Country info structure -*/ -struct DOSCountryInfoStructure -{ - WORD dateFmt; /* Date format */ - BYTE currencySym[5]; /* Currency symbol */ - BYTE thousandSep[2]; /* Thousands separator */ - BYTE decimalSep[2]; /* Decimal separator */ - BYTE dateSep[2]; /* Date separator */ - BYTE timeSep[2]; /* Time separator */ - BYTE currencyFmt; /* Currency format */ - BYTE currencyDig; /* Significant digits in currency */ - BYTE timeFmt; /* Time format */ - LONG caseMapRoutine; /* Routine to call for case mapping */ - BYTE dataListSep[2]; /* Data list separator */ - BYTE reserved[10]; /* Reserved */ -}; - -struct NWEXTENDED_COUNTRY_INFO -{ - BYTE infoID; /* ?? */ - WORD size; /* ?? */ - WORD countryID; - WORD codePage; - WORD dateFormat; - BYTE currencySymbol[5]; - BYTE thousandSeparator[2]; - BYTE decimalSeparator[2]; - BYTE dateSeparator[2]; - BYTE timeSeparator[2]; - BYTE currencyFormatFlags; - BYTE digitsInCurrency; - BYTE timeFormat; - BYTE junk[4]; /* Would have pointed to upper case function*/ - BYTE dataListSeparator[2]; - BYTE PAD[10]; -}; - - -extern struct DOSCountryInfoStructure DOSCountryInfo; - -extern WORD DOSCountryID; -extern WORD DOSCodePage; - -extern BYTE *weekDayNames[]; /* Names of weekdays */ -extern BYTE *monthNames[]; /* Names of months */ -extern BYTE *monthAbbrevs[]; -extern BYTE *ENGLISHmonthNames[]; -extern BYTE *ENGLISHweekDayNames[]; -extern BYTE *ENGLISHmonthAbbrevs[]; - - -extern LONG OSDoubleByteSpace; /* value for space character */ - -/* - Flags passed to date and time formatting routines -*/ -#define EN_INCLUDE_SECONDS 0x01 /* Include seconds in time */ -#define EN_INCLUDE_WEEKDAY 0x02 /* Include the day of the week in date */ -#define EN_USE_ALPHA_MONTH 0x04 /* Use month name, not number */ -#define EN_USE_4_DIGIT_YEAR 0x08 /* Print four digit year */ -#define EN_USE_ABBREV_MONTH 0x10 /* Use month abbreviation, not number */ -#define EN_INCLUDE_MILLISECONDS 0x20 /* Add Milliseconds to the time */ -#define EN_INCLUDE_MILLISECONDS_LAST (0x40 | 0x20) /* Use last generated MS value */ - -/* - Buffer lengths required for formatting dates and times. The numeric - format lengths are known, but those with text for the day of the week - and the month are padded, since we don't know how long they may be - after translation -*/ -#define EN_TIME_LEN 14 /* HH:MM:SS.MSSam */ -#define EN_DATE_LEN 11 /* MM/DD/YYYY */ -#define EN_DATE_TIME_LEN 27 /* MM/DD/YYYY HH:MM:SS.MSSam */ -#define EN_TEXT_DATE_LEN 84 /* Wednesday September 31, 1990 HH:MM:SS.MSSam*/ - -/****************************************************************************/ -/* - Line draw character macros -*/ - -/* Ä */ -#define LDC_H1 OSLineDrawCharTable[0] -/* Í */ -#define LDC_H2 OSLineDrawCharTable[1] -/* ³ */ -#define LDC_V1 OSLineDrawCharTable[2] -/* º */ -#define LDC_V2 OSLineDrawCharTable[3] -/* Ú */ -#define LDC_UL1 OSLineDrawCharTable[4] -/* ¿ */ -#define LDC_UR1 OSLineDrawCharTable[5] -/* À */ -#define LDC_LL1 OSLineDrawCharTable[6] -/* Ù */ -#define LDC_LR1 OSLineDrawCharTable[7] -/* É */ -#define LDC_UL2 OSLineDrawCharTable[8] -/* » */ -#define LDC_UR2 OSLineDrawCharTable[9] -/* È */ -#define LDC_LL2 OSLineDrawCharTable[10] -/* ¼ */ -#define LDC_LR2 OSLineDrawCharTable[11] -/* Á */ -#define LDC_UT1 OSLineDrawCharTable[12] -/* Â */ -#define LDC_DT1 OSLineDrawCharTable[13] -/* ´ */ -#define LDC_LT1 OSLineDrawCharTable[14] -/* Ã */ -#define LDC_RT1 OSLineDrawCharTable[15] -/* Ð */ -#define LDC_UT12 OSLineDrawCharTable[16] -/* Ò */ -#define LDC_DT12 OSLineDrawCharTable[17] -/* µ */ -#define LDC_LT12 OSLineDrawCharTable[18] -/* Æ */ -#define LDC_RT12 OSLineDrawCharTable[19] -/* Ï */ -#define LDC_UT21 OSLineDrawCharTable[20] -/* Ñ */ -#define LDC_DT21 OSLineDrawCharTable[21] -/* ¶ */ -#define LDC_LT21 OSLineDrawCharTable[22] -/* Ç */ -#define LDC_RT21 OSLineDrawCharTable[23] -/* Ê */ -#define LDC_UT2 OSLineDrawCharTable[24] -/* Ë */ -#define LDC_DT2 OSLineDrawCharTable[25] -/* ¹ */ -#define LDC_LT2 OSLineDrawCharTable[26] -/* Ì */ -#define LDC_RT2 OSLineDrawCharTable[27] -/* Ö */ -#define LDC_UL12 OSLineDrawCharTable[28] -/* · */ -#define LDC_UR12 OSLineDrawCharTable[29] -/* Ó */ -#define LDC_LL12 OSLineDrawCharTable[30] -/* ½ */ -#define LDC_LR12 OSLineDrawCharTable[31] -/* Õ */ -#define LDC_UL21 OSLineDrawCharTable[31] -/* ¸ */ -#define LDC_UR21 OSLineDrawCharTable[33] -/* Ô */ -#define LDC_LL21 OSLineDrawCharTable[34] -/* ¾ */ -#define LDC_LR21 OSLineDrawCharTable[35] -/* Å */ -#define LDC_X1 OSLineDrawCharTable[36] -/* × */ -#define LDC_X12 OSLineDrawCharTable[37] -/* Ø */ -#define LDC_X21 OSLineDrawCharTable[38] -/* Î */ -#define LDC_X2 OSLineDrawCharTable[39] -/*  */ -#define LDC_UP OSLineDrawCharTable[40] -/*  */ -#define LDC_DOWN OSLineDrawCharTable[41] -/*  */ -#define LDC_LEFT OSLineDrawCharTable[42] -/*  */ -#define LDC_RIGHT OSLineDrawCharTable[43] -/* ° */ -#define LDC_BG1 OSLineDrawCharTable[44] -/* ± */ -#define LDC_BG2 OSLineDrawCharTable[45] -/* ² */ -#define LDC_BG3 OSLineDrawCharTable[46] -/* Û */ -#define LDC_BG4 OSLineDrawCharTable[47] - -/****************************************************************************/ -/****************************************************************************/ - -/* ProcessLocaleConfigFile - * - * This procedure is designed to be used by the INSTALL NLM. It should be - * called before the name space NLMs are loaded and initialized. It should - * be called before the volumes are mounted. It should be called before the - * screen driver is loaded. It should be called before vrepair is loaded. - * It should be called before anything else that takes a snapshot of the - * locale tables. - */ - -extern LONG ProcessLocaleConfigFile( - struct ScreenStruct *screenID, - BYTE *fileName); - -extern LONG ResetFileServerName( - BYTE *newFileServerName); - -#endif /* __ENABLE_H__ */ diff --git a/include/nwnss/support/lnxmbINC/encp.h b/include/nwnss/support/lnxmbINC/encp.h deleted file mode 100644 index b9f885e..0000000 --- a/include/nwnss/support/lnxmbINC/encp.h +++ /dev/null @@ -1,2375 +0,0 @@ -#ifndef __ENCP_H__ -#define __ENCP_H__ -/***************************************************************************** - * - * (C) Copyright 1988-1996 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Revision: 465 $ - * - ****************************************************************************/ - -/* - - -FILE ENCP.H - Extended 3.1 NCPs for generic clients - - written by: Brady Anderson - March 15, 1990 -*/ - -#define NTCLIENTECO 1 -#define CROSSNAMEFIX 1 /* defect 100253657 - RDoxey */ - -/****************************************************************************/ - -/* Definitions used for OpenCreate Mode */ -#define OPEN_FILE 0x01 -#define TRUNCATE_FILE 0x02 -#define CREATE_FILE 0x08 -#define OPEN_64BIT_ACCESS 0x20 -#define OPEN_CALLBACK 0x80 -#define RO_ACCESS_OK 0x40 - -#define OpenCreateFlagsMask (TRUNCATE_FILE | OPEN_FILE | CREATE_FILE) - -/* Definitions used for OpenCreate Action */ -#define FILE_EXISTED 0x01 -#define FILE_CREATED 0x02 -#define FILE_TRUNCATED 0x04 -#define FILE_COMPRESSED 0x08 -#define FILE_RO_ACCESS 0x80 - - -/****************************************************************************/ -/* Defines used for Trustee scans, adds, and deletes */ -#define MAX_TRUSTEES 20 - -/****************************************************************************/ -/* Define for search attributes to include all files and subdirectories */ -#define SEARCH_ATTR_INCLUDE_ALL 0x8000 - - -//////////////////////////////////////////////////////////////////////////////////// -///////////////////////////// DFS Search Defines ////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////// -#define SEARCH_LINK_AWARE 0x20 -#define SEARCH_OPERATE_ON_LINK 0x40 -#define SEARCH_INFO_ON_FIRST_LINK 0x80 -#define SEARCH_LINK_BITS 0xe0 - -/****************************************************************************/ -/* These defines go with the ReturnInfoMask field to determine what will - be returned in the Netware Information structure */ -#define RFileName 0x00000001 -#define RSize 0x00000002 -#define RAttributes 0x00000004 -#define RDataStreamInfo 0x00000008 -#define RTotalDataStreamSize 0x00000010 -#define REAInfo 0x00000020 -#define RArchiveInfo 0x00000040 -#define RModifyInfo 0x00000080 -#define RCreationInfo 0x00000100 -#define RNameSpaceInfo 0x00000200 -#define RDirectoryInfo 0x00000400 -#define RRights 0x00000800 -/* valid only if RNewStyle is set */ -#define RReferenceID 0x00001000 -#define RNSAttribute 0x00002000 -#define RDataStreamActual 0x00004000 /* actual size in sectors */ -#define RDataStreamLogical 0x00008000 /* size from the dir entry */ -#define RLastUpdatedInSeconds 0x00010000 /* seconds relative to yr 2000 */ -#define RDOSName 0x00020000 /* 8.3 DOS Name */ -#define RFlushTime 0x00040000 /* For Drew - flush time of a file */ - -#define RParentBaseID 0x00080000 /* req.d by MAC NCP client */ -#define RMacFinderInfo 0x00100000 /* req.d by MAC NCP client */ -#define RSiblingCount 0x00200000 /* req.d by MAC NCP client */ -#define REffectiveRights 0x00400000 /* req.d by MAC NCP client */ -#define RMACDateTimes 0x00800000 /* req.d by MAC NCP client */ - -#define RLastAccessedTime 0x01000000 /* req.d by Client 32 -- valid only on file SPD # - Jim A. Nicolet - 6-25-98*/ - -#define RDFSLinkInfo 0x02000000 // NSS&DFS only -#define R64BitFileSize 0x04000000 /* 64 bit file sizes, upper 32 bits masked in TFS*/ -#define RNSSInfoOnSnapshot 0x20000000 // NSS&DFS only -#define RNSSLargeSizes 0x40000000 // NSS&DFS only - -#define RNewStyle 0x80000000 - -/* This is the Netware Information structure which is used to return - specific information about the entry, if RNewStyle is not set*/ -typedef struct -{ - /* Returned if RSize bit is set */ - LONG DiskSpaceAllocated; - - /* Returned if RAttribute bit is set */ - LONG Attributes; - WORD Flags; - - /* Returned if RDataStreamInfo bit is set */ - LONG DataStreamSize; - - /* Returned if RTotalDataStreamSize bit is set */ - LONG TotalDataStreamsSize; - WORD NumberOfDataStreams; - - /* Returned if RCreationInfo bit is set */ - WORD CreationTime; - WORD CreationDate; - LONG CreatorsID; - - /* Returned if RModifyInfo bit is set */ - WORD ModifiedTime; - WORD ModifiedDate; - LONG ModifiersID; - WORD LastAccessedDate; - - /* Returned if RArchiveInfo bit is set */ - WORD ArchivedTime; - WORD ArchivedDate; - LONG ArchiversID; - - /* Returned if RRights bit is set */ - WORD MaximumRightsMask; - - /* Returned if RDirectoryInfo bit is set */ - LONG DirectoryEntryNumber; - LONG DOSDirectoryEntryNumber; - LONG VolumeNumber; - - /* Returned if REAInfo bit is set */ - LONG ExtendedAttributesValueSize; - LONG ExtendedAttributesCount; - LONG ExtendedAttributesKeySize; - - /* Returned if RNameSpaceInfo bit is set */ - LONG CreatorNameSpaceNumber; - -} NetwareInfo; - - -typedef struct -{ - /* Returned if RFileName bit is set */ - BYTE FileNameLength; - BYTE FileName[256]; /*max. size is 255 character file name */ - -} NetwareFileName; - -/* for case89 NCPs */ -typedef struct -{ - /* Returned if RFileName bit is set */ - WORD FileNameLength; - BYTE FileName[768]; - -} EnhNetwareFileName; - - -/****************************************************************************/ -/* These defines go with the ModifySetMask field to determine which fields will be modified */ - -#define MAttributes 0x00000002 -#define MCreationDate 0x00000004 -#define MCreationTime 0x00000008 -#define MCreatorID 0x00000010 -#define MArchiveDate 0x00000020 -#define MArchiveTime 0x00000040 -#define MArchiveID 0x00000080 -#define MModifyDate 0x00000100 -#define MModifyTime 0x00000200 -#define MModifyID 0x00000400 -#define MLastAccess 0x00000800 -#define MRestrict 0x00001000 -#define MMaxSpace 0x00002000 - - -/* This bit is only valid with the - F3ModifyNSSpecificInfo api - NCP 87 19 -*/ -#define MName 0x00000001 - - -/* ************************************** -#define MModifyInSeconds 0x00004000 -***************************************** */ - -/* Structure used for Modify File Information Call */ -typedef struct -{ - /* Set if the MAttributes bit is set in the ModifyMask field */ - WORD FileAttributes; - BYTE FileMode; - BYTE FileXAttributes; - - /* Set if the MCreationDate bit is set */ - WORD CreationDate; - - /* Set if the MCreationTime bit is set */ - WORD CreationTime; - - /* Set if the MCreatorID bit is set */ - LONG CreatorsID; - - /* Set if the MModifyDate bit is set */ - WORD ModifiedDate; - - /* Set if the MModifyTime bit is set */ - WORD ModifiedTime; - - /* Set if the MModifyID bit is set */ - LONG ModifiersID; - - /* Set if the MArchiveDate bit is set */ - WORD ArchivedDate; - - /* Set if the MArchiveTime bit is set */ - WORD ArchivedTime; - - /* Set if the MArchiveID bit is set */ - LONG ArchiversID; - - /* Set if the MLastAccess bit is set */ - WORD LastAccessedDate; - - /* Set if the MRestrict bit is set */ - WORD RestrictionGrantMask; - WORD RestrictionRevokeMask; - - /* Set if the MMaxSpace bit is set */ - int MaximumSpace; - -/******************************************************************************** - LONG ModifyInRelativeSeconds; -******************************************************************************* */ - -} ModifyInfo; - -/****************************************************************************/ -typedef struct -{ - BYTE Volume; - LONG DirectoryBaseOrHandle; /* Directory Base | Short Directory Handle*/ - BYTE HandleFlag; - BYTE PathComponentCount; - BYTE PathString[300]; -} NWHandlePath; - -/* for case89 NCPs */ -typedef struct -{ - LONG DirectoryBaseOrHandle; /* Directory Base | Short Directory Handle*/ - BYTE Volume; - BYTE HandleFlag; - BYTE DataTypeFlag; /* This is a data field, not a bit mask */ - BYTE Reserved[5]; /* used for internal NCP engine & TFS backwards compatibility purposes*/ - BYTE PathComponentCount; - BYTE PathString[900]; -} EnhNWHandlePath; - -/* Handle Flags Definition */ -#define HFShortDirectoryHandle 0x00 -#define HFDirectoryBase 0x01 -#define HFNoHandlePresent 0xFF - -/* for case89 NCPs */ -#define ASCII_DATA_TYPE 0x00 -#define UTF8_DATA_TYPE 0x01 - -typedef struct -{ - BYTE Volume; - LONG DirectoryBaseOrHandle; /* Directory Base | Short Directory Handle*/ - BYTE HandleFlag; - BYTE PathComponentCount; -} NWRenMoveHandlePath; - -/* for case89 NCPs */ -typedef struct -{ - LONG DirectoryBaseOrHandle; /* Directory Base | Short Directory Handle*/ - BYTE Volume; - BYTE HandleFlag; - BYTE DataTypeFlag; - BYTE Reserved[5]; /* used for internal NCP engine & TFS backwards compatibility purposes*/ - BYTE PathComponentCount; -} EnhNWRenMoveHandlePath; -/****************************************************************************/ -typedef struct -{ - WORD HugeOffset; - WORD HugeLength; -} HugeInfoStruct; - -/****************************************************************************/ -/* File Handle to Directory Base NCP structure */ - -/* - HandleInfoLevel - 0 - Handle Info (Vol,DirBase,Stream#) - 1 - Handle Info with Name Space (Vol,DirBase,Stream#) - 2 - File info from handle - 3 - Dir info from 1 byte handle -*/ -typedef struct -{ - BYTE NWFileHandle[6]; - BYTE HandleInfoLevel; - BYTE NameSpace; /* only used when HandleInfoLevel == 1 */ -}HandleToDirBaseReq; - -typedef struct -{ - BYTE DirectoryHandle; - BYTE Pad[5]; - BYTE HandleInfoLevel; - BYTE Pad1; -} DirHandleInfoReq; - -typedef struct -{ - LONG Volume; - LONG DirectoryBase; - LONG DataStream; -}HandleToDirBaseRep; - -typedef struct -{ - LONG Volume; - LONG DirectoryBase; - LONG DOSDirectoryBase; - LONG NameSpace; - LONG DataStream; -}FileHandleInfoRep; - -typedef struct -{ - LONG Volume; - LONG DirectoryBase; - LONG DOSDirectoryBase; - LONG NameSpace; -}DirHandleInfoRep; - -typedef struct -{ - LONG Volume; - LONG DirectoryBase; - LONG DOSDirectoryBase; - LONG NameSpace; - LONG DataStream; - LONG ParentDirectoryNumber; - LONG ParentDOSDirectoryNumber; -}FileHandleInfoParentRep; - -typedef struct -{ - LONG Volume; - LONG DirectoryBase; - LONG DOSDirectoryBase; - LONG NameSpace; - LONG ParentDirectoryNumber; - LONG ParentDOSDirectoryNumber; -}DirHandleInfoParentRep; - -typedef struct -{ - LONG Volume; - LONG DirectoryBase; - LONG DOSDirectoryBase; - LONG NameSpace; - LONG ParentDirectoryNumber; - LONG ParentDOSDirectoryNumber; -} DIRINFOANDPARENT; - -typedef struct -{ - LONG Volume; - LONG DirectoryBase; - LONG DOSDirectoryBase; - LONG NameSpace; - LONG DataStream; - LONG ParentDirectoryNumber; - LONG ParentDOSDirectoryNumber; -} FILEINFOANDPARENT; - -/****************************************************************************/ -/* CreateOpen Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE OpenCreateFlags; - WORD SearchAttributes; - LONG ReturnInfoMask; - LONG CreateAttributes; - WORD DesiredAccessRights; - NWHandlePath NPathInfo; -}CreateOpenRequest; - -/* CreateOpen2 Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE DataStream; - BYTE OpenCreateFlags; - BYTE Xunused; - WORD SearchAttributes; - WORD XXunused; - LONG ReturnInfoMask; - LONG CreateAttributes; - WORD DesiredAccessRights; - NWHandlePath NPathInfo; -}CreateOpenRequest2; - -/* CreateOpen Reply NCP structure */ -typedef struct -{ - LONG FileHandle; - BYTE OpenCreateAction; - BYTE OCRetFlags; - NetwareInfo NInfo; - NetwareFileName FInfo; -}CreateOpenReply; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE DataStream; - BYTE OpenCreateFlags; - BYTE Reserved; - WORD SearchAttributes; - WORD Reserved1; - LONG ReturnInfoMask; - LONG CreateAttributes; - WORD DesiredAccessRights; - EnhNWHandlePath NPathInfo; -}EnhCreateOpenRequest2; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE OpenCreateFlags; - WORD SearchAttributes; - LONG ReturnInfoMask; - LONG CreateAttributes; - WORD DesiredAccessRights; - EnhNWHandlePath NPathInfo; -}EnhCreateOpenRequest; - -/* for case89 NCPs */ -typedef struct -{ - LONG FileHandle; - BYTE OpenCreateAction; - BYTE OCRetFlags; - NetwareInfo NInfo; - EnhNetwareFileName FInfo; -}EnhCreateOpenReply; - -/****************************************************************************/ -typedef struct -{ - LONG CCFileHandle; - BYTE CCFunction; -}CallbackControlRequest; - - -/****************************************************************************/ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - NWHandlePath NPathInfo; -}SearchInitRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - EnhNWHandlePath NPathInfo; -}EnhSearchInitRequest; - -typedef struct -{ - BYTE VolumeNumber; /* The following three fields make up the */ - LONG DirectoryNumber; /* nine byte search sequence */ - LONG EntryNumber; -}SearchInitReply; - - -/****************************************************************************/ -typedef struct -{ - BYTE NameSpace; - BYTE DataStream; - WORD SearchAttributes; - LONG ReturnInfoMask; - BYTE SVolume; - LONG SDirectoryNumber; - LONG SEntryNumber; - BYTE SearchPatternLength; - BYTE SearchPattern[255]; -}SearchContRequest; - - -typedef struct -{ - BYTE SVolume; - LONG SDirectoryNumber; - LONG SEntryNumber; - BYTE Reserved; - NetwareInfo NInfo; - NetwareFileName FInfo; -}SearchContReply; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE DataStream; - WORD SearchAttributes; - LONG ReturnInfoMask; - BYTE SVolume; - LONG SDirectoryNumber; - LONG SEntryNumber; - BYTE DataTypeFlag; - WORD SearchPatternLength; - BYTE SearchPattern[765]; -}EnhSearchContRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE SVolume; - LONG SDirectoryNumber; - LONG SEntryNumber; - BYTE Reserved; - NetwareInfo NInfo; - EnhNetwareFileName FInfo; -}EnhSearchContReply; - -/****************************************************************************/ -/* Rename File or Directory Request NCP structure */ - -/* Bits used in the RenameFlag to turn ON these options */ -#define RRenameToMyself 0x01 -#define RCompatabilityFlag 0x02 -#define RNameOnlyFlag 0x04 - -typedef struct -{ - BYTE NameSpace; - BYTE RenameFlag; - WORD SearchAttributes; - NWRenMoveHandlePath SrcPathInfo; - NWRenMoveHandlePath DstPathInfo; - BYTE PInfo; -}RenameRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE RenameFlag; - WORD SearchAttributes; - EnhNWRenMoveHandlePath SrcPathInfo; - EnhNWRenMoveHandlePath DstPathInfo; - BYTE PInfo; -}EnhRenameRequest; - -/* Only a completion code will be returned on reply */ - - - -/****************************************************************************/ -/* Trustees Structure */ -typedef struct -{ - LONG ObjectID; - WORD TrusteeRights; -}Trustees; - - -/****************************************************************************/ -/* Scan File or Directory for Trustees Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - WORD SearchAttribute; - LONG ScanSequence; - NWHandlePath NPathInfo; -}ScanTrusteesRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE MaxReplyObjectIDCount; - WORD SearchAttribute; - LONG ScanSequence; - EnhNWHandlePath NPathInfo; -}EnhScanTrusteesRequest; - -/* Scan File or Directory for Trustees Reply NCP structure */ -typedef struct -{ - LONG NextScanSequence; - WORD ObjectIDCount; - Trustees STrustees[MAX_TRUSTEES]; -}ScanTrusteesReply; - - - -/****************************************************************************/ -/* Add Trustee or Trustees to File or Directory Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - WORD SearchAttributes; - WORD TrusteeRightsMask; - WORD ObjectIDCount; - NWHandlePath NPathInfo; - Trustees ATrustees[MAX_TRUSTEES]; -}AddTrusteesRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - WORD SearchAttributes; - WORD TrusteeRightsMask; - WORD ObjectIDCount; - Trustees ATrustees[MAX_TRUSTEES]; /* variable length. NPathInfo starts after ObjectIDCount * sizeof(Trustees) (n * 6) */ - EnhNWHandlePath NPathInfo; -}EnhAddTrusteesRequest; - -/****************************************************************************/ -/* Delete Trustee or Trustees from a File or Directory Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - WORD ObjectIDCount; - NWHandlePath NPathInfo; - Trustees DTrustees[MAX_TRUSTEES]; -}DeleteTrusteesRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - WORD ObjectIDCount; - Trustees DTrustees[MAX_TRUSTEES]; /* variable length. NPathInfo starts after ObjectIDCount * sizeof(Trustees) (n * 6) */ - EnhNWHandlePath NPathInfo; -}EnhDeleteTrusteesRequest; - -/****************************************************************************/ -/* Obtain File/SubDirectory Info Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE DstNameSpace; - WORD SearchAttributes; - LONG ReturnInfoMask; - NWHandlePath NPathInfo; -}ObtainInfoRequest; - -/* Obtain File/SubDirectory Info Reply NCP structure */ -typedef struct -{ - NetwareInfo NInfo; - NetwareFileName FInfo; -}ObtainInfoReply; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE DstNameSpace; - WORD SearchAttributes; - LONG ReturnInfoMask; - EnhNWHandlePath NPathInfo; -}EnhObtainInfoRequest; - -/* for case89 NCPs */ -typedef struct -{ - NetwareInfo NInfo; - EnhNetwareFileName FInfo; -}EnhObtainInfoReply; - -/****************************************************************************/ -/* Modify File/SubDirectory Information Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - WORD SearchAttributes; - LONG ModifyMask; - ModifyInfo MInfo; - NWHandlePath NPathInfo; -}ModifyInfoRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - WORD SearchAttributes; - LONG ModifyMask; - ModifyInfo MInfo; - EnhNWHandlePath NPathInfo; -}EnhModifyInfoRequest; - -/****************************************************************************/ -/* Delete File Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - WORD SearchAttributes; - NWHandlePath NPathInfo; -}DeleteFileRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - WORD SearchAttributes; - EnhNWHandlePath NPathInfo; -}EnhDeleteFileRequest; - -/****************************************************************************/ -/* Allocate Directory Handle Request NCP Structure */ -typedef struct -{ - BYTE NameSpace; - BYTE DstNameSpace; /* valid only if bit 15 of alloc mode is set */ - WORD AllocateMode; - NWHandlePath NPathInfo; -} AllocateDirRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE DstNameSpace; /* valid only if bit 15 of alloc mode is set */ - WORD AllocateMode; - EnhNWHandlePath NPathInfo; -} EnhAllocateDirRequest; - -/* Allocate Directory Handle Reply NCP Structure */ -typedef struct -{ - BYTE NewDirectoryHandle; - BYTE VolumeNumber; - BYTE Reserved[4]; -} AllocateDirReply; - -typedef struct -{ - LONG Volume; - LONG DirectoryBase; - LONG DOSDirectoryBase; - LONG NameSpace; - BYTE NewDirectoryHandle; -} AllocateDirReply2; - - -/****************************************************************************/ -/* Set Directory Handle Request NCP Structure */ -typedef struct -{ - BYTE NameSpace; - BYTE DataStream; - BYTE DstDirHandle; - BYTE Flags; - NWHandlePath NPathInfo; -} SetDirRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE DataStream; - BYTE DstDirHandle; - BYTE Flags; - EnhNWHandlePath NPathInfo; -} EnhSetDirRequest; - -/* Set Directory Handle only returns a ccode for the reply */ - -typedef struct -{ - LONG Volume; - LONG DirectoryBase; - LONG DOSDirectoryBase; - LONG NameSpace; -} SetDirReply2; - - - -/****************************************************************************/ -/* Scan Salvagable Files Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE DataStream; - LONG ReturnInfoMask; - LONG ScanSequence; - NWHandlePath NPathInfo; -}ScanSalvageRequest; - - -/* Scan Salvagable Files Reply NCP structure */ -typedef struct -{ - LONG NextScanSequence; - LONG DeletedDateAndTime; - LONG DeletorID; - LONG DeletorVolume; - LONG DeletorDirectoryBase; - NetwareInfo NInfo; - NetwareFileName FInfo; -}ScanSalvageReply; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE DataStream; - LONG ReturnInfoMask; - LONG ScanSequence; - EnhNWHandlePath NPathInfo; -}EnhScanSalvageRequest; - -/* for case89 NCPs */ -typedef struct -{ - LONG NextScanSequence; - LONG DeletedDateAndTime; - LONG DeletorID; - LONG DeletorVolume; - LONG DeletorDirectoryBase; - NetwareInfo NInfo; - EnhNetwareFileName FInfo; -}EnhScanSalvageReply; - -/****************************************************************************/ -/* Recover Salvagable File Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - LONG Sequence; - LONG Volume; - LONG DirectoryBase; - BYTE NewFileNameLength; - BYTE NewFileName[255]; -}RecoverSalvageRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - LONG Sequence; - LONG Volume; - LONG DirectoryBase; - BYTE DataTypeFlag; - WORD NewFileNameLength; - BYTE NewFileName[765]; -}EnhRecoverSalvageRequest; - - -/****************************************************************************/ - /* Purge Salvagable File Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE Reserved; - LONG Sequence; - LONG Volume; - LONG DirectoryBase; -}PurgeSalvageRequest; - - -/****************************************************************************/ -/* Get Name Space Specific File/SubDirectory Information Request NCP structure */ -typedef struct -{ - BYTE SrcNameSpace; - BYTE DstNameSpace; - BYTE DataTypeFlag; - BYTE VolumeNumber; - LONG DirectoryBase; - LONG NSInfoBitMask; -}GetNSInfoRequest; - -/* Get Name Space Specific File/SubDirectory Info Reply NCP structure */ -typedef struct -{ - BYTE NSData[512]; -}GetNSInfoReply; - - -/****************************************************************************/ -/* Modify Name Space Specific Information */ -typedef struct -{ - BYTE SrcNameSpace; - BYTE DstNameSpace; - BYTE VolumeNumber; - LONG DirectoryBase; - LONG ModifyMask; - BYTE ModifyData[512]; -}ModifyNSInfoRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE SrcNameSpace; - BYTE DstNameSpace; - BYTE VolumeNumber; - LONG DirectoryBase; - LONG ModifyMask; - BYTE DataTypeFlag; - BYTE ModifyData[1024]; -}EnhModifyNSInfoRequest; - -/****************************************************************************/ -/* Search File/SubDirectory Set Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE DataStream; - WORD SearchAttributes; - LONG ReturnInfoMask; - WORD ReturnInfoCount; - BYTE SVolume; - LONG SDirectoryNumber; - LONG SEntryNumber; - BYTE SearchPatternLength; - BYTE SearchPattern[255]; -}SearchSetRequest; - -/* Search File/SubDirectory Set Reply NCP structure */ -typedef struct -{ - BYTE SVolume; - LONG SDirectoryNumber; - LONG SEntryNumber; - BYTE MoreEntries; - WORD InfoCount; - NetwareInfo NInfo; -}SearchSetReply; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE DataStream; - WORD SearchAttributes; - LONG ReturnInfoMask; - WORD ReturnInfoCount; - BYTE SVolume; - LONG SDirectoryNumber; - LONG SEntryNumber; - BYTE DataTypeFlag; - WORD SearchPatternLength; - BYTE SearchPattern[765]; -}EnhSearchSetRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE SVolume; - LONG SDirectoryNumber; - LONG SEntryNumber; - BYTE MoreEntries; - WORD InfoCount; - NetwareInfo NInfo; -// EnhNetwareFileName FInfo; There can be multiples of the NInfo and FInfo's returned. -}EnhSearchSetReply; - - -/****************************************************************************/ -/* Get Path from Handle Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE DirectoryHandle; -}GetPathRequest; - - -/****************************************************************************/ -/* Get Path from Handle Reply NCP structure */ -typedef struct -{ - NetwareFileName FInfo; -}GetPathReply; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE DirectoryHandle; - BYTE DataTypeFlag; -}EnhGetPathRequest; - -/* for case89 NCPs */ -typedef struct -{ - EnhNetwareFileName FInfo; -}EnhGetPathReply; - -/****************************************************************************/ -/* Get Directory Base and Volume # Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE DstNameSpace; - WORD DstNameSpaceID; /*ID = 'Jn', then DstNameSpace is valid*/ - NWHandlePath NPathInfo; -}GetDirBaseRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE DstNameSpace; - WORD DstNameSpaceID; /*ID = 'Jn', then DstNameSpace is valid*/ - EnhNWHandlePath NPathInfo; -}EnhGetDirBaseRequest; - -/****************************************************************************/ -/* Get Directory Base and Volume # NCP structure */ -typedef struct -{ - LONG NSDirectoryBase; - LONG DOSDirectoryBase; - BYTE VolumeNumber; -}GetDirBaseReply; - - -/****************************************************************************/ -/* Query Name Space Info */ -typedef struct -{ - BYTE NameSpace; - BYTE VolumeNumber; -}QueryNSInfoRequest; - -typedef struct -{ - LONG FixedFieldsMask; - LONG VariableFieldsMask; - LONG HugeFieldsMask; - WORD FixedBitsDefined; - WORD VariableBitsDefined; - WORD HugeBitsDefined; - LONG FieldsLengthTable[32]; -}QueryNSInfoReply; - - -/****************************************************************************/ -/* Get Name Spaces Loaded List From Volume Number NCP Structure */ -typedef struct -{ - WORD Reserved; - BYTE VolumeNumber; -}GetNSLLRequest; - -typedef struct -{ - WORD NumberOfNameSpacesLoaded; - BYTE NameSpaceLoadList[MaximumNumberOfNameSpaces]; -}GetNSLLReply; - - -/****************************************************************************/ -/* Get Huge NS Information */ -typedef struct -{ - BYTE NameSpace; - BYTE VolumeNumber; - LONG DirectoryBase; - LONG HugeMask; - BYTE HugeStateInfo[16]; -} GetHugeNSRequest; - -typedef struct -{ - BYTE NextHugeStateInfo[16]; - LONG HugeDataLength; - BYTE HugeData[512]; -} GetHugeNSReply; - - -/****************************************************************************/ -/* Set Huge NS Information */ -typedef struct -{ - BYTE NameSpace; - BYTE VolumeNumber; - LONG DirectoryBase; - LONG HugeMask; - BYTE HugeStateInfo[16]; - LONG HugeDataLength; - BYTE HugeData[480]; -} SetHugeNSRequest; - -typedef struct -{ - BYTE NextHugeStateInfo[16]; - LONG HugeDataUsed; -} SetHugeNSReply; - -/****************************************************************************/ - -#define LastComponentIsAFile 1 - -#define cookieValidBits LastComponentIsAFile - -typedef struct -{ - WORD cookieFlags; - LONG Vol; - LONG Base; -}PathCookie; - -/* Get Full Path String Request NCP structure */ -typedef struct -{ - BYTE SrcNS; - BYTE DstNS; - PathCookie pCookie; - NWHandlePath NPathInfo; -}GetFullPathStringReq; - -/****************************************************************************/ -/* Get Full Path String Reply NCP structure */ -typedef struct -{ - PathCookie repCookie; - WORD repComponentSize; - WORD repComponentCount; - BYTE ComponentBuffer; -}GetFullPathStringRep; - -/* for case89 NCPs */ -typedef struct -{ - BYTE SrcNS; - BYTE DstNS; - PathCookie pCookie; - EnhNWHandlePath NPathInfo; -}EnhGetFullPathStringReq; - -/* for case89 NCPs */ -typedef struct -{ - PathCookie repCookie; - WORD repComponentSize; - WORD repComponentCount; - BYTE ComponentBuffer; - /* note: follows, a series of WORD length preceeded path components: - WORD pathLength; - BYTE string[]; - */ -}EnhGetFullPathStringRep; - -/****************************************************************************/ -/* Get Effective Directory Rights Request NCP structure */ -typedef struct -{ - BYTE NameSpace; - BYTE DstNameSpace; - WORD SearchAttributes; - LONG ReturnInfoMask; - NWHandlePath NPathInfo; -}GetEffectiveRightsRequest; - -/* Get Effective Directory Rights Reply NCP structure */ -typedef struct -{ - WORD MyEffectiveRights; - NetwareInfo NInfo; - NetwareFileName FInfo; -}GetEffectiveRightsReply; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE DstNameSpace; - WORD SearchAttributes; - LONG ReturnInfoMask; - EnhNWHandlePath NPathInfo; -}EnhGetEffectiveRightsRequest; - -/* for case89 NCPs */ -typedef struct -{ - WORD MyEffectiveRights; - NetwareInfo NInfo; - EnhNetwareFileName FInfo; -}EnhGetEffectiveRightsReply; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - LONG ObjectID; - EnhNWHandlePath NPathInfo; -}EnhGetObjectEffectiveRightsRequest; - -/* for case89 NCPs */ -typedef struct -{ - WORD MyEffectiveRights; -}EnhGetObjectEffectiveRightsReply; - -typedef struct -{ - LONG Volume; - LONG DirectoryBase; - LONG DOSDirectoryBase; - LONG NameSpace; -} F3ALLOCDIRHANDLEINFO; - -/****************************************************************************/ -/* Modify DOS Attributes on a File or SubDirectory */ -typedef struct -{ - BYTE NameSpace; - BYTE Flags; - WORD SearchAttributes; - LONG AttributesMask; - LONG Attributes; - NWHandlePath NPathInfo; -}ModifyDOSAttributesRequest; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE Flags; - WORD SearchAttributes; - LONG AttributesMask; - LONG Attributes; - EnhNWHandlePath NPathInfo; -}EnhModifyDOSAttributesRequest; - -typedef struct -{ - LONG foundItems; - LONG changedItems; - LONG ValidFlag; /* indicates whether the newAttributes field is valid */ - LONG NewAttributes; /* when Allow Wild Cards is set, only valid for first match */ -}ModifyDOSAttributesReply; - -/****************************************************************************/ -/* Log File */ -typedef struct -{ - BYTE NameSpace; - BYTE reserved; - WORD reserved2; - LONG LogFileFlags; - LONG WaitTime; - NWHandlePath NPathInfo; -}LogFileRequest; - -#define LockFileImmediatelyBit 0x00000001 /* LOCKBIT in locks.h */ -#define CallBackRequestedBit 0x00008000 - -typedef struct -{ - BYTE NameSpace; - BYTE reserved; - WORD reserved2; - NWHandlePath NPathInfo; -}ClearOrReleaseFileRequest; -/****************************************************************************/ -/* Get Directory Space Restriction */ - -typedef struct -{ - BYTE NameSpace; - BYTE pad[2]; - NWHandlePath NPathInfo; -} GetDirSpaceRestrictionReq_t ; - -/* for case89 NCPs */ -typedef struct -{ - BYTE NameSpace; - BYTE pad[2]; - EnhNWHandlePath NPathInfo; -} EnhGetDirSpaceRestrictionReq_t ; - -/****************************************************************************/ -/* FUNCTION PROTOTYPES FOR GENPRIM.386 */ - -extern LONG GenericGetVolumeNumber( - BYTE *string, - LONG NameSpace, - BYTE **path, - BYTE *volume); - -/****************************************************************************/ -/* FUNCTION PROTOTYPES FOR FILER3.C */ - -extern LONG F3OpenCreate( - LONG station, - LONG task, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG NameSpace, - LONG DataStream, - LONG OpenCreateFlags, - LONG SearchAttributes, - LONG CreateAttributes, - LONG DesiredAccessRights, - LONG ReturnInfoMask, - LONG *FileHandle, - BYTE *OpenCreateAction, - NetwareInfo *NInfo, - NetwareFileName *FInfo, - LONG *rLen); - -#if CROSSNAMEFIX -extern LONG F3OpenCreateEx( - LONG station, - LONG task, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG NameSpace, - LONG DataStream, - LONG OpenCreateFlags, - LONG SearchAttributes, - LONG CreateAttributes, - LONG DesiredAccessRights, - LONG ReturnInfoMask, - LONG *FileHandle, - BYTE *OpenCreateAction, - NetwareInfo *NInfo, - NetwareFileName *FInfo, - LONG *rLen, - LONG MixedModeFlag); -#endif - -extern LONG F3InitFileSearch( - LONG station, - LONG NameSpace, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG *VolumeNumber, - LONG *DirectoryNumber, - LONG *EntryNumber); - -extern LONG F3ContinueFileSearch( - LONG station, - LONG NameSpace, - LONG SearchAttributes, - LONG Volume, - LONG DirectoryNumber, - LONG EntryNumber, - BYTE *SearchPattern, /* length preceded string */ - LONG ReturnInfoMask, - LONG *NextEntryNumber, - NetwareInfo *NInfo, - NetwareFileName *FInfo, - LONG *rLen); - - -extern LONG F3RenameFile( - LONG station, - LONG task, - LONG NameSpace, - LONG RenameFlag, - LONG SearchAttributes, - LONG SrcVolume, - LONG SrcPathCount, - LONG SrcPathBase, - BYTE *SrcPathString, - LONG DstVolume, - LONG DstPathCount, - LONG DstPathBase, - BYTE *DstPathString); - -extern LONG F3ScanForTrustees( - LONG station, - LONG NameSpace, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG ScanSequence, - LONG MaxTrusteeCount, /* Maximum Number of Trustees to return */ - LONG *NextScanSequence, - LONG *ObjectIDCount, - Trustees *TPtr); - -extern LONG F3ObtainFileInfo( - LONG station, - LONG NameSpace, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG DstNameSpace, - LONG ReturnInfoMask, - NetwareInfo *NInfo, - NetwareFileName *FInfo, - LONG *rLen); - -extern LONG F3ModifyInfo( - LONG station, - LONG task, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG NameSpace, - LONG SearchAttributes, - LONG ModifyMask, - ModifyInfo *MInfo); - -extern LONG F3ModifyDOSAttributes( - LONG Station, - LONG Task, - LONG Volume, - LONG PathBase, - BYTE *PathString, - LONG PathCount, - LONG NameSpace, - LONG SearchAttributes, - LONG Flags, - LONG Mask, - LONG newAttributes, - LONG *validFlag, - LONG *resultentAttributes, - LONG *foundItems, - LONG *changedItems); - - -extern LONG F3EraseFile( - LONG station, - LONG task, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG NameSpace, - LONG SearchAttributes); - -extern LONG F3SetDirHandle( - LONG station, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG NameSpace, - LONG DstDirHandle, - F3ALLOCDIRHANDLEINFO *info); - -extern LONG F3AddTrustees( - LONG station, - LONG NameSpace, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG TrusteeRightsMask, - LONG ObjectIDCount, - Trustees *TPtr); - -extern LONG F3DeleteTrustees( - LONG station, - LONG NameSpace, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG ObjectIDCount, - Trustees *TPtr); - -extern LONG F3AllocDirHandle( - LONG station, - LONG task, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG NameSpace, - LONG AllocateMode, - LONG DstNameSpace, - LONG *DirectoryHandle, - F3ALLOCDIRHANDLEINFO *info); - -extern LONG F3ScanSalvagedFiles( - LONG station, - LONG NameSpace, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG ScanSequence, - LONG ReturnInfoMask, - LONG *NextScanSequence, - LONG *DeletedDateAndTime, - LONG *DeletorID, - LONG *DeletedDirectoryBase, - NetwareInfo *NInfo, - NetwareFileName *FInfo, - LONG *rLen); - -extern LONG F3RecoverSalvagedFiles( - LONG station, - LONG NameSpace, - LONG Sequence, - LONG Volume, - LONG DirectoryBase, - BYTE *FileName); /* length preceded */ - -extern LONG F3PurgeSalvageableFile( - LONG station, - LONG NameSpace, - LONG Sequence, - LONG Volume, - LONG DirectoryBase); - -extern LONG F3GetNSSpecificInfo( - LONG station, - LONG SrcNameSpace, - LONG DstNameSpace, - LONG VolumeNumber, - LONG DirectoryBase, - LONG NSInfoBitMask, - LONG *NSInfoLength, - BYTE *NSInfo); - -extern LONG F3ModifyNSSpecificInfo( - LONG station, - LONG task, - LONG DataPacketLength, /* Size of data packet minus IPX header and fixed length data*/ - LONG SrcNameSpace, - LONG DstNameSpace, - LONG VolumeNumber, - LONG DirectoryBase, - LONG ModifyMask, - BYTE *MInfo); - -extern LONG F3SearchSet( - LONG station, - LONG NameSpace, - LONG SearchAttributes, - int NumberOfEntries, /* return info count -- maximum # of entries to return */ - LONG Volume, - LONG DirectoryNumber, - LONG EntryNumber, - BYTE *SearchPattern, /* length preceded */ - LONG ReturnInfoMask, - LONG *NewEntryNumber, - LONG *MoreEntriesFlag, - LONG *EntriesCount, - LONG *InfoLength, /* preset to contain buffer length -- rtn actual length */ - BYTE *Info); - -extern LONG F3GetPathString( - LONG Station, - LONG NameSpace, - LONG DirectoryHandle, - NetwareFileName *FInfo); - -extern LONG F3GetDirBase( - LONG station, - LONG SrcNameSpace, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG DstNameSpace, - LONG *DirectoryBase, - LONG *DOSDirectoryBase); - -extern LONG F3QueryNameSpaceInfo( - LONG NameSpace, - LONG VolumeNumber, - LONG *FixedFieldsMask, - LONG *VariableFieldsMask, - LONG *HugeFieldsMask, - LONG *FixedBitsDefined, - LONG *VariableBitsDefined, - LONG *HugeBitsDefined, - LONG *FLTable); /* must contain room for 32 longs */ - -extern LONG F3GetNameSpaceList( - LONG VolumeNumber, - LONG *NumOfLoadedNameSpaces, - BYTE *NSInfo); - -extern LONG F3GetHugeInfo( - LONG Station, - LONG Task, - LONG NameSpace, - LONG VolumeNumber, - LONG DirectoryBase, - LONG HugeMask, - BYTE *HSInfo, /* huge state info */ - LONG *HugeDataLength, - BYTE *NHSInfo, /* next huge state info */ - BYTE *HInfo); - -extern LONG F3SetHugeInfo( - LONG Station, - LONG Task, - LONG NameSpace, - LONG VolumeNumber, - LONG DirectoryBase, - LONG HugeMask, - BYTE *HSInfo, - LONG HugeDataLength, - BYTE *HInfo, - BYTE *NHSInfo, - LONG *HugeDataUsed); - -extern LONG F3GetFullPathString( - LONG Station, - LONG SrcNameSpace, - LONG Volume, - LONG PathBase, - LONG DstNameSpace, - PathCookie *pCookie, - LONG ComponentBufferSize, - LONG *ComponentCount, - LONG *ComponentSize, - BYTE *ComponentBuffer); - -extern LONG F3GetEffectiveDirectoryRights( - LONG station, - LONG NameSpace, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG DstNameSpace, - LONG ReturnInfoMask, - WORD *MyEffectiveRights, - NetwareInfo *NInfo, - NetwareFileName *FInfo, - LONG *rLen); - -extern LONG F3GetFileHandleInfoAndParent(LONG, LONG, void *); -extern LONG F3GetDirHandleInfoAndParent(LONG, LONG, void *); - -extern LONG GetNetWareInfo( - LONG Volume, - LONG Station, - LONG DirEntry, - LONG DOSDirEntry, - LONG NameSpace, - LONG ReturnInfoMask, - struct DirectoryStructure *OtherDir, - struct DirectoryStructure *DOSDir, - void *info, - LONG *rLen, -//;;BEGIN SPD 138431 - OPNSIZFX.NLM Change 33 of 34 - TDR 5/23/97 -// LONG infoLen); - LONG infoLen, - LONG *FileHandle); -//;;END SPD 138431 - OPNSIZFX.NLM Change 33 of 34 - TDR 5/23/97 - -extern LONG GenericFillReplyBuffer( - LONG Volume, - LONG Station, - LONG DirEntry, - LONG DOSDirEntry, - LONG NameSpace, - LONG ReturnInfoMask, - struct DirectoryStructure *OtherDir, - struct DirectoryStructure *DOSDir, - NetwareInfo *rep, - NetwareFileName *frep, -//;;BEGIN SPD 138431 - OPNSIZFX.NLM Change 34 of 34 - TDR 5/23/97 -// LONG *rLen,//); - LONG *rLen, - LONG *FileHandle); -//;;END SPD 138431 - OPNSIZFX.NLM Change 34 of 34 - TDR 5/23/97 - -extern LONG GenParsePath( - LONG NameSpace, - LONG Station, - NWHandlePath *NPathInfo, - LONG *Volume, - LONG *PathCount, - LONG *PathBase, - BYTE **PathString); - -#if CROSSNAMEFIX -extern LONG GenParsePathEx( - LONG NameSpace, - LONG Station, - NWHandlePath *NPathInfo, - LONG *Volume, - LONG *PathCount, - LONG *PathBase, - BYTE **PathString, - LONG *MixedModeFlag); -#endif - -extern LONG GenFullParsePath( - LONG NameSpace, - LONG Station, - NWHandlePath *NPathInfo, - LONG cookieFlags, - LONG *Volume, - LONG *PathBase); - -extern LONG GenParseCompactPath( - LONG NameSpace, - LONG Station, - NWRenMoveHandlePath *NPathInfo, - BYTE *String, - LONG *Volume, - LONG *PathCount, - LONG *PathBase, - BYTE **PathString, - BYTE **NewString); - -/****************************************************************************/ -/* Function Prototypes for NLM interface to the Generic NCPs. */ -/* These Functions can be exported */ -extern LONG GenNSOpenCreateFile( - LONG Station, - LONG Task, - NWHandlePath *NPathInfo, - BYTE NameSpace, - BYTE OpenCreateFlags, - WORD SearchAttributes, - WORD DesiredAccessRights, - LONG CreateAttributes, - LONG ReturnInfoMask, - LONG *FileHandle, - BYTE *OpenCreateAction, - NetwareInfo *NInfo, - BYTE *FileName); - - -extern LONG GenNSInitFileSearch( - LONG Station, - NWHandlePath *NPathInfo, - BYTE NameSpace, - BYTE *VolumeNumber, /* Search Seq. */ - LONG *DirectoryNumber, - LONG *EntryNumber); - - -extern LONG GenNSContinueFileSearch( - LONG Station, - BYTE NameSpace, - BYTE DataStream, - WORD SearchAttributes, - LONG ReturnInfoMask, - BYTE SVolume, /* Search Seq. */ - LONG SDirectoryNumber, - LONG SEntryNumber, - BYTE *SearchPattern, - LONG *NewSEntryNumber, - NetwareInfo *NInfo, - BYTE *FileName); - -/* replaced GenNSRename -- which had coding errors in it. */ -extern LONG GenNSRenameMove( - LONG Station, - LONG Task, - BYTE NameSpace, - BYTE RenameFlag, - WORD SearchAttributes, - NWRenMoveHandlePath *SrcPathInfo, /* special structure for rename */ - NWRenMoveHandlePath *DstPathInfo, - BYTE *PInfo); /* path info for both src & dst */ - -extern LONG GenNSObtainInfo( - LONG Station, - NWHandlePath *NPathInfo, - BYTE SrcNameSpace, - BYTE DstNameSpace, - WORD SearchAttributes, - LONG ReturnInfoMask, - NetwareInfo *NInfo, - BYTE *FileName); - - - -extern LONG GenNSModifyInfo( - LONG Station, - LONG Task, - NWHandlePath *NPathInfo, - BYTE NameSpace, - WORD SearchAttributes, - LONG ModifyMask, - ModifyInfo *MInfo); - - -extern LONG GenNSErase( - LONG Station, - LONG Task, - NWHandlePath *NPathInfo, - BYTE NameSpace, - WORD SearchAttributes); - - -extern LONG GenNSAllocDirHandle( - LONG Station, - LONG Task, - NWHandlePath *NPathInfo, - BYTE NameSpace, - WORD AllocateMode, - BYTE *NewDirectoryHandle, - BYTE *VolumeNumber); - -extern LONG GenNSAllocateDirHandle( - LONG Station, - LONG Task, - NWHandlePath *NPathInfo, - BYTE SrcNameSpace, - WORD AllocateMode, - BYTE DstNameSpace, - BYTE *NewDirectoryHandle, - BYTE *VolumeNumber); - -extern LONG GenNSGetDirBase( - LONG Station, - NWHandlePath *NPathInfo, - BYTE NameSpace, - WORD Reserved, /* if Reserved == 'Jn' then DstNameSpace is valid*/ - LONG *NSDirectoryBase, - LONG *DOSDirectoryBase, - BYTE *VolumeNumber, - BYTE DstNameSpace); - -extern LONG GenNSGetNameSpaceList( - BYTE VolumeNumber, - WORD *NumberNSLoaded, - BYTE *NSLoadedList); /* points to a buffer at least MaximumNumberOfNameSpaces big */ - -extern LONG GenNSScanSalvageableFiles( - LONG Station, - NWHandlePath *NPathInfo, - BYTE NameSpace, - BYTE DataStream, - LONG ReturnInfoMask, - LONG ScanSequence, - LONG *NextScanSequence, - LONG *DeletedDateAndTime, - LONG *DeletorID, - LONG *DeletorVolume, - LONG *DeletorDirectoryBase, - NetwareInfo *NInfo, - BYTE *FileName); - - -extern LONG GenNSRecoverSalvageableFile( - LONG Station, - LONG NameSpace, - LONG Sequence, - LONG Volume, - LONG DirectoryBase, - BYTE *NewFileName); - - - -extern LONG GenNSPurgeSalvageableFile( - LONG Station, - LONG NameSpace, - LONG Sequence, - LONG Volume, - LONG DirectoryBase); - - -extern LONG GenNSGetPathString( - LONG Station, - BYTE NameSpace, - BYTE DirectoryHandle, - BYTE *PathString); - - -extern LONG GenNSScanForTrustees( - LONG Station, - NWHandlePath *NPathInfo, - BYTE NameSpace, - WORD SearchAttribute, - LONG ScanSequence, - LONG *NextScanSequence, - WORD *ObjectIDCount, - Trustees *STrustees); - - -extern LONG GenNSAddTrustees( - LONG Station, - NWHandlePath *NPathInfo, - BYTE NameSpace, - WORD SearchAttributes, - WORD TrusteeRightsMask, - WORD ObjectIDCount, - Trustees *ATrustees); - - -extern LONG GenNSDeleteTrustees( - LONG Station, - NWHandlePath *NPathInfo, - BYTE NameSpace, - WORD ObjectIDCount, - Trustees *DTrustees); - - -extern LONG GenNSSetDirHandle( - LONG Station, - NWHandlePath *NPathInfo, - BYTE NameSpace, - BYTE DataStream, - BYTE DstDirHandle); - - -extern LONG GenNSQueryNameSpaceInfo( - BYTE NameSpace, - BYTE VolumeNumber, - LONG *FixedFieldsMask, - LONG *VariableFieldsMask, - LONG *HugeFieldsMask, - WORD *FixedBitsDefined, - WORD *VariableBitsDefined, - WORD *HugeBitsDefined, - LONG *FieldsLengthTable); /* pointer to space for 32 longs */ - - -extern LONG GenNSGetSpecificInfo( - LONG Station, - BYTE SrcNameSpace, - BYTE DstNameSpace, - BYTE VolumeNumber, - LONG DirectoryBase, - LONG NSInfoBitMask, - BYTE *NSData); - - -extern LONG GenNSModifySpecificInfo( - LONG Station, - LONG Task, - BYTE SrcNameSpace, - BYTE DstNameSpace, - BYTE VolumeNumber, - LONG DirectoryBase, - LONG ModifyMask, - WORD ModifyDataLength, - BYTE *ModifyData); - -extern LONG GetHugeInformation( - LONG Station, - LONG Task, - BYTE NameSpace, - BYTE VolumeNumber, - LONG DirectoryBase, - LONG HugeMask, - BYTE *HugeStateInfo, - BYTE *HugeData, - LONG *HugeDataLength, - BYTE *NextHugeStateInfo); - -extern LONG SetHugeInformation( - LONG Station, - LONG Task, - BYTE NameSpace, - BYTE VolumeNumber, - LONG DirectoryBase, - LONG HugeMask, - BYTE *HugeStateInfo, - LONG HugeDataLength, - BYTE *HugeData, - BYTE *NextHugeStateInfo, - LONG *HugeDataUsed); - -extern LONG GenNSGetFullPathString( - LONG Station, - BYTE SourceNameSpace, - BYTE DestinationNameSpace, - NWHandlePath *NPathInfo, - PathCookie *NLMCookie, - LONG NewPathBufferSize, - BYTE *NewPathBuffer, - WORD *NewPathComponentSize, - WORD *NewPathComponentCount); - -extern LONG GenNSEffectiveDirectoryRights( - LONG Station, - NWHandlePath *NPathInfo, - BYTE SrcNameSpace, - BYTE DstNameSpace, - WORD SearchAttributes, - LONG ReturnInfoMask, - WORD *EffectiveRights, - NetwareInfo *NInfo, - BYTE *FileName); - -extern LONG GenNSRename( - LONG Station, - LONG Task, - NWHandlePath *SrcPathInfo, - NWHandlePath *DstPathInfo, - BYTE NameSpace, - WORD SearchAttributes); - -extern LONG GenNSOpenCreate( - LONG Station, - LONG Task, - NWHandlePath *NPathInfo, - BYTE NameSpace, - BYTE DataStream, - BYTE OpenCreateFlags, - WORD SearchAttributes, - WORD DesiredAccessRights, - LONG CreateAttributes, - LONG ReturnInfoMask, - LONG *FileHandle, - BYTE *OpenCreateAction, - NetwareInfo *NInfo, - BYTE *FileName); - -/****************************************************************************/ -/****************************************************************************/ -/* ************************ NCP 87 (Enhanced NCP) has subfunctions ************************** */ - -typedef struct NCPPathHandle /* used in CASE 87 Enhanced NCPs*/ -{ - BYTE Volume; - LONG DirectoryBaseOrHandle; - BYTE HandleFlag; - BYTE PCC; - BYTE PS; /* Path componenets start here.*/ - /* PathString may not be prenet if component count is 0*/ -} NCPHandlePath; - -typedef struct NCPShortHandlePath /* used in CASE 87 Enhanced NCPs*/ -{ /* Just like the HandlePath but doesn't include the actual path stuff*/ - BYTE Volume; - LONG DirectoryBaseOrHandle; - BYTE HandleFlag; - BYTE PCC; /*Path Component Count */ -} NCPShortHandlePath; - -/* ************************************************************************ */ -/* ************************************************************************ */ -/* ************************************************************************ */ -/* ************************************************************************ */ - -/* ************************ ncp 90 10 ************************** */ -typedef struct { - BYTE Skip[37]; - WORD SubFuncLen; - BYTE Subfunction; - LONG Volume; - LONG DirBase; - LONG NameSpace; -} ncp90_10; - -/* ************************ ncp 90 11 ************************** */ -typedef struct { - BYTE Skip[37]; - WORD SubFuncLen; - BYTE Subfunction; - LONG Handle; -} ncp90_11; - -/* ************************ ncp 90 12 ************************** */ -typedef struct { - BYTE Skip[37]; - WORD SubFuncLen; - BYTE Subfunction; - BYTE NetWareFileHandle[6]; - LONG SuggestedFileSize; -} ncp90_12; - -typedef struct { - LONG OldFileSize; - LONG NewFileSize; -} ncp90_12_reply; - -/****************************************************************************/ -/****************************************************************************/ - - -extern void ASyncWaitCallBack( - WORD connectionNumber, - LONG CompletionCode, - LONG Task); - -/* define the data structures. */ - -extern struct ASyncLockWaitStructure *ASyncDoneList; -extern struct ASyncLockWaitStructure *ATimeOutList; - -/* define AStatus values */ - -#define Inserting 0 -#define Waiting 1 -#define Done 2 -#define Pending 3 -#define NeedsFree 4 -#define OCAcked 5 - - -/* define the wait type values */ - -#define PhysicalRecordLock 0 -#define NonPhysicalRecordLock 1 -#define OpenCallbackType 2 - -struct ASyncLockWaitStructure -{ - struct ASyncLockWaitStructure *ALink; - LONG AStation; - LONG ATask; - LONG AHandle; - LONG ACompletionCode; - LONG ALastTime; - LONG AWaitThread; - LONG ATimeOutTime; - struct ASyncLockWaitStructure *ATOLink; - BYTE AStatus; - BYTE AWaitType; -}; - - -extern LONG (*DupFileHook)( - struct RequestPacketStructure *Request, - struct ReplyProceduresStructure *RP, - LONG reserved, LONG PacketSize, - BYTE *Answer, LONG AnswerBufferLength); - -/****************************************************************************/ -/****************************************************************************/ - -#define ssflReturnFileName 0x00000001 -#define psflPurgeAll 0x00000001 - -/* ncp 87 41 */ -typedef struct -{ - BYTE NameSpace; - BYTE reserved; - WORD ControlFlags; - LONG ScanSequence; - NWHandlePath NPathInfo; -} ScanSalvFileList; - -typedef struct -{ - LONG NextScanSequence; - LONG PurgeBase; - LONG ScanItems; - BYTE ScanInfo; -} ScanSalvFileListRep; - -/* ncp 87 42 */ -typedef struct -{ - BYTE NameSpace; - BYTE reserved; - WORD ControlFlags; - LONG Volume; - LONG PurgeBase; - LONG PurgeCount; - LONG PurgeList; /* PurgeList[PurgeCount] */ -} PurgeSalvFileList; - -typedef struct -{ - LONG PurgedCount; - LONG PurgedList; /* PurgedListpPurgedCount] */ -} PurgeSalvFileListRep; - - -/* NCP 87 43 */ -typedef struct -{ - BYTE reserved[3]; - BYTE queryFlag; /* set to 0x1 if just querying for current rights */ - LONG fileHandle; - LONG removeRights; -} RevokeFileHandleRightsReq; - -typedef struct -{ - LONG fileHandle; - LONG currentRights; -} RevokeFileHandleRightsRep; - -/* NCP 87 64 */ -typedef struct -{ - LONG FileHandle; /* hi - lo*/ - QUAD StartingByteOffset; /* hi - lo*/ - WORD BytesToRead; /* hi - lo*/ -} ReadFile64Req; - -typedef struct -{ - WORD BytesActuallyRead; /* hi - lo*/ - BYTE Data; -} ReadFile64Rep; - -/* NCP 87 65 */ -typedef struct -{ - LONG FileHandle; /* hi - lo*/ - QUAD StartingByteOffset; /* hi - lo*/ - WORD BytesToWrite; /* hi - lo*/ - BYTE WriteBuffer; -} WriteFile64Req; - -/* NCP 87 66 */ -typedef struct -{ - LONG FileHandle; /* hi-lo*/ -} GetFileSize64Req; - -typedef struct -{ - QUAD CurrentFileSize; /* lo - hi*/ -} GetFileSize64Rep; - -/* NCP 87 67 */ -typedef struct -{ - LONG LockFlag; /* lo - hi*/ - LONG FileHandle; /* hi - lo*/ - QUAD LockAreaStartOffset; /* hi - lo*/ - QUAD LockAreaLength; /* hi - lo*/ - LONG LockTimeout; /* hi - lo*/ -} LogPhysicalRecord64Req; - -/* NCP 87 68 */ -typedef struct -{ - LONG FileHandle; /* hi - lo*/ - QUAD LockAreaStartOffset; /* hi - lo*/ - QUAD LockAreaLength; /* hi - lo*/ -} ReleasePhysicalRecord64Req; - -/* NCP 87 69 */ -typedef struct -{ - LONG FileHandle; /* hi - lo*/ - QUAD LockAreaStartOffset; /* hi - lo*/ - QUAD LockAreaLength; /* hi - lo*/ -} ClearPhysicalRecord64Req; - -#if NTCLIENTECO -/* NCP 87 44 */ -typedef struct -{ - BYTE reserved[2]; - BYTE volumeNumber; - BYTE nameSpace; - LONG directoryNumber; - WORD oldAccessRights; - WORD newAccessRights; - LONG fileHandle; -} UpdateFileHandleRightsReq; - -typedef struct -{ - LONG fileHandle; - LONG currentRights; -} UpdateFileHandleRightsRep; - -/* in LOCKS1.C */ -extern LONG UpdateFileHandleRights( - LONG Station, - LONG Task, - LONG VolumeNumber, - LONG NameSpace, - LONG DirectoryNumber, - LONG OldAccessRights, - LONG NewAccessRights, - LONG FileHandle, - LONG *newRights); -#endif - -#if 0 -/* in LOCKS1.C */ -extern LONG RevokeFileHandleRights( - LONG Station, - LONG Task, - LONG FileHandle, - LONG QueryFlag, - LONG removeRights, - LONG *newRights); - -extern LONG F3ScanSalvageFileList( - LONG Station, - LONG NameSpace, - LONG Volume, - LONG PathCount, - LONG PathBase, - BYTE *PathString, - LONG ControlFlags, - LONG ScanSequence, - LONG *NextScanSequence, - LONG *PurgeBase, - BYTE *info, - LONG *itemCount, - LONG *listSize); - -extern LONG F3PurgeSalvageFileList( - LONG Station, - LONG NameSpace, - LONG Volume, - LONG PurgeBase, - LONG ControlFlags, - LONG *PurgeCount, - LONG *PurgeList, - LONG *PurgeCCodeCount, - LONG *PurgeCCodeList); - - -#endif - -#endif /* __ENCP_H__ */ diff --git a/include/nwnss/support/lnxmbINC/errors.h b/include/nwnss/support/lnxmbINC/errors.h deleted file mode 100644 index 78e62b8..0000000 --- a/include/nwnss/support/lnxmbINC/errors.h +++ /dev/null @@ -1,280 +0,0 @@ -#ifndef __ERRORS_H__ -#define __ERRORS_H__ -/***************************************************************************** - * - * (C) Copyright 1988-1994 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Revision: 465 $ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Author: taysom $ - * - ****************************************************************************/ - - -/* ERROR CODES */ - -#define OK 000 -#define ERR_INSUFFICIENT_SPACE 001 -#define ERR_TTS_OUT_OF_RESOURCES 002 - -#define ERR_REVOKE_HANDLE_RIGHTS_NOT_FOUND 115 /* 0x73 - also defined in locks.h */ -#define ERR_REMOTE_NOT_ALLOWED 116 /* 0x74 - also defined in locks.h */ -#define ERR_UNKNOWN_SUCCESS_OR_FAILURE 117 /* 0x75 */ -#define ERR_BUFFER_NOT_LONG_ALIGNED 118 /* 0x76 */ -#define ERR_BUFFER_TOO_SMALL 119 /* 0x77 */ -#define ERR_VOLUME_FLAG_NOT_SET 120 /* 0x78 */ -#define ERR_NO_ITEMS_FOUND 121 /* 0x79 */ -#define ERR_CONNECTION_ALREADY_TEMPORARY 122 /* 0x7a */ -#define ERR_CONNECTION_ALREADY_LOGGED_IN 123 /* 0x7b */ -#define ERR_CONNECTION_NOT_AUTHENTICATED 124 /* 0x7c */ -#define ERR_CONNECTION_NOT_LOGGED_IN 125 /* 0x7d */ -#define ERR_NCP_BOUNDARY_CHECK_FAILED 126 /* 0x7e */ -#define ERR_LOCK_WAITING 127 /* 0x7f */ -#define ERR_LOCK_FAIL 128 /* 0x80 */ -#define ERR_OUT_OF_HANDLES 129 /* 0x81 */ -#define ERR_NO_OPEN_PRIVILEGE 130 /* 0x82 */ -#define ERR_HARD_IO_ERROR 131 /* 0x83 */ -#define ERR_NO_CREATE_PRIVILEGE 132 /* 0x84 */ -#define ERR_NO_CREATE_DELETE_PRIVILEGE 133 /* 0x85 */ -#define ERR_R_O_CREATE_FILE 134 /* 0x86 */ -#define ERR_CREATE_FILE_INVALID_NAME 135 /* 0x87 */ -#define ERR_INVALID_FILE_HANDLE 136 /* 0x88 */ -#define ERR_NO_SEARCH_PRIVILEGE 137 /* 0x89 */ -#define ERR_NO_DELETE_PRIVILEGE 138 /* 0x8a */ -#define ERR_NO_RENAME_PRIVILEGE 139 /* 0x8b */ -#define ERR_NO_SET_PRIVILEGE 140 /* 0x8c */ -#define ERR_SOME_FILES_IN_USE 141 /* 0x8d */ -#define ERR_ALL_FILES_IN_USE 142 /* 0x8e */ -#define ERR_SOME_READ_ONLY 143 /* 0x8f */ -#define ERR_ALL_READ_ONLY 144 /* 0x90 */ -#define ERR_SOME_NAMES_EXIST 145 /* 0x91 */ -#define ERR_ALL_NAMES_EXIST 146 /* 0x92 */ -#define ERR_NO_READ_PRIVILEGE 147 /* 0x93 */ -#define ERR_NO_WRITE_PRIVILEGE 148 /* 0x94 */ -#define ERR_FILE_DETACHED 149 /* 0x95 */ -#define ERR_NO_ALLOC_SPACE 150 /* 0x96 */ -#define ERR_TARGET_NOT_A_SUBDIRECTORY 150 /* 0x97 */ -#define ERR_NO_SPOOL_SPACE 151 /* 0x97 */ -#define ERR_INVALID_VOLUME 152 /* 0x98 */ -#define ERR_DIRECTORY_FULL 153 /* 0x99 */ -#define ERR_RENAME_ACROSS_VOLUME 154 /* 0x9a */ -#define ERR_BAD_DIR_HANDLE 155 /* 0x9b */ -#define ERR_INVALID_PATH 156 /* 0x9c */ -#define ERR_NO_SUCH_EXTENSION 156 /* 0x9d */ -#define ERR_NO_DIR_HANDLES 157 /* 0x9d */ -#define ERR_BAD_FILE_NAME 158 /* 0x9e */ -#define ERR_DIRECTORY_ACTIVE 159 /* 0x9f */ -#define ERR_DIRECTORY_NOT_EMPTY 160 /* 0xa0 */ -#define ERR_DIRECTORY_IO_ERROR 161 /* 0xa1 */ -#define ERR_IO_LOCKED 162 /* 0xa2 */ -#define ERR_TRANSACTION_RESTARTED 163 /* 0xa3 */ -#define ERR_RENAME_DIR_INVALID 164 /* 0xa4 */ -#define ERR_INVALID_OPENCREATE_MODE 165 /* 0xa5 */ -#define ERR_ALREADY_IN_USE 166 /* 0xa6 */ -#define ERR_INVALID_RESOURCE_TAG 167 /* 0xa7 */ -#define ERR_ACCESS_DENIED 168 /* 0xa8 */ - -#define ERR_INVALID_DATA_STREAM 190 /* 0xbe */ -#define ERR_INVALID_NAME_SPACE 191 /* 0xbf */ -#define ERR_NO_ACCOUNTING_PRIVILEGES 192 /* 0xc0 */ -#define ERR_NO_ACCOUNT_BALANCE 193 /* 0xc1 */ -#define ERR_CREDIT_LIMIT_EXCEEDED 194 /* 0xc2 */ -#define ERR_TOO_MANY_HOLDS 195 /* 0xc3 */ -#define ERR_ACCOUNTING_DISABLED 196 /* 0xc4 */ -#define ERR_LOGIN_LOCKOUT 197 /* 0xc5 */ -#define ERR_NO_CONSOLE_RIGHTS 198 /* 0xc6 */ - -#define ERR_Q_IO_FAILURE 208 /* 0xd0 */ -#define ERR_NO_QUEUE 209 /* 0xd1 */ -#define ERR_NO_Q_SERVER 210 /* 0xd2 */ -#define ERR_NO_Q_RIGHTS 211 /* 0xd3 */ -#define ERR_Q_FULL 212 /* 0xd4 */ -#define ERR_NO_Q_JOB 213 /* 0xd5 */ -#define ERR_NO_Q_JOB_RIGHTS 214 /* 0xd6 */ -#define ERR_UNENCRYPTED_NOT_ALLOWED 214 /* 0xd6 */ -#define ERR_Q_IN_SERVICE 215 /* 0xd7 */ -#define ERR_DUPLICATE_PASSWORD 215 /* 0xd7 */ -#define ERR_Q_NOT_ACTIVE 216 /* 0xd8 */ -#define ERR_PASSWORD_TOO_SHORT 216 /* 0xd8 */ -#define ERR_Q_STN_NOT_SERVER 217 /* 0xd9 */ -#define ERR_MAXIMUM_LOGINS_EXCEEDED 217 /* 0xd9 */ -#define ERR_Q_HALTED 218 /* 0xda */ -#define ERR_BAD_LOGIN_TIME 218 /* 0xda */ -#define ERR_Q_MAX_SERVERS 219 /* 0xdb */ -#define ERR_NODE_ADDRESS_VIOLATION 219 /* 0xdb */ -#define ERR_LOG_ACCOUNT_EXPIRED 220 /* 0xdc */ -#define ERR_BAD_PASSWORD 222 /* 0xde */ -#define ERR_PASSWORD_EXPIRED 223 /* 0xdf */ -#define ERR_NO_LOGIN_CONNECTIONS_AVAILABLE 224 /* 0xe0 */ - -#define ERR_WRITE_TO_GROUP_PROPERTY 232 /* 0xe8 */ -#define ERR_MEMBER_ALREADY_EXISTS 233 /* 0xe9 */ -#define ERR_NO_SUCH_MEMBER 234 /* 0xea */ -#define ERR_PROPERTY_NOT_GROUP 235 /* 0xeb */ -#define ERR_NO_SUCH_VALUE_SET 236 /* 0xec */ -#define ERR_PROPERTY_ALREADY_EXISTS 237 /* 0xed */ -#define ERR_OBJECT_ALREADY_EXISTS 238 /* 0xee */ -#define ERR_ILLEGAL_NAME 239 /* 0xef */ -#define ERR_ILLEGAL_WILDCARD 240 /* 0xf0 */ -#define ERR_BINDERY_SECURITY 241 /* 0xf1 */ -#define ERR_NO_OBJECT_READ_RIGHTS 242 /* 0xf2 */ -#define ERR_NO_OBJECT_RENAME_RIGHTS 243 /* 0xf3 */ -#define ERR_NO_OBJECT_DELETE_RIGHTS 244 /* 0xf4 */ -#define ERR_NO_OBJECT_CREATE_RIGHTS 245 /* 0xf5 */ -#define ERR_NO_PROPERTY_DELETE_RIGHTS 246 /* 0xf6 */ -#define ERR_NO_PROPERTY_CREATE_RIGHTS 247 /* 0xf7 */ -#define ERR_NO_PROPERTY_WRITE_RIGHTS 248 /* 0xf8 */ -#define ERR_NO_PROPERTY_READ_RIGHTS 249 /* 0xf9 */ -#define ERR_TEMP_REMAP 250 /* 0xfa */ -#define ERR_UNKNOWN_REQUEST 251 /* 0xfb */ -#define ERR_NO_SUCH_PROPERTY 251 /* 0xfb */ -#define ERR_MESSAGE_QUEUE_FULL 252 /* 0xfc */ -#define ERR_TARGET_ALREADY_HAS_MESSAGE 252 /* 0xfc */ -#define ERR_NO_SUCH_OBJECT 252 /* 0xfc */ -#define ERR_BAD_STATION_NUMBER 253 /* 0xfd */ -#define ERR_BINDERY_LOCKED 254 /* 0xfe */ -#define ERR_DIR_LOCKED 254 /* 0xfe */ -#define ERR_SPOOL_DELETE 254 /* 0xfe */ -#define ERR_TRUSTEE_NOT_FOUND 254 /* 0xfe */ -#define ERR_HARD_FAILURE 255 /* 0xff */ -#define ERR_FILE_NAME 255 /* 0xff */ -#define ERR_FILE_EXISTS 255 /* 0xff */ -#define ERR_CLOSE_FCB 255 /* 0xff */ -#define ERR_IO_BOUND 255 /* 0xff */ -#define ERR_NO_SPOOL_FILE 255 /* 0xff */ -#define ERR_BAD_SPOOL_PRINTER 255 /* 0xff */ -#define ERR_BAD_PARAMETER 255 /* 0xff */ -#define ERR_NO_FILES_FOUND 255 /* 0xff */ -#define ERR_NO_TRUSTEE_CHANGE_PRIVILEGE 255 /* 0xff */ -#define ERR_TARGET_NOT_LOGGED_IN 255 /* 0xff */ -#define ERR_TARGET_NOT_ACCEPTING_MESSAGES 255 /* 0xff */ -#define ERR_MUST_FORCE_DOWN 255 /* 0xff */ -#define ERR_CHECKSUM_REQUIRED 255 /* 0xff */ -#define ERR_SERVICE_ALREADY_LOADED 256 /* 0x100 */ -#define ERR_SERVICE_NOT_LOADED 257 /* 0x101 */ -#define ERR_INCORRECT_VERSION 258 /* 0x102 */ -#define ERR_NO_MEMORY_READ_ACCESS 259 /* 0x103 */ -#define ERR_NO_MEMORY_WRITE_ACCESS 260 /* 0x104 */ - -/* The following errors are returned in a LONG */ -#define ERR_MODULE_NOT_UNLOADED 513 -#define ERR_MODULE_NOT_LOADED 514 -#define ERR_UNABLE_TO_MOUNT_VOLUME 515 -#define ERR_UNABLE_TO_DISMOUNT_VOLUME 516 -#define ERR_UNABLE_TO_ADD_NAME_SPACE 517 -#define ERR_UNABLE_TO_SET_PARAMETER_VALUE 518 -#define ERR_UNABLE_TO_EXECUTE_NCF_FILE 519 - -/****************************************************************************/ -/* - -The following sections catagorize error codes by the routines that return -them ------------------------------------------------------------------------------- -Return codes from login procedures - - ERR_LOG_ACCOUNT_EXPIRED - ERR_NODE_ADDRESS_VIOLATION - ERR_BAD_LOGIN_TIME - ERR_MAXIMUM_LOGINS_EXCEEDED - ERR_PASSWORD_TOO_SHORT - ERR_DUPLICATE_PASSWORD - ERR_UNENCRYPTED_NOT_ALLOWED - ERR_LOGIN_LOCKOUT - ERR_PASSWORD_EXPIRED - ERR_BAD_PASSWORD - - Note that ERR_BAD_PASSWORD is used for two reasons - 1) on a login call, it means the password was correct, but it has - expired and all grace logins have been used up. - 2) on a change password call, it means that the old password given was - correct, but the account is not allowed to change the password - (typical of the GUEST account). - ERR_BAD_PASSWORD is not used to indicate that an incorrect password was - given, instead 255 indicates that the given password was invalid, - no such account exists, etc. - ------------------------------------------------------------------------------- -Return codes from accounting procedures - - ERR_NO_ACCOUNTING_PRIVILEGES - ERR_NO_ACCOUNT_BALANCE - ERR_CREDIT_LIMIT_EXCEEDED - ERR_TOO_MANY_HOLDS - ERR_ACCOUNTING_DISABLED - ------------------------------------------------------------------------------- -Return codes from queue procedures - - ERR_Q_IO_FAILURE - ERR_NO_QUEUE - ERR_NO_Q_SERVER - ERR_NO_Q_RIGHTS - ERR_Q_FULL - ERR_NO_Q_JOB - ERR_NO_Q_JOB_RIGHTS - ERR_Q_IN_SERVICE - ERR_Q_NOT_ACTIVE - ERR_Q_STN_NOT_SERVER - ERR_Q_HALTED - ERR_Q_MAX_SERVERS - ------------------------------------------------------------------------------- -Return codes from broadcast procedures - - ERR_TARGET_NOT_LOGGED_IN - ERR_TARGET_NOT_ACCEPTING_MESSAGES - ERR_TARGET_ALREADY_HAS_MESSAGE - ------------------------------------------------------------------------------- -Return codes from bindery procedures - - ERR_HARD_FAILURE Unrecoverable error (disk error, etc.) - ERR_BINDERY_LOCKED - ERR_NO_SUCH_OBJECT - ERR_NO_SUCH_PROPERTY - ERR_NO_PROPERTY_READ_RIGHTS - ERR_NO_PROPERTY_WRITE_RIGHTS - ERR_NO_PROPERTY_CREATE_RIGHTS No Property Creation or Change privileges - ERR_NO_PROPERTY_DELETE_RIGHTS - ERR_NO_OBJECT_CREATE_RIGHTS No Object Creation or Change privileges - ERR_NO_OBJECT_DELETE_RIGHTS - ERR_NO_OBJECT_RENAME_RIGHTS - ERR_NO_OBJECT_READ_RIGHTS No Object Read (Property Scan) privileges - ERR_BINDERY_SECURITY Attempt to change security to bindery-only status - ERR_ILLEGAL_WILDCARD - ERR_ILLEGAL_NAME - ERR_OBJECT_ALREADY_EXISTS - ERR_PROPERTY_ALREADY_EXISTS - ERR_NO_SUCH_VALUE_SET No property value to retrieve (in read/write) - ERR_PROPERTY_NOT_GROUP Set request made for non-set property - ERR_NO_SUCH_MEMBER Set request for non-existent member - ERR_MEMBER_ALREADY_EXISTS Setadd request for member already in set - ERR_WRITE_TO_GROUP_PROPERTY Attempt to Write Property to a set - - OK Operation successfully completed ------------------------------------------------------------------------------- -*/ - -/****************************************************************************/ -/****************************************************************************/ - - -#endif /* __ERRORS_H__ */ diff --git a/include/nwnss/support/lnxmbINC/event.h b/include/nwnss/support/lnxmbINC/event.h deleted file mode 100644 index a3eef7e..0000000 --- a/include/nwnss/support/lnxmbINC/event.h +++ /dev/null @@ -1,1331 +0,0 @@ -#ifndef __EVENT_H__ -#define __EVENT_H__ - -/***************************************************************************** - * - * (C) Copyright 1988-1996 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Revision: 465 $ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Author: taysom $ - * - ****************************************************************************/ - - -// -// WARNING!!!: -// The defintions are also used by CLIB, and are -// made available in the SDK through a separate -// header file. Ensure that modifications to this -// file are in sync with CLIB's SDK header files. -// - - - -#define EnumerateForConnection 0x00000001 -#define EnumerateForKnownEvents 0x00000002 - -// -// A consumer registering for an event sets -// this flag in the event type (which is being -// subscribed to) to denote that the consumer -// is MT safe. This allows us to distinguish -// MT safe consumers from MT unsafe ones. -// - -#define EVENT_CONSUMER_MT_SAFE 0x40000000 - -typedef struct QueuedEventStructure -{ - struct QueuedEventStructure *next; - LONG type; - void *parameter; - BYTE data[1]; -} QueuedEventStruct_t; - -#define INDEX_MASK 0xffff -#define MAX_INDEXS 0x10000 - -/* events with lower priority will be notified first */ -#define EVENT_PRIORITY_OS 0 -#define EVENT_PRIORITY_APPLICATION 20 -#define EVENT_PRIORITY_DEVICE 40 - -#define EVENT_CAN_SLEEP 1 - -#define EVENT_VOL_SYS_MOUNT 0 - /* parameter is undefined. Report Routine will be called immediately - * after vol SYS has been mounted. - */ - -#define EVENT_VOL_SYS_DISMOUNT 1 - /* parameter is undefined . Warn Routine and Report Routine will be - * called before vol SYS is dismounted. - */ - -#define EVENT_ANY_VOL_MOUNT 2 - /* parameter is volume number. Report Routine will be called immediately - * after any volume is mounted. - */ - -#define EVENT_ANY_VOL_DISMOUNT 3 - /* parameter is volume number. Warn Routine and Report Routine will be - * called before any volume is dismounted. - */ - -#define EVENT_DOWN_SERVER 4 - /* parameter is undefined. Warn Routine and Report Routine will be - * called before the server is shut down. The DS.NLM uses this event - * to shutdown the database. If you DS services, use the - * EVENT_PRE_DOWN_SERVER event instead. - */ - -#define EVENT_CHANGE_TO_REAL_MODE 5 - /* parameters is a flag mask containing the following. - * #define REAL_MODE_NESTED_INTERRRUPTS 0x00000001 - * #define REAL_MODE_INTERRUPTS_DISABLED 0x00000002 - * - * Report routine will be called before the server changes to real mode. - * This event is marked as may NOT sleep, however in most cases it - * really can. Some drivers needed to block until their device had - * finished outstanding IOs, so they have implemented a work around to - * the fact that this event may NOT sleep, by calling EndSleepNotAllowed - * doing whatever they needed to do (including blocking) and then - * calling StartSleepNotAllowed. Others needing to do the same should - * use the same method, however they must remember that if either - * the in debugger or ISR flag is set, we are in the context of the - * debugger and they cannot block or enable interrupts and therefore - * should not do the work around. - */ - -#define EVENT_RETURN_FROM_REAL_MODE 6 - /* parameters is a flag mask containing the following. - * #define REAL_MODE_NESTED_INTERRRUPTS 0x00000001 - * #define REAL_MODE_INTERRUPTS_DISABLED 0x00000002 - * - * Report routine will be called after the server has returned - * from real mode. - */ - -#define EVENT_EXIT_TO_DOS 7 - /* parameter is undefined. The Report Routine will be called before the - * server exits to DOS. - */ - -// -// EVENT_EXIT_TO_DOS: -// Even though this event is supposed to be non-blocking, many drivers -// do actually block EVEN while in the debugger! This typically happens -// when exiting to DOS from the debugger using the "q" debugger command. -// - -#define EVENT_MODULE_UNLOAD 8 - /* parameter is module handle. Warn Routine and Report Routine will be - * called when a module is unloaded from the console command line. Only - * the Report Routine will be called when a module unloads itself. - */ - -#define EVENT_CLEAR_CONNECTION 9 - /* parameter is connection number. Report Routine is called before the - * connection is cleared. - */ - -#define EVENT_LOGIN_CONNECTION 10 -#define EVENT_LOGIN_USER 10 - /* parameter is connection number. Report Routine is called after the - * connection has been logged in. - */ - -#define EVENT_CREATE_BINDERY_OBJ 11 - /* parameter is object ID. Report Routine is called after the object is - * created and entered in the bindery. - */ - -#define EVENT_DELETE_BINDERY_OBJ 12 - /* parameter is object ID. Report Routine is called before the object is - * removed from the bindery. - */ - -#define EVENT_CHANGE_SECURITY 13 - /* parameter is a pointer a structure of type EventSecurityChangeStruct. - * Report Routine is called after a security - * equivalence change has occurred. - */ - -#define EVENT_ACTIVATE_SCREEN 14 - /* Parameter is screen ID. Report routine is called after the - * screen becomes the active screen. - */ - -#define EVENT_UPDATE_SCREEN 15 - /* Parameter is screen ID. Report routine is called after a change is - * made to the screen image. - */ - -#define EVENT_UPDATE_CURSOR 16 - /* Parameter is screen ID. Report routine is called after a change to - * the cursor position or state occurs. - */ - -#define EVENT_KEY_WAS_PRESSED 17 - /* Parameter is undefined. Report routine is called whenever a - * key on the keyboard is pressed (including shift/alt/control). - * This routine is called at interrupt time. - */ - -#define EVENT_DEACTIVATE_SCREEN 18 - /* Parameter is screen ID. Report routine is called when the - * screen becomes inactive. - */ - -#define EVENT_TRUSTEE_CHANGE 19 - /* Parameter is a pointer to type struct EventTrusteeChangeStruct. The - * report routine is called everytime there is a change to a trustee in - * the file system. Shouldn't sleep. - */ - -#define EVENT_OPEN_SCREEN 20 - /* Parameter is the screen ID for the newly created screen. The report - * routine will be called after the screen is created. - */ - -#define EVENT_CLOSE_SCREEN 21 - /* Parameter is the screen ID for the screen that will be closed. The - * report routine will be called before the screen is closed. - */ - -#define EVENT_MODIFY_DIR_ENTRY 22 - /* Parameter is a pointer to a structure of type EventModifyDirEntryStruct - * which contains the modify information. The report routine will be - * called right after the entry is changed but before the directory - * entry is unlocked. The report routine must not go to sleep. - */ - -#define EVENT_NO_RELINQUISH_CONTROL 23 - /* Parameter is the running process. This will be called when the - * timer detects that a process is hogging the processor. The report - * routine must not sleep. - */ - -#define EVENT_SYSTEM_ALERT 24 - /* Parameter is a pointer to a structure of type EventSystemAlertStruct - * which contains the modify information. The report routine will be - * called whenever a system alert is generated. The report routine may - * sleep. - *********** NOTE - this event is no longer generated in v3.2 ************* - */ - -#define EVENT_CLIB_DEFINED_1 25 -#define EVENT_CLIB_DEFINED_2 26 - -#define EVENT_MODULE_LOAD 27 - /* parameter is module handle. The report routine will be called - * after a module has loaded. - */ - -// -// The next two events, EVENT_CREATE_PROCESS and EVENT_DESTROY_PROCESS -// are issued only for legacy threads. They are not issued for MPK -// threads. These events are considered obsolete. The MT safe events -// EVENT_CREATE_THREAD and EVENT_DESTROY_THREAD should be used instead. -// Since the legacy threads are always created and destroyed on processor -// 0, these events will never be issued on any processor other than 0. -// - -#define EVENT_CREATE_PROCESS 28 - /* parameter is the PID of the process being created. It is called - * after the process is created. The report routine may not sleep. - */ - -#define EVENT_DESTROY_PROCESS 29 - /* parameter is the PID of the process being destroyed. It is called - * before the process is actually destroyed. The report routine may not - * sleep. - */ - -#define EVENT_INW_SYS_ALERT 30 - /* Parameter is a pointer to a structure of type - * EventINWSystemAlertStruct. The report routine may sleep. - * - *********** NOTE - this event is no longer generated in v3.2 ************* - */ - -#define EVENT_END_OF_TASK 31 - /* Parameter is a pointer to a structure of type EndOfTaskStruct. The - * report routine is called before the end of task is actually performed - * and may sleep. - */ - -#define EVENT_NEW_PUBLIC 32 - /* Parameter is a pointer to a length preceded string which is the name - * of the new public entry point. This event may not sleep. - */ - -#define EVENT_PROTOCOL_BIND 33 - /* Parameter is a pointer to a structure of type EventProtocolBindStruct. - * This event is generated every time a board is bound to a protocol. - * This event may sleep. - */ - -#define EVENT_PROTOCOL_UNBIND 34 - /* Parameter is a pointer to a structure of type EventProtocolBindStruct. - * This event is generated every time a board is unbound from a protocol. - * This event may sleep. - */ - -#define EVENT_GENERIC 35 - -#define EVENT_VOL_AUDIT_RESET 36 - /* Parameter is the Volume Number - * This event is generated when the audit file for the indicated volume - * is reset. - * This event may sleep - */ - -#define EVENT_ALLOCATE_CONNECTION 37 - /* parameter is connection number. Report Routine is called after the - * connection is allocated. - */ - -#define EVENT_LOGOUT_CONNECTION 38 - /* parameter is connection number. Report Routine is called before the - * connection is logged out. - */ - -#define EVENT_MLID_REGISTER 39 - /* parameter is board number. Report Routine is called after the MLID - * is registered. - */ - -#define EVENT_MLID_DEREGISTER 40 - /* parameter is board number. Report Routine is called before the MLID - * is deregistered. - */ - -#define EVENT_DATA_MIGRATION 41 - /* Parameter is a pointer to a structure of type EventDataMigrationInfo. - * This event is generated when a file's data has been migrated. - */ - -#define EVENT_DATA_DEMIGRATION 42 - /* Parameter is a pointer to a structure of type EventDataMigrationInfo. - * This event is generated when a file's data has been de-migrated. - */ - -#define EVENT_QUEUE_ACTION 43 - /* Parameter is a pointer to a structure of type EventQueueNote. - * This event is generated when a queue is activated, deactivated, - * created, or deleted. - */ - -#define EVENT_NETWARE_ALERT 44 - /* Parameter is a pointer to a structure of type EventNetwareAlertStruct. - * This event is generated anytime the following alert calls are - * made: - * SystemAlert NW 3.0 - * QueueSystemAlert NW 3.0 - * INWSystemAlert NW 3.11 (temp) - * INWQueueSystemAlert NW 3.11 (temp) - * NetWareAlert NW 3.2 - * - * The report routine may sleep. - */ - -#define EVENT_INIT_STATE 45 - /* Parameter is a value indication the stage we are at in the - * initialization process. 0 - Start of OSMain, 1 - Before Startup, - * 2 - After Startup, 3 - Before Autoexec, 4 - After Autoexec. - * The report routine may sleep. - */ - -#define EVENT_CREATE_OBJECT 46 - /* Parameter is a pointer to a structure of type EventBinderyObject - * or EventDSObject - */ - -#define EVENT_DELETE_OBJECT 47 - /* Parameter is a pointer to a structure of type EventBinderyObject - * or EventDSObject - */ - -#define EVENT_RENAME_OBJECT 48 - /* Parameter is a pointer to a structure of type EventBinderyObject - * or EventDSObject - */ - -#define EVENT_VALUE_CHANGE 49 - /* Parameter is a pointer to a structure of type EventBinderyObject - * or EventDSObject - */ - -#define EVENT_CLOSE_FILE 50 - /* Parameter is a pointer to a structure of type EventCloseFileInfo. */ - -#define EVENT_CHANGE_TIME 51 - /* This event is given when the time is changed by a call to - * SetTimeFromVector or when Time Synchronization schedules - * a nonuniform adjustment. The parameter is the UTC time (in seconds) - * before the time change. The current time is available from the OS. - * Since you have no way of knowing the magnitudue of the time change, - * nor whether it has taken place or is scheduled for the next clock - * interrupt, you must detect the time change on your own. In general, - * if current time is less than old time, or at least two seconds ahead - * of old time, then the time change has been applied. You must wait - * for one of those conditions to be sure that the time change has - * "settled down" before you can assume that the event has "happened." - */ - -#define EVENT_MOVE_OBJECT 52 - /* Parameter is a pointer to a structure of type EventBinderyObject - * or EventDSObject - */ - -#define EVENT_VALUE_ADD 53 - /* Parameter is a pointer to a structure of type EventBinderyObject - * or EventDSObject - */ - -#define EVENT_VALUE_DEL 54 - /* Parameter is a pointer to a structure of type EventBinderyObject - * or EventDSObject - */ - -#define EVENT_DM_KEY_MODIFIED 55 - /* Parameter is a pointer to a structure of type EventDMKeyModified - */ - -#define EVENT_MODULE_UNLOADED 56 - /* Parameter is module handle. Report Routine will be called after the - * NLM's exit routine has been called, after his resources have been - * returned to the OS, and after he has been unlinked from the OS's lists. - * The only thing left of this NLM is the memory for his load definition - * structure, data image, and code image. - */ - -#define EVENT_REMOVE_PUBLIC 57 - /* Parameter is the address of the public entry point. This only happens - * on module unload. - */ - -#define EVENT_DS_EVENT 58 - /* Parameter is the address of a DS defined event structure */ - -#define EVENT_UNICODE 59 - /* Parameter is the address of a UNICODE defined event structure */ - - -#define EVENT_ALTERNATE_MOUNT_VOLUME 63 - /* called when NetWare is not aware of the volume name to be mounted, */ - /* Parameter is used to pass a event structure EventAlternateMountVolume.*/ - /* This event report is allowed to sleep, also the return code is in the */ - /* structre, after it has been processed. */ - -#define EVENT_CONSOLE_CONFIG_COMMAND 64 - /* called when the console command CONFIG is typed on the server command */ - /* line. The event report is allowed to sleep. The console screen handle */ - /* pointer is passed as the only parameter */ - -#define EVENT_CONSOLE_VERSION_COMMAND 65 - /* called when the console command VERSION is typed on the server command */ - /* line. The event report is allowed to sleep. A pointer to the structure */ - /* struct EventConfigVersionCmdInfo to help in the displaying to the screen */ - -#define EVENT_PRE_LOAD_NLM 66 - /* called while an NLM is being loaded but before most of the work is - * done. The data and code segments have not been allocated yet. The - * event report is allowed to sleep. The parameter is a pointer to an - * NLM Load File Header structure. - */ - -#define EVENT_LOW_MEMORY 67 - /* called when the cache memory allocator tries to allocate a cache block - * and fails; only one event per minute will be generated. It happens - * in conjunction with the netware alert. The event report can block. - * The parameter is a zero. This event is mainly for OS2 based NetWare - * so it can try to borrow memory back from OS2. - */ - -#define EVENT_COMPRESS_FILE 68 - /* at the beginning of a file compression after all pre-checks have - successfully completed. A CompressStatus_t structure will be - passed as the parameter. - */ -#define EVENT_DECOMPRESS_FILE 69 - /* at the beginning of a file decompression after all pre-checks have - successfully completed. A DecompressStatus_t structure will be - passed as the parameter. - */ - -#define EVENT_ABEND_NOTIFY 70 - /* Called after an Abend, before prompting the user if he wants to - do diagnostics or exit. A pointer to the Stack Frame will be - passed as a parameter. This event report is not allowed to sleep. - */ - -/* NW 4.20 only */ -#define EVENT_DO_DIAGNOSTICS 71 - /* Called when the user requests diagnostics to be done. (Either - when prompted after an Abend or from the internal debugger.) - A pointer to the Stack Frame will be passed as a parameter. - This event report is not allowed to sleep. - */ - -#define EVENT_MODULE_LOAD_FAIL 72 - /* Called when an NLM load fails. The parameter is a pointer to a - * Structure of type EventNLMLoadFailStruct. This event may sleep. - */ - -#define EVENT_USER_RESTRICTIONS 73 - /* Called when AddUserRestrictions or DeleteUserRestrictions is - called. The parameter is a pointer to a structure of type - EventUserRestrictionsStruct. This event may sleep. - */ - -#define EVENT_DAYLIGHT_SAVINGS_TIME_CHANGED 74 - /* in 4.20 */ - -#define EVENT_ABEND_LOG 75 - /* Called when be are building an abend log file entry. The parameter - * is a pointer to a buffer containing the log entry. The buffer is - * a 4K buffer, and can be added to as needed. This event may not - * sleep. - */ - -#define EVENT_PAGE_TABLE_CHANGE 76 - /* Called when the page tables are changed. This is useful for syncing - * up multiple page tables on multiple CPUs or with memory protection - * domains. The parameter is the logical address where something was - * mapped in or mapped out. This event cannot sleep. - */ - -#define EVENT_NAME_SPACE_ADDED 77 - /* Called when a Name Space is added to a volume. The parameter is a - * pointer to the EventAddNameSpaceStruc. This event may sleep. - */ - -#define EVENT_SET_PARAMETER_CHANGED 78 - /* Called when a set parameter is changed. The parameter is a - * pointer to the EventSetParameter. This event may sleep. - */ - -#define EVENT_NAME_SERVICE_STATE_CHANGE 79 - /* Called when the name service is loaded or unloaded or - * the bindery state changes (open or closed). The - * parameter is defined as follows: - * Bit Number Definition - * 0 Name Service Loaded if set - * 16 Bindery is open - * - * all other bits are reserved and set to zero - */ - -#define EVENT_IPX_INTERNAL_NET_NUMBER_SET 80 - /* Called when IPX Internal Net Number is set. The parameter - * passed to the notification routine is the IPX net number. - * PLEASE NOTE THE NET NUMBER IS IN NETWORK ORDER (HI-LO). - * This event may sleep. - */ - -#define EVENT_DOWN_ROUTER 81 - /* This event is generated when the OS wants the router, - * to go down. - * This event may & will sleep - */ - -#define EVENT_IOCONFIG_CHANGE 82 - /* This event is generated each time the IOConfigurationList */ - /* is modified. The parameter points to a structure whose first */ - /* element is 1 for add and 2 for delete, and second element is */ - /* a pointer to the IOConfigurationStructure being added or removed. */ - /* This event may NOT sleep. */ - -#define EVENT_SERVER_SHUTDOWN 83 - /* parameter is undefined. This is called after everything has - * been stop or shutdown when downing the server. - */ - -#define EVENT_PROCESSOR_ONLINE_OFFLINE 84 - /* parameter is the processor number. This event is generated each - * time the number of on line or off line processors changes. Since - * a spinlock is acquired, to prevent multiple processors from coming - * and going concurrently, this event may NOT sleep. - */ - -#define EVENT_CDBE_REPOPULATION_NEEDED 85 - /* Called when a cdbe database has been deleted while the system - * is currently operating. This event may NOT sleep. - */ - -#define EVENT_PROTOCOL_POST_BIND 86 - /* Parameter is a pointer to a structure of type EventProtocolBindStruct. - * This event is generated every time a board is bound to a protocol. - * This event may sleep. - */ - -#define EVENT_PROTOCOL_REGISTERED 87 - /* Generated when a Protocol is registered. The parameter is a - * pointer to the EventProtocolRegisteredStruct. This event may sleep. */ - -#define EVENT_PROTOCOL_UNREGISTERED 88 - /* Generated when a Protocol is unregistered. The parameter is a - * pointer to the EventProtocolRegisteredStruct. This event may sleep. */ - -#define EVENT_DEBUGGER_ACTIVE_CHANGED 89 - /* parameter is the debuggerActive flag value. This event is generated - * each time the value of debuggerActive is modified. This event may - * NOT sleep and may not invoke any procedure not available at debug - * time. - */ - -#define EVENT_CONNECTION_STATE_CHANGE 90 - /* parameter is the connection number. This event is generated each - * time the connection transitions from licenced to not licenced or - * from not licenced to licenced. It doesn't track logging in or - * logging out. It can block. - */ - -// -// These two events (EVENT_PROCESSOR_ON_LINE and EVENT_PROCESSOR_OFF_LINE -// are defined to be MT safe events. This means that the consumers of -// these two events are expected to be MT safe, and they don't have to -// declare themselves to be MT safe explicitly at registration time. -// - -#define EVENT_PROCESSOR_ON_LINE 91 - /* parameter is the processor number. This event is generated each - * time a processor is brought ON LINE. Since a spinlock is acquired, - * to prevent multiple processors from coming and going concurrently, - * this event may NOT sleep. - */ - -#define EVENT_PROCESSOR_OFF_LINE 92 - /* parameter is the processor number. This event is generated each - * time a processor is taken OFF LINE. Since a spinlock is acquired, - * to prevent multiple processors from coming and going concurrently, - * this event may NOT sleep. - */ - -#define EVENT_INTERRUPT_HANDLER_CHANGE 93 - /* parameter is the interrupt number. This event is generated each - * time an interrupt service routine is hooked or unhooked from the - * OS level interrupt service routine. Since a spinlock is acquired, - * to protect the interrupt vector pool this event may NOT sleep. - */ - -#define EVENT_BEFORE_LOAD_NLM 94 - /* called while an NLM is being loaded, after all module dependencies - * have been taken care of, but before this NLM load gets the load - * semaphore. The event report is allowed to sleep. The parameter is - * a pointer to an NLM Load File Header structure. - */ - -#define EVENT_NLM_ADDED 95 - /* called while an NLM is being added to an address space. The event - * report is allowed to sleep. The Parameter is a pointer to an address - * space structure. - */ - -#define EVENT_NLM_REMOVED 96 - /* called while an NLM is being removed from an address space. The event - * report is allowed to sleep. The Parameter is a pointer to an address - * space structure. - */ - -#define EVENT_ADDRESS_SPACE_CREATED 97 - /* called while an address space is being created. The event - * report is allowed to sleep. The Parameter is a pointer to an address - * space structure. - */ - -#define EVENT_ADDRESS_SPACE_DELETED 98 - /* called while an address space is being deleted. The event - * report is allowed to sleep. The Parameter is a pointer to an address - * space structure. This pointer may not be dereferenced. It's only use - * will be to match values in data structures tracking current address - * spaces. - */ - -#define EVENT_RESOURCE_TAG_ACQUIRED 99 - /* called when an NLM allocates a resource tag. The event - * report is allowed to sleep. The Parameter is a pointer to a - * Load Definition Structure. - */ - -#define EVENT_SWAPFILE_ADDED 100 - /* This event gets called when a new swapfile is created/added. - * The parameter is the same handle that is received if you call - * GetOsInformation. - */ - -#define EVENT_SWAPFILE_DELETED 101 - /* This event gets called when a swapfile is Deleted. - * The parameter is the same handle that is received if you call - * GetOsInformation. - */ - -#define EVENT_MODULE_LOAD_PRE_INIT 102 - /* This event gets called while an NLM is being loaded. The event is - * generated after the code, data, messages, etc. are read into memory - * and fixed up, but just before the NLM's initialization code is run. - * The parameter is a module handle. - */ - -#define EVENT_RESOURCE_TYPE_ADD 103 - /* called when an NLM calls RegisterTrackedResource to add a new - * resource type. This event is generated right after the resource - * type has been added. The parameter is the resource type signature. - * This event is allowed to sleep. - */ - -#define EVENT_RESOURCE_TYPE_DELETE 104 - /* called when an NLM calls UnRegisterTrackedResource to remove a - * resource type. This event is generated right after the resource - * type is deleted. The parameter is the resource type signature. - * This event is allowed to sleep. - */ - -#define EVENT_SET_PARM_CATEGORY_ADD 105 - /* Called when RegisterSetParameterCategory to add a new set parameter - * category. This event is generated right after the category has been - * added. The parameter is a pointer to a EventSetParameterCategory - * structure. This event is allowed to sleep. - */ - -#define EVENT_SET_PARM_CATEGORY_REMOVE 106 - /* Called when DeRegisterSetParameterCategory to remove a set parameter - * category. This event is generated right after the category is - * removed. The parameter is a pointer to a EventSetParameterCategory - * structure. This event is allowed to sleep. - */ - -#define EVENT_SET_PARM_ADD 107 - /* Called when RegisterSetParameter to add a new set parameter - * This event is generated right after the set parameter has been - * added. The parameter is a pointer to a EventSetParameter - * structure. This event is allowed to sleep. - */ - -#define EVENT_SET_PARM_REMOVE 108 - /* Called when DeRegisterSetParameter to remove a set parameter - * This event is generated right after the set parameter is removed. - * The parameter is a pointer to a EventSetParameter - * structure. This event is allowed to sleep. - */ - -#define EVENT_WAIT_FOR_KEY 109 - /* Called to signal that a screen is looking for input. - * The parameter is the screen ID with the low bit set on entry - * and the low bit clear on exit. This event is allowed to sleep. - */ - -#define EVENT_BEGIN_CREATE_SWAP_FILE 110 - /* Called just before a swap file is going to be created. This is to - * allow CPR or anyone else that would like to save a existing swap - * swapfile before a new one is created. The parameter is the volume - * number. The swapfile file name is always at the root and always - * named _SWAP_.MEM. - */ - -#define EVENT_NETWORK_REGISTERED_OR_DEREGISTERED_FOR_NCP_SERVICES 111 - /* Called to signal that a Network address has been registered for - * NCP services on it (Parameter == 0) or a NCP Services have been - * deregistered for a Network address (Parameter == 1). - * This event is allowed to sleep. - */ - -#define EVENT_MODULE_UNLOAD_FAIL 112 - /* Called if the Unload of a module fails for any reason. - * The ModuleHandle will be the parameter. - */ - -#define EVENT_ANY_VOL_DISMOUNT_END 113 - /* parameter is volume number. Warn Routine and Report Routine will be - * called after the volume is dismounted. - */ - -#define EVENT_SYS_VOL_DISMOUNT_END 114 - /* parameter is undefined . Warn Routine and Report Routine will be - * called after the SYS volume is dismounted. - */ - -#define EVENT_MODULE_UNLOAD_POST_EXIT_ROUTINE 115 - /* Parameter is the module handle. Report routine will be called after - * the NLM's exit routine has been called but before anything is cleaned - * up. This event is allowed to sleep. - */ - -#define EVENT_VOLUME_NDS_OBJECT_ID_CHANGED 116 - /* Parameter is a pointer to the structure EventVolNDSObjectID. - * This event is allowed to sleep. - */ - -#define EVENT_TTS_OUT_OF_RESOURCES 117 - /* Parameter is a pointer to the structure EventTTSOutOfResourcesStruct - * This event is allowed to sleep. - */ - -#define EVENT_LOCALE_FILE_CHANGED 118 - /* Parameter is a NOP because the only information that is needed is the - * fact that the config information changed. - */ - -#define EVENT_UNICODE_STANDARD_CONVERTER_CHANGED 119 - /* Parameter is undefined. An NLM has overridden the Standard Unicode - * Converter DLL. Any NLMs using Standard Converter calls (NWUS...) - * will automatically use the new converter. Any NLMs which have loaded - * an extended converter will need to unload and reload their converter - * to use the new codepage. This event is allowed to sleep. */ - -/* SPD #200605 Jim A. Nicolet 6-30-98 */ -#define EVENT_VOLUME_LOW_SPACE 120 - /* Parameter is a pointer to the structure EventVolumeLowSpaceStruct. - * This event is allowed to sleep - */ - - -#define EVENT_SCREEN_MODE_CHANGE 121 -/* Reseting the screen mode resets the character set. We need to have it - reloaded if it is something other than the default -*/ - -#define EVENT_SAVE_OR_RELOAD_WORKING_SET 122 -/* Parameter is pointer to the structure struct EventWorkingSet. This event is - generated when the server needs to save the current working set or to reload - the working set from the registry. This event is allowed to sleep. -*/ - - -// -// Events 123 and 124 were EVENT_CREATE_APPLICATION and EVENT_DESTROY_APPLICATION. -// These don't exist anymore. However, there could still some Novell Internal -// NLMs which are registering these two events. Till all such NLMs discontinue using -// these events, we will skip these two numbers. -// - - -//#define available event 123 -//#define available event 124 - -// -// These events are issued for MPK threads AS WELL AS legacy -// threads. -// These events are defined to be MT safe, which means that -// the consumers of these two events have to be MT safe, and -// don't have to specify so explicitly at registration time. -// -#define EVENT_CREATE_THREAD 125 - -#define EVENT_DESTROY_THREAD 126 - -#define EVENT_ADDRESS_SPACE_FAULT 127 - /* called when a protection fault has occurred that will cause and - * address space to be removed. The Parameter is a pointer to an address - * space structure. This event is called before the address space is removed. - */ - -#define EVENT_PORTAL_NEWS 128 - /* Parameter is a pointer to struct EventPortalNewsStruct. This event is allowed to sleep. */ - -#define EVENT_PRE_DOWN_SERVER 129 - /* parameter is undefined. Report Routine will be - * called before the server is shutdown and the EVENT_DOWN_SERVER - * event is generated. - */ - -#define EVENT_SEARCH_PATH 130 - /* called when a search path has been added, removed, or switch from dos to sys. The Parameter is a - * pointer to EventSearchStruc structure. This event is sleepable. - */ - -#define EVENT_PM_CHANGE_NOTIFICATION 131 - /* Place holder event for PM. The parameter is a pointer to the - * struct EventPMFeaturesInfoStruct - * This event is sleepable - */ - -#define EVENT_SLP 132 - /* Place holder event for SLP - * This event is sleepable - */ - -#define EVENT_COMMAND_LINE_ENTERED 133 - /* called when a console command line is entered. The parameter is a pointer to the - * struct EventCommandLineInfoStruct. - * This event is sleepable - */ - -#define EVENT_CONNECTION_HOOK 134 - /* called when a connection hook is modified. The parameter is a pointer to the - * struct EventConnectionHookInfoStruct. - * This event is sleepable - */ - -#define EVENT_IP_CONFIGURATION_CHANGE 135 - /* called when the IP configuration is modified. The parameter is a pointer to - * the struct EventIPConfigurationInfoStruct. - * This event is sleepable - */ - -#define EVENT_TIMEZONE_CHANGED 136 - /* This event is given when the time zone is changed by a call to - * ProcessSetTimeZone. This event is sleepable - */ - -#define EVENT_SCREEN_BEING_ACTIVATED 137 -#define EVENT_MODULE_BEING_LOADED 138 -#define EVENT_CONSOLE_RPC_NCP_ISSUED 139 /* defect #291644. RDoxey*/ - /* Called to signal that a Console RPC NCP (NCP 131 xx) request has - * been made. Parameter is a pointer to the struct EventNCP131InfoStruct. - * Warn Routine will be called at the beginning of the NCP request and - * Report Routine will be called after NCP reply, but before NCP is - * audited. This event is allowed to sleep. - */ - -#define EVENT_REAL_MODE_SUPPORT_CHANGE 140 - /* Called to signal a change in the level of support for real mode services. - * Parameter is the same as returned by GetRealModeSupportLevel. - * This event is allowed to sleep. - */ - -#define EVENT_BOOT_PARTITION_AVAILABLE 141 - /* parameter is undefined. This event is generated after Install creates a - * boot partition and copies files to it. Consumers of this event will want - * to transfer files from the "RAM drive" to the boot partition. - * This event is sleepable - */ - -#define EVENT_IP_ROUTE_CHANGE 142 - /* Event is signalled to indicate a change (addition or deletion) in the IP - * routing table. The parameter passed is a pointer to the following structure: - * struct EventIPRouteChange { - * int family; - * void *dest; - * int modification; - * LONG future[3]; }; - * This event is marked as a no-sleep event. This event may be generated on - * any processor. - */ - -#define EVENT_SCREEN_EVENT 143 - /* Event used pass screen update paramaters to a terminal monitor (e.g. SSH). - * This allows a monitor to know exactly what area has changed for optimization. - */ - -#define EVENT_ISCSI_INITIATOR_EVENT 144 - /* The parameter is a pointer to the EventInitiatorStructure. - * This event is allowed to sleep. - */ - -#define EVENT_ISCSI_TARGET_EVENT 145 - /* The parameter is a pointer to the EventTargetStructure. - * This event is allowed to sleep. - */ - -#define EVENT_IPSERVICES_CONFIG_CHANGE 146 - /* Called to signal a change to the configuration of IP services. No parameter is - * specified for this event. This event may be generated on any processor. - * This event is not allowed to sleep. - */ - -#define EVENT_UPDATE_SECURITY_EQUIVALENCE 147 - /* Called to signal that an UpdateSecurityEquivalence on a connection has - * taken place. The connection number will be passed as the only parameter. - * This event is allowed to sleep. - */ - -//#define available event 148 -//#define available event 149 -//#define available event 150 -//#define available event 151 -//#define available event 152 -//#define available event 153 -//#define available event 154 -//#define available event 155 -//#define available event 156 -//#define available event 157 -//#define available event 158 -//#define available event 159 -//#define available event 160 -//#define available event 161 -//#define available event 162 -//#define available event 163 -//#define available event 164 -//#define available event 165 -//#define available event 166 -//#define available event 167 -//#define available event 168 -//#define available event 169 -//#define available event 170 -//#define available event 171 -//#define available event 172 -//#define available event 173 -//#define available event 174 -//#define available event 175 -//#define available event 176 -//#define available event 177 -//#define available event 178 -//#define available event 179 -//#define available event 180 -//#define available event 181 -//#define available event 182 -//#define available event 183 -//#define available event 184 -//#define available event 185 -//#define available event 186 -//#define available event 187 -//#define available event 188 -//#define available event 189 -//#define available event 190 -//#define available event 191 - - -#define EVENT_TYPE_COUNT 192 - -/****************************************************************************/ -/****************************************************************************/ -/* --------------------------------------------------------------------------- - Event Structure Defintions ---------------------------------------------------------------------------- */ -/****************************************************************************/ -/****************************************************************************/ - -/* trustee changeFlags bits */ -#define EVENT_NEW_TRUSTEE 1 -#define EVENT_REMOVE_TRUSTEE 2 -#define EVENT_TRUSTEE_RIGHTS_MODIFIED 4 - -struct EventTrusteeChangeStruct -{ - LONG objectID; - - LONG entryID; - LONG volumeNumber; - LONG changeFlags; - LONG newRights; - struct DirectoryStructure *directoryEntry; - LONG evStation; -}; - -/* security changeFlags bits */ -#define EVENT_ADD_EQUIVALENCE 1 -#define EVENT_REMOVE_EQUIVALENCE 2 - -struct EventSecurityChangeStruct -{ - LONG objectID; - LONG equivalentID; - LONG changeFlags; -}; - -struct EventModifyDirEntryStruct -{ - LONG primaryDirectoryEntry; - LONG nameSpace; - LONG modifyBits; - struct ModifyStructure *modifyVector; - LONG volumeNumber; - struct DirectoryStructure *directoryEntry; - LONG oldModifyBits; /* Added for ds team - 1-30-98 Jim A. Nicolet */ - struct ModifyStructure *oldValuesVector; /* Added for ds team - 1-30-98 Jim A. Nicolet */ - LONG station; /* defect #291977 - RDoxey -Requested by Developer support for 3rd party use.*/ -}; - -struct EventSystemAlertStruct -{ - LONG targetStation; - LONG targetNotificationBits; - LONG errorLocus; - LONG errorClass; - LONG errorCode; - LONG errorSeverity; - BYTE *message; -}; - -struct EventINWSystemAlertStruct -{ - LONG alertId; - void *alertDataPtr; - LONG targetStation; - LONG targetNotificationBits; - LONG alertSeverity; - BYTE alertMessage[256]; -}; - -struct EventEndOfTaskStruct -{ - WORD station; - WORD unused; - LONG task; -}; - -struct EventProtocolBindStruct -{ - LONG boardNumber; - LONG protocolNumber; -}; - -extern struct ResourceTagStructure *OSEventResourceTag; - -struct EventDataMigrationInfo { - LONG FileSystemTypeID; - LONG Volume; - LONG DOSDirEntry; - LONG OwnerDirEntry; - LONG OwnerNameSpace; - BYTE OwnerFileName[256]; /* 255 + 1 len byte */ -}; - -struct EventQueueNote { - LONG QAction; /* 0=created, 1=deleted, 2 = activated, 3 = deactivated */ - LONG QID; - BYTE QName[50]; -}; - -struct EventNetwareAlertStruct -{ - LONG alertFlags; - LONG alertId; - LONG alertLocus; - LONG alertClass; - LONG alertSeverity; - LONG targetStationCount; - LONG targetStationList[32]; - LONG targetNotificationBits; - LONG alertParmCount; - void *alertDataPtr; - void *NetWorkManagementAttributePointer; - LONG alertUnused[2]; - LONG alertControlStringMessageNumber; - BYTE alertControlString[256]; - BYTE alertParameters[256+256]; - BYTE alertModuleName[36]; - LONG alertModuleMajorVersion; - LONG alertModuleMinorVersion; - LONG alertModuleRevision; -}; - -struct EventBinderyObject { - LONG EventObjectType; /* set to 'BIND' for bindery */ - LONG ObjectID; - LONG ObjectType; -}; - -#define EventBinderySignature 0x444e4942 /* 'DNIB' */ -#define EventDSSignature 0x43565344 /* 'CVSD' */ - -struct EventDSObject { - LONG EventObjectType; /* set to 'DSVC' for directory services */ - LONG EventType; /* add, delete, etc. */ - void *entry; /* DS defined entry structure */ -}; - -struct EventCloseFileInfo -{ - LONG fileHandle; - LONG station; - LONG task; - LONG fileHandleFlags; - LONG completionCode; -}; - -struct EventAlternateMountVolume -{ - LONG volumeFlags; /* 0x1 if mount all, 0x0 if mount volume name */ - LONG volumeNameLength; - BYTE volumeName[80]; - LONG volumeMountCCode; /* this is returned by alternate Mount */ - LONG alternateFileSystemID; - struct ScreenStruct *screenID; /* pass along the screenID */ - LONG displayErrorIfNoDisksFlag; /* pass along this flag */ - LONG requestedVolumeNumber; /* -1 if don't care else 1-255 for the suggested volume number (slot) */ - LONG unused[3]; -}; - -/* fileHandleFlags */ -#define ECNotReadableBit 0x00000001 -#define ECNotWriteableBit 0x00000002 -#define ECWrittenBit 0x00000004 -#define ECDetachedBit 0x00000008 -#define ECDirectFileSystemBit 0x00000020 -#define ECFileWriteThroughBit 0x00000040 - -struct EventConfigVersionCmdInfo -{ - struct ScreenStruct *screenID; - LONG linesUsed; /* can be change be the event handler */ - LONG linesPerScreen; -}; - -struct EventNLMLoadFailStruct -{ - LONG errorCode; - BYTE *name; /* Byte Length Preceeded */ -}; - - -/* EventUserRestrictionsStruct type indicators */ -#define EVENT_ADD_RESTRICTIONS 0 -#define EVENT_REMOVE_RESTRICTIONS 1 -#define EVENT_MODIFIED_RESTRICTIONS 2 - -struct EventUserRestrictionsStruct -{ - LONG type; - LONG Volume; - LONG Station; - LONG TrusteeID; - LONG newValue; /* valid only if type == 0, else = -1 */ -}; - -struct EventAddNameSpaceStruc -{ - LONG VolumeNumber; - LONG AddedNameSpaceNumber; -}; - -/* defect #291644. RDoxey*/ -struct EventNCP131InfoStruct -{ - LONG Station; - LONG SubFunction; - BYTE *Data; -}; - -struct EventSetParameter -{ - LONG setParameterType; - LONG setParameterCategoryNumber; - BYTE setParameterName[128]; /* ASCIIZ */ -}; - -struct EventSetParameterCategory -{ - LONG setParameterCategoryNumber; - BYTE setParameterCategoryName[128]; /* ASCIIZ */ -}; - -struct EventProtocolRegisteredStruct -{ - LONG protocolNumber; /* stack ID */ - BYTE protocolName[16]; /* ASCIIZ */ -}; - -struct EventVolNDSObjectID -{ - LONG VolumeNumber; - LONG oldNDSObjectID; - LONG newNDSObjectID; -}; - -#define EventByTTSThrottleControl 0x00000001 -#define EventByTTSThrottleDelayCheckFlag 0x00000002 -#define EventByBeginTransaction 0x00000004 -/* - Problem Code only when generated by EventByTTSThrottleControl - 5 trying to get a cache buffer - 6 trying to enlarge tables - 7 trying to get a disk block - x unrecoverable or unknown error code -*/ -struct EventTTSOutOfResourcesStruct -{ - LONG eventID; /* who is generating the event in tts */ - LONG problemCode; /* what type of resource problem */ -}; - -/* SPD #200605 Jim A. Nicolet 6-30-98 */ -struct EventVolumeLowSpaceStruct -{ - LONG VolumeNumber; - BYTE VolumeNameLen; - BYTE VolumeName[255]; -}; - -struct EventWorkingSet -{ - LONG SaveOrReloadFlag; /* 1 == Save or 0 == Reload */ - LONG ServerWorkingStatus; -}; - -#define SEARCH_PATH_LOCK_BIT 0x00000001 - -#define SEARCH_ADD_AT_END_ACTION 0x00000001 -#define SEARCH_INSERT_ACTION 0x00000002 -#define SEARCH_REMOVE_ACTION 0x00000003 -#define SEARCH_DOS_SWITCH_NW_ACTION 0x00000004 -#define SEARCH_REMOVE_DOS_PATHS_ACTION 0x00000005 -#define SEARCH_DOS_DEFAULT_CHANGED 0x00000006 - -struct EventSearchStruct -{ - int action; // action - int flags; // - int IsDosFlag; // 0 = NW Search Path, 1 = DOS Search Path, 0x81 = Default DOS Search Path - int insertionNumber; // only valid on SEARCH_INSERT_ACTION - int reserved; // 0 - char *pzSearchPath; // pointer to search path -}; - -struct EventCommandLineInfoStruct -{ - struct ScreenStruct *screenID; - char *pzCommandLine; - char *pzUpperCaseCommandLine; -}; - -struct EventPMFeaturesInfoStruct -{ - LONG returnActionCCode; - LONG returnFeaturesValue; -}; - -struct EventConnectionHookInfoStruct -{ - UINT32 action; - UINT32 hookIDNumber; - UINT32 station; - UINT32 spare; -}; - -#define EVENT_IP_NEW_ADDRESS 1 -#define EVENT_IP_CHANGE_ADDRESS 2 -#define EVENT_IP_DELETE_ADDRESS 3 - -#define EVENT_IP_PRIMARY_ADDRESS 1 -#define EVENT_IP_SECONDARY_ADDRESS 2 -#define EVENT_IP_GATEWAY_ADDRESS 3 - -struct EventIPConfigurationInfoStruct -{ - char IPAddress[16]; - char OldIPAddress[16]; - UINT32 boardNumber; - UINT32 action; /* EVENT_IP_NEW_ADDRESS, - EVENT_IP_CHANGE_ADDRESS, or - EVENT_IP_DELETE_ADDRESS */ - UINT32 addressType; /* EVENT_IP_PRIMARY_ADDRESS, - EVENT_IP_SECONDARY_ADDRESS, or - EVENT_IP_GATEWAY_ADDRESS */ -}; - -#endif /* __EVENT_H__ */ - -/****************************************************************************/ -/****************************************************************************/ diff --git a/include/nwnss/support/lnxmbINC/fshooks.h b/include/nwnss/support/lnxmbINC/fshooks.h deleted file mode 100644 index 1dbd8d9..0000000 --- a/include/nwnss/support/lnxmbINC/fshooks.h +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************** - * - * (C) Copyright 1987-1994 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Revision: 465 $ - * - ****************************************************************************/ - -/* - FILE: FSHOOKS.H - -*/ - -/* - Hook Number - 0 Erase File - 1 Open File - 2 Create File - 3 Create and Open File - 4 Rename Entry - 5 Close File - 6 Create Directory - 7 Delete Directory - 8 Modify Directory Entry - 9 Salvage File - 10 Purge File - 11 RenameNameSpaceEntry* - 12 F3SalvageFile - 13 F3PurgeFile - 14 F3OpenCreateFileOrDir - 15 F3RenameFileOrDir - 16 F3EraseFileOrDir - 17 F3ModifyDOSInfo - 18 F3ModifyNSSpecificInfo - 19 F3InitFileSearch - 20 F3ContinueFileSearch - 21 F3SearchSet - 22 DirectorySearch -*/ -/* The following structure has a triplets in vswitch.386 & netmanc.c */ - -typedef struct FSHOOK { - LONG *fsLink; - struct ResourceTagStructure *fsRTag; - LONG *fsEntrance; /* routine to be called on entrance to function */ - LONG *fsExit; /* routine to be called on exit from function */ - LONG useCount; /* defect #317715. RDoxey. Don't allow deregistration while accessing the list of registered nlms*/ -} FSHOOK; - -#define MAX_NUMBER_FSHOOKS 23 - -typedef struct FSHookParms_s { - LONG **HookLinkNamePtr; - BYTE *ExCntNamePtr; - BYTE *EntCntNamePtr; -} FSHookParms_s; - -extern struct FSHookParms_s FSHookParmsArray[]; - -#define FSHOOK_VERSION_NUMBER 1 -/****************************************************************************/ -/****************************************************************************/ - diff --git a/include/nwnss/support/lnxmbINC/fsproto.h b/include/nwnss/support/lnxmbINC/fsproto.h deleted file mode 100644 index 11cbbc4..0000000 --- a/include/nwnss/support/lnxmbINC/fsproto.h +++ /dev/null @@ -1,411 +0,0 @@ -/**************************************************************************** - | - | (C) Copyright 2004 Novell, Inc. - | All Rights Reserved. - | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. - | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. - | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. - | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com - | - |***************************************************************************/ - -LONG GenerateAuditRecord( - LONG volumeNumber, - LONG eventTypeID, - LONG connectionID, /* ID of event initiator */ - LONG successFailureStatusCode, - ...); - -void ConvertNewTrusteeRightsToOld( - BYTE *accessRights, - BYTE macStationFlag, - LONG station, - LONG volume, - LONG directoryNumber, - LONG nameSpace); - -void ConvertOldTrusteeRightsToNew( - BYTE *accessRights, - BYTE macStationFlag); - -BYTE *FindLastComponent( - BYTE *componentString, - LONG componentCount); - -void AlertNCPSearchMapLost( - LONG Station); - -void BeginTrans( - LONG station, - LONG task, - LONG wtime, - void (*rplyf)()); - -LONG EndTrans( - LONG station, - LONG task); - -LONG LogPRec( - LONG station, - LONG hndle, - LONG start, - LONG length, - LONG flags, - LONG wtime, - void (*rplyf)(), - ...); - -void LogRec( - LONG station, - LONG task, - BYTE *string, - LONG flags, - LONG wtime, - void (*rplyf)()); - -LONG ClearFLocks( - LONG station, - LONG task, - LONG lastset); - -LONG INWReleaseFile( - LONG station, - LONG task, - LONG vol, - LONG dir); - -LONG INWClearFile( - LONG station, - LONG task, - LONG vol, - LONG dir); - -void LFileSet( - LONG station, - LONG task, - LONG wtime, - void (*rplyf)()); - -LONG RelFileSet( - LONG station, - LONG task, - LONG lastset); - -void INWLogFile( - LONG station, - LONG task, - LONG vol, - LONG dir, - BYTE *filename, - LONG flags, - LONG wtime, - void (*rplyf)()); - -LONG OpenEAHandle( - LONG Station, - LONG Task, - LONG OpenFlags, - LONG Flags, - LONG Volume, - LONG Handle, - LONG *EAHandle); - -LONG CloseEAHandle( - LONG Station, - LONG Task, - LONG eaHandle); - -LONG WriteEAData( - LONG Station, - LONG Task, - LONG eaHandle, - LONG TotalDataLength, - LONG StartPosition, - LONG AccessFlag, - LONG KeySize, - BYTE *keyBuf, - LONG DataSize, - BYTE *inBuf, - LONG *BytesWritten); - -LONG ReadEAData( - LONG Station, - LONG Task, - LONG eaHandle, - LONG StartPosition, - LONG InspectSize, - LONG KeySize, - BYTE *Key, - BYTE *OutBuf, - LONG *TotalEALen, - WORD *CurrentLen, - LONG *AccessFlag, - LONG MaximumDataSize); - -LONG EnumEA( - LONG Station, - LONG Task, - LONG eaHandle, - LONG InfoLevel, - LONG StartPosition, - LONG InspectSize, - LONG KeySize, - BYTE *Key, - BYTE *EnumBuf, - LONG *EnumBufSize, - WORD *NextPos, - LONG *TotalDataSizeOfEAs, - LONG *TotalEAs, - WORD *CurrentEAsInReply, - LONG *TotalKeySizeOfEAs, - LONG MaximumDataSize); - -LONG DupEA( - LONG Station, - LONG Task, - LONG srcTypeFlag, - LONG srcVolume, - LONG srcHandle, - LONG dstTypeFlag, - LONG dstVolume, - LONG dstHandle, - LONG *DupCount, - LONG *DupData, - LONG *DupKey); - -LONG GetCurrentDiskUsedAmount( - LONG volumeNumber, - LONG trusteeID); - -LONG VCStnLockStatus( - LONG station, - LONG BufferSize, - BYTE *buffer); - -LONG VCStnFiles( - LONG station, - LONG buffersize, - BYTE *buffer, - LONG next); - -LONG VCFileTasks( - BYTE vol, - LONG dir, - BYTE forktype, - LONG buffersize, - BYTE *buffer, - LONG next); - -LONG VCStnPhyLocks( - LONG station, - BYTE vol, - LONG dir, - BYTE forktype, - LONG buffersize, - BYTE *buffer, - LONG next); - -LONG VCFilePhyLocks( - BYTE vol, - LONG dir, - BYTE forktype, - LONG buffersize, - BYTE *buffer, - LONG next); - -LONG VCStnLRecs( - LONG station, - LONG buffersize, - BYTE *buffer, - LONG next); - -LONG VCLRecTasks( - BYTE length, - BYTE *name, - LONG buffersize, - BYTE *buffer, - LONG next); - -LONG VCStnSems( - LONG station, - LONG buffersize, - BYTE *buffer, - LONG next); - -LONG VCSemaphoreTasks( - LONG length, - BYTE *name, - LONG buffersize, - BYTE *buffer, - LONG next); - -LONG SCreateSemaphore( - LONG station, - LONG task, - BYTE *string, - LONG initial, - BYTE *repbuf); - -LONG SExamineSemaphore( - LONG station, - LONG task, - LONG semval, - BYTE *retbuf); - -void SPSemaphore( - LONG station, - LONG task, - LONG semval, - LONG wtime, - void (*rplyf)()); - -LONG SVSemaphore( - LONG station, - LONG task, - LONG semval); - -LONG SCloseSem( - LONG station, - LONG task, - LONG semval); - -void LockPRecSet( - LONG station, - LONG task, - LONG flags, - LONG wtime, - void (*rplyf)()); - -void LRecSet( - LONG station, - LONG task, - LONG flags, - LONG wtime, - void (*rplyf)()); - -void MultiLFileSet( - LONG station, - LONG task, - LONG wtime, - void (*rplyf)()); - -LONG TTSCheck(void); - -LONG TTrackOn( - LONG station, - LONG task); - -LONG TTrackOff( - LONG station, - LONG task, - BYTE *retbuf); - -LONG TTrackAbort( - LONG station, - LONG task); - -LONG TTSCheckTransaction( - LONG referenceNumber); - -LONG SetTTaskFlags( - LONG station, - LONG task, - LONG pthresh, - LONG lthresh); - -LONG GTTaskFlags( - LONG station, - LONG task, - BYTE *threshrets); - -LONG STTaskState( - LONG station, - LONG task, - LONG flags); - -void GTTaskState( - LONG station, - LONG task, - BYTE *threshrets); - -LONG SetTransFlags( - LONG station, - LONG pthresh, - LONG lthresh); - -void GTransFlags( - LONG station, - BYTE *threshrets); - -LONG RelPRecLocks( - LONG station, - LONG task, - LONG lastset, - LONG clrflag); - -LONG ReleasePRec( - LONG station, - LONG hndle, - LONG start, - LONG length, - LONG clrflag); - -void ResetStation( - LONG station, - LONG task); - -void ClearTemporaryDirectoryHandles( - LONG Station, - LONG Task); - -LONG ClearRLocks( - LONG station, - LONG task, - LONG lastset); - -LONG RelRecSet( - LONG station, - LONG task, - LONG lastset); - -LONG ReleaseRecord( - LONG station, - LONG task, - BYTE *string); - -LONG UnlockRec( - LONG station, - LONG task, - BYTE *string); - -LONG GetFileStatusInformation( - LONG Station, - LONG Task, - WORD Index, - LONG SourceBase, - LONG SearchAttributes, - BYTE *ModifierString, - BYTE *ReplyArea); - -LONG SetFileStatusInformation( - LONG Station, - LONG Task, - LONG Base, - BYTE *ModifierString, - BYTE SearchAttributes, - WORD fileAttributes, - LONG CreationDate, - LONG LastAccessedDate, - LONG LastUpdatedDateAndTime, - LONG OwnerID); diff --git a/include/nwnss/support/lnxmbINC/ins.h b/include/nwnss/support/lnxmbINC/ins.h deleted file mode 100644 index 29c3cff..0000000 --- a/include/nwnss/support/lnxmbINC/ins.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef __INS_H__ -#define __INS_H__ -/***************************************************************************** - * - * (C) Copyright 1989-1994 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Revision: 465 $ - * - ****************************************************************************/ - -#define _INS_INCLUDED_ TRUE - - -#define NMLongIncr 1 -#define NMLongIncrHi 2 -#define NMLongPtrIncrHi 3 -#define NMLongDecr 4 -#define NMLongDecrHiLo 5 -#define NMLongPtrDecrHiLo 6 -#define NMWordIncr 7 -#define NMWordIncrHi 8 -#define NMWordDecr 9 -#define NMWordDecrHiLo 10 -#define NMByteIncr 11 -#define NMByteIncrHi 12 -#define NMByteDecr 13 -#define NMByteDecrHiLo 14 -#define NMQuadIncr 15 -#define NMQuadDecr 16 -#define NMSixByteIncr 17 -#define NMSixByteDecr 18 -#define NMAlertIncr 19 - -/****************************************************************************/ -/****************************************************************************/ - -#endif /* __INS_H__ */ diff --git a/include/nwnss/support/lnxmbINC/lanconf.h b/include/nwnss/support/lnxmbINC/lanconf.h deleted file mode 100644 index 8b13789..0000000 --- a/include/nwnss/support/lnxmbINC/lanconf.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/nwnss/support/lnxmbINC/lfsproto.h b/include/nwnss/support/lnxmbINC/lfsproto.h deleted file mode 100644 index c2d60d9..0000000 --- a/include/nwnss/support/lnxmbINC/lfsproto.h +++ /dev/null @@ -1,308 +0,0 @@ -/**************************************************************************** - | - | (C) Copyright 2004 Novell, Inc. - | All Rights Reserved. - | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. - | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. - | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. - | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com - | - |***************************************************************************/ - -extern LONG NumberOfVolumes; - -LONG CloseFile( - LONG station, - LONG task, - LONG handle); - -LONG CommitFile( - LONG Station, - LONG OpenFileHandle); - -LONG ConvertPathString( - LONG stationNumber, - BYTE base, - BYTE *modifierString, - LONG *volumeNumber, - LONG *pathBase, - BYTE *pathString, - LONG *pathCount); - -LONG MapDirectoryNumberToPath( - LONG Volume, - LONG DirectoryNumber, - LONG NameSpace, - BYTE *String, - LONG StringLength, - LONG *ActualLength); - -LONG MapPathToDirectoryNumberOrPhantom( - LONG Station, - LONG Volume, - LONG PathBase, - BYTE *PathString, - LONG PathCount, - LONG NameSpace, - LONG *DirectoryNumber, - LONG CanCreateFlag); - -LONG MapPathToDirectoryNumber( - LONG Station, - LONG Volume, - LONG PathBase, - BYTE *PathString, - LONG PathCount, - LONG NameSpace, - LONG *DirectoryNumber, - LONG *FileFlag); - -LONG GetAccessRights( - LONG Station, - LONG Volume, - LONG DirectoryNumber, - LONG NameSpace, - WORD *AccessRights); - -LONG RenameEntry( - LONG Station, - LONG Task, - LONG Volume, - LONG PathBase, - BYTE *PathString, - LONG PathCount, - LONG NameSpace, - LONG MatchBits, - BYTE SubdirectoryFlag, - LONG NewBase, - BYTE *NewString, - LONG NewCount, - LONG CompatabilityFlag, - BYTE AllowRenamesToMyselfFlag); - -LONG CreateFile( - LONG Station, - LONG Task, - LONG Volume, - LONG PathBase, - BYTE *PathString, - LONG PathCount, - LONG NameSpace, - LONG CreatedAttributes, - LONG FlagBits, - BYTE DataStreamNumber, - LONG *Handle, - LONG *DirectoryNumber, - void **DirectoryEntry); - -LONG DeleteDirectory( - LONG Station, - LONG Volume, - LONG PathBase, - BYTE *PathString, - LONG PathCount, - LONG NameSpace); - -LONG CreateDirectory( - LONG Station, - LONG Volume, - LONG PathBase, - BYTE *PathString, - LONG PathCount, - LONG NameSpace, - LONG DirectoryAccessMask, - LONG *ReturnedDirectoryNumber, - void **ReturnedSubDir); - -struct ModifyStructure; -struct DirectoryStructure; -LONG ModifyDirectoryEntry( - LONG Station, - LONG Task, - LONG Volume, - LONG PathBase, - BYTE *PathString, - LONG PathCount, - LONG NameSpace, - LONG MatchBits, - LONG TargetNameSpace, - struct ModifyStructure *ModifyVector, - LONG ModifyBits, - LONG AllowWildCardsFlag); - -LONG GetEntryFromPathStringBase( - LONG Station, - LONG Volume, - LONG PathBase, - BYTE *PathString, - LONG PathCount, - LONG SourceNameSpace, - LONG DesiredNameSpace, - struct DirectoryStructure **Dir, - LONG *DirectoryNumber); - -LONG DirectorySearch( - LONG Station, - LONG Volume, - LONG DirectoryNumber, - LONG NameSpace, - LONG StartEntryNumber, - BYTE *Pattern, - LONG MatchBits, - struct DirectoryStructure **DirectoryEntry, - LONG *ReturnedDirectoryNumber); - -LONG ScanTrusteeRights( - LONG Station, - LONG Volume, - LONG DirectoryNumber, - LONG NameSpace, - LONG StartingOffset, - LONG *TrusteeVector, - WORD *MaskVector, - LONG VectorSize, - LONG *ActualVectorSize); - -LONG GetAccessRights( /* moved to vswitch. 386 */ - LONG Station, - LONG Volume, - LONG DirectoryNumber, - LONG NameSpace, - WORD *AccessRights); - -LONG AddTrusteeRights( /* moved to vswitch.386 */ - LONG Station, - LONG Volume, - LONG DirectoryNumber, - LONG NameSpace, - LONG Trustee, - LONG NewRights); - -LONG DeleteTrusteeRights( /* moved to vswitch.386 */ - LONG Station, - LONG Volume, - LONG DirectoryNumber, - LONG NameSpace, - LONG DeletedTrustee, - BYTE CanDeleteOnPurgedFileFlag); - -LONG GetAccessRightsFromIDs( - LONG Volume, - LONG DirectoryNumber, /* assumes it is in the DOS name space. */ - LONG UserID, - LONG GroupID, - WORD *UserAccessRights, - WORD *GroupAccessRights); - -LONG FindNextTrusteeReference( - LONG Station, - LONG Volume, - LONG TrusteeID, - LONG StartEntryNumber, - LONG *EntryNumber, - WORD *TrusteeMask, - LONG *OwnerEntryNumber); - -LONG OpenFile( /* moved to vswitch.386 */ - LONG Station, - LONG Task, - LONG Volume, - LONG PathBase, - BYTE *PathString, - LONG PathCount, - LONG NameSpace, - LONG MatchBits, - LONG RequestedRights, - BYTE DataStreamNumber, - LONG *Handle, - LONG *DirectoryNumber, - void **DirectoryEntry); - -LONG EraseFile( /* moved to vswitch.386 */ - LONG Station, - LONG Task, - LONG Volume, - LONG PathBase, - BYTE *PathString, - LONG PathCount, - LONG NameSpace, - LONG MatchBits); - -LONG CountOwnedFilesAndDirectories( - LONG Station, - LONG Volume, - LONG ID, - LONG *FileCount, - LONG *DirectoryCount); - - -LONG ScanDeletedFiles( - LONG Station, - LONG Volume, - LONG DirectoryNumber, - LONG NameSpace, - LONG StartEntryNumber, - LONG *ReturnedDirectoryNumber, - struct DirectoryStructure **EntryPointer); - -LONG PurgeDeletedFile( - LONG Station, - LONG Volume, - LONG DirectoryNumber, - LONG ToBePurgedDirectoryNumber, - LONG NameSpace); - -LONG VM_Return_Volume_Info( - LONG volumeid, - struct volinfodef *volumeinfo); - -LONG VM_Find_Next_Volume( - LONG *nextvolumeid, - LONG filesystemid); - -LONG VM_Unregister_Volume( - LONG volumemanagerhandle, - LONG filesystemhandle); - -LONG VM_Change_Volume_Status( - LONG volumemanagerhandle, - LONG filesystemhandle, - LONG newinstance, - BYTE *newname, - LONG newstatus, - LONG (**jumptable)(void)); - -void VM_Volume_Request_Complete( - struct volumerequestdef *request, - LONG completioncode); - -LONG GetVolumeNameTableEntry( - LONG volumeNumber, - BYTE *nameBuffer); - -LONG VM_Register_Volume( - LONG *volumemanagerhandle, - LONG filesystemhandle, - LONG volumeinstance, - BYTE *volumename, - LONG volumestatus, - LONG filesystemid, - BYTE *filesystemname, - LONG (*pollroutine)( - LONG handle, - struct volumerequestdef *request), - LONG (*abortroutine)( - LONG handle, - struct volumerequestdef *request), - LONG (**jumptable)(void)); diff --git a/include/nwnss/support/lnxmbINC/loader.h b/include/nwnss/support/lnxmbINC/loader.h deleted file mode 100644 index bfd55ff..0000000 --- a/include/nwnss/support/lnxmbINC/loader.h +++ /dev/null @@ -1,885 +0,0 @@ -#ifndef __LOADER_H__ -#define __LOADER_H__ -#if 0 // GLP -/***************************************************************************** - * - * (C) Copyright 1988-1999 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Revision: 465 $ - * - ****************************************************************************/ - -#include - -/*************************** macro definitions *****************************/ - -#define LD_MODULE_DESCRIPTION_MAX_LENGTH 127 -#define LD_MODULE_LONG_NAME_MAX_LENGTH 255 - -#define MPKLoaderChanges TRUE - -/* defines for MPKAPIListType field of LoadTimeInfoStruct */ -#define MPK_API_LIST_EMPTY 0 -#define MPK_API_LIST_IS_FUNNELED_APIS 1 -#define MPK_API_LIST_IS_NON_FUNNELED_APIS 2 - -#define NORMALNLM 0x04 -#define LONGNAMENORMAL 0x05 -#define PACKEDNLM 0x84 -#define LONGNAMEPACKED 0x85 - -/* if these #defines are changed, they must be changed in loader.inc as well */ -/* changing the values (names are not important) of these #defines may require - changes in deftoc as well so that the outputs of deftoc match */ - -// Be careful how you use these "opposite types" -#define XPDFlagData 0x00 -#define XPDFlagNoBranch 0x00 -#define XPDFlagNotShared 0x00 - -#define XPDFlagFunction 0x01 -#define XPDFlagBranch 0x02 -#define XPDFlagShared 0x04 -#define XPDCNBFunnelStubNeeded 0x08 -#define XPDCNBFunnelStubInserted 0x10 - -/* Maximum length of a logical board name */ -#define MaximumLogicalNameLength 17 - -// -// bagStamp field: -// - -#define BAGFILE_STAMP 0x46474142 // 'FGAB' - -// -// bagMajorVer and bagMinorVer -// - -#define BAGFILE_MAJOR_VERSION 2 -#define BAGFILE_MINOR_VERSION 0 - -// -// bagType field: (Actually the record type). -// - -#define BAG_TYPE_SMP 0x00000001 -#define RECORD_TYPE_MPK_NLM_INFO 0x00000002 - - -#define MPK_NLM_MT_SAFE 0x00000001 -#define MPK_NLM_PREEMPTIBLE 0x00000002 -#define MPK_FUNNELED_API_LIST 0x00000004 -#define MPK_NLM_MT_UNSAFE 0x00000008 - - -// -// stamp field: -// - -#define SMP_RPC_STAMP 0x44504d53 // 'SMPD' - -// -// version field: -// - -#define SMP_RPC_VERSION 1 - -// -// flags field: -// - -#define SMP_FLAG_ALL_APIS 0x00000001 - -/* Define the public types */ -#define PUBLIC_TYPE_INTERNAL 0 -#define PUBLIC_TYPE_EXTERNAL 1 -#define PUBLIC_TYPE_NEW_EXTERNAL 2 -#define PUBLIC_TYPE_OLD_INTERNAL 3 -#define PUBLIC_TYPE_OLD_EXTERNAL 4 -#define PUBLIC_TYPE_GLOBAL_USER 5 -#define PUBLIC_TYPE_GLOBAL_USER_OLD 6 - -/* defines for the LoadDefinitonStructure's LDFlags member. */ - -#define LDModuleIsReEntrantBit 0x00000001 -#define LDModuleCanBeMultiplyLoadedBit 0x00000002 -#define LDSynchronizeStart 0x00000004 -#define LDPseudoPreemptionBit 0x00000008 -#define LDLoadInKernel 0x00000010 -#define LDDontShareCode 0x00000020 -#define LDAutoUnload 0x00000040 -#define LDHiddenModule 0x00000080 -#define LDDigitallySignedFile 0x00000100 -#define LDLoadProtected 0x00000200 -#define LDSharedLibraryModule 0x00000400 -#define LDRestartable 0x00000800 -#define LDUnsafeToUnloadNow 0x00001000 -#define LDModuleIsUniprocessor 0x00002000 -#define LDPreemptable 0x00004000 -#define LDHasSystemCalls 0x00008000 /* This module has memory protection marshalling code*/ -#define LDVirtualMemory 0x00010000 -#define LDAllExportsMTSafe 0x00020000 - -// Available bit positions -#define Available_1 0x00040000 -#define Available_2 0x00080000 -#define Available_3 0x00100000 -#define Available_4 0x00200000 -#define Available_5 0x00400000 -/* Clib is using this one. It is just reserved for them.*/ -#define LDUTF8Strings 0x00800000 -#define LDTSR 0x01000000 -#define LDUNICODE_STRINGS 0x02000000 - -#define LDHotSwapDriver 0x04000000 -#define LDStartupDeviceNLMBit 0x08000000 -#define LDBoundNLMBit 0x10000000 -#define LDDontUnloadBit 0x20000000 -#define LDModuleIsBeingDebugged 0x40000000 -#define LDMemoryOn4KBoundriesBit 0x80000000 - -/* bitmask for the flags settable from the load file header */ -#define LD_LOAD_FILE_FLAGS \ -(LDModuleIsReEntrantBit | LDModuleCanBeMultiplyLoadedBit | LDSynchronizeStart | \ -LDPseudoPreemptionBit | LDLoadInKernel | LDDontShareCode | LDAutoUnload | LDHiddenModule | \ -LDDigitallySignedFile | LDLoadProtected | LDSharedLibraryModule | LDRestartable | \ -LDHotSwapDriver | LDBoundNLMBit | LDDontUnloadBit | LDModuleIsBeingDebugged | \ -LDMemoryOn4KBoundriesBit | LDTSR | LDUNICODE_STRINGS | LDUTF8Strings) - -// unknown are the following: LDHasSystemCalls, - -// LDMemoryOn4KBoundriesBit - what meaning does this have now? - -// It seems like we should do the LDStartupDeviceNLMBit and LDBound cases -// differently - -/* LoadModule load options */ -#define LO_NORMAL 0x00000000 -#define LO_STARTUP 0x00000001 -#define LO_PROTECT 0x00000002 -#define LO_DEBUG 0x00000004 -#define LO_AUTO_LOAD 0x00000008 -#define LO_DONT_PROMPT 0x00000010 -#define LO_LOAD_LOW 0x00000020 -#define LO_RETURN_HANDLE 0x00000040 -#define LO_LOAD_SILENT 0x00000080 -#define LO_DELAY_RPC_DEF 0x00000100 -#define LO_RESTART 0x00000200 - -#define LO_DONT_DISPLAY_ERROR 0x00002000 - -#define LO_MEMORY_DEBUG 0x00010000 -#define LO_RELAXED_MEMORY_DEBUG 0x00020000 - -#define LO_CHECK_STARTUP 0x10000000 -#define LO_SKIP_CFG_INFO 0x20000000 -#define LO_LOAD_BOUND_IN_ONLY 0x40000000 -#define LO_BOUND 0x80000000 - -/* Loader returned error codes */ -#define LOAD_COULD_NOT_FIND_FILE 1 -#define LOAD_ERROR_READING_FILE 2 -#define LOAD_NOT_NLM_FILE_FORMAT 3 -#define LOAD_WRONG_NLM_FILE_VERSION 4 -#define LOAD_REENTRANT_INITIALIZE_FAILURE 5 -#define LOAD_CAN_NOT_LOAD_MULTIPLE_COPIES 6 -#define LOAD_ALREADY_IN_PROGRESS 7 -#define LOAD_NOT_ENOUGH_MEMORY 8 -#define LOAD_INITIALIZE_FAILURE 9 -#define LOAD_INCONSISTENT_FILE_FORMAT 10 -#define LOAD_CAN_NOT_LOAD_AT_STARTUP 11 -#define LOAD_AUTO_LOAD_MODULES_NOT_LOADED 12 -#define LOAD_UNRESOLVED_EXTERNAL 13 -#define LOAD_PUBLIC_ALREADY_DEFINED 14 -#define LOAD_XDC_DATA_ERROR 15 -#define LOAD_NOT_KERNEL 16 -#define LOAD_NIOS_ONLY_NLM 17 -#define LOAD_ADDRESS_SPACE_CREATION 18 -#define LOAD_INITIALIZE_FAULT 19 - -/* public address types */ -#define LOCAL_PUBLIC_ADDRESS 0 -#define GLOBAL_PUBLIC_ADDRESS 1 -#define REAL_PUBLIC_ADDRESS 2 -#define ENV_AWARE_ADDRESS 50 - -/* InterceptPublicAddress errors.*/ -#define INVALID_RECORD_TYPE -1 - -/* mapped memory types */ -/* define the protection areas */ -#define MEM_LOCAL_DATA 0x00000001 -#define MEM_LOCAL_CODE 0x00000002 -#define MEM_USER_CODE 0x00000004 -#define MEM_USER_DATA 0x00000008 -#define MEM_OS_DATA 0x00000010 -#define MEM_OS_CODE 0x00000020 -#define MEM_PCB 0x00000040 -#define MEM_SHARED_CODE 0x00000080 -#define MEM_LOGICAL_NEQ_PHYSICAL 0 -#define MEM_LOGICAL_EQ_PHYSICAL MEM_LOCAL_DATA - -/* memory map sizes */ -#define USER_CODE_AREA_SIZE (128 * 1024 * 1024) -#define SHARED_CODE_AREA_SIZE (128 * 1024 * 1024) - -/* define the registerable xdc procedure types */ -#define XDC_NLM_START 0 -#define XDC_NLM_CHECK 1 -#define XDC_NLM_EXIT 2 -#define XDC_NLM_OTHER 3 - -/* command-line registry flags */ -#define CL_STARTUP 0x00000001 /* STARTUP.NCF */ -#define CL_AUTOEXEC 0x00000002 /* AUTOEXEC.NCF */ -#define CL_IOSTART 0x00000004 /* IOAUTO.NCF */ -#define CL_IOAUTO 0x00000008 /* IOAUTO.NCF */ -#define CL_MSSTART 0x00000010 /* MSSTART.NCF */ -#define CL_MSAUTO 0x00000020 /* MSAUTO.NCF */ - -#define PROTECTED_TEXT "PROTECTED " -#define RELOAD_TEXT "RELOAD" -#define RESTART_TEXT "RESTART " -#define NO_RESTART_TEXT "NO RESTART" -#define ADDRESS_SPACE_TEXT "ADDRESS SPACE" -#define DEFAULT_AS_NAME_TEXT "ADDRESS_SPACE" -#define FORCED_UNLOAD_TEXT "KILL" - - -/*** GREEN RIVER CMC LOADER CHANGE ***/ -#define MaximumNumberOfUpdateRoutines 20 /* from ins.h */ -#define NMLongIncrHi 2 - -#define LT_DOS 1 -#define LT_OS2 2 -#define LT_MSWIN31 3 - -/*********************** type and tag declarations *************************/ - -struct MPKAPIInfoList -{ - struct MPKAPIInfoList *next; - BYTE matchedToExport; /* flag to indicate whether this API has been matched to an export */ - BYTE name[1]; -}; - -struct LoadTimeInfoStruct -{ - LONG MPKAPIListType; - struct MPKAPIInfoList *MPKAPIList; - LONG MainCodeCNBFunnelCount; - LONG SharedCodeCNBFunnelCount; -}; - -// -// The structures and #defines are also used by -// SMPRPC and MPKXDC tools. -// -// Since both 16-bit as well as 32-bit executables -// of the tools are generated using this header -// files, the fields in the structure -// have explicit field sizes specified in them. -// - -// -// The "bag" header. Identifies a specific bag type. -// v4.11 SMP understands only one bag type and stops -// processing XDC data if any other bag type is -// found. Some NLMs (especially CLIB's LIB0.NLM) -// use XDC information containing records understood -// only by MPK along with records that are understood -// by both SMP and MPK. This precludes the -// possibility of using a more efficient scheme. -// - -struct bagHeader /* 32 bytes */ -{ - UINT32 bagStamp; // The bag type. - BYTE bagMajorVer; - BYTE bagMinorVer; - BYTE bagZeros[2]; - UINT32 bagRecCount; - BYTE bagZeros2[20]; -}; - -// -// The record header. -// - -struct bagRecHeader /* 80 bytes */ -{ - UINT32 bagType; // Actually the record type. - UINT32 bagFlags; // Does anybody use this field??? - UINT32 bagSize; // # of bytes of data following - // this structure (does not - // include the size of this - // structure). Unknown record - // types can be skipped easily. - BYTE bagName[16]; /* Length Preceeded, Null Terminated */ - BYTE bagDescription[32]; /* Length Preceeded, Null Terminated */ - BYTE bagZeros[20]; -}; - -// -// Bag record header for MPK. -// - -typedef struct _MPKBagRecordHeader -{ - UINT32 RecordType; // Same values as that of - // bagType field of - // struct bagRecHeader. - UINT32 RecordFlagsReserved; // Don't know if it can be used. - // Leave it alone as a precaution. - UINT32 RecordSize; // # of bytes of data following - // this structure + - // sizeof (MPKBagRecordHeader) - - // sizeof (struct bagRecHeader) - BYTE RecordName[16]; - BYTE RecordDescription[32]; - BYTE RecordReserved[20]; - - // - // All the above fields are the same - // as in struct bagRecHeader. - // Following are the new fields. MPK - // records will not have any smpRpcHeader. - // - - UINT32 RecordInfoBitMap; - UINT32 ApiCount; - UINT32 RecordDataSize; // # of bytes of data following - // this structure. - UINT32 Reserved; -} MPKBagRecordHeader; - -// -// Used only when bagType (record type) is BAG_TYPE_SMP -// - -struct smpRpcHeader /* 32 bytes */ -{ - UINT32 stamp; - UINT32 version; - UINT32 flags; - UINT32 apiCount; // # of APIs names that follow. - UINT32 dataSize; // Total length of data that - // follows this structure - // (If API name list, then - // total length of all ASCIIZ - // API names + an additional - // NULL byte). - UINT32 zeros[3]; -}; - -struct CNBFunnelingStubStructure -{ - BYTE PushImmediateDWORD; - LONG AddressOfFunctionBeingStubbed; - BYTE JumpNearDisplacementRelative; - LONG JumpDisplacement; -}; - -/* if this struct is changed, it must be changed in loader.inc as well */ -/* changing the fields (names are not important) of this structure may require - changes in deftoc as well so that the outputs of deftoc match */ - -struct ExternalPublicDefinitionStructure -{ - /* note: the first 9 fields in this structure should be identical to - * those in the InternalPublicDefinitionStructure. - */ - struct ExternalPublicDefinitionStructure *EPDLink; - LONG EPDValue; - BYTE *EPDName; - LONG EPDSysCallAddress; - LONG EPDActualAddress; - WORD EPDExportDistance; - BYTE EPDFlag; - BYTE EPDType; - struct ExternalPublicDefinitionStructure *EPDHashLink; - struct LoadDefinitionStructure *EPDLoadRecord; -// WORD EPDAllowedImporters; -// WORD EPD_Available_for_Future_Use; /* unused */ - - struct CNBFunnelingStubStructure *EPDCNBFunnelingStubAddress; - LONG EPDMPKStubSize;// BFR WHAT USE NOW? - - // - // The # of modules that have imported this - // symbol. - // - - UINT EPDReferenceCount; -}; - -/* if this struct is changed, it must be changed in loader.inc as well */ -/* changing the fields (names are not important) of this structure may require - changes in deftoc as well so that the outputs of deftoc match */ - -struct InternalPublicDefinitionStructure -{ - /* note: the first 9 fields in this structure should be identical to - * those in the ExternalPublicDefinitionStructure. - */ - struct InternalPublicDefinitionStructure *IPDLink; - void *IPDValue; - BYTE *IPDName; - LONG IPDSysCallAddress; - void *IPDActualAddress; - WORD IPDExportDistance; - BYTE IPDFlag; - BYTE IPDType; - struct InternalPublicDefinitionStructure *IPDHashLink; -}; - -struct LoadDefinitionStructure -{ - struct LoadDefinitionStructure *LDLink; - struct LoadDefinitionStructure *LDKillLink; - struct LoadDefinitionStructure *LDScanLink; - struct ResourceTagStructure *LDResourceList; - LONG LDIdentificationNumber; - LONG LDCodeImageOffset; - LONG LDCodeImageLength; - LONG LDDataImageOffset; - LONG LDDataImageLength; - LONG LDUninitializedDataLength; - LONG LDCustomDataOffset; - LONG LDCustomDataSize; - LONG LDFlags; - LONG LDType; - LONG (*LDInitializationProcedure) - ( - struct LoadDefinitionStructure *LoadRecord, - struct ScreenStruct *screenID, - BYTE *CommandLine, - BYTE *loadDirectoryPath, - LONG uninitializedDataLength, - LONG fileHandle, - LONG (*ReadRoutine) - ( - LONG fileHandle, - LONG offset, - void *buffer, - LONG numberOfBytes - ), - LONG customDataOffset, - LONG customDataSize, - /* - ** The next two parameters were added in NetWare v4.11. - ** It would be preferred to get this data directly from LoadRecord, - ** They are provided here for any NLMs that still expect these - ** as parameters. - */ - LONG messageCount, - BYTE **messages - ); - void (*LDExitProcedure) - ( - void - ); - LONG (*LDCheckUnloadProcedure) - ( - struct ScreenStruct *screenID - ); - struct ExternalPublicDefinitionStructure *LDPublics; - - // - // Name of the NLM. This is usually the 8.3 file name, but does not have - // to look like a file name. - // This is a length preceeded string. Is it NULL - // terminated??? - // - - BYTE LDFileName[36]; - - // - // Description of the NLM. - // This is a length preceeded string. Is it NULL - // terminated???? - // - - BYTE LDName[1 + LD_MODULE_DESCRIPTION_MAX_LENGTH]; /* length preceeded */ - LONG *LDCLIBLoadStructure; - LONG *LDNLMDebugger; - LONG LDParentID; - LONG LDReservedForCLIB; - void *AllocMemory; - LONG LDTimeStamp; - void *LDModuleObjectHandle; /* If Instrumented BEW 10/16/90 */ - LONG LDMajorVersion; - LONG LDMinorVersion; - LONG LDRevision; - LONG LDYear; - LONG LDMonth; - LONG LDDay; - BYTE *LDCopyright; - LONG LDSuppressUnloadAllocMsg; - void *LDLibraryVM; -// LONG Reserved3; -// LONG Reserved4[64]; - BYTE LDFullPath[260]; // null terminated string - max size is 256 - LONG Reserved5[12]; - LONG Reserved6; - struct DomainStructure *LDDomainID; /* This must be non-zero for the Alloc Hunt code to work right. */ - /* It also points to the domain structure. */ - struct LoadDefinitionStructure *LDEnvLink; - void *LDAllocPagesListHead; - struct ExternalPublicDefinitionStructure *LDTempPublicList; - LONG LDMessageLanguage; /* for enabling */ - BYTE **LDMessages; /* for enabling */ - LONG LDMessageCount; /* for enabling */ - BYTE *LDHelpFile; /* for enabling */ - LONG LDMessageBufferSize; /* for enabling */ - LONG LDHelpBufferSize; /* for enabling */ - LONG LDSharedCodeOffset; /* NetWare 4 protection architecture */ - LONG LDSharedCodeLength; /* NetWare 4 protection architecture */ - LONG LDSharedDataOffset; /* NetWare 4 protection architecture */ - LONG LDSharedDataLength; /* NetWare 4 protection architecture */ - LONG (*LDSharedInitProcedure) /* NetWare 4 protection architecture */ - ( - struct LoadDefinitionStructure *LoadRecord, - struct ScreenStruct *screenID, - BYTE *CommandLine, - BYTE *loadDirectoryPath, - LONG uninitializedDataLength, - LONG fileHandle, - LONG (*ReadRoutine) - ( - LONG fileHandle, - LONG offset, - void *buffer, - LONG numberOfBytes - ), - LONG customDataOffset, - LONG customDataSize, - /* - ** The next two parameters were added in NetWare v4.11. - ** It would be preferred to get this data directly from LoadRecord, - ** They are provided here for any NLMs that still expect these - ** as parameters. - */ - LONG messageCount, - BYTE **messages - ); - void (*LDSharedExitProcedure) /* NetWare 4 protection architecture */ - ( - void - ); - LONG LDRPCDataTable; - LONG LDRealRPCDataTable; - LONG LDRPCDataTableSize; - - // - // Number of non-server symbols imported by this NLM. - // (Symbols imported from SERVER.NLM and LOADER.EXE are - // excluded from this count). - // - - LONG LDNumberOfReferencedPublics; - - // - // Pointer to an array each slot of which contains a pointer - // to the non-server symbol record this module imported. - // (Note that symbols imported from SERVER.NLM and LOADER.EXE - // don't show up in this list). - // - - struct ExternalPublicDefinitionStructure **LDReferencedPublics; - - // - // Number of symbols exported by this NLM which are - // referenced by other NLMs which import them. - // - - LONG LDNumberOfReferencedExports; - LONG LDNICIObject; /*** GREEN RIVER CMC LOADER CHANGE ***/ - LONG LDAllocPagesListLocked; /* True if LDAllocPagesListHead is locked */ - struct AddressSpace *LDAddressSpace; - - // - // We will use this field to distinguish between structures - // allocated by the loader and that allocated by anyone else - // knowing about the LoadDefinitionStructure format. Only if - // this Signature field is valid will be attempt to touch the - // LDImportedKernelSymbolCount and ppLDImportedKernelSymbols - // fields. - // - - UINT Signature; - - struct CNBFunnelingStubStructure *MainCNBFunnelingStubPtr; - LONG MainCNBFunnelingStubsLeft; - - LONG LDBuildNumber; /* NLM Build Number */ - struct LoadDefinitionExtension*LDExtensionData; - - // - // New fields to track some useful information. - // - - // - // # of symbols imported from the "kernel." - // (i.e. SERVER.NLM and LOADER.EXE). - // - - UINT LDImportedKernelSymbolCount; - - // - // Pointer to an array each slot of which contains a pointer - // to the list of kernel symbols (i.e. from SERVER.NLM and LOADER.EXE) - // imported by this module. - // - - struct InternalPublicDefinitionStructure **ppLDImportedKernelSymbols; - struct LoadTimeInfoStruct *loadTimeInfo; - struct CNBFunnelingStubStructure *SharedCNBFunnelingStubPtr; - LONG SharedCNBFunnelingStubsLeft; - UINT8 LDModuleLongName[LD_MODULE_LONG_NAME_MAX_LENGTH]; // Length proceeded only.... -}; - -struct StartInfoRecordStructure -{ - LONG relocationCount; - LONG relocationOffset; - LONG codeOffset; - LONG dataOffset; - LONG startOffset; - LONG OSNLMOffset; - LONG MSNLMOffset; - LONG languageID; - LONG messageFileOffset; - LONG messageFileLength; - LONG tableVersionNumber; - LONG DSNLMOffset; - LONG loaderImportOffset; - LONG loaderImportCount; - BYTE LoadFileStatusString[4]; - LONG reserved[1]; - BYTE loaderTypeString[1]; -}; - -struct RealModeDataStructure -{ - LONG OriginalCR0; - LONG XMSEntry; - LONG XMSHandle; - LONG XMSMemoryBase; - LONG XMSMemorySize; - LONG LoaderStackTop; - struct StartInfoRecordStructure *StartInfoPointer; - LONG ParentPSP_Address; - LONG ChildPSP_Address; - LONG HardwareLoaderID; - LONG FeatureFlagsEDX; - LONG FeatureFlagsECX; - LONG FeatureFlagsEBX; - LONG CPUFamily; - LONG CPUModel; - LONG CPUStepping; - LONG AdditionalHighMemory; - LONG OriginalCR4; - WORD DOSClientODIShutdownOffset; - WORD DOSClientODIShutdownSegment; - WORD DOSClientODIResetOffset; - WORD DOSClientODIResetSegment; - WORD DOSClientODIDriversShutdown; - WORD DOSClientODIDriversReset; - LONG Reserved; -}; - -struct LoadEngineNLMStructure -{ - struct LoadEngineNLMStructure *link; - LONG processID; - LONG status; /* 0 - new, 1 - mine, 2 - otherEngine's, 3 - done */ - LONG returnCode; - BYTE *nameAndCommandLine; - LONG loadOptions; - LONG engineNumber; - LONG function; /* 0 - load, 1 - is loaded, 2 - unload */ -}; - -typedef LONG (*Netman_f)(LONG *NetManBlock); - -typedef struct Netman_t -{ - Netman_f NetmanUpdate[MaximumNumberOfUpdateRoutines]; -} Netman_s, *pNetman_s; - -struct LoaderSymbols { - LONG (*SetNICIEntryPoints)(); - LONG (*ClearNICIEntryPoints)(); - BYTE breakOnLoadFlag; - BYTE *consoleSecured; - struct ExternalPublicDefinitionStructure *ExternalPublicList; - struct LoadDefinitionStructure **LoadedList; - ERROR (*AcquireLoaderLock)(void); - ERROR (*ReleaseLoaderLock)(void); - struct LoadDefinitionStructure **GhostModuleList; - struct InternalPublicDefinitionStructure **publicHashTable; - struct ResourceTagStructure *LoaderAllocRTag; - struct ResourceTagStructure *LoaderAllocHighRTag; - LONG *SignalDebuggerOptions; - LONG (*AddModuleToInternalModuleList)(); - LONG (*RemoveModuleFromInternalModuleList)(); - void (*CryptSymbolStruct)(); - LONG (*GhostCallBack)(); - LONG (*FindPublicRecordStructure)(); - LONG (*FindPublicRecord)(); - LONG (*LoadFile)(); - LONG (*AllocInitialize)(); - LONG (*AllocTerminate)(); - LONG (*UnloadLoadedFile)(); - void (*KillMe)(); - void (*KillLoadFileProcedure)(); - LONG (*LoadAllNeededModules)(); - LONG (*ProcessRelocationRecords)(); - LONG (*ProcessExternalRecords)(); - LONG (*ProcessPublicRecords)(); - LONG (*ProcessDebugRecords)(); - BYTE *(*AllocateMappedMemory)(); - LONG (*ReturnMappedMemory)(); - LONG (*ImportPublicSymbol)(); - LONG (*UnImportPublicSymbol)(); - LONG (*ExportPublicSymbol)(); - LONG (*GetNumberOfReferencedExports)(); - void *(*AllocateEnableMemory)(); - LONG (*FindAlternateMessageFile)(); - LONG (*FindAlternateHelpFile)(); - LONG (*LoadMessageAndHelpFiles)(); - void (*InitializePublicSymbols)(); - void (*SetLoadRecordID)(); - void (*AddToPublicHash)(); - void (*RemoveFromPublicHash)(); - struct LoadDefinitionStructure *(*ValidateModuleHandle)(); - LONG (*SetLoadBreakpoint)(); - struct ProcessorStructure *(*GetProcessorID)(); - void (*ReCalibrateUtilization)(void); - void (*CRemoveDebuggerSymbol)(); - void (*ReturnAllLeftOverResources)(); - pNetman_s NetMan; - LONG *NLMsLoaded; -}; - -struct LoaderExtensionStructure { - struct LoaderExtensionStructure*LDXNext; - struct ResourceTagStructure*LDXResourceTag; - LONG(*LDXHandler)(struct ScreenStruct*screen, - LONG hFile, - LONG(*readRoutine)(LONG, LONG, void*, LONG), - LONG options, - BYTE*moduleName, - BYTE*loadPath, - BYTE*commandLine, - struct AddressSpace*addressSpace); - struct KernelUserAddressPair *LDXReadRoutines; -}; - -struct LoaderSectionInformation { - void*LDSAddress; - LONG LDSSize; - BYTE LDSName[8]; -}; - -struct KernelUserAddressPair { - void*APKernel; - void*APUser; -}; - -/* - each loader extension should start its private data (if - * any) with this structure; further fields are up to the - * extension - * - the information is targeted mainly to aid debuggers - * - LDESignature should uniquely identify the type of extension - * in case some other component needs specific image type - * information (generally this would be the image's signature) - * - LDESectionCount and LDESections may be set to zero if they - * do not apply and the according (correct) information is - * stored in LoadDefinitionStructure - */ -struct LoadDefinitionExtension { - LONG LDESignature; - LONG LDESectionCount; - struct LoaderSectionInformation*LDESections; -}; - -/*********** remote declarations not found in an included header ***********/ - -extern struct InternalPublicDefinitionStructure *InternalPublicList; -extern struct InternalPublicDefinitionStructure *InternalOldPublicList; - -extern struct ExternalPublicDefinitionStructure *ExternalPublicList; - -extern LONG OSDataLinearAddress; -extern LONG OSCodeLinearAddress; - -extern WORD screenType; - -extern LONG (*NetManUpdate[MaximumNumberOfUpdateRoutines])(LONG *NetManBlock); - -extern void CNBFunneler(); -extern void UserCNBFunneler(); - -extern BYTE *GetMappedMemory(LONG imageType, - LONG size, - LONG SleepOKFlag, - LONG *SleptFlag); - -extern LONG ExportUserModeDataSymbol( - LONG moduleHandle, - BYTE *symbolName, - LONG symbolAddress); - -extern LONG ExportUserModePublicSymbol( - LONG moduleHandle, - BYTE *symbolName, - LONG syscallStubAddress); - -extern LONG ReleaseMappedMemory(BYTE *address, - LONG size); - -extern struct RealModeDataStructure *RealModeDataTable; -extern struct RealModeDataStructure RMDTable; - -extern struct ResourceTagStructure *LoaderAllocHighRTag; - -/************************** function definitions ***************************/ - -#define FILL_OUT_CNB_FUNNEL_STUB(s, c, t) \ -{ \ -s->PushImmediateDWORD = \ - 0x68; /* push immediate dword opcode */ \ -s->AddressOfFunctionBeingStubbed = \ - (LONG)(c); /* address of function to call */ \ -s->JumpNearDisplacementRelative = \ - 0xE9; /* jmp near, displ. relative opcode */ \ -s->JumpDisplacement = \ - (LONG)(t) - /* target address */ \ - ((LONG)&(s)->JumpDisplacement) - /* address that is just after */ \ - sizeof((s)->JumpDisplacement); /* this instruction */ \ -} - -#endif // #if 0 GLP - -#endif /* __LOADER_H__ */ diff --git a/include/nwnss/support/lnxmbINC/maapi.h b/include/nwnss/support/lnxmbINC/maapi.h deleted file mode 100644 index b6b6e8c..0000000 --- a/include/nwnss/support/lnxmbINC/maapi.h +++ /dev/null @@ -1,50 +0,0 @@ -/***************************************************************************** - * - * (C) Copyright 1997-1998 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - ****************************************************************************/ - -#ifndef __MAAPI_H -#define __MAAPI_H - -#ifdef __cplusplus -# define EXTERNC extern "C" -#else -# define EXTERNC -#endif - -#if defined(DS_FOR_NW) || defined(DS_FOR_NWU) -# define MASVEXPORT -# define MASVIMPORT -#else -# define MASVEXPORT __declspec(dllexport) -# define MASVIMPORT __declspec(dllimport) -#endif - -#ifdef __MASV_SOURCE__ -# define MASV__PORT MASVEXPORT -#else -# define MASV__PORT MASVIMPORT -#endif - -#define MASVAPI EXTERNC MASV__PORT - -/****************************************************************************/ -/****************************************************************************/ -#endif diff --git a/include/nwnss/support/lnxmbINC/manss.h b/include/nwnss/support/lnxmbINC/manss.h deleted file mode 100644 index 2419059..0000000 --- a/include/nwnss/support/lnxmbINC/manss.h +++ /dev/null @@ -1,35 +0,0 @@ -/***************************************************************************** - * - * (C) Copyright 1998 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - ****************************************************************************/ - -#ifndef __MANSS_H -#define __MANSS_H - -#include -#include - -MASVAPI uint32 MASVGetConnNSSVolumeAccess(uint32 connID, uint32 lblSize, void *label); - -MASVAPI uint32 MASVGetVolumeLabel(uint32 volumeNumber, uint32 *lblSize, void *label); - -/****************************************************************************/ -/****************************************************************************/ -#endif diff --git a/include/nwnss/support/lnxmbINC/masv.h b/include/nwnss/support/lnxmbINC/masv.h deleted file mode 100644 index 1ceb753..0000000 --- a/include/nwnss/support/lnxmbINC/masv.h +++ /dev/null @@ -1,259 +0,0 @@ -/***************************************************************************** - * - * (C) Copyright 1997-1998 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - ****************************************************************************/ - -#if ! defined(MASV_H) -#define MASV_H - -#include - -#define MASV_NCP_VERB 91 - -/************************************************************************/ -/* Rights (returned by Test Access Rights functions */ -/************************************************************************/ -#define NWMA_NONE 0 -#define NWMA_R 1 -#define NWMA_W 2 -#define NWMA_RW (NWMA_R|NWMA_W) - -/***********************************************************************/ -/* Graded Authentication Types */ -/***********************************************************************/ -#define NWMA_GA_SI -1 /* Internal use -- Resevered */ -#define NWMA_GA_NONE 0 -#define NWMA_GA_NV4 1 -#define NWMA_GA_SSL_CERT 2 -#define NWMA_GA_WEAK 3 -#define NWMA_GA_N3 4 /* N3 Authentication type (Via Bindery calls)*/ -#define NWMA_GA_UNAUTH 5 /* No Credentials Authentication type */ -#define NWMA_GA_V0AUTH 6 /* Version 0 Authentication Type */ - -/***********************************************************************/ -/* Clearance Request values */ -/***********************************************************************/ -#define NWMA_REQ_UNKNOWN -1 -#define NWMA_REQ_DEFAULT 0 /* Highest possible based on user default*/ -#define NWMA_REQ_REQUIRED 1 /* User supplied clearance only if approved*/ -#define NWMA_REQ_HIGHEST 2 /* Highest possible based on user auth clearances*/ - -/***********************************************************************/ -/* Range/Clearance typedefs */ -/***********************************************************************/ - -#define NWMA_RNG_UNKNOWN -1 /* Used for input to have masv determine */ -#define NWMA_RNG_SINGLE_LEVEL 0 -#define NWMA_RNG_TRUST_RANGE 1 - -/***********************************************************************/ -/* Human Readable Label typedefs */ -/***********************************************************************/ - -/* Length MAX for Human Readable Labels */ -#define NWMA_MAX_LABELNAME_LEN 31 -#define NWMA_MAX_LABELNAME_BYTES (NWMA_MAX_LABELNAME_LEN+1) * sizeof(unicode) - -/*Label Types */ -#define NWMA_LABEL_TYPE_UNKNOWN -1 /* Init value used for input */ -#define NWMA_LABEL_TYPE_IDL 0 -#define NWMA_LABEL_TYPE_V1 1 - -typedef struct NWMAHRL -{ - uint32 labelType; - unicode labelName[NWMA_MAX_LABELNAME_LEN+1]; -} NWMAHRL; - -/***********************************************************************/ -/* HRL Clearance Range typedefs */ -/***********************************************************************/ - -#define MA_RNG_UNKNOWN -1 /* Used for input to have masv determine */ -#define MA_RNG_SINGLE_LEVEL 0 -#define MA_RNG_TRUST_RANGE 1 - -typedef struct NWMARangeHRL -{ - uint32 rangeType; - NWMAHRL readLabel; - NWMAHRL writeLabel; -} NWMARangeHRL; - -/***********************************************************************/ -/* Policy Configuration Structure */ -/***********************************************************************/ -#define NWMA_POLICY_VERSION_1 1 - -typedef struct NWMAPolicyV1 -{ - uint8 version; /* IN/OUT -- NWMA_POLICY_VERSION*/ - uint8 minAPISendFnshAuthVer; - uint8 minAPIRecvFnshAuthVer; - uint8 loginDir_OK; - uint8 setServerAdmin; - uint32 policyNum; - NWMARangeHRL minOperatorRange; - NWMARangeHRL defaultAuthRange; - NWMARangeHRL defaultRange; - NWMARangeHRL unauthenticatedRange; - NWMAHRL defaultVolumeLabel; - NWMAHRL loginDirectoryLabel; - NWMAHRL defaultPartitionLabel; - NWMAHRL defaultPartitionPublicLabel; -} NWMAPolicyV1; - -/***********************************************************************/ -/* MASV NCP Structures */ -/***********************************************************************/ -typedef struct -{ - uint8 version; - uint8 volumeNameLength; - uint8 volumeName[1]; // length preceeded - NWMAHRL volLabel; -}SetVolumeLabelRequest; - -typedef struct -{ - uint8 version; - uint8 activeLabel; - uint8 volumeNameLength; - uint8 volumeName[1]; // length preceeded -}GetVolumeLabelRequest; - -typedef struct -{ - NWMAHRL volLabel; -}GetVolumeLabelReply; - -typedef struct -{ - uint8 version; - uint32 targetConnID; -}GetConnRangeRequest; - -typedef struct -{ - NWMARangeHRL range; -}GetConnRangeReply; - -typedef struct -{ - uint8 version; - NWMAHRL publicLabel; - NWMAHRL protectedLabel; - unicode objName[1]; -}SetPartLabelRequest; - -typedef struct -{ - uint8 version; - unicode objName[1]; -}RemovePartitionPropLabelRequest; - -typedef struct -{ - uint8 version; - unicode objName[1]; -}GetObjectLabelRequest; - -typedef struct -{ - NWMAHRL publicLabel; - NWMAHRL protectedLabel; -}GetObjectLabelReply; - -typedef struct -{ - uint8 version; - uint32 reqType; - NWMARangeHRL connRange; - uint32 gaType; - uint32 credentialSize; - uint8 credential[1]; - unicode objName[1]; -}RequestClearanceRequest; - -typedef struct -{ - uint32 flags; - uint32 credentialSize; - uint8 credential[1]; -}RequestClearanceReply; - -typedef struct -{ - uint8 version; - NWMARangeHRL authRange; - unicode objName[1]; -}SetRangeRequest; - -typedef struct -{ - uint8 version; - unicode objName[1]; -}ResetRangeRequest; - -typedef struct -{ - uint8 version; - unicode objName[1]; -}GetDefaultRangeRequest; - -typedef struct -{ - uint32 labelVersion; - NWMARangeHRL defaultRange; -}GetDefaultRangeReply; - -typedef struct -{ - uint8 version; - uint32 iterationHandle; - unicode objName[1]; -}ScanAuthRangeRequest; - -typedef struct -{ - uint32 labelVersion; - uint32 iterationHandle; - NWMARangeHRL authorizationRange; -}ScanAuthRangeReply; - -typedef struct -{ - uint8 version; - NWMAPolicyV1 policy; -}SetPolicyRequest; - -typedef struct -{ - uint8 version; -}GetPolicyRequest; - -typedef struct -{ - NWMAPolicyV1 policy; -}GetPolicyReply; - -#endif -/****************************************************************************/ -/****************************************************************************/ diff --git a/include/nwnss/support/lnxmbINC/mmpublic.h b/include/nwnss/support/lnxmbINC/mmpublic.h deleted file mode 100644 index 7ef75b9..0000000 --- a/include/nwnss/support/lnxmbINC/mmpublic.h +++ /dev/null @@ -1,1763 +0,0 @@ -/**************************************************************************** - | - | (C) Copyright 2004 Novell, Inc. - | All Rights Reserved. - | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. - | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. - | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. - | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com - | - |***************************************************************************/ -#ifndef _MMPUBLIC_H_ -#define _MMPUBLIC_H_ - -#include - -#ifndef MMBLD -typedef unsigned long HNDL; -typedef unsigned long OBID; -#endif - -/**************************************************************************** -** -** Miscellaneous Definitions -*/ - -/* Lock Types */ - -#define MM_READ_LOCK 0x01 -#define MM_WRITE_LOCK 0x02 - -#define MM_INTERNAL_OBJECT_MANAGER 0x01 -#define MM_EXTERNAL_OBJECT_MANAGER 0x02 - -#define MM_MAX_OBJECT_STRING_LEN 128 /* Including the NULL */ -#define MM_ID_LEN 16 /* 16 bytes, sizeof( GUID ) */ -#define MM_MAX_MIRROR_MEMBERS 8 - -#define FUNCTION_TABLE_SIZE 72 - -struct RemovableInfoDef -{ - LONG cartridgetype; - LONG mediatype; - LONG slotnumber; - BYTE label[64]; /* Labels are length preceeded, not */ - LONG identificationtype; /* nescessaraly NULL terminated strings.*/ - LONG identificationtimestamp; -}; - - -struct CreateRemovableInfoDef -{ - LONG cartridgetype; - LONG mediatype; - LONG slotnumber; - BYTE label[64]; /* Labels are length preceeded, not */ - LONG identificationtype; /* nescessaraly NULL terminated strings.*/ - LONG identificationtimestamp; -}; - - -/**************************************************************************** -** -** Class Definitions -*/ - -struct ClassGenericInfoDef -{ - BYTE name[MM_MAX_OBJECT_STRING_LEN]; - LONG status; - LONG numberofobjects; - LONG tablesize; - OBID application; -}; - -/* Class Types */ - -#define MM_IO_CLASS 0 -#define MM_APPLICATION_CLASS 1 -#define MM_FILTER_CLASS 2 -#define MM_IDENTIFIER_CLASS 3 -#define MM_NOTIFY_CLASS 4 -#define MM_OBJECT_MANAGER_CLASS 5 -#define MM_RESERVATION_CLASS 6 -#define MM_ATTRIBUTE_CLASS 7 -#define MM_MESSAGE_CLASS 8 -#define MM_IO_SUBSYSTEM_CLASS 9 -#define MM_MAX_INTERNAL_CLASSES 10 - -/* Class Status */ -#define MM_CLASS_AVAILABLE 0x00000000 -#define MM_CLASS_ACTIVATED 0x00000001 -#define MM_CLASS_SYSTEM 0x00000010 -#define MM_CLASS_PERMANENT 0x00000020 -#define MM_CLASS_PROPRIETARY 0x00000040 - -#define MM_APPLICATION_SIGNATURE 0x0050414D -#define MM_ATTRIBUTE_SIGNATURE 0x0054414D -#define MM_CACHE_SIGNATURE 0x0041434D -#define MM_CLASS_SIGNATURE 0x004C434D -#define MM_FILTER_SIGNATURE 0x0049464D -#define MM_IDENTIFIER_SIGNATURE 0x0044494D -#define MM_IO_SIGNATURE 0x004F494D -#define MM_IO_SUBSYSTEM_SIGNATURE 0x0053494D -#define MM_MESSAGE_SIGNATURE 0x00454D4D -#define MM_NOTIFY_SIGNATURE 0x004F4E4D -#define MM_OBJECT_MANAGER_SIGNATURE 0x004D4F4D -#define MM_RESERVATION_SIGNATURE 0x0045524D -#define MM_CPU_VECTOR_SIGNATURE 0x0056434D - -/**************************************************************************** -** -** Generic Object Definitions -*/ - -/* object status */ - -#define MM_OBJECT_ACTIVATED 0x00000001 -#define MM_OBJECT_REGISTERED 0x00000002 -#define MM_OBJECT_ACTIVATING 0x00000004 -#define MM_OBJECT_FUNCTIONAL 0x00000008 -#define MM_OBJECT_DEACTIVATING 0x00000010 -#define MM_OBJECT_LOADING 0x00000020 -#define MM_OBJECT_LOADING_BIT 5 - - -/**************************************************************************** -** -** Application Definitions -*/ - -struct ApplicationRegistrationDef -{ - LONG classobjectsignature; - BYTE *name; - LONG (*controlroutine)( LONG token, - LONG _function, - LONG _parm1, - LONG _parm2, - LONG _parm3, - LONG _bufferlength, - void *_buffer ); -#ifndef MMSDK - LONG privilegedapplicationkey; -#else - LONG reserved; /* Set to NULL */ -#endif - LONG type; - LONG token; - LONG identifier; -}; - -struct ApplicationGenericInfoDef -{ - BYTE name[MM_MAX_OBJECT_STRING_LEN]; - BYTE nlmfilename[MM_MAX_OBJECT_STRING_LEN]; - BYTE nlmdescription[MM_MAX_OBJECT_STRING_LEN]; - LONG status; - LONG type; - LONG identifier; - LONG numberofregisteredobjects; - LONG numberofreservedobjects; -}; - -/* Application Types */ - -#define MM_GENERAL_STORAGE_APPLICATION 0x00000001 -#define MM_FILE_SYSTEM_APPLICATION 0x00000002 -#define MM_BACKUP_RESTORE_APPLICATION 0x00000003 -#define MM_HUMAN_JUKEBOX_APPLICATION 0x00000004 -#define MM_IO_SUBSYSTEM_APPLICATION 0x00000005 - -/* Application Status */ - -#define MM_PRE_MOAB_APPLICATION 0x10000000 -#define MM_UNIPROCESSOR_APPLICATION 0x20000000 - -/**************************************************************************** -** -** Attribute Definitions -*/ - -struct AttributeRegistrationDef -{ - LONG classobjectsignature; - BYTE *name; - LONG type; - OBID objectid; - - LONG attributeid; - LONG valuetype; - LONG flags; - LONG (*getroutine)( OBID, - LONG attributeid, - LONG valuelength, - void *value, - void *token ); - - LONG (*setroutine)( OBID, - LONG attributeid, - LONG valuelength, - void *value, - void *token ); - void *token; -}; - -struct AttributeGenericInfoDef -{ - BYTE name[MM_MAX_OBJECT_STRING_LEN]; - LONG attributetype; - LONG status; - LONG attributeid; - LONG valuetype; - LONG valuesize; - OBID appliedobjectid; - OBID applicationid; -}; - -/* Attribute Types */ - -#define MM_GENERIC_ATTRIBUTE 0x00000001 -#define MM_OBJECT_TYPE_ATTRIBUTE 0x00000002 -#define MM_OBJECT_SPECIFIC_ATTRIBUTE 0x00000004 - -/* Attribute Status */ - -#define MM_ATTRIBUTE_SETTABLE 0x00000100 - -/* Attribute Data Types */ - -#define MM_STRING 0x00000001 -#define MM_BYTE 0x00000002 -#define MM_WORD 0x00000003 -#define MM_LONG 0x00000004 -#define MM_OTHER 0x00000005 - -/* Attribute IDs */ -#define MM_ADDED_VALUE_ID 0x4444410B -#define MM_BLOCK_SIZE_ID 0x4F4C420A -#define MM_CAPACITY_ID 0x50414308 -#define MM_CARD_ID 0x52414304 -#define MM_CARTRIDGE_TYPE_ID 0x5241430E -#define MM_CONTROLLER_ID 0x4E4F430A -#define MM_CYLINDERS_ID 0x4C594309 -#define MM_DATA_COMPRESSION_INFO_ID 0x54414415 -#define MM_DMA_ID 0x414D4403 -#define MM_DRIVER_ID 0x49524406 -#define MM_DRIVER_NAME_ID 0x4952440B -#define MM_HEADS_ID 0x41454805 -#define MM_HOTFIX_AVAILABLE_ID 0x544F4810 -#define MM_HOTFIX_BLOCKS_ID 0x544F480D -#define MM_HOTFIX_SIZE_ID 0x544F480B -#define MM_HOTFIX_SYSTEM_BLOCKS_ID 0x544F4814 -#define MM_INTERRUPT_ID 0x544E4909 -#define MM_LABEL_ID 0x42414C05 -#define MM_LUN_ID 0x4E554C03 -#define MM_MAXIMUM_BLOCK_SIZE_ID 0x58414D12 -#define MM_MAXIMUM_NUMBER_OF_PARTITIONS_ID 0x58414D1C -#define MM_MAXIMUM_PARTITION_SIZE_ID 0x58414D16 -#define MM_MEMORY_ID 0x4D454D06 -#define MM_MINIMUM_BLOCK_SIZE_ID 0x4E494D12 -#define MM_MIRROR_COUNT_ID 0x52494D0C -#define MM_MIRROR_GROUP_PRESENT_ID 0x52494D14 -#define MM_MIRROR_IN_SYNC_ID 0x52494D0E -#define MM_MIRROR_OPERATIONAL_ID 0x52494D12 -#define MM_MIRROR_ORPHAN_ID 0x52494D0D -#define MM_NAME_ID 0x4D414E04 -#define MM_PARTITION_OFFSET_ID 0x4F415010 -#define MM_PARTITION_TYPE_ID 0x5241500E -#define MM_PARTITIONER_TYPE_ID 0x52415010 -#define MM_PORT_ID 0x524F5004 -#define MM_PREFERRED_SIZE_ID 0x4552500E -#define MM_RAW_DEVICE_NAME_ID 0x5741520F -#define MM_READ_AFTER_WRITE_ID 0x41455210 -#define MM_READ_HANDICAP_ID 0x4145520D -#define MM_READ_ONLY_ID 0x41455209 -#define MM_REMIRROR_PERCENT_ID 0x4D455210 -#define MM_REMIRROR_STATUS_ID 0x4D45520F -#define MM_REMOVABLE_ID 0x4D455209 -#define MM_SECTORS_ID 0x43455307 -#define MM_SLOT_ID 0x4F4C5304 -#define MM_SLOT_NUMBER_ID 0x4F4C530B -#define MM_TAPE_MEDIA_TYPE_ID 0x5041540F -#define MM_TAPE_POSITION_SIZE_ID 0x50415412 -#define MM_TAPE_READ_FORMAT_ID 0x50415410 -#define MM_TAPE_WRITE_FORMAT_ID 0x50415411 -#define MM_TYPE_ID 0x50595404 -#define MM_UNIT_SIZE_ID 0x494E5509 -#define MM_USER_DEFINED_ID 0x4553550C - -/* Attribute Names */ - -#define MM_ADDED_VALUE "ADDED_VALUE" -#define MM_BLOCK_SIZE "BLOCK_SIZE" -#define MM_CAPACITY "CAPACITY" -#define MM_CARD "CARD" -#define MM_CARTRIDGE_TYPE "CARTRIDGE_TYPE" -#define MM_CONTROLLER "CONTROLLER" -#define MM_CYLINDERS "CYLINDERS" -#define MM_DATA_COMPRESSION_INFO "DATA_COMPRESSION_INFO" -#define MM_DATA_ENCRYPTION "DATA_ENCRYPTION" -#define MM_DATA_ENCRYPTION_KEY "DATA_ENCRYPTION_KEY" -#define MM_DMA "DMA" -#define MM_DRIVER "DRIVER"; -#define MM_DRIVER_NAME "DRIVER_NAME" -#define MM_HEADS "HEADS" -#define MM_HOTFIX_AVAILABLE "HOTFIX_AVAILABLE" -#define MM_HOTFIX_BLOCKS "HOTFIX_BLOCKS" -#define MM_HOTFIX_SIZE "HOTFIX_SIZE" -#define MM_HOTFIX_SYSTEM_BLOCKS "HOTFIX_SYSTEM_BLOCKS" -#define MM_INTERRUPT "INTERRUPT" -#define MM_LABEL "LABEL" -#define MM_LUN "LUN" -#define MM_MAXIMUM_BLOCK_SIZE "MAXIMUM_BLOCK_SIZE" -#define MM_MAXIMUM_PARTITION_SIZE "MAXIMUM_PARTITION_SIZE" -#define MM_MAXIMUM_PARTITIONS "MAXIMUM_NUMBER_OF_PARTITIONS" -#define MM_MEDIA_TYPE "MEDIA_TYPE" -#define MM_MEMORY "MEMORY" -#define MM_MINIMUM_BLOCK_SIZE "MINIMUM_BLOCK_SIZE" -#define MM_MIRROR_COUNT "MIRROR_COUNT" -#define MM_MIRROR_GROUP_PRESENT "MIRROR_GROUP_PRESENT" -#define MM_MIRROR_IN_SYNC "MIRROR_INSYNCH" -#define MM_MIRROR_IS_OPERATIONAL "MIRROR_OPERATIONAL" -#define MM_MIRROR_ORPHAN "MIRROR_ORPHAN" -#define MM_NAME "NAME" -#define MM_PARTITION_OFFSET "PARTITION_OFFSET" -#define MM_PARTITION_TYPE "PARTITION_TYPE" -#define MM_PARTITIONER_TYPE "PARTITIONER_TYPE" -#define MM_PORT "PORT" -#define MM_PREFERRED_SIZE "PREFERRED_SIZE" -#define MM_RAW_DEVICE_NAME "RAW_DEVICE_NAME" -#define MM_READ_AFTER_WRITE "READ_AFTER_WRITE" -#define MM_READ_HANDICAP "READ_HANDICAP" -#define MM_READ_ONLY "READ_ONLY" -#define MM_REMIRROR_PERCENT "REMIRROR_PERCENT" -#define MM_REMIRROR_STATUS "REMIRROR_STATUS" -#define MM_REMOVABLE "REMOVABLE" -#define MM_SECTORS "SECTORS" -#define MM_SLOT "SLOT" -#define MM_SLOT_NUMBER "SLOT_NUMBER" -#define MM_TAPE_MEDIA_TYPE "TAPE_MEDIA_TYPE" -#define MM_TAPE_POSITION_SIZE "TAPE_POSITION_SIZE" -#define MM_TAPE_READ_FORMAT "TAPE_READ_FORMAT" -#define MM_TAPE_WRITE_FORMAT "TAPE_WRITE_FORMAT" -#define MM_TYPE "TYPE" -#define MM_UNIT_SIZE "UNIT_SIZE" -#define MM_USER_DEFINED "USER_DEFINED" - - -/**************************************************************************** -** -** Filter Definitions -*/ - -struct FilterRegistrationDef -{ - LONG classobjectsignature; - BYTE *name; - OBID objectid; - LONG type; - LONG (*releaseroutine)(); - LONG (**functiontable)(); - void *token; -}; - -struct FilterGenericInfoDef -{ - BYTE name[MM_MAX_OBJECT_STRING_LEN]; - LONG type; - LONG status; - OBID applicationid; - OBID ioobjectid; -}; - -#define MM_BASE_FILTER 1 -#define MM_ENHANCED_BASE_FILTER 2 -#define MM_NON_BASE_FILTER 3 - -/**************************************************************************** -** -** Identifier Object Definitions -*/ - -struct IdentifierRegistrationDef -{ - LONG classobjectsignature; - BYTE *name; - LONG type; - LONG (*identifyroutine)( OBID ); - LONG (*labelroutine)( OBID, struct RemovableInfoDef *); - LONG (*unlabelroutine)( OBID ); - LONG registeredhandle; -}; - -struct IdentifierGenericInfoDef -{ - BYTE name[MM_MAX_OBJECT_STRING_LEN]; - LONG type; - LONG status; - LONG registeredhandle; - OBID applicationid; -}; - -#define MM_IDENTIFIER_CAN_LABEL 0x00000100 -#define MM_IDENTIFIER_CAN_UNLABEL 0x00000200 - -/**************************************************************************** -** -** IO Object Definitions -*/ - -struct IOObjectRegistrationDef -{ - LONG classobjectsignature; - BYTE *name; - LONG type; - LONG unitsize; - LONG blocksize; - LONG capacity; - LONG preferredunitsize; - LONG functionmask; - LONG controlmask; - LONG parentcount; - LONG childcount; - LONG specificinfosize; - - struct RemovableInfoDef removableinfo; - - LONG (**functiontable)(); - OBID mmobjectmanagerid; - LONG additionalspace; -}; - -struct IOObjectGenericInfoDef -{ - BYTE name[MM_MAX_OBJECT_STRING_LEN]; - LONG type; - LONG status; - LONG unitsize; - LONG blocksize; - LONG capacity; - LONG preferredunitsize; - LONG functionmask; - LONG controlmask; - LONG parentcount; - LONG siblingcount; - LONG childcount; - LONG specificinfosize; - struct RemovableInfoDef removableinfo; - LONG numberofcurrentreservations; - OBID applicationid; - OBID objectmanagerid; - BYTE guid[MM_ID_LEN]; -}; - -/* IO object status */ - -#define MM_IOOBJECT_BEING_IDENTIFIED 0x00000100 -#define MM_IOOBJECT_RESERVED 0x00000200 -#define MM_IOOBJECT_INFO_COMPLETE 0x00000400 -#define MM_IOOBJECT_FAILURE 0x00000800 - -#define MM_IOOBJECT_WRITABLE 0x00001000 -#define MM_IOOBJECT_WRITE_PROTECTED 0x00002000 -#define MM_IOOBJECT_REMOVABLE 0x00004000 -#define MM_IOOBJECT_ACCEPTS_MAGAZINES 0x00008000 - -#define MM_IOOBJECT_LOADED 0x00010000 -#define MM_IOOBJECT_LOCKED 0x00020000 -#define MM_IOOBJECT_IS_IN_A_MAGAZINE 0x00040000 -#define MM_IOOBJECT_IS_IN_A_CHANGER 0x00080000 - -#define MM_IOOBJECT_IS_OFFLINE 0x00100000 -#define MM_IOOBJECT_READ_HANDICAP 0x00200000 -#define MM_IOOBJECT_REMIRRORING 0x00400000 -#define MM_IOOBJECT_REMIRRORING_BIT 22 -#define MM_IOOBJECT_IS_DIVIDABLE 0x00800000 - -#define MM_IOOBJECT_AUTO_UNREGISTER 0x01000000 -#define MM_IOOBJECT_FROM_NWPA 0x02000000 -#define MM_IOOBJECT_BEING_INVENTORIED 0x04000000 -#define MM_IOOBJECT_BEING_INVENTORIED_BIT 26 -#define MM_IOOBJECT_RAID 0x08000000 - -#define MM_LOGICAL_PARTITION_OBJECT 0x10000000 -#define MM_IOOBJECT_SHARED 0x20000000 -#define MM_IOOBJECT_SHARE_INVALID 0x40000000 - -/* IO object types */ - -#define MM_ADAPTER_OBJECT 0x00000000 -#define MM_CHANGER_OBJECT 0x00000001 -#define MM_DEVICE_OBJECT 0x00000002 -#define MM_MEDIA_OBJECT 0x00000004 -#define MM_PARTITION_OBJECT 0x00000005 -#define MM_SLOT_OBJECT 0x00000006 -#define MM_HOTFIX_OBJECT 0x00000007 -#define MM_MIRROR_OBJECT 0x00000008 -#define MM_PARITY_OBJECT 0x00000009 -#define MM_SEGMENT_OBJECT 0x0000000A -#define MM_VOLUME_OBJECT 0x0000000B -#define MM_CLONE_OBJECT 0x0000000C -#define MM_MAGAZINE_OBJECT 0x0000000E -#define MM_VIRTUAL_DEVICE_OBJECT 0x0000000F -#define MM_PBA_OBJECT 0x00000010 -#define MM_GROUP_OBJECT 0x00000011 -#define MM_FAILOVER_OBJECT 0x00000012 -#define MM_SNAPSHOT_OBJECT 0x00000013 -#define MM_I2O_IOP_OBJECT 0x00001000 -#define MM_LOGICAL_PARTITION_OBJECT 0x10000000 - -/* -** IO Object Added Value Definitions -*/ - -#define MM_AV_UNIT_SPARING 0x00000001 /* Hotfixing */ -#define MM_AV_SPANNED 0x00000002 /* Linearly spanned */ -#define MM_AV_HARD_RAID_0 0x00000010 /* HW Striping */ -#define MM_AV_HARD_RAID_1 0x00000020 /* HW Mirroring */ -#define MM_AV_HARD_RAID_2 0x00000040 /* HW Duplexed Mirroring */ -#define MM_AV_HARD_RAID_3 0x00000080 /* HW Mirroring w/parity */ -#define MM_AV_HARD_RAID_5 0x00000100 /* HW Striping w/parity */ -#define MM_AV_SOFT_RAID_0 0x00000200 /* SW Striping */ -#define MM_AV_SOFT_RAID_1 0x00000400 /* SW Mirroring */ -#define MM_AV_SOFT_RAID_2 0x00000800 /* SW Duplexed Mirroring */ -#define MM_AV_SOFT_RAID_3 0x00001000 /* SW Mirroring w/parity */ -#define MM_AV_SOFT_RAID_5 0x00002000 /* SW Striping w/parity */ -#define MM_AV_FAILOVER 0x00004000 /* Has a standby */ -#define MM_AV_CLUSTER 0x00008000 /* A member of a cluster */ -#define MM_AV_REMOTE 0x00010000 /* Not physically attached */ -#define MM_AV_FILE_SYSTEM 0x00020000 /* Capacity comes from FS */ -#define MM_AV_SNAPSHOT 0x00040000 /* This is a snapshot pool */ - -/**************************************************************************** -** -** IO Subsystem Definitions -*/ -struct IOSubsystemRegistrationDef -{ - LONG classobjectsignature; - BYTE *name; - LONG type; - LONG specificinfosize; - LONG (*controlroutine)( LONG token, - LONG _function, - LONG _p1, - LONG _p2, - LONG _p3, - LONG _bufferlength, - void *_buffer ); - LONG token; -}; - -/* -** Defined Subsystem Types -*/ - -#define MM_SUBSYSTEM_NWPA 0x00000001 -#define MM_SUBSYSTEM_I20 0x00000002 -#define MM_SUBSYSTEM_CIOS 0x00000003 - - -struct IOSubsystemGenericInfoDef -{ - BYTE name[MM_MAX_OBJECT_STRING_LEN]; - LONG type; - LONG status; - LONG specificinfosize; - OBID applicationid; -}; - - -/**************************************************************************** -** -** Notify Definitions -*/ - -struct NotifyRegistrationDef -{ - LONG classobjectsignature; - BYTE *name; - LONG token; - LONG notifytype; - LONG objectclass; - LONG objecttype; - LONG event; - LONG (*routine)( HNDL _mmnotifyhandle, - LONG _token, - OBID _objectid, - LONG _objecttype, - LONG _objectclass, - LONG _event ); -}; - -struct NotifyGenericInfoDef -{ - BYTE name[MM_MAX_OBJECT_STRING_LEN]; - LONG type; - LONG status; - LONG reserved; - LONG objecttype; - LONG objectclass; - LONG event; - OBID applicationid; -}; - -/* notify events */ - -#define MM_NOTIFY_OBJECT_REGISTRATION 0x00000001 -#define MM_NOTIFY_OBJECT_UNREGISTRATION 0x00000002 -#define MM_NOTIFY_OBJECT_ACTIVATED 0x00000004 -#define MM_NOTIFY_OBJECT_DEACTIVATED 0x00000008 -#define MM_NOTIFY_OBJECT_RESERVATION 0x00000010 -#define MM_NOTIFY_OBJECT_UNRESERVATION 0x00000020 -#define MM_NOTIFY_OBJECT_SECONDARY_RESERVATION 0x00000040 -#define MM_NOTIFY_OBJECT_RERESERVATION 0x00000080 -#define MM_NOTIFY_OBJECT_ATTRIBUTE_CHANGE 0x00000100 -#define MM_NOTIFY_OBJECT_FUNCTIONAL 0x00000200 -#define MM_NOTIFY_OBJECT_NONFUNCTIONAL 0x00000400 -#define MM_NOTIFY_OBJECT_MIRROR_PARTITION_ADDED 0x00000800 -#define MM_NOTIFY_SCAN_DEVICES 0x00001000 -#define MM_NOTIFY_FAILOVER_OBJECT_ADDED 0x00002000 -#define MM_NOTIFY_OBJECT_UPDATED 0x00004000 - - -/**************************************************************************** -** -** Object Manager Definitions -*/ - -struct ObjectManagerRegistrationDef -{ - LONG classobjectsignature; - BYTE *name; - LONG reserved; - LONG objecttype; - LONG objectclass; - LONG (*controlroutine)( LONG token, - LONG _function, - LONG _parm1, - LONG _parm2, - LONG _parm3, - LONG _bufferlength, - void *_buffer ); - LONG token; - LONG identifier; -}; - -/* Object Manager identifiers. */ -#define NPA_DEVICE_IDENTIFIER 0x4E504100 /* NPA0 */ -#define RAID_DEVICE_IDENTIFIER 0x52414944 /* RAID */ -#define FAILOVER_DEVICE_IDENTIFIER 0x4641494C /* FAIL */ -#define MIRROR_IDENTIFIER 0x4D524944 /* MRID */ -#define RAID1_MIRROR_IDENTIFIER 0x5244314D /* RD1M */ -#define HOTFIX_IDENTIFIER 0x48464958 /* HFIX */ -#define HOTSPARE_IDENTIFIER 0x484F5453 /* HOTS */ -#define SNAP_IDENTIFIER 0x534E4850 /* SNAP */ - -struct ObjectManagerGenericInfoDef -{ - BYTE name[MM_MAX_OBJECT_STRING_LEN]; - LONG status; - LONG objecttype; - LONG objectclass; - OBID applicationid; - LONG identifier; -}; - -/**************************************************************************** -** -** /Reservation Definitions -*/ - -struct ReservationGenericInfoDef -{ - OBID objectid; - OBID applicationid; - LONG type; -}; - -struct SharedReserveRequestDef -{ - OBID applicationid; - OBID objectid; - LONG type; -}; - -/* Reservation status */ - -#define MM_PRIMARY_RESERVATION 0x00000100 -#define MM_SECONDARY_RESERVATION 0x00000200 - -/* Reservation Types */ - -#define MM_IO_MODE 0x00000001 -#define MM_CONTROL_MODE 0x00000002 - -/* Reservation Type Modifiers */ - -#define MM_SHARED_READ_RESERVE 0x00010000 -#define MM_SHARED_WRITE_RESERVE 0x00020000 -#define MM_SHARED_PRIMARY_RESERVE 0x00040000 -#define MM_RERESERVE 0x00080000 -#ifndef MMSDK -#define MM_PRIVILEGED_RESERVE 0x00100000 -#endif - - -/**************************************************************************** -** -** Miscellaneous Definitions -** -*/ - -/* Alert reasons */ - -#define MM_ALERT_HOTFIX_ERROR 0x00000000 -#define MM_ALERT_DRIVER_UNLOADED 0x00000001 -#define MM_ALERT_DEVICE_FAILURE 0x00000002 -#define MM_ALERT_PROGRAM_CONTROL 0x00000003 -#define MM_ALERT_MEDIA_DISMOUNT 0x00000004 -#define MM_ALERT_MEDIA_EJECT 0x00000005 -//#define MM_ALERT_SERVER_DOWN 0x00000006 -//#define MM_ALERT_SERVER_FAILURE 0x00000007 -#define MM_ALERT_MEDIA_LOAD 0x00000008 -#define MM_ALERT_MEDIA_MOUNT 0x00000009 -#define MM_ALERT_DRIVER_LOAD 0x0000000A -#define MM_ALERT_LOST_SOFTWARE_FAULT_TOLERANCE 0x0000000B -#define MM_ALERT_INTERNAL_OBJECT_DELETE 0x0000000C -#define MM_ALERT_MAGAZINE_LOAD 0x0000000D -#define MM_ALERT_MAGAZINE_UNLOAD 0x0000000E -//#define MM_ALERT_DEVICE_BEING_REMOVED 0x0000000F -//#define MM_ALERT_CHECK_DEVICE 0x00000010 -#define MM_ALERT_CONFIGURATION_CHANGE 0x00000011 -//#define MM_ALERT_APPLICATION_UNREGISTER 0x00000012 -//#define MM_ALERT_DAI_EMMULATION 0x00000013 -//#define MM_ALERT_LOST_HARDWARE_FAULT_TOLERANCE 0x00000014 -#define MM_ALERT_INTERNAL_OBJECT_CREATE 0x00000015 -#define MM_ALERT_OBJECT_MANAGER_REMOVED 0x00000016 -//#define MM_ALERT_DEVICE_GOING_TO_BE_DEACTIVATED 0x00000017 -#define MM_ALERT_DEVICE_END_OF_MEDIA 0x00000018 -#define MM_ALERT_MEDIA_INSERTED 0x00000019 -#define MM_ALERT_UNKNOWN_DEVICE_ALERT 0x0000001A -#define MM_ALERT_UNKNOWN_ADAPTER_ALERT 0x0000001B -#define MM_ALERT_BASE_FILTER_REMOVED 0x0000001C -#define MM_ALERT_MEDIA_CHANGED_DURING_IO 0x00000020 -#define MM_ALERT_APPLICATION_CLEANUP 0x00000021 -#define MM_ALERT_DRIVER_BEING_UNLOADED 0x00000022 -#define MM_ALERT_DRIVER_INSTANCE_UNLOADED 0x00000023 -#define MM_ALERT_DRIVER_INSTANCE_BEING_UNLOADED 0x00000024 -#define MM_CHECK_DRIVER_BEING_UNLOADED 0x00000025 // MM_CheckDevice() -#define MM_CHECK_DRIVER_INSTANCE_BEING_UNLOADED 0x00000026 // MM_CheckDevice() -#define MM_ALERT_BASE_FILTER_BEING_REMOVED 0x00000027 -#define MM_ASYNCHRONOUS_PARTITON_TABLE_UPDATE 0x00000028 -#define MM_ALERT_SHARED_STATUS_CHANGED 0x00000029 -#define MM_ALERT_DEVICE_CHANGED 0x0000002A -#define MM_ALERT_HANDICAP_STATUS_CHANGED 0x0000002B -#define MM_ALERT_PARTITION_DELETE 0x0000002C -#define MM_ALERT_POOL_STATE_CHANGE 0x0000002D - - -/* Alert types */ - -#define MM_ALERT_MESSAGE 0x00000001 -#define MM_ALERT_ACTIVATE 0x00000002 -#define MM_ALERT_DEACTIVATE 0x00000003 -#define MM_ALERT_UNREGISTER 0x00000004 -#define MM_ALERT_PARENT_MESSAGE 0x00000005 -#define MM_ALERT_PARENT_ACTIVATE 0x00000006 -#define MM_ALERT_PARENT_DEACTIVATE 0x00000007 -#define MM_ALERT_PARENT_UNREGISTER 0x00000008 -#define MM_ALERT_SHARED_RESERVE_REQUEST 0x00000009 -#define MM_ALERT_SHARED_RESERVE_LOST 0x0000000A -#define MM_ALERT_CHECK 0x0000000B -#define MM_ALERT_DELETE 0x0000000C -#define MM_ALERT_PARENT_DELETE 0x0000000D - -/* Console Definitions */ - -#define HJ_LOAD_MESSAGE 0x00000000 -#define HJ_UNLOAD_MESSAGE 0x00000001 -#define HJ_ACK_MESSAGE 0x00000002 -#define HJ_NACK_MESSAGE 0x00000003 -#define HJ_ERROR 0x00000004 -//application function definitions -#define HJ_LOAD_APPLICATION_FUNCTION 0x00000010 -#define HJ_UNLOAD_APPLICATION_FUNCTION 0x00000011 - -/* Media Identifacation Types */ - -#define MM_UNIDENTIFIED_MEDIA 0x00000001 -#define MM_HIGH_SIERRA_CDROM_MEDIA 0x00000002 -#define MM_ISO_CDROM_MEDIA 0x00000003 -#define MM_MAC_CDROM_MEDIA 0x00000004 -#define MM_NETWARE_FILE_SYSTEM_MEDIA 0x00000005 -#define MM_INTERNAL_IDENTIFY_TYPE 0x00000007 -#define MM_MEDIA_TYPE_SMS 0x00000008 -#define MM_MEDIA_TYPE_SIDF 0x00000009 -#define MM_MEDIA_TYPE_BLANK 0x0000000A -#define MM_MEDIA_TYPE_ERROR 0x0000000B -#define MM_IBM_PARTITIONED_MEDIA 0x0000000C - -/* Media Types (as defined by the SCSI spec.) */ - -#define MM_DIRECT_ACCESS_DEVICE 0x00000000 -#define MM_SEQUENTIAL_ACCESS_DEVICE 0x00000001 -#define MM_PRINTER_DEVICE 0x00000002 -#define MM_PROCESSOR_DEVICE 0x00000003 -#define MM_WORM_DEVICE 0x00000004 -#define MM_CD_ROM_DEVICE 0x00000005 -#define MM_SCANNER_DEVICE 0x00000006 -#define MM_MO_DEVICE 0x00000007 -#define MM_MEDIA_CHANGER_DEVICE 0x00000008 -#define MM_COMMUNICATION_DEVICE 0x00000009 -#define MM_FLOPPY_DEVICE 0x0000001E - - -/* -** Media Manager Completion Codes -*/ - -#define MM_OK 0x00000000 -#define MM_INVALID_OBJECT 0x00000001 -#define MM_MESSAGE_POSTPONED 0x00000002 // NWPA -#define MM_ABORTED_UNCLEAN 0x00000003 // NWPA -#define MM_MEMORY_ALLOCATION_ERROR 0x00000004 -#define MM_INVALID_MODE 0x00000005 -#define MM_RESERVATION_CONFLICT 0x00000006 -#define MM_OBJECT_NOT_FOUND 0x00000008 -#define MM_ATTRIBUTE_NOT_SETTABLE 0x00000009 -#define MM_ABORTED_CLEAN 0x0000000A // NWPA -#define MM_NOT_ABORTED 0x0000000B - -#define MM_CORRECTED_MEDIA_ERROR 0x00000010 // NWPA -#define MM_MEDIA_ERROR 0x00000011 // NWPA -#define MM_DEVICE_ERROR 0x00000012 // NWPA -#define MM_ADAPTER_ERROR 0x00000013 // NWPA -#define MM_FUNCTION_NOT_SUPPORTED_BY_DEVICE 0x00000014 // NWPA -#define MM_FUNCTION_NOT_SUPPORTED_BY_DRIVER 0x00000015 // NWPA -#define MM_PARAMETER_ERROR 0x00000016 // NWPA -#define MM_MEDIA_NOT_PRESENT 0x00000017 // NWPA -#define MM_MEDIA_CHANGED 0x00000018 // NWPA -#define MM_PREVIOUSLY_WRITTEN 0x00000019 // NWPA -#define MM_MEDIA_NOT_FORMATED 0x0000001A // NWPA -#define MM_BLANK_MEDIA 0x0000001B // NWPA -#define MM_END_OF_MEDIA 0x0000001C // NWPA -#define MM_FILE_MARK_DETECTED 0x0000001D // NWPA -#define MM_SET_MARK_DETECTED 0x0000001E // NWPA -#define MM_WRITE_PROTECTED 0x0000001F // NWPA -#define MM_OK_EARLY_WARNING 0x00000020 // NWPA -#define MM_BEGINNING_OF_MEDIA 0x00000021 // NWPA -#define MM_MEDIA_NOT_FOUND 0x00000022 // NWPA -#define MM_MEDIA_NOT_REMOVED 0x00000023 // NWPA -#define MM_UNKNOWN_COMPLETION 0x00000024 // NWPA -#define MM_FUNCTION_DATA_MISSING 0x00000025 // NWPA -#define MM_HOTFIX_ERROR 0x00000026 // NWPA -#define MM_HOTFIX_UPDATE_ERROR 0x00000027 // NWPA -#define MM_IO_ERROR 0x00000028 // NWPA -#define MM_CHANGER_SOURCE_EMPTY 0x00000029 // NWPA -#define MM_CHANGER_DEST_FULL 0x0000002A // NWPA -#define MM_CHANGER_JAMMED 0x0000002B // NWPA -#define MM_MAGAZINE_NOT_PRESENT 0x0000002D // NWPA -#define MM_MAGAZINE_SOURCE_EMPTY 0x0000002E // NWPA -#define MM_MAGAZINE_DEST_FULL 0x0000002F // NWPA -#define MM_MAGAZINE_JAMMED 0x00000030 // NWPA -#define MM_ABORT_CAUSED_BY_PRIOR_ERROR 0x00000031 // NWPA -#define MM_CHANGER_ERROR 0x00000032 // NWPA -#define MM_MAGAZINE_ERROR 0x00000033 // NWPA -#define MM_BLOCK_SIZE_ERROR 0x00000034 // NWPA -#define MM_DECOMPRESSION_ALOGRITHM_MISMATCH 0x00000035 // NWPA -#define MM_HJ_ERROR 0x00000036 - -/* -** The 0X01xx messages replace the original initial message -** completion codes of an earlier Media Manager -*/ - -#define MM_DATA_MISSING 0x00000101 -#define MM_INVALID_APPLICATION 0x00000102 -#define MM_INVALID_RESOURCETAG 0x00000103 -#define MM_OBJECT_NOT_ACTIVE 0x00000105 -#define MM_FUNCTION_NOT_SUPPORTED 0x00000107 -#define MM_DATABASE_FULL 0x0000010B -#define MM_TRADITIONAL_VOLUME 0x00000165 -#define MM_NSS_POOL 0x00000169 -#define MM_SBD_PARTITION 0x000001AD - -/* -** Additional Media Manager completion Codes -*/ - -#define MM_DATABASE_ERROR 0x00000200 -#define MM_INVALID_ATTRIBUTE 0x00000201 -#define MM_INVALID_RESERVATION_HANDLE 0x00000202 -#define MM_ATTRIBUTE_NAME_COLLISION 0x00000203 -#define MM_ATTRIBUTE_ID_COLLISION 0x00000204 -#define MM_MEDIA_NOT_LOADED 0x00000205 -#define MM_INVALID_OBJECT_MANAGER 0x00000206 -#define MM_INVALID_CLASS 0x00000207 -#define MM_CLASS_COLLISSION 0x00000208 -#define MM_FAILED_TO_UNREGISTER 0x00000209 -#define MM_INVALID_HANDLE 0x0000020A -#define MM_BUFFER_TOO_SMALL 0x0000020B -#define MM_INVALID_LOCK 0x0000020C -#define MM_INVALID_PARTITION 0x0000020D -#define MM_INVALID_PARTITION_TABLE 0x0000020E -#define MM_PARTITION_TABLE_FULL 0x0000020F -#define MM_NO_PARTITION_TABLE 0x00000210 -#define MM_INCONSISTANT_GEOMETRY 0x00000211 -#define MM_MEDIA_NOT_IDENTIFIED 0x00000212 -#define MM_INSYNC_CLONE_OBJECT 0x00000213 -#define MM_INVALID_ATTRIBUTE_TYPE 0x00000214 -#define MM_SHARED_RESERVE_DENIED 0x00000215 -#define MM_QUESTIONABLE_UNLOAD 0x00000216 -#define MM_INCOMPLETE_DATA_PATH 0x00000217 -#ifndef MMSDK -#define MM_INVALID_APPLICATION_KEY 0x00000218 -#endif -#define MM_SHARED_RESERVE_GRANTED 0x00000219 -#define MM_HOTFIX_TABLE_FULL 0x0000021A -#define MM_NOT_OWNER 0x0000021B -#define MM_MAX_RAID_ELEMENTS_EXCEEDED 0x0000021C -#define MM_RAID_RESTRIPING 0x0000021D -#define MM_INVALID_GUID 0x0000021E -#define MM_MIRROR_CAPACITY_MISMATCH 0x0000021F -#define MM_MIRROR_NOT_IN_SYNC 0x00000220 -#define MM_MIRROR_ALREADY_CHECKING 0x00000221 -#define MM_MIRROR_NOT_CHECKING 0x00000222 -#define MM_DEVICE_IS_FULL 0x00000223 -#define MM_BLOCK_NOT_MAPPED_IN 0x00000224 -#define MM_BLOCK_NOT_MAPPED_NOT_SET 0x00000225 -#define MM_BLOCK_TRANSFER_NOT_SET 0x00000226 -#define MM_BLOCK_TRANSFER_SET 0x00000227 -#define MM_NO_BLOCKS_AVAILABLE 0x00000228 -#define MM_NEW_BLOCK 0x00000229 -#define MM_UNSUPPORTED_VERSION 0x0000022A -#define MM_INCORRECT_OBJECT_TYPE 0x0000022B -#define MM_POOL_NOT_ACTIVE 0x0000022C -#define MM_SHARED_OBJECT_ERROR 0x0000022D -#define MM_RAID_ELEMENT_MISSING 0x0000022E -#define MM_NOT_REMIRROR_OWNER 0x0000022F -#define MM_SBD_PARTITION_NOT_SHARED 0x00000230 -#define MM_POLLED_INTERRUPT_TIMEOUT 0x00000231 -#define MM_TRY_NEXT_OBJECT 0x00000232 -#define MM_OVERLAPPING_PARTITIONS 0x00000233 -#define MM_RAID_NEEDS_RESTRIPE 0x00000234 -#define MM_RAID_TOO_BIG 0x00000235 -#define MM_FAILURE 0xFFFFFFFF - -/* -** The following completion codes are not concidered errors -*/ - -#define MM_ALREADY_RESERVED 0x00010000 - - -/* Media Manager IO Message Functions */ - -#define MM_FORMAT_MEDIA 0x00000000 -#define MM_TAPE_CONTROL 0x00000001 -#define MM_MEDIA_DETECT 0x00000002 -#define MM_ACTIVATE_FUNCTIONS 0x00000003 -#define MM_MOUNT_FUNCTIONS 0x00000004 -#define MM_SELECT_FUNCTIONS 0x00000005 -//#define MM_INSERT_FUNCTIONS 0x00000006 //formerly MM_LOAD_FUNCTIONS NO LONGER SUPPORTED -#define MM_LOCK_FUNCTIONS 0x00000007 -#define MM_MOVE_FUNCTIONS 0x00000008 -#define MM_LABEL_FUNCTIONS 0x00000009 -#define MM_SCAN_FUNCTIONS 0x0000000A -#define MM_LOAD_FUNCTIONS 0x0000000D -#define MM_INVENTORY_FUNCTIONS 0x0000000E -#define MM_READ_GUID 0x0000000F -#define MM_CHANGE_PATH 0x00000010 - -#define MM_RANDOM_READ 0x00000020 -#define MM_RANDOM_WRITE 0x00000021 -#define MM_RANDOM_WRITE_ONCE 0x00000022 -#define MM_SEQUENTIAL_READ 0x00000023 -#define MM_SEQUENTIAL_WRITE 0x00000024 -#define MM_RESET_END_OF_TAPE 0x00000025 -#define MM_SINGLE_FILE_MARKS 0x00000026 -#define MM_MULTIPLE_FILE_MARKS 0x00000027 -#define MM_SINGLE_SET_MARKS 0x00000028 -#define MM_MULTIPLE_SET_MARKS 0x00000029 -#define MM_SPACE_DATA_BLOCKS 0x0000002A -#define MM_LOCATE_DATA_BLOCKS 0x0000002B -#define MM_PARTITION_SUPPORT 0x0000002C -#define MM_SEQUENTIAL_SUPPORT 0x0000002D - -/* -** IO Request Priorities -** -** Normal priority is default. -*/ - -#define MM_LOW_PRIORITY 0x00010000 /* Elevator */ -#define MM_HIGH_PRIORITY 0x00020000 /* Elevator */ -#define MM_TOP_PRIORITY 0x00030000 /* Elevator */ -#define MM_NO_BLOCKING_IO 0x00040000 /* Coredumps */ -#define MM_RAW_PARTITION_IO 0x00080000 -#define MM_ACCELERATED 0x00100000 /* B4 elevator */ -#define MM_RETURN_RAW_COMPLETION 0x00200000 /* No Hotfix */ -#define MM_USING_PERFERRED_UNIT_SIZE 0x00400000 /* No sector xlation */ -#define MM_SCATTER_GATHER_REQUEST 0x00800000 /* NWPA */ -#define MM_HARDWARE_READ_AFTER_WRITE 0x01000000 /* NWPA */ -#define MM_SNAPSHOT_WRITE_THRU 0x02000000 /* SNAPSHOT write thru */ -#define MM_P0_MESSAGE 0x10000000 /* Processor 0 callback */ -#define MM_BLOCKING_CALLBACK 0x20000000 /* Callback can block */ -#define MM_AS_IS 0x40000000 /* NWPA */ -#define MM_WRITE_BACK 0x80000000 /* NWPA */ -#define SNAPSHOT_WRITE_MASK (0xFFFF \ - | MM_RAW_PARTITION_IO \ - | MM_SNAPSHOT_WRITE_THRU) - -struct MemoryConfiguration -{ - LONG MemoryAddress; - WORD MemoryRangeParagraphs; -}; - -struct IO_ConfigurationStructure -{ - LONG reserved1; - WORD CSharingFlags; - WORD CSlot; - WORD CIOPortsAndRanges[4]; - struct MemoryConfiguration CMemoryDecodeAndLength[2]; - BYTE CIntLine[2]; - BYTE CDMALine[2]; - - LONG reserved2[7]; - BYTE reserved[2]; - LONG CLinearMemory[2]; - WORD CChannelNumber; - LONG CBusTag; - WORD CIOConfigVersion; -}; - -struct AdapterSpecificInfoDef -{ - LONG status; - OBID subsystemid; - LONG assigneddriverid; - LONG adapternumber; - struct IO_ConfigurationStructure configinfo; - BYTE drivername[MM_MAX_OBJECT_STRING_LEN]; - BYTE systemname[MM_MAX_OBJECT_STRING_LEN]; -}; - -struct DeviceSpecificInfoDef -{ - LONG status; - OBID subsystemid; - BYTE targetnumber; - BYTE unitnumber; - BYTE cardnumber; - BYTE accessflags; - LONG devicetype; - - LONG blocksize; - LONG unitsize; - BYTE heads; - BYTE sectors; - WORD cylinders; - LONG capacity; - - OBID mmadapterid; - OBID mmmediaid; - BYTE rawname[MM_MAX_OBJECT_STRING_LEN]; -}; - -struct RaidDeviceSpecificInfoDef -{ - struct DeviceSpecificInfoDef deviceInfo; - LONG raidType; - LONG stripeSize; - LONG elementSize; - LONG elementCount; - LONG restripeFlag; -}; - -struct ChangerSpecificInfoDef -{ - LONG status; - LONG numberofdevices; - LONG numberofslots; - LONG numberofmailslots; - LONG reserved[8]; - LONG slotmappingtable[1]; -}; - - -struct PartitionSpecificInfoDef -{ - LONG status; - LONG partitionertype; - LONG partitiontype; - LONG partitionoffset; - LONG partitionsize; - BYTE bootflag; - BYTE partitionindex; - BYTE reservedbyte[2]; - LONG reserved; - BYTE label[MM_MAX_OBJECT_STRING_LEN]; -}; - -/* -** Partition Status -*/ - -#define MM_PARTITION_LABELED 0x01 -/* -** Partitioner Types -*/ - -#define MM_INTERNAL_PARTITIONER 0x01 -#define MM_EXTERNAL_PARTITIONER 0x02 - -/* -** Partition Types -*/ - -#define NETWARE_FREE_PARTITION ( 0 | (MM_INTERNAL_PARTITIONER << 8)) -#define NETWARE_HOTFIX_PARTITION (0x062 | (MM_INTERNAL_PARTITIONER << 8)) -#define NETWARE_286_PARTITION (0x064 | (MM_INTERNAL_PARTITIONER << 8)) -#define NETWARE_386_PARTITION (0x065 | (MM_INTERNAL_PARTITIONER << 8)) -#define NETWARE_SMS_PARTITION (0x066 | (MM_INTERNAL_PARTITIONER << 8)) -#define NETWARE_NSS_PARTITION (0x069 | (MM_INTERNAL_PARTITIONER << 8)) -#define NETWARE_VDEVICE_PARTITION (0x0CF | (MM_INTERNAL_PARTITIONER << 8)) -#define ORION_SBD_PARTITION (0x0AD | (MM_INTERNAL_PARTITIONER << 8)) -#define REMOTE_STORAGE_PARTITION (0x0AE | (MM_INTERNAL_PARTITIONER << 8)) -#define NOVELL_ISCSI_PARTITION (0x07F | (MM_INTERNAL_PARTITIONER << 8)) - -/* -** Partition Upgrade flags -*/ - -#define PARTITION_UPGRADE_CHECK 0x00 -#define PARTITION_UPGRADE_COMPLETE 0x01 -#define PARTITION_UPGRADE_NONSHARED 0x02 - -/* -** Partition Event Data Structures -*/ - -#define PARTITION_CREATE_ENTER_EVENT "MM.CreatePartition.Enter" -#define PARTITION_CREATE_EXIT_EVENT "MM.CreatePartition.Exit" -#define PARTITION_DELETE_ENTER_EVENT "MM.DeletePartition.Enter" -#define PARTITION_DELETE_EXIT_EVENT "MM.DeletePartition.Exit" -#define PARTITION_EXPAND_ENTER_EVENT "MM.ExpandPartition.Enter" -#define PARTITION_EXPAND_EXIT_EVENT "MM.ExpandPartition.Exit" -#define PARTITION_INIT_ENTER_EVENT "MM.InitializeDisk.Enter" -#define PARTITION_INIT_EXIT_EVENT "MM.InitializeDisk.Exit" - -/* NOTE: PARTITION_EXPAND_ENTER_EVENT uses the PartitionDeleteEnterDef. - PARTITION_EXPAND_EXIT_EVENT uses the PartitionCreateExitDef */ - -struct PartitionCreateEnterDef -{ - LONG enterExitID; - OBID deviceID; - LONG sizeInSectors; - LONG partitiontype; - LONG shared; /* shared status of the device. */ -}; - -struct PartitionCreateExitDef -{ - LONG enterExitID; - LONG enterRetStatus; - LONG opRetCode; - LONG partitionID; - LONG shared; /* shared status of the partition. */ -}; - -struct PartitionDeleteEnterDef -{ - LONG enterExitID; - LONG partitionID; - LONG shared; /* shared status of the partition. */ -}; - -struct PartitionDeleteExitDef -{ - LONG enterExitID; - LONG enterRetStatus; - LONG opRetCode; - LONG shared; /* shared status of the partition. */ -}; - -struct InitializeDiskEnterDef -{ - LONG enterExitID; - LONG deviceID; - LONG shared; /* shared status of the partition. */ -}; - -struct InitializeDiskExitDef -{ - LONG enterExitID; - LONG enterRetStatus; - LONG opRetCode; - LONG shared; /* shared status of the partition. */ -}; - - -struct HotfixSpecificInfoDef -{ - LONG hotfixoffset; - LONG hotfixidentifier; - LONG numberoftotalblocks; - LONG numberofusedblocks; - - LONG numberofavailableblocks; - LONG numberofsystemblocks; - LONG status; -}; - -struct MirrorSpecificInfoDef -{ - LONG status; - LONG mirrorcount; - LONG remirrorpercentage; - LONG mirroridentifier; - OBID mirrormembers[MM_MAX_MIRROR_MEMBERS]; - BYTE memberpercentremirrored[MM_MAX_MIRROR_MEMBERS]; -}; - -/* -** Mirror Object Status -*/ - -#define MM_MIRROR_GROUP_IN_SYNC 0x0001 -#define MM_MIRROR_ALL_PRESENT 0x0002 -#define MM_MIRROR_OPERATIONAL 0x0004 -#define MM_MIRROR_PARTIAL_SYNC 0x0010 -#define MM_MIRROR_VERIFYING 0x0020 -#define MM_MIRROR_REMIRRORING 0x0040 -#define MM_MIRROR_OBJECT_ORHANED 0x0080 -#define MM_MIRROR_WAITING 0x0100 -#define MM_MIRROR_OWNER 0x0200 - -/* This structure attaches the mirror guid, -** and is available only in RAID1 mirroring. */ -struct Raid1SpecificInfoDef -{ - struct MirrorSpecificInfoDef mirrorinfo; - LONG guid[4]; -}; - -struct MagazineSpecificInfoDef -{ - LONG status; - BYTE name[MM_MAX_OBJECT_STRING_LEN]; //??? - LONG numberofslots; - OBID slotmappingtable[1]; -}; - -struct GroupSpecificInfoDef -{ - QUAD capacity; - LONG elementcount; - LONG status; - LONG type; -}; - -struct SnapshotSpecificInfoDef -{ - BYTE name[64]; - OBID poolid; - OBID snappoolid; - LONG timestamp; - LONG attributes; - QUAD poolsize; /* in bytes */ - QUAD allocatedsize; /* in bytes */ -}; - -/* Snapshot attributes */ -#define SNAPSHOT_ACTIVATED 0x00000001 - -//#error Do these elements need to be type OBID? - -struct InsertRequestDef -{ - LONG deviceid; - LONG mailslot; - LONG mediaid; - LONG mediacount; -}; - -struct MediaRequestDef -{ - OBID devicenumber; - OBID mailslot; - OBID medianumber; - LONG mediacount; -}; - -struct MMIOStats -{ - LONG readbytecount[32]; - LONG readrequestcount[32]; - LONG writebytecount[32]; - LONG writerequestcount[32]; - LONG laststatstime; -}; - -struct MMStatsDefv0 -{ - LONG deltatime; - LONG readbytecount; - LONG readrequestcount; - LONG writebytecount; - LONG writerequestcount; - LONG percpurequests[32]; /* MAXIMUM_NUMBER_OF_PROCESSORS */ - LONG percpusurrogaterequests[32]; -}; - -struct SectorMappingElementDef -{ - OBID deviceID; - LONG startingsector; - LONG numberOfSectors; -}; - -struct SectorMappingDef -{ - LONG elementsAllocated; - LONG elementsReturned; - QUAD mapSector; - LONG sectorCount; - struct SectorMappingElementDef element[1]; -}; - - -/**************************************************************************** -** -** Public APIs -*/ - -/*extern LONG HJ_MediaRequest( - struct InsertRequestDef *_minfo, - LONG _requestcode, - OBID *_uniqueid ); -*/ -extern LONG MM_HJRequestAck(struct InsertRequestDef *_insertrequestinfo, - LONG *_ackcode, - void *_uniqueID); - -/*extern LONG HJ_MediaRequestAck( - struct InsertRequestDef *_minfo, - LONG _ackcode, - OBID _uniqueid ); -*/ -extern LONG MM_AbortRequest( HNDL _messagehandle ); - -#ifndef MMSDK -extern LONG MM_AllocatePerCPUVector( - void **_vector, - struct ResourceTagStructure *_resourcetag ); -#endif - -extern LONG MM_FreePerCPUVector( void *_vector ); - -extern LONG MM_CheckForPendingAborts( void ); - -extern LONG MM_CreateRemovableObject( -// HNDL *_mmmediahandle, - OBID *_mmmediaid, -// OBID _objectid, - OBID _parentobjectid, - struct CreateRemovableInfoDef *_removableinfo, -// OBID _mediaobjectmanagerid, - LONG _mmioobjecttype, - HNDL _mmapplicationhandle, -#ifdef MMSDK - LONG _resourcetag ); -#else - struct ResourceTagStructure *_resourcetag ); -#endif - -extern LONG MM_DeleteRemovableObject( OBID _mmobjectid ); - -extern LONG MM_FindObjectType( - LONG _class, - LONG _type, - OBID *_objectid ); - -extern LONG MM_GetObjectAttribute( - OBID _objectid, - LONG _attributeid, - LONG _infolength, - void *_info ); - -extern LONG MM_ObjectBlockingIO( - LONG *_returnparameter, - HNDL _mmreservationhandle, - LONG _function, - LONG _parameter0, - LONG _parameter1, - LONG _parameter2, - LONG _bufferlength, - void *_buffer ); - -extern LONG MM_ObjectIO( - HNDL *_messagehandle, - HNDL _mmreservationhandle, - LONG _function, - LONG _parameter0, - LONG _parameter1, - LONG _parameter2, - LONG _bufferlength, - void *_buffer, - LONG _requesttoken, - void (*_callbackroutine)() ); - -extern LONG MM_ObjectNonBlockingIO( - LONG *_returnparameter, - OBID _objectid, - LONG _function, - LONG _parm1, - LONG _parm2, - LONG _parm3, - LONG _bufferlength, - void *_buffer); - -extern LONG MM_ObjectControl( - OBID _objectid, - LONG _function, - LONG _parm1, - LONG _parm2, - LONG _parm3, - LONG _bufferlength, - void *_buffer ); - -extern LONG MM_RegisterObject( - HNDL *_mmobjecthandle, - LONG _class, - void *_objectinfo, - HNDL _mmapplicationhandle, -#ifdef MMSDK - LONG _resourcetag ); -#else - struct ResourceTagStructure *_resourcetag ); -#endif - -extern LONG MM_ReleaseIOObject( HNDL _mmreservehandle ); - -extern LONG MM_ReleaseUnloadSemaphore( LONG _currentinstance ); - -extern LONG MM_RenameObject( - OBID _objectid, - BYTE *_name ); - -extern LONG MM_ReserveIOObject( - HNDL *_mmreservationhandle, - OBID _objectid, - LONG _iomode, - LONG _alerttoken, - LONG (*_alertroutine)( HNDL reservationhandle, - LONG token, - LONG alerttype, - LONG alertreason ), - HNDL _applicationhandle ); - -extern LONG MM_ReturnIOStatistics( - OBID applicationHandle, - struct MMStatsDefv0 *_info, - LONG version ); - -extern LONG MM_ReturnMediaManagerStatistics( - struct MMStatsDefv0 *_info, - LONG version ); - -extern LONG MM_ReturnNextObjectAttribute( - OBID _objectid, - OBID *_nextattributeobjectid, - LONG *_attributeid ); - -extern LONG MM_ReturnObjectGenericInfo( - OBID _objectid, - LONG _infolength, - void *_info ); - -extern LONG MM_ReturnObjectHandle( - HNDL *_handle, - OBID _objectid, - HNDL _applicationhandle ); - -extern LONG MM_ReturnObjectMappingInfo( - OBID _objectid, - LONG _class, - LONG _infolength, - void *_info ); - -extern LONG MM_ReturnObjectOBID( - OBID *_objectobid, - HNDL _objecthandle ); - -extern LONG MM_ReturnObjectProgenitor( - OBID _progeny, - LONG _progenitortype, - OBID *_progenitor ); - -extern LONG MM_ReturnObjectSpecificInfo( - OBID _objectid, - LONG _infolength, - void *_info ); - -extern LONG MM_ReturnPhysicalSectorMapping( - OBID _objectid, - struct SectorMappingDef *_sectorMap); - -extern void MM_ScanForNewDevices( void ); - -extern LONG MM_ScanForNewPartitions( OBID _deviceID ); - -extern LONG MM_SetObjectAttribute( - OBID _objectid, - LONG _attributeid, - LONG _infolength, - void *_info ); - -extern LONG MM_SetUnloadSemaphore( LONG *_currentinstance ); - -extern LONG MM_SpecialObjectBlockingIO( - LONG *_returnparameter, - OBID _objectid, - LONG _function, - LONG _parameter0, - LONG _parameter1, - LONG _parameter2, - LONG _bufferlength, - void *_buffer); - -extern LONG MM_UnregisterObject( HNDL _mmobjecthandle, LONG _reason ); - -extern LONG MM_ValidateHandle( HNDL _handle ); - -extern LONG MM_ValidateID( OBID _id ); - -extern LONG MM_CreateRaid( - LONG type, - OBID partitionID, - LONG stripeSize, - BYTE *name, - HNDL *newRaidHNDL); - -extern LONG MM_CreateRaidWithNewPartition( - LONG partitionType, - LONG raidType, - OBID *freePartitionID, - LONG segmentSize, - LONG stripeSize, - BYTE *name, - HNDL *newRaidHNDL); - -extern LONG MM_DeleteRaid(OBID raidID); - -extern LONG MM_ExpandRaid( - OBID raidID, - OBID partitionID); - -extern LONG MM_ExpandRaidWithNewPartition( - OBID raidID, - OBID *freePartitionID); - -extern LONG MM_ExpandGroup( - OBID groupid, - OBID elementid, - BYTE *name, - BYTE *guid, - OBID *newgroupid); - -extern LONG MM_DeleteGroup( OBID groupid); - -extern LONG MM_ReturnGroupElementInfo( - OBID groupid, - OBID elementid, - QUAD *offset, - QUAD *size); - -extern LONG MM_CreateSnapshot( - BYTE *pool, - BYTE *snappool, - BYTE *snapname, - HNDL *snapID); - -extern LONG MM_DeleteSnapshot( BYTE *snapname ); -extern LONG MM_ActivateSnapshot( BYTE *snapname ); -extern LONG MM_DeactivateSnapshot( BYTE *snapname ); -extern LONG MM_RenameSnapshot( - BYTE *snapname, - BYTE *newname ); - - -extern LONG MM_UpgradePartitions(LONG flag); - - -/***************************************************************** -** Defines for the Volume Functions ** -*****************************************************************/ - -//#define MM_VOLUME_INIT_FILE_SYSTEM 0x00 //obsolete -#define MM_VOLUME_RETURN_CONFIG_DIALOG 0x01 -#define MM_VOLUME_CREATE 0x02 -#define MM_VOLUME_DELETE 0x03 -#define MM_VOLUME_MOUNT 0x04 -#define MM_VOLUME_DISMOUNT 0x05 -#define MM_VOLUME_EXPAND 0x06 -#define MM_VOLUME_NAMES 0x07 -#define MM_VOLUME_RETURN_TOKEN 0x08 -#define MM_VOLUME_SCAN 0x09 -#define MM_VOLUME_GET_INFO 0x0A -#define MM_VOLUME_CHANGE_INFO 0x0B -#define MM_VOLUME_MOUNT_CHECK 0x0C -#define MM_VOLUME_RETURN_LIMITS 0x0D -#define MM_VOLUME_RETURN_MAPPING 0x0E -#define MM_VOLUME_RETURN_PARTITION_MAPPING 0x0F -//do not use 0x10 - same as HJ_LOAD_APPLICATION_FUNCTION -//do not use 0x11 - same as HJ_UNLOAD_APPLICATION_FUNCTION -#define MM_VOLUME_TO_POOL_MAPPING 0x12 -#define MM_VOLUME_VALIDATE_NAME 0x13 -#define MM_POOL_LOAD 0x20 -#define MM_POOL_CREATE 0x22 -#define MM_POOL_DELETE 0x23 -#define MM_POOL_ACTIVATE 0x24 -#define MM_POOL_DEACTIVATE 0x25 -#define MM_POOL_EXPAND 0x26 -#define MM_POOL_NAMES 0x27 -#define MM_POOL_GET_INFO 0x2A -#define MM_POOL_CHANGE_INFO 0x2B -#define MM_POOL_ACTIVE_CHECK 0x2C -#define MM_POOL_RETURN_MAPPING 0x2E -#define MM_POOL_RETURN_PARTITION_MAPPING 0x2F -#define MM_POOL_MAINTENANCE 0x30 -#define MM_POOL_VALIDATE_NAME 0x33 -#define MM_POOL_NEW_SNAPSHOT 0x18 -/* The following snap defines are for internal use only. */ -#define MM_SNAP_CREATE_FILE 0x19 -#define MM_SNAP_ALLOCATE_BLOCKS 0x1A -#define MM_SNAP_DELETE_FILE 0x1B -#define MM_SNAP_GET_FREE_TREE 0x1C -#define MM_SNAP_FREEZE 0x1D -#define MM_SNAP_THAW 0x1E - -#define MM_CLASSIC_FILESYSTEM_ID 0x464E4333 /*FNC3*/ -#define MM_NSS_FILESYSTEM_ID 0x464E5353 /*FNSS*/ -#define MM_DOS_FILESYSTEM_ID 0x46444F53 /*FDOS*/ - -/* Pool status defines */ -#define MM_POOL_STATE_UNKNOWN 0 /* Pool is new and not available */ -#define MM_POOL_STATE_DEACTIVE 2 /* Pool is not currently activated */ -#define MM_POOL_STATE_MAINTENANCE 3 /* Pool is in a maintenance mode */ -#define MM_POOL_STATE_ACTIVE 6 /* Pool is active and available */ - -#define MM_BOOLEAN -1 -#define MM_UINT8 -2 -#define MM_UINT16 -3 -#define MM_UINT32 -4 -#define MM_QUAD -5 -#define MM_MENU -6 - -/* -** MM_VOLUME_CONFIG_REVISION: -** The MSW is the version of the VolumeConfigElementList structure. -** The LSW is the version of the VolumeConfigElementDef structute. -*/ -#define MM_VOLUME_CONFIG_REVISION 0x00000000 - -#define MM_MODIFIABLE_ELEMENT 0x00000001 -#define MM_UNICODE_TEXT 0x00000002 - -struct ElementMenuList -{ - LONG numberOfChoices; - BYTE **choice; -}; - -struct VolumeConfigElementDef -{ - BYTE *name; - BYTE *description; - struct ElementMenuList *menu; - void *data; - LONG size; - LONG attributes; -}; - -struct VolumeConfigElementList -{ - LONG revision; - LONG numberOfElements; - void *token; - struct VolumeConfigElementDef *elements; -}; - -struct VolumeMappingElementDef -{ - OBID logicalPartition; - LONG startingUnit; - LONG numberOfUnits; -}; - -struct VolumeMappingInfo -{ - BYTE *volumeName; - LONG numberOfElements; - struct VolumeMappingElementDef element[1]; -}; - -struct LogicalPartitionMappingElementDef -{ - BYTE *volumeName; - LONG startingUnit; - LONG numberOfUnits; -}; - -struct LogicalPartitionMappingInfo -{ - LONG numberOfElements; - struct LogicalPartitionMappingElementDef element[1]; -}; - -struct VolumeLimitDef -{ - LONG maxVolumeNameSize; - QUAD maxVolumeSize; - LONG maxBlockSize; - LONG maxSegmentSize; - LONG maxSegmentsPerVolume; - LONG maxVolumes; - LONG attributes; -}; - -struct VolumeNamesDef -{ - LONG attributes; - void *token; - BYTE *names; -}; - -struct VolumeInfoDef -{ - BYTE *volumeName; - QUAD numberOfBlocks; - LONG blockSize; - LONG unitSize; - struct VolumeConfigElementList *info; -}; - -#endif // _MMPUBLIC_H_ diff --git a/include/nwnss/support/lnxmbINC/modify.h b/include/nwnss/support/lnxmbINC/modify.h deleted file mode 100644 index 173ef5e..0000000 --- a/include/nwnss/support/lnxmbINC/modify.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef __MODIFY_H__ -#define __MODIFY_H__ -/***************************************************************************** - * - * (C) Copyright 1988-1994 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Revision: 465 $ - * - ****************************************************************************/ - -struct ModifyStructure -{ - BYTE *MModifyName; - LONG MFileAttributes; - LONG MFileAttributesMask; - WORD MCreateDate; - WORD MCreateTime; - LONG MOwnerID; - WORD MLastArchivedDate; - WORD MLastArchivedTime; - LONG MLastArchivedID; - WORD MLastUpdatedDate; /* also last modified date and time. */ - WORD MLastUpdatedTime; - LONG MLastUpdatedID; - WORD MLastAccessedDate; - WORD MInheritanceGrantMask; - WORD MInheritanceRevokeMask; - int MMaximumSpace; - LONG MLastUpdatedInSeconds; -}; - -#define MModifyNameBit 1 -#define MFileAttributesBit 2 -#define MCreateDateBit 4 -#define MCreateTimeBit 8 -#define MOwnerIDBit 0x10 -#define MLastArchivedDateBit 0x20 -#define MLastArchivedTimeBit 0x40 -#define MLastArchivedIDBit 0x80 -#define MLastUpdatedDateBit 0x100 -#define MLastUpdatedTimeBit 0x200 -#define MLastUpdatedIDBit 0x400 -#define MLastAccessedDateBit 0x800 -#define MInheritanceRestrictionMaskBit 0x1000 -#define MMaximumSpaceBit 0x2000 -#define MLastUpdatedInSecondsBit 0x4000 - -struct MACModifyStructure -{ - BYTE *MACModifyName; - BYTE *MACFinderInfo; - BYTE *MACProDosInfo; -/* BYTE *MACDirRightsMask; */ - LONG MACDirRightsMask; - LONG MACCreateTime; - LONG MACBackupTime; -}; - -#define MACModifyNameBit 1 -#define MACFinderInfoBit 2 -#define MACProDosInfoBit 4 -#define MACDirRightsMaskBit 8 -#define MACCreateTimeBit 0x10 -#define MACBackupTimeBit 0x20 - -/* define the GetStructure (used by GetExtendedInfo) */ - -struct GetStructure -{ - BYTE *OS2GetFullName; -}; - -#define OS2GetFullNameBit 1 - - -struct OS2ModifyStructure -{ - BYTE *OS2ModifyName; -}; - -#define OS2ModifyNameBit 1 - -/****************************************************************************/ -/****************************************************************************/ - -struct NTGetStructure -{ - BYTE *NTGetFullName; - LONG NTSignature[2]; -}; - -#define NTGetFullNameBit 1 -#define NTGetSignatureBit 2 - -struct NTModifyStructure -{ - BYTE *NTModifyName; - LONG NTNewSignature[2]; -}; - -#define NTModifyNameBit 1 -#define NTModifySignatureBit 2 - - - -#endif /* __MODIFY_H__ */ diff --git a/include/nwnss/support/lnxmbINC/mpktypes.h b/include/nwnss/support/lnxmbINC/mpktypes.h deleted file mode 100644 index 5a46487..0000000 --- a/include/nwnss/support/lnxmbINC/mpktypes.h +++ /dev/null @@ -1,96 +0,0 @@ -/***************************************************************************** - * - * (C) Copyright 1988-1996 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $Author: taysom $ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $RCSfile$ - * $Revision: 465 $ - ****************************************************************************/ - - - - -#ifndef _MPKTYPES_H_ -#define _MPKTYPES_H_ -#if 0 // GLP - should not need as we use "linuxmpk.h" -#include "portable.h" - - -/* - * Various data typedefs - */ -typedef void * THREAD; -typedef void * APPL; -typedef void * SPINLOCK; -typedef void * MUTEX; -typedef void * SEMAPHORE; -typedef void * RWLOCK; -typedef void * RWMUTEX; -typedef void * BARRIER; -typedef void * QUE; -typedef void * QUE_LIGHT; -typedef void * INTTAG; -typedef void * HANDLE; - -typedef void * SCREEN; - -typedef unsigned long FLAGS; -typedef unsigned long ERROR; -typedef unsigned long PROCESSOR; - -typedef void * CONDITION; - -// -// WARNING!!!: -// The following are for Novell Internal use only. -// Until an alternate place is found, they will -// be retained here. -// - -typedef void * SPINRWLOCK; -typedef void * KCONDITION; -typedef void * RESOURCETAG; -typedef void * MODULEHANDLE; - -/********** - Macros -**********/ - -#define CpuBitSet( x ) while( ( x & CpuBit ) == 0 ) { x |= CpuBit; } -#define CpuBitClear( x ) while( ( x & CpuBit ) != 0 ) { x &= ~CpuBit; } - -// -// Clear the Nth bit (0 based) in a bit map. -// - -#define ClearBit(BitMap, BitNum) (BitMap &= ~((UINT) 1 << (BitNum))) - -// -// Set the Nth bit (0 based) in a bit map. -// - -#define SetBit(BitMap, BitNum) (BitMap |= (1 << (BitNum))) - -// -// Module internal data/routines should be "visible" only during debugging. -// - -#endif // #if 0 -#endif diff --git a/include/nwnss/support/lnxmbINC/nameserv.h b/include/nwnss/support/lnxmbINC/nameserv.h deleted file mode 100644 index 8bfa2be..0000000 --- a/include/nwnss/support/lnxmbINC/nameserv.h +++ /dev/null @@ -1,387 +0,0 @@ -#ifndef __NAMESERV_H__ -#define __NAMESERV_H__ -/***************************************************************************** - * - * (C) Copyright 1993-2004 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Revision: 465 $ - * - ****************************************************************************/ - -#define NAME_SERVICE_VERSION 11 - -/* Queue privilege types */ -#define QUEUE_USER 0x00000001 -#define QUEUE_OPERATOR 0x00000002 -#define QUEUE_SERVER 0x00000004 - -/****************************************************************************/ - -struct NameServiceStructure -{ - /* 0 */ - LONG (*ChangeAccountBalance)( - LONG connectionNumber, - LONG clientID, - LONG serverID, - LONG chargeAmount); - - /* 1 */ - LONG (*ChangeAccountHoldAmount)( - LONG connectionNumber, - LONG clientID, - LONG serverID, - LONG holdAmount); - - /* 2 */ - LONG (*GetAccountBalance)( - LONG connectionNumber, - LONG clientID, - long *accountBalance, - long *creditLimit); - - /* 3 */ - LONG (*GetAccountHoldAmount)( - LONG connectionNumber, - LONG clientID, - LONG serverID, - long *totalHoldAmount, - long *serverHoldAmount); - - /* 4 */ - LONG (*MapNameToObjectID)( - LONG connectionNumber, - BYTE *objectName, - LONG objectType, - LONG *objectID, - LONG checkSecurityAccessFlag); - - /* 5 */ - LONG (*CheckListForGroupMembership)( - LONG connectionNumber, - LONG objectID, - BYTE *attributeName, - LONG candidateCount, - LONG *candidateObjectIDList); - - /* 6 */ - LONG (*AddSAPService)( - BYTE *serviceName, - LONG serviceType, - BYTE restrictedFlag, - BYTE *serviceNetworkAddress); - - /* 7 */ - LONG (*RemoveSAPService)( - BYTE *serviceName, - LONG serviceType); - - /* 8 */ - LONG (*BinderyNCPHandler)( - LONG connectionNumber, - LONG task, - LONG requestCode, - BYTE *info, - BYTE *ans, - LONG *AnswerLength, - LONG packetSubFunctionLength); - - /* 9 */ - LONG (*ChangePassword)( - LONG connectionNumber, - LONG objectID, - BYTE *oldPassword, - BYTE *newPassword, - LONG passwordEncryptedFlag); - - /* 10 */ - LONG (*AuthenticateLoginRequest)( - LONG connectionNumber, - BYTE *objectName, - LONG objectType, - BYTE *password, - LONG passwordEncryptedFlag, - LONG checkSecurityFlag); - - /* 11 */ - LONG (*GetObjectSecurityEquivalenceList)( - LONG connectionNumber, - LONG objectID, - LONG includeHighPrivilegesFlag, - LONG bufferSizeInLongs, - LONG *securityEquivalenceList, - LONG *securityEquivalenceCount, - LONG checkSecurityAccessFlag); - - /* 12 */ - LONG (*IsAConsoleOperator)( - LONG connectionNumber, - LONG *objectIDList, - LONG numberOfObjectIDs); - - /* 13 */ - LONG (*WriteProperty)( - LONG connectionNumber, - LONG objectID, - BYTE *propertyName, - LONG dataSet, - void *buffer, - LONG moreData, - LONG checkAccess, - LONG checkForGroup); - - /* 14 */ - LONG (*IsMemberOfGroup)( - LONG connectionNumber, - LONG objectID, - BYTE *propertyName, - LONG memberID, - LONG checkAccess); - - /* 15 */ - LONG (*ReadProperty)( - LONG connectionNumber, - LONG objectID, - BYTE *propertyName, - LONG dataSet, - void *buffer, - BYTE *moreData, - BYTE *propertyFlags, - LONG checkAccess); - - /* 16 */ - LONG (*ScanNextLoginObject)( - LONG connectionNumber, - LONG tasks, - BYTE *namePattern, - LONG typePattern, - LONG *objectID); /* For initial scan objectID should be -1 */ - - /* 17 */ - LONG (*GetManagementLevel)( - LONG connectionNumber, - LONG targetObjectID); - - /* 18 */ - LONG (*DeleteObject)( - LONG connectionNumber, - LONG objectID, - LONG checkAccess, - LONG deleteStaticObjectsFlag); - - /* 19 */ - LONG (*AddObject)( - LONG connectionNumber, - BYTE *objectName, - LONG objectType, - LONG lifetime, - LONG security, - LONG checkRights); - - /* 20 */ - LONG (*AddProperty)( - LONG connectionNumber, - LONG objectID, - BYTE *propertyName, - LONG propertyFlags, - LONG security, - LONG checkAccess); - - /* 20 */ - LONG (*MapObjectIDToNameAndType)( - LONG connectionNumber, - LONG objectID, - BYTE *objectName, /* The name is returned NULL terminated */ - LONG *objectType, - LONG checkSecurityAccessFlag); - - /* 22 */ - LONG (*IsValidObjectID)( - LONG objectID); - - /* 23 */ - LONG (*IsValidPermanentObjectID)( - LONG objectID); - - /* 24 */ - LONG (*DeleteProperty)( - LONG connectionNumber, - LONG objectID, - BYTE *propertyName, - LONG checkAccess); - - /* 25 */ - LONG (*ScanObjects)( - LONG connectionNumber, - LONG task, - BYTE *searchPattern,/* NULL terminated */ - LONG searchType, - LONG *lastID, /* Set to -1 to begin search */ - BYTE *objectName, /* Use NULL if you do not need this information */ - /* The name is returned NULL terminated */ - LONG *objectType, /* Use NULL if you do not need this information */ - BYTE *objectFlags, /* Use NULL if you do not need this information */ - BYTE *objectSecurity); /* Use NULL if you do not need this information */ - - /* 26 */ - LONG (*IDsListHasObjectCreatePrivilege)( - LONG connectionNumber, - LONG *authenticatedIDs, - LONG numberOfAuthenticatedIDs); - - /* 27 */ - LONG (*CheckLoginRestrictions)( - LONG connectionNumber, - LONG objectID); - /* Return values: - 0- login is allowed - 1- login is not allowed during the current time block - 2- account is disabled (or expired) - 3- account has been deleted - */ - - /* 28 */ - LONG (*CheckQueuePrivileges)( - LONG connectionNumber, - LONG queueObjectID, - LONG privilegeType, - LONG numberOfAuthenticatedIDs, - LONG *authenticatedIDs); - - /* 29 */ - LONG (*GetQueueDirectory)( - LONG connectionNumber, - LONG queueObjectID, - BYTE *directoryName); - - /* 30 */ - LONG (*MapObjectIDToLongName)( - LONG connectionNumber, - LONG objectID, - BYTE *objectName); /* The name is returned NULL terminated */ - - /* 31 */ - LONG (*ClearIntruderLockout)( - LONG connectionNumber, - LONG objectID); - - /* 32 */ - LONG (*CheckIfObjectAudited)( - LONG connectionNumber, - LONG objectID); - /* Returns 0 if the object is audited */ - - /* 33 */ - LONG (*ChangeObjectAuditStatus)( - LONG connectionNumber, - LONG objectID, - LONG auditObjectFlag); - - /* 34 */ - LONG (*CreateQueue)( - LONG connectionNumber, - BYTE *queueObjectName, - LONG queueObjectType, - BYTE *queueDirectoryPath, - LONG *queueObjectID, - LONG maxDNLen, - BYTE *queueDN); /* Always returned */ - /* - queueDirectoryPath starts with the volume, and must exist on - this server. It does not include the final directory name which - will be based on the object ID assigned to the new queue. The - queueDirectoryPath must be in a buffer of at least 128 bytes. The - path will be modified to contain the queue directory name at the - end during the call. - */ - - /* 35 */ - LONG (*DestroyQueue)( - LONG connectionNumber, - LONG queueObjectID); - /* - This routine must call DeleteQueueDirectory before removing - the queue object and properties. This is because - DestroyQueueDirectory uses the object and properties. - */ - - /* 36 */ - LONG (*ScanAccountHolds)( - LONG connectionNumber, - LONG clientObjectID, - LONG *serverObjectID, /* Set to zero for first call */ - LONG *holdAmount); - - /* 37 */ - LONG (*GetObjectPrivileges)( - LONG connectionNumber, - LONG objectID, - LONG includeHighPrivilegesFlag, - LONG *privileges, - LONG checkSecurityAccessFlag); - - /* 38 */ - LONG (*MapObjectIDToDN)( - LONG connectionNumber, - LONG objectID, - BYTE *unicodeDN, - LONG maxNameByteLength, - LONG unicodeFlag); - - /* 39 */ - LONG (*MapObjectIDToGUID)( // NEW in 6Pack - LONG objectID, - BYTE *pGUID); - - /* 40 */ - LONG (*MapGUIDToObjectID)( // NEW in 6Pack - BYTE *pGUID, - LONG *pObjectID); -}; - -struct NameServiceControlStructure -{ - /* 0 */ - LONG (*EnableNameService)(void); - - /* 1 */ - LONG (*DisableNameService)(void); - - /* 2 */ - LONG (*InitializeObjectIDs)( - LONG serverObjectID, - LONG supervisorObjectID); - - /* 3 */ - LONG (*UpdateConnectionZeroIds)( - LONG ServerID, - LONG SuperID); -}; - -extern struct NameServiceStructure NameService; -extern struct NameServiceControlStructure NameServiceControl; - -extern LONG GetBinderyOpen(void); - -/****************************************************************************/ -/****************************************************************************/ - -#endif /* __NAMESERV_H__ */ diff --git a/include/nwnss/support/lnxmbINC/nmevents.h b/include/nwnss/support/lnxmbINC/nmevents.h deleted file mode 100644 index 8b13789..0000000 --- a/include/nwnss/support/lnxmbINC/nmevents.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/nwnss/support/lnxmbINC/nspace.h b/include/nwnss/support/lnxmbINC/nspace.h deleted file mode 100644 index 950ffaf..0000000 --- a/include/nwnss/support/lnxmbINC/nspace.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef __NSPACE_H__ -#define __NSPACE_H__ -/***************************************************************************** - * - * (C) Copyright 1988-1994 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Revision: 465 $ - * - ****************************************************************************/ - - -/* define the routine vectors and defines for the name spaces. */ - - -/* #define MaximumNumberOfNameSpaces 10 moved to config.h JDM */ -#define DOSNameSpace 0 -#define MACNameSpace 1 -#define UNIXNameSpace 2 -#define FTAMNameSpace 3 -#define OS2NameSpace 4 -#define NTNameSpace 5 -/* Name Spaces 6 - 9 --> are reserved for Novell use only */ - -/* Name Space Flags */ -#define UNICODE_SUPPORT 0x00000001 - -/* Search Attribute to include all files & subdirectories */ -#define SEARCH_INCL_ALL 0x8000 -/* MatchBits flag to return more information about error */ -#define RETURN_EXTENDED_ERROR_CODE 0x80000000 - -/* RemoveEntryName Event Notification Defines */ -#define RE_rename_or_move_notification 0x4e650000 -#define RE_delete_notification 0x4e650001 -#define RE_open_file_notification 0x4e650002 -#define RE_dirhandle_create_phantom_entry 0x4e650003 -#define RE_rename_entry 0x4e650004 -#define RE_create_directory 0x4e650005 -#define RE_delete_directory 0x4e650006 -#define RE_clear_phantom 0x4e650007 -#define RE_create_and_open_file 0x4e650008 -#define RE_delete_hard_link_file 0x4e650009 -#define RE_delete_hard_link_directory 0x4e65000a -#define RE_delete_file_completely 0x4e65000b -#define RE_delete_file_to_limbo 0x4e65000c -#define RE_salvage_limbo_file 0x4e65000d -#define RE_change_directory 0x4e65000e - - -#endif /* __NSPACE_H__ */ diff --git a/include/nwnss/support/lnxmbINC/nwreg.h b/include/nwnss/support/lnxmbINC/nwreg.h deleted file mode 100644 index 8fbead9..0000000 --- a/include/nwnss/support/lnxmbINC/nwreg.h +++ /dev/null @@ -1,377 +0,0 @@ -/**************************************************************************** - | - | (C) Copyright 2004 Novell, Inc. - | All Rights Reserved. - | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. - | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. - | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. - | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com - | - |***************************************************************************/ -/* ---------------------------------------------------------------------------- - NetWare Registry Information - -This file documents the NetWare registry extentions that allow NLMs -to access to the NetWare registry database. All Registry API's have -been defined and documented below. - -IMPORTANT NOTE: It is possible to make your system unbootable by -corrupting the registry database! - ------------------------------------------------------------------------------ */ - -// -// Well Known -// -#define HKEY LONG -#define REGSAM LONG -//#ifndef BOOL -//#define BOOL unsigned int -//#endif -#define REGEVT struct LoadDefinitionStructure * -#define SECURITY_ATTRIBUTES LONG /* Connection Number */ -// -// Reserved Key Handles. -// -#define HKEY_ROOT ((HKEY)0x80000000) -#define HKEY_LOCAL_MACHINE ((HKEY)0x80000002) -#define HKEY_PERFORMANCE_DATA ((HKEY)0x80000004) -#define HKEY_DYN_DATA ((HKEY)0x80000006) - -#define HKLM HKEY_LOCAL_MACHINE -#define HKPD HKEY_PERFORMANCE_DATA -#define HKDD HKEY_DYN_DATA - -// -// Data Types -// -#define REG_NONE 0 // No value type -#define REG_SZ 1 // ASCIIZ null terminated string -#define REG_EXPAND_SZ 2 // ASCIIZ null terminated string (with environment variable references) -#define REG_BINARY 3 // Free form binary -#define REG_DWORD 4 // 32-bit number -#define REG_DWORD_BIG_ENDIAN 5 // 32-bit number -#define REG_LINK 6 // Symbolic Link -#define REG_MULTI_SZ 7 // Multiple ASCIIZ null terminated strings -#define REG_RESOURCE_LIST 8 // Resource list in the resource map -#define REG_FULL_RESOURCE_DESCRIPTOR 9 // Resource list in the hardware description -#define REG_RESOURCE_REQUIREMENTS_LIST 10 -#define REG_QWORD 11 // 64-bit number - - -// -// Open/Create Options -// - -#define REG_OPTION_RESERVED 0x00000000 // Parameter is reserved -#define REG_OPTION_NON_VOLATILE 0x00000000 // Key is preserved when system is rebooted -#define REG_OPTION_VOLATILE 0x00000001 // Key is not preserved when system is rebooted -#define REG_OPTION_CREATE_LINK 0x00000002 // Created key is a symbolic link -#define REG_OPTION_BACKUP_RESTORE 0x00000004 // open for backup or restore special access rules privilege required -#define REG_OPTION_OPEN_LINK 0x00000008 // Open symbolic link - -// -// Key creation/open disposition -// -#define REG_CREATED_NEW_KEY 0x00000001 // New Registry Key created -#define REG_OPENED_EXISTING_KEY 0x00000002 // Existing Key opened - -// -// Security Access Mask values -// -#define KEY_QUERY_VALUE 0x00000001 -#define KEY_SET_VALUE 0x00000002 -#define KEY_CREATE_SUB_KEY 0x00000004 -#define KEY_ENUMERATE_SUB_KEYS 0x00000008 -#define KEY_NOTIFY 0x00000010 -#define KEY_CREATE_LINK 0x00000020 - -#define KEY_READ (KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) -#define KEY_WRITE (KEY_SET_VALUE | KEY_CREATE_SUB_KEY) -#define KEY_EXECUTE (KEY_READ) -#define KEY_ALL_ACCESS (KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) - -// -// Notify filter values -// -#define REG_NOTIFY_CHANGE_NAME 0x00000001 // Create or delete (child) -#define REG_NOTIFY_CHANGE_ATTRIBUTES 0x00000002 -#define REG_NOTIFY_CHANGE_LAST_SET 0x00000004 // time stamp -#define REG_NOTIFY_CHANGE_SECURITY 0x00000008 - -#define REG_LEGAL_CHANGE_FILTER \ - (REG_NOTIFY_CHANGE_NAME |\ - REG_NOTIFY_CHANGE_ATTRIBUTES |\ - REG_NOTIFY_CHANGE_LAST_SET |\ - REG_NOTIFY_CHANGE_SECURITY) - - -// -// InValid Character Set for Names (Case Preserved, Case Insensitive) -// -#define NULL_CHAR 0x00 -#define SLASH_CHAR 0x5c - - -// -// VALENT Definition -// -typedef struct val_ent -{ - BYTE *vValueName; /* SET BY CALLER -- contains name of value to get */ - LONG vValueLen; /* SET BY OS -- contains size of value */ - void *vValueData; /* SET BY OS -- pointer to where data place in specified buffer */ - LONG vDataType; /* SET BY OS -- contains the data type */ -} VALENT; - -/* ---------------------------------------------------------------------------- - - NetWare Registry APIs - --------------------- - RegCloseKey - RegCreateKeyEx - RegDeleteKey - RegDeleteValue - RegEnumKeyEx - RegEnumValue - RegNotifyChangeKeyValue - RegOpenKeyEx - RegQueryInfoKey - RegQueryValueEx - RegSetValueEx - ----------------------------------------------------------------------------- */ - -extern LONG RegCloseKey(HKEY hKey); - -extern LONG RegCreateKeyEx( - HKEY hKey, - BYTE *SubKey, - LONG Reserved, /* reserved for future use */ - BYTE *reserved0, /* reserved for future use */ - LONG Options, /* volatile or not */ - REGSAM samDesired, /* security access mask */ - LONG Reserved1, /* reserved for future use */ - HKEY *newHKey, /* new handle */ - LONG *rtnDisposition); /* disposition taken */ - -extern LONG RegDeleteKey( - HKEY hKey, - BYTE *ptrSubKey); /* string identifying the subkey to delete */ - -extern LONG RegDeleteValue( - HKEY hKey, - BYTE *ptrValueName); /* name of value to delete */ - -extern LONG RegEnumKeyEx( - HKEY hKey, - LONG dwIndex, /* numeric index of key to enumerate */ - BYTE *Name, /* returned key name */ - LONG *lenName, /* sizeof key name*/ - LONG *Reserved, /* reserved for future use */ - BYTE *Reserved0, /* reserved for future use */ - LONG *Reserved1, /* reserved for future use */ - LONG *ptrLastWriteTime); /* DOS time of last modification of $subkey */ - -extern LONG RegEnumValue( - HKEY hKey, - LONG dwIndex, /* numeric index of key to enumerate */ - BYTE *Name, /* returned value name */ - LONG *lenName, /* sizeof value name */ - LONG *Reserved, /* must be zero */ - LONG *lpType, /* returned type of $valname */ - void *Data, /* data associated with $valname (of data type $type) */ - LONG *sizeData); /* sizeof data returned */ - -extern LONG RegFlushKey( - HKEY hKey); - -extern LONG RegLoadKey( - HKEY hKey, - BYTE *keyName, /* string identifying key to created under the specified HKEY */ - BYTE *pathAndFileName); /* path and file name point the hive created by a RegSaveKey */ - - -extern LONG RegNotifyChangeKeyValue( - HKEY hKey, - BOOL bWatchSubtree, - LONG dwNotifyFilter, - REGEVT hEvent, - BOOL fAsynchronus); - -extern LONG RegOpenKeyEx( - HKEY hKey, - BYTE *SubKey, /* string identifying subkey of $key */ - LONG ulOptions, - REGSAM samDesired, /* requested security access mask */ - HKEY *newHKey); /* returned key handle */ - -extern LONG RegQueryInfoKey( - HKEY hKey, - BYTE *reserved2, - LONG *reserved3, - LONG *Reserved, /* reserved for future use */ - LONG *rtnSubKeys, /* number of subkeys for this key */ - LONG *rtnMaxSubKeyLen, /* size of largest subkey */ - LONG *Reserved0, /* reserved for future use */ - LONG *rtnValues, /* number of values associated with this key */ - LONG *MaxValueNameLen, /* size of largest value name */ - LONG *MaxValueLen, /* size of largest value data */ - LONG Reserved1, /* reserved for future use */ - LONG *ptrLastWriteTime); /* time of last write (DOS Time Format )*/ - -extern LONG RegQueryMultipleValues( - HKEY hKey, - VALENT *pValent, - LONG numOfValents, - void *data, - LONG *totalSize); - - -extern LONG RegQueryValue( - HKEY hKey, - BYTE *SubKey, /* string identifying subkey of $key */ - void *lpData, /* returned type of $data */ - LONG *DataLen); /* returned data associated with $valname */ - - -extern LONG RegQueryValueEx( - HKEY hKey, - BYTE *ptrValueName, /* string identifying value to retreive */ - LONG *Reserved, /* reserved for future use */ - LONG *lpType, /* returned type of data */ - void *lpData, /* returned data associated with $valname */ - LONG *DataLen); /* sizeof returned data */ - -extern LONG RegSaveKey( - HKEY hkey, - BYTE *pathAndFileName, /* path and file name */ - SECURITY_ATTRIBUTES SecurityAttrs); /* security attributes */ - -extern LONG RegSetValue( - HKEY hKey, - BYTE *SubKey, - LONG dataType, /* data type of $data */ - void *Data, /* data to associate with valname */ - LONG sizeOfData); /* sizeof $data */ - - -extern LONG RegSetValueEx( - HKEY hKey, - BYTE *ValueName, /* name of value to set */ - LONG Reserved, /* reserved for future use */ - LONG dataType, /* data type of $data */ - BYTE *Data, /* data to associate with valname */ - LONG sizeOfData); /* sizeof $data */ - -/*------------------------------------------------------------------------------------------------------------------** -** extern LONG CloseConfigFile(); * THIS API IS ONLY TO BE USED BY ORION NLMs * ** -** extern void InitializeClusterCfgFileJumpTable(void *, ...); * THIS API IS ONLY TO BE USED BY ORION NLMs * ** -** extern void InitializeLocalCfgFileJumpTable(void); * THIS API IS ONLY TO BE USED BY ORION NLMs * ** -**------------------------------------------------------------------------------------------------------------------*/ - -/* ---------------------------------------------------------------------------- - - NetWare Remote Registry Access NCPs - ---------------------------------- - ncp xx 00 f_RegCloseKey - ncp xx 01 f_RegCreateKeyEx - ncp xx 02 f_RegDeleteKey - ncp xx 03 f_RegDeleteValue - ncp xx 04 f_RegEnumKeyEx - ncp xx 05 f_RegEnumValue - ncp xx 06 f_RegNotifyChangeKeyValue - ncp xx 07 f_RegOpenKeyEx - ncp xx 08 f_RegQueryInfoKey - ncp xx 09 f_RegQueryValueEx - ncp xx 10 f_RegSetValueEx - ----------------------------------------------------------------------------- */ - - -/* - Error Codes -*/ -#define REG_ERR_INVALID_HANDLE 0x40000001 -#define REG_ERR_INPUT_PARAMETER_NO_DATA 0x40000002 -#define REG_ERR_VALUE_NOT_SET 0x40000003 -#define REG_ERR_ENUM_INDEX_OUT_OF_RANGE 0x40000004 -#define REG_ERR_NAME_BUFFER_TOO_SMALL 0x40000005 -#define REG_ERR_VALUE_BUFFER_TOO_SMALL 0x40000006 -#define REG_ERR_SAM_CHECK_FAILED 0x40000007 -#define REG_ERR_DATABASE_IS_CORRUPT 0x40000008 -#define REG_ERR_INCOMPLETE_SUBKEY_PATH 0x40000009 -#define REG_ERR_VALUE_SEARCH_FAILED 0x4000000a -#define REG_ERR_INTERNAL_RESOURCE_FAILURE 0x4000000b -#define REG_ERR_DB_WRITE_ERROR 0x4000000c -#define REG_ERR_RESERVED_KEYS_NO_DELETE 0x4000000d -#define REG_ERR_SUBKEY_SEARCH_FAILED 0x4000000e -#define REG_ERR_NOT_ACCESSIBLE 0x4000000f -#define REG_ERR_REG_SZ_ONLY_ALLOWED 0x40000010 -#define REG_ERR_NO_FREE_HANDLE_SLOTS 0x40000011 -#define REG_ERR_DATABASE_NOT_ACCESSIBLE 0x40000012 -#define REG_ERR_INVALID_CHARACTER 0x40000013 -#define REG_ERR_FILE_CREATION_FOR_SAVEKEY 0x40000014 -#define REG_ERR_SERVICE_NOT_AVAILABLE 0x40000015 -#define REG_ERR_VALUE_SIZE_TOO_LARGE 0x40000016 - -/* ---------------------------------------------------------------------------- - - Reserved NetWare PATHS & KEYS under HKEY_LOCAL_MACHINE - ----------------------------------------------------------------------------- */ - -#define REGSTR_SET_PARAMETERS "Setable Parameters" -#define REGSTR_SET_PARAMETER_CURRENT_VALUE "Current Value" -#define REGSTR_SET_PARAMETER_PENDING_VALUE "Pending Value" -#define REGSTR_SET_PARAMETER_CONTROL_INFO "Control Info" -#define REGSTR_SET_PARAMETER_DEFAULT_VALUE "Default Value" - -#define REGSTR_SERVER_NAME "Server Name" -#define REGSTR_SERVER_OPERATION_MODE "Operational Mode" - -#define REGSTR_NO_SPLASH "No Splash" -#define REGSTR_PROTOCOL_IPX_INTERNAL_NET_NUMBER "Protocols\\IPX\\Internal Net Number" - - -#define REGSTR_LOAD_ORDER "Load Control" -#define REGSTR_LOAD_ORDER_CREATOR "Load Control\\Creator Info" -#define REGSTR_LOAD_ORDER_STAGE0 "Load Control\\Stage0" -#define REGSTR_LOAD_ORDER_STAGE1 "Load Control\\Stage1" -#define REGSTR_LOAD_ORDER_STAGE2 "Load Control\\Stage2" -#define REGSTR_LOAD_ORDER_STAGE3 "Load Control\\Stage3" -#define REGSTR_LOAD_ORDER_STAGE4 "Load Control\\Stage4" -#define REGSTR_LOAD_ORDER_STAGE5 "Load Control\\Stage5" -#define REGSTR_CREATOR_INFO "Creator Info" -#define REGSTR_LOAD_ORDER_BOOT_INFO "Load Control\\Boot Info" -#define REGSTR_BOOT_NCF_DATE_TIME_INFO "Startup & AutoExec Info" - -#define REGSTR_NCP_CONTROL_INFO "NCP Control" - -#define REGSTR_SERVER_GUID_INFO "Server GUID" -#define REGSTR_LAST_ISSUED_GUID "Last Issued GUID" - -#define REGSTR_ALERT_CONTROL "Alert Control" - -/* ---------------------------------------------------------------------------- - - Reserved NetWare PATHS & KEYS under HKEY_PERFORMANCE_DATA - ----------------------------------------------------------------------------- */ -#define REGSTR_SERVER_WORKING_SET "Server Working Set" -#define REGSTR_LEGACY_FILE_SYSTEM "Legacy File System" -#define REGSTR_LEGACY_CACHE "Legacy Cache" -#define REGSTR_LEGACY_PROCESSES "Legacy Processes" -#define REGSTR_LEGACY_DIRECTORY_CACHE "Legacy Directory Cache" -#define REGSTR_LEGACY_VOLUMES "Legacy Volumes" diff --git a/include/nwnss/support/lnxmbINC/portable.h b/include/nwnss/support/lnxmbINC/portable.h deleted file mode 100644 index abfe53a..0000000 --- a/include/nwnss/support/lnxmbINC/portable.h +++ /dev/null @@ -1,1263 +0,0 @@ -#ifndef __PORTABLE_H__ -#define __PORTABLE_H__ -/***************************************************************************** - * - * (C) Copyright 1988-1997 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2007-04-04 04:18:37 +0530 (Wed, 04 Apr 2007) $ - * $Revision: 1924 $ - * - ****************************************************************************/ - -/* -** PORTABLE.H -** -** Portable.h provides definitions that support C code -** portablity in various environments. -*/ - - -/*************************** NETWARE INTEGER TYPES *************************/ - -/* -** The following provides definitions for primitive integer -** data types that may change depending on the target -** platform (P5, P6, Merced). These types were adopted -** by committee on 18Dec96 and are intended to supercede -** the BYTE, WORD, and LONG data types currently defined -** in portable.h, etc. -*/ - -/**********************************************/ -/* UINT8 is an unsigned 8-bit integer. */ -/* It replaces the original BYTE type. */ -/**********************************************/ -#define UINT8 unsigned char - -/**********************************************/ -/* UINT16 is an unsigned 16-bit integer. */ -/* It replaces the original WORD type. */ -/**********************************************/ -#define UINT16 unsigned short - -/**********************************************/ -/* UINT32 is an unsigned 32-bit integer. */ -/* It replaces some of the uses for the */ -/* original LONG type. UINT32 should ONLY */ -/* be used for storing 4-byte data elements. */ -/**********************************************/ -//#ifdef IAPX386 -//#define UINT32 unsigned long -//#endif - -/**********************************************/ -/* UINT64 is an unsigned 64-bit integer. */ -/* It should only be used where very large */ -/* unsigned integers are required, such as */ -/* for file offsets in file systems that */ -/* support large (>4GB) files. UINT64 is */ -/* equivalent to the NAFS QUAD data type. */ -/**********************************************/ -#define UINT64 unsigned long long - -/**********************************************/ -/* UINT is an unsigned integer data type that */ -/* is guaranteed to be 32-bits or greater. */ -/* The size is processor specific and will */ -/* be selected to maximize processor */ -/* performance. UINT should be used for */ -/* items such as counts, array indexes, */ -/* return codes, etc. */ -/**********************************************/ -//#define UINT unsigned long - -/**********************************************/ -/* SINT8 is a signed 8-bit integer. */ -/* Since characters in NetWare are unsigned */ -/* quantities, the use of SINT8 is expected */ -/* to be extremely limited. */ -/**********************************************/ -#define SINT8 signed char - -/**********************************************/ -/* SINT16 is a signed 16-bit integer. */ -/* The use of SINT16 is expected to be */ -/* extremely limited. */ -/**********************************************/ -#define SINT16 short - -/**********************************************/ -/* SINT32 is a signed 32-bit integer. */ -/* Use SINT unless you absolutely need a */ -/* 4-byte signed integer. */ -/**********************************************/ -#define SINT32 int - -/**********************************************/ -/* SINT64 is a signed 64-bit integer. */ -/* It should only be used where very large */ -/* integers are required, such as for file */ -/* offsets in file systems that support */ -/* large (>4GB) files. SINT64 is equivalent */ -/* to the NAFS SQUAD data type. */ -/**********************************************/ -#define SINT64 long long - -/**********************************************/ -/* SINT is a signed integer data type that */ -/* is guaranteed to be 32-bits or greater. */ -/* The size is processor specific and will */ -/* be selected to maximize processor */ -/* performance. SINT should be used for */ -/* items such as counts, array indexes, */ -/* return codes, etc. that could go negative. */ -/**********************************************/ -#define SINT long - -#if 0 -/**********************************************/ -/* ADDR is an unsigned integer data type */ -/* whose size is large enough to represent */ -/* a logical byte address. Arithmetic and */ -/* bitwise operations may be performed on */ -/* ADDR data types, since they are integers. */ -/* Use the void* type (or other pointer type) */ -/* for addresses that may be dereferenced. */ -/**********************************************/ -#ifdef IAPX386 -#define ADDR unsigned long -#endif - -/**********************************************/ -/* STR is equivalent to UINT8 and should be */ -/* used to define pointers to NULL-terminated */ -/* ASCII strings. STR is NOT a pointer type, */ -/* so the "*" must be included in each */ -/* definition. For example: */ -/* STR *foo, bar[] = "test"; */ -/**********************************************/ -#define STR unsigned char - -/**********************************************/ -/* LSTR is equivalent to UINT8 and should be */ -/* used to define pointers to length-preceded */ -/* ASCII strings. LSTR is NOT a pointer */ -/* type so the "*" must be included in each */ -/* definition. For example: */ -/* LSTR *foo, bar[] = {4,'t','e','s','t'}; */ -/**********************************************/ -#define LSTR unsigned char - -/**********************************************/ -/* LSTRZ is equivalent to UINT8 and should be */ -/* used to define pointers to strings that */ -/* are length-preceded AND NULL-terminated. */ -/* LSTR is NOT a pointer type so the "*" must */ -/* be included in each definition. */ -/* For example: */ -/* LSTRZ *foo, bar[] = {4,'t','e','s','t',0}; */ -/**********************************************/ -#define LSTRZ unsigned char - - -/*************************** OBSOLETE TYPES *************************/ -/* -** The following types should not be used for new code, and existing -** code that uses these types should be changed to use one of the -** types defined in the previous section of this file. -*/ -#ifndef LONG -#define LONG UINT32 -#endif - -#ifndef WORD -#define WORD UINT16 -#endif - -#ifndef BYTE -#define BYTE UINT8 -#endif - -#ifndef SLONG -#define SLONG SINT32 -#endif - -#ifndef QUAD -#define QUAD UINT64 -#endif - -#ifndef BOOLEAN -#define BOOLEAN UINT -#endif - -/*************************************************************************/ - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#endif // if 0 -/*************************************************************************/ - -/* - * This section of portable.h will attempt to create a consistant - * set of macros to isolate the alignment and endianness of a machine - * from the C code. Each macro will follow a consistant naming - * convention and then allow aliases to support previous versions - * of byte swapping macros and routines. - * The following macros use WORD to mean 2 bytes and LONG to mean - * 4 bytes. Where macros operate on more than 4 bytes the number - * of bytes is included in the name (ex. COPY_6BYTE). - * The word 'addr' is used to indicate a byte pointer to the data - * that will be acted upon. A variable is indicated by 'var', and - * 'value' is used where either a constant or a variable can be used. - */ - - -/***************************** SUMMARY ************************************** - * - * The first set of macros is used to copy un-aligned data from - * one address to another. They do not swap the data and can be - * called on either aligned or un-aligned data. - * - * COPY_2BYTE(src_addr, dest_addr) - * COPY_WORD(src_addr, dest_addr) - * COPY_SOCKET(src_addr, dest_addr) - * - * COPY_4BYTE(src_addr, dest_addr) - * COPY_LONG(src_addr, dest_addr) - * COPY_NET(src_addr, dest_addr) - * - * COPY_6BYTE(src_addr, dest_addr) - * COPY_NODE(src_addr, dest_addr) - * COPY_HOST(src_addr, dest_addr) - * - * COPY_12BYTE(src_addr, dest_addr) - * COPY_ADDRESS(src_addr, dest_addr) - * - **************************************************************************** - * - * The next set of macros is used to assign a variable a value - * that may be mis-aligned. They do not swap the data. - * - * addr is the address of the potentially mis-aligned data. - * value can be either a constant or a variable. - * - * var = GET_WORD(addr) - * var = GET_LONG(addr) - * PUT_WORD(value, addr) - * PUT_LONG(value, addr) - * - **************************************************************************** - * - * Next is a set of macros that perform alignment and byte swaps if needed. - * The macros containing HILO will swap bytes on Little Endian machines only. - * The macros containing LOHI will swap bytes on Big Endian machines only. - * - * var = GET_HILO_WORD(addr) - * var = GET_LEN(addr) alias - * var = GET_SOCKET(addr) alias - * var = GET_HILO_LONG(addr) - * var = GET_LOHI_WORD(addr) - * var = GET_LOHI_LONG(addr) - * PUT_HILO_WORD(value, addr) - * PUT_LEN(value, addr) alias - * PUT_SOCKET(value, addr) alias - * PUT_HILO_LONG(value, addr) - * PUT_LOHI_WORD(value, addr) - * PUT_LOHI_LONG(value, addr) - * - **************************************************************************** - * - * Given a value (ie constants, register variables, or expressions) - * the next set of macros will return the value in specified order. - * The macros containing HILO will return the value in HILO order. - * The macros containing LOHI will return the value in LOHI order. - * - * var = VALUE_TO_HILO_WORD(value) - * WORD_TO_HILO(word) alias - * SOCKET_NUMBER(hostorder_sock) alias - * var = VALUE_TO_HILO_LONG(value) - * var = VALUE_TO_LOHI_WORD(value) - * var = VALUE_TO_LOHI_LONG(value) - * var = VALUE_FROM_HILO_WORD(value) - * var = VALUE_FROM_HILO_LONG(value) - * var = VALUE_FROM_LOHI_WORD(value) - * var = VALUE_FROM_LOHI_LONG(value) - * - **************************************************************************** - * - * The next set of macros will be used less frequently but is included for - * cases where the macros above will not work. They copy data from a source - * address to a destination address swapping and/or aligning data as needed. - * The macros containing HILO will swap bytes on Little Endian machines only. - * The macros containing LOHI will swap bytes on Big Endian machines only. - * - * COPY_TO_HILO_WORD(src_addr, dest_addr) - * COPY_TO_HILO_LONG(src_addr, dest_addr) - * COPY_TO_LOHI_WORD(src_addr, dest_addr) - * COPY_TO_LOHI_LONG(src_addr, dest_addr) - * COPY_FROM_HILO_WORD(src_addr, dest_addr) - * COPY_FROM_HILO_LONG(src_addr, dest_addr) - * COPY_FROM_LOHI_WORD(src_addr, dest_addr) - * COPY_FROM_LOHI_LONG(src_addr, dest_addr) - * - * Alternately, when the source and destination address are the same the - * following macros can be used. - * - * HOST_TO_HILO_WORD(addr) - * HOST_TO_HILO_LONG(addr) - * HOST_TO_LOHI_WORD(addr) - * HOST_TO_LOHI_LONG(addr) - * HOST_FROM_HILO_WORD(addr) - * HOST_FROM_HILO_LONG(addr) - * HOST_FROM_LOHI_WORD(addr) - * HOST_FROM_LOHI_LONG(addr) - * - **************************************************************************** - * - * Finally a set of macros to compare two groups of bytes to see if they - * are equal are included. They return TRUE if equal. - * - * ARE_2BYTES_EQUAL(addr1, addr2) - * WORD_EQUAL(addr1, addr2) alias - * ARE_4BYTES_EQUAL(addr1, addr2) - * LONG_EQUAL(addr1,addr2) alias - * NET_EQUAL(addr1,addr2) alias - * ARE_6BYTES_EQUAL(addr1, addr2) - * NODE_EQUAL(addr1,addr2) alias - * HOST_EQUAL(addr1,addr2) alias - * ARE_12BYTES_EQUAL(addr1, addr2) - * ADDRESS_EQUAL(addr1,addr2) alias - * - * - ************************* END OF SUMMARY **********************************/ - -/* - * COPY_2BYTE(src_addr, dest_addr) - * COPY_WORD(src_addr, dest_addr) alias - * COPY_SOCKET(src_addr, dest_addr) alias - * - * COPY_4BYTE(src_addr, dest_addr) - * COPY_LONG(src_addr, dest_addr) alias - * COPY_NET(src_addr, dest_addr) alias - * - * COPY_6BYTE(src_addr, dest_addr) - * COPY_NODE(src_addr, dest_addr) alias - * COPY_HOST(src_addr, dest_addr) alias - * - * COPY_12BYTE(src_addr, dest_addr) - * COPY_ADDRESS(src_addr, dest_addr) alias - * - * Description: - * Copy 2, 4, 6 or 12 bytes of potentially misaligned data. - * - * Purpose: - * Useful for copying sockets, networknumbers, nodenumbers or complete - * ipx addresses between ipx packets or between ipx packets and some - * location in memory that is in hilo order. - * - * Example: - * .. - * COPY_NET(&reqpacket->srcnet, &resppacket->dstnet); - * COPY_NODE(&reqpacket->srcnode, &resppacket->dstnode); - * COPY_SOCKET(&reqpacket->srcsocket, &resppacket->dstsocket); - * .. - * COPY_ADDRESS(&reqpacket->srcnet, &resppacket->dstnet); - * .. - */ -/* - * First define some structures that make copying misaligned data easy. - */ -typedef struct { - BYTE bytes[2]; -} _C2T_; /* Copy 2 Typedef */ - -typedef struct { - BYTE bytes[4]; -} _C4T_; /* Copy 4 Typedef */ - -typedef struct { - BYTE bytes[6]; -} _C6T_; /* Copy 6 Typedef */ - -typedef struct { - BYTE bytes[12]; -} _C12T_; /* Copy 12 Typedef */ -/* - * Now use the structures to do inline copies. - */ -#define COPY_2BYTE(src, dest) (*((_C2T_ *)(dest)) = *((_C2T_ *)(src))) -#define COPY_4BYTE(src, dest) (*((_C4T_ *)(dest)) = *((_C4T_ *)(src))) -#define COPY_6BYTE(src, dest) (*((_C6T_ *)(dest)) = *((_C6T_ *)(src))) -#define COPY_12BYTE(src, dest) (*((_C12T_ *)(dest)) = *((_C12T_ *)(src))) -/* Aliases */ -#define COPY_WORD(src, dest) COPY_2BYTE(src, dest) -#define COPY_SOCKET(src, dest) COPY_2BYTE(src, dest) - -#define COPY_LONG(src, dest) COPY_4BYTE(src, dest) -#define COPY_NET(src, dest) COPY_4BYTE(src, dest) - -#define COPY_NODE(src, dest) COPY_6BYTE(src, dest) -#define COPY_HOST(src, dest) COPY_6BYTE(src, dest) - -#define COPY_ADDRESS(src_addr, dest_addr) COPY_12BYTE(src_addr, dest_addr) - -/**************************************************************************/ - -/* - * GET_WORD(address) - * - * Description: - * Given an address of a 2 byte word in memory, - * get it without changing its byte order. - * Address may be misaligned. - * - * Purpose: - * Useful for picking a socket number out of a packet - * header without changing its byte order. - * - * Example: - * WORD socketinhiloorder; - * - * socketinhiloorder = GET_WORD(&ipxpacket->dstsocket); - * - * Note: - * Beware of side effects in address since it may be evaluated - * twice. - */ -/* - * If this machine is not strictly aligned then do a simple fetch. - * Otherwise, if the machine's byte order is hilo then do GET_HILO_WORD. - * Otherwise, get it a byte at a time. - */ -#if !defined(STRICT_ALIGNMENT) -#define GET_WORD(addr) (*(WORD *)(addr)) -#else -#if defined(HI_LO_MACH_TYPE) -#define GET_WORD(addr) GET_HILO_WORD(addr) -#else -#define GET_WORD(addr) ( \ - ((BYTE *)(addr))[0] | \ - ((BYTE *)(addr))[1] << 8 \ -) -#endif -#endif - -/* - * GET_LONG(address) - * - * Description: - * Given an address of a 4 byte long in memory, - * get it without changing its byte order. - * Address may be misaligned. - * - * Purpose: - * Useful for picking a network number out of a packet - * header without changing its byte order. - * This macro is used more than GET_HILO_LONG on - * network numbers because ipx/rip/sap generally leave - * network numbers in hilo order. - * - * Example: - * LONG networkinhiloorder; - * - * networkinhiloorder = GET_LONG(&ipxpacket->dstnetwork); - * - * Note: - * Beware of side effects in address since it may be evaluated - * four times. - */ -/* - * If this machine is not strictly aligned then do a simple fetch. - * Otherwise, if the machine's byte order is hilo then do GET_HILO_LONG. - * Otherwise, get it a byte at a time. - */ -#if !defined(STRICT_ALIGNMENT) -#define GET_LONG(addr) (*(LONG *)(addr)) -#else -#if defined(HI_LO_MACH_TYPE) -#define GET_LONG(addr) GET_HILO_LONG(addr) -#else -#define GET_LONG(addr) ( \ - ((BYTE *)(addr))[0] | \ - ((BYTE *)(addr))[1] << 8 | \ - ((BYTE *)(addr))[2] << 16 | \ - ((BYTE *)(addr))[3] << 24 \ -) -#endif -#endif - -/* - * PUT_WORD(word, address) - * - * Description: - * Given a 2 byte word and an address in memory, - * store the word in memory without changing its byte order. - * Address may be misaligned. - * - * Purpose: - * Useful for stuffing constants or variables that are already - * in hilo order in an ipxpacket in hilo order. - * Similar to COPY_WORD but works on constants and expressions - * COPY_WORD requires the src to be an address. - * - * Example: - * PUT_WORD(CONSTANT_ALREADY_IN_HILO_ORDER, &routeans->Operation) - * - * Note: - * Beware of side effects in both word and address since - * they may each be evaluated twice. - */ - -/* - * If this machine is not strictly aligned then do a simple store. - * Otherwise, if the machine's byte order is hilo then do PUT_HILO_WORD. - * Otherwise, store it a byte at a time. - */ -#if !defined(STRICT_ALIGNMENT) -#define PUT_WORD(w, addr) ( \ - *((WORD *)(addr)) = (WORD)(w) \ -) -#else -#if defined(HI_LO_MACH_TYPE) -#define PUT_WORD(w, addr) PUT_HILO_WORD(w, addr) -#else -#define PUT_WORD(w, addr) ( \ - ((BYTE *)(addr))[0] = (BYTE)(w), \ - ((BYTE *)(addr))[1] = (BYTE)((w) >> 8) \ -) -#endif -#endif - -/* - * PUT_LONG(long, address) - * - * Description: - * Given a 4 byte long and an address in memory, - * store the long in memory without changing its byte order. - * Address may be misaligned. - * - * Purpose: - * Useful for stuffing constants or variables that are already - * in hilo order in an ipxpacket in hilo order. - * Similar to COPY_LONG but works on constants and expressions. - * COPY_LONG requires the src to be an address. - * - * Example: - * PUT_LONG(network_in_hilo_order, &ipxpacket->DstNet) - * - * Note: - * Beware of side effects in both long and address since - * they may each be evaluated four times. - */ - -/* - * If this machine is not strictly aligned then do a simple store. - * Otherwise, if the machine's byte order is hilo then do PUT_HILO_LONG. - * Otherwise, store it a byte at a time. - */ -#if !defined(STRICT_ALIGNMENT) -#define PUT_LONG(l, addr) ( \ - *((LONG *)(addr)) = (LONG)(l) \ -) -#else -#if defined(HI_LO_MACH_TYPE) -#define PUT_LONG(l, addr) PUT_HILO_LONG(l, addr) -#else -#define PUT_LONG(l, addr) ( \ - ((BYTE *)(addr))[0] = (BYTE)(l), \ - ((BYTE *)(addr))[1] = (BYTE)((l) >> 8), \ - ((BYTE *)(addr))[2] = (BYTE)((l) >> 16), \ - ((BYTE *)(addr))[3] = (BYTE)((l) >> 24) \ -) -#endif -#endif - -/**************************************************************************/ - -/* - * GET_HILO_WORD(address) - * - * Description: - * Given an address of a 2 byte word in hilo order in memory, - * return its value in host order. - * Address may be misaligned. - * - * Purpose: - * Useful for dealing with length and socket number fields in - * ipx headers and fuction fields in sap and rip packets. - * - * Example: - * WORD len; - * .. - * len = GET_HILO_WORD(&ipxpacketptr->length); - * if (len > MAX_PACKET_SIZE) - * goto BadPacket; - * .. - * - * Note: - * Beware of side effects of addr since it will - * be evaluated twice. - */ -/* - * If this machine's byte order is hilo and it is not - * strictly aligned then do a simple fetch. - * Otherwise do it a byte at a time. - */ -#if defined(HI_LO_MACH_TYPE) && !defined(STRICT_ALIGNMENT) -#define GET_HILO_WORD(addr) (*(WORD *)(addr)) -#else -#define GET_HILO_WORD(addr) ((WORD) ( \ - ((BYTE *)(addr))[0] << 8 | \ - ((BYTE *)(addr))[1] \ -)) -#endif -/* Aliases */ -#define GET_LEN(ptr_to_len) GET_HILO_WORD(ptr_to_len) -#define GET_SOCKET(ptr_to_socket) GET_HILO_WORD(ptr_to_socket) - -/* - * GET_HILO_LONG(address) - * - * Description: - * Given an address of a 4 byte long in hilo order in memory, - * return its value in host order. - * Address may be misaligned. - * - * Purpose: - * Useful for dealing with network numbers in ipx packets - * when host order is required. Typically this is only - * when doing compares or other arithmetic operations. This - * is the case because ipx/router/sap usually keep network - * numbers in hilo order so a conversion to host order is - * not usually neccessary. - * - * Example: - * LONG netnumber; - * .. - * netnumber = GET_HILO_LONG(&ipxpacketptr->srcnetnumber); - * RoutineThatNeedsNetnumberInHostOrder(ipxpacket, netnumber); - * .. - * - * Note: - * Beware of side effects of address since it will - * be evaluated four times. - */ -/* - * If this machine's byte order is hilo and it is not - * strictly aligned then do a simple fetch. - * Otherwise do it a byte at a time. - */ -#if defined(HI_LO_MACH_TYPE) && !defined(STRICT_ALIGNMENT) -#define GET_HILO_LONG(addr) (*(LONG *)(addr)) -#else -#define GET_HILO_LONG(addr) ((LONG) ( \ - ((BYTE *)(addr))[0] << 24 | \ - ((BYTE *)(addr))[1] << 16 | \ - ((BYTE *)(addr))[2] << 8 | \ - ((BYTE *)(addr))[3] \ -)) -#endif - -/* - * PUT_HILO_WORD(word, address) - * PUT_LEN(word, ptr_to_len) Alias - * PUT_SOCKET(word, ptr_to_socket) Alias - * - * Description: - * Given a 2 byte word in host order and an address in memory, - * store the word in memory in hilo order. - * Address may be misaligned. - * - * Purpose: - * Useful for stuffing the length in an ipx packet and - * function in rip and sap packets. - * - * Example: - * PUT_HILO_WORD(2, &routeans->Operation) - * - * Note: - * Beware of side effects in both word and address since - * they may each be evaluated twice. - */ - -/* - * If this machine's byte order is hilo and it is not - * strictly aligned then do a simple store. - * Otherwise do it a byte at a time. - */ -#if defined(HI_LO_MACH_TYPE) && !defined(STRICT_ALIGNMENT) -#define PUT_HILO_WORD(w, addr) ( \ - *((WORD *)(addr)) = (WORD)(w) \ -) -#else -#define PUT_HILO_WORD(w, addr) ( \ - ((BYTE *)(addr))[0] = (BYTE)((w) >> 8), \ - ((BYTE *)(addr))[1] = (BYTE)(w) \ -) -#endif -/* Aliases */ -#define PUT_LEN(wrd, ptr_to_len) PUT_HILO_WORD(wrd, ptr_to_len) -#define PUT_SOCKET(wrd, ptr_to_socket) PUT_HILO_WORD(wrd, ptr_to_socket) - - - -/* - * PUT_HILO_LONG(long, address) - * - * Description: - * Given a 4 byte word in host order and an address in memory, - * store the word in memory in hilo order. - * Address may be misaligned. - * - * Purpose: - * Included for consistancy. Actual need not determined. - * Most of ipx/router/sap keep net numbers in hilo order - * so conversion is rarely needed. - * - * Note: - * Beware of side effects in both word and address since - * they may each be evaluated four times. - */ -/* - * If this machine's byte order is hilo and it is not - * strictly aligned then do a simple store. - * Otherwise do it a byte at a time. - */ -#if defined(HI_LO_MACH_TYPE) && !defined(STRICT_ALIGNMENT) -#define PUT_HILO_LONG(l, addr) ( \ - *((LONG *)(addr)) = (LONG)(l) \ -) -#else -#define PUT_HILO_LONG(l, addr) ( \ - ((BYTE *)(addr))[0] = (BYTE)((l) >> 24), \ - ((BYTE *)(addr))[1] = (BYTE)((l) >> 16), \ - ((BYTE *)(addr))[2] = (BYTE)((l) >> 8), \ - ((BYTE *)(addr))[3] = (BYTE)(l) \ -) -#endif - - -/* - * GET_LOHI_WORD(address) - * - * Description: - * Given an address of a 2 byte word in lohi order in memory, - * return its value in host order. - * Address may be misaligned. - * - * Purpose: - * Useful for dealing with length and socket number fields in - * ipx headers and fuction fields in sap and rip packets. - * - * Example: - * WORD len; - * .. - * len = GET_LOHI_WORD(&ipxpacketptr->length); - * if (len > MAX_PACKET_SIZE) - * goto BadPacket; - * .. - * - * Note: - * Beware of side effects of addr since it will - * be evaluated twice. - */ -/* - * If this machine's byte order is lohi and it is not - * strictly aligned then do a simple fetch. - * Otherwise do it a byte at a time. - */ - -#if defined(LO_HI_MACH_TYPE) && !defined(STRICT_ALIGNMENT) -#define GET_LOHI_WORD(addr) (*(WORD *)(addr)) -#else -#define GET_LOHI_WORD(addr) ( \ - ((BYTE *)(addr))[1] << 8 | \ - ((BYTE *)(addr))[0] \ -) -#endif - -/* - * GET_LOHI_LONG(address) - * - * Description: - * Given an address of a 4 byte long in lohi order in memory, - * return its value in host order. - * Address may be misaligned. - * - * Purpose: - * Useful for dealing with network numbers in ipx packets - * when host order is required. Typically this is only - * when doing compares or other arithmetic operations. This - * is the case because ipx/router/sap usually keep network - * numbers in lohi order so a conversion to host order is - * not usually neccessary. - * - * Example: - * LONG netnumber; - * .. - * netnumber = GET_LOHI_LONG(&ipxpacketptr->srcnetnumber); - * RoutineThatNeedsNetnumberInHostOrder(ipxpacket, netnumber); - * .. - * - * Note: - * Beware of side effects of address since it will - * be evaluated four times. - */ -/* - * If this machine's byte order is lohi and it is not - * strictly aligned then do a simple fetch. - * Otherwise do it a byte at a time. - */ -#if defined(LO_HI_MACH_TYPE) && !defined(STRICT_ALIGNMENT) -#define GET_LOHI_LONG(addr) (*(LONG *)(addr)) -#else -#define GET_LOHI_LONG(addr) ( \ - ((BYTE *)(addr))[3] << 24 | \ - ((BYTE *)(addr))[2] << 16 | \ - ((BYTE *)(addr))[1] << 8 | \ - ((BYTE *)(addr))[0] \ -) -#endif - -/* - * PUT_LOHI_WORD(word, address) - * - * Description: - * Given a 2 byte word in host order and an address in memory, - * store the word in memory in lohi order. - * Address may be misaligned. - * - * Purpose: - * Useful for stuffing the length in an ipx packet and - * function in rip and sap packets. - * - * Example: - * PUT_LOHI_WORD(2, &routeans->Operation) - * - * Note: - * Beware of side effects in both word and address since - * they may each be evaluated twice. - */ - -/* - * If this machine's byte order is lohi and it is not - * strictly aligned then do a simple store. - * Otherwise do it a byte at a time. - */ -#if defined(LO_HI_MACH_TYPE) && !defined(STRICT_ALIGNMENT) -#define PUT_LOHI_WORD(w, addr) ( \ - *((WORD *)(addr)) = (WORD)(w) \ -) -#else -#define PUT_LOHI_WORD(w, addr) ( \ - ((BYTE *)(addr))[1] = (BYTE)((w) >> 8), \ - ((BYTE *)(addr))[0] = (BYTE)(w) \ -) -#endif - -/* - * PUT_LOHI_LONG(long, address) - * - * Description: - * Given a 4 byte word in host order and an address in memory, - * store the long in memory in lohi order. - * Address may be misaligned. - * - * Purpose: - * Included for consistancy. Actual need not determined. - * - * Note: - * Beware of side effects in both word and address since - * they may each be evaluated four times. - */ -/* - * If this machine's byte order is lohi and it is not - * strictly aligned then do a simple store. - * Otherwise do it a byte at a time. - */ -#if defined(LO_HI_MACH_TYPE) && !defined(STRICT_ALIGNMENT) -#define PUT_LOHI_LONG(l, addr) ( \ - *((LONG *)(addr)) = (LONG)(l) \ -) -#else -#define PUT_LOHI_LONG(l, addr) ( \ - ((BYTE *)(addr))[3] = (BYTE)((l) >> 24), \ - ((BYTE *)(addr))[2] = (BYTE)((l) >> 16), \ - ((BYTE *)(addr))[1] = (BYTE)((l) >> 8), \ - ((BYTE *)(addr))[0] = (BYTE)(l) \ -) -#endif - -/****************************************************************************/ -/* - * VALUE_TO_HILO_WORD(word) - * WORD_TO_HILO(word) alias - * SOCKET_NUMBER(hostorder_sock) alias - * VALUE_FROM_HILO_WORD(word) alias - * - * Description: - * Given a word in host byte order, return its value in hilo order. - * Parameter may be a variable or constant. - * - * Purpose: - * For converting values not in memory (ie constants, register variables - * and expressions) to hilo order. - * - * Examples: - * WORD len = VALUE_TO_HILO_WORD(sizeof (struct foobar)); - * .. - * .. - * CIPXOpenThatWantsSocketInHiloOrder(SOCKET_NUMBER(0x455)); - * .. - * - * Note: - * Beware of side affects since word may be evaluated twice. - */ -#if defined(HI_LO_MACH_TYPE) -#define VALUE_TO_HILO_WORD(w) (w) -#else -#define VALUE_TO_HILO_WORD(w) ( \ - ((WORD)w & 0x00ff) << 8 | \ - ((WORD)w & 0xff00) >> 8 \ -) -#endif -/* Aliases */ -#define SOCKET_NUMBER(hostorder_sock) VALUE_TO_HILO_WORD(hostorder_sock) -#define WORD_TO_HILO(hostorder_sock) VALUE_TO_HILO_WORD(hostorder_sock) -#define VALUE_FROM_HILO_WORD(l) VALUE_TO_HILO_WORD(l) - - -/* - * VALUE_TO_HILO_LONG(long) - * LONG_TO_HILO(long) alias - * VALUE_FROM_HILO_LONG(long) alias - * - * Description: - * Given a long in host byte order, return its value in hilo order. - * Parameter may be a variable or constant. - * - * Purpose: - * For converting values not in memory (ie constants, register variables - * and expressions) to hilo order. - * - * Example: - * .. - * LONG internalnetnumberinhilo = VALUE_TO_HILO_LONG(netnumberinhostorder); - * .. - * - * Note: - * Beware of side affects since long may be evaluated twice. - */ -#if defined(HI_LO_MACH_TYPE) -#define VALUE_TO_HILO_LONG(l) (l) -#else -#define VALUE_TO_HILO_LONG(l) ( \ - ((LONG)l & 0x000000ff) << 24 | \ - ((LONG)l & 0x0000ff00) << 8 | \ - ((LONG)l & 0x00ff0000) >> 8 | \ - ((LONG)l & 0xff000000) >> 24 \ -) -#endif -/* Aliases */ -#define LONG_TO_HILO(hostorder_sock) VALUE_TO_HILO_LONG(hostorder_sock) -#define VALUE_FROM_HILO_LONG(l) VALUE_TO_HILO_LONG(l) - -/* - * VALUE_TO_LOHI_WORD(word) - * WORD_TO_LOHI(word) alias - * VALUE_FROM_LOHI_WORD(word) alias - * - * Description: - * Given a word in host byte order, return its value in lohi order. - * Parameter may be a variable or constant. - * - * Purpose: - * For converting values not in memory (ie constants, register variables - * and expressions) to lohi order. - * - * Example: - * WORD len = VALUE_TO_LOHI_WORD(sizeof (struct foobar)); - * - * Note: - * Beware of side affects since word may be evaluated twice. - */ -#if defined(LO_HI_MACH_TYPE) -#define VALUE_TO_LOHI_WORD(w) (w) -#else -#define VALUE_TO_LOHI_WORD(w) ( \ - ((WORD)w & 0x00ff) << 8 | \ - ((WORD)w & 0xff00) >> 8 \ -) -#endif -/* Aliases */ -#define WORD_TO_LOHI(w) VALUE_TO_LOHI_WORD(w) -#define VALUE_FROM_LOHI_WORD(l) VALUE_TO_LOHI_WORD(l) - - -/* - * VALUE_TO_LOHI_LONG(long) - * LONG_TO_LOHI(long) alias - * VALUE_FROM_LOHI_LONG(long) alias - * - * Description: - * Given a long in host byte order, return its value in lohi order. - * Parameter may be a variable or constant. - * - * Purpose: - * For converting values not in memory (ie constants, register variables - * and expressions) to hilo order. - * - * Example: - * .. - * LONG internalnetnumberinlohi = VALUE_TO_LOHI_LONG(netnumberinhostorder); - * .. - * - * Note: - * Beware of side affects since long may be evaluated twice. - */ -#if defined(LO_HI_MACH_TYPE) -#define VALUE_TO_LOHI_LONG(l) (l) -#else -#define VALUE_TO_LOHI_LONG(l) ( \ - ((LONG)l & 0x000000ff) << 24 | \ - ((LONG)l & 0x0000ff00) << 8 | \ - ((LONG)l & 0x00ff0000) >> 8 | \ - ((LONG)l & 0xff000000) >> 24 \ -) -#endif -/* Aliases */ -#define LONG_TO_LOHI(l) VALUE_TO_LOHI_LONG(l) -#define VALUE_FROM_LOHI_LONG(l) VALUE_TO_LOHI_LONG(l) - - -/****************************************************************************/ -/* - * COPY_TO_HILO_WORD(src, dest) - * COPY_TO_LOHI_WORD(src, dest) - * COPY_TO_HILO_LONG(src, dest) - * COPY_TO_LOHI_LONG(src, dest) - * - * aliases - * COPY_FROM_HILO_WORD(src, dest) - * COPY_FROM_LOHI_WORD(src, dest) - * COPY_FROM_HILO_LONG(src, dest) - * COPY_FROM_LOHI_LONG(src, dest) - * - * Description: - * Given the src address of a WORD or LONG in host order copy its - * contents to the dest address in HILO or LOHI order. - * - * Purpose: - * Useful for copying from one address to another when one or both - * addresses may be unaligned. - * - * Note: - * On machines where no swapping is needed this turns into a byte copy. - * Notice that the COPY_TO and COPY_FROM are identical. - */ -#if defined(HI_LO_MACH_TYPE) -#define COPY_TO_HILO_WORD(src,dest) COPY_2BYTE(src,dest) -#define COPY_TO_HILO_LONG(src,dest) COPY_4BYTE(src,dest) -#define COPY_TO_LOHI_WORD(src,dest) { \ - ((BYTE *)(dest))[0] = ((BYTE *)(src))[1]; \ - ((BYTE *)(dest))[1] = ((BYTE *)(src))[0]; \ -} - -#define COPY_TO_LOHI_LONG(src,dest) { \ - ((BYTE *)(dest))[0] = ((BYTE *)(src))[3]; \ - ((BYTE *)(dest))[1] = ((BYTE *)(src))[2]; \ - ((BYTE *)(dest))[2] = ((BYTE *)(src))[1]; \ - ((BYTE *)(dest))[3] = ((BYTE *)(src))[0]; \ -} -#else /* LO_HI_MACH_TYPE */ -#define COPY_TO_LOHI_WORD(src,dest) COPY_2BYTE(src,dest) -#define COPY_TO_LOHI_LONG(src,dest) COPY_4BYTE(src,dest) -#define COPY_TO_HILO_WORD(src,dest) { \ - ((BYTE *)(dest))[0] = ((BYTE *)(src))[1]; \ - ((BYTE *)(dest))[1] = ((BYTE *)(src))[0]; \ -} - -#define COPY_TO_HILO_LONG(src,dest) { \ - ((BYTE *)(dest))[0] = ((BYTE *)(src))[3]; \ - ((BYTE *)(dest))[1] = ((BYTE *)(src))[2]; \ - ((BYTE *)(dest))[2] = ((BYTE *)(src))[1]; \ - ((BYTE *)(dest))[3] = ((BYTE *)(src))[0]; \ -} -#endif -/* aliases */ -#define COPY_FROM_HILO_WORD(src, dest) COPY_TO_HILO_WORD(src,dest) -#define COPY_FROM_LOHI_WORD(src, dest) COPY_TO_LOHI_WORD(src,dest) -#define COPY_FROM_HILO_LONG(src, dest) COPY_TO_HILO_LONG(src,dest) -#define COPY_FROM_LOHI_LONG(src, dest) COPY_TO_LOHI_LONG(src,dest) - -/****************************************************************************/ -/* - * HOST_TO_HILO_WORD(addr) - * HOST_TO_LOHI_WORD(addr) - * HOST_TO_HILO_LONG(addr) - * HOST_TO_LOHI_LONG(addr) - * - * aliases - * HOST_FROM_HILO_WORD(addr) - * HOST_FROM_LOHI_WORD(addr) - * HOST_FROM_HILO_LONG(addr) - * HOST_FROM_LOHI_LONG(addr) - * - * Description: - * Given the address of a WORD or LONG in host order - * copy its contents to the same address in HILO or LOHI order. - * - * Purpose: - * Useful for assuring the correct endianess of a value found at addr. - * addr may be misaligned. - * - * Note: - * On machines where no swapping is needed no action is taken. - */ -#if defined(HI_LO_MACH_TYPE) -#define HOST_TO_HILO_WORD(addr) /* Nothing */ -#define HOST_TO_HILO_LONG(addr) /* Nothing */ -#define HOST_TO_LOHI_WORD(addr) { \ - BYTE temp; \ - temp = ((BYTE *)(addr))[0]; \ - ((BYTE *)(addr))[0] = ((BYTE *)(addr))[1]; \ - ((BYTE *)(addr))[1] = temp; \ -} -#define HOST_TO_LOHI_LONG(addr) { \ - BYTE temp; \ - temp = ((BYTE *)(addr))[0]; \ - ((BYTE *)(addr))[0] = ((BYTE *)(addr))[3]; \ - ((BYTE *)(addr))[3] = temp; \ - temp = ((BYTE *)(addr))[1]; \ - ((BYTE *)(addr))[1] = ((BYTE *)(addr))[2]; \ - ((BYTE *)(addr))[2] = temp; \ -} -#else /* LO_HI_MACH_TYPE */ -#define HOST_TO_LOHI_WORD(addr) /* Nothing */ -#define HOST_TO_LOHI_LONG(addr) /* Nothing */ -#define HOST_TO_HILO_WORD(addr) { \ - BYTE temp; \ - temp = ((BYTE *)(addr))[0]; \ - ((BYTE *)(addr))[0] = ((BYTE *)(addr))[1]; \ - ((BYTE *)(addr))[1] = temp; \ -} -#define HOST_TO_HILO_LONG(addr) { \ - BYTE temp; \ - temp = ((BYTE *)(addr))[0]; \ - ((BYTE *)(addr))[0] = ((BYTE *)(addr))[3]; \ - ((BYTE *)(addr))[3] = temp; \ - temp = ((BYTE *)(addr))[1]; \ - ((BYTE *)(addr))[1] = ((BYTE *)(addr))[2]; \ - ((BYTE *)(addr))[2] = temp; \ -} -#endif -/* aliases */ -#define HOST_FROM_HILO_WORD(addr) HOST_TO_HILO_WORD(addr) -#define HOST_FROM_LOHI_WORD(addr) HOST_TO_LOHI_WORD(addr) -#define HOST_FROM_HILO_LONG(addr) HOST_TO_HILO_LONG(addr) -#define HOST_FROM_LOHI_LONG(addr) HOST_TO_LOHI_LONG(addr) - -/****************************************************************************/ - -/* - * ARE_4BYTES_EQUAL(addr1, addr2) - * NET_EQUAL(addr1, addr2) alias - * - * ARE_6BYTES_EQUAL(addr1, addr2) - * NODE_EQUAL(addr1, addr2) alias - * HOST_EQUAL(addr1, addr2) alias - * - * ARE_12BYTES_EQUAL(addr1, addr2) - * ADDRESS_EQUAL(addr1, addr2) alias - * - * Description: - * Compare 2, 4, 6 or 12 bytes of misaligned data and return true - * if they are equal. - * - * Purpose: - * Useful for comparing ipx net, nodes or complete ipx addresses. - * - * Note: - * It is assumed that 2 byte versions are not very - * useful. In these cases usually at least one of the values - * will be in variable and a compare can be done by doing - * the appropriate "GET" and an ==. - */ - -#define ARE_2BYTES_EQUAL(addr1, addr2) ( \ - ((BYTE *)(addr1))[0] == ((BYTE *)(addr2))[0] && \ - ((BYTE *)(addr1))[1] == ((BYTE *)(addr2))[1] \ -) - -#define ARE_4BYTES_EQUAL(addr1, addr2) ( \ - ((BYTE *)(addr1))[0] == ((BYTE *)(addr2))[0] && \ - ((BYTE *)(addr1))[1] == ((BYTE *)(addr2))[1] && \ - ((BYTE *)(addr1))[2] == ((BYTE *)(addr2))[2] && \ - ((BYTE *)(addr1))[3] == ((BYTE *)(addr2))[3] \ -) - -#define ARE_6BYTES_EQUAL(addr1, addr2) ( \ - ((BYTE *)(addr1))[0] == ((BYTE *)(addr2))[0] && \ - ((BYTE *)(addr1))[1] == ((BYTE *)(addr2))[1] && \ - ((BYTE *)(addr1))[2] == ((BYTE *)(addr2))[2] && \ - ((BYTE *)(addr1))[3] == ((BYTE *)(addr2))[3] && \ - ((BYTE *)(addr1))[4] == ((BYTE *)(addr2))[4] && \ - ((BYTE *)(addr1))[5] == ((BYTE *)(addr2))[5] \ -) - -#define ARE_12BYTES_EQUAL(addr1, addr2) ( \ - ((BYTE *)(addr1))[0] == ((BYTE *)(addr2))[0] && \ - ((BYTE *)(addr1))[1] == ((BYTE *)(addr2))[1] && \ - ((BYTE *)(addr1))[2] == ((BYTE *)(addr2))[2] && \ - ((BYTE *)(addr1))[3] == ((BYTE *)(addr2))[3] && \ - ((BYTE *)(addr1))[4] == ((BYTE *)(addr2))[4] && \ - ((BYTE *)(addr1))[5] == ((BYTE *)(addr2))[5] && \ - ((BYTE *)(addr1))[6] == ((BYTE *)(addr2))[6] && \ - ((BYTE *)(addr1))[7] == ((BYTE *)(addr2))[7] && \ - ((BYTE *)(addr1))[8] == ((BYTE *)(addr2))[8] && \ - ((BYTE *)(addr1))[9] == ((BYTE *)(addr2))[9] && \ - ((BYTE *)(addr1))[10] == ((BYTE *)(addr2))[10] && \ - ((BYTE *)(addr1))[11] == ((BYTE *)(addr2))[11] \ -) -/* Aliases */ -#define WORD_EQUAL(addr1, addr2) ARE_2BYTES_EQUAL(addr1, addr2) - -#define NET_EQUAL(addr1, addr2) ARE_4BYTES_EQUAL(addr1, addr2) -#define LONG_EQUAL(addr1, addr2) ARE_4BYTES_EQUAL(addr1, addr2) - -#define NODE_EQUAL(addr1, addr2) ARE_6BYTES_EQUAL(addr1, addr2) -#define HOST_EQUAL(addr1, addr2) ARE_6BYTES_EQUAL(addr1, addr2) - -#define ADDRESS_EQUAL(addr1, addr2) ARE_12BYTES_EQUAL(addr1, addr2) - - -/*****************************************************************************/ -/*****************************************************************************/ -#endif /* __PORTABLE_H__ */ diff --git a/include/nwnss/support/lnxmbINC/procdefs.h b/include/nwnss/support/lnxmbINC/procdefs.h deleted file mode 100644 index 14d51b9..0000000 --- a/include/nwnss/support/lnxmbINC/procdefs.h +++ /dev/null @@ -1,23 +0,0 @@ -/**************************************************************************** - | - | Derived from Novell NSS procdefs.h for libnwnss userland builds. - | This wrapper keeps the NSS include name without pulling Linux kernel MPK - | headers into NSS userspace. - | - | This program is free software; you can redistribute it and/or modify it - | under the terms of version 2 of the GNU General Public License as - | published by the Free Software Foundation. - | - +-------------------------------------------------------------------------*/ -#ifndef _PROCDEFS_H_ -#define _PROCDEFS_H_ - -#ifndef _OMNI_H_ -# include -#endif - -#ifndef ASSERT_MPKNSS_LOCK -# define ASSERT_MPKNSS_LOCK() ((void)0) -#endif - -#endif /* _PROCDEFS_H_ */ diff --git a/include/nwnss/support/lnxmbINC/scs.h b/include/nwnss/support/lnxmbINC/scs.h deleted file mode 100644 index 8b13789..0000000 --- a/include/nwnss/support/lnxmbINC/scs.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/nwnss/support/lnxmbINC/setparms.h b/include/nwnss/support/lnxmbINC/setparms.h deleted file mode 100644 index 6fb95ac..0000000 --- a/include/nwnss/support/lnxmbINC/setparms.h +++ /dev/null @@ -1,253 +0,0 @@ -#ifndef __SETPARMS_H__ -#define __SETPARMS_H__ - -/***************************************************************************** - * - * (C) Copyright 1988-2002 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - ****************************************************************************/ - -///////////////////////////////////////////////////////////////////////////// -// Exported APIS // -///////////////////////////////////////////////////////////////////////////// - -extern int CheckSetParameterValue(char *varName, int valueTextFlag, char *value); - -extern LONG RegisterSetParameterCategory( - LONG moduleHandle, - struct ResourceTagStructure *RTag, - BYTE *newCategoryName, - LONG *categoryNumber); - -extern LONG DeRegisterSetParameterCategory( - LONG moduleHandle, - struct ResourceTagStructure *RTag, - BYTE *delCategoryName); - -extern LONG RegisterSetParameter( - LONG moduleHandle, - struct ResourceTagStructure *RTag, - LONG categoryNumber, - void (*spControlProcedure)(LONG oldValue), - LONG spFlags, - LONG *spParameter, - BYTE *spParameterName, - BYTE *spParameterDescription, - LONG spParameterType, - LONG spLowerLimit, - LONG spUpperLimit); - -extern LONG DeRegisterSetParameter( - LONG moduleHandle, - struct ResourceTagStructure *RTag, - LONG categoryNumber, - BYTE *ParameterName); - -extern LONG ReturnSetParameterCategoryInfo( - LONG infoLevel, - LONG *totalCategories, - ...); - -extern LONG GetSetableParameterValue( - LONG Station, - BYTE *setableParameterString, /* NULL terminated */ - void *returnValue); -extern LONG GetSetableParameterValueEx( - BYTE *setableParameterString, - void *returnValue, - int *returnType); - -extern LONG SetSetableParameterValue( - LONG Station, - BYTE *setableParameterString, /* NULL terminated */ - void *newValue); - -extern LONG ScanSetableParameters( - LONG scanCategory, /* -1 for all, COMMUNICATIONS, MEMORY, etc */ - LONG *scanSequence, /* 0 for first time */ - BYTE *rParameterName, - LONG *rType, /* 0 = number, 1 = boolean, 2 = time ticks., etc */ - LONG *rFlags, /* STARTUP, HIDE, etc */ - LONG *rCategory, /* COMMUNICATIONS, MEMORY, etc */ - void *rParameterDescription, /* description string */ - void *rCurrentValue, - LONG *rLowerLimit, - LONG *rUpperLimit); - -extern LONG IsSetableParameterPersistent( - LONG Station, - BYTE *setableParameterString); - -extern LONG ProcessSetCommandForNextReboot(BYTE *commandLine); - -extern LONG ResetSetableParameterValue( - LONG Station, - BYTE *setableParameterString); - -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// - -#define SET_PARAMETER_UPGRADE_TO_V3 1 - - -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// - -#define MaximumSetParameterNameLength 96 -#define MaximumTypeStringLength (128+64) // If the string is larger -- then setparm is marked as non-persistent - - -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -/* define the parameter types. */ -#define SP_TYPE_NUMBER 0 -#define SP_TYPE_BOOLEAN 1 // BOOLEAN (size is UINT8) *************** DO NOT USE FOR NEW SET PARMS -#define SP_TYPE_TICKS 2 -#define SP_TYPE_BLOCK_SHIFT 3 -#define SP_TYPE_TIME_OFFSET 4 /* [+|-]hh:mm:ss converted to seconds */ -#define SP_TYPE_STRING 5 // MaximumTypeStringLength, if longer than max, the set parm marked not persistent -#define SP_TYPE_TRIGGER 6 -#define SP_TYPE_BOOLEAN_UINT32 7 // BOOLEAN (size is UINT32) ******* NEW SET PARMS SHOULD USE THIS BOOLEAN DEFINITION - - -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -/* define the flags. */ -#define SP_STARTUP_ONLY 0x00000001 -#define SP_HIDE 0x00000002 -#define SP_ADVANCED 0x00000004 -#define SP_STARTUP_OR_LATER 0x00000008 -#define SP_NOT_SECURED_CONSOLE 0x00000010 /* Can't be performed on secured console*/ -#define SP_RPC_LOCKOUT 0x00000020 /* Lockout Console RPC from changing value */ -#define SP_STARTUP_PREFERRED 0x00000040 /* Used with SP_STARTUP_OR_LATER to indicate preferred place to set the parameter is in STARTUP.NCF */ -#define SPValueNotPersistentFlag 0x00000080 /* Indicates that this set parm. is not persistent */ -#define SPDontUpperCaseCmdLineFlag 0x00000100 /* indicates to use standard command line -- not upper case copy when setting value */ -#define SPCallBackStartupCallable 0x00010000 /* Indicates that the call back routine can be call while being registered */ - -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -// The following flags are for internal use only -#define SPOwnerFlag 0x01000000 /* Used to indicate that the set parameter has been registered by an nlm */ -#define SPDefaultValuePresentFlag 0x02000000 -#define SPPendingValuePresentFlag 0x04000000 -#define SPDirtyFlag 0x08000000 -#define SPReadOnlyFlag 0x10000000 -#define SPRegisteredFromRegistryFlag 0x20000000 /* used to indicate that set parameter was initially registered from the registry */ -#define SPRegByCategoryName 0x40000000 /* when reg. set parm, category number is ptr to category name */ -#define SPOldStyleFlag 0x80000000 - -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -#define SP_VALUE_FLAGS_MASK (SP_STARTUP_ONLY | SP_ADVANCED | SP_STARTUP_OR_LATER | SP_NOT_SECURED_CONSOLE | SP_RPC_LOCKOUT | SP_STARTUP_PREFERRED | SPValueNotPersistentFlag | SPDontUpperCaseCmdLineFlag) -#define SP_FLAGS_1 (SP_STARTUP_ONLY | SP_HIDE | SP_ADVANCED | SP_STARTUP_OR_LATER | SP_STARTUP_PREFERRED | SP_NOT_SECURED_CONSOLE | SP_RPC_LOCKOUT) -#define SP_FLAGS_2 (SPOldStyleFlag | SPCallBackStartupCallable | SPValueNotPersistentFlag | SPDontUpperCaseCmdLineFlag) -#define SP_FLAGS_MASK (SP_FLAGS_1 | SP_FLAGS_2) - - -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -/* * * * * * * * * * * * * * WARNING * * * * * * * * * * * * * * * * -* -* DO NOT USE THIS STRUCTURE -- ONLY FOR Old Set Parameter Registration (backwards compatability) -* -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -struct SetableParametersStructure -{ - struct SetableParametersStructure *SPLink; - LONG *SPParameter; - struct ResourceTagStructure *SPResourceTag; - void *SPParameterName; - BYTE SPParameterType; /* 0 = number, 1 = boolean, 2 = time ticks. */ - BYTE SPFlags; - BYTE SPCategory; - BYTE SPUnUsed; - LONG SPLowerLimit; - LONG SPUpperLimit; - void (*SPCallBackProcedure)(LONG oldValue); - void *SPParameterDescription; - WORD SPParmNameMsgNum; /* Message number for parameter name */ - WORD SPParmDescMsgNum; /* Message number for parameter description */ -}; -/* --------------------------------------------------------------------------- */ - -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -#if SET_PARAMETER_UPGRADE_TO_V3 -///////////////////////////////////////////////////////////////////////////// -// NW6 // -///////////////////////////////////////////////////////////////////////////// -#define SET_PARMS_VERSION_NUMBER 3 -#define SP_COMMUNICATIONS 0 -#define SP_MEMORY 1 -#define SP_LOCKS 5 -#define SP_DISK 7 -#define SP_TIME 8 -#define SP_NCP 9 -#define SP_MISCELLANEOUS 10 -#define SP_ERRORS 11 -#define SP_DIRECTORY_SERVICES 12 -#else -///////////////////////////////////////////////////////////////////////////// -// NW5 // -///////////////////////////////////////////////////////////////////////////// -#define SET_PARMS_VERSION_NUMBER 2 -#define SP_COMMUNICATIONS 0 -#define SP_MEMORY 1 -#define SP_FILE_CACHE 2 -#define SP_DIR_CACHE 3 -#define SP_FILE_SYSTEM 4 -#define SP_LOCKS 5 -#define SP_TRANSACTION_TRACKING 6 -#define SP_DISK 7 -#define SP_TIME 8 -#define SP_NCP 9 -#define SP_MISCELLANEOUS 10 -#define SP_ERRORS 11 -#define SP_DIRECTORY_SERVICES 12 -#endif // SET_PARAMETER_UPGRADE_TO_V3 - -//////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// -#define MIN_OS_MIN_SERVICE_PROCS 10 -#define MAX_OS_MIN_SERVICE_PROCS 500 -#define MIN_OS_MAX_SERVICE_PROCS 5 -#define MAX_OS_MAX_SERVICE_PROCS 1000 -//////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// - - -#endif /* __SETPARMS_H__ */ diff --git a/include/nwnss/support/lnxmbINC/subjects.h b/include/nwnss/support/lnxmbINC/subjects.h deleted file mode 100644 index ec88449..0000000 --- a/include/nwnss/support/lnxmbINC/subjects.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef __SUBJECTS_H__ -#define __SUBJECTS_H__ -/***************************************************************************** - * - * (C) Copyright 1989-1994 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Revision: 465 $ - * - ****************************************************************************/ - -/* - ID is built as Subject.Instance - Known Subjects -*/ - -#define ServerSubjects 0x00010000 -#define MemorySubjects 0x00020000 -#define NCPSubjects 0x00030000 -#define OSSubjects 0x00040000 -#define CommunicationSubjects 0x00050000 -#define FileSystemSubjects 0x00060000 -#define AdaptorSubjects 0x00070000 -#define QueueSubjects 0x00080000 -#define ConnectionSubjects 0x00090000 -#define VolumeMgrSubjects 0x000A0000 -#define MediaManagerSubjects 0x000B0000 -#define SetCmdSubjects 0x000C0000 -#define NLMSubjects 0x000D0000 -#define TTSSubjects 0x000E0000 -#define LocksSubjects 0x000F0000 -#define CompressionSubjects 0x00100000 -#define SFTIIISubjects 0x00110000 -#define VirtualMemorySubjects 0x00120000 -#define MPKSubjects 0x00130000 - -/****************************************************************************/ -/****************************************************************************/ - - -#endif /* __SUBJECTS_H__ */ diff --git a/include/nwnss/support/lnxmbINC/task.h b/include/nwnss/support/lnxmbINC/task.h deleted file mode 100644 index 03122f8..0000000 --- a/include/nwnss/support/lnxmbINC/task.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef __TASK_H__ -#define __TASK_H__ -/***************************************************************************** - * - * (C) Copyright 1993-1994 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Revision: 465 $ - * - ****************************************************************************/ - -/* Define internal task numbers */ -#define SYS_TASK 1 -#define AUDIT_TASK 2 -#define ACCOUNT_TASK 3 -#define TTS_TASK 4 -#define MIGRATION_TASK 5 /* defect #274960 - RDoxey */ -#define IOENGINE_TASKS 10 /* thru 19 (currently only uses 10 & 11) */ -#define COMPRESSION_TASK 20 -#define DECOMPRESSION_TASK 21 -#define REGISTRY_TASK 25 -#define VM_TASK 30 -#define UNICODE_TASK 35 -#define POLIMGR_TASK 40 /* SPD # 204499 Jim A. Nicolet 7-28-98 */ -#define NSS_TASK 50 /* SPD # 205892 RDoxey 8-6-98 */ -#define DS_TASK 55 /* Directory Services */ -#define SLP_TASK 60 /* SLP Services */ -#define SMTP_MAIL_TASK 65 /* smtp mail services Jim A. Nicolet */ -#define MASV_TASK 70 /* defect #274960 - RDoxey */ -#define NCP_TASK 75 /* defect #293519 - RDoxey */ -#define LIBRARY_TASK 80 /* task for LIBC and CLIB - RDoxey*/ -#define QTASK 254 /* 0xFE */ -#define WINSOCK_TASK 97 /* For Winsock suite */ -#define LOGGER_TASK 100 -#define BOOT_LOG_TASK 110 /* task for the boot$log.err file - RDoxey*/ -#define SETPARMS_TASK 120 - -/****************************************************************************/ -/****************************************************************************/ - - -#endif /* __TASK_H__ */ diff --git a/include/nwnss/support/lnxmbINC/version.h b/include/nwnss/support/lnxmbINC/version.h deleted file mode 100644 index b1c669b..0000000 --- a/include/nwnss/support/lnxmbINC/version.h +++ /dev/null @@ -1,4 +0,0 @@ - -/* -* File: .../support/lnxmbINC/version.h -**/ diff --git a/include/nwnss/support/lnxmbINC/volstruc.h b/include/nwnss/support/lnxmbINC/volstruc.h deleted file mode 100644 index b4c86c2..0000000 --- a/include/nwnss/support/lnxmbINC/volstruc.h +++ /dev/null @@ -1,336 +0,0 @@ -#ifndef __VOLSTRUC_H__ -#define __VOLSTRUC_H__ -/***************************************************************************** - * - * (C) Copyright 1988-1994 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $RCSfile$ - * $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ - * $Revision: 465 $ - * - ****************************************************************************/ - -#define MaximumVolumeMappingTableSize 255 - -#define NumberOfJumpRoutines 140 -#define NumberOfAttrHandles 32 -#define VolumeMappingError 152 - -typedef struct VolumeStructure -{ - LONG handle; - LONG volumestatus; - LONG volumeinstance; - BYTE volumename[64]; - LONG filesystemid; - LONG filesystemhandle; - BYTE *filesystemname; - LONG (*filesystempollroutine)(); - LONG (*filesystemabortroutine)(); - - LONG (*LFS_CreateDirectory)(); /* 1 */ - LONG (*LFS_DeleteDirectory)(); - LONG (*LFS_MapPathToDirectoryNumber)(); - LONG (*LFS_EraseFile)(); - LONG (*LFS_ModifyDirectoryEntry)(); - LONG (*LFS_RenameEntry)(); - LONG (*LFS_GetAccessRights)(); - LONG (*LFS_GetAccessRightsFromIDs)(); - LONG (*LFS_MapDirectoryNumberToPath)(); - LONG (*LFS_GetEntryFromPathStringBa)(); /* 10 */ - LONG (*LFS_GetOtherNameSpaceEntry)(); - LONG (*LFS_DirectorySearch)(); - LONG (*LFS_GetExtendedDirectoryInfo)(); - LONG (*LFS_GetParentDirectoryNumber)(); - LONG (*LFS_AddTrusteeRights)(); - LONG (*LFS_ScanTrusteeRights)(); - LONG (*LFS_DeleteTrusteeRights)(); - LONG (*LFS_PurgeTrustee)(); - LONG (*LFS_FindNextTrusteeReference)(); - LONG (*LFS_ScanUserRestrictionNodes)(); /* 20 */ - LONG (*LFS_AddUserRestriction)(); - LONG (*LFS_DeleteUserRestriction)(); - LONG (*LFS_ReturnDirectorySpaceRest)(); - LONG (*LFS_GetActualAvailableDiskSp)(); - LONG (*LFS_CountOwnedFilesAndDirect)(); - LONG (*LFS_ScanDeletedFiles)(); - LONG (*LFS_SalvageDeletedFile)(); - LONG (*LFS_PurgeDeletedFile)(); - LONG (*LFS_OpenFile)(); - LONG (*LFS_CreateFile)(); /* 30 */ - LONG (*LFS_CreateAndOpenFile)(); - LONG (*LFS_MigrateFile)(); - LONG (*LFS_DeMigrateFile)(); - LONG (*LFS_MigratedFileInformation)(); - LONG (*LFS_VolumeMigrationInformation)(); - LONG (*LFS_ReadMigratedFileData)(); - LONG (*LFS_ReadFile)(); - LONG (*LFS_WriteFile)(); - LONG (*LFS_ASyncStartReadFile)(); - LONG (*LFS_ASyncDoReadFile)(); /* 40 */ - LONG (*LFS_ASyncStartWriteFile)(); - LONG (*LFS_ASyncDoWriteFile)(); - LONG (*LFS_ASyncCheckWriteThrough)(); - LONG (*LFS_NewGetVolumeInfo)(); - LONG (*LFS_MapPathToDirectoryNumberOrPhantom)(); - LONG (*LFS_StationHasAccessRightsGrantedBelow)(); - LONG (*LFS_GetDataStreamLengthsFromPathString)(); - LONG (*LFS_CheckAndGetDirectoryEntry)(); - LONG (*LFS_GetDeletedEntry)(); - LONG (*LFS_GetOriginalNameSpace)(); /* 50 */ - LONG (*LFS_GetActualFileSize)(); - LONG (*LFS_VerifyNameSpaceNumber)(); - LONG (*LFS_VerifyDataStreamNumber)(); - LONG (*LFS_CheckVolumeNumber)(); - LONG (*LFS_GetFileSize)(); - LONG (*LFS_ReadFileNoCheck)(); - LONG (*LFS_SetFileTimeAndDateStamp)(); - LONG (*LFS_GetFileHoles)(); - LONG (*LFS_GetHandleInfoData)(); - LONG (*LFS_CloseFile)(); /* 60 */ - LONG (*LFS_CommitFile)(); - LONG (*LFS_VMGetDirectoryEntry)(); - LONG (*LFS_CreateDataMigratedFileEntry)(); - LONG (*LFS_RenameNameSpaceEntry)(); - LONG (*LFS_CancelFileLockWait)(); - LONG (*LFS_CheckAndSetSingleFileLock)(); - LONG (*LFS_ReleaseSingleFileLock)(); - LONG (*LFS_EnumerateFileLocks)(); - LONG (*LFS_CheckAndSetFileLocks)(); - LONG (*LFS_BackoutFileLocks)(); /* 70 */ - LONG (*LFS_UnenumerateFileLocks)(); - LONG (*LFS_ReleaseFile)(); - LONG (*LFS_CheckAndSetSingleRecordLock)(); - LONG (*LFS_ReleaseSingleRecordLock)(); - LONG (*LFS_EnumerateRecordLocks)(); - LONG (*LFS_CheckAndSetRecordLocks)(); - LONG (*LFS_BackoutRecordLocks)(); - LONG (*LFS_UnenumerateRecordLocks)(); - LONG (*LFS_ReleaseRecordLocks)(); - LONG (*LFS_SetVolumeFlags)(); /* 80 */ - LONG (*LFS_ClearVolumeFlags)(); - LONG (*LFS_GetOriginalInfo)(); - LONG (*LFS_CreateMigratedDir)(); - LONG (*LFS_F3OpenCreate)(); - LONG (*LFS_F3InitFileSearch)(); - LONG (*LFS_F3ContinueFileSearch)(); - LONG (*LFS_F3RenameFile)(); - LONG (*LFS_F3ScanForTrustees)(); - LONG (*LFS_F3ObtainFileInfo)(); - LONG (*LFS_F3ModifyInfo)(); /*90*/ - LONG (*LFS_F3EraseFile)(); - LONG (*LFS_INWGetVolumeInformation)(); - LONG (*LFS_F3AddTrustees)(); - LONG (*LFS_F3DeleteTrustees)(); - LONG (*LFS_GetActiveVolumeIOs)(); - LONG (*LFS_F3ScanSalvagedFiles)(); - LONG (*LFS_F3RecoverSalvagedFiles)(); - LONG (*LFS_F3PurgeSalvageableFile)(); - LONG (*LFS_F3GetNSSpecificInfo)(); - LONG (*LFS_F3ModifyNSSpecificInfo)(); /*100*/ - LONG (*LFS_F3SearchSet)(); - LONG (*LFS_F3GetDirBase)(); - LONG (*LFS_F3QueryNameSpaceInfo)(); - LONG (*LFS_F3GetNameSpaceList)(); - LONG (*LFS_F3GetHugeInfo)(); - LONG (*LFS_F3SetHugeInfo)(); - LONG (*LFS_F3GetFullPathString)(); - LONG (*LFS_F3GetEffectiveDirectoryRights)(); - LONG (*LFS_ParseTree)(); - LONG (*LFS_GetReferenceCountFromEntry)(); /* 110 */ - LONG (*LFS_SetOwningNameSpace)(); - LONG (*LFS_GetHandleInfo)(); - LONG (*LFS_GetFileInfoFromHandle)(); - LONG (*LFS_RemoveFile)(); - LONG (*LFS_RemoveFileCompletely)(); - LONG (*LFS_GetNameSpaceInformation)(); - LONG (*LFS_ClearPhantom)(); - LONG (*LFS_GetMaximumUserRestriction)(); - LONG (*LFS_GetCurrentDiskUsedAmount)(); - LONG (*LFS_FlushVolume)(); /* 120 */ - LONG (*LFS_SetCompressedFileSize)(); - LONG (*LFS_OpenEAHandle)(); /* 122 */ - LONG (*LFS_CloseEAHandle)(); /* 123 */ - LONG (*LFS_CleanEAHandle)(); /* 124 */ - LONG (*LFS_CheckAndDeleteEAHandle)(); /* 125 */ - LONG (*LFS_WriteEAData)(); /* 126 */ - LONG (*LFS_ReadEAData)(); /* 127 */ - LONG (*LFS_EnumEA)(); /* 128 */ - LONG (*LFS_AddNameSpace)(); /* 129 */ - LONG (*LFS_DismountVolume)(); /* 130 */ - LONG (*LFS_CheckVolumeForObjectID)(); /* 131 */ - LONG (*LFS_ModifyDOSAttributes)(); /* 132 */ - LONG (*LFS_UpdateDirectory)(); /* 133 */ - LONG (*LFS_GetRawFileSize)(); /* 134 */ - LONG (*LFS_SetVolumeObjectID)(); /* 135 */ - LONG (*LFS_GetVolumeOwnerRestrictionNodes)(); /* 136 */ - LONG (*LFS_F3OpenCreateEx)(); /* 137*/ /*defect 100253657 - RDoxey*/ - LONG reserved[3]; -} volumetype; - -typedef struct volinfodef -{ - LONG volumestatus; - LONG volumeinstance; - BYTE volumename[64]; - LONG filesystemid; -} volinfotype; - -typedef struct volumerequestdef -{ - LONG reserved[5]; - LONG volumenumber; - LONG stamp; - struct resourcetagdef *resourcetag; - - struct resourcetagdef *resourcetagnext; - struct resourcetagdef *resourcetaglast; - LONG callbackparameter; - void (*callbackroutine)(); - - LONG function; - LONG parameter1; - LONG parameter2; - LONG parameter3; -} volumerequesttype; - -typedef struct resourcetagdef -{ - LONG reserved[2]; - LONG signature; - LONG count; - struct resourcetagdef *resourcetagnext; - struct resourcetagdef *resourcetaglast; -} resourcetagtype; - -typedef struct eventdef -{ - LONG reserved1; - LONG timeout; - LONG reserved2; - void (*routine)(); - - struct resourcetagdef *resourcetag; - LONG reserved3; - LONG parameter0; - LONG parameter1; - - LONG parameter2; - LONG parameter3; -} eventtype; - -#define ACTIVEVOLUMEREQUEST 0x52455356 -#define ABORTEDVOLUMEREQUEST 0x53564241 - -/* Novell assigned file system numbers */ - -#define NETWARE386FILESYSTEM 0x00000001 -#define NETWARENFSFILESYSTEM 0x00000002 -#define NETWARENSSFILESYSTEM 0x00000003 -#define NETWARECDROMFILESYSTEM 0x70000001 -#define IBM_SMB_LAN_SERV_FS 0xf0000001 - -////////////////////////////////////////////////////////////////////////////////////// -/* volume status bits */ -////////////////////////////////////////////////////////////////////////////////////// -#define VOLUME_ONLINE_BIT 0x00000001 -#define VOLUME_COMING_ONLINE_BIT 0x00000004 -#define VOLUME_MOUNTED_BIT 0x00000002 -#define VOLUME_BEING_MOUNTED_BIT 0x00000008 - -#define VOLUME_MASK1 (VOLUME_ONLINE_BIT | VOLUME_COMING_ONLINE_BIT | VOLUME_MOUNTED_BIT | VOLUME_BEING_MOUNTED_BIT) - -////////////////////////////////////////////////////////////////////////////////////// -#define VOLUME_NEEDS_REPAIRING_BIT 0x00000010 -#define VOLUME_BEING_REPARED_BIT 0x00000020 -#define VOLUME_HOTFIXED_BIT 0x00000040 -#define VOLUME_HOTFIX_OK_BIT 0x00000080 - -#define VOLUME_MASK2 (VOLUME_NEEDS_REPAIRING_BIT | VOLUME_BEING_REPARED_BIT | VOLUME_HOTFIXED_BIT | VOLUME_HOTFIX_OK_BIT) - -////////////////////////////////////////////////////////////////////////////////////// -#define VOLUME_MIRRORED_BIT 0x00000100 -#define VOLUME_MIRRORS_OK_BIT 0x00000200 -#define VOLUME_PARITIED_BIT 0x00000400 -#define VOLUME_PARITY_OK_BIT 0x00000800 - -#define VOLUME_MASK3 (VOLUME_MIRRORED_BIT | VOLUME_MIRRORS_OK_BIT | VOLUME_PARITIED_BIT | VOLUME_PARITY_OK_BIT) - - -////////////////////////////////////////////////////////////////////////////////////// -#define VOLUME_IS_READONLY_BIT 0x00010000 -#define VOLUME_TTS_AVAILABLE_BIT 0x00020000 -#define VOLUME_TTS_OK_BIT 0x00040000 -//#define VOLUME_IS_REMOTE_BIT 0x00890000 - -#define VOLUME_MASK4 (VOLUME_IS_READONLY_BIT | VOLUME_TTS_AVAILABLE_BIT | VOLUME_TTS_OK_BIT) - - -////////////////////////////////////////////////////////////////////////////////////// -#define VOLUME_DATA_MIGRATION_BIT 0x01000000 -#define VOLUME_COMPRESSION_BIT 0x02000000 -#define VOLUME_SUB_ALLOC_BIT 0x04000000 -#define VOLUME_IMMEDIATE_PURGE_BIT 0x08000000 - -#define VOLUME_MASK5 (VOLUME_DATA_MIGRATION_BIT | VOLUME_COMPRESSION_BIT | VOLUME_SUB_ALLOC_BIT | VOLUME_IMMEDIATE_PURGE_BIT) - -////////////////////////////////////////////////////////////////////////////////////// -#define VOLUME_HIDDEN_BIT 0x80000000 - -#define VOLUME_MASK6 (VOLUME_HIDDEN_BIT) - -////////////////////////////////////////////////////////////////////////////////////// -#define VALID_VOLUME_STATUS_BITS_MASK (VOLUME_MASK1|VOLUME_MASK2|VOLUME_MASK3|VOLUME_MASK4|VOLUME_MASK5|VOLUME_MASK6) - -/* Volume function codes */ - -#if !defined(NSS_USERSPACE) -#define VOLUME_ONLINE 0 -#define VOLUME_OFFLINE 1 -#define VOLUME_MOUNT 2 -#define VOLUME_DISMOUNT 3 -#define VOLUME_DELETE 4 -#define VOLUME_RENAME 5 -#define VOLUME_REPAIR 6 -#define VOLUME_GET_STATS 7 -#endif - - -/* volume manager routine error codes */ - -#define SUCCESSFUL 0x0000 -#define MEMORY_ALLOCATION_ERROR 0x1001 -#define TRUNCATION_ERROR 0x1002 -#define VOLUME_TABLE_FULL 0x1003 -#define INVALID_PARAMETERS 0x1004 -#define INVALID_STATE 0x1005 -#define UNSUPPORTED_FUNCTION 0x1006 - -extern BYTE *NW386FileSystemString; -extern volumetype VolumeRecoveryStructure; -extern volumetype **VolumeMappingTable; -extern volumetype **OverflowVolumeMappingTable; -extern LONG VolumeMappingTableSize; -extern LONG OverflowVolumeMappingTableSize; - -/****************************************************************************/ -/****************************************************************************/ - - -#endif /* __VOLSTRUC_H__ */ diff --git a/include/nwnss/support/ndssdkINC_kern/dconst.h b/include/nwnss/support/ndssdkINC_kern/dconst.h deleted file mode 100644 index 32cf40f..0000000 --- a/include/nwnss/support/ndssdkINC_kern/dconst.h +++ /dev/null @@ -1,264 +0,0 @@ -/***************************************************************************** - * - * (C) Copyright 2004 Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * Name: dconst.h - * %version: 13 % - * %created_by: bjarvis % - * %date_modified: Tue Nov 10 16:09:39 1998 % - * - ****************************************************************************/ - -#ifndef DCONST_H -#define DCONST_H - -/* maximum number of characters in names, not including terminator */ -#define MAX_RDN_CHARS 128 -#define MAX_DN_CHARS 256 -#define MAX_SCHEMA_NAME_CHARS 32 -#define MAX_TREE_NAME_CHARS 32 -#define MAX_SAP_NAME_CHARS 47 - -#define MAX_OS_NAME_CHARS 32 -#define MAX_VENDOR_NAME_CHARS 32 -#define MAX_HARDWARE_NAME_CHARS 32 - -/* maximum size of unicode names, including terminator */ -#define MAX_RDN_BYTES (2*(MAX_RDN_CHARS + 1)) -#define MAX_DN_BYTES (2*(MAX_DN_CHARS + 1)) -#define MAX_SCHEMA_NAME_BYTES (2*(MAX_SCHEMA_NAME_CHARS + 1)) - -#define MAX_ASN1_NAME 32 -#define MAX_VALUE (63U * 1024U) -#define MAX_VALUES_IN_RDN (MAX_RDN_CHARS / 2) -#define MAX_RDNS_IN_DN (MAX_DN_CHARS / 2 + 1) -#define MAX_TUNED_NAME_SIZE (12 + MAX_DN_BYTES + 20 * MAX_RDNS_IN_DN) -#define MAX_LOCAL_CHAR_SIZE 5 /* escape and 4 hex digits */ -#define MAX_LOCAL_DN_SIZE (MAX_LOCAL_CHAR_SIZE * MAX_DN_CHARS + 1) - - -typedef enum DELIMIX /* indicies into an array of delimiter characters */ -{ - /* the elements of the delimiter array of indicies - * DI_CFG_TYPED and DI_CFG_ESC_STRINGS aren't really delimiters - * but are booleans. If the corresponding delimiter is - * DELIM_CFG_TRUE then output names are preferred with types for - * DI_CFG_TYPED and non-mappable characters in string output is - * mapped to an escape followed by 4 hex digits for - * DI_CFG_ESC_STRINGS. DI_WILD is used for patterns, after that - * DI_REL must be the first actual delimiter index and - * all DI_* values must be contiguous up to and including DI_COUNT - */ - DI_INVALID = -1, DI_CFG_TYPED = 0, DI_CFG_ESC_STRINGS, - DI_REL, DI_RDN, DI_DV, DI_VALUE, DI_WILD, DI_ESC, DI_EOS, DI_COUNT -} DELIMIX; - -#define DELIM_CFG_TRUE '1' -#define DELIM_CFG_FALSE '0' -#define DELIM_WILD '*' /* delimiter in filters */ -#define DELIM_VALUE '=' /* delimiter in names */ -#define DELIM_DV '+' /* delimiter in names */ - -/* delimiters in dot form names */ -#define DELIM_DF_RDN '.' -#define DELIM_DF_ESCAPE '\\' - -/* delimiters in slash form names */ -#define DELIM_SF_RDN '\\' -#define DELIM_SF_ESCAPE '\'' -#define DELIM_SF_RELATIVE '.' - -/* delimiters in SAP form names */ -#define DELIM_SAP_ESCAPE '^' - -/* unicode characters not accepted by DS */ -#define UNI_BYTE_ORDER_MARK 0xfeff -#define UNI_SWAPPED_BYTE_ORDER_MARK 0xfffe -#define UNI_REPLACEMENT_CHAR 0xfffd -#define UNI_NON_CHAR 0xffff - -/* special entry names in ACLs */ -#define DS_ROOT_NAME "[Root]" -#define DS_PUBLIC_NAME "[Public]" -#define DS_MASK_NAME "[Inheritance Mask]" -#define DS_CREATOR_NAME "[Creator]" /* can only be used in AddEntry */ -#define DS_SELF_NAME "[Self]" /* can only be used in AddEntry */ - -/* special attribute names in ACLs */ -#define DS_ALL_ATTRS_NAME "[All Attributes Rights]" -#define DS_ENTRY_RIGHTS_NAME "[Entry Rights]" - -typedef enum SYNTAX -{ - SYN_UNKNOWN, /* 0 */ - SYN_DIST_NAME, /* 1 */ - SYN_CE_STRING, /* 2 */ - SYN_CI_STRING, /* 3 */ - SYN_PR_STRING, /* 4 */ - SYN_NU_STRING, /* 5 */ - SYN_CI_LIST, /* 6 */ - SYN_BOOLEAN, /* 7 */ - SYN_INTEGER, /* 8 */ - SYN_OCTET_STRING, /* 9 */ - SYN_TEL_NUMBER, /* 10 */ - SYN_FAX_NUMBER, /* 11 */ - SYN_NET_ADDRESS, /* 12 */ - SYN_OCTET_LIST, /* 13 */ - SYN_EMAIL_ADDRESS, /* 14 */ - SYN_PATH, /* 15 */ - SYN_REPLICA_POINTER, /* 16 */ - SYN_OBJECT_ACL, /* 17 */ - SYN_PO_ADDRESS, /* 18 */ - SYN_TIMESTAMP, /* 19 */ - SYN_CLASS_NAME, /* 20 */ - SYN_STREAM, /* 21 */ - SYN_COUNTER, /* 22 */ - SYN_BACK_LINK, /* 23 */ - SYN_TIME, /* 24 */ - SYN_TYPED_NAME, /* 25 */ - SYN_HOLD, /* 26 */ - SYN_INTERVAL, /* 27 */ - SYNTAX_COUNT /* 37 */ -} SYNTAX; - -typedef enum NAME_SPACE_TYPE -{ - DS_DOS, DS_MACINTOSH, DS_UNIX, DS_FTAM, DS_OS2 -} NAME_SPACE_TYPE; - -typedef enum REPLICA_TYPE -{ - RT_MASTER, RT_SECONDARY, RT_READONLY, RT_SUBREF, RT_COUNT -} REPLICA_TYPE; - -#define RF_NO_HIDDEN 0x8000L -#define RF_NO_SECURE 0x4000L -#define RF_CACHE_ONLY 0x2000L - -typedef enum REPLICA_STATE -{ - RS_ON, RS_NEW_REPLICA, RS_DYING_REPLICA, - RS_LOCKED, RS_CRT_0, RS_CRT_1, - RS_TRANSITION_ON, RS_DEAD_REPLICA, RS_BEGIN_ADD, - RS_MASTER_START = 11, RS_MASTER_DONE, RS_FEDERATED, - RS_SS_0 = 48, RS_SS_1, - RS_JS_0 = 64, RS_JS_1, RS_JS_2, - RS_MS_0 = 80, RS_MS_1, - RS_COUNT -} REPLICA_STATE; - -typedef enum NET_ADDRESS_TYPE -{ - NT_IPX, NT_IP, NT_SDLC, NT_TOKENRING_ETHERNET, - NT_OSI, NT_APPLETALK, NT_NETBEUI, NT_SOCKADDR, - NT_UDP, NT_TCP, NT_UDP6, NT_TCP6, NT_INTERNAL, - NT_URL, NT_COUNT -} NET_ADDRESS_TYPE; - -/* Auxillary net address types are replicated in the referral, - * but are not bound to an actual protocol stack. - */ -#define IS_AUX_NT(type) ((type) == NT_URL) - -typedef enum NCP_SERVER_STATUS -{ - DS_UNKNOWN, DS_DOWN, DS_UP -} NCP_SERVER_STATUS; - -#define IPX_ADDRESS_LEN 12 -#define IP_ADDRESS_LEN 6 -#define IP6_ADDRESS_LEN 22 - -typedef enum EMAIL_ADDRESS_TYPE -{ - SMF70 = 1, SMF71, SMTP, X400, SNADS, PROFS -} EMAIL_ADDRESS_TYPE; - -typedef enum REPLICA_SAP_CONFIGURATION -{ - REPLICA_SAP_ROOT_MOST, REPLICA_SAP_NEVER, REPLICA_SAP_ALWAYS -} REPLICA_SAP_CONFIGURATION; - -typedef enum BACKUP_RESTORE_TAGS -{ - BKR_CREATE_DIBSET, BKR_RESTORE_ENTRIES, BKR_RESTORE_PARTITIONS, - BKR_RESTORE_FILE, BKR_RESTORE_BASE, BKR_RESTORE_STREAMS -} BACKUP_RESTORE_TAGS; - -/* federation state flags */ -#define FEDERATION_DISABLED 0x0001 - -/*--------------------------------------------------------------------------- - * definitions used by Access Control - */ -#define DS_ENTRY_BROWSE 0x00000001L -#define DS_ENTRY_ADD 0x00000002L -#define DS_ENTRY_DELETE 0x00000004L -#define DS_ENTRY_RENAME 0x00000008L -#define DS_ENTRY_SUPERVISOR 0x00000010L -#define DS_ENTRY_INHERIT_CTL 0x00000040L - -#define DS_ENTRY_MASK (DS_ENTRY_BROWSE | DS_ENTRY_ADD \ - | DS_ENTRY_DELETE | DS_ENTRY_RENAME \ - | DS_ENTRY_SUPERVISOR | DS_ENTRY_INHERIT_CTL) - -#define DS_ATTR_COMPARE 0x00000001L -#define DS_ATTR_READ 0x00000002L -#define DS_ATTR_WRITE 0x00000004L -#define DS_ATTR_SELF 0x00000008L -#define DS_ATTR_SUPERVISOR 0x00000020L -#define DS_ATTR_INHERIT_CTL 0x00000040L - -#define DS_ATTR_MASK (DS_ATTR_COMPARE | DS_ATTR_READ | DS_ATTR_WRITE \ - | DS_ATTR_SELF | DS_ATTR_SUPERVISOR \ - | DS_ATTR_INHERIT_CTL) - -#if DS_ENTRY_INHERIT_CTL != DS_ATTR_INHERIT_CTL - #error DS_ENTRY_INHERIT_CTL and DS_ATTR_INHERIT_CTL must be equal -#endif - -/*--------------------------------------------------------------------------- - * Bit definitions used by object manipulation APIs for the - * User Flags and System Flags attributes on Schema Ojbects - */ -/* User Flags */ -#define SCU_SINGLE_VALUED_ATTR 0x00000001L -#define SCU_PUBLIC_READ 0x00000002L -#define SCU_WRITE_MANAGED 0x00000004L -#define SCU_PER_REPLICA 0x00000008L -#define SCU_READ_ONLY_ATTR 0x00000010L -#define SCU_SCHEDULE_SYNC_IMMEDIATE 0x00000020L -#define SCU_SCHEDULE_SYNC_URGENT 0x00000040L -#define SCU_SCHEDULE_SYNC_NEVER 0x00000080L -#define SCU_CONTAINER_CLASS 0x00000100L /* class objects */ -#define SCU_EFFECTIVE_CLASS 0x00000200L /* class objects */ -#define SCU_SECURE 0x00000400L -#define SCU_CACHE 0x00000800L - -/* System Flags */ -#define SCS_NONREMOVABLE 0x00000001L -#define SCS_READ_ONLY_ATTR 0x00000002L -#define SCS_HIDDEN_ATTR 0x00000004L -#define SCS_SERVER_READ 0x00000008L -#define SCS_AMBIGUOUS_CONTAINMENT 0x00000010L /* class objects */ -#define SCS_AMBIGUOUS_NAMING 0x00000020L /* class objects */ -#define SCS_CAN_BE_USED_IN_NAMING 0x00000040L - -/*===========================================================================*/ -#endif diff --git a/include/nwnss/support/ndssdkINC_kern/dtypes.h b/include/nwnss/support/ndssdkINC_kern/dtypes.h deleted file mode 100644 index dfbb2f8..0000000 --- a/include/nwnss/support/ndssdkINC_kern/dtypes.h +++ /dev/null @@ -1,58 +0,0 @@ -/***************************************************************************** - * - * Copyright (C) Unpublished Work of Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * $release$ - * $modname: dtypes.h$ - * $version: 1.3$ - * $date: Fri, Mar 6, 1998$ - * $nokeywords$ - * - ****************************************************************************/ - -#ifndef DTYPES_H -#define DTYPES_H - -#ifdef __cplusplus -#define externC extern "C" -#else -#define externC extern -#endif - -#define FileScope - -#define __int64 long long int - -typedef unsigned short unicode; -typedef unsigned __int64 uint64; -typedef signed __int64 int64; -typedef unsigned long uint32; -typedef signed long int32; -typedef unsigned short uint16; -typedef signed short int16; -typedef unsigned char uint8; -typedef signed char int8; -typedef unsigned long streamSize; - -#define MAX_UINT64 0xffffffffffffffffL -#define MAX_UINT32 0xffffffffL -#define MAX_UINT16 0xffffL - -/*===========================================================================*/ -#endif diff --git a/include/nwnss/support/ndssdkINC_kern/nwdserr.h b/include/nwnss/support/ndssdkINC_kern/nwdserr.h deleted file mode 100644 index 73694a4..0000000 --- a/include/nwnss/support/ndssdkINC_kern/nwdserr.h +++ /dev/null @@ -1,495 +0,0 @@ -/***************************************************************************** - * - * Copyright (C) Unpublished Work of Novell, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, - * you may find current contact information at www.novell.com - * - * Name: nwdserr.h - * %version: 64 % - * %created_by: smclain % - * %date_modified: Wed Aug 21 12:41:15 2002 % - * - ****************************************************************************/ - -#ifndef NWDSERR_H -#define NWDSERR_H - -/* errors from the file system, IPX, NCP, and other NW OS services are one byte - * and are mapped to -1 to -256 when returned as a directory services error - */ -#define DSERR_INSUFFICIENT_SPACE -001 /* FFFFFFFF */ -#define DSERR_BUFFER_TOO_SMALL -119 /* FFFFFF89 */ -#define DSERR_VOLUME_FLAG_NOT_SET -120 /* FFFFFF88 */ -#define DSERR_NO_ITEMS_FOUND -121 /* FFFFFF87 */ -#define DSERR_CONN_ALREADY_TEMPORARY -122 /* FFFFFF86 */ -#define DSERR_CONN_ALREADY_LOGGED_IN -123 /* FFFFFF85 */ -#define DSERR_CONN_NOT_AUTHENTICATED -124 /* FFFFFF84 */ -#define DSERR_CONN_NOT_LOGGED_IN -125 /* FFFFFF83 */ -#define DSERR_NCP_BOUNDARY_CHECK_FAILED -126 /* FFFFFF82 */ -#define DSERR_LOCK_WAITING -127 /* FFFFFF81 */ -#define DSERR_LOCK_FAIL -128 /* FFFFFF80 */ -#define DSERR_OUT_OF_HANDLES -129 /* FFFFFF7F */ -#define DSERR_NO_OPEN_PRIVILEGE -130 /* FFFFFF7E */ -#define DSERR_HARD_IO_ERROR -131 /* FFFFFF7D */ -#define DSERR_NO_CREATE_PRIVILEGE -132 /* FFFFFF7C */ -#define DSERR_NO_CREATE_DELETE_PRIV -133 /* FFFFFF7B */ -#define DSERR_R_O_CREATE_FILE -134 /* FFFFFF7A */ -#define DSERR_CREATE_FILE_INVALID_NAME -135 /* FFFFFF79 */ -#define DSERR_INVALID_FILE_HANDLE -136 /* FFFFFF78 */ -#define DSERR_NO_SEARCH_PRIVILEGE -137 /* FFFFFF77 */ -#define DSERR_NO_DELETE_PRIVILEGE -138 /* FFFFFF76 */ -#define DSERR_NO_RENAME_PRIVILEGE -139 /* FFFFFF75 */ -#define DSERR_NO_SET_PRIVILEGE -140 /* FFFFFF74 */ -#define DSERR_SOME_FILES_IN_USE -141 /* FFFFFF73 */ -#define DSERR_ALL_FILES_IN_USE -142 /* FFFFFF72 */ -#define DSERR_SOME_READ_ONLY -143 /* FFFFFF71 */ -#define DSERR_ALL_READ_ONLY -144 /* FFFFFF70 */ -#define DSERR_SOME_NAMES_EXIST -145 /* FFFFFF6F */ -#define DSERR_ALL_NAMES_EXIST -146 /* FFFFFF6E */ -#define DSERR_NO_READ_PRIVILEGE -147 /* FFFFFF6D */ -#define DSERR_NO_WRITE_PRIVILEGE -148 /* FFFFFF6C */ -#define DSERR_FILE_DETACHED -149 /* FFFFFF6B */ -#define ERR_INSUFFICIENT_MEMORY -150 /* FFFFFF6A */ -#define DSERR_NO_ALLOC_SPACE -150 /* FFFFFF6A */ -#define DSERR_TARGET_NOT_A_SUBDIR -150 /* FFFFFF6A */ -#define DSERR_NO_SPOOL_SPACE -151 /* FFFFFF69 */ -#define DSERR_INVALID_VOLUME -152 /* FFFFFF68 */ -#define DSERR_DIRECTORY_FULL -153 /* FFFFFF67 */ -#define DSERR_RENAME_ACROSS_VOLUME -154 /* FFFFFF66 */ -#define DSERR_BAD_DIR_HANDLE -155 /* FFFFFF65 */ -#define DSERR_INVALID_PATH -156 /* FFFFFF64 */ -#define DSERR_NO_SUCH_EXTENSION -156 /* FFFFFF64 */ -#define DSERR_NO_DIR_HANDLES -157 /* FFFFFF63 */ -#define DSERR_BAD_FILE_NAME -158 /* FFFFFF62 */ -#define DSERR_DIRECTORY_ACTIVE -159 /* FFFFFF61 */ -#define DSERR_DIRECTORY_NOT_EMPTY -160 /* FFFFFF60 */ -#define DSERR_DIRECTORY_IO_ERROR -161 /* FFFFFF5F */ -#define DSERR_IO_LOCKED -162 /* FFFFFF5E */ -#define DSERR_TRANSACTION_RESTARTED -163 /* FFFFFF5D */ -#define DSERR_RENAME_DIR_INVALID -164 /* FFFFFF5C */ -#define DSERR_INVALID_OPENCREATE_MODE -165 /* FFFFFF5B */ -#define DSERR_ALREADY_IN_USE -166 /* FFFFFF5A */ -#define DSERR_INVALID_RESOURCE_TAG -167 /* FFFFFF59 */ -#define DSERR_ACCESS_DENIED -168 /* FFFFFF58 */ -#define DSERR_LOGIN_SIGNING_REQUIRED -188 /* FFFFFF44 */ -#define DSERR_LOGIN_ENCRYPT_REQUIRED -189 /* FFFFFF43 */ -#define DSERR_INVALID_DATA_STREAM -190 /* FFFFFF42 */ -#define DSERR_INVALID_NAME_SPACE -191 /* FFFFFF41 */ -#define DSERR_NO_ACCOUNTING_PRIVILEGES -192 /* FFFFFF40 */ -#define DSERR_NO_ACCOUNT_BALANCE -193 /* FFFFFF3F */ -#define DSERR_CREDIT_LIMIT_EXCEEDED -194 /* FFFFFF3E */ -#define DSERR_TOO_MANY_HOLDS -195 /* FFFFFF3D */ -#define DSERR_ACCOUNTING_DISABLED -196 /* FFFFFF3C */ -#define DSERR_LOGIN_LOCKOUT -197 /* FFFFFF3B */ -#define DSERR_NO_CONSOLE_RIGHTS -198 /* FFFFFF3A */ -#define DSERR_Q_IO_FAILURE -208 /* FFFFFF30 */ -#define DSERR_NO_QUEUE -209 /* FFFFFF2F */ -#define DSERR_NO_Q_SERVER -210 /* FFFFFF2E */ -#define DSERR_NO_Q_RIGHTS -211 /* FFFFFF2D */ -#define DSERR_Q_FULL -212 /* FFFFFF2C */ -#define DSERR_NO_Q_JOB -213 /* FFFFFF2B */ -#define DSERR_NO_Q_JOB_RIGHTS -214 /* FFFFFF2A */ -#define DSERR_UNENCRYPTED_NOT_ALLOWED -214 /* FFFFFF2A */ -#define DSERR_Q_IN_SERVICE -215 /* FFFFFF29 */ -#define DSERR_DUPLICATE_PASSWORD -215 /* FFFFFF29 */ -#define DSERR_Q_NOT_ACTIVE -216 /* FFFFFF28 */ -#define DSERR_PASSWORD_TOO_SHORT -216 /* FFFFFF28 */ -#define DSERR_Q_STN_NOT_SERVER -217 /* FFFFFF27 */ -#define DSERR_MAXIMUM_LOGINS_EXCEEDED -217 /* FFFFFF27 */ -#define DSERR_Q_HALTED -218 /* FFFFFF26 */ -#define DSERR_BAD_LOGIN_TIME -218 /* FFFFFF26 */ -#define DSERR_Q_MAX_SERVERS -219 /* FFFFFF25 */ -#define DSERR_NODE_ADDRESS_VIOLATION -219 /* FFFFFF25 */ -#define DSERR_LOG_ACCOUNT_EXPIRED -220 /* FFFFFF24 */ -#define DSERR_BAD_PASSWORD -222 /* FFFFFF22 */ -#define DSERR_PASSWORD_EXPIRED -223 /* FFFFFF21 */ -#define DSERR_NO_LOGIN_CONN_AVAILABLE -224 /* FFFFFF20 */ -#define DSERR_WRITE_TO_GROUP_PROPERTY -232 /* FFFFFF18 */ -#define DSERR_MEMBER_ALREADY_EXISTS -233 /* FFFFFF17 */ -#define DSERR_NO_SUCH_MEMBER -234 /* FFFFFF16 */ -#define DSERR_PROPERTY_NOT_GROUP -235 /* FFFFFF15 */ -#define DSERR_NO_SUCH_VALUE_SET -236 /* FFFFFF14 */ -#define DSERR_PROPERTY_ALREADY_EXISTS -237 /* FFFFFF13 */ -#define DSERR_OBJECT_ALREADY_EXISTS -238 /* FFFFFF12 */ -#define DSERR_ILLEGAL_NAME -239 /* FFFFFF11 */ -#define DSERR_ILLEGAL_WILDCARD -240 /* FFFFFF10 */ -#define DSERR_BINDERY_SECURITY -241 /* FFFFFF0F */ -#define DSERR_NO_OBJECT_READ_RIGHTS -242 /* FFFFFF0E */ -#define DSERR_NO_OBJECT_RENAME_RIGHTS -243 /* FFFFFF0D */ -#define DSERR_NO_OBJECT_DELETE_RIGHTS -244 /* FFFFFF0C */ -#define DSERR_NO_OBJECT_CREATE_RIGHTS -245 /* FFFFFF0B */ -#define DSERR_NO_PROPERTY_DELETE_RIGHTS -246 /* FFFFFF0A */ -#define DSERR_NO_PROPERTY_CREATE_RIGHTS -247 /* FFFFFF09 */ -#define DSERR_NO_PROPERTY_WRITE_RIGHTS -248 /* FFFFFF08 */ -#define DSERR_NO_PROPERTY_READ_RIGHTS -249 /* FFFFFF07 */ -#define DSERR_TEMP_REMAP -250 /* FFFFFF06 */ -#define ERR_REQUEST_UNKNOWN -251 /* FFFFFF05 */ -#define DSERR_UNKNOWN_REQUEST -251 /* FFFFFF05 */ -#define DSERR_NO_SUCH_PROPERTY -251 /* FFFFFF05 */ -#define DSERR_MESSAGE_QUEUE_FULL -252 /* FFFFFF04 */ -#define DSERR_TARGET_ALREADY_HAS_MSG -252 /* FFFFFF04 */ -#define DSERR_NO_SUCH_OBJECT -252 /* FFFFFF04 */ -#define DSERR_BAD_STATION_NUMBER -253 /* FFFFFF03 */ -#define DSERR_BINDERY_LOCKED -254 /* FFFFFF02 */ -#define DSERR_DIR_LOCKED -254 /* FFFFFF02 */ -#define DSERR_SPOOL_DELETE -254 /* FFFFFF02 */ -#define DSERR_TRUSTEE_NOT_FOUND -254 /* FFFFFF02 */ -#define DSERR_TIMEOUT -254 /* FFFFFF02 */ -#define DSERR_HARD_FAILURE -255 /* FFFFFF01 */ -#define DSERR_FILE_NAME -255 /* FFFFFF01 */ -#define DSERR_FILE_EXISTS -255 /* FFFFFF01 */ -#define DSERR_CLOSE_FCB -255 /* FFFFFF01 */ -#define DSERR_IO_BOUND -255 /* FFFFFF01 */ -#define DSERR_NO_SPOOL_FILE -255 /* FFFFFF01 */ -#define DSERR_BAD_SPOOL_PRINTER -255 /* FFFFFF01 */ -#define DSERR_BAD_PARAMETER -255 /* FFFFFF01 */ -#define DSERR_NO_FILES_FOUND -255 /* FFFFFF01 */ -#define DSERR_NO_TRUSTEE_CHANGE_PRIV -255 /* FFFFFF01 */ -#define DSERR_TARGET_NOT_LOGGED_IN -255 /* FFFFFF01 */ -#define DSERR_TARGET_NOT_ACCEPTING_MSGS -255 /* FFFFFF01 */ -#define DSERR_MUST_FORCE_DOWN -255 /* FFFFFF01 */ -#define ERR_OF_SOME_SORT -255 /* FFFFFF01 */ - -/* -301 to -399 are returned by the directory services client library */ -#define ERR_NOT_ENOUGH_MEMORY -301 /* 0xFFFFFED3 */ -#define ERR_BAD_KEY -302 /* 0xFFFFFED2 */ -#define ERR_BAD_CONTEXT -303 /* 0xFFFFFED1 */ -#define ERR_BUFFER_FULL -304 /* 0xFFFFFED0 */ -#define ERR_LIST_EMPTY -305 /* 0xFFFFFECF */ -#define ERR_BAD_SYNTAX -306 /* 0xFFFFFECE */ -#define ERR_BUFFER_EMPTY -307 /* 0xFFFFFECD */ -#define ERR_BAD_VERB -308 /* 0xFFFFFECC */ -#define ERR_EXPECTED_IDENTIFIER -309 /* 0xFFFFFECB */ -#define ERR_EXPECTED_EQUALS -310 /* 0xFFFFFECA */ -#define ERR_ATTR_TYPE_EXPECTED -311 /* 0xFFFFFEC9 */ -#define ERR_ATTR_TYPE_NOT_EXPECTED -312 /* 0xFFFFFEC8 */ -#define ERR_FILTER_TREE_EMPTY -313 /* 0xFFFFFEC7 */ -#define ERR_INVALID_OBJECT_NAME -314 /* 0xFFFFFEC6 */ -#define ERR_EXPECTED_RDN_DELIMITER -315 /* 0xFFFFFEC5 */ -#define ERR_TOO_MANY_TOKENS -316 /* 0xFFFFFEC4 */ -#define ERR_INCONSISTENT_MULTIAVA -317 /* 0xFFFFFEC3 */ -#define ERR_COUNTRY_NAME_TOO_LONG -318 /* 0xFFFFFEC2 */ -#define ERR_SYSTEM_ERROR -319 /* 0xFFFFFEC1 */ -#define ERR_CANT_ADD_ROOT -320 /* 0xFFFFFEC0 */ -#define ERR_UNABLE_TO_ATTACH -321 /* 0xFFFFFEBF */ -#define ERR_INVALID_HANDLE -322 /* 0xFFFFFEBE */ -#define ERR_BUFFER_ZERO_LENGTH -323 /* 0xFFFFFEBD */ -#define ERR_INVALID_REPLICA_TYPE -324 /* 0xFFFFFEBC */ -#define ERR_INVALID_ATTR_SYNTAX -325 /* 0xFFFFFEBB */ -#define ERR_INVALID_FILTER_SYNTAX -326 /* 0xFFFFFEBA */ -#define ERR_CONTEXT_CREATION -328 /* 0xFFFFFEB8 */ -#define ERR_INVALID_UNION_TAG -329 /* 0xFFFFFEB7 */ -#define ERR_INVALID_SERVER_RESPONSE -330 /* 0xFFFFFEB6 */ -#define ERR_NULL_POINTER -331 /* 0xFFFFFEB5 */ -#define ERR_NO_SERVER_FOUND -332 /* 0xFFFFFEB4 */ -#define ERR_NO_CONNECTION -333 /* 0xFFFFFEB3 */ -#define ERR_RDN_TOO_LONG -334 /* 0xFFFFFEB2 */ -#define ERR_DUPLICATE_TYPE -335 /* 0xFFFFFEB1 */ -#define ERR_DATA_STORE_FAILURE -336 /* 0xFFFFFEB0 */ -#define ERR_NOT_LOGGED_IN -337 /* 0xFFFFFEAF */ -#define ERR_INVALID_PASSWORD_CHARS -338 /* 0xFFFFFEAE */ -#define ERR_FAILED_SERVER_AUTHENT -339 /* 0xFFFFFEAD */ -#define ERR_TRANSPORT -340 /* 0xFFFFFEAC */ -#define ERR_NO_SUCH_SYNTAX -341 /* 0xFFFFFEAB */ -#define ERR_INVALID_DS_NAME -342 /* 0xFFFFFEAA */ -#define ERR_ATTR_NAME_TOO_LONG -343 /* 0xFFFFFEA9 */ -#define ERR_INVALID_TDS -344 /* 0xFFFFFEA8 */ -#define ERR_INVALID_DS_VERSION -345 /* 0xFFFFFEA7 */ -#define ERR_UNICODE_TRANSLATION -346 /* 0xFFFFFEA6 */ -#define ERR_SCHEMA_NAME_TOO_LONG -347 /* 0xFFFFFEA5 */ -#define ERR_UNICODE_FILE_NOT_FOUND -348 /* 0xFFFFFEA4 */ -#define ERR_UNICODE_ALREADY_LOADED -349 /* 0xFFFFFEA3 */ -#define ERR_NOT_CONTEXT_OWNER -350 /* 0xFFFFFEA2 */ -#define ERR_ATTEMPT_TO_AUTHENTICATE_0 -351 /* 0xFFFFFEA1 */ -#define ERR_NO_WRITABLE_REPLICAS -352 /* 0xFFFFFEA0 */ -#define ERR_DN_TOO_LONG -353 /* 0xFFFFFE9F */ -#define ERR_RENAME_NOT_ALLOWED -354 /* 0xFFFFFE9E */ -#define ERR_NOT_NDS_FOR_NT -355 /* 0xFFFFFE9D */ -#define ERR_NDS_FOR_NT_NO_DOMAIN -356 /* 0xFFFFFE9C */ -#define ERR_NDS_FOR_NT_SYNC_DISABLED -357 /* 0xFFFFFE9B */ -#define ERR_ITR_INVALID_HANDLE -358 /* 0xFFFFFE9A */ -#define ERR_ITR_INVALID_POSITION -359 /* 0xFFFFFE99 */ -#define ERR_ITR_INVALID_SEARCH_DATA -360 /* 0xFFFFFE98 */ -#define ERR_ITR_INVALID_SCOPE -361 /* 0xFFFFFE97 */ -#define ERR_ITR_MAX_COUNT -362 /* 0xFFFFFE96 */ - -/* -601 to -799 are returned by the directory services agent in the server */ -#define ERR_NO_SUCH_ENTRY -601 /* 0xFFFFFDA7 */ -#define ERR_NO_SUCH_VALUE -602 /* 0xFFFFFDA6 */ -#define ERR_NO_SUCH_ATTRIBUTE -603 /* 0xFFFFFDA5 */ -#define ERR_NO_SUCH_CLASS -604 /* 0xFFFFFDA4 */ -#define ERR_NO_SUCH_PARTITION -605 /* 0xFFFFFDA3 */ -#define ERR_ENTRY_ALREADY_EXISTS -606 /* 0xFFFFFDA2 */ -#define ERR_NOT_EFFECTIVE_CLASS -607 /* 0xFFFFFDA1 */ -#define ERR_ILLEGAL_ATTRIBUTE -608 /* 0xFFFFFDA0 */ -#define ERR_MISSING_MANDATORY -609 /* 0xFFFFFD9F */ -#define ERR_ILLEGAL_DS_NAME -610 /* 0xFFFFFD9E */ -#define ERR_ILLEGAL_CONTAINMENT -611 /* 0xFFFFFD9D */ -#define ERR_CANT_HAVE_MULTIPLE_VALUES -612 /* 0xFFFFFD9C */ -#define ERR_SYNTAX_VIOLATION -613 /* 0xFFFFFD9B */ -#define ERR_DUPLICATE_VALUE -614 /* 0xFFFFFD9A */ -#define ERR_ATTRIBUTE_ALREADY_EXISTS -615 /* 0xFFFFFD99 */ -#define ERR_MAXIMUM_ENTRIES_EXIST -616 /* 0xFFFFFD98 */ -#define ERR_DATABASE_FORMAT -617 /* 0xFFFFFD97 */ -#define ERR_INCONSISTENT_DATABASE -618 /* 0xFFFFFD96 */ -#define ERR_INVALID_COMPARISON -619 /* 0xFFFFFD95 */ -#define ERR_COMPARISON_FAILED -620 /* 0xFFFFFD94 */ -#define ERR_TRANSACTIONS_DISABLED -621 /* 0xFFFFFD93 */ -#define ERR_INVALID_TRANSPORT -622 /* 0xFFFFFD92 */ -#define ERR_SYNTAX_INVALID_IN_NAME -623 /* 0xFFFFFD91 */ -#define ERR_REPLICA_ALREADY_EXISTS -624 /* 0xFFFFFD90 */ -#define ERR_TRANSPORT_FAILURE -625 /* 0xFFFFFD8F */ -#define ERR_ALL_REFERRALS_FAILED -626 /* 0xFFFFFD8E */ -#define ERR_CANT_REMOVE_NAMING_VALUE -627 /* 0xFFFFFD8D */ -#define ERR_OBJECT_CLASS_VIOLATION -628 /* 0xFFFFFD8C */ -#define ERR_ENTRY_IS_NOT_LEAF -629 /* 0xFFFFFD8B */ -#define ERR_DIFFERENT_TREE -630 /* 0xFFFFFD8A */ -#define ERR_ILLEGAL_REPLICA_TYPE -631 /* 0xFFFFFD89 */ -#define ERR_SYSTEM_FAILURE -632 /* 0xFFFFFD88 */ -#define ERR_INVALID_ENTRY_FOR_ROOT -633 /* 0xFFFFFD87 */ -#define ERR_NO_REFERRALS -634 /* 0xFFFFFD86 */ -#define ERR_REMOTE_FAILURE -635 /* 0xFFFFFD85 */ -#define ERR_UNREACHABLE_SERVER -636 /* 0XFFFFFD84 */ -#define ERR_PREVIOUS_MOVE_IN_PROGRESS -637 /* 0XFFFFFD83 */ -#define ERR_NO_CHARACTER_MAPPING -638 /* 0XFFFFFD82 */ -#define ERR_INCOMPLETE_AUTHENTICATION -639 /* 0XFFFFFD81 */ -#define ERR_INVALID_CERTIFICATE -640 /* 0xFFFFFD80 */ -#define ERR_INVALID_REQUEST -641 /* 0xFFFFFD7F */ -#define ERR_INVALID_ITERATION -642 /* 0xFFFFFD7E */ -#define ERR_SCHEMA_IS_NONREMOVABLE -643 /* 0xFFFFFD7D */ -#define ERR_SCHEMA_IS_IN_USE -644 /* 0xFFFFFD7C */ -#define ERR_CLASS_ALREADY_EXISTS -645 /* 0xFFFFFD7B */ -#define ERR_BAD_NAMING_ATTRIBUTES -646 /* 0xFFFFFD7A */ -#define ERR_NOT_ROOT_PARTITION -647 /* 0xFFFFFD79 */ -#define ERR_INSUFFICIENT_STACK -648 /* 0xFFFFFD78 */ -#define ERR_INSUFFICIENT_BUFFER -649 /* 0xFFFFFD77 */ -#define ERR_AMBIGUOUS_CONTAINMENT -650 /* 0xFFFFFD76 */ -#define ERR_AMBIGUOUS_NAMING -651 /* 0xFFFFFD75 */ -#define ERR_DUPLICATE_MANDATORY -652 /* 0xFFFFFD74 */ -#define ERR_DUPLICATE_OPTIONAL -653 /* 0xFFFFFD73 */ -#define ERR_PARTITION_BUSY -654 /* 0XFFFFFD72 */ -#define ERR_MULTIPLE_REPLICAS -655 /* 0xFFFFFD71 */ -#define ERR_CRUCIAL_REPLICA -656 /* 0xFFFFFD70 */ -#define ERR_SCHEMA_SYNC_IN_PROGRESS -657 /* 0xFFFFFD6F */ -#define ERR_SKULK_IN_PROGRESS -658 /* 0xFFFFFD6E */ -#define ERR_TIME_NOT_SYNCHRONIZED -659 /* 0xFFFFFD6D */ -#define ERR_RECORD_IN_USE -660 /* 0xFFFFFD6C */ -#define ERR_DS_VOLUME_NOT_MOUNTED -661 /* 0xFFFFFD6B */ -#define ERR_DS_VOLUME_IO_FAILURE -662 /* 0xFFFFFD6A */ -#define ERR_DS_LOCKED -663 /* 0xFFFFFD69 */ -#define ERR_OLD_EPOCH -664 /* 0xFFFFFD68 */ -#define ERR_NEW_EPOCH -665 /* 0xFFFFFD67 */ -#define ERR_INCOMPATIBLE_DS_VERSION -666 /* 0xFFFFFD66 */ -#define ERR_PARTITION_ROOT -667 /* 0xFFFFFD65 */ -#define ERR_ENTRY_NOT_CONTAINER -668 /* 0xFFFFFD64 */ -#define ERR_FAILED_AUTHENTICATION -669 /* 0xFFFFFD63 */ -#define ERR_INVALID_CONTEXT -670 /* 0xFFFFFD62 */ -#define ERR_NO_SUCH_PARENT -671 /* 0xFFFFFD61 */ -#define ERR_NO_ACCESS -672 /* 0xFFFFFD60 */ -#define ERR_REPLICA_NOT_ON -673 /* 0xFFFFFD5F */ -#define ERR_INVALID_NAME_SERVICE -674 /* 0xFFFFFD5E */ -#define ERR_INVALID_TASK -675 /* 0xFFFFFD5D */ -#define ERR_INVALID_CONN_HANDLE -676 /* 0xFFFFFD5C */ -#define ERR_INVALID_IDENTITY -677 /* 0xFFFFFD5B */ -#define ERR_DUPLICATE_ACL -678 /* 0xFFFFFD5A */ -#define ERR_PARTITION_ALREADY_EXISTS -679 /* 0xFFFFFD59 */ -#define ERR_TRANSPORT_MODIFIED -680 /* 0xFFFFFD58 */ -#define ERR_ALIAS_OF_AN_ALIAS -681 /* 0xFFFFFD57 */ -#define ERR_AUDITING_FAILED -682 /* 0xFFFFFD56 */ -#define ERR_INVALID_API_VERSION -683 /* 0xFFFFFD55 */ -#define ERR_SECURE_NCP_VIOLATION -684 /* 0xFFFFFD54 */ -#define ERR_MOVE_IN_PROGRESS -685 /* 0xFFFFFD53 */ -#define ERR_NOT_LEAF_PARTITION -686 /* 0xFFFFFD52 */ -#define ERR_CANNOT_ABORT -687 /* 0xFFFFFD51 */ -#define ERR_CACHE_OVERFLOW -688 /* 0xFFFFFD50 */ -#define ERR_INVALID_SUBORDINATE_COUNT -689 /* 0xFFFFFD4F */ -#define ERR_INVALID_RDN -690 /* 0xFFFFFD4E */ -#define ERR_MOD_TIME_NOT_CURRENT -691 /* 0xFFFFFD4D */ -#define ERR_INCORRECT_BASE_CLASS -692 /* 0xFFFFFD4C */ -#define ERR_MISSING_REFERENCE -693 /* 0xFFFFFD4B */ -#define ERR_LOST_ENTRY -694 /* 0xFFFFFD4A */ -#define ERR_AGENT_ALREADY_REGISTERED -695 /* 0xFFFFFD49 */ -#define ERR_DS_LOADER_BUSY -696 /* 0xFFFFFD48 */ -#define ERR_DS_CANNOT_RELOAD -697 /* 0xFFFFFD47 */ -#define ERR_REPLICA_IN_SKULK -698 /* 0xFFFFFD46 */ -#define ERR_FATAL -699 /* 0xFFFFFD45 */ -#define ERR_OBSOLETE_API -700 /* 0xFFFFFD44 */ -#define ERR_SYNCHRONIZATION_DISABLED -701 /* 0xFFFFFD43 */ -#define ERR_INVALID_PARAMETER -702 /* 0xFFFFFD42 */ -#define ERR_DUPLICATE_TEMPLATE -703 /* 0xFFFFFD41 */ -#define ERR_NO_MASTER_REPLICA -704 /* 0xFFFFFD40 */ -#define ERR_DUPLICATE_CONTAINMENT -705 /* 0xFFFFFD3F */ -#define ERR_NOT_SIBLING -706 /* 0xFFFFFD3E */ -#define ERR_INVALID_SIGNATURE -707 /* 0xFFFFFD3D */ -#define ERR_INVALID_RESPONSE -708 /* 0xFFFFFD3C */ -#define ERR_INSUFFICIENT_SOCKETS -709 /* 0xFFFFFD3B */ -#define ERR_DATABASE_READ_FAIL -710 /* 0xFFFFFD3A */ -#define ERR_INVALID_CODE_PAGE -711 /* 0xFFFFFD39 */ -#define ERR_INVALID_ESCAPE_CHAR -712 /* 0xFFFFFD38 */ -#define ERR_INVALID_DELIMITERS -713 /* 0xFFFFFD37 */ -#define ERR_NOT_IMPLEMENTED -714 /* 0xFFFFFD36 */ -#define ERR_CHECKSUM_FAILURE -715 /* 0xFFFFFD35 */ -#define ERR_CHECKSUMMING_NOT_SUPPORTED -716 /* 0xFFFFFD34 */ -#define ERR_CRC_FAILURE -717 /* 0xFFFFFD33 */ -#define ERR_INVALID_ENTRY_HANDLE -718 /* 0xFFFFFD32 */ -#define ERR_INVALID_VALUE_HANDLE -719 /* 0xFFFFFD31 */ -#define ERR_CONNECTION_DENIED -720 /* 0xFFFFFD30 */ -#define ERR_NO_SUCH_FEDERATION_LINK -721 /* 0xFFFFFD2F */ -#define ERR_OP_SCHEMA_MISMATCH -722 /* 0xFFFFFD2E */ -#define ERR_STREAM_NOT_FOUND -723 /* 0xFFFFFD2D */ -#define ERR_DCLIENT_UNAVAILABLE -724 /* 0xFFFFFD2C */ -#define ERR_MASV_NO_ACCESS -725 /* 0xFFFFFD2B */ -#define ERR_MASV_INVALID_REQUEST -726 /* 0xFFFFFD2A */ -#define ERR_MASV_FAILURE -727 /* 0xFFFFFD29 */ -#define ERR_MASV_ALREADY_EXISTS -728 /* 0xFFFFFD28 */ -#define ERR_MASV_NOT_FOUND -729 /* 0xFFFFFD27 */ -#define ERR_MASV_BAD_RANGE -730 /* 0xFFFFFD26 */ -#define ERR_VALUE_DATA -731 /* 0xFFFFFD25 */ -#define ERR_DATABASE_LOCKED -732 /* 0xFFFFFD24 */ -#define ERR_DATABASE_ALREADY_EXISTS -733 /* 0xFFFFFD23 */ -#define ERR_DATABASE_NOT_FOUND -734 /* 0xFFFFFD22 */ -#define ERR_NOTHING_TO_ABORT -735 /* 0xFFFFFD21 */ -#define ERR_END_OF_STREAM -736 /* 0xFFFFFD20 */ -#define ERR_NO_SUCH_TEMPLATE -737 /* 0xFFFFFD1F */ -#define ERR_SAS_LOCKED -738 /* 0xFFFFFD1E */ -#define ERR_INVALID_SAS_VERSION -739 /* 0xFFFFFD1D */ -#define ERR_SAS_ALREADY_REGISTERED -740 /* 0xFFFFFD1C */ -#define ERR_NAME_TYPE_NOT_SUPPORTED -741 /* 0xFFFFFD1B */ -#define ERR_WRONG_DS_VERSION -742 /* 0xFFFFFD1A */ -#define ERR_INVALID_CONTROL_FUNCTION -743 /* 0xFFFFFD19 */ -#define ERR_INVALID_CONTROL_STATE -744 /* 0xFFFFFD18 */ -#define ERR_CACHE_IN_USE -745 /* 0xFFFFFD17 */ -#define ERR_ZERO_CREATION_TIME -746 /* 0xFFFFFD16 */ -#define ERR_WOULD_BLOCK -747 /* 0xFFFFFD15 */ -#define ERR_CONN_TIMEOUT -748 /* 0xFFFFFD14 */ -#define ERR_TOO_MANY_REFERRALS -749 /* 0xFFFFFD13 */ -#define ERR_OPERATION_CANCELLED -750 /* 0xFFFFFD12 */ -#define ERR_UNKNOWN_TARGET -751 /* 0xFFFFFD11 */ -#define ERR_GUID_FAILURE -752 /* 0xFFFFFD10 */ -#define ERR_INCOMPATIBLE_OS -753 /* 0xFFFFFD0F */ -#define ERR_CALLBACK_CANCEL -754 /* 0xFFFFFD0E */ -#define ERR_INVALID_SYNC_DATA -755 /* 0xFFFFFD0D */ -#define ERR_STREAM_EXISTS -756 /* 0xFFFFFD0C */ -#define ERR_AUXILIARY_HAS_CONTAINMENT -757 /* 0xFFFFFD0B */ -#define ERR_AUXILIARY_NOT_CONTAINER -758 /* 0xFFFFFD0A */ -#define ERR_AUXILIARY_NOT_EFFECTIVE -759 /* 0XFFFFFD09 */ -#define ERR_AUXILIARY_ON_ALIAS -760 /* 0xFFFFFD08 */ -#define ERR_HAVE_SEEN_STATE -761 /* 0xFFFFFD07 */ -#define ERR_VERB_LOCKED -762 /* 0xFFFFFD06 */ -#define ERR_VERB_EXCEEDS_TABLE_LENGTH -763 /* 0xFFFFFD05 */ -#define ERR_BOF_HIT -764 /* 0xFFFFFD04 */ -#define ERR_EOF_HIT -765 /* 0xFFFFFD03 */ -#define ERR_INCOMPATIBLE_REPLICA_VER -766 /* 0xFFFFFD02 */ -#define ERR_QUERY_TIMEOUT -767 /* 0xFFFFFD01 */ -#define ERR_QUERY_MAX_COUNT -768 /* 0xFFFFFD00 */ -#define ERR_DUPLICATE_NAMING -769 /* 0xFFFFFCFF */ -#define ERR_NO_TRANS_ACTIVE -770 /* 0xFFFFFCFE */ -#define ERR_TRANS_ACTIVE -771 /* 0xFFFFFCFD */ -#define ERR_ILLEGAL_TRANS_OP -772 /* 0xFFFFFCFC */ -#define ERR_ITERATOR_SYNTAX -773 /* 0xFFFFFCFB */ -#define ERR_REPAIRING_DIB -774 /* 0xFFFFFCFA */ -#define ERR_INVALID_OID_FORMAT -775 /* 0xFFFFFCF9 */ -#define ERR_DS_AGENT_CLOSING -776 /* 0xFFFFFCF8 */ -#define ERR_SPARSE_FILTER_VIOLATION -777 /* 0xFFFFFCF7 */ -#define ERR_VPVECTOR_CORRELATION_ERR -778 /* 0xFFFFFCF6 */ -#define ERR_CANNOT_GO_REMOTE -779 /* 0xFFFFFCF5 */ -#define ERR_REQUEST_NOT_SUPPORTED -780 /* 0xFFFFFCF4 */ -#define ERR_ENTRY_NOT_LOCAL -781 /* 0xFFFFFCF3 */ -#define ERR_ROOT_UNREACHABLE -782 /* 0xFFFFFCF2 */ -#define ERR_VRDIM_NOT_INITIALIZED -783 /* 0xFFFFFCF1 */ -#define ERR_WAIT_TIMEOUT -784 /* 0xFFFFFCF0 */ -#define ERR_DIB_ERROR -785 /* 0xFFFFFCEF */ -#define ERR_DIB_IO_FAILURE -786 /* 0xFFFFFCEE */ -#define ERR_ILLEGAL_SCHEMA_ATTRIBUTE -787 /* 0xFFFFFCED */ -#define ERR_SCHEMA_PARTITION -788 /* 0xFFFFFCEC */ -#define ERR_INVALID_TEMPLATE -789 /* 0xFFFFFCEB */ -#define ERR_OPENING_FILE -790 /* 0xFFFFFCEA */ -#define ERR_DIRECT_OPENING_FILE -791 /* 0xFFFFFCE9 */ -#define ERR_CREATING_FILE -792 /* 0xFFFFFCE8 */ -#define ERR_DIRECT_CREATING_FILE -793 /* 0xFFFFFCE7 */ -#define ERR_READING_FILE -794 /* 0xFFFFFCE6 */ -#define ERR_DIRECT_READING_FILE -795 /* 0xFFFFFCE5 */ -#define ERR_WRITING_FILE -796 /* 0xFFFFFCE4 */ -#define ERR_DIRECT_WRITING_FILE -797 /* 0xFFFFFCE3 */ -#define ERR_POSITIONING_IN_FILE -798 /* 0xFFFFFCE2 */ -#define ERR_GETTING_FILE_SIZE -799 /* 0xFFFFFCE1 */ -/* WARNING: Do not use any value between -800 and -6000 for DS errors! - We have claimed a new range between -6001 and -6999. - Also please read the comment below the last error code - below. */ -/* -6001 to -6999 are returned by the directory services agent in the server */ -#define ERR_TRUNCATING_FILE -6001 /* 0xFFFFE88F */ -#define ERR_PARSING_FILE_NAME -6002 /* 0xFFFFE88E */ -#define ERR_CLOSING_FILE -6003 /* 0xFFFFE88D */ -#define ERR_GETTING_FILE_INFO -6004 /* 0xFFFFE88C */ -#define ERR_EXPANDING_FILE -6005 /* 0xFFFFE88B */ -#define ERR_GETTING_FREE_BLOCKS -6006 /* 0xFFFFE88A */ -#define ERR_CHECKING_FILE_EXISTENCE -6007 /* 0xFFFFE889 */ -#define ERR_DELETING_FILE -6008 /* 0xFFFFE888 */ -#define ERR_RENAMING_FILE -6009 /* 0xFFFFE887 */ -#define ERR_INITIALIZING_IO_SYSTEM -6010 /* 0xFFFFE886 */ -#define ERR_FLUSHING_FILE -6011 /* 0xFFFFE885 */ -#define ERR_SETTING_UP_FOR_READ -6012 /* 0xFFFFE884 */ -#define ERR_SETTING_UP_FOR_WRITE -6013 /* 0xFFFFE883 */ -#define ERR_OLD_VIEW -6014 /* 0xFFFFE882 */ -#define ERR_SERVER_IN_SKULK -6015 /* 0xFFFFE881 */ -#define ERR_PARTIAL_RESULTS -6016 /* 0xFFFFE880 */ -#define ERR_NO_SUCH_SCHEMA -6017 /* 0xFFFFE87F */ -#define ERR_SERIAL_NUM_MISMATCH -6018 /* 0xFFFFE87E */ -#define ERR_BAD_RFL_DB_SERIAL_NUM -6019 /* 0xFFFFE87D */ -#define ERR_BAD_RFL_SERIAL_NUM -6020 /* 0xFFFFE87C */ -#define ERR_INVALID_FILE_SEQUENCE -6021 /* 0xFFFFE87B */ -#define ERR_RFL_TRANS_GAP -6022 /* 0xFFFFE87A */ -#define ERR_BAD_RFL_FILE_NUMBER -6023 /* 0xFFFFE879 */ -#define ERR_RFL_FILE_NOT_FOUND -6024 /* 0xFFFFE878 */ -#define ERR_BACKUP_ACTIVE -6025 /* 0xFFFFE877 */ -#define ERR_RFL_DEVICE_FULL -6026 /* 0xFFFFE876 */ -#define ERR_UNSUPPORTED_VERSION -6027 /* 0xFFFFE875 */ -#define ERR_MUST_WAIT_CHECKPOINT -6028 /* 0xFFFFE874 */ -#define ERR_ATTR_MAINT_IN_PROGRESS -6029 /* 0xFFFFE873 */ -#define ERR_ABORT_TRANSACTION -6030 /* 0xFFFFE872 */ -#define ERR_SETTING_FILE_INFO -6031 /* 0xFFFFE871 */ -#define ERR_REPLICA_RING_CHANGED -6032 /* 0xFFFFE870 */ -#define ERR_NOT_PARTITION_ROOT -6033 /* 0xFFFFE86F */ -#define ERR_SERVER_NOT_UP_TO_DATE -6034 /* 0xFFFFE86E */ -#define ERR_INCONSISTENT_BACKUP -6035 /* 0xFFFFE86D */ -#define ERR_NO_SUCH_INDEX -6036 /* 0xFFFFE86C */ -#define ERR_INDEX_OFFLINE -6037 /* 0xFFFFE86B */ -#define ERR_CLOSING_DATABASE -6038 /* 0xFFFFE86A */ -#define ERR_OBJECT_OP_DISABLED -6039 /* 0XFFFFE869 */ -#define ERR_OP_STARTED -6040 /* 0xFFFFE868 */ -#define ERR_OP_ABORTED -6041 /* 0xFFFFE867 */ -#define ERR_OP_FAILED -6042 /* 0xFFFFE866 */ -#define ERR_OP_IN_PROGRESS -6043 /* 0xFFFFE865 */ - - - -/* WARNING: When adding a new error code, please make sure that following happens: - 1. Update utprintf.cpp. - 2. Notify the core DS team, a CCB member, and CPR. - 3. If you are CPR, make sure it gets merged safely forward. - 4. Notify utility owners who document these errors codes such as iMonitor - and DSDump. - 5. Notify documentation and assist them in documenting your error codes. -*/ - -/* NOTE: In order to accommodate older compilers, do not introduce a new - * error code name longer than 31 characters. - */ - -/*===========================================================================*/ -#endif diff --git a/src/nwnss/Makefile b/src/nwnss/Makefile new file mode 100644 index 0000000..4f9e362 --- /dev/null +++ b/src/nwnss/Makefile @@ -0,0 +1,57 @@ +### +### ../nss/public_core Makefile +### + +############################################################################## +# +# (C) Copyright 2004 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +BASEDIR=.. + +ifdef DONT_BUILD_PUBLIC + +SUBDIRS= + +else + +SUBDIRS= \ + kmdb \ + libnss \ + library \ + libzapi \ + linuxmpk \ + lsa \ + manage \ + nebdrv \ + ndpmod \ + nss \ + nsslnxlib \ + comn \ + admindrv \ + nwraid \ + zlss \ + zapi \ + +endif + +NO_MAKEFILE_ENGINE=1 +include ${BASEDIR}/buildtools/Makefile.default + diff --git a/src/nwnss/admindrv/Makefile b/src/nwnss/admindrv/Makefile new file mode 100644 index 0000000..d619308 --- /dev/null +++ b/src/nwnss/admindrv/Makefile @@ -0,0 +1,32 @@ +### +### ../nss/private_core/admindrv Makefile +### + +############################################################################## +# +# (C) Copyright 2004 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +BASEDIR=../.. + +SUBDIRS= \ + +include ${BASEDIR}/buildtools/Makefile.default + diff --git a/src/nwnss/admindrv/Module.supported b/src/nwnss/admindrv/Module.supported new file mode 100644 index 0000000..9ab26c5 --- /dev/null +++ b/src/nwnss/admindrv/Module.supported @@ -0,0 +1 @@ +admindrv.ko diff --git a/src/nwnss/admindrv/admindrvLKM.c b/src/nwnss/admindrv/admindrvLKM.c new file mode 100644 index 0000000..ae1862e --- /dev/null +++ b/src/nwnss/admindrv/admindrvLKM.c @@ -0,0 +1,281 @@ +/**************************************************************************** + | + | (C) Copyright 2004 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NSS Linux initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $ + | + | $RCSfile$ + | $Revision: 1325 $ + | + |--------------------------------------------------------------------------- + | This module is used to: !!!Linux specific file!!! + | Init functions the admin file system driver + | + +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include + +MODULE_AUTHOR("Novell, Inc."); +MODULE_DESCRIPTION("admin file system driver"); +MODULE_LICENSE("GPL v2"); + +wait_queue_head_t request_queue; +DECLARE_WAIT_QUEUE_HEAD(request_queue); + +wait_queue_head_t reply_queue; +DECLARE_WAIT_QUEUE_HEAD(reply_queue); + +spinlock_t Admd_lock; +struct semaphore Admd_operation; +char *Admd_requestBuffer = NULL; +char *Admd_replyBuffer = NULL; +int Admd_requestLen; +int Admd_replyLen; +int Admd_amountRead; + +int Admd_major; + +//*************************************************************************** +// +//*************************************************************************** +int admd_request( + int requestLen, + char *request, + int *replyLen, + char **reply) +{ +// printk(KERN_ALERT "In admd_request\n"); + // Block if there is already a request in process + if (down_interruptible(&Admd_operation)) + { + return -ERESTARTSYS; + } + + Admd_requestBuffer = request; + Admd_requestLen = requestLen; + Admd_amountRead = 0; + + // Let the read complete -- send data to user space + wake_up_interruptible(&request_queue); + +// printk(KERN_ALERT "In admd_request: waiting for a reply\n"); + // Wait for reply from user space + if (wait_event_interruptible(reply_queue, Admd_replyBuffer) < 0) + { + up(&Admd_operation); + return -1; + } + *replyLen = Admd_replyLen; + *reply = Admd_replyBuffer; + Admd_replyBuffer = NULL; +// printk(KERN_ALERT "In admd_request: len=%d reply=%s\n", *replyLen, *reply); + + up(&Admd_operation); + return 0; +} +EXPORT_SYMBOL(admd_request); + +//*************************************************************************** +// +//*************************************************************************** +static int admd_open( + struct inode *inode, + struct file *file) +{ +// printk(KERN_ALERT "admindrv device_open called \n"); + return 0; +} + +//*************************************************************************** +// +//*************************************************************************** +static int admd_release( + struct inode *inode, + struct file *file) +{ + return 0; +} + +//*************************************************************************** +// +//*************************************************************************** +static ssize_t admd_read( + struct file *filp, + char *buffer, + size_t length, + loff_t *offset) +{ + int amountLeft; + int readLen; + int sts; + +// printk(KERN_ALERT "admindrv: device_read called length:%d \n",length); + + // + // If the userspace program has requested a non-blocking open or + // a zero lenth read then return an error. + // + if(filp->f_flags & O_NONBLOCK) + { + return -ENOSYS; + } + + if(length == 0) + { + return 0; + } + + // If no request is pending then wait for one. + if (wait_event_interruptible(request_queue, Admd_requestBuffer) < 0) + { + wake_up_interruptible(&reply_queue); + return -ERESTARTSYS; + } + + amountLeft = Admd_requestLen - Admd_amountRead; +// printk(KERN_ALERT "admindrv reqlen:%d read:%d left:%d\n", Admd_requestLen, Admd_amountRead, amountLeft); + + if (amountLeft <= 0) + { +// printk(KERN_ALERT "admindrv: bytes_read: 0\n"); + wake_up_interruptible(&reply_queue); + return -ERESTARTSYS; + } + + readLen = amountLeft <= length ? amountLeft : length; + + // + //copy from request buffer to buffer from read request + // + sts = copy_to_user(buffer, &Admd_requestBuffer[Admd_amountRead], readLen); + + + Admd_amountRead += readLen; + +// printk(KERN_ALERT "admindrv: bytes_read: %d\n", readLen); + return readLen; +} + +//*************************************************************************** +// +//*************************************************************************** +static ssize_t admd_write( + struct file *filp, + const char *buffer, + size_t length, + loff_t *offset) +{ + int sts; +// printk(KERN_ALERT "admindrv device_write called length:%d \n",length); + + if (!Admd_requestBuffer || Admd_requestLen != Admd_amountRead) + { +// printk(KERN_ALERT "Write request before read completed\n"); + } + + Admd_replyBuffer = kmalloc(length, GFP_KERNEL); + if (Admd_replyBuffer == NULL) + { + return -ERESTARTSYS; + } + + sts = copy_from_user(Admd_replyBuffer, buffer, length); + Admd_replyLen = length; + + Admd_requestBuffer = NULL; + + wake_up_interruptible(&reply_queue); + + return length; +} + +//*************************************************************************** +// +//*************************************************************************** +static int admd_ioctl(struct inode *inode, struct file * filp, unsigned int intval, unsigned long longval) +{ + //printk(KERN_ALERT "admd_ioctl called: %d: %d\n",intval,longval); + return 0; +} + +void __cyg_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void __cyg_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); + +void __cyg_profile_func_enter (void *this_fn, void *call_site) +{ + return; +} + +void __cyg_profile_func_exit (void *this_fn, void *call_site) +{ + return; +} + +//*************************************************************************** +// +//*************************************************************************** +struct file_operations admd_fops = { + .open = admd_open, + .release = admd_release, + .read = admd_read, + .write = admd_write, + .ioctl = admd_ioctl +}; + +int admd_init_module(void) +{ +//printk(KERN_ALERT"ADMD: init spin lock=%d\n", ADMD_lock.lock); + spin_lock_init(&Admd_lock); + init_MUTEX(&Admd_operation); + Admd_major = register_chrdev(0, ADMD_DEVICE_NAME, &admd_fops); //register a char device + if (Admd_major <= 0) + { + printk(KERN_ALERT "Unable to register the admin file system driver\n"); + return -ENOSYS; + } + //printk(KERN_INFO "Admin file system driver loaded\n"); + return(0); +} + +//*************************************************************************** +// +//*************************************************************************** +void admd_cleanup_module(void) +{ + unregister_chrdev(Admd_major, ADMD_DEVICE_NAME); + //printk(KERN_INFO "Admin file system driver unloaded\n"); +} + +module_init(admd_init_module); +module_exit(admd_cleanup_module); diff --git a/src/nwnss/admindrv/admindrvModules.mk b/src/nwnss/admindrv/admindrvModules.mk new file mode 100644 index 0000000..5c3fb6a --- /dev/null +++ b/src/nwnss/admindrv/admindrvModules.mk @@ -0,0 +1,276 @@ +############################################################################## +# +# (C) Copyright 2003 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +########################################################################## +# This defines what MODULES are being built for this NLM +# +# $Author: ghorlacher $ +# $Date: 2007-09-13 03:51:53 +0530 (Thu, 13 Sep 2007) $ +# +# $RCSfile$ +# $Revision: 2206 $ +# +########################################################################## +MODULE_VERSION=15 + +#------------------------------------------------------------------------- +# If the version number is not defined here, the general product version +# number will be used (defined in bldVersion.bld) +# +# major version 1 to 99 +# minor version 1 to 99 +# sub version 1 to 26 +#------------------------------------------------------------------------- +#MAJOR_VERSION= +#MINOR_VERSION= +#SUB_VERSION= + +#------------------------------------------------------------------------- +# Build OPTIONS +#------------------------------------------------------------------------- +BUILD_WITH_KERNEL_FLAGS=1 + +#set to 0 if you are NOT using source code control +IS_USING_SOURCE_CONTROL=1 + +#Set to ONE if you want the linked files to be copied to the SDK/BIN directory. +COPY_TO_SDK_BIN=1 + + #set to ONE if you only want to copy the OPTIMIZED version to SDK/BIN. + COPY_OPTIMIZED_ONLY=0 + +#Set this to ONE if you are building a NETWARE version independent NLM +#(not NETWARE version specific) +NETWARE_VERSION_INDEPENDENT=1 + + #if ONE include the NETWARE .H files in the compiler search paths. + USE_NETWARE_INCLUDES=0 + + #if ONE include the NETWARE import file at LINK time + USE_NETWARE_IMPORTS=0 + +#If ONE IMPORT the LIBNSS APIs and include in the search path SDK/LIBRARY +#and SDK/PUBLIC +IMPORT_INDEPENDENT_LIBNSS=0 + +#If ONE include in the search path SDK/LIBRARY and SDK/PUBLIC +USE_LIBNSS_INCLUDES=0 + +#If ONE add sdk/include to the include path +USE_SDK_INCLUDE=1 + +#If ONE then LINK with the NSS library and include all of the NSS library +#directories in the compiler search paths. This includes the SDK/PUBLIC, +#SDK/INCLUDE, SDK/INTERNAL, LIBRARY/SRC directories. +LINK_WITH_NSSLIB=0 + +#if ONE then IMPORT the NSS library and COMN layer APIS and include the +#SDK/PUBLIC directory in the compiler search paths. +IMPORT_NSSLIB=0 + + #If ONE and (LINK_WITH_NSSLIB==1 or IMPORT_NSSLIB==1) then do the same + #operation to the NSSLIB area you are doing to the local area. + CHECK_NSSLIB=0 + + #If ONE and (CHECK_NSSLIB==1) then we will clean the NSSLIB area when we + #clean the local area. + CLEAN_NSSLIB=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INCLUDE directory in + #the compiler search paths + USE_NSS_SDK_INCLUDES=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/COMNSA directory in + #the compiler search paths + USE_NSS_SDK_COMNSA_INCLUDES=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INTERNAL directory in + #the compiler search paths + USE_NSS_SDK_INTERNAL_INCLUDES=0 + +#if ONE then do NOT import the NSS COMMON layer APIs +DONT_IMPORT_COMMON_LAYER=0 + +#if ONE, compile and link with the NETWARE sdk environment. +USE_NETWARE_SDK=0 + +#if ONE, include DS headers. +USE_NDS_INCLUDES=0 + +#if ONE, do LANGUAGE ENABLING processing +DO_LANGUAGE_ENABLING=0 + +#Set to null (i.e. no value) to not add XDC data to the NLM. For most +#NetWare 5.0 NLMs, the value should be -u. +MOAB_XDC_TOOL_OPTION=-n + +#************************************************************************* +# List of source directories for NSS +#************************************************************************* +SOURCE_DIRECTORIES= + +#************************************************************************* +# Source Modules for NSS (.C .386) +#************************************************************************* +SOURCE_FILES=\ + admindrvLKM.c + +SOURCE_FILES_NODEBUG= + +#************************************************************************* +# Source Include files for NSS (.H .inc) +#************************************************************************* +INCLUDE_FILES=\ + admindrv.h + +#------------------------------------------------------------------------- +# Additional source files that need to be checked out +#------------------------------------------------------------------------- +OTHER_FILES=\ + Module.supported + +#------------------------------------------------------------------------- +# This defines what routines are being EXPORTED. You should put .IMP +# files in the "UTILITY_EXPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_EXPORTS= + +#UTILITY_EXPORTS_VIA_FILE= +UTILITY_EXPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# This defines what routines are being IMPORTED. You should put .IMP +# files in the "UTILITY_IMPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_IMPORTS= + +UTILITY_IMPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# Library definitions +# This defines additional libraries to LINK with and additional +# directories to put on out INCLUDE path. +#------------------------------------------------------------------------- +#additional libraries to link with +EXTRA_LIBRARIES= +EXTRA_STATIC_LIBRARIES= +EXTRA_DYNAMIC_LIBRARIES= +EXTRA_LIBRARY_INCLPATH= + +#------------------------------------------------------------------------- +# Include path +# This defines additional include path to compile with +#------------------------------------------------------------------------- +#additional include path +EXTRA_INCLUDE_PATH= + + +#------------------------------------------------------------------------- +# Additional C and ASSEMBLY options to use +#------------------------------------------------------------------------- +EXTRA_C_OPTIONS= +EXTRA_ASM_OPTIONS= +EXTRA_LINK_OPTIONS= + +#------------------------------------------------------------------------- +# Additional module attributes +#------------------------------------------------------------------------- +MODULE_DESCRIPTION='Upcall mechanism for admin file system' +MODULE_ADDITIONAL_COPYRIGHT= +MODULE_OPTIONS= +MODULE_DEPENDENCIES= +MODULE_TYPE= +MODULE_NAME=admindrv +MODULE_EXTENSION= +MODULE_START_ROUTINE= +MODULE_EXIT_ROUTINE= +#set to 1 if you want the optimized NLM to be packed +MODULE_PACK_NLM=1 + +#========================================================================= +#========================================================================= +# LOCAL BUILD RULES +#========================================================================= +#========================================================================= + +#------------------------------------------------------------------------- +# Default BUILD rule +#------------------------------------------------------------------------- +DEFAULT: DEFAULT_BUILD + +#------------------------------------------------------------------------- +# Additional rules +#------------------------------------------------------------------------- + +#BUILD_GREENRIVER_OPT: +# @echo "...This NLM does not have an OPTIMIZED GREENRIVER specific version" + +#BUILD_GREENRIVER_UNOPT: +# @echo "...This NLM does not have an UNOPTIMIZED GREENRIVER specific version" + +BUILD_MOAB_MP_UNOPT: \ + COMPILE_UNOPT_MP_MOAB \ + LINK_UNOPT_MP_MOAB + +BUILD_MOAB_MP_OPT: \ + COMPILE_OPT_MP_MOAB \ + LINK_OPT_MP_MOAB + +BUILD_MOAB_SP_UNOPT: + @echo "...This NLM does not have an UNOPTIMIZED SP specific version" + +BUILD_MOAB_SP_OPT: + @echo "...This NLM does not have an OPTIMIZED SP specific version" + + +#BUILD_MOAB_SP_UNOPT: \ +# COMPILE_UNOPT_SP_MOAB \ +# LINK_UNOPT_SP_MOAB +# +#BUILD_MOAB_SP_OPT: \ +# COMPILE_OPT_SP_MOAB \ +# LINK_OPT_SP_MOAB + + +#------------------------------------------------------------------------- +# Language Enabling rules +#------------------------------------------------------------------------- +mdb: \ + DEFAULT_MDB + +umdb: \ + LOCAL_MDB + +mdbcreate: \ + DEFAULT_CREATE_MDB_FILE + +#------------------------------------------------------------------------- +# Other rules +#------------------------------------------------------------------------- +deps: DEFAULT_DEPS + +cscope: DEFAULT_CSCOPE + diff --git a/src/nwnss/comn/Makefile b/src/nwnss/comn/Makefile new file mode 100644 index 0000000..bdbe1a8 --- /dev/null +++ b/src/nwnss/comn/Makefile @@ -0,0 +1,32 @@ +### +### ../nss/private_core/comn Makefile +### + +############################################################################## +# +# (C) Copyright 2004 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +BASEDIR=../.. + +SUBDIRS= \ + +include ${BASEDIR}/buildtools/Makefile.default + diff --git a/src/nwnss/comn/Module.supported b/src/nwnss/comn/Module.supported new file mode 100644 index 0000000..bfdf4e3 --- /dev/null +++ b/src/nwnss/comn/Module.supported @@ -0,0 +1 @@ +nsscomn.ko diff --git a/include/nwnss/comn/aes.h b/src/nwnss/comn/aes.h similarity index 97% rename from include/nwnss/comn/aes.h rename to src/nwnss/comn/aes.h index ece4db2..908c859 100644 --- a/include/nwnss/comn/aes.h +++ b/src/nwnss/comn/aes.h @@ -7,7 +7,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -64,13 +64,6 @@ #define AES_MAXNR 14 #define AES_BLOCK_SIZE 16 -#ifdef NSS_USERSPACE -#include -typedef uint32_t u32; -typedef uint16_t u16; -typedef uint8_t u8; -#endif - #ifdef __cplusplus extern "C" { #endif diff --git a/src/nwnss/comn/aes/aes_cbc.c b/src/nwnss/comn/aes/aes_cbc.c index 903f10e..67e91fb 100755 --- a/src/nwnss/comn/aes/aes_cbc.c +++ b/src/nwnss/comn/aes/aes_cbc.c @@ -7,7 +7,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -57,10 +57,7 @@ //#include /* Removed by Brenda */ //#include /* Removed by Brenda */ -#ifdef NSS_USERSPACE -#else #include -#endif #include /* Added by Brenda */ #include "aes_locl.h" @@ -93,7 +90,7 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, AES_encrypt(tmp, tmp, key); memcpy(out, tmp, AES_BLOCK_SIZE); memcpy(ivec, tmp, AES_BLOCK_SIZE); - } + } } else { while (len >= AES_BLOCK_SIZE) { memcpy(tmp, in, AES_BLOCK_SIZE); @@ -111,6 +108,6 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, for(n=0; n < len; ++n) out[n] = tmp[n] ^ ivec[n]; memcpy(ivec, tmp, AES_BLOCK_SIZE); - } + } } } diff --git a/src/nwnss/comn/aes/aes_core.c b/src/nwnss/comn/aes/aes_core.c index ead58d9..299e4c7 100755 --- a/src/nwnss/comn/aes/aes_core.c +++ b/src/nwnss/comn/aes/aes_core.c @@ -35,13 +35,9 @@ #endif //#include /* Removed by Brenda */ -#ifdef NSS_USERSPACE -#include -#else #include #include #include -#endif //#include /* Removed by Brenda */ #include /* Added by Brenda */ #include "aes_locl.h" @@ -735,7 +731,7 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) { u32 *rk; - int i = 0; + int i = 0; u32 temp; if (!userKey || !key) @@ -824,7 +820,7 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits, rk[15] = rk[ 7] ^ rk[14]; rk += 8; - } + } } return 0; } @@ -906,50 +902,50 @@ void AES_encrypt(const unsigned char *in, unsigned char *out, s3 = GETU32(in + 12) ^ rk[3]; #ifdef FULL_UNROLL /* round 1: */ - t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4]; - t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5]; - t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6]; - t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7]; - /* round 2: */ - s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8]; - s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9]; - s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10]; - s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11]; + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7]; + /* round 2: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11]; /* round 3: */ - t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12]; - t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13]; - t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14]; - t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15]; - /* round 4: */ - s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16]; - s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17]; - s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18]; - s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19]; + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15]; + /* round 4: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19]; /* round 5: */ - t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20]; - t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21]; - t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22]; - t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23]; - /* round 6: */ - s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24]; - s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25]; - s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26]; - s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27]; + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23]; + /* round 6: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27]; /* round 7: */ - t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28]; - t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29]; - t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30]; - t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31]; - /* round 8: */ - s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32]; - s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33]; - s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34]; - s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35]; + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31]; + /* round 8: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35]; /* round 9: */ - t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36]; - t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37]; - t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38]; - t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39]; + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39]; if (key->rounds > 10) { /* round 10: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40]; @@ -1232,32 +1228,33 @@ void AES_decrypt(const unsigned char *in, unsigned char *out, * apply last round and * map cipher state to byte array block: */ - s0 = - (Td4[(t0 >> 24) ] & 0xff000000) ^ - (Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ - (Td4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ - (Td4[(t1 ) & 0xff] & 0x000000ff) ^ - rk[0]; + s0 = + (Td4[(t0 >> 24) ] & 0xff000000) ^ + (Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ + (Td4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ + (Td4[(t1 ) & 0xff] & 0x000000ff) ^ + rk[0]; PUTU32(out , s0); - s1 = - (Td4[(t1 >> 24) ] & 0xff000000) ^ - (Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ - (Td4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ - (Td4[(t2 ) & 0xff] & 0x000000ff) ^ - rk[1]; + s1 = + (Td4[(t1 >> 24) ] & 0xff000000) ^ + (Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ + (Td4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ + (Td4[(t2 ) & 0xff] & 0x000000ff) ^ + rk[1]; PUTU32(out + 4, s1); - s2 = - (Td4[(t2 >> 24) ] & 0xff000000) ^ - (Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ - (Td4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ - (Td4[(t3 ) & 0xff] & 0x000000ff) ^ - rk[2]; + s2 = + (Td4[(t2 >> 24) ] & 0xff000000) ^ + (Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ + (Td4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ + (Td4[(t3 ) & 0xff] & 0x000000ff) ^ + rk[2]; PUTU32(out + 8, s2); - s3 = - (Td4[(t3 >> 24) ] & 0xff000000) ^ - (Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ - (Td4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ - (Td4[(t0 ) & 0xff] & 0x000000ff) ^ - rk[3]; + s3 = + (Td4[(t3 >> 24) ] & 0xff000000) ^ + (Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ + (Td4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ + (Td4[(t0 ) & 0xff] & 0x000000ff) ^ + rk[3]; PUTU32(out + 12, s3); } + diff --git a/include/nwnss/comn/aes/aes_locl.h b/src/nwnss/comn/aes/aes_locl.h similarity index 99% rename from include/nwnss/comn/aes/aes_locl.h rename to src/nwnss/comn/aes/aes_locl.h index 91630d1..c6347f0 100755 --- a/include/nwnss/comn/aes/aes_locl.h +++ b/src/nwnss/comn/aes/aes_locl.h @@ -7,7 +7,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in diff --git a/src/nwnss/comn/authsys/authorize.c b/src/nwnss/comn/authsys/authorize.c index 7b5d5c1..5b6704e 100644 --- a/src/nwnss/comn/authsys/authorize.c +++ b/src/nwnss/comn/authsys/authorize.c @@ -38,11 +38,6 @@ #include /* netware includes*/ #include #include -#ifdef NSS_USERSPACE -/* bindery.h also has a STATIC object-flag macro; restore NSS function marker. */ -#undef STATIC -#define STATIC -#endif //#include /* NDS includes */ #include @@ -154,7 +149,7 @@ STATUS AUTHSYS_AdminVolPreInit( { NINT modelIndex; NINT spaceIndex; - + ASSERT_MPKNSS_LOCK(); adminAuthModel = (AuthModelBeast_s *)zalloc(sizeof(AuthModelBeast_s)); @@ -351,9 +346,9 @@ AuthModelBeast_s *COMN_RegisterAuthorizeModel( { AuthModelBeast_s *authModel; NINT index; - + ASSERT_MPKNSS_LOCK(); - + if (version != AUTH_MODEL_VERSION) { SetErrno(genMsg, zERR_INVALID_AUTH_MODEL_VERSION); @@ -441,7 +436,7 @@ AuthSpaceBeast_s *COMN_RegisterAuthorizeSpace( NINT i; AuthSpaceBeast_s *authSpace; NINT index; - + ASSERT_MPKNSS_LOCK(); if (authSpaceBeastType > zFTYPE_MAX) @@ -502,7 +497,7 @@ AuthSpaceBeast_s *COMN_RegisterAuthorizeSpace( memcpy(&authSpace->authSpaceOps, spaceOps, sizeof(AuthSpaceOps_s)); memcpy(&authModel->authModelOps.authSpaceOps[index], spaceOps, sizeof(AuthSpaceOps_s)); - + return authSpace; } @@ -514,13 +509,13 @@ AuthSpaceBeast_s *COMN_RegisterAuthorizeSpace( **************************************************************************** ****************************************************************************/ -#define DEFAULT_G2I_CACHE_SIZE (1<<14) /* must be a power of two or the - * compute hash routine needs to be +#define DEFAULT_G2I_CACHE_SIZE (1<<14) /* must be a power of two or the + * compute hash routine needs to be * changed. With the current hash * algorithm it must not be greater * than a shift of 28. */ -#define DEFAULT_I2G_CACHE_SIZE (1<<14) /* must be a power of two or the - * compute hash routine needs to be +#define DEFAULT_I2G_CACHE_SIZE (1<<14) /* must be a power of two or the + * compute hash routine needs to be * changed. With the current hash * algorithm it must not be greater * than a shift of 28. */ @@ -655,7 +650,7 @@ void GUID_IDCacheResetInterval( G2I_CacheInvalidateTime = value; CANCEL_ALARM(GUIDtoIDCache.alarm); - secOneShot( &GUIDtoIDCache.alarm, G2I_CacheInvalidateTime, + secOneShot( &GUIDtoIDCache.alarm, G2I_CacheInvalidateTime, G2I_HandleAlarm); I2G_CacheInvalidateTime = value; @@ -746,7 +741,7 @@ void GUID_CacheUninit( NINT i; GUIDtoIDCacheNode_s *itemGuid; IDtoGUIDCacheNode_s *itemID; - + if (guidCache->numHashEntries == 0) { return; @@ -815,7 +810,7 @@ void G2I_DisplayCache(void) NINT i; GUIDtoIDCacheNode_s *node; char buffer[GUID_FORMAT_SIZE]; - + DBG_DebugPrintf(LGRAY,MSGNot("-------- GUID to ID Cache Contents --------\n")); ASSERT_LATCH(&GUIDtoIDCache.latch); if (GUIDtoIDCache.hash != NULL) @@ -859,7 +854,7 @@ void G2I_InvalidateCache(void) DQhead_t *hp; NINT i; GUIDtoIDCacheNode_s *item; - + if (GUIDtoIDCache.numHashEntries == 0) { return; @@ -869,7 +864,7 @@ void G2I_InvalidateCache(void) X_LATCH(&GUIDtoIDCache.latch); if (GUIDtoIDCache.hash != NULL) { - for (hp = &(*GUIDtoIDCache.hash)[0], i = GUIDtoIDCache.numHashEntries; + for (hp = &(*GUIDtoIDCache.hash)[0], i = GUIDtoIDCache.numHashEntries; i > 0; hp++,i--) { for (;;) @@ -909,7 +904,7 @@ void G2I_InvalidateManagementLevel( DQhead_t *hashp; NINT i; GUIDtoIDCacheNode_s *node; - + if (GUIDtoIDCache.numHashEntries == 0) { return; @@ -919,7 +914,7 @@ void G2I_InvalidateManagementLevel( X_LATCH(&GUIDtoIDCache.latch); if (GUIDtoIDCache.hash != NULL) { - for (hashp=&(*GUIDtoIDCache.hash)[0], i=0; + for (hashp=&(*GUIDtoIDCache.hash)[0], i=0; i < GUIDtoIDCache.numHashEntries; hashp++,i++) { DQ_FOREACH(hashp, node, GUIDtoIDCacheNode_s, hashLink) @@ -946,17 +941,17 @@ void G2I_AlarmThread (FsmLite_s *fsm) G2I_InvalidateCache(); if (!GUIDtoIDCache.shutdown) { - secOneShot( &GUIDtoIDCache.alarm, G2I_CacheInvalidateTime, + secOneShot( &GUIDtoIDCache.alarm, G2I_CacheInvalidateTime, G2I_HandleAlarm); } GUIDtoIDCache.running = FALSE; -} +} void G2I_HandleAlarm (OneShot_s *alarm) { GUIDtoIDCache.running = TRUE; - WORK_Schedule(&GUIDtoIDCache.fsm, (voidfunc_t)G2I_AlarmThread, 0); -} + WORK_Schedule( &GUIDtoIDCache.fsm, G2I_AlarmThread, 0); +} /************************************************************************** * This will initialize the GUID to ID cache @@ -974,7 +969,7 @@ STATUS G2I_CacheInit(void) */ if (!ONESHOT_SET(GUIDtoIDCache.alarm)) { - secOneShot(&GUIDtoIDCache.alarm, G2I_CacheInvalidateTime, + secOneShot(&GUIDtoIDCache.alarm, G2I_CacheInvalidateTime, G2I_HandleAlarm); } return zOK; @@ -1005,8 +1000,8 @@ NINT G2I_ComputeHash( // This takes into account the fact the times in eDir GUIDS are really // in milliseconds, not in 100 nanosecond increments. LONG adjustedTime = guid->timeLow >> 4; - return adjustedTime & (GUIDtoIDCache.numHashEntries - 1); -} + return adjustedTime & (GUIDtoIDCache.numHashEntries - 1); +} /**************************************************************************** @@ -1038,7 +1033,7 @@ GUIDtoIDCacheNode_s *G2I_CheckCache( #if NSS_DEBUG IS_ENABLED // char buffer[GUID_FORMAT_SIZE]; // LB_GUIDToString(guid, sizeof(buffer), buffer); -// DBG_DebugPrintf(LGREEN, +// DBG_DebugPrintf(LGREEN, // MSGNot("G2I cache hit: guid=%s\n"), buffer); #endif DQ_RMV(cacheNode, LRUlink); @@ -1058,7 +1053,7 @@ GUIDtoIDCacheNode_s *G2I_CheckCache( } /**************************************************************************** - * Add a new cache entry. + * Add a new cache entry. *****************************************************************************/ GUIDtoIDCacheNode_s *G2I_AddEntryToCache( NDSid_t *guid, @@ -1167,7 +1162,7 @@ void I2G_DisplayCache(void) IDtoGUIDCacheNode_s *node; char buffer[GUID_FORMAT_SIZE]; - + DBG_DebugPrintf(LGRAY,MSGNot("-------- ID to GUID Cache Contents --------\n")); ASSERT_LATCH(&IDtoGUIDCache.latch); if (IDtoGUIDCache.hash != NULL) @@ -1228,7 +1223,7 @@ void I2G_InvalidateCache( X_LATCH(&IDtoGUIDCache.latch); if (IDtoGUIDCache.hash != NULL) { - for (hp = &(*IDtoGUIDCache.hash)[0], i = IDtoGUIDCache.numHashEntries; + for (hp = &(*IDtoGUIDCache.hash)[0], i = IDtoGUIDCache.numHashEntries; i > 0; hp++,i--) { for (;;) @@ -1293,20 +1288,20 @@ void I2G_AlarmThread (FsmLite_s *fsm) { /* Full has expired, reset the counter, and invalidate the full cache */ I2G_TotalIntervalDelay = 0; - I2G_InvalidateCache(TRUE); + I2G_InvalidateCache(TRUE); } else { /* Partial timer has expired, invalidate just negative entries */ - I2G_InvalidateCache(FALSE); + I2G_InvalidateCache(FALSE); } I2G_SetNextAlarm(); } - + void I2G_HandleAlarm (OneShot_s *alarm) { - WORK_Schedule(&IDtoGUIDCache.fsm, (voidfunc_t)I2G_AlarmThread, 0); -} + WORK_Schedule( &IDtoGUIDCache.fsm, I2G_AlarmThread, 0); +} /************************************************************************** * This will initialize the ID to GUID cache @@ -1347,8 +1342,8 @@ void I2G_CacheUninit(void) NINT I2G_ComputeHash( LONG id) { - return id & (IDtoGUIDCache.numHashEntries - 1); -} + return id & (IDtoGUIDCache.numHashEntries - 1); +} /**************************************************************************** @@ -1378,7 +1373,7 @@ STATIC IDtoGUIDCacheNode_s *I2G_CheckCache( if (id == cacheNode->id) { /* these are the same entry */ #if NSS_DEBUG IS_ENABLED -// DBG_DebugPrintf(LGREEN, +// DBG_DebugPrintf(LGREEN, // MSGNot("I2G cache hit: id=0x%x\n"), id); #endif DQ_RMV(cacheNode, LRUlink); @@ -1394,7 +1389,7 @@ STATIC IDtoGUIDCacheNode_s *I2G_CheckCache( } /**************************************************************************** - * Add a new cache entry. + * Add a new cache entry. *****************************************************************************/ IDtoGUIDCacheNode_s *I2G_AddEntryToCache( NINT id, @@ -1512,8 +1507,8 @@ STATUS COMN_GetManagementLevel( if (cacheNode) { if (cacheNode->flags & G2I_POSITIVE_ENTRY) - { - if (cacheNode->managementLevel != -1 && + { + if (cacheNode->managementLevel != -1 && genMsg->pssConn.id == cacheNode->connID) { *managementLevel = cacheNode->managementLevel; @@ -1543,7 +1538,7 @@ STATUS COMN_GetManagementLevel( } MPKNSS_UNLOCK(); - *managementLevel = + *managementLevel = (*(NameService.GetManagementLevel))(genMsg->pssConn.id, id); MPKNSS_LOCK(); // DBG_DebugPrintf(YELLOW, "management level from GetManagementLevel = %d\n", *managementLevel); @@ -1632,8 +1627,8 @@ NINT SE_CacheInvalidateTime = SE_CACHE_INVALIDATE_TIME; void SE_HandleAlarm(OneShot_s *alarm); -#define DEFAULT_SE_CACHE_SIZE (1<<12) /* must be a power of two or the - * compute hash routine needs to be +#define DEFAULT_SE_CACHE_SIZE (1<<12) /* must be a power of two or the + * compute hash routine needs to be * changed */ typedef struct SECacheCtrl_s { @@ -1668,7 +1663,7 @@ typedef struct SECacheNode_s #if zLINUX NDSid_t guid; NDSid_t *guidList; - BOOL isSupervisor; + BOOL isSupervisor; #endif } SECacheNode_s; @@ -1699,12 +1694,12 @@ void SE_DisplayCache(void) DQhead_t *hashp; NINT i; SECacheNode_s *node; - + DBG_DebugPrintf(LGRAY,MSGNot("-------- Security Equivalence Cache Contents --------\n")); ASSERT_LATCH(&SECache.latch); if (SECache.hash != NULL) { - for (hashp=&(*SECache.hash)[0],i=0; i < SECache.numHashEntries; + for (hashp=&(*SECache.hash)[0],i=0; i < SECache.numHashEntries; hashp++,i++) { DQ_FOREACH(hashp, node, SECacheNode_s, hashLink) @@ -1723,11 +1718,11 @@ void SE_DisplayCache(void) for (j = 0; j < node->numSeEntries; j++) { #if zNETWARE - DBG_DebugPrintf(YELLOW, MSGNot("0x%8.8x "), + DBG_DebugPrintf(YELLOW, MSGNot("0x%8.8x "), (node->list)[j]); #endif #if zLINUX - DBG_DebugPrintf(YELLOW, MSGNot("0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x, "), + DBG_DebugPrintf(YELLOW, MSGNot("0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x, "), (node->guidList)[j]); #endif } @@ -1815,7 +1810,7 @@ STATUS SE_CacheInit() /* Invalidate the cache occasionally */ if (!ONESHOT_SET(SECache.alarm)) { - secOneShot(&SECache.alarm, SE_CacheInvalidateTime, + secOneShot(&SECache.alarm, SE_CacheInvalidateTime, SE_HandleAlarm); } return zOK; @@ -1915,20 +1910,20 @@ void SE_InvalidateCache(void) **************************************************************************/ void SE_AlarmThread (FsmLite_s *fsm) { - SE_InvalidateCache(); + SE_InvalidateCache(); if (!SECache.shutdown) { - secOneShot( &SECache.alarm, SE_CacheInvalidateTime, + secOneShot( &SECache.alarm, SE_CacheInvalidateTime, SE_HandleAlarm); } SECache.running = FALSE; } - + void SE_HandleAlarm (OneShot_s *alarm) { SECache.running = TRUE; - WORK_Schedule( &SECache.fsm, (voidfunc_t)SE_AlarmThread, 0); -} + WORK_Schedule( &SECache.fsm, SE_AlarmThread, 0); +} /************************************************************************** * This generates the HASH value for an entry @@ -1937,8 +1932,8 @@ void SE_HandleAlarm (OneShot_s *alarm) NINT SE_ComputeHash( LONG id) { - return id & (SECache.numHashEntries - 1); -} + return id & (SECache.numHashEntries - 1); +} #endif #if zLINUX NINT SE_ComputeHash( @@ -1947,8 +1942,8 @@ NINT SE_ComputeHash( // This takes into account the fact the times in eDir GUIDS are really // in milliseconds, not in 100 nanosecond increments. LONG adjustedTime = guid->timeLow >> 4; - return adjustedTime & (SECache.numHashEntries - 1); -} + return adjustedTime & (SECache.numHashEntries - 1); +} #endif /**************************************************************************** @@ -2010,7 +2005,7 @@ STATIC SECacheNode_s *SE_CheckCache( } /**************************************************************************** - * Add a new cache entry. + * Add a new cache entry. *****************************************************************************/ #if zNETWARE SECacheNode_s *SE_AddEntryToCache( @@ -2145,18 +2140,18 @@ STATUS COMN_GetSecurityEquivalenceList( node = SE_CheckCache(objectID, bufferSizeInLongs); if (node != NULL) { - memcpy(securityEquivalenceList, node->list, + memcpy(securityEquivalenceList, node->list, sizeof(LONG) * node->numSeEntries); *securityEquivalenceCount = node->numSeEntries; *privileges = node->privileges; #if NSS_DEBUG IS_ENABLED { NINT i; - DBG_DebugPrintf(YELLOW, MSGNot("Return SE cache entry: id=0x%x priv=0x%x\n"), + DBG_DebugPrintf(YELLOW, MSGNot("Return SE cache entry: id=0x%x priv=0x%x\n"), objectID, *privileges); for (i = 0; i < node->numSeEntries; i++) { - DBG_DebugPrintf(YELLOW, MSGNot(" (%d) id=0x%x\n"), i, (node->list)[i]); + DBG_DebugPrintf(YELLOW, MSGNot(" (%d) id=0x%x\n"), i, (node->list)[i]); } } #endif @@ -2165,7 +2160,7 @@ STATUS COMN_GetSecurityEquivalenceList( MPKNSS_UNLOCK(); status = (*(NameService.GetObjectSecurityEquivalenceList))( - 0, objectID, 0, + 0, objectID, 0, bufferSizeInLongs, securityEquivalenceList, securityEquivalenceCount, NOCHECK); if (status != 0) @@ -2173,7 +2168,7 @@ STATUS COMN_GetSecurityEquivalenceList( MPKNSS_LOCK(); return status; } - status = (*(NameService.GetObjectPrivileges))(0, objectID, 0, privileges, + status = (*(NameService.GetObjectPrivileges))(0, objectID, 0, privileges, NOCHECK); if (status != 0) { @@ -2189,7 +2184,7 @@ STATUS COMN_GetSecurityEquivalenceList( aprintf(LRED, "NSS: Unable to add security equivelance cache entry\n"); } #endif - return 0; + return 0; } #endif /* NetWare */ @@ -2210,18 +2205,18 @@ STATUS COMN_GetSecurityEquivalenceList( node = SE_CheckCache(objectID, bufferSizeInGUIDs); if (node != NULL) { - memcpy(securityEquivalenceList, node->guidList, + memcpy(securityEquivalenceList, node->guidList, sizeof(NDSid_t) * node->numSeEntries); *securityEquivalenceCount = node->numSeEntries; *isSupervisor = node->isSupervisor; #if NSS_DEBUG IS_ENABLED { NINT i; - DBG_DebugPrintf(YELLOW, MSGNot("Return SE cache entry: id=0x%x super=%d\n"), + DBG_DebugPrintf(YELLOW, MSGNot("Return SE cache entry: id=0x%x super=%d\n"), objectID, *isSupervisor); for (i = 0; i < node->numSeEntries; i++) { - DBG_DebugPrintf(YELLOW, MSGNot(" (%d) id=0x%x 0x%x 0x%x 0x%x\n"), i, (node->guidList)[i]); + DBG_DebugPrintf(YELLOW, MSGNot(" (%d) id=0x%x 0x%x 0x%x 0x%x\n"), i, (node->guidList)[i]); } } #endif @@ -2241,7 +2236,7 @@ STATUS COMN_GetSecurityEquivalenceList( free(objectDN); return(status); } - + MPKNSS_UNLOCK(); status = ndp_NCPMapDNToSEV(objectDN, &count, &nwIDs, isSupervisor); *securityEquivalenceCount = count; @@ -2269,7 +2264,7 @@ STATUS COMN_GetSecurityEquivalenceList( aprintf(LRED, "NSS: Unable to add security equivelance cache entry\n"); } #endif - return(status); + return(status); } EXPORT_SYMBOL(COMN_GetSecurityEquivalenceList); #endif @@ -2312,9 +2307,9 @@ STATUS getGUID ( MPKNSS_UNLOCK(); - err = (*DDCReadToBufferPtr)(context, &filter, DS_VALUE_INFO, + err = (*DDCReadToBufferPtr)(context, &filter, DS_VALUE_INFO, ATTR_DATA_SIZE - 1, ATTR_DATA_SIZE - 1, attributeData, &count); - if (err != 0) + if (err != 0) { *NDSid = zINVALID_GUID; goto exit; @@ -2405,7 +2400,7 @@ STATUS COMN_MapNDSIDToGUID( if (cacheNode != NULL) { /* cache node found */ if (cacheNode->flags & I2G_POSITIVE_ENTRY) - { + { *ndsGUID = cacheNode->guid; STACK_FREE(); return zOK; @@ -2643,7 +2638,7 @@ STATUS COMN_MapUIDToNDSGUID( if (cacheNode != NULL) { /* cache node found */ if (cacheNode->flags & I2G_POSITIVE_ENTRY) - { + { *ndsGUID = cacheNode->guid; STACK_FREE(); return zOK; @@ -2734,13 +2729,13 @@ void COMN_UpdateUIDToGUIDCache( NDSid_t *ndsGUID) { IDtoGUIDCacheNode_s *cacheNode; - + /* Check the cache to see if it exists. */ cacheNode = I2G_CheckCache(UID); if (cacheNode != NULL) { /* cache node found */ if (cacheNode->flags & I2G_POSITIVE_ENTRY) - { + { return; } else @@ -2794,7 +2789,7 @@ void COMN_ValidateTreeName( /* compare the server's tree name to the tree in the input name */ if (dName[inLen-serverLen-2] == '.') { - memcpy(aStack->inTreeName, &dName[inLen-serverLen-1], + memcpy(aStack->inTreeName, &dName[inLen-serverLen-1], serverLen*sizeof(unicode_t)); aStack->inTreeName[serverLen] = 0; //DBG_DebugPrintf(YELLOW, "inTreeName=%U................\n", aStack->inTreeName); @@ -2816,9 +2811,9 @@ void COMN_ValidateTreeName( { aprintf(YELLOW, MSGNew("Removing %U from the NSS object ID store\n", 0), dName); } - + xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, X_CF_DEFAULT); - volume->VOLcomnVolOps.VOL_modifyObjectName(genMsg, volume, xaction, + volume->VOLcomnVolOps.VOL_modifyObjectName(genMsg, volume, xaction, ndsGUID, &noName, 0, 0); volume->VOLcomnVolOps.VOL_endXLocal(xaction); STACK_FREE(); @@ -2885,7 +2880,7 @@ void COMN_CheckForChangedTree( int context; NINT status; const unicode dotDelims[] = {DELIM_CFG_FALSE, DELIM_CFG_TRUE, - DELIM_DF_RDN, DELIM_DF_RDN, DELIM_DV, DELIM_VALUE, DELIM_WILD, + DELIM_DF_RDN, DELIM_DF_RDN, DELIM_DV, DELIM_VALUE, DELIM_WILD, DELIM_DF_ESCAPE, 0}; #endif typedef struct Stack_s { @@ -2945,13 +2940,13 @@ void COMN_CheckForChangedTree( if ((err = ndp_NCPLocalTreeName(sizeof(alloc->serverTreeName), alloc->serverTreeName)) != zOK) { - MPKNSS_LOCK(); + MPKNSS_LOCK(); printk(KERN_ALERT "Unable to get server tree name from eDir, err=%d\n", err); // zASSERT("Unable to get tree name from eDir" == NULL); goto exitFree; } MPKNSS_LOCK(); -} +} #endif #if zNETWARE @@ -3039,7 +3034,7 @@ void COMN_CheckForChangedTree( for (;;) { if (volume->VOLcomnVolOps.VOL_browseUsersInVolume(&genMsg, volume, - MAX_USER_INFO_ENTRIES, &aStack->lastUserReturned, aStack->userInfo, + MAX_USER_INFO_ENTRIES, &aStack->lastUserReturned, aStack->userInfo, &numReturned, BROWSE_USERS_GET_ALL) != zOK) { zASSERT("Error browsing users in volume" == NULL); @@ -3073,7 +3068,7 @@ void COMN_CheckForChangedTree( } xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, X_CF_DEFAULT); - volume->VOLcomnVolOps.VOL_insertObjectName(&genMsg, volume, xaction, + volume->VOLcomnVolOps.VOL_insertObjectName(&genMsg, volume, xaction, &zTREENAME_ID, alloc->serverTreeName); volume->VOLcomnVolOps.VOL_endXLocal(xaction); @@ -3110,8 +3105,8 @@ void COMN_CheckAllVolumesForChangedTree() ASSERT_MPKNSS_LOCK(); /* - * Start by checking all volumes to see if we are in the same tree as we - * were last time we checked. This is only occasionally since it is + * Start by checking all volumes to see if we are in the same tree as we + * were last time we checked. This is only occasionally since it is * expensive. */ //DBG_DebugPrintf(YELLOW, "Checking all volumes for tree change..........\n"); @@ -3135,13 +3130,13 @@ void COMN_CheckAllVolumesForChangedTree() COMN_UnlockVolumeActive(volume, FALSE); } COMN_Release(&volume); - SET_FOREACHBLOCKINGEND(&NSSMasterVolumeList, volume, Volume_s, + SET_FOREACHBLOCKINGEND(&NSSMasterVolumeList, volume, Volume_s, masterVolLink); } } /************************************************************************** - * This function gets the name for an ID from the object ID store and + * This function gets the name for an ID from the object ID store and * resolves to the NDS object. It then reads the ID from the object and * returns it. ***************************************************************************/ @@ -3160,7 +3155,7 @@ STATUS COMN_GetIDFromObjectStore( #if zNETWARE int context; const unicode dotDelims[] = {DELIM_CFG_FALSE, DELIM_CFG_TRUE, - DELIM_DF_RDN, DELIM_DF_RDN, DELIM_DV, DELIM_VALUE, DELIM_WILD, + DELIM_DF_RDN, DELIM_DF_RDN, DELIM_DV, DELIM_VALUE, DELIM_WILD, DELIM_DF_ESCAPE, 0}; #endif #if zLINUX @@ -3318,7 +3313,7 @@ STATUS COMN_GetIDFromObjectStore( // } // /* Get entry info */ - status = (*DDCGetEntryInfoPtr)(context, DSI_ENTRY_ID, sizeof(*objectID), + status = (*DDCGetEntryInfoPtr)(context, DSI_ENTRY_ID, sizeof(*objectID), objectID); if (status != 0) { @@ -3362,7 +3357,7 @@ STATUS COMN_GetIDFromObjectStore( MPKNSS_UNLOCK(); status = ndp_NCPMapDNToGUID(1, aStack->unicodeDName,&otherGUID); if ((status != 0) || (LB_GUIDCompare(ndsGUID, &otherGUID) != 0)) - { + { if (status != 0) { if ((uni2utf(aStack->unicodeDName, aStack->utf8DName, sizeof(aStack->utf8DName))) == -1) @@ -3395,7 +3390,7 @@ STATUS COMN_GetIDFromObjectStore( status = ndp_NCPMapGUIDToUID(ndsGUID, objectID); if (status != 0) { - // Users that are not LUM enabled cause errors, so we only want to + // Users that are not LUM enabled cause errors, so we only want to // display the message if it is for some other reason. if (status != -601) { @@ -3408,7 +3403,7 @@ STATUS COMN_GetIDFromObjectStore( #if NSS_DEBUG IS_ENABLED -DBG_DebugPrintf(LMAGENTA, "COMN_GetIDFromObjectStore: ID=%d Name=%U\n", +DBG_DebugPrintf(LMAGENTA, "COMN_GetIDFromObjectStore: ID=%d Name=%U\n", *objectID, aStack->unicodeDName); #endif STACK_FREE(); @@ -3434,7 +3429,7 @@ errorExitLocked: *objectID = 0; STACK_FREE(); return zFAILURE; -} +} #if zNETWARE /************************************************************************** @@ -3449,8 +3444,8 @@ STATUS COMN_MapNDSGUIDToID( Volume_s *volume, NDSid_t *ndsGUID, LONG *objectID) -{ - return COMN_MapNDSGUIDToIDWithNameMsg(error, volume, ndsGUID, objectID, +{ + return COMN_MapNDSGUIDToIDWithNameMsg(error, volume, ndsGUID, objectID, NULL); } #endif @@ -3466,7 +3461,7 @@ STATUS COMN_MapNDSGUIDToUID( STATUS *error, NDSid_t *ndsGUID, LONG *objectID) -{ +{ return COMN_MapNDSGUIDToIDWithNameMsg(error, NULL, ndsGUID, objectID, NULL); } #endif @@ -3617,10 +3612,10 @@ STATUS COMN_LocalMapNDSGUIDToID( /************************************************************************** - * This routine is almost the same as COMN_MapNDSGUIDToID except that - * caller holds latch/latches which should be released in order to avoid - * potential deadlock if guid is not found in cache and NDS routine has - * to be called. + * This routine is almost the same as COMN_MapNDSGUIDToID except that + * caller holds latch/latches which should be released in order to avoid + * potential deadlock if guid is not found in cache and NDS routine has + * to be called. ***************************************************************************/ STATUS COMN_MapNDSGUIDToIDWithNameMsg( STATUS *error, @@ -3635,7 +3630,7 @@ STATUS COMN_MapNDSGUIDToIDWithNameMsg( ASSERT_MPKNSS_LOCK(); - if (COMN_LocalMapNDSGUIDToID(error, ndsGUID, objectID, nameMsg, + if (COMN_LocalMapNDSGUIDToID(error, ndsGUID, objectID, nameMsg, &addToCache) != zOK) { GeneralMsg_s genMsg; @@ -3663,7 +3658,7 @@ STATUS COMN_MapNDSGUIDToIDWithNameMsg( if ((status = COMN_LockVolumeActive(&genMsg, volume, FALSE)) == zOK) { - status = COMN_GetIDFromObjectStore(error, volume, ndsGUID,objectID); + status = COMN_GetIDFromObjectStore(error, volume, ndsGUID,objectID); COMN_UnlockVolumeActive(volume, FALSE); } else @@ -3685,7 +3680,7 @@ STATUS COMN_MapNDSGUIDToIDWithNameMsg( } else { - SET_FOREACHBLOCKING(&NSSMasterVolumeList, volume, Volume_s, + SET_FOREACHBLOCKING(&NSSMasterVolumeList, volume, Volume_s, masterVolLink) { /*** You MUST NOT use continue in this loop because the macro *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called @@ -3704,7 +3699,7 @@ STATUS COMN_MapNDSGUIDToIDWithNameMsg( { COMN_UNLATCH_NAMEMSG_BEASTS_KEEP_LATCHTYPE(nameMsg); } - status = COMN_GetIDFromObjectStore(error, volume, ndsGUID, + status = COMN_GetIDFromObjectStore(error, volume, ndsGUID, objectID); if (nameMsg) { @@ -3718,7 +3713,7 @@ STATUS COMN_MapNDSGUIDToIDWithNameMsg( goto addToCache; } next: - SET_FOREACHBLOCKINGEND(&NSSMasterVolumeList, volume, Volume_s, + SET_FOREACHBLOCKINGEND(&NSSMasterVolumeList, volume, Volume_s, masterVolLink); } found = FALSE; diff --git a/src/nwnss/comn/authsys/unixAuthModel.c b/src/nwnss/comn/authsys/unixAuthModel.c index 15f1559..fe19675 100644 --- a/src/nwnss/comn/authsys/unixAuthModel.c +++ b/src/nwnss/comn/authsys/unixAuthModel.c @@ -32,7 +32,7 @@ | |--------------------------------------------------------------------------- | This module is used to: - | These are the authorization routines for the Unix authorization + | These are the authorization routines for the Unix authorization | model. +-------------------------------------------------------------------------*/ #include @@ -185,7 +185,7 @@ void UXAUTH_NoPackAuthBeastCleanup( { ASSERT_MPKNSS_LOCK(); return; -} +} /*************************************************************************** * This routine is called when an auth beast is read from storage @@ -384,7 +384,7 @@ STATUS UXAUTH_CheckUserIDs( authInfo = beast->AUTHauthInfo.unx; - if (CHK_VerifyID(genMsg, volume, &beast->authInfo.unx->p.groupID, + if (CHK_VerifyID(genMsg, volume, &beast->authInfo.unx->p.groupID, &isOK) == zOK) { if (!isOK) @@ -425,7 +425,7 @@ STATUS UXAS_ChangeOwner( info.id.owner = *newOwner; COMN_STRUCT_INIT(infoMsg); - COMN_SETUP_MODIFY_INFO_MSG(&infoMsg, zMOD_OWNER_ID, &info, + COMN_SETUP_MODIFY_INFO_MSG(&infoMsg, zMOD_OWNER_ID, &info, zINFO_VERSION_A); return COMN_ModifyInfo(genMsg, nameMsg, &infoMsg); @@ -489,9 +489,9 @@ void UXAS_StoreIDInGUID( } /*************************************************************************** - * The authorization operations for the system + * The authorization operations for the system ***************************************************************************/ -struct AuthModelOps_s UnixAuthorizeModelOps = +struct AuthModelOps_s UnixAuthorizeModelOps = { UXAUTH_ConstructAuthBeast, UXAUTH_DestructAuthBeast, @@ -510,3 +510,4 @@ struct AuthModelOps_s UnixAuthorizeModelOps = UXAUTH_CheckUserIDs, UXAUTH_InvalidateAuthInfo, }; + diff --git a/src/nwnss/comn/authsys/unixAuthSpace.c b/src/nwnss/comn/authsys/unixAuthSpace.c index 886679d..259c48c 100644 --- a/src/nwnss/comn/authsys/unixAuthSpace.c +++ b/src/nwnss/comn/authsys/unixAuthSpace.c @@ -40,9 +40,9 @@ #include "comnPublics.h" #include "msgName.h" #include "unixAuthModel.h" - + /**************************************************************************** - * This routine will change the user ID in the Unix authorization info + * This routine will change the user ID in the Unix authorization info * for a beast. ****************************************************************************/ STATIC STATUS UX_chown( @@ -97,7 +97,7 @@ justReturn: } /**************************************************************************** - * This routine will change the mode in the Unix authorization info + * This routine will change the mode in the Unix authorization info * for a beast. ****************************************************************************/ STATIC STATUS UX_chmod( @@ -135,7 +135,7 @@ justReturn: } /**************************************************************************** - * This routine will get the IDs and mode in the Unix authorization info + * This routine will get the IDs and mode in the Unix authorization info * for a beast. ****************************************************************************/ STATUS UX_statAuth( @@ -176,7 +176,7 @@ justReturn: } /**************************************************************************** - * This routine will change the user ID in the Unix authorization info + * This routine will change the user ID in the Unix authorization info * for a beast. ****************************************************************************/ STATUS UX2NW_chown( @@ -190,7 +190,7 @@ STATUS UX2NW_chown( } /**************************************************************************** - * This routine will change the mode in the Unix authorization info + * This routine will change the mode in the Unix authorization info * for a beast. ****************************************************************************/ STATUS UX2NW_chmod( @@ -203,7 +203,7 @@ STATUS UX2NW_chmod( } /**************************************************************************** - * This routine will get the IDs and mode in the Unix authorization info + * This routine will get the IDs and mode in the Unix authorization info * for a beast. ****************************************************************************/ STATIC STATUS UX2NW_statAuth( @@ -219,14 +219,14 @@ STATIC STATUS UX2NW_statAuth( /***************************************************************************/ -struct UnixAuthSpaceOps_s UnixAuthorizeSpaceOps = +struct UnixAuthSpaceOps_s UnixAuthorizeSpaceOps = { UX_chown, UX_chmod, UX_statAuth, }; -struct UnixAuthSpaceOps_s UnixToNetWareAuthorizeSpaceOps = +struct UnixAuthSpaceOps_s UnixToNetWareAuthorizeSpaceOps = { UX2NW_chown, UX2NW_chmod, diff --git a/include/nwnss/include/unixAuthSpace.h b/src/nwnss/comn/authsys/unixAuthSpace.h similarity index 98% rename from include/nwnss/include/unixAuthSpace.h rename to src/nwnss/comn/authsys/unixAuthSpace.h index b9efe89..03c1259 100644 --- a/include/nwnss/include/unixAuthSpace.h +++ b/src/nwnss/comn/authsys/unixAuthSpace.h @@ -38,7 +38,7 @@ #define _UNIXAUTHSPACE_H_ #ifndef _OMNI_H_ -#include +#include #endif #ifndef _COMNAUTHORIZE_H_ diff --git a/src/nwnss/comn/authsys/unixDecision.c b/src/nwnss/comn/authsys/unixDecision.c index dcb75c7..3bf6993 100644 --- a/src/nwnss/comn/authsys/unixDecision.c +++ b/src/nwnss/comn/authsys/unixDecision.c @@ -71,7 +71,7 @@ NINT UX_GetEffectivePermissions( permissions |= (*mode & UX_IRWXU) >> UX_IMU; } /* Check the "group" permissions */ - else if (LB_GUIDCompare(&authBeast->authInfo.unx->p.groupID, + else if (LB_GUIDCompare(&authBeast->authInfo.unx->p.groupID, &IDs[connectIndex]) == 0) { permissions |= (*mode & UX_IRWXG) >> UX_IMG; @@ -115,7 +115,7 @@ STATIC STATUS UX_MayISeeTheObject( COMN_Release(&parentBeast); if (permissions & UX_IR) { - return zOK; + return zOK; } return zFAILURE; @@ -141,7 +141,7 @@ STATIC STATUS UX_MayIReadData( permissions = UX_GetEffectivePermissions(authBeast, IDs, numIDs, &mode); if (permissions & UX_IR) { - return zOK; + return zOK; } return zFAILURE; @@ -167,7 +167,7 @@ STATIC STATUS UX_MayIWriteData( permissions = UX_GetEffectivePermissions(authBeast, IDs, numIDs, &mode); if (permissions & UX_IW) { - return zOK; + return zOK; } return zFAILURE; @@ -211,7 +211,7 @@ STATIC STATUS UX_MayICreate( COMN_Release(&parentBeast); if (permissions & UX_IW) { - return zOK; + return zOK; } return zFAILURE; @@ -256,7 +256,7 @@ STATIC STATUS UX_MayICreateOnly( COMN_Release(&parentBeast); if (permissions == UX_IW) { - return zOK; + return zOK; } return zFAILURE; @@ -284,7 +284,7 @@ STATIC STATUS UX_MayIDelete( permissions = UX_GetEffectivePermissions(authBeast, IDs, numIDs, &mode); if (!(permissions & UX_IW)) { - return zFAILURE; + return zFAILURE; } if (parentZID != zINVALID_ZID) @@ -307,7 +307,7 @@ STATIC STATUS UX_MayIDelete( if (!(permissions & UX_IW)) { COMN_Release(&parentBeast); - return zFAILURE; + return zFAILURE; } /* Check the sticky bit */ @@ -362,7 +362,7 @@ STATUS UXAUTH_MayIDoThis( { /* if the connection has supervisor privilege allow all rights */ return zOK; } - + IDs = &genMsg->pssConn.ptr->authInfo.authenticatedIDs[0]; numIDs = genMsg->pssConn.ptr->authInfo.numAuthenticatedIDs; @@ -373,7 +373,7 @@ STATUS UXAUTH_MayIDoThis( zOK : zFAILURE; case MAY_I_SEE_THE_WILDCARD_OBJECT: case MAY_I_SEE_THE_OBJECT: - return UX_MayISeeTheObject(genMsg, authBeast, parentZID, IDs, + return UX_MayISeeTheObject(genMsg, authBeast, parentZID, IDs, numIDs); case MAY_I_READ_DATA: return UX_MayIReadData(authBeast, IDs, numIDs); @@ -399,3 +399,5 @@ STATUS UXAUTH_MayIDoThis( return zFAILURE; } } + + diff --git a/src/nwnss/comn/authsys/zasAuthModel.c b/src/nwnss/comn/authsys/zasAuthModel.c index b17ea59..ba7b2f7 100644 --- a/src/nwnss/comn/authsys/zasAuthModel.c +++ b/src/nwnss/comn/authsys/zasAuthModel.c @@ -2115,7 +2115,7 @@ void ZAS_FixVisibilityThread(FsmLite_s *fsm); void ZAS_FixVisibilityGotParentLatch(FsmLite_s *fsm) { TotalVisibilityProcesses++; - WORK_Schedule(fsm, (voidfunc_t)ZAS_FixVisibilityThread, 0); + WORK_Schedule(fsm, ZAS_FixVisibilityThread, 0); return; } @@ -2455,7 +2455,7 @@ STATUS ZAS_CheckInheritedVisibility( for (connectIndex = 0; connectIndex < numIDs; connectIndex++) { /* for each entry in the connection structure */ - if (ZAS_FindVisibilityTrustee(genMsg, authBeast, NULL, + if (ZAS_FindVisibilityTrustee(genMsg, authBeast, NULL, &IDs[connectIndex], SLATCHED, &entry, &entryIndex, &beast, &dummyZid) != zOK) { @@ -3831,7 +3831,7 @@ STATUS ZAS_AddACLEntry( zASSERT("Broken hard link chain"==NULL); hlZid = zINVALID_ZID; } - } + } } else { @@ -3866,7 +3866,7 @@ STATUS ZAS_AddACLEntry( authBeast->AUTHattributes |= zFA_ATTR_ARCHIVE; writeMainBeast = TRUE; } - + if ((modifyMetaDataTime) && (COMN_IsDerivedFrom(authBeast, zFTYPE_FILE))) { File_s *file = (File_s *)authBeast; @@ -4318,7 +4318,7 @@ STATUS ZAS_RemoveLatchedACLEntry( zASSERT("Broken hard link chain"==NULL); hlZid = zINVALID_ZID; } - } + } } else { @@ -4557,14 +4557,14 @@ zASSERT(GetErrno(genMsg) != 20000); hlZid,NOTLATCHED,TRUE); if (hlBeast != NULL) { - if ((status = ZAS_AddBeastVisibility(genMsg, - (AuthBeast_s *)beast, ((File_s *)hlBeast)->FILEfirstParentZid, + if ((status = ZAS_AddBeastVisibility(genMsg, + (AuthBeast_s *)beast, ((File_s *)hlBeast)->FILEfirstParentZid, FALSE, stats, FALSE)) != zOK) { aprintf(LRED, MSG("Visibility rebuild on volume %U:\n" "Error %d looking up an object while adding visibility.\n",249), name, GetErrno(genMsg)); - + } hlZid = hlBeast->HARDLhardLinkZid; @@ -4575,12 +4575,12 @@ zASSERT(GetErrno(genMsg) != 20000); zASSERT("Broken hard link chain"==NULL); hlZid = zINVALID_ZID; } - } + } } else { - if ((status = ZAS_AddBeastVisibility(genMsg, - (AuthBeast_s *)beast, ((File_s *)beast)->FILEfirstParentZid, + if ((status = ZAS_AddBeastVisibility(genMsg, + (AuthBeast_s *)beast, ((File_s *)beast)->FILEfirstParentZid, FALSE, stats, FALSE)) != zOK) { aprintf(LRED, MSG("Visibility rebuild on volume %U:\n" @@ -4662,7 +4662,7 @@ void ZAS_VisibilityRebuildThread( parms->name); goto exitStats; } - if (vol->VOLcomnVolOps.VOL_browseBeastsInVolume(&genMsg, + if (vol->VOLcomnVolOps.VOL_browseBeastsInVolume(&genMsg, vol, SELECT_BEASTS_ALL, NUM_REQUESTED_ZIDS, &startingZid, zidArray, &numReturnedZids) != zOK) { @@ -4831,7 +4831,7 @@ void ZAS_VisibilityRebuild( unicpy(parms->name, name); FSMLITE_INIT(fsm, "FSM for visibility rebuild ", ++fsmInstance); - WORK_Schedule(fsm, (voidfunc_t)ZAS_VisibilityRebuildThread, (ADDR)parms); + WORK_Schedule(fsm, ZAS_VisibilityRebuildThread, (ADDR)parms); aprintf(WHITE, MSG("Visibility rebuild started on volume \"%U\".\n",302), name); diff --git a/src/nwnss/comn/authsys/zasAuthSpace.c b/src/nwnss/comn/authsys/zasAuthSpace.c index 131c830..e347dec 100644 --- a/src/nwnss/comn/authsys/zasAuthSpace.c +++ b/src/nwnss/comn/authsys/zasAuthSpace.c @@ -38,10 +38,6 @@ +-------------------------------------------------------------------------*/ #include #include -#if defined(NSS_USERSPACE) -#undef STATIC -#define STATIC static -#endif #include #include #include @@ -85,7 +81,7 @@ NINT TotalVisibilityProcesses = 0; static inline BOOL NSSLAF_GenerateAuditLog (GeneralMsg_s *genMsg, STATUS status) { if ( NSSLAF_AuditEnabled && (status == zOK) && - !(genMsg->flags & DO_NOT_SEND_EVENTS) ) + !(genMsg->flags & DO_NOT_SEND_EVENTS) ) { return TRUE; } @@ -170,13 +166,13 @@ STATIC STATUS VAUTH_AddACLEntry( if (NSSLAF_GenerateAuditLog(genMsg, status)) { - NSSLAF_LogTrusteeChange(genMsg, nameMsg, + NSSLAF_LogTrusteeChange(genMsg, nameMsg, NSSLAF_MODE_ADD_TRUSTEE, trusteeID, rights, attributes, 0); } sendExitEvent: if (!(genMsg->flags & DO_NOT_SEND_EVENTS) && - (NEBEventInfo[EVENT_AddTrustee_Exit].consumers)) + (NEBEventInfo[EVENT_AddTrustee_Exit].consumers)) { COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, @@ -275,13 +271,13 @@ STATIC STATUS VAUTH_RemoveACLEntry( if (NSSLAF_GenerateAuditLog(genMsg, status)) { - NSSLAF_LogTrusteeChange(genMsg, nameMsg, + NSSLAF_LogTrusteeChange(genMsg, nameMsg, NSSLAF_MODE_REMOVE_TRUSTEE, trusteeID, 0, 0, 0); } sendExitEvent: if (!(genMsg->flags & DO_NOT_SEND_EVENTS) && - (NEBEventInfo[EVENT_RemoveTrustee_Exit].consumers)) + (NEBEventInfo[EVENT_RemoveTrustee_Exit].consumers)) { COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, @@ -591,15 +587,15 @@ STATIC STATUS VAUTH_SetInheritedRightsMask( { INIT_ENTER_EVENT(genMsg, nameMsg, aStack->evBlk, EVENT_SetInheritedRights_Enter, aStack->enter, id); - INIT_SET_RIGHTS_ENTER_EVENT(aStack->enter, inheritedRights, modifyFlag); - ZOS_ProduceEvent(status,&aStack->evBlk); - CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, justReturnLatch); + INIT_SET_RIGHTS_ENTER_EVENT(aStack->enter, inheritedRights, modifyFlag); + ZOS_ProduceEvent(status,&aStack->evBlk); + CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, justReturnLatch); } COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); } - /* Don't allow changes if the file is exclusive locked */ + /* Don't allow changes if the file is exclusive locked */ if ((nameMsg->curDataStream->NAMEDdenyReaderCount != 0) || (nameMsg->curDataStream->NAMEDdenyWriterCount != 0)) { @@ -657,8 +653,8 @@ STATIC STATUS VAUTH_SetInheritedRightsMask( status = zOK; if (sendAudit && NSSLAF_GenerateAuditLog(genMsg, status)) { - NSSLAF_LogTrusteeChange(genMsg, nameMsg, - NSSLAF_MODE_SET_INHERITED_RIGHTS, NULL, + NSSLAF_LogTrusteeChange(genMsg, nameMsg, + NSSLAF_MODE_SET_INHERITED_RIGHTS, NULL, 0, 0, inheritedRights); } @@ -671,7 +667,7 @@ sendExitEvent: genMsg, nameMsg, inheritedRights, &mInfo); if (!(genMsg->flags & DO_NOT_SEND_EVENTS) && - (NEBEventInfo[EVENT_SetInheritedRights_Exit].consumers)) + (NEBEventInfo[EVENT_SetInheritedRights_Exit].consumers)) { INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, EVENT_SetInheritedRights_Exit, aStack->exit, id); @@ -754,7 +750,7 @@ STATIC STATUS VAUTH_FindACLEntryInTree( COMN_SET_NAMING_MSG_PARSEMODE(nameMsg,NAMPMODE_DoNotResolveLeafName); COMN_SET_SEARCH_CHECK_FUNC(searchMsg, ZAS_CheckDirectory, - desiredTrusteeID, 1); + desiredTrusteeID, 1); zASSERT(searchMsg->srchMap.id != 0xffff); /* See if this happens */ if ((searchMsg->srchMap.id == -1) || (searchMsg->srchMap.id == 0)) { /* This is the first time in -- set up the searchmap */ @@ -1084,7 +1080,7 @@ STATUS VAUTH_GetVisibilityList( for (entry = 0, count = 0; (entry < authInfo->p.numVisibilityTrusteesAssigned) && - (count < *numTrustees); + (count < *numTrustees); entry++, count++) { trusteeVector[count].trusteeID = authInfo->p.visibilityList[entry].trusteeID; @@ -1103,7 +1099,7 @@ STATUS VAUTH_GetVisibilityList( } for (entry = 0; (entry < overflowBeast->p.numEntries) && (count < *numTrustees); - entry++, count++) + entry++, count++) { trusteeVector[count].trusteeID = overflowBeast->vis[entry].trusteeID; trusteeVector[count].count = overflowBeast->vis[entry].count; @@ -1142,7 +1138,7 @@ STATUS VAUTH_GetVisibilityList( for (entry = 0; (entry < aclOverflowBeast->p.numEntries) && (count < *numTrustees); - entry++) + entry++) { trusteeID = aclOverflowBeast->acl[entry].trusteeID; if (notInVisibilityList(&trusteeID, trusteeVector, tmpCount)) diff --git a/include/nwnss/include/zasAuthSpace.h b/src/nwnss/comn/authsys/zasAuthSpace.h similarity index 98% rename from include/nwnss/include/zasAuthSpace.h rename to src/nwnss/comn/authsys/zasAuthSpace.h index dee99e8..03d9de0 100644 --- a/include/nwnss/include/zasAuthSpace.h +++ b/src/nwnss/comn/authsys/zasAuthSpace.h @@ -38,7 +38,7 @@ #define _ZASAUTHSPACE_H_ #ifndef _OMNI_H_ -#include +#include #endif #ifndef _COMNAUTHORIZE_H_ diff --git a/src/nwnss/comn/authsys/zasDecision.c b/src/nwnss/comn/authsys/zasDecision.c index 7987ba8..a11e545 100644 --- a/src/nwnss/comn/authsys/zasDecision.c +++ b/src/nwnss/comn/authsys/zasDecision.c @@ -89,18 +89,18 @@ STATIC STATUS MayIChangeRights( ****************************************************************************/ STATUS VAUTH_CheckInheritedVisibility( GeneralMsg_s *genMsg, - AuthBeast_s *authBeast) + AuthBeast_s *authBeast) { NSSConnection_s *pssConn; STATUS status; AuthCtrl_s authControl; - + if ((pssConn = CNCT_RESOLVE_CONNECTION(genMsg)) == NULL) { return zFAILURE; } authControl = genMsg->pssConn.ptr->authInfo; - S_LATCH(&authControl.authListLatch); + S_LATCH(&authControl.authListLatch); status = ZAS_CheckInheritedVisibility(genMsg, authBeast, authControl.numAuthenticatedIDs, authControl.authenticatedIDs); @@ -201,7 +201,7 @@ STATIC STATUS MayISeeTheWildcardObject( if ((*effectiveRights & ~zAUTHORIZE_CREATE_ENTRY) == 0) { /* The only rights we have are create rights */ if (ZAS_GetParentsEffectiveRights(genMsg, authBeast, parentZID, - effectiveRights) != zOK) + effectiveRights) != zOK) { return zFAILURE; } @@ -423,7 +423,7 @@ STATIC STATUS MayIModifyMACMetadata( { /* Then get the parents rights and check them too */ if (ZAS_GetParentsEffectiveRights(genMsg, authBeast, parentZID, - &effectiveRights) != zOK) + &effectiveRights) != zOK) { /* unable to acquire parent's effective rights. */ return zFAILURE; @@ -558,7 +558,7 @@ STATIC STATUS MayIMoveTheObject( // return(zOK); // } #endif - } + } } else /* is a file */ { @@ -570,7 +570,7 @@ STATIC STATUS MayIMoveTheObject( { return zOK; } - + } return zFAILURE; } @@ -642,7 +642,7 @@ STATIC STATUS MayIDoEverything( /**************************************************************************** * - * This decision functions determines if the requester has supervisor rights + * This decision functions determines if the requester has supervisor rights * to the file system but not necessarilly to the DS NCP server object. * ****************************************************************************/ @@ -745,14 +745,14 @@ STATIC STATUS MayISetDirectoryQuota( { NINT effectiveRights; AuthBeast_s *parent; - + /* * See if the parent has supervisor rights. If it is the root then * there is no parent. */ if (parentZID == zINVALID_ZID) { - if (ZAS_GetEffectiveRights(genMsg, authBeast, zINVALID_ZID, + if (ZAS_GetEffectiveRights(genMsg, authBeast, zINVALID_ZID, &effectiveRights) != zOK) { return zFAILURE; @@ -766,7 +766,7 @@ STATIC STATUS MayISetDirectoryQuota( { return zFAILURE; } - if (ZAS_GetEffectiveRights(genMsg, parent, + if (ZAS_GetEffectiveRights(genMsg, parent, parent->AUTHfirstParentZid, &effectiveRights) != zOK) { COMN_Release(&parent); @@ -781,7 +781,7 @@ STATIC STATUS MayISetDirectoryQuota( } /* Check the current object */ - if (ZAS_GetEffectiveRights(genMsg, authBeast, parentZID, + if (ZAS_GetEffectiveRights(genMsg, authBeast, parentZID, &effectiveRights) != zOK) { return zFAILURE; @@ -835,7 +835,7 @@ STATIC STATUS MayIModifyCreateDateTime( * Check Mandatory Access Control (MAC) * ****************************************************************************/ -MASVAPI uint32 (*MASVGetConnNSSVolumeAccessPtr)(uint32 connID, +MASVAPI uint32 (*MASVGetConnNSSVolumeAccessPtr)(uint32 connID, uint32 lblSize, void *label) = NULL; void VAUTH_HandleMacOneShot(OneShot_s *alarm) @@ -843,7 +843,7 @@ void VAUTH_HandleMacOneShot(OneShot_s *alarm) NSSConnection_s *pssConn = STRUCT(alarm, NSSConnection_s, macAlarm); pssConn->flags |= CNCTFL_NEED_NEW_MAC_VALUE; -} +} STATUS VAUTH_PassedMAC( GeneralMsg_s *genMsg, @@ -861,7 +861,7 @@ STATUS VAUTH_PassedMAC( if (MASVGetConnNSSVolumeAccessPtr == NULL) { ZOS_ImportPublicSymbol(MASVGetConnNSSVolumeAccessPtr, - (LONG)CMN_ModuleHandle, + (LONG)CMN_ModuleHandle, (BYTE *)"\x1a""MASVGetConnNSSVolumeAccess"); } @@ -879,7 +879,7 @@ STATUS VAUTH_PassedMAC( MPKNSS_UNLOCK(); macAccess = MASVGetConnNSSVolumeAccessPtr( pssConn->connectionNumber, - sizeof(authBeast->AUTHvolume->p.mac), + sizeof(authBeast->AUTHvolume->p.mac), authBeast->AUTHvolume->p.mac); MPKNSS_LOCK(); pssConn->flags &= ~CNCTFL_NEED_NEW_MAC_VALUE; @@ -901,7 +901,7 @@ STATUS VAUTH_PassedMAC( MPKNSS_UNLOCK(); macAccess = MASVGetConnNSSVolumeAccessPtr( pssConn->connectionNumber, - sizeof(authBeast->AUTHvolume->p.mac), + sizeof(authBeast->AUTHvolume->p.mac), authBeast->AUTHvolume->p.mac); MPKNSS_LOCK(); } @@ -927,7 +927,7 @@ STATUS VAUTH_PassedMAC( } break; case MAY_I_CHANGE_ACCESS_RIGHTS: - case MAY_I_CREATE: + case MAY_I_CREATE: case MAY_I_DELETE: case MAY_I_MODIFY_METADATA: case MAY_I_MOVE_THE_OBJECT: @@ -1020,7 +1020,7 @@ STATUS VAUTH_MayIDoThis( return MayISalvage(genMsg, authBeast, parentZID); case MAY_I_SEE_THE_WILDCARD_OBJECT: { - if (MayISeeTheWildcardObject(genMsg, authBeast, parentZID, + if (MayISeeTheWildcardObject(genMsg, authBeast, parentZID, &effectiveRights) == zOK) { /* If this is a secure object then don't let it be seen */ @@ -1047,3 +1047,5 @@ STATUS VAUTH_MayIDoThis( return zFAILURE; } } + + diff --git a/include/nwnss/comn/checker.h b/src/nwnss/comn/checker.h similarity index 100% rename from include/nwnss/comn/checker.h rename to src/nwnss/comn/checker.h diff --git a/src/nwnss/comn/common/adminVolFile.c b/src/nwnss/comn/common/adminVolFile.c new file mode 100644 index 0000000..008f9e2 --- /dev/null +++ b/src/nwnss/comn/common/adminVolFile.c @@ -0,0 +1,213 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-01-21 04:09:53 +0530 (Sat, 21 Jan 2006) $ + | + | $RCSfile$ + | $Revision: 1315 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Support routines for admin volume + +-------------------------------------------------------------------------*/ +#include + +#include +#include /* NSS Library */ +#include + +#include "msgGen.h" +#include "zParams.h" +#include "nameSpace.h" +#include "comnAuthorize.h" +#include "volume.h" +#include "adminVolume.h" +#include "mgmt.h" +#include "comnPublics.h" + + +/**************************************************************************** + * Initialize files used inside the ADMIN volume. Always setup the + * current time and owner fields. + *****************************************************************************/ +STATUS AVFILE_Construct( + GeneralMsg_s *genMsg, + void *beast_LX) +{ + AdminVolFile_s *beast = (AdminVolFile_s *)beast_LX; + Time_t currentTime; + ASSERT_MPKNSS_LOCK(); + + currentTime = GetUTCTime(); + beast->AVFILEaccessedTime = + beast->AVFILEcreatedTime = + beast->AVFILEmodifiedTime = + beast->AVFILEmetaDataModifiedTime = currentTime; + + beast->AVFILEarchivedTime = INVALID_UTC_TIME; + + beast->AVFILEownerID = + beast->AVFILEmodifierID = + beast->AVFILEmetaDataModifierID = zSUPERVISOR_ID; + + return zOK; +} + +/************************************************************************** + * Cleanup files in the admin volume + ***************************************************************************/ +void AVFILE_Destruct( + void *beast_LX) +{ + AdminVolFile_s *beast = (AdminVolFile_s *)beast_LX; + GeneralMsg_s genMsg; + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + /* + * Files created by using COMN_AdmnVolInsertBeast instead of zCreate + * need to call COMN_AdmnVolRemoveBeast to clean up the stuff + * zDelete would normally take care of. + */ + if (AdminVolumeIsUsable && (beast->specialBeastDirKey != 0)) + { + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + status = COMN_AdmnVolRemoveBeast(&genMsg,beast); + if (status != zOK) + { + zASSERT("Beast is not destructed correctly" == NULL); + } + } +} + + +/**************************************************************************** + * This is only used for those "system" files (files created when + * Admin Volume starts up - files under AuthModels, BeastClasses, NameSpaces, + * Volumes directories. They are not allowed to be opened and deleted. Also + * user can't create anything under these four directories. + *****************************************************************************/ +STATIC STATUS AVFILE_Notify( + GeneralMsg_s *genMsg, + RootBeast_s *beast, + NINT notifyID) +{ + ASSERT_MPKNSS_LOCK(); + + switch(notifyID) + { + case BST_NOTIFY_CLOSE: + return zOK; + + case BST_NOTIFY_CREATE: + return zOK; +// SetErrno(genMsg, zERR_NO_CREATE_PRIVILEGE); +// break; + + case BST_NOTIFY_OPEN: + return zOK; +// /* if it's system beast, can't be opened */ +// if (!((AdminVolFile_s *)beast)->registeredByUser) +// { +// SetErrno(genMsg, zERR_NO_OPEN_PRIVILEGE); +// } +// else if ((((AdminVolFile_s *)beast)->readOverride == NULL) +// && (((AdminVolFile_s *)beast)->writeOverride == NULL)) +// { +// SetErrno(genMsg, zERR_NO_OPEN_PRIVILEGE); +// } +// else +// { +// return zOK; +// } +// break; + + case BST_NOTIFY_DELETE: + return zOK; +// /* if it's system beast, can't be deleted */ +// if (!((AdminVolFile_s *)beast)->registeredByUser) +// { +// SetErrno(genMsg, zERR_NO_DELETE_PRIVILEGE); +// } +// else +// { +// return zOK; +// } +// break; + + default: + zASSERT(0); /* we want this to fall into the ERROR handling*/ + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + break; + } + return zFAILURE; +} + + + +/**************************************************************************** + * COMMON OPS definition + * + *****************************************************************************/ + +/*--------------------------------------------------------------------------- + * Defines all of the FileBeast operations + *---------------------------------------------------------------------------*/ +CommonBeastOps_s AVFILE_ComnOps = +{ + AVFILE_Construct, /* construct */ + AVFILE_Destruct, /* destruct */ + +// cnt NULL, /* BST_getNameUniquifier */ + NULL, /* BST_setupNameTypeSpecificInfo */ + NULL, /* BST_lookupByNameInDirectory*/ + NULL, /* BST_isDirectoryEmpty*/ + NULL, /* BST_addNameToDirectory*/ + NULL, /* BST_removeNameFromDirectory*/ + NULL, /* BST_modifyNameSpaceMaskInDirectory*/ + NULL, /* BST_setMatchAttributesInDirectory*/ + NULL, /* BST_wildcardLookup*/ + + NULL, /* BST_truncateFile*/ + NULL, /* BST_getStorageInfo*/ + NULL, /* BST_getExtentList*/ + NULL, /* BST_getPhysicalExtent*/ + NULL, /* BST_isBlockInBeast*/ + + NULL, /* BST_asyncReadFileBlk*/ + NULL, /* BST_getFileBlk*/ + NULL, /* BST_dfsReadUnits*/ + NULL, /* BST_dfsWriteUnits*/ + + NULL, /* BST_getZID*/ + AVFILE_Notify, /* BST_beastNotify*/ + NULL, /* BST_getInfo*/ + NULL, /* BST_modifyInfo*/ + NULL, /* BST_getInfoXML */ + NULL /* BST_modifyInfoXML*/ +}; diff --git a/src/nwnss/comn/common/adminVolume.c b/src/nwnss/comn/common/adminVolume.c index 956cba4..1caf974 100644 --- a/src/nwnss/comn/common/adminVolume.c +++ b/src/nwnss/comn/common/adminVolume.c @@ -96,14 +96,6 @@ Key_t SwapKey; /* key for swap file */ Blknum_t LastSwapBlock = 0; /* the last used block in the swap file */ Blknum_t FreeSwapBlockListHead = 0; /* head of the free block list */ -#ifdef NSS_USERSPACE -typedef void (*avol_work_agent_callback_t)(Agent_s *, void *); -typedef void (*avol_work_asyncio_callback_t)(Asyncio_s *, void *); -typedef STATUS (*avol_alloc_storage_info_callback_t)(GeneralMsg_s *, RootBeast_s *); -typedef void (*avol_free_storage_info_callback_t)(RootBeast_s *); -typedef void (*avol_fsm_step_callback_t)(Fsm_s *); -#endif - /*--------------------------------------------------------------------------- * List of directories to create in the ADMIN volume. *---------------------------------------------------------------------------*/ @@ -120,7 +112,7 @@ AdminVolDirectories_s AdminVolDirs[] = #ifndef __linux__ // LINUX_AdminVolume LINUX_Startup /************************************************************************** - * This function is scheduled as a background thread to wait for eDIR + * This function is scheduled as a background thread to wait for eDIR * to start and then set the admin volume's eDIR GUID. ***************************************************************************/ void ADMINVOL_StartupThread( @@ -230,7 +222,7 @@ wait: err = (*DDCResolveNamePtr)(dsContext, DS_READABLE | DS_DEREFERENCE_ALIASES, aStack->volumeDSName); - if (err != 0) + if (err != 0) { aprintf(LRED, "Admin volume startup: error resolving volume name = %d\n",err); goto exitLogout; @@ -247,7 +239,7 @@ wait: modInfoMsg.parentZid = AdminVolume.AVOLfirstParentZid; X_LATCH(&AdminVolume.AVOLbeastLatch); - err = AdminVolume.AVOLcomnBeastOps.BST_modifyInfo(&genMsg, + err = AdminVolume.AVOLcomnBeastOps.BST_modifyInfo(&genMsg, &AdminVolume.AVOLroot, &modInfoMsg, NULL); UNX_LATCH(&AdminVolume.AVOLbeastLatch); MPKNSS_UNLOCK(); @@ -325,10 +317,10 @@ STATUS ADMINVOL_StartupPhase2( NINT spaceNum; AuthModelBeast_s *model; AuthSpaceBeast_s *space; - + ASSERT_MPKNSS_LOCK(); ENTER(TADMVOL,ADMINVOL_StartupPhase2); - + /*--------------------------------------------------------------------------- * The namespaces are up by now, so say we can create names on this volume *---------------------------------------------------------------------------*/ @@ -374,7 +366,7 @@ STATUS ADMINVOL_StartupPhase2( */ AdminVolume.AVOLuseCount--; - + /*--------------------------------------------------------------------------- * Now that it is setup, insert admin volume into system *---------------------------------------------------------------------------*/ @@ -389,9 +381,9 @@ STATUS ADMINVOL_StartupPhase2( * Start up a thread to wait for DS to come up and then set the admin * volume eDIR GUID. *---------------------------------------------------------------------------*/ - ZOS_StartThreadWithModuleHandle(AdminStartupThreadID, "NSS ADMIN VOL STARUP", - (void *(*)(THREAD, void *))ADMINVOL_StartupThread, - 0, 0, NULL, (LONG)CMN_ModuleHandle); + ZOS_StartThreadWithModuleHandle(AdminStartupThreadID, "NSS ADMIN VOL STARUP", + (void *(*)(THREAD, void *))ADMINVOL_StartupThread, + 0, 0, NULL, (LONG)CMN_ModuleHandle); #endif /*--------------------------------------------------------------------------- @@ -526,10 +518,10 @@ STATUS ADMINVOL_InitPersistentStorage( return zFAILURE; } - ZOS_zCreate(status, SwapRootKey, zNO_TASK, 0, zNSPACE_LONG, - aStack->path, zFILE_REGULAR, - zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT | zFA_NOT_VIRTUAL_FILE, - zCREATE_TRUNCATE_IF_THERE, + ZOS_zCreate(status, SwapRootKey, zNO_TASK, 0, zNSPACE_LONG, + aStack->path, zFILE_REGULAR, + zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT | zFA_NOT_VIRTUAL_FILE, + zCREATE_TRUNCATE_IF_THERE, zRR_READ_ACCESS | zRR_WRITE_ACCESS | zRR_DIO_MODE, &SwapKey); if (status != zOK) { @@ -550,7 +542,7 @@ void ADMINVOL_Shutdown(void) { GeneralMsg_s genMsg; STATUS status; - RootBeast_s *beast; + RootBeast_s *beast; // DQhead_t tempQ; DQhead_t purgingBeasts; NINT cnt = 0; @@ -702,7 +694,7 @@ STATUS COMN_AdmnVolInsertBeast( { goto error_cleanup; } - if (COMN_LsaCleanupSetup(&beast->AVFILEnamed, // cnt nameUniquifier, + if (COMN_LsaCleanupSetup(&beast->AVFILEnamed, // cnt nameUniquifier, &aStack->lsaInv) == zOK) { aStack->lsaInv.lid_zid = zINVALID_ZID; @@ -719,7 +711,7 @@ STATUS COMN_AdmnVolInsertBeast( } STACK_FREE(); - RTN_STATUS(zOK); + RTN_STATUS(zOK); /*------------------------------------------------------------------------- * cleanup on an error *-------------------------------------------------------------------------*/ @@ -762,7 +754,7 @@ STATUS COMN_AdmnVolRemoveBeast( { return zOK; } - + X_LATCH(&beast->AVFILEbeastLatch); while (beast->AVFILEnumParents > 0) { @@ -777,11 +769,11 @@ STATUS COMN_AdmnVolRemoveBeast( parentZID = beast->AVFILEfirstParent.p.zid; UNX_LATCH(&beast->AVFILEbeastLatch); - if (lsaDelDentry && Ptr_lsa_invalidate_dentry) - { - Ptr_lsa_invalidate_dentry( &aStack->lsaInv ); + if (lsaDelDentry && Ptr_lsa_invalidate_dentry) + { + Ptr_lsa_invalidate_dentry( &aStack->lsaInv ); lsaDelDentry = FALSE; - } + } directory = BEASTHASH_LookupByZid(genMsg,&AdminVolume,parentZID,XLATCHED); if (directory == NULL) @@ -792,8 +784,8 @@ STATUS COMN_AdmnVolRemoveBeast( zASSERT(COMN_IsDerivedFrom(directory,zFTYPE_ADMIN_VOL_FILE)); /*--------------------------------------------------------------------------- - * Remove related mgmt files (Admin Volume is removed in MgmtFile_shutdown. - * This is because when admin volume calls this function during shutdown, + * Remove related mgmt files (Admin Volume is removed in MgmtFile_shutdown. + * This is because when admin volume calls this function during shutdown, * removeVolumeMgmtFile can't be used already.) *---------------------------------------------------------------------------*/ if ((beast->specialBeastDirKey == AdminVolDirs[AV_VOLUME_DIRECTORY].key) @@ -811,7 +803,7 @@ STATUS COMN_AdmnVolRemoveBeast( /*--------------------------------------------------------------------------- * Remove name from the given directory *---------------------------------------------------------------------------*/ - if (COMN_LsaCleanupSetup(&beast->AVFILEnamed, /* cnt beast->AVFILEfirstParentNameUniquifier,*/ &aStack->lsaInv) == zOK) + if (COMN_LsaCleanupSetup(&beast->AVFILEnamed, /* cnt beast->AVFILEfirstParentNameUniquifier,*/ &aStack->lsaInv) == zOK) { aStack->lsaInv.lid_zid = beast->AVFILEzid; aStack->lsaInv.lid_pZid = directory->AVFILEzid; @@ -820,20 +812,20 @@ STATUS COMN_AdmnVolRemoveBeast( status = NAME_RemoveAllNames(genMsg,beast,NULL,directory, //cnt beast->AVFILEfirstParentNameUniquifier, REMNAMEFL_REMOVE_PARENT_AUTH, - NIL_METADATA_XACTION,/* cnt NULL, */NULL,NULL,NULL); - + NIL_METADATA_XACTION,/* cnt NULL, */NULL,NULL,NULL); + COMN_UnlatchAndRelease(&directory, XLATCHED); if (status != zOK) goto error_cleanup_beastOnly; } beast->specialBeastDirKey = 0; UNX_LATCH(&beast->AVFILEbeastLatch); - + if (lsaDelDentry && Ptr_lsa_invalidate_dentry) { Ptr_lsa_invalidate_dentry( &aStack->lsaInv ); } - + STACK_FREE(); RTN_STATUS(zOK); /*------------------------------------------------------------------------- @@ -841,7 +833,7 @@ STATUS COMN_AdmnVolRemoveBeast( *-------------------------------------------------------------------------*/ error_cleanup_beastOnly: UNX_LATCH(&beast->AVFILEbeastLatch); - + STACK_FREE(); RTN_STATUS(zFAILURE); } @@ -857,7 +849,7 @@ error_cleanup_beastOnly: *===========================================================================*/ /**************************************************************************** - * ZFS volume beast constructor + * ZFS volume beast constructor *****************************************************************************/ STATIC STATUS AVOL_BST_Construct( GeneralMsg_s *genMsg, @@ -898,7 +890,7 @@ STATUS AVOL_LoadRootDirectory( AdminVolume.AVOLinUseBlocks = 0; AdminVolume.AVOLsupportedAttributes = zATTR_READONLY | zATTR_DOS_METADATA | zATTR_NETWARE_METADATA | zATTR_HARD_LINKS | zATTR_VIRTUAL_FILES; - AdminVolume.AVOLenabledAttributes = zATTR_DOS_METADATA | + AdminVolume.AVOLenabledAttributes = zATTR_DOS_METADATA | zATTR_NETWARE_METADATA | zATTR_HARD_LINKS | zATTR_VIRTUAL_FILES; AdminVolume.AVOLmaximumFileSize = UI64_CONST(0xFFFFFFFFFFFFFFFF); @@ -908,7 +900,7 @@ STATUS AVOL_LoadRootDirectory( /*--------------------------------------------------------------------------- * Create the root directory of the ADMIN volume and set it up. *---------------------------------------------------------------------------*/ - rootdir = (AdminVolFile_s *)BST_new(genMsg, zFTYPE_ADMIN_VOL_FILE, + rootdir = (AdminVolFile_s *)BST_new(genMsg, zFTYPE_ADMIN_VOL_FILE, &AdminVolume); if (rootdir == NULL) goto error_cleanup; @@ -916,17 +908,17 @@ STATUS AVOL_LoadRootDirectory( X_LATCH( &rootdir->AVFILEbeastLatch); rootdir->AVFILEzid = zROOTDIR_ZID; rootdir->AVFILEfirstParentZid = zINVALID_ZID; - rootdir->AVFILEattributes = (zFA_SUBDIRECTORY | - zFA_RENAME_INHIBIT | - zFA_DELETE_INHIBIT | + rootdir->AVFILEattributes = (zFA_SUBDIRECTORY | + zFA_RENAME_INHIBIT | + zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT); rootdir->AVFILEbstState |= BST_STATE_NEW; COMN_MARK_BEAST_DIRTY( &rootdir->AVFILEroot); AdminVolume.AVOLrootdir = (File_s *)rootdir; BEASTHASH_Insert(&rootdir->AVFILEroot); /* This will put a use count on the - * beast, so it will stay around - * forever. + * beast, so it will stay around + * forever. */ UNX_LATCH(&rootdir->AVFILEbeastLatch); RTN_STATUS(zOK); @@ -987,14 +979,14 @@ STATUS AVOL_CreateDirectories( { unicpy(startOfFileName, AdminVolDirs[i].name); - attribute = zFA_SUBDIRECTORY | zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT | + attribute = zFA_SUBDIRECTORY | zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT; if (AdminVolDirs[i].hide) { attribute |= zFA_HIDDEN; } - ZOS_zCreate(status, AdminConnZeroRootKey, zNO_TASK, 0, - zNSPACE_LONG, aStack->path, zFILE_REGULAR, attribute, + ZOS_zCreate(status, AdminConnZeroRootKey, zNO_TASK, 0, + zNSPACE_LONG, aStack->path, zFILE_REGULAR, attribute, zCREATE_OPEN_IF_THERE, 0, &AdminVolDirs[i].key); if (status != zOK) { @@ -1228,7 +1220,7 @@ error_BadState: /**************************************************************************** * This routine runs on its own thread and completes writing a dirty block. - * The thread is scheduled from AVOL_BlockSignalHandler. + * The thread is scheduled from AVOL_BlockSignalHandler. *****************************************************************************/ void AVOL_WriteDirtyBlock( Agent_s *agent, @@ -1243,8 +1235,8 @@ void AVOL_WriteDirtyBlock( { /* disk available */ zASSERT(buf->volBlk != 0); - ZOS_zDIOWrite(status, SwapKey, - buf->volBlk << (buf->bufSizeShift - 9), + ZOS_zDIOWrite(status, SwapKey, + buf->volBlk << (buf->bufSizeShift - 9), 1 << (buf->bufSizeShift - 9) , 0, NULL, buf->pBuf.data); if (status != zOK) { @@ -1254,7 +1246,7 @@ void AVOL_WriteDirtyBlock( buf->volBlk, buf->pBuf.fileBlk, status); - + agent->status = status; zASSERT("Failure in AVOL_WriteDirtyBlock"==0); } @@ -1286,7 +1278,7 @@ void AVOL_BlockSignalHandler( { if (buf->state & CACHE_MEMORY_BUFFER) { /* memory block */ - memcpy(beast->storage.avInfo->u.memBlocks[buf->pBuf.fileBlk], buf->pBuf.data, (1<bufSizeShift)); + memcpy(beast->storage.avInfo->u.memBlocks[buf->pBuf.fileBlk], buf->pBuf.data, (1<bufSizeShift)); } else { /* disk block */ @@ -1299,7 +1291,7 @@ void AVOL_BlockSignalHandler( // FSMLITE_INIT(fsm, "FSM for admin vol block signal handler", 1); // // WORK_Schedule(fsm, AVOL_WriteDirtyBlock, (ADDR)agent); - WORK_Queue((FsmLite_s *)agent, (voidfunc_t)AVOL_WriteDirtyBlock, 0); + WORK_Queue((FsmLite_s *)agent, AVOL_WriteDirtyBlock, 0); RTN_VOID(); } } @@ -1336,9 +1328,9 @@ STATIC STATUS AVOL_AllocStorageInfo( beast->storage.avInfo = stInfo; parentFunc = COMN_GetNextParentVolumeComnOp(avol->AVOLbeastClass, - COMNVOLOPS_INDEX(VOL_allocStorageInfo),(statusfunc_t)AVOL_AllocStorageInfo); + COMNVOLOPS_INDEX(VOL_allocStorageInfo),AVOL_AllocStorageInfo); - status = ((avol_alloc_storage_info_callback_t)parentFunc)(genMsg,beast); + status = parentFunc(genMsg,beast); zASSERT(beast->ROOTblkSizeShift == PAGE_SHIFT); RTN_STATUS(status); @@ -1375,7 +1367,7 @@ STATIC void AVOL_FreeStorageInfo( parentFunc = COMN_GetNextParentVolumeComnOp(avol->AVOLbeastClass, COMNVOLOPS_INDEX(VOL_freeStorageInfo),(statusfunc_t)AVOL_FreeStorageInfo); - ((avol_free_storage_info_callback_t)parentFunc)(beast); + parentFunc(beast); RTN_VOID(); } @@ -1398,7 +1390,7 @@ STATUS AVOL_GetFreeBlockFromPool( X_LATCH(&SwapLatch); if (FreeSwapBlockListHead != 0) { /* there are free blocks */ - dioUnitOffset = + dioUnitOffset = FreeSwapBlockListHead << (beast->ROOTblkSizeShift - 9); ZOS_zDIORead(status, SwapKey, dioUnitOffset, 1, 0, NULL, aStack->buf); if (status != zOK) @@ -1417,7 +1409,7 @@ STATUS AVOL_GetFreeBlockFromPool( { UNX_LATCH(&SwapLatch); *blockNum = ++LastSwapBlock; - ZOS_zSetEOF(status, SwapKey, 0, + ZOS_zSetEOF(status, SwapKey, 0, (LastSwapBlock + 1) << beast->ROOTblkSizeShift, zSETSIZE_NON_SPARSE_FILE | zSETSIZE_NO_ZERO_FILL); if (status != zOK) @@ -1472,7 +1464,7 @@ STATUS AVOL_ReturnBlockToPool( STACK_FREE(); return zOK; } - + /**************************************************************************** * Truncate the file @@ -1497,7 +1489,7 @@ STATIC STATUS AVOL_TruncateFile( { for (i = blockNum; i < stInfo->numBlocks; i++) { - status = AVOL_ReturnBlockToPool(genMsg, beast, + status = AVOL_ReturnBlockToPool(genMsg, beast, stInfo->u.diskBlocks[i]); stInfo->u.diskBlocks[i] = 0; if (status != zOK) @@ -1516,8 +1508,8 @@ STATIC STATUS AVOL_TruncateFile( } stInfo->numBlocks = blockNum; COMN_MARK_BEAST_MESSY(beast); - return zOK; -} + return zOK; +} /**************************************************************************** * Get the generic storage info for this beast @@ -1532,7 +1524,7 @@ STATIC STATUS AVOL_GetStorageInfo( ENTER(TADMVOL,AVOL_GetStorageInfo); - getStorageInfo->filePhysSize = + getStorageInfo->filePhysSize = (stInfo->numBlocks << beast->ROOTblkSizeShift); getStorageInfo->metaDataPhysSize = 0; RTN_STATUS(zOK); @@ -1593,7 +1585,7 @@ STATIC Buffer_s *AVOL_GetFileBlkFromDisk( if (stInfo->u.diskBlocks[fileBlk] == 0) { /* extending the file*/ - if (AVOL_GetFreeBlockFromPool(genMsg, beast, + if (AVOL_GetFreeBlockFromPool(genMsg, beast, &stInfo->u.diskBlocks[fileBlk]) != zOK) { RTN_PTR(NULL); @@ -1635,7 +1627,7 @@ STATIC Buffer_s *AVOL_GetFileBlkFromDisk( else { dioUnitOffset = volBlock << (beast->ROOTblkSizeShift - 9); - ZOS_zDIORead(status, SwapKey, dioUnitOffset, + ZOS_zDIORead(status, SwapKey, dioUnitOffset, 1 << (beast->ROOTblkSizeShift - 9), 0, NULL, buf->pBuf.data); if (status != zOK) { @@ -1681,7 +1673,7 @@ STATIC Buffer_s *AVOL_GetFileBlkFromMemory( { /* block doesn't exist yet */ if ((stInfo->u.memBlocks[fileBlk] = zallocPage(1)) == NULL) - { + { SetErrno(genMsg,zERR_NO_MEMORY); RTN_PTR(NULL); } @@ -1701,7 +1693,7 @@ STATIC Buffer_s *AVOL_GetFileBlkFromMemory( volBlock = stInfo->u.memBlocks[fileBlk]; /* set volBlk address*/ /* buf->volBlock is really not a valid value on 64-bit machine */ - buf = cacheAllocBuffer(&beast->ROOTmycache, fileBlk, (Blknum_t)(ADDR)volBlock, + buf = cacheAllocBuffer(&beast->ROOTmycache, fileBlk, (Blknum_t)(ADDR)volBlock, AVOL_BlockSignalHandler, mode); zASSERT(buf != NULL); buf->state |= CACHE_MEMORY_BUFFER; @@ -1742,7 +1734,7 @@ STATIC Buffer_s *AVOL_GetFileBlk( */ if (fileBlk >= stInfo->numEntriesAlloced) { - oldAllocOffset = sizeof(AdminVolStorageInfo_s) + + oldAllocOffset = sizeof(AdminVolStorageInfo_s) + sizeof(stInfo->u) * (stInfo->numEntriesAlloced - 1); stInfo->numEntriesAlloced += AVOL_REALLOC_AMOUNT; if (fileBlk >= stInfo->numEntriesAlloced) @@ -1756,7 +1748,7 @@ STATIC Buffer_s *AVOL_GetFileBlk( SetErrno(genMsg, zERR_NO_MEMORY); RTN_PTR(NULL); } - memset((BYTE *)stInfo + oldAllocOffset, 0, + memset((BYTE *)stInfo + oldAllocOffset, 0, sizeof(stInfo->u) * AVOL_REALLOC_AMOUNT); beast->storage.avInfo = stInfo; } @@ -1772,7 +1764,7 @@ STATIC Buffer_s *AVOL_GetFileBlk( } else { /* we already have some blocks in memory */ - RTN_PTR(AVOL_GetFileBlkFromMemory(genMsg, beast, fileBlk, + RTN_PTR(AVOL_GetFileBlkFromMemory(genMsg, beast, fileBlk, ioMsg->mode)); } } @@ -1798,7 +1790,7 @@ void AVOL_GetFileBlkThread( void *unused) { GeneralMsg_s genMsg; - RootBeast_s *beast = STRUCT(asyncio->mycache, RootBeast_s, + RootBeast_s *beast = STRUCT(asyncio->mycache, RootBeast_s, ROOTmycache); AdminVolStorageInfo_s *stInfo = beast->storage.avInfo; Blknum_t fileBlk = asyncio->fileBlk; @@ -1819,11 +1811,11 @@ void AVOL_GetFileBlkThread( } else { /* we already have some blocks in memory */ - buffer = AVOL_GetFileBlkFromMemory(&genMsg, beast, fileBlk, + buffer = AVOL_GetFileBlkFromMemory(&genMsg, beast, fileBlk, asyncio->mode); } } - buffer = AVOL_GetFileBlkFromDisk(&genMsg, beast, fileBlk, + buffer = AVOL_GetFileBlkFromDisk(&genMsg, beast, fileBlk, asyncio->mode); } else @@ -1833,7 +1825,7 @@ void AVOL_GetFileBlkThread( SetErrno(&genMsg, zERR_NO_PERSIST_ADMIN_VOLUME); goto exit; } - buffer = AVOL_GetFileBlkFromMemory(&genMsg, beast, fileBlk, + buffer = AVOL_GetFileBlkFromMemory(&genMsg, beast, fileBlk, asyncio->mode); } exit: @@ -1850,7 +1842,7 @@ exit: void AVOL_asyncReadFileBlk( Asyncio_s *asyncio) { - RootBeast_s *beast = STRUCT(asyncio->mycache, RootBeast_s, + RootBeast_s *beast = STRUCT(asyncio->mycache, RootBeast_s, ROOTmycache); ENTER(TADMVOL,AVOL_asyncReadFileBlk); @@ -1865,23 +1857,17 @@ void AVOL_asyncReadFileBlk( ASSERT_SLATCH( &CACHE_SparseBuffer.agent.latch); ADD_LATCH( &CACHE_SparseBuffer.agent.latch); asyncio->buffer = &CACHE_SparseBuffer; - { - Fsm_s *Fsm = &asyncio->fsm; - - --(Fsm->sp); - zASSERT(*(Fsm->sp) != FSM_STACK_BOUNDARY); - ((avol_fsm_step_callback_t)*(Fsm->sp))(Fsm); - } + FSM_RUN( &asyncio->fsm); RTN_VOID(); } - WORK_Schedule((FsmLite_s *)asyncio, (voidfunc_t)AVOL_GetFileBlkThread, 0); + WORK_Schedule((FsmLite_s *)asyncio, AVOL_GetFileBlkThread, 0); RTN_VOID(); } /***************************************************************************** - * + * *****************************************************************************/ Xaction_s *AVOL_beginXLocal( Volume_s *volume, @@ -1891,17 +1877,17 @@ Xaction_s *AVOL_beginXLocal( * Start transactions on the persistent admin volume. Use the root * beast to get the common ops. */ - if ((PersistAdminVolume != NULL) && + if ((PersistAdminVolume != NULL) && (PersistAdminVolume->rootdir->FILEvolumeComnOps.VOL_beginXLocal != NULL)) { return PersistAdminVolume->rootdir->FILEvolumeComnOps. - VOL_beginXLocal(PersistAdminVolume, flags); + VOL_beginXLocal(PersistAdminVolume, flags); } return NULL; } /**************************************************************************** - * + * *****************************************************************************/ void AVOL_endXLocal( Xaction_s *xaction) @@ -1910,7 +1896,7 @@ void AVOL_endXLocal( * end transactions on the persistent admin volume. Use the root * beast to get the common ops. */ - if ((PersistAdminVolume != NULL) && + if ((PersistAdminVolume != NULL) && (PersistAdminVolume->rootdir->FILEvolumeComnOps.VOL_beginXLocal != NULL)) { PersistAdminVolume->rootdir->FILEvolumeComnOps.VOL_endXLocal(xaction); @@ -1919,7 +1905,7 @@ void AVOL_endXLocal( } /**************************************************************************** - * + * *****************************************************************************/ STATIC STATUS AVOL_AddPurgeLogEntry( GeneralMsg_s *genMsg, @@ -1932,7 +1918,7 @@ STATIC STATUS AVOL_AddPurgeLogEntry( } /**************************************************************************** - * + * *****************************************************************************/ STATIC STATUS AVOL_RemovePurgeLogEntry( GeneralMsg_s *genMsg, @@ -1972,10 +1958,10 @@ void *AVOL_GetBeastFromVolume( { return BST_read(genMsg, zid, PersistAdminVolume); } -} +} /**************************************************************************** - * + * *****************************************************************************/ STATUS AVOL_updateBeastToVolume ( GeneralMsg_s *genMsg, @@ -1988,7 +1974,7 @@ STATUS AVOL_updateBeastToVolume ( } /**************************************************************************** - * + * *****************************************************************************/ STATUS AVOL_insertBeastIntoVolume ( GeneralMsg_s *genMsg, @@ -2001,7 +1987,7 @@ STATUS AVOL_insertBeastIntoVolume ( } /**************************************************************************** - * + * *****************************************************************************/ STATUS AVOL_RemoveBeastFromVolume ( GeneralMsg_s *genMsg, @@ -2013,7 +1999,7 @@ STATUS AVOL_RemoveBeastFromVolume ( /**************************************************************************** - * + * *****************************************************************************/ STATUS AVOL_VolumeMaintenance( GeneralMsg_s *genMsg, @@ -2056,9 +2042,9 @@ NINT AVOL_PolicyObtainLoadTimeActivate( unicode_t *volumeName) { - typedef struct Stack_s { + typedef struct Stack_s { unicode_t cVolumeName[zMAX_COMPONENT_NAME]; - } Stack_s; + } Stack_s; unicode_t *parseLine; STACK_ALLOC(); @@ -2098,9 +2084,9 @@ NINT AVOL_PolicyObtainLoadTimeDeactivate( unicode_t *volumeName) { - typedef struct Stack_s { + typedef struct Stack_s { unicode_t cVolumeName[zMAX_COMPONENT_NAME]; - } Stack_s; + } Stack_s; unicode_t *parseLine; STACK_ALLOC(); @@ -2142,9 +2128,9 @@ NINT AVOL_PolicyObtainLoadTimeVolumeState( Volume_s *volume ) { - typedef struct Stack_s { + typedef struct Stack_s { unicode_t volumeName[zMAX_COMPONENT_NAME]; - } Stack_s; + } Stack_s; GeneralMsg_s dummyGenMsg; STACK_ALLOC(); @@ -2479,7 +2465,7 @@ NINT AVOL_PolicyObtainLoadTimeActivatePool( * * NOTE that both the ACTIVE and DEACTIVE pool policies * prevent SHARED pools from being activated. This is - * by design: it allows for + * by design: it allows for */ if (COMN_PoolCorrectType( pool, COMN_IT_LOCAL ) ) { @@ -3087,7 +3073,7 @@ void AVOL_PolicySetLoadTimeActivatePool( ///**************************************************************************** -// * +// * // *****************************************************************************/ //STATIC NINT AVOL_GetNameUniquifier( // GeneralMsg_s *genMsg, @@ -3136,7 +3122,7 @@ CommonBeastOps_s AVOL_ComnOps = NULL, /* BST_modifyInfo*/ NULL, /* BST_getInfoXML */ NULL /* BST_modifyInfoXML*/ -}; +}; diff --git a/src/nwnss/comn/common/authBeast.c b/src/nwnss/comn/common/authBeast.c new file mode 100644 index 0000000..a81eeee --- /dev/null +++ b/src/nwnss/comn/common/authBeast.c @@ -0,0 +1,149 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-01-21 04:09:53 +0530 (Sat, 21 Jan 2006) $ + | + | $RCSfile$ + | $Revision: 1315 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This defines the auth beast routines for PSS + +-------------------------------------------------------------------------*/ +#include + +#include /* NSS Library */ +#include +#include + +#include "comnBeasts.h" +#include "msgGen.h" +#include "msgName.h" +#include "beastStartup.h" +#include "zParams.h" +#include "comnParams.h" +#include "volume.h" +#include "comnAuthorize.h" +#include "comnZAS.h" + +/**************************************************************************** + * Constructor + *****************************************************************************/ +STATUS AUTH_BST_Construct( + GeneralMsg_s *genMsg, + void *authBeast_LX) +{ + AuthBeast_s *authBeast = (AuthBeast_s *)authBeast_LX; + ASSERT_MPKNSS_LOCK(); + if (authBeast->AUTHvolume == NULL) + { + SetErrno(genMsg, zERR_VOLUME_NOT_FOUND); + return zFAILURE; + } + +// if (authBeast->AUTHvolume->authModel == NULL) +// { +// if (authBeast->AUTHzid < zROOTDIR_ZID) +// { +// return zOK; +// } +// else +// { +// ASSERT("No auth model during auth beast construction" == NULL); +// SetErrno(genMsg, zERR_INVALID_AUTHORIZE_MODEL); +// return zFAILURE; +// } +// } + + zASSERT(authBeast->AUTHvolume->authModel != NULL); + + authBeast->AUTHauthModelOps = &authBeast->AUTHvolume->authModel-> + authModelOps; + + authBeast->AUTHmayIDoThis = authBeast->AUTHauthModelOps->mayIDoThis; + + return authBeast->AUTHauthModelOps->constructAuthBeast(genMsg, authBeast); +} + + +/**************************************************************************** + * Destructor + *****************************************************************************/ + +void AUTH_BST_Destruct( + void *authBeast_LX) +{ + AuthBeast_s *authBeast = (AuthBeast_s *)authBeast_LX; + ASSERT_MPKNSS_LOCK(); + if (authBeast->AUTHauthModelOps != NULL) + { + authBeast->AUTHauthModelOps->destructAuthBeast(authBeast); + } +} + +/**************************************************************************** + * COMMON OPS definition + * + *****************************************************************************/ + +/*--------------------------------------------------------------------------- + * Defines all of the AuthBeast operations + *---------------------------------------------------------------------------*/ +CommonBeastOps_s AuthBeastComnOps = +{ + AUTH_BST_Construct, /* construct */ + AUTH_BST_Destruct, /* destruct */ + +// cnt NULL, /* BST_getNameUniquifier */ + NULL, /* BST_setupNameTypeSpecificInfo */ + NULL, /* BST_lookupByNameInDirectory*/ + NULL, /* BST_isDirectoryEmpty*/ + NULL, /* BST_addNameToDirectory*/ + NULL, /* BST_removeNameFromDirectory*/ + NULL, /* BST_modifyNameSpaceMaskInDirectory*/ + NULL, /* BST_setMatchAttributesInDirectory*/ + NULL, /* BST_wildcardLookup*/ + + NULL, /* BST_truncateFile*/ + NULL, /* BST_getStorageInfo*/ + NULL, /* BST_getExtentList*/ + NULL, /* BST_getPhysicalExtent*/ + NULL, /* BST_isBlockInBeast*/ + + NULL, /* BST_asyncReadFileBlk*/ + NULL, /* BST_getFileBlk*/ + NULL, /* BST_dfsReadUnits*/ + NULL, /* BST_dfsWriteUnits*/ + + NULL, /* BST_getZID*/ + NULL, /* BST_beastNotify*/ + NULL, /* BST_getInfo*/ + NULL, /* BST_modifyInfo*/ + NULL, /* BST_getInfoXML*/ + NULL /* BST_modifyInfoXML*/ +}; + diff --git a/src/nwnss/comn/common/avolSimpleDir.c b/src/nwnss/comn/common/avolSimpleDir.c index 9f81de6..ec1f0a9 100644 --- a/src/nwnss/comn/common/avolSimpleDir.c +++ b/src/nwnss/comn/common/avolSimpleDir.c @@ -129,7 +129,7 @@ typedef struct FreeDirEntry_s /************************************************************************** - * Routine to get the beast in the persistent admin volume that we are + * Routine to get the beast in the persistent admin volume that we are * linking to. ***************************************************************************/ File_s *COMN_AVOL_ResolveLink( @@ -151,12 +151,12 @@ File_s *COMN_AVOL_ResolveLink( path = (utf8_t *)VIRT_TEMPLATE(&beast->NAMEDroot); COMN_INIT_NAMING_MSG(&aStack->nameMsg); - COMN_SETUP_NAMING_MSG_VOLUME_ZID_PATH(&aStack->nameMsg, + COMN_SETUP_NAMING_MSG_VOLUME_ZID_PATH(&aStack->nameMsg, PersistAdminVolume->VOLvolumeID, - /* cnt zFNU_FIRST_PARENT,*/ zROOTDIR_ZID, zNTYPE_FILE, path, - zPFMT_ASCII, NAMPMODE_Undefined, SLATCHED, zNSPACE_LONG, zNTYPE_FILE, + /* cnt zFNU_FIRST_PARENT,*/ zROOTDIR_ZID, zNTYPE_FILE, path, + zPFMT_ASCII, NAMPMODE_Undefined, SLATCHED, zNSPACE_LONG, zNTYPE_FILE, 0, NULL, NULL, NULL); - + if (COMN_Lookup(genMsg, &aStack->nameMsg) != zOK) { retBeast = NULL; @@ -172,7 +172,7 @@ exit: COMN_CleanupNameMsg(genMsg, &aStack->nameMsg); STACK_FREE(); return retBeast; -} +} /*======================================================================== *======================================================================== @@ -192,7 +192,7 @@ void AVOL_InitDirBlock( DirBlockHeader_s *blkheader; FreeDirEntry_s *fentry; NINT blockSize; - + ASSERT_MPKNSS_LOCK(); blkheader = (DirBlockHeader_s *)cblk->pBuf.data; @@ -234,13 +234,13 @@ Zid_t AVOL_LookupByNameInDirectory( NINT nameLen; IoMsg_s io; File_s *newDir; - + ASSERT_MPKNSS_LOCK(); ASSERT_LATCH(&directory->NAMEDbeastLatch); zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); zASSERT(directory->NAMEDstInfo != NULL); @@ -260,11 +260,11 @@ Zid_t AVOL_LookupByNameInDirectory( goto not_found; } S_LATCH(&newDir->FILEbeastLatch); - zid = newDir->FILEvolumeComnOps.VOL_lookupByNameInDirectory(genMsg, - &newDir->FILEnamed, nameSpace, nameType, name, // cnt nameUniquifier, + zid = newDir->FILEvolumeComnOps.VOL_lookupByNameInDirectory(genMsg, + &newDir->FILEnamed, nameSpace, nameType, name, // cnt nameUniquifier, /* cnt retNameUniquifier, */ retInfo); COMN_UnlatchAndRelease(&newDir, SLATCHED); - return zid; + return zid; } if (nameType != zNTYPE_FILE) @@ -327,8 +327,8 @@ Zid_t AVOL_LookupByNameInDirectory( { S_LATCH(&PersistAdminVolume->rootdir->FILEbeastLatch); zid = PersistAdminVolume->rootdir->FILEvolumeComnOps. - VOL_lookupByNameInDirectory(genMsg, - &PersistAdminVolume->rootdir->FILEnamed, nameSpace, nameType, + VOL_lookupByNameInDirectory(genMsg, + &PersistAdminVolume->rootdir->FILEnamed, nameSpace, nameType, name, /* cnt nameUniquifier, retNameUniquifier,*/ retInfo); UNS_LATCH(&PersistAdminVolume->rootdir->FILEbeastLatch); if (zid != zINVALID_ZID) @@ -336,7 +336,7 @@ Zid_t AVOL_LookupByNameInDirectory( return zid; } } - + not_found: SetErrno(genMsg,zERR_NAME_NOT_FOUND_IN_DIRECTORY); return zINVALID_ZID; @@ -346,7 +346,7 @@ not_found: // * A new directory has been created, allocate a block and initialize it. // *****************************************************************************/ // STATUS AVOL_InitDirectory( -// GeneralMsg_s *genMsg, +// GeneralMsg_s *genMsg, // NamedBeast_s *directory) //{ // ASSERT_XLATCH(&directory->NAMEDbeastLatch); @@ -360,7 +360,7 @@ not_found: * that there is only one free entry in each block of the correct size. ***************************************************************************/ NINT AVOL_IsDirectoryEmpty( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamedBeast_s *directory, NINT nameType) { @@ -379,8 +379,8 @@ NINT AVOL_IsDirectoryEmpty( ASSERT_LATCH(&directory->NAMEDbeastLatch); zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); zASSERT(directory->NAMEDstInfo != NULL); @@ -400,10 +400,10 @@ NINT AVOL_IsDirectoryEmpty( return TRUE; } S_LATCH(&newDir->FILEbeastLatch); - result = newDir->FILEvolumeComnOps.VOL_isDirectoryEmpty(genMsg, &newDir->FILEnamed, + result = newDir->FILEvolumeComnOps.VOL_isDirectoryEmpty(genMsg, &newDir->FILEnamed, nameType); COMN_UnlatchAndRelease(&newDir, SLATCHED); - return result; + return result; } lastblk = directory->NAMEDeof >> directory->NAMEDblkSizeShift; @@ -431,7 +431,7 @@ NINT AVOL_IsDirectoryEmpty( * This first checks the block header to make sure there is only one * free block and that it starts at the front of the block. ***************************************************************************/ - if ((blkheader->numFree != 1) || + if ((blkheader->numFree != 1) || (blkheader->nextFree != sizeof(DirBlockHeader_s))) { goto notEmpty; @@ -501,8 +501,8 @@ STATUS AVOL_AddNameToDirectory( ASSERT_XLATCH(&directory->NAMEDbeastLatch); zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); /* * If this directory links to the persistent admin volume then @@ -512,7 +512,7 @@ STATUS AVOL_AddNameToDirectory( if (directory->NAMEDattributes & zFA_IS_ADMIN_LINK) { /* - * If this is a linked directory check to see if there is an entry + * If this is a linked directory check to see if there is an entry * in the persistent admin volume. */ newDir = COMN_AVOL_ResolveLink(genMsg, directory); @@ -521,12 +521,12 @@ STATUS AVOL_AddNameToDirectory( return zFAILURE; } X_LATCH(&newDir->FILEbeastLatch); - status = newDir->FILEvolumeComnOps.VOL_addNameToDirectory(genMsg, - beast, &newDir->FILEnamed, nameSpaceMask, nameType, name, nsFlags, - /* cnt nameUniquifier,*/ addNameFlags,matchAttributes, xaction, + status = newDir->FILEvolumeComnOps.VOL_addNameToDirectory(genMsg, + beast, &newDir->FILEnamed, nameSpaceMask, nameType, name, nsFlags, + /* cnt nameUniquifier,*/ addNameFlags,matchAttributes, xaction, nameTypeInfo); COMN_UnlatchAndRelease(&newDir, XLATCHED); - return status; + return status; } // /** @@ -676,7 +676,7 @@ STATUS AVOL_AddNameToDirectory( CACHE_DIRTY_RELEASE(cblk); return zOK; } - prevFreeEntry = fentry; + prevFreeEntry = fentry; blkoffset = fentry->nextFree; } if (dirtyRelease) @@ -726,8 +726,8 @@ STATUS AVOL_RemoveNameFromDirectory( ASSERT_XLATCH(&directory->NAMEDbeastLatch); zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); /* * If this directory links to the persistent admin volume then @@ -737,7 +737,7 @@ STATUS AVOL_RemoveNameFromDirectory( if (directory->NAMEDattributes & zFA_IS_ADMIN_LINK) { /* - * If this is a linked directory check to see if there is an entry + * If this is a linked directory check to see if there is an entry * in the persistent admin volume. */ newDir = COMN_AVOL_ResolveLink(genMsg, directory); @@ -746,11 +746,11 @@ STATUS AVOL_RemoveNameFromDirectory( goto not_found; } X_LATCH(&newDir->FILEbeastLatch); - status = newDir->FILEvolumeComnOps.VOL_removeNameFromDirectory(genMsg, - beastZid, &newDir->FILEnamed, nameSpaceMask, nameType, name, // cnt nameUniquifier, + status = newDir->FILEvolumeComnOps.VOL_removeNameFromDirectory(genMsg, + beastZid, &newDir->FILEnamed, nameSpaceMask, nameType, name, // cnt nameUniquifier, removeNameFlags, xaction, nameTypeInfo); COMN_UnlatchAndRelease(&newDir, XLATCHED); - return status; + return status; } if (nameType != zNTYPE_FILE) @@ -804,7 +804,7 @@ STATUS AVOL_RemoveNameFromDirectory( entryOffset = GET_ENTRY_OFFSET(cblk,fentry); didMerge = TRUE; } - if ((entryOffset+fentry->header.entryLength) < + if ((entryOffset+fentry->header.entryLength) < (1 << directory->NAMEDblkSizeShift)) { nextEntry = GET_FREE_ENTRY_ADDR(cblk,entryOffset+fentry->header.entryLength); @@ -860,7 +860,7 @@ not_found: /**************************************************************************** * This locates the curName and curNameSpaceMask in the directory, via * an exact binary match. Then it replaces the nameSpacemask with - * the newNameSpacemask. NOTE--This function does not validate the + * the newNameSpacemask. NOTE--This function does not validate the * new nameSpacemask, it blindly obeys. All validity checking must * be done by the caller previous to calling this function. ALSO, * this function may not be used to set the nameSpaceMask to 0. @@ -891,8 +891,8 @@ STATUS AVOL_ModifyNameSpaceMaskInDirectory( ASSERT_XLATCH(&directory->NAMEDbeastLatch); zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); /* * If this directory links to the persistent admin volume then @@ -902,7 +902,7 @@ STATUS AVOL_ModifyNameSpaceMaskInDirectory( if (directory->NAMEDattributes & zFA_IS_ADMIN_LINK) { /* - * If this is a linked directory check to see if there is an entry + * If this is a linked directory check to see if there is an entry * in the persistent admin volume. */ newDir = COMN_AVOL_ResolveLink(genMsg, directory); @@ -912,11 +912,11 @@ STATUS AVOL_ModifyNameSpaceMaskInDirectory( } X_LATCH(&newDir->FILEbeastLatch); status = newDir->FILEvolumeComnOps. - VOL_modifyNameSpaceMaskInDirectory(genMsg, beast, &newDir->FILEnamed, - curNameSpaceMask, nameType, curName, // cnt nameUniquifier, + VOL_modifyNameSpaceMaskInDirectory(genMsg, beast, &newDir->FILEnamed, + curNameSpaceMask, nameType, curName, // cnt nameUniquifier, newNameSpaceMask, xaction); COMN_UnlatchAndRelease(&newDir, XLATCHED); - return status; + return status; } if (nameType != zNTYPE_FILE) @@ -995,8 +995,8 @@ STATUS AVOL_SetMatchAttributesInDirectory( ASSERT_XLATCH(&directory->NAMEDbeastLatch); zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); /* * If this directory links to the persistent admin volume then @@ -1007,7 +1007,7 @@ STATUS AVOL_SetMatchAttributesInDirectory( if (directory->NAMEDattributes & zFA_IS_ADMIN_LINK) { /* - * If this is a linked directory check to see if there is an entry + * If this is a linked directory check to see if there is an entry * in the persistent admin volume. */ newDir = COMN_AVOL_ResolveLink(genMsg, directory); @@ -1017,16 +1017,16 @@ STATUS AVOL_SetMatchAttributesInDirectory( } X_LATCH(&newDir->FILEbeastLatch); status = newDir->FILEvolumeComnOps. - VOL_modifyNameSpaceMaskInDirectory(genMsg, beast, &newDir->FILEnamed, - nameSpaceMask, nameType, name, // cnt nameUniquifier, + VOL_modifyNameSpaceMaskInDirectory(genMsg, beast, &newDir->FILEnamed, + nameSpaceMask, nameType, name, // cnt nameUniquifier, newMatchAttributes, xact); COMN_UnlatchAndRelease(&newDir, XLATCHED); - return status; + return status; } else { SetErrno(genMsg, zERR_NOT_SUPPORTED); - return zFAILURE; + return zFAILURE; } } @@ -1083,7 +1083,7 @@ Zid_t AVOL_WildcardLookup( // smap->options |= SMAPOPT_volumeChanged; // return zid; // } -// } +// } /* * If this directory links to the persistent admin volume then @@ -1101,16 +1101,16 @@ Zid_t AVOL_WildcardLookup( goto not_found; } S_LATCH(&newDir->FILEbeastLatch); - zid = (newDir->FILEvolumeComnOps.VOL_wildcardLookup(genMsg, &newDir->FILEnamed, + zid = (newDir->FILEvolumeComnOps.VOL_wildcardLookup(genMsg, &newDir->FILEnamed, nameSpace, nameType, pattern, smap, /* cnt retNameUniquifier,*/ retInfo)); COMN_UnlatchAndRelease(&newDir, SLATCHED); - return zid; + return zid; } ASSERT_LATCH(&directory->NAMEDbeastLatch); zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); if (nameType != zNTYPE_FILE) { @@ -1198,7 +1198,7 @@ returnLastEntry: /* we come here if we want to return the LAST entry*/ * then we found the next file. */ if ((entry->nameSpaceMask & (1<nSpaceID)) && // (entry->nameType == nameType) && - ((smap->options & SMAPOPT_matchAllEntries) || + ((smap->options & SMAPOPT_matchAllEntries) || nameSpace->nSpaceOps->wildMatch(pattern,entry->name, NAMED_GET_NFLAGS(entry) ))) { diff --git a/include/nwnss/include/avolSimpleDir.h b/src/nwnss/comn/common/avolSimpleDir.h similarity index 97% rename from include/nwnss/include/avolSimpleDir.h rename to src/nwnss/comn/common/avolSimpleDir.h index f3ca99e..72c6f65 100644 --- a/include/nwnss/include/avolSimpleDir.h +++ b/src/nwnss/comn/common/avolSimpleDir.h @@ -38,7 +38,7 @@ #define _AVOLSIMPLEDIR_H_ #ifndef _OMNI_H_ -#include +#include #endif extern Zid_t AVOL_LookupByNameInDirectory( @@ -52,11 +52,11 @@ extern Zid_t AVOL_LookupByNameInDirectory( struct FullDirectoryInfo_s *retInfo); //extern STATUS AVOL_InitDirectory( -// struct GeneralMsg_s *genMsg, +// struct GeneralMsg_s *genMsg, // struct NamedBeast_s *directory); extern NINT AVOL_IsDirectoryEmpty( - struct GeneralMsg_s *genMsg, + struct GeneralMsg_s *genMsg, struct NamedBeast_s *directory, NINT nameType); diff --git a/src/nwnss/comn/common/beastClass.c b/src/nwnss/comn/common/beastClass.c index e7e03f3..aa3fd34 100644 --- a/src/nwnss/comn/common/beastClass.c +++ b/src/nwnss/comn/common/beastClass.c @@ -35,6 +35,8 @@ | This is a pss routine that handles the registering of BEASTS | with the SYSTEM. +-------------------------------------------------------------------------*/ +#include + #include /* NSS Library */ #include #include @@ -92,7 +94,7 @@ NINT BST_ClassID2ArrayIndex( NINT classID) { NINT i; - + ASSERT_MPKNSS_LOCK(); for (i = 0; i < idMapCtrl->nextIndex; ++i) @@ -141,7 +143,7 @@ NINT BST_ArrayIndex2ClassID( ***************************************************************************/ STATUS BST_ExtendBeastList( NINT index) -{ +{ BeastClass_s *(*newArray)[]; NINT newSize; ASSERT_MPKNSS_LOCK(); @@ -164,7 +166,7 @@ STATUS BST_ExtendBeastList( *****************************************************************************/ BeastClass_s *BST_GetBeastClass( NINT beastClassID) -{ +{ ASSERT_MPKNSS_LOCK(); if (beastClassID < BeastClasses.arraySize) return (*BeastClasses.classList)[beastClassID]; @@ -175,7 +177,7 @@ BeastClass_s *BST_GetBeastClass( /************************************************************************** * Default LSS packed size routine, it says there is no data. ***************************************************************************/ -STATIC NINT BST_defaultPackedSize( +STATIC NINT BST_defaultPackedSize( void *beast) { ASSERT_MPKNSS_LOCK(); @@ -205,7 +207,7 @@ STATIC void BST_defaultNoPackCleanup( { ASSERT_MPKNSS_LOCK(); return; -} +} /**************************************************************************** @@ -352,7 +354,7 @@ STATUS COMN_SetLSSOpsForBeastClass( * Note that we only check that the pack routine is defined. If is has * been reassigned, then all other field have been reassigned. *-------------------------------------------------------------------------*/ - if (((*class->lssOps)[idx].lssClassID != zLSS_ID_INVALID) && + if (((*class->lssOps)[idx].lssClassID != zLSS_ID_INVALID) && ((*class->lssOps)[idx].pack != BST_defaultPack)) { SetErrno(genMsg,zERR_BEAST_CLASS_ROUTINE_MULT_DEF); @@ -361,13 +363,13 @@ STATUS COMN_SetLSSOpsForBeastClass( /*------------------------------------------------------------------------- * Verify that they defined all of the routines that MUST be defined. *-------------------------------------------------------------------------*/ - if ((lssOps->packedSize == NULL) || - (lssOps->pack == NULL) || + if ((lssOps->packedSize == NULL) || + (lssOps->pack == NULL) || (lssOps->unpack == NULL)) { SetErrno(genMsg,zERR_BEAST_CLASS_ROUTINE_NOT_DEF); return zFAILURE; - } + } (*class->lssOps)[idx] = *lssOps; /* assign the new OPS */ return zOK; @@ -597,7 +599,7 @@ STATUS COMN_RegisterBeastClass( { SetErrno(genMsg,zERR_BEAST_CLASS_NOT_DEFINED); return zFAILURE; - } + } /*--------------------------------------------------------------------------- * Extend the beast array to hold this new class if we need to. *---------------------------------------------------------------------------*/ @@ -637,7 +639,7 @@ STATUS COMN_RegisterBeastClass( beastSpecificOps) != zOK) { goto cleanup_free; - } + } /*--------------------------------------------------------------------------- * Add the name to the beast and the volume @@ -666,11 +668,11 @@ STATUS COMN_RegisterBeastClass( { /* * We need to hang on to the name until we can add the beast to the - * admin volume. We will use the useCount to hold a pointer to the + * admin volume. We will use the useCount to hold a pointer to the * name since useCount is not used until it is added to the admin * volume. */ - if ((newClass->BSTCLASSuseCount = + if ((newClass->BSTCLASSuseCount = (NINT)malloc((unilen(className) + 1) * sizeof(unicode_t))) == NULL) { goto cleanup_free; @@ -678,9 +680,9 @@ STATUS COMN_RegisterBeastClass( else { unicpy((unicode_t *)newClass->BSTCLASSuseCount, className); - } + } } - + return zOK; /*--------------------------------------------------------------------------- * Error cleanup, this will free all that has been allocate @@ -706,7 +708,7 @@ STATUS COMN_UnregisterBeastClass( if (beastClassID >= BeastClasses.arraySize) return zFAILURE; - + beastClass = (*BeastClasses.classList)[beastClassID]; if (beastClass == NULL) return zFAILURE; @@ -779,7 +781,7 @@ STATIC STATUS BST_doInitBeast( BeastClass_s *classList[MAX_BEASTCLASS_INHERITANCE_DEPTH]; BeastClass_s *curClass; NINT i; - + ASSERT_MPKNSS_LOCK(); /*--------------------------------------------------------------------------- * Initialize the beast @@ -882,7 +884,7 @@ STATUS BST_initNoZero( RootBeast_s *beast = (RootBeast_s *)voidBeast; Volume_s *vol = (Volume_s *)voidVol; BeastClass_s *beastClass; - + ASSERT_MPKNSS_LOCK(); beastClass = BST_GetBeastClass(beastClassID); @@ -908,7 +910,7 @@ void *BST_new( Volume_s *vol = (Volume_s *)voidVol; RootBeast_s *beast; BeastClass_s *beastClass; - + ASSERT_MPKNSS_LOCK(); /*--------------------------------------------------------------------------- @@ -1065,7 +1067,7 @@ void BST_releaseAndFree( BST_UNUSE_BEAST(beast); BST_free(beast); - + } } @@ -1080,7 +1082,7 @@ statusfunc_t COMN_GetNextParentBeastComnOp( { ASSERT_MPKNSS_LOCK(); zASSERT((index*sizeof(statusfunc_t)) < sizeof(CommonBeastOps_s)); - + while (class != NULL) { if (((statusfunc_t *)&class->comnOps)[index] == method) @@ -1093,10 +1095,10 @@ statusfunc_t COMN_GetNextParentBeastComnOp( if (((statusfunc_t *)&class->comnOps)[index] != method) return ((statusfunc_t *)&class->comnOps)[index]; class = class->derivedFrom; - } + } zASSERT(0); return NULL; -} +} /**************************************************************************** @@ -1109,7 +1111,7 @@ statusfunc_t COMN_GetNextParentVolumeComnOp( { ASSERT_MPKNSS_LOCK(); zASSERT((index*sizeof(statusfunc_t)) < sizeof(CommonVolumeOps_s)); - + while (class != NULL) { if (((statusfunc_t *)&class->comnVolOps)[index] == method) @@ -1122,10 +1124,10 @@ statusfunc_t COMN_GetNextParentVolumeComnOp( if (((statusfunc_t *)&class->comnVolOps)[index] != method) return ((statusfunc_t *)&class->comnVolOps)[index]; class = class->derivedFrom; - } + } zASSERT(0); return NULL; -} +} /**************************************************************************** @@ -1184,7 +1186,7 @@ STATUS COMN_GetBeastInfoXML( strcpy(&buf[infoLen], "<"TAG_VOLUMEINFO">"); infoLen += strlen(&buf[infoLen]); - status = volume->VOLcomnBeastOps.BST_getInfoXML(genMsg, (RootBeast_s *)volume, + status = volume->VOLcomnBeastOps.BST_getInfoXML(genMsg, (RootBeast_s *)volume, typeOfInfo, *bufLen, buf, &infoLen); if (status != zOK) { @@ -1291,15 +1293,15 @@ STATUS COMN_GetBeastInfoXML( unlatchAndRelease: COMN_UnlatchAndRelease(&beast, SLATCHED); - -unlockAndRelease: + +unlockAndRelease: if (onlineOnly) { COMN_UnlockVolumeActive(volume, FALSE); } COMN_Release(&volume); -exit: +exit: return status; } @@ -1363,11 +1365,11 @@ STATUS COMN_SetBeastInfoXML( if (oldDataMatch) { /* check if current value is the same as the old value */ - status = beast->ROOTcomnOps.BST_modifyInfoXML(genMsg, beast, bufLen, buf, NULL, FALSE); - if (status != zOK) - { - goto releaseBeast; - } + status = beast->ROOTcomnOps.BST_modifyInfoXML(genMsg, beast, bufLen, buf, NULL, FALSE); + if (status != zOK) + { + goto releaseBeast; + } } /* now do the actual change */ @@ -1380,7 +1382,7 @@ STATUS COMN_SetBeastInfoXML( COMN_MARK_BEAST_XLOCAL(beast, xaction); status = COMN_ForceBeastWrite(genMsg, beast, xaction); - + releaseBeast: if (xaction != NULL) { @@ -1388,21 +1390,21 @@ releaseBeast: } COMN_UnlatchAndRelease(&beast, XLATCHED); - -unlockAndRelease: + +unlockAndRelease: if (onlineOnly) { COMN_UnlockVolumeActive(volume, FALSE); } COMN_Release(&volume); -exit: +exit: return status; } /**************************************************************************** - * This is used to delete a beast + * This is used to delete a beast *****************************************************************************/ /** * Ying - March 4, 2004 @@ -1462,7 +1464,7 @@ STATUS COMN_DeleteBeast( Xaction_s *xaction = COMN_BeginXLocal(beast); status = BST_delete(genMsg, NULL, /* cnt zFNU_FIRST_PARENT,*/ beast, - NULL, NULL, xaction, FALSE, TRUE); + NULL, NULL, xaction, FALSE, TRUE); COMN_EndXLocal(beast, &xaction); COMN_UnlatchAndRelease(&beast, XLATCHED); @@ -1482,7 +1484,7 @@ STATUS COMN_DeleteBeast( nameType = zNTYPE_DATA_STREAM; nameSpaceID = zNSPACE_DATA_STREAM; } - + fileZid = ((NamedBeast_s *)beast)->NAMEDfirstParentZid; fileBeast = COMN_LookupByZid(genMsg, volume, fileZid, NOTLATCHED, TRUE); if (fileBeast == NULL) @@ -1490,39 +1492,39 @@ STATUS COMN_DeleteBeast( COMN_UnlatchAndRelease(&beast, XLATCHED); goto unlockAndRelease; } - + if (NAME_AllNamesInSalvage(fileBeast)) { fileNameType = zNTYPE_DELETED_FILE; } COMN_UnlatchAndRelease(&fileBeast, NOTLATCHED); } - else + else { nameType = zNTYPE_FILE; nameSpaceID = ((NamedBeast_s *)beast)->NAMEDfirstParentPrimaryNameSpaceID; fileZid = zid; } - + if (NAME_AllNamesInSalvage(beast)) { nameType = zNTYPE_DELETED_FILE; } - + /* release beast */ COMN_UnlatchAndRelease(&beast, XLATCHED); - + /* set up naming msg */ COMN_INIT_NAMING_MSG(&aStack->nameMsg); - - COMN_SETUP_NAMING_MSG_VOLUME_ZID(&aStack->nameMsg, volume->VOLvolumeID, - /* cnt zFNU_FIRST_PARENT,*/ zINVALID_ZID, fileZid, zid, - XLATCHED, nameSpaceID, nameType, NULL); + + COMN_SETUP_NAMING_MSG_VOLUME_ZID(&aStack->nameMsg, volume->VOLvolumeID, + /* cnt zFNU_FIRST_PARENT,*/ zINVALID_ZID, fileZid, zid, + XLATCHED, nameSpaceID, nameType, NULL); if (nameType == zNTYPE_DELETED_FILE || fileNameType == zNTYPE_DELETED_FILE) { COMN_SET_NAMING_MSG_NAMETYPES(&aStack->nameMsg, zNTYPE_DELETED_FILE); } - + aStack->nameMsg.parseFlags |= NAMPFL_dontProcessHardLink; /* make sure we don't auto-forward on a hardlink just yet */ rc = COMN_Lookup(genMsg, &aStack->nameMsg); aStack->nameMsg.parseFlags &= ~NAMPFL_dontProcessHardLink; @@ -1530,7 +1532,7 @@ STATUS COMN_DeleteBeast( { goto cleanupNameMsg; } - + aStack->nameMsg.workNameType = nameType; if (nameType == zNTYPE_DATA_STREAM || nameType == zNTYPE_EXTENDED_ATTRIBUTE) { @@ -1540,23 +1542,23 @@ STATUS COMN_DeleteBeast( aStack->nameMsg.fileParentZid = fileZid; } } - + COMN_SETUP_DELETE_FILE_MSG(&aStack->deleteMsg, zDELETE_PURGE_IMMEDIATE | zDELETE_FORCE_DELETE); - + status = COMN_Delete( genMsg, &aStack->nameMsg, &aStack->deleteMsg); cleanupNameMsg: COMN_CleanupNameMsg( genMsg, &aStack->nameMsg ); } -unlockAndRelease: +unlockAndRelease: if (onlineOnly) { COMN_UnlockVolumeActive(volume, FALSE); } COMN_Release(&volume); -exit: +exit: STACK_FREE(); return status; } @@ -1617,7 +1619,7 @@ STATUS COMN_GetBeastFullName( goto unlockAndRelease; } - status = COMN_GetFileNameFromZid2(genMsg, volume, zid, + status = COMN_GetFileNameFromZid2(genMsg, volume, zid, nameSpaceID, uniName, FALSE); if (status != zOK) { @@ -1647,7 +1649,7 @@ unlockAndRelease: } COMN_Release(&volume); -exit: +exit: return status; } @@ -1656,7 +1658,7 @@ exit: *=========================================================================== * * BEASTCLASS COMMON OPS definition - * + * *=========================================================================== *===========================================================================*/ @@ -1680,7 +1682,7 @@ void beastClassDestruct( BeastClass_s *beast = (BeastClass_s *)beast_LX; ASSERT_MPKNSS_LOCK(); free(beast->lssOps); -} +} /*--------------------------------------------------------------------------- * Defines all of the NamedBeast operations diff --git a/include/nwnss/comn/common/beastClass.h b/src/nwnss/comn/common/beastClass.h similarity index 98% rename from include/nwnss/comn/common/beastClass.h rename to src/nwnss/comn/common/beastClass.h index 9764d9f..a064ed1 100644 --- a/include/nwnss/comn/common/beastClass.h +++ b/src/nwnss/comn/common/beastClass.h @@ -38,7 +38,7 @@ #define _BEASTCLASS_H_ #ifndef _COMNBEASTS_H_ -#include +#include #endif #ifndef _COMNBEASTCLASS_H_ diff --git a/src/nwnss/comn/common/beastDelete.c b/src/nwnss/comn/common/beastDelete.c index 06a6d1b..aeb8501 100644 --- a/src/nwnss/comn/common/beastDelete.c +++ b/src/nwnss/comn/common/beastDelete.c @@ -34,6 +34,7 @@ | This module is used to: | This modules deals with deleting beasts (and any datastream beasts) +-------------------------------------------------------------------------*/ +#include #include #include @@ -60,7 +61,6 @@ #include "csaLease.h" #include "comnAuthorize.h" #include "opLock.h" -#include "inst.h" /**************************************************************************** * BST_deleteDataStreams @@ -145,7 +145,7 @@ STATUS BST_deleteDataStreams( goto cleanup_return; } /*--------------------------------------------------------------------------- - * Read through the beast, and delete every located dataStream. Make a + * Read through the beast, and delete every located dataStream. Make a * separate transaction for each dataStream. *---------------------------------------------------------------------------*/ genMsg->flags |= DO_NOT_SEND_FSHOOKS; @@ -220,7 +220,7 @@ cleanup_return: else { STACK_FREE(); - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } } @@ -240,27 +240,27 @@ STATIC void BST_actualCleanupDeletedFile( NINT saveNameType; BOOL containsDeletedFiles; - /* file has a useCount, but should not be latched upon entering this + /* file has a useCount, but should not be latched upon entering this * function */ ASSERT_MPKNSS_LOCK(); ENTER(TDELETE, BST_actualCleanupDeletedFile); /*--------------------------------------------------------------------------- * If the file is a subdirectory, and it contains deleted (but not yet purged) - * contents, purge all contents now!!! + * contents, purge all contents now!!! *---------------------------------------------------------------------------*/ if (file->FILEattributes & zFA_SUBDIRECTORY) { - S_LATCH(&file->FILEbeastLatch); + S_LATCH(&file->FILEbeastLatch); containsDeletedFiles = (file->FILEcomnOps.BST_isDirectoryEmpty( genMsg,&file->FILEnamed,zNTYPE_DELETED_FILE)) ? FALSE : TRUE; - UNS_LATCH(&file->FILEbeastLatch); + UNS_LATCH(&file->FILEbeastLatch); if (containsDeletedFiles) { /* The beast whose contained subtree we are purging has already * had all of it's names removed and is marked with BST_STATE_PURGING - * ... We can't call COMN_PurgeDeletedDirectoryTree in this + * ... We can't call COMN_PurgeDeletedDirectoryTree in this * state because the necessary lookups will fail. We must * temporarily remove the "BST_STATE_PURGING" flag and mark the * beast's parent entry nameType as zNTYPE_DELETED_FILE so that @@ -302,10 +302,10 @@ STATIC void BST_actualCleanupDeletedFile( /* Cleanup any trustee information for this beast */ - X_LATCH(&file->FILEbeastLatch); + X_LATCH(&file->FILEbeastLatch); ((AuthBeast_s *)file)->AUTHauthModelOps->deleteAuthInfo(genMsg, &file->FILEauth, file->FILEfirstParentZid); - UNX_LATCH(&file->FILEbeastLatch); + UNX_LATCH(&file->FILEbeastLatch); RTN_VOID(); } @@ -335,14 +335,14 @@ STATIC void BST_cleanupDeletedFileWorkerThread( /**************************************************************************** * This function is called to cleanup a deleted file beast. Any contained - * data streams and Extended attributes are deleted. In the case of a + * data streams and Extended attributes are deleted. In the case of a * subdirectory, this function also purges the entire subtree of any deleted * files which are not yet purged. * * This function is only called by BST_delete and ZFSPOOL_PlayPurgeLog. * * The purgelog code calls this with "dontSpawnThread == TRUE" and - * "beastIsLatched == FALSE". In this case this whole process runs + * "beastIsLatched == FALSE". In this case this whole process runs * synchronously. * * The BST_delete code calls this with "dontSpawnThread = either" and @@ -376,16 +376,16 @@ STATUS BST_cleanupDeletedFile( *---------------------------------------------------------------------------*/ if (((file->FILEnameFlags & (NFL_HAS_DATA_STREAMS|NFL_HAS_EXTENDED_ATTRIBUTES)) == 0) && - ((file->FILEattributes & zFA_SUBDIRECTORY) == 0) && - !((AuthBeast_s *)file)->AUTHauthModelOps->isAuthInfo(genMsg, + ((file->FILEattributes & zFA_SUBDIRECTORY) == 0) && + !((AuthBeast_s *)file)->AUTHauthModelOps->isAuthInfo(genMsg, &file->FILEauth)) { RTN_STATUS(zOK); } - if (beastIsLatched) + if (beastIsLatched) { - /* + /* * If this parameter is "TRUE" we always need to spawn a worker thread * because the lower level code needs to get its own latches. So force * the dontSpawnThread flag to FALSE. @@ -394,7 +394,7 @@ STATUS BST_cleanupDeletedFile( } /*--------------------------------------------------------------------------- - * At this point, + * At this point, * if (dontSpawnThread == TRUE), the beasts are NOT currently latched. * If (dontSpawnThread == FALSE), the beasts ARE latched. *---------------------------------------------------------------------------*/ @@ -429,22 +429,22 @@ STATUS BST_cleanupDeletedFile( { SetErrno(genMsg, zERR_NO_MEMORY); COMN_UnlockVolumeActive(file->FILEvolume,FALSE); - errPrintf(WHERE, Module, -1, + errPrintf(WHERE, Module, -1, MSG("Unable to delete dataStreams\n", 590)); RTN_STATUS(zFAILURE); } FSMLITE_INIT(fsm, "FSM to delete files", 0); /* Extra use count to keep it around*/ - COMN_USE_BEAST( &file->FILEroot); - WORK_Schedule( fsm, (voidfunc_t)BST_cleanupDeletedFileWorkerThread, + COMN_USE_BEAST( &file->FILEroot); + WORK_Schedule( fsm, BST_cleanupDeletedFileWorkerThread, (ADDR)&file->FILEagent); } RTN_STATUS(zOK); } /**************************************************************************** - * This function marks the deleted flag in the uncompressed info on the + * This function marks the deleted flag in the uncompressed info on the * compressed beast . *****************************************************************************/ void BST_fixCompressedBeast( @@ -465,12 +465,12 @@ void BST_fixCompressedBeast( { RootBeast_s *compBeast; - if ((compBeast = CM_LookupCompBeast(genMsg, + if ((compBeast = CM_LookupCompBeast(genMsg, (RootBeast_s *)namedBeast, compInfo, SLATCHED)) != NULL) { zASSERT((*compBeast->variableData)[RVD_UNCOMP_DATA]); ((UncompressInfo_s *)(*compBeast->variableData) - [RVD_UNCOMP_DATA])->uncompBeastDeleted + [RVD_UNCOMP_DATA])->uncompBeastDeleted = TRUE; COMN_UnlatchAndRelease(&compBeast, SLATCHED); } @@ -511,7 +511,7 @@ STATUS BST_deleteSetup( */ if(targetBeast->FILEattributes & zFA_HARDLINK) { - /* don't allow delete of a version 2 beast with hardlinks, we don't + /* don't allow delete of a version 2 beast with hardlinks, we don't * know how to anymore. Must upgrade or rollback */ if(targetBeast->FILEbeastVersion <= BEAST_VERSION_2) @@ -556,7 +556,7 @@ STATUS BST_deleteSetup( COMN_UnlatchAndRelease(&primaryBeast,XLATCHED); SetErrno(genMsg,zERR_INVALID_INTERNAL_LINK_STRUCTURE); return (zFAILURE); - } + } } else { @@ -594,7 +594,7 @@ STATUS BST_deleteSetup( prevHardLinkZid = nextBeast->FILEhardLinkZid; } // primary CANNOT be prev, cuz that means target is the primary name */ - zASSERT(neighborBeast != primaryBeast); + zASSERT(neighborBeast != primaryBeast); X_LATCH(&targetBeast->FILEbeastLatch); } } @@ -685,7 +685,7 @@ STATUS BST_delete( goto error_Cleanup; } zASSERT((pentry->p.zid == directory->NAMEDzid) || - (directory->NAMEDvolume == &AdminVolume.vol && pentry->p.zid >= + (directory->NAMEDvolume == &AdminVolume.vol && pentry->p.zid >= AVOL_FIRST_PERSISTENT_ZID)); if (pentry->p.nameType == zNTYPE_DELETED_FILE) @@ -695,7 +695,7 @@ STATUS BST_delete( zASSERT((namedBeast->NAMEDnumParents == 1) || (((HardLinkBeast_s*)namedBeast)->HARDLhardLinkZid != zINVALID_ZID)); - + /*--------------------------------------------------------------------------- * If this is a container (zSUBDIRECTORY bit set in attributes) then make * sure all contained objects are gone before allowing a delete. @@ -726,7 +726,7 @@ STATUS BST_delete( /* need to add data stream and extended info's delete event */ eflProcessDataStreams(genMsg, (File_s *)beast, EFL_FILE_STATE_DELETE_FILE, xaction); } - + if (COMN_IsDerivedFrom(beast, zFTYPE_FILE) && ((((File_s *)beast)->FILEnameFlags & NFL_HAS_DATA_STREAMS) || (((File_s *)beast)->FILEnameFlags & NFL_HAS_EXTENDED_ATTRIBUTES))) @@ -734,10 +734,10 @@ STATUS BST_delete( /* need to add data stream and extended info's delete event */ eflProcessDataStreams(genMsg, (File_s *)beast, EFL_FILE_STATE_DELETE_FILE, xaction); } - - VOL_insertEFLEntry(genMsg, beast, EFL_FILE_STATE_DELETE_FILE, + + VOL_insertEFLEntry(genMsg, beast, EFL_FILE_STATE_DELETE_FILE, NULL, xaction); - ClearErrno(genMsg); + ClearErrno(genMsg); /* * Adjust the directory space. Don't bother if the file is being @@ -747,10 +747,10 @@ STATUS BST_delete( * quotas on the file. * If the file has multiple parents (hard links) and the parent * being deleted is the primary, we move the quota to the new - * parent. + * parent. * * The block tracking routines that normally do this in - * the LSS will not be able to because by then the parents are gone and + * the LSS will not be able to because by then the parents are gone and * directory quotas require knowledge of the parents. * * We also ignore data streams and extended attribute because they @@ -762,10 +762,10 @@ STATUS BST_delete( if (doQuotas /* We were asked to adjust quotas? */ && /* And quotas are enabled on the volume? */ - ((quotaBeast->NAMEDvolume->VOLenabledAttributes & zATTR_DIR_QUOTAS) || + ((quotaBeast->NAMEDvolume->VOLenabledAttributes & zATTR_DIR_QUOTAS) || (quotaBeast->NAMEDvolume->VOLenabledAttributes & zATTR_USER_SPACE_RESTRICTIONS)) && - /* And either we have a single non-deleted parent? */ + /* And either we have a single non-deleted parent? */ (((quotaBeast->NAMEDnumParents == 1) && (quotaBeast->NAMEDfirstParent.p.nameType != zNTYPE_DELETED_FILE)) || @@ -797,18 +797,18 @@ STATUS BST_delete( if (quotaBeast->NAMEDnameFlags & NFL_HAS_EXTENDED_ATTRIBUTES) { if (COMN_GetDataStreamUsedSpace(genMsg, (File_s *)quotaBeast, - zNTYPE_EXTENDED_ATTRIBUTE, TRUE, xaction, + zNTYPE_EXTENDED_ATTRIBUTE, TRUE, xaction, &usedEASize) != zOK) { ClearErrno(genMsg); } } - if ((COMN_GetPurgeableBlksCnt(genMsg, quotaBeast, &physBlocks) == zOK) && + if ((COMN_GetPurgeableBlksCnt(genMsg, quotaBeast, &physBlocks) == zOK) && (!(quotaBeast->NAMEDnameFlags & NFL_BLKS_NOT_IN_PURGEABLE_CNT)) && ((physBlocks + usedDataStreamSize + usedEASize) != 0)) { totalUsedSize = - (physBlocks << quotaBeast->NAMEDblkSizeShift) + + (physBlocks << quotaBeast->NAMEDblkSizeShift) + usedDataStreamSize + usedEASize; @@ -821,7 +821,7 @@ STATUS BST_delete( */ VOL_AdjustUsedUserSpace(xaction, "aBeast->NAMEDroot, -(physBlocks << quotaBeast->NAMEDblkSizeShift)); - DIRQ_AdjustUsedDirSpace(xaction, + DIRQ_AdjustUsedDirSpace(xaction, quotaBeast->NAMEDvolume, "aBeast->NAMEDroot, -totalUsedSize); } @@ -836,11 +836,11 @@ STATUS BST_delete( zASSERT(((HardLinkBeast_s*)namedBeast)->HARDLhlFlags & zHL_FIRST_HLNAME); zASSERT(namedBeast->NAMEDfirstParentZid != neighborBeast->FILEfirstParentZid); - DIRQ_AdjustUsedDirSpace(xaction, + DIRQ_AdjustUsedDirSpace(xaction, quotaBeast->NAMEDvolume, &namedBeast->NAMEDroot, -totalUsedSize); - DIRQ_AdjustUsedDirSpace(xaction, + DIRQ_AdjustUsedDirSpace(xaction, quotaBeast->NAMEDvolume, &neighborBeast->FILEroot, totalUsedSize); /* @@ -855,7 +855,7 @@ STATUS BST_delete( ClearErrno(genMsg); } } - + /*--------------------------------------------------------------------------- * Remove the names from the beast. If appropriate, this may add the name * to the salvage system rather than completely removing it. @@ -881,13 +881,13 @@ STATUS BST_delete( { /* only primary name left, not much work here */ if((((HardLinkBeast_s*)namedBeast)->HARDLhlFlags & zHL_FIRST_HLNAME ) && - (neighborBeast == NULL)) + (neighborBeast == NULL)) { zASSERT(((HardLinkBeast_s*)namedBeast)->HARDLprimaryZid == primaryBeast->FILEzid); zASSERT(((HardLinkBeast_s*)namedBeast)->HARDLhardLinkZid == zINVALID_ZID); zASSERT(primaryBeast->FILEhardLinkZid == namedBeast->NAMEDzid); } - else + else { /* if primaryname with siblings */ if(((HardLinkBeast_s*)namedBeast)->HARDLhlFlags & zHL_FIRST_HLNAME) @@ -922,7 +922,7 @@ STATUS BST_delete( COMN_MARK_BEAST_XLOCAL(&neighborBeast->FILEroot,xaction); COMN_ForceBeastWrite(genMsg,neighborBeast,xaction); } - else + else { /* non-primary HL name, throw away to HL beast. Nothing more to do. */ zASSERT(neighborBeast != NULL); /* Better be the left beast */ @@ -977,7 +977,7 @@ STATUS BST_delete( { purgingFileName = TRUE; - /* If this is the last and/or only name for the beast, this + /* If this is the last and/or only name for the beast, this * function will set the numParents count to zero so the beast * can be purged. */ @@ -1033,7 +1033,7 @@ STATUS BST_delete( /* cancel the alarm to FLUSH the beast ?? Not sure if needed for hardlink??? */ zASSERT(beast->ROOTstInfo != NULL); CANCEL_ALARM(beast->ROOTmycache.agent.timer); - + if (purgingFileName) { zASSERT(namedBeast != NULL); @@ -1048,7 +1048,7 @@ STATUS BST_delete( /* Now, make beast and namedBeast point to the primary beast * instead, and use the remaining cleanup code to cleanup the - * primary. + * primary. * NOTE: The remaining code is shared with deleting non-hardlink * files. */ @@ -1097,7 +1097,7 @@ STATUS BST_delete( /* cancel the alarm to FLUSH the beast */ zASSERT(beast->ROOTstInfo != NULL); CANCEL_ALARM(beast->ROOTmycache.agent.timer); - + /* Check if any datastream/deletedFile cleanup needs to be done. */ if (namedBeast) { @@ -1130,10 +1130,10 @@ STATUS BST_delete( { ClearErrno(genMsg); } - namedBeast->NAMEDnameFlags &= ~(NFL_ADDED_TO_SALVAGE_TREE | + namedBeast->NAMEDnameFlags &= ~(NFL_ADDED_TO_SALVAGE_TREE | NFL_BLKS_NOT_IN_PURGEABLE_CNT); namedBeast->NAMEDnameFlags |= NFL_PURGED_FROM_SALVAGE_TREE; - + COMN_MARK_BEAST_XLOCAL(&namedBeast->NAMEDroot,xaction); volLog.delta = -1; @@ -1203,7 +1203,7 @@ STATUS BST_PurgeFileName( { goto returnFailure; } - + beast = COMN_LookupByZid(genMsg, volume, zid, NOTLATCHED, TRUE); if (beast == NULL) { @@ -1244,7 +1244,7 @@ STATUS BST_PurgeFileName( /* * It is OK if directory is NULL here ... this should not happen anymore, * but we have had some cases where a bug left a deleted file stranded - * with no parent. If there is no parent, this will delete the file + * with no parent. If there is no parent, this will delete the file * anyway */ @@ -1257,7 +1257,7 @@ STATUS BST_PurgeFileName( if(primaryBeast == NULL) { zASSERT("Primary beast has dissappeared" == NULL); - ForceSetErrno(genMsg, zERR_INTERNAL_DIRECTORY_ERROR); + ForceSetErrno(genMsg, zERR_INTERNAL_DIRECTORY_ERROR); COMN_Release(&beast); COMN_UnlockVolumeActive(volume,FALSE); goto returnFailure; @@ -1288,9 +1288,9 @@ STATUS BST_PurgeFileName( /* We cannot truncate the file if it is open */ if ((beast->NAMEDnumParents == 1) && ((beast->NAMEDattributes & zFA_SUBDIRECTORY) == 0) && - (beast->NAMEDeof > 0) && + (beast->NAMEDeof > 0) && (beast->NAMEDopenCount == 0) && - !(beast->NAMEDattributes & zFA_HARDLINK)) + !(beast->NAMEDattributes & zFA_HARDLINK)) { QUAD purgeBlkCnt = 0; diff --git a/src/nwnss/comn/common/beastHash.c b/src/nwnss/comn/common/beastHash.c index cead30a..f0c4cfa 100644 --- a/src/nwnss/comn/common/beastHash.c +++ b/src/nwnss/comn/common/beastHash.c @@ -36,16 +36,16 @@ /*************************************************************************** * NOTES added on: 31/10/03 by Vandana * - * Rules and notes for using BST_new - * (The same rules will apply to routines that call BST_new, + * Rules and notes for using BST_new + * (The same rules will apply to routines that call BST_new, * directly or indirectly): * BST_create * BST_read - * ZFSVOL_GetBeastFromBuffer + * ZFSVOL_GetBeastFromBuffer * ZFSVOL_GetBeastFromVolume * * Changes made to the behaviour of BST_new. - * BST_new (ROOT_BST_Construct) no longer puts the beast on the volume + * BST_new (ROOT_BST_Construct) no longer puts the beast on the volume * linked list. * BEASTHASH_Insert puts the beast on volume linked list. * @@ -64,17 +64,17 @@ * Error case after a BEASTHASH_Insert requiring the beast to be cleaned up: * BST_UNLINK_FROM_ALL_LISTS(beast) * beast->bstState |= BST_STATE_TOSS_ON_RELEASE; - * COMN_Release(&beast) * This will release the useCount put on by + * COMN_Release(&beast) * This will release the useCount put on by * BEASTHASH_Insert * * * Current code changes: - * Code that does a DQ_RMV from the vol link list currently after a + * Code that does a DQ_RMV from the vol link list currently after a * BST_new, is to be modified to either not do it, or do it after * BEASTHASH_Insert. ****************************************************************************/ #include -#if defined(__linux__) && defined(__KERNEL__) +#ifdef __linux__ #include #include #endif @@ -86,7 +86,6 @@ #include #include #include -#include #include "zParams.h" #include "comnParams.h" @@ -98,9 +97,7 @@ #include "adminVolume.h" #include "utc.h" #include "cacheControl.h" -#if defined(NSS_BLOCK_IO) #include "csa.h" -#endif #include "hardLinkBeast.h" #define LOCAL_DEBUG DISABLE @@ -182,8 +179,8 @@ void CHECK_BEAST_HASH(void) DQ_FOREACH( &NotInUseBeasts, beast, RootBeast_s, notInUseLink) { count++; - zASSERT((beast->useCount == 0) && - ((beast->bstState & BST_STATE_TOSSING) || + zASSERT((beast->useCount == 0) && + ((beast->bstState & BST_STATE_TOSSING) || QMEMBER(&(beast->notInUseLink)))); } @@ -223,9 +220,7 @@ void BEASTHASH_tossNotInUseBeasts(FsmLite_s *fsm) } zASSERT(Config.bst.notInUse > 0); notInUse = Config.bst.notInUse--; -#if defined(NSS_BLOCK_IO) BST_tossAsync(beast); -#endif /* * If the count did not stay decremented it is because we could @@ -256,7 +251,7 @@ void BEASTHASH_tossNotInUseBeasts(FsmLite_s *fsm) * * IMPORTANT: This routine can NOT yield, since it is called from DoRelease * code path. That can be called by FastWorkToDo's and FSM's. - * Also there is code relying on the fact that unlatch and + * Also there is code relying on the fact that unlatch and * release does not block. * ****************************************************************************/ @@ -272,10 +267,8 @@ void BEASTHASH_checkNotInUseBeasts () { if (!BeastTossWorkRunning) { -#if defined(NSS_BLOCK_IO) BeastTossWorkRunning = TRUE; - WORK_Schedule(&BeastTossFsm, BEASTHASH_tossNotInUseBeasts, (ADDR)0); -#endif + WORK_Schedule(&BeastTossFsm, BEASTHASH_tossNotInUseBeasts, NULL); } } } @@ -302,9 +295,9 @@ void BEASTHASH_checkNotInUseBeasts () * (100-p) * * The preceeding formula generates numbers that are too large because it - * calculates the amount based on allowing the total pages available to grow. - * This is not the case, the calculation should not require that the amount of - * memory available should be expected to grow. + * calculates the amount based on allowing the total pages available to grow. + * This is not the case, the calculation should not require that the amount of + * memory available should be expected to grow. * * The formula now implemented is: * @@ -317,7 +310,7 @@ void BEASTHASH_checkNotInUseBeasts () * ****************************************************************************/ enum { APPROX_NUM_BEASTS_PER_PAGE = 8 }; -#if defined(__linux__) && defined(__KERNEL__) +#ifdef __linux__ void BEASTHASH_remainingLimit () { SNINT remaining; @@ -330,20 +323,13 @@ void BEASTHASH_remainingLimit () */ totalBeasts = (APPROX_NUM_BEASTS_PER_PAGE * (si.freeram - si.freehigh)) + Config.bst.total; - remaining = ((totalBeasts * Config.bst.percentMemory) / 100) - + remaining = ((totalBeasts * Config.bst.percentMemory) / 100) - Config.bst.total; Config.bst.remainingLimit = remaining; return; } -#elif defined(NSS_USERSPACE) -void BEASTHASH_remainingLimit () -{ - Config.bst.remainingLimit = Config.bst.notInUseMax - Config.bst.total; - return; -} - #else extern LONG CurrentNumberOfCacheBuffers; @@ -352,10 +338,10 @@ void BEASTHASH_remainingLimit () SNINT remaining; NINT totalBeasts; - totalBeasts = (APPROX_NUM_BEASTS_PER_PAGE * - (Cache.available + CurrentNumberOfCacheBuffers)) + + totalBeasts = (APPROX_NUM_BEASTS_PER_PAGE * + (Cache.available + CurrentNumberOfCacheBuffers)) + Config.bst.total; - remaining = ((totalBeasts * Config.bst.percentMemory) / 100) - + remaining = ((totalBeasts * Config.bst.percentMemory) / 100) - Config.bst.total; Config.bst.remainingLimit = remaining; @@ -383,20 +369,20 @@ void BEASTHASH_adjustNotInUseLimit() { Config.bst.notInUseLimit = Config.bst.notInUseMax; } - + #if NSS_DEBUG IS_ENABLED // if (limit < Config.bst.notInUseLimit) // { -// DBG_DebugPrintf(LMAGENTA, "Changed limit up: %d rem=%d\n", +// DBG_DebugPrintf(LMAGENTA, "Changed limit up: %d rem=%d\n", // Config.bst.notInUseLimit, Config.bst.remainingLimit); // } // else if (limit > Config.bst.notInUseLimit) // { -// DBG_DebugPrintf(YELLOW, "Changed limit down: %d rem=%d\n", +// DBG_DebugPrintf(YELLOW, "Changed limit down: %d rem=%d\n", // Config.bst.notInUseLimit, Config.bst.remainingLimit); // } #endif -} +} /************************************************************************** * Adjust the limits so they ar current and then free any beasts that should @@ -426,10 +412,10 @@ void beastResetLimit (OneShot_s *beastLimitAlarm) // if (limit != Config.bst.notInUseLimit) // { // DBG_DebugPrintf(LGREEN, "beastResetLimit. tot:%d ~use:%d limit:%d remain:%d\n" -// " NSS:%d trad:%d\n", +// " NSS:%d trad:%d\n", // Config.bst.total, Config.bst.notInUse, // Config.bst.notInUseLimit, Config.bst.remainingLimit, -// Cache.available * APPROX_NUM_BEASTS_PER_PAGE, +// Cache.available * APPROX_NUM_BEASTS_PER_PAGE, // CurrentNumberOfCacheBuffers * APPROX_NUM_BEASTS_PER_PAGE); // } #endif @@ -448,7 +434,7 @@ void BEASTHASH_enqNotInUseBeasts( // ENTER(TBIO, BEASTHASH_enqNotInUseBeasts); zASSERT(beast->useCount == 0); - DEBUG_PRINTF(TBIO, DBG_INDENT, (YELLOW, + DEBUG_PRINTF(TBIO, DBG_INDENT, (YELLOW, MSGNot("BEASTHASH_enqNotInUseBeasts: Volume=\"%U\" Beast=\"%U\"(%u)\n"), beast->vol.volume->VOLroot.name, beast->name, @@ -459,7 +445,7 @@ void BEASTHASH_enqNotInUseBeasts( /*------------------------------------------------------------------------- * Insert the new beast on the end of the list *-------------------------------------------------------------------------*/ - + DQ_ENQ(&NotInUseBeasts, beast, notInUseLink); ++Config.bst.notInUse; beast->lastTimeNotInUse = GetUTCTime(); @@ -486,14 +472,14 @@ void BEASTHASH_incrementUseCount( ASSERT_MPKNSS_LOCK(); // ENTER(TBIO, BEASTHASH_incrementUseCount); - DEBUG_PRINTF(TBIO, DBG_INDENT, (YELLOW, + DEBUG_PRINTF(TBIO, DBG_INDENT, (YELLOW, MSGNot("BEASTHASH_incrementUseCount: Volume=\"%U\" Beast=\"%U\"(%u) Count=%d\n"), beast->vol.volume->VOLroot.name, beast->name, (NINT)beast->zid, beast->useCount)); - if (beast->useCount == 0) + if (beast->useCount == 0) { if(QMEMBER(&(beast->notInUseLink))) { @@ -501,7 +487,7 @@ void BEASTHASH_incrementUseCount( --Config.bst.notInUse; } /* This ASSERT is no longer valid, since the useCount can be zero - * and the beast not be on the notinuselist when the beast is being + * and the beast not be on the notinuselist when the beast is being * tossed. But we don't set the tossing bit until after the buffers * have been flushed. So asserting that the tossing bit is set * if not in the notinuselink is not valid. The tossing code will @@ -509,7 +495,7 @@ void BEASTHASH_incrementUseCount( */ // else // { -// zASSERT((beast->bstState & BST_STATE_TOSSING) || +// zASSERT((beast->bstState & BST_STATE_TOSSING) || // (beast->ROOTadminVolume == &AdminVolume)); // } } @@ -517,7 +503,7 @@ void BEASTHASH_incrementUseCount( beast->useCount++; beast->bstState &= ~(BST_STATE_TOSSING); // RTN_VOID(); -} +} /************************************************************************** * Check the beast to see if it needs to be marked dirty and a timer @@ -525,7 +511,7 @@ void BEASTHASH_incrementUseCount( ***************************************************************************/ void BEASTHASH_checkVersion( RootBeast_s *beast) -{ +{ //#if NSS_DEBUG IS_ENABLED //DBG_DebugPrintf(MAGENTA, "HASH: version=%d beast=%Ld\n", beast->beastVersion, // beast->zid); @@ -554,9 +540,7 @@ void BEASTHASH_checkVersion( //#if NSS_DEBUG IS_ENABLED //DBG_DebugPrintf(LMAGENTA, "(OK)\n"); //#endif -#if defined(NSS_BLOCK_IO) BST_MarkDirty(beast); -#endif } else { @@ -584,7 +568,7 @@ void BEASTHASH_checkVersion( //rks NINT c = ~0; //rks NINT n; //rks BYTE *buf; -//rks +//rks //rks buf = (BYTE *)&file; //rks for (n = 0; n < 4; n++) //rks { @@ -592,7 +576,7 @@ void BEASTHASH_checkVersion( //rks } //rks //rks return (c + (NINT)volume) % Config.bst.hashSize; -//rks} +//rks} /************************************************************************** * Given a ZID, this will return the beast for that ZID if it exists. @@ -614,7 +598,7 @@ void *BEASTHASH_LookupByZid( DQhead_t *head; ASSERT_MPKNSS_LOCK(); - + ENTER(TBIO, BEASTHASH_LookupByZid); /*--------------------------------------------------------------------------- * If the target zid is zero, return an error @@ -629,13 +613,11 @@ void *BEASTHASH_LookupByZid( * Check the zid to see if what looks like a request to the admin volume * is actually going to the persistent admin volume. *---------------------------------------------------------------------------*/ -#if defined(NSS_BLOCK_IO) - if ((volume == &AdminVolume.vol) && (PersistAdminVolume != NULL) && + if ((volume == &AdminVolume.vol) && (PersistAdminVolume != NULL) && (zid >= AVOL_FIRST_PERSISTENT_ZID)) { volume = PersistAdminVolume; - } -#endif + } /*--------------------------------------------------------------------------- * Set up to hash the ZID @@ -668,7 +650,7 @@ void *BEASTHASH_LookupByZid( hash_audit(head); Inst.bst.negativeHit++; SetErrno(genMsg, zERR_INVALID_BEAST_ID); - + RTN_PTR(NULL); } } @@ -677,13 +659,10 @@ void *BEASTHASH_LookupByZid( goto finish; } } - + /*--------------------------------------------------------------------------- - * The beast was not in the hash. The original NSS kernel build falls back - * to reading the beast from disk here. the userspace NSS build keeps that original path - * available only when an explicit block IO backend is enabled. + * The beast was not in the hash, read the beast in from the disk. *---------------------------------------------------------------------------*/ -#if defined(NSS_BLOCK_IO) newBeast = BST_read(genMsg, zid, volume); if (newBeast == NULL) @@ -692,18 +671,13 @@ void *BEASTHASH_LookupByZid( RTN_PTR(NULL); } Inst.bst.miss++; -#else - SetErrno(genMsg, zERR_INVALID_BEAST_ID); - RTN_PTR(NULL); -#endif -#if defined(NSS_BLOCK_IO) /*--------------------------------------------------------------------------- * Now that we have read the beast in, we now need to see if someone else * was reading this beast in at the same time and got them into the hash * list first. If so, we use the version in the hash and release the version * we just read. *---------------------------------------------------------------------------*/ - + hash_audit(head); DQ_FOREACH(head, beast, RootBeast_s, hash) { @@ -713,7 +687,7 @@ void *BEASTHASH_LookupByZid( if (beast->bstState & BST_STATE_PURGING) { SetErrno(genMsg, zERR_INVALID_BEAST_ID); - + BST_free(newBeast); hash_audit(head); RTN_PTR(NULL); @@ -726,12 +700,10 @@ void *BEASTHASH_LookupByZid( /*--------------------------------------------------------------------------- * It was not found in the hash, insert the new beast into the hash. *---------------------------------------------------------------------------*/ -#if defined(NSS_BLOCK_IO) if ( CSA_SLAVE_VOLUMES_FOUND( volume ) ) { newBeast->csaBeast = CSA_CSABeastLookup( volume, zid ); } -#endif /* This does what BEASTHASH_Insert does*/ /** Put the beast on both the beastHash and on the vol link **/ zASSERT(!QMEMBER(&(newBeast->notInUseLink))); @@ -747,8 +719,6 @@ void *BEASTHASH_LookupByZid( BEASTHASH_checkVersion(newBeast); beast = newBeast; -#endif - #ifdef DEBUG_BEAST_USE_COUNT if (beast->rb_whereCntPtr >= RB_NUM_WHERES_TO_KEEP) beast->rb_whereCntPtr = 0; beast->rb_whereCnt[beast->rb_whereCntPtr++] = WHERE; @@ -757,9 +727,9 @@ void *BEASTHASH_LookupByZid( finish: COND_LATCH(&beast->ROOTbeastLatch,latchType); + - - DEBUG_PRINTF(TBIO, DBG_INDENT, (YELLOW, + DEBUG_PRINTF(TBIO, DBG_INDENT, (YELLOW, MSGNot("BEASTHASH_LookupByZid: Volume=\"%U\" Beast=\"%U\"(%u) Count after lookup=%d\n"), beast->vol.volume->VOLroot.name, beast->name, @@ -791,7 +761,6 @@ void *COMN_LookupByZid( { RTN_PTR(NULL); } -#if defined(NSS_AUTH_BEASTS) if ((!dontDoVisibilityCheck) && (COMN_IsDerivedFrom(beast, zFTYPE_AUTH_BEAST))) { @@ -821,7 +790,6 @@ void *COMN_LookupByZid( COMN_Release(&primaryBeast); } } -#endif RTN_PTR(beast); } @@ -846,7 +814,6 @@ void *COMN_LookupByZidWhileWildcarding( RTN_PTR(NULL); } -#if defined(NSS_AUTH_BEASTS) /* If this is a hardlink beast, we must temporarily get the primary "inode" * beast to use for the "mayIDoThis" function. */ @@ -854,7 +821,7 @@ void *COMN_LookupByZidWhileWildcarding( /* If latchtype is NOTLATCHED, the authbeast is not latched. It is * illegal to call mayIDoThis without the beast latched. I am not - * changing this right now since latching the beasts can cause + * changing this right now since latching the beasts can cause * deadlocks if requested latchtype is NOTLATCHED. When we get this * issue resolved, look at the code in ZAS_ConvertVisFromVersionOne * where a kludge fix was made to not convert visibility if we don't @@ -885,7 +852,6 @@ void *COMN_LookupByZidWhileWildcarding( COND_UNLATCH(&primaryBeast->FILEbeastLatch, latchType); COMN_Release(&primaryBeast); } -#endif RTN_PTR(beast); } EXPORT_SYMBOL(COMN_LookupByZidWhileWildcarding); @@ -907,7 +873,7 @@ STATUS BEASTHASH_Startup() * If the hashSize is even force it to be odd. We picked 31 because it * reduces grouping if they happen to pick a power of two for the size. */ - Config.bst.hashSize = Config.bst.notInUseMax + + Config.bst.hashSize = Config.bst.notInUseMax + ((Config.bst.notInUseMax & 1) ? 0 : 31); RootBeastHash = zalloc(Config.bst.hashSize * sizeof(DQhead_t)); zASSERT(RootBeastHash != NULL); @@ -953,7 +919,7 @@ void BEASTHASH_Shutdown() hashBeast->beastClass->classID ); zASSERT("Above beast was not freed" == NULL); } - } + } } #endif @@ -981,13 +947,11 @@ void BEASTHASH_Insert( ASSERT_MPKNSS_LOCK(); /* Insert with the correct volume if it is from the admin volume */ -#if defined(NSS_BLOCK_IO) - if ((beast->vol.volume == &AdminVolume.vol) && (PersistAdminVolume != NULL) + if ((beast->vol.volume == &AdminVolume.vol) && (PersistAdminVolume != NULL) && (beast->zid >= AVOL_FIRST_PERSISTENT_ZID)) { beast->vol.volume = PersistAdminVolume; } -#endif hashIndex = GET_HASH(beast->zid, beast->ROOTvolume); head = &RootBeastHash[hashIndex]; @@ -999,7 +963,7 @@ void BEASTHASH_Insert( hash_audit(head); DQ_FOREACH(head, hashBeast, RootBeast_s, hash) { - if ( (beast->zid == hashBeast->zid) && + if ( (beast->zid == hashBeast->zid) && ((ADDR)beast->ROOTvolume == (ADDR)hashBeast->ROOTvolume) ) { /* Display the ZID that is already in the HASH */ @@ -1068,7 +1032,7 @@ void BEASTHASH_Remove( * * NOTE: Some of this code is copied from BEASTHASH_LookupByZid. So any * changes made their may need to be reflected here. - * + * * We do not directly use BEASTHASH_LookupByZid as that code will read the * beast into memory, and we do not want to do that. ****************************************************************************/ @@ -1088,14 +1052,12 @@ STATUS COMN_FlushAndTossBeast( return zFAILURE; } -#if defined(NSS_BLOCK_IO) - if ((volume == &AdminVolume.vol) && (PersistAdminVolume != NULL) - && (zid >= AVOL_FIRST_PERSISTENT_ZID)) + if ((volume == &AdminVolume.vol) && (PersistAdminVolume != NULL) + && (zid >= AVOL_FIRST_PERSISTENT_ZID)) { volume = PersistAdminVolume; } -#endif - + /*--------------------------------------------------------------------------- * Set up to hash the ZID *---------------------------------------------------------------------------*/ @@ -1103,7 +1065,7 @@ STATUS COMN_FlushAndTossBeast( head = &RootBeastHash[hashIndex]; /*--------------------------------------------------------------------------- - * See if the desired beast is in the hash. + * See if the desired beast is in the hash. *---------------------------------------------------------------------------*/ hash_audit(head); DQ_FOREACH(head, beast, RootBeast_s, hash) @@ -1128,9 +1090,7 @@ STATUS COMN_FlushAndTossBeast( DQ_RMV(beast, notInUseLink); --Config.bst.notInUse; zASSERT(beast->useCount == 0); -#if defined(NSS_BLOCK_IO) BST_tossAsync(beast); -#endif return zOK; } @@ -1155,7 +1115,7 @@ STATUS COMN_FlushAndTossBeast( * * NOTE: Some of this code is copied from COMN_LookupByZid. So any * changes made their may need to be reflected here. - * + * * We do not directly use BEASTHASH_LookupByZid as that code will read the * beast into memory, and we do not want to do that. * @@ -1177,7 +1137,7 @@ void *COMN_LookupByZidInBeastHash( File_s *primaryBeast = NULL; ASSERT_MPKNSS_LOCK(); - + /*--------------------------------------------------------------------------- * If the target zid is zero, return an error *---------------------------------------------------------------------------*/ @@ -1191,13 +1151,11 @@ void *COMN_LookupByZidInBeastHash( * Check the zid to see if what looks like a request to the admin volume * is actually going to the persistent admin volume. *---------------------------------------------------------------------------*/ -#if defined(NSS_BLOCK_IO) - if ((volume == &AdminVolume.vol) && (PersistAdminVolume != NULL) && + if ((volume == &AdminVolume.vol) && (PersistAdminVolume != NULL) && (zid >= AVOL_FIRST_PERSISTENT_ZID)) { volume = PersistAdminVolume; - } -#endif + } /*--------------------------------------------------------------------------- * Set up to hash the ZID @@ -1228,7 +1186,6 @@ void *COMN_LookupByZidInBeastHash( foundInHash: COND_LATCH(&beast->ROOTbeastLatch,latchType); -#if defined(NSS_AUTH_BEASTS) if ((!dontDoVisibilityCheck) && (COMN_IsDerivedFrom(beast, zFTYPE_AUTH_BEAST))) { @@ -1258,7 +1215,6 @@ foundInHash: COMN_Release(&primaryBeast); } } -#endif return beast; } @@ -1284,7 +1240,6 @@ void BEASTHASH_InvalidateDOSTimes() savedTimeZoneOffset = NSS_TimeZoneOffset; ResetTimeCache &= ~TIME_BEASTS; -#if defined(NSS_AUTH_BEASTS) if (RootBeastHash != NULL) { NINT i; @@ -1306,27 +1261,27 @@ void BEASTHASH_InvalidateDOSTimes() { changedBeasts++; } - ((File_s *)hashBeast)->FILEcreatedDOSTime = + ((File_s *)hashBeast)->FILEcreatedDOSTime = INVALID_DOS_TIME; - ((File_s *)hashBeast)->FILEarchivedDOSTime = + ((File_s *)hashBeast)->FILEarchivedDOSTime = INVALID_DOS_TIME; - ((File_s *)hashBeast)->FILEmodifiedDOSTime = + ((File_s *)hashBeast)->FILEmodifiedDOSTime = INVALID_DOS_TIME; - ((File_s *)hashBeast)->FILEaccessedDOSTime = + ((File_s *)hashBeast)->FILEaccessedDOSTime = INVALID_DOS_TIME; } } } - // Can be called from Fast Work-To-Do PERIODIC_YIELD(); + // Can be called from Fast Work-To-Do PERIODIC_YIELD(); } } -#endif #if NSS_DEBUG IS_ENABLED aprintf(YELLOW, "Invalidating DOS times in beasts\n" "total objects = %d\n" "file objects = %d\n" - "changed objects = %d\n", + "changed objects = %d\n", totalBeasts, fileBeasts, changedBeasts); #endif RTN_VOID(); } + diff --git a/src/nwnss/comn/common/beastIO.c b/src/nwnss/comn/common/beastIO.c index 559152b..e55106a 100644 --- a/src/nwnss/comn/common/beastIO.c +++ b/src/nwnss/comn/common/beastIO.c @@ -33,6 +33,7 @@ |--------------------------------------------------------------------------- | This module is used to: +-------------------------------------------------------------------------*/ +#include #include /* NSS Library */ #include @@ -178,7 +179,7 @@ STATUS BST_doUnpackIndex( // ****************************************************************************/ //void *BST_read( // GeneralMsg_s *genMsg, -// Zid_t zid, +// Zid_t zid, // Volume_s *volume) //{ // ENTER(TBIO, BST_read); @@ -195,7 +196,7 @@ STATUS BST_doUnpackIndex( * Because of latching used in some of the pack routines this routine must * always be paired with a call to BST_getPackedSize. ****************************************************************************/ -void BST_doPackIndex( +void BST_doPackIndex( RootBeast_s *beast, void *_data, NINT packedLen, @@ -208,7 +209,7 @@ void BST_doPackIndex( BeastClass_s *curClass; BeastClass_s *classList[MAX_BEASTCLASS_INHERITANCE_DEPTH]; NINT i; - + ASSERT_MPKNSS_LOCK(); ENTER(TBIO, BST_doPack); @@ -237,7 +238,7 @@ void BST_doPackIndex( break; curClass = classList[--i]; } - zASSERT(packedLen == (data - startData)); + zASSERT(packedLen == (data - startData)); RTN_VOID(); } @@ -297,15 +298,15 @@ void BST_noPackCleanupIndex( * This will start an ASYNCRONOUS request to throw a beast from memory ****************************************************************************/ -void BST_tossAsync( +void BST_tossAsync( RootBeast_s *beast) { ASSERT_MPKNSS_LOCK(); ENTER(TBIO,BST_tossAsync); zASSERT(beast->useCount == 0); /* We cannot ASSERT_NOLATCH because if the beast is flushing because - * of defaultFlush then it will not have a use count, but have a - * S_LATCH. We wait for that to flush. + * of defaultFlush then it will not have a use count, but have a + * S_LATCH. We wait for that to flush. */ // ASSERT_NOLATCH(&beast->ROOTbeastLatch); /* Setting the tossing bit before calling cacheFlushMyCache caused @@ -339,8 +340,8 @@ void BST_tossAsync( beast->bstState |= BST_STATE_FULL_FLUSH; cacheFlushMyCacheBufs(&beast->ROOTmycache); - /* If while flushing bufs (which can yield), someone set the purging - * bit, then they will do the default Flush and we don't care about + /* If while flushing bufs (which can yield), someone set the purging + * bit, then they will do the default Flush and we don't care about * flushing or tossing this beast anymore, since the beast is being * purged */ @@ -395,7 +396,7 @@ STATUS BST_flush (void *voidBeast) * * If somebody is currently flushing the beast, or waiting to flush the * beast, the AGENT_FLUSHING bit is set. We use the X_BARRIER to wait - * for that flush to finish, so we can reflush. + * for that flush to finish, so we can reflush. * We want to reflush so that I know when it is done flushing. * * If the beast is currently flushing there is a tiny window in which @@ -444,7 +445,7 @@ STATUS BST_flush (void *voidBeast) * Request to truncate a beast at the given block number (block number * is inclusive) ****************************************************************************/ -STATUS BST_truncate( +STATUS BST_truncate( struct GeneralMsg_s *genMsg, void *voidBeast, Blknum_t block, @@ -476,19 +477,19 @@ STATUS BST_truncate( * Uncompress the file if needed. */ BOOL done = FALSE; QUAD startingOffset = (QUAD)block << beast->blkSizeShift; - QUAD numBytes = + QUAD numBytes = ((count == -1) ? (beast->eof - startingOffset) - : (count << beast->blkSizeShift)); - NINT grantedRights = 0; - + : (count << beast->blkSizeShift)); + NINT grantedRights = 0; + if (startingOffset < beast->eof) { status = CM_uncompressFileRange(genMsg, beast, startingOffset, numBytes, CACHE_WRITE, XLATCHED, 0, &grantedRights, TRUE, &done); - if (status != zOK) + if (status != zOK) { RTN_STATUS(status); - } + } } } else @@ -500,20 +501,20 @@ STATUS BST_truncate( { RTN_STATUS(status); } - + if (purgeableBlocks != 0) - { + { QUAD cnt = 0; - - /* in CM_prepareToTruncateFile, it adjusts compBeast's + + /* in CM_prepareToTruncateFile, it adjusts compBeast's * purgeable blocks. So here we should assign purgeableBlocks - * to uncompBeast's blkCnt instead + * to uncompBeast's blkCnt instead */ if ( COMN_GetPurgeableBlksCnt(genMsg, beast, &cnt) != zOK) { RTN_STATUS(status); } - + zASSERT(cnt < UI64_CONST(0x100000000)); purgeableBlocks = cnt; } @@ -533,7 +534,7 @@ STATUS BST_truncate( { volLog.delta = -purgeableBlocks; volLog.action = VOLINFO_CHANGE_PURGEABLE_BLOCKS; - + //#if NSS_DEBUG IS_ENABLED zASSERT(beast->ROOTvolume->VOLpurgeableBlocks >= purgeableBlocks); // DBG_DebugPrintf(YELLOW, MSGNot("BST_Truncate: Purgeable blocks = %Ld, delta- = %d, beast zid = 0x%Lx\n"), beast->ROOTvolume->VOLpurgeableBlocks, purgeableBlocks, beast->zid); @@ -654,23 +655,23 @@ void BST_SignalPurge( BST_JUST_MARK_CLEAN(beast); status = beast->ROOTcomnVolOps.VOL_removeBeastFromVolume(&genMsg,beast,xaction); - if (status != zOK) - { - if (GetErrno(&genMsg) == zERR_ZID_NOT_FOUND) - { - ClearErrno(&genMsg); - } - else - { - //FixFixFix6 -- rollback transaction - zASSERT("Unexpected error from beast delete" == 0); - agent->status = GetErrno(&genMsg); - } - } + if (status != zOK) + { + if (GetErrno(&genMsg) == zERR_ZID_NOT_FOUND) + { + ClearErrno(&genMsg); + } + else + { + //FixFixFix6 -- rollback transaction + zASSERT("Unexpected error from beast delete" == 0); + agent->status = GetErrno(&genMsg); + } + } /* Remove any directory quota entries */ - status = beast->ROOTcomnVolOps.VOL_removeDirectory(&genMsg, - beast->ROOTvolume, xaction, beast->zid); + status = beast->ROOTcomnVolOps.VOL_removeDirectory(&genMsg, + beast->ROOTvolume, xaction, beast->zid); if (status != zOK) { status = GetErrno(&genMsg); @@ -704,15 +705,15 @@ void BST_SignalPurge( } COMN_EndXLocal(beast,&xaction); - //defaultSignal(agent); + //defaultSignal(agent); //BST_CLEAR_FLUSHING_STATE(beast); don't need this just before freeing UNX_LATCH(&beast->ROOTbeastLatch); - BST_free(beast); + BST_free(beast); RELEASE_RSRC(NAME_RESERVE); - RTN_VOID(); -} + RTN_VOID(); +} BOOL WriteMessyBeasts = TRUE; @@ -733,7 +734,7 @@ void BST_SignalFlush( ASSERT_MPKNSS_LOCK(); ENTER(TBIO,BST_SignalFlush); - + DEBUG_PRINTF(TBIO,DBG_INDENT,(MAGENTA,MSGNot("Flushing beast \"%U\" zid=%u bst=%08x\n"),beast->name,(NINT)beast->zid,beast)); flags = BST_STATE_DIRTY; @@ -741,7 +742,7 @@ void BST_SignalFlush( { flags |= BST_STATE_MESSY; } - if ((beast->bstState & flags) && + if ((beast->bstState & flags) && !(beast->bstState & BST_STATE_DO_NOT_WRITE)) { COMN_SETUP_GENERAL_MSG_NOSA( &genMsg); @@ -757,9 +758,9 @@ void BST_SignalFlush( xaction = COMN_BeginXLocal(beast); - (void)VOL_insertEFLEntry(&genMsg, beast, + (void)VOL_insertEFLEntry(&genMsg, beast, EFL_FILE_STATE_UNDEFINED, NULL, xaction); - ClearErrno(&genMsg); + ClearErrno(&genMsg); status = ((isNewBeast) ? beast->ROOTcomnVolOps.VOL_insertBeastIntoVolume(&genMsg,beast,packedSize,xaction) @@ -781,7 +782,7 @@ void BST_SignalFlush( /*--------------------------------------------------------------------------- * We are done writing, release the latches/use counts on the beast *---------------------------------------------------------------------------*/ - + if (beast->bstState & BST_STATE_FLUSHING_BY_TIMER) { /* While flushing by timer, the useCount is > 0, so the @@ -799,7 +800,7 @@ void BST_SignalFlush( */ BST_CLEAR_WRITING_STATE(beast); COMN_Release(&beast); - RTN_VOID(); + RTN_VOID(); } else { @@ -813,7 +814,7 @@ void BST_SignalFlush( { zASSERT(beast->useCount == 0); BST_UNLINK_FROM_ALL_LISTS(beast); - + DEBUG_PRINTF(TBIO,DBG_INDENT,(MAGENTA,MSGNot("Flushed and Tossing \"%U\" zid=%u bst=%08x\n"),beast->name,(NINT)beast->zid,beast)); cacheTossAll(&beast->ROOTmycache); @@ -822,20 +823,20 @@ void BST_SignalFlush( } /*-------------------------------------------------------------------------- - * If AGENT_FLUSHING was set and BST_tossAsync was called, then this + * If AGENT_FLUSHING was set and BST_tossAsync was called, then this * beast will not be tossed. So, here we re-check conditions that require - * beast to be tossed and call BST_tossAsync again. + * beast to be tossed and call BST_tossAsync again. * * The defaultSignal above cleared the AGENT_FLUSHING flag before returning. *--------------------------------------------------------------------------*/ - if ((beast->useCount == 0) && + if ((beast->useCount == 0) && (beast->bstState & (BST_STATE_TOSS_ON_RELEASE | BST_STATE_VOL_TOSSING))) { BST_tossAsync(beast); - RTN_VOID(); + RTN_VOID(); } - RTN_VOID(); -} + RTN_VOID(); +} /************************************************************************** @@ -860,7 +861,7 @@ void BST_SignalToss( /**************************************************************************** * Generic Signal handler for all Beasts. This routine is called when * all buffers (data) associated with the beast has been written. - * + * * This routine is called when defaultFlush( beast->mycache.agent ) finally * completes. * @@ -873,19 +874,19 @@ void BST_signalHandler( ASSERT_MPKNSS_LOCK(); ENTER(TBIO, BST_signalHandler); - + beast = STRUCT(agent, RootBeast_s, ROOTmycache.agent); - + /*--------------------------------------------------------------------------- * This is just a double check case to make sure that the act of flushing did * not dirty other buffers. We should normally not go into this if statement *---------------------------------------------------------------------------*/ - if ((beast->bstState & BST_STATE_FULL_FLUSH) && - (DQ_NOT_EMPTY(&agent->flushList))) + if ((beast->bstState & BST_STATE_FULL_FLUSH) && + (DQ_NOT_EMPTY(&agent->flushList))) { - - zASSERT("This should not happen" == NULL ); + + zASSERT("This should not happen" == NULL ); defaultFlush(agent); RTN_VOID(); } @@ -895,7 +896,7 @@ void BST_signalHandler( *---------------------------------------------------------------------------*/ if (beast->bstState & BST_STATE_FLUSHING) { - + defaultSignal(agent); RTN_VOID(); } @@ -905,19 +906,19 @@ void BST_signalHandler( *---------------------------------------------------------------------------*/ if ((beast->bstState & BST_STATE_PURGING) && (beast->useCount == 0)) { - + DEBUG_PRINTF(TBIO,DBG_INDENT,(MAGENTA,MSGNot("Scheduling BST_SignalPurge \"%U\" zid=%u bst=%08x\n"),beast->name,(NINT)beast->zid,beast)); CANCEL_ALARM(beast->ROOTmycache.agent.timer); - BST_JUST_MARK_CLEAN(beast); - defaultSignal(agent); /* tell them it is written */ - /* When we schedule the work for purging, we are not holding the + BST_JUST_MARK_CLEAN(beast); + defaultSignal(agent); /* tell them it is written */ + /* When we schedule the work for purging, we are not holding the * the latch on the beast. If there is a lot of purges going on, then * it is possible for the otehr works to be queued behind the purges. * To avoid this, I am putting the signal purges on their own list * and they can be lower priority work to do's. */ - WORK_Schedule_LOW( &agent->fsm, (voidfunc_t)BST_SignalPurge, 0); + WORK_Schedule_LOW( &agent->fsm, BST_SignalPurge, 0); RTN_VOID(); } @@ -927,30 +928,30 @@ void BST_signalHandler( * FixFixFix6 -- For now we are writing a beast even if it is marked for * deletion. After we have transactions in, we should optimize this. *---------------------------------------------------------------------------*/ - if ((beast->bstState & BST_STATE_FULL_FLUSH) /*&& - !(beast->bstState & BST_STATE_DO_NOT_WRITE) && - (beast->bstState & (BST_STATE_DIRTY | BST_STATE_MESSY)) */) + if ((beast->bstState & BST_STATE_FULL_FLUSH) /*&& + !(beast->bstState & BST_STATE_DO_NOT_WRITE) && + (beast->bstState & (BST_STATE_DIRTY | BST_STATE_MESSY)) */) { DEBUG_PRINTF(TBIO,DBG_INDENT,(MAGENTA,MSGNot("Scheduling BST_SignalFlush \"%U\" zid=%u bst=%08x\n"),beast->name,(NINT)beast->zid,beast)); if (beast->zid < zFIRST_ALLOCATABLE_ZID) { - WORK_Schedule_HIGH( &agent->fsm, (voidfunc_t)BST_SignalFlush, 0); + WORK_Schedule_HIGH( &agent->fsm, BST_SignalFlush, 0); } else { - WORK_Schedule( &agent->fsm, (voidfunc_t)BST_SignalFlush, 0); + WORK_Schedule( &agent->fsm, BST_SignalFlush, 0); } RTN_VOID(); } /*--------------------------------------------------------------------------- * Signal that the write is completed *---------------------------------------------------------------------------*/ - + defaultSignal(agent); /*--------------------------------------------------------------------------- * Now see if we should now TOSS the beast from memory *---------------------------------------------------------------------------*/ - + BST_CLEAR_WRITING_STATE(beast); if ((beast->bstState & BST_STATE_TOSSING) /*&& (beast->useCount == 0)*/) @@ -959,7 +960,7 @@ void BST_signalHandler( BST_UNLINK_FROM_ALL_LISTS(beast); DEBUG_PRINTF(TBIO,DBG_INDENT,(MAGENTA,MSGNot("Scheduling BST_SignalToss \"%U\" zid=%u bst=%08x\n"),beast->name,(NINT)beast->zid,beast)); - WORK_Schedule( &agent->fsm, (voidfunc_t)BST_SignalToss, 0); + WORK_Schedule( &agent->fsm, BST_SignalToss, 0); } RTN_VOID(); } @@ -978,7 +979,7 @@ void beastTimerPop( ENTER(TBIO, beastTimerPop); /* do NOT flush the beast if it is marked for deletion */ - + if ((beast->bstState & BST_STATE_DIRTY) && !(beast->bstState & BST_STATE_PURGING)) { if (beast->bstState & BST_STATE_FLUSHING_BY_TIMER) /* if already flushing, don't try again */ @@ -988,7 +989,7 @@ void beastTimerPop( BEASTHASH_incrementUseCount(beast); beast->bstState |= (BST_STATE_FULL_FLUSH | BST_STATE_FLUSHING_BY_TIMER); - + DEBUG_PRINTF(TBIO,DBG_INDENT,(CYAN,MSGNot("Timer: Flushing Beast \"%U\"(%08x) mycache=%08x\n"), beast->name, (NINT)beast->zid, @@ -997,7 +998,7 @@ void beastTimerPop( } else { - + DEBUG_PRINTF(TBIO,DBG_INDENT,(CYAN,MSGNot("Timer: Did not need to flush Beast \"%U\"(%08x)\n"),beast->name,beast->zid)); } RTN_VOID(); @@ -1030,8 +1031,8 @@ void BST_MarkDirty( * i.e we cannot have defaultFlush by timer on the volume at the * same time as flushVolume. */ - if (!(beast->bstState & - (BST_STATE_DO_NOT_WRITE|BST_STATE_IS_VOLUME_OR_POOL))) + if (!(beast->bstState & + (BST_STATE_DO_NOT_WRITE|BST_STATE_IS_VOLUME_OR_POOL))) { Agent_s *agent = &beast->ROOTmycache.agent; @@ -1066,7 +1067,7 @@ void BST_MarkXLocal( } else { - COMN_MARK_BEAST_DIRTY(beast); + COMN_MARK_BEAST_DIRTY(beast); } RTN_VOID(); } @@ -1108,8 +1109,8 @@ void BST_MarkCleanAndNotNew( /************************************************************************** * This MUST only be called on beasts that are not dirty, and cannot have - * dirty buffers associated with them. - * Toss a beast on a READ_ONLY volume only. We know the beast is not dirty + * dirty buffers associated with them. + * Toss a beast on a READ_ONLY volume only. We know the beast is not dirty * and cannot be flushed. ***************************************************************************/ #define TOSS_BEAST_TIME 3600 /* An hour */ @@ -1133,7 +1134,7 @@ void *COMN_LookupByZidInBeastHashAndToss( { return NULL; } - COND_LATCH(&beast->ROOTbeastLatch, latchType); + COND_LATCH(&beast->ROOTbeastLatch, latchType); return beast; } @@ -1144,7 +1145,7 @@ void *COMN_BeastTossOldNotInUseBeasts( { zASSERT(!(beast->bstState & (BST_STATE_DIRTY | BST_STATE_MESSY))); - if ((beast->useCount == 1) && + if ((beast->useCount == 1) && (LATCH_FREE(&beast->ROOTbeastLatch)) && (((Volume_s *)voidVol)->VOLenabledAttributes & zATTR_READONLY) && ((GetUTCTime() - beast->lastTimeNotInUse) > TOSS_BEAST_TIME)) @@ -1152,8 +1153,9 @@ void *COMN_BeastTossOldNotInUseBeasts( beast->useCount--; BST_UNLINK_FROM_ALL_LISTS(beast); beast->bstState |= BST_STATE_TOSSING; - WORK_Schedule( &beast->ROOTmycache.agent.fsm, (voidfunc_t)BST_SignalToss, 0); + WORK_Schedule( &beast->ROOTmycache.agent.fsm, BST_SignalToss, 0); return NULL; } return beast; } + diff --git a/src/nwnss/comn/common/beastRelease.c b/src/nwnss/comn/common/beastRelease.c index e69c4eb..0e2ecf1 100644 --- a/src/nwnss/comn/common/beastRelease.c +++ b/src/nwnss/comn/common/beastRelease.c @@ -50,7 +50,7 @@ STATIC void DoRelease(RootBeast_s *beast) { ASSERT_MPKNSS_LOCK(); - + if ((beast) != NULL) { zASSERT((beast)->useCount > 0); @@ -66,7 +66,7 @@ STATIC void DoRelease(RootBeast_s *beast) else if ((beast)->bstState & (BST_STATE_VOL_TOSSING | BST_STATE_TOSS_ON_RELEASE)) { - /* BST_TossAsync yields, and we cannot yield in this + /* BST_TossAsync yields, and we cannot yield in this * routine. defaultFlush will end up in BST_SignalFlush * which will call tossAsync from a WTD. */ @@ -97,7 +97,7 @@ STATIC void DoRelease(RootBeast_s *beast) "Tossing V/P beast \"%U\" zid=%u bst=%08x\n"), beast->name, (NINT)beast->zid, beast) ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( YELLOW, + DBG_DebugPrintf( YELLOW, MSGNot("%s V/P free Vol=\"%U\" Beast=\"%U\"(%u) count=0\n"), WHERE, beast->vol.volume->VOLroot.name, beast->name, @@ -115,7 +115,7 @@ STATIC void DoRelease(RootBeast_s *beast) if ( /*COMN_IsDerivedFrom(beast, zFTYPE_VOLUME) ||*/ COMN_IsDerivedFrom(beast, zFTYPE_POOL) ) { - DBG_DebugPrintf( YELLOW, + DBG_DebugPrintf( YELLOW, MSGNot("%s V/P release Vol=\"%U\" Beast=\"%U\"(%u) count=%d\n"), WHERE, beast->vol.volume->VOLroot.name, beast->name, @@ -145,22 +145,22 @@ void COMN_ReleaseInternal(void *voidBeast) RootBeast_s *beast = (RootBeast_s *)voidBeast; ASSERT_MPKNSS_LOCK(); - + ENTER(TBIO, COMN_Release); #if zLINUX // printk( "%s RUB VZ=%d Z=%d C=%d\n", WHERE, // (NINT)(beast)->vol.volume->VOLzid, (NINT)(beast)->zid, (beast)->useCount ); #else - DEBUG_PRINTF(TBIO, DBG_INDENT, (YELLOW, + DEBUG_PRINTF(TBIO, DBG_INDENT, (YELLOW, MSGNot("COMN_Release: Volume=\"%U\" Beast=\"%U\"(%u) Count before release=%d\n"), - beast->vol.volume->VOLroot.name, + beast->vol.volume->VOLroot.name, beast->name, (NINT)beast->zid, beast->useCount)); #endif DoRelease(beast); - + RTN_VOID(); } @@ -183,13 +183,14 @@ void COMN_UnlatchAndReleaseInternal(void *voidBeast, NINT latchType) ASSERT_MPKNSS_LOCK(); COND_UNLATCH(&beast->ROOTbeastLatch, latchType); - DEBUG_PRINTF(TBIO, DBG_INDENT, (YELLOW, + DEBUG_PRINTF(TBIO, DBG_INDENT, (YELLOW, MSGNot("COMN_UnlatchAndRelease: Volume=\"%U\" Beast=\"%U\"(%u) Count before release=%d\n"), - beast->vol.volume->VOLroot.name, + beast->vol.volume->VOLroot.name, beast->name, (NINT)beast->zid, beast->useCount)); DoRelease(beast); - + RTN_VOID(); } + diff --git a/src/nwnss/comn/common/beastStartup.c b/src/nwnss/comn/common/beastStartup.c new file mode 100644 index 0000000..ed5c799 --- /dev/null +++ b/src/nwnss/comn/common/beastStartup.c @@ -0,0 +1,470 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $ + | + | $RCSfile$ + | $Revision: 1325 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This is a pss routine that handles the registering of BEASTS + | with the SYSTEM. + +-------------------------------------------------------------------------*/ +#include + +#include +#include + +#include "comnBeastClass.h" +#include "beastStartup.h" +#include "zParams.h" +#include "msgGen.h" +#include "comnPublics.h" +#include "pssStartup.h" +#include "name.h" +#include "comnAuthorize.h" +#include "beastClass.h" +#include "nameSpace.h" +#include "volume.h" +#include "adminVolume.h" +#include "zasAuthModel.h" +#include "extAttrBeast.h" +#include "alarm.h" +#include "pssConfig.h" +#include "pssConnection.h" +#include "hardLinkBeast.h" + +/*--------------------------------------------------------------------------- + * These are the primitive beasts that need to be magically inserted into + * the system. After these are inserted, the regular registration routine + * (COMN_RegisterBeastClass) can be called. + *---------------------------------------------------------------------------*/ +BeastClassRegisterInfo_s PrimitiveBeastClasses[PRIMITIVE_BEAST_CLASS_COUNT] = +{ + {MSGNot(L"Root"), + zFTYPE_ROOT_BEAST,zFTYPE_ROOT_BEAST, + sizeof(RootBeast_s), + &RootBeastComnOps, + &RootBeastComnVolOps, + NULL, + NULL}, + + {MSGNot(L"Named"), + zFTYPE_NAMED_DATA_STREAM,zFTYPE_ROOT_BEAST, + sizeof(NamedBeast_s), + &NamedBeastComnOps, + &NamedBeastComnVolOps, + NULL, + NULL}, + + {MSGNot(L"Authenticated"), + zFTYPE_AUTH_BEAST,zFTYPE_NAMED_DATA_STREAM, + sizeof(AuthBeast_s), + &AuthBeastComnOps, + NULL, + NULL, + NULL}, + + {MSGNot(L"File"), + zFTYPE_FILE,zFTYPE_AUTH_BEAST, + sizeof(File_s), + &FileBeastComnOps, + NULL, + NULL, + NULL}, + + {MSGNot(L"AdminVolumeFile"), + zFTYPE_ADMIN_VOL_FILE,zFTYPE_FILE, + sizeof(AdminVolFile_s), + &AVFILE_ComnOps, + NULL, + NULL, + NULL}, + + {MSGNot(L"Volume"), + zFTYPE_VOLUME,zFTYPE_ADMIN_VOL_FILE, + sizeof(Volume_s), + &VOL_ComnOps, + &VOL_ComnVolOps, + NULL, + NULL}, + + {MSGNot(L"AdminVolume"), + zFTYPE_ADMIN_VOL,zFTYPE_VOLUME, + sizeof(AdminVolume_s), + &AVOL_ComnOps, + &AVOL_ComnVolOps, + NULL, + NULL}, + + {MSGNot(L"NameSpace"), + zFTYPE_NAMESPACE,zFTYPE_ADMIN_VOL_FILE, + sizeof(NameSpace_s), + NULL, + NULL, + NULL, + NULL}, + + {MSGNot(L"BeastClass"), + zFTYPE_BEAST_CLASS,zFTYPE_ADMIN_VOL_FILE, + sizeof(BeastClass_s), + &BeastClassComnOps, + NULL, + NULL, + NULL} + + ,{MSGNot(L"Pool"), + zFTYPE_POOL,zFTYPE_ADMIN_VOL_FILE, + sizeof(Pool_s), + &POOL_ComnOps, + &POOL_ComnVolOps, + NULL, + NULL} +}; + +/*--------------------------------------------------------------------------- + * The list of beast classes to register. + *---------------------------------------------------------------------------*/ +BeastClassRegisterInfo_s BeastClassList[] = +{ + {MSGNot(L"AuthorizeModel"), + zFTYPE_AUTH_MODEL,zFTYPE_ADMIN_VOL_FILE, + sizeof(AuthModelBeast_s), + NULL, + NULL, + NULL, + NULL}, + + {MSGNot(L"ZASAuthorizeModel"), + zFTYPE_ZAS_AUTH_MODEL,zFTYPE_AUTH_MODEL, + sizeof(AuthModelBeast_s), + NULL, + NULL, + NULL, + NULL}, + + {MSGNot(L"UnixAuthorizeModel"), + zFTYPE_UNIX_AUTH_MODEL,zFTYPE_AUTH_MODEL, + sizeof(AuthModelBeast_s), + NULL, + NULL, + NULL, + NULL}, + + {MSGNot(L"AuthorizeSpace"), + zFTYPE_AUTH_SPACE,zFTYPE_ADMIN_VOL_FILE, + sizeof(AuthSpaceBeast_s), + NULL, + NULL, + NULL, + NULL}, + + {MSGNot(L"ZASAuthorizeSpace"), + zFTYPE_ZAS_AUTH_SPACE,zFTYPE_AUTH_SPACE, + sizeof(AuthSpaceBeast_s), + NULL, + NULL, + NULL, + NULL}, + + {MSGNot(L"UnixAuthorizeSpace"), + zFTYPE_UNIX_AUTH_SPACE,zFTYPE_AUTH_SPACE, + sizeof(AuthSpaceBeast_s), + NULL, + NULL, + NULL, + NULL}, + + {MSGNot(L"ZAS_ACLOverflow"), + zFTYPE_ZAS_ACL_OVERFLOW,zFTYPE_ROOT_BEAST, + sizeof(ZasAclOverflowBeast_s), + &ACLO_ComnBeastOps, + NULL, + NULL, + NULL}, + + {MSGNot(L"ZAS_VISOverflow"), + zFTYPE_ZAS_VIS_OVERFLOW,zFTYPE_ROOT_BEAST, + sizeof(ZasVisOverflowBeast_s), + &VISO_ComnBeastOps, + NULL, + NULL, + NULL}, + + {MSGNot(L"ExtendedAttribute"), + zFTYPE_EXTENDED_ATTRIBUTE,zFTYPE_NAMED_DATA_STREAM, + sizeof(ExtAttrBeast_s), + &ExtAttrBeastComnOps, + NULL, + NULL, + NULL}, + + {MSGNot(L"HardLink"), + zFTYPE_HARDLINK_BEAST,zFTYPE_FILE, + sizeof(HardLinkBeast_s), + &HardLinkBeastComnOps, + NULL, + NULL, + NULL}, + + {NULL} /* end of list*/ +}; + + + /* + * Beast memory usage restrictions + */ +extern OneShot_s BeastLimitAlarm; + +extern void beastResetLimit(OneShot_s *beastLimitAlarm); + +/**************************************************************************** + * This routine inserts the rootclass in the system. It then insert + * all of the other classes. + *****************************************************************************/ +STATUS BEAST_Startup( + GeneralMsg_s *genMsg) +{ + STATUS status; + BeastClass_s *class; + NINT classID; + NINT i; + + /* + * Since all beasts must have an owner the connection structure must be + * initialized before we create beasts. + */ + if (CNCT_PSSConnectionStartup() != zOK) + { + return zFAILURE; + } + COMN_GENMSG_RESOLVE_CONNECTION(genMsg); + + /* + * Initialize the beast limits on how much memory beasts can + * use in the system. + */ + INIT_ONESHOT(BeastLimitAlarm); + beastResetLimit( &BeastLimitAlarm); + ASSERT_MPKNSS_LOCK(); + +/*------------------------------------------------------------------------- + * We generate a STORAGE SYSTEM ID for the ADMIN VOLUME class so that it + * will get filled in with the default pack/unpack routines + *-------------------------------------------------------------------------*/ + if (BEASTHASH_Startup(genMsg) != zOK) + return zFAILURE; + + BST_ClassID2ArrayIndex(genMsg,&LSSOpsIDMap,zFTYPE_ADMIN_VOL); +/*--------------------------------------------------------------------------- + * We must first insert the primitive beasts into the system + * These are manually inserted. + *---------------------------------------------------------------------------*/ + for (i=0;i < PRIMITIVE_BEAST_CLASS_COUNT;i++) + { + classID = PrimitiveBeastClasses[i].classID; + + if (classID >= BeastClasses.arraySize) + { + if ((status = BST_ExtendBeastList(classID)) != zOK) + goto error_cleanup; + } + + class = (BeastClass_s *)zalloc(sizeof(BeastClass_s)); + if (class == NULL) + goto error_noMemory; + + class->classID = classID; + class->beastSize = PrimitiveBeastClasses[i].beastSize; + + /* root has no derived class */ + if (classID != zFTYPE_ROOT_BEAST) + class->derivedFrom = BST_GetBeastClass(PrimitiveBeastClasses[i].derivedFromClassID); + + if (BST_InitOps(genMsg,class, + PrimitiveBeastClasses[i].comnOps, + PrimitiveBeastClasses[i].comnVolOps, + PrimitiveBeastClasses[i].lssOps, + PrimitiveBeastClasses[i].beastSpecificOps) != zOK) + { + goto error_cleanup; + } + + (*BeastClasses.classList)[classID] = class; + } +/*--------------------------------------------------------------------------- + * All of the primitive beast classes are defined. Now initialize the ADMIN + * volume, Setup Namespaces, then finish setting up the admin volume. + *---------------------------------------------------------------------------*/ + if (ADMINVOL_StartupPhase1(genMsg) != zOK) + goto error_cleanup; + + if (NSPACE_Startup(genMsg) != zOK) + goto error_cleanup; + +/*--------------------------------------------------------------------------- + * Now that all of the primitive beasts are in the table, Initialize each + * of them and then set the name. + *---------------------------------------------------------------------------*/ + for (i=0;i < PRIMITIVE_BEAST_CLASS_COUNT;i++) + { + class = BST_GetBeastClass(PrimitiveBeastClasses[i].classID); + zASSERT(class != NULL); + + if (BST_initNoZero(genMsg,class,zFTYPE_BEAST_CLASS,&AdminVolume) != zOK) + { + goto error_cleanup; + } + /* + * We need to hang on to the name until we can add the beast to the + * admin volume. We will use the useCount to hold a pointer to the + * name since useCount is not used until it is added to the admin + * volume. + */ + if ((class->BSTCLASSuseCount = + (NINT)malloc((unilen(PrimitiveBeastClasses[i].className) + 1) + * sizeof(unicode_t))) == NULL) + { + goto error_cleanup; + } + else + { + unicpy((unicode_t *)class->BSTCLASSuseCount, + PrimitiveBeastClasses[i].className); + } + } +/*--------------------------------------------------------------------------- + * Register all other beasts in the list + *---------------------------------------------------------------------------*/ + if (COMN_RegisterBeastClassList(genMsg,BeastClassList) != zOK) + goto error_cleanup; + + return zOK; +/*===========================================================================*/ +error_noMemory: + SetErrno(genMsg,zERR_NO_MEMORY); + +error_cleanup: + BEAST_Shutdown(); + BEASTHASH_Shutdown(); + return zFAILURE; +} + + +/**************************************************************************** + * This is used to cleanup all beasts in memory + *****************************************************************************/ +void BEAST_Shutdown() +{ + BeastClass_s *beastClass; + NINT i; + voidfunc_t beastClassDestructor; + + ASSERT_MPKNSS_LOCK(); + + if (BeastClasses.classList != NULL) + { + /* free all non-primitive beast classes, do it from back to front*/ + for (i=BeastClasses.arraySize-1;i > zFTYPE_BEAST_CLASS;i--) + { + COMN_UnregisterBeastClass(i); + } +/*--------------------------------------------------------------------------- + * Now bring down the ADMIN volume and the name spaces. + *---------------------------------------------------------------------------*/ + ADMINVOL_Shutdown(); + NSPACE_Shutdown(); + WORK_WaitForPending(); +/*--------------------------------------------------------------------------- + * We have to handle the freeing of the primitive beasts special because we + * are calling the destructors that we are in the process of freeing. I + * am first going to save off the destructor for the beast class and then + * NULL it out so it won't be called now. + *---------------------------------------------------------------------------*/ + beastClass = (*BeastClasses.classList)[zFTYPE_BEAST_CLASS]; + beastClassDestructor = beastClass->comnOps.BST_destruct; + beastClass->comnOps.BST_destruct = NULL; + + /* Call all other destructors for the primitive beasts */ + for (i=0;i <= zFTYPE_BEAST_CLASS;i++) + { + if ((beastClass = (*BeastClasses.classList)[i]) != NULL) + { + /* + * If we are still holding the beast class name in the + * useCount field then let go of the memory. + */ + if ((beastClass->BSTCLASSzid == 0) && + (beastClass->BSTCLASSuseCount > 1)) + { + free((unicode_t *)beastClass->BSTCLASSuseCount); + } + BST_UNUSE_BEAST(&beastClass->BSTCLASSroot); /* decrement USE count*/ + BST_uninit(beastClass); + } + } + + /* now that the file related stuff is cleaned out (like names) actually + * cleanup the beast class portions of the structure and free them*/ + for (i=0;i <= zFTYPE_BEAST_CLASS;i++) + { + if ((beastClass = (*BeastClasses.classList)[i]) != NULL) + { +// Already freed in the loop above. Don't try to free again. +// /* +// * If we are still holding the beast class name in the +// * useCount field then let go of the memory. +// */ +// if ((beastClass->BSTCLASSzid == 0) && +// (beastClass->BSTCLASSuseCount > 1)) +// { +// free((unicode_t *)beastClass->BSTCLASSuseCount); +// } + beastClassDestructor(beastClass); + free(beastClass); + } + } + } + free(BeastClasses.classList); + free(LSSOpsIDMap.classIDArray); + free(AuthModelIDMap.classIDArray); + free(AuthSpaceIDMap.classIDArray); + + BEASTHASH_Shutdown(); + AUTHSYS_AdminVolPostShutdown(); + + /* + * Even though during startup we do CNCT_PSSConnectionStartup before + * BEASTHASH_Startup, during shutdown we shut down connections here + * (instead of reverse startup order). This is because during shutdown + * of the connection there are beasts for the management files that must + * be released. At this point, all code which needs the connection + * structure should have been shut down. + */ + CNCT_PSSConnectionShutdown(); +} diff --git a/include/nwnss/comn/common/beastStartup.h b/src/nwnss/comn/common/beastStartup.h similarity index 99% rename from include/nwnss/comn/common/beastStartup.h rename to src/nwnss/comn/common/beastStartup.h index cedaf96..5ebe7c0 100644 --- a/include/nwnss/comn/common/beastStartup.h +++ b/src/nwnss/comn/common/beastStartup.h @@ -38,7 +38,7 @@ #define _BEASTSTARTUP_H_ #ifndef _COMNBEASTS_H_ -#include +#include #endif /*--------------------------------------------------------------------------- diff --git a/src/nwnss/comn/common/cSA.c b/src/nwnss/comn/common/cSA.c index 7a28870..6edd5f7 100644 --- a/src/nwnss/comn/common/cSA.c +++ b/src/nwnss/comn/common/cSA.c @@ -36,10 +36,6 @@ #include -#ifdef NSS_USERSPACE -#include -#endif - #include #include #include @@ -58,14 +54,6 @@ #include "csaLease.h" #include "xMsg.h" -#ifdef NSS_USERSPACE -/* cSA userspace status bridge: Msg_s.sys.where is a QUAD carrier here. */ -#undef SetErrnoFromStatus -#define SetErrnoFromStatus(_genMsg, _msg) \ - ((_genMsg)->errStatus = (_msg)->sys.status, \ - ((_genMsg)->errStatusSetter = (char *)(uintptr_t)((_msg)->sys.where))) -#endif - NINT XLSSArrayIndex; #if NSS_DEBUG IS_ENABLED /* Our xMsg_s must not be bigger than a Msg_s */ @@ -87,7 +75,7 @@ SearchMapCleanupWork_s SMapCleanupWork; CIRhead_t SMapCleanupIDList = NULL; -ObjCache_s CSASearchMapCleanupList; +ObjCache_s CSASearchMapCleanupList; /***************************************************************************** @@ -100,7 +88,7 @@ STATUS CSA_MsgRecv( Zid_t zid, RootBeast_s **beast, NINT latchType) -{ +{ Volume_s *volume; CSA_REMOTE_GENMSG_TO_LOCAL_GENMSG(xGenMsg, genMsg); @@ -119,7 +107,7 @@ STATUS CSA_MsgRecv( COMN_Release(&volume); return zFAILURE; } - + *beast = BEASTHASH_LookupByZid(genMsg, volume, zid, latchType); if (*beast == NULL) { @@ -149,7 +137,7 @@ STATUS CSA_VOL_GetBeastFromVolume( NINT *xlssPackedSize) { NINT realPackedSize; - + realPackedSize = BST_getPackedSizeIndex(zlssBeast, XLSSArrayIndex); zASSERT(realPackedSize != 0); @@ -180,7 +168,7 @@ void CSA_VOL_GetBeastFromVolumeMsg( XLSS_GetBeastMsg_s *xlssPacket = &msg->body.getBeast.xlssPacket; /* Input */ CSA_GetBeastMsg_s *csaPacket = &msg->body.getBeast.csaPacket; /* Output */ - status = CSA_MsgRecv( &genMsg, &xlssPacket->XGBM_genMsg, msg, + status = CSA_MsgRecv( &genMsg, &xlssPacket->XGBM_genMsg, msg, xlssPacket->XGBM_zid, &zlssBeast, XLATCHED ); if (status != zOK) { @@ -196,17 +184,14 @@ void CSA_VOL_GetBeastFromVolumeMsg( csaPacket->CGBM_beastLeaseID = beastLeaseID; csaPacket->CGBM_dataSeqNum = zlssBeast->csaBeast->CB_dataSeqNum; - NINT xlssPackedSize = (NINT)msg->sys.data[0].length; - - status = CSA_VOL_GetBeastFromVolume(&genMsg, zlssBeast, - (void *)(uintptr_t)msg->sys.data[0].start, - &xlssPackedSize); - msg->sys.data[0].length = (QUAD)xlssPackedSize; + status = CSA_VOL_GetBeastFromVolume(&genMsg, zlssBeast, + msg->sys.data[0].start, + &msg->sys.data[0].length); if (status != zOK) - { + { CSA_BeastLeaseToss( &genMsg, (CsaVolumeDoor_s *)msg->sys.door, xlssPacket->XGBM_zid, beastLeaseID); - } + } exitCleanupReturn: CSA_MsgRecvCleanup(&zlssBeast, XLATCHED); @@ -229,8 +214,8 @@ Zid_t CSA_VOL_LookupByNameInDirectory( // cnt NINT *retNameUniquifier, FullDirectoryInfo_s *retInfo) { - return directory->FILEcomnOps.BST_lookupByNameInDirectory(genMsg, - &directory->FILEnamed, nameSpace, nameType, name,/* cnt nameUniquifier, + return directory->FILEcomnOps.BST_lookupByNameInDirectory(genMsg, + &directory->FILEnamed, nameSpace, nameType, name,/* cnt nameUniquifier, retNameUniquifier,*/ retInfo); } @@ -245,7 +230,7 @@ void CSA_VOL_LookupByNameInDirectoryMsg( CSA_LookupByNameMsg_s *csaPacket = &msg->body.lookupName.csaPacket; // cnt NINT nameUniquifier; - status = CSA_MsgRecv( &genMsg, &xlssPacket->XLBM_genMsg, msg, + status = CSA_MsgRecv( &genMsg, &xlssPacket->XLBM_genMsg, msg, xlssPacket->XLBM_directoryZid, &directory, SLATCHED); if (status != zOK) { @@ -259,14 +244,13 @@ void CSA_VOL_LookupByNameInDirectoryMsg( goto exitNameSpaceLookupFailed; } - csaPacket->CLBM_zid = CSA_VOL_LookupByNameInDirectory(&genMsg, + csaPacket->CLBM_zid = CSA_VOL_LookupByNameInDirectory(&genMsg, (File_s *)directory, nameSpace, - xlssPacket->XLBM_nameType, - (unicode_t *)(uintptr_t)msg->sys.data[0].start, /* name */ -// cnt xlssPacket->XLBM_nameUniquifier, + xlssPacket->XLBM_nameType, + (unicode_t *)msg->sys.data[0].start, /* name */ +// cnt xlssPacket->XLBM_nameUniquifier, // cnt &nameUniquifier, - (msg->sys.numDataAreas == 2 ? - (void *)(uintptr_t)msg->sys.data[1].start : NULL)); + (msg->sys.numDataAreas == 2 ? msg->sys.data[1].start : NULL)); // cnt csaPacket->CLBM_nameUniquifier = nameUniquifier; @@ -305,14 +289,14 @@ void CSA_VOL_GetStorageInfoMsg(xMsg_s *msg) XLSS_GetStorageInfoMsg_s *xlssPacket = &msg->body.getStorageInfo.xlssPacket; CSA_GetStorageInfoMsg_s *csaPacket = &msg->body.getStorageInfo.csaPacket; - status = CSA_MsgRecv( &genMsg, &xlssPacket->XGSM_genMsg, msg, + status = CSA_MsgRecv( &genMsg, &xlssPacket->XGSM_genMsg, msg, xlssPacket->XGSM_zid, &beast, SLATCHED); if (status != zOK) { goto exitReturn; } - status = CSA_VOL_GetStorageInfo(&genMsg, beast, + status = CSA_VOL_GetStorageInfo(&genMsg, beast, &csaPacket->CGSM_storageInfo); CSA_MsgRecvCleanup(&beast, SLATCHED); @@ -349,7 +333,7 @@ void CSA_VOL_IsBlockInBeastMsg( goto exitReturn; } - csaPacket->CIBM_retReply = CSA_VOL_IsBlockInBeast(beast, + csaPacket->CIBM_retReply = CSA_VOL_IsBlockInBeast(beast, xlssPacket->XIBM_block); CSA_MsgRecvCleanup(&beast, SLATCHED); @@ -387,7 +371,7 @@ void CSA_VOL_GetFileBlkMsg( } FILEBLK_IO_MSG(ioMsg, beast, xlssPacket->XGFM_fileBlk, 0, CACHE_READ); - buffer = CSA_VOL_GetFileBlk(&genMsg, &ioMsg); + buffer = CSA_VOL_GetFileBlk(&genMsg, &ioMsg); if (buffer == NULL) { status = zFAILURE; @@ -397,8 +381,7 @@ void CSA_VOL_GetFileBlkMsg( csaPacket->CGFM_volBlk = buffer->volBlk; zASSERT(msg->sys.data[0].length == PAGE_SIZE); mapBufferPage(buffer); - memcpy((void *)(uintptr_t)msg->sys.data[0].start, - buffer->pBuf.data, msg->sys.data[0].length); + memcpy(msg->sys.data[0].start, buffer->pBuf.data, msg->sys.data[0].length); unmapBufferPage(buffer); CACHE_RELEASE(buffer); @@ -435,9 +418,9 @@ Buffer_s *CSA_VOL_AsyncReadFileBlk( offset = ((QUAD)ioMsg->fileBlk) << shift; numBytes = ((QUAD)1) << shift; - do + do { - status = CM_uncompressFileRange(genMsg, beast, offset, numBytes, + status = CM_uncompressFileRange(genMsg, beast, offset, numBytes, CACHE_READ, SLATCHED, NULL, &grantedRights, TRUE, &done); if (status != zOK) { @@ -468,7 +451,7 @@ void CSA_VOL_AsyncReadFileBlkMsg( } FILEBLK_IO_MSG(ioMsg, beast, xlssPacket->XARM_fileBlk, 0, CACHE_READ); - buffer = CSA_VOL_AsyncReadFileBlk(&genMsg, &ioMsg); + buffer = CSA_VOL_AsyncReadFileBlk(&genMsg, &ioMsg); if (buffer == NULL) { status = zFAILURE; @@ -478,8 +461,7 @@ void CSA_VOL_AsyncReadFileBlkMsg( csaPacket->CARM_volBlk = buffer->volBlk; zASSERT(msg->sys.data[0].length == PAGE_SIZE); mapBufferPage(buffer); - memcpy((void *)(uintptr_t)msg->sys.data[0].start, - buffer->pBuf.data, msg->sys.data[0].length); + memcpy(msg->sys.data[0].start, buffer->pBuf.data, msg->sys.data[0].length); unmapBufferPage(buffer); CACHE_RELEASE(buffer); @@ -526,15 +508,15 @@ void CSA_VOL_GetExtentListMsg( goto exitReturn; } - status = CSA_VOL_GetExtentList(&genMsg, beast, + status = CSA_VOL_GetExtentList(&genMsg, beast, xlssPacket->XGEM_startingBlk, msg->sys.data[0].length / sizeof(Blknum_t), - (Blknum_t *)(uintptr_t)msg->sys.data[0].start, + (Blknum_t *)msg->sys.data[0].start, &retNumExtents, &csaPacket->CGEM_retNextBlock); csaPacket->CGEM_retNumExtents = retNumExtents; - + CSA_MsgRecvCleanup(&beast, SLATCHED); exitReturn: @@ -552,7 +534,7 @@ BOOL CSA_VOL_IsDirectoryEmpty( File_s *directory, NINT nameType) { - return directory->FILEcomnOps.BST_isDirectoryEmpty(genMsg, + return directory->FILEcomnOps.BST_isDirectoryEmpty(genMsg, &directory->FILEnamed, nameType); } @@ -565,15 +547,15 @@ void CSA_VOL_IsDirectoryEmptyMsg( XLSS_IsDirectoryEmptyMsg_s *xlssPacket = &msg->body.isDirEmpty.xlssPacket; CSA_IsDirectoryEmptyMsg_s *csaPacket = &msg->body.isDirEmpty.csaPacket; - status = CSA_MsgRecv( &genMsg, &xlssPacket->XIDM_genMsg, msg, + status = CSA_MsgRecv( &genMsg, &xlssPacket->XIDM_genMsg, msg, xlssPacket->XIDM_dirZid, &directory, SLATCHED); if (status != zOK) { goto exitReturn; } - csaPacket->CIDM_retValue = CSA_VOL_IsDirectoryEmpty(&genMsg, - (File_s *)directory, xlssPacket->XIDM_nameType); + csaPacket->CIDM_retValue = CSA_VOL_IsDirectoryEmpty(&genMsg, + (File_s *)directory, xlssPacket->XIDM_nameType); status = GetErrno(&genMsg); CSA_MsgRecvCleanup(&directory, SLATCHED); @@ -604,7 +586,7 @@ void CSA_VOL_GetPhysicalExtentMsg( XLSS_GetPhysicalExtentMsg_s *xlssPacket=&xMsg->body.getPhyExtent.xlssPacket; CSA_GetPhysicalExtentMsg_s *csaPacket = &xMsg->body.getPhyExtent.csaPacket; - status = CSA_MsgRecv( &genMsg, NULL, xMsg, xlssPacket->XGPM_zid, + status = CSA_MsgRecv( &genMsg, NULL, xMsg, xlssPacket->XGPM_zid, &beast, SLATCHED); if (status != zOK) { @@ -612,8 +594,8 @@ void CSA_VOL_GetPhysicalExtentMsg( } zMsg.sys.status = zOK; - zMsg.sys.owner = 0; - zMsg.sys.door = 0; + zMsg.sys.owner = NULL; + zMsg.sys.door = NULL; zMsg.sys.numDataAreas = 1; zMsg.sys.data[MAP_DATA].start = xMsg->sys.data[MAP_DATA].start; zMsg.sys.data[MAP_DATA].length = xMsg->sys.data[MAP_DATA].length; @@ -623,7 +605,7 @@ void CSA_VOL_GetPhysicalExtentMsg( zMsg.body.map.offset = xlssPacket->XGPM_startOffset; zMsg.body.map.extentListFormat = zFILEMAP_PHYSICAL; - status = CSA_VOL_GetPhysicalExtent(&zMsg, beast); + status = CSA_VOL_GetPhysicalExtent(&zMsg, beast); if (status == zOK) { csaPacket->CGPM_retNumExtents = zMsg.body.map.retExtentListCount; @@ -674,8 +656,8 @@ void CSA_VOL_DioReadUnitsMsg( status = zFAILURE; goto exitVolumeLockFailed; } - - beast = BEASTHASH_LookupByZid(&genMsg, volume, + + beast = BEASTHASH_LookupByZid(&genMsg, volume, xlssPacket->XDRM_zid, SLATCHED); if (beast == NULL) { @@ -684,16 +666,16 @@ void CSA_VOL_DioReadUnitsMsg( } msg.sys.status = zOK; - msg.sys.owner = 0; - msg.sys.door = 0; + msg.sys.owner = NULL; + msg.sys.door = NULL; msg.sys.numDataAreas = 1; // msg.sys.data[DIO_DATA].start = csaPacket->CDRM_retData; msg.sys.data[DIO_DATA].length = xlssPacket->XDRM_length; - msg.sys.callback = 0; + msg.sys.callback = NULL; msg.body.id.sa = xlssPacket->XDRM_saID; msg.body.dio.unitOffset = xlssPacket->XDRM_startSector; - status = CSA_VOL_DioReadUnits(&msg, beast); + status = CSA_VOL_DioReadUnits(&msg, beast); if (status != zOK) { SetErrnoFromStatus(&genMsg, &msg); @@ -723,12 +705,12 @@ Zid_t CSA_VOL_WildcardLookup( NameSpace_s *nameSpace, NINT nameType, unicode_t *pattern, - SearchMap_s *smap, + SearchMap_s *smap, // cnt NINT *retNameUniquifier, FullDirectoryInfo_s *retInfo) { - return directory->FILEcomnOps.BST_wildcardLookup(genMsg, - &directory->FILEnamed, nameSpace, nameType, pattern, smap, + return directory->FILEcomnOps.BST_wildcardLookup(genMsg, + &directory->FILEnamed, nameSpace, nameType, pattern, smap, /* cnt retNameUniquifier,*/ retInfo); } @@ -745,7 +727,7 @@ void CSA_VOL_WildcardLookupMsg( XLSS_WildcardLookupMsg_s *xlssPacket = &msg->body.wildLookup.xlssPacket; CSA_WildcardLookupMsg_s *csaPacket = &msg->body.wildLookup.csaPacket; - status = CSA_MsgRecv( &genMsg, &xlssPacket->XWLM_genMsg, msg, + status = CSA_MsgRecv( &genMsg, &xlssPacket->XWLM_genMsg, msg, xlssPacket->XWLM_directoryZid, &directory, SLATCHED); if (status != zOK) { @@ -790,7 +772,7 @@ void CSA_VOL_WildcardLookupMsg( } else { - smap = SMAP_FindSearchMapByID(&pssConn->searchMaps, + smap = SMAP_FindSearchMapByID(&pssConn->searchMaps, xlssPacket->XWLM_smapID, SMAPOPT_notReusable); if (smap == NULL) { @@ -802,14 +784,13 @@ void CSA_VOL_WildcardLookupMsg( smap->options |= xlssPacket->XWLM_smapOptions; csaPacket->CWLM_smapID = smap->mapID; - csaPacket->CWLM_zid = CSA_VOL_WildcardLookup(&genMsg, + csaPacket->CWLM_zid = CSA_VOL_WildcardLookup(&genMsg, (File_s *)directory, nameSpace, - xlssPacket->XWLM_nameType, - (unicode_t *)(uintptr_t)msg->sys.data[0].start, /* pattern */ - smap, + xlssPacket->XWLM_nameType, + (unicode_t *)msg->sys.data[0].start, /* pattern */ + smap, // cnt &retNameUniquifier, - (msg->sys.numDataAreas == 2 ? - (void *)(uintptr_t)msg->sys.data[1].start : NULL)); + (msg->sys.numDataAreas == 2 ? msg->sys.data[1].start : NULL)); if (csaPacket->CWLM_zid == zINVALID_ZID) { @@ -862,15 +843,15 @@ void CSA_SearchMapCleanupMsgWork( for (;;) { - CIR_DEQ(SMapCleanupIDList, smapIDList, + CIR_DEQ(SMapCleanupIDList, smapIDList, SearchMapCleanupIDList_s, SMCIL_link); if (smapIDList == NULL) { break; } - smap = SMAP_FindSearchMapByID( &pssConn->searchMaps, - smapIDList->SMCIL_smapID, + smap = SMAP_FindSearchMapByID( &pssConn->searchMaps, + smapIDList->SMCIL_smapID, SMAPOPT_notReusable); if (smap != NULL) { @@ -907,13 +888,13 @@ void CSA_SearchMapCleanupMsg( smapIDList->SMCIL_link = NULL; CIR_ENQ(SMapCleanupIDList, smapIDList, SMCIL_link); - + if (!SMapCleanupWork.SMCW_workScheduled) { SMapCleanupWork.SMCW_workScheduled = TRUE; FSMLITE_INIT(&SMapCleanupWork.SMCW_fsm, MSGNot("SmapCleanupWork"), 0); - WORK_Schedule( &SMapCleanupWork.SMCW_fsm, - (voidfunc_t)CSA_SearchMapCleanupMsgWork, 0); + WORK_Schedule( &SMapCleanupWork.SMCW_fsm, + CSA_SearchMapCleanupMsgWork, NULL); } return; } @@ -921,8 +902,8 @@ void CSA_SearchMapCleanupMsg( /***************************************************************************** * - * Request from the XLSS to cleanup all SMs that were created for this - * slave. + * Request from the XLSS to cleanup all SMs that were created for this + * slave. * * I get the IDs and put them on the list (instead of directly releasing them) * because the SM latch needs to be held to release them. Getting the latch @@ -938,7 +919,7 @@ void CSA_SearchMapCleanupAll( for (;;) { DQ_DEQ(&volObject->smapHead, smap, SearchMap_s, croLink); - + if (smap == NULL) { break; @@ -952,13 +933,13 @@ void CSA_SearchMapCleanupAll( smapIDList->SMCIL_link = NULL; CIR_ENQ(SMapCleanupIDList, smapIDList, SMCIL_link); - + if (!SMapCleanupWork.SMCW_workScheduled) { SMapCleanupWork.SMCW_workScheduled = TRUE; FSMLITE_INIT(&SMapCleanupWork.SMCW_fsm, MSGNot("SmapCleanupWork"), 0); - WORK_Schedule( &SMapCleanupWork.SMCW_fsm, - (voidfunc_t)CSA_SearchMapCleanupMsgWork, 0); + WORK_Schedule( &SMapCleanupWork.SMCW_fsm, + CSA_SearchMapCleanupMsgWork, NULL); } PERIODIC_YIELD(); } @@ -971,7 +952,7 @@ void CSA_SearchMapCleanupAllMsg( CSA_SearchMapCleanupAll((CsaVolumeDoor_s *)msg->sys.door); return; } - + /***************************************************************************** * ****************************************************************************/ @@ -981,12 +962,12 @@ Zid_t CSA_SearchMapReestablish( NameSpace_s *nameSpace, NINT nameType, unicode_t *pattern, - SearchMap_s *smap) + SearchMap_s *smap) { // cnt NINT retNameUniquifier; - return directory->FILEcomnOps.BST_wildcardLookup(genMsg, - &directory->FILEnamed, nameSpace, nameType, pattern, smap, + return directory->FILEcomnOps.BST_wildcardLookup(genMsg, + &directory->FILEnamed, nameSpace, nameType, pattern, smap, /* cnt &retNameUniquifier,*/ NULL); } @@ -1005,14 +986,14 @@ void CSA_SearchMapReestablishMsg( } Stack_s; Stack_s *aStack; - XLSS_SearchMapReestablishMsg_s *xlssPacket = + XLSS_SearchMapReestablishMsg_s *xlssPacket = &msg->body.reestablishSmap.xlssPacket; - CSA_SearchMapReestablishMsg_s *csaPacket = + CSA_SearchMapReestablishMsg_s *csaPacket = &msg->body.reestablishSmap.csaPacket; STACK_ALLOC_NO_ASTACK(); - status = CSA_MsgRecv( &genMsg, &xlssPacket->XSRM_genMsg, msg, + status = CSA_MsgRecv( &genMsg, &xlssPacket->XSRM_genMsg, msg, xlssPacket->XSRM_directoryZid, &directory, SLATCHED); if (status != zOK) { @@ -1035,7 +1016,7 @@ void CSA_SearchMapReestablishMsg( /** Get the name corresponding to the zid where we want to set our ** search map to **/ - if ((file = BEASTHASH_LookupByZid(&genMsg, directory->ROOTvolume, + if ((file = BEASTHASH_LookupByZid(&genMsg, directory->ROOTvolume, xlssPacket->XSRM_zid, SLATCHED)) == NULL) { status = zFAILURE; @@ -1075,10 +1056,10 @@ void CSA_SearchMapReestablishMsg( smap->options |= xlssPacket->XSRM_smapOptions; csaPacket->CSRM_smapID = smap->mapID; - csaPacket->CSRM_zid = CSA_SearchMapReestablish(&genMsg, + csaPacket->CSRM_zid = CSA_SearchMapReestablish(&genMsg, (File_s *)directory, nameSpace, - xlssPacket->XSRM_nameType, - aStack->name, /* pattern */ + xlssPacket->XSRM_nameType, + aStack->name, /* pattern */ smap); if (csaPacket->CSRM_zid == zINVALID_ZID) @@ -1107,7 +1088,7 @@ exitReturn: /***************************************************************************** * CSA_SendVolumeStats - * + * * Runs on a timer to send updates VolumeStats to the slaves, if the stats * have changed. ****************************************************************************/ @@ -1115,7 +1096,7 @@ void CSA_SendVolumeStats( FsmLite_s *fsm, Volume_s *volume) { - CsaVolumeInfo_s *csaVolInfo = volume->v_csaVolInfo; + CsaVolumeInfo_s *csaVolInfo = volume->v_csaVolInfo; xMsg_s msg; CSA_SendVolumeStatsMsg_s *csaPacket = &msg.body.sendVolStats.csaPacket; @@ -1140,8 +1121,8 @@ void CSA_SendVolumeStats( CSA_MsgSendAll(volume, &msg, XLSS_SEND_VOLUME_STATS); - secOneShot( &csaVolInfo->CVI_volumeStatsUpdateTimer, - CFS_UPDATE_VOL_STATS_SECS, + secOneShot( &csaVolInfo->CVI_volumeStatsUpdateTimer, + CFS_UPDATE_VOL_STATS_SECS, CSA_SendVolumeStatsCheck); COMN_Release(&volume); @@ -1155,8 +1136,8 @@ void CSA_SendVolumeStats( void CSA_SendVolumeStatsCheck( OneShot_s *timer) { - CsaVolumeInfo_s *csaVolInfo = STRUCT(timer, CsaVolumeInfo_s, - CVI_volumeStatsUpdateTimer); + CsaVolumeInfo_s *csaVolInfo = STRUCT(timer, CsaVolumeInfo_s, + CVI_volumeStatsUpdateTimer); Volume_s *volume = csaVolInfo->CVI_volume; XlssMasterVolumeInfo_s volInfo; @@ -1171,19 +1152,18 @@ void CSA_SendVolumeStatsCheck( return; } - CSAVOL_FillMasterVolInfo(volume, &volInfo); + CSAVOL_FillMasterVolInfo(volume, &volInfo); - if (memcmp(&volInfo, &csaVolInfo->CVI_volStatsLastSent, + if (memcmp(&volInfo, &csaVolInfo->CVI_volStatsLastSent, sizeof(volInfo)) != 0) { COMN_USE_BEAST(&volume->VOLroot); - WORK_Schedule(&csaVolInfo->CVI_fsm, - (voidfunc_t)CSA_SendVolumeStats, (ADDR)volume); + WORK_Schedule(&csaVolInfo->CVI_fsm, CSA_SendVolumeStats, (ADDR)volume); } - else + else { - secOneShot( &csaVolInfo->CVI_volumeStatsUpdateTimer, - CFS_UPDATE_VOL_STATS_SECS, + secOneShot( &csaVolInfo->CVI_volumeStatsUpdateTimer, + CFS_UPDATE_VOL_STATS_SECS, CSA_SendVolumeStatsCheck); } return; @@ -1192,12 +1172,12 @@ void CSA_SendVolumeStatsCheck( /***************************************************************************** * - * This routine is called when the slave first starts communicating with + * This routine is called when the slave first starts communicating with * the master. When the slave who has demanded gets its callback routine * called, it will call this routine to create a communication link with * a set of keys being exchanged. * This routine is called with the volume active if we are not in reconnect - * mode. + * mode. ****************************************************************************/ void CSA_VolNotifyMsg( xMsg_s *msg) @@ -1227,7 +1207,7 @@ void CSA_VolNotifyMsg( COMN_USE_BEAST(&volume->VOLroot); - if (!(volume->v_statusFlag & VOL_SF_RECONNECT)) + if (!(volume->v_statusFlag & VOL_SF_RECONNECT)) { if (COMN_LockVolumeActive(&genMsg, volume, FALSE) != zOK) { @@ -1248,7 +1228,7 @@ void CSA_VolNotifyMsg( case zVOLSTATE_ACTIVE: { if (!(volume->v_statusFlag & VOL_SF_RECONNECT) && - (xlssPacket->XVNM_reconnectState != + (xlssPacket->XVNM_reconnectState != CRO_RECONNECT_STATE_IN_SYNC)) { goto exitBadState; @@ -1276,11 +1256,11 @@ void CSA_VolNotifyMsg( DQ_INIT(&volume->v_csaVolInfo->CVI_csaVolumeDoorHead); DQ_INIT(&volume->v_csaVolInfo->CVI_csaBeastHead); INIT_ONESHOT(volume->v_csaVolInfo->CVI_volumeStatsUpdateTimer); - FSMLITE_INIT(&volume->v_csaVolInfo->CVI_fsm, - MSGNot("CFS Volume Stats"), 0); + FSMLITE_INIT(&volume->v_csaVolInfo->CVI_fsm, + MSGNot("CFS Volume Stats"), 0); volume->v_csaVolInfo->CVI_scheduled = FALSE; } - csaVolObject = MSG_CreateDoor(&CsaVolumeType.hdr, + csaVolObject = MSG_CreateDoor(&CsaVolumeType.hdr, CsaMsgMgr.mgr, 0, &csaVolKey); if (csaVolObject == NULL) { @@ -1301,7 +1281,7 @@ void CSA_VolNotifyMsg( csaVolObject->volume = volume; csaVolObject->reconnectState = xlssPacket->XVNM_reconnectState; NULLIFY(&csaVolObject->csaVolumeDoorLink); - DQ_ENQ( &volume->v_csaVolInfo->CVI_csaVolumeDoorHead, + DQ_ENQ( &volume->v_csaVolInfo->CVI_csaVolumeDoorHead, csaVolObject, csaVolumeDoorLink); DQ_INIT(&csaVolObject->smapHead); if (csaVolObject->reconnectState == CRO_RECONNECT_STATE_IN_SYNC) @@ -1309,15 +1289,15 @@ void CSA_VolNotifyMsg( if (!(volume->v_statusFlag & VOL_SF_RECONNECT)) { xMSG_INIT(&aStack->reconnectMsg); - MSG_Send(csaVolObject->xlssVolumeKey, + MSG_Send(csaVolObject->xlssVolumeKey, XLSS_ALL_SLAVES_SYNCD, (Msg_s *)&aStack->reconnectMsg); } } if (!volume->v_csaVolInfo->CVI_scheduled) { volume->v_csaVolInfo->CVI_scheduled = TRUE; - secOneShot( &volume->v_csaVolInfo->CVI_volumeStatsUpdateTimer, - CFS_UPDATE_VOL_STATS_SECS, + secOneShot( &volume->v_csaVolInfo->CVI_volumeStatsUpdateTimer, + CFS_UPDATE_VOL_STATS_SECS, CSA_SendVolumeStatsCheck); } break; @@ -1327,7 +1307,7 @@ void CSA_VolNotifyMsg( goto exitBadState; } } - + exitBadState: if (lockedActive) { @@ -1410,3 +1390,5 @@ void CSA_StatsDisplay_UI() aprintf(CYAN," Deleted %Lu\n", CSAStats.CS_beastLeaseDeleted ); } /* End of CSA_StatsDisplay_UI() */ + + diff --git a/src/nwnss/comn/common/cSAcache.c b/src/nwnss/comn/common/cSAcache.c index 26b590e..5147f7f 100644 --- a/src/nwnss/comn/common/cSAcache.c +++ b/src/nwnss/comn/common/cSAcache.c @@ -34,7 +34,6 @@ +-------------------------------------------------------------------------*/ #include -#include #include #include @@ -51,19 +50,19 @@ void CSA_MsgSendAll( Volume_s *volume, xMsg_s *msg, NINT method) -{ +{ CsaVolumeDoor_s *csaVolObject; CsaVolumeDoor_s *prevCsaVolObject; if (CSA_SLAVE_VOLUMES_FOUND(volume)) { - DQ_FOREACH_NONEXT(&volume->v_csaVolInfo->CVI_csaVolumeDoorHead, + DQ_FOREACH_NONEXT(&volume->v_csaVolInfo->CVI_csaVolumeDoorHead, csaVolObject, CsaVolumeDoor_s, csaVolumeDoorLink) { MSG_USE_DOOR(&csaVolObject->door); MSG_Send(csaVolObject->xlssVolumeKey, method, (Msg_s *)msg); - DQ_FOREACH_NEXT(prevCsaVolObject, csaVolObject, + DQ_FOREACH_NEXT(prevCsaVolObject, csaVolObject, CsaVolumeDoor_s, csaVolumeDoorLink); /*** WARNING - csaVolumeDoorLink now points to *** the next item. Generally, code below this @@ -88,17 +87,17 @@ void CSA_RemoveNameCacheEntry( NINT nsFlag) { xMsg_s msg; - CSA_NameCacheInvalidateMsg_s *csaPacket = + CSA_NameCacheInvalidateMsg_s *csaPacket = &msg.body.nameCacheInvalidate.csaPacket; - xMSG_INIT( &msg ); + xMSG_INIT( &msg ); csaPacket->CNCM_parentZid = parentZid; csaPacket->CNCM_nameSpaceMask = nameSpaceMask; csaPacket->CNCM_nameType = nameType; csaPacket->CNCM_nsFlag = nsFlag; - msg.sys.data[0].start = (QUAD)(uintptr_t)uniName; + msg.sys.data[0].start = uniName; msg.sys.data[0].length = (unilen(uniName) + 1) * sizeof(unicode_t); msg.sys.numDataAreas++; msg.sys.readMask = 0x01; @@ -117,11 +116,11 @@ void CSA_InvalidateAuthCache( BOOL entireCache) { xMsg_s msg; - CSA_AuthCacheInvalidateMsg_s *csaPacket = + CSA_AuthCacheInvalidateMsg_s *csaPacket = &msg.body.authCacheInvalidate.csaPacket; Volume_s *volume; - xMSG_INIT( &msg ); + xMSG_INIT( &msg ); csaPacket->CACM_trusteeID = *trusteeID; csaPacket->CACM_entireCache = entireCache; @@ -142,7 +141,7 @@ void CSA_InvalidateAuthCache( COMN_Release(&volume); } continueWithNextVolume: - SET_FOREACHBLOCKINGEND(&NSSMasterVolumeList, volume, Volume_s, + SET_FOREACHBLOCKINGEND(&NSSMasterVolumeList, volume, Volume_s, masterVolLink) } return; @@ -156,8 +155,10 @@ void CSA_NotifyAllSlavesSyncd( { xMsg_s msg; - xMSG_INIT( &msg ); + xMSG_INIT( &msg ); CSA_MsgSendAll(volume, &msg, XLSS_ALL_SLAVES_SYNCD); return; } + + diff --git a/src/nwnss/comn/common/cSAmanager.c b/src/nwnss/comn/common/cSAmanager.c index 2941d25..9edf199 100644 --- a/src/nwnss/comn/common/cSAmanager.c +++ b/src/nwnss/comn/common/cSAmanager.c @@ -57,7 +57,7 @@ typedef struct CsaMsgType_s { mTypeHeader_s hdr; - statusfunc_t method[CSA_MSG_NUM_METHODS]; + statusfunc_t method[CSA_MSG_NUM_METHODS]; } CsaMsgType_s; typedef statusfunc_t CM_t; @@ -68,7 +68,7 @@ ADDR CSA_ConsumerIDExit; BOOL CSA_StartupCompleted = TRUE; CsamManager_s CsaMsgMgr = { 0 }; -CsaMsgType_s CsaMsgType = +CsaMsgType_s CsaMsgType = { MSG_INIT_TYPE("CsaMasterVolume", &DoorType.hdr, sizeof(CsaMsgDoor_s), CSA_MSG_NUM_METHODS, @@ -79,7 +79,7 @@ CsaMsgType_s CsaMsgType = } }; -CsaVolumeType_s CsaVolumeType = +CsaVolumeType_s CsaVolumeType = { MSG_INIT_TYPE("CsaVolume", &DoorType.hdr, sizeof(CsaVolumeDoor_s), CSA_VOL_NUM_METHODS, @@ -165,7 +165,7 @@ BOOL CSA_matchCleanup ( mDoor_s *door, VolumeID_t *guid ) void CSA_SupplyVolCleanup( VolumeID_t *guid) { - MSG_BreakSetOfDoors(&CsaMsgType.hdr, (boolfunc_t)CSA_matchCleanup, guid); + MSG_BreakSetOfDoors(&CsaMsgType.hdr, CSA_matchCleanup, guid); } LONG CSA_ChangeVolStateExit (struct EventBlock *evBlk) @@ -195,9 +195,9 @@ LONG CSA_ChangeVolStateExit (struct EventBlock *evBlk) // } // MPKNSS_LOCK(); // rc = CSA_SupplyVolName(volName, &data->volID); -// MPKNSS_UNLOCK(); +// MPKNSS_UNLOCK(); // } -// else +// else if (data->newState != zVOLSTATE_ACTIVE) { MPKNSS_LOCK(); @@ -208,11 +208,11 @@ LONG CSA_ChangeVolStateExit (struct EventBlock *evBlk) { if (CSA_SLAVE_VOLUMES_FOUND(volume)) { - while (1) + while (1) { - DQ_DEQ( &volume->v_csaVolInfo->CVI_csaVolumeDoorHead, + DQ_DEQ( &volume->v_csaVolInfo->CVI_csaVolumeDoorHead, csaVolObject, CsaVolumeDoor_s, csaVolumeDoorLink); - if (csaVolObject == NULL) + if (csaVolObject == NULL) { break; } @@ -229,7 +229,7 @@ LONG CSA_ChangeVolStateExit (struct EventBlock *evBlk) } CSA_SupplyVolCleanup(&data->volID); - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); } return 0; } @@ -274,7 +274,7 @@ void CSA_CheckForSlavesAndSync( Volume_s *volume) { GeneralMsg_s genMsg; - STATUS rc; + STATUS rc; NINT timeout; CsaVolumeDoor_s *csaVolObject; BOOL allSyncd = FALSE; @@ -290,7 +290,7 @@ void CSA_CheckForSlavesAndSync( STACK_FREE(); return; } - + /* * We just had a volume come on line, advertise it in * the switchboard @@ -349,7 +349,7 @@ void CSA_CheckForSlavesAndSync( { if (csaVolObject->reconnectState >= CRO_RECONNECT_STATE_SYNC_PHASE1) { - continue; + continue; } else { @@ -373,7 +373,7 @@ void CSA_CheckForSlavesAndSync( { if (csaVolObject->reconnectState == CRO_RECONNECT_STATE_IN_SYNC) { - continue; + continue; } else { diff --git a/src/nwnss/comn/common/checker.c b/src/nwnss/comn/common/checker.c index 5ac6410..614bf5d 100644 --- a/src/nwnss/comn/common/checker.c +++ b/src/nwnss/comn/common/checker.c @@ -110,7 +110,7 @@ void CHK_TimedOut( } /*************************************************************************** - * This function puts the checker to sleep for the specified number of + * This function puts the checker to sleep for the specified number of * seconds. ***************************************************************************/ void CHK_Sleep( @@ -140,19 +140,19 @@ void CHK_ComputeDelayTime() } actualTime = GetHighResolutionTimer() - LastTimeChecked; - expectedTime = (CHK_BeastsProcessed * 10000 / CHK_NumBetweenDelay) / + expectedTime = (CHK_BeastsProcessed * 10000 / CHK_NumBetweenDelay) / (1000 / CHK_DELAY_AMOUNT); thresholdAmount = expectedTime + (expectedTime >> 3); /* 112.5% of expected */ #if CHK_DEBUG - aprintf(LMAGENTA, "Checker time: actual=%d expected=%d threshold=%d\n", + aprintf(LMAGENTA, "Checker time: actual=%d expected=%d threshold=%d\n", actualTime, expectedTime, thresholdAmount); #endif if (actualTime > thresholdAmount) { - CHK_NumBetweenDelay = (CHECK_BUSY_NUM_BEASTS * 100) / + CHK_NumBetweenDelay = (CHECK_BUSY_NUM_BEASTS * 100) / ((actualTime * 100) / expectedTime); /* Make sure we require at least one beast on each delay */ if (CHK_NumBetweenDelay == 0) @@ -166,12 +166,12 @@ void CHK_ComputeDelayTime() } #if CHK_DEBUG - aprintf(LCYAN, "Checker computed CHK_NumBetweenDelay=%d\n", + aprintf(LCYAN, "Checker computed CHK_NumBetweenDelay=%d\n", CHK_NumBetweenDelay); #endif LastTimeChecked = GetHighResolutionTimer(); CHK_BeastsProcessed = 0; -} +} #if zNETWARE /*************************************************************************** @@ -216,7 +216,7 @@ STATUS CHK_GetContext( LONG status; const unicode dotDelims[] = {DELIM_CFG_FALSE, DELIM_CFG_TRUE, - DELIM_DF_RDN, DELIM_DF_RDN, DELIM_DV, DELIM_VALUE, DELIM_WILD, + DELIM_DF_RDN, DELIM_DF_RDN, DELIM_DV, DELIM_VALUE, DELIM_WILD, DELIM_DF_ESCAPE, 0}; MPKNSS_UNLOCK(); @@ -315,7 +315,7 @@ BOOL CHK_ShutdownVolume( /************************************************************************** * This function checks the user tree to make sure that the entries are - * still valid. + * still valid. ***************************************************************************/ void CHK_CheckUsers( Volume_s *volume, @@ -342,7 +342,7 @@ void CHK_CheckUsers( struct { - struct + struct { unicode_t *namePtr; unicode_t uniName[MAX_DN_CHARS+1]; @@ -395,7 +395,7 @@ void CHK_CheckUsers( for (;;) { if (volume->VOLcomnVolOps.VOL_browseUsersInVolume(&genMsg, volume, - MAX_USER_INFO_ENTRIES, &alloc->lastUserReturned, alloc->userInfo, + MAX_USER_INFO_ENTRIES, &alloc->lastUserReturned, alloc->userInfo, &numReturned, BROWSE_USERS_GET_ALL) != zOK) { zASSERT("Error browsing users in volume" == NULL); @@ -438,15 +438,15 @@ void CHK_CheckUsers( if (ccode == 0) { #if CHK_DEBUG - DBG_DebugPrintf(YELLOW, - "CHK_CheckUsers: Change name to:%U\n", + DBG_DebugPrintf(YELLOW, + "CHK_CheckUsers: Change name to:%U\n", alloc->name.namePtr); #endif - xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, + xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, X_CF_DEFAULT); status = volume->VOLcomnVolOps.VOL_insertObjectName( - &genMsg, volume, xaction, &alloc->userInfo[i].userID, + &genMsg, volume, xaction, &alloc->userInfo[i].userID, alloc->name.namePtr); volume->VOLcomnVolOps.VOL_endXLocal(xaction); if (status != zOK) @@ -457,7 +457,7 @@ void CHK_CheckUsers( } #endif #if zNETWARE - if (COMN_LocalMapNDSGUIDToID(&status, &alloc->userInfo[i].userID, + if (COMN_LocalMapNDSGUIDToID(&status, &alloc->userInfo[i].userID, &oldID, NULL, &addToCache) == zOK) { /* @@ -470,21 +470,21 @@ void CHK_CheckUsers( /* * Get entry info */ - ccode = (*DDCGetEntryInfoPtr)(context, DSI_ENTRY_DN, + ccode = (*DDCGetEntryInfoPtr)(context, DSI_ENTRY_DN, sizeof(alloc->name), &alloc->name); if (ccode == 0) { #if CHK_DEBUG - DBG_DebugPrintf(YELLOW, - "CHK_CheckUsers: Change name to:%U\n", + DBG_DebugPrintf(YELLOW, + "CHK_CheckUsers: Change name to:%U\n", alloc->name.namePtr); #endif MPKNSS_LOCK(); - xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, + xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, X_CF_DEFAULT); status = volume->VOLcomnVolOps.VOL_insertObjectName( - &genMsg, volume, xaction, &alloc->userInfo[i].userID, + &genMsg, volume, xaction, &alloc->userInfo[i].userID, alloc->name.namePtr); volume->VOLcomnVolOps.VOL_endXLocal(xaction); if (status != zOK) @@ -519,7 +519,7 @@ void CHK_CheckUsers( DBG_DebugPrintf(YELLOW, "CHK_CheckUsers:Can't find user. GUID=%d.\n", alloc->userInfo[i].userID.timeLow); #endif - /* + /* * If there is no name and we have disk space then we are OK, * otherwise, we can remove this entry. */ @@ -532,7 +532,7 @@ void CHK_CheckUsers( } else { - status = volume->VOLcomnVolOps.VOL_removeUser(&genMsg, + status = volume->VOLcomnVolOps.VOL_removeUser(&genMsg, volume, &alloc->userInfo[i].userID); } } @@ -552,21 +552,21 @@ void CHK_CheckUsers( &alloc->currentGUID); #endif #if zNETWARE - ccode = (*DDCNameToIDPtr)(context, DS_CREATE_ID, + ccode = (*DDCNameToIDPtr)(context, DS_CREATE_ID, &alloc->uniName); #endif MPKNSS_LOCK(); if (ccode != 0 || alloc->uniName[0] == 0) { - /* + /* * Got an error looking up the name. If enough time has * passed and we have re-tried enough times then get rid * of this entry. */ #if CHK_DEBUG DBG_DebugPrintf(LRED, - "CHK_CheckUsers:Error %d looking up user. count=%d time=%d curtime=%d\n", - status, numberOfTimesNotFound, timeNotFound, + "CHK_CheckUsers:Error %d looking up user. count=%d time=%d curtime=%d\n", + status, numberOfTimesNotFound, timeNotFound, GetUTCTime()); #endif if ((numberOfTimesNotFound >= CHK_RetryMax) && @@ -576,7 +576,7 @@ void CHK_CheckUsers( #if CHK_DEBUG DBG_DebugPrintf(LRED, "CHK_CheckUsers: Removing User.\n"); #endif - status = volume->VOLcomnVolOps.VOL_removeUser(&genMsg, + status = volume->VOLcomnVolOps.VOL_removeUser(&genMsg, volume, &alloc->userInfo[i].userID); } else @@ -589,11 +589,11 @@ void CHK_CheckUsers( timeNotFound = GetUTCTime(); } numberOfTimesNotFound++; - xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, + xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, X_CF_DEFAULT); status = volume->VOLcomnVolOps.VOL_modifyObjectName( - &genMsg, volume, xaction, &alloc->userInfo[i].userID, - alloc->uniName, timeNotFound, + &genMsg, volume, xaction, &alloc->userInfo[i].userID, + alloc->uniName, timeNotFound, numberOfTimesNotFound); volume->VOLcomnVolOps.VOL_endXLocal(xaction); } @@ -601,14 +601,14 @@ void CHK_CheckUsers( else { /* - * Make sure that the guid from the name is the same one + * Make sure that the guid from the name is the same one * as the entry we started with. */ #if zNETWARE /* On Linux, the above successful call to ndp_NCPMapDNToGUID * already gave us a GUID */ - if (COMN_MapNDSIDToGUID(&status, + if (COMN_MapNDSIDToGUID(&status, DDCContextEntryIDPtr(context), &alloc->currentGUID) == zOK) #endif { @@ -622,7 +622,7 @@ void CHK_CheckUsers( } if (timeNotFound) { - /* + /* * If found and it was previously not found then clear * the "not found" time and count. */ @@ -631,11 +631,11 @@ void CHK_CheckUsers( timeNotFound = 0; numberOfTimesNotFound = 0; } - xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, + xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, X_CF_DEFAULT); status = volume->VOLcomnVolOps.VOL_modifyObjectName( - &genMsg, volume, xaction, &alloc->userInfo[i].userID, - alloc->uniName, timeNotFound, + &genMsg, volume, xaction, &alloc->userInfo[i].userID, + alloc->uniName, timeNotFound, numberOfTimesNotFound); volume->VOLcomnVolOps.VOL_endXLocal(xaction); } @@ -655,7 +655,7 @@ exitFree: free(alloc); exit: return; -} +} /**************************************************************************** * This function checks to see if the ID is still valid. @@ -698,7 +698,7 @@ STATUS CHK_VerifyID( * Unable to find the name in the object ID store. Do another check of * NDS just to make sure. If it's not found then return FALSE. */ - if (COMN_LocalMapNDSGUIDToID(&status, objectID, + if (COMN_LocalMapNDSGUIDToID(&status, objectID, &oldID, NULL, &addToCache) != zOK) { *isOK = FALSE; @@ -717,7 +717,7 @@ STATUS CHK_VerifyID( /************************************************************************** * This function checks the beast tree to make sure that the user IDs are - * still valid. + * still valid. ***************************************************************************/ void CHK_CheckFiles( Volume_s *volume, @@ -747,7 +747,7 @@ void CHK_CheckFiles( goto exit; } - aprintf(YELLOW, "Doing NSS background check of files on volume %U\n", + aprintf(YELLOW, "Doing NSS background check of files on volume %U\n", volName); /* @@ -822,7 +822,7 @@ exit: /*************************************************************************** * This function checks the directory tree to make sure that the entries are - * still valid. + * still valid. ***************************************************************************/ void CHK_CheckDirectoryQuotas( Volume_s *volume, @@ -866,7 +866,7 @@ void CHK_CheckDirectoryQuotas( LB_delay(1); if (volume->VOLcomnVolOps.VOL_browseDirsInVolume(&genMsg, volume, - MAX_DIR_INFO_ENTRIES, &lastDirReturned, aStack->dirInfo, + MAX_DIR_INFO_ENTRIES, &lastDirReturned, aStack->dirInfo, &numReturned) != zOK) { zASSERT(GetErrno(&genMsg) == zERR_DIR_QUOTAS_NOT_ENABLED); @@ -889,7 +889,7 @@ void CHK_CheckDirectoryQuotas( DBG_DebugPrintf(LCYAN, "Checking dir %Lx\n", aStack->dirInfo[i].dirZid); #endif - if ((beast = COMN_LookupByZid(&genMsg, volume, aStack->dirInfo[i].dirZid, + if ((beast = COMN_LookupByZid(&genMsg, volume, aStack->dirInfo[i].dirZid, NOTLATCHED, TRUE)) == NULL) { if (GetErrno(&genMsg) == zERR_ZID_NOT_FOUND) @@ -897,20 +897,20 @@ void CHK_CheckDirectoryQuotas( #if CHK_DEBUG DBG_DebugPrintf(LRED, "removing dir %Lx\n", aStack->dirInfo[i].dirZid); #endif - xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, + xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, X_CF_DEFAULT); - if (volume->VOLcomnVolOps.VOL_removeDirectory(&genMsg, + if (volume->VOLcomnVolOps.VOL_removeDirectory(&genMsg, volume, xaction, aStack->dirInfo[i].dirZid) != zOK) { - zASSERT("Error removing dir entry dir background check" + zASSERT("Error removing dir entry dir background check" == NULL); ClearErrno(&genMsg); - } + } volume->VOLcomnVolOps.VOL_endXLocal(xaction); } else { - zASSERT("Error getting beast during background dir quota check" + zASSERT("Error getting beast during background dir quota check" == NULL); ClearErrno(&genMsg); } @@ -925,10 +925,10 @@ void CHK_CheckDirectoryQuotas( exit: STACK_FREE(); return; -} +} /************************************************************************** - * This function is scheduled as a background thread to check the file + * This function is scheduled as a background thread to check the file * system. ***************************************************************************/ void CHK_CheckerThread( @@ -978,7 +978,7 @@ void CHK_CheckerThread( * If checking has not been suspended then go for it... */ if ((Config.Storage.checker) || (Config.Storage.forceChecker)) - { + { aprintf(YELLOW, "NSS background check running (%d)...\n", ++count); CHK_BeastsProcessed = 0; @@ -993,7 +993,7 @@ void CHK_CheckerThread( { if (!CHK_ShutdownVolume(volume)) { - (void)COMN_GetVolumeName(&genMsg, volume, volName, + (void)COMN_GetVolumeName(&genMsg, volume, volName, zMAX_COMPONENT_NAME); ClearErrno( &genMsg ); CHK_CheckUsers(volume, volName); @@ -1030,13 +1030,13 @@ exit: void CHK_StartProcess() { #if zNETWARE - ZOS_StartThreadWithModuleHandle(CHK_ThreadID, "NSS Checker", - (void *(*)(THREAD, void *))CHK_CheckerThread, + ZOS_StartThreadWithModuleHandle(CHK_ThreadID, "NSS Checker", + (void *(*)(THREAD, void *))CHK_CheckerThread, 0, 0, NULL, (LONG)CMN_ModuleHandle); #endif #if zLINUX - ZOS_StartThread(CHK_ThreadID, "NSS Checker", - (void *(*)(THREAD, void *))CHK_CheckerThread, + ZOS_StartThread(CHK_ThreadID, "NSS Checker", + (void *(*)(THREAD, void *))CHK_CheckerThread, 0, 0, NULL); #endif if (CHK_ThreadID == 0) diff --git a/src/nwnss/comn/common/cmdLineRecovery.c b/src/nwnss/comn/common/cmdLineRecovery.c index 8c063af..eafea18 100644 --- a/src/nwnss/comn/common/cmdLineRecovery.c +++ b/src/nwnss/comn/common/cmdLineRecovery.c @@ -34,12 +34,11 @@ | This module is used to: | Recover SYS volume if it was renamed or if you need to expand it. +-------------------------------------------------------------------------*/ -#include +#include -#include -#include -#include -#include +#include +#include +#include #include "zPublics.h" #include "xmlNSS.h" @@ -67,8 +66,8 @@ STATUS InitializeCommandFile(Key_t *fileKey, Key_t *rootKey); ** Function: CovertFromSectors ** ** Given the number of sectors, convert it to either MB or GB depending on -** its size. partitionSize points to the string. -** Returns: Nothing +** its size. partitionSize points to the string. +** Returns: Nothing ****************************************************************************/ void CovertFromSectors(char size[], utf8_t* partitionSize) @@ -125,55 +124,55 @@ STATUS DisplayFreePartitions() // if we couldn't get memory abort requestBuffer = (utf8_t *)malloc(BUFFERSIZE); if (requestBuffer == NULL) - { + { aprintf( LRED, "Error out of memory" ); - return(zFAILURE); + return(zFAILURE); } strcpy(requestBuffer, ""); // initialize command file // abort if error on initializing command file. - if (InitializeCommandFile(&fileKey, &rootKey) != zOK) + if (InitializeCommandFile(&fileKey, &rootKey) != zOK) { free(requestBuffer); - return(zFAILURE); + return(zFAILURE); } // request partition information // abort if error on writing to command file. - if (WriteBuffer(requestBuffer, fileKey, strlen(requestBuffer)) != zOK) + if (WriteBuffer(requestBuffer, fileKey, strlen(requestBuffer)) != zOK) { free(requestBuffer); zClose(fileKey); - zClose(rootKey); + zClose(rootKey); return(zFAILURE); } // get reply // abort if error on read - if ((replyBuffer = ReadReply(fileKey)) == NULL) + if ((replyBuffer = ReadReply(fileKey)) == NULL) { free(requestBuffer); zClose(fileKey); - zClose(rootKey); + zClose(rootKey); return(zFAILURE); } // Close manage.cmd - zClose(fileKey); - zClose(rootKey); + zClose(fileKey); + zClose(rootKey); // get space for partitionSize buffer // if we couldn't get memory abort partitionSize = (utf8_t *)malloc(PARTITIONBUFFERSIZE); if (partitionSize == NULL) - { + { aprintf( LRED, "Memory allocation error.\n" ); free(requestBuffer); free(replyBuffer); - return(zFAILURE); + return(zFAILURE); } // setup pointers to start and end of buffer. - startOfData = replyBuffer; + startOfData = replyBuffer; endOfData = startOfData + strlen(replyBuffer); aprintf( LBLUE, "PartitionID\t Size\t\tPartition Name\n" ); while (1) @@ -183,16 +182,16 @@ STATUS DisplayFreePartitions() // parse to partitionInfo tag // save pointers to the begin partitionInfo tag and the end // partitionInfo tag - savstartOfData = elementInfo.dataStart; + savstartOfData = elementInfo.dataStart; savendOfData = elementInfo.dataEnd; if (XML_GetTagElement(TAG_PARTITIONNAME, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) - { + { // get partitionName and save it for later memcpy(partitionName, elementInfo.dataStart, elementInfo.dataLen); partitionName[elementInfo.dataLen] = '\0'; // restore saved position - elementInfo.dataStart = savstartOfData; + elementInfo.dataStart = savstartOfData; elementInfo.dataEnd = savendOfData; if (XML_GetTagElement(TAG_PARTITIONTYPE, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) @@ -202,7 +201,7 @@ STATUS DisplayFreePartitions() partitionType[elementInfo.dataLen] = '\0'; // restore saved position elementInfo.dataStart = savstartOfData; - elementInfo.dataEnd = savendOfData; + elementInfo.dataEnd = savendOfData; if (XML_GetTagElement(TAG_PARTITIONID, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) { @@ -241,7 +240,7 @@ STATUS DisplayFreePartitions() CovertFromSectors(numSectors, partitionSize); aprintf( LGREEN, " %-7s%12s %s\n", partitionID, partitionSize, partitionName ); } - } + } else { // else if partition type is NSS see if it's part of a pool @@ -249,7 +248,7 @@ STATUS DisplayFreePartitions() { if (strcmp( poolName,"") == 0) { - // if its not part of a pool then output + // if its not part of a pool then output CovertFromSectors(numSectors, partitionSize); aprintf( LGREEN, " %-7s%12s %s\n", partitionID, partitionSize, partitionName ); } @@ -266,18 +265,18 @@ STATUS DisplayFreePartitions() free(requestBuffer); free(replyBuffer); free(partitionSize); - return zOK; + return zOK; } // ajust start position so we get the next partitionInfo tag - startOfData = savendOfData; + startOfData = savendOfData; } } /**************************************************************************** ** Function: SalvageSys ** -** Salvage SYS -** +** Salvage SYS +** ** Returns: Status ****************************************************************************/ @@ -320,18 +319,18 @@ STATUS SalvageSys() // if we couldn't get memory abort requestBuffer = (utf8_t *)malloc(BUFFERSIZE); if (requestBuffer == NULL) - { + { aprintf( LRED, "Memory allocation error. SalvageSys failed.\n" ); - return(zFAILURE); + return(zFAILURE); } // initialize command file // abort if error on initializing command file. - if (InitializeCommandFile(&fileKey, &rootKey) != zOK) + if (InitializeCommandFile(&fileKey, &rootKey) != zOK) { free(requestBuffer); aprintf( LRED, "Error initializing command file. SalvageSys failed.\n" ); - return(zFAILURE); + return(zFAILURE); } strcpy(requestBuffer, RequestPoolCommand); @@ -339,7 +338,7 @@ STATUS SalvageSys() // request list of all pools so we can check each one to see which one contains deleted // SYS volume. // abort if error on writing to command file. - if (WriteBuffer(requestBuffer, fileKey, strlen(requestBuffer)) != zOK) + if (WriteBuffer(requestBuffer, fileKey, strlen(requestBuffer)) != zOK) { aprintf( LRED, "Error getting pool information. SalvageSys failed.\n" ); goto CleanUpFailure; @@ -347,7 +346,7 @@ STATUS SalvageSys() // get reply // abort if error on read - if ((replyBuffer = ReadReply(fileKey)) == NULL) + if ((replyBuffer = ReadReply(fileKey)) == NULL) { aprintf( LRED, "Error getting pool information. SalvageSys failed.\n" ); goto CleanUpFailure; @@ -367,19 +366,19 @@ STATUS SalvageSys() // parse to listPools tag if (XML_GetTagElement(TAG_LISTPOOLS, startOfData, endOfData, &elementInfo) == zOK) - { + { while (1) { - // save listPools end tag position + // save listPools end tag position savendOfData = elementInfo.dataEnd; // keep looking for poolInfo tags until we get a list of all pools if (XML_GetTagElement(TAG_POOLINFO, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) { - // get poolName + // get poolName if (XML_GetTagElement(TAG_POOLNAME, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) - { + { poolNameptr[pCount] = malloc(elementInfo.dataLen +1); memcpy(poolNameptr[pCount], elementInfo.dataStart, elementInfo.dataLen); @@ -387,7 +386,7 @@ STATUS SalvageSys() pCount++; // allocate another position in array for the next pointer // abort on error getting memory - if ((pPtr = realloc(poolNameptr, + if ((pPtr = realloc(poolNameptr, (pCount+1) * sizeof(poolNameptr))) == NULL) { aprintf( LRED, "Memory allocation error. SalvageSys failed.\n" ); @@ -408,7 +407,7 @@ STATUS SalvageSys() break; } // increment count and reposition start and end of data so we can look - // for next poolInfo tag. + // for next poolInfo tag. elementInfo.dataStart = elementInfo.dataEnd; elementInfo.dataEnd = savendOfData; } @@ -433,7 +432,7 @@ STATUS SalvageSys() // request pool information so we can get SYS's internal Name // abort if error on writing to command file. - if (WriteBuffer(requestBuffer, fileKey, strlen(requestBuffer)) != zOK) + if (WriteBuffer(requestBuffer, fileKey, strlen(requestBuffer)) != zOK) { aprintf( LRED, "Error getting deleted volume information. SalvageSys failed.\n" ); goto CleanUpFailureWithPoolPtr; @@ -442,7 +441,7 @@ STATUS SalvageSys() // get reply // abort if error on read free(replyBuffer); - if ((replyBuffer = ReadReply(fileKey)) == NULL) + if ((replyBuffer = ReadReply(fileKey)) == NULL) { aprintf( LRED, "Error getting deleted volume information. SalvageSys failed.\n" ); goto CleanUpFailureWithPoolPtr; @@ -463,7 +462,7 @@ STATUS SalvageSys() // Get the state of the pool. if (XML_GetTagElement(TAG_POOLSTATE, startOfData, endOfData, &elementInfo) == zOK) - { + { memcpy(poolState, elementInfo.dataStart, elementInfo.dataLen); poolState[elementInfo.dataLen] = '\0'; @@ -476,8 +475,8 @@ STATUS SalvageSys() // parse to deletedVolume tag if (XML_GetTagElement(TAG_DELETEDVOLUMEINFO, startOfData, endOfData, &elementInfo) == zOK) - { - // save deletedVolume end tag position + { + // save deletedVolume end tag position savendOfData = elementInfo.dataEnd; while (1) { @@ -485,7 +484,7 @@ STATUS SalvageSys() // volumes internal names saved. if (XML_GetTagElement(TAG_VOLUMENAME, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) - { + { internalVolNamePtr[count] = malloc(elementInfo.dataLen +1); memcpy(internalVolNamePtr[count], elementInfo.dataStart, elementInfo.dataLen); @@ -493,7 +492,7 @@ STATUS SalvageSys() count++; // allocate another position in array for the next pointer // abort on error getting memory - if ((ptr = realloc(internalVolNamePtr, + if ((ptr = realloc(internalVolNamePtr, (count+1) * sizeof(internalVolNamePtr))) == NULL) { aprintf( LRED, "Memory allocation error. SalvageSys failed.\n" ); @@ -507,7 +506,7 @@ STATUS SalvageSys() break; } // increment count and reposition start and end of data so we can look - // for next volumeName. + // for next volumeName. elementInfo.dataStart = elementInfo.dataEnd; elementInfo.dataEnd = savendOfData; } @@ -535,7 +534,7 @@ STATUS SalvageSys() // request volume information for each saved internal volume name until // we find SYS. // abort if error on writing to command file. - if (WriteBuffer(requestBuffer, fileKey, strlen(requestBuffer)) != zOK) + if (WriteBuffer(requestBuffer, fileKey, strlen(requestBuffer)) != zOK) { aprintf( LRED, "Error getting volume information. SavageSys failed.\n" ); goto CleanUpFailureWithVolPtr; @@ -543,7 +542,7 @@ STATUS SalvageSys() // get reply // abort if error on read free(replyBuffer); - if ((replyBuffer = ReadReply(fileKey)) == NULL) + if ((replyBuffer = ReadReply(fileKey)) == NULL) { aprintf( LRED, "Error getting volume information. SavageSys failed.\n" ); goto CleanUpFailureWithVolPtr; @@ -570,7 +569,7 @@ STATUS SalvageSys() strcat(requestBuffer, UndeleteVolume3); // try and undelete the SYS volume. // abort if error on writing to command file. - if (WriteBuffer(requestBuffer, fileKey, strlen(requestBuffer)) != zOK) + if (WriteBuffer(requestBuffer, fileKey, strlen(requestBuffer)) != zOK) { aprintf( LRED, "Error undeleting SYS volume. SavageSys failed.\n" ); goto CleanUpFailureWithVolPtr; @@ -578,7 +577,7 @@ STATUS SalvageSys() // get reply // abort if error on read free(replyBuffer); - if ((replyBuffer = ReadReply(fileKey)) == NULL) + if ((replyBuffer = ReadReply(fileKey)) == NULL) { aprintf( LRED, "Error undeleting SYS volume. SavageSys failed.\n" ); goto CleanUpFailureWithVolPtr; @@ -655,7 +654,7 @@ CleanUpOk: } free (poolNameptr); free(requestBuffer); - zClose(fileKey); + zClose(fileKey); zClose(rootKey); // Close manage.cmd return (zOK); @@ -675,7 +674,7 @@ CleanupFailureWithReply: free (replyBuffer); CleanUpFailure: free(requestBuffer); - zClose(fileKey); + zClose(fileKey); zClose(rootKey); // Close manage.cmd return (zFAILURE); } @@ -685,7 +684,7 @@ CleanUpFailure: ** Function: ChangeSysQuota ** ** Change SYS quota -** +** ** Returns: Status ****************************************************************************/ @@ -704,15 +703,15 @@ STATUS ChangeSysQuota(utf8_t quota[]) Key_t fileKey; // get space for request buffer - requestBuffer = (utf8_t *)malloc(BUFFERSIZE); + requestBuffer = (utf8_t *)malloc(BUFFERSIZE); if (requestBuffer == NULL) - { + { aprintf( LRED, "Error out of memory" ); return(zFAILURE); // if we couldn't get memory abort } // initialize command file if (InitializeCommandFile(&fileKey, &rootKey) != zOK) - { + { aprintf( LRED, "Error setting quota to \"%s\" MB.\n", quota ); free(requestBuffer); return(zFAILURE); // if we couldn't open command file return failure @@ -725,28 +724,28 @@ STATUS ChangeSysQuota(utf8_t quota[]) strcat(requestBuffer,""); // make sure quota is greater then 0 - if (LB_atoi (quota) > 0) + if (LB_atoi (quota) > 0) { rQuota = LB_atoq(quota); // convert to quad rQuota *= (QUAD)1048576; // quota needs to be in bytes LB_sprintf(description, "%Lu", rQuota); - strcat(requestBuffer,""); - } + } else - { - strcat(requestBuffer,""); + { + strcat(requestBuffer,""); } strcat(requestBuffer,""); strcat(requestBuffer,""); strcat(requestBuffer,""); strcat(requestBuffer,""); // write command to command file - if (WriteBuffer(requestBuffer, fileKey, strlen(requestBuffer)) != zOK) + if (WriteBuffer(requestBuffer, fileKey, strlen(requestBuffer)) != zOK) { free(requestBuffer); - zClose(fileKey); + zClose(fileKey); zClose(rootKey); // Close manage.cmd aprintf( LRED, "Error setting quota to \"%s\" MB.\n", quota ); return(zFAILURE); @@ -755,16 +754,16 @@ STATUS ChangeSysQuota(utf8_t quota[]) if ((replyBuffer = ReadReply(fileKey)) == NULL) // get reply { free(requestBuffer); - zClose(fileKey); + zClose(fileKey); zClose(rootKey); // Close manage.cmd aprintf( LRED, "Error setting quota to \"%s\" MB.\n", quota ); return(zFAILURE); } - zClose(fileKey); + zClose(fileKey); zClose(rootKey); // Close manage.cmd // setup pointers to start and end of buffer - startOfData = replyBuffer; + startOfData = replyBuffer; endOfData = startOfData + strlen(replyBuffer); if (XML_GetTagElement(TAG_MODIFYVOLUMEINFO, startOfData, endOfData, &elementInfo) == zOK) { @@ -777,14 +776,14 @@ STATUS ChangeSysQuota(utf8_t quota[]) resultValue[elementInfo.attributeValueLen] = '\0'; if (strcmp(resultValue, "0") == 0) // Check for error { - if (strcmp(quota, "0") == 0) + if (strcmp(quota, "0") == 0) { // if quota was set to zero output None aprintf( LGREEN, "SYS volume quota was successfully changed to \"None\".\n" ); } else { - // otherwise let them now what the new quota is. + // otherwise let them now what the new quota is. aprintf( LGREEN, "SYS volume quota was successfully changed to \"%s\" MB.\n", quota ); } free(requestBuffer); @@ -812,7 +811,7 @@ STATUS ChangeSysQuota(utf8_t quota[]) free(replyBuffer); return (zFAILURE); } - } + } } } } @@ -827,7 +826,7 @@ STATUS ChangeSysQuota(utf8_t quota[]) ** Function: ExpandSys ** ** Expands the Pool that SYS volume is on. If needed will create a partition -** +** ** Returns: Status ****************************************************************************/ @@ -860,16 +859,16 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) NINT iBytesRead; // get space for request buffer - requestBuffer = (utf8_t *)malloc(BUFFERSIZE); + requestBuffer = (utf8_t *)malloc(BUFFERSIZE); if (requestBuffer == NULL) - { + { aprintf( LRED, "Error out of memory" ); return(zFAILURE); // if we couldn't get memory abort } // initialize command file - if (InitializeCommandFile(&fileKey, &rootKey) != zOK) - { + if (InitializeCommandFile(&fileKey, &rootKey) != zOK) + { aprintf( LRED, "Error Expanding SYS\n" ); free(requestBuffer); return(zFAILURE); // if we couldn't open command file return failure @@ -894,28 +893,28 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) if ((status = zRead(sysInfoKey, zNILXID, 0, BUFFERSIZE - 1, requestBuffer, &iBytesRead)) != zOK) { aprintf( LRED, "ERROR: zRead = %d\n", status ); - zClose(sysInfoKey); + zClose(sysInfoKey); goto CleanUpFailure; } requestBuffer[iBytesRead] = '\0'; // setup pointers to start and end of buffer - elementInfo.dataStart = requestBuffer; + elementInfo.dataStart = requestBuffer; elementInfo.dataEnd = requestBuffer + iBytesRead; if (XML_GetTagElement(TAG_POOLNAME, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) - { + { memcpy(sysPoolName, elementInfo.dataStart, elementInfo.dataLen); sysPoolName[elementInfo.dataLen] = '\0'; // save poolname for later. } else - { + { // if we can't find pool we must abort. - zClose(sysInfoKey); + zClose(sysInfoKey); aprintf( LRED, "Error Expanding SYS\n" ); goto CleanUpFailure; } - zClose(sysInfoKey); // close VolumeInfo.xml + zClose(sysInfoKey); // close VolumeInfo.xml strcpy(requestBuffer, ""); aprintf( LGREEN, "Gathering partition information.\n" ); @@ -933,17 +932,17 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) goto CleanUpFailure; } // setup pointers to start and end of buffer - startOfData = replyBuffer; + startOfData = replyBuffer; endOfData = startOfData + strlen(replyBuffer); while (1) { if (XML_GetTagElement(TAG_PARTITIONINFO, startOfData, endOfData, &elementInfo) == zOK) - { - // check each partition in the list to find the one with the passed in + { + // check each partition in the list to find the one with the passed in // partitionID // save this spot - savstartOfData = elementInfo.dataStart; + savstartOfData = elementInfo.dataStart; savendOfData = elementInfo.dataEnd; if (XML_GetTagElement(TAG_PARTITIONID, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) @@ -956,7 +955,7 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) // we have a match, now check to see if its OK // restore saved position and get poolName elementInfo.dataStart = savstartOfData; - elementInfo.dataEnd = savendOfData; + elementInfo.dataEnd = savendOfData; if (XML_GetTagElement(TAG_POOLNAME, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) { @@ -969,7 +968,7 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) else { // restore saved position and get partitionType - elementInfo.dataStart = savstartOfData; + elementInfo.dataStart = savstartOfData; elementInfo.dataEnd = savendOfData; if (XML_GetTagElement(TAG_PARTITIONTYPE, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) @@ -999,34 +998,34 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) aprintf( LRED, "Error: Partition not found, ExpandSYS failed\n" ); goto CleanUpReplyFailure; } - startOfData = savendOfData; + startOfData = savendOfData; } // ajust start position so we get the rest of the information we need to create // a partition // restore saved position and get deviceID elementInfo.dataStart = savstartOfData; - elementInfo.dataEnd = savendOfData; - if (XML_GetTagElement(TAG_DEVICEID, elementInfo.dataStart, + elementInfo.dataEnd = savendOfData; + if (XML_GetTagElement(TAG_DEVICEID, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) - { + { memcpy(deviceID, elementInfo.dataStart, elementInfo.dataLen); deviceID[elementInfo.dataLen] = '\0'; // restore saved position // and get startingSector elementInfo.dataStart = savstartOfData; - elementInfo.dataEnd = savendOfData; - if (XML_GetTagElement(TAG_STARTINGSECTOR, elementInfo.dataStart, + elementInfo.dataEnd = savendOfData; + if (XML_GetTagElement(TAG_STARTINGSECTOR, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) - { + { memcpy(startingSector, elementInfo.dataStart, elementInfo.dataLen); startingSector[elementInfo.dataLen] = '\0'; // restore saved position // and get numSectors elementInfo.dataStart = savstartOfData; - elementInfo.dataEnd = savendOfData; - if (XML_GetTagElement(TAG_NUMSECTORS, elementInfo.dataStart, + elementInfo.dataEnd = savendOfData; + if (XML_GetTagElement(TAG_NUMSECTORS, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) - { + { memcpy(numSectors, elementInfo.dataStart, elementInfo.dataLen); numSectors[elementInfo.dataLen] = '\0'; @@ -1038,7 +1037,7 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) // restore saved position // and get logicalPartitionID elementInfo.dataStart = savstartOfData; - elementInfo.dataEnd = savendOfData; + elementInfo.dataEnd = savendOfData; if (XML_GetTagElement(TAG_LOGICALPARTITIONID, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) { @@ -1054,8 +1053,8 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) } } else // create an NSS partition. - { - aprintf( LGREEN, "Creating partition.\n" ); + { + aprintf( LGREEN, "Creating partition.\n" ); strcpy(requestBuffer,""); strcat(requestBuffer,""); strcat(requestBuffer,""); @@ -1077,7 +1076,7 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) if (SYSHotFixSize != 0) { // if they want hotfix then give them mirror too - // hotfix must be at least 100kb + // hotfix must be at least 100kb if (SYSHotFixSize < 100) { SYSHotFixSize = 100; @@ -1097,7 +1096,7 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) strcat(requestBuffer,""); } strcat(requestBuffer,""); - strcat(requestBuffer,""); + strcat(requestBuffer,""); strcat(requestBuffer,""); strcat(requestBuffer,""); strcat(requestBuffer,""); @@ -1117,7 +1116,7 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) // setup pointers to start and end of buffer // and parse reply to see if partition was created or if we got // an error - elementInfo.dataStart = replyBuffer; + elementInfo.dataStart = replyBuffer; elementInfo.dataEnd = replyBuffer + strlen(replyBuffer); if (XML_GetTagElement(TAG_RESULT, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) @@ -1149,7 +1148,7 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) } // partition was created OK and we are now going to expand SYS aprintf( LGREEN, "Partition successfully created. Proceeding to expand pool \"%s\".\n", sysPoolName ); - elementInfo.dataStart = replyBuffer; + elementInfo.dataStart = replyBuffer; elementInfo.dataEnd = replyBuffer + strlen(replyBuffer); if (XML_GetTagElement(TAG_LOGICALPARTITIONID, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) @@ -1197,7 +1196,7 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) } // setup pointers to start and end of buffer // parse reply to see if we got an error. - elementInfo.dataStart = replyBuffer; + elementInfo.dataStart = replyBuffer; elementInfo.dataEnd = replyBuffer + strlen(replyBuffer); if (XML_GetTagElement(TAG_RESULT, elementInfo.dataStart, elementInfo.dataEnd, &elementInfo) == zOK) @@ -1234,7 +1233,7 @@ STATUS ExpandSys(utf8_t passedPartitionID[]) free(requestBuffer); free(replyBuffer); // free buffers - zClose(fileKey); + zClose(fileKey); zClose(rootKey); // Close manage.cmd return zOK; @@ -1242,7 +1241,7 @@ CleanUpReplyFailure: free(replyBuffer); CleanUpFailure: free(requestBuffer); - zClose(fileKey); + zClose(fileKey); zClose(rootKey); // Close manage.cmd return (zFAILURE); } @@ -1268,15 +1267,15 @@ STATUS RenameToSys(utf8_t volumeName[]) Key_t fileKey; // get space for request buffer - requestBuffer = (utf8_t *)malloc(BUFFERSIZE); + requestBuffer = (utf8_t *)malloc(BUFFERSIZE); if (requestBuffer == NULL) - { + { aprintf( LRED, "Error out of memory" ); return(zFAILURE); // if we couldn't get memory abort } // initialize command file - if (InitializeCommandFile(&fileKey, &rootKey) != zOK) - { + if (InitializeCommandFile(&fileKey, &rootKey) != zOK) + { aprintf( LRED, "Error renaming \"%s\".\n", volumeName ); free(requestBuffer); return(zFAILURE); // if we couldn't open command file return failure @@ -1298,7 +1297,7 @@ STATUS RenameToSys(utf8_t volumeName[]) if (WriteBuffer(requestBuffer, fileKey, strlen(requestBuffer)) != zOK) { free(requestBuffer); - zClose(fileKey); + zClose(fileKey); zClose(rootKey); // Close manage.cmd aprintf( LRED, "Error renaming \"%s\".\n", volumeName ); return(zFAILURE); @@ -1307,13 +1306,13 @@ STATUS RenameToSys(utf8_t volumeName[]) if ((replyBuffer = ReadReply(fileKey)) == NULL) { free(requestBuffer); - zClose(fileKey); + zClose(fileKey); zClose(rootKey); // Close manage.cmd aprintf( LRED, "Error renaming \"%s\".\n", volumeName ); return(zFAILURE); } - zClose(fileKey); + zClose(fileKey); zClose(rootKey); // Close manage.cmd startOfData = replyBuffer; @@ -1354,7 +1353,7 @@ STATUS RenameToSys(utf8_t volumeName[]) free(replyBuffer); // free buffers return (zFAILURE); } - } + } } } } @@ -1367,9 +1366,9 @@ STATUS RenameToSys(utf8_t volumeName[]) /**************************************************************************** ** Function: WriteBuffer ** -** Write contents of the buffer pointed to by requestBuffer to the file who's +** Write contents of the buffer pointed to by requestBuffer to the file who's ** Key is fileKey -** Returns: STATUS +** Returns: STATUS ****************************************************************************/ STATUS WriteBuffer(utf8_t *requestBuffer, Key_t fileKey, NINT size) @@ -1388,7 +1387,7 @@ STATUS WriteBuffer(utf8_t *requestBuffer, Key_t fileKey, NINT size) /**************************************************************************** ** Function: ReadReply ** -** Read into a buffer pointed to by replyBuffer the contents of the command +** Read into a buffer pointed to by replyBuffer the contents of the command ** file ** Returns: utf8_t pointer to the buffer which contains the file ** or NULL if error @@ -1438,7 +1437,7 @@ utf8_t * ReadReply(Key_t fileKey) aprintf( LRED, "Error allocating memory.\n" ); free (replyBuffer); return(NULL); - } + } replyBuffer = rPtr; } } @@ -1447,9 +1446,9 @@ utf8_t * ReadReply(Key_t fileKey) /**************************************************************************** ** Function: InitializeCommandFile ** -** Opens _ADMIN:\\Manage_NSS\\manage.cmd and writes initialize command -** -** Returns: STATUS +** Opens _ADMIN:\\Manage_NSS\\manage.cmd and writes initialize command +** +** Returns: STATUS ****************************************************************************/ STATUS InitializeCommandFile(Key_t *fileKey, Key_t *rootKey) @@ -1465,7 +1464,7 @@ STATUS InitializeCommandFile(Key_t *fileKey, Key_t *rootKey) aprintf( LRED, "ERROR: Getting zRootKey = %d\n", status ); return(zFAILURE); } - + /* Open _admin:\Manage_NSS\Manage.cmd */ if((status = zOpen( *rootKey, /* Root Key */ @@ -1493,3 +1492,4 @@ STATUS InitializeCommandFile(Key_t *fileKey, Key_t *rootKey) return zOK; } + diff --git a/src/nwnss/comn/common/comnAudit.c b/src/nwnss/comn/common/comnAudit.c index 370f5b6..7e1998e 100644 --- a/src/nwnss/comn/common/comnAudit.c +++ b/src/nwnss/comn/common/comnAudit.c @@ -35,11 +35,7 @@ | Audit Events +-------------------------------------------------------------------------*/ -#if !defined(NSS_USERSPACE) #include -#else -#include -#endif #include #include @@ -86,15 +82,15 @@ void NSSLAF_LogTrusteeChange( if (status == zOK) { /* Returned name is unicode - need utf8 */ - uni2utf(aStack->uniName, aStack->fdnName, + uni2utf(aStack->uniName, aStack->fdnName, sizeof(aStack->fdnName)); } else { - printk("<4>NSS: Audit: Trustee Mode %d: Error %d for guid\n", + printk("<4>NSS: Audit: Trustee Mode %d: Error %d for guid\n", mode, status); - LB_GUIDToString(trusteeID, zMAX_COMPONENT_NAME, - aStack->fdnName); + LB_GUIDToString(trusteeID, zMAX_COMPONENT_NAME, + aStack->fdnName); } break; } @@ -102,8 +98,8 @@ void NSSLAF_LogTrusteeChange( default: break; } - status = COMN_GetNameFromBeast(genMsg, nameMsg->curvol, - nameMsg->nameSpaceID, zMAX_COMPONENT_NAME, + status = COMN_GetNameFromBeast(genMsg, nameMsg->curvol, + nameMsg->nameSpaceID, zMAX_COMPONENT_NAME, aStack->uniName, NULL); if (status == zOK) { @@ -112,16 +108,16 @@ void NSSLAF_LogTrusteeChange( } else { - printk("<4>NSS: Audit: Trustee Mode %d: Error %d for vol name\n", + printk("<4>NSS: Audit: Trustee Mode %d: Error %d for vol name\n", mode, GetErrno(genMsg)); ClearErrno(genMsg); - LB_GUIDToString(&nameMsg->curvol->VOLvolumeID, - zMAX_COMPONENT_NAME, aStack->volName); + LB_GUIDToString(&nameMsg->curvol->VOLvolumeID, + zMAX_COMPONENT_NAME, aStack->volName); } if ((getNameBuf = COMN_GetPathNameWorkBuffer(genMsg)) == NULL) { - printk("<4> NSS: Audit: Trustee Mode %d: Error %d for work buffer\n", + printk("<4> NSS: Audit: Trustee Mode %d: Error %d for work buffer\n", mode, GetErrno(genMsg)); ClearErrno(genMsg); snprintf(localName, sizeof(localName), "zid:0x%llx", nameMsg->curFile->FILEzid); @@ -136,7 +132,7 @@ void NSSLAF_LogTrusteeChange( if (COMN_GetName(genMsg,nameMsg,&gfnMsg) != zOK) { - printk("<4> NSS: Audit: Trustee Mode %d: Error %d for get name\n", + printk("<4> NSS: Audit: Trustee Mode %d: Error %d for get name\n", mode, GetErrno(genMsg)); ClearErrno(genMsg); snprintf(localName, sizeof(localName), "zid:0x%llx", nameMsg->curFile->FILEzid); @@ -148,33 +144,33 @@ void NSSLAF_LogTrusteeChange( } auditLog: -#if !defined(NSS_USERSPACE) && defined(LINUX_VERSION_CODE) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,6)) MPKNSS_UNLOCK(); switch (mode) { case NSSLAF_MODE_ADD_TRUSTEE: { - audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL_OTHER, + audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL_OTHER, "NSS: AddTrustee: fsuid=%ld,vol=%s,path=%s,trustee=%s," - "rights=0x%lx,attributes=0x%lx\n", - genMsg->pssConn.id, aStack->volName, filePathName, + "rights=0x%lx,attributes=0x%lx\n", + genMsg->pssConn.id, aStack->volName, filePathName, aStack->fdnName, rights, attributes); break; } case NSSLAF_MODE_REMOVE_TRUSTEE: { - audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL_OTHER, + audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL_OTHER, "NSS: RemoveTrustee: fsuid=%ld,vol=%s,path=%s,trustee=%s\n", - genMsg->pssConn.id, aStack->volName, filePathName, + genMsg->pssConn.id, aStack->volName, filePathName, aStack->fdnName); break; } case NSSLAF_MODE_SET_INHERITED_RIGHTS: { - audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL_OTHER, + audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL_OTHER, "NSS: SetInheritedRightsMask: fsuid=%ld,vol=%s,path=%s," - "inheritedRightsMask=0x%lx\n", - genMsg->pssConn.id, aStack->volName, filePathName, + "inheritedRightsMask=0x%lx\n", + genMsg->pssConn.id, aStack->volName, filePathName, inheritedRights); break; } diff --git a/src/nwnss/comn/common/comnDSI.c b/src/nwnss/comn/common/comnDSI.c new file mode 100644 index 0000000..d867ffe --- /dev/null +++ b/src/nwnss/comn/common/comnDSI.c @@ -0,0 +1,1001 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996-1998 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_DSI + +#include + +#include +#include /* NSS Library */ +#include +#include +#include +#include + +#include "zParams.h" +#include "comnPublics.h" +#include "volume.h" +#include "pssStartup.h" +#include "comnAuthorize.h" + + +/*************************************************************************** + * + * Create/Delete/Rename volume objects in NDS using DSI NLM + * + * Steps: + * Check to see if DS is installed and active. If not return an error. + * Check to see if DSI is loaded. If not load it. + * Import the required DSI functions + * + * Get the ndsObjectID field from the PersistentVolume_s structure. + * Create/Delete/Rename the volume object by calling the appropriate + * DSI function. + * Modify the ndsOBjectID field in the PersistentVolume_s structure. + * + * Unimport the DSI functions + * Unload DSI if we loaded it. + * + **************************************************************************/ + +#define NSSVOL_MAXNAME 256 + +#define ADD_TO_NDS_RETRY_COUNT 100 +#define ADD_TO_NDS_RETRY_COUNT2 10 + +#define NDS_PASSWORD_LENGTH 63 +#define NDS_LOGINNAME_LENGTH 256 + +#define DSINameBaseExistsAPI MSGNot("\x11" "DSINameBaseExists") +#define DSILoginAPI MSGNot("\x8" "DSILogin") +#define DSIGetVolumeIDsAPI MSGNot("\xf" "DSIGetVolumeIDs") +#define DSIRemoveVolumeObjectAPI MSGNot("\x15" "DSIRemoveVolumeObject") +#define DSIRenameVolumeObjectAPI MSGNot("\x15" "DSIRenameVolumeObject") +#define DSIInstallCleanupAPI MSGNot("\x11" "DSIInstallCleanup") +#define DSIRegInstallMasterAPI MSGNot("\x18" "DSIRegisterInstallMaster") +#define DSIUnRegInstallMasterAPI MSGNot("\x1a" "DSIUnRegisterInstallMaster") + +int (*DSINameBaseExistsPtr)(int *exists) = NULL; +int (*DSILoginPtr)(BYTE *localDN, BYTE *password) = NULL; +int (*DSIGetVolumeIDsPtr)(BYTE *volName, LONG *id, LONG *contID) = NULL; +int (*DSIRemoveVolumeObjectPtr)(LONG id) = NULL; +int (*DSIRenameVolumeObjectPtr)(LONG id, BYTE *newVolumeName) = NULL; +void (*DSIInstallCleanupPtr)(void) = NULL; +int (*DSIRegInstallMasterPtr)(BYTE **functionNames) = NULL; +int (*DSIUnRegInstallMasterPtr)(BYTE **functionNames) = NULL; + + +NINT ILoadedDSI = FALSE; +NINT DSIAlreadySetup = 0; +NINT DSISetupComplete = 0; +NINT DSICleanupInProgress = 0; +NINT DSIErrno = zOK; + +BYTE *DSIRegisterFunctions[] = +{ + "\x11" "NSSDummy_DSIAlert", + "\x17" "NSSDummy_DSIInformation", + "\x15" "NSSDummy_DSIStartWait", + "\x13" "NSSDummy_DSIEndWait", + "\x15" "NSSDummy_InstallAlloc", + "\x14" "NSSDummy_InstallFree", + "\x15" "NSSDummy_InstallTrace", + "\x1d" "NSSDummy_InstallCheckForAbort", + "\x22" "NSSDummy_InstallResolveDSConflicts", + "\x24" "NSSDummy_InstallReturnFileServerName", + "\x22" "NSSDummy_StartObjectUpgradeDisplay", + "\x1c" "NSSDummy_ObjectUpgradeStatus", + "\x20" "NSSDummy_EndObjectUpgradeDisplay", +}; + +typedef struct AddToNDSFsm_s { + FsmLite_s fsm; + NINT updateAction; + unicode_t volNameExisting[NSSVOL_MAXNAME]; + BOOL volNameExistingIsNull; + unicode_t volNameNew[NSSVOL_MAXNAME]; + BOOL volNameNewIsNull; + UserID_t ndsObjectID; + BOOL ndsObjectIDIsNull; + NINT count; + BYTE loginName[NDS_LOGINNAME_LENGTH + 1]; + BOOL loginNameIsNull; + BYTE password[NDS_PASSWORD_LENGTH + 1]; + BOOL passwordIsNull; +} AddToNDSFsm_s; + +STATUS ImportDSIFunctionPtrs(GeneralMsg_s *genMsg) +{ + ASSERT_MPKNSS_LOCK(); + +#ifndef __linux__ // LINUX_DSI LINUX_ServerVersion + /* This allows the 6 pack code to run on Cobra */ + if ((COMN_Resource.serverMajorVersion == 5) && + (COMN_Resource.serverMinorVersion < 60)) + { + SetErrno(genMsg, zERR_IMPORT_DSI_SYMBOL_FAILED); + return zFAILURE; + } +#endif + + if (DSINameBaseExistsPtr == NULL) + { + ZOS_ImportPublicSymbol(DSINameBaseExistsPtr, + (LONG)CMN_ModuleHandle, (BYTE *)DSINameBaseExistsAPI); + if (DSINameBaseExistsPtr == NULL) + { + goto returnError; + } + } + + if (DSILoginPtr == NULL) + { + ZOS_ImportPublicSymbol(DSILoginPtr, + (LONG)CMN_ModuleHandle, (BYTE *)DSILoginAPI); + if (DSILoginPtr == NULL) + { + goto returnError; + } + } + + if (DSIGetVolumeIDsPtr == NULL) + { + ZOS_ImportPublicSymbol(DSIGetVolumeIDsPtr, + (LONG)CMN_ModuleHandle, (BYTE *)DSIGetVolumeIDsAPI); + if (DSIGetVolumeIDsPtr == NULL) + { + goto returnError; + } + } + + if (DSIRemoveVolumeObjectPtr == NULL) + { + ZOS_ImportPublicSymbol(DSIRemoveVolumeObjectPtr, + (LONG)CMN_ModuleHandle, (BYTE *)DSIRemoveVolumeObjectAPI); + if (DSIRemoveVolumeObjectPtr == NULL) + { + goto returnError; + } + } + + if (DSIRenameVolumeObjectPtr == NULL) + { + ZOS_ImportPublicSymbol(DSIRenameVolumeObjectPtr, + (LONG)CMN_ModuleHandle, (BYTE *)DSIRenameVolumeObjectAPI); + if (DSIRenameVolumeObjectPtr == NULL) + { + goto returnError; + } + } + + if (DSIInstallCleanupPtr == NULL) + { + ZOS_ImportPublicSymbol(DSIInstallCleanupPtr, + (LONG)CMN_ModuleHandle, (BYTE *)DSIInstallCleanupAPI); + if (DSIInstallCleanupPtr == NULL) + { + goto returnError; + } + } + + if (DSIRegInstallMasterPtr == NULL) + { + ZOS_ImportPublicSymbol(DSIRegInstallMasterPtr, + (LONG)CMN_ModuleHandle, (BYTE *)DSIRegInstallMasterAPI); + if (DSIRegInstallMasterPtr == NULL) + { + goto returnError; + } + } + + if (DSIUnRegInstallMasterPtr == NULL) + { + ZOS_ImportPublicSymbol(DSIUnRegInstallMasterPtr, + (LONG)CMN_ModuleHandle, (BYTE *)DSIUnRegInstallMasterAPI); + if (DSIUnRegInstallMasterPtr == NULL) + { + goto returnError; + } + } + return zOK; + +returnError: + SetErrno(genMsg, zERR_IMPORT_DSI_SYMBOL_FAILED); + return zFAILURE; +} + +void UnimportDSIFunctionPtrs(void) +{ + ASSERT_MPKNSS_LOCK(); + + if (DSINameBaseExistsPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)CMN_ModuleHandle, DSINameBaseExistsAPI); + DSINameBaseExistsPtr = NULL; + } + + if (DSILoginPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)CMN_ModuleHandle, DSILoginAPI); + DSILoginPtr = NULL; + } + + if (DSIGetVolumeIDsPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)CMN_ModuleHandle, DSIGetVolumeIDsAPI); + DSIGetVolumeIDsPtr = NULL; + } + + if (DSIRemoveVolumeObjectPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)CMN_ModuleHandle, DSIRemoveVolumeObjectAPI); + DSIRemoveVolumeObjectPtr = NULL; + } + + if (DSIRenameVolumeObjectPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)CMN_ModuleHandle, DSIRenameVolumeObjectAPI); + DSIRenameVolumeObjectPtr = NULL; + } + + if (DSIInstallCleanupPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)CMN_ModuleHandle, DSIInstallCleanupAPI); + DSIInstallCleanupPtr = NULL; + } + + if (DSIRegInstallMasterPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)CMN_ModuleHandle, DSIRegInstallMasterAPI); + DSIRegInstallMasterPtr = NULL; + } + + if (DSIUnRegInstallMasterPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)CMN_ModuleHandle, DSIUnRegInstallMasterAPI); + DSIUnRegInstallMasterPtr = NULL; + } +} + + +STATUS SetupToCallDSI(GeneralMsg_s *genMsg) +{ + int exists = FALSE; + int ccode; + + ASSERT_MPKNSS_LOCK(); + + if (ZOS_IsNLMLoaded(MSGNot("\x6" "DS.NLM")) == 0) + { + SetErrno(genMsg, zERR_DS_NOT_SETUP); + return zFAILURE; + } + + if (ZOS_IsNLMLoaded(MSGNot("\x7" "DSI.NLM")) == 0) + { + ZOS_LoadModule(ccode, CMN_DefaultScreen, "DSI.NLM", LO_LOAD_SILENT); + if (ccode != 0) + { + SetErrno(genMsg, zERR_DSI_LOAD_FAILED); + return zFAILURE; + } + else + { + ILoadedDSI = TRUE; + } + } + + if (ImportDSIFunctionPtrs(genMsg) != zOK) + { + return zFAILURE; + } + + MPKNSS_UNLOCK(); + ccode = DSIRegInstallMasterPtr(DSIRegisterFunctions); + MPKNSS_LOCK(); + if (ccode != 0) + { + if (ccode == -2) + { + //FixFixFix6 : Do something to trigger this later. + SetErrno(genMsg, zERR_DSIREG_RET2); + UnimportDSIFunctionPtrs(); + return zFAILURE; + } + SetErrno(genMsg, zERR_DSIREG_FAILED); + return zFAILURE; + } + + MPKNSS_UNLOCK(); + ccode = DSINameBaseExistsPtr(&exists); + MPKNSS_LOCK(); + if ((ccode != 0) || (exists == FALSE)) + { + SetErrno(genMsg, zERR_DS_NOT_SETUP); + return zFAILURE; + } + + return zOK; +} + +void COMN_CleanupCallToDSI(void) +{ + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + DSIAlreadySetup--; + + if (DSIAlreadySetup > 0) + { + return; + } + + DSISetupComplete = 0; + DSIErrno = zOK; + + DSICleanupInProgress = 1; + if (DSIInstallCleanupPtr) + { + MPKNSS_UNLOCK(); + DSIInstallCleanupPtr(); + MPKNSS_LOCK(); + } + + if (DSIUnRegInstallMasterPtr) + { + MPKNSS_UNLOCK(); + DSIUnRegInstallMasterPtr(DSIRegisterFunctions); + MPKNSS_LOCK(); + } + + UnimportDSIFunctionPtrs(); + if (ILoadedDSI == TRUE) + { + ZOS_UnloadModule(status, CMN_DefaultScreen, "DSI.NLM"); + ILoadedDSI = FALSE; + } + + DSICleanupInProgress = 0; + return; +} + +STATUS COMN_SetupDSIAndLogin(BYTE *LoginObject, BYTE *LoginPassword) +{ + GeneralMsg_s genMsg; + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + DSIAlreadySetup++; + + if (DSIAlreadySetup > 1) + { + while (DSISetupComplete == 0) + { + LB_delay(1); + } + if (DSISetupComplete == 1) + { + return zOK; + } + else if (DSISetupComplete == 2) + { + /* Another attempt was made at the same time as this one and it + * failed. Since this one is waiting treat it as if it had the + * same error. */ + SetErrno(&genMsg, DSIErrno); + goto cleanupAndReturn; + } + } + + while (DSICleanupInProgress == 1) + { + LB_delay(1); + } + + if (SetupToCallDSI(&genMsg) != zOK) + { + goto cleanupAndReturn; + } + + MPKNSS_UNLOCK(); + status = DSILoginPtr(LoginObject, LoginPassword); + MPKNSS_LOCK(); + + if (status != 0) + { + SetErrno(&genMsg, zERR_DSI_LOGIN_FAILED); + goto cleanupAndReturn; + } + DSIErrno = zOK; + DSISetupComplete = 1; + return zOK; + +cleanupAndReturn: + DSIErrno = GetErrno(&genMsg); + DSISetupComplete = 2; + COMN_CleanupCallToDSI(); + return GetErrno(&genMsg); +} + + +/** This call assumes DSI has been set up logged into etc. + ** Do not change the definition of this API without notifying the install + ** team. They use it. + **/ +STATUS zUpdateVolumeObjectInNDS( + NINT updateAction, + unicode_t *volNameExisting, + unicode_t *volNameNew, + UserID_t *ndsObjectID) +{ + GeneralMsg_s genMsg; + STATUS status; + LONG objectId, containerId; + ModifyInfoMsg_s modInfoMsg; + zVolumeInfo_s volInfo; + Volume_s *volume = NULL; + char vname[NSSVOL_MAXNAME]; + NINT vnameLen; + UserID_t localNDSObjID; + BOOL unImportFlag = FALSE; + NINT loopCnt; + + MPKNSS_LOCK(); + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + switch (updateAction) + { + case CREATE_VOLUME_OBJECT: + + LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, &vname[1], + NSSVOL_MAXNAME, volNameNew, &vnameLen); + + vname[0] = vnameLen; + + if (DSIGetVolumeIDsPtr == NULL) + { + ZOS_ImportPublicSymbol(DSIGetVolumeIDsPtr, + (LONG)CMN_ModuleHandle, (BYTE *)DSIGetVolumeIDsAPI); + if (DSIGetVolumeIDsPtr == NULL) + { + SetErrno(&genMsg, zERR_IMPORT_DSI_SYMBOL_FAILED); + break; + } + unImportFlag = TRUE; + } + + MPKNSS_UNLOCK(); + /* Sometimes it takes multiple attempts to get a volume added to DS + * so, try a few times + */ + loopCnt = ADD_TO_NDS_RETRY_COUNT2; + do + { + status = DSIGetVolumeIDsPtr(vname, &objectId, &containerId); + }while ((status != 0) && (--loopCnt)); + + MPKNSS_LOCK(); + + if (unImportFlag) + { + ZOS_UnImportPublicSymbol( + (LONG)CMN_ModuleHandle, DSIGetVolumeIDsAPI); + DSIGetVolumeIDsPtr = NULL; + unImportFlag = FALSE; + } + if (status != 0) + { + SetErrno(&genMsg, zERR_ADD_TO_NDS_FAILED); + break; + } + + uniupr(volNameNew); + volume = COMN_VolumeNameLookup(&genMsg, volNameNew, FALSE, NULL); + if (volume == NULL) + { + ForceSetErrno(&genMsg, zERR_VOL_UNAVAILABLE); + break; + } + + COMN_MapNDSIDToGUID(&status, objectId, &volInfo.ndsObjectID); + + if (ndsObjectID) + { + *ndsObjectID = volInfo.ndsObjectID; + } + + COMN_STRUCT_INIT(modInfoMsg); + COMN_SETUP_MODIFY_TYPE_INFO_MSG(&modInfoMsg, 0, NULL, + zMOD_VOL_NDS_OBJECT_ID, &volInfo); + + modInfoMsg.parentZid = volume->VOLfirstParentZid; + + X_LATCH(&volume->VOLbeastLatch); + status = volume->VOLcomnBeastOps.BST_modifyInfo(&genMsg, &volume->VOLroot, + &modInfoMsg, NULL); + UNX_LATCH(&volume->VOLbeastLatch); + COMN_Release(&volume); + + break; + + case GET_VOLUME_OBJECT_ID: + uniupr(volNameExisting); + volume = COMN_VolumeNameLookup(&genMsg, volNameExisting, FALSE, NULL); + if (volume == NULL) + { + ForceSetErrno(&genMsg, zERR_VOL_UNAVAILABLE); + *ndsObjectID = zINVALID_USERID; + break; + } + + S_LATCH(&volume->VOLbeastLatch); + *ndsObjectID = volume->VOLndsObjectID; + UNS_LATCH(&volume->VOLbeastLatch); + + COMN_Release(&volume); + break; + + case DELETE_VOLUME_OBJECT: + if (ndsObjectID != NULL) + { + localNDSObjID = *ndsObjectID; + } + else if (volNameExisting != NULL) + { + uniupr(volNameExisting); + volume = COMN_VolumeNameLookup(&genMsg,volNameExisting,FALSE,NULL); + if (volume == NULL) + { + ForceSetErrno(&genMsg, zERR_VOL_UNAVAILABLE); + break; + } + + S_LATCH(&volume->VOLbeastLatch); + localNDSObjID = volume->VOLndsObjectID; + UNS_LATCH(&volume->VOLbeastLatch); + + COMN_Release(&volume); + } + else + { + SetErrno(&genMsg, zERR_INVALID_STATE); + break; + } + + COMN_MapNDSGUIDToID(&status, volume, &localNDSObjID, &objectId); + + if (DSIRemoveVolumeObjectPtr == NULL) + { + ZOS_ImportPublicSymbol(DSIRemoveVolumeObjectPtr, + (LONG)CMN_ModuleHandle, (BYTE *)DSIRemoveVolumeObjectAPI); + if (DSIRemoveVolumeObjectPtr == NULL) + { + SetErrno(&genMsg, zERR_IMPORT_DSI_SYMBOL_FAILED); + break; + } + unImportFlag = TRUE; + } + + MPKNSS_UNLOCK(); + loopCnt = ADD_TO_NDS_RETRY_COUNT2; + do + { + status = DSIRemoveVolumeObjectPtr(objectId); + }while ((status != 0) && (--loopCnt)); + + MPKNSS_LOCK(); + + if (unImportFlag) + { + ZOS_UnImportPublicSymbol( + (LONG)CMN_ModuleHandle, DSIRemoveVolumeObjectAPI); + DSIRemoveVolumeObjectPtr = NULL; + unImportFlag = FALSE; + } + + if (status != 0) + { + SetErrno(&genMsg, zERR_DEL_TO_NDS_FAILED); + break; + } + + break; + + case RENAME_VOLUME_OBJECT: + if (ndsObjectID != NULL) + { + localNDSObjID = *ndsObjectID; + } + else if (volNameExisting != NULL) + { + uniupr(volNameExisting); + volume = COMN_VolumeNameLookup(&genMsg,volNameExisting,FALSE,NULL); + if (volume == NULL) + { + uniupr(volNameNew); + volume = COMN_VolumeNameLookup(&genMsg,volNameNew,FALSE,NULL); + + if (volume == NULL) + { + ForceSetErrno(&genMsg, zERR_VOL_UNAVAILABLE); + break; + } + } + + S_LATCH(&volume->VOLbeastLatch); + localNDSObjID = volume->VOLndsObjectID; + UNS_LATCH(&volume->VOLbeastLatch); + + COMN_Release(&volume); + } + else + { + SetErrno(&genMsg, zERR_INVALID_STATE); + break; + } + + COMN_MapNDSGUIDToID(&status, volume, &localNDSObjID, &objectId); + + LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, &vname[1], + NSSVOL_MAXNAME, volNameNew, &vnameLen); + + vname[0] = vnameLen; + + if (DSIRenameVolumeObjectPtr == NULL) + { + ZOS_ImportPublicSymbol(DSIRenameVolumeObjectPtr, + (LONG)CMN_ModuleHandle, (BYTE *)DSIRenameVolumeObjectAPI); + if (DSIRenameVolumeObjectPtr == NULL) + { + SetErrno(&genMsg, zERR_IMPORT_DSI_SYMBOL_FAILED); + break; + } + unImportFlag = TRUE; + } + + MPKNSS_UNLOCK(); + loopCnt = ADD_TO_NDS_RETRY_COUNT2; + do + { + status = DSIRenameVolumeObjectPtr(objectId, vname); + }while ((status != 0) && (--loopCnt)); + + MPKNSS_LOCK(); + + if (unImportFlag) + { + ZOS_UnImportPublicSymbol( + (LONG)CMN_ModuleHandle, DSIRenameVolumeObjectAPI); + DSIRenameVolumeObjectPtr = NULL; + unImportFlag = FALSE; + } + + if (status != 0) + { + SetErrno(&genMsg, zERR_REN_TO_NDS_FAILED); + break; + } + + break; + + default: + SetErrno(&genMsg, zERR_INVALID_STATE); + break; + } + status = GetErrno(&genMsg); + MPKNSS_UNLOCK(); + return status; +} + + + +void SetupDSIAndUpdateInNDS ( + FsmLite_s *fsm) +{ + AddToNDSFsm_s *fsmWork = (AddToNDSFsm_s *)fsm; + STATUS status; + + if ((status = COMN_SetupDSIAndLogin( + fsmWork->loginNameIsNull ? NULL : fsmWork->loginName, + fsmWork->passwordIsNull ? NULL : fsmWork->password )) != zOK) + { + goto delayAndReschedule; + } + + ZOS_zUpdateVolumeObjectInNDS(status, + fsmWork->updateAction, + (fsmWork->volNameExistingIsNull ? NULL : fsmWork->volNameExisting), + (fsmWork->volNameNewIsNull ? NULL : fsmWork->volNameNew), + (fsmWork->ndsObjectIDIsNull ? NULL : &fsmWork->ndsObjectID)); + + COMN_CleanupCallToDSI(); + + if (status != zOK) + { + goto delayAndReschedule; + } + else + { + switch (fsmWork->updateAction) + { + case CREATE_VOLUME_OBJECT: + if (!fsmWork->volNameNewIsNull) + { + aprintf(LGREEN, MSG("Added volume %U to the NDS tree\n", + 161), fsmWork->volNameNew); + } + break; + case DELETE_VOLUME_OBJECT: + if (!fsmWork->volNameExistingIsNull) + { + aprintf(LGREEN, MSG("Removed volume %U from the NDS tree\n", + 162), fsmWork->volNameExisting); + } + break; + case RENAME_VOLUME_OBJECT: + if (!fsmWork->volNameExistingIsNull && !fsmWork->volNameNewIsNull) + { + aprintf(LGREEN, MSG("Renamed volume %U to %U in the NDS tree\n", + 163), fsmWork->volNameExisting, fsmWork->volNameNew); + } + break; + default: + break; + } + } + +cleanupAndRet: + free(fsmWork); + return; + +delayAndReschedule: + switch (status) + { + case zOK: + goto cleanupAndRet; + break; + + case zERR_DSIREG_RET2: + case zERR_DS_NOT_SETUP: + if (!CMN_Shutdown && (fsmWork->count++ <= ADD_TO_NDS_RETRY_COUNT)) + { + /** Delay 5 seconds **/ + LB_delay(5000); + if (!CMN_Shutdown) + { + WORK_Schedule(&fsmWork->fsm, SetupDSIAndUpdateInNDS, 0); + break; + } + } + goto cleanupAndRet; + break; + + case zERR_DSI_LOAD_FAILED: + case zERR_DSI_LOGIN_FAILED: + case zERR_ADD_TO_NDS_FAILED: + case zERR_DEL_TO_NDS_FAILED: + case zERR_REN_TO_NDS_FAILED: + if (!CMN_Shutdown && (fsmWork->count++ <= ADD_TO_NDS_RETRY_COUNT2)) + { + /** Delay 5 seconds **/ + LB_delay(5000); + if (!CMN_Shutdown) + { + WORK_Schedule(&fsmWork->fsm, SetupDSIAndUpdateInNDS, 0); + break; + } + } + goto cleanupAndRet; + break; + + + case zERR_INVALID_STATE: + case zERR_IMPORT_DSI_SYMBOL_FAILED: + case zERR_DSIREG_FAILED: + case zERR_VOL_UNAVAILABLE: + default: + goto cleanupAndRet; + break; + } + return; +} + + +STATUS COMN_AsyncSetupDSIAndUpdateInNDS( + NINT updateAction, + unicode_t *volNameExisting, + unicode_t *volNameNew, + UserID_t *ndsObjectID, + BYTE *ndsLogin, + BYTE *ndsPassword) +{ + AddToNDSFsm_s *fsmWork; + + fsmWork = zalloc(sizeof(AddToNDSFsm_s)); + if (fsmWork == NULL) + { + return zERR_NO_MEMORY; + } + + FSMLITE_INIT(&fsmWork->fsm, MSGNot("FSM to add volumes to NDS"), 0); + fsmWork->updateAction = updateAction; + if (volNameExisting) + { + unincpy(fsmWork->volNameExisting, volNameExisting, NSSVOL_MAXNAME); + } + else + { + fsmWork->volNameExistingIsNull = TRUE; + } + if (volNameNew) + { + unincpy(fsmWork->volNameNew, volNameNew, NSSVOL_MAXNAME); + } + else + { + fsmWork->volNameNewIsNull = TRUE; + } + if (ndsObjectID) + { + fsmWork->ndsObjectID = *ndsObjectID; + } + else + { + fsmWork->ndsObjectIDIsNull = TRUE; + } + fsmWork->count = 0; + if (ndsLogin) + { + strncpy(fsmWork->loginName, ndsLogin, NDS_LOGINNAME_LENGTH + 1); + } + else + { + fsmWork->loginNameIsNull = TRUE; + } + if (ndsPassword) + { + strncpy(fsmWork->password, ndsPassword, NDS_PASSWORD_LENGTH + 1); + } + else + { + fsmWork->passwordIsNull = TRUE; + } + + WORK_Schedule(&fsmWork->fsm, SetupDSIAndUpdateInNDS, 0); + + return zOK; +} + +/**** These are just dummies required for now ***/ + +void NSSDummy_StartObjectUpgradeDisplay(unsigned char *header, + unsigned long numberOfBinderyObjects, int displayLogPortal) +{ + header = header; + numberOfBinderyObjects = numberOfBinderyObjects; + displayLogPortal = displayLogPortal; + return; +} + +void NSSDummy_ObjectUpgradeStatus(unsigned char *objectStatus) +{ + objectStatus = objectStatus; + return; +} + +void NSSDummy_EndObjectUpgradeDisplay(void) +{ + return; +} + +void NSSDummy_DSIAlert(LONG msg, ...) +{ + msg = msg; + return; +} + +void NSSDummy_DSIInformation(LONG msg, ...) +{ + msg = msg; + return; +} + +int NSSDummy_DSIEndWait(void) +{ + return 0; +} + +int NSSDummy_DSIStartWait(LONG messageNumber) +{ + messageNumber = messageNumber; + return 0; +} + +char *NSSDummy_InstallReturnFileServerName(void) +{ + static char serverName[128]; + + ReturnFileServerName(serverName); + return serverName; +} + +void *NSSDummy_InstallAlloc(LONG numberOfBytes) +{ + void *ptr; + MPKNSS_LOCK(); + ptr = malloc(numberOfBytes); + MPKNSS_UNLOCK(); + return ptr; +} + +void NSSDummy_InstallFree(void *ptr) +{ + MPKNSS_LOCK(); + free(ptr); + MPKNSS_UNLOCK(); +} + +void NSSDummy_InstallCheckForAbort(void) +{ + return; +} + +void NSSDummy_InstallTrace(BYTE *txt, ...) +{ + txt = txt; +} + +int NSSDummy_InstallResolveDSConflicts(LONG numConflicts) +{ + numConflicts = numConflicts; + return 0; +} + +#endif //__linux__ // LINUX_DSI + diff --git a/src/nwnss/comn/common/comnDataStream.c b/src/nwnss/comn/common/comnDataStream.c index c96df87..e057144 100644 --- a/src/nwnss/comn/common/comnDataStream.c +++ b/src/nwnss/comn/common/comnDataStream.c @@ -33,7 +33,7 @@ |--------------------------------------------------------------------------- | This module is used to: | This contains the top level internal file interfaces. All external - | interfaces call these routines. + | interfaces call these routines. +-------------------------------------------------------------------------*/ #include @@ -85,7 +85,7 @@ STATUS COMN_InitDataStreamInfo( (file->FILEdataStreamInfo->dataStream.count != DSI_COUNT_INVALID)) { STACK_FREE(); - return(zOK); + return(zOK); } nameSpaceID = zNSPACE_DATA_STREAM; break; @@ -95,7 +95,7 @@ STATUS COMN_InitDataStreamInfo( (file->FILEdataStreamInfo->extAttr.count != DSI_COUNT_INVALID)) { STACK_FREE(); - return(zOK); + return(zOK); } nameSpaceID = zNSPACE_EXTENDED_ATTRIBUTE; break; @@ -257,7 +257,7 @@ STATUS COMN_InitDataStreamInfo( (dsInfo->extAttr.count != DSI_COUNT_INVALID))); STACK_FREE(); return(zOK); - + /*===========================================================================*/ cleanup_searchMap: COMN_WildClose(genMsg,&searchMsg); @@ -369,7 +369,7 @@ STATUS COMN_GetDataStreamUsedSpace( * the next dataStream to be counted. Both pointers are XLATCHED * and have useCounts. */ - if (COMN_GetStorageInfo(genMsg, aStack->nameMsg.curDataStream, + if (COMN_GetStorageInfo(genMsg, aStack->nameMsg.curDataStream, &getStorageInfo) != zOK) { goto cleanup_searchMap; @@ -379,7 +379,7 @@ STATUS COMN_GetDataStreamUsedSpace( /* call back with size and user info if needed */ if (adjustUsedSpace) { - VOL_AdjustUsedUserSpace(xaction, + VOL_AdjustUsedUserSpace(xaction, &aStack->nameMsg.curDataStream->NAMEDroot, -getStorageInfo.filePhysSize); } @@ -412,7 +412,7 @@ STATUS COMN_GetDataStreamUsedSpace( *returnSize = size; STACK_FREE(); return(zOK); - + /*===========================================================================*/ cleanup_searchMap: COMN_WildClose(genMsg,&searchMsg); diff --git a/src/nwnss/comn/common/comnEFL.c b/src/nwnss/comn/common/comnEFL.c index 7c17816..ada77ad 100644 --- a/src/nwnss/comn/common/comnEFL.c +++ b/src/nwnss/comn/common/comnEFL.c @@ -55,7 +55,7 @@ typedef struct EFLCheckerControl_s { BOOL checkerStarted; - BOOL inProgress; + BOOL inProgress; OneShot_s alarm; /* Alarm for periodic background epoch checker */ FsmLite_s fsm; /* thread on which backgroung checker happens */ }EFLCheckerControl_s; @@ -84,7 +84,7 @@ NINT secondsToTimeOfDay(NINT targetTimeOfDay) { waitSecs += 24 * 60 * 60; } - + return waitSecs; } @@ -93,20 +93,20 @@ NINT secondsToTimeOfDay(NINT targetTimeOfDay) * * This function browses through list of volumes, and send check epoch event * to each volume. If the volume supports EFL, it will check if any of used - * epochs hasn't been pinged for a certain amount of time and delete it if + * epochs hasn't been pinged for a certain amount of time and delete it if * it is the case * ****************************************************************************/ void checkIdleEpochs( - FsmLite_s *fsm, + FsmLite_s *fsm, ADDR unused) -{ +{ GeneralMsg_s genMsg; - Volume_s *vol; + Volume_s *vol; NINT secsToStart; - + ASSERT_MPKNSS_LOCK(); - + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); SET_FOREACHBLOCKING(&NSSMasterVolumeList, vol, Volume_s, masterVolLink) @@ -115,27 +115,27 @@ void checkIdleEpochs( { break; } - + vol->VOLcomnVolOps.VOL_administerEFL(&genMsg, vol, VOL_EFL_ADMIN_CHECK_EPOCH, NULL, NULL); SET_FOREACHBLOCKINGEND(&NSSMasterVolumeList, vol, Volume_s, masterVolLink) } - + /* restart checker */ eflCheckerControl.inProgress = FALSE; if (eflCheckerControl.checkerStarted) { secsToStart = secondsToTimeOfDay(0); - + if (secsToStart) { secOneShot(&eflCheckerControl.alarm, secsToStart, eflCheckerStart); - } + } else - { + { eflCheckerStart(&eflCheckerControl.alarm); } } @@ -150,9 +150,9 @@ void checkIdleEpochs( void eflCheckerStart(OneShot_s *alarm) { if (!eflCheckerControl.inProgress) - { + { eflCheckerControl.inProgress = TRUE; - WORK_Schedule(&eflCheckerControl.fsm, (voidfunc_t)checkIdleEpochs, 0); + WORK_Schedule(&eflCheckerControl.fsm, checkIdleEpochs, 0); } } @@ -165,19 +165,19 @@ void eflCheckerStart(OneShot_s *alarm) void startupEFLChecker() { NINT secsToStart; - + ASSERT_MPKNSS_LOCK(); eflCheckerControl.checkerStarted = TRUE; eflCheckerControl.inProgress = FALSE; - + secsToStart = secondsToTimeOfDay(0); if (!secsToStart) { /* Don't start epoch checker at the startup time */ secsToStart = 24 * 60 * 60; } - + /* set up epoch checker, let it run at mid-night */ INIT_ONESHOT(eflCheckerControl.alarm); FSMLITE_INIT(&eflCheckerControl.fsm, "EFL checker", 1); @@ -222,14 +222,14 @@ void EFL_Uninit() { LB_delay(1000); - if (++i >= COMN_EFL_SHUTDOWN_SECONDS) + if (++i >= COMN_EFL_SHUTDOWN_SECONDS) { - errPrintf(WHERE, Module, -1, + errPrintf(WHERE, Module, -1, MSG("Unable to stop efl checker.\n", 591)); break; } } - + CANCEL_ALARM(eflCheckerControl.alarm); } } @@ -245,7 +245,7 @@ STATUS resetVolumeEFLTree( unicode_t *volName) { Volume_s *volume = NULL; - STATUS status = zFAILURE; + STATUS status = zFAILURE; Xaction_s *xaction; struct purgeLogInfo_s { @@ -253,7 +253,7 @@ STATUS resetVolumeEFLTree( LONG purgeLogLoc[MAX_PLOG_LOCATION_SIZE]; }; struct purgeLogInfo_s *purgeLogInfo = NULL; - + /* find volume */ volume = COMN_VolumeNameLookup(genMsg, volName, FALSE, NULL); if (volume == NULL) @@ -265,30 +265,30 @@ STATUS resetVolumeEFLTree( { goto exitRelease; } - + /* set up purge log */ purgeLogInfo = zalloc(sizeof(struct purgeLogInfo_s)); if (purgeLogInfo == NULL) { errPrintf(WHERE, Module, 706, MSGNew("Error allocating memory for remove epoch operation\n", 0)); - SetErrno(genMsg, zERR_NO_MEMORY); + SetErrno(genMsg, zERR_NO_MEMORY); goto exitUnlock; } - SETUP_RESET_EFL_TREE_LOG(&purgeLogInfo->purgeLogMsg, - (void *)&purgeLogInfo->purgeLogLoc, volume); + SETUP_RESET_EFL_TREE_LOG(&purgeLogInfo->purgeLogMsg, + (void *)&purgeLogInfo->purgeLogLoc, volume); xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, X_CF_DEFAULT); - status = volume->VOLcomnVolOps.VOL_addPurgeLogEntry( - genMsg, volume, PLOG_EFL_RESET_TREE, + status = volume->VOLcomnVolOps.VOL_addPurgeLogEntry( + genMsg, volume, PLOG_EFL_RESET_TREE, &purgeLogInfo->purgeLogMsg, (Xaction_s *)xaction); volume->VOLcomnVolOps.VOL_endXLocal(xaction); if (status != zOK) { goto exitUnlock; } - - /* + + /* * Reset the EFL tree * */ @@ -301,10 +301,10 @@ STATUS resetVolumeEFLTree( goto exitUnlock; } } - + xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, X_CF_DEFAULT); - status = volume->VOLcomnVolOps.VOL_removePurgeLogEntry( - genMsg, volume, PLOG_EFL_RESET_TREE, + status = volume->VOLcomnVolOps.VOL_removePurgeLogEntry( + genMsg, volume, PLOG_EFL_RESET_TREE, &purgeLogInfo->purgeLogMsg, (Xaction_s *)xaction); volume->VOLcomnVolOps.VOL_endXLocal(xaction); @@ -313,12 +313,12 @@ exitUnlock: { free(purgeLogInfo); } - + COMN_UnlockVolumeActive(volume, FALSE); - + exitRelease: COMN_Release(&volume); - + exit: return status; -} +} diff --git a/src/nwnss/comn/common/comnEvent.c b/src/nwnss/comn/common/comnEvent.c index 0c38f08..76bd9f4 100644 --- a/src/nwnss/comn/common/comnEvent.c +++ b/src/nwnss/comn/common/comnEvent.c @@ -258,14 +258,14 @@ void ClusterSoftwareDetection( DBG_DebugPrintf(CYAN,"Cluster flag is %d and ID is 0x%lx\n", ClusterSoftwareIsCheckingPoolStateChanges, ClusterSoftwareId ); -#endif +#endif } return; } /* End of ClusterSoftwareDetection() */ /************************************************************************** - * + * ***************************************************************************/ void EventProducerCallback( struct EventBlock *evBlk) @@ -315,130 +315,130 @@ void ReportProduceEventError( /************************************************************************** - * + * ***************************************************************************/ void RegisterNSSEventProducers() { struct ProducerRegistrationInfo reg; ASSERT_MPKNSS_LOCK(); - REG_EVENT_PROD(reg, MSGNot("NSS.Delete.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.Delete.Enter"), EVENT_Delete_Enter, CONSUMABLE_BIT); - REG_EVENT_PROD(reg, MSGNot("NSS.Delete.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.Delete.Exit"), EVENT_Delete_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.Create.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.Create.Enter"), EVENT_Create_Enter, CONSUMABLE_BIT); - REG_EVENT_PROD(reg, MSGNot("NSS.Create.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.Create.Exit"), EVENT_Create_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.Open.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.Open.Enter"), EVENT_Open_Enter, CONSUMABLE_BIT); - REG_EVENT_PROD(reg, MSGNot("NSS.Open.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.Open.Exit"), EVENT_Open_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.Close.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.Close.Enter"), EVENT_Close_Enter, CONSUMABLE_BIT); - REG_EVENT_PROD(reg, MSGNot("NSS.Close.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.Close.Exit"), EVENT_Close_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.ModifyInfo.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.ModifyInfo.Enter"), EVENT_ModifyInfo_Enter, CONSUMABLE_BIT); - REG_EVENT_PROD(reg, MSGNot("NSS.ModifyInfo.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.ModifyInfo.Exit"), EVENT_ModifyInfo_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.Rename.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.Rename.Enter"), EVENT_Rename_Enter, CONSUMABLE_BIT); - REG_EVENT_PROD(reg, MSGNot("NSS.Rename.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.Rename.Exit"), EVENT_Rename_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.SetDataSize.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.SetDataSize.Enter"), EVENT_SetDataSize_Enter, CONSUMABLE_BIT); - REG_EVENT_PROD(reg, MSGNot("NSS.SetDataSize.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.SetDataSize.Exit"), EVENT_SetDataSize_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.AddTrustee.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.AddTrustee.Enter"), EVENT_AddTrustee_Enter, CONSUMABLE_BIT); - REG_EVENT_PROD(reg, MSGNot("NSS.AddTrustee.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.AddTrustee.Exit"), EVENT_AddTrustee_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.RemoveTrustee.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.RemoveTrustee.Enter"), EVENT_RemoveTrustee_Enter, CONSUMABLE_BIT); - REG_EVENT_PROD(reg, MSGNot("NSS.RemoveTrustee.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.RemoveTrustee.Exit"), EVENT_RemoveTrustee_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.SetInheritedRights.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.SetInheritedRights.Enter"), EVENT_SetInheritedRights_Enter, CONSUMABLE_BIT); - REG_EVENT_PROD(reg, MSGNot("NSS.SetInheritedRights.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.SetInheritedRights.Exit"), EVENT_SetInheritedRights_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.ChangeVolState.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.ChangeVolState.Enter"), EVENT_ChangeVolState_Enter, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.ChangeVolState.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.ChangeVolState.Exit"), EVENT_ChangeVolState_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.Link.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.Link.Enter"), EVENT_Link_Enter, CONSUMABLE_BIT); - REG_EVENT_PROD(reg, MSGNot("NSS.Link.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.Link.Exit"), EVENT_Link_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.ChangePoolState.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.ChangePoolState.Enter"), EVENT_ChangePoolState_Enter, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.ChangePoolState.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.ChangePoolState.Exit"), EVENT_ChangePoolState_Exit, 0); - - REG_EVENT_PROD(reg, MSGNot("NSS.PoolCreate.Enter"), + + REG_EVENT_PROD(reg, MSGNot("NSS.PoolCreate.Enter"), EVENT_PoolCreate_Enter, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.PoolCreate.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.PoolCreate.Exit"), EVENT_PoolCreate_Exit, 0); - - REG_EVENT_PROD(reg, MSGNot("NSS.PoolDelete.Enter"), + + REG_EVENT_PROD(reg, MSGNot("NSS.PoolDelete.Enter"), EVENT_PoolDelete_Enter, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.PoolDelete.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.PoolDelete.Exit"), EVENT_PoolDelete_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.PoolResize.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.PoolResize.Enter"), EVENT_PoolResize_Enter, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.PoolResize.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.PoolResize.Exit"), EVENT_PoolResize_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.PoolRename.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.PoolRename.Enter"), EVENT_PoolRename_Enter, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.PoolRename.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.PoolRename.Exit"), EVENT_PoolRename_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.ChangePoolShared.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.ChangePoolShared.Enter"), EVENT_ChangePoolShared_Enter, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.ChangePoolShared.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.ChangePoolShared.Exit"), EVENT_ChangePoolShared_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeCreate.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeCreate.Enter"), EVENT_LVolCreate_Enter, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeCreate.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeCreate.Exit"), EVENT_LVolCreate_Exit, 0); - - REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeDelete.Enter"), + + REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeDelete.Enter"), EVENT_LVolDelete_Enter, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeDelete.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeDelete.Exit"), EVENT_LVolDelete_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeRename.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeRename.Enter"), EVENT_LVolRename_Enter, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeRename.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeRename.Exit"), EVENT_LVolRename_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeSalvage.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeSalvage.Enter"), EVENT_LVolSalvage_Enter, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeSalvage.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeSalvage.Exit"), EVENT_LVolSalvage_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.LVolumePurge.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.LVolumePurge.Enter"), EVENT_LVolPurge_Enter, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.LVolumePurge.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.LVolumePurge.Exit"), EVENT_LVolPurge_Exit, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeSnapshot.Enter"), + REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeSnapshot.Enter"), EVENT_LVolSnapshot_Enter, 0); - REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeSnapshot.Exit"), + REG_EVENT_PROD(reg, MSGNot("NSS.LVolumeSnapshot.Exit"), EVENT_LVolSnapshot_Exit, 0); REG_EVENT_PROD(reg, MSGNot("NSS.PoolFreeze"), @@ -451,7 +451,7 @@ void RegisterNSSEventProducers() #error 1) Comments with the name of the event #error 2) Define the event exit and enter structures. #endif - + } void UnregisterNSSEventProducers() @@ -460,7 +460,7 @@ void UnregisterNSSEventProducers() ASSERT_MPKNSS_LOCK(); for (i=0; i < MAX_NSS_EVENTS; i++) { - ZOS_UnRegisterProducer((struct ProducerInfo *)NEBEventInfo[i].producerID, + ZOS_UnRegisterProducer((struct ProducerInfo *)NEBEventInfo[i].producerID, (void *)i); } } @@ -476,7 +476,7 @@ LONG COMN_SendNSSEvent( LONG status = zOK; #if NSS_DEBUG IS_ENABLED - DBG_ScreenAPrintf("COMN.NEB.Events",WHERE,LMAGENTA, + DBG_ScreenAPrintf("COMN.NEB.Events",WHERE,LMAGENTA, MSGNot("COMN_SendNSSEvent with event %d\n"), event); #endif *denyCode = zOK; @@ -508,3 +508,4 @@ LONG COMN_SendNSSEvent( } return(status); } + diff --git a/src/nwnss/comn/common/comnFile.c b/src/nwnss/comn/common/comnFile.c index 103f4d8..9b39433 100644 --- a/src/nwnss/comn/common/comnFile.c +++ b/src/nwnss/comn/common/comnFile.c @@ -33,7 +33,7 @@ |--------------------------------------------------------------------------- | This module is used to: | This contains the top level internal file interfaces. All external - | interfaces call these routines. + | interfaces call these routines. +-------------------------------------------------------------------------*/ #include #include @@ -54,9 +54,6 @@ #include #include #include -#ifdef NSS_USERSPACE -#include -#endif #include "hardLinkBeast.h" #include "comnPublics.h" @@ -99,9 +96,6 @@ #include "unixNSpace.h" #include "comnVariableData.h" #include "zasAuthModel.h" -#ifdef NSS_USERSPACE -#include "inst.h" -#endif #if zLINUX #include "lsa.h" @@ -112,28 +106,7 @@ extern LONG GetCurrentTime(); #define USER_DELAY_COUNTER 20 /** 10 times .5 secs for 5 sec wait **/ #define USER_DELAY_TIME 500 /** 500 milliseconds **/ -#ifdef NSS_USERSPACE -/* comnFile userspace status bridge: Msg_s.sys.where is a QUAD carrier here. */ -#undef SetErrnoFromStatus -#define SetErrnoFromStatus(_genMsg, _msg) \ - ((_genMsg)->errStatus = (_msg)->sys.status, \ - ((_genMsg)->errStatusSetter = (char *)(uintptr_t)((_msg)->sys.where))) - -static inline struct inode *nss_igrab(struct inode *inode) -{ - return inode; -} - -static inline void nss_iput(struct inode *inode) -{ - (void)inode; -} - -#define igrab(_inode) nss_igrab(_inode) -#define iput(_inode) nss_iput(_inode) -#endif - -#define ODDNULL ((void *)1) /* Used to indicate a NULL pointer but +#define ODDNULL ((void *)1) /* Used to indicate a NULL pointer but * it is distinguished from NULL so we * can differentiate between legacy pointer * and NSS. @@ -156,7 +129,7 @@ BOOL COMN_OldCreateRights = FALSE; /* Enables the old broken create rights /************************************************************************** - * Send all the necessary pre-close events. + * Send all the necessary pre-close events. ***************************************************************************/ void MSG_Notify (FileHandle_s *fileHandle) { @@ -180,21 +153,21 @@ void MSG_Notify (FileHandle_s *fileHandle) if ((fileHandle->fhState & FH_NDS_OPEN) && (LegacyEventReport[EventReport_CloseFile])) { - ((STATUS (*)(FileHandle_s *))LegacyEventReport[EventReport_CloseFile])(fileHandle); + LegacyEventReport[EventReport_CloseFile](fileHandle); } if (!(fileHandle->grantedRights & zRR_PREVENT_FS_HOOKS)) { COMN_SETUP_GENERAL_MSG( &genMsg, fileHandle->connID, fileHandle->taskID, zSAGENT_NONE); - - CHECK_FSHOOKS_CLOSE_ENTER(CloseFile_Hook, &parms, &genMsg, + + CHECK_FSHOOKS_CLOSE_ENTER(CloseFile_Hook, &parms, &genMsg, fileHandle->door.dr_key); INIT_EVENT_ID_STATUS(fileHandle->enterExitID, exit.enterRetStatus); if (NEBEventInfo[EVENT_Close_Enter].consumers) { - INIT_CLOSE_ENTER_EVENT(&genMsg, evBlk, EVENT_Close_Enter, + INIT_CLOSE_ENTER_EVENT(&genMsg, evBlk, EVENT_Close_Enter, enter, fileHandle, fileHandle->enterExitID); ZOS_ProduceEvent(status, &evBlk); CHECK_ENTER_RETURN( &genMsg, status, evBlk, exit, cantStopClose); @@ -207,18 +180,18 @@ void MSG_Notify (FileHandle_s *fileHandle) /************************************************************************** * (Greg's contribution) - * Main Entry: 1com€ment + * Main Entry: 1com€ment * Pronunciation: 'k€-"ment * Function: noun * Etymology: Middle English, from Late Latin commentum, from Latin, invention, - * from neuter of commentus, past participle of comminisci to invent, from + * from neuter of commentus, past participle of comminisci to invent, from * com- + -minisci (akin to ment-, mens mind) -- more at MIND * Date: 14th century * 1 : COMMENTARY * 2 : a note explaining, illustrating, or criticizing the meaning of a writing - * 3 a : an observation or remark expressing an opinion or attitude b : a - * judgment expressed indirectly - * + * 3 a : an observation or remark expressing an opinion or attitude b : a + * judgment expressed indirectly + * ***************************************************************************/ /************************************************************************** @@ -227,7 +200,7 @@ void MSG_Notify (FileHandle_s *fileHandle) * COMN_Close will schedule a WorkToDo to asynchronously close a file * MSG_DestroyKey path in that case does not free the object, so we need * to do that. - * + * ***************************************************************************/ void COMN_CloseAsync (FsmLite_s *fsm, FileHandle_s *fileHandle) { @@ -285,8 +258,8 @@ STATUS COMN_Close (FileHandle_s *fileHandle) { DQ_RMV(fileHandle, bstLink); } - WORK_Schedule(&fileHandle->FH_asyncCloseFsm, - (voidfunc_t)COMN_CloseAsync, (ADDR)fileHandle); + WORK_Schedule(&fileHandle->FH_asyncCloseFsm, + COMN_CloseAsync, (ADDR)fileHandle); STACK_FREE(); RTN_STATUS(zERR_DONT_FREE_OBJECT); } @@ -312,15 +285,15 @@ STATUS COMN_Close (FileHandle_s *fileHandle) #ifndef __linux__ // LINUX_ConnMgr /** Check if the Connection has this handle saved for Packet Burst **/ if ((GetConnectionServiceInformation( - fileHandle->pssConn->connectionNumber, &station) == 0) && - (station != NULL) && + fileHandle->pssConn->connectionNumber, &station) == 0) && + (station != NULL) && (station->SCHandle == (LONG)fileHandle->door.dr_key)) { station->SCHandle = (LONG)ODDNULL; } #endif - dataStream = fileHandle->dataStream; + dataStream = fileHandle->dataStream; file = fileHandle->file; if (dataStream != NULL) { @@ -345,12 +318,12 @@ STATUS COMN_Close (FileHandle_s *fileHandle) dataStream->NAMEDbstState &= ~BST_STATE_DIOMODE; } } - + dataStream->NAMEDcomnOps.BST_beastNotify( &genMsg,&dataStream->NAMEDroot,BST_NOTIFY_CLOSE); /** As an optimization we should do the flush only if the file is not being - ** deleted and after the alloc_ahead blocks have been truncated which is + ** deleted and after the alloc_ahead blocks have been truncated which is ** being done in FH_FreeOpenFile **/ /** ** if (closeFlags & zCLOSE_FLUSH) @@ -403,7 +376,7 @@ STATUS COMN_Close (FileHandle_s *fileHandle) COMN_SETUP_GENERAL_MSG_NOSA( &cmGenMsg); if ((fileHandle->grantedRights & zRR_ENABLE_IO_ON_COMPRESSED_DATA)) - { + { status = CM_accessCompFileDone(&cmGenMsg, &dataStream->NAMEDroot, fileHandle->compBeast); } @@ -419,7 +392,7 @@ STATUS COMN_Close (FileHandle_s *fileHandle) } } } - + /* * NOTE: We need to cleanup the snapshot even if COW has been * disabled. @@ -508,7 +481,7 @@ STATUS COMN_LsaCleanupSetup( COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE(&genMsg); if ( COMN_GetNameFromBeast( &genMsg, beast, /* cnt nameUniquifier, */ - nsID, zMAX_COMPONENT_NAME, + nsID, zMAX_COMPONENT_NAME, lsaInv->lid_name, &namelen) != zOK ) { printk("<1> Error from COMN_GetNameFromBeast = %d\n", GetErrno(&genMsg)); @@ -542,7 +515,7 @@ STATUS COMN_CreateWithCallback( GeneralMsg_s *genMsg, NamingMsg_s *nameMsg, CreateMsg_s *createMsg, - FileHandleIDP_s *retFileHandle, + FileHandleIDP_s *retFileHandle, void *userParam, STATUS (*createCallBack)(GeneralMsg_s *genMsg, NamingMsg_s *nameMsg, @@ -634,8 +607,8 @@ STATUS COMN_CreateWithCallback( } /*--------------------------------------------------------------------------- - * Check for presence of BOTH zFA_COMPRESS_FILE_IMMEDIATELY and - * zFA_DO_NOT_COMPRESS_FILE. If both are here, clear the + * Check for presence of BOTH zFA_COMPRESS_FILE_IMMEDIATELY and + * zFA_DO_NOT_COMPRESS_FILE. If both are here, clear the * zFA_COMPRESS_FILE_IMMEDIATELY bit and continue on. This functionality * matches what occurs in the legacy file system. *---------------------------------------------------------------------------*/ @@ -644,7 +617,7 @@ STATUS COMN_CreateWithCallback( (createMsg->attributes & zFA_DO_NOT_COMPRESS_FILE)) { createMsg->attributes &= ~zFA_COMPRESS_FILE_IMMEDIATELY; - } + } /*--------------------------------------------------------------------------- * Check File Type @@ -654,7 +627,7 @@ STATUS COMN_CreateWithCallback( (createMsg->beastClassID != zFTYPE_EXTENDED_ATTRIBUTE)) { SetErrno(genMsg, zERR_INVALID_TYPE_FILE); - goto cleanup_errorAndReturn; + goto cleanup_errorAndReturn; } /*--------------------------------------------------------------------------- * Mask Valid Requested Rights - NOTE -- requested Rights are only valid @@ -703,7 +676,7 @@ STATUS COMN_CreateWithCallback( { goto cleanup_freeOpenFileAndReturn; } - + #if NSS_DEBUG IS_ENABLED pentry = NAME_GetParentEntry(genMsg,nameMsg->curFile/* cnt ,nameMsg->fileNameUniquifier*/); zASSERT(pentry->p.nameType == zNTYPE_FILE); @@ -719,7 +692,7 @@ STATUS COMN_CreateWithCallback( } /*--------------------------------------------------------------------------- - * Check to make sure we still have user disk space before proceeding + * Check to make sure we still have user disk space before proceeding * with create. *---------------------------------------------------------------------------*/ if (nameMsg->curvol->v_statusFlag & VOL_SF_LOGICAL_VOLUME) @@ -728,15 +701,15 @@ STATUS COMN_CreateWithCallback( for (i = 0;;) { - aStack->useableBlksVOL = nameMsg->curvol->VOLtotalBlocks - - nameMsg->curvol->VOLinUseBlocks + + aStack->useableBlksVOL = nameMsg->curvol->VOLtotalBlocks - + nameMsg->curvol->VOLinUseBlocks + nameMsg->curvol->VOLpurgeableBlocks + nameMsg->curvol->VOLnonPurgeableBlocks; if (aStack->useableBlksVOL <= nameMsg->curvol->VOLfreeBlockAdjustment) { /* Volume has used all its space in non-deleted - * files. We cannot create any more files + * files. We cannot create any more files */ if (rsrcLatched) { @@ -756,7 +729,7 @@ STATUS COMN_CreateWithCallback( } if ((nameMsg->curvol->v_pool->POOLtotalBlocks - - nameMsg->curvol->v_pool->POOLinUseBlocks) > + nameMsg->curvol->v_pool->POOLinUseBlocks) > nameMsg->curvol->v_pool->VOLfreeBlockAdjustment) { if (rsrcLatched) @@ -795,9 +768,9 @@ STATUS COMN_CreateWithCallback( rsrcLatched = TRUE; } COMN_MakeVolumeFreeSpace(genMsg, nameMsg->curvol, FALSE, TRUE, 0); - + LB_delay(USER_DELAY_TIME); /* Wait .5 sec */ - COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); + COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); } } @@ -1023,7 +996,7 @@ reLookupLeafName: aStack->parentZid = nameMsg->curFile->FILEzid; /* - * If file already exists, find it, set useCount and latch it. + * If file already exists, find it, set useCount and latch it. * NOTE - As a fix to Defect #230368 and Defect #230747, this lookup * always does NOT do a visibility check. We need to know if the beast * already exists, even if we don't have rights to see it. @@ -1039,12 +1012,12 @@ reLookupLeafName: if (nameMsg->scanMsg.retScanFlags & NSRETSFL_hasExtendedASCII) { /* Note - only DOS sets this flag. We did not find the name - * already in the directory. The name has extended ASCII + * already in the directory. The name has extended ASCII * characters in it, so before creating the new file, we must * reparse the extended ASCII characters using DOS uppercasing * rules or we will have problems. * Up to this point, the path was already parsed without doing - * uppercasing, because we need to look up existing file + * uppercasing, because we need to look up existing file * names exactly as typed by the user, or we wouldn't be able * to lookup files that contain illegal characters. */ @@ -1119,7 +1092,7 @@ reLookupLeafName: * existingBeast, if non-NULL, is a pointer to the existing beast, which has * a useCount and an XLATCH on it. * beastName points to the name of the leaf component, whether it exists or not. - * parentZid contains the parentZid of the beast to be created. + * parentZid contains the parentZid of the beast to be created. *===========================================================================*/ INIT_EVENT_ID_STATUS(id, aStack->exit.enterRetStatus); if ((!(createMsg->requestedRights & zRR_PREVENT_FS_HOOKS)) && @@ -1132,16 +1105,16 @@ reLookupLeafName: COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); RELEASE_RSRC(NAME_RESERVE); - CHECK_FSHOOKS_CREATE_ENTER(F3OpenCreate_Hook, &aStack->parms, status, - cleanup_freeOpenFileExit, genMsg, nameMsg, createMsg, + CHECK_FSHOOKS_CREATE_ENTER(F3OpenCreate_Hook, &aStack->parms, status, + cleanup_freeOpenFileExit, genMsg, nameMsg, createMsg, beastName, aStack->asciiBeastName, retFileHandle); if (NEBEventInfo[EVENT_Create_Enter].consumers) { - INIT_CREATE_ENTER_EVENT(genMsg, nameMsg, aStack->evBlk, EVENT_Create_Enter, + INIT_CREATE_ENTER_EVENT(genMsg, nameMsg, aStack->evBlk, EVENT_Create_Enter, aStack->enter, id, beastName, createMsg, retFileHandle); ZOS_ProduceEvent(status,&aStack->evBlk); - CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, + CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, cleanup_freeOpenFileExit); } @@ -1251,7 +1224,7 @@ reLookupLeafName: if(nameMsg->hlFile) zASSERT(nameMsg->hlFile->HARDLfirstParentNameType == zNTYPE_FILE); else - zASSERT(nameMsg->curFile->FILEfirstParentNameType == zNTYPE_FILE); + zASSERT(nameMsg->curFile->FILEfirstParentNameType == zNTYPE_FILE); #endif /*--------------------------------------------------------------------------- * Ask the container's beast class if this class allows CREATE @@ -1329,7 +1302,7 @@ reLookupLeafName: primaryBeast = HL_CheckIfHardlinkAndReturnPrimary( genMsg, existingBeast, XLATCHED); - rightsCheckFile = + rightsCheckFile = primaryBeast? primaryBeast : (File_s *)existingBeast; aStack->rightsCheckParentZid = aStack->parentZid; } @@ -1354,10 +1327,10 @@ reLookupLeafName: { if (nameMsg->curvol->VOLenabledAttributes & zATTR_READONLY) { -// zASSERT(!(createMsg->requestedRights & +// zASSERT(!(createMsg->requestedRights & // ~zVALID_READ_ONLY_FILE_REQ_RIGHTS)); - if ((createMsg->requestedRights & - ~zVALID_READ_ONLY_FILE_REQ_RIGHTS) || + if ((createMsg->requestedRights & + ~zVALID_READ_ONLY_FILE_REQ_RIGHTS) || (createMsg->createFlags & zCREATE_TRUNCATE_IF_THERE)) { SetErrno(genMsg, zERR_ALL_FILES_READ_ONLY); @@ -1366,13 +1339,13 @@ reLookupLeafName: } /* Mask read in drop boxes */ - if ((createMsg->requestedRights & zRR_MASK_READ_IN_DROP_BOXES) + if ((createMsg->requestedRights & zRR_MASK_READ_IN_DROP_BOXES) && (rightsCheckFile->FILEmayIDoThis(genMsg, rightsCheckFile, aStack->rightsCheckParentZid, MAY_I_CREATE_ONLY) == zOK)) { createMsg->requestedRights &= ~zRR_READ_ACCESS; } - + /* see if we can READ from it*/ if (createMsg->requestedRights & zRR_READ_ACCESS) { @@ -1381,7 +1354,7 @@ reLookupLeafName: aStack->rightsCheckParentZid, MAY_I_READ_DATA) != zOK)) { if (rightsCheckFile->FILEmayIDoThis(genMsg, - rightsCheckFile, aStack->rightsCheckParentZid, + rightsCheckFile, aStack->rightsCheckParentZid, MAY_I_CREATE) == zOK) { /* The file can be open with create rights if: * 1. It was created by the current user @@ -1414,11 +1387,11 @@ cantRead: aStack->rightsCheckParentZid, MAY_I_WRITE_DATA) != zOK)) { if (rightsCheckFile->FILEmayIDoThis(genMsg, - rightsCheckFile, aStack->rightsCheckParentZid, + rightsCheckFile, aStack->rightsCheckParentZid, MAY_I_CREATE) == zOK) { /* The file can be open with create rights if: - * 1. It was created by the current user - * 2. It is empty + * 1. It was created by the current user + * 2. It is empty */ if (LB_GUIDCompare(&rightsCheckFile->FILEownerID, &genMsg->pssConn.ptr->authInfo.authenticatedIDs[0]) != 0) @@ -1448,7 +1421,7 @@ cantWrite: if ((existingBeast->root.fileSnapshotBeast == NULL) && (existingBeast->NAMEDsnapReaderCount != 0)) { - fixUpSnapReaders = + fixUpSnapReaders = existingBeast->NAMEDsnapReaderCount; } if (SetupSnapshotBeast(genMsg, @@ -1462,13 +1435,13 @@ cantWrite: * that when the snapshot reader close the file * they can decrement it */ - SetupSnapshotBeast(genMsg, + SetupSnapshotBeast(genMsg, &existingBeast->NAMEDroot, nameMsg->curvol); } fhState |= FH_WRITE_SNAPSHOT; cleanupSnapBeast = existingBeast; } - } + } } createMsg->ret_openCreateAction = zBEAST_EXISTED; @@ -1486,7 +1459,7 @@ checkAgain: zATTR_CFS_MASTER) && (!retried)) { retried = TRUE; - CSA_CloseNotInUseFileHandles(existingBeast, + CSA_CloseNotInUseFileHandles(existingBeast, zRR_WRITE_ACCESS, NULL); goto checkAgain; } @@ -1598,15 +1571,15 @@ checkAgain: if (delayedOutOfSpaceError) { SetErrno(genMsg, zERR_OUT_OF_SPACE); - goto cleanup_freeOpenFile; + goto cleanup_freeOpenFile; } /* Defect #306666. We can't allow unlicensed connection access */ if (!ConnectionIsLoggedIn(genMsg->pssConn.id)) { - /* Not doing "open if there". Fail this unlicensed access */ - SetErrno(genMsg, zERR_NO_CREATE_PRIVILEGE); - goto cleanup_freeOpenFile; + /* Not doing "open if there". Fail this unlicensed access */ + SetErrno(genMsg, zERR_NO_CREATE_PRIVILEGE); + goto cleanup_freeOpenFile; } /* @@ -1619,7 +1592,7 @@ checkAgain: } /* - * Check for Create Trustee rights + * Check for Create Trustee rights */ if ((aStack->doRightsCheck) && (((File_s *)nameMsg->curFile)->FILEmayIDoThis(genMsg, @@ -1637,13 +1610,13 @@ checkAgain: curDir = (File_s *)nameMsg->curFile; if (curVol == (Volume_s *)&AdminVolume) { - /* + /* * Make sure _admin volume files are marked as volatile so op locks * aren't used with these file. */ createMsg->attributes |= zFA_VOLATILE; - if ((PersistAdminVolume != NULL) && + if ((PersistAdminVolume != NULL) && (curDir->FILEzid >= AVOL_FIRST_PERSISTENT_ZID)) { curVol = PersistAdminVolume; @@ -1679,7 +1652,7 @@ checkAgain: * resulting in a window where this beast is being tossed and in error * conditions we will toss it again, hence the extra use count */ - /** 10/28/03 - Vandana - + /** 10/28/03 - Vandana - ** Don't need this anymore, because BST_new (ROOT_BST_Construct) no ** longer puts the beast on the volume linked list. That is now ** done as part of BEASTHASH_Insert @@ -1735,7 +1708,7 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, { /* Fix SPD 194361 - Fixed to NOT set the modify time when creating * data streams and extended attributes. */ - nameMsg->curFile->FILEaccessedTime = + nameMsg->curFile->FILEaccessedTime = nameMsg->curFile->FILEmetaDataModifiedTime = aStack->currentTime; nameMsg->curFile->FILEarchivedTime = INVALID_UTC_TIME; @@ -1754,9 +1727,9 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, curDir->FILEvolume->VOLfile.FILEmodifiedTime = aStack->currentTime; COMN_MARK_BEAST_MESSY(&curDir->FILEroot); - ((File_s *)newBeast)->FILEaccessedTime = - ((File_s *)newBeast)->FILEcreatedTime = - ((File_s *)newBeast)->FILEmodifiedTime = + ((File_s *)newBeast)->FILEaccessedTime = + ((File_s *)newBeast)->FILEcreatedTime = + ((File_s *)newBeast)->FILEmodifiedTime = ((File_s *)newBeast)->FILEmetaDataModifiedTime = aStack->currentTime; ((File_s *)newBeast)->FILEarchivedTime = INVALID_UTC_TIME; @@ -1764,7 +1737,7 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, if (createMsg->attributes & (zFA_ARCHIVE|zFA_ATTR_ARCHIVE)) { /* If setting archive bits, add to MFL */ - SBS_markFileModified((File_s *)newBeast, + SBS_markFileModified((File_s *)newBeast, (createMsg->attributes & (zFA_ARCHIVE|zFA_ATTR_ARCHIVE)), xaction); @@ -1772,7 +1745,7 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, /* DOS Times are set in the constructor */ OID_SaveObjectID(curVol, &createMsg->ownerID); - ((File_s *)newBeast)->FILEownerID = + ((File_s *)newBeast)->FILEownerID = ((File_s *)newBeast)->FILEmodifierID = ((File_s *)newBeast)->FILEmetaDataModifierID = createMsg->ownerID; @@ -1798,7 +1771,7 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, /*--------------------------------------------------------------------------- * If the file already exists we will only get this far if the - * zCREATE_DELETE_IF_THERE bit is set. If this is the case, we must now + * zCREATE_DELETE_IF_THERE bit is set. If this is the case, we must now * delete the old file before proceeding. *---------------------------------------------------------------------------*/ createMsg->ret_openCreateAction = zBEAST_CREATED; @@ -1833,7 +1806,7 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, aStack->lsaInv.lid_pZid = curDir->FILEzid; lsaDelDentry = TRUE; } - status = BST_delete(genMsg, curDir, existingBeast, primaryBeast, + status = BST_delete(genMsg, curDir, existingBeast, primaryBeast, neighborBeast, xaction, FALSE, TRUE); if(status != zOK) @@ -1962,9 +1935,9 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, /* we don't unlatch curDir here because it is needed end transaction */ // COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS_KEEP_LATCHTYPE(nameMsg); - zASSERT((NamedBeast_s *)nameMsg->curFile == nameMsg->curDataStream); + zASSERT((NamedBeast_s *)nameMsg->curFile == nameMsg->curDataStream); zASSERT(nameMsg->curFile == curDir); - COMN_Release(&nameMsg->curDataStream); + COMN_Release(&nameMsg->curDataStream); nameMsg->curFile = (File_s *)newBeast; nameMsg->curDataStream = newBeast; @@ -1986,13 +1959,13 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, goto cleanup_resetNameMsg; } } - + if (COMN_ForceBeastWrite(genMsg,newBeast,xaction) != zOK) { goto cleanup_resetNameMsg; } - + DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, %s\n"), GetCurrentTime(), Ticks, ThreadId(), WHERE)); COMN_EndXLocal(curDir,&xaction); @@ -2010,19 +1983,19 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, if (!creatingDataStream) { aStack->lsaPzid = curDir->FILEzid; - COMN_UnlatchAndRelease(&curDir, nameMsg->latchType); + COMN_UnlatchAndRelease(&curDir, nameMsg->latchType); if (newBeast && !(createMsg->createFlags & zCREATE_KEEP_VFS_CACHE)) { lsaInvDentry = TRUE; } } - + if (existingBeast) { COMN_UnlatchAndRelease(&existingBeast,XLATCHED); } - if (lsaDelDentry && Ptr_lsa_invalidate_dentry) + if (lsaDelDentry && Ptr_lsa_invalidate_dentry) { Ptr_lsa_invalidate_dentry(&aStack->lsaInv); } @@ -2044,7 +2017,7 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, /*--------------------------------------------------------------------------- * Update NamingMsg to the correct state. *---------------------------------------------------------------------------*/ -returnTheFile: +returnTheFile: /* curDir is now invalid */ if (creatingDataStream) { @@ -2061,7 +2034,7 @@ returnTheFile: if ((hl = nameMsg->hlFile)) { COMN_USE_BEAST(&nameMsg->hlFile->HARDLroot); - } + } COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS_KEEP_LATCHTYPE(nameMsg); if(hl) @@ -2093,7 +2066,7 @@ fillFileHandle: { goto cleanup_freeOpenFile; } - + /* Compression-related checks */ if (CM_COMPRESSION_ENABLED(nameMsg->curvol)) { @@ -2120,11 +2093,11 @@ fillFileHandle: } if (createMsg->requestedRights & zRR_WRITE_ACCESS) { - /* + /* * To write compressed one must be writing to a NEW file and one - * must be requesting exclusive access. + * must be requesting exclusive access. */ - if (!(createMsg->requestedRights & zRR_DENY_READ) || + if (!(createMsg->requestedRights & zRR_DENY_READ) || !(createMsg->requestedRights & zRR_DENY_WRITE)) { SetErrno(genMsg, zERR_ALL_FILES_READ_ONLY); @@ -2155,7 +2128,7 @@ fillFileHandle: OPLOCK_BreakPSA(nameMsg->curFile); } } - + if (FH_OpenFile(genMsg, retFileHandle, nameMsg, fhState) != zOK) { goto cleanup_freeOpenFile; @@ -2221,12 +2194,12 @@ fillFileHandle: { if (createMsg->ret_openCreateAction == zBEAST_EXISTED) { - BOOL keep_comp_version = + BOOL keep_comp_version = (((fh->grantedRights & zRR_LEAVE_FILE_COMPRESSED) || fh->parentIsImmCompress) ? TRUE : FALSE); - NINT access_mode = - (fh->grantedRights & zRR_WRITE_ACCESS) + NINT access_mode = + (fh->grantedRights & zRR_WRITE_ACCESS) ? CACHE_UPDATE : CACHE_READ; if (CM_prepareToAccessUncompFile(genMsg, nameMsg->curFile, @@ -2237,12 +2210,12 @@ fillFileHandle: } if (keep_comp_version) - { + { fh->grantedRights |= zRR_LEAVE_FILE_COMPRESSED; } - else + else { - fh->grantedRights &= ~zRR_LEAVE_FILE_COMPRESSED; + fh->grantedRights &= ~zRR_LEAVE_FILE_COMPRESSED; } } else @@ -2250,13 +2223,13 @@ fillFileHandle: if ((fh->parentIsImmCompress) || (createMsg->attributes & zFA_COMPRESS_FILE_IMMEDIATELY)) { - fh->grantedRights |= zRR_LEAVE_FILE_COMPRESSED; - } + fh->grantedRights |= zRR_LEAVE_FILE_COMPRESSED; + } } } } } - + /* Defect 309982 - Create-OpenIfThere was not setting accessedTime */ if (!(createMsg->ret_openCreateAction & zBEAST_CREATED) && (createMsg->createFlags & zCREATE_OPEN_IF_THERE)) @@ -2278,7 +2251,7 @@ fillFileHandle: } } } - + /* truncate newFile if it's not new and if createFlags instructs so */ if (!(createMsg->ret_openCreateAction & zBEAST_CREATED) && (createMsg->createFlags & zCREATE_TRUNCATE_IF_THERE)) @@ -2289,13 +2262,13 @@ fillFileHandle: createMsg->ownerID; aStack->currentTime = GetUTCTime(); - ((File_s *)newBeast)->FILEmodifiedTime = - ((File_s *)newBeast)->FILEaccessedTime = + ((File_s *)newBeast)->FILEmodifiedTime = + ((File_s *)newBeast)->FILEaccessedTime = ((File_s *)newBeast)->FILEmetaDataModifiedTime = aStack->currentTime; - ((File_s *)newBeast)->FILEmodifiedDOSTime = - ((File_s *)newBeast)->FILEaccessedDOSTime = + ((File_s *)newBeast)->FILEmodifiedDOSTime = + ((File_s *)newBeast)->FILEaccessedDOSTime = ((File_s *)newBeast)->FILEmetaDataModifiedDOSTime = INVALID_DOS_TIME; @@ -2332,13 +2305,13 @@ fillFileHandle: /* After beast is truncated, its related compBeast is thrown away. * we need to decrement compBeast's useCount that we add in - * CM_prepareAccessCompFile + * CM_prepareAccessCompFile */ if (retFileHandle != NULL && retFileHandle->ptr->compBeast) { COMN_Release(&retFileHandle->ptr->compBeast); } - + if (creatingDataStream) dstrCounts->dataSize -= newBeast->NAMEDeof; @@ -2346,17 +2319,17 @@ fillFileHandle: COMN_MARK_BEAST_DIRTY(&newBeast->NAMEDroot); } } - + status = zOK; /* For every open file, I want to make sure that: - * 1) There is an inode associated with this file. + * 1) There is an inode associated with this file. * This is to ensure that pages read and written will come from * the Linux cache. Without an inode this cannot happen. * Open can also happen from zOpen or zCreate. * 2) There is an useCount on the inode. Close will do iput. * 3) lsa_get_inode does an iget which will call lsa_read_inode which * will do a lookup which will set rb_inode for the beast. - * 4) Create with Open does not have the inode count incremented, + * 4) Create with Open does not have the inode count incremented, * so it should not come with the NAMPFL_noExtraInodeCount set. */ if (retFileHandle && Ptr_lsa_get_inode) @@ -2364,7 +2337,7 @@ fillFileHandle: struct inode *fh_inode = NULL; BOOL needLsaInode = FALSE; - if (nameMsg->curFile->FILEroot.rb_inode) + if (nameMsg->curFile->FILEroot.rb_inode) { /* if (!(nameMsg->parseFlags & NAMPFL_noExtraInodeCount)) */ { @@ -2383,9 +2356,9 @@ fillFileHandle: { COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); fh_inode = Ptr_lsa_get_inode( - &nameMsg->curFile->FILEvolume->VOLvolumeID, + &nameMsg->curFile->FILEvolume->VOLvolumeID, nameMsg->curFile->FILEzid); - COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); + COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); } #if 0 // if (!(nameMsg->curFile->FILEroot.rb_inode) || @@ -2394,9 +2367,9 @@ fillFileHandle: // { // COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); // fh_inode = Ptr_lsa_get_inode( -// &nameMsg->curFile->FILEvolume->VOLvolumeID, +// &nameMsg->curFile->FILEvolume->VOLvolumeID, // nameMsg->curFile->FILEzid); -// COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); +// COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); // } #endif retFileHandle->ptr->fh_inode = fh_inode; @@ -2407,20 +2380,20 @@ sendExitEvent: if ((!(createMsg->requestedRights & zRR_PREVENT_FS_HOOKS)) && FSHOOKS_OR_EVENTS(F3OpenCreate_Hook, EVENT_Create_Exit)) { - COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); + COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); - CHECK_FSHOOKS_CREATE_EXIT(F3OpenCreate_Hook, &aStack->parms, genMsg, nameMsg, + CHECK_FSHOOKS_CREATE_EXIT(F3OpenCreate_Hook, &aStack->parms, genMsg, nameMsg, createMsg, beastName, aStack->asciiBeastName, retFileHandle); if (NEBEventInfo[EVENT_Create_Exit].consumers) { INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, EVENT_Create_Exit, aStack->exit, id); - INIT_CREATE_EXIT_EVENT(aStack->exit, status, createMsg, nameMsg, + INIT_CREATE_EXIT_EVENT(aStack->exit, status, createMsg, nameMsg, retFileHandle); ZOS_ProduceEvent(status,&aStack->evBlk); } - COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); + COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); } if (beastNameAllocated) @@ -2450,12 +2423,12 @@ cleanup_resetNameMsg: } else { - COMN_Release(&nameMsg->curDataStream); + COMN_Release(&nameMsg->curDataStream); nameMsg->curFile = curDir; nameMsg->curDataStream = (NamedBeast_s *)curDir; COMN_USE_BEAST(&nameMsg->curDataStream->NAMEDroot); } - + cleanup_removeNames: if (creatingDataStream) { @@ -2504,14 +2477,14 @@ cleanup_newBeast: // // /* Assign newbeast to a temp pointer and unlatch and release (and NULLIFY) // * the temp. This allows us to hang onto the real "newBeast" pointer so we -// * can use it in the subsequent call to BST_free. +// * can use it in the subsequent call to BST_free. // */ // tempBeast = newBeast; // CANCEL_ALARM(newBeast->NAMEDmycache.agent.timer); // COMN_UnlatchAndRelease(&tempBeast, XLATCHED); - /* Save errno around the write to prevent a successful write obscuring - * an error we are in the process of returning. COMN_ForceBeastWrite + /* Save errno around the write to prevent a successful write obscuring + * an error we are in the process of returning. COMN_ForceBeastWrite * has paths that clear errno. */ aStack->tmpMsg = *genMsg; @@ -2524,7 +2497,7 @@ cleanup_newBeast: *genMsg = aStack->tmpMsg; } } - } + } cleanup_endXlocal: COMN_EndXLocal(curDir,&xaction); @@ -2543,9 +2516,9 @@ cleanup_freeOpenFile: } if (retFileHandle) { - COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); + COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); MSG_DestroyKey(retFileHandle->key); - COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); + COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); } if(neighborBeast) { @@ -2565,7 +2538,7 @@ cleanup_freeOpenFileAndReturn: if (existingBeast) { COMN_UnlatchAndRelease(&existingBeast, XLATCHED); - } + } if(primaryBeast) { COMN_UnlatchAndRelease(&primaryBeast, XLATCHED); @@ -2609,17 +2582,17 @@ cleanup_freeOpenFileExit: if (retFileHandle) { MSG_DestroyKey(retFileHandle->key); - } + } if ((nameMsg->curFile) || (nameMsg->curDataStream)) { - COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); + COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); } if (dosNameSpace != NULL) { COMN_Release(&dosNameSpace); } STACK_FREE(); - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } @@ -2712,7 +2685,7 @@ STATUS COMN_Delete( release all reference to the primary. Make sure the latches are the hardlink, not on the primary */ - if((hl = nameMsg->hlFile)) + if((hl = nameMsg->hlFile)) { nameMsg->hlFile = NULL; COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS_KEEP_LATCHTYPE(nameMsg); @@ -2831,14 +2804,14 @@ STATUS COMN_Delete( COMN_UNLATCH_NAMEMSG_BEASTS_KEEP_LATCHTYPE(nameMsg); X_LATCH(&curDir->FILEbeastLatch); COMN_LATCH_NAMEMSG_BEASTS(nameMsg,XLATCHED); - + curDirLatched = TRUE; } /* Based on the nameType, this is either a purge or a delete */ - hookType = (nameMsg->workNameType == zNTYPE_DELETED_FILE) ? + hookType = (nameMsg->workNameType == zNTYPE_DELETED_FILE) ? PurgeFile_Hook : F3EraseFile_Hook; - + INIT_EVENT_ID_STATUS(id, aStack->exit.enterRetStatus); if (FSHOOKS_OR_EVENTS(hookType, EVENT_Delete_Enter)) { @@ -2857,16 +2830,16 @@ STATUS COMN_Delete( } else { - CHECK_FSHOOKS_DELETE_ENTER(F3EraseFile_Hook, &aStack->eraseParms, status, - releaseDirectoryExit, genMsg, nameMsg); + CHECK_FSHOOKS_DELETE_ENTER(F3EraseFile_Hook, &aStack->eraseParms, status, + releaseDirectoryExit, genMsg, nameMsg); } if (NEBEventInfo[EVENT_Delete_Enter].consumers) { - INIT_ENTER_EVENT(genMsg, nameMsg, aStack->evBlk, EVENT_Delete_Enter, + INIT_ENTER_EVENT(genMsg, nameMsg, aStack->evBlk, EVENT_Delete_Enter, aStack->enter, id); ZOS_ProduceEvent(status, &aStack->evBlk); - CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, + CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, releaseDirectoryExit); } @@ -2939,7 +2912,7 @@ STATUS COMN_Delete( goto cleanup_unlatchDirectory; } - /* Don't allow delete if the file is exclusive locked */ + /* Don't allow delete if the file is exclusive locked */ if ((nameMsg->curDataStream->NAMEDdenyReaderCount != 0) || (nameMsg->curDataStream->NAMEDdenyWriterCount != 0)) { @@ -2957,7 +2930,7 @@ STATUS COMN_Delete( goto cleanup_unlatchDirectory; } - if (!(deleteMsg->deleteFlags & zDELETE_FORCE_DELETE) && + if (!(deleteMsg->deleteFlags & zDELETE_FORCE_DELETE) && nameMsg->curFile->FILEattributes & zFA_DELETE_INHIBIT) { SetErrno(genMsg,zERR_ALL_FILES_READ_ONLY); @@ -3017,7 +2990,7 @@ STATUS COMN_Delete( } if ( !(deleteMsg->deleteFlags & zDELETE_KEEP_VFS_CACHE)) { - if ( COMN_LsaCleanupSetup(nameMsg->curDataStream, + if ( COMN_LsaCleanupSetup(nameMsg->curDataStream, /* cnt nameUniquifier,*/ &aStack->lsaInv) == zOK) { if (primaryBeast != NULL) @@ -3037,8 +3010,8 @@ STATUS COMN_Delete( { nameMsg->curFile->FILEattributes |= zFA_IMMEDIATE_PURGE; - status = BST_delete( genMsg, curDir, nameMsg->curDataStream, - primaryBeast, neighborBeast, xaction, FALSE, TRUE); + status = BST_delete( genMsg, curDir, nameMsg->curDataStream, + primaryBeast, neighborBeast, xaction, FALSE, TRUE); if ((status != zOK) && (nameMsg->curFile != NULL)) { @@ -3047,8 +3020,8 @@ STATUS COMN_Delete( } else { - status = BST_delete( genMsg, curDir, nameMsg->curDataStream, - primaryBeast, neighborBeast, xaction, FALSE, TRUE); + status = BST_delete( genMsg, curDir, nameMsg->curDataStream, + primaryBeast, neighborBeast, xaction, FALSE, TRUE); } if ((status != zOK) && @@ -3056,12 +3029,12 @@ STATUS COMN_Delete( (nameMsg->workNameType == zNTYPE_DELETED_FILE)) { DoPurgeDeletedDirectoryTree = TRUE; - } + } else { DoPurgeDeletedDirectoryTree = FALSE; } - + currentTime = GetUTCTime(); if (!deletingExtAttr) { @@ -3134,12 +3107,12 @@ sendExitEvent: if (hookType == PurgeFile_Hook) { CHECK_FSHOOKS_PURGE_EXIT(PurgeFile_Hook, &aStack->purgeParms, genMsg, - nameMsg); + nameMsg); } else { CHECK_FSHOOKS_DELETE_EXIT(F3EraseFile_Hook, &aStack->eraseParms, genMsg, - nameMsg); + nameMsg); } if (NEBEventInfo[EVENT_Delete_Exit].consumers) @@ -3197,18 +3170,18 @@ sendExitEvent: * and then re-latch the child. */ if (curDir != nameMsg->curFile) { - + COMN_UNLATCH_NAMEMSG_BEASTS_KEEP_LATCHTYPE(nameMsg); X_LATCH(&curDir->FILEbeastLatch); COMN_LATCH_NAMEMSG_BEASTS(nameMsg,XLATCHED); - + curDirLatched = TRUE; } /* Based on the nameType, this is either a purge or a delete */ - hookType = (nameMsg->workNameType == zNTYPE_DELETED_FILE) ? + hookType = (nameMsg->workNameType == zNTYPE_DELETED_FILE) ? PurgeFile_Hook : F3EraseFile_Hook; - + INIT_EVENT_ID_STATUS(id, aStack->exit.enterRetStatus); if (FSHOOKS_OR_EVENTS(F3EraseFile_Hook, EVENT_Delete_Enter)) { @@ -3223,20 +3196,20 @@ sendExitEvent: if (hookType == PurgeFile_Hook) { CHECK_FSHOOKS_PURGE_ENTER(PurgeFile_Hook, &aStack->purgeParms, - status, skipOperation, genMsg, nameMsg); + status, skipOperation, genMsg, nameMsg); } else { CHECK_FSHOOKS_DELETE_ENTER(F3EraseFile_Hook, &aStack->eraseParms, - status, skipOperation, genMsg, nameMsg); + status, skipOperation, genMsg, nameMsg); } if (NEBEventInfo[EVENT_Delete_Enter].consumers) { - INIT_ENTER_EVENT(genMsg, nameMsg, aStack->evBlk, + INIT_ENTER_EVENT(genMsg, nameMsg, aStack->evBlk, EVENT_Delete_Enter, aStack->enter, id); ZOS_ProduceEvent(status, &aStack->evBlk); - CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, + CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, skipOperation); } @@ -3267,7 +3240,7 @@ sendExitEvent: goto deleteNextFile; } - /* Don't allow delete if the file is exclusive locked */ + /* Don't allow delete if the file is exclusive locked */ if ((nameMsg->curDataStream->NAMEDdenyReaderCount != 0) || (nameMsg->curDataStream->NAMEDdenyWriterCount != 0)) { @@ -3350,7 +3323,7 @@ sendExitEvent: } if ( !(deleteMsg->deleteFlags & zDELETE_KEEP_VFS_CACHE)) { - if ( COMN_LsaCleanupSetup(nameMsg->curDataStream, + if ( COMN_LsaCleanupSetup(nameMsg->curDataStream, /* cnt nameUniquifier,*/ &aStack->lsaInv) == zOK) { if (primaryBeast != NULL) @@ -3370,8 +3343,8 @@ sendExitEvent: { nameMsg->curFile->FILEattributes |= zFA_IMMEDIATE_PURGE; - status = BST_delete( genMsg, curDir, nameMsg->curDataStream, - primaryBeast, neighborBeast, xaction, FALSE, TRUE); + status = BST_delete( genMsg, curDir, nameMsg->curDataStream, + primaryBeast, neighborBeast, xaction, FALSE, TRUE); if ((status != zOK) && (nameMsg->curFile != NULL)) { @@ -3380,8 +3353,8 @@ sendExitEvent: } else { - status = BST_delete( genMsg, curDir, nameMsg->curDataStream, - primaryBeast, neighborBeast, xaction, FALSE, TRUE); + status = BST_delete( genMsg, curDir, nameMsg->curDataStream, + primaryBeast, neighborBeast, xaction, FALSE, TRUE); } @@ -3390,11 +3363,11 @@ sendExitEvent: (nameMsg->workNameType == zNTYPE_DELETED_FILE)) { DoPurgeDeletedDirectoryTree = TRUE; - } + } else { DoPurgeDeletedDirectoryTree = FALSE; - } + } currentTime = GetUTCTime(); if (!deletingExtAttr) @@ -3445,11 +3418,11 @@ sendExitEvent: if (DoPurgeDeletedDirectoryTree) { - /* We just tried to purge a deleted directory, but failed - * because the dir still contains other deleted files/dirs. - * Synchronously auto-purge each contained subfile first. - * We do this at this high level so that we can be outside of - * the original transaction, and so that we can start an + /* We just tried to purge a deleted directory, but failed + * because the dir still contains other deleted files/dirs. + * Synchronously auto-purge each contained subfile first. + * We do this at this high level so that we can be outside of + * the original transaction, and so that we can start an * individual transaction for every purge. */ ClearErrno(genMsg); @@ -3464,27 +3437,27 @@ sendExitEvent: if (hookType == PurgeFile_Hook) { CHECK_FSHOOKS_PURGE_EXIT(PurgeFile_Hook, &aStack->purgeParms, - genMsg, nameMsg); + genMsg, nameMsg); } else { CHECK_FSHOOKS_DELETE_EXIT(F3EraseFile_Hook, &aStack->eraseParms, - genMsg, nameMsg); + genMsg, nameMsg); } if (NEBEventInfo[EVENT_Delete_Exit].consumers) { - INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, + INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, EVENT_Delete_Exit, aStack->exit, id); ZOS_ProduceEvent(status,&aStack->evBlk); } RESERVE_RSRC(NAME_RESERVE); } - if (status != zOK) - { + if (status != zOK) + { goto cleanup_closedir; - } + } deleteCnt++; /*--------------------------------------------------------------------------- @@ -3521,17 +3494,17 @@ deleteNextFile: if (hookType == PurgeFile_Hook) { CHECK_FSHOOKS_PURGE_EXIT(PurgeFile_Hook, &aStack->purgeParms, - genMsg, nameMsg); + genMsg, nameMsg); } else { CHECK_FSHOOKS_DELETE_EXIT(F3EraseFile_Hook, &aStack->eraseParms, - genMsg, nameMsg); + genMsg, nameMsg); } if (NEBEventInfo[EVENT_Delete_Exit].consumers) { - INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, + INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, EVENT_Delete_Exit, aStack->exit, id); ZOS_ProduceEvent(status,&aStack->evBlk); } @@ -3644,7 +3617,7 @@ releaseDirectoryExit: { COMN_UnlatchAndRelease(&neighborBeast, XLATCHED); } - + if(primaryBeast) { COMN_UnlatchAndRelease(&primaryBeast, XLATCHED); @@ -3726,7 +3699,7 @@ STATUS COMN_PurgeDeletedDirectoryTree( */ X_LATCH(&PurgeDirLatch); - /* Lock the volume in an ACTIVE state so it can't be + /* Lock the volume in an ACTIVE state so it can't be * deactivated while we are actively purging this sub-tree. Note - This * lock is separate from the one put in on behalf of the nameMsg. That * extra lock is put in place because the CleanupNameMsg call unlocks it @@ -3782,9 +3755,9 @@ STATUS COMN_PurgeDeletedDirectoryTree( if (COMN_WildOpen(genMsg,&aStack->nameMsg,&searchMsg) != zOK) { goto cleanup_return; - } + } /*--------------------------------------------------------------------------- - * Read through the subtree, and delete every located file. Make a + * Read through the subtree, and delete every located file. Make a * separate transaction for each file. *---------------------------------------------------------------------------*/ genMsg->flags |= DO_NOT_SEND_FSHOOKS; @@ -3792,7 +3765,7 @@ STATUS COMN_PurgeDeletedDirectoryTree( while (COMN_WildRead(genMsg, &aStack->nameMsg, &searchMsg) == zOK) { /* If asked to skip the starting "delDir", check if we are there yet */ - if (skipDelDir) + if (skipDelDir) { if (aStack->nameMsg.curFile == delDir) { @@ -3816,7 +3789,7 @@ STATUS COMN_PurgeDeletedDirectoryTree( if (aStack->nameMsg.fileParentZid == curDir->FILEzid) { X_LATCH(&curDir->FILEbeastLatch); - } + } else { COMN_Release(&curDir); @@ -3846,7 +3819,7 @@ STATUS COMN_PurgeDeletedDirectoryTree( if(primaryBeast == NULL) { zASSERT("Primary beast has dissappeared" == NULL); - ForceSetErrno(genMsg, zERR_INTERNAL_DIRECTORY_ERROR); + ForceSetErrno(genMsg, zERR_INTERNAL_DIRECTORY_ERROR); UNX_LATCH(&curDir->FILEbeastLatch); break; } @@ -3857,7 +3830,7 @@ STATUS COMN_PurgeDeletedDirectoryTree( xaction = COMN_BeginXLocal(curDir); - if (BST_delete(genMsg, curDir, aStack->nameMsg.curDataStream, primaryBeast, + if (BST_delete(genMsg, curDir, aStack->nameMsg.curDataStream, primaryBeast, NULL, /*neighborBeast only applies to hardlinks */xaction, TRUE, TRUE) != zOK) { COMN_EndXLocal(curDir,&xaction); @@ -3865,9 +3838,9 @@ STATUS COMN_PurgeDeletedDirectoryTree( if(primaryBeast) { COMN_UnlatchAndRelease(&primaryBeast, XLATCHED); - } - + } + UNX_LATCH(&curDir->FILEbeastLatch); /* No need to unlatch/release the nameMsg beasts. The * cleanup will do that */ @@ -3951,9 +3924,9 @@ cleanup_return_noUnlock: else { STACK_FREE(); - return(zFAILURE); + return(zFAILURE); } -} +} /**************************************************************************** @@ -4008,7 +3981,7 @@ STATUS COMN_GetInfo( RTN_STATUS(zFAILURE); } - ASSERT_LATCH(&nameMsg->curFile->FILEbeastLatch); + ASSERT_LATCH(&nameMsg->curFile->FILEbeastLatch); /* If not a real datastream, make sure the namespace is valid for the volume */ if ((nameMsg->curDataStream == (NamedBeast_s *)nameMsg->curFile) && @@ -4145,7 +4118,7 @@ STATUS COMN_GetInfoByBeastPtr( } else { - infoMsg->ret_getInfo->std.zid = fileBeast->FILEzid; + infoMsg->ret_getInfo->std.zid = fileBeast->FILEzid; infoMsg->ret_getInfo->std.dataStreamZid = dataStreamBeast->NAMEDzid; if (infoMsg->ret_getInfo->infoVersion >= zINFO_VERSION_D) { @@ -4364,11 +4337,11 @@ STATUS COMN_Link( INIT_EVENT_ID_STATUS(id, aStack->exit.enterRetStatus); if (NEBEventInfo[EVENT_Link_Enter].consumers) { - INIT_LINK_ENTER_EVENT(genMsg, srcNameMsg, destNameMsg, aStack->evBlk, + INIT_LINK_ENTER_EVENT(genMsg, srcNameMsg, destNameMsg, aStack->evBlk, EVENT_Link_Enter, aStack->enter, id, destNameMsg->scanMsg.retUnicodeComp, linkMsg); - ZOS_ProduceEvent(status,&aStack->evBlk); - CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, + ZOS_ProduceEvent(status,&aStack->evBlk); + CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, error_cleanupExit); } /*--------------------------------------------------------------------------- @@ -4379,15 +4352,15 @@ STATUS COMN_Link( * different part of the tree, so we wont encounter a deadlock. *---------------------------------------------------------------------------*/ COMN_LATCH_NAMEMSG_BEASTS(destNameMsg,XLATCHED); - - if(srcNameMsg->curFile->FILEhardLinkZid == zINVALID_ZID) // if no initial shadow beast, we have to create one + + if(srcNameMsg->curFile->FILEhardLinkZid == zINVALID_ZID) // if no initial shadow beast, we have to create one { if(srcNameMsg->fileParentZid == destNameMsg->curFile->FILEzid) { primaryDir = destNameMsg->curFile; COMN_USE_BEAST(&primaryDir->FILEroot); /* Get a usecount on the primary directory beast */ } - else if ((primaryDir = COMN_LookupByZid(genMsg, srcNameMsg->curvol, + else if ((primaryDir = COMN_LookupByZid(genMsg, srcNameMsg->curvol, srcNameMsg->fileParentZid, XLATCHED, FALSE)) != NULL) { primaryDirIsLatched = TRUE; @@ -4420,7 +4393,7 @@ STATUS COMN_Link( zASSERT(srcNameMsg->hlFile == NULL); - srcNameMsg->hlFile = HL_doCreateHardLinkBeast( genMsg,(NamedBeast_s*)srcNameMsg->curFile, NULL, + srcNameMsg->hlFile = HL_doCreateHardLinkBeast( genMsg,(NamedBeast_s*)srcNameMsg->curFile, NULL, &srcNameMsg->curFile->FILEfirstParent, xaction); if(srcNameMsg->hlFile == NULL) { @@ -4433,7 +4406,7 @@ STATUS COMN_Link( /* Fill in srcNameMsg so it will be unlatch/released later */ zASSERT(srcNameMsg->hlParentZid == zINVALID_ZID); - srcNameMsg->hlParentZid = srcNameMsg->curFile->FILEfirstParentZid; + srcNameMsg->hlParentZid = srcNameMsg->curFile->FILEfirstParentZid; pentry = &srcNameMsg->hlFile->HARDLfirstParent; // the names were moved from the inode firstParentEntry to the hlFile at hlBeast creation time removeNameFlags = NF_FIRST_NAME; @@ -4451,7 +4424,7 @@ STATUS COMN_Link( nentry->p.name, nsFlag); if(srcNameMsg->curFile->FILEcomnOps.BST_removeNameFromDirectory( - genMsg, srcNameMsg->curFile->FILEzid, + genMsg, srcNameMsg->curFile->FILEzid, (NamedBeast_s*)primaryDir, nentry->p.nameSpaceMask, pentry->p.nameType, nentry->p.name, removeNameFlags, xaction, pentry->t) != zOK) @@ -4461,11 +4434,11 @@ STATUS COMN_Link( } if (srcNameMsg->curFile->FILEcomnOps.BST_addNameToDirectory(genMsg, - (NamedBeast_s*)srcNameMsg->hlFile, + (NamedBeast_s*)srcNameMsg->hlFile, (NamedBeast_s*)primaryDir, nentry->p.nameSpaceMask, - pentry->p.nameType, nentry->p.name, + pentry->p.nameType, nentry->p.name, nsFlag, removeNameFlags, - MA_ATTR_SET_MASK(srcNameMsg->curFile->FILEattributes), + MA_ATTR_SET_MASK(srcNameMsg->curFile->FILEattributes), xaction, pentry->t) != zOK) { zASSERT("Error adding name to directory in HardLInk upgrade. Now what?" == NULL); @@ -4495,12 +4468,12 @@ STATUS COMN_Link( COMN_MARK_BEAST_XLOCAL((RootBeast_s*)primaryDir, xaction); COMN_ForceBeastWrite(genMsg, primaryDir, xaction); COMN_MARK_BEAST_XLOCAL((RootBeast_s*)srcNameMsg->curFile, xaction); - COMN_ForceBeastWrite(genMsg, srcNameMsg->curFile, xaction); + COMN_ForceBeastWrite(genMsg, srcNameMsg->curFile, xaction); COMN_MARK_BEAST_XLOCAL((RootBeast_s*)srcNameMsg->hlFile, xaction); - COMN_ForceBeastWrite(genMsg, srcNameMsg->hlFile, xaction); + COMN_ForceBeastWrite(genMsg, srcNameMsg->hlFile, xaction); } - - if((hlBeast = HL_doCreateHardLinkBeast(genMsg,(NamedBeast_s*)srcNameMsg->curFile, + + if((hlBeast = HL_doCreateHardLinkBeast(genMsg,(NamedBeast_s*)srcNameMsg->curFile, (NamedBeast_s*)srcNameMsg->hlFile, NULL, xaction)) == NULL) { zASSERT("Could not HL_doCreateHardLinkBeast in COMN_Link. Now what?"==NULL); @@ -4511,7 +4484,7 @@ STATUS COMN_Link( /* now inserting the new name(s) into the new hardlink beast */ zASSERT(destNameMsg->workNameType == zNTYPE_FILE); - if (NAME_InsertAndMangleName(genMsg, hlBeast,srcNameMsg->curFile, + if (NAME_InsertAndMangleName(genMsg, hlBeast,srcNameMsg->curFile, destNameMsg->curFile, destNameMsg->workNameSpaceID, destNameMsg->workNameType, destNameMsg->scanMsg.retUnicodeComp, INSNAMEFL_NEW_PARENT_AUTH, xaction, NULL, NULL) != zOK) @@ -4561,11 +4534,11 @@ STATUS COMN_Link( COMN_UNLATCH_NAMEMSG_BEASTS(destNameMsg, &destLatchType); Ptr_lsa_invalidate_dentry(&aStack->lsaInv); } - } + } } COMN_UnlatchAndRelease(&hlBeast, XLATCHED); - + status = zOK; sendExitEvent: if (NEBEventInfo[EVENT_Link_Exit].consumers) @@ -4658,7 +4631,7 @@ STATUS COMN_ModifyInfo( goto cleanup_error; } - ASSERT_XLATCH(&nameMsg->curFile->FILEbeastLatch); + ASSERT_XLATCH(&nameMsg->curFile->FILEbeastLatch); /* Check if the volume is READ-ONLY */ if (nameMsg->curvol->VOLenabledAttributes & zATTR_READONLY) @@ -4670,7 +4643,7 @@ STATUS COMN_ModifyInfo( /* If the file is in the salvage system, then don't allow modifications */ if (nameMsg->retParseFlags & NAMRETPFL_hasDeletedNameType) { - SetErrno(genMsg, zERR_ALL_FILES_READ_ONLY); + SetErrno(genMsg, zERR_ALL_FILES_READ_ONLY); goto cleanup_error; } @@ -4678,13 +4651,13 @@ STATUS COMN_ModifyInfo( (infoMsg->modifyInfo->std.fileAttributesModMask & MA_VALID_MASK)) { /* One or more of the zFA_HIDDEN, zFA_SYSTEM, or zFA_SUBDIRECTORY bit - * is being changed in the file attributes. This requires a + * is being changed in the file attributes. This requires a * corresponding update to the matchAttributes that are stored in * the directory (nametree). These two updates must not get out of * sync or we have problems. Because of this, we create a transaction * and tie the two updates together. */ - modifyMatchAttr = TRUE; + modifyMatchAttr = TRUE; } if (!COMN_IgnoreDoNotModifyMask) { @@ -4727,7 +4700,7 @@ STATUS COMN_ModifyInfo( if (NEBEventInfo[EVENT_ModifyInfo_Enter].consumers) { - INIT_ENTER_EVENT(genMsg, nameMsg, aStack->evBlk, + INIT_ENTER_EVENT(genMsg, nameMsg, aStack->evBlk, EVENT_ModifyInfo_Enter, aStack->enter, id); INIT_MODIFY_ENTER_EVENT(infoMsg, aStack->enter); ZOS_ProduceEvent(status,&aStack->evBlk); @@ -4749,7 +4722,7 @@ STATUS COMN_ModifyInfo( /* Get a pointer to the curent directory for use in the xaction */ COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); - if ((curDir = COMN_LookupByZid(genMsg, nameMsg->curvol, + if ((curDir = COMN_LookupByZid(genMsg, nameMsg->curvol, nameMsg->fileParentZid, XLATCHED, TRUE)) == NULL) { status = zFAILURE; @@ -4770,7 +4743,7 @@ STATUS COMN_ModifyInfo( xaction = NULL; } - /* Check if the file is exclusive locked */ + /* Check if the file is exclusive locked */ if ((status == zOK) && (!(infoMsg->modifyFlags & MF_ALLOW_MODIFY_WITH_DENY_READ_WRITE)) && ((nameMsg->curDataStream->NAMEDdenyReaderCount != 0) || @@ -4787,8 +4760,8 @@ STATUS COMN_ModifyInfo( if (status == zOK) { /*--------------------------------------------------------------------------- - * Check for presence of BOTH zFA_COMPRESS_FILE_IMMEDIATELY and - * zFA_DO_NOT_COMPRESS_FILE. If both are here, clear the + * Check for presence of BOTH zFA_COMPRESS_FILE_IMMEDIATELY and + * zFA_DO_NOT_COMPRESS_FILE. If both are here, clear the * zFA_COMPRESS_FILE_IMMEDIATELY bit and continue on. This functionality * matches what occurs in the legacy file system. *---------------------------------------------------------------------------*/ @@ -4801,28 +4774,28 @@ STATUS COMN_ModifyInfo( /* 1/28/05 - This used to call BST_modifyInfo with curDataStream * which would get an error if the beast really was a datastream. - * You cannot modify info on a datastream anyway. Today, I'm + * You cannot modify info on a datastream anyway. Today, I'm * merging MSG_ModifyInfo back into COMN_ModifyInfo, and the only * functional difference was that MSG_ModifyInfo modified file info * even if it was a data stream that was open. This was changed to - * use curFile so we will modify file info if we are pointing at the + * use curFile so we will modify file info if we are pointing at the * datastream ... same functionality as current zAPI, and will * not break existing apps ... just allow them to do more. */ /* If this is a hardlink name, and they are modifying - * zMOD_PRIMARY_NAMESPACE or zMOD_DELETED_INFO, these both + * zMOD_PRIMARY_NAMESPACE or zMOD_DELETED_INFO, these both * need to be modified on the hard link beast itself. All other * modification need to be made to the primary "iNode" beast. * The only way to do this without changing the LSS interface * is to call BST_modifyInfo twice - Once for the hard link and * once for the rest. */ - if ((nameMsg->hlFile) && + if ((nameMsg->hlFile) && (infoMsg->modifyInfoMask & (zMOD_PRIMARY_NAMESPACE|zMOD_DELETED_INFO))) { hlInfoMask = infoMsg->modifyInfoMask & (zMOD_PRIMARY_NAMESPACE|zMOD_DELETED_INFO); - inodeInfoMask = infoMsg->modifyInfoMask & + inodeInfoMask = infoMsg->modifyInfoMask & ~(zMOD_PRIMARY_NAMESPACE|zMOD_DELETED_INFO); /* Modify some info using the hard link beast */ @@ -4924,12 +4897,12 @@ STATUS COMN_ModifyInfo( COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); RELEASE_RSRC(NAME_RESERVE); - CHECK_FSHOOKS_MODIFY_EXIT(ModifyDirectoryEntry_Hook, &aStack->parms, - genMsg, nameMsg, infoMsg, &modifyVector); + CHECK_FSHOOKS_MODIFY_EXIT(ModifyDirectoryEntry_Hook, &aStack->parms, + genMsg, nameMsg, infoMsg, &modifyVector); if (NEBEventInfo[EVENT_ModifyInfo_Exit].consumers) { - INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, + INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, EVENT_ModifyInfo_Exit, aStack->exit, id); ZOS_ProduceEvent(status,&aStack->evBlk); } @@ -4979,26 +4952,26 @@ STATUS COMN_ModifyInfo( } genMsg->flags &= ~DO_NOT_SEND_FSHOOKS; - infoMsg->parentZid = + infoMsg->parentZid = nameMsg->hlFile ? nameMsg->hlParentZid : nameMsg->fileParentZid; INIT_EVENT_ID_STATUS(id, aStack->exit.enterRetStatus); - if (FSHOOKS_OR_EVENTS(ModifyDirectoryEntry_Hook, + if (FSHOOKS_OR_EVENTS(ModifyDirectoryEntry_Hook, EVENT_ModifyInfo_Enter)) { COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); RELEASE_RSRC(NAME_RESERVE); - CHECK_FSHOOKS_MODIFY_ENTER(ModifyDirectoryEntry_Hook, &aStack->parms, - status, skipOperation, genMsg, nameMsg, + CHECK_FSHOOKS_MODIFY_ENTER(ModifyDirectoryEntry_Hook, &aStack->parms, + status, skipOperation, genMsg, nameMsg, infoMsg, &modifyVector); if (NEBEventInfo[EVENT_ModifyInfo_Enter].consumers) { - INIT_ENTER_EVENT(genMsg, nameMsg, aStack->evBlk, + INIT_ENTER_EVENT(genMsg, nameMsg, aStack->evBlk, EVENT_ModifyInfo_Enter, aStack->enter, id); INIT_MODIFY_ENTER_EVENT(infoMsg, aStack->enter); ZOS_ProduceEvent(status,&aStack->evBlk); - CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, + CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, skipOperation); } @@ -5015,7 +4988,7 @@ STATUS COMN_ModifyInfo( /* Get a pointer to the curent directory for use in the xaction */ COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); - if ((curDir = COMN_LookupByZid(genMsg, nameMsg->curvol, + if ((curDir = COMN_LookupByZid(genMsg, nameMsg->curvol, nameMsg->fileParentZid, XLATCHED, TRUE)) == NULL) { status = zFAILURE; @@ -5036,7 +5009,7 @@ STATUS COMN_ModifyInfo( xaction = NULL; } - /* For now, just check if the file is exclusive locked */ + /* For now, just check if the file is exclusive locked */ if ((status == zOK) && (!(infoMsg->modifyFlags & MF_ALLOW_MODIFY_WITH_DENY_READ_WRITE)) && ((nameMsg->curDataStream->NAMEDdenyReaderCount != 0) || @@ -5055,8 +5028,8 @@ STATUS COMN_ModifyInfo( if (status == zOK) { /*--------------------------------------------------------------------------- - * Check for presence of BOTH zFA_COMPRESS_FILE_IMMEDIATELY and - * zFA_DO_NOT_COMPRESS_FILE. If both are here, clear the + * Check for presence of BOTH zFA_COMPRESS_FILE_IMMEDIATELY and + * zFA_DO_NOT_COMPRESS_FILE. If both are here, clear the * zFA_COMPRESS_FILE_IMMEDIATELY bit and continue on. This functionality * matches what occurs in the legacy file system. *---------------------------------------------------------------------------*/ @@ -5067,7 +5040,7 @@ STATUS COMN_ModifyInfo( infoMsg->modifyInfo->std.fileAttributes &= ~zFA_COMPRESS_FILE_IMMEDIATELY; } /* If this is a hardlink name, and they are modifying - * zMOD_PRIMARY_NAMESPACE or zMOD_DELETED_INFO, these both + * zMOD_PRIMARY_NAMESPACE or zMOD_DELETED_INFO, these both * need to be modified on the hard link beast itself. All other * modification need to be made to the primary "iNode" beast. * The only way to do this without changing the LSS interface @@ -5079,12 +5052,12 @@ STATUS COMN_ModifyInfo( /* Force this to go through the hardlink to the inode NOW */ COMN_Lookup(genMsg,nameMsg); } - if ((nameMsg->hlFile) && + if ((nameMsg->hlFile) && (infoMsg->modifyInfoMask & (zMOD_PRIMARY_NAMESPACE|zMOD_DELETED_INFO))) { hlInfoMask = infoMsg->modifyInfoMask & (zMOD_PRIMARY_NAMESPACE|zMOD_DELETED_INFO); - inodeInfoMask = infoMsg->modifyInfoMask & + inodeInfoMask = infoMsg->modifyInfoMask & ~(zMOD_PRIMARY_NAMESPACE|zMOD_DELETED_INFO); /* Modify some info using the hard link beast */ @@ -5140,7 +5113,7 @@ STATUS COMN_ModifyInfo( if (status != zOK) { STATUS status2; - + inodeInfoMask = infoMsg->modifyInfoMask; infoMsg->modifyInfoMask = zMOD_FILE_ATTRIBUTES; infoMsg->modifyInfo->std.fileAttributes = oldFileAttributes; @@ -5183,12 +5156,12 @@ STATUS COMN_ModifyInfo( COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); RELEASE_RSRC(NAME_RESERVE); - CHECK_FSHOOKS_MODIFY_EXIT(ModifyDirectoryEntry_Hook, &aStack->parms, - genMsg, nameMsg, infoMsg, &modifyVector); + CHECK_FSHOOKS_MODIFY_EXIT(ModifyDirectoryEntry_Hook, &aStack->parms, + genMsg, nameMsg, infoMsg, &modifyVector); if (NEBEventInfo[EVENT_ModifyInfo_Exit].consumers) { - INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, + INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, EVENT_ModifyInfo_Exit, aStack->exit, id); ZOS_ProduceEvent(status,&aStack->evBlk); } @@ -5213,7 +5186,7 @@ STATUS COMN_ModifyInfo( modifyCnt++; doNextModify: - /* reset the nameMessage back to a search pattern type for the + /* reset the nameMessage back to a search pattern type for the * next loop of WildRead */ if (COMN_ResetNameMsgToSearchPattern(genMsg,nameMsg) != zOK) goto cleanup_closedir; @@ -5275,7 +5248,7 @@ cleanup_closedir: COMN_WildClose(genMsg,&aStack->srchMsg); cleanup_error: - status = zFAILURE; + status = zFAILURE; goto justReturn; /*** Comes from fshooks and events already released resources **/ @@ -5297,23 +5270,23 @@ void resumeOpen( zASSERT((waiting->state & OPEN_WAITING) != 0); waiting->state |= OPEN_RESUMING; - + if (QMEMBER(&waiting->link)) { DQ_RMV(waiting, link); } - waiting->xaction->waitFor = NULL; + waiting->xaction->waitFor = NULL; waiting->xaction = NULL; - + waiting->openResumeCallback(&waiting); - + return; -} +} void cancelOpen( OpenWaiting_s **candidate) -{ +{ OpenWaiting_s *waiting = *candidate; ASSERT_MPKNSS_LOCK(); @@ -5323,8 +5296,8 @@ void cancelOpen( waiting->state |= OPEN_CANCELLED; if (waiting->state & OPEN_RESUMING) - { - /* The thread who is resuming open will check this flag + { + /* The thread who is resuming open will check this flag * and close the file if it is set */ return; @@ -5335,13 +5308,13 @@ void cancelOpen( DQ_RMV(waiting, link); } - waiting->xaction->waitFor = NULL; + waiting->xaction->waitFor = NULL; waiting->xaction = NULL; waiting->openResumeCallback(candidate); } - + /************************************************************************** * Common internal interface to OPEN a file ***************************************************************************/ @@ -5363,7 +5336,7 @@ STATUS COMN_Open( NINT fixUpSnapReaders = 0; BYTE fhState = 0; FileHandle_s *fh; - Zid_t rightsCheckParentZid; + Zid_t rightsCheckParentZid; typedef struct Stack_s { @@ -5422,36 +5395,36 @@ STATUS COMN_Open( goto cleanup_freeOpenFileAndReturn; } - ASSERT_XLATCH(&nameMsg->curFile->FILEbeastLatch); - ASSERT_XLATCH(&nameMsg->curDataStream->NAMEDbeastLatch); + ASSERT_XLATCH(&nameMsg->curFile->FILEbeastLatch); + ASSERT_XLATCH(&nameMsg->curDataStream->NAMEDbeastLatch); requestedRights = (openMsg->requestedRights & (zRR_READ_ACCESS | zRR_WRITE_ACCESS)) ? 0 : zRR_PREVENT_FS_HOOKS; INIT_EVENT_ID_STATUS(id, aStack->exit.enterRetStatus); - if (!(requestedRights & zRR_PREVENT_FS_HOOKS) && + if (!(requestedRights & zRR_PREVENT_FS_HOOKS) && FSHOOKS_OR_EVENTS(OpenFile_Hook, EVENT_Open_Enter)) { COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); RELEASE_RSRC(NAME_RESERVE); - CHECK_FSHOOKS_OPEN_ENTER(OpenFile_Hook, &aStack->parms, status, - cleanup_freeOpenFileExit, genMsg, nameMsg, + CHECK_FSHOOKS_OPEN_ENTER(OpenFile_Hook, &aStack->parms, status, + cleanup_freeOpenFileExit, genMsg, nameMsg, openMsg, retFileHandle); if (NEBEventInfo[EVENT_Open_Enter].consumers) { - INIT_ENTER_EVENT(genMsg, nameMsg, aStack->evBlk, EVENT_Open_Enter, + INIT_ENTER_EVENT(genMsg, nameMsg, aStack->evBlk, EVENT_Open_Enter, aStack->enter, id); INIT_OPEN_ENTER_EVENT(aStack->enter, openMsg); ZOS_ProduceEvent(status,&aStack->evBlk); - CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, + CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, cleanup_freeOpenFileExit); } RESERVE_RSRC(NAME_RESERVE); COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); } - if (nameMsg->curDataStream->NAMEDcomnOps.BST_beastNotify(genMsg, + if (nameMsg->curDataStream->NAMEDcomnOps.BST_beastNotify(genMsg, &nameMsg->curDataStream->NAMEDroot, BST_NOTIFY_OPEN) != zOK) { goto cleanup_freeOpenFile; @@ -5506,7 +5479,7 @@ STATUS COMN_Open( rightsCheckParentZid = nameMsg->hlFile ? nameMsg->hlParentZid : nameMsg->fileParentZid; - if (requestedRights & (zRR_DELETE_FILE_ON_CLOSE | + if (requestedRights & (zRR_DELETE_FILE_ON_CLOSE | zRR_PURGE_IMMEDIATE_ON_CLOSE)) { if (((doRightsCheck) && @@ -5714,11 +5687,11 @@ cantWrite: } if (requestedRights & zRR_WRITE_ACCESS) { - /* + /* * To write compressed one must be writing to a NEW file and one - * must be requesting exclusive access. + * must be requesting exclusive access. */ - if (!(requestedRights & zRR_DENY_READ) || + if (!(requestedRights & zRR_DENY_READ) || !(requestedRights & zRR_DENY_WRITE)) { SetErrno(genMsg, zERR_ALL_FILES_READ_ONLY); @@ -5740,7 +5713,7 @@ cantWrite: goto cleanup_freeOpenFile; } } - + if (FH_OpenFile(genMsg, retFileHandle, nameMsg, fhState) != zOK) { goto cleanup_freeOpenFile; @@ -5755,12 +5728,12 @@ cantWrite: * we've done so far. * Note: The blocked open implementation is only targeted * for NFS LkMgr locking request (when locking request is - * conflicting with certain file handles' deny mode - * previously held by other CIFS/PC NFS/NLM clients). - * LkMgr's locking request should ONLY come throught + * conflicting with certain file handles' deny mode + * previously held by other CIFS/PC NFS/NLM clients). + * LkMgr's locking request should ONLY come throught * COMN_Open path. - */ - zASSERT(genMsg->saID == zSAGENT_NFS); + */ + zASSERT(genMsg->saID == zSAGENT_NFS); } goto cleanup_freeOpenFile; } @@ -5782,7 +5755,7 @@ cantWrite: fh->smap = SMAP_NewSearchMap(genMsg, nameMsg); fh->smap->options |= SMAPOPT_notReusable; } - + /* Perform compression-related processing */ if (!(nameMsg->curDataStream->NAMEDattributes & zFA_SUBDIRECTORY)) { @@ -5814,12 +5787,12 @@ cantWrite: } else if (CM_COMPRESSION_ENABLED(nameMsg->curvol)) { - BOOL keep_comp_version = + BOOL keep_comp_version = (((fh->grantedRights & zRR_LEAVE_FILE_COMPRESSED) || fh->parentIsImmCompress) ? TRUE : FALSE); - NINT access_mode = - (fh->grantedRights & zRR_WRITE_ACCESS) + NINT access_mode = + (fh->grantedRights & zRR_WRITE_ACCESS) ? CACHE_UPDATE : CACHE_READ; if (CM_prepareToAccessUncompFile(genMsg, nameMsg->curFile, @@ -5834,7 +5807,7 @@ cantWrite: else fh->grantedRights &= ~zRR_LEAVE_FILE_COMPRESSED; } } - + /* Set the accessed time. We no longer set accessed time on reads and * writes. It is only set when a file is opened or created */ { @@ -5854,7 +5827,7 @@ cantWrite: RELEASE_RSRC(NAME_RESERVE); /* Must release resources before read ahead */ /* For every open file, I want to make sure that: - * 1) There is an inode associated with this file. + * 1) There is an inode associated with this file. * This is to ensure that pages read and written will come from * the Linux cache. Without an inode this cannot happen. * Open can also happen from zOpen or zCreate. @@ -5867,7 +5840,7 @@ cantWrite: struct inode *fh_inode = NULL; BOOL needLsaInode = FALSE; - if (nameMsg->curFile->FILEroot.rb_inode) + if (nameMsg->curFile->FILEroot.rb_inode) { if (!(nameMsg->parseFlags & NAMPFL_noExtraInodeCount)) { @@ -5886,9 +5859,9 @@ cantWrite: { COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); fh_inode = Ptr_lsa_get_inode( - &nameMsg->curFile->FILEvolume->VOLvolumeID, + &nameMsg->curFile->FILEvolume->VOLvolumeID, nameMsg->curFile->FILEzid); - COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); + COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); } #if 0 // if (!(nameMsg->curFile->FILEroot.rb_inode) || @@ -5897,15 +5870,15 @@ cantWrite: // { // COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); // fh_inode = Ptr_lsa_get_inode( -// &nameMsg->curFile->FILEvolume->VOLvolumeID, +// &nameMsg->curFile->FILEvolume->VOLvolumeID, // nameMsg->curFile->FILEzid); -// COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); +// COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); // } #endif retFileHandle->ptr->fh_inode = fh_inode; } - if ( retFileHandle->ptr->dataStream->NAMEDbstState & BST_STATE_DIOMODE) + if ( retFileHandle->ptr->dataStream->NAMEDbstState & BST_STATE_DIOMODE) { NamedBeast_s *lDataStream = retFileHandle->ptr->dataStream; @@ -5923,12 +5896,12 @@ cantWrite: ** flush before tossing. Also we should only flush and toss ** user data and not metadata. **/ - + ASSERT_XLATCH(&lDataStream->NAMEDbeastLatch); cacheFlushAndTossMyCacheUserData(&lDataStream->NAMEDmycache); } } - else if ((requestedRights & zRR_READ_ACCESS) && + else if ((requestedRights & zRR_READ_ACCESS) && (retFileHandle->ptr->dataStream->NAMEDeof > 0)) { /**do read ahead if file is open for reading and is non zero in size**/ @@ -5943,7 +5916,7 @@ sendExitEvent: { COMN_UNLATCH_NAMEMSG_BEASTS(nameMsg, &latchType); - CHECK_FSHOOKS_OPEN_EXIT(OpenFile_Hook, &aStack->parms, genMsg, nameMsg, + CHECK_FSHOOKS_OPEN_EXIT(OpenFile_Hook, &aStack->parms, genMsg, nameMsg, openMsg, retFileHandle); if (NEBEventInfo[EVENT_Open_Exit].consumers) { @@ -6002,8 +5975,8 @@ cleanup_freeOpenFileExit: COMN_LATCH_NAMEMSG_BEASTS(nameMsg, latchType); STACK_FREE(); - RTN_STATUS(zFAILURE); - + RTN_STATUS(zFAILURE); + } @@ -6053,7 +6026,7 @@ STATUS COMN_SetDataSize( ENTER(TCOMMON, COMN_SetDataSize); /* Don't call ConnectionIsLoggedIn on this API */ - + if ((fileHandle = COMN_RESOLVE_FILEHANDLE(genMsg,fileHandleIDP)) == NULL) { status = zFAILURE; @@ -6079,14 +6052,14 @@ STATUS COMN_SetDataSize( goto justReturn; } -#if BLKNUM_64 IS_DISABLED +#if BLKNUM_64 IS_DISABLED if (newEOF > zMAX_FILE_SIZE) { SetErrno(genMsg,zERR_FILE_TOO_LARGE); status = zFAILURE; goto justReturn; } -#endif +#endif beast = &dataStream->NAMEDroot; if (setSizeFlags & zSETSIZE_COMPRESSED) @@ -6094,20 +6067,20 @@ STATUS COMN_SetDataSize( if ((fileHandle->grantedRights & zRR_ENABLE_IO_ON_COMPRESSED_DATA) && (fileHandle->grantedRights & zRR_WRITE_ACCESS) && // (fileHandle->compBeast != 0) && - /* No bits other than zSETSIZE_LOGICAL_ONLY + /* No bits other than zSETSIZE_LOGICAL_ONLY * and zSETSIZE_COMPRESSED are set */ - ((setSizeFlags & + ((setSizeFlags & ~(zSETSIZE_LOGICAL_ONLY|zSETSIZE_COMPRESSED)) == 0)) { X_LATCH(&dataStream->NAMEDbeastLatch); - if (CM_prepareToWriteCompFile(genMsg, &dataStream->NAMEDroot, + if (CM_prepareToWriteCompFile(genMsg, &dataStream->NAMEDroot, &fileHandle->compBeast) != zOK) { UNX_LATCH(&dataStream->NAMEDbeastLatch); status = zFAILURE; goto justReturn; } - beast = fileHandle->compBeast; + beast = fileHandle->compBeast; UNX_LATCH(&beast->ROOTbeastLatch); UNX_LATCH(&dataStream->NAMEDbeastLatch); } @@ -6154,8 +6127,8 @@ STATUS COMN_SetDataSize( * than physical EOF, which requires zATTR_SPARSE_FILES to be set */ if ((file->FILEvolume->VOLenabledAttributes & - (zATTR_PHYSICAL_EOF|zATTR_SPARSE_FILES)) != - (zATTR_PHYSICAL_EOF|zATTR_SPARSE_FILES)) + (zATTR_PHYSICAL_EOF|zATTR_SPARSE_FILES)) != + (zATTR_PHYSICAL_EOF|zATTR_SPARSE_FILES)) { /* Can't change just one of the EOF's unless the LSS supports both * sparse files and changing physical EOF independently */ @@ -6188,7 +6161,7 @@ STATUS COMN_SetDataSize( COMN_GetStorageInfo(genMsg, beast, &aStack->stInfo); curEOF = aStack->stInfo.physicalEOF; - /* We are using physical EOF. Some LSS's such as DOSFAT maintain + /* We are using physical EOF. Some LSS's such as DOSFAT maintain * a physical EOF on cluster boundaries rather than on NSS block * boundaries. In these LSS's, it is the responsibility of the LSS * to do the partial block expands when NEW NSS blocks are added to @@ -6222,7 +6195,7 @@ STATUS COMN_SetDataSize( INIT_EVENT_ID_STATUS(id, aStack->exit.enterRetStatus); if (NEBEventInfo[EVENT_SetDataSize_Enter].consumers) { - INIT_SIZE_ENTER_EVENT(genMsg, aStack->evBlk, EVENT_SetDataSize_Enter,aStack->enter, + INIT_SIZE_ENTER_EVENT(genMsg, aStack->evBlk, EVENT_SetDataSize_Enter,aStack->enter, fileHandle, setSizeFlags, curEOF, newEOF,id); ZOS_ProduceEvent(status,&aStack->evBlk); CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, justReturn); @@ -6244,7 +6217,7 @@ STATUS COMN_SetDataSize( */ /* * Ying - Nov 5, 2003. This section may not work correctly if file is - * compressed (curEOF is wrong if + * compressed (curEOF is wrong if * (setSizeFlags & zSETSIZE_NON_SPARSE_FILE) != 0). But Paul said * he preferred not to attemp to fix it unless something is proven * to be broken @@ -6292,42 +6265,42 @@ RetrySetDataSizeAgain: CM_COMPRESSION_ENABLED(beast->ROOTvolume)) { BOOL done = FALSE; - NINT grantedRights = 0; + NINT grantedRights = 0; - /* + /* * If file is not opened with zRR_ENABLE_IO_ON_COMPRESSED_DATA, * decompress file if: * 1. file has snapshot beast - * 2. or newEOF is not zero + * 2. or newEOF is not zero * 3. or set logical size only. */ if (((fileHandle->grantedRights & zRR_ENABLE_IO_ON_COMPRESSED_DATA) == 0) - && + && ( ((dataStream->NAMEDvolume->VOLenabledAttributes & zATTR_COW) && (fileHandle->fhState & FH_WRITE_SNAPSHOT) && (dataStream->NAMEDroot.fileSnapshotBeast != NULL)) - || (newEOF != 0 ) + || (newEOF != 0 ) || (setSizeFlags & zSETSIZE_LOGICAL_ONLY))) { - /* + /* * Note we don't pass in beast->ROOTeof as its decomp size. - * This is because here assess mode is CACHE_WRITE (can't use + * This is because here assess mode is CACHE_WRITE (can't use * CACHE_READ since this mode doesn't necessarily throw away - * compBeast, depending on the file idle interval), if decomp + * compBeast, depending on the file idle interval), if decomp * size is beast->ROOTeof, decomp routine thinks the write intends * to cover the whole data range - thus all compressed data will be * tossed away directly instead of decompressing it. * Hence we pass in beast->ROOTeof -1 as its decompress size. This way - * all data will be decompressed. This should work fine since - * if file is compressed, beast->ROOTeof has to be bigger than 8k. - */ + * all data will be decompressed. This should work fine since + * if file is compressed, beast->ROOTeof has to be bigger than 8k. + */ status = CM_uncompressFileRange(genMsg, beast, 0, - beast->ROOTeof - 1, CACHE_WRITE, XLATCHED, + beast->ROOTeof - 1, CACHE_WRITE, XLATCHED, 0, &grantedRights, TRUE, &done); - if (status != zOK) + if (status != zOK) { goto cleanup_error; - } + } } } @@ -6390,11 +6363,11 @@ RetrySetDataSizeAgain: aStack->startOffset = curEOF & (aStack->blockSize-1); aStack->lenToWrite = aStack->blockSize - aStack->startOffset; - totalBlks = 1 + ((aStack->lenToWrite >= aStack->totalLength) ? 0 : + totalBlks = 1 + ((aStack->lenToWrite >= aStack->totalLength) ? 0 : (1 + ((aStack->totalLength - aStack->lenToWrite - 1) >> beast->ROOTblkSizeShift))); flags = 0; - if (setSizeFlags & zSETSIZE_NO_ZERO_FILL) + if (setSizeFlags & zSETSIZE_NO_ZERO_FILL) { flags |= ALLOC_NO_ZERO_FILL; } @@ -6404,7 +6377,7 @@ RetrySetDataSizeAgain: } FILEBLK_IO_MSG_FLAG(aStack->io, beast, blkNum, totalBlks, ((aStack->startOffset != 0) ? CACHE_UPDATE : CACHE_WRITE), flags); - aStack->cblk = COMN_GetFileBlk(genMsg, &aStack->io); + aStack->cblk = COMN_GetFileBlk(genMsg, &aStack->io); if (aStack->cblk == NULL) { if (GetErrno(genMsg) == zERR_PURGED_SPACE_UNAVAILABLE) @@ -6433,11 +6406,11 @@ RetrySetDataSizeAgain: * No zeroing needs to be done in the EOF block, but * all allocated blocks beyond EOF need to be discarded */ blkNum = (curEOF + (aStack->blockSize-1)) >> dataStream->NAMEDblkSizeShift; - BST_truncate(&aStack->localGenMsg, beast, blkNum, -1, 0); /* ignore the error*/ - + BST_truncate(&aStack->localGenMsg, beast, blkNum, -1, 0); /* ignore the error*/ + /* After beast is truncated, its related compBeast is thrown away. * we need to decrement compBeast's useCount that we add in - * CM_prepareAccessCompFile + * CM_prepareAccessCompFile */ if (beast == &dataStream->NAMEDroot && fileHandle->compBeast) { @@ -6477,7 +6450,7 @@ RetrySetDataSizeAgain: /* Get file blk sets this whenever we allocate more than * one block to extend a file. Closing the file will truncate * it back to the logical eof. In this case we do not want - * that since we have done a set physical size only. + * that since we have done a set physical size only. */ beast->bstState &= ~BST_STATE_TRUNCATE_CLOSE; COMN_MARK_BEAST_DIRTY(beast); @@ -6527,7 +6500,7 @@ RetrySetDataSizeAgain: blkNum++; } - if (blkNum <= oldBlkNum) + if (blkNum <= oldBlkNum) { if ((dataStream->NAMEDvolume->VOLenabledAttributes & zATTR_COW) && (fileHandle->fhState & FH_WRITE_SNAPSHOT) && @@ -6545,11 +6518,11 @@ RetrySetDataSizeAgain: { //FixFixFix6 -- need to roll back this transaction goto cleanup_error; - } + } /* After beast is truncated, its related compBeast is thrown away. * we need to decrement compBeast's useCount that we add in - * CM_prepareAccessCompFile + * CM_prepareAccessCompFile */ if (beast == &dataStream->NAMEDroot && fileHandle->compBeast) { @@ -6617,7 +6590,7 @@ RetrySetDataSizeAgain: if (dataStream->NAMEDbstState & BST_STATE_DIOMODE) { - /** We absolutely want to do a BST_flush here, because we want to + /** We absolutely want to do a BST_flush here, because we want to ** guarantee that the metadata of the beast is committed when we ** do a setDataSize **/ @@ -6630,7 +6603,7 @@ RetrySetDataSizeAgain: sendExitEvent: if (NEBEventInfo[EVENT_SetDataSize_Exit].consumers) { - INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, + INIT_EXIT_EVENT(status, genMsg, aStack->evBlk, EVENT_SetDataSize_Exit, aStack->exit, id); INIT_SIZE_EXIT_EVENT(aStack->exit, newEOF); ZOS_ProduceEvent(status,&aStack->evBlk); @@ -6688,10 +6661,10 @@ STATUS COMN_GetPhysicalFileMap( msg.sys.status = zOK; msg.sys.owner = NULL; - msg.sys.door = (QUAD)(uintptr_t)&fileHandle->door; + msg.sys.door = &fileHandle->door; msg.sys.numDataAreas = 1; - msg.sys.data[MAP_DATA].start = (QUAD)(uintptr_t)mapMsg->ret_extentList; - msg.sys.data[MAP_DATA].length = mapMsg->extentListCount * + msg.sys.data[MAP_DATA].start = mapMsg->ret_extentList; + msg.sys.data[MAP_DATA].length = mapMsg->extentListCount * sizeof(zPhysicalExtent_s); msg.body.id.xid = 0; msg.body.id.internalFlags = 0; @@ -6701,8 +6674,8 @@ STATUS COMN_GetPhysicalFileMap( status = MSG_GetFileMap(&msg); - mapMsg->ret_endingOffset = msg.body.map.retEndingOffset; - mapMsg->ret_extentListCount = msg.body.map.retExtentListCount; + mapMsg->ret_endingOffset = msg.body.map.retEndingOffset; + mapMsg->ret_extentListCount = msg.body.map.retExtentListCount; if (status != zOK) { @@ -6770,7 +6743,7 @@ STATUS COMN_GetFileMap( case zFILEMAP_PHYSICAL: STACK_FREE(); RTN_STATUS (COMN_GetPhysicalFileMap(genMsg, mapMsg, fileHandle)); - + case zFILEMAP_ALLOCATION: break; @@ -6814,7 +6787,7 @@ STATUS COMN_GetFileMap( { decompressNoRights(beast, mapMsg->startingOffset, beast->ROOTeof); } - + if ((beast->ROOTvolume->VOLenabledAttributes & zATTR_COW) && (fileHandle->fhState & FH_READ_BACKUP) && ((fileSnapBeast = beast->fileSnapshotBeast) != NULL)) @@ -6850,7 +6823,7 @@ STATUS COMN_GetFileMap( /* FileMapBeast is a pointer to the real beast or the snapshot beast or * compressed beast. If we are getting information on compressed beast - * then there is no snapshot beast + * then there is no snapshot beast */ fileMapBeast = beast; @@ -6861,8 +6834,8 @@ STATUS COMN_GetFileMap( */ if (beast->bitCount == fileSnapBeast->bitCount) { - /* The whole filemap was copied to the snapshot beast, so - * all the info can be gotten from the snapshot beast + /* The whole filemap was copied to the snapshot beast, so + * all the info can be gotten from the snapshot beast */ fileMapBeast = fileSnapBeast; } @@ -6892,7 +6865,7 @@ STATUS COMN_GetFileMap( STACK_FREE(); RTN_STATUS(GetErrno(genMsg)); } - /* if processBothMaps is set, filemapbeast points to datastream */ + /* if processBothMaps is set, filemapbeast points to datastream */ if ((processBothMaps) && (fileMapBeast->eof < fileSnapBeast->eof)) { /* We got an EOF error on the original beast, but if it was @@ -6928,9 +6901,9 @@ STATUS COMN_GetFileMap( { /* Before we skip over the hole, we will look to make sure * it is not allocated in the snapshot beast. Since - * processBothMaps is set we know we are currently + * processBothMaps is set we know we are currently * processing the dataStream beast - */ + */ aStack->sBlkNum = nextOffset >> blockShift; aStack->sBlkCount = -aStack->extentList[idx]; for (aStack->blk = aStack->sBlkNum; aStack->blk < (aStack->sBlkNum + aStack->sBlkCount); aStack->blk++) @@ -6939,7 +6912,7 @@ STATUS COMN_GetFileMap( goto finished; if (fileMapBeast->ROOTcomnOps.BST_isBlockInBeast( - fileSnapBeast, aStack->blk)) + fileSnapBeast, aStack->blk)) { /* The block is allocated in the snapshot beast */ nextRetElem->offset = nextOffset; @@ -6959,7 +6932,7 @@ STATUS COMN_GetFileMap( startAdjustment = 0; } nextRetElem++; - /* inc the count, and if we just filled up the + /* inc the count, and if we just filled up the * callers buffer, get out now... */ if (++extentListCount == mapMsg->extentListCount) goto finished; @@ -6998,7 +6971,7 @@ continueProcessing: if ((fileMapBeast->bitMap != NULL) && (TST_BIT(fileMapBeast->bitMap, aStack->blk)) && (!(fileMapBeast->ROOTcomnOps. - BST_isBlockInBeast(fileSnapBeast, aStack->blk))) ) + BST_isBlockInBeast(fileSnapBeast, aStack->blk))) ) { /* There was a hole in the file when the copy * was made. We need to return hole info @@ -7104,7 +7077,7 @@ doneWithThisPiece:; if ((processBothMaps) && (fileMapBeast->eof < fileSnapBeast->eof)) { /* We need to continue to get info from the snapshot beast - * if orig beast is smaller than snapshot beast. + * if orig beast is smaller than snapshot beast. * The filemap of the snapshot beast will be complete from * the truncation point, so just set startBlock to nextBlock * and continue processing the snapshot file. @@ -7210,7 +7183,7 @@ STATUS SetupSnapshotBeast( xaction = COMN_BeginXLocal(snapBeast); SETUP_BEAST_DELETE_PURGE_LOG(&purgeLogMsg, snapBeast, NULL); - if (snapBeast->ROOTcomnVolOps.VOL_addPurgeLogEntry(genMsg, + if (snapBeast->ROOTcomnVolOps.VOL_addPurgeLogEntry(genMsg, volume, PLOG_BEAST_DELETE, &purgeLogMsg, xaction) != zOK) { COMN_EndXLocal(snapBeast, &xaction); diff --git a/src/nwnss/comn/common/comnIO.c b/src/nwnss/comn/common/comnIO.c index 8bff2df..257c59b 100644 --- a/src/nwnss/comn/common/comnIO.c +++ b/src/nwnss/comn/common/comnIO.c @@ -38,10 +38,8 @@ | 1. If a failure occures in a lower level, the buffer field in asyncio | is set to NULL. +-------------------------------------------------------------------------*/ -#if !defined(NSS_USERSPACE) #include #include -#endif #include #include @@ -50,14 +48,13 @@ #include #include #include -#include +#include #include #include #include #include #include #include -#include #include #include "zParams.h" @@ -74,6 +71,7 @@ #include "pssConfig.h" #include "comnLock.h" #include "comnDataStream.h" +#include "nssOSAPIs.h" #include "cmNSS.h" #include "fsmsg.h" #include "uxaction.h" @@ -82,27 +80,6 @@ #include "sbsMFL.h" #include "csaLease.h" -#include - -#ifdef NSS_USERSPACE -#include "NssPageRuntime.h" -#include "NssUaccessRuntime.h" -#ifdef SetStatusFromErrno -#undef SetStatusFromErrno -#define SetStatusFromErrno(_msg, _genMsg) \ - (SetStatus((_msg), GetErrno((_genMsg))), \ - ((_msg)->sys.where = (QUAD)(uintptr_t)((_genMsg)->errStatusSetter))) -#endif -#ifdef ClearStatus -#undef ClearStatus -#define ClearStatus(_msg) \ - (SetStatus((_msg), zOK), ((_msg)->sys.where = (QUAD)(uintptr_t)WHERE)) -#endif -typedef void (*comn_io_async_callback_t)(ADDR context, STATUS status, - NINT offset, NINT length, zBuffer_s *buffer); -typedef void (*comn_io_release_callback_t)(ADDR handle); -#endif - Histogram_s WriteHistogram = {0}; @@ -119,15 +96,15 @@ NINT BufferBlkNumOffset[(offsetof(PubBuffer_s, fileBlk) == offsetof(zBuffer_s, b void asyncReadFileBlk (Asyncio_s *asyncio) { RootBeast_s *beast = STRUCT(asyncio->mycache, RootBeast_s, ROOTmycache); - + ASSERT_MPKNSS_LOCK(); - WARN_MPKNSS_LOCK(); + WARN_MPKNSS_LOCK(); if (!isCached(asyncio, asyncio->action)) { FSM_PUSH(&asyncio->fsm, asyncio->action); beast->ROOTcomnOps.BST_asyncReadFileBlk(asyncio); } -} +} /* * asyncReadChunkDone finishes up the work started by asyncReadFileBlk @@ -147,7 +124,7 @@ void asyncReadChunkDone (Fsm_s *fsm) else { chunk->nc_handle = NULL; - SetStatus(AIO_CHAIN(&asyncio->io)->msg, asyncio->io.status); + SetStatus(AIO_CHAIN(&asyncio->io)->msg, asyncio->io.status); if (buffer) { CACHE_RELEASE(buffer); @@ -160,9 +137,9 @@ void asyncReadChunkDone (Fsm_s *fsm) /************************************************************************** * * Ying: Some of this routine's callers don't decompress file in advance, - * while some others do. So decompress file here for one more time. + * while some others do. So decompress file here for one more time. ***************************************************************************/ -Buffer_s *COMN_GetFileBlk( +Buffer_s *COMN_GetFileBlk( GeneralMsg_s *genMsg, IoMsg_s *io) { @@ -176,7 +153,7 @@ Buffer_s *COMN_GetFileBlk( decompressNoRights(io->beast, 0, io->beast->eof); } - buffer = cacheLookup( &io->beast->ROOTmycache, + buffer = cacheLookup( &io->beast->ROOTmycache, io->fileBlk, io->mode); if (buffer == NULL) { @@ -217,7 +194,7 @@ Buffer_s *WRITE_GetFileBlk( /************************************************************************** - * + * * This routine checks the cache for the blk requested. If it finds it * it returns it. Else it reads the block in. If the returned buffer is * a sparse blk buffer, then it gets the extent list to find the size @@ -248,7 +225,7 @@ Buffer_s *COMN_GetFileBlkOrHole( /* I don't think anybody call this code */ if (buffer == &CACHE_SparseBuffer) { - status = io->beast->ROOTcomnOps.BST_getExtentList(genMsg, io->beast, + status = io->beast->ROOTcomnOps.BST_getExtentList(genMsg, io->beast, io->fileBlk, 1, extentList, &numExtents, &nextBlk); if (status != zOK) @@ -256,7 +233,7 @@ Buffer_s *COMN_GetFileBlkOrHole( /* I don't think anybody call this code */ if (GetErrno(genMsg) == zERR_END_OF_FILE) { blockSize = 1 << io->beast->ROOTblkSizeShift; - *holeBlks = ((io->beast->ROOTeof + blockSize - 1) >> + *holeBlks = ((io->beast->ROOTeof + blockSize - 1) >> io->beast->ROOTblkSizeShift) - io->fileBlk; } else @@ -281,7 +258,7 @@ Buffer_s *COMN_GetFileBlkOrHole( /* I don't think anybody call this code */ /************************************************************************** - * + * * This routine checks the cache for the blk requested. If it finds it * it returns it. Else it reads the block in. If the returned buffer is * a sparse blk buffer, then it gets the extent list to find the size @@ -289,7 +266,7 @@ Buffer_s *COMN_GetFileBlkOrHole( /* I don't think anybody call this code */ * size in blocks. * ***************************************************************************/ -Buffer_s *COMN_GetFileBlkOrHoleWithExtent( +Buffer_s *COMN_GetFileBlkOrHoleWithExtent( GeneralMsg_s *genMsg, IoMsg_s *io, Blknum_t *holeBlks, @@ -312,7 +289,7 @@ Buffer_s *COMN_GetFileBlkOrHoleWithExtent( buffer = io->beast->ROOTcomnOps.BST_getFileBlk(genMsg, io); } - status = io->beast->ROOTcomnOps.BST_getExtentList(genMsg, io->beast, + status = io->beast->ROOTcomnOps.BST_getExtentList(genMsg, io->beast, io->fileBlk, 1, extentList, &numExtents, &nextBlk); if (status != zOK) @@ -321,7 +298,7 @@ Buffer_s *COMN_GetFileBlkOrHoleWithExtent( { zASSERT(buffer == &CACHE_SparseBuffer); blockSize = 1 << io->beast->ROOTblkSizeShift; - blks = ((io->beast->ROOTeof + blockSize - 1) >> + blks = ((io->beast->ROOTeof + blockSize - 1) >> io->beast->ROOTblkSizeShift) - io->fileBlk; } else @@ -352,7 +329,7 @@ Buffer_s *COMN_GetFileBlkOrHoleWithExtent( /************************************************************************** - * + * ***************************************************************************/ void AsyncReadWorkToDo (Fsm_s *fsm) { @@ -369,15 +346,15 @@ void AsyncReadWorkToDo (Fsm_s *fsm) /* Call the AsyncRead callback here */ - ((comn_io_async_callback_t)asyncio->aioData.asyncReadCallBack)(asyncio->aioData.callBackContext, + asyncio->aioData.asyncReadCallBack(asyncio->aioData.callBackContext, zOK, asyncio->aioData.offsetInBuffer, - asyncio->aioData.bytesRead, + asyncio->aioData.bytesRead, (zBuffer_s *)&asyncio->io.buffer->pBuf); } else { - ((comn_io_async_callback_t)asyncio->aioData.asyncReadCallBack)(asyncio->aioData.callBackContext, + asyncio->aioData.asyncReadCallBack(asyncio->aioData.callBackContext, asyncio->io.status, 0, 0, @@ -391,7 +368,7 @@ void AsyncRead_ReadBlkDone (FsmLite_s *fsm) { ASSERT_MPKNSS_LOCK(); - WORK_Schedule(fsm, (voidfunc_t)AsyncReadWorkToDo, (ADDR)NULL); + WORK_Schedule(fsm, AsyncReadWorkToDo, NULL); } /* @@ -408,7 +385,7 @@ STATUS COMN_StartAsyncRead (zNSSMsg_s *msg) BOOL useSnapshot = FALSE; ASSERT_MPKNSS_LOCK(); - + fileHandle = (FileHandle_s *)msg->sys.door; if ((fileHandle->grantedRights & zRR_READ_ACCESS) == 0) @@ -435,7 +412,7 @@ STATUS COMN_StartAsyncRead (zNSSMsg_s *msg) { msg->body.async.retEof = dataStream->NAMEDeof; } - /* + /* * Check for any locks (this is kind of silly because we * check again when we do the async read. But you do what * backwards compatibility expects. @@ -479,7 +456,7 @@ STATUS COMN_AsyncRead (zNSSMsg_s *msg) #endif ASSERT_MPKNSS_LOCK(); - + ++Inst.file.curFileReadCount; /* Global Number of Reads */ fileHandle = (FileHandle_s *)msg->sys.door; @@ -489,10 +466,10 @@ STATUS COMN_AsyncRead (zNSSMsg_s *msg) */ if (fileHandle->virtInfo != NULL) { - /* + /* * FixFixFix -- needs to be implemented when Paul finishes the I/O * path for the zAPIs - */ + */ SetStatus(msg, zERR_READ_FAILURE); return zFAILURE; } @@ -528,9 +505,9 @@ STATUS COMN_AsyncRead (zNSSMsg_s *msg) GeneralMsg_s genMsg; STATUS rc; BOOL done = FALSE; - + COMN_SETUP_GENERAL_MSG_NOSA( &genMsg); - + /* numBytes is not calculated using snapshot beast's (if exist) * eof. This is fine because the only situation (ideally) file * remains in compressed state happens when file is accessed for the @@ -538,7 +515,7 @@ STATUS COMN_AsyncRead (zNSSMsg_s *msg) * shouldn't have different eof than the original beast */ rc = CM_uncompressFileRange( &genMsg, beast, - startingOffset, numBytes, CACHE_READ, SLATCHED, 0, + startingOffset, numBytes, CACHE_READ, SLATCHED, 0, &fileHandle->grantedRights, FALSE, &done); if ((rc != zOK) || ! done) { @@ -546,7 +523,7 @@ STATUS COMN_AsyncRead (zNSSMsg_s *msg) return rc; } } - + if ((beast->ROOTvolume->VOLenabledAttributes & zATTR_COW) && (fileHandle->fhState & FH_READ_BACKUP) && ((fileSnapBeast = beast->fileSnapshotBeast) != NULL)) @@ -581,7 +558,7 @@ STATUS COMN_AsyncRead (zNSSMsg_s *msg) } msg->body.async.retActualBytes = numBytes; - /* + /* * Check for any locks */ if (!useSnapshot && HAS_BYTE_RANGE_LOCKS(dataStream)) @@ -639,11 +616,10 @@ STATUS COMN_AsyncRead (zNSSMsg_s *msg) /* Not in the cache -- Spin off async read request */ asyncio = getAsyncio(); INIT_AIO(asyncio, &readBeast->ROOTmycache, block, CACHE_READ); - INIT_AIO_ASYNCREAD((AioAsyncRead_s *)asyncio, - (voidfunc_t)(uintptr_t)msg->sys.callback, + INIT_AIO_ASYNCREAD((AioAsyncRead_s *)asyncio, msg->sys.callback, msg->body.async.callbackContext, offsetInBuffer, numBytes); - asyncio->action = (voidfunc_t)AsyncRead_ReadBlkDone; + asyncio->action = AsyncRead_ReadBlkDone; asyncReadFileBlk(asyncio); /** The call back AsyncRead_ReadBlkDone will UNLATCH the beast **/ } @@ -653,13 +629,12 @@ STATUS COMN_AsyncRead (zNSSMsg_s *msg) /* Call the callBack function */ ASSERT_SLATCH( &(buffer->agent.latch)); UNS_LATCH( &readBeast->ROOTbeastLatch); - ((comn_io_async_callback_t)(uintptr_t)msg->sys.callback)( - msg->body.async.callbackContext, + msg->sys.callback(msg->body.async.callbackContext, zOK, offsetInBuffer, numBytes, (zBuffer_s *)&buffer->pBuf); - } + } Inst.file.curBytesRead += numBytes; #ifndef __linux__ // LINUX_ConnMgr connectionNum = fileHandle->connID; @@ -667,19 +642,19 @@ STATUS COMN_AsyncRead (zNSSMsg_s *msg) conn->totalBytesRead += numBytes; #endif return zOK; -} +} PubBuffer_s *COMN_FastReadCache( - MyCache_s *mycache, - Blknum_t fileBlk) + MyCache_s *mycache, + Blknum_t fileBlk) { Buffer_s *buffer; ASSERT_MPKNSS_LOCK(); buffer = fastReadCache( mycache, fileBlk); return ((buffer == NULL) ? NULL : &buffer->pBuf); -} +} /************************************************************************** * Common internal interface to AsyncReleaseBuffer @@ -687,13 +662,13 @@ PubBuffer_s *COMN_FastReadCache( void COMN_AsyncReleaseBuffer( PubBuffer_s *pBuf ) { - Buffer_s *buffer; + Buffer_s *buffer; ASSERT_MPKNSS_LOCK(); zASSERT(pBuf); buffer = STRUCT(pBuf, Buffer_s, pBuf); CACHE_RELEASE(buffer); -} +} /************************************************************************** * Common internal interface to READ a dataStream @@ -702,18 +677,18 @@ void COMN_AsyncReleaseBuffer( void COMN_ReleaseChunks (zNSSMsg_s *msg) { - NSSChunk_s *chunk = (NSSChunk_s *)(uintptr_t)msg->sys.data[RW_DATA].start; + NSSChunk_s *chunk = msg->sys.data[RW_DATA].start; NSSChunk_s *last = &chunk[msg->body.read.numChunks]; for (; chunk < last; ++chunk) { if (chunk->nc_handle != NULL) { - ((comn_io_release_callback_t)chunk->nc_release)(chunk->nc_handle); + chunk->nc_release(chunk->nc_handle); chunk->nc_handle = NULL; } } -} +} STATUS MSG_ChunkyRead (zNSSMsg_s *msg) { @@ -733,7 +708,7 @@ STATUS MSG_ChunkyRead (zNSSMsg_s *msg) NINT totalBytes = 0; NINT numChunks = 0; NINT numBytes = msg->body.read.numBytes; - NSSChunk_s *chunk = (NSSChunk_s *)(uintptr_t)msg->sys.data[RW_DATA].start; + NSSChunk_s *chunk = msg->sys.data[RW_DATA].start; STATUS rc = zOK; RootBeast_s *readBeast; RootBeast_s *fileSnapBeast = NULL; @@ -745,7 +720,7 @@ STATUS MSG_ChunkyRead (zNSSMsg_s *msg) BOOL seqRead = FALSE; ASSERT_MPKNSS_LOCK(); - + ++Inst.file.curFileReadCount; /* Global Number of Reads */ msg->body.read.numChunks = 0; @@ -761,8 +736,8 @@ STATUS MSG_ChunkyRead (zNSSMsg_s *msg) if (numBytes == 0) { return zOK; - } - + } + RESERVE_RSRC(msg->body.read.maxChunks << 1); dataStream = fileHandle->dataStream; S_LATCH( &dataStream->NAMEDbeastLatch); @@ -816,8 +791,8 @@ STATUS MSG_ChunkyRead (zNSSMsg_s *msg) { numBytes = eof - offset; } - /* - * First check to see if lock queue is empty. + /* + * First check to see if lock queue is empty. */ if (!useSnapshot && HAS_BYTE_RANGE_LOCKS(dataStream)) { @@ -835,7 +810,7 @@ STATUS MSG_ChunkyRead (zNSSMsg_s *msg) bytesInBlk = (1 << shift) - blkoffset; numAsyncios = 0; - if ((block == fileHandle->lastBlkRead) || + if ((block == fileHandle->lastBlkRead) || (block == fileHandle->lastBlkRead + 1)) { seqRead = TRUE; @@ -857,7 +832,7 @@ STATUS MSG_ChunkyRead (zNSSMsg_s *msg) readBeast = beast; } chunk->nc_length = bytesInBlk; - chunk->nc_release = (voidfunc_t)cacheRelease; + chunk->nc_release = cacheRelease; chunk->nc_offset = blkoffset; buffer = fastReadCache( &readBeast->ROOTmycache, block); if (buffer == NULL) @@ -870,10 +845,10 @@ STATUS MSG_ChunkyRead (zNSSMsg_s *msg) SYNC_ADD(sync); asyncio = (AioChunk_s *)getAsyncio(); - INIT_AIO( &(asyncio->io), &readBeast->ROOTmycache, + INIT_AIO( &(asyncio->io), &readBeast->ROOTmycache, block, CACHE_READ); asyncio->chunk = chunk; - asyncio->io.action = (voidfunc_t)asyncReadChunkDone; + asyncio->io.action = asyncReadChunkDone; INIT_AIO_CHAIN( &(asyncio->io), &sync); ++numAsyncios; @@ -902,7 +877,7 @@ STATUS MSG_ChunkyRead (zNSSMsg_s *msg) msg->body.read.bytesRead = totalBytes; RELEASE_RSRC(msg->body.read.maxChunks << 1); fileHandle->lastBlkRead = block - 1; - if (seqRead && readBeast->ROOTvolume->readAheadBlocks) + if (seqRead && readBeast->ROOTvolume->readAheadBlocks) { fileHandle->readAheadBlk = block; asyncReadAhead(fileHandle); @@ -933,7 +908,7 @@ STATUS MSG_ChunkyRead (zNSSMsg_s *msg) conn = (**NW_connectionTable)[connectionNum]; conn->totalBytesRead += totalBytes; #endif - + COMN_Release( &beast); exit: @@ -957,9 +932,9 @@ unlatch: goto exit; } -/************************************************************************** - * Common internal interface to WRITE a dataStream - ***************************************************************************/ +/************************************************************************** + * Common internal interface to WRITE a dataStream + ***************************************************************************/ STATUS COMN_Write (zNSSMsg_s *msg) { GeneralMsg_s genMsg; // Get rid of this guy @@ -998,7 +973,7 @@ STATUS COMN_Write (zNSSMsg_s *msg) STACK_ALLOC(); ASSERT_MPKNSS_LOCK(); - + COMN_SETUP_GENERAL_MSG_NOSA( &genMsg); ++Inst.file.curFileWriteCount; /* Global Number of writes */ @@ -1020,7 +995,7 @@ STATUS COMN_Write (zNSSMsg_s *msg) aStack->startingOffset = msg->body.rw.startingOffset; aStack->numBytes = msg->body.rw.numBytes; - if ((aStack->startingOffset > zMAX_FILE_SIZE) || + if ((aStack->startingOffset > zMAX_FILE_SIZE) || ((aStack->startingOffset + aStack->numBytes) > zMAX_FILE_SIZE)) { SetStatus(msg, zERR_FILE_TOO_LARGE); @@ -1114,8 +1089,8 @@ RetryTheWholeWriteAgain: } } - /* - * First check to see if lock queue is empty. + /* + * First check to see if lock queue is empty. */ if (HAS_BYTE_RANGE_LOCKS(dataStream)) { @@ -1142,7 +1117,7 @@ RetryTheWholeWriteAgain: && CM_COMPRESSION_ENABLED(beast->ROOTvolume)) { status = CM_uncompressFileRange( &genMsg, beast, - aStack->startingOffset, aStack->numBytes, CACHE_UPDATE, XLATCHED, 0, + aStack->startingOffset, aStack->numBytes, CACHE_UPDATE, XLATCHED, 0, &fileHandle->grantedRights, TRUE, &done); if (status != zOK) @@ -1160,24 +1135,24 @@ RetryTheWholeWriteAgain: RELEASE_RSRC(WRITE_RESERVE); STACK_FREE(); return status; - } + } } aStack->blkOffset = aStack->startingOffset & MASK(0, beast->ROOTmycache.bufSizeShift); aStack->block = aStack->startingOffset >> beast->ROOTmycache.bufSizeShift; aStack->bytesInBlk = (1 << beast->ROOTmycache.bufSizeShift) - aStack->blkOffset; - numBlks = 1 + ((aStack->bytesInBlk >= aStack->numBytes) ? + numBlks = 1 + ((aStack->bytesInBlk >= aStack->numBytes) ? 0 : (1 + ((aStack->numBytes - aStack->bytesInBlk - 1) >> beast->ROOTmycache.bufSizeShift))); origNumBlks = numBlks; /* * The following code is to prevent small files from - * allocing ahead too far. + * allocing ahead too far. */ numBlks = numBlks + ( (aStack->block < Config.Storage.allocAhead) ? - aStack->block : Config.Storage.allocAhead ); + aStack->block : Config.Storage.allocAhead ); while (aStack->numBytes != 0) { @@ -1194,14 +1169,14 @@ RetryTheWholeWriteAgain: goto endWrite; } } - mode = (aStack->bytesInBlk == (1 << beast->ROOTmycache.bufSizeShift)) ? - CACHE_WRITE : CACHE_UPDATE; + mode = (aStack->bytesInBlk == (1 << beast->ROOTmycache.bufSizeShift)) ? + CACHE_WRITE : CACHE_UPDATE; FILEBLK_IO_MSG_FLAG(aStack->io, beast, aStack->block, numBlks, mode, (numBlks > origNumBlks) ? ALLOC_NUM_BLOCKS_IS_OPTIONAL : 0); buffer = WRITE_GetFileBlk(msg, &aStack->io); if (buffer == NULL) { - if ((numBlks + blksWritten) > origNumBlks) + if ((numBlks + blksWritten) > origNumBlks) { if ((GetStatus(msg) == zERR_OUT_OF_SPACE) || (GetStatus(msg) == zERR_PURGED_SPACE_UNAVAILABLE)) @@ -1266,7 +1241,7 @@ RetryTheWholeWriteAgain: state2 = file->FILEvolume->VOLenabledAttributes & zATTR_USER_TRANSACTION_ACTIVE; if(state1 && state2) -// if ((msg->body.id.xid != 0) && +// if ((msg->body.id.xid != 0) && // (file->FILEvolume->VOLenabledAttributes & // zATTR_USER_TRANSACTION_ACTIVE)); { @@ -1293,15 +1268,15 @@ RetryTheWholeWriteAgain: } mapBufferPage(buffer); MPKNSS_UNLOCK(); - /* The buffer passed to us can be from user space if we come + /* The buffer passed to us can be from user space if we come * through the VFS layer. */ if (copy_from_user( &(buffer->pBuf.data[aStack->blkOffset]), - &(((char *)(uintptr_t)msg->sys.data[RW_DATA].start)[bytesWritten]), + &(((char *)msg->sys.data[RW_DATA].start)[bytesWritten]), aStack->bytesInBlk) != 0) { printk("<1> copy_from_user got error in COMN_Write\n"); - } + } MPKNSS_LOCK(); unmapBufferPage(buffer); // MPKNSS_UNLOCK(); @@ -1309,7 +1284,7 @@ RetryTheWholeWriteAgain: // { // buffer->pBuf.data = kmap_atomic(buffer->b_page, KM_USER0); // memcpy( &(buffer->pBuf.data[aStack->blkOffset]), -// &(((char *)(uintptr_t)msg->sys.data[RW_DATA].start)[bytesWritten]), +// &(((char *)msg->sys.data[RW_DATA].start)[bytesWritten]), // aStack->bytesInBlk); // kunmap_atomic(buffer->pBuf.data, KM_USER0); // buffer->pBuf.data = NULL; @@ -1317,13 +1292,13 @@ RetryTheWholeWriteAgain: // else // { // memcpy( &(buffer->pBuf.data[aStack->blkOffset]), -// &(((char *)(uintptr_t)msg->sys.data[RW_DATA].start)[bytesWritten]), +// &(((char *)msg->sys.data[RW_DATA].start)[bytesWritten]), // aStack->bytesInBlk); // } // // MPKNSS_LOCK(); // ZOS_CMovFast( &(buffer->pBuf.data[aStack->blkOffset]), -// &(((char *)(uintptr_t)msg->sys.data[RW_DATA].start)[bytesWritten]), +// &(((char *)msg->sys.data[RW_DATA].start)[bytesWritten]), // aStack->bytesInBlk); CACHE_DIRTY_RELEASE(buffer); @@ -1397,7 +1372,7 @@ endWrite: if (! (file->FILEattributes & (zFA_ARCHIVE|zFA_ATTR_ARCHIVE))) { /* - * If this is the OFF-to-ON transition of the file archive bits, + * If this is the OFF-to-ON transition of the file archive bits, * add the file to the volume's Modified Files List (if any). */ SBS_markFileModified(file, zFA_ARCHIVE, 0); @@ -1415,7 +1390,7 @@ endWrite: if ((dataStream == (NamedBeast_s *)file) || (dataStream->NAMEDbeastClass->classID == zFTYPE_NAMED_DATA_STREAM)) { - /* Is a regular file or dataStream (not EA), set modifiedTime + /* Is a regular file or dataStream (not EA), set modifiedTime * and modifierID too */ file->FILEmodifiedTime = aStack->currentTime; file->FILEmodifiedDOSTime = INVALID_DOS_TIME; @@ -1445,7 +1420,7 @@ endWrite: { UNX_LATCH( &file->FILEbeastLatch); } - + STACK_FREE(); return status; } @@ -1472,7 +1447,7 @@ STATUS COMN_DirectReadFile (zNSSMsg_s *msg) return zFAILURE; } if ((fileHandle->grantedRights & zRR_READ_ACCESS) == 0) - { + { SetStatus(msg, zERR_NO_READ_PRIVILEGE); return zFAILURE; } @@ -1533,7 +1508,7 @@ STATUS COMN_DirectWriteFile (zNSSMsg_s *msg) return zFAILURE; } if ((fileHandle->grantedRights & zRR_WRITE_ACCESS) == 0) - { + { SetStatus(msg, zERR_NO_WRITE_PRIVILEGE); return zFAILURE; } @@ -1546,7 +1521,7 @@ STATUS COMN_DirectWriteFile (zNSSMsg_s *msg) } #if BLKNUM_64 IS_DISABLED - if ((startingOffset > zMAX_FILE_SIZE) || + if ((startingOffset > zMAX_FILE_SIZE) || ((startingOffset + numBytes) > zMAX_FILE_SIZE)) { SetStatus(msg, zERR_FILE_TOO_LARGE); @@ -1575,7 +1550,7 @@ STATUS COMN_DirectWriteFile (zNSSMsg_s *msg) if (! (file->FILEattributes & (zFA_ARCHIVE|zFA_ATTR_ARCHIVE))) { /* - * If this is the OFF-to-ON transition of the file archive bits, + * If this is the OFF-to-ON transition of the file archive bits, * add the file to the volume's Modified Files List (if any). */ X_LATCH( &file->FILEbeastLatch); @@ -1584,10 +1559,10 @@ STATUS COMN_DirectWriteFile (zNSSMsg_s *msg) } else file->FILEattributes |= zFA_ARCHIVE; - file->FILEmodifiedTime = + file->FILEmodifiedTime = file->FILEmetaDataModifiedTime = GetUTCTime(); - file->FILEmodifiedDOSTime = + file->FILEmodifiedDOSTime = file->FILEmetaDataModifiedDOSTime = INVALID_DOS_TIME; file->FILEmetaDataSeqNum++; @@ -1605,7 +1580,7 @@ STATUS COMN_DirectWriteFile (zNSSMsg_s *msg) if ((msg->body.dio.unitOffset + numUnits) >= eofUnit) { X_LATCH(&dataStream->NAMEDbeastLatch); - dataStream->NAMEDeof = + dataStream->NAMEDeof = (msg->body.dio.unitOffset + numUnits) << DIO_UNIT_SHIFT; COMN_MARK_BEAST_DIRTY(&dataStream->NAMEDroot); UNX_LATCH(&dataStream->NAMEDbeastLatch); @@ -1647,7 +1622,7 @@ STATUS COMN_SwitchToDirectFileMode ( { ++dataStream->NAMEDdioModeCount; } - return zOK; + return zOK; } dataStream->NAMEDbstState |= BST_STATE_DIOMODE; dataStream->NAMEDdioModeCount = 1; @@ -1676,9 +1651,9 @@ void asyncReadAheadDone (Fsm_s *fsm) } -/************************************************************************** +/************************************************************************** * - ***************************************************************************/ + ***************************************************************************/ void asyncContinueReadAhead (FsmLite_s *fsmLite) { Asyncio_s *aio = STRUCT(fsmLite,Asyncio_s,fsm.lite); @@ -1692,13 +1667,13 @@ void asyncContinueReadAhead (FsmLite_s *fsmLite) asyncReadAheadDone((Fsm_s *)fsmLite); return; } - aio->action = (voidfunc_t)asyncReadAheadDone; + aio->action = asyncReadAheadDone; asyncReadFileBlk(aio); } -/************************************************************************** +/************************************************************************** * - ***************************************************************************/ + ***************************************************************************/ static inline STATUS asyncReadAheadBlock( RootBeast_s *beast, Blknum_t blk) @@ -1722,15 +1697,15 @@ static inline STATUS asyncReadAheadBlock( return zOK; } -/************************************************************************** +/************************************************************************** * - ***************************************************************************/ + ***************************************************************************/ void asyncReadAhead (FileHandle_s *fileHandle) { RootBeast_s *beast = fileHandle->compBeast; NINT i; NINT readAheadBlocks; - + ASSERT_MPKNSS_LOCK(); if (beast == 0) @@ -1751,7 +1726,7 @@ void asyncReadAhead (FileHandle_s *fileHandle) readAheadBlocks = beast->ROOTvolume->readAheadBlocks; if ((fileHandle->readAheadBlk < 2) && (readAheadBlocks > 2)) { - /* At open and if the read ahead request is for the 1st block in the + /* At open and if the read ahead request is for the 1st block in the * file, then read ahead only 2 blocks, because the file read requests * may be random or may only be for the beginning of the file. * As more bytes are read from the file, the read call will determine @@ -1765,7 +1740,7 @@ void asyncReadAhead (FileHandle_s *fileHandle) /* * Don't read past end of file */ - if ((fileHandle->readAheadBlk + i) > + if ((fileHandle->readAheadBlk + i) > ((beast->eof - 1) >> beast->blkSizeShift)) { break; @@ -1775,7 +1750,7 @@ void asyncReadAhead (FileHandle_s *fileHandle) { continue; } - + if (asyncReadAheadBlock(beast, fileHandle->readAheadBlk + i) != zOK) { break; @@ -1785,9 +1760,9 @@ void asyncReadAhead (FileHandle_s *fileHandle) -/************************************************************************** - * Common internal interface to COPY data from one file to another. - ***************************************************************************/ +/************************************************************************** + * Common internal interface to COPY data from one file to another. + ***************************************************************************/ STATUS COMN_CopyFileToFile ( GeneralMsg_s *genMsg, FileIOMsg_s *srcFileIO, @@ -1796,7 +1771,7 @@ STATUS COMN_CopyFileToFile ( FileHandleIDP_s *dstFhIDP) { #define MAX_ALLOC_AHEAD 64 - FileHandle_s *srcFileHandle, *dstFileHandle; + FileHandle_s *srcFileHandle, *dstFileHandle; File_s *srcFile, *dstFile; NamedBeast_s *srcDataStream, *dstDataStream; RootBeast_s *srcBeast, *dstBeast; @@ -1817,18 +1792,18 @@ STATUS COMN_CopyFileToFile ( typedef struct Stack_s { IoMsg_s srcIO; IoMsg_s dstIO; - Blknum_t srcBlkNum; + Blknum_t srcBlkNum; Blknum_t dstBlkNum; - Blknum_t srcBlksExt; + Blknum_t srcBlksExt; Blknum_t totSrcBlksExt; Blknum_t srcHolesExt; - QUAD srcStartOffset; + QUAD srcStartOffset; QUAD dstStartOffset; - NINT srcBlkOffset; + NINT srcBlkOffset; NINT dstBlkOffset; - NINT srcDelta; + NINT srcDelta; NINT dstDelta; - NINT srcBlkSize; + NINT srcBlkSize; NINT dstBlkSize; } Stack_s; STACK_ALLOC(); @@ -1847,13 +1822,13 @@ STATUS COMN_CopyFileToFile ( return zFAILURE; } - if ((srcFileHandle->grantedRights & zRR_READ_ACCESS) == 0) + if ((srcFileHandle->grantedRights & zRR_READ_ACCESS) == 0) { SetErrno(genMsg, zERR_NO_READ_PRIVILEGE); STACK_FREE(); return zFAILURE; } - if ((dstFileHandle->grantedRights & zRR_WRITE_ACCESS) == 0) + if ((dstFileHandle->grantedRights & zRR_WRITE_ACCESS) == 0) { SetErrno(genMsg, zERR_NO_WRITE_PRIVILEGE); STACK_FREE(); @@ -1920,7 +1895,7 @@ STATUS COMN_CopyFileToFile ( { srcBeast = &srcDataStream->NAMEDroot; } - else + else { S_LATCH(&srcBeast->ROOTbeastLatch); } @@ -1948,30 +1923,30 @@ STATUS COMN_CopyFileToFile ( X_LATCH(&dstFile->FILEbeastLatch); } X_LATCH(&dstDataStream->NAMEDbeastLatch); - + if (srcBeast != &srcDataStream->NAMEDroot) { - if (CM_prepareToWriteCompFile(genMsg, + if (CM_prepareToWriteCompFile(genMsg, &dstDataStream->NAMEDroot, &dstFileHandle->compBeast) != zOK) { UNS_LATCH(&srcDataStream->NAMEDbeastLatch); UNS_LATCH(&srcBeast->ROOTbeastLatch); UNX_LATCH(&dstDataStream->NAMEDbeastLatch); - + RELEASE_RSRC(WRITE_RESERVE); } - + dstBeast = dstFileHandle->compBeast; ASSERT_XLATCH(&dstBeast->ROOTbeastLatch); } - else - { + else + { zASSERT(srcFileHandle->compBeast == NULL); dstBeast = &dstDataStream->NAMEDroot; /* Since IO will be performed on uncompBeast, release compBeast if there's one. * we need to decrement compBeast's useCount that we add in - * CM_prepareAccessCompFile + * CM_prepareAccessCompFile */ if (dstFileHandle->compBeast) { @@ -1992,7 +1967,7 @@ STATUS COMN_CopyFileToFile ( dstEOF = dstBeast->ROOTeof; if ((dstEOF > aStack->dstStartOffset) && ((aStack->dstStartOffset + bytesToCopy) > dstEOF)) { - truncBlk = (aStack->dstStartOffset + aStack->dstBlkSize - 1) >> + truncBlk = (aStack->dstStartOffset + aStack->dstBlkSize - 1) >> dstBeast->ROOTblkSizeShift; if (useSnapshot) { @@ -2012,15 +1987,15 @@ STATUS COMN_CopyFileToFile ( (dstFile->FILEdataStreamInfo != NULL)) { if ((dstFileHandle->dataStreamNameType == zNTYPE_DATA_STREAM) && - (dstFile->FILEdataStreamInfo->dataStream.count != + (dstFile->FILEdataStreamInfo->dataStream.count != DSI_COUNT_INVALID)) { dstFile->FILEdataStreamInfo->dataStream.dataSize -= (dstDataStream->NAMEDeof - dstEOF); } - else if ((dstFileHandle->dataStreamNameType == + else if ((dstFileHandle->dataStreamNameType == zNTYPE_EXTENDED_ATTRIBUTE) && - (dstFile->FILEdataStreamInfo->extAttr.count != + (dstFile->FILEdataStreamInfo->extAttr.count != DSI_COUNT_INVALID)) { dstFile->FILEdataStreamInfo->extAttr.dataSize -= @@ -2035,7 +2010,7 @@ STATUS COMN_CopyFileToFile ( COMN_MARK_BEAST_DIRTY(dstBeast); if (dstBeast != &dstDataStream->NAMEDroot) { - COMN_MARK_BEAST_DIRTY(&dstDataStream->NAMEDroot); + COMN_MARK_BEAST_DIRTY(&dstDataStream->NAMEDroot); } } @@ -2065,9 +2040,9 @@ STATUS COMN_CopyFileToFile ( { /* Uncompress the file if needed. */ done = FALSE; - + status = CM_uncompressFileRange(genMsg, srcBeast, - aStack->srcStartOffset, bytesToCopy, CACHE_READ, SLATCHED, 0, + aStack->srcStartOffset, bytesToCopy, CACHE_READ, SLATCHED, 0, &srcFileHandle->grantedRights, TRUE, &done); if (status != zOK) goto errorCleanupAndReturn; @@ -2079,14 +2054,14 @@ STATUS COMN_CopyFileToFile ( /* Uncompress the file if needed. */ done = FALSE; status = CM_uncompressFileRange(genMsg, dstBeast, - aStack->dstStartOffset, bytesToCopy, CACHE_UPDATE, XLATCHED, 0, + aStack->dstStartOffset, bytesToCopy, CACHE_UPDATE, XLATCHED, 0, &dstFileHandle->grantedRights, TRUE, &done); if (status != zOK) goto errorCleanupAndReturn; } - aStack->srcBlkOffset = aStack->srcStartOffset & (aStack->srcBlkSize -1); + aStack->srcBlkOffset = aStack->srcStartOffset & (aStack->srcBlkSize -1); aStack->dstBlkOffset = aStack->dstStartOffset & (aStack->dstBlkSize -1); aStack->srcBlkNum = aStack->srcStartOffset >> srcBeast->ROOTblkSizeShift; @@ -2105,7 +2080,7 @@ STATUS COMN_CopyFileToFile ( FILEBLK_IO_MSG(aStack->srcIO, srcBeast, aStack->srcBlkNum, 1, CACHE_READ); if (aStack->totSrcBlksExt == 0) { - srcBuf = COMN_GetFileBlkOrHoleWithExtent(genMsg, &aStack->srcIO, + srcBuf = COMN_GetFileBlkOrHoleWithExtent(genMsg, &aStack->srcIO, &aStack->srcHolesExt, &aStack->totSrcBlksExt); } else @@ -2114,7 +2089,7 @@ STATUS COMN_CopyFileToFile ( } if (aStack->srcBlksExt == 0) { - aStack->srcBlksExt = (aStack->totSrcBlksExt > MAX_ALLOC_AHEAD) ? + aStack->srcBlksExt = (aStack->totSrcBlksExt > MAX_ALLOC_AHEAD) ? MAX_ALLOC_AHEAD : aStack->totSrcBlksExt; } if (srcBuf == NULL) @@ -2132,7 +2107,7 @@ STATUS COMN_CopyFileToFile ( } if (useSnapshot) { - if (COMN_CopyTheBlockToSnapshot(genMsg, dstBeast, + if (COMN_CopyTheBlockToSnapshot(genMsg, dstBeast, aStack->dstBlkNum) != zOK) { status = zFAILURE; @@ -2140,7 +2115,7 @@ STATUS COMN_CopyFileToFile ( goto errorEndWrite; } } - mode = (aStack->dstDelta == aStack->dstBlkSize) ? CACHE_WRITE : CACHE_UPDATE; + mode = (aStack->dstDelta == aStack->dstBlkSize) ? CACHE_WRITE : CACHE_UPDATE; FILEBLK_IO_MSG_FLAG(aStack->dstIO,dstBeast,aStack->dstBlkNum,aStack->srcBlksExt,mode, ALLOC_NUM_BLOCKS_IS_OPTIONAL); @@ -2161,8 +2136,8 @@ STATUS COMN_CopyFileToFile ( srcBuf->pBuf.data = kmap_atomic(srcBuf->b_page, KM_USER1); srcUnMap = TRUE; } - memcpy( &dstBuf->pBuf.data[aStack->dstBlkOffset], - &srcBuf->pBuf.data[aStack->srcBlkOffset], aStack->dstDelta ); + memcpy( &dstBuf->pBuf.data[aStack->dstBlkOffset], + &srcBuf->pBuf.data[aStack->srcBlkOffset], aStack->dstDelta ); if (dstUnMap) { kunmap_atomic(dstBuf->pBuf.data, KM_USER0); @@ -2176,7 +2151,7 @@ STATUS COMN_CopyFileToFile ( srcUnMap = FALSE; } -// ZOS_CMovFast( &dstBuf->pBuf.data[aStack->dstBlkOffset], +// ZOS_CMovFast( &dstBuf->pBuf.data[aStack->dstBlkOffset], // &srcBuf->pBuf.data[aStack->srcBlkOffset], aStack->dstDelta ); CACHE_DIRTY_RELEASE(dstBuf); @@ -2189,7 +2164,7 @@ STATUS COMN_CopyFileToFile ( if (aStack->dstBlkOffset == 0) { aStack->dstBlkNum++; - } + } aStack->dstDelta = aStack->dstBlkSize - aStack->dstBlkOffset; } aStack->totSrcBlksExt--; @@ -2199,14 +2174,14 @@ STATUS COMN_CopyFileToFile ( else { /** Do hole processing **/ - /** This assumes that if a sparse file is being copied, the - ** the src file start offset and dst file start offsets are + /** This assumes that if a sparse file is being copied, the + ** the src file start offset and dst file start offsets are ** on similar block boundaries. **/ if (dstEOF < (aStack->dstBlkOffset + (aStack->dstBlkNum * aStack->dstBlkSize))) { aStack->dstBlkNum += aStack->srcHolesExt; - aStack->dstBlkOffset += (aStack->srcHolesExt * aStack->srcBlkSize); + aStack->dstBlkOffset += (aStack->srcHolesExt * aStack->srcBlkSize); aStack->dstBlkOffset = aStack->dstBlkOffset & (aStack->dstBlkSize -1); if (bytesToCopy > (aStack->srcHolesExt * aStack->srcBlkSize)) @@ -2231,7 +2206,7 @@ STATUS COMN_CopyFileToFile ( UP_LATCH(&dstBuf->agent.latch); if (dstBuf->pBuf.data == NULL) { - dstBuf->pBuf.data = + dstBuf->pBuf.data = kmap_atomic(dstBuf->b_page, KM_USER0); bzero(dstBuf->pBuf.data, aStack->dstBlkSize); kunmap_atomic(dstBuf->pBuf.data, KM_USER0); @@ -2269,14 +2244,14 @@ STATUS COMN_CopyFileToFile ( if (loops++ >> 4) { loops = 0; - + /* * Since we are about to down-latch, it will be possible for * beasts to be force-written to disk. Before allowing this, we * need to make sure that dstEOF is accurate so that an LSS which - * doesn't support physical EOF being separate from logical EOF + * doesn't support physical EOF being separate from logical EOF * (like DOSFAT) won't get confused. - * + * * Set new EOF if the datastream just grew. * If a compressed stream is being written, set the EOF of the original * stream to be the same as that of the compressed stream, so utilities like @@ -2290,15 +2265,15 @@ STATUS COMN_CopyFileToFile ( (dstFile->FILEdataStreamInfo != NULL)) { if ((dstFileHandle->dataStreamNameType == zNTYPE_DATA_STREAM) && - (dstFile->FILEdataStreamInfo->dataStream.count != + (dstFile->FILEdataStreamInfo->dataStream.count != DSI_COUNT_INVALID)) { dstFile->FILEdataStreamInfo->dataStream.dataSize += (dstEOF - dstDataStream->NAMEDeof); } - else if ((dstFileHandle->dataStreamNameType == + else if ((dstFileHandle->dataStreamNameType == zNTYPE_EXTENDED_ATTRIBUTE) && - (dstFile->FILEdataStreamInfo->extAttr.count != + (dstFile->FILEdataStreamInfo->extAttr.count != DSI_COUNT_INVALID)) { dstFile->FILEdataStreamInfo->extAttr.dataSize += @@ -2310,10 +2285,10 @@ STATUS COMN_CopyFileToFile ( dstDataStream->NAMEDeof = dstEOF; } - /** - ** Down grade the xlatch to shared latch so that if - ** monitor or other applications are waiting to get - ** info about this file they are not starved during + /** + ** Down grade the xlatch to shared latch so that if + ** monitor or other applications are waiting to get + ** info about this file they are not starved during ** large file copies. **/ @@ -2350,7 +2325,7 @@ STATUS COMN_CopyFileToFile ( X_LATCH(&dstDataStream->NAMEDbeastLatch); if (dstBeast != &dstDataStream->NAMEDroot) { - X_LATCH(&dstBeast->ROOTbeastLatch); + X_LATCH(&dstBeast->ROOTbeastLatch); } } @@ -2378,15 +2353,15 @@ errorEndWrite: (dstFile->FILEdataStreamInfo != NULL)) { if ((dstFileHandle->dataStreamNameType == zNTYPE_DATA_STREAM) && - (dstFile->FILEdataStreamInfo->dataStream.count != + (dstFile->FILEdataStreamInfo->dataStream.count != DSI_COUNT_INVALID)) { dstFile->FILEdataStreamInfo->dataStream.dataSize += (dstEOF - dstDataStream->NAMEDeof); } - else if ((dstFileHandle->dataStreamNameType == + else if ((dstFileHandle->dataStreamNameType == zNTYPE_EXTENDED_ATTRIBUTE) && - (dstFile->FILEdataStreamInfo->extAttr.count != + (dstFile->FILEdataStreamInfo->extAttr.count != DSI_COUNT_INVALID)) { dstFile->FILEdataStreamInfo->extAttr.dataSize += @@ -2405,7 +2380,7 @@ errorEndWrite: if (! (dstFile->FILEattributes & (zFA_ARCHIVE|zFA_ATTR_ARCHIVE))) { /* - * If this is the OFF-to-ON transition of the file archive bits, + * If this is the OFF-to-ON transition of the file archive bits, * add the file to the volume's Modified Files List (if any). */ SBS_markFileModified(dstFile, zFA_ARCHIVE, 0); @@ -2455,7 +2430,7 @@ errorCleanupAndReturn: * ***************************************************************************/ STATUS CreateSnapshotBitMap( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, RootBeast_s *beast) { NINT bitMapSize; @@ -2465,13 +2440,13 @@ STATUS CreateSnapshotBitMap( ASSERT_XLATCH(&beast->ROOTbeastLatch); /** Calculate the bitMapSize based on the size of the file. - ** EOF (in bytes) + blksize - 1 divided by blksize will give + ** EOF (in bytes) + blksize - 1 divided by blksize will give ** number of 4K blks. ** We need 1 bit for every 4K blk, so I add 7 and divide by 8 to ** get the number of Blks **/ - bitCount = (beast->eof + (1 << beast->blkSizeShift) - 1) >> + bitCount = (beast->eof + (1 << beast->blkSizeShift) - 1) >> beast->blkSizeShift; bitMapSize = (bitCount + BITS_PER_NINT - 1) >> NINTBITS; @@ -2532,11 +2507,11 @@ BOOL COMN_ReadSnapOrDontCopyToSnap( ASSERT_MPKNSS_LOCK(); ASSERT_LATCH(&beast->ROOTbeastLatch); - if ((bitNumber >= beast->bitCount) || + if ((bitNumber >= beast->bitCount) || (beast->bitMap == NULL) || - (beast->bitCount == beast->fileSnapshotBeast->bitCount)) + (beast->bitCount == beast->fileSnapshotBeast->bitCount)) { - return TRUE; + return TRUE; } return TST_BIT(beast->bitMap, bitNumber); } @@ -2612,7 +2587,7 @@ STATUS COMN_CopyTheBlockToSnapshot( srcBuf->pBuf.data = NULL; srcUnMap = FALSE; } - + // CMovFast(dstBuf->pBuf.data,srcBuf->pBuf.data,1 << beast->blkSizeShift); CACHE_DIRTY_RELEASE(dstBuf); @@ -2646,7 +2621,7 @@ STATUS COMN_CopyFilemapToSnapshot( /* Uncompress the file if needed. */ if (CM_COMPRESSION_ENABLED(beast->ROOTvolume)) { - status = decompressNoRights(beast, + status = decompressNoRights(beast, blkNum * (1 << beast->blkSizeShift), beast->ROOTeof); if (status != zOK) { @@ -2654,10 +2629,10 @@ STATUS COMN_CopyFilemapToSnapshot( } } - if ((blkNum == 0) && + if ((blkNum == 0) && (beast->bitCount > 0) && - (snapBeast->bitCount == 0) && - (COMN_IsDerivedFrom(beast->vol.volume, zFTYPE_ZLSS_VOL))) + (snapBeast->bitCount == 0) && + (COMN_IsDerivedFrom(beast->vol.volume, zFTYPE_ZLSS_VOL))) { X_LATCH(&snapBeast->ROOTbeastLatch); @@ -2668,7 +2643,7 @@ STATUS COMN_CopyFilemapToSnapshot( snapBeast->bitCount = beast->bitCount; if (beast->bitMap != NULL) { - memset(beast->bitMap, 0xff, + memset(beast->bitMap, 0xff, ((beast->bitCount + NINTMASK) >> NINTBITS)); } // cacheMoveMyCacheBufList(&snapBeast->mycache, &beast->mycache); @@ -2676,7 +2651,7 @@ STATUS COMN_CopyFilemapToSnapshot( UNX_LATCH(&snapBeast->ROOTbeastLatch); return status; } - + for (blk = blkNum; blk < beast->bitCount; blk++) { if (COMN_CopyTheBlockToSnapshot(genMsg, beast, blk) != zOK) @@ -2688,8 +2663,8 @@ STATUS COMN_CopyFilemapToSnapshot( } STATUS COMN_GetPhysicalSizeOfSnap( - GeneralMsg_s *genMsg, - RootBeast_s *beast, + GeneralMsg_s *genMsg, + RootBeast_s *beast, GetStorageInfo_s *getStorageInfo) { RootBeast_s *snapBeast; @@ -2737,11 +2712,11 @@ STATUS COMN_GetPhysicalSizeOfSnap( /* I'll lie and say that all the blocks to the logicalEOF of * the snapshot file are allocated */ - getStorageInfo->filePhysSize = - getStorageInfo->physicalEOF = + getStorageInfo->filePhysSize = + getStorageInfo->physicalEOF = ((QUAD)beast->bitCount) << beast->ROOTblkSizeShift; - getStorageInfo->metaDataPhysSize = - gSI1.metaDataPhysSize + gSI2.metaDataPhysSize; + getStorageInfo->metaDataPhysSize = + gSI1.metaDataPhysSize + gSI2.metaDataPhysSize; } return zOK; } diff --git a/src/nwnss/comn/common/comnLib.c b/src/nwnss/comn/common/comnLib.c index 5e42848..bca4edb 100644 --- a/src/nwnss/comn/common/comnLib.c +++ b/src/nwnss/comn/common/comnLib.c @@ -39,7 +39,6 @@ #include #include #include -#include #include "zParams.h" #include "comnPublics.h" @@ -50,15 +49,9 @@ #include "nameSpace.h" #include "adminVolume.h" #include "comnAuthorize.h" -/* userspace: nssRegistration.h not needed for this import */ +#include "nssRegistration.h" extern struct VersionInformation_s CMN_VersionInfo; -#ifndef NSSAPI_VERSION -#define NSSAPI_VERSION 0 -#endif -#ifndef NSS_DEBUG_STATE -#define NSS_DEBUG_STATE 0 -#endif /* @@ -457,7 +450,7 @@ STATUS COMN_GetName( if (pathSeparatorAdded) { if (gfnMsg->internalFlags & - GFN_NO_SEPARATOR_AFTER_VOLUME_COLON) + GFN_NO_SEPARATOR_AFTER_VOLUME_COLON) { lastWorkBuf += 1; workSizeLeft += 1; @@ -578,12 +571,12 @@ STATUS COMN_GetName( // * to add a change name space component */ // if (!(getNameMask & zGFN_INCLUDE_PATH)) // { -// /* If not returning a whole path, we dont have a +// /* If not returning a whole path, we dont have a // * terminator already inserted */ // if (workSizeLeft < 4) // goto error_BufTooSmall; // *(--lastWorkBuf) = 0; -// workSizeLeft -= 1; +// workSizeLeft -= 1; // } // else // { @@ -628,7 +621,7 @@ STATUS COMN_GetName( NSS_UNI_CONVERSION_NSPACE_DEFAULT, lastWorkBuf, retBufPtr,retBufSize) != zOK) { - goto error_exit; + goto error_exit; } gfnMsg->ret_getName->name = retBufPtr; break; @@ -684,8 +677,8 @@ error_exit: * a located beast on exit from the function. *****************************************************************************/ STATUS COMN_ResetNameMsgToSearchPattern( - GeneralMsg_s *genMsg, - NamingMsg_s *nameMsg) + GeneralMsg_s *genMsg, + NamingMsg_s *nameMsg) { ASSERT_MPKNSS_LOCK(); @@ -724,7 +717,7 @@ error_exit: /************************************************************************** * COMN_CleanupNameMsg * - * This function cleans up (releases) any open resources held by a naming + * This function cleans up (releases) any open resources held by a naming * message. * * It is currently looking at: diff --git a/src/nwnss/comn/common/comnLock.c b/src/nwnss/comn/common/comnLock.c index 483f88e..5a58087 100644 --- a/src/nwnss/comn/common/comnLock.c +++ b/src/nwnss/comn/common/comnLock.c @@ -56,16 +56,6 @@ #include "msgLock.h" #include "fsmsg.h" - -/* - * Imported NSS headers use old generic K&R callback typedefs such as - * voidfunc_t/boolfunc_t. Modern C modes treat those as zero-argument - * function pointers, so cast at the original callback call sites instead - * of changing the public imported headers. - */ -typedef BOOL (*NSS_LockDataCompareFunc)(ADDR, ADDR); -typedef void (*NSS_LockSaCallbackFunc)(voidfunc_t, ADDR, STATUS, NSSConnection_s *, NINT); - STATUS existingLock ( LockSet_s *lockSet, NamedBeast_s *beast, @@ -151,7 +141,7 @@ BOOL SET_DestroyLock (void *node) unlockByteRange(x, TRUE); return TRUE; -} +} void prLockDepth (int depth) { @@ -172,7 +162,7 @@ BOOL SET_DumpLock (void *node, NINT depth, ADDR msg) printf("byte-range state=%d start=%qd end=%qd\n", x->head.state, x->start, x->end); return TRUE; -} +} RBP_Tree_s SET_SetTree = RBP_INIT_TREE(SET_SetTree, SET_CompareLocks, @@ -245,7 +235,7 @@ BOOL START_DestroyLock (void *node) unlockByteRange(x, TRUE); return TRUE; -} +} BOOL START_DumpLock (void *node, NINT depth, ADDR msg) { @@ -256,7 +246,7 @@ BOOL START_DumpLock (void *node, NINT depth, ADDR msg) printf("byte-range start=%qd end=%qd\n", x->start, x->end); return TRUE; -} +} RBP_Tree_s START_HeldTree = RBP_INIT_TREE(START_HeldTree, START_CompareLocks, @@ -320,7 +310,7 @@ BOOL END_DestroyLock (void *node) unlockByteRange(x, TRUE); return TRUE; -} +} BOOL END_DumpLock (void *node, NINT depth, ADDR msg) { @@ -331,7 +321,7 @@ BOOL END_DumpLock (void *node, NINT depth, ADDR msg) printf("byte-range start=%qd end=%qd\n", x->start, x->end); return TRUE; -} +} RBP_Tree_s END_HeldTree = RBP_INIT_TREE(END_HeldTree, END_CompareLocks, @@ -346,7 +336,7 @@ void lockFailed (LockHeader_s *header, STATUS status); * Initialize a lock set. May not need the owner field. Can * use offset in UserXaction_s structure to get back to the * user transaction. - */ + */ void initLockSet (LockSet_s *lockSet) { extern void LOCK_WakeUp(); @@ -354,7 +344,7 @@ void initLockSet (LockSet_s *lockSet) ASSERT_MPKNSS_LOCK(); INIT_REPLY( &lockSet->reply); lockSet->setRoot = NULL; - lockSet->waiting = 0; + lockSet->waiting = 0; lockSet->saStatus = zOK; } @@ -374,11 +364,11 @@ void freeByteRangeLock (ByteRangeLock_s *lock) } if (lock->startHeld.p) { - RBP_Delete( &START_HeldTree, &lock->beast->startLocks, lock); - RBP_Delete( &END_HeldTree, &lock->beast->endLocks, lock); + RBP_Delete( &START_HeldTree, &lock->beast->startLocks, lock); + RBP_Delete( &END_HeldTree, &lock->beast->endLocks, lock); } zASSERT(DQ_EMPTY( &lock->head.waiters)); - + free(lock); } @@ -463,7 +453,7 @@ ByteRangeLock_s *allocByteRangeLock ( RTN_PTR(NULL); } } - INIT_LOCKHEAD( &(lock->head), lockSet, lockMsg->mode, + INIT_LOCKHEAD( &(lock->head), lockSet, lockMsg->mode, (lockMsg->callBack.waitTime == 0xFFFFFFFF) ? TRUE : FALSE); lock->fh = lockMsg->fh; lock->beast = lockMsg->beast; @@ -472,9 +462,9 @@ ByteRangeLock_s *allocByteRangeLock ( if (lock->end < lock->start) { lock->end = MAX_QUAD; - } + } lock->lockData = lockMsg->lockData; - RBP_Insert( &SET_SetTree, &lock->head.lockSet->setRoot, lock); + RBP_Insert( &SET_SetTree, &lock->head.lockSet->setRoot, lock); RTN_PTR(lock); } @@ -533,17 +523,17 @@ ByteRangeLock_s *MSG_allocByteRangeLock ( SetStatus(msg, zERR_BAD_PARAMETER_VALUE); return NULL; } - INIT_LOCKHEAD( &(lock->head), lockSet, mode, + INIT_LOCKHEAD( &(lock->head), lockSet, mode, (msg->body.rw.timeout == 0xFFFFFFFF) ? TRUE : FALSE); lock->beast = fh->dataStream; lock->fh = fh; lock->start = msg->body.rw.startingOffset; - lock->end = msg->body.rw.startingOffset + msg->body.rw.length; + lock->end = msg->body.rw.startingOffset + msg->body.rw.length; if (lock->end < lock->start) { lock->end = MAX_QUAD; } - RBP_Insert( &SET_SetTree, &lock->head.lockSet->setRoot, lock); + RBP_Insert( &SET_SetTree, &lock->head.lockSet->setRoot, lock); return lock; } @@ -578,23 +568,23 @@ ByteRangeLock_s *testLock( if (lockSet == lock->head.lockSet) { /* - * They have the same owner + * They have the same owner */ - if (semanticAgentID == zSAGENT_NFS) + if (semanticAgentID == zSAGENT_NFS) { - /* + /* * For locks held by NFS clients, * we don't allow locks to be overlapped * if they have the same owner */ - return lock; + return lock; } else { /* - * For locks held by NCP/CIFS clients, + * For locks held by NCP/CIFS clients, * they are compatible if they have the - * same owner. + * same owner. */ goto nextLock; } @@ -605,15 +595,15 @@ ByteRangeLock_s *testLock( * Locks are compatible so skip to next lock */ goto nextLock; - } - + } + /* This is conflicted with the requested lock */ return lock; nextLock: if (lock == endLock) { break; - } + } } return NULL; } @@ -629,22 +619,22 @@ BOOL checkDeadLock( UserXaction_s *tmpXaction; zASSERT(waiter->waitFor == NULL); - + if (waiter == holder) { return TRUE; } - + tmpXaction = holder; while (1) - { + { if (tmpXaction->waitFor == NULL) - { + { if (setWaitFor) { waiter->waitFor = holder; } - + return FALSE; } else if (tmpXaction->waitFor == waiter) @@ -654,12 +644,12 @@ BOOL checkDeadLock( } tmpXaction = tmpXaction->waitFor; } - -} + +} BOOL checkDeadLockByFH( - FileHandle_s *waiterFH, + FileHandle_s *waiterFH, FileHandle_s *holderFH, BOOL setWaitFor) { @@ -688,14 +678,14 @@ void clearXactionWaitForByFH( xaction = resolveXaction(zNILXID, fh, NULL, NULL, 0, FALSE); if (xaction == NULL) - { + { zASSERT(xaction == NULL); return; } - + xaction->waitFor = NULL; -} - +} + /* * If possible, lock the given byte range, otherwise return FALSE. */ @@ -717,8 +707,8 @@ STATUS lockByteRange ( { DQ_RMV(lock, head.waiting); } - - clearXactionWaitForByFH(lock->fh); + + clearXactionWaitForByFH(lock->fh); } /* * We have to scan each lock currently held by beast @@ -731,18 +721,18 @@ STATUS lockByteRange ( /* * We can't get this lock, queue up on it if it won't * cause deadlock. - */ + */ if (lock->head.waitForever) - { + { if (checkDeadLockByFH(lock->fh, holder->fh, TRUE)) { - DQ_ENQ( &holder->head.waiters, lock, head.waiting); + DQ_ENQ( &holder->head.waiters, lock, head.waiting); RTN_STATUS(zERR_DEAD_LOCK); } } - DQ_ENQ( &holder->head.waiters, lock, head.waiting); - + DQ_ENQ( &holder->head.waiters, lock, head.waiting); + RTN_STATUS(zERR_LOCK_COLLISION); } /* @@ -827,7 +817,7 @@ ByteRangeLock_s *findByteRangeLock (UnlockByteRangeMsg_s *unlockMsg) * locks under the same owner, and we support unlock * a subrange, we have to find a lock with * equal or greater range than the requested one. - * Then let the userFunc decides if this is the + * Then let the userFunc decides if this is the * right one */ if (unlockMsg->userFunc == NULL) @@ -842,7 +832,7 @@ ByteRangeLock_s *findByteRangeLock (UnlockByteRangeMsg_s *unlockMsg) if (unlockMsg->end == lock->end) { RTN_PTR(lock); - } + } lock = RBP_Succ( &SET_SetTree, lock); } RTN_PTR(NULL); @@ -857,14 +847,14 @@ ByteRangeLock_s *findByteRangeLock (UnlockByteRangeMsg_s *unlockMsg) { if ((lock->fh->semanticAgentID == zSAGENT_NFS) && (lock->end >= end)) { - if (((NSS_LockDataCompareFunc)unlockMsg->userFunc)(lock->lockData, unlockMsg->lockData)) + if (unlockMsg->userFunc(lock->lockData, unlockMsg->lockData)) { RTN_PTR(lock); } /* I suspect I could return NULL here because NFS locks * don't over lap */ - } + } lock = RBP_Succ( &SET_SetTree, lock); } RTN_PTR(NULL); @@ -906,17 +896,17 @@ ByteRangeLock_s *findByteRangeLockByStartingOffset ( lock = RBP_Succ( &SET_SetTree, lock); } return candidate; -} +} void wakeupLockRequests(ByteRangeLock_s *lock) -{ +{ ByteRangeLock_s *candidate; LockSet_s *candidateSet; UserXaction_s *userXaction; DQhead_t waiters; STATUS status; voidfunc_t saCallBack; - + /* * Take care of any locks waiting for this lock to be released. */ @@ -947,7 +937,7 @@ void wakeupLockRequests(ByteRangeLock_s *lock) */ CANCEL_ALARM(candidate->head.reply.alarm); - ((NSS_LockSaCallbackFunc)saCallBack)(candidate->head.reply.userCallBack, + saCallBack(candidate->head.reply.userCallBack, candidate->head.reply.userData, zOK, userXaction->task->master->nssConn, @@ -961,7 +951,7 @@ void wakeupLockRequests(ByteRangeLock_s *lock) */ if (--candidateSet->waiting == 0) { - + CANCEL_ALARM(candidateSet->reply.alarm); /* * I'd really just like to queue this up, @@ -969,7 +959,7 @@ void wakeupLockRequests(ByteRangeLock_s *lock) */ if (candidateSet->reply.saCallBack) { - ((NSS_LockSaCallbackFunc)candidateSet->reply.saCallBack)( + candidateSet->reply.saCallBack( candidateSet->reply.userCallBack, candidateSet->reply.userData, zOK, @@ -983,7 +973,7 @@ void wakeupLockRequests(ByteRangeLock_s *lock) else if (status == zERR_DEAD_LOCK) { CANCEL_ALARM(candidate->head.reply.alarm); - lockFailed( &candidate->head, zERR_DEAD_LOCK); + lockFailed( &candidate->head, zERR_DEAD_LOCK); } } } @@ -1010,8 +1000,8 @@ void unlockByteRange ( if (lock->head.state == LK_LOCKED) { zASSERT(lock->startHeld.p); - RBP_Delete( &START_HeldTree, &lock->beast->startLocks, lock); - RBP_Delete( &END_HeldTree, &lock->beast->endLocks, lock); + RBP_Delete( &START_HeldTree, &lock->beast->startLocks, lock); + RBP_Delete( &END_HeldTree, &lock->beast->endLocks, lock); } else if (lock->head.state == LK_WAITING) { @@ -1034,9 +1024,9 @@ void unlockByteRange ( * set know that all locks are taken care of. */ userXaction = STRUCT(lockSet, UserXaction_s, byteRangeLocks); - + CANCEL_ALARM(lockSet->reply.alarm); - ((NSS_LockSaCallbackFunc)lockSet->reply.saCallBack)(lockSet->reply.userCallBack, + lockSet->reply.saCallBack(lockSet->reply.userCallBack, lockSet->reply.userData, zOK, userXaction->task->master->nssConn, @@ -1049,9 +1039,9 @@ void unlockByteRange ( } } lock->head.state = LK_IDLE; - + wakeupLockRequests(lock); - + zASSERT(DQ_EMPTY( &lock->head.waiters)); if (clear) { @@ -1123,7 +1113,7 @@ void lockSetFailedWorkToDo (FsmLite_s *fsm) saCallBack = lockSet->reply.saCallBack; if (saCallBack) { - ((NSS_LockSaCallbackFunc)saCallBack)(lockSet->reply.userCallBack, + saCallBack(lockSet->reply.userCallBack, lockSet->reply.userData, zERR_LOCK_WAITING, userXaction->task->master->nssConn, @@ -1144,7 +1134,7 @@ void lockSetFailedTimeout (OneShot_s *alarm) * obtain but don't free any resources. */ - WORK_Schedule( &lockSet->reply.fsm, (voidfunc_t)lockSetFailedWorkToDo, 0); + WORK_Schedule( &lockSet->reply.fsm, lockSetFailedWorkToDo, 0); } /* @@ -1153,7 +1143,7 @@ void lockSetFailedTimeout (OneShot_s *alarm) void lockFailed ( LockHeader_s *header, STATUS status) -{ +{ UserXaction_s *userXaction = STRUCT(header->lockSet, UserXaction_s, byteRangeLocks); voidfunc_t saCallBack; @@ -1172,17 +1162,17 @@ void lockFailed ( if (header->sibling.p) { RBP_Delete( &SET_SetTree, &header->lockSet->setRoot, header); - } + } if (header->waitForever) - { + { clearXactionWaitForByFH(((ByteRangeLock_s *)header)->fh); } - + saCallBack = header->reply.saCallBack; if (saCallBack) { header->reply.saCallBack = NULL; - ((NSS_LockSaCallbackFunc)saCallBack)(header->reply.userCallBack, + saCallBack(header->reply.userCallBack, header->reply.userData, status, userXaction->task->master->nssConn, @@ -1206,7 +1196,7 @@ void lockFailedWorkToDo (FsmLite_s *fsm) } void lockFailedTimeout (OneShot_s *alarm) -{ +{ LockHeader_s *header = STRUCT(alarm, LockHeader_s, reply.alarm); if (header->state != LK_WAITING) @@ -1220,12 +1210,12 @@ void lockFailedTimeout (OneShot_s *alarm) if (header->sibling.p) { RBP_Delete( &SET_SetTree, &header->lockSet->setRoot, header); - } + } if (header->waitForever) - { + { clearXactionWaitForByFH(((ByteRangeLock_s *)header)->fh); } - WORK_Schedule( &header->reply.fsm, (voidfunc_t)lockFailedWorkToDo, 0); + WORK_Schedule( &header->reply.fsm, lockFailedWorkToDo, 0); } // /* @@ -1254,7 +1244,7 @@ void lockFailedTimeout (OneShot_s *alarm) // SetErrno(genMsg, zERR_ALREADY_WAITING_FOR_LOCK); // return zFAILURE; // } -// } +// } // return zOK; //} // @@ -1269,7 +1259,7 @@ void lockFailedTimeout (OneShot_s *alarm) // // /* // * Some of this code is just a wild guess but it is -// * reasonable. +// * reasonable. // */ // if (lockMsg->mode == LK_EXCLUSIVE) // { @@ -1323,7 +1313,7 @@ void lockFailedTimeout (OneShot_s *alarm) // status = lockByteRange(lock); // if (status == zOK) // { -// lockMsg->callBack.saCallBack(lockMsg->callBack.userCallBack, +// lockMsg->callBack.saCallBack(lockMsg->callBack.userCallBack, // lockMsg->callBack.userData, // zOK, // genMsg->pssConn.ptr, @@ -1342,17 +1332,17 @@ void lockFailedTimeout (OneShot_s *alarm) // } // else // { /* -// * Didn't want to wait for lock or a deadlock is detected, +// * Didn't want to wait for lock or a deadlock is detected, // * call back with error // */ // DQ_RMV(lock, head.waiting); -// RBP_Delete( &SET_SetTree, &lock->head.lockSet->setRoot, lock); -// +// RBP_Delete( &SET_SetTree, &lock->head.lockSet->setRoot, lock); +// // freeByteRangeLock(lock); -// /* +// /* // * Sent zERR_LOCK_COLLISION instead of zERR_DEAD_LOCK here // * so that semantic agent call tell and do correct cleanup -// * when dead lock is detected later on when lock is being +// * when dead lock is detected later on when lock is being // * waken up // */ // lockMsg->callBack.saCallBack(lockMsg->callBack.userCallBack, @@ -1457,7 +1447,7 @@ STATUS COMN_LockByteRange ( if (saCallBack) { lockMsg->callBack.saCallBack = NULL; - ((NSS_LockSaCallbackFunc)saCallBack)(lockMsg->callBack.userCallBack, + saCallBack(lockMsg->callBack.userCallBack, lockMsg->callBack.userData, zOK, genMsg->pssConn.ptr, @@ -1477,21 +1467,21 @@ STATUS COMN_LockByteRange ( } else { /* - * Didn't want to wait for lock or a deadlock is detected, + * Didn't want to wait for lock or a deadlock is detected, * call back with error */ freeByteRangeLock(lock); - /* + /* * Sent zERR_LOCK_COLLISION instead of zERR_DEAD_LOCK here * so that semantic agent call tell and do correct cleanup - * when dead lock is detected later on when lock is being + * when dead lock is detected later on when lock is being * waken up */ saCallBack = lockMsg->callBack.saCallBack; if (saCallBack) { lockMsg->callBack.saCallBack = NULL; - ((NSS_LockSaCallbackFunc)saCallBack)(lockMsg->callBack.userCallBack, + saCallBack(lockMsg->callBack.userCallBack, lockMsg->callBack.userData, zERR_LOCK_COLLISION, genMsg->pssConn.ptr, @@ -1509,7 +1499,7 @@ error: if (saCallBack) { lockMsg->callBack.saCallBack = NULL; - ((NSS_LockSaCallbackFunc)saCallBack)(lockMsg->callBack.userCallBack, + saCallBack(lockMsg->callBack.userCallBack, lockMsg->callBack.userData, GetErrno(genMsg), genMsg->pssConn.ptr, @@ -1566,7 +1556,7 @@ STATUS COMN_LockByteRangeSet ( */ if (setMsg->callBack.saCallBack) { - ((NSS_LockSaCallbackFunc)setMsg->callBack.saCallBack)(setMsg->callBack.userCallBack, + setMsg->callBack.saCallBack(setMsg->callBack.userCallBack, setMsg->callBack.userData, zOK, userXaction->task->master->nssConn, @@ -1607,7 +1597,7 @@ STATUS COMN_LockByteRangeSet ( */ if (setMsg->callBack.saCallBack) { - ((NSS_LockSaCallbackFunc)setMsg->callBack.saCallBack)(setMsg->callBack.userCallBack, + setMsg->callBack.saCallBack(setMsg->callBack.userCallBack, setMsg->callBack.userData, zERR_LOCK_COLLISION, genMsg->pssConn.ptr, @@ -1772,7 +1762,7 @@ BOOL LOCK_IsExclusiveByteRange ( } /* - * Called by NFS writers to see if any NCP/CIFS clients held + * Called by NFS writers to see if any NCP/CIFS clients held * a byte range lock for the the range of byte being written. */ BOOL LOCK_IsExclusiveByteRangeMandatory ( @@ -1806,7 +1796,7 @@ BOOL LOCK_IsExclusiveByteRangeMandatory ( goto nextLock; } if (lock->fh->semanticAgentID == zSAGENT_NFS) - { + { /* * NFS locks are only advisory */ @@ -1817,7 +1807,7 @@ nextLock: if (lock == endLock) { break; - } + } } /* * No confilicts with any of the existing locks. @@ -1831,9 +1821,9 @@ nextLock: * on a beast -- used when closing a file. */ void COMN_BeastUnlockByteRange ( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamedBeast_s *beast, - FileHandle_s *fileHandle) /** The file Handle can only be NULL if genMsg + FileHandle_s *fileHandle) /** The file Handle can only be NULL if genMsg ** is also NULL **/ { @@ -1888,7 +1878,7 @@ typedef struct LockCallback_s } LockCallback_s; void MSG_LockByteRangeCallBack ( - voidfunc_t callBack, + voidfunc_t callBack, ADDR userData, STATUS status, NSSConnection_s *nssConn, @@ -1920,7 +1910,7 @@ STATUS MSG_LockByteRange (zNSSMsg_s *msg) return zFAILURE; } - status = lockByteRange(lock); + status = lockByteRange(lock); if (status == zOK) { return zOK; @@ -1937,13 +1927,13 @@ STATUS MSG_LockByteRange (zNSSMsg_s *msg) lcb.threadID = ThreadId(); lock->head.state = LK_WAITING; - lock->head.reply.saCallBack = (voidfunc_t)MSG_LockByteRangeCallBack; + lock->head.reply.saCallBack = MSG_LockByteRangeCallBack; lock->head.reply.userCallBack = NULL; lock->head.reply.userData = (ADDR)&lcb; msecOneShot( &lock->head.reply.alarm, msg->body.rw.timeout, lockFailedTimeout); Wait(); - return lcb.status; + return lcb.status; } else { /* @@ -1968,7 +1958,7 @@ STATUS MSG_UnlockByteRange (zNSSMsg_s *msg) ASSERT_MPKNSS_LOCK(); if (xid != zNILXID) - { + { /* * Locks on a user specified transaction can * only be released by ending the transaction. @@ -2062,16 +2052,16 @@ void LOCK_Shutdown(void) * msecs -- amount of time to wait to acquire the lock in millisecs * If set to 0, will not wait for the lock. * If set to -1, will wait until lock is acquired. - * Return values: - * LOCKED TRUE + * Return values: + * LOCKED TRUE * NOT_LOCKED FALSE * ***************************************************************************/ Lock_s *COMN_LookupLock( - BYTE *key, - NINT keyBytes, - BOOL allocIfNotThere) + BYTE *key, + NINT keyBytes, + BOOL allocIfNotThere) { LONG hashIndex; DQhead_t *head; @@ -2096,7 +2086,7 @@ Lock_s *COMN_LookupLock( DQ_FOREACH(head, lock, Lock_s, hashLink) { - if ((lock->keyLen == keyBytes) && + if ((lock->keyLen == keyBytes) && (memcmp(key, lock->key, keyBytes) == 0)) { return lock; @@ -2113,10 +2103,10 @@ Lock_s *COMN_LookupLock( /* Check to see if somebody else already got this lock and put it on * the hash */ - + DQ_FOREACH(head, lock, Lock_s, hashLink) { - if ((lock->keyLen == keyBytes) && + if ((lock->keyLen == keyBytes) && (memcmp(key, lock->key, keyBytes) == 0)) { objCacheFree(newLock); @@ -2136,7 +2126,7 @@ Lock_s *COMN_LookupLock( BOOL COMN_LockFunc( BYTE *key, NINT keyBytes, - NINT mode, + NINT mode, SLONG msecs) { @@ -2202,7 +2192,7 @@ BOOL COMN_LockFunc( default: { /* Wait for msecs to get a lock */ - /* FixFixFix6: Add this functionality when logical lock APIs + /* FixFixFix6: Add this functionality when logical lock APIs * implemented */ zASSERT("Timed locks not implemented yet" == NULL); @@ -2214,7 +2204,7 @@ BOOL COMN_LockFunc( } void COMN_UnLockFunc( - BYTE *key, + BYTE *key, NINT keyBytes) { Lock_s *lock; diff --git a/src/nwnss/comn/common/comnLog.c b/src/nwnss/comn/common/comnLog.c index 8ae11de..1c083db 100644 --- a/src/nwnss/comn/common/comnLog.c +++ b/src/nwnss/comn/common/comnLog.c @@ -34,10 +34,13 @@ | This module is used to: | NSSLOG routines that are aware of Common Layer specific structures. +-------------------------------------------------------------------------*/ +#include + #include #include #include +#include "nssOSAPIs.h" #include "comnPublics.h" #include "volume.h" #include "nssLog.h" @@ -293,3 +296,6 @@ STATUS NSSLOG_EventLog( } /* End of NSSLOG_EventLog() */ #endif + + + diff --git a/src/nwnss/comn/common/comnLookup.c b/src/nwnss/comn/common/comnLookup.c index 68786b6..0f3348f 100644 --- a/src/nwnss/comn/common/comnLookup.c +++ b/src/nwnss/comn/common/comnLookup.c @@ -33,7 +33,7 @@ |--------------------------------------------------------------------------- | This module is used to: | This contains the top level internal file interfaces. All external - | interfaces call these routines. + | interfaces call these routines. +-------------------------------------------------------------------------*/ #include @@ -58,13 +58,13 @@ #include "macNSpace.h" /***** fixfixfix@nextMediaFormatChange begin *******/ -/* At the next media format change, only the extended Mac namespace will - * will be supported at the volume level. Compatibilty with the - * 31 char legacy namespace will be accomplished only with the +/* At the next media format change, only the extended Mac namespace will + * will be supported at the volume level. Compatibilty with the + * 31 char legacy namespace will be accomplished only with the * zid-mangling algorithm (see comnMacShortName.c) */ /**************************************************************************** * RevalidateFirstMacComponent - * + * * This function is temporary until we get a media format changes. It is * used to handle cases where we are parsing MAC names that can be either * 31 or 255 characters in length, but we didn't know the limit when the @@ -72,13 +72,13 @@ * for its maximum length based on the current volume settings. *****************************************************************************/ STATIC STATUS RevalidateFirstMacComponent ( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamingMsg_s *nameMsg) { if (nameMsg->curvol) { - if (nameMsg->curvol->p.enabledAttributes & zATTR_EXTENDED_MAC_NAMESPACE) + if (nameMsg->curvol->p.enabledAttributes & zATTR_EXTENDED_MAC_NAMESPACE) { return zOK; /* don't need to check */ } @@ -90,7 +90,7 @@ STATIC STATUS RevalidateFirstMacComponent ( { if (nameMsg->scanMsg.retScanFlags & NSRETSFL_componentIsAscii) { - if (nameMsg->scanMsg.retAsciiCompLen > MACNS_LEGACY_NAME_LIMIT) + if (nameMsg->scanMsg.retAsciiCompLen > MACNS_LEGACY_NAME_LIMIT) { if (nameMsg->scanMsg.scanFlags & NSSFL_moreComponentsFollow) { @@ -105,7 +105,7 @@ STATIC STATUS RevalidateFirstMacComponent ( } else if (nameMsg->scanMsg.retScanFlags & NSRETSFL_componentIsUnicode) { - if (unilen (nameMsg->scanMsg.retUnicodeComp) > MACNS_LEGACY_NAME_LIMIT ) + if (unilen (nameMsg->scanMsg.retUnicodeComp) > MACNS_LEGACY_NAME_LIMIT ) { if (nameMsg->scanMsg.scanFlags & NSSFL_moreComponentsFollow) { @@ -130,7 +130,7 @@ STATIC STATUS RevalidateFirstMacComponent ( /***** fixfixfix@nextMediaFormatChange end *******/ /**************************************************************************** - * + * *****************************************************************************/ STATIC void ExtractAndSetParentIsImmCompressFlag( GeneralMsg_s *genMsg, @@ -146,8 +146,8 @@ STATIC void ExtractAndSetParentIsImmCompressFlag( TRUE); if (dirBeast) { - if (COMN_IsDerivedFrom(dirBeast, zFTYPE_NAMED_DATA_STREAM) - && (dirBeast->NAMEDattributes & + if (COMN_IsDerivedFrom(dirBeast, zFTYPE_NAMED_DATA_STREAM) + && (dirBeast->NAMEDattributes & zFA_COMPRESS_FILE_IMMEDIATELY)) { nameMsg->retParseFlags |= NAMRETPFL_parentIsImmCompress; @@ -185,7 +185,7 @@ STATIC STATUS ResolveNameMsgStartingBeasts( ASSERT_MPKNSS_LOCK(); dontDoVisibilityCheck = (nameMsg->parseFlags & NAMPFL_dontDoVisibilityChecks) ? TRUE : FALSE; - requireOnlineVolume = + requireOnlineVolume = (nameMsg->parseFlags & NAMPFL_dontLockVolumeActive) ? FALSE : TRUE; nameMsg->retParseFlags &= ~NAMRETPFL_parentIsImmCompress; @@ -202,7 +202,7 @@ STATIC STATUS ResolveNameMsgStartingBeasts( /* Should never get this far with a Search pattern */ SetErrno(genMsg,zERR_INVALID_PATH); return(zFAILURE); - + case zHPT_SIMPLE: case zHPT_FULL: /* Cleanout all starting volume and beast pointers, the path @@ -295,9 +295,9 @@ STATIC STATUS ResolveNameMsgStartingBeasts( nameMsg->zidNameType = cxh->fileNameType; nameMsg->fileNameType = cxh->fileNameType; zASSERT(NAME_HasThisParentZID(nameMsg->curFile,nameMsg->fileParentZid) || - (nameMsg->curFile->FILEvolume == &AdminVolume.vol && + (nameMsg->curFile->FILEvolume == &AdminVolume.vol && nameMsg->fileParentZid >= AVOL_FIRST_PERSISTENT_ZID) || - (nameMsg->curFile->FILEvolume == PersistAdminVolume && + (nameMsg->curFile->FILEvolume == PersistAdminVolume && nameMsg->fileParentZid < AVOL_FIRST_PERSISTENT_ZID)); // cnt zASSERT(NAME_HasThisNameUniquifier(nameMsg->curFile,nameMsg->fileNameUniquifier)); @@ -367,9 +367,9 @@ STATIC STATUS ResolveNameMsgStartingBeasts( nameMsg->zidNameType = fh->fileNameType; nameMsg->fileNameType = fh->fileNameType; zASSERT(NAME_HasThisParentZID(nameMsg->curFile,nameMsg->fileParentZid) || - (nameMsg->curFile->FILEvolume == &AdminVolume.vol && + (nameMsg->curFile->FILEvolume == &AdminVolume.vol && nameMsg->fileParentZid >= AVOL_FIRST_PERSISTENT_ZID) || - (nameMsg->curFile->FILEvolume == PersistAdminVolume && + (nameMsg->curFile->FILEvolume == PersistAdminVolume && nameMsg->fileParentZid < AVOL_FIRST_PERSISTENT_ZID)); // cnt zASSERT(NAME_HasThisNameUniquifier(nameMsg->curFile,nameMsg->fileNameUniquifier)); if((fh->hlFile) && (nameMsg->hlFile == NULL)) @@ -437,9 +437,9 @@ STATIC STATUS ResolveNameMsgStartingBeasts( nameMsg->zidNameType = fh->fileNameType; nameMsg->fileNameType = fh->fileNameType; zASSERT(NAME_HasThisParentZID(nameMsg->curFile,nameMsg->fileParentZid) || - (nameMsg->curFile->FILEvolume == &AdminVolume.vol && + (nameMsg->curFile->FILEvolume == &AdminVolume.vol && nameMsg->fileParentZid >= AVOL_FIRST_PERSISTENT_ZID) || - (nameMsg->curFile->FILEvolume == PersistAdminVolume && + (nameMsg->curFile->FILEvolume == PersistAdminVolume && nameMsg->fileParentZid < AVOL_FIRST_PERSISTENT_ZID)); // cnt zASSERT(NAME_HasThisNameUniquifier(nameMsg->curFile,nameMsg->fileNameUniquifier)); /* if we parsed through a hardlink to open this file, note this in the namingmsg */ @@ -533,7 +533,7 @@ STATIC STATUS ResolveNameMsgStartingBeasts( /* Resolve the curFile/DataStream */ if (nameMsg->curFile == NULL) { - if ((nameMsg->curFile = COMN_LookupByZid(genMsg, &AdminVolume, + if ((nameMsg->curFile = COMN_LookupByZid(genMsg, &AdminVolume, nameMsg->fileZid, nameMsg->latchType, dontDoVisibilityCheck)) == NULL) { @@ -545,7 +545,7 @@ STATIC STATUS ResolveNameMsgStartingBeasts( nameMsg->fileZid = zINVALID_ZID; nameMsg->dataStreamZid = zINVALID_ZID; } - /* If the fileNameUniquifier is zFNU_FIRST_PARENT, locate the + /* If the fileNameUniquifier is zFNU_FIRST_PARENT, locate the * zid of the first parent. */ // cnt if (nameMsg->fileNameUniquifier == zFNU_FIRST_PARENT) { @@ -764,7 +764,7 @@ STATIC STATUS ResolveNameMsgStartingBeasts( /* if we looked up an "inode", as evidenced by the fact that * we are not a hardlink, but we DO have a hardlink link, then * default hlFile to the primary parent beast */ - if(!(nameMsg->curFile->FILEattributes & zFA_HARDLINK) && + if(!(nameMsg->curFile->FILEattributes & zFA_HARDLINK) && (nameMsg->curFile->FILEhardLinkZid != zINVALID_ZID)) { nameMsg->hlFile = COMN_LookupByZid(genMsg, @@ -778,9 +778,9 @@ STATIC STATUS ResolveNameMsgStartingBeasts( } } - /* If the parentZid is invalid and hard links are not allowed, - * select the beast's first parent. Otherwise, validate the - * parent zid for the beast. */ + /* If the parentZid is invalid and hard links are not allowed, + * select the beast's first parent. Otherwise, validate the + * parent zid for the beast. */ // cnt if (nameMsg->fileNameUniquifier == zFNU_FIRST_PARENT) { /* Use the first Parent as the parentZid */ @@ -837,90 +837,90 @@ STATIC STATUS ResolveNameMsgStartingBeasts( zASSERT(scanMsg->retUnicodeComp != NULL); switch (*scanMsg->retUnicodeComp) { - case UNI_NDS_ROOT: - /* This overrides the volume, but is not currently supported */ - zASSERT("NDS Root not supported in COMN_Lookup" == NULL); - SetErrno(genMsg,zERR_INVALID_PATH); - return(zFAILURE); - - case UNI_VOLUME_ROOT: - /* This is not an override of the volume, it is simply a specifier - * that any subsequent path is to begin parsing at the root of - * the specified volume. The volume itself is identified by - * by a contextHandle, fileHandle or volumeID. Locate the - * volume from the correct source and set it up. */ - - switch (nameMsg->handlePathType) - { - case zHPT_SIMPLE: - case zHPT_FULL: - case zHPT_VOLUME_ZID: - default: - /* Its illegal to have a volume root on these name types - * because they either require that the volume name be - * part of the path, or they do not have a path. */ - SetErrno(genMsg,zERR_INVALID_PATH); - return(zFAILURE); - - case zHPT_VOLUME_ZID_PATH: - /* Use the specified volume, but override the ZID to - * the rootdir of the volume. */ - - /* Resolve the curFile/DataStream to the rootdir of the volume */ - if (nameMsg->curFile) - { - COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS_KEEP_LATCHTYPE(nameMsg); - } - nameMsg->curFile = nameMsg->curvol->rootdir; - nameMsg->curDataStream = (NamedBeast_s *)nameMsg->curFile; - COMN_LATCH_AND_USE_NAMEMSG_BEASTS(nameMsg,nameMsg->latchType); - nameMsg->fileParentZid = zINVALID_ZID; + case UNI_NDS_ROOT: + /* This overrides the volume, but is not currently supported */ + zASSERT("NDS Root not supported in COMN_Lookup" == NULL); + SetErrno(genMsg,zERR_INVALID_PATH); + return(zFAILURE); + + case UNI_VOLUME_ROOT: + /* This is not an override of the volume, it is simply a specifier + * that any subsequent path is to begin parsing at the root of + * the specified volume. The volume itself is identified by + * by a contextHandle, fileHandle or volumeID. Locate the + * volume from the correct source and set it up. */ + + switch (nameMsg->handlePathType) + { + case zHPT_SIMPLE: + case zHPT_FULL: + case zHPT_VOLUME_ZID: + default: + /* Its illegal to have a volume root on these name types + * because they either require that the volume name be + * part of the path, or they do not have a path. */ + SetErrno(genMsg,zERR_INVALID_PATH); + return(zFAILURE); + + case zHPT_VOLUME_ZID_PATH: + /* Use the specified volume, but override the ZID to + * the rootdir of the volume. */ + + /* Resolve the curFile/DataStream to the rootdir of the volume */ + if (nameMsg->curFile) + { + COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS_KEEP_LATCHTYPE(nameMsg); + } + nameMsg->curFile = nameMsg->curvol->rootdir; + nameMsg->curDataStream = (NamedBeast_s *)nameMsg->curFile; + COMN_LATCH_AND_USE_NAMEMSG_BEASTS(nameMsg,nameMsg->latchType); + nameMsg->fileParentZid = zINVALID_ZID; // cnt nameMsg->fileNameUniquifier = zFNU_INVALID_NAME_UNIQUIFIER; - nameMsg->fileNameType = zNTYPE_FILE; - nameMsg->fileZid = zINVALID_ZID; - nameMsg->dataStreamZid = zINVALID_ZID; + nameMsg->fileNameType = zNTYPE_FILE; + nameMsg->fileZid = zINVALID_ZID; + nameMsg->dataStreamZid = zINVALID_ZID; nameMsg->retParseFlags &= ~NAMRETPFL_parentIsImmCompress; - /* If this was the only component, then flag it as + /* If this was the only component, then flag it as * such. Else, scan ahead for the next component */ - if (nameMsg->retParseFlags & NAMRETPFL_lastComponent) - { - nameMsg->handlePathType = zHPT_VOLUME_ZID; - } + if (nameMsg->retParseFlags & NAMRETPFL_lastComponent) + { + nameMsg->handlePathType = zHPT_VOLUME_ZID; + } else if (NMSG_ScanNextComponent(genMsg, nameMsg) != zOK) { return(zFAILURE); } - break; - } - break; - - case UNI_VOLUMENAME_ROOT: + break; + } + break; + + case UNI_VOLUMENAME_ROOT: /* We should have already processed any and all volume name * overrides. If we get here this is an error. */ zASSERT("Illegal Volume Override in ResolveNameMsgStartingBeasts" == NULL); SetErrno(genMsg,zERR_INVALID_PATH); return(zFAILURE); - - default: - /* There is not a root indicator in the path. */ - switch (nameMsg->handlePathType) - { - case zHPT_VOLUME_ZID: - case zHPT_VOLUME_ZID_PATH: - /* There was no volume override. Simply fall through...*/ - break; - - case zHPT_SIMPLE: - case zHPT_FULL: - default: - /* Its illegal to have a not have some sort of volume - * root on these types. They must be fully qualified.*/ - SetErrno(genMsg,zERR_INVALID_PATH); - return(zFAILURE); - } - } - } + + default: + /* There is not a root indicator in the path. */ + switch (nameMsg->handlePathType) + { + case zHPT_VOLUME_ZID: + case zHPT_VOLUME_ZID_PATH: + /* There was no volume override. Simply fall through...*/ + break; + + case zHPT_SIMPLE: + case zHPT_FULL: + default: + /* Its illegal to have a not have some sort of volume + * root on these types. They must be fully qualified.*/ + SetErrno(genMsg,zERR_INVALID_PATH); + return(zFAILURE); + } + } + } /* Now that we have found the starting beast, verify that it still has * the requested starting zidNameType. */ if (((pentry = NAME_GetParentEntry(genMsg, @@ -936,16 +936,16 @@ STATIC STATUS ResolveNameMsgStartingBeasts( } /***** fixfixfix@nextMediaFormatChange - begin*******/ -/* At the next media format change, only the extended Mac namespace will - * will be supported at the volume level. Compatibilty with the - * 31 char legacy namespace will be accomplished only with the - * zid-mangling algorithm (see comnMacShortName.c) This check should +/* At the next media format change, only the extended Mac namespace will + * will be supported at the volume level. Compatibilty with the + * 31 char legacy namespace will be accomplished only with the + * zid-mangling algorithm (see comnMacShortName.c) This check should * not need to be made, once we drop support for the 31 char Mac NS */ /* set scan flags to support extended Mac namespace if volume attribute is enabled */ -/* We default NSSFL_useExtendedMacNamespace, but at this point, if we - * know the volume, we can set the scan flag appropriately +/* We default NSSFL_useExtendedMacNamespace, but at this point, if we + * know the volume, we can set the scan flag appropriately */ if (nameMsg->curvol) // and it should be there now { @@ -988,7 +988,7 @@ STATUS COMN_Lookup( if (nameMsg->parseFlags & NAMPFL_nameMsgFullyResolved) { - if((nameMsg->curFile->FILEattributes & zFA_HARDLINK) && + if((nameMsg->curFile->FILEattributes & zFA_HARDLINK) && !(nameMsg->parseFlags & NAMPFL_dontProcessHardLink) && (nameMsg->hlFile == NULL)) { @@ -996,15 +996,15 @@ STATUS COMN_Lookup( dontDoVisibilityCheck = (nameMsg->parseFlags & NAMPFL_dontDoVisibilityChecks) ? TRUE : FALSE; - nextBeast = COMN_LookupByZid(genMsg, nameMsg->curvol, - ((HardLinkBeast_s*)nameMsg->curFile)->HARDLprimaryZid, - nameMsg->latchType, - dontDoVisibilityCheck); + nextBeast = COMN_LookupByZid(genMsg, nameMsg->curvol, + ((HardLinkBeast_s*)nameMsg->curFile)->HARDLprimaryZid, + nameMsg->latchType, + dontDoVisibilityCheck); if(nextBeast != NULL) { nameMsg->hlParentZid = nameMsg->fileParentZid; nameMsg->hlFile = (HardLinkBeast_s *)nameMsg->curFile; - + if((NamedBeast_s *)nameMsg->curFile == nameMsg->curDataStream) { COMN_Release(&nameMsg->curDataStream); /* Already unlatched */ @@ -1089,22 +1089,22 @@ STATUS COMN_Lookup( /***** fixfixfix@nextMediaFormatChange begin *******/ -/* At the next media format change, only the extended Mac namespace will - * will be supported at the volume level and at that time only the "else" - * part of this code will apply. The conditional stuff for zNSPACE_MAC +/* At the next media format change, only the extended Mac namespace will + * will be supported at the volume level and at that time only the "else" + * part of this code will apply. The conditional stuff for zNSPACE_MAC * will be obsolete */ -/* At this point we have been through NSMG_ValidateNameMsg which - * validated the first parse component, but defaults to use the - * extended Mac namespace (allows 255 chars) The volume attributes +/* At this point we have been through NSMG_ValidateNameMsg which + * validated the first parse component, but defaults to use the + * extended Mac namespace (allows 255 chars) The volume attributes * are not guaranteed to be available, until after ResolveNameMsgStartingBeasts - * has been called. After this call, we need to make sure that the - * parsed name is not < 31 chars if the volume does not support the + * has been called. After this call, we need to make sure that the + * parsed name is not < 31 chars if the volume does not support the * extended Mac namespace. */ if ( (nameMsg->nameSpaceID & zNSPACE_MAC) && (nameMsg->curvol == NULL) ) - { // volume attributes were not available + { // volume attributes were not available // do not know if Mac namespace allows 31 or 255 chars if (ResolveNameMsgStartingBeasts(genMsg, nameMsg) != zOK) goto cleanup; @@ -1122,7 +1122,7 @@ STATUS COMN_Lookup( goto cleanup; } - + /*--------------------------------------------------------------------------- * Now, parse the path component string as far as the caller requested... * The only handlePathTypes which survive the call to ResolvenameMsgBeasts are @@ -1189,8 +1189,8 @@ STATUS COMN_Lookup( * component will have already been parsed and the *---------------------------------------------------------------------------*/ case zHPT_VOLUME_ZID_PATH: - /* If the parse mode is still set to NAMPMODE_Undefined, default it - * to be NAMPMODE_FullyResolveAny. */ + /* If the parse mode is still set to NAMPMODE_Undefined, default it + * to be NAMPMODE_FullyResolveAny. */ if (nameMsg->parseMode == NAMPMODE_Undefined) nameMsg->parseMode = NAMPMODE_FullyResolveAny; @@ -1208,7 +1208,7 @@ STATUS COMN_Lookup( (!((1<curvol->VOLnameSpaceMask))) { SetErrno(genMsg,zERR_INVALID_NAMESPACE_ID); - goto cleanup; + goto cleanup; } /* Parse each component until we are done */ @@ -1265,7 +1265,7 @@ STATUS COMN_Lookup( nextBeast = NAME_FindNameInAsciiNameCache( genMsg,nameMsg->curFile, nameMsg->workNameSpace, - nameMsg->workNameType, + nameMsg->workNameType, scanMsg->retAsciiCompLen, scanMsg->retAsciiComp, nameMsg->latchType, @@ -1297,7 +1297,7 @@ STATUS COMN_Lookup( { nextBeast = NAME_FindNameInAsciiNameCache( genMsg,nameMsg->curFile,dosNameSpace, - nameMsg->workNameType, + nameMsg->workNameType, scanMsg->retAsciiCompLen, scanMsg->retAsciiComp, nameMsg->latchType, @@ -1312,18 +1312,18 @@ STATUS COMN_Lookup( * negative entry in the DOS ascii name cache, * but no negative entry in the LONG ascii name * cache ... so clear the error and go ahead - * and convert to unicode and look it up etc... + * and convert to unicode and look it up etc... */ ClearErrno(genMsg); } } - if ( (nextBeast==NULL) && - (nameMsg->workNameSpaceID == zNSPACE_MAC) && + if ( (nextBeast==NULL) && + (nameMsg->workNameSpaceID == zNSPACE_MAC) && (GetErrno(genMsg) == zERR_NAME_NOT_FOUND_IN_DIRECTORY) ) { // couldn't find in ascii cache - process through unicode - // may have mangledZid format + // may have mangledZid format ClearErrno (genMsg); } @@ -1418,9 +1418,9 @@ STATUS COMN_Lookup( COND_UNLATCH(&nameMsg->curFile->FILEbeastLatch, nameMsg->latchType); /* Get and latch the parent */ - nextBeast = COMN_LookupByZid(genMsg, nameMsg->curvol, - nameMsg->fileParentZid, nameMsg->latchType, - dontDoVisibilityCheck); + nextBeast = COMN_LookupByZid(genMsg, nameMsg->curvol, + nameMsg->fileParentZid, nameMsg->latchType, + dontDoVisibilityCheck); if (nextBeast == NULL) { nameMsg->latchType = NOTLATCHED; @@ -1515,12 +1515,12 @@ STATUS COMN_Lookup( goto cleanup; } /* We have the new beast. If it is not a dataStream, - * move curFile and curDataStream. If it is a + * move curFile and curDataStream. If it is a * datastream, just move curDataStream */ GotNextBeast: if (scanMsg->retScanFlags & NSRETSFL_hasIllegalChars) { - /* The name had illegal characters, but we + /* The name had illegal characters, but we * succeeded in looking it up anyway. Clear * any possible error codes put in genMsg by the * scanNextComponent code. @@ -1540,10 +1540,10 @@ GotNextBeast: // cnt nameMsg->fileNameUniquifier = nameUniquifier; nameMsg->fileNameType = nameMsg->workNameType; nameMsg->retParseFlags &= ~NAMRETPFL_parentIsImmCompress; - if (nameMsg->curFile->FILEattributes & + if (nameMsg->curFile->FILEattributes & zFA_COMPRESS_FILE_IMMEDIATELY) { - nameMsg->retParseFlags |= + nameMsg->retParseFlags |= NAMRETPFL_parentIsImmCompress; } COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS_KEEP_LATCHTYPE(nameMsg); @@ -1596,7 +1596,7 @@ GotNextBeast: (!((1<curvol->VOLnameSpaceMask))) { SetErrno(genMsg,zERR_INVALID_NAMESPACE_ID); - goto cleanup; + goto cleanup; } } } @@ -1613,7 +1613,7 @@ DoNotResolveLeaf: (nameMsg->retParseFlags & NAMRETPFL_haveAParsedComponent) && (nameMsg->retParseFlags & NAMRETPFL_lastComponent)) || ((nameMsg->handlePathType == zHPT_VOLUME_ZID) && - (!(nameMsg->retParseFlags & NAMRETPFL_haveAParsedComponent)))); + (!(nameMsg->retParseFlags & NAMRETPFL_haveAParsedComponent)))); /* make sure curBeast is a directory container */ if (!(nameMsg->curFile->FILEattributes & zFA_SUBDIRECTORY) && @@ -1684,15 +1684,15 @@ DoNotResolveLeaf: * and then return the primary zid info in the normal naming fields. * cnt fixfixfix do I need to release the hardlink, get the primary, and re-get the hardlink? *---------------------------------------------------------------------------*/ - if((nameMsg->curFile->FILEattributes & zFA_HARDLINK) && + if((nameMsg->curFile->FILEattributes & zFA_HARDLINK) && !(nameMsg->parseFlags & NAMPFL_dontProcessHardLink)&& (nameMsg->hlFile == NULL)) { - nextBeast = COMN_LookupByZid(genMsg, nameMsg->curvol, - ((HardLinkBeast_s*)nameMsg->curFile)->HARDLprimaryZid, - nameMsg->latchType, - dontDoVisibilityCheck); + nextBeast = COMN_LookupByZid(genMsg, nameMsg->curvol, + ((HardLinkBeast_s*)nameMsg->curFile)->HARDLprimaryZid, + nameMsg->latchType, + dontDoVisibilityCheck); if(nextBeast != NULL) { nameMsg->hlParentZid = nameMsg->fileParentZid; @@ -1744,14 +1744,14 @@ DoNotResolveLeaf: } nameMsg->latchType = XLATCHED; nameMsg->parseFlags &= ~NAMPFL_XLatchAfterLookup; - } + } zASSERT(nameMsg->curvol != NULL); zASSERT(nameMsg->curFile != NULL); zASSERT(nameMsg->curDataStream != NULL); zASSERT((nameMsg->handlePathType == zHPT_VOLUME_ZID) || ((nameMsg->handlePathType == zHPT_VOLUME_ZID_PATH) && - (nameMsg->retParseFlags & NAMRETPFL_haveAParsedComponent))); + (nameMsg->retParseFlags & NAMRETPFL_haveAParsedComponent))); return zOK; /*------------------------------------------------------------------------- @@ -1763,7 +1763,7 @@ cleanup: if ((GetErrno(genMsg) == zERR_NAME_NOT_FOUND_IN_DIRECTORY) && ( ((nameMsg->retParseFlags & (NAMRETPFL_haveAParsedComponent|NAMRETPFL_lastComponent)) == - NAMRETPFL_haveAParsedComponent) || + NAMRETPFL_haveAParsedComponent) || (nameMsg->parseMode == NAMPMODE_FullyResolveDirectory))) { ForceSetErrno(genMsg,zERR_INVALID_PATH); @@ -1811,7 +1811,7 @@ cleanup: nameMsg->latchType = XLATCHED; nameMsg->parseFlags &= ~NAMPFL_XLatchAfterLookup; - } + } return zFAILURE; } diff --git a/src/nwnss/comn/common/comnMacShortName.c b/src/nwnss/comn/common/comnMacShortName.c index b9c7c72..718a6ae 100755 --- a/src/nwnss/comn/common/comnMacShortName.c +++ b/src/nwnss/comn/common/comnMacShortName.c @@ -45,13 +45,13 @@ #include "zParams.h" // zInfo at least #include "nameSpace.h" // necessary for macNSpace.h -#include "macNSpace.h" // MACNS_LEGACY_NAME_LIMIT +#include "macNSpace.h" // MACNS_LEGACY_NAME_LIMIT /**************************************************************************** -* Support routines to mangle 255 unicode char names to 31 byte-based +* Support routines to mangle 255 unicode char names to 31 byte-based * names. This supports AFP 3.1 255 char names and provides back-wards -* compatibility for AFP 2.2 (31 char) names +* compatibility for AFP 2.2 (31 char) names *******************************************************************************/ /************************************************************************* @@ -73,7 +73,7 @@ BOOL COMN_VerifyMangledMacName (unicode_t * mangledName, unicode_t * fileName) if (uninicmp (mangledName, fileName, baseLen ) == 0) return TRUE; - // Check to see if first char is unmappable + // Check to see if first char is unmappable if (uninicmp (mangledName, testStr, 4) == 0) // first char must be unmappable { if (!IS_UNICODE_MAPPABLE_TO_MAC_ASCII (*fileName)) // first char is unmappable @@ -116,12 +116,12 @@ void dropExt (struct parseInfo * info) info->extLen = 0; } -// file name (base + extension) has more than 31 characters or +// file name (base + extension) has more than 31 characters or // must mangle (has unmappable chars) unicode_t * generateMangledMacName (struct parseInfo * info, unicode_t * mangledName) { - + unicode_t dotChar[2]; dotChar[0] = 0x002E; dotChar[1] = 0; @@ -143,7 +143,7 @@ unicode_t * generateMangledMacName (struct parseInfo * info, unicode_t * mangle if (info->mangleBase == FALSE) { if (unilen (info->workingBase) + unilen (info->mangleStr) + 1 <= 31) - info->mangleExt = TRUE; + info->mangleExt = TRUE; } } } @@ -166,10 +166,10 @@ unicode_t * generateMangledMacName (struct parseInfo * info, unicode_t * mangle int minLen; int additionalExtChars; - minLen = info->baseLen + unilen (info->mangleStr) + 1; // for the dot - + minLen = info->baseLen + unilen (info->mangleStr) + 1; // for the dot + additionalExtChars = MACNS_LEGACY_NAME_LIMIT - minLen; - + if (additionalExtChars > info->extLen) additionalExtChars = info->extLen; @@ -192,8 +192,8 @@ unicode_t * generateMangledMacName (struct parseInfo * info, unicode_t * mangle newBaseLen = LB_unilen (info->workingBase); else newBaseLen = minLen; - - mangledName[0] = 0; + + mangledName[0] = 0; LB_unincat (mangledName, info->workingBase, newBaseLen); LB_unicat (mangledName, info->mangleStr); if (info->dropExt == FALSE) @@ -214,22 +214,22 @@ unicode_t * getMangleString (unicode_t * mangleStr, LONG zID) char buffer[256]; unicode_t * uPtr = mangleStr; char * chPtr; - + memset (buffer, 0, 256); buffer[0] = '#'; sprintf (&buffer[1], "%x", zID); uPtr = mangleStr; - *uPtr = 0; - + *uPtr = 0; + chPtr = &buffer[0]; - + /* convert ASCII hex digit string to unicode */ while (*chPtr) *uPtr++ = *chPtr++; - - *uPtr = 0; - + + *uPtr = NULL; + if (*mangleStr != 0) return (mangleStr); else @@ -239,40 +239,40 @@ unicode_t * getMangleString (unicode_t * mangleStr, LONG zID) static STATUS parseFileName (parseInfo * info, unicode_t * srcFileName) { unicode_t * lastDotPtr, *srcPtr; - char byteFileName [zMAX_COMPONENT_NAME]; + char byteFileName [zMAX_COMPONENT_NAME]; // STATUS err; - + memset (info, 0, sizeof (*info)); memset (byteFileName, 0, sizeof (byteFileName) ); LB_unicpy (info->srcName, srcFileName); // find base & extension - + // extension - look at first dot from end of file name lastDotPtr = LB_unirchr (srcFileName, DOT_CHAR /* period or dot */); if (lastDotPtr) info->extLen = LB_unilen (lastDotPtr); - + if (lastDotPtr == NULL) // no extension info->dropExt = TRUE; else *lastDotPtr = 0; // terminate base file name for now - -// find base file name + +// find base file name // copy base to workingBaseName (first 31 chars only) memset (info->workingBase, 0, sizeof (info->workingBase) ); - // zero out, because unincpy does not always null terminate + // zero out, because unincpy does not always null terminate // src is > 31 chars, no null terminator is added to string LB_unincpy (info->workingBase, srcFileName, MACNS_LEGACY_NAME_LIMIT); - + info->baseLen = LB_unilen (srcFileName); - + if (lastDotPtr) // restore dot to filename, overwrite null terminator we added - *lastDotPtr = DOT_CHAR; + *lastDotPtr = DOT_CHAR; // if (base len > 31) // set mangleBase = true @@ -295,61 +295,61 @@ static STATUS parseFileName (parseInfo * info, unicode_t * srcFileName) // set mangleExt = true // else // copy extension to workingExt - + // unincpy does not always null terminate dest string memset (info->workingExt, 0, sizeof (info->workingExt) ); - LB_unincpy (info->workingExt, lastDotPtr + 1, MACNS_LEGACY_NAME_LIMIT); + LB_unincpy (info->workingExt, lastDotPtr + 1, MACNS_LEGACY_NAME_LIMIT); // if there is an unmappable char in extension // truncate workingExtension at unmappable char // set mangleExt = true srcPtr = info->workingExt; - + // terminate at first unmappable char position while (*srcPtr != 0) { if (!IS_UNICODE_MAPPABLE_TO_MAC_ASCII(*srcPtr)) { - *srcPtr = 0; + *srcPtr = 0; info->mangleExt = TRUE; } - else + else { srcPtr++; } } } - + // base - check base for unmappable // if (firstChar is unmappable) // substitute ??? for file name in workingBaseName // set mangleBase to true -// else +// else // tuncate at first unmappable in workingBaseName // set mangleBase to true - if (info->baseLen > 0) // filename doesn't start with dot + if (info->baseLen > 0) // filename doesn't start with dot { int len = 0; srcPtr = info->workingBase; - + // terminate at first unmappable char position while (*srcPtr != 0) { if (!IS_UNICODE_MAPPABLE_TO_MAC_ASCII(*srcPtr)) { - *srcPtr = 0; + *srcPtr = 0; info->mangleBase = TRUE; } - else + else { srcPtr++; } } - + len = LB_unilen (info->workingBase); if (len == 0) // first char is unmappable { @@ -361,11 +361,11 @@ static STATUS parseFileName (parseInfo * info, unicode_t * srcFileName) } return (0); - + } STATUS COMN_MakeShortMacFileName (zInfo_s * zSrcInfo, unicode_t * uniFileName, BYTE * macByteName) -{ +{ unicode_t * mangleStr = NULL; unicode_t * uPtr; parseInfo * info = NULL; @@ -392,7 +392,7 @@ STATUS COMN_MakeShortMacFileName (zInfo_s * zSrcInfo, unicode_t * uniFileName, B rc = zERR_NO_MEMORY; goto Cleanup; } - + info = malloc (sizeof (*info) ); if (info == NULL) { @@ -422,7 +422,7 @@ STATUS COMN_MakeShortMacFileName (zInfo_s * zSrcInfo, unicode_t * uniFileName, B } LB_unicpy (info->mangleStr, mangleStr); - if (!info->mangleBase && !info->mangleExt && + if (!info->mangleBase && !info->mangleExt && (info->baseLen + info->extLen + 1 <= MACNS_LEGACY_NAME_LIMIT) ) { LB_unicpy (uniFileName, info->srcName); @@ -439,7 +439,7 @@ STATUS COMN_MakeShortMacFileName (zInfo_s * zSrcInfo, unicode_t * uniFileName, B NINT retLen; rc = LB_UnicodeToMacByte(NSS_UNI_CONVERSION_RAW, - (char *)&(info->asciiName), + (char *)&(info->asciiName), sizeof (info->asciiName), mangledName, &retLen); if (rc != zOK) { @@ -461,9 +461,9 @@ Cleanup: /**************************************************************************** -* Determine if file name matches the #zid mangled format -* Mangled format is 31 chars or less with embedded zid like -* #zid.ext or name.ext#zid or name#zid +* Determine if file name matches the #zid mangled format +* Mangled format is 31 chars or less with embedded zid like +* #zid.ext or name.ext#zid or name#zid ****************************************************************************/ LONG COMN_GetZidFromMangledName (unicode_t * fileName) @@ -486,7 +486,7 @@ LONG COMN_GetZidFromMangledName (unicode_t * fileName) BYTE idStr [32]; // buffer for #nnn string, 10 bytes should be enough #nnn + null terminator - + // if (getMacNameLimit() > MACNS_LEGACY_NAME_LIMIT) @@ -497,7 +497,7 @@ LONG COMN_GetZidFromMangledName (unicode_t * fileName) uPtr = unirchr (fileName, '#'); - if (uPtr == NULL) + if (uPtr == NULL) return 0; // no # in file name, therefore, no ID in name utf8Ptr = &idStr[0]; @@ -520,7 +520,7 @@ LONG COMN_GetZidFromMangledName (unicode_t * fileName) while (*bPtr) { - if ( isxdigit (*bPtr) ) + if ( isxdigit (*bPtr) ) bPtr++; else return 0; // not hex string digit, not an ID diff --git a/src/nwnss/comn/common/comnMacintosh.c b/src/nwnss/comn/common/comnMacintosh.c index 2268a01..a2c2eff 100644 --- a/src/nwnss/comn/common/comnMacintosh.c +++ b/src/nwnss/comn/common/comnMacintosh.c @@ -34,6 +34,8 @@ | This module is used to: | Support routines for MACintosh +-------------------------------------------------------------------------*/ +#include + //#include "zParams.h" #include "comnPublics.h" //#include "comnParams.h" @@ -94,7 +96,7 @@ STATUS COMN_AddMACDataStreamToNameMsg( nameMsg->parseFlags &= ~NAMPFL_nameMsgValidated; if (NMSG_ValidateNameMsg(genMsg,nameMsg) != zOK) return(zFAILURE); - + /* Restore the "original" starting nameSpaceID and nameType fields. * NOTE -- this does not change the workNameSpaceID and workNameType * which apply to the curDataStream, only the starting values. */ @@ -102,22 +104,22 @@ STATUS COMN_AddMACDataStreamToNameMsg( nameMsg->nameSpaceID = saveNameSpaceID; return(zOK); -} - +} + /**************************************************************************** * COMN_GetMACDataStreamPtr * * This function takes as input a nameMsg that is already fully resolved - * to point to the parent beast for a MAC Resource Fork dataStream. + * to point to the parent beast for a MAC Resource Fork dataStream. * It looks up a MAC data stream for this parent and latches it *****************************************************************************/ STATUS COMN_GetMACDataStreamPtr( - GeneralMsg_s *genMsg, - NamingMsg_s *nameMsg, - NamedBeast_s **dataStream, - NINT latchType, - BOOL *newlyLatched) + GeneralMsg_s *genMsg, + NamingMsg_s *nameMsg, + NamedBeast_s **dataStream, + NINT latchType, + BOOL *newlyLatched) { NameSpace_s *dsNameSpace; // cnt NINT nameUniquifier; @@ -163,4 +165,5 @@ STATUS COMN_GetMACDataStreamPtr( *newlyLatched = TRUE; return(zOK); -} +} + diff --git a/src/nwnss/comn/common/comnOpLock.c b/src/nwnss/comn/common/comnOpLock.c index 63563f8..ea35bac 100644 --- a/src/nwnss/comn/common/comnOpLock.c +++ b/src/nwnss/comn/common/comnOpLock.c @@ -32,11 +32,16 @@ | |--------------------------------------------------------------------------- | This module is used to: - | Define the Common side of OpLocks. + | Define the Common side of OpLocks. | +-------------------------------------------------------------------------*/ #include +#include +#include +#include +#include +#include #include #include @@ -48,9 +53,6 @@ #include "opLock.h" #include "pssStartup.h" #include "comnPublics.h" -#include "schedule.h" -extern STATUS snoozeSec(DQhead_t *list, NINT seconds); -extern void roust(DQhead_t *list, STATUS status); #ifndef __linux__ // LINUX_NetWareAlerts extern NetWareAlertStructure OpLockTimeoutAlert; @@ -75,9 +77,6 @@ NetWareAlertStructure OpLockTimeoutAlert = { }; #endif -typedef STATUS (*oplock_callback_t)(LONG event, GeneralMsg_s *genMsg, OpLock_s *opLock); -#define OPLOCK_CALLBACK(_callback) ((oplock_callback_t)(_callback)) - BOOL OpLockVerbose = FALSE; // TRUE; OpLockInst_s OpLockInst; @@ -226,7 +225,7 @@ void OPLOCK_Free (OpLock_s *opLock) ASSERT_XLATCH( &fh->file->FILEbeastLatch); fh->opLock = NULL; - OPLOCK_CALLBACK(opLock->opCallback)(OPLOCK_CLEAR, NULL, opLock); + opLock->opCallback(OPLOCK_CLEAR, NULL, opLock); zASSERT(!QMEMBER( &opLock->tickle)); @@ -281,7 +280,7 @@ void OPLOCK_TimeOutAlert ( { strcpy(aStack->name, ""); } - } + } else { ClearErrno(genMsg); @@ -305,14 +304,14 @@ void OPLOCK_TimeOutAlert ( * this call returns. * 4. If you were trying to also break shared oplocks, you'll have * to call OPLOCK_BreakShared - */ + */ STATUS OPLOCK_WaitForBreak ( GeneralMsg_s *genMsg, File_s *file) { OpLockControl_s *opLockControl; OpLock_s *opLock; - oplock_callback_t callback; + statusfunc_t callback; DQhead_t save; LONG ownerStation; STATUS rc; @@ -347,7 +346,7 @@ STATUS OPLOCK_WaitForBreak ( opLockControl->opState = OPLOCK_IDLE; return zOK; } - callback = OPLOCK_CALLBACK(opLock->opCallback); + callback = opLock->opCallback; rc = callback(OPLOCK_WAITING, genMsg, opLock); OPLOCK(waitForBreak); @@ -380,7 +379,7 @@ STATUS OPLOCK_WaitForBreak ( { ownerStation = opLock->fileHandle->connID; } - rc = OPLOCK_CALLBACK(opLock->opCallback)(OPLOCK_TIMEOUT, genMsg, opLock); + rc = opLock->opCallback(OPLOCK_TIMEOUT, genMsg, opLock); ASSERT_MPKNSS_LOCK(); if (rc != zOK) { @@ -411,7 +410,7 @@ STATUS OPLOCK_BreakExclusive ( BOOL wait) { OpLockControl_s *opLockControl = file->opLockControl; - oplock_callback_t callback; + statusfunc_t callback; OpLock_s *opLock; STATUS rc; @@ -436,7 +435,7 @@ STATUS OPLOCK_BreakExclusive ( opLockControl->opState = OPLOCK_IDLE; return zOK; } - callback = OPLOCK_CALLBACK(opLock->opCallback); + callback = opLock->opCallback; rc = callback(OPLOCK_BREAK, genMsg, opLock); ASSERT_MPKNSS_LOCK(); if (rc != zOK) @@ -516,7 +515,7 @@ STATUS OPLOCK_BreakShared (File_s *file) break; } OPLOCK(breakShared); - OPLOCK_CALLBACK(opLock->opCallback)(OPLOCK_BREAK, NULL, opLock); + opLock->opCallback(OPLOCK_BREAK, NULL, opLock); /* * We are ignoring callbacks that failed. It is * their problem, not ours. @@ -584,7 +583,7 @@ STATUS OPLOCK_BreakPSA (File_s *file) break; } OPLOCK(breakShared); - OPLOCK_CALLBACK(opLock->opCallback)(OPLOCK_BREAK, NULL, opLock); + opLock->opCallback(OPLOCK_BREAK, NULL, opLock); ASSERT_MPKNSS_LOCK(); } return zOK; diff --git a/src/nwnss/comn/common/comnPool.c b/src/nwnss/comn/common/comnPool.c index b6712d8..6f2694e 100644 --- a/src/nwnss/comn/common/comnPool.c +++ b/src/nwnss/comn/common/comnPool.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include @@ -149,7 +149,7 @@ void POOL_DisplayPools(void) *** can use a continue BEFORE any blocking calls. ***/ COMN_USE_BEAST( &pool->POOLroot ); - X_LATCH( &pool->cvsLatch ); + X_LATCH( &pool->cvsLatch ); featureCount = 0; featureCurrent = 0; featureCurrentReal = 0; @@ -354,7 +354,7 @@ void POOL_DisplayPools(void) } #endif } - UNX_LATCH( &pool->cvsLatch ); + UNX_LATCH( &pool->cvsLatch ); COMN_Release( &pool ); SET_FOREACHBLOCKINGEND(&NSSMasterPoolList, pool, Pool_s, masterPoolLink) } @@ -394,7 +394,7 @@ void COMN_PoolStateChangeReport( MSG("Could not change pool %U to the %s state.\n" "The pool needs to be upgraded from NSS 2.x format to NSS 3.0 format.\n" "Make sure NDS is running then use 'NSS /zlssVolumeUpgrade=%U'\n" - "(or ALL to upgrade all NSS 2.x volumes)\n", 186), + "(or ALL to upgrade all NSS 2.x volumes)\n", 186), aStack->name, vol_GetStateName(destState), aStack->name); } else if (GetErrno(genMsg) != zERR_VOLUME_STATE_CHANGE_ABORTED) @@ -483,14 +483,14 @@ STATIC STATUS POOL_AddPoolToSystem( status = COMN_AdmnVolInsertBeast(genMsg,&pool->avfile, AdminVolDirs[AV_POOL_DIRECTORY].key, name); - + if (status != zOK) { RTN_STATUS(zFAILURE); } /* - * Add the management file for the pool. + * Add the management file for the pool. */ if (addPoolMgmtFile(genMsg, name) != zOK) { @@ -501,7 +501,7 @@ STATIC STATUS POOL_AddPoolToSystem( } /***************************************************************************** - * This will rename the given pools management objects. The caller renames + * This will rename the given pools management objects. The caller renames * the pool persistently. *****************************************************************************/ STATUS POOL_Rename( @@ -528,7 +528,7 @@ STATUS POOL_Rename( /* Rename the pool in the root's 'Pools' directory. * This is a important rename as this is the Pool_s beast - * object. + * object. */ unicpy( /*dest*/oldFullName, AVOL_POOL_PATH_UNICODE ); unicat( /*dest*/oldFullName, oldPoolName ); @@ -578,14 +578,14 @@ Pool_s *gPool; * NOTE - * That the VolumeID and Name are the only Persistnet Pool_s items that * are always correct. I.E. when the Pool is in any pool state these - * fields are correct. Most persistent field are only valid in the + * fields are correct. Most persistent field are only valid in the * ACTIVE state. * *****************************************************************************/ void *POOL_BstNew( GeneralMsg_s *genMsg, NINT beastClassID, /* ID assigned by Novell for the Pool type - * being created. + * being created. */ void *voidOwnerPool, /* Owner of the pool. Currently this must * be the Admin volume. @@ -620,9 +620,9 @@ void *POOL_BstNew( | Ensure the GUID is also correct. *-------------------------------------------------------------------------*/ newPool->POOLvolumeID = *poolID; - newPool->POOLattributes |= (zFA_SUBDIRECTORY | - zFA_RENAME_INHIBIT | - zFA_DELETE_INHIBIT | + newPool->POOLattributes |= (zFA_SUBDIRECTORY | + zFA_RENAME_INHIBIT | + zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT); /** * Generally, one would do both of the next lines when @@ -678,7 +678,7 @@ void *POOL_BstNew( } return( NULL ); } - + #if NSS_DEBUG IS_ENABLED gPool = newPool; #endif @@ -688,7 +688,7 @@ void *POOL_BstNew( /* - * COMN_PoolActiveLock() + * COMN_PoolActiveLock() * * This function is used to lock a pool in the ACTIVE state so it cannot * be deactivated. If the pool is not already in an ACTIVE state, or if @@ -702,7 +702,7 @@ STATUS COMN_PoolActiveLock( { ASSERT_MPKNSS_LOCK(); - + ++pool->POOLkeepActiveUseCount; if ( ( pool->state != zVOLSTATE_ACTIVE ) || ( pool->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP ) ) @@ -721,7 +721,7 @@ STATUS COMN_PoolActiveLock( /* * COMN_PoolActiveUnlock - * + * * This function releases a "keep active" lock on a volume. */ @@ -977,8 +977,8 @@ STATIC STATUS POOL_SingleStateChange( * done because technically the state is not valid during a * transistion. */ - X_LATCH( &nssPool->stateLatch ); - /* Should we get the pools beast latch??? FixFixFix6 */ + X_LATCH( &nssPool->stateLatch ); + /* Should we get the pools beast latch??? FixFixFix6 */ for ( cvsPass = 1; cvsPass <= 10; cvsPass++ ) { @@ -1089,7 +1089,7 @@ STATIC STATUS POOL_SingleStateChange( { nssPool->state = requestedState; } - UNX_LATCH( &nssPool->stateLatch ); + UNX_LATCH( &nssPool->stateLatch ); #if NSS_DEBUG IS_ENABLED @@ -1154,13 +1154,13 @@ justReturn: * / \ * / \ * / \ - * / MAINTENANCE + * / MAINTENANCE * / / - * / / - * / / - * / / - * / / - * / / + * / / + * / / + * / / + * / / + * / / * ACTIVE * * @@ -1183,10 +1183,10 @@ justReturn: * are open on the pool. In addition, before we attempt any state * change we send a event that allows the event reciever to fail the * ATTEMPTED state change. - * + * * When an error is returned it is simply best to get the current * pool state if your code needs to know the state we ended in. - * + * * A state change from DEACTIVE to ACTIVE may end up in MAINTENANCE state. * This is possible because if the LSS detects the pool is corrupt then * the pool will be placed into MAINTENANCE state. This function supports @@ -1256,7 +1256,7 @@ restart: destState = zVOLSTATE_UNKNOWN; } } - if ( (mode & VOLMODE_VERBOSE) && (!restarted) ) + if ( (mode & VOLMODE_VERBOSE) && (!restarted) ) { typedef struct Stack_s { STATUS status; @@ -1371,7 +1371,7 @@ restart: UNX_LATCH( &vol->cvsLatch ); /* At this point some other thread could clear VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP * so we limit the amount of delaying before re-attempting restart. Otherwise, - * we could wait until someone else sets VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP. + * we could wait until someone else sets VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP. */ while ( (vol->POOLkeepActiveUseCount != 0) && (cnt < 10) ) { @@ -1445,9 +1445,9 @@ CPSSkip:; vol->v_statusFlag &= ~VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP; /* Serialize code per pool */ - UNX_LATCH( &vol->cvsLatch ); + UNX_LATCH( &vol->cvsLatch ); if (vol->POOLroot.rb_inode != NULL) - { + { VOL_CleanupInodeBeastLink(&vol->POOLroot); } @@ -1461,8 +1461,8 @@ CPSSkip:; * */ BOOL COMN_PoolCorrectType( - Pool_s *pool, - NINT includeType ) + Pool_s *pool, + NINT includeType ) { @@ -1627,7 +1627,7 @@ NINT LB_VolumeFindMMVolume( unicode_t *volumeName ) { Volume_s *volume; GeneralMsg_s dummyGenMsg; - + ASSERT_MPKNSS_LOCK(); /* Search the NSS volumes - we can not use MM because @@ -1697,7 +1697,7 @@ STATUS LB_VolumeNameAcceptable( unicode_t *volumeName ) * LB_VolumeNameAcceptableWithFlag() - * Determines if a volume name is acceptable as the name of * a NEW NSS volume. - * + * * It is the same as LB_VolumeNameAcceptable except if flag * ignoreDupLegacyVolume is turned on, volume name is acceptable * if it is conflict with a dismounted legacy volume. @@ -1716,7 +1716,7 @@ STATUS LB_VolumeNameAcceptableWithFlag( } /* Use the Media manager to see if the volume exists in the Traditional - * or NSS tables, and also find out if the volume is currently + * or NSS tables, and also find out if the volume is currently * mounted */ found = LB_VolumeFindMMVolume( volumeName ); @@ -1731,7 +1731,7 @@ STATUS LB_VolumeNameAcceptableWithFlag( return(zERR_DUPLICATE_VOLUME_NAME); } break; - + case LB_VOLUME_NOT_FOUND: default: break; @@ -1920,14 +1920,14 @@ STATUS POOL_FlushPool( POOL_FOR_EACH_LOADED_VOLUME(pool, volume) { COMN_USE_BEAST(&volume->VOLroot); - if (prevVolume != NULL) - { - COMN_Release(&prevVolume); - } - prevVolume = volume; + if (prevVolume != NULL) + { + COMN_Release(&prevVolume); + } + prevVolume = volume; - if (COMN_LockVolumeActive(genMsg, volume, FALSE) != zOK) - { + if (COMN_LockVolumeActive(genMsg, volume, FALSE) != zOK) + { continue; } status = VOL_FlushVolume(genMsg, volume); @@ -1938,10 +1938,10 @@ STATUS POOL_FlushPool( } COMN_UnlockVolumeActive(volume,FALSE); } - if (prevVolume != NULL) - { - COMN_Release(&prevVolume); - } + if (prevVolume != NULL) + { + COMN_Release(&prevVolume); + } if ((volume = pool->P_VolumeInternal) != NULL) { @@ -1951,7 +1951,7 @@ STATUS POOL_FlushPool( status = VOL_FlushVolume(genMsg, volume); COMN_UnlockVolumeActive(volume,FALSE); } - COMN_Release(&volume); + COMN_Release(&volume); } UNX_LATCH( &pool->cvsLatch ); @@ -1975,10 +1975,10 @@ STATUS COMN_FlushPool( { STATUS status; Pool_s *pool; - + ASSERT_MPKNSS_LOCK(); ENTER(TCOMMON,COMN_FlushPool); - + if((pool = COMN_PoolNameLookup(genMsg, poolName, TRUE, NULL)) == NULL) { RTN_STATUS(zFAILURE); @@ -1988,12 +1988,12 @@ STATUS COMN_FlushPool( COMN_Release(&pool); RTN_STATUS(zFAILURE); } - + status = POOL_FlushPool(genMsg, pool); - + COMN_PoolActiveUnlock(pool); COMN_Release(&pool); - + RTN_STATUS(status); } @@ -2025,10 +2025,10 @@ STATUS POOL_BST_Construct( initAgent(&pool->agent, VOL_VolumeSignalHandler, MSGNot("Pool")); DQ_INIT(&pool->v_alertList); -// // pool->v_disableWorkToDoScheduled = 0; +// // pool->v_disableWorkToDoScheduled = 0; // pool->v_alertListCount = 0; #if VOL_DISABLE_USE_SYSTEMS_WORK_TO_DO - fillInWork( &pool->v_disableWorkToDoStructure, (voidfunc_t)pool_DisableWorkToDoRoutine, pool); + fillInWork( &pool->v_disableWorkToDoStructure, pool_DisableWorkToDoRoutine, pool); #else FSMLITE_INIT( &pool->v_disableWorkToDoFsm /* Lite FSM */, MSGNot("POOL Disable Work-To-Do"), 0 /* Instance */ ); @@ -2078,7 +2078,7 @@ void POOL_BST_Destruct( #if NSS_ASSERT IS_ENABLED count = 0; #endif - + while ( pool->v_statusFlag & VOL_SF_DISABLE_THREAD_SCHEDULED ) { /* * Delay to give Work-to-do time to run. We do not do a yield @@ -2088,11 +2088,11 @@ void POOL_BST_Destruct( * could return a error anyway. We unlatch because the work-to-do * will need to obtain to do a checkpoint. */ - + // UNX_LATCH( &pool->POOLbeastLatch ); LB_delay( 40 ); /* 40 millisecs */ // X_LATCH( &pool->POOLbeastLatch ); - + #if NSS_ASSERT IS_ENABLED ++count; /* Not in ASSERT macro just in case of side-effects */ #endif @@ -2101,22 +2101,22 @@ void POOL_BST_Destruct( } /* Clean off all the items on the ALERT Queue */ - + DQ_DEQ(&pool->v_alertList, alertInfo, NSSVolumeAlert_s, nva_alertList); while ( alertInfo != NULL ) { --pool->v_alertListCount; - LB_free( alertInfo ); + LB_free( alertInfo ); alertInfo = NULL; - + DQ_DEQ(&pool->v_alertList, alertInfo, NSSVolumeAlert_s, nva_alertList); } - + #if NSS_ASSERT IS_ENABLED count = 0; #endif - + while ( pool->v_statusFlag & VOL_SF_ALERT_THREAD_SCHEDULED ) { /* * Delay to give Work-to-do time to run. We do not do a yield @@ -2126,11 +2126,11 @@ void POOL_BST_Destruct( * could return a error anyway. We unlatch because the work-to-do * will need to obtain to do a checkpoint. */ - + // UNX_LATCH( &vol->VOLbeastLatch ); LB_delay( 40 ); /* 40 millisecs */ // X_LATCH( &vol->VOLbeastLatch ); - + #if NSS_ASSERT IS_ENABLED ++count; /* Not in ASSERT macro just in case of side-effects */ #endif @@ -2308,7 +2308,7 @@ STATUS POOL_VOL_ChangeVolumeState( /************************************************************************** - * + * ***************************************************************************/ STATUS POOL_Activate( GeneralMsg_s *genMsg, @@ -2428,7 +2428,7 @@ void pool_DisableWorkToDoRoutine( DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, MSGNot("Work to do done with DISABLEing Pool....(May be ASYNC!!!)\n") )); #endif - + /* Mark that we are 'almost' done running. */ pool->v_statusFlag &= ~VOL_SF_DISABLE_THREAD_SCHEDULED; COMN_Release( &pool ); @@ -2629,7 +2629,7 @@ void pool_AlertWorkToDoRoutine( * state request. *****************************************************************************/ STATUS POOL_DisablePool( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, Pool_s *pool ) { @@ -2648,7 +2648,7 @@ STATUS POOL_DisablePool( */ pool->v_ioFlag |= VOL_IOF_DISABLE; /* LSS must stop writing to the media */ - + /* See if a thread already scheduled */ if ( pool->v_statusFlag & VOL_SF_DISABLE_THREAD_SCHEDULED ) { /* Already scheduled so just return. ScheduleWork() does @@ -2657,7 +2657,7 @@ STATUS POOL_DisablePool( * were to cause another disable that we will ignore the * 2nd request. */ - + DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, (CYAN,MSGNot("Asynchronous disable pool already scheduled\n"))); RTN_STATUS(zOK); @@ -2672,7 +2672,7 @@ STATUS POOL_DisablePool( * own use count. */ COMN_USE_BEAST(&pool->POOLroot); - + #if VOL_DISABLE_USE_SYSTEMS_WORK_TO_DO ScheduleWork( &pool->v_disableWorkToDoStructure ); #else @@ -2680,7 +2680,7 @@ STATUS POOL_DisablePool( #endif RTN_STATUS(zOK); - + } /* End of POOL_DisablePool */ @@ -2692,7 +2692,7 @@ STATUS POOL_DisablePool( * STATUS Standard NSS status. */ -STATUS comn_PoolAlert( +STATUS comn_PoolAlert( GeneralMsg_s *genMsg, RootBeast_s *beast, /* Beast that error directly effects. Can * be NULL if CVA_SYSTEM_DATA is set. @@ -2756,7 +2756,7 @@ STATUS comn_PoolAlert( alertInfo->nva_station = -1; /* Unknown */ alertInfo->nva_flags = flags | NVA_FLAG_UNKNOWN_STATION; /* Station is unknown */ - + /* Track number of items queueud */ ++pool->v_alertListCount; DQ_ENQ(&pool->v_alertList,alertInfo,nva_alertList); @@ -2778,11 +2778,11 @@ STATUS comn_PoolAlert( * own use count. */ COMN_USE_BEAST(&pool->POOLroot); - - WORK_Schedule( &pool->v_alertWorkToDoFsm, (voidfunc_t)pool_AlertWorkToDoRoutine, 0); + + WORK_Schedule( &pool->v_alertWorkToDoFsm, pool_AlertWorkToDoRoutine, 0); RTN_STATUS(zOK); - + } /* End of comn_PoolAlert() */ /**************************************************************************** @@ -2799,9 +2799,9 @@ STATUS POOL_BST_ModifyInfo( zPoolInfo_s *poolInfo; derivedFromModifyInfo = COMN_GetNextParentBeastComnOp(pool->POOLbeastClass, - COMNOPS_INDEX(BST_modifyInfo),(statusfunc_t)POOL_BST_ModifyInfo); + COMNOPS_INDEX(BST_modifyInfo),POOL_BST_ModifyInfo); - if (((STATUS (*)(GeneralMsg_s *, RootBeast_s *, ModifyInfoMsg_s *, Xaction_s *))derivedFromModifyInfo)(genMsg, &pool->POOLroot, modifyMsg, xaction) != zOK) + if (derivedFromModifyInfo(genMsg,pool,modifyMsg,xaction) != zOK) { return zFAILURE; } @@ -2816,7 +2816,7 @@ STATUS POOL_BST_ModifyInfo( if (modifyMsg->modifyInfoMask & (zMOD_POOL_ATTRIBUTES | zMOD_POOL_NDS_OBJECT_ID)) { - if (pool->POOLauth.mayIDoThis(genMsg, pool, modifyMsg->parentZid, + if (pool->POOLauth.mayIDoThis(genMsg, pool, modifyMsg->parentZid, MAY_I_SUPERVISE) != zOK) { SetErrno(genMsg,zERR_NO_SET_PRIVILEGE); @@ -2831,7 +2831,7 @@ STATUS POOL_BST_ModifyInfo( } /* - * POOL_ChangePoolSetup - + * POOL_ChangePoolSetup - * Determines if the Pool should be processed. Generally, used by * command line UI routines. * @@ -2881,7 +2881,7 @@ BOOL POOL_ChangePoolSetup( /* - * POOL_ChangePoolCleanup - + * POOL_ChangePoolCleanup - * Releases resources that 'setup' reserved. * * WARNING - Only call if POOL_ChangePoolSetup returned TRUE. @@ -2936,9 +2936,9 @@ STATIC STATUS POOL_ChangePoolMSAP( } else { - /* We were asked to turn MSAP on, but the LSS did + /* We were asked to turn MSAP on, but the LSS did * not do it. Since the - * LSS ignored our change, but did not return an error, + * LSS ignored our change, but did not return an error, * this means * that the LSS simply does not support MSAP. */ aprintf(YELLOW,MSG("MSAP is not supported on pool \"%U\"...\n",612),name); @@ -3080,7 +3080,7 @@ STATUS POOL_ChangePoolWaterMark( STATUS status; COMN_STRUCT_INIT(modInfoMsg); - COMN_SETUP_MODIFY_TYPE_INFO_MSG(&modInfoMsg, 0, &info, 0, NULL); + COMN_SETUP_MODIFY_TYPE_INFO_MSG(&modInfoMsg, 0, &info, 0, NULL); modInfoMsg.parentZid = pool->POOLfirstParentZid; volInfo = &info.vol; /* we have to use the vol structure because it is the only @@ -3132,7 +3132,7 @@ STATUS POOL_ChangePoolWaterMarksByName( { if (*tmpName == L':') { - if (*(tmpName+1)) + if (*(tmpName+1)) { foundCount = TRUE; LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, buf, sizeof(buf), @@ -3140,7 +3140,7 @@ STATUS POOL_ChangePoolWaterMarksByName( waterMark = LB_atoi(&buf[0]); if (highWaterFlag) /* this is a highwater value */ - { + { if(waterMark > zMAX_HIGHWATERMARK) { waterMark = zMAX_HIGHWATERMARK; @@ -3242,7 +3242,7 @@ STATUS POOL_ChangePoolWaterMarksByName( (void) POOL_ChangePoolWaterMark(genMsg, pool, name, highWaterFlag, waterMark); ClearErrno(genMsg); COMN_PoolActiveUnlock(pool); - + COMN_Release( &pool ); /* remove useCount added by lookup*/ } @@ -3368,3 +3368,5 @@ CommonVolumeOps_s POOL_ComnVolOps = NULL, /* VOL_FCNTL */ }; + + diff --git a/src/nwnss/comn/common/comnRename.c b/src/nwnss/comn/common/comnRename.c index 1e70e6a..dabf6cf 100644 --- a/src/nwnss/comn/common/comnRename.c +++ b/src/nwnss/comn/common/comnRename.c @@ -66,7 +66,6 @@ #include "sbsMFL.h" #include "nssDebug.h" #include "lsa.h" -#include "inst.h" /************************************************************************** * This routine will rename the beast defined in "srcNameMsg" to @@ -178,7 +177,7 @@ STATIC STATUS REN_DoRenameBeast( * Check to see if we are returning a salvage file to an undeleted state. * If so then check space restrictions. *-------------------------------------------------------------------------*/ - if (srcBeast->FILEvolume->VOLenabledAttributes & + if (srcBeast->FILEvolume->VOLenabledAttributes & (zATTR_USER_SPACE_RESTRICTIONS | zATTR_DIR_QUOTAS)) { if (srcNameMsg->workNameType == zNTYPE_DELETED_FILE && @@ -220,9 +219,9 @@ STATIC STATUS REN_DoRenameBeast( goto error_cleanupSrcPrimaryXLatchedAndReturn; } - if (VOL_CheckUserSpace(genMsg, "aBeast->FILEroot, + if (VOL_CheckUserSpace(genMsg, "aBeast->FILEroot, storageInfo.filePhysSize) != zOK || - DIRQ_CheckDirQuotas(genMsg, "aBeast->FILEroot, + DIRQ_CheckDirQuotas(genMsg, "aBeast->FILEroot, (storageInfo.filePhysSize + usedDataStreamSize + usedEASize)) != zOK) { @@ -251,7 +250,7 @@ STATIC STATUS REN_DoRenameBeast( zASSERT(destNameMsg->curFile == NULL); /* destNameMsg needs to be ignored...we're renaming in the src dir only * and the new name is in replacePattern */ - if ((targetDir = COMN_LookupByZid(genMsg, srcNameMsg->curvol, + if ((targetDir = COMN_LookupByZid(genMsg, srcNameMsg->curvol, srcNameMsg->fileParentZid, NOTLATCHED, FALSE)) == NULL) { zASSERT("Unable to locate parent dir of the file being renamed"==NULL); @@ -271,7 +270,7 @@ STATIC STATUS REN_DoRenameBeast( * srcDir is simply a shared pointer with the targetDir. *-------------------------------------------------------------*/ srcDir = targetDir; - } + } else /* destNameMsg points to the targetDir, new name is in replacePattern */ { targetDir = destNameMsg->curFile; @@ -282,12 +281,12 @@ STATIC STATUS REN_DoRenameBeast( /* see if srcDir and targetDir are two different directories */ if (srcNameMsg->fileParentZid != targetDir->FILEzid) { - if ((srcDir = COMN_LookupByZid(genMsg, srcNameMsg->curvol, + if ((srcDir = COMN_LookupByZid(genMsg, srcNameMsg->curvol, srcNameMsg->fileParentZid, NOTLATCHED, FALSE)) == NULL) { zASSERT("Unable to locate parent dir of the file being renamed"==NULL); goto error_cleanupAndReturn; - } + } /*---------------------------------------------------------- * srcDir is a pointer to the source directory. This pointer @@ -295,7 +294,7 @@ STATIC STATUS REN_DoRenameBeast( * nameMsg so we must track it separately. * srcBeast points to the beast to be renamed. *----------------------------------------------------------*/ - releaseSrcDir = TRUE; + releaseSrcDir = TRUE; } else { @@ -307,7 +306,7 @@ STATIC STATUS REN_DoRenameBeast( } /*--------------------------------------------------------------------------- * Do not allow renaming to a deleted nameType This would be the case if - * the targetDirectory is a deleted directory or the dest nameType is + * the targetDirectory is a deleted directory or the dest nameType is * a deleted nameType. *---------------------------------------------------------------------------*/ if ((targetDirNameType == zNTYPE_DELETED_FILE) || @@ -326,7 +325,7 @@ STATIC STATUS REN_DoRenameBeast( * Check to see if we are accessing files on the persistent admin * volume via the admin volumes. */ - if ((PersistAdminVolume == NULL) || + if ((PersistAdminVolume == NULL) || ((((srcDir->FILEvolume != &AdminVolume.vol) || (srcDir->FILEzid < AVOL_FIRST_PERSISTENT_ZID)) || targetDir->FILEvolume != PersistAdminVolume) && @@ -522,12 +521,12 @@ STATIC STATUS REN_DoRenameBeast( ClearErrno(genMsg); /*** Everything is unlatched at this time so don't need to do anything - *** before event/fshook is called. If RESERVE_RSRC are added to + *** before event/fshook is called. If RESERVE_RSRC are added to *** this routine (Paul if you do this.. ) we will need to RELEASE_RSRC and *** and RESERVE_RSRC again ***/ /* Based on the nameType, this is either a salvage or a rename */ - hookType = (srcNameMsg->workNameType == zNTYPE_DELETED_FILE) ? + hookType = (srcNameMsg->workNameType == zNTYPE_DELETED_FILE) ? SalvageFile_Hook : F3RenameFile_Hook; if (hookType == SalvageFile_Hook) @@ -539,28 +538,28 @@ STATIC STATUS REN_DoRenameBeast( if (targetDir->FILEzid != srcDir->FILEzid) { SendBothRenameAndSalvageHooks = TRUE; - CHECK_FSHOOKS_RENAME_ENTER(F3RenameFile_Hook, &aStack->renameParms, status, - error_cleanupReleaseAndReturn, genMsg, srcNameMsg, + CHECK_FSHOOKS_RENAME_ENTER(F3RenameFile_Hook, &aStack->renameParms, status, + error_cleanupReleaseAndReturn, genMsg, srcNameMsg, newName, aStack->asciiNewName, targetDir->FILEzid, renMsg); } } else { - CHECK_FSHOOKS_RENAME_ENTER(F3RenameFile_Hook, &aStack->renameParms, status, - error_cleanupReleaseAndReturn, genMsg, srcNameMsg, + CHECK_FSHOOKS_RENAME_ENTER(F3RenameFile_Hook, &aStack->renameParms, status, + error_cleanupReleaseAndReturn, genMsg, srcNameMsg, newName, aStack->asciiNewName, targetDir->FILEzid, renMsg); } INIT_EVENT_ID_STATUS(id, aStack->exit.enterRetStatus); if (NEBEventInfo[EVENT_Rename_Enter].consumers) { - INIT_RENAME_ENTER_EVENT(genMsg, srcNameMsg, aStack->evBlk, + INIT_RENAME_ENTER_EVENT(genMsg, srcNameMsg, aStack->evBlk, EVENT_Rename_Enter, aStack->enter, id, newName, renMsg, targetDir->FILEzid); - ZOS_ProduceEvent(status,&aStack->evBlk); - CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, + ZOS_ProduceEvent(status,&aStack->evBlk); + CHECK_ENTER_RETURN(genMsg, status, aStack->evBlk, aStack->exit, error_cleanupReleaseAndReturn); } - + /*--------------------------------------------------------------------------- * Check if the srcBeast is Locked *---------------------------------------------------------------------------*/ @@ -581,7 +580,7 @@ STATIC STATUS REN_DoRenameBeast( } - /* For now, just check if the file is exclusive locked */ + /* For now, just check if the file is exclusive locked */ if ((srcBeast->FILEdenyReaderCount != 0) || (srcBeast->FILEdenyWriterCount != 0)) { @@ -662,11 +661,11 @@ STATIC STATUS REN_DoRenameBeast( } UNS_LATCH(&srcBeast->FILEbeastLatch); - /* If the beast being moved is a subdirectory, we need to do a + /* If the beast being moved is a subdirectory, we need to do a * check to make sure we're not moving the subdirectory to * a location below itself. */ - if (srcBeast->FILEattributes & zFA_SUBDIRECTORY) - { + if (srcBeast->FILEattributes & zFA_SUBDIRECTORY) + { /* for simplicity, start looking at the target dir itself */ nextParent = targetDir; COMN_USE_BEAST(&nextParent->FILEroot); @@ -693,7 +692,7 @@ STATIC STATUS REN_DoRenameBeast( goto error_cleanupRelease; } COMN_Release(&nextParent); - } + } /* * Before the file(s) can be moved we need to make sure that the @@ -704,16 +703,16 @@ STATIC STATUS REN_DoRenameBeast( * the directory, but that can happen anyway with files that are * already open. We will have to live with any adjustment errors. */ - sourceQuotas = + sourceQuotas = DIRQ_ThereAreDirQuotas(srcDir->FILEvolume, srcDir->FILEzid); - targetQuotas = + targetQuotas = DIRQ_ThereAreDirQuotas(targetDir->FILEvolume, targetDir->FILEzid); if (sourceQuotas || targetQuotas) { BOOL isPrimaryHardLink; /* See if we are renaming a non-Primary hard link */ - isPrimaryHardLink = ((srcPrimaryBeast) && + isPrimaryHardLink = ((srcPrimaryBeast) && (srcBeast->FILEattributes & zFA_HARDLINK) && (((HardLinkBeast_s *)srcBeast)->HARDLhlFlags & zHL_FIRST_HLNAME)); @@ -829,7 +828,7 @@ STATIC STATUS REN_DoRenameBeast( if (!(renMsg->renameFlags & zRENAME_KEEP_VFS_CACHE)) { - if ( COMN_LsaCleanupSetup( &existingBeast->FILEnamed, + if ( COMN_LsaCleanupSetup( &existingBeast->FILEnamed, &aStack->lsaDestInv) == zOK ) { if (existingPrimaryBeast != NULL) @@ -846,7 +845,7 @@ STATIC STATUS REN_DoRenameBeast( } } /* Delete the existing beast first. */ - if (BST_delete( genMsg, targetDir, existingBeast, + if (BST_delete( genMsg, targetDir, existingBeast, existingPrimaryBeast, existingNeighborBeast, xaction, FALSE, TRUE) != zOK) { @@ -856,7 +855,7 @@ STATIC STATUS REN_DoRenameBeast( /* The delete of the existing beast has succeeded. Keep the * transaction until done with all portions of the rename. */ - } + } else { /* The name already exists. It is either a different file, @@ -868,7 +867,7 @@ STATIC STATUS REN_DoRenameBeast( } } ClearErrno(genMsg); - + /*--------------------------------------------------------------------------- Now that a potential delete is finished, the srcPrimary and srcBeasts must be latched. These MAY BE the same as existingPrimary and existingNeighbor. @@ -883,7 +882,7 @@ STATIC STATUS REN_DoRenameBeast( if(srcPrimaryBeast == NULL) { zASSERT("Primary beast has dissappeared" == NULL); - ForceSetErrno(genMsg, zERR_INTERNAL_DIRECTORY_ERROR); + ForceSetErrno(genMsg, zERR_INTERNAL_DIRECTORY_ERROR); goto error_cleanupUnlatch; } if(srcPrimaryBeast != existingPrimaryBeast) @@ -935,7 +934,7 @@ STATIC STATUS REN_DoRenameBeast( } if (sourceQuotas) { - /* + /* * Use srcDir instead of srcBeast because the beast is now at * the destination. */ @@ -1019,11 +1018,11 @@ STATIC STATUS REN_DoRenameBeast( * a deadlock. We couldn't do it before, because we had not yet guaranteed * that the target directory was not below the src directory. *-------------------------------------------------------------------------*/ - + X_LATCH(&targetDir->FILEbeastLatch); /* targetDir is same as destNameMsg->curFIle, unless releaseTargetDir - * is TRUE. Set the proper flags so either the nameMsg cleanup + * is TRUE. Set the proper flags so either the nameMsg cleanup * will unlatch it, or it will be done manually */ if (releaseTargetDir) /* set if renameFlags & zRENAME_TARGET_IS_PATTERN */ targetDirLatched = TRUE; @@ -1061,7 +1060,7 @@ STATIC STATUS REN_DoRenameBeast( if (!(renMsg->renameFlags & zRENAME_KEEP_VFS_CACHE)) { - if ( COMN_LsaCleanupSetup( &existingBeast->FILEnamed, + if ( COMN_LsaCleanupSetup( &existingBeast->FILEnamed, &aStack->lsaDestInv) == zOK ) { if (existingPrimaryBeast != NULL) @@ -1078,7 +1077,7 @@ STATIC STATUS REN_DoRenameBeast( } } /* Delete the existing beast first. */ - if (BST_delete( genMsg, targetDir, existingBeast, + if (BST_delete( genMsg, targetDir, existingBeast, existingPrimaryBeast, existingNeighborBeast, xaction, FALSE, TRUE) != zOK) { @@ -1088,7 +1087,7 @@ STATIC STATUS REN_DoRenameBeast( /* The delete of the existing beast has succeeded. Keep the * transaction until done with all portions of the rename. */ - } + } else { /* The name already exists. It is either a different file, @@ -1119,7 +1118,7 @@ STATIC STATUS REN_DoRenameBeast( if(srcPrimaryBeast == NULL) { zASSERT("Primary beast has dissappeared" == NULL); - ForceSetErrno(genMsg, zERR_INTERNAL_DIRECTORY_ERROR); + ForceSetErrno(genMsg, zERR_INTERNAL_DIRECTORY_ERROR); goto error_cleanupUnlatch; } if(srcPrimaryBeast != existingPrimaryBeast) @@ -1164,7 +1163,7 @@ STATIC STATUS REN_DoRenameBeast( if (!(srcBeast->FILEattributes & (zFA_ARCHIVE | zFA_ATTR_ARCHIVE))) { /* - * If this is the OFF-to-ON transition of the file archive bits, + * If this is the OFF-to-ON transition of the file archive bits, * add the file to the volume's Modified Files List (if any). */ SBS_markFileModified(srcBeast, zFA_ARCHIVE | zFA_ATTR_ARCHIVE, 0); @@ -1219,14 +1218,14 @@ STATIC STATUS REN_DoRenameBeast( (NamedBeast_s *)srcDir, (NamedBeast_s *)targetDir, /* cnt srcNameMsg->fileNameUniquifier, renMsg->retNameUniquifier, */ destNameMsg->workNameType); - if (srcBeast->FILEattributes & zFA_SUBDIRECTORY) - { + if (srcBeast->FILEattributes & zFA_SUBDIRECTORY) + { /* If there are context handles pointing to this directory then * point them to the new place (same zid, but different parentZid) */ CXH_FixupAllContextHandlesOnBeast(genMsg,srcBeast,srcDir,targetDir, // cnt srcNameMsg->fileNameUniquifier, renMsg->retNameUniquifier, destNameMsg->workNameType); - } + } // /* Fixup any generic semantic agent handles which may point to the // * beast which was just moved */ // SAH_FixupAllSAHsOnBeast(genMsg, (NamedBeast_s *)srcBeast, @@ -1273,7 +1272,7 @@ STATIC STATUS REN_DoRenameBeast( { COMN_UnlatchAndRelease(&srcPrimaryBeast, XLATCHED); } - + if (srcDirLatched) UNX_LATCH(&srcDir->FILEbeastLatch); @@ -1304,7 +1303,7 @@ STATIC STATUS REN_DoRenameBeast( Ptr_lsa_invalidate_dentry( &aStack->lsaSrcInv); COMN_LATCH_NAMEMSG_BEASTS(srcNameMsg, srcLatchType); } - if (COMN_LsaCleanupSetup( &srcBeast->FILEnamed, + if (COMN_LsaCleanupSetup( &srcBeast->FILEnamed, &aStack->lsaDestInv) == zOK ) { aStack->lsaDestInv.lid_zid = zINVALID_ZID; @@ -1331,7 +1330,7 @@ sendExitEvent: */ if (hookType == SalvageFile_Hook) { - CHECK_FSHOOKS_SALVAGE_EXIT(SalvageFile_Hook, &aStack->salvageParms, genMsg, + CHECK_FSHOOKS_SALVAGE_EXIT(SalvageFile_Hook, &aStack->salvageParms, genMsg, srcNameMsg, newName, aStack->asciiNewName); if (SendBothRenameAndSalvageHooks) { @@ -1342,7 +1341,7 @@ sendExitEvent: } else { - CHECK_FSHOOKS_RENAME_EXIT(F3RenameFile_Hook, &aStack->renameParms, genMsg, + CHECK_FSHOOKS_RENAME_EXIT(F3RenameFile_Hook, &aStack->renameParms, genMsg, srcNameMsg, newName, aStack->asciiNewName, zINVALID_ZID, renMsg); } if (NEBEventInfo[EVENT_Rename_Exit].consumers) @@ -1390,7 +1389,7 @@ error_cleanupUnlatch: /* Tell the nameMsg cleanup to not unlatch */ srcNameMsg->latchType = NOTLATCHED; } - + if(existingNeighborBeast) { UNX_LATCH(&existingNeighborBeast->FILEbeastLatch); @@ -1418,7 +1417,7 @@ error_cleanupUnlatch: error_cleanupRelease: if (srcPrimaryBeast) COMN_Release(&srcPrimaryBeast); - + if (existingPrimaryBeast) COMN_Release(&existingPrimaryBeast); @@ -1443,7 +1442,7 @@ error_cleanupRelease: error_cleanupReleaseAndReturn: if (srcPrimaryBeast) COMN_Release(&srcPrimaryBeast); - + if (existingPrimaryBeast) COMN_Release(&existingPrimaryBeast); @@ -1586,14 +1585,14 @@ STATUS COMN_Rename( /* Make sure that a single component exists */ if ((destNameMsg->retParseFlags & - (NAMRETPFL_haveAParsedComponent | NAMRETPFL_lastComponent)) != - (NAMRETPFL_haveAParsedComponent | NAMRETPFL_lastComponent)) + (NAMRETPFL_haveAParsedComponent | NAMRETPFL_lastComponent)) != + (NAMRETPFL_haveAParsedComponent | NAMRETPFL_lastComponent)) { SetErrno(genMsg,zERR_INVALID_PATH); goto cleanup_target; } zASSERT(destNameMsg->scanMsg.retScanFlags & NSRETSFL_componentIsUnicode); - zASSERT(destNameMsg->scanMsg.retUnicodeComp != NULL); + zASSERT(destNameMsg->scanMsg.retUnicodeComp != NULL); /* Move the replace pattern to a separate work buffer */ replacePattern = tempWorkBuffer; @@ -1640,10 +1639,10 @@ STATUS COMN_Rename( * destNameMsg->retParseFlags - better be NAMRETPFL_lastComponent & NAMRETPFL_haveAParsedComponent *---------------------------------------------------------------------------*/ zASSERT((destNameMsg->retParseFlags & - (NAMRETPFL_haveAParsedComponent | NAMRETPFL_lastComponent)) == + (NAMRETPFL_haveAParsedComponent | NAMRETPFL_lastComponent)) == (NAMRETPFL_haveAParsedComponent | NAMRETPFL_lastComponent)); zASSERT(destNameMsg->scanMsg.retScanFlags & NSRETSFL_componentIsUnicode); - zASSERT(destNameMsg->scanMsg.retUnicodeComp != NULL); + zASSERT(destNameMsg->scanMsg.retUnicodeComp != NULL); zASSERT(destNameMsg->curFile->FILEattributes & zFA_SUBDIRECTORY); /* Move the replace pattern to a separate work buffer */ @@ -1651,12 +1650,12 @@ STATUS COMN_Rename( unimcpy(replacePattern,destNameMsg->scanMsg.retUnicodeComp, zMAX_COMPONENT_NAME); replacePattern[zMAX_COMPONENT_NAME] = 0; /* Force null termination */ - } + } else /* No wildcard characters in dest name */ { /*--------------------------------------------------------------------------- * No wildcard characters are in the dest name. Resolve the leafname - * to figure out what kind of rename to do. + * to figure out what kind of rename to do. * Following are a list rules for rename: * - If the dest filename does not exist, we want to rename/move the src * file to this filename in this directory. @@ -1704,7 +1703,7 @@ STATUS COMN_Rename( * curFile. If we need to back up later, we will do it * using parentZid. */ COMN_Release(&tempDir); - + /* Move the replace pattern to a separate work buffer and */ /* leave replacePattern == NULL until later on - SEE ABOVE */ if (saveCurComponent != NULL) @@ -1773,7 +1772,7 @@ STATUS COMN_Rename( zASSERT(destNameMsg->curFile != NULL); zASSERT(destNameMsg->scanMsg.retUnicodeComp != NULL); zASSERT((destNameMsg->retParseFlags & - (NAMRETPFL_haveAParsedComponent | NAMRETPFL_lastComponent)) == + (NAMRETPFL_haveAParsedComponent | NAMRETPFL_lastComponent)) == (NAMRETPFL_haveAParsedComponent | NAMRETPFL_lastComponent)); /* Move the replace pattern to a separate work buffer */ @@ -1872,7 +1871,7 @@ STATUS COMN_Rename( * rather than a directory object. * FixFixFix6 -- We may want to revisit this decision *---------------------------------------------------------------------------*/ - if (!(COMN_IsDerivedFrom(srcNameMsg->curDataStream,zFTYPE_FILE)) && + if (!(COMN_IsDerivedFrom(srcNameMsg->curDataStream,zFTYPE_FILE)) && !(srcNameMsg->curDataStream->NAMEDattributes & zFA_HARDLINK)) { SetErrno(genMsg,zERR_CANT_RENAME_DATA_STREAMS); @@ -1894,7 +1893,7 @@ STATUS COMN_Rename( * Check if the source beast is a directory, and if it is the exact same * directory as the target directory. If it is, we need to back the target * up to its parent directory...because it is the directory itself which - * is being renamed, so we need destNameMsg to point at the directory's + * is being renamed, so we need destNameMsg to point at the directory's * parent directory. *-------------------------------------------------------------------------*/ if ((srcNameMsg->curFile->FILEattributes & zFA_SUBDIRECTORY) && @@ -1917,9 +1916,9 @@ STATUS COMN_Rename( destNameMsg->fileParentZid = destNameMsg->curFile->FILEfirstParentZid; // cnt destNameMsg->fileNameUniquifier = // cnt destNameMsg->curFile->FILEfirstParentNameUniquifier; - destNameMsg->fileNameType = + destNameMsg->fileNameType = destNameMsg->curFile->FILEfirstParentNameType; - destNameMsg->workNameType = + destNameMsg->workNameType = destNameMsg->curFile->FILEfirstParentNameType; if (destNameMsg->workNameType == zNTYPE_FILE) destNameMsg->retParseFlags &= ~NAMRETPFL_hasDeletedNameType; @@ -1967,7 +1966,7 @@ STATUS COMN_Rename( * This is necessary, because the act of renaming a beast may move it down * in the name tree so that we would try to rename it again later with the * exact same rename. This also prevents us from renaming a beast if another - * rename from a different thread is started after us, but renames the beast + * rename from a different thread is started after us, but renames the beast * before we get to it. *---------------------------------------------------------------------------*/ X_LATCH(&srcNameMsg->curvol->VOLbeastLatch); @@ -2092,7 +2091,7 @@ STATUS COMN_Rename( } } - /* reset the nameMessage back to a search pattern type for the + /* reset the nameMessage back to a search pattern type for the * next loop of ReadDir */ checkNextFile: if (COMN_ResetNameMsgToSearchPattern(genMsg,srcNameMsg) != zOK) diff --git a/src/nwnss/comn/common/comnStartup.c b/src/nwnss/comn/common/comnStartup.c index 757ec4c..7b321c1 100644 --- a/src/nwnss/comn/common/comnStartup.c +++ b/src/nwnss/comn/common/comnStartup.c @@ -92,14 +92,14 @@ void COMN_FSHOOKS_Startup() LONG result; ASSERT_MPKNSS_LOCK(); - - ZOS_FindPublicRecordStructure(result, MSGNot("\x10""FSHookParmsArray"), 0, + + ZOS_FindPublicRecordStructure(result, MSGNot("\x10""FSHookParmsArray"), 0, &retList, (LONG *)&symRec) if (result != 0) { return; } - memcpy(&FSHooksList, symRec->IPDActualAddress, + memcpy(&FSHooksList, symRec->IPDActualAddress, sizeof(FSHookParms_s) * MAX_NUMBER_FSHOOKS); #endif return; @@ -285,7 +285,7 @@ STATUS ZLOG_ssprintf( bufferLength - *retLen, format, args ); if ( added < 0 ) { /* Encoding error in format string */ - return( zERR_BAD_PARAMETER_VALUE ); + return( zERR_BAD_PARAMETER_VALUE ); } if ( added >= (bufferLength - *retLen) ) { /* Could do a re-alloc here and then error on out of memory */ diff --git a/src/nwnss/comn/common/comnTask.c b/src/nwnss/comn/common/comnTask.c index ff1284b..dfd651b 100644 --- a/src/nwnss/comn/common/comnTask.c +++ b/src/nwnss/comn/common/comnTask.c @@ -24,16 +24,18 @@ | |--------------------------------------------------------------------------- | - | $Author: vandana $ - | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ | | $RCSfile$ - | $Revision: 1177 $ + | $Revision: 1177 $ | |--------------------------------------------------------------------------- | This module is used to: | Manage Masters, Tasks, and User Transactions +-------------------------------------------------------------------------*/ +#include + #include #include @@ -175,7 +177,7 @@ UserXaction_s *resolveXaction ( return uxaction; } return NULL; -} +} void registerUserXaction ( Task_s *task, @@ -248,12 +250,12 @@ UserXaction_s *lookupActiveXaction (Xid_t xid) { UserXaction_s *uxaction = lookupXaction(xid); - /* An active transaction may be in the begin or active state because a - * transaction's state only becomes ACTIVE_UXACTION when the first write - * takes place. However, while they are not in the active state they are + /* An active transaction may be in the begin or active state because a + * transaction's state only becomes ACTIVE_UXACTION when the first write + * takes place. However, while they are not in the active state they are * technically active when in the BEGIN_UXACTION state */ - if ((uxaction != NULL) && + if ((uxaction != NULL) && ((uxaction->state == ACTIVE_UXACTION) || (uxaction->state == BEGIN_UXACTION))) { return uxaction; @@ -354,8 +356,8 @@ UserXaction_s *allocUserXaction ( uxaction->xid = xid; uxaction->state = IDLE_UXACTION; - uxaction->waitFor = NULL; - + uxaction->waitFor = NULL; + registerUserXaction(task, parentXaction, uxaction); RTN_PTR(uxaction); @@ -422,14 +424,14 @@ STATUS COMN_BeginTask ( ENTER(TUSERX, COMN_BeginTask); if (*taskID == 0) - { + { while (1) { *taskID = ++master->nextTaskID; /* check if this task ID is used */ if (lookupTask(master, *taskID) == NULL) - { + { break; } } @@ -734,19 +736,19 @@ STATUS MGR_Startup () goto errMSG_RegisterType; } rc = objCacheCreate( &TaskObjCache, "Tasks", - sizeof(Task_s), (voidfunc_t)initTask); + sizeof(Task_s), initTask); if (rc != zOK) { goto errTaskObjCache; } rc = objCacheCreate( &UserXactionObjCache, "UserXactions", - sizeof(UserXaction_s), (voidfunc_t)initUserXaction); + sizeof(UserXaction_s), initUserXaction); if (rc != zOK) { goto errUserXactionObjCache; } rc = objCacheCreate( &HomeXactionObjCache, "HomeXactions", - sizeof(HomeXaction_s), (voidfunc_t)initHomeXaction); + sizeof(HomeXaction_s), initHomeXaction); if (rc != zOK) { goto errHomeXactionObjCache; diff --git a/src/nwnss/comn/common/comnUnicode.c b/src/nwnss/comn/common/comnUnicode.c index ed51f90..87b47c9 100644 --- a/src/nwnss/comn/common/comnUnicode.c +++ b/src/nwnss/comn/common/comnUnicode.c @@ -34,6 +34,8 @@ | This module is used to: | Support routines for NCP handling +-------------------------------------------------------------------------*/ +#include + #include #include "comnPublics.h" diff --git a/src/nwnss/comn/common/comnVariableData.c b/src/nwnss/comn/common/comnVariableData.c index d511c5a..588c436 100644 --- a/src/nwnss/comn/common/comnVariableData.c +++ b/src/nwnss/comn/common/comnVariableData.c @@ -58,8 +58,8 @@ typedef struct RVD_functions_t RVD_UnpackFunc_t unpackFunc; RVD_FreeFunc_t freeFunc; RVD_GetXMLInfoFunc_t getXMLInfoFunc; - RVD_SetXMLInfoFunc_t setXMLInfoFunc; - BOOL registered; + RVD_SetXMLInfoFunc_t setXMLInfoFunc; + BOOL registered; } RVD_functions_t; STATIC RVD_functions_t RVD_functions[RVD_MAX_ELEMENTS] = {{0}}; @@ -80,11 +80,11 @@ STATUS COMN_RegisterRootVariableDataType( RVD_PackFunc_t packFunc, RVD_UnpackFunc_t unpackFunc, RVD_FreeFunc_t freeFunc, - RVD_GetXMLInfoFunc_t getXMLInfoFunc, /* can be NULL */ + RVD_GetXMLInfoFunc_t getXMLInfoFunc, /* can be NULL */ RVD_SetXMLInfoFunc_t setXMLInfoFunc) /* can be NULL */ { ASSERT_MPKNSS_LOCK(); - if (rvdType >= RVD_MAX_ELEMENTS) + if (rvdType > RVD_MAX_ELEMENTS) { SetErrno(genMsg, zERR_INVALID_REGISTRATION_TYPE); return(zFAILURE); @@ -131,7 +131,7 @@ void COMN_UnRegisterRootVariableDataType( NINT rvdType) { ASSERT_MPKNSS_LOCK(); - if (rvdType >= RVD_MAX_ELEMENTS) + if (rvdType > RVD_MAX_ELEMENTS) return; RVD_functions[rvdType].packedSizeFunc = NULL; @@ -158,7 +158,7 @@ NINT COMN_PackedSizeRootVariableData( /* Call the registered function for each element with a non-NULL pointer */ for (idx=0; idxROOTvariableData)[idx])) { zASSERT(RVD_functions[idx].packedSizeFunc != NULL); @@ -184,7 +184,7 @@ BYTE *COMN_PackRootVariableData( /* Call the registered function for each element with a non-NULL pointer */ for (idx=0; idxROOTvariableData)[idx])) { zASSERT(RVD_functions[idx].packFunc != NULL); @@ -259,7 +259,7 @@ void COMN_FreeRootVariableData( RootBeast_s *beast) { NINT idx; - + ASSERT_MPKNSS_LOCK(); if (beast->ROOTvariableData) { @@ -277,7 +277,7 @@ void COMN_FreeRootVariableData( free( beast->ROOTvariableData); beast->ROOTvariableData = NULL; } -} +} /**************************************************************************** @@ -291,7 +291,7 @@ STATUS COMN_InitRootVariableData( ASSERT_MPKNSS_LOCK(); if (beast->ROOTvariableData) return(zOK); - + beast->ROOTvariableData = zalloc( sizeof(void *) * RVD_MAX_ELEMENTS); if (beast->ROOTvariableData == NULL) { @@ -315,8 +315,8 @@ STATUS COMN_GetRootVariableDataXMLInfo( NINT idx; NINT len; STATUS status = zOK; - - + + ASSERT_MPKNSS_LOCK(); if (beast->ROOTvariableData) @@ -329,7 +329,7 @@ STATUS COMN_GetRootVariableDataXMLInfo( RVD_functions[idx].getXMLInfoFunc != NULL) { len = 0; - + status = RVD_functions[idx].getXMLInfoFunc(genMsg, beast, bufLen - *infoLen, &buf[*infoLen], &len); if (status != zOK) @@ -342,7 +342,7 @@ STATUS COMN_GetRootVariableDataXMLInfo( } } - return status; + return status; } /**************************************************************************** @@ -354,14 +354,14 @@ STATUS COMN_SetRootVariableDataXMLInfo( RootBeast_s *beast, NINT bufLen, utf8_t *buf, - Xaction_s *xaction, + Xaction_s *xaction, BOOL doChange) { NINT idx; STATUS status = zOK; - + ASSERT_MPKNSS_LOCK(); - + if (beast->ROOTvariableData) { /* Call the registered function for each element with a non-NULL pointer */ @@ -371,7 +371,7 @@ STATUS COMN_SetRootVariableDataXMLInfo( ((*beast->ROOTvariableData)[idx]) && RVD_functions[idx].setXMLInfoFunc != NULL) { - status = RVD_functions[idx].setXMLInfoFunc(genMsg, beast, + status = RVD_functions[idx].setXMLInfoFunc(genMsg, beast, bufLen, buf, xaction, doChange); if (status != zOK) { @@ -381,5 +381,6 @@ STATUS COMN_SetRootVariableDataXMLInfo( } } - return status; + return status; } + diff --git a/src/nwnss/comn/common/comnVol.c b/src/nwnss/comn/common/comnVol.c index 99cfe18..2c1e8cf 100644 --- a/src/nwnss/comn/common/comnVol.c +++ b/src/nwnss/comn/common/comnVol.c @@ -90,9 +90,6 @@ #include "lsa.h" #include "ndp_idbroker.h" #endif -#ifdef NSS_USERSPACE -#include -#endif #if zNETWARE #include "nwccs.h" #endif @@ -277,32 +274,32 @@ GROUP_EVENT evNSSVolDmtDevDeact = GROUP_EVENT evNSSVolDmtDevDeactNonIO = { - GEventcbID, VTLong, 0, VolumeMgrSubjects + 36, 0, 0, - nmVolDeactSeriousNonIOError, &NSSVolumeDeactivatedDueToSeriousError, 0, 0 + GEventcbID, VTLong, 0, VolumeMgrSubjects + 36, 0, 0, + nmVolDeactSeriousNonIOError, &NSSVolumeDeactivatedDueToSeriousError, 0, 0 }; GROUP_EVENT evNSSPoolDmtDevDeact = { - GEventcbID, VTLong, 0, VolumeMgrSubjects + 37, 0, 0, - nmPoolDeactSeriousIOError, &NSSPoolDeactivatedDueToSeriousIOError, 0, 0 + GEventcbID, VTLong, 0, VolumeMgrSubjects + 37, 0, 0, + nmPoolDeactSeriousIOError, &NSSPoolDeactivatedDueToSeriousIOError, 0, 0 }; GROUP_EVENT evNSSPoolDmtDevDeactNonIO = { - GEventcbID, VTLong, 0, VolumeMgrSubjects + 38, 0, 0, - nmPoolDeactSeriousNonIOError, &NSSPoolDeactivatedDueToSeriousError, 0, 0 + GEventcbID, VTLong, 0, VolumeMgrSubjects + 38, 0, 0, + nmPoolDeactSeriousNonIOError, &NSSPoolDeactivatedDueToSeriousError, 0, 0 }; GROUP_EVENT evNSSVolumeNeedsToBeReZid = { - GEventcbID, VTLong, 0, VolumeMgrSubjects + 39, 0, 0, - nmNSSVolumeNeedsToBeReZid, &NSSVolumeNeedsToBeReZid, 0, 0 + GEventcbID, VTLong, 0, VolumeMgrSubjects + 39, 0, 0, + nmNSSVolumeNeedsToBeReZid, &NSSVolumeNeedsToBeReZid, 0, 0 }; GROUP_EVENT evNSSVolumeClusterROError = { - GEventcbID, VTLong, 0, VolumeMgrSubjects + 40, 0, 0, - nmNSSVolumeClusterROError, &NSSVolumeClusterROError, 0, 0 + GEventcbID, VTLong, 0, VolumeMgrSubjects + 40, 0, 0, + nmNSSVolumeClusterROError, &NSSVolumeClusterROError, 0, 0 }; @@ -542,7 +539,7 @@ void VOL_StartPurgeAllDeletedFilesThread( Volume_s *vol); /* - * VOL_ChangeVolumeSetup - + * VOL_ChangeVolumeSetup - * Determines if the Volume should be processed. Generally, used by * command line UI routines. * @@ -595,7 +592,7 @@ BOOL VOL_ChangeVolumeSetup( /* - * VOL_ChangeVolumeCleanup - + * VOL_ChangeVolumeCleanup - * Releases resources that 'setup' reserved. * * WARNING - Only call if VOL_ChangeVolumeSetup returned TRUE. @@ -616,7 +613,7 @@ void VOL_ChangeVolumeCleanup( * STATUS Standard NSS status. */ -STATUS comn_VolumeAlert( +STATUS comn_VolumeAlert( GeneralMsg_s *genMsg, RootBeast_s *beast, /* Beast that error directly effects. Can * be NULL if CVA_SYSTEM_DATA is set. @@ -655,8 +652,8 @@ STATUS comn_VolumeAlert( } alertInfo->nva_volumeZID = volume->VOLroot.zid; - zASSERT((beast != NULL) || (flags & (CVA_SYSTEM_DATA | - CVA_REZID_NEEDED | + zASSERT((beast != NULL) || (flags & (CVA_SYSTEM_DATA | + CVA_REZID_NEEDED | CVA_CLUSTER_RO_ERROR))); if ( beast != NULL ) { @@ -669,8 +666,8 @@ STATUS comn_VolumeAlert( DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, ( CYAN,MSGNot("%s nva_beastZID ZID set to %Ld\n"), WHERE, alertInfo->nva_beastZID ) ); - zASSERT((buffer != NULL) || (flags & (CVA_SYSTEM_DATA | - CVA_REZID_NEEDED | + zASSERT((buffer != NULL) || (flags & (CVA_SYSTEM_DATA | + CVA_REZID_NEEDED | CVA_CLUSTER_RO_ERROR))); if ( buffer != NULL ) { @@ -709,11 +706,11 @@ STATUS comn_VolumeAlert( * own use count. */ COMN_USE_BEAST(&volume->VOLroot); - - WORK_Schedule( &volume->v_alertWorkToDoFsm, (voidfunc_t)vol_AlertWorkToDoRoutine, 0); + + WORK_Schedule( &volume->v_alertWorkToDoFsm, vol_AlertWorkToDoRoutine, 0); RTN_STATUS(zOK); - + } /* End of comn_VolumeAlert() */ @@ -751,7 +748,7 @@ STATUS comn_VolumeAlert( * ALERTS queued to the poor users. */ -STATUS COMN_VolumeAlert( +STATUS COMN_VolumeAlert( GeneralMsg_s *genMsg, RootBeast_s *beast, /* Beast that error directly effects. Can * be NULL if CVA_SYSTEM_DATA is set. @@ -844,7 +841,7 @@ STATUS COMN_VolumeAlert( ClearErrno( genMsg ); } RTN_STATUS(zOK); - + } /* End of COMN_VolumeAlert() */ @@ -917,7 +914,7 @@ CVNL_s CVNL; * calling COMN_Release. * If the volume being looked up is an Internal Volume(IV) then the volume * will generally not be found. To find a IV volume GM_FLAGS_INTERNAL_VOLUME - * must be set in the genMsg. See COMN_INCLUDE_INTERNAL_VOLUMES and + * must be set in the genMsg. See COMN_INCLUDE_INTERNAL_VOLUMES and * COMN_EXCLUDE_INTERNAL_VOLUMES. * * Notes - @@ -952,7 +949,7 @@ Volume_s *COMN_VolumeNameLookup( ( !(volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP)) ) ) && - ( VOL_ACCESSIBLE2(volume, genMsg) || gInternalVolumes ) ) + ( VOL_ACCESSIBLE2(volume, genMsg) || gInternalVolumes ) ) { /* The v_volumeName check for NULL is required because the Volume_s * constructor places us on the NSSMasterVolumeList before we @@ -1106,7 +1103,7 @@ void COMN_VolumeStateChangeReport( * * This function will return the next volume in the master volume list. * If the curVolume pointer is passed in as NULL, this will return the first - * volume in the list, otherwise, it will return the volume in the list + * volume in the list, otherwise, it will return the volume in the list * immediately following the specified volume. * * NOTE -- This increments the volume's use count, locking it into memory. @@ -1123,7 +1120,7 @@ Volume_s *COMN_GetNextVolume( again:; if (curVolume == NULL) { - SET_PEEK(&NSSMasterVolumeList, retVolume, Volume_s, masterVolLink); + SET_PEEK(&NSSMasterVolumeList, retVolume, Volume_s, masterVolLink); } else { @@ -1139,7 +1136,7 @@ again:; COMN_USE_BEAST(&retVolume->VOLroot); } RTN_PTR(retVolume); - + } /**************************************************************************** @@ -1168,7 +1165,7 @@ STATUS COMN_GetVolumeName( } /**************************************************************************** - * COMN_LockVolumeDeactive + * COMN_LockVolumeDeactive * * This function is used to lock a volume in the ACTIVE state so it cannot * be deactivated. If the volume is not already in an ACTIVE state, or if @@ -1194,7 +1191,7 @@ STATUS COMN_LockVolumeDeactive( /**************************************************************************** * COMN_UnlockVolumeDeactive - * + * * This function releases a "keep deactive" lock on a volume. *****************************************************************************/ void COMN_UnlockVolumeDeactive( @@ -1208,7 +1205,7 @@ void COMN_UnlockVolumeDeactive( #if 0 //enum { TRACK_CALLERS = 11, NUM_TRACK = 1000 }; -// +// //typedef struct TrackVolLock_s { // ADDR process; // void *callers[TRACK_CALLERS]; @@ -1238,7 +1235,7 @@ void COMN_UnlockVolumeDeactive( //void trackVolUnlock () //{ // TrackVolLock_s *track; -// +// // for (track = TrackVolLock; track < NextVolLock; ++track) { // if (track->process == RunningProcess) { // --NextVolLock; @@ -1253,7 +1250,7 @@ void COMN_UnlockVolumeDeactive( #endif /**************************************************************************** - * COMN_LockVolumeActive + * COMN_LockVolumeActive * * This function is used to lock a volume in the ACTIVE state so it cannot * be deactivated. If the volume is not already in an ACTIVE state, or if @@ -1277,7 +1274,7 @@ STATUS COMN_LockVolumeActive( * the volume into an active state so just pretend we did */ return(zOK); } - + ++volume->VOLv_keepActiveUseCount; if ((volume->state != zVOLSTATE_ACTIVE) || (volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP)) @@ -1298,7 +1295,7 @@ allowLock: /**************************************************************************** * COMN_UnlockVolumeActive - * + * * This function releases a "keep active" lock on a volume. *****************************************************************************/ void COMN_UnlockVolumeActive( @@ -1378,7 +1375,7 @@ STATUS COMN_VolumeLock( /**************************************************************************** * COMN_UnlockVolume - * + * * This function releases a lock on a volume. *****************************************************************************/ void COMN_UnlockVolume( @@ -1395,7 +1392,7 @@ void COMN_UnlockVolume( /**************************************************************************** * COMN_RegisterForVolumeEvents - * + * * This function allows the caller to register callback routines to be * called whenever a certain event type happens to any volume. * @@ -1501,7 +1498,7 @@ EXPORT_SYMBOL(COMN_RemoveVolumeFromAllLists); /**************************************************************************** * This will send an event to each registered semantic agent, informing them * that we are about to deactivate the volume. The first non-zOK status - * causes this function to return without notifying the other + * causes this function to return without notifying the other *****************************************************************************/ STATUS VOL_SendDeactivateWarningToSAgents( GeneralMsg_s *genMsg, @@ -1517,7 +1514,7 @@ STATUS VOL_SendDeactivateWarningToSAgents( ASSERT_MPKNSS_LOCK(); for (i=0;i <= MaxVolumeEventSAgent;i++) { - if ((VolumeEventFuncs[i] != NULL) && + if ((VolumeEventFuncs[i] != NULL) && (VolumeEventFuncs[i]->volumeDeactivateWarning != NULL)) { status = VolumeEventFuncs[i]->volumeDeactivateWarning(genMsg,volume); @@ -1543,7 +1540,7 @@ void VOL_SendDeactivateEventToSAgents( ASSERT_MPKNSS_LOCK(); for (i=0;i <= MaxVolumeEventSAgent;i++) { - if ((VolumeEventFuncs[i] != NULL) && + if ((VolumeEventFuncs[i] != NULL) && (VolumeEventFuncs[i]->volumeDeactivated != NULL)) { VolumeEventFuncs[i]->volumeDeactivated(&volume->VOLvolumeID); @@ -1651,10 +1648,10 @@ STATUS COMN_FlushVolume( * do not need to change. * */ -void *VOL_BstNew( +void *VOL_BstNew( GeneralMsg_s *genMsg, NINT beastClassID, /* ID assigned by Novell for the Volume type - * being created. + * being created. */ void *voidOwnerVol, /* Owner of the volume. Currently this must * be the Admin volume. @@ -1680,14 +1677,14 @@ void *VOL_BstNew( * NOTE - * That the VolumeID and Name are the only Persistnet Volume_s items that * are always correct. I.E. when the Volume is in any volume state these - * fields are correct. Most persistent field are only valid in the + * fields are correct. Most persistent field are only valid in the * ACTIVE state. * *****************************************************************************/ -void *VOL_BstNew2( +void *VOL_BstNew2( GeneralMsg_s *genMsg, NINT beastClassID, /* ID assigned by Novell for the Volume type - * being created. + * being created. */ void *voidOwnerVol, /* Owner of the volume. Currently this must * be the Admin volume. @@ -1728,7 +1725,7 @@ void *VOL_BstNew2( /*--------------------------------------------------------------------------- | Set the authorization model. - *-------------------------------------------------------------------------*/ + *-------------------------------------------------------------------------*/ zASSERT(authModelID == zFTYPE_ZAS_AUTH_MODEL || authModelID == zFTYPE_UNIX_AUTH_MODEL); newVolume->p.authModelID = authModelID; AUTHSYS_VolInit(genMsg, newVolume, authModelID); @@ -1776,7 +1773,7 @@ void *VOL_BstNew2( /************************************************************************** - * + * ***************************************************************************/ STATUS VOL_Activate( GeneralMsg_s *genMsg, @@ -1800,7 +1797,7 @@ STATUS VOL_Activate( } /************************************************************************** - * + * ***************************************************************************/ STATUS VOL_Deactivate( GeneralMsg_s *genMsg, @@ -1888,7 +1885,7 @@ void VOL_VolumeSignalHandler( ENTER(TCOMMON,VOL_VolumeSignalHandler); defaultSignal(agent); RTN_VOID(); -} +} @@ -1996,13 +1993,9 @@ STATUS VOL_UnLoadSystemBeasts( void VOL_CleanupInodeBeastLink(RootBeast_s *beast) { -#ifdef NSS_USERSPACE - LsaInode_s *lsaInode = NssLsaXattrUserspaceInodePrivate(beast->rb_inode); -#else LsaInode_s *lsaInode = STRUCT(beast->rb_inode,LsaInode_s,li_inode); -#endif File_s *tmpBeast; - + tmpBeast = lsaInode->li_beast; if (tmpBeast) { @@ -2031,7 +2024,7 @@ static inline int beast_vollink_count(DQhead_t *head) /***************************************************************** * - * Move the beasts waiting to be purged to the front of the + * Move the beasts waiting to be purged to the front of the * WorkLowWaitingListHead. * *****************************************************************/ @@ -2048,7 +2041,7 @@ static void purge_volume_beasts_first( Volume_s *volume) ** of a million items on a circular list. So I will go through this ** list holding the spin lock and change the order of the items. ** I want to make sure that the purging beasts that are for this - ** volume are moved to the front of the list and so they are + ** volume are moved to the front of the list and so they are ** processed first. **/ CIR_INIT(front); @@ -2061,7 +2054,7 @@ static void purge_volume_beasts_first( Volume_s *volume) { break; } - if (fsm->action == BST_SignalPurge) + if (fsm->action == BST_SignalPurge) { beast = STRUCT(fsm, RootBeast_s, ROOTmycache.agent.fsm); if (beast->ROOTvolume == volume) @@ -2124,7 +2117,7 @@ VOL_FATV_Again: if (beast == NULL) break; if (beast->rb_inode != NULL) - { + { VOL_CleanupInodeBeastLink(beast); } if (beast->bstState & BST_STATE_PURGING) @@ -2242,7 +2235,7 @@ VOL_FATV_Again: * free the beast, just in case somebody genuine has the useCount on * it. */ - BST_UNLINK_FROM_ALL_LISTS(beast); + BST_UNLINK_FROM_ALL_LISTS(beast); BST_tossAsync(beast); } while (DQ_NOT_EMPTY(&beastStillInUse)) @@ -2258,7 +2251,7 @@ VOL_FATV_Again: * free the beast, just in case somebody genuine has the useCount on * it. */ - BST_UNLINK_FROM_ALL_LISTS(beast); + BST_UNLINK_FROM_ALL_LISTS(beast); BST_tossAsync(beast); } @@ -2680,10 +2673,10 @@ STATUS VOL_Rename( /* Tell any caring SAs about the rename */ for (idx=0; idx <= MaxVolumeEventSAgent; idx++) { - if ((VolumeEventFuncs[idx] != NULL) && - (VolumeEventFuncs[idx]->VolumeNameChanged != NULL)) + if ((VolumeEventFuncs[idx] != NULL) && + (VolumeEventFuncs[idx]->VolumeNameChanged != NULL)) { - status1 = VolumeEventFuncs[idx]->VolumeNameChanged( + status1 = VolumeEventFuncs[idx]->VolumeNameChanged( &dummyGenMsg, volume, newVolumeName ); if ( status1 != zOK ) { @@ -2745,7 +2738,7 @@ STATUS VOL_ProcessKnownVolumes( unicpy(&pathStr[AdminVolNameLen], L":"); unicpy(&pathStr[AdminVolNameLen+1], AdminVolDirs[AV_VOLUME_DIRECTORY].name); - ZOS_zOpen(status, rootKey, zNO_TASK, zNSPACE_LONG, + ZOS_zOpen(status, rootKey, zNO_TASK, zNSPACE_LONG, pathStr, zRR_SCAN_ACCESS, &retKey); if (status != zOK) { @@ -2755,7 +2748,7 @@ STATUS VOL_ProcessKnownVolumes( for(;;) { - ZOS_zWildRead(status, retKey, zPFMT_UTF8, zNTYPE_FILE, NULL, 0, + ZOS_zWildRead(status, retKey, zPFMT_UTF8, zNTYPE_FILE, NULL, 0, zGET_NAME, sizeof(aStack->info), zINFO_VERSION_A, &aStack->info); if (status != zOK) { @@ -2795,7 +2788,7 @@ errorFree: errorExit: STACK_FREE(); return zFAILURE; -} +} ///**************************************************************************** // * Process the ACTIVATE command @@ -2836,7 +2829,7 @@ errorExit: // } // printf(MSG("Volume %U set to the ACTIVE state.\n", 0),name); // RTN_STATUS(zOK); -//} +//} ///**************************************************************************** // * Process the DECATIVE command @@ -2881,7 +2874,7 @@ errorExit: // } // printf(MSG("Volume %U set to the DEACTIFVE state.\n", 861),name); // RTN_STATUS(zOK); -//} +//} /**************************************************************************** * Process internal command that effects a volumes STATE @@ -2921,7 +2914,7 @@ STATUS COMN_ChangeSingleVolumeStateByName( COMN_Release( &vol ); /* remove useCount added by lookup*/ RTN_STATUS(zOK); -} +} @@ -2996,8 +2989,8 @@ STATUS COMN_ChangeVolumeStateByName( args.returnStatus = zOK; args.destState = destState; args.mode = mode; - - SET_APPLY( &NSSMasterVolumeList, (statusfunc_t)applyChangeVolumeStateByName, &args); + + SET_APPLY( &NSSMasterVolumeList, applyChangeVolumeStateByName, &args); /* If any state changes failed, return the first error */ if (args.returnStatus != zOK) { @@ -3045,11 +3038,11 @@ STATUS COMN_ChangeVolumeStateByName( COMN_Release( &vol ); /* remove useCount added by lookup*/ } RTN_STATUS(zOK); -} +} /**************************************************************************** - * + * *****************************************************************************/ STATUS VOL_ChangeSingleVolumeMinKeepSeconds( GeneralMsg_s *genMsg, @@ -3096,7 +3089,7 @@ STATUS VOL_ChangeSalvageMinKeepSeconds( { STATUS returnStatus = zOK; Volume_s *vol; - + ASSERT_MPKNSS_LOCK(); SET_FOREACHBLOCKING(&NSSMasterVolumeList, vol, Volume_s, masterVolLink) { /*** You MUST NOT use continue in this loop because the macro @@ -3203,10 +3196,10 @@ STATUS VOL_ChangeSingleVolumeSalvageByName( return zOK; } else - { + { return zFAILURE; } -} +} #endif /**************************************************************************** @@ -3552,7 +3545,7 @@ void VOL_ChangeVolumeTransactionByName( (void)COMN_GetVolumeName(genMsg,vol,volName,NELEMS(volName)); ClearErrno( genMsg ); - VOL_ChangeVolumeTransaction(genMsg, vol, volName, + VOL_ChangeVolumeTransaction(genMsg, vol, volName, transactionOn); ClearErrno( genMsg ); } @@ -3653,7 +3646,7 @@ void VOL_ChangeVolumeTransaction( if(status != zOK) { errPrintf(WHERE, Module, 684, - MSG("Could not change transaction on volume %U, status=%d.\n", 971), + MSG("Could not change transaction on volume %U, status=%d.\n", 971), name, GetErrno(genMsg)); } else @@ -3672,7 +3665,7 @@ void VOL_ChangeVolumeTransaction( // LONG maxTransactions; // NINT logFileLength; // /* Create a new log file. If a previous one existed, we don't -// care because it will have been replayed (and supposedly +// care because it will have been replayed (and supposedly // destroyed) before we get to this point. // */ // @@ -3681,29 +3674,29 @@ void VOL_ChangeVolumeTransaction( // // COMN_INIT_NAMING_MSG(&nameMsg); /* initial naming message to nulls */ // COMN_SETUP_NAMING_MSG_SIMPLE( -// &nameMsg, +// &nameMsg, // logFileName, // zPFMT_UNICODE, -// NAMPMODE_Undefined , -// XLATCHED, -// zNSPACE_DOS,zNTYPE_FILE, -// NULL); +// NAMPMODE_Undefined , +// XLATCHED, +// zNSPACE_DOS,zNTYPE_FILE, +// NULL); // COMN_STRUCT_INIT(createMsg); /* init the create message to nulls */ // COMN_SETUP_CREATE_FILE_MSG( // &createMsg, /* and then fill it in */ -// zFTYPE_FILE, +// zFTYPE_FILE, // zFA_IMMEDIATE_PURGE|zFA_COPY_INHIBIT|zFA_DO_NOT_COMPRESS_FILE, -// COMN_GetUserID(genMsg), +// COMN_GetUserID(genMsg), // zRR_READ_ACCESS|zRR_WRITE_ACCESS|zRR_CANT_DELETE_WHILE_OPEN| // zRR_DONT_UPDATE_ACCESS_TIME, // zCREATE_OPEN_IF_THERE,NULL); // // /* go create the log file */ // status = COMN_Create( -// genMsg, -// &nameMsg, -// &createMsg, -// &fileHandleIDP); +// genMsg, +// &nameMsg, +// &createMsg, +// &fileHandleIDP); // COMN_CleanupNameMsg(genMsg, &nameMsg); // // @@ -3722,7 +3715,7 @@ void VOL_ChangeVolumeTransaction( // logFileLength, // zSETSIZE_NON_SPARSE_FILE); // -// MSG_DestroyKey(fileHandleIDP.key); +// MSG_DestroyKey(fileHandleIDP.key); // } // // if(status == zOK) @@ -3793,7 +3786,7 @@ void VOL_ChangeVolumeMigrationByName( (void)COMN_GetVolumeName(genMsg,vol,volName,NELEMS(volName)); ClearErrno( genMsg ); - VOL_ChangeVolumeMigration(genMsg, vol, volName, + VOL_ChangeVolumeMigration(genMsg, vol, volName, migrationOn); ClearErrno( genMsg ); } @@ -3903,14 +3896,14 @@ void VOL_ChangeVolumeMigration( { if (vol->VOLenabledAttributes & zATTR_MIGRATION) { - aprintf(YELLOW,MSG("Migration of files enabled on volume %U.\n",1187),name); + aprintf(YELLOW,MSG("Migration of files enabled on volume %U.\n",1187),name); } else { - /* We were asked to turn migration on, but the LSS did not + /* We were asked to turn migration on, but the LSS did not * do it. Since the - * LSS ignored our change, but did not return an error, + * LSS ignored our change, but did not return an error, * this means * that the LSS simply does not support migration. */ aprintf(YELLOW,MSG("Migration of files is not supported on volume \"%U\"...\n",1188),name); @@ -4115,7 +4108,7 @@ void VOL_ChangeVolumeHardlinks( * LSS ignored our change, but did not return an error, this means * that the LSS simply does not support hardlinks. */ aprintf(YELLOW,MSG("Hardlinks may not be created on volume \"%U\" until it is upgraded using the \"ZLSSUpgradeCurrentVolumeMediaFormat\" command...\n",682),name); - + } else { @@ -4268,7 +4261,7 @@ void VOL_ChangeVolumeATimeByName( return; } - + if (COMN_LockVolumeActive(genMsg, vol, FALSE) != zOK) { errPrintf(WHERE, Module, 678, @@ -4371,7 +4364,7 @@ STATUS VOL_CheckUserSpace( { return zOK; } - + ownerID = COMN_GetOwnerID(beast); if (volume->VOLcomnVolOps.VOL_getUserSpaceInfo(genMsg, volume, &ownerID, &restrictionAmount, &usedAmount) != zOK) @@ -4394,7 +4387,7 @@ STATUS VOL_CheckUserSpace( } /**************************************************************************** - * + * ****************************************************************************/ STATUS VOL_DisableUserSpaceRestrictions( GeneralMsg_s *genMsg, @@ -4421,7 +4414,7 @@ STATUS VOL_DisableUserSpaceRestrictions( SetErrno(genMsg, zERR_NO_MEMORY); return zFAILURE; } - SETUP_CLEAR_USER_TREE_LOG(&purgeLogInfo->purgeLogMsg, + SETUP_CLEAR_USER_TREE_LOG(&purgeLogInfo->purgeLogMsg, (void *)&purgeLogInfo->purgeLogLoc, vol); xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); status = vol->VOLcomnVolOps.VOL_addPurgeLogEntry(genMsg, vol, @@ -4442,7 +4435,7 @@ STATUS VOL_DisableUserSpaceRestrictions( GetErrno(genMsg)); if (GetErrno(genMsg) == zERR_VOLUME_STATE_CHANGE_REQUESTED) { - /* If volume is being deactivated, do not remove it from the + /* If volume is being deactivated, do not remove it from the * purge Log, so that the cleanup can continue when we come * back up. */ @@ -4453,7 +4446,7 @@ STATUS VOL_DisableUserSpaceRestrictions( /* remove purge log entry */ xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); - vol->VOLcomnVolOps.VOL_removePurgeLogEntry(genMsg, vol, + vol->VOLcomnVolOps.VOL_removePurgeLogEntry(genMsg, vol, PLOG_CLEAR_USED_AMOUNT, &purgeLogInfo->purgeLogMsg, xaction); vol->VOLcomnVolOps.VOL_endXLocal(xaction); free(purgeLogInfo); @@ -4497,7 +4490,7 @@ void VOL_EnableUserSpaceRestrictionsThread( * Add a purge log entry to remove the tree in case we do not finish so * that it is cleaned up. */ - SETUP_CLEAR_USER_TREE_LOG(&purgeLogInfo->purgeLogMsg, + SETUP_CLEAR_USER_TREE_LOG(&purgeLogInfo->purgeLogMsg, (void *)&purgeLogInfo->purgeLogLoc, vol); xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); status = vol->VOLcomnVolOps.VOL_addPurgeLogEntry(&genMsg, vol, @@ -4554,7 +4547,7 @@ void VOL_EnableUserSpaceRestrictionsThread( continue; } /* - * If this is a beast that is part of salvage then do not + * If this is a beast that is part of salvage then do not * count it. */ if (((NamedBeast_s *)beast)->NAMEDnameFlags & @@ -4568,13 +4561,13 @@ void VOL_EnableUserSpaceRestrictionsThread( * If this is an EA/Datastream then check to see if its parent * has been deleted. Datastreams are not marked deleted. */ - if ((((NamedBeast_s *)beast)->NAMEDfirstParentNameType == + if ((((NamedBeast_s *)beast)->NAMEDfirstParentNameType == zNTYPE_DATA_STREAM) || - (((NamedBeast_s *)beast)->NAMEDfirstParentNameType == + (((NamedBeast_s *)beast)->NAMEDfirstParentNameType == zNTYPE_EXTENDED_ATTRIBUTE)) { - parent = BEASTHASH_LookupByZid(&genMsg, vol, - ((NamedBeast_s *)beast)->NAMEDfirstParentZid, + parent = BEASTHASH_LookupByZid(&genMsg, vol, + ((NamedBeast_s *)beast)->NAMEDfirstParentZid, NOTLATCHED); if (parent == NULL) { @@ -4597,9 +4590,9 @@ void VOL_EnableUserSpaceRestrictionsThread( * counted when we do its parent beast. */ if ((beast->beastClass->classID == zFTYPE_COMPRESSION) || - (!(beast->ROOTvolume->VOLcompAttributes.compFlags & + (!(beast->ROOTvolume->VOLcompAttributes.compFlags & VOL_COMP_FLAGS_UPGRADE_FINISHED) && - (beast->beastClass->classID == zFTYPE_ROOT_BEAST) && + (beast->beastClass->classID == zFTYPE_ROOT_BEAST) && (beast->eof != 0))) { COMN_UnlatchAndRelease(&beast, SLATCHED); @@ -4607,7 +4600,7 @@ void VOL_EnableUserSpaceRestrictionsThread( } /* - * Add up the space being used. If there is a compression beast + * Add up the space being used. If there is a compression beast * then account for its space as well. */ vol->VOLzidInProcess = beast->zid; @@ -4631,7 +4624,7 @@ exitFreeMem: exitPurgeLog: /* remove the purge log entry */ xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); - vol->VOLcomnVolOps.VOL_removePurgeLogEntry(&genMsg, vol, + vol->VOLcomnVolOps.VOL_removePurgeLogEntry(&genMsg, vol, PLOG_CLEAR_USED_AMOUNT, &purgeLogInfo->purgeLogMsg, xaction); vol->VOLcomnVolOps.VOL_endXLocal(xaction); free(purgeLogInfo); @@ -4686,7 +4679,7 @@ STATUS VOL_InitUserSpaceRestrictionData( if ((status = COMN_LockVolumeActive(genMsg, vol, FALSE)) == zOK) { - WORK_Schedule(fsm, (voidfunc_t)VOL_EnableUserSpaceRestrictionsThread, (ADDR)vol); + WORK_Schedule(fsm, VOL_EnableUserSpaceRestrictionsThread, (ADDR)vol); } else { @@ -4795,12 +4788,12 @@ void VOL_AdjustUsedUserSpace( // } // else // { -// DBG_DebugPrintf(LMAGENTA, "UNKNOWN DATA STREAM: %d\n", ((NamedBeast_s *)beast)->NAMEDfirstParent.p.nameType); +// DBG_DebugPrintf(LMAGENTA, "UNKNOWN DATA STREAM: %d\n", ((NamedBeast_s *)beast)->NAMEDfirstParent.p.nameType); // } //} //else //{ -// DBG_DebugPrintf(LMAGENTA, "UNKNOWN\n"); +// DBG_DebugPrintf(LMAGENTA, "UNKNOWN\n"); //} //******** end debug ********** volume = beast->vol.volume; @@ -4827,7 +4820,7 @@ void VOL_AdjustUsedUserSpace( return; } - tmpBeast = beast; + tmpBeast = beast; /* Check to see if this is a compressed beast */ if (!COMN_IsDerivedFrom(beast, zFTYPE_NAMED_DATA_STREAM)) @@ -4839,7 +4832,7 @@ void VOL_AdjustUsedUserSpace( COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); zASSERT((beast->beastClass->classID == zFTYPE_COMPRESSION) || - (!(beast->ROOTvolume->VOLcompAttributes.compFlags & + (!(beast->ROOTvolume->VOLcompAttributes.compFlags & VOL_COMP_FLAGS_UPGRADE_FINISHED) && (beast->beastClass->classID == zFTYPE_ROOT_BEAST))); uncompInfo = (UncompressInfo_s *) @@ -4847,14 +4840,14 @@ void VOL_AdjustUsedUserSpace( /* * If uncompBeastDeleted is true then the blocks for this compressed * beast have already been counted when the uncompressed beast was - * deleted - */ + * deleted + */ if (uncompInfo->uncompBeastDeleted) { //DBG_DebugPrintf(LRED, "VOL_AdjustUsedUserSpace: Compression beast already accounted for\n"); return; } - tmpBeast = COMN_LookupByZid(&genMsg, beast->ROOTvolume, + tmpBeast = COMN_LookupByZid(&genMsg, beast->ROOTvolume, uncompInfo->uncompBeastZid, NOTLATCHED, TRUE); zASSERT(tmpBeast); @@ -4870,7 +4863,7 @@ void VOL_AdjustUsedUserSpace( } if (tmpBeast && - ((((NamedBeast_s *)tmpBeast)->NAMEDnumParents == 0) || + ((((NamedBeast_s *)tmpBeast)->NAMEDnumParents == 0) || NAME_AllNamesInSalvage(tmpBeast))) { if (releaseBeast) @@ -4902,7 +4895,7 @@ void VOL_AdjustUsedUserSpace( } /* Adjust value in storage */ - volume->VOLcomnVolOps.VOL_adjustUsedUserSpace(xaction, beast, + volume->VOLcomnVolOps.VOL_adjustUsedUserSpace(xaction, beast, amountToAdjust); //DBG_DebugPrintf(YELLOW, "VOL_AdjustUsedUserSpace: Adjusted\n"); return; @@ -4969,19 +4962,19 @@ STATUS VOL_BrowseUsersInVolume( if (status == zOK) { /* requester has rights */ return (volume->VOLcomnVolOps.VOL_browseUsersInVolume(genMsg, volume, - numEntriesRequested, lastUserReturned, userEntries, + numEntriesRequested, lastUserReturned, userEntries, numEntriesReturned, allUsersFlag)); } - else if ((allUsersFlag & BROWSE_USERS_GET_COUNT) || + else if ((allUsersFlag & BROWSE_USERS_GET_COUNT) || (allUsersFlag & BROWSE_USERS_START_AT_COUNT)) { *numEntriesReturned = 0; } - else + else { /* no supervisor rights -- only return for this user */ myID = COMN_GetUserID(genMsg); if ((LB_GUIDCompare(&myID, lastUserReturned) == 0) || - (volume->VOLcomnVolOps.VOL_getUserSpaceInfo(genMsg, volume, + (volume->VOLcomnVolOps.VOL_getUserSpaceInfo(genMsg, volume, &myID, &restrictionAmount, &usedAmount) != zOK)) { *numEntriesReturned = 0; @@ -5026,7 +5019,7 @@ STATUS VOL_RemoveUser( * Make sure that the requester has supervisor rights on the root of * the volume. */ - + ASSERT_LATCH(&volume->rootdir->FILEbeastLatch); if (volume->VOLmayIDoThis(genMsg, volume->rootdir, zINVALID_ZID, MAY_I_SUPERVISE) != zOK) @@ -5118,7 +5111,7 @@ STATUS VOL_SetUserSpaceRestriction( STACK_FREE(); return status; } - + /**************************************************************************** * Process command lines that effect a volume's user space restriction @@ -5225,7 +5218,7 @@ void VOL_ChangeVolumeUserSpaceRestrictionsByName( COMN_Release( &vol ); /* remove useCount added by lookup*/ } return; -} +} /**************************************************************************** * Process command lines that effect a volume's compression attribute @@ -5590,8 +5583,8 @@ STATUS VOL_ChangeVolumeMFLByName( * *****************************************************************************/ STATIC STATUS VOL_administerMFL( - GeneralMsg_s *genMsg, - Volume_s *volume, + GeneralMsg_s *genMsg, + Volume_s *volume, NINT opCode) { STATUS rc; @@ -5689,7 +5682,7 @@ STATUS VOL_administerMFLByName( adminArgs.genMsg = genMsg; adminArgs.opCode = opCode; /* If errors encountered, return the first error */ - status = SET_APPLY( &NSSMasterVolumeList, (statusfunc_t)administerMFLByVolLink, + status = SET_APPLY( &NSSMasterVolumeList, administerMFLByVolLink, &adminArgs); } else /* administer given volume */ @@ -5723,7 +5716,7 @@ STATUS VOL_insertEFLEntry( unicode_t *name, Xaction_s *xaction) { - if ((beast->zid < zROOTDIR_ZID) || (beast->zid & SNAPSHOT_ZID_FLAG) || + if ((beast->zid < zROOTDIR_ZID) || (beast->zid & SNAPSHOT_ZID_FLAG) || !COMN_IsDerivedFrom(beast, zFTYPE_NAMED_DATA_STREAM)) { return zOK; @@ -5754,7 +5747,7 @@ STATUS VOL_insertEFLEntry( { action = EFL_FILE_STATE_NO_ACTION; } - beast->bstState &= + beast->bstState &= ~(BST_STATE_DATA_CHANGED | BST_STATE_METADATA_CHANGED); } @@ -5762,7 +5755,7 @@ STATUS VOL_insertEFLEntry( { return zOK; } - return beast->ROOTcomnVolOps.VOL_insertEFLEntry(genMsg, + return beast->ROOTcomnVolOps.VOL_insertEFLEntry(genMsg, (File_s *)beast, action, name, xaction); } @@ -5816,9 +5809,9 @@ STATIC STATUS VOL_ChangeVolumeDataShred( } else { - /* We were asked to turn Data Shredding on, but the LSS did + /* We were asked to turn Data Shredding on, but the LSS did * not do it. Since the - * LSS ignored our change, but did not return an error, + * LSS ignored our change, but did not return an error, * this means * that the LSS simply does not support Data Shredding. */ aprintf(YELLOW,MSG("Data Shredding is not supported on volume \"%U\"...\n",1175),name); @@ -5856,7 +5849,7 @@ STATUS VOL_ChangeVolumeDataShredByName( { if (*tmpName == L':') { - if (*(tmpName+1)) + if (*(tmpName+1)) { if ((*(tmpName+1)) >= (L'0' + MAX_DATA_SHRED_PATTERNS)) { @@ -5901,7 +5894,7 @@ STATUS VOL_ChangeVolumeDataShredByName( /* Ignore this volume if it's DataShred status is not being * changed */ - if ((shreddingCurrentlyOn != enableShredding) || + if ((shreddingCurrentlyOn != enableShredding) || (currentShredCount != shredCount)) { STATUS status; @@ -5910,7 +5903,7 @@ STATUS VOL_ChangeVolumeDataShredByName( (void)COMN_GetVolumeName(genMsg,vol,volName,NELEMS(volName)); ClearErrno( genMsg ); status = VOL_ChangeVolumeDataShred(genMsg, vol, volName, shredCount, - enableShredding); + enableShredding); if ( status != zOK ) { if (returnStatus == zOK) @@ -5965,7 +5958,7 @@ STATUS VOL_ChangeVolumeDataShredByName( currentShredCount = vol->VOLshredCount; - if (shreddingCurrentlyOn && enableShredding && + if (shreddingCurrentlyOn && enableShredding && (currentShredCount == shredCount)) { aprintf(YELLOW,MSG("Data shredding is already enabled on Volume %U with shred count %d.\n", 1179), name, shredCount); @@ -5981,7 +5974,7 @@ STATUS VOL_ChangeVolumeDataShredByName( return(zOK); } - VOL_ChangeVolumeDataShred(genMsg, vol, name, shredCount, + VOL_ChangeVolumeDataShred(genMsg, vol, name, shredCount, enableShredding); COMN_UnlockVolumeActive(vol, FALSE); COMN_Release( &vol ); /* remove useCount added by lookup*/ @@ -6031,9 +6024,9 @@ STATIC STATUS VOL_ChangeVolumeHighIntegrity( } else { - /* We were asked to turn High Integrity on, but the LSS did + /* We were asked to turn High Integrity on, but the LSS did * not do it. Since the - * LSS ignored our change, but did not return an error, + * LSS ignored our change, but did not return an error, * this means * that the LSS simply does not support high integrity. */ aprintf(YELLOW,MSG("Immediate flush files on close is not supported on volume \"%U\"...\n",1202),name); @@ -6219,7 +6212,7 @@ STATUS VOL_ChangeVolumeReadAheadByName( { if (*tmpName == L':') { - if (*(tmpName+1)) + if (*(tmpName+1)) { foundCount = TRUE; LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, buf, sizeof(buf), @@ -6368,9 +6361,9 @@ STATIC STATUS VOL_ChangeVolumeCFSMaster( } else { - /* We were asked to turn CFS Master on, but the LSS did + /* We were asked to turn CFS Master on, but the LSS did * not do it. Since the - * LSS ignored our change, but did not return an error, + * LSS ignored our change, but did not return an error, * this means * that the LSS simply does not support. */ aprintf(YELLOW,MSG("Being CFS Master is not supported on volume \"%U\"...\n",598),name); @@ -6544,9 +6537,9 @@ STATIC STATUS VOL_ChangeVolumeCOW( } else { - /* We were asked to turn COW on, but the LSS did + /* We were asked to turn COW on, but the LSS did * not do it. Since the - * LSS ignored our change, but did not return an error, + * LSS ignored our change, but did not return an error, * this means * that the LSS simply does not support COW. */ aprintf(YELLOW,MSG("File Copy on Write is not supported on volume \"%U\"...\n",1020),name); @@ -6844,7 +6837,7 @@ void VOL_UpgradeBeastsOnVolumeByName( * version then we need to upgrade the beasts on this volume */ #if NSS_DEBUG IS_ENABLED -DBG_DebugPrintf(LMAGENTA, "Volume's beast version mask = %x\n", +DBG_DebugPrintf(LMAGENTA, "Volume's beast version mask = %x\n", vol->VOLbeastVersionMask); #endif if ((vol->VOLbeastVersionMask & (1 << (BEAST_VERSION_1 - 1)))) @@ -6853,10 +6846,10 @@ DBG_DebugPrintf(LMAGENTA, "Volume's beast version mask = %x\n", (void)COMN_GetVolumeName(genMsg, vol, volName, NELEMS(volName)); ClearErrno(genMsg); - aprintf(WHITE, MSG("Upgrading beasts on volume %U\n", 1160), + aprintf(WHITE, MSG("Upgrading beasts on volume %U\n", 1160), volName); - if (VOL_UpgradeBeastsOnVolume(genMsg, vol, volName, + if (VOL_UpgradeBeastsOnVolume(genMsg, vol, volName, callbackForUpgrade, &processedCount, &upgradedCount) != zOK) { errPrintf(WHERE, Module, 720, @@ -6884,7 +6877,7 @@ DBG_DebugPrintf(LMAGENTA, "Volume's beast version mask = %x\n", } #if NSS_DEBUG IS_ENABLED -DBG_DebugPrintf(LMAGENTA, "Volume's beast version mask = %x\n", +DBG_DebugPrintf(LMAGENTA, "Volume's beast version mask = %x\n", vol->VOLbeastVersionMask); #endif if (COMN_LockVolumeActive(genMsg, vol, FALSE) != zOK) @@ -6905,7 +6898,7 @@ DBG_DebugPrintf(LMAGENTA, "Volume's beast version mask = %x\n", return; } - if (VOL_UpgradeBeastsOnVolume(genMsg, vol, name, + if (VOL_UpgradeBeastsOnVolume(genMsg, vol, name, callbackForUpgrade, &processedCount, &upgradedCount) != zOK) { errPrintf(WHERE, Module, 730, @@ -6919,7 +6912,7 @@ DBG_DebugPrintf(LMAGENTA, "Volume's beast version mask = %x\n", COMN_Release( &vol ); /* remove useCount added by lookup*/ } return; -} +} /**************************************************************************** * VOL_DisableVolume @@ -6948,7 +6941,7 @@ DBG_DebugPrintf(LMAGENTA, "Volume's beast version mask = %x\n", * state request. *****************************************************************************/ STATUS VOL_DisableVolume( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, Volume_s *volume ) { @@ -6967,7 +6960,7 @@ STATUS VOL_DisableVolume( */ volume->v_ioFlag |= VOL_IOF_DISABLE; /* LSS must stop writing to the media */ - + /* See if a thread already scheduled */ if ( volume->v_statusFlag & VOL_SF_DISABLE_THREAD_SCHEDULED ) { /* Already scheduled so just return. ScheduleWork() does @@ -6976,7 +6969,7 @@ STATUS VOL_DisableVolume( * were to cause another disable that we will ignore the * 2nd request. */ - + DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, (CYAN,MSGNot("Asynchronous disable volume already scheduled\n"))); RTN_STATUS(zOK); @@ -6999,7 +6992,7 @@ STATUS VOL_DisableVolume( * shutdown owned. */ COMN_USE_BEAST(&volume->VOLroot); - + #if VOL_DISABLE_USE_SYSTEMS_WORK_TO_DO ScheduleWork( &volume->v_disableWorkToDoStructure ); #else @@ -7007,8 +7000,8 @@ STATUS VOL_DisableVolume( #endif RTN_STATUS(zOK); - -} + +} /**************************************************************************** @@ -7035,13 +7028,13 @@ STATUS VOL_DisableVolume( * / \ * / \ * / \ - * / MAINTENANCE + * / MAINTENANCE * / / - * / / - * / / - * / / - * / / - * / / + * / / + * / / + * / / + * / / + * / / * ACTIVE * * @@ -7064,10 +7057,10 @@ STATUS VOL_DisableVolume( * are open on the volume. In addition, before we attempt any state * change we send a event that allows the event reciever to fail the * ATTEMPTED state change. - * + * * When an error is returned it is simply best to get the current * volume state if your code needs to know the state we ended in. - * + * * A state change from DEACTIVE to ACTIVE may end up in MAINTENANCE state. * This is possible because if the LSS detects the volume is corrupt then * the volume will be placed into MAINTENANCE state. This function supports @@ -7115,7 +7108,7 @@ STATUS COMN_ChangeVolumeState( * requirements on the bits that can be set so we just * blow away users and set to the correct values. We * also ALWAYS go to DEACTIVE state. - * The VOLMODE_DISABLE bit also prevents + * The VOLMODE_DISABLE bit also prevents * a volume in the UNKNOWN state to change to the DEACTIVE state. * This is VERY important for LVs because the POOL may be in the * middle of a state change in which it is lowering all @@ -7150,7 +7143,7 @@ STATUS COMN_ChangeVolumeState( } } /* Serialize the CVS code per volume */ - X_LATCH( &vol->cvsLatch ); + X_LATCH( &vol->cvsLatch ); #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(CYAN,"CVS %s Mode is 0x%lx\n",WHERE,mode ); #endif @@ -7193,7 +7186,7 @@ STATUS COMN_ChangeVolumeState( case zVOLSTATE_DEACTIVE: case zVOLSTATE_MAINTENANCE: #ifdef USER_GPACHNER - aprintf(YELLOW, WHERE ); + aprintf(YELLOW, WHERE ); #endif aprintf(YELLOW,MSG("Deactivating volume \"%U\"...\n",199),aStack->volName); break; @@ -7205,7 +7198,7 @@ STATUS COMN_ChangeVolumeState( { case zVOLSTATE_ACTIVE: #ifdef USER_GPACHNER - aprintf(NSS_VOLUME_COLOR, WHERE ); + aprintf(NSS_VOLUME_COLOR, WHERE ); #endif aprintf(NSS_VOLUME_COLOR,MSG("Activating volume \"%U\"...\n",200),aStack->volName); break; @@ -7304,7 +7297,7 @@ STATUS COMN_ChangeVolumeState( /* These TWO cases require two state changes */ case zVOLSTATE_ACTIVE: case zVOLSTATE_MAINTENANCE: - status = VOL_SingleStateChange( genMsg, vol, vol->state, + status = VOL_SingleStateChange( genMsg, vol, vol->state, zVOLSTATE_DEACTIVE, mode, &isPersistentAdminVolume ); } @@ -7314,7 +7307,7 @@ STATUS COMN_ChangeVolumeState( if (destState != zVOLSTATE_ACTIVE) { BOOL promptForReply; - + promptForReply = FALSE; vol->v_statusFlag |= VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP; /*----------------------------------------------------------- @@ -7369,8 +7362,8 @@ STATUS COMN_ChangeVolumeState( } - /* Initiate shutdown of all - * Compression Management activities related to this volume + /* Initiate shutdown of all + * Compression Management activities related to this volume */ if (vol->VOLenabledAttributes & zATTR_COMPRESSION) { @@ -7425,7 +7418,7 @@ STATUS COMN_ChangeVolumeState( * it into DEACTIVE above as part of a two state change * request. */ - + if ( (vol->state == zVOLSTATE_DEACTIVE) && (destState != zVOLSTATE_DEACTIVE) ) { @@ -7482,14 +7475,14 @@ CVSSkip:; vol->v_statusFlag &= ~VOL_SF_LEAVING_DEACTIVE_STATE_CLEANUP; /* Serialize code per volume */ - UNX_LATCH( &vol->cvsLatch ); + UNX_LATCH( &vol->cvsLatch ); if ( weLatchedPool ) { zASSERT( vol->v_pool != NULL ); UNX_LATCH( &vol->v_pool->cvsLatch ); } if (vol->VOLroot.rb_inode != NULL) - { + { VOL_CleanupInodeBeastLink(&vol->VOLroot); } @@ -7576,10 +7569,10 @@ CVSSkip:; { /* * If the persistent admin volume has not yet been activated then we - * have delayed creation of management files for the other volumes + * have delayed creation of management files for the other volumes * so that we do not run out of memory from all of the files created. - * If this is the persistent admin volume that has just activated - * then go ahead and create management files for those volumes that + * If this is the persistent admin volume that has just activated + * then go ahead and create management files for those volumes that * already have been activated. */ if (vol->state == zVOLSTATE_ACTIVE) @@ -7602,7 +7595,7 @@ CVSSkip:; */ if (VOL_ProcessKnownVolumes(genMsg) != zOK) { - zASSERT("Error processing know volumes"==0); + zASSERT("Error processing know volumes"==0); } ClearErrno(genMsg); } @@ -7647,9 +7640,9 @@ STATIC STATUS VOL_SingleStateChange( EventChangeVolStateExit_s exit; unicode_t *vName; GeneralMsg_s dummyGenMsg; - + ASSERT_MPKNSS_LOCK(); - + #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(CYAN,"CVS %s Mode is 0x%lx\n",WHERE,mode ); #endif @@ -7675,7 +7668,7 @@ STATIC STATUS VOL_SingleStateChange( INIT_EVENT_ID_STATUS(id, exit.enterRetStatus); if (NEBEventInfo[EVENT_ChangeVolState_Enter].consumers) { - INIT_VOL_STATE_ENTER_EVENT(evBlk, EVENT_ChangeVolState_Enter, + INIT_VOL_STATE_ENTER_EVENT(evBlk, EVENT_ChangeVolState_Enter, enter, id, vol, origState, requestedState, mode); ZOS_ProduceEvent(status,&evBlk); /* This macro can do a GOTO!!! */ @@ -7689,7 +7682,7 @@ STATIC STATUS VOL_SingleStateChange( /*--------------------------------------------------------------- * Tell all semantic agents that this volume is now being * deactivated. This is where the semantic agents cleanup - * all of their own search maps, context handles, file + * all of their own search maps, context handles, file * handles, etc... *---------------------------------------------------------------*/ (void)VOL_SendDeactivateEventToSAgents(vol); @@ -7711,13 +7704,13 @@ STATIC STATUS VOL_SingleStateChange( * done because technically the state is not valid during a * transistion. */ - - X_LATCH( &vol->stateLatch ); //Should we get the volumes beast latch??? FixFixFix6 + + X_LATCH( &vol->stateLatch ); //Should we get the volumes beast latch??? FixFixFix6 for ( cvsPass = 1; cvsPass <= 10; cvsPass++ ) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, (GREEN,MSGNot("Pass %d\n"), cvsPass )); - status = vol->VOLcomnVolOps.VOL_changeVolumeState( genMsg, vol, + status = vol->VOLcomnVolOps.VOL_changeVolumeState( genMsg, vol, origState, requestedState, mode, cvsPass ); if ( status != zOK ) { @@ -7817,14 +7810,14 @@ STATIC STATUS VOL_SingleStateChange( * with potential slaves and will give the slaves a chance to SYNC * up (create access and beast leases on master) before activating. */ - if ((requestedState == zVOLSTATE_ACTIVE) && + if ((requestedState == zVOLSTATE_ACTIVE) && (origState != requestedState)) { CSA_CheckForSlavesAndSync(vol); } vol->state = requestedState; } - UNX_LATCH( &vol->stateLatch ); + UNX_LATCH( &vol->stateLatch ); #if NSS_DEBUG IS_ENABLED @@ -7834,15 +7827,15 @@ STATIC STATUS VOL_SingleStateChange( ClearErrno( &dummyGenMsg ); DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(GREEN, MSGNot("%U Change state OCCURRED (status=%lu set at %s) from %d to %d\n"), - vName,(unsigned long)GetErrno(genMsg), + vName,(unsigned long)GetErrno(genMsg), GetErrnoSetter(genMsg), origState, vol->state )); } #endif if (NEBEventInfo[EVENT_ChangeVolState_Exit].consumers) { - - INIT_EXIT_EVENT(status, genMsg, evBlk, + + INIT_EXIT_EVENT(status, genMsg, evBlk, EVENT_ChangeVolState_Exit, exit, id); INIT_VOL_STATE_EXIT_EVENT(exit, vol, origState, mode); ZOS_ProduceEvent(result,&evBlk); @@ -7946,7 +7939,7 @@ void VOL_DisplayVolumes(void) continue; } #endif - + (void)COMN_GetVolumeName(&genMsg,volume,vname,NELEMS(vname)); ClearErrno( &genMsg ); @@ -8152,13 +8145,13 @@ void formattedSize( BYTE **byteval) { QUAD scale; -#define A_ONE (UI64_CONST(1)) -#define A_KILO (UI64_CONST(1024)) -#define A_MEGA (A_KILO * A_KILO) -#define A_GIGA (A_MEGA * A_KILO) -#define A_TERA (A_GIGA * A_KILO) -#define A_PEDA (A_TERA * A_KILO) -#define A_EXA (A_PEDA * A_KILO) +#define A_ONE (UI64_CONST(1)) +#define A_KILO (UI64_CONST(1024)) +#define A_MEGA (A_KILO * A_KILO) +#define A_GIGA (A_MEGA * A_KILO) +#define A_TERA (A_GIGA * A_KILO) +#define A_PEDA (A_TERA * A_KILO) +#define A_EXA (A_PEDA * A_KILO) if (bytes > A_EXA) { @@ -8210,7 +8203,7 @@ void formattedSize( { *size = bytes / scale; /* Multiplying by 100 gives us decimal values to 2 digits */ - *sized = ((bytes - (*size * scale)) * 100)/scale; + *sized = ((bytes - (*size * scale)) * 100)/scale; } return; } @@ -8237,7 +8230,7 @@ void VOL_DisplaySpaceInfo(void) char symbol; BOOL printingAsterisk = FALSE; BOOL printingSymbol = FALSE; - BOOL firstLine; + BOOL firstLine; MPKNSS_LOCK(); wPause(stdout, -1); @@ -8255,9 +8248,9 @@ void VOL_DisplaySpaceInfo(void) struct volinfodef volType; struct VolInfoStructure volInfo; LONG ccode; - + for (volID = -1;;) - { + { ZOS_VM_Find_Next_Volume(ccode, &volID, -1); if (ccode != 0) { @@ -8269,21 +8262,21 @@ void VOL_DisplaySpaceInfo(void) zASSERT("Error VM_Return_Volume_Info" == NULL); continue; } - + if (volType.filesystemid == NETWARENSSFILESYSTEM) { continue; } - + if (firstLine) - { + { aprintf(LBLUE,MSG("Traditional Volumes:\n",538)); firstLine = FALSE; } LB_LenByteToUnicode(NSS_UNI_CONVERSION_RAW, name, NELEMS(name), - &volType.volumename[1], volType.volumename[0], NULL); - + &volType.volumename[1], volType.volumename[0], NULL); + /* get volume size */ ZOS_INWNewGetVolumeInfo(ccode, volID, &volInfo); @@ -8291,41 +8284,41 @@ void VOL_DisplaySpaceInfo(void) { /* Note: size in sectors */ color = LGREEN; - + totalBlocks = (QUAD)volInfo.SectorsPerCluster * volInfo.VolumeSizeInClusters; - - vFreeBlocks = (QUAD)volInfo.FreeableLimboSectors + + + vFreeBlocks = (QUAD)volInfo.FreeableLimboSectors + (volInfo.FreedClusters + volInfo.SubAllocFreeableClusters) * volInfo.SectorsPerCluster; usedBlocks = totalBlocks - vFreeBlocks; - - formattedSize(totalBlocks * volInfo.SectorSize, + + formattedSize(totalBlocks * volInfo.SectorSize, &tsize, &tsized, &tbyteval); - formattedSize((QUAD)usedBlocks * volInfo.SectorSize, + formattedSize((QUAD)usedBlocks * volInfo.SectorSize, &usize, &usized, &ubyteval); - formattedSize(vFreeBlocks * volInfo.SectorSize, + formattedSize(vFreeBlocks * volInfo.SectorSize, &fsize, &fsized, &fbyteval); aprintf(color, MSG(" %-24.24U %4d.%-2.2d %2s ", - 539), name, tsize, tsized, tbyteval); - aprintf(color, MSG(" %4d.%-2.2d %2s %4d.%-2.2d %2s \n", - 540), usize, usized, ubyteval, fsize, - fsized, fbyteval); + 539), name, tsize, tsized, tbyteval); + aprintf(color, MSG(" %4d.%-2.2d %2s %4d.%-2.2d %2s \n", + 540), usize, usized, ubyteval, fsize, + fsized, fbyteval); } - else + else { zASSERT(ccode == ERR_INVALID_VOLUME); - + color = YELLOW; aprintf(color, MSG(" %-24.24U -- Volume Not Mounted -- \n", 541), name); } } - } + } #endif /* NSS volumes (no container pools) */ firstLine = TRUE; - + SET_FOREACHBLOCKING(&NSSMasterVolumeList, volume, Volume_s, masterVolLink) { /*** You MUST NOT use continue in this loop because the macro *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called @@ -8336,7 +8329,7 @@ void VOL_DisplaySpaceInfo(void) { goto NextVolume; } - + if (volume->v_pool != NULL) { goto NextVolume; @@ -8346,7 +8339,7 @@ void VOL_DisplaySpaceInfo(void) { goto NextVolume; } - + COMN_USE_BEAST( &volume->VOLroot ); X_LATCH( &volume->cvsLatch ); @@ -8367,12 +8360,12 @@ void VOL_DisplaySpaceInfo(void) getInfo = FALSE; break; } - + (void)COMN_GetVolumeName( &genMsg, volume, name, NELEMS(name)); ClearErrno( &genMsg ); if (firstLine) - { + { aprintf(LBLUE,MSG("NSS Volumes (No Pools):\n",542)); firstLine = FALSE; } @@ -8381,7 +8374,7 @@ void VOL_DisplaySpaceInfo(void) { totalBlocks = volume->VOLtotalBlocks; - usedBlocks = volume->VOLinUseBlocks - + usedBlocks = volume->VOLinUseBlocks - volume->VOLpurgeableBlocks + volume->VOLfreeBlockAdjustment; @@ -8395,18 +8388,18 @@ void VOL_DisplaySpaceInfo(void) vFreeBlocks = totalBlocks - usedBlocks; } - formattedSize(totalBlocks << volume->VOLblockShift, + formattedSize(totalBlocks << volume->VOLblockShift, &tsize, &tsized, &tbyteval); - formattedSize(usedBlocks << volume->VOLblockShift, + formattedSize(usedBlocks << volume->VOLblockShift, &usize, &usized, &ubyteval); - formattedSize(vFreeBlocks << volume->VOLblockShift, + formattedSize(vFreeBlocks << volume->VOLblockShift, &fsize, &fsized, &fbyteval); aprintf(color, MSG(" %-24.24U %4d.%-2.2d %2s ", - 543), name, tsize, tsized, tbyteval); - aprintf(color, MSG(" %4d.%-2.2d %2s %4d.%-2.2d %2s \n", - 544), usize, usized, ubyteval, fsize, - fsized, fbyteval); + 543), name, tsize, tsized, tbyteval); + aprintf(color, MSG(" %4d.%-2.2d %2s %4d.%-2.2d %2s \n", + 544), usize, usized, ubyteval, fsize, + fsized, fbyteval); } else { @@ -8422,7 +8415,7 @@ NextVolume: /* nss volumes and container pools */ firstLine = TRUE; - + SET_FOREACHBLOCKING(&NSSMasterPoolList, pool, Pool_s, masterPoolLink) { /*** You MUST NOT use continue in this loop because the macro *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called @@ -8455,7 +8448,7 @@ NextVolume: } if (firstLine) - { + { aprintf(LBLUE,MSG("NSS Pools/Volumes:\n",546)); firstLine = FALSE; } @@ -8471,16 +8464,16 @@ NextVolume: } pFreeBlocks = totalBlocks - usedBlocks; - formattedSize(totalBlocks << pool->POOLblockShift, + formattedSize(totalBlocks << pool->POOLblockShift, &tsize, &tsized, &tbyteval); - formattedSize(usedBlocks << pool->POOLblockShift, + formattedSize(usedBlocks << pool->POOLblockShift, &usize, &usized, &ubyteval); - formattedSize(pFreeBlocks << pool->POOLblockShift, + formattedSize(pFreeBlocks << pool->POOLblockShift, &fsize, &fsized, &fbyteval); aprintf(color, MSG(" %-26.26U %4d.%-2.2d %2s %4d.%-2.2d %2s %4d.%-2.2d %2s \n", 1242), - name, tsize, tsized, tbyteval, usize, usized, - ubyteval, fsize, fsized, fbyteval); + name, tsize, tsized, tbyteval, usize, usized, + ubyteval, fsize, fsized, fbyteval); POOL_FOR_EACH_LOADED_VOLUME(pool, volume) { @@ -8511,7 +8504,7 @@ NextVolume: { symbol = ' '; totalBlocks = volume->VOLtotalBlocks; - if ( (totalBlocks << volume->VOLblockShift) == + if ( (totalBlocks << volume->VOLblockShift) == zLV_NO_QUOTA_SIZE) { symbol = '@'; @@ -8521,7 +8514,7 @@ NextVolume: { totalBlocks = pool->POOLtotalBlocks; } - usedBlocks = volume->VOLinUseBlocks - + usedBlocks = volume->VOLinUseBlocks - volume->VOLpurgeableBlocks + volume->VOLfreeBlockAdjustment; if (usedBlocks > pool->POOLtotalBlocks) @@ -8543,19 +8536,19 @@ NextVolume: asterisk = '*'; printingAsterisk = TRUE; } - formattedSize(totalBlocks << volume->VOLblockShift, + formattedSize(totalBlocks << volume->VOLblockShift, &tsize, &tsized, &tbyteval); - formattedSize(usedBlocks << volume->VOLblockShift, + formattedSize(usedBlocks << volume->VOLblockShift, &usize, &usized, &ubyteval); - formattedSize(vFreeBlocks << volume->VOLblockShift, + formattedSize(vFreeBlocks << volume->VOLblockShift, &fsize, &fsized, &fbyteval); aprintf(color, MSG(" %-24.24U %4d.%-2.2d %2s ", - 1243), name, tsize, tsized, tbyteval); + 1243), name, tsize, tsized, tbyteval); aprintf(MAGENTA, MSG("%c", 1244), symbol); - aprintf(color, MSG(" %4d.%-2.2d %2s %4d.%-2.2d %2s ", - 1245), usize, usized, ubyteval, fsize, - fsized, fbyteval); + aprintf(color, MSG(" %4d.%-2.2d %2s %4d.%-2.2d %2s ", + 1245), usize, usized, ubyteval, fsize, + fsized, fbyteval); aprintf(MAGENTA, MSG("%c\n", 1246), asterisk); } else @@ -8570,7 +8563,7 @@ NextVolume: } UNX_LATCH( &pool->cvsLatch ); COMN_Release( &pool ); - + SET_FOREACHBLOCKINGEND(&NSSMasterPoolList, pool, Pool_s, masterPoolLink) } @@ -8652,11 +8645,11 @@ void COMN_CheckLowSpace( if (!volume->VOLstorageAlertHasBeenSent) { /* we have not yet sent an alert -- so send one*/ #ifndef __linux__ // LINUX_NetWareAlerts - /*FixFixFix6*/ + /*FixFixFix6*/ struct EventVolumeLowSpaceStruct vevent; vevent.VolumeNameLen = strlen(volName); strcpy(vevent.VolumeName, volName); - ZOS_MapVolumeNameToNumber(result,(BYTE *)&vevent.VolumeNameLen, + ZOS_MapVolumeNameToNumber(result,(BYTE *)&vevent.VolumeNameLen, &vevent.VolumeNumber); if ( result == 0) { @@ -8712,7 +8705,7 @@ STATIC STATUS COMN_FakeACVSSoUserSpaceGetsAnEvent( INIT_EVENT_ID_STATUS(id, exitE.enterRetStatus); if (NEBEventInfo[EVENT_ChangeVolState_Enter].consumers) { - INIT_VOL_STATE_ENTER_EVENT(evBlk, EVENT_ChangeVolState_Enter, + INIT_VOL_STATE_ENTER_EVENT(evBlk, EVENT_ChangeVolState_Enter, enterE, id, vol, cState, cState, mode); ZOS_ProduceEvent(status,&evBlk); /* This macro can do a GOTO!!! */ @@ -8734,7 +8727,7 @@ STATIC STATUS COMN_FakeACVSSoUserSpaceGetsAnEvent( */ if (NEBEventInfo[EVENT_ChangeVolState_Exit].consumers) { - + INIT_EXIT_EVENT( zOK, genMsg, evBlk, EVENT_ChangeVolState_Exit, exitE, id); INIT_VOL_STATE_EXIT_EVENT(exitE, vol, cState, mode); @@ -8763,8 +8756,8 @@ STATUS COMN_VolumeAttributesChanged( for (idx=0; idx <= MaxVolumeEventSAgent; idx++) { - if ((VolumeEventFuncs[idx] != NULL) && - (VolumeEventFuncs[idx]->VolumeAttributesChanged != NULL)) + if ((VolumeEventFuncs[idx] != NULL) && + (VolumeEventFuncs[idx]->VolumeAttributesChanged != NULL)) { (void)VolumeEventFuncs[idx]->VolumeAttributesChanged(genMsg,volume); ClearErrno( genMsg ); @@ -8775,7 +8768,7 @@ STATUS COMN_VolumeAttributesChanged( ClearErrno( genMsg ); #endif return(zOK); -} +} /************************************************************************** @@ -8949,7 +8942,7 @@ STATUS COMN_MakeVolumeFreeSpace( /**************************************************************************** - * + * *****************************************************************************/ STATIC void VOL_PurgeAllDeletedFilesWorkerThread( FsmLite_s *fsm, @@ -9002,7 +8995,7 @@ void VOL_StartPurgeAllDeletedFilesThread( vol->v_statusFlag |= VOL_SF_PURGE_ALL_THREAD_SCHEDULED; - WORK_Schedule(fsm, (voidfunc_t)VOL_PurgeAllDeletedFilesWorkerThread, (ADDR)vol); + WORK_Schedule(fsm, VOL_PurgeAllDeletedFilesWorkerThread, (ADDR)vol); } @@ -9073,7 +9066,7 @@ STATUS COMN_RemoveIDsFromAllVolumes( /* remove the user space restrictions */ for (i = 0; i < IDcount; i++) { - if (VOL_GetUserSpaceInfo(genMsg, nameMsg.curvol, + if (VOL_GetUserSpaceInfo(genMsg, nameMsg.curvol, &IDlist[i], &usedAmount , &restrictionAmount) == zOK) { /* @@ -9083,15 +9076,15 @@ STATUS COMN_RemoveIDsFromAllVolumes( */ if (usedAmount == 0) { - status = VOL_RemoveUser(genMsg, + status = VOL_RemoveUser(genMsg, nameMsg.curvol, &IDlist[i]); zASSERT(status == zOK); } else { zASSERT(usedAmount > 0); - status = VOL_SetUserSpaceRestriction(genMsg, - nameMsg.curvol, &IDlist[i], + status = VOL_SetUserSpaceRestriction(genMsg, + nameMsg.curvol, &IDlist[i], zUSER_NO_RESTRICTIONS); zASSERT(status == zOK); } @@ -9194,7 +9187,7 @@ void vol_DisableWorkToDoRoutine( DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, MSGNot("Work to do done with DISABLEing Volume....(May be ASYNC!!!)\n") )); #endif - + /* Mark that we are 'almost' done running. */ volume->v_statusFlag &= ~VOL_SF_DISABLE_THREAD_SCHEDULED; COMN_Release( &volume ); @@ -9245,12 +9238,12 @@ void vol_AlertWorkToDoRoutine( ( LRED, MSGNot("Work to do Alert Volume....\n") )); volume = STRUCT( workToDoFsm, Volume_s, v_alertWorkToDoFsm ); - + DQ_DEQ(&volume->v_alertList, alertInfo, NSSVolumeAlert_s, nva_alertList); while ( alertInfo != NULL ) { --volume->v_alertListCount; /* Track number of items queued */ - + /* Get the volume name and convert to ASCII */ status = COMN_GetVolumeName(&genMsg, volume, aStack->uniVolName, NELEMS(aStack->uniVolName)); @@ -9288,7 +9281,7 @@ void vol_AlertWorkToDoRoutine( 4, /* Number of (LONG) parameters */ serverName, aStack->volName, - alertInfo->nva_status, + alertInfo->nva_status, alertInfo->nva_statusSetter) ); #endif } @@ -9454,13 +9447,13 @@ void vol_AlertWorkToDoRoutine( alertInfo->nva_beastZID )); #endif } - } + } LB_free( alertInfo ); alertInfo = NULL; LB_delay( 500 ); /* Wait for 1/2 second just to even out * the flow of the ALERTs from this volume. */ - + DQ_DEQ(&volume->v_alertList, alertInfo, NSSVolumeAlert_s, nva_alertList); } /* Mark that we are 'almost' done running. */ @@ -9557,7 +9550,7 @@ STATUS COMN_SetNSSVolumeLabel( * * GREG * - * + * * YES|NO * * @@ -9651,7 +9644,7 @@ STATIC STATUS COMN_LV_RenameParse( DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, MSGNot("Volume name is reserved.\n" ) )); break; - case zERR_DUPLICATE_VOLUME_NAME: + case zERR_DUPLICATE_VOLUME_NAME: DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, MSGNot("Volume name is already in use.\n" ) )); break; @@ -9936,7 +9929,7 @@ STATIC STATUS COMN_LV_CreateParse( AuthModels[index]->modelIndex); if (authModelID == zFTYPE_INVALID) { - authModelID = zFTYPE_ZAS_AUTH_MODEL; + authModelID = zFTYPE_ZAS_AUTH_MODEL; } } parm->authModelID = authModelID; @@ -9960,8 +9953,8 @@ STATIC STATUS COMN_LV_CreateParse( else { parm->virtualFileFlag = FALSE; - DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, - (CYAN, MSGNot("VirtFlag not set\n"))); + DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, + (CYAN, MSGNot("VirtFlag not set\n"))); } /* Volume ID */ @@ -10411,7 +10404,7 @@ VCO_ParmNameToParmNumber_s VCO_ParmNameToParmNumber[] = { /* comn_VolumeCommonOpsParmNameToParmNumber() - - * Converts a parmater name unto a parameter number for the + * Converts a parmater name unto a parameter number for the * COMN_VolumeCommonOpsViaVirtualFile commands. */ @@ -10576,7 +10569,7 @@ STATUS COMN_VolumeCommonOpsViaVirtualFile( Volume_s *volume; volume = (Volume_s *)rootBeast; - status = volume->VOLcomnVolOps.VOL_commandFunction( + status = volume->VOLcomnVolOps.VOL_commandFunction( &genMsg, volume, parmNumber, parms, parmLen, parm, dataLen, data, offset, retBufLen, retBuf, retLen); @@ -10627,7 +10620,7 @@ STATUS COMN_BrowseBeastsInVolume( { Volume_s *volume; STATUS status = zFAILURE; - + volume = COMN_VolumeNameLookup(genMsg, uniVolName, onlineOnly, NULL); if (volume == NULL) { @@ -10650,7 +10643,7 @@ STATUS COMN_BrowseBeastsInVolume( } COMN_Release(&volume); -exit: +exit: return status; } @@ -10683,7 +10676,7 @@ NEB_STATUS fixCompStatsVolumeStateChangeCallBack( VolumeID_t *volumeID; zASSERT( evBlk != NULL ); - + data = (EventChangeVolStateEnter_s *)evBlk->EBEventData; volumeID = (VolumeID_t *)evBlk->EBUserParameter; @@ -10691,7 +10684,7 @@ NEB_STATUS fixCompStatsVolumeStateChangeCallBack( if ( LB_GUIDCompare(volumeID, &data->volID ) == 0 ) { /* it is our volume */ - fixCompStatsVolStateChanged = TRUE; + fixCompStatsVolStateChanged = TRUE; eventThreadID = (THREAD)ThreadId(); Wait(); } @@ -10746,14 +10739,14 @@ STATUS COMN_FixVolumeCompStats( } // import some symbols - ZOS_ImportPublicSymbol(COMPFIX_VerifyAndLoadLVSystemBeastsPtr, CMN_ModuleHandle, + ZOS_ImportPublicSymbol(COMPFIX_VerifyAndLoadLVSystemBeastsPtr, CMN_ModuleHandle, (BYTE *)COMPFIX_VerifyAndLoadLVSystemBeastsAPI); - ZOS_ImportPublicSymbol(COMPFIX_UnloadlvSystemBeastsPtr, CMN_ModuleHandle, + ZOS_ImportPublicSymbol(COMPFIX_UnloadlvSystemBeastsPtr, CMN_ModuleHandle, (BYTE *)COMPFIX_UnloadlvSystemBeastsAPI); - ZOS_ImportPublicSymbol(COMPFIX_verify_FlushVolVolumeBuffersPtr, CMN_ModuleHandle, + ZOS_ImportPublicSymbol(COMPFIX_verify_FlushVolVolumeBuffersPtr, CMN_ModuleHandle, (BYTE *)COMPFIX_verify_FlushVolVolumeBuffersAPI); - if (COMPFIX_VerifyAndLoadLVSystemBeastsPtr == NULL || - COMPFIX_UnloadlvSystemBeastsPtr == NULL || + if (COMPFIX_VerifyAndLoadLVSystemBeastsPtr == NULL || + COMPFIX_UnloadlvSystemBeastsPtr == NULL || COMPFIX_verify_FlushVolVolumeBuffersPtr == NULL) { SetErrno(genMsg, zERR_SYMBOL_NOT_DEFINED); @@ -10766,7 +10759,7 @@ STATUS COMN_FixVolumeCompStats( consumerRegInfo.CRIVersion = NEB_CONSUMER_VERSION1; consumerRegInfo.CRIConsumerName = MSGNot("NSS.FixVolCompStats"); consumerRegInfo.CRIOwnerID = CMN_ModuleHandle; - consumerRegInfo.CRIConsumerCallback = (LONG (*)(struct EventBlock *))fixCompStatsVolumeStateChangeCallBack; + consumerRegInfo.CRIConsumerCallback = fixCompStatsVolumeStateChangeCallBack; consumerRegInfo.CRIConsumerType = CHECK_CONSUMER; // consumerRegInfo.CRIConsumerType = SYNCHRONOUS_CONSUMER; // A CHECK_CONSUMER is allowed to FAIL the 'enter' event @@ -10779,14 +10772,14 @@ STATUS COMN_FixVolumeCompStats( /* check for volume's status */ if (volume->state == zVOLSTATE_MAINTENANCE) - { - /* we have to quasi-activate the volume. the following code + { + /* we have to quasi-activate the volume. the following code * only works on ZLSS type of volume */ if (volume->VOLbeastClass->classID != zFTYPE_ZLSS_VOL) { SetErrno(genMsg, zERR_NOT_SUPPORTED); - goto unregisterEvent; + goto unregisterEvent; } if ( (COMPFIX_VerifyAndLoadLVSystemBeastsPtr(genMsg, volume)) != zOK) @@ -10848,9 +10841,9 @@ STATUS COMN_FixVolumeCompStats( } } - numPreCompressedFileBlocks += + numPreCompressedFileBlocks += (CEILING(beast->eof, volume->VOLblockSize) >> volume->VOLblockShift); - } + } else { if (COMN_IsDerivedFrom(beast, zFTYPE_NAMED_DATA_STREAM)) @@ -10866,10 +10859,10 @@ STATUS COMN_FixVolumeCompStats( (beast->beastClass->classID == zFTYPE_ROOT_BEAST) && (beast->eof != 0)) ) { // This is a compressed beast // compile counts for numCompressedFileBlocks - // + // if (beast->eof <= 0x0FFFFFFF) { - numCompressedFileBlocks += + numCompressedFileBlocks += (CEILING(beast->eof, volume->VOLblockSize) >> volume->VOLblockShift); } } @@ -10877,7 +10870,7 @@ STATUS COMN_FixVolumeCompStats( COMN_UnlatchAndRelease(&beast, XLATCHED); } - } while (numReturnedZids > 0); + } while (numReturnedZids > 0); // printk(KERN_ALERT "@@@@@ VOLnumCompressedFiles1: %Lu\n", volume->VOLnumCompressedFiles); volume->VOLnumCompressedFiles = numCompressedFiles; @@ -10899,7 +10892,7 @@ STATUS COMN_FixVolumeCompStats( status = zOK; -unloadLVBeast: +unloadLVBeast: if (volume->state == zVOLSTATE_MAINTENANCE) { volume->maintenanceStatus &= ~VOLMAINTSTATUS_CHECKING; @@ -10965,9 +10958,9 @@ STATUS COMN_ncs_PVKY( } /**************************************************************************** - * return value: >0: key length. - * 0 : no key for the volume. - * -1: error. + * return value: >0: key length. + * 0 : no key for the volume. + * -1: error. *****************************************************************************/ SNINT COMN_ncs_GVKY( unicode_t *volumeName, @@ -11005,13 +10998,13 @@ STATUS COMN_SVKY( VolKeyInfo_s *p; ASSERT_MPKNSS_LOCK(); - + /* Don't allow a universal key ! */ if(unicmp(volumeName, L"ALL") == 0) { return zFAILURE; } - + /* search list of registered volumes, if present, replace the key */ DQ_FOREACH(&VolKeyHead, p, VolKeyInfo_s, dqLink) { @@ -11022,7 +11015,7 @@ STATUS COMN_SVKY( return zOK; } } - + /* Not found in existing list, insert a vol/key pair */ if((p = zalloc(sizeof( VolKeyInfo_s))) == NULL) { @@ -11048,13 +11041,13 @@ STATUS COMN_SVPW( ASSERT_MPKNSS_LOCK(); /* Don't allow a universal password or passwords that are too big */ - if( (unicmp(volumeName, L"ALL") == 0) || + if( (unicmp(volumeName, L"ALL") == 0) || ((unilen(volumePassword)+1) * sizeof(unicode_t) > sizeof(p->vPW))) { bzero(volumePassword, unilen(volumePassword)*sizeof(unicode_t)); return zFAILURE; } - + /* search list of registered volumes, if present, replace the password */ DQ_FOREACH(&VolPasswordHead, p, VolPasswordInfo_s, dqLink) { @@ -11065,7 +11058,7 @@ STATUS COMN_SVPW( return zOK; } } - + /* Not found in existing list, insert a vol/password pair */ if((p = zalloc(sizeof( VolPasswordInfo_s))) == NULL) { @@ -11334,9 +11327,9 @@ STATUS COMN_GenerateVolumeCrypto( attrib[2].type = NICI_A_KEY_USAGE; attrib[2].u.f.hasValue = 1; attrib[2].u.f.value = NICI_F_DATA_ENCRYPT | NICI_F_DATA_DECRYPT | NICI_F_EXTRACT; - + COMN_SetEncryptionAlgorithm (&encAlgo, key, &parmInfo); - + if ((status = CCS_GenerateKey (context, &encAlgo, attrib, 3, &sizeChanged, &aesKey, NICI_H_INVALID)) != NICI_E_OK) { @@ -11363,12 +11356,12 @@ STATUS COMN_GenerateVolumeCrypto( pbeAlgo.parameterLen = sizeof (parmInfoData); SetPBEAlgorithm (&pbeAlgo, key); key->p.wrappedKeyLen = sizeof(key->p.wrappedKey); - if ((status = CCS_pbeEncrypt(context, - &pbeAlgo, + if ((status = CCS_pbeEncrypt(context, + &pbeAlgo, volumePassword, // NULL terminated unicode - key->key, - sizeof(key->key), - key->p.wrappedKey, + key->key, + sizeof(key->key), + key->p.wrappedKey, (pnuint32)&(key->p.wrappedKeyLen))) != NICI_E_OK) { goto error_destroyKey; @@ -11379,7 +11372,7 @@ STATUS COMN_GenerateVolumeCrypto( * the end of the structure. */ key->p.macLen = sizeof(key->p.mac); - if ((status = CCS_pbeSign(context, + if ((status = CCS_pbeSign(context, &pbeAlgo, volumePassword, &(key->p.version), @@ -11461,7 +11454,7 @@ STATUS COMN_ProcessVolumeCrypto( status = zERR_INVALID_VOLUME_PASSWORD; goto error_destroyContext; } - + keyLen = sizeof (key->key); if ((status = CCS_pbeDecrypt(ccsContext, &pbeAlgo, @@ -11534,7 +11527,7 @@ STATUS COMN_ProcessVolumeCrypto( MPKNSS_LOCK(); return(status); -} +} #endif /**************************************************************************** @@ -11580,7 +11573,7 @@ error_exit: * key data filled in, but not yet unwrapped. If a key is already registered * for this volume, it is simply used. If no key is registered, we look for * a registered password. If a password is present, we use it to check the validity - * validity of the wrapped data, then unwrap the key, using the password and + * validity of the wrapped data, then unwrap the key, using the password and * set the key present bit, and register the key for future activations. *****************************************************************************/ STATUS COMN_EnableEncryptedVolume( @@ -11625,7 +11618,7 @@ STATUS COMN_EnableEncryptedVolume( MPKNSS_UNLOCK(); - status = AES_set_encrypt_key(vol->v_key.key, 128, &aesEncKey); + status = AES_set_encrypt_key(vol->v_key.key, 128, &aesEncKey); zASSERT(status == zOK); if (status != zOK) { @@ -11637,7 +11630,7 @@ STATUS COMN_EnableEncryptedVolume( AES_cbc_encrypt( GLOBAL_IV, &vol->v_key.iv[0], sizeof(vol->v_key.iv), &aesEncKey, &vol->v_key.iv[0], AES_ENCRYPT); - MPKNSS_LOCK(); + MPKNSS_LOCK(); vol->v_statusFlag |= VOL_SF_KEYPRESENT; for (i=0; iv_pState != zVOL_PSTATE_DELETION) + if(vol->v_pState != zVOL_PSTATE_DELETION) { /* Not a deleted volume - illegal condition */ return zERR_INVALID_VOLUME_PASSWORD; @@ -11671,7 +11664,7 @@ error_exit: status = zERR_INVALID_VOLUME_PASSWORD; return(status); } - + /**************************************************************************** * COMN_DisableEncryptedVolume assumes a valid Volume_s. This routine * tears down all the info if finds associated crypto support, including @@ -11701,3 +11694,4 @@ void COMN_DisableEncryptedVolume( } vol->v_key.numCryptBuffers = 0; } + diff --git a/src/nwnss/comn/common/comnWild.c b/src/nwnss/comn/common/comnWild.c index 2900fad..e40c71e 100644 --- a/src/nwnss/comn/common/comnWild.c +++ b/src/nwnss/comn/common/comnWild.c @@ -218,7 +218,7 @@ STATIC STATUS WILD_ReestablishSearchMap( COMN_SETUP_NAMING_MSG_FILE_BEAST_PTR_WITH_WORKBUF(&aStack->localNameMsg, nameMsg->curvol, beast->NAMEDfirstParentZid, - // cnt beast->NAMEDfirstParentNameUniquifier, + // cnt beast->NAMEDfirstParentNameUniquifier, (File_s *)beast, NAMPMODE_FullyResolveDirectory, SLATCHED, @@ -360,7 +360,7 @@ STATUS COMN_WildFindOpenContainerWithZID( if ((smap->useCount == 1) && /* On active list but not otherwise inuse */ (smap->lookupZID == zid) && (smap->fileNameSpaceID == nameMsg->nameSpaceID) && - (LB_GUIDCompare(&smap->volumeID,volID) == 0) && + (LB_GUIDCompare(&smap->volumeID,volID) == 0) && (smap->taskID == genMsg->taskID) && ((smap->options & SMAPOPT_noWildCardChars) == noWildCardSmapOpt)) { @@ -378,7 +378,7 @@ STATUS COMN_WildFindOpenContainerWithZID( if ((smap->useCount == 1) && /* On active list but not otherwise inuse */ (smap->lookupZID == zid) && (smap->fileNameSpaceID == nameMsg->nameSpaceID) && - (LB_GUIDCompare(&smap->volumeID,volID) == 0) && + (LB_GUIDCompare(&smap->volumeID,volID) == 0) && (smap->taskID == genMsg->taskID) && ((smap->options & SMAPOPT_noWildCardChars) == noWildCardSmapOpt)) { @@ -422,7 +422,7 @@ STATUS COMN_WildFindOpenContainerWithZID( } } /*------------------------------------------------------------------------- - * + * *-------------------------------------------------------------------------*/ DEBUG_PRINTF(TWILD, DBG_INDENT, (LGREEN, MSGNot("COMN_WildFindOpenContainerWithZID: Could not establishSearchMap Not found for ZID %u\n"),(NINT)zid)); //ForceSetErrno(genMsg,zERR_BAD_SEARCHMAP_ID); @@ -450,7 +450,7 @@ foundSMAP: /* In all cases above, we have already incremented the useCount for * this SearchMapIDP_s pointer */ COMN_SET_SEARCHMAP(&srchMsg->srchMap,smap->mapID,smap); - RTN_STATUS(zOK); + RTN_STATUS(zOK); } @@ -499,7 +499,7 @@ Restart_WildRead: SetErrno(genMsg,zERR_BAD_SEARCHMAP_ID); goto cleanup_error; } - + if (smap->options & SMAPOPT_atEndOfDir) { status = zFAILURE; @@ -578,8 +578,8 @@ Restart_WildRead: zASSERT(nameMsg->curFile == NULL); zASSERT(nameMsg->curDataStream == NULL); zASSERT(nameMsg->curvol == NULL); - - /* Set up the name message to point to the directory to be + + /* Set up the name message to point to the directory to be * searched. This is done in a "KLUDGEY - BRUTE FORCE type of * way. If we just call COMN_LOOKUP, we will get an error if * the workNameSpace is Data Stream or Extended Attribute because @@ -657,7 +657,7 @@ Restart_WildRead: } nameMsg->fileZid = smap->dirZid; nameMsg->dataStreamZid = smap->dirZid; - nameMsg->fileParentZid = smap->fileParentZid; + nameMsg->fileParentZid = smap->fileParentZid; // cnt nameMsg->fileNameUniquifier = smap->fileNameUniquifier; nameMsg->fileNameType = smap->fileNameType; nameMsg->zidNameType = smap->fileNameType; @@ -677,7 +677,7 @@ Restart_WildRead: zASSERT(nameMsg->curFile == NULL); nameMsg->fileZid = smap->dirZid; nameMsg->dataStreamZid = smap->dirZid; - nameMsg->fileParentZid = smap->fileParentZid; + nameMsg->fileParentZid = smap->fileParentZid; // cnt nameMsg->fileNameUniquifier = smap->fileNameUniquifier; nameMsg->fileNameType = smap->fileNameType; nameMsg->zidNameType = smap->fileNameType; @@ -792,7 +792,7 @@ Restart_WildRead: COMN_Release(&nameMsg->workNameSpace); if ((nameMsg->workNameSpace = NSPACE_LOOKUP_NAMESPACE(genMsg, nameMsg->workNameSpaceID,nameMsg->workNameSpace)) == NULL) - { + { status = zFAILURE; goto cleanup_error; } @@ -806,7 +806,7 @@ Restart_WildRead: * which contains a searchPattern in the nameMsg->curComponent ptr. *---------------------------------------------------------------------------*/ - CHECK_FSHOOKS_DIRECTORY_SEARCH_ENTER(DirectorySearch_Hook, &parms, + CHECK_FSHOOKS_DIRECTORY_SEARCH_ENTER(DirectorySearch_Hook, &parms, status, cleanup_error, genMsg, nameMsg, srchMsg); if ( (origLatchType = nameMsg->latchType) == NOTLATCHED) @@ -875,7 +875,7 @@ Restart_WildRead: status = zOK; sendExitEvent: - CHECK_FSHOOKS_DIRECTORY_SEARCH_EXIT(DirectorySearch_Hook, &parms, + CHECK_FSHOOKS_DIRECTORY_SEARCH_EXIT(DirectorySearch_Hook, &parms, genMsg, nameMsg, srchMsg); RTN_STATUS(status); @@ -1006,7 +1006,7 @@ STATIC void WILD_HandleBeastlessName( ASSERT_MPKNSS_LOCK(); ENTER(TWILD, WILD_HandleBeastlessName); - curdir = (NamedBeast_s *)nameMsg->curFile; + curdir = (NamedBeast_s *)nameMsg->curFile; ASSERT_LATCH(&curdir->NAMEDbeastLatch); /* make sure directory is latched */ COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); @@ -1041,7 +1041,7 @@ STATIC void WILD_HandleBeastlessName( * This routine will search for the specific file in the given directory that * matches the wildcard pattern. The pattern has already been set into * the WORKNAME buffer, and we know it contains no wildcard characters. - * + * ***************************************************************************/ STATIC STATUS WILD_searchForSpecificFile( GeneralMsg_s *genMsg, @@ -1106,7 +1106,7 @@ STATIC STATUS WILD_searchForSpecificFile( srchMsg->srchMap.ptr->lookupZID = curFile->NAMEDzid; return(zOK); - + /*===========================================================================*/ cleanup_errorExit: return(zFAILURE); @@ -1153,7 +1153,7 @@ void LB_SaveErrno( * * (1) In some rare cases zERR_C will be returned (see LB_SetErrno). */ -void LB_CombineErrno( +void LB_CombineErrno( GeneralMsg_s *genMsg, /* Current Errno */ ErrnoInfo_s *ei ) /* Original Errno */ { @@ -1195,7 +1195,7 @@ void LB_CombineErrno( * zOK_O zOK_C zOK_O * */ -void LB_CombineErrnoWithForce( +void LB_CombineErrnoWithForce( GeneralMsg_s *genMsg, /* Current Errno */ ErrnoInfo_s *ei ) /* Original Errno */ { @@ -1226,7 +1226,7 @@ void LB_CombineErrnoWithForce( * zOK_O zOK_C zOK_O * */ -void LB_RestoreErrno( +void LB_RestoreErrno( GeneralMsg_s *genMsg, /* Current Errno */ ErrnoInfo_s *ei ) /* Original Errno */ { @@ -1241,7 +1241,7 @@ void LB_RestoreErrno( * This routine will search for the next file in the given directory that * matches the wildcard pattern. The pattern has already been set into * the WORKNAME buffer. - * + * * outputs: * nameMsg.curVnode the next file we found ***************************************************************************/ @@ -1288,7 +1288,7 @@ STATIC STATUS WILD_searchForFile( smap = SMAP_RESOLVE_SEARCHMAP(genMsg,&srchMsg->srchMap,srchMsg->srchOpt); smap->match = nameMsg->match; - + /* commented out 7/22/97 by Brenda and Neal. We don't want to invalidate * this field unless we successfully find a new file. * @@ -1470,7 +1470,7 @@ STATIC STATUS WILD_searchForFile( !(aStack->fullDirInfo.matchAttributes & MA_ATTRS_ARE_VALID) ) { /* Set the Hidden, System, Subdirectory & VALID bits into the - * match attributes for this name entry. This does not need + * match attributes for this name entry. This does not need * to be part of a transaction. The data is considered "Messy" * meaning it doesn't matter if it makes it back to disk or not. * If the system crashes before it is flushed, it will just get @@ -1511,7 +1511,7 @@ STATIC STATUS WILD_searchForFile( (LONG)aStack->fullDirInfo.zid, aStack->fullDirInfo.name)); /* Make the Hardlink flags accurately reflect whether or not - * curFile is a hardlink beast. This does not need + * curFile is a hardlink beast. This does not need * to be part of a transaction. The data is considered "Messy" * meaning it doesn't matter if it makes it back to disk or not. * If the system crashes before it is flushed, it will just get @@ -1590,7 +1590,7 @@ STATIC STATUS WILD_searchForFile( COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS_KEEP_LATCHTYPE(nameMsg); nameMsg->curFile = (File_s *)curFile; /* Already latched */ nameMsg->curDataStream = curFile; - COMN_USE_BEAST(&nameMsg->curDataStream->NAMEDroot); + COMN_USE_BEAST(&nameMsg->curDataStream->NAMEDroot); } else { @@ -1638,7 +1638,7 @@ cleanup_release: * This routine will search for the next file that matches the wildcard * pattern. The pattern has already been set into the WORKNAME buffer. * The search includes the original directory and all subdirectories. - * + * * outputs: * nameMsg.curVnode the next file we found ***************************************************************************/ @@ -1695,7 +1695,7 @@ STATIC STATUS WILD_searchAllDirsForFile( smap = srchMsg->srchMap.ptr; if (smap->parentMap == NULL) { /* no parent directory search map */ - if (srchMsg->srchOpt & SMAPOPT_returnAllFilesFirst) + if (srchMsg->srchOpt & SMAPOPT_returnAllFilesFirst) { /* Return a pointer to the directory now, since we * have finished searching everything below it */ @@ -1726,7 +1726,7 @@ STATIC STATUS WILD_searchAllDirsForFile( zASSERT(smap->useCount >= 2); COMN_SET_SEARCHMAP(&srchMsg->srchMap,smap->mapID,smap); - if (srchMsg->srchOpt & SMAPOPT_returnAllFilesFirst) + if (srchMsg->srchOpt & SMAPOPT_returnAllFilesFirst) { /* Return a pointer to the directory now, since we * have finished searching everything below it */ diff --git a/src/nwnss/comn/common/comnXaction.c b/src/nwnss/comn/common/comnXaction.c index 6a0c960..70a5516 100644 --- a/src/nwnss/comn/common/comnXaction.c +++ b/src/nwnss/comn/common/comnXaction.c @@ -33,7 +33,7 @@ |--------------------------------------------------------------------------- | This module is used to: | This contains the top level internal file interfaces. All external - | interfaces call these routines. + | interfaces call these routines. +-------------------------------------------------------------------------*/ #include @@ -64,7 +64,7 @@ typedef struct AbortXLocalInfo_s } AbortXLocalInfo_s; AbortXLocalInfo_s AbortXLocalInfo[MAX_ABORT_XLOCAL_INFO]; -NINT AbortXLocalCount = 0; +NINT AbortXLocalCount = 0; /**************************************************************************** * This routine is called to abort a transaction @@ -114,7 +114,7 @@ void COMN_AbortXLocal( AbortXLocalInfo[AbortXLocalCount].AXI_status = status; AbortXLocalInfo[AbortXLocalCount].AXI_errnoSetter = GetErrnoSetter(genMsg); AbortXLocalInfo[AbortXLocalCount].AXI_alertFlags = flags; - NSS_StoreCallers( AbortXLocalInfo[AbortXLocalCount].AXI_callers, + NSS_StoreCallers( AbortXLocalInfo[AbortXLocalCount].AXI_callers, NUM_ABORT_XLOCAL_CALLERS, 1); @@ -125,7 +125,7 @@ void COMN_AbortXLocal( COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); (void)COMN_VolumeAlert( &dummyGenMsg, NULL, volume, NULL, - 0, 0, status, GetErrnoSetter( genMsg ), flags ); + 0, 0, status, GetErrnoSetter( genMsg ), flags ); } RTN_VOID(); @@ -138,7 +138,7 @@ void COMN_AbortXLocal( Xaction_s *COMN_BeginXLocal( void *voidBeast) { - RootBeast_s *beast = (RootBeast_s *)voidBeast; + RootBeast_s *beast = (RootBeast_s *)voidBeast; Xaction_s *xaction; ASSERT_MPKNSS_LOCK(); @@ -288,5 +288,6 @@ STATUS COMN_ForceBeastWrite( { COMN_MARK_BEAST_DIRTY(beast); /* this sets the flush timer */ } - RTN_STATUS(zOK); -} + RTN_STATUS(zOK); +} + diff --git a/src/nwnss/comn/common/contextHandle.c b/src/nwnss/comn/common/contextHandle.c index 9b5cbdb..b446c68 100644 --- a/src/nwnss/comn/common/contextHandle.c +++ b/src/nwnss/comn/common/contextHandle.c @@ -34,7 +34,7 @@ | This module is used to: | This manages Context Handles structures for PSS. +-------------------------------------------------------------------------*/ -#include +#include #include /* netware includes*/ #include #include @@ -63,7 +63,7 @@ * connection, with IDs ranging from 2 .. 255. For now, the NWSA semantic * agent maps legacy DirHandleIDs to NSS ContextHandleIDs with a simple * byte array. It knows whether a handle ID belongs to NSS by whether it's - * mapping slot is filled in. + * mapping slot is filled in. * * In the future, when we change contextHandleIDs to be "64 bit keys" the * NWSA mapping will need to be changed to an array of 256 Keys rather than @@ -96,7 +96,7 @@ STATIC void CXH_ReleaseContextHandleBeasts( ***************************************************************************/ STATIC STATUS CXH_ExtendContextHandleList( NSSConnection_s *pssConn) -{ +{ NINT newArraySize; ContextHandleInfo_s *(*new)[]; @@ -229,7 +229,7 @@ STATIC void CXH_RemoveContextHandle( { NSSConnection_s *pssConn; NINT handleID; - + ASSERT_MPKNSS_LOCK(); pssConn = cxh->pssConn; ASSERT_XLATCH(&pssConn->contextHandles.cxhLatch); @@ -238,7 +238,7 @@ STATIC void CXH_RemoveContextHandle( { /* This is the special SYS:LOGIN context handle */ zASSERT(pssConn->contextHandles.sysLoginCxh == cxh); - pssConn->contextHandles.sysLoginCxh = NULL; + pssConn->contextHandles.sysLoginCxh = NULL; } else { @@ -279,7 +279,7 @@ STATIC void CXH_RemoveContextHandle( * yet freed it because we had it in use. * If the use count goes to zero, this function will also release the * use count on the beasts pointed to by the context handle, and will free - * up the memory occupied by the handle. + * up the memory occupied by the handle. * ***************************************************************************/ void COMN_DoReleaseContextHandleIDP( @@ -294,7 +294,7 @@ void COMN_DoReleaseContextHandleIDP( if ((cxh = cxhIDP->ptr) == NULL) { return; - } + } zASSERT(cxh->handleID == cxhIDP->id); cxhIDP->ptr = NULL; @@ -330,7 +330,7 @@ STATIC STATUS CXH_SetupSYSLoginContextHandle( NamingMsg_s nameMsg; } Stack_s; STACK_ALLOC(); - + ASSERT_MPKNSS_LOCK(); ASSERT_XLATCH(&pssConn->contextHandles.cxhLatch); zASSERT(pssConn->contextHandles.sysLoginCxh == NULL); @@ -341,7 +341,7 @@ STATIC STATUS CXH_SetupSYSLoginContextHandle( COMN_INIT_NAMING_MSG(&aStack->nameMsg); COMN_SETUP_NAMING_MSG_SIMPLE(&aStack->nameMsg, L"SYS:\\LOGIN", zPFMT_UNICODE, NAMPMODE_FullyResolveAny, NOTLATCHED, zNSPACE_DOS, - zNTYPE_FILE, NULL); + zNTYPE_FILE, NULL); if ( COMN_Lookup(genMsg, &aStack->nameMsg) != zOK) { @@ -424,7 +424,7 @@ ContextHandleInfo_s *COMN_DoResolveContextHandle( if ((pssConn = CNCT_RESOLVE_CONNECTION(genMsg)) == NULL) return NULL; /*------------------------------------------------------------------------- - * Validate the context handle. Note the context handle IDof ZERO + * Validate the context handle. Note the context handle IDof ZERO * is always invalid. *-------------------------------------------------------------------------*/ handleid = CONTEXTHANDLE_INDEX(cxhIDP->id); /* make index into tables*/ @@ -438,7 +438,7 @@ ContextHandleInfo_s *COMN_DoResolveContextHandle( } /*--------------------------------------------------------------------------- * This is a special context handle ID==1, which points to the SYS:LOGIN - * Directory + * Directory *---------------------------------------------------------------------------*/ if (pssConn->contextHandles.sysLoginCxh == NULL) { @@ -814,7 +814,7 @@ STATUS COMN_ClearTaskBasedContextHandles( /**************************************************************************** - * This routine will find all contextHandles that point to the + * This routine will find all contextHandles that point to the * combination of vol/oldDir/dir and will fix them to point to the * combination of vol/newDir/dir. *****************************************************************************/ diff --git a/src/nwnss/comn/common/cro.c b/src/nwnss/comn/common/cro.c index 9cc0d54..3ea248a 100644 --- a/src/nwnss/comn/common/cro.c +++ b/src/nwnss/comn/common/cro.c @@ -36,9 +36,6 @@ #include #include -#ifdef NSS_USERSPACE -#include -#endif #include #include @@ -54,13 +51,6 @@ #include "csaLease.h" #include "cro.h" -#ifdef NSS_USERSPACE -/* cro userspace status bridge: Msg_s.sys.where is a QUAD carrier here. */ -#undef SetErrnoFromStatus -#define SetErrnoFromStatus(_genMsg, _msg) \ - ((_genMsg)->errStatus = (_msg)->sys.status, \ - ((_genMsg)->errStatusSetter = (char *)(uintptr_t)((_msg)->sys.where))) -#endif /*************************************************************************** @@ -78,7 +68,7 @@ BOOL CRO_ProcessErrorAndRequestRetry( Volume_s *vol) { STATUS status = GetErrno(genMsg); - + if (status == zERR_DESTROY_OBJECT) { COMN_VolumeAlert(genMsg, NULL, vol, NULL, 0, 0, @@ -111,17 +101,17 @@ STATUS CRO_AccessLeaseGetMsg( Key_t key, FileHandle_s *fh, BOOL reconnect, - Key_t *retMasterFHKey) + Key_t *retMasterFHKey) { STATUS status; xMsg_s msg; - XLSS_AccessLeaseOpenMsg_s *xlssPacket = + XLSS_AccessLeaseOpenMsg_s *xlssPacket = &msg.body.accessLeaseOpen.xlssPacket; /* In */ - CSA_AccessLeaseOpenMsg_s *csaPacket = + CSA_AccessLeaseOpenMsg_s *csaPacket = &msg.body.accessLeaseOpen.csaPacket; /* Out */ - - xMSG_INIT( &msg ); + + xMSG_INIT( &msg ); XLSS_LOCAL_GENMSG_TO_REMOTE_GENMSG(genMsg, &xlssPacket->XALM_genMsg); xlssPacket->XALM_fileNameUniquifier = fh->fileNameUniquifier; @@ -131,7 +121,7 @@ STATUS CRO_AccessLeaseGetMsg( xlssPacket->XALM_nSpaceID = fh->dataStreamNameSpaceID; xlssPacket->XALM_nameType = fh->dataStreamNameType; xlssPacket->XALM_grantedRights = fh->grantedRights; - xlssPacket->XALM_parseFlags = reconnect ? + xlssPacket->XALM_parseFlags = reconnect ? NAMPFL_dontLockVolumeActive : 0; status = MSG_Call(key, CSA_ACCESS_LEASE_OPEN, (Msg_s *)&msg); @@ -187,8 +177,8 @@ STATUS CRO_AccessLeaseGet( } retryRequest: - status = CRO_AccessLeaseGetMsg( genMsg, - vol->v_croVolDoor->CVO_CSAVolumeKey, + status = CRO_AccessLeaseGetMsg( genMsg, + vol->v_croVolDoor->CVO_CSAVolumeKey, fh, FALSE, &masterFHKey); if (status != zOK) { @@ -211,7 +201,7 @@ foundAccessLease: fh->FH_accessLease = aLease; aLease->CAL_fhCount++; UNX_LATCH(&beast->NB_alList->CALL_latch); - + return zOK; } @@ -290,7 +280,7 @@ STATUS CRO_AccessLeaseReconnect( { MSG_RELEASE_DOOR(&prevFh->door); } - + zASSERT(fh->FH_accessLease != NULL); if (fh->FH_accessLease->CAL_flags & CAL_FLAG_AL_RECREATED) { @@ -342,7 +332,7 @@ STATUS CRO_AccessLeaseSync( { BEASTHASH_incrementUseCount(&namedBeast->NAMEDroot); CRO_AccessLeaseCleanupNotInUse(namedBeast); - + if (DQ_NOT_EMPTY(&namedBeast->openFileHandles)) { if (CRO_AccessLeaseReconnect(genMsg, namedBeast, key) != zOK) @@ -378,7 +368,7 @@ STATUS CRO_AccessLeaseSync( } return zOK; } - + #if NSS_DEBUG IS_ENABLED /* Catch changes (at compile time) to structures that we init. */ @@ -431,7 +421,7 @@ void CRO_CloseListDestruct( /* * CRO_CloseListSend() - * Close a list of files on the master. This is a synchronous call. - * + * * Notes - * If we get transmission type errors we still clean up our Access Leases. * At some point the master will ask us to validate access leases and .................... @@ -443,10 +433,10 @@ STATUS CRO_CloseListSend( Volume_s *vol = rootBeast->ROOTvolume; STATUS status; xMsg_s msg; - XLSS_AccessLeaseCloseMsg_s *xlssPacket = + XLSS_AccessLeaseCloseMsg_s *xlssPacket = &msg.body.accessLeaseClose.xlssPacket; /* In */ #if NSS_DEBUG IS_ENABLED - CSA_AccessLeaseCloseMsg_s *csaPacket = + CSA_AccessLeaseCloseMsg_s *csaPacket = &msg.body.accessLeaseClose.csaPacket; /* Out */ #endif @@ -469,7 +459,7 @@ STATUS CRO_CloseListSend( { /* No keys to close so we are done */ return( zOK ); } - + status = MSG_Call( vol->v_croVolDoor->CVO_CSAVolumeKey, CSA_ACCESS_LEASE_CLOSE, (Msg_s *)&msg ); if (status != zOK) { @@ -479,8 +469,8 @@ STATUS CRO_CloseListSend( { NINT i; - zASSERT( csaPacket->CALCM_masterKeyCount == closeList->XCL_Keys ); - zASSERT( xlssPacket->XALCM_masterKeyCount == closeList->XCL_Keys ); + zASSERT( csaPacket->CALCM_masterKeyCount == closeList->XCL_Keys ); + zASSERT( xlssPacket->XALCM_masterKeyCount == closeList->XCL_Keys ); for ( i = 0; i < closeList->XCL_Keys; ++i ) { /* Can see this ASSERT if a validate sneaks in and cause the @@ -776,3 +766,5 @@ void CRO_AccessLeaseRemoveClosed( return; } /* End of CRO_AccessLeaseRemoveClosed() */ + + diff --git a/src/nwnss/comn/common/csaLease.c b/src/nwnss/comn/common/csaLease.c index 5734c5f..5e42d78 100644 --- a/src/nwnss/comn/common/csaLease.c +++ b/src/nwnss/comn/common/csaLease.c @@ -33,8 +33,9 @@ |--------------------------------------------------------------------------- +-------------------------------------------------------------------------*/ +#include + #include -#include #include #include @@ -46,10 +47,10 @@ #include #include -#include -#include -#include -#include +#include "xMsg.h" +#include "csa.h" +#include "csaLease.h" +#include "xMsg.h" CSAStats_s CSAStats; @@ -105,7 +106,7 @@ void CSA_CSABeastNotInUse( STATUS CSA_BeastLeaseToss( GeneralMsg_s *genMsg, CsaVolumeDoor_s *csaVolumeDoor, - Zid_t zid, + Zid_t zid, CSALeaseID_t beastLeaseID ) { CSABeast_s *csaBeast; @@ -375,7 +376,7 @@ CSALeaseID_t CSA_BeastLeaseCreate( /** We do not release the use count that we ** got from CSA_CSABeastCreate because ** rootBeast->csaBeast is using it. - **/ + **/ rootBeast->csaBeast = csaBeast; CSA_CSABeastUse( csaBeast ); } @@ -384,7 +385,7 @@ CSALeaseID_t CSA_BeastLeaseCreate( CSA_CSABeastUse( csaBeast ); CSA_CSABEAST_X_LATCH( csaBeast ); } - beastLease = CSA_BeastLeaseConstruct( genMsg, csaVolumeDoor, csaBeast, rootBeast ); + beastLease = CSA_BeastLeaseConstruct( genMsg, csaVolumeDoor, csaBeast, rootBeast ); /* Must get ID before release latch on CSABeast */ beastLeaseID = CSA_BeastLeaseID( beastLease ); CSA_CSABEAST_UNX_LATCH( csaBeast ); @@ -519,7 +520,7 @@ CSABeastLease_s *CSA_BeastLeaseConstruct( } /* End of CSA_BeastLeaseConstruct() */ -/* +/* * CSA_BeastLeaseDestruct() - * Called to free up a Beast Lease. The caller must have * a use count. The only other use counts on the beast lease @@ -541,7 +542,7 @@ void CSA_BeastLeaseDestruct( CSABeastLease_s *beastLease = *csaBeastLeasePtr; // zASSERT( beastLease->CBL_useCount == CSA_BEAST_LEASE_DESTROY_USE_COUNT ); - /* Caller, //CBL_csaVolumeDoorLink// and CBL_beastLink */ + /* Caller, //CBL_csaVolumeDoorLink// and CBL_beastLink */ CSA_CSABEAST_ASSERT_X_LATCH( csaBeast ); zASSERT( QMEMBER( &beastLease->CBL_beastLink ) ); // zASSERT( QMEMBER( &beastLease->CBL_csaVolumeDoorLink ) ); @@ -615,13 +616,13 @@ STATUS CSA_BeastLeaseExpire( RootBeast_s *rootBeast ) // * // * Routine called ASYNC by XLSS after it has broken a Beast Lease. // * -// */ +// */ //STATUS CSA_BeastLeaseBreakMsg( // xMsg_s *msg) //{ // GeneralMsg_s genMsg; // Volume_s *volume; -// XLSS_BeastLeaseBreakMsg_s *xlssPacket = +// XLSS_BeastLeaseBreakMsg_s *xlssPacket = // &msg->body.beastLeaseBreakReply.xlssPacket; // // COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE( &genMsg ); @@ -702,7 +703,7 @@ CSABeast_s *CSA_CSABeastCreate( * Attempts to make the 'CSABeast' not in use. Errors should be * expected (see Notes below). CSA Beast will not be placed on the not * in use list until after the caller releases its latch and use count. - * + * * Notes - * A common return is that the 'CSABeast' is still * in use because of Access Lease(s). @@ -819,7 +820,7 @@ CSABeast_s *CSA_CSABeastConstruct( DQ_INIT( &csaBeast->CB_accessLeaseHead ); INIT_LATCH( &csaBeast->CB_latch ); csaBeast->CB_dataSeqNum = 0; - + /* Place on the list that cleanup logic expects us to be on */ DQ_ENQ( &csaVolumeDoor->volume->v_csaVolInfo->CVI_csaBeastHead, csaBeast, CB_csaVolumeInfoLink ); ++csaBeast->CB_useCount; @@ -853,7 +854,7 @@ void CSA_CSABeastDestruct( ++CSAStats.CS_csaBeastDestructed; --CSAStats.CS_csaBeastCurrent; - /* First remove from lookup area, so that no one can find + /* First remove from lookup area, so that no one can find * item while we free it. This will remove the hash * "use count". */ @@ -884,18 +885,18 @@ STATUS CSA_BeastLeaseBreakCall( { xMsg_s msg; STATUS status; - CSA_BeastLeaseBreakMsg_s *csaPacket = + CSA_BeastLeaseBreakMsg_s *csaPacket = &msg.body.beastLeaseBreakRequest.csaPacket; CSA_CSABEAST_ASSERT_LATCH( csaBeast ); - xMSG_INIT( &msg ); + xMSG_INIT( &msg ); csaPacket->CBLM_zid = csaBeast->CB_zid; csaPacket->CBLM_delayHint = 2 * 1000; /* FixFixFix - need logic here */ csaPacket->CBLM_beastLeaseID = (CSALeaseID_t)((ADDR)csaBeastLease); - status = MSG_Send( csaBeastLease->CBL_csaVolumeDoor->xlssVolumeKey, + status = MSG_Send( csaBeastLease->CBL_csaVolumeDoor->xlssVolumeKey, XLSS_BEAST_LEASE_BREAK, (Msg_s *)&msg); /*** FixFixFix add code to wait for reply ***/ @@ -913,9 +914,9 @@ STATUS CSA_BeastLeaseBreakCall( */ void CSA_BeastLeaseBreakSendAll( RootBeast_s *rootBeast ) -{ +{ xMsg_s msg; - CSA_BeastLeaseBreakMsg_s *csaPacket = + CSA_BeastLeaseBreakMsg_s *csaPacket = &msg.body.beastLeaseBreakRequest.csaPacket; // Volume_s *volume = rootBeast->ROOTvolume; CSABeast_s *csaBeast = rootBeast->csaBeast; @@ -929,7 +930,7 @@ void CSA_BeastLeaseBreakSendAll( CSA_CSABeastUse(csaBeast); - xMSG_INIT( &msg ); + xMSG_INIT( &msg ); csaPacket->CBLM_zid = rootBeast->ROOTzid; csaPacket->CBLM_delayHint = 2 * 1000; /* FixFixFix - need logic here */ @@ -939,7 +940,7 @@ void CSA_BeastLeaseBreakSendAll( CSABeastLease_s, CBL_beastLink ) { csaPacket->CBLM_beastLeaseID = CSA_BeastLeaseID( csaBeastLease ); - MSG_Send( csaBeastLease->CBL_csaVolumeDoor->xlssVolumeKey, + MSG_Send( csaBeastLease->CBL_csaVolumeDoor->xlssVolumeKey, XLSS_BEAST_LEASE_BREAK, (Msg_s *)&msg ); DQ_FOREACH_NEXT( prevCsaBeastLease, csaBeastLease, @@ -967,7 +968,7 @@ STATUS CSA_CSABeastHashInit() for (i = 0; i < Config.bst.hashSize; i++) { - DQ_INIT(&CSABeastHash[i]); + DQ_INIT(&CSABeastHash[i]); } return zOK; } @@ -1061,13 +1062,13 @@ void CSA_CSABeastLookupRemove( * of the beast is gone, so it is releasing the lease it had * obtained on the CSA side. * - */ + */ STATUS CSA_BeastLeaseTossMsg( xMsg_s *msg) { GeneralMsg_s genMsg; Volume_s *volume; - XLSS_BeastLeaseTossMsg_s *xlssPacket = + XLSS_BeastLeaseTossMsg_s *xlssPacket = &msg->body.beastLeaseToss.xlssPacket; COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE( &genMsg ); @@ -1100,7 +1101,7 @@ STATUS CSA_BeastLeaseTossMsg( * Receiver of list of beasts that slaves already have leases on. * We need to recreate the beast lease on the master. This is only * called during reconnect. - */ + */ STATUS CSA_BeastLeaseRecreateMsg( xMsg_s *msg) { @@ -1129,11 +1130,11 @@ STATUS CSA_BeastLeaseRecreateMsg( // } beastCount = msg->sys.data[0].length/sizeof(*beastLeaseList); - beastLeaseList = (XLSSBeastLeaseList_s *)(uintptr_t)msg->sys.data[0].start; + beastLeaseList = msg->sys.data[0].start; for (i = 0; i < beastCount; i++) { - beast = BEASTHASH_LookupByZid(&genMsg, volume, + beast = BEASTHASH_LookupByZid(&genMsg, volume, beastLeaseList[i].XBLL_beastZid, XLATCHED); if (beast == NULL) { @@ -1141,7 +1142,7 @@ STATUS CSA_BeastLeaseRecreateMsg( continue; } - beastLeaseID = CSA_BeastLeaseAcquire( &genMsg, + beastLeaseID = CSA_BeastLeaseAcquire( &genMsg, (CsaVolumeDoor_s *)msg->sys.door, beast ); if ( beastLeaseID == INVALID_BEAST_LEASE_ID ) @@ -1170,14 +1171,14 @@ STATUS CSA_BeastLeaseRecreateMsg( * the slaves that have a beast lease, that this beast is going to be purged, * so they need to stop using it further. When the last useCount on the * slave for this beast is removed, the slave should toss the beast from - * memory. + * memory. * **************************************************************************/ void CSA_BeastLeaseStatePurging ( RootBeast_s *rootBeast) { xMsg_s msg; - CSA_BeastStatePurgingMsg_s *csaPacket = + CSA_BeastStatePurgingMsg_s *csaPacket = &msg.body.beastStatePurging.csaPacket; CSABeast_s *csaBeast = rootBeast->csaBeast; CSABeastLease_s *csaBeastLease; @@ -1187,7 +1188,7 @@ void CSA_BeastLeaseStatePurging ( return; } - xMSG_INIT( &msg ); + xMSG_INIT( &msg ); csaPacket->CBPM_zid = rootBeast->ROOTzid; @@ -1195,7 +1196,7 @@ void CSA_BeastLeaseStatePurging ( DQ_FOREACH( &csaBeast->CB_beastLeaseHead, csaBeastLease, CSABeastLease_s, CBL_beastLink ) { - MSG_Send( csaBeastLease->CBL_csaVolumeDoor->xlssVolumeKey, + MSG_Send( csaBeastLease->CBL_csaVolumeDoor->xlssVolumeKey, XLSS_BEAST_STATE_PURGING, (Msg_s *)&msg ); } CSA_CSABEAST_UNS_LATCH( csaBeast ); @@ -1226,9 +1227,9 @@ void CSA_AccessLeaseOpenMsg( } Stack_s; Stack_s *aStack; - XLSS_AccessLeaseOpenMsg_s *xlssPacket = + XLSS_AccessLeaseOpenMsg_s *xlssPacket = &msg->body.accessLeaseOpen.xlssPacket; /* In */ - CSA_AccessLeaseOpenMsg_s *csaPacket = + CSA_AccessLeaseOpenMsg_s *csaPacket = &msg->body.accessLeaseOpen.csaPacket; /* Out */ STACK_ALLOC_NO_ASTACK(); @@ -1277,9 +1278,9 @@ void CSA_AccessLeaseCloseMsg( /* Method CSA_ACCESS_LEASE_CLOSE */ { int i; STATUS status; - XLSS_AccessLeaseCloseMsg_s *xlssPacket = + XLSS_AccessLeaseCloseMsg_s *xlssPacket = &msg->body.accessLeaseClose.xlssPacket; /* In */ - CSA_AccessLeaseCloseMsg_s *csaPacket = + CSA_AccessLeaseCloseMsg_s *csaPacket = &msg->body.accessLeaseClose.csaPacket; /* Out */ csaPacket->CALCM_masterKeyCount = 0; @@ -1307,9 +1308,9 @@ STATUS CSA_AccessLeaseValidate( STATUS status; NamedBeast_s *namedBeast; xMsg_s msg; - CSA_AccessLeaseValidateMsg_s *csaPacket = + CSA_AccessLeaseValidateMsg_s *csaPacket = &msg.body.accessLeaseValidate.csaPacket; - XLSS_AccessLeaseValidateMsg_s *xlssPacket = + XLSS_AccessLeaseValidateMsg_s *xlssPacket = &msg.body.accessLeaseValidate.xlssPacket; namedBeast = fh->dataStream; @@ -1323,7 +1324,7 @@ STATUS CSA_AccessLeaseValidate( csaPacket->CALVM_zid = namedBeast->NAMEDzid; csaPacket->CALVM_masterFHKey = fh->door.dr_key; - status = MSG_Call( fh->FH_csaVolObj->xlssVolumeKey, + status = MSG_Call( fh->FH_csaVolObj->xlssVolumeKey, XLSS_ACCESS_LEASE_VALIDATE, (Msg_s *)&msg ); if ( status == zOK ) { @@ -1361,7 +1362,7 @@ STATUS CSA_CloseNotInUseFileHandles( MSG_RELEASE_DOOR(&prevFh->door); } if ((fh != skipFH) && - (fh->fhState & FH_CFS_OPEN) && + (fh->fhState & FH_CFS_OPEN) && FH_RequestedRightsInConflict(fh->grantedRights, rights)) { status = CSA_AccessLeaseValidate(fh, &inUse); @@ -1387,7 +1388,7 @@ STATUS CSA_CloseNotInUseFileHandles( /*************************************************************************** * - * Close all the file Handles associated with a slave, on a Beast. + * Close all the file Handles associated with a slave, on a Beast. * ***************************************************************************/ void CSA_CloseFileHandlesForASlaveOnBeast( @@ -1395,8 +1396,8 @@ void CSA_CloseFileHandlesForASlaveOnBeast( CsaVolumeDoor_s *volObject) { FileHandle_s *fh, *prevFh = NULL; - - + + DQ_FOREACH(&namedBeast->openFileHandles, fh, FileHandle_s, bstLink) { MSG_USE_DOOR(&fh->door); @@ -1406,7 +1407,7 @@ void CSA_CloseFileHandlesForASlaveOnBeast( } if ((fh->fhState & FH_CFS_OPEN) && (fh->FH_csaVolObj == volObject)) { - MSG_DestroyKey(fh->door.dr_key); + MSG_DestroyKey(fh->door.dr_key); } prevFh = fh; } @@ -1421,7 +1422,7 @@ void CSA_CloseFileHandlesForASlaveOnBeast( /*************************************************************************** * - * Close all the file Handles associated with a slave. + * Close all the file Handles associated with a slave. * ***************************************************************************/ void CSA_CloseFileHandlesForASlave( @@ -1435,7 +1436,7 @@ void CSA_CloseFileHandlesForASlave( if (namedBeast) { BEASTHASH_incrementUseCount(&namedBeast->NAMEDroot); - + if (DQ_NOT_EMPTY(&namedBeast->openFileHandles)) { CSA_CloseFileHandlesForASlaveOnBeast(namedBeast, volObject); @@ -1469,3 +1470,5 @@ void CSA_AccessLeaseCleanupAllMsg( CSA_CloseFileHandlesForASlave((CsaVolumeDoor_s *)msg->sys.door); return; } + + diff --git a/include/nwnss/include/csaLease.h b/src/nwnss/comn/common/csaLease.h similarity index 99% rename from include/nwnss/include/csaLease.h rename to src/nwnss/comn/common/csaLease.h index fbea093..99357d1 100644 --- a/include/nwnss/include/csaLease.h +++ b/src/nwnss/comn/common/csaLease.h @@ -105,7 +105,7 @@ typedef struct CSABeast_s * * Warning * To use a Beast Lease the user MUST have a latch on the - * CSABeast that the Beast Lease is part of (see + * CSABeast that the Beast Lease is part of (see * CSA_CSABEAST_X_LATCH and CSA_CSABEAST_S_LATCH). The user * must also get a "use count" via CSA_BeastLeaseUse for the * Beast Lease. @@ -113,7 +113,7 @@ typedef struct CSABeast_s * Warning * Some code assumes that there is only one Beast Lease per * CSABeast for a specific csaVolumeDoor. See CSA_BeastLeaseCleanup. - * + * * Notes - * We did not make this a mDoor_s because of the memory * overhead. At the time we create this item the mDoor was @@ -201,7 +201,7 @@ CSALeaseID_t CSA_BeastLeaseID( STATUS CSA_BeastLeaseToss( GeneralMsg_s *genMsg, CsaVolumeDoor_s *csaVolumeDoor, - Zid_t zid, + Zid_t zid, CSALeaseID_t beastLeaseID ); CSABeast_s *CSA_CSABeastConstruct( @@ -253,3 +253,4 @@ void CSA_BeastLeaseStatePurging ( RootBeast_s *rootBeast ); #endif #endif /* #ifdef _CSALEASE_H_ */ + diff --git a/src/nwnss/comn/common/csaManage.c b/src/nwnss/comn/common/csaManage.c new file mode 100644 index 0000000..761873b --- /dev/null +++ b/src/nwnss/comn/common/csaManage.c @@ -0,0 +1,484 @@ +/**************************************************************************** + | + | (C) Copyright 1995 - 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |------------------------------------------------------------------------- + | This module is used to: + | Handle all ZLSS virtual file (XML normally) requests. For example, + | the virtual files in _ADMIN:\Manage_NSS\SA\CSA code is in this file. + +-------------------------------------------------------------------------*/ +#include + +#include +#include +#include + +#include +#include +#include "nwreg.h" +#include "nssPubs.h" + +#include "comnPublics.h" +#include "xAdminVolume.h" +#include "parse.h" +#include "virtualIO.h" +#include "xCtype.h" +#include "xmlTags.h" +#include "mgmt.h" +#include "manage.h" +#include "csaManage.h" +#include "csa.h" + + +/* Pre-declaration of function(s) referenced prior to declaration */ +STATUS CSA_ssprintf( + NINT bufferLength, + BYTE **bufferAddress, + NINT *retLen, + const char *format, + ...); + + +/**************************************************************************** + * This function creates an entire transformation template for the + * management files that have read and write functions. + * + * The read routine name is required. + ****************************************************************************/ +STATUS CSA_MGMT_MakeReadFunctionVirtualFile( + Key_t key, + utf8_t *readRoutine, + utf8_t *readParm) +{ + NINT filePos = 0; + STATUS status; + + if ((status = VIRT_InitVirtualFile(key, &filePos)) != zOK) + { + goto errorExit; + } + + if ((status = VIRT_MakeReadWriteFuncDataStream(key, NULL, + readRoutine, readParm, NULL, NULL, FALSE, + &filePos)) != zOK) + { + goto errorExit; + } + + status = VIRT_FinishVirtualFile(key, &filePos); + +errorExit: + return status; +} + + + +STATUS CSA_IOCountTag( + NINT bufferLength, + BYTE **bufferAddress, + NINT *retLen, /* This indicates how much of buffer is + * already filled in. We must update + * as we fill things in. + */ + char *countName, + NINT count ) +{ + STATUS status; + + status = CSA_ssprintf(bufferLength, bufferAddress, retLen, + "\n", + countName, count ); + return( status ); +} + + +/* + * + * Notes - + * This is a ADMIN volume function API. + */ +STATUS CSA_VolOpStats2XML( + GeneralMsg_s *genMsg, + NINT parmLen, + utf8_t *parm, + NINT bufferLength, + BYTE **bufferAddress, + NINT *retLen, /* This idicates how much of buffer is + * already filled in. + */ + VirtInfo_s *virtInfo ) +{ + STATUS status; + + CSA_ssprintf(bufferLength, bufferAddress, retLen, "\n"); + + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("CsaBeastConstructed"), + CSAStats.CS_csaBeastConstructed); + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("CsaBeastDestructed"), + CSAStats.CS_csaBeastDestructed); + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("CsaBeastCurrent"), + CSAStats.CS_csaBeastCurrent); + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("CsaBeastConstructFailed"), + CSAStats.CS_csaBeastConstructFailed); + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("CsaBeastNotInUse"), + CSAStats.CS_csaBeastNotInUse); + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("CsaBeastReserved"), + CSAStats.CS_csaBeastReserved); + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("BeastLeaseConstructed"), + CSAStats.CS_beastLeaseConstructed); + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("BeastLeaseDestructed"), + CSAStats.CS_beastLeaseDestructed); + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("BeastLeaseCurrent"), + CSAStats.CS_beastLeaseCurrent); + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("BeastLeaseConstructFailed"), + CSAStats.CS_beastLeaseConstructFailed); + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("BeastLeaseToss"), + CSAStats.CS_beastLeaseToss); + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("BeastLeaseTossFailed"), + CSAStats.CS_beastLeaseTossFailed); + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("BeastLeaseCleanup"), + CSAStats.CS_beastLeaseCleanup); + CSA_IOCountTag(bufferLength, bufferAddress, retLen, + MSGNot("BeastLeaseCleanupMissing"), + CSAStats.CS_beastLeaseCleanupMissing); + + status = CSA_ssprintf(bufferLength, bufferAddress, retLen, "\n"); + + return status; +} /* End of ZLSS_PhysicalIO2XMLGlobal() */ + + +/* + * CSA_VolOpStats() - + * Returns ZLSS physical I/O information for the server. + * + * Notes - + * This is a ADMIN volume function API. + */ +/* VIRTUAL FILE -- READ FUNCTION */ +STATUS CSA_Stats( + NINT parmLen, + utf8_t *parm, + VirtInfo_s *virtInfo) +{ + STATUS status = zOK; + GeneralMsg_s genMsg; + NINT bufferLength; + BYTE **buffer; + NINT *retLen; + + MPKNSS_LOCK(); + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (CYAN, "In CSA_VolOpStats\n")); + + /* We always fill our data at the beginning of the buffer */ + virtInfo->resultEOF = 0; + /* Resize the output buffer to ensure that we have enough + * space for all the Physical IO stats. + */ + status = VIRT_CheckResultSize( virtInfo, 16*1024 ); + if ( status != zOK ) + { + goto errorExit; + } + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + CSA_XML_Head( virtInfo, &genMsg ); + + bufferLength = virtInfo->resultBufferSize; + buffer = &virtInfo->resultBuffer; + retLen = &virtInfo->resultEOF; + + status = CSA_VolOpStats2XML( &genMsg, parmLen, parm, + bufferLength, buffer, retLen, virtInfo ); + + CSA_ErrNoAndErrNoSetterSet( virtInfo, &genMsg ); + status = CSA_XML_Tail( virtInfo, &genMsg ); + +errorExit: + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (CYAN, "Exit CSA_VolOpStats\n")); + MPKNSS_UNLOCK(); + return status; + +} /* End of CSA_VolOpStats() */ + + + +STATUS CSA_XML_Head( + VirtInfo_s *virtInfo, + GeneralMsg_s *genMsg ) + +{ + STATUS status; + + status = VIRT_AddResultTag( virtInfo, TAG_NSSREPLY, FALSE, TRUE ); + return status; + +} + +STATUS CSA_XML_Tail( + VirtInfo_s *virtInfo, + GeneralMsg_s *genMsg ) + +{ + STATUS status; + + status = VIRT_AddResultTag( virtInfo, TAG_NSSREPLY, TRUE, TRUE ); + return status; + +} + + +STATUS CSA_ssprintf( + NINT bufferLength, + BYTE **bufferAddress, + NINT *retLen, + const char *format, + ...) +{ + va_list args; + int added; /* Does not include the NULL */ + + va_start( args, format ); + added = LB_vsnprintf( *bufferAddress + *retLen, + bufferLength - *retLen, format, args ); + if ( added < 0 ) + { /* Encoding error in format string */ + return( zERR_BAD_PARAMETER_VALUE ); + } + if ( added >= (bufferLength - *retLen) ) + { /* Could do a re-alloc here and then error on out of memory */ + *retLen = bufferLength; /* Say we are using whole buffer so + * that next call to us returns no + * space left. This way callers can call + * us many times in a row and only need + * to check for an error after the last + * call. + */ + return( zERR_BUFFER_TOO_SMALL ); + } + *retLen += added; + return( zOK ); + +} /* End of CSA_ssprintf() */ + + + +typedef struct CSA_VirtualFileCommands_s +{ + BYTE *XVFC_Path; + NINT XVFC_CreateAttr; + BYTE *XVFC_CommandFunctionName; + BYTE *XVFC_CommandParamters; +} CSA_VirtualFileCommands_s; + +CSA_VirtualFileCommands_s CSA_VitrualFileCommands[] = +{ + {"Manage_NSS\\LSS\\CSA", zFA_SUBDIRECTORY, NULL, NULL }, + {"Manage_NSS\\LSS\\CSA\\CSAStats.XML", zFA_VOLATILE, "CSA_Stats", NULL } +}; + + +STATUS CSA_VFCCreate( GeneralMsg_s *genMsg ) + +{ + NINT i; + NINT createAttr; + STATUS status; + Key_t rootKey; + Key_t retKey; + + typedef struct Stack_s { + BYTE pathStr[zMAX_FULL_NAME]; + } Stack_s; + STACK_ALLOC(); + + /* setup the root key for file operations */ + ZOS_zRootKey(status, 0, &rootKey); + if (status != zOK) + { + zASSERT("Error getting root key" == 0); + SetErrno(genMsg, status); + goto noRoot; + } + + for ( i = 0; i < NELEMS(CSA_VitrualFileCommands); ++i ) + { + strcpy(aStack->pathStr, AdminVolAsciiName); + strcat(aStack->pathStr, ":\\"); + strcat(aStack->pathStr, CSA_VitrualFileCommands[i].XVFC_Path); + createAttr = CSA_VitrualFileCommands[i].XVFC_CreateAttr | + zFA_DELETE_INHIBIT | zFA_RENAME_INHIBIT | zFA_COPY_INHIBIT; + ZOS_zCreate(status, rootKey, zNO_TASK, 0, + zNSPACE_LONG | zMODE_UTF8, aStack->pathStr, zFILE_REGULAR, + createAttr, zCREATE_OPEN_IF_THERE, zRR_WRITE_ACCESS, &retKey); + if (status != zOK) + { + zASSERT("Error during create" == NULL); + continue; + } + + if ( !(CSA_VitrualFileCommands[i].XVFC_CreateAttr & zFA_SUBDIRECTORY) ) + { + status = CSA_MGMT_MakeReadFunctionVirtualFile( retKey, + CSA_VitrualFileCommands[i].XVFC_CommandFunctionName, + CSA_VitrualFileCommands[i].XVFC_CommandParamters ); + if ( status != zOK) + { + ZOS_zClose( status, retKey ); + continue; + } + } + ZOS_zClose(status, retKey); + zASSERT(status == zOK); + + } + ZOS_zClose(status, rootKey); +noRoot: + STACK_FREE(); + return zOK; + +} /* End of CSA_VFCCreate() */ + + + +void CSA_VFCDelete( void ) +{ + SNINT i; + STATUS status; + Key_t rootKey; + + typedef struct Stack_s { + BYTE pathStr[zMAX_FULL_NAME]; + } Stack_s; + STACK_ALLOC(); + + /* setup the root key for file operations */ + ZOS_zRootKey(status, 0, &rootKey); + if (status != zOK) + { + zASSERT("Error getting root key" == 0); + goto noRoot; + } + for ( i = NELEMS(CSA_VitrualFileCommands)-1; i >= 0; --i ) + { + strcpy(aStack->pathStr, AdminVolAsciiName); + strcat(aStack->pathStr, ":\\"); + strcat(aStack->pathStr, CSA_VitrualFileCommands[i].XVFC_Path); + ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, aStack->pathStr, + zMATCH_ALL, zDELETE_FORCE_DELETE); + zASSERT(status == zOK); + if ( status != zOK ) + { + status = zOK; + } + } + ZOS_zClose(status, rootKey); +noRoot: + STACK_FREE(); + return; + +} /* End of CSA_VFCDelete() */ + + +#define ATR_VALUESETTER "source" + + +/**************************************************************************** + * This function takes the input error, adds the XML for error messages and + * puts it in the supplied buffer. It also sets the 'source' attribute. + ****************************************************************************/ +void CSA_MGMT_BuildResultNSSWithSetter( + STATUS result, + utf8_t *resultSetter, + utf8_t *buffer) +{ + sprintf(buffer, MSGNot("<"TAG_RESULT + " "ATR_VALUE"=\"%d\"" + " "ATR_VALUESETTER"=\"%s\"" + ">" + "<"TAG_DESCRIPTION">%s" + "\n"), + result, + resultSetter, + GetErrorFromNumber(result) ); +} + +/**************************************************************************** + * This function takes the input error, adds the XML for error messages and + * puts it in the result buffer. It also sets the 'source' attribute. + ****************************************************************************/ +STATUS CSA_MGMT_ReturnResultNSSWithSetter( + VirtInfo_s *virtInfo, + STATUS result, + utf8_t *resultSetter ) +{ + STATUS status; + typedef struct Stack_s { + utf8_t tempBuf[512]; + } Stack_s; + STACK_ALLOC(); + + CSA_MGMT_BuildResultNSSWithSetter(result, resultSetter, aStack->tempBuf); + status = VIRT_AddResultData(virtInfo, aStack->tempBuf); + + STACK_FREE(); + return status; +} + +/* CSA_ErrNoAndErrNoSetterSet() - + * Set a errno and errnoSetter into the buffer supplied. The + * errno is stored as a QUAD. This routine is used to set zERR_ into + * a read buffer so that a client can retrieve the zERR_. + * + */ + +STATUS CSA_ErrNoAndErrNoSetterSet( + VirtInfo_s *virtInfo, + GeneralMsg_s *genMsg ) + +{ + CSA_MGMT_ReturnResultNSSWithSetter( virtInfo, GetErrno( genMsg ), GetErrnoSetter( genMsg ) ); + return zOK; + +} /* End of CSA_ErrNoAndErrNoSetterSet() */ diff --git a/src/nwnss/comn/common/csaManage.h b/src/nwnss/comn/common/csaManage.h new file mode 100644 index 0000000..c8ea29b --- /dev/null +++ b/src/nwnss/comn/common/csaManage.h @@ -0,0 +1,58 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) Initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Structures, defines and proto-types used by CSA manage code. + +-------------------------------------------------------------------------*/ +#ifndef _CSAMANAGE_H_ +#define _CSAMANAGE_H_ + + +STATUS CSA_ErrNoAndErrNoSetterSet( + VirtInfo_s *virtInfo, + GeneralMsg_s *genMsg ); + +STATUS CSA_XML_Head( + VirtInfo_s *virtInfo, + GeneralMsg_s *genMsg ); + +STATUS CSA_XML_Tail( + VirtInfo_s *virtInfo, + GeneralMsg_s *genMsg ); + +STATUS CSA_VFCCreate( + GeneralMsg_s *genMsg ); + +void CSA_VFCDelete( void ); + +#endif /* _CSAMANAGE_H_ */ diff --git a/src/nwnss/comn/common/dirQuotas.c b/src/nwnss/comn/common/dirQuotas.c index eac77e5..ac39410 100644 --- a/src/nwnss/comn/common/dirQuotas.c +++ b/src/nwnss/comn/common/dirQuotas.c @@ -34,6 +34,7 @@ | This module has the routines used in the common layer to handle | directory quotas. +-------------------------------------------------------------------------*/ +#include #include #include @@ -178,7 +179,7 @@ void DIRQ_DisplayCache(void) DQhead_t *hashp; NINT i; DirQuotaCacheNode_s *node; - + DBG_DebugPrintf(LGRAY,MSGNot("-------- Directory Quota Cache Contents --------\n")); ASSERT_LATCH(&DirQuotaCache.latch); if (DirQuotaCache.hash != NULL) @@ -264,7 +265,7 @@ void DIRQ_CacheUninit(void) DQhead_t *hp; NINT i; DirQuotaCacheNode_s *item; - + if (DirQuotaCache.numHashEntries == 0) { return; @@ -316,7 +317,7 @@ NINT DIRQ_ComputeHash( NINT c = ~0; NINT n; BYTE *buf; - + buf = (BYTE *)&volume; for (n = 0; n < 8; n++) { @@ -327,8 +328,8 @@ NINT DIRQ_ComputeHash( { c = DIRQ_CRCtable[(c ^ buf[n]) & 0xff] ^ (c >> 8); } - return c % DirQuotaCache.numHashEntries; -} + return c % DirQuotaCache.numHashEntries; +} /**************************************************************************** @@ -353,8 +354,8 @@ STATIC DirQuotaCacheNode_s *DIRQ_CheckCache( if (dir == cacheNode->dir && volume->VOLzid == cacheNode->volume) { /* these are the same entry */ - DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (LGREEN, - MSGNot("dirq cache hit: dir=%Ld vol=%Ld\n"), dir, + DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (LGREEN, + MSGNot("dirq cache hit: dir=%Ld vol=%Ld\n"), dir, volume->VOLzid)); DQ_RMV(cacheNode, LRUlink); DQ_ENQ(&DirQuotaCache.LRUqueue, cacheNode, LRUlink); @@ -362,8 +363,8 @@ STATIC DirQuotaCacheNode_s *DIRQ_CheckCache( return cacheNode; } } - DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (GREEN, - MSGNot("dirq cache miss: dir=%Ld vol=%Ld\n"), dir, + DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (GREEN, + MSGNot("dirq cache miss: dir=%Ld vol=%Ld\n"), dir, volume->VOLzid)); return NULL; } @@ -386,7 +387,7 @@ DirQuotaCacheNode_s *DIRQ_AddDirToCache( BOOL allocedEntry = FALSE; ASSERT_XLATCH(&DirQuotaCache.latch); - + #if NSS_DEBUG IS_ENABLED DirQuotaCache.gets--; if (DIRQ_CheckCache(volume, dirZid) != NULL) @@ -410,11 +411,11 @@ DirQuotaCacheNode_s *DIRQ_AddDirToCache( } else { - DQ_ENQ(&DirQuotaCache.LRUqueue, cacheNode, LRUlink); + DQ_ENQ(&DirQuotaCache.LRUqueue, cacheNode, LRUlink); PERIODIC_YIELD(); } } - + if (DirQuotaCache.numUnusedEntries > 0) { /* use a packet from the unused list */ @@ -493,8 +494,8 @@ errorExit: */ if ((cacheNode = DIRQ_CheckCache(volume, originalZid)) != NULL) { /* found in cache -- return finding */ -DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (YELLOW, -MSGNot("DIRQ_FindCacheEntry: found in cache. vol=%Ld zid=%Ld\n"), +DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (YELLOW, +MSGNot("DIRQ_FindCacheEntry: found in cache. vol=%Ld zid=%Ld\n"), volume->VOLzid, originalZid)); STACK_FREE(); return cacheNode; @@ -505,13 +506,13 @@ volume->VOLzid, originalZid)); * has a quota. When it is found (or if none are found) then make * a cache entry and return the result. */ - + /* * Get the quota info of the original entry so it will be available to * add to the cache. */ if (volume->VOLcomnVolOps.VOL_getDirQuotaInfo( - &genMsg, volume, originalZid, &originalQuota, &originalUsedAmount) + &genMsg, volume, originalZid, &originalQuota, &originalUsedAmount) != zOK) { if (GetErrno(&genMsg) != zERR_NO_SUCH_DIR) @@ -534,10 +535,10 @@ volume->VOLzid, originalZid)); zid = originalZid; do { -DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (YELLOW, -MSGNot("DIRQ_FindCacheEntry: doing a comnlookup. vol=%Ld zid=%Ld\n"), +DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (YELLOW, +MSGNot("DIRQ_FindCacheEntry: doing a comnlookup. vol=%Ld zid=%Ld\n"), volume->VOLzid, zid)); - if ((directory = COMN_LookupByZid(&genMsg, volume, zid, NOTLATCHED, + if ((directory = COMN_LookupByZid(&genMsg, volume, zid, NOTLATCHED, FALSE)) == NULL) { /* beast might be deleted */ @@ -600,23 +601,23 @@ volume->VOLzid, zid)); /* * Add the entries to the cache. */ -DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (YELLOW, +DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (YELLOW, MSGNot("DIRQ_FindCacheEntry: adding to cache. Num entries = %d\n"), stackPtr+1)); - + for (stackPtr--; stackPtr >= 0; stackPtr--) { - DIRQ_AddDirToCache(volume, aStack->dirStack[stackPtr].zid, zid, + DIRQ_AddDirToCache(volume, aStack->dirStack[stackPtr].zid, zid, zDIR_NO_QUOTA, 0, levelCount - aStack->dirStack[stackPtr].level); } STACK_FREE(); - return DIRQ_AddDirToCache(volume, originalZid, zid, originalQuota, + return DIRQ_AddDirToCache(volume, originalZid, zid, originalQuota, originalUsedAmount, levelCount); errorExit: STACK_FREE(); return NULL; -} +} /**************************************************************************** * Remove a directory from the cache. @@ -631,7 +632,7 @@ STATUS DIRQ_RemoveEntryFromCache( X_LATCH(&DirQuotaCache.latch); DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (YELLOW, MSGNot("Removed a dir quota cache entry: vol=%Ld dir=%ld\n"), volume->VOLzid, dir)); - + if ((cacheNode = DIRQ_CheckCache(volume, dir)) != NULL) { /* found the cache entry */ DQ_RMV(cacheNode, LRUlink); @@ -663,7 +664,7 @@ STATUS DIRQ_LatchDirInCache( DirQuotaCacheNode_s *cacheNode; X_LATCH(&DirQuotaCache.latch); - + if ((cacheNode = DIRQ_FindCacheEntry(volume, dirZid)) == NULL) { /* did not find the cache entry */ zASSERT("Error getting cache entry in DIRQ_LatchDirInCache" == 0); @@ -693,7 +694,7 @@ void DIRQ_UnlatchDirInCache( DirQuotaCacheNode_s *cacheNode; X_LATCH(&DirQuotaCache.latch); - + if ((cacheNode = DIRQ_CheckCache(volume, dirZid)) == NULL) { /* did not find the cache entry */ // zASSERT("Unable to find dir cache entry to unlatch it" == 0); @@ -867,7 +868,7 @@ void DIRQ_ComputeUsedAmount( // zASSERT(LATCH_FREE(&DirQuotaCache.latch)); zASSERT(!(dirZid & SNAPSHOT_ZID_FLAG)); -// ***** removed because we need to compute used amount for classic NetWare +// ***** removed because we need to compute used amount for classic NetWare // ***** behavior when quotas are off. // /* // * If directory quotas are not on then return. @@ -888,7 +889,7 @@ void DIRQ_ComputeUsedAmount( return; } - /* + /* * Ignore file types that should not be used to start the file tree we are * computing used space for. */ @@ -951,12 +952,12 @@ void DIRQ_ComputeUsedAmount( COMN_INIT_NAMING_MSG(&aStack->nameMsg); /* - * Lock the volume in an ACTIVE state so it can't be + * Lock the volume in an ACTIVE state so it can't be * deactivated while we are actively purging this sub-tree. Note - This * lock is separate from the one put in on behalf of the nameMsg. That * extra lock is put in place because the CleanupNameMsg call unlocks it * too. This extra lock is needed in case the nameMsg is ever reset - * in the middle by any of the wildcard code. + * in the middle by any of the wildcard code. */ if (COMN_LockVolumeActive(&genMsg, volume, !volumeIsActive) != zOK) { @@ -972,9 +973,9 @@ void DIRQ_ComputeUsedAmount( goto cleanupUnlock; } - /* + /* * This extra lock is for the nameMsg cleanup code so our count won't - * get out of sync. + * get out of sync. */ if (COMN_LockVolumeActive(&genMsg, volume, !volumeIsActive) != zOK) { @@ -985,8 +986,8 @@ void DIRQ_ComputeUsedAmount( } COMN_USE_BEAST(&beast->FILEvolume->VOLroot) - COMN_SETUP_NAMING_MSG_FILE_BEAST_PTR(&aStack->nameMsg, volume, - beast->FILEfirstParentZid, /* cnt zFNU_FIRST_PARENT,*/ beast, + COMN_SETUP_NAMING_MSG_FILE_BEAST_PTR(&aStack->nameMsg, volume, + beast->FILEfirstParentZid, /* cnt zFNU_FIRST_PARENT,*/ beast, NAMPMODE_FullyResolveAny, XLATCHED, nameSpace, zNTYPE_FILE, NULL); COMN_USE_BEAST(&beast->FILEroot); // COMN_LATCH_AND_USE_NAMEMSG_BEASTS(&aStack->nameMsg, aStack->nameMsg.latchType); @@ -994,7 +995,7 @@ void DIRQ_ComputeUsedAmount( /* Setup the search message */ COMN_STRUCT_INIT(searchMsg); COMN_SETUP_SEARCH_MSG (&searchMsg, -1, - SMAPOPT_32BitMode | SMAPOPT_searchAllDirs | SMAPOPT_matchAllEntries | + SMAPOPT_32BitMode | SMAPOPT_searchAllDirs | SMAPOPT_matchAllEntries | SMAPOPT_notReusable, zNTYPE_FILE); if (COMN_WildOpen(&genMsg, &aStack->nameMsg, &searchMsg) != zOK) @@ -1030,7 +1031,7 @@ DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (MAGENTA, "Starting wild reads\n")); COMN_Lookup(&genMsg, &aStack->nameMsg); } - if (COMN_GetStorageInfo(&genMsg, aStack->nameMsg.curFile, + if (COMN_GetStorageInfo(&genMsg, aStack->nameMsg.curFile, &storageInfo) != zOK) { zASSERT("Error getting storage info." == 0); @@ -1059,7 +1060,7 @@ DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (MAGENTA, "Starting wild reads\n")); *amountUsed += storageInfo.filePhysSize + usedDataStreamSize + usedEASize; -DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (CYAN, "(%Ld) Used amount incremented by %Ld to %Ld\n", +DEBUG_PRINTF(TDIRQCACHE, DBG_NOINDENT, (CYAN, "(%Ld) Used amount incremented by %Ld to %Ld\n", aStack->nameMsg.curFile->FILEzid, storageInfo.filePhysSize, *amountUsed)); } } @@ -1079,7 +1080,7 @@ errorClose: COMN_WildClose(&genMsg, &searchMsg); cleanupName: if (!volumeIsActive) - { /* + { /* * If the volume is not active then make sure we do not try and unlock * it when we cleanup the name message. */ @@ -1094,14 +1095,14 @@ cleanup: { zASSERT("Problem computing dir quota used amount" == 0); errPrintf(WHERE, Module, 694, - MSG("Unable to compute used amount in dir quota, status=%d.\n", + MSG("Unable to compute used amount in dir quota, status=%d.\n", 1125), GetErrno(&genMsg)); *amountUsed = 0; } STACK_FREE(); return; -} +} /**************************************************************************** * @@ -1133,15 +1134,15 @@ void DIRQ_ComputeUsedAmountThread( { // zASSERT("Problem latching directory quota cache" == 0); // errPrintf(WHERE, Module, 695, -// MSG("Unable to latch directory quota cache. Used amount not computed. error=%d\n", +// MSG("Unable to latch directory quota cache. Used amount not computed. error=%d\n", // 1126), GetErrno(&genMsg)); xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); - vol->VOLcomnVolOps.VOL_removePurgeLogEntry(&genMsg, vol, + vol->VOLcomnVolOps.VOL_removePurgeLogEntry(&genMsg, vol, PLOG_DIR_QUOTA_USED, &fsm->purgeLogInfo.purgeLogMsg, xaction); vol->VOLcomnVolOps.VOL_endXLocal(xaction); goto exit; } - + DIRQ_ComputeUsedAmount(vol, dirZid, &amountUsed, TRUE); /* * Check to see if someone is wanting to deactivate the volume. @@ -1156,12 +1157,12 @@ void DIRQ_ComputeUsedAmountThread( { /* If the amount is good then make any needed adjustment */ - if (vol->VOLcomnVolOps.VOL_getDirQuotaInfo(&genMsg, vol, dirZid, "a, + if (vol->VOLcomnVolOps.VOL_getDirQuotaInfo(&genMsg, vol, dirZid, "a, &usedAmount) != zOK) { zASSERT("Problem getting dir quota used amount" == 0); errPrintf(WHERE, Module, 696, - MSG("Unable to get used amount in dir quota, status=%d.\n", + MSG("Unable to get used amount in dir quota, status=%d.\n", 1127), GetErrno(&genMsg)); usedAmount = 0; } @@ -1169,14 +1170,14 @@ void DIRQ_ComputeUsedAmountThread( amountUsed -= usedAmount; xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); - vol->VOLcomnVolOps.VOL_adjustUsedDirSpace(xaction, vol, dirZid, + vol->VOLcomnVolOps.VOL_adjustUsedDirSpace(xaction, vol, dirZid, amountUsed); } else { xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); } - vol->VOLcomnVolOps.VOL_removePurgeLogEntry(&genMsg, vol, + vol->VOLcomnVolOps.VOL_removePurgeLogEntry(&genMsg, vol, PLOG_DIR_QUOTA_USED, &fsm->purgeLogInfo.purgeLogMsg, xaction); vol->VOLcomnVolOps.VOL_endXLocal(xaction); @@ -1193,7 +1194,7 @@ exit: if (COMN_LockVolumeActive(&genMsg, newVol, FALSE) == zOK) { NumDirQuotasScheduled++; - WORK_Schedule((FsmLite_s *)newEntry, (voidfunc_t)DIRQ_ComputeUsedAmountThread, (ADDR)NULL); + WORK_Schedule((FsmLite_s *)newEntry, DIRQ_ComputeUsedAmountThread, NULL); } else { @@ -1283,7 +1284,7 @@ STATUS DIRQ_GetDirectoryQuotas( X_LATCH(&DirQuotaCache.latch); for (*numEntriesUsed = 0, level = 0; - *numEntriesUsed < numEntries && dirZid != zINVALID_ZID; + *numEntriesUsed < numEntries && dirZid != zINVALID_ZID; (*numEntriesUsed)++) { /* * Go until we have filled the return buffer or until there are no more @@ -1301,7 +1302,7 @@ STATUS DIRQ_GetDirectoryQuotas( * compute usage for the level zero entry even if there are no * quotas. */ - if (cacheNode->quota == zDIR_NO_QUOTA && level == 0 && + if (cacheNode->quota == zDIR_NO_QUOTA && level == 0 && doClassicEmulation) { UNX_LATCH(&DirQuotaCache.latch); @@ -1359,14 +1360,14 @@ STATUS DIRQ_GetDirectoryQuotas( STATUS DBG_GetFileNameFromZid( GeneralMsg_s *genMsg, Volume_s *volume, - Zid_t zid, + Zid_t zid, unicode_t *name) { NINT releaseFile = FALSE; File_s *file; File_s *childFile = NULL; // cnt NINT nameUniquifier; - NINT unicodeLen; + NINT unicodeLen; NINT seperatorLen; /* in unicode */ unicode_t *seperator; unicode_t *insertPtr = name + (zMAX_FULL_NAME - 1); @@ -1383,8 +1384,8 @@ STATUS DBG_GetFileNameFromZid( { goto errorExit; } - - if (nameSpace->nSpaceOps->getSeparator(genMsg, + + if (nameSpace->nSpaceOps->getSeparator(genMsg, PATH_SEPARATOR, &seperator, &seperatorLen) != zOK) { goto errorExit; @@ -1426,7 +1427,7 @@ STATUS DBG_GetFileNameFromZid( releaseFile = FALSE; } unicpy(name, insertPtr); - + return zOK; errorExit: @@ -1480,23 +1481,23 @@ void DBG_LogDirectoryQuota( if (zRootKey(0, &rootKey) != zOK) { aprintf(LRED, "(DirQuotas) Error opening root key for debug\n"); - goto lock; + goto lock; } /* Open the file */ if (zCreate(rootKey, zNO_TASK, zNILXID, - zNSPACE_LONG | zMODE_UTF8, "sys:\\dirquota.log", + zNSPACE_LONG | zMODE_UTF8, "sys:\\dirquota.log", zFILE_REGULAR, 0, zCREATE_OPEN_IF_THERE, zRR_WRITE_ACCESS, &fileKey) != zOK) { aprintf(LRED, "(DirQuotas) Error opening debug file\n"); goto lock; } - if (zGetInfo(fileKey, zGET_STD_INFO, sizeof(aStack->info), zINFO_VERSION_A, &aStack->info) + if (zGetInfo(fileKey, zGET_STD_INFO, sizeof(aStack->info), zINFO_VERSION_A, &aStack->info) != zOK) { aprintf(LRED, "(DirQuotas) Error debug file info\n"); - goto close; + goto close; } eof = aStack->info.std.logicalEOF; @@ -1512,19 +1513,19 @@ void DBG_LogDirectoryQuota( fileName = &volName[zMAX_FULL_NAME]; out = (char *)&volName[zMAX_FULL_NAME * 2]; - if (COMN_GetVolumeName(genMsg, beast->FILEvolume, volName, + if (COMN_GetVolumeName(genMsg, beast->FILEvolume, volName, zMAX_FULL_NAME) != zOK) { aprintf(LRED, "(DirQuotas) Unable to get volume name\n"); MPKNSS_UNLOCK(); - goto free; + goto free; } if (DBG_GetFileNameFromZid(genMsg, beast->FILEvolume, beast->FILEzid, fileName) != zOK) { aprintf(LRED, "(DirQuotas) Unable to get file name\n"); MPKNSS_UNLOCK(); - goto free; + goto free; } time = GetUTCTime(); @@ -1536,7 +1537,7 @@ void DBG_LogDirectoryQuota( if (zWrite(fileKey, zNILXID, eof, strlen(out), out, &numWritten) != zOK) { aprintf(LRED, "(DirQuotas) Unable to get file name\n"); - goto free; + goto free; } // aprintf(LGREEN, out); @@ -1629,7 +1630,7 @@ STATUS DIRQ_SetDirectoryQuota( * with no content will be recomputed each time the quota changes. */ /* We also need to recompute if the oldQuota was zDIR_NO_QUOTA */ -#if 0 +#if 0 if (volume->VOLcomnVolOps.VOL_getDirQuotaInfo(genMsg, volume, beast->FILEzid, &retQuota, &retUsedAmount) != zOK) { @@ -1660,7 +1661,7 @@ STATUS DIRQ_SetDirectoryQuota( } /* Add purge log entry */ - SETUP_DIR_TREE_USED_LOG(&fsm->purgeLogInfo.purgeLogMsg, + SETUP_DIR_TREE_USED_LOG(&fsm->purgeLogInfo.purgeLogMsg, (void *)&fsm->purgeLogInfo.purgeLogLoc, volume, beast->FILEzid); status = volume->VOLcomnVolOps.VOL_addPurgeLogEntry(genMsg, volume, PLOG_DIR_QUOTA_USED, &fsm->purgeLogInfo.purgeLogMsg, xaction); @@ -1678,7 +1679,7 @@ STATUS DIRQ_SetDirectoryQuota( fsm->purgeLogInfo.purgeLogMsg.dirUsed.volume = volume; fsm->purgeLogInfo.purgeLogMsg.dirUsed.dirZid = beast->FILEzid; - /* + /* * If there are too many quota computations being done then queue this * for later. */ @@ -1692,7 +1693,7 @@ STATUS DIRQ_SetDirectoryQuota( { NumDirQuotasScheduled++; //DBG_DebugPrintf(YELLOW, "DIRQ -- Inc dir quotas scheduled: %d\n", NumDirQuotasScheduled); - WORK_Schedule((FsmLite_s *)fsm, (voidfunc_t)DIRQ_ComputeUsedAmountThread, (ADDR)NULL); + WORK_Schedule((FsmLite_s *)fsm, DIRQ_ComputeUsedAmountThread, NULL); status = zOK; } } @@ -1800,12 +1801,12 @@ STATUS DIRQ_CheckDirQuotas( X_LATCH(&DirQuotaCache.latch); zid = beast->zid; - /* + /* * Check all directories with assigned quotas above this one */ do { - if ((cacheNode = DIRQ_FindCacheEntry(volume, zid)) + if ((cacheNode = DIRQ_FindCacheEntry(volume, zid)) == NULL) { zASSERT("Error finding parent while checking directory used space" == 0); @@ -1874,12 +1875,12 @@ STATUS DIRQ_MinDirQuota ( X_LATCH(&DirQuotaCache.latch); zid = beast->zid; - /* + /* * Check all directories with assigned quotas above this one */ do { - if ((cacheNode = DIRQ_FindCacheEntry(volume, zid)) + if ((cacheNode = DIRQ_FindCacheEntry(volume, zid)) == NULL) { zASSERT("Error finding parent while computing directory used space" == 0); @@ -1924,7 +1925,7 @@ SQUAD DIRQ_GetADirectoryQuota( { return zDIR_NO_QUOTA; } - + X_LATCH(&DirQuotaCache.latch); if ((cacheNode = DIRQ_FindCacheEntry(volume, zid)) == NULL) { @@ -1934,7 +1935,7 @@ SQUAD DIRQ_GetADirectoryQuota( UNX_LATCH(&DirQuotaCache.latch); return cacheNode->quota; -} +} /**************************************************************************** * Check to see if there any directory quotas above this location. @@ -1949,7 +1950,7 @@ BOOL DIRQ_ThereAreDirQuotas( { return FALSE; } - + /* * If this is a snapshot copy of a beast we do not want to account for * its space. @@ -1974,7 +1975,7 @@ BOOL DIRQ_ThereAreDirQuotas( } UNX_LATCH(&DirQuotaCache.latch); return TRUE; -} +} /**************************************************************************** * Adjust the amount of used space for all quota parents of a directory. @@ -2018,7 +2019,7 @@ void DIRQ_AdjustUsedDirSpace( COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); zASSERT((child->beastClass->classID == zFTYPE_COMPRESSION) || - (!(child->ROOTvolume->VOLcompAttributes.compFlags & + (!(child->ROOTvolume->VOLcompAttributes.compFlags & VOL_COMP_FLAGS_UPGRADE_FINISHED) && (child->beastClass->classID == zFTYPE_ROOT_BEAST))); uncompInfo = (UncompressInfo_s *) @@ -2026,13 +2027,13 @@ void DIRQ_AdjustUsedDirSpace( /* * If uncompBeastDeleted is true then the blocks for this compressed * beast have already been counted when the uncompressed beast was - * deleted - */ + * deleted + */ if (uncompInfo->uncompBeastDeleted) { return; } - tmpBeast = COMN_LookupByZid(&genMsg, volume, + tmpBeast = COMN_LookupByZid(&genMsg, volume, uncompInfo->uncompBeastZid, NOTLATCHED, TRUE); zASSERT(tmpBeast); @@ -2049,7 +2050,7 @@ void DIRQ_AdjustUsedDirSpace( if (tmpBeast) { - if ((((NamedBeast_s *)tmpBeast)->NAMEDnumParents == 0) || + if ((((NamedBeast_s *)tmpBeast)->NAMEDnumParents == 0) || NAME_AllNamesInSalvage(tmpBeast)) { if (releaseBeast) @@ -2081,12 +2082,12 @@ void DIRQ_AdjustUsedDirSpace( X_LATCH(&DirQuotaCache.latch); - /* + /* * Adjust all directories with assigned quotas above this one */ do { - if ((cacheNode = DIRQ_FindCacheEntry(volume, zid)) + if ((cacheNode = DIRQ_FindCacheEntry(volume, zid)) == NULL) { zASSERT("Error finding parent while adjusting directory used space" == 0); @@ -2101,7 +2102,7 @@ void DIRQ_AdjustUsedDirSpace( cacheNode->usedAmount += amountToAdjust; /* Adjust value in storage */ - volume->VOLcomnVolOps.VOL_adjustUsedDirSpace(xaction, volume, + volume->VOLcomnVolOps.VOL_adjustUsedDirSpace(xaction, volume, zid, amountToAdjust); } zid = cacheNode->parentQuota; @@ -2134,14 +2135,14 @@ void DIRQ_FixDirectoryQuotas( volume = COMN_VolumeNameLookup(genMsg, volName, FALSE, NULL); if (volume == NULL) { - aprintf(LRED, MSG("Unable to find volume %U to fix directory quotas\n", 584), + aprintf(LRED, MSG("Unable to find volume %U to fix directory quotas\n", 584), volName); goto exit; } if (!(volume->VOLenabledAttributes & zATTR_DIR_QUOTAS)) { - aprintf(YELLOW, MSG("Directory quotas not enabled on volume %U\n", 585), + aprintf(YELLOW, MSG("Directory quotas not enabled on volume %U\n", 585), volName); goto exitRelease; } @@ -2158,7 +2159,7 @@ void DIRQ_FixDirectoryQuotas( for (;;) { if (volume->VOLcomnVolOps.VOL_browseDirsInVolume(genMsg, volume, - MAX_DIR_INFO_ENTRIES, &lastDirReturned, aStack->dirInfo, + MAX_DIR_INFO_ENTRIES, &lastDirReturned, aStack->dirInfo, &numReturned) != zOK) { zASSERT(GetErrno(genMsg) == zERR_DIR_QUOTAS_NOT_ENABLED); @@ -2173,21 +2174,21 @@ void DIRQ_FixDirectoryQuotas( for (i = 0; i < numReturned; i++) { /* Fixup the used amount for an entry */ - if ((beast = COMN_LookupByZid(genMsg, volume, aStack->dirInfo[i].dirZid, + if ((beast = COMN_LookupByZid(genMsg, volume, aStack->dirInfo[i].dirZid, XLATCHED, TRUE)) == NULL) { continue; } if (COMN_IsDerivedFrom(beast, zFTYPE_FILE)) { - if (DIRQ_RemoveDirectoryQuota(genMsg, volume, (File_s *)beast) + if (DIRQ_RemoveDirectoryQuota(genMsg, volume, (File_s *)beast) != zOK) { zASSERT("Unable to remove a directory quota" == NULL); } else { - if (DIRQ_SetDirectoryQuota(genMsg, volume, (File_s *)beast, + if (DIRQ_SetDirectoryQuota(genMsg, volume, (File_s *)beast, aStack->dirInfo[i].quota) != zOK) { zASSERT("Unable to set a directory quota" == NULL); @@ -2197,7 +2198,7 @@ void DIRQ_FixDirectoryQuotas( COMN_UnlatchAndRelease(&beast, XLATCHED); } } - aprintf(YELLOW, MSG("Recomputation started for all directory quotas on volume %U\n", 588), + aprintf(YELLOW, MSG("Recomputation started for all directory quotas on volume %U\n", 588), volName); exitUnlock: @@ -2207,10 +2208,10 @@ exitRelease: exit: STACK_FREE(); return; -} +} /**************************************************************************** - * + * ****************************************************************************/ void DIRQ_DisableDirectoryQuotas( Volume_s *vol) @@ -2231,7 +2232,7 @@ void DIRQ_DisableDirectoryQuotas( return; } - SETUP_REMOVE_DIR_TREE_LOG(&purgeLogInfo->purgeLogMsg, + SETUP_REMOVE_DIR_TREE_LOG(&purgeLogInfo->purgeLogMsg, (void *)&purgeLogInfo->purgeLogLoc, vol); xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); status = vol->VOLcomnVolOps.VOL_addPurgeLogEntry(&genMsg, vol, @@ -2253,7 +2254,7 @@ void DIRQ_DisableDirectoryQuotas( GetErrno(&genMsg)); if (GetErrno(&genMsg) == zERR_VOLUME_STATE_CHANGE_REQUESTED) { - /* If volume is being deactivated, do not remove it from the + /* If volume is being deactivated, do not remove it from the * purge Log, so that the cleanup can continue when we come * back up. */ @@ -2263,7 +2264,7 @@ void DIRQ_DisableDirectoryQuotas( } xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); - status = vol->VOLcomnVolOps.VOL_removePurgeLogEntry(&genMsg, vol, + status = vol->VOLcomnVolOps.VOL_removePurgeLogEntry(&genMsg, vol, PLOG_REMOVE_DIR_TREE, &purgeLogInfo->purgeLogMsg, xaction); vol->VOLcomnVolOps.VOL_endXLocal(xaction); free(purgeLogInfo); @@ -2430,7 +2431,7 @@ void DIRQ_ChangeVolumeDirectoryQuotasByName( DIRQ_ChangeVolumeDirectoryQuotas(genMsg, vol, name, enableQuotas); } return; -} +} /**************************************************************************** * diff --git a/src/nwnss/comn/common/eflMgmt.c b/src/nwnss/comn/common/eflMgmt.c index 8b9122b..40e884b 100644 --- a/src/nwnss/comn/common/eflMgmt.c +++ b/src/nwnss/comn/common/eflMgmt.c @@ -67,9 +67,9 @@ typedef struct EFLControlCookie_s { NINT currentOp; -#define EFL_OP_NONE 0 -#define EFL_OP_ENUMERATE 1 -#define EFL_OP_CHANGE_EPOCH 2 +#define EFL_OP_NONE 0 +#define EFL_OP_ENUMERATE 1 +#define EFL_OP_CHANGE_EPOCH 2 #define EFL_OP_START_EPOCH 3 #define EFL_OP_STOP_EPOCH 4 #define EFL_OP_REMOVE_EPOCH 5 @@ -85,7 +85,7 @@ typedef struct EFLControlCookie_s #define EFL_OP_RESET 15 #define EFL_OP_END 99 - NINT nameSpaceID; + NINT nameSpaceID; NINT inactiveEpochInterval; EFLEntryIndex_s nextEntry; Zid_t lastZidReturned; @@ -141,7 +141,7 @@ STATUS allocateEFLCookie( eflCookie->nextEntry.done = FALSE; } return zOK; -} +} /**************************************************************************** * @@ -156,12 +156,12 @@ STATUS checkEFLResultSize ( BYTE *temp; /* Is there enough space in the result buffer? */ - if ((eflCookie->resultAllocedLen - eflCookie->resultLen) < + if ((eflCookie->resultAllocedLen - eflCookie->resultLen) < EFL_RESULT_MIN_SIZE) { eflCookie->resultAllocedLen += EFL_RESULT_REALLOC_AMOUNT; temp = eflCookie->resultBuf; - eflCookie->resultBuf = realloc(eflCookie->resultBuf, + eflCookie->resultBuf = realloc(eflCookie->resultBuf, eflCookie->resultAllocedLen); if (eflCookie->resultBuf == NULL) { @@ -213,7 +213,7 @@ BOOL sendEFLResult( STATUS EFL_GetNameFromZid( GeneralMsg_s *genMsg, Volume_s *volume, - Zid_t zid, + Zid_t zid, NINT nameSpaceID, unicode_t *name, NINT *objectType) @@ -239,12 +239,12 @@ STATUS EFL_GetNameFromZid( { if (COMN_IsDerivedFrom(beast, zFTYPE_NAMED_DATA_STREAM)) { - if (((NamedBeast_s *)beast)->NAMEDfirstParentNameType == + if (((NamedBeast_s *)beast)->NAMEDfirstParentNameType == zNTYPE_DATA_STREAM) { *objectType = EFL_DATASTREAM; } - else if (((NamedBeast_s *)beast)->NAMEDfirstParentNameType == + else if (((NamedBeast_s *)beast)->NAMEDfirstParentNameType == zNTYPE_EXTENDED_ATTRIBUTE) { *objectType = EFL_EXTENDED_ATTRIBUTE; @@ -260,8 +260,8 @@ STATUS EFL_GetNameFromZid( unicode_t *insertPtr; NINT len; - if (COMN_GetFileNameFromZid(genMsg, volume, - ((NamedBeast_s *)beast)->NAMEDfirstParentZid, + if (COMN_GetFileNameFromZid(genMsg, volume, + ((NamedBeast_s *)beast)->NAMEDfirstParentZid, nameSpaceID, name, FALSE) != zOK) { goto error; @@ -271,8 +271,8 @@ STATUS EFL_GetNameFromZid( { goto error; } - - if (nameSpace->nSpaceOps->getSeparator(genMsg, + + if (nameSpace->nSpaceOps->getSeparator(genMsg, PATH_SEPARATOR, &seperator, &seperatorLen) != zOK) { goto error; @@ -284,7 +284,7 @@ STATUS EFL_GetNameFromZid( memmove(insertPtr, seperator, seperatorLen * sizeof(unicode_t)); insertPtr += seperatorLen; - if (NAME_GetFirstNameFromBeast(genMsg, beast, zMAX_COMPONENT_NAME, + if (NAME_GetFirstNameFromBeast(genMsg, beast, zMAX_COMPONENT_NAME, insertPtr, NULL, NULL, NULL) != zOK) { goto error; @@ -292,11 +292,11 @@ STATUS EFL_GetNameFromZid( } else { - if (COMN_GetFileNameFromZid(genMsg, volume, beast->ROOTzid, + if (COMN_GetFileNameFromZid(genMsg, volume, beast->ROOTzid, nameSpaceID, name, FALSE) != zOK) { goto error; - } + } } COMN_Release(&beast); return zOK; @@ -314,7 +314,7 @@ error: STATUS eflProcessDataStreamByType( GeneralMsg_s *genMsg, File_s *file, - NINT nameType, + NINT nameType, NINT action, Xaction_s *xaction) { @@ -387,7 +387,7 @@ STATUS eflProcessDataStreamByType( * the next dataStream to be deleted. Both pointers are XLATCHED * and have useCounts. */ VOL_insertEFLEntry(genMsg, (RootBeast_s *)aStack->nameMsg.curDataStream, action, NULL, xaction); - + /* Put the nameMsg back to the parent file beast */ COMN_UnlatchAndRelease(&aStack->nameMsg.curDataStream, XLATCHED); aStack->nameMsg.curDataStream = (NamedBeast_s *)aStack->nameMsg.curFile; @@ -422,7 +422,7 @@ cleanup_return: else { STACK_FREE(); - return(zFAILURE); + return(zFAILURE); } } @@ -440,20 +440,20 @@ STATUS eflProcessDataStreams( ASSERT_XLATCH(&file->FILEbeastLatch); - if (volume->VOLcomnVolOps.VOL_administerEFL(genMsg, volume, + if (volume->VOLcomnVolOps.VOL_administerEFL(genMsg, volume, VOL_EFL_GET_STATUS, NULL, &retData) != zOK) { - return zFAILURE; + return zFAILURE; } if (!retData.u.active) { return zOK; } - + if (file->FILEnameFlags & NFL_HAS_DATA_STREAMS) { - if (eflProcessDataStreamByType(genMsg, file, zNTYPE_DATA_STREAM, + if (eflProcessDataStreamByType(genMsg, file, zNTYPE_DATA_STREAM, action, xaction) != zOK) { return zFAILURE; @@ -487,32 +487,32 @@ STATUS listEpochs( BYTE epochBuffer1[GUID_FORMAT_SIZE+2]; - if (volume->VOLcomnVolOps.VOL_administerEFL(genMsg, volume, + if (volume->VOLcomnVolOps.VOL_administerEFL(genMsg, volume, VOL_EFL_ADMIN_LIST_EPOCHS, NULL, &adminOut) != zOK) { - return zFAILURE; + return zFAILURE; } - + /* process active epochs */ - numEntries = adminOut.u.listEpochs.numActiveEpochs; + numEntries = adminOut.u.listEpochs.numActiveEpochs; sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("<"TAG_ACTIVEEPOCHS">\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); for (i = 0; i < numEntries; i++) { - LB_GUIDToString(&adminOut.u.listEpochs.activeEpochs[i], + LB_GUIDToString(&adminOut.u.listEpochs.activeEpochs[i], sizeof(epochBuffer1), epochBuffer1); sprintf(eflCookie->resultBuf + eflCookie->resultLen, - MSGNot("<"TAG_EPOCH" "ATR_VALUE"=\"%s\"/>\n"), + MSGNot("<"TAG_EPOCH" "ATR_VALUE"=\"%s\"/>\n"), epochBuffer1); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); } sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); if (adminOut.u.listEpochs.activeEpochs) { @@ -523,28 +523,28 @@ STATUS listEpochs( numEntries = adminOut.u.listEpochs.numUsedEpochs; sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("<"TAG_USEDEPOCHS">\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); for (i = 0; i < numEntries; i++) { - LB_GUIDToString(&adminOut.u.listEpochs.usedEpochs[i], + LB_GUIDToString(&adminOut.u.listEpochs.usedEpochs[i], sizeof(epochBuffer1), epochBuffer1); sprintf(eflCookie->resultBuf + eflCookie->resultLen, - MSGNot("<"TAG_EPOCH" "ATR_VALUE"=\"%s\"/>\n"), + MSGNot("<"TAG_EPOCH" "ATR_VALUE"=\"%s\"/>\n"), epochBuffer1); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); } sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); if (adminOut.u.listEpochs.usedEpochs) { free(adminOut.u.listEpochs.usedEpochs); } - + return zOK; } @@ -567,12 +567,12 @@ STATUS EFL_ListEpochs( BYTE volName[zMAX_COMPONENT_NAME]; } Stack_s; STACK_ALLOC(); - + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); eflCookie = (EFLControlCookie_s *)virtInfo->otherPtr; - /* + /* * Send anything that happens to be held in the result buffer. If this * fills the output buffer then we are done with this request. */ @@ -608,7 +608,7 @@ STATUS EFL_ListEpochs( ClearErrno(&genMsg); listEpochs(&genMsg, volume, eflCookie); status = GetErrno(&genMsg); - + COMN_UnlockVolumeActive(volume, FALSE); errorReleaseVolume: COMN_Release(&volume); @@ -674,12 +674,12 @@ STATUS EFL_ReadAllFiles( char timeString[32]; } Stack_s; STACK_ALLOC(); - + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); eflCookie = (EFLControlCookie_s *)virtInfo->otherPtr; - /* + /* * Send anything that happens to be held in the result buffer. If this * fills the output buffer then we are done with this request. */ @@ -701,7 +701,7 @@ STATUS EFL_ReadAllFiles( utf8Name = malloc(EFL_UTF8_BUF_SIZE); /* We reach here only if there is an unfinished enumeration */ - zASSERT((eflCookie->currentOp == EFL_OP_ENUMERATE_FILES) && + zASSERT((eflCookie->currentOp == EFL_OP_ENUMERATE_FILES) && !eflCookie->done); /* allocate memory for return data and for path */ @@ -729,9 +729,9 @@ STATUS EFL_ReadAllFiles( while (bufBytesLeft > 0) { - if (volume->VOLcomnVolOps.VOL_browseBeastsInVolume(&genMsg, volume, - SELECT_BEASTS_ALL, MAX_EFL_ENTRIES_PER_SCOOP, - &eflCookie->lastZidReturned, beastEntries, + if (volume->VOLcomnVolOps.VOL_browseBeastsInVolume(&genMsg, volume, + SELECT_BEASTS_ALL, MAX_EFL_ENTRIES_PER_SCOOP, + &eflCookie->lastZidReturned, beastEntries, &numEntriesObtained) != zOK) { status = GetErrno(&genMsg); @@ -740,7 +740,7 @@ STATUS EFL_ReadAllFiles( for (i = 0; i < numEntriesObtained; ++i) { - if ((file = COMN_LookupByZid(&genMsg, volume, beastEntries[i], + if ((file = COMN_LookupByZid(&genMsg, volume, beastEntries[i], NOTLATCHED, FALSE)) == NULL) { continue; @@ -752,24 +752,24 @@ STATUS EFL_ReadAllFiles( continue; } - if (!COMN_IsDerivedFrom(file, zFTYPE_NAMED_DATA_STREAM) || + if (!COMN_IsDerivedFrom(file, zFTYPE_NAMED_DATA_STREAM) || NAME_AllNamesInSalvage(file)) { COMN_Release(&file); continue; } - if (EFL_GetNameFromZid(&genMsg, volume, file->FILEzid, + if (EFL_GetNameFromZid(&genMsg, volume, file->FILEzid, eflCookie->nameSpaceID, entry, &objectType) != zOK) { status = GetErrno(&genMsg); goto errorReleaseVolume; } - if (objectType == EFL_DATASTREAM || + if (objectType == EFL_DATASTREAM || objectType == EFL_EXTENDED_ATTRIBUTE) { - if ((parent = COMN_LookupByZid(&genMsg, volume, + if ((parent = COMN_LookupByZid(&genMsg, volume, file->FILEfirstParentZid, NOTLATCHED, TRUE)) == NULL) { COMN_Release(&file); @@ -779,9 +779,9 @@ STATUS EFL_ReadAllFiles( { COMN_Release(&parent); COMN_Release(&file); - continue; + continue; } - COMN_Release(&parent); + COMN_Release(&parent); } eflCookie->lastZidReturned = beastEntries[i]; @@ -807,25 +807,25 @@ STATUS EFL_ReadAllFiles( status = zERR_UNICODE_CONVERSION_ERROR; goto errorReleaseVolume; } - sprintf(eflCookie->resultBuf + eflCookie->resultLen, - MSGNot("<" TAG_FILE "><" - TAG_NAME "><" - TAG_ID1 ">%Lu<" - TAG_ID2 ">0<" - TAG_ID3 ">0<" - TAG_MODIFIEDTIME ">%s<" + sprintf(eflCookie->resultBuf + eflCookie->resultLen, + MSGNot("<" TAG_FILE "><" + TAG_NAME "><" + TAG_ID1 ">%Lu<" + TAG_ID2 ">0<" + TAG_ID3 ">0<" + TAG_MODIFIEDTIME ">%s<" TAG_SIZE ">%Lu%s"), - utf8Name, - beastEntries[i], + utf8Name, + beastEntries[i], UTCTime2UniversalStr(file->FILEmodifiedTime, aStack->timeString), file->FILEeof, dirTag); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, - MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + MSGNot("\n")); + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); COMN_Release(&file); @@ -836,24 +836,24 @@ STATUS EFL_ReadAllFiles( } /* Normal end of enumeration */ - if ((numEntriesObtained == 0) || eflCookie->done) + if ((numEntriesObtained == 0) || eflCookie->done) { eflCookie->done = TRUE; MGMT_BuildResultNSS(status, eflCookie->resultBuf + eflCookie->resultLen); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sendEFLResult(eflCookie, &bufBytesLeft, &outBuf, retLen); break; @@ -877,19 +877,19 @@ sendRetcode: /* send the error code */ MGMT_BuildResultNSS(status, eflCookie->resultBuf + eflCookie->resultLen); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sendEFLResult(eflCookie, &bufBytesLeft, &outBuf, retLen); @@ -949,11 +949,11 @@ STATUS EFL_ControlReadFunc( *retLen = 0; if (virtInfo->otherPtr == NULL) - { + { /* This file has no write function */ doReadOnly = TRUE; } - + if ((status = allocateEFLCookie(virtInfo)) != zOK) { STACK_FREE(); @@ -965,25 +965,25 @@ STATUS EFL_ControlReadFunc( if (doReadOnly) { /* send out the start tag */ - strcpy(eflCookie->resultBuf, + strcpy(eflCookie->resultBuf, MSGNot("<"TAG_NSSREPLY">\n<"TAG_FILEEVENTLIST">\n<"TAG_LISTEPOCHS">\n")); eflCookie->resultLen = strlen(eflCookie->resultBuf); } - + /* list all epochs */ if (doReadOnly) { EFL_ListEpochs(parmLen, parm, virtInfo); goto done; } - /* Return all files if we are taking a snap */ + /* Return all files if we are taking a snap */ else if (eflCookie->currentOp == EFL_OP_ENUMERATE_FILES) { EFL_ReadAllFiles(parmLen, parm, virtInfo); goto done; } - /* + /* * Send anything that happens to be held in the result buffer. If this * fills the output buffer then we are done with this request. */ @@ -1004,7 +1004,7 @@ STATUS EFL_ControlReadFunc( } /* We reach here only if there is an unfinished EFL enumeration */ - zASSERT((eflCookie->currentOp == EFL_OP_ENUMERATE) && + zASSERT((eflCookie->currentOp == EFL_OP_ENUMERATE) && ! eflCookie->done); /* allocate memory for return data */ @@ -1031,7 +1031,7 @@ STATUS EFL_ControlReadFunc( goto sendRetcode; } - if (volume->VOLcomnVolOps.VOL_enumerateEFL(&genMsg, volume, + if (volume->VOLcomnVolOps.VOL_enumerateEFL(&genMsg, volume, &eflCookie->epoch, MAX_EFL_ENTRIES_PER_SCOOP, &eflCookie->nextEntry, eflEntries, &numEntriesObtained) != zOK) @@ -1081,13 +1081,13 @@ STATUS EFL_ControlReadFunc( goto errorReleaseVolume; } - sprintf(eflCookie->resultBuf + eflCookie->resultLen, - MSGNot("<" TAG_FILE "><" - TAG_ACTION ">%u<" - TAG_NAME ">"), + sprintf(eflCookie->resultBuf + eflCookie->resultLen, + MSGNot("<" TAG_FILE "><" + TAG_ACTION ">%u<" + TAG_NAME ">"), entry->action, utf8Name); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sendEFLResult(eflCookie, &bufBytesLeft, &outBuf, retLen); checkEFLResultSize(eflCookie); @@ -1099,10 +1099,10 @@ STATUS EFL_ControlReadFunc( status = zERR_UNICODE_CONVERSION_ERROR; goto errorReleaseVolume; } - sprintf(eflCookie->resultBuf + eflCookie->resultLen, + sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("<" TAG_NEWNAME ">"), utf8Name); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sendEFLResult(eflCookie, &bufBytesLeft, &outBuf, retLen); checkEFLResultSize(eflCookie); @@ -1115,33 +1115,33 @@ STATUS EFL_ControlReadFunc( status = zERR_UNICODE_CONVERSION_ERROR; goto errorReleaseVolume; } - sprintf(eflCookie->resultBuf + eflCookie->resultLen, + sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("<" TAG_REALNAME ">"), utf8Name); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sendEFLResult(eflCookie, &bufBytesLeft, &outBuf, retLen); checkEFLResultSize(eflCookie); } - sprintf(eflCookie->resultBuf + eflCookie->resultLen, + sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("<" TAG_ID1 ">%Lu<" TAG_ID2 ">%Lu<" - TAG_ID3 ">%Lu<" - TAG_MODIFIEDTIME ">%s<" - TAG_SIZE ">%Lu%s"), + TAG_ID3 ">%Lu<" + TAG_MODIFIEDTIME ">%s<" + TAG_SIZE ">%Lu%s"), entry->zid, entry->id1, entry->id2, UTCTime2UniversalStr(modifiedTime, aStack->timeString), size, dirTag); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); - sprintf(eflCookie->resultBuf + eflCookie->resultLen, - MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + sprintf(eflCookie->resultBuf + eflCookie->resultLen, + MSGNot("\n")); + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sendEFLResult(eflCookie, &bufBytesLeft, &outBuf, retLen); @@ -1154,26 +1154,26 @@ STATUS EFL_ControlReadFunc( } /* Normal end of enumeration */ - if (eflCookie->nextEntry.done || eflCookie->done) + if (eflCookie->nextEntry.done || eflCookie->done) { eflCookie->done = TRUE; eflCookie->nextEntry.done = FALSE; eflCookie->nextEntry.firstTime = TRUE; MGMT_BuildResultNSS(status, eflCookie->resultBuf + eflCookie->resultLen); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sendEFLResult(eflCookie, &bufBytesLeft, &outBuf, retLen); } @@ -1198,15 +1198,15 @@ sendRetcode: eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sendEFLResult(eflCookie, &bufBytesLeft, &outBuf, retLen); @@ -1231,7 +1231,7 @@ STATUS getTagAttribute( char *holdChar) { STATUS status; - + status = XML_GetTagAttribute(attribute, elementInfo); if (status != zOK) { @@ -1241,15 +1241,15 @@ STATUS getTagAttribute( zASSERT(elementInfo->attributeValueEnd != NULL); if (elementInfo->attributeValueEnd) { - *holdChar = *(elementInfo->attributeValueEnd + 1); + *holdChar = *(elementInfo->attributeValueEnd + 1); *(elementInfo->attributeValueEnd + 1) = 0; } - + return zOK; } /**************************************************************************** - * Parse the EFL operation from the XML + * Parse the EFL operation from the XML ****************************************************************************/ STATUS parseEFLOp( GeneralMsg_s *genMsg, @@ -1266,21 +1266,21 @@ STATUS parseEFLOp( start = element->dataStart; for(;;) { - if (XML_GetNextTag(start, element->dataEnd, &elementInfo, + if (XML_GetNextTag(start, element->dataEnd, &elementInfo, tagName, tagLen) != zOK) { description = MSGNot("Could not find \"fileEventList\" tag"); goto badFormat; } start = elementInfo.elementEnd + 1; - + if (!memcmp(*tagName, MSGNot(TAG_FILEEVENTLIST), *tagLen)) { break; } } - - if (XML_GetNextTag(elementInfo.dataStart, elementInfo.dataEnd, &elementInfo, + + if (XML_GetNextTag(elementInfo.dataStart, elementInfo.dataEnd, &elementInfo, tagName, tagLen) != zOK) { description = MSGNot("Missing action tag"); @@ -1378,7 +1378,7 @@ STATUS parseEFLOp( eflCookie->done = FALSE; } else if (memcmp(*tagName, MSGNot(TAG_GETEFLNAMESPACEID), *tagLen) == 0) - { + { eflCookie->currentOp = EFL_OP_GET_NAMESPACE_ID; } else if (memcmp(*tagName, MSGNot(TAG_SETEFLNAMESPACEID), *tagLen) == 0) @@ -1397,7 +1397,7 @@ STATUS parseEFLOp( *(elementInfo.attributeValueEnd + 1) = holdChar; } else if (memcmp(*tagName, MSGNot(TAG_GETINACTIVEEPOCHINTERVAL), *tagLen) == 0) - { + { eflCookie->currentOp = EFL_OP_GET_INACTIVE_EPOCH_INTERVAL; } else if (memcmp(*tagName, MSGNot(TAG_SETINACTIVEEPOCHINTERVAL), *tagLen) == 0) @@ -1416,13 +1416,13 @@ STATUS parseEFLOp( } } else if (memcmp(*tagName, MSGNot(TAG_CHECKEPOCHS), *tagLen) == 0) - { + { eflCookie->currentOp = EFL_OP_CHECK_EPOCHS; } else if (memcmp(*tagName, MSGNot(TAG_PINGEPOCH), *tagLen) == 0) { eflCookie->currentOp = EFL_OP_PING_EPOCH; - + if ((getTagAttribute(MSGNot(ATR_EPOCHNUMBER), &elementInfo, &holdChar) != zOK) || (LB_GUIDFromUTF8(elementInfo.attributeValueStart, &eflCookie->epoch) != zOK)) { @@ -1435,7 +1435,7 @@ STATUS parseEFLOp( { eflCookie->currentOp = EFL_OP_RESET; } - else + else { description = MSGNot("Unknown tag"); goto badFormat; @@ -1471,12 +1471,12 @@ STATUS EFL_ControlWriteFunc( EFLAdminIn_s adminIn; EFLAdminOut_s adminOut; Xaction_s *xaction; - utf8_t *tagName = NULL; - NINT tagLen; + utf8_t *tagName = NULL; + NINT tagLen; char holdChar; typedef struct Stack_s { unicode_t uniVolName[zMAX_COMPONENT_NAME]; - BYTE volName[zMAX_COMPONENT_NAME]; + BYTE volName[zMAX_COMPONENT_NAME]; BYTE epochBuffer1[GUID_FORMAT_SIZE+2]; BYTE epochBuffer2[GUID_FORMAT_SIZE+2]; } Stack_s; @@ -1530,24 +1530,24 @@ STATUS EFL_ControlWriteFunc( *(tagName + tagLen) = 0; sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("<%s>\n"), tagName); - *(tagName + tagLen) = holdChar; - eflCookie->resultLen += strlen(eflCookie->resultBuf + + *(tagName + tagLen) = holdChar; + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); - + switch (eflCookie->currentOp) { case EFL_OP_ENUMERATE: - status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, VOL_EFL_ADMIN_GET_NAME_SPACE_ID, NULL, &adminOut); - if (status == zOK) + if (status == zOK) { - eflCookie->nameSpaceID = adminOut.u.nameSpaceID; + eflCookie->nameSpaceID = adminOut.u.nameSpaceID; } break; case EFL_OP_REMOVE_ENTRY: S_LATCH(&volume->rootdir->FILEbeastLatch); xaction = COMN_BeginXLocal(volume->rootdir); - status = volume->VOLcomnVolOps.VOL_deleteEFLEntry(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_deleteEFLEntry(&genMsg, volume, eflCookie->lastZidReturned, eflCookie->id1Returned, eflCookie->id2Returned, &eflCookie->epoch, xaction); COMN_EndXLocal(volume->rootdir, &xaction); @@ -1555,7 +1555,7 @@ STATUS EFL_ControlWriteFunc( break; case EFL_OP_CHANGE_EPOCH: adminIn.u.changeEpoch.epoch = eflCookie->epoch; - status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, VOL_EFL_ADMIN_CHANGE_EPOCH, &adminIn, &adminOut); epoch = adminOut.u.changeEpoch.epoch; if (status == zOK) @@ -1565,53 +1565,53 @@ STATUS EFL_ControlWriteFunc( sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("<"TAG_EPOCH" "ATR_VALUE"=\"%s\"/>\n" - "<"TAG_NEWEPOCH" "ATR_VALUE"=\"%s\"/>\n"), + "<"TAG_NEWEPOCH" "ATR_VALUE"=\"%s\"/>\n"), aStack->epochBuffer1, aStack->epochBuffer2); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); } break; case EFL_OP_START_EPOCH: - status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, VOL_EFL_ADMIN_CHANGE_EPOCH, NULL, &adminOut); epoch = adminOut.u.changeEpoch.epoch; if (status == zOK) { LB_GUIDToString(&epoch, sizeof(aStack->epochBuffer1), aStack->epochBuffer1); - sprintf(eflCookie->resultBuf + eflCookie->resultLen, - MSGNot("<"TAG_NEWEPOCH" "ATR_VALUE"=\"%s\"/>\n"), + sprintf(eflCookie->resultBuf + eflCookie->resultLen, + MSGNot("<"TAG_NEWEPOCH" "ATR_VALUE"=\"%s\"/>\n"), aStack->epochBuffer1); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); } break; case EFL_OP_STOP_EPOCH: adminIn.u.changeEpoch.epoch = eflCookie->epoch; - status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, VOL_EFL_ADMIN_CHANGE_EPOCH, &adminIn, NULL); if (status == zOK) { LB_GUIDToString(&eflCookie->epoch, sizeof(aStack->epochBuffer1), aStack->epochBuffer1); sprintf(eflCookie->resultBuf + eflCookie->resultLen, - MSGNot("<"TAG_EPOCH" "ATR_VALUE"=\"%s\"/>\n"), + MSGNot("<"TAG_EPOCH" "ATR_VALUE"=\"%s\"/>\n"), aStack->epochBuffer1); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); } break; case EFL_OP_REMOVE_EPOCH: adminIn.u.changeEpoch.epoch = eflCookie->epoch; - status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, VOL_EFL_ADMIN_REMOVE_EPOCH, &adminIn, NULL); if (status == zOK) { LB_GUIDToString(&eflCookie->epoch, sizeof(aStack->epochBuffer1), aStack->epochBuffer1); sprintf(eflCookie->resultBuf + eflCookie->resultLen, - MSGNot("<"TAG_EPOCH" "ATR_VALUE"=\"%s\"/>\n"), + MSGNot("<"TAG_EPOCH" "ATR_VALUE"=\"%s\"/>\n"), aStack->epochBuffer1); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); } break; @@ -1619,69 +1619,69 @@ STATUS EFL_ControlWriteFunc( status = listEpochs(&genMsg, volume, eflCookie); break; case EFL_OP_ENUMERATE_FILES: - status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, VOL_EFL_ADMIN_GET_NAME_SPACE_ID, NULL, &adminOut); - if (status == zOK) + if (status == zOK) { - eflCookie->nameSpaceID = adminOut.u.nameSpaceID; + eflCookie->nameSpaceID = adminOut.u.nameSpaceID; } break; case EFL_OP_GET_INACTIVE_EPOCH_INTERVAL: - status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, VOL_EFL_ADMIN_GET_INACTIVE_EPOCH_INTERVAL, NULL, &adminOut); - if (status == zOK) + if (status == zOK) { sprintf(eflCookie->resultBuf + eflCookie->resultLen, - MSGNot("<"TAG_INTERVAL" "ATR_VALUE"=\"%d\"/>\n"), + MSGNot("<"TAG_INTERVAL" "ATR_VALUE"=\"%d\"/>\n"), adminOut.u.inactiveEpochInterval); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); } break; - case EFL_OP_SET_INACTIVE_EPOCH_INTERVAL: + case EFL_OP_SET_INACTIVE_EPOCH_INTERVAL: adminIn.u.inactiveEpochInterval = eflCookie->inactiveEpochInterval; - status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, VOL_EFL_ADMIN_SET_INACTIVE_EPOCH_INTERVAL, &adminIn, NULL); break; - case EFL_OP_CHECK_EPOCHS: - status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, + case EFL_OP_CHECK_EPOCHS: + status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, VOL_EFL_ADMIN_CHECK_EPOCH, NULL, NULL); break; - case EFL_OP_PING_EPOCH: + case EFL_OP_PING_EPOCH: adminIn.u.changeEpoch.epoch = eflCookie->epoch; - status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, VOL_EFL_ADMIN_PING_EPOCH, &adminIn, NULL); if (status == zOK) { LB_GUIDToString(&eflCookie->epoch, sizeof(aStack->epochBuffer1), aStack->epochBuffer1); sprintf(eflCookie->resultBuf + eflCookie->resultLen, - MSGNot("<"TAG_EPOCH" "ATR_VALUE"=\"%s\"/>\n"), + MSGNot("<"TAG_EPOCH" "ATR_VALUE"=\"%s\"/>\n"), aStack->epochBuffer1); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); } break; case EFL_OP_GET_NAMESPACE_ID: - status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, VOL_EFL_ADMIN_GET_NAME_SPACE_ID, NULL, &adminOut); - if (status == zOK) + if (status == zOK) { sprintf(eflCookie->resultBuf + eflCookie->resultLen, - MSGNot("<"TAG_NAMESPACE" "ATR_ID"=\"%d\"/>\n"), + MSGNot("<"TAG_NAMESPACE" "ATR_ID"=\"%d\"/>\n"), adminOut.u.nameSpaceID); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); } break; - case EFL_OP_SET_NAMESPACE_ID: + case EFL_OP_SET_NAMESPACE_ID: adminIn.u.nameSpaceID = eflCookie->nameSpaceID; - status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerEFL(&genMsg, volume, VOL_EFL_ADMIN_SET_NAME_SPACE_ID, &adminIn, NULL); /* set EFL name space would reset EFL tree, let it fall through */ case EFL_OP_RESET: { - if (utf2uni(aStack->volName, aStack->uniVolName, + if (utf2uni(aStack->volName, aStack->uniVolName, zMAX_COMPONENT_NAME * sizeof(unicode_t)) == -1) { status = zERR_INVALID_UTF8_CHAR; @@ -1700,9 +1700,9 @@ STATUS EFL_ControlWriteFunc( break; } - if ((eflCookie->currentOp != EFL_OP_ENUMERATE && + if ((eflCookie->currentOp != EFL_OP_ENUMERATE && eflCookie->currentOp != EFL_OP_ENUMERATE_FILES) || status != zOK) - { + { if (status == zOK) { MGMT_BuildResultElement(status, "success", @@ -1719,15 +1719,15 @@ STATUS EFL_ControlWriteFunc( sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n"), tagName); *(tagName + tagLen) = holdChar; - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); } COMN_UnlockVolumeActive(volume, FALSE); @@ -1747,11 +1747,11 @@ sendReturnCode: eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); sprintf(eflCookie->resultBuf + eflCookie->resultLen, MSGNot("\n")); - eflCookie->resultLen += strlen(eflCookie->resultBuf + + eflCookie->resultLen += strlen(eflCookie->resultBuf + eflCookie->resultLen); done: MPKNSS_UNLOCK(); diff --git a/src/nwnss/comn/common/extAttrBeast.c b/src/nwnss/comn/common/extAttrBeast.c index 2bc1bf6..8d4403e 100644 --- a/src/nwnss/comn/common/extAttrBeast.c +++ b/src/nwnss/comn/common/extAttrBeast.c @@ -44,7 +44,7 @@ #include "extAttrBeast.h" ///**************************************************************************** -// * +// * // *****************************************************************************/ //STATUS extAttrConstruct( // GeneralMsg_s *genMsg, @@ -54,12 +54,12 @@ //} /**************************************************************************** - * + * *****************************************************************************/ //void extAttrDestruct( // ExtAttrBeast_s *beast) //{ -//} +//} /**************************************************************************** * This function returns metadata information for an extAttrBeast object @@ -72,19 +72,15 @@ STATUS EXTATTR_BST_GetInfo( ExtAttrBeast_s *extAttr = (ExtAttrBeast_s *)extAttr_LX; zExtAttrInfo_s *extAttrInfo; statusfunc_t derivedFromGetInfo; - typedef STATUS (*extattr_get_info_func_t)( - GeneralMsg_s *, - RootBeast_s *, - GetInfoMsg_s *); ASSERT_MPKNSS_LOCK(); /*--------------------------------------------------------------------------- - * First, call the generic namedBeast information routine and fill in any + * First, call the generic namedBeast information routine and fill in any * requested named beast information. If it fails, do not continue... *---------------------------------------------------------------------------*/ derivedFromGetInfo = COMN_GetNextParentBeastComnOp(extAttr->EAbeastClass, - COMNOPS_INDEX(BST_getInfo),(statusfunc_t)EXTATTR_BST_GetInfo); - if (((extattr_get_info_func_t)derivedFromGetInfo)(genMsg,extAttr_LX,infoMsg) != zOK) + COMNOPS_INDEX(BST_getInfo),EXTATTR_BST_GetInfo); + if (derivedFromGetInfo(genMsg,extAttr,infoMsg) != zOK) return(zFAILURE); /*--------------------------------------------------------------------------- @@ -92,7 +88,7 @@ STATUS EXTATTR_BST_GetInfo( *---------------------------------------------------------------------------*/ if ((extAttrInfo = infoMsg->ret_getTypeInfo) == NULL) return(zOK); /* No type specific info requeted */ - + if (infoMsg->sizeRetGetTypeInfo < sizeof(zExtAttrInfo_s)) { SetErrno(genMsg,zERR_BUFFER_TOO_SMALL); @@ -131,7 +127,7 @@ STATUS EXTATTR_BST_ModifyInfo( // statusfunc_t derivedFromModifyInfo; ///*--------------------------------------------------------------------------- -// * First, call the generic namedBeast information routine and fill in any +// * First, call the generic namedBeast information routine and fill in any // * requested named beast information. If it fails, do not continue... // *---------------------------------------------------------------------------*/ // derivedFromModifyInfo = BST_GetNextParentMethod(extAttr->EAbeastClass, @@ -144,7 +140,7 @@ STATUS EXTATTR_BST_ModifyInfo( *---------------------------------------------------------------------------*/ if ((extAttrInfo = modifyMsg->modifyTypeInfo) == NULL) return(zOK); /* No type specific info to modify */ - + ASSERT_XLATCH(&extAttr->EAbeastLatch); zASSERT(!(modifyMsg->modifyTypeInfoMask & ~zVALID_MOD_EXTATTR_INFO_MASK)); if (modifyMsg->modifyTypeInfoMask & zMOD_EXTATTR_FLAGS) @@ -158,7 +154,7 @@ STATUS EXTATTR_BST_ModifyInfo( } else { - /* We have a transaction. Mark the beast as part of that + /* We have a transaction. Mark the beast as part of that * transaction and force write it as part of that transaction */ COMN_MARK_BEAST_XLOCAL(&extAttr->EAroot,xaction); if (COMN_ForceBeastWrite(genMsg,extAttr,xaction) != zOK) @@ -173,7 +169,7 @@ STATUS EXTATTR_BST_ModifyInfo( /**************************************************************************** * COMMON OPS definition - * + * *****************************************************************************/ /*--------------------------------------------------------------------------- diff --git a/src/nwnss/comn/common/fileBeast.c b/src/nwnss/comn/common/fileBeast.c new file mode 100644 index 0000000..bba82e2 --- /dev/null +++ b/src/nwnss/comn/common/fileBeast.c @@ -0,0 +1,1936 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2007-08-04 03:19:51 +0530 (Sat, 04 Aug 2007) $ + | + | $RCSfile$ + | $Revision: 2122 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This defines all of the primitive BEASTS inside of PSS + +-------------------------------------------------------------------------*/ +#include /* NetWare includes */ +#include + +#include /* NSS Library includes */ +#include +#include + +#include "comnBeasts.h" +#include "zParams.h" +#include "comnParams.h" +#include "comnPublics.h" +#include "comnZAS.h" +#include "msgGen.h" +#include "msgName.h" +#include "beastStartup.h" +#include "beastClass.h" +#include "zParams.h" +#include "comnParams.h" +#include "stdlib.h" +#include "volume.h" +#include "comnAuthorize.h" +#include "nameSpace.h" +#include "name.h" +#include "comnDataStream.h" +#include "cmNSS.h" +#include "sbsMFL.h" +#include "searchMap.h" +#include "objectIDStore.h" +#include "dirQuotas.h" +#include "opLock.h" +#include "nssPubs.h" +#include "xmlTags.h" +#include "mgmt.h" + +/**************************************************************************** + * + *****************************************************************************/ +STATUS FILE_BST_Construct( + GeneralMsg_s *genMsg, + void *beast_LX) +{ + File_s *beast = (File_s *)beast_LX; + beast->createdDOSTime = + beast->modifiedDOSTime = + beast->metaDataModifiedDOSTime = + beast->accessedDOSTime = + beast->archivedDOSTime = INVALID_DOS_TIME; + + return zOK; +} + +/**************************************************************************** + * + *****************************************************************************/ +void FILE_BST_Destruct( + void *file_LX) +{ + File_s *file = (File_s *)file_LX; + if (file->opLockControl) + { + zASSERT(file->opLockControl->opState == OPLOCK_IDLE); + zASSERT(DQ_EMPTY( &file->opLockControl->opLocks)); + free(file->opLockControl); + } + if (file->dataStreamInfo) + { + free(file->dataStreamInfo); + } +} + +/**************************************************************************** + * This function makes sure the fileBeast can be opened + *****************************************************************************/ +STATUS FILE_BST_BeastNotify( + GeneralMsg_s *genMsg, + RootBeast_s *file, + NINT notifyID) +{ + switch (notifyID) + { + case BST_NOTIFY_CLOSE: + case BST_NOTIFY_CREATE: + case BST_NOTIFY_OPEN: + case BST_NOTIFY_DELETE: + return zOK; + + default: + zASSERT(0); + } + return zFAILURE; +} + +/**************************************************************************** + * This function returns metadata information for a file beast object + *****************************************************************************/ +STATUS FILE_BST_GetInfo( + GeneralMsg_s *genMsg, + RootBeast_s *file_LX, + GetInfoMsg_s *infoMsg) +{ + File_s *file = (File_s *)file_LX; + zInfo_s *fileInfo; + statusfunc_t derivedFromGetInfo; + File_s *infoFile = file; + +/*--------------------------------------------------------------------------- + * First, call the generic namedBeast information routine and fill in any + * requested named beast information. If it fails, do not continue... + *---------------------------------------------------------------------------*/ + derivedFromGetInfo = COMN_GetNextParentBeastComnOp(file->FILEbeastClass, + COMNOPS_INDEX(BST_getInfo),FILE_BST_GetInfo); + if (derivedFromGetInfo(genMsg,file,infoMsg) != zOK) + return(zFAILURE); + +/*--------------------------------------------------------------------------- + * Now, if the caller requested, fill in any file specific information + *---------------------------------------------------------------------------*/ + if ((fileInfo = infoMsg->ret_getInfo) == NULL) + return(zOK); /* No info requeted */ + + if (((infoMsg->ret_getInfo->infoVersion == zINFO_VERSION_A) && (fileInfo->totalBytes < offsetof(zInfo_s,variableData))) + || ((infoMsg->ret_getInfo->infoVersion == zINFO_VERSION_B) && (fileInfo->totalBytes < offsetof(zInfoB_s,variableData))) + || ((infoMsg->ret_getInfo->infoVersion == zINFO_VERSION_C) && (fileInfo->totalBytes < offsetof(zInfoC_s,variableData))) + || ((infoMsg->ret_getInfo->infoVersion == zINFO_VERSION_D) && (fileInfo->totalBytes < offsetof(zInfoD_s,variableData)))) + { + SetErrno(genMsg,zERR_BUFFER_TOO_SMALL); + return(zFAILURE); + } + +/*--------------------------------------------------------------------------- + * Make sure the beast is latched to access its meta data + *---------------------------------------------------------------------------*/ + ASSERT_LATCH(&file->FILEbeastLatch); + + if (infoMsg->snapShotFileInfo) + { + infoFile = (File_s *)file->FILEroot.fileSnapshotBeast; + S_LATCH(&infoFile->FILEbeastLatch); + } +/*--------------------------------------------------------------------------- + * Return optional information + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & zGET_TIMES_IN_SECS) + { + fileInfo->time.created = infoFile->FILEcreatedTime; + fileInfo->time.archived = infoFile->FILEarchivedTime; + fileInfo->time.modified = infoFile->FILEmodifiedTime; + fileInfo->time.accessed = infoFile->FILEaccessedTime; + fileInfo->time.metaDataModified = infoFile->FILEmetaDataModifiedTime; + } + else if (infoMsg->getInfoMask & zGET_TIMES_IN_MICROS) + { + /* Currently we don't track time in microseconds. So I am just + * multiplying UTC time (in seconds) by 1,000,000 to get the time + * in micro seconds + */ + fileInfo->time.created = (QUAD)infoFile->FILEcreatedTime * 1000000; + fileInfo->time.archived = (QUAD)infoFile->FILEarchivedTime * 1000000; + fileInfo->time.modified = (QUAD)infoFile->FILEmodifiedTime * 1000000; + fileInfo->time.accessed = (QUAD)infoFile->FILEaccessedTime * 1000000; + fileInfo->time.metaDataModified = + (QUAD)infoFile->FILEmetaDataModifiedTime * 1000000; + } + + if (infoMsg->getInfoMask & zGET_IDS) + { + fileInfo->id.owner = infoFile->FILEownerID; + fileInfo->id.archiver = infoFile->FILEarchiverID; + fileInfo->id.modifier = infoFile->FILEmodifierID; + fileInfo->id.metaDataModifier = infoFile->FILEmetaDataModifierID; + } + + if (infoMsg->snapShotFileInfo) + { + UNS_LATCH(&infoFile->FILEbeastLatch); + } +/*--------------------------------------------------------------------------- + * Return optional data Stream information + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & zGET_DATA_STREAM_INFO) + { + if (file->FILEnameFlags & NFL_HAS_DATA_STREAMS) + { + if ((file->FILEdataStreamInfo == NULL) || + (file->FILEdataStreamInfo->dataStream.count==DSI_COUNT_INVALID)) + { + if (COMN_InitDataStreamInfo(genMsg,file,zNTYPE_DATA_STREAM)!=zOK) + return(zFAILURE); + } + + fileInfo->dataStream.count = + file->FILEdataStreamInfo->dataStream.count; + fileInfo->dataStream.totalDataSize = + file->FILEdataStreamInfo->dataStream.dataSize; + fileInfo->dataStream.totalNameSize = + file->FILEdataStreamInfo->dataStream.nameSize; + } +// This is done in the named beast's getInfo function +// else +// { +// fileInfo->dataStream.count = 0; +// fileInfo->dataStream.totalDataSize = 0; +// fileInfo->dataStream.totalNameSize = 0; +// } + } + +/*--------------------------------------------------------------------------- + * Return optional data Stream information + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & zGET_EXTENDED_ATTRIBUTE_INFO) + { + if (file->FILEnameFlags & NFL_HAS_EXTENDED_ATTRIBUTES) + { + if ((file->FILEdataStreamInfo == NULL) || + (file->FILEdataStreamInfo->extAttr.count == DSI_COUNT_INVALID)) + { + if (COMN_InitDataStreamInfo(genMsg,file, + zNTYPE_EXTENDED_ATTRIBUTE) != zOK) + { + return(zFAILURE); + } + } + + fileInfo->extAttr.count = file->FILEdataStreamInfo->extAttr.count; + fileInfo->extAttr.totalDataSize = + file->FILEdataStreamInfo->extAttr.dataSize; + fileInfo->extAttr.totalNameSize = + file->FILEdataStreamInfo->extAttr.nameSize; + } +// This is done in the named beast's getInfo function +// else +// { +// fileInfo->extAttr.count = 0; +// fileInfo->extAttr.totalDataSize = 0; +// fileInfo->extAttr.totalNameSize = 0; +// } + } + +/*--------------------------------------------------------------------------- + * Return optional directory quota information + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & zGET_DIR_QUOTA) + { + DirQuotaEntry_s dirQuota; + NINT entries; + + /* Get directory quotas only supported for zInfo version B and later */ + if (fileInfo->infoVersion < zINFO_VERSION_B) + { + SetErrno(genMsg, zERR_BAD_PARAMETER_VALUE); + return (zFAILURE); + } + + /* If hardlink, use the primary beast zid for quota info */ + if (DIRQ_GetDirectoryQuotas(genMsg, file->FILEvolume, + infoMsg->hlFile ? infoFile->FILEzid : fileInfo->std.zid, + 1, &dirQuota, &entries, FALSE) != zOK) + { + return (zFAILURE); + } + + if (entries == 1) + { + ((zInfoB_s *)fileInfo)->dirQuota.quota = dirQuota.quota; + ((zInfoB_s *)fileInfo)->dirQuota.usedAmount = dirQuota.usedAmount; + } + else + { + ((zInfoB_s *)fileInfo)->dirQuota.quota = -1; + ((zInfoB_s *)fileInfo)->dirQuota.usedAmount = 0; + } + } + + /*----------------------------------------------------------------------- + * Return optional inherited rights mask and trustee information + *-----------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & (zGET_INH_RIGHTS_MASK | zGET_ALL_TRUSTEES)) + { + STATUS status; + NamingMsg_s nameMsg; + NameSpace_s *nameSpace; + NINT remainingBytes; + zTrusteeInfo_s *nextTrustee; + NINT inheritedRightsMask; + GUID_t trustee; + NINT rights; + NINT sequence; + NINT attributes; /* Returned but not used */ + + /* Get inherited rights mask only supported for zInfo version C and later */ + if (infoMsg->ret_getInfo->infoVersion < zINFO_VERSION_C) + { + SetErrno(genMsg, zERR_BAD_PARAMETER_VALUE); + return (zFAILURE); + } + + /*------------------------------------------------------------------- + * We need to setup a nameMsg pointing to the file beast. We must + * manually "USE" all of the necessary beast pointers. + * + * NOTE - we set the latchType to XLATCHED. This is dangerous, but we + * are careful here. The cleanup code will UN_XLATCH the beast unless + * we set the latchType to NOTLATCHED before cleanup is called. + * + * ***** WE MUST NOT UNLATCH THE BEAST IN THIS FUNCTION. ***** + * That is the responsibility of the caller!!!! + *-------------------------------------------------------------------*/ + ASSERT_LATCH(&file->FILEbeastLatch); /* Make sure already latched */ + COMN_INIT_NAMING_MSG(&nameMsg); + + /* We don't care what namespace we use here ... just choose one */ + if ((nameSpace = COMN_NameSpaceIDLookup(genMsg, zNSPACE_LONG)) == NULL) + { + return (zFAILURE); + } + if (COMN_LockVolumeActive(genMsg,file->FILEvolume,FALSE) != zOK) + { + COMN_Release(&nameSpace); + return (zFAILURE); + } + COMN_USE_BEAST(&file->FILEvolume->VOLroot); + COMN_USE_BEAST(&file->FILEroot); + COMN_USE_BEAST(&file->FILEroot); + COMN_SETUP_NAMING_MSG_FILE_BEAST_PTR(&nameMsg, file->FILEvolume, + file->FILEfirstParentZid, /* cnt file->FILEfirstParentNameUniquifier,*/ + file, NAMPMODE_FullyResolveAny, XLATCHED, /* See above comnents */ + nameSpace, file->FILEfirstParentNameType, NULL); + /*------------------------------------------------------------------- + * From this point on we must cleanup the name message on exit, + * BUT WE MUST NOT UNLATCH THE BEAST ... so set it to NOTLATCHED before + * cleanup -- see above comments. + *-------------------------------------------------------------------*/ + + status = zOK; + + if (infoMsg->getInfoMask & zGET_INH_RIGHTS_MASK) + { + status = COMN_ZAS_getInheritedRightsMask( genMsg, &nameMsg, + &inheritedRightsMask); + ((zInfoC_s *)fileInfo)->inheritedRightsMask = inheritedRightsMask; + } + + if ((status == zOK) && (infoMsg->getInfoMask & zGET_ALL_TRUSTEES)) + { + ((zInfoC_s *)fileInfo)->trustees.numEntries = 0; + ((zInfoC_s *)fileInfo)->trustees.trusteeArray = fileInfo->nextByte; + nextTrustee = (zTrusteeInfo_s *)zINFO_PTR(fileInfo, fileInfo->nextByte); + remainingBytes = fileInfo->totalBytes - fileInfo->nextByte; + + sequence = 0; + while ( (status = COMN_ZAS_getACLEntry( genMsg, &nameMsg, + &sequence, &trustee, &rights, &attributes)) == zOK) + { + if (sequence == -1) + { + /* We're done. No more trustees */ + break; + } + + /* Got a trustee, see if there is room to store it */ + if (remainingBytes < sizeof(zTrusteeInfo_s)) + { + SetErrno(genMsg,zERR_BUFFER_TOO_SMALL); + status = zFAILURE; + break; + } + + /* Copy next trustee */ + nextTrustee->trustee = trustee; + nextTrustee->rights = rights; + ++((zInfoC_s *)fileInfo)->trustees.numEntries; + + /* Adjust loop variables and try again */ + ++nextTrustee; + remainingBytes -= sizeof(zTrusteeInfo_s); + } + } + + /*-------------------------------------------------------------------- + * See above comments related to latch/unlatch of the beast + * in the nameMsg + *--------------------------------------------------------------------*/ + nameMsg.latchType = NOTLATCHED; /* So cleanup wont unlatch it */ + COMN_CleanupNameMsg(genMsg, &nameMsg); + + if (status != zOK) + { + return(zFAILURE); + } + } + + return zOK; +} + +/**************************************************************************** + * this returns information about the beast in XML string format + *****************************************************************************/ +STATUS FILE_BST_GetInfoXML( + GeneralMsg_s *genMsg, + RootBeast_s *rBeast, + NINT typeOfInfo, + NINT bufLen, + utf8_t *buf, + NINT *infoLen) +{ + File_s *file = (File_s *)rBeast; + STATUS status = zOK; + statusfunc_t derivedFromGetInfoXML; + NINT len = 0; + NINT tmpLen; + typedef struct Stack_s{ + utf8_t tmpBuf[4096]; + } Stack_s; + Stack_s *aStack; + + /* Call parent routine */ + derivedFromGetInfoXML = COMN_GetNextParentBeastComnOp(file->FILEbeastClass, + COMNOPS_INDEX(BST_getInfoXML), FILE_BST_GetInfoXML); + if (derivedFromGetInfoXML != NULL && + derivedFromGetInfoXML(genMsg, file, typeOfInfo, bufLen, buf, infoLen) != zOK) + { + return zFAILURE; + } + + if (!(typeOfInfo & BST_INFO_FILE)) + { + return zOK; + } + + STACK_ALLOC_NO_ASTACK(); + + bufLen -= *infoLen; + + strcpy(&aStack->tmpBuf[len], "<"TAG_FILEBEASTINFO">"); + len += strlen(&aStack->tmpBuf[len]); + + /* PersistentFile_s */ + sprintf(&aStack->tmpBuf[len], "<"TAG_PERSISTENTFILE">"); + len += strlen(&aStack->tmpBuf[len]); + + if ((status = MNSS_FillUTCTime(TAG_ACCESSEDTIME, file->FILEaccessedTime, bufLen - len, + &aStack->tmpBuf[len], &tmpLen)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + len += tmpLen; + + if ((status = MNSS_FillUTCTime(TAG_CREATEDTIME, file->FILEcreatedTime, bufLen - len, + &aStack->tmpBuf[len], &tmpLen)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + len += tmpLen; + + if ((status = MNSS_FillUTCTime(TAG_MODIFIEDTIME, file->FILEmodifiedTime, bufLen - len, + &aStack->tmpBuf[len], &tmpLen)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + len += tmpLen; + + if ((status = MNSS_FillUTCTime(TAG_METADATAMODIFIEDTIME, file->FILEmetaDataModifiedTime, bufLen - len, + &aStack->tmpBuf[len], &tmpLen)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + len += tmpLen; + + if ((status = MNSS_FillUTCTime(TAG_ARCHIVEDTIME, file->FILEarchivedTime, bufLen - len, + &aStack->tmpBuf[len], &tmpLen)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + len += tmpLen; + + if ((status = MNSS_FillInAnID(TAG_MODIFIERID, &file->FILEmodifierID, bufLen - len, + &aStack->tmpBuf[len], &tmpLen)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + len += tmpLen; + + if ((status = MNSS_FillInAnID(TAG_METADATAMODIFIERID, &file->FILEmetaDataModifierID, bufLen - len, + &aStack->tmpBuf[len], &tmpLen)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + len += tmpLen; + + if ((status = MNSS_FillInAnID(TAG_ARCHIVERID, &file->FILEarchiverID, bufLen - len, + &aStack->tmpBuf[len], &tmpLen)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + len += tmpLen; + + sprintf(&aStack->tmpBuf[len], ""); + len += strlen(&aStack->tmpBuf[len]); + + /* various dos time */ + sprintf(&aStack->tmpBuf[len], "<"TAG_ACCESSEDDOSTIME">%u" + "<"TAG_CREATEDDOSTIME">%u" + "<"TAG_MODIFIEDDOSTIME">%u" + "<"TAG_METADATAMODIFIEDDOSTIME">%u" + "<"TAG_ARCHIVEDDOSTIME">%u", + file->FILEaccessedDOSTime, + file->FILEcreatedDOSTime, + file->FILEmodifiedDOSTime, + file->FILEmetaDataModifiedDOSTime, + file->FILEarchivedDOSTime); + len += strlen(&aStack->tmpBuf[len]); + + /* DataStreamInfo_s */ + if (file->FILEdataStreamInfo) + { + sprintf(&aStack->tmpBuf[len], "<"TAG_DATASTREAMINFO">" + "<"TAG_DATASTREAM">" + "<"TAG_COUNT">%u" + "<"TAG_DATASIZE">%Lu" + "<"TAG_NAMESIZE">%u" + "" + "<"TAG_EXTENDEDATTRIBUTE">" + "<"TAG_COUNT">%u" + "<"TAG_DATASIZE">%Lu" + "<"TAG_NAMESIZE">%u" + "" + "", + file->FILEdataStreamInfo->dataStream.count, + file->FILEdataStreamInfo->dataStream.dataSize, + file->FILEdataStreamInfo->dataStream.nameSize, + file->FILEdataStreamInfo->extAttr.count, + file->FILEdataStreamInfo->extAttr.dataSize, + file->FILEdataStreamInfo->extAttr.nameSize); + len += strlen(&aStack->tmpBuf[len]); + } + + strcpy(&aStack->tmpBuf[len], "\n"); + len += strlen(&aStack->tmpBuf[len]); + + if ((len + 1)> bufLen) + { + SetErrno(genMsg, zERR_BUFFER_TOO_SMALL); + status = zFAILURE; + } + else + { + strcpy(&buf[*infoLen], aStack->tmpBuf); + *infoLen += len; + } + +exit: + STACK_FREE(); + + return status; +} + +/**************************************************************************** + * This function modifies metadata information for a file beast object + *****************************************************************************/ +STATUS FILE_BST_ModifyInfo( + GeneralMsg_s *genMsg, + RootBeast_s *file_LX, + ModifyInfoMsg_s *modifyMsg, + Xaction_s *xaction) /* Optional xaction, may be NULL */ +{ + File_s *file = (File_s *)file_LX; + zInfo_s *info; + STATUS status; + NINT somethingChanged = FALSE; + NINT accessedTimeChanged = FALSE; + NINT subDirectoryFlag; + NINT mask; + NINT supervisorFlag; /* 0 = no supervisor rights, + * 1 = supervisor management level on an NDS ID + * 2 = Full Supervisor rights to the object */ + ParentEntry_s *parent = NULL; + BOOL fileLatched; + BOOL mayIModify = FALSE; + BOOL mayIModifyReaderInfo = FALSE; + BOOL mayIModifyModifierInfo = FALSE; + BOOL mayIModifyImmediatePurge = FALSE; + BOOL mayIModifyCreateDateTime = FALSE; + NameSpace_s *nameSpace; + GetStorageInfo_s storageInfo; + SQUAD restrictionAmount; + SQUAD usedAmount; + NINT managementLevel; + NINT managementLevel2; + LONG oldAttributes; + + typedef struct Stack_s { + SearchMap_s smap; + UserID_t myID; + UserID_t fileOwnerID; + UserID_t fileModifierID; + UserID_t fileMetaDataModifierID; + UserID_t fileArchiverID; + } Stack_s; + STACK_ALLOC(); + + info = modifyMsg->modifyInfo; + mask = modifyMsg->modifyInfoMask; + + + zASSERT(!(mask & ~zVALID_MOD_INFO_MASK)); + ASSERT_XLATCH(&file->FILEbeastLatch); + fileLatched = TRUE; + +/* This code causes too many problems and it is probably OK to let people + * change NetWare Meta Data even if it can't be stored persistently. + * If the user modifies something that can't be stored by the LSS it will + * be modified in memory, but won't stick persistently. They can use the + * zATTR_NETWARE_METADATA bit to determine if the attributes will be persistent. + * + * if (mask & (zMOD_FILE_ATTRIBUTES | zMOD_MODIFIED_TIME | zMOD_CREATED_TIME | + * zMOD_ARCHIVED_TIME | zMOD_ACCESSED_TIME | zMOD_METADATA_MODIFIED_TIME | + * zMOD_OWNER_ID | zMOD_ARCHIVER_ID | zMOD_MODIFIER_ID | + * zMOD_METADATA_MODIFIER_ID | zMOD_PRIMARY_NAMESPACE | zMOD_DELETED_INFO)) + * { + * if ((mask & zMOD_MODIFIED_TIME) || + * ((mask & zMOD_FILE_ATTRIBUTES) && + * (info->std.fileAttributesModMask & + * ~(zFA_READ_ONLY|zFA_HIDDEN|zFA_SYSTEM|zFA_EXECUTE|zFA_ARCHIVE)))) + * { + * if (!(file->FILEvolume->VOLenabledAttributes & zATTR_DOS_METADATA)) + * { + * status = zERR_DOS_METADATA_NOT_ENABLED; + * goto modifyErrorExit; + * } + * } + * + * if (!(file->FILEvolume->VOLenabledAttributes & zATTR_NETWARE_METADATA)) + * { + * status = zERR_NETWARE_METADATA_NOT_ENABLED; + * goto modifyErrorExit; + * } + * } + */ + if ((mask & zMOD_MAC_METADATA) && + (!(file->FILEvolume->VOLenabledAttributes & zATTR_MAC_METADATA))) + { + status = zERR_MAC_METADATA_NOT_ENABLED; + goto modifyErrorExit; + } + + if ((mask & zMOD_UNIX_METADATA) && + (!(file->FILEvolume->VOLenabledAttributes & zATTR_UNIX_METADATA))) + { + status = zERR_UNIX_METADATA_NOT_ENABLED; + goto modifyErrorExit; + } + + subDirectoryFlag = file->FILEattributes & zFA_SUBDIRECTORY; + aStack->fileOwnerID = file->FILEownerID; + aStack->fileModifierID = file->FILEmodifierID; + aStack->fileMetaDataModifierID = file->FILEmetaDataModifierID; + aStack->fileArchiverID = file->FILEarchiverID; + + if (subDirectoryFlag) + { + mask &= ~(zMOD_MODIFIER_ID | zMOD_ACCESSED_TIME); + } +/* else FixFixFix6 -- Legacy code does not allow setting of space restrictions + * on files. If we ever implement space restrictions, we need to do the + * same restriction here. + { + legacyInfoMask &= ~(MMaximumSpaceBit); + } */ + + aStack->myID = COMN_GetUserID(genMsg); + + if (LB_GUIDCompare(&aStack->myID, &zINVALID_USERID) == 0) + { + status = zERR_INVALID_USER_ID; + goto modifyErrorExit; + } + + if (file->FILEmayIDoThis(genMsg, file, modifyMsg->parentZid, + MAY_I_SUPERVISE) == zOK) + { + supervisorFlag = 2; + mayIModify = TRUE; + mayIModifyReaderInfo = TRUE; + mayIModifyModifierInfo = TRUE; + } + else + { + supervisorFlag = 0; + ClearErrno(genMsg); + } +/*--------------------------------------------------------------------------- + * If changing create date/time, See if we have rights + *---------------------------------------------------------------------------*/ + if (mask & zMOD_CREATED_TIME) + { + if (file->FILEmayIDoThis(genMsg, file, modifyMsg->parentZid, + MAY_I_MODIFY_CREATE_DATE_TIME) == zOK) + { + mayIModifyCreateDateTime = TRUE; + } + else + { + mayIModifyCreateDateTime = FALSE; + } + } +/*--------------------------------------------------------------------------- + * If changing modifier metadata, See if we have rights + *---------------------------------------------------------------------------*/ + if (mask & (zMOD_MODIFIER_ID | zMOD_MODIFIED_TIME | + zMOD_METADATA_MODIFIER_ID | zMOD_METADATA_MODIFIED_TIME)) + { + if (file->FILEmayIDoThis(genMsg, file, modifyMsg->parentZid, + MAY_I_MODIFY_MODIFIER_METADATA) == zOK) + { + mayIModifyModifierInfo = TRUE; + } + else + { + mayIModifyModifierInfo = FALSE; + ClearErrno(genMsg); + } + } +/*--------------------------------------------------------------------------- + * If changing reader metadata, See if we have rights + *---------------------------------------------------------------------------*/ + if ((mask & (zMOD_ARCHIVER_ID |zMOD_ARCHIVED_TIME | zMOD_ACCESSED_TIME | + zMOD_METADATA_MODIFIED_TIME)) || + ((mask & zMOD_FILE_ATTRIBUTES) && + (info->std.fileAttributesModMask & (zFA_ARCHIVE | zFA_ATTR_ARCHIVE)))) + { + if (file->FILEmayIDoThis(genMsg, file, modifyMsg->parentZid, + MAY_I_MODIFY_READER_METADATA) == zOK) + { + mayIModifyReaderInfo = TRUE; + } + else + { + mayIModifyReaderInfo = FALSE; + ClearErrno(genMsg); + } + } +/*--------------------------------------------------------------------------- + * If changing misc info that only requires modify metadata rights, + * see if we have rights + *---------------------------------------------------------------------------*/ + if (mask & (zMOD_FILE_ATTRIBUTES | zMOD_PRIMARY_NAMESPACE | + zMOD_METADATA_MODIFIED_TIME | + zMOD_UNIX_METADATA)) + { + if (file->FILEmayIDoThis(genMsg, file, modifyMsg->parentZid, + MAY_I_MODIFY_METADATA) == zOK) + { + mayIModify = TRUE; + } + else + { + mayIModify = FALSE; + ClearErrno(genMsg); + } + } +/*--------------------------------------------------------------------------- + * If changing misc info that only requires modify metadata rights, + * see if we have rights + *---------------------------------------------------------------------------*/ + if (mask & zMOD_MAC_METADATA) + { + if (file->FILEmayIDoThis(genMsg, file, modifyMsg->parentZid, + MAY_I_MODIFY_MAC_METADATA) == zOK) + { + mayIModify = TRUE; + } + else + { + mayIModify = FALSE; + ClearErrno(genMsg); + } + } + +/*************** NOTE ***************************************************** + * When volume and beast locking are added make sure we are unlocked + * during this part. Calls to the name service routine can go remote + * and take a long time to complete. + **************************************************************************/ + UNX_LATCH(&file->FILEbeastLatch); + fileLatched = FALSE; + + if (supervisorFlag == 0) + { + COMN_GetManagementLevel(genMsg, file->FILEvolume, &aStack->fileOwnerID, + &managementLevel); + { + supervisorFlag = (managementLevel < zRSUPER) ? 0 : 1; + } + } + +/*------------------------------------------------------------------------- + * Validate the various IDs + *-------------------------------------------------------------------------*/ + + /* check the owner ID */ + if ((mask & zMOD_OWNER_ID) && supervisorFlag && + (LB_GUIDCompare(&info->id.owner, &aStack->fileOwnerID) != 0)) + { + if (supervisorFlag == 1) + { + COMN_GetManagementLevel(genMsg, file->FILEvolume, &info->id.owner, + &managementLevel); + if (managementLevel < zRSUPER) + { + goto noPrivExit; + } + } + } + + /* check the modifier ID */ + if ((mask & zMOD_MODIFIER_ID) && LB_GUIDCompare(&info->id.modifier, &aStack->fileModifierID) != 0) + { + if (LB_GUIDCompare(&info->id.modifier, &aStack->myID) == 0) + { + if (!mayIModifyModifierInfo) + { + goto noPrivExit; + } + } + else + { + COMN_GetManagementLevel(genMsg, file->FILEvolume, + &info->id.modifier, &managementLevel); + COMN_GetManagementLevel(genMsg, file->FILEvolume, + &aStack->fileModifierID, &managementLevel2); + + if ((supervisorFlag == 0) || + ((supervisorFlag == 1) && + ((managementLevel < zRSUPER) || + (managementLevel2 < zRSUPER)))) + { + goto noPrivExit; + } + } + } + + /* check the metaData modifier ID */ + if ((mask & zMOD_METADATA_MODIFIER_ID) && + LB_GUIDCompare(&info->id.metaDataModifier, &aStack->fileMetaDataModifierID) != 0) + { + if (LB_GUIDCompare(&info->id.metaDataModifier, &aStack->myID) == 0) + { + if (!mayIModifyModifierInfo) + { + goto noPrivExit; + } + } + else + { + COMN_GetManagementLevel(genMsg, file->FILEvolume, + &info->id.metaDataModifier, &managementLevel); + COMN_GetManagementLevel(genMsg, file->FILEvolume, + &aStack->fileMetaDataModifierID, &managementLevel2); + + if ((supervisorFlag == 0) || + ((supervisorFlag == 1) && + ((managementLevel < zRSUPER) || + (managementLevel2 < zRSUPER)))) + { + goto noPrivExit; + } + } + } + + /* check the archiver ID */ + if ((mask & zMOD_ARCHIVER_ID) && + LB_GUIDCompare(&info->id.archiver, &aStack->fileArchiverID) != 0) + { + if (LB_GUIDCompare(&info->id.archiver, &aStack->myID) == 0) + { + if (!mayIModifyReaderInfo) + { + goto noPrivExit; + } + } + else + { + COMN_GetManagementLevel(genMsg, file->FILEvolume, + &info->id.archiver, &managementLevel); + COMN_GetManagementLevel(genMsg, file->FILEvolume, + &aStack->fileArchiverID, &managementLevel2); + + if ((supervisorFlag == 0) || + ((supervisorFlag == 1) && + ((managementLevel < zRSUPER) || + (managementLevel2 < zRSUPER)))) + { + goto noPrivExit; + } + } + } + /* Re-latch the beast now that we're done with the name service */ + X_LATCH(&file->FILEbeastLatch); + fileLatched = TRUE; +/*--------------------------------------------------------------------------- + * Before making changes, make sure we can get a parent name entry if + * we need one. + *---------------------------------------------------------------------------*/ + if (mask & (zMOD_PRIMARY_NAMESPACE|zMOD_DELETED_INFO)) + { + if (!mayIModify) + { + goto noPrivExit; + } + if ((parent = NAME_GetParentEntry(genMsg, file/* cnt modifyMsg->nameUniquifier */)) == NULL) + { + goto modifyErrorExit_noSetErrno; + } + } + if (file->opLockControl) + { + OPLOCK_BreakShared(file); + } +/*------------------------------------------------------------------------- + * Make the changes to the file beast + *-------------------------------------------------------------------------*/ + oldAttributes = file->FILEattributes; + if (mask & zMOD_FILE_ATTRIBUTES) + { + info->std.fileAttributes &= zFA_VALID_DIRECTORY_ATTRIBUTES; + info->std.fileAttributesModMask &= zFA_VALID_FILE_ATTRIBUTES; + + /* If they are setting the READONLY bit, also set DELETE_INHIBIT + * and RENAME_INHIBIT. This is because some DOS utilities don't + * know how to set these INHIBIT bits, but they still need to be + * set (for example "attrib +r" needs to prevent a file from + * being deleted or renamed */ + if ((info->std.fileAttributes & zFA_READ_ONLY) && + (info->std.fileAttributesModMask & zFA_READ_ONLY)) + { + if (!(modifyMsg->modifyFlags & MF_DONT_AUTO_SET_DELETE_RENAME_INHIBIT)) + { + info->std.fileAttributes |= zFA_DELETE_INHIBIT; + info->std.fileAttributesModMask |= zFA_DELETE_INHIBIT; + + if (!(modifyMsg->modifyFlags & MF_DONT_AUTO_SET_RENAME_INHIBIT)) + { + info->std.fileAttributes |= zFA_RENAME_INHIBIT; + info->std.fileAttributesModMask |= zFA_RENAME_INHIBIT; + } + } + } + + if (supervisorFlag != 2) + { + info->std.fileAttributesModMask &= ~(zFA_COPY_INHIBIT); + } + + if (!mayIModify) + { + /* Only allow certain attributes to be modified without + * modifyMetadata rights. We will check their rights next */ + info->std.fileAttributesModMask &= (zFA_IMMEDIATE_PURGE | + zFA_ARCHIVE | zFA_ATTR_ARCHIVE); + } + if ((info->std.fileAttributesModMask & (zFA_ARCHIVE | zFA_ATTR_ARCHIVE)) && + (!mayIModifyReaderInfo)) + { + info->std.fileAttributesModMask &= ~(zFA_ARCHIVE | zFA_ATTR_ARCHIVE); + } + + if (info->std.fileAttributesModMask & zFA_IMMEDIATE_PURGE) + { + if (file->FILEmayIDoThis(genMsg, file, modifyMsg->parentZid, + MAY_I_DELETE) == zOK) + { + mayIModifyImmediatePurge = TRUE; + } + else + { + info->std.fileAttributesModMask &= ~(zFA_IMMEDIATE_PURGE); + ClearErrno(genMsg); + } + } + + /* Don't allow to set IC bit if volume doesn't have compression turned on. Mike + * Olsen said it is what traditional file system behaves + */ + if (!CM_COMPRESSION_ENABLED(file->FILEvolume)) + { + info->std.fileAttributesModMask &= ~zFA_COMPRESS_FILE_IMMEDIATELY; + } + + if (info->std.fileAttributesModMask & zFA_COMPRESS_FILE_IMMEDIATELY) + { + if ((info->std.fileAttributes & zFA_COMPRESS_FILE_IMMEDIATELY) + != (file->FILEattributes & zFA_COMPRESS_FILE_IMMEDIATELY)) + { + if (CM_COMPRESSION_ENABLED(file->FILEvolume) + && (info->std.fileAttributes & zFA_COMPRESS_FILE_IMMEDIATELY)) + { + if (! subDirectoryFlag) + { + /* + * Turning Immediate Compress flag OFF to ON + * Start compressing the file. + */ + if(CM_checkParentDirForCompressOK(genMsg, file)) + { + (void) CM_compressFileAsync(genMsg, &file->FILEroot, + XLATCHED, COMP_NORMAL); + } + + /* Since CM_compressFileAsync doesn't compress file + * if file open count is not zero, this line makes sure + * that file will be compressed when file is closed + */ + addLeaveCompressedToGrantedRights(&file->FILEroot); + + /* Ignore all errors */ + ClearErrno(genMsg); + } + else /* subdirectory */ + { + /* + * Turning Immediate Compress flag OFF to ON + * Start compressing the files in this directory . + */ + NameSpace_s *nameSpace = NULL; + Zid_t zid; + RootBeast_s *beast; +// cnt NINT nameUniquifier; + + bzero(&aStack->smap, sizeof(aStack->smap)); + aStack->smap.options |= SMAPOPT_matchAllEntries; + + nameSpace = COMN_NameSpaceIDLookup(genMsg, zNSPACE_LONG); + if (nameSpace != NULL) + { + zASSERT(LATCH_INUSE(&file->FILEbeastLatch)); + + while (1) + { + zid = file->FILEcomnOps.BST_wildcardLookup(genMsg, &file->FILEnamed, + nameSpace, zNTYPE_FILE, NULL, + &aStack->smap, /* cnt &nameUniquifier,*/ NULL); + + if (zid == zINVALID_ZID) + { + break; + } + + beast = (RootBeast_s *)COMN_LookupByZid(genMsg, file->FILEvolume, zid, + XLATCHED, TRUE); + if (beast == NULL) + { + continue; + } + + if (COMN_IsDerivedFrom(beast, zFTYPE_NAMED_DATA_STREAM) && + !(((NamedBeast_s *)beast)->NAMEDattributes & zFA_SUBDIRECTORY)) + { + if(CM_checkParentDirForCompressOK(genMsg, (File_s*)beast)) + { + CM_compressFileAsync(genMsg, beast, XLATCHED, COMP_NORMAL); + /* Since CM_compressFileAsync doesn't compress file + * if file open count is not zero, this line makes sure + * that file will be compressed when file is closed + * by the last open file handle + */ + addLeaveCompressedToGrantedRights(&file->FILEroot); + } + } + COMN_UnlatchAndRelease(&beast, XLATCHED); + } + BST_UNUSE_BEAST(&nameSpace->NSPACEroot); + } + } + } + else + { + /* + * Turning Immediate Compress flag ON to OFF + * Do nothing. + */ + } + } + } + + /* do no allow outside callers to modify the zFA_HARDLINK bit */ + info->std.fileAttributesModMask &= ~zFA_HARDLINK; + + file->FILEattributes = (file->FILEattributes & ~info->std.fileAttributesModMask) | + (info->std.fileAttributes & info->std.fileAttributesModMask); + + somethingChanged = TRUE; + } + +/*------------------------------------------------------------------------- + * time updates + *-------------------------------------------------------------------------*/ + if ((mask & zMOD_CREATED_TIME) && (mayIModifyCreateDateTime)) + { + file->FILEcreatedTime = info->time.created; + file->FILEcreatedDOSTime = INVALID_DOS_TIME; + somethingChanged = TRUE; + } + + if ((mask & zMOD_ARCHIVED_TIME) && (mayIModifyReaderInfo)) + { + file->FILEarchivedTime = info->time.archived; + file->FILEarchivedDOSTime = INVALID_DOS_TIME; + somethingChanged = TRUE; + } + + if ((mask & zMOD_MODIFIED_TIME) && (mayIModifyModifierInfo)) + { + file->FILEmodifiedTime = info->time.modified; + file->FILEmodifiedDOSTime = INVALID_DOS_TIME; + somethingChanged = TRUE; + } + + if ((mask & zMOD_ACCESSED_TIME) && (mayIModifyReaderInfo)) + { + file->FILEaccessedTime = info->time.accessed; + file->FILEaccessedDOSTime = INVALID_DOS_TIME; + accessedTimeChanged = TRUE; + } + + if ((mask & zMOD_METADATA_MODIFIED_TIME) && + ((supervisorFlag == 2) || (mayIModify) || (mayIModifyModifierInfo) || + (mayIModifyReaderInfo) || (mayIModifyImmediatePurge))) + { + file->FILEmetaDataModifiedTime = info->time.metaDataModified; + file->FILEmetaDataModifiedDOSTime = INVALID_DOS_TIME; + somethingChanged = TRUE; + } + +/*------------------------------------------------------------------------- + * ID changes + *-------------------------------------------------------------------------*/ + + if ((mask & zMOD_OWNER_ID) && supervisorFlag) + { + /* Rights checked earlier -- but we still need to check supervisorFlag */ + + ClearErrno( genMsg ); + if (COMN_GetBeastStorageInfo(genMsg, &file->FILEroot, &storageInfo) != zOK) + { + goto modifyErrorExit_noSetErrno; + } + + /* + * If the file has blocks in it make sure the new owner has enough space + * before allowing the change. + */ + if (storageInfo.filePhysSize > 0) + { + /* + * First, adjust the user space usage. Move the space used + * by the previous owner to the space used by the new owner. + */ + if (file->FILEvolume->VOLcomnVolOps.VOL_getUserSpaceInfo( + genMsg, file->FILEvolume, &info->id.owner, &restrictionAmount, + &usedAmount) != zOK) + { + if (GetErrno(genMsg) == zERR_NO_SUCH_USER) + { + restrictionAmount = zUSER_NO_RESTRICTIONS; + } + else + { + goto modifyErrorExit_noSetErrno; + } + ClearErrno( genMsg ); + } + + if ((restrictionAmount == zUSER_NO_RESTRICTIONS) || + (usedAmount + storageInfo.filePhysSize) <= restrictionAmount) + { + BOOL tempXaction = FALSE; + + if (xaction == NULL) + { + xaction = COMN_BeginXLocal(file); + tempXaction = TRUE; + } + VOL_AdjustUsedUserSpace(xaction, + &file->FILEroot, -storageInfo.filePhysSize); + + OID_SaveObjectID(file->FILEvolume, &info->id.owner); + file->FILEownerID = info->id.owner; + somethingChanged = TRUE; + + VOL_AdjustUsedUserSpace(xaction, + &file->FILEroot, storageInfo.filePhysSize); + if (tempXaction == TRUE) + { + COMN_EndXLocal(file, &xaction); + } + } + else + { + status = zERR_NOT_ENOUGH_USER_SPACE; + goto modifyErrorExit; + } + } + else + { + OID_SaveObjectID(file->FILEvolume, &info->id.owner); + file->FILEownerID = info->id.owner; + somethingChanged = TRUE; + } + } + if ((mask & zMOD_ARCHIVER_ID) && + LB_GUIDCompare(&info->id.archiver, &aStack->fileArchiverID) != 0) + { + /* Rights checked earlier */ + OID_SaveObjectID(file->FILEvolume, &info->id.archiver); + file->FILEarchiverID = info->id.archiver; + somethingChanged = TRUE; + } + if ((mask & zMOD_MODIFIER_ID) && + LB_GUIDCompare(&info->id.modifier, &aStack->fileModifierID) != 0) + { + /* Rights checked earlier */ + OID_SaveObjectID(file->FILEvolume, &info->id.modifier); + file->FILEmodifierID = info->id.modifier; + somethingChanged = TRUE; + } + if ((mask & zMOD_METADATA_MODIFIER_ID) && + LB_GUIDCompare(&info->id.metaDataModifier, &aStack->fileMetaDataModifierID) != 0) + { + /* Rights checked earlier */ + OID_SaveObjectID(file->FILEvolume, &info->id.metaDataModifier); + file->FILEmetaDataModifierID = info->id.metaDataModifier; + somethingChanged = TRUE; + } + +/*--------------------------------------------------------------------------- + * Primary Namespace + *---------------------------------------------------------------------------*/ + if ((mask & zMOD_PRIMARY_NAMESPACE) && (mayIModify)) + { + zASSERT(parent != NULL); + parent->p.primaryNameSpaceID = info->primaryNameSpaceID; + somethingChanged = TRUE; + } + +/*--------------------------------------------------------------------------- + * Modify optional MAC name space meta data + *---------------------------------------------------------------------------*/ + if ((mask & zMOD_MAC_METADATA) && (mayIModify)) + { + nameSpace = COMN_NameSpaceIDLookup(genMsg, zNSPACE_MAC); + if (nameSpace == NULL) + { + /* Just ignore name space modification if it is not loaded */ + } + else + { + if (nameSpace->nSpaceOps->modifyInfo(genMsg, (NamedBeast_s *)file, + modifyMsg) != zOK) + { + /* Just ignore name space modification if it it fails */ + zASSERT("Unable to modify MAC metadata"==NULL); + } + COMN_Release(&nameSpace); + somethingChanged = TRUE; + } + } +/*--------------------------------------------------------------------------- + * Modify optional UNIX name space meta data + *---------------------------------------------------------------------------*/ + if ((mask & zMOD_UNIX_METADATA) && (mayIModify)) + { + nameSpace = COMN_NameSpaceIDLookup(genMsg, zNSPACE_UNIX); + if (nameSpace == NULL) + { + /* Just ignore name space modification if it is not loaded */ + } + else + { + if (nameSpace->nSpaceOps->modifyInfo(genMsg, (NamedBeast_s *)file, + modifyMsg) != zOK) + { + /* Just ignore name space modification if it it fails */ + zASSERT("Unable to modify UNIX metadata"==NULL); + } + COMN_Release(&nameSpace); + somethingChanged = TRUE; + } + } +/*--------------------------------------------------------------------------- + * Modify salvage information for deleted file (we looked up "parent" earlier) + *---------------------------------------------------------------------------*/ + if ((mask & zMOD_DELETED_INFO) && (mayIModify) && + (parent->p.nameType == zNTYPE_DELETED_FILE) && (parent->t != NULL)) + { + parent->t->u.deleted.ID = info->deleted.id; + parent->t->u.deleted.time = info->deleted.time; + somethingChanged = TRUE; + } + +/*--------------------------------------------------------------------------- + * Modify directory quota for the file + *---------------------------------------------------------------------------*/ + if (mask & zMOD_DIR_QUOTA) + { + /* Get directory quotas only supported for zInfo version B and later */ + if (info->infoVersion < zINFO_VERSION_B) + { + SetErrno(genMsg, zERR_BAD_PARAMETER_VALUE); + goto modifyErrorExit_noSetErrno; + } + + if (DIRQ_SetDirectoryQuota(genMsg, file->FILEvolume, file, + ((zInfoB_s *)info)->dirQuota.quota) != zOK) + { + goto modifyErrorExit_noSetErrno; + } + + somethingChanged = TRUE; + } + + /*----------------------------------------------------------------------- + * Modify optional inherited rights mask and trustee information + *-----------------------------------------------------------------------*/ + if (mask & (zMOD_INH_RIGHTS_MASK | zMOD_ALL_TRUSTEES)) + { + STATUS status; + NamingMsg_s nameMsg; + NameSpace_s *nameSpace; + zTrusteeInfo_s *nextTrustee; + NINT idx; + + /* Get inherited rights mask only supported for zInfo version C and later */ + if (info->infoVersion < zINFO_VERSION_C) + { + SetErrno(genMsg, zERR_BAD_PARAMETER_VALUE); + goto modifyErrorExit_noSetErrno; + } + + /*-------------------------------------------------------------------- + * We need to setup a nameMsg pointing to the file beast. We must + * manually "USE" all of the necessary beast pointers. + * + * NOTE - we set the latchType to XLATCHED. This is dangerous, but we + * are careful here. The cleanup code will UN_XLATCH the beast unless + * we set the latchType to NOTLATCHED before cleanup is called. + * + * ***** WE MUST NOT UNLATCH THE BEAST IN THIS FUNCTION. ***** + * That is the responsibility of the caller!!!! + *--------------------------------------------------------------------*/ + ASSERT_XLATCH(&file->FILEbeastLatch); /* Make sure already latched */ + COMN_INIT_NAMING_MSG(&nameMsg); + + /* We don't care what namespace we use here ... just choose one */ + if ((nameSpace = COMN_NameSpaceIDLookup(genMsg, zNSPACE_LONG)) == NULL) + { + goto modifyErrorExit_noSetErrno; + } + if (COMN_LockVolumeActive(genMsg,file->FILEvolume,FALSE) != zOK) + { + COMN_Release(&nameSpace); + goto modifyErrorExit_noSetErrno; + } + COMN_USE_BEAST(&file->FILEvolume->VOLroot); + COMN_USE_BEAST(&file->FILEroot); + COMN_USE_BEAST(&file->FILEroot); + COMN_SETUP_NAMING_MSG_FILE_BEAST_PTR(&nameMsg, file->FILEvolume, + file->FILEfirstParentZid, /* cnt file->FILEfirstParentNameUniquifier, */ + file, NAMPMODE_FullyResolveAny, XLATCHED, /* See above comnents */ + nameSpace, file->FILEfirstParentNameType, NULL); + /*------------------------------------------------------------------- + * From this point on we must cleanup the name message on exit, + * BUT WE MUST NOT UNLATCH THE BEAST ... so set it to NOTLATCHED before + * cleanup -- see above comments. + *-------------------------------------------------------------------*/ + + status = zOK; + + if (mask & zMOD_INH_RIGHTS_MASK) + { + status = COMN_ZAS_setInheritedRightsMask( genMsg, &nameMsg, + (NINT)(((zInfoC_s *)info)->inheritedRightsMask), TRUE); + + somethingChanged = TRUE; + } + + if ((status == zOK) && (mask & zMOD_ALL_TRUSTEES)) + { + + nextTrustee = (zTrusteeInfo_s *)zINFO_PTR( + info, ((zInfoC_s *)info)->trustees.trusteeArray); + for (idx=0; idx<(((zInfoC_s *)info)->trustees.numEntries); idx++) + { + /* Loop and assign all trustees, stopping if we get errors */ + status = COMN_ZAS_addACLEntry( genMsg, &nameMsg, + &nextTrustee->trustee, + (NINT)(nextTrustee->rights), + zAUTHORIZE_INHERIT_DOWN | zAUTHORIZE_INHERIT_UP); + if (status != zOK) + { + break; + } + ++nextTrustee; + } + } + + /*-------------------------------------------------------------------- + * See above comments related to latch/unlatch of the beast + * in the nameMsg + *--------------------------------------------------------------------*/ + nameMsg.latchType = NOTLATCHED; /* So cleanup wont unlatch it */ + COMN_CleanupNameMsg(genMsg, &nameMsg); + + if (status != zOK) + { + goto modifyErrorExit_noSetErrno; + } + somethingChanged = TRUE; + } + +/*--------------------------------------------------------------------------- + * Now, finish modification cleanup + *---------------------------------------------------------------------------*/ + if (somethingChanged || accessedTimeChanged) + { + /* If only the accessedTimeChanged, do not change the metadata + * modified time + */ + if (somethingChanged) + { + if (!(mask & zMOD_METADATA_MODIFIED_TIME)) + { + file->FILEmetaDataModifiedTime = GetUTCTime(); + file->FILEmetaDataModifiedDOSTime = INVALID_DOS_TIME; + } + if (!(mask & zMOD_METADATA_MODIFIER_ID)) + { + file->FILEmetaDataModifierID = aStack->myID; + } + } + + /* if something changed, but a file attr change wasn't requested, then archive the change */ + /* if something changed, a file attr change was requested, but not an archive bit change, then archive the change */ + if(!(mask & zMOD_FILE_ATTRIBUTES) || + ((info->std.fileAttributesModMask & zFA_ATTR_ARCHIVE)== 0)) + { + mask |= zMOD_FILE_ATTRIBUTES; // pretend that a request was made to modify the file attr + info->std.fileAttributesModMask |= zFA_ATTR_ARCHIVE; + file->FILEattributes |= zFA_ATTR_ARCHIVE; // and force the attr_archive bit to be set + } + + if ((mask & zMOD_FILE_ATTRIBUTES) && + (info->std.fileAttributesModMask & (zFA_ARCHIVE|zFA_ATTR_ARCHIVE))) + { + if (((file->FILEattributes & (zFA_ARCHIVE|zFA_ATTR_ARCHIVE)) != 0) && + ((oldAttributes & (zFA_ARCHIVE|zFA_ATTR_ARCHIVE)) == 0)) + { + /* Archive bits going from OFF to ON; add to MFL */ + SBS_markFileModified(file, + file->FILEattributes & (zFA_ARCHIVE|zFA_ATTR_ARCHIVE), 0); + } + else if (((file->FILEattributes & (zFA_ARCHIVE|zFA_ATTR_ARCHIVE)) == 0) && + ((oldAttributes & (zFA_ARCHIVE|zFA_ATTR_ARCHIVE)) != 0)) + { + /* Archive bits going from ON to OFF; remove from MFL */ + SBS_markFileUnmodified(file); + } + } + + file->FILEmetaDataSeqNum++; + + if (xaction == NULL) + { + /* No transaction. Just mark the beast dirty and let it get flushed + * at some later point in time */ + COMN_MARK_BEAST_DIRTY(&file->FILEroot); + } + else + { + /* We have a transaction. Mark the beast as part of that + * transaction and force write it as part of that transaction */ + COMN_MARK_BEAST_XLOCAL(&file->FILEroot,xaction); + if (COMN_ForceBeastWrite(genMsg,file,xaction) != zOK) + { + goto modifyErrorExit_noSetErrno; + } + } + } + + STACK_FREE(); + return zOK; + +noPrivExit: + status = zERR_NO_SET_PRIVILEGE; + + +modifyErrorExit: + SetErrno(genMsg, status); + +modifyErrorExit_noSetErrno: + if (!fileLatched) + X_LATCH(&file->FILEbeastLatch); + STACK_FREE(); + return zFAILURE; +} + + +STATUS modifyDSInfoXML( + GeneralMsg_s *genMsg, + File_s *file, + DataStreamCounts_s *ds, + XML_ElementInfo_s *element, + Xaction_s *xaction, + BOOL doChange) +{ + STATUS status; + + const TagRequest_s tags[] = + { + {TAG_COUNT, TR_OPTIONAL}, + {TAG_DATASIZE, TR_OPTIONAL}, + {TAG_NAMESIZE, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags) - 1]; + + enum + { + COUNT = 0, + DATA_SIZE = 1, + NAME_SIZE = 2, + }; + + if ((status = MNSS_GetTagContents(NULL, NULL, element, tags, tagContent)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto Exit; + } + + status = zOK; + if (tagContent[COUNT].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, file, NINT, FALSE, + (ADDR)&ds->count, &tagContent[COUNT].element); + } + + if (tagContent[DATA_SIZE].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, file, QUAD, FALSE, + (ADDR)&ds->dataSize, &tagContent[DATA_SIZE].element); + } + + if (tagContent[NAME_SIZE].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, file, NINT, FALSE, + (ADDR)&ds->nameSize, &tagContent[NAME_SIZE].element); + } + +Exit: + return status; +} + + +/** + * Ying - March 4, 2004 + * NOTE: This function is provided for convinence, although I did my best + * to ensure its correctness, it's not fully tested + */ +STATUS FILE_BST_ModifyInfoXML( + GeneralMsg_s *genMsg, + RootBeast_s *rBeast, + NINT bufLen, + utf8_t *buf, + Xaction_s *xaction, + BOOL doChange) +{ + STATUS status = zOK; + File_s *beast = (File_s *)rBeast; + statusfunc_t derivedFromSetInfoXML; + XML_ElementInfo_s elementInfo; + utf8_t *copyBuf = NULL; + + const TagRequest_s tags[] = + { + {TAG_PERSISTENTFILE, TR_OPTIONAL}, + {TAG_ACCESSEDDOSTIME, TR_OPTIONAL}, + {TAG_CREATEDDOSTIME, TR_OPTIONAL}, + {TAG_MODIFIEDDOSTIME, TR_OPTIONAL}, + {TAG_METADATAMODIFIEDDOSTIME, TR_OPTIONAL}, + {TAG_ARCHIVEDDOSTIME, TR_OPTIONAL}, + {TAG_DATASTREAMINFO, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags) - 1]; + + enum + { + PERSISTENT_FILE = 0, + ACCESSED_DOS_TIME = 1, + CREATED_DOS_TIME = 2, + MODIFIED_DOS_TIME = 3, + METADATA_DOS_TIME = 4, + ARCHIVED_DOS_TIME = 5, + DATA_STREAM_INFO = 6 + }; + + /* Call parent routine */ + derivedFromSetInfoXML = COMN_GetNextParentBeastComnOp(beast->FILEbeastClass, + COMNOPS_INDEX(BST_modifyInfoXML), FILE_BST_ModifyInfoXML); + if (derivedFromSetInfoXML != NULL && + derivedFromSetInfoXML(genMsg, rBeast, bufLen, buf, xaction, doChange) != zOK) + { + return zFAILURE; + } + + /* make another copy of buf, buf will be changed + * while doing MNSS_GetTagContents + */ + copyBuf = malloc(bufLen); + if (copyBuf == NULL) + { + SetErrno(genMsg, zERR_NO_MEMORY); + return zFAILURE; + } + memcpy(copyBuf, buf, bufLen); + + if (XML_GetTagElement(TAG_FILEBEASTINFO, copyBuf, copyBuf + bufLen - 1, + &elementInfo) == zFAILURE) + { + // No file beast related info needs to be modified + status = zOK; + goto Exit; + } + + if (elementInfo.dataStart == NULL) + { + // no actual data + status = zOK; + goto Exit; + } + + if ((status = MNSS_GetTagContents(NULL, NULL, &elementInfo, tags, tagContent)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto Exit; + } + + + /* + * modify persistent data + */ + + if (tagContent[PERSISTENT_FILE].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + const TagRequest_s persistentTags[] = + { + {TAG_ACCESSEDTIME, TR_OPTIONAL}, + {TAG_CREATEDTIME, TR_OPTIONAL}, + {TAG_MODIFIEDTIME, TR_OPTIONAL}, + {TAG_METADATAMODIFIEDTIME, TR_OPTIONAL}, + {TAG_ARCHIVEDTIME, TR_OPTIONAL}, + {TAG_MODIFIERID, TR_OPTIONAL}, + {TAG_METADATAMODIFIERID, TR_OPTIONAL}, + {TAG_ARCHIVERID, TR_OPTIONAL}, + {0} + }; + TagContent_s persistentContent[NELEMS(persistentTags) - 1]; + + enum + { + ACCESSED_TIME = 0, + CREATED_TIME = 1, + MODIFIED_TIME = 2, + METADATA_TIME = 3, + ARCHIVED_TIME = 4, + MODIFIER_ID = 5, + METADATA_ID = 6, + ARCHIVER_ID = 7 + }; + + if ((status = MNSS_GetTagContents(NULL, NULL, &tagContent[PERSISTENT_FILE].element, + persistentTags, persistentContent)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto Exit; + } + + if (persistentContent[ACCESSED_TIME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if ((status = modifyTimeXML(genMsg, beast, &persistentContent[ACCESSED_TIME].element, + (ADDR)&beast->FILEaccessedTime, xaction, doChange)) != zOK) + { + goto Exit; + } + } + + if (persistentContent[CREATED_TIME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if ((status = modifyTimeXML(genMsg, beast, &persistentContent[CREATED_TIME].element, + (ADDR)&beast->FILEcreatedTime, xaction, doChange)) != zOK) + { + goto Exit; + } + } + + if (persistentContent[MODIFIED_TIME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if ((status = modifyTimeXML(genMsg, beast, &persistentContent[MODIFIED_TIME].element, + (ADDR)&beast->FILEmodifiedTime, xaction, doChange)) != zOK) + { + goto Exit; + } + } + + if (persistentContent[METADATA_TIME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if ((status = modifyTimeXML(genMsg, beast, &persistentContent[METADATA_TIME].element, + (ADDR)&beast->FILEmetaDataModifiedTime, xaction, doChange)) != zOK) + { + goto Exit; + } + } + + if (persistentContent[ARCHIVED_TIME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if ((status = modifyTimeXML(genMsg, beast, &persistentContent[ARCHIVED_TIME].element, + (ADDR)&beast->FILEarchivedTime, xaction, doChange)) != zOK) + { + goto Exit; + } + } + + if (persistentContent[MODIFIER_ID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if ((status = modifyIDXML(genMsg, beast, &persistentContent[ARCHIVED_TIME].element, + (ADDR)&beast->FILEmodifierID, xaction, doChange)) != zOK) + { + goto Exit; + } + } + + if (persistentContent[METADATA_ID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if ((status = modifyIDXML(genMsg, beast, &persistentContent[ARCHIVED_TIME].element, + (ADDR)&beast->FILEmetaDataModifierID, xaction, doChange)) != zOK) + { + goto Exit; + } + } + + if (persistentContent[ARCHIVER_ID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if ((status = modifyIDXML(genMsg, beast, &persistentContent[ARCHIVED_TIME].element, + (ADDR)&beast->FILEarchiverID, xaction, doChange)) != zOK) + { + goto Exit; + } + } + } + + if (tagContent[ACCESSED_DOS_TIME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, DOSTime_t, FALSE, (ADDR)&beast->FILEaccessedDOSTime, + &tagContent[ACCESSED_DOS_TIME].element); + } + + if (tagContent[CREATED_DOS_TIME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, DOSTime_t, FALSE, (ADDR)&beast->FILEcreatedDOSTime, + &tagContent[CREATED_DOS_TIME].element); + } + + if (tagContent[MODIFIED_DOS_TIME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, DOSTime_t, FALSE, (ADDR)&beast->FILEmodifiedDOSTime, + &tagContent[MODIFIED_DOS_TIME].element); + } + + if (tagContent[METADATA_DOS_TIME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, DOSTime_t, FALSE, (ADDR)&beast->FILEmetaDataModifiedDOSTime, + &tagContent[METADATA_DOS_TIME].element); + } + + if (tagContent[ARCHIVED_DOS_TIME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, DOSTime_t, FALSE, (ADDR)&beast->FILEarchivedDOSTime, + &tagContent[ARCHIVED_DOS_TIME].element); + } + + /* datastream info */ + if (tagContent[DATA_STREAM_INFO].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + const TagRequest_s DSTags[] = + { + {TAG_DATASTREAM, TR_OPTIONAL}, + {TAG_EXTENDEDATTRIBUTE, TR_OPTIONAL}, + {0} + }; + TagContent_s DSContent[NELEMS(DSTags) - 1]; + + enum + { + DATA_STREAM = 0, + EXTENDED_ATTRIBUTE = 1, + }; + + if ((status = MNSS_GetTagContents(NULL, NULL, &tagContent[DATA_STREAM_INFO].element, + DSTags, DSContent)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto Exit; + } + + if (DSContent[DATA_STREAM].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if ((status = modifyDSInfoXML(genMsg, beast, &beast->FILEdataStreamInfo->dataStream, + &DSContent[DATA_STREAM].element, xaction, doChange)) != zOK) + { + goto Exit; + } + } + + if (DSContent[EXTENDED_ATTRIBUTE].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if ((status = modifyDSInfoXML(genMsg, beast, &beast->FILEdataStreamInfo->extAttr, + &DSContent[EXTENDED_ATTRIBUTE].element, xaction, doChange)) != zOK) + { + goto Exit; + } + } + } + + status = zOK; + +Exit: + free(copyBuf); + + return status; +} +/**************************************************************************** + * COMMON OPS definition + * + *****************************************************************************/ + +/*--------------------------------------------------------------------------- + * Defines all of the FileBeast operations + *---------------------------------------------------------------------------*/ +CommonBeastOps_s FileBeastComnOps = +{ + FILE_BST_Construct, /* construct */ + FILE_BST_Destruct, /* destruct */ + +// cnt NULL, /* BST_getNameUniquifier */ + NULL, /* BST_setupNameTypeSpecificInfo */ + NULL, /* BST_lookupByNameInDirectory*/ + NULL, /* BST_isDirectoryEmpty*/ + NULL, /* BST_addNameToDirectory*/ + NULL, /* BST_removeNameFromDirectory*/ + NULL, /* BST_modifyNameSpaceMaskInDirectory*/ + NULL, /* BST_setMatchAttributesInDirectory*/ + NULL, /* BST_wildcardLookup*/ + + NULL, /* BST_truncateFile*/ + NULL, /* BST_getStorageInfo*/ + NULL, /* BST_getExtentList*/ + NULL, /* BST_getPhysicalExtent*/ + NULL, /* BST_isBlockInBeast*/ + + NULL, /* BST_asyncReadFileBlk*/ + NULL, /* BST_getFileBlk*/ + NULL, /* BST_dfsReadUnits*/ + NULL, /* BST_dfsWriteUnits*/ + + NULL, /* BST_getZID*/ + FILE_BST_BeastNotify, /* BST_beastNotify*/ + FILE_BST_GetInfo, /* BST_getInfo*/ + FILE_BST_ModifyInfo, /* BST_modifyInfo*/ + FILE_BST_GetInfoXML, /* BST_getInfoXML*/ + FILE_BST_ModifyInfoXML, /* BST_modifyInfoXML*/ +}; diff --git a/src/nwnss/comn/common/fileHandle.c b/src/nwnss/comn/common/fileHandle.c index 7675aa4..4415e31 100644 --- a/src/nwnss/comn/common/fileHandle.c +++ b/src/nwnss/comn/common/fileHandle.c @@ -72,17 +72,6 @@ #include "comnLock.h" #include "csa.h" #include "lsa.h" -#ifdef NSS_USERSPACE -#include -#endif - -#ifdef NSS_USERSPACE -/* fileHandle userspace status bridge: Msg_s.sys.where is a QUAD carrier here. */ -#undef SetErrnoFromStatus -#define SetErrnoFromStatus(_genMsg, _msg) \ - ((_genMsg)->errStatus = (_msg)->sys.status, \ - ((_genMsg)->errStatusSetter = (char *)(uintptr_t)((_msg)->sys.where))) -#endif extern mDoor_s *findDoor(Key_t key); @@ -149,7 +138,7 @@ Key_t EA_Open ( mKEY_NOTIFY, &key); zASSERT(fh != NULL); - FH_INIT_NEW_FILEHANDLE(fh); + FH_INIT_NEW_FILEHANDLE(fh); fh->grantedRights = rights; fh->pssConn = master->nssConn; @@ -225,7 +214,7 @@ tryAgain: goto tryAgain; } - /* + /* * Check do see whether requested rights, conflict with the rights * on a particular fileHandle. */ @@ -287,7 +276,7 @@ void FH_DeleteRights ( NamedBeast_s *dataStream = fileHandle->dataStream; NINT rights = fileHandle->grantedRights; OpenWaiting_s *candidate; - + if (rights & zRR_DENY_READ) { zASSERT(dataStream->NAMEDdenyReaderCount != 0); @@ -307,8 +296,8 @@ void FH_DeleteRights ( { zASSERT(dataStream->NAMEDwriterCount != 0); --dataStream->NAMEDwriterCount; - } - + } + /* browse through any pending open requests */ while (DQ_NOT_EMPTY(&fileHandle->fhWaiters)) { @@ -316,7 +305,7 @@ void FH_DeleteRights ( DQ_DEQ(&fileHandle->fhWaiters, candidate, OpenWaiting_s, link); if (dataStream->NAMEDvolume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) - { + { /* volume is deactivating */ cancelOpen(&candidate); } @@ -356,14 +345,14 @@ FileHandle_s *FH_AllocOpenFile ( zASSERT(fh != NULL); ++Inst.file.openCount; - FH_INIT_NEW_FILEHANDLE(fh); + FH_INIT_NEW_FILEHANDLE(fh); fh->grantedRights = 0; /* no rights granted by default */ fh->pssConn = nssConn; fh->connID = nssConn->connectionNumber; fh->taskID = genMsg->taskID; fh->semanticAgentID = genMsg->saID; - + --nssConn->connUseCount; return fh; } @@ -404,7 +393,7 @@ STATUS FH_OpenFile ( SetErrno(genMsg, zERR_NO_MEMORY); free(virtInfo->resultBuffer); free(virtInfo); - return zFAILURE; + return zFAILURE; } INIT_LATCH(virtInfo->javaLatch); fhType = &VirtualType; @@ -464,14 +453,14 @@ FileHandle_s *FH_msgAllocOpenFile ( zASSERT(fh != NULL); ++Inst.file.openCount; - FH_INIT_NEW_FILEHANDLE(fh); + FH_INIT_NEW_FILEHANDLE(fh); fh->grantedRights = 0; /* no rights granted by default */ fh->pssConn = master->nssConn; fh->connID = master->nssConn->connectionNumber; fh->taskID = msg->body.id.taskID; fh->semanticAgentID = 0; - + msg->sys.passedKey = key; return fh; @@ -511,20 +500,20 @@ FileHandle_s *FH_msgAllocOpenFile ( STATUS enableCompressedIO ( zNSSMsg_s *msg, FileHandle_s *fh) -{ +{ GeneralMsg_s genMsg; NamedBeast_s *dataStream = fh->dataStream; RootBeast_s *compBeast = NULL; COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); - + zASSERT(fh->grantedRights & zRR_WRITE_ACCESS || fh->grantedRights & zRR_READ_ACCESS); /* Prepare to read compressed version of the datastream */ if (CM_prepareToAccessCompFile(&genMsg, &dataStream->NAMEDroot, &compBeast) != zOK) - { + { SetStatus(msg, GetErrno(&genMsg)); return zFAILURE; } @@ -544,15 +533,15 @@ STATUS compressionOnVolume ( GeneralMsg_s genMsg; BOOL keep_comp_version = ((fh->grantedRights & zRR_LEAVE_FILE_COMPRESSED) || fh->parentIsImmCompress); - NINT access_mode = (fh->grantedRights & zRR_WRITE_ACCESS) - ? CACHE_UPDATE : CACHE_READ; + NINT access_mode = (fh->grantedRights & zRR_WRITE_ACCESS) + ? CACHE_UPDATE : CACHE_READ; COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); if (CM_prepareToAccessUncompFile(&genMsg, fh->file, - &fh->dataStream->NAMEDroot, access_mode, + &fh->dataStream->NAMEDroot, access_mode, &keep_comp_version) != zOK) - { + { SetStatus(msg, GetErrno(&genMsg)); return zFAILURE; } @@ -803,26 +792,26 @@ BOOL FH_FreeOpenFile (FileHandle_s *fileHandle) xaction = COMN_BeginXLocal(curDir); if ( COMN_LsaCleanupSetup( fileHandle->dataStream, /* cnt nameUniquifier,*/ &aStack->lsaInv) == zOK) - { + { if (primaryBeast != NULL) { - aStack->lsaInv.lid_zid = primaryBeast->FILEzid; + aStack->lsaInv.lid_zid = primaryBeast->FILEzid; } else { - aStack->lsaInv.lid_zid = fileHandle->dataStream->NAMEDzid; + aStack->lsaInv.lid_zid = fileHandle->dataStream->NAMEDzid; } - aStack->lsaInv.lid_pZid = curDir->NAMEDzid; + aStack->lsaInv.lid_pZid = curDir->NAMEDzid; lsaDelDentry = TRUE; - } + } /* use "fileHandle->dataStream" instead of "dataStream" * so pointer gets cleaned up properly */ - if (BST_delete(&genMsg, curDir, fileHandle->dataStream, primaryBeast, - neighborBeast, xaction, FALSE, TRUE) != zOK) - { + if (BST_delete(&genMsg, curDir, fileHandle->dataStream, primaryBeast, + neighborBeast, xaction, FALSE, TRUE) != zOK) + { zASSERT("BST_delete failed" == NULL); - } + } fileDeleted = TRUE; COMN_ForceBeastWrite(&genMsg,curDir,xaction); @@ -852,18 +841,18 @@ BOOL FH_FreeOpenFile (FileHandle_s *fileHandle) } else { - /* if the use count went to zero, truncate the file. i.e. + /* if the use count went to zero, truncate the file. i.e. * remove alloc-ahead blocks from file. */ - if (dataStream->NAMEDopenCount == 0) + if (dataStream->NAMEDopenCount == 0) { /* This if statement is for performance reasons. No need to * XLATCH beast unless the conditions are True */ if ((dataStream->NAMEDbstState & BST_STATE_TRUNCATE_CLOSE) || - ((dataStream->NAMEDnameFlags & + ((dataStream->NAMEDnameFlags & NFL_ADDED_TO_SALVAGE_TREE) && - (dataStream->NAMEDnameFlags & + (dataStream->NAMEDnameFlags & NFL_BLKS_NOT_IN_PURGEABLE_CNT) ) || (dataStream->NAMEDbstState & BST_STATE_DIRTY)) { @@ -887,24 +876,24 @@ BOOL FH_FreeOpenFile (FileHandle_s *fileHandle) Blknum_t eofBlock; Blkcnt_t purgeBlocks = 0; - if (COMN_GetStorageInfo(&genMsg, dataStream, + if (COMN_GetStorageInfo(&genMsg, dataStream, &getStorageInfo) == zOK) { - truncBlocks = (getStorageInfo.filePhysSize >> + truncBlocks = (getStorageInfo.filePhysSize >> dataStream->NAMEDblkSizeShift); } else { ClearErrno(&genMsg); } - - eofBlock = (dataStream->NAMEDeof + - (QUAD)((1 << dataStream->NAMEDblkSizeShift)-1)) >> + + eofBlock = (dataStream->NAMEDeof + + (QUAD)((1 << dataStream->NAMEDblkSizeShift)-1)) >> dataStream->NAMEDblkSizeShift; - if ((dataStream->NAMEDnameFlags & + if ((dataStream->NAMEDnameFlags & NFL_ADDED_TO_SALVAGE_TREE) && - (!(dataStream->NAMEDnameFlags & + (!(dataStream->NAMEDnameFlags & NFL_BLKS_NOT_IN_PURGEABLE_CNT))) { @@ -917,18 +906,18 @@ BOOL FH_FreeOpenFile (FileHandle_s *fileHandle) purgeBlocks = truncBlocks - eofBlock; } - dataStream->NAMEDbstState &= + dataStream->NAMEDbstState &= ~BST_STATE_TRUNCATE_CLOSE; - if (BST_truncate(&genMsg,dataStream, eofBlock, -1, + if (BST_truncate(&genMsg,dataStream, eofBlock, -1, purgeBlocks) != zOK) { zASSERT("Error truncating file on close. Internal error." == NULL); ClearErrno(&genMsg); } } - if ((dataStream->NAMEDnameFlags & + if ((dataStream->NAMEDnameFlags & NFL_ADDED_TO_SALVAGE_TREE) && - (dataStream->NAMEDnameFlags & + (dataStream->NAMEDnameFlags & NFL_BLKS_NOT_IN_PURGEABLE_CNT) && (COMN_GetPurgeableBlksCnt( &genMsg,dataStream, &physBlocks) == zOK)) @@ -954,7 +943,7 @@ BOOL FH_FreeOpenFile (FileHandle_s *fileHandle) { primaryBeast->FILEnameFlags &= ~NFL_BLKS_NOT_IN_PURGEABLE_CNT; } - COMN_saveBeastPurgeableBlksCnt( &genMsg, dataStream, 0, + COMN_saveBeastPurgeableBlksCnt( &genMsg, dataStream, 0, physBlocks); volLog.delta = physBlocks; @@ -964,7 +953,7 @@ BOOL FH_FreeOpenFile (FileHandle_s *fileHandle) zASSERT((dataStream->NAMEDbstState & BST_STATE_PURGING) == 0); // DBG_DebugPrintf(YELLOW, MSGNot("FreeOpenFH: Purgeable blocks = %Ld, delta+ = %Ld, beast zid = 0x%Lx\n"), volume->VOLpurgeableBlocks, physBlocks, dataStream->NAMEDzid); //#endif - + // done in VOL_writeVolumeLoggedData // volume->VOLpurgeableBlocks += physBlocks; volume->VOLcomnVolOps. @@ -1021,8 +1010,8 @@ openCountNoLongerZero: * beast is dirty.) */ if ( (fileHandle->grantedRights & zRR_FLUSH_ON_CLOSE) || - ( (volume->VOLenabledAttributes & zATTR_HIGH_INTEGRITY) && - ( (fileHandle->fhState & FH_MODIFIED) || + ( (volume->VOLenabledAttributes & zATTR_HIGH_INTEGRITY) && + ( (fileHandle->fhState & FH_MODIFIED) || (dataStream->NAMEDbstState & BST_STATE_DIRTY) ) && !(dataStream->NAMEDattributes & zFA_SUBDIRECTORY) ) ) { @@ -1086,7 +1075,7 @@ FileHandle_s *FH_DenyReaderWriterCantReopen( * Note, this may be called only once perhandle. *****************************************************************************/ STATUS FH_SetOpenFileGrantedRights( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, OpenMsg_s *openMsg, FileHandleIDP_s *fhIDP, NINT grantedRights) @@ -1139,7 +1128,7 @@ tryAgain: * Read/Write access. We emulate that feature here. */ if (((grantedRights & zRR_DENY_RW_OPENER_CAN_REOPEN)==0) || ((conflictFH = FH_DenyReaderWriterCantReopen( - genMsg, dataStream, zRR_READ_ACCESS | zRR_DENY_READ)) != NULL)) + genMsg, dataStream, zRR_READ_ACCESS | zRR_DENY_READ)) != NULL)) { SetErrno(genMsg,zERR_CANT_DENY_READ_LOCK); goto filelock_conflict; @@ -1218,7 +1207,7 @@ tryAgain: { /* In traditional NetWare, if a file was opened with Deny * Write only in compatability mode, the exact same - * station/task could NOT open it multiple times with + * station/task could NOT open it multiple times with * write access; but if it opens with Deny Write AND write * access in compatabilility mode, then the exact same * station/task could open it multiple times with write @@ -1237,7 +1226,7 @@ tryAgain: /*--------------------------------------------------------------------------- * Set the miscellaneous bits *---------------------------------------------------------------------------*/ - if (grantedRights & (zRR_DELETE_FILE_ON_CLOSE | + if (grantedRights & (zRR_DELETE_FILE_ON_CLOSE | zRR_PURGE_IMMEDIATE_ON_CLOSE)) { /* do nothing, just save the right bit in the handle itself */ @@ -1295,11 +1284,11 @@ tryAgain: filelock_conflict: if (!retried) { - if (CSA_CloseNotInUseFileHandles(dataStream, + if (CSA_CloseNotInUseFileHandles(dataStream, (grantedRights & (zRR_READ_ACCESS| zRR_WRITE_ACCESS| zRR_DENY_READ| - zRR_DENY_WRITE)), + zRR_DENY_WRITE)), fh) == zOK) { retried = TRUE; @@ -1308,31 +1297,31 @@ filelock_conflict: } if (openMsg && openMsg->openWaiting) - { - zASSERT(genMsg->saID == zSAGENT_NFS); + { + zASSERT(genMsg->saID == zSAGENT_NFS); if (checkDeadLockByFH(fh, conflictFH, TRUE)) { ForceSetErrno(genMsg, zERR_DEAD_LOCK); } else - { + { UserXaction_s *xaction = resolveXaction(zNILXID, fh, NULL, NULL, 0, FALSE); - + if (xaction == NULL) { ForceSetErrno(genMsg, zERR_NO_XACTION); } else - { + { openMsg->openWaiting->xaction = xaction; openMsg->openWaiting->state |= OPEN_WAITING; - + DQ_ENQ(&conflictFH->fhWaiters, openMsg->openWaiting, link); } } } - + return(zFAILURE); } @@ -1376,10 +1365,10 @@ void FH_CloseAllFilesForTask (Master_s *master, NINT taskID) if (master) { args.taskID = taskID; - MSG_DestroySetOfKeys( &master->mgr, &NormalFileType.hdr, (boolfunc_t)matchTask, &args); - MSG_DestroySetOfKeys( &master->mgr, &VirtualType.hdr, (boolfunc_t)matchTask, &args); - MSG_DestroySetOfKeys( &master->mgr, &MigratedType.hdr, (boolfunc_t)matchTask, &args); - MSG_DestroySetOfKeys( &master->mgr, &InternalEAHandleType.hdr, (boolfunc_t)matchTask, &args); + MSG_DestroySetOfKeys( &master->mgr, &NormalFileType.hdr, matchTask, &args); + MSG_DestroySetOfKeys( &master->mgr, &VirtualType.hdr, matchTask, &args); + MSG_DestroySetOfKeys( &master->mgr, &MigratedType.hdr, matchTask, &args); + MSG_DestroySetOfKeys( &master->mgr, &InternalEAHandleType.hdr, matchTask, &args); } } @@ -1419,7 +1408,7 @@ void FH_CloseAllSAgentFilesOnVolume( for (;;) { DQ_DEQ( &vol->beastList, beast, NamedBeast_s, root.volLink); - if (beast == NULL) + if (beast == NULL) { if ((rootDirDone) || (vol->rootdir == NULL)) { @@ -1482,7 +1471,7 @@ void FH_CloseAllFilesOnVolume( for (;;) { DQ_DEQ( &vol->beastList, beast, NamedBeast_s, root.volLink); - if (beast == NULL) + if (beast == NULL) { if ((rootDirDone) || (vol->rootdir == NULL)) { @@ -1576,7 +1565,7 @@ void displayFileName ( aStack->objNameBuf[1] = '\0'; #else MPKNSS_UNLOCK(); - if (GetConnectionAuthenticatedIdentity(pssConn->connectionNumber, + if (GetConnectionAuthenticatedIdentity(pssConn->connectionNumber, aStack->objNameBuf, NULL, NULL) != 0) { aStack->objNameBuf[0] = 0; @@ -1606,7 +1595,7 @@ void displayFileName ( MSG("File \"Unknown name\" in use by user %S on station %u.\n", 978), aStack->objNameBuf, pssConn->connectionNumber); } - COMN_CleanupNameMsg(genMsg,&aStack->nameMsg); + COMN_CleanupNameMsg(genMsg,&aStack->nameMsg); --pssConn->connUseCount; STACK_FREE(); } @@ -1642,7 +1631,7 @@ BOOL COMN_ListOpenFilesOnVolume( for (;;) { DQ_DEQ( &vol->beastList, rootBeast, RootBeast_s, volLink); - if (rootBeast == NULL) + if (rootBeast == NULL) { if ((rootDirDone) || (vol->rootdir == NULL)) { @@ -1681,7 +1670,7 @@ BOOL COMN_ListOpenFilesOnVolume( (!singleSemanticAgent || (fileHandle->semanticAgentID == genMsg->saID))) { - filesAreOpen = TRUE; + filesAreOpen = TRUE; displayFileName(genMsg, fileHandle, OutputRoutine); } MSG_RELEASE_DOOR(&fileHandle->door); @@ -1696,7 +1685,7 @@ BOOL COMN_ListOpenFilesOnVolume( /**************************************************************************** - * This routine will find all open file handles that point to the + * This routine will find all open file handles that point to the * combination of vol/oldDir/dataStream and will fix them to point to the * combination of vol/newDir/dataStream. *****************************************************************************/ @@ -1706,7 +1695,7 @@ void FH_FixupAllFileHandlesOnBeast( NamedBeast_s *oldDir, NamedBeast_s *newDir, // cnt NINT oldNameUniquifier, -// cnt NINT newNameUniquifier, +// cnt NINT newNameUniquifier, NINT newNameType) { FileHandle_s *fileHandle; @@ -1738,7 +1727,7 @@ BOOL COMN_IsDenyReaderWriterNotMe( FileHandle_s *fh; BOOL retried = TRUE; ASSERT_MPKNSS_LOCK(); - + if (file->NAMEDvolume->VOLenabledAttributes & zATTR_CFS_MASTER) { retried = FALSE; @@ -1756,7 +1745,7 @@ tryAgain: return(TRUE); } - if (CSA_CloseNotInUseFileHandles(file, + if (CSA_CloseNotInUseFileHandles(file, (zRR_WRITE_ACCESS|zRR_READ_ACCESS), NULL) != zOK) { return(TRUE); @@ -1800,7 +1789,7 @@ BOOL COMN_IsOpenerNotMe( * file open. * * This function checks all open handles for the file, and if all open file - * handles with the zRR_CANT_DELETE_WHILE_OPEN bit also have the + * handles with the zRR_CANT_DELETE_WHILE_OPEN bit also have the * zRR_OPENER_CAN_DELETE_WHILE_OPEN bit set, and if they are also opened * by the same connection/task, the delete will be allowed. *****************************************************************************/ @@ -1828,13 +1817,13 @@ tryAgain: { if (fh->grantedRights & zRR_CANT_DELETE_WHILE_OPEN) { - /* If opener is not allowed to delete -- + /* If opener is not allowed to delete -- * or this is not the opener -- * reject the delete */ if (((fh->grantedRights & zRR_OPENER_CAN_DELETE_WHILE_OPEN) == 0) || (fh->pssConn->connectionNumber != genMsg->pssConn.id) || - (fh->taskID != genMsg->taskID)) - { + (fh->taskID != genMsg->taskID)) + { if ((retried) || !(fh->fhState & FH_CFS_OPEN)) { return(TRUE); @@ -1842,11 +1831,11 @@ tryAgain: if (CSA_CloseNotInUseFileHandles(file, (zRR_CANT_DELETE_WHILE_OPEN), NULL) != zOK) { - return(TRUE); + return(TRUE); } retried = TRUE; goto tryAgain; - } + } } } /* All handles found with "Cant Delete" were also "Opener Can Delete", @@ -1860,9 +1849,9 @@ tryAgain: *****************************************************************************/ BOOL FH_DenyWriteMandatory( NamedBeast_s *file) -{ +{ FileHandle_s *fh; - + DQ_FOREACH(&file->openFileHandles, fh, FileHandle_s, bstLink) { if ((fh->grantedRights & zRR_DENY_WRITE) && @@ -1871,6 +1860,8 @@ BOOL FH_DenyWriteMandatory( return TRUE; } } - + return FALSE; } + + diff --git a/src/nwnss/comn/common/fsmsg.c b/src/nwnss/comn/common/fsmsg.c index 225f7db..d1b3868 100644 --- a/src/nwnss/comn/common/fsmsg.c +++ b/src/nwnss/comn/common/fsmsg.c @@ -37,6 +37,7 @@ +-------------------------------------------------------------------------*/ #if zLINUX +#include #endif #include @@ -55,7 +56,6 @@ #include #include -#include #include #include "xError.h" @@ -83,18 +83,6 @@ #include "dirQuotas.h" #include "comnPublics.h" -#define FSMSG_METHOD(_fn) ((statusfunc_t)(_fn)) -#define FSMSG_DATA_PTR(_type, _quad) ((_type *)(uintptr_t)(_quad)) -#define FSMSG_DATA_VOID(_quad) ((void *)(uintptr_t)(_quad)) - -#undef SetStatusFromErrno -#define SetStatusFromErrno(_msg, _genMsg) \ - (((_msg)->sys.status = (_genMsg)->errStatus), \ - ((_msg)->sys.where = (QUAD)(uintptr_t)(_genMsg)->errStatusSetter)) - -typedef STATUS (*FSMSG_NextCharFunc_t)(utf8_t *name, utf8_t **next, unicode_t *ch); -typedef STATUS (*FSMSG_MethodFunc_t)(zNSSMsg_s *msg); - void messageInfo (zNSSMsg_s *msg, File_s *file, zInfo_s *info); enum @@ -107,65 +95,71 @@ extern NSSConnection_s *MSG_DoResolveConnection(LONG connID); extern NSSConnection_s *MSG_CreateConnection(unicode_t *fdn); extern void MSG_DeleteConnection(LONG connID); +extern STATUS COMN_Close(); extern STATUS EA_Close(); -extern STATUS MSG_CloseRootKey(FileHandle_s *fh); +extern STATUS MSG_CloseRootKey(); extern STATUS MSG_Notify(); -extern STATUS FH_Resolve(Msg_s *msg); -extern STATUS MSG_ChangeConnection(zNSSMsg_s *msg); +extern STATUS FH_Resolve(); +extern STATUS MSG_ChangeConnection(); extern STATUS MSG_ChunkyRead(); +extern STATUS COMN_Write(); extern STATUS COMN_StartAsyncRead(); -extern STATUS MSG_NewConnection(zNSSMsg_s *msg); -extern STATUS MSG_Open(zNSSMsg_s *msg); -extern STATUS MSG_Create(zNSSMsg_s *msg); -extern STATUS MSG_Delete(zNSSMsg_s *msg); +extern STATUS COMN_AsyncRead(); +extern STATUS COMN_SetEOF(); +extern STATUS COMN_DirectReadFile(); +extern STATUS COMN_DirectWriteFile(); +extern STATUS MSG_NewConnection(); +extern STATUS MSG_Open(); +extern STATUS MSG_Create(); +extern STATUS MSG_Delete(); extern STATUS MSG_LockByteRange(); extern STATUS MSG_UnlockByteRange(); -extern STATUS MSG_Enumerate(zNSSMsg_s *msg); +extern STATUS MSG_Enumerate(); -extern STATUS MSG_AbortUserXaction(zNSSMsg_s *msg); -extern STATUS MSG_BeginTask(zNSSMsg_s *msg); -extern STATUS MSG_BeginUserXaction(zNSSMsg_s *msg); -extern STATUS MSG_CommitUserXaction(zNSSMsg_s *msg); -extern STATUS MSG_EndTask(zNSSMsg_s *msg); +extern STATUS MSG_AbortUserXaction(); +extern STATUS MSG_BeginTask(); +extern STATUS MSG_BeginUserXaction(); +extern STATUS MSG_CommitUserXaction(); +extern STATUS MSG_EndTask(); -extern STATUS MSG_Flush(zNSSMsg_s *msg); -extern STATUS MSG_GetFileMap(zNSSMsg_s *msg); -extern STATUS MSG_GetInfo(zNSSMsg_s *msg); -extern STATUS MSG_GetInfoByName(zNSSMsg_s *msg); -extern STATUS MSG_ModifyInfo(zNSSMsg_s *msg); -extern STATUS MSG_ModifyInfoByName(zNSSMsg_s *msg); -extern STATUS MSG_Link(zNSSMsg_s *msg); -extern STATUS MSG_Rename(zNSSMsg_s *msg); -extern STATUS MSG_WildRead(zNSSMsg_s *msg); -extern STATUS MSG_WildRewind(zNSSMsg_s *msg); +extern STATUS MSG_Flush(); +extern STATUS MSG_GetFileMap(); +extern STATUS MSG_GetInfo(); +extern STATUS MSG_GetInfoByName(); +extern STATUS MSG_ModifyInfo(); +extern STATUS MSG_ModifyInfoByName(); +extern STATUS MSG_Link(); +extern STATUS MSG_Rename(); +extern STATUS MSG_WildRead(); +extern STATUS MSG_WildRewind(); -extern STATUS MSG_AddTrustee(zNSSMsg_s *msg); -extern STATUS MSG_DeleteTrustee(zNSSMsg_s *msg); -extern STATUS MSG_GetTrustee(zNSSMsg_s *msg); -extern STATUS MSG_GetInheritedRightsMask(zNSSMsg_s *msg); -extern STATUS MSG_SetInheritedRightsMask(zNSSMsg_s *msg); +extern STATUS MSG_AddTrustee(); +extern STATUS MSG_DeleteTrustee(); +extern STATUS MSG_GetTrustee(); +extern STATUS MSG_GetInheritedRightsMask(); +extern STATUS MSG_SetInheritedRightsMask(); -extern STATUS MSG_IsNSS(zNSSMsg_s *msg); +extern STATUS MSG_IsNSS(); extern STATUS VIRT_Close(); extern STATUS VIRT_ChunkyRead(); extern STATUS VIRT_Write(); -extern STATUS DEMIGRATE_AsyncRead(zNSSMsg_s *msg); -extern STATUS DEMIGRATE_ChunkyRead(zNSSMsg_s *msg); -extern STATUS DEMIGRATE_SetEOF(zNSSMsg_s *msg); -extern STATUS DEMIGRATE_Write(zNSSMsg_s *msg); +extern STATUS DEMIGRATE_AsyncRead(); +extern STATUS DEMIGRATE_ChunkyRead(); +extern STATUS DEMIGRATE_SetEOF(); +extern STATUS DEMIGRATE_Write(); -extern STATUS MSG_GetEffectiveRights(zNSSMsg_s *msg); +extern STATUS MSG_GetEffectiveRights(); -extern STATUS MSG_ZidCreate(zNSSMsg_s *msg); -extern STATUS MSG_ZidDelete(zNSSMsg_s *msg); -extern STATUS MSG_ZidLink(zNSSMsg_s *msg); -extern STATUS MSG_ZidOpen(zNSSMsg_s *msg); -extern STATUS MSG_ZidRename(zNSSMsg_s *msg); +extern STATUS MSG_ZidCreate(); +extern STATUS MSG_ZidDelete(); +extern STATUS MSG_ZidLink(); +extern STATUS MSG_ZidOpen(); +extern STATUS MSG_ZidRename(); -extern STATUS MSG_FileControl(zNSSMsg_s *msg); +extern STATUS MSG_FileControl(); FileHandleType_s NormalFileType = { @@ -173,50 +167,50 @@ FileHandleType_s NormalFileType = NSS_NUM_METHODS, NULL, NULL, COMN_Close, MSG_Notify, MSG_BreakDoor), { - FSMSG_METHOD(FH_Resolve), /* NSS_RESOLVE_FILEHANDLE */ - FSMSG_METHOD(MSG_AbortUserXaction), /* NSS_ABORTXACTION */ - FSMSG_METHOD(MSG_AddTrustee), /* NSS_ADDTRUSTEE */ - FSMSG_METHOD(COMN_AsyncRead), /* NSS_ASYNCREAD */ - FSMSG_METHOD(MSG_BeginTask), /* NSS_BEGINTASK */ - FSMSG_METHOD(MSG_BeginUserXaction), /* NSS_BEGINXACTION */ - FSMSG_METHOD(MSG_ChangeConnection), /* NSS_CHANGECONNECTION */ - FSMSG_METHOD(MSG_CommitUserXaction), /* NSS_COMMITXACTION */ - FSMSG_METHOD(MSG_Create), /* NSS_CREATE */ - FSMSG_METHOD(MSG_Delete), /* NSS_DELETE */ - FSMSG_METHOD(MSG_DeleteTrustee), /* NSS_DELETETRUSTEE */ - FSMSG_METHOD(COMN_DirectReadFile), /* NSS_DIOREAD */ - FSMSG_METHOD(COMN_DirectWriteFile), /* NSS_DIOWRITE */ - FSMSG_METHOD(MSG_EndTask), /* NSS_ENDTASK */ - FSMSG_METHOD(MSG_Flush), /* NSS_FLUSH */ - FSMSG_METHOD(MSG_GetFileMap), /* NSS_GETFILEMAP */ - FSMSG_METHOD(MSG_GetInfo), /* NSS_GETINFO */ - FSMSG_METHOD(MSG_GetInheritedRightsMask), /* NSS_GETINHERITEDRIGHTSMASK */ - FSMSG_METHOD(MSG_GetTrustee), /* NSS_GETTRUSTEE */ - FSMSG_METHOD(MSG_IsNSS), /* NSS_ISNSS */ - FSMSG_METHOD(MSG_Link), /* NSS_LINK */ - FSMSG_METHOD(MSG_LockByteRange), /* NSS_LOCKBYTERANGE */ - FSMSG_METHOD(MSG_ModifyInfo), /* NSS_MODIFYINFO */ - FSMSG_METHOD(MSG_Open), /* NSS_OPEN */ - FSMSG_METHOD(MSG_ZidOpen), /* NSS_ZID_OPEN */ - FSMSG_METHOD(MSG_ChunkyRead), /* NSS_READ */ - FSMSG_METHOD(MSG_Rename), /* NSS_RENAME */ - FSMSG_METHOD(COMN_SetEOF), /* NSS_SETEOF */ - FSMSG_METHOD(MSG_SetInheritedRightsMask), /* NSS_SETINHERITEDRIGHTSMASK */ - FSMSG_METHOD(COMN_StartAsyncRead), /* NSS_START_ASYNCREAD */ - FSMSG_METHOD(MSG_UnlockByteRange), /* NSS_UNLOCKBYTERANGE */ - FSMSG_METHOD(MSG_WildRead), /* NSS_WILDREAD */ - FSMSG_METHOD(MSG_WildRewind), /* NSS_WILDREWIND */ - FSMSG_METHOD(COMN_Write), /* NSS_WRITE */ - FSMSG_METHOD(MSG_Enumerate), /* NSS_ENUMERATE */ - FSMSG_METHOD(MSG_GetEffectiveRights), /* NSS_GET_EFFECTIVE_RIGHTS */ - FSMSG_METHOD(MSG_ZidDelete), /* NSS_ZID_DELETE */ - FSMSG_METHOD(MSG_ZidCreate), /* NSS_ZID_CREATE */ - FSMSG_METHOD(MSG_ZidLink), /* NSS_ZID_LINK */ - FSMSG_METHOD(MSG_ZidRename), /* NSS_ZID_RENAME */ - FSMSG_METHOD(MSG_FileControl), /* NSS_FILE_CONTROL */ - FSMSG_METHOD(MSG_GetInfoByName), /* NSS_GETINFOBYNAME */ - FSMSG_METHOD(MSG_ModifyInfoByName), /* NSS_MODIFYINFOBYNAME */ - FSMSG_METHOD(NullMethod) /* NSS_NEWCONNECTION */ + FH_Resolve, /* NSS_RESOLVE_FILEHANDLE */ + MSG_AbortUserXaction, /* NSS_ABORTXACTION */ + MSG_AddTrustee, /* NSS_ADDTRUSTEE */ + COMN_AsyncRead, /* NSS_ASYNCREAD */ + MSG_BeginTask, /* NSS_BEGINTASK */ + MSG_BeginUserXaction, /* NSS_BEGINXACTION */ + MSG_ChangeConnection, /* NSS_CHANGECONNECTION */ + MSG_CommitUserXaction, /* NSS_COMMITXACTION */ + MSG_Create, /* NSS_CREATE */ + MSG_Delete, /* NSS_DELETE */ + MSG_DeleteTrustee, /* NSS_DELETETRUSTEE */ + COMN_DirectReadFile, /* NSS_DIOREAD */ + COMN_DirectWriteFile, /* NSS_DIOWRITE */ + MSG_EndTask, /* NSS_ENDTASK */ + MSG_Flush, /* NSS_FLUSH */ + MSG_GetFileMap, /* NSS_GETFILEMAP */ + MSG_GetInfo, /* NSS_GETINFO */ + MSG_GetInheritedRightsMask, /* NSS_GETINHERITEDRIGHTSMASK */ + MSG_GetTrustee, /* NSS_GETTRUSTEE */ + MSG_IsNSS, /* NSS_ISNSS */ + MSG_Link, /* NSS_LINK */ + MSG_LockByteRange, /* NSS_LOCKBYTERANGE */ + MSG_ModifyInfo, /* NSS_MODIFYINFO */ + MSG_Open, /* NSS_OPEN */ + MSG_ZidOpen, /* NSS_ZID_OPEN */ + MSG_ChunkyRead, /* NSS_READ */ + MSG_Rename, /* NSS_RENAME */ + COMN_SetEOF, /* NSS_SETEOF */ + MSG_SetInheritedRightsMask, /* NSS_SETINHERITEDRIGHTSMASK */ + COMN_StartAsyncRead, /* NSS_START_ASYNCREAD */ + MSG_UnlockByteRange, /* NSS_UNLOCKBYTERANGE */ + MSG_WildRead, /* NSS_WILDREAD */ + MSG_WildRewind, /* NSS_WILDREWIND */ + COMN_Write, /* NSS_WRITE */ + MSG_Enumerate, /* NSS_ENUMERATE */ + MSG_GetEffectiveRights, /* NSS_GET_EFFECTIVE_RIGHTS */ + MSG_ZidDelete, /* NSS_ZID_DELETE */ + MSG_ZidCreate, /* NSS_ZID_CREATE */ + MSG_ZidLink, /* NSS_ZID_LINK */ + MSG_ZidRename, /* NSS_ZID_RENAME */ + MSG_FileControl, /* NSS_FILE_CONTROL */ + MSG_GetInfoByName, /* NSS_GETINFOBYNAME */ + MSG_ModifyInfoByName, /* NSS_MODIFYINFOBYNAME */ + NullMethod /* NSS_NEWCONNECTION */ } }; @@ -226,50 +220,50 @@ FileHandleType_s VirtualType = NSS_NUM_METHODS, NULL, NULL, VIRT_Close, MSG_Notify, MSG_BreakDoor), { - FSMSG_METHOD(FH_Resolve), /* NSS_RESOLVE_FILEHANDLE */ - FSMSG_METHOD(MSG_AbortUserXaction), /* NSS_ABORTXACTION */ - FSMSG_METHOD(MSG_AddTrustee), /* NSS_ADDTRUSTEE */ - FSMSG_METHOD(NullMethod), /* NSS_ASYNCREAD */ - FSMSG_METHOD(MSG_BeginTask), /* NSS_BEGINTASK */ - FSMSG_METHOD(MSG_BeginUserXaction), /* NSS_BEGINXACTION */ - FSMSG_METHOD(MSG_ChangeConnection), /* NSS_CHANGECONNECTION */ - FSMSG_METHOD(MSG_CommitUserXaction), /* NSS_COMMITXACTION */ - FSMSG_METHOD(MSG_Create), /* NSS_CREATE */ - FSMSG_METHOD(MSG_Delete), /* NSS_DELETE */ - FSMSG_METHOD(MSG_DeleteTrustee), /* NSS_DELETETRUSTEE */ - FSMSG_METHOD(COMN_DirectReadFile), /* NSS_DIOREAD */ - FSMSG_METHOD(COMN_DirectWriteFile), /* NSS_DIOWRITE */ - FSMSG_METHOD(MSG_EndTask), /* NSS_ENDTASK */ - FSMSG_METHOD(MSG_Flush), /* NSS_FLUSH */ - FSMSG_METHOD(MSG_GetFileMap), /* NSS_GETFILEMAP */ - FSMSG_METHOD(MSG_GetInfo), /* NSS_GETINFO */ - FSMSG_METHOD(MSG_GetInheritedRightsMask), /* NSS_GETINHERITEDRIGHTSMASK */ - FSMSG_METHOD(MSG_GetTrustee), /* NSS_GETTRUSTEE */ - FSMSG_METHOD(MSG_IsNSS), /* NSS_ISNSS */ - FSMSG_METHOD(MSG_Link), /* NSS_LINK */ - FSMSG_METHOD(MSG_LockByteRange), /* NSS_LOCKBYTERANGE */ - FSMSG_METHOD(MSG_ModifyInfo), /* NSS_MODIFYINFO */ - FSMSG_METHOD(MSG_Open), /* NSS_OPEN */ - FSMSG_METHOD(MSG_ZidOpen), /* NSS_ZID_OPEN */ - FSMSG_METHOD(VIRT_ChunkyRead), /* NSS_READ */ - FSMSG_METHOD(MSG_Rename), /* NSS_RENAME */ - FSMSG_METHOD(COMN_SetEOF), /* NSS_SETEOF */ - FSMSG_METHOD(MSG_SetInheritedRightsMask), /* NSS_SETINHERITEDRIGHTSMASK */ - FSMSG_METHOD(COMN_StartAsyncRead), /* NSS_START_ASYNCREAD */ - FSMSG_METHOD(MSG_UnlockByteRange), /* NSS_UNLOCKBYTERANGE */ - FSMSG_METHOD(MSG_WildRead), /* NSS_WILDREAD */ - FSMSG_METHOD(MSG_WildRewind), /* NSS_WILDREWIND */ - FSMSG_METHOD(VIRT_Write), /* NSS_WRITE */ - FSMSG_METHOD(MSG_Enumerate), /* NSS_ENUMERATE */ - FSMSG_METHOD(MSG_GetEffectiveRights), /* NSS_GET_EFFECTIVE_RIGHTS */ - FSMSG_METHOD(MSG_ZidDelete), /* NSS_ZID_DELETE */ - FSMSG_METHOD(MSG_ZidCreate), /* NSS_ZID_CREATE */ - FSMSG_METHOD(MSG_ZidLink), /* NSS_ZID_LINK */ - FSMSG_METHOD(MSG_ZidRename), /* NSS_ZID_RENAME */ - FSMSG_METHOD(NullMethod), /* NSS_FILE_CONTROL */ - FSMSG_METHOD(MSG_GetInfoByName), /* NSS_GETINFOBYNAME */ - FSMSG_METHOD(MSG_ModifyInfoByName), /* NSS_MODIFYINFOBYNAME */ - FSMSG_METHOD(NullMethod) /* NSS_NEWCONNECTION */ + FH_Resolve, /* NSS_RESOLVE_FILEHANDLE */ + MSG_AbortUserXaction, /* NSS_ABORTXACTION */ + MSG_AddTrustee, /* NSS_ADDTRUSTEE */ + NullMethod, /* NSS_ASYNCREAD */ + MSG_BeginTask, /* NSS_BEGINTASK */ + MSG_BeginUserXaction, /* NSS_BEGINXACTION */ + MSG_ChangeConnection, /* NSS_CHANGECONNECTION */ + MSG_CommitUserXaction, /* NSS_COMMITXACTION */ + MSG_Create, /* NSS_CREATE */ + MSG_Delete, /* NSS_DELETE */ + MSG_DeleteTrustee, /* NSS_DELETETRUSTEE */ + COMN_DirectReadFile, /* NSS_DIOREAD */ + COMN_DirectWriteFile, /* NSS_DIOWRITE */ + MSG_EndTask, /* NSS_ENDTASK */ + MSG_Flush, /* NSS_FLUSH */ + MSG_GetFileMap, /* NSS_GETFILEMAP */ + MSG_GetInfo, /* NSS_GETINFO */ + MSG_GetInheritedRightsMask, /* NSS_GETINHERITEDRIGHTSMASK */ + MSG_GetTrustee, /* NSS_GETTRUSTEE */ + MSG_IsNSS, /* NSS_ISNSS */ + MSG_Link, /* NSS_LINK */ + MSG_LockByteRange, /* NSS_LOCKBYTERANGE */ + MSG_ModifyInfo, /* NSS_MODIFYINFO */ + MSG_Open, /* NSS_OPEN */ + MSG_ZidOpen, /* NSS_ZID_OPEN */ + VIRT_ChunkyRead, /* NSS_READ */ + MSG_Rename, /* NSS_RENAME */ + COMN_SetEOF, /* NSS_SETEOF */ + MSG_SetInheritedRightsMask, /* NSS_SETINHERITEDRIGHTSMASK */ + COMN_StartAsyncRead, /* NSS_START_ASYNCREAD */ + MSG_UnlockByteRange, /* NSS_UNLOCKBYTERANGE */ + MSG_WildRead, /* NSS_WILDREAD */ + MSG_WildRewind, /* NSS_WILDREWIND */ + VIRT_Write, /* NSS_WRITE */ + MSG_Enumerate, /* NSS_ENUMERATE */ + MSG_GetEffectiveRights, /* NSS_GET_EFFECTIVE_RIGHTS */ + MSG_ZidDelete, /* NSS_ZID_DELETE */ + MSG_ZidCreate, /* NSS_ZID_CREATE */ + MSG_ZidLink, /* NSS_ZID_LINK */ + MSG_ZidRename, /* NSS_ZID_RENAME */ + NullMethod, /* NSS_FILE_CONTROL */ + MSG_GetInfoByName, /* NSS_GETINFOBYNAME */ + MSG_ModifyInfoByName, /* NSS_MODIFYINFOBYNAME */ + NullMethod /* NSS_NEWCONNECTION */ } }; @@ -279,50 +273,50 @@ FileHandleType_s MigratedType = NSS_NUM_METHODS, NULL, NULL, COMN_Close, MSG_Notify, MSG_BreakDoor), { - FSMSG_METHOD(FH_Resolve), /* NSS_RESOLVE_FILEHANDLE */ - FSMSG_METHOD(MSG_AbortUserXaction), /* NSS_ABORTXACTION */ - FSMSG_METHOD(MSG_AddTrustee), /* NSS_ADDTRUSTEE */ - FSMSG_METHOD(DEMIGRATE_AsyncRead), /* NSS_ASYNCREAD */ - FSMSG_METHOD(MSG_BeginTask), /* NSS_BEGINTASK */ - FSMSG_METHOD(MSG_BeginUserXaction), /* NSS_BEGINXACTION */ - FSMSG_METHOD(MSG_ChangeConnection), /* NSS_CHANGECONNECTION */ - FSMSG_METHOD(MSG_CommitUserXaction), /* NSS_COMMITXACTION */ - FSMSG_METHOD(MSG_Create), /* NSS_CREATE */ - FSMSG_METHOD(MSG_Delete), /* NSS_DELETE */ - FSMSG_METHOD(MSG_DeleteTrustee), /* NSS_DELETETRUSTEE */ - FSMSG_METHOD(COMN_DirectReadFile), /* NSS_DIOREAD */ - FSMSG_METHOD(COMN_DirectWriteFile), /* NSS_DIOWRITE */ - FSMSG_METHOD(MSG_EndTask), /* NSS_ENDTASK */ - FSMSG_METHOD(MSG_Flush), /* NSS_FLUSH */ - FSMSG_METHOD(MSG_GetFileMap), /* NSS_GETFILEMAP */ - FSMSG_METHOD(MSG_GetInfo), /* NSS_GETINFO */ - FSMSG_METHOD(MSG_GetInheritedRightsMask), /* NSS_GETINHERITEDRIGHTSMASK */ - FSMSG_METHOD(MSG_GetTrustee), /* NSS_GETTRUSTEE */ - FSMSG_METHOD(MSG_IsNSS), /* NSS_ISNSS */ - FSMSG_METHOD(MSG_Link), /* NSS_LINK */ - FSMSG_METHOD(MSG_LockByteRange), /* NSS_LOCKBYTERANGE */ - FSMSG_METHOD(MSG_ModifyInfo), /* NSS_MODIFYINFO */ - FSMSG_METHOD(MSG_Open), /* NSS_OPEN */ - FSMSG_METHOD(MSG_ZidOpen), /* NSS_ZID_OPEN */ - FSMSG_METHOD(DEMIGRATE_ChunkyRead), /* NSS_READ */ - FSMSG_METHOD(MSG_Rename), /* NSS_RENAME */ - FSMSG_METHOD(DEMIGRATE_SetEOF), /* NSS_SETEOF */ - FSMSG_METHOD(MSG_SetInheritedRightsMask), /* NSS_SETINHERITEDRIGHTSMASK */ - FSMSG_METHOD(COMN_StartAsyncRead), /* NSS_START_ASYNCREAD */ - FSMSG_METHOD(MSG_UnlockByteRange), /* NSS_UNLOCKBYTERANGE */ - FSMSG_METHOD(MSG_WildRead), /* NSS_WILDREAD */ - FSMSG_METHOD(MSG_WildRewind), /* NSS_WILDREWIND */ - FSMSG_METHOD(DEMIGRATE_Write), /* NSS_WRITE */ - FSMSG_METHOD(MSG_Enumerate), /* NSS_ENUMERATE */ - FSMSG_METHOD(MSG_GetEffectiveRights), /* NSS_GET_EFFECTIVE_RIGHTS */ - FSMSG_METHOD(MSG_ZidDelete), /* NSS_ZID_DELETE */ - FSMSG_METHOD(MSG_ZidCreate), /* NSS_ZID_CREATE */ - FSMSG_METHOD(MSG_ZidLink), /* NSS_ZID_LINK */ - FSMSG_METHOD(MSG_ZidRename), /* NSS_ZID_RENAME */ - FSMSG_METHOD(MSG_FileControl), /* NSS_FILE_CONTROL */ - FSMSG_METHOD(MSG_GetInfoByName), /* NSS_GETINFOBYNAME */ - FSMSG_METHOD(MSG_ModifyInfoByName), /* NSS_MODIFYINFOBYNAME */ - FSMSG_METHOD(NullMethod) /* NSS_NEWCONNECTION */ + FH_Resolve, /* NSS_RESOLVE_FILEHANDLE */ + MSG_AbortUserXaction, /* NSS_ABORTXACTION */ + MSG_AddTrustee, /* NSS_ADDTRUSTEE */ + DEMIGRATE_AsyncRead, /* NSS_ASYNCREAD */ + MSG_BeginTask, /* NSS_BEGINTASK */ + MSG_BeginUserXaction, /* NSS_BEGINXACTION */ + MSG_ChangeConnection, /* NSS_CHANGECONNECTION */ + MSG_CommitUserXaction, /* NSS_COMMITXACTION */ + MSG_Create, /* NSS_CREATE */ + MSG_Delete, /* NSS_DELETE */ + MSG_DeleteTrustee, /* NSS_DELETETRUSTEE */ + COMN_DirectReadFile, /* NSS_DIOREAD */ + COMN_DirectWriteFile, /* NSS_DIOWRITE */ + MSG_EndTask, /* NSS_ENDTASK */ + MSG_Flush, /* NSS_FLUSH */ + MSG_GetFileMap, /* NSS_GETFILEMAP */ + MSG_GetInfo, /* NSS_GETINFO */ + MSG_GetInheritedRightsMask, /* NSS_GETINHERITEDRIGHTSMASK */ + MSG_GetTrustee, /* NSS_GETTRUSTEE */ + MSG_IsNSS, /* NSS_ISNSS */ + MSG_Link, /* NSS_LINK */ + MSG_LockByteRange, /* NSS_LOCKBYTERANGE */ + MSG_ModifyInfo, /* NSS_MODIFYINFO */ + MSG_Open, /* NSS_OPEN */ + MSG_ZidOpen, /* NSS_ZID_OPEN */ + DEMIGRATE_ChunkyRead, /* NSS_READ */ + MSG_Rename, /* NSS_RENAME */ + DEMIGRATE_SetEOF, /* NSS_SETEOF */ + MSG_SetInheritedRightsMask, /* NSS_SETINHERITEDRIGHTSMASK */ + COMN_StartAsyncRead, /* NSS_START_ASYNCREAD */ + MSG_UnlockByteRange, /* NSS_UNLOCKBYTERANGE */ + MSG_WildRead, /* NSS_WILDREAD */ + MSG_WildRewind, /* NSS_WILDREWIND */ + DEMIGRATE_Write, /* NSS_WRITE */ + MSG_Enumerate, /* NSS_ENUMERATE */ + MSG_GetEffectiveRights, /* NSS_GET_EFFECTIVE_RIGHTS */ + MSG_ZidDelete, /* NSS_ZID_DELETE */ + MSG_ZidCreate, /* NSS_ZID_CREATE */ + MSG_ZidLink, /* NSS_ZID_LINK */ + MSG_ZidRename, /* NSS_ZID_RENAME */ + MSG_FileControl, /* NSS_FILE_CONTROL */ + MSG_GetInfoByName, /* NSS_GETINFOBYNAME */ + MSG_ModifyInfoByName, /* NSS_MODIFYINFOBYNAME */ + NullMethod /* NSS_NEWCONNECTION */ } }; @@ -332,50 +326,50 @@ FileHandleType_s RootType = NSS_NUM_METHODS, NULL, NULL, MSG_CloseRootKey, MSG_Notify, MSG_BreakDoor), { - FSMSG_METHOD(FH_Resolve), /* NSS_RESOLVE_FILEHANDLE */ - FSMSG_METHOD(MSG_AbortUserXaction), /* NSS_ABORTXACTION */ - FSMSG_METHOD(NullMethod), /* NSS_ASYNCREAD */ - FSMSG_METHOD(NullMethod), /* NSS_ADDTRUSTEE */ - FSMSG_METHOD(MSG_BeginTask), /* NSS_BEGINTASK */ - FSMSG_METHOD(MSG_BeginUserXaction), /* NSS_BEGINXACTION */ - FSMSG_METHOD(MSG_ChangeConnection), /* NSS_CHANGECONNECTION */ - FSMSG_METHOD(MSG_CommitUserXaction), /* NSS_COMMITXACTION */ - FSMSG_METHOD(MSG_Create), /* NSS_CREATE */ - FSMSG_METHOD(MSG_Delete), /* NSS_DELETE */ - FSMSG_METHOD(NullMethod), /* NSS_DELETETRUSTEE */ - FSMSG_METHOD(NullMethod), /* NSS_DIOREAD */ - FSMSG_METHOD(NullMethod), /* NSS_DIOWRITE */ - FSMSG_METHOD(MSG_EndTask), /* NSS_ENDTASK */ - FSMSG_METHOD(NullMethod), /* NSS_FLUSH */ - FSMSG_METHOD(NullMethod), /* NSS_GETFILEMAP */ - FSMSG_METHOD(NullMethod), /* NSS_GETINFO */ - FSMSG_METHOD(NullMethod), /* NSS_GETINHERITEDRIGHTSMASK */ - FSMSG_METHOD(NullMethod), /* NSS_GETTRUSTEE */ - FSMSG_METHOD(MSG_IsNSS), /* NSS_ISNSS */ - FSMSG_METHOD(MSG_Link), /* NSS_LINK */ - FSMSG_METHOD(NullMethod), /* NSS_LOCKBYTERANGE */ - FSMSG_METHOD(NullMethod), /* NSS_MODIFYINFO */ - FSMSG_METHOD(MSG_Open), /* NSS_OPEN */ - FSMSG_METHOD(MSG_ZidOpen), /* NSS_ZID_OPEN */ - FSMSG_METHOD(NullMethod), /* NSS_READ */ - FSMSG_METHOD(MSG_Rename), /* NSS_RENAME */ - FSMSG_METHOD(NullMethod), /* NSS_SETEOF */ - FSMSG_METHOD(NullMethod), /* NSS_SETINHERITEDRIGHTSMASK */ - FSMSG_METHOD(NullMethod), /* NSS_START_ASYNCREAD */ - FSMSG_METHOD(NullMethod), /* NSS_UNLOCKBYTERANGE */ - FSMSG_METHOD(NullMethod), /* NSS_WILDREAD */ - FSMSG_METHOD(NullMethod), /* NSS_WILDREWIND */ - FSMSG_METHOD(NullMethod), /* NSS_WRITE */ - FSMSG_METHOD(NullMethod), /* NSS_ENUMERATE */ - FSMSG_METHOD(NullMethod), /* NSS_GET_EFFECTIVE_RIGHTS */ - FSMSG_METHOD(MSG_ZidDelete), /* NSS_ZID_DELETE */ - FSMSG_METHOD(MSG_ZidCreate), /* NSS_ZID_CREATE */ - FSMSG_METHOD(MSG_ZidLink), /* NSS_ZID_LINK */ - FSMSG_METHOD(MSG_ZidRename), /* NSS_ZID_RENAME */ - FSMSG_METHOD(NullMethod), /* NSS_FILE_CONTROL */ - FSMSG_METHOD(MSG_GetInfoByName), /* NSS_GETINFOBYNAME */ - FSMSG_METHOD(MSG_ModifyInfoByName), /* NSS_MODIFYINFOBYNAME */ - FSMSG_METHOD(MSG_NewConnection) /* NSS_NEWCONNECTION */ + FH_Resolve, /* NSS_RESOLVE_FILEHANDLE */ + MSG_AbortUserXaction, /* NSS_ABORTXACTION */ + NullMethod, /* NSS_ASYNCREAD */ + NullMethod, /* NSS_ADDTRUSTEE */ + MSG_BeginTask, /* NSS_BEGINTASK */ + MSG_BeginUserXaction, /* NSS_BEGINXACTION */ + MSG_ChangeConnection, /* NSS_CHANGECONNECTION */ + MSG_CommitUserXaction, /* NSS_COMMITXACTION */ + MSG_Create, /* NSS_CREATE */ + MSG_Delete, /* NSS_DELETE */ + NullMethod, /* NSS_DELETETRUSTEE */ + NullMethod, /* NSS_DIOREAD */ + NullMethod, /* NSS_DIOWRITE */ + MSG_EndTask, /* NSS_ENDTASK */ + NullMethod, /* NSS_FLUSH */ + NullMethod, /* NSS_GETFILEMAP */ + NullMethod, /* NSS_GETINFO */ + NullMethod, /* NSS_GETINHERITEDRIGHTSMASK */ + NullMethod, /* NSS_GETTRUSTEE */ + MSG_IsNSS, /* NSS_ISNSS */ + MSG_Link, /* NSS_LINK */ + NullMethod, /* NSS_LOCKBYTERANGE */ + NullMethod, /* NSS_MODIFYINFO */ + MSG_Open, /* NSS_OPEN */ + MSG_ZidOpen, /* NSS_ZID_OPEN */ + NullMethod, /* NSS_READ */ + MSG_Rename, /* NSS_RENAME */ + NullMethod, /* NSS_SETEOF */ + NullMethod, /* NSS_SETINHERITEDRIGHTSMASK */ + NullMethod, /* NSS_START_ASYNCREAD */ + NullMethod, /* NSS_UNLOCKBYTERANGE */ + NullMethod, /* NSS_WILDREAD */ + NullMethod, /* NSS_WILDREWIND */ + NullMethod, /* NSS_WRITE */ + NullMethod, /* NSS_ENUMERATE */ + NullMethod, /* NSS_GET_EFFECTIVE_RIGHTS */ + MSG_ZidDelete, /* NSS_ZID_DELETE */ + MSG_ZidCreate, /* NSS_ZID_CREATE */ + MSG_ZidLink, /* NSS_ZID_LINK */ + MSG_ZidRename, /* NSS_ZID_RENAME */ + NullMethod, /* NSS_FILE_CONTROL */ + MSG_GetInfoByName, /* NSS_GETINFOBYNAME */ + MSG_ModifyInfoByName, /* NSS_MODIFYINFOBYNAME */ + MSG_NewConnection /* NSS_NEWCONNECTION */ } }; @@ -391,49 +385,49 @@ FileHandleType_s InternalEAHandleType = NSS_NUM_METHODS, NULL, NULL, EA_Close, NULL, MSG_BreakDoor), { - FSMSG_METHOD(FH_Resolve), /* NSS_RESOLVE_FILEHANDLE */ - FSMSG_METHOD(NullMethod), /* NSS_ABORTXACTION */ - FSMSG_METHOD(NullMethod), /* NSS_ADDTRUSTEE */ - FSMSG_METHOD(COMN_AsyncRead), /* NSS_ASYNCREAD */ - FSMSG_METHOD(NullMethod), /* NSS_BEGINTASK */ - FSMSG_METHOD(NullMethod), /* NSS_BEGINXACTION */ - FSMSG_METHOD(NullMethod), /* NSS_CHANGECONNECTION */ - FSMSG_METHOD(NullMethod), /* NSS_COMMITXACTION */ - FSMSG_METHOD(NullMethod), /* NSS_CREATE */ - FSMSG_METHOD(NullMethod), /* NSS_DELETE */ - FSMSG_METHOD(NullMethod), /* NSS_DELETETRUSTEE */ - FSMSG_METHOD(NullMethod), /* NSS_DIOREAD */ - FSMSG_METHOD(NullMethod), /* NSS_DIOWRITE */ - FSMSG_METHOD(NullMethod), /* NSS_ENDTASK */ - FSMSG_METHOD(NullMethod), /* NSS_FLUSH */ - FSMSG_METHOD(NullMethod), /* NSS_GETFILEMAP */ - FSMSG_METHOD(NullMethod), /* NSS_GETINFO */ - FSMSG_METHOD(NullMethod), /* NSS_GETINHERITEDRIGHTSMASK */ - FSMSG_METHOD(NullMethod), /* NSS_GETTRUSTEE */ - FSMSG_METHOD(NullMethod), /* NSS_ISNSS */ - FSMSG_METHOD(NullMethod), /* NSS_LINK */ - FSMSG_METHOD(NullMethod), /* NSS_LOCKBYTERANGE */ - FSMSG_METHOD(NullMethod), /* NSS_MODIFYINFO */ - FSMSG_METHOD(NullMethod), /* NSS_OPEN */ - FSMSG_METHOD(NullMethod), /* NSS_ZID_OPEN */ - FSMSG_METHOD(MSG_ChunkyRead), /* NSS_READ */ - FSMSG_METHOD(NullMethod), /* NSS_RENAME */ - FSMSG_METHOD(COMN_SetEOF), /* NSS_SETEOF */ - FSMSG_METHOD(NullMethod), /* NSS_SETINHERITEDRIGHTSMASK */ - FSMSG_METHOD(COMN_StartAsyncRead), /* NSS_START_ASYNCREAD */ - FSMSG_METHOD(NullMethod), /* NSS_UNLOCKBYTERANGE */ - FSMSG_METHOD(NullMethod), /* NSS_WILDREAD */ - FSMSG_METHOD(NullMethod), /* NSS_WILDREWIND */ - FSMSG_METHOD(COMN_Write), /* NSS_WRITE */ - FSMSG_METHOD(NullMethod), /* NSS_ENUMERATE */ - FSMSG_METHOD(NullMethod), /* NSS_GET_EFFECTIVE_RIGHTS */ - FSMSG_METHOD(NullMethod), /* NSS_ZID_DELETE */ - FSMSG_METHOD(NullMethod), /* NSS_ZID_RENAME */ - FSMSG_METHOD(NullMethod), /* NSS_ZID_CREATE */ - FSMSG_METHOD(NullMethod), /* NSS_FILE_CONTROL */ - FSMSG_METHOD(NullMethod), /* NSS_GETINFOBYNAME */ - FSMSG_METHOD(NullMethod), /* NSS_MODIFYINFOBYNAME */ - FSMSG_METHOD(NullMethod) /* NSS_NEWCONNECTION */ + FH_Resolve, /* NSS_RESOLVE_FILEHANDLE */ + NullMethod, /* NSS_ABORTXACTION */ + NullMethod, /* NSS_ADDTRUSTEE */ + COMN_AsyncRead, /* NSS_ASYNCREAD */ + NullMethod, /* NSS_BEGINTASK */ + NullMethod, /* NSS_BEGINXACTION */ + NullMethod, /* NSS_CHANGECONNECTION */ + NullMethod, /* NSS_COMMITXACTION */ + NullMethod, /* NSS_CREATE */ + NullMethod, /* NSS_DELETE */ + NullMethod, /* NSS_DELETETRUSTEE */ + NullMethod, /* NSS_DIOREAD */ + NullMethod, /* NSS_DIOWRITE */ + NullMethod, /* NSS_ENDTASK */ + NullMethod, /* NSS_FLUSH */ + NullMethod, /* NSS_GETFILEMAP */ + NullMethod, /* NSS_GETINFO */ + NullMethod, /* NSS_GETINHERITEDRIGHTSMASK */ + NullMethod, /* NSS_GETTRUSTEE */ + NullMethod, /* NSS_ISNSS */ + NullMethod, /* NSS_LINK */ + NullMethod, /* NSS_LOCKBYTERANGE */ + NullMethod, /* NSS_MODIFYINFO */ + NullMethod, /* NSS_OPEN */ + NullMethod, /* NSS_ZID_OPEN */ + MSG_ChunkyRead, /* NSS_READ */ + NullMethod, /* NSS_RENAME */ + COMN_SetEOF, /* NSS_SETEOF */ + NullMethod, /* NSS_SETINHERITEDRIGHTSMASK */ + COMN_StartAsyncRead, /* NSS_START_ASYNCREAD */ + NullMethod, /* NSS_UNLOCKBYTERANGE */ + NullMethod, /* NSS_WILDREAD */ + NullMethod, /* NSS_WILDREWIND */ + COMN_Write, /* NSS_WRITE */ + NullMethod, /* NSS_ENUMERATE */ + NullMethod, /* NSS_GET_EFFECTIVE_RIGHTS */ + NullMethod, /* NSS_ZID_DELETE */ + NullMethod, /* NSS_ZID_RENAME */ + NullMethod, /* NSS_ZID_CREATE */ + NullMethod, /* NSS_FILE_CONTROL */ + NullMethod, /* NSS_GETINFOBYNAME */ + NullMethod, /* NSS_MODIFYINFOBYNAME */ + NullMethod /* NSS_NEWCONNECTION */ } }; @@ -611,7 +605,7 @@ void fileHandleToNamingMsg (FileHandle_s *fh, NamingMsg_s *nameMsg) { File_s *file = fh->file; NamedBeast_s *dataStream = fh->dataStream; - + ASSERT_MPKNSS_LOCK(); zASSERT(COMN_IsDerivedFrom(file, zFTYPE_FILE)); @@ -717,7 +711,7 @@ STATUS MSG_AbortUserXaction (zNSSMsg_s *msg) RTN_STATUS(zFAILURE); } COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE( &genMsg); - + status = COMN_AbortUserXaction( &genMsg, uxaction); if (status != zOK) { @@ -753,7 +747,7 @@ STATUS MSG_BeginUserXaction (zNSSMsg_s *msg) SetStatus(msg, zERR_NESTED_XACTIONS_NOT_IMPLIMENTED); RTN_STATUS(zFAILURE); - /* We will do nested transactions later + /* We will do nested transactions later // parentXaction = lookupActiveXaction(msg->body.id.xid); // if (parentXaction == NULL) @@ -812,20 +806,20 @@ STATUS MSG_CommitUserXaction (zNSSMsg_s *msg) STATUS MSG_BeginTask( zNSSMsg_s *msg) -{ +{ GeneralMsg_s genMsg; STATUS status; - + COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE( &genMsg); - - status = COMN_BeginTask(&genMsg, + + status = COMN_BeginTask(&genMsg, (Master_s *)msg->sys.owner, (NINT *)&msg->body.id.taskID); if (status != zOK) { SetStatusFromErrno(msg,&genMsg); return(zFAILURE); } - + return(zOK); } @@ -837,17 +831,17 @@ STATUS MSG_EndTask( COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE( &genMsg); - status = COMN_EndTask(&genMsg, + status = COMN_EndTask(&genMsg, (Master_s *)msg->sys.owner, msg->body.id.taskID); if (status != zOK) { SetStatusFromErrno(msg,&genMsg); return(zFAILURE); } - + return(zOK); - -} + +} STATUS MSG_Create (zNSSMsg_s *msg) @@ -875,7 +869,7 @@ STATUS MSG_Create (zNSSMsg_s *msg) /* * Setup the name message */ - name = (msg->sys.numDataAreas == 0) ? NULL : FSMSG_DATA_VOID(msg->sys.data[PATH_DATA].start); + name = (msg->sys.numDataAreas == 0) ? NULL : msg->sys.data[PATH_DATA].start; status = MSG_InitNameMsg(msg, &aStack->nameMsg, name, msg->body.name.nameSpace, XLATCHED); if (status != zOK) @@ -971,7 +965,7 @@ STATUS MSG_ZidCreate (zNSSMsg_s *msg) /* * Setup the name message */ - name = (msg->sys.numDataAreas == 0) ? NULL : FSMSG_DATA_VOID(msg->sys.data[PATH_DATA].start); + name = (msg->sys.numDataAreas == 0) ? NULL : msg->sys.data[PATH_DATA].start; status = MSG_InitZidNameMsg(msg, &aStack->nameMsg, msg->body.byZid.zid, name, nameSpace, XLATCHED); if (status != zOK) @@ -1050,7 +1044,7 @@ STATUS MSG_Delete (zNSSMsg_s *msg) /* * Need to do something with match */ - name = (msg->sys.numDataAreas == 0) ? NULL : FSMSG_DATA_VOID(msg->sys.data[PATH_DATA].start); + name = (msg->sys.numDataAreas == 0) ? NULL : msg->sys.data[PATH_DATA].start; status = MSG_InitNameMsg(msg, &aStack->nameMsg, name, msg->body.name.nameSpace, XLATCHED); if (status != zOK) @@ -1252,7 +1246,7 @@ STATUS LSA_setSearchMap ( status = WILD_enumSearchForFile(genMsg, dir, nameSpace, workBuf, smap, fullDirInfo); smap->options = saveOptions; - + if (status != zOK) { goto error_releaseWork; @@ -1321,7 +1315,7 @@ STATUS WILD_setSearchMap ( * } * } */ - /* + /* * Load the beast for the given ZID and extract the name * and release the beast. */ @@ -1344,7 +1338,7 @@ STATUS WILD_setSearchMap ( workBuf, smap, &aStack->fullDirInfo); COMN_Release( &workNameSpace); smap->options = saveOptions; - + if (status != zOK) { goto error_releaseWork; @@ -1400,7 +1394,7 @@ STATUS MSG_Enumerate (zNSSMsg_s *msg) SearchMsg_s searchMsg; GetInfoMsg_s infoMsg; zMatchAttr_s matchAttr; - zInfo_s *info = FSMSG_DATA_PTR(zInfo_s, msg->sys.data[INFO_DATA].start); + zInfo_s *info = (zInfo_s *)msg->sys.data[INFO_DATA].start; File_s *file; typedef struct Stack_s { @@ -1452,7 +1446,7 @@ STATUS MSG_Enumerate (zNSSMsg_s *msg) fh->dataStreamNameSpaceID, info, msg->sys.data[INFO_DATA].length, - msg->body.wild.version, + msg->body.wild.version, msg->body.id.externalFlags, &info->vol, sizeof(zVolumeInfo_s)); @@ -1502,7 +1496,7 @@ STATUS uni2uni ( *retNextUniInput = ++uniInput; return zOK; } - + STATUS getVolName ( CONST utf8_t *path, unicode_t *name, @@ -1515,7 +1509,7 @@ STATUS getVolName ( for (i = 0; i < len; ++i) { - status = ((FSMSG_NextCharFunc_t)nextCh)(path, &path, &ch); + status = nextCh(path, &path, &ch); if (status != zOK) { return status; @@ -1540,7 +1534,7 @@ STATUS MSG_IsNSS (zNSSMsg_s *msg) STATUS status; GeneralMsg_s genMsg; Volume_s *vol; - utf8_t *path = FSMSG_DATA_VOID(msg->sys.data[PATH_DATA].start); + utf8_t *path = msg->sys.data[PATH_DATA].start; typedef struct Stack_s { unicode_t name[zMAX_COMPONENT_NAME+1]; @@ -1549,7 +1543,7 @@ STATUS MSG_IsNSS (zNSSMsg_s *msg) status = getVolName(path, aStack->name, zMAX_COMPONENT_NAME, (msg->body.name.nameSpace & zMODE_UTF8) - ? (statusfunc_t)LB_UTF8ToUniChar : (statusfunc_t)uni2uni); + ? LB_UTF8ToUniChar : uni2uni); if (status != zOK) { SetStatus(msg, status); @@ -1587,7 +1581,7 @@ STATUS MSG_NewConnection (zNSSMsg_s *msg) SetStatus(msg, zERR_BAD_METHOD); return zFAILURE; } - fdn = FSMSG_DATA_PTR(unicode_t, msg->sys.data[FDN_DATA].start); + fdn = msg->sys.data[FDN_DATA].start; fdn[msg->sys.data[FDN_DATA].length/sizeof(unicode_t) - 1] = 0; nssConn = MSG_CreateConnection(fdn); @@ -1619,7 +1613,7 @@ STATUS MSG_Open (zNSSMsg_s *msg) ASSERT_MPKNSS_LOCK(); - name = (msg->sys.numDataAreas == 0) ? NULL : FSMSG_DATA_VOID(msg->sys.data[PATH_DATA].start); + name = (msg->sys.numDataAreas == 0) ? NULL : msg->sys.data[PATH_DATA].start; status = MSG_InitNameMsg(msg, &aStack->nameMsg, name, msg->body.name.nameSpace, XLATCHED); aStack->nameMsg.parseMode = NAMPMODE_FullyResolveAny; @@ -1744,7 +1738,7 @@ STATUS getAllocationFileMap (zNSSMsg_s *msg) COMN_STRUCT_INIT(mapMsg); COMN_SETUP_FILE_MAP_MSG( &mapMsg, msg->body.map.offset, count, - zFILEMAP_ALLOCATION, FSMSG_DATA_VOID(msg->sys.data[MAP_DATA].start)); + zFILEMAP_ALLOCATION, msg->sys.data[MAP_DATA].start); COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE( &genMsg); status = COMN_GetFileMap( &genMsg, &mapMsg, &fileHandleIDP); @@ -1921,9 +1915,9 @@ void getVolumesPoolInfo (Volume_s *vol, zInfo_s *info) info->pool.features.supported = 0; //vol->VOLsupportedAttributes; info->pool.totalSpace = vol->VOLtotalBlocks << vol->VOLblockShift; - info->pool.numUsedBytes = (vol->VOLinUseBlocks + - vol->VOLfreeBlockAdjustment) - << vol->VOLblockShift; + info->pool.numUsedBytes = (vol->VOLinUseBlocks + + vol->VOLfreeBlockAdjustment) + << vol->VOLblockShift; info->pool.purgeableBytes = vol->VOLpurgeableBlocks << vol->VOLblockShift; info->pool.nonPurgeableBytes = vol->VOLnonPurgeableBlocks @@ -1972,11 +1966,11 @@ void getVolInfo (Volume_s *vol, zInfo_s *info) status = COMN_LockVolumeActive(&genMsg, vol, FALSE ); if ( status == zOK ) { - info->vol.ndsObjectID = vol->p.ndsObjectID; + info->vol.ndsObjectID = vol->p.ndsObjectID; info->vol.nameSpaceMask = vol->p.nameSpaceMask; info->vol.features.enabled = vol->p.enabledAttributes; info->vol.features.supported = vol->supportedAttributes; - info->vol.maximumFileSize = vol->maximumFileSize; + info->vol.maximumFileSize = vol->maximumFileSize; info->vol.totalSpaceQuota = vol->logged.totalBlocks << vol->VOLblockShift; info->vol.numUsedBytes = (vol->logged.inUseBlocks + vol->VOLfreeBlockAdjustment) << vol->VOLblockShift; info->vol.numObjects = vol->logged.numObjects; @@ -2042,7 +2036,7 @@ void messageInfo (zNSSMsg_s *msg, File_s *file, zInfo_s *info) if (msg->body.id.externalFlags & zGET_POOL_INFO) { getPoolInfo(pool, info); - info->retMask = msg->body.id.externalFlags & + info->retMask = msg->body.id.externalFlags & ~(zGET_VOLUME_INFO | zGET_VOL_SALVAGE_INFO); } return; @@ -2075,7 +2069,7 @@ void messageInfo (zNSSMsg_s *msg, File_s *file, zInfo_s *info) STATUS MSG_GetInfo (zNSSMsg_s *msg) { FileHandle_s *fh = STRUCT(msg->sys.door, FileHandle_s, door); - zInfo_s *info = FSMSG_DATA_PTR(zInfo_s, msg->sys.data[INFO_DATA].start); + zInfo_s *info = (zInfo_s *)msg->sys.data[INFO_DATA].start; STATUS status; GeneralMsg_s genMsg; @@ -2095,7 +2089,7 @@ STATUS MSG_GetInfo (zNSSMsg_s *msg) COMN_SETUP_GET_TYPE_INFO_MSG( &infoMsg, msg->body.id.externalFlags, fh->fileNameSpaceID, info, msg->sys.data[INFO_DATA].length, - msg->body.info.version, + msg->body.info.version, msg->body.id.externalFlags, &info->vol, sizeof(zVolumeInfo_s)); @@ -2131,7 +2125,7 @@ STATUS MSG_GetInfo (zNSSMsg_s *msg) STATUS MSG_GetInfoByName (zNSSMsg_s *msg) { FileHandle_s *fh = STRUCT(msg->sys.door, FileHandle_s, door); - zInfo_s *info = FSMSG_DATA_PTR(zInfo_s, msg->sys.data[INFO_DATA].start); + zInfo_s *info = (zInfo_s *)msg->sys.data[INFO_DATA].start; void *name; STATUS status; @@ -2158,7 +2152,7 @@ STATUS MSG_GetInfoByName (zNSSMsg_s *msg) return zFAILURE; } - name = (msg->sys.numDataAreas == 1) ? NULL : FSMSG_DATA_VOID(msg->sys.data[PATH_FOR_INFO_DATA].start); + name = (msg->sys.numDataAreas == 1) ? NULL : msg->sys.data[PATH_FOR_INFO_DATA].start; status = MSG_InitNameMsg(msg, &aStack->nameMsg, name, msg->body.name.nameSpace, SLATCHED); aStack->nameMsg.parseMode = NAMPMODE_FullyResolveAny; @@ -2171,7 +2165,7 @@ STATUS MSG_GetInfoByName (zNSSMsg_s *msg) COMN_SETUP_GET_TYPE_INFO_MSG( &infoMsg, msg->body.id.externalFlags, fh->fileNameSpaceID, info, msg->sys.data[INFO_DATA].length, - msg->body.infoByName.version, + msg->body.infoByName.version, msg->body.id.externalFlags, &info->vol, sizeof(zVolumeInfo_s)); @@ -2228,7 +2222,7 @@ STATUS MSG_Link (zNSSMsg_s *msg) COMN_INCLUDE_INTERNAL_VOLUMES( &genMsg ); status = MSG_InitNameMsg(msg, &aStack->srcNameMsg, - FSMSG_DATA_VOID(msg->sys.data[PATH_DATA].start), + msg->sys.data[PATH_DATA].start, msg->body.name.nameSpace, XLATCHED); if (status != zOK) { @@ -2240,7 +2234,7 @@ STATUS MSG_Link (zNSSMsg_s *msg) msg->body.dst.srcMatch); status = MSG_InitNameMsg(msg, &aStack->destNameMsg, - FSMSG_DATA_VOID(msg->sys.data[DSTPATH_DATA].start), + msg->sys.data[DSTPATH_DATA].start, msg->body.dst.nameSpace, XLATCHED); if (status != zOK) { @@ -2329,14 +2323,14 @@ STATUS MSG_ZidLink (zNSSMsg_s *msg) if (msg->body.byZid.dstZid == 0) { status = MSG_InitNameMsg(msg, &aStack->destNameMsg, - FSMSG_DATA_VOID(msg->sys.data[PATH_DATA].start), + msg->sys.data[PATH_DATA].start, msg->body.name.nameSpace, XLATCHED); } else { status = MSG_InitZidNameMsg(msg, &aStack->destNameMsg, msg->body.byZid.dstZid, - FSMSG_DATA_VOID(msg->sys.data[PATH_DATA].start), + msg->sys.data[PATH_DATA].start, msg->body.name.nameSpace, XLATCHED); } if (status != zOK) @@ -2375,11 +2369,11 @@ STATUS ModifyPoolVolumeInfo( if (file->FILEbstState & BST_STATE_IS_VOLUME_OR_POOL) { // This path has the _ADMIN volume locked active!!!? - /* since beast is either a volume or a pool, it shouldn't - * have any file information to modify + /* since beast is either a volume or a pool, it shouldn't + * have any file information to modify */ *continueWithFileOps = FALSE; - + if (COMN_IsDerivedFrom (file, zFTYPE_VOLUME)) { vol = (Volume_s *)file; @@ -2413,7 +2407,7 @@ STATUS ModifyPoolVolumeInfo( } X_LATCH(&pool->POOLbeastLatch); xaction = COMN_BeginXLocal(pool); - + status = pool->POOLcomnBeastOps.BST_modifyInfo( genMsg, &pool->POOLroot, infoMsg, xaction); @@ -2472,7 +2466,7 @@ BOOL bad_numEntries (void *info, QUAD length) STATUS MSG_ModifyInfo (zNSSMsg_s *msg) { FileHandle_s *fh = STRUCT(msg->sys.door, FileHandle_s, door); - zInfo_s *info = FSMSG_DATA_PTR(zInfo_s, msg->sys.data[INFO_DATA].start); + zInfo_s *info = (zInfo_s *)msg->sys.data[INFO_DATA].start; File_s *file = fh->file; QUAD mask = msg->body.id.externalFlags; GeneralMsg_s genMsg; @@ -2559,7 +2553,7 @@ cleanup_errorNoNameMsg: STATUS MSG_ModifyInfoByName (zNSSMsg_s *msg) { FileHandle_s *fh = STRUCT(msg->sys.door, FileHandle_s, door); - zInfo_s *info = FSMSG_DATA_PTR(zInfo_s, msg->sys.data[INFO_DATA].start); + zInfo_s *info = (zInfo_s *)msg->sys.data[INFO_DATA].start; File_s *file = fh->file; QUAD mask = msg->body.id.externalFlags; GeneralMsg_s genMsg; @@ -2598,7 +2592,7 @@ STATUS MSG_ModifyInfoByName (zNSSMsg_s *msg) } COMN_SETUP_GENERAL_MSG( &genMsg, fh->connID, zNO_TASK, zSAGENT_Z); - name = (msg->sys.numDataAreas == 1) ? NULL : FSMSG_DATA_VOID(msg->sys.data[PATH_FOR_INFO_DATA].start); + name = (msg->sys.numDataAreas == 1) ? NULL : msg->sys.data[PATH_FOR_INFO_DATA].start; status = MSG_InitNameMsg(msg, &aStack->nameMsg, name, msg->body.name.nameSpace, XLATCHED); aStack->nameMsg.parseMode = NAMPMODE_FullyResolveAny; @@ -2681,7 +2675,7 @@ STATUS MSG_Rename (zNSSMsg_s *msg) return zFAILURE; } status = MSG_InitNameMsg(msg, &aStack->srcNameMsg, - FSMSG_DATA_VOID(msg->sys.data[PATH_DATA].start), + msg->sys.data[PATH_DATA].start, msg->body.name.nameSpace, XLATCHED); if (status != zOK) { @@ -2693,7 +2687,7 @@ STATUS MSG_Rename (zNSSMsg_s *msg) msg->body.dst.srcMatch); status = MSG_InitNameMsg(msg, &aStack->destNameMsg, - FSMSG_DATA_VOID(msg->sys.data[DSTPATH_DATA].start), + msg->sys.data[DSTPATH_DATA].start, msg->body.dst.nameSpace, XLATCHED); if (status != zOK) { @@ -2783,14 +2777,14 @@ STATUS MSG_ZidRename (zNSSMsg_s *msg) if (msg->body.byZid.dstZid == 0) { status = MSG_InitNameMsg(msg, &aStack->destNameMsg, - FSMSG_DATA_VOID(msg->sys.data[PATH_DATA].start), + msg->sys.data[PATH_DATA].start, msg->body.name.nameSpace, XLATCHED); } else { status = MSG_InitZidNameMsg(msg, &aStack->destNameMsg, msg->body.byZid.dstZid, - FSMSG_DATA_VOID(msg->sys.data[PATH_DATA].start), + msg->sys.data[PATH_DATA].start, msg->body.name.nameSpace, XLATCHED); } if (status != zOK) @@ -2823,7 +2817,7 @@ STATUS MSG_WildRead (zNSSMsg_s *msg) SearchMsg_s searchMsg; GetInfoMsg_s infoMsg; zMatchAttr_s matchAttr; - zInfo_s *info = FSMSG_DATA_PTR(zInfo_s, msg->sys.data[INFO_DATA].start); + zInfo_s *info = (zInfo_s *)msg->sys.data[INFO_DATA].start; typedef struct Stack_s { NamingMsg_s nameMsg; } Stack_s; @@ -2857,7 +2851,7 @@ STATUS MSG_WildRead (zNSSMsg_s *msg) fh->dataStreamNameSpaceID, info, msg->sys.data[INFO_DATA].length, - msg->body.wild.version, + msg->body.wild.version, msg->body.id.externalFlags, &info->vol, sizeof(zVolumeInfo_s)); @@ -2923,7 +2917,7 @@ STATUS MSG_AddTrustee (zNSSMsg_s *msg) } COMN_CleanupNameMsg( &genMsg, &aStack->nameMsg); STACK_FREE(); - return status; + return status; } STATUS MSG_DeleteTrustee (zNSSMsg_s *msg) @@ -2949,7 +2943,7 @@ STATUS MSG_DeleteTrustee (zNSSMsg_s *msg) } COMN_CleanupNameMsg( &genMsg, &aStack->nameMsg); STACK_FREE(); - return status; + return status; } STATUS MSG_GetTrustee (zNSSMsg_s *msg) @@ -2990,7 +2984,7 @@ STATUS MSG_GetTrustee (zNSSMsg_s *msg) msg->body.auth.sequence = sequence; COMN_CleanupNameMsg( &genMsg, &aStack->nameMsg); STACK_FREE(); - return zOK; + return zOK; } STATUS MSG_GetInheritedRightsMask (zNSSMsg_s *msg) @@ -3021,7 +3015,7 @@ STATUS MSG_GetInheritedRightsMask (zNSSMsg_s *msg) } COMN_CleanupNameMsg( &genMsg, &aStack->nameMsg); STACK_FREE(); - return status; + return status; } STATUS MSG_SetInheritedRightsMask (zNSSMsg_s *msg) @@ -3047,7 +3041,7 @@ STATUS MSG_SetInheritedRightsMask (zNSSMsg_s *msg) } COMN_CleanupNameMsg( &genMsg, &aStack->nameMsg); STACK_FREE(); - return status; + return status; } STATUS zRootKey ( @@ -3216,7 +3210,7 @@ STATUS MSG_Demigrate ( return zFAILURE; } } - return ((FSMSG_MethodFunc_t)msgFunc)(msg); + return msgFunc(msg); } STATUS COMN_DemigrateDataStream (File_s *file, NamedBeast_s *dataStream) @@ -3254,7 +3248,7 @@ STATUS DEMIGRATE_AsyncRead (zNSSMsg_s *msg) return MSG_Demigrate(msg, msg->body.async.startingOffset, msg->body.async.bytesToRead, - (statusfunc_t)COMN_AsyncRead); + COMN_AsyncRead); } STATUS DEMIGRATE_ChunkyRead (zNSSMsg_s *msg) @@ -3270,7 +3264,7 @@ STATUS DEMIGRATE_SetEOF (zNSSMsg_s *msg) return MSG_Demigrate(msg, msg->body.rw.startingOffset, 0, - (statusfunc_t)COMN_SetEOF); + COMN_SetEOF); } STATUS DEMIGRATE_Write (zNSSMsg_s *msg) @@ -3278,7 +3272,7 @@ STATUS DEMIGRATE_Write (zNSSMsg_s *msg) return MSG_Demigrate(msg, msg->body.rw.startingOffset, msg->body.rw.numBytes, - (statusfunc_t)COMN_Write); + COMN_Write); } @@ -3297,27 +3291,27 @@ STATUS MSG_GetEffectiveRights (zNSSMsg_s *msg) STACK_ALLOC(); /* Create a new general and naming message. Since we - * already have a file handle we can use it to populate + * already have a file handle we can use it to populate * the naming message. - * NB: We have to have NOTLATCHED beasts via the naming - * message because we might need to get effective rights - * for a file system element that is in the path of a - * zOpen performed by DS and this will deadlock because - * the zOpen will want a XLATCH on the beast we already - * hold a latch on. Thus, we don't latch to allow any + * NB: We have to have NOTLATCHED beasts via the naming + * message because we might need to get effective rights + * for a file system element that is in the path of a + * zOpen performed by DS and this will deadlock because + * the zOpen will want a XLATCH on the beast we already + * hold a latch on. Thus, we don't latch to allow any * zOpen involving our object to succeed. */ COMN_SETUP_GENERAL_MSG( &genMsg, fh->connID, msg->body.id.taskID, zSAGENT_Z); COMN_INIT_NAMING_MSG(&aStack->nameMsg); - COMN_SETUP_NAMING_MSG_VOLUME_ZID(&aStack->nameMsg, - fh->file->FILEvolume->VOLvolumeID, -// cnt fh->fileNameUniquifier, - fh->fileParentZid, - fh->file->FILEzid, - fh->dataStream->NAMEDzid, - NOTLATCHED, - fh->fileNameSpaceID, - fh->fileNameType, + COMN_SETUP_NAMING_MSG_VOLUME_ZID(&aStack->nameMsg, + fh->file->FILEvolume->VOLvolumeID, +// cnt fh->fileNameUniquifier, + fh->fileParentZid, + fh->file->FILEzid, + fh->dataStream->NAMEDzid, + NOTLATCHED, + fh->fileNameSpaceID, + fh->fileNameType, NULL); /* Resolve the naming message */ @@ -3333,21 +3327,21 @@ STATUS MSG_GetEffectiveRights (zNSSMsg_s *msg) if (LB_GUIDCompare(&nilGUID, &(msg->body.getEffRights.objId)) == 0) { /* Get effective rights for the connection */ - status = COMN_ZAS_getEffectiveRights(&genMsg, - &aStack->nameMsg, + status = COMN_ZAS_getEffectiveRights(&genMsg, + &aStack->nameMsg, &effRights); } else { /* Get the effective rights for the specified object */ - status = COMN_ZAS_getEffectiveRightsByID(&genMsg, - &aStack->nameMsg, - &msg->body.getEffRights.objId, + status = COMN_ZAS_getEffectiveRightsByID(&genMsg, + &aStack->nameMsg, + &msg->body.getEffRights.objId, &effRights); } msg->body.getEffRights.effRights = effRights; - COMN_CleanupNameMsg(&genMsg, &aStack->nameMsg); + COMN_CleanupNameMsg(&genMsg, &aStack->nameMsg); if (status != zOK) { @@ -3380,7 +3374,7 @@ STATUS FCNTL_SharedOpLock (zNSSMsg_s *msg) goto exit; } X_LATCH( &file->FILEbeastLatch); - rc = OPLOCK_BreakExclusive( &genMsg, file, TRUE); + rc = OPLOCK_BreakExclusive( &genMsg, file, TRUE); if (rc != zOK) { SetStatusFromErrno(msg, &genMsg); diff --git a/src/nwnss/comn/common/hardLinkBeast.c b/src/nwnss/comn/common/hardLinkBeast.c index e6f8a61..fc5d96d 100755 --- a/src/nwnss/comn/common/hardLinkBeast.c +++ b/src/nwnss/comn/common/hardLinkBeast.c @@ -85,11 +85,11 @@ STATUS HARDLINK_BST_Construct( void HARDLINK_BST_Destruct( void *beast_LX) { -} +} /**************************************************************************** * COMMON OPS definition - * + * *****************************************************************************/ /*--------------------------------------------------------------------------- @@ -142,7 +142,7 @@ HardLinkBeast_s *HL_doCreateHardLinkBeast( ASSERT_MPKNSS_LOCK(); - + hlBeast = (HardLinkBeast_s *)BST_create(genMsg,zFTYPE_HARDLINK_BEAST,beast->NAMEDvolume,xaction); if(hlBeast != NULL) { @@ -178,7 +178,7 @@ HardLinkBeast_s *HL_doCreateHardLinkBeast( // cnt fixfixfix this needs to be written STATUS HL_doDestroyHardLinkBeast( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, HardLinkBeast_s *hlBeast, File_s *inodeBeast, Xaction_s *xaction) @@ -229,3 +229,10 @@ File_s *HL_CheckIfHardlinkAndReturnPrimary( return(primaryBeast); } + + + + + + + diff --git a/src/nwnss/comn/common/hmc.c b/src/nwnss/comn/common/hmc.c index 394937b..e5ead8b 100644 --- a/src/nwnss/comn/common/hmc.c +++ b/src/nwnss/comn/common/hmc.c @@ -20,7 +20,7 @@ | |*************************************************************************** | - | + | | |--------------------------------------------------------------------------- | @@ -38,9 +38,6 @@ //#include //#include -#if defined(NSS_USERSPACE) -#include "NssPageRuntime.h" -#else #include #include #include @@ -50,7 +47,6 @@ #include #include #include -#endif #include #include @@ -137,7 +133,7 @@ tasks. Nov 2006 - It appears that Linux freely tosses 'cached' blocks from memory. It + It appears that Linux freely tosses 'cached' blocks from memory. It also appears that Linux does not allow the FS to specify that some blocks are much more costly to re-read than others. In the case of NSS, user blocks are cheap and meta-data blocks are very expensive to re-read. @@ -182,7 +178,7 @@ static inline void lruPageBufferRMV( PageBuffer_s *pb ) { if ( QMEMBER( &pb->PB_LruLink ) ) { - DQ_RMV( pb, PB_LruLink); + DQ_RMV( pb, PB_LruLink); } return; } @@ -316,7 +312,7 @@ static inline void cachePageBufferRMV( PageBuffer_s *pb ) { if ( QMEMBER( &pb->PB_HashLink ) ) { - DQ_RMV( pb, PB_HashLink); + DQ_RMV( pb, PB_HashLink); } return; } @@ -342,7 +338,7 @@ static inline void poolPageBufferRMV( PageBuffer_s *pb ) { if ( QMEMBER( &pb->PB_PoolLink ) ) { - DQ_RMV( pb, PB_PoolLink); + DQ_RMV( pb, PB_PoolLink); } return; } @@ -439,7 +435,7 @@ static void freePageBuffer( PageBuffer_s *pb ) Return - Number of PageBuffer_s allocated. - */ + */ static unsigned int allocPageBufferGroup( unsigned int numberToAllocate ) { PageBuffer_s *pb; @@ -515,7 +511,7 @@ STATUS addAPage( PageBuffer_s *pb ) Frees a Linux Himem page associated with a PageBuffer_s. This PB must already have a page associated with it. - Return + Return On return the PageBuffer_s will no longer have a page associated with it. In addition PB_Page will be NULL. */ @@ -552,7 +548,7 @@ unsigned int freePageBufferGroup(unsigned int numToFree) for (i = 0; i < numToFree; i++) { pb = getPageBuffer( ); - if ( !pb ) + if ( !pb ) { pb = lruPageBufferDEQ(); if (!pb) @@ -582,7 +578,7 @@ static void HMC_PrivateFree() unsigned int itemsRemaining = Config.cache.privateCachePageBuffers; printk("<3>NSS: Freeing the NSS private cache.\n"); - do + do { itemsProcessed = freePageBufferGroup(itemsRemaining); itemsRemaining = itemsRemaining - itemsProcessed; @@ -904,7 +900,7 @@ EXPORT_SYMBOL(HMC_MarkNewestIfCached); use NSS meta-data cache for user data. */ static BOOL HMC_CopyDataToLinuxCache( - Buffer_s *buffer, + Buffer_s *buffer, struct inode *inode) { struct page *page; @@ -922,18 +918,18 @@ static BOOL HMC_CopyDataToLinuxCache( return FALSE; } unlock_page(page); - data = kmap_atomic(page, KM_USER0); - memcpy(data, buffer->pBuf.data, PAGE_SIZE); - kunmap_atomic(data, KM_USER0); - mark_page_accessed(page); - page_cache_release(page); + data = kmap_atomic(page, KM_USER0); + memcpy(data, buffer->pBuf.data, PAGE_SIZE); + kunmap_atomic(data, KM_USER0); + mark_page_accessed(page); + page_cache_release(page); MPKNSS_LOCK(); return TRUE; } -/* - Returns - +/* + Returns - This will return TRUE if we did find in himem and successfully copied the data to buffer. @@ -941,9 +937,9 @@ static BOOL HMC_CopyDataToLinuxCache( Must only be called if HMC_UseHimem returned TRUE. */ static BOOL HMC_CopyDataFromLinuxCache( - Buffer_s *buffer, + Buffer_s *buffer, struct inode *inode) -{ +{ struct page *page; char *data; @@ -956,11 +952,11 @@ static BOOL HMC_CopyDataFromLinuxCache( { return FALSE; } - data = kmap_atomic(page, KM_USER0); - memcpy(buffer->pBuf.data, data, PAGE_SIZE); - kunmap_atomic(data, KM_USER0); - mark_page_accessed(page); - page_cache_release(page); + data = kmap_atomic(page, KM_USER0); + memcpy(buffer->pBuf.data, data, PAGE_SIZE); + kunmap_atomic(data, KM_USER0); + mark_page_accessed(page); + page_cache_release(page); /// cacheLinuxStatsUpdate((buffer->state & CACHE_USER_BUFFER), CACHE_READ, !found); return TRUE; } @@ -998,15 +994,15 @@ static BOOL HMC_CopyDataToPrivateCache( { return FALSE; } - data = kmap_atomic(page, KM_USER0); - memcpy(data, buffer->pBuf.data, PAGE_SIZE); - kunmap_atomic(data, KM_USER0); + data = kmap_atomic(page, KM_USER0); + memcpy(data, buffer->pBuf.data, PAGE_SIZE); + kunmap_atomic(data, KM_USER0); return TRUE; } -/* - Returns - +/* + Returns - This will return TRUE if we found in our private cache and successfully copied the data to the Buffer_s. @@ -1014,9 +1010,9 @@ static BOOL HMC_CopyDataToPrivateCache( Must only be called if HMC_UseHimem returned TRUE. */ static BOOL HMC_CopyDataFromPrivateCache( - Buffer_s *buffer, + Buffer_s *buffer, struct inode *inode) -{ +{ struct page *page; char *data; BOOL found = FALSE; @@ -1052,7 +1048,7 @@ static BOOL HMC_CopyDataFromPrivateCache( */ BOOL HMC_CopyDataToHimem( DQhead_t *poolHead, - Buffer_s *buffer, + Buffer_s *buffer, struct inode *inode) { BOOL copied; @@ -1068,8 +1064,8 @@ BOOL HMC_CopyDataToHimem( EXPORT_SYMBOL(HMC_CopyDataToHimem); -/* - Returns - +/* + Returns - This will return TRUE if we did find in himem and successfully copied the data to buffer. @@ -1077,9 +1073,9 @@ EXPORT_SYMBOL(HMC_CopyDataToHimem); Must only be called if HMC_UseHimem returned TRUE. */ BOOL HMC_CopyDataFromHimem( - Buffer_s *buffer, + Buffer_s *buffer, struct inode *inode) -{ +{ BOOL found; S_LATCH( &Cache.CC_HMCCacheTypeLatch ); @@ -1357,3 +1353,4 @@ STATUS HMC_Shutdown( void ) status = HMC_TypeSet( HMC_CT_NONE ); return status; } + diff --git a/src/nwnss/comn/common/mgmt.c b/src/nwnss/comn/common/mgmt.c index 8e34b3a..19ee258 100644 --- a/src/nwnss/comn/common/mgmt.c +++ b/src/nwnss/comn/common/mgmt.c @@ -1 +1 @@ -#include +#include diff --git a/src/nwnss/comn/common/mgmtFiles.c b/src/nwnss/comn/common/mgmtFiles.c index c213e39..132ea1a 100644 --- a/src/nwnss/comn/common/mgmtFiles.c +++ b/src/nwnss/comn/common/mgmtFiles.c @@ -47,8 +47,6 @@ #include #include -#include "msgGen.h" -#include "comnBeasts.h" #include "mgmt.h" #include "name.h" #include "pssStartup.h" @@ -64,10 +62,9 @@ #include "virtualIO.h" #include "xmlTags.h" #include "cmControl.h" -#include "nssOSAPIs.h" #if zLINUX -#include "cmActivity.h" -#include "cmRuntime.h" +#include "../compression/cmActivity.h" +#include "../compression/cmRuntime.h" #else #include "..\compression\cmActivity.h" #include "..\compression\cmRuntime.h" @@ -84,7 +81,7 @@ ****************************************************************************/ typedef struct ReadInst_s { - BYTE *tag; + BYTE *tag; BOOL isFile; /* if set then this is a file not an element */ void *RI_data; /* address of data. Must be a pointer to a * NINT if callFunc is NULL. @@ -384,7 +381,7 @@ void cacheMDHimemBucketMaxEntries( { NINT param1, param2; NINT maxInBucket; - + ASSERT_MPKNSS_LOCK(); getBucketStats(&maxInBucket, ¶m1, ¶m2, Cache.bucketPageBuffer, Config.cache.privateHashSize); sprintf(data, MSGNot("%u"), maxInBucket); @@ -395,7 +392,7 @@ void cacheMDHimemTotalEntries( { NINT param1, param2; NINT totalEntries; - + ASSERT_MPKNSS_LOCK(); getBucketStats(¶m1, &totalEntries, ¶m2, Cache.bucketPageBuffer, Config.cache.privateHashSize); sprintf(data, MSGNot("%u"), totalEntries); @@ -412,7 +409,7 @@ void cacheMDHimemBucketPercentage( if (Config.cache.privateHashSize == 0) { sprintf(data, MSGNot("0")); - } + } else { getBucketStats(¶m1, ¶m2, &numUsedBuckets, Cache.bucketPageBuffer, Config.cache.privateHashSize); @@ -427,7 +424,7 @@ void cacheBucketMaxEntries( { NINT param1, param2; NINT maxInBucket; - + ASSERT_MPKNSS_LOCK(); getBucketStats(&maxInBucket, ¶m1, ¶m2, Cache.bucket, Config.cache.hashSize); @@ -439,7 +436,7 @@ void cacheTotalEntries( { NINT param1, param2; NINT totalEntries; - + ASSERT_MPKNSS_LOCK(); getBucketStats(¶m1, &totalEntries, ¶m2, Cache.bucket, Config.cache.hashSize); @@ -457,7 +454,7 @@ void cacheBucketPercentage( if (Config.cache.hashSize == 0) { sprintf(data, MSGNot("0")); - } + } else { getBucketStats(¶m1, ¶m2, &numUsedBuckets, Cache.bucket, Config.cache.hashSize); @@ -491,12 +488,12 @@ void nameBucketPercentage( NINT param1, param2; NINT uniNumUsedBuckets; NINT asciiNumUsedBuckets; - + ASSERT_MPKNSS_LOCK(); if ((Config.cache.hashSize == 0) || (NameCache.numHashEntries == 0)) { sprintf(data, MSGNot("0")); - } + } else { getBucketStats(¶m1, ¶m2, &uniNumUsedBuckets, NameCache.uniHash, NameCache.numHashEntries); @@ -509,7 +506,7 @@ void nameChangeCount( BYTE *data, ReadInst_s *rec ) { ASSERT_MPKNSS_LOCK(); - sprintf(data, MSGNot("%Lu"), NameCache.changeCount); + sprintf(data, MSGNot("%Lu"), NameCache.changeCount); } void nameGets( @@ -517,13 +514,13 @@ void nameGets( { ASSERT_MPKNSS_LOCK(); sprintf(data, MSGNot("%Lu"), NameCache.uniGets + NameCache.asciiGets); -} +} void nameHits( BYTE *data, ReadInst_s *rec ) { ASSERT_MPKNSS_LOCK(); - sprintf(data, MSGNot("%Lu"), NameCache.uniHits + NameCache.asciiHits); + sprintf(data, MSGNot("%Lu"), NameCache.uniHits + NameCache.asciiHits); } void nameHitPercentage( @@ -531,9 +528,9 @@ void nameHitPercentage( { ASSERT_MPKNSS_LOCK(); - sprintf(data, MSGNot("%Lu"), - (((NameCache.uniGets + NameCache.asciiGets) != UI64_CONST(0)) ? - (((NameCache.uniHits + NameCache.asciiHits) * UI64_CONST(100)) / (NameCache.uniGets + NameCache.asciiGets)) : + sprintf(data, MSGNot("%Lu"), + (((NameCache.uniGets + NameCache.asciiGets) != UI64_CONST(0)) ? + (((NameCache.uniHits + NameCache.asciiHits) * UI64_CONST(100)) / (NameCache.uniGets + NameCache.asciiGets)) : UI64_CONST(0))); } @@ -542,42 +539,42 @@ void nameNegativeHits( { ASSERT_MPKNSS_LOCK(); - sprintf(data, MSGNot("%Lu"), NameCache.uniNegativeHits + NameCache.asciiNegativeHits); + sprintf(data, MSGNot("%Lu"), NameCache.uniNegativeHits + NameCache.asciiNegativeHits); } void nameNumAllocs( BYTE *data, ReadInst_s *rec ) { ASSERT_MPKNSS_LOCK(); - sprintf(data, MSGNot("%Lu"), NameCache.numAllocs); + sprintf(data, MSGNot("%Lu"), NameCache.numAllocs); } void nameNumAlreadyAdded ( BYTE *data, ReadInst_s *rec ) { ASSERT_MPKNSS_LOCK(); - sprintf(data, MSGNot("%Lu"), NameCache.numAlreadyAdded); + sprintf(data, MSGNot("%Lu"), NameCache.numAlreadyAdded); } void nameNumNegativeAdds( BYTE *data, ReadInst_s *rec ) { ASSERT_MPKNSS_LOCK(); - sprintf(data, MSGNot("%Lu"), NameCache.numNegativeAdds); + sprintf(data, MSGNot("%Lu"), NameCache.numNegativeAdds); } void nameNumRemoved ( BYTE *data, ReadInst_s *rec ) { ASSERT_MPKNSS_LOCK(); - sprintf(data, MSGNot("%Lu"), NameCache.numRemoved); + sprintf(data, MSGNot("%Lu"), NameCache.numRemoved); } void nameNumVictimSelected ( BYTE *data, ReadInst_s *rec ) { ASSERT_MPKNSS_LOCK(); - sprintf(data, MSGNot("%Lu"), NameCache.numVictimSelected); + sprintf(data, MSGNot("%Lu"), NameCache.numVictimSelected); } void namePositiveHits( @@ -585,7 +582,7 @@ void namePositiveHits( { ASSERT_MPKNSS_LOCK(); - sprintf(data, MSGNot("%Lu"), NameCache.uniPositiveHits + NameCache.asciiPositiveHits); + sprintf(data, MSGNot("%Lu"), NameCache.uniPositiveHits + NameCache.asciiPositiveHits); } void nameTotalEntries( @@ -594,7 +591,7 @@ void nameTotalEntries( NINT param1, param2; NINT uniTotalEntries; NINT asciiTotalEntries; - + ASSERT_MPKNSS_LOCK(); getBucketStats(¶m1, &uniTotalEntries, ¶m2, NameCache.uniHash, NameCache.numHashEntries); getBucketStats(¶m1, &asciiTotalEntries, ¶m2, NameCache.asciiHash, NameCache.numHashEntries); @@ -724,7 +721,7 @@ void bstBucketPercentage( if (Config.cache.hashSize == 0) { sprintf(data, MSGNot("0")); - } + } else { getBucketStats(¶m1, ¶m2, &numUsedBuckets, RootBeastHash, Config.bst.hashSize); @@ -770,7 +767,7 @@ void fsmWaiting( next = (CIRlink_t)NEXT(next); } while (next != FsmReadyQ); } - + sprintf(data, MSGNot("%u"), count); } @@ -785,7 +782,7 @@ void authHashSize( ASSERT_MPKNSS_LOCK(); sprintf(data, MSGNot("%u"), AuthCache.hashMask+1); -} +} void authBucketMaxEntries( BYTE *data, ReadInst_s *rec ) @@ -809,7 +806,7 @@ void authBucketPercentage( if (AuthCache.hashMask + 1 == 0) { sprintf(data, MSGNot("0")); - } + } else { getBucketStats(¶m1, ¶m2, &numUsedBuckets, (DQhead_t *)AuthCache.hash, AuthCache.hashMask + 1); @@ -911,14 +908,14 @@ void latchWaiter( { ASSERT_MPKNSS_LOCK(); sprintf(data, MSGNot("%u"), Latch_Waiter()); -} +} void latchHolder( BYTE *data, ReadInst_s *rec ) { ASSERT_MPKNSS_LOCK(); sprintf(data, MSGNot("%u"), Latch_Holder()); -} +} void latchAll( BYTE *data, ReadInst_s *rec ) @@ -932,7 +929,7 @@ void latchFree( { ASSERT_MPKNSS_LOCK(); sprintf(data, MSGNot("%u"), Latch_Free()); -} +} #endif void getCompInfo( @@ -942,7 +939,7 @@ void getCompInfo( RootBeast_s *beast; Volume_s *volume; Volume_s *prevVolume; - CMActivity_s *activity; + CMActivity_s *activity; BOOL latched = FALSE; NINT len; typedef struct { @@ -950,13 +947,13 @@ typedef struct { unicode_t fileName[zMAX_FULL_NAME + 1]; } AllocStuff_s; AllocStuff_s *as; - + ASSERT_MPKNSS_LOCK(); as = zalloc( sizeof( *as ) ); if ( as == NULL ) { - zASSERT(MSG("Unable to Allocate Memory\n", 190) == NULL); + zASSERT(MSG("Unable to Allocate Memory\n", 190) == NULL); return; } @@ -989,18 +986,18 @@ typedef struct { if (DQ_NOT_EMPTY(&CM_activities)) { DQ_FOREACH(&CM_activities, activity, CMActivity_s, allActivitiesChain) - { + { if (activity->state != CM_ACTIVITY_STATE_RUNNING) - { + { continue; } - + beast = activity->decompStream.beast; - + /* get the volume name on which this beast resides */ volume = beast->ROOTvolume; - - if (COMN_GetVolumeName(&genMsg, volume, + + if (COMN_GetVolumeName(&genMsg, volume, as->volName, NELEMS(as->volName)) != zOK) { zASSERT("can't get volume's name" == NULL); @@ -1013,33 +1010,33 @@ typedef struct { S_LATCH(&beast->ROOTbeastLatch); latched = TRUE; } - - if (COMN_GetFileNameFromZid(&genMsg, volume, beast->zid, OS_NAME_SPACE, - as->fileName, FALSE) != zOK) + + if (COMN_GetFileNameFromZid(&genMsg, volume, beast->zid, OS_NAME_SPACE, + as->fileName, FALSE) != zOK) { if (latched) { UNS_LATCH(&beast->ROOTbeastLatch); latched = FALSE; - } - + } + /* This could happen if the beast is during the purging process */ // zASSERT("can't get beast's name" == NULL); continue; } - + if (latched) - { + { UNS_LATCH(&beast->ROOTbeastLatch); latched = FALSE; } - + sprintf(&data[len], MSGNot("<"TAG_FILE">\n" "<"TAG_VOLUME">%U\n" "<"TAG_NAME">%U\n"), - as->volName, as->fileName); + as->volName, as->fileName); len += strlen(&data[len]); - + /* mark what is the operation on this file (comp or decomp) */ if (activity->op == CM_ACTIVITY_OP_COMPRESS) { @@ -1047,11 +1044,11 @@ typedef struct { len += strlen(&data[len]); } else - { + { sprintf(&data[len], MSGNot("<"TAG_OPERATION">decompression\n")); len += strlen(&data[len]); } - + sprintf(&data[len], MSGNot("\n")); len += strlen(&data[len]); } @@ -1070,7 +1067,7 @@ typedef struct { while (TRUE) { volume = COMN_GetNextVolume(prevVolume); - if (prevVolume) + if (prevVolume) { COMN_Release(&prevVolume); } @@ -1078,7 +1075,7 @@ typedef struct { if (volume == NULL) { break; - } + } prevVolume = volume; @@ -1087,14 +1084,14 @@ typedef struct { continue; } - if (COMN_GetVolumeName(&genMsg, volume, + if (COMN_GetVolumeName(&genMsg, volume, as->volName, NELEMS(as->volName)) != zOK) { zASSERT("can't get volume's name" == NULL); continue; } - sprintf(&data[len], + sprintf(&data[len], MSGNot("<"TAG_VOLUME">\n" "<"TAG_VOLUMENAME">%U\n" "<"TAG_COMPRESSEDFILES">%Lu\n" @@ -1161,15 +1158,15 @@ ReadInst_s MgmtReadInsts[] = * Cache * *------------------------------------------------------------------------------*/ {TAG_BUFFERCACHE, TRUE, 0, 0}, - {TAG_RESETTIME, FALSE, &Inst.resetUpTime, &genUTCFromUpTime }, - {TAG_TIME, FALSE, NULL, &genUTCTimeCurrent }, - {TAG_CACHEHITS, FALSE, NULL, &genStatTotalHit }, + {TAG_RESETTIME, FALSE, &Inst.resetUpTime, &genUTCFromUpTime }, + {TAG_TIME, FALSE, NULL, &genUTCTimeCurrent }, + {TAG_CACHEHITS, FALSE, NULL, &genStatTotalHit }, {TAG_CACHEMISSES, FALSE, NULL, &genStatTotalMiss}, {TAG_CACHEHITPERCENT, FALSE, 0, &genCacheHitPercentage}, - {TAG_CACHEIOSYSTEMHITS, FALSE, NULL, &genStatIOSystemTotalHit }, + {TAG_CACHEIOSYSTEMHITS, FALSE, NULL, &genStatIOSystemTotalHit }, {TAG_CACHEIOSYSTEMMISSES, FALSE, NULL, &genStatIOSystemTotalMiss}, {TAG_CACHEIOSYSTEMHITPERCENT, FALSE, NULL, &genCacheIOSystemHitPercentage}, - {TAG_CACHEIOUSERHITS, FALSE, NULL, &genStatIOUserTotalHit }, + {TAG_CACHEIOUSERHITS, FALSE, NULL, &genStatIOUserTotalHit }, {TAG_CACHEIOUSERMISSES, FALSE, NULL, &genStatIOUserTotalMiss}, {TAG_CACHEIOUSERHITPERCENT, FALSE, NULL, &genCacheIOUserHitPercentage}, {TAG_CACHEBUFFERSNUMBER, FALSE, (ADDR *)&Config.cache.numBuffers, 0}, @@ -1180,14 +1177,14 @@ ReadInst_s MgmtReadInsts[] = {TAG_TOTALENTRIES, FALSE, 0, &cacheTotalEntries}, {TAG_BUCKETSUSEDPERCENT, FALSE, 0, &cacheBucketPercentage}, /* Added Oct 2006 */ - {TAG_CACHEIOLINUXHITS, FALSE, NULL, &genStatIOLinuxTotalHit }, - {TAG_CACHEIOLINUXHITSPERCENT, FALSE, NULL, &genCacheIOLinuxTotalHitPercentage }, + {TAG_CACHEIOLINUXHITS, FALSE, NULL, &genStatIOLinuxTotalHit }, + {TAG_CACHEIOLINUXHITSPERCENT, FALSE, NULL, &genCacheIOLinuxTotalHitPercentage }, {TAG_CACHEIOLINUXMISSES, FALSE, NULL, &genStatIOLinuxTotalMiss}, - {TAG_CACHEIOLINUXSYSTEMHITS, FALSE, NULL, &genStatIOLinuxSystemTotalHit }, - {TAG_CACHEIOLINUXSYSTEMHITSPERCENT, FALSE, NULL, &genCacheIOLinuxSystemTotalHitPercentage }, + {TAG_CACHEIOLINUXSYSTEMHITS, FALSE, NULL, &genStatIOLinuxSystemTotalHit }, + {TAG_CACHEIOLINUXSYSTEMHITSPERCENT, FALSE, NULL, &genCacheIOLinuxSystemTotalHitPercentage }, {TAG_CACHEIOLINUXSYSTEMMISSES, FALSE, NULL, &genStatIOLinuxSystemTotalMiss}, - {TAG_CACHEIOLINUXUSERHITS, FALSE, NULL, &genStatIOLinuxUserTotalHit }, - {TAG_CACHEIOLINUXUSERHITSPERCENT, FALSE, NULL, &genCacheIOLinuxUserTotalHitPercentage }, + {TAG_CACHEIOLINUXUSERHITS, FALSE, NULL, &genStatIOLinuxUserTotalHit }, + {TAG_CACHEIOLINUXUSERHITSPERCENT, FALSE, NULL, &genCacheIOLinuxUserTotalHitPercentage }, {TAG_CACHEIOLINUXUSERMISSES, FALSE, NULL, &genStatIOLinuxUserTotalMiss}, /* Added Nov 2006 */ {TAG_HMCCACHETYPE, FALSE, &Config.cache.hmcCacheType, 0}, @@ -1220,8 +1217,8 @@ ReadInst_s MgmtReadInsts[] = * File * *------------------------------------------------------------------------------*/ {TAG_FILESTATS, TRUE, 0, 0}, - {TAG_RESETTIME, FALSE, &Inst.resetUpTime, &genUTCFromUpTime }, - {TAG_TIME, FALSE, NULL, &genUTCTimeCurrent }, + {TAG_RESETTIME, FALSE, &Inst.resetUpTime, &genUTCFromUpTime }, + {TAG_TIME, FALSE, NULL, &genUTCTimeCurrent }, {TAG_CURRENTOPENCOUNT, FALSE, (ADDR *)&Inst.file.openCount, 0}, {TAG_BYTESREAD, FALSE, 0, &fileBytesRead}, {TAG_BYTESWRITTEN, FALSE, 0, &fileBytesWrite}, @@ -1229,7 +1226,7 @@ ReadInst_s MgmtReadInsts[] = {TAG_FILEWRITECOUNTS, FALSE, 0, &fileWriteCount}, {TAG_FILESDELETED, FALSE, (ADDR *)&Inst.file.deletedCount, 0}, {TAG_FILESPURGED, FALSE, (ADDR *)&Inst.file.purgedCount, 0}, - {TAG_FILESSALVAGED, FALSE, (ADDR *)&Inst.file.salvagedCount, 0}, + {TAG_FILESSALVAGED, FALSE, (ADDR *)&Inst.file.salvagedCount, 0}, /*------------------------------------------------------------------------------* * Beast Cache * *------------------------------------------------------------------------------*/ @@ -1275,7 +1272,7 @@ ReadInst_s MgmtReadInsts[] = {TAG_MAXIMUMENTRIES, FALSE, (ADDR *)&AuthCache.maxEntries, 0}, {TAG_USEDENTRIES, FALSE, (ADDR *)&AuthCache.numEntries, 0}, {TAG_BUCKETMAXIMUMENTRIES, FALSE, 0, &authBucketMaxEntries}, - {TAG_BUCKETSUSEDPERCENT, FALSE, 0, &authBucketPercentage}, + {TAG_BUCKETSUSEDPERCENT, FALSE, 0, &authBucketPercentage}, {TAG_CACHEACTIVATIONCOUNT, FALSE, (ADDR *)&AuthCache.activationCount, 0}, {TAG_CACHESIGNATURE, FALSE, (ADDR *)&AuthCache.signatureCount, 0}, {TAG_CACHERESETCOUNT, FALSE, (ADDR *)&AuthCache.resetCount, 0}, @@ -1333,7 +1330,7 @@ STATUS MGMT_readOverride( } saveIndex = index; - if ((status = VIRT_AddResultTag(virtInfo, TAG_NSSREPLY, FALSE, + if ((status = VIRT_AddResultTag(virtInfo, TAG_NSSREPLY, FALSE, TRUE)) != zOK) { goto exit; @@ -1348,7 +1345,7 @@ STATUS MGMT_readOverride( * when we get to the next file entry. Index comes in pointing to the * entry with the current file name. */ - while ((MgmtReadInsts[++index].tag != NULL) && + while ((MgmtReadInsts[++index].tag != NULL) && !MgmtReadInsts[index].isFile) { /* Generate the actual element data */ @@ -1363,7 +1360,7 @@ STATUS MGMT_readOverride( } if (strcmp(MgmtReadInsts[index].tag, MSGNot(""))) { - if ((status = VIRT_AddResultElement(virtInfo, + if ((status = VIRT_AddResultElement(virtInfo, MgmtReadInsts[index].tag, aStack->data, TRUE)) != zOK) { break; @@ -1382,7 +1379,7 @@ STATUS MGMT_readOverride( { goto exit; } - if ((status = VIRT_AddResultTag(virtInfo, TAG_NSSREPLY, TRUE, + if ((status = VIRT_AddResultTag(virtInfo, TAG_NSSREPLY, TRUE, TRUE)) != zOK) { goto exit; @@ -1423,7 +1420,7 @@ STATUS MGMT_StartupReadInsts( SetErrno(genMsg, status); goto errorExit; } - + /* Export the symbol */ ZOS_ModuleRegister(MGMT_readOverride); @@ -1437,7 +1434,7 @@ STATUS MGMT_StartupReadInsts( strcpy(&aStack->pathStr[AVFileMgmtDirLen], MgmtReadInsts[i].tag); aStack->pathStr[AVFileMgmtDirLen] = toupper(aStack->pathStr[AVFileMgmtDirLen]); strcat(aStack->pathStr, MSG(".xml", 571)); - ZOS_zCreate(status, rootKey, zNO_TASK, 0, + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, aStack->pathStr, zFILE_REGULAR, AVFILEFILEATTR, zCREATE_OPEN_IF_THERE, zRR_WRITE_ACCESS, &retKey); if (status != zOK) @@ -1448,7 +1445,7 @@ STATUS MGMT_StartupReadInsts( /* Write the transformation template to the file */ sprintf(parm, "%d", i); - if ((status = MGMTS_MakeFunctionVirtualFile(retKey, + if ((status = MGMTS_MakeFunctionVirtualFile(retKey, "MGMT_readOverride", parm, NULL, NULL, FALSE)) != zOK) { SetErrno(genMsg, status); @@ -1490,7 +1487,7 @@ void MGMT_ShutdownReadInsts() BYTE pathStr[zMAX_FULL_NAME]; } Stack_s; STACK_ALLOC(); - + ASSERT_MPKNSS_LOCK(); ZOS_zRootKey(status, 0, &rootKey); @@ -1518,7 +1515,7 @@ void MGMT_ShutdownReadInsts() zASSERT(status == zOK); } } - + ZOS_zClose(status, rootKey); ZOS_ModuleUnregister(MGMT_readOverride); STACK_FREE(); diff --git a/src/nwnss/comn/common/mgmtPool.c b/src/nwnss/comn/common/mgmtPool.c index 64628dc..b1a636b 100644 --- a/src/nwnss/comn/common/mgmtPool.c +++ b/src/nwnss/comn/common/mgmtPool.c @@ -107,7 +107,7 @@ typedef struct { COMN_USE_BEAST( &pool->POOLroot ); COMN_GetPoolName(&genMsg, pool, as->pname, zMAX_COMPONENT_NAME); - if (LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, as->poolName, + if (LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, as->poolName, zMAX_COMPONENT_NAME, as->pname, NULL) != zOK) { COMN_Release( &pool ); @@ -149,7 +149,7 @@ STATUS pool_salFreeableSize( formattedSize(pool->POOLpurgeableBlocks << pool->POOLblockShift, &size, &sized, &byteval); - sprintf(data, MSGNot("%Lu (%d.%d %s)"), + sprintf(data, MSGNot("%Lu (%d.%d %s)"), pool->POOLpurgeableBlocks << pool->POOLblockShift, size, sized, byteval); @@ -169,7 +169,7 @@ STATUS pool_salNonFreeableSize( formattedSize(pool->POOLnonPurgeableBlocks << pool->POOLblockShift, &size, &sized, &byteval); - sprintf(data, MSGNot("%Lu (%d.%d %s)"), + sprintf(data, MSGNot("%Lu (%d.%d %s)"), pool->POOLnonPurgeableBlocks << pool->POOLblockShift, size, sized, byteval); @@ -185,7 +185,7 @@ STATUS pool_salMinKeepSeconds( { utf8_t data[20]; - sprintf(data, MSGNot("%u"), pool->POOLminKeepSeconds); + sprintf(data, MSGNot("%u"), pool->POOLminKeepSeconds); return VIRT_AddResultElement(virtInfo, TAG_MINKEEPTIME, data, TRUE); } @@ -198,7 +198,7 @@ STATUS pool_salMaxKeepSeconds( { utf8_t data[20]; - sprintf(data, MSGNot("%u"), pool->POOLmaxKeepSeconds); + sprintf(data, MSGNot("%u"), pool->POOLmaxKeepSeconds); return VIRT_AddResultElement(virtInfo, TAG_MAXKEEPTIME, data, TRUE); } @@ -211,7 +211,7 @@ STATUS pool_salLowWaterMark( { utf8_t data[20]; - sprintf(data, MSGNot("%u"), pool->POOLlowWaterMark); + sprintf(data, MSGNot("%u"), pool->POOLlowWaterMark); return VIRT_AddResultElement(virtInfo, TAG_LOWWATERMARK, data, TRUE); } @@ -224,7 +224,7 @@ STATUS pool_salHighWaterMark( { utf8_t data[20]; - sprintf(data, MSGNot("%u"), pool->POOLhighWaterMark); + sprintf(data, MSGNot("%u"), pool->POOLhighWaterMark); return VIRT_AddResultElement(virtInfo, TAG_HIGHWATERMARK, data, TRUE); } @@ -241,11 +241,11 @@ STATUS pool_size( formattedSize(pool->POOLtotalBlocks << pool->POOLblockShift, &size, &sized, &byteval); - sprintf(data, MSGNot("%Lu (%d.%d %s)"), + sprintf(data, MSGNot("%Lu (%d.%d %s)"), pool->POOLtotalBlocks << pool->POOLblockShift, size, sized, byteval); - return VIRT_AddResultElement(virtInfo, TAG_SIZE, data, TRUE); + return VIRT_AddResultElement(virtInfo, TAG_SIZE, data, TRUE); } @@ -260,13 +260,13 @@ STATUS pool_freeSize( BYTE *byteval; LONG size, sized; QUAD notInUseSize; - + notInUseSize = (pool->POOLtotalBlocks - pool->POOLinUseBlocks) > pool->freeBlockAdjustment ? pool->POOLtotalBlocks - pool->POOLinUseBlocks - pool->freeBlockAdjustment : 0; formattedSize(notInUseSize << pool->POOLblockShift, &size, &sized, &byteval); - sprintf(data, MSGNot("%Lu (%d.%d %s)"), + sprintf(data, MSGNot("%Lu (%d.%d %s)"), notInUseSize << pool->POOLblockShift, size, sized, byteval); @@ -285,7 +285,7 @@ STATUS pool_percentFreeSpace( if (pool->POOLtotalBlocks != 0) { - sprintf(data, MSGNot("%d"), + sprintf(data, MSGNot("%d"), (((pool->POOLtotalBlocks - pool->POOLinUseBlocks) > pool->freeBlockAdjustment) ? 100 * (pool->POOLtotalBlocks - pool->POOLinUseBlocks - pool->freeBlockAdjustment) : 0) /pool->POOLtotalBlocks ); @@ -294,7 +294,7 @@ STATUS pool_percentFreeSpace( { strcpy(data, "0"); } - return VIRT_AddResultElement(virtInfo, TAG_PERCENTFREESPACE, + return VIRT_AddResultElement(virtInfo, TAG_PERCENTFREESPACE, data, TRUE); } @@ -390,7 +390,7 @@ STATUS pool_enabledAttributes( } if (pool->POOLenabledFeatures & zPOOL_FEATURE_PERSISTENT_FEATURES) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("PERSISTENT_ATTRIBUTES "))) != zOK) { goto exit; @@ -405,7 +405,7 @@ STATUS pool_enabledAttributes( } if (pool->POOLenabledFeatures & zPOOL_FEATURE_MULTIPLE_VOLUMES) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("MULTIPLE_VOLUMES "))) != zOK) { goto exit; @@ -463,16 +463,16 @@ STATUS pool_info( memcpy(path, parm, parmLen); path[parmLen] = 0; - if ((status = VIRT_AddResultTag(virtInfo, TAG_NSSREPLY, FALSE, + if ((status = VIRT_AddResultTag(virtInfo, TAG_NSSREPLY, FALSE, TRUE)) != zOK) { goto exit; } - if ((status = findPool(path, MSGNot("Pool\\%s\\PoolInfo.xml"), + if ((status = findPool(path, MSGNot("Pool\\%s\\PoolInfo.xml"), &pool)) == zOK) { - if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLINFO, FALSE, + if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLINFO, FALSE, TRUE)) != zOK) { goto done; @@ -510,7 +510,7 @@ STATUS pool_info( goto done; } /* put in the salvage info */ - if ((status = VIRT_AddResultTag(virtInfo, + if ((status = VIRT_AddResultTag(virtInfo, TAG_SALVAGE, FALSE, TRUE)) != zOK) { goto done; @@ -539,12 +539,12 @@ STATUS pool_info( { goto done; } - if ((status = VIRT_AddResultTag(virtInfo, TAG_SALVAGE, TRUE, + if ((status = VIRT_AddResultTag(virtInfo, TAG_SALVAGE, TRUE, TRUE)) != zOK) { goto done; } - if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLINFO, TRUE, + if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLINFO, TRUE, TRUE)) != zOK) { goto done; @@ -640,15 +640,15 @@ typedef struct { memcpy(as->path, parm, parmLen); as->path[parmLen] = 0; - if ((status = VIRT_AddResultTag(virtInfo, TAG_NSSREPLY, FALSE, + if ((status = VIRT_AddResultTag(virtInfo, TAG_NSSREPLY, FALSE, TRUE)) != zOK) { goto exit; } - if ((status = findPool(as->path, MSGNot("Pool\\%s\\OwnedVolumes.xml"), + if ((status = findPool(as->path, MSGNot("Pool\\%s\\OwnedVolumes.xml"), &pool)) == zOK) { - if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLINFO, FALSE, + if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLINFO, FALSE, TRUE)) != zOK) { goto done; @@ -658,14 +658,14 @@ typedef struct { { goto done; } - if ((status = VIRT_AddResultTag(virtInfo, TAG_OWNEDVOLUMES, FALSE, + if ((status = VIRT_AddResultTag(virtInfo, TAG_OWNEDVOLUMES, FALSE, TRUE)) != zOK) { goto done; } DQ_FOREACH(&pool->P_VolumeList, volume, Volume_s, v_poolVolLink) { - if (COMN_GetVolumeName(&genMsg, volume, as->vname, + if (COMN_GetVolumeName(&genMsg, volume, as->vname, zMAX_COMPONENT_NAME) != zOK) { zASSERT("Failed to get a volume name" == NULL); @@ -677,8 +677,8 @@ typedef struct { sprintf(as->data, MSGNot("<"TAG_VOLUMEENTRY">\n%s<" TAG_VOLUMENAME">%U<" TAG_VOLUMESTATE">%s\n\n"), - volume->VOLpState == MSGNot(zVOL_PSTATE_DELETION) ? + TAG_VOLUMEENTRY">\n"), + volume->VOLpState == MSGNot(zVOL_PSTATE_DELETION) ? MSGNot("<"TAG_DELETEDVOLUME"/>\n") : MSGNot(""), as->vname, pool_getStateName(volume->VOLstate)); if ((status = VIRT_AddResultData(virtInfo, as->data)) != zOK) @@ -687,12 +687,12 @@ typedef struct { } } } - if ((status = VIRT_AddResultTag(virtInfo, TAG_OWNEDVOLUMES, TRUE, + if ((status = VIRT_AddResultTag(virtInfo, TAG_OWNEDVOLUMES, TRUE, TRUE)) != zOK) { goto done; } - if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLINFO, TRUE, + if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLINFO, TRUE, TRUE)) != zOK) { goto done; @@ -725,8 +725,8 @@ typedef struct PoolAVFileInst_s PoolAVFileInst_s PoolInst[] = { {NULL, TRUE, NULL}, - {NULL, FALSE, "pool_info", (statusfunc_t)pool_info}, - {NULL, FALSE, "pool_volumes", (statusfunc_t)pool_volumes}, + {NULL, FALSE, "pool_info", pool_info}, + {NULL, FALSE, "pool_volumes", pool_volumes}, {0}, }; @@ -790,10 +790,10 @@ typedef struct { { strcpy(&as->pathStr[AVFileMgmtDirLen], MSGNot("Pool")); - ZOS_zCreate(status, rootKey, zNO_TASK, 0, + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, as->pathStr, zFILE_REGULAR, AVFILEDIRATTR, zCREATE_OPEN_IF_THERE, zRR_WRITE_ACCESS, &retKey); - if (status != zOK) + if (status != zOK) { SetErrno(genMsg, status); goto errorClose; @@ -821,12 +821,12 @@ typedef struct { createAttr = AVFILEFILEATTR; } - ZOS_zCreate(status, rootKey, zNO_TASK, 0, - zNSPACE_LONG | zMODE_UTF8, as->pathStr, zFILE_REGULAR, + ZOS_zCreate(status, rootKey, zNO_TASK, 0, + zNSPACE_LONG | zMODE_UTF8, as->pathStr, zFILE_REGULAR, createAttr, zCREATE_OPEN_IF_THERE, zRR_WRITE_ACCESS, &retKey); if (status != zOK) { - /* + /* * This check is here because of a bug in zCreate. It can be * removed when zCreate opens an existing directory without * an error. @@ -837,15 +837,15 @@ typedef struct { zASSERT("Error during create" == 0); goto errorClose; } - ZOS_zOpen(status, rootKey, zNO_TASK, zNSPACE_LONG | zMODE_UTF8, + ZOS_zOpen(status, rootKey, zNO_TASK, zNSPACE_LONG | zMODE_UTF8, as->pathStr, zRR_WRITE_ACCESS, &retKey); } if (!PoolInst[i].isDir) { /* Write the transformation template to the file */ - if ((status = MGMTS_MakeFunctionVirtualFile(retKey, - PoolInst[i].functionName, + if ((status = MGMTS_MakeFunctionVirtualFile(retKey, + PoolInst[i].functionName, as->pathStr, NULL, NULL, FALSE)) != zOK) { zASSERT("Error writing transformation template" == 0); @@ -860,10 +860,10 @@ typedef struct { if (PoolInst[i].functionName) { #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) - inter_module_register(PoolInst[i].functionName, + inter_module_register(PoolInst[i].functionName, THIS_MODULE, PoolInst[i].function); #else - nss_register_module(PoolInst[i].functionName, + nss_register_module(PoolInst[i].functionName, PoolInst[i].function, THIS_MODULE); #endif } @@ -884,17 +884,17 @@ typedef struct { free(as); - return zOK; + return zOK; errorClose: ZOS_zClose(status, rootKey); - + errorExit: free(as); return zFAILURE; - + } /************************************************************************** @@ -921,7 +921,7 @@ typedef struct { return; } - LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, as->name, + LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, as->name, zMAX_COMPONENT_NAME, poolName, NULL); memcpy(as->pathStr, AVFileMgmtDir, AVFileMgmtDirLen); @@ -943,7 +943,7 @@ typedef struct { MGMT_PoolFunctionsRegistered--; for (; i > 0; i--) { - sprintf(&as->pathStr[AVFileMgmtDirLen], PoolInst[i - 1].path, + sprintf(&as->pathStr[AVFileMgmtDirLen], PoolInst[i - 1].path, as->name); ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, as->pathStr, zMATCH_ALL, zDELETE_FORCE_DELETE); @@ -955,9 +955,9 @@ typedef struct { if (PoolInst[i].functionName) { #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) - inter_module_unregister(PoolInst[i].functionName); + inter_module_unregister(PoolInst[i].functionName); #else - nss_unregister_module(PoolInst[i].functionName); + nss_unregister_module(PoolInst[i].functionName); #endif } MPKNSS_LOCK(); diff --git a/src/nwnss/comn/common/mgmtVol.c b/src/nwnss/comn/common/mgmtVol.c index cb9e5a4..467e27b 100644 --- a/src/nwnss/comn/common/mgmtVol.c +++ b/src/nwnss/comn/common/mgmtVol.c @@ -64,7 +64,6 @@ #include "checker.h" #include "zasAuthModel.h" #include "objectIDStore.h" -#include "adminVolume.h" SNINT MGMT_VolumeFunctionsRegistered = 0; @@ -291,13 +290,13 @@ STATUS volume_compPreCompressedBytes( BYTE *byteval; LONG size, sized; - formattedSize(volume->VOLnumPreCompressedFileBlocks << volume->VOLblockShift, + formattedSize(volume->VOLnumPreCompressedFileBlocks << volume->VOLblockShift, &size, &sized, &byteval); - sprintf(data, MSGNot("%Lu (%d.%d %s)"), + sprintf(data, MSGNot("%Lu (%d.%d %s)"), volume->VOLnumPreCompressedFileBlocks << volume->VOLblockShift, size, sized, byteval); - + return VIRT_AddResultElement(virtInfo, TAG_PRECOMPRESSIONBYTES, data, TRUE); } @@ -314,7 +313,7 @@ STATUS volume_compCompressedBytes( formattedSize(volume->VOLnumCompressedFileBlocks << volume->VOLblockShift, &size, &sized, &byteval); - sprintf(data, MSGNot("%Lu (%d.%d %s)"), + sprintf(data, MSGNot("%Lu (%d.%d %s)"), volume->VOLnumCompressedFileBlocks << volume->VOLblockShift, size, sized, byteval); @@ -377,7 +376,7 @@ STATUS volume_salFreeableSize( formattedSize(volume->VOLpurgeableBlocks << volume->VOLblockShift, &size, &sized, &byteval); - sprintf(data, MSGNot("%Lu (%d.%d %s)"), + sprintf(data, MSGNot("%Lu (%d.%d %s)"), volume->VOLpurgeableBlocks << volume->VOLblockShift, size, sized, byteval); @@ -398,7 +397,7 @@ STATUS volume_salNonFreeableSize( formattedSize(volume->VOLnonPurgeableBlocks << volume->VOLblockShift, &size, &sized, &byteval); - sprintf(data, MSGNot("%Lu (%d.%d %s)"), + sprintf(data, MSGNot("%Lu (%d.%d %s)"), volume->VOLnonPurgeableBlocks << volume->VOLblockShift, size, sized, byteval); @@ -489,7 +488,7 @@ STATUS volume_size( formattedSize(volume->VOLtotalBlocks << volume->VOLblockShift, &size, &sized, &byteval); - sprintf(data, MSGNot("%Lu (%d.%d %s)"), + sprintf(data, MSGNot("%Lu (%d.%d %s)"), volume->VOLtotalBlocks << volume->VOLblockShift, size, sized, byteval); @@ -508,13 +507,13 @@ STATUS volume_notInUseSize( BYTE *byteval; LONG size, sized; QUAD notInUseSize; - + notInUseSize = (SQUAD)(volume->VOLtotalBlocks - volume->VOLinUseBlocks + volume->VOLpurgeableBlocks) > volume->VOLfreeBlockAdjustment ? - volume->VOLtotalBlocks - volume->VOLinUseBlocks + volume->VOLpurgeableBlocks - volume->VOLfreeBlockAdjustment : 0; + volume->VOLtotalBlocks - volume->VOLinUseBlocks + volume->VOLpurgeableBlocks - volume->VOLfreeBlockAdjustment : 0; formattedSize(notInUseSize << volume->VOLblockShift, &size, &sized, &byteval); - sprintf(data, MSGNot("%Lu (%d.%d %s)"), + sprintf(data, MSGNot("%Lu (%d.%d %s)"), notInUseSize << volume->VOLblockShift, size, sized, byteval); @@ -538,7 +537,7 @@ STATUS volume_freeSpacePercent( } else { - sprintf(data, MSGNot("%d"), + sprintf(data, MSGNot("%d"), (((SQUAD)(volume->VOLtotalBlocks - volume->VOLinUseBlocks + volume->VOLpurgeableBlocks) > volume->VOLfreeBlockAdjustment) ? 100 * (volume->VOLtotalBlocks - volume->VOLinUseBlocks + volume->VOLpurgeableBlocks - volume->VOLfreeBlockAdjustment) : 0) /volume->VOLtotalBlocks ); @@ -575,7 +574,7 @@ STATUS volume_attributes( if (supportedFlag) { attributes = volume->VOLsupportedAttributes; - if ((status = VIRT_AddResultTag(virtInfo, + if ((status = VIRT_AddResultTag(virtInfo, TAG_SUPPORTEDATTRIBUTES, FALSE, FALSE)) != zOK) { goto exit; @@ -584,7 +583,7 @@ STATUS volume_attributes( else { attributes = volume->VOLenabledAttributes; - if ((status = VIRT_AddResultTag(virtInfo, + if ((status = VIRT_AddResultTag(virtInfo, TAG_ENABLEDATTRIBUTES, FALSE, FALSE)) != zOK) { goto exit; @@ -600,7 +599,7 @@ STATUS volume_attributes( } if (attributes & zATTR_USER_SPACE_RESTRICTIONS) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("USER_SPACE_RESTRICTIONS "))) != zOK) { goto exit; @@ -608,7 +607,7 @@ STATUS volume_attributes( } if (attributes & zATTR_READONLY) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("READ_ONLY "))) != zOK) { goto exit; @@ -616,7 +615,7 @@ STATUS volume_attributes( } if (attributes & zATTR_COMPRESSION) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("COMPRESSION "))) != zOK) { goto exit; @@ -624,7 +623,7 @@ STATUS volume_attributes( } if (attributes & zATTR_EXTENDED_ATTRIBUTES) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("EXTENDED_ATTRIBUTES "))) != zOK) { goto exit; @@ -632,7 +631,7 @@ STATUS volume_attributes( } if (attributes & zATTR_DATA_STREAMS) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("DATA_STREAMS "))) != zOK) { goto exit; @@ -640,7 +639,7 @@ STATUS volume_attributes( } if (attributes & zATTR_DOS_METADATA) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("DOS_METADATA "))) != zOK) { goto exit; @@ -648,7 +647,7 @@ STATUS volume_attributes( } if (attributes & zATTR_NETWARE_METADATA) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("NETWARE_METADATA "))) != zOK) { goto exit; @@ -656,7 +655,7 @@ STATUS volume_attributes( } if (attributes & zATTR_MAC_METADATA) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("MAC_METADATA "))) != zOK) { goto exit; @@ -664,7 +663,7 @@ STATUS volume_attributes( } if (attributes & zATTR_UNIX_METADATA) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("UNIX_METADATA "))) != zOK) { goto exit; @@ -672,7 +671,7 @@ STATUS volume_attributes( } if (attributes & zATTR_HARD_LINKS) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("HARD_LINKS "))) != zOK) { goto exit; @@ -680,7 +679,7 @@ STATUS volume_attributes( } if (attributes & zATTR_TRANSACTION) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("SYSTEM_TRANSACTION "))) != zOK) { goto exit; @@ -688,7 +687,7 @@ STATUS volume_attributes( } if (attributes & zATTR_SPARSE_FILES) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("SPARSE_FILES "))) != zOK) { goto exit; @@ -696,7 +695,7 @@ STATUS volume_attributes( } if (attributes & zATTR_PHYSICAL_EOF) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("PHYSICAL_EOF "))) != zOK) { goto exit; @@ -704,7 +703,7 @@ STATUS volume_attributes( } if (attributes & zATTR_DIRECT_IO) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("DIRECT_IO "))) != zOK) { goto exit; @@ -712,7 +711,7 @@ STATUS volume_attributes( } if (attributes & zATTR_PERSISTENT_ATTRIBUTES) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("PERSISTENT_ATTRIBUTES "))) != zOK) { goto exit; @@ -720,7 +719,7 @@ STATUS volume_attributes( } if (attributes & zATTR_VERIFY) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("VERIFY "))) != zOK) { goto exit; @@ -728,7 +727,7 @@ STATUS volume_attributes( } if (attributes & zATTR_REBUILD) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("REBUILD "))) != zOK) { goto exit; @@ -736,7 +735,7 @@ STATUS volume_attributes( } if (attributes & zATTR_COW) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("SNAP_SHOTTING "))) != zOK) { goto exit; @@ -744,7 +743,7 @@ STATUS volume_attributes( } if (attributes & zATTR_VIRTUAL_FILES) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("VIRTUAL_FILES "))) != zOK) { goto exit; @@ -752,7 +751,7 @@ STATUS volume_attributes( } if (attributes & zATTR_USER_TRANSACTION) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("USER_TRANSACTIONS_PENDING "))) != zOK) { goto exit; @@ -760,7 +759,7 @@ STATUS volume_attributes( } if (attributes & zATTR_USER_TRANSACTION_ACTIVE) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("USER_TRANSACTION "))) != zOK) { goto exit; @@ -768,7 +767,7 @@ STATUS volume_attributes( } if (attributes & zATTR_DONT_BACKUP) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("DONT_BACKUP "))) != zOK) { goto exit; @@ -776,7 +775,7 @@ STATUS volume_attributes( } if (attributes & zATTR_MFL) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("MFL "))) != zOK) { goto exit; @@ -784,7 +783,7 @@ STATUS volume_attributes( } if (attributes & zATTR_DIR_QUOTAS) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("DIRECTORY_QUOTAS "))) != zOK) { goto exit; @@ -792,7 +791,7 @@ STATUS volume_attributes( } if (attributes & zATTR_SHRED_DATA) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("SHRED_DATA "))) != zOK) { goto exit; @@ -800,7 +799,7 @@ STATUS volume_attributes( } if (attributes & zATTR_SHARED) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("SHARED "))) != zOK) { goto exit; @@ -808,7 +807,7 @@ STATUS volume_attributes( } if (attributes & zATTR_HIGH_INTEGRITY) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("HIGH_INTEGRITY "))) != zOK) { goto exit; @@ -816,7 +815,7 @@ STATUS volume_attributes( } if (attributes & zATTR_CFS_MASTER) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("CFS_MASTER "))) != zOK) { goto exit; @@ -824,7 +823,7 @@ STATUS volume_attributes( } if (attributes & zATTR_CFS_SLAVE) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("CFS_SLAVE "))) != zOK) { goto exit; @@ -832,7 +831,7 @@ STATUS volume_attributes( } if (attributes & zATTR_MIGRATION) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("MIGRATION "))) != zOK) { goto exit; @@ -840,7 +839,7 @@ STATUS volume_attributes( } if (attributes & zATTR_ENCRYPTED) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("ENCRYPTED "))) != zOK) { goto exit; @@ -848,7 +847,7 @@ STATUS volume_attributes( } if (attributes & zATTR_NO_ATIME) { - if ((status = VIRT_AddResultData(virtInfo, + if ((status = VIRT_AddResultData(virtInfo, MSGNot("NO_ACCESS_TIME "))) != zOK) { goto exit; @@ -857,12 +856,12 @@ STATUS volume_attributes( if (supportedFlag) { - status = VIRT_AddResultTag(virtInfo, TAG_SUPPORTEDATTRIBUTES, TRUE, + status = VIRT_AddResultTag(virtInfo, TAG_SUPPORTEDATTRIBUTES, TRUE, TRUE); } else { - status = VIRT_AddResultTag(virtInfo, TAG_ENABLEDATTRIBUTES, TRUE, + status = VIRT_AddResultTag(virtInfo, TAG_ENABLEDATTRIBUTES, TRUE, TRUE); } exit: @@ -878,7 +877,7 @@ STATUS volume_nameSpaces( Volume_s *volume) { STATUS status; - if ((status = VIRT_AddResultTag(virtInfo, + if ((status = VIRT_AddResultTag(virtInfo, TAG_NAMESPACES, FALSE, FALSE)) != zOK) { goto exit; @@ -946,7 +945,7 @@ STATUS volume_files( return VIRT_AddResultElement(virtInfo, TAG_FILES, data, TRUE); } - + /**************************************************************************** * Given a volume, find the maximum file size for the volume ****************************************************************************/ @@ -1055,13 +1054,13 @@ STATUS volume_mountStatus( COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); if (COMN_GetVolumeName(&genMsg, volume, aStack->vname, zMAX_COMPONENT_NAME) != zOK) { - zASSERT("Error getting volume name" == NULL); + zASSERT("Error getting volume name" == NULL); STACK_FREE(); return GetErrno(&genMsg); } - LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, &aStack->volName[1], + LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, &aStack->volName[1], zMAX_COMPONENT_NAME, aStack->vname, NULL); - aStack->volName[0] = strlen(&aStack->volName[1]); + aStack->volName[0] = strlen(&aStack->volName[1]); #ifndef __linux__ // LINUX_NetWareVol ZOS_MapVolumeNameToNumber(result, (BYTE *)aStack->volName, &volNumber); @@ -1125,8 +1124,8 @@ STATUS volume_nextZid( /**************************************************************************** - * volume_getExtendedInfo - returns extended 'getinfo' information about a - * volume. Allows the LSS that owns the volume to return LSS + * volume_getExtendedInfo - returns extended 'getinfo' information about a + * volume. Allows the LSS that owns the volume to return LSS * specific information also. ****************************************************************************/ /* VIRTUAL FILE -- READ FUNCTION */ @@ -1140,7 +1139,7 @@ STATUS volume_getExtendedInfo( GeneralMsg_s genMsg; typedef struct { - unicode_t uni_pname[zMAX_COMPONENT_NAME]; + unicode_t uni_pname[zMAX_COMPONENT_NAME]; BYTE data[6*1024]; VCO_VolumeCommonOps_s pCD; } AllocStuff_s; @@ -1176,14 +1175,14 @@ STATUS volume_getExtendedInfo( * a Slatch, but waits(deadlocks) for the 2nd Slatch, because * Thread C requested a Xlatch. */ - S_LATCH( &volume->stateLatch ); + S_LATCH( &volume->stateLatch ); as->pCD.u.VCO_getInfo.VGI_action = 0; - status = volume->VOLcomnVolOps.VOL_commandFunction( + status = volume->VOLcomnVolOps.VOL_commandFunction( &genMsg, volume, VCO_VOLUME_GET_INFO_NUMBER, &as->pCD, parmLen, parm, /*dataLen*/ 0, /*data*/ NULL, /*offset*/ 0, sizeof( as->data ), as->data, &retLen); - UNS_LATCH( &volume->stateLatch ); + UNS_LATCH( &volume->stateLatch ); if ( status != zOK ) { @@ -1197,7 +1196,7 @@ STATUS volume_getExtendedInfo( status = GetErrno(&genMsg); goto exit; } - status = VIRT_AddResultData(virtInfo, as->data); + status = VIRT_AddResultData(virtInfo, as->data); exit: free(as); @@ -1259,7 +1258,7 @@ STATUS allocateINFCookie( cookie->resultLen = 0; } return zOK; -} +} /**************************************************************************** * Send whatever is in the cookie buffer. Return TRUE if we filled the @@ -1330,7 +1329,7 @@ STATUS volume_userInfo( struct { - struct + struct { unicode_t *namePtr; unicode_t uniName[MAX_DN_CHARS+1]; @@ -1351,7 +1350,7 @@ STATUS volume_userInfo( } cookie = (INFControlCookie_s *)virtInfo->memPtr; - /* + /* * Send anything that happens to be held in the cookie buffer. If this * fills the output buffer then we are done with this request. */ @@ -1407,8 +1406,8 @@ STATUS volume_userInfo( while (bufBytesLeft > 0 && !cookie->done) { numEntriesRequested = MAX_USER_INFO_ENTRIES; - if (volume->VOLcomnVolOps.VOL_browseUsersInVolume(&genMsg, volume, - MAX_USER_INFO_ENTRIES, &cookie->u.uCursor, alloc->userInfo, + if (volume->VOLcomnVolOps.VOL_browseUsersInVolume(&genMsg, volume, + MAX_USER_INFO_ENTRIES, &cookie->u.uCursor, alloc->userInfo, &numEntriesObtained, BROWSE_USERS_GET_ALL) != zOK) { status = GetErrno(&genMsg); @@ -1426,10 +1425,10 @@ STATUS volume_userInfo( #endif (void)LB_GUIDToString(&alloc->userInfo[i].userID, GUID_FORMAT_SIZE, id); /* put out standard user info */ - sprintf(cookie->resultBuf + cookie->resultLen, - MSGNot("<" TAG_USER "><" TAG_ID ">%s<" - TAG_SPACEUSED ">%Ld<" - TAG_QUOTAAMOUNT ">%Ld\n"), + sprintf(cookie->resultBuf + cookie->resultLen, + MSGNot("<" TAG_USER "><" TAG_ID ">%s<" + TAG_SPACEUSED ">%Ld<" + TAG_QUOTAAMOUNT ">%Ld\n"), id, alloc->userInfo[i].usedAmount, alloc->userInfo[i].restrictionAmount); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); @@ -1439,21 +1438,21 @@ STATUS volume_userInfo( */ if ((volume->VOLcomnVolOps.VOL_getObjectName(&genMsg, volume, - &alloc->userInfo[i].userID, alloc->uniName, &timeNotFound, + &alloc->userInfo[i].userID, alloc->uniName, &timeNotFound, &numberOfTimesNotFound) != zOK) || (alloc->uniName[0] == 0)) { - sprintf(cookie->resultBuf + cookie->resultLen, + sprintf(cookie->resultBuf + cookie->resultLen, MSGNot("<" TAG_NAME ">unknown\n")); - cookie->resultLen += strlen(cookie->resultBuf + + cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); } else { - sprintf(cookie->resultBuf + cookie->resultLen, + sprintf(cookie->resultBuf + cookie->resultLen, MSGNot("<" TAG_NAME ">%U\n"), alloc->uniName); - cookie->resultLen += strlen(cookie->resultBuf + + cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(YELLOW, @@ -1466,36 +1465,36 @@ STATUS volume_userInfo( * Check to make sure we can still look up this name. */ MPKNSS_UNLOCK(); - ccode = (*DDCNameToIDPtr)(context, DS_CREATE_ID, + ccode = (*DDCNameToIDPtr)(context, DS_CREATE_ID, &alloc->uniName); MPKNSS_LOCK(); #endif if (ccode != 0) { - /* + /* * Got an error looking up the name. Add "not found" tag. */ #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LRED, "volume_userInfo: User %U not found in NDS.\n", alloc->uniName); #endif - sprintf(cookie->resultBuf + cookie->resultLen, - MSGNot("<" TAG_IDNOTFOUND "><" TAG_TIME "><" + sprintf(cookie->resultBuf + cookie->resultLen, + MSGNot("<" TAG_IDNOTFOUND "><" TAG_TIME "><" TAG_UTC ">%d<" TAG_STRING ">%s<" - TAG_NUMBEROFTIMES ">%d%d\n"), - timeNotFound, UTCTime2Str(timeNotFound, timeString), + timeNotFound, UTCTime2Str(timeNotFound, timeString), numberOfTimesNotFound); - cookie->resultLen += strlen(cookie->resultBuf + + cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); } } #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LCYAN, "user finished: %U\n", &alloc->uniName); #endif - sprintf(cookie->resultBuf + cookie->resultLen, + sprintf(cookie->resultBuf + cookie->resultLen, MSGNot("\n")); - cookie->resultLen += strlen(cookie->resultBuf + + cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); cookie->u.uCursor = alloc->userInfo[i].userID; if (sendINFResult(cookie, &bufBytesLeft, &outBuf, retLen)) @@ -1521,14 +1520,14 @@ sendRetcode: /* send the status */ sprintf(cookie->resultBuf + cookie->resultLen, MSGNot("\n")); - cookie->resultLen += strlen(cookie->resultBuf + + cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); MGMT_BuildResultNSS(status, cookie->resultBuf + cookie->resultLen); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); sprintf(cookie->resultBuf + cookie->resultLen, MSGNot("\n")); - cookie->resultLen += strlen(cookie->resultBuf + + cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); sendINFResult(cookie, &bufBytesLeft, &outBuf, retLen); } @@ -1581,7 +1580,7 @@ STATUS volume_dirInfo( } cookie = (INFControlCookie_s *)virtInfo->memPtr; - /* + /* * Send anything that happens to be held in the cookie buffer. If this * fills the output buffer then we are done with this request. */ @@ -1628,8 +1627,8 @@ STATUS volume_dirInfo( while (bufBytesLeft > 0 && !cookie->done) { numEntriesRequested = MAX_DIR_INFO_ENTRIES; - if (volume->VOLcomnVolOps.VOL_browseDirsInVolume(&genMsg, volume, - MAX_DIR_INFO_ENTRIES, &cookie->u.dCursor, aStack->dirInfo, + if (volume->VOLcomnVolOps.VOL_browseDirsInVolume(&genMsg, volume, + MAX_DIR_INFO_ENTRIES, &cookie->u.dCursor, aStack->dirInfo, &numEntriesObtained) != zOK) { status = GetErrno(&genMsg); @@ -1642,7 +1641,7 @@ STATUS volume_dirInfo( for (i = 0; i < numEntriesObtained; ++i) { - if (COMN_GetFileNameFromZid(&genMsg, volume, aStack->dirInfo[i].dirZid, + if (COMN_GetFileNameFromZid(&genMsg, volume, aStack->dirInfo[i].dirZid, zNSPACE_LONG, path, FALSE) != zOK) { status = GetErrno(&genMsg); @@ -1650,14 +1649,14 @@ STATUS volume_dirInfo( } /* put out standard directory quota info */ - sprintf(cookie->resultBuf + cookie->resultLen, - MSGNot("<" TAG_DIRECTORY "><" - TAG_ZID ">%Lu<" - TAG_PATH ">%U<" - TAG_SPACEUSED ">%Ld<" - TAG_QUOTAAMOUNT ">%Ld" - "\n"), - aStack->dirInfo[i].dirZid, path, aStack->dirInfo[i].usedAmount, + sprintf(cookie->resultBuf + cookie->resultLen, + MSGNot("<" TAG_DIRECTORY "><" + TAG_ZID ">%Lu<" + TAG_PATH ">%U<" + TAG_SPACEUSED ">%Ld<" + TAG_QUOTAAMOUNT ">%Ld" + "\n"), + aStack->dirInfo[i].dirZid, path, aStack->dirInfo[i].usedAmount, aStack->dirInfo[i].quota); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); cookie->u.dCursor = aStack->dirInfo[i].dirZid; @@ -1684,14 +1683,14 @@ sendRetcode: /* send the status */ sprintf(cookie->resultBuf + cookie->resultLen, MSGNot("\n")); - cookie->resultLen += strlen(cookie->resultBuf + + cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); MGMT_BuildResultNSS(status, cookie->resultBuf + cookie->resultLen); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); sprintf(cookie->resultBuf + cookie->resultLen, MSGNot("\n")); - cookie->resultLen += strlen(cookie->resultBuf + + cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); sendINFResult(cookie, &bufBytesLeft, &outBuf, retLen); } @@ -1721,7 +1720,7 @@ void convertRightsToTags( zAUTHORIZE_MODIFY_METADATA | zAUTHORIZE_SUPERVISOR | zAUTHORIZE_SALVAGE | zAUTHORIZE_SECURE); - utf8_t rightsTags[16][20] = + utf8_t rightsTags[16][20] = { {TAG_READ}, {TAG_WRITE}, @@ -1812,7 +1811,7 @@ void releaseTrusteeCookie( } } return; -} +} /**************************************************************************** * Allocate a cookie structure for trustee info. @@ -1845,7 +1844,7 @@ STATUS allocateTrusteeCookie( virtInfo->closeFunc = releaseTrusteeCookie; } return zOK; -} +} /**************************************************************************** * Send whatever is in the cookie buffer. Return TRUE if we filled the @@ -1911,7 +1910,7 @@ void insertEntry( cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); sprintf(cookie->resultBuf + cookie->resultLen, "<" TAG_ID ">"); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); - LB_GUIDToString(userID, cookie->resultBufLen - cookie->resultLen, + LB_GUIDToString(userID, cookie->resultBufLen - cookie->resultLen, cookie->resultBuf + cookie->resultLen); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); sprintf(cookie->resultBuf + cookie->resultLen, @@ -1926,7 +1925,7 @@ void insertEntry( sprintf(cookie->resultBuf + cookie->resultLen, "\n"); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); STACK_FREE(); - return; + return; } /**************************************************************************** @@ -1954,20 +1953,20 @@ void insertTrustees( sprintf(cookie->resultBuf + cookie->resultLen, "<" TAG_INHERITEDRIGHTSFILTER " " ATR_VALUE "=\""); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); - convertRightsToChars(authInfo->p.inheritedRightsMask, - cookie->resultBuf + cookie->resultLen); + convertRightsToChars(authInfo->p.inheritedRightsMask, + cookie->resultBuf + cookie->resultLen); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); sprintf(cookie->resultBuf + cookie->resultLen, "\">"); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); - convertRightsToTags(authInfo->p.inheritedRightsMask, - cookie->resultBuf + cookie->resultLen); + convertRightsToTags(authInfo->p.inheritedRightsMask, + cookie->resultBuf + cookie->resultLen); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); sprintf(cookie->resultBuf + cookie->resultLen, - "\n"); + "\n"); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); } - if ((authInfo->p.numTrusteesAssigned == 0) && + if ((authInfo->p.numTrusteesAssigned == 0) && (authInfo->p.trusteeOverflow == NULL)) { return; @@ -1978,7 +1977,7 @@ void insertTrustees( /* search the main beast for the trustees */ for (i = 0; i < authInfo->p.numTrusteesAssigned && i < 4; i++) { - insertEntry(volume, authInfo->p.ACL[i].rights, + insertEntry(volume, authInfo->p.ACL[i].rights, &authInfo->p.ACL[i].trusteeID, cookie); } } @@ -1996,9 +1995,9 @@ void insertTrustees( } for (entry=0; entry < overflowBeast->p.numEntries; entry++) { - insertEntry(volume, overflowBeast->acl[entry].rights, + insertEntry(volume, overflowBeast->acl[entry].rights, &overflowBeast->acl[entry].trusteeID, cookie); - if (cookie->resultLen + TRUSTEE_COOKIE_ALLOC_SIZE > + if (cookie->resultLen + TRUSTEE_COOKIE_ALLOC_SIZE > cookie->resultBufLen) { cookie->resultBufLen += TRUSTEE_COOKIE_ALLOC_SIZE; @@ -2017,7 +2016,7 @@ void insertTrustees( } return; -} +} /**************************************************************************** * Generate a list of trustees for the volume. @@ -2068,7 +2067,7 @@ STATUS volume_trusteeInfo( } cookie = (TrusteeControlCookie_s *)virtInfo->memPtr; - /* + /* * Send anything that happens to be held in the result buffer. If this * fills the output buffer then we are done with this request. */ @@ -2124,7 +2123,7 @@ STATUS volume_trusteeInfo( numEntriesRequested = MAX_ZID_ENTRIES; if (volume->VOLcomnVolOps.VOL_browseBeastsInVolume(&genMsg, volume, - SELECT_BEASTS_ALL, MAX_ZID_ENTRIES, &cookie->cursor, + SELECT_BEASTS_ALL, MAX_ZID_ENTRIES, &cookie->cursor, aStack->zidArray, &numEntriesObtained) != zOK) { status = GetErrno(&genMsg); @@ -2167,7 +2166,7 @@ STATUS volume_trusteeInfo( } authInfo = ((File_s *)beast)->FILEauthInfo.zas; - if ((authInfo->p.numTrusteesAssigned == 0) && + if ((authInfo->p.numTrusteesAssigned == 0) && (authInfo->p.trusteeOverflow == NULL) && ((authInfo->p.inheritedRightsMask == 0xFFFFFFFF) || (authInfo->p.inheritedRightsMask == 0xFFFF) || @@ -2177,19 +2176,19 @@ STATUS volume_trusteeInfo( continue; } - if (COMN_GetFileNameFromZid(&genMsg, volume, aStack->zidArray[i], + if (COMN_GetFileNameFromZid(&genMsg, volume, aStack->zidArray[i], nameSpace, uniPath, FALSE) != zOK) { unicpy(uniPath, L"***Error***\n"); } /* put out file name info */ - sprintf(cookie->resultBuf + cookie->resultLen, - "<" TAG_FILE ">\n<" - TAG_ZID ">%Lu<" + sprintf(cookie->resultBuf + cookie->resultLen, + "<" TAG_FILE ">\n<" + TAG_ZID ">%Lu<" TAG_PATH ">", aStack->zidArray[i]); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); - uni2utf(uniPath, cookie->resultBuf + cookie->resultLen, + uni2utf(uniPath, cookie->resultBuf + cookie->resultLen, cookie->resultBufLen - cookie->resultLen); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); @@ -2226,14 +2225,14 @@ sendRetcode: /* send the status */ sprintf(cookie->resultBuf + cookie->resultLen, MSGNot("\n")); - cookie->resultLen += strlen(cookie->resultBuf + + cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); MGMT_BuildResultNSS(status, cookie->resultBuf + cookie->resultLen); cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); sprintf(cookie->resultBuf + cookie->resultLen, MSGNot("\n")); - cookie->resultLen += strlen(cookie->resultBuf + + cookie->resultLen += strlen(cookie->resultBuf + cookie->resultLen); sendTrusteeResult(cookie, &bufBytesLeft, &outBuf, retLen); } @@ -2292,19 +2291,19 @@ STATUS volume_getInfo( * put in what used to be called "extended info" including lss specific * info. */ - if ((status = + if ((status = volume_getExtendedInfo(parmLen, parm, virtInfo, volume)) != zOK) { goto done; } - /* - * put in the user usage statistics + /* + * put in the user usage statistics */ if ((status = volume_mountStatus(virtInfo, volume)) != zOK) { goto done; } - if ((status = + if ((status = VIRT_AddResultTag(virtInfo, TAG_USERIO, FALSE, TRUE)) != zOK) { goto done; @@ -2337,16 +2336,16 @@ STATUS volume_getInfo( goto done; } #endif - if ((status = + if ((status = VIRT_AddResultTag(virtInfo, TAG_USERIO, TRUE, TRUE)) != zOK) { goto done; } #if NSS_DEBUG IS_ENABLED - /* - * put in the system usage statistics + /* + * put in the system usage statistics */ - if ((status = + if ((status = VIRT_AddResultTag(virtInfo, TAG_SYSTEMIO, FALSE, TRUE)) != zOK) { goto done; @@ -2375,7 +2374,7 @@ STATUS volume_getInfo( { goto done; } - if ((status = + if ((status = VIRT_AddResultTag(virtInfo, TAG_SYSTEMIO, TRUE, TRUE)) != zOK) { goto done; @@ -2384,7 +2383,7 @@ STATUS volume_getInfo( /* * put in the compression info */ - if ((status = + if ((status = VIRT_AddResultTag(virtInfo, TAG_COMPRESSION, FALSE, TRUE)) != zOK) { goto done; @@ -2405,13 +2404,13 @@ STATUS volume_getInfo( { goto done; } - if ((status = + if ((status = VIRT_AddResultTag(virtInfo, TAG_COMPRESSION, TRUE, TRUE)) != zOK) { goto done; } - /* - * put in the salvage info + /* + * put in the salvage info */ if ((status = VIRT_AddResultTag(virtInfo, TAG_SALVAGE, FALSE, TRUE)) != zOK) @@ -2560,12 +2559,12 @@ typedef struct VolAVFileInst_s VolAVFileInst_s VolumeInst[] = { {NULL, TRUE, FALSE, TRUE, NULL, NULL, NULL, NULL}, - {NULL, FALSE, TRUE, TRUE, MSGNot("EFL_ControlReadFunc"), MSGNot("EFL_ControlWriteFunc"), (statusfunc_t)EFL_ControlReadFunc, (statusfunc_t)EFL_ControlWriteFunc}, - {NULL, FALSE, TRUE, TRUE, MSGNot("SBS_volumeMFLControlReadFunc"), MSGNot("SBS_volumeMFLControlWriteFunc"), (statusfunc_t)SBS_volumeMFLControlReadFunc, (statusfunc_t)SBS_volumeMFLControlWriteFunc}, - {NULL, FALSE, FALSE, TRUE, MSGNot("volume_getInfo"), NULL, (statusfunc_t)volume_getInfo, NULL}, - {NULL, FALSE, TRUE, TRUE, MSGNot("volume_userInfo"), NULL, (statusfunc_t)volume_userInfo, NULL}, - {NULL, FALSE, TRUE, TRUE, MSGNot("volume_dirInfo"), NULL, (statusfunc_t)volume_dirInfo, NULL}, - {NULL, FALSE, TRUE, TRUE, MSGNot("volume_trusteeInfo"), NULL, (statusfunc_t)volume_trusteeInfo, NULL}, + {NULL, FALSE, TRUE, TRUE, MSGNot("EFL_ControlReadFunc"), MSGNot("EFL_ControlWriteFunc"), EFL_ControlReadFunc, EFL_ControlWriteFunc}, + {NULL, FALSE, TRUE, TRUE, MSGNot("SBS_volumeMFLControlReadFunc"), MSGNot("SBS_volumeMFLControlWriteFunc"), SBS_volumeMFLControlReadFunc, SBS_volumeMFLControlWriteFunc}, + {NULL, FALSE, FALSE, TRUE, MSGNot("volume_getInfo"), NULL, volume_getInfo, NULL}, + {NULL, FALSE, TRUE, TRUE, MSGNot("volume_userInfo"), NULL, volume_userInfo, NULL}, + {NULL, FALSE, TRUE, TRUE, MSGNot("volume_dirInfo"), NULL, volume_dirInfo, NULL}, + {NULL, FALSE, TRUE, TRUE, MSGNot("volume_trusteeInfo"), NULL, volume_trusteeInfo, NULL}, {0}, }; @@ -2636,10 +2635,10 @@ STATUS addVolumeMgmtFile( { strcpy(&pathStr[AVFileMgmtDirLen], MSGNot("Volume")); - ZOS_zCreate(status, rootKey, zNO_TASK, 0, + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, pathStr, zFILE_REGULAR, AVFILEDIRATTR, zCREATE_OPEN_IF_THERE, zRR_WRITE_ACCESS, &retKey); - if (status != zOK) + if (status != zOK) { zASSERT("Error creating volume admin directory" == 0); SetErrno(genMsg, status); @@ -2652,7 +2651,7 @@ STATUS addVolumeMgmtFile( VolumeBaseDirIsSetUp = TRUE; } - LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, aStack->name, zMAX_COMPONENT_NAME, + LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, aStack->name, zMAX_COMPONENT_NAME, volumeName, NULL); for(i = 0; VolumeInst[i].path != 0; i++) @@ -2677,12 +2676,12 @@ STATUS addVolumeMgmtFile( createAttr = AVFILEFILEATTR; } - ZOS_zCreate(status, rootKey, zNO_TASK, 0, - zNSPACE_LONG | zMODE_UTF8, pathStr, zFILE_REGULAR, + ZOS_zCreate(status, rootKey, zNO_TASK, 0, + zNSPACE_LONG | zMODE_UTF8, pathStr, zFILE_REGULAR, createAttr, zCREATE_OPEN_IF_THERE, zRR_WRITE_ACCESS, &retKey); if (status != zOK) { - /* + /* * This check is here because of a bug in zCreate. It can be * removed when zCreate opens an existing directory without * an error. @@ -2693,16 +2692,16 @@ STATUS addVolumeMgmtFile( zASSERT("Error during create" == 0); goto errorClose; } - ZOS_zOpen(status, rootKey, zNO_TASK, zNSPACE_LONG | zMODE_UTF8, + ZOS_zOpen(status, rootKey, zNO_TASK, zNSPACE_LONG | zMODE_UTF8, pathStr, zRR_WRITE_ACCESS, &retKey); } if (!VolumeInst[i].isDir) { /* Write the transformation template to the file */ - if ((status = MGMTS_MakeFunctionVirtualFile(retKey, - VolumeInst[i].readFunctionName, aStack->name, - VolumeInst[i].writeFunctionName, aStack->name, + if ((status = MGMTS_MakeFunctionVirtualFile(retKey, + VolumeInst[i].readFunctionName, aStack->name, + VolumeInst[i].writeFunctionName, aStack->name, VolumeInst[i].useCookieRead)) != zOK) { zASSERT("Error writing transformation template" == 0); @@ -2717,20 +2716,20 @@ STATUS addVolumeMgmtFile( if (VolumeInst[i].readFunctionName) { #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) - inter_module_register(VolumeInst[i].readFunctionName, + inter_module_register(VolumeInst[i].readFunctionName, THIS_MODULE, VolumeInst[i].readFunction); #else - nss_register_module(VolumeInst[i].readFunctionName, + nss_register_module(VolumeInst[i].readFunctionName, VolumeInst[i].readFunction, THIS_MODULE ); #endif } if (VolumeInst[i].writeFunctionName) { #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) - inter_module_register(VolumeInst[i].writeFunctionName, + inter_module_register(VolumeInst[i].writeFunctionName, THIS_MODULE, VolumeInst[i].writeFunction); #else - nss_register_module(VolumeInst[i].writeFunctionName, + nss_register_module(VolumeInst[i].writeFunctionName, VolumeInst[i].writeFunction, THIS_MODULE); #endif } @@ -2748,7 +2747,7 @@ STATUS addVolumeMgmtFile( zASSERT(status == zOK); free(pathStr); STACK_FREE(); - return zOK; + return zOK; errorClose: ZOS_zClose(status, rootKey); @@ -2764,7 +2763,7 @@ errorExit: * Remove loaded volume as management files ***************************************************************************/ void removeVolumeMgmtFileByName( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, unicode_t *volumeName) { NINT i; @@ -2779,7 +2778,7 @@ void removeVolumeMgmtFileByName( ASSERT_MPKNSS_LOCK(); - LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, aStack->name, zMAX_COMPONENT_NAME, + LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, aStack->name, zMAX_COMPONENT_NAME, volumeName, NULL); memcpy(aStack->pathStr, AVFileMgmtDir, AVFileMgmtDirLen); @@ -2810,9 +2809,9 @@ void removeVolumeMgmtFileByName( if (VolumeInst[i].readFunctionName) { #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) - inter_module_unregister(VolumeInst[i].readFunctionName); + inter_module_unregister(VolumeInst[i].readFunctionName); #else - nss_unregister_module(VolumeInst[i].readFunctionName); + nss_unregister_module(VolumeInst[i].readFunctionName); #endif } if (VolumeInst[i].writeFunctionName) @@ -2839,7 +2838,7 @@ errorExit: * Remove loaded volume as management files ***************************************************************************/ void removeVolumeMgmtFile( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, void *volume) { typedef struct Stack_s { diff --git a/src/nwnss/comn/common/name.c b/src/nwnss/comn/common/name.c index ae68b9e..8b5f8b4 100644 --- a/src/nwnss/comn/common/name.c +++ b/src/nwnss/comn/common/name.c @@ -137,7 +137,7 @@ void NAME_MoveParentEntry( /**************************************************************************** * This will add the given name info to the beast with the given parent and - * nameUniquifier. + * nameUniquifier. * It does not check to see if the name already exists. It trusts that the * caller has already validated that the name does not exist, and that * the name is valid. @@ -179,7 +179,7 @@ STATUS COMN_AddNameToBeast( * Now, we simply add everything to the first (and only) parent entry. *---------------------------------------------------------------------------*/ if (NAME_doAddName(genMsg,beast,&beast->firstParent, - nameSpaceMask,name,nsFlags) != zOK) + nameSpaceMask,name,nsFlags) != zOK) { RTN_STATUS(zFAILURE); } @@ -187,8 +187,8 @@ STATUS COMN_AddNameToBeast( if (primaryNameSpaceID != zNSPACE_INVALID) beast->NAMEDfirstParentPrimaryNameSpaceID = primaryNameSpaceID; - /* If this is the first name added to this parent entry, the ZID will - * be zINVALID_ZID. Subsequent names for other namespaces will find + /* If this is the first name added to this parent entry, the ZID will + * be zINVALID_ZID. Subsequent names for other namespaces will find * the parent ZID already initialized. */ if (beast->NAMEDfirstParentZid == zINVALID_ZID) @@ -250,7 +250,7 @@ STATUS NAME_InsertAndMangleName( NINT nsFlag; NINT beastNamesAdded = 0; NINT dirNamesAdded = 0; - NINT beastNamesRemoved = 0; + NINT beastNamesRemoved = 0; NINT dirNamesRemoved = 0; // cnt NINT nameUniquifier; NINT addNameFlags = 0; @@ -345,7 +345,7 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, { case NAME_FAILED: goto error_removeAllNames; - + case NAME_CAN_BE_SHARED: /* The name may be shared, simply set the correct bit */ nameShareMask |= (1 << nsID); @@ -361,7 +361,7 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, if (COMN_AddNameToBeast(genMsg, beast, primaryBeast, parentZID, (1<flags & NSFLforceUpper) ? + ((nameSpace->flags & NSFLforceUpper) ? NAMEforcedUpper :0),xaction, &pentry) != zOK) { goto error_removeAllNames; @@ -387,7 +387,7 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, nameType, mangledName, nsFlag, /* cnt nameUniquifier,*/ addNameFlags, MA_ATTR_SET_MASK(beast->NAMEDattributes), - xaction, + xaction, ((flags & INSNAMEFL_DIRECTORY_ONLY) ? NULL : pentry->t)) != zOK) { goto error_removeAllNames; @@ -465,7 +465,7 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, directory, nameShareMask, nameType, name, nsFlag, /* cnt nameUniquifier ,*/ addNameFlags, MA_ATTR_SET_MASK(beast->NAMEDattributes), - xaction, + xaction, ((flags & INSNAMEFL_DIRECTORY_ONLY) ? NULL : pentry->t)) != zOK) { goto error_removeAllNames; @@ -539,7 +539,7 @@ error_removeAllNames: &beastNamesRemoved, &dirNamesRemoved, NULL); } else - { + { /* since we didn't insert name to beast, we expect that all names with * the same zid should be removed from directory */ @@ -548,7 +548,7 @@ error_removeAllNames: 0, 0, NULL, REMNAMEFL_REMOVE_ALL_NAMES, xaction, NULL); dirNamesRemoved++; } - + if ((beastNamesRemoved != beastNamesAdded) || (dirNamesRemoved != dirNamesAdded)) { @@ -591,7 +591,7 @@ STATUS COMN_GenerateUniqueName( unicode_t *mangledName) { NINT nameShareMode; - + /* Resolve to the Directory Beast */ if (COMN_Lookup(genMsg,nameMsg) != zOK) { @@ -611,7 +611,7 @@ STATUS COMN_GenerateUniqueName( return(zFAILURE); } return(zOK); -} +} /**************************************************************************** @@ -630,7 +630,7 @@ STATUS COMN_InsertAndMangleName( NINT *retBeastNamesAdded, NINT *retDirNamesAdded) { - return NAME_InsertAndMangleName(genMsg, voidBeast, NULL, voidDirectory, + return NAME_InsertAndMangleName(genMsg, voidBeast, NULL, voidDirectory, primaryNameSpaceID, nameType, name, flags, NULL, /* cnt retNameUniquifier, */ retBeastNamesAdded, retDirNamesAdded); } @@ -660,7 +660,7 @@ STATUS COMN_InsertAndMangleName( // cnt NINT dirNamesAdded = 0; // cnt NINT beastNamesRemoved, dirNamesRemoved; // cnt NINT addNameFlags; -// cnt +// cnt // cnt ASSERT_MPKNSS_LOCK(); // cnt ENTER(TNAMING, NAME_MoveDeletedNames); // cnt /*--------------------------------------------------------------------------- @@ -694,13 +694,13 @@ STATUS COMN_InsertAndMangleName( // cnt *retNameUniquifier = nameUniquifier; // cnt /*--------------------------------------------------------------------------- // cnt * Go through each individual nameEntry in the old parentEntry and move them -// cnt * one at a time. +// cnt * one at a time. // cnt *---------------------------------------------------------------------------*/ // cnt addNameFlags = NF_FIRST_NAME; // cnt DQ_FOREACH(&srcParentEntry->names, nnode, LinkedNameEntry_s, nlink) // cnt { // cnt nsFlag = nnode->p.flagsAndLen & ~NAMEnameLenMask; -// cnt +// cnt // cnt if (COMN_AddNameToBeast(genMsg, beast, // cnt nameUniquifier, // cnt targetDir->NAMEDzid, nnode->p.nameSpaceMask, // cnt srcParentEntry->p.primaryNameSpaceID, zNTYPE_DELETED_FILE, @@ -710,19 +710,19 @@ STATUS COMN_InsertAndMangleName( // cnt } // cnt beastNamesAdded++; // cnt COMN_MARK_BEAST_XLOCAL(&beast->NAMEDroot,xaction); -// cnt +// cnt // cnt /* remove any negative cache entries */ // cnt NAME_RemoveNameFromCache(genMsg, targetDir->NAMEDvolume, // cnt targetDir->NAMEDzid, nnode->p.nameSpaceMask, // cnt zNTYPE_DELETED_FILE, nnode->p.name, nsFlag); -// cnt +// cnt // cnt zASSERT((newParentEntry->t != NULL) && (srcParentEntry->t != NULL)); // cnt newParentEntry->t->u.deleted.time = srcParentEntry->t->u.deleted.time; // cnt newParentEntry->t->u.deleted.ID = srcParentEntry->t->u.deleted.ID; -// cnt +// cnt // cnt if (DQ_ISHEADNEXT(&srcParentEntry->names, nnode, LinkedNameEntry_s, nlink)) // cnt addNameFlags |= NF_LAST_NAME; -// cnt +// cnt // cnt if (targetDir->NAMEDcomnOps.BST_addNameToDirectory(genMsg, beast, // cnt targetDir, nnode->p.nameSpaceMask, zNTYPE_DELETED_FILE, // cnt nnode->p.name, nsFlag, /* cnt nameUniquifier,*/ addNameFlags, @@ -730,13 +730,13 @@ STATUS COMN_InsertAndMangleName( // cnt xaction, newParentEntry->t) != zOK) // cnt { // cnt goto error_removeTargetNames; -// cnt } +// cnt } // cnt dirNamesAdded++; // cnt addNameFlags &= ~NF_FIRST_NAME; // cnt COMN_MARK_BEAST_XLOCAL(&targetDir->NAMEDroot,xaction); // cnt zASSERT(beastNamesAdded == dirNamesAdded); // cnt } -// cnt +// cnt // cnt /*--------------------------------------------------------------------------- // cnt * All names have been successfully added to the target directory. // cnt * Now remove the names from the source directory/parentEntry. @@ -747,13 +747,13 @@ STATUS COMN_InsertAndMangleName( // cnt { // cnt /* We set the "ATOMIC" flag, so that if we get here we know that either // cnt * no src names were removed, or an AbendVolume occurred. Since we were -// cnt * unable to remove the original names from the srcDir, attempt to +// cnt * unable to remove the original names from the srcDir, attempt to // cnt * cleanup by removing the new names from the targetDir -- leaving the // cnt * old names in the srcDir -- and return an error. */ // cnt goto error_removeTargetNames; // cnt } // cnt COMN_MARK_BEAST_XLOCAL(&srcDir->NAMEDroot,xaction); -// cnt +// cnt // cnt /*--------------------------------------------------------------------------- // cnt * Adjust the authorization visibility // cnt *---------------------------------------------------------------------------*/ @@ -771,10 +771,10 @@ STATUS COMN_InsertAndMangleName( // cnt zASSERT("Failed to Add authorization info to the file"==NULL); // cnt } // cnt } -// cnt +// cnt // cnt /* Leave with the srcDir/beast still latched */ // cnt RTN_STATUS(zOK); -// cnt +// cnt // cnt /*===========================================================================*/ // cnt error_removeTargetNames: // cnt /* The targetDir is latched */ @@ -782,7 +782,7 @@ STATUS COMN_InsertAndMangleName( // cnt NAME_RemoveAllNames(genMsg,beast,targetDir, // cnt nameUniquifier, // cnt (REMNAMEFL_REMOVE_ALL_NAMES|REMNAMEFL_ERROR_BACKOUT), // cnt xaction, /* cnt NULL,*/&beastNamesRemoved, &dirNamesRemoved, NULL); -// cnt +// cnt // cnt if ((beastNamesRemoved != beastNamesAdded) || // cnt (dirNamesRemoved != dirNamesAdded)) // cnt { @@ -798,7 +798,7 @@ STATUS COMN_InsertAndMangleName( // cnt } // cnt COMN_MARK_BEAST_XLOCAL(&beast->NAMEDroot,xaction); // cnt COMN_MARK_BEAST_XLOCAL(&targetDir->NAMEDroot,xaction); -// cnt +// cnt // cnt error_cleanup: // cnt RTN_STATUS(zFAILURE); // cnt } @@ -806,7 +806,7 @@ STATUS COMN_InsertAndMangleName( /**************************************************************************** * This will move a beast from one parent to another, and if possible, it - * preserves all existing names in every namespace. Each existing name is + * preserves all existing names in every namespace. Each existing name is * individually checked for uniqueness in the new directory, and if necessary * it is mangled to be unique. *****************************************************************************/ @@ -905,8 +905,8 @@ STATUS NAME_MoveAndMangleNames( * "savedParentEntry". We will then use the "saved ParentEntry to add the * names back to the beast with the new directory. */ - if (NAME_RemoveAllNames(genMsg, beast, primaryBeast, srcDir, - REMNAMEFL_REMOVE_ALL_NAMES|REMNAMEFL_ATOMIC|REMNAMEFL_REMOVE_PARENT_AUTH, + if (NAME_RemoveAllNames(genMsg, beast, primaryBeast, srcDir, + REMNAMEFL_REMOVE_ALL_NAMES|REMNAMEFL_ATOMIC|REMNAMEFL_REMOVE_PARENT_AUTH, xaction, /* cnt NULL, */ NULL, NULL, &savedParentEntry) != zOK) { goto error_cleanup; @@ -940,7 +940,7 @@ STATUS NAME_MoveAndMangleNames( { case NAME_FAILED: goto error_removeTargetNames; - + case NAME_CAN_BE_SHARED: /* The name may be with original name, simply set the correct bit */ nameShareMask |= (1 << nsID); @@ -978,7 +978,7 @@ STATUS NAME_MoveAndMangleNames( xaction,newParentEntry->t) != zOK) { goto error_removeTargetNames; - } + } dirNamesAdded++; addNameFlags &= ~NF_FIRST_NAME; zASSERT(beastNamesAdded == dirNamesAdded); @@ -1043,7 +1043,7 @@ STATUS NAME_MoveAndMangleNames( xaction, newParentEntry->t) != zOK) { goto error_removeTargetNames; - } + } if (beast->NAMEDattributes & zFA_HARDLINK) { @@ -1085,7 +1085,7 @@ STATUS NAME_MoveAndMangleNames( // cnt { // cnt /* We set the "ATOMIC" flag, so that if we get here we know that either // cnt * no src names were removed, or an AbendVolume occurred. Since we were -// cnt * unable to remove the original names from the srcDir, attempt to +// cnt * unable to remove the original names from the srcDir, attempt to // cnt * cleanup by removing the new names from the targetDir -- leaving the // cnt * old names in the srcDir -- and return an error. */ // cnt goto error_removeTargetNames; @@ -1181,7 +1181,7 @@ error_removeTargetNames: if(targetDir->NAMEDcomnOps.BST_addNameToDirectory(genMsg, beast, srcDir, nnode->p.nameSpaceMask, savedParentEntry.p.nameType, - nnode->p.name, (nnode->p.flagsAndLen & ~NAMEnameLenMask), /* cnt nameUniquifier ,*/ + nnode->p.name, (nnode->p.flagsAndLen & ~NAMEnameLenMask), /* cnt nameUniquifier ,*/ addNameFlags, MA_ATTR_SET_MASK(beast->NAMEDattributes), xaction, savedParentEntry.t) != zOK) { @@ -1207,7 +1207,7 @@ error_during_removeTargetNames: { DQ_DEQ(&savedParentEntry.names, nnode, LinkedNameEntry_s, nlink); if(nnode != NULL) - free(nnode); + free(nnode); else break; } @@ -1222,7 +1222,7 @@ error_during_removeTargetNames: * This will return the parent entry for the given ZID, else it returns NULL *****************************************************************************/ //FixFixFix6: This routine matches INVALID name uniquifier against INVALID -// uniquifier and returns a first parent which has invalid +// uniquifier and returns a first parent which has invalid // entries. This needs to be looked at and fixed. eg for zid // 127 (root directory) of the volume ParentEntry_s *NAME_GetParentEntry( @@ -1278,7 +1278,7 @@ STATUS NAME_GetNameTypeInfo( if ((pentry = NAME_GetParentEntry(genMsg,beast /* cnt nameUniquifier*/)) == NULL) return(zFAILURE); - *nameTypeInfo = pentry->t; + *nameTypeInfo = pentry->t; return(zOK); } @@ -1443,7 +1443,7 @@ void NAME_RemoveStrandedParentEntry( { removeNameFlags &= ~NF_FIRST_NAME; } - } + } if (saveErrno != zOK) { @@ -1483,7 +1483,7 @@ void NAME_RemoveStrandedParentEntry( *****************************************************************************/ STATUS NAME_WillAddToSalvage( - NamedBeast_s *beast, + NamedBeast_s *beast, NamedBeast_s *directory, NINT flags, ParentEntry_s *pentry) @@ -1500,7 +1500,7 @@ STATUS NAME_WillAddToSalvage( { return(FALSE); } - return(TRUE); + return(TRUE); } @@ -1577,7 +1577,7 @@ STATUS NAME_RemoveAllNames( startingNameType = pentry->p.nameType; // remember the starting state for this file - zASSERT((pentry->p.zid == directory->NAMEDzid) || + zASSERT((pentry->p.zid == directory->NAMEDzid) || (directory->NAMEDvolume == &AdminVolume.vol)); /*--------------------------------------------------------------------------- @@ -1594,7 +1594,7 @@ STATUS NAME_RemoveAllNames( primaryBeast ? (NamedBeast_s*)primaryBeast : beast, directory, flags, pentry))) { - flags |= REMNAMEFL_ATOMIC; + flags |= REMNAMEFL_ATOMIC; } /*--------------------------------------------------------------------------- @@ -1637,7 +1637,7 @@ STATUS NAME_RemoveAllNames( { if (GetErrno(genMsg) == zERR_NAME_NOT_FOUND_IN_DIRECTORY) { - /* We couldn't find the name in the directory, but we're + /* We couldn't find the name in the directory, but we're * doing an error backout, so it's probably OK. */ ClearErrno(genMsg); @@ -1645,7 +1645,7 @@ STATUS NAME_RemoveAllNames( } else if (flags & REMNAMEFL_ATOMIC) { - goto cleanup_reAddNames; + goto cleanup_reAddNames; } else { @@ -1674,7 +1674,7 @@ STATUS NAME_RemoveAllNames( beastNamesRemoved++; } - } + } /*--------------------------------------------------------------------------- * Now, if we are adding to salvage, go through each of the names in the @@ -1686,7 +1686,7 @@ STATUS NAME_RemoveAllNames( pentry,zNTYPE_DELETED_FILE, SNT_CHANGE_NAMETYPE) != zOK) { /* Unable to allocate memory to change the name type to deleted.*/ - goto EndAddToSalvage; + goto EndAddToSalvage; } pentry->p.nameType = zNTYPE_DELETED_FILE; zASSERT(pentry->t != NULL); @@ -1805,14 +1805,14 @@ STATUS NAME_RemoveAllNames( bst->NAMEDnameFlags |= NFL_ADDED_TO_SALVAGE_TREE; if (bst->NAMEDopenCount > 0) { - /** The file is still open and its blocks can be altered - ** wait until the file is closed before adding the + /** The file is still open and its blocks can be altered + ** wait until the file is closed before adding the ** blocks to the purgeable block count **/ bst->NAMEDnameFlags |= NFL_BLKS_NOT_IN_PURGEABLE_CNT; if(primaryBeast) { - /* In this case, bst is the primary beast, so it is + /* In this case, bst is the primary beast, so it is * already flagged. Now we want to flag the hardlink * beast too if two beasts are involved. * The hardlink beast is pointed to by "beast". @@ -1823,7 +1823,7 @@ STATUS NAME_RemoveAllNames( /* FixFixFix: Shouldn't we call GetPurgeableBlksCnt here? */ else if (COMN_GetStorageInfo(genMsg, bst, &getStorageInfo) == zOK) { - physBlocks = + physBlocks = (getStorageInfo.filePhysSize >> bst->NAMEDblkSizeShift); COMN_saveBeastPurgeableBlksCnt(genMsg, bst,0, physBlocks); if (physBlocks != 0) @@ -1832,7 +1832,7 @@ STATUS NAME_RemoveAllNames( volLog.action = VOLINFO_CHANGE_PURGEABLE_BLOCKS; //#if NSS_DEBUG IS_ENABLED -// DBG_DebugPrintf(YELLOW, MSGNot("RemoveAllNames: Purgeable blocks = %Ld, delta+ = %Ld, beast zid = 0x%Lx\n"), bst->NAMEDvolume->VOLpurgeableBlocks, physBlocks, bst->NAMEDzid); +// DBG_DebugPrintf(YELLOW, MSGNot("RemoveAllNames: Purgeable blocks = %Ld, delta+ = %Ld, beast zid = 0x%Lx\n"), bst->NAMEDvolume->VOLpurgeableBlocks, physBlocks, bst->NAMEDzid); //#endif // done in VOL_writeVolumeLoggedData // bst->NAMEDvolume->VOLpurgeableBlocks += physBlocks; @@ -1857,32 +1857,32 @@ STATUS NAME_RemoveAllNames( bst->NAMEDvolume, xaction, &volLog); CHANGE_COMP_STATS_COMP_DELETED_FILES(1); } - else if (!(bst->NAMEDattributes & + else if (!(bst->NAMEDattributes & (zFA_CANT_COMPRESS_DATA_STREAM/* | zFA_DO_NOT_COMPRESS_FILE*/)) && (CM_curCompControlParams.compressDeletedFilesOption == COMP_DELETED_FILES_IMMEDIATELY) && // CM_curCompControlParams.compEnabled && CM_COMPRESSION_ENABLED(bst->NAMEDvolume)) - { + { if (CM_curCompControlParams.compEnabled) { if(CM_checkParentDirForCompressOK(genMsg, (File_s*)bst)) { - CM_compressFileAsync(genMsg, &bst->NAMEDroot, XLATCHED, + CM_compressFileAsync(genMsg, &bst->NAMEDroot, XLATCHED, COMP_NORMAL); /* Since CM_compressFileAsync doesn't compress file * if file open count is not zero, this line makes sure - * that file will be compressed when file is closed + * that file will be compressed when file is closed * by the last open file handle - */ + */ addLeaveCompressedToGrantedRights(&bst->NAMEDroot); } } else { /* enqueue the request */ - CM_enqueueCompressRequest(bst->NAMEDvolume, bst->NAMEDzid, - COMP_NORMAL); + CM_enqueueCompressRequest(bst->NAMEDvolume, bst->NAMEDzid, + COMP_NORMAL); } } ClearErrno(genMsg); @@ -1929,7 +1929,7 @@ EndAddToSalvage: } zASSERT(beastNamesRemoved == dirNamesRemoved); COMN_MARK_BEAST_XLOCAL(&beast->NAMEDroot,xaction); - } + } /*--------------------------------------------------------------------------- * Cleanup the authorization visibility @@ -1988,10 +1988,10 @@ EndAddToSalvage: if (COMN_IsDerivedFrom(beast, zFTYPE_FILE)) { File_s *file = primaryBeast ? (File_s*)primaryBeast : (File_s *)beast; - + if((file->FILEnumParents == 0) || NAME_AllNamesInSalvage(file)) { - /* + /* * All of the file's names are deleted or moved to salvage system; * Turn off the file's archive bit. We don't backup deleted files. */ @@ -2097,7 +2097,7 @@ BOOL NAME_HasThisParentZID( // cnt zASSERT((parentZID != zINVALID_ZID) || (beast->NAMEDzid == zROOTDIR_ZID)); // cnt RTN_BOOL(TRUE); // cnt } -// cnt } +// cnt } RTN_BOOL(FALSE); } @@ -2124,7 +2124,7 @@ BOOL NAME_HasThisParentZID( zASSERT((nameUniquifier != zFNU_INVALID_NAME_UNIQUIFIER) || (beast->NAMEDzid == zROOTDIR_ZID)); RTN_BOOL(TRUE); } - + DQ_FOREACH(&beast->otherParents, lpentry, LinkedParentEntry_s, plink) { if (lpentry->pentry.p.nameUniquifier == nameUniquifier) @@ -2132,7 +2132,7 @@ BOOL NAME_HasThisParentZID( zASSERT((nameUniquifier != zFNU_INVALID_NAME_UNIQUIFIER) || (beast->NAMEDzid == zROOTDIR_ZID)); RTN_BOOL(TRUE); } - } + } RTN_BOOL(FALSE); } */ @@ -2150,14 +2150,14 @@ BOOL NAME_HasThisParentZID( // cnt NamedBeast_s *beast = (NamedBeast_s *)voidBeast; // cnt LinkedParentEntry_s *lpentry; // cnt ASSERT_MPKNSS_LOCK(); -// cnt +// cnt // cnt if (beast->NAMEDfirstParentZID == parentZID) // cnt { // cnt zASSERT((parentZID != zINVALID_ZID) || (beast->NAMEDzid == zROOTDIR_ZID)); // cnt *retNameUniquifier = beast->NAMEDfirstParentNameUniquifier; // cnt return(zOK); // cnt } -// cnt +// cnt // cnt DQ_FOREACH(&beast->otherParents, lpentry, LinkedParentEntry_s, plink) // cnt { // cnt if (lpentry->pentry.p.zid == parentZID) @@ -2166,7 +2166,7 @@ BOOL NAME_HasThisParentZID( // cnt *retNameUniquifier = lpentry->pentry.p.nameUniquifier; // cnt return(zOK); // cnt } -// cnt } +// cnt } // cnt *retNameUniquifier = zFNU_INVALID_NAME_UNIQUIFIER; // cnt SetErrno(genMsg,zERR_PARENT_NOT_FOUND_IN_BEAST); // cnt return(zFAILURE); @@ -2236,7 +2236,7 @@ STATUS COMN_GetNameFromBeast( if (retNameLen != NULL) *retNameLen = NAMED_GET_NLENGTH(&nnode->p); - if ((nameSpace->flags & NSFLforceLowerIfForcedUpper) && + if ((nameSpace->flags & NSFLforceLowerIfForcedUpper) && (nnode->p.flagsAndLen & NAMEforcedUpper)) { unilwr(retName); @@ -2277,7 +2277,7 @@ STATUS COMN_GetNameFromBeast( // cnt if (retNameLen != NULL) // cnt *retNameLen = NAMED_GET_NLENGTH(&nnode->p); // cnt -// cnt if ((nameSpace->flags & NSFLforceLowerIfForcedUpper) && +// cnt if ((nameSpace->flags & NSFLforceLowerIfForcedUpper) && // cnt (nnode->p.flagsAndLen & NAMEforcedUpper)) // cnt { // cnt unilwr(retName); @@ -2326,7 +2326,7 @@ cleanupNormal: /**************************************************************************** * This returns the first name (NULL terminated) for the given beast. It * returns the name type and namespace of the located first name. If the - * first name has more than one namespace, it returns the number of the + * first name has more than one namespace, it returns the number of the * lowest numbered namespace. This routine ALWAYS returns a valid string in * the name field, even if it has to generate one. * @@ -2401,7 +2401,7 @@ STATUS NAME_GetFirstNameFromBeast( zASSERT(FALSE); SetErrno(genMsg,zERR_INVALID_NAMESPACE_ID); goto cleanup; - } + } if (retName != NULL) { @@ -2416,7 +2416,7 @@ STATUS NAME_GetFirstNameFromBeast( } unimcpy(retName,nnode->p.name,retNameSize); - if ((nameSpace->flags & NSFLforceLowerIfForcedUpper) && + if ((nameSpace->flags & NSFLforceLowerIfForcedUpper) && (nnode->p.flagsAndLen & NAMEforcedUpper)) { unilwr(retName); @@ -2524,7 +2524,7 @@ BOOL NAME_BeastHasNameInParent( nspace = COMN_NameSpaceIDLookup(NULL,nameSpaceID); if (nspace == NULL) RTN_BOOL(FALSE); - + zASSERT(beast->NAMEDfirstParentZid == parentZid); // cnt if (beast->NAMEDfirstParentZid == parentZid) { @@ -2632,7 +2632,7 @@ BOOL NAME_AllNamesInSalvage( return ((beast->NAMEDnumParents == 1) && (beast->NAMEDfirstParentNameType == zNTYPE_DELETED_FILE)); } - + /**************************************************************************** * This function is used to give a beast a new name in a single namespace. *****************************************************************************/ @@ -2668,7 +2668,7 @@ STATIC STATUS NAME_RenameSingleNameSpace( if ((parentEntry = NAME_GetParentEntry(genMsg, beast /* cnt nameUniquifier*/)) == NULL) { zASSERT("Unable to get parent entry for existing beast"==NULL); - goto cleanup_error; + goto cleanup_error; } zASSERT(parentEntry->p.nameType == nameType); @@ -2807,14 +2807,14 @@ cleanup_removeNewNameFromTarget: directory->NAMEDzid, nnode->p.nameSpaceMask, nameType, newName, nsFlag); if (directory->NAMEDcomnOps.BST_removeNameFromDirectory( genMsg, - beast->NAMEDzid, directory, + beast->NAMEDzid, directory, (1<nSpaceID), nameType, newName, /* cnt nameUniquifier,*/ NF_UPDATE_NAME, xaction, parentEntry->t) != zOK) { - /* We were unable to remove the newName from the directory. We are in - * an inconsistent, unrecoverable state. The only way out is to undo - * the transaction, and the only current way to do that is to - * run the recovery log to undo the partial transaction. + /* We were unable to remove the newName from the directory. We are in + * an inconsistent, unrecoverable state. The only way out is to undo + * the transaction, and the only current way to do that is to + * run the recovery log to undo the partial transaction. */ /* FixFixFix6 -- When we implement real transaction * abort, we need to revisit this code */ @@ -2881,7 +2881,7 @@ cleanup_reAddNameToSrc: * abort, we need to revisit this code */ zASSERT("Unable to re-add name after failed rename in single namespace"==NULL); COMN_AbortXLocal(genMsg,directory->NAMEDvolume,xaction, WHERE); - } + } /* Put the original nnode back into the parent entry */ NULLIFY(&nnode->nlink); @@ -2892,7 +2892,7 @@ cleanup_reAddNameToSrc: cleanup_error: RTN_STATUS(zFAILURE); -} +} /**************************************************************************** @@ -2950,7 +2950,7 @@ STATUS NAME_RenameBeast( /*--------------------------------------------------------------------------- * Make sure that this beast is not currently being renamed by another. *---------------------------------------------------------------------------*/ - + if (srcBeast->NAMEDbstState & BST_STATE_RENAMING) { SetErrno(genMsg,zERR_FILE_RENAME_IN_PROGRESS); @@ -2958,7 +2958,7 @@ STATUS NAME_RenameBeast( } /* Prevent concurrent renames of this srcBeast */ srcBeast->NAMEDbstState |= BST_STATE_RENAMING; - + if ((srcNameType == zNTYPE_DELETED_FILE) && (newNameType != zNTYPE_DELETED_FILE) && @@ -2971,14 +2971,14 @@ STATUS NAME_RenameBeast( else { EFLAdminOut_s retEFLData; - NINT nameLen; + NINT nameLen; NINT dirLen; updateVolSalvageInfo = FALSE; - + /* get beast's original name now if we have EFL active epochs */ - if ((srcBeast->NAMEDcomnVolOps.VOL_administerEFL(genMsg, - srcBeast->NAMEDvolume, VOL_EFL_GET_STATUS, NULL, + if ((srcBeast->NAMEDcomnVolOps.VOL_administerEFL(genMsg, + srcBeast->NAMEDvolume, VOL_EFL_GET_STATUS, NULL, &retEFLData) == zOK) && retEFLData.u.active) { if (srcBeast->NAMEDcomnVolOps.VOL_administerEFL( @@ -2989,22 +2989,22 @@ STATUS NAME_RenameBeast( } eflNSID = retEFLData.u.nameSpaceID; - if (eflNSID != zNSPACE_INVALID) + if (eflNSID != zNSPACE_INVALID) { if ((eflOriginalName = COMN_GetPathNameWorkBuffer(genMsg)) == NULL) { RTN_STATUS(zFAILURE); } - if (COMN_GetFileNameFromZid(genMsg, srcBeast->NAMEDvolume, - srcDir->NAMEDzid, eflNSID, eflOriginalName, TRUE) != zOK) - { + if (COMN_GetFileNameFromZid(genMsg, srcBeast->NAMEDvolume, + srcDir->NAMEDzid, eflNSID, eflOriginalName, TRUE) != zOK) + { goto cleanup_error; } dirLen = unilen(eflOriginalName); if (COMN_GetNameFromBeast(genMsg, srcBeast, /* cnt zFNU_FIRST_PARENT, */ - eflNSID, (PATHWORKBUF_SIZE / sizeof(unicode_t)) - dirLen - 1, + eflNSID, (PATHWORKBUF_SIZE / sizeof(unicode_t)) - dirLen - 1, &eflOriginalName[dirLen], &nameLen) != zOK) { goto cleanup_error; @@ -3031,14 +3031,14 @@ STATUS NAME_RenameBeast( { srcBeast->NAMEDbstState &= ~BST_STATE_RENAMING; // cnt renMsg->retNameUniquifier = srcNameUniquifier; - + if (eflOriginalName) { COMN_ReleasePathNameWorkBuffer(&eflOriginalName); } RTN_STATUS(zOK); } - + /* We are moving the file to a new target directory or nameType. We * already know that the newName does not exist in the target directory * in the lookup nameSpace. However, we must now check all other @@ -3246,7 +3246,7 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, // cnt * names were either put back or we did an AbendTheVolume error. // cnt * We now have two sets of names for this beast, and we // cnt * must remove the new names in the target directory. */ -// cnt goto cleanup_removeNewTargetNames; +// cnt goto cleanup_removeNewTargetNames; // cnt } // cntDEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, %s\n"), GetCurrentTime(), Ticks, ThreadId(), WHERE)); // cnt @@ -3315,7 +3315,7 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, ClearErrno(genMsg); } } - if (bst->NAMEDnameFlags & NFL_HAS_EXTENDED_ATTRIBUTES) + if (bst->NAMEDnameFlags & NFL_HAS_EXTENDED_ATTRIBUTES) { if (COMN_GetDataStreamUsedSpace(genMsg, (File_s *)bst, zNTYPE_EXTENDED_ATTRIBUTE, FALSE, NULL, @@ -3357,7 +3357,7 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, /* If primaryBeast is non-NULL, then bst==primaryBeast, and the * primary flags have already been cleared, and the primary has * been flagged as XLOCAL. Now, we need to update the hardlink - * beast (srcBeast) by clearing its flags too. + * beast (srcBeast) by clearing its flags too. * Also, we need to update the parent name type information in the * primary to reflect the "salvaged" state, and force out the primary. * The Hard link beast will be forced out later. @@ -3372,14 +3372,14 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, /* Force out the primary now ... hardlink will be forced later */ COMN_ForceBeastWrite(genMsg,primaryBeast,xaction); } - + volLog.delta = -1; volLog.action = VOLINFO_CHANGE_NUM_DELETED_FILES; // done in VOL_writeVolumeLoggedData // bst->NAMEDvolume->VOLnumDeletedFiles -= 1; bst->NAMEDvolume->VOLcomnVolOps.VOL_writeVolumeLoggedData( bst->NAMEDvolume, xaction, &volLog); - + if (bst->NAMEDattributes & zFA_DATA_STREAM_IS_COMPRESSED) { volLog.delta = -1; @@ -3388,11 +3388,11 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, bst->NAMEDvolume, xaction, &volLog); CHANGE_COMP_STATS_COMP_DELETED_FILES(-1); } - + /* modify EFL entry - undelete file */ - VOL_insertEFLEntry(genMsg, &srcBeast->NAMEDroot, - EFL_FILE_STATE_UNDELETE, NULL, xaction); - + VOL_insertEFLEntry(genMsg, &srcBeast->NAMEDroot, + EFL_FILE_STATE_UNDELETE, NULL, xaction); + if (COMN_IsDerivedFrom(srcBeast, zFTYPE_FILE) && ((((File_s *)srcBeast)->FILEnameFlags & NFL_HAS_DATA_STREAMS) || (((File_s *)srcBeast)->FILEnameFlags & NFL_HAS_EXTENDED_ATTRIBUTES))) @@ -3404,12 +3404,12 @@ DEBUG_PRINTF(TCREATE, DBG_NOINDENT, (GREEN, MSGNot("CurT=%d, Ticks=%d, Thr=0x%x, else { /* modify EFL entry - rename file */ - if (eflNSID != zNSPACE_INVALID) + if (eflNSID != zNSPACE_INVALID) { zASSERT(eflOriginalName != NULL); - - VOL_insertEFLEntry(genMsg, &srcBeast->NAMEDroot, - EFL_FILE_STATE_RENAME, eflOriginalName, xaction); + + VOL_insertEFLEntry(genMsg, &srcBeast->NAMEDroot, + EFL_FILE_STATE_RENAME, eflOriginalName, xaction); } } @@ -3496,7 +3496,7 @@ BOOL NAME_MatchAttributes( matchAttr->matchFileAttrSet)) { DEBUG_PRINTF(TMATCHATTR, DBG_INDENT, (LGREEN, MSGNot("Matchattr: FAILED mustBeSet bits (bstAttr=%08x matchAttr=%08x)\n"), - beastAttributes,matchAttr->matchFileAttrSet)); + beastAttributes,matchAttr->matchFileAttrSet)); return FALSE; } @@ -3507,7 +3507,7 @@ BOOL NAME_MatchAttributes( ((matchAttr->matchFileAttrNotSet & beastAttributes) != 0)) { DEBUG_PRINTF(TMATCHATTR, DBG_INDENT, (LGREEN, MSGNot("Matchattr: FAILED must be clear bits (bstAttr=%08x matchAttr=%08x)\n"), - beastAttributes,matchAttr->matchFileAttrNotSet)); + beastAttributes,matchAttr->matchFileAttrNotSet)); return FALSE; } @@ -3518,7 +3518,7 @@ BOOL NAME_MatchAttributes( /**************************************************************************** - * + * *****************************************************************************/ STATUS NAME_HardLinkSetMatchAttributesInDirectory( GeneralMsg_s *genMsg, @@ -3541,7 +3541,7 @@ STATUS NAME_HardLinkSetMatchAttributesInDirectory( /* curFile is the primary "iNode" beast for this hardlink. We need to walk * through every hardlink for this primary beast and perform the - * NAME_SetmatchAttributesInDirectory call for each. + * NAME_SetmatchAttributesInDirectory call for each. * We DO NOT LATCH any of these beasts, because we have the primary beast * already XLATCHED so we know none of them can be changing. We only * need to pull a zid out of them ... we are not modifying them. @@ -3620,7 +3620,7 @@ abortXLocal: } /**************************************************************************** - * + * *****************************************************************************/ STATUS NAME_SetMatchAttributesInDirectory( GeneralMsg_s *genMsg, @@ -3647,7 +3647,7 @@ STATUS NAME_SetMatchAttributesInDirectory( { status = curFile->FILEcomnOps.BST_setMatchAttributesInDirectory( genMsg, &curFile->FILEnamed, &curDir->FILEnamed, - nnode->p.nameSpaceMask, pentry->p.nameType, + nnode->p.nameSpaceMask, pentry->p.nameType, nnode->p.name, // cnt pentry->p.nameUniquifier, MA_ATTR_SET_MASK(newFileAttributes), xaction); if (status == zOK) @@ -3671,8 +3671,8 @@ restoreOriginalMatchAttrs: break; } status = curFile->FILEcomnOps.BST_setMatchAttributesInDirectory( - genMsg, &curFile->FILEnamed, &curDir->FILEnamed, - nnode->p.nameSpaceMask, pentry->p.nameType, + genMsg, &curFile->FILEnamed, &curDir->FILEnamed, + nnode->p.nameSpaceMask, pentry->p.nameType, nnode->p.name, // cnt pentry->p.nameUniquifier, MA_ATTR_SET_MASK(oldFileAttributes), xaction); if (status == zOK) @@ -3698,7 +3698,7 @@ restoreOriginalMatchAttrs: COMN_AbortXLocal(genMsg,curDir->FILEvolume,xaction, WHERE); } return zFAILURE; -} +} /**************************************************************************** * Get a full name from a zid. This function assumes that the situation is @@ -3714,7 +3714,7 @@ restoreOriginalMatchAttrs: STATUS COMN_GetFileNameFromZid2( GeneralMsg_s *genMsg, Volume_s *volume, - Zid_t zid, + Zid_t zid, NINT nameSpaceID, unicode_t *name, BOOL appendSeperator) @@ -3742,7 +3742,7 @@ STATUS COMN_GetFileNameFromZid2( { nameType = zNTYPE_EXTENDED_ATTRIBUTE; } - else + else { nameType = zNTYPE_FILE; } @@ -3755,8 +3755,8 @@ STATUS COMN_GetFileNameFromZid2( unicode_t *insertPtr; NINT len; - if (COMN_GetFileNameFromZid(genMsg, volume, - ((NamedBeast_s *)beast)->NAMEDfirstParentZid, + if (COMN_GetFileNameFromZid(genMsg, volume, + ((NamedBeast_s *)beast)->NAMEDfirstParentZid, nameSpaceID, name, FALSE) != zOK) { goto error; @@ -3766,8 +3766,8 @@ STATUS COMN_GetFileNameFromZid2( { goto error; } - - if (nameSpace->nSpaceOps->getSeparator(genMsg, + + if (nameSpace->nSpaceOps->getSeparator(genMsg, PATH_SEPARATOR, &seperator, &seperatorLen) != zOK) { goto error; @@ -3779,7 +3779,7 @@ STATUS COMN_GetFileNameFromZid2( memmove(insertPtr, seperator, seperatorLen * sizeof(unicode_t)); insertPtr += seperatorLen; - if (NAME_GetFirstNameFromBeast(genMsg, beast, zMAX_COMPONENT_NAME, + if (NAME_GetFirstNameFromBeast(genMsg, beast, zMAX_COMPONENT_NAME, insertPtr, NULL, NULL, NULL) != zOK) { goto error; @@ -3787,11 +3787,11 @@ STATUS COMN_GetFileNameFromZid2( } else { - if (COMN_GetFileNameFromZid(genMsg, volume, beast->ROOTzid, + if (COMN_GetFileNameFromZid(genMsg, volume, beast->ROOTzid, nameSpaceID, name, FALSE) != zOK) { goto error; - } + } } COMN_Release(&beast); return zOK; @@ -3815,7 +3815,7 @@ error: STATUS COMN_GetFileNameFromZid( GeneralMsg_s *genMsg, Volume_s *volume, - Zid_t zid, + Zid_t zid, NINT nameSpaceID, unicode_t *name, BOOL appendSeperator) @@ -3825,7 +3825,7 @@ STATUS COMN_GetFileNameFromZid( File_s *childFile = NULL; HardLinkBeast_s *hlFile = NULL; // cnt NINT nameUniquifier; - NINT unicodeLen; + NINT unicodeLen; NINT seperatorLen; /* in unicode */ unicode_t *seperator; unicode_t *insertPtr = name + (zMAX_FULL_NAME - 1); @@ -3842,8 +3842,8 @@ STATUS COMN_GetFileNameFromZid( { goto errorExit; } - - if (nameSpace->nSpaceOps->getSeparator(genMsg, + + if (nameSpace->nSpaceOps->getSeparator(genMsg, PATH_SEPARATOR, &seperator, &seperatorLen) != zOK) { goto errorExit; @@ -3854,7 +3854,7 @@ STATUS COMN_GetFileNameFromZid( insertPtr -= seperatorLen; memmove(insertPtr, seperator, seperatorLen * sizeof(unicode_t)); } - + while (zid != zROOTDIR_ZID) { file = BEASTHASH_LookupByZid(genMsg, volume, zid, NOTLATCHED); @@ -3888,7 +3888,7 @@ STATUS COMN_GetFileNameFromZid( insertPtr -= unicodeLen; zASSERT(insertPtr >= name); if(insertPtr < name) - { + { COMN_Release(&file); SetErrno(genMsg, zERR_BUFFER_TOO_SMALL); goto errorExit; @@ -3899,7 +3899,7 @@ STATUS COMN_GetFileNameFromZid( insertPtr -= seperatorLen; zASSERT(insertPtr >= name); if(insertPtr < name) - { + { COMN_Release(&file); SetErrno(genMsg, zERR_BUFFER_TOO_SMALL); goto errorExit; @@ -3925,7 +3925,7 @@ STATUS COMN_GetFileNameFromZid( releaseFile = FALSE; } unicpy(name, insertPtr); - + return zOK; errorExit: @@ -3948,7 +3948,7 @@ errorExit: ****************************************************************************/ STATUS COMN_ZidToFileName( VolumeID_t *volumeID, - Zid_t zid, + Zid_t zid, NINT nameSpaceID, unicode_t *fileName, unicode_t *volName) @@ -3972,7 +3972,7 @@ STATUS COMN_ZidToFileName( goto exitUnlock; } - if (COMN_GetFileNameFromZid(&genMsg, volume, zid, nameSpaceID, fileName, + if (COMN_GetFileNameFromZid(&genMsg, volume, zid, nameSpaceID, fileName, FALSE) == zOK) { ClearErrno(&genMsg); diff --git a/src/nwnss/comn/common/nameCache.c b/src/nwnss/comn/common/nameCache.c index f13e8df..a557bec 100644 --- a/src/nwnss/comn/common/nameCache.c +++ b/src/nwnss/comn/common/nameCache.c @@ -105,7 +105,7 @@ NameCacheCtrl_s NameCache = /* control head for the name hash */ /************************************************************************** * Structure to track name cache optimiser behaviour **************************************************************************/ -struct nameCacheOptimizerStats_s NameCacheOptimizerStats = +struct nameCacheOptimizerStats_s NameCacheOptimizerStats = { 0, /* Number of times the cache was re-sized */ 0, /* Number of optimiser cycles during which the cache was not re-sized */ @@ -131,7 +131,7 @@ void ZAS_DisplayNameCache(void) NINT j; char indicator; NameCacheNode_s *node; - + if (!(DBG_DebugFlag & TNAMECACHE)) { return; @@ -172,7 +172,7 @@ void ZAS_DisplayNameCache(void) DQ_FOREACH(hashp, node, NameCacheNode_s, asciiHashLink) { DBG_DebugPrintf(GREEN,MSGNot("[%7.7d]%c vol=%16.16LX%16.16LX pZid=%16.16d nspace=%2.2d typ=%X asciiName="), - i, indicator, ((QUAD *)&node->volGuid)[0], ((QUAD *)&node->volGuid)[1], (LONG)node->parentZid, + i, indicator, ((QUAD *)&node->volGuid)[0], ((QUAD *)&node->volGuid)[1], (LONG)node->parentZid, node->nameType, node->nameSpaceID); for (j = 0; j < node->asciiNameLen; j++) { @@ -426,7 +426,7 @@ STATIC NameCacheNode_s *NAME_CheckCacheUnicode( if (parentZid == cacheNode->parentZid && LB_GUIDCompare(volume, &cacheNode->volGuid) == 0 && nameSpace->nSpaceOps->unicodeCompareFileNames(uniName, - cacheNode->uniName, nsFlag) == 0 && + cacheNode->uniName, nsFlag) == 0 && nameSpace->nSpaceID == cacheNode->nameSpaceID && nameType == cacheNode->nameType) { /* these are the same entry */ @@ -471,7 +471,7 @@ STATIC NameCacheNode_s *NAME_CheckCacheAscii( */ if (parentZid == cacheNode->parentZid && LB_GUIDCompare(volume, &cacheNode->volGuid) == 0 && - nameSpace->nSpaceOps->asciiLenCompareFileNames(asciiName, + nameSpace->nSpaceOps->asciiLenCompareFileNames(asciiName, asciiNameLen, cacheNode->asciiName, cacheNode->asciiNameLen, nsFlag) == 0 && nameSpace->nSpaceID == cacheNode->nameSpaceID && @@ -579,7 +579,7 @@ Zid_t NAME_GetNameFromCacheAscii( memcpy(nullTermBuffer,asciiName,tempLen); nullTermBuffer[tempLen] = 0; DEBUG_PRINTF(TNAMECACHE, DBG_NOINDENT, (YELLOW, MSGNot("Get an ASCII name cache entry: %s"), nullTermBuffer)); -} +} #endif NameCache.asciiGets++; @@ -615,7 +615,7 @@ Zid_t NAME_GetNameFromCacheAscii( /**************************************************************************** - * Add a cache node entry. This function exists to avoid duplication of + * Add a cache node entry. This function exists to avoid duplication of * effort to add cache nodes in the normal manner and to re-hash entries * on cache re-size. *****************************************************************************/ @@ -624,21 +624,21 @@ void NAME_HashAndCache(NameCacheNode_s *cacheNode, BOOL reverseLRU) NINT uniHashIndex; NINT asciiHashIndex; - uniHashIndex = NAME_HashUnicode(&cacheNode->volGuid, - cacheNode->parentZid, + uniHashIndex = NAME_HashUnicode(&cacheNode->volGuid, + cacheNode->parentZid, cacheNode->nameType, - cacheNode->nameSpaceID, + cacheNode->nameSpaceID, cacheNode->uniName); NULLIFY(&cacheNode->uniHashLink); NULLIFY(&cacheNode->asciiHashLink); DQ_PUSH(&NameCache.uniHash[uniHashIndex], cacheNode, uniHashLink); /* link of unicode hash list */ if (cacheNode->asciiNameLen != 0) { - asciiHashIndex = NAME_HashAscii(&cacheNode->volGuid, - cacheNode->parentZid, + asciiHashIndex = NAME_HashAscii(&cacheNode->volGuid, + cacheNode->parentZid, cacheNode->nameType, - cacheNode->nameSpaceID, - cacheNode->asciiNameLen, + cacheNode->nameSpaceID, + cacheNode->asciiNameLen, cacheNode->asciiName); DQ_PUSH(&NameCache.asciiHash[asciiHashIndex], cacheNode, asciiHashLink); /* link of ascii hash list */ } @@ -677,7 +677,7 @@ void NAME_AddNameToCache( NINT asciiNameLen, /* May be 0 */ char *asciiName, /* May be NULL if asciiNameLen is 0 */ Zid_t zid -/* cnt NINT nameUniquifier*/) +/* cnt NINT nameUniquifier*/) { NameCacheNode_s *cacheNode; VolumeID_t volumeID; @@ -694,7 +694,7 @@ void NAME_AddNameToCache( { if (zid == zINVALID_ZID) { - /* + /* * Negative cache entries not allowed for admin volume because * we cannot easily determine if they are are for the persistent * volume or not. @@ -721,7 +721,7 @@ void NAME_AddNameToCache( goto earlyExit; } } - + /* we only get here if the entry is not found */ #if NSS_DEBUG IS_ENABLED if ((SNINT)(NameCache.numEntries - NameCache.maxEntries) > (SNINT)NameCacheOptimizerStats.maxReqdNodeDestroys) @@ -751,7 +751,7 @@ void NAME_AddNameToCache( free(cacheNode); } } - + uniSize = (unilen(uniName) + 1) * sizeof(unicode_t); /* length of string plus null */ packetSize = uniSize + asciiNameLen; /* Ascii is not NULL terminated */ if (packetSize < DEFAULT_CACHE_NAME_LEN) @@ -774,7 +774,7 @@ void NAME_AddNameToCache( free(cacheNode); NameCache.numUnusedEntries--; NameCache.numUnusedFrees++; - } + } cacheNode = malloc(sizeof(NameCacheNode_s) + packetSize - 1); NameCache.numAllocs++; } @@ -836,7 +836,7 @@ void NAME_AddNameToCache( nullTermBuffer[tempLen] = 0; DEBUG_PRINTF(TNAMECACHE, DBG_NOINDENT, (YELLOW, MSGNot("Added a name cache entry: pzid=%d nspace=%2d uniName=%U asciiName = %s\n"), (LONG)parentZid, nameSpace->nSpaceID, uniName, nullTermBuffer)); - } + } else { DEBUG_PRINTF(TNAMECACHE, DBG_NOINDENT, (YELLOW, MSGNot("Added a name cache entry: pzid=%d nspace=%2d uniName=%U No ASCII Name\n"), @@ -880,7 +880,7 @@ STATUS NAME_RemoveNameFromCache( DEBUG_PRINTF(TNAMECACHE, DBG_NOINDENT, (YELLOW, MSGNot("Removed a name cache entry: pzid=%d nspaceMask=%4x uniName=%U\n"), (LONG)parentZid, nameSpaceMask, uniName)); - /* + /* * Elsewhere in the Lookup code, there are places which, if we fail to find * a name in the LONG namespace, we attempt to locate it using the DOS nameSpace. * As a result, if we attempt to lookup a name that doesnt exist in the LONG @@ -910,7 +910,7 @@ STATUS NAME_RemoveNameFromCache( ClearErrno(genMsg); continue; } - + if ((cacheNode = NAME_CheckCacheUnicode(&volume->VOLvolumeID, parentZid, nameSpace, nameType, uniName, nsFlag)) != NULL) { /* found the cache entry */ @@ -948,7 +948,7 @@ STATUS NAME_RemoveNameFromCache( if (CSA_SLAVE_VOLUMES_FOUND(volume)) { - CSA_RemoveNameCacheEntry(volume, parentZid, saveNameSpaceMask, + CSA_RemoveNameCacheEntry(volume, parentZid, saveNameSpaceMask, nameType, uniName, nsFlag); } return zOK; @@ -974,7 +974,7 @@ void NAME_InvalidateCacheEntriesForVolume( { if (LB_GUIDCompare(volume, &cacheNode->volGuid) == 0) { - DEBUG_PRINTF(TNAMECACHE, DBG_NOINDENT, (LMAGENTA, + DEBUG_PRINTF(TNAMECACHE, DBG_NOINDENT, (LMAGENTA, MSGNot("Remove Hash=%d vol=%x nspace=%d name=%U\n"), i, cacheNode->volGuid.timeLow, cacheNode->nameSpaceID, cacheNode->uniName)); @@ -1026,7 +1026,7 @@ void NAME_InvalidateCacheEntriesForDirectory( if ((LB_GUIDCompare(volume, &cacheNode->volGuid) == 0) && (directoryZid == cacheNode->parentZid)) { - DEBUG_PRINTF(TNAMECACHE, DBG_NOINDENT, (LMAGENTA, + DEBUG_PRINTF(TNAMECACHE, DBG_NOINDENT, (LMAGENTA, MSGNot("Remove Hash=%d vol=%x nspace=%d name=%U\n"), i, cacheNode->volGuid.timeLow, cacheNode->nameSpaceID, cacheNode->uniName)); @@ -1058,9 +1058,9 @@ void NAME_InvalidateCacheEntriesForDirectory( /* - * This function will be called on a fast work-to-do one shot that - * we want to use to re-optimise the cache. We might need to block - * so a fast wtd is no use. This function exists just to start a + * This function will be called on a fast work-to-do one shot that + * we want to use to re-optimise the cache. We might need to block + * so a fast wtd is no use. This function exists just to start a * normal work-to-do to execute the optimiser */ void NAME_ReoptimizeStarter(void) @@ -1075,7 +1075,7 @@ void NAME_ReoptimizeStarter(void) /* - Re-size the cache in line with the current beast count, + Re-size the cache in line with the current beast count, re-create the cache if if changes radically. */ void NAME_Reoptimize(void) @@ -1127,7 +1127,7 @@ NoChangeInNameCacheSize: #endif /* If the change exceeded the limits set at the last invalidate */ - if ((NameCache.maxEntries < NameCache.minValidSize) + if ((NameCache.maxEntries < NameCache.minValidSize) || (NameCache.maxEntries > NameCache.maxValidSize)) { /* Invalidate the cache */ @@ -1156,7 +1156,7 @@ void NAME_DestroyCache(void) DQhead_t *hp; NINT i; NameCacheNode_s *item; - + ASSERT_LATCH(&NameCache.latch); /* Now that the ASCII hash list has been destroyed, free up all of the @@ -1349,7 +1349,7 @@ void NAME_InvalidateCache(void) DQ_INIT(ahp); } - /* Destroy the cache then re-initialize it. Since we just made the cache look empty then the destroy just frees + /* Destroy the cache then re-initialize it. Since we just made the cache look empty then the destroy just frees * the hash bucket lists and not the nodes. We have the nodes in oldLRU so that we can add them back */ (void)NAME_ReinitCache(); diff --git a/src/nwnss/comn/common/nameLookup.c b/src/nwnss/comn/common/nameLookup.c index eb249ce..f0ec862 100644 --- a/src/nwnss/comn/common/nameLookup.c +++ b/src/nwnss/comn/common/nameLookup.c @@ -57,7 +57,7 @@ #include "nameScan.h" #include "comnMacShortName.h" /**************************************************************************** - * + * *****************************************************************************/ STATIC void NAME_HandleBeastlessName( File_s *dir, @@ -238,7 +238,7 @@ tryLookupAgain: } goto found; } - + /* We have some clients which get confused and mix LONG names with * "DOS-8.3" names in the same path string. To get around this problem, if * a name is not found in the long name space, we always double check the @@ -327,7 +327,7 @@ tryLookupAgain: if (convertedHexConstants) { - /* IMPORTANT-IMPORTANT-IMPORTANT + /* IMPORTANT-IMPORTANT-IMPORTANT * We must never add positive name cache entries where the unicode * name has been converted, BUT the ascii name has not. It is much * easier to just blow the unconverted ASCII name away here and @@ -351,7 +351,7 @@ tryLookupAgain: /* Note - only DOS sets this flag. We did not find the name, but the * name contains extended ASCII characters. Reparse the path component * using traditional NetWare uppercasing/legal character rules and then - * try to look it up one more time. + * try to look it up one more time. */ if (NMSG_ReparseNameMsgDOSComponent(genMsg,nameMsg) == zOK) { @@ -401,7 +401,7 @@ tryLookupAgain: if (strippedFFChars) { - /* IMPORTANT-IMPORTANT-IMPORTANT + /* IMPORTANT-IMPORTANT-IMPORTANT * We must never add positive name cache entries where the unicode * name has been converted, BUT the ascii name has not. It is much * easier to just blow the unconverted ASCII name away here and @@ -428,7 +428,7 @@ tryLookupAgain: } // do comn_lookupbyzid and return beast ptr - nextBeast = COMN_LookupByZid (genMsg, nameMsg->curvol, + nextBeast = COMN_LookupByZid (genMsg, nameMsg->curvol, (Zid_t) mangledZid, nameMsg->latchType, FALSE); ClearErrno(genMsg); // we may have to set it later @@ -450,7 +450,7 @@ tryLookupAgain: // does name match mangled name? if (COMN_GetNameFromBeast(genMsg, nextBeast, /* cnt zFNU_FIRST_PARENT,*/ - zNSPACE_MAC, + zNSPACE_MAC, zMAX_COMPONENT_NAME, aStack->macName, &retLen) != zOK) { @@ -465,7 +465,7 @@ tryLookupAgain: goto error; } // cnt *retNameUniquifier = zFNU_FIRST_PARENT; - goto found; + goto found; } error: if (nextBeast) @@ -495,7 +495,7 @@ found: /**************************************************************************** * Given the specific unicode name information, this will look in the name * cache for the unicode name. If it doesn't find the name in the name cache - * it calls the BST_lookupByNameInDIrectory to ask the LSS to search the + * it calls the BST_lookupByNameInDIrectory to ask the LSS to search the * directory. If * the name is found and it is not already in the name cache, it's unicode * and ascii equivalents are added to the name cache. @@ -566,7 +566,7 @@ Zid_t NAME_FindZidForNameInDir( if (!skipNegativeAdd) { NAME_AddNameToCache(count, directory->FILEvolume, - directory->FILEzid, nameSpace, nameType, uniName, + directory->FILEzid, nameSpace, nameType, uniName, asciiNameLen, asciiName, zINVALID_ZID /* cnt,zFNU_INVALID_NAME_UNIQUIFIER*/); } @@ -597,7 +597,7 @@ errorExit: /**************************************************************************** * Given the specific unicode name information, this will look in the name * cache for the unicode name. If it doesn't find the name in the name cache - * it calls the BST_lookupByNameInDIrectory to ask the LSS to search the + * it calls the BST_lookupByNameInDIrectory to ask the LSS to search the * directory. If the name is found, the beast is read into memory. If * the name is found and it is not already in the name cache, it's unicode * and ascii equivalents are added to the name cache. @@ -626,8 +626,8 @@ void *NAME_FindNameInDir( (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); if ((zid = NAME_FindZidForNameInDir(genMsg, _directory, nameSpace, nameType, - uniName, asciiNameLen, asciiName, - negativeNameCacheFlag + uniName, asciiNameLen, asciiName, + negativeNameCacheFlag /* cnt, retNameUniquifier*/)) == zINVALID_ZID) { goto errorExit; @@ -727,7 +727,7 @@ STATUS NAME_RemoveBeastlessNameFromDir( } latchType = GET_LATCH_TYPE(&curdir->NAMEDbeastLatch); - COMN_SETUP_NAMING_MSG_FILE_BEAST_PTR(&aStack->noCleanupNameMsg, + COMN_SETUP_NAMING_MSG_FILE_BEAST_PTR(&aStack->noCleanupNameMsg, curdir->NAMEDvolume, curdir->NAMEDfirstParentZid, // cnt curdir->NAMEDfirstParentNameUniquifier, @@ -740,7 +740,7 @@ STATUS NAME_RemoveBeastlessNameFromDir( /* get the full path name of the parent directory */ COMN_STRUCT_INIT(gfnMsg); - COMN_SETUP_GET_NAME_MSG(&gfnMsg, + COMN_SETUP_GET_NAME_MSG(&gfnMsg, zGFN_INCLUDE_PATH|zGFN_INCLUDE_VOLUME, GFN_NO_SEPARATOR_AFTER_VOLUME_COLON, zPFMT_UNICODE, pathNameSpace->nSpaceID, @@ -770,7 +770,7 @@ STATUS NAME_RemoveBeastlessNameFromDir( { zASSERT(aStack->noCleanupNameMsg.latchType == latchType); } - } + } else { NINT len; @@ -780,7 +780,7 @@ STATUS NAME_RemoveBeastlessNameFromDir( if (pathNameSpace->nSpaceOps->getSeparator(genMsg,PATH_SEPARATOR, &separatorStr, &separatorLen) != zOK) { - zASSERT("Unable to get path sepatator, This should not happen\n" == NULL); + zASSERT("Unable to get path sepatator, This should not happen\n" == NULL); separatorLen = 1; separatorStr = MSGNot(L"\\"); } diff --git a/src/nwnss/comn/common/nameScan.c b/src/nwnss/comn/common/nameScan.c index 76f8229..b3cac0b 100644 --- a/src/nwnss/comn/common/nameScan.c +++ b/src/nwnss/comn/common/nameScan.c @@ -33,8 +33,9 @@ |--------------------------------------------------------------------------- | This module is used to: | This contains the top level internal file interfaces. All external - | interfaces call these routines. + | interfaces call these routines. +-------------------------------------------------------------------------*/ +#include #include #include #include @@ -90,7 +91,7 @@ STATIC void DEBUG_NMSG_ValidateWorkBufferList() /*--------------------------------------------------------------------------- * Count every free buffer, make sure it is on proper boundaries, make sure - * it belongs to a tracked buffer page, and make sure the count of free + * it belongs to a tracked buffer page, and make sure the count of free * buffers plus the allocated buffers is consistent. *---------------------------------------------------------------------------*/ STK_FOREACH(workBufferList,retBuffer,_WorkBufferList_s, link) @@ -115,7 +116,7 @@ foundBufferPage:; * COMN_GetPathNameWorkBuffer *****************************************************************************/ void *COMN_GetPathNameWorkBuffer( - GeneralMsg_s *genMsg) + GeneralMsg_s *genMsg) { _WorkBufferList_s *newPage; _WorkBufferList_s *retBuffer; @@ -145,7 +146,7 @@ void *COMN_GetPathNameWorkBuffer( return(NULL); } zASSERT(((ADDR)newPage & 0xFFF) == 0); - workBufferPagesAllocated++; + workBufferPagesAllocated++; /* Push the page track node on a stack */ newPageTrackNode->pagePtr = newPage; @@ -153,7 +154,7 @@ void *COMN_GetPathNameWorkBuffer( STK_PUSH(workBufferPageList, newPageTrackNode, link); /* Split the page up into individual work buffers and push them on a stack */ - pageSizeRemaining = PAGE_SIZE; + pageSizeRemaining = PAGE_SIZE; while (pageSizeRemaining >= PATHWORKBUF_SIZE) { NULLIFY(&newPage->link); @@ -295,16 +296,16 @@ STATIC STATUS ProcessVolumeNameOverride( * is empty. It adjusts the nameMsg appropriately. *****************************************************************************/ STATIC STATUS AdjustEmptySrcPath( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamingMsg_s *nameMsg) { ASSERT_MPKNSS_LOCK(); /* - * A non-NULL source path exists, but it does not contain any path data + * A non-NULL source path exists, but it does not contain any path data */ if (nameMsg->parseFlags & NAMPFL_mustBeFullyQualified) { - SetErrno(genMsg,zERR_PATH_MUST_BE_FULLY_QUALIFIED); + SetErrno(genMsg,zERR_PATH_MUST_BE_FULLY_QUALIFIED); goto cleanup_failure; } nameMsg->path.voidPtr = NULL; @@ -359,7 +360,7 @@ cleanup_failure: * next component in an ASCII null string. *****************************************************************************/ STATIC STATUS ScanNextComponentAsciiNull( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamingMsg_s *nameMsg) { ScanComponentMsg_s *scanMsg = &nameMsg->scanMsg; @@ -421,7 +422,7 @@ cleanup_failure: * next component in an ASCII length string. *****************************************************************************/ STATIC STATUS ScanNextComponentAsciiLen( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamingMsg_s *nameMsg) { ScanComponentMsg_s *scanMsg = &nameMsg->scanMsg; @@ -489,7 +490,7 @@ cleanup_failure: * next component in an ASCII counted path string. *****************************************************************************/ STATIC STATUS ScanNextComponentAsciiCP( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamingMsg_s *nameMsg) { ScanComponentMsg_s *scanMsg = &nameMsg->scanMsg; @@ -601,7 +602,7 @@ cleanup_failure: * next component in a unicode Null-terminated string. *****************************************************************************/ STATIC STATUS ScanNextComponentUnicode( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamingMsg_s *nameMsg) { ScanComponentMsg_s *scanMsg = &nameMsg->scanMsg; @@ -656,7 +657,7 @@ cleanup_failure: * next component in a UTF8 Null-terminated string. *****************************************************************************/ STATIC STATUS ScanNextComponentUTF8Null( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamingMsg_s *nameMsg) { ScanComponentMsg_s *scanMsg = &nameMsg->scanMsg; @@ -714,7 +715,7 @@ cleanup_failure: * next component in a UTF8 length string. *****************************************************************************/ STATIC STATUS ScanNextComponentUTF8Len( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamingMsg_s *nameMsg) { ScanComponentMsg_s *scanMsg = &nameMsg->scanMsg; @@ -778,7 +779,7 @@ cleanup_failure: * next component in a UTF8 counted path string. *****************************************************************************/ STATIC STATUS ScanNextComponentUTF8CP( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamingMsg_s *nameMsg) { ScanComponentMsg_s *scanMsg = &nameMsg->scanMsg; @@ -973,7 +974,7 @@ STATUS NMSG_ScanNextComponent( } /* We parsed a component. Clear the first component flags */ - scanMsg->scanFlags &= ~(NSSFL_volumeNameOverrideAllowed | + scanMsg->scanFlags &= ~(NSSFL_volumeNameOverrideAllowed | NSSFL_parsingFirstComponent); /* The normal fast path is to not have these special return scan flags @@ -1001,7 +1002,7 @@ STATUS NMSG_ScanNextComponent( /* * If we scanned a volume name override, process the volume name now. - * We will then flag that no more volume overrides are allowed and + * We will then flag that no more volume overrides are allowed and * scan another component */ if (scanMsg->retScanFlags & NSRETSFL_scannedVolumeNameOverride) @@ -1036,7 +1037,7 @@ STATUS NMSG_ScanNextComponent( * a component, but we just processed the last component in the * buffer */ if (nameMsg->retParseFlags & - (NAMRETPFL_haveAParsedComponent|NAMRETPFL_lastComponent)) + (NAMRETPFL_haveAParsedComponent|NAMRETPFL_lastComponent)) { break; } @@ -1061,13 +1062,13 @@ STATUS NMSG_ScanNextComponent( break; default: - SetErrno(genMsg,zERR_PATH_MUST_BE_FULLY_QUALIFIED); + SetErrno(genMsg,zERR_PATH_MUST_BE_FULLY_QUALIFIED); goto cleanup_failure; } } else { - SetErrno(genMsg,zERR_PATH_MUST_BE_FULLY_QUALIFIED); + SetErrno(genMsg,zERR_PATH_MUST_BE_FULLY_QUALIFIED); goto cleanup_failure; } } @@ -1096,7 +1097,7 @@ STATUS NMSG_ReparseNameMsgDOSComponent( { /* If called with other than DOS, do not reparse anything. This * actually happens when creating a MAC Resource Fork. - * If the DOS namespace set the "ExtendedASCII" flag, clear it so + * If the DOS namespace set the "ExtendedASCII" flag, clear it so * we won't be stuck in a loop calling here... */ nameMsg->scanMsg.retScanFlags &= ~NSRETSFL_hasExtendedASCII; return(zOK); @@ -1147,7 +1148,7 @@ STATUS NMSG_ValidateNameMsg( ASSERT_MPKNSS_LOCK(); /*--------------------------------------------------------------------------- - * If the name message is already validated, return now + * If the name message is already validated, return now *---------------------------------------------------------------------------*/ if (nameMsg->parseFlags & NAMPFL_nameMsgValidated) return(zOK); @@ -1181,7 +1182,7 @@ STATUS NMSG_ValidateNameMsg( case zHPT_CONTEXT: /* Path optional, may override context handle and be fully qualified */ if (nameMsg->contextHandle.id == 0) { - /* If the contextHandleID is 0, then pretend no context handle + /* If the contextHandleID is 0, then pretend no context handle * reallyexists. Switch over to require a fully qualified path */ nameMsg->handlePathType = zHPT_FULL; nameMsg->parseFlags |= NAMPFL_mustBeFullyQualified; @@ -1192,7 +1193,7 @@ STATUS NMSG_ValidateNameMsg( &nameMsg->contextHandle) == NULL) { /* If the context handle is bad, temporarily ignore it - * and simply require a fully qualified path. This + * and simply require a fully qualified path. This * allows for a bad handle (IE Legacy) with a valid NSS * volume override. Keep track of this error, such that * if the path is not fully qualified we can return a @@ -1210,7 +1211,7 @@ STATUS NMSG_ValidateNameMsg( if (nameMsg->fileHandle.ptr == NULL) { /* * If the fileHandle.ptr is NULL, then switch over to - * require a fully qualified path + * require a fully qualified path */ nameMsg->handlePathType = zHPT_FULL; nameMsg->parseFlags |= NAMPFL_mustBeFullyQualified; @@ -1294,15 +1295,15 @@ STATUS NMSG_ValidateNameMsg( scanFlags |= NSSFL_useExtendedMacNamespace; /***** fixfixfix@nextMediaFormatChange begin *******/ -/* At the next media format change, only the extended Mac namespace will - * will be supported at the volume level. This check will not be +/* At the next media format change, only the extended Mac namespace will + * will be supported at the volume level. This check will not be * necessary then. */ -/* Currently we default the scanFlags with NSSFL_useExtendedMacNamespace, +/* Currently we default the scanFlags with NSSFL_useExtendedMacNamespace, * because we may not have the volume info in order to make the right choice. - * Ater ResolveStartingBeasts in ComnLookup, the scan flag is set according - * to the volume attributes. None of this will be necessary after the next - * media format change when we drop support for the legacy-style 31-char mac + * Ater ResolveStartingBeasts in ComnLookup, the scan flag is set according + * to the volume attributes. None of this will be necessary after the next + * media format change when we drop support for the legacy-style 31-char mac * namespace */ if (nameMsg->curvol) @@ -1339,9 +1340,9 @@ STATUS NMSG_ValidateNameMsg( nameMsg->workBuffer); nameMsg->scanNextComponent = ScanNextComponentAsciiNull; - break; + break; - case zPFMT_ASCII_LP: /* May be fully qualified */ + case zPFMT_ASCII_LP: /* May be fully qualified */ scanFlags |= (NSSFL_volumeNameOverrideAllowed | NSSFL_startingPathIsAscii); @@ -1360,9 +1361,9 @@ STATUS NMSG_ValidateNameMsg( nameMsg->workBuffer); nameMsg->scanNextComponent = ScanNextComponentAsciiLen; - break; + break; - case zPFMT_ASCII_LEN: /* May be fully qualified */ + case zPFMT_ASCII_LEN: /* May be fully qualified */ scanFlags |= (NSSFL_volumeNameOverrideAllowed | NSSFL_startingPathIsAscii); @@ -1381,10 +1382,10 @@ STATUS NMSG_ValidateNameMsg( nameMsg->workBuffer); nameMsg->scanNextComponent = ScanNextComponentAsciiLen; - break; - - - case zPFMT_ASCII_COUNTED: /* relative to handlePathType, no override allowed */ + break; + + + case zPFMT_ASCII_COUNTED: /* relative to handlePathType, no override allowed */ /* The workPathCount is used to track the number of yet-to-be- * processed components in a counted path string */ @@ -1410,16 +1411,16 @@ STATUS NMSG_ValidateNameMsg( nameMsg->workBuffer); nameMsg->scanNextComponent = ScanNextComponentAsciiCP; - break; - - - case zPFMT_UNICODE: /* May be fully qualified */ + break; + + + case zPFMT_UNICODE: /* May be fully qualified */ scanFlags |= NSSFL_volumeNameOverrideAllowed; - scanFlags &= ~(NSSFL_startingPathIsAscii | + scanFlags &= ~(NSSFL_startingPathIsAscii | NSSFL_allowShortAsciiLenStrings | - NSSFL_dontUpperCaseAscii | - NSSFL_asciiBreakNotSpecial | + NSSFL_dontUpperCaseAscii | + NSSFL_asciiBreakNotSpecial | NSSFL_insertAsciiBreaks); NSPACE_SETUP_UNICODE_SCAN_MSG( @@ -1431,13 +1432,13 @@ STATUS NMSG_ValidateNameMsg( nameMsg->scanNextComponent = ScanNextComponentUnicode; break; - case zPFMT_UTF8: /* May be fully qualified */ + case zPFMT_UTF8: /* May be fully qualified */ scanFlags |= NSSFL_volumeNameOverrideAllowed; - scanFlags &= ~(NSSFL_startingPathIsAscii | + scanFlags &= ~(NSSFL_startingPathIsAscii | NSSFL_allowShortAsciiLenStrings | - NSSFL_dontUpperCaseAscii | - NSSFL_asciiBreakNotSpecial | + NSSFL_dontUpperCaseAscii | + NSSFL_asciiBreakNotSpecial | NSSFL_insertAsciiBreaks); NSPACE_SETUP_UTF8_SCAN_MSG( @@ -1450,12 +1451,12 @@ STATUS NMSG_ValidateNameMsg( nameMsg->scanNextComponent = ScanNextComponentUTF8Null; break; - case zPFMT_UTF8_LP: /* May be fully qualified */ + case zPFMT_UTF8_LP: /* May be fully qualified */ scanFlags |= NSSFL_volumeNameOverrideAllowed; - scanFlags &= ~(NSSFL_startingPathIsAscii | - NSSFL_dontUpperCaseAscii | - NSSFL_asciiBreakNotSpecial | + scanFlags &= ~(NSSFL_startingPathIsAscii | + NSSFL_dontUpperCaseAscii | + NSSFL_asciiBreakNotSpecial | NSSFL_insertAsciiBreaks); /* Word-length preceeded */ @@ -1467,14 +1468,14 @@ STATUS NMSG_ValidateNameMsg( nameMsg->workBuffer); nameMsg->scanNextComponent = ScanNextComponentUTF8Len; - break; + break; - case zPFMT_UTF8_LEN: /* May be fully qualified */ + case zPFMT_UTF8_LEN: /* May be fully qualified */ scanFlags |= NSSFL_volumeNameOverrideAllowed; - scanFlags &= ~(NSSFL_startingPathIsAscii | - NSSFL_dontUpperCaseAscii | - NSSFL_asciiBreakNotSpecial | + scanFlags &= ~(NSSFL_startingPathIsAscii | + NSSFL_dontUpperCaseAscii | + NSSFL_asciiBreakNotSpecial | NSSFL_insertAsciiBreaks); NSPACE_SETUP_UTF8_SCAN_MSG( @@ -1485,9 +1486,9 @@ STATUS NMSG_ValidateNameMsg( nameMsg->workBuffer); nameMsg->scanNextComponent = ScanNextComponentUTF8Len; - break; - - case zPFMT_UTF8_COUNTED: /* relative to handlePathType, no override allowed */ + break; + + case zPFMT_UTF8_COUNTED: /* relative to handlePathType, no override allowed */ /* The workPathCount is used to track the number of yet-to-be- * processed components in a counted path string */ @@ -1497,9 +1498,9 @@ STATUS NMSG_ValidateNameMsg( * type of path strings */ scanFlags |= NSSFL_noPathSeparatorsAllowed; scanFlags &= ~(NSSFL_volumeNameOverrideAllowed | - NSSFL_startingPathIsAscii | - NSSFL_dontUpperCaseAscii | - NSSFL_asciiBreakNotSpecial | + NSSFL_startingPathIsAscii | + NSSFL_dontUpperCaseAscii | + NSSFL_asciiBreakNotSpecial | NSSFL_insertAsciiBreaks); /* Word-length preceeded */ @@ -1511,20 +1512,20 @@ STATUS NMSG_ValidateNameMsg( nameMsg->workBuffer); nameMsg->scanNextComponent = ScanNextComponentUTF8CP; - break; - - - default: - SetErrno(genMsg,zERR_INVALID_HANDLE_PATH); - goto NormalizeError; - } + break; + + + default: + SetErrno(genMsg,zERR_INVALID_HANDLE_PATH); + goto NormalizeError; + } if (NMSG_ScanNextComponent(genMsg, nameMsg) != zOK) { goto NormalizeError; } - } - + } + SuccessfulReturn: nameMsg->parseFlags |= NAMPFL_nameMsgValidated; return(zOK); @@ -1540,4 +1541,6 @@ NormalizeError: } return(zFAILURE); -} +} + + diff --git a/src/nwnss/comn/common/nameScanDebug.c b/src/nwnss/comn/common/nameScanDebug.c new file mode 100644 index 0000000..7b2fd40 --- /dev/null +++ b/src/nwnss/comn/common/nameScanDebug.c @@ -0,0 +1,264 @@ +/**************************************************************************** + | + | (C) Copyright 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) Initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to provide a testable debug interface for the + | internal component parsing code. + +-------------------------------------------------------------------------*/ +#include /* NSS Library Includes*/ +#include +#include +#include +#include +#include + +#include "comnPublics.h" +#include "zParams.h" +#include "zPublics.h" +#include "msgGen.h" +#include "msgName.h" +#include "nameScan.h" + + +/**************************************************************************** + * This routine is for TESTING ONLY. It is here just for the CMD.NLM to + * be able to test the path parsing code. It iteratively scans all components + * in a path string and builds a return buffer with all of the components + * combined. Each returned component is a NULL terminated string. The + * end of the components is signaled by an extra NULL component at the end + * of the ret_path. + *****************************************************************************/ +STATIC int DoScanComponents( + GeneralMsg_s *genMsg, + NamingMsg_s *nameMsg, + NINT sizeRetPath, + unicode_t *ret_path, + NINT *ret_numComponents) +{ + ScanComponentMsg_s *scanMsg = &nameMsg->scanMsg; + unicode_t *destPtr = ret_path; + NINT tempLen; + NINT numComponents = 0; + NINT startNameSpaceID; + NINT maxDestSize = sizeRetPath - 1; /* Pre-reserve final NULL */ + NINT saveRetScanFlags; + + ENTER(TCOMMON, COMN_PathNormalize); + RESERVE_RSRC(NAME_RESERVE); + + startNameSpaceID = nameMsg->nameSpaceID; + + if (NMSG_ValidateNameMsg(genMsg,nameMsg) != zOK) + { + goto error_Exit; + } + + if ((nameMsg->scanMsg.retScanFlags & NSRETSFL_hasWildcardChars) && + !(nameMsg->parseFlags & NAMPFL_allowWildcardChars)) + { + SetErrno(genMsg,zERR_INVALID_NAME); + goto error_Exit; + } + + for(;;) + { + /* If we changed name spaces, insert the component here */ + if (nameMsg->workNameSpaceID != startNameSpaceID) + { + if (maxDestSize < 4) + { + SetErrno(genMsg,zERR_BUFFER_TOO_SMALL); + goto error_Exit; + } + maxDestSize -= 4; + *destPtr++ = UNI_CHANGE_NAMESPACE; + *destPtr++ = nameMsg->workNameSpaceID | zPATH_CHANGE_NSPACE_BIT; + *destPtr++ = nameMsg->workNameType | zPATH_CHANGE_NSPACE_BIT; + *destPtr++ = 0; + ++numComponents; + + startNameSpaceID = nameMsg->workNameSpaceID; + } + + if (!(nameMsg->retParseFlags & NAMRETPFL_haveAParsedComponent)) + { + break; + } + + /* If ASCII component, convert it to unicode */ + if (nameMsg->scanMsg.retScanFlags & NSRETSFL_componentIsAscii) + { + if (nameMsg->workNameSpace->nSpaceOps->asciiLenToUnicode( + genMsg,scanMsg->uniConversionType, + scanMsg->retAsciiComp,scanMsg->retAsciiCompLen, + scanMsg->uniWorkBuffer1,zMAX_COMPONENT_NAME) != zOK) + { + if (GetErrno(genMsg) == zERR_BUFFER_TOO_SMALL) + { + if (nameMsg->retParseFlags & NAMRETPFL_lastComponent) + { + ForceSetErrno(genMsg,zERR_INVALID_NAME); + } + else + { + ForceSetErrno(genMsg,zERR_INVALID_PATH); + } + } + goto error_Exit; + } + + scanMsg->uniSrcPath = scanMsg->uniWorkBuffer1; + + saveRetScanFlags = scanMsg->retScanFlags & NSRETSFL_SAVE_RET_SCAN_FLAGS; + if (scanMsg->retAsciiSrcPath) + { + scanMsg->scanFlags |= NSSFL_moreComponentsFollow; + } + if (nameMsg->workNameSpace->nSpaceOps-> + unicodeScanNextComponent(genMsg, scanMsg) != zOK) + { + goto error_Exit; + } + scanMsg->retScanFlags |= saveRetScanFlags; + zASSERT(nameMsg->scanMsg.retScanFlags & NSRETSFL_componentIsUnicode); + } + + if ((nameMsg->scanMsg.retScanFlags & NSRETSFL_hasWildcardChars) && + !(nameMsg->parseFlags & NAMPFL_allowWildcardChars)) + { + SetErrno(genMsg,zERR_INVALID_NAME); + goto error_Exit; + } + + zASSERT(nameMsg->scanMsg.retScanFlags & NSRETSFL_componentIsUnicode); + + tempLen = LB_unilen(nameMsg->scanMsg.retUnicodeComp); + if (maxDestSize < (tempLen+1)) + { + SetErrno(genMsg,zERR_BUFFER_TOO_SMALL); + goto error_Exit; + } + maxDestSize -= (tempLen+1); + LB_unicpy(destPtr, nameMsg->scanMsg.retUnicodeComp); + destPtr += tempLen; + *destPtr++ = 0; + ++numComponents; + + if (nameMsg->retParseFlags & NAMRETPFL_lastComponent) + { + break; + } + + /* Get the next component */ + if (NMSG_ScanNextComponent(genMsg,nameMsg) != zOK) + { + goto error_Exit; + } + if ((nameMsg->scanMsg.retScanFlags & NSRETSFL_hasWildcardChars) && + !(nameMsg->parseFlags & NAMPFL_allowWildcardChars)) + { + SetErrno(genMsg,zERR_INVALID_NAME); + goto error_Exit; + } + } + + /* Add final NULL terminator */ + *destPtr++ = 0; + *ret_numComponents = numComponents; + + RELEASE_RSRC(NAME_RESERVE); + RTN_STATUS(zOK); + +/*===========================================================================*/ +error_Exit: + RELEASE_RSRC(NAME_RESERVE); + RTN_STATUS(zFAILURE); +} + + +/**************************************************************************** + * This routine is for TESTING ONLY. It is here just for the CMD.NLM to + * be able to test the path parsing code. It iteratively scans all components + * in a path string and builds a return buffer with all of the components + * combined. Each returned component is a NULL terminated string. The + * end of the components is signaled by an extra NULL component at the end + * of the ret_path. + *****************************************************************************/ +STATUS TestScanComponents( + NINT nameSpaceID, + NINT pathFormat, + void *path, + NINT parseFlags, + NINT scanFlags, + NINT sizeRetPath, + unicode_t *ret_path, + NINT *ret_parseFlags, + NINT *ret_scanFlags, + NINT *ret_numComponents) +{ + GeneralMsg_s genMsg; + NamingMsg_s nameMsg; + NINT numComponents; + char *pathPtr; + VolumeID_t volumeID = zINVALID_GUID; + + MPKNSS_LOCK(); + + COMN_INIT_NAMING_MSG(&nameMsg); + COMN_SETUP_GENERAL_MSG(&genMsg,zSYS_CONNECTION,zNO_TASK,zSAGENT_Z); + + pathPtr = (char *)path; + if (pathFormat == zPFMT_ASCII_COUNTED) + { + pathPtr++; + COMN_SET_NAMING_MSG_PATHCOUNT(&nameMsg,*(char *)path); + } + + COMN_SETUP_NAMING_MSG_VOLUME(&nameMsg, volumeID, + pathPtr, pathFormat, NAMPMODE_FullyResolveAny, SLATCHED, + nameSpaceID, zNTYPE_FILE, NULL, 0, NULL, NULL); + + nameMsg.parseFlags = parseFlags; + nameMsg.scanMsg.scanFlags = scanFlags; + + DoScanComponents(&genMsg, &nameMsg, sizeRetPath, ret_path, &numComponents); + + *ret_parseFlags = nameMsg.retParseFlags; + *ret_scanFlags = nameMsg.scanMsg.retScanFlags; + *ret_numComponents = numComponents; + + COMN_CleanupNameMsg(&genMsg, &nameMsg); + MPKNSS_UNLOCK(); + return GetErrno(&genMsg); +} + + diff --git a/src/nwnss/comn/common/namedBeast.c b/src/nwnss/comn/common/namedBeast.c new file mode 100644 index 0000000..605e893 --- /dev/null +++ b/src/nwnss/comn/common/namedBeast.c @@ -0,0 +1,2007 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2007-08-04 03:19:51 +0530 (Sat, 04 Aug 2007) $ + | + | $RCSfile$ + | $Revision: 2122 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This defines all of the primitive BEASTS inside of PSS + +-------------------------------------------------------------------------*/ +#include + +#include "comnPublics.h" + +#include /* NSS Library */ +#include +#include +#include +#include +#include + +#include "comnBeasts.h" +#include "msgGen.h" +#include "msgName.h" +#include "beastStartup.h" +#include "zParams.h" +#include "volume.h" +#include "searchMap.h" +#include "nameSpace.h" +#include "fullDirectoryInfo.h" +#include "name.h" +#include "comnLock.h" +#include "comnAuthorize.h" +#include "comnIO.h" +#include "xmlTags.h" +#include "nssPubs.h" +#include "mgmt.h" +#include "cmDefs.h" +#include "cmNSS.h" +#include "comnCompress.h" +#include "hardLinkBeast.h" + +/* File attributes */ +NINT attrBitsToCheck = ( + zFA_READ_ONLY | zFA_HIDDEN | zFA_SYSTEM | zFA_EXECUTE | + zFA_SUBDIRECTORY | zFA_ARCHIVE | zFA_SHAREABLE | + zFA_SMODE_BITS | zFA_NO_SUBALLOC | zFA_TRANSACTION | + zFA_NOT_VIRTUAL_FILE | zFA_IMMEDIATE_PURGE | + zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT | + zFA_IS_ADMIN_LINK | zFA_IS_LINK | zFS_REMOTE_DATA_ACCESS | + zFA_REMOTE_DATA_INHIBIT | zFA_COMPRESS_FILE_IMMEDIATELY | + zFA_DATA_STREAM_IS_COMPRESSED | zFA_DO_NOT_COMPRESS_FILE | + zFA_CANT_COMPRESS_DATA_STREAM | zFA_ATTR_ARCHIVE | + zFA_VOLATILE); + +utf8_t *attrTags[] = +{ + TAG_READONLY, + TAG_HIDDEN, + TAG_SYSTEM, + TAG_EXECUTE, + + TAG_SUBDIRECTORY, + TAG_ARCHIVE, + "", + TAG_SHAREABLE, + + "", + "", + "", + TAG_NOSUBALLOC, + + TAG_TRANSACTION, + TAG_NOTVIRTUAL, + "", + "", + + TAG_IMMEDIATEPURGE, + TAG_RENAMEINHIBIT, + TAG_DELETEINHIBIT, + TAG_COPYINHIBIT, + + TAG_ADMINLINK, + TAG_LINK, + TAG_REMOTEDATAACCESS, + TAG_REMOTEDATAINHIBIT, + + "", + TAG_COMPRESSIMMEDIATE, + TAG_DATASTREAMCOMPRESS, + TAG_DONOTCOMPRESS, + + "", + TAG_NOSTREAMCOMPRESS, + TAG_ATTRARCHIVE, + TAG_VOLATILE, + 0, +}; + + + +/* name flags */ +NINT nameFlagsBitsToCheck = ( + NFL_HAS_DATA_STREAMS | NFL_HAS_EXTENDED_ATTRIBUTES | + NFL_ADDED_TO_SALVAGE_TREE | NFL_BLKS_NOT_IN_PURGEABLE_CNT); + +utf8_t *nameFlagsTags[] = +{ + TAG_NFLHASDATASTREAMS, + TAG_NFLHASEXTENDEDATTRIBUTES, + "", + "", + + "", + "", + "", + "", + + TAG_NFLADDEDTOSALVAGETREE, + TAG_NFLBLKSNOTINPURGEABLECOUNT, + 0, +}; + + + +NINT nameEntryFlagsToCheck = ( + NAMEforcedUpper | NAMEovflow | NAMEdup | NAMEool | + NAMEnameLenMask | NAMEcaseSensitive); + +utf8_t *nameEntryFlagsTags[] = +{ + "", + "", + "", + "", + + "", + "", + "", + "", + + "", + "", + "", + TAG_NAMELENGTHMASK, + + TAG_NAMEOUTOFLINE, + TAG_NAMEDUPLICATE, + TAG_NAMEOVERFLOW, + TAG_NAMEFORCEDUPPERCASE, + + TAG_NAMECASESENSITIVE, + 0, +}; + +/**************************************************************************** + * This properly initializes a new NAMED beast in memory + *****************************************************************************/ +STATUS NAMED_BST_Construct( + GeneralMsg_s *genMsg, + void *beast_LX) +{ + NamedBeast_s *beast = (NamedBeast_s *)beast_LX; +// cnt beast->NAMEDfirstParentNameUniquifier = zFNU_INVALID_NAME_UNIQUIFIER; + beast->NAMEDfirstParentZid = zINVALID_ZID; + beast->firstParent.p.primaryNameSpaceID = (BYTE)zNSPACE_INVALID; + beast->startLocks = NULL; + beast->endLocks = NULL; + DQ_INIT( &beast->firstParent.names); + DQ_INIT( &beast->NAMEDreserved); + DQ_INIT( &beast->openFileHandles); + return zOK; +} + + +/**************************************************************************** + * This properly cleanups up the NAMED beast from memory + *****************************************************************************/ +void NAMED_BST_Destruct( + void *beast_LX) +{ + NamedBeast_s *beast = (NamedBeast_s *)beast_LX; + /* + * Release any byte range locks: This is put here + * to catch directories and other things that can + * be locked besides files + */ + if (beast->startLocks) + { + COMN_BeastUnlockByteRange(NULL, beast, NULL); + } + + NAMED_BeastCleanupNames(beast, FALSE); + + zASSERT(beast->startLocks == NULL); + zASSERT(beast->endLocks == NULL); + zASSERT(DQ_EMPTY( &beast->openFileHandles)); +} + +void NAMED_BeastCleanupNames( + NamedBeast_s *beast, + BOOL beastIsLatched) +{ + LinkedParentEntry_s *lpnode; + LinkedNameEntry_s *nnode; + GeneralMsg_s genMsg; + +/*--------------------------------------------------------------------------- + * Free FirstParent Names + *---------------------------------------------------------------------------*/ + for (;;) + { + DQ_DEQ(&beast->firstParent.names, nnode, LinkedNameEntry_s, nlink); + if (nnode == NULL) + break; + free(nnode); + } + if (beast->firstParent.t) + { + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + if (!beastIsLatched) + { + X_LATCH(&beast->NAMEDbeastLatch); + } + beast->NAMEDcomnOps.BST_setupNameTypeSpecificInfo(&genMsg, beast, + &beast->firstParent, zNTYPE_FILE, SNT_REMOVE_PARENT); + if (!beastIsLatched) + { + UNX_LATCH(&beast->NAMEDbeastLatch); + } + zASSERT(beast->firstParent.t == NULL); + } +#if (CURRENT_BEAST_VERSION != BEAST_VERSION_3) +#error "Check to see if the beastVersion code below is still correct." +#endif + +/*--------------------------------------------------------------------------- + * Loop through and free all of the names if this is a version 2 beast + *---------------------------------------------------------------------------*/ + if(beast->NAMEDbeastVersion <= BEAST_VERSION_2) + { + for (;;) + { + DQ_DEQ(&beast->NAMEDreserved, lpnode, LinkedParentEntry_s, plink); + if (lpnode == NULL) + break; + + for (;;) + { + DQ_DEQ(&lpnode->pentry.names, nnode, LinkedNameEntry_s, nlink); + if (nnode == NULL) + break; + free(nnode); + } + /* If there is nameType-specific info for this parent entry, remove it*/ + if (lpnode->pentry.t) + { + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + if (!beastIsLatched) + { + X_LATCH(&beast->NAMEDbeastLatch); + } + beast->NAMEDcomnOps.BST_setupNameTypeSpecificInfo(&genMsg, beast, + &lpnode->pentry, zNTYPE_FILE, SNT_REMOVE_PARENT); + if (!beastIsLatched) + { + UNX_LATCH(&beast->NAMEDbeastLatch); + } + zASSERT(lpnode->pentry.t == NULL); + } + free(lpnode); + } + } +} + +#define zZID_ALLOCATION_RANGE_FOR_DIRS zDEFAULT_ZID_ALLOCATION_RANGE +#define zZID_ALLOCATION_RANGE_FOR_FILES 4 + + +/**************************************************************************** + * This routine returns the next available ZID + *****************************************************************************/ +Zid_t NAMED_BST_GetZID( + GeneralMsg_s *genMsg, + NamedBeast_s *directory, + Xaction_s *xaction) +{ + NINT zidCount; + ASSERT_XLATCH(&directory->NAMEDbeastLatch); +/*--------------------------------------------------------------------------- + * If no ZIDS in this directory, allocate some from the volume. + *---------------------------------------------------------------------------*/ + if ((directory->p.numChildZIDs <= 0) || + (directory->p.nextChildZID >= directory->NAMEDvolume->VOLnextZid)) + { + /* If for any reason the directory beast is corrupt, the nextChildZid + * may have a bogus large value. Prevent against giving out large + * corrupt values. + */ + X_LATCH(&directory->NAMEDvolume->VOLbeastLatch); + + zidCount = (directory->NAMEDattributes & zFA_SUBDIRECTORY) ? + zZID_ALLOCATION_RANGE_FOR_DIRS : + zZID_ALLOCATION_RANGE_FOR_FILES; + + directory->p.numChildZIDs = directory->NAMEDcomnVolOps.VOL_allocateZIDs( + genMsg,directory->NAMEDvolume, + zidCount, + &directory->p.nextChildZID, + xaction); + + UNX_LATCH(&directory->NAMEDvolume->VOLbeastLatch); + + if (directory->p.numChildZIDs <= 0) + { + return zINVALID_ZID; + } + } +/*--------------------------------------------------------------------------- + * Always return only 1 ZID. + *---------------------------------------------------------------------------*/ + COMN_MARK_BEAST_XLOCAL(&directory->NAMEDroot,xaction); + directory->p.numChildZIDs--; + return directory->p.nextChildZID++; +} + +/**************************************************************************** + * This function makes sure the namedBeast can be opened + *****************************************************************************/ +STATUS NAMED_BST_BeastNotify( + GeneralMsg_s *genMsg, + RootBeast_s *file, + NINT notifyID) +{ + switch (notifyID) + { + case BST_NOTIFY_CLOSE: + case BST_NOTIFY_CREATE: + case BST_NOTIFY_OPEN: + case BST_NOTIFY_DELETE: + return zOK; + + default: + zASSERT(0); + } + return zFAILURE; +} + + /* + * Initializes the names sub-structure in Info_s + */ +STATUS COMN_InfoInitFileName (zInfo_s *info, NINT numNameSpaces) +{ + LONG *fileNames; + NINT next; + NINT i; + + if (info->infoVersion > zINFO_VERSION_D) + { + goto noSpace; + } + next = info->nextByte; + next = ALIGN(next, sizeof(LONG)); + if (next >= info->totalBytes) + { + goto noSpace; + } + info->names.fileNameArray = next; + info->names.numEntries = numNameSpaces; + fileNames = (LONG *)(((ADDR)info) + next); + next += numNameSpaces * sizeof(LONG); + if (next >= info->totalBytes) + { + goto noSpace; + } + info->nextByte = next; + for (i = 0; i < numNameSpaces; ++i) + { + fileNames[i] = 0; + } + return zOK; + +noSpace: + info->names.fileNameArray = 0; + info->names.numEntries = 0; + return zERR_BUFFER_TOO_SMALL; +} + + /* + * Copy (or put) a file name into the variable data area and + * set up an index in the names sub-structure. + */ +STATUS COMN_InfoPutFileName (zInfo_s *info, NINT nameSpace, unicode_t *name) +{ + LONG *fileNames; + NINT length; + NINT index; + + if (info->infoVersion > zINFO_VERSION_D) + { + return zERR_UNABLE_TO_RETURN_INFO; + } + if (nameSpace >= info->names.numEntries) + { + return zERR_UNABLE_TO_RETURN_INFO; + } + zASSERT(info->names.fileNameArray != 0); + + length = unilen(name) * sizeof(unicode_t); + if (length > (info->totalBytes - info->nextByte)) + { + return zERR_UNABLE_TO_RETURN_INFO; + } + index = info->nextByte; + fileNames = (LONG *)&((BYTE *)info)[info->names.fileNameArray]; + fileNames[nameSpace] = index; + + unicpy( (unicode_t *)&(((BYTE *)info)[index]), name); + + length = ALIGN(length, sizeof(LONG)); + + info->nextByte += length; + + return zOK; +} + + /* + * The data already resides in the variable data area, so + * just assign the index correctly and update the next empty + * area of the variable data area. + */ +void COMN_InfoAssignFileName (zInfo_s *info, NINT nameSpace, NINT ulen) +{ + LONG *fileNames; + NINT size; + + zASSERT(nameSpace < info->names.numEntries); + zASSERT(info->names.fileNameArray != 0); + + fileNames = (LONG *)&((BYTE *)info)[info->names.fileNameArray]; + fileNames[nameSpace] = info->nextByte; + size = (ulen + 1) * sizeof(unicode_t); + size = ALIGN(size, sizeof(LONG)); + if (size > (info->totalBytes - info->nextByte)) + { + info->nextByte = info->totalBytes; + } + else + { + info->nextByte += size; + } +} + +/**************************************************************************** + * This function returns metadata information for a named beast object + *****************************************************************************/ +STATUS NAMED_BST_GetInfo( + GeneralMsg_s *genMsg, + RootBeast_s *file_LX, + GetInfoMsg_s *infoMsg) +{ + NamedBeast_s *file = ( NamedBeast_s *)file_LX; + zInfo_s *fileInfo; + NINT tempSize; + NINT ulen; + NINT blockSize; + ParentEntry_s *parentEntry; + NINT idx, idx2; +// cnt NINT nameUniquifier; + NINT nameType; + BOOL isDataStream; + NINT dataStreamNameSpaceID; + GetStorageInfo_s getStorageInfo; + NameSpace_s *nameSpace; + NINT remainingBytes; + NamedBeast_s *infoFile = file; + + +/*--------------------------------------------------------------------------- + * If the caller requested, fill in any namedBeast specific information + *---------------------------------------------------------------------------*/ + if ((fileInfo = infoMsg->ret_getInfo) == NULL) + return(zOK); /* No info requested */ + + if (((fileInfo->infoVersion == zINFO_VERSION_A) && (fileInfo->nextByte < offsetof(zInfo_s,variableData))) + || ((fileInfo->infoVersion == zINFO_VERSION_B) && (fileInfo->nextByte < offsetof(zInfoB_s,variableData))) + || ((fileInfo->infoVersion == zINFO_VERSION_C) && (fileInfo->nextByte < offsetof(zInfoC_s,variableData))) + || ((fileInfo->infoVersion == zINFO_VERSION_D) && (fileInfo->nextByte < offsetof(zInfoD_s,variableData)))) + { + SetErrno(genMsg,zERR_BUFFER_TOO_SMALL); + return(zFAILURE); + } +/*--------------------------------------------------------------------------- + * Make sure the beast is latched to access its meta data + *---------------------------------------------------------------------------*/ + ASSERT_LATCH(&file->NAMEDbeastLatch); + + if (infoMsg->snapShotFileInfo) + { + infoFile = (NamedBeast_s *)file->NAMEDroot.fileSnapshotBeast; + S_LATCH(&infoFile->NAMEDbeastLatch); + } + + blockSize = (1 << infoFile->NAMEDblkSizeShift); +/*------------------------------------------------------------------------- + * Return COMMON information that is always returned + *-------------------------------------------------------------------------*/ + fileInfo->std.fileType = infoFile->NAMEDbeastClass->classID; + fileInfo->std.fileAttributes = infoFile->NAMEDattributes; + /* If a hardlink was in the path to this beast, return the fact that + * a hardlink was observed. Most other metadata will come from the + * inode beast. + */ + if(infoMsg->hlFile != NULL) + { + fileInfo->std.fileAttributes |= zFA_HARDLINK; + } + fileInfo->std.fileAttributesModMask = 0xFFFFFFFF; + fileInfo->std.logicalEOF = infoFile->NAMEDeof; + +/*--------------------------------------------------------------------------- + * Return optional information + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & zGET_STORAGE_USED) + { + if (infoMsg->snapShotFileInfo) + { + if (COMN_GetPhysicalSizeOfSnap( genMsg, &file->NAMEDroot, + &getStorageInfo) != zOK) + { + UNS_LATCH(&infoFile->NAMEDbeastLatch); + return(zFAILURE); + } + } + else + { + if (COMN_GetStorageInfo(genMsg,file,&getStorageInfo) != zOK) + { + return(zFAILURE); + } + } + fileInfo->storageUsed.physicalEOF = getStorageInfo.physicalEOF; + fileInfo->storageUsed.dataBytes = getStorageInfo.filePhysSize; + fileInfo->storageUsed.metaDataBytes = getStorageInfo.metaDataPhysSize; + } + +/*--------------------------------------------------------------------------- + * Determine the nameUniquifier to use when getting name information. + * NOTE- infoMsg->ret_getInfo must have been previously initialized to + * contain the zids. + *-------------------------------------------------------------------------*/ + if (fileInfo->std.zid != fileInfo->std.dataStreamZid) + { + isDataStream = TRUE; +// cnt nameUniquifier = file->NAMEDfirstParentNameUniquifier; + } + else + { + isDataStream = FALSE; +// cnt nameUniquifier = infoMsg->nameUniquifier; + } + +/*------------------------------------------------------------------------- + * Return the Name of the file in the selected name space + *-------------------------------------------------------------------------*/ + + if (infoMsg->getInfoMask & zGET_NAME) + { + fileInfo->nameStart = fileInfo->nextByte; + remainingBytes = fileInfo->totalBytes - fileInfo->nextByte; + + if (isDataStream) + { + if (NAME_GetFirstNameFromBeast(genMsg, file, + remainingBytes / sizeof(unicode_t), + zINFO_NAME(fileInfo), + NULL, &nameType, &ulen) != zOK) + { + fileInfo->nameStart = 0; + goto cleanup; + } + } + else + { + if (COMN_GetNameFromBeast(genMsg, + infoMsg->hlFile ? ( NamedBeast_s *)infoMsg->hlFile : file, +// cnt nameUniquifier, + infoMsg->nameSpaceID, + remainingBytes / sizeof(unicode_t), + zINFO_NAME(fileInfo), &ulen) != zOK) + { + fileInfo->nameStart = 0; + goto cleanup; + } + } + /* Get the string size and round it up to a Mod4 boundary */ + tempSize = (ulen + 1) * sizeof(unicode_t); + tempSize = ALIGN( tempSize, sizeof(LONG) ); + /* Aligning could have gone beyond remaining bytes */ + if (tempSize > remainingBytes) + { + tempSize = remainingBytes; + } + fileInfo->nextByte += tempSize; + } + +/*------------------------------------------------------------------------- + * Return the Name of the file in all name space + *-------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & zGET_ALL_NAMES) + { + if (COMN_InfoInitFileName(fileInfo, MaxRegisteredNameSpaceID + 1) != zOK) + { + goto cleanup; + } + remainingBytes = fileInfo->totalBytes - fileInfo->nextByte; + if (isDataStream) + { + if (NAME_GetFirstNameFromBeast(genMsg, file, + remainingBytes / sizeof(unicode_t), + (unicode_t *)zINFO_PTR(fileInfo, fileInfo->nextByte), + &dataStreamNameSpaceID, &nameType, &ulen) != zOK) + { + goto cleanup; + } + if (infoMsg->getInfoMask & zGET_NAME) + { + /* We can share with the name in fileInfo->name */ + zINFO_FILENAMES(fileInfo)[dataStreamNameSpaceID] = + fileInfo->nameStart; + } + else + { + /* We can't share, point at this new name... */ + COMN_InfoAssignFileName(fileInfo, dataStreamNameSpaceID, ulen); + } + } + else + { + /* For each namespace supported on the volume, get the + * name of the file. Even if the name is shared in + * the name entry, we may not be able to share it here, + * because of upper/lower casing. For this reason, we + * don't simply walk the name enries for the beast. + */ + for (idx = 0; idx <= MaxRegisteredNameSpaceID; ++idx) + { + if (file->NAMEDvolume->VOLnameSpaceMask & (1<hlFile ? ( NamedBeast_s *)infoMsg->hlFile : file, + /* cnt nameUniquifier,*/idx, + (fileInfo->totalBytes - fileInfo->nextByte) + / sizeof(unicode_t), + (unicode_t *)zINFO_PTR(fileInfo, fileInfo->nextByte), + &ulen) != zOK) + { + zINFO_FILENAMES(fileInfo)[idx] = 0; + goto cleanup; + } + /* See if we can share the name with an + * already returned name + */ + if ((infoMsg->getInfoMask & zGET_NAME) && + (unicmp(zINFO_NAME(fileInfo), + (unicode_t *)zINFO_PTR(fileInfo, + fileInfo->nextByte)) == 0)) + { + /* We can share with the name in fileInfo->name */ + zINFO_FILENAMES(fileInfo)[idx] = fileInfo->nameStart; + } + else + { + /* Can we share with any names already + * added to the array + */ + for (idx2=0; idx2nextByte)) ==0)) + { + /* We can share */ + zINFO_FILENAMES(fileInfo)[idx] = + zINFO_FILENAMES(fileInfo)[idx2]; + break; + } + } + if (idx2 == idx) + { + /* We can't share, point at this new name... */ + COMN_InfoAssignFileName(fileInfo, idx, ulen); + } + } + } + else + { + /* This name does not exist for this name space... */ + zINFO_FILENAMES(fileInfo)[idx] = 0; + } + } + } + } +/*--------------------------------------------------------------------------- + * Return the primaryNameSpaceID + * (We get it for UNIX metadata too, because the unix namespace needs to + * fill in certain metadata based on who the primary name space is. + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & (zGET_PRIMARY_NAMESPACE | zGET_UNIX_METADATA)) + { + isDataStream = TRUE; + + if ((parentEntry = NAME_GetParentEntry(genMsg, + infoMsg->hlFile ? (NamedBeast_s *)infoMsg->hlFile : file)) == NULL) + { + goto cleanup; + } + fileInfo->primaryNameSpaceID = parentEntry->p.primaryNameSpaceID; + } + +/*--------------------------------------------------------------------------- + * Return optional File information + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & (zGET_TIMES_IN_SECS | zGET_TIMES_IN_MICROS)) + { + fileInfo->time.created = INVALID_UTC_TIME; + fileInfo->time.archived = INVALID_UTC_TIME; + fileInfo->time.modified = INVALID_UTC_TIME; + fileInfo->time.accessed = INVALID_UTC_TIME; + fileInfo->time.metaDataModified = INVALID_UTC_TIME; + } + + if (infoMsg->getInfoMask & zGET_IDS) + { + fileInfo->id.owner = zINVALID_USERID; + fileInfo->id.archiver = zINVALID_USERID; + fileInfo->id.modifier = zINVALID_USERID; + fileInfo->id.metaDataModifier = zINVALID_USERID; + } + +/*--------------------------------------------------------------------------- + * Return optional blocksize information + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & zGET_BLOCK_SIZE) + { + fileInfo->blockSize.size = blockSize; + fileInfo->blockSize.sizeShift = infoFile->NAMEDblkSizeShift; + } + +/*--------------------------------------------------------------------------- + * Return optional count information + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & zGET_COUNTS) + { + fileInfo->count.open = infoFile->NAMEDopenCount; + fileInfo->count.hardLink = infoFile->NAMEDnumParents; + } + +/*--------------------------------------------------------------------------- + * Return optional data Stream information + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & zGET_DATA_STREAM_INFO) + { + fileInfo->dataStream.count = 0; + fileInfo->dataStream.totalDataSize = 0; + fileInfo->dataStream.totalNameSize = 0; + } + +/*--------------------------------------------------------------------------- + * Return optional data Stream information + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & zGET_EXTENDED_ATTRIBUTE_INFO) + { + fileInfo->extAttr.count = 0; + fileInfo->extAttr.totalDataSize = 0; + fileInfo->extAttr.totalNameSize = 0; + } + +/*--------------------------------------------------------------------------- + * Return optional deleted file information + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & zGET_DELETED_INFO) + { + if ((parentEntry = NAME_GetParentEntry(genMsg, + infoMsg->hlFile ? (NamedBeast_s *)infoMsg->hlFile : file)) == NULL) + { + goto cleanup; + } + if (parentEntry->p.nameType != zNTYPE_DELETED_FILE) + { + fileInfo->deleted.time = 0; + fileInfo->deleted.id = zINVALID_USERID; + } + else + { + zASSERT(parentEntry->t != NULL); + if (parentEntry->t) + { + fileInfo->deleted.time = parentEntry->t->u.deleted.time; + fileInfo->deleted.id = parentEntry->t->u.deleted.ID; + } + } + } + +/*--------------------------------------------------------------------------- + * Return optional MAC name space meta data + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & zGET_MAC_METADATA) + { + nameSpace = COMN_NameSpaceIDLookup(genMsg, zNSPACE_MAC); + if (nameSpace == NULL) + { + memset(&fileInfo->macNS, 0, sizeof(zMacInfo_s) ); + } + else + { + if (nameSpace->nSpaceOps->getInfo(genMsg, file, infoMsg) != zOK) + { + goto cleanup; + } + COMN_Release(&nameSpace); + } + } +/*--------------------------------------------------------------------------- + * Return optional UNIX name space meta data + *---------------------------------------------------------------------------*/ + if (infoMsg->getInfoMask & zGET_UNIX_METADATA) + { + nameSpace = COMN_NameSpaceIDLookup(genMsg, zNSPACE_UNIX); + if (nameSpace == NULL) + { + memset(&fileInfo->unixNS, 0, sizeof(zUnixInfo_s) ); + } + else + { + if (nameSpace->nSpaceOps->getInfo(genMsg, file, infoMsg) != zOK) + { + goto cleanup; + } + COMN_Release(&nameSpace); + } + } + if (infoMsg->snapShotFileInfo) + { + UNS_LATCH(&infoFile->NAMEDbeastLatch); + } + return zOK; + +/*--------------------------------------------------------------------------- + * + *---------------------------------------------------------------------------*/ +cleanup: + if (infoMsg->snapShotFileInfo) + { + UNS_LATCH(&infoFile->NAMEDbeastLatch); + } + return zFAILURE; +} + +utf8_t* nameTypeToString( + NINT nameType) +{ + switch(nameType) + { + case zNTYPE_FILE: + return MSGNot("File"); + + case zNTYPE_DATA_STREAM: + return MSGNot("DataStream"); + + case zNTYPE_EXTENDED_ATTRIBUTE: + return MSGNot("ExtendedAttribute"); + + case zNTYPE_DELETED_FILE: + return MSGNot("DeletedFile"); + + default: + return MSGNot("Unknown"); + } +} + +utf8_t *nameSpaceIDToString( + NINT nameSpaceID) +{ + switch(nameSpaceID) + { + case zNSPACE_DOS: + return MSGNot("DOS"); + + case zNSPACE_LONG: + return MSGNot("Long"); + + case zNSPACE_MAC: + return MSGNot("Macintosh"); + + case zNSPACE_UNIX: + return MSGNot("Unix"); + + case zNSPACE_EXTENDED_ATTRIBUTE: + return MSGNot("ExtendedAttribute"); + + case zNSPACE_DATA_STREAM: + return MSGNot("DataStream"); + + default: + return MSGNot("Unknown"); + } +} + +STATUS fillParentEntryXML( + GeneralMsg_s *genMsg, + ParentEntry_s *entry, + NINT bufLen, + utf8_t *buf, + NINT *infoLen) +{ + STATUS status; + NINT len = 0; + NINT tmpLen; + NINT i; + LinkedNameEntry_s *nnode; + typedef struct Stack_s{ + utf8_t tmpBuf[8192]; + char guid[GUID_FORMAT_SIZE]; + utf8_t utf8Name[MAX_UTF8_BUF_SIZE]; + } Stack_s; + + STACK_ALLOC(); + + strcpy(&aStack->tmpBuf[len], "<"TAG_PARENTENTRY">"); + len += strlen(&aStack->tmpBuf[len]); + + /* PersistentParentEntry_s */ + sprintf(&aStack->tmpBuf[len], "<"TAG_PERSISTENTPARENTENTRY">" +// cnt "<"TAG_NAMEUNIQUIFIER">%u" + "<"TAG_NAMETYPE">%s" + "<"TAG_PRIMARYNAMESPACEID">%s" + "<"TAG_NUMNAMES">%u" + "<"TAG_RENAMESEQNUM">%u" + "<"TAG_ZID">%Lu" + "", +// cnt entry->p.nameUniquifier, + nameTypeToString(entry->p.nameType), + nameSpaceIDToString(entry->p.primaryNameSpaceID), + entry->p.numNames, + entry->p.renameSeqNum, + entry->p.zid); + len += strlen(&aStack->tmpBuf[len]); + + + /* TypeSpecificPersistentparentEntry_s */ + if (entry->t) + { + LB_GUIDToString(&entry->t->u.deleted.ID, GUID_FORMAT_SIZE, aStack->guid); + + sprintf(&aStack->tmpBuf[len], "<"TAG_TYPESPECIFICPARENTENTRY">" + "<"TAG_DELETEDPARENTENTRY">"); + len += strlen(&aStack->tmpBuf[len]); + + if ((status = MNSS_FillUTCTime(TAG_TIME, entry->t->u.deleted.time, bufLen - len, + &aStack->tmpBuf[len], &tmpLen)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + len += tmpLen; + + sprintf(&aStack->tmpBuf[len], "<"TAG_ID">%s" + "" + "", + aStack->guid); + len += strlen(&aStack->tmpBuf[len]); + } + + /* names */ + sprintf(&aStack->tmpBuf[len], "<"TAG_NAMES">"); + len += strlen(&aStack->tmpBuf[len]); + + DQ_FOREACH(&entry->names, nnode, LinkedNameEntry_s, nlink) + { + sprintf(&aStack->tmpBuf[len], "<"TAG_NAMEENTRY">"); + len += strlen(&aStack->tmpBuf[len]); + + /* nameSpaceMask */ + sprintf(&aStack->tmpBuf[len], "<"TAG_NAMESPACES">"); + len += strlen(&aStack->tmpBuf[len]); + + for (i = 0; i <= MaxRegisteredNameSpaceID; i++) + { + if (nnode->p.nameSpaceMask & (1 << i)) + { + sprintf(&aStack->tmpBuf[len], "<%s/>", nameSpaceIDToString(i)); + len += strlen(&aStack->tmpBuf[len]); + } + } + + sprintf(&aStack->tmpBuf[len], ""); + len += strlen(&aStack->tmpBuf[len]); + + /* flasAndLen */ + sprintf(&aStack->tmpBuf[len], "<"TAG_FLAGS">"); + len += strlen(&aStack->tmpBuf[len]); + + if ((status = MNSS_ConvertBitsToTags((QUAD)nnode->p.flagsAndLen, (QUAD)nameEntryFlagsToCheck, + nameEntryFlagsTags, bufLen - len, &aStack->tmpBuf[len], + &tmpLen)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + len += tmpLen; + + sprintf(&aStack->tmpBuf[len], ""); + len += strlen(&aStack->tmpBuf[len]); + + /* name */ + if (uni2utf(nnode->p.name, aStack->utf8Name, MAX_UTF8_BUF_SIZE) == -1) + { + SetErrno(genMsg, zERR_UNICODE_CONVERSION_ERROR); + status = zFAILURE; + goto exit; + } + sprintf(&aStack->tmpBuf[len], "<"TAG_NAME">", aStack->utf8Name); + len += strlen(&aStack->tmpBuf[len]); + + sprintf(&aStack->tmpBuf[len], ""); + len += strlen(&aStack->tmpBuf[len]); + } + + sprintf(&aStack->tmpBuf[len], ""); + len += strlen(&aStack->tmpBuf[len]); + + + strcpy(&aStack->tmpBuf[len], ""); + len += strlen(&aStack->tmpBuf[len]); + + if ((len + 1)> bufLen) + { + SetErrno(genMsg, zERR_BUFFER_TOO_SMALL); + status = zFAILURE; + goto exit; + } + else + { + strcpy(buf, aStack->tmpBuf); + *infoLen += len; + } + + status = zOK; +exit: + STACK_FREE(); + + return status; +} + +/**************************************************************************** + * this returns information about the beast in XML string format + *****************************************************************************/ +STATUS NAMED_BST_GetInfoXML( + GeneralMsg_s *genMsg, + RootBeast_s *rBeast, + NINT typeOfInfo, + NINT bufLen, + utf8_t *buf, + NINT *infoLen) +{ + STATUS status; + NamedBeast_s *beast = (NamedBeast_s *)rBeast; + statusfunc_t derivedFromGetInfoXML; + NINT len = 0; + NINT tmpLen; +// cnt LinkedParentEntry_s *pnode; + typedef struct Stack_s{ + utf8_t tmpBuf[4096]; + } Stack_s; + Stack_s *aStack; + + /* Call parent routine */ + derivedFromGetInfoXML = COMN_GetNextParentBeastComnOp(beast->NAMEDbeastClass, + COMNOPS_INDEX(BST_getInfoXML), NAMED_BST_GetInfoXML); + if (derivedFromGetInfoXML != NULL && + derivedFromGetInfoXML(genMsg, beast, typeOfInfo, bufLen, buf, infoLen) != zOK) + { + return zFAILURE; + } + + if (!(typeOfInfo & BST_INFO_NAMED)) + { + return zOK; + } + + STACK_ALLOC_NO_ASTACK(); + + bufLen -= *infoLen; + + strcpy(&aStack->tmpBuf[len], "<"TAG_NAMEDBEASTINFO">"); + len += strlen(&aStack->tmpBuf[len]); + + /* PersistentNamed_s */ + sprintf(&aStack->tmpBuf[len], "<"TAG_PERSISTENTNAMED">" + "<"TAG_NEXTCHILDZID">%Lu", + beast->NAMEDnextChildZID); + len += strlen(&aStack->tmpBuf[len]); + + /* attributes */ + sprintf(&aStack->tmpBuf[len], "<"TAG_ATTRIBUTES">"); + len += strlen(&aStack->tmpBuf[len]); + + if ((status = MNSS_ConvertBitsToTags((QUAD)beast->NAMEDattributes, (QUAD)attrBitsToCheck, + attrTags, bufLen - len, &aStack->tmpBuf[len], + &tmpLen)) != zOK) + { + goto exit; + } + + len += tmpLen; + + sprintf(&aStack->tmpBuf[len], ""); + len += strlen(&aStack->tmpBuf[len]); + + /* numChildZIDs and numParents */ + sprintf(&aStack->tmpBuf[len], "<"TAG_NUMCHILDZIDS">%u" + "<"TAG_NUMPARENTS">%u", + beast->NAMEDnumChildZIDs, beast->NAMEDnumParents); + len += strlen(&aStack->tmpBuf[len]); + + /* nameFlags */ + sprintf(&aStack->tmpBuf[len], "<"TAG_NAMEFLAGS">"); + len += strlen(&aStack->tmpBuf[len]); + + if ((status = MNSS_ConvertBitsToTags(beast->NAMEDnameFlags, nameFlagsBitsToCheck, + nameFlagsTags, bufLen - len, &aStack->tmpBuf[len], + &tmpLen)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + len += tmpLen; + + sprintf(&aStack->tmpBuf[len], ""); + len += strlen(&aStack->tmpBuf[len]); + + /* firstParent */ + sprintf(&aStack->tmpBuf[len], "<"TAG_FIRSTPARENT">"); + len += strlen(&aStack->tmpBuf[len]); + + tmpLen = 0; + if ((status = fillParentEntryXML(genMsg, &beast->NAMEDfirstParent, bufLen - len, + &aStack->tmpBuf[len], &tmpLen)) != zOK) + { + goto exit; + } + len += tmpLen; + + sprintf(&aStack->tmpBuf[len], ""); + len += strlen(&aStack->tmpBuf[len]); + +// cnt /* otherParents */ +// cnt if (DQ_NOT_EMPTY(&beast->otherParents)) +// cnt { +// cnt sprintf(&aStack->tmpBuf[len], "<"TAG_OTHERPARENTS">"); +// cnt len += strlen(&aStack->tmpBuf[len]); +// cnt +// cnt DQ_FOREACH(&beast->otherParents,pnode,LinkedParentEntry_s,plink) +// cnt { +// cnt tmpLen = 0; +// cnt if ((status = fillParentEntryXML(genMsg, &pnode->pentry, bufLen - len, +// cnt &aStack->tmpBuf[len], &tmpLen)) != zOK) +// cnt { +// cnt goto exit; +// cnt } +// cnt len += tmpLen; +// cnt } +// cnt +// cnt sprintf(&aStack->tmpBuf[len], ""); +// cnt len += strlen(&aStack->tmpBuf[len]); +// cnt } + + /* the rest */ + sprintf(&aStack->tmpBuf[len], "<"TAG_OPENCOUNT">%u" + "<"TAG_DIOMODECOUNT">%u" + "<"TAG_READERCOUNT">%u" + "<"TAG_WRITERCOUNT">%u" + "<"TAG_DENYREADERCOUNT">%u" + "<"TAG_DENYWRITERCOUNT">%u" + "<"TAG_DONTDELETEWHILEOPENCOUNT">%u" +// cnt "<"TAG_LASTNAMEUNIQUIFIER">%u" + "<"TAG_SNAPREADERCOUNT">%u", + beast->openCount, beast->dioModeCount, beast->readerCount, + beast->writerCount, beast->denyReaderCount, + beast->denyWriterCount, beast->dontDeleteWhileOpenCount, + /* cnt beast->lastNameUniquifier,*/ beast->snapReaderCount); + len += strlen(&aStack->tmpBuf[len]); + + strcpy(&aStack->tmpBuf[len], "\n"); + len += strlen(&aStack->tmpBuf[len]); + + if ((len + 1)> bufLen) + { + SetErrno(genMsg, zERR_BUFFER_TOO_SMALL); + status = zFAILURE; + } + else + { + strcpy(&buf[*infoLen], aStack->tmpBuf); + *infoLen += len; + } + +exit: + STACK_FREE(); + + return status; +} + +/**************************************************************************** + * This function modifies metadata information for a named beast object + *****************************************************************************/ +STATUS NAMED_BST_ModifyInfo( + GeneralMsg_s *genMsg, + RootBeast_s *file, + ModifyInfoMsg_s *modifyMsg, + Xaction_s *xaction) /* Optional xaction, may be NULL */ +{ + SetErrno(genMsg, zERR_CANT_MOD_DATA_STREAM_METADATA); + return zFAILURE; +} + + + +STATUS modifyInfoNameSpaceXML( + GeneralMsg_s *genMsg, + NamedBeast_s *namedBeast, + ADDR address, + XML_ElementInfo_s *element, + Xaction_s *xaction, + BOOL doChange) +{ + STATUS status; + + SNINT oldValue; + SNINT newValue; + utf8_t *oldValueStr; + utf8_t *newValueStr; + + status = getModifyValue(genMsg, element, &oldValueStr, &newValueStr); + if (status != zOK) + { + return status; + } + + if (!newValueStr || !oldValueStr) + { + SetErrno(genMsg, zERR_XML_IS_BAD); + status = zFAILURE; + goto Exit; + } + + oldValue = MNSS_ConvertNameSpaceTagsToValue(oldValueStr); + newValue = MNSS_ConvertNameSpaceTagsToValue(newValueStr); + + if (oldValue == -1 || newValue == -1) + { + SetErrno(genMsg, zERR_INVALID_NAMESPACE_ID); + return zFAILURE; + } + + setNumberValueXML(genMsg, namedBeast, WORD, address, NULL); + +Exit: + return status; +} + +STATUS modifyInfoNameTypeXML( + GeneralMsg_s *genMsg, + NamedBeast_s *namedBeast, + ADDR address, + XML_ElementInfo_s *element, + Xaction_s *xaction, + BOOL doChange) +{ + STATUS status; + + SNINT oldValue; + SNINT newValue; + utf8_t *oldValueStr; + utf8_t *newValueStr; + + status = getModifyValue(genMsg, element, &oldValueStr, &newValueStr); + if (status != zOK) + { + return status; + } + + if (!newValueStr || !oldValueStr) + { + SetErrno(genMsg, zERR_XML_IS_BAD); + return zFAILURE; + } + + oldValue = MNSS_ConvertNameTypeTagsToValue(oldValueStr); + newValue = MNSS_ConvertNameTypeTagsToValue(newValueStr); + + if (oldValue == -1 || newValue == -1) + { + SetErrno(genMsg, zERR_INVALID_NAMESPACE_ID); + return zFAILURE; + } + + setNumberValueXML(genMsg, namedBeast,WORD, address, NULL); + + return status; +} + +STATUS modifyParentEntryXML( + GeneralMsg_s *genMsg, + NamedBeast_s *beast, + ParentEntry_s *pentry, + XML_ElementInfo_s *elementInfo, + Xaction_s *xaction, + BOOL doChange) +{ + STATUS status; + XML_ElementInfo_s element; + + if (XML_GetTagElement(TAG_PARENTENTRY, elementInfo->dataStart, + elementInfo->dataEnd, &element) == zFAILURE) + { + // No parententry related info needs to be modified + return zOK; + } + + if (element.dataStart == NULL) + { + // no actual data + return zOK; + } + + /* PersistentParentEntry_s */ + { + XML_ElementInfo_s persistentElement; + + const TagRequest_s tags[] = + { +// cnt {TAG_NAMEUNIQUIFIER, TR_OPTIONAL}, + {TAG_NAMETYPE, TR_OPTIONAL}, + {TAG_PRIMARYNAMESPACEID, TR_OPTIONAL}, + {TAG_NUMNAMES, TR_OPTIONAL}, + {TAG_RENAMESEQNUM, TR_OPTIONAL}, + {TAG_ZID, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags) - 1]; + + enum + { +// cnt NAME_UNIQUIFIER = 0, + NAME_TYPE = 1, + PRIMARY_NS_ID = 2, + NUM_NAMES = 3, + RENAME_SEQ_NUM = 4, + ZID = 5 + }; + + if (XML_GetTagElement(TAG_PERSISTENTPARENTENTRY, element.dataStart, + element.dataEnd, &persistentElement) == zFAILURE) + { + // No parententry related info needs to be modified + return zOK; + } + + if ((status = MNSS_GetTagContents(NULL, NULL, &persistentElement, tags, tagContent)) != zOK) + { + SetErrno(genMsg, status); + return zFAILURE; + } + +/* cnt if (tagContent[NAME_UNIQUIFIER].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + * { + * modifyInfoNumber(genMsg, beast, WORD, FALSE, (ADDR)&pentry->p.nameUniquifier, + * &tagContent[NAME_UNIQUIFIER].element); + * } + */ + + if (tagContent[NAME_TYPE].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if ((status = modifyInfoNameTypeXML(genMsg, beast, (ADDR)&pentry->p.nameType, + &tagContent[NAME_TYPE].element, xaction, doChange)) != zOK) + { + goto Exit; + } + } + + if (tagContent[PRIMARY_NS_ID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if ((status = modifyInfoNameSpaceXML(genMsg, beast, (ADDR)&pentry->p.primaryNameSpaceID, + &tagContent[PRIMARY_NS_ID].element, xaction, doChange)) != zOK) + { + goto Exit; + } + } + + if (tagContent[NUM_NAMES].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, BYTE, FALSE, (ADDR)&pentry->p.numNames, + &tagContent[NUM_NAMES].element); + } + + if (tagContent[RENAME_SEQ_NUM].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, LONG, FALSE, (ADDR)&pentry->p.renameSeqNum, + &tagContent[RENAME_SEQ_NUM].element); + } + + if (tagContent[ZID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, Zid_t, FALSE, (ADDR)&pentry->p.zid, + &tagContent[ZID].element); + } + } + +Exit: + return status; +} + +STATUS attributesChangeFunc( + GeneralMsg_s *genMsg, + void *beast, + void *oldAttrAddr, + void *newAttrAddr, + Xaction_s *xaction) +{ + NamedBeast_s *namedBeast = (NamedBeast_s *)beast; + QUAD oldAttr = *(QUAD *)oldAttrAddr; + QUAD newAttr = *(QUAD *)newAttrAddr; + QUAD changedBits = oldAttr ^ newAttr; + + /* compression related attributes */ + if (changedBits & zFA_CANT_COMPRESS_DATA_STREAM) + { + if (newAttr & zFA_CANT_COMPRESS_DATA_STREAM) + { + INC_VOLUME_UNCOMPRESSIBLE_FILES(namedBeast, xaction); + CHANGE_COMP_STATS_UNCOMPRESSIBLE_FILES(1); + } + else + { + DEC_VOLUME_UNCOMPRESSIBLE_FILES(namedBeast, xaction); + CHANGE_COMP_STATS_UNCOMPRESSIBLE_FILES(-1); + } + } + + if (changedBits & zFA_DATA_STREAM_IS_COMPRESSED) + { + RootBeast_s *compBeast = NULL; + CompressInfo_s *compInfo = BEAST_CM_INFO((RootBeast_s *)beast); + + if (compInfo != NULL && compInfo->p.compZid != zINVALID_ZID) + { + if ((compBeast = COMN_LookupByZid(genMsg, namedBeast->NAMEDvolume, compInfo->p.compZid, + NOTLATCHED, TRUE)) == NULL) + { + if (newAttr & zFA_DATA_STREAM_IS_COMPRESSED) + { + return zFAILURE; + } + } + } + + if (newAttr & zFA_DATA_STREAM_IS_COMPRESSED) + { + if (compInfo == NULL || compInfo->p.compZid == zINVALID_ZID || compBeast == NULL) + { + return zFAILURE; + } + + if (NAME_AllNamesInSalvage(namedBeast)) + { + INC_VOLUME_COMP_DELETED_FILES(namedBeast->NAMEDvolume, xaction); + CHANGE_COMP_STATS_COMP_DELETED_FILES(1); + } + + INC_VOLUME_COMPRESSED_FILES(namedBeast->NAMEDvolume, xaction); + CHANGE_COMP_STATS_COMPRESSED_FILES(1); + + CHANGE_VOLUME_COMPRESSED_FILE_BLOCKS( + compBeast, xaction, + CEILING(compBeast->eof, compBeast->ROOTvolume->VOLblockSize) + >> compBeast->ROOTvolume->VOLblockShift); + + /* update volume's num of precompressed blocks */ + CHANGE_VOLUME_PRECOMPRESSED_FILE_BLOCKS( + namedBeast, xaction, + CEILING(namedBeast->NAMEDeof, namedBeast->NAMEDvolume->VOLblockSize) + >> namedBeast->NAMEDvolume->VOLblockShift); + } + else + { + if (NAME_AllNamesInSalvage(namedBeast)) + { + DEC_VOLUME_COMP_DELETED_FILES(namedBeast->NAMEDvolume, xaction); + CHANGE_COMP_STATS_COMP_DELETED_FILES(-1); + } + + DEC_VOLUME_COMPRESSED_FILES(namedBeast->NAMEDvolume, xaction); + CHANGE_COMP_STATS_COMPRESSED_FILES(-1); + + if (compBeast != NULL) + { + CHANGE_VOLUME_COMPRESSED_FILE_BLOCKS( + compBeast, xaction, + -CEILING(compBeast->eof, compBeast->ROOTvolume->VOLblockSize) + >> compBeast->ROOTvolume->VOLblockShift); + + /* update volume's num of precompressed blocks */ + CHANGE_VOLUME_PRECOMPRESSED_FILE_BLOCKS( + namedBeast, xaction, + -CEILING(namedBeast->NAMEDeof, namedBeast->NAMEDvolume->VOLblockSize) + >> namedBeast->NAMEDvolume->VOLblockShift); + } + } + + if (compBeast != NULL) + { + COMN_UnlatchAndRelease(&compBeast, NOTLATCHED); + } + } + + return zOK; +} + +/** + * Ying - March 4, 2004 + * NOTE: This function is provided for convinence, although I did my best + * to ensure its correctness, it's not fully tested except for attributes + * change + */ +STATUS NAMED_BST_ModifyInfoXML( + GeneralMsg_s *genMsg, + RootBeast_s *rBeast, + NINT bufLen, + utf8_t *buf, + Xaction_s *xaction, + BOOL doChange) +{ + STATUS status = zOK; + NamedBeast_s *beast = (NamedBeast_s *)rBeast; + statusfunc_t derivedFromSetInfoXML; + XML_ElementInfo_s elementInfo; + utf8_t *copyBuf = NULL; + + const TagRequest_s tags[] = + { + {TAG_PERSISTENTNAMED, TR_OPTIONAL}, + {TAG_FIRSTPARENT, TR_OPTIONAL}, +// cnt {TAG_OTHERPARENTS, TR_OPTIONAL}, + {TAG_OPENCOUNT, TR_OPTIONAL}, + {TAG_DIOMODECOUNT, TR_OPTIONAL}, + {TAG_READERCOUNT, TR_OPTIONAL}, + {TAG_WRITERCOUNT, TR_OPTIONAL}, + {TAG_DENYREADERCOUNT, TR_OPTIONAL}, + {TAG_DENYWRITERCOUNT, TR_OPTIONAL}, + {TAG_DONTDELETEWHILEOPENCOUNT, TR_OPTIONAL}, +// cnt {TAG_LASTNAMEUNIQUIFIER, TR_OPTIONAL}, + {TAG_SNAPREADERCOUNT, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags) - 1]; + + enum + { + PERSISTENT_NAMED = 0, + FIRST_PARENT = 1, + OTHER_PARENTS = 2, + OPEN_COUNT = 3, + DIO_MODE_COUNT = 4, + READER_COUNT = 5, + WRITER_COUNT = 6, + DENY_READER_COUNT = 7, + DENY_WRITER_COUNT = 8, + DONT_DELETE_WHILE_OPEN_COUNT = 9, +// cnt LAST_NAME_UNIQUIFIER = 10, + SNAP_READER_COUNT = 11 + }; + + /* Call parent routine */ + derivedFromSetInfoXML = COMN_GetNextParentBeastComnOp(beast->NAMEDbeastClass, + COMNOPS_INDEX(BST_modifyInfoXML), NAMED_BST_ModifyInfoXML); + if (derivedFromSetInfoXML != NULL && + derivedFromSetInfoXML(genMsg, rBeast, bufLen, buf, xaction, doChange) != zOK) + { + return zFAILURE; + } + + /* make another copy of buf, buf will be changed + * while doing MNSS_GetTagContents + */ + copyBuf = malloc(bufLen); + if (copyBuf == NULL) + { + SetErrno(genMsg, zERR_NO_MEMORY); + return zFAILURE; + } + memcpy(copyBuf, buf, bufLen); + + if (XML_GetTagElement(TAG_NAMEDBEASTINFO, copyBuf, copyBuf + bufLen - 1, + &elementInfo) == zFAILURE) + { + // No namedBeast related info needs to be modified + status = zOK; + goto Exit; + } + + if (elementInfo.dataStart == NULL) + { + // no actual data + status = zOK; + goto Exit; + } + + if ((status = MNSS_GetTagContents(NULL, NULL, &elementInfo, tags, tagContent)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto Exit; + } + + /* + * modify persistent data + */ + + if (tagContent[PERSISTENT_NAMED].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + const TagRequest_s persistentTags[] = + { + {TAG_NEXTCHILDZID, TR_OPTIONAL}, + {TAG_ATTRIBUTES, TR_OPTIONAL}, + {TAG_NUMCHILDZIDS, TR_OPTIONAL}, + {TAG_NUMPARENTS, TR_OPTIONAL}, + {TAG_NAMEFLAGS, TR_OPTIONAL}, + {0} + }; + TagContent_s persistentContent[NELEMS(persistentTags) - 1]; + + enum + { + NEXT_CHILD_ZID = 0, + ATTRIBUTES = 1, + NUM_CHILD_ZIDS = 2, + NUM_PARENTS = 3, + NAME_FLAGS = 4, + }; + + if ((status = MNSS_GetTagContents(NULL, NULL, &tagContent[PERSISTENT_NAMED].element, + persistentTags, persistentContent)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto Exit; + } + + if (persistentContent[NEXT_CHILD_ZID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, Zid_t, FALSE, (ADDR)&beast->NAMEDnextChildZID, + &persistentContent[NEXT_CHILD_ZID].element); + } + + if (persistentContent[ATTRIBUTES].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyFlagsInfoXML(genMsg, beast, LONG, (ADDR)&beast->NAMEDattributes, + &persistentContent[ATTRIBUTES].element, (QUAD)attrBitsToCheck, (utf8_t **)attrTags, + attributesChangeFunc); + } + + if (persistentContent[NUM_CHILD_ZIDS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, WORD, FALSE, (ADDR)&beast->NAMEDnumChildZIDs, + &persistentContent[NUM_CHILD_ZIDS].element); + } + + if (persistentContent[NUM_PARENTS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, WORD, FALSE, (ADDR)&beast->NAMEDnumParents, + &persistentContent[NUM_PARENTS].element); + } + + if (persistentContent[NAME_FLAGS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyFlagsInfoXML(genMsg, beast, WORD, (ADDR)&beast->NAMEDnameFlags, + &persistentContent[NAME_FLAGS].element, + (QUAD)nameFlagsBitsToCheck, (utf8_t **)nameFlagsTags, NULL); + } + } + + if (tagContent[FIRST_PARENT].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyParentEntryXML(genMsg, beast, &beast->NAMEDfirstParent, + &tagContent[FIRST_PARENT].element, xaction, doChange); + } + +#if 0 +// Fixfixfix this part needs to be rewrite if ever there's a need to use it +// i.e., need to destroy and recreate the other parents link list. + if (tagContent[OTHER_PARENTS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + utf8_t *start = (utf8_t *)tagContent[OTHER_PARENTS].element.dataStart; + + while (XML_GetTagElement(TAG_PARENTENTRY, + start, + (utf8_t *)tagContent[OTHER_PARENTS].element.dataEnd, + &pEntryElementInfo) == zOK) + { + modifyParentEntryXML(genMsg, beast, &beast->NAMEDfirstParent, + &tagContent[OTHER_PARENTS].element, xaction, doChange); + start = (utf8_t *)pEntryElementInfo.elementEnd + 1; + }; + } +#endif + + /* other counts */ + if (tagContent[OPEN_COUNT].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, NINT, FALSE, (ADDR)&beast->NAMEDopenCount, + &tagContent[OPEN_COUNT].element); + } + + if (tagContent[DIO_MODE_COUNT].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, NINT, FALSE, (ADDR)&beast->NAMEDdioModeCount, + &tagContent[DIO_MODE_COUNT].element); + } + if (tagContent[READER_COUNT].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, WORD, FALSE, (ADDR)&beast->NAMEDreaderCount, + &tagContent[READER_COUNT].element); + } + if (tagContent[WRITER_COUNT].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, WORD, FALSE, (ADDR)&beast->NAMEDwriterCount, + &tagContent[WRITER_COUNT].element); + } + if (tagContent[DENY_READER_COUNT].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, WORD, FALSE, (ADDR)&beast->NAMEDdenyReaderCount, + &tagContent[DENY_READER_COUNT].element); + } + if (tagContent[DENY_WRITER_COUNT].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, WORD, FALSE, (ADDR)&beast->NAMEDdenyWriterCount, + &tagContent[DENY_WRITER_COUNT].element); + } + if (tagContent[DONT_DELETE_WHILE_OPEN_COUNT].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, WORD, FALSE, (ADDR)&beast->NAMEDdontDeleteWhileOpenCount, + &tagContent[DONT_DELETE_WHILE_OPEN_COUNT].element); + } +/* cnt if (tagContent[LAST_NAME_UNIQUIFIER].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + * { + * modifyInfoNumber(genMsg, beast, WORD, FALSE, (ADDR)&beast->lastNameUniquifier, + * &tagContent[LAST_NAME_UNIQUIFIER].element); + * } + */ + if (tagContent[SNAP_READER_COUNT].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, WORD, FALSE, (ADDR)&beast->NAMEDsnapReaderCount, + &tagContent[SNAP_READER_COUNT].element); + } + + status = zOK; +Exit: + free(copyBuf); + + return status; +} + +/**************************************************************************** + * Given a beast, allocate a new nameUniquifier to use for a new parent link + *****************************************************************************/ +// cnt STATIC NINT NAMED_VOL_GetNameUniquifier( +// cnt GeneralMsg_s *genMsg, +// cnt NamedBeast_s *beast) +// cnt{ +// cnt /* There is no higher-up comnOps for this function. Just do the +// cnt * default functionality here */ +// cnt +// cnt ++beast->lastNameUniquifier; +// cnt if (beast->lastNameUniquifier == zFNU_INVALID_NAME_UNIQUIFIER) +// cnt { +// cnt beast->lastNameUniquifier = zFNU_UNDEFINED + 1; +// cnt } +// cnt +// cnt /* FixFixFix6 -- This is simpleMinded--It needs to be fixed when we +// cnt * finish full support for scalable numbers of hard links */ +// cnt return (beast->lastNameUniquifier); +// cnt} + +/**************************************************************************** + * Setup nameTypeSpecificInfo for the beast + * All we support in the common layer is some typeSpecific info for salvage. + * If an LSS wishes to store additionial typeSpecific info for any nameType, + * it must override this function. + *****************************************************************************/ +STATIC STATUS NAMED_VOL_SetupNameTypeSpecificInfo( + GeneralMsg_s *genMsg, + NamedBeast_s *beast, + struct ParentEntry_s *pentry, + NINT newNameType, + NINT action) +{ + ASSERT_XLATCH(&beast->NAMEDbeastLatch); + + switch (action) + { + case SNT_NEW_PARENT: + zASSERT(pentry->t == NULL); + if (newNameType == zNTYPE_DELETED_FILE) + { + pentry->t = zalloc(sizeof(TypeSpecificPersistentParentEntry_s)); + if (pentry->t == NULL) + { + SetErrno(genMsg,zERR_NO_MEMORY); + return(zFAILURE); + } + } + break; + + case SNT_REMOVE_PARENT: + if (pentry->t) + { + free(pentry->t); + pentry->t = NULL; + } + break; + + case SNT_CHANGE_NAMETYPE: + if ((newNameType != pentry->p.nameType) && + (newNameType == zNTYPE_DELETED_FILE)) + { + zASSERT(pentry->t == NULL); + + pentry->t = zalloc(sizeof(TypeSpecificPersistentParentEntry_s)); + if (pentry->t == NULL) + { + SetErrno(genMsg,zERR_NO_MEMORY); + return(zFAILURE); + } + } + break; + default: + SetErrno(genMsg,zERR_BAD_PARAMETER_VALUE); + return(zFAILURE); + } + return(zOK); +} + + +/**************************************************************************** + * COMMON OPS definition + * + *****************************************************************************/ + +/*--------------------------------------------------------------------------- + * NamedBeast ComnOps + *---------------------------------------------------------------------------*/ +CommonBeastOps_s NamedBeastComnOps = +{ + NAMED_BST_Construct, /* construct */ + NAMED_BST_Destruct, /* destruct */ + +// cnt NULL, /* BST_getNameUniquifier */ + NULL, /* BST_setupNameTypeSpecificInfo */ + NULL, /* BST_lookupByNameInDirectory*/ + NULL, /* BST_isDirectoryEmpty*/ + NULL, /* BST_addNameToDirectory*/ + NULL, /* BST_removeNameFromDirectory*/ + NULL, /* BST_modifyNameSpaceMaskInDirectory*/ + NULL, /* BST_setMatchAttributesInDirectory*/ + NULL, /* BST_wildcardLookup*/ + + NULL, /* BST_truncateFile*/ + NULL, /* BST_getStorageInfo*/ + NULL, /* BST_getExtentList*/ + NULL, /* BST_getPhysicalExtent*/ + NULL, /* BST_isBlockInBeast*/ + + NULL, /* BST_asyncReadFileBlk*/ + NULL, /* BST_getFileBlk*/ + NULL, /* BST_dioReadUnits*/ + NULL, /* BST_dioWriteUnits*/ + + NAMED_BST_GetZID, /* BST_getZID*/ + NAMED_BST_BeastNotify, /* BST_beastNotify*/ + NAMED_BST_GetInfo, /* BST_getInfo*/ + NAMED_BST_ModifyInfo, /* BST_modifyInfo*/ + NAMED_BST_GetInfoXML, /* BST_getInfoXML*/ + NAMED_BST_ModifyInfoXML, /* BST_modifyInfoXML*/ +}; + +/*------------------------------------------------------------------------- + * NamedBeast VOLUME ComnOps + *-------------------------------------------------------------------------*/ +CommonVolumeOps_s NamedBeastComnVolOps = +{ +// cnt NAMED_VOL_GetNameUniquifier, /* VOL_getNameUniquifier */ + NAMED_VOL_SetupNameTypeSpecificInfo, /* VOL_setupNameTypeSpecificInfo */ + NULL, /* VOL_lookupByNameInDirectory */ + NULL, /* VOL_isDirectoryEmpty */ + NULL, /* VOL_addNameToDirectory */ + NULL, /* VOL_removeNameFromDirectory */ + NULL, /* VOL_modifyNameSpaceMaskInDirectory */ + NULL, /* VOL_setMatchAttributesInDirectory */ + NULL, /* VOL_wildcardLookup */ + + NULL, /* VOL_truncateFile*/ + NULL, /* VOL_getStorageInfo*/ + NULL, /* VOL_getExtentList*/ + NULL, /* VOL_getPhysicalExtent*/ + NULL, /* VOL_isBlockInBeast*/ + + NULL, /* VOL_asyncReadFileBlk */ + NULL, /* VOL_getFileBlk */ + NULL, /* VOL_dioReadUnits */ + NULL, /* VOL_dioWriteUnits */ + + NULL, /* VOL_beginXLocal */ + NULL, /* VOL_endXLocal */ + NULL, /* VOL_addPurgeLogEntry */ + NULL, /* VOL_removePurgeLogEntry */ + NULL, /* VOL_writeVolumeLoggedData */ + + NULL, /* VOL_changeVolumeState */ + NULL, /* VOL_volumeMaintenance */ + NULL, /* VOL_allocStorageInfo */ + NULL, /* VOL_freeStorageInfo */ + NULL, /* VOL_getBeastFromVolume */ + NULL, /* VOL_updateBeastToVolume */ + NULL, /* VOL_insertBeastIntoVolume */ + NULL, /* VOL_removeBeastFromVolume */ + NULL, /* VOL_allocateZIDs */ + NULL, /* VOL_flushSystemBeasts */ + NULL, /* VOL_makeVolumeFreeSpace */ + NULL, /* VOL_browseBeastsInVolume */ + + NULL, /* VOL_getUserSpaceInfo */ + NULL, /* VOL_setUserSpaceRestriction */ + NULL, /* VOL_adjustUsedUserSpace */ + NULL, /* VOL_removeUser */ + NULL, /* VOL_resetAllUsers */ + NULL, /* VOL_browseUsersInVolume */ + + NULL, /* VOL_insertMFLEntry */ + NULL, /* VOL_deleteMFLEntry */ + NULL, /* VOL_lookupMFLEntry */ + NULL, /* VOL_enumerateMFL */ + NULL, /* VOL_administerMFL */ + NULL, /* VOL_commandFunction */ + + NULL, /* VOL_getDirQuotaInfo */ + NULL, /* VOL_setDirQuota */ + NULL, /* VOL_adjustUsedDirSpace */ + NULL, /* VOL_removeDirectory */ + NULL, /* VOL_resetAllDirEntries */ + NULL, /* VOL_browseDirsInVolume */ + + NULL, /* VOL_getObjectName */ + NULL, /* VOL_insertObjectName */ + NULL, /* VOL_resetAllObjects */ + NULL, /* VOL_modifyObjectName */ + + NULL, /* VOL_insertEFLEntry */ + NULL, /* VOL_deleteEFLEntry */ + NULL, /* VOL_lookupEFLEntry */ + NULL, /* VOL_enumerateEFL */ + NULL, /* VOL_administerEFL */ + NULL, /* VOL_resetEFL */ + + NULL, /* VOL_FCNTL */ +}; diff --git a/src/nwnss/comn/common/objectIDStore.c b/src/nwnss/comn/common/objectIDStore.c index 46dcc2e..a45e550 100644 --- a/src/nwnss/comn/common/objectIDStore.c +++ b/src/nwnss/comn/common/objectIDStore.c @@ -114,10 +114,10 @@ void OID_DisplayCache(void) NINT i; ObjectIDCacheNode_s *node; char buffer[GUID_FORMAT_SIZE]; - + ASSERT_MPKNSS_LOCK(); DBG_DebugPrintf(LGRAY,MSGNot("-------- Object ID Cache Contents --------\n")); - DBG_DebugPrintf(LGREEN, "numUnusedEntries: %d\n", + DBG_DebugPrintf(LGREEN, "numUnusedEntries: %d\n", ObjectIDCache.numUnusedEntries); ASSERT_LATCH(&ObjectIDCache.latch); if (ObjectIDCache.hash != NULL) @@ -207,7 +207,7 @@ void OID_CacheUninit(void) DQhead_t *hp; NINT i; ObjectIDCacheNode_s *item; - + if (ObjectIDCache.numHashEntries == 0) { return; @@ -217,7 +217,7 @@ void OID_CacheUninit(void) X_LATCH(&ObjectIDCache.latch); if (ObjectIDCache.hash != NULL) { - for (hp = &(*ObjectIDCache.hash)[0], i = ObjectIDCache.numHashEntries; + for (hp = &(*ObjectIDCache.hash)[0], i = ObjectIDCache.numHashEntries; i > 0; hp++, i--) { for (;;) @@ -267,11 +267,11 @@ NINT OID_ComputeHash( * a better distribution. */ - volPiece = (NINT)volume ? volume->VOLzid : 0; + volPiece = (NINT)volume ? volume->VOLzid : 0; - return ((objectID->timeLow >> 8) + (objectID->timeLow & 0xff) + volPiece) & + return ((objectID->timeLow >> 8) + (objectID->timeLow & 0xff) + volPiece) & (ObjectIDCache.numHashEntries - 1); -} +} /**************************************************************************** @@ -309,7 +309,7 @@ ObjectIDCacheNode_s *OID_CheckObjectIDCache( { /* these are the same entry */ #ifdef OID_DEBUG // LB_GUIDToString(&cacheNode->objectID, sizeof(buffer), buffer); -// DBG_DebugPrintf (LGREEN, "object id cache hit: objectID=%s vol=%Ld\n", +// DBG_DebugPrintf (LGREEN, "object id cache hit: objectID=%s vol=%Ld\n", // buffer, volume->VOLzid); #endif DQ_RMV(cacheNode, LRUlink); @@ -320,7 +320,7 @@ ObjectIDCacheNode_s *OID_CheckObjectIDCache( } #ifdef OID_DEBUG LB_GUIDToString(objectID, sizeof(buffer), buffer); - DBG_DebugPrintf (LRED, "object id cache miss: objectID=%s vol=%Ld\n", + DBG_DebugPrintf (LRED, "object id cache miss: objectID=%s vol=%Ld\n", buffer, volume->VOLzid); #endif @@ -344,7 +344,7 @@ void OID_AddObjectIDToCache( #endif X_LATCH(&ObjectIDCache.latch); - + /* * If it is already there then just return */ @@ -377,7 +377,7 @@ void OID_AddObjectIDToCache( DQ_ENQ(&ObjectIDCache.unusedQueue, cacheNode, hashLink); /* save the entry for reuse */ ObjectIDCache.numUnusedEntries++; } - + if (ObjectIDCache.numUnusedEntries > 0) { /* use a packet from the unused list */ @@ -437,7 +437,7 @@ void OID_RemoveEntryFromCache( DBG_DebugPrintf(YELLOW, "Removing OID cache entry: objectID=%s vol=%Ld\n", buffer, volume->VOLzid); #endif - + if ((cacheNode = OID_CheckObjectIDCache(volume, objectID)) != NULL) { /* found the cache entry */ DQ_RMV(cacheNode, LRUlink); @@ -475,7 +475,7 @@ void OID_InvalidateObjectIDCache( if (ObjectIDCache.hash != NULL) { zASSERT(ObjectIDCache.numEntries <= ObjectIDCache.maxEntries); - for (hashp=&(*ObjectIDCache.hash)[0],i=0; i < ObjectIDCache.numHashEntries; + for (hashp=&(*ObjectIDCache.hash)[0],i=0; i < ObjectIDCache.numHashEntries; hashp++,i++) { DQ_FOREACH(hashp, cacheNode, ObjectIDCacheNode_s, hashLink) @@ -495,7 +495,7 @@ void OID_InvalidateObjectIDCache( } } #ifdef OID_DEBUG - DBG_DebugPrintf (YELLOW, + DBG_DebugPrintf (YELLOW, "Invalidated object cache for volume %Ld.\n", volume->VOLzid); #endif UNX_LATCH(&ObjectIDCache.latch); @@ -523,8 +523,8 @@ BOOL OID_FixupName( } /* - * Match the patttern against the end of the target. If the entire - * pattern matches then we have a substring match so replace the + * Match the patttern against the end of the target. If the entire + * pattern matches then we have a substring match so replace the * matched part with the new name. */ if (uniicmp(&target[targetLen - patternLen], pattern) == 0) @@ -593,7 +593,7 @@ void OID_CheckNamesInVolume( for (;;) { if (volume->VOLcomnVolOps.VOL_browseUsersInVolume(&genMsg, volume, - MAX_USER_INFO_ENTRIES, &lastUserReturned, aStack->userInfo, + MAX_USER_INFO_ENTRIES, &lastUserReturned, aStack->userInfo, &numReturned, BROWSE_USERS_GET_ALL) != zOK) { zASSERT("Error browsing users in volume" == NULL); @@ -631,22 +631,22 @@ void OID_CheckNamesInVolume( case NDS_RENAME: { #ifdef OID_DEBUG - DBG_DebugPrintf(LCYAN, "process rename/move name: %U\n", + DBG_DebugPrintf(LCYAN, "process rename/move name: %U\n", entry->u.ren.oldName); #endif - if (OID_FixupName(uniName, entry->u.ren.oldName, + if (OID_FixupName(uniName, entry->u.ren.oldName, entry->u.ren.newName)) { xaction = volume->VOLcomnVolOps.VOL_beginXLocal( volume, X_CF_DEFAULT); status = volume->VOLcomnVolOps.VOL_insertObjectName( - &genMsg, volume, xaction, &aStack->userInfo[i].userID, + &genMsg, volume, xaction, &aStack->userInfo[i].userID, uniName); volume->VOLcomnVolOps.VOL_endXLocal(xaction); if (status != zOK) { ClearErrno(&genMsg); - zASSERT("Error changing name in object store" == + zASSERT("Error changing name in object store" == NULL); } G2I_InvalidateCache(); @@ -656,7 +656,7 @@ void OID_CheckNamesInVolume( case NDS_DELETE: { #ifdef OID_DEBUG - DBG_DebugPrintf(LCYAN, "process delete name: %U\n", + DBG_DebugPrintf(LCYAN, "process delete name: %U\n", entry->u.del.name); #endif if (uniicmp(uniName, entry->u.del.name) == 0) @@ -664,13 +664,13 @@ void OID_CheckNamesInVolume( xaction = volume->VOLcomnVolOps.VOL_beginXLocal( volume, X_CF_DEFAULT); status = volume->VOLcomnVolOps.VOL_modifyObjectName( - &genMsg, volume, xaction, &aStack->userInfo[i].userID, + &genMsg, volume, xaction, &aStack->userInfo[i].userID, &uniNULL, 1, 9999); volume->VOLcomnVolOps.VOL_endXLocal(xaction); if (status != zOK) { ClearErrno(&genMsg); - zASSERT("Error changing name in object store" == + zASSERT("Error changing name in object store" == NULL); } G2I_InvalidateCache(); @@ -722,16 +722,16 @@ void OID_ProcessEventThread( /* * Check the queued events against each volume */ - SET_FOREACHBLOCKING(&NSSMasterVolumeList, volume, Volume_s, + SET_FOREACHBLOCKING(&NSSMasterVolumeList, volume, Volume_s, masterVolLink) { /*** You MUST NOT use continue in this loop because the macro *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called *** every time through the loop. Technically, you *** can use a continue BEFORE any blocking calls. ***/ - + OID_CheckNamesInVolume(volume, &eventHead); - SET_FOREACHBLOCKINGEND(&NSSMasterVolumeList, volume, Volume_s, + SET_FOREACHBLOCKINGEND(&NSSMasterVolumeList, volume, Volume_s, masterVolLink) } @@ -802,7 +802,7 @@ int OID_StartEventThread() FSMLITE_INIT(fsm, "FSM for object store event handling", ++fsmInstance); - WORK_Schedule(fsm, (voidfunc_t)OID_ProcessEventThread, (ADDR)NULL); + WORK_Schedule(fsm, OID_ProcessEventThread, NULL); } return 0; } @@ -839,12 +839,12 @@ void OID_ExportVolGUIDsToLinuxThread( STACK_ALLOC(); ASSERT_MPKNSS_LOCK(); - COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); aStack->lastUserReturned = zINVALID_USERID; for (;;) { if (volume->VOLcomnVolOps.VOL_browseUsersInVolume(&genMsg, volume, - MAX_USER_INFO_ENTRIES, &aStack->lastUserReturned, aStack->userInfo, + MAX_USER_INFO_ENTRIES, &aStack->lastUserReturned, aStack->userInfo, &numReturned, BROWSE_USERS_GET_ALL) != zOK) { zASSERT("Error browsing users in volume" == NULL); @@ -901,10 +901,10 @@ void OID_ExportVolGUIDsToLinuxThread( */ if (modifyNotFound) { - xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, + xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, X_CF_DEFAULT); status = volume->VOLcomnVolOps.VOL_modifyObjectName( - &genMsg, volume, xaction, &aStack->userInfo[idx].userID, + &genMsg, volume, xaction, &aStack->userInfo[idx].userID, aStack->uniName, timeNotFound, numberOfTimesNotFound); volume->VOLcomnVolOps.VOL_endXLocal(xaction); if (status != zOK) @@ -956,7 +956,7 @@ void OID_ExportVolGUIDsToLinux( free(fsm); return; } - WORK_Schedule(fsm, (voidfunc_t)OID_ExportVolGUIDsToLinuxThread, (ADDR)volume); + WORK_Schedule(fsm, OID_ExportVolGUIDsToLinuxThread, (ADDR)volume); } /**************************************************************************** @@ -986,7 +986,7 @@ void NDP_DNChangedHandler( { goto exit; } - newEntry->u.del.name = (unicode_t *)((BYTE *)newEntry + + newEntry->u.del.name = (unicode_t *)((BYTE *)newEntry + sizeof(EventEntry_s)); newEntry->next = NULL; newEntry->type = NDS_DELETE; @@ -1008,9 +1008,9 @@ void NDP_DNChangedHandler( { goto exit; } - newEntry->u.ren.oldName = (unicode_t *)((BYTE *)newEntry + + newEntry->u.ren.oldName = (unicode_t *)((BYTE *)newEntry + sizeof(EventEntry_s)); - newEntry->u.ren.newName = (unicode_t *)((BYTE *)newEntry->u.ren.oldName + + newEntry->u.ren.newName = (unicode_t *)((BYTE *)newEntry->u.ren.oldName + oldSize); newEntry->next = NULL; newEntry->type = NDS_RENAME; @@ -1100,7 +1100,7 @@ STATUS OID_Startup(void) // secOneShot(&OID_BackgroundVerifyAlarm, OID_BACKGROUND_VERIFY_TIME, // OID_StartBackgroundVerify); return zOK; -} +} /**************************************************************************** * This function shuts down the object ID store @@ -1110,7 +1110,7 @@ void OID_Shutdown(void) OID_CacheUninit(); // CANCEL_ALARM(OID_BackgroundVerifyAlarm); return; -} +} /**************************************************************************** @@ -1129,7 +1129,7 @@ STATUS OID_AddEntryIfNotThere( STATUS status; int context; const unicode dotDelims[] = {DELIM_CFG_FALSE, DELIM_CFG_TRUE, - DELIM_DF_RDN, DELIM_DF_RDN, DELIM_DV, DELIM_VALUE, DELIM_WILD, + DELIM_DF_RDN, DELIM_DF_RDN, DELIM_DV, DELIM_VALUE, DELIM_WILD, DELIM_DF_ESCAPE, 0}; #endif struct @@ -1161,7 +1161,7 @@ STATUS OID_AddEntryIfNotThere( xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); ClearErrno(genMsg); - if (vol->VOLcomnVolOps.VOL_getObjectName(genMsg, vol, objectID, + if (vol->VOLcomnVolOps.VOL_getObjectName(genMsg, vol, objectID, alloc->uniName, NULL, NULL) != zOK) { if (GetErrno(genMsg) != zERR_FULL_NAME_NOT_FOUND) @@ -1333,7 +1333,7 @@ STATUS OID_AddEntryIfNotThere( #endif /* End of Linux/Netware specific versions */ /* Add the name to the user store */ - if (vol->VOLcomnVolOps.VOL_insertObjectName(genMsg, vol, xaction, + if (vol->VOLcomnVolOps.VOL_insertObjectName(genMsg, vol, xaction, objectID, alloc->namePtr) != zOK) { goto exit; @@ -1394,7 +1394,7 @@ void OID_SaveObjectID( */ if (vol->VOLstate != zVOLSTATE_ACTIVE) { - return; + return; } /* * Check the cache to see if we have already inserted this entry. If @@ -1417,7 +1417,7 @@ void OID_SaveObjectID( FSMLITE_INIT(&info->fsm, "FSM for adding an ID to the Object ID store", ++fsmInstance); - + info->volume = vol; info->objectID = *objectID; COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); @@ -1428,9 +1428,9 @@ void OID_SaveObjectID( free(info); return; } - WORK_Schedule((FsmLite_s *)info, (voidfunc_t)OID_AddEntryIfNotThereThread, (ADDR)NULL); + WORK_Schedule((FsmLite_s *)info, OID_AddEntryIfNotThereThread, NULL); return; -} +} /**************************************************************************** * This function gets the objects name from the object ID store. @@ -1447,7 +1447,7 @@ STATUS OID_GetObjectName( DBG_DebugPrintf(LMAGENTA, "Enter OID_GetObjectName: vol=%Ld objectID=%x\n", vol->VOLzid, objectID->timeLow); #endif - status = vol->VOLcomnVolOps.VOL_getObjectName(genMsg, vol, objectID, + status = vol->VOLcomnVolOps.VOL_getObjectName(genMsg, vol, objectID, name, NULL, NULL); if (status == zOK && name[0] == 0) @@ -1463,7 +1463,7 @@ STATUS OID_GetObjectName( } else { - DBG_DebugPrintf(LMAGENTA, "Exit OID_GetObjectName: Error=%d\n", + DBG_DebugPrintf(LMAGENTA, "Exit OID_GetObjectName: Error=%d\n", GetErrno(genMsg)); // zASSERT("Error in OID_GetObjectName" == NULL); } @@ -1517,10 +1517,10 @@ void OID_EnableObjectInfoThread( } /* - * Add a purge log entry to re-scan the tree in case we crash while + * Add a purge log entry to re-scan the tree in case we crash while * scanning. */ - SETUP_SCAN_USER_NAMES_LOG(&purgeLogInfo->purgeLogMsg, + SETUP_SCAN_USER_NAMES_LOG(&purgeLogInfo->purgeLogMsg, (void *)&purgeLogInfo->purgeLogLoc, vol); xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); status = vol->VOLcomnVolOps.VOL_addPurgeLogEntry(&genMsg, vol, @@ -1582,24 +1582,24 @@ void OID_EnableObjectInfoThread( if (COMN_IsDerivedFrom(beast, zFTYPE_POOL)) { - OID_AddEntryIfNotThere(&genMsg, vol, + OID_AddEntryIfNotThere(&genMsg, vol, &((Pool_s *)beast)->POOLndsObjectID); } if (COMN_IsDerivedFrom(beast, zFTYPE_VOLUME)) { - OID_AddEntryIfNotThere(&genMsg, vol, + OID_AddEntryIfNotThere(&genMsg, vol, &((Volume_s *)beast)->VOLndsObjectID); } /* Add the archiver, modifier, ... */ if (COMN_IsDerivedFrom(beast, zFTYPE_FILE)) { - OID_AddEntryIfNotThere(&genMsg, vol, + OID_AddEntryIfNotThere(&genMsg, vol, &((File_s *)beast)->FILEmodifierID); - OID_AddEntryIfNotThere(&genMsg, vol, + OID_AddEntryIfNotThere(&genMsg, vol, &((File_s *)beast)->FILEmetaDataModifierID); - OID_AddEntryIfNotThere(&genMsg, vol, + OID_AddEntryIfNotThere(&genMsg, vol, &((File_s *)beast)->FILEarchiverID); } @@ -1612,7 +1612,7 @@ void OID_EnableObjectInfoThread( /* Handle object IDs in the overflow beasts */ if (beast->beastClass->classID == zFTYPE_ZAS_ACL_OVERFLOW) { - for (entry=0; entry < + for (entry=0; entry < ((ZasAclOverflowBeast_s *)beast)->p.numEntries; entry++) { OID_AddEntryIfNotThere(&genMsg, vol, @@ -1622,7 +1622,7 @@ void OID_EnableObjectInfoThread( } if (beast->beastClass->classID == zFTYPE_ZAS_VIS_OVERFLOW) { - for (entry=0; entry < + for (entry=0; entry < ((ZasVisOverflowBeast_s *)beast)->p.numEntries; entry++) { OID_AddEntryIfNotThere(&genMsg, vol, @@ -1639,7 +1639,7 @@ exitFreeMem: exitPurgeLog: /* remove the purge log entry */ xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); - vol->VOLcomnVolOps.VOL_removePurgeLogEntry(&genMsg, vol, + vol->VOLcomnVolOps.VOL_removePurgeLogEntry(&genMsg, vol, PLOG_SCAN_USER_NAMES, &purgeLogInfo->purgeLogMsg, xaction); vol->VOLcomnVolOps.VOL_endXLocal(xaction); exitFreePurgeLogInfo: @@ -1696,7 +1696,7 @@ STATUS OID_InitObjectInfo( if ((status = COMN_LockVolumeActive(genMsg, vol, FALSE)) == zOK) { - WORK_Schedule(fsm, (voidfunc_t)OID_EnableObjectInfoThread, (ADDR)vol); + WORK_Schedule(fsm, OID_EnableObjectInfoThread, (ADDR)vol); } else { @@ -1734,10 +1734,10 @@ STATUS OID_ResetObjectInfo( } /* - * Add a purge log entry to re-scan the tree in case we crash while + * Add a purge log entry to re-scan the tree in case we crash while * scanning. */ - SETUP_REMOVE_USER_TREE_LOG(&purgeLogInfo->purgeLogMsg, + SETUP_REMOVE_USER_TREE_LOG(&purgeLogInfo->purgeLogMsg, (void *)&purgeLogInfo->purgeLogLoc, vol); xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); status = vol->VOLcomnVolOps.VOL_addPurgeLogEntry(genMsg, vol, @@ -1756,7 +1756,7 @@ STATUS OID_ResetObjectInfo( /* remove the purge log entry */ xaction = vol->VOLcomnVolOps.VOL_beginXLocal(vol, X_CF_DEFAULT); - vol->VOLcomnVolOps.VOL_removePurgeLogEntry(genMsg, vol, + vol->VOLcomnVolOps.VOL_removePurgeLogEntry(genMsg, vol, PLOG_REMOVE_USER_TREE, &purgeLogInfo->purgeLogMsg, xaction); vol->VOLcomnVolOps.VOL_endXLocal(xaction); exitFreePurgeLogInfo: @@ -1843,7 +1843,7 @@ void OID_InitObjectIDStoreByName( COMN_Release( &vol ); } return; -} +} // // This functionality has been moved to checker.c @@ -1880,7 +1880,7 @@ void OID_InitObjectIDStoreByName( // } *alloc = NULL; // // const unicode dotDelims[] = {DELIM_CFG_FALSE, DELIM_CFG_TRUE, -// DELIM_DF_RDN, DELIM_DF_RDN, DELIM_DV, DELIM_VALUE, DELIM_WILD, +// DELIM_DF_RDN, DELIM_DF_RDN, DELIM_DV, DELIM_VALUE, DELIM_WILD, // DELIM_DF_ESCAPE, 0}; // // COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); @@ -1975,7 +1975,7 @@ void OID_InitObjectIDStoreByName( // for (;;) // { // if (volume->VOLcomnVolOps.VOL_browseUsersInVolume(&genMsg, volume, -// MAX_USER_INFO_ENTRIES, &lastUserReturned, userInfo, +// MAX_USER_INFO_ENTRIES, &lastUserReturned, userInfo, // &numReturned, TRUE) != zOK) // { // zASSERT("Error browsing users in volume" == NULL); @@ -1993,7 +1993,7 @@ void OID_InitObjectIDStoreByName( //#ifdef OID_DEBUG // DBG_DebugPrintf(LCYAN, "BV - Checking user %x\n", userInfo[i].userID.timeLow); //#endif -// if (COMN_LocalMapNDSGUIDToID(&status, &userInfo[i].userID, +// if (COMN_LocalMapNDSGUIDToID(&status, &userInfo[i].userID, // &oldID, NULL, &addToCache) != zOK) // { // continue; @@ -2017,7 +2017,7 @@ void OID_InitObjectIDStoreByName( // /* // * Get entry info // */ -// ccode = (*DDCGetEntryInfoPtr)(context, DSI_ENTRY_DN, +// ccode = (*DDCGetEntryInfoPtr)(context, DSI_ENTRY_DN, // sizeof(*alloc), alloc); // if (ccode != 0) // { @@ -2035,7 +2035,7 @@ void OID_InitObjectIDStoreByName( //#endif // MPKNSS_LOCK(); // -// xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, +// xaction = volume->VOLcomnVolOps.VOL_beginXLocal(volume, // X_CF_DEFAULT); // status = volume->VOLcomnVolOps.VOL_insertObjectName(&genMsg, // volume, xaction, &userInfo[i].userID, alloc->namePtr); @@ -2088,7 +2088,7 @@ void OID_InitObjectIDStoreByName( // *** can use a continue BEFORE any blocking calls. // ***/ // OID_VerifyVolume(volume); -// SET_FOREACHBLOCKINGEND(&NSSMasterVolumeList, volume, Volume_s, +// SET_FOREACHBLOCKINGEND(&NSSMasterVolumeList, volume, Volume_s, // masterVolLink) // } // diff --git a/src/nwnss/comn/common/pssConnection.c b/src/nwnss/comn/common/pssConnection.c index d1b3dc8..68ddfb4 100644 --- a/src/nwnss/comn/common/pssConnection.c +++ b/src/nwnss/comn/common/pssConnection.c @@ -65,7 +65,7 @@ #include "comnAuthorize.h" #include "nssDebug.h" -/* For Linux, this is a quick place to store the sys connection pointer. +/* For Linux, this is a quick place to store the sys connection pointer. * We need to do this here, becaue the LSA stuff does not track the * sys connection. */ @@ -101,8 +101,8 @@ STATIC BOOL ConnectionsAreStarted = FALSE; *-------------------------------------------------------------------------*/ BOOL ConnDirCreated = FALSE; /* record all connection management files */ -DQhead_t RegConnMgmtFiles = DQ_STATIC_INIT(RegConnMgmtFiles); - +DQhead_t RegConnMgmtFiles = DQ_STATIC_INIT(RegConnMgmtFiles); + typedef struct ConnAVFileInst_s { BYTE *path; @@ -137,7 +137,7 @@ typedef struct ConnAVFileInst_s // { // return zFAILURE; // } -// if ((status & BEING_ABORTED) || +// if ((status & BEING_ABORTED) || // (status & LOGOUT_IN_PROGRESS)) // { // return zFAILURE; @@ -192,11 +192,11 @@ typedef struct ConnAVFileInst_s // memcpy(data, &lpData[1], lpData[0]); // data[lpData[0]] = '\0'; // strcpy(path, (char *)AVFileMgmtDir); -// sprintf(&path[AVFileMgmtDirLen], +// sprintf(&path[AVFileMgmtDirLen], // MSG("Connection\\%d\\Login Name.xml", 42), connNum); // if (type == 'x') // { -// status = XMLConvert(path, data, NSSSTRING, NULL, NULL, NONE, +// status = XMLConvert(path, data, NSSSTRING, NULL, NULL, NONE, // NULL, NULL, NULL, buffer, bufferLength); // } // else @@ -217,7 +217,7 @@ typedef struct ConnAVFileInst_s // } // // MPKNSS_UNLOCK(); -// return status; +// return status; //} // // @@ -251,7 +251,7 @@ typedef struct ConnAVFileInst_s // pssConn->totalBytesRead += pssConn->curBytesRead; // pssConn->curBytesRead = 0; // strcpy(path, (char *)AVFileMgmtDir); -// sprintf(&path[AVFileMgmtDirLen], +// sprintf(&path[AVFileMgmtDirLen], // MSG("Connection\\%d\\Bytes Read.xml", 43), connNum); // sprintf(data, MSGNot("%Lu\r\n"), pssConn->totalBytesRead); // if (type == 'x') @@ -268,7 +268,7 @@ typedef struct ConnAVFileInst_s // } // // MPKNSS_UNLOCK(); -// return status; +// return status; //} // // @@ -302,7 +302,7 @@ typedef struct ConnAVFileInst_s // pssConn->totalBytesWritten += pssConn->curBytesWritten; // pssConn->curBytesWritten = 0; // strcpy(path, (char *)AVFileMgmtDir); -// sprintf(&path[AVFileMgmtDirLen], +// sprintf(&path[AVFileMgmtDirLen], // MSG("Connection\\%d\\Bytes Written.xml", 250), connNum); // sprintf(data, MSGNot("%Lu\r\n"), pssConn->totalBytesWritten); // if (type == 'x') @@ -319,7 +319,7 @@ typedef struct ConnAVFileInst_s // } // // MPKNSS_UNLOCK(); -// return status; +// return status; //} // ///**************************************************************************** @@ -360,7 +360,7 @@ typedef struct ConnAVFileInst_s // } // // if (connNum >= 0) -// { +// { // unAddedConn = zalloc(sizeof(UnAddedCNCT_s)); // if (unAddedConn == NULL) // { @@ -394,10 +394,10 @@ typedef struct ConnAVFileInst_s // if (!ConnDirCreated) // { // initConnMgmtFile(); -// +// // strcpy(&pathStr[AVFileMgmtDirLen], MSG("Connection", 13)); // -// ZOS_zCreate(status, rootKey, zNO_TASK, 0, +// ZOS_zCreate(status, rootKey, zNO_TASK, 0, // zNSPACE_LONG | zMODE_UTF8, pathStr, zFILE_REGULAR, AVFILEDIRATTR, // zCREATE_OPEN_IF_THERE, zRR_WRITE_ACCESS, &retKey); // if (status != zOK) @@ -431,8 +431,8 @@ typedef struct ConnAVFileInst_s // createAttr = AVFILEFILEATTR; // } // -// ZOS_zCreate(status, rootKey, zNO_TASK, 0, -// zNSPACE_LONG | zMODE_UTF8, pathStr, zFILE_REGULAR, +// ZOS_zCreate(status, rootKey, zNO_TASK, 0, +// zNSPACE_LONG | zMODE_UTF8, pathStr, zFILE_REGULAR, // createAttr, 0, zRR_WRITE_ACCESS, &retKey); // if (status != zOK) // { @@ -449,7 +449,7 @@ typedef struct ConnAVFileInst_s // /* Write the transformation template to the file */ // sprintf(parm, "%ld", unAddedConn->connNum); // if (MGMT_MakeFunctionVirtualFileWithRawDataStream(&genMsg, -// retKey, ConnInst[i].functionName, parm, NULL, NULL) +// retKey, ConnInst[i].functionName, parm, NULL, NULL) // != zOK) // { // zASSERT("Error writing transformation template" == 0); @@ -471,7 +471,7 @@ typedef struct ConnAVFileInst_s // } // ZOS_zClose(status, rootKey); // zASSERT(status == zOK); -// return; +// return; // //errorFree: // free(unAddedConn); @@ -479,18 +479,18 @@ typedef struct ConnAVFileInst_s //errorClose: // ZOS_zClose(status, rootKey); // zASSERT(status == zOK); -// +// //errorExit: // return; //} // // ///****************************************************************************** -// * In order to avoid hangup during the shutdown, in this case we do checking -// * on the flag ComnMgmtFileSetup. We know if it set to FALSE, comn module -// * either haven't fully started up yet or are being shutdown. Under these two -// * situations, because we can't use commnon methods (i.e. COMN_XX) to get -// * beasts. +// * In order to avoid hangup during the shutdown, in this case we do checking +// * on the flag ComnMgmtFileSetup. We know if it set to FALSE, comn module +// * either haven't fully started up yet or are being shutdown. Under these two +// * situations, because we can't use commnon methods (i.e. COMN_XX) to get +// * beasts. // ******************************************************************************/ //void CNCT_removeMgmtFile( // NINT connNum) @@ -526,7 +526,7 @@ typedef struct ConnAVFileInst_s // DQ_FOREACH(&RegConnMgmtFiles, mgmtFile, AVFileLink_s, link) // { // if (stricmp(mgmtFile->path, pathStr) == 0) -// { +// { // DQ_RMV(mgmtFile,link); // findMgmtFile = TRUE; // break; @@ -653,7 +653,7 @@ STATUS COMN_GetAuthenticatedIDs( *retGUIDCount = numIDs; return (zOK); -} +} /**************************************************************************** * This function returns TRUE if the connection is supervisor equivalent @@ -662,7 +662,7 @@ STATUS COMN_GetAuthenticatedIDs( LONG IsSupervisor( LONG connectionID) { - if (connectionID == zSYS_CONNECTION) + if (connectionID == zSYS_CONNECTION) { return(TRUE); } @@ -670,7 +670,7 @@ LONG IsSupervisor( if (LinuxConnFuncs.GetLinuxIsSupervisor == NULL) { return(FALSE); - + } return(LinuxConnFuncs.GetLinuxIsSupervisor(connectionID)); } @@ -736,7 +736,7 @@ UserID_t COMN_GetUserID( return(zINVALID_USERID); } return (pssConn->authInfo.authenticatedIDs[0]); -} +} /************************************************************************** * This routine updates the NDS GUID authenticated IDs in the NSS connection @@ -792,7 +792,7 @@ STATUS COMN_UpdatePSSConnection( * this while running DSREPAIR on a large database, causing their users * to lose rights. * HOWEVER - if the error is ERR_NO_SUCH_ENTRY, then the eDir user has - * been deleted, and we will allow the code to replace the SEV with + * been deleted, and we will allow the code to replace the SEV with * an empty vector. */ if ((status != zOK) && (status != ERR_NO_SUCH_ENTRY)) @@ -806,7 +806,7 @@ STATUS COMN_UpdatePSSConnection( */ X_LATCH(&pssConn->authInfo.authListLatch); // DEBUG_PRINTF(TCONNECT, DBG_NOINDENT, (LGREEN, "Updating the connection list\n")); - if ((pssConn->authInfo.numOriginalIDs != numAuthIds) || + if ((pssConn->authInfo.numOriginalIDs != numAuthIds) || (pssConn->authInfo.authenticatedIDs == NULL)) { /* if the original connection structure has changed in size */ pssConn->authInfo.numOriginalIDs = numAuthIds; @@ -827,7 +827,7 @@ STATUS COMN_UpdatePSSConnection( errPrintf(WHERE, Module, 666, MSG("No memory to create an NSS connection entry.", 149)); UNX_LATCH(&pssConn->authInfo.authListLatch); - DEBUG_PRINTF(TCONNECT, DBG_NOINDENT, + DEBUG_PRINTF(TCONNECT, DBG_NOINDENT, (LGREEN, "Error exit from updating the connection list\n")); free(nwIDs); return zFAILURE; @@ -840,7 +840,7 @@ STATUS COMN_UpdatePSSConnection( { free(pssConn->authInfo.originalIDs); } - pssConn->authInfo.originalIDs = NULL; + pssConn->authInfo.originalIDs = NULL; } /* @@ -860,7 +860,7 @@ STATUS COMN_UpdatePSSConnection( { /* found the NetWare "anyone" ID */ foundAnyone = TRUE; } - pssConn->authInfo.authenticatedIDs[index] = nwIDs[index]; + pssConn->authInfo.authenticatedIDs[index] = nwIDs[index]; #if NSS_DEBUG IS_ENABLED if (!printedHeader) @@ -898,7 +898,7 @@ STATUS COMN_UpdatePSSConnection( #if NSS_DEBUG IS_ENABLED if (convertedID) { - DEBUG_PRINTF(TCONNECT, DBG_NOINDENT, + DEBUG_PRINTF(TCONNECT, DBG_NOINDENT, (MAGENTA, " %d. ID=added GUID=%08x-%04x-%04x-%02x-%02x-%02x%02x%02x%02x%02x%02x\n", index, pssConn->authInfo.authenticatedIDs[index].timeLow, @@ -916,7 +916,7 @@ STATUS COMN_UpdatePSSConnection( #endif } UNX_LATCH(&pssConn->authInfo.authListLatch); -// DEBUG_PRINTF(TCONNECT, DBG_NOINDENT, (LGREEN, "Exit from updating the connection list\n");) +// DEBUG_PRINTF(TCONNECT, DBG_NOINDENT, (LGREEN, "Exit from updating the connection list\n");) free(nwIDs); return returnStatus; @@ -973,7 +973,7 @@ STATUS COMN_CreatePSSConnection( INIT_ONESHOT(pssConn->macAlarm); pssConn->flags |= CNCTFL_NEED_NEW_MAC_VALUE; - DEBUG_PRINTF(TCONNECT, DBG_NOINDENT, + DEBUG_PRINTF(TCONNECT, DBG_NOINDENT, (YELLOW, "Creating NSS connection %d\n", connectionNumber)); COMN_UpdatePSSConnection(pssConn); @@ -1110,7 +1110,7 @@ void CNCT_CleanupAllPSSConnections() *----------------------------------------------------------------------------*/ while (DQ_NOT_EMPTY(&UnAddedConnectionList)) { - DQ_TAKE(&UnAddedConnectionList, unAddedConn, UnAddedCNCT_s, link); + DQ_TAKE(&UnAddedConnectionList, unAddedConn, UnAddedCNCT_s, link); if(unAddedConn) { free(unAddedConn); @@ -1243,7 +1243,7 @@ STATUS COMN_EndOfTaskCleanup( ASSERT_MPKNSS_LOCK(); - DEBUG_PRINTF(TCONNECT, DBG_NOINDENT, + DEBUG_PRINTF(TCONNECT, DBG_NOINDENT, (YELLOW, "Closing task on connection %d\n", genMsg->pssConn.id)); /* @@ -1265,7 +1265,7 @@ STATUS COMN_EndOfTaskCleanup( return zOK; } /* - * Cleanup the searchmaps + * Cleanup the searchmaps */ pssConn->connUseCount++; SMAP_CleanupAllSearchMapsOnTask(genMsg,pssConn,taskFlag); @@ -1318,7 +1318,7 @@ NSSConnection_s *COMN_DoResolveConnection( } else if ((LinuxConnFuncs.GetLinuxConnectionNSS == NULL) || (LinuxConnFuncs.GetLinuxConnectionNSS( - genMsg->pssConn.id, &pssConn) != 0)) + genMsg->pssConn.id, &pssConn) != 0)) { return NULL; } @@ -1332,7 +1332,7 @@ NSSConnection_s *COMN_DoResolveConnection( /*------------------------------------------------------------------------- * See if we have a NSS connection structure. The structure should be there * because of a connection allocation event. But, there are cases where a - * connection is established + * connection is established *-------------------------------------------------------------------------*/ zASSERT(pssConn != NULL); diff --git a/src/nwnss/comn/common/registerLSS.c b/src/nwnss/comn/common/registerLSS.c index 88c9ba0..f0afbfa 100644 --- a/src/nwnss/comn/common/registerLSS.c +++ b/src/nwnss/comn/common/registerLSS.c @@ -45,7 +45,7 @@ /* FixFixFix * FixFixFix - * FixFixFix - If and when LSS's are ever given their own objects in the + * FixFixFix - If and when LSS's are ever given their own objects in the * FixFixFix - Admin volume, this module should be removed, and this * FixFixFix - functionality should be replaced with an "LSS Info" function. * FixFixFix @@ -69,7 +69,7 @@ DQhead_t RegisteredLSSList = DQ_STATIC_INIT(RegisteredLSSList); /**************************************************************************** - * + * *****************************************************************************/ STATUS COMN_RegisterLSSFeatures( GeneralMsg_s *genMsg, @@ -135,7 +135,7 @@ void COMN_UnregisterLSSFeatures( } } return; -} +} /**************************************************************************** * This function returns the LSS feature information in a buffer. If there diff --git a/src/nwnss/comn/common/repair.c b/src/nwnss/comn/common/repair.c index a5d7fbf..33d73be 100644 --- a/src/nwnss/comn/common/repair.c +++ b/src/nwnss/comn/common/repair.c @@ -19,7 +19,7 @@ | |*************************************************************************** | - | NetWare Advance File Service + | NetWare Advance File Service | |--------------------------------------------------------------------------- | @@ -33,20 +33,15 @@ | This module is used to: | +-------------------------------------------------------------------------*/ -#if defined(NSS_USERSPACE) -#ifndef EXPORT_SYMBOL -#define EXPORT_SYMBOL(_fun) -#endif -#else #if zLINUX #define EXPORT_SYMTAB #include #else #define EXPORT_SYMBOL(_fun) #endif + #include #include -#endif #include "nssOSAPIs.h" #include /* NSS Library Includes*/ #include @@ -55,14 +50,6 @@ #include #include #include -#if defined(NSS_USERSPACE) -#undef ZOS_WakeUp -#undef ZOS_ScheduleWorkToDo -#undef ZOS_ScheduleFastWorkToDo -#undef ZOS_CancelWorkToDo -#undef ZOS_Sleep -#undef ZOS_YieldThread -#endif #include "schedule.h" #include "nssOSAPIs.h" #include @@ -92,29 +79,6 @@ #define NEB_STATUS int #endif -#if defined(NSS_USERSPACE) -/* nssOSAPIs.h intentionally exposes the original kernel/NLM ZOS macros. - * Keep repair.c on the userspace boundary: verify/repair worker threads and - * event consumers are represented, but not started through kernel symbols. */ -#undef ZOS_StartThread -#define ZOS_StartThread(_thread, _name, _func, _stack, _prio, _arg) \ - do { (void)(_name); (void)(_func); (void)(_stack); (void)(_prio); \ - (void)(_arg); (_thread) = 0; } while (0) - -#undef ZOS_StartThreadWithModuleHandle -#define ZOS_StartThreadWithModuleHandle(_thread, _name, _func, _stack, _prio, _arg, _module) \ - do { (void)(_module); \ - ZOS_StartThread((_thread), (_name), (_func), (_stack), (_prio), (_arg)); \ - } while (0) - -#undef ZOS_RegisterConsumer -#define ZOS_RegisterConsumer(_reg) do { (void)(_reg); } while (0) - -#undef ZOS_UnRegisterConsumer -#define ZOS_UnRegisterConsumer(_consumer, _event) \ - do { (void)(_consumer); (void)(_event); } while (0) -#endif - #undef WHERE #define WHERE "repair.c" "[" MAKE_STRING(__LINE__) "]" @@ -136,11 +100,11 @@ Latch_s VP_RepairProcessListLatch = STATIC_INIT_LATCH(VP_RepairProcessListLatch); /* Latch used to walk the VP_RepairProcessList list. Latch must only be owned * while walking list. - */ + */ DQhead_t VP_RepairProcessList = DQ_STATIC_INIT(VP_RepairProcessList); /* List of all current and saved VPV_Status_s items. These items track * the status of pool verify operations. Used by verify thread and XML - * interfaces, and CPS NEB event code. + * interfaces, and CPS NEB event code. */ Latch_s VP_RepairProcessListNoItem; /* Latched used to implement ZSH_FLAG_WAIT. We always have an X_LATCH on latch @@ -270,7 +234,7 @@ void VP_ThreadInfoDestroy( VP_Status_s *pInfo ) if ( tInfo->VPTI_ownershipKey != NULL ) { - (void)xPoolOwnershipRelease( tInfo->VPTI_ownershipKey, WHERE ); + (void)xPoolOwnershipRelease( tInfo->VPTI_ownershipKey, WHERE ); tInfo->VPTI_ownershipKey = NULL; } if ( tInfo->VPTI_poolVol != NULL ) @@ -413,7 +377,7 @@ void VP_PoolInfoDelete( VP_Status_s *pComn ) // Key used to uniquily identify different verify/rebuild statuses. We ensure - // that rebuild and verify keys to not match so that underlying code can + // that rebuild and verify keys to not match so that underlying code can // assume keys are unique. QUAD ZVP_StatusUserKey = UI64_CONST(0)-UI64_CONST(1); @@ -571,7 +535,7 @@ STATUS VP_ThreadInfoCreate( Pool_s *pool ) { VP_ThreadInfo_s *tInfo; - + tInfo = (VP_ThreadInfo_s *)zalloc(sizeof(VP_ThreadInfo_s)); if ( tInfo == NULL ) { @@ -785,10 +749,10 @@ STATUS VP_ThreadStart(VP_Status_s *pComn) // By using the CMN_ModuleHandle we take ownership of thread // so that NetWare will not ABEND if the user thread that started // this process terminates. - ZOS_StartThreadWithModuleHandle( tInfo->VPTI_processID, CheckModName, VP_PoolRAVThread, + ZOS_StartThreadWithModuleHandle( tInfo->VPTI_processID, CheckModName, VP_PoolRAVThread, NULL, CHECK_STACKSIZE, pComn, (LONG)CMN_ModuleHandle ); #else - ZOS_StartThread( tInfo->VPTI_processID, CheckModName, VP_PoolRAVThread, + ZOS_StartThread( tInfo->VPTI_processID, CheckModName, VP_PoolRAVThread, NULL, CHECK_STACKSIZE, pComn ); #endif if ( tInfo->VPTI_processID == 0 ) @@ -874,12 +838,12 @@ LONG ChangeStateEnterCallBack(struct EventBlock *evBlk) } else { - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return(SUCCESS); } if ( newState == oldState ) { /* Ignore switches to current state */ - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return(SUCCESS); } if ( newState == zVOLSTATE_MAINTENANCE ) @@ -901,8 +865,8 @@ ZCCBCheckPoolForLiveProcesses: // VP_PoolInfoGet( pComn ); if ( (pComn->VPS_threadInfo) && ( LB_GUIDCompare( &pComn->VPS_poolVolID, objectID ) == 0 ) ) - { - if ( mode & VOLMODE_USER_ABORTABLE ) + { + if ( mode & VOLMODE_USER_ABORTABLE ) { /* We are allowed to abort request so we do. We do not use * zERR_VOLUME_STATE_CHANGE_ABORTED because it is handled special by * NSS's Change Pool State. It causes no error to be displayed to the user. @@ -916,7 +880,7 @@ ZCCBCheckPoolForLiveProcesses: } // notify the process to clean up and die pComn->VPS_Terminate = TRUE; - count++; + count++; } // VP_PoolInfoRelease( pComn ); } @@ -980,7 +944,7 @@ LONG ZCheckerXESR(struct EventBlock *evBlk) +-------------------------------------------------------------------------*/ void REPAIR_Startup() { -//#ifndef __linux__ // LINUX_Rebuild +//#ifndef __linux__ // LINUX_Rebuild struct ConsumerRegistrationInfo consumerRegInfo; ASSERT_MPKNSS_LOCK(); @@ -1147,15 +1111,15 @@ STATUS CPUnInitGlobals() -/* -------------------------------------------------------------------------- - StartUpList +/* -------------------------------------------------------------------------- + StartUpList This routine is called either by CPStartUpList() or RPStartUpList() in either case the routine is required to exit by killing the process. -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- getNextNameFromCmdLineString in - namePtr -> unicode string containing names seperated by commas name -> place to copy the next name from input string @@ -1201,7 +1165,7 @@ STATUS getNextNameFromCmdLineString(unicode_t *name, NINT size, unicode_t **nam } //terminate name, skip to next name in string - *name = 0; + *name = 0; while(c == L' ' || c == L',') { ++*namePtr; @@ -1535,7 +1499,7 @@ again: } UNX_LATCH( &VP_RepairProcessListLatch ); if ( (zVS->ZSH_Flag & ZSH_FLAG_WAIT) && (zVS->ZSH_SearchKey == 0) && - (status == zOK) && (zVS->ZSH_ResultsReturned == 0) ) + (status == zOK) && (zVS->ZSH_ResultsReturned == 0) ) { goto again; } @@ -1567,7 +1531,7 @@ again: } UNX_LATCH( &VP_RepairProcessListLatch ); if ( (zVS->ZSH_Flag & ZSH_FLAG_WAIT) && (zVS->ZSH_SearchKey == 0) && - (status == zOK) && (zVS->ZSH_ResultsReturned == 0) ) + (status == zOK) && (zVS->ZSH_ResultsReturned == 0) ) { goto again; } @@ -1678,8 +1642,8 @@ STATUS VP_PoolAction3( unsigned int bufSize, ZVP_StatusHeader_s *zVS ) /* - zPoolVerify() - - Used by XML interface to actually do work. + zPoolVerify() - + Used by XML interface to actually do work. */ STATUS zPoolVerify( int action, unsigned int bufSize, void *buffer ) @@ -1725,7 +1689,7 @@ HERE_WE_ARE(); } case zPOOL_RAV_VERSION_INFORMATION: { - + status = VP_PA_RAVVersionInformation( bufSize, buffer ); return status; } @@ -2103,7 +2067,7 @@ STATUS VP_PoolVerifyStart( } /* End of VP_PoolVerifyStart() */ -STATUS VP_PoolAction( +STATUS VP_PoolAction( GeneralMsg_s *genMsg, const unicode_t *poolName, Pool_s *pool, @@ -2653,3 +2617,5 @@ STATUS COMN_ReverseNameLookup2( return status; } /* End of COMN_ReverseNameLookup2() */ + + diff --git a/src/nwnss/comn/common/restartCount.c b/src/nwnss/comn/common/restartCount.c new file mode 100644 index 0000000..ea67097 --- /dev/null +++ b/src/nwnss/comn/common/restartCount.c @@ -0,0 +1,51 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This is a COMMON layer routine used to manage the Restart Count + | + | + +-------------------------------------------------------------------------*/ +#include + + /* May 15, 1998 + * + * The AUTH system has been changed to only require a unique + * restart count per volume. This allowed us to add an activation + * count to the Volume_s and thus remove the Global RestartCount. + * This was done mainly because it was not easy or scalable to + * write out the RestartCount to ALL active volumes. + * + * Greg Pachner + */ + diff --git a/src/nwnss/comn/common/rootBeast.c b/src/nwnss/comn/common/rootBeast.c new file mode 100644 index 0000000..294e1d1 --- /dev/null +++ b/src/nwnss/comn/common/rootBeast.c @@ -0,0 +1,2029 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $ + | + | $RCSfile$ + | $Revision: 1325 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This defines all of the primitive BEASTS inside of PSS + +-------------------------------------------------------------------------*/ +#include + +#include /* NSS Library includes */ +#include +#include +#include +#include + +#include "comnBeasts.h" +#include "msgGen.h" +#include "msgName.h" +//#include "beastStartup.h" +#include "comnBeastClass.h" +#include "zParams.h" +#include "comnParams.h" +#include "nameSpace.h" +#include "searchMap.h" +#include "volume.h" +//#include "zfs.h" +//#include "memPool.h" +#include "msgIO.h" +#include "fullDirectoryInfo.h" +#include "comnVariableData.h" +#include "comnPublics.h" +#include "fileHandle.h" +#include "objectIDStore.h" +#include "csa.h" +#include "csaLease.h" +#include "guid.h" +#include "xmlTags.h" +#include "nssPubs.h" +#include "manage.h" +#include "mgmt.h" + +/*=========================================================================== + *=========================================================================== + * + * COMMON BEAST OPERATIONS + * + *=========================================================================== + *===========================================================================*/ + +/**************************************************************************** + * Root constructore for the object + *****************************************************************************/ +STATUS ROOT_BST_Construct( + GeneralMsg_s *genMsg, + RootBeast_s *beast) +{ + Volume_s *vol = beast->ROOTvolume; + + beast->beastVersion = vol->VOLroot.beastVersion; + + beast->ownerID = COMN_GetUserID(genMsg); + +// The following is commented out because COMN_Create will save the ID for +// files, and non-files are not as important. We run into race conditions +// when setting it here. +// /* FixFixFix -- COMN layer should not be using zFTYPE_ZLSS_USER_TREE */ +// /* FixFixFix -- we may want to do this only when creating new files/datastreams +// * /overflowbeasts ... (So it doesn't slow down open +// */ +// if (beast->beastClass->classID != zFTYPE_ZLSS_USER_TREE) +// { +// OID_SaveObjectID(vol, &beast->ownerID); +// } + beast->blkSizeShift = vol->VOLblockShift; + initMyCache( &beast->ROOTmycache, BST_signalHandler, vol->VOLblockShift, + MSGNot("MyCache")); + + if (beast->ROOTcomnVolOps.VOL_allocStorageInfo(genMsg,beast) != zOK) + { + return zFAILURE; + } + +/** The next two lines are done in BEASTHASH_Insert, once we know we are + going to beast around. **/ +// beast->lastTimeNotInUse = GetUTCTime(); +// DQ_PUSH(&vol->beastList,beast,volLink); + return zOK; +} + + +/**************************************************************************** + * Destruct all the links to this beast in beast hash tables + *****************************************************************************/ +void ROOT_BST_Destruct( + RootBeast_s *beast) +{ + if (beast->ROOTvariableData) + { + COMN_FreeRootVariableData( beast ); + } + zASSERT(beast->ROOTvariableData == NULL); + + //zASSERT(CIR_EMPTY(beast->ROOTbeastLatch.waiting)); + ASSERT_NOLATCH( &beast->ROOTbeastLatch); + + BST_UNLINK_FROM_ALL_LISTS(beast); + + //zASSERT(!QMEMBER(&beast->ROOTmycache.agent.timer.link)); + CANCEL_ALARM(beast->ROOTmycache.agent.timer); +#if NSS_DEBUG IS_ENABLED + checkMyCache( &beast->ROOTmycache); +#endif + if ( beast->csaBeast ) + { + CSA_CSABeastRelease( &beast->csaBeast ); + } + beast->ROOTcomnVolOps.VOL_freeStorageInfo(beast); +} + + + +/*=========================================================================== + *=========================================================================== + *=========================================================================== + * BEAST OPERATIONS + *=========================================================================== + *=========================================================================== + *===========================================================================*/ + +/*=========================================================================== + * BEAST Container OPERATIONS + *===========================================================================*/ + +/**************************************************************************** + * Given a beast, allocate a new nameUniquifier to use for a new parent link + *****************************************************************************/ +// cnt STATIC NINT ROOT_BST_GetNameUniquifier( +// cnt GeneralMsg_s *genMsg, +// cnt NamedBeast_s *beast) +// cnt { +// cnt /* Forward the request to the volume */ +// cnt return(beast->NAMEDcomnVolOps.VOL_getNameUniquifier( +// cnt genMsg, beast)); +// cnt } + +/**************************************************************************** + * Setup nameTypeSpecificInfo for the beast + *****************************************************************************/ +STATIC STATUS ROOT_BST_SetupNameTypeSpecificInfo( + GeneralMsg_s *genMsg, + NamedBeast_s *beast, + struct ParentEntry_s *pentry, + NINT newNameType, + NINT action) +{ + /* Forward the request to the volume */ + return(beast->NAMEDcomnVolOps.VOL_setupNameTypeSpecificInfo( + genMsg, beast,pentry,newNameType,action)); +} + +/**************************************************************************** + * Given a unicode name, locate a beast in that container, this increments + * the use count by 1 + *****************************************************************************/ +STATIC Zid_t ROOT_BST_LookupByNameInDirectory( + GeneralMsg_s *genMsg, + NamedBeast_s *container, + NameSpace_s *nameSpace, + NINT nameType, + unicode_t *name, +// cnt NINT nameUniquifier, +// cnt NINT *retNameUniquifier, + struct FullDirectoryInfo_s *retInfo) +{ + /* Forward the request to the volume */ + return(container->NAMEDcomnVolOps.VOL_lookupByNameInDirectory( + genMsg, container, nameSpace, nameType, name, /* cnt nameUniquifier, + retNameUniquifier,*/ retInfo)); +} + +/**************************************************************************** + * is the given directory empty + *****************************************************************************/ +STATIC BOOL ROOT_BST_IsDirectoryEmpty( + GeneralMsg_s *genMsg, + NamedBeast_s *container, + NINT nameType) +{ + /* Forward the request to the volume */ + return(container->NAMEDcomnVolOps.VOL_isDirectoryEmpty( + genMsg, container, nameType)); +} + +/**************************************************************************** + * This adds a contained name to a directory beast. This is not the name + * of the directory beast itself, it is the name of a beast contained + * in the directory. + *****************************************************************************/ +STATIC STATUS ROOT_BST_AddNameToDirectory( + GeneralMsg_s *genMsg, + NamedBeast_s *beast, + NamedBeast_s *container, + NINT nameSpaceMask, + NINT nameType, + unicode_t *name, + NINT nsFlags, +// cnt NINT nameUniquifier, + NINT addNameFlags, + NINT matchAttributes, + Xaction_s *xaction, + TypeSpecificPersistentParentEntry_s *nameTypeInfo) +{ + /* Forward the request to the volume */ + return(container->NAMEDcomnVolOps.VOL_addNameToDirectory( + genMsg, beast, container, nameSpaceMask, nameType, name, + nsFlags, /* cnt nameUniquifier,*/ addNameFlags, matchAttributes, + xaction, nameTypeInfo)); +} + +/**************************************************************************** + * This removes a contained name from a directory beast. This is not the name + * of the directory beast itself, it is the name of a beast contained + * in the directory. + *****************************************************************************/ +STATIC STATUS ROOT_BST_RemoveNameFromDirectory( + GeneralMsg_s *genMsg, + Zid_t beastZid, + NamedBeast_s *container, + NINT nameSpaceMask, + NINT nameType, + unicode_t *name, +// cnt NINT nameUniquifier, + NINT removeNameFlags, + Xaction_s *xaction, + TypeSpecificPersistentParentEntry_s *nameTypeInfo) +{ + /* Forward the request to the volume */ + return(container->NAMEDcomnVolOps.VOL_removeNameFromDirectory( + genMsg, beastZid, container, nameSpaceMask, nameType, + name, /* cnt nameUniquifier,*/ removeNameFlags, xaction, nameTypeInfo)); +} + +/**************************************************************************** + * This locates the curName and curNameSpaceMask in the directory, via + * an exact binary match. Then it replaces the nameSpacemask with + * the newNameSpacemask. NOTE--This function does not validate the + * new nameSpacemask, it blindly obeys. All validity checking must + * be done by the caller previous to calling this function. ALSO, + * this function may not be used to set the nameSpaceMask to 0. + *****************************************************************************/ +STATIC STATUS ROOT_BST_ModifyNameSpaceMaskInDirectory( + GeneralMsg_s *genMsg, + NamedBeast_s *beast, + NamedBeast_s *container, + NINT curNameSpaceMask, + NINT nameType, + unicode_t *curName, +// cnt NINT nameUniquifier, + NINT newNameSpaceMask, + Xaction_s *xaction) +{ + /* Forward the request to the volume */ + return(container->NAMEDcomnVolOps.VOL_modifyNameSpaceMaskInDirectory( + genMsg, beast, container, curNameSpaceMask, nameType, + curName, /* cnt nameUniquifier,*/ newNameSpaceMask, xaction)); +} + +/**************************************************************************** + * This locates the name and nameSpaceMask in the directory, via + * an exact binary match. Then it sets the new matchAttributes for + * that name entry. + * This function is an optional LSS Function. If an LSS does not support + * storing matchAttributes in the directory, it may supply a NULL + * pointer for this function. + *****************************************************************************/ +STATIC STATUS ROOT_BST_setMatchAttributesInDirectory( + GeneralMsg_s *genMsg, + NamedBeast_s *beast, /* beast we are updating*/ + NamedBeast_s *container, /* directory we are updating in*/ + NINT nameSpaceMask, + NINT nameType, + unicode_t *name, +// cnt NINT nameUniquifier, /* Caller passes zFNU_UNDEFINED if not known */ + NINT newMatchAttributes, + Xaction_s *xaction) /* Optional xaction, may be NULL */ +{ + /* Forward the request to the volume */ + return(container->NAMEDcomnVolOps.VOL_setMatchAttributesInDirectory( + genMsg, beast, container, nameSpaceMask, nameType, + name, /* cnt nameUniquifier,*/ newMatchAttributes, xaction)); +} + +/**************************************************************************** + * this is called to locate a name in a directory via wildcarding + *****************************************************************************/ +STATIC Zid_t ROOT_BST_WildcardLookup( + GeneralMsg_s *genMsg, + NamedBeast_s *container, + NameSpace_s *nameSpace, + NINT nameType, + unicode_t *pattern, + SearchMap_s *smap, +// cnt NINT *retNameUniquifier, + FullDirectoryInfo_s *retInfo) +{ + /* Forward the request to the volume */ + return(container->NAMEDcomnVolOps.VOL_wildcardLookup( + genMsg, container, nameSpace, nameType, pattern, + smap, /* cnt retNameUniquifier,*/ retInfo)); +} + + + +/*=========================================================================== + * BEAST Block OPERATIONS + *===========================================================================*/ + +/**************************************************************************** + * allocate a range of ZIDs from a volume, return parameter is count of + * how many we got + *****************************************************************************/ +STATIC STATUS ROOT_BST_TruncateFile( + struct GeneralMsg_s *genMsg, + RootBeast_s *beast, + Blknum_t blockNum, + Blkcnt_t count) +{ + /* Forward the request to the volume */ + return(beast->ROOTcomnVolOps.VOL_truncateFile( + genMsg, beast, blockNum, count)); +} + +/**************************************************************************** + * This is the default handler to get the generic Storage Info. + *****************************************************************************/ +STATIC STATUS ROOT_BST_GetStorageInfo( + GeneralMsg_s *genMsg, + RootBeast_s *beast, + GetStorageInfo_s *getStorageInfo) +{ + /* Forward the request to the volume */ + return(beast->ROOTcomnVolOps.VOL_getStorageInfo( + genMsg, beast,getStorageInfo)); +} + +/**************************************************************************** + * This will return a map of the poolBlk blocks being used by the beast. + * This is designed so it can be called multiple times to get the full + * map. + *****************************************************************************/ +STATIC STATUS ROOT_BST_GetExtentList( + GeneralMsg_s *genMsg, + RootBeast_s *beast, + Blknum_t startingBlock, + NINT extentListSize, + Blknum_t (*extentList)[], + NINT *retNumExtents, + Blknum_t *retNextBlock) +{ + /* Forward the request to the volume */ + return(beast->ROOTcomnVolOps.VOL_getExtentList( + genMsg, beast, startingBlock, extentListSize, + extentList, retNumExtents, retNextBlock)); +} + +/**************************************************************************** + * This will return map a logical offset in the beast to a physical extent + * being used by the beast. + *****************************************************************************/ +STATIC STATUS ROOT_BST_GetPhysicalExtent( + struct zNSSMsg_s *msg, + RootBeast_s *beast) +{ + /* Forward the request to the volume */ + return beast->ROOTcomnVolOps.VOL_getPhysicalExtent(msg, beast); +} + +/**************************************************************************** + * This returns TRUE if the the given block is poolBlky allocated in + * the given beast. It returns FALSE if the block is not poolBlkly + * allocated to the beast + *****************************************************************************/ +STATIC BOOL ROOT_BST_IsBlockInBeast( + RootBeast_s *beast, + Blknum_t blockNum) +{ + /* Forward the request to the volume */ + return(beast->ROOTcomnVolOps.VOL_isBlockInBeast(beast,blockNum)); +} + + + +/*=========================================================================== + * BEAST I/O OPERATIONS + *===========================================================================*/ + +/**************************************************************************** + * This read a fileBlk block into memory, this is only called if the block + * is not already in cache + *****************************************************************************/ +STATIC void ROOT_BST_AsyncReadFileBlk( + Asyncio_s *asyncio) +{ + RootBeast_s *beast; + + beast = STRUCT(asyncio->mycache,RootBeast_s,ROOTmycache); + /* Forward the request to the volume */ + beast->ROOTcomnVolOps.VOL_asyncReadFileBlk(asyncio); +} + +/**************************************************************************** + * This read a fileBlk block into memory, this is only called if the block + * is not already in cache + *****************************************************************************/ +STATIC Buffer_s *ROOT_BST_GetFileBlk( + GeneralMsg_s *genMsg, + IoMsg_s *iomsg) +{ + /* Forward the request to the volume */ + return(iomsg->beast->ROOTcomnVolOps.VOL_getFileBlk(genMsg,iomsg)); +} + +/**************************************************************************** + * Direct read file + *****************************************************************************/ +STATIC STATUS ROOT_BST_DioReadUnits( + zNSSMsg_s *msg, + RootBeast_s *beast) +{ + /* Forward the request to the volume */ + return beast->ROOTcomnVolOps.VOL_dioReadUnits(msg, beast); +} + +/**************************************************************************** + * Direct write file + *****************************************************************************/ +STATIC STATUS ROOT_BST_DioWriteUnits( + zNSSMsg_s *msg, + RootBeast_s *beast) +{ + /* Forward the request to the volume */ + return beast->ROOTcomnVolOps.VOL_dioWriteUnits(msg, beast); +} + + + +/*=========================================================================== + * BEAST I/O OPERATIONS + *===========================================================================*/ + +/**************************************************************************** + * get a ZID from the directory + *****************************************************************************/ +STATIC Zid_t ROOT_BST_GetZID( + GeneralMsg_s *genMsg, + void *directory, + Xaction_s *xaction) +{ + zASSERT(0); + return zINVALID_ZID; +} + +/**************************************************************************** + * This is called to see if the given file can be opened + *****************************************************************************/ +STATIC STATUS ROOT_BST_BeastNotify( + GeneralMsg_s *genMsg, + RootBeast_s *dirBeast, + NINT notifyID) +{ +// zASSERT(0); +// SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); +// return zFAILURE; + return zOK; +} +/**************************************************************************** + * this returns information about the beast + *****************************************************************************/ +STATIC STATUS ROOT_BST_GetInfo( + GeneralMsg_s *genMsg, + RootBeast_s *beast, + struct GetInfoMsg_s *info) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * this returns information about the beast in XML string format + *****************************************************************************/ +STATIC STATUS ROOT_BST_GetInfoXML( + GeneralMsg_s *genMsg, + RootBeast_s *beast, + NINT typeOfInfo, + NINT bufLen, + utf8_t *buf, + NINT *infoLen) +{ + STATUS status = zOK; + NINT len = 0; + NINT tmpLen; + GetStorageInfo_s getStorageInfo; + typedef struct Stack_s{ + utf8_t tmpBuf[4096]; + unicode_t uniVolName[64]; + utf8_t volumeIDBuf[128]; + } Stack_s; + Stack_s *aStack; + + if (!(typeOfInfo & BST_INFO_ROOT)) + { + return zOK; + } + + STACK_ALLOC_NO_ASTACK(); + + bufLen -= *infoLen; + + strcpy(&aStack->tmpBuf[len], "<"TAG_ROOTBEASTINFO">"); + len += strlen(&aStack->tmpBuf[len]); + + sprintf(&aStack->tmpBuf[len], "<"TAG_ZID">%Lu" + "<"TAG_EOF">%Lu", + beast->zid, beast->eof); + len += strlen(&aStack->tmpBuf[len]); + + if ((status = MNSS_FillInAnID(TAG_OWNERID, &beast->ownerID, bufLen - len, + &aStack->tmpBuf[len], &tmpLen)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + len += tmpLen; + + // fixfixfix may need to return beast state, classID in string format + sprintf(&aStack->tmpBuf[len], "<"TAG_METADATASEQNUM">%u" + "<"TAG_BLOCKSIZESHIFT">%d" + "<"TAG_BEASTVERSION">%d" + "<"TAG_BEASTSTATE">%d" + "<"TAG_BEASTCLASS">" + "<"TAG_CLASSID">%d" + "<"TAG_DERIVEDFROMCLASSID">%d" + "<"TAG_BEASTSIZE">%u" + "<"TAG_BEASTCOUNT">%u" + "" + "<"TAG_USECOUNT">%u", + beast->metaDataSeqNum, beast->blkSizeShift, + beast->beastVersion, beast->bstState, + beast->beastClass->classID, + beast->beastClass->derivedFrom->classID, + beast->beastClass->beastSize, + beast->beastClass->beastCount, + beast->useCount); + len += strlen(&aStack->tmpBuf[len]); + + if (beast->fileSnapshotBeast != NULL) + { + sprintf(&aStack->tmpBuf[len], "<"TAG_FILESNAPSHOTBEASTZID">%Lu", + beast->fileSnapshotBeast->zid); + len += strlen(&aStack->tmpBuf[len]); + } + + status = COMN_GetVolumeName(genMsg, beast->vol.volume, aStack->uniVolName, sizeof(aStack->uniVolName)); + if (status != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + + (void)LB_GUIDToString( &beast->ROOTvolume->VOLvolumeID, + sizeof(aStack->volumeIDBuf), aStack->volumeIDBuf); + + /* fill in volume info */ + sprintf(&aStack->tmpBuf[len], "<"TAG_VOLUME">" + "<"TAG_VOLUMEID">%s" + "<"TAG_VOLUMENAME">" + "", + aStack->volumeIDBuf, + aStack->uniVolName); + len += strlen(&aStack->tmpBuf[len]); + + /* fill in storage info */ + if (beast->ROOTcomnOps.BST_getStorageInfo(genMsg, beast, &getStorageInfo) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + + /* fill in volume info */ + sprintf(&aStack->tmpBuf[len], "<"TAG_STORAGEINFO">" + "<"TAG_PHYSICALEOF">%Lu" + "<"TAG_FILEPHYSSIZE">%Lu" + "<"TAG_METADATAPHYSSIZE">%Lu" + "", + getStorageInfo.physicalEOF, + getStorageInfo.filePhysSize, + getStorageInfo.metaDataPhysSize); + len += strlen(&aStack->tmpBuf[len]); + + /* fill in myCache info */ + sprintf(&aStack->tmpBuf[len], "<"TAG_MYCACHE">" + "<"TAG_LATCH"><"TAG_COUNT">%u" + "", + beast->mycache.agent.latch.count); + len += strlen(&aStack->tmpBuf[len]); + + if (beast->csaBeast != NULL) + { + sprintf(&aStack->tmpBuf[len], "<"TAG_CSABEASTZID">%Lu", + beast->csaBeast->CB_zid); + len += strlen(&aStack->tmpBuf[len]); + } + + if ((status = MNSS_FillUTCTime(TAG_LASTTIMENOTINUSE, beast->lastTimeNotInUse, bufLen - len, + &aStack->tmpBuf[len], &tmpLen)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto exit; + } + len += tmpLen; + + /* fill in variable data */ + if (beast->variableData != NULL) + { + NINT rvdLen = 0; + + strcpy(&aStack->tmpBuf[len], "<"TAG_VARIABLEDATA">"); + len += strlen(&aStack->tmpBuf[len]); + + status = COMN_GetRootVariableDataXMLInfo(genMsg, beast, bufLen - len, + &aStack->tmpBuf[len], &rvdLen); + if (status != zOK) + { + goto exit; + } + len += rvdLen; + + strcpy(&aStack->tmpBuf[len], ""), + len += strlen(&aStack->tmpBuf[len]); + } + + sprintf(&aStack->tmpBuf[len], "\n"); + len += strlen(&aStack->tmpBuf[len]); + + if ((len + 1)> bufLen) + { + SetErrno(genMsg, zERR_BUFFER_TOO_SMALL); + status = zFAILURE; + } + else + { + strcpy(&buf[*infoLen], aStack->tmpBuf); + *infoLen += len; + } + +exit: + STACK_FREE(); + + return status; +} + +/**************************************************************************** + * this modifies information about the beast + *****************************************************************************/ +STATIC STATUS ROOT_BST_ModifyInfo( + GeneralMsg_s *genMsg, + RootBeast_s *beast, + struct ModifyInfoMsg_s *modifyInfo, + Xaction_s *xaction) /* Optional xaction, may be NULL */ +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + + +/**************************************************************************** + * this modifies information about the beast (info is passed through xml string) + *****************************************************************************/ +/** + * Ying - March 4, 2004 + * NOTE: This function is provided for convinence, although I did my best + * to ensure its correctness, it's not fully tested + */ +STATIC STATUS ROOT_BST_ModifyInfoXML( + GeneralMsg_s *genMsg, + RootBeast_s *beast, + NINT bufLen, + utf8_t *buf, + Xaction_s *xaction, + BOOL doChange) +{ + STATUS status = zOK; + XML_ElementInfo_s elementInfo; + utf8_t *copyBuf = NULL; + + const TagRequest_s tags[] = + { + {TAG_EOF, TR_OPTIONAL}, + {TAG_OWNERID, TR_OPTIONAL}, + {TAG_METADATASEQNUM, TR_OPTIONAL}, + {TAG_USECOUNT, TR_OPTIONAL}, + {TAG_MYCACHE, TR_OPTIONAL}, + {TAG_VARIABLEDATA, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags) - 1]; + + enum + { + FILE_EOF = 0, + OWNER_ID = 1, + METADATA_SEQ_NUM = 2, + USE_COUNT = 3, + MY_CACHE = 4, + VARIABLE_DATA = 5 + }; + + /* make another copy of buf, buf will be changed + * while doing MNSS_GetTagContents + */ + copyBuf = malloc(bufLen); + if (copyBuf == NULL) + { + SetErrno(genMsg, zERR_NO_MEMORY); + return zFAILURE; + } + memcpy(copyBuf, buf, bufLen); + + if (XML_GetTagElement(TAG_ROOTBEASTINFO, copyBuf, copyBuf + bufLen - 1, + &elementInfo) == zFAILURE) + { + // No rootBeast related info needs to be modified + goto Exit; + } + + if (elementInfo.dataStart == NULL) + { + // no actual data + goto Exit; + } + + if ((status = MNSS_GetTagContents(NULL, NULL, &elementInfo, tags, tagContent)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto Exit; + } + + if (tagContent[FILE_EOF].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, QUAD, FALSE, (ADDR)&beast->eof, + &tagContent[FILE_EOF].element); + } + + if (tagContent[OWNER_ID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if ((status = modifyIDXML(genMsg,beast, &tagContent[OWNER_ID].element, + (ADDR)&beast->ownerID, xaction, doChange)) != zOK) + { + goto Exit; + } + } + + if (tagContent[METADATA_SEQ_NUM].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, LONG, FALSE, (ADDR)&beast->metaDataSeqNum, + &tagContent[METADATA_SEQ_NUM].element); + } + + if (tagContent[USE_COUNT].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, beast, NINT, FALSE, (ADDR)&beast->useCount, + &tagContent[USE_COUNT].element); + } + + if (tagContent[MY_CACHE].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + XML_ElementInfo_s elementLatch; + + if (XML_GetTagElement(TAG_LATCH, tagContent[MY_CACHE].element.dataStart, + tagContent[MY_CACHE].element.dataEnd, &elementLatch) != zFAILURE + && elementLatch.dataStart != NULL) + { + XML_ElementInfo_s elementCount; + + if (XML_GetTagElement(TAG_COUNT, elementLatch.dataStart, + elementLatch.dataEnd, &elementCount) != zFAILURE + && elementCount.dataStart != NULL) + { + modifyInfoNumber(genMsg, beast, SNINT, TRUE, (ADDR)&beast->ROOTbeastLatch.count, &elementCount); + } + + } + } + + if (tagContent[VARIABLE_DATA].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + status = COMN_SetRootVariableDataXMLInfo(genMsg, beast, + tagContent[VARIABLE_DATA].element.dataLen, + tagContent[VARIABLE_DATA].element.dataStart, + xaction, + doChange); + if (status != zOK) + { + goto Exit; + } + } + + status = zOK; + +Exit: + free(copyBuf); + + return status; +} + +/*=========================================================================== + *=========================================================================== + *=========================================================================== + * VOLUME OPERATIONS + *=========================================================================== + *=========================================================================== + *===========================================================================*/ + +/*=========================================================================== + * VOLUME Container OPERATIONS + *===========================================================================*/ + +/**************************************************************************** + * Given a beast, allocate a new nameUniquifier to use for a new parent link + *****************************************************************************/ +// cnt STATIC NINT ROOT_VOL_GetNameUniquifier( +// cnt GeneralMsg_s *genMsg, +// cnt void *beast) +// cnt { +// cnt zASSERT(0); +// cnt SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); +// cnt return(zFNU_INVALID_NAME_UNIQUIFIER); +// cnt return 0; +// cnt } + +/**************************************************************************** + * Setup nameTypeSpecificInfo for the beast + *****************************************************************************/ +STATIC STATUS ROOT_VOL_SetupNameTypeSpecificInfo( + GeneralMsg_s *genMsg, + void *beast, + struct ParentEntry_s *pentry, + NINT newNameType, + NINT action) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; + +} + +/**************************************************************************** + * Given a unicode name, locate a beast in that container, this increments + * the use count by 1 + *****************************************************************************/ +STATIC RootBeast_s *ROOT_VOL_LookupByNameInDirectory( + GeneralMsg_s *genMsg, + void *conainer, + NameSpace_s *nameSpace, + NINT nameType, + unicode_t *name, +// cnt NINT nameUniquifier, +// cnt NINT *retNameUniquifier, + FullDirectoryInfo_s *retInfo) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return NULL; +} + +/**************************************************************************** + * is the given directory empty + *****************************************************************************/ +STATIC BOOL ROOT_VOL_IsDirectoryEmpty( + GeneralMsg_s *genMsg, + void *container, + NINT nameType) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return FALSE; +} + +/**************************************************************************** + * This adds a contained name to a directory beast. This is not the name + * of the directory beast itself, it is the name of a beast contained + * in the directory. + *****************************************************************************/ +STATIC STATUS ROOT_VOL_AddNameToDirectory( + GeneralMsg_s *genMsg, + NamedBeast_s *beast, + NamedBeast_s *directory, + NINT nameSpaceMask, + NINT nameType, + unicode_t *name, + NINT nsFlags, +// cnt NINT nameUniquifier, + NINT addNameFlags, + NINT matchAttributes, + Xaction_s *xaction, + TypeSpecificPersistentParentEntry_s *nameTypeInfo) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * This removes a contained name from a directory beast. This is not the name + * of the directory beast itself, it is the name of a beast contained + * in the directory. + *****************************************************************************/ +STATIC STATUS ROOT_VOL_RemoveNameFromDirectory( + GeneralMsg_s *genMsg, + Zid_t beastZid, + NamedBeast_s *directory, + NINT nameSpaceMask, + NINT nameType, + unicode_t *name, +// cnt NINT nameUniquifier, + NINT removeNameFlags, + Xaction_s *xaction, + TypeSpecificPersistentParentEntry_s *nameTypeInfo) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * This locates the curName and curNameSpaceMask in the directory, via + * an exact binary match. Then it replaces the nameSpacemask with + * the newNameSpacemask. NOTE--This function does not validate the + * new nameSpacemask, it blindly obeys. All validity checking must + * be done by the caller previous to calling this function. ALSO, + * this function may not be used to set the nameSpaceMask to 0. + *****************************************************************************/ +STATIC STATUS ROOT_VOL_ModifyNameSpaceMaskInDirectory( + GeneralMsg_s *genMsg, + NamedBeast_s *beast, + NamedBeast_s *directory, + NINT curNameSpaceMask, + NINT nameType, + unicode_t *curName, +// cnt NINT nameUniquifier, + NINT newNameSpaceMask, + Xaction_s *xaction) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * This locates the name and nameSpaceMask in the directory, via + * an exact binary match. Then it sets the new matchAttributes for + * that name entry. + * This function is an optional LSS Function. If an LSS does not support + * storing matchAttributes in the directory, it may supply a NULL + * pointer for this function. + *****************************************************************************/ +STATIC STATUS ROOT_VOL_setMatchAttributesInDirectory( + GeneralMsg_s *genMsg, + NamedBeast_s *beast, /* beast we are updating*/ + NamedBeast_s *directory, /* directory we are updating in*/ + NINT nameSpaceMask, + NINT nameType, + unicode_t *name, +// cnt NINT nameUniquifier, /* Caller passes zFNU_UNDEFINED if not known */ + NINT newMatchAttributes, + Xaction_s *xaction) /* Optional xaction, may be NULL */ +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * this is called to locate a name in a directory via wildcarding + *****************************************************************************/ +STATIC Zid_t ROOT_VOL_WildcardLookup( + GeneralMsg_s *genMsg, + NamedBeast_s *directory, + NameSpace_s *nameSpace, + NINT nameType, + unicode_t *pattern, + SearchMap_s *smap, +// cnt NINT cnt *retNameUniquifier, + FullDirectoryInfo_s *retInfo) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zINVALID_ZID; +} + + + +/*=========================================================================== + * VOLUME BLOCK OPERATIONS + *===========================================================================*/ + +/**************************************************************************** + * allocate a range of ZIDs from a volume, return parameter is count of + * how many we got + *****************************************************************************/ +STATIC STATUS ROOT_VOL_TruncateFile( + struct GeneralMsg_s *genMsg, + void *beast, + Blknum_t blockNum, + Blkcnt_t count) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * This is the default handler to get the generic Storage Info. + *****************************************************************************/ +STATIC STATUS ROOT_VOL_GetStorageInfo( + GeneralMsg_s *genMsg, + RootBeast_s *beast, + GetStorageInfo_s *getStorageInfo) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * This will return a map of the poolBlk blocks being used by the beast. + * This is designed so it can be called multiple times to get the full + * map. + *****************************************************************************/ +STATIC STATUS ROOT_VOL_GetExtentList( + GeneralMsg_s *genMsg, + RootBeast_s *beast, + Blknum_t startingBlock, + NINT extentListSize, + Blknum_t (*extentList)[], + NINT *retNumExtents, + Blknum_t *retNextBlock) +{ + zASSERT(0); + *retNumExtents = 0; + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * This will return a map of the poolBlk blocks being used by the beast. + * This is designed so it can be called multiple times to get the full + * map. + *****************************************************************************/ +STATIC STATUS ROOT_VOL_GetPhysicalExtent ( + struct zNSSMsg_s *msg, + RootBeast_s *beast) +{ + zASSERT(0); + SetStatus(msg, zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * This returns TRUE if the the given block is poolBlky allocated in + * the given beast. It returns FALSE if the block is not poolBlkly + * allocated to the beast + *****************************************************************************/ +STATIC BOOL ROOT_VOL_IsBlockInBeast( + RootBeast_s *beast, + Blknum_t blockNum) +{ + zASSERT(0); + return FALSE; +} + + + +/*=========================================================================== + * VOLUME I/O OPERATIONS + *===========================================================================*/ + +/**************************************************************************** + * This read a fileBlk block into memory, this is only called if the block + * is not already in cache + *****************************************************************************/ +STATIC void ROOT_VOL_AsyncReadFileBlk( + Asyncio_s *asyncio) +{ + zASSERT(0); + asyncio->status = zERR_COMN_OP_NOT_SUPPORTED; + FSM_RUN(&asyncio->fsm); +} + +/**************************************************************************** + * This read a fileBlk block into memory, this is only called if the block + * is not already in cache + *****************************************************************************/ +STATIC Buffer_s *ROOT_VOL_GetFileBlk( + GeneralMsg_s *genMsg, + IoMsg_s *iomsg) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return NULL; +} + +/**************************************************************************** + * Direct read file + *****************************************************************************/ +STATIC void ROOT_VOL_DioReadUnits( + zNSSMsg_s *msg, + RootBeast_s *beast) +{ + zASSERT(0); + SetStatus(msg,zERR_COMN_OP_NOT_SUPPORTED); +} + +/**************************************************************************** + * Direct write file + *****************************************************************************/ +STATIC void ROOT_VOL_DioWriteUnits( + zNSSMsg_s *msg, + RootBeast_s *beast) +{ + zASSERT(0); + SetStatus(msg,zERR_COMN_OP_NOT_SUPPORTED); +} + + + +/*=========================================================================== + * VOLUME Transaction OPERATIONS + *===========================================================================*/ + +/**************************************************************************** + * This is called to begin a transaction. This default handler returns + * the NILL MetaData transaction. + *****************************************************************************/ +STATIC void *ROOT_VOL_BeginXLocal( + Volume_s *volume, + NINT flags) +{ + return NIL_METADATA_XACTION; +} + +/**************************************************************************** + * This is called to end a transaction. This verifies that we received the + * NIL MetaData Transaction + *****************************************************************************/ +void ROOT_VOL_EndXLocal( + Xaction_s *xaction) +{ + zASSERT(xaction == NIL_METADATA_XACTION); +} + +/**************************************************************************** + * Add an entry to the purge log + *****************************************************************************/ +STATIC STATUS ROOT_VOL_AddPurgeLogEntry( + GeneralMsg_s *genMsg, + Volume_s *volume, + NINT type, /* input: the type of entry being added */ + PurgeLogMsg_s *purgeMsg, /* input: the information to find the log entry */ + Xaction_s *xAction) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * Remove an entry from the purge log + *****************************************************************************/ +STATIC STATUS ROOT_VOL_RemovePurgeLogEntry( + GeneralMsg_s *genMsg, + Volume_s *volume, + NINT type, /* input: the type of entry being added */ + PurgeLogMsg_s *purgeMsg, /* input: the information to find the log entry */ + Xaction_s *xAction) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * Write the persistent volume data + *****************************************************************************/ +STATIC void ROOT_VOL_WriteLoggedVolumeData( + Volume_s *volume, + Xaction_s *xaction, + VolInfoLog_s *volLog) +{ + /* Do nothing by default. Volumes must define this */ + /* However, the Admin volume does not, so this will be called for + * the admin volume */ +} + + + +/*=========================================================================== + * other VOLUME OPERATIONS + *===========================================================================*/ + +/**************************************************************************** + * this is called to change a VOLUME's state. + *****************************************************************************/ +STATUS ROOT_VOL_ChangeVolumeState( + GeneralMsg_s *genMsg, + RootBeast_s *volBeast, + NINT sourceState, + NINT desiredState, + NINT mode, + NINT pass) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/************************************************************************** + * This is called when a volume needs to be check/repaired. + ***************************************************************************/ +STATUS ROOT_VOL_VolumeMaintenance( + struct GeneralMsg_s *genMsg, + RootBeast_s *volBeast, + NINT checkCommand, + NINT checkFlags, + void *userInfo) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * This is the default handler to ALLOCATE the Storage Info. Since we do + * not actually need to allocate anything, this returns an OK. + *****************************************************************************/ +STATIC STATUS ROOT_VOL_AllocStorageInfo( + GeneralMsg_s *genMsg, + RootBeast_s *beast) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * This is the default handler to FREE the storage info. Since we originally + * did not allocate anything, this simply returns. + *****************************************************************************/ +STATIC void ROOT_VOL_FreeStorageInfo( + RootBeast_s *beast) +{ + zASSERT(0); + zASSERT(beast->storage.info == NULL); +} + + +/**************************************************************************** + * This reads the raw beast data from the volume + *****************************************************************************/ +void *ROOT_VOL_GetBeastFromVolume( + GeneralMsg_s *genMsg, + Zid_t zid, + Volume_s *volume) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return NULL; +} + +/**************************************************************************** + * This is an ASYNCRONOUS call that writes an existing beast to a volume + *****************************************************************************/ +STATIC STATUS ROOT_VOL_UpdateBeastToVolume( + GeneralMsg_s *genMsg, + RootBeast_s *beast, + NINT packedSize, + Xaction_s *xaction) +{ + zASSERT(0); + BST_noPackCleanup(beast); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * This is an ASYNCRONOUS call that writes a new beast to a volume + *****************************************************************************/ +STATIC STATUS ROOT_VOL_InsertBeastIntoVolume( + GeneralMsg_s *genMsg, + RootBeast_s *beast, + NINT packedSize, + Xaction_s *xaction) +{ + zASSERT(0); + BST_noPackCleanup(beast); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * This is an ASYNCRONOUS call that writes an existing beast to a volume + *****************************************************************************/ +STATIC STATUS ROOT_VOL_RemoveBeastFromVolume( + GeneralMsg_s *genMsg, + RootBeast_s *beast, + Xaction_s *xaction) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * This is a request to allocate a range of zids. This returns how many + * zids were allocated. Zero means it failed. + *****************************************************************************/ +STATIC NINT ROOT_VOL_AllocateZIDs( + GeneralMsg_s *genMsg, + Volume_s *volume, + NINT howMany, + Zid_t *retZID, + Xaction_s *xaction) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + *retZID = zINVALID_ZID; + return 0; +} + + +/************************************************************************** + * This request is sent when we are flushing a volume. The common layer + * has finished writing all of the files that were currently modified + * on this volume. This request should now write all of the system + * beasts that are modified on this volume. It should not return until + * the writes have been completed + ***************************************************************************/ +STATIC STATUS ROOT_VOL_FlushSystemBeasts( + GeneralMsg_s *genMsg, + Volume_s *volume) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + + +/************************************************************************** + * This request is sent when we need to get free space on a volume. + * The LSS should attempt to purge files until there are at least as many + * free blocks as requested. + ***************************************************************************/ +STATIC STATUS ROOT_VOL_MakeVolumeFreeSpace( + GeneralMsg_s *genMsg, + Volume_s *volume, + BOOL purgeAllDeletedFiles, + BOOL asyncPurge, + QUAD numberOfBlocks) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATIC STATUS ROOT_VOL_BrowseBeastsInVolume( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT selectionCriteria, + NINT numBeastsRequested, + Zid_t *lastBeastReturned, /* inout */ + Zid_t *beastZids, /* out */ + NINT *numBeastsReturned) /* out */ +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_GetUserSpaceInfo( + GeneralMsg_s *genMsg, + Volume_s *volume, + const UserID_t *userID, + SQUAD *restrictionAmount, + SQUAD *usedAmount) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_SetUserSpaceRestriction( + GeneralMsg_s *genMsg, + Volume_s *volume, + Xaction_s *xAction, + const UserID_t *userID, + SQUAD restrictionAmount) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +void ROOT_VOL_AdjustUsedUserSpace( + Xaction_s *xaction, + RootBeast_s *beast, + SQUAD amountToAdjust) +{ + zASSERT(0); + return; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_RemoveUser( + GeneralMsg_s *genMsg, + Volume_s *volume, + const UserID_t *userID) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_ResetAllUsers( + GeneralMsg_s *genMsg, + Volume_s *volume) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_BrowseUsersInVolume( + GeneralMsg_s *genMsg, + Volume_s *volume, + NINT numEntriesRequested, + UserID_t *lastUserReturned, /* inout */ + COMNUserRest_s *userEntries, /* out */ + NINT *numEntriesReturned, /* out */ + BOOL allUsers) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_insertMFLEntry( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + Zid_t zid, + Epoch_t epoch, + struct Xaction_s *xaction) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_deleteMFLEntry( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + Zid_t zid, + Epoch_t *epoch, /* out */ + struct Xaction_s *xaction) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_lookupMFLEntry( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + Zid_t zid, + Epoch_t *epoch) /* out */ +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_enumerateMFL( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + Epoch_t targetEpoch, + NINT numEntriesRequested, + Zid_t *lastZidReturned, /* inout */ + void *mflEntries, /* out */ + NINT *numEntriesReturned, /* out */ + BOOL *isMFLincomplete) /* out */ +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_administerMFL( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT opCode, + MFLAdminParms_s *parms) /* inout */ +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_insertEFLEntry( + struct GeneralMsg_s *genMsg, + File_s *beast, + NINT action, + unicode_t *name, + struct Xaction_s *xaction) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_deleteEFLEntry( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + Zid_t zid, + QUAD id1, + QUAD id2, + EFLEpoch_t *epoch, + struct Xaction_s *xaction) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_lookupEFLEntry( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + Zid_t zid, + EFLEpoch_t *targetEpoch, + EFLEntry_s *eflEntry) /* out */ +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_enumerateEFL( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + EFLEpoch_t *targetEpoch, + NINT maxEntries, + EFLEntryIndex_s *nextEntry, /* inout */ + EFLEntry_s *retEntries, /* out */ + NINT *numEntriesReturned) /* out */ +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_administerEFL( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT opcode, + EFLAdminIn_s *data, + EFLAdminOut_s *retData) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_resetEFL( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_FCNTL( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT opCode, + FCNTL_In_s *data, + FCNTL_Out_s *retData, + Xaction_s *xaction) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_commandFunction( + struct GeneralMsg_s *genMsg, + void *beast, + NINT functionNumber, + VCO_VolumeCommonOps_s *parsedCommandData, + NINT parmLen, + utf8_t *parm, + NINT dataLen, + BYTE *commandData, + NINT offset, + NINT retBufLen, + BYTE *retBuf, + NINT *retLen) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_GetDirQuotaInfo( + GeneralMsg_s *genMsg, + Volume_s *volume, + Zid_t dirZid, + SQUAD *quota, + SQUAD *usedAmount) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_SetDirQuota( + GeneralMsg_s *genMsg, + Volume_s *volume, + Xaction_s *xAction, + Zid_t directory, + SQUAD restrictionAmount) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +void ROOT_VOL_AdjustUsedDirSpace( + Xaction_s *xaction, + Volume_s *volume, + Zid_t dirZid, + SQUAD amountToAdjust) +{ + zASSERT(0); + return; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_RemoveDirectory( + GeneralMsg_s *genMsg, + Volume_s *volume, + Xaction_s *xAction, + Zid_t directory) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_ResetAllDirEntries( + GeneralMsg_s *genMsg, + Volume_s *volume) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_BrowseDirsInVolume( + GeneralMsg_s *genMsg, + Volume_s *volume, + NINT numEntriesRequested, + Zid_t *lastUserReturned, /* inout */ + COMNDirQuota_s *userEntries, /* out */ + NINT *numEntriesReturned) /* out */ +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_GetObjectName( + GeneralMsg_s *genMsg, + Volume_s *volume, + UserID_t *objectID, + unicode_t *name, + Time_t *timeNotFound, + NINT *numberOfTimesNotFound) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_InsertObjectName( + GeneralMsg_s *genMsg, + Volume_s *volume, + Xaction_s *xAction, + UserID_t *objectID, + unicode_t *name) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_ResetAllObjects( + GeneralMsg_s *genMsg, + Volume_s *volume) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS ROOT_VOL_ModifyObjectName( + GeneralMsg_s *genMsg, + Volume_s *volume, + Xaction_s *xAction, + UserID_t *objectID, + unicode_t *name, + Time_t timeNotFound, + NINT numberOfTimesNotFound) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/*--------------------------------------------------------------------------- + * RootBeast BEAST ComnOps + *---------------------------------------------------------------------------*/ +#if zLINUX +# define VPTRCAST (void *) +#else +# define VPTRCAST +#endif +CommonBeastOps_s RootBeastComnOps = +{ + VPTRCAST ROOT_BST_Construct, /* construct */ + VPTRCAST ROOT_BST_Destruct, /* destruct */ + +// cnt NULL, /* BST_getNameUniquifier */ + VPTRCAST ROOT_BST_SetupNameTypeSpecificInfo, /* BST_setupNameTypeSpecificInfo */ + VPTRCAST ROOT_BST_LookupByNameInDirectory, /* BST_lookupByNameInDirectory*/ + VPTRCAST ROOT_BST_IsDirectoryEmpty, /* BST_isDirectoryEmpty*/ + VPTRCAST ROOT_BST_AddNameToDirectory, /* BST_addNameToDirectory*/ + VPTRCAST ROOT_BST_RemoveNameFromDirectory, /* BST_removeNameFromDirectory*/ + VPTRCAST ROOT_BST_ModifyNameSpaceMaskInDirectory, /* BST_modifyNameSpaceMaskInDirectory*/ + VPTRCAST ROOT_BST_setMatchAttributesInDirectory, /* BST_setMatchAttributesInDirectory*/ + VPTRCAST ROOT_BST_WildcardLookup, /* BST_wildcardLookup*/ + + VPTRCAST ROOT_BST_TruncateFile, /* BST_truncateFile*/ + VPTRCAST ROOT_BST_GetStorageInfo, /* BST_getStorageInfo*/ + VPTRCAST ROOT_BST_GetExtentList, /* BST_getExtentList*/ + VPTRCAST ROOT_BST_GetPhysicalExtent, /* BST_getPhysicalExtent*/ + VPTRCAST ROOT_BST_IsBlockInBeast, /* BST_isBlockInBeast*/ + + VPTRCAST ROOT_BST_AsyncReadFileBlk, /* BST_asyncReadFileBlk*/ + VPTRCAST ROOT_BST_GetFileBlk, /* BST_getFileBlk*/ + VPTRCAST ROOT_BST_DioReadUnits, /* BST_dioReadUnits*/ + VPTRCAST ROOT_BST_DioWriteUnits, /* BST_dioWriteUnits*/ + + VPTRCAST ROOT_BST_GetZID, /* BST_getZID*/ + VPTRCAST ROOT_BST_BeastNotify, /* BST_beastNotify*/ + VPTRCAST ROOT_BST_GetInfo, /* BST_getInfo*/ + VPTRCAST ROOT_BST_ModifyInfo, /* BST_modifyInfo*/ + VPTRCAST ROOT_BST_GetInfoXML, /* BST_getInfoXML*/ + VPTRCAST ROOT_BST_ModifyInfoXML /* BST_modifyInfoXML*/ +}; + +/*------------------------------------------------------------------------- + * RootBeast VOLUME ComnOps + *-------------------------------------------------------------------------*/ +CommonVolumeOps_s RootBeastComnVolOps = +{ +// cnt NULL, /* VOL_getNameUniquifier */ + VPTRCAST ROOT_VOL_SetupNameTypeSpecificInfo, /* VOL_setupNameTypeSpecificInfo */ + VPTRCAST ROOT_VOL_LookupByNameInDirectory, /* VOL_lookupByNameInDirectory */ + VPTRCAST ROOT_VOL_IsDirectoryEmpty, /* VOL_isDirectoryEmpty */ + VPTRCAST ROOT_VOL_AddNameToDirectory, /* VOL_addNameToDirectory */ + VPTRCAST ROOT_VOL_RemoveNameFromDirectory, /* VOL_removeNameFromDirectory */ + VPTRCAST ROOT_VOL_ModifyNameSpaceMaskInDirectory, /* VOL_modifyNameSpaceMaskInDirectory */ + VPTRCAST ROOT_VOL_setMatchAttributesInDirectory, /* VOL_setMatchAttributesInDirectory */ + VPTRCAST ROOT_VOL_WildcardLookup, /* VOL_wildcardLookup */ + + VPTRCAST ROOT_VOL_TruncateFile, /* VOL_truncateFile*/ + VPTRCAST ROOT_VOL_GetStorageInfo, /* VOL_getStorageInfo*/ + VPTRCAST ROOT_VOL_GetExtentList, /* VOL_getExtentList*/ + VPTRCAST ROOT_VOL_GetPhysicalExtent, /* VOL_getPhysicalExtent*/ + VPTRCAST ROOT_VOL_IsBlockInBeast, /* VOL_isBlockInBeast*/ + + VPTRCAST ROOT_VOL_AsyncReadFileBlk, /* VOL_asyncReadFileBlk */ + VPTRCAST ROOT_VOL_GetFileBlk, /* VOL_getFileBlk */ + VPTRCAST ROOT_VOL_DioReadUnits, /* VOL_dioReadUnits */ + VPTRCAST ROOT_VOL_DioWriteUnits, /* VOL_dioWriteUnits */ + + VPTRCAST ROOT_VOL_BeginXLocal, /* VOL_beginXLocal */ + VPTRCAST ROOT_VOL_EndXLocal, /* VOL_endXLocal */ + VPTRCAST ROOT_VOL_AddPurgeLogEntry, /* VOL_addPurgeLogEntry */ + VPTRCAST ROOT_VOL_RemovePurgeLogEntry, /* VOL_removePurgeLogEntry */ + VPTRCAST ROOT_VOL_WriteLoggedVolumeData, /* VOL_writeVolumeLoggedData */ + + VPTRCAST ROOT_VOL_ChangeVolumeState, /* VOL_changeVolumeState */ + VPTRCAST ROOT_VOL_VolumeMaintenance, /* VOL_volumeMaintenance */ + VPTRCAST ROOT_VOL_AllocStorageInfo, /* VOL_allocStorageInfo */ + VPTRCAST ROOT_VOL_FreeStorageInfo, /* VOL_freeStorageInfo */ + VPTRCAST ROOT_VOL_GetBeastFromVolume, /* VOL_getBeastFromVolume */ + VPTRCAST ROOT_VOL_UpdateBeastToVolume, /* VOL_updateBeastToVolume */ + VPTRCAST ROOT_VOL_InsertBeastIntoVolume, /* VOL_insertBeastIntoVolume */ + VPTRCAST ROOT_VOL_RemoveBeastFromVolume, /* VOL_removeBeastFromVolume */ + VPTRCAST ROOT_VOL_AllocateZIDs, /* VOL_allocateZIDs */ + VPTRCAST ROOT_VOL_FlushSystemBeasts, /* VOL_flushSystemBeasts */ + VPTRCAST ROOT_VOL_MakeVolumeFreeSpace, /* VOL_makeVolumeFreeSpace */ + VPTRCAST ROOT_VOL_BrowseBeastsInVolume, /* VOL_browseBeastsInVolume */ + + VPTRCAST ROOT_VOL_GetUserSpaceInfo, /* VOL_getUserSpaceInfo */ + VPTRCAST ROOT_VOL_SetUserSpaceRestriction, /* VOL_setUserSpaceRestriction */ + VPTRCAST ROOT_VOL_AdjustUsedUserSpace, /* VOL_adjustUsedUserSpace */ + VPTRCAST ROOT_VOL_RemoveUser, /* VOL_removeUser */ + VPTRCAST ROOT_VOL_ResetAllUsers, /* VOL_resetAllUsers */ + VPTRCAST ROOT_VOL_BrowseUsersInVolume, /* VOL_browseUsersInVolume */ + + VPTRCAST ROOT_VOL_insertMFLEntry, /* VOL_insertMFLEntry */ + VPTRCAST ROOT_VOL_deleteMFLEntry, /* VOL_deleteMFLEntry */ + VPTRCAST ROOT_VOL_lookupMFLEntry, /* VOL_lookupMFLEntry */ + VPTRCAST ROOT_VOL_enumerateMFL, /* VOL_enumerateMFL */ + VPTRCAST ROOT_VOL_administerMFL, /* VOL_administerMFL */ + VPTRCAST ROOT_VOL_commandFunction, /* VOL_commandFunction */ + + VPTRCAST ROOT_VOL_GetDirQuotaInfo, /* VOL_getDirQuotaInfo */ + VPTRCAST ROOT_VOL_SetDirQuota, /* VOL_setDirQuota */ + VPTRCAST ROOT_VOL_AdjustUsedDirSpace, /* VOL_adjustUsedDirSpace */ + VPTRCAST ROOT_VOL_RemoveDirectory, /* VOL_removeDirectory */ + VPTRCAST ROOT_VOL_ResetAllDirEntries, /* VOL_resetAllDirEntries */ + VPTRCAST ROOT_VOL_BrowseDirsInVolume, /* VOL_browseDirsInVolume */ + + VPTRCAST ROOT_VOL_GetObjectName, /* VOL_getObjectName */ + VPTRCAST ROOT_VOL_InsertObjectName, /* VOL_insertObjectName */ + VPTRCAST ROOT_VOL_ResetAllObjects, /* VOL_resetAllObjects */ + VPTRCAST ROOT_VOL_ModifyObjectName, /* VOL_modifyObjectName */ + + VPTRCAST ROOT_VOL_insertEFLEntry, /* VOL_insertEFLEntry */ + VPTRCAST ROOT_VOL_deleteEFLEntry, /* VOL_deleteEFLEntry */ + VPTRCAST ROOT_VOL_lookupEFLEntry, /* VOL_lookupEFLEntry */ + VPTRCAST ROOT_VOL_enumerateEFL, /* VOL_enumerateEFL */ + VPTRCAST ROOT_VOL_administerEFL, /* VOL_administerEFL */ + VPTRCAST ROOT_VOL_resetEFL, /* VOL_resetEFL */ + + VPTRCAST ROOT_VOL_FCNTL, /* VOL_FCNTL */ +}; + + +/*=========================================================================== + *=========================================================================== + * + * AUTH SYSTEM BEAST OPERATIONS + * + *=========================================================================== + *===========================================================================*/ + +/**************************************************************************** + * + *****************************************************************************/ +STATIC STATUS rootMayIDoThis( + GeneralMsg_s *genMsg, + AuthBeast_s *beast, + Zid_t parentZID, + NINT operation) +{ + zASSERT(0); + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +#if NSS_DEBUG IS_ENABLED +/**************************************************************************** + * Display the contents of the given beasts MYCACHE + *****************************************************************************/ +void RootDisplayMyCache( + RootBeast_s *beast) +{ + Buffer_s *next; + + printf(MSGNot("***** MYCACHE *****\n")); + DQ_FOREACH(&beast->ROOTmycache.bufList,next,Buffer_s,mycacheLink) + { + printf(MSGNot("%08x: data=%08x logical=%d latch=%d state=%d\n"), + next,next->pBuf.data,next->pBuf.fileBlk, + next->agent.latch.count,next->state); + } +} + +#endif diff --git a/src/nwnss/comn/common/sAgentHandle.c b/src/nwnss/comn/common/sAgentHandle.c index 8de6741..8dc0024 100644 --- a/src/nwnss/comn/common/sAgentHandle.c +++ b/src/nwnss/comn/common/sAgentHandle.c @@ -64,7 +64,7 @@ NINT DBG_NumberOfSAgentHandleFrees = 0; ***************************************************************************/ STATIC STATUS SAH_ExtendSAgentHandleList( NSSConnection_s *pssConn) -{ +{ SAHandleCtrl_s *new; NINT i; @@ -244,7 +244,7 @@ STATIC void SAH_RemoveSemanticAgentHandle( * yet freed it because we had it in use. * If the use count goes to zero, this function will also release the * use count on the beasts pointed to by the context handle, and will free - * up the memory occupied by the handle. + * up the memory occupied by the handle. * ***************************************************************************/ void COMN_DoReleaseSAgentHandleIDP( @@ -259,7 +259,7 @@ void COMN_DoReleaseSAgentHandleIDP( if ((sah = sahIDP->ptr) == NULL) { return; - } + } zASSERT(sah->handleID == sahIDP->id); sahIDP->ptr = NULL; @@ -496,7 +496,7 @@ void SAH_RemoveAllSAHsOnVolume( /**************************************************************************** - * This routine will find all semantic agent handles that point to the + * This routine will find all semantic agent handles that point to the * combination of vol/oldDir/file and will fix them to point to the * combination of vol/newDir/file. *****************************************************************************/ @@ -539,3 +539,4 @@ void SAH_RemoveAllSAHsOnVolume( // pssConn->connUseCount--; // } //} + diff --git a/src/nwnss/comn/common/sazLib.c b/src/nwnss/comn/common/sazLib.c index c08b3ee..6be5e9f 100644 --- a/src/nwnss/comn/common/sazLib.c +++ b/src/nwnss/comn/common/sazLib.c @@ -39,7 +39,6 @@ #include #include "fileHandle.h" -#include #include "msgName.h" #include "zParams.h" #include "fsmsg.h" @@ -99,12 +98,12 @@ STATUS MSG_InitPatternMsg ( SetStatus(msg, zERR_BAD_PARAMETER_VALUE); return zFAILURE; } - COMN_SET_FILEHANDLE( &nameMsg->fileHandle, fileHandle->door.dr_key, + COMN_SET_FILEHANDLE( &nameMsg->fileHandle, fileHandle->door.dr_key, fileHandle); if (fileHandle->file->FILEattributes & zFA_IS_LINK) { - COMN_SET_NAMING_MSG_OPERATE_ON_LINK(nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(nameMsg); } nameMsg->pathCount = 0; /* NOT USED */ @@ -148,7 +147,7 @@ STATUS MSG_InitPatternMsg ( return zFAILURE; } *srchOpt = SMAPOPT_32BitMode; - nameMsg->path.voidPtr = (void *)(uintptr_t)msg->sys.data[PATTERN_DATA].start; + nameMsg->path.voidPtr = msg->sys.data[PATTERN_DATA].start; } else { @@ -192,7 +191,7 @@ STATUS MSG_InitNameMsg ( if (nameSpace & zMODE_DELETED) { nameMsg->nameType = zNTYPE_DELETED_FILE; - } + } else switch (nameMsg->nameSpaceID) { case zNSPACE_DATA_STREAM: @@ -221,7 +220,7 @@ STATUS MSG_InitNameMsg ( { nameMsg->handlePathType = zHPT_BEAST; - COMN_SET_FILEHANDLE( &nameMsg->fileHandle, fileHandle->door.dr_key, + COMN_SET_FILEHANDLE( &nameMsg->fileHandle, fileHandle->door.dr_key, fileHandle); } else @@ -277,7 +276,7 @@ STATUS MSG_InitZidNameMsg ( if (nameSpace & zMODE_DELETED) { nameType = zNTYPE_DELETED_FILE; - } + } else switch (nameSpace & 0xff) { case zNSPACE_DATA_STREAM: diff --git a/include/nwnss/include/sazlib.h b/src/nwnss/comn/common/sazlib.h similarity index 99% rename from include/nwnss/include/sazlib.h rename to src/nwnss/comn/common/sazlib.h index 2c300a0..fb08ff8 100644 --- a/include/nwnss/include/sazlib.h +++ b/src/nwnss/comn/common/sazlib.h @@ -38,7 +38,7 @@ #define _SAZLIB_H_ #ifndef _OMNI_H_ -#include +#include #endif /* Pre-define struct(s) so Linux compiler doesn't complain */ diff --git a/src/nwnss/comn/common/searchMap.c b/src/nwnss/comn/common/searchMap.c index 755b10a..4c35e87 100644 --- a/src/nwnss/comn/common/searchMap.c +++ b/src/nwnss/comn/common/searchMap.c @@ -279,7 +279,7 @@ STATUS SMAP_AllocAndInitSearchMap( pssConn->connUseCount--; RTN_STATUS(zFAILURE); } - DEBUG_PRINTF(TWILD, DBG_INDENT, (LGREEN, + DEBUG_PRINTF(TWILD, DBG_INDENT, (LGREEN, MSGNot("SMAP_AllocAndInitSearchMap: " "Allocating NEW nonReusable searchmap %08x\n"), smap)); @@ -303,7 +303,7 @@ STATUS SMAP_AllocAndInitSearchMap( RTN_STATUS(zFAILURE); } pssConn->searchMaps.numMaps++; - DEBUG_PRINTF(TWILD, DBG_INDENT, (LGREEN, + DEBUG_PRINTF(TWILD, DBG_INDENT, (LGREEN, MSGNot("SMAP_AllocAndInitSearchMap: " "Allocating NEW searchmap %08x (cnt=%u)\n"), smap,pssConn->searchMaps.numMaps)); @@ -314,7 +314,7 @@ STATUS SMAP_AllocAndInitSearchMap( if (DQ_NOT_EMPTY(&pssConn->searchMaps.reuseInactiveList)) { DQ_TAKE(&pssConn->searchMaps.reuseInactiveList, smap, SearchMap_s, link); - DEBUG_PRINTF(TWILD, DBG_INDENT, (LGREEN, + DEBUG_PRINTF(TWILD, DBG_INDENT, (LGREEN, MSGNot("SMAP_AllocAndInitSearchMap: " "Reusing INACTIVE searchmap %08x (old ZID=%u)\n"), smap,(NINT)smap->lookupZID)); @@ -368,7 +368,7 @@ if (++numberOfLoops >= 1000) #if NSS_DEBUG IS_ENABLED ++DBG_NumberOfSearchMapImplicitFrees; #endif - DEBUG_PRINTF(TWILD, DBG_INDENT, (LGREEN, + DEBUG_PRINTF(TWILD, DBG_INDENT, (LGREEN, MSGNot("SMAP_AllocAndInitSearchMap: " "Reusing ACTIVE searchmap %08x (old ZID=%u)\n"), smap,(NINT)smap->lookupZID)); @@ -404,7 +404,7 @@ if (++numberOfLoops >= 1000) smap->seqNum = STARTING_SEQ; smap->fileNameSpaceID = nameMsg->nameSpaceID; /*--------------------------------------------------------------------------- - * + * *---------------------------------------------------------------------------*/ switch (SMAPOPT_MODE(srchMsg->srchOpt)) { @@ -506,7 +506,7 @@ void SMAP_ReleaseSearchMap( ENTER(TWILD, SMAP_ReleaseSearchMap); ASSERT_MPKNSS_LOCK(); zASSERT((smap != NULL) && !(smap->options & SMAPOPT_inactive)); - DEBUG_PRINTF(TWILD, DBG_INDENT, (LGREEN, + DEBUG_PRINTF(TWILD, DBG_INDENT, (LGREEN, MSGNot("SMAP_ReleaseSearchMap: Freeing searchmap %08x (ZID=%u)\n"), smap,(NINT)smap->lookupZID)); @@ -570,7 +570,7 @@ void SMAP_ReleaseSearchMap( * yet freed it because we had it in use. * If the use count goes to zero, this function will also release the * use count on the beasts pointed to by the context handle, and will free - * up the memory occupied by the handle. + * up the memory occupied by the handle. * ***************************************************************************/ void SMAP_DoReleaseSearchMapIDP( @@ -585,7 +585,7 @@ void SMAP_DoReleaseSearchMapIDP( if ((smap = smapIDP->ptr) == NULL) { return; - } + } smapIDP->ptr = NULL; ASSERT_XLATCH(&smap->pssConn->searchMaps.smLatch); @@ -635,7 +635,7 @@ void SMAP_DoReleaseSearchMapIDP( *****************************************************************************/ STATIC void SMAP_ReleaseParentMaps( SearchMap_s *smap) - + { SearchMap_s *parentMap; SearchMap_s *nextParentMap; @@ -683,7 +683,7 @@ void SMAP_FreeSearchMap( RTN_VOID(); } - pssConn = smap->pssConn; /* Save this, because smap may be freed */ + pssConn = smap->pssConn; /* Save this, because smap may be freed */ pssConn->connUseCount++; X_LATCH(&pssConn->searchMaps.smLatch); @@ -701,9 +701,9 @@ void SMAP_FreeSearchMap( /**************************************************************************** - * This funciton releases the searchMapIDP_s pointer contained in a + * This funciton releases the searchMapIDP_s pointer contained in a * searchMsg. Any function which owns an initialized SearchMsg_s which - * either calls COMN_WildOpen or COMN_RESOLVE_SEARCHMAP must call this + * either calls COMN_WildOpen or COMN_RESOLVE_SEARCHMAP must call this * function to cleanup the searchMAP_IDP_s -- unless the function also * calls COMN_WildClose. COMN_WildClose does its own cleanup on the * searchMapIDP_s. @@ -719,7 +719,7 @@ void COMN_CleanupSearchMsg( return; } - pssConn = searchMsg->srchMap.ptr->pssConn; /* Save this, because smap may be freed */ + pssConn = searchMsg->srchMap.ptr->pssConn; /* Save this, because smap may be freed */ pssConn->connUseCount++; X_LATCH(&pssConn->searchMaps.smLatch); @@ -792,7 +792,7 @@ SearchMap_s *SMAP_DoResolveSearchMap( UNX_LATCH(&pssConn->searchMaps.smLatch); pssConn->connUseCount--; - RTN_PTR(smap); + RTN_PTR(smap); } @@ -946,7 +946,7 @@ void SMAP_RemoveAllSAgentSearchMapsOnVolume( DQ_FOREACH(&pssConn->searchMaps.inuseList,smap,SearchMap_s,link) { if ((LB_GUIDCompare(&smap->volumeID,&vol->VOLvolumeID) == 0) && - (smap->semanticAgentID == genMsg->saID)) + (smap->semanticAgentID == genMsg->saID)) { saveMap = smap; smap = OPREV(smap,SearchMap_s,link); @@ -959,7 +959,7 @@ void SMAP_RemoveAllSAgentSearchMapsOnVolume( DQ_FOREACH(&pssConn->searchMaps.reuseActiveList,smap,SearchMap_s,link) { if ((LB_GUIDCompare(&smap->volumeID,&vol->VOLvolumeID) == 0) && - (smap->semanticAgentID == genMsg->saID)) + (smap->semanticAgentID == genMsg->saID)) { saveMap = smap; smap = OPREV(smap,SearchMap_s,link); diff --git a/src/nwnss/comn/common/seqUpdater.c b/src/nwnss/comn/common/seqUpdater.c old mode 100644 new mode 100755 index 0549d1c..5717c23 --- a/src/nwnss/comn/common/seqUpdater.c +++ b/src/nwnss/comn/common/seqUpdater.c @@ -52,7 +52,7 @@ BOOL SEQ_ThreadRunning = FALSE; BOOL SEQ_ShutdownRequest = FALSE; BOOL SEQ_Sleeping = FALSE; OneShot_s SEQ_Alarm; - + /*************************************************************************** * This function is called when the alarm goes off ***************************************************************************/ @@ -65,7 +65,7 @@ void SEQ_TimedOut( } /*************************************************************************** - * This function puts the updater to sleep for the specified number of + * This function puts the updater to sleep for the specified number of * seconds. ***************************************************************************/ void SEQ_Sleep( @@ -188,7 +188,7 @@ void SEQ_UpdaterThread( * If updating has not been suspended then go for it... */ if ((Config.SecEquiv.updater) || (Config.SecEquiv.forceUpdater)) - { + { aprintf(YELLOW, "NSS background security equivalence updater running ...\n"); SEQ_UpdateAllPSSConnections(); @@ -218,8 +218,8 @@ exit: ***************************************************************************/ void SEQ_StartProcess() { - ZOS_StartThread(SEQ_ThreadID, "NSS Security Equivalence Updater", - (void *(*)(THREAD, void *))SEQ_UpdaterThread, + ZOS_StartThread(SEQ_ThreadID, "NSS Security Equivalence Updater", + (void *(*)(THREAD, void *))SEQ_UpdaterThread, 0, 0, NULL); if (SEQ_ThreadID == 0) { diff --git a/src/nwnss/comn/common/uxaction.c b/src/nwnss/comn/common/uxaction.c index 22e5be3..e4247ec 100644 --- a/src/nwnss/comn/common/uxaction.c +++ b/src/nwnss/comn/common/uxaction.c @@ -24,11 +24,11 @@ | |--------------------------------------------------------------------------- | - | $Author: cteerlink $ - | $Date: 2005-12-17 04:40:11 +0530 (Sat, 17 Dec 2005) $ + | $Author: cteerlink $ + | $Date: 2005-12-17 04:40:11 +0530 (Sat, 17 Dec 2005) $ | | $RCSfile$ - | $Revision: 1294 $ + | $Revision: 1294 $ | |--------------------------------------------------------------------------- | This module is used to: @@ -49,17 +49,17 @@ atomically (ie. either they all happen, or none of them happen), they happen in the correct order relative to each other, they happen in isolation relative to other transactions (ie. they happen either entirely before or entirely - after another transaction), and all the writes are durable (ie. once + after another transaction), and all the writes are durable (ie. once committed, the transaction is assured to residing in pesistant store). User transactions belong to a task, and are identified by a transaction ID. When a task is created, a default XID is also created. This ID is not visible from the outside world, but is used by legacy APIs when a default - transaction ID is needed. + transaction ID is needed. At the current time, multiple transactions may be linked to a given task. - However, nested (subtransactions) are not supported. - + However, nested (subtransactions) are not supported. + The only file system action that is currently transaction'd is file write. GENERAL FUNCTION OVERVIEW: @@ -67,8 +67,8 @@ In general, the sequence in which these functions would be called are: The system is activated at COMN code startup and volume state change - callback routines are registered. Then as volumes are activated and - deactivated, these callback routines are invoked. A bit in the + callback routines are registered. Then as volumes are activated and + deactivated, these callback routines are invoked. A bit in the enabled attributes field of the volume specifies whether writes to files on a volume are to be transactioned. If that bit is detected, we first try to replay any previous transaction log file (more about this later). @@ -87,7 +87,7 @@ At some future point that transaction will end in one of three ways. 1) The xaction may be "committed" which will cause a marker to be written to the log file noting such, and control will not be returned the the calling code - until all portions of the log file which deal with that transaction have + until all portions of the log file which deal with that transaction have been written to persistant media. What happens to the actual user data will be discussed later. 2)Another possibility is that the xaction is aborted by the caller. In this case, all of the data written to the volume is replaced @@ -104,7 +104,7 @@ general, the following ordering is enforced. For any given transaction, log file data must be written before user data. The log file must be written in time order. All log data associated with a transaction must be written - before control can return from a "commit". Abort requests may return + before control can return from a "commit". Abort requests may return immediately as they will be "undone" asynchronously, either in the near future if the system stays up, or in the more distant future in the case of an immediatly subsequent crash. Blocks in the log file may not be reused @@ -117,12 +117,12 @@ the logfile is scanned for what appears to be the newest and oldest blocks based upon LSNs and valid checksums. Once the boundaries of the file are determined, it is replayed in the forward direction. Data written is - association with valid transactions, is replayed. Once the logfile is + association with valid transactions, is replayed. Once the logfile is replayed in the forward direction, any transactions which have not been committed durig the replay must be considered as aborted transactions. The log file is then played in the reverse direction, aborting any leftover transaction. Once successfully completed, the logfile is deleted and a - new logfile is started. If the system crashes at any point during the + new logfile is started. If the system crashes at any point during the replay/undo the entire process can be executed again on the next volume activate. @@ -146,7 +146,7 @@ marker denoting a begin, commit, or abort transaction, or it may contain data written as part of a transaction. - + */ #include @@ -154,7 +154,6 @@ #include #include #include -#include #include "zError.h" #include "reserveResources.h" @@ -164,7 +163,6 @@ #include "uxaction.h" #include "msgName.h" #include "xError.h" -#include "xStdio.h" #include "nCache.h" #include "comnTask.h" #include "eventSys.h" @@ -174,35 +172,7 @@ extern LONG GetCurrentTime(); /* used to get timestamps for log records */ extern NINT makeBufferCheckSum(BYTE *ptr, NINT bufSize); -#ifndef aprintf -#define aprintf LB_aprintf -#endif - -#ifndef ZOS_RegisterConsumer -#define ZOS_RegisterConsumer(_consumerInfo) \ - do { \ - MPKNSS_UNLOCK(); \ - RegisterConsumer((_consumerInfo)); \ - MPKNSS_LOCK(); \ - } while (0) -#endif - -#ifndef ZOS_UnRegisterConsumer -#define ZOS_UnRegisterConsumer(_consumerId, _producerId) \ - do { \ - MPKNSS_UNLOCK(); \ - UnRegisterConsumer((_consumerId), (_producerId)); \ - MPKNSS_LOCK(); \ - } while (0) -#endif - -#ifdef ClearStatus -#undef ClearStatus -#define ClearStatus(_msg) (((_msg)->sys.status = zOK), \ - ((_msg)->sys.where = (QUAD)(uintptr_t)(WHERE))) -#endif - -/* This prototype is required for cleanup when a transaction is being reset +/* This prototype is required for cleanup when a transaction is being reset * from any state to idle but no writes have been transactioned using it */ extern void COMN_CleanupUserXaction (UserXaction_s *xaction); @@ -213,14 +183,14 @@ ADDR UserXactionConsumerIDEnter = 0; /* IDs for volstatechange callback*/ ADDR UserXactionConsumerIDExit = 0; LONG UXactionSystemInited = FALSE; /* flag to determine if xactions code is currently active */ -LONG UXactionVolumesActive = 0; /* Count of volumes +LONG UXactionVolumesActive = 0; /* Count of volumes currently being xaction'd */ typedef struct ReplayXaction_s { DQlink_t replayXactionLink; - Xid_t xid; + Xid_t xid; LONG prevLogOffset; } ReplayXaction_s; @@ -295,7 +265,7 @@ void unpinBuf (Buffer_s *buf) void AbortOldestTransactions(Volume_s *vol) { - int abortCount = 0; + int abortCount = 0; Xid_t *abortListArray; UserXactionLogBuffer_s *bfrHdr; GeneralMsg_s genMsg; @@ -304,7 +274,7 @@ void AbortOldestTransactions(Volume_s *vol) IoMsg_s logFileIOMsg; UserXactionLogRec_s *logRec; UserXaction_s *uxaction; - + ENTER(TUSERX, abortOldestTransaction); /* @@ -321,10 +291,10 @@ void AbortOldestTransactions(Volume_s *vol) /* now read the last block in the logfile so we can search for "begins */ COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE( &genMsg); - FILEBLK_IO_MSG(logFileIOMsg, + FILEBLK_IO_MSG(logFileIOMsg, vol->UXactionLogFileHandleIDP.ptr->dataStream, vol->UXMetaData.lastBlk, - 1, + 1, CACHE_READ); logBuf = COMN_GetFileBlk( &genMsg, &logFileIOMsg); @@ -336,8 +306,8 @@ void AbortOldestTransactions(Volume_s *vol) } mapBufferPage(logBuf); bfrHdr = (UserXactionLogBuffer_s*) &(logBuf->pBuf.data[0]); - - zASSERT(bfrHdr->checkSum == makeBufferCheckSum((BYTE*)&(logBuf->pBuf.data[0]), + + zASSERT(bfrHdr->checkSum == makeBufferCheckSum((BYTE*)&(logBuf->pBuf.data[0]), vol->UXMetaData.logFileBlockSize)); logRec = (UserXactionLogRec_s *) ((BYTE*) bfrHdr @@ -373,9 +343,9 @@ void AbortOldestTransactions(Volume_s *vol) */ zASSERT(abortCount > 0); - vol->UXMetaData.lastBlk = - (vol->UXMetaData.lastBlk + 1 == vol->UXMetaData.logFileSizeInBlocks) ? - 0 : + vol->UXMetaData.lastBlk = + (vol->UXMetaData.lastBlk + 1 == vol->UXMetaData.logFileSizeInBlocks) ? + 0 : vol->UXMetaData.lastBlk + 1; /* now call abort on each the uxactions that began in this block */ @@ -400,7 +370,7 @@ FreeExit: #if NSS_ASSERT IS_ENABLED void checkLogFileForZeros ( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, Volume_s *vol ) { @@ -415,10 +385,10 @@ void checkLogFileForZeros ( for (block = 0; block < logFileSizeInBlocks; block++) { - - FILEBLK_IO_MSG( - logFileIOMsg, - vol->UXactionLogFileHandleIDP.ptr->dataStream, + + FILEBLK_IO_MSG( + logFileIOMsg, + vol->UXactionLogFileHandleIDP.ptr->dataStream, block, /* block 0 */ 1, /* for 1 block */ CACHE_READ); @@ -442,7 +412,7 @@ void checkLogFileForZeros ( unmapBufferPage(logBuf); CACHE_RELEASE(logBuf); - } + } } #endif @@ -467,7 +437,7 @@ void checkLogFileForZeros ( *******************************************************************************/ STATUS createXactionLogFile( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, unicode_t *vname ) { @@ -507,19 +477,19 @@ STATUS createXactionLogFile( unicpy(aStack->logFileName,vname); unicat(aStack->logFileName,MSGNot(L":\\UXaction.log")); COMN_SETUP_NAMING_MSG_SIMPLE( - &aStack->nameMsg, + &aStack->nameMsg, aStack->logFileName, zPFMT_UNICODE, - NAMPMODE_Undefined , - XLATCHED, - zNSPACE_LONG,zNTYPE_FILE, - NULL); + NAMPMODE_Undefined , + XLATCHED, + zNSPACE_LONG,zNTYPE_FILE, + NULL); COMN_STRUCT_INIT(aStack->createMsg); /* init the create message to nulls */ COMN_SETUP_CREATE_FILE_MSG( &aStack->createMsg, /* and then fill it in */ - zFTYPE_FILE, + zFTYPE_FILE, zFA_IMMEDIATE_PURGE|zFA_COPY_INHIBIT|zFA_DO_NOT_COMPRESS_FILE, - COMN_GetUserID(genMsg), + COMN_GetUserID(genMsg), zRR_READ_ACCESS|zRR_WRITE_ACCESS|zRR_CANT_DELETE_WHILE_OPEN| zRR_DONT_UPDATE_ACCESS_TIME, zCREATE_OPEN_IF_THERE|zCREATE_TRUNCATE_IF_THERE,NULL); @@ -527,10 +497,10 @@ STATUS createXactionLogFile( /* * go create the log file */ - status = COMN_Create(genMsg, - &aStack->nameMsg, - &aStack->createMsg, - &vol->UXactionLogFileHandleIDP); + status = COMN_Create(genMsg, + &aStack->nameMsg, + &aStack->createMsg, + &vol->UXactionLogFileHandleIDP); COMN_CleanupNameMsg(genMsg, &aStack->nameMsg); if (status != zOK) @@ -555,7 +525,7 @@ STATUS createXactionLogFile( * must insure that it is at least some minimum in * size. */ - logFileLength = ALIGN((maxTransactions * AVG_XACTION_SIZE), + logFileLength = ALIGN((maxTransactions * AVG_XACTION_SIZE), (1 << vol->UXactionLogFileHandleIDP.ptr->file->FILEblkSizeShift)); if (logFileLength < MIN_LOG_FILE_SIZE) { @@ -567,7 +537,7 @@ STATUS createXactionLogFile( zNILXID, logFileLength, zSETSIZE_NON_SPARSE_FILE); - + X_LATCH( &vol->UXactionLogFileHandleIDP.ptr->dataStream->NAMEDbeastLatch); #if NSS_ASSERT IS_ENABLED @@ -603,17 +573,17 @@ STATUS createXactionLogFile( vol->UXMetaData.curBlk = 0; vol->UXMetaData.lastBlk = 0; vol->UXMetaData.insertOffset = sizeof(UserXactionLogBuffer_s); - vol->UXMetaData.logFileBlockSize = + vol->UXMetaData.logFileBlockSize = (1 << vol->UXactionLogFileHandleIDP.ptr->file->FILEblkSizeShift); vol->UXMetaData.logFileSizeInBlocks = logFileLength >> vol->UXactionLogFileHandleIDP.ptr->file->FILEblkSizeShift; - vol->UXMetaData.logFileBlockSizeShiftFactor = + vol->UXMetaData.logFileBlockSizeShiftFactor = vol->UXactionLogFileHandleIDP.ptr->file->FILEblkSizeShift; - FILEBLK_IO_MSG( - aStack->logFileIOMsg, - vol->UXactionLogFileHandleIDP.ptr->dataStream, + FILEBLK_IO_MSG( + aStack->logFileIOMsg, + vol->UXactionLogFileHandleIDP.ptr->dataStream, 0, /* block 0 */ 1, /* for 1 block */ CACHE_WRITE); @@ -631,9 +601,9 @@ STATUS createXactionLogFile( status = zOK; } mapBufferPage(logBuf); - memcpy( + memcpy( &(logBuf->pBuf.data[0]), - &bfrHdr, + &bfrHdr, sizeof(UserXactionLogBuffer_s)); unmapBufferPage(logBuf); @@ -689,7 +659,7 @@ ReplayXaction_s *lookupReplayXaction (DQhead_t *xlist, Xid_t xid) * * FUNCTION: Given a pointer to a piece of memory, and a length, contruct a * checksum based on a NINT from every 254th byte. Seed it with 1, -* and rotate it one to the left before each add to use the whole +* and rotate it one to the left before each add to use the whole * NINT. If the sum ends up as zero, bump it by one. Only a * NINT from every 254 bytes is used in a effort to save time. * @@ -704,12 +674,12 @@ ReplayXaction_s *lookupReplayXaction (DQhead_t *xlist, Xid_t xid) *******************************************************************************/ NINT makeBufferCheckSum ( - BYTE *ptr, + BYTE *ptr, NINT bufSize) { - NINT checkSum = 1; - BYTE *endPtr = ptr + bufSize - sizeof(NINT); + NINT checkSum = 1; + BYTE *endPtr = ptr + bufSize - sizeof(NINT); ENTER(TUSERX, makeBufferCheckSum); @@ -776,7 +746,7 @@ STATUS validXactionBlock(UserXactionLogBuffer_s *lBuf, NINT bSize, LONG logFileS if(logRec->type >= LOGRECTYPE_END) /* check to make sure that record type is valid */ return FALSE; - logRec = (UserXactionLogRec_s *)ALIGN( + logRec = (UserXactionLogRec_s *)ALIGN( (ADDR)((BYTE*)logRec + sizeof(UserXactionLogRec_s) + logRec->byteCount @@ -836,7 +806,7 @@ STATUS validXactionBlock(UserXactionLogBuffer_s *lBuf, NINT bSize, LONG logFileS * write the original (old) data * close the logfile * delete the logfile -* +* * INPUT: unicode_t *vname ;unicode name of volume to search * * OUTPUT: NONE @@ -845,22 +815,22 @@ STATUS validXactionBlock(UserXactionLogBuffer_s *lBuf, NINT bSize, LONG logFileS * EFFECTS: Logfile is closed and deleted * *******************************************************************************/ -void replayXactionLogFile ( +void replayXactionLogFile ( unicode_t *vname) { GeneralMsg_s genMsg; Buffer_s *logBuf; UserXactionLogRec_s *logRec; UserXactionLogRec_s *logRec0; - STATUS status; + STATUS status; SNINT i, j, k; UserXactionLogBuffer_s *bfrHdr; NINT validBlockFound = FALSE; Seq_t lowestLSN = 0xffffffff; - LONG lowestLSNBlock = 0xffffffff; + LONG lowestLSNBlock = 0xffffffff; Seq_t highestLSN = 1; LONG highestLSNBlock = 0; - ReplayXaction_s *replayXaction; + ReplayXaction_s *replayXaction; NINT oldLatch; FileHandleIDP_s uxActionLogFileHandleIDP; DQhead_t replayXactionHead; @@ -878,7 +848,7 @@ void replayXactionLogFile ( unicode_t toLogFileName[zMAX_COMPONENT_NAME]; unicode_t utmpStr[32]; char time[32]; - + } Stack_s; STACK_ALLOC(); @@ -892,9 +862,9 @@ void replayXactionLogFile ( unicpy(aStack->logFileName,vname); unicat(aStack->logFileName,MSGNot(L":\\UXaction.log")); COMN_SETUP_NAMING_MSG_SIMPLE(&aStack->nameMsg, aStack->logFileName, zPFMT_UNICODE, - NAMPMODE_Undefined, XLATCHED, zNSPACE_LONG,zNTYPE_FILE, NULL); + NAMPMODE_Undefined, XLATCHED, zNSPACE_LONG,zNTYPE_FILE, NULL); COMN_STRUCT_INIT(aStack->openMsg); - COMN_SETUP_OPEN_FILE_MSG(&aStack->openMsg, + COMN_SETUP_OPEN_FILE_MSG(&aStack->openMsg, zRR_READ_ACCESS | zRR_DENY_WRITE, NULL); status = COMN_Open(&genMsg, &aStack->nameMsg, &aStack->openMsg, &uxActionLogFileHandleIDP); @@ -915,14 +885,14 @@ void replayXactionLogFile ( zASSERT(uxActionLogFileHandleIDP.ptr != NULL); - aStack->uxMetaData.logFileBlockSize = + aStack->uxMetaData.logFileBlockSize = (1 << uxActionLogFileHandleIDP.ptr->file->FILEblkSizeShift); - aStack->uxMetaData.logFileBlockSizeShiftFactor = + aStack->uxMetaData.logFileBlockSizeShiftFactor = uxActionLogFileHandleIDP.ptr->file->FILEblkSizeShift; - aStack->uxMetaData.logFileSizeInBlocks = - uxActionLogFileHandleIDP.ptr->file->FILEeof >> + aStack->uxMetaData.logFileSizeInBlocks = + uxActionLogFileHandleIDP.ptr->file->FILEeof >> uxActionLogFileHandleIDP.ptr->file->FILEblkSizeShift; logFileSize = aStack->uxMetaData.logFileSizeInBlocks * aStack->uxMetaData.logFileBlockSize; @@ -932,8 +902,8 @@ void replayXactionLogFile ( for(i=0; i < aStack->uxMetaData.logFileSizeInBlocks; i++) { - FILEBLK_IO_MSG(aStack->logFileIOMsg, - uxActionLogFileHandleIDP.ptr->dataStream, + FILEBLK_IO_MSG(aStack->logFileIOMsg, + uxActionLogFileHandleIDP.ptr->dataStream, i, 1, CACHE_READ); logBuf = COMN_GetFileBlk(&genMsg, &aStack->logFileIOMsg); @@ -949,7 +919,7 @@ void replayXactionLogFile ( /* if not a valid block, skip it */ if(validXactionBlock((UserXactionLogBuffer_s*)&(logBuf->pBuf.data[0]), aStack->uxMetaData.logFileBlockSize, logFileSize)) { - logRec = (UserXactionLogRec_s*) ((BYTE*)&logBuf->pBuf.data[0] + + logRec = (UserXactionLogRec_s*) ((BYTE*)&logBuf->pBuf.data[0] + sizeof(UserXactionLogBuffer_s)); if (validBlockFound) @@ -986,14 +956,14 @@ void replayXactionLogFile ( /* Now parse the file again to see if any invalid blocks show up between * the lowestLSN and the highestLSN. If so, we can't use the file. */ - for (i = lowestLSNBlock; ; + for (i = lowestLSNBlock; ; (++i == aStack->uxMetaData.logFileSizeInBlocks) ? i = 0 : i) { - FILEBLK_IO_MSG( - aStack->logFileIOMsg, - uxActionLogFileHandleIDP.ptr->dataStream, - i, - 1, + FILEBLK_IO_MSG( + aStack->logFileIOMsg, + uxActionLogFileHandleIDP.ptr->dataStream, + i, + 1, CACHE_READ); logBuf = COMN_GetFileBlk(&genMsg, &aStack->logFileIOMsg); @@ -1017,19 +987,19 @@ void replayXactionLogFile ( } /* - * We now know the starting point. Proceed forward from there and + * We now know the starting point. Proceed forward from there and * replay the logfile */ DQ_INIT(&replayXactionHead); - for (i = lowestLSNBlock; ; + for (i = lowestLSNBlock; ; (++i == aStack->uxMetaData.logFileSizeInBlocks) ? i = 0 : i) { - FILEBLK_IO_MSG( - aStack->logFileIOMsg, - uxActionLogFileHandleIDP.ptr->dataStream, - i, - 1, + FILEBLK_IO_MSG( + aStack->logFileIOMsg, + uxActionLogFileHandleIDP.ptr->dataStream, + i, + 1, CACHE_READ); logBuf = COMN_GetFileBlk(&genMsg, &aStack->logFileIOMsg); @@ -1041,7 +1011,7 @@ void replayXactionLogFile ( mapBufferPage(logBuf); bfrHdr = (UserXactionLogBuffer_s*) &(logBuf->pBuf.data[0]); - logRec = (UserXactionLogRec_s *) ((BYTE*) bfrHdr + + logRec = (UserXactionLogRec_s *) ((BYTE*) bfrHdr + sizeof(UserXactionLogBuffer_s)); /* examine each log record in buffer,do the appropriate thing */ @@ -1050,9 +1020,9 @@ void replayXactionLogFile ( /* * have we seen the xaction before ? */ - replayXaction = lookupReplayXaction(&replayXactionHead, logRec->xid); + replayXaction = lookupReplayXaction(&replayXactionHead, logRec->xid); - switch (logRec->type) + switch (logRec->type) { case LOGRECTYPE_BEGIN: @@ -1067,8 +1037,8 @@ void replayXactionLogFile ( case LOGRECTYPE_COMMIT: /* - * if we don't have a replay xaction, we were - * "homed" past the begin_xaction which implies a + * if we don't have a replay xaction, we were + * "homed" past the begin_xaction which implies a * later successful commit or abort, hence we have a * partial xaction and no need to do anything further */ @@ -1086,30 +1056,30 @@ void replayXactionLogFile ( DQ_RMV(replayXaction, replayXactionLink); free(replayXaction); } - break; + break; case LOGRECTYPE_DATA: if (replayXaction != NULL) { status = writeToXactionedDataFile( - &genMsg, - &uxActionLogFileHandleIDP, - logRec->zid, - zMAX_FILE_SIZE, - logRec->fileByteOffset, - ((char *)&logRec[1])+logRec->byteCount, + &genMsg, + &uxActionLogFileHandleIDP, + logRec->zid, + zMAX_FILE_SIZE, + logRec->fileByteOffset, + ((char *)&logRec[1])+logRec->byteCount, logRec->byteCount); - replayXaction->prevLogOffset = - i * aStack->uxMetaData.logFileBlockSize + + replayXaction->prevLogOffset = + i * aStack->uxMetaData.logFileBlockSize + ((BYTE*)logRec - (BYTE*)bfrHdr); } break; case LOGRECTYPE_TRUNCATE: - /* Do nothing because the truncate really happened when the original log entry + /* Do nothing because the truncate really happened when the original log entry * was created. This will create odd behaviour if transactioned and non-transactioned - * operations are carried out on the same transactional file. Therefore, we + * operations are carried out on the same transactional file. Therefore, we * assume that all operations on a file are transactional or all are not. */ break; @@ -1133,16 +1103,16 @@ void replayXactionLogFile ( } /* - * We've finished playing the log file forward. Now play it backward, - * checking each write record against pending transactions. We have + * We've finished playing the log file forward. Now play it backward, + * checking each write record against pending transactions. We have * to undo all these writes. */ for (i = highestLSNBlock; - ; + ; (--i < 0) ? i = aStack->uxMetaData.logFileSizeInBlocks-1 : i) { - FILEBLK_IO_MSG(aStack->logFileIOMsg, - uxActionLogFileHandleIDP.ptr->dataStream, + FILEBLK_IO_MSG(aStack->logFileIOMsg, + uxActionLogFileHandleIDP.ptr->dataStream, i, 1, CACHE_READ); logBuf = COMN_GetFileBlk(&genMsg, &aStack->logFileIOMsg); @@ -1156,7 +1126,7 @@ void replayXactionLogFile ( mapBufferPage(logBuf); bfrHdr = (UserXactionLogBuffer_s*) &(logBuf->pBuf.data[0]); - logRec0 = (UserXactionLogRec_s *) ((BYTE*) bfrHdr + + logRec0 = (UserXactionLogRec_s *) ((BYTE*) bfrHdr + sizeof(UserXactionLogBuffer_s)); /* @@ -1168,7 +1138,7 @@ void replayXactionLogFile ( for (k = 0; k < j; k++) { logRec = (UserXactionLogRec_s *)ALIGN( - (ADDR)((BYTE*)logRec + (ADDR)((BYTE*)logRec + sizeof(UserXactionLogRec_s) + logRec->byteCount * (logRec->type == LOGRECTYPE_TRUNCATE ? 1 : 2)), @@ -1181,10 +1151,10 @@ void replayXactionLogFile ( */ if (replayXaction == NULL) { - continue; + continue; } /* - * a begin implies that everything has been undone, do + * a begin implies that everything has been undone, do * release the replay structure */ if (logRec->type == LOGRECTYPE_BEGIN) @@ -1198,12 +1168,12 @@ void replayXactionLogFile ( if ((logRec->type == LOGRECTYPE_DATA) || (logRec->type == LOGRECTYPE_TRUNCATE)) { status = writeToXactionedDataFile( - &genMsg, - &uxActionLogFileHandleIDP, - logRec->zid, - zMAX_FILE_SIZE, - logRec->fileByteOffset, - (char *)&logRec[1], + &genMsg, + &uxActionLogFileHandleIDP, + logRec->zid, + zMAX_FILE_SIZE, + logRec->fileByteOffset, + (char *)&logRec[1], logRec->byteCount); } else @@ -1230,8 +1200,8 @@ errorExit: status = VOL_FlushVolume(&genMsg,uxActionLogFileHandleIDP.ptr->file->FILEvolume); zASSERT(status == zOK); - - MSG_DestroyKey(uxActionLogFileHandleIDP.key); + + MSG_DestroyKey(uxActionLogFileHandleIDP.key); RELEASE_RSRC(READ_RESERVE); @@ -1246,10 +1216,10 @@ renameExit: UNS_LATCH(&uxActionLogFileHandleIDP.ptr->dataStream->NAMEDbeastLatch); - MSG_DestroyKey(uxActionLogFileHandleIDP.key); + MSG_DestroyKey(uxActionLogFileHandleIDP.key); ClearErrno(&genMsg); - + /* Create a pathname for the current logfile */ COMN_INIT_NAMING_MSG(&aStack->nameMsg); unicpy(aStack->logFileName,vname); @@ -1262,12 +1232,12 @@ renameExit: unicpy(aStack->toLogFileName,vname); unicat(aStack->toLogFileName,MSGNot(L":\\XLog")); UTCTime2UniversalStr(GetUTCTime(),aStack->time); - LB_ByteToUnicode(NSS_UNI_CONVERSION_RAW, aStack->utmpStr, 32, aStack->time , NULL); + LB_ByteToUnicode(NSS_UNI_CONVERSION_RAW, aStack->utmpStr, 32, aStack->time , NULL); unicat(aStack->toLogFileName,aStack->utmpStr); /* Rename the file from its current name to a timestamp name */ COMN_SETUP_NAMING_MSG_SIMPLE(&aStack->toNameMsg, aStack->toLogFileName, zPFMT_UNICODE, - NAMPMODE_Undefined, XLATCHED, zNSPACE_LONG,zNTYPE_FILE, NULL); + NAMPMODE_Undefined, XLATCHED, zNSPACE_LONG,zNTYPE_FILE, NULL); COMN_SETUP_RENAME_MSG( &aStack->renMsg, 0); (void) COMN_Rename( &genMsg, &aStack->nameMsg, &aStack->toNameMsg, &aStack->renMsg); @@ -1278,7 +1248,7 @@ renameExit: (void) VOL_FlushVolume(&genMsg,volume); ClearErrno(&genMsg); - + RELEASE_RSRC(READ_RESERVE); STACK_FREE(); @@ -1289,7 +1259,7 @@ renameExit: * NAME: shutdownVolumeXactionSupport * * FUNCTION: We have to abort all currently pending xactions, wait for -* them to home and then we have to close the logfile. +* them to home and then we have to close the logfile. * * INPUT: Volume_s *vol ;volume to shutdown transactions for * @@ -1317,14 +1287,14 @@ void shutdownVolumeXactionSupport(Volume_s *vol) /* When the server is being downed the following code to abort active - * transactions results in a server abend when reading from the TTS - * log file. This probably happens because the log file is open and the - * shutdown code asynchronously closed the file handle. Oddly enough, - * this case is handled later in this function but left unhandled for the - * transaction aborts. Since the log will be flushed when the volume is - * dis-mounted and the log will be replayed when the volume is mounted, - * it was decided to remove the code to abort active transactions and - * let the volume dismount with them orphaned in the log. This means + * transactions results in a server abend when reading from the TTS + * log file. This probably happens because the log file is open and the + * shutdown code asynchronously closed the file handle. Oddly enough, + * this case is handled later in this function but left unhandled for the + * transaction aborts. Since the log will be flushed when the volume is + * dis-mounted and the log will be replayed when the volume is mounted, + * it was decided to remove the code to abort active transactions and + * let the volume dismount with them orphaned in the log. This means ` * that the code to delete the log file must also be removed. It is * also the case that several of the locals are no longer required. */ @@ -1335,7 +1305,7 @@ void shutdownVolumeXactionSupport(Volume_s *vol) * FixFixFix TAYSOM - This is still not cleaning up quite right * for xactions that are in the BEGIN, COMMIT, or ABORT states. */ -// while (DQ_NOT_EMPTY( &vol->HomeTimeOrderList)) +// while (DQ_NOT_EMPTY( &vol->HomeTimeOrderList)) // { // DQ_TAKE( &vol->HomeTimeOrderList, home, HomeXaction_s, timeOrderLink); // uxaction = home->userXaction; @@ -1348,7 +1318,7 @@ void shutdownVolumeXactionSupport(Volume_s *vol) // HomeXactionLogFile(vol); -// while (DQ_NOT_EMPTY( &homeShutDownList)) +// while (DQ_NOT_EMPTY( &homeShutDownList)) // { // DQ_TAKE( &homeShutDownList, home, HomeXaction_s, timeOrderLink) // DQ_ENQ( &vol->HomeTimeOrderList, home, timeOrderLink); @@ -1363,7 +1333,7 @@ void shutdownVolumeXactionSupport(Volume_s *vol) if (vol->UXactionLogFileHandleIDP.ptr->file && vol->UXactionLogFileHandleIDP.ptr->file->FILEvolume) { - VOL_FlushVolume( &genMsg, + VOL_FlushVolume( &genMsg, vol->UXactionLogFileHandleIDP.ptr->file->FILEvolume); } if (vol->UXactionLogFileHandleIDP.ptr->file) @@ -1376,8 +1346,8 @@ void shutdownVolumeXactionSupport(Volume_s *vol) // COMN_INIT_NAMING_MSG(&nameMsg); // unicpy(logFileName,vname); // unicat(logFileName,MSGNot(L":\\UXaction.log")); -// COMN_SETUP_NAMING_MSG_SIMPLE(&nameMsg, logFileName, zPFMT_UNICODE, -// NAMPMODE_Undefined , XLATCHED, zNSPACE_DOS,zNTYPE_FILE, NULL); +// COMN_SETUP_NAMING_MSG_SIMPLE(&nameMsg, logFileName, zPFMT_UNICODE, +// NAMPMODE_Undefined , XLATCHED, zNSPACE_DOS,zNTYPE_FILE, NULL); // // COMN_Delete(&genMsg,&nameMsg,&deleteMsg);*/ /* delete happens first cuz it needs a nameMsg */ // @@ -1389,7 +1359,7 @@ void shutdownVolumeXactionSupport(Volume_s *vol) /******************************************************************************* * NAME: unplayReplayXaction * -* FUNCTION: Given a pointer to a xaction struct in the log record, unplay +* FUNCTION: Given a pointer to a xaction struct in the log record, unplay * this transaction to the beginning starting from the log file * offset specified in the replayXaction struct, move backward * through the log file, opening and modifying data files, until @@ -1411,9 +1381,9 @@ void shutdownVolumeXactionSupport(Volume_s *vol) *******************************************************************************/ STATUS unplayReplayXaction ( - GeneralMsg_s *genMsg, - FileHandleIDP_s *uxActionLogFileHandleIDP, - UserXactionLogMetaData_s *uxMetaData, + GeneralMsg_s *genMsg, + FileHandleIDP_s *uxActionLogFileHandleIDP, + UserXactionLogMetaData_s *uxMetaData, ReplayXaction_s *replayXaction) { LONG logRecOffset; @@ -1425,7 +1395,7 @@ STATUS unplayReplayXaction ( ENTER(TUSERX, UnplayReplayXaction); - for (logRecOffset = replayXaction->prevLogOffset; + for (logRecOffset = replayXaction->prevLogOffset; logRecType != LOGRECTYPE_BEGIN; ) { /* @@ -1433,11 +1403,11 @@ STATUS unplayReplayXaction ( * the log file that we need to process, then if it involved * data, return the data to the file from whence it came */ - FILEBLK_IO_MSG( - logFileIOMsg, - uxActionLogFileHandleIDP->ptr->dataStream, - logRecOffset >> uxMetaData->logFileBlockSizeShiftFactor, - 1, + FILEBLK_IO_MSG( + logFileIOMsg, + uxActionLogFileHandleIDP->ptr->dataStream, + logRecOffset >> uxMetaData->logFileBlockSizeShiftFactor, + 1, CACHE_READ); logBuf = COMN_GetFileBlk(genMsg, &logFileIOMsg); zASSERT(logBuf != NULL); @@ -1446,8 +1416,8 @@ STATUS unplayReplayXaction ( RTN_STATUS(zERR_HARD_READ_ERROR); } mapBufferPage(logBuf); - logRec = (UserXactionLogRec_s*) - &(logBuf->pBuf.data[logRecOffset & + logRec = (UserXactionLogRec_s*) + &(logBuf->pBuf.data[logRecOffset & MASK(0,uxMetaData->logFileBlockSizeShiftFactor)]); /* * If we have a valid looking zid @@ -1456,12 +1426,12 @@ STATUS unplayReplayXaction ( if ((logRec->type == LOGRECTYPE_DATA) || (logRec->type == LOGRECTYPE_TRUNCATE)) { status = writeToXactionedDataFile( - genMsg, - uxActionLogFileHandleIDP, + genMsg, + uxActionLogFileHandleIDP, logRec->zid, logRec->originalEOF, - logRec->fileByteOffset, - (char *)&logRec[1], + logRec->fileByteOffset, + (char *)&logRec[1], logRec->byteCount); if (status != zOK) { @@ -1476,7 +1446,7 @@ STATUS unplayReplayXaction ( CACHE_RELEASE(logBuf); } RTN_STATUS(zOK); -} +} /* @@ -1497,7 +1467,7 @@ void awaitAgent (Agent_s *agent) /******************************************************************************* * NAME: writeToXactionedDataFile * -* FUNCTION: This function is used to write a string of data to a file +* FUNCTION: This function is used to write a string of data to a file * indentified only by zid. If the zid can't be found, or the * offset is not valid, a zFAILURE status is returned. This * routine is ONLY used during replay of the log file and does @@ -1520,12 +1490,12 @@ void awaitAgent (Agent_s *agent) *******************************************************************************/ STATUS writeToXactionedDataFile( - GeneralMsg_s *genMsg, - FileHandleIDP_s *uxActionLogFileHandleIDP, - Zid_t zid, - QUAD originalEOF, - QUAD fileByteOffset, - BYTE *source, + GeneralMsg_s *genMsg, + FileHandleIDP_s *uxActionLogFileHandleIDP, + Zid_t zid, + QUAD originalEOF, + QUAD fileByteOffset, + BYTE *source, LONG byteCount) { Buffer_s *dataBuf; @@ -1538,20 +1508,20 @@ STATUS writeToXactionedDataFile( /* given the zid, go get a beast for it */ dataFileBeast = COMN_LookupByZid( - genMsg, - uxActionLogFileHandleIDP->ptr->file->FILEvolume, - zid, - XLATCHED, + genMsg, + uxActionLogFileHandleIDP->ptr->file->FILEvolume, + zid, + XLATCHED, TRUE); /* if the file still exists, write the data to it */ if (dataFileBeast) { FILEBLK_IO_MSG( - dataFileIOMsg, - dataFileBeast, - fileByteOffset >> dataFileBeast->blkSizeShift, - 1, + dataFileIOMsg, + dataFileBeast, + fileByteOffset >> dataFileBeast->blkSizeShift, + 1, CACHE_UPDATE); dataBuf = COMN_GetFileBlk(genMsg, &dataFileIOMsg); @@ -1559,9 +1529,9 @@ STATUS writeToXactionedDataFile( if (dataBuf) { mapBufferPage(dataBuf); - memcpy( &(dataBuf->pBuf.data[fileByteOffset & + memcpy( &(dataBuf->pBuf.data[fileByteOffset & MASK(0,dataFileBeast->blkSizeShift)]), - source, + source, byteCount); unmapBufferPage(dataBuf); @@ -1592,7 +1562,7 @@ STATUS writeToXactionedDataFile( { dataFileBeast->ROOTeof = originalEOF; COMN_MARK_BEAST_DIRTY(dataFileBeast); - } + } } status = zOK; @@ -1624,7 +1594,7 @@ STATUS writeToXactionedDataFile( *******************************************************************************/ STATUS COMN_AbortUserXaction ( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, UserXaction_s *uxaction) { Buffer_s *logBuf; @@ -1648,8 +1618,8 @@ STATUS COMN_AbortUserXaction ( } if (uxaction->state == BEGIN_UXACTION) { - /* A transaction in the begin state has no persistent data - and the state can simply be changed in memory before + /* A transaction in the begin state has no persistent data + and the state can simply be changed in memory before returning. */ uxaction->state = IDLE_UXACTION; @@ -1688,10 +1658,10 @@ STATUS COMN_AbortUserXaction ( * that we need to process */ FILEBLK_IO_MSG( - logFileIOMsg, - vol->UXactionLogFileHandleIDP.ptr->dataStream, - logRecOffset >> vol->UXMetaData.logFileBlockSizeShiftFactor, - 1, + logFileIOMsg, + vol->UXactionLogFileHandleIDP.ptr->dataStream, + logRecOffset >> vol->UXMetaData.logFileBlockSizeShiftFactor, + 1, CACHE_READ); logBuf = COMN_GetFileBlk(genMsg, &logFileIOMsg); @@ -1712,12 +1682,12 @@ STATUS COMN_AbortUserXaction ( if ((logRec->type == LOGRECTYPE_DATA) || (logRec->type == LOGRECTYPE_TRUNCATE)) { writeToXactionedDataFile( - genMsg, - &vol->UXactionLogFileHandleIDP, - logRec->zid, + genMsg, + &vol->UXactionLogFileHandleIDP, + logRec->zid, logRec->originalEOF, - logRec->fileByteOffset, - (char *)&logRec[1], + logRec->fileByteOffset, + (char *)&logRec[1], logRec->byteCount); } logRecOffset = logRec->prevLogOffset; @@ -1745,12 +1715,12 @@ errorExit: /******************************************************************************* * NAME: COMN_BeginUserXaction * -* FUNCTION: This function sets a transaction to the begin state. It cannot - write the BEGIN marker to the log file because the transaction - only supports writes to a single volume from many that might - support transactional files. Since the volume the writes will - apply to is not known from the supplied information then the - BEGIN marker cannot be written to the transaction log of any +* FUNCTION: This function sets a transaction to the begin state. It cannot + write the BEGIN marker to the log file because the transaction + only supports writes to a single volume from many that might + support transactional files. Since the volume the writes will + apply to is not known from the supplied information then the + BEGIN marker cannot be written to the transaction log of any volume. * * INPUT: GeneralMsg_s *genMsg ; General message @@ -1765,7 +1735,7 @@ errorExit: *******************************************************************************/ STATUS COMN_BeginUserXaction ( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, UserXaction_s *uxaction) { ENTER(TUSERX, commitUserXaction); @@ -1781,16 +1751,16 @@ STATUS COMN_BeginUserXaction ( SetErrno(genMsg, zERR_TRANSACTION_INVALID_STATE); RTN_STATUS(zFAILURE); } - /* The transaction will remain at the BEGIN state until the - * first write associated with it. This is because we only - * support transactions that are associated with one volume - * and we have no information here to bind the transaction - * to any volume. When the write takes place we know what - * volume to associate the transaction with and we will + /* The transaction will remain at the BEGIN state until the + * first write associated with it. This is because we only + * support transactions that are associated with one volume + * and we have no information here to bind the transaction + * to any volume. When the write takes place we know what + * volume to associate the transaction with and we will * write the begin transaction log entry at that time. - * NB: This means that the transaction remains an in memory + * NB: This means that the transaction remains an in memory * only resource until the first write takes place. - * The home transaction will not be created until the first + * The home transaction will not be created until the first * write. */ uxaction->homeXaction = NULL; @@ -1819,7 +1789,7 @@ STATUS COMN_BeginUserXaction ( *******************************************************************************/ STATUS COMN_CommitUserXaction ( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, UserXaction_s *uxaction) { @@ -1835,8 +1805,8 @@ STATUS COMN_CommitUserXaction ( } if (uxaction->state == BEGIN_UXACTION) { - /* A transaction in the begin state has no persistent data - and the state can simply be changed in memory before + /* A transaction in the begin state has no persistent data + and the state can simply be changed in memory before returning. */ uxaction->state = IDLE_UXACTION; @@ -1846,7 +1816,7 @@ STATUS COMN_CommitUserXaction ( } RTN_STATUS(zOK); } - if (uxaction->state != ACTIVE_UXACTION) + if (uxaction->state != ACTIVE_UXACTION) { SetErrno(genMsg, zERR_TRANSACTION_INVALID_STATE); RTN_STATUS(zFAILURE); @@ -1914,7 +1884,7 @@ void HomeXactionLogFile (Volume_s *vol) vol->UXMetaData.lastBlk = vol->UXMetaData.curBlk; RTN_VOID(); } - + /******************************************************************************* * NAME: UXACTION_Startup * @@ -1991,9 +1961,9 @@ void UXACTION_Startup () * FUNCTION: Called from NSS shutdown code, this routine unregisters the * event callback routines and marks the system as inactive. * -* INPUT: +* INPUT: * -* OUTPUT: +* OUTPUT: * * SIDE * EFFECTS: Two callbacks unregistered, Xaction system marked as inactive @@ -2004,7 +1974,7 @@ void UXACTION_Shutdown() { zASSERT(UXactionSystemInited == TRUE); - if (UserXactionConsumerIDEnter) + if (UserXactionConsumerIDEnter) { ZOS_UnRegisterConsumer((void *)UserXactionConsumerIDEnter, (void *)EVENT_ChangeVolState_Enter); @@ -2013,7 +1983,7 @@ void UXACTION_Shutdown() if (UserXactionConsumerIDExit) { - + ZOS_UnRegisterConsumer((void *)UserXactionConsumerIDExit, (void *)EVENT_ChangeVolState_Exit); UserXactionConsumerIDExit = 0; @@ -2028,7 +1998,7 @@ void UXACTION_Shutdown() /******************************************************************************* * NAME: StartUXactionSupportOnVolume * -* FUNCTION: This function causes User Transactions to be active on the +* FUNCTION: This function causes User Transactions to be active on the * specified volume. * * INPUT: Volume_s *vol ;pointer to volume object @@ -2068,7 +2038,7 @@ STATUS COMN_StartUXactionSupportOnVolume(Volume_s *vol) "failed.\n", 974), aStack->vname); } - } + } STACK_FREE(); return status; @@ -2078,11 +2048,11 @@ STATUS COMN_StartUXactionSupportOnVolume(Volume_s *vol) /******************************************************************************* * NAME: UXactionActivateThread * -* FUNCTION: This function is a work to do thread entry point to call -* function that activates User Transactions on a volume. When +* FUNCTION: This function is a work to do thread entry point to call +* function that activates User Transactions on a volume. When * we are activating a volume we can activate transaction support -* inline, but when enabling transaction support on a volume we -* cannot. Therefore, this function exists to allow activation to +* inline, but when enabling transaction support on a volume we +* cannot. Therefore, this function exists to allow activation to * be carried out asynchronously when enabling transactions. * * INPUT: FsmLite_s *fsm ; FSM state structure @@ -2139,7 +2109,7 @@ LONG UXChangeVolStateEnterCallBack (struct EventBlock *evBlk) data = (EventChangeVolStateEnter_s *)evBlk->EBEventData; - if ( (data->oldState == zVOLSTATE_ACTIVE) && + if ( (data->oldState == zVOLSTATE_ACTIVE) && (data->newState != zVOLSTATE_ACTIVE) ) { /* * we saw a change to deactivate, so check to see if this volume @@ -2157,11 +2127,11 @@ LONG UXChangeVolStateEnterCallBack (struct EventBlock *evBlk) vol->VOLenabledAttributes &= ~zATTR_USER_TRANSACTION_ACTIVE; shutdownVolumeXactionSupport(vol); UXactionVolumesActive--; - } + } COMN_Release(&vol); } - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return(SUCCESS); } @@ -2181,8 +2151,8 @@ LONG UXChangeVolStateEnterCallBack (struct EventBlock *evBlk) * OUTPUT: NONE * * SIDE -* EFFECTS: logfile replayed, new logfile created, UXMetaData inited, -* +* EFFECTS: logfile replayed, new logfile created, UXMetaData inited, +* * *******************************************************************************/ LONG UXChangeVolStateExitCallBack (struct EventBlock *evBlk) @@ -2204,7 +2174,7 @@ LONG UXChangeVolStateExitCallBack (struct EventBlock *evBlk) && (data->newState == zVOLSTATE_ACTIVE)) { /* * we saw a change to activate, so check to see if this volume - * is transactioned, and if so, start it up. We don't care if + * is transactioned, and if so, start it up. We don't care if * this fails, the TTS APIs will indicate whether TTS is enabled. * We should only fail to enable it if the volume doesn't support * TTS or NSS is going bad. @@ -2220,15 +2190,15 @@ LONG UXChangeVolStateExitCallBack (struct EventBlock *evBlk) } QuickExit: - MPKNSS_UNLOCK(); - return 0; + MPKNSS_UNLOCK(); + return 0; } Buffer_s *nextLogBuf ( GeneralMsg_s *genMsg, - Volume_s *vol, + Volume_s *vol, Buffer_s *logBuf, - Buffer_s *fileBuf, + Buffer_s *fileBuf, BOOL fileBufIsLatched) { UserXactionLogBuffer_s *bfrHdr; @@ -2237,7 +2207,7 @@ Buffer_s *nextLogBuf ( LONG blockNum; /* - * go to the next block. If we run into the "lastBlk" pointer, + * go to the next block. If we run into the "lastBlk" pointer, * the file is full and we abort the oldest xaction */ blockNum = vol->UXMetaData.curBlk + 1; @@ -2275,14 +2245,14 @@ Buffer_s *nextLogBuf ( CACHE_RELEASE(logBuf); UNX_LATCH( &vol->UXactionLogFileHandleIDP.ptr->dataStream->NAMEDbeastLatch); SetErrno(genMsg, zERR_TRANSACTION_LOG_FILE_OVERFLOW); - return NULL; + return NULL; } bfrHdr = (UserXactionLogBuffer_s*) &(logBuf->pBuf.data[0]); } /* * Get the next block */ - FILEBLK_IO_MSG(logFileIOMsg, vol->UXactionLogFileHandleIDP.ptr->dataStream, + FILEBLK_IO_MSG(logFileIOMsg, vol->UXactionLogFileHandleIDP.ptr->dataStream, blockNum, 1, CACHE_WRITE); newLogBuf = COMN_GetFileBlk(genMsg, &logFileIOMsg); @@ -2313,7 +2283,7 @@ Buffer_s *nextLogBuf ( errorExit: return newLogBuf; -} +} /* * WriteLog @@ -2324,13 +2294,13 @@ errorExit: */ STATUS WriteLog ( zNSSMsg_s *msg, - GeneralMsg_s *genMsg, - FileHandle_s *callerfh, - Xid_t xid, - QUAD fileByteOffset, - Buffer_s *fileBuf, - NINT byteCount, - BYTE *oldData, + GeneralMsg_s *genMsg, + FileHandle_s *callerfh, + Xid_t xid, + QUAD fileByteOffset, + Buffer_s *fileBuf, + NINT byteCount, + BYTE *oldData, BYTE *newData, QUAD originalEOF, NINT *residue) @@ -2344,7 +2314,7 @@ STATUS WriteLog ( Volume_s *vol; IoMsg_s logFileIOMsg; Buffer_s *logBuf; - Zid_t zid; + Zid_t zid; NINT logRecSize = sizeof(UserXactionLogRec_s) + byteCount; NINT remainder; GeneralMsg_s localGenMsg; @@ -2352,11 +2322,11 @@ STATUS WriteLog ( ENTER(TUSERX, WriteLog); - /* For a caller with an I/O message get the file handle from the message, + /* For a caller with an I/O message get the file handle from the message, * otherwise it was supplied in argument. */ if (msg != NULL) { - fh = (FileHandle_s *)msg->sys.door; + fh = (FileHandle_s *)msg->sys.door; } else { @@ -2366,8 +2336,8 @@ STATUS WriteLog ( zid = fh->file->FILEzid; /* logRecSize already accomodates the size of a header and one data block. - * This is the total size needed for a truncate buffer. If the operation is - * a write then newData will be non-NULL and we need additional space for a + * This is the total size needed for a truncate buffer. If the operation is + * a write then newData will be non-NULL and we need additional space for a * data block (one data block is required for the old data, one for the new). */ if (newData != NULL) { @@ -2377,12 +2347,12 @@ STATUS WriteLog ( /* If the caller has a message */ if (msg != NULL) { - /* Use the transaction ID in the message. The xid + /* Use the transaction ID in the message. The xid * argument is re-used as though it is a local */ xid = msg->body.id.xid; - /* The caller will not have supplied a general message, so - * re-use it to store the address of our local general message. + /* The caller will not have supplied a general message, so + * re-use it to store the address of our local general message. * This lets us use one identifier for all general message * uses. */ genMsg = &localGenMsg; @@ -2401,8 +2371,8 @@ STATUS WriteLog ( RTN_STATUS(zFAILURE); } - /* If the transaction is in the begin state we need to associate it with a - * volume, switch it to the active state and move its home record to the + /* If the transaction is in the begin state we need to associate it with a + * volume, switch it to the active state and move its home record to the * volume's home record list */ if (uxaction->state == BEGIN_UXACTION) { @@ -2410,9 +2380,9 @@ STATUS WriteLog ( uxaction->LogVolumeID = vol->volumeID; - /* If we are doing a write then WriteXactionMarker can wrap the log - * file. This might require a flush of the supplied buffer. The - * WriteXactionMarker function will pin the buffer supplied as the + /* If we are doing a write then WriteXactionMarker can wrap the log + * file. This might require a flush of the supplied buffer. The + * WriteXactionMarker function will pin the buffer supplied as the * third argument if it is non-NULL. */ status = WriteXactionMarker(LOGRECTYPE_BEGIN, uxaction, newData != NULL ? fileBuf : NULL); if (status != zOK) @@ -2462,10 +2432,10 @@ STATUS WriteLog ( { COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE(genMsg); } - FILEBLK_IO_MSG(logFileIOMsg, - vol->UXactionLogFileHandleIDP.ptr->dataStream, - vol->UXMetaData.curBlk, - 1, + FILEBLK_IO_MSG(logFileIOMsg, + vol->UXactionLogFileHandleIDP.ptr->dataStream, + vol->UXMetaData.curBlk, + 1, CACHE_UPDATE); X_LATCH( &vol->UXactionLogFileHandleIDP.ptr->dataStream->NAMEDbeastLatch); logBuf = COMN_GetFileBlk(genMsg, &logFileIOMsg); @@ -2546,7 +2516,7 @@ STATUS WriteLog ( logRec->originalEOF = originalEOF; logRec->xid = uxaction->xid; logRec->prevLogOffset = home->lastLogRec; - home->lastLogRec = + home->lastLogRec = vol->UXMetaData.curBlk * vol->UXMetaData.logFileBlockSize + vol->UXMetaData.insertOffset; logRec->byteCount = byteCount; bfrHdr->numLogRecs++; @@ -2555,13 +2525,13 @@ STATUS WriteLog ( /* now copy the old and, if not a truncate, the new data to the transaction log. */ - memcpy( + memcpy( logBuf->pBuf.data + vol->UXMetaData.insertOffset + sizeof(UserXactionLogRec_s), oldData, byteCount); if (newData != NULL) { - memcpy( + memcpy( logBuf->pBuf.data + vol->UXMetaData.insertOffset + sizeof(UserXactionLogRec_s) + byteCount, newData, @@ -2573,7 +2543,7 @@ STATUS WriteLog ( /* checksum this block so that it will be valid on a replay should the system crash */ - bfrHdr->checkSum = + bfrHdr->checkSum = makeBufferCheckSum((BYTE *)bfrHdr, vol->UXMetaData.logFileBlockSize); /* If we are handling a case involving changed user data */ @@ -2602,11 +2572,11 @@ UnlatchAndExit: /******************************************************************************* * NAME: WriteXactionMarker * -* FUNCTION: This function write marker records to the log file which +* FUNCTION: This function write marker records to the log file which * indicate start, end, and abort xaction points in the logfile. * * INPUT: NINT marker ;the enum code used for begin, commit, and abort -* UserXaction_s *uxaction ; pointer to the xaction that needs the +* UserXaction_s *uxaction ; pointer to the xaction that needs the * ; marker put in the logfile * * OUTPUT: STATUS ;success or failure of call @@ -2619,12 +2589,12 @@ UnlatchAndExit: *******************************************************************************/ STATUS WriteXactionMarker( - NINT marker, - UserXaction_s *uxaction, + NINT marker, + UserXaction_s *uxaction, Buffer_s *latchedBuf) { UserXactionLogBuffer_s *bfrHdr; - LONG blockNum; + LONG blockNum; GeneralMsg_s genMsg; Buffer_s *logBuf; IoMsg_s logFileIOMsg; @@ -2653,11 +2623,11 @@ STATUS WriteXactionMarker( /* read the active logFile block and pick up the appropriate metadata */ - FILEBLK_IO_MSG( - logFileIOMsg, + FILEBLK_IO_MSG( + logFileIOMsg, vol->UXactionLogFileHandleIDP.ptr->dataStream, vol->UXMetaData.curBlk, - 1, + 1, CACHE_UPDATE); X_LATCH( &vol->UXactionLogFileHandleIDP.ptr->dataStream->NAMEDbeastLatch); @@ -2669,7 +2639,7 @@ STATUS WriteXactionMarker( goto UnlatchAndExit; } mapBufferPage(logBuf); - + bfrHdr = (UserXactionLogBuffer_s*) &(logBuf->pBuf.data[0]); /* Check to see if we have sufficient space to hold this marker */ @@ -2677,7 +2647,7 @@ STATUS WriteXactionMarker( > vol->UXMetaData.logFileBlockSize) { /* * go to the next block. If we run into the "lastBlk" pointer, - * the file is full and we abort the uxaction + * the file is full and we abort the uxaction */ blockNum = (vol->UXMetaData.curBlk + 1 == vol->UXMetaData.logFileSizeInBlocks) ? 0 @@ -2706,7 +2676,7 @@ STATUS WriteXactionMarker( { UNX_LATCH( &vol->UXactionLogFileHandleIDP.ptr->dataStream->NAMEDbeastLatch); SetErrno(&genMsg, zERR_TRANSACTION_LOG_FILE_OVERFLOW); - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } logBuf = COMN_GetFileBlk(&genMsg, &logFileIOMsg); @@ -2722,11 +2692,11 @@ STATUS WriteXactionMarker( } /* Get a new block */ - FILEBLK_IO_MSG( - logFileIOMsg, - vol->UXactionLogFileHandleIDP.ptr->dataStream, - blockNum, - 1, + FILEBLK_IO_MSG( + logFileIOMsg, + vol->UXactionLogFileHandleIDP.ptr->dataStream, + blockNum, + 1, CACHE_WRITE); newLogBuf = COMN_GetFileBlk( &genMsg, &logFileIOMsg); @@ -2761,11 +2731,11 @@ STATUS WriteXactionMarker( /* fill in the data regarding this marker */ home = uxaction->homeXaction; - logRec = (UserXactionLogRec_s*) + logRec = (UserXactionLogRec_s*) ((BYTE*)&logBuf->pBuf.data[0] + vol->UXMetaData.insertOffset); logRec->LSN = SEQ_INC(vol->UXMetaData.lastLSN); logRec->prevLogOffset = home->lastLogRec; - home->lastLogRec = vol->UXMetaData.curBlk * vol->UXMetaData.logFileBlockSize + + home->lastLogRec = vol->UXMetaData.curBlk * vol->UXMetaData.logFileBlockSize + vol->UXMetaData.insertOffset; logRec->xid = uxaction->xid; @@ -2778,10 +2748,10 @@ STATUS WriteXactionMarker( /* checksum this block so that it will be valid on a replay should the system crash */ - bfrHdr->checkSum = + bfrHdr->checkSum = makeBufferCheckSum((BYTE *)bfrHdr, vol->UXMetaData.logFileBlockSize); - vol->UXMetaData.insertOffset += + vol->UXMetaData.insertOffset += ALIGN(sizeof(UserXactionLogRec_s), sizeof(NINT)); /* make sure log buffer flushes before freeing the transaction */ @@ -2834,13 +2804,13 @@ STATUS LogUserData ( for (;;) { status = WriteLog(msg, - NULL, - NULL, - zNILXID, - currentFileOffset, + NULL, + NULL, + zNILXID, + currentFileOffset, buffer, bytesToLog, - &(buffer->pBuf.data[blkOffset]), + &(buffer->pBuf.data[blkOffset]), &(((char *)msg->sys.data[RW_DATA].start)[bytesWritten]), originalEOF, &residue); @@ -2890,8 +2860,8 @@ STATUS LogUserData ( STATUS LogTruncateData ( GeneralMsg_s *genMsg, FileHandleIDP_s *fileHandleIDP, - QUAD truncatePos, - QUAD curEOF, + QUAD truncatePos, + QUAD curEOF, Xid_t xid) { STATUS status; @@ -2955,13 +2925,13 @@ STATUS LogTruncateData ( for (;;) { status = WriteLog(NULL, - genMsg, - fileHandleIDP->ptr, - xid, - curOffs, + genMsg, + fileHandleIDP->ptr, + xid, + curOffs, buffer, bytesToLog, - &(buffer->pBuf.data[blkOffset]), + &(buffer->pBuf.data[blkOffset]), NULL, curEOF, &residue); diff --git a/src/nwnss/comn/common/virtualIO.c b/src/nwnss/comn/common/virtualIO.c index b6ae872..df81b54 100644 --- a/src/nwnss/comn/common/virtualIO.c +++ b/src/nwnss/comn/common/virtualIO.c @@ -1,2 +1,2 @@ -#include +#include diff --git a/src/nwnss/comn/common/volBeast.c b/src/nwnss/comn/common/volBeast.c new file mode 100644 index 0000000..e818571 --- /dev/null +++ b/src/nwnss/comn/common/volBeast.c @@ -0,0 +1,2092 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1998 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: gpachner $ + | $Date: 2007-09-29 03:10:21 +0530 (Sat, 29 Sep 2007) $ + | + | $RCSfile$ + | $Revision: 2224 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This defines all of the primitive BEASTS inside of PSS + +-------------------------------------------------------------------------*/ +#include +#include /* NSS Library */ +#include +#include +#include +#include + +#include +#include + +#include "volume.h" +#include "msgGen.h" +#include "beastStartup.h" +#include "zParams.h" +#include "adminVolume.h" +#include "comnPublics.h" +#include "comnAuthorize.h" +#include "cmNSS.h" +#include "cmAlgoMan.h" +#include "cmControl.h" +#include "dirQuotas.h" +#include "pssStartup.h" +#include "xmlTags.h" +#include "objectIDStore.h" +#include "csa.h" +#include "nssPubs.h" +#include "mgmt.h" + + /* Check that sizes are still correct. Needed for our + * COMPILER_NO_INCOMPLETE_OFFSETOF compilers as they will not + * calculate items at compile time. + */ +BYTE CHECK_PersistentVolume_s_1[ (256 == sizeof(PersistentVolume_s)) ? 1 : 0 ]; +BYTE CHECK_LoggedPersistentVolume_s_1[ (128 == sizeof(LoggedPersistentVolume_s)) ? 1 : 0 ]; + +/* Volume attributes */ +QUAD volAttrBitsToCheck = ( + zATTR_SALVAGE | zATTR_USER_SPACE_RESTRICTIONS | zATTR_READONLY | zATTR_COMPRESSION | + zATTR_EXTENDED_ATTRIBUTES | zATTR_DATA_STREAMS | zATTR_DOS_METADATA | zATTR_NETWARE_METADATA | + zATTR_MAC_METADATA | zATTR_UNIX_METADATA | zATTR_HARD_LINKS | zATTR_TRANSACTION | + zATTR_SPARSE_FILES | zATTR_PHYSICAL_EOF | zATTR_DIRECT_IO | zATTR_PERSISTENT_ATTRIBUTES | + zATTR_VERIFY | zATTR_REBUILD | zATTR_COW | zATTR_VIRTUAL_FILES | + zATTR_USER_TRANSACTION | zATTR_USER_TRANSACTION_ACTIVE | zATTR_DONT_BACKUP | zATTR_MFL | + zATTR_DIR_QUOTAS | zATTR_SHRED_DATA | zATTR_SHARED | zATTR_HIGH_INTEGRITY | + zATTR_MIGRATION | zATTR_CFS_MASTER | zATTR_CFS_SLAVE | zATTR_ENCRYPTED | + zATTR_EXTENDED_MAC_NAMESPACE); + +utf8_t *volAttrTags[] = +{ + TAG_SALVAGE, + TAG_USERSPACERESTRICTIONS, + TAG_READONLY, + TAG_COMPRESSION, + + TAG_EXTENDEDATTRIBUTES, + TAG_DATASTREAMS, + TAG_DOSMETADATA, + TAG_NETWAREMETADATA, + + TAG_MACMETADATA, + TAG_UNIXMETADATA, + TAG_HARDLINKS, + TAG_TRANSACTION, + + TAG_SPARSEFILES, + TAG_PHYSICALEOF, + TAG_DIRECTIO, + TAG_PERSISTENTATTRIBUTES, + + TAG_VERIFY, + TAG_REBUILD, + TAG_SNAPSHOT, + TAG_VIRTUALFILES, + + TAG_USERTRANSACTION, + TAG_USERTRANSACTIONACTIVE, + TAG_DONTBACKUP, + TAG_MFL, + + TAG_DIRECTORYQUOTAS, + TAG_SHREDDATA, + TAG_SHARED, + TAG_HIGHINTEGRITY, + + TAG_MIGRATION, + TAG_CFSMASTER, + TAG_CFSSLAVE, + TAG_ENCRYPTED, + + TAG_EXTENDEDMACNAMESPACE, + 0, +}; + +NINT compFlagsBitsToCheck = ( + VOL_COMP_FLAGS_IMMEDIATE_COMPRESS | VOL_COMP_FLAGS_UPGRADE_START | VOL_COMP_FLAGS_UPGRADE_FINISHED); + +utf8_t *compFlagsTags[] = +{ + TAG_COMPFLAGSIMMEDIATECOMPRES, + "", + "", + "", + + "", + "", + "", + "", + + "", + "", + "", + "", + + "", + "", + TAG_COMPFLAGSUPGRADESTART, + TAG_COMPFLAGSUPGRADEFINISHED, + + 0, +}; + +/*========================================================================= + *========================================================================= + * BEAST OPERATIONS + *========================================================================= + *=========================================================================*/ + +/**************************************************************************** + * CONSTRUCTOR for VOLUMES + *****************************************************************************/ +STATUS VOL_BST_Construct( + GeneralMsg_s *genMsg, + void *vol_LX) +{ + Volume_s *vol = (Volume_s *)vol_LX; + vol->state = zVOLSTATE_UNKNOWN; + + INIT_LATCH( &vol->cvsLatch ); + INIT_LATCH( &vol->stateLatch ); + + vol->VOLroot.bstState |= BST_STATE_IS_VOLUME_OR_POOL; /* Flag as a volume */ + + zASSERT( sizeof( PersistentVolume_s ) == 256 ); + zASSERT( sizeof( LoggedPersistentVolume_s ) == 128 ); + +#if VOL_DISABLE_USE_SYSTEMS_WORK_TO_DO + fillInWork( &vol->v_disableWorkToDoStructure, vol_DisableWorkToDoRoutine, vol); +#else + FSMLITE_INIT( &vol->v_disableWorkToDoFsm /* Lite FSM */, + MSGNot("VOL Disable Work-To-Do"), 0 /* Instance */ ); +#endif + + DQ_INIT(&vol->v_alertList); +// vol->v_disableWorkToDoScheduled = 0; +// vol->v_alertListCount = 0; + FSMLITE_INIT( &vol->v_alertWorkToDoFsm /* Lite FSM */, + MSGNot("VOL Alert Work-To-Do"), 0 /* Instance */ ); + + + DQ_INIT(&vol->beastList); + CM_initVolumeRuntime(vol); + initAgent(&vol->agent, VOL_VolumeSignalHandler, MSGNot("Volume")); + + vol->decompFreeSpaceWarningTime = GetUTCTime(); + +#if 0 /* Removed because not fully inited until LSS's constructor is called. Defect 309900. */ + /* insert into Master Volume List*/ + SET_ENQ(&NSSMasterVolumeList,vol,masterVolLink); +#endif + return zOK; +} + +/**************************************************************************** + * DESTURCTOR for VOLUMES + *****************************************************************************/ +void VOL_BST_Destruct( + void *vol_LX) +{ + Volume_s *vol = (Volume_s *)vol_LX; + NSSVolumeAlert_s *alertInfo; + unicode_t *oldMemory; +#if NSS_ASSERT IS_ENABLED + NINT count; +#endif + + zASSERT( vol->state == zVOLSTATE_UNKNOWN ); + zASSERT(vol->rootdir == NULL); + zASSERT(DQ_EMPTY(&vol->beastList)); + + /* For some reason the volume is not latched when + * we enter this destructor. This is not normal + * for destructors. But anyway, if this changes + * then the commented out code that unlatches and + * then re-latches needs to be re-added. + * May 1998 - Greg Pachner + */ + ASSERT_NOLATCH( &vol->VOLbeastLatch ); + + /* We can still have a work-to-do scheduled. If so wait + * for it to complete before we allow the Volume beast to + * disappear on the work-to-do. + */ + WARN( !(vol->v_statusFlag & VOL_SF_DISABLE_THREAD_SCHEDULED) ); +#if NSS_ASSERT IS_ENABLED + count = 0; +#endif + + while ( vol->v_statusFlag & VOL_SF_DISABLE_THREAD_SCHEDULED ) + { /* + * Delay to give Work-to-do time to run. We do not do a yield + * because no documentation on work-to-do priority and no info + * on if yield lets 'lower' (less important) threads run. We + * could add cancel code, but this code will work and cancel + * could return a error anyway. We unlatch because the work-to-do + * will need to obtain to do a checkpoint. + */ + +// UNX_LATCH( &vol->VOLbeastLatch ); + LB_delay( 40 ); /* 40 millisecs */ +// X_LATCH( &vol->VOLbeastLatch ); + +#if NSS_ASSERT IS_ENABLED + ++count; /* Not in ASSERT macro just in case of side-effects */ +#endif + /* If we have been doing this for 15 secs then ASSERT */ + zASSERT( count < ((15 * 1000)/40) ); + } + + /* Clean off all the items on the ALERT Queue */ + + DQ_DEQ(&vol->v_alertList, alertInfo, NSSVolumeAlert_s, nva_alertList); + while ( alertInfo != NULL ) + { + --vol->v_alertListCount; + LB_free( alertInfo ); + alertInfo = NULL; + + DQ_DEQ(&vol->v_alertList, alertInfo, NSSVolumeAlert_s, nva_alertList); + } + + +#if NSS_ASSERT IS_ENABLED + count = 0; +#endif + + while ( vol->v_statusFlag & VOL_SF_ALERT_THREAD_SCHEDULED ) + { /* + * Delay to give Work-to-do time to run. We do not do a yield + * because no documentation on work-to-do priority and no info + * on if yield lets 'lower' (less important) threads run. We + * could add cancel code, but this code will work and cancel + * could return a error anyway. We unlatch because the work-to-do + * will need to obtain to do a checkpoint. + */ + +// UNX_LATCH( &vol->VOLbeastLatch ); + LB_delay( 40 ); /* 40 millisecs */ +// X_LATCH( &vol->VOLbeastLatch ); + +#if NSS_ASSERT IS_ENABLED + ++count; /* Not in ASSERT macro just in case of side-effects */ +#endif + /* If we have been doing this for 15 secs then ASSERT */ + zASSERT( count < ((15 * 1000)/40) ); + } + + /** ZLSS has been changed to remove the volume from the master + * list once ZLSS commits to unloading the volume. This prevents + * other threads from doing a CVS on the volume to remove the volume + * from UNKNOWN state. This was done when LVs where added because + * LVs are unloaded seperately from the pool sometimes. For example, + * when a LV is deleted. + */ + if (QMEMBER(&vol->masterVolLink)) + { +#if NSS_DEBUG IS_ENABLED + if (( COMN_IsDerivedFrom(vol, zFTYPE_ZLSS_VOL) ) || + ( COMN_IsDerivedFrom(vol, zFTYPE_XLSS_VOLUME) ) ) + { + zASSERT( "ZLSS/XLSS Volume found on Master Volume List" == NULL ); + } +#endif + SET_RMV(vol,masterVolLink); + } +#if NSS_DEBUG IS_ENABLED + else + { + if (( !COMN_IsDerivedFrom(vol, zFTYPE_ZLSS_VOL) ) && + ( !COMN_IsDerivedFrom(vol, zFTYPE_XLSS_VOLUME) ) ) + { + zASSERT( "Volume not found on Master Volume List" == NULL ); + } + } +#endif + + if (vol->v_csaVolInfo != NULL) + { + CANCEL_ALARM(vol->v_csaVolInfo->CVI_volumeStatsUpdateTimer); + free(vol->v_csaVolInfo); + vol->v_csaVolInfo = NULL; + } + /* 'free' releases spinlock so NULL pointer first */ + oldMemory = vol->v_volumeName; + vol->v_volumeName = NULL; + free( oldMemory ); + +} + +/**************************************************************************** + * This function returns volume specific info about a volume beast + *****************************************************************************/ +STATIC STATUS VOL_BST_GetInfo( + GeneralMsg_s *genMsg, + RootBeast_s *volume_LX, + GetInfoMsg_s *infoMsg) +{ + Volume_s *volume = (Volume_s *)volume_LX; + zVolumeInfo_s *volInfo; + statusfunc_t derivedFromGetInfo; + QUAD adjustmentInBytes; + +/*--------------------------------------------------------------------------- + * First, call the generic file information routine and fill in any + * requested generic information. If it fails, do not continue... + *---------------------------------------------------------------------------*/ + derivedFromGetInfo = COMN_GetNextParentBeastComnOp(volume->VOLbeastClass, + COMNOPS_INDEX(BST_getInfo),VOL_BST_GetInfo); + if (derivedFromGetInfo(genMsg,volume,infoMsg) != zOK) + return(zFAILURE); +/*--------------------------------------------------------------------------- + * Now, if the caller requested, fill in any volume specific information + *---------------------------------------------------------------------------*/ + if ((volInfo = infoMsg->ret_getTypeInfo) == NULL) + return(zOK); /* No info requeted */ + + if (infoMsg->sizeRetGetTypeInfo < sizeof(zVolumeInfo_s)) + { + SetErrno(genMsg,zERR_BUFFER_TOO_SMALL); + return(zFAILURE); + } +/*--------------------------------------------------------------------------- + * Fill in generic volume info + *---------------------------------------------------------------------------*/ + volInfo->volumeID = volume->VOLvolumeID; + volInfo->volumeState = volume->state; + volInfo->features.supported = volume->VOLsupportedAttributes; + volInfo->features.enabled = volume->VOLenabledAttributes; + volInfo->maximumFileSize = volume->VOLmaximumFileSize; + volInfo->authModelID = volume->VOLauthModelID; + volInfo->dataShreddingCount = volume->VOLshredCount; + volInfo->nameSpaceMask = volume->VOLnameSpaceMask; + volInfo->totalSpaceQuota = ((QUAD)volume->VOLtotalBlocks) << volume->VOLblockShift; + volInfo->numUsedBytes = ((QUAD)volume->VOLinUseBlocks) << volume->VOLblockShift; + adjustmentInBytes = (QUAD)volume->VOLfreeBlockAdjustment << volume->VOLblockShift; + volInfo->numUsedBytes += adjustmentInBytes; + + volInfo->numObjects = volume->VOLnumObjects; + volInfo->numFiles = volume->VOLnumFiles; + volInfo->ndsObjectID = volume->VOLndsObjectID; + + /* Get compression-related statistics */ + if (volume->VOLenabledAttributes & zATTR_COMPRESSION) + { + volInfo->comp.numCompressedFiles = volume->VOLnumCompressedFiles; + volInfo->comp.numCompDelFiles = volume->VOLnumCompDelFiles; + volInfo->comp.numUncompressibleFiles = volume->VOLnumUncompressibleFiles; + volInfo->comp.numPreCompressedBytes = + volume->VOLnumPreCompressedFileBlocks << volume->VOLblockShift; + volInfo->comp.numCompressedBytes = + volume->VOLnumCompressedFileBlocks << volume->VOLblockShift; + } + else + { + volInfo->comp.numCompressedFiles = 0; + volInfo->comp.numCompDelFiles = 0; + volInfo->comp.numUncompressibleFiles = 0; + volInfo->comp.numPreCompressedBytes = 0; + volInfo->comp.numCompressedBytes = 0; + } + +/*--------------------------------------------------------------------------- + * Fill in any requested type specific info + *---------------------------------------------------------------------------*/ + if (infoMsg->getTypeInfoMask) + { + if (infoMsg->getTypeInfoMask & zGET_VOL_SALVAGE_INFO) + { + volInfo->salvage.purgeableBytes = + volume->VOLpurgeableBlocks << volume->VOLblockShift; + volInfo->salvage.nonPurgeableBytes = + volume->VOLnonPurgeableBlocks << volume->VOLblockShift; + volInfo->salvage.numDeletedFiles = volume->VOLnumDeletedFiles; + volInfo->salvage.oldestDeletedTime = INVALID_UTC_TIME; /* Filled in by LSS */ + volInfo->salvage.minKeepSeconds = volume->VOLminKeepSeconds; + volInfo->salvage.maxKeepSeconds = volume->VOLmaxKeepSeconds; + volInfo->salvage.lowWaterMark = volume->VOLlowWaterMark; + volInfo->salvage.highWaterMark = volume->VOLhighWaterMark; + } + } + return(zOK); +} + +/**************************************************************************** + * this returns information about the beast in XML string format + *****************************************************************************/ +STATUS VOL_BST_GetInfoXML( + GeneralMsg_s *genMsg, + RootBeast_s *rBeast, + NINT typeOfInfo, + NINT bufLen, + utf8_t *buf, + NINT *infoLen) +{ + Volume_s *volume = (Volume_s *)rBeast; + STATUS status = zOK; + NINT len = 0; + NINT tmpLen; + typedef struct Stack_s{ + utf8_t tmpBuf[4096]; + } Stack_s; + Stack_s *aStack; + + /* Volume_s is the base of all volume types, don't call parent routine */ + + /* can expand to something else later */ + if (!(typeOfInfo & (BST_INFO_VOLUME_SIMPLE | BST_INFO_VOLUME_FULL))) + { + return zOK; + } + + STACK_ALLOC_NO_ASTACK(); + + bufLen -= *infoLen; + + if (typeOfInfo & BST_INFO_VOLUME_SIMPLE) + { + strcpy(&aStack->tmpBuf[len], "<"TAG_VOLUMEBEASTINFOSIMPLE">"); + } + else + { + strcpy(&aStack->tmpBuf[len], "<"TAG_VOLUMEBEASTINFOFULL">"); + } + len += strlen(&aStack->tmpBuf[len]); + + sprintf(&aStack->tmpBuf[len], "<"TAG_PERSISTENTVOLUME">" + "<"TAG_BLOCKSIZE">%u" + "<"TAG_NAMESPACEMASK">%u" + "<"TAG_MINKEEPTIME">%u" + "<"TAG_MAXKEEPTIME">%u" + "<"TAG_LOWWATERMARK">%u" + "<"TAG_HIGHWATERMARK">%u", + volume->VOLblockSize, + volume->VOLnameSpaceMask, + volume->VOLminKeepSeconds, + volume->VOLmaxKeepSeconds, + volume->VOLlowWaterMark, + volume->VOLhighWaterMark); + len += strlen(&aStack->tmpBuf[len]); + + sprintf(&aStack->tmpBuf[len], "<"TAG_ENABLEDATTRIBUTES">"); + len += strlen(&aStack->tmpBuf[len]); + + if ((status = MNSS_ConvertBitsToTags((QUAD)volume->VOLenabledAttributes, + (QUAD)volAttrBitsToCheck, + volAttrTags, bufLen - len, &aStack->tmpBuf[len], + &tmpLen)) != zOK) + { + goto Exit; + } + + sprintf(&aStack->tmpBuf[len], ""); + len += strlen(&aStack->tmpBuf[len]); + + sprintf(&aStack->tmpBuf[len], "<"TAG_COMPATTRIBUTES"><"TAG_COMPFLAGS">"); + len += strlen(&aStack->tmpBuf[len]); + + if ((status = MNSS_ConvertBitsToTags((QUAD)volume->VOLcompAttributes.compFlags, + (QUAD)compFlagsBitsToCheck, + compFlagsTags, bufLen - len, &aStack->tmpBuf[len], + &tmpLen)) != zOK) + { + goto Exit; + } + + sprintf(&aStack->tmpBuf[len], ""); + len += strlen(&aStack->tmpBuf[len]); + + sprintf(&aStack->tmpBuf[len], ""); + len += strlen(&aStack->tmpBuf[len]); + + sprintf(&aStack->tmpBuf[len], "<"TAG_LOGGEDPERSISTENTVOLUME">" + "<"TAG_NEXTZID">%Lu" + "<"TAG_TOTALFILES">%Lu" + "<"TAG_TOTALOBJECTS">%Lu" + "<"TAG_TOTALBLOCKS">%Lu" + "<"TAG_INUSEBLOCKS">%Lu" + "<"TAG_PURGEABLEBLOCKS">%Lu" + "<"TAG_NONPURGEABLEBLOCKS">%Lu", + volume->VOLnextZid, + volume->VOLnumFiles, + volume->VOLnumObjects, + volume->VOLtotalBlocks, + volume->VOLinUseBlocks, + volume->VOLpurgeableBlocks, + volume->VOLnonPurgeableBlocks); + len += strlen(&aStack->tmpBuf[len]); + + sprintf(&aStack->tmpBuf[len], + "<"TAG_DELETEDFILES">%Lu" + "<"TAG_RENAMESEQNUM">%u" + "<"TAG_COMPRESSEDFILES">%Lu" + "<"TAG_COMPRESSEDDELETEDFILES">%Lu" + "<"TAG_UNCOMPRESSIBLEFILES">%Lu" + "<"TAG_COMPRESSEDBLOCKS">%Lu" + "<"TAG_PRECOMPRESSIONBLOCKS">%Lu" + "<"TAG_EPOCH">%u" + "", + volume->VOLnumDeletedFiles, + volume->VOLrenameSeqNum, + volume->VOLnumCompressedFiles, + volume->VOLnumCompDelFiles, + volume->VOLnumUncompressibleFiles, + volume->VOLnumCompressedFileBlocks, + volume->VOLnumPreCompressedFileBlocks, + volume->VOLepoch); + len += strlen(&aStack->tmpBuf[len]); + + + // fill in state info + strcpy(&aStack->tmpBuf[len], "<"TAG_VOLUMESTATE">"); + len += strlen(&aStack->tmpBuf[len]); + switch (volume->state) + { + case zVOLSTATE_UNKNOWN: + default: + strcpy(&aStack->tmpBuf[len], "unknown"); + break; + + case zVOLSTATE_DEACTIVE: + strcpy(&aStack->tmpBuf[len], "deactive"); + break; + + case zVOLSTATE_MAINTENANCE: + strcpy(&aStack->tmpBuf[len], "maintenance"); + break; + + case zVOLSTATE_ACTIVE: + strcpy(&aStack->tmpBuf[len], "active"); + break; + } + len += strlen(&aStack->tmpBuf[len]); + + strcpy(&aStack->tmpBuf[len], ""); + len += strlen(&aStack->tmpBuf[len]); + + if (typeOfInfo & BST_INFO_VOLUME_SIMPLE) + { + strcpy(&aStack->tmpBuf[len], ""); + } + else + { + strcpy(&aStack->tmpBuf[len], ""); + } + len += strlen(&aStack->tmpBuf[len]); + + if ((len + 1)> bufLen) + { + SetErrno(genMsg, zERR_BUFFER_TOO_SMALL); + status = zFAILURE; + } + else + { + strcpy(&buf[*infoLen], aStack->tmpBuf); + *infoLen += len; + } + +Exit: + STACK_FREE(); + + + return status; +} + + +/**************************************************************************** + * This function modifies metadata information for a file beast object + *****************************************************************************/ +STATUS VOL_BST_ModifyInfo( + GeneralMsg_s *genMsg, + RootBeast_s *volume_LX, + ModifyInfoMsg_s *modifyMsg, + Xaction_s *xaction) /* Optional xaction, may be NULL */ +{ + Volume_s *volume = (Volume_s *)volume_LX; + zVolumeInfo_s *volInfo; + statusfunc_t derivedFromModifyInfo; +/*--------------------------------------------------------------------------- + * First, call the generic file information routine and modify any + * requested generic information. If it fails, do not continue... + *---------------------------------------------------------------------------*/ + derivedFromModifyInfo = COMN_GetNextParentBeastComnOp(volume->VOLbeastClass, + COMNOPS_INDEX(BST_modifyInfo),VOL_BST_ModifyInfo); + if (derivedFromModifyInfo(genMsg,volume,modifyMsg,xaction) != zOK) + return(zFAILURE); +/*--------------------------------------------------------------------------- + * Now, if the caller requested, modify any volume specific information + *---------------------------------------------------------------------------*/ + if ((volInfo = modifyMsg->modifyTypeInfo) == NULL) + { + return(zOK); /* No type specific volume info to be modified */ + } + + if (modifyMsg->modifyTypeInfoMask) + { + if (volume->VOLmayIDoThis(genMsg, volume, modifyMsg->parentZid, + MAY_I_SUPERVISE) != zOK) + { + SetErrno(genMsg,zERR_NO_SET_PRIVILEGE); + return(zFAILURE); + } + + if (modifyMsg->modifyTypeInfoMask & zMOD_VOL_ATTRIBUTES) + { +/* + * Fix for SPDs #208079, #208082 and #208083. + * Volume attributes can only be modified by the LSS modules. They are the + * modules which control whether or not certain features are implemented, + * so they are the modules which must decide whether to allow a specific + * attribute to be modified on the volume + */ +/* volume->VOLvolAttributes = volInfo->volumeAttributes; */ + /* + * Turning volume compression ON: + * Perform generic volume compression management startup + * before LSS does any processing, so that if the generic startup + * encounters an error, we have less cleanup to do. + */ + if ((volInfo->features.enableModMask & zATTR_COMPRESSION) && + (!(volume->VOLenabledAttributes & zATTR_COMPRESSION)) && + (volInfo->features.enabled & zATTR_COMPRESSION)) + { + STATUS rc; + + CM_initVolumeCompState(volume); + + /* This is logically true in this function because + * from modifyInfo's point of view, there shouldn't be any + * compression files exist at all at this moment, so if VOL_COMP_FLAGS_UPGRADE_START + * is set, then VOL_COMP_FLAGS_UPGRADE_FINISHED should be set, too. + */ + if (volume->VOLcompAttributes.compFlags & VOL_COMP_FLAGS_UPGRADE_START) + { + volume->VOLcompAttributes.compFlags |= VOL_COMP_FLAGS_UPGRADE_FINISHED; + } + + + rc = CM_volumeActivate(volume); + if (rc != zOK) + { + SetErrno(genMsg, rc); + volInfo->features.enabled &= ~zATTR_COMPRESSION; + } + } + + /* + * User space restrictions + */ + if ((volInfo->features.enableModMask & + zATTR_USER_SPACE_RESTRICTIONS) && + ((volInfo->features.enabled & zATTR_USER_SPACE_RESTRICTIONS) != + (volume->VOLenabledAttributes & + zATTR_USER_SPACE_RESTRICTIONS))) + { + if (!(volume->VOLsupportedAttributes & + zATTR_USER_SPACE_RESTRICTIONS)) + { + SetErrno(genMsg, zERR_VOLUME_STATE_NOT_SUPPORTED); + return zFAILURE; + } + + if (volume->VOLenabledAttributes & zATTR_READONLY) + { + SetErrno(genMsg, zERR_VOLUME_READ_ONLY); + return zFAILURE; + } + + /* Free any disk restriction structures that may exist */ + if (VOL_DisableUserSpaceRestrictions(genMsg, volume) != zOK) + { + return zFAILURE; + } + + /* + * The actual initialization of the user restrictions must + * be kicked off by the LSS modify info since the structures + * needed may not exist until the LSS gets a crack at this + * operation. + */ + } + + /* + * Directory quotas + */ + if ((volInfo->features.enableModMask & zATTR_DIR_QUOTAS) && + ((volInfo->features.enabled & zATTR_DIR_QUOTAS) != + (volume->VOLenabledAttributes & zATTR_DIR_QUOTAS))) + { + if (!(volume->VOLsupportedAttributes & zATTR_DIR_QUOTAS)) + { + SetErrno(genMsg, zERR_VOLUME_STATE_NOT_SUPPORTED); + return zFAILURE; + } + + if (volume->VOLenabledAttributes & zATTR_READONLY) + { + SetErrno(genMsg, zERR_VOLUME_READ_ONLY); + return zFAILURE; + } + + /* + * Free any directory quota structures that may exist. We + * do this even on an enable just to make sure things are + * clean. + */ + DIRQ_DisableDirectoryQuotas(volume); + } + } + + if (modifyMsg->modifyTypeInfoMask & zMOD_VOL_NDS_OBJECT_ID) + { + /* FixFixFix6(Later) Mike, do something here to make this + * persistent for ALL volumes. Currently, only ZLSS + * will make persistent via it ZLSS VOL modify info + * routine. + */ + volume->VOLndsObjectID = volInfo->ndsObjectID; + OID_SaveObjectID(volume, &volume->VOLndsObjectID); + } + } + + return(zOK); +} + +/** + * Ying - March 4, 2004 + * NOTE: This function is provided for convinence, although I did my best + * to ensure its correctness, it's not fully tested + */ +STATUS VOL_BST_ModifyInfoXML( + GeneralMsg_s *genMsg, + RootBeast_s *rBeast, + NINT bufLen, + utf8_t *buf, + Xaction_s *xaction, + BOOL doChange) +{ + STATUS status = zOK; + Volume_s *volume = (Volume_s *)rBeast; + XML_ElementInfo_s elementInfo; + utf8_t *copyBuf = NULL; + + const TagRequest_s tags[] = + { + {TAG_PERSISTENTVOLUME, TR_OPTIONAL}, + {TAG_LOGGEDPERSISTENTVOLUME, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags) - 1]; + + enum + { + PERSISTENT_VOLUME = 0, + LOGGED_PERSISTENT_VOLUME = 1, + }; + + + /* Volume_s is the base of all volume types, don't call parent routine */ + + /* make another copy of buf, buf will be changed + * while doing MNSS_GetTagContents + */ + copyBuf = malloc(bufLen); + if (copyBuf == NULL) + { + SetErrno(genMsg, zERR_NO_MEMORY); + return zFAILURE; + } + memcpy(copyBuf, buf, bufLen); + + /* Fixfixfix, it only processes TAG_VOLUMEBEASTINFOSIMPLE, + * somebody can add code to process TAG_VOLUMEBEASTINFOFULL if needed + */ + + if (XML_GetTagElement(TAG_VOLUMEBEASTINFOSIMPLE, copyBuf, copyBuf + bufLen - 1, + &elementInfo) == zFAILURE) + { + // No namedBeast related info needs to be modified + status = zOK; + goto Exit; + } + + if (elementInfo.dataStart == NULL) + { + // no actual data + status = zOK; + goto Exit; + } + + if ((status = MNSS_GetTagContents(NULL, NULL, &elementInfo, tags, tagContent)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto Exit; + } + + /* + * modify persistent data + */ + + if (tagContent[PERSISTENT_VOLUME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + const TagRequest_s persistentTags[] = + { + {TAG_BLOCKSIZE, TR_OPTIONAL}, + {TAG_NAMESPACEMASK, TR_OPTIONAL}, + {TAG_MINKEEPTIME, TR_OPTIONAL}, + {TAG_MAXKEEPTIME, TR_OPTIONAL}, + {TAG_LOWWATERMARK, TR_OPTIONAL}, + {TAG_HIGHWATERMARK, TR_OPTIONAL}, + {TAG_ENABLEDATTRIBUTES, TR_OPTIONAL}, + {TAG_COMPATTRIBUTES, TR_OPTIONAL}, + {0} + }; + TagContent_s persistentContent[NELEMS(persistentTags) - 1]; + + enum + { + BLK_SIZE = 0, + NAME_SPACE_MASK = 1, + MIN_KEEP_TIME = 2, + MAX_KEEP_TIME = 3, + LOW_WATER_MARK = 4, + HIGH_WATER_MARK = 5, + ENABLED_ATTRIBUTES = 6, + COMP_ATTRIBUTES = 7 + }; + + if ((status = MNSS_GetTagContents(NULL, NULL, &tagContent[PERSISTENT_VOLUME].element, + persistentTags, persistentContent)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto Exit; + } + + if (persistentContent[BLK_SIZE].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, LONG, FALSE, (ADDR)&volume->VOLblockSize, + &persistentContent[BLK_SIZE].element); + } + + if (persistentContent[NAME_SPACE_MASK].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, LONG, FALSE, (ADDR)&volume->VOLnameSpaceMask, + &persistentContent[NAME_SPACE_MASK].element); + } + + if (persistentContent[MIN_KEEP_TIME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, LONG, FALSE, (ADDR)&volume->VOLminKeepSeconds, + &persistentContent[MIN_KEEP_TIME].element); + } + + if (persistentContent[MAX_KEEP_TIME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, LONG, FALSE, (ADDR)&volume->VOLmaxKeepSeconds, + &persistentContent[MAX_KEEP_TIME].element); + } + + + if (persistentContent[LOW_WATER_MARK].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, LONG, FALSE, (ADDR)&volume->VOLlowWaterMark, + &persistentContent[LOW_WATER_MARK].element); + } + + if (persistentContent[HIGH_WATER_MARK].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, LONG, FALSE, (ADDR)&volume->VOLhighWaterMark, + &persistentContent[HIGH_WATER_MARK].element); + } + + if (persistentContent[ENABLED_ATTRIBUTES].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyFlagsInfoXML(genMsg, volume, QUAD, (ADDR)&volume->VOLenabledAttributes, + &persistentContent[ENABLED_ATTRIBUTES].element, + (QUAD)volAttrBitsToCheck, (utf8_t **)volAttrTags, + NULL); + } + + if (persistentContent[COMP_ATTRIBUTES].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyFlagsInfoXML(genMsg, volume, LONG, (ADDR)&volume->VOLcompAttributes.compFlags, + &persistentContent[COMP_ATTRIBUTES].element, + (QUAD)compFlagsBitsToCheck, (utf8_t **)compFlagsTags, + NULL); + } + } + + if (tagContent[LOGGED_PERSISTENT_VOLUME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + const TagRequest_s loggedTags[] = + { + {TAG_NEXTZID, TR_OPTIONAL}, + {TAG_TOTALFILES, TR_OPTIONAL}, + {TAG_TOTALOBJECTS, TR_OPTIONAL}, + {TAG_TOTALBLOCKS, TR_OPTIONAL}, + {TAG_INUSEBLOCKS, TR_OPTIONAL}, + {TAG_PURGEABLEBLOCKS, TR_OPTIONAL}, + {TAG_NONPURGEABLEBLOCKS, TR_OPTIONAL}, + {TAG_DELETEDFILES, TR_OPTIONAL}, + {TAG_RENAMESEQNUM, TR_OPTIONAL}, + {TAG_COMPRESSEDFILES, TR_OPTIONAL}, + {TAG_COMPRESSEDDELETEDFILES, TR_OPTIONAL}, + {TAG_UNCOMPRESSIBLEFILES, TR_OPTIONAL}, + {TAG_COMPRESSEDBLOCKS, TR_OPTIONAL}, + {TAG_PRECOMPRESSIONBLOCKS, TR_OPTIONAL}, + {TAG_EPOCH, TR_OPTIONAL}, + {0} + }; + TagContent_s loggedContent[NELEMS(loggedTags) - 1]; + + enum + { + NEXT_ZID = 0, + TOTAL_FILES = 1, + TOTAL_OBJECTS = 2, + TOTAL_BLOCKS = 3, + IN_USE_BLOCKS = 4, + PURGEABLE_BLOCKS = 5, + NON_PURGEABLE_BLOCKS = 6, + DELETED_FILES = 7, + RENAME_SEQ_NUM = 8, + COMPRESSED_FILES = 9, + COMPRESSED_DELETED_FILES = 10, + UNCOMPRESSIBLE_FILES = 11, + COMPRESSED_BLOCKS = 12, + PRE_COMPRESSED_BLOCKS = 13, + EPOCH = 14 + }; + + if ((status = MNSS_GetTagContents(NULL, NULL, &tagContent[LOGGED_PERSISTENT_VOLUME].element, + loggedTags, loggedContent)) != zOK) + { + SetErrno(genMsg, status); + status = zFAILURE; + goto Exit; + } + + if (loggedContent[NEXT_ZID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, QUAD, FALSE, (ADDR)&volume->VOLnextZid, + &loggedContent[NEXT_ZID].element); + } + + if (loggedContent[TOTAL_FILES].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, QUAD, FALSE, (ADDR)&volume->VOLnumFiles, + &loggedContent[TOTAL_FILES].element); + } + + if (loggedContent[TOTAL_OBJECTS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, QUAD, FALSE, (ADDR)&volume->VOLnumObjects, + &loggedContent[TOTAL_OBJECTS].element); + } + + if (loggedContent[TOTAL_BLOCKS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, QUAD, FALSE, (ADDR)&volume->VOLtotalBlocks, + &loggedContent[TOTAL_BLOCKS].element); + } + + if (loggedContent[IN_USE_BLOCKS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, QUAD, FALSE, (ADDR)&volume->VOLinUseBlocks, + &loggedContent[IN_USE_BLOCKS].element); + } + + if (loggedContent[PURGEABLE_BLOCKS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, QUAD, FALSE, (ADDR)&volume->VOLpurgeableBlocks, + &loggedContent[PURGEABLE_BLOCKS].element); + } + + if (loggedContent[NON_PURGEABLE_BLOCKS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, QUAD, FALSE, (ADDR)&volume->VOLnonPurgeableBlocks, + &loggedContent[NON_PURGEABLE_BLOCKS].element); + } + + if (loggedContent[DELETED_FILES].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, QUAD, FALSE, (ADDR)&volume->VOLnumDeletedFiles, + &loggedContent[DELETED_FILES].element); + } + + if (loggedContent[RENAME_SEQ_NUM].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, LONG, FALSE, (ADDR)&volume->VOLrenameSeqNum, + &loggedContent[RENAME_SEQ_NUM].element); + } + + if (loggedContent[COMPRESSED_FILES].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, QUAD, FALSE, (ADDR)&volume->VOLnumCompressedFiles, + &loggedContent[COMPRESSED_FILES].element); + } + + if (loggedContent[COMPRESSED_DELETED_FILES].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, QUAD, FALSE, (ADDR)&volume->VOLnumCompDelFiles, + &loggedContent[COMPRESSED_DELETED_FILES].element); + } + + if (loggedContent[UNCOMPRESSIBLE_FILES].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, QUAD, FALSE, (ADDR)&volume->VOLnumUncompressibleFiles, + &loggedContent[UNCOMPRESSIBLE_FILES].element); + } + + if (loggedContent[COMPRESSED_BLOCKS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, QUAD, FALSE, (ADDR)&volume->VOLnumCompressedFileBlocks, + &loggedContent[COMPRESSED_BLOCKS].element); + } + + if (loggedContent[PRE_COMPRESSED_BLOCKS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, QUAD, FALSE, (ADDR)&volume->VOLnumPreCompressedFileBlocks, + &loggedContent[PRE_COMPRESSED_BLOCKS].element); + } + + if (loggedContent[EPOCH].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + modifyInfoNumber(genMsg, volume, LONG, FALSE, (ADDR)&volume->VOLepoch, + &loggedContent[EPOCH].element); + } + } + + status = zOK; +Exit: + free(copyBuf); + + return status; +} + + + /*** The VOL_CVS_xxx defines specify when the COMN layer + *** does certain things in CVS. These value MUST not change as + *** LSSes are deciding which passes to do thing based on + *** when the COMN layer does things! + ***/ + +#define VOL_CVS_DEACTIVATE 3 +#define VOL_CVS_ACTIVATE 7 +#define VOL_CVS_MAINTENANCE_TO_ACTIVE 7 +#define VOL_CVS_ACTIVE_TO_MAINTENANCE 3 + +#if VOL_CVS_DEACTIVATE != 3 +#error ZLSSPOOL_DEACTIVATE_CLEANUP_LV_DELETES must be before VOL_CVS_DEACTIVATE +#endif + +/*========================================================================= + *========================================================================= + * VOLUME OPERATIONS + *========================================================================= + *=========================================================================*/ + +/**************************************************************************** + * + *****************************************************************************/ +STATUS VOL_VOL_SetMatchAttributesInDirectory( + GeneralMsg_s *genMsg, + NamedBeast_s *beast, + NamedBeast_s *directory, + NINT nameSpaceMask, + NINT nameType, + unicode_t *name, +// cnt NINT nameUniquifier, + NINT newMatchAttributes, + Xaction_s *xaction) +{ + /* This function is optional in the LSS implementations. If they don't + * override this function, it means they don't have a way to store + * match attributes in a directory record. If we come to this function + * it means the LSS didn't override this comnOP. + * If this is the case, we just ignore the OP. + */ + return(zOK); +} + +/************************************************************************** + * + ***************************************************************************/ +STATUS VOL_VOL_ChangeVolumeState( + GeneralMsg_s *genMsg, + void *vol_LX, + NINT sourceState, + NINT requestedState, + NINT mode, + NINT pass) +{ + Volume_s *vol = (Volume_s *)vol_LX; + STATUS status = zOK; + + switch (requestedState) + { +/*===========================================================================*/ + case zVOLSTATE_ACTIVE: + switch(sourceState) + { + case zVOLSTATE_ACTIVE: + return(zOK); + case zVOLSTATE_DEACTIVE: + if ( pass == VOL_CVS_ACTIVATE ) + { + status = VOL_Activate( genMsg, vol, mode ); + return( status ); + } + if ( pass == 9 ) // fixfixfix cnt how do I know pass 9 is correct? + { + vol->p.PV_activationTimeUTC = GetUTCTime(); + if((vol->VOLenabledAttributes & zATTR_ENCRYPTED) && (!(vol->v_statusFlag & VOL_SF_KEYPRESENT))) + { + if((status = COMN_EnableEncryptedVolume(vol)) != zOK) + { + ForceSetErrno(genMsg, status); + return zFAILURE; + } + } + } + return(zOK); + case zVOLSTATE_MAINTENANCE: + if ( pass == VOL_CVS_MAINTENANCE_TO_ACTIVE ) + { + status = VOL_Activate( genMsg, vol, mode ); + return( status ); + } + if ( pass == 9 ) + { + vol->p.PV_activationTimeUTC = GetUTCTime(); + } + return(zOK); + case zVOLSTATE_UNKNOWN: + SetErrno(genMsg,zERR_NOT_SUPPORTED); + return(zFAILURE); + default: + goto error_BadState; + } + break; +/*===========================================================================*/ + case zVOLSTATE_DEACTIVE: + switch (sourceState) + { + case zVOLSTATE_ACTIVE: + if ( pass == VOL_CVS_DEACTIVATE ) + { /* This does a flush and then toss */ + (void)VOL_Deactivate(genMsg, vol, mode); + if(vol->VOLenabledAttributes & zATTR_ENCRYPTED) + { + COMN_DisableEncryptedVolume(vol); + } + } + return(zOK); + case zVOLSTATE_DEACTIVE: + case zVOLSTATE_MAINTENANCE: + case zVOLSTATE_UNKNOWN: + return(zOK); + default: + goto error_BadState; + } + break; +/*===========================================================================*/ + case zVOLSTATE_MAINTENANCE: + switch(sourceState) + { + case zVOLSTATE_ACTIVE: + if ( pass == VOL_CVS_ACTIVE_TO_MAINTENANCE ) + { /* This does a flush and then toss */ + VOL_Deactivate(genMsg, vol, mode); + if(vol->VOLenabledAttributes & zATTR_ENCRYPTED) + { + COMN_DisableEncryptedVolume(vol); + } + } + return(zOK); + case zVOLSTATE_DEACTIVE: + return(zOK); + case zVOLSTATE_MAINTENANCE: + return(zOK); + + case zVOLSTATE_UNKNOWN: + SetErrno(genMsg,zERR_NOT_SUPPORTED); + return(zFAILURE); + default: + goto error_BadState; + } + break; +/*===========================================================================*/ + case zVOLSTATE_UNKNOWN: + switch(sourceState) + { + case zVOLSTATE_ACTIVE: + case zVOLSTATE_MAINTENANCE: + SetErrno(genMsg,zERR_NOT_SUPPORTED); + return(zFAILURE); + + case zVOLSTATE_DEACTIVE: + case zVOLSTATE_UNKNOWN: + return(zOK); + default: + goto error_BadState; + } + break; + } + +/*--------------------------------------------------------------------------- + * General error handling + *---------------------------------------------------------------------------*/ +error_BadState: + zASSERT("Unknown volume STATE requested"==0); + SetErrno(genMsg,zERR_INVALID_STATE); + return(zFAILURE); + +} + +/**************************************************************************** + * This initializes the Generic portion of the Storage Info structure + *****************************************************************************/ +STATIC STATUS VOL_VOL_allocStorageInfo( + GeneralMsg_s *genMsg, + RootBeast_s *beast) +{ + StorageInfo_s *stInfo = beast->storage.info; + + zASSERT(stInfo != NULL); + stInfo->beast = beast; + return zOK; +} + +/**************************************************************************** + * This frees the storage info structure + *****************************************************************************/ +STATIC void VOL_VOL_freeStorageInfo( + RootBeast_s *beast) +{ + free(beast->storage.info); + beast->storage.info = NULL; +} + +/**************************************************************************** + * This will allocate and return the next range of ZIDs for this volume. + * The return parameter is count of how many we got + *****************************************************************************/ +STATIC NINT VOL_VOL_AllocateZIDs( + GeneralMsg_s *genMsg, + Volume_s *vol, + NINT howMany, + Zid_t *retZID, + Xaction_s *xaction) +{ + ASSERT_XLATCH(&vol->VOLbeastLatch); + zASSERT((howMany > 0) && (howMany <= 4096)); + if (howMany > 0) + { + *retZID = vol->VOLnextZid; + vol->VOLnextZid += howMany; + COMN_MARK_BEAST_DIRTY(&vol->VOLroot); + } + return howMany; +} + + +/************************************************************************** + * This will do a flush of the system beasts of the volume (i.e. rootdir) + ***************************************************************************/ +STATUS VOL_VOL_FlushSystemBeasts( + GeneralMsg_s *genMsg, + void *vol_LX) +{ + Volume_s *vol = (Volume_s *)vol_LX; + if (vol->VOLenabledAttributes & zATTR_READONLY) + { + return zOK; + } + else + { +#if VOL_HAS_SYSTEM_BEASTS + return VOL_DoFlushSystemBeasts(genMsg,vol,FALSE); +#else + return zOK; +#endif + } +} + + +/**************************************************************************** + * This will attempt to free up space from the salvage system + *****************************************************************************/ +STATUS VOL_VOL_MakeVolumeFreeSpace( + GeneralMsg_s *genMsg, + void *volume_LX, + BOOL purgeAllDeletedFiles, + BOOL asyncPurge, + QUAD numberOfBlocks) +{ + /* This function is here as a catch-all. If a volume supports salvage, + * it must override this OP */ + SetErrno(genMsg,zERR_OUT_OF_SPACE); + return(zFAILURE); +} + +/**************************************************************************** + * This function returns the Zids of the next numBeastsRequested beasts + *****************************************************************************/ +STATUS VOL_VOL_BrowseBeastsInVolume( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT selectionCriteria, + NINT numBeastsRequested, + Zid_t *lastBeastReturned, /* inout */ + Zid_t *beastZids, /* out */ + NINT *numBeastsReturned) /* out */ +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + *numBeastsReturned = 0; + return(zOK); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_GetUserSpaceInfo( + GeneralMsg_s *genMsg, + Volume_s *volume, + const UserID_t *userID, + SQUAD *restrictionAmount, + SQUAD *usedAmount) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + *restrictionAmount = zUSER_NO_RESTRICTIONS; + *usedAmount = 0; + return(zOK); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_SetUserSpaceRestriction( + GeneralMsg_s *genMsg, + Volume_s *volume, + Xaction_s *xAction, + const UserID_t *userID, + SQUAD restrictionAmount) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + SetErrno(genMsg,zERR_USER_SPACE_RESTRICT_NOT_ENABLED); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +void VOL_VOL_AdjustUsedUserSpace( + Xaction_s *xaction, + RootBeast_s *beast, + SQUAD amountToAdjust) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + return; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_RemoveUser( + GeneralMsg_s *genMsg, + Volume_s *volume, + const UserID_t *userID) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + SetErrno(genMsg,zERR_USER_SPACE_RESTRICT_NOT_ENABLED); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_ResetAllUsers( + GeneralMsg_s *genMsg, + Volume_s *volume) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + SetErrno(genMsg,zERR_USER_SPACE_RESTRICT_NOT_ENABLED); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_BrowseUsersInVolume( + GeneralMsg_s *genMsg, + Volume_s *volume, + NINT numEntriesRequested, + UserID_t *lastUserReturned, /* inout */ + COMNUserRest_s *userEntries, /* out */ + NINT *numEntriesReturned, + LONG allUsersFlag) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + + if (numEntriesReturned) *numEntriesReturned = 0; + if (lastUserReturned) *lastUserReturned = zINVALID_USERID; + return(zOK); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_InsertMFLEntry( + GeneralMsg_s *genMsg, + Volume_s *volume, + Zid_t zid, + Epoch_t epoch, + Xaction_s *xaction) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + SetErrno(genMsg,zERR_MFL_NOT_ENABLED); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_DeleteMFLEntry( + GeneralMsg_s *genMsg, + Volume_s *volume, + Zid_t zid, + Epoch_t *epoch, /* out */ + Xaction_s *xaction) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + SetErrno(genMsg,zERR_MFL_NOT_ENABLED); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_LookupMFLEntry( + GeneralMsg_s *genMsg, + Volume_s *volume, + Zid_t zid, + Epoch_t *epoch) /* out */ +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + SetErrno(genMsg,zERR_MFL_NOT_ENABLED); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_EnumerateMFL( + GeneralMsg_s *genMsg, + Volume_s *volume, + Epoch_t targetEpoch, + NINT numEntriesRequested, + Zid_t *lastZidReturned, /* inout */ + MFLEntry_s *entries, /* out */ + NINT *numEntriesReturned, /* out */ + BOOL *isMFLincomplete) /* out supply value if ptr non-zero */ +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + SetErrno(genMsg,zERR_MFL_NOT_ENABLED); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_administerMFL( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT opCode, + MFLAdminParms_s *parms) /* inout */ +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + SetErrno(genMsg,zERR_MFL_NOT_ENABLED); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_InsertEFLEntry( + GeneralMsg_s *genMsg, + File_s *beast, + NINT action, + unicode_t *name, + Xaction_s *xaction) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + return(zOK); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_DeleteEFLEntry( + GeneralMsg_s *genMsg, + Volume_s *volume, + Zid_t zid, + QUAD id1, + QUAD id2, + EFLEpoch_t *epoch, + Xaction_s *xaction) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + return(zOK); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_LookupEFLEntry( + GeneralMsg_s *genMsg, + Volume_s *volume, + Zid_t zid, + EFLEpoch_t *targetEpoch, + EFLEntry_s *entry) /* out */ +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + SetErrno(genMsg,zERR_ZID_NOT_FOUND); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_EnumerateEFL( + GeneralMsg_s *genMsg, + Volume_s *volume, + EFLEpoch_t *targetEpoch, + NINT maxEntries, + EFLEntryIndex_s *nextEntry, /* inout */ + EFLEntry_s *retEntries, /* out */ + NINT *numEntriesReturned) /* out */ +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + *numEntriesReturned = 0; + return(zOK); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_administerEFL( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT opCode, + EFLAdminIn_s *data, + EFLAdminOut_s *retData) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + switch (opCode) + { + case VOL_EFL_ADMIN_GET_NAME_SPACE_ID: + { + retData->u.nameSpaceID = zNSPACE_INVALID; + return zOK; + } + } + SetErrno(genMsg,zERR_EFL_NOT_ENABLED); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_resetEFL( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume) +{ + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return(zFAILURE); +} + + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_FCNTL( + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT opCode, + FCNTL_In_s *data, + FCNTL_Out_s *retData, + Xaction_s *xaction) +{ + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return(zFAILURE); +} + + +/**************************************************************************** + * This common op is used to perform LSS specific volume operations. For + * example, create volume, rename volume and delete volume are implemented + * via this common op. This was added when logical volumes were added. This + * function is not specific to logical volumes although ZLSS is the only + * LSS that currently supports. This function here is the catch all that + * returns an error and releases the useCount on the volume beast. + *****************************************************************************/ +STATIC STATUS VOL_VOL_CommandFunction( + GeneralMsg_s *genMsg, + void *beast_LX, + NINT functionNumber, + VCO_VolumeCommonOps_s *pCD, + NINT parmLen, + utf8_t *parm, + NINT dataLen, + BYTE *commandData, + NINT offset, + NINT retBufLen, + BYTE *retBuf, + NINT *retLen) + +{ + Volume_s *beast = (Volume_s *)beast_LX; + STATUS status; + Pool_s *pool = beast->v_pool; + + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP. CASE VCO_VOLUME_GET_INFO_NUMBER needs + * to be called by childern. + */ + zASSERT( COMN_IsDerivedFrom(beast, zFTYPE_VOLUME) ); +#ifdef USER_GPACHNER + LB_aprintf(LRED,"%s\n",WHERE); +#endif + + switch( functionNumber ) + { + /*** Note that the VCO_VOLUME_CREATE_NUMBER command + *** is handle by ZLSSPOL_VOL_CommandFunction() because + *** we only have a pool beast when a volume is created. + ***/ + case VCO_VOLUME_CREATE_NUMBER: + case VCO_VOLUME_RENAME_NUMBER: + case VCO_VOLUME_DELETE_NUMBER: + case VCO_VOLUME_DELETE_ACTION_NUMBER: + COMN_Release( &beast ); + status = zFAILURE; + SetErrno( genMsg, zERR_NOT_SUPPORTED ); + break; + case VCO_VOLUME_GET_INFO_NUMBER: + { + char *loc = retBuf + *retLen; + + if ( (retBufLen - *retLen) < 1024 ) + { + COMN_Release( &beast ); /* Release OUR inherited use count */ + SetErrno( genMsg, zERR_BUFFER_TOO_SMALL ); + status = zFAILURE; + break; + } + + ASSERT_LATCH( &beast->stateLatch ); +// S_LATCH( &beast->stateLatch ); + sprintf( loc, MSGNot("<"TAG_VOLUMENAME">%U\r\n"), pCD->u.VCO_getInfo.VGI_volumeName); + loc = loc + strlen( loc ); + + sprintf( loc, MSGNot("<"TAG_PERSISTENTVOLUMESTATE">%u\r\n"), + (unsigned int)beast->VOLpState); + loc = loc + strlen( loc ); + + sprintf( loc, MSGNot("<"TAG_VOLUMEID">")); + loc = loc + strlen( loc ); + (void)LB_GUIDToString( &beast->VOLvolumeID, retBufLen + - ((ADDR)loc - (ADDR)retBuf), loc ); + loc = loc + strlen( loc ); + sprintf( loc, MSGNot("\r\n")); + loc = loc + strlen( loc ); + + if ( pool != NULL ) + { + typedef struct Stack_s { + unicode_t pname[zMAX_COMPONENT_NAME]; + } Stack_s; + STACK_ALLOC(); + + (void)COMN_GetPoolName( genMsg, pool, aStack->pname, NELEMS(aStack->pname) ); + ClearErrno( genMsg ); + sprintf( loc, MSGNot("<"TAG_POOLNAME">%U\r\n"), aStack->pname); + loc = loc + strlen( loc ); + STACK_FREE(); + } + + sprintf( loc, MSGNot("<"TAG_VOLUMESTATE">%ld\r\n"), beast->state); + loc = loc + strlen( loc ); + switch ( beast->state ) + { + case zVOLSTATE_MAINTENANCE: + break; + case zVOLSTATE_UNKNOWN: + break; + case zVOLSTATE_DEACTIVE: + break; + case zVOLSTATE_ACTIVE: + sprintf( loc, MSGNot("<"TAG_CREATETIME">%ld\r\n"),beast->p.PV_createTimeUTC); + loc = loc + strlen( loc ); + sprintf( loc, MSGNot("<"TAG_ACTIVATETIME">%ld\r\n"), + beast->p.PV_activationTimeUTC); + loc = loc + strlen( loc ); + sprintf( loc, MSGNot("<"TAG_VERIFYTIME">%ld\r\n"),beast->p.PV_verifyTimeUTC); + loc = loc + strlen( loc ); + sprintf( loc, MSGNot("<"TAG_REBUILDTIME">%ld\r\n"), beast->p.PV_rebuildTimeUTC); + loc = loc + strlen( loc ); + sprintf( loc, MSGNot("<"TAG_MEDIALAYOUT">%lu.%02lu\r\n"), beast->VOLmediaFormatMajor, + beast->VOLmediaFormatMinor); + loc = loc + strlen( loc ); + sprintf( loc, MSGNot("<"TAG_CREATEMEDIALAYOUT + ">%lu.%02lu\r\n"), + beast->VOLmediaFormatMajorCreate, + beast->VOLmediaFormatMinorCreate); + loc = loc + strlen( loc ); + + default: + break; + } + +// UNS_LATCH( &beast->stateLatch ); + COMN_Release( &beast ); /* Release OUR inherited use count */ + *retLen += (ADDR)loc - (ADDR)(retBuf + *retLen);/* Does not include NULL */ + status = zOK; + break; + } + default: + COMN_Release( &beast ); + status = zFAILURE; + SetErrno( genMsg, zERR_NOT_SUPPORTED ); + zASSERT("Unknown function number"==NULL); + break; + } + return( status ); + +} /* End of VOL_VOL_CommandFunction() */ + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_GetDirQuotaInfo( + GeneralMsg_s *genMsg, + Volume_s *volume, + Zid_t dirZid, + SQUAD *quota, + SQUAD *usedAmount) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + *quota = zDIR_NO_QUOTA; + *usedAmount = 0; + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_SetDirQuota( + GeneralMsg_s *genMsg, + Volume_s *volume, + Xaction_s *xAction, + Zid_t directory, + SQUAD quota) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + SetErrno(genMsg, zERR_DIR_QUOTAS_NOT_ENABLED); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +void VOL_VOL_AdjustUsedDirSpace( + Xaction_s *xaction, + Volume_s *volume, + Zid_t dirZid, + SQUAD amountToAdjust) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + return; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_RemoveDirectory( + GeneralMsg_s *genMsg, + Volume_s *volume, + Xaction_s *xAction, + Zid_t directory) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + SetErrno(genMsg, zERR_DIR_QUOTAS_NOT_ENABLED); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_ResetAllDirEntries( + GeneralMsg_s *genMsg, + Volume_s *volume) +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + SetErrno(genMsg, zERR_DIR_QUOTAS_NOT_ENABLED); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_BrowseDirsInVolume( + GeneralMsg_s *genMsg, + Volume_s *volume, + NINT numEntriesRequested, + Zid_t *lastUserReturned, /* inout */ + COMNDirQuota_s *userEntries, /* out */ + NINT *numEntriesReturned) /* out */ +{ + /* This function is here as a catch-all. If a volume supports this OP, + * it must override this OP */ + SetErrno(genMsg, zERR_DIR_QUOTAS_NOT_ENABLED); + return(zFAILURE); +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_GetObjectName( + GeneralMsg_s *genMsg, + Volume_s *volume, + UserID_t *objectID, + unicode_t *name, + Time_t *timeNotFound, + NINT *numberOfTimesNotFound) +{ + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_InsertObjectName( + GeneralMsg_s *genMsg, + Volume_s *volume, + Xaction_s *xAction, + UserID_t *objectID, + unicode_t *name) +{ + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_ResetAllObjects( + GeneralMsg_s *genMsg, + Volume_s *volume) +{ + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * + ****************************************************************************/ +STATUS VOL_VOL_ModifyObjectName( + GeneralMsg_s *genMsg, + Volume_s *volume, + Xaction_s *xAction, + UserID_t *objectID, + unicode_t *name, + Time_t timeNotFound, + NINT numberOfTimesNotFound) +{ + SetErrno(genMsg,zERR_COMN_OP_NOT_SUPPORTED); + return zFAILURE; +} + +/**************************************************************************** + * COMMON OPS definition + * + *****************************************************************************/ + +/*--------------------------------------------------------------------------- + * Defines all of the FileBeast operations + *---------------------------------------------------------------------------*/ +CommonBeastOps_s VOL_ComnOps = +{ + VOL_BST_Construct, /* construct */ + VOL_BST_Destruct, /* destruct */ + +// cnt NULL, /* BST_getNameUniquifier */ + NULL, /* BST_setupNameTypeSpecificInfo */ + NULL, /* BST_lookupByNameInDirectory*/ + NULL, /* BST_isDirectoryEmpty*/ + NULL, /* BST_addNameToDirectory*/ + NULL, /* BST_removeNameFromDirectory*/ + NULL, /* BST_modifyNameSpaceMaskInDirectory*/ + NULL, /* BST_setMatchAttributesInDirectory*/ + NULL, /* BST_wildcardLookup*/ + + NULL, /* BST_truncateFile*/ + NULL, /* BST_getStorageInfo*/ + NULL, /* BST_getExtentList*/ + NULL, /* BST_getPhysicalExtent*/ + NULL, /* BST_isBlockInBeast*/ + + NULL, /* BST_asyncReadFileBlk*/ + NULL, /* BST_getFileBlk*/ + NULL, /* BST_dioReadUnits*/ + NULL, /* BST_dioWriteUnits*/ + + NULL, /* BST_getZID*/ + NULL, /* BST_beastNotify*/ + VOL_BST_GetInfo, /* BST_getInfo*/ + VOL_BST_ModifyInfo, /* BST_modifyInfo*/ + VOL_BST_GetInfoXML, /* BST_getInfoXML */ + VOL_BST_ModifyInfoXML /* BST_modifyInfoXML*/ +}; + + +/*------------------------------------------------------------------------- + * + *-------------------------------------------------------------------------*/ +CommonVolumeOps_s VOL_ComnVolOps = +{ +// cnt NULL, /* VOL_getNameUniquifier */ + NULL, /* VOL_setupNameTypeSpecificInfo */ + NULL, /* VOL_lookupByNameInDirectory */ + NULL, /* VOL_isDirectoryEmpty */ + NULL, /* VOL_addNameToDirectory */ + NULL, /* VOL_removeNameFromDirectory */ + NULL, /* VOL_modifyNameSpaceMaskInDirectory */ + VOL_VOL_SetMatchAttributesInDirectory, /* VOL_setMatchAttributesInDirectory */ + NULL, /* VOL_wildcardLookup */ + + NULL, /* VOL_truncateFile */ + NULL, /* VOL_getStorageInfo */ + NULL, /* VOL_getExtentList */ + NULL, /* VOL_getPhysicalExtent */ + NULL, /* VOL_isBlockInBeast */ + + NULL, /* VOL_asyncReadFileBlk */ + NULL, /* VOL_getFileBlk */ + NULL, /* VOL_dioReadUnits */ + NULL, /* VOL_dioWriteUnits */ + + NULL, /* VOL_beginXLocal */ + NULL, /* VOL_endXLocal */ + NULL, /* VOL_addPurgeLogEntry */ + NULL, /* VOL_removePurgeLogEntry */ + NULL, /* VOL_writeVolumeLoggedData */ + + VOL_VOL_ChangeVolumeState, /* VOL_changeVolumeState */ + NULL, /* VOL_volumeMaintenance */ + VOL_VOL_allocStorageInfo, /* VOL_allocStorageInfo */ + VOL_VOL_freeStorageInfo, /* VOL_freeStorageInfo */ + NULL, /* VOL_getBeastFromVolume */ + NULL, /* VOL_updateBeastToVolume */ + NULL, /* VOL_insertBeastIntoVolume */ + NULL, /* VOL_removeBeastFromVolume */ + VOL_VOL_AllocateZIDs, /* VOL_allocateZIDs */ + VOL_VOL_FlushSystemBeasts, /* VOL_flushSystemBeasts*/ + VOL_VOL_MakeVolumeFreeSpace, /* VOL_makeVolumeFreeSpace */ + VOL_VOL_BrowseBeastsInVolume, /* VOL_browseBeastsInVolume */ + + VOL_VOL_GetUserSpaceInfo, /* VOL_getUserSpaceInfo */ + VOL_VOL_SetUserSpaceRestriction, /* VOL_setUserSpaceRestriction */ + VOL_VOL_AdjustUsedUserSpace, /* VOL_adjustUsedUserSpace */ + VOL_VOL_RemoveUser, /* VOL_removeUser */ + VOL_VOL_ResetAllUsers, /* VOL_ResetAllUsers */ + VOL_VOL_BrowseUsersInVolume, /* VOL_browseUsersInVolume */ + + VOL_VOL_InsertMFLEntry, /* VOL_insertMFLEntry */ + VOL_VOL_DeleteMFLEntry, /* VOL_deleteMFLEntry */ + VOL_VOL_LookupMFLEntry, /* VOL_lookupMFLEntry */ + VOL_VOL_EnumerateMFL, /* VOL_enumerateMFL */ + VOL_VOL_administerMFL, /* VOL_administerMFL */ + VOL_VOL_CommandFunction, /* VOL_commandFunction */ + + VOL_VOL_GetDirQuotaInfo, /* VOL_getDirQuotaInfo */ + VOL_VOL_SetDirQuota, /* VOL_setDirQuota */ + VOL_VOL_AdjustUsedDirSpace, /* VOL_adjustUsedDirSpace */ + VOL_VOL_RemoveDirectory, /* VOL_removeDirectory */ + VOL_VOL_ResetAllDirEntries, /* VOL_resetAllDirEntries */ + VOL_VOL_BrowseDirsInVolume, /* VOL_browseDirsInVolume */ + + VOL_VOL_GetObjectName, /* VOL_getObjectName */ + VOL_VOL_InsertObjectName, /* VOL_insertObjectName */ + VOL_VOL_ResetAllObjects, /* VOL_resetAllObjects */ + VOL_VOL_ModifyObjectName, /* VOL_modifyObjectName */ + + VOL_VOL_InsertEFLEntry, /* VOL_insertEFLEntry */ + VOL_VOL_DeleteEFLEntry, /* VOL_deleteEFLEntry */ + VOL_VOL_LookupEFLEntry, /* VOL_lookupEFLEntry */ + VOL_VOL_EnumerateEFL, /* VOL_enumerateEFL */ + VOL_VOL_administerEFL, /* VOL_administerEFL */ + VOL_VOL_resetEFL, /* VOL_resetEFL */ + + VOL_VOL_FCNTL, /* VOL_FCNTL */ +}; diff --git a/src/nwnss/comn/common/volStartup.c b/src/nwnss/comn/common/volStartup.c index 5342a21..5e67d39 100644 --- a/src/nwnss/comn/common/volStartup.c +++ b/src/nwnss/comn/common/volStartup.c @@ -130,7 +130,7 @@ STATUS applyVolumeShutdown (SETlink_t *item, void *verbose) void VOLUME_Shutdown( BOOL verbose) { - SET_APPLY( &NSSMasterVolumeList, (statusfunc_t)applyVolumeShutdown, (void *)verbose); + SET_APPLY( &NSSMasterVolumeList, applyVolumeShutdown, (void *)verbose); } @@ -176,7 +176,7 @@ void POOL_Shutdown( ASSERT_MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); - + SET_FOREACHBLOCKING(&NSSMasterPoolList, pool, Pool_s, masterPoolLink) { /*** You MUST NOT use continue in this loop because the macro *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called diff --git a/src/nwnss/comn/common/zAPI.c b/src/nwnss/comn/common/zAPI.c index d55787d..4f1f8ec 100644 --- a/src/nwnss/comn/common/zAPI.c +++ b/src/nwnss/comn/common/zAPI.c @@ -34,16 +34,8 @@ | This module is used to: | Define all of the NLM Public Interfaces to PSS +-------------------------------------------------------------------------*/ -#include -#include -#include - -#ifdef NSS_USERSPACE -#include "NssUaccessRuntime.h" -typedef void (*zapi_release_callback_t)(ADDR handle); -#else #include -#endif +#include #include #include @@ -56,21 +48,6 @@ typedef void (*zapi_release_callback_t)(ADDR handle); #include #include -#ifndef __KERNEL__ -static void -mpkEnter(void) -{ -} - -static void -mpkExit(void) -{ -} -#endif - -#define ZAPI_PTR_TO_QUAD(_ptr) ((QUAD)(uintptr_t)(_ptr)) -#define ZAPI_FUNC_TO_QUAD(_fn) ((QUAD)(uintptr_t)(_fn)) - STATUS zAbortXaction ( Key_t key, Xid_t xid) @@ -168,7 +145,7 @@ STATUS zChangeConnection ( } return rc; } - + STATUS zClose (Key_t key) { @@ -199,7 +176,7 @@ STATUS zCommitXaction ( STATUS zCreate ( Key_t key, - NINT taskID, + NINT taskID, Xid_t xid, NINT nameSpace, const void *path, @@ -215,7 +192,7 @@ STATUS zCreate ( if (path != NULL) { msg.sys.numDataAreas = 1; - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(path); + msg.sys.data[PATH_DATA].start = (void *)path; /* We could set it to 0 for local access */ if (nameSpace & zMODE_UTF8) { @@ -230,7 +207,7 @@ STATUS zCreate ( else { msg.sys.numDataAreas = 0; - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(NULL); + msg.sys.data[PATH_DATA].start = NULL; } msg.body.id.xid = xid; msg.body.id.taskID = taskID; @@ -263,7 +240,7 @@ STATUS zDelete ( if (path != NULL) { msg.sys.numDataAreas = 1; - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(path); + msg.sys.data[PATH_DATA].start = (void *)path; /* We could set it to 0 for local access */ if (nameSpace & zMODE_UTF8) { @@ -278,7 +255,7 @@ STATUS zDelete ( else { msg.sys.numDataAreas = 0; - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(NULL); + msg.sys.data[PATH_DATA].start = NULL; } msg.body.id.xid = xid; msg.body.id.taskID = zNO_TASK; @@ -318,9 +295,9 @@ STATUS zDIORead ( zNSSMsg_s msg; msg.sys.numDataAreas = 1; - msg.sys.data[DIO_DATA].start = ZAPI_PTR_TO_QUAD(retBuffer); + msg.sys.data[DIO_DATA].start = (void *)retBuffer; msg.sys.data[DIO_DATA].length = unitsToRead << DIO_UNIT_SHIFT; - msg.sys.callback = ZAPI_FUNC_TO_QUAD(dioReadCallBack); + msg.sys.callback = dioReadCallBack; msg.body.id.sa = zSAGENT_NETWARE; msg.body.dio.unitOffset = unitOffset; msg.body.dio.callBackContext = callBackContext; @@ -342,9 +319,9 @@ STATUS zDIOWrite ( zNSSMsg_s msg; msg.sys.numDataAreas = 1; - msg.sys.data[DIO_DATA].start = ZAPI_PTR_TO_QUAD(buffer); + msg.sys.data[DIO_DATA].start = (void *)buffer; msg.sys.data[DIO_DATA].length = unitsToWrite << DIO_UNIT_SHIFT; - msg.sys.callback = ZAPI_FUNC_TO_QUAD(dioWriteCallBack); + msg.sys.callback = dioWriteCallBack; msg.body.id.sa = zSAGENT_NETWARE; msg.body.dio.unitOffset = unitOffset; msg.body.dio.callBackContext = callBackContext; @@ -380,12 +357,12 @@ STATUS zEnumerate ( zNSSMsg_s msg; STATUS rc; - /* To avoid having to modify all beast common operations to return - * zero quotas if they don't support quotas we'll just start by + /* To avoid having to modify all beast common operations to return + * zero quotas if they don't support quotas we'll just start by * zeroing out the quotas for the correct info version */ if (((infoVersion >= zINFO_VERSION_B) && (infoVersion <= zINFO_VERSION_D)) - && (getInfoMask & zGET_DIR_QUOTA) + && (getInfoMask & zGET_DIR_QUOTA) && (retGetInfo != NULL)) { ((zInfoB_s *)retGetInfo)->dirQuota.quota = zDIR_NO_QUOTA; @@ -394,7 +371,7 @@ STATUS zEnumerate ( msg.sys.numDataAreas = 1; - msg.sys.data[INFO_DATA].start = ZAPI_PTR_TO_QUAD(retGetInfo); + msg.sys.data[INFO_DATA].start = retGetInfo; msg.sys.data[INFO_DATA].length = sizeRetGetInfo; msg.body.id.externalFlags = getInfoMask; msg.body.wild.version = infoVersion; @@ -437,7 +414,7 @@ STATUS zGetFileMap ( STATUS rc; msg.sys.numDataAreas = 1; - msg.sys.data[MAP_DATA].start = ZAPI_PTR_TO_QUAD(retExtentList); + msg.sys.data[MAP_DATA].start = (void *)retExtentList; msg.sys.data[MAP_DATA].length = bytesForExtents; msg.body.id.xid = 0; msg.body.id.internalFlags = 0; @@ -464,12 +441,12 @@ STATUS zGetInfo ( { zNSSMsg_s msg; - /* To avoid having to modify all beast common operations to return - * zero quotas if they don't support quotas we'll just start by + /* To avoid having to modify all beast common operations to return + * zero quotas if they don't support quotas we'll just start by * zeroing out the quotas for the correct info version */ if (((infoVersion >= zINFO_VERSION_B) && (infoVersion <= zINFO_VERSION_D)) - && (getInfoMask & zGET_DIR_QUOTA) + && (getInfoMask & zGET_DIR_QUOTA) && (retGetInfo != NULL)) { ((zInfoB_s *)retGetInfo)->dirQuota.quota = zDIR_NO_QUOTA; @@ -477,7 +454,7 @@ STATUS zGetInfo ( } msg.sys.numDataAreas = 1; - msg.sys.data[INFO_DATA].start = ZAPI_PTR_TO_QUAD(retGetInfo); + msg.sys.data[INFO_DATA].start = (void *)retGetInfo; msg.sys.data[INFO_DATA].length = sizeRetGetInfo; msg.body.id.xid = 0; msg.body.id.internalFlags = 0; @@ -499,12 +476,12 @@ STATUS zGetInfoByName ( { zNSSMsg_s msg; - /* To avoid having to modify all beast common operations to return - * zero quotas if they don't support quotas we'll just start by + /* To avoid having to modify all beast common operations to return + * zero quotas if they don't support quotas we'll just start by * zeroing out the quotas for the correct info version */ if (((infoVersion >= zINFO_VERSION_B) && (infoVersion <= zINFO_VERSION_D)) - && (getInfoMask & zGET_DIR_QUOTA) + && (getInfoMask & zGET_DIR_QUOTA) && (retGetInfo != NULL)) { ((zInfoB_s *)retGetInfo)->dirQuota.quota = zDIR_NO_QUOTA; @@ -514,7 +491,7 @@ STATUS zGetInfoByName ( if (path != NULL) { msg.sys.numDataAreas = 2; - msg.sys.data[PATH_FOR_INFO_DATA].start = ZAPI_PTR_TO_QUAD(path); + msg.sys.data[PATH_FOR_INFO_DATA].start = (void *)path; /* We could set it to 0 for local access */ if (nameSpace & zMODE_UTF8) { @@ -530,7 +507,7 @@ STATUS zGetInfoByName ( { msg.sys.numDataAreas = 1; } - msg.sys.data[INFO_DATA].start = ZAPI_PTR_TO_QUAD(retGetInfo); + msg.sys.data[INFO_DATA].start = (void *)retGetInfo; msg.sys.data[INFO_DATA].length = sizeRetGetInfo; msg.body.id.xid = 0; msg.body.id.internalFlags = (useSnapShot ? USE_SHAP_SHOT : 0); @@ -609,7 +586,7 @@ STATUS zLink ( msg.sys.numDataAreas = 2; if (srcPath != NULL) { - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(srcPath); + msg.sys.data[PATH_DATA].start = (void *)srcPath; /* We could set it to 0 for local access */ if (srcNameSpace & zMODE_UTF8) { @@ -623,12 +600,12 @@ STATUS zLink ( } else { - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(NULL); + msg.sys.data[PATH_DATA].start = NULL; msg.sys.data[PATH_DATA].length = 0; } if (dstPath != NULL) { - msg.sys.data[DSTPATH_DATA].start = ZAPI_PTR_TO_QUAD(dstPath); + msg.sys.data[DSTPATH_DATA].start = (void *)dstPath; /* We could set it to 0 for local access */ if (dstNameSpace & zMODE_UTF8) { @@ -642,7 +619,7 @@ STATUS zLink ( } else { - msg.sys.data[DSTPATH_DATA].start = ZAPI_PTR_TO_QUAD(NULL); + msg.sys.data[DSTPATH_DATA].start = NULL; msg.sys.data[DSTPATH_DATA].length = 0; } msg.body.id.xid = xid; @@ -657,7 +634,7 @@ STATUS zLink ( STATUS zLockByteRange ( Key_t key, - Xid_t xid, + Xid_t xid, NINT mode, QUAD startingOffset, QUAD length, @@ -686,7 +663,7 @@ STATUS zModifyInfo ( zNSSMsg_s msg; msg.sys.numDataAreas = 1; - msg.sys.data[INFO_DATA].start = ZAPI_PTR_TO_QUAD(modifyInfo); + msg.sys.data[INFO_DATA].start = (void *)modifyInfo; msg.sys.data[INFO_DATA].length = sizeModifyInfo; msg.body.id.xid = xid; msg.body.id.internalFlags = 0; @@ -711,7 +688,7 @@ STATUS zModifyInfoByName ( if (path != NULL) { msg.sys.numDataAreas = 2; - msg.sys.data[PATH_FOR_INFO_DATA].start = ZAPI_PTR_TO_QUAD(path); + msg.sys.data[PATH_FOR_INFO_DATA].start = (void *)path; /* We could set it to 0 for local access */ if (nameSpace & zMODE_UTF8) { @@ -727,7 +704,7 @@ STATUS zModifyInfoByName ( { msg.sys.numDataAreas = 1; } - msg.sys.data[INFO_DATA].start = ZAPI_PTR_TO_QUAD(modifyInfo); + msg.sys.data[INFO_DATA].start = (void *)modifyInfo; msg.sys.data[INFO_DATA].length = sizeModifyInfo; msg.body.id.xid = xid; msg.body.id.internalFlags = 0; @@ -748,7 +725,7 @@ STATUS zNewConnection ( if (fdn != NULL) { msg.sys.numDataAreas = 1; - msg.sys.data[FDN_DATA].start = ZAPI_PTR_TO_QUAD(fdn); + msg.sys.data[FDN_DATA].start = (void *)fdn; msg.sys.data[FDN_DATA].length = (unilen(fdn) + 1) * sizeof(unicode_t); } @@ -776,7 +753,7 @@ STATUS zOpen ( if (path != NULL) { msg.sys.numDataAreas = 1; - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(path); + msg.sys.data[PATH_DATA].start = (void *)path; /* We could set it to 0 for local access */ if (nameSpace & zMODE_UTF8) { @@ -808,7 +785,7 @@ STATUS zOpen ( STATUS zRead ( Key_t key, - Xid_t xid, + Xid_t xid, QUAD startingOffset, NINT bytesToRead, void *retBuffer, @@ -828,13 +805,13 @@ STATUS zRead ( mpkEnter(); STACK_ALLOC_NO_ASTACK(); - + set_fs(get_ds()); /* This ensures that copy_from/to_user works irrespective * of whether the buffer is from user space or not */ msg.sys.numDataAreas = 1; - msg.sys.data[RW_DATA].start = ZAPI_PTR_TO_QUAD(aStack->chunks); + msg.sys.data[RW_DATA].start = aStack->chunks; msg.sys.data[RW_DATA].length = sizeof(aStack->chunks); msg.body.id.xid = 0; msg.body.id.internalFlags = 0; @@ -892,7 +869,7 @@ STATUS zRead ( STATUS zReadPageChunks ( Key_t key, - Xid_t xid, + Xid_t xid, QUAD startingOffset, NINT bytesToRead, NSSChunk_s *chunks, @@ -903,7 +880,7 @@ STATUS zReadPageChunks ( NINT rc; msg.sys.numDataAreas = 1; - msg.sys.data[RW_DATA].start = ZAPI_PTR_TO_QUAD(chunks); + msg.sys.data[RW_DATA].start = chunks; msg.sys.data[RW_DATA].length = maxChunks * sizeof(NSSChunk_s); msg.body.id.xid = 0; msg.body.id.internalFlags = 0; @@ -928,10 +905,10 @@ STATUS zReleasePageChunks ( MPKNSS_LOCK(); for (i = 0; i < numChunks; ++i) - { + { if (chunks[i].nc_handle != (ADDR)NULL) { - ((zapi_release_callback_t)chunks[i].nc_release)(chunks[i].nc_handle); + chunks[i].nc_release(chunks[i].nc_handle); chunks[i].nc_handle = (ADDR)NULL; } } @@ -954,7 +931,7 @@ STATUS zRename ( msg.sys.numDataAreas = 2; if (srcPath != NULL) { - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(srcPath); + msg.sys.data[PATH_DATA].start = (void *)srcPath; if (srcNameSpace & zMODE_UTF8) { msg.sys.data[PATH_DATA].length = strlen(srcPath) + 1; @@ -967,12 +944,12 @@ STATUS zRename ( } else { - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(NULL); + msg.sys.data[PATH_DATA].start = NULL; msg.sys.data[PATH_DATA].length = 0; } if (dstPath != NULL) { - msg.sys.data[DSTPATH_DATA].start = ZAPI_PTR_TO_QUAD(dstPath); + msg.sys.data[DSTPATH_DATA].start = (void *)dstPath; /* We could set it to 0 for local access */ if (dstNameSpace & zMODE_UTF8) { @@ -986,7 +963,7 @@ STATUS zRename ( } else { - msg.sys.data[DSTPATH_DATA].start = ZAPI_PTR_TO_QUAD(NULL); + msg.sys.data[DSTPATH_DATA].start = NULL; msg.sys.data[DSTPATH_DATA].length = 0; } msg.body.id.xid = xid; @@ -1001,7 +978,7 @@ STATUS zRename ( STATUS zSetEOF ( Key_t key, - Xid_t xid, + Xid_t xid, QUAD dataSize, NINT setSizeFlags) { @@ -1032,7 +1009,7 @@ STATUS zSetInheritedRightsMask( STATUS zUnlockByteRange ( Key_t key, - Xid_t xid, + Xid_t xid, QUAD startingOffset, QUAD length) { @@ -1060,12 +1037,12 @@ STATUS zWildRead ( { zNSSMsg_s msg; - /* To avoid having to modify all beast common operations to return - * zero quotas if they don't support quotas we'll just start by + /* To avoid having to modify all beast common operations to return + * zero quotas if they don't support quotas we'll just start by * zeroing out the quotas for the correct info version */ if (((infoVersion >= zINFO_VERSION_B) && (infoVersion <= zINFO_VERSION_D)) - && (getInfoMask & zGET_DIR_QUOTA) + && (getInfoMask & zGET_DIR_QUOTA) && (retGetInfo != NULL)) { ((zInfoB_s *)retGetInfo)->dirQuota.quota = zDIR_NO_QUOTA; @@ -1076,7 +1053,7 @@ STATUS zWildRead ( { msg.sys.numDataAreas = 2; - msg.sys.data[PATTERN_DATA].start = ZAPI_PTR_TO_QUAD(pattern); + msg.sys.data[PATTERN_DATA].start = (void *)pattern; /* We could set it to 0 for local access */ if (characterCode == zPFMT_UTF8) { @@ -1092,7 +1069,7 @@ STATUS zWildRead ( { msg.sys.numDataAreas = 1; } - msg.sys.data[INFO_DATA].start = ZAPI_PTR_TO_QUAD(retGetInfo); + msg.sys.data[INFO_DATA].start = retGetInfo; msg.sys.data[INFO_DATA].length = sizeRetGetInfo; msg.body.id.externalFlags = getInfoMask; msg.body.wild.version = infoVersion; @@ -1113,7 +1090,7 @@ STATUS zWildRewind ( STATUS zWrite ( Key_t key, - Xid_t xid, + Xid_t xid, QUAD startingOffset, NINT bytesToWrite, const void *buffer, @@ -1124,7 +1101,7 @@ STATUS zWrite ( mm_segment_t oldfs = get_fs(); msg.sys.numDataAreas = 1; - msg.sys.data[RW_DATA].start = ZAPI_PTR_TO_QUAD(buffer); + msg.sys.data[RW_DATA].start = (void *)buffer; msg.sys.data[RW_DATA].length = bytesToWrite; msg.body.id.xid = xid; msg.body.id.internalFlags = 0; @@ -1161,7 +1138,7 @@ STATUS ZnewAsyncReadCache ( STATUS rc; msg.sys.numDataAreas = 0; - msg.sys.callback = ZAPI_FUNC_TO_QUAD(asyncReadCallBack); + msg.sys.callback = asyncReadCallBack; msg.body.async.blockNumber = blockNumber; msg.body.async.callBackContext = callBackContext; @@ -1221,8 +1198,7 @@ BOOL zIsNSSVolume (const utf8_t *path) MPKNSS_LOCK(); - rc = getVolName(path, aStack->name, zMAX_COMPONENT_NAME, - (statusfunc_t)LB_UTF8ToUniChar); + rc = getVolName(path, aStack->name, zMAX_COMPONENT_NAME, LB_UTF8ToUniChar); if (rc != zOK) { STACK_FREE(); @@ -1254,8 +1230,8 @@ BOOL zIsNSSVolume (const utf8_t *path) STATUS zGetEffectiveRights ( - Key_t key, - GUID_t objId, + Key_t key, + GUID_t objId, NINT *effectiveRights) { zNSSMsg_s msg; @@ -1277,7 +1253,7 @@ STATUS zGetEffectiveRights ( STATUS zZIDCreate ( Key_t key, - NINT taskID, + NINT taskID, Xid_t xid, NINT nameSpace, VolumeID_t *volumeID, @@ -1295,7 +1271,7 @@ STATUS zZIDCreate ( if (path != NULL) { msg.sys.numDataAreas = 1; - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(path); + msg.sys.data[PATH_DATA].start = (void *)path; /* We could set it to 0 for local access */ if (nameSpace & zMODE_UTF8) { @@ -1310,7 +1286,7 @@ STATUS zZIDCreate ( else { msg.sys.numDataAreas = 0; - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(NULL); + msg.sys.data[PATH_DATA].start = NULL; } msg.body.id.xid = xid; msg.body.id.taskID = taskID; @@ -1375,7 +1351,7 @@ STATUS zZIDLink ( msg.sys.numDataAreas = 1; if (dstPath != NULL) { - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(dstPath); + msg.sys.data[PATH_DATA].start = (void *)dstPath; if (dstNameSpace & zMODE_UTF8) { msg.sys.data[PATH_DATA].length = strlen(dstPath) + 1; @@ -1388,7 +1364,7 @@ STATUS zZIDLink ( } else { - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(NULL); + msg.sys.data[PATH_DATA].start = NULL; msg.sys.data[PATH_DATA].length = 0; } msg.body.id.xid = xid; @@ -1455,7 +1431,7 @@ STATUS zZIDRename ( msg.sys.numDataAreas = 1; if (dstPath != NULL) { - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(dstPath); + msg.sys.data[PATH_DATA].start = (void *)dstPath; if (dstNameSpace & zMODE_UTF8) { msg.sys.data[PATH_DATA].length = strlen(dstPath) + 1; @@ -1468,7 +1444,7 @@ STATUS zZIDRename ( } else { - msg.sys.data[PATH_DATA].start = ZAPI_PTR_TO_QUAD(NULL); + msg.sys.data[PATH_DATA].start = NULL; msg.sys.data[PATH_DATA].length = 0; } msg.body.id.xid = xid; diff --git a/src/nwnss/comn/common/zFriends.c b/src/nwnss/comn/common/zFriends.c new file mode 100644 index 0000000..ce16b08 --- /dev/null +++ b/src/nwnss/comn/common/zFriends.c @@ -0,0 +1,486 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996-2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2007-04-12 01:48:56 +0530 (Thu, 12 Apr 2007) $ + | + | $RCSfile$ + | $Revision: 1932 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Interfaces for friends of NSS. + +-------------------------------------------------------------------------*/ +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* DEPRECATED please use zZIDOpen*/ +STATUS zOpenByZid ( + Key_t key, + NINT taskID, + Zid_t zid, + NINT requestedRights, + Key_t *retKey) +{ + zNSSMsg_s msg; + STATUS rc; + + msg.sys.numDataAreas = 0; + msg.body.id.xid = 0; + msg.body.id.taskID = taskID; + msg.body.id.internalFlags = 0; + msg.body.name.nameSpace = zNSPACE_INVALID; + msg.body.byZid.requestedRights = requestedRights; + msg.body.byZid.zid = zid; + + rc = mpkMSG_Call(key, NSS_ZID_OPEN, (Msg_s *)&msg); + + if (rc == zOK) + { + *retKey = msg.sys.passedKey; + } + return rc; +} +/* END DEPRECATED */ + +STATUS ResolveFileHandle ( + Key_t key, + FileHandle_s **fhp) +{ + Msg_s msg; + STATUS rc; + + rc = MSG_Call(key, NSS_RESOLVE_FILEHANDLE, &msg); + + if (rc == zOK) + { + *fhp = (FileHandle_s *)msg.sys.door; + } + return rc; +} + +STATUS xMangleConnection ( + Key_t key, + NINT connectionID) +{ + extern NSSConnection_s *MSG_DoResolveConnection(NINT connID); + FileHandle_s *fh; + NSSConnection_s *nssConn; + STATUS rc; + + MPKNSS_LOCK(); + rc = ResolveFileHandle(key, &fh); + if (rc != zOK) + { + goto exit; + } + nssConn = MSG_DoResolveConnection(connectionID); + if (nssConn == NULL) + { + rc = zERR_BAD_CONNECTION_ID; + goto exit; + } + fh->pssConn = nssConn; + fh->connID = nssConn->connectionNumber; + + MSG_ChangeOwner( &fh->door, &nssConn->defaultMaster->mgr); + +exit: + RTN_MPKUNLOCK_STATUS(rc); +} + +STATUS xSharedOpLock ( + Key_t key, + voidfunc_t callback, + void *userdata) +{ + zNSSMsg_s msg; + + msg.sys.numDataAreas = 0; + msg.body.id.externalFlags = 0; + msg.sys.callback = callback; + msg.body.fcntl.opCode = FCNTL_SHARED_OPLOCK; + msg.body.fcntl.userData[0] = (ADDR)userdata; + + return zMSG_Call(key, NSS_FILE_CONTROL, (Msg_s *)&msg); +} + +STATUS xAdjustQuotaFileLen( + Key_t key, + SQUAD adjustFactor) +{ + zNSSMsg_s msg; + + msg.sys.numDataAreas = 0; + msg.body.id.externalFlags = 0; + msg.body.fcntl.opCode = FCNTL_ADJUST_QUOTA_FILELEN; + msg.body.fcntl.quotaAdjustFactor = adjustFactor; + + return zMSG_Call(key, NSS_FILE_CONTROL, (Msg_s *)&msg); +} + + +STATUS xGetMyZid ( + Key_t key, + Zid_t *pzid) +{ + zNSSMsg_s msg; + STATUS rc; + + msg.sys.numDataAreas = 0; + msg.body.id.externalFlags = 0; + msg.body.fcntl.opCode = FCNTL_GET_MY_ZID; + + rc = zMSG_Call(key, NSS_FILE_CONTROL, (Msg_s *)&msg); + if (rc) + { + return rc; + } + *pzid = msg.body.fcntl.zid; + return zOK; +} + + +DOSTime_t xUTC2dosTime (Time_t utc) +{ + DOSTime_t dosTime; + + MPKNSS_LOCK(); + dosTime = UTC2dosTime(utc); + MPKNSS_UNLOCK(); + return dosTime; +} + +Time_t xDOS2utcTime (DOSTime_t dosTime) +{ + Time_t utc; + + MPKNSS_LOCK(); + utc =DOS2utcTime(dosTime); + MPKNSS_UNLOCK(); + return utc; +} + +/*************************************************************************** + * + * xPoolGetEnabledFeatures gets the pool's enabled features given + * the pool's GUID. + * + * + * Enabled feature bits are defined in zParams.h and have the + * form zPOOL_FEATURE_... + * + * This function was added for Changju Gao in the Cluster Team. He + * needed access to if a pool was shared in his EVENT code. Vandana + * and Greg did not want to add enabled features to all the pool events + * so we added this API instead. We did not have him use zGetInfo + * because it only works on ACTIVE pools. + ***************************************************************************/ +STATUS xPoolGetEnabledFeatures( + VolumeID_t *poolID, + QUAD *enabledFeatures ) +{ + GeneralMsg_s genMsg; + STATUS status = zOK; + Pool_s *pool; + + MPKNSS_LOCK(); + zASSERT( enabledFeatures != NULL ); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + pool = COMN_PoolIDLookup(&genMsg, poolID, FALSE); + if (pool == NULL) + { + status = GetErrno(&genMsg); + zASSERT( status != zOK ); + goto errorReturn; + } + + *enabledFeatures = pool->POOLenabledFeatures; + COMN_Release(&pool); + +errorReturn: + MPKNSS_UNLOCK(); + return status; +} + + +/*************************************************************************** + * + * xPoolGUIDToName gets the pool name given the pool's GUID. + * + ***************************************************************************/ +STATUS xPoolGUIDToName( + VolumeID_t *poolID, + unicode_t *poolName, + NINT poolNameSizeInUnicode) +{ + GeneralMsg_s genMsg; + STATUS status; + Pool_s *pool; + + MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + pool = COMN_PoolIDLookup(&genMsg, poolID, FALSE); + if (pool == NULL) + { + status = GetErrno(&genMsg); + goto errorReturn; + } + + status = COMN_GetPoolName(&genMsg, pool, poolName, poolNameSizeInUnicode); + COMN_Release(&pool); + + if (status != zOK) + { + status = GetErrno(&genMsg); + } + +errorReturn: + MPKNSS_UNLOCK(); + return status; +} + + +/*************************************************************************** + * + * xPoolNameToGUID gets the pool's GUID given its name. + * It will return success only if the pool is active. + * + ***************************************************************************/ +STATUS xPoolNameToGUID( + unicode_t *poolName, + VolumeID_t *poolID) + +{ + GeneralMsg_s genMsg; + Pool_s *pool; + STATUS status; + + MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + pool = COMN_PoolNameLookup(&genMsg, poolName, FALSE, poolID); + if (pool == NULL) + { + *poolID = zINVALID_GUID; + status = GetErrno(&genMsg); + } + else + { + COMN_Release(&pool); + status = zOK; + } + MPKNSS_UNLOCK(); + return status; +} + + +/*************************************************************************** + * + * xVolumeGUIDToName gets the volume name given the volume's GUID. + * + * It will return success only if the volume is active. + * + ***************************************************************************/ +STATUS xVolumeGUIDToName( + VolumeID_t *volumeID, + unicode_t *volumeName, + NINT volumeNameSizeInUnicode) +{ + GeneralMsg_s genMsg; + STATUS status; + Volume_s *volume; + + MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + volume = COMN_VolumeIDLookup(&genMsg, volumeID, FALSE); + if (volume == NULL) + { + status = GetErrno(&genMsg); + goto errorReturn; + } + + status = COMN_GetVolumeName(&genMsg, volume, + volumeName, volumeNameSizeInUnicode); + COMN_Release(&volume); + + if (status != zOK) + { + status = GetErrno(&genMsg); + } +errorReturn: + MPKNSS_UNLOCK(); + return status; +} + + +/*************************************************************************** + * + * xVolumeNameToGUID gets the volume's GUID given its name. + * It will return success only if the volume is active. + * + ***************************************************************************/ +STATUS xVolumeNameToGUID( + unicode_t *volumeName, + VolumeID_t *volumeID) +{ + GeneralMsg_s genMsg; + Volume_s *volume; + STATUS status; + + MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + volume = COMN_VolumeNameLookup(&genMsg, volumeName, FALSE, volumeID); + if (volume == NULL) + { + status = GetErrno(&genMsg); + *volumeID = zINVALID_GUID; + } + else + { + COMN_Release(&volume); + status = zOK; + } + MPKNSS_UNLOCK(); + return status; +} + + +/**************************************************************************** + * + * Force a volume to upgrade all of the beasts on the volume. + * + ****************************************************************************/ +STATUS xForceVolumeUpgrade ( + unicode_t *volName, + STATUS (*callBack)(NINT processedCount, NINT updatedCount), + NINT *processedCount, + NINT *upgradedCount) +{ + GeneralMsg_s genMsg; + Volume_s *vol; + STATUS status; + + MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + *processedCount = 0; + *upgradedCount = 0; + /* + * Change the given volume + */ + vol = COMN_VolumeNameLookup(&genMsg, volName, TRUE, NULL); + if (vol == NULL) + { + status = zERR_VOLUME_NOT_FOUND; + goto exit; + } + + if (!(vol->VOLbeastVersionMask & (1 << (BEAST_VERSION_1 - 1)))) + { + /* already upgraded */ + status = zOK; + goto exit1; + } + + if (VOL_UpgradeBeastsOnVolume(&genMsg, vol, volName, callBack, + processedCount, upgradedCount) != zOK) + { + status = GetErrno(&genMsg); + } + else + { + status = zOK; + } + +exit1: + COMN_Release(&vol); +exit: + MPKNSS_UNLOCK(); + return status; +} + + +/**************************************************************************** + * + * Check the specified volume to see if it has been upgraded. + * + ****************************************************************************/ +BOOL xIsVolumeUpgraded ( + unicode_t *volName) +{ + GeneralMsg_s genMsg; + Volume_s *vol; + BOOL retVal; + + MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + /* + * Change the given volume + */ + vol = COMN_VolumeNameLookup(&genMsg, volName, FALSE, NULL); + if (vol == NULL) + { + retVal = FALSE; + goto exit; + } + + if (!VOL_ACCESSIBLE2(vol, &genMsg)) + { + retVal = FALSE; + goto exit1; + } + + if ((vol->VOLbeastVersionMask & (1 << (BEAST_VERSION_1 - 1)))) + { + retVal = FALSE; + } + else + { + retVal = TRUE; + } + +exit1: + COMN_Release(&vol); +exit: + MPKNSS_UNLOCK(); + return retVal; +} diff --git a/src/nwnss/comn/common/zPool.c b/src/nwnss/comn/common/zPool.c index 97f78a0..af90366 100644 --- a/src/nwnss/comn/common/zPool.c +++ b/src/nwnss/comn/common/zPool.c @@ -1,26 +1,26 @@ /**************************************************************************** | - | (C) Copyright 2002, 2003 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 2002, 2003 Novell, Inc. + | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) module + | NetWare Advance File Services (NSS) module | |--------------------------------------------------------------------------- | @@ -31,9 +31,9 @@ | $Revision: 980 $ | |--------------------------------------------------------------------------- - | This module is used to: - | This defines the zFreeze and zThaw interface that was added in NW6.1 - | (Nakoma). There is a specification on this in the NSS area of the WEB. + | This module is used to: + | This defines the zFreeze and zThaw interface that was added in NW6.1 + | (Nakoma). There is a specification on this in the NSS area of the WEB. | +-------------------------------------------------------------------------*/ #include @@ -57,1148 +57,1148 @@ typedef struct FreezeInfo_s { - NINT FI_Stamp; -#define FI_STAMP 0x4847495a - NINT FI_UseCount; - Time_t FI_FreezeUTC; /* UTC of when zPoolFreeze called */ - Time_t FI_ThawUTC; /* UTC of when zPoolThaw called */ - NINT FI_CallbacksRequired; /* Number of consumers when Freeze - * event was generated. - */ - NINT FI_CallbacksReceived; - OneShot_s FI_Timer; /* Timer used for timeout generation */ - BOOL FI_Timeout; /* TRUE if the timeout occurs */ - BOOL FI_TimeoutScheduled; - Time_t FI_TimeoutSceduleUTC; - BOOL FI_PoolFlushScheduled; - Time_t FI_PoolFlushSceduleUTC; - BOOL FI_FreezeEventProduced; /* Set after production of freeze event */ - BOOL FI_FreezeEventProduce; /* Set during production of freeze event */ - BOOL FI_PoolLocked; /* TRUE when lock is held */ - BOOL FI_PoolLatched; /* TRUE when WE own P_FreezeThawLatch latch */ - BOOL FI_PoolFlushDone; /* Flush has completed */ - STATUS FI_PoolFlushStatus; /* Status from async flush, only valid - * when FI_PoolFlushDone is true. - */ - BOOL FI_CallbacksDone; /* Set to TRUE when zFreeze API can - * return to the caller. - */ - FreezeApplicationStatus_s *FI_FreezeApplicationStatus; - /* Freeze app status buffer (can - * be NULL). - */ - Pool_s *FI_Pool; /* Pool. */ - FsmLite_s FI_TimeoutFSMLite; - FsmLite_s FI_PoolFlushFSMLite; - EventPoolFreeze_s FI_FreezeEvent; - EventPoolThaw_s FI_ThawEvent; - unicode_t FI_PoolName[64]; /* NULL termianted pool name. */ + NINT FI_Stamp; +#define FI_STAMP 0x4847495a + NINT FI_UseCount; + Time_t FI_FreezeUTC; /* UTC of when zPoolFreeze called */ + Time_t FI_ThawUTC; /* UTC of when zPoolThaw called */ + NINT FI_CallbacksRequired; /* Number of consumers when Freeze + * event was generated. + */ + NINT FI_CallbacksReceived; + OneShot_s FI_Timer; /* Timer used for timeout generation */ + BOOL FI_Timeout; /* TRUE if the timeout occurs */ + BOOL FI_TimeoutScheduled; + Time_t FI_TimeoutSceduleUTC; + BOOL FI_PoolFlushScheduled; + Time_t FI_PoolFlushSceduleUTC; + BOOL FI_FreezeEventProduced; /* Set after production of freeze event */ + BOOL FI_FreezeEventProduce; /* Set during production of freeze event */ + BOOL FI_PoolLocked; /* TRUE when lock is held */ + BOOL FI_PoolLatched; /* TRUE when WE own P_FreezeThawLatch latch */ + BOOL FI_PoolFlushDone; /* Flush has completed */ + STATUS FI_PoolFlushStatus; /* Status from async flush, only valid + * when FI_PoolFlushDone is true. + */ + BOOL FI_CallbacksDone; /* Set to TRUE when zFreeze API can + * return to the caller. + */ + FreezeApplicationStatus_s *FI_FreezeApplicationStatus; + /* Freeze app status buffer (can + * be NULL). + */ + Pool_s *FI_Pool; /* Pool. */ + FsmLite_s FI_TimeoutFSMLite; + FsmLite_s FI_PoolFlushFSMLite; + EventPoolFreeze_s FI_FreezeEvent; + EventPoolThaw_s FI_ThawEvent; + unicode_t FI_PoolName[64]; /* NULL termianted pool name. */ } FreezeInfo_s; -NINT ZFT_TimeoutInstance = 0; -NINT ZFT_PoolFlushInstance = 0; +NINT ZFT_TimeoutInstance = 0; +NINT ZFT_PoolFlushInstance = 0; void ZFT_FASFill( - FreezeApplicationStatus_s *fas, - void *nebConsumerId, - char *ApplicationMessage, - STATUS completionCode ); + FreezeApplicationStatus_s *fas, + void *nebConsumerId, + char *ApplicationMessage, + STATUS completionCode ); void ZFT_FASInit( - FreezeApplicationStatus_s *fas ); + FreezeApplicationStatus_s *fas ); void ZFT_FASString( - char *buffer, - const char *message, - size_t bufferElements ); + char *buffer, + const char *message, + size_t bufferElements ); void ZFT_FlushPoolAsync( - FreezeInfo_s *fi ); + FreezeInfo_s *fi ); LONG ZFT_FreezeEvent( - FreezeInfo_s *fi, - Pool_s *pool, - unicode_t *poolName_U, - EventPoolFreeze_s *freezeEvent, - EventPoolThaw_s *thawEvent, - int timeOutSeconds ); + FreezeInfo_s *fi, + Pool_s *pool, + unicode_t *poolName_U, + EventPoolFreeze_s *freezeEvent, + EventPoolThaw_s *thawEvent, + int timeOutSeconds ); LONG ZFT_ThawEvent( - FreezeInfo_s *fi, - Pool_s *pool, - unicode_t *poolName_U, - STATUS opRetCode, - EventPoolThaw_s *thawEvent ); + FreezeInfo_s *fi, + Pool_s *pool, + unicode_t *poolName_U, + STATUS opRetCode, + EventPoolThaw_s *thawEvent ); -void ZFT_FreezeInfoDelete( - FreezeInfo_s *fi ); +void ZFT_FreezeInfoDelete( + FreezeInfo_s *fi ); FreezeInfo_s *ZFT_FreezeInfoNew( - int timeOutSeconds, - unicode_t *poolName, - FreezeApplicationStatus_s *fas, - STATUS *status ); + int timeOutSeconds, + unicode_t *poolName, + FreezeApplicationStatus_s *fas, + STATUS *status ); void ZFT_FreezeInfoRelease( - char *where, - FreezeInfo_s **fi ); + char *where, + FreezeInfo_s **fi ); void ZFT_FreezeInfoUse( - FreezeInfo_s *fi ); + FreezeInfo_s *fi ); void ZFT_FreezeTimeoutStart( - FreezeInfo_s *fi, - int timeOutSeconds ); + FreezeInfo_s *fi, + int timeOutSeconds ); void ZFT_PoolFlushThread( - FsmLite_s *fsmLite, - FreezeInfo_s *fi ); + FsmLite_s *fsmLite, + FreezeInfo_s *fi ); void ZFT_TimeOutThread( - FsmLite_s *fsmLite, - void *notUsed ); + FsmLite_s *fsmLite, + void *notUsed ); void ZFT_TimeOutTimer( - OneShot_s *alarm); + OneShot_s *alarm); /** - ** These next three functions can somewhat public as + ** These next three functions can somewhat public as ** we let users call them via PTRs in the PoolFreeze ** event structure. **/ STATUS zPoolEventReceived( - void *key, - void *nebConsumerId ); + void *key, + void *nebConsumerId ); STATUS zPoolNotifyQuiescent( - void *key, - void *nebConsumerId, - STATUS completionCode, - char *applicationName, - char *applicationMessage ); + void *key, + void *nebConsumerId, + STATUS completionCode, + char *applicationName, + char *applicationMessage ); STATUS zPoolNotifyQuiescentRequired( - void *key, - void *nebConsumerId ); + void *key, + void *nebConsumerId ); FreezeInfo_s *ZFT_FreezeInfoNew( - int timeOutSeconds, - unicode_t *poolName, - FreezeApplicationStatus_s *fas, - STATUS *status ) + int timeOutSeconds, + unicode_t *poolName, + FreezeApplicationStatus_s *fas, + STATUS *status ) { - FreezeInfo_s *fi; + FreezeInfo_s *fi; - if ( LB_unilen( poolName ) >= NELEMS( fi->FI_PoolName ) ) - { - *status = zERR_BAD_PARAMETER_VALUE; - return( NULL ); - } - zASSERT( (sizeof( *fi ) - sizeof( fi->FI_Timer ) - - sizeof( fi->FI_TimeoutFSMLite ) - - sizeof( fi->FI_PoolFlushFSMLite ) - - sizeof( fi->FI_FreezeEvent ) - - sizeof( fi->FI_ThawEvent ) ) == (52*4) ); - fi = zalloc( sizeof( *fi ) ); - if ( fi == NULL ) - { - *status = zERR_NO_MEMORY; - return( NULL ); - } - fi->FI_Stamp = FI_STAMP; - fi->FI_UseCount = 0; - fi->FI_FreezeUTC = GetUTCTime(); - fi->FI_ThawUTC = 0; - fi->FI_FreezeEventProduced = FALSE; - fi->FI_FreezeEventProduce = FALSE; - fi->FI_PoolLocked = FALSE; - fi->FI_PoolLatched = FALSE; - fi->FI_CallbacksRequired = 0; - fi->FI_CallbacksReceived = 0; - fi->FI_PoolFlushDone = FALSE; - fi->FI_PoolFlushStatus = zOK; - fi->FI_CallbacksDone = FALSE; - fi->FI_Pool = NULL; - fi->FI_TimeoutSceduleUTC = 0; - fi->FI_PoolFlushScheduled = FALSE; - fi->FI_PoolFlushSceduleUTC = 0; - fi->FI_TimeoutScheduled = FALSE; - fi->FI_Timeout = FALSE; - fi->FI_FreezeApplicationStatus = fas; - FSMLITE_INIT( &fi->FI_TimeoutFSMLite, MSGNot("zFreeze Timeout"), ZFT_TimeoutInstance++ ); - FSMLITE_INIT( &fi->FI_PoolFlushFSMLite, MSGNot("zFreeze Pool Flush"), ZFT_PoolFlushInstance++ ); - INIT_ONESHOT( fi->FI_Timer ); - bzero( &fi->FI_FreezeEvent, sizeof(fi->FI_FreezeEvent) ); - bzero( &fi->FI_ThawEvent, sizeof(fi->FI_ThawEvent) ); - LB_unicpy( &fi->FI_PoolName[0], poolName ); + if ( LB_unilen( poolName ) >= NELEMS( fi->FI_PoolName ) ) + { + *status = zERR_BAD_PARAMETER_VALUE; + return( NULL ); + } + zASSERT( (sizeof( *fi ) - sizeof( fi->FI_Timer ) - + sizeof( fi->FI_TimeoutFSMLite ) - + sizeof( fi->FI_PoolFlushFSMLite ) - + sizeof( fi->FI_FreezeEvent ) - + sizeof( fi->FI_ThawEvent ) ) == (52*4) ); + fi = zalloc( sizeof( *fi ) ); + if ( fi == NULL ) + { + *status = zERR_NO_MEMORY; + return( NULL ); + } + fi->FI_Stamp = FI_STAMP; + fi->FI_UseCount = 0; + fi->FI_FreezeUTC = GetUTCTime(); + fi->FI_ThawUTC = 0; + fi->FI_FreezeEventProduced = FALSE; + fi->FI_FreezeEventProduce = FALSE; + fi->FI_PoolLocked = FALSE; + fi->FI_PoolLatched = FALSE; + fi->FI_CallbacksRequired = 0; + fi->FI_CallbacksReceived = 0; + fi->FI_PoolFlushDone = FALSE; + fi->FI_PoolFlushStatus = zOK; + fi->FI_CallbacksDone = FALSE; + fi->FI_Pool = NULL; + fi->FI_TimeoutSceduleUTC = 0; + fi->FI_PoolFlushScheduled = FALSE; + fi->FI_PoolFlushSceduleUTC = 0; + fi->FI_TimeoutScheduled = FALSE; + fi->FI_Timeout = FALSE; + fi->FI_FreezeApplicationStatus = fas; + FSMLITE_INIT( &fi->FI_TimeoutFSMLite, MSGNot("zFreeze Timeout"), ZFT_TimeoutInstance++ ); + FSMLITE_INIT( &fi->FI_PoolFlushFSMLite, MSGNot("zFreeze Pool Flush"), ZFT_PoolFlushInstance++ ); + INIT_ONESHOT( fi->FI_Timer ); + bzero( &fi->FI_FreezeEvent, sizeof(fi->FI_FreezeEvent) ); + bzero( &fi->FI_ThawEvent, sizeof(fi->FI_ThawEvent) ); + LB_unicpy( &fi->FI_PoolName[0], poolName ); - /* Use count for caller */ - ZFT_FreezeInfoUse( fi ); - return( fi ); + /* Use count for caller */ + ZFT_FreezeInfoUse( fi ); + return( fi ); -} /* End of ZFT_FreezeInfoNew() */ +} /* End of ZFT_FreezeInfoNew() */ -void ZFT_FreezeInfoDelete( - FreezeInfo_s *fi ) +void ZFT_FreezeInfoDelete( + FreezeInfo_s *fi ) { - zASSERT( fi->FI_Stamp == FI_STAMP ); + zASSERT( fi->FI_Stamp == FI_STAMP ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "ZFT_FreezeInfoRelease\n" ); + DBG_DebugPrintf( CYAN, "ZFT_FreezeInfoRelease\n" ); #endif - if ( fi->FI_PoolLatched ) - { - UNX_LATCH( &fi->FI_Pool->P_FreezeThawLatch ); - fi->FI_PoolLatched = FALSE; - } - if ( fi->FI_PoolLocked ) - { + if ( fi->FI_PoolLatched ) + { + UNX_LATCH( &fi->FI_Pool->P_FreezeThawLatch ); + fi->FI_PoolLatched = FALSE; + } + if ( fi->FI_PoolLocked ) + { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "ZFT_FreezeInfoRelease - COMN_PoolActiveUnlock\n" ); + DBG_DebugPrintf( CYAN, "ZFT_FreezeInfoRelease - COMN_PoolActiveUnlock\n" ); #endif - COMN_PoolActiveUnlock( fi->FI_Pool ); - fi->FI_PoolLocked = FALSE; - } - if ( fi->FI_Pool != NULL ) - { - COMN_Release( &fi->FI_Pool ); - } - free( fi ); -} /* End of ZFT_FreezeInfoDelete() */ + COMN_PoolActiveUnlock( fi->FI_Pool ); + fi->FI_PoolLocked = FALSE; + } + if ( fi->FI_Pool != NULL ) + { + COMN_Release( &fi->FI_Pool ); + } + free( fi ); +} /* End of ZFT_FreezeInfoDelete() */ void ZFT_FreezeInfoUse( - FreezeInfo_s *fi ) + FreezeInfo_s *fi ) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "ZFT_FreezeInfoUse\n" ); + DBG_DebugPrintf( CYAN, "ZFT_FreezeInfoUse\n" ); #endif - fi->FI_UseCount += 1; + fi->FI_UseCount += 1; } void ZFT_FreezeInfoRelease( - char *where, - FreezeInfo_s **fi ) + char *where, + FreezeInfo_s **fi ) { - ASSERT_MPKNSS_LOCK(); + ASSERT_MPKNSS_LOCK(); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "ZFT_FreezeInfoRelease %s\n", where ); + DBG_DebugPrintf( CYAN, "ZFT_FreezeInfoRelease %s\n", where ); #endif - (*fi)->FI_UseCount -= 1; - if ( (*fi)->FI_UseCount == 0 ) - { - ZFT_FreezeInfoDelete( *fi ); - } - *fi = NULL; + (*fi)->FI_UseCount -= 1; + if ( (*fi)->FI_UseCount == 0 ) + { + ZFT_FreezeInfoDelete( *fi ); + } + *fi = NULL; } -/* ZFT_FASString() - - * Fill in a buffer with a string while ensuring that - * the buffer gets a NULL and does not overflow. The - * message will be truncated if required. +/* ZFT_FASString() - + * Fill in a buffer with a string while ensuring that + * the buffer gets a NULL and does not overflow. The + * message will be truncated if required. */ void ZFT_FASString( - char *buffer, - const char *message, - size_t bufferElements ) + char *buffer, + const char *message, + size_t bufferElements ) { - if ( bufferElements == 0 ) - { - return; - } - LB_strncpy( buffer, message, bufferElements-1 ); - buffer[bufferElements-1] = '\0'; - return; + if ( bufferElements == 0 ) + { + return; + } + LB_strncpy( buffer, message, bufferElements-1 ); + buffer[bufferElements-1] = '\0'; + return; -} /* End of ZFT_FASString() */ +} /* End of ZFT_FASString() */ void ZFT_FASInit( - FreezeApplicationStatus_s *fas ) + FreezeApplicationStatus_s *fas ) { - if ( fas == NULL ) - { - return; - } - fas->FAS_UsedEntries = 0; - fas->FAS_NeededEntries = 0; + if ( fas == NULL ) + { + return; + } + fas->FAS_UsedEntries = 0; + fas->FAS_NeededEntries = 0; } void ZFT_FASFill( - FreezeApplicationStatus_s *fas, - void *nebConsumerId, - char *ApplicationMessage, - STATUS completionCode ) + FreezeApplicationStatus_s *fas, + void *nebConsumerId, + char *ApplicationMessage, + STATUS completionCode ) { - if ( fas == NULL ) - { - return; - } - fas->FAS_NeededEntries += 1; - if ( fas->FAS_UsedEntries < fas->FAS_AllocatedEntries ) - { - FreezeApplicationStatusEntry_s *entry; + if ( fas == NULL ) + { + return; + } + fas->FAS_NeededEntries += 1; + if ( fas->FAS_UsedEntries < fas->FAS_AllocatedEntries ) + { + FreezeApplicationStatusEntry_s *entry; - entry = &fas->FAS_Entries[fas->FAS_UsedEntries]; - entry->FASE_Status = completionCode; - ZFT_FASString( &entry->FASE_ApplicationName[0], nebConsumerId, NELEMS(entry->FASE_ApplicationName) ); - ZFT_FASString( &entry->FASE_ApplicationMessage[0], ApplicationMessage, NELEMS(entry->FASE_ApplicationMessage) ); - fas->FAS_UsedEntries += 1; - } - return; + entry = &fas->FAS_Entries[fas->FAS_UsedEntries]; + entry->FASE_Status = completionCode; + ZFT_FASString( &entry->FASE_ApplicationName[0], nebConsumerId, NELEMS(entry->FASE_ApplicationName) ); + ZFT_FASString( &entry->FASE_ApplicationMessage[0], ApplicationMessage, NELEMS(entry->FASE_ApplicationMessage) ); + fas->FAS_UsedEntries += 1; + } + return; -} /* End of ZFT_FASFill() */ +} /* End of ZFT_FASFill() */ -/* ZFT_TimeOutThread() - - * This is the thread that runs when a freeze/thaw timeout occurs. +/* ZFT_TimeOutThread() - + * This is the thread that runs when a freeze/thaw timeout occurs. * */ void ZFT_TimeOutThread( - FsmLite_s *fsmLite, - void *notUsed ) + FsmLite_s *fsmLite, + void *notUsed ) { - FreezeInfo_s *fi = STRUCT( fsmLite, FreezeInfo_s, FI_TimeoutFSMLite ); + FreezeInfo_s *fi = STRUCT( fsmLite, FreezeInfo_s, FI_TimeoutFSMLite ); - ASSERT_MPKNSS_LOCK(); - zASSERT( fi->FI_Stamp == FI_STAMP ); + ASSERT_MPKNSS_LOCK(); + zASSERT( fi->FI_Stamp == FI_STAMP ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "ZFT_TimeOutThread is now running\n" ); + DBG_DebugPrintf( CYAN, "ZFT_TimeOutThread is now running\n" ); #endif - fi->FI_Timeout = TRUE; - ZFT_FreezeInfoRelease( WHERE, &fi ); /* Release the 'timers' use count */ - + fi->FI_Timeout = TRUE; + ZFT_FreezeInfoRelease( WHERE, &fi ); /* Release the 'timers' use count */ + #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(CYAN, "ZFT_TimeOutThread is complete\n" ); + DBG_DebugPrintf(CYAN, "ZFT_TimeOutThread is complete\n" ); #endif - return; + return; -} /* End of ZFT_TimeOutThread() */ +} /* End of ZFT_TimeOutThread() */ -/* ZFT_TimeOutTimer() - - * This is the Fast work to do that runs when a freeze/thaw timeout occurs. +/* ZFT_TimeOutTimer() - + * This is the Fast work to do that runs when a freeze/thaw timeout occurs. * */ void ZFT_TimeOutTimer( - OneShot_s *alarm) + OneShot_s *alarm) { - FreezeInfo_s *fi = STRUCT( alarm, FreezeInfo_s, FI_Timer ); + FreezeInfo_s *fi = STRUCT( alarm, FreezeInfo_s, FI_Timer ); - ASSERT_MPKNSS_LOCK(); - zASSERT( fi->FI_Stamp == FI_STAMP ); - zASSERT( !fi->FI_TimeoutScheduled ); + ASSERT_MPKNSS_LOCK(); + zASSERT( fi->FI_Stamp == FI_STAMP ); + zASSERT( !fi->FI_TimeoutScheduled ); - fi->FI_TimeoutScheduled = TRUE; - fi->FI_TimeoutSceduleUTC = GetUTCTime(); - /* Schedule a thread to do the work later (so we will not block) */ - WORK_Schedule( &fi->FI_TimeoutFSMLite, (voidfunc_t)ZFT_TimeOutThread, 0); - return; + fi->FI_TimeoutScheduled = TRUE; + fi->FI_TimeoutSceduleUTC = GetUTCTime(); + /* Schedule a thread to do the work later (so we will not block) */ + WORK_Schedule( &fi->FI_TimeoutFSMLite, ZFT_TimeOutThread, 0); + return; -} /* End of ZFT_TimeOutTimer() */ +} /* End of ZFT_TimeOutTimer() */ /* - * ZFT_FreezeTimeoutStart() - - * Starts timer that we cause zFreeze API to timeout with an error. - * In most cases, the timer will be canceled before the timeout occurs. + * ZFT_FreezeTimeoutStart() - + * Starts timer that we cause zFreeze API to timeout with an error. + * In most cases, the timer will be canceled before the timeout occurs. * */ void ZFT_FreezeTimeoutStart( - FreezeInfo_s *fi, - int timeOutSeconds ) + FreezeInfo_s *fi, + int timeOutSeconds ) { - ZFT_FreezeInfoUse( fi ); /* The callbacks need a count because it is the key */ - ZFT_FreezeInfoUse( fi ); /* The timer needs a count */ - secOneShot( &fi->FI_Timer, timeOutSeconds, ZFT_TimeOutTimer ); + ZFT_FreezeInfoUse( fi ); /* The callbacks need a count because it is the key */ + ZFT_FreezeInfoUse( fi ); /* The timer needs a count */ + secOneShot( &fi->FI_Timer, timeOutSeconds, ZFT_TimeOutTimer ); -} /* End of ZFT_FreezeTimeoutStart() */ +} /* End of ZFT_FreezeTimeoutStart() */ -/* ZFT_PoolFlushThread() - - * This is the thread that runs to ASYNC flush a pool. +/* ZFT_PoolFlushThread() - + * This is the thread that runs to ASYNC flush a pool. * */ void ZFT_PoolFlushThread( - FsmLite_s *fsmLite, - FreezeInfo_s *fi ) + FsmLite_s *fsmLite, + FreezeInfo_s *fi ) { - STATUS status; - GeneralMsg_s dummyGenMsg; + STATUS status; + GeneralMsg_s dummyGenMsg; - ASSERT_MPKNSS_LOCK(); - zASSERT( fi->FI_Stamp == FI_STAMP ); + ASSERT_MPKNSS_LOCK(); + zASSERT( fi->FI_Stamp == FI_STAMP ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "ZFT_PoolFlushThread is now running\n" ); + DBG_DebugPrintf( CYAN, "ZFT_PoolFlushThread is now running\n" ); #endif - COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); + COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); - status = POOL_FlushPool( &dummyGenMsg, fi->FI_Pool ); - if ( status != zOK ) - { - fi->FI_PoolFlushStatus = GetErrno( &dummyGenMsg ); + status = POOL_FlushPool( &dummyGenMsg, fi->FI_Pool ); + if ( status != zOK ) + { + fi->FI_PoolFlushStatus = GetErrno( &dummyGenMsg ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( LRED, "ZFT_PoolFlushThread Flush error %ld\n", fi->FI_PoolFlushStatus ); + DBG_DebugPrintf( LRED, "ZFT_PoolFlushThread Flush error %ld\n", fi->FI_PoolFlushStatus ); #endif - } - - fi->FI_PoolFlushDone = TRUE; - ZFT_FreezeInfoRelease( WHERE, &fi ); /* Release the 'threads' use count */ + } + + fi->FI_PoolFlushDone = TRUE; + ZFT_FreezeInfoRelease( WHERE, &fi ); /* Release the 'threads' use count */ #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(CYAN, "ZFT_PoolFlushThread is complete\n" ); + DBG_DebugPrintf(CYAN, "ZFT_PoolFlushThread is complete\n" ); #endif - return; + return; -} /* End of ZFT_TimeOutThread() */ +} /* End of ZFT_TimeOutThread() */ void ZFT_FlushPoolAsync( - FreezeInfo_s *fi ) + FreezeInfo_s *fi ) { - zASSERT( fi->FI_Pool != NULL ); - zASSERT( !fi->FI_PoolFlushScheduled ); + zASSERT( fi->FI_Pool != NULL ); + zASSERT( !fi->FI_PoolFlushScheduled ); - fi->FI_PoolFlushScheduled = TRUE; - fi->FI_PoolFlushSceduleUTC = GetUTCTime(); - /* Schedule a thread to do the work later (so we will not block) */ - ZFT_FreezeInfoUse( fi ); /* Use count for ZFT_PoolFlushThread */ - WORK_Schedule( &fi->FI_PoolFlushFSMLite, (voidfunc_t)ZFT_PoolFlushThread, (ADDR)fi ); - return; + fi->FI_PoolFlushScheduled = TRUE; + fi->FI_PoolFlushSceduleUTC = GetUTCTime(); + /* Schedule a thread to do the work later (so we will not block) */ + ZFT_FreezeInfoUse( fi ); /* Use count for ZFT_PoolFlushThread */ + WORK_Schedule( &fi->FI_PoolFlushFSMLite, ZFT_PoolFlushThread, (ADDR)fi ); + return; } -NINT ZPoolFreezeCalls = 0; -NINT ZPoolThawCalls = 0; -NINT ZPoolThawCallsBad1 = 0; -NINT ZPoolThawCallsBad2 = 0; -NINT ZPoolThawRequiredCalls = 0; +NINT ZPoolFreezeCalls = 0; +NINT ZPoolThawCalls = 0; +NINT ZPoolThawCallsBad1 = 0; +NINT ZPoolThawCallsBad2 = 0; +NINT ZPoolThawRequiredCalls = 0; /* * - * timeOut - max amount of time in seconds before operation must time out. A - * time out will cause zFreeze to return a failure. - * thawKey - On success this pointer is filled in with the key to call zThaw - * with. + * timeOut - max amount of time in seconds before operation must time out. A + * time out will cause zFreeze to return a failure. + * thawKey - On success this pointer is filled in with the key to call zThaw + * with. * - * status - Return status of the function as follows - * zOK - Caller must call zThaw - * zERR_POOL_FREEZE_CONSISTENT_FAILED - * zERR_POOL_FREEZE_TIMEOUT - * zERR_POOL_FREEZE_ALREADY_IN_PROGRESS - * zERR_POOL_NOT_IN_ACTIVE_STATE - * zERR_VOLUME_STATE_CHANGE_REQUESTED - * or other NSS error code. + * status - Return status of the function as follows + * zOK - Caller must call zThaw + * zERR_POOL_FREEZE_CONSISTENT_FAILED + * zERR_POOL_FREEZE_TIMEOUT + * zERR_POOL_FREEZE_ALREADY_IN_PROGRESS + * zERR_POOL_NOT_IN_ACTIVE_STATE + * zERR_VOLUME_STATE_CHANGE_REQUESTED + * or other NSS error code. * - * Warnings - - * This is a documented 3rd party API. + * Warnings - + * This is a documented 3rd party API. */ STATUS zPoolFreeze( - unicode_t *poolName, - int timeOutSeconds, - FreezeApplicationStatus_s *fas, /* Can be NULL */ - void **thawKey ) + unicode_t *poolName, + int timeOutSeconds, + FreezeApplicationStatus_s *fas, /* Can be NULL */ + void **thawKey ) { - NINT waitFlag; - FreezeInfo_s *fi; - GeneralMsg_s dummyGenMsg; - STATUS status; - STATUS returnCode; + NINT waitFlag; + FreezeInfo_s *fi; + GeneralMsg_s dummyGenMsg; + STATUS status; + STATUS returnCode; - MPKNSS_LOCK(); + MPKNSS_LOCK(); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( MAGENTA, "zFreeze start\n" ); + DBG_DebugPrintf( MAGENTA, "zFreeze start\n" ); #endif - COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); - ZPoolFreezeCalls += 1; + COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); + ZPoolFreezeCalls += 1; - *thawKey = NULL; /* Set up for failure exits */ - ZFT_FASInit( fas ); + *thawKey = NULL; /* Set up for failure exits */ + ZFT_FASInit( fas ); - fi = ZFT_FreezeInfoNew( timeOutSeconds, poolName, fas, &status ); - if ( fi == NULL ) - { - MPKNSS_UNLOCK(); - return( status ); - } - /* We say find non active pool's so that caller gets - * pool not active verses pool not found. This is - * done via COMN_PoolActiveLock. - */ - fi->FI_Pool = COMN_PoolNameLookup( &dummyGenMsg, poolName, FALSE, NULL ); - if ( fi->FI_Pool == NULL ) - { - ZFT_FreezeInfoRelease( WHERE, &fi ); + fi = ZFT_FreezeInfoNew( timeOutSeconds, poolName, fas, &status ); + if ( fi == NULL ) + { + MPKNSS_UNLOCK(); + return( status ); + } + /* We say find non active pool's so that caller gets + * pool not active verses pool not found. This is + * done via COMN_PoolActiveLock. + */ + fi->FI_Pool = COMN_PoolNameLookup( &dummyGenMsg, poolName, FALSE, NULL ); + if ( fi->FI_Pool == NULL ) + { + ZFT_FreezeInfoRelease( WHERE, &fi ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( LRED, "zFreeze - pool not found\n" ); + DBG_DebugPrintf( LRED, "zFreeze - pool not found\n" ); #endif - MPKNSS_UNLOCK(); - return( GetErrno( &dummyGenMsg ) ); - } + MPKNSS_UNLOCK(); + return( GetErrno( &dummyGenMsg ) ); + } - status = COMN_PoolActiveLock( &dummyGenMsg, fi->FI_Pool ); - if ( status != zOK ) - { - ZFT_FreezeInfoRelease( WHERE, &fi ); + status = COMN_PoolActiveLock( &dummyGenMsg, fi->FI_Pool ); + if ( status != zOK ) + { + ZFT_FreezeInfoRelease( WHERE, &fi ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( LRED, "zFreeze - pool not active\n" ); + DBG_DebugPrintf( LRED, "zFreeze - pool not active\n" ); #endif - MPKNSS_UNLOCK(); - return( GetErrno( &dummyGenMsg ) ); - } - fi->FI_PoolLocked = TRUE; - /* - * We will use the XLATCH code that will not block is we can - * not get an X Latch. - */ - X_NOWAIT( &fi->FI_Pool->P_FreezeThawLatch, waitFlag ); - /* Is the latch owned by someone else? */ - if ( waitFlag == WAITED ) - { /* - * Yes - then we will return an error. This design was - * decided on to help prevent deadlocks if numerous - * user are trying to freeze all pools. If they do not - * freeze in the same order then deadlock can occur. - */ - ZFT_FreezeInfoRelease( WHERE, &fi ); + MPKNSS_UNLOCK(); + return( GetErrno( &dummyGenMsg ) ); + } + fi->FI_PoolLocked = TRUE; + /* + * We will use the XLATCH code that will not block is we can + * not get an X Latch. + */ + X_NOWAIT( &fi->FI_Pool->P_FreezeThawLatch, waitFlag ); + /* Is the latch owned by someone else? */ + if ( waitFlag == WAITED ) + { /* + * Yes - then we will return an error. This design was + * decided on to help prevent deadlocks if numerous + * user are trying to freeze all pools. If they do not + * freeze in the same order then deadlock can occur. + */ + ZFT_FreezeInfoRelease( WHERE, &fi ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( LRED, "zFreeze - Latch already owned\n" ); + DBG_DebugPrintf( LRED, "zFreeze - Latch already owned\n" ); #endif - MPKNSS_UNLOCK(); - return( zERR_POOL_FREEZE_ALREADY_IN_PROGRESS ); - } - fi->FI_PoolLatched = TRUE; - /* The P_FreezeThawLatch latch will be released after we unlock the pool */ + MPKNSS_UNLOCK(); + return( zERR_POOL_FREEZE_ALREADY_IN_PROGRESS ); + } + fi->FI_PoolLatched = TRUE; + /* The P_FreezeThawLatch latch will be released after we unlock the pool */ - /* Set timeout for slow callbacks and/or pool flushes. - */ - ZFT_FreezeTimeoutStart( fi, timeOutSeconds ); + /* Set timeout for slow callbacks and/or pool flushes. + */ + ZFT_FreezeTimeoutStart( fi, timeOutSeconds ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "zFreeze - Produce event\n" ); + DBG_DebugPrintf( CYAN, "zFreeze - Produce event\n" ); #endif - ZFT_FreezeEvent( fi, fi->FI_Pool, poolName, &fi->FI_FreezeEvent, &fi->FI_ThawEvent, timeOutSeconds ); + ZFT_FreezeEvent( fi, fi->FI_Pool, poolName, &fi->FI_FreezeEvent, &fi->FI_ThawEvent, timeOutSeconds ); - /* Wait for callbacks to get done */ + /* Wait for callbacks to get done */ #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "zFreeze - Wait for callbacks\n" ); + DBG_DebugPrintf( CYAN, "zFreeze - Wait for callbacks\n" ); #endif - while ( (!fi->FI_CallbacksDone) && - (!fi->FI_Timeout) && - (!(fi->FI_Pool->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP)) ) - { - LB_delay( 250 ); - } + while ( (!fi->FI_CallbacksDone) && + (!fi->FI_Timeout) && + (!(fi->FI_Pool->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP)) ) + { + LB_delay( 250 ); + } - if ( (fi->FI_Pool->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) ) - { + if ( (fi->FI_Pool->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) ) + { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "zFreeze - stopping because of deactivate request\n" ); + DBG_DebugPrintf( CYAN, "zFreeze - stopping because of deactivate request\n" ); #endif - returnCode = zERR_VOLUME_STATE_CHANGE_REQUESTED; - } - else if ( fi->FI_Timeout ) - { + returnCode = zERR_VOLUME_STATE_CHANGE_REQUESTED; + } + else if ( fi->FI_Timeout ) + { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "zFreeze stopping because of timeout\n" ); + DBG_DebugPrintf( CYAN, "zFreeze stopping because of timeout\n" ); #endif - returnCode = zERR_POOL_FREEZE_TIMEOUT; - } - else - { + returnCode = zERR_POOL_FREEZE_TIMEOUT; + } + else + { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "zFreeze - Calling flush\n" ); + DBG_DebugPrintf( CYAN, "zFreeze - Calling flush\n" ); #endif - ZFT_FlushPoolAsync( fi ); - /* Wait for flush to get done */ - while ( (!fi->FI_PoolFlushDone) && - (!fi->FI_Timeout) && - (!(fi->FI_Pool->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP)) ) - { - LB_delay( 250 ); - } - if ( (fi->FI_Pool->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) ) - { + ZFT_FlushPoolAsync( fi ); + /* Wait for flush to get done */ + while ( (!fi->FI_PoolFlushDone) && + (!fi->FI_Timeout) && + (!(fi->FI_Pool->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP)) ) + { + LB_delay( 250 ); + } + if ( (fi->FI_Pool->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) ) + { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "zFreeze stopping because of deactivate request\n" ); + DBG_DebugPrintf( CYAN, "zFreeze stopping because of deactivate request\n" ); #endif - returnCode = zERR_VOLUME_STATE_CHANGE_REQUESTED; - } - else if ( fi->FI_Timeout ) - { + returnCode = zERR_VOLUME_STATE_CHANGE_REQUESTED; + } + else if ( fi->FI_Timeout ) + { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "zFreeze stopping because of timeout\n" ); + DBG_DebugPrintf( CYAN, "zFreeze stopping because of timeout\n" ); #endif - returnCode = zERR_POOL_FREEZE_TIMEOUT; - } - else - { /* Final return will be whatever ASYNC pool flush returned */ - returnCode = fi->FI_PoolFlushStatus; - } - } + returnCode = zERR_POOL_FREEZE_TIMEOUT; + } + else + { /* Final return will be whatever ASYNC pool flush returned */ + returnCode = fi->FI_PoolFlushStatus; + } + } - if ( returnCode == zOK ) - { /* Only return a valid key if caller is required to - * call zPoolThaw!!! - * also save it into the Pool_s for zPoolThawByName(). - */ - fi->FI_Pool->P_FreezeThawKey = *thawKey = fi; + if ( returnCode == zOK ) + { /* Only return a valid key if caller is required to + * call zPoolThaw!!! + * also save it into the Pool_s for zPoolThawByName(). + */ + fi->FI_Pool->P_FreezeThawKey = *thawKey = fi; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( MAGENTA, "zFreeze(exit) no errors\n" ); + DBG_DebugPrintf( MAGENTA, "zFreeze(exit) no errors\n" ); #endif - } - else - { /* When we return an error caller must not call zPoolThaw. - * We call to send thaw event and free resources. - */ - MPKNSS_UNLOCK(); - status = zPoolThaw( fi, returnCode ); - MPKNSS_LOCK(); - zASSERT( status == zOK ); + } + else + { /* When we return an error caller must not call zPoolThaw. + * We call to send thaw event and free resources. + */ + MPKNSS_UNLOCK(); + status = zPoolThaw( fi, returnCode ); + MPKNSS_LOCK(); + zASSERT( status == zOK ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( MAGENTA, "zFreeze(exit) Error %ld\n", returnCode ); + DBG_DebugPrintf( MAGENTA, "zFreeze(exit) Error %ld\n", returnCode ); #endif - } + } - MPKNSS_UNLOCK(); - return( returnCode ); + MPKNSS_UNLOCK(); + return( returnCode ); -} /* End of zPoolFreeze() */ +} /* End of zPoolFreeze() */ /* - * zPoolThawRequired() - - * Returns TRUE if zPoolThaw needs to be called immediately. - * Caller of zPoolFreeze/zPoolThaw needs to call every 1/2 second - * to determine that it must stop trying to snap a pool and call - * zPoolThaw immediately. The caller musr then fail the snap - * creation. + * zPoolThawRequired() - + * Returns TRUE if zPoolThaw needs to be called immediately. + * Caller of zPoolFreeze/zPoolThaw needs to call every 1/2 second + * to determine that it must stop trying to snap a pool and call + * zPoolThaw immediately. The caller musr then fail the snap + * creation. */ STATUS zPoolThawRequired( - void *thawKey ) + void *thawKey ) { - FreezeInfo_s *fi = thawKey; + FreezeInfo_s *fi = thawKey; - MPKNSS_LOCK(); - ZPoolThawRequiredCalls += 1; - zASSERT( fi->FI_Stamp == FI_STAMP ); - if( fi->FI_Stamp != FI_STAMP ) - { - MPKNSS_UNLOCK(); - return( zERR_BAD_PARAMETER_VALUE ); - } - if ( fi->FI_Pool->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP ) - { - MPKNSS_UNLOCK(); - return( zERR_VOLUME_STATE_CHANGE_REQUESTED ); - } - if ( fi->FI_Timeout ) - { - MPKNSS_UNLOCK(); - return( zERR_POOL_FREEZE_TIMEOUT ); - } - MPKNSS_UNLOCK(); - return( zOK ); + MPKNSS_LOCK(); + ZPoolThawRequiredCalls += 1; + zASSERT( fi->FI_Stamp == FI_STAMP ); + if( fi->FI_Stamp != FI_STAMP ) + { + MPKNSS_UNLOCK(); + return( zERR_BAD_PARAMETER_VALUE ); + } + if ( fi->FI_Pool->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP ) + { + MPKNSS_UNLOCK(); + return( zERR_VOLUME_STATE_CHANGE_REQUESTED ); + } + if ( fi->FI_Timeout ) + { + MPKNSS_UNLOCK(); + return( zERR_POOL_FREEZE_TIMEOUT ); + } + MPKNSS_UNLOCK(); + return( zOK ); -} /* End of zPoolThawRequired() */ +} /* End of zPoolThawRequired() */ /* - * zPoolCallbackRequired() - - * Returns TRUE if zPoolNotifyQuiescent needs to be called immediately. - * Freeze/thaw event catchers need to call every 1/2 second - * to determine that it must stop trying to Quiescent. + * zPoolCallbackRequired() - + * Returns TRUE if zPoolNotifyQuiescent needs to be called immediately. + * Freeze/thaw event catchers need to call every 1/2 second + * to determine that it must stop trying to Quiescent. */ STATUS zPoolNotifyQuiescentRequired( - void *key, - void *nebConsumerId ) + void *key, + void *nebConsumerId ) { - FreezeInfo_s *fi = key; + FreezeInfo_s *fi = key; - MPKNSS_LOCK(); - zASSERT( fi != NULL ); - zASSERT( fi->FI_Stamp == FI_STAMP ); - if( fi->FI_Stamp != FI_STAMP ) - { - MPKNSS_UNLOCK(); - return( zERR_BAD_PARAMETER_VALUE ); - } - if ( fi->FI_Timeout ) - { - MPKNSS_UNLOCK(); - return( zERR_POOL_FREEZE_TIMEOUT ); - } - if ( fi->FI_Pool->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP ) - { - MPKNSS_UNLOCK(); - return( zERR_VOLUME_STATE_CHANGE_REQUESTED ); - } - MPKNSS_UNLOCK(); - return( zOK ); + MPKNSS_LOCK(); + zASSERT( fi != NULL ); + zASSERT( fi->FI_Stamp == FI_STAMP ); + if( fi->FI_Stamp != FI_STAMP ) + { + MPKNSS_UNLOCK(); + return( zERR_BAD_PARAMETER_VALUE ); + } + if ( fi->FI_Timeout ) + { + MPKNSS_UNLOCK(); + return( zERR_POOL_FREEZE_TIMEOUT ); + } + if ( fi->FI_Pool->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP ) + { + MPKNSS_UNLOCK(); + return( zERR_VOLUME_STATE_CHANGE_REQUESTED ); + } + MPKNSS_UNLOCK(); + return( zOK ); -} /* End of zPoolCallbackRequired() */ +} /* End of zPoolCallbackRequired() */ /* - * zThaw() - - * This function will cause NSS to inform caring applications to thaw - * their data. + * zThaw() - + * This function will cause NSS to inform caring applications to thaw + * their data. * - * Return - - * thawKey - On success this pointer is filled in with the key to call - * zThaw with. - * status - Return status of the function as follows - * zERR_POOL_FREEZE_BAD_KEY - * zOK - * or other NSS error code. + * Return - + * thawKey - On success this pointer is filled in with the key to call + * zThaw with. + * status - Return status of the function as follows + * zERR_POOL_FREEZE_BAD_KEY + * zOK + * or other NSS error code. * - * Note - - * We do not UNX_LATCH( &fi->FI_Pool->P_FreezeThawLatch ) here because - * the spec says only one call per pool. Therefore the latch gets released - * we everyone is done with 'fi'. + * Note - + * We do not UNX_LATCH( &fi->FI_Pool->P_FreezeThawLatch ) here because + * the spec says only one call per pool. Therefore the latch gets released + * we everyone is done with 'fi'. * - * Warnings - - * This is a documented 3rd party API. + * Warnings - + * This is a documented 3rd party API. */ STATUS zPoolThaw( - void *thawKey, - STATUS opRetCode ) + void *thawKey, + STATUS opRetCode ) { - FreezeInfo_s *fi = thawKey; + FreezeInfo_s *fi = thawKey; - MPKNSS_LOCK(); - ZPoolThawCalls += 1; + MPKNSS_LOCK(); + ZPoolThawCalls += 1; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( MAGENTA, "zPoolThaw(enter)\n" ); + DBG_DebugPrintf( MAGENTA, "zPoolThaw(enter)\n" ); #endif - if ( thawKey == NULL ) - { + if ( thawKey == NULL ) + { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( MAGENTA, "zPoolThaw(exit) Error zERR_POOL_FREEZE_BAD_KEY\n" ); + DBG_DebugPrintf( MAGENTA, "zPoolThaw(exit) Error zERR_POOL_FREEZE_BAD_KEY\n" ); #endif - ZPoolThawCallsBad1 += 1; - MPKNSS_UNLOCK(); - return( zERR_POOL_FREEZE_BAD_KEY ); - } - if ( fi->FI_Stamp != FI_STAMP ) - { + ZPoolThawCallsBad1 += 1; + MPKNSS_UNLOCK(); + return( zERR_POOL_FREEZE_BAD_KEY ); + } + if ( fi->FI_Stamp != FI_STAMP ) + { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( MAGENTA, "zPoolThaw(exit) Error zERR_POOL_FREEZE_BAD_KEY(stamp)\n" ); + DBG_DebugPrintf( MAGENTA, "zPoolThaw(exit) Error zERR_POOL_FREEZE_BAD_KEY(stamp)\n" ); #endif - ZPoolThawCallsBad2 += 1; - MPKNSS_UNLOCK(); - return( zERR_POOL_FREEZE_BAD_KEY ); - } - fi->FI_ThawUTC = GetUTCTime(); + ZPoolThawCallsBad2 += 1; + MPKNSS_UNLOCK(); + return( zERR_POOL_FREEZE_BAD_KEY ); + } + fi->FI_ThawUTC = GetUTCTime(); - ZFT_ThawEvent( fi, fi->FI_Pool, &fi->FI_PoolName[0], opRetCode, &fi->FI_ThawEvent ); - if ( !fi->FI_Timeout ) - { - CANCEL_ALARM( fi->FI_Timer ); - if ( !fi->FI_TimeoutScheduled ) - { /* Force the timeout so things get cleaned up */ - ZFT_TimeOutTimer( &fi->FI_Timer ); - } - } - ZFT_FreezeInfoRelease( WHERE, &fi ); + ZFT_ThawEvent( fi, fi->FI_Pool, &fi->FI_PoolName[0], opRetCode, &fi->FI_ThawEvent ); + if ( !fi->FI_Timeout ) + { + CANCEL_ALARM( fi->FI_Timer ); + if ( !fi->FI_TimeoutScheduled ) + { /* Force the timeout so things get cleaned up */ + ZFT_TimeOutTimer( &fi->FI_Timer ); + } + } + ZFT_FreezeInfoRelease( WHERE, &fi ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( MAGENTA, "zPoolThaw(exit) No Error\n" ); + DBG_DebugPrintf( MAGENTA, "zPoolThaw(exit) No Error\n" ); #endif - MPKNSS_UNLOCK(); - return( zOK ); + MPKNSS_UNLOCK(); + return( zOK ); -} /* End of zPoolThaw() */ +} /* End of zPoolThaw() */ /* - * zPoolThawByName() - - * This function will cause NSS to inform caring applications to thaw - * their data. + * zPoolThawByName() - + * This function will cause NSS to inform caring applications to thaw + * their data. * - * Return - - * poolName - On success this pointer is filled in with the key to call - * zThaw with. - * status - Return status of the function as follows - * zERR_POOL_FREEZE_BAD_KEY - * zOK - * or other NSS error code. + * Return - + * poolName - On success this pointer is filled in with the key to call + * zThaw with. + * status - Return status of the function as follows + * zERR_POOL_FREEZE_BAD_KEY + * zOK + * or other NSS error code. * - * Note - - * We do not UNX_LATCH( &fi->FI_Pool->P_FreezeThawLatch ) here because - * the spec says only one call per pool. Therefore the latch gets released - * we everyone is done with 'fi'. + * Note - + * We do not UNX_LATCH( &fi->FI_Pool->P_FreezeThawLatch ) here because + * the spec says only one call per pool. Therefore the latch gets released + * we everyone is done with 'fi'. * */ STATUS zPoolThawByName( - unicode_t *poolName, - STATUS opRetCode ) + unicode_t *poolName, + STATUS opRetCode ) { - Pool_s *fi_pool = NULL; - void *freezeKey; - GeneralMsg_s dummyGenMsg; + Pool_s *fi_pool = NULL; + void *freezeKey; + GeneralMsg_s dummyGenMsg; - MPKNSS_LOCK(); + MPKNSS_LOCK(); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( MAGENTA, "zPoolThawByName start\n" ); + DBG_DebugPrintf( MAGENTA, "zPoolThawByName start\n" ); #endif - COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); + COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); - /* We say find non active pool's so that caller gets - * pool not active verses pool not found. This is - * done via COMN_PoolActiveLock. - */ - fi_pool = COMN_PoolNameLookup( &dummyGenMsg, poolName, FALSE, NULL ); - if ( NULL == fi_pool ) - { + /* We say find non active pool's so that caller gets + * pool not active verses pool not found. This is + * done via COMN_PoolActiveLock. + */ + fi_pool = COMN_PoolNameLookup( &dummyGenMsg, poolName, FALSE, NULL ); + if ( NULL == fi_pool ) + { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( LRED, "zPoolThawByName - pool not found\n" ); + DBG_DebugPrintf( LRED, "zPoolThawByName - pool not found\n" ); #endif - MPKNSS_UNLOCK(); - return( GetErrno( &dummyGenMsg ) ); - } + MPKNSS_UNLOCK(); + return( GetErrno( &dummyGenMsg ) ); + } #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( MAGENTA, "zPoolThawByName(exit) no errors\n" ); + DBG_DebugPrintf( MAGENTA, "zPoolThawByName(exit) no errors\n" ); #endif - freezeKey = fi_pool->P_FreezeThawKey; - fi_pool->P_FreezeThawKey = NULL; - COMN_Release( &fi_pool ); - MPKNSS_UNLOCK(); + freezeKey = fi_pool->P_FreezeThawKey; + fi_pool->P_FreezeThawKey = NULL; + COMN_Release( &fi_pool ); + MPKNSS_UNLOCK(); - return( zPoolThaw( freezeKey, opRetCode )); -} /* End of zPoolThawByName() */ + return( zPoolThaw( freezeKey, opRetCode )); +} /* End of zPoolThawByName() */ -/* zPoolEventReceived() - - * Function to call when an application has recieved the NEB freeze - * or thaw event. +/* zPoolEventReceived() - + * Function to call when an application has recieved the NEB freeze + * or thaw event. * - * Note - - * This function makes it easy for the freeze code to know how - * many zPoolNotifyQuiescent calls it will be getting. + * Note - + * This function makes it easy for the freeze code to know how + * many zPoolNotifyQuiescent calls it will be getting. */ STATUS zPoolEventReceived( - void *key, - void *nebConsumerId ) + void *key, + void *nebConsumerId ) { - FreezeInfo_s *fi = key; + FreezeInfo_s *fi = key; - MPKNSS_LOCK(); - zASSERT( fi != NULL ); - zASSERT( fi->FI_Stamp == FI_STAMP ); - if( fi->FI_Stamp != FI_STAMP ) - { - MPKNSS_UNLOCK(); - return( zERR_BAD_PARAMETER_VALUE ); - } - if ( fi->FI_FreezeEventProduce ) - { /* Freeze Event */ - ++fi->FI_CallbacksRequired; - } - else - { /* Thaw Event */ - } - MPKNSS_UNLOCK(); - return( zOK ); + MPKNSS_LOCK(); + zASSERT( fi != NULL ); + zASSERT( fi->FI_Stamp == FI_STAMP ); + if( fi->FI_Stamp != FI_STAMP ) + { + MPKNSS_UNLOCK(); + return( zERR_BAD_PARAMETER_VALUE ); + } + if ( fi->FI_FreezeEventProduce ) + { /* Freeze Event */ + ++fi->FI_CallbacksRequired; + } + else + { /* Thaw Event */ + } + MPKNSS_UNLOCK(); + return( zOK ); -} /* End of zPoolEventReceived() */ +} /* End of zPoolEventReceived() */ /* - * Function to call when an application has made its data consistent (or failed). + * Function to call when an application has made its data consistent (or failed). * * * Completion codes. - * zOK Data is consistent - * zOK No data on pool to make consistent - * zERR_POOL_FREEZE_CONSISTENT_FAILED Could not make data consistent - * zERR_POOL_FREEZE_TIMEOUT Not enough time to make data consistent + * zOK Data is consistent + * zOK No data on pool to make consistent + * zERR_POOL_FREEZE_CONSISTENT_FAILED Could not make data consistent + * zERR_POOL_FREEZE_TIMEOUT Not enough time to make data consistent * */ STATUS zPoolNotifyQuiescent( - void *key, - void *nebConsumerId, - STATUS completionCode, - char *applicationName, - char *applicationMessage ) + void *key, + void *nebConsumerId, + STATUS completionCode, + char *applicationName, + char *applicationMessage ) { - FreezeInfo_s *fi = key; + FreezeInfo_s *fi = key; - MPKNSS_LOCK(); - zASSERT( fi != NULL ); - zASSERT( fi->FI_Stamp == FI_STAMP ); - if( fi->FI_Stamp != FI_STAMP ) - { - MPKNSS_UNLOCK(); - return( zERR_BAD_PARAMETER_VALUE ); - } - zASSERT( !fi->FI_CallbacksDone ); - ++fi->FI_CallbacksReceived; + MPKNSS_LOCK(); + zASSERT( fi != NULL ); + zASSERT( fi->FI_Stamp == FI_STAMP ); + if( fi->FI_Stamp != FI_STAMP ) + { + MPKNSS_UNLOCK(); + return( zERR_BAD_PARAMETER_VALUE ); + } + zASSERT( !fi->FI_CallbacksDone ); + ++fi->FI_CallbacksReceived; - ZFT_FASFill( fi->FI_FreezeApplicationStatus, applicationName, applicationMessage, completionCode ); - /* As soon as all callbacks have reported we let the zFreeze - * API complete. - */ - if ( (fi->FI_FreezeEventProduced) && (fi->FI_CallbacksReceived == fi->FI_CallbacksRequired) ) - { - fi->FI_CallbacksDone = TRUE; - ZFT_FreezeInfoRelease( WHERE, &fi ); - } - MPKNSS_UNLOCK(); - return( zOK ); + ZFT_FASFill( fi->FI_FreezeApplicationStatus, applicationName, applicationMessage, completionCode ); + /* As soon as all callbacks have reported we let the zFreeze + * API complete. + */ + if ( (fi->FI_FreezeEventProduced) && (fi->FI_CallbacksReceived == fi->FI_CallbacksRequired) ) + { + fi->FI_CallbacksDone = TRUE; + ZFT_FreezeInfoRelease( WHERE, &fi ); + } + MPKNSS_UNLOCK(); + return( zOK ); -} /* End of zPoolNotifyQuiescent() */ +} /* End of zPoolNotifyQuiescent() */ LONG ZFT_FreezeEvent( - FreezeInfo_s *fi, - Pool_s *pool, - unicode_t *poolName_U, - EventPoolFreeze_s *freezeEvent, - EventPoolThaw_s *thawEvent, - int timeOutSeconds ) + FreezeInfo_s *fi, + Pool_s *pool, + unicode_t *poolName_U, + EventPoolFreeze_s *freezeEvent, + EventPoolThaw_s *thawEvent, + int timeOutSeconds ) { - LONG denyCode; - LONG eCode; + LONG denyCode; + LONG eCode; - /* Send the PoolFreezeEnter event */ - freezeEvent->enterExitID = thawEvent->enterExitID = ++EnterExitEventID; - freezeEvent->poolName = poolName_U; - freezeEvent->poolID = pool->POOLvolumeID; - freezeEvent->timeOutSeconds = timeOutSeconds; - if ( pool->POOLenabledFeatures & zPOOL_FEATURE_SHARED_CLUSTER ) - { - freezeEvent->shared = TRUE; - } - else - { - freezeEvent->shared = FALSE; - } + /* Send the PoolFreezeEnter event */ + freezeEvent->enterExitID = thawEvent->enterExitID = ++EnterExitEventID; + freezeEvent->poolName = poolName_U; + freezeEvent->poolID = pool->POOLvolumeID; + freezeEvent->timeOutSeconds = timeOutSeconds; + if ( pool->POOLenabledFeatures & zPOOL_FEATURE_SHARED_CLUSTER ) + { + freezeEvent->shared = TRUE; + } + else + { + freezeEvent->shared = FALSE; + } - freezeEvent->poolEventReceived = zPoolEventReceived; - freezeEvent->poolNotifyQuiescentRequired = zPoolNotifyQuiescentRequired; - freezeEvent->poolNotifyQuiescent = zPoolNotifyQuiescent; - freezeEvent->key = fi; - fi->FI_FreezeEventProduce = TRUE; - eCode = COMN_SendNSSEvent( EVENT_PoolFreeze, freezeEvent, sizeof(*freezeEvent), &denyCode ); - zASSERT( eCode != OPERATION_DENIED ); /* We are not consumable */ - fi->FI_FreezeEventProduce = FALSE; - fi->FI_FreezeEventProduced = TRUE; - if ( fi->FI_CallbacksReceived == fi->FI_CallbacksRequired ) - { /* This handles the case where all Freeze consumers did - * their zPoolNotifyQuiescent() call in their NEB handler (vs ASYNC). - */ - fi->FI_CallbacksDone = TRUE; - ZFT_FreezeInfoRelease( WHERE, &fi ); - } + freezeEvent->poolEventReceived = zPoolEventReceived; + freezeEvent->poolNotifyQuiescentRequired = zPoolNotifyQuiescentRequired; + freezeEvent->poolNotifyQuiescent = zPoolNotifyQuiescent; + freezeEvent->key = fi; + fi->FI_FreezeEventProduce = TRUE; + eCode = COMN_SendNSSEvent( EVENT_PoolFreeze, freezeEvent, sizeof(*freezeEvent), &denyCode ); + zASSERT( eCode != OPERATION_DENIED ); /* We are not consumable */ + fi->FI_FreezeEventProduce = FALSE; + fi->FI_FreezeEventProduced = TRUE; + if ( fi->FI_CallbacksReceived == fi->FI_CallbacksRequired ) + { /* This handles the case where all Freeze consumers did + * their zPoolNotifyQuiescent() call in their NEB handler (vs ASYNC). + */ + fi->FI_CallbacksDone = TRUE; + ZFT_FreezeInfoRelease( WHERE, &fi ); + } - return( eCode ); + return( eCode ); -} /* End of ZFT_FreezeEvent() */ +} /* End of ZFT_FreezeEvent() */ LONG ZFT_ThawEvent( - FreezeInfo_s *fi, - Pool_s *pool, - unicode_t *poolName_U, - STATUS opRetCode, - EventPoolThaw_s *thawEvent ) + FreezeInfo_s *fi, + Pool_s *pool, + unicode_t *poolName_U, + STATUS opRetCode, + EventPoolThaw_s *thawEvent ) { - LONG denyCode; - LONG eCode; + LONG denyCode; + LONG eCode; - /* Send the PoolThaw event */ - thawEvent->poolName = poolName_U; - thawEvent->poolID = pool->POOLvolumeID; - if ( pool->POOLenabledFeatures & zPOOL_FEATURE_SHARED_CLUSTER ) - { - thawEvent->shared = TRUE; - } - else - { - thawEvent->shared = FALSE; - } + /* Send the PoolThaw event */ + thawEvent->poolName = poolName_U; + thawEvent->poolID = pool->POOLvolumeID; + if ( pool->POOLenabledFeatures & zPOOL_FEATURE_SHARED_CLUSTER ) + { + thawEvent->shared = TRUE; + } + else + { + thawEvent->shared = FALSE; + } - /* Set to the status of the freeze request */ - thawEvent->opRetCode = opRetCode; - thawEvent->key = fi; - eCode = COMN_SendNSSEvent( EVENT_PoolThaw, thawEvent, sizeof(*thawEvent), &denyCode ); - zASSERT( eCode != OPERATION_DENIED ); /* We are not consumable */ + /* Set to the status of the freeze request */ + thawEvent->opRetCode = opRetCode; + thawEvent->key = fi; + eCode = COMN_SendNSSEvent( EVENT_PoolThaw, thawEvent, sizeof(*thawEvent), &denyCode ); + zASSERT( eCode != OPERATION_DENIED ); /* We are not consumable */ - return( eCode ); + return( eCode ); -} /* End of ZFT_ThawEvent() */ +} /* End of ZFT_ThawEvent() */ /* - * zPoolOwnershipGet() - - * Attempts to get exclusive ownership of a pool. If function returns zOK then - * you must call zPoolOwnershipRelease at some point. The exclusive access is - * only valid while the pool is in MAINTENANCE state. NEB must be used to monitor - * when a pool enters/exits MAINTENANCE state. + * zPoolOwnershipGet() - + * Attempts to get exclusive ownership of a pool. If function returns zOK then + * you must call zPoolOwnershipRelease at some point. The exclusive access is + * only valid while the pool is in MAINTENANCE state. NEB must be used to monitor + * when a pool enters/exits MAINTENANCE state. * - * Warnings - - * This is a documented 3rd party API. + * Warnings - + * This is a documented 3rd party API. */ STATUS zPoolOwnershipGet( - unicode_t *poolName, - char *who, /* String to help identify the owner of a pool. Useful - * when a module has more than ONE caller to this - * function. ZLSS passes in WHERE. - */ - void **cookie ) + unicode_t *poolName, + char *who, /* String to help identify the owner of a pool. Useful + * when a module has more than ONE caller to this + * function. ZLSS passes in WHERE. + */ + void **cookie ) { - STATUS status; + STATUS status; - MPKNSS_LOCK(); - status = xPoolOwnershipGet( poolName, who, (PoolOwnership_s **)cookie ); - MPKNSS_UNLOCK(); - return( status ); + MPKNSS_LOCK(); + status = xPoolOwnershipGet( poolName, who, (PoolOwnership_s **)cookie ); + MPKNSS_UNLOCK(); + return( status ); -} /* End of xPoolOwnershipGet() */ +} /* End of xPoolOwnershipGet() */ /* - * xPoolOwnershipGet() - - * Attempts to get exclusive ownership of a pool. If function returns zOK then - * you must call zPoolOwnershipRelease at some point. The exclusive access is - * only valid while the pool is in MAINTENANCE state. NEB must be used to monitor - * when a pool enters/exits MAINTENANCE state. + * xPoolOwnershipGet() - + * Attempts to get exclusive ownership of a pool. If function returns zOK then + * you must call zPoolOwnershipRelease at some point. The exclusive access is + * only valid while the pool is in MAINTENANCE state. NEB must be used to monitor + * when a pool enters/exits MAINTENANCE state. * */ STATUS xPoolOwnershipGet( - unicode_t *poolName, - char *who, /* String to help identify the owner of a pool. Useful - * when a module has more than ONE caller to this - * function. ZLSS passes in WHERE. - */ - PoolOwnership_s **cookie ) + unicode_t *poolName, + char *who, /* String to help identify the owner of a pool. Useful + * when a module has more than ONE caller to this + * function. ZLSS passes in WHERE. + */ + PoolOwnership_s **cookie ) { - NINT waitFlag; - Pool_s *pool; - PoolOwnership_s *po; - GeneralMsg_s dummyGenMsg; + NINT waitFlag; + Pool_s *pool; + PoolOwnership_s *po; + GeneralMsg_s dummyGenMsg; - COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); + COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); - po = zalloc( sizeof( PoolOwnership_s ) ); - if ( po == NULL ) - { - return( zERR_NO_MEMORY ); - } + po = zalloc( sizeof( PoolOwnership_s ) ); + if ( po == NULL ) + { + return( zERR_NO_MEMORY ); + } - pool = COMN_PoolNameLookup( &dummyGenMsg, poolName, FALSE, NULL ); - if ( pool == NULL ) - { - free( po ); - return( GetErrno( &dummyGenMsg ) ); - } - /* - * We will use the XLATCH code that will not block is we can - * not get an X Latch. - */ - X_NOWAIT( &pool->P_MaintenaceLatch, waitFlag ); - /* Is the latch owned by someone else? */ - if ( waitFlag == WAITED ) - { /* Someone already owns */ - COMN_Release( &pool ); - free( po ); - return( zERR_ACCESS_DENIED ); - } - po->PO_signature = PO_SIGNATURE; -// po->PO_moduleHandle = moduleHandle; - po->PO_pool = pool; /* We take COMN_PoolNameLookup use count. Prevents pool - * from being freed on us. Does not prevent movement - * between pool STATES!. - */ - LB_strncpy( po->PO_who, who, sizeof(po->PO_who)-1 ); - po->PO_who[sizeof(po->PO_who)-1] = '\0'; - pool->P_Owner = po; - *cookie = po; - (void)NSSLOG_printf( CMN_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_OWNERSHIP, "Pool \"%U\" is owned by %s", - poolName, who ); - return( zOK ); + pool = COMN_PoolNameLookup( &dummyGenMsg, poolName, FALSE, NULL ); + if ( pool == NULL ) + { + free( po ); + return( GetErrno( &dummyGenMsg ) ); + } + /* + * We will use the XLATCH code that will not block is we can + * not get an X Latch. + */ + X_NOWAIT( &pool->P_MaintenaceLatch, waitFlag ); + /* Is the latch owned by someone else? */ + if ( waitFlag == WAITED ) + { /* Someone already owns */ + COMN_Release( &pool ); + free( po ); + return( zERR_ACCESS_DENIED ); + } + po->PO_signature = PO_SIGNATURE; +// po->PO_moduleHandle = moduleHandle; + po->PO_pool = pool; /* We take COMN_PoolNameLookup use count. Prevents pool + * from being freed on us. Does not prevent movement + * between pool STATES!. + */ + LB_strncpy( po->PO_who, who, sizeof(po->PO_who)-1 ); + po->PO_who[sizeof(po->PO_who)-1] = '\0'; + pool->P_Owner = po; + *cookie = po; + (void)NSSLOG_printf( CMN_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_OWNERSHIP, "Pool \"%U\" is owned by %s", + poolName, who ); + return( zOK ); -} /* End of xPoolOwnershipGet() */ +} /* End of xPoolOwnershipGet() */ /* - * zPoolOwnershipRelease() - - * Releases ownership of a pool. Must only be called ONCE and only - * if zPoolOwnershipGet returns zOK. + * zPoolOwnershipRelease() - + * Releases ownership of a pool. Must only be called ONCE and only + * if zPoolOwnershipGet returns zOK. * - * Warnings - - * This is a documented 3rd party API. + * Warnings - + * This is a documented 3rd party API. */ STATUS zPoolOwnershipRelease( - void *cookie, - char *who ) + void *cookie, + char *who ) { - STATUS status; + STATUS status; - MPKNSS_LOCK(); - status = xPoolOwnershipRelease( cookie, who ); - MPKNSS_UNLOCK(); - return( status ); + MPKNSS_LOCK(); + status = xPoolOwnershipRelease( cookie, who ); + MPKNSS_UNLOCK(); + return( status ); -} /* End of zPoolOwnershipRelease() */ +} /* End of zPoolOwnershipRelease() */ /* - * xPoolOwnershipRelease() - - * Releases ownership of a pool. Must only be called ONCE and only - * if xPoolOwnershipGet returns zOK. + * xPoolOwnershipRelease() - + * Releases ownership of a pool. Must only be called ONCE and only + * if xPoolOwnershipGet returns zOK. * */ STATUS xPoolOwnershipRelease( - PoolOwnership_s *po, - char *who ) + PoolOwnership_s *po, + char *who ) { - typedef struct Stack_s { - unicode_t name[zMAX_COMPONENT_NAME]; - GeneralMsg_s dummyGenMsg; - } Stack_s; - STACK_ALLOC(); + typedef struct Stack_s { + unicode_t name[zMAX_COMPONENT_NAME]; + GeneralMsg_s dummyGenMsg; + } Stack_s; + STACK_ALLOC(); - COMN_SETUP_GENERAL_MSG_NOSA(&aStack->dummyGenMsg); - if ( (po == NULL) || (po->PO_signature != PO_SIGNATURE) ) - { - STACK_FREE(); - return( zERR_BAD_PARAMETER_VALUE ); - } + COMN_SETUP_GENERAL_MSG_NOSA(&aStack->dummyGenMsg); + if ( (po == NULL) || (po->PO_signature != PO_SIGNATURE) ) + { + STACK_FREE(); + return( zERR_BAD_PARAMETER_VALUE ); + } - (void)COMN_GetPoolName( &aStack->dummyGenMsg, po->PO_pool, aStack->name, NELEMS(aStack->name) ); - (void)NSSLOG_printf( CMN_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_OWNERSHIP, "Pool \"%U\" has been released by %s", - aStack->name, who ); - po->PO_signature = ~PO_SIGNATURE; - po->PO_pool->P_Owner = NULL; - UNX_LATCH( &po->PO_pool->P_MaintenaceLatch ); - COMN_Release( &po->PO_pool ); - free( po ); - STACK_FREE(); - return( zOK ); + (void)COMN_GetPoolName( &aStack->dummyGenMsg, po->PO_pool, aStack->name, NELEMS(aStack->name) ); + (void)NSSLOG_printf( CMN_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_OWNERSHIP, "Pool \"%U\" has been released by %s", + aStack->name, who ); + po->PO_signature = ~PO_SIGNATURE; + po->PO_pool->P_Owner = NULL; + UNX_LATCH( &po->PO_pool->P_MaintenaceLatch ); + COMN_Release( &po->PO_pool ); + free( po ); + STACK_FREE(); + return( zOK ); -} /* End of xPoolOwnershipRelease() */ +} /* End of xPoolOwnershipRelease() */ diff --git a/src/nwnss/comn/common/zPublics.c b/src/nwnss/comn/common/zPublics.c new file mode 100644 index 0000000..c71c595 --- /dev/null +++ b/src/nwnss/comn/common/zPublics.c @@ -0,0 +1,237 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996-2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) Initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2006-11-14 05:57:30 +0530 (Tue, 14 Nov 2006) $ + | + | $RCSfile$ + | $Revision: 1632 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This contains the public NLM interfaces to the file system + +-------------------------------------------------------------------------*/ +#include /* NSS Library Includes*/ +#include +#include +#include + +#include "zPublics.h" +#include "sazlib.h" +#include "comnPublics.h" +#include "msgGen.h" +#include "msgName.h" +#include "msgIO.h" +#include "fileHandle.h" + + +#ifdef NOTREADY +/**************************************************************************** + * Perform an Asynchronous read on the specified open file + *****************************************************************************/ +STATUS zAsyncReadCache( + NINT connectionID, + NINT fileHandleID, + QUAD blockNumber, + ADDR callBackContext, + void (*asyncReadCallBack)( + ADDR callBackContext, + STATUS completionCode, + NINT bytesRead, + zBuffer_s *releaseBuffer), + QUAD *ret_BlocksRemaining) +{ +// GeneralMsg_s genMsg; +// AsyncFileIOMsg_s asyncIOMsg; +// FileHandleIDP_s fileHandleIDP; +// +// COMN_STRUCT_INIT(asyncIOMsg); +// COMN_SETUP_ASYNC_FILEIO_MSG(&asyncIOMsg,blockNumber,asyncReadCallBack, +// callBackContext, ret_BlocksRemaining); +// COMN_SET_FILEHANDLE_ID(&fileHandleIDP,fileHandleID); +// MPKNSS_LOCK(); +// COMN_SETUP_GENERAL_MSG(&genMsg,connectionID,zNO_TASK,zSAGENT_Z); +// COMN_AsyncRead(&genMsg,&asyncIOMsg,&fileHandleIDP); +// MPKNSS_UNLOCK(); +// return GetErrno(&genMsg); +} + +/**************************************************************************** + * Release the cache buffer returned by an Asynchronous read + *****************************************************************************/ +void zAsyncReleaseCache( + zBuffer_s *releaseBuffer) +{ +// zASSERT(releaseBuffer); +// MPKNSS_LOCK(); +// COMN_AsyncReleaseBuffer((PubBuffer_s *)releaseBuffer); +// MPKNSS_UNLOCK(); +} + +/*************************************************************************** + * Re read a cache buffer + ***************************************************************************/ +zBuffer_s *zAsyncReReadCache( + ADDR reReadHandle, + QUAD blockNumber) +{ +// zBuffer_s *buffer; +// MPKNSS_LOCK(); +// buffer = (zBuffer_s *)COMN_FastReadCache((MyCache_s *)reReadHandle, +// blockNumber); +// MPKNSS_UNLOCK(); +// return (buffer); +} +#endif + + +/************************************************************************** + * Close the given file + ***************************************************************************/ +STATUS zBrowseUsers( + NINT connectionID, + unicode_t *volName, + NINT numEntriesRequested, + UserID_t *lastUserReturned, /* inout */ + zUserRest_s *userEntries, /* out */ + NINT *numEntriesReturned) /* out */ +{ + GeneralMsg_s genMsg; + Volume_s *volume; + + MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG(&genMsg,connectionID,zNO_TASK,zSAGENT_Z); + uniupr(volName); + volume = COMN_VolumeNameLookup(&genMsg, volName, TRUE, NULL); + if (volume == NULL) + { + return GetErrno(&genMsg); + } + if (COMN_LockVolumeActive(&genMsg, volume, FALSE) != zOK) + { + COMN_Release(&volume); + return GetErrno(&genMsg); + + } + VOL_BrowseUsersInVolume(&genMsg, volume, numEntriesRequested, + lastUserReturned, (COMNUserRest_s *)userEntries, numEntriesReturned, + BROWSE_USERS_GET_USED_OR_RESTRICTED); + + COMN_UnlockVolumeActive(volume, FALSE); + COMN_Release(&volume); + MPKNSS_UNLOCK(); + return GetErrno(&genMsg); +} + + + +/**************************************************************************** + * Set the data size for a file object + *****************************************************************************/ +STATUS zSetDataSize( + SLONG unused, + NINT connectionID, + NINT fileHandleID, + QUAD dataSize, + NINT setSizeFlags) +{ + Key_t key; + zNSSMsg_s msg; + STATUS rc; + + MPKNSS_LOCK(); + + key = CONN_KEY(connectionID, fileHandleID); + msg.sys.numDataAreas = 0; + msg.body.id.xid = 0; + msg.body.id.externalFlags = setSizeFlags; + msg.body.rw.startingOffset = dataSize; + + rc = MSG_Call(key, NSS_SETEOF, (Msg_s *)&msg); + + MPKNSS_UNLOCK(); + return rc; +} + + +/************************************************************************ + * APIs for the Mandatory Access Control Services + ************************************************************************/ + +STATUS zGetNSSVolumeLabel( + unicode_t *volName, + LONG labelSize, + void *label) +{ + GeneralMsg_s genMsg; + Volume_s *volume; + + MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG(&genMsg,zSYS_CONNECTION,zNO_TASK,zSAGENT_Z); + + uniupr(volName); + + volume = COMN_VolumeNameLookup(&genMsg, volName, TRUE, NULL); + + if (volume != NULL) + { + COMN_GetNSSVolumeLabel(&genMsg, volume, labelSize, label); + COMN_Release(&volume); + } + + MPKNSS_UNLOCK(); + + return (GetErrno(&genMsg)); +} + + +STATUS zSetNSSVolumeLabel( + unicode_t *volName, + LONG labelSize, + void *label) +{ + GeneralMsg_s genMsg; + Volume_s *volume; + + MPKNSS_LOCK(); + + COMN_SETUP_GENERAL_MSG(&genMsg,zSYS_CONNECTION,zNO_TASK,zSAGENT_Z); + + uniupr(volName); + + volume = COMN_VolumeNameLookup(&genMsg, volName, TRUE, NULL); + + if (volume != NULL) + { + COMN_SetNSSVolumeLabel(&genMsg, volume, labelSize, label); + COMN_Release(&volume); + } + + MPKNSS_UNLOCK(); + + return (GetErrno(&genMsg)); +} + diff --git a/include/nwnss/comn/main/comnAudit.h b/src/nwnss/comn/comnAudit.h similarity index 99% rename from include/nwnss/comn/main/comnAudit.h rename to src/nwnss/comn/comnAudit.h index 749435a..2570773 100644 --- a/include/nwnss/comn/main/comnAudit.h +++ b/src/nwnss/comn/comnAudit.h @@ -66,3 +66,4 @@ extern void NSSLAF_LogTrusteeChange( #endif #endif /* #ifdef _COMNAUDIT_H_ */ + diff --git a/include/nwnss/comn/comnCmdline.h b/src/nwnss/comn/comnCmdline.h similarity index 96% rename from include/nwnss/comn/comnCmdline.h rename to src/nwnss/comn/comnCmdline.h index 9e08144..55de96a 100644 --- a/include/nwnss/comn/comnCmdline.h +++ b/src/nwnss/comn/comnCmdline.h @@ -38,7 +38,7 @@ #define _PSSCMDLINE_H_ #ifndef _OMNI_H_ -#include +#include #endif #ifdef __cplusplus @@ -67,10 +67,10 @@ BOOL VOL_ChangeVolumeSetup( // NINT fromLoadCmdline, // NINT *didHelp); extern void getBucketStats( - NINT *maxInBucket, - NINT *totalEntries, + NINT *maxInBucket, + NINT *totalEntries, NINT *numUsedBuckets, - DQhead_t *bucketHead, + DQhead_t *bucketHead, NINT size); extern void UnregisterNSSSetCmds(); diff --git a/src/nwnss/comn/comnModules.mk b/src/nwnss/comn/comnModules.mk new file mode 100644 index 0000000..d6b6ba5 --- /dev/null +++ b/src/nwnss/comn/comnModules.mk @@ -0,0 +1,490 @@ +############################################################################## +# +# (C) Copyright 2003 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +########################################################################## +# This defines what MODULES are being built for this NLM +# +# $Author: bbhanuprakash $ +# $Date: 2008-03-04 15:24:09 +0530 (Tue, 04 Mar 2008) $ +# +# $RCSfile$ +# $Revision: 2291 $ +# +########################################################################## +MODULE_VERSION=15 + +#------------------------------------------------------------------------- +# Build OPTIONS +#------------------------------------------------------------------------- +BUILD_WITH_KERNEL_FLAGS=1 + +#set to 0 if you are NOT using source code control +IS_USING_SOURCE_CONTROL=1 + +#Set to ONE if you want the linked files to be copied to the SDK/BIN directory. +COPY_TO_SDK_BIN=1 + + #set to ONE if you only want to copy the OPTIMIZED version to SDK/BIN. + COPY_OPTIMIZED_ONLY=0 + +#Set this to ONE if you are building a NETWARE version independent NLM +#(not NETWARE version specific) +NETWARE_VERSION_INDEPENDENT=0 + + #if ONE include the NETWARE .H files in the compiler search paths. + USE_NETWARE_INCLUDES=1 + + #if ONE include the NETWARE import file at LINK time + USE_NETWARE_IMPORTS=1 + +#If ONE IMPORT the LIBNSS APIs and include in the search path SDK/LIBRARY +#and SDK/PUBLIC +IMPORT_INDEPENDENT_LIBNSS=1 + +#If ONE include in the search path SDK/LIBRARY and SDK/PUBLIC +USE_LIBNSS_INCLUDES=1 + +#If ONE then LINK with the NSS library and include all of the NSS library +#directories in the compiler search paths. This includes the SDK/PUBLIC, +#SDK/INCLUDE, SDK/INTERNAL, LIBRARY/SRC directories. +LINK_WITH_NSSLIB=0 + +#if ONE then IMPORT the NSS library and COMN layer APIS and include the +#SDK/PUBLIC directory in the compiler search paths. +IMPORT_NSSLIB=1 + + #If ONE and (LINK_WITH_NSSLIB==1 or IMPORT_NSSLIB==1) then do the same + #operation to the NSSLIB area you are doing to the local area. + CHECK_NSSLIB=0 + + #If ONE and (CHECK_NSSLIB==1) then we will clean the NSSLIB area when we + #clean the local area. + CLEAN_NSSLIB=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INCLUDE directory in + #the compiler search paths + USE_NSS_SDK_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/COMNSA directory in + #the compiler search paths + USE_NSS_SDK_COMNSA_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INTERNAL directory in + #the compiler search paths + USE_NSS_SDK_INTERNAL_INCLUDES=1 + +#if ONE then do NOT import the NSS COMMON layer APIs +DONT_IMPORT_COMMON_LAYER=1 + +#if ONE, compile and link with the NETWARE sdk environment. +USE_NETWARE_SDK=0 + +#if ONE, include DS headers. +USE_NDS_INCLUDES=1 + +#if ONE, do LANGUAGE ENABLING processing +DO_LANGUAGE_ENABLING=1 + +#Set to null (i.e. no value) to not add XDC data to the NLM. For most +#NetWare 5.0 NLMs, the value should be -u. +MOAB_XDC_TOOL_OPTION=-n + +#************************************************************************* +# List of source directories for NSS +#************************************************************************* +SOURCE_DIRECTORIES=\ + authsys \ + common \ + main \ + namespace \ + compression \ + sbs \ + aes + +#************************************************************************* +# Source Modules for NSS (.C .386) +#************************************************************************* +AUTHSYS_SRC= \ + authsys/authorize.c \ + authsys/zasAuthCache.c \ + authsys/zasAuthModel.c \ + authsys/zasAuthSpace.c \ + authsys/zasDecision.c \ + authsys/unixAuthModel.c \ + authsys/unixAuthSpace.c \ + authsys/unixDecision.c + +COMMON_SRC= \ + common/adminVolFile.c \ + common/adminVolume.c \ + common/authBeast.c \ + common/avolSimpleDir.c \ + common/beastClass.c \ + common/beastDelete.c \ + common/beastHash.c \ + common/beastIO.c \ + common/beastRelease.c \ + common/beastStartup.c \ + common/checker.c \ + common/cmdLineRecovery.c \ + common/comnAudit.c \ + common/comnDSI.c \ + common/comnDataStream.c \ + common/comnEFL.c \ + common/comnEvent.c \ + common/comnFile.c \ + common/comnIO.c \ + common/comnLib.c \ + common/comnLock.c \ + common/comnLog.c \ + common/comnLookup.c \ + common/comnMacintosh.c \ + common/comnMacShortName.c \ + common/comnOpLock.c \ + common/comnPool.c \ + common/comnRename.c \ + common/comnStartup.c \ + common/comnTask.c \ + common/comnUnicode.c \ + common/comnVariableData.c \ + common/comnVol.c \ + common/comnWild.c \ + common/comnXaction.c \ + common/contextHandle.c \ + common/dirQuotas.c \ + common/eflMgmt.c \ + common/extAttrBeast.c \ + common/fileBeast.c \ + common/fileHandle.c \ + common/fsmsg.c \ + common/hardLinkBeast.c \ + common/hmc.c \ + common/mgmt.c \ + common/mgmtFiles.c \ + common/mgmtPool.c \ + common/mgmtVol.c \ + common/name.c \ + common/nameCache.c \ + common/nameLookup.c \ + common/nameScan.c \ + common/nameScanDebug.c \ + common/namedBeast.c \ + common/objectIDStore.c \ + common/pssConnection.c \ + common/registerLSS.c \ + common/repair.c \ + common/restartCount.c \ + common/rootBeast.c \ + common/sAgentHandle.c \ + common/sazLib.c \ + common/searchMap.c \ + common/seqUpdater.c \ + common/uxaction.c \ + common/virtualIO.c \ + common/volBeast.c \ + common/volStartup.c \ + common/cSA.c \ + common/cro.c \ + common/cSAcache.c \ + common/csaLease.c \ + common/csaManage.c \ + common/cSAmanager.c \ + common/zAPI.c \ + common/zPool.c \ + common/zFriends.c \ + common/zPublics.c + +COMPRESSION_SRC= \ + compression/cdcomp.c \ + compression/cdcompa.c \ + compression/cduncomp.c \ + compression/cduncompa.c \ + compression/cmActivity.c \ + compression/cmAlgoMan.c \ + compression/cmBgCompress.c \ + compression/cmCompDecomp.c \ + compression/cmCompFile.c \ + compression/cmControl.c \ + compression/cmRuntime.c \ + compression/comnCompress.c \ + compression/copyAlgo.c \ + compression/nwAlgo.c + +MAIN_SRC=\ + main/comnCmdline.c \ + main/marshal.c \ + main/comnLKM.c \ + main/pssStartup.c \ + main/comnsaSDKSym.c \ + main/nssCOMNSym.c \ + main/qdiv.c \ + main/xlssSym.c \ + main/zPoolSym.c \ + main/zPublicsSym.c + +NAMESPACE_SRC= \ + namespace/dataStreamNSpace.c \ + namespace/dosNSWild.c \ + namespace/dosNSpace.c \ + namespace/extAttrNSpace.c \ + namespace/longNSpace.c \ + namespace/macNSpace.c \ + namespace/nameSpace.c \ + namespace/unixNSpace.c + +SBS_SRC= \ + sbs/sbsMFL.c \ + sbs/sbsMgmt.c + +AES_SRC= \ + aes/aes_core.c \ + aes/aes_cbc.c + + +#------------------------------------------------------------------------- +# All source files as one definition +#------------------------------------------------------------------------- +SOURCE_FILES=\ + comnVersion.c \ + $(AUTHSYS_SRC) \ + $(COMMON_SRC) \ + $(COMPRESSION_SRC) \ + $(NAMESPACE_SRC) \ + $(SBS_SRC) \ + $(AES_SRC) \ + $(MAIN_SRC) +ifeq (${UNOPT_ENV},1) + SOURCE_FILES += main/unssCOMNSym.c +endif + +SOURCE_FILES_NODEBUG= + +#************************************************************************* +# Source Include files for NSS (.H .inc) +#************************************************************************* +BASE_INC=\ + adminVolume.h \ + comnCmdline.h \ + csa.h \ + cro.h \ + mgmt.h \ + nameScan.h \ + pssStartup.h \ + zasAuthCache.h \ + purgeDir.h \ + objectIDStore.h \ + checker.h \ + seqUpdater.h \ + aes.h + +AUTHSYS_INC=\ + authsys/zasAuthSpace.h + +COMMON_INC=\ + common/avolSimpleDir.h \ + common/beastClass.h \ + common/beastStartup.h \ + common/dirQuotas.h \ + common/csaLease.h \ + common/csaManage.h \ + common/hmc.h \ + common/sazlib.h + +COMPRESSION_INC= \ + compression/cmCompFile.h \ + compression/cmActivity.h \ + compression/cmRuntime.h \ + compression/cdcommon.h \ + compression/cdcomp.h \ + compression/cdnetwar.h \ + compression/cdreada.h \ + compression/cduncomp.h \ + compression/nwAlgo.h + +MAIN_INC= + +NAMESPACE_INC= \ + namespace/dataStreamNSpace.h \ + namespace/dosNSpace.h \ + namespace/extAttrNSpace.h \ + namespace/longNSpace.h \ + namespace/nspaceStartup.h + +SBS_INC= + +AES_INC= \ + aes/aes_locl.h + +#------------------------------------------------------------------------- +# All include files +#------------------------------------------------------------------------- +INCLUDE_FILES=\ + $(BASE_INC) \ + $(AUTHSYS_INC) \ + $(COMMON_INC) \ + $(COMPRESSION_INC) \ + $(NAMESPACE_INC) \ + $(MAIN_INC) \ + $(SBS_INC) \ + $(AES_INC) + +#------------------------------------------------------------------------- +# Additional source files that need to be checked out +#------------------------------------------------------------------------- +OTHER_FILES=\ + Module.supported + +#------------------------------------------------------------------------- +# This defines what routines are being EXPORTED. You should put .IMP +# files in the "UTILITY_EXPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_EXPORTS= + +UTILITY_EXPORTS_VIA_FILE= + +# $(NSSLIBRARY_IMPORT) \ +#ifndef OPT_ENV +# $(NSSLIBRARY_UNOPT_IMPORT) +#endif + +#------------------------------------------------------------------------- +# This defines what routines are being IMPORTED. You should put .IMP +# files in the "UTILITY_IMPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_IMPORTS= + + +UTILITY_IMPORTS_VIA_FILE= + + +#------------------------------------------------------------------------- +# Library definitions +# This defines additional libraries to LINK with and additional +# directories to put on out INCLUDE path. +#------------------------------------------------------------------------- +#additional libraries to link with +EXTRA_LIBRARIES= +EXTRA_STATIC_LIBRARIES= +EXTRA_DYNAMIC_LIBRARIES= +EXTRA_LIBRARY_INCLPATH= + +#------------------------------------------------------------------------- +# Include path +# This defines additional include path to compile with +#------------------------------------------------------------------------- +#additional include path +EXTRA_INCLUDE_PATH=\ + ${BASEDIR}/public_core/sharedsrc \ + +#------------------------------------------------------------------------- +# Additional C and ASSEMBLY options to use +#------------------------------------------------------------------------- +EXTRA_C_OPTIONS= +EXTRA_ASM_OPTIONS= +EXTRA_LINK_OPTIONS= + +#------------------------------------------------------------------------- +# Additional module attributes +#------------------------------------------------------------------------- +MODULE_DESCRIPTION='NSS Common Support Layer (COMN)' +MODULE_ADDITIONAL_COPYRIGHT=Patents 5,787,439; 5,903,720; 5,915,253; 6,466,944 Other Patents Pending. +#MODULE_OPTIONS=OPTION reentrant +MODULE_OPTIONS= +MODULE_DEPENDENCIES= +MODULE_TYPE= +MODULE_NAME=nsscomn +MODULE_EXTENSION= +MODULE_START_ROUTINE= +MODULE_EXIT_ROUTINE= +#set to 1 if you want the optimized NLM to be packed +MODULE_PACK_NLM=1 + + +#========================================================================= +#========================================================================= +# LOCAL BUILD RULES +#========================================================================= +#========================================================================= + +#------------------------------------------------------------------------- +# Default BUILD rule +#------------------------------------------------------------------------- +DEFAULT: DEFAULT_BUILD + +#------------------------------------------------------------------------- +# Additional rules +#------------------------------------------------------------------------- +#BUILD_GREENRIVER_OPT: \ +# COMPILE_OPT_GREENRIVER \ +# LINK_OPT_GREENRIVER + +#BUILD_GREENRIVER_UNOPT: \ +# COMPILE_UNOPT_GREENRIVER \ +# LINK_UNOPT_GREENRIVER + +BUILD_MOAB_MP_UNOPT: \ + COMPILE_UNOPT_MP_MOAB \ + LINK_UNOPT_MP_MOAB + +BUILD_MOAB_MP_OPT: \ + COMPILE_OPT_MP_MOAB \ + LINK_OPT_MP_MOAB + + +BUILD_MOAB_SP_UNOPT: + @echo "...This NLM does not have an UNOPTIMIZED SP specific version" + +BUILD_MOAB_SP_OPT: + @echo "...This NLM does not have an OPTIMIZED SP specific version" + + +#BUILD_MOAB_SP_UNOPT: \ +# COMPILE_UNOPT_SP_MOAB \ +# LINK_UNOPT_SP_MOAB +# +#BUILD_MOAB_SP_OPT: \ +# COMPILE_OPT_SP_MOAB \ +# LINK_OPT_SP_MOAB + +#------------------------------------------------------------------------- +# Language Enabling rules +#------------------------------------------------------------------------- +mdb: \ + DEFAULT_MDB + +umdb: \ + LOCAL_MDB + +mdbCreate: \ + DEFAULT_CREATE_MDB_FILE + +#------------------------------------------------------------------------- +# Other rules +#------------------------------------------------------------------------- +deps: DEFAULT_DEPS + +cscope: DEFAULT_CSCOPE + diff --git a/src/nwnss/comn/comnVersion.c b/src/nwnss/comn/comnVersion.c index 01cebaa..55e4252 100644 --- a/src/nwnss/comn/comnVersion.c +++ b/src/nwnss/comn/comnVersion.c @@ -36,7 +36,7 @@ +-------------------------------------------------------------------------*/ #include -VersionInformation_s CMN_VersionInfo = +VersionInformation_s CMN_VersionInfo = { ZMAJV, ZMINV, diff --git a/include/nwnss/include/cdcommon.h b/src/nwnss/comn/compression/cdcommon.h similarity index 79% rename from include/nwnss/include/cdcommon.h rename to src/nwnss/comn/compression/cdcommon.h index d501155..db97c8c 100644 --- a/include/nwnss/include/cdcommon.h +++ b/src/nwnss/comn/compression/cdcommon.h @@ -62,8 +62,8 @@ typedef struct compressFileHeader_s { typedef struct AlgorithmCustomStats_s { - BYTE *Description; - LONG Value; + BYTE *Description; + LONG Value; } COMPRESS_CUSTOM_STATS, *COMPRESS_CUSTOM_STATS_P; @@ -91,52 +91,52 @@ typedef struct CompressFileEntry_s { typedef struct CompressionStats_s { - BYTE *CompressionAlgorithmName; - LONG CompressionAlogrythmCode; + BYTE *CompressionAlgorithmName; + LONG CompressionAlogrythmCode; - LONG NumberOfCompressions; - LONG UnableToCompressCount; - LONG TotalSectorsUsedIfNotCompressed; - LONG TotalSectorsUsedCompressed; - LONG CompressionTickCount; - LONG CompressionAbortedCount; - LONG CompressionMemoryAllocationFailures; - LONG CompressionIOErrors; - LONG CompressionFileTooBig; - LONG CompressionFileTooSmall; + LONG NumberOfCompressions; + LONG UnableToCompressCount; + LONG TotalSectorsUsedIfNotCompressed; + LONG TotalSectorsUsedCompressed; + LONG CompressionTickCount; + LONG CompressionAbortedCount; + LONG CompressionMemoryAllocationFailures; + LONG CompressionIOErrors; + LONG CompressionFileTooBig; + LONG CompressionFileTooSmall; - COMPRESS_FILE_ENTRY *FilesBeingCompressed; - COMPRESS_FILE_ENTRY *FilesQueuedToBeCompressed; + COMPRESS_FILE_ENTRY *FilesBeingCompressed; + COMPRESS_FILE_ENTRY *FilesQueuedToBeCompressed; /* custom statistics */ - LONG CustomStatsCount; + LONG CustomStatsCount; - COMPRESS_CUSTOM_STATS_P CustomStats; + COMPRESS_CUSTOM_STATS_P CustomStats; } COMPRESS_STATS, *COMPRESS_STATS_P; typedef struct DeCompressionStats_s { - BYTE *DecompressionAlgorithmName; - LONG DecompressionAlogrythmCode; + BYTE *DecompressionAlgorithmName; + LONG DecompressionAlogrythmCode; - LONG TotalDecompressionsDone; - LONG TotalSectorsDecompressed; - LONG DecompressionTickCount; - LONG DecompressionAbortedCount; - LONG DecompressionMemoryAllocationFailures; - LONG DecompressionFileCorruptionCount; - LONG DecompressionIOErrors; + LONG TotalDecompressionsDone; + LONG TotalSectorsDecompressed; + LONG DecompressionTickCount; + LONG DecompressionAbortedCount; + LONG DecompressionMemoryAllocationFailures; + LONG DecompressionFileCorruptionCount; + LONG DecompressionIOErrors; - COMPRESS_FILE_ENTRY *FilesBeingDecompressed; - COMPRESS_FILE_ENTRY *FilesQueuedToBeDecompressed; + COMPRESS_FILE_ENTRY *FilesBeingDecompressed; + COMPRESS_FILE_ENTRY *FilesQueuedToBeDecompressed; /* custom statistics */ - LONG CustomStatsCount; + LONG CustomStatsCount; - COMPRESS_CUSTOM_STATS_P CustomStats; + COMPRESS_CUSTOM_STATS_P CustomStats; } DECOMPRESS_STATS, *DECOMPRESS_STATS_P; @@ -146,14 +146,14 @@ typedef struct DeCompressionStats_s { * * ***************************************************************************/ - /* things you might want to know: - 1. file name - 2. percent completed - 3. stage - 4. deleted file or not - 5. ratio so far - 6. - */ + /* things you might want to know: + 1. file name + 2. percent completed + 3. stage + 4. deleted file or not + 5. ratio so far + 6. + */ /* stage : 0- analyzing file 1-building compressed version */ @@ -199,30 +199,30 @@ typedef struct DecompressStatusNode_s { ***************************************************************************/ typedef struct CompressAlgorithm_s { - struct CompressAlgorithm_s *next; - LONG (*CompressFile)( IoHandle_t inHandle, IoHandle_t outHandle, - IoHandle_t tempHandle, LONG inFileSize, LONG volume, - ADDR *compressionHandle, BYTE *fileName, - CompressStatus_t *compressStatus ); - void (*GetStats)(); - BYTE CompressionCode; - struct ResourceTagStructure *ResourceTag; + struct CompressAlgorithm_s *next; + LONG (*CompressFile)( IoHandle_t inHandle, IoHandle_t outHandle, + IoHandle_t tempHandle, LONG inFileSize, LONG volume, + ADDR *compressionHandle, BYTE *fileName, + CompressStatus_t *compressStatus ); + void (*GetStats)(); + BYTE CompressionCode; + struct ResourceTagStructure *ResourceTag; } COMPRESS_ALGO, *COMPRESS_ALGO_P; typedef struct DecompressAlgorithm_s { - struct DecompressAlgorithm_s *next; - LONG (*DecompressFile)( IoHandle_t inHandle, IoHandle_t outHandle, - ADDR *decompressHandle, BYTE *fileName, LONG volume, - LONG directoryEntry ); - void (*GetStats)(); - BYTE DecompressionCode; - struct ResourceTagStructure *ResourceTag; + struct DecompressAlgorithm_s *next; + LONG (*DecompressFile)( IoHandle_t inHandle, IoHandle_t outHandle, + ADDR *decompressHandle, BYTE *fileName, LONG volume, + LONG directoryEntry ); + void (*GetStats)(); + BYTE DecompressionCode; + struct ResourceTagStructure *ResourceTag; } DECOMPRESS_ALGO, *DECOMPRESS_ALGO_P; /*************************************************************************** * - * + * * ***************************************************************************/ @@ -282,3 +282,4 @@ extern BYTE CompressionEnabledTable[]; /****************************************************************************/ /****************************************************************************/ + diff --git a/src/nwnss/comn/compression/cdcomp.c b/src/nwnss/comn/compression/cdcomp.c index fa1a890..4dd4b69 100644 --- a/src/nwnss/comn/compression/cdcomp.c +++ b/src/nwnss/comn/compression/cdcomp.c @@ -1,26 +1,26 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996-1999 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996-1999 Novell, Inc. + | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | Netware file compression algorithm ported to NSS + | Netware file compression algorithm ported to NSS | |--------------------------------------------------------------------------- | @@ -31,7 +31,7 @@ | $Revision: 1522 $ | |--------------------------------------------------------------------------- - | Module Description: + | Module Description: | +-------------------------------------------------------------------------*/ #include @@ -40,12 +40,10 @@ #include "cmDefs.h" #include "cmActivity.h" #include "nwAlgo.h" -#include "schedule.h" #define DATA_ENCODE_MARKER 1 extern LONG GetCurrentTime(); -extern void CYieldUntilIdle(void); extern LONG CCDCountTreeNodes( compressNode_tp node, LONG *count ); extern LONG CCDFreeShannonTree( compressNode_tp node ); @@ -76,68 +74,68 @@ COMPRESS_ALGO_P CompressionAlgorithmsList = NULL; #define WRITE_TEMP_BYTE( cp, byte ) \ if (cp->WriteCurrentPointer == cp->WriteBufferEnd) { \ - if ((ccode = CCDGetNewTempBlock( cp )) !=0) return(ccode); } \ + if ((ccode = CCDGetNewTempBlock( cp )) !=0) return(ccode); } \ *cp->WriteCurrentPointer = (BYTE)byte;\ cp->WriteCurrentPointer++; - + #define WRITE_TEMP_WORD( cp, word ) \ if ((cp->WriteCurrentPointer+1) >= cp->WriteBufferEnd) \ - { \ - WRITE_TEMP_BYTE( cp, (BYTE)word ) \ - WRITE_TEMP_BYTE( cp, (BYTE)(word >> 8)) \ + { \ + WRITE_TEMP_BYTE( cp, (BYTE)word ) \ + WRITE_TEMP_BYTE( cp, (BYTE)(word >> 8)) \ } \ - else{ \ - *((WORD *)cp->WriteCurrentPointer) = (WORD)word; \ - cp->WriteCurrentPointer += 2; \ + else{ \ + *((WORD *)cp->WriteCurrentPointer) = (WORD)word; \ + cp->WriteCurrentPointer += 2; \ } #define WRITE_TEMP_LONG( cp , longvar ) \ - if ((cp->WriteCurrentPointer+3) >= cp->WriteBufferEnd) \ - { \ - WRITE_TEMP_BYTE( cp, (BYTE)(longvar) ) \ - WRITE_TEMP_BYTE( cp, (BYTE)(longvar >> 8) ) \ - WRITE_TEMP_BYTE( cp, (BYTE)(longvar >> 16) ) \ - WRITE_TEMP_BYTE( cp, (BYTE)(longvar >> 24) ) \ - } \ + if ((cp->WriteCurrentPointer+3) >= cp->WriteBufferEnd) \ + { \ + WRITE_TEMP_BYTE( cp, (BYTE)(longvar) ) \ + WRITE_TEMP_BYTE( cp, (BYTE)(longvar >> 8) ) \ + WRITE_TEMP_BYTE( cp, (BYTE)(longvar >> 16) ) \ + WRITE_TEMP_BYTE( cp, (BYTE)(longvar >> 24) ) \ + } \ else\ - { \ - *((LONG *)cp->WriteCurrentPointer) = longvar; \ - cp->WriteCurrentPointer += 4; \ + { \ + *((LONG *)cp->WriteCurrentPointer) = longvar; \ + cp->WriteCurrentPointer += 4; \ } #define READ_TEMP_BYTE( dest ) \ if ( InputCurrentPointer == InputBufferEnd ) { \ - if ((ccode=CCDGetNewTempReadBlock( readCache, &ReadFileSize,\ - &InputCurrentPointer, &InputBufferEnd, &ReadEOFPointer))!=0) return(ccode); \ - cp->compressStatus->currentIntermediateBlocks++; } \ + if ((ccode=CCDGetNewTempReadBlock( readCache, &ReadFileSize,\ + &InputCurrentPointer, &InputBufferEnd, &ReadEOFPointer))!=0) return(ccode); \ + cp->compressStatus->currentIntermediateBlocks++; } \ dest = *InputCurrentPointer; \ InputCurrentPointer++; #define READ_TEMP_WORD( dest ) \ - if ((InputCurrentPointer+1) >= InputBufferEnd){ \ - READ_TEMP_BYTE( b1 ) \ - READ_TEMP_BYTE( b2 ) \ - dest = (b2 << 8 ) | b1; \ - } \ - else{ \ - dest = *((WORD *)(InputCurrentPointer)); \ - InputCurrentPointer += 2; \ + if ((InputCurrentPointer+1) >= InputBufferEnd){ \ + READ_TEMP_BYTE( b1 ) \ + READ_TEMP_BYTE( b2 ) \ + dest = (b2 << 8 ) | b1; \ + } \ + else{ \ + dest = *((WORD *)(InputCurrentPointer)); \ + InputCurrentPointer += 2; \ } #define READ_TEMP_LONG( dest ) \ - if ((InputCurrentPointer+3) >= InputBufferEnd){ \ - READ_TEMP_BYTE( b1 ) \ - READ_TEMP_BYTE( b2 ) \ - READ_TEMP_BYTE( b3 ) \ - READ_TEMP_BYTE( b4 ) \ - dest = (b4 << 24) | (b3 << 16) | (b2 << 8) | b1;\ + if ((InputCurrentPointer+3) >= InputBufferEnd){ \ + READ_TEMP_BYTE( b1 ) \ + READ_TEMP_BYTE( b2 ) \ + READ_TEMP_BYTE( b3 ) \ + READ_TEMP_BYTE( b4 ) \ + dest = (b4 << 24) | (b3 << 16) | (b2 << 8) | b1;\ } \ else { \ - dest = *((LONG *)(InputCurrentPointer); \ - InputCurrentPointer += 4; \ + dest = *((LONG *)(InputCurrentPointer); \ + InputCurrentPointer += 4; \ } @@ -166,29 +164,29 @@ CCDGetNewTempBlock( compressData_tp cp ) { LONG ccode; - if ((ccode=NSSCCDReturnWriteCacheBlock( cp->WriteBufferHandle, - cp->WriteHandle, CD_SYSTEM_SECTORS_PER_BUFFER, (LONG)1 - )) != 0) + if ((ccode=NSSCCDReturnWriteCacheBlock( cp->WriteBufferHandle, + cp->WriteHandle, CD_SYSTEM_SECTORS_PER_BUFFER, (LONG)1 + )) != 0) { - cp->WriteBufferBegin = NULL; - return(ccode); + cp->WriteBufferBegin = NULL; + return(ccode); } cp->WriteBufferBegin = NULL; if ((zStopCompression(cp->FileVolume)) || (cp->AbortCompression)) - return( COMPRESS_ERROR_ABORTED ); + return( COMPRESS_ERROR_ABORTED ); cp->WriteBlockNumber++; if ((ccode=NSSCCDGetWriteCacheBlock( cp->WriteHandle, cp->WriteBlockNumber, - (LONG)1, &(cp->WriteCurrentPointer), &(cp->WriteBufferHandle) - )) != 0) return(ccode); + (LONG)1, &(cp->WriteCurrentPointer), &(cp->WriteBufferHandle) + )) != 0) return(ccode); if ((zStopCompression(cp->FileVolume)) || (cp->AbortCompression)) - return( COMPRESS_ERROR_ABORTED ); + return( COMPRESS_ERROR_ABORTED ); - cp->WriteBufferBegin = cp->WriteCurrentPointer; - cp->WriteBufferEnd = cp->WriteCurrentPointer + CD_SYSTEM_CACHE_BUFFER_SIZE ; + cp->WriteBufferBegin = cp->WriteCurrentPointer; + cp->WriteBufferEnd = cp->WriteCurrentPointer + CD_SYSTEM_CACHE_BUFFER_SIZE ; cp->compressStatus->totalIntermediateBlocks++; @@ -212,22 +210,22 @@ CCDGetNewTempReadBlock( { LONG ccode, valid, hole; - if (*ReadFileSize > CD_SYSTEM_CACHE_BUFFER_SIZE) - { - if ((ccode=NSSCCDFreeReadAheadBuffer( readCache )) != 0) return(ccode); + if (*ReadFileSize > CD_SYSTEM_CACHE_BUFFER_SIZE) + { + if ((ccode=NSSCCDFreeReadAheadBuffer( readCache )) != 0) return(ccode); - if ((ccode=NSSCCDGetReadAheadBuffer( readCache, - (BYTE **) InputCurrentPointer, &valid, &hole )) != 0) - return(ccode); + if ((ccode=NSSCCDGetReadAheadBuffer( readCache, + (BYTE **) InputCurrentPointer, &valid, &hole )) != 0) + return(ccode); - if (hole) return( COMPRESS_ERROR_INVALID_HOLE ); + if (hole) return( COMPRESS_ERROR_INVALID_HOLE ); - *ReadFileSize -= CD_SYSTEM_CACHE_BUFFER_SIZE; + *ReadFileSize -= CD_SYSTEM_CACHE_BUFFER_SIZE; - if (*ReadFileSize <= CD_SYSTEM_CACHE_BUFFER_SIZE) - *InputBufferEnd = *ReadEOFPointer = *InputCurrentPointer + *ReadFileSize; - else - *InputBufferEnd = *InputCurrentPointer + CD_SYSTEM_CACHE_BUFFER_SIZE; + if (*ReadFileSize <= CD_SYSTEM_CACHE_BUFFER_SIZE) + *InputBufferEnd = *ReadEOFPointer = *InputCurrentPointer + *ReadFileSize; + else + *InputBufferEnd = *InputCurrentPointer + CD_SYSTEM_CACHE_BUFFER_SIZE; } else { @@ -237,7 +235,7 @@ CCDGetNewTempReadBlock( return((LONG)0); } - + /************************************************************************* * * * * @@ -250,16 +248,16 @@ CCDProcessHole( compressData_tp cp, LONG holeSize ) compressHoleNode_tp newHole; if ((newHole=(compressHoleNode_tp) CD_MALLOC( sizeof(compressHoleNode_t))) == NULL) - return( COMPRESS_ERROR_OUT_OF_RAM ); + return( COMPRESS_ERROR_OUT_OF_RAM ); newHole->next = NULL; if (!cp->HoleHead) { - cp->HoleHead = cp->HoleTail = newHole; + cp->HoleHead = cp->HoleTail = newHole; } else { - cp->HoleTail->next = newHole; - cp->HoleTail = newHole; + cp->HoleTail->next = newHole; + cp->HoleTail = newHole; } newHole->offset = cp->HoleTotalByteCount + cp->DataReadIndex; @@ -270,7 +268,7 @@ CCDProcessHole( compressData_tp cp, LONG holeSize ) cp->ReadFileSize -= holeSize; cp->compressStatus->currentInitialBlocks += - holeSize >> CD_SYSTEM_CACHE_BUFFER_SHIFT; + holeSize >> CD_SYSTEM_CACHE_BUFFER_SHIFT; return((LONG)0); } @@ -292,77 +290,77 @@ CCDWriteOutHoles( compressData_tp cp, LONG *holeCount ) while (hole) { - hcount++; + hcount++; - if (cp->WriteCurrentPointer == cp->WriteBufferEnd) - { - *(LONG *)cp->WriteCurrentPointer = - CCDCheckSumBlock4KMinus1( (LONG *)cp->WriteBufferBegin ); + if (cp->WriteCurrentPointer == cp->WriteBufferEnd) + { + *(LONG *)cp->WriteCurrentPointer = + CCDCheckSumBlock4KMinus1( (LONG *)cp->WriteBufferBegin ); - if ((ccode=NSSCCDReturnWriteCacheBlock( cp->WriteBufferHandle, - cp->WriteHandle, CD_SYSTEM_SECTORS_PER_BUFFER, (LONG)0 )) != 0) - { - cp->WriteBufferBegin = NULL; - return(ccode); - } + if ((ccode=NSSCCDReturnWriteCacheBlock( cp->WriteBufferHandle, + cp->WriteHandle, CD_SYSTEM_SECTORS_PER_BUFFER, (LONG)0 )) != 0) + { + cp->WriteBufferBegin = NULL; + return(ccode); + } - cp->WriteBufferBegin = NULL; + cp->WriteBufferBegin = NULL; - if ((zStopCompression(cp->FileVolume)) || (cp->AbortCompression)) return( COMPRESS_ERROR_ABORTED ); + if ((zStopCompression(cp->FileVolume)) || (cp->AbortCompression)) return( COMPRESS_ERROR_ABORTED ); - cp->WriteBlockNumber++; + cp->WriteBlockNumber++; - if ((ccode=NSSCCDGetWriteCacheBlock( cp->WriteHandle, cp->WriteBlockNumber, - (LONG)0, &(cp->WriteCurrentPointer), &(cp->WriteBufferHandle) - )) != 0) return(ccode); + if ((ccode=NSSCCDGetWriteCacheBlock( cp->WriteHandle, cp->WriteBlockNumber, + (LONG)0, &(cp->WriteCurrentPointer), &(cp->WriteBufferHandle) + )) != 0) return(ccode); - cp->WriteBufferBegin = cp->WriteCurrentPointer; - cp->WriteBufferEnd = cp->WriteCurrentPointer + - (CD_SYSTEM_CACHE_BUFFER_SIZE - 4); - } + cp->WriteBufferBegin = cp->WriteCurrentPointer; + cp->WriteBufferEnd = cp->WriteCurrentPointer + + (CD_SYSTEM_CACHE_BUFFER_SIZE - 4); + } - *(LONG *)cp->WriteCurrentPointer = hole->offset; + *(LONG *)cp->WriteCurrentPointer = hole->offset; - cp->WriteCurrentPointer += sizeof(LONG); + cp->WriteCurrentPointer += sizeof(LONG); - if (cp->WriteCurrentPointer == cp->WriteBufferEnd) - { - *(LONG *)cp->WriteCurrentPointer = - CCDCheckSumBlock4KMinus1( (LONG *)cp->WriteBufferBegin ); + if (cp->WriteCurrentPointer == cp->WriteBufferEnd) + { + *(LONG *)cp->WriteCurrentPointer = + CCDCheckSumBlock4KMinus1( (LONG *)cp->WriteBufferBegin ); - if ((ccode=NSSCCDReturnWriteCacheBlock( cp->WriteBufferHandle, - cp->WriteHandle, CD_SYSTEM_SECTORS_PER_BUFFER, (LONG)0 )) != 0) - { - cp->WriteBufferBegin = NULL; - return(ccode); - } + if ((ccode=NSSCCDReturnWriteCacheBlock( cp->WriteBufferHandle, + cp->WriteHandle, CD_SYSTEM_SECTORS_PER_BUFFER, (LONG)0 )) != 0) + { + cp->WriteBufferBegin = NULL; + return(ccode); + } - cp->WriteBufferBegin = NULL; + cp->WriteBufferBegin = NULL; - if ((zStopCompression(cp->FileVolume)) || (cp->AbortCompression)) return( COMPRESS_ERROR_ABORTED ); + if ((zStopCompression(cp->FileVolume)) || (cp->AbortCompression)) return( COMPRESS_ERROR_ABORTED ); - cp->WriteBlockNumber++; + cp->WriteBlockNumber++; - if ((ccode=NSSCCDGetWriteCacheBlock( cp->WriteHandle, cp->WriteBlockNumber, - (LONG)0, &(cp->WriteCurrentPointer), &(cp->WriteBufferHandle) - )) != 0) return(ccode); + if ((ccode=NSSCCDGetWriteCacheBlock( cp->WriteHandle, cp->WriteBlockNumber, + (LONG)0, &(cp->WriteCurrentPointer), &(cp->WriteBufferHandle) + )) != 0) return(ccode); - cp->WriteBufferBegin = cp->WriteCurrentPointer; - cp->WriteBufferEnd = cp->WriteCurrentPointer + - (CD_SYSTEM_CACHE_BUFFER_SIZE - 4); - } + cp->WriteBufferBegin = cp->WriteCurrentPointer; + cp->WriteBufferEnd = cp->WriteCurrentPointer + + (CD_SYSTEM_CACHE_BUFFER_SIZE - 4); + } - *(LONG *)cp->WriteCurrentPointer = hole->size; + *(LONG *)cp->WriteCurrentPointer = hole->size; - cp->WriteCurrentPointer += sizeof(LONG); + cp->WriteCurrentPointer += sizeof(LONG); - prev = hole; + prev = hole; - hole = hole->next; + hole = hole->next; - cp->HoleHead = hole; + cp->HoleHead = hole; - CD_FREE( prev ); + CD_FREE( prev ); } *holeCount = hcount; @@ -390,9 +388,9 @@ CCDCountDuplicates( compressData_tp cp ) j = cp->DataProcessedIndex + COMPRESS_MIN_DUPLICATE_COUNT ; for(i=COMPRESS_MIN_DUPLICATE_COUNT; - (iUnprocessedDataSize) && (iUnprocessedDataSize) && (iDataProcessedIndex > cp->WindowSize) - lowLimit = cp->DataProcessedIndex - cp->WindowSize; + lowLimit = cp->DataProcessedIndex - cp->WindowSize; else - lowLimit = 0; + lowLimit = 0; hiLimit = cp->UnprocessedDataSize; @@ -442,43 +440,43 @@ CCDFindMatch( register compressData_tp cp, WORD *length, WORD *offset ) while ( next > lowLimit ) { - if (( READ_BYTE( cp, next ) == b1 ) && - ( READ_BYTE( cp, next + 1 ) == b2 ) && - ( READ_BYTE( cp, next + 2 ) == b3 ) - ) - { - j = next + 3; + if (( READ_BYTE( cp, next ) == b1 ) && + ( READ_BYTE( cp, next + 1 ) == b2 ) && + ( READ_BYTE( cp, next + 2 ) == b3 ) + ) + { + j = next + 3; - for ( i = compareStart; i < hiLimit; i++, j++) - { - if (!(i & COMPRESS_RESCHEDULE_BYTE_MASK)) - { - CYieldUntilIdle(); + for ( i = compareStart; i < hiLimit; i++, j++) + { + if (!(i & COMPRESS_RESCHEDULE_BYTE_MASK)) + { + CYieldUntilIdle(); - if ((zStopCompression(cp->FileVolume)) || (cp->AbortCompression)) - return( COMPRESS_ERROR_ABORTED ); - } - if (( READ_BYTE( cp, j ) != READ_BYTE( cp, i ))) - break; - } + if ((zStopCompression(cp->FileVolume)) || (cp->AbortCompression)) + return( COMPRESS_ERROR_ABORTED ); + } + if (( READ_BYTE( cp, j ) != READ_BYTE( cp, i ))) + break; + } - i -= base; + i -= base; - if (i > (*length)) - { - (*length) = i; - (*offset) = cp->DataProcessedIndex - next; - if ((i == (COMPRESS_WINDOW_SIZE-1)) || - (i == cp->UnprocessedDataSize)) break; - } - } + if (i > (*length)) + { + (*length) = i; + (*offset) = cp->DataProcessedIndex - next; + if ((i == (COMPRESS_WINDOW_SIZE-1)) || + (i == cp->UnprocessedDataSize)) break; + } + } - next = cp->Links[ next & COMPRESS_LINK_MASK ]; + next = cp->Links[ next & COMPRESS_LINK_MASK ]; - CYieldUntilIdle(); + CYieldUntilIdle(); - if ((zStopCompression(cp->FileVolume)) || (cp->AbortCompression)) - return( COMPRESS_ERROR_ABORTED ); + if ((zStopCompression(cp->FileVolume)) || (cp->AbortCompression)) + return( COMPRESS_ERROR_ABORTED ); } return((LONG)0); @@ -502,30 +500,30 @@ CCDProcessMatch( compressData_tp cp, WORD length, WORD offset ) if ((length > 8196) || ( offset > 8196)) { return 1; -// Abend(MSGNot("Compression: invalid length or offset (>8196).")); +// Abend(MSGNot("Compression: invalid length or offset (>8196).")); } j = cp->DataProcessedIndex; if ((j+length+2) < cp->ReadFileSize) - for ( i=0; iFileVolume)) || (cp->AbortCompression)) - return( COMPRESS_ERROR_ABORTED ); - } - b1 = READ_BYTE( cp, j ); - b2 = READ_BYTE( cp, j + 1 ); - b3 = READ_BYTE( cp, j + 2 ); + if ((zStopCompression(cp->FileVolume)) || (cp->AbortCompression)) + return( COMPRESS_ERROR_ABORTED ); + } + b1 = READ_BYTE( cp, j ); + b2 = READ_BYTE( cp, j + 1 ); + b3 = READ_BYTE( cp, j + 2 ); - hash = GET_HASH( b1, b2, b3 ); + hash = GET_HASH( b1, b2, b3 ); - cp->Links[ j & COMPRESS_LINK_MASK ] = cp->Heads[ hash ] ; - cp->Heads[ hash ] = j; - } + cp->Links[ j & COMPRESS_LINK_MASK ] = cp->Heads[ hash ] ; + cp->Heads[ hash ] = j; + } cp->UnprocessedDataSize -= length; @@ -537,13 +535,13 @@ CCDProcessMatch( compressData_tp cp, WORD length, WORD offset ) if ( length < 0xFE ) { - cp->LengthTable[ length ] ++; + cp->LengthTable[ length ] ++; - WRITE_TEMP_BYTE( cp, (BYTE)length ) + WRITE_TEMP_BYTE( cp, (BYTE)length ) - WRITE_TEMP_WORD( cp, offset ) + WRITE_TEMP_WORD( cp, offset ) - return((LONG)0); + return((LONG)0); } cp->LengthTable[ 0xFE ]++; @@ -611,13 +609,13 @@ CCDProcessDuplicates( register compressData_tp cp, WORD length ) if (value < (LONG) 0xFE) { - cp->LengthTable[ value ] ++; + cp->LengthTable[ value ] ++; - WRITE_TEMP_BYTE( cp, value ) + WRITE_TEMP_BYTE( cp, value ) - WRITE_TEMP_WORD( cp, 1 ) + WRITE_TEMP_WORD( cp, 1 ) - return((LONG)0); + return((LONG)0); } cp->LengthTable[ 0xFE ]++; @@ -638,19 +636,19 @@ CCDProcessDuplicates( register compressData_tp cp, WORD length ) ***************************************************************************/ #define RELINQUISH_CONTROL \ - CYieldUntilIdle(); \ + CYieldUntilIdle(); \ if (cp->compressStatus->projectedCompressedSize > cp->compressStatus->originalSize ) \ - return( COMPRESS_ERROR_UNCOMPRESSABLE ); \ + return( COMPRESS_ERROR_UNCOMPRESSABLE ); \ if ((zStopCompression( cp->FileVolume ) ) || (cp->AbortCompression)) \ - return( COMPRESS_ERROR_ABORTED ); \ + return( COMPRESS_ERROR_ABORTED ); \ cp->compressStatus->currentInitialBlocks = \ - (cp->DataProcessedIndex >> CD_SYSTEM_CACHE_BUFFER_SHIFT); + (cp->DataProcessedIndex >> CD_SYSTEM_CACHE_BUFFER_SHIFT); LONG CCDAnalyzeFile( register compressData_tp cp, readCache_tp readCache, - compressCheckHeader_tp header + compressCheckHeader_tp header ) { LONG i, j, hash; @@ -659,215 +657,215 @@ CCDAnalyzeFile( LONG ccode; while ((cp->WindowSize < COMPRESS_WINDOW_SIZE) && - (cp->DataProcessedIndex < cp->ReadFileSize )) + (cp->DataProcessedIndex < cp->ReadFileSize )) { - if (!(cp->DataProcessedIndex & COMPRESS_RESCHEDULE_BYTE_MASK)) - { - RELINQUISH_CONTROL - } + if (!(cp->DataProcessedIndex & COMPRESS_RESCHEDULE_BYTE_MASK)) + { + RELINQUISH_CONTROL + } - j = (LONG)cp->DataProcessedIndex; - b1 = READ_BYTE( cp, j ); + j = (LONG)cp->DataProcessedIndex; + b1 = READ_BYTE( cp, j ); - if ( ((LONG)cp->UnprocessedDataSize >= COMPRESS_MIN_DUPLICATE_COUNT) && - ( b1 == READ_BYTE( cp, j + 4 )) && - ( b1 == READ_BYTE( cp, j + 3 )) && - ( b1 == READ_BYTE( cp, j + 2 )) && - ( b1 == READ_BYTE( cp, j + 1 )) && - ( ( length = CCDCountDuplicates( cp ) ) >= COMPRESS_MIN_DUPLICATE_COUNT) - ) + if ( ((LONG)cp->UnprocessedDataSize >= COMPRESS_MIN_DUPLICATE_COUNT) && + ( b1 == READ_BYTE( cp, j + 4 )) && + ( b1 == READ_BYTE( cp, j + 3 )) && + ( b1 == READ_BYTE( cp, j + 2 )) && + ( b1 == READ_BYTE( cp, j + 1 )) && + ( ( length = CCDCountDuplicates( cp ) ) >= COMPRESS_MIN_DUPLICATE_COUNT) + ) - { - if ((ccode= CCDProcessDuplicates( cp, length )) !=0) return(ccode); + { + if ((ccode= CCDProcessDuplicates( cp, length )) !=0) return(ccode); - RELINQUISH_CONTROL + RELINQUISH_CONTROL - length--; + length--; - cp->WindowSize += length; + cp->WindowSize += length; - header->DataEncodes++; + header->DataEncodes++; - if (length < 0xFE) header->LengthOffsetEncodes++; - else header->LargeLengthOffsetEncodes++; + if (length < 0xFE) header->LengthOffsetEncodes++; + else header->LargeLengthOffsetEncodes++; - header->LengthTotal += length; - header->OffsetTotal++; + header->LengthTotal += length; + header->OffsetTotal++; - continue; - } + continue; + } - if ((LONG)cp->UnprocessedDataSize > 3) - { - if ((ccode=CCDFindMatch( cp , &length, &offset )) !=0) return(ccode); + if ((LONG)cp->UnprocessedDataSize > 3) + { + if ((ccode=CCDFindMatch( cp , &length, &offset )) !=0) return(ccode); - if (length > 2) - { - if((ccode = CCDProcessMatch( cp, length, offset )) !=0) return(ccode); + if (length > 2) + { + if((ccode = CCDProcessMatch( cp, length, offset )) !=0) return(ccode); - RELINQUISH_CONTROL + RELINQUISH_CONTROL - cp->WindowSize += length; + cp->WindowSize += length; - if (length < 0xFE) header->LengthOffsetEncodes++; - else header->LargeLengthOffsetEncodes++; + if (length < 0xFE) header->LengthOffsetEncodes++; + else header->LargeLengthOffsetEncodes++; - header->OffsetTotal += offset; - header->LengthTotal += length; + header->OffsetTotal += offset; + header->LengthTotal += length; - continue; - } - } + continue; + } + } - if ((j+1) < cp->ReadFileSize) b2 = READ_BYTE( cp, (j+1) ); else b2=0; - if ((j+2) < cp->ReadFileSize) b3 = READ_BYTE( cp, (j+2) ); else b3=0; + if ((j+1) < cp->ReadFileSize) b2 = READ_BYTE( cp, (j+1) ); else b2=0; + if ((j+2) < cp->ReadFileSize) b3 = READ_BYTE( cp, (j+2) ); else b3=0; - hash = GET_HASH( b1, b2, b3 ); + hash = GET_HASH( b1, b2, b3 ); - cp->Links[ j & COMPRESS_LINK_MASK ] = cp->Heads[ hash ]; + cp->Links[ j & COMPRESS_LINK_MASK ] = cp->Heads[ hash ]; - cp->Heads[ hash ] = (LONG)cp->DataProcessedIndex; + cp->Heads[ hash ] = (LONG)cp->DataProcessedIndex; - cp->DataProcessedIndex++; + cp->DataProcessedIndex++; - cp->UnprocessedDataSize--; + cp->UnprocessedDataSize--; - cp->DataTable[ b1 ] ++; + cp->DataTable[ b1 ] ++; - WRITE_TEMP_BYTE( cp, DATA_ENCODE_MARKER ) + WRITE_TEMP_BYTE( cp, DATA_ENCODE_MARKER ) - WRITE_TEMP_BYTE( cp, b1 ) + WRITE_TEMP_BYTE( cp, b1 ) - cp->WindowSize++; + cp->WindowSize++; - header->DataEncodes++; + header->DataEncodes++; } if (cp->WindowSize > COMPRESS_WINDOW_SIZE ) - cp->WindowSize = COMPRESS_WINDOW_SIZE; + cp->WindowSize = COMPRESS_WINDOW_SIZE; while ( cp->DataProcessedIndex < cp->ReadFileSize ) { - if (!(cp->DataProcessedIndex & COMPRESS_RESCHEDULE_BYTE_MASK )) - { - RELINQUISH_CONTROL - } + if (!(cp->DataProcessedIndex & COMPRESS_RESCHEDULE_BYTE_MASK )) + { + RELINQUISH_CONTROL + } - while ( - ( cp->UnprocessedDataSize < COMPRESS_WINDOW_SIZE ) && - ( cp->DataReadIndex < cp->ReadFileSize ) - ) - { + while ( + ( cp->UnprocessedDataSize < COMPRESS_WINDOW_SIZE ) && + ( cp->DataReadIndex < cp->ReadFileSize ) + ) + { - if ((ccode = NSSCCDFreeReadAheadBuffer( readCache )) != 0 ) return(ccode); + if ((ccode = NSSCCDFreeReadAheadBuffer( readCache )) != 0 ) return(ccode); - for(i=0; iReadCachePointers [i] = cp->ReadCachePointers[i+1]; - cp->ReadBytesValidInCache[i] = cp->ReadBytesValidInCache[i+1]; - cp->ReadCacheHoleFlags [i] = cp->ReadCacheHoleFlags[i+1]; - } + for(i=0; iReadCachePointers [i] = cp->ReadCachePointers[i+1]; + cp->ReadBytesValidInCache[i] = cp->ReadBytesValidInCache[i+1]; + cp->ReadCacheHoleFlags [i] = cp->ReadCacheHoleFlags[i+1]; + } /* since there are never two holes back to back the next get should get data */ GetAnotherReadCache:; - if (cp->DataReadIndex < cp->ReadFileSize) - if ((ccode=NSSCCDGetReadAheadBuffer( readCache, - (BYTE **)&(cp->ReadCachePointers[COMPRESS_READ_CACHE_BUFFER_RANGE -1]), - &(cp->ReadBytesValidInCache[COMPRESS_READ_CACHE_BUFFER_RANGE -1]), - &(cp->ReadCacheHoleFlags[COMPRESS_READ_CACHE_BUFFER_RANGE -1]) )) != 0) - return(ccode); + if (cp->DataReadIndex < cp->ReadFileSize) + if ((ccode=NSSCCDGetReadAheadBuffer( readCache, + (BYTE **)&(cp->ReadCachePointers[COMPRESS_READ_CACHE_BUFFER_RANGE -1]), + &(cp->ReadBytesValidInCache[COMPRESS_READ_CACHE_BUFFER_RANGE -1]), + &(cp->ReadCacheHoleFlags[COMPRESS_READ_CACHE_BUFFER_RANGE -1]) )) != 0) + return(ccode); - if (cp->ReadCacheHoleFlags[ COMPRESS_READ_CACHE_BUFFER_RANGE -1 ]) - { - if ((ccode=CCDProcessHole( cp, cp->ReadBytesValidInCache[COMPRESS_READ_CACHE_BUFFER_RANGE-1] )) != 0) return(ccode); + if (cp->ReadCacheHoleFlags[ COMPRESS_READ_CACHE_BUFFER_RANGE -1 ]) + { + if ((ccode=CCDProcessHole( cp, cp->ReadBytesValidInCache[COMPRESS_READ_CACHE_BUFFER_RANGE-1] )) != 0) return(ccode); - header->NumberOfHoles++; + header->NumberOfHoles++; + + cp->ReadBytesValidInCache[ COMPRESS_READ_CACHE_BUFFER_RANGE -1 ] =0; + cp->ReadCacheHoleFlags[ COMPRESS_READ_CACHE_BUFFER_RANGE -1 ] =0; - cp->ReadBytesValidInCache[ COMPRESS_READ_CACHE_BUFFER_RANGE -1 ] =0; - cp->ReadCacheHoleFlags[ COMPRESS_READ_CACHE_BUFFER_RANGE -1 ] =0; + goto GetAnotherReadCache; + } - goto GetAnotherReadCache; - } + cp->UnprocessedDataSize += cp->ReadBytesValidInCache[COMPRESS_READ_CACHE_BUFFER_RANGE-1]; + cp->DataReadIndex += cp->ReadBytesValidInCache[COMPRESS_READ_CACHE_BUFFER_RANGE-1]; - cp->UnprocessedDataSize += cp->ReadBytesValidInCache[COMPRESS_READ_CACHE_BUFFER_RANGE-1]; - cp->DataReadIndex += cp->ReadBytesValidInCache[COMPRESS_READ_CACHE_BUFFER_RANGE-1]; + cp->ReadCacheBase++; + } - cp->ReadCacheBase++; - } + j = (LONG)cp->DataProcessedIndex; - j = (LONG)cp->DataProcessedIndex; + if (jReadFileSize) b1 = READ_BYTE( cp, j ); - if (jReadFileSize) b1 = READ_BYTE( cp, j ); + if ( (cp->UnprocessedDataSize >= COMPRESS_MIN_DUPLICATE_COUNT) && + ( b1 == READ_BYTE( cp, j + 4 )) && + ( b1 == READ_BYTE( cp, j + 3 )) && + ( b1 == READ_BYTE( cp, j + 2 )) && + ( b1 == READ_BYTE( cp, j + 1 )) && + ( ( length = CCDCountDuplicates( cp ) ) >= COMPRESS_MIN_DUPLICATE_COUNT) + ) + { + if ((ccode=CCDProcessDuplicates( cp, length )) !=0) return(ccode); - if ( (cp->UnprocessedDataSize >= COMPRESS_MIN_DUPLICATE_COUNT) && - ( b1 == READ_BYTE( cp, j + 4 )) && - ( b1 == READ_BYTE( cp, j + 3 )) && - ( b1 == READ_BYTE( cp, j + 2 )) && - ( b1 == READ_BYTE( cp, j + 1 )) && - ( ( length = CCDCountDuplicates( cp ) ) >= COMPRESS_MIN_DUPLICATE_COUNT) - ) - { - if ((ccode=CCDProcessDuplicates( cp, length )) !=0) return(ccode); + RELINQUISH_CONTROL - RELINQUISH_CONTROL + length--; - length--; + header->DataEncodes++; - header->DataEncodes++; + if (length < 0xFE) header->LengthOffsetEncodes++; + else header->LargeLengthOffsetEncodes++; - if (length < 0xFE) header->LengthOffsetEncodes++; - else header->LargeLengthOffsetEncodes++; + header->OffsetTotal ++; + header->LengthTotal += length; - header->OffsetTotal ++; - header->LengthTotal += length; + continue; + } - continue; - } + if (cp->UnprocessedDataSize > 3) + { + if ((ccode=CCDFindMatch( cp , &length, &offset )) !=0) return(ccode); - if (cp->UnprocessedDataSize > 3) - { - if ((ccode=CCDFindMatch( cp , &length, &offset )) !=0) return(ccode); + if (length > 2) + { + if((ccode=CCDProcessMatch( cp, length, offset )) !=0) return(ccode); - if (length > 2) - { - if((ccode=CCDProcessMatch( cp, length, offset )) !=0) return(ccode); + RELINQUISH_CONTROL - RELINQUISH_CONTROL + if (length < 0xFE) header->LengthOffsetEncodes++; + else header->LargeLengthOffsetEncodes++; - if (length < 0xFE) header->LengthOffsetEncodes++; - else header->LargeLengthOffsetEncodes++; + header->LengthTotal += length; + header->OffsetTotal += offset; - header->LengthTotal += length; - header->OffsetTotal += offset; + continue; + } + } - continue; - } - } + if ( (j+1) < cp->ReadFileSize ) b2 = READ_BYTE( cp, j+1 ); else b2=0; + if ( (j+2) < cp->ReadFileSize ) b3 = READ_BYTE( cp, j+2 ); else b3=0; - if ( (j+1) < cp->ReadFileSize ) b2 = READ_BYTE( cp, j+1 ); else b2=0; - if ( (j+2) < cp->ReadFileSize ) b3 = READ_BYTE( cp, j+2 ); else b3=0; + hash = GET_HASH( b1, b2, b3 ); - hash = GET_HASH( b1, b2, b3 ); + cp->Links[ j & COMPRESS_LINK_MASK ] = cp->Heads[ hash ]; - cp->Links[ j & COMPRESS_LINK_MASK ] = cp->Heads[ hash ]; + cp->Heads[ hash ] = (LONG)cp->DataProcessedIndex; - cp->Heads[ hash ] = (LONG)cp->DataProcessedIndex; + cp->DataProcessedIndex++; - cp->DataProcessedIndex++; + cp->UnprocessedDataSize--; - cp->UnprocessedDataSize--; + cp->DataTable[ b1 ] ++; - cp->DataTable[ b1 ] ++; + WRITE_TEMP_BYTE( cp, DATA_ENCODE_MARKER ) - WRITE_TEMP_BYTE( cp, DATA_ENCODE_MARKER ) + WRITE_TEMP_BYTE( cp, b1 ) - WRITE_TEMP_BYTE( cp, b1 ) - - header->DataEncodes++; + header->DataEncodes++; } @@ -883,29 +881,29 @@ GetAnotherReadCache:; LONG CCDAddNodes( - compressData_tp cp, - int first, - int length, - compressNode_tpp previous, - LONG count[], /* array of counts of given byte values */ - BYTE value[], - LONG index, - compressNode_tpp table -) + compressData_tp cp, + int first, + int length, + compressNode_tpp previous, + LONG count[], /* array of counts of given byte values */ + BYTE value[], + LONG index, + compressNode_tpp table +) { LONG total, sum; compressNode_tp node; LONG ccode; int i; - CYieldUntilIdle(); + CYieldUntilIdle(); if ((zStopCompression(cp->FileVolume)) || (cp->AbortCompression)) return( COMPRESS_ERROR_ABORTED ); if( (node = (compressNode_tp)CD_MALLOC( sizeof(compressNode_t))) == NULL ) - return( COMPRESS_ERROR_OUT_OF_RAM ); + return( COMPRESS_ERROR_OUT_OF_RAM ); - memset( node, 0, sizeof(compressNode_t) ); + memset( node, 0, sizeof(compressNode_t) ); *previous = node; @@ -916,26 +914,26 @@ CCDAddNodes( if(length == 1) { - node->value = value[ first ]; - node->count = count[ first ]; - node->left = 0; - node->right = 0; - node->code = 0; - node->length = index; + node->value = value[ first ]; + node->count = count[ first ]; + node->left = 0; + node->right = 0; + node->code = 0; + node->length = index; - for(i=0; iBitString[ i ] == '1') - node->code |= (LONG)( (LONG)1 << i ); + for(i=0; iBitString[ i ] == '1') + node->code |= (LONG)( (LONG)1 << i ); - table[ node->value ] = node; + table[ node->value ] = node; - /* each bit code will appear count times */ - cp->compressStatus->projectedCompressedSize += (index * node->count); + /* each bit code will appear count times */ + cp->compressStatus->projectedCompressedSize += (index * node->count); - /* this is a leaf node so we add in the space for the leaf node value */ - cp->compressStatus->projectedCompressedSize += 8; + /* this is a leaf node so we add in the space for the leaf node value */ + cp->compressStatus->projectedCompressedSize += 8; - return((LONG)0); + return((LONG)0); } total = sum = 0; @@ -943,7 +941,7 @@ CCDAddNodes( /* find total number of occurances for this half of the tree */ for(i=first; i<(length+first); i++) - total += count [ i ]; + total += count [ i ]; total >>=1 ; @@ -951,26 +949,26 @@ CCDAddNodes( for(i=0; i< (length -1); i++) { - sum += count [ first + i ]; - if (sum >= total) - { - if ((sum - total) <= (total - (sum - count[first + i]))) - { - ++i; + sum += count [ first + i ]; + if (sum >= total) + { + if ((sum - total) <= (total - (sum - count[first + i]))) + { + ++i; - /* See if there is an odd number of nodes and the split is odd */ - if ((i % 2) == 1 && i > 2 && (length % 2) == 1) - --i; - } + /* See if there is an odd number of nodes and the split is odd */ + if ((i % 2) == 1 && i > 2 && (length % 2) == 1) + --i; + } - if (length == 6 && i == 3) - --i; + if (length == 6 && i == 3) + --i; - if (length == 3) - i = 1; + if (length == 3) + i = 1; - break; - } + break; + } } cp->BitString[ index ] = '0'; @@ -1001,11 +999,11 @@ CCDGenerateShannonTrees( compressData_tp cp ) LONG temp; LONG ccode; LONG total; - typedef struct Stack_s { - BYTE value[ COMPRESS_VALUE_RANGE ]; - LONG count[ COMPRESS_VALUE_RANGE ]; + typedef struct Stack_s { + BYTE value[ COMPRESS_VALUE_RANGE ]; + LONG count[ COMPRESS_VALUE_RANGE ]; } Stack_s; - + LONG index; STACK_ALLOC(); @@ -1015,19 +1013,19 @@ CCDGenerateShannonTrees( compressData_tp cp ) total=0; for(i=0; i< 256; i++) { - temp = 0; - index = 0; - for (j=0; j < 256; j++) - if ( (cp->DataTable[j] != (LONG)-1) && (cp->DataTable[j] >= temp)) - { - temp = cp->DataTable[j]; - index = (LONG)j; - } + temp = 0; + index = 0; + for (j=0; j < 256; j++) + if ( (cp->DataTable[j] != (LONG)-1) && (cp->DataTable[j] >= temp)) + { + temp = cp->DataTable[j]; + index = (LONG)j; + } - aStack->value[i] = (BYTE)index; - aStack->count[i] = cp->DataTable[ index ]; - total += aStack->count[i]; - cp->DataTable[ index ] = (LONG)-1; + aStack->value[i] = (BYTE)index; + aStack->count[i] = cp->DataTable[ index ]; + total += aStack->count[i]; + cp->DataTable[ index ] = (LONG)-1; } @@ -1038,28 +1036,28 @@ CCDGenerateShannonTrees( compressData_tp cp ) cp->BitString[0] = '1'; if ((ccode=CCDAddNodes(cp, 0, i, &cp->DataTree, aStack->count, aStack->value, 1, cp->DataPointer )) != 0) - { - STACK_FREE(); + { + STACK_FREE(); return(ccode); - } + } total = 0; /* sort lengths according from top to bottom and place them in arrays */ for(i=0; i<256; i++) { - temp = 0; - index = 0; - for( j=0; j<256; j++) - if ((cp->LengthTable[j] != (LONG)-1) && (cp->LengthTable[j] >=temp)) - { - temp = cp->LengthTable[j]; - index = (LONG)j; - } - aStack->value[i] = (BYTE)index; - aStack->count[i] = cp->LengthTable[ index ]; - total += aStack->count[i]; - cp->LengthTable[ index ] = (LONG)-1; + temp = 0; + index = 0; + for( j=0; j<256; j++) + if ((cp->LengthTable[j] != (LONG)-1) && (cp->LengthTable[j] >=temp)) + { + temp = cp->LengthTable[j]; + index = (LONG)j; + } + aStack->value[i] = (BYTE)index; + aStack->count[i] = cp->LengthTable[ index ]; + total += aStack->count[i]; + cp->LengthTable[ index ] = (LONG)-1; } for(i = 0; i<256; i++) if (aStack->count[i] == 0) break; @@ -1067,30 +1065,30 @@ CCDGenerateShannonTrees( compressData_tp cp ) if (!i) { i++; } cp->BitString[0] = '0'; - + if ((ccode=CCDAddNodes(cp, 0, i, &cp->LengthTree, aStack->count, aStack->value, 1, cp->LengthPointer )) != 0) - { - STACK_FREE(); + { + STACK_FREE(); return(ccode); - } + } total = 0; /* sort offsets according from top to bottom and place them in arrays */ for( i =0; i<256; i ++) { - temp = 0; - index = 0; - for (j=0; j<256; j++) - if ((cp->OffsetTable[j] != (LONG)-1) && (cp->OffsetTable[j] >=temp)) - { - temp= cp->OffsetTable[j]; - index = (LONG)j; - } - aStack->value[i] = (BYTE)index; - aStack->count[i] = cp->OffsetTable[index]; - total += aStack->count[i]; - cp->OffsetTable[ index ] = (LONG)-1; + temp = 0; + index = 0; + for (j=0; j<256; j++) + if ((cp->OffsetTable[j] != (LONG)-1) && (cp->OffsetTable[j] >=temp)) + { + temp= cp->OffsetTable[j]; + index = (LONG)j; + } + aStack->value[i] = (BYTE)index; + aStack->count[i] = cp->OffsetTable[index]; + total += aStack->count[i]; + cp->OffsetTable[ index ] = (LONG)-1; } for(i=0; i<256; i++) if (aStack->count[i] == 0) break; @@ -1098,12 +1096,12 @@ CCDGenerateShannonTrees( compressData_tp cp ) if (!i) { i++; } if ((ccode=CCDAddNodes(cp, 0, i, &cp->OffsetTree, aStack->count, aStack->value, 0, cp->OffsetPointer )) != 0) - { - STACK_FREE(); + { + STACK_FREE(); return(ccode); - } + } - STACK_FREE(); + STACK_FREE(); return( (LONG)0 ); } @@ -1116,22 +1114,22 @@ CCDGenerateShannonTrees( compressData_tp cp ) LONG CCDInterpretIntermediateFile ( - register compressData_tp cp, - readCache_tp readCache, - compressCheckHeader_tp header + register compressData_tp cp, + readCache_tp readCache, + compressCheckHeader_tp header ) { - LONG length, offset; - LONG ccode; - BYTE cbyte, b1, b2; - LONG ReadFileSize; + LONG length, offset; + LONG ccode; + BYTE cbyte, b1, b2; + LONG ReadFileSize; - BYTE *InputCurrentPointer; - BYTE *InputBufferEnd; - BYTE *ReadEOFPointer; + BYTE *InputCurrentPointer; + BYTE *InputBufferEnd; + BYTE *ReadEOFPointer; - LONG dataEncodes = 0, lengthOffsetEncodes = 0, largeLengthOffsetEncodes = 0; - LONG offsetTotal = 0, lengthTotal = 0; + LONG dataEncodes = 0, lengthOffsetEncodes = 0, largeLengthOffsetEncodes = 0; + LONG offsetTotal = 0, lengthTotal = 0; compressNode_tp node; @@ -1139,136 +1137,136 @@ CCDInterpretIntermediateFile ( if (cp->ReadFileSize <= CD_SYSTEM_CACHE_BUFFER_SIZE) { - InputBufferEnd = ReadEOFPointer = InputCurrentPointer + cp->ReadFileSize; + InputBufferEnd = ReadEOFPointer = InputCurrentPointer + cp->ReadFileSize; } else { - InputBufferEnd = InputCurrentPointer + CD_SYSTEM_CACHE_BUFFER_SIZE; - ReadEOFPointer = (BYTE *)-1; + InputBufferEnd = InputCurrentPointer + CD_SYSTEM_CACHE_BUFFER_SIZE; + ReadEOFPointer = (BYTE *)-1; } - + ReadFileSize = cp->ReadFileSize; while ( InputCurrentPointer < ReadEOFPointer ) { - CYieldUntilIdle(); + CYieldUntilIdle(); - if ( !((ADDR)InputCurrentPointer & COMPRESS_RESCHEDULE_BYTE_MASK) ) - { - if ((zStopCompression( cp->FileVolume )) || ( cp->AbortCompression)) return( COMPRESS_ERROR_ABORTED ); - } + if ( !((ADDR)InputCurrentPointer & COMPRESS_RESCHEDULE_BYTE_MASK) ) + { + if ((zStopCompression( cp->FileVolume )) || ( cp->AbortCompression)) return( COMPRESS_ERROR_ABORTED ); + } - READ_TEMP_BYTE( cbyte ) + READ_TEMP_BYTE( cbyte ) - if (cbyte == (BYTE) DATA_ENCODE_MARKER) - { - /* raw data find code and write it out */ + if (cbyte == (BYTE) DATA_ENCODE_MARKER) + { + /* raw data find code and write it out */ - READ_TEMP_BYTE( cbyte ) + READ_TEMP_BYTE( cbyte ) - node = cp->DataPointer[ cbyte ]; - if (!node) return (COMPRESS_ERROR_TEMP_FILE_ERROR); + node = cp->DataPointer[ cbyte ]; + if (!node) return (COMPRESS_ERROR_TEMP_FILE_ERROR); - if((ccode= CCDCompressWriteBits( cp, node->length, node->code )) != 0) - return(ccode); + if((ccode= CCDCompressWriteBits( cp, node->length, node->code )) != 0) + return(ccode); - dataEncodes++; + dataEncodes++; - continue; + continue; - } + } - /* length cannot be less than three */ + /* length cannot be less than three */ - if (cbyte < 3) - { - return( COMPRESS_ERROR_TEMP_FILE_ERROR ); - } + if (cbyte < 3) + { + return( COMPRESS_ERROR_TEMP_FILE_ERROR ); + } - if( cbyte < 0xFE ) - { - length = cbyte; + if( cbyte < 0xFE ) + { + length = cbyte; - lengthOffsetEncodes++; + lengthOffsetEncodes++; - lengthTotal += length ; + lengthTotal += length ; - node = cp->LengthPointer[ length ]; - if (!node) return (COMPRESS_ERROR_TEMP_FILE_ERROR); + node = cp->LengthPointer[ length ]; + if (!node) return (COMPRESS_ERROR_TEMP_FILE_ERROR); - if((ccode = CCDCompressWriteBits( cp, node->length, node->code )) !=0) return(ccode); + if((ccode = CCDCompressWriteBits( cp, node->length, node->code )) !=0) return(ccode); - cp->DataProcessedIndex++; + cp->DataProcessedIndex++; - READ_TEMP_WORD( offset ) + READ_TEMP_WORD( offset ) - if ((offset >> COMPRESS_OFFSET_SHIFT) > 255) - return (COMPRESS_ERROR_TEMP_FILE_ERROR); + if ((offset >> COMPRESS_OFFSET_SHIFT) > 255) + return (COMPRESS_ERROR_TEMP_FILE_ERROR); - node = cp->OffsetPointer[ offset >> COMPRESS_OFFSET_SHIFT ]; - if (!node) return (COMPRESS_ERROR_TEMP_FILE_ERROR); + node = cp->OffsetPointer[ offset >> COMPRESS_OFFSET_SHIFT ]; + if (!node) return (COMPRESS_ERROR_TEMP_FILE_ERROR); - offsetTotal += offset; + offsetTotal += offset; - if ((ccode = CCDCompressWriteBits( cp, COMPRESS_OFFSET_SHIFT, offset ))!=0) return(ccode); + if ((ccode = CCDCompressWriteBits( cp, COMPRESS_OFFSET_SHIFT, offset ))!=0) return(ccode); - if ((ccode = CCDCompressWriteBits( cp, node->length, node->code ))!=0) return(ccode); + if ((ccode = CCDCompressWriteBits( cp, node->length, node->code ))!=0) return(ccode); - continue; + continue; - } + } - largeLengthOffsetEncodes++; + largeLengthOffsetEncodes++; - READ_TEMP_WORD( length ) + READ_TEMP_WORD( length ) - lengthTotal += length; + lengthTotal += length; - node = cp->LengthPointer[ 0xFE ]; - if (!node) return (COMPRESS_ERROR_TEMP_FILE_ERROR); + node = cp->LengthPointer[ 0xFE ]; + if (!node) return (COMPRESS_ERROR_TEMP_FILE_ERROR); - if((ccode = CCDCompressWriteBits( cp, node->length, node->code )) !=0) return(ccode); + if((ccode = CCDCompressWriteBits( cp, node->length, node->code )) !=0) return(ccode); - if((ccode = CCDCompressWriteBits( cp, (LONG)13, length )) !=0) return(ccode); + if((ccode = CCDCompressWriteBits( cp, (LONG)13, length )) !=0) return(ccode); - READ_TEMP_WORD( offset ) + READ_TEMP_WORD( offset ) - if ((offset >> COMPRESS_OFFSET_SHIFT) > 255) - return (COMPRESS_ERROR_TEMP_FILE_ERROR); + if ((offset >> COMPRESS_OFFSET_SHIFT) > 255) + return (COMPRESS_ERROR_TEMP_FILE_ERROR); - offsetTotal += offset; + offsetTotal += offset; - node = cp->OffsetPointer[ offset >> COMPRESS_OFFSET_SHIFT ]; - if (!node) return (COMPRESS_ERROR_TEMP_FILE_ERROR); + node = cp->OffsetPointer[ offset >> COMPRESS_OFFSET_SHIFT ]; + if (!node) return (COMPRESS_ERROR_TEMP_FILE_ERROR); - if((ccode = CCDCompressWriteBits( cp, COMPRESS_OFFSET_SHIFT, offset ))!=0) return(ccode); + if((ccode = CCDCompressWriteBits( cp, COMPRESS_OFFSET_SHIFT, offset ))!=0) return(ccode); - if((ccode = CCDCompressWriteBits( cp, node->length, node->code ))!=0) return(ccode); + if((ccode = CCDCompressWriteBits( cp, node->length, node->code ))!=0) return(ccode); } if (dataEncodes != header->DataEncodes) { - return( COMPRESS_ERROR_CODE_COUNTS_MISMATCH ); + return( COMPRESS_ERROR_CODE_COUNTS_MISMATCH ); } if (lengthOffsetEncodes != header->LengthOffsetEncodes) { - return( COMPRESS_ERROR_CODE_COUNTS_MISMATCH ); + return( COMPRESS_ERROR_CODE_COUNTS_MISMATCH ); } if (largeLengthOffsetEncodes != header->LargeLengthOffsetEncodes) { - return( COMPRESS_ERROR_CODE_COUNTS_MISMATCH ); + return( COMPRESS_ERROR_CODE_COUNTS_MISMATCH ); } if (offsetTotal != header->OffsetTotal) { - return( COMPRESS_ERROR_TOTALS_MISMATCH ); + return( COMPRESS_ERROR_TOTALS_MISMATCH ); } - if (lengthTotal != header->LengthTotal) + if (lengthTotal != header->LengthTotal) { - return( COMPRESS_ERROR_TOTALS_MISMATCH ); + return( COMPRESS_ERROR_TOTALS_MISMATCH ); } return((LONG)0); @@ -1288,18 +1286,18 @@ CCDWriteShannonTree( compressData_tp cp, compressNode_tp node ) LONG ccode; if (++treeHeight > 32) - return( COMPRESS_ERROR_TREE_TOO_BIG ); + return( COMPRESS_ERROR_TREE_TOO_BIG ); if (node->left != 0) { - if ((ccode= CCDCompressWriteZeroBit( cp ))!=0) return(ccode); - if ((ccode= CCDWriteShannonTree( cp, node->left ))!=0) return(ccode); - if ((ccode= CCDWriteShannonTree( cp, node->right ))!=0) return(ccode); + if ((ccode= CCDCompressWriteZeroBit( cp ))!=0) return(ccode); + if ((ccode= CCDWriteShannonTree( cp, node->left ))!=0) return(ccode); + if ((ccode= CCDWriteShannonTree( cp, node->right ))!=0) return(ccode); } else { - if ((ccode= CCDCompressWriteOneBit( cp ))!=0) return(ccode); - if ((ccode= CCDCompressWriteBits(cp, (LONG)8, node->value ))!=0) return(ccode); + if ((ccode= CCDCompressWriteOneBit( cp ))!=0) return(ccode); + if ((ccode= CCDCompressWriteBits(cp, (LONG)8, node->value ))!=0) return(ccode); } --treeHeight; @@ -1313,7 +1311,7 @@ CCDWriteShannonTree( compressData_tp cp, compressNode_tp node ) * * ***************************************************************************/ -LONG CCDCompressFile( +LONG CCDCompressFile( IoHandle_t InHandle, IoHandle_t OutHandle, IoHandle_t TempHandle, @@ -1326,41 +1324,41 @@ LONG CCDCompressFile( { compressData_tp cp; - LONG sectorsToWrite; - LONG numberOfChecksums; - LONG holeCount; - LONG valid; - LONG hole; - LONG actualSize; - LONG nextDWordInFileSize; - LONG allocSize; - LONG *headerChecksum; - LONG i; + LONG sectorsToWrite; + LONG numberOfChecksums; + LONG holeCount; + LONG valid; + LONG hole; + LONG actualSize; + LONG nextDWordInFileSize; + LONG allocSize; + LONG *headerChecksum; + LONG i; - LONG ccode, scode=0; - readCache_tp readCache = NULL; - LONG percentageGain = 0; - LONG compressedSize; - compressHoleNode_tp holeMark, prevHole; - LONG beginHigh, endHigh, highDiff; + LONG ccode, scode=0; + readCache_tp readCache = NULL; + LONG percentageGain = 0; + LONG compressedSize; + compressHoleNode_tp holeMark, prevHole; + LONG beginHigh, endHigh, highDiff; -#if TESTING_COMPRESSION - LONG begin; - LONG waitcount = 0; - LONG rafailcount = 0; - LONG end; - LONG diff; - LONG col = 0; - LONG colb = 0; +#if TESTING_COMPRESSION + LONG begin; + LONG waitcount = 0; + LONG rafailcount = 0; + LONG end; + LONG diff; + LONG col = 0; + LONG colb = 0; #endif - typedef struct Stack_s { - compressFileHeader_t fileHeader; - compressCheckHeader_t header; - } Stack_s; + typedef struct Stack_s { + compressFileHeader_t fileHeader; + compressCheckHeader_t header; + } Stack_s; - STACK_ALLOC(); - -#if TESTING_COMPRESSION + STACK_ALLOC(); + +#if TESTING_COMPRESSION begin = GetCurrentTime(); #endif @@ -1370,41 +1368,41 @@ LONG CCDCompressFile( if (CompressionAlgorithmsList) { - ccode = (*CompressionAlgorithmsList->CompressFile)( - InHandle, OutHandle, TempHandle, - InFileSize, Volume, CompressionHandle, - FileName, compressStatus ); + ccode = (*CompressionAlgorithmsList->CompressFile)( + InHandle, OutHandle, TempHandle, + InFileSize, Volume, CompressionHandle, + FileName, compressStatus ); - CompressDecompressActivityCount--; - STACK_FREE(); - return(ccode); + CompressDecompressActivityCount--; + STACK_FREE(); + return(ccode); } if ( InFileSize > COMPRESS_MAX_FILE_SIZE ) { - CompressDecompressActivityCount--; - CompressStatistics[ COMPRESS_ERROR_FILE_TOO_BIG - 10001 ]++; - STACK_FREE(); - return( COMPRESS_ERROR_FILE_TOO_BIG ); + CompressDecompressActivityCount--; + CompressStatistics[ COMPRESS_ERROR_FILE_TOO_BIG - 10001 ]++; + STACK_FREE(); + return( COMPRESS_ERROR_FILE_TOO_BIG ); } - memset( &aStack->header, 0, sizeof(aStack->header) ); + memset( &aStack->header, 0, sizeof(aStack->header) ); memset( &aStack->fileHeader, 0, sizeof(aStack->fileHeader) ); allocSize = sizeof(compressData_t) + (COMPRESS_MATCH_HEAD_SIZE<<2) + - (COMPRESS_LINK_SIZE<<2); + (COMPRESS_LINK_SIZE<<2); actualSize = allocSize; - + cp = (compressData_tp)CD_MALLOC(allocSize); if (cp == NULL) { - CompressDecompressActivityCount--; + CompressDecompressActivityCount--; CompressStatistics[ COMPRESS_ERROR_OUT_OF_RAM - 10001 ]++; - STACK_FREE(); + STACK_FREE(); return( COMPRESS_ERROR_OUT_OF_RAM ); } @@ -1422,7 +1420,7 @@ LONG CCDCompressFile( #if TESTING_COMPRESSION for(i=0; ((FileName[i] !='\0') && (i<12)); i++) - cp->FileName[i] = FileName[i]; + cp->FileName[i] = FileName[i]; cp->FileName[i] = '\0'; #endif @@ -1432,16 +1430,16 @@ LONG CCDCompressFile( if ((cp->AbortCompression) || (zStopCompression( Volume ))) { - ccode = COMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = COMPRESS_ERROR_ABORTED; + goto ErrorExit; } - CYieldUntilIdle(); + CYieldUntilIdle(); cp->ReadFileSize = InFileSize; i= 0; - + if ((ccode = NSSCCDPrepareForRead(InHandle, InFileSize, &readCache)) != 0) { goto ErrorExit; @@ -1449,32 +1447,32 @@ LONG CCDCompressFile( while ((iDataReadIndex < cp->ReadFileSize )) + && ( cp->DataReadIndex < cp->ReadFileSize )) { - if ((ccode= NSSCCDGetReadAheadBuffer( readCache, - (BYTE **)&(cp->ReadCachePointers[i]), &valid, &hole )) != 0) - goto ErrorExit; + if ((ccode= NSSCCDGetReadAheadBuffer( readCache, + (BYTE **)&(cp->ReadCachePointers[i]), &valid, &hole )) != 0) + goto ErrorExit; - CYieldUntilIdle(); + CYieldUntilIdle(); - if ((cp->AbortCompression) || (zStopCompression( Volume ))) - { - ccode = COMPRESS_ERROR_ABORTED; - goto ErrorExit; - } + if ((cp->AbortCompression) || (zStopCompression( Volume ))) + { + ccode = COMPRESS_ERROR_ABORTED; + goto ErrorExit; + } - if ( hole ) - { - if ((ccode=CCDProcessHole( cp, valid )) != 0) goto ErrorExit; - aStack->header.NumberOfHoles++; - continue; - } + if ( hole ) + { + if ((ccode=CCDProcessHole( cp, valid )) != 0) goto ErrorExit; + aStack->header.NumberOfHoles++; + continue; + } - cp->ReadBytesValidInCache[ i ] = valid; - cp->DataReadIndex += valid; - cp->UnprocessedDataSize += valid; + cp->ReadBytesValidInCache[ i ] = valid; + cp->DataReadIndex += valid; + cp->UnprocessedDataSize += valid; - i++; + i++; } @@ -1482,11 +1480,11 @@ LONG CCDCompressFile( cp->WriteNoFlushFlag = 1; if ((ccode = NSSCCDGetWriteCacheBlock( - TempHandle, (LONG)0, (LONG) 1, (BYTE **)&(cp->WriteCurrentPointer), - &(cp->WriteBufferHandle) )) !=0 ) + TempHandle, (LONG)0, (LONG) 1, (BYTE **)&(cp->WriteCurrentPointer), + &(cp->WriteBufferHandle) )) !=0 ) { - cp->WriteBufferBegin = NULL; - goto ErrorExit; + cp->WriteBufferBegin = NULL; + goto ErrorExit; } cp->WriteBufferBegin = cp->WriteCurrentPointer; @@ -1495,12 +1493,12 @@ LONG CCDCompressFile( if ((cp->AbortCompression) || ( zStopCompression( Volume ) )) { - ccode = COMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = COMPRESS_ERROR_ABORTED; + goto ErrorExit; } cp->WriteBufferEnd = (BYTE *)((ADDR)cp->WriteCurrentPointer + - CD_SYSTEM_CACHE_BUFFER_SIZE); + CD_SYSTEM_CACHE_BUFFER_SIZE); cp->compressStatus->projectedCompressedSize = sizeof(aStack->fileHeader) << 3; @@ -1517,30 +1515,30 @@ LONG CCDCompressFile( cp->compressStatus->projectedCompressedSize += (aStack->header.NumberOfHoles << 6); sectorsToWrite = ((cp->WriteCurrentPointer - cp->WriteBufferBegin) - + CD_SYSTEM_SECTOR_SIZE -1) >> CD_SYSTEM_SECTOR_SHIFT; + + CD_SYSTEM_SECTOR_SIZE -1) >> CD_SYSTEM_SECTOR_SHIFT; cp->ReadFileSize = (cp->WriteBlockNumber << CD_SYSTEM_CACHE_BUFFER_SHIFT) - + (cp->WriteCurrentPointer - cp->WriteBufferBegin); + + (cp->WriteCurrentPointer - cp->WriteBufferBegin); if ((ccode = NSSCCDReturnWriteCacheBlock( cp->WriteBufferHandle, - cp->WriteHandle, sectorsToWrite, (LONG)1 )) != 0) + cp->WriteHandle, sectorsToWrite, (LONG)1 )) != 0) { - cp->WriteBufferBegin = NULL; - goto ErrorExit; + cp->WriteBufferBegin = NULL; + goto ErrorExit; } cp->WriteBufferBegin = NULL; if ((cp->AbortCompression) || (zStopCompression( Volume ) )) { - ccode = COMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = COMPRESS_ERROR_ABORTED; + goto ErrorExit; } - if ((ccode = NSSCCDStopReadAhead( readCache )) != 0) + if ((ccode = NSSCCDStopReadAhead( readCache )) != 0) { - readCache = NULL; - goto ErrorExit; + readCache = NULL; + goto ErrorExit; } readCache = NULL; @@ -1548,8 +1546,8 @@ LONG CCDCompressFile( if ((cp->AbortCompression) || (zStopCompression( Volume ) )) { - ccode = COMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = COMPRESS_ERROR_ABORTED; + goto ErrorExit; } /**********************************************************************/ @@ -1560,7 +1558,7 @@ LONG CCDCompressFile( cp->compressStatus->projectedCompressedSize += 7; /* round up to byte size */ - cp->compressStatus->projectedCompressedSize >>= 3; /* number of bytes */ + cp->compressStatus->projectedCompressedSize >>= 3; /* number of bytes */ /* bring byte count up to the next dword */ @@ -1579,92 +1577,92 @@ LONG CCDCompressFile( if ( InFileSize <= cp->compressStatus->projectedCompressedSize ) { - ccode = COMPRESS_ERROR_UNCOMPRESSABLE; - goto ErrorExit; + ccode = COMPRESS_ERROR_UNCOMPRESSABLE; + goto ErrorExit; } nextDWordInFileSize = (InFileSize + 3) & (LONG)~3; if ( ((nextDWordInFileSize + (VOL_COMP_LOWER_LIMIT-1))/VOL_COMP_LOWER_LIMIT) - <= ((cp->compressStatus->projectedCompressedSize + (VOL_COMP_LOWER_LIMIT -1))/VOL_COMP_LOWER_LIMIT)) + <= ((cp->compressStatus->projectedCompressedSize + (VOL_COMP_LOWER_LIMIT -1))/VOL_COMP_LOWER_LIMIT)) { - /* No disk allocation units will be saved */ + /* No disk allocation units will be saved */ - ccode = COMPRESS_ERROR_UNCOMPRESSABLE; - goto ErrorExit; + ccode = COMPRESS_ERROR_UNCOMPRESSABLE; + goto ErrorExit; } percentageGain = ((LONG)100 - (cp->compressStatus->projectedCompressedSize - *(LONG)100)/ nextDWordInFileSize ); + *(LONG)100)/ nextDWordInFileSize ); if (percentageGain < compressStatus->minimumPercentageGain) { - ccode = COMPRESS_ERROR_UNCOMPRESSABLE; - goto ErrorExit; + ccode = COMPRESS_ERROR_UNCOMPRESSABLE; + goto ErrorExit; } compressStatus->totalCompressedBlocks = - (cp->compressStatus->projectedCompressedSize + - CD_SYSTEM_CACHE_BUFFER_SIZE - 1) >> CD_SYSTEM_CACHE_BUFFER_SHIFT; - - /* see if there's any actual blocks will be saved. The extra one block is - * the indirect file map block that compBeast takes */ - if ((compressStatus->totalCompressedBlocks + 1) >= - ((InHandle->CM_stream.stream->beastSize - InHandle->CM_stream.stream->beastOffset - + CD_SYSTEM_CACHE_BUFFER_SIZE - 1) >> CD_SYSTEM_CACHE_BUFFER_SHIFT)) - { - /* no blocks will be saved */ - ccode = COMPRESS_ERROR_UNCOMPRESSABLE; - goto ErrorExit; - } + (cp->compressStatus->projectedCompressedSize + + CD_SYSTEM_CACHE_BUFFER_SIZE - 1) >> CD_SYSTEM_CACHE_BUFFER_SHIFT; + /* see if there's any actual blocks will be saved. The extra one block is + * the indirect file map block that compBeast takes */ + if ((compressStatus->totalCompressedBlocks + 1) >= + ((InHandle->CM_stream.stream->beastSize - InHandle->CM_stream.stream->beastOffset + + CD_SYSTEM_CACHE_BUFFER_SIZE - 1) >> CD_SYSTEM_CACHE_BUFFER_SHIFT)) + { + /* no blocks will be saved */ + ccode = COMPRESS_ERROR_UNCOMPRESSABLE; + goto ErrorExit; + } + cp->compressStatus->compressionStage++; if((ccode=NSSCCDSetFileSize( TempHandle, cp->ReadFileSize, cp->ReadFileSize )) != 0) - goto ErrorExit; + goto ErrorExit; - if ((ccode = NSSCCDStartReadAhead( TempHandle, cp->ReadFileSize, &readCache, (LONG)16 )) !=0) + if ((ccode = NSSCCDStartReadAhead( TempHandle, cp->ReadFileSize, &readCache, (LONG)16 )) !=0) { - readCache = NULL; - goto ErrorExit; + readCache = NULL; + goto ErrorExit; } /* let read ahead threads queue up for reading */ - CYieldUntilIdle(); - + CYieldUntilIdle(); + if ((cp->AbortCompression) || (zStopCompression( Volume ) )) { - ccode = COMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = COMPRESS_ERROR_ABORTED; + goto ErrorExit; } - if ((ccode = NSSCCDGetReadAheadBuffer( readCache, &cp->ReadCachePointers[0], - & valid, & hole )) != 0) - goto ErrorExit; + if ((ccode = NSSCCDGetReadAheadBuffer( readCache, &cp->ReadCachePointers[0], + & valid, & hole )) != 0) + goto ErrorExit; - if ( hole ) { ccode = COMPRESS_ERROR_INVALID_HOLE; goto ErrorExit; } + if ( hole ) { ccode = COMPRESS_ERROR_INVALID_HOLE; goto ErrorExit; } - cp->WriteNoFlushFlag = 0; - cp->WriteBlockNumber = 0; - cp->WriteHandle = OutHandle; + cp->WriteNoFlushFlag = 0; + cp->WriteBlockNumber = 0; + cp->WriteHandle = OutHandle; if ((ccode = NSSCCDGetWriteCacheBlock( OutHandle, (LONG)0, (LONG)0, - (BYTE **)&(cp->WriteCurrentPointer), &(cp->WriteBufferHandle))) !=0 ) + (BYTE **)&(cp->WriteCurrentPointer), &(cp->WriteBufferHandle))) !=0 ) { - cp->WriteBufferBegin = NULL; - goto ErrorExit; + cp->WriteBufferBegin = NULL; + goto ErrorExit; } cp->WriteBufferBegin = cp->WriteCurrentPointer; if ((cp->AbortCompression) || (zStopCompression( Volume ))) { - ccode = COMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = COMPRESS_ERROR_ABORTED; + goto ErrorExit; } cp->WriteBufferEnd = cp->WriteCurrentPointer + - (CD_SYSTEM_CACHE_BUFFER_SIZE - 4); + (CD_SYSTEM_CACHE_BUFFER_SIZE - 4); #ifdef HI_LO_MACH_TYPE aStack->fileHeader.CompressCode = NETWARE_COMPRESS_HILO; @@ -1676,7 +1674,7 @@ LONG CCDCompressFile( aStack->fileHeader.CompressMinorVersion = COMPRESS_MINOR_VERSION; aStack->fileHeader.OriginalFileLength = InFileSize; aStack->fileHeader.CompressedFileLength = cp->compressStatus->projectedCompressedSize; - aStack->fileHeader.NumberOfHoles = aStack->header.NumberOfHoles; + aStack->fileHeader.NumberOfHoles = aStack->header.NumberOfHoles; /* have to count now because we are going to write out header */ @@ -1693,7 +1691,7 @@ LONG CCDCompressFile( headerChecksum = (LONG *)&aStack->fileHeader; for (i=0; i<(sizeof(compressFileHeader_t)>>2)-1; i++, headerChecksum++) - aStack->fileHeader.HeaderCheckSum += *headerChecksum; + aStack->fileHeader.HeaderCheckSum += *headerChecksum; // CMovD( (void *)&aStack->fileHeader, (void *)cp->WriteBufferBegin, sizeof(aStack->fileHeader) >> 2 ); memmove((void *)cp->WriteBufferBegin, (void *)&aStack->fileHeader, sizeof(aStack->fileHeader)); @@ -1702,13 +1700,13 @@ LONG CCDCompressFile( if (aStack->header.NumberOfHoles) { - if ((ccode = CCDWriteOutHoles(cp, &holeCount)) != 0) goto ErrorExit; + if ((ccode = CCDWriteOutHoles(cp, &holeCount)) != 0) goto ErrorExit; - if (holeCount != aStack->header.NumberOfHoles) - { - ccode = COMPRESS_ERROR_HOLE_COUNT_MISMATCH; - goto ErrorExit; - } + if (holeCount != aStack->header.NumberOfHoles) + { + ccode = COMPRESS_ERROR_HOLE_COUNT_MISMATCH; + goto ErrorExit; + } } if ((ccode = CCDWriteShannonTree( cp, cp->DataTree )) !=0) goto ErrorExit; @@ -1720,46 +1718,46 @@ LONG CCDCompressFile( /************************************************************************/ if ((ccode = CCDInterpretIntermediateFile( cp, readCache, &aStack->header )) !=0) - goto ErrorExit; + goto ErrorExit; /************************************************************************/ /* since we always write longs the current pointer will - either have space for 4 bytes or be at the buffer end - which leaves 4 bytes for the checksum */ + either have space for 4 bytes or be at the buffer end + which leaves 4 bytes for the checksum */ - if (cp->WriteCurrentPointer == cp->WriteBufferEnd) + if (cp->WriteCurrentPointer == cp->WriteBufferEnd) { - *(LONG *)cp->WriteCurrentPointer = - CCDCheckSumBlock4KMinus1( (LONG *)cp->WriteBufferBegin ); + *(LONG *)cp->WriteCurrentPointer = + CCDCheckSumBlock4KMinus1( (LONG *)cp->WriteBufferBegin ); - if ((ccode=NSSCCDReturnWriteCacheBlock( cp->WriteBufferHandle, - cp->WriteHandle, CD_SYSTEM_SECTORS_PER_BUFFER, (LONG)0 )) != 0) - { - cp->WriteBufferBegin = NULL; - goto ErrorExit; - } + if ((ccode=NSSCCDReturnWriteCacheBlock( cp->WriteBufferHandle, + cp->WriteHandle, CD_SYSTEM_SECTORS_PER_BUFFER, (LONG)0 )) != 0) + { + cp->WriteBufferBegin = NULL; + goto ErrorExit; + } - cp->WriteBufferBegin = NULL; + cp->WriteBufferBegin = NULL; - if ((cp->AbortCompression) || (zStopCompression(cp->FileVolume))) - { - ccode = COMPRESS_ERROR_ABORTED; - goto ErrorExit; - } + if ((cp->AbortCompression) || (zStopCompression(cp->FileVolume))) + { + ccode = COMPRESS_ERROR_ABORTED; + goto ErrorExit; + } - cp->WriteBlockNumber++; + cp->WriteBlockNumber++; - if ((ccode=NSSCCDGetWriteCacheBlock( cp->WriteHandle, - cp->WriteBlockNumber, (LONG)0, &(cp->WriteCurrentPointer), - &(cp->WriteBufferHandle) )) != 0) - { - goto ErrorExit; - } + if ((ccode=NSSCCDGetWriteCacheBlock( cp->WriteHandle, + cp->WriteBlockNumber, (LONG)0, &(cp->WriteCurrentPointer), + &(cp->WriteBufferHandle) )) != 0) + { + goto ErrorExit; + } - cp->WriteBufferBegin = cp->WriteCurrentPointer; - cp->WriteBufferEnd = cp->WriteCurrentPointer + - (CD_SYSTEM_CACHE_BUFFER_SIZE - 4 ); + cp->WriteBufferBegin = cp->WriteCurrentPointer; + cp->WriteBufferEnd = cp->WriteCurrentPointer + + (CD_SYSTEM_CACHE_BUFFER_SIZE - 4 ); } cp->WriteBitBuffer >>= (cp->WriteBitIndex-1); @@ -1769,48 +1767,48 @@ LONG CCDCompressFile( cp->WriteCurrentPointer += sizeof(LONG); *(LONG *)cp->WriteCurrentPointer = (~CCDCheckSumBlock( (LONG *)cp->WriteBufferBegin, - (cp->WriteCurrentPointer - cp->WriteBufferBegin) >> 2))+1; + (cp->WriteCurrentPointer - cp->WriteBufferBegin) >> 2))+1; cp->WriteCurrentPointer += sizeof(LONG); sectorsToWrite = ((cp->WriteCurrentPointer - cp->WriteBufferBegin) - + CD_SYSTEM_SECTOR_SIZE -1) >> CD_SYSTEM_SECTOR_SHIFT; + + CD_SYSTEM_SECTOR_SIZE -1) >> CD_SYSTEM_SECTOR_SHIFT; compressedSize = (cp->WriteBlockNumber << CD_SYSTEM_CACHE_BUFFER_SHIFT) + - (LONG)(cp->WriteCurrentPointer - cp->WriteBufferBegin); + (LONG)(cp->WriteCurrentPointer - cp->WriteBufferBegin); if ((ccode=NSSCCDReturnWriteCacheBlock( cp->WriteBufferHandle, - cp->WriteHandle, sectorsToWrite, (LONG)0 )) != 0) + cp->WriteHandle, sectorsToWrite, (LONG)0 )) != 0) { - cp->WriteBufferBegin = NULL; - goto ErrorExit; + cp->WriteBufferBegin = NULL; + goto ErrorExit; } cp->WriteBufferBegin = NULL; if ((cp->AbortCompression) || (zStopCompression( Volume ) )) { - ccode = COMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = COMPRESS_ERROR_ABORTED; + goto ErrorExit; } if ( compressedSize != cp->compressStatus->projectedCompressedSize ) { - ccode = COMPRESS_ERROR_MATCH_SIZE_FAIL; - goto ErrorExit; + ccode = COMPRESS_ERROR_MATCH_SIZE_FAIL; + goto ErrorExit; } -#if TESTING_COMPRESSION +#if TESTING_COMPRESSION waitcount = readCache->CacheWaitCount; rafailcount = readCache->CacheReadAheadFailedCount; col = readCache->Collided; colb = readCache->CollidedBytes; -#endif +#endif if ((ccode = NSSCCDStopReadAhead( readCache )) != 0) { - readCache = NULL; - goto ErrorExit; + readCache = NULL; + goto ErrorExit; } readCache = NULL; @@ -1822,107 +1820,108 @@ LONG CCDCompressFile( ErrorExit: - if (cp->DataTree) CCDFreeShannonTree( cp->DataTree ); - if (cp->OffsetTree) CCDFreeShannonTree( cp->OffsetTree ); - if (cp->LengthTree) CCDFreeShannonTree( cp->LengthTree ); + if (cp->DataTree) CCDFreeShannonTree( cp->DataTree ); + if (cp->OffsetTree) CCDFreeShannonTree( cp->OffsetTree ); + if (cp->LengthTree) CCDFreeShannonTree( cp->LengthTree ); - if (cp->WriteBufferBegin) - scode = NSSCCDReturnWriteCacheBlock( cp->WriteBufferHandle, - cp->WriteHandle, (LONG) 8, (LONG)cp->WriteNoFlushFlag ); + if (cp->WriteBufferBegin) + scode = NSSCCDReturnWriteCacheBlock( cp->WriteBufferHandle, + cp->WriteHandle, (LONG) 8, (LONG)cp->WriteNoFlushFlag ); - if (readCache) - { -#if TESTING_COMPRESSION - waitcount = readCache->CacheWaitCount; - rafailcount = readCache->CacheReadAheadFailedCount; - col = readCache->Collided; - colb = readCache->CollidedBytes; -#endif - NSSCCDStopReadAhead( readCache ); - } + if (readCache) + { +#if TESTING_COMPRESSION + waitcount = readCache->CacheWaitCount; + rafailcount = readCache->CacheReadAheadFailedCount; + col = readCache->Collided; + colb = readCache->CollidedBytes; +#endif + NSSCCDStopReadAhead( readCache ); + } - endHigh = GetHighResolutionTimer(); + endHigh = GetHighResolutionTimer(); -#if TESTING_COMPRESSION - if (NWALGO_DBG_COLOR) - { - end = GetCurrentTime(); +#if TESTING_COMPRESSION + if (NWALGO_DBG_COLOR) + { + end = GetCurrentTime(); - if (end-begin) diff = (end-begin); else diff= 1; + if (end-begin) diff = (end-begin); else diff= 1; - if ((!ccode) && (!scode)) - { - NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR,MSGNot(" %-12s %2ld %10ld %10ld %10ld %10ld %2ld %2ld %2ld %2ld %2ld\n"), - cp->FileName, percentageGain, (InFileSize/diff) * 18, - (cp->compressStatus->projectedCompressedSize/diff) * 18, InFileSize, - cp->compressStatus->projectedCompressedSize, waitcount, rafailcount, col, colb, Volume)); - } - else - { - if (ccode) - { - NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR,MSGNot(" %-12s %10ld %10ld %10ld %10ld\n"), - cp->FileName, InFileSize, cp->compressStatus->projectedCompressedSize, - Volume, ccode )); - } - else - { - NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR,MSGNot(" %-12s %10ld %10ld %10ld %10ld\n"), - cp->FileName, InFileSize, cp->compressStatus->projectedCompressedSize, - Volume, scode )); - } - } + if ((!ccode) && (!scode)) + { + NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR,MSGNot(" %-12s %2ld %10ld %10ld %10ld %10ld %2ld %2ld %2ld %2ld %2ld\n"), + cp->FileName, percentageGain, (InFileSize/diff) * 18, + (cp->compressStatus->projectedCompressedSize/diff) * 18, InFileSize, + cp->compressStatus->projectedCompressedSize, waitcount, rafailcount, col, colb, Volume)); + } + else + { + if (ccode) + { + NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR,MSGNot(" %-12s %10ld %10ld %10ld %10ld\n"), + cp->FileName, InFileSize, cp->compressStatus->projectedCompressedSize, + Volume, ccode )); + } + else + { + NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR,MSGNot(" %-12s %10ld %10ld %10ld %10ld\n"), + cp->FileName, InFileSize, cp->compressStatus->projectedCompressedSize, + Volume, scode )); + } + } - } + } #endif - for (holeMark = cp->HoleHead; holeMark; ) - { - prevHole = holeMark; - holeMark = holeMark->next; - CD_FREE( prevHole ); - } + for (holeMark = cp->HoleHead; holeMark; ) + { + prevHole = holeMark; + holeMark = holeMark->next; + CD_FREE( prevHole ); + } - if (ccode) - { + if (ccode) + { - if ((ccode >10000) && (ccode<(10000 + COMPRESS_ERROR_COUNT))) - CompressStatistics[ ccode - 10001 ]++; + if ((ccode >10000) && (ccode<(10000 + COMPRESS_ERROR_COUNT))) + CompressStatistics[ ccode - 10001 ]++; - switch(ccode) - { - case COMPRESS_ERROR_READ_ZERO_BYTES: - break; + switch(ccode) + { + case COMPRESS_ERROR_READ_ZERO_BYTES: + break; - case COMPRESS_ERROR_TREE_TOO_BIG: - break; - } + case COMPRESS_ERROR_TREE_TOO_BIG: + break; + } - CD_FREE( cp ); - CompressDecompressActivityCount--; - STACK_FREE(); - return(ccode); - } + CD_FREE( cp ); + CompressDecompressActivityCount--; + STACK_FREE(); + return(ccode); + } - if (scode) - { - if ((scode >10000) && (scode<(10000 + COMPRESS_ERROR_COUNT))) - CompressStatistics[ scode - 10001 ]++; - CD_FREE( cp ); - CompressDecompressActivityCount--; - STACK_FREE(); - return(scode); - } + if (scode) + { + if ((scode >10000) && (scode<(10000 + COMPRESS_ERROR_COUNT))) + CompressStatistics[ scode - 10001 ]++; + CD_FREE( cp ); + CompressDecompressActivityCount--; + STACK_FREE(); + return(scode); + } - highDiff = endHigh - beginHigh; + highDiff = endHigh - beginHigh; - CD_FREE( cp ); - STACK_FREE(); + CD_FREE( cp ); + STACK_FREE(); return( (LONG)0 ); } /****************************************************************************/ /****************************************************************************/ + diff --git a/include/nwnss/include/cdcomp.h b/src/nwnss/comn/compression/cdcomp.h similarity index 84% rename from include/nwnss/include/cdcomp.h rename to src/nwnss/comn/compression/cdcomp.h index b07a2b8..f3995c5 100644 --- a/include/nwnss/include/cdcomp.h +++ b/src/nwnss/comn/compression/cdcomp.h @@ -1,26 +1,26 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996-1999 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996-1999 Novell, Inc. + | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | Netware file compression algorithm ported to NSS + | Netware file compression algorithm ported to NSS | |--------------------------------------------------------------------------- | @@ -31,7 +31,7 @@ | $Revision: 1177 $ | |--------------------------------------------------------------------------- - | Module Description: + | Module Description: | +-------------------------------------------------------------------------*/ #ifndef __CDCOMP_H__ @@ -39,7 +39,7 @@ /*************************************************************************** * - * + * * ***************************************************************************/ @@ -48,7 +48,7 @@ #define COMPRESS_ERROR_READ_BEYOND_EOF 10003 #define COMPRESS_ERROR_ABORTED 10004 #define COMPRESS_ERROR_UNCOMPRESSABLE 10005 -#define COMPRESS_ERROR_CODE_COUNTS_MISMATCH 10006 +#define COMPRESS_ERROR_CODE_COUNTS_MISMATCH 10006 #define COMPRESS_ERROR_TOTALS_MISMATCH 10007 #define COMPRESS_ERROR_TREE_TOO_BIG 10008 #define COMPRESS_ERROR_MATCH_SIZE_FAIL 10009 @@ -63,7 +63,7 @@ #define COMPRESS_ERROR_TRY_AGAIN 10018 -#define COMPRESS_ERROR_COUNT 18 +#define COMPRESS_ERROR_COUNT 18 /************************************************************************** @@ -91,7 +91,7 @@ #define GET_HASH GET_HASH_16K /*************************************************************************** - * + * * Hash for ?K head list links * ***************************************************************************/ @@ -113,7 +113,7 @@ /************************************************************************* * this allows us to look back 8K and forward 8K at any index - * + * * *************************************************************************/ @@ -131,7 +131,7 @@ /*************************************************************************** * - * Compress Reschedule Size is the number of bytes before we relinquish + * Compress Reschedule Size is the number of bytes before we relinquish * control * ***************************************************************************/ @@ -174,56 +174,56 @@ * ***************************************************************************/ -#define COMPRESS_MAX_FILE_SIZE 0x0FFFFFFF +#define COMPRESS_MAX_FILE_SIZE 0x0FFFFFFF /*************************************************************************** * - * + * * ***************************************************************************/ typedef struct compressCheckHeader_s { - LONG LengthOffsetEncodes; - LONG LargeLengthOffsetEncodes; - LONG OffsetEncodes; - LONG DataEncodes; - LONG LengthTotal; - LONG OffsetTotal; - LONG NumberOfHoles; + LONG LengthOffsetEncodes; + LONG LargeLengthOffsetEncodes; + LONG OffsetEncodes; + LONG DataEncodes; + LONG LengthTotal; + LONG OffsetTotal; + LONG NumberOfHoles; } compressCheckHeader_t, *compressCheckHeader_tp; /*************************************************************************** * - * + * * ***************************************************************************/ typedef struct compressHoleNode_s { - struct compressHoleNode_s *next; - LONG offset; - LONG size; + struct compressHoleNode_s *next; + LONG offset; + LONG size; } compressHoleNode_t, *compressHoleNode_tp; /*************************************************************************** * - * shannon tree node type + * shannon tree node type * ***************************************************************************/ typedef struct compressNode_s { struct compressNode_s *left; struct compressNode_s *right; - LONG value; - LONG count; - LONG length; - LONG code; /* for 4G files code will never > 32 bits */ + LONG value; + LONG count; + LONG length; + LONG code; /* for 4G files code will never > 32 bits */ } compressNode_t, *compressNode_tp, * *compressNode_tpp; /*************************************************************************** * - * + * * ***************************************************************************/ typedef struct compressData_s { @@ -278,7 +278,7 @@ typedef struct compressData_s { LONG AbortCompression; #if TESTING_COMPRESSION - BYTE FileName[16]; + BYTE FileName[16]; #endif LONG *Heads; /* 16K x 4 */ @@ -288,7 +288,7 @@ typedef struct compressData_s { } compressData_t, *compressData_tp, **compressData_tpp; -LONG CCDCompressFile( +LONG CCDCompressFile( IoHandle_t InHandle, IoHandle_t OutHandle, IoHandle_t TempHandle, @@ -316,3 +316,4 @@ extern BYTE StopCompressionTable[]; /****************************************************************************/ /****************************************************************************/ + diff --git a/src/nwnss/comn/compression/cdcompa.c b/src/nwnss/comn/compression/cdcompa.c index 553bed9..6195bb0 100644 --- a/src/nwnss/comn/compression/cdcompa.c +++ b/src/nwnss/comn/compression/cdcompa.c @@ -67,7 +67,7 @@ data = tw; \ for (i=0; i>= 1; \ } @@ -77,7 +77,7 @@ CCDCheckSumBlock( LONG *data, LONG lengthInDwords ) LONG i, checkSum; for (i=0, checkSum=0; iAbortCompression ) return( COMPRESS_ERROR_ABORTED ); - *((LONG *)cd->WriteBufferEnd) = - CCDCheckSumBlock4KMinus1( (LONG *)cd->WriteBufferBegin ); + *((LONG *)cd->WriteBufferEnd) = + CCDCheckSumBlock4KMinus1( (LONG *)cd->WriteBufferBegin ); if ((ccode = NSSCCDReturnWriteCacheBlock( cd->WriteBufferHandle, - cd->WriteHandle, CD_SYSTEM_SECTORS_PER_BUFFER, (LONG)0)) !=0) + cd->WriteHandle, CD_SYSTEM_SECTORS_PER_BUFFER, (LONG)0)) !=0) { - cd->WriteBufferBegin = 0; - return(ccode); + cd->WriteBufferBegin = 0; + return(ccode); } cd->WriteBufferBegin = 0; cd->WriteBlockNumber++; - if ((ccode = NSSCCDGetWriteCacheBlock( cd->WriteHandle, - cd->WriteBlockNumber, (LONG)0, & cd->WriteCurrentPointer, - & cd->WriteBufferHandle )) != 0) + if ((ccode = NSSCCDGetWriteCacheBlock( cd->WriteHandle, + cd->WriteBlockNumber, (LONG)0, & cd->WriteCurrentPointer, + & cd->WriteBufferHandle )) != 0) { - return(ccode); + return(ccode); } cd->WriteBufferBegin = cd->WriteCurrentPointer; @@ -163,37 +163,37 @@ CCDCheckSumSwappedBlock( LONG *data, LONG lengthInDwords ) LONG i, checkSum; for (i=0, checkSum=0; ileft) - CCDFreeShannonTree( treePointer->left ); + if (treePointer->left) + CCDFreeShannonTree( treePointer->left ); - if (treePointer->right) - CCDFreeShannonTree( treePointer->right ); + if (treePointer->right) + CCDFreeShannonTree( treePointer->right ); - CD_FREE( treePointer ); + CD_FREE( treePointer ); } } @@ -201,10 +201,10 @@ void CDCountTreeNodes( compressNode_tp treePointer, LONG *count ) { if (treePointer->left) - CDCountTreeNodes( treePointer->left, count ); + CDCountTreeNodes( treePointer->left, count ); if (treePointer->right) - CDCountTreeNodes( treePointer->right, count ); + CDCountTreeNodes( treePointer->right, count ); (*count)++; } @@ -217,3 +217,4 @@ CCDCountTreeNodes( compressNode_tp treePointer, LONG *count ) CDCountTreeNodes( treePointer, count ); return((LONG)0); } + diff --git a/include/nwnss/include/cdnetwar.h b/src/nwnss/comn/compression/cdnetwar.h similarity index 94% rename from include/nwnss/include/cdnetwar.h rename to src/nwnss/comn/compression/cdnetwar.h index ebf1bb5..9919494 100644 --- a/include/nwnss/include/cdnetwar.h +++ b/src/nwnss/comn/compression/cdnetwar.h @@ -57,16 +57,16 @@ LONG NSSCCDDecompressBuildFile( IoHandle_t outHandle, LONG offset, LONG size, LONG prevSize, LONG nextSize ); LONG NSSCCDReturnWriteCacheBlock( LONG CacheHandle , IoHandle_t fileHandle, - LONG NumberOfSectors, LONG NoFlushFlag ); + LONG NumberOfSectors, LONG NoFlushFlag ); void NSSCCDReturnReadCacheBlock(IoHandle_t fileHandle, LONG CacheHandle); LONG NSSCCDGetWriteCacheBlock( IoHandle_t fileHandle, LONG CacheBlockNumber, - LONG NoFlushFlag, BYTE **CacheBlock, LONG *CacheHandle ); + LONG NoFlushFlag, BYTE **CacheBlock, LONG *CacheHandle ); LONG NSSCCDGetReadCacheBlock(IoHandle_t fileHandle, LONG CacheBlockNumber, - LONG *RealBytesRead, BYTE **CacheBlock, LONG *CacheHandle, - LONG *HoleFlag); + LONG *RealBytesRead, BYTE **CacheBlock, LONG *CacheHandle, + LONG *HoleFlag); LONG NSSCCDPrepareForRead(IoHandle_t fileHandle, LONG FileSize, readCache_tpp ReadCacheHandleReturn); @@ -88,3 +88,5 @@ LONG NSSCCDGetReadAheadBuffer(readCache_tp readCache, BYTE **cachePointer, /****************************************************************************/ /****************************************************************************/ + + diff --git a/include/nwnss/include/cdreada.h b/src/nwnss/comn/compression/cdreada.h similarity index 96% rename from include/nwnss/include/cdreada.h rename to src/nwnss/comn/compression/cdreada.h index 617104f..105ec5b 100644 --- a/include/nwnss/include/cdreada.h +++ b/src/nwnss/comn/compression/cdreada.h @@ -46,12 +46,12 @@ typedef struct ReadAheadWorkToDoStructure_s { - LONG MainCache; - LONG ThisIsQueuedFlag; + LONG MainCache; + LONG ThisIsQueuedFlag; #if 0 - struct WorkToDoStructure WorkToDo; + struct WorkToDoStructure WorkToDo; #endif - LONG pad; + LONG pad; } readAheadWorkToDo_t, *readAheadWorkToDo_tp; @@ -90,3 +90,4 @@ typedef struct readCache_s { /****************************************************************************/ /****************************************************************************/ + diff --git a/src/nwnss/comn/compression/cduncomp.c b/src/nwnss/comn/compression/cduncomp.c index c84b6e2..224d5aa 100644 --- a/src/nwnss/comn/compression/cduncomp.c +++ b/src/nwnss/comn/compression/cduncomp.c @@ -1,26 +1,26 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996-1999 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996-1999 Novell, Inc. + | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | Netware file compression algorithm ported to NSS + | Netware file compression algorithm ported to NSS | |--------------------------------------------------------------------------- | @@ -31,7 +31,7 @@ | $Revision: 1522 $ | |--------------------------------------------------------------------------- - | Module Description: + | Module Description: | +-------------------------------------------------------------------------*/ @@ -95,31 +95,31 @@ CCDAbortDecompress( uncompressData_tp ucp ) #define INC_BIT_MAP_PTR( ucp ) \ ucp->BitMapCurrentPointer++; \ if( ucp->BitMapCurrentPointer == ucp->BitMapCurrentEnd ) { \ - if ((ccode=NSSCCDFreeReadAheadBuffer( ucp->ReadCache )) != 0) return(ccode); \ - if ((ccode=NSSCCDGetReadAheadBuffer( ucp->ReadCache,\ - (BYTE **)&(ucp->BitMapCurrentPointer), &valid, &hole )) != 0) return(ccode); \ - if (hole) { return( UNCOMPRESS_ERROR_INVALID_HOLES ); } \ - ucp->CompressedFileSize -= CD_SYSTEM_CACHE_BUFFER_SIZE; \ - if (ucp->CompressedFileSize < CD_SYSTEM_CACHE_BUFFER_SIZE) {\ - ucp->BitMapCurrentEnd = ucp->BitMapCurrentPointer + (ucp->CompressedFileSize >> 2) -1; \ - if (bitMapSwapped){ \ - if (CCDCheckSumSwappedBlock( ucp->BitMapCurrentPointer, \ - ucp->CompressedFileSize >> 2)) return( UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); \ - } \ - else {\ - if (CCDCheckSumBlock( ucp->BitMapCurrentPointer, \ - ucp->CompressedFileSize >> 2)) return( UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); \ - }\ - } \ - else { \ - ucp->BitMapCurrentEnd = ucp->BitMapCurrentPointer + (CD_SYSTEM_CACHE_BUFFER_LONGS -1); \ - if (bitMapSwapped) { \ - if (CCDCheckSumSwappedBlock4K( ucp->BitMapCurrentPointer )) return(UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); \ - } \ - else { \ - if (CCDCheckSumBlock4K( ucp->BitMapCurrentPointer )) return(UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); \ - } \ - } \ + if ((ccode=NSSCCDFreeReadAheadBuffer( ucp->ReadCache )) != 0) return(ccode); \ + if ((ccode=NSSCCDGetReadAheadBuffer( ucp->ReadCache,\ + (BYTE **)&(ucp->BitMapCurrentPointer), &valid, &hole )) != 0) return(ccode); \ + if (hole) { return( UNCOMPRESS_ERROR_INVALID_HOLES ); } \ + ucp->CompressedFileSize -= CD_SYSTEM_CACHE_BUFFER_SIZE; \ + if (ucp->CompressedFileSize < CD_SYSTEM_CACHE_BUFFER_SIZE) {\ + ucp->BitMapCurrentEnd = ucp->BitMapCurrentPointer + (ucp->CompressedFileSize >> 2) -1; \ + if (bitMapSwapped){ \ + if (CCDCheckSumSwappedBlock( ucp->BitMapCurrentPointer, \ + ucp->CompressedFileSize >> 2)) return( UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); \ + } \ + else {\ + if (CCDCheckSumBlock( ucp->BitMapCurrentPointer, \ + ucp->CompressedFileSize >> 2)) return( UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); \ + }\ + } \ + else { \ + ucp->BitMapCurrentEnd = ucp->BitMapCurrentPointer + (CD_SYSTEM_CACHE_BUFFER_LONGS -1); \ + if (bitMapSwapped) { \ + if (CCDCheckSumSwappedBlock4K( ucp->BitMapCurrentPointer )) return(UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); \ + } \ + else { \ + if (CCDCheckSumBlock4K( ucp->BitMapCurrentPointer )) return(UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); \ + } \ + } \ } /*********************************************************************** @@ -140,24 +140,24 @@ CCDDecompressProcessHoles( decompressHoleMark_tp hm, prev; if (bitMapSwapped) - prevHoleOffset = SWAP_LONG(*ucp->BitMapCurrentPointer); + prevHoleOffset = SWAP_LONG(*ucp->BitMapCurrentPointer); else - prevHoleOffset = *ucp->BitMapCurrentPointer; + prevHoleOffset = *ucp->BitMapCurrentPointer; NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "CCDDecompressProcessHoles(holeCount=%ld prevHoleOffset=%ld) called\n", holeCount, prevHoleOffset)); INC_BIT_MAP_PTR( ucp ) if (bitMapSwapped) - prevHoleSize = SWAP_LONG(*ucp->BitMapCurrentPointer); + prevHoleSize = SWAP_LONG(*ucp->BitMapCurrentPointer); else - prevHoleSize = *ucp->BitMapCurrentPointer; + prevHoleSize = *ucp->BitMapCurrentPointer; INC_BIT_MAP_PTR( ucp ) if((hm=(decompressHoleMark_tp)CD_MALLOC(sizeof(decompressHoleMark_t)))==NULL) { - return(UNCOMPRESS_ERROR_OUT_OF_RAM); + return(UNCOMPRESS_ERROR_OUT_OF_RAM); } ucp->HoleListHead = hm; @@ -173,38 +173,38 @@ CCDDecompressProcessHoles( while (holeCount) { - if (bitMapSwapped) - nextHoleOffset = SWAP_LONG(*ucp->BitMapCurrentPointer); - else - nextHoleOffset = *ucp->BitMapCurrentPointer; + if (bitMapSwapped) + nextHoleOffset = SWAP_LONG(*ucp->BitMapCurrentPointer); + else + nextHoleOffset = *ucp->BitMapCurrentPointer; - INC_BIT_MAP_PTR( ucp ) + INC_BIT_MAP_PTR( ucp ) - if (bitMapSwapped) - nextHoleSize = SWAP_LONG(*ucp->BitMapCurrentPointer); - else - nextHoleSize = *ucp->BitMapCurrentPointer; + if (bitMapSwapped) + nextHoleSize = SWAP_LONG(*ucp->BitMapCurrentPointer); + else + nextHoleSize = *ucp->BitMapCurrentPointer; - INC_BIT_MAP_PTR( ucp ) + INC_BIT_MAP_PTR( ucp ) - holeCount--; + holeCount--; - if((hm=(decompressHoleMark_tp) CD_MALLOC(sizeof(decompressHoleMark_t)))==NULL) - { - return( UNCOMPRESS_ERROR_OUT_OF_RAM ); - } + if((hm=(decompressHoleMark_tp) CD_MALLOC(sizeof(decompressHoleMark_t)))==NULL) + { + return( UNCOMPRESS_ERROR_OUT_OF_RAM ); + } - prev->next = hm; + prev->next = hm; - hm->next = NULL; - hm->offset = nextHoleOffset; - hm->size = nextHoleSize; + hm->next = NULL; + hm->offset = nextHoleOffset; + hm->size = nextHoleSize; - prev = hm; + prev = hm; } for(hm = ucp->HoleListHead; hm; hm = hm->next) - ucp->WriteFileSize -= hm->size; + ucp->WriteFileSize -= hm->size; return((LONG)0); @@ -243,27 +243,27 @@ CCDContinueDecompressHiLo(uncompressData_tp ucp) if (ucp->ThreadExitNow) { - ccode = UNCOMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_ABORTED; + goto ErrorExit; } /************************************************************************/ if ((ccode = CCDReadShannonTreeHiLo( ucp, &ucp->DataTree, &header->DataTreeNodes ))!=0) - goto ErrorExit; + goto ErrorExit; if (header->DataTreeNodes) { - ccode = UNCOMPRESS_ERROR_INVALID_DATA_COUNT; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_INVALID_DATA_COUNT; + goto ErrorExit; } if (ucp->ThreadExitNow) { - ccode = UNCOMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_ABORTED; + goto ErrorExit; } @@ -271,19 +271,19 @@ CCDContinueDecompressHiLo(uncompressData_tp ucp) if ((ccode = CCDReadShannonTreeHiLo( ucp, &ucp->LengthTree, &header->LengthTreeNodes ))!=0) - goto ErrorExit; + goto ErrorExit; if (header->LengthTreeNodes) { - ccode = UNCOMPRESS_ERROR_INVALID_DATA_COUNT; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_INVALID_DATA_COUNT; + goto ErrorExit; } if (ucp->ThreadExitNow) { - ccode = UNCOMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_ABORTED; + goto ErrorExit; } @@ -291,19 +291,19 @@ CCDContinueDecompressHiLo(uncompressData_tp ucp) if ((ccode = CCDReadShannonTreeHiLo( ucp, &ucp->OffsetTree, &header->OffsetTreeNodes ))!=0) - goto ErrorExit; + goto ErrorExit; if (header->OffsetTreeNodes) { - ccode = UNCOMPRESS_ERROR_INVALID_DATA_COUNT; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_INVALID_DATA_COUNT; + goto ErrorExit; } if (ucp->ThreadExitNow) { - ccode = UNCOMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_ABORTED; + goto ErrorExit; } @@ -311,44 +311,44 @@ CCDContinueDecompressHiLo(uncompressData_tp ucp) if (ucp->HoleListHead) { - while (ucp->HoleListHead && - ucp->HoleListHead->offset == (ucp->WriteCacheNextBlockToGet << CD_SYSTEM_CACHE_BUFFER_SHIFT )) - { - ucp->WriteCacheNextBlockToGet += (ucp->HoleListHead->size >> CD_SYSTEM_CACHE_BUFFER_SHIFT ); - holeMarker = ucp->HoleListHead; - ucp->HoleListHead = ucp->HoleListHead->next; - CD_FREE(holeMarker); - } + while (ucp->HoleListHead && + ucp->HoleListHead->offset == (ucp->WriteCacheNextBlockToGet << CD_SYSTEM_CACHE_BUFFER_SHIFT )) + { + ucp->WriteCacheNextBlockToGet += (ucp->HoleListHead->size >> CD_SYSTEM_CACHE_BUFFER_SHIFT ); + holeMarker = ucp->HoleListHead; + ucp->HoleListHead = ucp->HoleListHead->next; + CD_FREE(holeMarker); + } - if (ucp->WriteCacheNextBlockToGet == - ucp->decompressStatus.status.totalBlocksToDecompress) - { - /* This file has no real content */ - return 0; - } + if (ucp->WriteCacheNextBlockToGet == + ucp->decompressStatus.status.totalBlocksToDecompress) + { + /* This file has no real content */ + return 0; + } } if ((ccode=NSSCCDGetWriteCacheBlock(ucp->WriteHandle, - ucp->WriteCacheNextBlockToGet, (LONG)0, - &(ucp->WriteCachePointers[0]),&(ucp->WriteCacheHandle[0]))) !=0) + ucp->WriteCacheNextBlockToGet, (LONG)0, + &(ucp->WriteCachePointers[0]),&(ucp->WriteCacheHandle[0]))) !=0) { - ucp->WriteCachePointers[0] = NULL; - goto ErrorExit; + ucp->WriteCachePointers[0] = NULL; + goto ErrorExit; } ucp->WriteCurrentBufferBegin = ucp->WriteCurrentPointer = ucp->WriteCachePointers[0]; ucp->WriteCacheBufferEnd[0] = ucp->WriteCurrentBufferEnd = - (BYTE *)(((ADDR)ucp->WriteCurrentPointer) + CD_SYSTEM_CACHE_BUFFER_SIZE); + (BYTE *)(((ADDR)ucp->WriteCurrentPointer) + CD_SYSTEM_CACHE_BUFFER_SIZE); if (ucp->WriteFileSize <= CD_SYSTEM_CACHE_BUFFER_SIZE) { - ucp->WriteEOFPointer = (BYTE *)(((ADDR)ucp->WriteCurrentPointer) + - ucp->WriteFileSize); + ucp->WriteEOFPointer = (BYTE *)(((ADDR)ucp->WriteCurrentPointer) + + ucp->WriteFileSize); } else { - ucp->WriteCacheNextBlockToGet++; - ucp->WriteEOFPointer = (BYTE *)-1; + ucp->WriteCacheNextBlockToGet++; + ucp->WriteEOFPointer = (BYTE *)-1; } ucp->decompressStatus.status.state++; @@ -364,182 +364,182 @@ CCDContinueDecompressHiLo(uncompressData_tp ucp) ErrorExit: - for( holeMarker = ucp->HoleListHead; holeMarker; ) - { - previousHole = holeMarker; - holeMarker = holeMarker->next; - CD_FREE( previousHole ); - } + for( holeMarker = ucp->HoleListHead; holeMarker; ) + { + previousHole = holeMarker; + holeMarker = holeMarker->next; + CD_FREE( previousHole ); + } #if 0 - if (ucp->decompressStatus.prev) - ucp->decompressStatus.prev->next = ucp->decompressStatus.next; + if (ucp->decompressStatus.prev) + ucp->decompressStatus.prev->next = ucp->decompressStatus.next; - if (ucp->decompressStatus.next) - ucp->decompressStatus.next->prev = ucp->decompressStatus.prev; - else - { - if (!ucp->decompressStatus.prev) - VolumeDecompressFilesTail[ ucp->Volume ] = - (DecompressStatusNode_t *)&VolumeDecompressFiles[ ucp->Volume ]; - } + if (ucp->decompressStatus.next) + ucp->decompressStatus.next->prev = ucp->decompressStatus.prev; + else + { + if (!ucp->decompressStatus.prev) + VolumeDecompressFilesTail[ ucp->Volume ] = + (DecompressStatusNode_t *)&VolumeDecompressFiles[ ucp->Volume ]; + } #endif - if (ucp->WriteCachePointers[0]) - { - if (!ccode) - NSSCCDUpdateDecompressPosition( ucp->WriteHandle, (LONG)-1 ); - else - NSSCCDUpdateDecompressPosition( ucp->WriteHandle, (LONG)0 ); + if (ucp->WriteCachePointers[0]) + { + if (!ccode) + NSSCCDUpdateDecompressPosition( ucp->WriteHandle, (LONG)-1 ); + else + NSSCCDUpdateDecompressPosition( ucp->WriteHandle, (LONG)0 ); - for (i=0; iWriteCacheHandle[i] != 0) - { - if (ucp->WriteCurrentBufferEnd == ucp->WriteCacheBufferEnd[i]) - { - sectorsToWrite = - ((ucp->WriteCurrentPointer - ucp->WriteCurrentBufferBegin) + - (CD_SYSTEM_SECTOR_SIZE -1)) >> CD_SYSTEM_SECTOR_SHIFT; + if (ucp->WriteCacheHandle[i] != 0) + { + if (ucp->WriteCurrentBufferEnd == ucp->WriteCacheBufferEnd[i]) + { + sectorsToWrite = + ((ucp->WriteCurrentPointer - ucp->WriteCurrentBufferBegin) + + (CD_SYSTEM_SECTOR_SIZE -1)) >> CD_SYSTEM_SECTOR_SHIFT; - if (!scode) - scode = NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], - ucp->WriteHandle, sectorsToWrite, (LONG)0); - else - (void)NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], - ucp->WriteHandle, sectorsToWrite, (LONG)0); + if (!scode) + scode = NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], + ucp->WriteHandle, sectorsToWrite, (LONG)0); + else + (void)NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], + ucp->WriteHandle, sectorsToWrite, (LONG)0); - break; - } - else - { - if (!scode) - scode = NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], - ucp->WriteHandle, (LONG)CD_SYSTEM_SECTORS_PER_BUFFER, - (LONG)0); - else - (void)NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], - ucp->WriteHandle, (LONG)CD_SYSTEM_SECTORS_PER_BUFFER, - (LONG)0); - } - } - } - } + break; + } + else + { + if (!scode) + scode = NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], + ucp->WriteHandle, (LONG)CD_SYSTEM_SECTORS_PER_BUFFER, + (LONG)0); + else + (void)NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], + ucp->WriteHandle, (LONG)CD_SYSTEM_SECTORS_PER_BUFFER, + (LONG)0); + } + } + } + } - if ( ucp->ReadCache ) - { + if ( ucp->ReadCache ) + { #if TESTING_COMPRESSION - waitcount = ucp->ReadCache->CacheWaitCount; - rafailcount = ucp->ReadCache->CacheReadAheadFailedCount; - col = ucp->ReadCache->Collided; - colb = ucp->ReadCache->CollidedBytes; + waitcount = ucp->ReadCache->CacheWaitCount; + rafailcount = ucp->ReadCache->CacheReadAheadFailedCount; + col = ucp->ReadCache->Collided; + colb = ucp->ReadCache->CollidedBytes; #endif - s1code = NSSCCDStopReadAhead( ucp->ReadCache ); - } + s1code = NSSCCDStopReadAhead( ucp->ReadCache ); + } - endHigh = GetHighResolutionTimer(); + endHigh = GetHighResolutionTimer(); - CD_FREE( ucp->DataTree ); + CD_FREE( ucp->DataTree ); #if TESTING_COMPRESSION - if (CompressScreen) - { - end = GetCurrentTime(); + if (CompressScreen) + { + end = GetCurrentTime(); - if (end-beginTime) diff = end-beginTime; else diff = 1; + if (end-beginTime) diff = end-beginTime; else diff = 1; - percent = (100 - (header->CompressedFileLength * 100) / - header->OriginalFileLength); + percent = (100 - (header->CompressedFileLength * 100) / + header->OriginalFileLength); - if (!ccode) - { - NWALGO_DBG_PRINTF((CompressScreen,MSGNot("* %-12s %2ld %10ld %10ld %10ld %10ld %2ld %2ld %2ld %2ld %2ld hl\n"), - &ucp->DosName[1], percent, (header->OriginalFileLength/diff) * 18, - (header->CompressedFileLength/diff) * 18, header->CompressedFileLength, - header->OriginalFileLength, waitcount, rafailcount, col, colb, ucp->Volume)); - } - else - { - NWALGO_DBG_PRINTF((CompressScreen,MSGNot("* %-12s %10ld %10ld %10ld hl\n"), - &ucp->DosName[1], header->CompressedFileLength, - header->OriginalFileLength, ucp->Volume )); - } - } + if (!ccode) + { + NWALGO_DBG_PRINTF((CompressScreen,MSGNot("* %-12s %2ld %10ld %10ld %10ld %10ld %2ld %2ld %2ld %2ld %2ld hl\n"), + &ucp->DosName[1], percent, (header->OriginalFileLength/diff) * 18, + (header->CompressedFileLength/diff) * 18, header->CompressedFileLength, + header->OriginalFileLength, waitcount, rafailcount, col, colb, ucp->Volume)); + } + else + { + NWALGO_DBG_PRINTF((CompressScreen,MSGNot("* %-12s %10ld %10ld %10ld hl\n"), + &ucp->DosName[1], header->CompressedFileLength, + header->OriginalFileLength, ucp->Volume )); + } + } #endif - if (ccode) - { + if (ccode) + { #if 0 - if ((ccode > 10000) && (ccode <(10000 + UNCOMPRESS_ERROR_COUNT))) - UncompressStatistics [ ccode - 10001 ] ++; - CompressDecompressActivityCount--; + if ((ccode > 10000) && (ccode <(10000 + UNCOMPRESS_ERROR_COUNT))) + UncompressStatistics [ ccode - 10001 ] ++; + CompressDecompressActivityCount--; #endif - NSSCCDDecompressIsDone( ucp->WriteHandle, ccode, &ucp->DosName[0] ); + NSSCCDDecompressIsDone( ucp->WriteHandle, ccode, &ucp->DosName[0] ); - CD_FREE( ucp ); + CD_FREE( ucp ); - return ccode; - } + return ccode; + } - if (s1code) - { + if (s1code) + { #if 0 - if ((s1code > 10000) && (s1code <(10000 + UNCOMPRESS_ERROR_COUNT))) - UncompressStatistics [ s1code - 10001 ] ++; - CompressDecompressActivityCount--; + if ((s1code > 10000) && (s1code <(10000 + UNCOMPRESS_ERROR_COUNT))) + UncompressStatistics [ s1code - 10001 ] ++; + CompressDecompressActivityCount--; #endif - NSSCCDDecompressIsDone( ucp->WriteHandle, s1code, &ucp->DosName[0] ); + NSSCCDDecompressIsDone( ucp->WriteHandle, s1code, &ucp->DosName[0] ); - CD_FREE( ucp ); + CD_FREE( ucp ); - return s1code; - } + return s1code; + } - if (scode) - { + if (scode) + { #if 0 - if ((scode > 10000) && (scode <(10000 + UNCOMPRESS_ERROR_COUNT))) - UncompressStatistics [ scode - 10001 ] ++; - CompressDecompressActivityCount--; + if ((scode > 10000) && (scode <(10000 + UNCOMPRESS_ERROR_COUNT))) + UncompressStatistics [ scode - 10001 ] ++; + CompressDecompressActivityCount--; #endif - NSSCCDDecompressIsDone( ucp->WriteHandle, scode, &ucp->DosName[0] ); + NSSCCDDecompressIsDone( ucp->WriteHandle, scode, &ucp->DosName[0] ); - CD_FREE( ucp ); + CD_FREE( ucp ); - return scode; - } + return scode; + } - NSSCCDDecompressIsDone( ucp->WriteHandle, (LONG)0, &ucp->DosName[0] ); + NSSCCDDecompressIsDone( ucp->WriteHandle, (LONG)0, &ucp->DosName[0] ); #if 0 - highDiff = endHigh - ucp->beginHighTickCount; + highDiff = endHigh - ucp->beginHighTickCount; - VolumeDecompressHighTickCount[ ucp->Volume ] += highDiff; - if (highDiff > VolumeDecompressHighTickCount[ ucp->Volume ]) - VolumeDecompressHighTickHigh[ ucp->Volume ] ++; + VolumeDecompressHighTickCount[ ucp->Volume ] += highDiff; + if (highDiff > VolumeDecompressHighTickCount[ ucp->Volume ]) + VolumeDecompressHighTickHigh[ ucp->Volume ] ++; - VolumeDecompressByteInCount[ ucp->Volume ] += - ucp->Header->CompressedFileLength; - if (VolumeDecompressByteInCount[ ucp->Volume ] < - ucp->Header->CompressedFileLength) - VolumeDecompressHighByteInCount[ ucp->Volume ]++; + VolumeDecompressByteInCount[ ucp->Volume ] += + ucp->Header->CompressedFileLength; + if (VolumeDecompressByteInCount[ ucp->Volume ] < + ucp->Header->CompressedFileLength) + VolumeDecompressHighByteInCount[ ucp->Volume ]++; - VolumeDecompressByteOutCount[ ucp->Volume ] += - ucp->Header->OriginalFileLength; - if (VolumeDecompressByteOutCount[ ucp->Volume ] < - ucp->Header->OriginalFileLength ) - VolumeDecompressHighByteOutCount[ ucp->Volume ]++; - CompressDecompressActivityCount--; + VolumeDecompressByteOutCount[ ucp->Volume ] += + ucp->Header->OriginalFileLength; + if (VolumeDecompressByteOutCount[ ucp->Volume ] < + ucp->Header->OriginalFileLength ) + VolumeDecompressHighByteOutCount[ ucp->Volume ]++; + CompressDecompressActivityCount--; #endif - CD_FREE( ucp ); + CD_FREE( ucp ); return (LONG)0; } @@ -573,8 +573,8 @@ CCDContinueDecompress(uncompressData_tp ucp) if (ucp->ThreadExitNow) { - ccode = UNCOMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_ABORTED; + goto ErrorExit; } /************************************************************************/ @@ -585,15 +585,15 @@ CCDContinueDecompress(uncompressData_tp ucp) if (header->DataTreeNodes) { - ccode = UNCOMPRESS_ERROR_INVALID_DATA_COUNT; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_INVALID_DATA_COUNT; + goto ErrorExit; } if (ucp->ThreadExitNow) { - ccode = UNCOMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_ABORTED; + goto ErrorExit; } @@ -601,19 +601,19 @@ CCDContinueDecompress(uncompressData_tp ucp) if ((ccode = CCDReadShannonTree( ucp, &ucp->LengthTree, &header->LengthTreeNodes ))!=0) - goto ErrorExit; + goto ErrorExit; if (header->LengthTreeNodes) { - ccode = UNCOMPRESS_ERROR_INVALID_DATA_COUNT; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_INVALID_DATA_COUNT; + goto ErrorExit; } if (ucp->ThreadExitNow) { - ccode = UNCOMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_ABORTED; + goto ErrorExit; } @@ -621,19 +621,19 @@ CCDContinueDecompress(uncompressData_tp ucp) if ((ccode = CCDReadShannonTree( ucp, &ucp->OffsetTree, &header->OffsetTreeNodes ))!=0) - goto ErrorExit; + goto ErrorExit; if (header->OffsetTreeNodes) { - ccode = UNCOMPRESS_ERROR_INVALID_DATA_COUNT; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_INVALID_DATA_COUNT; + goto ErrorExit; } if (ucp->ThreadExitNow) { - ccode = UNCOMPRESS_ERROR_ABORTED; - goto ErrorExit; + ccode = UNCOMPRESS_ERROR_ABORTED; + goto ErrorExit; } @@ -641,44 +641,44 @@ CCDContinueDecompress(uncompressData_tp ucp) if (ucp->HoleListHead) { - while (ucp->HoleListHead && - ucp->HoleListHead->offset == (ucp->WriteCacheNextBlockToGet << CD_SYSTEM_CACHE_BUFFER_SHIFT )) - { - ucp->WriteCacheNextBlockToGet += (ucp->HoleListHead->size >> CD_SYSTEM_CACHE_BUFFER_SHIFT ); - holeMarker = ucp->HoleListHead; - ucp->HoleListHead = ucp->HoleListHead->next; - CD_FREE(holeMarker); - } + while (ucp->HoleListHead && + ucp->HoleListHead->offset == (ucp->WriteCacheNextBlockToGet << CD_SYSTEM_CACHE_BUFFER_SHIFT )) + { + ucp->WriteCacheNextBlockToGet += (ucp->HoleListHead->size >> CD_SYSTEM_CACHE_BUFFER_SHIFT ); + holeMarker = ucp->HoleListHead; + ucp->HoleListHead = ucp->HoleListHead->next; + CD_FREE(holeMarker); + } - if (ucp->WriteCacheNextBlockToGet == - ucp->decompressStatus.status.totalBlocksToDecompress) - { - /* This file has no real content */ - return 0; - } + if (ucp->WriteCacheNextBlockToGet == + ucp->decompressStatus.status.totalBlocksToDecompress) + { + /* This file has no real content */ + return 0; + } } if ((ccode=NSSCCDGetWriteCacheBlock(ucp->WriteHandle, - ucp->WriteCacheNextBlockToGet, (LONG)0, - &(ucp->WriteCachePointers[0]),&(ucp->WriteCacheHandle[0]))) !=0) + ucp->WriteCacheNextBlockToGet, (LONG)0, + &(ucp->WriteCachePointers[0]),&(ucp->WriteCacheHandle[0]))) !=0) { - ucp->WriteCachePointers[0] = NULL; - goto ErrorExit; + ucp->WriteCachePointers[0] = NULL; + goto ErrorExit; } ucp->WriteCurrentBufferBegin = ucp->WriteCurrentPointer = ucp->WriteCachePointers[0]; ucp->WriteCacheBufferEnd[0] = ucp->WriteCurrentBufferEnd = - (BYTE *)(((ADDR)ucp->WriteCurrentPointer) + CD_SYSTEM_CACHE_BUFFER_SIZE); + (BYTE *)(((ADDR)ucp->WriteCurrentPointer) + CD_SYSTEM_CACHE_BUFFER_SIZE); if (ucp->WriteFileSize <= CD_SYSTEM_CACHE_BUFFER_SIZE) { - ucp->WriteEOFPointer = (BYTE *)(((ADDR)ucp->WriteCurrentPointer) + - ucp->WriteFileSize); + ucp->WriteEOFPointer = (BYTE *)(((ADDR)ucp->WriteCurrentPointer) + + ucp->WriteFileSize); } else { - ucp->WriteCacheNextBlockToGet++; - ucp->WriteEOFPointer = (BYTE *)-1; + ucp->WriteCacheNextBlockToGet++; + ucp->WriteEOFPointer = (BYTE *)-1; } @@ -695,185 +695,185 @@ CCDContinueDecompress(uncompressData_tp ucp) ErrorExit: - for( holeMarker = ucp->HoleListHead; holeMarker; ) - { - previousHole = holeMarker; - holeMarker = holeMarker->next; - CD_FREE( previousHole ); - } + for( holeMarker = ucp->HoleListHead; holeMarker; ) + { + previousHole = holeMarker; + holeMarker = holeMarker->next; + CD_FREE( previousHole ); + } #if 0 - if (ucp->decompressStatus.prev) - ucp->decompressStatus.prev->next = ucp->decompressStatus.next; + if (ucp->decompressStatus.prev) + ucp->decompressStatus.prev->next = ucp->decompressStatus.next; - if (ucp->decompressStatus.next) - ucp->decompressStatus.next->prev = ucp->decompressStatus.prev; - else - { - if (!ucp->decompressStatus.prev) - VolumeDecompressFilesTail[ ucp->Volume ] = - (DecompressStatusNode_t *)&VolumeDecompressFiles[ ucp->Volume ]; - } + if (ucp->decompressStatus.next) + ucp->decompressStatus.next->prev = ucp->decompressStatus.prev; + else + { + if (!ucp->decompressStatus.prev) + VolumeDecompressFilesTail[ ucp->Volume ] = + (DecompressStatusNode_t *)&VolumeDecompressFiles[ ucp->Volume ]; + } #endif - if (ucp->WriteCachePointers[0]) - { - if (!ccode) - NSSCCDUpdateDecompressPosition( ucp->WriteHandle, (LONG)-1 ); - else - NSSCCDUpdateDecompressPosition( ucp->WriteHandle, (LONG)0 ); + if (ucp->WriteCachePointers[0]) + { + if (!ccode) + NSSCCDUpdateDecompressPosition( ucp->WriteHandle, (LONG)-1 ); + else + NSSCCDUpdateDecompressPosition( ucp->WriteHandle, (LONG)0 ); - for (i=0; iWriteCacheHandle[i] != 0) - { - if (ucp->WriteCurrentBufferEnd == ucp->WriteCacheBufferEnd[i]) - { - sectorsToWrite = - ((ucp->WriteCurrentPointer - ucp->WriteCurrentBufferBegin) + - (CD_SYSTEM_SECTOR_SIZE -1)) >> CD_SYSTEM_SECTOR_SHIFT; + for (i=0; iWriteCacheHandle[i] != 0) + { + if (ucp->WriteCurrentBufferEnd == ucp->WriteCacheBufferEnd[i]) + { + sectorsToWrite = + ((ucp->WriteCurrentPointer - ucp->WriteCurrentBufferBegin) + + (CD_SYSTEM_SECTOR_SIZE -1)) >> CD_SYSTEM_SECTOR_SHIFT; - if (!scode) - scode = NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], - ucp->WriteHandle, sectorsToWrite, (LONG)0); - else - (void)NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], - ucp->WriteHandle, sectorsToWrite, (LONG)0); + if (!scode) + scode = NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], + ucp->WriteHandle, sectorsToWrite, (LONG)0); + else + (void)NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], + ucp->WriteHandle, sectorsToWrite, (LONG)0); - break; - } - else - { - if (!scode) - scode = NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], - ucp->WriteHandle, (LONG)CD_SYSTEM_SECTORS_PER_BUFFER, - (LONG)0); - else - (void)NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], - ucp->WriteHandle, (LONG)CD_SYSTEM_SECTORS_PER_BUFFER, - (LONG)0); - } - } - } - } + break; + } + else + { + if (!scode) + scode = NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], + ucp->WriteHandle, (LONG)CD_SYSTEM_SECTORS_PER_BUFFER, + (LONG)0); + else + (void)NSSCCDReturnWriteCacheBlock( ucp->WriteCacheHandle[i], + ucp->WriteHandle, (LONG)CD_SYSTEM_SECTORS_PER_BUFFER, + (LONG)0); + } + } + } + } - if ( ucp->ReadCache ) - { + if ( ucp->ReadCache ) + { #if TESTING_COMPRESSION - waitcount = ucp->ReadCache->CacheWaitCount; - rafailcount = ucp->ReadCache->CacheReadAheadFailedCount; - col = ucp->ReadCache->Collided; - colb = ucp->ReadCache->CollidedBytes; + waitcount = ucp->ReadCache->CacheWaitCount; + rafailcount = ucp->ReadCache->CacheReadAheadFailedCount; + col = ucp->ReadCache->Collided; + colb = ucp->ReadCache->CollidedBytes; #endif - s1code = NSSCCDStopReadAhead( ucp->ReadCache ); - } + s1code = NSSCCDStopReadAhead( ucp->ReadCache ); + } - CD_FREE( ucp->DataTree ); + CD_FREE( ucp->DataTree ); - endHigh = GetHighResolutionTimer(); + endHigh = GetHighResolutionTimer(); #if TESTING_COMPRESSION - if (CompressScreen) - { - end = GetCurrentTime(); + if (CompressScreen) + { + end = GetCurrentTime(); - if (end-beginTime) diff = end-beginTime; else diff = 1; + if (end-beginTime) diff = end-beginTime; else diff = 1; - percent = (100 - (header->CompressedFileLength * 100) / - header->OriginalFileLength); + percent = (100 - (header->CompressedFileLength * 100) / + header->OriginalFileLength); - if (!ccode) - { - NWALGO_DBG_PRINTF((CompressScreen,MSGNot("* %-12s %2ld %10ld %10ld %10ld %10ld %2ld %2ld %2ld %2ld %2ld\n"), - &ucp->DosName[1], percent, (header->OriginalFileLength/diff) * 18, - (header->CompressedFileLength/diff) * 18, header->CompressedFileLength, - header->OriginalFileLength, waitcount, rafailcount, col, colb, ucp->Volume)); - } - else - { - NWALGO_DBG_PRINTF((CompressScreen, MSGNot("* %-12s %10ld %10ld %10ld %10ld\n"), - &ucp->DosName[1], header->CompressedFileLength, - header->OriginalFileLength, ucp->Volume, ccode)); - } + if (!ccode) + { + NWALGO_DBG_PRINTF((CompressScreen,MSGNot("* %-12s %2ld %10ld %10ld %10ld %10ld %2ld %2ld %2ld %2ld %2ld\n"), + &ucp->DosName[1], percent, (header->OriginalFileLength/diff) * 18, + (header->CompressedFileLength/diff) * 18, header->CompressedFileLength, + header->OriginalFileLength, waitcount, rafailcount, col, colb, ucp->Volume)); + } + else + { + NWALGO_DBG_PRINTF((CompressScreen, MSGNot("* %-12s %10ld %10ld %10ld %10ld\n"), + &ucp->DosName[1], header->CompressedFileLength, + header->OriginalFileLength, ucp->Volume, ccode)); + } - } + } #endif - if (ccode) - { + if (ccode) + { #if 0 - if ((ccode > 10000) && (ccode <(10000 + UNCOMPRESS_ERROR_COUNT))) - UncompressStatistics [ ccode - 10001 ] ++; - CompressDecompressActivityCount--; + if ((ccode > 10000) && (ccode <(10000 + UNCOMPRESS_ERROR_COUNT))) + UncompressStatistics [ ccode - 10001 ] ++; + CompressDecompressActivityCount--; #endif - NSSCCDDecompressIsDone( ucp->WriteHandle, ccode, &ucp->DosName[0] ); + NSSCCDDecompressIsDone( ucp->WriteHandle, ccode, &ucp->DosName[0] ); - CD_FREE( ucp ); + CD_FREE( ucp ); - return ccode; - } + return ccode; + } - if (s1code) - { + if (s1code) + { #if 0 - if ((s1code > 10000) && (s1code <(10000 + UNCOMPRESS_ERROR_COUNT))) - UncompressStatistics [ s1code - 10001 ] ++; - CompressDecompressActivityCount--; + if ((s1code > 10000) && (s1code <(10000 + UNCOMPRESS_ERROR_COUNT))) + UncompressStatistics [ s1code - 10001 ] ++; + CompressDecompressActivityCount--; #endif - NSSCCDDecompressIsDone( ucp->WriteHandle, s1code, &ucp->DosName[0] ); + NSSCCDDecompressIsDone( ucp->WriteHandle, s1code, &ucp->DosName[0] ); - CD_FREE( ucp ); + CD_FREE( ucp ); - return s1code; - } + return s1code; + } - if (scode) - { + if (scode) + { #if 0 - if ((scode > 10000) && (scode <(10000 + UNCOMPRESS_ERROR_COUNT))) - UncompressStatistics [ scode - 10001 ] ++; - CompressDecompressActivityCount--; + if ((scode > 10000) && (scode <(10000 + UNCOMPRESS_ERROR_COUNT))) + UncompressStatistics [ scode - 10001 ] ++; + CompressDecompressActivityCount--; #endif - NSSCCDDecompressIsDone( ucp->WriteHandle, scode, &ucp->DosName[0] ); + NSSCCDDecompressIsDone( ucp->WriteHandle, scode, &ucp->DosName[0] ); - CD_FREE( ucp ); + CD_FREE( ucp ); - return scode; - } + return scode; + } - NSSCCDDecompressIsDone( ucp->WriteHandle, (LONG)0, &ucp->DosName[0] ); + NSSCCDDecompressIsDone( ucp->WriteHandle, (LONG)0, &ucp->DosName[0] ); #if 0 - highDiff = endHigh - ucp->beginHighTickCount; + highDiff = endHigh - ucp->beginHighTickCount; - VolumeDecompressHighTickCount[ ucp->Volume ] += highDiff; - if (highDiff > VolumeDecompressHighTickCount[ ucp->Volume ]) - VolumeDecompressHighTickHigh[ ucp->Volume ] ++; + VolumeDecompressHighTickCount[ ucp->Volume ] += highDiff; + if (highDiff > VolumeDecompressHighTickCount[ ucp->Volume ]) + VolumeDecompressHighTickHigh[ ucp->Volume ] ++; - VolumeDecompressByteInCount[ ucp->Volume ] += - ucp->Header->CompressedFileLength; - if (VolumeDecompressByteInCount[ ucp->Volume ] < - ucp->Header->CompressedFileLength) - VolumeDecompressHighByteInCount[ ucp->Volume ]++; + VolumeDecompressByteInCount[ ucp->Volume ] += + ucp->Header->CompressedFileLength; + if (VolumeDecompressByteInCount[ ucp->Volume ] < + ucp->Header->CompressedFileLength) + VolumeDecompressHighByteInCount[ ucp->Volume ]++; - VolumeDecompressByteOutCount[ ucp->Volume ] += - ucp->Header->OriginalFileLength; - if (VolumeDecompressByteOutCount[ ucp->Volume ] < - ucp->Header->OriginalFileLength ) - VolumeDecompressHighByteOutCount[ ucp->Volume ]++; - CompressDecompressActivityCount--; + VolumeDecompressByteOutCount[ ucp->Volume ] += + ucp->Header->OriginalFileLength; + if (VolumeDecompressByteOutCount[ ucp->Volume ] < + ucp->Header->OriginalFileLength ) + VolumeDecompressHighByteOutCount[ ucp->Volume ]++; + CompressDecompressActivityCount--; #endif - CD_FREE( ucp ); + CD_FREE( ucp ); return (LONG)0; @@ -898,34 +898,34 @@ CCDStartDecompress( compressFileHeader_tp header; decompressHoleMark_tp holeMarker, previousHole; - LONG ccode, valid, hole, nodeTotal, actualSize ; - LONG holeFlag, bytesRead, firstReadHandle; - LONG headerChecksum=0, *headerChecksumPtr; - LONG i; - LONG bitMapSwapped=0; + LONG ccode, valid, hole, nodeTotal, actualSize ; + LONG holeFlag, bytesRead, firstReadHandle; + LONG headerChecksum=0, *headerChecksumPtr; + LONG i; + LONG bitMapSwapped=0; - BYTE *firstBuffer = 0; + BYTE *firstBuffer = 0; NWALGO_DBG_PRINTF((RED, "CCDStartDecompress\n")); #if 0 if ((CompressDecompressActivityCount+1) >= ( CurrentNumberOfCacheBuffers >> 3 )) { - UncompressStatistics[ UNCOMPRESS_ERROR_TRY_AGAIN - 10001 ]++; - return( UNCOMPRESS_ERROR_TRY_AGAIN ); + UncompressStatistics[ UNCOMPRESS_ERROR_TRY_AGAIN - 10001 ]++; + return( UNCOMPRESS_ERROR_TRY_AGAIN ); } CompressDecompressActivityCount++; #endif if ((ucp=(uncompressData_tp)CD_MALLOC( - sizeof(uncompressData_t) + sizeof(compressFileHeader_t))) == NULL) + sizeof(uncompressData_t) + sizeof(compressFileHeader_t))) == NULL) { #if 0 - CompressDecompressActivityCount--; - UncompressStatistics[ UNCOMPRESS_ERROR_OUT_OF_RAM - 10001 ]++; + CompressDecompressActivityCount--; + UncompressStatistics[ UNCOMPRESS_ERROR_OUT_OF_RAM - 10001 ]++; #endif - return( UNCOMPRESS_ERROR_OUT_OF_RAM ); + return( UNCOMPRESS_ERROR_OUT_OF_RAM ); } memset( ucp, 0, sizeof( *ucp ) ); @@ -938,12 +938,12 @@ NWALGO_DBG_PRINTF((RED, "CCDStartDecompress\n")); header = ucp->Header = (compressFileHeader_tp)((ADDR)ucp + sizeof(uncompressData_t)); // CMovB( dosName, &ucp->DosName[0], dosName[0]+1 ); - memmove(&ucp->DosName[0], dosName, dosName[0]+1 ); + memmove(&ucp->DosName[0], dosName, dosName[0]+1 ); ucp->DosName[ dosName[0]+1 ] = '\0'; ucp->Volume = volume; - + if ((ccode = NSSCCDPrepareForRead(inHandle, header->CompressedFileLength, &ucp->ReadCache)) != 0) { @@ -953,32 +953,32 @@ NWALGO_DBG_PRINTF((RED, "CCDStartDecompress\n")); *decompressHandle = (ADDR)ucp; if ((ccode = NSSCCDGetReadCacheBlock( inHandle, (LONG)0, &bytesRead, - &firstBuffer, &firstReadHandle, &holeFlag)) !=0 ) + &firstBuffer, &firstReadHandle, &holeFlag)) !=0 ) { - firstBuffer = NULL; - goto StartDecompressErrorExit; + firstBuffer = NULL; + goto StartDecompressErrorExit; } if (holeFlag) { - ccode = UNCOMPRESS_ERROR_INVALID_HOLES; - goto StartDecompressErrorExit; + ccode = UNCOMPRESS_ERROR_INVALID_HOLES; + goto StartDecompressErrorExit; } if (!bytesRead) { - ccode = UNCOMPRESS_ERROR_FILE_TOO_SMALL; - goto StartDecompressErrorExit; + ccode = UNCOMPRESS_ERROR_FILE_TOO_SMALL; + goto StartDecompressErrorExit; } if (ucp->ThreadExitNow) { - ccode = UNCOMPRESS_ERROR_ABORTED; - goto StartDecompressErrorExit; + ccode = UNCOMPRESS_ERROR_ABORTED; + goto StartDecompressErrorExit; } // CMovD( firstBuffer, header, sizeof(*header) >> 2 ); - memmove( header, firstBuffer, sizeof(*header)); + memmove( header, firstBuffer, sizeof(*header)); #if 0 NSSCCDReturnReadCacheBlock( inHandle, firstReadHandle ); @@ -987,38 +987,38 @@ NWALGO_DBG_PRINTF((RED, "CCDStartDecompress\n")); ucp->ReadCache->CacheHandles[ucp->ReadCache->CacheNextToBeUsed & CD_READ_CACHE_MASK] = firstReadHandle; ucp->BitMapCurrentPointer = (LONG *)firstBuffer; ucp->ReadCache->CacheNextToBeUsed ++; - ucp->ReadCache->CacheNextToBeUsed &= CD_READ_CACHE_MASK; - ucp->ReadCache->CacheNextBlockToRead ++; + ucp->ReadCache->CacheNextToBeUsed &= CD_READ_CACHE_MASK; + ucp->ReadCache->CacheNextBlockToRead ++; #endif firstBuffer = NULL; if (ucp->ThreadExitNow) { - ccode = UNCOMPRESS_ERROR_ABORTED; - goto StartDecompressErrorExit; + ccode = UNCOMPRESS_ERROR_ABORTED; + goto StartDecompressErrorExit; } if ((header->CompressCode != NETWARE_COMPRESS_LOHI) - && (header->CompressCode != NETWARE_COMPRESS_HILO) - && (header->CompressCode != 0)) + && (header->CompressCode != NETWARE_COMPRESS_HILO) + && (header->CompressCode != 0)) { - CD_FREE( ucp ); + CD_FREE( ucp ); - return( UNCOMPRESS_ERROR_UNKNOWN_VERSION ); + return( UNCOMPRESS_ERROR_UNKNOWN_VERSION ); } if (bytesRead < sizeof(*header)) { - ccode = UNCOMPRESS_ERROR_FILE_TOO_SMALL; - goto StartDecompressErrorExit; + ccode = UNCOMPRESS_ERROR_FILE_TOO_SMALL; + goto StartDecompressErrorExit; } if ((header->CompressMajorVersion != COMPRESS_MAJOR_VERSION) || - (header->CompressMinorVersion != COMPRESS_MINOR_VERSION)) + (header->CompressMinorVersion != COMPRESS_MINOR_VERSION)) { - ccode = UNCOMPRESS_ERROR_UNKNOWN_VERSION; - goto StartDecompressErrorExit; + ccode = UNCOMPRESS_ERROR_UNKNOWN_VERSION; + goto StartDecompressErrorExit; } #ifdef HI_LO_MACH_TYPE /* APPLE/rmw - was #ifdef HILO_MACHINE */ @@ -1026,138 +1026,138 @@ NWALGO_DBG_PRINTF((RED, "CCDStartDecompress\n")); #else if ((header->CompressCode & NETWARE_COMPRESS_HILO)) { #endif - bitMapSwapped = 1; + bitMapSwapped = 1; - *(LONG *)&header->CompressCode = SWAP_LONG( *(LONG *)&header->CompressCode ); - header->CompressedFileLength = SWAP_LONG( header->CompressedFileLength ); - header->OriginalFileLength = SWAP_LONG( header->OriginalFileLength ); - header->DataTreeNodes = SWAP_LONG( header->DataTreeNodes ); - header->LengthTreeNodes = SWAP_LONG( header->LengthTreeNodes ); - header->OffsetTreeNodes = SWAP_LONG( header->OffsetTreeNodes ); - header->NumberOfHoles = SWAP_LONG( header->NumberOfHoles ); - header->HeaderCheckSum = SWAP_LONG( header->HeaderCheckSum ); + *(LONG *)&header->CompressCode = SWAP_LONG( *(LONG *)&header->CompressCode ); + header->CompressedFileLength = SWAP_LONG( header->CompressedFileLength ); + header->OriginalFileLength = SWAP_LONG( header->OriginalFileLength ); + header->DataTreeNodes = SWAP_LONG( header->DataTreeNodes ); + header->LengthTreeNodes = SWAP_LONG( header->LengthTreeNodes ); + header->OffsetTreeNodes = SWAP_LONG( header->OffsetTreeNodes ); + header->NumberOfHoles = SWAP_LONG( header->NumberOfHoles ); + header->HeaderCheckSum = SWAP_LONG( header->HeaderCheckSum ); } headerChecksumPtr = (LONG *)header; for (i=0; i< (sizeof(compressFileHeader_t)>>2) -1; i++, headerChecksumPtr++ ) - headerChecksum += *headerChecksumPtr; + headerChecksum += *headerChecksumPtr; if (headerChecksum != header->HeaderCheckSum) { - ccode = UNCOMPRESS_ERROR_INVALID_HEADER; - goto StartDecompressErrorExit; + ccode = UNCOMPRESS_ERROR_INVALID_HEADER; + goto StartDecompressErrorExit; } ucp->decompressStatus.status.totalBlocksToDecompress = - (header->OriginalFileLength + (CD_SYSTEM_CACHE_BUFFER_SIZE - 1)) - >> CD_SYSTEM_CACHE_BUFFER_SHIFT; + (header->OriginalFileLength + (CD_SYSTEM_CACHE_BUFFER_SIZE - 1)) + >> CD_SYSTEM_CACHE_BUFFER_SHIFT; #if 0 if (VolumeDecompressFilesTail[ ucp->Volume ]->next == - (DecompressStatusNode_t *)&VolumeDecompressFiles[ ucp->Volume ]) - ucp->decompressStatus.prev = NULL; + (DecompressStatusNode_t *)&VolumeDecompressFiles[ ucp->Volume ]) + ucp->decompressStatus.prev = NULL; else - ucp->decompressStatus.prev = VolumeDecompressFilesTail[ ucp->Volume ]; + ucp->decompressStatus.prev = VolumeDecompressFilesTail[ ucp->Volume ]; ucp->decompressStatus.next = NULL; VolumeDecompressFilesTail[ ucp->Volume ]->next = - (DecompressStatusNode_t *)&ucp->decompressStatus; + (DecompressStatusNode_t *)&ucp->decompressStatus; queued++; #endif - /* ignore the error + /* ignore the error (void)EventReport( EVENT_DECOMPRESS_FILE, (LONG)&ucp->decompressStatus.status ); */ nodeTotal = (header->DataTreeNodes + header->LengthTreeNodes + - header->OffsetTreeNodes) * sizeof(uncompressNode_t); + header->OffsetTreeNodes) * sizeof(uncompressNode_t); actualSize = nodeTotal; if ((ucp->DataTree = (uncompressNode_tp)CD_MALLOC(nodeTotal)) == NULL) { - ccode = UNCOMPRESS_ERROR_TRY_AGAIN; - goto StartDecompressErrorExit; + ccode = UNCOMPRESS_ERROR_TRY_AGAIN; + goto StartDecompressErrorExit; } if (ucp->ThreadExitNow) { - ccode = UNCOMPRESS_ERROR_ABORTED; - goto StartDecompressErrorExit; + ccode = UNCOMPRESS_ERROR_ABORTED; + goto StartDecompressErrorExit; } memset( ucp->DataTree, 0, nodeTotal ); ucp->LengthTree = (uncompressNode_tp)((ADDR)ucp->DataTree + - (header->DataTreeNodes * sizeof(uncompressNode_t))); + (header->DataTreeNodes * sizeof(uncompressNode_t))); ucp->OffsetTree = (uncompressNode_tp)((ADDR)ucp->LengthTree + - (header->LengthTreeNodes * sizeof(uncompressNode_t))); + (header->LengthTreeNodes * sizeof(uncompressNode_t))); ucp->CompressedFileSize = header->CompressedFileLength; if (ucp->ThreadExitNow) { - ccode = UNCOMPRESS_ERROR_ABORTED; - goto StartDecompressErrorExit; + ccode = UNCOMPRESS_ERROR_ABORTED; + goto StartDecompressErrorExit; } #if 0 if ((ccode=NSSCCDGetReadAheadBuffer( ucp->ReadCache, - (BYTE **)&(ucp->BitMapCurrentPointer), &bytesRead, &holeFlag )) != 0) - goto StartDecompressErrorExit; + (BYTE **)&(ucp->BitMapCurrentPointer), &bytesRead, &holeFlag )) != 0) + goto StartDecompressErrorExit; #endif if (ucp->CompressedFileSize < CD_SYSTEM_CACHE_BUFFER_SIZE) { - ucp->BitMapCurrentEnd = ucp->BitMapCurrentPointer - + ((ucp->CompressedFileSize >> 2)-1 ); + ucp->BitMapCurrentEnd = ucp->BitMapCurrentPointer + + ((ucp->CompressedFileSize >> 2)-1 ); - if (bitMapSwapped) - { - if (CCDCheckSumSwappedBlock( ucp->BitMapCurrentPointer, - ucp->CompressedFileSize >> 2)) - { - ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; - goto StartDecompressErrorExit; - } + if (bitMapSwapped) + { + if (CCDCheckSumSwappedBlock( ucp->BitMapCurrentPointer, + ucp->CompressedFileSize >> 2)) + { + ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; + goto StartDecompressErrorExit; + } + } + else + { + if (CCDCheckSumBlock( ucp->BitMapCurrentPointer, + ucp->CompressedFileSize >> 2)) + { + ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; + goto StartDecompressErrorExit; + } + } + + ucp->CompressedFileSize = 0; } else { - if (CCDCheckSumBlock( ucp->BitMapCurrentPointer, - ucp->CompressedFileSize >> 2)) - { - ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; - goto StartDecompressErrorExit; - } - } + ucp->BitMapCurrentEnd = ucp->BitMapCurrentPointer + + (CD_SYSTEM_CACHE_BUFFER_LONGS - 1 ); - ucp->CompressedFileSize = 0; - } - else - { - ucp->BitMapCurrentEnd = ucp->BitMapCurrentPointer - + (CD_SYSTEM_CACHE_BUFFER_LONGS - 1 ); + ucp->CompressedFileSize -= CD_SYSTEM_CACHE_BUFFER_SIZE; - ucp->CompressedFileSize -= CD_SYSTEM_CACHE_BUFFER_SIZE; + if (bitMapSwapped) + { + if (CCDCheckSumSwappedBlock4K( ucp->BitMapCurrentPointer )) + { + ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; + goto StartDecompressErrorExit; + } - if (bitMapSwapped) - { - if (CCDCheckSumSwappedBlock4K( ucp->BitMapCurrentPointer )) - { - ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; - goto StartDecompressErrorExit; - } - - } - else - { - if (CCDCheckSumBlock4K( ucp->BitMapCurrentPointer )) - { - ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; - goto StartDecompressErrorExit; - } - } + } + else + { + if (CCDCheckSumBlock4K( ucp->BitMapCurrentPointer )) + { + ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; + goto StartDecompressErrorExit; + } + } } ucp->BitMapCurrentPointer += (sizeof(compressFileHeader_t)>>2); @@ -1166,25 +1166,25 @@ NWALGO_DBG_PRINTF((RED, "CCDStartDecompress\n")); if (!header->NumberOfHoles) { - if ((ccode=NSSCCDDecompressBuildFile( outHandle, (LONG)0, - header->OriginalFileLength, 0, 0 )) != 0) - goto StartDecompressErrorExit; + if ((ccode=NSSCCDDecompressBuildFile( outHandle, (LONG)0, + header->OriginalFileLength, 0, 0 )) != 0) + goto StartDecompressErrorExit; } - else - { - if ((ccode=CCDDecompressProcessHoles( - ucp, header->NumberOfHoles, bitMapSwapped ) )!=0) - goto StartDecompressErrorExit; + else + { + if ((ccode=CCDDecompressProcessHoles( + ucp, header->NumberOfHoles, bitMapSwapped ) )!=0) + goto StartDecompressErrorExit; - if ((ccode=NSSCCDDecompressBuildFile( outHandle, (LONG)0, - header->OriginalFileLength, 0, 0 )) != 0) - goto StartDecompressErrorExit; - } + if ((ccode=NSSCCDDecompressBuildFile( outHandle, (LONG)0, + header->OriginalFileLength, 0, 0 )) != 0) + goto StartDecompressErrorExit; + } if (bitMapSwapped) - ucp->BitBuffer = SWAP_LONG(*ucp->BitMapCurrentPointer); + ucp->BitBuffer = SWAP_LONG(*ucp->BitMapCurrentPointer); else - ucp->BitBuffer = *ucp->BitMapCurrentPointer; + ucp->BitBuffer = *ucp->BitMapCurrentPointer; ucp->BitBufferIndex = 33; @@ -1192,75 +1192,75 @@ NWALGO_DBG_PRINTF((RED, "CCDStartDecompress\n")); if( ucp->BitMapCurrentPointer == ucp->BitMapCurrentEnd ) { - if (ucp->CompressedFileSize == 0) - { - ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; - goto StartDecompressErrorExit; - } + if (ucp->CompressedFileSize == 0) + { + ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; + goto StartDecompressErrorExit; + } - if ((ccode = NSSCCDFreeReadAheadBuffer( ucp->ReadCache )) != 0) - goto StartDecompressErrorExit; + if ((ccode = NSSCCDFreeReadAheadBuffer( ucp->ReadCache )) != 0) + goto StartDecompressErrorExit; - if ((ccode = NSSCCDGetReadAheadBuffer( ucp->ReadCache, - (BYTE **)&(ucp->BitMapCurrentPointer), &valid, &hole )) != 0) - goto StartDecompressErrorExit; + if ((ccode = NSSCCDGetReadAheadBuffer( ucp->ReadCache, + (BYTE **)&(ucp->BitMapCurrentPointer), &valid, &hole )) != 0) + goto StartDecompressErrorExit; - if (hole) - { - ccode = UNCOMPRESS_ERROR_INVALID_HOLES; - goto StartDecompressErrorExit; - } + if (hole) + { + ccode = UNCOMPRESS_ERROR_INVALID_HOLES; + goto StartDecompressErrorExit; + } - if (ucp->CompressedFileSize < CD_SYSTEM_CACHE_BUFFER_SIZE) - { - ucp->BitMapCurrentEnd = ucp->BitMapCurrentPointer - + (ucp->CompressedFileSize >> 2) -1; + if (ucp->CompressedFileSize < CD_SYSTEM_CACHE_BUFFER_SIZE) + { + ucp->BitMapCurrentEnd = ucp->BitMapCurrentPointer + + (ucp->CompressedFileSize >> 2) -1; - if (bitMapSwapped) - { - if (CCDCheckSumSwappedBlock( ucp->BitMapCurrentPointer, - ucp->CompressedFileSize >> 2)) - { - ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; - goto StartDecompressErrorExit; - } - } - else - { - if (CCDCheckSumBlock( ucp->BitMapCurrentPointer, - ucp->CompressedFileSize >> 2)) - { - ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; - goto StartDecompressErrorExit; - } - } + if (bitMapSwapped) + { + if (CCDCheckSumSwappedBlock( ucp->BitMapCurrentPointer, + ucp->CompressedFileSize >> 2)) + { + ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; + goto StartDecompressErrorExit; + } + } + else + { + if (CCDCheckSumBlock( ucp->BitMapCurrentPointer, + ucp->CompressedFileSize >> 2)) + { + ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; + goto StartDecompressErrorExit; + } + } - ucp->CompressedFileSize = 0; - } - else - { - ucp->BitMapCurrentEnd = ucp->BitMapCurrentPointer - + (CD_SYSTEM_CACHE_BUFFER_LONGS - 1); + ucp->CompressedFileSize = 0; + } + else + { + ucp->BitMapCurrentEnd = ucp->BitMapCurrentPointer + + (CD_SYSTEM_CACHE_BUFFER_LONGS - 1); - ucp->CompressedFileSize -= CD_SYSTEM_CACHE_BUFFER_SIZE; + ucp->CompressedFileSize -= CD_SYSTEM_CACHE_BUFFER_SIZE; - if (bitMapSwapped) - { - if (CCDCheckSumSwappedBlock4K( ucp->BitMapCurrentPointer )) - { - ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; - goto StartDecompressErrorExit; - } - } - else - { - if (CCDCheckSumBlock4K( ucp->BitMapCurrentPointer )) - { - ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; - goto StartDecompressErrorExit; - } - } - } + if (bitMapSwapped) + { + if (CCDCheckSumSwappedBlock4K( ucp->BitMapCurrentPointer )) + { + ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; + goto StartDecompressErrorExit; + } + } + else + { + if (CCDCheckSumBlock4K( ucp->BitMapCurrentPointer )) + { + ccode = UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE; + goto StartDecompressErrorExit; + } + } + } } ucp->decompressStatus.status.state++; @@ -1277,55 +1277,56 @@ NWALGO_DBG_PRINTF((RED, "CCDStartDecompress\n")); StartDecompressErrorExit: - for( holeMarker = ucp->HoleListHead; holeMarker; ) - { - previousHole = holeMarker; - holeMarker = holeMarker->next; - CD_FREE( previousHole ); - } + for( holeMarker = ucp->HoleListHead; holeMarker; ) + { + previousHole = holeMarker; + holeMarker = holeMarker->next; + CD_FREE( previousHole ); + } #if 0 - if (queued) - { - if (ucp->decompressStatus.prev) - ucp->decompressStatus.prev->next = ucp->decompressStatus.next; + if (queued) + { + if (ucp->decompressStatus.prev) + ucp->decompressStatus.prev->next = ucp->decompressStatus.next; - if (ucp->decompressStatus.next) - ucp->decompressStatus.next->prev = ucp->decompressStatus.prev; - else - { - if (!ucp->decompressStatus.prev) - VolumeDecompressFilesTail[ ucp->Volume ] = - (DecompressStatusNode_t *)&VolumeDecompressFiles[ ucp->Volume ]; - } - } + if (ucp->decompressStatus.next) + ucp->decompressStatus.next->prev = ucp->decompressStatus.prev; + else + { + if (!ucp->decompressStatus.prev) + VolumeDecompressFilesTail[ ucp->Volume ] = + (DecompressStatusNode_t *)&VolumeDecompressFiles[ ucp->Volume ]; + } + } #endif - if ( firstBuffer ) NSSCCDReturnReadCacheBlock(inHandle, firstReadHandle); + if ( firstBuffer ) NSSCCDReturnReadCacheBlock(inHandle, firstReadHandle); - if ( ucp->ReadCache ) NSSCCDStopReadAhead( ucp->ReadCache ); - - if ( ucp->DataTree ) CD_FREE( ucp->DataTree ); + if ( ucp->ReadCache ) NSSCCDStopReadAhead( ucp->ReadCache ); + + if ( ucp->DataTree ) CD_FREE( ucp->DataTree ); #if 0 - if ((ccode > 10000) && (ccode <(10000 + UNCOMPRESS_ERROR_COUNT))) - UncompressStatistics [ ccode - 10001 ] ++; - CompressDecompressActivityCount--; + if ((ccode > 10000) && (ccode <(10000 + UNCOMPRESS_ERROR_COUNT))) + UncompressStatistics [ ccode - 10001 ] ++; + CompressDecompressActivityCount--; #endif /* #if TESTING_COMPRESSION */ - if (CompressScreen) - NWALGO_DBG_PRINTF((CompressScreen,MSGNot("* %-12s %10ld %10ld %10ld %10ld\n"), - &ucp->DosName[1], header->CompressedFileLength, - header->OriginalFileLength, ucp->Volume, ccode )); + if (CompressScreen) + NWALGO_DBG_PRINTF((CompressScreen,MSGNot("* %-12s %10ld %10ld %10ld %10ld\n"), + &ucp->DosName[1], header->CompressedFileLength, + header->OriginalFileLength, ucp->Volume, ccode )); /* #endif */ - CD_FREE( ucp ); + CD_FREE( ucp ); - return(ccode); + return(ccode); } /****************************************************************************/ /****************************************************************************/ + diff --git a/src/nwnss/comn/compression/cduncomp.h b/src/nwnss/comn/compression/cduncomp.h new file mode 100644 index 0000000..f0a42b0 --- /dev/null +++ b/src/nwnss/comn/compression/cduncomp.h @@ -0,0 +1,154 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996-1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Netware file compression algorithm ported to NSS + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |--------------------------------------------------------------------------- + | Module Description: + | + +-------------------------------------------------------------------------*/ +#ifndef __CDUNCOMP_H__ +#define __CDUNCOMP_H__ + +#define UNCOMPRESS_READ_CACHE_BUFFER_RANGE 1 +#define UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE 3 + +#define UNCOMPRESS_MAX_LENGTH_VALUE 0xFE + +#define UNCOMPRESS_ERROR_OUT_OF_RAM 10001 +#define UNCOMPRESS_ERROR_READ_ZERO_BYTES 10002 +#define UNCOMPRESS_ERROR_READ_BEYOND_EOF 10003 +#define UNCOMPRESS_ERROR_ABORTED 10004 +#define UNCOMPRESS_ERROR_INVALID_DATA_COUNT 10005 /* tree count */ +#define UNCOMPRESS_ERROR_INVALID_LENGTH_COUNT 10006 /* tree count */ +#define UNCOMPRESS_ERROR_INVALID_OFFSET_COUNT 10007 /* tree count */ +#define UNCOMPRESS_ERROR_HOLE_COUNT_MISMATCH 10008 +#define UNCOMPRESS_ERROR_UNKNOWN_VERSION 10009 +#define UNCOMPRESS_ERROR_FILE_TOO_SMALL 10010 +#define UNCOMPRESS_ERROR_TREE_TOO_BIG 10011 +#define UNCOMPRESS_ERROR_INVALID_HOLES 10012 +#define UNCOMPRESS_ERROR_INVALID_OFFSET 10013 +#define UNCOMPRESS_ERROR_INVALID_LENGTH 10014 +#define UNCOMPRESS_ERROR_WRITE_BEYOND_EOF 10015 +#define UNCOMPRESS_ERROR_INVALID_HEADER 10016 +#define UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE 10017 +#define UNCOMPRESS_ERROR_TRY_AGAIN 10018 /* also defined in FILER2.C */ +#define UNCOMPRESS_ERROR_TRY_AGAIN_FOREVER 10019 /* also defined in FILER2.C */ + +/*#define UNCOMPRESS_ERROR_COUNT 15 DEFINED in CONFIG.H */ + +#define UNCOMPRESS_DOS_NAME_SIZE 16 + +typedef struct decompressHoleMark_s { + + struct decompressHoleMark_s * next; + LONG offset; + LONG size; + +} decompressHoleMark_t, *decompressHoleMark_tp, **decompressHoleMark_tpp; + +typedef struct uncompressNode_s { + + struct uncompressNode_s *left; + struct uncompressNode_s *right; + LONG value; /* Byte value */ + +} uncompressNode_t, *uncompressNode_tp, * *uncompressNode_tpp; + +typedef struct uncompressData_s { + + LONG BitBufferIndex; + LONG BitBuffer; + LONG *BitMapCurrentPointer; + LONG *BitMapCurrentEnd; + + IoHandle_t WriteHandle; + LONG WriteFileSize; + BYTE *WriteCurrentPointer; + BYTE *WriteCurrentBufferBegin; + + BYTE *WriteCurrentBufferEnd; + LONG BytesInWriteCacheSoFar; + LONG WriteCacheBufferCount; + LONG WriteCacheNextBlockToGet; + + BYTE *WriteCachePointers [ UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE ]; + BYTE *WriteCacheBufferEnd [ UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE ]; + LONG WriteCacheHandle [ UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE ]; + LONG WriteCacheBlockNumber[ UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE ]; + + uncompressNode_tp DataTree; + uncompressNode_tp OffsetTree; + uncompressNode_tp LengthTree; + readCache_tp ReadCache; + + compressFileHeader_tp Header; + LONG ThreadExitNow; + decompressHoleMark_tp HoleListHead; + BYTE * WriteEOFPointer; + + BYTE * WritePreviousBufferEnd; + LONG WritePreviousBufferIndex; + LONG CompressedFileSize; + + BYTE DosName[ UNCOMPRESS_DOS_NAME_SIZE ]; + + LONG Volume; + + DecompressStatusNode_t decompressStatus; + + LONG beginHighTickCount; + +} uncompressData_t, *uncompressData_tp, * *uncompressData_tpp; + +#if 0 +typedef struct decompressWorkToDo_s { + + struct WorkToDoStructure DWTD; + uncompressData_tp ucp; + +} decompressWorkToDo_t, *decompressWorkToDo_tp, **decompressWorkToDo_tpp; +#endif + + +LONG +CCDStartDecompress( + IoHandle_t inHandle, + IoHandle_t outHandle, + ADDR *decompressHandle, + BYTE *dosName, + LONG volume, + LONG directoryNumber); + +#endif + +/****************************************************************************/ +/****************************************************************************/ + diff --git a/src/nwnss/comn/compression/cduncompa.c b/src/nwnss/comn/compression/cduncompa.c index c74e1f1..8aa4e63 100644 --- a/src/nwnss/comn/compression/cduncompa.c +++ b/src/nwnss/comn/compression/cduncompa.c @@ -41,12 +41,12 @@ #define READ_BIT(ud, bit) \ ud->BitBufferIndex--; \ if (!ud->BitBufferIndex) { \ - if (ud->BitMapCurrentPointer == ud->BitMapCurrentEnd) \ - if ((ccode=CCDDecompressFillBitBuffer(ud))!=0) \ - return(ccode); \ - ud->BitBuffer = *ud->BitMapCurrentPointer; \ - ud->BitMapCurrentPointer++; \ - ud->BitBufferIndex = 32; \ + if (ud->BitMapCurrentPointer == ud->BitMapCurrentEnd) \ + if ((ccode=CCDDecompressFillBitBuffer(ud))!=0) \ + return(ccode); \ + ud->BitBuffer = *ud->BitMapCurrentPointer; \ + ud->BitMapCurrentPointer++; \ + ud->BitBufferIndex = 32; \ } \ bit = (ud->BitBuffer & 0x1) ? 1 : 0; \ ud->BitBuffer >>=1; @@ -54,19 +54,19 @@ #define READ_BITS( ud, bits, len ) \ bits = 0; \ for(i=0; iBitBufferIndex--; \ if (!ud->BitBufferIndex) { \ - if (ud->BitMapCurrentPointer == ud->BitMapCurrentEnd) \ - if ((ccode=CCDDecompressFillBitBufferHiLo(ud))!=0) \ - return(ccode); \ - ud->BitBuffer = SWAP_LONG(*ud->BitMapCurrentPointer); \ - ud->BitMapCurrentPointer++; \ - ud->BitBufferIndex = 32; \ + if (ud->BitMapCurrentPointer == ud->BitMapCurrentEnd) \ + if ((ccode=CCDDecompressFillBitBufferHiLo(ud))!=0) \ + return(ccode); \ + ud->BitBuffer = SWAP_LONG(*ud->BitMapCurrentPointer); \ + ud->BitMapCurrentPointer++; \ + ud->BitBufferIndex = 32; \ } \ bit = (ud->BitBuffer & 0x1) ? 1 : 0; \ ud->BitBuffer >>=1; @@ -74,12 +74,12 @@ #define READ_BITS_HILO( ud, bits, len ) \ bits = 0; \ for(i=0; i 0) && (size > mydiff)) { - NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "memmove src=0x%p, dest=0x%p, diff=0x%lx, size=0x%lx\n", + NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "memmove src=0x%p, dest=0x%p, diff=0x%lx, size=0x%lx\n", src, dest, mydiff, size)); } - for (i = 0; i < size; i++) + for (i = 0; i < size; i++) dest[i] = src[i]; } @@ -121,76 +121,76 @@ CCDDecompressGetWriteBuffer( uncompressData_tp ud ) if (ud->WriteCacheBufferCount < (UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE-1)) { - ud->WriteCacheBufferCount++; - ud->BytesInWriteCacheSoFar += CD_SYSTEM_CACHE_BUFFER_SIZE; - } + ud->WriteCacheBufferCount++; + ud->BytesInWriteCacheSoFar += CD_SYSTEM_CACHE_BUFFER_SIZE; + } else { - LONG handle; - handle = ud->WriteCacheHandle[0]; + LONG handle; + handle = ud->WriteCacheHandle[0]; - /* mark this block since as tried once to return */ - ud->WriteCacheHandle[0] = 0; + /* mark this block since as tried once to return */ + ud->WriteCacheHandle[0] = 0; - if((ccode=NSSCCDReturnWriteCacheBlock( handle, - ud->WriteHandle, CD_SYSTEM_SECTORS_PER_BUFFER, (LONG)0)) !=0) - return(ccode); + if((ccode=NSSCCDReturnWriteCacheBlock( handle, + ud->WriteHandle, CD_SYSTEM_SECTORS_PER_BUFFER, (LONG)0)) !=0) + return(ccode); - ud->WriteCachePointers[0] = ud->WriteCachePointers[1]; - ud->WriteCacheBlockNumber[0] = ud->WriteCacheBlockNumber[1]; - ud->WriteCacheHandle[0] = ud->WriteCacheHandle[1]; - ud->WriteCacheBufferEnd[0] = ud->WriteCacheBufferEnd[1]; + ud->WriteCachePointers[0] = ud->WriteCachePointers[1]; + ud->WriteCacheBlockNumber[0] = ud->WriteCacheBlockNumber[1]; + ud->WriteCacheHandle[0] = ud->WriteCacheHandle[1]; + ud->WriteCacheBufferEnd[0] = ud->WriteCacheBufferEnd[1]; - ud->WriteCachePointers[1] = ud->WriteCachePointers[2]; - ud->WriteCacheBlockNumber[1] = ud->WriteCacheBlockNumber[2]; - ud->WriteCacheHandle[1] = ud->WriteCacheHandle[2]; - ud->WriteCacheBufferEnd[1] = ud->WriteCacheBufferEnd[2]; + ud->WriteCachePointers[1] = ud->WriteCachePointers[2]; + ud->WriteCacheBlockNumber[1] = ud->WriteCacheBlockNumber[2]; + ud->WriteCacheHandle[1] = ud->WriteCacheHandle[2]; + ud->WriteCacheBufferEnd[1] = ud->WriteCacheBufferEnd[2]; } if (ud->HoleListHead) { - while (ud->HoleListHead && + while (ud->HoleListHead && ud->HoleListHead->offset == (ud->WriteCacheNextBlockToGet << CD_SYSTEM_CACHE_BUFFER_SHIFT )) - { - ud->WriteCacheNextBlockToGet += (ud->HoleListHead->size >> CD_SYSTEM_CACHE_BUFFER_SHIFT ); - toFree = ud->HoleListHead; - ud->HoleListHead = ud->HoleListHead->next; - CD_FREE(toFree); - } + { + ud->WriteCacheNextBlockToGet += (ud->HoleListHead->size >> CD_SYSTEM_CACHE_BUFFER_SHIFT ); + toFree = ud->HoleListHead; + ud->HoleListHead = ud->HoleListHead->next; + CD_FREE(toFree); + } /* This file can't be ended with a hole because ud->WriteFileSize is not 0 */ - CD_ASSERT ((ud->WriteCacheNextBlockToGet != + CD_ASSERT ((ud->WriteCacheNextBlockToGet != ud->decompressStatus.status.totalBlocksToDecompress)); } NSSCCDUpdateDecompressPosition( ud->WriteHandle, - ud->WriteCacheNextBlockToGet << CD_SYSTEM_CACHE_BUFFER_SHIFT); + ud->WriteCacheNextBlockToGet << CD_SYSTEM_CACHE_BUFFER_SHIFT); - if ((ccode=NSSCCDGetWriteCacheBlock(ud->WriteHandle, - ud->WriteCacheNextBlockToGet, (LONG)0, - &ud->WriteCachePointers[ ud->WriteCacheBufferCount ], - &ud->WriteCacheHandle[ ud->WriteCacheBufferCount ]))!=0) - return(ccode); + if ((ccode=NSSCCDGetWriteCacheBlock(ud->WriteHandle, + ud->WriteCacheNextBlockToGet, (LONG)0, + &ud->WriteCachePointers[ ud->WriteCacheBufferCount ], + &ud->WriteCacheHandle[ ud->WriteCacheBufferCount ]))!=0) + return(ccode); - ud->WriteCacheBlockNumber[ ud->WriteCacheBufferCount ] = - ud->WriteCacheNextBlockToGet; + ud->WriteCacheBlockNumber[ ud->WriteCacheBufferCount ] = + ud->WriteCacheNextBlockToGet; ud->WriteCacheNextBlockToGet++; - ud->WriteCacheBufferEnd[ ud->WriteCacheBufferCount ] = - ud->WriteCachePointers[ ud->WriteCacheBufferCount ] - + CD_SYSTEM_CACHE_BUFFER_SIZE; - - ud->WriteCurrentBufferEnd = - ud->WriteCacheBufferEnd[ ud->WriteCacheBufferCount ]; + ud->WriteCacheBufferEnd[ ud->WriteCacheBufferCount ] = + ud->WriteCachePointers[ ud->WriteCacheBufferCount ] + + CD_SYSTEM_CACHE_BUFFER_SIZE; + + ud->WriteCurrentBufferEnd = + ud->WriteCacheBufferEnd[ ud->WriteCacheBufferCount ]; ud->WriteCurrentBufferBegin = ud->WriteCurrentPointer = - ud->WriteCachePointers[ ud->WriteCacheBufferCount ]; + ud->WriteCachePointers[ ud->WriteCacheBufferCount ]; ud->WriteFileSize -= CD_SYSTEM_CACHE_BUFFER_SIZE; if (ud->WriteFileSize <= CD_SYSTEM_CACHE_BUFFER_SIZE) - ud->WriteEOFPointer = ud->WriteCurrentPointer + ud->WriteFileSize; + ud->WriteEOFPointer = ud->WriteCurrentPointer + ud->WriteFileSize; if (ud->ThreadExitNow) return(UNCOMPRESS_ERROR_ABORTED); @@ -210,32 +210,32 @@ CCDDecompressFillBitBuffer( uncompressData_tp ud ) if ((ccode = NSSCCDFreeReadAheadBuffer( ud->ReadCache )) != 0) return(ccode); - if ((ccode = NSSCCDGetReadAheadBuffer( ud->ReadCache, - (BYTE **)&ud->BitMapCurrentPointer, &validBytes, &holeFlag )) != 0) - return(ccode); + if ((ccode = NSSCCDGetReadAheadBuffer( ud->ReadCache, + (BYTE **)&ud->BitMapCurrentPointer, &validBytes, &holeFlag )) != 0) + return(ccode); if (holeFlag) return( UNCOMPRESS_ERROR_INVALID_HOLES ); if (ud->CompressedFileSize < CD_SYSTEM_CACHE_BUFFER_SIZE) { - if (CCDCheckSumBlock( ud->BitMapCurrentPointer, - ud->CompressedFileSize >> 2 )) - return( UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); + if (CCDCheckSumBlock( ud->BitMapCurrentPointer, + ud->CompressedFileSize >> 2 )) + return( UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); - ud->CompressedFileSize = 0; + ud->CompressedFileSize = 0; - ud->BitMapCurrentEnd = ud->BitMapCurrentPointer + - (ud->CompressedFileSize >> 2) - 1; + ud->BitMapCurrentEnd = ud->BitMapCurrentPointer + + (ud->CompressedFileSize >> 2) - 1; } else { - if ( CCDCheckSumBlock4K( ud->BitMapCurrentPointer ) ) - return( UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); + if ( CCDCheckSumBlock4K( ud->BitMapCurrentPointer ) ) + return( UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); - ud->CompressedFileSize -= CD_SYSTEM_CACHE_BUFFER_SIZE; + ud->CompressedFileSize -= CD_SYSTEM_CACHE_BUFFER_SIZE; - ud->BitMapCurrentEnd = ud->BitMapCurrentPointer + - CD_SYSTEM_CACHE_BUFFER_LONGS - 1; + ud->BitMapCurrentEnd = ud->BitMapCurrentPointer + + CD_SYSTEM_CACHE_BUFFER_LONGS - 1; } return((LONG)0); @@ -255,32 +255,32 @@ CCDDecompressFillBitBufferHiLo( uncompressData_tp ud ) if ((ccode = NSSCCDFreeReadAheadBuffer( ud->ReadCache )) != 0) return(ccode); - if ((ccode = NSSCCDGetReadAheadBuffer( ud->ReadCache, - (BYTE **)&ud->BitMapCurrentPointer, &validBytes, &holeFlag )) != 0) - return(ccode); + if ((ccode = NSSCCDGetReadAheadBuffer( ud->ReadCache, + (BYTE **)&ud->BitMapCurrentPointer, &validBytes, &holeFlag )) != 0) + return(ccode); if (holeFlag) return( UNCOMPRESS_ERROR_INVALID_HOLES ); if (ud->CompressedFileSize < CD_SYSTEM_CACHE_BUFFER_SIZE) { - if (CCDCheckSumBlock( ud->BitMapCurrentPointer, - ud->CompressedFileSize >> 2 )) - return( UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); + if (CCDCheckSumBlock( ud->BitMapCurrentPointer, + ud->CompressedFileSize >> 2 )) + return( UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); - ud->CompressedFileSize = 0; + ud->CompressedFileSize = 0; - ud->BitMapCurrentEnd = ud->BitMapCurrentPointer + - (ud->CompressedFileSize >> 2) - 1; + ud->BitMapCurrentEnd = ud->BitMapCurrentPointer + + (ud->CompressedFileSize >> 2) - 1; } else { - if ( CCDCheckSumBlock4K( ud->BitMapCurrentPointer ) ) - return( UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); + if ( CCDCheckSumBlock4K( ud->BitMapCurrentPointer ) ) + return( UNCOMPRESS_ERROR_CORRUPT_COMPRESSED_FILE ); - ud->CompressedFileSize -= CD_SYSTEM_CACHE_BUFFER_SIZE; + ud->CompressedFileSize -= CD_SYSTEM_CACHE_BUFFER_SIZE; - ud->BitMapCurrentEnd = ud->BitMapCurrentPointer + - CD_SYSTEM_CACHE_BUFFER_LONGS - 1; + ud->BitMapCurrentEnd = ud->BitMapCurrentPointer + + CD_SYSTEM_CACHE_BUFFER_LONGS - 1; } return((LONG)0); @@ -290,10 +290,10 @@ CCDDecompressFillBitBufferHiLo( uncompressData_tp ud ) /* ******************************************************************** */ LONG -CDReadShannonTreeHiLo( - uncompressData_tp ud, - uncompressNode_tpp parentPtr, - uncompressNode_tpp allocPool, +CDReadShannonTreeHiLo( + uncompressData_tp ud, + uncompressNode_tpp parentPtr, + uncompressNode_tpp allocPool, LONG *count ) { LONG ccode; @@ -310,19 +310,19 @@ CDReadShannonTreeHiLo( READ_BIT_HILO( ud, bit ) - if (bit) + if (bit) { - READ_BITS_HILO( ud, prevChild->value, 8 ) - return((LONG)0); + READ_BITS_HILO( ud, prevChild->value, 8 ) + return((LONG)0); } - if ((ccode = CDReadShannonTreeHiLo( ud, &(prevChild->left), allocPool, - count)) != 0) - return(ccode); + if ((ccode = CDReadShannonTreeHiLo( ud, &(prevChild->left), allocPool, + count)) != 0) + return(ccode); - if ((ccode = CDReadShannonTreeHiLo( ud, &(prevChild->right), allocPool, - count)) != 0) - return(ccode); + if ((ccode = CDReadShannonTreeHiLo( ud, &(prevChild->right), allocPool, + count)) != 0) + return(ccode); return((LONG)0); } @@ -330,7 +330,7 @@ CDReadShannonTreeHiLo( /* ******************************************************************** */ LONG -CCDReadShannonTreeHiLo( uncompressData_tp ud, uncompressNode_tpp tree, +CCDReadShannonTreeHiLo( uncompressData_tp ud, uncompressNode_tpp tree, LONG *nodeCount) { uncompressNode_tp hold; @@ -339,7 +339,7 @@ CCDReadShannonTreeHiLo( uncompressData_tp ud, uncompressNode_tpp tree, hold = *tree; if ((ccode=CDReadShannonTreeHiLo( ud, tree, tree, nodeCount)) != 0) - return( ccode ); + return( ccode ); *tree = hold; @@ -357,119 +357,119 @@ CCDDecompressFileHiLo( uncompressData_tp ud ) while ( ud->WriteCurrentPointer != ud->WriteEOFPointer ) { - READ_BIT_HILO( ud, bit ); + READ_BIT_HILO( ud, bit ); - if (bit) - { - tree = ud->DataTree; + if (bit) + { + tree = ud->DataTree; - while( tree->left ) - { - READ_BIT_HILO( ud, bit ); - tree = bit ? tree->right : tree->left; - } + while( tree->left ) + { + READ_BIT_HILO( ud, bit ); + tree = bit ? tree->right : tree->left; + } - if (ud->WriteCurrentPointer == ud->WriteCurrentBufferEnd) - { - if ((ccode = CCDDecompressGetWriteBuffer( ud )) != 0) return(ccode); - } + if (ud->WriteCurrentPointer == ud->WriteCurrentBufferEnd) + { + if ((ccode = CCDDecompressGetWriteBuffer( ud )) != 0) return(ccode); + } - *ud->WriteCurrentPointer = (BYTE)tree->value; + *ud->WriteCurrentPointer = (BYTE)tree->value; - ud->WriteCurrentPointer ++; + ud->WriteCurrentPointer ++; - continue; - } + continue; + } - tree = ud ->LengthTree; + tree = ud ->LengthTree; - while( tree->left ) - { - READ_BIT_HILO( ud, bit ); - tree = bit ? tree->right : tree->left; - } + while( tree->left ) + { + READ_BIT_HILO( ud, bit ); + tree = bit ? tree->right : tree->left; + } - if (tree->value == 0xFE) - { - READ_BITS_HILO( ud, length, 13 ); - } - else - { - length = tree->value; - } + if (tree->value == 0xFE) + { + READ_BITS_HILO( ud, length, 13 ); + } + else + { + length = tree->value; + } - READ_BITS_HILO(ud, offset, 5 ); + READ_BITS_HILO(ud, offset, 5 ); - tree = ud->OffsetTree; + tree = ud->OffsetTree; - while( tree->left ) - { - READ_BIT_HILO( ud, bit ); - tree = bit ? tree->right : tree->left; - } + while( tree->left ) + { + READ_BIT_HILO( ud, bit ); + tree = bit ? tree->right : tree->left; + } - offset += ( tree->value << 5 ); + offset += ( tree->value << 5 ); - if (((ud->WriteCurrentPointer - offset) < ud->WriteCurrentBufferBegin) - || ((ud->WriteCurrentPointer + length) >= ud->WriteCurrentBufferEnd)) - { - byteIndex = ((ud->WriteCurrentPointer - ud->WriteCurrentBufferBegin) - + ud->BytesInWriteCacheSoFar) - offset; + if (((ud->WriteCurrentPointer - offset) < ud->WriteCurrentBufferBegin) + || ((ud->WriteCurrentPointer + length) >= ud->WriteCurrentBufferEnd)) + { + byteIndex = ((ud->WriteCurrentPointer - ud->WriteCurrentBufferBegin) + + ud->BytesInWriteCacheSoFar) - offset; - if (byteIndex < 0) return(UNCOMPRESS_ERROR_INVALID_OFFSET); + if (byteIndex < 0) return(UNCOMPRESS_ERROR_INVALID_OFFSET); - ud->WritePreviousBufferIndex = byteIndex >> CD_SYSTEM_CACHE_BUFFER_SHIFT; + ud->WritePreviousBufferIndex = byteIndex >> CD_SYSTEM_CACHE_BUFFER_SHIFT; - if (length > (CD_SYSTEM_CACHE_BUFFER_SIZE * 2)) - return( UNCOMPRESS_ERROR_INVALID_LENGTH ); + if (length > (CD_SYSTEM_CACHE_BUFFER_SIZE * 2)) + return( UNCOMPRESS_ERROR_INVALID_LENGTH ); - previousStringPointer = ud->WriteCachePointers[ ud->WritePreviousBufferIndex ] - + (byteIndex & CD_SYSTEM_CACHE_BUFFER_MASK) ; + previousStringPointer = ud->WriteCachePointers[ ud->WritePreviousBufferIndex ] + + (byteIndex & CD_SYSTEM_CACHE_BUFFER_MASK) ; - ud->WritePreviousBufferEnd = ud->WriteCacheBufferEnd[ ud->WritePreviousBufferIndex ]; + ud->WritePreviousBufferEnd = ud->WriteCacheBufferEnd[ ud->WritePreviousBufferIndex ]; - toCopy = length; + toCopy = length; - while (length) - { - if (ud->WriteCurrentPointer == ud->WriteCurrentBufferEnd) - { - if (ud->WriteCacheBufferCount == (UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE-1)) - ud->WritePreviousBufferIndex--; + while (length) + { + if (ud->WriteCurrentPointer == ud->WriteCurrentBufferEnd) + { + if (ud->WriteCacheBufferCount == (UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE-1)) + ud->WritePreviousBufferIndex--; - if ((ccode = CCDDecompressGetWriteBuffer( ud )) != 0) - return( ccode ); - } + if ((ccode = CCDDecompressGetWriteBuffer( ud )) != 0) + return( ccode ); + } - if (previousStringPointer == ud->WritePreviousBufferEnd) - { - ud->WritePreviousBufferIndex ++; - ud->WritePreviousBufferEnd = ud->WriteCacheBufferEnd[ ud->WritePreviousBufferIndex ]; - previousStringPointer = ud->WriteCachePointers[ ud->WritePreviousBufferIndex ]; - } + if (previousStringPointer == ud->WritePreviousBufferEnd) + { + ud->WritePreviousBufferIndex ++; + ud->WritePreviousBufferEnd = ud->WriteCacheBufferEnd[ ud->WritePreviousBufferIndex ]; + previousStringPointer = ud->WriteCachePointers[ ud->WritePreviousBufferIndex ]; + } - if (toCopy > (ud->WritePreviousBufferEnd - previousStringPointer )) - toCopy = ud->WritePreviousBufferEnd - previousStringPointer ; + if (toCopy > (ud->WritePreviousBufferEnd - previousStringPointer )) + toCopy = ud->WritePreviousBufferEnd - previousStringPointer ; - if (toCopy > (ud->WriteCurrentBufferEnd - ud->WriteCurrentPointer)) - toCopy = ud->WriteCurrentBufferEnd - ud->WriteCurrentPointer; + if (toCopy > (ud->WriteCurrentBufferEnd - ud->WriteCurrentPointer)) + toCopy = ud->WriteCurrentBufferEnd - ud->WriteCurrentPointer; - memmovePropagate(previousStringPointer, ud->WriteCurrentPointer, toCopy); + memmovePropagate(previousStringPointer, ud->WriteCurrentPointer, toCopy); - previousStringPointer += toCopy; - ud->WriteCurrentPointer += toCopy; + previousStringPointer += toCopy; + ud->WriteCurrentPointer += toCopy; + + length -= toCopy; + toCopy = length; + } - length -= toCopy; - toCopy = length; - } + continue; + } - continue; - } + memmovePropagate(ud->WriteCurrentPointer - offset, ud->WriteCurrentPointer, length); - memmovePropagate(ud->WriteCurrentPointer - offset, ud->WriteCurrentPointer, length); - - ud->WriteCurrentPointer += length; + ud->WriteCurrentPointer += length; } @@ -479,10 +479,10 @@ CCDDecompressFileHiLo( uncompressData_tp ud ) /* ******************************************************************** */ LONG -CDReadShannonTree( - uncompressData_tp ud, - uncompressNode_tpp parentPtr, - uncompressNode_tpp allocPool, +CDReadShannonTree( + uncompressData_tp ud, + uncompressNode_tpp parentPtr, + uncompressNode_tpp allocPool, LONG *count ) { LONG ccode; @@ -499,24 +499,24 @@ CDReadShannonTree( READ_BIT( ud, bit ) - if (bit) + if (bit) { - READ_BITS( ud, prevChild->value, 8 ) - return((LONG)0); + READ_BITS( ud, prevChild->value, 8 ) + return((LONG)0); } if ((ccode = CDReadShannonTree( ud, &(prevChild->left), allocPool, count)) != 0) - return(ccode); + return(ccode); if ((ccode = CDReadShannonTree( ud, &(prevChild->right), allocPool, count)) != 0) - return(ccode); + return(ccode); return((LONG)0); } /* ******************************************************************** */ LONG -CCDReadShannonTree( uncompressData_tp ud, uncompressNode_tpp tree, +CCDReadShannonTree( uncompressData_tp ud, uncompressNode_tpp tree, LONG *nodeCount) { uncompressNode_tp hold; @@ -525,7 +525,7 @@ CCDReadShannonTree( uncompressData_tp ud, uncompressNode_tpp tree, hold = *tree; if ((ccode=CDReadShannonTree( ud, tree, tree, nodeCount)) != 0) - return(ccode ); + return(ccode ); *tree = hold; @@ -546,117 +546,117 @@ CCDDecompressFile( uncompressData_tp ud ) while ( ud->WriteCurrentPointer != ud->WriteEOFPointer ) { - READ_BIT( ud, bit ); + READ_BIT( ud, bit ); - if (bit) - { - tree = ud->DataTree; + if (bit) + { + tree = ud->DataTree; - while( tree->left ) - { - READ_BIT( ud, bit ); - tree = bit ? tree->right : tree->left; - } + while( tree->left ) + { + READ_BIT( ud, bit ); + tree = bit ? tree->right : tree->left; + } - if (ud->WriteCurrentPointer == ud->WriteCurrentBufferEnd) - { - if ((ccode = CCDDecompressGetWriteBuffer( ud )) != 0) return(ccode); - } + if (ud->WriteCurrentPointer == ud->WriteCurrentBufferEnd) + { + if ((ccode = CCDDecompressGetWriteBuffer( ud )) != 0) return(ccode); + } - *ud->WriteCurrentPointer = (BYTE)tree->value; + *ud->WriteCurrentPointer = (BYTE)tree->value; - ud->WriteCurrentPointer ++; + ud->WriteCurrentPointer ++; - continue; - } + continue; + } - tree = ud ->LengthTree; + tree = ud ->LengthTree; - while( tree->left ) - { - READ_BIT( ud, bit ); - tree = bit ? tree->right : tree->left; - } + while( tree->left ) + { + READ_BIT( ud, bit ); + tree = bit ? tree->right : tree->left; + } - if (tree->value == 0xFE) - { - /* length cannot exceed 8196 because only 13 bits */ - READ_BITS( ud, length, 13 ); - } - else - { - length = tree->value; - } + if (tree->value == 0xFE) + { + /* length cannot exceed 8196 because only 13 bits */ + READ_BITS( ud, length, 13 ); + } + else + { + length = tree->value; + } - READ_BITS(ud, offset, 5 ); + READ_BITS(ud, offset, 5 ); - tree = ud->OffsetTree; + tree = ud->OffsetTree; - while( tree->left ) - { - READ_BIT( ud, bit ); - tree = bit ? tree->right : tree->left; - } + while( tree->left ) + { + READ_BIT( ud, bit ); + tree = bit ? tree->right : tree->left; + } - offset += ( tree->value << 5 ); + offset += ( tree->value << 5 ); - if (((ud->WriteCurrentPointer - offset) < ud->WriteCurrentBufferBegin) - || ((ud->WriteCurrentPointer + length) >= ud->WriteCurrentBufferEnd)) - { - byteIndex = ((ud->WriteCurrentPointer - ud->WriteCurrentBufferBegin) - + ud->BytesInWriteCacheSoFar) - offset; + if (((ud->WriteCurrentPointer - offset) < ud->WriteCurrentBufferBegin) + || ((ud->WriteCurrentPointer + length) >= ud->WriteCurrentBufferEnd)) + { + byteIndex = ((ud->WriteCurrentPointer - ud->WriteCurrentBufferBegin) + + ud->BytesInWriteCacheSoFar) - offset; - if (byteIndex < 0) return( UNCOMPRESS_ERROR_INVALID_OFFSET ); + if (byteIndex < 0) return( UNCOMPRESS_ERROR_INVALID_OFFSET ); - ud->WritePreviousBufferIndex = byteIndex >> CD_SYSTEM_CACHE_BUFFER_SHIFT; + ud->WritePreviousBufferIndex = byteIndex >> CD_SYSTEM_CACHE_BUFFER_SHIFT; - previousStringPointer = ud->WriteCachePointers[ ud->WritePreviousBufferIndex ] - + (byteIndex & CD_SYSTEM_CACHE_BUFFER_MASK) ; + previousStringPointer = ud->WriteCachePointers[ ud->WritePreviousBufferIndex ] + + (byteIndex & CD_SYSTEM_CACHE_BUFFER_MASK) ; - ud->WritePreviousBufferEnd = ud->WriteCacheBufferEnd[ ud->WritePreviousBufferIndex ]; + ud->WritePreviousBufferEnd = ud->WriteCacheBufferEnd[ ud->WritePreviousBufferIndex ]; - toCopy = length; + toCopy = length; - while (length) - { - if (ud->WriteCurrentPointer == ud->WriteCurrentBufferEnd) - { - if (ud->WriteCacheBufferCount == (UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE-1)) - ud->WritePreviousBufferIndex--; + while (length) + { + if (ud->WriteCurrentPointer == ud->WriteCurrentBufferEnd) + { + if (ud->WriteCacheBufferCount == (UNCOMPRESS_WRITE_CACHE_BUFFER_RANGE-1)) + ud->WritePreviousBufferIndex--; - if ((ccode = CCDDecompressGetWriteBuffer( ud )) != 0) - return( ccode ); - } + if ((ccode = CCDDecompressGetWriteBuffer( ud )) != 0) + return( ccode ); + } - if (previousStringPointer == ud->WritePreviousBufferEnd) - { - ud->WritePreviousBufferIndex ++; - previousStringPointer = ud->WriteCachePointers[ ud->WritePreviousBufferIndex ]; - ud->WritePreviousBufferEnd = ud->WriteCacheBufferEnd[ ud->WritePreviousBufferIndex ]; - } + if (previousStringPointer == ud->WritePreviousBufferEnd) + { + ud->WritePreviousBufferIndex ++; + previousStringPointer = ud->WriteCachePointers[ ud->WritePreviousBufferIndex ]; + ud->WritePreviousBufferEnd = ud->WriteCacheBufferEnd[ ud->WritePreviousBufferIndex ]; + } - if (toCopy > (ud->WritePreviousBufferEnd - previousStringPointer )) - toCopy = ud->WritePreviousBufferEnd - previousStringPointer ; + if (toCopy > (ud->WritePreviousBufferEnd - previousStringPointer )) + toCopy = ud->WritePreviousBufferEnd - previousStringPointer ; - if (toCopy > (ud->WriteCurrentBufferEnd - ud->WriteCurrentPointer)) - toCopy = ud->WriteCurrentBufferEnd - ud->WriteCurrentPointer; + if (toCopy > (ud->WriteCurrentBufferEnd - ud->WriteCurrentPointer)) + toCopy = ud->WriteCurrentBufferEnd - ud->WriteCurrentPointer; memmovePropagate(previousStringPointer, ud->WriteCurrentPointer, toCopy); - previousStringPointer += toCopy; - ud->WriteCurrentPointer += toCopy; + previousStringPointer += toCopy; + ud->WriteCurrentPointer += toCopy; + + length -= toCopy; + toCopy = length; + } - length -= toCopy; - toCopy = length; - } + continue; + } - continue; - } + memmovePropagate( ud->WriteCurrentPointer - offset, ud->WriteCurrentPointer, length); - memmovePropagate( ud->WriteCurrentPointer - offset, ud->WriteCurrentPointer, length); - - ud->WriteCurrentPointer += length; + ud->WriteCurrentPointer += length; } return((LONG)0); diff --git a/src/nwnss/comn/compression/cmActivity.c b/src/nwnss/comn/compression/cmActivity.c index 9958f1c..372ca49 100644 --- a/src/nwnss/comn/compression/cmActivity.c +++ b/src/nwnss/comn/compression/cmActivity.c @@ -46,9 +46,9 @@ #include "cmControl.h" /* - * Called to indicate successful completion of a (de)compression activity. - */ -STATIC QUAD totalCompActivities = 0; + * Called to indicate successful completion of a (de)compression activity. + */ +STATIC QUAD totalCompActivities = 0; STATIC void CM_activityDone(CMActivity_s *activity) { RootBeast_s *uncompBeast = activity->decompStream.beast; @@ -59,8 +59,8 @@ STATIC void CM_activityDone(CMActivity_s *activity) NINT newCompState; NINT num; Xaction_s *localXaction = NULL; - - + + ASSERT_MPKNSS_LOCK(); XLATCH_BEAST(uncompBeast); @@ -73,7 +73,7 @@ STATIC void CM_activityDone(CMActivity_s *activity) newCompState = COMP_STATUS_COMPRESSED; if (activity->keepSrcChunk) newCompState |= COMP_STATUS_UNCOMPRESSED; - if (compInfo->p.chunkSize > 0) + if (compInfo->p.chunkSize > 0) { Buffer_s *cmbuf; QUAD compChunkOffset; @@ -84,14 +84,14 @@ STATIC void CM_activityDone(CMActivity_s *activity) goto cleanupAndExit; /* Set compressed chunk size in chunk header */ - cmbuf = CM_fetchFileBlk(&genMsg, compBeast, - compChunkOffset >> compBeast->blkSizeShift, + cmbuf = CM_fetchFileBlk(&genMsg, compBeast, + compChunkOffset >> compBeast->blkSizeShift, CACHE_UPDATE, 0); if (! cmbuf) goto cleanupAndExit; mapBufferPage(cmbuf); - chunkHdr = (CompChunkHdr_s *) + chunkHdr = (CompChunkHdr_s *) (cmbuf->pBuf.data + (compChunkOffset & ((1 << compBeast->blkSizeShift) - 1))); chunkHdr->compChunkSize = activity->compStream.beastSize; @@ -99,8 +99,8 @@ STATIC void CM_activityDone(CMActivity_s *activity) CACHE_DIRTY_RELEASE(cmbuf); (void) setCompChunkValidRange(&genMsg, - activity->compStream.beast, offset, - compInfo->p.chunkSize, + activity->compStream.beast, offset, + compInfo->p.chunkSize, activity->compStream.beastOffset, activity->compStream.beastSize); (void) setChunkCompStatus(&genMsg, activity->compStream.beast, @@ -108,7 +108,7 @@ STATIC void CM_activityDone(CMActivity_s *activity) UNXLATCH_BEAST(compBeast); BST_flush(compBeast); XLATCH_BEAST(compBeast); - if (! activity->keepSrcChunk) + if (! activity->keepSrcChunk) { /* * create a hole in the uncompBeast in the range @@ -120,19 +120,19 @@ STATIC void CM_activityDone(CMActivity_s *activity) */ } } - else + else { /* Set Compressed beast's new (logical) EOF, and flush compBeast */ - SET_DATASTREAM_SIZE(&genMsg, compBeast, - activity->compStream.beastOffset + + SET_DATASTREAM_SIZE(&genMsg, compBeast, + activity->compStream.beastOffset + activity->compStream.beastSize); COMN_MARK_BEAST_DIRTY(compBeast); - + UNXLATCH_BEAST(compBeast); BST_flush(compBeast); XLATCH_BEAST(compBeast); #if 0 - if (! activity->keepSrcChunk) + if (! activity->keepSrcChunk) { /* Discard uncompressed data */ /* @@ -142,11 +142,11 @@ STATIC void CM_activityDone(CMActivity_s *activity) * We should instead to a cacheTruncateMyCache followed by the * bstTruncate LSS op. But for the moment, don't do anything. */ - (void) TRUNCATE_BEAST(&genMsg, activity->decompStream.beast, + (void) TRUNCATE_BEAST(&genMsg, activity->decompStream.beast, activity->decompStream.beastOffset); } #endif - compInfo->p.status &= + compInfo->p.status &= ~(COMP_STATUS_UNCOMPRESSED|COMP_STATUS_COMPRESSED); compInfo->p.status |= newCompState; } @@ -154,48 +154,48 @@ STATIC void CM_activityDone(CMActivity_s *activity) /* update the percentage space saved */ { totalCompActivities++; - zASSERT(totalCompActivities >= 1); + zASSERT(totalCompActivities >= 1); if (totalCompActivities == 0) { totalCompActivities = 1; } num = activity->decompStream.beastSize - activity->compStream.beastSize; - + X_LATCH(&CM_curCompStatistics.latch); /* round the ratio */ - CM_curCompStatistics.percentSpaceSaved = - (100 * num + activity->decompStream.beastSize / 2)/activity->decompStream.beastSize; + CM_curCompStatistics.percentSpaceSaved = + (100 * num + activity->decompStream.beastSize / 2)/activity->decompStream.beastSize; if (!CM_curCompStatistics.averageCompRatio) { /* we don't store averageCompRatio persistently, let's * fake something if this is the first time */ - CM_curCompStatistics.averageCompRatio - = CM_curCompStatistics.percentSpaceSaved; + CM_curCompStatistics.averageCompRatio + = CM_curCompStatistics.percentSpaceSaved; } else - { + { /* round the ratio */ - num = CM_curCompStatistics.percentSpaceSaved + - CM_curCompStatistics.averageCompRatio * (totalCompActivities - 1); - CM_curCompStatistics.averageCompRatio = + num = CM_curCompStatistics.percentSpaceSaved + + CM_curCompStatistics.averageCompRatio * (totalCompActivities - 1); + CM_curCompStatistics.averageCompRatio = (num + totalCompActivities / 2)/totalCompActivities; - } + } displayCompRatio(); UNX_LATCH(&CM_curCompStatistics.latch); } /* Update precious counts and cleanup the datastream if necessary. */ localXaction = COMN_BeginXLocal(uncompBeast); - + ++ compInfo->p.Cprecious; - if (! activity->keepSrcChunk) + if (! activity->keepSrcChunk) { - if (-- compInfo->p.UCprecious == 0) + if (-- compInfo->p.UCprecious == 0) { /* remove activity from uncompBeast->CM_activities list. */ DQ_RMV(activity, beastActivitiesChain); @@ -208,7 +208,7 @@ STATIC void CM_activityDone(CMActivity_s *activity) */ setBeastCompAttr(uncompBeast, zFA_DATA_STREAM_IS_COMPRESSED, localXaction, FALSE); setVolCompStats(uncompBeast, compBeast, localXaction, TRUE); - + if (compCleanup(&genMsg, uncompBeast, compBeast, FALSE, &localXaction) != zOK) { /* roll back compression related stats and attributes */ @@ -216,17 +216,17 @@ STATIC void CM_activityDone(CMActivity_s *activity) { localXaction = COMN_BeginXLocal(uncompBeast); } - + compInfo->p.UCprecious++; compInfo->p.status |= COMP_STATUS_UNCOMPRESSED; // compInfo->p.Cprecious--; setBeastCompAttr(uncompBeast, 0, localXaction, TRUE); setVolCompStats(uncompBeast, compBeast, localXaction, FALSE); - updateBeastPurgeableBlksCnt(&genMsg, + updateBeastPurgeableBlksCnt(&genMsg, (NamedBeast_s *)uncompBeast, compBeast, TRUE, localXaction); - } - + } + goto releaseBeastsAndExit; } @@ -237,17 +237,17 @@ STATIC void CM_activityDone(CMActivity_s *activity) newCompState = COMP_STATUS_UNCOMPRESSED; if (activity->keepSrcChunk) newCompState |= COMP_STATUS_COMPRESSED; - if (compInfo->p.chunkSize > 0) + if (compInfo->p.chunkSize > 0) { /* reset compStream.beastOffset, beastSize to include the entire * chunk (including chunk hdr) i.e., * hdrSize = sizeof(CompChunkHdr_s); * compStream.beastOffset -= hdrSize; * compStream.beastSize += hdrSize; - * - * flush to disk, all uncompBeast blocks in the range + * + * flush to disk, all uncompBeast blocks in the range * . - * + * * if uncompBeast is not marked for "Immediate Compression", * { * Throw away the compressed version of the chunk data: @@ -258,9 +258,9 @@ STATIC void CM_activityDone(CMActivity_s *activity) * the beast. * } */ - (void) setBeastChunkValidRange(&genMsg, - activity->decompStream.beast, - compInfo->p.chunkSize, + (void) setBeastChunkValidRange(&genMsg, + activity->decompStream.beast, + compInfo->p.chunkSize, activity->decompStream.beastOffset, activity->decompStream.beastSize); setChunkCompStatus(&genMsg, activity->compStream.beast, offset, @@ -278,7 +278,7 @@ STATIC void CM_activityDone(CMActivity_s *activity) XLATCH_BEAST(uncompBeast); XLATCH_BEAST(compBeast); } - else + else { /* We must unlatch/latch compBeast/uncompBeast in order. * The rule is if doing unlatching, unlatch compBeast before unlatching uncompBeast; @@ -290,15 +290,15 @@ STATIC void CM_activityDone(CMActivity_s *activity) XLATCH_BEAST(uncompBeast); XLATCH_BEAST(compBeast); - compInfo->p.status &= + compInfo->p.status &= ~(COMP_STATUS_UNCOMPRESSED|COMP_STATUS_COMPRESSED|COMP_STATUS_FAILURE); compInfo->p.status |= newCompState; - if (! activity->keepSrcChunk) + if (! activity->keepSrcChunk) { /* Seems it is not necessary. */ /* Discard compressed data */ - (void) TRUNCATE_BEAST(&genMsg, activity->compStream.beast, + (void) TRUNCATE_BEAST(&genMsg, activity->compStream.beast, (activity->compStream.beastOffset + activity->compStream.beastSize)); } @@ -315,26 +315,26 @@ STATIC void CM_activityDone(CMActivity_s *activity) setBeastCompAttr(uncompBeast, 0, localXaction, FALSE); setVolCompStats(uncompBeast, compBeast, localXaction, FALSE); } - + /* Update precious counts and cleanup the datastream if necessary. */ ++ compInfo->p.UCprecious; - if (! activity->keepSrcChunk) + if (! activity->keepSrcChunk) { - if (-- compInfo->p.Cprecious == 0) + if (-- compInfo->p.Cprecious == 0) { /* remove activity from uncompBeast->CM_activities list. */ DQ_RMV(activity, beastActivitiesChain); - + /* wakeup all threads waiting for this activity to finish */ CM_signalEvent((ADDR)&compInfo->CM_activities, zOK); - + if (decompCleanup(&genMsg, uncompBeast, compBeast, FALSE, localXaction) == zOK) { compBeast = 0; } /* compInfo will be released by decompCleanup */ // else if ((compInfo = BEAST_CM_INFO(uncompBeast)) != NULL) -// { +// { // /* roll back the modified compression related information */ // setBeastCompAttr(uncompBeast, zFA_DATA_STREAM_IS_COMPRESSED, localXaction, TRUE); // setVolCompStats(uncompBeast, compBeast, localXaction, TRUE); @@ -352,22 +352,22 @@ STATIC void CM_activityDone(CMActivity_s *activity) ClearErrno(&genMsg); } -cleanupAndExit: +cleanupAndExit: /* remove activity from uncompBeast->CM_activities list. */ DQ_RMV(activity, beastActivitiesChain); if (DQ_EMPTY(&compInfo->CM_activities)) - updateBeastPurgeableBlksCnt(&genMsg, (NamedBeast_s *)uncompBeast, + updateBeastPurgeableBlksCnt(&genMsg, (NamedBeast_s *)uncompBeast, compBeast, TRUE, localXaction); /* wakeup all threads waiting for this activity to finish */ CM_signalEvent((ADDR)&compInfo->CM_activities, zOK); -releaseBeastsAndExit: +releaseBeastsAndExit: if (localXaction) { - COMN_EndXLocal(uncompBeast, &localXaction); + COMN_EndXLocal(uncompBeast, &localXaction); } - - if (compBeast) + + if (compBeast) COMN_UnlatchAndRelease(&compBeast, XLATCHED); COMN_UnlatchAndRelease(&uncompBeast, XLATCHED); } @@ -387,49 +387,49 @@ STATIC void CM_activityAborted(CMActivity_s *activity, STATUS errCode) XLATCH_BEAST(uncompBeast); XLATCH_BEAST(compBeast); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); - + DQ_RMV(activity, beastActivitiesChain); activity->state = CM_ACTIVITY_STATE_FINISHED; if (activity->op == CM_ACTIVITY_OP_COMPRESS) - { + { status = COMP_STATUS_UNCOMPRESSED; if (errCode != zERR_CM_ABORTED) { status |= COMP_STATUS_FAILURE; } - - if (compInfo->p.chunkSize > 0) + + if (compInfo->p.chunkSize > 0) { - /* + /* * reset compStream.beastOffset, beastSize to include the entire * chunk (including hdr) i.e., * hdrSize = sizeof(CompChunkHdr_s); * compStream.beastOffset -= hdrSize; * compStream.beastSize += hdrSize; - * + * * * throw away the partially compressed chunk data * create a hole in the compBeast in the range * - * This step may not be possible with current NSS implementation. + * This step may not be possible with current NSS implementation. * set chunk status to CantCompress; */ setChunkCompStatus(&genMsg, activity->compStream.beast, offset, compInfo->p.chunkSize, status); } - else + else { localXaction = COMN_BeginXLocal(uncompBeast); compInfo->p.status &= ~COMP_STATUS_COMPRESSED; compInfo->p.status = status; - + if (errCode != zERR_CM_ABORTED) { setBeastCompAttr(uncompBeast, zFA_CANT_COMPRESS_DATA_STREAM, localXaction, FALSE); } } - + if (!(compInfo->p.action & COMP_ACTION_ENABLE_IO_WRITE) && (compInfo->p.Cprecious == 0)) { @@ -438,15 +438,15 @@ STATIC void CM_activityAborted(CMActivity_s *activity, STATUS errCode) CM_signalEvent((ADDR)&compInfo->CM_activities, errCode); - /* we don't set up beast compression related attributes because we - * know it's cleaned up during compSetup. Also, we don't need to + /* we don't set up beast compression related attributes because we + * know it's cleaned up during compSetup. Also, we don't need to * update volume comp blocks stats */ - + if (decompCleanup(&genMsg, uncompBeast, compBeast, FALSE, localXaction) == zOK) { compBeast = 0; } - + goto releaseBeastsAndExit; } } @@ -457,35 +457,35 @@ STATIC void CM_activityAborted(CMActivity_s *activity, STATUS errCode) { status |= COMP_STATUS_FAILURE; } - - if (compInfo->p.chunkSize > 0) + + if (compInfo->p.chunkSize > 0) { - /* + /* * throw away the partially decompressed chunk data * create a hole in the uncompBeast in the range * - * This step may not be possible with current NSS implementation. + * This step may not be possible with current NSS implementation. * In case of whole file compression, truncate the beast. */ setChunkCompStatus(&genMsg, activity->compStream.beast, offset, compInfo->p.chunkSize, status); } - else + else { localXaction = COMN_BeginXLocal(uncompBeast); compInfo->p.status &= ~COMP_STATUS_UNCOMPRESSED; compInfo->p.status |= status; } - - if (compInfo->p.UCprecious == 0) + + if (compInfo->p.UCprecious == 0) { setBeastCompAttr(uncompBeast, zFA_DATA_STREAM_IS_COMPRESSED, localXaction, FALSE); /* we don't need to update volume comp blocks stats */ compCleanup(&genMsg, uncompBeast, compBeast, FALSE, &localXaction); } - + } if (localXaction) @@ -501,14 +501,14 @@ STATIC void CM_activityAborted(CMActivity_s *activity, STATUS errCode) if (DQ_EMPTY(&compInfo->CM_activities)) { - updateBeastPurgeableBlksCnt(&genMsg, (NamedBeast_s *)uncompBeast, + updateBeastPurgeableBlksCnt(&genMsg, (NamedBeast_s *)uncompBeast, compBeast, TRUE, localXaction); } - + /* Wakeup all threads waiting for this activity to finish. */ CM_signalEvent((ADDR)&compInfo->CM_activities, errCode); -releaseBeastsAndExit: +releaseBeastsAndExit: if (localXaction) { COMN_EndXLocal(uncompBeast, &localXaction); @@ -518,7 +518,7 @@ releaseBeastsAndExit: { COMN_UnlatchAndRelease(&compBeast, XLATCHED); } - + COMN_UnlatchAndRelease(&uncompBeast, XLATCHED); } @@ -533,7 +533,7 @@ void CM_activityWorkToDoRun(FsmLite_s *workToDoFsm, ADDR unused) rc = ALGOMGR_invokeCompAlgo(activity); if (rc != zOK) CM_activityAborted(activity, rc); - else CM_activityDone(activity); + else CM_activityDone(activity); zASSERT(NEXT(&activity->allActivitiesChain) != NULL); @@ -550,7 +550,7 @@ void CM_activitySuspend(CMActivity_s *activity) case CM_ACTIVITY_STATE_RUNNING: activity->state = CM_ACTIVITY_STATE_SUSPENDED; break; - default: + default: break; } } @@ -568,7 +568,7 @@ void CM_activityResume(CMActivity_s *activity) activity->state = CM_ACTIVITY_STATE_RUNNABLE; CM_signalEvent((ADDR)activity, zOK); break; - default: + default: break; } } @@ -587,7 +587,7 @@ void CM_activityAbort(CMActivity_s *activity, STATUS errCode, BOOL wait) activity->state = CM_ACTIVITY_STATE_ABORTING; CM_signalEvent((ADDR)activity, errCode); break; - default: + default: break; } } diff --git a/include/nwnss/include/cmActivity.h b/src/nwnss/comn/compression/cmActivity.h similarity index 96% rename from include/nwnss/include/cmActivity.h rename to src/nwnss/comn/compression/cmActivity.h index 92081ba..37a4936 100644 --- a/include/nwnss/include/cmActivity.h +++ b/src/nwnss/comn/compression/cmActivity.h @@ -37,19 +37,19 @@ #ifndef _CM_ACTIVITY_H_ #define _CM_ACTIVITY_H_ -typedef struct CMStream_s +typedef struct CMStream_s { struct CMActivity_s *activity; RootBeast_s *beast; /* Beast being read/written */ QUAD beastOffset; /* offset in the beast where the stream starts */ - QUAD beastSize; /* size of the part of the beast + QUAD beastSize; /* size of the part of the beast * comprising the stream */ QUAD streamOffset; /* current logical offset for stream I/O */ - Blknum_t curHoleBlks; /* # of hole blks (if any) starting at + Blknum_t curHoleBlks; /* # of hole blks (if any) starting at * streamOffset */ } CMStream_s; -typedef struct CMActivity_s +typedef struct CMActivity_s { DQlink_t allActivitiesChain; DQlink_t beastActivitiesChain; @@ -82,7 +82,7 @@ typedef struct CMActivity_s } CMActivity_s; extern STATUS CM_activityAlloc( - NINT activityOp, + NINT activityOp, CMActivity_s **activity, BOOL wait); extern void CM_activityFree(CMActivity_s *activity); diff --git a/src/nwnss/comn/compression/cmAlgoMan.c b/src/nwnss/comn/compression/cmAlgoMan.c index dc0d45d..f7842dc 100644 --- a/src/nwnss/comn/compression/cmAlgoMan.c +++ b/src/nwnss/comn/compression/cmAlgoMan.c @@ -41,7 +41,7 @@ #include "cmControl.h" #include "comnCompress.h" -typedef struct CompAlgo_s +typedef struct CompAlgo_s { BYTE algoID; BYTE state; @@ -78,7 +78,7 @@ void ALGOMGR_free(void *mem) /* * Called by the algorithm after it is loaded. */ -STATUS +STATUS ALGOMGR_registerCompAlgo(BYTE algoID, CompAlgoIF_s *algoIF) { STATUS rc; @@ -96,7 +96,7 @@ tryAgain: ; goto tryAgain; case COMP_ALGO_STATE_UNREGISTERED: break; - default: + default: break; } @@ -118,7 +118,7 @@ functionExit: ; /* * Called by NSS before unloading an algorithm */ -STATUS +STATUS ALGOMGR_unregisterCompAlgo(BYTE algoID, BOOL abortOngoingActivities, BOOL wait) { tryAgain: ; @@ -136,11 +136,11 @@ tryAgain: ; else return zOK; case COMP_ALGO_STATE_UNREGISTERED: return zOK; - default: + default: break; } - for (;;) + for (;;) { CMActivity_s *activity; NINT waitCount = 0; @@ -153,14 +153,14 @@ tryAgain: ; case CM_ACTIVITY_STATE_ABORTED: case CM_ACTIVITY_STATE_FINISHED: continue; - default: + default: break; } if (abortOngoingActivities && (activity->algoID == algoID)) activity->state = CM_ACTIVITY_STATE_ABORTING; ++ waitCount; } - + /* * Wait till all the ongoing (de)compressions finish. */ @@ -170,7 +170,7 @@ tryAgain: ; return zOK; (void) CM_awaitEvent((ADDR)&CompAlgoTable[algoID]); } - + /* Call the algorithm's uninit() routine */ MPKNSS_UNLOCK(); CompAlgoTable[algoID].ops->uninit(); @@ -233,7 +233,7 @@ ALGOMGR_uninit(void *voidVol, BOOL abortOngoingActivities, BOOL wait) } } -#if zLINUX +#if zLINUX #define LinuxCMStream_t (CMStream_t) #else #define LinuxCMStream_t @@ -253,22 +253,22 @@ ALGOMGR_invokeCompAlgo(CMActivity_s *activity) break; case COMP_ALGO_STATE_UNREGISTERED: case COMP_ALGO_STATE_UNREGISTERING: - default: + default: return zERR_CM_COMP_ALGO_NOT_REGISTERED; } MPKNSS_UNLOCK(); if (activity->op == CM_ACTIVITY_OP_COMPRESS) { - rc = CompAlgoTable[algoID].ops->compressStream(algoVersion, - LinuxCMStream_t &activity->decompStream, + rc = CompAlgoTable[algoID].ops->compressStream(algoVersion, + LinuxCMStream_t &activity->decompStream, LinuxCMStream_t &activity->compStream, LinuxCMStream_t &activity->tmpStream, minPercentGain); } - else + else { - rc = CompAlgoTable[algoID].ops->uncompressStream(algoVersion, - LinuxCMStream_t &activity->compStream, + rc = CompAlgoTable[algoID].ops->uncompressStream(algoVersion, + LinuxCMStream_t &activity->compStream, LinuxCMStream_t &activity->decompStream); } MPKNSS_LOCK(); @@ -282,7 +282,7 @@ ALGOMGR_invokeCompAlgo(CMActivity_s *activity) break; case CM_ACTIVITY_STATE_RUNNING: activity->state = CM_ACTIVITY_STATE_FINISHED; - default: + default: break; } if (CompAlgoTable[algoID].state == COMP_ALGO_STATE_UNREGISTERING) @@ -290,10 +290,10 @@ ALGOMGR_invokeCompAlgo(CMActivity_s *activity) return rc; } -STATUS +STATUS ALGOMGR_fetchStreamBuf( CMStream_t streamHandle, - QUAD offset, + QUAD offset, CMBuffer_t *cmbuf, /* out */ LONG mode, LONG sizeRequested, @@ -321,17 +321,17 @@ ALGOMGR_fetchStreamBuf( /* Perform activity suspend/resume/abort control */ tryAgain: ; - switch (activity->state) + switch (activity->state) { case CM_ACTIVITY_STATE_ABORTING: rc = zERR_CM_ABORTED; goto functionExit; case CM_ACTIVITY_STATE_SUSPENDED: - /* Block this thread on this activity; + /* Block this thread on this activity; * to be awakened when the activity is resumed */ (void) CM_awaitEvent((ADDR) activity); goto tryAgain; - default: + default: break; } @@ -346,7 +346,7 @@ tryAgain: ; realOffset = stream->beastOffset + offset; { /* Clip realSize against actual readable size within the buffer */ - LONG readableSize = realOffset & + LONG readableSize = realOffset & ((1 << stream->beast->blkSizeShift) - 1); readableSize = (1 << stream->beast->blkSizeShift) - readableSize; if (realSize > readableSize) @@ -358,48 +358,48 @@ tryAgain: ; rc = zERR_END_OF_FILE; goto functionExit; } - /* + /* * realSize bytes at realOffset in beast can be actually supplied to - * the caller. Now do the actual I/O. + * the caller. Now do the actual I/O. */ if (mode == CACHE_READ) { SLATCH_BEAST(stream->beast); } - else + else { XLATCH_BEAST(stream->beast); } rc = zOK; realBlknum = realOffset >> stream->beast->blkSizeShift; - if (mode == CACHE_READ) + if (mode == CACHE_READ) { - if (stream->curHoleBlks > 0) + if (stream->curHoleBlks > 0) { - Blknum_t holeStart = (stream->streamOffset + stream->beastOffset) + Blknum_t holeStart = (stream->streamOffset + stream->beastOffset) >> stream->beast->blkSizeShift; - if ((realBlknum >= holeStart) && + if ((realBlknum >= holeStart) && (realBlknum < (holeStart + stream->curHoleBlks))) *isHole = TRUE; } - else + else { cmbuf->buffer = CM_fetchFileBlk(&genMsg, stream->beast, realBlknum, mode, &stream->curHoleBlks); - if (! cmbuf->buffer) + if (! cmbuf->buffer) { rc = GetErrno(&genMsg); goto unlatchBeastAndReturn; } - if (stream->curHoleBlks > 0) + if (stream->curHoleBlks > 0) { *isHole = TRUE; CACHE_RELEASE(cmbuf->buffer); } } - if (*isHole) + if (*isHole) { INVALIDATE_HANDLE(*cmbuf); *data = NULL; @@ -408,7 +408,7 @@ tryAgain: ; -- stream->curHoleBlks; } } - else + else { if (activity->op == CM_ACTIVITY_OP_DECOMPRESS) { @@ -426,7 +426,7 @@ tryAgain: ; if (cmbuf->buffer) { mapBufferPage(cmbuf->buffer); - *data = cmbuf->buffer->pBuf.data + realOffset % + *data = cmbuf->buffer->pBuf.data + realOffset % (1 << cmbuf->buffer->bufSizeShift); *sizeReturned = realSize; stream->streamOffset = offset + realSize; @@ -439,22 +439,22 @@ functionExit: ; return rc; } -STATUS +STATUS ALGOMGR_releaseStreamBuf( CMStream_t streamHandle, - CMBuffer_t cmbuf, + CMBuffer_t cmbuf, BOOL isdirty) { STATUS rc; CMStream_s *stream; CMActivity_s *activity; - + MPKNSS_LOCK(); if (! ISVALID_HANDLE(streamHandle)) { rc = zERR_CM_INVALID_STREAM_HANDLE; goto functionExit; } - + if (! ISVALID_HANDLE(cmbuf)) { rc = zERR_CM_INVALID_BUFFER_HANDLE; goto functionExit; @@ -473,9 +473,9 @@ ALGOMGR_releaseStreamBuf( activity = stream->activity; /* Update sizeDone (size of target stream already (de)compressed) */ - if (activity->op == CM_ACTIVITY_OP_DECOMPRESS) + if (activity->op == CM_ACTIVITY_OP_DECOMPRESS) { - if (stream == &activity->decompStream) + if (stream == &activity->decompStream) { CompressInfo_s *compInfo = BEAST_CM_INFO(stream->beast); @@ -485,7 +485,7 @@ ALGOMGR_releaseStreamBuf( activity->sizeDone); } } - else + else { if (stream == &activity->compStream) activity->sizeDone += (1 << stream->beast->blkSizeShift); @@ -498,11 +498,11 @@ tryAgain: ; rc = zERR_CM_ABORTED; goto functionExit; case CM_ACTIVITY_STATE_SUSPENDED: - /* Block this thread on this activity; + /* Block this thread on this activity; * to be awakened when the activity is resumed */ (void) CM_awaitEvent((ADDR) activity); goto tryAgain; - default: + default: break; } rc = zOK; @@ -541,7 +541,7 @@ ALGOMGR_getStreamSize(CMStream_t streamHandle) return beastSize; } -STATUS +STATUS ALGOMGR_setStreamPosition(CMStream_t streamHandle, QUAD offset) { CMStream_s *stream; @@ -554,7 +554,7 @@ ALGOMGR_setStreamPosition(CMStream_t streamHandle, QUAD offset) return zOK; } -QUAD +QUAD ALGOMGR_getStreamPosition(CMStream_t streamHandle) { QUAD streamOffset; diff --git a/src/nwnss/comn/compression/cmBgCompress.c b/src/nwnss/comn/compression/cmBgCompress.c index 8088120..bb8f7f2 100644 --- a/src/nwnss/comn/compression/cmBgCompress.c +++ b/src/nwnss/comn/compression/cmBgCompress.c @@ -40,7 +40,7 @@ #include "alarm.h" #include "nssPubs.h" -typedef struct CMBgCompressControl_s +typedef struct CMBgCompressControl_s { BOOL inProgress; /* Background compression currently in progress */ BOOL scheduled; /* Background compression currently in progress */ @@ -49,7 +49,7 @@ typedef struct CMBgCompressControl_s #define CM_BG_COMPRESS_REASON_NONE 0 #define CM_BG_COMPRESS_REASON_TIMER 1 #define CM_BG_COMPRESS_REASON_USER_REQUEST 2 - OneShot_s alarm; /* Alarm for periodic background compression */ + OneShot_s alarm; /* Alarm for periodic background compression */ FsmLite_s fsm; /* thread on which background compression happens */ } CMBgCompressControl_s; #define BG_COMPRESS_ABORTED(_bgCompress) (! (_bgCompress)->inProgress) @@ -59,7 +59,7 @@ typedef struct CMBgCompressControl_s STATIC void CM_compressIdleFiles(Volume_s *volume, CMBgCompressControl_s *bgCompress) { typedef struct Stack_s { - Zid_t beastZids[MAX_ZIDS_PER_SCOOP]; + Zid_t beastZids[MAX_ZIDS_PER_SCOOP]; } Stack_s; Zid_t lastZidReturned; GeneralMsg_s genMsg; @@ -74,7 +74,7 @@ STATIC void CM_compressIdleFiles(Volume_s *volume, CMBgCompressControl_s *bgComp COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); lastZidReturned = zINVALID_ZID; - do + do { if (BG_COMPRESS_ABORTED(bgCompress)) { @@ -98,15 +98,15 @@ STATIC void CM_compressIdleFiles(Volume_s *volume, CMBgCompressControl_s *bgComp } if (volume->cmVolumeState.compActive != TRUE) - { + { /* volume is deactivating */ STACK_FREE(); return; } /* Obtain a scoop of ZIDs to examine */ - rc = volume->VOLcomnVolOps.VOL_browseBeastsInVolume(&genMsg, volume, - SELECT_BEASTS_FOR_COMPRESSION, MAX_ZIDS_PER_SCOOP, + rc = volume->VOLcomnVolOps.VOL_browseBeastsInVolume(&genMsg, volume, + SELECT_BEASTS_FOR_COMPRESSION, MAX_ZIDS_PER_SCOOP, &lastZidReturned, aStack->beastZids, &numBeastsReturned); if (rc != zOK) { @@ -118,14 +118,14 @@ STATIC void CM_compressIdleFiles(Volume_s *volume, CMBgCompressControl_s *bgComp for (i = 0; i < numBeastsReturned; ++ i) { if (volume->cmVolumeState.compActive != TRUE) - { + { /* and if volume is deactivating */ STACK_FREE(); return; } /* Obtain the beast */ - beast = (NamedBeast_s *)COMN_LookupByZid(&genMsg, volume, + beast = (NamedBeast_s *)COMN_LookupByZid(&genMsg, volume, aStack->beastZids[i], SLATCHED, TRUE); /* Ignore all errors */ @@ -135,18 +135,18 @@ STATIC void CM_compressIdleFiles(Volume_s *volume, CMBgCompressControl_s *bgComp /* Compress only beasts satisfying the following criteria */ if (COMN_IsDerivedFrom(beast, zFTYPE_NAMED_DATA_STREAM) && - ((beast->NAMEDattributes & + ((beast->NAMEDattributes & (zFA_SUBDIRECTORY|zFA_IS_LINK|zFA_DO_NOT_COMPRESS_FILE| zFA_CANT_COMPRESS_DATA_STREAM)) == 0)) - { + { if (beast->NAMEDattributes & zFA_COMPRESS_FILE_IMMEDIATELY) { - if ((beast->NAMEDattributes & + if ((beast->NAMEDattributes & (zFA_DATA_STREAM_IS_COMPRESSED | zFA_CANT_COMPRESS_DATA_STREAM)) != 0) { goto skipBeast; - } - } + } + } else if (beast->NAMEDattributes & zFA_DO_NOT_COMPRESS_FILE) { goto skipBeast; @@ -166,7 +166,7 @@ STATIC void CM_compressIdleFiles(Volume_s *volume, CMBgCompressControl_s *bgComp goto skipBeast; } break; - default: + default: break; } } @@ -180,7 +180,7 @@ STATIC void CM_compressIdleFiles(Volume_s *volume, CMBgCompressControl_s *bgComp /* Check again if bgCompress is disabled by user. */ if (BG_COMPRESS_ABORTED(bgCompress) || - (volume->cmVolumeState.compActive != TRUE)) + (volume->cmVolumeState.compActive != TRUE)) { COMN_UnlatchAndRelease(&beast, SLATCHED); STACK_FREE(); @@ -192,12 +192,12 @@ STATIC void CM_compressIdleFiles(Volume_s *volume, CMBgCompressControl_s *bgComp { goto skipBeast; } - + /* * Obtained a potential candidate for compression; * Initiate its compression in the background and proceed. */ - rc = CM_compressFileAsync(&genMsg, &beast->NAMEDroot, + rc = CM_compressFileAsync(&genMsg, &beast->NAMEDroot, SLATCHED, COMP_BACKGROUND); if ((rc != zOK) && (GetErrno(&genMsg) == zERR_NO_MEMORY)) { @@ -217,7 +217,7 @@ STATIC void CM_compressIdleFiles(Volume_s *volume, CMBgCompressControl_s *bgComp } skipBeast: ; COMN_UnlatchAndRelease(&beast, SLATCHED); - + PERIODIC_YIELD(); } } while (numBeastsReturned == MAX_ZIDS_PER_SCOOP); @@ -242,17 +242,17 @@ void CM_bgCompressRun(CMBgCompressControl_s *bgCompress) /* Scan all known volumes for compression */ while (! BG_COMPRESS_ABORTED(bgCompress)) - { + { nextVolume = COMN_GetNextVolume(prevVolume); - if (prevVolume) + if (prevVolume) { - COMN_Release(&prevVolume); + COMN_Release(&prevVolume); } if (nextVolume == NULL) { break; - } + } prevVolume = nextVolume; @@ -265,12 +265,12 @@ void CM_bgCompressRun(CMBgCompressControl_s *bgCompress) } } - if (prevVolume) + if (prevVolume) { - COMN_Release(&prevVolume); + COMN_Release(&prevVolume); } - if (BG_COMPRESS_ABORTED(bgCompress)) + if (BG_COMPRESS_ABORTED(bgCompress)) { CM_bgCompressCleanUp(); } @@ -279,10 +279,10 @@ void CM_bgCompressRun(CMBgCompressControl_s *bgCompress) bgCompress->inProgress = FALSE; } - /* Set an alarm to start background compression at next interval */ + /* Set an alarm to start background compression at next interval */ if (bgCompress->reason == CM_BG_COMPRESS_REASON_USER_REQUEST) { - CM_bgCompressRestartStartTimer(FALSE); + CM_bgCompressRestartStartTimer(FALSE); } } @@ -313,7 +313,7 @@ SecondsToTimeOfDay(LONG targetTimeOfDay) STATIC void CM_bgCompressWorkerThread(FsmLite_s *workToDoFsm, ADDR startCompress) { - CMBgCompressControl_s *bgCompress = + CMBgCompressControl_s *bgCompress = STRUCT(workToDoFsm, CMBgCompressControl_s, fsm); ASSERT_MPKNSS_LOCK(); @@ -321,7 +321,7 @@ CM_bgCompressWorkerThread(FsmLite_s *workToDoFsm, ADDR startCompress) bgCompress->scheduled = FALSE; if ((BOOL)startCompress) { - CM_bgCompressRun(bgCompress); + CM_bgCompressRun(bgCompress); } else { @@ -339,7 +339,7 @@ CM_startBgCompress(CMBgCompressControl_s *bgCompress) { bgCompress->inProgress = TRUE; bgCompress->scheduled = TRUE; - WORK_Schedule(&bgCompress->fsm, (voidfunc_t)CM_bgCompressWorkerThread, (ADDR)TRUE); + WORK_Schedule(&bgCompress->fsm, CM_bgCompressWorkerThread, (ADDR)TRUE); } } @@ -354,11 +354,11 @@ CM_stopBgCompress(CMBgCompressControl_s *bgCompress) } else { - if (! bgCompress->scheduled) + if (! bgCompress->scheduled) { /* clean up any queued request */ - bgCompress->scheduled = TRUE; - WORK_Schedule(&bgCompress->fsm, (voidfunc_t)CM_bgCompressWorkerThread, (ADDR)FALSE); + bgCompress->scheduled = TRUE; + WORK_Schedule(&bgCompress->fsm, CM_bgCompressWorkerThread, (ADDR)FALSE); } } @@ -367,7 +367,7 @@ CM_stopBgCompress(CMBgCompressControl_s *bgCompress) STATIC void CM_bgCompressStartTimerPopped(OneShot_s *alarm) { - CMBgCompressControl_s *bgCompress = + CMBgCompressControl_s *bgCompress = STRUCT(alarm, CMBgCompressControl_s, alarm); ASSERT_MPKNSS_LOCK(); @@ -381,7 +381,7 @@ CM_bgCompressStartTimerPopped(OneShot_s *alarm) return; /* Set an alarm to stop background compression */ - secOneShot(&bgCompress->alarm, secsToStop, + secOneShot(&bgCompress->alarm, secsToStop, CM_bgCompressStopTimerPopped); /* Start the background compression thread */ @@ -393,7 +393,7 @@ CM_bgCompressStartTimerPopped(OneShot_s *alarm) STATIC void CM_bgCompressStopTimerPopped(OneShot_s *alarm) { - CMBgCompressControl_s *bgCompress = + CMBgCompressControl_s *bgCompress = STRUCT(alarm, CMBgCompressControl_s, alarm); ASSERT_MPKNSS_LOCK(); @@ -413,8 +413,8 @@ CM_bgCompressStopTimerPopped(OneShot_s *alarm) /* Set an alarm to start background compression at next interval */ /* Cancel any previous timer */ CANCEL_ALARM(bgCompress->alarm); - - secOneShot(&bgCompress->alarm, secsToStart, + + secOneShot(&bgCompress->alarm, secsToStart, CM_bgCompressStartTimerPopped); } } @@ -425,13 +425,13 @@ void CM_bgCompressRestartStartTimer(BOOL startup) { LONG secsToStart = SecondsToTimeOfDay( CM_curCompControlParams.dailyCheckStartTime); - + ASSERT_MPKNSS_LOCK(); // Change of start timer only affects when bgCompression is not on progress if (startup) { - secOneShot(&CM_bgCompressControl.alarm, + secOneShot(&CM_bgCompressControl.alarm, secsToStart, CM_bgCompressStartTimerPopped); } else if (!CM_bgCompressControl.inProgress) @@ -443,9 +443,9 @@ void CM_bgCompressRestartStartTimer(BOOL startup) } if (secsToStart > 0) - { + { /* Set an alarm to start background compression at next interval */ - secOneShot(&CM_bgCompressControl.alarm, + secOneShot(&CM_bgCompressControl.alarm, secsToStart, CM_bgCompressStartTimerPopped); } else CM_bgCompressStartTimerPopped(&CM_bgCompressControl.alarm); @@ -490,7 +490,7 @@ CM_bgCompressInit() CM_bgCompressControl.scheduled = FALSE; CM_bgCompressControl.reason = CM_BG_COMPRESS_REASON_NONE; INIT_ONESHOT(CM_bgCompressControl.alarm); - FSMLITE_INIT(&CM_bgCompressControl.fsm, + FSMLITE_INIT(&CM_bgCompressControl.fsm, "FSM for background compression/decompression", 1); } @@ -518,7 +518,7 @@ CM_bgCompressStopRequest() } -/* +/* * When UTC is changed (cause by change of time zone), * we need to recompute bgcompression start and stop time */ @@ -534,4 +534,5 @@ void CM_bgCompressResetTimer() { CM_bgCompressRestartStartTimer(FALSE); } -} +} + diff --git a/src/nwnss/comn/compression/cmCompDecomp.c b/src/nwnss/comn/compression/cmCompDecomp.c index 8ba5c21..6d2b6bb 100644 --- a/src/nwnss/comn/compression/cmCompDecomp.c +++ b/src/nwnss/comn/compression/cmCompDecomp.c @@ -36,7 +36,7 @@ +-------------------------------------------------------------------------*/ #include #include -#include +#include #include #include @@ -45,7 +45,8 @@ #include #include #endif -#include +#include +#include #include #include #include @@ -54,13 +55,6 @@ #include "cmNSS.h" #include "comnCompress.h" #include "cmRuntime.h" - -#ifdef NSS_USERSPACE -#ifndef ZOS_StartThreadWithModuleHandle -#define ZOS_StartThreadWithModuleHandle(_thread, _name, _func, _arg1, _arg2, _arg3, _module) \ - do { (_thread) = 0; (void)(_name); (void)(_func); (void)(_arg1); (void)(_arg2); (void)(_arg3); (void)(_module); } while (0) -#endif -#endif #include "cmActivity.h" #include "cmAlgoMan.h" #include "cmControl.h" @@ -124,7 +118,7 @@ STATIC LONG CM_exitwinHandle = 0, CM_keywinHandle = 0; /* stat headers */ #define MaxNameLines 4 -STATIC LangEnabledStruct_s CM_statFileName[MaxNameLines] = +STATIC LangEnabledStruct_s CM_statFileName[MaxNameLines] = {StructMSGNot("File(s) Being Compressed:"), StructMSGNot("(Can be more than one if"), StructMSGNot("doing multiple threading)"), @@ -133,11 +127,11 @@ STATIC LangEnabledStruct_s CM_statFileName[MaxNameLines] = STATIC LangEnabledStruct_s CM_statCompRatio = StructMSGNot("Last compression ratio:"); STATIC LangEnabledStruct_s CM_statAvCompRatio = StructMSGNot("Average compression ratio:"); - + STATIC LangEnabledStruct_s CM_statNumCompFiles = StructMSGNot("Total compressed files:"); STATIC LangEnabledStruct_s CM_statNumCompDelFiles = StructMSGNot("Total compressed deleted files:"); STATIC LangEnabledStruct_s CM_statNumUncompFiles = StructMSGNot("Total uncompressible files:"); - + STATIC LangEnabledStruct_s CM_statNumEnqReqs = StructMSGNot("Num. of enqueued regular compression activities:"); STATIC LangEnabledStruct_s CM_statNumEnqBGReqs = StructMSGNot("Num. of enqueued background compression activities:"); STATIC LangEnabledStruct_s CM_statMaxNumEnqReqs = StructMSGNot("Max num. of enqueued compression activities:"); @@ -148,56 +142,56 @@ STATIC LangEnabledStruct_s CM_statUsedDecompActs = StructMSGNot("Used decompress #define StartLine 1 STATIC void displayHeaders() -{ +{ STATUS status; - + ASSERT_MPKNSS_LOCK(); ASSERT_LATCH(&CM_curCompStatistics.latch); /* file names */ - zPutWinCursor(status, CM_winHandle, StartLine, 2); + zPutWinCursor(status, CM_winHandle, StartLine, 2); zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statFileName[0])); - zPutWinCursor(status, CM_winHandle, StartLine + 1, 2); + zPutWinCursor(status, CM_winHandle, StartLine + 1, 2); zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statFileName[1])); - zPutWinCursor(status, CM_winHandle, StartLine + 2, 2); - zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statFileName[2])); - + zPutWinCursor(status, CM_winHandle, StartLine + 2, 2); + zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statFileName[2])); + /* compression ration*/ - zPutWinCursor(status, CM_winHandle, StartLine + 5, 2); + zPutWinCursor(status, CM_winHandle, StartLine + 5, 2); zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statCompRatio)); - zPutWinCursor(status, CM_winHandle, StartLine + 6, 2); + zPutWinCursor(status, CM_winHandle, StartLine + 6, 2); zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statAvCompRatio)); - - /* compressed files, uncompressible files */ - zPutWinCursor(status, CM_winHandle, StartLine + 8, 2); + + /* compressed files, uncompressible files */ + zPutWinCursor(status, CM_winHandle, StartLine + 8, 2); zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statNumCompFiles)); - zPutWinCursor(status, CM_winHandle, StartLine + 9, 2); + zPutWinCursor(status, CM_winHandle, StartLine + 9, 2); zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statNumCompDelFiles)); - zPutWinCursor(status, CM_winHandle, StartLine + 10, 2); + zPutWinCursor(status, CM_winHandle, StartLine + 10, 2); zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statNumUncompFiles)); - - /* number of enqueued activities */ - zPutWinCursor(status, CM_winHandle, StartLine + 12, 2); + + /* number of enqueued activities */ + zPutWinCursor(status, CM_winHandle, StartLine + 12, 2); zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statNumEnqReqs)); - zPutWinCursor(status, CM_winHandle, StartLine + 13, 2); + zPutWinCursor(status, CM_winHandle, StartLine + 13, 2); zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statNumEnqBGReqs)); - zPutWinCursor(status, CM_winHandle, StartLine + 14, 2); + zPutWinCursor(status, CM_winHandle, StartLine + 14, 2); zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statMaxNumEnqReqs)); - /* activities */ - zPutWinCursor(status, CM_winHandle, StartLine + 16, 2); + /* activities */ + zPutWinCursor(status, CM_winHandle, StartLine + 16, 2); zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statUsedCompActs)); - - zPutWinCursor(status, CM_winHandle, StartLine + 17, 2); + + zPutWinCursor(status, CM_winHandle, StartLine + 17, 2); zWinPrintf(status, CM_winHandle, StructGetMSGStr(CM_statUsedDecompActs)); } #endif -/* +/* * name is null-terminated. - */ + */ void displayCompNames() { #ifndef __linux__ // LINUX_Compression LINUX_ScreenIO @@ -205,8 +199,8 @@ void displayCompNames() RootBeast_s *beast; Volume_s *volume; NINT len, nameLen; - NINT count = 0; - CMActivity_s *activity; + NINT count = 0; + CMActivity_s *activity; BOOL latched = FALSE; #define maxDisplayVolLen 14 LangEnabledStruct_s abbr[] = { @@ -214,15 +208,15 @@ void displayCompNames() StructMSGNot("..:...\\"), StructMSGNot(".:...\\"), StructMSGNot(":...\\") - }; + }; typedef struct { BYTE name[MaxNameLines][zMAX_COMPONENT_NAME + 16 + 10]; unicode_t uniName[zMAX_COMPONENT_NAME + 1]; } AllocStuff_s; AllocStuff_s *as; BYTE spaces[79] = " " - " "; - + " "; + ASSERT_MPKNSS_LOCK(); ASSERT_LATCH(&CM_curCompStatistics.latch); @@ -234,7 +228,7 @@ typedef struct { as = zalloc( sizeof( *as ) ); if ( as == NULL ) { - aprintf(BROWN, MSG("Unable to Allocate Memory\n", 190)); + aprintf(BROWN, MSG("Unable to Allocate Memory\n", 190)); return; } @@ -243,61 +237,61 @@ typedef struct { if (DQ_NOT_EMPTY(&CM_activities)) { DQ_FOREACH(&CM_activities, activity, CMActivity_s, allActivitiesChain) - { + { if (activity->state != CM_ACTIVITY_STATE_RUNNING) - { + { continue; } - + if (count >= MaxNameLines - 1) { /* Not enough space to display, just exit */ strcpy(as->name[count], "..."); count++; break; - } + } beast = activity->decompStream.beast; - + /* get the volume name on which this beast resides */ volume = beast->ROOTvolume; - - if (COMN_GetVolumeName(&genMsg, volume, + + if (COMN_GetVolumeName(&genMsg, volume, as->uniName, NELEMS(as->uniName))) { zASSERT("can't get volume's name" == NULL); continue; } - if (COMN_UnicodeToName(&genMsg, NSS_UNI_CONVERSION_RAW, + if (COMN_UnicodeToName(&genMsg, NSS_UNI_CONVERSION_RAW, as->uniName, as->name[count], zMAX_COMPONENT_NAME + 1)) { zASSERT("can't convert unicode name to ascii name" == NULL); as->name[count][0] = 0; count++; continue; - } - + } + /* We don't display the whole name is it's too long */ nameLen = strlen(as->name[count]); - if (nameLen > maxDisplayVolLen) - { - strcpy(&as->name[count][maxDisplayVolLen - 3], StructGetMSGStr(abbr[0])); + if (nameLen > maxDisplayVolLen) + { + strcpy(&as->name[count][maxDisplayVolLen - 3], StructGetMSGStr(abbr[0])); nameLen = maxDisplayVolLen - 3 + strlen(StructGetMSGStr(abbr[0])); } else if (nameLen > (maxDisplayVolLen - 1)) - { - strcpy(&as->name[count][maxDisplayVolLen - 2], StructGetMSGStr(abbr[1])); + { + strcpy(&as->name[count][maxDisplayVolLen - 2], StructGetMSGStr(abbr[1])); nameLen = maxDisplayVolLen - 2 + strlen(StructGetMSGStr(abbr[1])); } else if (nameLen > (maxDisplayVolLen - 2)) { - strcpy(&as->name[count][maxDisplayVolLen - 1], StructGetMSGStr(abbr[2])); + strcpy(&as->name[count][maxDisplayVolLen - 1], StructGetMSGStr(abbr[2])); nameLen = maxDisplayVolLen - 1 + strlen(StructGetMSGStr(abbr[2])); } else - { - strcpy(&as->name[count][nameLen], StructGetMSGStr(abbr[3])); + { + strcpy(&as->name[count][nameLen], StructGetMSGStr(abbr[3])); nameLen += strlen(StructGetMSGStr(abbr[3])); } zASSERT(nameLen <= 25); @@ -308,7 +302,7 @@ typedef struct { SLATCH_BEAST(beast); latched = TRUE; } - + if (COMN_GetNameFromBeast(&genMsg, beast, /* cnt zFNU_FIRST_PARENT,*/ zNSPACE_LONG, NELEMS(as->uniName), as->uniName, &len)) @@ -317,32 +311,32 @@ typedef struct { { UNSLATCH_BEAST(beast); latched = FALSE; - } - + } + /* This could happen if the beast is during the purging process */ // zASSERT("can't get beast's name" == NULL); continue; } - + if (latched) - { + { UNSLATCH_BEAST(beast); latched = FALSE; } - - if (COMN_UnicodeToName(&genMsg, NSS_UNI_CONVERSION_RAW, + + if (COMN_UnicodeToName(&genMsg, NSS_UNI_CONVERSION_RAW, as->uniName, &as->name[count][nameLen], zMAX_COMPONENT_NAME + 1)) { zASSERT("can't convert unicode name to ascii name" == NULL); as->name[count][0] = 0; count++; continue; - } - - if (nameLen + len > 30) + } + + if (nameLen + len > 30) { /* We don't display the whole name if it's too long */ - strcpy(&as->name[count][30], "..."); + strcpy(&as->name[count][30], "..."); } /* mark what is the operation on this file (comp or decomp) */ @@ -351,10 +345,10 @@ typedef struct { strcat(as->name[count], " (C)"); } else - { + { strcat(as->name[count], " (D)"); } - + count++; } } @@ -363,13 +357,13 @@ typedef struct { count = 0; while (count < MaxNameLines) - { - len = strlen(StructGetMSGStr(CM_statFileName[count])); - /* put cursor at column 40 */ + { + len = strlen(StructGetMSGStr(CM_statFileName[count])); + /* put cursor at column 40 */ zASSERT(len < 40); PutWinCursor(CM_winHandle, StartLine + count, 40); WinPrintf(CM_winHandle, as->name[count]); - WinPrintf(CM_winHandle, + WinPrintf(CM_winHandle, &spaces[40 + strlen(as->name[count])]); count++; } @@ -384,11 +378,11 @@ typedef struct { void displayCompRatio() { #ifndef __linux__ // LINUX_Compression LINUX_ScreenIO - BYTE buf[80]; + BYTE buf[80]; NINT len; BYTE dots[79] = "......................................." - "......................................."; - + "......................................."; + ASSERT_MPKNSS_LOCK(); ASSERT_LATCH(&CM_curCompStatistics.latch); @@ -401,13 +395,13 @@ void displayCompRatio() sprintf(buf, "%d", CM_curCompStatistics.percentSpaceSaved); len = strlen(StructGetMSGStr(CM_statCompRatio)); - PutWinCursor(CM_winHandle, StartLine + 5, len + 2); + PutWinCursor(CM_winHandle, StartLine + 5, len + 2); WinPrintf(CM_winHandle, &dots[len + 2 + strlen(buf) + 2]); WinPrintf(CM_winHandle, buf); sprintf(buf, "%d", CM_curCompStatistics.averageCompRatio); len = strlen(StructGetMSGStr(CM_statAvCompRatio)); - PutWinCursor(CM_winHandle, StartLine + 6, len + 2); + PutWinCursor(CM_winHandle, StartLine + 6, len + 2); WinPrintf(CM_winHandle, &dots[len + 2 + strlen(buf) + 2]); WinPrintf(CM_winHandle, buf); @@ -419,11 +413,11 @@ void displayCompRatio() void displayFileCounts() { #ifndef __linux__ // LINUX_Compression LINUX_ScreenIO - BYTE buf[80]; + BYTE buf[80]; NINT len; BYTE dots[79] = "......................................." - "......................................."; - + "......................................."; + ASSERT_MPKNSS_LOCK(); ASSERT_LATCH(&CM_curCompStatistics.latch); @@ -437,22 +431,22 @@ void displayFileCounts() sprintf(buf, "%d", CM_curCompStatistics.compressedFiles - CM_curCompStatistics.compDelFiles); len = strlen(StructGetMSGStr(CM_statNumCompFiles)); - PutWinCursor(CM_winHandle, StartLine + 8, len + 2); + PutWinCursor(CM_winHandle, StartLine + 8, len + 2); WinPrintf(CM_winHandle, &dots[len + 2 + strlen(buf) + 2]); WinPrintf(CM_winHandle, buf); sprintf(buf, "%d", CM_curCompStatistics.compDelFiles); len = strlen(StructGetMSGStr(CM_statNumCompDelFiles)); - PutWinCursor(CM_winHandle, StartLine + 9, len + 2); + PutWinCursor(CM_winHandle, StartLine + 9, len + 2); WinPrintf(CM_winHandle, &dots[len + 2 + strlen(buf) + 2]); WinPrintf(CM_winHandle, buf); sprintf(buf, "%d", CM_curCompStatistics.uncompressibleFiles); len = strlen(StructGetMSGStr(CM_statNumUncompFiles)); - PutWinCursor(CM_winHandle, StartLine + 10, len + 2); + PutWinCursor(CM_winHandle, StartLine + 10, len + 2); WinPrintf(CM_winHandle, &dots[len + 2 + strlen(buf) + 2]); WinPrintf(CM_winHandle, buf); - + MPKNSS_LOCK(); #endif return; @@ -461,11 +455,11 @@ void displayFileCounts() void displayWaitingCounts() { #ifndef __linux__ // LINUX_Compression LINUX_ScreenIO - BYTE buf[80]; + BYTE buf[80]; NINT len; BYTE dots[79] = "......................................." - "......................................."; - + "......................................."; + ASSERT_MPKNSS_LOCK(); ASSERT_LATCH(&CM_curCompStatistics.latch); @@ -478,19 +472,19 @@ void displayWaitingCounts() sprintf(buf, "%d", CM_curCompStatistics.numQueuedCompReqs); len = strlen(StructGetMSGStr(CM_statNumEnqReqs)); - PutWinCursor(CM_winHandle, StartLine + 12, len + 2); + PutWinCursor(CM_winHandle, StartLine + 12, len + 2); WinPrintf(CM_winHandle, &dots[len + 2 + strlen(buf) + 2]); WinPrintf(CM_winHandle, buf); sprintf(buf, "%d", CM_curCompStatistics.numQueuedBGCompReqs); len = strlen(StructGetMSGStr(CM_statNumEnqBGReqs)); - PutWinCursor(CM_winHandle, StartLine + 13, len + 2); + PutWinCursor(CM_winHandle, StartLine + 13, len + 2); WinPrintf(CM_winHandle, &dots[len + 2 + strlen(buf) + 2]); WinPrintf(CM_winHandle, buf); sprintf(buf, "%d", CM_curCompControlParams.maxZidsQueuedForCompression); len = strlen(StructGetMSGStr(CM_statMaxNumEnqReqs)); - PutWinCursor(CM_winHandle, StartLine + 14, len + 2); + PutWinCursor(CM_winHandle, StartLine + 14, len + 2); WinPrintf(CM_winHandle, &dots[len + 2 + strlen(buf) + 2]); WinPrintf(CM_winHandle, buf); @@ -500,13 +494,13 @@ void displayWaitingCounts() } void displayCompActivityCounts() -{ +{ #ifndef __linux__ // LINUX_Compression LINUX_ScreenIO - BYTE buf[80]; + BYTE buf[80]; NINT len; BYTE dots[79] = "......................................." - "......................................."; - + "......................................."; + ASSERT_MPKNSS_LOCK(); ASSERT_LATCH(&CM_curCompStatistics.latch); @@ -519,13 +513,13 @@ void displayCompActivityCounts() sprintf(buf, "%d", CM_curCompStatistics.numCompActivities); len = strlen(StructGetMSGStr(CM_statUsedCompActs)); - PutWinCursor(CM_winHandle, StartLine + 16, len + 2); + PutWinCursor(CM_winHandle, StartLine + 16, len + 2); WinPrintf(CM_winHandle, &dots[len + 2 + strlen(buf) + 2]); WinPrintf(CM_winHandle, buf); sprintf(buf, "%d", CM_curCompStatistics.numDecompActivities); len = strlen(StructGetMSGStr(CM_statUsedDecompActs)); - PutWinCursor(CM_winHandle, StartLine + 17, len + 2); + PutWinCursor(CM_winHandle, StartLine + 17, len + 2); WinPrintf(CM_winHandle, &dots[len + 2 + strlen(buf) + 2]); WinPrintf(CM_winHandle, buf); @@ -537,7 +531,7 @@ void displayCompActivityCounts() #ifndef __linux__ // LINUX_Compression LINUX_ScreenIO /* caller should have nss mpk lock. */ STATIC void CM_screenDestroy() -{ +{ ASSERT_MPKNSS_LOCK(); ASSERT_XLATCH(&CM_curCompStatistics.latch); @@ -547,32 +541,32 @@ STATIC void CM_screenDestroy() } MPKNSS_UNLOCK(); - + if (CM_exitwinHandle) { DeleteWindow(CM_exitwinHandle); } - + if (CM_keywinHandle) { DeleteWindow(CM_keywinHandle); } - + if (CM_winHandle) - { - DeleteWindow(CM_winHandle); + { + DeleteWindow(CM_winHandle); } - + if (CM_scrHandle) { PutNWWinScreen(CM_scrHandle); } - CM_scrHandle = 0; + CM_scrHandle = 0; CM_winHandle = 0; CM_keywinHandle = 0; CM_exitwinHandle = 0; - + MPKNSS_LOCK(); return; @@ -582,14 +576,14 @@ STATIC void CM_screenDestroy() STATIC void CM_screenRun(THREAD threadID, void *param) { LONG keyvalue; - LONG attrchr; + LONG attrchr; LONG select = 0; - WORD keyCheck[2] = {0,0}; + WORD keyCheck[2] = {0,0}; while (1) { MPKNSS_LOCK(); - + if (!CM_isStarted) { /* we are shutting down */ @@ -598,7 +592,7 @@ STATIC void CM_screenRun(THREAD threadID, void *param) S_LATCH(&CM_curCompStatistics.latch); if (!CM_scrHandle) - { + { UNS_LATCH(&CM_curCompStatistics.latch); MPKNSS_UNLOCK(); kDelayThread(500); @@ -607,23 +601,23 @@ STATIC void CM_screenRun(THREAD threadID, void *param) UNS_LATCH(&CM_curCompStatistics.latch); MPKNSS_UNLOCK(); - + GetCharSem(CM_scrHandle, &attrchr, (LONG *)&CM_isStarted); if (!CM_isStarted) { MPKNSS_LOCK(); goto Exit; } - + MPKNSS_LOCK(); S_LATCH(&CM_curCompStatistics.latch); MPKNSS_UNLOCK(); - + keyvalue = (attrchr & 0x0000ffff); /* This is the only way to exit the compression screen */ if (keyvalue == ESC_K) - { + { /* Copied from menuMain.c */ NWMakeWindow(CM_scrHandle, &CM_exitwinHandle, 10, 32, 4, 11); SetTitle(CM_exitwinHandle, (BYTE *)MSG(" Exit? ", 191)); @@ -635,10 +629,10 @@ STATIC void CM_screenRun(THREAD threadID, void *param) WinPrintf(CM_exitwinHandle, (BYTE *)MSG(" No\r\n", 193)); WinPrintf(CM_exitwinHandle, (BYTE *)MSG(" Yes", 194)); - + while(1) { - SelectWinMenuElement(CM_exitwinHandle, &select, select + 1, + SelectWinMenuElement(CM_exitwinHandle, &select, select + 1, keyCheck, FALSE); if (((select & 0x0000ffff) == RTARROW_K) || @@ -668,7 +662,7 @@ STATIC void CM_screenRun(THREAD threadID, void *param) select = -1; } } - + DeleteWindow(CM_exitwinHandle); /*- "Yes" is seleted -*/ @@ -678,7 +672,7 @@ STATIC void CM_screenRun(THREAD threadID, void *param) UNS_LATCH(&CM_curCompStatistics.latch); break; } - } + } MPKNSS_LOCK(); UNS_LATCH(&CM_curCompStatistics.latch); @@ -687,18 +681,18 @@ STATIC void CM_screenRun(THREAD threadID, void *param) Exit: X_LATCH(&CM_curCompStatistics.latch); - CM_screenDestroy(); + CM_screenDestroy(); CM_screenThreadID = NULL; UNX_LATCH(&CM_curCompStatistics.latch); MPKNSS_UNLOCK(); - + return; -} +} #endif STATUS CM_screenDisplay() -{ +{ STATUS status = zOK; #ifndef __linux__ // LINUX_Compression LINUX_ScreenIO BYTE *title = {(BYTE *)MSG("NSS" " COMPRESSION STATISTICS ", 195)}; @@ -714,14 +708,14 @@ STATUS CM_screenDisplay() goto Exit; } - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); /*- Display the main window -*/ status = GetNWWinScreen(&CM_scrHandle, title); if (status != zOK) - { + { MPKNSS_LOCK(); - aprintf(BROWN, MSG("Unable to Get Compression Screen Memory\n", 1228)); + aprintf(BROWN, MSG("Unable to Get Compression Screen Memory\n", 1228)); MPKNSS_UNLOCK(); goto Exit; } @@ -733,7 +727,7 @@ STATUS CM_screenDisplay() DisplayWindow(CM_winHandle); ClearWindow(CM_winHandle); - + /*- Display the key map window -*/ #define MAX_COLUMNS 78 NWMakeWindow(CM_scrHandle, &CM_keywinHandle, 22, 1, 2, MAX_COLUMNS); @@ -743,18 +737,18 @@ STATUS CM_screenDisplay() /*- Create a thread to get user's key stroke -*/ MPKNSS_LOCK(); - ZOS_StartThreadWithModuleHandle(CM_screenThreadID, "NSS Compression Screen", - (void *(*)(THREAD, void *))CM_screenRun, - 0, 0, 0, (LONG)CMN_ModuleHandle); + ZOS_StartThreadWithModuleHandle(CM_screenThreadID, "NSS Compression Screen", + (void *(*)(THREAD, void *))CM_screenRun, + 0, 0, 0, (LONG)CMN_ModuleHandle); if (!CM_screenThreadID) { CM_screenDestroy(); goto Exit; } - /*- Display the information -*/ + /*- Display the information -*/ displayHeaders(); - + displayCompNames(); displayCompRatio(); displayFileCounts(); @@ -794,10 +788,10 @@ BOOL CM_checkParentDirForCompressOK(GeneralMsg_s *genMsg, File_s *beast) STATIC STATUS decompressionStart( GeneralMsg_s *genMsg, - RootBeast_s *uncompBeast, + RootBeast_s *uncompBeast, RootBeast_s *compBeast, - QUAD offset, - SQUAD size, + QUAD offset, + SQUAD size, BOOL keepCompVersion, BOOL wait, /* Is blocking allowed? */ CMActivity_s **activity) /* out */ @@ -815,9 +809,9 @@ decompressionStart( ASSERT_MPKNSS_LOCK(); zASSERT(compInfo != NULL); - + chunksize = compInfo->p.chunkSize; - if (chunksize == 0) + if (chunksize == 0) { /* Whole file compression */ Buffer_s *cmbuf; @@ -826,14 +820,14 @@ decompressionStart( return zFAILURE; mapBufferPage(cmbuf); fileHdr = (CompFileHdr_s *)cmbuf->pBuf.data; - if (IS_COMPFILE_LAYOUT_NETWARE(fileHdr->fileLayout_ID)) + if (IS_COMPFILE_LAYOUT_NETWARE(fileHdr->fileLayout_ID)) { algoID = NSS_COMP_ALGO_ID_NETWARE; algoVersion = NETWARE_COMP_ALGO_VERSION; compChunkOffset = 0; compChunkSize = size; } - else + else { chunkHdr = (CompChunkHdr_s *) ((BYTE *)fileHdr + sizeof(CompFileHdr_s)); @@ -854,13 +848,13 @@ decompressionStart( if (getCompChunkOffset(genMsg, compBeast, offset, chunksize, &compChunkOffset) != zOK) \ return zFAILURE; - cmbuf = CM_fetchFileBlk(genMsg, compBeast, + cmbuf = CM_fetchFileBlk(genMsg, compBeast, compChunkOffset >> compBeast->blkSizeShift, CACHE_READ, 0); if (! cmbuf) return zFAILURE; mapBufferPage(cmbuf); chunkHdr = (CompChunkHdr_s *) - (cmbuf->pBuf.data + (compChunkOffset & + (cmbuf->pBuf.data + (compChunkOffset & ((1 << cmbuf->bufSizeShift) - 1))); algoID = chunkHdr->algoID; @@ -875,7 +869,7 @@ decompressionStart( } if ((rc = CM_activityAlloc(CM_ACTIVITY_OP_DECOMPRESS, &newActivity, TRUE)) - != zOK) + != zOK) { SetErrno(genMsg, rc); return zFAILURE; @@ -902,11 +896,11 @@ decompressionStart( COMN_USE_BEAST(uncompBeast); COMN_USE_BEAST(compBeast); - if (*activity) + if (*activity) { DQ_INSERT_BEFORE(*activity, newActivity, beastActivitiesChain); } - else + else { DQ_ENQ(&compInfo->CM_activities, newActivity, beastActivitiesChain); } @@ -929,8 +923,8 @@ decompressionStart( STATIC STATUS compressionStart( CMCompDecompParams_s *parms, - QUAD offset, - SQUAD size, + QUAD offset, + SQUAD size, CMActivity_s **activity) /* out */ { CMActivity_s *newActivity; @@ -941,18 +935,18 @@ compressionStart( STATUS rc; ASSERT_MPKNSS_LOCK(); - if ((rc = CM_activityAlloc(CM_ACTIVITY_OP_COMPRESS, &newActivity, - parms->wait)) != zOK) + if ((rc = CM_activityAlloc(CM_ACTIVITY_OP_COMPRESS, &newActivity, + parms->wait)) != zOK) { SetErrno(parms->genMsg, rc); return zFAILURE; } /* Set up beast for compression, if needed */ - if ((! parms->compInfo) || + if ((! parms->compInfo) || (BEAST_UNCOMPRESSED(parms->compInfo) && BEAST_CLEAN(parms->compInfo->p.status))) { - rc = compSetup(parms->genMsg, parms->uncompBeast, &parms->compBeast, + rc = compSetup(parms->genMsg, parms->uncompBeast, &parms->compBeast, parms->xaction); if (rc != zOK) goto cleanupAndExit; @@ -972,9 +966,9 @@ compressionStart( algoID = parms->compInfo->p.algoID; algoVersion = parms->compInfo->p.algoVersion; - if ((algoID == NSS_COMP_ALGO_ID_NETWARE) && + if ((algoID == NSS_COMP_ALGO_ID_NETWARE) && (parms->compInfo->p.chunkSize == 0)) - { + { /* * Whole file compression using the Netware Algorithm: * In this case, we let the netware algorithm decide the entire @@ -985,7 +979,7 @@ compressionStart( offset = 0; zASSERT(size == GET_DATASTREAM_SIZE(parms->uncompBeast)); } - else + else { /* chunky compression */ Buffer_s *cmbuf; @@ -998,7 +992,7 @@ compressionStart( mapBufferPage(cmbuf); fileHdr = (CompFileHdr_s *)cmbuf->pBuf.data; - if (offset == 0) + if (offset == 0) { /* * Compressing first chunk of the file. @@ -1007,18 +1001,18 @@ compressionStart( chunkHdr = (CompChunkHdr_s *)((BYTE *)fileHdr+sizeof(*fileHdr)); compChunkOffset = sizeof(CompFileHdr_s); } - else + else { /* some chunk other than the first */ unmapBufferPage(cmbuf); CACHE_DIRTY_RELEASE(cmbuf); - if ((rc = getCompChunkOffset(parms->genMsg, parms->compBeast, + if ((rc = getCompChunkOffset(parms->genMsg, parms->compBeast, offset, parms->compInfo->p.chunkSize, &compChunkOffset)) != zOK) { goto cleanupAndExit; } - cmbuf = CM_fetchFileBlk(parms->genMsg, parms->compBeast, - compChunkOffset >> parms->compBeast->blkSizeShift, + cmbuf = CM_fetchFileBlk(parms->genMsg, parms->compBeast, + compChunkOffset >> parms->compBeast->blkSizeShift, CACHE_UPDATE, 0); if (! cmbuf) { @@ -1028,7 +1022,7 @@ compressionStart( } mapBufferPage(cmbuf); chunkHdr = (CompChunkHdr_s *) - (cmbuf->pBuf.data + + (cmbuf->pBuf.data + (compChunkOffset & ((1 << cmbuf->bufSizeShift) - 1))); } compChunkOffset += sizeof(CompChunkHdr_s); @@ -1081,11 +1075,11 @@ compressionStart( COMN_USE_BEAST(parms->uncompBeast); COMN_USE_BEAST(parms->compBeast); - if (*activity) + if (*activity) { DQ_INSERT_BEFORE(*activity, newActivity, beastActivitiesChain); } - else + else { DQ_ENQ(&parms->compInfo->CM_activities, newActivity, beastActivitiesChain); } @@ -1112,11 +1106,11 @@ cleanupAndExit: ; STATIC STATUS startDecompIfNeeded( GeneralMsg_s *genMsg, - RootBeast_s *uncompBeast, - RootBeast_s *compBeast, + RootBeast_s *uncompBeast, + RootBeast_s *compBeast, QUAD *startOffset, /* inout: increment it by byte range processed */ QUAD endOffset, - CMActivity_s *enqBeforeActivity, /* EnQ newly created activities + CMActivity_s *enqBeforeActivity, /* EnQ newly created activities * before this */ NINT accessMode, /* intended mode of access to the range */ NINT *grantedRights, @@ -1129,40 +1123,40 @@ startDecompIfNeeded( QUAD chunksize = compInfo->p.chunkSize; QUAD offset = *startOffset; BOOL keepCompVersion; - + ASSERT_MPKNSS_LOCK(); - if (chunksize == 0) + if (chunksize == 0) { chunksize = GET_DATASTREAM_SIZE(uncompBeast); } - for (; offset < endOffset; - offset = TRUNC(offset + chunksize, chunksize)) + for (; offset < endOffset; + offset = TRUNC(offset + chunksize, chunksize)) { NINT status; - QUAD chunkStart = TRUNC(offset, chunksize); - - if (compInfo->p.chunkSize == 0) + QUAD chunkStart = TRUNC(offset, chunksize); + + if (compInfo->p.chunkSize == 0) { status = compInfo->p.status; } - else - { + else + { rc = getChunkCompStatus(genMsg, compBeast, offset, chunksize, &status); if (rc != zOK) break; } - if (CHUNK_UNCOMPRESSED(status)) + if (CHUNK_UNCOMPRESSED(status)) { /* * The chunk is already in decompressed state. Good! */ - continue; + continue; } - else if (COMP_FAILED(status)) + else if (COMP_FAILED(status)) { /* * A previous attempt at decompression of this chunk @@ -1170,8 +1164,8 @@ startDecompIfNeeded( */ SetErrno(genMsg, zERR_CM_CANT_DECOMPRESS); - /* clean COMP_STATUS_FAILURE so we can try later if - * failure is caused by hardware error + /* clean COMP_STATUS_FAILURE so we can try later if + * failure is caused by hardware error */ compInfo->p.status &= ~COMP_STATUS_FAILURE; @@ -1186,35 +1180,35 @@ startDecompIfNeeded( CMActivity_s *newActivity = enqBeforeActivity; if (!(*grantedRights & zRR_LEAVE_FILE_COMPRESSED)) - { + { Volume_s *volume = uncompBeast->ROOTvolume; QUAD freeBlocks; typedef struct Stack_s { unicode_t volName[zMAX_COMPONENT_NAME + 1]; } Stack_s; - + STACK_ALLOC(); - - freeBlocks = (volume->VOLtotalBlocks - volume->VOLinUseBlocks) + + freeBlocks = (volume->VOLtotalBlocks - volume->VOLinUseBlocks) > volume->VOLfreeBlockAdjustment ? - (volume->VOLtotalBlocks - volume->VOLinUseBlocks + (volume->VOLtotalBlocks - volume->VOLinUseBlocks - volume->VOLfreeBlockAdjustment) : 0; - if (100 * (freeBlocks + volume->VOLpurgeableBlocks) - < (CM_curCompControlParams.minFreeSpaceToDecompress * + if (100 * (freeBlocks + volume->VOLpurgeableBlocks) + < (CM_curCompControlParams.minFreeSpaceToDecompress * volume->VOLtotalBlocks)) - { + { *grantedRights |= zRR_LEAVE_FILE_COMPRESSED; if ((CM_curCompControlParams.decompFreeSpaceWarningInterval != 0) && - ((volume->decompFreeSpaceWarningTime + - CM_curCompControlParams.decompFreeSpaceWarningInterval) < - GetUTCTime())) + ((volume->decompFreeSpaceWarningTime + + CM_curCompControlParams.decompFreeSpaceWarningInterval) < + GetUTCTime())) { volume->decompFreeSpaceWarningTime = GetUTCTime(); /* this function will always return a valid name */ - COMN_GetVolumeName(genMsg, volume, aStack->volName, zMAX_COMPONENT_NAME + 1); + COMN_GetVolumeName(genMsg, volume, aStack->volName, zMAX_COMPONENT_NAME + 1); #ifndef __linux__ // LINUX_Compression LINUX_NetWareAlerts ZOS_NetWareAlert((CMN_ModuleHandle, &NSSDecompressUnderFreePercentage, 1, @@ -1224,34 +1218,34 @@ startDecompIfNeeded( } STACK_FREE(); } - + /* Set up for beast decompression, if needed */ - if (BEAST_COMPRESSED(compInfo) && + if (BEAST_COMPRESSED(compInfo) && BEAST_CLEAN(compInfo->p.status)) - { + { rc = decompSetup(genMsg, uncompBeast, NULL); if (rc != zOK) { break; } - } + } - if (accessMode != CACHE_READ) + if (accessMode != CACHE_READ) { - /* + /* * If the entire chunk is about to be overwritten, * toss its contents without uncompressing */ - if (!writeAfterEOF && (offset == chunkStart) && - (endOffset >= (chunkStart + chunksize))) - { - rc = CM_tossBeastCompChunk(genMsg, uncompBeast, + if (!writeAfterEOF && (offset == chunkStart) && + (endOffset >= (chunkStart + chunksize))) + { + rc = CM_tossBeastCompChunk(genMsg, uncompBeast, compBeast, chunkStart, TRUE); - if (rc != zOK || BEAST_UNCOMPRESSED(compInfo)) + if (rc != zOK || BEAST_UNCOMPRESSED(compInfo)) { break; } - + continue; } } @@ -1259,37 +1253,37 @@ startDecompIfNeeded( if (accessMode != CACHE_READ) { keepCompVersion = FALSE; - } + } else { - keepCompVersion = (*grantedRights & zRR_LEAVE_FILE_COMPRESSED) ? + keepCompVersion = (*grantedRights & zRR_LEAVE_FILE_COMPRESSED) ? TRUE : FALSE; } - rc = decompressionStart(genMsg, uncompBeast, compBeast, + rc = decompressionStart(genMsg, uncompBeast, compBeast, offset, chunksize, keepCompVersion, wait, &newActivity); - if (rc != zOK) - break; + if (rc != zOK) + break; -#if 0 -/* FixFixFix6 +#if 0 +/* FixFixFix6 * This part is removed for defect 288895. * Looks like this code was put here in the mind of chunky decompression scenario. * We should revisit it and decide if this code is necessary at that moment * (We have already done several checks in checkDecompStatus). * For the time being, a whole file would be decompressed before anything could * go on, so there's no use to be notified when the desired part is finished - * decompressing (we have to wait in any case). + * decompressing (we have to wait in any case). * Also, if this part is decided to be useful, we should unlatch both uncomp/comp * beasts before put this thread into sleep. */ - if (endOffset < (newActivity->decompStream.beastOffset + if (endOffset < (newActivity->decompStream.beastOffset + newActivity->decompStream.beastSize)) { ADD_UNCOMP_DATA_WAITER(&compInfo->dataWaiters, endOffset); } -#endif +#endif *isDone = FALSE; } } @@ -1305,10 +1299,10 @@ startDecompIfNeeded( STATIC STATUS checkDecompStatus( GeneralMsg_s *genMsg, - RootBeast_s *uncompBeast, - RootBeast_s *compBeast, - QUAD offset, - QUAD size, + RootBeast_s *uncompBeast, + RootBeast_s *compBeast, + QUAD offset, + QUAD size, NINT accessMode, NINT *grantedRights, BOOL wait, /* is blocking allowed? */ @@ -1324,13 +1318,13 @@ checkDecompStatus( ASSERT_MPKNSS_LOCK(); - if (chunksize == 0) + if (chunksize == 0) { chunksize = GET_DATASTREAM_SIZE(uncompBeast); if (offset >= chunksize) - { - /* at least part of the required file range falls after eof, - * just need to check if the original file has been uncompressed + { + /* at least part of the required file range falls after eof, + * just need to check if the original file has been uncompressed */ offset = 0; size = chunksize; @@ -1345,18 +1339,18 @@ checkDecompStatus( * that offset/(offset + size) is greater than eof */ endOffset = offset + size; - - DQ_FOREACH_SAFE(&compInfo->CM_activities, activity, tmpActivity, + + DQ_FOREACH_SAFE(&compInfo->CM_activities, activity, tmpActivity, CMActivity_s, beastActivitiesChain) { CMStream_s *decompStream; decompStream = &activity->decompStream; - if ((offset >= decompStream->beastOffset) && + if ((offset >= decompStream->beastOffset) && (endOffset <= decompStream->beastSize)) - { - + { + if ((activity->op == CM_ACTIVITY_OP_COMPRESS) && ((activity->state == CM_ACTIVITY_STATE_RUNNABLE) || (activity->state == CM_ACTIVITY_STATE_RUNNING))) @@ -1372,29 +1366,29 @@ checkDecompStatus( return zOK; } -#if 0 +#if 0 /* FixFixFix6 the rest part of this is checking for chunky compression. * It needs to be fixed when NSS supports chunky compression - */ + */ if (endOffset <= decompStream->beastOffset) { /* no activity is doing on this range */ break; - } - - nextChunkOffset = decompStream->beastOffset + + } + + nextChunkOffset = decompStream->beastOffset + decompStream->beastSize; if (offset >= nextChunkOffset) { /* The reqd file range falls after this chunk */ - continue; + continue; } - /* + /* * If necessary, initiate decompression of all chunks before this chunk * overlapping given file range. */ - rc = startDecompIfNeeded(genMsg, uncompBeast, compBeast, &offset, + rc = startDecompIfNeeded(genMsg, uncompBeast, compBeast, &offset, decompStream->beastOffset, activity, accessMode, grantedRights, wait, writeAfterEOF, &done); if (rc != zOK) @@ -1413,13 +1407,13 @@ checkDecompStatus( if (! keepCompVersion) CM_activityAbort(activity, zFAILURE, FALSE); } - else if (endOffset > (decompStream->beastOffset + activity->sizeDone)) + else if (endOffset > (decompStream->beastOffset + activity->sizeDone)) { /* * Decompression Activity: * the reqd part of the chunk is not yet fully decompressed. */ - if (endOffset < (decompStream->beastOffset + if (endOffset < (decompStream->beastOffset + decompStream->beastSize)) { ADD_UNCOMP_DATA_WAITER(&compInfo->dataWaiters, endOffset); @@ -1427,11 +1421,11 @@ checkDecompStatus( done = FALSE; } offset = nextChunkOffset; -#endif +#endif } /* Initiate decompression of any chunks not already started above */ - rc = startDecompIfNeeded(genMsg, uncompBeast, compBeast, &offset, + rc = startDecompIfNeeded(genMsg, uncompBeast, compBeast, &offset, endOffset, 0, accessMode, grantedRights, wait, writeAfterEOF, &done); if (rc != zOK) return rc; @@ -1448,7 +1442,7 @@ startCompIfNeeded( CMCompDecompParams_s *parms, QUAD *startOffset, /* inout: increment it by byte range processed */ QUAD endOffset, /* Process upto this offset */ - CMActivity_s *enqBeforeActivity) /* EnQ newly created activities + CMActivity_s *enqBeforeActivity) /* EnQ newly created activities * before this */ { STATUS rc = zOK; @@ -1460,7 +1454,7 @@ startCompIfNeeded( ASSERT_MPKNSS_LOCK(); if ((! parms->compInfo) || - (BEAST_UNCOMPRESSED(parms->compInfo) && + (BEAST_UNCOMPRESSED(parms->compInfo) && BEAST_CLEAN(parms->compInfo->p.status))) { /* @@ -1469,7 +1463,7 @@ startCompIfNeeded( * without which we cannot execute the rest of this routine. */ newActivity = enqBeforeActivity; - rc = compressionStart(parms, offset, + rc = compressionStart(parms, offset, GET_DATASTREAM_SIZE(parms->uncompBeast), &newActivity); if (rc != zOK) return rc; @@ -1477,14 +1471,14 @@ startCompIfNeeded( parms->isDone = FALSE; } chunksize = parms->compInfo->p.chunkSize; - if (parms->compInfo->p.chunkSize == 0) + if (parms->compInfo->p.chunkSize == 0) { chunksize = GET_DATASTREAM_SIZE(parms->uncompBeast); } - if (beast_was_uc_clean) + if (beast_was_uc_clean) { - /* - * Update offset to account for the compression activity started above + /* + * Update offset to account for the compression activity started above */ offset = TRUNC(offset + chunksize, chunksize); } @@ -1494,55 +1488,55 @@ startCompIfNeeded( * This for loop won't even be entered in whole-file compression case, * as the only compression activity was already started above. */ - for (; offset < endOffset; - offset = TRUNC(offset + chunksize, chunksize)) + for (; offset < endOffset; + offset = TRUNC(offset + chunksize, chunksize)) { /* A part of the reqd file range falls before this chunk */ NINT status; - if (parms->compInfo->p.chunkSize == 0) + if (parms->compInfo->p.chunkSize == 0) { status = parms->compInfo->p.status; } - else - { - rc = getChunkCompStatus(parms->genMsg, parms->compBeast, + else + { + rc = getChunkCompStatus(parms->genMsg, parms->compBeast, offset, chunksize, &status); if (rc != zOK) break; } - if (CHUNK_COMPRESSED(status)) + if (CHUNK_COMPRESSED(status)) { /* * The chunk is already in compressed state. Good! */ } - else + else { - if (COMP_FAILED(status)) + if (COMP_FAILED(status)) { /* * A previous attempt at compression of this chunk * failed. Return error. */ SetErrno(parms->genMsg, zERR_CM_CANT_COMPRESS); - - /* clean COMP_STATUS_FAILURE so we can try later if - * failure is caused by hardware error + + /* clean COMP_STATUS_FAILURE so we can try later if + * failure is caused by hardware error */ parms->compInfo->p.status &= ~COMP_STATUS_FAILURE; - + rc = zFAILURE; break; } - else + else { /* * This chunk needs to be compressed. */ newActivity = enqBeforeActivity; - rc = compressionStart(parms, offset, chunksize, + rc = compressionStart(parms, offset, chunksize, &newActivity); if (rc != zOK) break; @@ -1572,7 +1566,7 @@ STATUS isSparseFile( { if (getStorageInfo.physicalEOF > getStorageInfo.filePhysSize) { - *isSparse = TRUE; + *isSparse = TRUE; } else { @@ -1589,11 +1583,11 @@ STATUS isSparseFile( STATIC STATUS checkCompStatus( GeneralMsg_s *genMsg, RootBeast_s *uncompBeast, - QUAD offset, + QUAD offset, QUAD size, Xaction_s *xaction, BOOL keepUncompVersion, - BOOL wait, + BOOL wait, BOOL *isDone) /* out */ { STATUS rc; @@ -1606,16 +1600,16 @@ STATIC STATUS checkCompStatus( ASSERT_MPKNSS_LOCK(); if (COMN_IsDerivedFrom(uncompBeast, zFTYPE_NAMED_DATA_STREAM)) - { + { NamedBeast_s *nbeast = (NamedBeast_s *)uncompBeast; - + if ((nbeast->NAMEDattributes & zFA_DO_NOT_COMPRESS_FILE) || (nbeast->NAMEDattributes & zFA_CANT_COMPRESS_DATA_STREAM)) { return zOK; } } - + rc = isSparseFile(genMsg, uncompBeast, &isSparse); if (rc != zOK) { @@ -1626,20 +1620,20 @@ STATIC STATUS checkCompStatus( * Prevent compression of files < CM_MIN_FILE_SIZE_FOR_COMPRESSION in size */ if ((GET_DATASTREAM_SIZE(uncompBeast) < CM_MIN_FILE_SIZE_TO_COMPRESS(uncompBeast)) - || isSparse) - { - + || isSparse) + { + if (COMN_IsDerivedFrom(uncompBeast, zFTYPE_NAMED_DATA_STREAM) && - ! (((NamedBeast_s *)uncompBeast)->NAMEDattributes + ! (((NamedBeast_s *)uncompBeast)->NAMEDattributes & zFA_CANT_COMPRESS_DATA_STREAM)) - { + { Xaction_s *localXaction = COMN_BeginXLocal(uncompBeast); zASSERT(! BEAST_CM_INFO(uncompBeast)); ((NamedBeast_s *)uncompBeast)->NAMEDattributes |= zFA_CANT_COMPRESS_DATA_STREAM; - INC_VOLUME_UNCOMPRESSIBLE_FILES(((NamedBeast_s *)uncompBeast), + INC_VOLUME_UNCOMPRESSIBLE_FILES(((NamedBeast_s *)uncompBeast), localXaction); - + /* update the statistics */ CHANGE_COMP_STATS_UNCOMPRESSIBLE_FILES(1); @@ -1650,12 +1644,12 @@ STATIC STATUS checkCompStatus( ClearErrno(genMsg); } COMN_EndXLocal(uncompBeast, &localXaction); - } - + } + /* can't compress due to small file size is not an error */ return zOK; } - + parms.genMsg = genMsg; parms.uncompBeast = uncompBeast; parms.keepSrcVersion = keepUncompVersion; @@ -1665,9 +1659,9 @@ STATIC STATUS checkCompStatus( parms.compBeast = 0; parms.compInfo = BEAST_CM_INFO(parms.uncompBeast); parms.isDone = TRUE; - - if (parms.compInfo) - { + + if (parms.compInfo) + { if (parms.compInfo->p.action & COMP_ACTION_ENABLE_IO_WRITE) { /* enable_io is going on, no need to do compression */ @@ -1678,8 +1672,8 @@ STATIC STATUS checkCompStatus( zASSERT(parms.compInfo->p.compZid != zINVALID_ZID); if (parms.compInfo->p.compZid != zINVALID_ZID) { - parms.compBeast = CM_LookupCompBeast(parms.genMsg, parms.uncompBeast, - parms.compInfo, XLATCHED); + parms.compBeast = CM_LookupCompBeast(parms.genMsg, parms.uncompBeast, + parms.compInfo, XLATCHED); if (parms.compBeast == 0) { rc = zFAILURE; @@ -1691,32 +1685,32 @@ STATIC STATUS checkCompStatus( rc = zFAILURE; goto functionExit; } - + chunksize = parms.compInfo->p.chunkSize; nextChunkOffset = 0; - if (chunksize == 0) + if (chunksize == 0) { offset = 0; chunksize = GET_DATASTREAM_SIZE(parms.uncompBeast); } - else + else { offset = TRUNC(offset, chunksize); } - - DQ_FOREACH_SAFE(&parms.compInfo->CM_activities, activity, tmpActivity, + + DQ_FOREACH_SAFE(&parms.compInfo->CM_activities, activity, tmpActivity, CMActivity_s, beastActivitiesChain) { CMStream_s *decompStream; - + decompStream = &activity->decompStream; - - if ((offset >= decompStream->beastOffset) && + + if ((offset >= decompStream->beastOffset) && (endOffset <= decompStream->beastSize)) - { + { if (activity->op == CM_ACTIVITY_OP_COMPRESS) { - /* there is an activity doing the same thing */ + /* there is an activity doing the same thing */ *isDone = FALSE; rc = zOK; goto functionExit; @@ -1729,9 +1723,9 @@ STATIC STATUS checkCompStatus( * available. Somebody is trying to access the file. abort * compression. */ - zASSERT(!(BEAST_UNCOMPRESSED(parms.compInfo))); + zASSERT(!(BEAST_UNCOMPRESSED(parms.compInfo))); SetErrno(parms.genMsg, zERR_CM_ABORTED); - *isDone = TRUE; + *isDone = TRUE; rc = zFAILURE; goto functionExit; } @@ -1740,30 +1734,30 @@ STATIC STATUS checkCompStatus( #if 0 /* FixFixFix6 the rest part of this is checking for chunky compression. * It needs to be fixed when NSS supports chunky compression - */ + */ if (endOffset <= decompStream->beastOffset) { /* We are done */ break; } - nextChunkOffset = decompStream->beastOffset + + nextChunkOffset = decompStream->beastOffset + decompStream->beastSize; if (offset >= nextChunkOffset) { /* The reqd file range falls after this chunk */ continue; } - - /* + + /* * If necessary, initiate decompression of all chunks before this * chunk overlapping given file range. */ - rc = startCompIfNeeded(&parms, &offset, decompStream->beastOffset, + rc = startCompIfNeeded(&parms, &offset, decompStream->beastOffset, activity); if (rc != zOK) goto functionExit; - - /* + + /* * A portion of overlaps with this activity's chunk */ offset += chunksize; @@ -1777,14 +1771,14 @@ STATIC STATUS checkCompStatus( */ if (BEAST_IMM_COMPRESS(parms.uncompBeast)) continue; - else + else { SetErrno(parms.genMsg, zERR_CM_ABORTED); rc = zFAILURE; goto functionExit; } } - else + else { /* * Compression Activity: @@ -1792,15 +1786,15 @@ STATIC STATUS checkCompStatus( */ parms.isDone = FALSE; } -#endif +#endif } } /* Initiate compression of any chunks not already started above */ - rc = startCompIfNeeded(&parms, &offset, endOffset, 0); + rc = startCompIfNeeded(&parms, &offset, endOffset, 0); *isDone = parms.isDone; -functionExit: +functionExit: if (parms.compBeast) { COMN_UnlatchAndRelease(&parms.compBeast, XLATCHED); @@ -1828,7 +1822,7 @@ STATUS decompress ( do { rc = CM_uncompressFileRange( &genMsg, beast, - offset, numBytes, CACHE_READ, latchType, 0, + offset, numBytes, CACHE_READ, latchType, 0, grantedRights, TRUE, &done); if (rc != zOK) @@ -1846,7 +1840,7 @@ STATUS decompressNoRights ( NINT numBytes) { NINT grantedRights = 0; - + return decompress(beast, &grantedRights, offset, numBytes); } @@ -1863,7 +1857,7 @@ void addLeaveCompressedToGrantedRights( { fh->grantedRights |= zRR_LEAVE_FILE_COMPRESSED; } - } + } } BOOL CM_isBeastUncompressed( @@ -1878,9 +1872,9 @@ BOOL CM_isBeastUncompressed( /* WARNING: Caller MUST not hold fileSnapshotBeast's latch */ STATUS CM_uncompressFileRange( GeneralMsg_s *genMsg, - RootBeast_s *uncompBeast, - QUAD offset, - QUAD size, + RootBeast_s *uncompBeast, + QUAD offset, + QUAD size, NINT accessMode, NINT latchType, Xaction_s *xaction, @@ -1898,19 +1892,19 @@ STATUS CM_uncompressFileRange( if (COMN_IsDerivedFrom(uncompBeast, zFTYPE_COMPRESSION) || COMN_IsDerivedFrom(uncompBeast, zFTYPE_COMPRESSION_INTERMEDIATE)) - { + { *isDone = TRUE; return zOK; } - if (isSlatched) + if (isSlatched) { // in order to solve backup performance issue, we check for compInfo here. // This should be safe because any place that changes compInfo will have - // uncompBeast xlatched in advance. - // + // uncompBeast xlatched in advance. + // compInfo = BEAST_CM_INFO(uncompBeast); - if ((!compInfo) || + if ((!compInfo) || (!BEAST_COMPRESSED(compInfo) && DQ_EMPTY(&compInfo->CM_activities))) { *isDone = TRUE; @@ -1921,55 +1915,55 @@ STATUS CM_uncompressFileRange( UPLATCH_BEAST(uncompBeast); } } - else if (! islatched) + else if (! islatched) { XLATCH_BEAST(uncompBeast); } else { ASSERT_XLATCH(&uncompBeast->ROOTbeastLatch); - } - - for(;;) + } + + for(;;) { *isDone = TRUE; compInfo = BEAST_CM_INFO(uncompBeast); - if ((!compInfo) || + if ((!compInfo) || (!BEAST_COMPRESSED(compInfo) && DQ_EMPTY(&compInfo->CM_activities))) { goto rcRet; } zASSERT(compInfo->p.compZid != zINVALID_ZID); - compBeast = (RootBeast_s *)CM_LookupCompBeast(genMsg, uncompBeast, - compInfo, XLATCHED); - if (compBeast == 0) + compBeast = (RootBeast_s *)CM_LookupCompBeast(genMsg, uncompBeast, + compInfo, XLATCHED); + if (compBeast == 0) { rc = zFAILURE; goto rcRet; } - + /* * Initiate decompression of requisite chunks. * Wait for decompression to finish (if wait == true). */ rc = checkDecompStatus(genMsg, uncompBeast, compBeast, offset, size, - accessMode, grantedRights, wait, isDone); - if ((rc != zOK) || *isDone) - { + accessMode, grantedRights, wait, isDone); + if ((rc != zOK) || *isDone) + { *isDone = TRUE; break; } - if (wait) - { + if (wait) + { COMN_UnlatchAndRelease(&compBeast, XLATCHED); compBeast = 0; UNXLATCH_BEAST(uncompBeast); rc = CM_awaitEvent((ADDR)&compInfo->CM_activities); XLATCH_BEAST(uncompBeast); - if (rc != zOK) + if (rc != zOK) { if (rc == zERR_CM_ABORTED) { @@ -1977,8 +1971,8 @@ STATUS CM_uncompressFileRange( } else { - /* clean COMP_STATUS_FAILURE so we can try later if - * failure is caused by hardware error + /* clean COMP_STATUS_FAILURE so we can try later if + * failure is caused by hardware error */ compInfo->p.status &= ~COMP_STATUS_FAILURE; @@ -1994,17 +1988,17 @@ STATUS CM_uncompressFileRange( break; } } - + if (compBeast) COMN_UnlatchAndRelease(&compBeast, XLATCHED); -rcRet: +rcRet: if ((accessMode != CACHE_READ) && (rc == zOK) && (*isDone)) { BOOL tossCompBeast = (*grantedRights & zRR_LEAVE_FILE_COMPRESSED) ? FALSE : TRUE; compInfo = BEAST_CM_INFO(uncompBeast); - + if (compInfo && (!BEAST_UNCOMPRESSED(compInfo) || tossCompBeast)) { zASSERT(!BEAST_COMPRESSED(compInfo)); @@ -2014,32 +2008,32 @@ rcRet: } } - if (isSlatched) + if (isSlatched) { DOWNLATCH_BEAST(uncompBeast); } - else if (! islatched) + else if (! islatched) { UNXLATCH_BEAST(uncompBeast); - } + } else { ASSERT_XLATCH(&uncompBeast->ROOTbeastLatch); - } - + } + return rc; } /* * Currently this routine is not called from anywhere. * The function CM_compressFileAsync is called instead. - * WARNING: Caller MUST not hold fileSnapshotBeast's latch + * WARNING: Caller MUST not hold fileSnapshotBeast's latch */ -STATUS +STATUS CM_compressFileRange( GeneralMsg_s *genMsg, - RootBeast_s *uncompBeast, - QUAD offset, + RootBeast_s *uncompBeast, + QUAD offset, QUAD size, NINT latchType, Xaction_s *xaction, @@ -2055,19 +2049,19 @@ CM_compressFileRange( ASSERT_MPKNSS_LOCK(); - if (isSlatched) + if (isSlatched) { UPLATCH_BEAST(uncompBeast); } - else if (! islatched) + else if (! islatched) { XLATCH_BEAST(uncompBeast); } else { ASSERT_XLATCH(&uncompBeast->ROOTbeastLatch); - } - + } + if ((uncompBeast->bstState & BST_STATE_PURGING) || COMN_IsDerivedFrom(uncompBeast, zFTYPE_COMPRESSION) || COMN_IsDerivedFrom(uncompBeast, zFTYPE_COMPRESSION_INTERMEDIATE)) @@ -2075,10 +2069,10 @@ CM_compressFileRange( goto Exit; } - for(;;) + for(;;) { /* Initiate compression of requisite chunks. */ - rc = checkCompStatus(genMsg, uncompBeast, offset, size, + rc = checkCompStatus(genMsg, uncompBeast, offset, size, xaction, keepUncompVersion, wait, isDone); if ((rc != zOK) || (*isDone) || (! wait)) { @@ -2091,7 +2085,7 @@ CM_compressFileRange( UNXLATCH_BEAST(uncompBeast); rc = CM_awaitEvent((ADDR)&compInfo->CM_activities); XLATCH_BEAST(uncompBeast); - if (rc != zOK) + if (rc != zOK) { SetErrno(genMsg, rc); rc = zFAILURE; @@ -2105,7 +2099,7 @@ CM_compressFileRange( */ if ((GetErrno(genMsg) == zERR_NO_MEMORY) && ! wait) { - rc = CM_enqueueCompressRequest(uncompBeast->ROOTvolume, + rc = CM_enqueueCompressRequest(uncompBeast->ROOTvolume, uncompBeast->zid, reason); if (rc != zOK) { @@ -2119,25 +2113,25 @@ CM_compressFileRange( } Exit: - if (isSlatched) + if (isSlatched) { DOWNLATCH_BEAST(uncompBeast); } - else if (! islatched) + else if (! islatched) { UNXLATCH_BEAST(uncompBeast); } else { ASSERT_XLATCH(&uncompBeast->ROOTbeastLatch); - } + } return rc; } STATUS CM_compressFileAsync( GeneralMsg_s *genMsg, - RootBeast_s *uncompBeast, + RootBeast_s *uncompBeast, NINT latchType, NINT reason) { @@ -2150,19 +2144,19 @@ STATUS CM_compressFileAsync( ASSERT_MPKNSS_LOCK(); - if (isSlatched) + if (isSlatched) { UPLATCH_BEAST(uncompBeast); } - else if (! islatched) + else if (! islatched) { XLATCH_BEAST(uncompBeast); } else { ASSERT_XLATCH(&uncompBeast->ROOTbeastLatch); - } - + } + if ((uncompBeast->bstState & BST_STATE_PURGING) || COMN_IsDerivedFrom(uncompBeast, zFTYPE_COMPRESSION) || COMN_IsDerivedFrom(uncompBeast, zFTYPE_COMPRESSION_INTERMEDIATE)) @@ -2184,7 +2178,7 @@ STATUS CM_compressFileAsync( && !NAME_AllNamesInSalvage(uncompBeast) && ((NamedBeast_s *)uncompBeast)->NAMEDopenCount != 0) { - /* beast is not deleted, and there's something else accessing the file, + /* beast is not deleted, and there's something else accessing the file, don't need to compress it */ goto Exit; } @@ -2192,7 +2186,7 @@ STATUS CM_compressFileAsync( if (CM_curCompControlParams.compEnabled) { /* Initiate compression of requisite chunks. */ - rc = checkCompStatus(genMsg, uncompBeast, 0, + rc = checkCompStatus(genMsg, uncompBeast, 0, GET_DATASTREAM_SIZE(uncompBeast), 0, FALSE, FALSE, &isDone); } @@ -2203,7 +2197,7 @@ STATUS CM_compressFileAsync( if ((! CM_curCompControlParams.compEnabled) || ((rc != zOK) && (GetErrno(genMsg) == zERR_NO_MEMORY))) { - rc = CM_enqueueCompressRequest(uncompBeast->ROOTvolume, + rc = CM_enqueueCompressRequest(uncompBeast->ROOTvolume, uncompBeast->zid, reason); if (rc != zOK) { @@ -2217,18 +2211,18 @@ STATUS CM_compressFileAsync( } Exit: - if (isSlatched) + if (isSlatched) { DOWNLATCH_BEAST(uncompBeast); } - else if (! islatched) + else if (! islatched) { UNXLATCH_BEAST(uncompBeast); } else { ASSERT_XLATCH(&uncompBeast->ROOTbeastLatch); - } + } return rc; } @@ -2245,23 +2239,23 @@ void CM_abortBeastActivities(RootBeast_s *beast, BOOL wait) { return; } - + /* remove this beast from compress waiting queue. It is possible * that beast be enqueued for several times */ CM_removeBeastCompressRequest(beast); - /* + /* * beast is not in compress waiting queue, so it might * have compression/decompression activities going on */ - for (;;) + for (;;) { compInfo = BEAST_CM_INFO(beast); if (! compInfo) return; - - /* - * abort all ongoing compression/decompression activities + + /* + * abort all ongoing compression/decompression activities * on this beast */ waitCount = 0; @@ -2285,7 +2279,7 @@ void CM_abortBeastActivities(RootBeast_s *beast, BOOL wait) * Given beast is about to be fully truncated; * Cleanup its compression-related state. * beast must be XLATCHED. - * WARNING: Caller MUST not hold fileSnapshotBeast's latch + * WARNING: Caller MUST not hold fileSnapshotBeast's latch */ STATUS CM_prepareToTruncateFile( GeneralMsg_s *genMsg, @@ -2304,7 +2298,7 @@ STATUS CM_prepareToTruncateFile( { return zOK; } - + /* First, abort all ongoing activities on the beast and wait for them to * finish */ CM_abortBeastActivities(uncompBeast, TRUE); @@ -2312,30 +2306,30 @@ STATUS CM_prepareToTruncateFile( // setBeastCompAttr(uncompBeast, 0, NULL, TRUE); compInfo = BEAST_CM_INFO(uncompBeast); - if ((! compInfo) || + if ((! compInfo) || (BEAST_UNCOMPRESSED(compInfo) && BEAST_CLEAN(compInfo->p.status))) { localXaction = COMN_BeginXLocal(uncompBeast); - + setBeastCompAttr(uncompBeast, 0, localXaction, TRUE); COMN_EndXLocal(uncompBeast, &localXaction); - + return zOK; } zASSERT(compInfo->p.compZid != zINVALID_ZID); - + compBeast = (RootBeast_s *)CM_LookupCompBeast(genMsg, uncompBeast, compInfo, - XLATCHED); + XLATCHED); if (compBeast == 0) { return zFAILURE; } - - if (! BEAST_UNCOMPRESSED(compInfo)) + + if (! BEAST_UNCOMPRESSED(compInfo)) { /* File is not fully uncompressed */ - if (BEAST_CLEAN(compInfo->p.status)) + if (BEAST_CLEAN(compInfo->p.status)) { rc = decompSetup(genMsg, uncompBeast, NULL); if (rc != zOK) @@ -2347,7 +2341,7 @@ STATUS CM_prepareToTruncateFile( localXaction = COMN_BeginXLocal(uncompBeast); if (BEAST_COMPRESSED(compInfo)) { - /* modify compression stats if its fully compressed */ + /* modify compression stats if its fully compressed */ setBeastCompAttr(uncompBeast, 0, localXaction, TRUE); setVolCompStats(uncompBeast, compBeast, localXaction, FALSE); } @@ -2359,7 +2353,7 @@ STATUS CM_prepareToTruncateFile( /* Now the beast is in UC_unclean state; Move it to UC_clean state */ zASSERT(! BEAST_CLEAN(compInfo->p.status)); - + rc = decompCleanup(genMsg, uncompBeast, compBeast, recovery, localXaction); if (rc == zOK) { @@ -2370,7 +2364,7 @@ STATUS CM_prepareToTruncateFile( return rc; } -rcRet: +rcRet: if (localXaction) { COMN_EndXLocal(uncompBeast, &localXaction); @@ -2388,12 +2382,12 @@ CM_prepareToAccessUncompFile( BOOL *keepCompVersion) /* inout */ { CompressInfo_s *compInfo = BEAST_CM_INFO(uncompBeast); - + ASSERT_MPKNSS_LOCK(); /* Clear CANT_COMPRESS flag if file opened for write */ if (COMN_IsDerivedFrom(uncompBeast, zFTYPE_NAMED_DATA_STREAM)) - { + { if (accessMode != CACHE_READ) { NamedBeast_s *nbeast = (NamedBeast_s *)uncompBeast; @@ -2408,7 +2402,7 @@ CM_prepareToAccessUncompFile( nbeast->NAMEDattributes &= ~zFA_CANT_COMPRESS_DATA_STREAM; COMN_MARK_BEAST_DIRTY(uncompBeast); } - } + } else if (COMN_IsDerivedFrom(uncompBeast, zFTYPE_COMPRESSION) || COMN_IsDerivedFrom(uncompBeast, zFTYPE_COMPRESSION_INTERMEDIATE)) { @@ -2416,21 +2410,21 @@ CM_prepareToAccessUncompFile( *keepCompVersion = FALSE; return zOK; } - + if (BEAST_DO_NOT_COMPRESS(uncompBeast)) { /* Always keep not compressed */ *keepCompVersion = FALSE; return zOK; - } + } if (BEAST_IMM_COMPRESS(uncompBeast)) { /* Always keep compressed */ *keepCompVersion = TRUE; - } - - if (!compInfo) + } + + if (!compInfo) { /* there's no compressed file */ return zOK; @@ -2452,15 +2446,15 @@ CM_prepareToAccessUncompFile( SLONG idleTime = GetUTCTime() - file->FILEaccessedTime; if (idleTime >= CM_curCompControlParams.minFileIdleTime) { - /* + /* * File accessed long ago * Same as DECOMP_OPTION_LEAVE_DECOMPRESSED */ *keepCompVersion = TRUE; } - else - { - /* + else + { + /* * File accessed again after a short interval * Same as DECOMP_OPTION_CHANGE_TO_DECOMPRESSED */ @@ -2470,7 +2464,7 @@ CM_prepareToAccessUncompFile( } case DECOMP_OPTION_CHANGE_TO_DECOMPRESSED: *keepCompVersion = FALSE; - default: + default: break; } @@ -2481,16 +2475,16 @@ void CM_uncompFileAccessDone( GeneralMsg_s *genMsg, RootBeast_s *uncompBeast) { - STATUS rc; + STATUS rc; CompressInfo_s *compInfo; ASSERT_MPKNSS_LOCK(); zASSERT(IS_XLATCHED(&uncompBeast->ROOTbeastLatch)); - compInfo = BEAST_CM_INFO(uncompBeast); - if (compInfo && (BEAST_COMPRESSED(compInfo) || + compInfo = BEAST_CM_INFO(uncompBeast); + if (compInfo && (BEAST_COMPRESSED(compInfo) || !CM_checkParentDirForCompressOK(genMsg, (File_s*)uncompBeast))) - { + { return; } @@ -2503,11 +2497,11 @@ void CM_uncompFileAccessDone( zASSERT(!BEAST_COMPRESSED(compInfo)); if (COMN_IsDerivedFrom(uncompBeast, zFTYPE_NAMED_DATA_STREAM) - && !NAME_AllNamesInSalvage(uncompBeast) - && ((NamedBeast_s *)uncompBeast)->NAMEDopenCount != 0) + && !NAME_AllNamesInSalvage(uncompBeast) + && ((NamedBeast_s *)uncompBeast)->NAMEDopenCount != 0) { - /* beast is not deleted, and there's something else accessing the file, - through away its compressed data, keep it uncompressed */ + /* beast is not deleted, and there's something else accessing the file, + through away its compressed data, keep it uncompressed */ rc = CM_tossCompBeastData(genMsg, uncompBeast, TRUE); } else @@ -2524,7 +2518,7 @@ void CM_uncompFileAccessDone( } /* - * retCompBeast is returned slatched + * retCompBeast is returned slatched */ STATUS CM_prepareToAccessCompFile( GeneralMsg_s *genMsg, @@ -2539,32 +2533,32 @@ STATUS CM_prepareToAccessCompFile( zASSERT(!COMN_IsDerivedFrom(uncompBeast, zFTYPE_COMPRESSION) && !COMN_IsDerivedFrom(uncompBeast, zFTYPE_COMPRESSION_INTERMEDIATE)); - if ((! compInfo) || (! BEAST_COMPRESSED(compInfo))) + if ((! compInfo) || (! BEAST_COMPRESSED(compInfo))) { /* Not fully compressed; return the uncompressed stream */ *retCompBeast = 0; return zOK; } - else + else { zASSERT(compInfo->p.compZid != zINVALID_ZID); - compBeast = (RootBeast_s *)CM_LookupCompBeast(genMsg, uncompBeast, - compInfo, SLATCHED); + compBeast = (RootBeast_s *)CM_LookupCompBeast(genMsg, uncompBeast, + compInfo, SLATCHED); if (compBeast == 0) { return zFAILURE; } - if (BEAST_COMPRESSED(compInfo)) + if (BEAST_COMPRESSED(compInfo)) { /* Fully compressed; return the compressed stream */ zASSERT(compInfo->p.Cprecious != 0); - + compInfo->p.action &= ~COMP_ACTION_ENABLE_IO_WRITE; *retCompBeast = compBeast; return zOK; } - else + else { /* * Partially compressed @@ -2581,7 +2575,7 @@ STATUS CM_prepareToAccessCompFile( * Called before overwriting the compressed stream of a file. * We throw all file data and pretend as if we are starting compression on the * file, except that the compressed data is going to be written directly. - * retCompBeast is returned xlatched + * retCompBeast is returned xlatched */ STATUS CM_prepareToWriteCompFile( GeneralMsg_s *genMsg, @@ -2592,44 +2586,44 @@ STATUS CM_prepareToWriteCompFile( CompressInfo_s *compInfo = BEAST_CM_INFO(uncompBeast); // RootBeast_s *compBeast = NULL; Xaction_s *localXaction; - + ASSERT_MPKNSS_LOCK(); ASSERT_XLATCH(&uncompBeast->ROOTbeastLatch); - + /* First, abort all ongoing activities on the beast; * Wait till they all terminate */ CM_abortBeastActivities(uncompBeast, TRUE); - + /* * If we had a write previously: - * compInfo won't be clean; - * If we only had a read or did nothing previously: + * compInfo won't be clean; + * If we only had a read or did nothing previously: * a: compInfo == NULL || UCprecious != 0 => no compBeast * b: UCprecious == 0 (implies Cprecious != 0) => compBeast * - * After this function is returned, the beast is forced to UC_unclean state. + * After this function is returned, the beast is forced to UC_unclean state. */ - if ((!compInfo) || - (BEAST_UNCOMPRESSED(compInfo) && BEAST_CLEAN(compInfo->p.status))) - { + if ((!compInfo) || + (BEAST_UNCOMPRESSED(compInfo) && BEAST_CLEAN(compInfo->p.status))) + { zASSERT(*retCompBeast == NULL); if (compInfo && BEAST_UNCOMPRESSED(compInfo)) { /* Cprecious == 0 */ zASSERT(compInfo->p.UCprecious != 0); } - + /* beast in UC_clean state, move it to UC_unclean state */ if (compInfo && compInfo->p.compZid != zINVALID_ZID) { - *retCompBeast = CM_LookupCompBeast(genMsg, uncompBeast, compInfo, + *retCompBeast = CM_LookupCompBeast(genMsg, uncompBeast, compInfo, XLATCHED); - if (*retCompBeast == NULL) + if (*retCompBeast == NULL) { return zFAILURE; } } - + rc = compSetup(genMsg, uncompBeast, retCompBeast, 0); if (rc != zOK) { @@ -2639,9 +2633,9 @@ STATUS CM_prepareToWriteCompFile( } return rc; } - + localXaction = COMN_BeginXLocal(uncompBeast); - + compInfo = BEAST_CM_INFO(uncompBeast); compInfo->p.UCprecious = 0; compInfo->p.action |= COMP_ACTION_ENABLE_IO_WRITE; @@ -2649,7 +2643,7 @@ STATUS CM_prepareToWriteCompFile( COMN_MARK_BEAST_XLOCAL(uncompBeast, localXaction); rc = COMN_ForceBeastWrite(genMsg, uncompBeast, localXaction); COMN_EndXLocal(uncompBeast, &localXaction); - + if (rc != zOK) { zASSERT("COMN_ForceBeastWrite failed" == 0); @@ -2659,31 +2653,31 @@ STATUS CM_prepareToWriteCompFile( } return rc; } - - + + zASSERT(*retCompBeast != 0); } - else + else { BOOL releaseCompBeast = FALSE; - + if ((compInfo->p.action & COMP_ACTION_ENABLE_IO_WRITE) && (*retCompBeast != NULL)) { - /* we've been here before */ + /* we've been here before */ zASSERT(!BEAST_CLEAN(compInfo->p.status)); - zASSERT(*retCompBeast != NULL); - + zASSERT(*retCompBeast != NULL); + XLATCH_BEAST(*retCompBeast); - + return zOK; } - + if (*retCompBeast == NULL) { zASSERT(compInfo->p.compZid != zINVALID_ZID); - - *retCompBeast = (RootBeast_s *)CM_LookupCompBeast(genMsg, + + *retCompBeast = (RootBeast_s *)CM_LookupCompBeast(genMsg, uncompBeast, compInfo, XLATCHED); if (*retCompBeast == NULL) { @@ -2696,19 +2690,19 @@ STATUS CM_prepareToWriteCompFile( ASSERT_NOLATCH(&(*retCompBeast)->ROOTbeastLatch); X_LATCH(&(*retCompBeast)->ROOTbeastLatch); } - - if (! BEAST_UNCOMPRESSED(compInfo)) + + if (! BEAST_UNCOMPRESSED(compInfo)) { /* The beast is not fully uncompressed */ /* Force the beast to UC_unclean state */ - if (BEAST_CLEAN(compInfo->p.status)) + if (BEAST_CLEAN(compInfo->p.status)) { rc = decompSetup(genMsg, uncompBeast, 0); - if (rc != zOK) + if (rc != zOK) { if (releaseCompBeast) { - COMN_UnlatchAndRelease(retCompBeast, XLATCHED); + COMN_UnlatchAndRelease(retCompBeast, XLATCHED); } else { @@ -2717,7 +2711,7 @@ STATUS CM_prepareToWriteCompFile( return rc; } } - + localXaction = COMN_BeginXLocal(uncompBeast); /* Modify compression related stats if beast is fully compressed */ @@ -2726,22 +2720,22 @@ STATUS CM_prepareToWriteCompFile( setBeastCompAttr(uncompBeast, 0, localXaction, FALSE); setVolCompStats(uncompBeast, *retCompBeast, localXaction, FALSE); } - + compInfo->p.UCprecious = 0; compInfo->p.Cprecious = 0; compInfo->p.action |= COMP_ACTION_ENABLE_IO_WRITE; COMN_MARK_BEAST_XLOCAL(uncompBeast, localXaction); rc = COMN_ForceBeastWrite(genMsg, uncompBeast, localXaction); - + if (rc != zOK) { zASSERT("COMN_ForceBeastWrite failed" == 0); COMN_EndXLocal(uncompBeast, &localXaction); - + if (releaseCompBeast) { - COMN_UnlatchAndRelease(retCompBeast, XLATCHED); + COMN_UnlatchAndRelease(retCompBeast, XLATCHED); } else { @@ -2760,9 +2754,9 @@ STATUS CM_prepareToWriteCompFile( cacheTruncateMyCache(&uncompBeast->ROOTmycache, 0, -1); (void)uncompBeast->ROOTcomnOps.BST_truncateFile(genMsg, uncompBeast, 0, -1); - + ASSERT_XLATCH(&(*retCompBeast)->ROOTbeastLatch); - + return zOK; } @@ -2788,24 +2782,24 @@ STATUS CM_accessCompFileDone1( ASSERT_MPKNSS_LOCK(); ASSERT_XLATCH(&uncompBeast->ROOTbeastLatch); - - if (!compBeast) + + if (!compBeast) { /* the file has no compressed data and only opened for read */ return zOK; } compInfo = BEAST_CM_INFO(uncompBeast); - + /* It could happen when compBeast is not NULL but compInfo is NULL. * This situation happens: * time 1: client1 requests zRR_ENABLE_IO_ON_COMPRESSED_DATA|zRR_DENY_WRITE - |zRR_READ_ACCESS to read compressed data, for example, backs up the file - * time 2: client2 requests zRR_READ_ACCESS to read uncompressed data. If + |zRR_READ_ACCESS to read compressed data, for example, backs up the file + * time 2: client2 requests zRR_READ_ACCESS to read uncompressed data. If * file hasn't been touched for a long time, file will be decompressed * and compInfo will be tossed away. CompBeast is still kept in memory * because of non-zero useCount. - * time 3: client1 closes file. + * time 3: client1 closes file. */ if (!compInfo || !(compInfo->p.action & COMP_ACTION_ENABLE_IO_WRITE)) @@ -2821,8 +2815,8 @@ STATUS CM_accessCompFileDone1( if (compBeast->bstState & BST_STATE_TRUNCATE_CLOSE) { - Blknum_t eofBlock = (compBeast->ROOTeof + - (QUAD)((1 << compBeast->ROOTblkSizeShift)-1)) >> + Blknum_t eofBlock = (compBeast->ROOTeof + + (QUAD)((1 << compBeast->ROOTblkSizeShift)-1)) >> compBeast->ROOTblkSizeShift; compBeast->bstState &= ~BST_STATE_TRUNCATE_CLOSE; @@ -2833,21 +2827,21 @@ STATUS CM_accessCompFileDone1( ClearErrno(genMsg); } } - + UNXLATCH_BEAST(compBeast); - - BST_flush(compBeast); - + + BST_flush(compBeast); + XLATCH_BEAST(compBeast); - + localXaction = COMN_BeginXLocal(uncompBeast); - + cmbuf = CM_fetchFileBlk(genMsg, compBeast, 0, CACHE_READ, 0); if (!cmbuf) { rc = zFAILURE; goto cleanupExit; - } + } mapBufferPage(cmbuf); compInfo->p.UCprecious = 0; compInfo->p.status &= ~COMP_STATUS_UNCOMPRESSED; @@ -2855,22 +2849,22 @@ STATUS CM_accessCompFileDone1( fileHdr = (CompFileHdr_s *)cmbuf->pBuf.data; if (cmbuf == &CACHE_SparseBuffer /* we had just set compBeast's EOF */ - || IS_COMPFILE_LAYOUT_NETWARE(fileHdr->fileLayout_ID)) + || IS_COMPFILE_LAYOUT_NETWARE(fileHdr->fileLayout_ID)) { compInfo->p.chunkSize = 0; compInfo->p.Cprecious = 1; } - else if (IS_COMPFILE_LAYOUT_NSS(fileHdr->fileLayout_ID)) + else if (IS_COMPFILE_LAYOUT_NSS(fileHdr->fileLayout_ID)) { compInfo->p.chunkSize = fileHdr->chunkSize; /* First force the uncompBeast into C_unclean state */ - if (compInfo->p.chunkSize != 0) + if (compInfo->p.chunkSize != 0) { compInfo->p.Cprecious = fileHdr->nvalidChunks; } else compInfo->p.Cprecious = 1; } - else + else { zASSERT("Compressed file just written has an unsupported format" == 0); SetErrno(genMsg, zERR_UNSUPPORTED_OBJECT_LAYOUT); @@ -2891,7 +2885,7 @@ STATUS CM_accessCompFileDone1( setBeastCompAttr(uncompBeast, zFA_DATA_STREAM_IS_COMPRESSED, localXaction, FALSE); setVolCompStats(uncompBeast, compBeast, localXaction, TRUE); - + /* Move the uncompBeast into C_clean state */ rc = compCleanup(genMsg, uncompBeast, compBeast, recovery, &localXaction); if (rc != zOK) @@ -2900,17 +2894,17 @@ STATUS CM_accessCompFileDone1( { localXaction = COMN_BeginXLocal(uncompBeast); } - + setBeastCompAttr(uncompBeast, 0, localXaction, TRUE); setVolCompStats(uncompBeast, compBeast, localXaction, FALSE); } - -cleanupExit: + +cleanupExit: if (localXaction) { COMN_EndXLocal(uncompBeast, &localXaction); } - + if (compBeast) { COMN_UnlatchAndRelease(&compBeast, XLATCHED); @@ -2934,7 +2928,7 @@ STATUS CM_accessCompFileDone( STATUS CM_cleanupBeast( GeneralMsg_s *genMsg, - RootBeast_s *uncompBeast, + RootBeast_s *uncompBeast, Xaction_s *xaction) { STATUS rc = zOK; @@ -2945,35 +2939,35 @@ STATUS CM_cleanupBeast( ASSERT_MPKNSS_LOCK(); zASSERT(xaction == NULL); - + if ((! compInfo) || BEAST_CLEAN(compInfo->p.status)) return zOK; zASSERT(compInfo->p.compZid != zINVALID_ZID); compBeast = (RootBeast_s *)CM_LookupCompBeast(genMsg, uncompBeast, compInfo, - XLATCHED); + XLATCHED); if (compBeast == 0) return zFAILURE; - + /* since it only happens during the recovery stage, we know that * the previous compression/decompression is not finished * successfully. We don't need to modify volume compression block stats, * however, we should roll back beast compression attributes because * we have them cleared during the setup stage - */ + */ // if (compInfo->p.action & COMP_ACTION_ENABLE_IO_WRITE) // { // UNXLATCH_BEAST(compBeast); // return CM_accessCompFileDone1(genMsg, uncompBeast, compBeast, TRUE); // } // else -// { - if ((compInfo->p.Cprecious == 0 && compInfo->p.UCprecious == 0) - || (compInfo->p.Cprecious == 0 && compInfo->p.UCprecious == 1)) - { +// { + if ((compInfo->p.Cprecious == 0 && compInfo->p.UCprecious == 0) + || (compInfo->p.Cprecious == 0 && compInfo->p.UCprecious == 1)) + { localXaction = (xaction != NULL) ? xaction : COMN_BeginXLocal(uncompBeast); - + setBeastCompAttr(uncompBeast, 0, localXaction, FALSE); - + rc = decompCleanup(genMsg, uncompBeast, compBeast, TRUE, xaction); if (rc == zOK) { @@ -2985,11 +2979,11 @@ STATUS CM_cleanupBeast( } } else if (compInfo->p.Cprecious == 1 && compInfo->p.UCprecious == 0) - { + { localXaction = (xaction != NULL) ? xaction : COMN_BeginXLocal(uncompBeast); - + setBeastCompAttr(uncompBeast, zFA_DATA_STREAM_IS_COMPRESSED, localXaction, TRUE); - + rc = compCleanup(genMsg, uncompBeast, compBeast, TRUE, NULL); if (!xaction) @@ -3003,15 +2997,15 @@ STATUS CM_cleanupBeast( * xaction should be NULL if this is the case */ zASSERT(xaction == NULL); - + rc = CM_tossUncompBeastData(genMsg, uncompBeast, compBeast, TRUE); } // } zASSERT(!(compInfo->p.action & COMP_ACTION_ADD_COMPLOG)); - + if (compBeast) { - COMN_UnlatchAndRelease(&compBeast, XLATCHED); + COMN_UnlatchAndRelease(&compBeast, XLATCHED); } return rc; } @@ -3036,21 +3030,21 @@ STATUS CM_volumeActivate(Volume_s *volume) displayFileCounts(); UNX_LATCH(&CM_curCompStatistics.latch); - volume->cmVolumeState.compActive = TRUE; - + volume->cmVolumeState.compActive = TRUE; + if ((volume->VOLcompAttributes.compFlags & VOL_COMP_FLAGS_UPGRADE_START) && !(volume->VOLcompAttributes.compFlags & VOL_COMP_FLAGS_UPGRADE_FINISHED)) - { + { /* This is a pre-Nakoma volume, needs to upgrade compBeast from * zFTYPE_ROOT_BEAST to zFTYPE_COMPRESSION */ - CM_StartUpgradeProcess(); + CM_StartUpgradeProcess(); } } return zOK; } -void +void CM_volumeDeactivate(Volume_s *volume, BOOL abortOngoingActivities, BOOL wait) { ASSERT_MPKNSS_LOCK(); @@ -3089,17 +3083,17 @@ CM_startup() return rc; rc = ALGOMGR_init(0); if (rc != zOK) - return rc; + return rc; rc = CM_runtimeInit(); if (rc != zOK) return rc; CM_isStarted = TRUE; - return zOK; + return zOK; } void CM_shutdown(BOOL abortOngoingActivities, BOOL wait) -{ +{ ASSERT_MPKNSS_LOCK(); CM_isStarted = FALSE; @@ -3107,7 +3101,7 @@ CM_shutdown(BOOL abortOngoingActivities, BOOL wait) #ifndef __linux__ // LINUX_Compression LINUX_ScreenIO /* shut down the stat screen */ while (CM_screenThreadID) - { + { MPKNSS_UNLOCK(); kDelayThread(100); MPKNSS_LOCK(); diff --git a/src/nwnss/comn/compression/cmCompFile.c b/src/nwnss/comn/compression/cmCompFile.c index 3a14764..411c21b 100644 --- a/src/nwnss/comn/compression/cmCompFile.c +++ b/src/nwnss/comn/compression/cmCompFile.c @@ -39,20 +39,20 @@ #include "cmCompFile.h" #include "cmAlgoMan.h" -CompFileLayoutID_s NW_compFileLayout_ID = -{ - 0x01, - NW_COMPFILE_MAJOR_VERSION, - NW_COMPFILE_MINOR_VERSION, - 0, +CompFileLayoutID_s NW_compFileLayout_ID = +{ + 0x01, + NW_COMPFILE_MAJOR_VERSION, + NW_COMPFILE_MINOR_VERSION, + 0, }; -CompFileLayoutID_s NSS_compFileLayout_ID = -{ - 0x00, - NSS_COMPFILE_MAJOR_VERSION, - NSS_COMPFILE_MINOR_VERSION, - 0, +CompFileLayoutID_s NSS_compFileLayout_ID = +{ + 0x00, + NSS_COMPFILE_MAJOR_VERSION, + NSS_COMPFILE_MINOR_VERSION, + 0, }; STATUS @@ -65,7 +65,7 @@ initCompDatastream( CompressInfo_s *compInfo = BEAST_CM_INFO(uncompBeast); zASSERT(compInfo); - if (! ((compInfo->p.algoID == NSS_COMP_ALGO_ID_NETWARE) + if (! ((compInfo->p.algoID == NSS_COMP_ALGO_ID_NETWARE) && (compInfo->p.chunkSize == 0))) { SNINT i; @@ -83,7 +83,7 @@ initCompDatastream( fileHdr->algoVersion = compInfo->p.algoVersion; fileHdr->chunkSize = compInfo->p.chunkSize; fileHdr->nvalidChunks = 0; - for (i = 0; i < DIRECT_CHUNK_VECTOR_BYTES; ++ i) + for (i = 0; i < DIRECT_CHUNK_VECTOR_BYTES; ++ i) { fileHdr->chunkStateVector[i] = 0; } @@ -101,11 +101,11 @@ createHoleInBeast( QUAD size) { LONG pageSize = (1 << beast->blkSizeShift); - Blknum_t holeBlkcnt = + Blknum_t holeBlkcnt = (TRUNC(offset, pageSize) + size) >> beast->blkSizeShift; if (holeBlkcnt > 0) - return CREATE_HOLE_IN_BEAST(genMsg, beast, + return CREATE_HOLE_IN_BEAST(genMsg, beast, (offset + pageSize - 1) >> beast->blkSizeShift, holeBlkcnt); else return zOK; @@ -121,14 +121,14 @@ getCompChunkOffset( { LONG chunkNum = offset / chunksize; LONG chunkVectorPagenum; - if (chunkNum < NUM_DIRECT_CHUNKS) + if (chunkNum < NUM_DIRECT_CHUNKS) { *compChunkOffset = (chunkNum == 0) ? sizeof(CompFileHdr_s) : offset; return zOK; } chunkNum -= NUM_DIRECT_CHUNKS; chunkVectorPagenum = chunkNum / NCHUNKS_PER_PAGE(beast); - *compChunkOffset = offset + + *compChunkOffset = offset + ((chunkVectorPagenum + 1) << beast->blkSizeShift); return zOK; } @@ -163,19 +163,19 @@ getChunkCompStatus( mapBufferPage(cmbuf); fileHdr = (CompFileHdr_s *)cmbuf->pBuf.data; - if (chunkNum >= fileHdr->nvalidChunks) + if (chunkNum >= fileHdr->nvalidChunks) { *status = COMP_STATUS_UNCOMPRESSED; } - else if (chunkNum < NUM_DIRECT_CHUNKS) + else if (chunkNum < NUM_DIRECT_CHUNKS) { BYTE byteind = chunkNum / NCHUNKS_PER_BYTE; *status = ((BYTE *)&fileHdr->chunkStateVector)[byteind] >> - (CHUNK_STATE_NBITS * + (CHUNK_STATE_NBITS * (NCHUNKS_PER_BYTE - 1 - (chunkNum % NCHUNKS_PER_BYTE))); } - else + else { LONG chunkVectorPagenum; BYTE *chunkStateVector; @@ -194,7 +194,7 @@ getChunkCompStatus( chunkStateVector = (BYTE *)cmbuf->pBuf.data; byteind = chunkNum / NCHUNKS_PER_BYTE; *status = chunkStateVector[byteind] >> - (CHUNK_STATE_NBITS * + (CHUNK_STATE_NBITS * (NCHUNKS_PER_BYTE - 1 - (chunkNum % NCHUNKS_PER_BYTE))); } unmapBufferPage(cmbuf); @@ -219,27 +219,27 @@ setChunkCompStatus( return zFAILURE; mapBufferPage(cmbuf); fileHdr = (CompFileHdr_s *)cmbuf->pBuf.data; - if (chunkNum < NUM_DIRECT_CHUNKS) + if (chunkNum < NUM_DIRECT_CHUNKS) { BYTE *chunkStateVector = (BYTE *)&fileHdr->chunkStateVector; NINT byteind; SNINT chunkStateShift; - if (fileHdr->nvalidChunks <= chunkNum) + if (fileHdr->nvalidChunks <= chunkNum) { byteind = fileHdr->nvalidChunks / NCHUNKS_PER_BYTE; - chunkStateShift = (CHUNK_STATE_NBITS * + chunkStateShift = (CHUNK_STATE_NBITS * (NCHUNKS_PER_BYTE - 1 - (fileHdr->nvalidChunks % NCHUNKS_PER_BYTE))); - while (fileHdr->nvalidChunks < chunkNum) + while (fileHdr->nvalidChunks < chunkNum) { - chunkStateVector[byteind] &= + chunkStateVector[byteind] &= (~CHUNK_STATE_MASK) << chunkStateShift; - chunkStateVector[byteind] |= + chunkStateVector[byteind] |= (COMP_STATUS_UNCOMPRESSED|COMP_STATUS_CLEAN) << chunkStateShift; ++ fileHdr->nvalidChunks; - if (chunkStateShift == 0) + if (chunkStateShift == 0) { - chunkStateShift = + chunkStateShift = (CHUNK_STATE_NBITS * (NCHUNKS_PER_BYTE - 1)); ++ byteind; } @@ -247,20 +247,20 @@ setChunkCompStatus( } ++ fileHdr->nvalidChunks; } - else + else { byteind = chunkNum / NCHUNKS_PER_BYTE; - chunkStateShift = (CHUNK_STATE_NBITS * + chunkStateShift = (CHUNK_STATE_NBITS * (NCHUNKS_PER_BYTE - 1 - (chunkNum % NCHUNKS_PER_BYTE))); } - chunkStateVector[byteind] &= + chunkStateVector[byteind] &= (~CHUNK_STATE_MASK) << chunkStateShift; - chunkStateVector[byteind] |= + chunkStateVector[byteind] |= (status & CHUNK_STATE_MASK) << chunkStateShift; unmapBufferPage(cmbuf); CACHE_RELEASE(cmbuf); } - else + else { LONG chunkVectorPagenum; BYTE *chunkStateVector; @@ -269,7 +269,7 @@ setChunkCompStatus( NINT chunkStateShift; chunkNum -= NUM_DIRECT_CHUNKS; - if ((fileHdr->nvalidChunks - NUM_DIRECT_CHUNKS) <= chunkNum) + if ((fileHdr->nvalidChunks - NUM_DIRECT_CHUNKS) <= chunkNum) { QUAD chunkOffset = fileHdr->nvalidChunks * chunksize; LONG curChunk = fileHdr->nvalidChunks - NUM_DIRECT_CHUNKS; @@ -284,28 +284,28 @@ setChunkCompStatus( chunkStateVector = (BYTE *)cmbuf->pBuf.data; byteind = (curChunk % NCHUNKS_PER_PAGE(compBeast)) / NCHUNKS_PER_BYTE; - chunkStateShift = (CHUNK_STATE_NBITS * + chunkStateShift = (CHUNK_STATE_NBITS * (NCHUNKS_PER_BYTE - 1 - ((curChunk % NCHUNKS_PER_PAGE(compBeast)) % NCHUNKS_PER_BYTE))); - while (curChunk < chunkNum) + while (curChunk < chunkNum) { - chunkStateVector[byteind] &= + chunkStateVector[byteind] &= (~CHUNK_STATE_MASK) << chunkStateShift; - chunkStateVector[byteind] |= + chunkStateVector[byteind] |= (COMP_STATUS_UNCOMPRESSED|COMP_STATUS_CLEAN) << chunkStateShift; ++ fileHdr->nvalidChunks; ++ curChunk; - if (chunkStateShift == 0) + if (chunkStateShift == 0) { - chunkStateShift = + chunkStateShift = (CHUNK_STATE_NBITS * (NCHUNKS_PER_BYTE - 1)); - if (++ byteind >= (1 << cmbuf->bufSizeShift)) + if (++ byteind >= (1 << cmbuf->bufSizeShift)) { unmapBufferPage(cmbuf); CACHE_DIRTY_RELEASE(cmbuf); - blknum += + blknum += (NCHUNKS_PER_PAGE(compBeast) * chunksize) >> (compBeast->blkSizeShift + 1); - cmbuf = CM_fetchFileBlk(genMsg, compBeast, blknum, + cmbuf = CM_fetchFileBlk(genMsg, compBeast, blknum, CACHE_UPDATE, 0); if (! cmbuf) return zFAILURE; @@ -318,7 +318,7 @@ setChunkCompStatus( } ++ fileHdr->nvalidChunks; } - else + else { chunkVectorPagenum = chunkNum / NCHUNKS_PER_PAGE(compBeast); chunkNum -= chunkVectorPagenum * NCHUNKS_PER_PAGE(compBeast); @@ -330,13 +330,13 @@ setChunkCompStatus( chunkStateVector = (BYTE *)cmbuf->pBuf.data; byteind = chunkNum / NCHUNKS_PER_BYTE; - chunkStateShift = (CHUNK_STATE_NBITS * + chunkStateShift = (CHUNK_STATE_NBITS * (NCHUNKS_PER_BYTE - 1 - (chunkNum % NCHUNKS_PER_BYTE))); } - chunkStateVector[byteind] &= + chunkStateVector[byteind] &= (~CHUNK_STATE_MASK) << chunkStateShift; - chunkStateVector[byteind] |= + chunkStateVector[byteind] |= (status & CHUNK_STATE_MASK) << chunkStateShift; unmapBufferPage(cmbuf); CACHE_DIRTY_RELEASE(cmbuf); @@ -353,17 +353,17 @@ setBeastChunkValidRange( SLONG dataSize) { LONG pageSize = (1 << beast->blkSizeShift); - if (chunksize != 0) + if (chunksize != 0) { - Blknum_t holeBlkcnt = + Blknum_t holeBlkcnt = (TRUNC(dataOffset, pageSize) + chunksize) >> beast->blkSizeShift; if (holeBlkcnt > 0) - return CREATE_HOLE_IN_BEAST(genMsg, beast, - (dataOffset + dataSize + pageSize - 1) >> beast->blkSizeShift, + return CREATE_HOLE_IN_BEAST(genMsg, beast, + (dataOffset + dataSize + pageSize - 1) >> beast->blkSizeShift, holeBlkcnt); else return zOK; } - else + else { zASSERT(0); /* We shouldn't be called in this case */ return TRUNCATE_BEAST(genMsg, beast, dataOffset + dataSize); @@ -384,11 +384,11 @@ CM_tossBeastUncompChunk( NINT status; CompressInfo_s *compInfo = BEAST_CM_INFO(uncompBeast); Xaction_s *localXaction; - + zASSERT(compInfo != 0); - if (compInfo->p.chunkSize != 0) + if (compInfo->p.chunkSize != 0) { - rc = getChunkCompStatus(genMsg, compBeast, offset, + rc = getChunkCompStatus(genMsg, compBeast, offset, compInfo->p.chunkSize, &status); if (rc != zOK) return rc; @@ -396,23 +396,23 @@ CM_tossBeastUncompChunk( else status = compInfo->p.status; /* Toss the uncompressed version */ - if (forceToss || ISVALID_COMP_CHUNK(status)) + if (forceToss || ISVALID_COMP_CHUNK(status)) { - if (ISVALID_UNCOMP_CHUNK(status)) + if (ISVALID_UNCOMP_CHUNK(status)) { localXaction = COMN_BeginXLocal(uncompBeast); -- compInfo->p.UCprecious; - if (compInfo->p.chunkSize != 0) + if (compInfo->p.chunkSize != 0) { setChunkCompStatus(genMsg, compBeast, offset, compInfo->p.chunkSize, COMP_STATUS_COMPRESSED); } - else + else { - compInfo->p.status &= + compInfo->p.status &= ~(COMP_STATUS_UNCOMPRESSED|COMP_STATUS_FAILURE); - compInfo->p.status |= COMP_STATUS_COMPRESSED; - + compInfo->p.status |= COMP_STATUS_COMPRESSED; + setBeastCompAttr(uncompBeast, zFA_DATA_STREAM_IS_COMPRESSED, localXaction, FALSE); setVolCompStats(uncompBeast, compBeast, localXaction, TRUE); @@ -433,8 +433,8 @@ CM_tossBeastUncompChunk( } else { - zASSERT("Comp data is missing" == NULL); - SetErrno(genMsg, zERR_CM_CANT_COMPRESS); + zASSERT("Comp data is missing" == NULL); + SetErrno(genMsg, zERR_CM_CANT_COMPRESS); return zFAILURE; } } @@ -451,46 +451,46 @@ STATUS CM_tossBeastCompChunk( NINT status; CompressInfo_s *compInfo = BEAST_CM_INFO(uncompBeast); Xaction_s *localXaction; - + if (compInfo == 0) { return zOK; } - if (compInfo->p.chunkSize != 0) + if (compInfo->p.chunkSize != 0) { - rc = getChunkCompStatus(genMsg, compBeast, offset, + rc = getChunkCompStatus(genMsg, compBeast, offset, compInfo->p.chunkSize, &status); if (rc != zOK) return rc; } else - { + { status = compInfo->p.status; } - + /* Toss the compressed version */ - if (forceToss || ISVALID_UNCOMP_CHUNK(status)) + if (forceToss || ISVALID_UNCOMP_CHUNK(status)) { - if (ISVALID_COMP_CHUNK(status)) + if (ISVALID_COMP_CHUNK(status)) { - localXaction = COMN_BeginXLocal(uncompBeast); - + localXaction = COMN_BeginXLocal(uncompBeast); + -- compInfo->p.Cprecious; - compInfo->p.UCprecious = (compInfo->p.chunkSize != 0) + compInfo->p.UCprecious = (compInfo->p.chunkSize != 0) ? GET_DATASTREAM_SIZE(uncompBeast) / compInfo->p.chunkSize : 1; - if (compInfo->p.chunkSize != 0) + if (compInfo->p.chunkSize != 0) { - setChunkCompStatus(genMsg, compBeast, offset, compInfo->p.chunkSize, - COMP_STATUS_UNCOMPRESSED); - /* NOTE: we shall set beast attributes and statistics here also */ + setChunkCompStatus(genMsg, compBeast, offset, compInfo->p.chunkSize, + COMP_STATUS_UNCOMPRESSED); + /* NOTE: we shall set beast attributes and statistics here also */ } - else - { + else + { if (!CHUNK_UNCOMPRESSED(status)) - { + { /* this beast is fully compressed, and we are going to throw * away its compressed data, modify compression related information */ @@ -498,7 +498,7 @@ STATUS CM_tossBeastCompChunk( setVolCompStats(uncompBeast, compBeast, localXaction, FALSE); } - compInfo->p.status &= + compInfo->p.status &= ~(COMP_STATUS_COMPRESSED|COMP_STATUS_FAILURE); compInfo->p.status |= COMP_STATUS_UNCOMPRESSED; } @@ -512,34 +512,34 @@ STATUS CM_tossBeastCompChunk( } COMN_EndXLocal(uncompBeast, &localXaction); } - - if (compInfo->p.chunkSize != 0) + + if (compInfo->p.chunkSize != 0) { QUAD compChunkOffset; /* free comp chunk */ if (getCompChunkOffset(genMsg, compBeast, offset, - compInfo->p.chunkSize, &compChunkOffset) == zOK) + compInfo->p.chunkSize, &compChunkOffset) == zOK) { return zFAILURE; } (void) setCompChunkValidRange(genMsg, compBeast, offset, compInfo->p.chunkSize, compChunkOffset, 0); } - else + else { /* Discard compressed data */ (void) TRUNCATE_BEAST(genMsg, compBeast, 0); - } - - return zOK; + } + + return zOK; } else - { + { zASSERT("Uncomp data is missing" == NULL); SetErrno(genMsg, zERR_CM_CANT_DECOMPRESS); - return zFAILURE; - } + return zFAILURE; + } } /* @@ -558,17 +558,17 @@ CM_tossUncompBeastData( QUAD offset = 0; CompressInfo_s *compInfo = BEAST_CM_INFO(uncompBeast); BOOL releaseBeast = FALSE; - + if (! compInfo) { SetErrno(genMsg, zERR_INVALID_STATE); return zFAILURE; } - if (compInfo->p.chunkSize != 0) + if (compInfo->p.chunkSize != 0) nchunks = GET_DATASTREAM_SIZE(uncompBeast) / compInfo->p.chunkSize; else nchunks = 1; - + if (compBeast == NULL) { compBeast = (RootBeast_s *)CM_LookupCompBeast(genMsg, uncompBeast, compInfo, XLATCHED); @@ -577,13 +577,13 @@ CM_tossUncompBeastData( return zFAILURE; } releaseBeast = TRUE; - } + } nfailed = 0; - while (nchunks > 0) + while (nchunks > 0) { /* Toss each chunk */ - rc = CM_tossBeastUncompChunk(genMsg, uncompBeast, compBeast, offset, + rc = CM_tossBeastUncompChunk(genMsg, uncompBeast, compBeast, offset, FALSE); if (rc != zOK) ++ nfailed; @@ -592,17 +592,17 @@ CM_tossUncompBeastData( } rc = (nfailed > 0) ? zFAILURE : zOK; - if ((rc == zOK) && DQ_EMPTY(&compInfo->CM_activities) && + if ((rc == zOK) && DQ_EMPTY(&compInfo->CM_activities) && BEAST_COMPRESSED(compInfo) && ! BEAST_CLEAN(compInfo->p.status)) { rc = compCleanup(genMsg, uncompBeast, compBeast, recovery, 0); } - + if (releaseBeast) { - COMN_UnlatchAndRelease(&compBeast, XLATCHED); + COMN_UnlatchAndRelease(&compBeast, XLATCHED); } - + return rc; } @@ -628,22 +628,22 @@ STATUS CM_tossCompBeastData( SetErrno(genMsg, zERR_INVALID_STATE); return zFAILURE; } - - if (compInfo->p.chunkSize != 0) + + if (compInfo->p.chunkSize != 0) nchunks = GET_DATASTREAM_SIZE(uncompBeast) / compInfo->p.chunkSize; else nchunks = 1; - + zASSERT(compInfo->p.compZid != zINVALID_ZID); compBeast = (RootBeast_s *)CM_LookupCompBeast(genMsg, uncompBeast, compInfo, - XLATCHED); + XLATCHED); if (compBeast == 0) return zFAILURE; nfailed = 0; - while (nchunks > 0) + while (nchunks > 0) { /* Toss each chunk */ - rc = CM_tossBeastCompChunk(genMsg, uncompBeast, compBeast, offset, + rc = CM_tossBeastCompChunk(genMsg, uncompBeast, compBeast, offset, FALSE); if (rc != zOK) ++ nfailed; @@ -659,9 +659,10 @@ STATUS CM_tossCompBeastData( { if ((rc = decompCleanup(genMsg, uncompBeast, compBeast, FALSE, 0)) == zOK) return zOK; - } + } } - COMN_UnlatchAndRelease(&compBeast, XLATCHED); - + COMN_UnlatchAndRelease(&compBeast, XLATCHED); + return rc; } + diff --git a/src/nwnss/comn/compression/cmControl.c b/src/nwnss/comn/compression/cmControl.c index 22417a1..5e842a8 100644 --- a/src/nwnss/comn/compression/cmControl.c +++ b/src/nwnss/comn/compression/cmControl.c @@ -68,10 +68,10 @@ void CM_controlCompression(BOOL enable) if (enable) { - /* - * Start all the pending requests. + /* + * Start all the pending requests. */ - CM_startPendingCompressions(); + CM_startPendingCompressions(); } else { @@ -136,8 +136,8 @@ void CM_initVolumeCompState(Volume_s *volume) * them back after reset volume's compression state, we won't have chance * to do it later */ - LONG compFlags = volume->VOLcompAttributes.compFlags & - (VOL_COMP_FLAGS_UPGRADE_START | VOL_COMP_FLAGS_UPGRADE_FINISHED); + LONG compFlags = volume->VOLcompAttributes.compFlags & + (VOL_COMP_FLAGS_UPGRADE_START | VOL_COMP_FLAGS_UPGRADE_FINISHED); /* Initialize volume's persistent data */ CM_resetVolumeCompState(volume); diff --git a/src/nwnss/comn/compression/cmRuntime.c b/src/nwnss/comn/compression/cmRuntime.c index ff4b4ce..a3c6ce8 100644 --- a/src/nwnss/comn/compression/cmRuntime.c +++ b/src/nwnss/comn/compression/cmRuntime.c @@ -39,20 +39,20 @@ #include "cmControl.h" #include "cmActivity.h" #include "cmRuntime.h" -#include "cmNSS.h" +#include "cmNSS.h" #include "comnCompress.h" /* * A simple event-based wait/signal mechanism. - * rc = CM_awaitEvent(): + * rc = CM_awaitEvent(): * Puts itself on eventq until an event indicated by is * signalled. - * A CM_signalEvent(, ) call by another thread goes + * A CM_signalEvent(, ) call by another thread goes * thru the eventq and wakes up all threads waiting on
, passing * . CM_signalEvent returns the number of threads woken up. * The event system should be initialized by calling CM_eventInit(). */ -typedef struct CMEvent_s +typedef struct CMEvent_s { ADDR event; STATUS retCode; @@ -106,11 +106,11 @@ CM_signalEvent(ADDR event, STATUS retCode) DQ_FOREACH_SAFE(&CM_EventqHead, myevent, tmp, CMEvent_s, eventqChain) { - if ((myevent->event == event) && ! myevent->done) + if ((myevent->event == event) && ! myevent->done) { myevent->retCode = retCode; myevent->done = TRUE; - /* We don't dequeue the waiter. Instead, we let him dequeue himself + /* We don't dequeue the waiter. Instead, we let him dequeue himself * when he runs next */ Continue(myevent->threadID); ++ found; @@ -123,8 +123,8 @@ CM_signalEvent(ADDR event, STATUS retCode) * Compression Manager's activity pool. * Each CMActivity_s holds the context of an ongoing (de)compression operation * of a single NSS datastream chunk. - * CM_activityPool: A pre-allocated pool of CMActivity_s structures - * (CM_maxActivities of them). + * CM_activityPool: A pre-allocated pool of CMActivity_s structures + * (CM_maxActivities of them). * CM_compAvail of them can be used for compression activities, * CM_decompAvail of them can be used for decompression activities, * UNINITING() indicates that the pool is being shutdown. @@ -132,7 +132,7 @@ CM_signalEvent(ADDR event, STATUS retCode) * structure is in the pool. */ STATIC SNINT CM_maxActivities, CM_nextAvailActivity; -STATIC SNINT CM_compAvail, CM_decompAvail; +STATIC SNINT CM_compAvail, CM_decompAvail; STATIC SNINT CM_compUsed, CM_decompUsed; /* @@ -150,35 +150,35 @@ DQhead_t CM_activities; void CM_activityPoolChange() -{ +{ NINT compAvail, decompAvail; - + ASSERT_MPKNSS_LOCK(); - - /* + + /* * Allocate max comp/decomp activities proportionate to the Netware - * maxCompressions/decompressions set parameters + * maxCompressions/decompressions set parameters */ - if (CM_curCompControlParams.maxCmActivities > 0) + if (CM_curCompControlParams.maxCmActivities > 0) { compAvail = (CM_maxActivities * CM_curCompControlParams.maxCompressions) / CM_curCompControlParams.maxCmActivities; decompAvail = CM_maxActivities - compAvail; } - else - { + else + { zASSERT(CM_curCompControlParams.maxCmActivities > 0); compAvail = 0; decompAvail = 0; - } - - /* - * CM_compAvail and CM_decompAvail can be negative. For example, + } + + /* + * CM_compAvail and CM_decompAvail can be negative. For example, * if previously CM_compAvail is 0, CM_compUsed is 5; CM_decompAvail is 0, CM_decompUsed is 5, * now due to change of maxCompressions, compAvail is 2, decompAvail is 8. - * CM_compAvail can be set to (2 - 5) = -3. New comp activity won't be allocated until - * more than 3 comp activities are returned. - * + * CM_compAvail can be set to (2 - 5) = -3. New comp activity won't be allocated until + * more than 3 comp activities are returned. + * */ CM_compAvail = compAvail - CM_compUsed; CM_decompAvail = decompAvail - CM_decompUsed; @@ -190,15 +190,15 @@ CM_activityPoolInit(NINT maxCmActivities) #ifdef PREALLOC_ACTIVITY_POOL SNINT i; - CM_activityPool = (CMActivity_s *)malloc(sizeof(CMActivity_s) + CM_activityPool = (CMActivity_s *)malloc(sizeof(CMActivity_s) * maxCmActivities); if (! CM_activityPool) return zERR_NO_MEMORY; - for (i = 0; i < maxCmActivities; ++ i) + for (i = 0; i < maxCmActivities; ++ i) { CM_activityPool[i].state = CM_ACTIVITY_STATE_AVAILABLE; - FSMLITE_INIT(&CM_activityPool[i].fsm, + FSMLITE_INIT(&CM_activityPool[i].fsm, "FSM for compression/decompression activity", i); } #endif /* PREALLOC_ACTIVITY_POOL */ @@ -206,18 +206,18 @@ CM_activityPoolInit(NINT maxCmActivities) ASSERT_MPKNSS_LOCK(); CM_maxActivities = maxCmActivities; - CM_nextAvailActivity = 0; - + CM_nextAvailActivity = 0; + CM_compUsed = 0; CM_decompUsed = 0; - + CM_activityPoolChange(); return zOK; } STATIC void CM_activityPoolUninit(Volume_s *volume, BOOL abortOngoingActivities, BOOL wait) -{ +{ ASSERT_MPKNSS_LOCK(); if (! volume) @@ -226,7 +226,7 @@ CM_activityPoolUninit(Volume_s *volume, BOOL abortOngoingActivities, BOOL wait) } /* count ongoing activities; abort them if asked for */ - for (;;) + for (;;) { SNINT waitCount = 0; #ifdef PREALLOC_ACTIVITY_POOL @@ -238,7 +238,7 @@ CM_activityPoolUninit(Volume_s *volume, BOOL abortOngoingActivities, BOOL wait) && (volume == CM_activityPool[i].decompStream.beast->ROOTvolume)) { ++ waitCount; - + if (abortOngoingActivities) { CM_activityAbort(&CM_activityPool[i], zERR_CM_ABORTED, FALSE); @@ -246,14 +246,14 @@ CM_activityPoolUninit(Volume_s *volume, BOOL abortOngoingActivities, BOOL wait) } } #else /* PREALLOC_ACTIVITY_POOL */ - { + { CMActivity_s *activity; - + DQ_FOREACH(&CM_activities, activity, CMActivity_s, allActivitiesChain) { if (volume != activity->decompStream.beast->ROOTvolume) - continue; + continue; if (abortOngoingActivities) { CM_activityAbort(activity, zERR_CM_ABORTED, FALSE); @@ -267,11 +267,11 @@ CM_activityPoolUninit(Volume_s *volume, BOOL abortOngoingActivities, BOOL wait) if (waitCount == 0) break; else if (! wait) - return; + return; - (void) CM_awaitEvent((ADDR)&CM_maxActivities); + (void) CM_awaitEvent((ADDR)&CM_maxActivities); } - + #ifdef PREALLOC_ACTIVITY_POOL if (! volume) free(CM_activityPool); @@ -290,7 +290,7 @@ CM_activityPoolAlloc() return 0; for (i = CM_nextAvailActivity; i < CM_maxActivities; ++ i) { - if (CM_activityPool[i].state == CM_ACTIVITY_STATE_AVAILABLE) + if (CM_activityPool[i].state == CM_ACTIVITY_STATE_AVAILABLE) { CM_activityPool[i].state = CM_ACTIVITY_STATE_SUSPENDED; CM_nextAvailActivity = i+1; @@ -325,7 +325,7 @@ CM_activityPoolAlloc() if (activity) { activity->state = CM_ACTIVITY_STATE_AVAILABLE; - FSMLITE_INIT(&activity->fsm, + FSMLITE_INIT(&activity->fsm, "FSM for compression/decompression activity", 0); } return activity; @@ -343,44 +343,44 @@ CM_activityPoolFree(CMActivity_s *activity) */ STATUS CM_activityAlloc( - NINT activityOp, + NINT activityOp, CMActivity_s **activity, BOOL wait) { CMActivity_s *newActivity; - SNINT *navail = (activityOp == CM_ACTIVITY_OP_COMPRESS) - ? &CM_compAvail : &CM_decompAvail; - SNINT *nused = (activityOp == CM_ACTIVITY_OP_COMPRESS) - ? &CM_compUsed : &CM_decompUsed; - + SNINT *navail = (activityOp == CM_ACTIVITY_OP_COMPRESS) + ? &CM_compAvail : &CM_decompAvail; + SNINT *nused = (activityOp == CM_ACTIVITY_OP_COMPRESS) + ? &CM_compUsed : &CM_decompUsed; + ASSERT_MPKNSS_LOCK(); - for (;;) + for (;;) { STATUS rc; - if (((CM_compUsed + CM_decompUsed) < CM_maxActivities) && (*navail > 0)) - { + if (((CM_compUsed + CM_decompUsed) < CM_maxActivities) && (*navail > 0)) + { --(*navail); ++(*nused); newActivity = CM_activityPoolAlloc(); zASSERT(newActivity); - if (newActivity) + if (newActivity) { *activity = newActivity; - newActivity->op = activityOp; + newActivity->op = activityOp; /* update the statistics */ X_LATCH(&CM_curCompStatistics.latch); if (activityOp == CM_ACTIVITY_OP_COMPRESS) - { - CM_curCompStatistics.numCompActivities++; + { + CM_curCompStatistics.numCompActivities++; } else { - CM_curCompStatistics.numDecompActivities++; + CM_curCompStatistics.numDecompActivities++; } - displayCompActivityCounts(); + displayCompActivityCounts(); UNX_LATCH(&CM_curCompStatistics.latch); return zOK; @@ -407,24 +407,24 @@ CM_activityAlloc( void CM_activityFree(CMActivity_s *activity) { - SNINT *navail = (activity->op == CM_ACTIVITY_OP_COMPRESS) + SNINT *navail = (activity->op == CM_ACTIVITY_OP_COMPRESS) ? &CM_compAvail : &CM_decompAvail; - SNINT *nused = (activity->op == CM_ACTIVITY_OP_COMPRESS) + SNINT *nused = (activity->op == CM_ACTIVITY_OP_COMPRESS) ? &CM_compUsed : &CM_decompUsed; - + ASSERT_MPKNSS_LOCK(); /* update the statistics */ X_LATCH(&CM_curCompStatistics.latch); if (activity->op == CM_ACTIVITY_OP_COMPRESS) { - CM_curCompStatistics.numCompActivities--; + CM_curCompStatistics.numCompActivities--; } else { - CM_curCompStatistics.numDecompActivities--; + CM_curCompStatistics.numDecompActivities--; } - displayCompActivityCounts(); + displayCompActivityCounts(); UNX_LATCH(&CM_curCompStatistics.latch); CM_activityPoolFree(activity); @@ -444,51 +444,51 @@ STATIC STATUS CM_initCompressRequestQueue(Volume_s *volume) ASSERT_MPKNSS_LOCK(); SQ_INIT(&volume->cmVolumeState.compRequestQHead); - INIT_LATCH(&volume->cmVolumeState.latch); + INIT_LATCH(&volume->cmVolumeState.latch); SQ_INIT(&volume->cmVolumeState.compRequestBGQHead); - INIT_LATCH(&volume->cmVolumeState.BGlatch); + INIT_LATCH(&volume->cmVolumeState.BGlatch); return zOK; } void removeCompressRequest( - SQhead_t *head, + SQhead_t *head, Latch_s *latch, NINT *queueNumber) { CompRequestScoop_s *curScoop; ASSERT_MPKNSS_LOCK(); - + X_LATCH(latch); - for (;;) + for (;;) { SQ_DEQ(head, curScoop, CompRequestScoop_s, requestQLink); if (! curScoop) { /* update the statistics */ X_LATCH(&CM_curCompStatistics.latch); - displayWaitingCounts(); + displayWaitingCounts(); UNX_LATCH(&CM_curCompStatistics.latch); - + UNX_LATCH(latch); return; } - + /* update the statistics */ X_LATCH(&CM_curCompStatistics.latch); (*queueNumber) -= curScoop->firstFreeInd - curScoop->firstValidReqInd - curScoop->removedQueues; zASSERT((SNINT)*queueNumber >= 0); - displayWaitingCounts(); + displayWaitingCounts(); UNX_LATCH(&CM_curCompStatistics.latch); - free(curScoop); - + free(curScoop); + PERIODIC_YIELD(); } - + /* Shouldn't reach here */ } @@ -498,8 +498,8 @@ void CM_cleanNormalCompressionRequestQueue( Volume_s *volume) { removeCompressRequest(&volume->cmVolumeState.compRequestQHead, - &volume->cmVolumeState.latch, - &CM_curCompStatistics.numQueuedCompReqs); + &volume->cmVolumeState.latch, + &CM_curCompStatistics.numQueuedCompReqs); } /* remove all the enqueued requests initiated by background compression */ @@ -507,12 +507,12 @@ void CM_cleanBGCompressRequestQueue( Volume_s *volume) { removeCompressRequest(&volume->cmVolumeState.compRequestBGQHead, - &volume->cmVolumeState.BGlatch, + &volume->cmVolumeState.BGlatch, &CM_curCompStatistics.numQueuedBGCompReqs); } void CM_uninitCompressRequestQueue( - Volume_s *volume) + Volume_s *volume) { ASSERT_MPKNSS_LOCK(); @@ -527,23 +527,23 @@ void CM_stopCompression( ASSERT_MPKNSS_LOCK(); - prevVolume = 0; - + prevVolume = 0; + /* clean up each volume's enqueue request */ while (1) - { + { nextVolume = COMN_GetNextVolume(prevVolume); if (prevVolume) { - COMN_Release(&prevVolume); + COMN_Release(&prevVolume); } if (nextVolume == NULL) { break; - } - - prevVolume = nextVolume; + } + + prevVolume = nextVolume; /* Make sure the volume is in active state */ if ((nextVolume->state != zVOLSTATE_ACTIVE) || @@ -567,7 +567,7 @@ void CM_stopCompression( STATUS CM_enqueueCompressRequest( - Volume_s *volume, + Volume_s *volume, Zid_t zid, NINT reason) { @@ -576,7 +576,7 @@ STATUS CM_enqueueCompressRequest( SQhead_t *head; Latch_s *latch; NINT *queueNumber; - + ASSERT_MPKNSS_LOCK(); if (reason == COMP_BACKGROUND) @@ -599,12 +599,12 @@ STATUS CM_enqueueCompressRequest( { if (curScoop->firstFreeInd < MAX_COMP_REQS_PER_SCOOP) { - curScoop->req[curScoop->firstFreeInd++].zid = zid; - + curScoop->req[curScoop->firstFreeInd++].zid = zid; + /* update the statistics */ X_LATCH(&CM_curCompStatistics.latch); (*queueNumber)++; - displayWaitingCounts(); + displayWaitingCounts(); UNX_LATCH(&CM_curCompStatistics.latch); goto Exit; @@ -620,22 +620,22 @@ STATUS CM_enqueueCompressRequest( /* try to get a scoop from BG queueHead */ X_LATCH(&volume->cmVolumeState.BGlatch); - - SQ_DEQ(&volume->cmVolumeState.compRequestBGQHead, tmpScoop, + + SQ_DEQ(&volume->cmVolumeState.compRequestBGQHead, tmpScoop, CompRequestScoop_s, requestQLink); if (tmpScoop) - { + { /* update the statistics */ X_LATCH(&CM_curCompStatistics.latch); - CM_curCompStatistics.numQueuedBGCompReqs -= + CM_curCompStatistics.numQueuedBGCompReqs -= tmpScoop->firstFreeInd - tmpScoop->firstValidReqInd - tmpScoop->removedQueues; - displayWaitingCounts(); + displayWaitingCounts(); UNX_LATCH(&CM_curCompStatistics.latch); - - UNX_LATCH(&volume->cmVolumeState.BGlatch); + + UNX_LATCH(&volume->cmVolumeState.BGlatch); curScoop = tmpScoop; goto initNewScoop; } @@ -648,7 +648,7 @@ STATUS CM_enqueueCompressRequest( } zASSERT(sizeof(CompRequestScoop_s) == 4096); - + curScoop = (CompRequestScoop_s *)malloc(sizeof(CompRequestScoop_s)); if (! curScoop) { @@ -661,9 +661,9 @@ initNewScoop: curScoop->firstValidReqInd = 0; curScoop->req[curScoop->firstFreeInd++].zid = zid; curScoop->removedQueues = 0; - + NULLIFY(&curScoop->requestQLink); - SQ_ENQ(head, curScoop, requestQLink); + SQ_ENQ(head, curScoop, requestQLink); /* update the statistics */ X_LATCH(&CM_curCompStatistics.latch); @@ -680,7 +680,7 @@ Exit: Zid_t dequeueRequest( SQhead_t *head, - Latch_s *latch, + Latch_s *latch, NINT *queueNumber) { CompRequestScoop_s *curScoop; @@ -690,7 +690,7 @@ Zid_t dequeueRequest( X_LATCH(latch); - for (;;) + for (;;) { SQ_PEEK(head, curScoop, CompRequestScoop_s, requestQLink); if (curScoop) @@ -700,10 +700,10 @@ Zid_t dequeueRequest( if (curScoop->req[curScoop->firstValidReqInd].zid != zINVALID_ZID) { returnZid = curScoop->req[curScoop->firstValidReqInd++].zid; - + /* update the statistics */ X_LATCH(&CM_curCompStatistics.latch); - (*queueNumber)--; + (*queueNumber)--; displayWaitingCounts(); UNX_LATCH(&CM_curCompStatistics.latch); @@ -727,13 +727,13 @@ Zid_t dequeueRequest( return zINVALID_ZID; } } - + /* NOT REACHED */ } - + STATIC Zid_t CM_dequeueCompressRequest( - Volume_s *volume, + Volume_s *volume, NINT *reason) { Zid_t returnZid; @@ -743,16 +743,16 @@ STATIC Zid_t CM_dequeueCompressRequest( /* normal compression queue has higher prioritity */ *reason = COMP_NORMAL; returnZid = dequeueRequest(&volume->cmVolumeState.compRequestQHead, - &volume->cmVolumeState.latch, + &volume->cmVolumeState.latch, &CM_curCompStatistics.numQueuedCompReqs); if (returnZid == zINVALID_ZID) { - *reason = COMP_BACKGROUND; + *reason = COMP_BACKGROUND; returnZid = dequeueRequest(&volume->cmVolumeState.compRequestBGQHead, - &volume->cmVolumeState.BGlatch, + &volume->cmVolumeState.BGlatch, &CM_curCompStatistics.numQueuedBGCompReqs); - } - + } + return returnZid; } @@ -772,17 +772,17 @@ void removeRequest( X_LATCH(latch); - while (SQ_NOT_EMPTY(head)) - { + while (SQ_NOT_EMPTY(head)) + { SQ_DEQ(head, curScoop, CompRequestScoop_s, requestQLink); - zASSERT(curScoop != NULL); + zASSERT(curScoop != NULL); if (curScoop) - { + { i = curScoop->firstValidReqInd; while (i < curScoop->firstFreeInd) - { + { if (curScoop->req[i].zid == zid) { /* found it */ @@ -792,27 +792,27 @@ void removeRequest( /* update the statistics */ X_LATCH(&CM_curCompStatistics.latch); - (*queueNumber)--; + (*queueNumber)--; displayWaitingCounts(); UNX_LATCH(&CM_curCompStatistics.latch); - + } - + i++; } - - SQ_ENQ(&tmpRequestQHead, curScoop, requestQLink); + + SQ_ENQ(&tmpRequestQHead, curScoop, requestQLink); } - + PERIODIC_YIELD(); } - SQ_PREPEND(head, &tmpRequestQHead); + SQ_PREPEND(head, &tmpRequestQHead); UNX_LATCH(latch); - + return; -} +} /* * If beast is in the compress request queue, remove it from the queue and return TRUE @@ -824,11 +824,11 @@ BOOL CM_removeBeastCompressRequest( { Volume_s *volume = beast->vol.volume; BOOL found = FALSE; - + ASSERT_MPKNSS_LOCK(); /* need to check both queues */ - removeRequest(&volume->cmVolumeState.compRequestQHead, + removeRequest(&volume->cmVolumeState.compRequestQHead, &volume->cmVolumeState.latch, beast->ROOTzid, &found, &CM_curCompStatistics.numQueuedCompReqs); removeRequest(&volume->cmVolumeState.compRequestBGQHead, @@ -836,7 +836,7 @@ BOOL CM_removeBeastCompressRequest( &CM_curCompStatistics.numQueuedBGCompReqs); return found; -} +} /* @@ -881,7 +881,7 @@ void CM_startPendingCompressions() { if(CM_checkParentDirForCompressOK(&genMsg, (File_s*)uncompBeast)) { - CM_compressFileAsync(&genMsg, uncompBeast, XLATCHED, reason); + CM_compressFileAsync(&genMsg, uncompBeast, XLATCHED, reason); } COMN_UnlatchAndRelease(&uncompBeast, XLATCHED); } @@ -896,34 +896,34 @@ STATIC SNINT CM_availCompThreads, CM_availDecompThreads; STATIC SNINT CM_usedCompThreads, CM_usedDecompThreads; void CM_threadsChange() -{ +{ NINT compAvail, decompAvail; - + ASSERT_MPKNSS_LOCK(); - - /* + + /* * Allocate max comp/decomp threads as indicated by the Netware - * maxCompressions/decompressions set parameters + * maxCompressions/decompressions set parameters */ - if (CM_curCompControlParams.maxCmActivities > 0) + if (CM_curCompControlParams.maxCmActivities > 0) { compAvail = CM_curCompControlParams.maxCompressions; decompAvail = CM_curCompControlParams.maxCmActivities - compAvail; } - else + else { compAvail = 0; decompAvail = 0; - } - - /* - * CM_availCompThreads and CM_availDecompThreads can be negative. For example, - * if previously CM_availCompThreads is 0, CM_usedCompThreads is 5; + } + + /* + * CM_availCompThreads and CM_availDecompThreads can be negative. For example, + * if previously CM_availCompThreads is 0, CM_usedCompThreads is 5; * CM_availDecompThreads is 0, CM_usedDecompThreads is 5, * now due to change of maxCompressions, compAvail is 2, decompAvail is 8. - * CM_availCompThreads can be set to (2 - 5) = -3. New comp thread won't be started until - * more than 3 comp threads are returned. - * + * CM_availCompThreads can be set to (2 - 5) = -3. New comp thread won't be started until + * more than 3 comp threads are returned. + * */ CM_availCompThreads = compAvail - CM_usedCompThreads; CM_availDecompThreads = decompAvail - CM_usedDecompThreads; @@ -936,9 +936,9 @@ CM_initThreads() CM_usedCompThreads = 0; CM_usedDecompThreads = 0; - + CM_threadsChange(); - + DQ_INIT(&CM_activities); } @@ -947,11 +947,11 @@ CM_initThreads() #define START_COMP_THREAD(_activity) \ - WORK_Schedule(&activity->fsm, (voidfunc_t)CM_activityWorkToDoRun, NULL) + WORK_Schedule(&activity->fsm, CM_activityWorkToDoRun, NULL) /* Decompression activities are always run as WorkToDo's */ #define START_DECOMP_THREAD(_activity) \ - WORK_Schedule(&activity->fsm, (voidfunc_t)CM_activityWorkToDoRun, NULL) + WORK_Schedule(&activity->fsm, CM_activityWorkToDoRun, NULL) BOOL CM_startActivity(CMActivity_s *activity) @@ -962,11 +962,11 @@ CM_startActivity(CMActivity_s *activity) zASSERT(activity->state == CM_ACTIVITY_STATE_RUNNABLE); - if ((activity->op == CM_ACTIVITY_OP_COMPRESS) + if ((activity->op == CM_ACTIVITY_OP_COMPRESS) && (( CM_usedCompThreads + CM_usedDecompThreads) < CM_maxActivities) - && (CM_availCompThreads > 0)) + && (CM_availCompThreads > 0)) { - -- CM_availCompThreads; + -- CM_availCompThreads; ++ CM_usedCompThreads; activity->state = CM_ACTIVITY_STATE_RUNNING; @@ -974,22 +974,22 @@ CM_startActivity(CMActivity_s *activity) /* update the screen */ X_LATCH(&CM_curCompStatistics.latch); - displayCompNames(); + displayCompNames(); UNX_LATCH(&CM_curCompStatistics.latch); return TRUE; } else if ((activity->op == CM_ACTIVITY_OP_DECOMPRESS) && (( CM_usedCompThreads + CM_usedDecompThreads) < CM_maxActivities) - && (CM_availDecompThreads > 0)) + && (CM_availDecompThreads > 0)) { -- CM_availDecompThreads; - ++ CM_usedDecompThreads; + ++ CM_usedDecompThreads; activity->state = CM_ACTIVITY_STATE_RUNNING; /* update the screen */ X_LATCH(&CM_curCompStatistics.latch); - displayCompNames(); + displayCompNames(); UNX_LATCH(&CM_curCompStatistics.latch); START_DECOMP_THREAD(activity); @@ -1027,8 +1027,8 @@ CM_threadExit(CMActivity_s *activity) ++ CM_availCompThreads; -- CM_usedCompThreads; } - else - { + else + { zASSERT(activity->op == CM_ACTIVITY_OP_DECOMPRESS); ++ CM_availDecompThreads; -- CM_usedDecompThreads; @@ -1058,7 +1058,7 @@ CM_runtimeInit() CM_initThreads(); rc = CM_activityPoolInit(CM_curCompControlParams.maxCmActivities); if (rc != zOK) - return rc; + return rc; return zOK; } diff --git a/include/nwnss/include/cmRuntime.h b/src/nwnss/comn/compression/cmRuntime.h similarity index 98% rename from include/nwnss/include/cmRuntime.h rename to src/nwnss/comn/compression/cmRuntime.h index 884a6c3..60de467 100644 --- a/include/nwnss/include/cmRuntime.h +++ b/src/nwnss/comn/compression/cmRuntime.h @@ -51,7 +51,7 @@ void CM_threadExit(struct CMActivity_s *activity); STATUS CM_awaitEvent(ADDR event); SNINT CM_signalEvent(ADDR event, STATUS retCode); STATUS CM_activityAlloc( - NINT activityOp, + NINT activityOp, struct CMActivity_s **activity, /* out */ BOOL wait); void CM_activityFree(struct CMActivity_s *activity); @@ -62,7 +62,7 @@ extern DQhead_t CM_activities; /* * This iterator can be safely used to browse thru a queue while removing the - * current cursor element inside the body of the loop. + * current cursor element inside the body of the loop. * You still have to ensure that nobody modifies the queue while the iteration * is in progress. * Adapted from DQ_FOREACH() macro in que.h @@ -82,7 +82,7 @@ extern DQhead_t CM_activities; #define DQ_INSERT_BEFORE(__item, __newItem, linkField) \ DQ_ENQ((DQhead_t *)(&(__item)->linkField), __newItem, linkField) -typedef struct DataWaiter_s +typedef struct DataWaiter_s { DQlink_t waitqLink; ADDR threadID; diff --git a/src/nwnss/comn/compression/comnCompress.c b/src/nwnss/comn/compression/comnCompress.c index bdf7e5d..6635ca1 100644 --- a/src/nwnss/comn/compression/comnCompress.c +++ b/src/nwnss/comn/compression/comnCompress.c @@ -33,14 +33,14 @@ |--------------------------------------------------------------------------- | Module Description: | - +-------------------------------------------------------------------------*/ + +-------------------------------------------------------------------------*/ #include "nwAlgo.h" -#include +#include #include -#include "pssStartup.h" -#include "cmDefs.h" +#include "pssStartup.h" +#include "cmDefs.h" #include "cmNSS.h" #include "comnIO.h" #include "comnBeastClass.h" @@ -58,25 +58,13 @@ #include "cdcommon.h" #include "msgIO.h" -#ifdef NSS_USERSPACE -#ifndef ZOS_StartThread -#define ZOS_StartThread(_thread, _name, _func, _arg1, _arg2, _arg3) \ - do { (_thread) = 0; (void)(_name); (void)(_func); (void)(_arg1); (void)(_arg2); (void)(_arg3); } while (0) -#endif -#ifndef ZOS_StartThreadWithModuleHandle -#define ZOS_StartThreadWithModuleHandle(_thread, _name, _func, _arg1, _arg2, _arg3, _module) \ - do { (_thread) = 0; (void)(_name); (void)(_func); (void)(_arg1); (void)(_arg2); (void)(_arg3); (void)(_module); } while (0) -#endif -#define kDestroyThread(_thread) zOK -#endif - /* comp status */ NINT compStatusBitsToCheck = ( - COMP_STATUS_UNCOMPRESSED | COMP_STATUS_COMPRESSED | + COMP_STATUS_UNCOMPRESSED | COMP_STATUS_COMPRESSED | COMP_STATUS_FAILURE | COMP_STATUS_CLEAN); -utf8_t *compStatusTags[] = +utf8_t *compStatusTags[] = { TAG_UNCOMPRESSED, TAG_COMPRESSED, @@ -88,7 +76,7 @@ utf8_t *compStatusTags[] = /* comp action */ NINT compActionBitsToCheck = (COMP_ACTION_ADD_COMPLOG | COMP_ACTION_ENABLE_IO_WRITE); -utf8_t *compActionTags[] = +utf8_t *compActionTags[] = { TAG_ADDCOMPLOG, TAG_ENABLEIOWRITE, @@ -102,18 +90,18 @@ STATUS COMP_BST_GetInfoXML( NINT bufLen, utf8_t *buf, NINT *infoLen); - + STATUS COMP_BST_ModifyInfoXML( GeneralMsg_s *genMsg, RootBeast_s *rBeast, NINT bufLen, utf8_t *buf, - Xaction_s *xaction, + Xaction_s *xaction, BOOL doChange); /**************************************************************************** * COMMON OPS definition - * + * *****************************************************************************/ /*--------------------------------------------------------------------------- @@ -152,26 +140,26 @@ CommonBeastOps_s CompBeastComnOps = COMP_BST_GetInfoXML, /* BST_getInfoXML*/ COMP_BST_ModifyInfoXML /* BST_modifyInfoXML*/ }; -BeastClassRegisterInfo_s CompClassList[] = +BeastClassRegisterInfo_s CompClassList[] = { {MSGNot(L"CompressionBeast"), zFTYPE_COMPRESSION, zFTYPE_ROOT_BEAST, - sizeof(CompBeast_s), + sizeof(CompBeast_s), &CompBeastComnOps, NULL, NULL, NULL}, - + {MSGNot(L"CompressionBeastIntermediate"), zFTYPE_COMPRESSION_INTERMEDIATE, zFTYPE_ROOT_BEAST, - sizeof(CompBeast_s), + sizeof(CompBeast_s), NULL, NULL, NULL, NULL}, - + {NULL} /* end of list */ }; @@ -184,26 +172,23 @@ BeastClassRegisterInfo_s CompClassList[] = #define CMUpgrade_shutdownWaitSeconds 30 - + typedef struct CMUpgrade_s { THREAD threadID; BOOL shuttingDown; BOOL inProgress; BOOL threadStarted; -} CMUpgrade_s; - +} CMUpgrade_s; + CMUpgrade_s CM_Upgrade = {0}; - + NINT COMP_EnableIOFailWarningTime = 0; #define COMP_EnableIOFailWarningInterval (30 * 60) /* 30 minutes */ extern void BST_SignalToss(Agent_s *agent); -typedef STATUS (*comp_get_info_xml_func_t)(GeneralMsg_s *, void *, NINT, NINT, utf8_t *, NINT *); -typedef STATUS (*comp_modify_info_xml_func_t)(GeneralMsg_s *, RootBeast_s *, NINT, utf8_t *, Xaction_s *, BOOL); - CompFixStats_s CompFixStats = {0}; STATIC STATUS COMN_GetStorageInfoInternal( @@ -235,15 +220,15 @@ STATUS COMP_BST_GetInfoXML( Stack_s *aStack; /* Call parent routine */ - derivedFromGetInfoXML = COMN_GetNextParentBeastComnOp(beast->COMProot.beastClass, - COMNOPS_INDEX(BST_getInfoXML), (statusfunc_t)COMP_BST_GetInfoXML); + derivedFromGetInfoXML = COMN_GetNextParentBeastComnOp(beast->COMProot.beastClass, + COMNOPS_INDEX(BST_getInfoXML), COMP_BST_GetInfoXML); if (derivedFromGetInfoXML != NULL && - ((comp_get_info_xml_func_t)derivedFromGetInfoXML)(genMsg, beast, typeOfInfo, bufLen, buf, infoLen) != zOK) + derivedFromGetInfoXML(genMsg, beast, typeOfInfo, bufLen, buf, infoLen) != zOK) { return zFAILURE; } - + if (!(typeOfInfo & BST_INFO_COMPRESSION)) { return zOK; @@ -252,7 +237,7 @@ STATUS COMP_BST_GetInfoXML( STACK_ALLOC_NO_ASTACK(); bufLen -= *infoLen; - + strcpy(&aStack->tmpBuf[len], "<"TAG_COMPBEASTINFO">"); len += strlen(&aStack->tmpBuf[len]); @@ -287,7 +272,7 @@ STATUS COMP_BST_ModifyInfoXML( RootBeast_s *rBeast, NINT bufLen, utf8_t *buf, - Xaction_s *xaction, + Xaction_s *xaction, BOOL doChange) { STATUS status = zOK; @@ -296,7 +281,7 @@ STATUS COMP_BST_ModifyInfoXML( XML_ElementInfo_s elementInfo; utf8_t *copyBuf = NULL; - const TagRequest_s tags[] = + const TagRequest_s tags[] = { {TAG_UNCOMPZID, TR_OPTIONAL}, {0} @@ -307,18 +292,18 @@ STATUS COMP_BST_ModifyInfoXML( { UNCOMP_ZID = 0, }; - + /* Call parent routine */ - derivedFromSetInfoXML = COMN_GetNextParentBeastComnOp(beast->COMProot.beastClass, - COMNOPS_INDEX(BST_modifyInfoXML), (statusfunc_t)COMP_BST_ModifyInfoXML); - if (derivedFromSetInfoXML != NULL && - ((comp_modify_info_xml_func_t)derivedFromSetInfoXML)(genMsg, rBeast, bufLen, buf, xaction, doChange) != zOK) + derivedFromSetInfoXML = COMN_GetNextParentBeastComnOp(beast->COMProot.beastClass, + COMNOPS_INDEX(BST_modifyInfoXML), COMP_BST_ModifyInfoXML); + if (derivedFromSetInfoXML != NULL && + derivedFromSetInfoXML(genMsg, rBeast, bufLen, buf, xaction, doChange) != zOK) { return zFAILURE; } - /* make another copy of buf, buf will be changed - * while doing MNSS_GetTagContents + /* make another copy of buf, buf will be changed + * while doing MNSS_GetTagContents */ copyBuf = malloc(bufLen); if (copyBuf == NULL) @@ -328,13 +313,13 @@ STATUS COMP_BST_ModifyInfoXML( } memcpy(copyBuf, buf, bufLen); - if (XML_GetTagElement(TAG_COMPBEASTINFO, copyBuf, copyBuf + bufLen - 1, + if (XML_GetTagElement(TAG_COMPBEASTINFO, copyBuf, copyBuf + bufLen - 1, &elementInfo) == zFAILURE) { // No compBeast related info needs to be modified goto Exit; } - + if (elementInfo.dataStart == NULL) { // no actual data @@ -350,7 +335,7 @@ STATUS COMP_BST_ModifyInfoXML( if (tagContent[UNCOMP_ZID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - modifyInfoNumber(genMsg, rBeast, Zid_t, FALSE, + modifyInfoNumber(genMsg, rBeast, Zid_t, FALSE, (ADDR)&beast->p.uncompZid, &tagContent[UNCOMP_ZID].element); } @@ -390,7 +375,7 @@ STATUS COMP_GetVariableDataXML( strcpy(&aStack->tmpBuf[len], "<"TAG_VARIABLEDATACOMP">"); len += strlen(&aStack->tmpBuf[len]); - sprintf(&aStack->tmpBuf[len], + sprintf(&aStack->tmpBuf[len], "<"TAG_COMPZID">%Lu" "<"TAG_CHUNKSIZE">%u" "<"TAG_UCPRECIOUS">%u" @@ -401,7 +386,7 @@ STATUS COMP_GetVariableDataXML( "<"TAG_PURGEABLEBLKS">%d" #endif "<"TAG_ALGOID">%d" - "<"TAG_ALGOVERSION">%d", + "<"TAG_ALGOVERSION">%d", compInfo->p.compZid, compInfo->p.chunkSize, compInfo->p.UCprecious, @@ -413,7 +398,7 @@ STATUS COMP_GetVariableDataXML( sprintf(&aStack->tmpBuf[len], "<"TAG_STATUS">"); len += strlen(&aStack->tmpBuf[len]); - + if ((status = MNSS_ConvertBitsToTags((QUAD)compInfo->p.status, (QUAD)compStatusBitsToCheck, compStatusTags, bufLen - len, &aStack->tmpBuf[len], &tmpLen)) != zOK) @@ -422,13 +407,13 @@ STATUS COMP_GetVariableDataXML( } len += tmpLen; - + sprintf(&aStack->tmpBuf[len], ""); len += strlen(&aStack->tmpBuf[len]); - + sprintf(&aStack->tmpBuf[len], "<"TAG_ACTION">"); len += strlen(&aStack->tmpBuf[len]); - + if ((status = MNSS_ConvertBitsToTags((QUAD)compInfo->p.action, (QUAD)compActionBitsToCheck, compActionTags, bufLen - len, &aStack->tmpBuf[len], &tmpLen)) != zOK) @@ -440,7 +425,7 @@ STATUS COMP_GetVariableDataXML( sprintf(&aStack->tmpBuf[len], ""); len += strlen(&aStack->tmpBuf[len]); - + strcpy(&aStack->tmpBuf[len], ""); len += strlen(&aStack->tmpBuf[len]); @@ -469,7 +454,7 @@ STATUS compInfoStatusChangeFunc( void *newStatusAddr, Xaction_s *xaction) { - RootBeast_s *uncompBeast = (RootBeast_s *)beast; + RootBeast_s *uncompBeast = (RootBeast_s *)beast; CompressInfo_s *compInfo = BEAST_CM_INFO(uncompBeast); BYTE newStatus = *(BYTE *)newStatusAddr; @@ -478,7 +463,7 @@ STATUS compInfoStatusChangeFunc( return zOK; } - if (compInfo->p.UCprecious == 1 && compInfo->p.Cprecious == 1 && + if (compInfo->p.UCprecious == 1 && compInfo->p.Cprecious == 1 && !(newStatus & COMP_STATUS_CLEAN)) { return CM_tossUncompBeastData(genMsg, uncompBeast, NULL, TRUE); @@ -494,7 +479,7 @@ STATUS compInfoActionChangeFunc( void *newActionAddr, Xaction_s *xaction) { - RootBeast_s *uncompBeast = (RootBeast_s *)beast; + RootBeast_s *uncompBeast = (RootBeast_s *)beast; BYTE oldAction = *(BYTE *)oldActionAddr; BYTE newAction = *(BYTE *)newActionAddr; BYTE changedBits = oldAction ^ newAction; @@ -504,7 +489,7 @@ STATUS compInfoActionChangeFunc( { SETUP_BEAST_COMP_CLEANUP_PURGE_LOG(&purgeLogMsg, uncompBeast); uncompBeast->ROOTcomnVolOps.VOL_removePurgeLogEntry(genMsg, - uncompBeast->vol.volume, PLOG_BEAST_COMP_CLEANUP, + uncompBeast->vol.volume, PLOG_BEAST_COMP_CLEANUP, &purgeLogMsg, xaction); } @@ -521,7 +506,7 @@ STATUS COMP_SetVariableDataXML( RootBeast_s *beast, NINT bufLen, utf8_t *buf, - Xaction_s *xaction, + Xaction_s *xaction, BOOL doChange) { STATUS status = zOK; @@ -529,7 +514,7 @@ STATUS COMP_SetVariableDataXML( CompressInfo_s *compInfo; utf8_t *copyBuf = NULL; - const TagRequest_s tags[] = + const TagRequest_s tags[] = { {TAG_COMPZID, TR_OPTIONAL}, {TAG_CHUNKSIZE, TR_OPTIONAL}, @@ -556,15 +541,15 @@ STATUS COMP_SetVariableDataXML( STATUS = 7, ACTION = 8 }; - + compInfo = BEAST_CM_INFO(beast); if (!compInfo) { return zOK; } - /* make another copy of buf, buf will be changed - * while doing MNSS_GetTagContents + /* make another copy of buf, buf will be changed + * while doing MNSS_GetTagContents */ copyBuf = malloc(bufLen); if (copyBuf == NULL) @@ -574,13 +559,13 @@ STATUS COMP_SetVariableDataXML( } memcpy(copyBuf, buf, bufLen); - if (XML_GetTagElement(TAG_VARIABLEDATACOMP, copyBuf, copyBuf + bufLen - 1, + if (XML_GetTagElement(TAG_VARIABLEDATACOMP, copyBuf, copyBuf + bufLen - 1, &elementInfo) == zFAILURE) { // No comp variable data related info needs to be modified goto Exit; } - + if (elementInfo.dataStart == NULL) { // no actual data @@ -596,57 +581,57 @@ STATUS COMP_SetVariableDataXML( if (tagContent[COMP_ZID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - modifyInfoNumber(genMsg, beast, Zid_t, FALSE, + modifyInfoNumber(genMsg, beast, Zid_t, FALSE, (ADDR)&compInfo->p.compZid, &tagContent[COMP_ZID].element); } if (tagContent[CHUNK_SIZE].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - modifyInfoNumber(genMsg, beast, LONG, FALSE, + modifyInfoNumber(genMsg, beast, LONG, FALSE, (ADDR)&compInfo->p.chunkSize, &tagContent[CHUNK_SIZE].element); } if (tagContent[UC_PRECIOUS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - modifyInfoNumber(genMsg, beast, LONG, FALSE, + modifyInfoNumber(genMsg, beast, LONG, FALSE, (ADDR)&compInfo->p.UCprecious, &tagContent[UC_PRECIOUS].element); } if (tagContent[C_PRECIOUS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - modifyInfoNumber(genMsg, beast, LONG, FALSE, + modifyInfoNumber(genMsg, beast, LONG, FALSE, (ADDR)&compInfo->p.Cprecious, &tagContent[C_PRECIOUS].element); } if (tagContent[PURGEABLE_BLKS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - modifyInfoNumber(genMsg, beast, Blknum_t, TRUE, + modifyInfoNumber(genMsg, beast, Blknum_t, TRUE, (ADDR)&compInfo->p.purgeableBlks, &tagContent[PURGEABLE_BLKS].element); } if (tagContent[ALGO_ID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - modifyInfoNumber(genMsg, beast, BYTE, FALSE, + modifyInfoNumber(genMsg, beast, BYTE, FALSE, (ADDR)&compInfo->p.algoID, &tagContent[ALGO_ID].element); } if (tagContent[ALGO_VERSION].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - modifyInfoNumber(genMsg, beast, BYTE, FALSE, + modifyInfoNumber(genMsg, beast, BYTE, FALSE, (ADDR)&compInfo->p.algoVersion, &tagContent[ALGO_VERSION].element); } if (tagContent[STATUS].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - modifyFlagsInfoXML(genMsg, beast, BYTE, (ADDR)&compInfo->p.status, - &tagContent[STATUS].element, (QUAD)compStatusBitsToCheck, + modifyFlagsInfoXML(genMsg, beast, BYTE, (ADDR)&compInfo->p.status, + &tagContent[STATUS].element, (QUAD)compStatusBitsToCheck, (utf8_t **)compStatusTags, compInfoStatusChangeFunc); } if (tagContent[ACTION].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - modifyFlagsInfoXML(genMsg, beast, BYTE, (ADDR)&compInfo->p.action, - &tagContent[ACTION].element, (QUAD)compActionBitsToCheck, + modifyFlagsInfoXML(genMsg, beast, BYTE, (ADDR)&compInfo->p.action, + &tagContent[ACTION].element, (QUAD)compActionBitsToCheck, (utf8_t **)compActionTags, compInfoActionChangeFunc); } @@ -686,7 +671,7 @@ STATUS UNCOMP_GetVariableDataXML( strcpy(&aStack->tmpBuf[len], "<"TAG_VARIABLEDATAUNCOMP">"); len += strlen(&aStack->tmpBuf[len]); - sprintf(&aStack->tmpBuf[len], + sprintf(&aStack->tmpBuf[len], "<"TAG_UNCOMPZID">%Lu" "<"TAG_UNCOMPPARENTZID">%u", uncompInfo->uncompBeastZid, @@ -710,7 +695,7 @@ STATUS UNCOMP_GetVariableDataXML( header = (compressFileHeader_t *)cmBuf->pBuf.data; - sprintf(&aStack->tmpBuf[len], + sprintf(&aStack->tmpBuf[len], "<"TAG_COMPHEADER">" "<"TAG_COMPRESSCODE">%d" "<"TAG_COMPRESSMAJORVERSION">%d" @@ -758,7 +743,7 @@ STATUS UNCOMP_SetVariableDataXML( RootBeast_s *beast, NINT bufLen, utf8_t *buf, - Xaction_s *xaction, + Xaction_s *xaction, BOOL doChange) { STATUS status = zOK; @@ -766,7 +751,7 @@ STATUS UNCOMP_SetVariableDataXML( UncompressInfo_s *uncompInfo; utf8_t *copyBuf = NULL; - const TagRequest_s tags[] = + const TagRequest_s tags[] = { {TAG_UNCOMPZID, TR_OPTIONAL}, {TAG_UNCOMPPARENTZID, TR_OPTIONAL}, @@ -781,15 +766,15 @@ STATUS UNCOMP_SetVariableDataXML( UNCOMP_PARENT_ZID = 1, UNCOMP_BEAST_DELETED = 2, }; - + uncompInfo = (UncompressInfo_s *)(*beast->variableData)[RVD_UNCOMP_DATA]; if (!uncompInfo) { return zOK; } - /* make another copy of buf, buf will be changed - * while doing MNSS_GetTagContents + /* make another copy of buf, buf will be changed + * while doing MNSS_GetTagContents */ copyBuf = malloc(bufLen); if (copyBuf == NULL) @@ -799,13 +784,13 @@ STATUS UNCOMP_SetVariableDataXML( } memcpy(copyBuf, buf, bufLen); - if (XML_GetTagElement(TAG_VARIABLEDATAUNCOMP, copyBuf, copyBuf + bufLen - 1, + if (XML_GetTagElement(TAG_VARIABLEDATAUNCOMP, copyBuf, copyBuf + bufLen - 1, &elementInfo) == zFAILURE) { // No uncomp variable data related info needs to be modified goto Exit; } - + if (elementInfo.dataStart == NULL) { // no actual data @@ -821,13 +806,13 @@ STATUS UNCOMP_SetVariableDataXML( if (tagContent[UNCOMP_ZID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - modifyInfoNumber(genMsg, beast, Zid_t, FALSE, (ADDR)&uncompInfo->uncompBeastZid, + modifyInfoNumber(genMsg, beast, Zid_t, FALSE, (ADDR)&uncompInfo->uncompBeastZid, &tagContent[UNCOMP_ZID].element); } if (tagContent[UNCOMP_PARENT_ZID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - modifyInfoNumber(genMsg, beast, Zid_t, FALSE, (ADDR)&uncompInfo->uncompParentZid, + modifyInfoNumber(genMsg, beast, Zid_t, FALSE, (ADDR)&uncompInfo->uncompParentZid, &tagContent[UNCOMP_PARENT_ZID].element); } @@ -869,7 +854,7 @@ BOOL CM_SetCompBeastData( if (COMN_InitRootVariableData(&genMsg, compBeast) != zOK) { - return FALSE; + return FALSE; } } uncompInfo = (*compBeast->ROOTvariableData)[RVD_UNCOMP_DATA]; @@ -889,8 +874,8 @@ BOOL CM_SetCompBeastData( { uncompInfo->uncompParentZid = ((NamedBeast_s *)uncompBeast)-> NAMEDfirstParentZid; - uncompInfo->uncompBeastDeleted = - (((NamedBeast_s *)uncompBeast)->NAMEDnumParents == 0) || + uncompInfo->uncompBeastDeleted = + (((NamedBeast_s *)uncompBeast)->NAMEDnumParents == 0) || NAME_AllNamesInSalvage(uncompBeast); } else @@ -920,8 +905,8 @@ RootBeast_s *CM_LookupCompBeast( ASSERT_MPKNSS_LOCK(); zASSERT(compInfo); - compBeast = COMN_LookupByZid(genMsg, beast->ROOTvolume, compInfo->p.compZid, - latchType, TRUE); + compBeast = COMN_LookupByZid(genMsg, beast->ROOTvolume, compInfo->p.compZid, + latchType, TRUE); if (compBeast == NULL) { return NULL; @@ -935,7 +920,7 @@ RootBeast_s *CM_LookupCompBeast( /* * Every compressible root beast (i.e. data stream) has a compression-related - * metadata structure (CompressInfo_s) stored in its RootVariableData area. + * metadata structure (CompressInfo_s) stored in its RootVariableData area. * To compress a data stream, we create a RootBeast * and create a reference to it in the data stream's rootbeast. This reference * and other compression status related info is held in the above CompressInfo_s @@ -956,7 +941,7 @@ STATIC NINT CM_PackedSizeRootVariableData( if (BEAST_CM_INFO(beast) == NULL) return 0; - else + else return (sizeof(PackedCompInfo_s)); } @@ -1001,7 +986,7 @@ STATIC STATUS CM_AllocRootVariableData( if (COMN_InitRootVariableData(genMsg, beast) != zOK) return zFAILURE; - + compInfo = (CompressInfo_s *)malloc(sizeof(CompressInfo_s)); if (compInfo == NULL) { @@ -1010,19 +995,19 @@ STATIC STATUS CM_AllocRootVariableData( } SET_BEAST_CM_INFO(beast, compInfo); - if (persistentCompressInfo) + if (persistentCompressInfo) { memmove(&compInfo->p, persistentCompressInfo, sizeof(PersistentCompressInfo_s)); } - else + else { VolumeCompAttr_s *compAttributes = &beast->ROOTvolume->VOLcompAttributes; bzero(compInfo, sizeof(*compInfo)); compInfo->p.compZid = zINVALID_ZID; compInfo->p.chunkSize = compAttributes->chunkSize; - compInfo->p.UCprecious = (compInfo->p.chunkSize != 0) + compInfo->p.UCprecious = (compInfo->p.chunkSize != 0) ? GET_DATASTREAM_SIZE(beast) / compInfo->p.chunkSize : 1; compInfo->p.Cprecious = 0; @@ -1068,7 +1053,7 @@ STATIC BYTE *CM_UnpackRootVariableData( if (CM_AllocRootVariableData(genMsg, beast, &packedInfo->cmInfo) != zOK) return NULL; } - + return (storeBuffer + sizeof(PackedCompInfo_s)); } @@ -1079,20 +1064,20 @@ BYTE *CM_FreeRootVariableData( RootBeast_s *beast) { CompressInfo_s *compInfo = BEAST_CM_INFO(beast); - DataWaiter_s *waiter; + DataWaiter_s *waiter; CMActivity_s *activity; - + ASSERT_MPKNSS_LOCK(); - if (compInfo) + if (compInfo) { zASSERT(DQ_EMPTY(&compInfo->CM_activities)); while (DQ_NOT_EMPTY(&compInfo->CM_activities)) - { + { DQ_TAKE(&compInfo->CM_activities, activity, CMActivity_s, beastActivitiesChain); free(activity); - } - + } + zASSERT(DQ_EMPTY(&compInfo->dataWaiters)); while (DQ_NOT_EMPTY(&compInfo->dataWaiters)) { @@ -1137,7 +1122,7 @@ STATIC BYTE *CM_CompressUnpackRootVariableData( { if (COMN_InitRootVariableData(genMsg, beast) != zOK) { - return NULL; + return NULL; } return storeBuffer; } @@ -1163,14 +1148,14 @@ STATUS fixCompFlags( RootBeast_s *compBeast; RootBeast_s *uncompBeast = (RootBeast_s *)beast; PurgeLogMsg_s purgeLogMsg; - STATUS status = zOK; + STATUS status = zOK; ASSERT_XLATCH(&uncompBeast->ROOTbeastLatch); zASSERT(!(beast->NAMEDattributes & zFA_SUBDIRECTORY)); zASSERT(beast->openCount == 0); compInfo = BEAST_CM_INFO(uncompBeast); - + if (compInfo && DQ_EMPTY(&compInfo->CM_activities)) { if (compInfo->p.UCprecious == 1 && compInfo->p.Cprecious == 1) @@ -1184,7 +1169,7 @@ STATUS fixCompFlags( else if (compInfo->p.UCprecious == 0 && compInfo->p.Cprecious == 1 && CHUNK_COMPRESSED(compInfo->p.status) && !CHUNK_UNCOMPRESSED(compInfo->p.status) && (!BEAST_CLEAN(compInfo->p.status) || - !(beast->NAMEDattributes & zFA_DATA_STREAM_IS_COMPRESSED) || + !(beast->NAMEDattributes & zFA_DATA_STREAM_IS_COMPRESSED) || (compInfo->p.action & COMP_ACTION_ADD_COMPLOG))) { zASSERT("UC = 0, C = 1 (OK to hit go)"==NULL); @@ -1204,15 +1189,15 @@ STATUS fixCompFlags( { SETUP_BEAST_COMP_CLEANUP_PURGE_LOG(&purgeLogMsg, uncompBeast); uncompBeast->ROOTcomnVolOps.VOL_removePurgeLogEntry(genMsg, - uncompBeast->vol.volume, PLOG_BEAST_COMP_CLEANUP, + uncompBeast->vol.volume, PLOG_BEAST_COMP_CLEANUP, &purgeLogMsg, localXaction); } else { compInfo->p.action |= COMP_ACTION_ADD_COMPLOG; } - } - + } + if (status == zOK) { if (!(beast->NAMEDattributes & zFA_DATA_STREAM_IS_COMPRESSED)) @@ -1220,7 +1205,7 @@ STATUS fixCompFlags( setBeastCompAttr(uncompBeast, zFA_DATA_STREAM_IS_COMPRESSED, localXaction, FALSE); setVolCompStats(uncompBeast, compBeast, localXaction, TRUE); } - + if (!BEAST_CLEAN(compInfo->p.status)) { compInfo->p.status |= COMP_STATUS_CLEAN; @@ -1245,7 +1230,7 @@ STATUS fixCompFlags( CompFixStats.case3++; if (!CHUNK_COMPRESSED(compInfo->p.status) && CHUNK_UNCOMPRESSED(compInfo->p.status) && - (!BEAST_CLEAN(compInfo->p.status) || + (!BEAST_CLEAN(compInfo->p.status) || (beast->NAMEDattributes & zFA_DATA_STREAM_IS_COMPRESSED) || (compInfo->p.action & COMP_ACTION_ADD_COMPLOG))) { @@ -1261,15 +1246,15 @@ STATUS fixCompFlags( { SETUP_BEAST_COMP_CLEANUP_PURGE_LOG(&purgeLogMsg, uncompBeast); uncompBeast->ROOTcomnVolOps.VOL_removePurgeLogEntry(genMsg, - uncompBeast->vol.volume, PLOG_BEAST_COMP_CLEANUP, + uncompBeast->vol.volume, PLOG_BEAST_COMP_CLEANUP, &purgeLogMsg, localXaction); } else { compInfo->p.action |= COMP_ACTION_ADD_COMPLOG; } - } - + } + if (status == zOK) { if (beast->NAMEDattributes & zFA_DATA_STREAM_IS_COMPRESSED) @@ -1282,7 +1267,7 @@ STATUS fixCompFlags( COMN_UnlatchAndRelease(&compBeast, XLATCHED); } } - + if (!BEAST_CLEAN(compInfo->p.status)) { compInfo->p.status |= COMP_STATUS_CLEAN; @@ -1295,10 +1280,10 @@ STATUS fixCompFlags( COMN_EndXLocal(uncompBeast, &localXaction); } else if (CHUNK_COMPRESSED(compInfo->p.status) && !CHUNK_UNCOMPRESSED(compInfo->p.status) && - BEAST_CLEAN(compInfo->p.status) && compInfo->p.compZid != zINVALID_ZID) + BEAST_CLEAN(compInfo->p.status) && compInfo->p.compZid != zINVALID_ZID) { /* There was a problem prior to NW65 SP3 release that when a file finishes compression - * and does compCleanup inside CM_activityDone, it is possible that zFAILURE is returned + * and does compCleanup inside CM_activityDone, it is possible that zFAILURE is returned * at the place where uncompBeast data is being truncated. Because error handling in * CM_activityDone is not correct, file will go into this invalid state. Without the following * fix code, file will end up with no data left. @@ -1345,16 +1330,16 @@ void compUpgradeOnVolume( Zid_t beastZids[MAX_ZIDS_PER_SCOOP]; BYTE errString[200]; } Stack_s; - + Zid_t lastZidReturned; - RootBeast_s *beast; + RootBeast_s *beast; RootBeast_s *compBeast = NULL; RootBeast_s *compBeast2 = NULL; BeastClass_s *rootBeastClass; BeastClass_s *compBeastClass; BeastClass_s *compBeastInterClass; /* class for intermediate compBeast */ CompressInfo_s *compInfo; - NINT numBeastsReturned; + NINT numBeastsReturned; BOOL markVolumeDone = TRUE; Xaction_s *xaction; NINT i; @@ -1371,13 +1356,13 @@ void compUpgradeOnVolume( rootBeastClass = BST_GetBeastClass(zFTYPE_ROOT_BEAST); compBeastClass = BST_GetBeastClass(zFTYPE_COMPRESSION); compBeastInterClass = BST_GetBeastClass(zFTYPE_COMPRESSION_INTERMEDIATE); - - lastZidReturned = zINVALID_ZID; - + + lastZidReturned = zINVALID_ZID; + do { - if (CM_Upgrade.shuttingDown) + if (CM_Upgrade.shuttingDown) { CM_Upgrade.inProgress = FALSE; (void)NSSLOG_EventLogWithVolume( volume, CMN_ModuleHandle, @@ -1398,8 +1383,8 @@ void compUpgradeOnVolume( } /* Obtain a scoop of ZIDs to examine */ - if (volume->VOLcomnVolOps.VOL_browseBeastsInVolume(&genMsg, volume, - SELECT_BEASTS_FOR_COMPRESSION, MAX_ZIDS_PER_SCOOP, + if (volume->VOLcomnVolOps.VOL_browseBeastsInVolume(&genMsg, volume, + SELECT_BEASTS_FOR_COMPRESSION, MAX_ZIDS_PER_SCOOP, &lastZidReturned, aStack->beastZids, &numBeastsReturned) != zOK) { aprintf(CYAN, @@ -1416,7 +1401,7 @@ void compUpgradeOnVolume( compBeast2 = NULL; compBeast = NULL; - if (CM_Upgrade.shuttingDown) + if (CM_Upgrade.shuttingDown) { CM_Upgrade.inProgress = FALSE; (void)NSSLOG_EventLogWithVolume( volume, CMN_ModuleHandle, @@ -1427,7 +1412,7 @@ void compUpgradeOnVolume( } if (volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) - { + { /* if volume is deactivating */ (void)NSSLOG_EventLogWithVolume( volume, CMN_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_MEDIA_UPGRADE, MSGNot("Compression upgrade deactivation.") ); @@ -1437,7 +1422,7 @@ void compUpgradeOnVolume( } /* Obtain the beast */ - beast = (RootBeast_s *)COMN_LookupByZid(&genMsg, volume, + beast = (RootBeast_s *)COMN_LookupByZid(&genMsg, volume, aStack->beastZids[i], XLATCHED, TRUE); /* Ignore all errors */ @@ -1454,10 +1439,10 @@ void compUpgradeOnVolume( ClearErrno(&genMsg); continue; } - + ClearErrno(&genMsg); compInfo = BEAST_CM_INFO(beast); - if (!compInfo) + if (!compInfo) { /* beast is uncompressed */ goto unlatchAndContinue; @@ -1481,7 +1466,7 @@ void compUpgradeOnVolume( * between NW6.1 beta1 and beta2. It can be ignored if nobody upgrades * volume from beta1 to beta2. */ - if (!compInfo->p.algoVersion) + if (!compInfo->p.algoVersion) { /* In NW6.1 beta1 code, compBeast also has compInfo, but except for * zid field, everything else is zero @@ -1495,10 +1480,10 @@ void compUpgradeOnVolume( goto unlatchAndContinue; } /*================================================================================*/ - - compBeast = (RootBeast_s *)CM_LookupCompBeast(&genMsg, beast, - compInfo, XLATCHED); - if (!compBeast) + + compBeast = (RootBeast_s *)CM_LookupCompBeast(&genMsg, beast, + compInfo, XLATCHED); + if (!compBeast) { zASSERT("Can't get compBeast" == NULL); @@ -1513,7 +1498,7 @@ void compUpgradeOnVolume( aprintf(LRED,aStack->errString); /* If the error is zERR_ZID_NOT_FOUND then there is - * nothing we can do to fix this, so there is no + * nothing we can do to fix this, so there is no * reason to not mark the volume done. Trying again * will NOT solve the problem. */ @@ -1537,7 +1522,7 @@ void compUpgradeOnVolume( zASSERT(((CompBeast_s *)compBeast)->COMPuncompZid == beast->zid); goto unlatchCompBeast; } - + xaction = COMN_BeginXLocal(beast); if (compBeast->beastClass->classID == zFTYPE_COMPRESSION_INTERMEDIATE) @@ -1546,7 +1531,7 @@ void compUpgradeOnVolume( compBeast = NULL; goto upgradeStep2; } - + if (compBeast->beastClass->classID != zFTYPE_ROOT_BEAST) { zASSERT("CompBeast was not a valid compression beast" == NULL); @@ -1562,7 +1547,7 @@ void compUpgradeOnVolume( aprintf(LRED, aStack->errString); goto endXaction; } - + if ((compBeast->useCount != 1) || (!CIR_EMPTY(compBeast->ROOTbeastLatch.waiting))) { @@ -1574,7 +1559,7 @@ void compUpgradeOnVolume( goto endXaction; } - /* upgrade compBeast to type zFTYPE_COMPRESSION_INTERMEDIATE, + /* upgrade compBeast to type zFTYPE_COMPRESSION_INTERMEDIATE, * write it, and release it from memory if it's possible */ compBeast->beastClass = compBeastInterClass; COMN_MARK_BEAST_XLOCAL(compBeast, xaction); @@ -1588,42 +1573,42 @@ void compUpgradeOnVolume( markVolumeDone = FALSE; goto endXaction; } - + /* check if there's somebody else is waiting or using this beast. * a. If it is the case, stop here. upgrade compBeast from * zFTYPE_COMPRESSION_INTERMEDIATE to zFTYPE_COMPRESSION - * next time. + * next time. * b. If it is not the case, unlink the beast from hash, * so any hash lookup has to read it from the disk, thus * compBeast will have the correct beast size - */ + */ if ((compBeast->useCount == 1) && (CIR_EMPTY(compBeast->ROOTbeastLatch.waiting))) - { + { /* The following two lines don't block, so after we - * unlink the beast, nobody else can get it from + * unlink the beast, nobody else can get it from * memory directly */ - compBeast->bstState |= BST_STATE_TOSS_ON_RELEASE; - BST_UNLINK_FROM_ALL_LISTS(compBeast); - } + compBeast->bstState |= BST_STATE_TOSS_ON_RELEASE; + BST_UNLINK_FROM_ALL_LISTS(compBeast); + } else - { + { /* try to upgrade it later */ aprintf(CYAN, MSGNot("Compression upgrade incomplete, Zid=0x%08x:%08x is in use and cannot be upgraded.\n" "It may be possible to upgrade this file on next reboot.\n"), - (LONG)(aStack->beastZids[i] >> 32), (LONG)aStack->beastZids[i]); + (LONG)(aStack->beastZids[i] >> 32), (LONG)aStack->beastZids[i]); markVolumeDone = FALSE; compBeast->beastClass = rootBeastClass; goto endXaction; } - - /* read compBeast and upgrade it to zFTYPE_COMPRESSION */ - compBeast2 = (RootBeast_s *)CM_LookupCompBeast(&genMsg, beast, + + /* read compBeast and upgrade it to zFTYPE_COMPRESSION */ + compBeast2 = (RootBeast_s *)CM_LookupCompBeast(&genMsg, beast, compInfo, XLATCHED); - if (!compBeast2) + if (!compBeast2) { zASSERT("Can't get intermediate compBeast" == NULL); aprintf(CYAN, @@ -1634,9 +1619,9 @@ void compUpgradeOnVolume( markVolumeDone = FALSE; goto endXaction; } - + upgradeStep2: - zASSERT(compBeast2->beastClass->classID == zFTYPE_COMPRESSION_INTERMEDIATE); + zASSERT(compBeast2->beastClass->classID == zFTYPE_COMPRESSION_INTERMEDIATE); compBeast2->beastClass = compBeastClass; ((CompBeast_s *)compBeast2)->p.uncompZid = beast->zid; COMN_MARK_BEAST_XLOCAL(compBeast2, xaction); @@ -1650,7 +1635,7 @@ upgradeStep2: markVolumeDone = FALSE; goto endXaction; } - + endXaction: COMN_EndXLocal(beast, &xaction); @@ -1660,20 +1645,20 @@ endXaction: COMN_UnlatchAndRelease(&compBeast2, XLATCHED); } -unlatchCompBeast: +unlatchCompBeast: if (compBeast) { COMN_UnlatchAndRelease(&compBeast, XLATCHED); } -unlatchAndContinue: +unlatchAndContinue: COMN_UnlatchAndRelease(&beast, XLATCHED); - + PERIODIC_YIELD(); } - + } while (numBeastsReturned == MAX_ZIDS_PER_SCOOP); - + /* all beasts on this volume has been upgraded */ if (markVolumeDone) { @@ -1692,7 +1677,7 @@ unlatchAndContinue: aprintf(CYAN,MSGNot("Compression upgrade failed.\n")); } STACK_FREE(); -} +} void *CM_UpgradeThread( @@ -1705,28 +1690,28 @@ void *CM_UpgradeThread( MPKNSS_LOCK(); - + COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); CM_Upgrade.inProgress = TRUE; noVolUpgraded = TRUE; - + SET_FOREACHBLOCKING(&NSSMasterVolumeList, vol, Volume_s, masterVolLink) { COMN_USE_BEAST(&vol->VOLroot); - + if ((vol->VOLenabledAttributes & zATTR_COMPRESSION) && (vol->VOLcompAttributes.compFlags & VOL_COMP_FLAGS_UPGRADE_START) && !(vol->VOLcompAttributes.compFlags & VOL_COMP_FLAGS_UPGRADE_FINISHED) && - (vol->state == zVOLSTATE_ACTIVE) && + (vol->state == zVOLSTATE_ACTIVE) && !(vol->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP)) { noVolUpgraded = FALSE; if (COMN_LockVolumeActive(&dummyGenMsg, vol, FALSE) == zOK) - { - /* volume hasn't been fully upgrade yet */ - compUpgradeOnVolume(vol); + { + /* volume hasn't been fully upgrade yet */ + compUpgradeOnVolume(vol); COMN_UnlockVolumeActive(vol, FALSE); } } @@ -1735,15 +1720,15 @@ void *CM_UpgradeThread( SET_FOREACHBLOCKINGEND(&NSSMasterVolumeList, vol, Volume_s, masterVolLink) } - + CM_Upgrade.inProgress = FALSE; - CM_Upgrade.threadID = NULL; + CM_Upgrade.threadID = NULL; CM_Upgrade.threadStarted = FALSE; MPKNSS_UNLOCK(); return NULL; - + } - + /************************************************************************************ * This function schedules a background thread to check and upgrade compressed beast* * from RootBeast_s type to CompBeast_s type * @@ -1752,26 +1737,26 @@ void CM_StartUpgradeProcess() { ASSERT_MPKNSS_LOCK(); - if (!CM_Upgrade.threadStarted) + if (!CM_Upgrade.threadStarted) { CM_Upgrade.inProgress = FALSE; - CM_Upgrade.shuttingDown = FALSE; + CM_Upgrade.shuttingDown = FALSE; CM_Upgrade.threadStarted = TRUE; - + #ifdef __linux__ // check to see if new thread is independent of its parent - ZOS_StartThread(CM_Upgrade.threadID, "NSS Media Upgrade", + ZOS_StartThread(CM_Upgrade.threadID, "NSS Media Upgrade", CM_UpgradeThread, 0, 0, NULL); #else - ZOS_StartThreadWithModuleHandle(CM_Upgrade.threadID, "NSS Media Upgrade", + ZOS_StartThreadWithModuleHandle(CM_Upgrade.threadID, "NSS Media Upgrade", CM_UpgradeThread, 0, 0, NULL, (LONG)CMN_ModuleHandle); #endif - if (CM_Upgrade.threadID == 0) + if (CM_Upgrade.threadID == 0) { errPrintf(WHERE, Module, -1, MSG("Unable to start the background compression upgrade process.\n", 579)); CM_Upgrade.threadStarted = FALSE; - } + } } } @@ -1781,12 +1766,12 @@ void CM_StartUpgradeProcess() void CM_StopUpgradeProcess() { NINT i; - + ASSERT_MPKNSS_LOCK(); - CM_Upgrade.shuttingDown = TRUE; - - if (!CM_Upgrade.inProgress) + CM_Upgrade.shuttingDown = TRUE; + + if (!CM_Upgrade.inProgress) { if (CM_Upgrade.threadStarted) { @@ -1794,29 +1779,29 @@ void CM_StopUpgradeProcess() } } else - { + { /* thread is running, waiting for it to finish */ i = 0; while (CM_Upgrade.inProgress) { LB_delay(1000); - + if (++i >= CMUpgrade_shutdownWaitSeconds) { errPrintf(WHERE, Module, -1, MSG("Unable to shutdown the background compression upgrade process.\n", 580)); - break; + break; } } } - + return; -} +} STATUS comnCompressInit() { GeneralMsg_s dummyGenMsg; - + ASSERT_MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); @@ -1825,53 +1810,53 @@ STATUS comnCompressInit() */ if (COMN_RegisterRootVariableDataType( &dummyGenMsg, RVD_COMP_META_DATA, CM_PackedSizeRootVariableData, CM_PackRootVariableData, - CM_UnpackRootVariableData, CM_FreeRootVariableData, + CM_UnpackRootVariableData, CM_FreeRootVariableData, COMP_GetVariableDataXML, COMP_SetVariableDataXML) != zOK) { goto errorExit; - } - - if (COMN_RegisterRootVariableDataType( &dummyGenMsg, - RVD_UNCOMP_DATA, CM_CompressPackedSizeRootVariableData, - CM_CompressPackRootVariableData, CM_CompressUnpackRootVariableData, - CM_CompressFreeRootVariableData, + } + + if (COMN_RegisterRootVariableDataType( &dummyGenMsg, + RVD_UNCOMP_DATA, CM_CompressPackedSizeRootVariableData, + CM_CompressPackRootVariableData, CM_CompressUnpackRootVariableData, + CM_CompressFreeRootVariableData, UNCOMP_GetVariableDataXML, UNCOMP_SetVariableDataXML) != zOK) { goto unregisterRVD; - } - - if (COMN_RegisterBeastClassList(&dummyGenMsg, - CompClassList) != zOK) + } + + if (COMN_RegisterBeastClassList(&dummyGenMsg, + CompClassList) != zOK) { goto unregisterBeastRVD; - } - + } + return zOK; - + unregisterBeastRVD: COMN_UnRegisterRootVariableDataType(RVD_UNCOMP_DATA); unregisterRVD: COMN_UnRegisterRootVariableDataType(RVD_COMP_META_DATA); - + errorExit: - return zFAILURE; - + return zFAILURE; + } void comnCompressUninit() -{ +{ NINT i; - + ASSERT_MPKNSS_LOCK(); CM_StopUpgradeProcess(); - + for (i = 0; CompClassList[i].className != NULL; i++) { COMN_UnregisterBeastClass(CompClassList[i].classID); } - + COMN_UnRegisterRootVariableDataType(RVD_UNCOMP_DATA); COMN_UnRegisterRootVariableDataType(RVD_COMP_META_DATA); } @@ -1895,19 +1880,19 @@ STATIC void deleteBeast(RootBeast_s *beast) /* NOTE: if commitChange is FALSE, caller is responsible to commit the beast changes */ STATUS setBeastCompAttr( - RootBeast_s *uncompBeast, + RootBeast_s *uncompBeast, NINT desiredAttr, Xaction_s *xaction, BOOL commitChange) -{ +{ NamedBeast_s *nbeast; STATUS status = zOK; zASSERT(xaction != NULL); - + /* Clear compression-related file status flags */ if (COMN_IsDerivedFrom(uncompBeast, zFTYPE_NAMED_DATA_STREAM)) - { + { nbeast = (NamedBeast_s *)uncompBeast; if (desiredAttr & zFA_DATA_STREAM_IS_COMPRESSED) @@ -1921,7 +1906,7 @@ STATUS setBeastCompAttr( nbeast->NAMEDattributes &= ~zFA_CANT_COMPRESS_DATA_STREAM; } - + if (!(nbeast->NAMEDattributes & zFA_DATA_STREAM_IS_COMPRESSED)) { INC_VOLUME_COMPRESSED_FILES(nbeast->NAMEDvolume, xaction); @@ -1933,14 +1918,14 @@ STATUS setBeastCompAttr( { /* deleted file */ INC_VOLUME_COMP_DELETED_FILES(nbeast->NAMEDvolume, xaction); - + /* update the statistics */ CHANGE_COMP_STATS_COMP_DELETED_FILES(1); } } - + nbeast->NAMEDattributes |= zFA_DATA_STREAM_IS_COMPRESSED; - + } else if (desiredAttr & zFA_CANT_COMPRESS_DATA_STREAM) { @@ -1955,21 +1940,21 @@ STATUS setBeastCompAttr( { /* deleted file */ DEC_VOLUME_COMP_DELETED_FILES(nbeast->NAMEDvolume, xaction); - + /* update the statistics */ CHANGE_COMP_STATS_COMP_DELETED_FILES(-1); } nbeast->NAMEDattributes &= ~zFA_DATA_STREAM_IS_COMPRESSED; } - + if (!(nbeast->NAMEDattributes & zFA_CANT_COMPRESS_DATA_STREAM)) { INC_VOLUME_UNCOMPRESSIBLE_FILES(nbeast, xaction); /* update the statistics */ CHANGE_COMP_STATS_UNCOMPRESSIBLE_FILES(1); - } + } nbeast->NAMEDattributes |= zFA_CANT_COMPRESS_DATA_STREAM; } @@ -1988,14 +1973,14 @@ STATUS setBeastCompAttr( { /* deleted file */ DEC_VOLUME_COMP_DELETED_FILES(nbeast->NAMEDvolume, xaction); - + /* update the statistics */ CHANGE_COMP_STATS_COMP_DELETED_FILES(-1); } nbeast->NAMEDattributes &= ~zFA_DATA_STREAM_IS_COMPRESSED; } - + if (nbeast->NAMEDattributes & zFA_CANT_COMPRESS_DATA_STREAM) { DEC_VOLUME_UNCOMPRESSIBLE_FILES(nbeast, xaction); @@ -2007,7 +1992,7 @@ STATUS setBeastCompAttr( } } - if (commitChange) + if (commitChange) { GeneralMsg_s genMsg; @@ -2018,48 +2003,48 @@ STATUS setBeastCompAttr( zASSERT(status == zOK); } } - + return status; -} +} void setVolCompStats( RootBeast_s *uncompBeast, RootBeast_s *compBeast, Xaction_s *xaction, BOOL isAddStats) -{ +{ zASSERT(xaction != NULL); - /* update volume's num of compressed blocks */ + /* update volume's num of compressed blocks */ if (isAddStats) { CHANGE_VOLUME_COMPRESSED_FILE_BLOCKS( - compBeast, xaction, + compBeast, xaction, CEILING(compBeast->eof, compBeast->ROOTvolume->VOLblockSize) >> compBeast->ROOTvolume->VOLblockShift); /* update volume's num of precompressed blocks */ CHANGE_VOLUME_PRECOMPRESSED_FILE_BLOCKS( - uncompBeast, xaction, + uncompBeast, xaction, CEILING(uncompBeast->eof, uncompBeast->ROOTvolume->VOLblockSize) >> uncompBeast->ROOTvolume->VOLblockShift); } else { CHANGE_VOLUME_COMPRESSED_FILE_BLOCKS( - compBeast, xaction, + compBeast, xaction, -CEILING(compBeast->eof, compBeast->ROOTvolume->VOLblockSize) >> compBeast->ROOTvolume->VOLblockShift); /* update volume's num of precompressed blocks */ CHANGE_VOLUME_PRECOMPRESSED_FILE_BLOCKS( - uncompBeast, xaction, + uncompBeast, xaction, -CEILING(uncompBeast->eof, uncompBeast->ROOTvolume->VOLblockSize) >> uncompBeast->ROOTvolume->VOLblockShift); - } + } } - + /* * Create a compressed beast to hold the compressed data of given uncompBeast. @@ -2095,17 +2080,17 @@ STATUS compSetup( { return rc; } - + allocCompInfo = TRUE; compInfo = BEAST_CM_INFO(uncompBeast); zASSERT(compInfo); } zASSERT(BEAST_UNCOMPRESSED(compInfo) && BEAST_CLEAN(compInfo->p.status)); - if (COMN_GetStorageInfoInternal(genMsg, uncompBeast, *compBeast, + if (COMN_GetStorageInfoInternal(genMsg, uncompBeast, *compBeast, TRUE, &getStorageInfo) == zOK) { - COMN_saveBeastPurgeableBlksCnt(genMsg, (NamedBeast_s *)uncompBeast, 0, + COMN_saveBeastPurgeableBlksCnt(genMsg, (NamedBeast_s *)uncompBeast, 0, (getStorageInfo.filePhysSize >> uncompBeast->ROOTblkSizeShift)); } else @@ -2144,31 +2129,31 @@ STATUS compSetup( /* link the new beast to the original beast */ compInfo->p.compZid = newBeast->zid; - + /* set the correct owner ID */ - newBeast->ownerID = uncompBeast->ownerID; + newBeast->ownerID = uncompBeast->ownerID; if (!CM_SetCompBeastData(newBeast, uncompBeast)) { rc = zFAILURE; goto releaseNewBeast; } } - else + else { if ((*compBeast)->beastClass->classID == zFTYPE_COMPRESSION) { - zASSERT(((CompBeast_s *)*compBeast)->COMPuncompZid == uncompBeast->zid); + zASSERT(((CompBeast_s *)*compBeast)->COMPuncompZid == uncompBeast->zid); } } - + compInfo->p.status &= ~COMP_STATUS_CLEAN; - - /* Clear compression-related file status flags */ + + /* Clear compression-related file status flags */ if (COMN_IsDerivedFrom(uncompBeast, zFTYPE_NAMED_DATA_STREAM)) - { + { oldAttr = ((NamedBeast_s *)uncompBeast)->NAMEDattributes; } - + setBeastCompAttr(uncompBeast, 0, localXaction, FALSE); /* Commit the uncompBeast changes */ @@ -2178,7 +2163,7 @@ STATUS compSetup( { zASSERT("COMN_ForceBeastWrite failed" == NULL); setBeastCompAttr(uncompBeast, oldAttr, localXaction, FALSE); - + goto releaseNewBeast; } @@ -2191,11 +2176,11 @@ STATUS compSetup( if (!(compInfo->p.action & COMP_ACTION_ADD_COMPLOG)) { SETUP_BEAST_COMP_CLEANUP_PURGE_LOG(&purgeLogMsg, uncompBeast); - if ((rc = uncompBeast->ROOTcomnVolOps.VOL_addPurgeLogEntry(genMsg, + if ((rc = uncompBeast->ROOTcomnVolOps.VOL_addPurgeLogEntry(genMsg, uncompBeast->ROOTvolume, PLOG_BEAST_COMP_CLEANUP, &purgeLogMsg, localXaction)) != zOK) - { + { setBeastCompAttr(uncompBeast, oldAttr, localXaction, TRUE); - + goto releaseNewBeast; } @@ -2207,12 +2192,12 @@ STATUS compSetup( { uncompBeast->ROOTcomnVolOps.VOL_removePurgeLogEntry(&dummyGenMsg, uncompBeast->ROOTvolume, PLOG_BEAST_COMP_CLEANUP, - &purgeLogMsg, localXaction); + &purgeLogMsg, localXaction); compInfo->p.action &= ~COMP_ACTION_ADD_COMPLOG; goto releaseNewBeast; } } - + /* Commit the compBeast */ BEASTHASH_Insert(newBeast); newBeast->bstState |= BST_STATE_NEW; @@ -2240,7 +2225,7 @@ STATUS compSetup( (void) uncompBeast->ROOTcomnVolOps.VOL_removePurgeLogEntry(&dummyGenMsg, uncompBeast->ROOTvolume, PLOG_BEAST_COMP_CLEANUP, - &purgeLogMsg, localXaction); + &purgeLogMsg, localXaction); newBeast->bstState |= BST_STATE_PURGING; } else @@ -2257,8 +2242,8 @@ STATUS compSetup( *compBeast = newBeast; } - - if (! xaction) + + if (! xaction) COMN_EndXLocal(uncompBeast, &localXaction); return rc; @@ -2272,12 +2257,12 @@ releaseNewBeast: BST_free(newBeast); } -cleanupEndXaction: +cleanupEndXaction: if (allocCompInfo) { CM_FreeRootVariableData(uncompBeast); } - + { GeneralMsg_s tmpMsg; @@ -2285,12 +2270,12 @@ cleanupEndXaction: COMN_MARK_BEAST_XLOCAL(uncompBeast, localXaction); COMN_ForceBeastWrite(&tmpMsg, uncompBeast, localXaction); - - if (! xaction) + + if (! xaction) { COMN_EndXLocal(uncompBeast, &localXaction); } - } + } return rc; } @@ -2347,10 +2332,10 @@ STATUS compCleanup( { SETUP_BEAST_COMP_CLEANUP_PURGE_LOG(&purgeLogMsg, uncompBeast); rc = uncompBeast->ROOTcomnVolOps.VOL_removePurgeLogEntry(genMsg, - uncompBeast->vol.volume, PLOG_BEAST_COMP_CLEANUP, + uncompBeast->vol.volume, PLOG_BEAST_COMP_CLEANUP, &purgeLogMsg, localXaction); zASSERT(rc == zOK); - if (rc != zOK) + if (rc != zOK) { /* see comments in decompCleanup */ CompFixStats.fail1++; @@ -2376,8 +2361,8 @@ STATUS compCleanup( COMN_MARK_BEAST_XLOCAL(uncompBeast, localXaction); rc = COMN_ForceBeastWrite(genMsg, uncompBeast, localXaction); - if (rc != zOK) - { + if (rc != zOK) + { compInfo->p.status &= ~COMP_STATUS_CLEAN; compInfo->p.action = oldAction; @@ -2387,13 +2372,13 @@ STATUS compCleanup( } return rc; } - + /* Add an uncompBeast truncate purgelog entry */ SETUP_BEAST_TRUNCATE_PURGE_LOG(&purgeLogMsg, uncompBeast, 0, -1); rc = uncompBeast->ROOTcomnVolOps.VOL_addPurgeLogEntry(genMsg, uncompBeast->vol.volume, PLOG_TRUNCATE, &purgeLogMsg, localXaction); - if (rc != zOK) + if (rc != zOK) { if (!xaction || !*xaction) { @@ -2412,7 +2397,7 @@ STATUS compCleanup( COMN_MARK_BEAST_XLOCAL(uncompBeast, localXaction); rc = COMN_ForceBeastWrite(genMsg, uncompBeast, localXaction); - if (rc != zOK) + if (rc != zOK) { compInfo->p.status &= ~COMP_STATUS_CLEAN; compInfo->p.action = oldAction; @@ -2440,21 +2425,21 @@ STATUS compCleanup( { GeneralMsg_s dummyGenMsg; COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg); - + localXaction = COMN_BeginXLocal(uncompBeast); SETUP_BEAST_TRUNCATE_PURGE_LOG(&purgeLogMsg, uncompBeast, 0, -1); (void) uncompBeast->ROOTcomnVolOps.VOL_removePurgeLogEntry( &dummyGenMsg, uncompBeast->vol.volume, PLOG_TRUNCATE, &purgeLogMsg, localXaction); - updateBeastPurgeableBlksCnt(genMsg, (NamedBeast_s *)uncompBeast, + updateBeastPurgeableBlksCnt(genMsg, (NamedBeast_s *)uncompBeast, compBeast, TRUE, localXaction); COMN_EndXLocal(uncompBeast, &localXaction); } else { - updateBeastPurgeableBlksCnt(genMsg, (NamedBeast_s *)uncompBeast, + updateBeastPurgeableBlksCnt(genMsg, (NamedBeast_s *)uncompBeast, compBeast, TRUE, 0); } @@ -2477,11 +2462,11 @@ STATUS decompSetup( CompressInfo_s *compInfo; NINT oldAttr = 0; BOOL purgeLogAdded = FALSE; - + ASSERT_MPKNSS_LOCK(); zASSERT(xaction == NULL); - + compInfo = BEAST_CM_INFO(uncompBeast); zASSERT(compInfo != NULL); zASSERT(BEAST_COMPRESSED(compInfo)); @@ -2493,7 +2478,7 @@ STATUS decompSetup( if (!(compInfo->p.action & COMP_ACTION_ADD_COMPLOG)) { SETUP_BEAST_COMP_CLEANUP_PURGE_LOG(&purgeLogMsg, uncompBeast); - if ((rc = uncompBeast->ROOTcomnVolOps.VOL_addPurgeLogEntry(genMsg, + if ((rc = uncompBeast->ROOTcomnVolOps.VOL_addPurgeLogEntry(genMsg, uncompBeast->ROOTvolume, PLOG_BEAST_COMP_CLEANUP, &purgeLogMsg, localXaction)) != zOK) { @@ -2507,14 +2492,14 @@ STATUS decompSetup( compInfo->p.action |= COMP_ACTION_ADD_COMPLOG; purgeLogAdded = TRUE; } - + compInfo->p.status &= ~COMP_STATUS_CLEAN; - + if (COMN_IsDerivedFrom(uncompBeast, zFTYPE_NAMED_DATA_STREAM)) - { + { oldAttr = ((NamedBeast_s *)uncompBeast)->NAMEDattributes; } - + setBeastCompAttr(uncompBeast, 0, localXaction, FALSE); /* Commit the uncompBeast changes */ @@ -2549,18 +2534,18 @@ STATUS decompSetup( { COMN_EndXLocal(uncompBeast, &localXaction); } - + /* There's no purgeLog added here because if system crashes at this moment, - * PLOG_BEAST_COMP_CLEANUP calls CM_cleanupBeast. (UC = 0, C = 1) will call - * compCleanup, which in terms will truncate uncompBeast. - */ - /* truncate the uncompBeast + * PLOG_BEAST_COMP_CLEANUP calls CM_cleanupBeast. (UC = 0, C = 1) will call + * compCleanup, which in terms will truncate uncompBeast. + */ + /* truncate the uncompBeast * XXX Maybe this is not necessary */ cacheTruncateMyCache(&uncompBeast->ROOTmycache, 0, -1); { GeneralMsg_s tmpMsg; COMN_SETUP_GENERAL_MSG_NOSA(&tmpMsg); - (void)uncompBeast->ROOTcomnOps.BST_truncateFile(&tmpMsg, uncompBeast, + (void)uncompBeast->ROOTcomnOps.BST_truncateFile(&tmpMsg, uncompBeast, 0, -1); } return rc; @@ -2589,17 +2574,17 @@ STATUS decompCleanup( { return zOK; } - + zASSERT(BEAST_UNCOMPRESSED(compInfo)); - /* need to wait all ongoing activity to finish */ + /* need to wait all ongoing activity to finish */ zASSERT(DQ_EMPTY(&compInfo->CM_activities)); if (DQ_NOT_EMPTY(&compInfo->CM_activities)) - { + { UNX_LATCH(&compBeast->ROOTbeastLatch); CM_abortBeastActivities(uncompBeast, TRUE); X_LATCH(&compBeast->ROOTbeastLatch); - } + } /* * All uncompressed data must have been flushed to disk by now. @@ -2607,14 +2592,14 @@ STATUS decompCleanup( localXaction = xaction ? xaction : COMN_BeginXLocal(uncompBeast); - /* + /* * Update beast's contribution to volume's purgeableBlks count, if any * Do this before any error-prone actions are taken. * To prevent the count update routine from adding the compBeast's - * blocks into the count, we set this routine's includeCompBeastInfo + * blocks into the count, we set this routine's includeCompBeastInfo * parameter to FALSE */ - updateBeastPurgeableBlksCnt(genMsg, (NamedBeast_s *)uncompBeast, 0, + updateBeastPurgeableBlksCnt(genMsg, (NamedBeast_s *)uncompBeast, 0, FALSE, localXaction); if (! recovery) @@ -2629,7 +2614,7 @@ STATUS decompCleanup( { SETUP_BEAST_COMP_CLEANUP_PURGE_LOG(&purgeLogMsg, uncompBeast); rc = uncompBeast->ROOTcomnVolOps.VOL_removePurgeLogEntry(genMsg, - uncompBeast->vol.volume, PLOG_BEAST_COMP_CLEANUP, + uncompBeast->vol.volume, PLOG_BEAST_COMP_CLEANUP, &purgeLogMsg, localXaction); zASSERT( rc == zOK ); if (rc != zOK) @@ -2642,7 +2627,7 @@ STATUS decompCleanup( * a Logical Volume. * Jun 19, 2003. Greg let Ying make more comments on this. * action bit is stored as persistent data on disk. There are - * some situations can remove purge log entry (such as + * some situations can remove purge log entry (such as * rebuild which throws away all purge log entries) without * clean up this bit. */ @@ -2681,15 +2666,15 @@ STATUS decompCleanup( /* Add a compBeast delete purgeLog entry and delete compBeast */ SETUP_BEAST_DELETE_PURGE_LOG(&purgeLogMsg, compBeast, NULL); - if (compBeast->ROOTcomnVolOps.VOL_addPurgeLogEntry(genMsg, - compBeast->ROOTvolume, PLOG_BEAST_DELETE, &purgeLogMsg, + if (compBeast->ROOTcomnVolOps.VOL_addPurgeLogEntry(genMsg, + compBeast->ROOTvolume, PLOG_BEAST_DELETE, &purgeLogMsg, localXaction) == zOK) { deleteBeast(compBeast); } else ClearErrno(genMsg); -cleanupEndXaction: +cleanupEndXaction: if (! xaction) COMN_EndXLocal(uncompBeast, &localXaction); @@ -2708,27 +2693,27 @@ Buffer_s *CM_fetchFileBlk( ASSERT_MPKNSS_LOCK(); - if (! holeBlks) + if (! holeBlks) holeBlks = &tmpHoleBlks; FILEBLK_IO_MSG(iomsg, beast, blknum, 1, mode); return COMN_GetFileBlkOrHole(genMsg, &iomsg, holeBlks); } /* - * Get physical Storage info for given datastream. + * Get physical Storage info for given datastream. * The datastream beast must be atleast SLATCHED. * if compBeast != NULL, compBeast must be atleast SLATCHED * else datastream's compBeast must NOT be latched by caller. */ STATUS COMN_GetStorageInfo( GeneralMsg_s *genMsg, - void *voidBeast, + void *voidBeast, GetStorageInfo_s *getStorageInfo) { RootBeast_s *beast = (RootBeast_s *)voidBeast; CompressInfo_s *compInfo = BEAST_CM_INFO(beast); - if (compInfo && (compInfo->p.compZid != zINVALID_ZID)) + if (compInfo && (compInfo->p.compZid != zINVALID_ZID)) { STATUS rc; GetStorageInfo_s compBeastStorageInfo; @@ -2736,8 +2721,8 @@ STATUS COMN_GetStorageInfo( zASSERT(compInfo->p.compZid != zINVALID_ZID); ClearErrno( genMsg ); - compBeast = (RootBeast_s *)CM_LookupCompBeast(genMsg, beast, compInfo, - SLATCHED); + compBeast = (RootBeast_s *)CM_LookupCompBeast(genMsg, beast, compInfo, + SLATCHED); if (compBeast == 0) { /* In July 2002 we had an issue that dirs would only @@ -2760,11 +2745,11 @@ STATUS COMN_GetStorageInfo( return rc; } - rc = compBeast->ROOTcomnOps.BST_getStorageInfo(genMsg, compBeast, + rc = compBeast->ROOTcomnOps.BST_getStorageInfo(genMsg, compBeast, &compBeastStorageInfo); COMN_UnlatchAndRelease((void **)&compBeast, SLATCHED); - if (rc == zOK) + if (rc == zOK) { rc = beast->ROOTcomnOps.BST_getStorageInfo(genMsg, beast, getStorageInfo); @@ -2775,13 +2760,13 @@ STATUS COMN_GetStorageInfo( } return rc; } - else return beast->ROOTcomnOps.BST_getStorageInfo(genMsg, beast, + else return beast->ROOTcomnOps.BST_getStorageInfo(genMsg, beast, getStorageInfo); } /* * Copy of COMN_GetStorageInfo with compBeast parameter explicitly supplied. - * Get physical storage info for given datastream. + * Get physical storage info for given datastream. * The datastream beast must be atleast SLATCHED. * compBeast must be atleast SLATCHED */ @@ -2796,8 +2781,8 @@ STATIC STATUS COMN_GetStorageInfoInternal( CompressInfo_s *compInfo = BEAST_CM_INFO(beast); ASSERT_LATCH(&beast->ROOTbeastLatch); - if (compInfo && includeCompBeastInfo && - (compInfo->p.compZid != zINVALID_ZID)) + if (compInfo && includeCompBeastInfo && + (compInfo->p.compZid != zINVALID_ZID)) { STATUS rc; GetStorageInfo_s compBeastStorageInfo; @@ -2808,9 +2793,9 @@ STATIC STATUS COMN_GetStorageInfoInternal( ASSERT_LATCH(&compBeast->ROOTbeastLatch); zASSERT(compBeast->zid == compInfo->p.compZid); - rc = compBeast->ROOTcomnOps.BST_getStorageInfo(genMsg, compBeast, + rc = compBeast->ROOTcomnOps.BST_getStorageInfo(genMsg, compBeast, &compBeastStorageInfo); - if (rc == zOK) + if (rc == zOK) { rc = beast->ROOTcomnOps.BST_getStorageInfo(genMsg, beast, getStorageInfo); @@ -2821,7 +2806,7 @@ STATIC STATUS COMN_GetStorageInfoInternal( } return rc; } - else return beast->ROOTcomnOps.BST_getStorageInfo(genMsg, beast, + else return beast->ROOTcomnOps.BST_getStorageInfo(genMsg, beast, getStorageInfo); } /* @@ -2840,7 +2825,7 @@ STATIC STATUS COMN_GetStorageInfoInternal( * activity, we can update the volume's purgeableBlks count during recovery. */ void COMN_saveBeastPurgeableBlksCnt( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamedBeast_s *beast, RootBeast_s *compBeast, Blknum_t purgeableBlks) @@ -2861,7 +2846,7 @@ void COMN_saveBeastPurgeableBlksCnt( /* * If compressed beast (compBeast) exists, establish a dependency so - * that the above change to beast is committed to disk before + * that the above change to beast is committed to disk before * any compBeast changes are written to disk. */ if (compBeast) @@ -2873,12 +2858,12 @@ void COMN_saveBeastPurgeableBlksCnt( /* * Check if the deleted (purgeable) beast's physical size changed since its - * blocks were last added to the volume's purgeableBlks count. - * + * blocks were last added to the volume's purgeableBlks count. + * * If so, update the count. */ void updateBeastPurgeableBlksCnt( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamedBeast_s *beast, RootBeast_s *compBeast, BOOL includeCompBeastInfo, /* Include compBeast's blks also (if any) */ @@ -2894,17 +2879,17 @@ void updateBeastPurgeableBlksCnt( (beast->NAMEDnameFlags & NFL_ADDED_TO_SALVAGE_TREE) && (! (beast->NAMEDnameFlags & NFL_BLKS_NOT_IN_PURGEABLE_CNT))) { - if (COMN_GetStorageInfoInternal(genMsg, beast, compBeast, + if (COMN_GetStorageInfoInternal(genMsg, beast, compBeast, includeCompBeastInfo, &getStorageInfo) == zOK) { - QUAD beastBlks = + QUAD beastBlks = (getStorageInfo.filePhysSize >> beast->NAMEDblkSizeShift); if (beastBlks != compInfo->p.purgeableBlks) { VolInfoLog_s volLog; - Xaction_s *localXaction = + Xaction_s *localXaction = xaction ? xaction : COMN_BeginXLocal(beast); - + volLog.action = VOLINFO_CHANGE_PURGEABLE_BLOCKS; volLog.delta = beastBlks - compInfo->p.purgeableBlks; @@ -2934,11 +2919,11 @@ void updateBeastPurgeableBlksCnt( } /* - * Get the # bytes currently contributed by given beast to the + * Get the # bytes currently contributed by given beast to the * Volume's purgeableBlk count. */ STATUS COMN_GetPurgeableBlksCnt( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, void *voidBeast, QUAD *purgeableBlks) /* out */ { @@ -2959,7 +2944,7 @@ STATUS COMN_GetPurgeableBlksCnt( } else if ((rc = COMN_GetStorageInfo(genMsg, voidBeast, &getStorageInfo)) == zOK) { - *purgeableBlks = + *purgeableBlks = getStorageInfo.filePhysSize >> beast->NAMEDblkSizeShift; } return rc; @@ -2973,9 +2958,9 @@ void COMN_EnableIOWarning( GeneralMsg_s dummyGenMsg; unicode_t name[zMAX_COMPONENT_NAME]; } Stack_s; - + STACK_ALLOC(); - + if ((GetUTCTime() - COMP_EnableIOFailWarningTime) > COMP_EnableIOFailWarningInterval) { @@ -2987,7 +2972,7 @@ void COMN_EnableIOWarning( errPrintf(WHERE, Module, -1, MSG("Request to access file's compressed data directly failed " "due to volume\n %U's compression attribute is not on.", 581), aStack->name); - COMP_EnableIOFailWarningTime = GetUTCTime(); + COMP_EnableIOFailWarningTime = GetUTCTime(); } STACK_FREE(); } diff --git a/src/nwnss/comn/compression/copyAlgo.c b/src/nwnss/comn/compression/copyAlgo.c new file mode 100644 index 0000000..742d50d --- /dev/null +++ b/src/nwnss/comn/compression/copyAlgo.c @@ -0,0 +1,164 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996-1998 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) Command Line Support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | Module Description: + | + +-------------------------------------------------------------------------*/ +#include +#include "cmAlgoMan.h" + +STATIC STATUS +COPY_ALGOInit() +{ + return zOK; +} + +STATIC STATUS +copyStream( + CMStream_t inStream, + CMStream_t outStream) +{ + STATUS rc = zOK; + QUAD inOffset, outOffset; + LONG inSize, outSize; + CMBuffer_t inBuf, outBuf; + BYTE *inData, *outData; + LONG fileSize = ALGOMGR_getStreamSize(inStream); + LONG isHole; + + inOffset = outOffset = 0; + inSize = outSize = 0; + inData = outData = 0; + INVALIDATE_HANDLE(inBuf); + INVALIDATE_HANDLE(outBuf); + while (inOffset < fileSize) + { + if (! inData) + { + + rc = ALGOMGR_fetchStreamBuf(inStream, inOffset, &inBuf, + CM_STREAM_MODE_READ, PAGE_SIZE, &inData, &inSize, &isHole); + if (rc != zOK) + break; + } + if (! outData) + { + rc = ALGOMGR_fetchStreamBuf(outStream, outOffset, &outBuf, + CM_STREAM_MODE_UPDATE, PAGE_SIZE, &outData, &outSize, + &isHole); + if (rc != zOK) + break; + } + + if (inSize <= outSize) + { + memmove(outData, inData, inSize); + rc = ALGOMGR_releaseStreamBuf(inStream, inBuf, FALSE); + INVALIDATE_HANDLE(inBuf); + if (rc != zOK) + break; + inData = 0; + inOffset += inSize; + outOffset += inSize; + outSize -= inSize; + if (outSize == 0) + { + rc = ALGOMGR_releaseStreamBuf(outStream, outBuf, TRUE); + INVALIDATE_HANDLE(outBuf); + if (rc != zOK) + break; + outData = 0; + } + } + else + { + memmove(outData, inData, outSize); + rc = ALGOMGR_releaseStreamBuf(outStream, outBuf, TRUE); + INVALIDATE_HANDLE(outBuf); + if (rc != zOK) + break; + outData = 0; + inOffset += outSize; + outOffset += outSize; + inSize -= outSize; + } + } + if (ISVALID_HANDLE(inBuf)) + ALGOMGR_releaseStreamBuf(inStream, inBuf, FALSE); + if (ISVALID_HANDLE(outBuf)) + ALGOMGR_releaseStreamBuf(outStream, outBuf, TRUE); + if (rc == zOK) + { + ALGOMGR_setStreamSize(outStream, fileSize); + } + return rc; +} + +STATIC STATUS +COPY_ALGOCompressStream( + BYTE algoVersion, + CMStream_t uncompStream, /* read-only */ + CMStream_t compStream, /* write */ + CMStream_t tempStream, /* write/read + * For NW algorithm use */ + BYTE minPercentGain) +{ + return copyStream(uncompStream, compStream); +} + +STATIC STATUS +COPY_ALGOUncompressStream( + BYTE algoVersion, + CMStream_t compStream, + CMStream_t uncompStream) +{ + return copyStream(compStream, uncompStream); +} + +STATIC void +COPY_ALGOUninit() +{ +} + +STATIC CompAlgoIF_s COPY_ALGOOps = { + COPY_ALGOInit, + COPY_ALGOCompressStream, + COPY_ALGOUncompressStream, + COPY_ALGOUninit, +}; + +STATUS +COPY_ALGOStartup() +{ + return ALGOMGR_registerCompAlgo(NSS_COMP_ALGO_ID_COPY, ©_ALGOOps); +} diff --git a/src/nwnss/comn/compression/nwAlgo.c b/src/nwnss/comn/compression/nwAlgo.c index 55210b5..aa72be3 100644 --- a/src/nwnss/comn/compression/nwAlgo.c +++ b/src/nwnss/comn/compression/nwAlgo.c @@ -36,7 +36,7 @@ +-------------------------------------------------------------------------*/ #include "nwAlgo.h" -LONG +LONG NSSCCDSetFileSize( IoHandle_t internalHandle, LONG fileSize, @@ -45,7 +45,7 @@ NSSCCDSetFileSize( return ALGOMGR_setStreamSize(CM_STREAM(internalHandle), internalFileSize); } -LONG +LONG NSSCCDDecompressBuildFile( IoHandle_t outHandle, LONG offset, LONG size, LONG prevSize, LONG nextSize ) { @@ -58,17 +58,17 @@ NSSCCDDecompressBuildFile( IoHandle_t outHandle, LONG offset, LONG size, return (LONG)0; } -LONG +LONG NSSCCDGetWriteCacheBlock( IoHandle_t ioHandle, LONG cacheBlockNumber, - LONG noFlushFlag, BYTE **cacheBlock, LONG *cacheHandle ) + LONG noFlushFlag, BYTE **cacheBlock, LONG *cacheHandle ) { STATUS rc; LONG holeFlag; LONG size; - NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "---------- getwrite: fseek(offset=%ld) handle=%d\n", + NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "---------- getwrite: fseek(offset=%ld) handle=%d\n", cacheBlockNumber * CD_SYSTEM_CACHE_BUFFER_SIZE, ioHandle->nextfreeIobuf+1)); - ioHandle->iobuf[ioHandle->nextfreeIobuf].offset = + ioHandle->iobuf[ioHandle->nextfreeIobuf].offset = cacheBlockNumber * CD_SYSTEM_CACHE_BUFFER_SIZE; CD_ASSERT((! ISVALID_HANDLE(ioHandle->iobuf[ioHandle->nextfreeIobuf].cmbuf))); rc = ALGOMGR_fetchStreamBuf(CM_STREAM(ioHandle), @@ -84,9 +84,9 @@ NSSCCDGetWriteCacheBlock( IoHandle_t ioHandle, LONG cacheBlockNumber, return rc; } -LONG +LONG NSSCCDReturnWriteCacheBlock( LONG cacheHandle, IoHandle_t ioHandle, - LONG numberOfSectors, LONG noFlushFlag ) + LONG numberOfSectors, LONG noFlushFlag ) { STATUS rc; LONG offset; @@ -99,7 +99,7 @@ NSSCCDReturnWriteCacheBlock( LONG cacheHandle, IoHandle_t ioHandle, NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "---------- returnwrite: fseek(offset=%ld) handle=%d\n", offset, cacheHandle+1)); if (offset != ALGOMGR_getStreamPosition(CM_STREAM(ioHandle))) { #if 0 - NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "---------- write_off %ld != %ld\n", offset, + NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "---------- write_off %ld != %ld\n", offset, ALGOMGR_getStreamPosition(CM_STREAM(ioHandle)))); #endif ALGOMGR_setStreamPosition(CM_STREAM(ioHandle), (QUAD)offset); @@ -107,37 +107,37 @@ NSSCCDReturnWriteCacheBlock( LONG cacheHandle, IoHandle_t ioHandle, CD_ASSERT((ISVALID_HANDLE(ioHandle->iobuf[cacheHandle].cmbuf))); rc = ALGOMGR_releaseStreamBuf(CM_STREAM(ioHandle), ioHandle->iobuf[cacheHandle].cmbuf, TRUE); - NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "---------- wrote (secsize=%d, nsectors=%ld, offset=%ld)\n", + NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "---------- wrote (secsize=%d, nsectors=%ld, offset=%ld)\n", CD_SYSTEM_SECTOR_SIZE, numberOfSectors, offset)); - + INVALIDATE_HANDLE(ioHandle->iobuf[cacheHandle].cmbuf); return rc; } -LONG +LONG NSSCCDGetReadCacheBlock( IoHandle_t ioHandle, LONG cacheBlockNumber, - LONG *realBytesRead, BYTE **cacheBlock, LONG *cacheHandle, - LONG *holeFlag ) + LONG *realBytesRead, BYTE **cacheBlock, LONG *cacheHandle, + LONG *holeFlag ) { STATUS rc; CMStream_t stream = CM_STREAM(ioHandle); - ioHandle->iobuf[ioHandle->nextfreeIobuf].offset = + ioHandle->iobuf[ioHandle->nextfreeIobuf].offset = cacheBlockNumber * CD_SYSTEM_CACHE_BUFFER_SIZE; - NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "getread: offset=%d handle=%d\n", + NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "getread: offset=%d handle=%d\n", ioHandle->iobuf[ioHandle->nextfreeIobuf].offset, ioHandle->nextfreeIobuf+1)); - *holeFlag = 0; + *holeFlag = 0; if (ioHandle->iobuf[ioHandle->nextfreeIobuf].offset != ALGOMGR_getStreamPosition(stream)) { - rc = ALGOMGR_setStreamPosition(stream, + rc = ALGOMGR_setStreamPosition(stream, (QUAD)ioHandle->iobuf[ioHandle->nextfreeIobuf].offset); if (rc != 0) { - NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "fseek(offset=%ld)", + NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "fseek(offset=%ld)", ioHandle->iobuf[ioHandle->nextfreeIobuf].offset)); return rc; } } - *realBytesRead = CD_SYSTEM_CACHE_BUFFER_SIZE; + *realBytesRead = CD_SYSTEM_CACHE_BUFFER_SIZE; rc = ALGOMGR_fetchStreamBuf(stream, ioHandle->iobuf[ioHandle->nextfreeIobuf].offset, &ioHandle->iobuf[ioHandle->nextfreeIobuf].cmbuf, CM_STREAM_MODE_READ, @@ -152,14 +152,14 @@ NSSCCDGetReadCacheBlock( IoHandle_t ioHandle, LONG cacheBlockNumber, return rc; } -void +void NSSCCDReturnReadCacheBlock(IoHandle_t ioHandle, LONG cacheHandle) { if ((cacheHandle == 0) || (cacheHandle > READ_CACHE_BUFFER_RANGE)) return; -- cacheHandle; - NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "return_read: offset=%d, handle=%d\n", + NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "return_read: offset=%d, handle=%d\n", ioHandle->iobuf[cacheHandle].offset, cacheHandle+1)); (void) ALGOMGR_releaseStreamBuf(CM_STREAM(ioHandle), ioHandle->iobuf[cacheHandle].cmbuf, FALSE); @@ -191,11 +191,11 @@ LONG NSSCCDGetReadAheadBuffer(readCache_tp ra, BYTE **cachePointer, ra->CacheNextBlockToRead++; if (*holeFlag) { - NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, " ~~~ holeFlag is on\n")); + NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, " ~~~ holeFlag is on\n")); } else { - ra->CacheNextToBeUsed ++; + ra->CacheNextToBeUsed ++; ra->CacheNextToBeUsed &= CD_READ_CACHE_MASK; } return (LONG)0; @@ -204,9 +204,9 @@ LONG NSSCCDGetReadAheadBuffer(readCache_tp ra, BYTE **cachePointer, LONG NSSCCDFreeReadAheadBuffer(readCache_tp ra) { - NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "free_read_ahead used=%d, freed=%d:\n", + NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "free_read_ahead used=%d, freed=%d:\n", ra->CacheNextToBeUsed, ra->CacheNextToBeFreed)); - NSSCCDReturnReadCacheBlock(ra->CacheReadFileHandle, + NSSCCDReturnReadCacheBlock(ra->CacheReadFileHandle, ra->CacheHandles[ra->CacheNextToBeFreed]); ra->CacheHandles[ra->CacheNextToBeFreed] = 0; /* Some invalid value */ @@ -215,14 +215,14 @@ LONG NSSCCDFreeReadAheadBuffer(readCache_tp ra) return (LONG)0; } -LONG +LONG NSSCCDPrepareForRead( IoHandle_t ioHandle, LONG fileSize, readCache_tpp readCacheHandleReturn) { readCache_tp ra; if ((ra = (readCache_tp)CD_MALLOC(sizeof(readCache_t))) == NULL) - return( zERR_NO_MEMORY ); + return( zERR_NO_MEMORY ); memset(ra, (LONG)0, sizeof(readCache_t)); @@ -238,18 +238,18 @@ NSSCCDPrepareForRead( IoHandle_t ioHandle, LONG fileSize, LONG NSSCCDStopReadAhead(readCache_tp ra) { NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "Stopping read\n")); - + while (ra->CacheNextToBeFreed != ra->CacheNextToBeUsed) { - if (ra->CacheHandles[ra->CacheNextToBeFreed] == 0) + if (ra->CacheHandles[ra->CacheNextToBeFreed] == 0) { - NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "freeing NULL buffer, used=%d, freed=%d:\n", + NWALGO_DBG_PRINTF((NWALGO_DBG_COLOR, "freeing NULL buffer, used=%d, freed=%d:\n", ra->CacheNextToBeUsed, ra->CacheNextToBeFreed)); ++ ra->CacheNextToBeFreed; ra->CacheNextToBeFreed &= CD_READ_CACHE_MASK; CD_ASSERT((0)); } - else { + else { NSSCCDFreeReadAheadBuffer(ra); } } @@ -264,14 +264,14 @@ NWALGO_init() return zOK; } -STATIC STATUS +STATIC STATUS NWALGO_compressStream( - BYTE algoVersion, + BYTE algoVersion, CMStream_t uncompStream, /* read-only */ CMStream_t compStream, /* write */ CMStream_t tempStream, /* write/read * For NW algorithm use */ - BYTE minPercentGain) + BYTE minPercentGain) { LONG ccode; QUAD fileSize = ALGOMGR_getStreamSize(uncompStream); @@ -299,7 +299,7 @@ NWALGO_compressStream( tempHandle.CM_stream = tempStream; tempHandle.nextfreeIobuf = 0; - ccode = CCDCompressFile(&uncompHandle, &compHandle, &tempHandle, + ccode = CCDCompressFile(&uncompHandle, &compHandle, &tempHandle, fileSize, 0, &compressHandle, "", &compressStatus); switch (ccode) { case 0: @@ -338,10 +338,10 @@ NWALGO_compressStream( } } -STATIC STATUS +STATIC STATUS NWALGO_uncompressStream( - BYTE algoVersion, - CMStream_t compStream, + BYTE algoVersion, + CMStream_t compStream, CMStream_t uncompStream) { LONG ccode; @@ -356,7 +356,7 @@ NWALGO_uncompressStream( uncompHandle.CM_stream = uncompStream; uncompHandle.nextfreeIobuf = 0; - ccode = CCDStartDecompress(&compHandle, &uncompHandle, &compressHandle, + ccode = CCDStartDecompress(&compHandle, &uncompHandle, &compressHandle, "", 0, 0); switch (ccode) { case 0: diff --git a/include/nwnss/include/nwAlgo.h b/src/nwnss/comn/compression/nwAlgo.h similarity index 98% rename from include/nwnss/include/nwAlgo.h rename to src/nwnss/comn/compression/nwAlgo.h index f46d1ae..973af30 100644 --- a/include/nwnss/include/nwAlgo.h +++ b/src/nwnss/comn/compression/nwAlgo.h @@ -37,7 +37,7 @@ #ifndef _NWALGO_H_ #define _NWALGO_H_ -#include +#include #include #include #include diff --git a/include/nwnss/include/cro.h b/src/nwnss/comn/cro.h similarity index 99% rename from include/nwnss/include/cro.h rename to src/nwnss/comn/cro.h index 0909f3f..749379e 100644 --- a/include/nwnss/include/cro.h +++ b/src/nwnss/comn/cro.h @@ -116,3 +116,4 @@ STATUS CRO_CloseListSend( CRO_CloseList_s *closeList, RootBeast_s *rootBeast ); #endif #endif /* #ifdef _CRO_H_ */ + diff --git a/include/nwnss/include/csa.h b/src/nwnss/comn/csa.h similarity index 95% rename from include/nwnss/include/csa.h rename to src/nwnss/comn/csa.h index 3677d71..67ee8bf 100644 --- a/include/nwnss/include/csa.h +++ b/src/nwnss/comn/csa.h @@ -39,23 +39,23 @@ #define _CSA_H_ #ifndef _OMNI_H_ -#include +#include #endif #ifndef _XUNICODE_H_ -#include +#include #endif #ifndef _VOLUME_H_ -#include +#include #endif #ifndef _SWITCHBOARD_H_ -#include +#include #endif #ifndef _XMSG_H_ -#include +#include #endif @@ -108,7 +108,7 @@ typedef struct CsaVolumeType_s mTypeHeader_s hdr; statusfunc_t method[CSA_VOL_NUM_METHODS]; } CsaVolumeType_s; - + typedef struct CsamManager_s { mManager_s *mgr; @@ -166,7 +166,7 @@ typedef struct SearchMapCleanupIDList_s extern ObjCache_s CSASearchMapCleanupList; -extern void CSA_SearchMapCleanupAll( +extern void CSA_SearchMapCleanupAll( CsaVolumeDoor_s *volObject); extern STATUS CSA_CloseNotInUseFileHandles( @@ -186,7 +186,7 @@ extern void CSA_SendVolumeStats( FsmLite_s *fsm, Volume_s *volume); -extern void CSA_CloseFileHandlesForASlave( +extern void CSA_CloseFileHandlesForASlave( CsaVolumeDoor_s *volObject); #ifdef __cplusplus @@ -194,3 +194,4 @@ extern void CSA_CloseFileHandlesForASlave( #endif #endif + diff --git a/src/nwnss/comn/main/comnCmdline.c b/src/nwnss/comn/main/comnCmdline.c index 4c7a2a5..1207285 100644 --- a/src/nwnss/comn/main/comnCmdline.c +++ b/src/nwnss/comn/main/comnCmdline.c @@ -48,9 +48,6 @@ #include /* NSS Library Includes*/ #include -#if defined(NSS_USERSPACE) -#include "NssPageRuntime.h" -#endif #include #include #include @@ -77,7 +74,7 @@ #include "mgmt.h" #include "nssOSAPIs.h" #include "msgName.h" -#include "dirQuotas.h" +#include "dirQuotas.h" #include "cmNSS.h" #include "comnIO.h" #include "nssPubs.h" @@ -118,7 +115,7 @@ NINT COMN_IncludeType = COMN_IT_DEFAULT; NINT COMN_OverrideType = COMN_OT_DEFAULT; - /* BitMask of overrides that a user can + /* BitMask of overrides that a user can * specify that modifies how a command works. * Legal bits COMN_OT_SHARED, COMN_OT_CORRUPT * and COMN_OT_QUESTIONS. This @@ -196,7 +193,7 @@ STATUS doChangeCacheBuffers ( struct sysinfo si; MPKNSS_LOCK(); - + newSize = *(NINT *)switchDef->ret_value; if (newSize < MIN_NUM_BUFFERS) { @@ -261,7 +258,7 @@ STATUS doCacheBalance ( * Echo a line for NSSCON **************************************************************************/ STATUS doEchoString( - PCLSwitchDef_s *switchDef, + PCLSwitchDef_s *switchDef, NINT options, void *userParm) { @@ -289,7 +286,7 @@ STATUS doResetInst ( } /************************************************************************** - * + * ***************************************************************************/ STATUS doStatusDisplay( PCLSwitchDef_s *switchDef, @@ -364,7 +361,7 @@ NINT COMN_ChangeStateCommandLineSwitches() void getEncryptedVolumePassword(unicode_t *password) { struct ScreenStruct *screenID; - NINT bufsize = ENCRYPTED_VOLUME_PASSWORD_LENGTH +1; + NINT bufsize = ENCRYPTED_VOLUME_PASSWORD_LENGTH +1; BYTE buffer[ENCRYPTED_VOLUME_PASSWORD_LENGTH +1]; NINT retval; NINT charCount = 0; @@ -491,7 +488,7 @@ STATUS doChangeVolumeState( MPKNSS_UNLOCK(); return zOK; -} +} #if 1 @@ -510,7 +507,7 @@ STATUS doChangeVolumeStateForceDeact( switchDef->userInfo,VOLMODE_VERBOSE); MPKNSS_UNLOCK(); return zOK; -} +} #endif @@ -546,8 +543,8 @@ STATUS doChangeVolumeHardlinks( switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} - +} + /************************************************************************** * Switch among the various states @@ -565,7 +562,7 @@ STATUS doChangeVolumeExtendedMac( switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} +} /* fixfixfix@nextMediaFormatChange end */ @@ -584,7 +581,7 @@ STATUS doChangeVolumeTransaction( switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} +} /************************************************************************** * Switch among the various states @@ -601,7 +598,7 @@ STATUS doChangeVolumeMigration( switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} +} /************************************************************************** @@ -613,14 +610,14 @@ STATIC STATUS doChangeVolumeCompression( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); VOL_ChangeVolumeCompressionByName(&genMsg,(unicode_t *)switchDef->ret_value, switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} +} STATIC STATUS doChangeVolumeATime( PCLSwitchDef_s *switchDef, @@ -628,14 +625,14 @@ STATIC STATUS doChangeVolumeATime( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); VOL_ChangeVolumeATimeByName(&genMsg,(unicode_t *)switchDef->ret_value, switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} +} STATIC STATUS doToggleBGCompression( PCLSwitchDef_s *switchDef, NINT options, @@ -750,7 +747,7 @@ STATIC STATUS doEnableFileCompression( MPKNSS_LOCK(); SET_COMP_ENABLED_FLAG(EnableFileCompression); - + MPKNSS_UNLOCK(); return zOK; } @@ -768,7 +765,7 @@ STATIC STATUS doEndOfDaylightSavingsTime( getDSTChangeRules(EDSTInfo, &DSTStopInfo); if(DSTStopInfo.isOK) { - checkOrSetDSTConversionResults(-1,-1,-1); + checkOrSetDSTConversionResults(-1,-1,-1); BEASTHASH_InvalidateDOSTimes(); CM_bgCompressResetTimer(); strcpy(EDSTSaved, EDSTInfo); @@ -818,7 +815,7 @@ STATIC STATUS doImmediatePurgeOfDeletedFiles( { MPKNSS_LOCK(); - + if (ImmediatePurgeOfDeletedFiles) { if (!NW_PurgeImmediateFlag) @@ -860,7 +857,7 @@ STATIC STATUS doMinimumCompressionPercentageGain( { MPKNSS_LOCK(); - SET_MIN_PERCENT_GAIN(MinimumCompressionPercentageGain); + SET_MIN_PERCENT_GAIN(MinimumCompressionPercentageGain); MPKNSS_UNLOCK(); return zOK; @@ -886,7 +883,7 @@ STATIC STATUS doMinimumFileDeleteWaitTime( return zOK; } #endif - + STATIC STATUS doCompressionScreen( PCLSwitchDef_s *switchDef, NINT options, @@ -918,7 +915,7 @@ STATUS doChangeVolumeStateForce( switchDef->userInfo,VOLMODE_VERBOSE|VOLMODE_USER_ABORTABLE|VOLMODE_OVERRIDE); MPKNSS_UNLOCK(); return zOK; -} +} /************************************************************************** * Change the state of user space restrictions on a volume @@ -929,14 +926,14 @@ STATUS doChangeVolumeUserSpaceRestrictions( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); VOL_ChangeVolumeUserSpaceRestrictionsByName( &genMsg, (unicode_t *)switchDef->ret_value, switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} +} /************************************************************************** * Change the state of directory quotas on a volume @@ -947,14 +944,14 @@ STATUS doChangeVolumeDirectoryQuotas( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); DIRQ_ChangeVolumeDirectoryQuotasByName( &genMsg, (unicode_t *)switchDef->ret_value, switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} +} /************************************************************************** * Fix the used amount of directory quotas on a volume @@ -965,13 +962,13 @@ STATUS doFixVolumeDirectoryQuotas( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); DIRQ_FixDirectoryQuotas(&genMsg, (unicode_t *)switchDef->ret_value); MPKNSS_UNLOCK(); return zOK; -} +} /************************************************************************** * Rebuild the visibility lists on a volume @@ -982,13 +979,13 @@ STATUS doVisibilityRebuild( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); ZAS_VisibilityRebuildByName(&genMsg, (unicode_t *)switchDef->ret_value); MPKNSS_UNLOCK(); return zOK; -} +} /************************************************************************** * Change the state of MFL maintenance on a volume @@ -999,14 +996,14 @@ STATUS doChangeVolumeMFL( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); VOL_ChangeVolumeMFLByName( &genMsg, (unicode_t *)switchDef->ret_value, switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} +} /************************************************************************** * Change the state of data shredding on a volume @@ -1017,14 +1014,14 @@ STATUS doChangeVolumeDataShredding( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); VOL_ChangeVolumeDataShredByName( &genMsg, (unicode_t *)switchDef->ret_value, switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} +} /************************************************************************** * Change the state of HIGH INTEGRITY on a volume @@ -1035,14 +1032,14 @@ STATUS doChangeVolumeHighIntegrity( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); VOL_ChangeVolumeHighIntegrityByName( &genMsg, (unicode_t *)switchDef->ret_value, switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} +} /************************************************************************** * Change the state of CFS MASTER on a volume @@ -1053,14 +1050,14 @@ STATUS doChangeVolumeCFSMaster( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); VOL_ChangeVolumeCFSMasterByName( &genMsg, (unicode_t *)switchDef->ret_value, switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} +} /************************************************************************** * Change the state of COW on a volume @@ -1071,14 +1068,14 @@ STATUS doChangeVolumeCOW( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); VOL_ChangeVolumeCOWByName( &genMsg, (unicode_t *)switchDef->ret_value, switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} +} #if zLINUX @@ -1096,7 +1093,7 @@ STATUS doMSAPServerIdSet( { STATUS status; GUID_t userGuid; - + MPKNSS_LOCK(); status = LB_GUIDFromUTF8( (utf8_t *)switchDef->ret_value, &userGuid ); if ( status != zOK ) @@ -1145,7 +1142,7 @@ STATUS doChangePoolMSAP( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); POOL_ChangePoolMSAPByName( @@ -1164,7 +1161,7 @@ STATUS doChangePoolWaterMarks( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); POOL_ChangePoolWaterMarksByName( @@ -1182,14 +1179,14 @@ STATUS doChangePoolWaterMarks( // void *userParm) //{ // GeneralMsg_s genMsg; -// +// // MPKNSS_LOCK(); // COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); // VOL_ChangePoolSharedByName( // &genMsg, (unicode_t *)switchDef->ret_value, switchDef->userInfo); // MPKNSS_UNLOCK(); // return zOK; -//} +//} /************************************************************************** * Change the state of user space restrictions on a volume @@ -1200,14 +1197,14 @@ STATUS doUpgradeBeastsOnVolume( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); - VOL_UpgradeBeastsOnVolumeByName(&genMsg, + VOL_UpgradeBeastsOnVolumeByName(&genMsg, (unicode_t *)switchDef->ret_value); MPKNSS_UNLOCK(); return zOK; -} +} /************************************************************************** * Perform specified administrative operation on the MFL @@ -1218,20 +1215,20 @@ STATUS doAdministerMFL( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); VOL_administerMFLByName( &genMsg, (unicode_t *)switchDef->ret_value, switchDef->userInfo); MPKNSS_UNLOCK(); return zOK; -} +} void getBucketStats( - NINT *maxInBucket, - NINT *totalEntries, + NINT *maxInBucket, + NINT *totalEntries, NINT *numUsedBuckets, - DQhead_t *bucketHead, + DQhead_t *bucketHead, NINT size) { DQhead_t *bucket; @@ -1252,7 +1249,7 @@ void getBucketStats( for (next = bucket->next; next != bucket; next = next->next) { ++(*totalEntries); - ++numInBucket; + ++numInBucket; } if (numInBucket != 0) { @@ -1276,14 +1273,14 @@ STATUS doChangeVolumeReadAhead( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); VOL_ChangeVolumeReadAheadByName( &genMsg, (unicode_t *)switchDef->ret_value); MPKNSS_UNLOCK(); return zOK; -} +} /************************************************************************** * display name cache statistics ***************************************************************************/ @@ -1343,18 +1340,18 @@ STATUS doDisplayNameCacheStats( #if NSS_DEBUG IS_ENABLED aprintf(YELLOW, MSGNot("********** NAME CACHE OPTIMIZER **********\n")); - aprintf(LGREEN, MSGNot("Optimizer runs: %d, Resizes: %d ~ %d%%\n"), - NameCacheOptimizerStats.optimizeCount, - NameCacheOptimizerStats.resizeCount, + aprintf(LGREEN, MSGNot("Optimizer runs: %d, Resizes: %d ~ %d%%\n"), + NameCacheOptimizerStats.optimizeCount, + NameCacheOptimizerStats.resizeCount, NameCacheOptimizerStats.optimizeCount > 0 ? (NameCacheOptimizerStats.resizeCount * 100) / NameCacheOptimizerStats.optimizeCount : 0); - aprintf(LGREEN, MSGNot("Max ~ Min cache size: %d ~ %d, Max ~ Min delta: %d ~ %d\n"), - NameCacheOptimizerStats.maxSize, - NameCacheOptimizerStats.minSize, - NameCacheOptimizerStats.maxChange, + aprintf(LGREEN, MSGNot("Max ~ Min cache size: %d ~ %d, Max ~ Min delta: %d ~ %d\n"), + NameCacheOptimizerStats.maxSize, + NameCacheOptimizerStats.minSize, + NameCacheOptimizerStats.maxChange, NameCacheOptimizerStats.minChange); - aprintf(LGREEN, MSGNot("Max ~ Min Invalidate change: %d ~ %d, Max %%: %d\n"), - NameCacheOptimizerStats.maxInvalidateChange, - NameCacheOptimizerStats.minInvalidateChange, + aprintf(LGREEN, MSGNot("Max ~ Min Invalidate change: %d ~ %d, Max %%: %d\n"), + NameCacheOptimizerStats.maxInvalidateChange, + NameCacheOptimizerStats.minInvalidateChange, NameCacheOptimizerStats.maxPctInvalidateChange); aprintf(LGREEN, MSGNot("Max req'd node destroys: %d\n"), NameCacheOptimizerStats.maxReqdNodeDestroys); aprintf(LGREEN, MSGNot("Last Invalidate size: %d\n"), NameCache. lastInvalidateSize); @@ -1372,7 +1369,7 @@ STATUS doDisplayNameCacheStats( //rks * Dump the count in each bucket to the debug buffer //rks ***************************************************************************/ //rksvoid displayBucketCounts( -//rks DQhead_t *bucketHead, +//rks DQhead_t *bucketHead, //rks NINT size) //rks{ //rks DQhead_t *bucket; @@ -1389,7 +1386,7 @@ STATUS doDisplayNameCacheStats( //rks numInBucket = 0; //rks for (next = bucket->next; next != bucket; next = next->next) //rks { -//rks ++numInBucket; +//rks ++numInBucket; //rks } //rks DBG_DebugPrintf(LMAGENTA, "bucket #%d=%d\n", i, numInBucket); //rks } @@ -1459,7 +1456,7 @@ STATUS doDisplayBeastCacheStats( if (Config.bst.hashSize != 0) { - aprintf(LGREEN, MSG("Percent of buckets used: %d%%\n", 570), + aprintf(LGREEN, MSG("Percent of buckets used: %d%%\n", 570), (numUsedBuckets*100) / Config.bst.hashSize); } else @@ -1471,7 +1468,7 @@ STATUS doDisplayBeastCacheStats( #if NSS_DEBUG IS_ENABLED //rks displayBucketCounts(RootBeastHash, Config.bst.hashSize); #endif - + MPKNSS_UNLOCK(); return zOK; } @@ -1582,7 +1579,7 @@ STATUS doDisplayCacheStats( lSystem.miss = Inst.cache.ioMissLinuxSystemTotal; lUser.hit = lAll.hit - lSystem.hit; lUser.miss = lAll.miss - lSystem.miss; - + nAll.hit = Inst.cache.ioHitUserSystemTotal; nAll.miss = Inst.cache.ioMissUserSystemTotal; nSystem.hit = Inst.cache.ioHitSystemTotal; @@ -1591,7 +1588,7 @@ STATUS doDisplayCacheStats( nUser.miss = nAll.miss - nSystem.miss; /* We must add up the old cache stats with the new Linux ones to get a true total. Vandana wants these because her calculator is - broken:-) + broken:-) Since a miss in the NSS cache always causes a lookup in the Linux cache we only have to count the Linux miss in our totals:-) */ @@ -1600,7 +1597,7 @@ STATUS doDisplayCacheStats( ctSystem.hit = nSystem.hit + lSystem.hit; ctSystem.miss = /* nSystem.miss */ + lSystem.miss; ctUser.hit = nUser.hit + lUser.hit; - ctUser.miss = /* nUser.miss + */ lUser.miss; + ctUser.miss = /* nUser.miss + */ lUser.miss; aprintf(YELLOW, MSG("***** Buffer Cache Statistics *****\n", 920)); aprintf(LGREEN, MSG("Min cache buffers: %d\n", 550), Config.cache.numBuffers); @@ -1758,7 +1755,7 @@ STATUS comn_SetupNameMsgFromZID( /************************************************************************** - * + * ***************************************************************************/ STATUS COMN_ReverseNameLookup( @@ -1910,7 +1907,7 @@ STATUS doZIDToFileName( switch ( GetErrno( &genMsg ) ) { case zERR_INVALID_PATH: - aprintf(YELLOW,MSG("Note - ZID is for a deleted file(%s).\n",143), + aprintf(YELLOW,MSG("Note - ZID is for a deleted file(%s).\n",143), GetErrnoSetter(&genMsg) ); status = COMN_ReverseNameLookup( &genMsg, ZIDToFileNameVolumeName, zid, @@ -2313,7 +2310,7 @@ NINT doIDCacheResetInterval( void *userParm) { MPKNSS_LOCK(); - aprintf(WHITE, MSGNot("ID cache reset interval changed to %d\n"), + aprintf(WHITE, MSGNot("ID cache reset interval changed to %d\n"), G2I_CacheInvalidateTime); GUID_IDCacheResetInterval(G2I_CacheInvalidateTime); MPKNSS_UNLOCK(); @@ -2326,7 +2323,7 @@ NINT doResetObjectIDStore( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); OID_InitObjectIDStoreByName(&genMsg, (unicode_t *)switchDef->ret_value, @@ -2341,7 +2338,7 @@ NINT doUpdateObjectIDStore( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); OID_InitObjectIDStoreByName(&genMsg, (unicode_t *)switchDef->ret_value, @@ -2356,7 +2353,7 @@ NINT doCSAClean( NINT options, void *userParm) { - + MPKNSS_LOCK(); CSA_Clean_UI(); MPKNSS_UNLOCK(); @@ -2369,7 +2366,7 @@ NINT doCSAStatsDisplay( NINT options, void *userParm) { - + MPKNSS_LOCK(); CSA_StatsDisplay_UI(); MPKNSS_UNLOCK(); @@ -2383,7 +2380,7 @@ NINT doRemoveObjectIDStore( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); OID_InitObjectIDStoreByName(&genMsg, (unicode_t *)switchDef->ret_value, @@ -2400,7 +2397,7 @@ NINT doStartBackgroundChecker( Config.Storage.forceChecker = TRUE; CHK_Wakeup(); return zOK; -} +} #if zLINUX NINT doStartSecurityEquivUpdater( @@ -2411,7 +2408,7 @@ NINT doStartSecurityEquivUpdater( Config.SecEquiv.forceUpdater = TRUE; SEQ_Wakeup(); return zOK; -} +} NINT doUpdateSecurityEquivInterval( struct PCLSwitchDef_s *switchDef, @@ -2421,7 +2418,7 @@ NINT doUpdateSecurityEquivInterval( Config.SecEquiv.intervalChanged = TRUE; SEQ_Wakeup(); return zOK; -} +} #endif @@ -2504,7 +2501,7 @@ STATUS doResetEFLTree( void *userParm) { GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); resetVolumeEFLTree(&genMsg, (unicode_t *)switchDef->ret_value); @@ -2557,7 +2554,7 @@ STATUS doListHardLinks( if(beast != NULL) { - status = COMN_GetFileNameFromZid(&genMsg, aStack->nameMsg.curvol, zid, + status = COMN_GetFileNameFromZid(&genMsg, aStack->nameMsg.curvol, zid, zNSPACE_LONG, aStack->name, FALSE); if(status == zOK) @@ -2629,7 +2626,7 @@ STATUS doListHardLinks( // return zFAILURE; // } // -// +// // if((linkFile = unichr((unicode_t *)switchDef->ret_value, '|')) == NULL) // { // rc = zFAILURE; @@ -2714,7 +2711,7 @@ PCLSwitchDef_s CMN_CommandLineSwitches[] = NULL, (PCLFunction_t)doRebuildPurgePoolVolumesPost }, - /*** + /*** *** End of Modifier type commands ***/ @@ -3078,14 +3075,14 @@ PCLSwitchDef_s CMN_CommandLineSwitches[] = }, #if NSS_DEBUG IS_ENABLED - {MSGNot("NameCacheDump"), - NULL, - SWHELP_CAT_MAINT|SWTYPE_NAME|SWOPT_RUNTIME_ONLY|SWOPT_HIDDEN, - 0, 0, - (PCLFunction_t)doDumpNameCache, NULL, - {{0, 0}}, 0, 0, + {MSGNot("NameCacheDump"), + NULL, + SWHELP_CAT_MAINT|SWTYPE_NAME|SWOPT_RUNTIME_ONLY|SWOPT_HIDDEN, + 0, 0, + (PCLFunction_t)doDumpNameCache, NULL, + {{0, 0}}, 0, 0, StructMSG("Show name cache contents.", 85) - }, + }, #endif @@ -4032,7 +4029,7 @@ PCLSwitchDef_s CMN_CommandLineSwitches[] = {{0,0}},0,TRUE, StructMSG("Set the purge high water mark to this percentage for one or ALL Pools. Usage: /PoolHighWaterMark=POOL:PERCENT", 644) }, - + {MSGNot("PoolLowWaterMark"), NULL, SWHELP_CAT_CONTROL|SWTYPE_VALUE|SWVAL_UNICODE|SWOPT_RUNTIME_ONLY, @@ -4174,7 +4171,7 @@ PCLSwitchDef_s CMN_CommandLineSwitches[] = " (one hour). Issuing this command causes UTC time to be recalculated from local time.", 657) }, - {MSGNot("DaysUntouchedBeforeCompression"), + {MSGNot("DaysUntouchedBeforeCompression"), NULL, SWHELP_CAT_CONTROL|SWTYPE_VALUE|SWVAL_NINT|SWOPT_HAS_NUMERIC_RANGE|SWOPT_FINISHOFSTARTUP, 0,0, @@ -4183,7 +4180,7 @@ PCLSwitchDef_s CMN_CommandLineSwitches[] = StructMSG("The number of days to wait after a file was last accessed before automatically compressing it.", 668) }, - {MSGNot("DecompressFreeSpaceWarningInterval"), + {MSGNot("DecompressFreeSpaceWarningInterval"), NULL, SWHELP_CAT_CONTROL|SWTYPE_VALUE|SWVAL_NINT|SWOPT_HAS_NUMERIC_RANGE, 0,0, @@ -4194,7 +4191,7 @@ PCLSwitchDef_s CMN_CommandLineSwitches[] = " (setting the interval to 0 turns off the alert).", 669) }, - {MSGNot("DecompressPercentDiskSpaceFreeToAllowCommit"), + {MSGNot("DecompressPercentDiskSpaceFreeToAllowCommit"), NULL, SWHELP_CAT_CONTROL|SWTYPE_VALUE|SWVAL_NINT|SWOPT_HAS_NUMERIC_RANGE, 0,0, @@ -4254,7 +4251,7 @@ PCLSwitchDef_s CMN_CommandLineSwitches[] = StructMSG("Allow or Disallow level 2 (shared) oplocks.", 675) }, - {MSGNot("MaximumConcurrentCompressions"), + {MSGNot("MaximumConcurrentCompressions"), NULL, SWHELP_CAT_CONTROL|SWTYPE_VALUE|SWVAL_NINT|SWOPT_HAS_NUMERIC_RANGE|SWOPT_FINISHOFSTARTUP|SWOPT_RUNTIME_ONLY, 0,0, @@ -4265,7 +4262,7 @@ PCLSwitchDef_s CMN_CommandLineSwitches[] = }, - {MSGNot("MinimumCompressionPercentageGain"), + {MSGNot("MinimumCompressionPercentageGain"), NULL, SWHELP_CAT_CONTROL|SWTYPE_VALUE|SWVAL_NINT|SWOPT_HAS_NUMERIC_RANGE|SWOPT_FINISHOFSTARTUP|SWOPT_RUNTIME_ONLY, 0,0, @@ -4274,7 +4271,7 @@ PCLSwitchDef_s CMN_CommandLineSwitches[] = StructMSG("The minimum percentage a file must compress in order to remain compressed.", 677) }, -/* The code to implement this above currently does nothing. When the code is completed, this structure will call it +/* The code to implement this above currently does nothing. When the code is completed, this structure will call it {MSGNot("MinimumFileDeleteWaitTime"), NULL, SWHELP_CAT_CONTROL|SWTYPE_VALUE|SWVAL_NINT|SWOPT_HAS_NUMERIC_RANGE, @@ -4304,7 +4301,7 @@ PCLSwitchDef_s CMN_CommandLineSwitches[] = (PCLFunction_t)doEchoString, NULL, {{0,0}},0,0, StructMSG("Echo a character string",000) - }, + }, #endif {MSGNot("WriteMessyBeasts"), @@ -4334,7 +4331,7 @@ PCLSwitchDef_s CMN_CommandLineSwitches[] = StructMSGNot("Only enable when fixing broken file atributes.") }, - {PCMDLINE_ENDOFLIST} + {PCMDLINE_ENDOFLIST} }; ///************************************************************************** @@ -4365,3 +4362,4 @@ PCLSwitchDef_s CMN_CommandLineSwitches[] = // // {PCMDLINE_ENDOFLIST} //}; + diff --git a/src/nwnss/comn/main/comnLKM.c b/src/nwnss/comn/main/comnLKM.c new file mode 100644 index 0000000..de6565d --- /dev/null +++ b/src/nwnss/comn/main/comnLKM.c @@ -0,0 +1,249 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996, 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Initialize COMN + +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include + + +#include /* netware */ + +#include /* Library */ +#include +#include +#include +#include + +#include "pssStartup.h" +#include "adminVolume.h" +#include "nssDebug.h" + +/*------------------------------------------------------------------------- + * Global variables + *-------------------------------------------------------------------------*/ +char **NSSMessageTable; + +static LONG CMN_ModuleIsLoaded = 0; +# define LOADED_MAGIC 0x54494E49 + +struct LoadDefinitionStructure *CMN_ModuleHandle; +struct ScreenStruct *CMN_DefaultScreen; + + +/*------------------------------------------------------------------------- + * Defines the CallBacks for NSS + *-------------------------------------------------------------------------*/ +NSSRegistrationCallBacks_s CMN_CallBacks = +{ + CMN_GlobalStartup, + CMN_ServerDown +}; + + +/*------------------------------------------------------------------------- + * Defines the name of the MODULE. + *-------------------------------------------------------------------------*/ +STATIC char myNLMName[] = MODULE_NAME; +const char Module[] = MODULE_NAME; + + +/************************************************************************** + * load function for the NLM initialization process + ***************************************************************************/ +LONG GenericStartRoutine( + void *handle, + void *errorScreen, + BYTE *commandLine) +{ +#ifndef __linux__ + LONG numMessages; + LONG languageID; + BYTE *helpFile; + LONG result; +#endif + STATUS status; + char cmn_CommandLine[128]; + +/*------------------------------------------------------------------------- + * Init global variables + *-------------------------------------------------------------------------*/ + Enable(); /* Because interrupts comes in masked*/ + MPKNSS_LOCK(); + + CMN_ModuleHandle = handle; + CMN_DefaultScreen = errorScreen; + AVOL_PolicyStartup(); + + strmcpy(cmn_CommandLine,commandLine,sizeof(cmn_CommandLine)); +/*------------------------------------------------------------------------- + * setup message file + *-------------------------------------------------------------------------*/ +#ifndef __linux__ + ZOS_ReturnMessageInformation(result,(LONG)handle, (BYTE***)&NSSMessageTable, + &numMessages, &languageID, &helpFile); + if(result != zOK) + { + ERROR_LOADING_MSG_TABLES(errorScreen); + MPKNSS_UNLOCK(); + return zFAILURE; + } +#endif + + /*- ck if module is already loaded, yet return now -*/ + + if(CMN_ModuleIsLoaded == LOADED_MAGIC) + { + MPKNSS_UNLOCK(); + return zOK; + } + + /* mark module loaded */ + CMN_ModuleIsLoaded = LOADED_MAGIC; + + LB_ParseCmdline(CMN_CommandLineSwitches, POPT_AT_STARTUP, + cmn_CommandLine, NULL); + { + // sksmith - this version and copyright string are for the MSG file + char *ver = MSG("VeRsIoN=2.70 Novell Storage Services (NSS) Common Code",927); + char *copyR = MSG("CoPyRiGhT=(c) 1995-1998 Novell, Inc. All rights reserved.",965); + if (ver && copyR) + { + } + } +/*------------------------------------------------------------------------- + * Register with NSS and tell them we are HERE. + *-------------------------------------------------------------------------*/ + status = NSS_RegisterExternalNLM( + myNLMName, + CMN_ModuleHandle, + NSSMessageTable, + NSSMODULETYPE_COMMON, + NSSREGFLAG_REQUIRED, + &CMN_VersionInfo, + NSSAPI_VERSION, + NSS_SNAPDATE, + NSS_DEBUG_STATE, + NSS_MP_FLAG, + CMN_CommandLineSwitches, + &CMN_CallBacks); + if (status != zOK) + { + MPKNSS_UNLOCK(); + return zFAILURE; + } + MPKNSS_UNLOCK(); + return zOK; +} + + +/************************************************************************** + * This routine is called to UNLOAD the nlm + ***************************************************************************/ +LONG GenericExitRoutine(void) +{ + + MPKNSS_LOCK(); + + AVOL_PolicyShutdown(); + + if (CMN_ModuleIsLoaded == LOADED_MAGIC) + { + CMN_GlobalShutdown(); + NSS_UnRegisterExternalNLM(myNLMName); + } + MPKNSS_UNLOCK(); + return zOK; +} + + + +static int __init comn_init (void) +{ + LONG retc; + + printk("<1>" "COMN::%s[%d]\n", __FILE__, __LINE__ ); + mpkEnter(); + retc = GenericStartRoutine(&init_module, "", ""); + printk("<1>" "COMN::%s[%d]\n", __FILE__, __LINE__ ); + mpkExit(); + + return(retc); // TODO: Is this correct for LINUX +} + + + +static void __exit comn_exit (void) +{ + mpkEnter(); + printk("<1>" "COMN::%s[%d]\n", __FILE__, __LINE__ ); + GenericExitRoutine(); + printk("<1>" "COMN::%s[%d]\n", __FILE__, __LINE__ ); + mpkExit(); + return; // TODO: Is this correct for LINUX +} + +void __cyg_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void __cyg_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); + + +void __cyg_profile_func_enter (void *this_fn, void *call_site) +{ + nss_profile_func_enter(this_fn, call_site); + return; +} + +void __cyg_profile_func_exit (void *this_fn, void *call_site) +{ + nss_profile_func_exit(this_fn, call_site); + return; +} + +MODULE_AUTHOR("Novell, Inc."); +MODULE_DESCRIPTION("NSS Common Layer"); +MODULE_LICENSE("GPL v2"); + +module_init(comn_init) +module_exit(comn_exit) diff --git a/src/nwnss/comn/main/comnsaSDKSym.c b/src/nwnss/comn/main/comnsaSDKSym.c new file mode 100644 index 0000000..722e6cf --- /dev/null +++ b/src/nwnss/comn/main/comnsaSDKSym.c @@ -0,0 +1,45 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export comnSA symbols to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB + +#include + +#include +#include + + +EXPORT_SYMBOL(NAME_GetParentEntry); diff --git a/src/nwnss/comn/main/marshal.c b/src/nwnss/comn/main/marshal.c new file mode 100644 index 0000000..c3f36a7 --- /dev/null +++ b/src/nwnss/comn/main/marshal.c @@ -0,0 +1,338 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996-2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-03-19 04:10:05 +0530 (Sat, 19 Mar 2005) $ + | + | $RCSfile$ + | $Revision: 882 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Code to marshal zAPIs. + +-------------------------------------------------------------------------*/ + +#include +#include +typedef ADDR PHYSADDR; + +#ifndef __linux__ // LINUX_Marshalling +#include +#endif + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef __linux__ // LINUX_Marshalling + +STATUS MARSHAL_Startup (struct GeneralMsg_s *genMsg) +{ + return zOK; +} +void MARSHAL_Shutdown() +{ + return; +} + +#else + +extern LONG RegisterMarshallingCode( + ADDR startAddress, + ADDR endAddress, + struct ResourceTagStructure *rTag, + LONG *codeHandle); + +extern LONG RegisterSystemCall( + void (*entryPoint)(), + char *entryPointName, + LONG parameterCount, + void *moduleHandle, + LONG addressSpace, + LONG flags, + struct ResourceTagStructure *rTag); + +extern LONG UnregisterMarshallingCode(LONG codeHandle); + +extern LONG UnregisterSystemCall( + char *entryPointName, + void *moduleHandle, + LONG addressSpace); + +void MARSHAL_CodeBegin (void) +{ + /* + * Marks the begining of the marshalling code + * + * We have made a very big assumption here, functions + * will be laid out in memory in the order that they + * appear in code. (Just hope we never get a compiler + * that reorders functions to reduce cache conflicts.) + */ +} + +STATUS lockMemory (void *start, NINT length) +{ + volatile BYTE *begin = start; + volatile BYTE *end = begin + length; + NINT sum; + + sum = *end; + while (begin < end) + { + sum += *begin; + begin += PAGE_SIZE; + } + return NVMKernelLock(start, length); +} + +STATUS MARSHAL_zMSG_Call (Key_t key, NINT method, Msg_s *msg) +{ + STATUS rc; + NINT i, j; + NINT numDataAreas; + + if (lockMemory(msg, sizeof(Msg_s)) != zOK) + { + return zERR_BAD_ADDRESS; + } + if ((numDataAreas = msg->sys.numDataAreas) > MAX_DATA_AREAS) + { + return zERR_BAD_PARAMETER_VALUE; + } + for (i = 0; i < numDataAreas; ++i) + { + rc = lockMemory(msg->sys.data[i].start, msg->sys.data[i].length); + if (rc != zOK) + { + for (j = 0; j < i; ++j) + { + NVMKernelUnlock(msg->sys.data[i].start, + msg->sys.data[i].length); + } + NVMKernelUnlock(msg, sizeof(Msg_s)); + return zERR_BAD_ADDRESS; + } + } + rc = zMSG_Call(key, method, msg); + for (i = 0; i < numDataAreas; ++i) + { + NVMKernelUnlock(msg->sys.data[i].start, msg->sys.data[i].length); + } + NVMKernelUnlock(msg, sizeof(Msg_s)); + return rc; +} + +STATUS MARSHAL_zRead ( + Key_t key, + Xid_t xid, + QUAD startingOffset, + NINT bytesToRead, + void *retBuffer, + NINT *retBytesRead) +{ + STATUS rc; + NINT bytesRead; + + if (lockMemory(retBuffer, bytesToRead) != zOK) + { + return zERR_BAD_ADDRESS; + } + rc = zRead(key, xid, startingOffset, bytesToRead, retBuffer, &bytesRead); + if (rc == zOK) + { + *retBytesRead = bytesRead; + } + NVMKernelUnlock(retBuffer, bytesToRead); + return rc; +} + +STATUS MARSHAL_zRootKey ( + NINT connectionID, + Key_t *retRootKey) +{ + Key_t rootKey; + STATUS rc; + + rc = zRootKey(connectionID, &rootKey); + if (rc == zOK) + { + *retRootKey = rootKey; + } + return rc; +} + +STATUS MARSHAL_xIdToGuid (LONG id, NDSid_t *guid) +{ + NDSid_t localGuid; + STATUS status; + + status = xIdToGuid(id, &localGuid); + if (status == zOK) + { + *guid = localGuid; + } + return status; +} + +STATUS MARSHAL_xGuidToId (NDSid_t *guid, LONG *idp) +{ + NDSid_t localGuid; + LONG id; + STATUS status; + + localGuid = *guid; + + status = xGuidToId( &localGuid, &id); + if (status == zOK) + { + *idp = id; + } + return status; +} + +void MARSHAL_CodeEnd (void) +{ + /* Marks the end of the marshalling code */ +} + +typedef struct Marshal_s +{ + voidfunc_t entryPoint; /* This is the ring-0 address of the function. + * After we get through the callgate, we will + * execute here. + */ + char *name; /* This is the name (NULL-terminated) of the + * function that we will register with the + * loader (or symbol table). This is the name + * that must be in the user-application's import + * list. Note that this name can be different + * than the ring-0 name. + */ + LONG parameterCount; /* This is the number of parameters of the + * function. This is necessary to have when + * copying from the ring-3 stack to the ring-0 + * stack. Note that if this parameter is -1, + * we will copy the user's stack pointer to + * the kernel's stack. It will then be up to + * the marshalling code to get the parameters + * off the stack. This is necessary for + * variable-length parameter lists. + */ + BOOL registered; /* Used in clean-up code to unregister + * the marshalling code. + */ +} Marshal_s; + +Marshal_s Marshal[] = +{ + { (voidfunc_t)zClose, "zClose", 2, FALSE }, + { (voidfunc_t)MARSHAL_zMSG_Call, "zMSG_Call", 4, FALSE }, + { (voidfunc_t)MARSHAL_zRead, "zRead", 9, FALSE }, + { (voidfunc_t)MARSHAL_zRootKey, "zRootKey", 2, FALSE }, + { (voidfunc_t)MARSHAL_xIdToGuid, "xIdToGuid", 2, FALSE }, + { (voidfunc_t)MARSHAL_xGuidToId, "xGuidToId", 2, FALSE }, + { (voidfunc_t)NULL, NULL, 0, FALSE } +}; + +LONG MARSHAL_CodeHandle; + +void MARSHAL_unregister () +{ + Marshal_s *marshal; + + for (marshal = Marshal; marshal->entryPoint != NULL; ++marshal) + { + if (marshal->registered) + { + UnregisterSystemCall(marshal->name, + CMN_ModuleHandle, + 0); + } + marshal->registered = FALSE; + } +} + +STATUS MARSHAL_Startup (struct GeneralMsg_s *genMsg) +{ + STATUS rc; + Marshal_s *marshal; + + ASSERT_MPKNSS_LOCK(); + + MPKNSS_UNLOCK(); + rc = RegisterMarshallingCode( (ADDR)MARSHAL_CodeBegin, + (ADDR)MARSHAL_CodeEnd, + COMN_Resource.memoryRTag, + &MARSHAL_CodeHandle); + if (rc != zOK) + { + MPKNSS_LOCK(); + return rc; + } + for (marshal = Marshal; marshal->entryPoint != NULL; ++marshal) + { + rc = RegisterSystemCall(marshal->entryPoint, + marshal->name, + marshal->parameterCount, + CMN_ModuleHandle, + 0, 0, +#ifdef __linux__ // LINUX_Marshalling + NULL); +#else + COMN_Resource.systemCallRTag); +#endif + if (rc != zOK) + { + MPKNSS_LOCK(); + MARSHAL_Shutdown(); + return rc; + } + marshal->registered = TRUE; + } + MPKNSS_LOCK(); + return zOK; +} + +void MARSHAL_Shutdown() +{ + ASSERT_MPKNSS_LOCK(); + + MPKNSS_UNLOCK(); + MARSHAL_unregister(); + UnregisterMarshallingCode(MARSHAL_CodeHandle); + MPKNSS_LOCK(); +} + +#endif + diff --git a/src/nwnss/comn/main/nssCOMNSym.c b/src/nwnss/comn/main/nssCOMNSym.c new file mode 100644 index 0000000..5a9ea7b --- /dev/null +++ b/src/nwnss/comn/main/nssCOMNSym.c @@ -0,0 +1,502 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2006-08-18 01:53:17 +0530 (Fri, 18 Aug 2006) $ + | + | $RCSfile$ + | $Revision: 1489 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export COMN symbols to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern BOOL VIRT_PrintDebug; + +EXPORT_SYMBOL(NSSUT_DisplayAll); +EXPORT_SYMBOL(VP_ClearChecking); +EXPORT_SYMBOL(VP_ClearRepairing); +EXPORT_SYMBOL(VP_MarkAsChecking); +EXPORT_SYMBOL(VP_MarkAsRepairing); +EXPORT_SYMBOL(VFS_AddUnicode); +EXPORT_SYMBOL(VFS_ssprintf); +EXPORT_SYMBOL(MGMT_ReturnResultNSSWithSetter); +EXPORT_SYMBOL(MNSS_BuildResult2); +EXPORT_SYMBOL(MNSS_ConvertBitsToTags); +EXPORT_SYMBOL(MNSS_ConvertNameSpaceTagsToValue); +EXPORT_SYMBOL(MNSS_ConvertNameTypeTagsToValue); +EXPORT_SYMBOL(MNSS_ConvertTagsToBits); +EXPORT_SYMBOL(MNSS_FillInAnID); +EXPORT_SYMBOL(MNSS_FillUTCTime); +EXPORT_SYMBOL(MNSS_FindUserIDByDN); +EXPORT_SYMBOL(MNSS_GetGUIDFromName); +EXPORT_SYMBOL(MNSS_GetNDSNameFromGUID); +EXPORT_SYMBOL(MNSS_GetTagContents); +EXPORT_SYMBOL(MNSS_ReturnResult2); + +EXPORT_SYMBOL(AdminVolDirs); +EXPORT_SYMBOL(asyncReadAhead); +EXPORT_SYMBOL(asyncReadFileBlk); +EXPORT_SYMBOL(attrBitsToCheck); +EXPORT_SYMBOL(attrTags); +EXPORT_SYMBOL(AUTHSYS_VolInit); +EXPORT_SYMBOL(AuthModelIDMap); +EXPORT_SYMBOL(AuthModels); +EXPORT_SYMBOL(BEASTHASH_LookupByZid); + +#ifdef DEBUG_BEAST_USE_COUNT +EXPORT_SYMBOL(BEASTHASH_InsertInternal); +EXPORT_SYMBOL(BEASTHASH_incrementUseCountInternal); +#else +EXPORT_SYMBOL(BEASTHASH_Insert); +EXPORT_SYMBOL(BEASTHASH_incrementUseCount); +#endif + +EXPORT_SYMBOL(BST_ArrayIndex2ClassID); +EXPORT_SYMBOL(BST_ClassID2ArrayIndex); +EXPORT_SYMBOL(BST_cleanupDeletedFile); +EXPORT_SYMBOL(BST_doPackIndex); +EXPORT_SYMBOL(BST_doUnpackIndex); +EXPORT_SYMBOL(BST_flush); +EXPORT_SYMBOL(BST_free); +EXPORT_SYMBOL(BST_getPackedSizeIndex); +EXPORT_SYMBOL(BST_MarkCleanAndNotNew); +EXPORT_SYMBOL(BST_MarkDirty); +EXPORT_SYMBOL(BST_MarkXLocal); +EXPORT_SYMBOL(BST_new); +EXPORT_SYMBOL(BST_noPackCleanupIndex); +EXPORT_SYMBOL(BST_PurgeFileName); +EXPORT_SYMBOL(BST_releaseAndFree); +EXPORT_SYMBOL(BST_truncate); +EXPORT_SYMBOL(CM_cleanupBeast); +EXPORT_SYMBOL(CM_compressFileRange); +EXPORT_SYMBOL(CM_curCompStatistics); +EXPORT_SYMBOL(CM_prepareToTruncateFile); +EXPORT_SYMBOL(CM_prepareToWriteCompFile); +EXPORT_SYMBOL(CM_StartUpgradeProcess); +EXPORT_SYMBOL(CM_resetVolumeCompState); +EXPORT_SYMBOL(CM_tossUncompBeastData); +EXPORT_SYMBOL(CM_uncompressFileRange); +EXPORT_SYMBOL(COMN_AbortUserXaction); +EXPORT_SYMBOL(COMN_AbortXLocal); +EXPORT_SYMBOL(COMN_AddMACDataStreamToNameMsg); +EXPORT_SYMBOL(COMN_AddNameToBeast); +EXPORT_SYMBOL(COMN_AllocSemanticAgentHandle); +EXPORT_SYMBOL(COMN_AsyncRead); +EXPORT_SYMBOL(COMN_AsyncReleaseBuffer); +//WRONG PLACE//EXPORT_SYMBOL(COMN_AsyncSetupDSIAndUpdateInNDS); +EXPORT_SYMBOL(COMN_BeastTossOldNotInUseBeasts); +EXPORT_SYMBOL(COMN_BeginUserXaction); +EXPORT_SYMBOL(COMN_BeginXLocal); +EXPORT_SYMBOL(COMN_BrowseBeastsInVolume); +EXPORT_SYMBOL(COMN_ChangeContextHandle); +EXPORT_SYMBOL(COMN_ChangePoolState); +EXPORT_SYMBOL(COMN_ChangePoolStateByName); +EXPORT_SYMBOL(COMN_ChangeSingleVolumeStateByName); +EXPORT_SYMBOL(COMN_ChangeStateCommandLineSwitches); +EXPORT_SYMBOL(COMN_ChangeVolumeState); +EXPORT_SYMBOL(COMN_ChangeVolumeStateByName); +EXPORT_SYMBOL(COMN_CheckLowSpace); +//WRONG PLACE//EXPORT_SYMBOL(COMN_CleanupCallToDSI); +EXPORT_SYMBOL(COMN_CleanupNameMsg); +EXPORT_SYMBOL(COMN_CleanupSAgentOnVolume); +EXPORT_SYMBOL(COMN_CleanupSearchMsg); +EXPORT_SYMBOL(COMN_ClearLSSOpsForBeastClass); +EXPORT_SYMBOL(COMN_ClearTaskBasedContextHandles); +EXPORT_SYMBOL(COMN_Close); +EXPORT_SYMBOL(COMN_ClusterIDGet); +EXPORT_SYMBOL(COMN_ClusterSoftwareIsCheckingPoolStateChanges); +EXPORT_SYMBOL(COMN_CommitUserXaction); +EXPORT_SYMBOL(COMN_CopyFileToFile); +EXPORT_SYMBOL(COMN_Create); +EXPORT_SYMBOL(COMN_CreateWithCallback); +EXPORT_SYMBOL(COMN_CreatePSSConnection); +EXPORT_SYMBOL(COMN_Delete); +EXPORT_SYMBOL(COMN_DeleteBeast); +EXPORT_SYMBOL(COMN_DestroyContextHandle); +EXPORT_SYMBOL(COMN_DirectReadFile); +EXPORT_SYMBOL(COMN_DirectWriteFile); +EXPORT_SYMBOL(COMN_DoReleaseContextHandleIDP); +EXPORT_SYMBOL(COMN_DoReleaseSAgentHandleIDP); +EXPORT_SYMBOL(COMN_DoResolveConnection); +EXPORT_SYMBOL(COMN_DoResolveContextHandle); +EXPORT_SYMBOL(COMN_DoResolveFileHandle); +EXPORT_SYMBOL(COMN_DoResolveSemanticAgentHandle); +EXPORT_SYMBOL(COMN_Encrypted_Page_Head); +EXPORT_SYMBOL(COMN_EndOfTaskCleanup); +EXPORT_SYMBOL(COMN_EndXLocal); +EXPORT_SYMBOL(COMN_FastReadCache); +EXPORT_SYMBOL(COMN_FindAuthModelByName); +EXPORT_SYMBOL(COMN_FindDefaultXaction); +EXPORT_SYMBOL(COMN_FixVolumeCompStats); +EXPORT_SYMBOL(COMN_Flush); +EXPORT_SYMBOL(COMN_FlushAndTossBeast); +EXPORT_SYMBOL(COMN_FlushVolume); +EXPORT_SYMBOL(COMN_ForceBeastWrite); +EXPORT_SYMBOL(COMN_FreeRootVariableData); +EXPORT_SYMBOL(COMN_FreeSemanticAgentHandle); +EXPORT_SYMBOL(COMN_FVPW); +EXPORT_SYMBOL(COMN_GenerateUniqueName); +EXPORT_SYMBOL(COMN_GetAdminVolume); +EXPORT_SYMBOL(COMN_GetBeastFullName); +EXPORT_SYMBOL(COMN_GetBeastInfoXML); +EXPORT_SYMBOL(COMN_GetFileBlk); +EXPORT_SYMBOL(COMN_GetFileMap); +EXPORT_SYMBOL(COMN_GetFileNameFromZid); +EXPORT_SYMBOL(COMN_GetInfo); +EXPORT_SYMBOL(COMN_GetInfoByBeastPtr); +EXPORT_SYMBOL(COMN_GetMACDataStreamPtr); +EXPORT_SYMBOL(COMN_GetManagementLevel); +EXPORT_SYMBOL(COMN_GetName); +EXPORT_SYMBOL(COMN_GetNameFromBeast); +EXPORT_SYMBOL(COMN_GetNextParentBeastComnOp); +EXPORT_SYMBOL(COMN_GetNextParentVolumeComnOp); +EXPORT_SYMBOL(COMN_GetNextVolume); +EXPORT_SYMBOL(COMN_GetPathNameWorkBuffer); +EXPORT_SYMBOL(COMN_GetPhysicalSizeOfSnap); +EXPORT_SYMBOL(COMN_GetPoolName); +EXPORT_SYMBOL(COMN_GetPurgeableBlksCnt); +EXPORT_SYMBOL(COMN_GetRegisteredLSSFeatures); +EXPORT_SYMBOL(COMN_GetStorageInfo); +EXPORT_SYMBOL(COMN_GetUserID); +EXPORT_SYMBOL(COMN_GetVersionInformation); +EXPORT_SYMBOL(COMN_GetVolumeName); +EXPORT_SYMBOL(COMN_GetZidFromMangledName); +EXPORT_SYMBOL(COMN_IncludeType); +EXPORT_SYMBOL(COMN_InitDataStreamInfo); +EXPORT_SYMBOL(COMN_InitEncryptedVolume); +EXPORT_SYMBOL(COMN_InitRootVariableData); +EXPORT_SYMBOL(COMN_InsertAndMangleName); +EXPORT_SYMBOL(COMN_IsDenyReaderWriterNotMe); +EXPORT_SYMBOL(COMN_IsDerivedFrom); +EXPORT_SYMBOL(COMN_IsIDDerivedFrom); +EXPORT_SYMBOL(COMN_ListOpenFilesOnVolume); +EXPORT_SYMBOL(COMN_LockByteRange); +EXPORT_SYMBOL(COMN_LockByteRangeSet); +EXPORT_SYMBOL(COMN_LockVolumeActive); +EXPORT_SYMBOL(COMN_LockVolumeDeactive); +EXPORT_SYMBOL(COMN_Lookup); +EXPORT_SYMBOL(COMN_LookupByZid); +EXPORT_SYMBOL(COMN_LookupByZidInBeastHash); +EXPORT_SYMBOL(COMN_LookupByZidInBeastHashAndToss); +EXPORT_SYMBOL(COMN_LPNameToUnicode); +EXPORT_SYMBOL(COMN_MakeShortMacFileName); +EXPORT_SYMBOL(COMN_MakeVolumeFreeSpace); +EXPORT_SYMBOL(COMN_MapNDSGUIDToName); +EXPORT_SYMBOL(COMN_MapNDSGUIDToUID); +EXPORT_SYMBOL(COMN_MapUIDToNDSGUID); +//WRONG PLACE//EXPORT_SYMBOL(COMN_MapNDSGUIDToID); +//WRONG PLACE//EXPORT_SYMBOL(COMN_MapNDSGUIDToIDWithNameMsg); +//WRONG PLACE//EXPORT_SYMBOL(COMN_MapNDSIDToGUID); +EXPORT_SYMBOL(COMN_SetBeastInfoXML); +EXPORT_SYMBOL(COMN_ModifyInfo); +EXPORT_SYMBOL(COMN_NameSpaceIDLookup); +EXPORT_SYMBOL(COMN_NameToUnicode); +EXPORT_SYMBOL(COMN_Open); +EXPORT_SYMBOL(COMN_OverrideType); +EXPORT_SYMBOL(COMN_PackedSizeRootVariableData); +EXPORT_SYMBOL(COMN_PackRootVariableData); +EXPORT_SYMBOL(COMN_PoolActiveLock); +EXPORT_SYMBOL(COMN_PoolActiveUnlock); +EXPORT_SYMBOL(COMN_PoolEvent); +EXPORT_SYMBOL(COMN_PoolIDLookup); +EXPORT_SYMBOL(COMN_PoolNameLookup); +EXPORT_SYMBOL(COMN_RegisterBeastClassList); +EXPORT_SYMBOL(COMN_RegisterForLinuxConnectionCallbacks); +EXPORT_SYMBOL(COMN_RegisterForVolumeEvents); +EXPORT_SYMBOL(COMN_RegisterLSSFeatures); +EXPORT_SYMBOL(COMN_RegisterRootVariableDataType); +EXPORT_SYMBOL(COMN_ReleaseInternal); +EXPORT_SYMBOL(COMN_ReleaseChunks); +EXPORT_SYMBOL(COMN_ReleasePathNameWorkBufferInternal); +//WRONG PLACE//EXPORT_SYMBOL(COMN_RemoveIDsFromAllVolumes); +EXPORT_SYMBOL(COMN_RemovePSSConnection); +EXPORT_SYMBOL(COMN_Rename); +EXPORT_SYMBOL(COMN_ResetNameMsgToSearchPattern); +//WRONG PLACE//EXPORT_SYMBOL(COMN_Resource); +EXPORT_SYMBOL(COMN_SendNSSEvent); +EXPORT_SYMBOL(COMN_ServerIDGet); +EXPORT_SYMBOL(COMN_SetDataSize); +EXPORT_SYMBOL(COMN_SetLSSOpsForBeastClass); +EXPORT_SYMBOL(COMN_SetupContextHandle); +//WRONG PLACE//EXPORT_SYMBOL(COMN_SetupDSIAndLogin); +EXPORT_SYMBOL(COMN_StartUXactionSupportOnVolume); +EXPORT_SYMBOL(COMN_SVPW); +//WRONG PLACE//EXPORT_SYMBOL(COMN_SVKY); +EXPORT_SYMBOL(COMN_SwitchToDirectFileMode); +EXPORT_SYMBOL(COMN_UnicodeToLPName); +EXPORT_SYMBOL(COMN_UnicodeToName); +EXPORT_SYMBOL(COMN_UnlatchAndReleaseInternal); +EXPORT_SYMBOL(COMN_UnlockByteRange); +EXPORT_SYMBOL(COMN_UnlockByteRangeSet); +EXPORT_SYMBOL(COMN_UnlockVolumeActive); +EXPORT_SYMBOL(COMN_UnlockVolumeDeactive); +EXPORT_SYMBOL(COMN_UnpackRootVariableData); +EXPORT_SYMBOL(COMN_UnregisterBeastClass); +EXPORT_SYMBOL(COMN_UnRegisterForVolumeEvents); +EXPORT_SYMBOL(COMN_UnregisterLSSFeatures); +EXPORT_SYMBOL(COMN_UnRegisterRootVariableDataType); +EXPORT_SYMBOL(COMN_UpdateUIDToGUIDCache); +EXPORT_SYMBOL(COMN_ValidateNameSpace); +EXPORT_SYMBOL(COMN_VolumeAlert); +EXPORT_SYMBOL(COMN_VolumeAttributesChanged); +EXPORT_SYMBOL(COMN_VolumeCommonOpsViaVirtualFile); +EXPORT_SYMBOL(COMN_VolumeEvent); +EXPORT_SYMBOL(COMN_VolumeIDLookup); +EXPORT_SYMBOL(COMN_VolumeMaintenance); +EXPORT_SYMBOL(COMN_VolumeNameLookup); +EXPORT_SYMBOL(COMN_WildClose); +EXPORT_SYMBOL(COMN_WildFindOpenContainerWithZID); +EXPORT_SYMBOL(COMN_WildOpen); +EXPORT_SYMBOL(COMN_WildRead); +EXPORT_SYMBOL(COMN_WildRewind); +EXPORT_SYMBOL(COMN_WildSetupReread); +EXPORT_SYMBOL(COMN_Write); +EXPORT_SYMBOL(COMN_ZidToFileName); +EXPORT_SYMBOL(ConnectionIsLoggedIn); +EXPORT_SYMBOL(CRO_ProcessErrorAndRequestRetry); +EXPORT_SYMBOL(CRO_AccessLeaseSync); +EXPORT_SYMBOL(CRO_AccessLeaseToss); +EXPORT_SYMBOL(CRO_AccessLeaseValidate); +EXPORT_SYMBOL(CSA_Stats); +#if NSS_DEBUG IS_ENABLED +EXPORT_SYMBOL(DBG_EqualS); +#endif +EXPORT_SYMBOL(DIRQ_AdjustUsedDirSpace); +EXPORT_SYMBOL(DIRQ_ChangeDirQuotaAttribute); +EXPORT_SYMBOL(DIRQ_ChangeVolumeDirectoryQuotasByName); +EXPORT_SYMBOL(DIRQ_CheckDirQuotas); +EXPORT_SYMBOL(DIRQ_MinDirQuota); +EXPORT_SYMBOL(DIRQ_ComputeUsedAmount); +EXPORT_SYMBOL(DIRQ_DisableDirectoryQuotas); +EXPORT_SYMBOL(DIRQ_GetADirectoryQuota); +EXPORT_SYMBOL(DIRQ_GetDirectoryQuotas); +EXPORT_SYMBOL(DIRQ_RemoveDirectoryQuota); +EXPORT_SYMBOL(DIRQ_SetDirectoryQuota); +EXPORT_SYMBOL(displayFileCounts); +EXPORT_SYMBOL(EA_Open); +EXPORT_SYMBOL(EFL_ControlReadFunc); +EXPORT_SYMBOL(EFL_ControlWriteFunc); +EXPORT_SYMBOL(EFL_GetNameFromZid); +EXPORT_SYMBOL(FH_AddRights); +EXPORT_SYMBOL(FH_AreRightsCompatible); +EXPORT_SYMBOL(FH_DeleteRights); +EXPORT_SYMBOL(FH_SetOpenFileGrantedRights); +EXPORT_SYMBOL(fixCompFlags); +EXPORT_SYMBOL(hackKey); +EXPORT_SYMBOL(HL_doCreateHardLinkBeast); +EXPORT_SYMBOL(IsSupervisor); +EXPORT_SYMBOL(LB_PoolNameAcceptable); +//WRONG PLACE//EXPORT_SYMBOL(LB_VolumeFindMMVolume); +EXPORT_SYMBOL(LB_VolumeNameAcceptable); +EXPORT_SYMBOL(LegacyEventReport); +EXPORT_SYMBOL(LOCK_IsExclusiveByteRange); +EXPORT_SYMBOL(LOCK_IsSharedByteRange); +EXPORT_SYMBOL(LSSOpsIDMap); +EXPORT_SYMBOL(MaxRegisteredNameSpaceID); +EXPORT_SYMBOL(MGMT_BuildResultElement); +EXPORT_SYMBOL(MGMT_CopyToWorkingBuffer); +EXPORT_SYMBOL(MGMT_FindFirstElement); +EXPORT_SYMBOL(MGMT_MakeCommandVirtualFile); +EXPORT_SYMBOL(MGMT_MakeCommandVirtualFileWithHelp); +EXPORT_SYMBOL(MGMT_MakeFunctionVirtualFile); +EXPORT_SYMBOL(MGMT_MakeFunctionVirtualFileWithHelp); +EXPORT_SYMBOL(MGMT_readOverride); +EXPORT_SYMBOL(MGMT_ReturnError); +EXPORT_SYMBOL(MGMT_ReturnResultNSS); +EXPORT_SYMBOL(MGMTS_MakeCommandVirtualFile); +EXPORT_SYMBOL(MGMTS_MakeCommandVirtualFileWithHelp); +EXPORT_SYMBOL(MGMTS_MakeFunctionVirtualFile); +EXPORT_SYMBOL(MGMTS_MakeFunctionVirtualFileWithHelp); +EXPORT_SYMBOL(NAME_doAddName); +EXPORT_SYMBOL(NAME_InvalidateCacheEntriesForDirectory); +EXPORT_SYMBOL(NAME_RemoveNameFromCache); +EXPORT_SYMBOL(NAMED_BeastCleanupNames); +EXPORT_SYMBOL(NameTypeNameSpaces); +//WRONG PLACE//EXPORT_SYMBOL(NSSDummy_DSIAlert); +//WRONG PLACE//EXPORT_SYMBOL(NSSDummy_DSIEndWait); +//WRONG PLACE//EXPORT_SYMBOL(NSSDummy_DSIInformation); +//WRONG PLACE//EXPORT_SYMBOL(NSSDummy_DSIStartWait); +//WRONG PLACE//EXPORT_SYMBOL(NSSDummy_EndObjectUpgradeDisplay); +//WRONG PLACE//EXPORT_SYMBOL(NSSDummy_InstallAlloc); +//WRONG PLACE//EXPORT_SYMBOL(NSSDummy_InstallCheckForAbort); +//WRONG PLACE//EXPORT_SYMBOL(NSSDummy_InstallFree); +//WRONG PLACE//EXPORT_SYMBOL(NSSDummy_InstallResolveDSConflicts); +//WRONG PLACE//EXPORT_SYMBOL(NSSDummy_InstallReturnFileServerName); +//WRONG PLACE//EXPORT_SYMBOL(NSSDummy_InstallTrace); +//WRONG PLACE//EXPORT_SYMBOL(NSSDummy_ObjectUpgradeStatus); +//WRONG PLACE//EXPORT_SYMBOL(NSSDummy_StartObjectUpgradeDisplay); +EXPORT_SYMBOL(NSSLOG_EventLog); +EXPORT_SYMBOL(NSSLOG_EventLogWithPool); +EXPORT_SYMBOL(NSSLOG_EventLogWithPoolAndGenMsg); +EXPORT_SYMBOL(NSSLOG_EventLogWithVolume); +EXPORT_SYMBOL(NSSLOG_EventLogWithVolumeAndGenMsg); +EXPORT_SYMBOL(NSSMasterPoolList); +EXPORT_SYMBOL(NSSMasterVolumeList); +EXPORT_SYMBOL(NW_ClientFileCachingEnabledFlag); +EXPORT_SYMBOL(NW_Level2OpLocksEnabledFlag); +EXPORT_SYMBOL(OID_InitObjectInfo); +EXPORT_SYMBOL(OID_InvalidateObjectIDCache); +EXPORT_SYMBOL(OID_SaveObjectID); +EXPORT_SYMBOL(OpLockInst); +EXPORT_SYMBOL(OPLOCK_AllocExclusive); +EXPORT_SYMBOL(OPLOCK_AllocShared); +EXPORT_SYMBOL(OPLOCK_Break); +EXPORT_SYMBOL(OPLOCK_BreakExclusive); +EXPORT_SYMBOL(OPLOCK_BreakFailed); +EXPORT_SYMBOL(OPLOCK_BreakShared); +EXPORT_SYMBOL(OPLOCK_Free); +EXPORT_SYMBOL(OPLOCK_MakeShared); +EXPORT_SYMBOL(OPLOCK_WaitForBreak); +//WRONG PLACE//EXPORT_SYMBOL(OS_setParmCommand); +//WRONG PLACE//XPORT_SYMBOL(OS_setParmRead); +EXPORT_SYMBOL(pool_blockSize); +EXPORT_SYMBOL(POOL_BstNew); +EXPORT_SYMBOL(POOL_FlushPool); +EXPORT_SYMBOL(pool_info); +EXPORT_SYMBOL(POOL_Rename); +EXPORT_SYMBOL(pool_salFreeableSize); +EXPORT_SYMBOL(pool_salHighWaterMark); +EXPORT_SYMBOL(pool_salLowWaterMark); +EXPORT_SYMBOL(pool_salMaxKeepSeconds); +EXPORT_SYMBOL(pool_salMinKeepSeconds); +EXPORT_SYMBOL(pool_salNonFreeableSize); +EXPORT_SYMBOL(pool_volumes); +EXPORT_SYMBOL(resolveXaction); +EXPORT_SYMBOL(SBS_enumerateMFL); +EXPORT_SYMBOL(SBS_markFileModified); +EXPORT_SYMBOL(SBS_markFileUnmodified); +EXPORT_SYMBOL(SBS_volumeMFLControlReadFunc); +EXPORT_SYMBOL(SBS_volumeMFLControlWriteFunc); +EXPORT_SYMBOL(TestScanComponents); +EXPORT_SYMBOL(UXactionActivateThread); +EXPORT_SYMBOL(UXactionSystemInited); +EXPORT_SYMBOL(UXAS_StoreIDInGUID); +EXPORT_SYMBOL(UXASindex); +EXPORT_SYMBOL(VAUTH_MayIDoThis); +EXPORT_SYMBOL(VIRT_AddAttribute); +EXPORT_SYMBOL(VIRT_AddResultCDataElement); +EXPORT_SYMBOL(VIRT_AddResultData); +EXPORT_SYMBOL(VIRT_AddResultElement); +EXPORT_SYMBOL(VIRT_AddResultTag); +EXPORT_SYMBOL(VIRT_AddResultTagForAttribute); +EXPORT_SYMBOL(VIRT_CheckResultSize); +EXPORT_SYMBOL(VIRT_FinishVirtualFile); +EXPORT_SYMBOL(VIRT_InitVirtualFile); +EXPORT_SYMBOL(VIRT_MakeDataTypeDataStream); +EXPORT_SYMBOL(VIRT_MakeReadWriteFuncDataStream); +EXPORT_SYMBOL(VIRT_MakeResultsImportant); +EXPORT_SYMBOL(VIRT_MakeResultsNormal); +EXPORT_SYMBOL(VIRT_ResetResult); +EXPORT_SYMBOL(VIRT_ssprintf); +EXPORT_SYMBOL(VIRT_test); +EXPORT_SYMBOL(VIRT_testCommand); +EXPORT_SYMBOL(VIRT_testCookieRead); +EXPORT_SYMBOL(VIRT_testRead); +EXPORT_SYMBOL(VIRT_testWrite); +EXPORT_SYMBOL(volume_dirInfo); +EXPORT_SYMBOL(volume_getExtendedInfo); +EXPORT_SYMBOL(volume_getInfo); +EXPORT_SYMBOL(volume_userInfo); +EXPORT_SYMBOL(VOL_Activate); +EXPORT_SYMBOL(VOL_AdjustUsedUserSpace); +EXPORT_SYMBOL(VOL_BrowseUsersInVolume); +EXPORT_SYMBOL(VOL_BstNew); +EXPORT_SYMBOL(VOL_BstNew2); +EXPORT_SYMBOL(VOL_ChangeUserSpaceAttribute); +EXPORT_SYMBOL(VOL_ChangeVolumeSalvageByName); +EXPORT_SYMBOL(VOL_CheckUserSpace); +EXPORT_SYMBOL(VOL_Deactivate); +EXPORT_SYMBOL(VOL_DisableUserSpaceRestrictions); +EXPORT_SYMBOL(VOL_DisableVolume); +EXPORT_SYMBOL(VOL_FlushVolume); +EXPORT_SYMBOL(VOL_GetUserSpaceInfo); +EXPORT_SYMBOL(VOL_InitUserSpaceRestrictionData); +EXPORT_SYMBOL(VOL_insertEFLEntry); +EXPORT_SYMBOL(VOL_Rename); +EXPORT_SYMBOL(VOL_SendDeactivateEventToSAgents); +EXPORT_SYMBOL(VOL_SetUserSpaceRestriction); +EXPORT_SYMBOL(WriteXactionMarker); +EXPORT_SYMBOL(xAdjustQuotaFileLen); +EXPORT_SYMBOL(ZAS_AddACLEntry); +EXPORT_SYMBOL(ZAS_CountACLs); +EXPORT_SYMBOL(ZAS_FixVisibility); +EXPORT_SYMBOL(ZAS_GetAllACLs); +EXPORT_SYMBOL(ZAS_InvalidateEACLCacheEntries); +EXPORT_SYMBOL(ZAS_InvalidateEntireEACLCache); +EXPORT_SYMBOL(ZAS_RemoveACLEntry); +EXPORT_SYMBOL(ZASindex); +//WRONG PLACE//EXPORT_SYMBOL(zUpdateVolumeObjectInNDS); +EXPORT_SYMBOL(MGMTS_MakeUserCommandVirtualFileWithHelp); +EXPORT_SYMBOL(VIRT_PrintDebug); diff --git a/src/nwnss/comn/main/pssNLM.c b/src/nwnss/comn/main/pssNLM.c new file mode 100644 index 0000000..12e0249 --- /dev/null +++ b/src/nwnss/comn/main/pssNLM.c @@ -0,0 +1,190 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) Initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | preforms all program (NLM) initialization + | + | + +-------------------------------------------------------------------------*/ +#include /* netware */ + +#include /* Library */ +#include +#include +#include +#include + +#include "pssStartup.h" +#include "adminVolume.h" + +/*------------------------------------------------------------------------- + * Global variables + *-------------------------------------------------------------------------*/ +char **NSSMessageTable; + +static LONG CMN_ModuleIsLoaded = 0; +# define LOADED_MAGIC 0x54494E49 + +struct LoadDefinitionStructure *CMN_ModuleHandle; +struct ScreenStruct *CMN_DefaultScreen; + + +/*------------------------------------------------------------------------- + * Defines the CallBacks for NSS + *-------------------------------------------------------------------------*/ +NSSRegistrationCallBacks_s CMN_CallBacks = +{ + CMN_GlobalStartup, + CMN_ServerDown +}; + + +/*------------------------------------------------------------------------- + * Defines the name of the MODULE. + *-------------------------------------------------------------------------*/ +STATIC char myNLMName[] = MODULE_NAME; + +const char Module[] = MODULE_NAME; + + +/************************************************************************** + * load function for the NLM initialization process + ***************************************************************************/ +LONG GenericStartRoutine( + struct LoadDefinitionStructure *handle, + struct ScreenStruct *errorScreen, + BYTE *commandLine) +{ + LONG numMessages; + LONG languageID; + BYTE *helpFile; + STATUS status; + LONG result; + char cmn_CommandLine[128]; + +/*------------------------------------------------------------------------- + * Init global variables + *-------------------------------------------------------------------------*/ + Enable(); /* Because interrupts comes in masked*/ + MPKNSS_LOCK(); + + CMN_ModuleHandle = handle; + CMN_DefaultScreen = errorScreen; + AVOL_PolicyStartup(); + + strmcpy(cmn_CommandLine,commandLine,sizeof(cmn_CommandLine)); +/*------------------------------------------------------------------------- + * setup message file + *-------------------------------------------------------------------------*/ + ZOS_ReturnMessageInformation(result,(LONG)handle, (BYTE***)&NSSMessageTable, + &numMessages, &languageID, &helpFile); + if(result != zOK) + { + ERROR_LOADING_MSG_TABLES(errorScreen); + MPKNSS_UNLOCK(); + return zFAILURE; + } + + /*- ck if module is already loaded, yet return now -*/ + + if(CMN_ModuleIsLoaded == LOADED_MAGIC) + { + MPKNSS_UNLOCK(); + return zOK; + } + + /* mark module loaded */ + CMN_ModuleIsLoaded = LOADED_MAGIC; + + LB_ParseCmdline(CMN_CommandLineSwitches, POPT_AT_STARTUP, + cmn_CommandLine, NULL); + { + // sksmith - this version and copyright string are for the MSG file + char *ver = MSG("VeRsIoN=2.70 Novell Storage Services (NSS) Common Code",927); + char *copyR = MSG("CoPyRiGhT=(c) 1995-1998 Novell, Inc. All rights reserved.",965); + if (ver && copyR) + { + } + } +/*------------------------------------------------------------------------- + * Register with NSS and tell them we are HERE. + *-------------------------------------------------------------------------*/ + status = NSS_RegisterExternalNLM( + myNLMName, + (NINT)CMN_ModuleHandle, + NSSMessageTable, + NSSMODULETYPE_COMMON, + NSSREGFLAG_REQUIRED, + &CMN_VersionInfo, + NSSAPI_VERSION, + NSS_SNAPDATE, + NSS_DEBUG_STATE, + NSS_MP_FLAG, + CMN_CommandLineSwitches, + &CMN_CallBacks); + if (status != zOK) + { + MPKNSS_UNLOCK(); + return zFAILURE; + } + MPKNSS_UNLOCK(); + return zOK; +} + + +/************************************************************************** + * This routine is called to UNLOAD the nlm + ***************************************************************************/ +LONG GenericExitRoutine(void) +{ +// NINT row,col; + + Enable(); /* Because it comes in masked*/ +// LB_MEMORY_DISPLAY_SHUTDOWN(); + MPKNSS_LOCK(); + + AVOL_PolicyShutdown(); + + if (CMN_ModuleIsLoaded == LOADED_MAGIC) + { +// wGetPos(stdout,&row,&col); +// wSetPos(stdout,row,0); /* position to the front of the current line*/ + + CMN_GlobalShutdown(); + NSS_UnRegisterExternalNLM(myNLMName); + +// OutputToScreenWithAttribute(NSS_DefaultScreen,LGREEN,MSG("COMN" " Terminated\n\n", 0)); + } + MPKNSS_UNLOCK(); + return zOK; +} diff --git a/src/nwnss/comn/main/pssStartup.c b/src/nwnss/comn/main/pssStartup.c new file mode 100644 index 0000000..e18c132 --- /dev/null +++ b/src/nwnss/comn/main/pssStartup.c @@ -0,0 +1,1103 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: randys $ + | $Date: 2006-12-21 22:28:48 +0530 (Thu, 21 Dec 2006) $ + | + | $RCSfile$ + | $Revision: 1789 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | + | + | + +-------------------------------------------------------------------------*/ +#if zLINUX +#include +#include +#endif +#include +#include +#include + +#include /* NSS Library includes*/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pssStartup.h" +#include "zParams.h" +#include "msgName.h" +#include "comnCmdline.h" +#include "pssConfig.h" +#include "comnParams.h" +#include "msgGen.h" +#include "eventSys.h" +#include "name.h" +#include "repair.h" +#include "volume.h" +#include "utc.h" +#include "comnTask.h" +#include "nssOSAPIs.h" +#include "comnPublics.h" +#include "dirQuotas.h" +#include "comnAuthorize.h" +#include "checker.h" +#include "seqUpdater.h" +#include "zPublics.h" +#include "nssPubs.h" +#include "hmc.h" + +#include "cmNSS.h" +#include "cmAlgoMan.h" +#include "cmControl.h" +#include "uxaction.h" + +/*------------------------------------------------------------------------- + * Global variables - Development Test variables + *-------------------------------------------------------------------------*/ +NINT CMN_StartupCompleted = FALSE; /* used to know if initialization completed */ +NINT CMN_Shutdown = FALSE; /* used to know if shutdown begins */ + + +/*------------------------------------------------------------------------- + * debug global variables + *-------------------------------------------------------------------------*/ +#if LOG_TEST IS_ENABLED +NINT LogTest = FALSE; +#endif + +#if FMAP_TEST IS_ENABLED +NINT FmapTest = FALSE; +NINT OneBlockExtents = FALSE; +#endif + +#if NSS_DEBUG IS_ENABLED +extern NINT DBG_NumberOfContextHandleAllocs; +extern NINT DBG_NumberOfContextHandleFrees; +extern NINT DBG_NumberOfSAgentHandleAllocs; +extern NINT DBG_NumberOfSAgentHandleFrees; +extern NINT DBG_NumberOfSearchMapAllocs; +extern NINT DBG_NumberOfSearchMapImplicitFrees; +extern NINT DBG_NumberOfSearchMapExplicitFrees; +#endif + +/************************************************************************** + * Setup the Number of WorkerThreads that are available. + ***************************************************************************/ +#ifndef __linux__ // LINUX_Startup +void CheckOSMinAndMaxProcesses(void) +{ + LONG oldValue, diff, newValue; + LONG result; + ASSERT_MPKNSS_LOCK(); + ZOS_GetSetableParameterValue(result,0, + MSGNot("Minimum Service Processes"), &oldValue); + if (result != 0) + { + goto doItTheNotCleanWay; + } + if (oldValue < (Config.os.workLimit + 20)) + { + if ((Config.os.workLimit + 20) < MAX_OS_MIN_SERVICE_PROCS) + { + newValue = Config.os.workLimit + 20; + } + else + { + newValue = MAX_OS_MIN_SERVICE_PROCS; + } + + ZOS_SetSetableParameterValue(result,0,MSGNot("Minimum Service Processes"), &newValue); + if (result != 0) + { + goto doItTheNotCleanWay; + } + diff = (newValue - oldValue) << 1; + ZOS_GetSetableParameterValue(result,0, + MSGNot("Maximum Service Processes"), &oldValue); + if (result != 0) + { + goto doItTheNotCleanWay; + } + if ((oldValue + diff) < MAX_OS_MAX_SERVICE_PROCS) + { + newValue = oldValue + diff; + } + else + { + newValue = MAX_OS_MAX_SERVICE_PROCS; + } + ZOS_SetSetableParameterValue(result,0,MSGNot("Maximum Service Processes"), &newValue); + if (result != 0) + { + goto doItTheNotCleanWay; + } + + } + return; + +doItTheNotCleanWay: + + if (*NW_MinimumNumberOfServerProcesses < (Config.os.workLimit + 20)) + { + oldValue = *NW_MinimumNumberOfServerProcesses; + if ((Config.os.workLimit + 20) < MAX_OS_MIN_SERVICE_PROCS) + { + newValue = Config.os.workLimit + 20; + } + else + { + newValue = MAX_OS_MIN_SERVICE_PROCS; + } + *NW_MinimumNumberOfServerProcesses = newValue; + diff = (newValue - oldValue) << 1; + if (((*NW_MaximumNumberOfServerProcesses) + diff) < + MAX_OS_MAX_SERVICE_PROCS) + { + newValue = (*NW_MaximumNumberOfServerProcesses) + diff; + } + else + { + newValue = MAX_OS_MAX_SERVICE_PROCS; + } + *NW_MaximumNumberOfServerProcesses = newValue; + } + return; +} +#endif + +/*--------------------------------------------------------------------------- + * GLOBAL VARIABLES: These are variables used to keep track of the current + * value of the NetWare "PurgeImmediateFlag" and "NW_MinimumFileDeleteWaitTime" + * which are controlled by the "Immediate Purge Of Deleted Files" and + * "Minimum File Delete Wait Time" Set parameters + *---------------------------------------------------------------------------*/ +BOOL NW_PurgeImmediateFlag = FALSE; +NINT NW_MinimumFileDeleteWaitTime = 0; +LONG NW_ClientFileCachingEnabledFlag = TRUE; +LONG NW_Level2OpLocksEnabledFlag = TRUE; + +//FixFixFix6 - Put this macro in an include file +#define TICK2SEC(_x) (((_x) * 10) / 182) + +#ifndef __linux__ // LINUX_Startup +LONG SetParamChangedEventID = 0; +LONG TimeZondChangedEventID = 0; + +/**************************************************************************** + * This function is called whenever a set parameter is changed + * The time zone change is called in a seperate function. It is done because + * during server starts up, although NSS registers event type + * EVENT_SET_PARAMETER_CHANGED, SetParameterChangedEventFunc won't be called + * when time zone is changed, which causes first time background compression + * doesn't start up at a proper time + *****************************************************************************/ +void SetParameterChangedEventFunc( + struct EventSetParameter *spEvent) +{ + BYTE PurgeImmediateFlagByte; + LONG MinimumFileDeleteWaitTime; + char DSTInfo[50]; + NINT offset; + LONG result; + + LONG numberVal, tickVal; + BYTE byteVal; + + MPKNSS_LOCK(); + /* + * Oplock set parameters + */ + if (strcmp(spEvent->setParameterName, + MSGNot("Client File Caching Enabled")) == 0) + { + ZOS_GetSetableParameterValue(result,0, MSGNot("Client File Caching Enabled"), + &numberVal); + if (result == 0) + { + NW_ClientFileCachingEnabledFlag = (numberVal != 0); + } + else + { + zASSERT("Error getting value of Set Parameter: Client File Caching Enabled."==NULL); + } + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Level 2 OpLocks Enabled")) == 0) + { + ZOS_GetSetableParameterValue(result,0, MSGNot("Level 2 OpLocks Enabled"), + &numberVal); + if (result == 0) + { + NW_Level2OpLocksEnabledFlag = (numberVal != 0); + } + else + { + zASSERT("Error getting value of Set Parameter: Level 2 OpLocks Enabled"==NULL); + } + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Immediate Purge Of Deleted Files")) == 0) + { + ZOS_GetSetableParameterValue(result,0, MSGNot("Immediate Purge Of Deleted Files"), + &PurgeImmediateFlagByte); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Immediate Purge Of Deleted Files."==NULL); + } + + if (PurgeImmediateFlagByte) + { + if (!NW_PurgeImmediateFlag) + { + /* Purge Immediate was turned off */ + VOL_PurgeImmediateFlagSet(); + NW_PurgeImmediateFlag = TRUE; + } + } + else + { + NW_PurgeImmediateFlag = FALSE; + } + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Minimum File Delete Wait Time")) == 0) + { + ZOS_GetSetableParameterValue(result,0, MSGNot("Minimum File Delete Wait Time"), + &MinimumFileDeleteWaitTime); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Minimum File Delete Wait Time."==NULL); + } + else + { + /* FixFixFix6 -- We need to fix this to work, but first we need to + * resolve how to keep nonpurgeableblocks and purgeableblocks + * counts accurate */ +// GeneralMsg_s genMsg; +// NW_MinimumFileDeleteWaitTime = TICK2SEC(MinimumFileDeleteWaitTime); +// +// COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); +// VOL_ChangeSalvageMinKeepSeconds(&genMsg, NW_MinimumFileDeleteWaitTime); + } + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Start Of Daylight Savings Time")) == 0) + { + ZOS_GetSetableParameterValue(result, 0, MSGNot("Start Of Daylight Savings Time"), + DSTInfo); + if (result != 0) + { + checkOrSetDSTConversionResults(0,-1,-1); + zASSERT("Error getting value of Set Parameter: Start Of Daylight Savings Time."==NULL); + } + else + { + getDSTChangeRules(DSTInfo, &DSTStartInfo); + checkOrSetDSTConversionResults(-1,-1,-1); + } + BEASTHASH_InvalidateDOSTimes(); + CM_bgCompressResetTimer(); + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("End Of Daylight Savings Time")) == 0) + { + ZOS_GetSetableParameterValue(result,0, MSGNot("End Of Daylight Savings Time"), + DSTInfo); + if (result != 0) + { + checkOrSetDSTConversionResults(-1,0,-1); + zASSERT("Error getting value of Set Parameter: End Of Daylight Savings Time."==NULL); + } + else + { + getDSTChangeRules(DSTInfo, &DSTStopInfo); + checkOrSetDSTConversionResults(-1,-1,-1); + } + BEASTHASH_InvalidateDOSTimes(); + CM_bgCompressResetTimer(); + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Daylight Savings Time Offset")) == 0) + { + ZOS_GetSetableParameterValue(result,0, MSGNot("Daylight Savings Time Offset"), + &offset); + if (result != 0) + { + checkOrSetDSTConversionResults(-1,-1,0); + zASSERT("Error getting value of Set Parameter: Daylight Savings Time Offset."==NULL); + } + else + { + checkOrSetDSTConversionResults(-1,-1,offset); + } + BEASTHASH_InvalidateDOSTimes(); + CM_bgCompressResetTimer(); + } +// else +// if (strcmp(spEvent->setParameterName, +// MSGNot("Time Zone")) == 0) +// { +// BEASTHASH_InvalidateDOSTimes(); +// CM_bgCompressResetTimer(); +// } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Compression Daily Check Stop Hour")) == 0) + { + ZOS_GetSetableParameterValue(result, 0, MSGNot("Compression Daily Check Stop Hour"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Compression Daily Check Stop Hour" == NULL); + } + SET_COMP_DAILY_CHECK_STOP_TIME(numberVal * 60 * 60, FALSE); + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Compression Daily Check Starting Hour")) == 0) + { + ZOS_GetSetableParameterValue(result, 0, MSGNot("Compression Daily Check Starting Hour"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Compression Daily Check Starting Hour" == NULL); + } + SET_COMP_DAILY_CHECK_START_TIME(numberVal * 60 * 60, FALSE); + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Minimum Compression Percentage Gain")) == 0) + { + ZOS_GetSetableParameterValue(result, 0, MSGNot("Minimum Compression Percentage Gain"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Minimum Compression Percentage Gain" == NULL); + } + SET_MIN_PERCENT_GAIN(numberVal); + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Enable File Compression")) == 0) + { + ZOS_GetSetableParameterValue(result, 0, MSGNot("Enable File Compression"), &byteVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Enable File Compression" == NULL); + } + SET_COMP_ENABLED_FLAG(byteVal); + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Maximum Concurrent Compressions")) == 0) + { + ZOS_GetSetableParameterValue(result, 0, MSGNot("Maximum Concurrent Compressions"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Maximum Concurrent Compressions" == NULL); + } + SET_MAX_CONCURRENT_COMPRESSIONS(numberVal); + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Convert Compressed To Uncompressed Option")) == 0) + { + ZOS_GetSetableParameterValue(result, 0, MSGNot("Convert Compressed To Uncompressed Option"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Convert Compressed To Uncompressed Option" == NULL); + } + SET_DECOMP_OPTION(numberVal); + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Decompress Percent Disk Space Free To Allow Commit")) == 0) + { + ZOS_GetSetableParameterValue(result, 0, MSGNot("Decompress Percent Disk Space Free To Allow Commit"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Decompress Percent Disk Space Free To Allow Commit" == NULL); + } + SET_MIN_FREE_SPACE_TO_DECOMPRESS(numberVal); + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Decompress Free Space Warning Interval")) == 0) + { + ZOS_GetSetableParameterValue(result, 0, MSGNot("Decompress Free Space Warning Interval"), &tickVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Decompress Free Space Warning Interval" == NULL); + } + SET_DECOMP_FREE_SPACE_WARN_INTERVAL(TICK2SEC(tickVal)); + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Deleted Files Compression Option")) == 0) + { + ZOS_GetSetableParameterValue(result, 0, MSGNot("Deleted Files Compression Option"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Deleted Files Compression Option" == NULL); + } + SET_COMPRESS_DELETED_FILES_OPTION(numberVal); + } + else + if (strcmp(spEvent->setParameterName, + MSGNot("Days Untouched Before Compression")) == 0) + { + ZOS_GetSetableParameterValue(result, 0, MSGNot("Days Untouched Before Compression"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Days Untouched Before Compression" == NULL); + } + SET_FILE_IDLE_TIME_FOR_COMP((QUAD)numberVal * 24 * 60 * 60); + } + MPKNSS_UNLOCK(); +} + +/**************************************************************************** + * This function is called whenever time zone is changed + *****************************************************************************/ +void TimeZoneChangedEventFunc( + struct EventSetParameter *spEvent) +{ + MPKNSS_LOCK(); + BEASTHASH_InvalidateDOSTimes(); + CM_bgCompressResetTimer(); + MPKNSS_UNLOCK(); +} + +/************************************************************************** + * Get the state of the "Immediage Purge Of Deleted Files" Set parameter + ***************************************************************************/ +STATUS SetParameterStartup( + struct GeneralMsg_s *genMsg) +{ + BYTE PurgeImmediateFlagByte; + LONG MinimumFileDeleteWaitTime; + char DSTInfo[50]; + NINT offset; + LONG result; + LONG numberVal, tickVal; + BYTE byteVal; + + ASSERT_MPKNSS_LOCK(); + /* + * Oplock set parameters + */ + ZOS_GetSetableParameterValue(result,0, MSGNot("Client File Caching Enabled"), + &numberVal); + if (result == 0) + { + NW_ClientFileCachingEnabledFlag = (numberVal != 0); + } + + ZOS_GetSetableParameterValue(result,0, MSGNot("Level 2 OpLocks Enabled"), + &numberVal); + if (result == 0) + { + NW_Level2OpLocksEnabledFlag = (numberVal != 0); + } + + /* + * Salvage set parameters + */ + ZOS_GetSetableParameterValue(result,0, MSGNot("Immediate Purge Of Deleted Files"), + &PurgeImmediateFlagByte); + if (result != 0) + { + errPrintf(WHERE, Module, 662, + MSG("Error getting value of Set Parameter: Immediate Purge " + "Of Deleted Files.", 871)); + return(zFAILURE); + } + + NW_PurgeImmediateFlag = PurgeImmediateFlagByte; + + ZOS_GetSetableParameterValue(result,0, MSGNot("Minimum File Delete Wait Time"), + &MinimumFileDeleteWaitTime); + if (result != 0) + { + errPrintf(WHERE, Module, 664, + MSG("Error getting value of Set Parameter: " + "Minimum File Delete Wait Time.", 872)); + } + else + { + /* FixFixFix6 -- We need to fix this to work, but first we need to + * resolve how to keep nonpurgeableblocks and purgeableblocks + * counts accurate */ +// NW_MinimumFileDeleteWaitTime = TICK2SEC(MinimumFileDeleteWaitTime); + NW_MinimumFileDeleteWaitTime = 0; //FixFixFix6 + VOL_ChangeSalvageMinKeepSeconds(genMsg, NW_MinimumFileDeleteWaitTime); + } + + ZOS_GetSetableParameterValue(result,0, MSGNot("Start Of Daylight Savings Time"), + DSTInfo); + if (result != 0) + { + /* Mark FALSE in DSTStartInfo.isOK field */ + checkOrSetDSTConversionResults(0,-1,-1); + } + else + { + getDSTChangeRules(DSTInfo, &DSTStartInfo); + } + + ZOS_GetSetableParameterValue(result,0, MSGNot("End Of Daylight Savings Time"), + DSTInfo); + if (result != 0) + { + checkOrSetDSTConversionResults(-1,0,-1); + } + else + { + getDSTChangeRules(DSTInfo, &DSTStopInfo); + } + + ZOS_GetSetableParameterValue(result,0, MSGNot("Daylight Savings Time Offset"), + &offset); + if (result != 0) + { + checkOrSetDSTConversionResults(-1,-1,0); + } + else + { + checkOrSetDSTConversionResults(-1,-1,offset); + } + + ZOS_GetSetableParameterValue(result, 0, MSGNot("Compression Daily Check Stop Hour"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Compression Daily Check Stop Hour" == NULL); + } + SET_COMP_DAILY_CHECK_STOP_TIME(numberVal * 60 * 60, TRUE); + + ZOS_GetSetableParameterValue(result, 0, MSGNot("Compression Daily Check Starting Hour"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Compression Daily Check Starting Hour" == NULL); + } + SET_COMP_DAILY_CHECK_START_TIME(numberVal * 60 * 60, TRUE); + + ZOS_GetSetableParameterValue(result, 0, MSGNot("Minimum Compression Percentage Gain"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Minimum Compression Percentage Gain" == NULL); + } + SET_MIN_PERCENT_GAIN(numberVal); + + ZOS_GetSetableParameterValue(result, 0, MSGNot("Enable File Compression"), &byteVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Enable File Compression" == NULL); + } + CM_curCompControlParams.compEnabled = byteVal ? TRUE : FALSE; + + ZOS_GetSetableParameterValue(result, 0, MSGNot("Maximum Concurrent Compressions"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Maximum Concurrent Compressions" == NULL); + } + SET_MAX_CONCURRENT_COMPRESSIONS(numberVal); + + ZOS_GetSetableParameterValue(result, 0, MSGNot("Convert Compressed To Uncompressed Option"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Convert Compressed To Uncompressed Option" == NULL); + } + SET_DECOMP_OPTION(numberVal); + + ZOS_GetSetableParameterValue(result, 0, MSGNot("Decompress Percent Disk Space Free To Allow Commit"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Decompress Percent Disk Space Free To Allow Commit" == NULL); + } + SET_MIN_FREE_SPACE_TO_DECOMPRESS(numberVal); + + ZOS_GetSetableParameterValue(result, 0, MSGNot("Decompress Free Space Warning Interval"), &tickVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Decompress Free Space Warning Interval" == NULL); + } + SET_DECOMP_FREE_SPACE_WARN_INTERVAL(TICK2SEC(tickVal)); + + ZOS_GetSetableParameterValue(result, 0, MSGNot("Deleted Files Compression Option"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Deleted Files Compression Option" == NULL); + } + SET_COMPRESS_DELETED_FILES_OPTION(numberVal); + + ZOS_GetSetableParameterValue(result, 0, MSGNot("Days Untouched Before Compression"), &numberVal); + if (result != 0) + { + zASSERT("Error getting value of Set Parameter: Days Untouched Before Compression" == NULL); + } + SET_FILE_IDLE_TIME_FOR_COMP((QUAD)numberVal * 24 * 60 * 60); + + /* Register to get notified whenever any set parameter value is changed */ + ZOS_EventNotificationReg(SetParamChangedEventID, + EVENT_SET_PARAMETER_CHANGED, + NULL, SetParameterChangedEventFunc); + if(SetParamChangedEventID == NULL) + { + errPrintf(WHERE, Module, 663, + MSG("Error registering for event EVENT_SET_PARAMETER_CHANGED.", 873)); + return(zFAILURE); + } + + ZOS_EventNotificationReg(TimeZondChangedEventID, + EVENT_TIMEZONE_CHANGED, + NULL, TimeZoneChangedEventFunc); + if (TimeZondChangedEventID == NULL) + { + errPrintf(WHERE, Module, 663, + MSG("Error registering for event EVENT_TIMEZONE_CHANGED.", 637)); + SetParameterShutdown(); + return(zFAILURE); + } + + return zOK; +} + +/**************************************************************************** + * Shutdown the setparameter stuff + *****************************************************************************/ +void SetParameterShutdown(void) +{ + /* Unregister to get notified whenever any set parameter value is changed */ + ASSERT_MPKNSS_LOCK(); + + if (TimeZondChangedEventID) + { + ZOS_EventNotificationUnReg(TimeZondChangedEventID); + TimeZondChangedEventID = NULL; + } + + if (SetParamChangedEventID) + { + ZOS_EventNotificationUnReg(SetParamChangedEventID); + SetParamChangedEventID = NULL; + } +} +#endif + +/**************************************************************************** + * Import any functions that were loaded during startup + *****************************************************************************/ +void LoadFunctions(void) +{ + if (BEASTHASH_InvalidateDOSTimesPtr == NULL) + { + BEASTHASH_InvalidateDOSTimesPtr = BEASTHASH_InvalidateDOSTimes; + } +} + +/**************************************************************************** + * Import any functions that were loaded during startup + *****************************************************************************/ +void UnloadFunctions(void) +{ + BEASTHASH_InvalidateDOSTimesPtr = NULL; +} + +#if zLINUX +typedef struct RegFunc_t +{ + char *name; + statusfunc_t addr; +}RegFunc_t; + +RegFunc_t regFunctions[] = +{ + {MSGNot("zCreate"), &zCreate}, + {MSGNot("zDelete"), &zDelete}, + {MSGNot("zRootKey"), &zRootKey}, + {MSGNot("zClose"), &zClose}, + {MSGNot("zGetInfo"), &zGetInfo}, + {MSGNot("zOpen"), &zOpen}, + {MSGNot("zRead"), &zRead}, + {MSGNot("zWrite"), &zWrite}, + {MSGNot("MGMTS_MakeFunctionVirtualFile"), &MGMTS_MakeFunctionVirtualFile}, + {MSGNot("VIRT_AddResultData"), &VIRT_AddResultData}, + {MSGNot("VIRT_AddResultElement"), &VIRT_AddResultElement}, + {MSGNot("VIRT_AddResultTag"), &VIRT_AddResultTag}, + {0} +}; + +/**************************************************************************** + * Register functions that need to be dynamically imported somewhere else + *****************************************************************************/ +void CMN_RegisterDynamicSymbols(void) +{ + NINT i; + + MPKNSS_UNLOCK(); + for (i = 0; regFunctions[i].name != NULL; i++) + { +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) + inter_module_register(regFunctions[i].name, THIS_MODULE, regFunctions[i].addr); +#else + nss_register_module(regFunctions[i].name, regFunctions[i].addr, THIS_MODULE); +#endif + } + MPKNSS_LOCK(); + +} + +/**************************************************************************** + * Register functions that need to be dynamically imported somewhere else + *****************************************************************************/ +void CMN_UnregisterDynamicSymbols(void) +{ + NINT i; + + MPKNSS_UNLOCK(); + for (i = 0; regFunctions[i].name != NULL; i++) + { +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) + inter_module_unregister(regFunctions[i].name); +#else + nss_unregister_module(regFunctions[i].name); +#endif + } + MPKNSS_LOCK(); + +} +#endif + +/************************************************************************** + * This is the actuall NSS global startup routine. This is called as an + * event. + ***************************************************************************/ +STATUS CMN_GlobalStartup(void) +{ + GeneralMsg_s genMsg; + STATUS status; + +#ifndef __linux__ // LINUX_Startup + LONG languageID; // added 08/10/98 by sks + char cmn_CommandLine[128]; // added 08/10/98 by sks +#endif + + ASSERT_MPKNSS_LOCK(); + +#if zLINUX + CMN_RegisterDynamicSymbols(); +#endif +/*------------------------------------------------------------------------- + * Now start initing the different systems. + *-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_Startup + // 08/10/98: Added by sksmith + ZOS_ReturnOSLanguageID(languageID); + + if (languageID != 4) + { + /* test code only languageID = 9;*/ + + sprintf(cmn_CommandLine, "MALHLP%d", languageID); + } + else + { sprintf(cmn_CommandLine, "MALHLP"); + } + + ZOS_LoadModule(status, CMN_DefaultScreen, cmn_CommandLine, LO_NORMAL); + + if (status != 0 && status != LOAD_CAN_NOT_LOAD_MULTIPLE_COPIES) + { + aprintf(LRED," Load of %s failed, status=%d. Attempting to load MALHLP.\n", + cmn_CommandLine, status); + ZOS_LoadModule(status, CMN_DefaultScreen, "MALHLP", LO_NORMAL); + + if (status != 0 && status != LOAD_CAN_NOT_LOAD_MULTIPLE_COPIES) + { + aprintf(LRED," Load of %s failed, status=%d.\n", "MALHLP", status); + } + } + // END OF ... 08/10/98: Added by sksmith +#endif //__linux__ // LINUX_Startup + + COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE(&genMsg); + + configStartup(); + if ((status = DIRQ_Startup()) != zOK) + goto DIRQ_Failed; + + if ((status = CACHE_Startup()) != zOK) + goto CACHE_Failed; + + if ((status = HMC_Startup()) != zOK) + { + goto HMC_Failed; + } + + if (MGR_Startup() != zOK) + goto MGR_Failed; + + if (LOCK_Startup() != zOK) + goto LOCK_Failed; + + if (NAME_CacheInit() != zOK) + goto NAME_Failed; + + if (VIRT_Startup(&genMsg) != zOK) + goto VIRT_Failed; + + if (BEAST_Startup(&genMsg) != zOK) + goto BEAST_Failed; + + if (AUTHSYS_Startup(&genMsg) != zOK) + goto AUTHORIZE_Failed; + + if (COMN_Startup(&genMsg) != zOK) + goto CMN_Failed; + + if (MARSHAL_Startup( &genMsg) != zOK) + goto MARSHAL_Failed; + + LoadFunctions(); + + /* Init CM_control so that compression settings could be put in */ + if (CM_controlInit() != zOK) + goto CM_InitFailed; + +#ifndef __linux__ // LINUX_SetParms + if (SetParameterStartup(&genMsg) != zOK) + goto SETP_Failed; +#endif + + /* + * There are several server parameters affect compression control settings. + * Let it start up after the set parameters is done. + */ + if (CM_startup() != zOK) + goto CM_StartupFailed; + +/*--------------------------------------------------------------------------- + * Everything is setup, after this point pools and volumes can start appearing + *---------------------------------------------------------------------------*/ + + RegisterNSSEventProducers(); + if (POOL_Startup(&genMsg) != zOK) + { + goto POOL_Failed; + } + if (VOLUME_Startup(&genMsg) != zOK) + goto VOLUME_Failed; + + REPAIR_Startup(); // dosen't matter if failes??? + + UXACTION_Startup(); /* doesn't matter if it fails */ + +#ifndef __linux__ // LINUX_Startup + CheckOSMinAndMaxProcesses(); +#endif + +/*--------------------------------------------------------------------------- + * Everything is setup except mgmt files. If this flag is set, that means + * mgmt files can safely use all comn operations. + *---------------------------------------------------------------------------*/ + CMN_StartupCompleted = TRUE; + + /* This will create MGMTFILES directory to put statistics files under it */ + if (MGMTFILES_Startup(&genMsg) != zOK) + { + errPrintf(WHERE, Module, 692, + MSG("Error %d during startup of management files..." + "continuing system startup.", 836), GetErrno(&genMsg)); + } + + CHK_StartProcess(); /* Start up the background checker */ + +#if zLINUX + SEQ_StartProcess(); /* Start up the security equivalence updater */ +#endif + + EFL_Init(); /* Start up EFL epoch checker */ + + return zOK; + + +/*========================================================================= + * Error handling + *=========================================================================*/ +//MGMTFILES_Failed: +// VOLUME_Shutdown(FALSE); + +VOLUME_Failed: + POOL_Shutdown(FALSE); + +POOL_Failed: + UnregisterNSSEventProducers(); + + CM_shutdown(TRUE, TRUE); + +CM_StartupFailed: +#ifndef __linux__ // LINUX_SetParms + SetParameterShutdown(); + +SETP_Failed: +#endif + CM_controlUninit(); + +CM_InitFailed: + UnloadFunctions(); + + MARSHAL_Shutdown(); + +MARSHAL_Failed: + COMN_Shutdown(); + +CMN_Failed: + AUTHSYS_Shutdown(); + +AUTHORIZE_Failed: + BEAST_Shutdown(); + +BEAST_Failed: + VIRT_Shutdown(); + +VIRT_Failed: + NAME_CacheUninit(); + +NAME_Failed: + LOCK_Shutdown(); + +LOCK_Failed: + MGR_Shutdown(); + +MGR_Failed: + HMC_Shutdown(); + +HMC_Failed: + CACHE_Shutdown(); + +CACHE_Failed: + DIRQ_Shutdown(); + +DIRQ_Failed: + CHK_StopProcess(); /* Stop the background checker - can be called even + * if it was not started */ + return zFAILURE; +} + + +/*- (FUNCTION) ----- PSSGlobal_Shutdown() ------------------------------- + | + | uninitialize all global data and return all resources + | + +-------------------------------------------------------------------------*/ +void CMN_GlobalShutdown(void) +{ + + ASSERT_MPKNSS_LOCK(); + if (CMN_StartupCompleted) + { + CMN_Shutdown = TRUE; /* flag not inited */ +// NSSMenuExit(); + EFL_Uninit(); /* stop EFL epoch checker */ + CHK_StopProcess(); /* Stop the background checker - can be called even + * if it was not started */ + UXACTION_Shutdown(); /* doesn't matter if it fails */ + MGMTFILES_Shutdown(); + REPAIR_Shutdown(); // Greg moved here - It calls common layer! + +#ifndef __linux__ // LINUX_SetParms + SetParameterShutdown(); +#endif + MARSHAL_Shutdown(); + COMN_Shutdown(); + VOLUME_Shutdown(TRUE); + POOL_Shutdown(TRUE); + CM_shutdown(TRUE, TRUE); + AUTHSYS_Shutdown(); + BEAST_Shutdown(); + VIRT_Shutdown(); + NAME_CacheUninit(); + G2I_CacheUninit(); + I2G_CacheUninit(); + SE_CacheUninit(); + LOCK_Shutdown(); + MGR_Shutdown(); + HMC_Shutdown(); + CACHE_Shutdown(); + DIRQ_Shutdown(); +// MAL_Shutdown(); +// REPAIR_Shutdown(); + UnregisterNSSEventProducers(); +#if zLINUX + CMN_UnregisterDynamicSymbols(); +#endif + +#if NSS_DEBUG IS_ENABLED + zASSERT(DBG_NumberOfContextHandleAllocs == DBG_NumberOfContextHandleFrees); + zASSERT(DBG_NumberOfSAgentHandleAllocs == DBG_NumberOfSAgentHandleFrees); + zASSERT(DBG_NumberOfSearchMapAllocs == + (DBG_NumberOfSearchMapImplicitFrees + DBG_NumberOfSearchMapExplicitFrees)); +#endif + CMN_StartupCompleted = FALSE; /* flag not inited */ + } +} + + +/************************************************************************** + * This is called when DOWNSERVER is called, so deactivate all the volumes. + ***************************************************************************/ +void CMN_ServerDown(void) +{ + MPKNSS_LOCK(); + VOLUME_Shutdown(TRUE); + POOL_Shutdown(TRUE); + MPKNSS_UNLOCK(); +} + + +#ifndef __linux__ // LINUX_Startup +/************************************************************************** + * Display version Information + ***************************************************************************/ +NINT CMN_DisplayVersion(void) +{ + DISPLAY_DEFAULT_VERSION_INFORMATION(NULL); + return zOK; +} +#endif diff --git a/src/nwnss/comn/main/qdiv.c b/src/nwnss/comn/main/qdiv.c new file mode 100644 index 0000000..dad1a90 --- /dev/null +++ b/src/nwnss/comn/main/qdiv.c @@ -0,0 +1,412 @@ +/**************************************************************************** + | + |*************************************************************************** + | + | Novell Storage Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $ + | + | $RCSfile$ + | $Revision: 1325 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Implement the quad division functions + +-------------------------------------------------------------------------*/ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Multiprecision divide. This algorithm is from Knuth vol. 2 (2nd ed), + * section 4.3.1, pp. 257--259. + */ + +#include +//#include +//#include +//#include +//#include + +/* + * Depending on the desired operation, we view a `long long' (aka SQUAD) in + * one or more of the following formats. + */ +union uu { + SQUAD q; /* as a (signed) quad */ + SQUAD uq; /* as an unsigned quad */ + SLONG sl[2]; /* as two signed longs */ + LONG ul[2]; /* as two unsigned longs */ +}; + +/* + * Define high and low longwords. + */ + +#define H 1 +#define L 0 + +/* + * Total number of bits in a SQUAD and in the pieces that make it up. + * These are used for shifting, and also below for halfword extraction + * and assembly. + */ +#define CHAR_BIT 8 +#define QUAD_BITS (sizeof(SQUAD) * CHAR_BIT) +#define LONG_BITS (sizeof(SLONG) * CHAR_BIT) +#define HALF_BITS (sizeof(SLONG) * CHAR_BIT / 2) + +/* + * Extract high and low shortwords from longword, and move low shortword of + * longword to upper half of long, i.e., produce the upper longword of + * ((SQUAD)(x) << (number_of_bits_in_long/2)). (`x' must actually be LONG.) + * + * These are used in the multiply code, to split a longword into upper + * and lower halves, and to reassemble a product as a SQUAD, shifted left + * (sizeof(long)*CHAR_BIT/2). + */ +#define HHALF(x) ((x) >> HALF_BITS) +#define LHALF(x) ((x) & ((1 << HALF_BITS) - 1)) +#define LHUP(x) ((x) << HALF_BITS) + + typedef unsigned int qshift_t; + + + +#define B (1 << HALF_BITS) /* digit base */ + +/* Combine two `digits' to make a single two-digit number. */ +#define COMBINE(_a, _b) (((LONG)(_a) << HALF_BITS) | (_b)) + +/* select a type for digits in base B: use unsigned short if they fit */ +//Brenda +//#if ULONG_MAX == 0xffffffff && USHRT_MAX >= 0xffff +//typedef unsigned short digit; +//#else +typedef LONG digit; +//#endif + +/* + * Shift p[0]..p[len] left `sh' bits, ignoring any bits that + * `fall out' the left (there never will be any such anyway). + * We may assume len >= 0. NOTE THAT THIS WRITES len+1 DIGITS. + */ +static void shl( + register digit *p, + register int len, + register int sh) +{ + register int i; + + for (i = 0; i < len; i++) + p[i] = LHALF(p[i] << sh) | (p[i + 1] >> (HALF_BITS - sh)); + p[i] = LHALF(p[i] << sh); +} + +/* + * __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v. + * + * We do this in base 2-sup-HALF_BITS, so that all intermediate products + * fit within LONG. As a consequence, the maximum length dividend and + * divisor are 4 `digits' in this base (they are shorter if they have + * leading zeros). + */ +QUAD __qdivrem( + QUAD uq, + QUAD vq, + QUAD *arq) +{ + union uu tmp; + digit *u, *v, *q; + register digit v1, v2; + LONG qhat, rhat, t; + int m, n, d, j, i; + digit uspace[5], vspace[5], qspace[5]; + +/* + * Take care of special cases: divide by zero, and u < v. + */ + if (vq == 0) { + /* divide by zero. */ + static volatile const unsigned int zero = 0; + + tmp.ul[H] = tmp.ul[L] = 1 / zero; + if (arq) + *arq = uq; + return (tmp.q); + } + if (uq < vq) { + if (arq) + *arq = uq; + return (0); + } + u = &uspace[0]; + v = &vspace[0]; + q = &qspace[0]; + +/* + * Break dividend and divisor into digits in base B, then + * count leading zeros to determine m and n. When done, we + * will have: + * u = (u[1]u[2]...u[m+n]) sub B + * v = (v[1]v[2]...v[n]) sub B + * v[1] != 0 + * 1 < n <= 4 (if n = 1, we use a different division algorithm) + * m >= 0 (otherwise u < v, which we already checked) + * m + n = 4 + * and thus + * m = 4 - n <= 2 + */ + tmp.uq = uq; + u[0] = 0; + u[1] = HHALF(tmp.ul[H]); + u[2] = LHALF(tmp.ul[H]); + u[3] = HHALF(tmp.ul[L]); + u[4] = LHALF(tmp.ul[L]); + tmp.uq = vq; + v[1] = HHALF(tmp.ul[H]); + v[2] = LHALF(tmp.ul[H]); + v[3] = HHALF(tmp.ul[L]); + v[4] = LHALF(tmp.ul[L]); + for (n = 4; v[1] == 0; v++) { + if (--n == 1) { + LONG rbj; /* r*B+u[j] (not root boy jim) */ + digit q1, q2, q3, q4; + +/* + * Change of plan, per exercise 16. + * r = 0; + * for j = 1..4: + * q[j] = floor((r*B + u[j]) / v), + * r = (r*B + u[j]) % v; + * We unroll this completely here. + */ + t = v[2]; /* nonzero, by definition */ + q1 = u[1] / t; + rbj = COMBINE(u[1] % t, u[2]); + q2 = rbj / t; + rbj = COMBINE(rbj % t, u[3]); + q3 = rbj / t; + rbj = COMBINE(rbj % t, u[4]); + q4 = rbj / t; + if (arq) + *arq = rbj % t; + tmp.ul[H] = COMBINE(q1, q2); + tmp.ul[L] = COMBINE(q3, q4); + return (tmp.q); + } + } + +/* + * By adjusting q once we determine m, we can guarantee that + * there is a complete four-digit quotient at &qspace[1] when + * we finally stop. + */ + for (m = 4 - n; u[1] == 0; u++) + m--; + for (i = 4 - m; --i >= 0;) + q[i] = 0; + q += 4 - m; + +/* + * Here we run Program D, translated from MIX to C and acquiring + * a few minor changes. + * + * * D1: choose multiplier 1 << d to ensure v[1] >= B/2. + */ + d = 0; + for (t = v[1]; t < B / 2; t <<= 1) + d++; + if (d > 0) { + shl(&u[0], m + n, d); /* u <<= d */ + shl(&v[1], n - 1, d); /* v <<= d */ + } +/* + * D2: j = 0. + */ + j = 0; + v1 = v[1]; /* for D3 -- note that v[1..n] are constant */ + v2 = v[2]; /* for D3 */ + do { + register digit uj0, uj1, uj2; + +/* + * D3: Calculate qhat (\^q, in TeX notation). + * Let qhat = min((u[j]*B + u[j+1])/v[1], B-1), and + * let rhat = (u[j]*B + u[j+1]) mod v[1]. + * While rhat < B and v[2]*qhat > rhat*B+u[j+2], + * decrement qhat and increase rhat correspondingly. + * Note that if rhat >= B, v[2]*qhat < rhat*B. + */ + uj0 = u[j + 0]; /* for D3 only -- note that u[j+...] change */ + uj1 = u[j + 1]; /* for D3 only */ + uj2 = u[j + 2]; /* for D3 only */ + if (uj0 == v1) { + qhat = B; + rhat = uj1; + goto qhat_too_big; + } else { + LONG nn = COMBINE(uj0, uj1); + qhat = nn / v1; + rhat = nn % v1; + } + while (v2 * qhat > COMBINE(rhat, uj2)) { +qhat_too_big: + qhat--; + if ((rhat += v1) >= B) + break; + } +/* + * D4: Multiply and subtract. + * The variable `t' holds any borrows across the loop. + * We split this up so that we do not require v[0] = 0, + * and to eliminate a final special case. + */ + for (t = 0, i = n; i > 0; i--) { + t = u[i + j] - v[i] * qhat - t; + u[i + j] = LHALF(t); + t = (B - HHALF(t)) & (B - 1); + } + t = u[j] - t; + u[j] = LHALF(t); +/* + * D5: test remainder. + * There is a borrow if and only if HHALF(t) is nonzero; + * in that (rare) case, qhat was too large (by exactly 1). + * Fix it by adding v[1..n] to u[j..j+n]. + */ + if (HHALF(t)) { + qhat--; + for (t = 0, i = n; i > 0; i--) { /* D6: add back. */ + t += u[i + j] + v[i]; + u[i + j] = LHALF(t); + t = HHALF(t); + } + u[j] = LHALF(u[j] + t); + } + q[j] = qhat; + } while (++j <= m); /* D7: loop on j. */ + +/* + * If caller wants the remainder, we have to calculate it as + * u[m..m+n] >> d (this is at most n digits and thus fits in + * u[m+1..m+n], but we may need more source digits). + */ + if (arq) { + if (d) { + for (i = m + n; i > m; --i) + u[i] = (u[i] >> d) | LHALF(u[i - 1] << (HALF_BITS - d)); + u[i] = 0; + } + tmp.ul[H] = COMBINE(uspace[1], uspace[2]); + tmp.ul[L] = COMBINE(uspace[3], uspace[4]); + *arq = tmp.q; + } + + tmp.ul[H] = COMBINE(qspace[1], qspace[2]); + tmp.ul[L] = COMBINE(qspace[3], qspace[4]); + return (tmp.q); +} + +/* + * Return remainder after dividing two unsigned quads. + */ +QUAD __umoddi3( + QUAD a, + QUAD b) +{ + QUAD r; + + (void)__qdivrem(a, b, &r); + return (r); +} + +/* + * Divide two unsigned quads. + */ +QUAD __udivdi3( + QUAD a, + QUAD b) +{ + return (__qdivrem(a, b, (QUAD *)0)); +} + +/* + * Return remainder after dividing two signed quads. + * + * If -1/2 should produce -1 on this machine, this code is wrong. + */ +SQUAD __moddi3( + QUAD a, + QUAD b) +{ + QUAD ua, ub, ur; + int neg; + + if (a < 0) + ua = -(QUAD)a, neg = 1; + else + ua = a, neg = 0; + if (b < 0) + ub = -(QUAD)b; + else + ub = b; + (void)__qdivrem(ua, ub, &ur); + return (neg ? -ur : ur); +} + +/* + * Divide two signed quads./* + * if -1/2 should produce -1 on this machine, this code is wrong/* + */ +SQUAD __divdi3( + QUAD a, + QUAD b) +{ + QUAD ua, ub, uq; + int neg; + + if (a < 0) + ua = -(QUAD)a, neg = 1; + else + ua = a, neg = 0; + if (b < 0) + ub = -(QUAD)b, neg ^= 1; + else + ub = b; + uq = __qdivrem(ua, ub, (QUAD *)0); + return (neg ? -uq : uq); +} diff --git a/src/nwnss/comn/main/unssCOMNSym.c b/src/nwnss/comn/main/unssCOMNSym.c new file mode 100644 index 0000000..0c06deb --- /dev/null +++ b/src/nwnss/comn/main/unssCOMNSym.c @@ -0,0 +1,43 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export COMN symbols to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB + +#include + +#include + +EXPORT_SYMBOL(OpLockVerbose); diff --git a/src/nwnss/comn/main/xlssSym.c b/src/nwnss/comn/main/xlssSym.c new file mode 100644 index 0000000..16bb7e3 --- /dev/null +++ b/src/nwnss/comn/main/xlssSym.c @@ -0,0 +1,45 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export xlss symbols to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB + +#include + +#include +#include + + +EXPORT_SYMBOL(XLSSArrayIndex); diff --git a/src/nwnss/comn/main/zPoolSym.c b/src/nwnss/comn/main/zPoolSym.c new file mode 100644 index 0000000..9e48a1a --- /dev/null +++ b/src/nwnss/comn/main/zPoolSym.c @@ -0,0 +1,50 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export zPool symbols to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB + +#include + +#include +#include + + +EXPORT_SYMBOL(zPoolFreeze); +EXPORT_SYMBOL(zPoolOwnershipGet); +EXPORT_SYMBOL(zPoolOwnershipRelease); +EXPORT_SYMBOL(zPoolThaw); +EXPORT_SYMBOL(zPoolThawByName); +EXPORT_SYMBOL(zPoolThawRequired); diff --git a/src/nwnss/comn/main/zPublicsSym.c b/src/nwnss/comn/main/zPublicsSym.c new file mode 100644 index 0000000..63d86d0 --- /dev/null +++ b/src/nwnss/comn/main/zPublicsSym.c @@ -0,0 +1,114 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2006-10-31 02:59:05 +0530 (Tue, 31 Oct 2006) $ + | + | $RCSfile$ + | $Revision: 1585 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export zPublics symbles to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB + +#include + +#include +#include + +#include +#include +#include +#include + + +EXPORT_SYMBOL(xDOS2utcTime); +EXPORT_SYMBOL(xForceVolumeUpgrade); +//EXPORT_SYMBOL(xGuidToId); +//EXPORT_SYMBOL(xIdToGuid); +EXPORT_SYMBOL(xIsVolumeUpgraded); +EXPORT_SYMBOL(xMangleConnection); +EXPORT_SYMBOL(xPoolGetEnabledFeatures); +EXPORT_SYMBOL(xPoolGUIDToName); +EXPORT_SYMBOL(xPoolNameToGUID); +EXPORT_SYMBOL(xSharedOpLock); +EXPORT_SYMBOL(xUTC2dosTime); +EXPORT_SYMBOL(xVolumeGUIDToName); +EXPORT_SYMBOL(xVolumeNameToGUID); +EXPORT_SYMBOL(zAbortXaction); +EXPORT_SYMBOL(zAddTrustee); +EXPORT_SYMBOL(zBeginTask); +EXPORT_SYMBOL(zBeginXaction); +EXPORT_SYMBOL(zBrowseUsers); +EXPORT_SYMBOL(zChangeConnection); +EXPORT_SYMBOL(zClose); +EXPORT_SYMBOL(zCommitXaction); +EXPORT_SYMBOL(zCreate); +EXPORT_SYMBOL(zDelete); +EXPORT_SYMBOL(zDeleteTrustee); +EXPORT_SYMBOL(zDIORead); +EXPORT_SYMBOL(zDIOWrite); +EXPORT_SYMBOL(zEndTask); +EXPORT_SYMBOL(zEnumerate); +EXPORT_SYMBOL(zFlush); +EXPORT_SYMBOL(zGetEffectiveRights); +EXPORT_SYMBOL(zGetFileMap); +EXPORT_SYMBOL(zGetInfo); +EXPORT_SYMBOL(zGetInfoByName); +EXPORT_SYMBOL(zGetInheritedRightsMask); +EXPORT_SYMBOL(zGetNSSVolumeLabel); +EXPORT_SYMBOL(zGetTrustee); +EXPORT_SYMBOL(zInfoGetFileName); +EXPORT_SYMBOL(zIsNSSVolume); +EXPORT_SYMBOL(zLink); +EXPORT_SYMBOL(zLockByteRange); +EXPORT_SYMBOL(zModifyInfo); +EXPORT_SYMBOL(zModifyInfoByName); +EXPORT_SYMBOL(zOpen); +EXPORT_SYMBOL(zOpenByZid); +EXPORT_SYMBOL(zRead); +EXPORT_SYMBOL(zReadPageChunks); +EXPORT_SYMBOL(zReleasePageChunks); +EXPORT_SYMBOL(zRename); +EXPORT_SYMBOL(zRootKey); +EXPORT_SYMBOL(zSetEOF); +EXPORT_SYMBOL(zSetInheritedRightsMask); +EXPORT_SYMBOL(zSetNSSVolumeLabel); +EXPORT_SYMBOL(zUnlockByteRange); +EXPORT_SYMBOL(zWildRead); +EXPORT_SYMBOL(zWildRewind); +EXPORT_SYMBOL(zWrite); +EXPORT_SYMBOL(zSetDataSize); +EXPORT_SYMBOL(zRegisterDemigrateFunction); +EXPORT_SYMBOL(zUnregisterDemigrateFunction); +EXPORT_SYMBOL(zZIDCreate); +EXPORT_SYMBOL(zZIDDelete); +EXPORT_SYMBOL(zZIDLink); +EXPORT_SYMBOL(zZIDOpen); +EXPORT_SYMBOL(zZIDRename); +EXPORT_SYMBOL(xGetMyZid); diff --git a/include/nwnss/comn/nameScan.h b/src/nwnss/comn/nameScan.h similarity index 99% rename from include/nwnss/comn/nameScan.h rename to src/nwnss/comn/nameScan.h index a5ff7b5..79346e6 100644 --- a/include/nwnss/comn/nameScan.h +++ b/src/nwnss/comn/nameScan.h @@ -33,7 +33,7 @@ |--------------------------------------------------------------------------- | This module is used to: | This defines the interfaces into the PSS portion of the connection - | structure. + | structure. +-------------------------------------------------------------------------*/ #ifndef _NAMESCAN_H_ #define _NAMESCAN_H_ diff --git a/src/nwnss/comn/namespace/dataStreamNSpace.c b/src/nwnss/comn/namespace/dataStreamNSpace.c index 41ab24b..fb49c82 100644 --- a/src/nwnss/comn/namespace/dataStreamNSpace.c +++ b/src/nwnss/comn/namespace/dataStreamNSpace.c @@ -58,7 +58,7 @@ STATIC BYTE DSNS_ValidCharBitMap[32]; /**************************************************************************** * STATIC initialization of a nsOps table for the Data Stream Namespace *****************************************************************************/ -STATIC NameSpaceOps_s dataStreamNsOps = +STATIC NameSpaceOps_s dataStreamNsOps = { DSNS_asciiScanNextComponent, DSNS_asciiLenScanNextComponent, @@ -93,8 +93,8 @@ STATUS DSNS_Startup( ns = COMN_RegisterNameSpace(genMsg,NAMESPACE_VERSION, zNSPACE_DATA_STREAM, - (1< 0) && ((status = LB_UTF8LenToUniChar(srcPtr, srcLength, &srcPtr, &ch, - &srcLength)) == zOK)) + &srcLength)) == zOK)) { switch (ch) { @@ -887,16 +887,16 @@ STATIC STATUS DSNS_utf8LenScanNextComponent( { goto error_InvalidUtf8Char; } - /* Augmented periods are only significant if followed by - * a wildcard character. Otherwise, just convert them - * to non-augmented... - * On the other hand, if a UNI_PERIOD is followed by - * a wildcard character, convert it to augmented. */ - if ((ch == UNI_WILD_AUG_PERIOD) && + /* Augmented periods are only significant if followed by + * a wildcard character. Otherwise, just convert them + * to non-augmented... + * On the other hand, if a UNI_PERIOD is followed by + * a wildcard character, convert it to augmented. */ + if ((ch == UNI_WILD_AUG_PERIOD) && ((ch2 == 0) || - (!DSNS_isUnicodeWildcardChar(ch2)))) + (!DSNS_isUnicodeWildcardChar(ch2)))) { - ch = UNI_PERIOD; + ch = UNI_PERIOD; } else if ((!preValidated) && (ch == UNI_PERIOD) && (ch2 != 0) && (DSNS_isUnicodeWildcardChar(ch2))) @@ -1018,11 +1018,11 @@ error_Exit: /************************************************************************** * DSNS_unicodeScanNextComponent - * + * * This function scans a NULL terminated unicode string, looking for the next * component. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name or wildcard character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -1097,7 +1097,7 @@ STATIC STATUS DSNS_unicodeScanNextComponent( ((*srcPtr == 0) || (!DSNS_isUnicodeWildcardChar(*srcPtr)))) { - ch = UNI_PERIOD; + ch = UNI_PERIOD; } else if ((!preValidated) && (ch == UNI_PERIOD) && (*srcPtr != 0) && @@ -1251,7 +1251,7 @@ STATIC NINT DSNS_generateUniqueName( SetErrno(genMsg,zERR_NOT_SUPPORTED); return(zFAILURE); } - + /************************************************************************** * This will insert the path SEPARATOR character between path names for this @@ -1267,7 +1267,7 @@ STATIC STATUS DSNS_getSeparator( /* This should never be called on this namespace */ SetErrno(genMsg,zERR_INVALID_PATH_SEPARATOR); return(zFAILURE); -} +} /************************************************************************** @@ -1393,10 +1393,10 @@ STATIC BOOL DSNS_wildMatch( * An augmented question mark matches any valid character or an end of frame * or a '.', except that on the '.' it doesn't advance beyond it *---------------------------------------------------------------------------*/ - case UNI_WILD_AUG_QMARK: + case UNI_WILD_AUG_QMARK: if ((*name == 0) || (*name == UNI_PERIOD)) { - /* match end of name or match '.' but don't inc */ + /* match end of name or match '.' but don't inc */ break; } name++; @@ -1406,7 +1406,7 @@ STATIC BOOL DSNS_wildMatch( *---------------------------------------------------------------------------*/ case UNI_WILD_QMARK: if (*name == 0) /* match end of name */ - break; + break; name++; break; @@ -1463,7 +1463,7 @@ STATIC BOOL DSNS_wildMatch( case UNI_WILD_AUG_PERIOD: if ((*name == 0) || (*name++ == UNI_PERIOD)) { - /* we match our end of name or a period */ + /* we match our end of name or a period */ break; } @@ -1505,7 +1505,7 @@ STATIC STATUS DSNS_asciiToUnicode( destName, destNameSize, asciiName, - &temp); + &temp); if (status != zOK) { SetErrno(genMsg,status); @@ -1537,7 +1537,7 @@ STATIC STATUS DSNS_asciiLenToUnicode( destNameSize, asciiName, asciiNameLen, - &temp); + &temp); if (status != zOK) { SetErrno(genMsg,status); diff --git a/include/nwnss/comn/namespace/dataStreamNSpace.h b/src/nwnss/comn/namespace/dataStreamNSpace.h similarity index 98% rename from include/nwnss/comn/namespace/dataStreamNSpace.h rename to src/nwnss/comn/namespace/dataStreamNSpace.h index b17906b..1c04217 100644 --- a/include/nwnss/comn/namespace/dataStreamNSpace.h +++ b/src/nwnss/comn/namespace/dataStreamNSpace.h @@ -38,7 +38,7 @@ #define _DATASTREAMNSPACE_H_ #ifndef _OMNI_H_ -#include +#include #endif /*--------------------------------------------------------------------------- @@ -59,7 +59,7 @@ extern void DSNS_shutdown( #define DSNS_isValidUnicodeFileNameChar(_ch,_preValidated) \ ( (!IS_UNICODE_AUG_WILDCARD_CHAR(_ch)) && \ ( (_preValidated) || \ - ( (!IS_INVALID_UNICODE_CHAR(_ch)) && \ + ( (!IS_INVALID_UNICODE_CHAR(_ch)) && \ ( ((_ch) >= 128) || \ (TST_BIT(DSNS_ValidCharBitMap,(_ch))))))) @@ -112,7 +112,7 @@ extern NINT DSNS_generateUniqueName( extern STATUS DSNS_getSeparator( GeneralMsg_s *genMsg, - NINT type, + NINT type, unicode_t **retStr, NINT *retLen); diff --git a/src/nwnss/comn/namespace/dosNSWild.c b/src/nwnss/comn/namespace/dosNSWild.c index f069318..3320df6 100644 --- a/src/nwnss/comn/namespace/dosNSWild.c +++ b/src/nwnss/comn/namespace/dosNSWild.c @@ -322,7 +322,7 @@ STATUS DOSNS_wildReplace( wc.answerBuffer++; for (count = 0;*wc.answerBuffer;count++) { - if ((*wc.answerBuffer == UNI_PERIOD) || + if ((*wc.answerBuffer == UNI_PERIOD) || !DOSNS_isValidUnicodeFileNameChar(*wc.answerBuffer,FALSE)) /* This character is not allowed */ goto BadFileNameError; @@ -345,7 +345,7 @@ STATUS DOSNS_wildReplace( *---------------------------------------------------------------------------*/ BadFileNameError: SetErrno(genMsg,zERR_INVALID_NAME); - return zFAILURE; + return zFAILURE; } /**************************************************************************** @@ -400,7 +400,7 @@ STATIC STATUS DOSNS_advanceSearchAndFoundStrings( /* This can match anything (including nothing), as long as */ /* what follows the match string matches the rest of the */ /* search string */ - + for (wc->srcName = &wc->srcName[unilen(wc->srcName)]; wc->srcName > wc->matchString; wc->srcName--) @@ -590,10 +590,10 @@ BOOL DOSNS_wildMatch( * An augmented question mark matches any valid character or an end of frame * or a '.', except that on the '.' it doesn't advance beyond it *---------------------------------------------------------------------------*/ - case UNI_WILD_AUG_QMARK: + case UNI_WILD_AUG_QMARK: if ((*name == 0) || (*name == UNI_PERIOD)) { - /* match end of name or match '.' but don't inc */ + /* match end of name or match '.' but don't inc */ break; } name++; @@ -603,7 +603,7 @@ BOOL DOSNS_wildMatch( *---------------------------------------------------------------------------*/ case UNI_WILD_QMARK: if (*name == 0) /* match end of name */ - break; + break; name++; break; @@ -659,7 +659,7 @@ BOOL DOSNS_wildMatch( case UNI_WILD_AUG_PERIOD: if ((*name == 0) || (*name++ == UNI_PERIOD)) { - /* we match our end of name or a period */ + /* we match our end of name or a period */ break; } diff --git a/src/nwnss/comn/namespace/dosNSpace.c b/src/nwnss/comn/namespace/dosNSpace.c index 426e6d2..8200ce0 100644 --- a/src/nwnss/comn/namespace/dosNSpace.c +++ b/src/nwnss/comn/namespace/dosNSpace.c @@ -59,7 +59,7 @@ /**************************************************************************** * STATIC initialization of a nsOps table for the DOS Namespace *****************************************************************************/ -STATIC NameSpaceOps_s dosNsOps = +STATIC NameSpaceOps_s dosNsOps = { DOSNS_asciiScanNextComponent, DOSNS_asciiLenScanNextComponent, @@ -149,7 +149,7 @@ BOOL DOSNS_isValidUniToUpper( } /* We need to try traditional NetWare uppercase rules. This will only - * work if the character is single byte. Otherwise, if the default + * work if the character is single byte. Otherwise, if the default * function did not return a valid upper case char we are out of luck. * Convert the character to ASCII before using the traditional NetWare * ASCII uppercase tables @@ -196,7 +196,7 @@ BOOL DOSNS_isValidUniToUpper( * component. The component may be returned in ASCII or unicode, depending * on the type of component. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name or wildcard character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -205,7 +205,7 @@ BOOL DOSNS_isValidUniToUpper( * * If any doublebyte, wildcard or other special combinations of characters are * encountered, this function converts the scanned component to unicode - * and does a full semantic parsing operation on it before returning. + * and does a full semantic parsing operation on it before returning. * * If the component is made up of normal everyday characters, this function * leaves the component in ASCII and does not do a full semantic parse. This @@ -214,7 +214,7 @@ BOOL DOSNS_isValidUniToUpper( * the caller does not find the name in the ASCII name cache, the name would * then need to be translated to Unicode and a full unicode scan would need * to be done before it can be used. - * + * ***************************************************************************/ STATIC STATUS DOSNS_asciiScanNextComponent( GeneralMsg_s *genMsg, @@ -306,7 +306,7 @@ STATIC STATUS DOSNS_asciiScanNextComponent( goto error_InvalidName; } /* Note - Traditional NetWare always uppercased the first - * byte of a double byte sequence, but I checked their + * byte of a double byte sequence, but I checked their * tables, and the upper-case did nothing, because 0x80-0xFF * mapped to upper straight through with no changes. */ @@ -340,7 +340,7 @@ STATIC STATUS DOSNS_asciiScanNextComponent( switch (ch) { case ASCII_WILDCARD_BREAK: - if (!(scanMsg->scanFlags & NSSFL_asciiBreakNotSpecial)) + if (!(scanMsg->scanFlags & NSSFL_asciiBreakNotSpecial)) { /* ASCII breaks are special, Require a second * character to go with this sequence */ @@ -380,7 +380,7 @@ STATIC STATUS DOSNS_asciiScanNextComponent( case ASCII_AUG_PERIOD: case ASCII_ASTERISK: case ASCII_QMARK: - /* Note -- we intentionally fall through from the + /* Note -- we intentionally fall through from the * above case element. Do not rearrange this code * without being aware of this. */ if (doUpperCase) @@ -538,7 +538,7 @@ STATIC STATUS DOSNS_asciiScanNextComponent( } goto foundNextComponent; } - + /* In DOS NameSpace, we allow any number and combination * of trailing slashes. Just strip them all */ while (((ch=*srcPtr) == '/') || (ch == '\\')) @@ -561,7 +561,7 @@ STATIC STATUS DOSNS_asciiScanNextComponent( /* If there is a single slash after the volume override * then just strip it. It is not needed. If there - * is more than one slash it is an invalid path. + * is more than one slash it is an invalid path. */ ch = *srcPtr; if ((ch == '/') || (ch == '\\')) @@ -579,7 +579,7 @@ STATIC STATUS DOSNS_asciiScanNextComponent( ch = *srcPtr; if ((componentSize != 0) && (ch == 0)) { - /* We allow a ":" all by itself if it is the only + /* We allow a ":" all by itself if it is the only * thing in a counted path component */ goto error_InvalidPath; /* Trailing Colon is Illegal */ } @@ -600,7 +600,7 @@ STATIC STATUS DOSNS_asciiScanNextComponent( ch = *srcPtr; if (((componentSize != 0) && (ch == 0)) || (ch == ':')) { - /* We allow a "::" all by itself if it is the only + /* We allow a "::" all by itself if it is the only * thing in a counted path component */ goto error_InvalidPath; /* Trailing colons and 3+ colons are illegal */ } @@ -676,12 +676,12 @@ STATIC STATUS DOSNS_asciiScanNextComponent( { goto error_InvalidName; } - if ((ch >= 0x80) && + if ((ch >= 0x80) && (scanMsg->scanFlags & NSSFL_continueAfterIllegalChars)) - { + { /* Don't uppercase 8-bit characters */ - *upperPtr++ = ch; - } + *upperPtr++ = ch; + } else { *upperPtr++ = NW_LocaleTable->DOSUpperCaseTable[ch]; @@ -738,7 +738,7 @@ function_exit: if (scanMsg->retScanFlags & NSRETSFL_scannedVolumeNameOverride) { - scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; + scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; scanMsg->retUnicodeComp = scanMsg->uniWorkBuffer1; } else @@ -823,7 +823,7 @@ error_Exit: * next component. The component may be returned in ASCII or unicode, * depending on the type of component. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name or wildcard character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -832,7 +832,7 @@ error_Exit: * * If any doublebyte, wildcard or other special combinations of characters are * encountered, this function converts the scanned component to unicode - * and does a full semantic parsing operation on it before returning. + * and does a full semantic parsing operation on it before returning. * * If the component is made up of normal everyday characters, this function * leaves the component in ASCII and does not do a full semantic parse. This @@ -841,7 +841,7 @@ error_Exit: * the caller does not find the name in the ASCII name cache, the name would * then need to be translated to Unicode and a full unicode scan would need * to be done before it can be used. - * + * ***************************************************************************/ STATIC STATUS DOSNS_asciiLenScanNextComponent( GeneralMsg_s *genMsg, @@ -938,7 +938,7 @@ STATIC STATUS DOSNS_asciiLenScanNextComponent( goto error_InvalidName; } /* Note - Traditional NetWare always uppercased the first - * byte of a double byte sequence, but I checked their + * byte of a double byte sequence, but I checked their * tables, and the upper-case did nothing, because 0x80-0xFF * mapped to upper straight through with no changes. */ @@ -1014,7 +1014,7 @@ STATIC STATUS DOSNS_asciiLenScanNextComponent( case ASCII_AUG_PERIOD: case ASCII_ASTERISK: case ASCII_QMARK: - /* Note -- we intentionally fall through from the + /* Note -- we intentionally fall through from the * above case element. Do not rearrange this code * without being aware of this. */ if (doUpperCase) @@ -1174,7 +1174,7 @@ STATIC STATUS DOSNS_asciiLenScanNextComponent( } goto foundNextComponent; } - + /* In DOS NameSpace, we allow any number and combination * of trailing slashes. Just strip them all */ while ((srcLength > 0) && @@ -1190,7 +1190,7 @@ STATIC STATUS DOSNS_asciiLenScanNextComponent( if ((componentSize != 0) && (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed)) { - /* Got a volume name. Quit parsing here. The + /* Got a volume name. Quit parsing here. The * destAsciiComp buffer contains the volume name. * Go translate the volume name to unicode. */ @@ -1199,7 +1199,7 @@ STATIC STATUS DOSNS_asciiLenScanNextComponent( /* If there is a single slash after the volume override * then just strip it. It is not needed. If there - * is more than one slash it is an invalid path. + * is more than one slash it is an invalid path. */ ch = *srcPtr; if ((srcLength > 0) && ((ch == '/') || (ch == '\\'))) @@ -1217,7 +1217,7 @@ STATIC STATUS DOSNS_asciiLenScanNextComponent( if ((componentSize != 0) && (srcLength == 0)) { - /* We allow a ":" all by itself if it is the only + /* We allow a ":" all by itself if it is the only * thing in a counted path component */ goto error_InvalidPath; /* Trailing Colon is Illegal */ } @@ -1231,7 +1231,7 @@ STATIC STATUS DOSNS_asciiLenScanNextComponent( scanMsg->retNextNameType = zNTYPE_DATA_STREAM; goto foundNextComponent; } - + /* A "::" signals the start of an extended attribute * name. We must quit parsing here */ ++srcPtr; /* Skip over second colon */ @@ -1239,7 +1239,7 @@ STATIC STATUS DOSNS_asciiLenScanNextComponent( if (((componentSize != 0) && (srcLength == 0)) || ((srcLength > 0) && (*srcPtr == ':'))) { - /* We allow a "::" all by itself if it is the only + /* We allow a "::" all by itself if it is the only * thing in a counted path component */ goto error_InvalidPath; /* Trailing colons and 3+ colons are illegal */ } @@ -1402,7 +1402,7 @@ function_exit: if (scanMsg->retScanFlags & NSRETSFL_scannedVolumeNameOverride) { - scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; + scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; scanMsg->retUnicodeComp = scanMsg->uniWorkBuffer1; } else @@ -1486,13 +1486,13 @@ error_Exit: * This function scans a NULL terminated UTF8 string, looking for the next * component. The component will be returned in unicode. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name character, then this function returns an error. * * If the character is a component separator, this function stops scanning, * sets up the return message to indicate the type of separator that was found * and returns successful. (The separators are stripped from the buffer) - * + * ***************************************************************************/ STATIC STATUS DOSNS_utf8ScanNextComponent( GeneralMsg_s *genMsg, @@ -1586,7 +1586,7 @@ STATIC STATUS DOSNS_utf8ScanNextComponent( { case 1: *destUnicodeComp++ = UNI_VOLUME_ROOT; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; break; @@ -1612,7 +1612,7 @@ STATIC STATUS DOSNS_utf8ScanNextComponent( goto cleanup_path; } - /* If the last component had illegal characters, + /* If the last component had illegal characters, * re-map the error code to indicate illegal path */ if (scanMsg->retScanFlags & NSRETSFL_hasIllegalChars) { @@ -1646,7 +1646,7 @@ STATIC STATUS DOSNS_utf8ScanNextComponent( goto cleanup_path; } - /* If the last component had illegal characters, + /* If the last component had illegal characters, * re-map the error code to indicate illegal path */ if (scanMsg->retScanFlags & NSRETSFL_hasIllegalChars) { @@ -1674,7 +1674,7 @@ STATIC STATUS DOSNS_utf8ScanNextComponent( if ((!atComponentFront) && (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed)) { - /* Got a volume name. Quit parsing here. The + /* Got a volume name. Quit parsing here. The * destUnicodeComp buffer contains the volume name. */ scanMsg->retScanFlags |= (NSRETSFL_scannedVolumeNameOverride | @@ -1685,7 +1685,7 @@ STATIC STATUS DOSNS_utf8ScanNextComponent( /* If there is a single slash after the volume override * then just strip it. It is not needed. If there - * is more than one slash it is an invalid path. + * is more than one slash it is an invalid path. */ if ((status = LB_UTF8ToUniChar(srcPtr,&nextSrcPtr,&ch)) != zOK) { @@ -1714,7 +1714,7 @@ STATIC STATUS DOSNS_utf8ScanNextComponent( ch = *srcPtr; if ((!atComponentFront) && (ch == 0)) { - /* We allow a ":" all by itself if it is the only + /* We allow a ":" all by itself if it is the only * thing in a counted path component */ goto cleanup_path; /* Trailing colon is illegal */ } @@ -1733,11 +1733,11 @@ STATIC STATUS DOSNS_utf8ScanNextComponent( ch = *srcPtr; if (((!atComponentFront) && (ch == 0)) || (ch == UNI_COLON)) { - /* We allow a "::" all by itself if it is the only + /* We allow a "::" all by itself if it is the only * thing in a counted path component */ goto cleanup_path; /* Trailing colons and 3+ colons are illegal */ } - + /* Double Colon: Change namespace to extended attribute namespace */ scanMsg->retScanFlags |= NSRETSFL_scannedChangeNameSpace; scanMsg->retNextNameSpaceID = zNSPACE_EXTENDED_ATTRIBUTE; @@ -1895,14 +1895,14 @@ STATIC STATUS DOSNS_utf8ScanNextComponent( if ((ch == UNI_WILD_AUG_PERIOD) && (!DOSNS_isUnicodeWildcardChar(ch2))) { - ch = UNI_PERIOD; + ch = UNI_PERIOD; } else if ((!origIsAscii) && (ch == UNI_PERIOD) && (DOSNS_isUnicodeWildcardChar(ch2))) { ch = UNI_WILD_AUG_PERIOD; } - + /* This period starts an extension, save it and reset * the field limits for the extension piece. */ if (maxComponentSize < 1) @@ -2007,7 +2007,7 @@ STATIC STATUS DOSNS_utf8ScanNextComponent( *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; case UNI_VOLUME_ROOT: case UNI_NDS_ROOT: @@ -2017,7 +2017,7 @@ STATIC STATUS DOSNS_utf8ScanNextComponent( (scanMsg->scanFlags & NSSFL_parsingFirstComponent)) { *destUnicodeComp++ = ch; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* Remove a single terminating slash */ if ((status = LB_UTF8ToUniChar(srcPtr,&nextSrcPtr,&ch)) != zOK) @@ -2137,14 +2137,14 @@ STATIC STATUS DOSNS_utf8ScanNextComponent( * backwards compatability. * Be very carefull if changing this. */ - validChar = + validChar = ((DOSNS_isValid7BitUnicodeFileNameChar(ch, preValidated)) || (!(scanMsg->scanFlags & NSSFL_continueAfterIllegalChars) && (DOSNS_isValidUnicodeFileNameChar(ch, preValidated)))); } else { - /* If the string originated in unicode, convert it to + /* If the string originated in unicode, convert it to * uppercase and validate that we have a valid upper * case character that is mappable to ASCII. */ @@ -2165,7 +2165,7 @@ STATIC STATUS DOSNS_utf8ScanNextComponent( */ if (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed) { - nameTooLongError = TRUE; + nameTooLongError = TRUE; } else { @@ -2186,7 +2186,7 @@ STATIC STATUS DOSNS_utf8ScanNextComponent( */ if (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed) { - nameTooLongError = TRUE; + nameTooLongError = TRUE; } else { @@ -2364,13 +2364,13 @@ error_Exit: * This function scans a UTF8 string with a separate length, looking for the * next component. The component will be returned in unicode. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name character, then this function returns an error. * * If the character is a component separator, this function stops scanning, * sets up the return message to indicate the type of separator that was found * and returns successful. (The separators are stripped from the buffer) - * + * ***************************************************************************/ STATIC STATUS DOSNS_utf8LenScanNextComponent( GeneralMsg_s *genMsg, @@ -2428,7 +2428,7 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( while ((srcLength > 0) && ((status = LB_UTF8LenToUniChar(srcPtr, srcLength, &srcPtr, &ch, - &srcLength)) == zOK)) + &srcLength)) == zOK)) { /* * Process a slash in the path string. @@ -2479,7 +2479,7 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( { case 1: *destUnicodeComp++ = UNI_VOLUME_ROOT; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; break; @@ -2505,7 +2505,7 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( goto cleanup_path; } - /* If the last component had illegal characters, + /* If the last component had illegal characters, * re-map the error code to indicate illegal path */ if (scanMsg->retScanFlags & NSRETSFL_hasIllegalChars) { @@ -2541,7 +2541,7 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( goto cleanup_path; } - /* If the last component had illegal characters, + /* If the last component had illegal characters, * re-map the error code to indicate illegal path */ if (scanMsg->retScanFlags & NSRETSFL_hasIllegalChars) { @@ -2569,7 +2569,7 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( if ((!atComponentFront) && (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed)) { - /* Got a volume name. Quit parsing here. The + /* Got a volume name. Quit parsing here. The * destUnicodeComp buffer contains the volume name. */ scanMsg->retScanFlags |= (NSRETSFL_scannedVolumeNameOverride | @@ -2580,7 +2580,7 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( /* If there is a single slash after the volume override * then just strip it. It is not needed. If there - * is more than one slash it is an invalid path. + * is more than one slash it is an invalid path. */ if ((status = LB_UTF8LenToUniChar(srcPtr, srcLength, &nextSrcPtr, &ch, &nextSrcLength)) != zOK) @@ -2612,7 +2612,7 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( /* Note -- assume UNI_COLON and NULL are single byte UTF8 chars */ if ((!atComponentFront) && (srcLength == 0)) { - /* We allow a ":" all by itself if it is the only + /* We allow a ":" all by itself if it is the only * thing in a counted path component */ goto cleanup_path; /* Trailing colon is illegal */ } @@ -2632,11 +2632,11 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( if (((!atComponentFront) && (srcLength == 0)) || ((srcLength != 0) && (ch == UNI_COLON))) { - /* We allow a "::" all by itself if it is the only + /* We allow a "::" all by itself if it is the only * thing in a counted path component */ goto cleanup_path; /* Trailing colons and 3+ colons are illegal */ } - + /* Double Colon: Change namespace to extended attribute namespace */ scanMsg->retScanFlags |= NSRETSFL_scannedChangeNameSpace; scanMsg->retNextNameSpaceID = zNSPACE_EXTENDED_ATTRIBUTE; @@ -2800,14 +2800,14 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( if ((ch == UNI_WILD_AUG_PERIOD) && (!DOSNS_isUnicodeWildcardChar(ch2))) { - ch = UNI_PERIOD; + ch = UNI_PERIOD; } else if ((!origIsAscii) && (ch == UNI_PERIOD) && (DOSNS_isUnicodeWildcardChar(ch2))) { ch = UNI_WILD_AUG_PERIOD; } - + /* This period starts an extension, save it and reset * the field limits for the extension piece. */ if (maxComponentSize < 1) @@ -2926,7 +2926,7 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; case UNI_VOLUME_ROOT: case UNI_NDS_ROOT: @@ -2936,7 +2936,7 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( (scanMsg->scanFlags & NSSFL_parsingFirstComponent)) { *destUnicodeComp++ = ch; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* Remove a single terminating slash */ if ((status = LB_UTF8LenToUniChar(srcPtr, srcLength, @@ -3064,14 +3064,14 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( * backwards compatability. * Be very carefull if changing this. */ - validChar = + validChar = ((DOSNS_isValid7BitUnicodeFileNameChar(ch, preValidated)) || (!(scanMsg->scanFlags & NSSFL_continueAfterIllegalChars) && (DOSNS_isValidUnicodeFileNameChar(ch, preValidated)))); } else { - /* If the string originated in unicode, convert it to + /* If the string originated in unicode, convert it to * uppercase and validate that we have a valid upper * case character that is mappable to ASCII. */ @@ -3092,7 +3092,7 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( */ if (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed) { - nameTooLongError = TRUE; + nameTooLongError = TRUE; } else { @@ -3113,7 +3113,7 @@ STATIC STATUS DOSNS_utf8LenScanNextComponent( */ if (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed) { - nameTooLongError = TRUE; + nameTooLongError = TRUE; } else { @@ -3299,11 +3299,11 @@ error_Exit: /************************************************************************** * DOSNS_unicodeScanNextComponent - * + * * This function scans a NULL terminated unicode string, looking for the next * component. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name or wildcard character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -3399,7 +3399,7 @@ STATIC STATUS DOSNS_unicodeScanNextComponent( { case 1: *destUnicodeComp++ = UNI_VOLUME_ROOT; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; break; @@ -3425,7 +3425,7 @@ STATIC STATUS DOSNS_unicodeScanNextComponent( goto cleanup_path; } - /* If the last component had illegal characters, + /* If the last component had illegal characters, * re-map the error code to indicate illegal path */ if (scanMsg->retScanFlags & NSRETSFL_hasIllegalChars) { @@ -3458,7 +3458,7 @@ STATIC STATUS DOSNS_unicodeScanNextComponent( goto cleanup_path; } - /* If the last component had illegal characters, + /* If the last component had illegal characters, * re-map the error code to indicate illegal path */ if (scanMsg->retScanFlags & NSRETSFL_hasIllegalChars) { @@ -3486,7 +3486,7 @@ STATIC STATUS DOSNS_unicodeScanNextComponent( if ((!atComponentFront) && (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed)) { - /* Got a volume name. Quit parsing here. The + /* Got a volume name. Quit parsing here. The * destUnicodeComp buffer contains the volume name. */ scanMsg->retScanFlags |= (NSRETSFL_scannedVolumeNameOverride | @@ -3497,7 +3497,7 @@ STATIC STATUS DOSNS_unicodeScanNextComponent( /* If there is a single slash after the volume override * then just strip it. It is not needed. If there - * is more than one slash it is an invalid path. + * is more than one slash it is an invalid path. */ ch = *srcPtr; if (ch == UNI_PATH_SEPARATOR) @@ -3521,7 +3521,7 @@ STATIC STATUS DOSNS_unicodeScanNextComponent( ch = *srcPtr; if ((!atComponentFront) && (ch == 0)) { - /* We allow a ":" all by itself if it is the only + /* We allow a ":" all by itself if it is the only * thing in a counted path component */ goto cleanup_path; /* Trailing colon is illegal */ } @@ -3540,11 +3540,11 @@ STATIC STATUS DOSNS_unicodeScanNextComponent( ch = *srcPtr; if (((!atComponentFront) && (ch == 0)) || (ch == UNI_COLON)) { - /* We allow a "::" all by itself if it is the only + /* We allow a "::" all by itself if it is the only * thing in a counted path component */ goto cleanup_path; /* Trailing colons and 3+ colons are illegal */ } - + /* Double Colon: Change namespace to extended attribute namespace */ scanMsg->retScanFlags |= NSRETSFL_scannedChangeNameSpace; scanMsg->retNextNameSpaceID = zNSPACE_EXTENDED_ATTRIBUTE; @@ -3692,14 +3692,14 @@ STATIC STATUS DOSNS_unicodeScanNextComponent( if ((ch == UNI_WILD_AUG_PERIOD) && (!DOSNS_isUnicodeWildcardChar(ch2))) { - ch = UNI_PERIOD; + ch = UNI_PERIOD; } else if ((!origIsAscii) && (ch == UNI_PERIOD) && (DOSNS_isUnicodeWildcardChar(ch2))) { ch = UNI_WILD_AUG_PERIOD; } - + /* This period starts an extension, save it and reset * the field limits for the extension piece. */ if (maxComponentSize < 1) @@ -3794,7 +3794,7 @@ STATIC STATUS DOSNS_unicodeScanNextComponent( *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; case UNI_VOLUME_ROOT: case UNI_NDS_ROOT: @@ -3804,7 +3804,7 @@ STATIC STATUS DOSNS_unicodeScanNextComponent( (scanMsg->scanFlags & NSSFL_parsingFirstComponent)) { *destUnicodeComp++ = ch; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* Remove a single terminating slash */ ch = *srcPtr; @@ -3903,14 +3903,14 @@ STATIC STATUS DOSNS_unicodeScanNextComponent( * backwards compatability. * Be very carefull if changing this. */ - validChar = + validChar = ((DOSNS_isValid7BitUnicodeFileNameChar(ch, preValidated)) || (!(scanMsg->scanFlags & NSSFL_continueAfterIllegalChars) && (DOSNS_isValidUnicodeFileNameChar(ch, preValidated)))); } else { - /* If the string originated in unicode, convert it to + /* If the string originated in unicode, convert it to * uppercase and validate that we have a valid upper * case character that is mappable to ASCII. */ @@ -3931,7 +3931,7 @@ STATIC STATUS DOSNS_unicodeScanNextComponent( */ if (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed) { - nameTooLongError = TRUE; + nameTooLongError = TRUE; } else { @@ -3952,7 +3952,7 @@ STATIC STATUS DOSNS_unicodeScanNextComponent( */ if (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed) { - nameTooLongError = TRUE; + nameTooLongError = TRUE; } else { @@ -4150,7 +4150,7 @@ STATIC STATUS DOSNS_getSeparator( } SetErrno(genMsg,zERR_INVALID_PATH_SEPARATOR); return zFAILURE; -} +} /************************************************************************** @@ -4445,7 +4445,7 @@ checkCharAgain: if ((status == zOK) && (retActualLength != 1)) { /* We can't uppercase anything except single-byte characters - * using traditional NetWare rules. + * using traditional NetWare rules. * Just treat it as invalid */ status = zFAILURE; } @@ -4561,7 +4561,7 @@ checkCharAgain2: if ((status == zOK) && (retActualLength != 1)) { /* We can't uppercase anything except single-byte characters - * using traditional NetWare rules. + * using traditional NetWare rules. * Just treat it as invalid */ status = zFAILURE; } @@ -4611,7 +4611,7 @@ checkCharAgain2: *---------------------------------------------------------------------------*/ if (dstExtAsciiCount == 0) { - shareable = FALSE; + shareable = FALSE; dstPtr = periodPtr; periodPtr = NULL; } @@ -4623,7 +4623,7 @@ checkCharAgain2: *---------------------------------------------------------------------------*/ if (dstNameAsciiCount == 0) { - shareable = FALSE; + shareable = FALSE; } /*--------------------------------------------------------------------------- * We have a syntax-valid dest name. Null terminate it, and then begin the @@ -4640,7 +4640,7 @@ checkCharAgain2: COMN_SETUP_GENERAL_MSG_NOSA(&tempGenMsg); if (DOSNS_isLegalName(&tempGenMsg,uniqueName) != zOK) - shareable = FALSE; + shareable = FALSE; /*--------------------------------------------------------------------------- * if shareable is TRUE then uniqueName is unmodified from the original @@ -4686,7 +4686,7 @@ checkCharAgain2: } /* If the filename is longer than 6 chars, truncate it one char at a time - * allowing for the fact that a unicode character that maps to a + * allowing for the fact that a unicode character that maps to a * double byte ASCII char really counts for two characters. */ while (dstNameAsciiCount > 6) @@ -4718,7 +4718,7 @@ checkCharAgain2: uniqueName[tildeIdx+1]++; /* Try next ~1, ~2, ~`3, or ~4 char */ foundBeastZid = NAME_FindZidForNameInDir(genMsg, directory, - nameSpace, srcNameType, uniqueName, 0, NULL, + nameSpace, srcNameType, uniqueName, 0, NULL, FALSE/* cnt , &dummy*/); if (foundBeastZid == zINVALID_ZID) { @@ -4799,8 +4799,8 @@ checkCharAgain2: * ~ numbers for this file name. */ uniqueName[tildeIdx+1] = mangleChars[31]; - foundBeastZid = NAME_FindZidForNameInDir(genMsg, - directory, nameSpace, srcNameType, uniqueName, 0, NULL, + foundBeastZid = NAME_FindZidForNameInDir(genMsg, + directory, nameSpace, srcNameType, uniqueName, 0, NULL, FALSE/* cnt , &dummy*/); if (foundBeastZid == zINVALID_ZID) { @@ -4811,7 +4811,7 @@ checkCharAgain2: { /* Assign next level of tilde character */ uniqueName[tildeIdx+1] = mangleChars[i]; - foundBeastZid = NAME_FindZidForNameInDir(genMsg, + foundBeastZid = NAME_FindZidForNameInDir(genMsg, directory, nameSpace, srcNameType, uniqueName, 0, NULL, FALSE/* cnt , &dummy*/); if (foundBeastZid == zINVALID_ZID) @@ -4830,7 +4830,7 @@ checkCharAgain2: } } PERIODIC_YIELD(); - } + } /*--------------------------------------------------------------------------- * We failed with the 4char hash. Now, as a last resort, use the first two @@ -4913,7 +4913,7 @@ STATIC STATUS DOSNS_asciiToUnicode( destName, destNameSize, asciiName, - &temp); + &temp); if (status != zOK) { SetErrno(genMsg,status); @@ -4945,7 +4945,7 @@ STATIC STATUS DOSNS_asciiLenToUnicode( destNameSize, asciiName, asciiNameLen, - &temp); + &temp); if (status != zOK) { SetErrno(genMsg,status); diff --git a/include/nwnss/comn/namespace/dosNSpace.h b/src/nwnss/comn/namespace/dosNSpace.h similarity index 97% rename from include/nwnss/comn/namespace/dosNSpace.h rename to src/nwnss/comn/namespace/dosNSpace.h index 49d52fe..c293ed7 100644 --- a/include/nwnss/comn/namespace/dosNSpace.h +++ b/src/nwnss/comn/namespace/dosNSpace.h @@ -38,7 +38,7 @@ #define _DOSNSPACE_H_ #ifndef _OMNI_H_ -#include +#include #endif /*--------------------------------------------------------------------------- @@ -60,20 +60,20 @@ extern void DOSNS_shutdown( #define DOSNS_isValidUnicodeFileNameChar(_ch,_preValidated) \ ( (!IS_UNICODE_AUG_WILDCARD_CHAR(_ch)) && \ ( (_preValidated) || \ - ( (IS_UNICODE_MAPPABLE_TO_ASCII(_ch)) && \ + ( (IS_UNICODE_MAPPABLE_TO_ASCII(_ch)) && \ ( ((_ch) >= 128) || \ (TST_BIT(NW_LocaleTable->DOSValidCharBitMap,(_ch))))))) #define DOSNS_isValid7BitUnicodeFileNameChar(_ch,_preValidated) \ ( (!IS_UNICODE_AUG_WILDCARD_CHAR(_ch)) && \ ( (_preValidated) || \ - ( ((_ch) < 128) && \ + ( ((_ch) < 128) && \ (TST_BIT(NW_LocaleTable->DOSValidCharBitMap,(_ch)))))) #define DOSNS_isValidUnicodeUpperFileNameChar(_ch,_preValidated) \ ( (!IS_UNICODE_AUG_WILDCARD_CHAR(_ch)) && \ ( (_preValidated) || \ - ( (IS_UNICODE_MAPPABLE_TO_ASCII(_ch)) && \ + ( (IS_UNICODE_MAPPABLE_TO_ASCII(_ch)) && \ ( ((_ch) >= 128) || \ (TST_BIT(NW_LocaleTable->DOSValidCharBitMapNoLower,(_ch))))))) @@ -126,7 +126,7 @@ extern NINT DOSNS_generateUniqueName( extern STATUS DOSNS_getSeparator( GeneralMsg_s *genMsg, - NINT type, + NINT type, unicode_t **retStr, NINT *retLen); diff --git a/src/nwnss/comn/namespace/extAttrNSpace.c b/src/nwnss/comn/namespace/extAttrNSpace.c index 84835ad..68b9828 100644 --- a/src/nwnss/comn/namespace/extAttrNSpace.c +++ b/src/nwnss/comn/namespace/extAttrNSpace.c @@ -58,7 +58,7 @@ STATIC BYTE EANS_ValidCharBitMap[32]; /**************************************************************************** * STATIC initialization of a nsOps table for the EA Namespace *****************************************************************************/ -STATIC NameSpaceOps_s eaNsOps = +STATIC NameSpaceOps_s eaNsOps = { EANS_asciiScanNextComponent, EANS_asciiLenScanNextComponent, @@ -93,7 +93,7 @@ STATUS EANS_Startup( ns = COMN_RegisterNameSpace(genMsg,NAMESPACE_VERSION, zNSPACE_EXTENDED_ATTRIBUTE, - (1< 0) && ((status = LB_UTF8LenToUniChar(srcPtr, srcLength, &srcPtr, &ch, - &srcLength)) == zOK)) + &srcLength)) == zOK)) { switch (ch) { @@ -887,16 +887,16 @@ STATIC STATUS EANS_utf8LenScanNextComponent( { goto error_InvalidUtf8Char; } - /* Augmented periods are only significant if followed by - * a wildcard character. Otherwise, just convert them - * to non-augmented... - * On the other hand, if a UNI_PERIOD is followed by - * a wildcard character, convert it to augmented. */ - if ((ch == UNI_WILD_AUG_PERIOD) && + /* Augmented periods are only significant if followed by + * a wildcard character. Otherwise, just convert them + * to non-augmented... + * On the other hand, if a UNI_PERIOD is followed by + * a wildcard character, convert it to augmented. */ + if ((ch == UNI_WILD_AUG_PERIOD) && ((ch2 == 0) || - (!EANS_isUnicodeWildcardChar(ch2)))) + (!EANS_isUnicodeWildcardChar(ch2)))) { - ch = UNI_PERIOD; + ch = UNI_PERIOD; } else if ((!preValidated) && (ch == UNI_PERIOD) && (ch2 != 0) && (EANS_isUnicodeWildcardChar(ch2))) @@ -1018,11 +1018,11 @@ error_Exit: /************************************************************************** * EANS_unicodeScanNextComponent - * + * * This function scans a NULL terminated unicode string, looking for the next * component. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name or wildcard character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -1097,7 +1097,7 @@ STATIC STATUS EANS_unicodeScanNextComponent( ((*srcPtr == 0) || (!EANS_isUnicodeWildcardChar(*srcPtr)))) { - ch = UNI_PERIOD; + ch = UNI_PERIOD; } else if ((!preValidated) && (ch == UNI_PERIOD) && (*srcPtr != 0) && @@ -1250,7 +1250,7 @@ STATIC NINT EANS_generateUniqueName( SetErrno(genMsg,zERR_NOT_SUPPORTED); return(zFAILURE); } - + /************************************************************************** * This will insert the path SEPARATOR character between path names for this @@ -1266,7 +1266,7 @@ STATIC STATUS EANS_getSeparator( /* This should never be called on this namespace */ SetErrno(genMsg,zERR_INVALID_PATH_SEPARATOR); return(zFAILURE); -} +} /************************************************************************** @@ -1392,10 +1392,10 @@ STATIC BOOL EANS_wildMatch( * An augmented question mark matches any valid character or an end of frame * or a '.', except that on the '.' it doesn't advance beyond it *---------------------------------------------------------------------------*/ - case UNI_WILD_AUG_QMARK: + case UNI_WILD_AUG_QMARK: if ((*name == 0) || (*name == UNI_PERIOD)) { - /* match end of name or match '.' but don't inc */ + /* match end of name or match '.' but don't inc */ break; } name++; @@ -1405,7 +1405,7 @@ STATIC BOOL EANS_wildMatch( *---------------------------------------------------------------------------*/ case UNI_WILD_QMARK: if (*name == 0) /* match end of name */ - break; + break; name++; break; @@ -1462,7 +1462,7 @@ STATIC BOOL EANS_wildMatch( case UNI_WILD_AUG_PERIOD: if ((*name == 0) || (*name++ == UNI_PERIOD)) { - /* we match our end of name or a period */ + /* we match our end of name or a period */ break; } @@ -1504,7 +1504,7 @@ STATIC STATUS EANS_asciiToUnicode( destName, destNameSize, asciiName, - &temp); + &temp); if (status != zOK) { SetErrno(genMsg,status); @@ -1536,7 +1536,7 @@ STATIC STATUS EANS_asciiLenToUnicode( destNameSize, asciiName, asciiNameLen, - &temp); + &temp); if (status != zOK) { SetErrno(genMsg,status); diff --git a/include/nwnss/comn/namespace/extAttrNSpace.h b/src/nwnss/comn/namespace/extAttrNSpace.h similarity index 98% rename from include/nwnss/comn/namespace/extAttrNSpace.h rename to src/nwnss/comn/namespace/extAttrNSpace.h index 31b1c1d..cc5d96b 100644 --- a/include/nwnss/comn/namespace/extAttrNSpace.h +++ b/src/nwnss/comn/namespace/extAttrNSpace.h @@ -38,7 +38,7 @@ #define _EXTATTRNSPACE_H_ #ifndef _OMNI_H_ -#include +#include #endif /*--------------------------------------------------------------------------- @@ -60,7 +60,7 @@ extern void EANS_shutdown( #define EANS_isValidUnicodeFileNameChar(_ch,_preValidated) \ ( (!IS_UNICODE_AUG_WILDCARD_CHAR(_ch)) && \ ( (_preValidated) || \ - ( (!IS_INVALID_UNICODE_CHAR(_ch)) && \ + ( (!IS_INVALID_UNICODE_CHAR(_ch)) && \ ( ((_ch) >= 128) || \ (TST_BIT(EANS_ValidCharBitMap,(_ch))))))) @@ -113,7 +113,7 @@ extern NINT EANS_generateUniqueName( extern STATUS EANS_getSeparator( GeneralMsg_s *genMsg, - NINT type, + NINT type, unicode_t **retStr, NINT *retLen); diff --git a/src/nwnss/comn/namespace/longNSpace.c b/src/nwnss/comn/namespace/longNSpace.c index b4e8ab6..0e16291 100644 --- a/src/nwnss/comn/namespace/longNSpace.c +++ b/src/nwnss/comn/namespace/longNSpace.c @@ -59,7 +59,7 @@ STATIC BYTE LONGNS_ValidCharBitMap[32]; /**************************************************************************** * STATIC initialization of a nsOps table for the LONG Namespace *****************************************************************************/ -STATIC NameSpaceOps_s longNsOps = +STATIC NameSpaceOps_s longNsOps = { LONGNS_asciiScanNextComponent, LONGNS_asciiLenScanNextComponent, @@ -94,8 +94,8 @@ STATUS LONGNS_Startup( ns = COMN_RegisterNameSpace(genMsg,NAMESPACE_VERSION, zNSPACE_LONG, - (1<retNextNameType = zNTYPE_DATA_STREAM; goto foundNextComponent; } - + /* A "::" signals the start of an extended attribute * name. We must quit parsing here */ ++srcPtr; /* Skip over second colon */ ch = *srcPtr; if ((ch == 0) || (ch == ':')) { - /* We allow a "::" all by itself if it is the only + /* We allow a "::" all by itself if it is the only * thing in a counted path component */ goto error_InvalidPath; /* Trailing colons and 3+ colons are illegal */ } @@ -452,7 +452,7 @@ function_exit: if (scanMsg->retScanFlags & NSRETSFL_scannedVolumeNameOverride) { - scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; + scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; scanMsg->retUnicodeComp = scanMsg->uniWorkBuffer1; } else @@ -529,7 +529,7 @@ error_Exit: * next component. The component may be returned in ASCII or unicode, * depending on the type of component. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name or wildcard character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -538,7 +538,7 @@ error_Exit: * * If any doublebyte, wildcard or other special combinations of characters are * encountered, this function converts the scanned component to unicode - * and does a full semantic parsing operation on it before returning. + * and does a full semantic parsing operation on it before returning. * * If the component is made up of normal everyday characters, this function * leaves the component in ASCII and does not do a full semantic parse. This @@ -547,7 +547,7 @@ error_Exit: * the caller does not find the name in the ASCII name cache, the name would * then need to be translated to Unicode and a full unicode scan would need * to be done before it can be used. - * + * ***************************************************************************/ STATIC STATUS LONGNS_asciiLenScanNextComponent( GeneralMsg_s *genMsg, @@ -726,7 +726,7 @@ STATIC STATUS LONGNS_asciiLenScanNextComponent( } goto foundNextComponent; } - + /* In LONG NameSpace, we allow any number and combination * of trailing slashes. Just strip them all */ while ((srcLength > 0) && @@ -742,7 +742,7 @@ STATIC STATUS LONGNS_asciiLenScanNextComponent( if ((componentSize != 0) && (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed)) { - /* Got a volume name. Quit parsing here. The + /* Got a volume name. Quit parsing here. The * destAsciiComp buffer contains the volume name. * Go translate the volume name to unicode. */ @@ -751,7 +751,7 @@ STATIC STATUS LONGNS_asciiLenScanNextComponent( /* If there is a single slash after the volume override * then just strip it. It is not needed. If there - * is more than one slash it is an invalid path. + * is more than one slash it is an invalid path. */ ch = *srcPtr; if ((srcLength > 0) && ((ch == '/') || (ch == '\\'))) @@ -769,7 +769,7 @@ STATIC STATUS LONGNS_asciiLenScanNextComponent( if ((componentSize != 0) && (srcLength == 0)) { - /* We allow a ":" all by itself if it is the only + /* We allow a ":" all by itself if it is the only * thing in a counted path component */ goto error_InvalidPath; /* Trailing Colon is Illegal */ } @@ -791,7 +791,7 @@ STATIC STATUS LONGNS_asciiLenScanNextComponent( if (((componentSize != 0) && (srcLength == 0)) || ((srcLength > 0) && (*srcPtr == ':'))) { - /* We allow a "::" all by itself if it is the only + /* We allow a "::" all by itself if it is the only * thing in a counted path component */ goto error_InvalidPath; /* Trailing colons and 3+ colons are illegal */ } @@ -867,7 +867,7 @@ function_exit: if (scanMsg->retScanFlags & NSRETSFL_scannedVolumeNameOverride) { - scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; + scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; scanMsg->retUnicodeComp = scanMsg->uniWorkBuffer1; } else @@ -943,7 +943,7 @@ error_Exit: * This function scans a NULL terminated UTF8 string, looking for the next * component. The component will be returned in unicode. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -1105,7 +1105,7 @@ STATIC STATUS LONGNS_utf8ScanNextComponent( if ((!atComponentFront) && (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed)) { - /* Got a volume name. Quit parsing here. The + /* Got a volume name. Quit parsing here. The * destUnicodeComp buffer contains the volume name. */ scanMsg->retScanFlags |= (NSRETSFL_scannedVolumeNameOverride | @@ -1113,7 +1113,7 @@ STATIC STATUS LONGNS_utf8ScanNextComponent( /* If there is a single slash after the volume override * then just strip it. It is not needed. If there - * is more than one slash it is an invalid path. + * is more than one slash it is an invalid path. */ if ((status = LB_UTF8ToUniChar(srcPtr,&nextSrcPtr,&ch)) != zOK) { @@ -1142,7 +1142,7 @@ STATIC STATUS LONGNS_utf8ScanNextComponent( ch = *srcPtr; if ((!atComponentFront) && (ch == 0)) { - /* We allow a ":" all by itself if it is the only + /* We allow a ":" all by itself if it is the only * thing in a counted path component */ goto cleanup_path; /* Trailing colon is illegal */ } @@ -1161,11 +1161,11 @@ STATIC STATUS LONGNS_utf8ScanNextComponent( ch = *srcPtr; if (((!atComponentFront) && (ch == 0)) || (ch == UNI_COLON)) { - /* We allow a "::" all by itself if it is the only + /* We allow a "::" all by itself if it is the only * thing in a counted path component */ goto cleanup_path; /* Trailing colons and 3+ colons are illegal */ } - + /* Double Colon: Change namespace to extended attribute namespace */ scanMsg->retScanFlags |= NSRETSFL_scannedChangeNameSpace; scanMsg->retNextNameSpaceID = zNSPACE_EXTENDED_ATTRIBUTE; @@ -1217,7 +1217,7 @@ STATIC STATUS LONGNS_utf8ScanNextComponent( * we just counted and skipped over. Any combination of * leading dots is legal, so keep all the dots. */ - /* Make sure there is room for all the dots. We already + /* Make sure there is room for all the dots. We already * subtracted one from maxDestSize for the first dot. We * compare against numDots rather than numDots-1, because we * still need to make sure there is room for a trailing NULL @@ -1250,7 +1250,7 @@ STATIC STATUS LONGNS_utf8ScanNextComponent( if ((ch == UNI_WILD_AUG_PERIOD) && (!LONGNS_isUnicodeWildcardChar(ch2))) { - ch = UNI_PERIOD; + ch = UNI_PERIOD; } else if ((!preValidated) && (ch == UNI_PERIOD) && (LONGNS_isUnicodeWildcardChar(ch2))) @@ -1438,7 +1438,7 @@ STATIC STATUS LONGNS_utf8ScanNextComponent( *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; case UNI_VOLUME_ROOT: case UNI_NDS_ROOT: @@ -1448,7 +1448,7 @@ STATIC STATUS LONGNS_utf8ScanNextComponent( (scanMsg->scanFlags & NSSFL_parsingFirstComponent)) { *destUnicodeComp++ = ch; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* Remove a single terminating slash */ if ((status = LB_UTF8ToUniChar(srcPtr,&nextSrcPtr,&ch)) != zOK) @@ -1697,7 +1697,7 @@ error_Exit: * This function scans a UTF8 string with a separate length, looking for the * next component. The component will be returned in unicode. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -1751,7 +1751,7 @@ STATIC STATUS LONGNS_utf8LenScanNextComponent( while ((srcLength > 0) && ((status = LB_UTF8LenToUniChar(srcPtr, srcLength, &nextSrcPtr, &ch, - &nextSrcLength)) == zOK)) + &nextSrcLength)) == zOK)) { /* The "period" processing requires a pointer to the start of the * period. With UTF8 we need this prev ptr to back up */ @@ -1880,7 +1880,7 @@ STATIC STATUS LONGNS_utf8LenScanNextComponent( if ((!atComponentFront) && (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed)) { - /* Got a volume name. Quit parsing here. The + /* Got a volume name. Quit parsing here. The * destUnicodeComp buffer contains the volume name. */ scanMsg->retScanFlags |= (NSRETSFL_scannedVolumeNameOverride | @@ -1888,7 +1888,7 @@ STATIC STATUS LONGNS_utf8LenScanNextComponent( /* If there is a single slash after the volume override * then just strip it. It is not needed. If there - * is more than one slash it is an invalid path. + * is more than one slash it is an invalid path. */ if ((status = LB_UTF8LenToUniChar(srcPtr, srcLength, &nextSrcPtr, &ch, &nextSrcLength)) != zOK) @@ -1920,7 +1920,7 @@ STATIC STATUS LONGNS_utf8LenScanNextComponent( /* Determine the type of change namespace component */ if ((!atComponentFront) && (srcLength == 0)) { - /* We allow a ":" all by itself if it is the only + /* We allow a ":" all by itself if it is the only * thing in a counted path component */ goto cleanup_path; /* Trailing colon is illegal */ } @@ -1940,11 +1940,11 @@ STATIC STATUS LONGNS_utf8LenScanNextComponent( if (((!atComponentFront) && (srcLength == 0)) || ((srcLength != 0) && (*srcPtr == UNI_COLON))) { - /* We allow a "::" all by itself if it is the only + /* We allow a "::" all by itself if it is the only * thing in a counted path component */ goto cleanup_path; /* Trailing colons and 3+ colons are illegal */ } - + /* Double Colon: Change namespace to extended attribute namespace */ scanMsg->retScanFlags |= NSRETSFL_scannedChangeNameSpace; scanMsg->retNextNameSpaceID = zNSPACE_EXTENDED_ATTRIBUTE; @@ -2000,7 +2000,7 @@ STATIC STATUS LONGNS_utf8LenScanNextComponent( * we just counted and skipped over. Any combination of * leading dots is legal, so keep all the dots. */ - /* Make sure there is room for all the dots. We already + /* Make sure there is room for all the dots. We already * subtracted one from maxDestSize for the first dot. We * compare against numDots rather than numDots-1, because we * still need to make sure there is room for a trailing NULL @@ -2036,7 +2036,7 @@ STATIC STATUS LONGNS_utf8LenScanNextComponent( if ((ch == UNI_WILD_AUG_PERIOD) && (!LONGNS_isUnicodeWildcardChar(ch2))) { - ch = UNI_PERIOD; + ch = UNI_PERIOD; } else if ((!preValidated) && (ch == UNI_PERIOD) && (LONGNS_isUnicodeWildcardChar(ch2))) @@ -2241,7 +2241,7 @@ STATIC STATUS LONGNS_utf8LenScanNextComponent( *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; case UNI_VOLUME_ROOT: case UNI_NDS_ROOT: @@ -2251,7 +2251,7 @@ STATIC STATUS LONGNS_utf8LenScanNextComponent( (scanMsg->scanFlags & NSSFL_parsingFirstComponent)) { *destUnicodeComp++ = ch; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* Remove a single terminating slash */ if ((status = LB_UTF8LenToUniChar(srcPtr, srcLength, @@ -2440,7 +2440,7 @@ STATIC STATUS LONGNS_utf8LenScanNextComponent( foundNextComponent: if (srcLength == 0) { - scanMsg->retAsciiSrcPath = NULL; + scanMsg->retAsciiSrcPath = NULL; } else { @@ -2516,11 +2516,11 @@ error_Exit: /************************************************************************** * LONGNS_unicodeScanNextComponent - * + * * This function scans a NULL terminated unicode string, looking for the next * component. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name or wildcard character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -2670,7 +2670,7 @@ STATIC STATUS LONGNS_unicodeScanNextComponent( if ((!atComponentFront) && (scanMsg->scanFlags & NSSFL_volumeNameOverrideAllowed)) { - /* Got a volume name. Quit parsing here. The + /* Got a volume name. Quit parsing here. The * destUnicodeComp buffer contains the volume name. */ scanMsg->retScanFlags |= (NSRETSFL_scannedVolumeNameOverride | @@ -2678,7 +2678,7 @@ STATIC STATUS LONGNS_unicodeScanNextComponent( /* If there is a single slash after the volume override * then just strip it. It is not needed. If there - * is more than one slash it is an invalid path. + * is more than one slash it is an invalid path. */ ch = *srcPtr; if (ch == UNI_PATH_SEPARATOR) @@ -2702,7 +2702,7 @@ STATIC STATUS LONGNS_unicodeScanNextComponent( ch = *srcPtr; if ((!atComponentFront) && (ch == 0)) { - /* We allow a ":" all by itself if it is the only + /* We allow a ":" all by itself if it is the only * thing in a counted path component */ goto cleanup_path; /* Trailing colon is illegal */ } @@ -2721,11 +2721,11 @@ STATIC STATUS LONGNS_unicodeScanNextComponent( ch = *srcPtr; if (((!atComponentFront) && (ch == 0)) || (ch == UNI_COLON)) { - /* We allow a "::" all by itself if it is the only + /* We allow a "::" all by itself if it is the only * thing in a counted path component */ goto cleanup_path; /* Trailing colons and 3+ colons are illegal */ } - + /* Double Colon: Change namespace to extended attribute namespace */ scanMsg->retScanFlags |= NSRETSFL_scannedChangeNameSpace; scanMsg->retNextNameSpaceID = zNSPACE_EXTENDED_ATTRIBUTE; @@ -2771,7 +2771,7 @@ STATIC STATUS LONGNS_unicodeScanNextComponent( * we just counted and skipped over. Any combination of * leading dots is legal, so keep all the dots. */ - /* Make sure there is room for all the dots. We already + /* Make sure there is room for all the dots. We already * subtracted one from maxDestSize for the first dot. We * compare against numDots rather than numDots-1, because we * still need to make sure there is room for a trailing NULL @@ -2795,7 +2795,7 @@ STATIC STATUS LONGNS_unicodeScanNextComponent( if ((ch == UNI_WILD_AUG_PERIOD) && (!LONGNS_isUnicodeWildcardChar(*dotPath))) { - ch = UNI_PERIOD; + ch = UNI_PERIOD; } else if ((!preValidated) && (ch == UNI_PERIOD) && (LONGNS_isUnicodeWildcardChar(*dotPath))) @@ -2969,7 +2969,7 @@ STATIC STATUS LONGNS_unicodeScanNextComponent( *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; case UNI_VOLUME_ROOT: case UNI_NDS_ROOT: @@ -2979,7 +2979,7 @@ STATIC STATUS LONGNS_unicodeScanNextComponent( (scanMsg->scanFlags & NSSFL_parsingFirstComponent)) { *destUnicodeComp++ = ch; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* Remove a single terminating slash */ ch = *srcPtr; @@ -3322,7 +3322,7 @@ STATIC NINT LONGNS_generateUniqueName( if (LONGNS_isLegalName(&tempGenMsg,uniqueName) != zOK) { zASSERT(dstNameAsciiCount + 2 < LONGNS_NAME_LIMIT); - shareable = FALSE; + shareable = FALSE; *dstPtr++ = L'~'; *dstPtr++ = L'1'; dstNameAsciiCount += 2; @@ -3355,7 +3355,7 @@ STATIC NINT LONGNS_generateUniqueName( *---------------------------------------------------------------------------*/ while ((dstNameUniCount > 0) && ((uniqueName[dstNameUniCount-1] == L' ') || - (uniqueName[dstNameUniCount-1] == UNI_PERIOD))) + (uniqueName[dstNameUniCount-1] == UNI_PERIOD))) { shareable = FALSE; dstNameUniCount--; @@ -3381,7 +3381,7 @@ STATIC NINT LONGNS_generateUniqueName( if (LONGNS_isLegalName(&tempGenMsg,uniqueName) != zOK) { zASSERT(dstNameAsciiCount + 2 < LONGNS_NAME_LIMIT); - shareable = FALSE; + shareable = FALSE; *dstPtr++ = L'~'; *dstPtr++ = L'1'; dstNameAsciiCount += 2; @@ -3394,7 +3394,7 @@ STATIC NINT LONGNS_generateUniqueName( * that does not already exist in the directory--modifying the name each * time through the loop... *---------------------------------------------------------------------------*/ - uniqueName[dstNameUniCount] = 0; + uniqueName[dstNameUniCount] = 0; firstDigitUni = dstNameUniCount; firstDigitAscii = dstNameAsciiCount; @@ -3404,7 +3404,7 @@ STATIC NINT LONGNS_generateUniqueName( for (;;) { foundBeastZid = NAME_FindZidForNameInDir(genMsg, directory, - nameSpace, srcNameType, uniqueName, 0, NULL, + nameSpace, srcNameType, uniqueName, 0, NULL, FALSE /* cnt , &dummy*/); if (foundBeastZid == zINVALID_ZID) { @@ -3428,7 +3428,7 @@ STATIC NINT LONGNS_generateUniqueName( /*------------------------------------------------------------------- * The name already exists in the directory. Mangle and try again... *-------------------------------------------------------------------*/ - shareable = FALSE; + shareable = FALSE; /* If at the end of the max length, overrite last byte with digit */ if (firstDigitAscii == LONGNS_NAME_LIMIT) @@ -3493,7 +3493,7 @@ STATIC NINT LONGNS_generateUniqueName( } } } - + /************************************************************************** * This will insert the path SEPARATOR character between path names for this @@ -3536,7 +3536,7 @@ STATIC STATUS LONGNS_getSeparator( } SetErrno(genMsg, zERR_INVALID_PATH_SEPARATOR); return(zFAILURE); -} +} /************************************************************************** @@ -3704,10 +3704,10 @@ STATIC BOOL LONGNS_wildMatch( * An augmented question mark matches any valid character or an end of frame * or a '.', except that on the '.' it doesn't advance beyond it *---------------------------------------------------------------------------*/ - case UNI_WILD_AUG_QMARK: + case UNI_WILD_AUG_QMARK: if ((*name == 0) || (*name == UNI_PERIOD)) { - /* match end of name or match '.' but don't inc */ + /* match end of name or match '.' but don't inc */ break; } name++; @@ -3717,7 +3717,7 @@ STATIC BOOL LONGNS_wildMatch( *---------------------------------------------------------------------------*/ case UNI_WILD_QMARK: if (*name == 0) /* match end of name */ - break; + break; name++; break; @@ -3773,7 +3773,7 @@ STATIC BOOL LONGNS_wildMatch( case UNI_WILD_AUG_PERIOD: if ((*name == 0) || (*name++ == UNI_PERIOD)) { - /* we match our end of name or a period */ + /* we match our end of name or a period */ break; } @@ -3824,7 +3824,7 @@ STATIC STATUS LONGNS_asciiToUnicode( destName, destNameSize, asciiName, - &temp); + &temp); if (status != zOK) { SetErrno(genMsg,status); @@ -3856,7 +3856,7 @@ STATIC STATUS LONGNS_asciiLenToUnicode( destNameSize, asciiName, asciiNameLen, - &temp); + &temp); if (status != zOK) { SetErrno(genMsg,status); diff --git a/include/nwnss/comn/namespace/longNSpace.h b/src/nwnss/comn/namespace/longNSpace.h similarity index 98% rename from include/nwnss/comn/namespace/longNSpace.h rename to src/nwnss/comn/namespace/longNSpace.h index 4bde766..a066d25 100644 --- a/include/nwnss/comn/namespace/longNSpace.h +++ b/src/nwnss/comn/namespace/longNSpace.h @@ -38,7 +38,7 @@ #define _LONGNSPACE_H_ #ifndef _OMNI_H_ -#include +#include #endif /*--------------------------------------------------------------------------- @@ -59,7 +59,7 @@ extern void LONGNS_shutdown( #define LONGNS_isValidUnicodeFileNameChar(_ch,_preValidated) \ ( (!IS_UNICODE_AUG_WILDCARD_CHAR(_ch)) && \ ( (_preValidated) || \ - ( (!IS_INVALID_UNICODE_CHAR(_ch)) && \ + ( (!IS_INVALID_UNICODE_CHAR(_ch)) && \ ( ((_ch) >= 128) || \ (TST_BIT(LONGNS_ValidCharBitMap,(_ch))))))) @@ -112,7 +112,7 @@ extern NINT LONGNS_generateUniqueName( extern STATUS LONGNS_getSeparator( GeneralMsg_s *genMsg, - NINT type, + NINT type, unicode_t **retStr, NINT *retLen); diff --git a/src/nwnss/comn/namespace/macNSpace.c b/src/nwnss/comn/namespace/macNSpace.c index 5508d7f..d699652 100644 --- a/src/nwnss/comn/namespace/macNSpace.c +++ b/src/nwnss/comn/namespace/macNSpace.c @@ -34,6 +34,7 @@ | This module is used to: | This is the MACNameSpace code +-------------------------------------------------------------------------*/ +#include #include "comnPublics.h" #include @@ -59,7 +60,7 @@ /**************************************************************************** * STATIC initialization of a nsOps table for the MAC Namespace *****************************************************************************/ -STATIC NameSpaceOps_s MACNsOps = +STATIC NameSpaceOps_s MACNsOps = { MACNS_asciiScanNextComponent, MACNS_asciiLenScanNextComponent, @@ -83,9 +84,9 @@ STATIC NameSpaceOps_s MACNsOps = }; /***** fixfixfix@nextMediaFormatChange begin *******/ -/* At the next media format change, only the extended Mac namespace will - * will be supported at the volume level and we can change this check - * to only do the second one - the one based on the 255 limit. +/* At the next media format change, only the extended Mac namespace will + * will be supported at the volume level and we can change this check + * to only do the second one - the one based on the 255 limit. * If you wanted, you could drop the second parameter (nameLimitLen) to this call. */ BOOL MACNS_isValidAndMappableUnicodeFileNameChar (unicode_t ch, int nameLimitLen) @@ -115,9 +116,9 @@ STATUS MACNS_Startup( * First, register our metadata packing functions *---------------------------------------------------------------------------*/ if (COMN_RegisterRootVariableDataType( genMsg, RVD_MAC_META_DATA, - (RVD_PackedSizeFunc_t)MACNS_PackedSizeRootVariableData, + (RVD_PackedSizeFunc_t)MACNS_PackedSizeRootVariableData, (RVD_PackFunc_t)MACNS_PackRootVariableData, - (RVD_UnpackFunc_t)MACNS_UnpackRootVariableData, + (RVD_UnpackFunc_t)MACNS_UnpackRootVariableData, (RVD_FreeFunc_t)MACNS_FreeRootVariableData, NULL, NULL) != zOK) { @@ -128,9 +129,9 @@ STATUS MACNS_Startup( * Now, register the namespace itself *---------------------------------------------------------------------------*/ ns = COMN_RegisterNameSpace(genMsg,NAMESPACE_VERSION, - zNSPACE_MAC, - (1<retScanFlags |= NSRETSFL_componentIsUnicode; goto foundNextComponent; } - + scanMsg->retScanFlags |= NSRETSFL_componentMustBeDirectory; goto foundNextComponent; @@ -386,7 +387,7 @@ error_Exit: * next component. The component may be returned in ASCII or unicode, * depending on the type of component. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name or wildcard character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -395,7 +396,7 @@ error_Exit: * * If any doublebyte, wildcard or other special combinations of characters are * encountered, this function converts the scanned component to unicode - * and does a full semantic parsing operation on it before returning. + * and does a full semantic parsing operation on it before returning. * * If the component is made up of normal everyday characters, this function * leaves the component in ASCII and does not do a full semantic parse. This @@ -404,7 +405,7 @@ error_Exit: * the caller does not find the name in the ASCII name cache, the name would * then need to be translated to Unicode and a full unicode scan would need * to be done before it can be used. - * + * ***************************************************************************/ STATIC STATUS MACNS_asciiLenScanNextComponent( GeneralMsg_s *genMsg, @@ -498,7 +499,7 @@ STATIC STATUS MACNS_asciiLenScanNextComponent( scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; goto foundNextComponent; } - + scanMsg->retScanFlags |= NSRETSFL_componentMustBeDirectory; goto foundNextComponent; @@ -632,7 +633,7 @@ error_Exit: * This function scans a NULL terminated UTF8 string, looking for the next * component. The component will be returned in unicode. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -660,7 +661,7 @@ STATIC STATUS MACNS_utf8ScanNextComponent( scanMsg->retScanFlags = 0; /***** fixfixfix@nextMediaFormatChange begin *******/ -/* At the next media format change, only the extended Mac namespace will +/* At the next media format change, only the extended Mac namespace will * will be supported at the volume level. This check could be replaced * with the following line: * lenlimit = MACNS_NAME_LIMIT; */ @@ -760,7 +761,7 @@ STATIC STATUS MACNS_utf8ScanNextComponent( else { /* Strip the path separator(s) */ - srcPtr = nextSrcPtr; + srcPtr = nextSrcPtr; } dirSpecified = TRUE; @@ -792,14 +793,14 @@ STATIC STATUS MACNS_utf8ScanNextComponent( else { /* Strip the path separator(s) */ - srcPtr = nextSrcPtr; + srcPtr = nextSrcPtr; } /* Stuff the "previousDir" in the target path. */ *destUnicodeComp++ = UNI_PREVIOUS_DIR; *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; case UNI_VOLUME_ROOT: case UNI_NDS_ROOT: @@ -809,7 +810,7 @@ STATIC STATUS MACNS_utf8ScanNextComponent( (scanMsg->scanFlags & NSSFL_parsingFirstComponent)) { *destUnicodeComp++ = ch; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* Remove a single optional terminating colon */ if ((status = LB_UTF8ToUniChar(srcPtr,&nextSrcPtr,&ch2)) != zOK) @@ -1022,7 +1023,7 @@ error_Exit: * This function scans a UTF8 string with a separate length, looking for the * next component. The component will be returned in unicode. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -1053,7 +1054,7 @@ STATIC STATUS MACNS_utf8LenScanNextComponent( /***** fixfixfix@nextMediaFormatChange begin*******/ -/* At the next media format change, only the extended Mac namespace will +/* At the next media format change, only the extended Mac namespace will * will be supported at the volume level. This check could be replaced * with the following line: * lenlimit = MACNS_NAME_LIMIT; */ @@ -1078,7 +1079,7 @@ STATIC STATUS MACNS_utf8LenScanNextComponent( while ((srcLength > 0) && ((status = LB_UTF8LenToUniChar(srcPtr, srcLength, &srcPtr, &ch, - &srcLength)) == zOK)) + &srcLength)) == zOK)) { /* * Process a colon in the path string. @@ -1165,7 +1166,7 @@ STATIC STATUS MACNS_utf8LenScanNextComponent( else { /* Strip the path separator(s) */ - srcPtr = nextSrcPtr; + srcPtr = nextSrcPtr; srcLength = nextSrcLength; } dirSpecified = TRUE; @@ -1198,7 +1199,7 @@ STATIC STATUS MACNS_utf8LenScanNextComponent( else { /* Strip the path separator(s) */ - srcPtr = nextSrcPtr; + srcPtr = nextSrcPtr; srcLength = nextSrcLength; } /* Stuff the "previousDir" in the target path. */ @@ -1206,7 +1207,7 @@ STATIC STATUS MACNS_utf8LenScanNextComponent( *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; case UNI_VOLUME_ROOT: case UNI_NDS_ROOT: @@ -1216,7 +1217,7 @@ STATIC STATUS MACNS_utf8LenScanNextComponent( (scanMsg->scanFlags & NSSFL_parsingFirstComponent)) { *destUnicodeComp++ = ch; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* Remove a single optional terminating colon */ if ((status = LB_UTF8LenToUniChar(srcPtr, srcLength, @@ -1443,11 +1444,11 @@ error_Exit: /************************************************************************** * MACNS_unicodeScanNextComponent - * + * * This function scans a NULL terminated unicode string, looking for the next * component. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name or wildcard character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -1481,7 +1482,7 @@ STATIC STATUS MACNS_unicodeScanNextComponent( scanMsg->retScanFlags = 0; /***** fixfixfix@nextMediaFormatChange begin *******/ -/* At the next media format change, only the extended Mac namespace will +/* At the next media format change, only the extended Mac namespace will * will be supported at the volume level. This check could be replaced * with the following line: * lenlimit = MACNS_NAME_LIMIT; */ @@ -1604,7 +1605,7 @@ STATIC STATUS MACNS_unicodeScanNextComponent( *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; case UNI_VOLUME_ROOT: case UNI_NDS_ROOT: @@ -1614,7 +1615,7 @@ STATIC STATUS MACNS_unicodeScanNextComponent( (scanMsg->scanFlags & NSSFL_parsingFirstComponent)) { *destUnicodeComp++ = ch; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* Remove a single optional terminating colon */ ch2 = *srcPtr; @@ -1855,10 +1856,10 @@ STATIC NINT MACNS_generateUniqueName( *---------------------------------------------------------------------------*/ /***** fixfixfix@nextMediaFormatChange begin *******/ -/* At the next media format change, only the extended Mac namespace will +/* At the next media format change, only the extended Mac namespace will * will be supported at the volume level. This check could be replaced * with the following line: - * nameLimitLen = MACNS_NAME_LIMIT; + * nameLimitLen = MACNS_NAME_LIMIT; * or eliminate variable completely and just use define */ if (directory->root.vol.volume->p.enabledAttributes & zATTR_EXTENDED_MAC_NAMESPACE) @@ -1914,7 +1915,7 @@ STATIC NINT MACNS_generateUniqueName( *---------------------------------------------------------------------------*/ if (dstNameAsciiCount == 0) { - shareable = FALSE; + shareable = FALSE; } /*--------------------------------------------------------------------------- * We have a syntax-valid dest name. Null terminate it, and then begin the @@ -1930,7 +1931,7 @@ STATIC NINT MACNS_generateUniqueName( goto nameFailedExit; if (MACNS_isLegalName(NULL,uniqueName) != zOK) - shareable = FALSE; + shareable = FALSE; /*--------------------------------------------------------------------------- * if shareable is TRUE then uniqueName is unmodified from the original @@ -1983,7 +1984,7 @@ STATIC NINT MACNS_generateUniqueName( uniqueName[tildeIdx+1]++; /* Try next ~1, ~2, ~`3, or ~4 char */ foundBeastZid = NAME_FindZidForNameInDir(genMsg, directory, - nameSpace, srcNameType, uniqueName, 0, NULL, + nameSpace, srcNameType, uniqueName, 0, NULL, FALSE /* cnt, &dummy*/); if (foundBeastZid == zINVALID_ZID) { @@ -2064,7 +2065,7 @@ STATIC NINT MACNS_generateUniqueName( } /*--------------------------------------------------------------------------- - * We failed with the 4char hash. Now, as a last resort, replace last 6 + * We failed with the 4char hash. Now, as a last resort, replace last 6 * filename characters with ~ + 5 characters of hash generated characters * (0..9,A..F) * @@ -2170,7 +2171,7 @@ STATIC STATUS MACNS_getSeparator( } SetErrno(genMsg,zERR_INVALID_PATH_SEPARATOR); return zFAILURE; -} +} /************************************************************************** @@ -2338,7 +2339,7 @@ STATIC STATUS MACNS_asciiToUnicode( destName, destNameSize, asciiName, - &temp); + &temp); if (status != zOK) { SetErrno(genMsg,status); @@ -2367,7 +2368,7 @@ STATIC STATUS MACNS_asciiLenToUnicode( destNameSize, asciiName, asciiNameLen, - &temp); + &temp); if (status != zOK) { SetErrno(genMsg,status); @@ -2496,7 +2497,7 @@ STATIC STATUS MACNS_modifyInfo( /* Completely replace the zMacInfo_s with the new data--All fields */ memcpy((*beast->NAMEDvariableData)[RVD_MAC_META_DATA], &modifyMsg->modifyInfo->macNS, sizeof(zMacInfo_s)); - + return(zOK); } @@ -2508,7 +2509,7 @@ STATIC NINT MACNS_PackedSizeRootVariableData( { if ((*beast->variableData)[RVD_MAC_META_DATA] == NULL) return 0; - else + else return (sizeof(PackedMacInfo_s)); } @@ -2554,7 +2555,7 @@ STATIC BYTE *MACNS_UnpackRootVariableData( if (COMN_InitRootVariableData(genMsg, beast) != zOK) return NULL; - + (*beast->ROOTvariableData)[RVD_MAC_META_DATA] = malloc(sizeof(zMacInfo_s)); if (((*beast->ROOTvariableData)[RVD_MAC_META_DATA]) == NULL) { diff --git a/src/nwnss/comn/namespace/nameSpace.c b/src/nwnss/comn/namespace/nameSpace.c index 61d6f60..95438e7 100644 --- a/src/nwnss/comn/namespace/nameSpace.c +++ b/src/nwnss/comn/namespace/nameSpace.c @@ -55,9 +55,9 @@ /**************************************************************************** **************************************************************************** - * + * * Global Array that defines the active name spaces. - * + * ***************************************************************************** *****************************************************************************/ NameSpace_s *NameSpaces[MAX_NUM_NSPACES]; @@ -88,16 +88,16 @@ STATUS NSPACE_Startup( if (UNIXNS_Startup(genMsg) != zOK) goto ErrorHandler; - + if (DSNS_Startup(genMsg) != zOK) goto ErrorHandler; - + if (EANS_Startup(genMsg) != zOK) goto ErrorHandler; - + if (MACNS_Startup(genMsg) != zOK) goto ErrorHandler; - + return zOK; ErrorHandler: @@ -229,7 +229,7 @@ NameSpace_s *COMN_RegisterNameSpace( } STACK_FREE(); return NULL; - } + } } NameSpaces[nameSpaceID] = ns; /*--------------------------------------------------------------------------- @@ -316,11 +316,11 @@ unicode_t *COMN_GetDisplayableNameSpaceList( NameSpace_s *ns; NINT strlen = 0; ASSERT_MPKNSS_LOCK(); - + if (retNameListSize <= 1) { return retNameList; - } + } for (i=0;i <= MaxRegisteredNameSpaceID;i++) { /* for now SKIP the display of these name spaces */ diff --git a/include/nwnss/comn/namespace/nspaceStartup.h b/src/nwnss/comn/namespace/nspaceStartup.h similarity index 98% rename from include/nwnss/comn/namespace/nspaceStartup.h rename to src/nwnss/comn/namespace/nspaceStartup.h index e766a5d..ae33b39 100644 --- a/include/nwnss/comn/namespace/nspaceStartup.h +++ b/src/nwnss/comn/namespace/nspaceStartup.h @@ -38,7 +38,7 @@ #define _NSPACESTARTUP_H_ #ifndef _OMNI_H_ -#include +#include #endif diff --git a/src/nwnss/comn/namespace/unixNSpace.c b/src/nwnss/comn/namespace/unixNSpace.c index 7b981f6..46e0dc6 100644 --- a/src/nwnss/comn/namespace/unixNSpace.c +++ b/src/nwnss/comn/namespace/unixNSpace.c @@ -33,6 +33,7 @@ | This module is used to: | This is the LONGNameSpace code +-------------------------------------------------------------------------*/ +#include #include "comnPublics.h" #include #include @@ -57,7 +58,7 @@ /**************************************************************************** * STATIC initialization of a nsOps table for the UNIX Namespace *****************************************************************************/ -STATIC NameSpaceOps_s unixNsOps = +STATIC NameSpaceOps_s unixNsOps = { UNIXNS_asciiScanNextComponent, UNIXNS_asciiLenScanNextComponent, @@ -93,9 +94,9 @@ STATUS UNIXNS_Startup( * First, register our metadata packing functions *---------------------------------------------------------------------------*/ if (COMN_RegisterRootVariableDataType( genMsg, RVD_UNIX_META_DATA, - (RVD_PackedSizeFunc_t)UNIXNS_PackedSizeRootVariableData, + (RVD_PackedSizeFunc_t)UNIXNS_PackedSizeRootVariableData, (RVD_PackFunc_t)UNIXNS_PackRootVariableData, - (RVD_UnpackFunc_t)UNIXNS_UnpackRootVariableData, + (RVD_UnpackFunc_t)UNIXNS_UnpackRootVariableData, (RVD_FreeFunc_t)UNIXNS_FreeRootVariableData, NULL, NULL) != zOK) { @@ -142,7 +143,7 @@ void UNIXNS_Shutdown( * component. The component may be returned in ASCII or unicode, depending * on the type of component. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -151,7 +152,7 @@ void UNIXNS_Shutdown( * * If any doublebyte, or other special combinations of characters are * encountered, this function converts the scanned component to unicode - * and does a full semantic parsing operation on it before returning. + * and does a full semantic parsing operation on it before returning. * * If the component is made up of normal everyday characters, this function * leaves the component in ASCII and does not do a full semantic parse. This @@ -160,7 +161,7 @@ void UNIXNS_Shutdown( * the caller does not find the name in the ASCII name cache, the name would * then need to be translated to Unicode and a full unicode scan would need * to be done before it can be used. - * + * ***************************************************************************/ STATIC STATUS UNIXNS_asciiScanNextComponent( GeneralMsg_s *genMsg, @@ -249,7 +250,7 @@ STATIC STATUS UNIXNS_asciiScanNextComponent( scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; goto foundNextComponent; } - + scanMsg->retScanFlags |= NSRETSFL_componentMustBeDirectory; goto foundNextComponent; @@ -376,7 +377,7 @@ error_Exit: * next component. The component may be returned in ASCII or unicode, * depending on the type of component. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -385,7 +386,7 @@ error_Exit: * * If any doublebyte or other special combinations of characters are * encountered, this function converts the scanned component to unicode - * and does a full semantic parsing operation on it before returning. + * and does a full semantic parsing operation on it before returning. * * If the component is made up of normal everyday characters, this function * leaves the component in ASCII and does not do a full semantic parse. This @@ -394,7 +395,7 @@ error_Exit: * the caller does not find the name in the ASCII name cache, the name would * then need to be translated to Unicode and a full unicode scan would need * to be done before it can be used. - * + * ***************************************************************************/ STATIC STATUS UNIXNS_asciiLenScanNextComponent( GeneralMsg_s *genMsg, @@ -489,7 +490,7 @@ STATIC STATUS UNIXNS_asciiLenScanNextComponent( scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; goto foundNextComponent; } - + scanMsg->retScanFlags |= NSRETSFL_componentMustBeDirectory; goto foundNextComponent; @@ -634,7 +635,7 @@ error_Exit: * This function scans a NULL terminated UTF8 string, looking for the next * component. The component will be returned in unicode. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -779,7 +780,7 @@ STATIC STATUS UNIXNS_utf8ScanNextComponent( *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; } } @@ -809,7 +810,7 @@ STATIC STATUS UNIXNS_utf8ScanNextComponent( else { /* Strip the path separator(s) */ - srcPtr = nextSrcPtr; + srcPtr = nextSrcPtr; } dirSpecified = TRUE; @@ -841,14 +842,14 @@ STATIC STATUS UNIXNS_utf8ScanNextComponent( else { /* Strip the path separator(s) */ - srcPtr = nextSrcPtr; + srcPtr = nextSrcPtr; } /* Stuff the "previousDir" in the target path. */ *destUnicodeComp++ = UNI_PREVIOUS_DIR; *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; case UNI_VOLUME_ROOT: case UNI_NDS_ROOT: @@ -858,7 +859,7 @@ STATIC STATUS UNIXNS_utf8ScanNextComponent( (scanMsg->scanFlags & NSSFL_parsingFirstComponent)) { *destUnicodeComp++ = ch; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* Remove a single optional terminating slash */ if ((status = LB_UTF8ToUniChar(srcPtr,&nextSrcPtr,&ch2)) != zOK) @@ -1072,13 +1073,13 @@ error_Exit: * This function scans a UTF8 string with a separate length, looking for the * next component. The component will be returned in unicode. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name character, then this function returns an error. * * If the character is a component separator, this function stops scanning, * sets up the return message to indicate the type of separator that was found * and returns successful. (The separators are stripped from the buffer) - * + * ***************************************************************************/ STATIC STATUS UNIXNS_utf8LenScanNextComponent( GeneralMsg_s *genMsg, @@ -1116,7 +1117,7 @@ STATIC STATUS UNIXNS_utf8LenScanNextComponent( while ((srcLength > 0) && ((status = LB_UTF8LenToUniChar(srcPtr, srcLength, &srcPtr, &ch, - &srcLength)) == zOK)) + &srcLength)) == zOK)) { /* * Process a slash in the path string. @@ -1236,7 +1237,7 @@ STATIC STATUS UNIXNS_utf8LenScanNextComponent( *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; } } @@ -1267,7 +1268,7 @@ STATIC STATUS UNIXNS_utf8LenScanNextComponent( else { /* Strip the path separator(s) */ - srcPtr = nextSrcPtr; + srcPtr = nextSrcPtr; srcLength = nextSrcLength; } dirSpecified = TRUE; @@ -1301,7 +1302,7 @@ STATIC STATUS UNIXNS_utf8LenScanNextComponent( else { /* Strip the path separator(s) */ - srcPtr = nextSrcPtr; + srcPtr = nextSrcPtr; srcLength = nextSrcLength; } /* Stuff the "previousDir" in the target path. */ @@ -1309,7 +1310,7 @@ STATIC STATUS UNIXNS_utf8LenScanNextComponent( *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; case UNI_VOLUME_ROOT: case UNI_NDS_ROOT: @@ -1319,7 +1320,7 @@ STATIC STATUS UNIXNS_utf8LenScanNextComponent( (scanMsg->scanFlags & NSSFL_parsingFirstComponent)) { *destUnicodeComp++ = ch; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* Remove a single optional terminating slash */ if ((status = LB_UTF8LenToUniChar(srcPtr, srcLength, @@ -1547,11 +1548,11 @@ error_Exit: /************************************************************************** * UNIXNS_unicodeScanNextComponent - * + * * This function scans a NULL terminated unicode string, looking for the next * component. * - * It scans forward one character at a time. If the character is not a + * It scans forward one character at a time. If the character is not a * valid file name character, then this function returns an error. * * If the character is a component separator, this function stops scanning, @@ -1692,7 +1693,7 @@ STATIC STATUS UNIXNS_unicodeScanNextComponent( *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; } } @@ -1755,7 +1756,7 @@ STATIC STATUS UNIXNS_unicodeScanNextComponent( *destUnicodeComp++ = 0; /* flag as a fully parsed component */ scanMsg->retScanFlags |= NSRETSFL_componentIsUnicode; - goto foundNextComponent; + goto foundNextComponent; case UNI_VOLUME_ROOT: case UNI_NDS_ROOT: @@ -1765,7 +1766,7 @@ STATIC STATUS UNIXNS_unicodeScanNextComponent( (scanMsg->scanFlags & NSSFL_parsingFirstComponent)) { *destUnicodeComp++ = ch; - *destUnicodeComp++ = 0; + *destUnicodeComp++ = 0; /* Remove a single optional terminating slash */ ch2 = *srcPtr; @@ -2049,7 +2050,7 @@ STATIC NINT UNIXNS_generateUniqueName( *---------------------------------------------------------------------------*/ if (dstNameAsciiCount == 0) { - shareable = FALSE; + shareable = FALSE; } /*--------------------------------------------------------------------------- * We have a syntax-valid dest name. Null terminate it, and then begin the @@ -2065,7 +2066,7 @@ STATIC NINT UNIXNS_generateUniqueName( goto nameFailedExit; if (UNIXNS_isLegalName(NULL,uniqueName) != zOK) - shareable = FALSE; + shareable = FALSE; /*--------------------------------------------------------------------------- * if shareable is TRUE then uniqueName is unmodified from the original @@ -2118,7 +2119,7 @@ STATIC NINT UNIXNS_generateUniqueName( uniqueName[tildeIdx+1]++; /* Try next ~1, ~2, ~`3, or ~4 char */ foundBeastZid = NAME_FindZidForNameInDir(genMsg, directory, - nameSpace, srcNameType, uniqueName, 0, NULL, + nameSpace, srcNameType, uniqueName, 0, NULL, FALSE/* cnt, &dummy*/); if (foundBeastZid == zINVALID_ZID) { @@ -2199,7 +2200,7 @@ STATIC NINT UNIXNS_generateUniqueName( } /*--------------------------------------------------------------------------- - * We failed with the 4char hash. Now, as a last resort, replace last 6 + * We failed with the 4char hash. Now, as a last resort, replace last 6 * filename characters with ~ + 5 characters of hash generated characters * (0..9,A..F) * @@ -2301,7 +2302,7 @@ STATIC STATUS UNIXNS_getSeparator( } SetErrno(genMsg,zERR_INVALID_PATH_SEPARATOR); return zFAILURE; -} +} /************************************************************************** @@ -2517,7 +2518,7 @@ STATIC STATUS UNIXNS_asciiToUnicode( destName, destNameSize, asciiName, - &temp); + &temp); if (status != zOK) { SetErrno(genMsg,status); @@ -2549,7 +2550,7 @@ STATIC STATUS UNIXNS_asciiLenToUnicode( destNameSize, asciiName, asciiNameLen, - &temp); + &temp); if (status != zOK) { SetErrno(genMsg,status); @@ -2755,7 +2756,7 @@ STATIC STATUS UNIXNS_modifyInfo( newVariableSize); } } - + return(zOK); } @@ -2771,7 +2772,7 @@ STATIC NINT UNIXNS_PackedSizeRootVariableData( unixInfo = (zUnixInfo_s *)(*beast->ROOTvariableData)[RVD_UNIX_META_DATA]; if (unixInfo == NULL) return 0; - else + else return (sizeof(PackedUnixInfo_s) + unixInfo->variableSize); } @@ -2794,7 +2795,7 @@ STATIC BYTE *UNIXNS_PackRootVariableData( { packedInfo->rvdID = RVD_UNIX_META_DATA; packedInfo->rvdLayout = UNIX_METADATA_LAYOUT; - memcpy(&packedInfo->unixInfo, unixInfo, + memcpy(&packedInfo->unixInfo, unixInfo, (sizeof(zUnixInfo_s) + unixInfo->variableSize)); return (storeBuffer + sizeof(PackedUnixInfo_s) + unixInfo->variableSize); @@ -2817,7 +2818,7 @@ STATIC BYTE *UNIXNS_UnpackRootVariableData( if (COMN_InitRootVariableData(genMsg, beast) != zOK) return NULL; - + zASSERT(packedInfo->rvdID == RVD_UNIX_META_DATA); /* @@ -2854,7 +2855,7 @@ STATIC BYTE *UNIXNS_UnpackRootVariableData( /* Mark the beast "messy" so it will get flushed back to disk */ COMN_MARK_BEAST_MESSY(beast); - + return (storeBuffer + sizeof(PackedUnixInfo_Layout1_s)); } diff --git a/include/nwnss/comn/pssStartup.h b/src/nwnss/comn/pssStartup.h similarity index 98% rename from include/nwnss/comn/pssStartup.h rename to src/nwnss/comn/pssStartup.h index ccaa6fc..8258574 100644 --- a/include/nwnss/comn/pssStartup.h +++ b/src/nwnss/comn/pssStartup.h @@ -38,18 +38,18 @@ #define _PSSSTARTUP_H_ #ifndef _OMNI_H_ -# include +# include #endif #ifndef _MSGGEN_H_ -# include +# include #endif /* Pre-define struct(s) so Linux compiler doesn't complain */ struct AdminVolume_s; #define MODULE_NAME MSGNot("COMN") -extern const char Module[]; +extern const char Module[]; extern NINT CMN_StartupCompleted; extern NINT CMN_Shutdown; diff --git a/include/nwnss/include/purgeDir.h b/src/nwnss/comn/purgeDir.h similarity index 100% rename from include/nwnss/include/purgeDir.h rename to src/nwnss/comn/purgeDir.h diff --git a/src/nwnss/comn/sbs/sbsMFL.c b/src/nwnss/comn/sbs/sbsMFL.c index 1f65c8e..34be817 100644 --- a/src/nwnss/comn/sbs/sbsMFL.c +++ b/src/nwnss/comn/sbs/sbsMFL.c @@ -56,7 +56,7 @@ void SBS_markFileModified( - File_s *file, + File_s *file, NINT archiveBitsToSet, Xaction_s *xaction) { @@ -81,7 +81,7 @@ SBS_markFileModified( localXaction); if (status != zOK) { - /* If entry already exists, keep the entry. Don't modify it + /* If entry already exists, keep the entry. Don't modify it * Otherwise mark the MFL incomplete */ if (GetErrno(&genMsg) != zERR_FILE_ALREADY_EXISTS) { @@ -158,7 +158,7 @@ SBS_markFileModifiedAsync(File_s *file) BEASTHASH_incrementUseCount(&file->FILEroot); FSMLITE_INIT(fsm, "FSM for MFL operation", 0); - WORK_Schedule(fsm, (voidfunc_t)SBS_markFileModifiedWorkToDoRun, (ADDR)file); + WORK_Schedule(fsm, SBS_markFileModifiedWorkToDoRun, (ADDR)file); } /* @@ -198,7 +198,7 @@ SBS_markFileUnmodifiedAsync(File_s *file) return; BEASTHASH_incrementUseCount(&file->FILEroot); FSMLITE_INIT(fsm, "FSM for MFL operation", 0); - WORK_Schedule(fsm, (voidfunc_t)SBS_markFileUnmodifiedWorkToDoRun, (ADDR)file); + WORK_Schedule(fsm, SBS_markFileUnmodifiedWorkToDoRun, (ADDR)file); } #if 0 @@ -219,7 +219,7 @@ typedef struct MFLVerifyStats_s #define MAX_ZIDS_PER_SCOOP 100 STATIC void SBS_verifyMFL( - Volume_s *volume, + Volume_s *volume, MFLVerifyStats_s *verifyStats, /* out */ BOOL doFix) { @@ -239,7 +239,7 @@ SBS_verifyMFL( if (doFix) SBS_fixingMFL = TRUE; - do + do { /* Make sure the volume is in active state */ if ((volume->state != zVOLSTATE_ACTIVE) || @@ -253,8 +253,8 @@ SBS_verifyMFL( numBeastsReturned = MAX_ZIDS_PER_SCOOP; /* Obtain a scoop of ZIDs to examine */ - rc = volume->VOLcomnVolOps.VOL_browseBeastsInVolume(&genMsg, volume, - SELECT_BEASTS_ALL, MAX_ZIDS_PER_SCOOP, + rc = volume->VOLcomnVolOps.VOL_browseBeastsInVolume(&genMsg, volume, + SELECT_BEASTS_ALL, MAX_ZIDS_PER_SCOOP, &lastZidReturned, beastZids, &numBeastsReturned); if (rc != zOK) { @@ -266,7 +266,7 @@ SBS_verifyMFL( for (i = 0; i < numBeastsReturned; ++ i) { /* Obtain the file */ - file = (File_s *)COMN_LookupByZid(&genMsg, volume, + file = (File_s *)COMN_LookupByZid(&genMsg, volume, beastZids[i], SLATCHED, TRUE); /* Ignore all errors */ @@ -298,8 +298,8 @@ SBS_verifyMFL( file->FILEvolume->VOLepoch, localXaction); if (status != zOK) { - /* If entry already exists, keep the entry. - * Don't modify it. + /* If entry already exists, keep the entry. + * Don't modify it. * Otherwise mark the MFL incomplete */ if (GetErrno(&genMsg) != zERR_FILE_ALREADY_EXISTS) { @@ -326,8 +326,8 @@ SBS_verifyMFL( &epoch, localXaction); if (status != zOK) { - /* If entry already exists, keep the entry. - * Don't modify it. + /* If entry already exists, keep the entry. + * Don't modify it. * Otherwise mark the MFL incomplete */ if (GetErrno(&genMsg) != zERR_ZID_NOT_FOUND) { @@ -393,7 +393,7 @@ SBS_enumerateMFL( GeneralMsg_s gm, *genMsg; #endif /* 0 */ typedef struct Stack_s { - MFLEntry_s mflEntries[MAX_MFL_ENTRIES_PER_SCOOP]; + MFLEntry_s mflEntries[MAX_MFL_ENTRIES_PER_SCOOP]; NamingMsg_s nameMsg; GetNameMsg_s gfnMsg; zGetName_s nameBuffer; @@ -441,7 +441,7 @@ SBS_enumerateMFL( { if (numEntriesRequested > MAX_MFL_ENTRIES_PER_SCOOP) numEntriesRequested = MAX_MFL_ENTRIES_PER_SCOOP; - rc = volume->VOLcomnVolOps.VOL_enumerateMFL(genMsg, volume, + rc = volume->VOLcomnVolOps.VOL_enumerateMFL(genMsg, volume, volume->VOLepoch + 1, numEntriesRequested, &lastZidReturned, aStack->mflEntries, &numEntriesObtained, &mflIncompleteFlag); if (rc != zOK) @@ -453,9 +453,9 @@ SBS_enumerateMFL( for (i = 0; i < numEntriesObtained; ++ i) { COMN_SETUP_NAMING_MSG_VOLUME_ZID( &aStack->nameMsg, volume->volumeID, - /* cnt zFNU_FIRST_PARENT,*/ zINVALID_ZID, aStack->mflEntries[i].key.zid, + /* cnt zFNU_FIRST_PARENT,*/ zINVALID_ZID, aStack->mflEntries[i].key.zid, aStack->mflEntries[i].key.zid, SLATCHED, nameSpaceID, zNTYPE_FILE, - NULL); + NULL); rc = COMN_GetName(genMsg, &aStack->nameMsg, &aStack->gfnMsg); COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS_KEEP_LATCHTYPE(&aStack->nameMsg); aStack->nameMsg.parseFlags &= ~NAMPFL_nameMsgFullyResolved; @@ -470,7 +470,7 @@ SBS_enumerateMFL( nameLen = strlen((BYTE *)&aStack->nameBuffer.variableData[0]) + 1; break; case zPFMT_UNICODE: - nameLen = sizeof(unicode_t) * + nameLen = sizeof(unicode_t) * (unilen((unicode_t *)&aStack->nameBuffer.variableData[0]) +1); break; @@ -479,14 +479,14 @@ SBS_enumerateMFL( rc = zFAILURE; goto done; } - fileDescLen = ALIGN((offsetof(ModifiedFileDesc_s, pathName) + + fileDescLen = ALIGN((offsetof(ModifiedFileDesc_s, pathName) + nameLen), sizeof(QUAD)); if ((((BYTE *)fileDesc - dataBuf) + fileDescLen) <= bufSize) { lastZidReturned = fileDesc->fileZid = aStack->mflEntries[i].key.zid; fileDesc->size = fileDescLen; fileDesc->pathNameBytes = nameLen; - memmove(&fileDesc->pathName[0], &aStack->nameBuffer.variableData[0], + memmove(&fileDesc->pathName[0], &aStack->nameBuffer.variableData[0], nameLen); ++ *numFilesReturned; fileDesc = (ModifiedFileDesc_s *) diff --git a/src/nwnss/comn/sbs/sbsMgmt.c b/src/nwnss/comn/sbs/sbsMgmt.c index 39d136a..3853846 100644 --- a/src/nwnss/comn/sbs/sbsMgmt.c +++ b/src/nwnss/comn/sbs/sbsMgmt.c @@ -59,15 +59,15 @@ typedef struct MFLControlCookie_s { // Volume_s *volume; NINT currentOp; -#define MFL_OP_NONE 0 -#define MFL_OP_ENUMERATE 1 -#define MFL_OP_GET_STATUS 2 -#define MFL_OP_VERIFY 3 +#define MFL_OP_NONE 0 +#define MFL_OP_ENUMERATE 1 +#define MFL_OP_GET_STATUS 2 +#define MFL_OP_VERIFY 3 #define MFL_OP_REPAIR 4 #define MFL_OP_END 99 - union + union { - struct + struct { BOOL isDynamic; /* include files modified during enumeration? */ NINT nameSpaceID; /* use this name space for returning path names */ @@ -89,7 +89,7 @@ void cleanupMFLControlCookie( { return; -// MFLControlCookie_s *mflCookie = +// MFLControlCookie_s *mflCookie = // (MFLControlCookie_s *)virtInfo->memPtr; // // if (mflCookie == NULL) @@ -121,7 +121,7 @@ STATUS allocateCookie( mflCookie->currentOp = MFL_OP_NONE; } return zOK; -} +} /**************************************************************************** * Send whatever is in the result buffer. Return TRUE if we filled the @@ -197,7 +197,7 @@ STATUS SBS_volumeMFLControlReadFunc( } mflCookie = (MFLControlCookie_s *)virtInfo->memPtr; - /* + /* * Send anything that happens to be held in the result buffer. If this * fills the output buffer then we are done with this request. */ @@ -235,7 +235,7 @@ STATUS SBS_volumeMFLControlReadFunc( } /* We reach here only if there is an unfinished MFL enumeration */ - zASSERT((mflCookie->currentOp == MFL_OP_ENUMERATE) && + zASSERT((mflCookie->currentOp == MFL_OP_ENUMERATE) && ! mflCookie->s.enumerate.done); /* allocate memory for return data and for path */ @@ -276,16 +276,16 @@ STATUS SBS_volumeMFLControlReadFunc( COMN_INIT_NAMING_MSG(&aStack->nameMsg); COMN_SET_NAMING_MSG_VOLUME(&aStack->nameMsg, volume); COMN_STRUCT_INIT(aStack->gfnMsg); - COMN_SETUP_GET_NAME_MSG(&aStack->gfnMsg, zGFN_INCLUDE_PATH, 0, - mflCookie->s.enumerate.pathFormat, + COMN_SETUP_GET_NAME_MSG(&aStack->gfnMsg, zGFN_INCLUDE_PATH, 0, + mflCookie->s.enumerate.pathFormat, mflCookie->s.enumerate.nameSpaceID, &aStack->nameBuffer, sizeof(zGetName_s)); while (bufBytesLeft > 0) { numEntriesRequested = MAX_MFL_ENTRIES_PER_SCOOP; - if (volume->VOLcomnVolOps.VOL_enumerateMFL(&genMsg, volume, - (mflCookie->s.enumerate.isDynamic ? + if (volume->VOLcomnVolOps.VOL_enumerateMFL(&genMsg, volume, + (mflCookie->s.enumerate.isDynamic ? (volume->VOLepoch + 1) : volume->VOLepoch), numEntriesRequested, &mflCookie->s.enumerate.cursor.lastZidReturned, @@ -300,16 +300,16 @@ STATUS SBS_volumeMFLControlReadFunc( mflCookie->s.enumerate.done = TRUE; } - mflCookie->s.enumerate.isMFLincomplete = + mflCookie->s.enumerate.isMFLincomplete = mflCookie->s.enumerate.isMFLincomplete || mflIncompleteFlag; for (i = 0; i < numEntriesObtained; ++i) { COMN_SETUP_NAMING_MSG_VOLUME_ZID( &aStack->nameMsg, volume->volumeID, - /* cnt zFNU_FIRST_PARENT,*/ zINVALID_ZID, mflEntries[i].key.zid, - mflEntries[i].key.zid, SLATCHED, + /* cnt zFNU_FIRST_PARENT,*/ zINVALID_ZID, mflEntries[i].key.zid, + mflEntries[i].key.zid, SLATCHED, mflCookie->s.enumerate.nameSpaceID, zNTYPE_FILE, - NULL); + NULL); status = COMN_GetName(&genMsg, &aStack->nameMsg, &aStack->gfnMsg); COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS_KEEP_LATCHTYPE(&aStack->nameMsg); aStack->nameMsg.parseFlags &= ~NAMPFL_nameMsgFullyResolved; @@ -320,12 +320,12 @@ STATUS SBS_volumeMFLControlReadFunc( } status = zOK; mflCookie->s.enumerate.cursor.lastZidReturned = mflEntries[i].key.zid; - sprintf(mflCookie->resultBuf + mflCookie->resultLen, - MSGNot("<" TAG_FILE "><" TAG_NAME ">%s<" - TAG_ID ">%Ld\n"), + sprintf(mflCookie->resultBuf + mflCookie->resultLen, + MSGNot("<" TAG_FILE "><" TAG_NAME ">%s<" + TAG_ID ">%Ld\n"), &aStack->nameBuffer.variableData[0], mflEntries[i].key.zid); - mflCookie->resultLen += strlen(mflCookie->resultBuf + + mflCookie->resultLen += strlen(mflCookie->resultBuf + mflCookie->resultLen); if (sendResult(mflCookie, &bufBytesLeft, &outBuf, retLen)) { @@ -334,23 +334,23 @@ STATUS SBS_volumeMFLControlReadFunc( } /* Normal end of enumeration */ - if ((numEntriesObtained == 0) || mflCookie->s.enumerate.done) + if ((numEntriesObtained == 0) || mflCookie->s.enumerate.done) { mflCookie->s.enumerate.done = TRUE; sprintf(mflCookie->resultBuf + mflCookie->resultLen, - MSGNot("<" TAG_STATUS " " ATR_COMPLETE "=\"%s\"/>\n\n\n"), mflCookie->s.enumerate.isMFLincomplete ? MSGNot("no") : MSGNot("yes")); - mflCookie->resultLen += strlen(mflCookie->resultBuf + + mflCookie->resultLen += strlen(mflCookie->resultBuf + mflCookie->resultLen); MGMT_BuildResultNSS(status, mflCookie->resultBuf + mflCookie->resultLen); - mflCookie->resultLen += strlen(mflCookie->resultBuf + + mflCookie->resultLen += strlen(mflCookie->resultBuf + mflCookie->resultLen); sprintf(mflCookie->resultBuf + mflCookie->resultLen, MSGNot("\n")); - mflCookie->resultLen += strlen(mflCookie->resultBuf + + mflCookie->resultLen += strlen(mflCookie->resultBuf + mflCookie->resultLen); sendResult(mflCookie, &bufBytesLeft, &outBuf, retLen); break; @@ -373,14 +373,14 @@ sendRetcode: /* send the error code */ sprintf(mflCookie->resultBuf + mflCookie->resultLen, MSGNot("\n")); - mflCookie->resultLen += strlen(mflCookie->resultBuf + + mflCookie->resultLen += strlen(mflCookie->resultBuf + mflCookie->resultLen); MGMT_BuildResultNSS(status, mflCookie->resultBuf + mflCookie->resultLen); mflCookie->resultLen += strlen(mflCookie->resultBuf + mflCookie->resultLen); sprintf(mflCookie->resultBuf + mflCookie->resultLen, MSGNot("\n")); - mflCookie->resultLen += strlen(mflCookie->resultBuf + + mflCookie->resultLen += strlen(mflCookie->resultBuf + mflCookie->resultLen); sendResult(mflCookie, &bufBytesLeft, &outBuf, retLen); @@ -396,7 +396,7 @@ sendRetcode: } /**************************************************************************** - * Parse the MFL operation from the XML + * Parse the MFL operation from the XML ****************************************************************************/ STATIC STATUS parseMFLOp( @@ -408,7 +408,7 @@ parseMFLOp( utf8_t *tagName; NINT tagLen; - if (XML_GetNextTag(element->dataStart, element->dataEnd, &elementInfo, + if (XML_GetNextTag(element->dataStart, element->dataEnd, &elementInfo, &tagName, &tagLen) != zOK) { goto badFormat; @@ -426,30 +426,30 @@ parseMFLOp( if (XML_GetTagAttribute(MSGNot(ATR_NAMESPACE), &elementInfo) == zOK) { if (memcmp(MSGNot("zNSPACE_DOS"), elementInfo.attributeValueStart, - elementInfo.attributeValueEnd - + elementInfo.attributeValueEnd - elementInfo.attributeValueStart + 1) == 0) { mflCookie->s.enumerate.nameSpaceID = zNSPACE_DOS; } else if (memcmp(MSGNot("zNSPACE_MAC"), elementInfo.attributeValueStart, - elementInfo.attributeValueEnd - + elementInfo.attributeValueEnd - elementInfo.attributeValueStart + 1) == 0) { mflCookie->s.enumerate.nameSpaceID = zNSPACE_MAC; } else if (memcmp(MSGNot("zNSPACE_UNIX"), elementInfo.attributeValueStart, - elementInfo.attributeValueEnd - + elementInfo.attributeValueEnd - elementInfo.attributeValueStart + 1) == 0) { mflCookie->s.enumerate.nameSpaceID = zNSPACE_UNIX; } else if (memcmp(MSGNot("zNSPACE_LONG"), elementInfo.attributeValueStart, - elementInfo.attributeValueEnd - + elementInfo.attributeValueEnd - elementInfo.attributeValueStart + 1) == 0) { mflCookie->s.enumerate.nameSpaceID = zNSPACE_LONG; } - else + else { goto badFormat; } @@ -457,19 +457,19 @@ parseMFLOp( // if (XML_GetTagAttribute(MSGNot("pathFormat"), &elementInfo) == zOK) // { // if (memcmp(MSGNot("zPFMT_ASCII"), elementInfo.attributeValueStart, -// elementInfo.attributeValueEnd - +// elementInfo.attributeValueEnd - // elementInfo.attributeValueStart + 1) == 0) // { // mflCookie->s.enumerate.pathFormat = zPFMT_ASCII; // } // else if (memcmp(MSGNot("zPFMT_UTF8"), elementInfo.attributeValueStart, -// elementInfo.attributeValueEnd - +// elementInfo.attributeValueEnd - // elementInfo.attributeValueStart + 1) == 0) // { // mflCookie->s.enumerate.pathFormat = zPFMT_UTF8; // } // else if (memcmp(MSGNot("zPFMT_UNICODE"), elementInfo.attributeValueStart, -// elementInfo.attributeValueEnd - +// elementInfo.attributeValueEnd - // elementInfo.attributeValueStart + 1) == 0) // { // mflCookie->s.enumerate.pathFormat = zPFMT_UNICODE; @@ -482,12 +482,12 @@ parseMFLOp( // if (XML_GetTagAttribute(MSGNot("isDynamic"), &elementInfo) == zOK) // { // if (memcmp(MSGNot("yes"), elementInfo.attributeValueStart, -// elementInfo.attributeValueEnd - +// elementInfo.attributeValueEnd - // elementInfo.attributeValueStart + 1) == 0) // { // mflCookie->s.enumerate.isDynamic = TRUE; // } -// else +// else // { // mflCookie->s.enumerate.isDynamic = FALSE; // } @@ -505,16 +505,16 @@ parseMFLOp( { mflCookie->currentOp = MFL_OP_REPAIR; } - else + else { mflCookie->currentOp = MFL_OP_END; - SetErrno(genMsg, zERR_BAD_TRANSFORMATION); + SetErrno(genMsg, zERR_BAD_TRANSFORMATION); return zFAILURE; } return zOK; badFormat: - SetErrno(genMsg, zERR_BAD_TRANSFORMATION); + SetErrno(genMsg, zERR_BAD_TRANSFORMATION); return zFAILURE; } @@ -598,19 +598,19 @@ STATUS SBS_volumeMFLControlWriteFunc( case MFL_OP_ENUMERATE: break; case MFL_OP_GET_STATUS: - status = volume->VOLcomnVolOps.VOL_administerMFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerMFL(&genMsg, volume, VOL_MFL_ADMIN_GET_STATUS_OP, &adminParms); if (status == zOK) { sprintf(mflCookie->resultBuf + mflCookie->resultLen, MSGNot("<"TAG_STATUS" "ATR_COMPLETE"=\"%s\"/>\n"), adminParms.status.incomplete ? MSGNot("no") : MSGNot("yes")); - mflCookie->resultLen += strlen(mflCookie->resultBuf + + mflCookie->resultLen += strlen(mflCookie->resultBuf + mflCookie->resultLen); } break; case MFL_OP_VERIFY: - status = volume->VOLcomnVolOps.VOL_administerMFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerMFL(&genMsg, volume, VOL_MFL_ADMIN_VERIFY_OP, &adminParms); if (status == zOK) { @@ -622,12 +622,12 @@ STATUS SBS_volumeMFLControlWriteFunc( adminParms.verifyStats.numModifiedFiles, adminParms.verifyStats.numMissingEntries, adminParms.verifyStats.numExtraEntries); - mflCookie->resultLen += strlen(mflCookie->resultBuf + + mflCookie->resultLen += strlen(mflCookie->resultBuf + mflCookie->resultLen); } break; case MFL_OP_REPAIR: - status = volume->VOLcomnVolOps.VOL_administerMFL(&genMsg, volume, + status = volume->VOLcomnVolOps.VOL_administerMFL(&genMsg, volume, VOL_MFL_ADMIN_FIX_OP, &adminParms); if (status == zOK) { @@ -643,7 +643,7 @@ STATUS SBS_volumeMFLControlWriteFunc( adminParms.verifyStats.numExtraEntries, adminParms.verifyStats.numAddErrors, adminParms.verifyStats.numDeleteErrors); - mflCookie->resultLen += strlen(mflCookie->resultBuf + + mflCookie->resultLen += strlen(mflCookie->resultBuf + mflCookie->resultLen); } break; @@ -662,14 +662,14 @@ sendReturnCode: { sprintf(mflCookie->resultBuf + mflCookie->resultLen, MSGNot("\n")); - mflCookie->resultLen += strlen(mflCookie->resultBuf + + mflCookie->resultLen += strlen(mflCookie->resultBuf + mflCookie->resultLen); MGMT_BuildResultNSS(status, mflCookie->resultBuf + mflCookie->resultLen); mflCookie->resultLen += strlen(mflCookie->resultBuf + mflCookie->resultLen); sprintf(mflCookie->resultBuf + mflCookie->resultLen, MSGNot("\n")); - mflCookie->resultLen += strlen(mflCookie->resultBuf + + mflCookie->resultLen += strlen(mflCookie->resultBuf + mflCookie->resultLen); status = zOK; } diff --git a/include/nwnss/comn/main/seqUpdater.h b/src/nwnss/comn/seqUpdater.h similarity index 100% rename from include/nwnss/comn/main/seqUpdater.h rename to src/nwnss/comn/seqUpdater.h diff --git a/include/nwnss/include/zasAuthCache.h b/src/nwnss/comn/zasAuthCache.h similarity index 98% rename from include/nwnss/include/zasAuthCache.h rename to src/nwnss/comn/zasAuthCache.h index 2021b89..85bbc0e 100644 --- a/include/nwnss/include/zasAuthCache.h +++ b/src/nwnss/comn/zasAuthCache.h @@ -38,11 +38,11 @@ #define _ZASAUTHCACHE_H_ #ifndef _OMNI_H_ -#include +#include #endif #ifndef _MSGGEN_H_ -#include +#include #endif #ifndef _ZASAUTHMODEL_H_ diff --git a/src/nwnss/library/Makefile b/src/nwnss/library/Makefile new file mode 100644 index 0000000..28529a4 --- /dev/null +++ b/src/nwnss/library/Makefile @@ -0,0 +1,43 @@ +### +### ../nss/public_core/library Makefile +### + +############################################################################## +# +# (C) Copyright 2004 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +BASEDIR=../.. + +SUBDIRS= \ + +NSSERRTABLE_SUBDIR=misc/ + +opt: misc/nssErrorTable.c + +all: opt + +both: opt + +clean: clean_nssErrorTable.c + +include ${BASEDIR}/buildtools/Makefile.default +include ${BASEDIR}/buildtools/Makefile.nssErrorTable + diff --git a/src/nwnss/library/Module.supported b/src/nwnss/library/Module.supported new file mode 100644 index 0000000..a8dba54 --- /dev/null +++ b/src/nwnss/library/Module.supported @@ -0,0 +1 @@ +nsslibrary.ko diff --git a/src/nwnss/library/debug/DebugHexDump.c b/src/nwnss/library/debug/DebugHexDump.c new file mode 100644 index 0000000..4e6b57f --- /dev/null +++ b/src/nwnss/library/debug/DebugHexDump.c @@ -0,0 +1,134 @@ +/**************************************************************************** + | + | (C) Copyright 1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Dump some memory to the debug area + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Display debug information. + | + +-------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include + +#include + + +#if NSS_DEBUG IS_ENABLED + +/* + * DebugHexDump + * debugMask Standard debug mask to determine if debuggin item. + * debugColor Color to use on print. + * displayMode Not supported - We always do BYTE ASCII dump. + * userArea Pointer to memory to dump. + * len Number of BYTEs to dump. If <= 0 nothing is printed. + * + * Dumps a range of memory to the debug device. Currently only supports + * a BYTE dump with the ASCII equivalent displayed on the right. + * + * + * 00000000 45 45 45 45 45 45 45 45 | 45 45 45 45 45 41 41 41 EEEEEEEEEEEEEAAA + * 00000010 45 45 45 45 45 45 45 45 | 45 45 45 45 45 00 01 02 EEEEEEEEEEEEE... + * 00000020 45 45 45 45 45 45 45 45 | 45 45 45 45 45 45 45 45 EEEEEEEEEEEEEEEE + * ^ ^ ^ + * | | Column 60 (DHD_COLUMN_ASCII) + * | Column 10 (DHD_COLUMN_HEX) + * Column 0 (DHD_COLUMN_OFFSET) + */ + +#define DHD_COLUMN_OFFSET 0 +#define DHD_COLUMN_HEX 10 +#define DHD_COLUMN_ASCII 60 + +void DBG_DebugHexDump( + NINT debugMask, + NINT debugColor, + NINT displayMode, + void *userArea, + int length ) + +{ + NINT column; + char viewLine[81]; + int len; + + if ( length <= 0 ) + { + return; + } + memset( &viewLine[0], ' ', 79 ); + viewLine[79] = 0; + column = 0; + for ( len = 0; len < length; ++len, ++column ) + { + if ( column == 16 ) + { + DEBUG_PRINTF( debugMask, DBG_NOINDENT, + ( debugColor, MSGNot("%s\n"), &viewLine[0] )); + memset( &viewLine[0], ' ', 79 ); + column = 0; + } + if ( column == 0 ) + { /* We have chossen to display the OFFSET verses the address */ + sprintf( &viewLine[DHD_COLUMN_OFFSET], MSGNot("%08lx"), len ); + viewLine[DHD_COLUMN_OFFSET + 8] = ' '; + } + if ( column == 8 ) + { + viewLine[column*3 + DHD_COLUMN_HEX + 0] = '|'; + viewLine[column*3 + DHD_COLUMN_HEX + 1] = ' '; + } + + sprintf( &viewLine[(column/8)*2 + (column*3) + DHD_COLUMN_HEX], + MSGNot("%02x"), *(char *)userArea ); + viewLine[(column/8)*2 + (column*3) + DHD_COLUMN_HEX + 2] = ' '; + /* Fill in ASCII portion. This is the range that ZED does. */ + if( ( *(unsigned char *)userArea > 0x19) && ( *(unsigned char *)userArea < 0x80) ) + { + viewLine[column+DHD_COLUMN_ASCII] = *(char *)userArea; + } + else + { + viewLine[column+DHD_COLUMN_ASCII] = '.'; + } + userArea = ((char *)userArea) + 1; + } + DEBUG_PRINTF( debugMask, DBG_NOINDENT, + ( debugColor, MSGNot("%s\n"), &viewLine[0]) ); + return; + +} + + +#endif diff --git a/src/nwnss/library/debug/DebugPrintf.c b/src/nwnss/library/debug/DebugPrintf.c new file mode 100644 index 0000000..937b43c --- /dev/null +++ b/src/nwnss/library/debug/DebugPrintf.c @@ -0,0 +1,1074 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Contains code that handles the 'debug buffer'. The debugger + | buffer is used to store debug information in a memory buffer. This + | buffer can then be viewed or saved. This is done from the internal + | debugger via '=d' and the '=s' commands. This buffer can be searched + | by hitting 'F' while viewing the buffer ('=d' command). + +-------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include "nssOSAPIs.h" +#include +//#include +#include +#include +#include +#include + + +#if NSS_DEBUG IS_ENABLED + +/* + * A string is a sequence of ASCII characters terminated with a NULL. + * A 'record' is a string, attribute, UTC, and length. + * A attribute indciates a color. + * The UTC is the time of the DBG_DebugPrintf call. + * A line is a sequence of records where the last record contains a + * string that ends with a 0x0a. The line can be longer than the + * physical screen in which case it will be wrapped when displayed. + * The debug buffer contains multiple 'records' that are stored in + * a circular nature. + * + * NOTE - This implies that a string with multiple 0x0a counts at most + * as one line because we currently only count strings that END WITH + * a 0x0a as a SINGLE line. This does mess up scrolling. + * + * + * A record is implemented as follows. + * DebugEntryHeader_s + * 'string' + * DebugEntryTail_s + * + */ + + +#define PAGEUP 1 +#define PAGEDOWN 2 + + +QUAD DBG_ScreenSwitches; /* This holds commandline settable bits + * as to what behaviour the user wants + * out of the NSS Debug Screen. Legal + * bits are defined by DBG_SS_xxx in + * pssDebug.h. DO NOT CONFUSS the + * NSS Debug Screen with the '=d' buffer. + * They are not the same. + */ +QUAD DBG_Mask; +QUAD DBG_DebugMask = TDEFAULT; +NINT DBG_DebugTime = DBG_TIME_NONE; + +NINT DBG_DebugLogBufferSize = (1*1024*1024); + +DebugEntryHeader_s debugEntryHeader; +NINT DBG_debugLogBufferInsert=0; +NINT DBG_debugLogBufferRemove=0; +NINT DBG_debugLogEndRecordTail=0; /* Index of last record's tail */ +NINT DBG_debugLogStop = FALSE; /* Set to TRUE when you need + * modifications to the DEBUG BUFFER to + * stop. This is used by the save code + * so that it can take a correct snapshot + * without abending the server because + * the pointers it has are no longer + * correct. Some of the DOS calls we + * make are hooked and therefore we + * can get some calls to the DEBUG + * BUFFER print code. + */ +BYTE *DBG_debugLogBuffer=NULL; +BYTE dummy; +NINT DBG_debugLogMask; + +#ifndef __linux__ // LINUX_Debugger +struct ScreenStruct *debuggerScreen; +#endif + + + +/**************************************************************************** + * Determine where to position to display previous entries + *****************************************************************************/ +STATIC NINT moveBackward( + NINT numLinesRequested, + NINT *su_current) +{ + NINT lineCount = 0; + BYTE lastChar; + DebugEntryHeader_s *header; + +/* +OutputToScreenWithAttribute(screen, LRED, MSGNot("startCurrent=%d DBG_debugLogBufferRemove=%d\n"), + startCurrent, DBG_debugLogBufferRemove); + ZOS_GetKey(screen, &keyType, &keyValue, NULL, NULL, 0); + if((keyType == ESCAPE_KEY) || (keyValue == 'q')) + return; +*/ + while ((lineCount != numLinesRequested) && + (*su_current != DBG_debugLogBufferRemove)) + { /* repeat until all processed or requested lines processed */ + DebugEntryTail_s *tail; + if (*su_current != 0 ) + { + tail = (DebugEntryTail_s *)(&DBG_debugLogBuffer[(*su_current) - sizeof(DebugEntryTail_s)]); + *su_current -= ( tail->DET_length + + sizeof(DebugEntryHeader_s) + sizeof(DebugEntryTail_s)); + } + else + { /* Current 0 so start at last line of buffer */ + tail = (DebugEntryTail_s *)(&DBG_debugLogBuffer[DBG_debugLogEndRecordTail]); + *su_current = DBG_debugLogEndRecordTail - + (tail->DET_length + sizeof(DebugEntryHeader_s)); + } + header = (DebugEntryHeader_s *)&DBG_debugLogBuffer[*su_current]; + if (*su_current != DBG_debugLogBufferRemove) + { /* if not at the beginning */ + lastChar = *su_current ? DBG_EOS_CHAR_PREV(*su_current) : + DBG_EOS_CHAR_OF_END_RECORD(); + if (lastChar == 0x0A) + { + if ( (!DBG_Mask) || (header->DEH_mask & DBG_Mask)) + { + lineCount++; + } + } + } + else + { + if ( (!DBG_Mask) || (header->DEH_mask & DBG_Mask)) + { + lineCount++; + } + } + } +//OutputToScreenWithAttribute(debuggerScreen, LRED, MSGNot("(back) lineCount=%d\n"), lineCount); +//ZOS_GetKey(debuggerScreen, &dummy, &dummy, NULL, NULL, 0); + return lineCount; +} + + +/**************************************************************************** + * Determine where to position to display previous entries + *****************************************************************************/ +STATIC NINT moveForward( + NINT numLinesRequested, + NINT *su_current) +{ + NINT lineCount = 0; + DebugEntryHeader_s *prevHeader; + + while ((lineCount < numLinesRequested) && + (*su_current != DBG_debugLogBufferInsert)) + { /* repeat until all processed or requested lines processed */ + prevHeader = (DebugEntryHeader_s *)&DBG_debugLogBuffer[*su_current]; + *su_current += prevHeader->DEH_length + + sizeof(DebugEntryHeader_s) + sizeof(DebugEntryTail_s); + if ((DBG_EOS_CHAR_PREV(*su_current) == 0x0A) || + (*su_current == DBG_debugLogBufferInsert)) + { + if ( (!DBG_Mask) || (prevHeader->DEH_mask & DBG_Mask)) + { + lineCount++; + } + } + if (*su_current > (DBG_DebugLogBufferSize - MAX_LOG_ENTRY_SIZE)) + { + *su_current = 0; + } + } +//OutputToScreenWithAttribute(debuggerScreen, LRED, MSGNot("(forward) lineCount=%d\n"), lineCount); +//ZOS_GetKey(debuggerScreen, &dummy, &dummy, NULL, NULL, 0); + return lineCount; +} + +/**************************************************************************** + * Search forward in the log + *****************************************************************************/ +BOOL searchLine( + BYTE *searchString, + NINT len, + NINT su_current) +{ + NINT index; + NINT tempLen; + NINT recLen; + BYTE *strPtr; + + strPtr = searchString; + tempLen = len; +//OutputToScreenWithAttribute(debuggerScreen, LRED, MSGNot("Entering searchline\n")); + while (su_current != DBG_debugLogBufferInsert) + { /* repeat until all processed */ + recLen = ((DebugEntryHeader_s *)&DBG_debugLogBuffer[su_current])->DEH_length - 1/*remove NULL*/; + for (index = su_current + sizeof(DebugEntryHeader_s); + DBG_debugLogBuffer[index] != 0; index++, recLen--) + { + if (recLen < len) + { + tempLen = recLen; + } +//{ +//BYTE value; +//OutputToScreenWithAttribute(debuggerScreen, LRED, MSGNot("(searchLine) len=%d tempLen=%d recLen=%d <%s> |%s|\n"), +// len, tempLen, recLen, strPtr, &DBG_debugLogBuffer[index]); +//ZOS_GetKey(debuggerScreen, &dummy, &value, NULL, NULL, 0); +//if (value == 'q') +// return FALSE; +//} + + if (strnicmp(&DBG_debugLogBuffer[index], strPtr, tempLen) == 0) + { + len -= tempLen; + if (len == 0) + { + return TRUE; + } + tempLen = len; + strPtr += recLen; + break; + } + else + { + tempLen = len; + strPtr = searchString; + } + } + su_current += ((DebugEntryHeader_s *)&DBG_debugLogBuffer[su_current])->DEH_length + + sizeof(DebugEntryHeader_s) + sizeof(DebugEntryTail_s); + if ((DBG_EOS_CHAR_PREV(su_current) == 0x0A) || + (su_current == DBG_debugLogBufferInsert)) + { + return FALSE; + } + if (su_current > (DBG_DebugLogBufferSize - MAX_LOG_ENTRY_SIZE)) + { + su_current = 0; + } + } + return FALSE; +} + +/**************************************************************************** + * Search backward in the log + *****************************************************************************/ +BOOL searchUp( + BYTE *searchString, + NINT *su_current) +{ + NINT len; +// BYTE value; + + len = strlen(searchString); +//OutputToScreenWithAttribute(debuggerScreen, LRED, MSGNot("(searchup) su_current=%d\n"), *su_current); + while (*su_current != DBG_debugLogBufferRemove) + { /* repeat until all processed */ + moveBackward(1, su_current); + +//{ +//BYTE value; +//OutputToScreenWithAttribute(debuggerScreen, LRED, MSGNot("(searchup - 2) su_current=%d\n"), *su_current); +//ZOS_GetKey(debuggerScreen, &dummy, &value, NULL, NULL, 0); +//if (value == 'q') +// return FALSE; +//} + if (searchLine(searchString, len, *su_current)) + { + return TRUE; + } + } + return FALSE; +} + +/**************************************************************************** + * Search forward in the log + *****************************************************************************/ +BOOL searchDown( + BYTE *searchString, + NINT *su_current) +{ + NINT len; + + len = strlen(searchString); + while (*su_current != DBG_debugLogBufferInsert) + { /* repeat until all processed */ + if (searchLine(searchString, len, *su_current)) + { + return TRUE; + } + moveForward(1, su_current); + } + return FALSE; +} + +/**************************************************************************** + * Display the results of a search + *****************************************************************************/ +void displayLines ( + struct ScreenStruct *screen, + NINT start, + NINT end) +{ + NINT su_current; + DebugEntryHeader_s *header; + char buffer[40]; + + for (su_current = start; su_current != end;) + { /* repeat until all processed or 24 lines processed */ + + header = (DebugEntryHeader_s *)&DBG_debugLogBuffer[su_current]; + if ( (!DBG_Mask) || (header->DEH_mask & DBG_Mask)) + { + if ( (DBG_DebugTime != DBG_TIME_NONE) && + (DBG_BEGIN_LINE(su_current) ) + { + DBG_UTCTime2Str( ((DebugEntryHeader_s *)&DBG_debugLogBuffer[su_current])->DEH_utc, &buffer[0] ); + if ( DBG_DebugTime == DBG_TIME_FULL ) + { + OutputToScreenWithAttribute(screen, + LGRAY, + MSGNot("<%s>"),&buffer[0] ); + } + else + { + OutputToScreenWithAttribute(screen, + LGREEN, + MSGNot("<%s>"),&buffer[12] ); + } + } + OutputToScreenWithAttribute(screen, + ((DebugEntryHeader_s *)&DBG_debugLogBuffer[su_current])->DEH_attribute, + MSGNot("%s"),&DBG_debugLogBuffer[su_current+sizeof(DebugEntryHeader_s)]); + } + su_current += header->DEH_length + + sizeof(DebugEntryHeader_s) + sizeof(DebugEntryTail_s); + if (su_current > (DBG_DebugLogBufferSize - MAX_LOG_ENTRY_SIZE)) + { + su_current = 0; + } + } +} + +/**************************************************************************** + * Display the results of a search + * + * Only finds an item ONCE per (line/record?)!!! + *****************************************************************************/ +#if zNETWARE +void searchDisplay ( + struct ScreenStruct *screen, + NINT su_current, + NINT *startCurrent, + NINT *endCurrent) +{ + NINT linesMoved; + BYTE lastChar; + + *startCurrent = su_current; + OutputToScreen(screen, MSGNot("\n")); + moveBackward(12, startCurrent); + *endCurrent = *startCurrent; + linesMoved = moveForward(24, endCurrent); + if (linesMoved < 24) + { + moveBackward(24-linesMoved, startCurrent); + } + +//OutputToScreenWithAttribute(debuggerScreen, LRED, MSGNot("(display) su_current=%d start=%d, linesMoved=%d\n"), su_current, start, linesMoved); +//ZOS_GetKey(debuggerScreen, &dummy, &dummy, NULL, NULL, 0); + displayLines(screen, *startCurrent, su_current); + + /* display the selected line */ + do + { + OutputToScreenWithAttribute(screen, BROWN, + /*((DebugEntryHeader_s *)&DBG_debugLogBuffer[su_current])->DEH_attribute,*/ + MSGNot("%s"),&DBG_debugLogBuffer[su_current+sizeof(DebugEntryHeader_s)]); + su_current += ((DebugEntryHeader_s *)&DBG_debugLogBuffer[su_current])->DEH_length + + sizeof(DebugEntryHeader_s) + sizeof(DebugEntryTail_s); + lastChar = su_current ? DBG_EOS_CHAR_PREV(su_current) : + DBG_EOS_CHAR_OF_END_RECORD(); + } while (lastChar != 0x0a && su_current != DBG_debugLogBufferInsert); + + displayLines(screen, su_current, *endCurrent); + OutputToScreen(screen, MSGNot("\n")); +} +#endif // #if zNETWARE + + +#if zNETWARE +/**************************************************************************** + * Dump the log to the debugger screen + *****************************************************************************/ +void DBG_DumpLogBuffer( + struct ScreenStruct *screen) +{ + NINT startCurrent; + NINT endCurrent; + NINT searchCurrent; + NINT validKeys; + NINT searchDirection; + BYTE keyType; + BYTE keyValue; + BYTE searchString[80]; + + debuggerScreen = screen; + startCurrent = DBG_debugLogBufferInsert; + endCurrent = DBG_debugLogBufferInsert; + moveBackward(24, &startCurrent); + keyType = CURSOR_PUP_KEY; + validKeys = PAGEUP; + for(;;) + { +top: + /* Display the records */ + + displayLines(screen, startCurrent, endCurrent); + + if (endCurrent == DBG_debugLogBufferInsert) + { + OutputToScreenWithAttribute(screen, YELLOW, + MSGNot("PageUp/LineUp for previous entries, t/d for time/date, ESC to exit")); + validKeys = PAGEUP; + } + else if (startCurrent == DBG_debugLogBufferRemove) + { + OutputToScreenWithAttribute(screen, YELLOW, + MSGNot("PageDown/LineDown for next entries, t/d for time/date, ESC to exit")); + validKeys = PAGEDOWN; + } + else + { + OutputToScreenWithAttribute(screen, LGREEN, + MSGNot("PgUp/LUp for prev, PgDn/LDn for next, t/d for time/date, ESC to exit")); + validKeys = PAGEUP | PAGEDOWN; + } + +newKey: + GetKey(screen, &keyType, &keyValue, NULL, NULL, 0); + + switch (keyValue) + { + case 't': + case 'T': + if ( DBG_DebugTime != DBG_TIME_PARTIAL ) + { + DBG_DebugTime = DBG_TIME_PARTIAL; + } + else + { + DBG_DebugTime = DBG_TIME_NONE; + } + goto top; + case 'd': + case 'D': + if ( DBG_DebugTime != DBG_TIME_FULL ) + { + DBG_DebugTime = DBG_TIME_FULL; + } + else + { + DBG_DebugTime = DBG_TIME_NONE; + } + goto top; +doF: + case 'S': + case 's': + case 'F': + case 'f': + PositionOutputCursor(screen, 24, 0); + OutputToScreenWithAttribute(screen, LBLUE, + MSGNot("Enter the search string: ")); + PositionInputCursor(screen, 24, 24); + InputFromKeyboard(screen, MSGNot("\x01..\xff"), 80, 80, searchString, + 0, 1, searchString); + PositionOutputCursor(screen, 24, 0); + OutputToScreenWithAttribute(screen, LBLUE, + MSGNot("'U'=search up 'D'=search down 'T'=Time 'Y'=Date ")); + searchCurrent = -1; + searchDirection = -1; + do + { + GetKey(screen, &keyType, &keyValue, NULL, NULL, 0); + switch (keyValue) + { + case 'U': + case 'u': + if (searchCurrent == -1) + searchCurrent = endCurrent; + if (searchDirection == 2) + { + moveBackward(1, &searchCurrent); + } + if (searchUp(searchString, &searchCurrent)) + { + searchDisplay(screen, searchCurrent, + &startCurrent, &endCurrent); + searchDirection = 1; + } + else + { + PositionOutputCursor(screen, 24, 0); + OutputToScreenWithAttribute(screen, LRED, + MSGNot("Not found while search up -- 'D'=search down ")); + continue; + } + break; + case 'D': + case 'd': + if (searchCurrent == -1) + searchCurrent = startCurrent; + if (searchDirection == 1) + { + moveForward(1, &searchCurrent); + } + if (searchDown(searchString, &searchCurrent)) + { + searchDisplay(screen, searchCurrent, + &startCurrent, &endCurrent); + moveForward(1, &searchCurrent); + searchDirection = 2; + } + else + { + PositionOutputCursor(screen, 24, 0); + OutputToScreenWithAttribute(screen, LRED, + MSGNot("Not found while search down -- 'U'=search up ")); + continue; + } + break; + case 'f': + case 'F': + case 's': + case 'S': + goto doF; + case 't': + case 'T': + if ( DBG_DebugTime != DBG_TIME_PARTIAL ) + { + DBG_DebugTime = DBG_TIME_PARTIAL; + } + else + { + DBG_DebugTime = DBG_TIME_NONE; + } + displayLines(screen, startCurrent, endCurrent); + break; + case 'y': + case 'Y': + if ( DBG_DebugTime != DBG_TIME_FULL ) + { + DBG_DebugTime = DBG_TIME_FULL; + } + else + { + DBG_DebugTime = DBG_TIME_NONE; + } + displayLines(screen, startCurrent, endCurrent); + break; + default: + OutputToScreen(screen, MSGNot("\a")); + } + PositionOutputCursor(screen, 24, 0); + OutputToScreenWithAttribute(screen, LBLUE, + MSGNot("'U'=search up 'D'=search down 'T'=Time 'Y'=Date ")); + } while (keyType != ESCAPE_KEY); + OutputToScreen(screen, MSGNot("\n")); + + goto top; + } + + switch (keyType) + { + case CURSOR_UP_KEY: + if(!(validKeys & PAGEUP)) + { + OutputToScreen(screen, MSGNot("\a")); + goto newKey; + } + moveBackward(moveBackward(1, &startCurrent), &endCurrent); + break; + case CURSOR_DOWN_KEY: + if(!(validKeys & PAGEDOWN)) + { + OutputToScreen(screen, MSGNot("\a")); + goto newKey; + } + moveForward(moveForward(1, &endCurrent), &startCurrent); + break; + case ESCAPE_KEY: + OutputToScreen(screen, MSGNot("\n")); + return; + case CURSOR_HOME_KEY: + startCurrent = DBG_debugLogBufferRemove; + endCurrent = DBG_debugLogBufferRemove; + moveForward(24, &endCurrent); + break; + case CURSOR_END_KEY: + startCurrent = DBG_debugLogBufferInsert; + endCurrent = DBG_debugLogBufferInsert; + moveBackward(24, &startCurrent); + break; + case CURSOR_PUP_KEY: + if(!(validKeys & PAGEUP)) + { + OutputToScreen(screen, MSGNot("\a")); + goto newKey; + } + moveBackward(moveBackward(24, &startCurrent), &endCurrent); + break; + case CURSOR_PDOWN_KEY: + if(!(validKeys & PAGEDOWN)) + { + OutputToScreen(screen, MSGNot("\a")); + goto newKey; + } + moveForward(moveForward(24, &endCurrent), &startCurrent); + break; + default: + OutputToScreen(screen, MSGNot("\a")); + goto newKey; + } + OutputToScreenWithAttribute(screen, LGREEN, MSGNot("\n")); + } +} +#endif // #if zNETWARE + + +/* + * DBG_ScreenAPrintfDisplay() - + * + * Returns - + * TRUE if selection string indicates that the item should be displayed. + */ +BOOL DBG_ScreenAPrintfDisplay( char *selectionString ) + +{ + + if ( selectionString == NULL ) + { + return(FALSE); + } + + if ( DBG_debugLogMask & DEBUG_LOG_SCREEN ) + { /* When Randy logs to the screen he does not want to + * see all my stuff. So instead of working on the + * code for the selection string I just did this + * simple check. + */ + return( FALSE ); + } + +// if ( strstr( "Greg", selectionString ) != NULL ) +// { +// return( FALSE ); +// } + return( TRUE ); + +} /* End of DBG_ScreenAPrintfDisplay() */ + + +/* DBG_ScreenAPrintf() - + * Prints to the NSS Debug Screen. + * + * Notes - + * If the DEBUG screen does not exist then display goes to the console. + * + * Issues - + * Should put everything in a buffer and have a thread display so that + * we are not blocking. This would fix problem of having output interrupted + * by other output (we release NSS spinlock to display a the screen AND + * have multiple display calls). + * Add support for the selectionString parameter. Could have regular + * expression matching. + */ +#if zNETWARE +void DBG_ScreenAPrintf( + char *selectionString, /* Mask.Mask... for example one could + * pass in 'ZLSS.Greg.Pool" and information + * will be displayed if Greg or Pool or + * ZLSS is on. + */ + char *whereString, /* Paul's famous WHERE macro result */ + NINT attr, + const char *formatStr, + ...) +{ + va_list args; + BOOL printed = FALSE; + + if ( !DBG_ScreenAPrintfDisplay(selectionString) ) + { + return; + } + va_start(args,formatStr); + if (DBG_DbgScreen == NULL) + { + DBG_InitDebug(); + } + + if ( DBG_ScreenSwitches & DBG_SS_WHERE ) + { + LB_wAPrintf( DBG_DbgScreen, LCYAN, "%-30s ", whereString ); + printed = TRUE; + } + if ( DBG_ScreenSwitches & DBG_SS_MASK ) + { + LB_wAPrintf( DBG_DbgScreen, LCYAN, "%-30s ", selectionString ); + printed = TRUE; + } + if ( DBG_ScreenSwitches & DBG_SS_UTC ) + { + char buffer[40]; + + UTCTime2Str(GetUTCTime(),&buffer[0]); + /*** We use [12] so not to display the date ***/ + LB_wAPrintf( DBG_DbgScreen, LCYAN, "%-14s ", &buffer[12] ); + printed = TRUE; + } + if ( printed ) + { + LB_wAPrintf( DBG_DbgScreen, LCYAN, "\n" ); + } + LB__wioOutput( DBG_DbgScreen, attr, formatStr, args); + va_end( args ); + +} /* End of DBG_ScreenAPrintf() */ +#endif +#ifdef __linux__ // LINUX_Debugger +void DBG_ScreenAPrintf( + char *selectionString, /* Mask.Mask... for example one could + * pass in 'ZLSS.Greg.Pool" and information + * will be displayed if Greg or Pool or + * ZLSS is on. + */ + char *whereString, /* Paul's famous WHERE macro result */ + NINT attr, + const char *formatStr, + ...) {} +#endif + + +/**************************************************************************** + * Inserts the line into the debug buffer + *****************************************************************************/ +void DBG_InsertLine( + NINT color, + char *buffer, + NINT bufLen, + QUAD mask, + BOOL newLine) +{ + char *insertPtr; + DebugEntryTail_s *tail; + DebugEntryHeader_s *header; + + while (DBG_debugLogBufferRemove > DBG_debugLogBufferInsert && + DBG_debugLogBufferInsert + MAX_LOG_ENTRY_SIZE >= DBG_debugLogBufferRemove) + { /* adjust the remove pointer to be past the possible insert size */ + DBG_debugLogBufferRemove += + ((DebugEntryHeader_s *)&DBG_debugLogBuffer[DBG_debugLogBufferRemove])->DEH_length + + sizeof(DebugEntryHeader_s) + sizeof(DebugEntryTail_s); + if (DBG_debugLogBufferRemove > (DBG_DebugLogBufferSize - MAX_LOG_ENTRY_SIZE)) + { + DBG_debugLogBufferRemove = 0; + } + } + header = (DebugEntryHeader_s *)&DBG_debugLogBuffer[DBG_debugLogBufferInsert]; + insertPtr = &DBG_debugLogBuffer[DBG_debugLogBufferInsert + + sizeof(DebugEntryHeader_s)]; + + if ( bufLen > (MAX_LOG_ELEMENT_SIZE - 2) ) + { /* If the string is too long then dump ERROR into buffer */ + LB_sprintf( insertPtr, MSGNot("*ERROR* output truncated:\n") ); + bufLen = MAX_LOG_ELEMENT_SIZE - 2 - strlen(insertPtr); + insertPtr += strlen(insertPtr); + } + memcpy(insertPtr, buffer, bufLen); + if (newLine) + { + insertPtr[bufLen++] = '\n'; + } + insertPtr[bufLen++] = '\0'; + header->DEH_attribute = color; + header->DEH_length = bufLen; + header->DEH_utc = GetUTCTime(); + header->DEH_mask = mask; + zASSERT(bufLen <= MAX_LOG_ELEMENT_SIZE); + + DBG_debugLogBufferInsert += bufLen + sizeof(DebugEntryHeader_s); + tail = (DebugEntryTail_s *)&DBG_debugLogBuffer[DBG_debugLogBufferInsert]; + tail->DET_length = bufLen; + DBG_debugLogBufferInsert += sizeof( DebugEntryTail_s ); + + if (DBG_debugLogBufferInsert > (DBG_DebugLogBufferSize - MAX_LOG_ENTRY_SIZE)) + { + DBG_debugLogEndRecordTail = DBG_debugLogBufferInsert - sizeof(DebugEntryTail_s); + DBG_debugLogBufferInsert = 0; + if (DBG_debugLogBufferRemove == 0) + { + DBG_debugLogBufferRemove += debugEntryHeader.DEH_length + sizeof(DebugEntryTail_s) + + sizeof(DebugEntryHeader_s); + } + } +} + +/**************************************************************************** + * This routine will display lines into the '=d' buffer. This is done + * by storing the line into a record. The record will have the UTC stored + * into it so that it can be optionally displayed by the user. + *****************************************************************************/ +void DBG_DebugPrintf( + NINT attr, + const char *formatStr, + ...) +{ + va_list args; + QUAD mask; + static NINT CurrentPos = 0; + + mask = DBG_DebugMask; + DBG_DebugMask = TDEFAULT; + + if (DBG_debugLogBuffer == NULL) + { /* This indicates that we have not yet inited or + * have already uninited. + */ + return; + } +#if 0 +// if (debugLogIgnore) +// return; +#endif + + if ( DBG_debugLogStop ) + { /* Global that prevents moving of pointers while + * saving the Debug buffer. + */ +// ZOS_EnterDebugger(); + return; + } + +#ifndef __linux__ // LINUX_Debugger + if (DBG_DbgScreen == NULL) + { + DBG_InitDebug(); + } +#endif + + va_start(args,formatStr); + /* if the DEBUG screen is not created, it prints to the console*/ +#ifndef __linux__ // LINUX_Debugger + if(DBG_debugLogMask & DEBUG_LOG_SCREEN) + { + LB__wioOutput(DBG_DbgScreen,attr,formatStr,args); + } +#endif + + if (DBG_debugLogMask & DEBUG_LOG_MEMORY) + { /* insert the entry in the log buffer */ + char *data; + NINT len; + SNINT pos; + SNINT lineLen; + SNINT lineStart; + + data = &DBG_debugLogBuffer[DBG_DebugLogBufferSize]; + LB_vsprintf( data, (char *)formatStr, args); + len = strlen(data); + + /* + * Break up the message into lines + */ + for (pos = 0, lineLen = 1, lineStart = 0; pos < len; + pos++, lineLen++, CurrentPos++) + { + if (data[pos] == '\n' || CurrentPos >= 78) + { + DBG_InsertLine(attr, &data[lineStart], lineLen, mask, + data[pos] == '\n' ? FALSE : TRUE); + lineStart += lineLen; + lineLen = 0; + CurrentPos = 0; + } + } + if (lineLen > 1) + { + DBG_InsertLine(attr, &data[lineStart], lineLen - 1, mask, FALSE); + } + } + va_end( args ); +} + +#endif // #if NSS_DEBUG IS_ENABLED + + + +/************************************************************************** + * Non Language Enabled UTC to String. Used by Debug code to display + * US style dates and times in a well known fashion. Callers assume + * location a length of fields within string. Hours are in 24 hour periods. + * + * This routine takes UTC time (seconds from Jan 1, 1970) and converts + * it to a string in the format dd-mmm-yyyy hh:mm:ss). + * + * Note that it also converts the time to the local timezone of the + * server. + ***************************************************************************/ +char *DBG_UTCTime2Str( + Time_t utcTime, + char *str) +{ + + /*------------------------------------------------------------------------- + * Defines the time breakout structure + *-------------------------------------------------------------------------*/ + typedef struct TimeBreakout { + BYTE CYear; /* 0-79 == 2000-2079, 80-99 == 1980-1999 */ + BYTE CMonth; /* 1 = January */ + BYTE CDay; /* 1 = 1st */ + BYTE CHour; /* 0-23 */ + BYTE CMinute; /* 0-59 */ + BYTE CSecond; /* 0-59 */ + } TimeBreakout; + + #define SECONDS_IN_A_MINUTE (LONG) (60) + #define SECONDS_IN_AN_HOUR (LONG) (60 * 60) + #define SECONDS_IN_A_DAY (LONG)( 24 * 60 * 60) + #define SECONDS_IN_A_YEAR (LONG)(365 * SECONDS_IN_A_DAY) + #define SECONDS_IN_A_LEAPYEAR (LONG)(366 * SECONDS_IN_A_DAY) + #define SECONDS_IN_4_YEARS (LONG)((SECONDS_IN_A_YEAR * 3) + SECONDS_IN_A_LEAPYEAR) + + NINT year,month,leapYear; + NINT numLeapYears; + TimeBreakout time; + + if (utcTime == INVALID_UTC_TIME) + { + sprintf(str,MSGNot("Invalid UTC Time")); + return( str ); + } + + /* Adjust utcTime time to local time using time zone and DST offsets */ + + /* localtime = utcTime - TZ + DST */ + utcTime -= NSS_TimeZoneOffset; + if (NSS_DaylightOnOff) + { + utcTime += NSS_DaylightOffset; + } + + numLeapYears = utcTime / SECONDS_IN_4_YEARS; + utcTime -= numLeapYears * SECONDS_IN_4_YEARS; + + + /* first unroll the years*/ + for (year=1970+(numLeapYears<<2),leapYear=2;;leapYear = (leapYear+1) & 0x03,year++) + { + if (leapYear == 0) + { + if (utcTime >= SECONDS_IN_A_LEAPYEAR) + { + utcTime -= SECONDS_IN_A_LEAPYEAR; + } + else + break; + + } + else + { + if (utcTime >= SECONDS_IN_A_YEAR) + { + utcTime -= SECONDS_IN_A_YEAR; + } + else + break; + } + } + + if (leapYear != 0) + { + /* Not a leap year */ + for (month=1;;month++) + { + zASSERT(month<=12); + if (utcTime < secondsAtEndOfMonth[month]) + { + utcTime -= secondsAtEndOfMonth[month-1]; + break; + } + } + } + else + { + /* leap year */ + for (month=1;;month++) + { + zASSERT(month<=12); + if (utcTime < secondsAtEndOfLeapMonth[month]) + { + utcTime -= secondsAtEndOfLeapMonth[month-1]; + break; + } + } + } + + time.CMonth = month; /* Month should be 1 based not zero based */ + + time.CDay = (utcTime / SECONDS_IN_A_DAY) + 1; /* Days are 1 based also*/ + utcTime = utcTime % SECONDS_IN_A_DAY; + + time.CHour = utcTime / SECONDS_IN_AN_HOUR; + utcTime = utcTime % SECONDS_IN_AN_HOUR; + + time.CMinute = utcTime / SECONDS_IN_A_MINUTE; + utcTime = utcTime % SECONDS_IN_A_MINUTE; + + time.CSecond = utcTime; + + sprintf(str,MSGNot("%02d-%s-%d %02d:%02d:%02d"), + time.CDay, MONTH_NAMES(time.CMonth), year, + time.CHour, time.CMinute, time.CSecond); + + + return(str); + +} + diff --git a/src/nwnss/library/debug/assert.c b/src/nwnss/library/debug/assert.c new file mode 100644 index 0000000..a225004 --- /dev/null +++ b/src/nwnss/library/debug/assert.c @@ -0,0 +1,96 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library routine that handles ASSERTION failures. + +-------------------------------------------------------------------------*/ +#include "procdefs.h" /* NetWare includes*/ + +#include /* NSS Library Includes*/ +#include +#include + +#if NSS_DEBUG IS_ENABLED +#ifndef __linux__ // LINUX_Debug +static char AssertMsg[]=MSGNot("\nASSERT FAILED: %s\n"); +#else +static char AssertMsg[]=MSGNot("<1>\nASSERT FAILED: %s\n"); +#endif +int DBG_DebugBreak = 1; + +/************************************************************************** + * Report ASSERTION errors and then ABEND. + ***************************************************************************/ +int DBG_AssertError( + char *err) +{ + //ZFlushDebug(); + /* Print into debug buffer */ + DBG_DebugPrintf( LGRAY, (char *)AssertMsg, err ); +#ifdef __linux__ // LINUX_Debug + printk( AssertMsg, err); +#else + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID,LRED,(char *)AssertMsg, err); +#endif + //OutputToScreenWithAttribute(COMN_Resource.debuggerScreenID,LRED,(char *)AssertMsg, err); + + return 0; +} +/************************************************************************** + * Report ASSERTION errors and then ABEND. + ***************************************************************************/ +int DBG_AssertError_MP( + char *err) +{ + //ZFlushDebug(); + /* Print into debug buffer */ +#ifdef __linux__ // LINUX_Debug + printk( AssertMsg, err); +#else + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID,LRED,(char *)AssertMsg, err); + //OutputToScreenWithAttribute(COMN_Resource.debuggerScreenID,LRED,(char *)AssertMsg, err); + +#endif + return 0; +} + +/**************************************************************************** + * This is a stub routine that is called so the debugger breaks on the + * properly line on asserts + *****************************************************************************/ +int DBG_AssertErrorStub() +{ + return 0; +} + +#endif diff --git a/src/nwnss/library/debug/dbgerror.c b/src/nwnss/library/debug/dbgerror.c new file mode 100644 index 0000000..002ebe0 --- /dev/null +++ b/src/nwnss/library/debug/dbgerror.c @@ -0,0 +1,58 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + +-------------------------------------------------------------------------*/ +#ifndef UNIX +#include +#endif +#include + +#if NSS_DEBUG IS_ENABLED +/**************************************************************************** + * Display an error message and continue + *****************************************************************************/ +int DBG_error(char *where, char *string, int errCode) +{ + if (errCode) + { + PRINT(LGRAY) MSGNot("ERROR: %s %s=%d\n"), where, string, errCode); + } + else + { + PRINT(LGRAY) MSGNot("ERROR: %s %s\n"), where, string); + } + return errCode; +} +#endif diff --git a/src/nwnss/library/debug/dbgfatal.c b/src/nwnss/library/debug/dbgfatal.c new file mode 100644 index 0000000..ee34550 --- /dev/null +++ b/src/nwnss/library/debug/dbgfatal.c @@ -0,0 +1,67 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996-1998 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_Abend +#include /* OS include files*/ + +#ifndef UNIX +#include /* NSS Library includes */ +#endif + +#include + +/**************************************************************************** + * Display a FATAL msg, enter the debugger, and then Abend the server. + * The goal of this function is that NOONE calls it!!! + * + * Callers can assume + *****************************************************************************/ +DBG_fatal (char *where, char *string, int errCode) +{ + static char fatalmsg[] = MSGNot("** FATAL ** %s %s %d\n"); + static char fatalmsg_noCode[] = MSGNot("** FATAL ** %s %s\n"); + char *msg = (errCode != 0) ? fatalmsg : fatalmsg_noCode; + + PRINT(LRED) msg, where, string, errCode); +#if NSS_DEBUG IS_ENABLED + LB_aprintf( LRED, msg, where, string, errCode ); + ZOS_EnterDebugger(); +#else + ZOS_Abend(string); +#endif + return 0; +} +#endif diff --git a/src/nwnss/library/debug/dbginit.c b/src/nwnss/library/debug/dbginit.c new file mode 100644 index 0000000..bbc4e1c --- /dev/null +++ b/src/nwnss/library/debug/dbginit.c @@ -0,0 +1 @@ +#include diff --git a/src/nwnss/library/debug/dfi.c b/src/nwnss/library/debug/dfi.c new file mode 100644 index 0000000..dcd23d8 --- /dev/null +++ b/src/nwnss/library/debug/dfi.c @@ -0,0 +1,1056 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | DFI - Generic code that understands how to display information + | in XML format given the information structure definition + | (as described by a DFI_DataFormatInformation_s)/ + | + |--------------------------------------------------------------------------- + | + | $Author: gpachner $ + | $Date: 2007-06-15 03:05:05 +0530 (Fri, 15 Jun 2007) $ + | + | $RCSfile$ + | $Revision: 2058 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | + +-------------------------------------------------------------------------*/ +#include +#include +#include +#include + +//#include "sdZLSS.h" +#ifndef NTLIB +#include "utc.h" /* FOr NSS's UTCTime2Str routine */ +#endif + +#include "ntlib.h" +#include "dfi.h" + +/* Official API Routine + * + */ +STATUS DFI_DisplayStructure( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer ) + +{ + unsigned int i; + + for ( i = 0; dfi[i].DFI_Type != DFI_TYPE_END; i++ ) + { + DFI_Display( co, &dfi[i], buffer, dfi[i].DFI_Offset ); + } + return( zOK ); +} + + +unsigned int DFI_BasicSizeOf( DFI_DataFormatInformation_s *dfi ) +{ + unsigned int size; + + switch( dfi->DFI_Type ) + { + case DFI_TYPE_END: + size = 0; + break; + case DFI_TYPE_BYTE: + case DFI_TYPE_char_STR: + size = 1; + break; + case DFI_TYPE_WORD: + case DFI_TYPE_unicode_t: + case DFI_TYPE_unicode_t_STR: + case DFI_TYPE_unicode_t_ARRAY: + size = 2; + break; + case DFI_TYPE_Blknum_t: + case DFI_TYPE_LONG: + case DFI_TYPE_Time_t: +#ifndef __LP64__ + case DFI_TYPE_STRUCT_PTR: +#endif + size = 4; + break; + case DFI_TYPE_Zid_t: + case DFI_TYPE_Lsn_t: + case DFI_TYPE_QBlknum_t: + case DFI_TYPE_SQUAD: + case DFI_TYPE_QUAD: +#ifdef __LP64__ + case DFI_TYPE_STRUCT_PTR: +#endif + size = 8; + break; + case DFI_TYPE_GUID_t: + case DFI_TYPE_VolumeID_t: + case DFI_TYPE_UserID_t: + size = 16; + break; + case DFI_TYPE_STRUCT: + size = dfi->DFI_SizeOf; + break; + default: + size = 0; + } + return( size ); +} /* End of DFI_BasicSizeOf() */ + + + +char *DFI_BasicTypeName( DFI_DataFormatInformation_s *dfi ) +{ + char *typeName; + static char gBadStuff[128]; + + switch( dfi->DFI_Type ) + { + case DFI_TYPE_END: + typeName = "DFI_TYPE_END"; + break; + case DFI_TYPE_BYTE: + typeName = "BYTE"; + break; + case DFI_TYPE_WORD: + typeName = "WORD"; + break; + case DFI_TYPE_unicode_t: + typeName = "unicode_t"; + break; + case DFI_TYPE_char_STR: + typeName = "char_STR"; + break; + case DFI_TYPE_unicode_t_STR: + typeName = "unicode_t_STR"; + break; + case DFI_TYPE_unicode_t_ARRAY: + typeName = "unicode_t_ARRAY"; + break; + case DFI_TYPE_Blknum_t: + typeName = "Blknum_t"; + break; + case DFI_TYPE_LONG: + typeName = "LONG"; + break; + case DFI_TYPE_Time_t: + typeName = "Time_t"; + break; + case DFI_TYPE_Zid_t: + typeName = "Zid_t"; + break; + case DFI_TYPE_Lsn_t: + typeName = "Lsn_t"; + break; + case DFI_TYPE_STRUCT_PTR: + typeName = &gBadStuff[0]; + typeName[0] = '*'; + strcpy( &typeName[1], dfi->DFI_Name2 ); + break; + case DFI_TYPE_STRUCT: + typeName = &gBadStuff[0]; + strcpy( typeName, dfi->DFI_Name2 ); + break; + case DFI_TYPE_QBlknum_t: + typeName = "QBlknum_t"; + break; + case DFI_TYPE_SQUAD: + typeName = "SQUAD"; + break; + case DFI_TYPE_QUAD: + typeName = "QUAD"; + break; + case DFI_TYPE_GUID_t: + typeName = "GUID_t"; + break; + case DFI_TYPE_VolumeID_t: + typeName = "VolumeID_t"; + break; + case DFI_TYPE_UserID_t: + typeName = "UserID_t"; + break; + default: + typeName = "DFI_TYPE_DEFAULT"; + break; + } + return( typeName ); + +} /* End of DFI_BasicTypeName() */ + + +int DFI_Display_Header_ARRAY( + DFI_CallerOptions_s *co, + char *arrayName, + char *typeName, + unsigned int arrayElements, + unsigned int arraySize, + void *address ) +{ + SNP_PrintBuffer_s *pb = co->DCO_SNPOutput; + int rc; + + SNP_snprintf( WHERE, pb, "DCO_Details & DCO_DETAILS_ADDRESS) + { +#ifdef COMPILER_CODE_WARRIOR + SNP_snprintf( WHERE, pb, " %s=\"0x%llX\"", co->DCO_XMLAttributeAddress, (QUAD)address - (QUAD)co->DCO_LocalAddress + (QUAD)co->DCO_SourceAddress ); +#else + SNP_snprintf( WHERE, pb, " %s=\"0x%LX\"", co->DCO_XMLAttributeAddress, (QUAD)(ADDR)address - (QUAD)(ADDR)co->DCO_LocalAddress + (QUAD)(ADDR)co->DCO_SourceAddress ); +#endif + } + if (co->DCO_Details & DCO_DETAILS_TYPE) + { + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeType, typeName ); + } + if (co->DCO_Details & DCO_DETAILS_SIZE) + { + SNP_snprintf( WHERE, pb, " %s=\"0x%X\"", co->DCO_XMLAttributeSize, arraySize ); + } + if (co->DCO_Details & DCO_DETAILS_SIZE) + { + SNP_snprintf( WHERE, pb, " %s=\"%d\"", co->DCO_XMLAttributeArrayElements, arrayElements ); + } +// if ( (co->DCO_Details & DCO_DETAILS_INDEX) && (arrayElements > 0) ) +// { +// SNP_snprintf( WHERE, pb, " index=\"0x%X\"", index ); +// } + if (co->DCO_Details & DCO_DETAILS_NAME) + { /** We wait on the name so that it is next to the value **/ + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeName, arrayName ); + } +// rc = SNP_snprintf( WHERE, pb, "\n", tag, (QUAD)address, arraySize, typeName, arrayElements ); + rc = SNP_snprintf( WHERE, pb, ">\n" ); + return( DFI_SNPToStatus( co, pb, rc, WHERE ) ); + +} + +int DFI_Display_Tail_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + char *typeName ) +{ + SNP_PrintBuffer_s *pb = co->DCO_SNPOutput; + int rc; + + rc = SNP_snprintf( WHERE, pb, "\n" ); + return( DFI_SNPToStatus( co, pb, rc, WHERE ) ); + +} + + +int DFI_Display_Header_Structure( + DFI_CallerOptions_s *co, + char *tag, + char *structureName, + unsigned int index, + unsigned int arrayElements, + unsigned int structureSize, /* As defined by sizeof */ + void *address ) +{ + SNP_PrintBuffer_s *pb = co->DCO_SNPOutput; + int rc; + + SNP_snprintf( WHERE, pb, "<%s", co->DCO_XMLTagStructure ); + + if (co->DCO_Details & DCO_DETAILS_ADDRESS) + { +#ifdef COMPILER_CODE_WARRIOR + SNP_snprintf( WHERE, pb, " %s=\"0x%llX\"", co->DCO_XMLAttributeAddress, (QUAD)address - (QUAD)co->DCO_LocalAddress + (QUAD)co->DCO_SourceAddress ); +#else + SNP_snprintf( WHERE, pb, " %s=\"0x%LX\"", co->DCO_XMLAttributeAddress, (QUAD)(ADDR)address - (QUAD)(ADDR)co->DCO_LocalAddress + (QUAD)(ADDR)co->DCO_SourceAddress ); +#endif + } + if (co->DCO_Details & DCO_DETAILS_TYPE) + { + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeType, structureName ); + } + if (co->DCO_Details & DCO_DETAILS_SIZE) + { + SNP_snprintf( WHERE, pb, " %s=\"0x%X\"", co->DCO_XMLAttributeSize, structureSize ); + } + if ( (co->DCO_Details & DCO_DETAILS_INDEX) && (arrayElements > 0) ) + { + SNP_snprintf( WHERE, pb, " %s=\"0x%X\"", co->DCO_XMLAttributeIndex, index ); + } + + if (co->DCO_Details & DCO_DETAILS_NAME) + { /** We wait on the name so that it is next to the value **/ + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeName, tag ); + } + + rc = SNP_snprintf( WHERE, pb, ">\n" ); + return( DFI_SNPToStatus( co, pb, rc, WHERE ) ); + +} + +/* + * Routine to convert from a LB_vsnprintf error to a STATUS + * and setter. + */ +STATUS DFI_SNPToStatus( + DFI_CallerOptions_s *co, /* Place to stick the error */ + SNP_PrintBuffer_s *pb, /* Print object the rc is from */ + int rc, + char *where ) +{ + + if ( rc < 0 ) + { /* Mal formed format string */ + DFI_SetErrnoAndWhere( co, zERR_BAD_PARAMETER_VALUE, where ); + return( zERR_BAD_PARAMETER_VALUE ); + } + else if ( rc == 0 ) + { /* Depending on if grows are allowed then */ + if ( pb->SPB_Alloc == NULL ) + { /* No alloc routine */ + DFI_SetErrnoAndWhere( co, zERR_BUFFER_TOO_SMALL, where ); + return( zERR_BUFFER_TOO_SMALL ); + } + else + { /* Alloc routine must have not allocated any memory */ + DFI_SetErrnoAndWhere( co, zERR_NO_MEMORY, where ); + return( zERR_NO_MEMORY ); + } + } + return( zOK ); + +} + + +STATUS DFI_Display_Header_Union( + DFI_CallerOptions_s *co, + char *name, + char *unionName, + unsigned int index, + unsigned int arrayElements, + unsigned int unionSize, /* As defined by sizeof */ + void *address ) +{ + SNP_PrintBuffer_s *pb = co->DCO_SNPOutput; + int rc; + + SNP_snprintf( WHERE, pb, "DCO_Details & DCO_DETAILS_ADDRESS) + { +#ifdef COMPILER_CODE_WARRIOR + SNP_snprintf( WHERE, pb, " %s=\"0x%llX\"", co->DCO_XMLAttributeAddress, (QUAD)address - (QUAD)co->DCO_LocalAddress + (QUAD)co->DCO_SourceAddress ); +#else + SNP_snprintf( WHERE, pb, " %s=\"0x%LX\"", co->DCO_XMLAttributeAddress, (QUAD)(ADDR)address - (QUAD)(ADDR)co->DCO_LocalAddress + (QUAD)(ADDR)co->DCO_SourceAddress ); +#endif + } + if (co->DCO_Details & DCO_DETAILS_TYPE) + { + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeType, unionName ); + } + if (co->DCO_Details & DCO_DETAILS_SIZE) + { + SNP_snprintf( WHERE, pb, " %s=\"0x%X\"", co->DCO_XMLAttributeSize, unionSize ); + } + if ( (co->DCO_Details & DCO_DETAILS_INDEX) && (arrayElements > 0) ) + { + SNP_snprintf( WHERE, pb, " %s=\"0x%X\"", co->DCO_XMLAttributeIndex, index ); + } + + if (co->DCO_Details & DCO_DETAILS_NAME) + { /** We wait on the name so that it is next to the value **/ + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeName, name ); + } + + rc = SNP_snprintf( WHERE, pb, ">\n" ); + return( DFI_SNPToStatus( co, pb, rc, WHERE ) ); + +} /* End of DFI_Display_Header_Union() */ + + +STATUS DFI_Display_Tail_Union( + DFI_CallerOptions_s *co, + char *unionName, + unsigned int unionSize, /* As defined by sizeof */ + void *address ) +{ + SNP_PrintBuffer_s *pb = co->DCO_SNPOutput; + int rc; + + rc = SNP_snprintf( WHERE, pb, "DCO_Details & DCO_DETAILS_TYPE) + { + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeType, unionName ); + } +#endif + rc = SNP_snprintf( WHERE, pb, ">\n" ); + return( DFI_SNPToStatus( co, pb, rc, WHERE ) ); + +} + + +STATUS DFI_Display_Tail_Structure( + DFI_CallerOptions_s *co, + char *structureName, + unsigned int structureSize, /* As defined by sizeof */ + void *address ) +{ + SNP_PrintBuffer_s *pb = co->DCO_SNPOutput; + int rc; + + rc = SNP_snprintf( WHERE, pb, "DCO_XMLTagStructure ); +#if 0 +// The name in the End Tag would be nice for viewing, but appears to be illegal XML + if (co->DCO_Details & DCO_DETAILS_TYPE) + { + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeType, structureName ); + } +#endif + rc = SNP_snprintf( WHERE, pb, ">\n" ); + return( DFI_SNPToStatus( co, pb, rc, WHERE ) ); + +} + + +/* Official API Routine + * + * We don't set error code in 'co' because 'co' is not legal. + */ +STATUS DFI_COValidate( + DFI_CallerOptions_s *co ) + +{ + + if ( co == NULL ) + { + return( DFI_ERROR_CALLER_OPTION_STRUCTURE_NULL ); + } + if ( (co->DCO_Signature1 != DCO_SIGNATURE1 ) || + (co->DCO_Signature2 != DCO_SIGNATURE2) ) + { + return( DFI_ERROR_CALLER_OPTION_STRUCTURE_SIGNATURE_BAD ); + } + return( DFI_OK ); + +} + + +/* Official API Routine + * + */ +STATUS DFI_Close( + DFI_CallerOptions_s *co ) +{ + + STATUS status; + + status = DFI_COValidate( co ); + if ( status != 0 ) + { + return( status ); + } + free( co ); + return( DFI_OK ); + +} /* End of DFI_Close() */ + + +/* Official API Routine + * + */ +DFI_CallerOptions_s *DFI_Open( + SNP_PrintBuffer_s *pbOutput, + SNP_PrintBuffer_s *pbErrors, + int outputType, + int details, + int arraySize, /* 0 for no limit */ + int expandLevel, /* 0 for no limit */ + void *localAddress, /* Local Address (where data is being processed from) */ + void *sourceAddress ) /* Address that memory is really from */ + +{ + DFI_CallerOptions_s *co; + + if ( (outputType != DCO_OUTPUT_TYPE_XML) && (outputType != DCO_OUTPUT_TYPE_XML_SHORT) ) + { + SNP_snprintf( WHERE, pbErrors, "%s FATAL: 'outputType' must be DCO_OUTPUT_TYPE_XML or DCO_OUTPUT_TYPE_XML_SHORT", WHERE ); + return( NULL ); + } + co = (void *)malloc( sizeof( *co ) ); + if ( co == NULL ) + { + SNP_snprintf( WHERE, pbErrors, "%s FATAL: Out of memory\n", WHERE ); + return( co ); + } + memset( co, 0, sizeof( *co ) ); + co->DCO_Signature1 = DCO_SIGNATURE1; + co->DCO_OutputType = outputType; + co->DCO_SNPOutput = pbOutput; + co->DCO_SNPErrors = pbErrors; + DFI_ClearErrno( co ); + co->DCO_Details = details; + co->DCO_ArraySize = arraySize; + co->DCO_ExpandLevel = expandLevel; + co->DCO_LocalAddress = localAddress; + co->DCO_SourceAddress = sourceAddress; + co->DCO_Zid = 0; + co->DCO_AuthType = DCO_AUTHTYPE_ZAS; + if ( outputType == DCO_OUTPUT_TYPE_XML ) + { // This must be unique within tags + co->DCO_XMLTagBasic = "Basic"; + co->DCO_XMLTagStructure = "Structure"; + // This must be unique within attibutes + co->DCO_XMLAttributeAddress = "Address"; + co->DCO_XMLAttributeArrayElements = "ArrayElements"; + co->DCO_XMLAttributeDate = "Date"; + co->DCO_XMLAttributeIndex = "Index"; + co->DCO_XMLAttributeName = "Name"; + co->DCO_XMLAttributeSize = "Size"; + co->DCO_XMLAttributeType = "Type"; + co->DCO_XMLAttributeTypeCount = "TypeCount"; + co->DCO_XMLAttributeValue = "Value"; + co->DCO_XMLAttributeValueCount = "ValueCount"; + } + else + { // This must be unique within tags + co->DCO_XMLTagBasic = "B"; + co->DCO_XMLTagStructure = "S"; + // This must be unique within attibutes + co->DCO_XMLAttributeAddress = "A"; + co->DCO_XMLAttributeArrayElements = "AE"; + co->DCO_XMLAttributeDate = "D"; + co->DCO_XMLAttributeIndex = "I"; + co->DCO_XMLAttributeName = "N"; + co->DCO_XMLAttributeSize = "S"; + co->DCO_XMLAttributeType = "T"; + co->DCO_XMLAttributeTypeCount = "TC"; + co->DCO_XMLAttributeValue = "V"; + co->DCO_XMLAttributeValueCount = "VC"; + } + co->DCO_Signature2 = DCO_SIGNATURE2; + return( co ); + +} /* End of DFI_Open() */ + + +/* Internal Routine + * + */ +STATUS DFI_Display_Type_yyy_ARRAY_With_Count_zzz( + DFI_CallerOptions_s *co, + char *tag, + int index, + QUAD yyyValue, + QUAD zzzValue, + char *yyyType, + char *zzzType, + void *yyyAddress, + unsigned int yyySize ) +{ + SNP_PrintBuffer_s *pb = co->DCO_SNPOutput; + int rc; + + SNP_snprintf( WHERE, pb, "<%s %s=\"%d\" ", tag, co->DCO_XMLAttributeIndex, index ); // XML + if (co->DCO_Details & DCO_DETAILS_ADDRESS) + { +#ifdef COMPILER_CODE_WARRIOR + SNP_snprintf( WHERE, pb, "%s=\"0x%llX\" ", co->DCO_XMLAttributeAddress, (QUAD)yyyAddress - (QUAD)co->DCO_LocalAddress + (QUAD)co->DCO_SourceAddress ); +#else + SNP_snprintf( WHERE, pb, "%s=\"0x%LX\" ", co->DCO_XMLAttributeAddress, (QUAD)(ADDR)yyyAddress - (QUAD)(ADDR)co->DCO_LocalAddress + (QUAD)(ADDR)co->DCO_SourceAddress ); +#endif + } + if (co->DCO_Details & DCO_DETAILS_TYPE) + { + SNP_snprintf( WHERE, pb, "%s=\"%s\" ", co->DCO_XMLAttributeType, yyyType ); + SNP_snprintf( WHERE, pb, "%s=\"%s\" ", co->DCO_XMLAttributeTypeCount, zzzType ); + } + SNP_snprintf( WHERE, pb, "%s=\"0x%X\" ", co->DCO_XMLAttributeValue, yyyValue ); + SNP_snprintf( WHERE, pb, "%s=\"0x%X\" ", co->DCO_XMLAttributeValueCount, zzzValue ); + + rc = SNP_snprintf( WHERE, pb, "/>\n", zzzValue ); // XML +// rc = SNP_snprintf( WHERE, pb, "<%s index=\"%d\" countType=\"Blkcnt_t\" countValue=\"0x%X\" type=\"Blknum_t\" value=\"0x%X\"/>\n", tag, index, *count, *block ); + return( DFI_SNPToStatus( co, pb, rc, WHERE ) ); + +} /* End of DFI_Display_Type_Blknum_t_ARRAY_With_Count_Blkcnt_t() */ + + +/* Official API Routine + * + */ +STATUS DFI_Display_Type_Blknum_t_ARRAY_With_Count_Blkcnt_t( + DFI_CallerOptions_s *co, + char *tag, + int index, + Blknum_t *block, + Blkcnt_t *count ) +{ + STATUS status; + + status = DFI_Display_Type_yyy_ARRAY_With_Count_zzz( co, tag, index, *block, *count, "Blknum_t", "Blkcnt_t", block, sizeof( *block ) ); +// rc = SNP_snprintf( WHERE, pb, "<%s index=\"%d\" countType=\"Blkcnt_t\" countValue=\"0x%X\" type=\"Blknum_t\" value=\"0x%X\"/>\n", tag, index, *count, *block ); + return( status ); + +} /* End of DFI_Display_Type_Blknum_t_ARRAY_With_Count_Blkcnt_t() */ + + + +/* Official API Routine + * + * Returns - + * zOK for no error else 'co' has errno(I.E. STATUS) and + * the errno setter. On errors, co->DCO_SNPErrors MAY have + * a message. On errors, co->DCO_SNPOutput will be contain + * partial results and therefore should not be parsed. + * + */ +STATUS DFI_Display( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset ) + +{ + SNP_PrintBuffer_s *pb; + STATUS status; + int rc; + NINT size; + NINT array; + char *cValue; + unicode_t *uValue; + NINT lOffset; /* Local Offset */ + + status = DFI_COValidate( co ); + if ( status != 0 ) + { /* Invalid 'co' */ +// DFI_SetErrno( co, status ); We do not set as 'co' is invaid + return( status ); + } + + pb = co->DCO_SNPOutput; + if ( dfi->DFI_ArrayElements == 0 ) + { + status = DFI_DisplayElement( co, dfi, buffer, offset, 0 ); + } + else + { + switch( dfi->DFI_Type ) + { + case DFI_TYPE_END: + size = 0; + break; + case DFI_TYPE_char_STR: + /* We verify that the string is NULL terminated so + * we do not blow up in displaying it. + */ + SNP_snprintf( WHERE, pb, "<%s", co->DCO_XMLTagBasic ); + size = DFI_BasicSizeOf( dfi ) * dfi->DFI_ArrayElements; + if (co->DCO_Details & DCO_DETAILS_ADDRESS) + { + SNP_snprintf( WHERE, pb, " %s=\"0x%lX\"", co->DCO_XMLAttributeAddress, (long)(buffer+offset) - (long)co->DCO_LocalAddress + (long)co->DCO_SourceAddress ); + } + if (co->DCO_Details & DCO_DETAILS_TYPE) + { + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeType, DFI_BasicTypeName( dfi ) ); + } + if (co->DCO_Details & DCO_DETAILS_SIZE) + { + SNP_snprintf( WHERE, pb, " %s=\"%d\"", co->DCO_XMLAttributeSize, size ); + } +// if ( (co->DCO_Details & DCO_DETAILS_INDEX) && (dfi->DFI_ArrayElements > 0) ) +// { +// SNP_snprintf( WHERE, pb, " index=\"%d\"", index ); +// } + if (co->DCO_Details & DCO_DETAILS_NAME) + { /** We wait on the name so that it is next to the value **/ + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeName, dfi->DFI_Name ); + } + if (co->DCO_Details & DCO_DETAILS_VALUE) + { + SNP_snprintf( WHERE, pb, " %s=\"", co->DCO_XMLAttributeValue ); + cValue = (void *)(buffer + offset); + lOffset = offset; + for ( array = 0; array < dfi->DFI_ArrayElements; array++ ) + { + if ( cValue[array] == 0 ) + { + break; + } + SNP_snprintf( WHERE, pb, "%c", *(char *)(buffer+lOffset) ); + lOffset += 1; + } + } + rc = SNP_snprintf( WHERE, pb, "\"/>\n"); + status = DFI_SNPToStatus( co, pb, rc, WHERE ); + break; + case DFI_TYPE_unicode_t_STR: + /* We verify that the string is NULL terminated so + * we do not blow up in displaying it. + */ + SNP_snprintf( WHERE, pb, "<%s", co->DCO_XMLTagBasic ); + size = DFI_BasicSizeOf( dfi ) * dfi->DFI_ArrayElements; + if (co->DCO_Details & DCO_DETAILS_ADDRESS) + { + SNP_snprintf( WHERE, pb, " %s=\"0x%lX\"", co->DCO_XMLAttributeAddress, (long)(buffer+offset) - (long)co->DCO_LocalAddress + (long)co->DCO_SourceAddress ); + } + if (co->DCO_Details & DCO_DETAILS_TYPE) + { + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeType, DFI_BasicTypeName( dfi ) ); + } + if (co->DCO_Details & DCO_DETAILS_SIZE) + { + SNP_snprintf( WHERE, pb, " %s=\"%d\"", co->DCO_XMLAttributeSize, size ); + } +// if ( (co->DCO_Details & DCO_DETAILS_INDEX) && (dfi->DFI_ArrayElements > 0) ) +// { +// SNP_snprintf( WHERE, pb, " index=\"%d\"", index ); +// } + if (co->DCO_Details & DCO_DETAILS_NAME) + { /** We wait on the name so that it is next to the value **/ + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeName, dfi->DFI_Name ); + } + if (co->DCO_Details & DCO_DETAILS_VALUE) + { + SNP_snprintf( WHERE, pb, " %s=\"", co->DCO_XMLAttributeValue ); + uValue = (void *)(buffer + offset); + lOffset = offset; + for ( array = 0; array < dfi->DFI_ArrayElements; array++ ) + { + if ( uValue[array] == 0 ) + { + break; + } + SNP_snprintf( WHERE, pb, "%c", *(WORD *)(buffer+lOffset) ); // Not real UNICODE conversion here FixFixFix Plus need to ESCAPE quotes + lOffset += 2; + } + SNP_snprintf( WHERE, pb, "\""); // XML + } + rc = SNP_snprintf( WHERE, pb, "/>\n"); // XML + status = DFI_SNPToStatus( co, pb, rc, WHERE ); + break; + case DFI_TYPE_unicode_t_ARRAY: + SNP_snprintf( WHERE, pb, "<%s", co->DCO_XMLTagBasic ); + size = DFI_BasicSizeOf( dfi ) * dfi->DFI_ArrayElements; + if (co->DCO_Details & DCO_DETAILS_ADDRESS) + { + SNP_snprintf( WHERE, pb, " %s=\"0x%lX\"", co->DCO_XMLAttributeAddress, (long)(buffer+offset) - (long)co->DCO_LocalAddress + (long)co->DCO_SourceAddress ); + } + if (co->DCO_Details & DCO_DETAILS_TYPE) + { + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeType, DFI_BasicTypeName( dfi ) ); + } + if (co->DCO_Details & DCO_DETAILS_SIZE) + { + SNP_snprintf( WHERE, pb, " %s=\"%d\"", co->DCO_XMLAttributeSize, size ); + } +// if ( (co->DCO_Details & DCO_DETAILS_INDEX) && (dfi->DFI_ArrayElements > 0) ) +// { +// SNP_snprintf( WHERE, pb, " index=\"%d\"", index ); +// } + if (co->DCO_Details & DCO_DETAILS_NAME) + { /** We wait on the name so that it is next to the value **/ + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeName, dfi->DFI_Name ); + } + if (co->DCO_Details & DCO_DETAILS_VALUE) + { + SNP_snprintf( WHERE, pb, " %s=\"", co->DCO_XMLAttributeValue ); + uValue = (void *)(buffer + offset); + lOffset = offset; + for ( array = 0; array < dfi->DFI_ArrayElements; array++ ) + { + SNP_snprintf( WHERE, pb, "%c", *(WORD *)(buffer+lOffset) ); // Not real UNICODE conversion here FixFixFix Plus need to ESCAPE quotes + lOffset += 2; + } + } + rc = SNP_snprintf( WHERE, pb, "\"/>\n"); // XML + status = DFI_SNPToStatus( co, pb, rc, WHERE ); + break; + default: + { + BYTE *data = buffer+offset; + + lOffset = offset; + if ( dfi->DFI_ArrayElements > 0 ) + { + (void)DFI_Display_Header_ARRAY( co, dfi->DFI_Name, + DFI_BasicTypeName( dfi ), + dfi->DFI_ArrayElements, + dfi->DFI_ArrayElements * DFI_BasicSizeOf( dfi ), + &data[0] ); + } + for ( array = 0; array < dfi->DFI_ArrayElements; array++ ) + { + size = DFI_DisplayElement( co, dfi, buffer, lOffset, array ); + if ( size < 0 ) + { /* Error condition */ + status = DFI_GetErrno( co ); + break; + } + lOffset += size; + } + if ( dfi->DFI_ArrayElements > 0 ) + { + (void)DFI_Display_Tail_ARRAY( co, dfi->DFI_Name, DFI_BasicTypeName( dfi ) ); + } + } + break; + } + } + return( status ); +} + + +SIZEOF DFI_DisplayElement( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ) +{ + STATUS status; + SIZEOF size = -1; + + switch( co->DCO_OutputType ) + { + case DCO_OUTPUT_TYPE_XML: + size = DFI_DisplayElementXML( co, dfi, buffer, offset, index ); + break; +// case DCO_OUTPUT_TYPE_ASCII: +// status = DFI_DisplayElementASCII( co, dfi, buffer, offset, index ); +// break; + default: + status = zERR_BAD_PARAMETER_VALUE; + DFI_SetErrno( co, status ); + break; + } + return( size ); + +} + + +char *DFI_UTCTime2Str( +#ifdef NTLIB + LONG longTime, +#else + Time_t cTime, +#endif + char *buffer, + NINT bufLen ) +{ +#ifdef NTLIB + struct tm *tmTime; + time_t cTime; + + cTime = longTime; + tmTime = localtime( &cTime ); + strftime(buffer, bufLen, "%b %d, %Y %I:%M:%S %p %z", tmTime); +#else + /* Note that the NetWare function does NOT take the length of the buffer. + * We use the DEBUG version so that we do not release the NSS spinlock + * which we may not hold. + */ + DBG_UTCTime2Str( cTime, buffer ); +#endif + return( buffer ); +// printf( "\n %s\n", aTime ); + +} /* End of DFI_UTCTime2Str() */ + + +SIZEOF DFI_DisplayElementXML( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ) + +{ + int rc; + SNP_PrintBuffer_s *pb; + STATUS status; + NINT size = 0; + char timeBuffer[80]; + + status = DFI_COValidate( co ); + if ( status != zOK ) + { + return( -1 ); + } + /* Handle NON-BASIC items */ + if ( dfi->DFI_Type == DFI_TYPE_STRUCT ) + { + size = dfi->DFI_Routine( co, dfi, buffer + offset, 0, index ); // FixFixFix is it correct to say offset 0 - I think so. + return( size ); + } + else if ( dfi->DFI_Type == DFI_TYPE_UNION_HEADER ) + { + status = DFI_Display_Header_Union( co, dfi->DFI_Name, dfi->DFI_Name2, index, 0, dfi->DFI_SizeOf, buffer + offset); + if ( status == zOK ) + { + return( size ); + } + return( -1 ); + } + else if ( dfi->DFI_Type == DFI_TYPE_UNION_TAIL ) + { + status = DFI_Display_Tail_Union( co, dfi->DFI_Name, dfi->DFI_SizeOf, buffer + offset); + if ( status == zOK ) + { + return( size ); + } + return( -1 ); + } + /* Handle BASIC items */ + pb = co->DCO_SNPOutput; + SNP_snprintf( WHERE, pb, "<%s", co->DCO_XMLTagBasic ); + size = DFI_BasicSizeOf( dfi ); + /**** FixFixFix ****/ + /** This would be a good place to handle address range checking for NetWare **/ + /** This would be a good place to handle address range checking for NetWare **/ + /** This would be a good place to handle address range checking for NetWare **/ + /** This would be a good place to handle address range checking for NetWare **/ + + if (co->DCO_Details & DCO_DETAILS_ADDRESS) + { + SNP_snprintf( WHERE, pb, " %s=\"0x%lX\"", co->DCO_XMLAttributeAddress, (long)(buffer+offset) - (long)co->DCO_LocalAddress + (long)co->DCO_SourceAddress ); + } + if (co->DCO_Details & DCO_DETAILS_TYPE) + { + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeType, DFI_BasicTypeName( dfi ) ); + } + if (co->DCO_Details & DCO_DETAILS_SIZE) + { + SNP_snprintf( WHERE, pb, " %s=\"%d\"", co->DCO_XMLAttributeSize, size ); + } + if ( (co->DCO_Details & DCO_DETAILS_INDEX) && (dfi->DFI_ArrayElements > 0) ) + { + SNP_snprintf( WHERE, pb, " %s=\"%d\"", co->DCO_XMLAttributeIndex, index ); + } + if (co->DCO_Details & DCO_DETAILS_NAME) + { /** We wait on the name so that it is next to the value **/ + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeName, dfi->DFI_Name ); + } + if (co->DCO_Details & DCO_DETAILS_VALUE) + { + switch( dfi->DFI_Type ) + { + case DFI_TYPE_END: + break; + case DFI_TYPE_BYTE: + SNP_snprintf( WHERE, pb, " %s=\"0x%X\"", co->DCO_XMLAttributeValue, *(BYTE *)(buffer+offset) ); + break; + case DFI_TYPE_WORD: + SNP_snprintf( WHERE, pb, " %s=\"0x%X\"", co->DCO_XMLAttributeValue, *(WORD *)(buffer+offset) ); + break; + case DFI_TYPE_LONG: + SNP_snprintf( WHERE, pb, " %s=\"0x%lX\"", co->DCO_XMLAttributeValue, *(LONG *)(buffer+offset) ); + break; + case DFI_TYPE_SQUAD: +#ifdef COMPILER_CODE_WARRIOR + SNP_snprintf( WHERE, pb, " %s=\"0x%llX\"", co->DCO_XMLAttributeValue, *(SQUAD *)(buffer+offset) ); +#else + SNP_snprintf( WHERE, pb, " %s=\"0x%LX\"", co->DCO_XMLAttributeValue, *(SQUAD *)(buffer+offset) ); +#endif + break; + case DFI_TYPE_QUAD: +#ifdef COMPILER_CODE_WARRIOR + SNP_snprintf( WHERE, pb, " %s=\"0x%llX\"", co->DCO_XMLAttributeValue, *(QUAD *)(buffer+offset) ); +#else + SNP_snprintf( WHERE, pb, " %s=\"0x%LX\"", co->DCO_XMLAttributeValue, *(QUAD *)(buffer+offset) ); +#endif + break; + case DFI_TYPE_Time_t: + SNP_snprintf( WHERE, pb, " %s=\"0x%lX\" %s=\"%s\"", co->DCO_XMLAttributeValue, *(LONG *)(buffer+offset), + co->DCO_XMLAttributeDate, DFI_UTCTime2Str(*(LONG *)(buffer+offset), &timeBuffer[0], sizeof(timeBuffer) ) ); + break; + case DFI_TYPE_unicode_t: + SNP_snprintf( WHERE, pb, " %s=\"%c\"", co->DCO_XMLAttributeValue, *(WORD *)(buffer+offset) ); // Not real UNICODE conversion here FixFixFix + break; + case DFI_TYPE_unicode_t_STR: + SNP_snprintf( WHERE, pb, " %s=\"%c\"", co->DCO_XMLAttributeValue, *(WORD *)(buffer+offset) ); // Not real UNICODE conversion here FixFixFix + break; + case DFI_TYPE_char_STR: + SNP_snprintf( WHERE, pb, " %s=\"%c\"", co->DCO_XMLAttributeValue, *(BYTE *)(buffer+offset) ); + break; + case DFI_TYPE_UserID_t: + case DFI_TYPE_GUID_t: + case DFI_TYPE_VolumeID_t: + (void)LB_GUIDToString( (GUID_t *)(buffer+offset), sizeof(timeBuffer), timeBuffer ); + SNP_snprintf( WHERE, pb, " %s=\"%s\"", co->DCO_XMLAttributeValue, timeBuffer ); + break; + case DFI_TYPE_Lsn_t: +#ifdef COMPILER_CODE_WARRIOR + SNP_snprintf( WHERE, pb, " %s=\"0x%llX\"", co->DCO_XMLAttributeValue, *(QUAD *)(buffer+offset) ); +#else + SNP_snprintf( WHERE, pb, " %s=\"0x%LX\"", co->DCO_XMLAttributeValue, *(QUAD *)(buffer+offset) ); +#endif + break; + case DFI_TYPE_Zid_t: +#ifdef COMPILER_CODE_WARRIOR + SNP_snprintf( WHERE, pb, " %s=\"0x%llX\"", co->DCO_XMLAttributeValue, *(QUAD *)(buffer+offset) ); +#else + SNP_snprintf( WHERE, pb, " %s=\"0x%LX\"", co->DCO_XMLAttributeValue, *(QUAD *)(buffer+offset) ); +#endif + break; + case DFI_TYPE_Blknum_t: + SNP_snprintf( WHERE, pb, " %s=\"0x%lX\"", co->DCO_XMLAttributeValue, *(LONG *)(buffer+offset) ); + break; + case DFI_TYPE_QBlknum_t: +#ifdef COMPILER_CODE_WARRIOR + SNP_snprintf( WHERE, pb, " %s=\"0x%llX\"", co->DCO_XMLAttributeValue, *(QUAD *)(buffer+offset) ); +#else + SNP_snprintf( WHERE, pb, " %s=\"0x%LX\"", co->DCO_XMLAttributeValue, *(QUAD *)(buffer+offset) ); +#endif + break; + case DFI_TYPE_STRUCT_PTR: + SNP_snprintf( WHERE, pb, " %s=\"0x%lX\"", co->DCO_XMLAttributeValue, *(ADDR *)(buffer+offset) ); + break; + case DFI_TYPE_STRUCT: + SNP_snprintf( WHERE, pb, " %s=\"0x%lX\"", co->DCO_XMLAttributeValue, (ADDR *)(buffer+offset) ); // FixFixFix - the value is the address or NO VALUE??? + break; + default: + DFI_SetErrno( co, zERR_BAD_PARAMETER_VALUE ); + SNP_snprintf( WHERE, co->DCO_SNPErrors, "%s WARNING: Case %d is not supported in DFI_DisplayElement()\n", WHERE, dfi->DFI_Type); + return( -1 ); + } + } + rc = SNP_snprintf( WHERE, pb, "/>\n"); + if ( DFI_SNPToStatus( co, pb, rc, WHERE ) != zOK ) + { + return( -1 ); + } + return( size ); + +} /* End of DFI_DisplayElementXML() */ + + + + + + + + + + + + + diff --git a/src/nwnss/library/debug/enterDebug.c b/src/nwnss/library/debug/enterDebug.c new file mode 100644 index 0000000..fb50502 --- /dev/null +++ b/src/nwnss/library/debug/enterDebug.c @@ -0,0 +1,330 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + +-------------------------------------------------------------------------*/ +#include +#include /*NSS Library*/ +#ifndef UNIX +#include +#endif +#include +#include + +#if NSS_DEBUG IS_ENABLED +/************************************************************************** + * Need to add code and data structures to handle setjmp/longjmp. + * I would almost need my own versions of those guys. + ***************************************************************************/ +#define MAX_DEPTH 600 + +typedef struct DebugFrame_s +{ + QUAD trace; + char *name; +} DebugFrame_s; + + +typedef struct DebugContext_s +{ + STKlink_t link; + ADDR p_thread; + NINT depth; + DebugFrame_s stk[MAX_DEPTH]; +} DebugContext_s; + +STKtop_t DebugContext = NULL; + +/************************************************************************** + * + ***************************************************************************/ +#define fpush(_context, _trace, _name) \ + { \ + (_context)->stk[(_context)->depth].trace = (_trace); \ + (_context)->stk[(_context)->depth++].name = (_name); \ + } + +/************************************************************************** + * + ***************************************************************************/ +STATIC DebugFrame_s *fpop (DebugContext_s *context) +{ + return &context->stk[--context->depth]; +} + +/************************************************************************** + * + ***************************************************************************/ +STATIC DebugContext_s *newContext (ADDR myThread) +{ + DebugContext_s *context; + + context = (DebugContext_s *)zalloc(sizeof(DebugContext_s)); + if (context == NULL) + { + return NULL; + } + context->p_thread = myThread; + STK_PUSH(DebugContext, context, link); + return context; +} + +/************************************************************************** + * + ***************************************************************************/ +STATIC void freeDebugContext () +{ + DebugContext_s *context; + + for(;;) + { + STK_POP(DebugContext, context, DebugContext_s, link); + if (context == NULL) return; + free(context); + } +} + +/************************************************************************** + * + ***************************************************************************/ +STATIC DebugContext_s *findContext (void) +{ + DebugContext_s *context; + ADDR myThread; + + myThread = (ADDR)kCurrentThread(); + + STK_FOREACH(DebugContext, context, DebugContext_s, link) + { + if (context->p_thread == myThread) + { + return context; + } + } + return newContext(myThread); +} + +/************************************************************************** + * + ***************************************************************************/ +STATIC DebugContext_s *getRtnContext (void) +{ + DebugContext_s *context; + + //if (!zDebug) return NULL; + context = findContext(); + if (context == NULL) return NULL; + if (context->depth == 0) return NULL; + if (context->depth >= MAX_DEPTH) return NULL; + + return context; +} + +/************************************************************************** + * + ***************************************************************************/ +STATIC void printFrameDepth (unsigned frame) +{ + unsigned i; + + for (i = 0; i < frame; ++i) + { + /*PRINT(LGRAY) MSGNot(" "));*/ + PRINT(LGRAY) MSGNot(" ")); + } +} + +/************************************************************************** + * + ***************************************************************************/ +void DBG_Denter (char *where, QUAD trace, char *name) +{ + DebugContext_s *context; + + context = findContext(); + if (context == NULL) return; + + INITDBGIO(); + DBGLOCK(); + if (context->depth >= MAX_DEPTH) + { + PRINT(LRED) MSGNot("Too DEEP %d %s:%s:%x\n"), + context->depth++, name, where, context->p_thread); + ZOS_EnterDebugger(); + } + else + { + if (trace & DBG_TraceFlag) + { + printFrameDepth(context->depth); + /*PRSEQ(LGRAY) MSGNot(">%s:%s\n"), name, where);*/ + PRSEQ(LGRAY) MSGNot(">%s:%s:%x\n"), name, where, context->p_thread); + } + fpush(context, trace, name); + } + DBGUNLOCK(); +} + +/************************************************************************** + * + ***************************************************************************/ +void DBG_Dindent (void) +{ + //DebugContext_s *context; + //if (!zDebug) return 0; + //context = findContext(); + //if (context == NULL) return 0; + //if (context->depth == 0) return 0; + //if (context->depth >= MAX_DEPTH) return 0; + + DebugContext_s *context = getRtnContext(); + if (context != NULL) + { + INITDBGIO(); + DBGLOCK(); + printFrameDepth(context->depth); + DBGUNLOCK(); + } + //return 0; +} + +/************************************************************************** + * + ***************************************************************************/ +STATIC NINT printReturn (char *where) +{ + DebugContext_s *context = getRtnContext(); + DebugFrame_s *frame; + + if (context != NULL) + { + frame = fpop(context); + if (frame->trace & DBG_TraceFlag) + { + INITDBGIO(); + DBGLOCK(); + printFrameDepth(context->depth); + /*PRSEQ(LGRAY) MSGNot("<%s:%s"), frame->name, where);*/ + PRSEQ(LGRAY) MSGNot("<%s:%s:%x"), frame->name, where, context->p_thread); + return TRUE; + } + } + return FALSE; +} + +/************************************************************************** + * + ***************************************************************************/ +void DBG_Dexit (char *where) +{ + if (printReturn(where)) + { + PRINT(LGRAY) MSGNot("\n")); + DBGUNLOCK(); + } +} + +/************************************************************************** + * + ***************************************************************************/ +void DBG_DrtnVoid (char *where) +{ + if (printReturn(where)) + { + PRINT(LGRAY) MSGNot("\n")); + DBGUNLOCK(); + } +} + +/************************************************************************** + * + ***************************************************************************/ +void DBG_DrtnSNINT (char *where, SNINT returnCode) +{ + if (printReturn(where)) + { + PRINT(LGRAY) MSGNot(" return 0x%08x\n"), returnCode); + DBGUNLOCK(); + } +} + +/************************************************************************** + * + ***************************************************************************/ +void DBG_DrtnNINT (char *where, NINT returnCode) +{ + if (printReturn(where)) + { + PRINT(LGRAY) MSGNot(" return 0x%08x\n"), returnCode); + DBGUNLOCK(); + } +} + +/************************************************************************** + * + ***************************************************************************/ +void DBG_DrtnStatus (char *where, STATUS status) +{ + if (printReturn(where)) + { + PRINT(LGRAY) MSGNot(" return %u\n"), status); + DBGUNLOCK(); + } +} + +/************************************************************************** + * + ***************************************************************************/ +void DBG_DrtnPtr (char *where, void *returnCode) +{ + if (printReturn(where)) + { + PRINT(LGRAY) MSGNot(" return 0x%08x\n"), returnCode); + DBGUNLOCK(); + } +} + +/************************************************************************** + * + ***************************************************************************/ +void DBG_DrtnQUAD(char *where, QUAD returnCode) +{ + if (printReturn(where)) + { + PRINT(LGRAY) MSGNot(" return 0x%08x%08x\n"), (NINT)(returnCode >> 32), (NINT)returnCode); + DBGUNLOCK(); + } +} + +#endif diff --git a/src/nwnss/library/debug/ncpTrAsm.386 b/src/nwnss/library/debug/ncpTrAsm.386 new file mode 100644 index 0000000..2812812 --- /dev/null +++ b/src/nwnss/library/debug/ncpTrAsm.386 @@ -0,0 +1,66 @@ +;***************************************************************************** +;* +;* (C) Copyright 1986-1995 Novell, Inc. +;* All Rights Reserved. +;* +;* This program is free software; you can redistribute it and/or +;* modify it under the terms of version 2 of the GNU General Public +;* License as published by the Free Software Foundation. +;* +;* This program is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;* GNU General Public License for more details. +;* +;* You should have received a copy of the GNU General Public License +;* along with this program; if not, contact Novell, Inc. +;* +;* To contact Novell about this file by physical or electronic mail, +;* you may find current contact information at www.novell.com +;* +;* +;* $Author: taysom $ +;* $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ +;* +;* $RCSfile$ +;* $Revision: 465 $ +;* +;***************************************************************************** + .prot + name NCPTRA.386 + +;***************************************************************************** + + assume ds: OSDATA, es: OSDATA, ss: OSDATA + +OSDATA segment rw public 'DATA' +OSDATA ends + +;***************************************************************************** +OSCODE segment er public 'CODE' + + assume cs: OSCODE + + public DBG_NCPTrace + extrn DBG_NCPTraceReport:near + +;---------------------------------------------------------------------------- +; This is the NCP Trace routine that is placed in the NCP SwitchVector +; table when we are doing NCP tracing. It calls a C routine that +; displays what information it wants and returns the address of the +; real routine to go to. We then jump to that real routine. +; +; The routine we call has the following prototype: +; NcpProto_t NCPTraceReport( +; struct RequestPacketStructure *requestPacket); +;---------------------------------------------------------------------------- +DBG_NCPTrace proc + push [esp+4] ;push request buffer (passed in ESI) + call DBG_NCPTraceReport ;print NCP number + add esp,4 + jmp eax + +DBG_NCPTrace endp + +OSCODE ends + end diff --git a/src/nwnss/library/debug/ncpTrace.c b/src/nwnss/library/debug/ncpTrace.c new file mode 100644 index 0000000..11619c7 --- /dev/null +++ b/src/nwnss/library/debug/ncpTrace.c @@ -0,0 +1,417 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | General NCP handling routines in PSS + | + | + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_NCP +#include /* NetWare Includes*/ +#include +#include + +#include /* NSS Library Includes*/ +#include +#include +#include +#include +#include + +//#include "ncpHook.h" + +#if NSS_DEBUG IS_ENABLED +/*------------------------------------------------------------------------- + * General function prototype for NCP handling routines + *-------------------------------------------------------------------------*/ +typedef void (*NcpProto_t)( + struct RequestPacketStructure *requestPacket, + struct ReplyProceduresStructure *RP, + LONG reserved, + LONG PacketSize, + BYTE *Answer, + LONG AnswerBufferLength); + +/************************************************************************** + * Global variables + ***************************************************************************/ +static WFile_s *DBG_NCPTraceScreen = NULL; +static NcpProto_t DBG_NCPFunctions[256]; +static BOOL DBG_NCPsHooked = FALSE; + +#define MAX_NCP_LOG_ENTRIES 64 /* make this divisible by the number of entries on a display line (4)*/ +//#else +//#define MAX_NCP_LOG_ENTRIES 8 +//#endif + +#define NCP_LOG_ENTRY_LENGTH 128 +#define NUM_NCP_LINES (MAX_NCP_LOG_ENTRIES/4) +#define NUM_DUMP_LINES (NCP_LOG_ENTRY_LENGTH/16) + +typedef struct NCPinfo_s +{ + NINT len; /* length of the NCP */ + BYTE info[NCP_LOG_ENTRY_LENGTH]; /* content of the NCP request */ +} NCPinfo_s; + +static BOOL DBG_NCPLogFlag = FALSE; +static NINT DBG_NCPLogIndex = MAX_NCP_LOG_ENTRIES; +static NCPinfo_s DBG_NCPLog[MAX_NCP_LOG_ENTRIES]; + +extern void DBG_NCPTrace( + struct RequestPacketStructure *requestPacket, + struct ReplyProceduresStructure *RP, + LONG reserved, + LONG PacketSize, + BYTE *Answer, + LONG AnswerBufferLength); + +//#if NSS_DEBUG IS_ENABLED +/*************************************************************************** + * display the NCP log + ***************************************************************************/ +void DBG_DisplayNCPLog( + struct ScreenStruct *debugScreen) +{ + NINT requestCode; + NINT entry; + NINT i; + NINT j; + NINT color; + NINT length; +// BYTE keyType; +// BYTE keyValue; + SNINT value=0; + NINT character; + BYTE inputString[80]; + + for (;;) + { + ClearScreen(debugScreen); + PositionOutputCursor(debugScreen, NUM_NCP_LINES, 0); + if (value > 0 && value <= MAX_NCP_LOG_ENTRIES) + { + entry = (DBG_NCPLogIndex + value) % MAX_NCP_LOG_ENTRIES; + length = DBG_NCPLog[entry].len; + if (length > NCP_LOG_ENTRY_LENGTH) + { + length = NCP_LOG_ENTRY_LENGTH; + } + for (i = 0; i < length; i += 16) + { + for (j = 0; j < 8; j++) + { + if (i + j < length) + { + OutputToScreenWithAttribute(debugScreen, WHITE, + MSGNot("%02x "), DBG_NCPLog[entry].info[i + j]); + } + else + { + OutputToScreen(debugScreen, MSGNot(" ")); + } + } + OutputToScreenWithAttribute(debugScreen, WHITE, + MSGNot("| ")); + for (j = 8; j < 16; j++) + { + if (i + j < length) + { + OutputToScreenWithAttribute(debugScreen, WHITE, + MSGNot("%02x "), DBG_NCPLog[entry].info[i + j]); + } + else + { + OutputToScreen(debugScreen, MSGNot(" ")); + } + } + OutputToScreen(debugScreen, MSGNot(" ")); + for (j = 0; j < 16; j++) + { + if (i + j < length) + { + character = DBG_NCPLog[entry].info[i + j]; + if (character >= 32 && character <= 127) + { + OutputToScreenWithAttribute(debugScreen, LGREEN, + MSGNot("%c"), DBG_NCPLog[entry].info[i + j]); + } + else + { + OutputToScreenWithAttribute(debugScreen, GREEN, + MSGNot("."), DBG_NCPLog[entry].info[i + j]); + } + } + else + { + OutputToScreen(debugScreen, MSGNot(" ")); + } + } + OutputToScreen(debugScreen, MSGNot("\n")); + } + } + PositionOutputCursor(debugScreen, 0, 0); + for (i = 1; i <= MAX_NCP_LOG_ENTRIES; i++) + { + if (i == value) + { /* if this is the displayed NCP entry ... */ + color = LCYAN; + } + else + { + color = LGRAY; + } + entry = (DBG_NCPLogIndex + i) % MAX_NCP_LOG_ENTRIES; + requestCode = DBG_NCPLog[entry].info[0]; + OutputToScreenWithAttribute(debugScreen, LBLUE, MSGNot("%2d) "), i); + OutputToScreenWithAttribute(debugScreen, color, MSGNot("%3d"), requestCode); + switch (requestCode) + { + case 21: + case 22: + case 23: + case 35: + case 90: + case 123: + case 131: + OutputToScreenWithAttribute(debugScreen, color, MSGNot(".%-8d "), + DBG_NCPLog[entry].info[3]); + break; + case 32: + case 34: + case 86: + case 87: + case 104: + case 111: + OutputToScreenWithAttribute(debugScreen, color, MSGNot(".%-8d "), + DBG_NCPLog[entry].info[1]); + break; + default: + OutputToScreenWithAttribute(debugScreen, color, MSGNot(" ")); + break; + } + if ((i % 4) == 0) + { + OutputToScreen(debugScreen, MSGNot("\n")); + } + } + PositionOutputCursor(debugScreen, NUM_NCP_LINES + NUM_DUMP_LINES, 0); + OutputToScreenWithAttribute(debugScreen, YELLOW, + MSGNot("Enter entry number for details or Enter to exit")); + PositionInputCursor(debugScreen, NUM_NCP_LINES + NUM_DUMP_LINES, 48); + InputFromKeyboard(debugScreen, MSGNot("0..9"), 3, 3, inputString, 0, 0, MSGNot("")); + OutputToScreen(debugScreen, MSGNot("\n")); + if (strlen(inputString) == 0) + { + return; + } +// GetKey(debugScreen, &keyType, &keyValue, NULL, NULL, 0); +// OutputToScreen(debugScreen, MSGNot("\n")); +// if (keyType == ESCAPE_KEY) +// { +// return; +// } + value = atoi(inputString); + } +} + +/************************************************************************** + * This routine reports the NCPs it has encountered. + ***************************************************************************/ +NcpProto_t DBG_NCPTraceReport( + struct RequestPacketStructure *requestPacket) +{ + NINT requestCode; + NINT subCode; + static char formatStr[] = MSGNot("%3d.%-3d "); + static char formatStrS[] = MSGNot("%3d "); + + MPKNSS_LOCK(); + requestCode = requestPacket->RRequestCode; + /* Display the NCP on the NCP trace screen */ + if (DBG_NCPTraceScreen != NULL) + { + switch (requestCode) + { + /*========================================================================*/ + case 21: /* switch0.c*/ + case 22: /* switch0.c*/ + case 23: /* switch0.c */ + case 35: /* switch2.c, macware.c */ + case 90: /* switch2.c */ + case 123: /* switch2.c */ + case 131: /* switch2.c */ + subCode = requestPacket->RData[2]; + wPrintf(DBG_NCPTraceScreen,formatStr,requestCode,subCode); + break; + /*========================================================================*/ + case 32: /* switch0.c */ + case 34: /* switch0.c */ + case 86: /* eareq.c */ + case 87: /* switch2.c */ + case 104: /* NDS NCPS */ + case 111: /* switch1.c */ + subCode = requestPacket->RData[0]; + wPrintf(DBG_NCPTraceScreen,formatStr,requestCode,subCode); + break; + /*===========================================================================*/ + default: + wPrintf(DBG_NCPTraceScreen,formatStrS,requestCode); + break; + } + } + + /* Enter the NCP in the NCP log */ + if (DBG_NCPLogFlag) + { + if (++DBG_NCPLogIndex >= MAX_NCP_LOG_ENTRIES) + { + DBG_NCPLogIndex = 0; + } + switch (requestCode) + { + case 21: + case 22: + case 23: + case 35: + case 90: + case 123: + case 131: + DBG_NCPLog[DBG_NCPLogIndex].len = + GET_HILO_WORD(&requestPacket->RData[0]) + 3; + break; + default: + DBG_NCPLog[DBG_NCPLogIndex].len = NCP_LOG_ENTRY_LENGTH; + } + memcpy(&DBG_NCPLog[DBG_NCPLogIndex].info[0], &requestPacket->RRequestCode, + NCP_LOG_ENTRY_LENGTH); + } + MPKNSS_UNLOCK(); + + return DBG_NCPFunctions[requestCode]; +} + + +/************************************************************************** + * This routine will hook all of the desired NCP routines. + ***************************************************************************/ +void DBG_DebugHookNCPs() +{ + NINT i; + + if (!DBG_NCPsHooked) + { /* if not already hooked then hook the NCPs*/ + for (i=0; i < 256; i++) + { + DBG_NCPFunctions[i] = (voidfunc_t)(*NW_SwitchVector)[i]; + (*NW_SwitchVector)[i] = DBG_NCPTrace; + } + DBG_NCPsHooked = TRUE; + } +} + +/************************************************************************** + * This routine will hook all of the desired NCP routines. + ***************************************************************************/ +void DBG_DebugUnHookNCPs() +{ + NINT i; + + if (DBG_NCPTraceScreen == NULL && DBG_NCPLogFlag == FALSE && DBG_NCPsHooked) + { /* if not tracing and not logging then unhook the NCPs*/ + for (i=0; i < 256; i++) + { + (*NW_SwitchVector)[i] = DBG_NCPFunctions[i]; + } + DBG_NCPsHooked = FALSE; + } +} + +/************************************************************************** + * This routine will hook all of the desired NCP routines. + ***************************************************************************/ +void DBG_HookNCPTrace() +{ + DBG_DebugHookNCPs(); + if (DBG_NCPTraceScreen == NULL) + { + DBG_NCPTraceScreen = wOpen(MSGNot("NCP Trace Screen"),0); + if (DBG_NCPTraceScreen == NULL) + { + errPrintf(WHERE, LibModule, 203, + MSGNot("Error creating NCP Trace screen")); /* DEBUG CODE */ + return; + } + wCenter(DBG_NCPTraceScreen,MSGNot("NCP Trace Screen")); + wPrintf(DBG_NCPTraceScreen,MSGNot("\n")); + } +} + +/************************************************************************** + * This routine will UNhook all of the desired NCP routines we hooked at + * load time. + ***************************************************************************/ +void DBG_UnHookNCPTrace() +{ + if (DBG_NCPTraceScreen != NULL) + { + wClose(DBG_NCPTraceScreen); + DBG_NCPTraceScreen = NULL; + } + DBG_DebugUnHookNCPs(); +} + +/************************************************************************** + * This routine will hook all of the desired NCP routines. + ***************************************************************************/ +void DBG_HookNCPLog() +{ + DBG_DebugHookNCPs(); + DBG_NCPLogFlag = TRUE; +} + + +/************************************************************************** + * This routine will UNhook all of the desired NCP routines we hooked at + * load time. + ***************************************************************************/ +void DBG_UnHookNCPLog() +{ + DBG_NCPLogFlag = FALSE; + DBG_DebugUnHookNCPs(); +} + +#endif + +#endif // #ifndef __linux__ // LINUX_NCP + diff --git a/src/nwnss/library/debug/pssDebug.c b/src/nwnss/library/debug/pssDebug.c index ad114a0..cd070d0 100644 --- a/src/nwnss/library/debug/pssDebug.c +++ b/src/nwnss/library/debug/pssDebug.c @@ -35,13 +35,10 @@ | NSS Library source +-------------------------------------------------------------------------*/ #ifndef UNIX -#define UNIX 1 +#include #endif -#ifndef UNIX -#include -#endif -#include -#include +#include +#include #if NSS_DEBUG IS_ENABLED @@ -81,7 +78,7 @@ NINT DBG_PageSize = 20; /*------------------------------------------------------------------------- - * + * *-------------------------------------------------------------------------*/ void DBG_prseq (void) { @@ -89,7 +86,7 @@ void DBG_prseq (void) } ///*------------------------------------------------------------------------- -// * +// * // *-------------------------------------------------------------------------*/ //grabdebug (void) //{ @@ -98,7 +95,7 @@ void DBG_prseq (void) //} ///*------------------------------------------------------------------------- -// * +// * // *-------------------------------------------------------------------------*/ //void DBG_bugWait (void) //{ @@ -263,7 +260,7 @@ void DBG_prseq (void) /* * Routines for entering and exiting functions */ -//#include "include/schedule.h" +//#include "schedule.h" //#define MAX_HERE 200 @@ -304,7 +301,7 @@ void DBG_prseq (void) // } // FATAL(MSGNot("Haven't been here!"), myThread); //} - + /************************************************************************** * Returns a static buffer with the data ***************************************************************************/ @@ -322,12 +319,12 @@ char *DBG_DebugFormatBinary( retBuf[i] = (((buf[i] >= ' ') && (buf[i] <= '~')) ? buf[i] : '.'); } return retBuf; -} +} /************************************************************************** - * + * ***************************************************************************/ //typedef struct COUNTER { // char *what; @@ -535,10 +532,3 @@ char *DBG_DebugFormatBinary( #endif /* NSS_DEBUG */ -#ifdef NSS_USERSPACE -int pr(const char *what) -{ - (void)what; - return TRUE; -} -#endif diff --git a/src/nwnss/library/debug/sdBasic.c b/src/nwnss/library/debug/sdBasic.c new file mode 100644 index 0000000..607cd1c --- /dev/null +++ b/src/nwnss/library/debug/sdBasic.c @@ -0,0 +1,370 @@ +/**************************************************************************** + | + | (C) Copyright 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | sdBasic - Structure Display Basic. + / Displays Basic data types. + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Display NSS 3.00 memory structures. + / + / Warning - This file is used by NT Utilities like zedRemote, ZlogGet and + / etc. DO NOT ADD NSS specific code. The define NTLIB is only defined + / when source file is compiled with NT Utilities. + +-------------------------------------------------------------------------*/ + +#ifndef NTLIB +#include /* NetWare includes */ +#endif + +#include +#include + +#include "dfi.h" +#include "sbi.h" +#include "sdBasic.h" +#include "sdNSS.h" +#include "snp.h" + + +/* + * Returns the amount of data actaully displayed. We return + * this verses using dfi->DFI_SizeOf because some structures + * are variable size. The routines that display variable size + * items can then return the proper amount. + */ +SIZEOF SDM_NotUsed_s( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ) +{ + + printf("SDM_NotUsed_s is being called this is a bug\n\n"); + return( dfi->DFI_SizeOf ); + +} + + +SDM_Table_s *SDM_TableLookup( + char *objectName, + SDM_Table_s *table ) +{ + unsigned int i; + + for ( i = 0; table[i].ST_Name != NULL; ++i ) + { + if ( stricmp( table[i].ST_Name, objectName ) == 0 ) + { + return( &table[i] ); + } + } + return( NULL ); +} + + + + +#ifndef NTLIB +#define MMU_SUPERVISOR_READ 5 +#undef MMU_ERROR +#define MMU_ERROR -1 +extern LONG ValidateAddressRangePresent(void *address, LONG range, LONG flag); +#endif + +/* + * SDM_Structure() - + * Default routine to display structures. Used for structures + * that are not variable size. The structure must be able to be + * completely described by a DFI List. + * + * + * Returns - + * The amount of data actually displayed. We return + * this verses using dfi->DFI_SizeOf because some structures + * are variable size. The routines that display variable size + * items can then return the proper amount. + */ +SIZEOF SDM_Structure( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ) +{ + void *data = (void *)(buffer + offset); + NINT i; + DFI_DataFormatInformation_s *dfsList = dfi->DFI_List; + + DFI_Display_Header_Structure( co, dfi->DFI_Name, dfi->DFI_Name2, index, dfi->DFI_ArrayElements, dfi->DFI_SizeOf, buffer+offset ); + for ( i = 0; dfsList[i].DFI_Type != DFI_TYPE_END; i++ ) + { + DFI_Display( co, &dfsList[i], buffer, dfsList[i].DFI_Offset ); + } + DFI_Display_Tail_Structure( co, dfi->DFI_Name2, 0 /* Not known in this generic routine(plus not used by caller) */, data ); + return( dfi->DFI_SizeOf ); + +} + + +/* + * Display object(specified by SDM_Table_s) into memory buffer (specified + * by DFI_CallerOptions_s) + * + */ +STATUS SDM_Display( +#ifndef NTLIB + struct ScreenStruct *screen, +#endif + SDM_Table_s *table, + DFI_CallerOptions_s *co, + char *objectName, + NINT arrayElements, + BYTE *buffer, + unsigned int bufferSize ) + +{ + SDM_Table_s *st; + SIZEOF sizeOf; + DFI_DataFormatInformation_s dfi; + + bzero( &dfi, sizeof( dfi ) ); + if ( *objectName == '*' ) + { + ++objectName; + dfi.DFI_Type = DFI_TYPE_STRUCT_PTR; + } + else + { + dfi.DFI_Type = DFI_TYPE_STRUCT; + } +#ifndef NTLIB +//OutputToScreenWithAttribute( screen, LRED, "%s\n", WHERE ); +#endif + st = SDM_TableLookup( objectName, table ); + if ( st == NULL ) + { +#ifndef NTLIB +//OutputToScreenWithAttribute( screen, LRED, "%s\n", WHERE ); +#endif + return( zERR_OBJECT_NOT_FOUND ); + } +#ifndef NTLIB + /* FixFixFix - this check may not be valid all of the time. I.E. for variable sized items. */ + if ( ValidateAddressRangePresent(buffer, st->ST_SizeOf, + MMU_SUPERVISOR_READ) == MMU_ERROR) + { + OutputToScreenWithAttribute( screen, LRED, "%s Address is not valid 0x%lx\n", WHERE, buffer ); + return( zERR_BAD_ADDRESS ); + } +#endif + /* FixFixFix - this check may not be valid all of the time. I.E. for variable sized items. */ +#ifndef NTLIB +//OutputToScreenWithAttribute( screen, LRED, "%s\n", WHERE ); +#endif + if ( bufferSize < st->ST_SizeOf ) + { +#ifndef NTLIB +//OutputToScreenWithAttribute( screen, LRED, "%s\n", WHERE ); +#endif + return( zERR_BUFFER_TOO_SMALL ); + } +#ifndef NTLIB +//OutputToScreenWithAttribute( screen, LRED, "%s\n", WHERE ); +#endif + dfi.DFI_Routine = st->ST_Routine; + dfi.DFI_Offset = 0; + dfi.DFI_Name = st->ST_Name; + dfi.DFI_ArrayElements = arrayElements; + dfi.DFI_Name2 = objectName; + dfi.DFI_SizeOf = st->ST_SizeOf; + dfi.DFI_List = st->ST_DFIList; /* SDM_Structure() requires this information */ + +#ifndef NTLIB +//OutputToScreenWithAttribute( screen, LRED, "%s\n", WHERE ); +#endif + sizeOf = DFI_Display( co, &dfi, buffer, dfi.DFI_Offset ); +#ifndef NTLIB +//OutputToScreenWithAttribute( screen, LRED, "%s\n", WHERE ); +#endif + return( zOK ); + +} /* End of SDM_Display() */ + + + +int ZSD_Display_Type_LONG( + DFI_CallerOptions_s *co, + char *tag, + LONG *aLong ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_LONG, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)aLong, 0 ); + return( rc ); +} /* End of ZSD_Display_Type_LONG() */ + + +int ZSD_Display_Type_SLONG( + DFI_CallerOptions_s *co, + char *tag, + SLONG *aLong ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_SLONG, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)aLong, 0 ); + return( rc ); +} /* End of ZSD_Display_Type_SLONG() */ + + +int ZSD_Display_Type_QUAD( + DFI_CallerOptions_s *co, + char *tag, + QUAD *aQuad ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_QUAD, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)aQuad, 0 ); + return( rc ); +} /* End of ZSD_Display_Type_LONG() */ + + +int ZSD_Display_Type_QUAD_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, /* Number of array elements */ + QUAD *aQuad ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_QUAD, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + dfi.DFI_ArrayElements = arrayElements; + rc = DFI_Display( co, &dfi, (BYTE *)aQuad, 0 ); + return( rc ); +} /* End of ZSD_Display_Type_QUAD_ARRAY() */ + + +int ZSD_Display_Type_WORD( + DFI_CallerOptions_s *co, + char *tag, + WORD *aWord ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_WORD, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)aWord, 0 ); + return( rc ); + +} /* End of ZSD_Display_Type_WORD() */ + + +int ZSD_Display_Type_SWORD( + DFI_CallerOptions_s *co, + char *tag, + SWORD *aWord ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_SWORD, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)aWord, 0 ); + return( rc ); +} /* End of ZSD_Display_Type_SWORD() */ + + +int ZSD_Display_Type_BYTE( + DFI_CallerOptions_s *co, + char *tag, + BYTE *aByte ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_BYTE, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)aByte, 0 ); + return( rc ); +} /* End of ZSD_Display_Type_BYTE() */ + + +int ZSD_Display_Type_Zid_t( + DFI_CallerOptions_s *co, + char *tag, + Zid_t *zid ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_Zid_t, NULL, 0, "", 0, "" }; + int rc; + +// rc = SNP_snprintf( WHERE, pb, "<%s type=\"Zid_t\" value=\"0x%LX\"/>\n", tag, zid ); + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)zid, 0 ); + return( rc ); + +} /* End of ZSD_Display_Type_Zid_t() */ + + +int ZSD_Display_Type_Time_t( + DFI_CallerOptions_s *co, + char *tag, + Time_t *time ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_Time_t, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)time, 0 ); + return( rc ); + +} /* End of ZSD_Display_Type_Time_t() */ + + +int ZSD_Display_Type_Time_t_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, /* Number of array elements */ + Time_t *time ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_Time_t, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + dfi.DFI_ArrayElements = arrayElements; + rc = DFI_Display( co, &dfi, (BYTE *)time, 0 ); + return( rc ); + +} /* End of ZSD_Display_Type_Time_t_ARRAY() */ diff --git a/src/nwnss/library/debug/sdNSS.c b/src/nwnss/library/debug/sdNSS.c new file mode 100644 index 0000000..02e0637 --- /dev/null +++ b/src/nwnss/library/debug/sdNSS.c @@ -0,0 +1,1668 @@ +/**************************************************************************** + | + | (C) Copyright 2002, 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | sdNSS - Structure Display NSS items. + | + |--------------------------------------------------------------------------- + | + | $Author: gpachner $ + | $Date: 2007-07-12 01:41:12 +0530 (Thu, 12 Jul 2007) $ + | + | $RCSfile$ + | $Revision: 2087 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Display NSS 3.00 structures. + / + / Warning - This file is used by NT Utilities like zedRemote, ZlogGet and + / etc. DO NOT ADD NSS specific code. The define NTLIB is only defined + / when source file is compiled with NT Utilities. + +-------------------------------------------------------------------------*/ +#include +#include + + +#include "dfi.h" +#include "sbi.h" +#include "sdNSS.h" +#include "snp.h" +#include "pssConfig.h" +#include "cacheControl.h" +#include "msgGen.h" +#include "msgName.h" +#include "fileHandle.h" +#include "opLock.h" +#include "pssConnection.h" +#include "comnAuthorize.h" +#include "rbpTree.h" +#include "adminVolume.h" +#include "hmc.h" + + + +/* + * Only structures in these table can be viewed via the offical API. + * + * THIS TABLE MUST BE KEPT IN ALPHANUMERIC order for '=vs' and '=va' + * to work. Note that a ASSCII '_' is between the Uppercase Letters and + * the lowercase letters. + * + */ +SDM_Table_s SDM_TableNSS[] = { + /****************************************************************/ + /*** Entries MUST be in alpha order or '=va' does not work!!! ***/ + /****************************************************************/ + { "ACLEntry_s", sizeof( ACLEntry_s ), SDM_Structure, DFI_ACLEntry_s }, + { "AdminVolFile_s", sizeof( AdminVolFile_s ), SDM_Structure, DFI_AdminVolFile_s }, + { "Agent_s", sizeof( Agent_s ), SDM_Structure, DFI_Agent_s }, + { "Asyncio_s", sizeof( Asyncio_s ), SDM_Structure, DFI_Asyncio_s }, + { "AuthBeast_s", sizeof( AuthBeast_s ), SDM_Structure, DFI_AuthBeast_s }, + { "AuthCtrl_s", sizeof( AuthCtrl_s ), SDM_Structure, DFI_AuthCtrl_s }, + { "BioReq_s", sizeof( BioReq_s ), SDM_Structure, DFI_BioReq_s }, + { "Buffer_s", sizeof( Buffer_s ), SDM_Structure, DFI_Buffer_s }, + { "CacheControl_s", sizeof( CacheControl_s ), SDM_Structure, DFI_CacheControl_s }, + { "Config_s", sizeof( Config_s ), SDM_Structure, DFI_Config_s }, + { "ConnectionIDP_s", sizeof( ConnectionIDP_s ), SDM_Structure, DFI_ConnectionIDP_s }, + { "ContextHandleCtrl_s", sizeof( ContextHandleCtrl_s ), SDM_Structure, DFI_ContextHandleCtrl_s }, + { "ContextHandleIDP_s", sizeof( ContextHandleIDP_s ), SDM_Structure, DFI_ContextHandleIDP_s }, + { "ContextHandleInfo_s", sizeof( ContextHandleInfo_s ), SDM_Structure, DFI_ContextHandleInfo_s }, + { "FileHandleIDP_s", sizeof( FileHandleIDP_s ), SDM_Structure, DFI_FileHandleIDP_s }, + { "FileHandle_s", sizeof( FileHandle_s ), SDM_Structure, DFI_FileHandle_s }, + { "File_s", sizeof( File_s ), SDM_Structure, DFI_File_s }, + { "FsmLite_s", sizeof( FsmLite_s ), SDM_Structure, DFI_FsmLite_s }, + { "Fsm_s", sizeof( Fsm_s ), SDM_Structure, DFI_Fsm_s }, + { "GeneralMsg_s", sizeof( GeneralMsg_s ), SDM_Structure, DFI_GeneralMsg_s }, + { "Histogram_s", sizeof( Histogram_s ), SDM_Structure, DFI_Histogram_s }, + { "Latch_s", sizeof( Latch_s ), SDM_Structure, DFI_Latch_s }, + { "Logged PersistentPool_s", sizeof( LoggedPersistentPool_s ), SDM_Structure, DFI_LoggedPersistentPool_s }, + { "LoggedPersistentVolume_s", sizeof( LoggedPersistentVolume_s ), SDM_Structure, DFI_LoggedPersistentVolume_s }, + { "MyCache_s", sizeof( MyCache_s ), SDM_Structure, DFI_MyCache_s }, + { "NSSConnection_s", sizeof( NSSConnection_s ), SDM_Structure, DFI_NSSConnection_s }, + { "NamedBeast_s", sizeof( struct NamedBeast_s ), SDM_Structure, DFI_NamedBeast_s }, + { "NamingMsg_s", sizeof( NamingMsg_s ), SDM_Structure, DFI_NamingMsg_s }, + { "OneShot_s", sizeof( OneShot_s ), SDM_Structure, DFI_OneShot_s }, + { "OpLockControl_s", sizeof( OpLockControl_s ), SDM_Structure, DFI_OpLockControl_s }, + { "OpLock_s", sizeof( OpLock_s ), SDM_Structure, DFI_OpLock_s }, + { "PageBuffer_s", sizeof( PageBuffer_s ), SDM_Structure, DFI_PageBuffer_s }, + { "PersistentNamed_s", sizeof( PersistentNamed3_s ), SDM_Structure, DFI_PersistentNamed_s }, + { "PersistentPool_s", sizeof( PersistentPool_s ), SDM_Structure, DFI_PersistentPool_s }, + { "PersistentVolume_s", sizeof( PersistentVolume_s ), SDM_Structure, DFI_PersistentVolume_s }, + { "PoolOwnership_s", sizeof( PoolOwnership_s ), SDM_Structure, DFI_PoolOwnership_s }, + { "Pool_s", sizeof( Pool_s ), SDM_Structure, DFI_Pool_s }, + { "PubBuffer_s", sizeof( PubBuffer_s ), SDM_Structure, DFI_PubBuffer_s }, + { "RBP_Node_s", sizeof( RBP_Node_s ), SDM_Structure, DFI_RBP_Node_s }, + { "RootBeast_s", sizeof( RootBeast_s ), SDM_Structure, DFI_RootBeast_s }, + { "SAgentHandleCtrl_s", sizeof( SAgentHandleCtrl_s ), SDM_Structure, DFI_SAgentHandleCtrl_s }, + { "ScanComponentMsg_s", sizeof( ScanComponentMsg_s ), SDM_Structure, DFI_ScanComponentMsg_s }, + { "SearchMapCtrl_s", sizeof( SearchMapCtrl_s ), SDM_Structure, DFI_SearchMapCtrl_s }, + { "UXASAuthorizeInfo_s", sizeof(UXASAuthorizeInfo_s), SDM_Structure, DFI_UXASAuthorizeInfo_s }, + { "UXASPersistentAuthInfo_s", sizeof(UXASPersistentAuthInfo_s), SDM_Structure, DFI_UXASPersistentAuthInfo_s }, + { "VisEntry_s", sizeof( VisEntry_s ), SDM_Structure, DFI_VisEntry_s }, + { "Volume_s", sizeof( Volume_s ), SDM_Structure, DFI_Volume_s }, + { "Xaction_s", sizeof( Xaction_s ), SDM_Structure, DFI_Xaction_s }, + { "ZASAuthorizeInfo_s", sizeof(ZASAuthorizeInfo_s), SDM_Structure, DFI_ZASAuthorizeInfo_s }, + { "ZASPersistentAuthInfo_s", sizeof(ZASPersistentAuthInfo_s), SDM_Structure, DFI_ZASPersistentAuthInfo_s }, + { "mDataArea_s", sizeof( mDataArea_s ), SDM_Structure, DFI_mDataArea_s }, + { "mDoor_s", sizeof( mDoor_s ), SDM_Structure, DFI_mDoor_s }, + { "mManager_s", sizeof( mManager_s ), SDM_Structure, DFI_mManager_s }, + { "mObject_s", sizeof( mObject_s ), SDM_Structure, DFI_mObject_s }, + { "mSystemMsg_s", sizeof( mSystemMsg_s ), SDM_Structure, DFI_mSystemMsg_s }, + { "mTypeHeader_s", sizeof( mTypeHeader_s ), SDM_Structure, DFI_mTypeHeader_s }, + { "mType_s", sizeof( mType_s ), SDM_Structure, DFI_mType_s }, + { "zInfo_s", sizeof( zInfo_s ), SDM_Structure, DFI_zInfo_s }, + { "zMacInfo_s", sizeof( zMacInfo_s ), SDM_Structure, DFI_zMacInfo_s }, + { "zNSSMsg_s", sizeof( zNSSMsg_s ), SDM_Structure, DFI_zNSSMsg_s }, + { "zPoolInfo_s", sizeof( zPoolInfo_s ), SDM_Structure, DFI_zPoolInfo_s }, + { "zUnixInfo_s", sizeof( zUnixInfo_s ), SDM_Structure, DFI_zUnixInfo_s }, + { "zVolumeInfo_s", sizeof( zVolumeInfo_s ), SDM_Structure, DFI_zVolumeInfo_s }, + { "zWorkProc_s", sizeof( zWorkProc_s ), SDM_Structure, DFI_zWorkProc_s }, + /****************************************************************/ + /*** Entries MUST be in alpha order or '=va' does not work!!! ***/ + /****************************************************************/ + + { NULL, 0, NULL } /* End of table entry */ +}; + + + + +#define DFI_Master_s DFI_NotUsed_s +#define DFI_NameSpace_s DFI_NotUsed_s +#define DFI_SAHandleCtrl_s DFI_NotUsed_s +#define DFI_SearchMap_s DFI_NotUsed_s +#define DFI_SlabHdr_s DFI_NotUsed_s +#define DFI_VirtInfo_s DFI_NotUsed_s +#define DFI_zMatchAttr_s DFI_NotUsed_s + + +#define DFI_AdminVolume_s DFI_NotUsed_s +#define DFI_AdminVolStorageInfo_s DFI_NotUsed_s +#define DFI_AuthModelOps_s DFI_NotUsed_s +#define DFI_BeastClass_s DFI_NotUsed_s +#define DFI_StorageInfo_s DFI_NotUsed_s + +#define DFI_AuthModelBeast_s DFI_NotUsed_s + +#define DFI_ZFSStorageInfo_s DFI_NotUsed_s +#define DFI_ResourceTagStructure DFI_NotUsed_s +#define DFI_ZfsBeastTreeBeast_s DFI_NotUsed_s +#define DFI_ZfsNameTree_s DFI_NotUsed_s +#define DFI_ZfsMFLBeast_s DFI_NotUsed_s +#define DFI_ZfsUserTreeBeast_s DFI_NotUsed_s +#define DFI_ZfsDirTreeBeast_s DFI_NotUsed_s +#define DFI_ZfsPurgeLogBeast_s DFI_NotUsed_s +#define DFI_ZlogBeast_s DFI_NotUsed_s +#define DFI_ZLSSVOL_LVD_DeleteQueueInfo_t DFI_NotUsed_s +#define DFI_StorPool_s DFI_NotUsed_s +#define DFI_ZFSMemorySuperBlk_s DFI_NotUsed_s +#define DFI_ZfsMYBTreeBeast_s DFI_NotUsed_s +#define DFI_ZfsFreeExtent_s DFI_NotUsed_s +#define DFI_LoadDefinitionStructure DFI_NotUsed_s +#define DFI_CROAccessLease_s DFI_NotUsed_s +#define DFI_CsaVolumeDoor_s DFI_NotUsed_s +#define DFI_inode_s DFI_NotUsed_s +#define DFI_EncryptedBufPage_s DFI_NotUsed_s +#define DFI_page_s DFI_NotUsed_s + + /* Dummy entry to pass to SDM_Structure */ +DFI_DataFormatInformation_s DFI_NotUsed_s[] = { + + { DFI_TYPE_END , NULL, 0, "", 0, "" } +}; + +DFI_DataFormatInformation_s DFI_AuthCtrl_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(AuthCtrl_s, authListLatch), "authListLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s}, + { DFI_TYPE_NINT , NULL , offsetof(AuthCtrl_s, numAuthenticatedIDs), "numAuthenticatedIDs", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(AuthCtrl_s, numOriginalIDs), "numOriginalIDs", 0, ""}, + { DFI_TYPE_UserID_t_PTR , NULL , offsetof(AuthCtrl_s, authenticatedIDs), "authenticatedIDs", 0, "UserID_t", sizeof(UserID_t)}, + { DFI_TYPE_LONG , NULL , offsetof(AuthCtrl_s, originalIDs), "originalIDs", 0, "LONG", sizeof(LONG)}, + { DFI_TYPE_END , NULL , 0, "", 0, "" } +}; + +DFI_DataFormatInformation_s DFI_SAgentHandleCtrl_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(SAgentHandleCtrl_s, saLatch), "saLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s}, + { DFI_TYPE_NINT , NULL , offsetof(SAgentHandleCtrl_s, nextFree), "nextFree", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(SAgentHandleCtrl_s, arraySize), "arraySize", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(SAgentHandleCtrl_s, list), "list", 0, "SAHandleCtrl_s", 0/*sizeof(SAHandleCtrl_s)*/, DFI_SAHandleCtrl_s}, + { DFI_TYPE_END , NULL , 0, "", 0, "" } +}; + +DFI_DataFormatInformation_s DFI_SearchMapCtrl_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(SearchMapCtrl_s, smLatch), "smLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(SearchMapCtrl_s, inuseList), "inuseList", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(SearchMapCtrl_s, reuseActiveList), "reuseActiveList", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(SearchMapCtrl_s, reuseInactiveList), "reuseInactiveList", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_NINT , NULL , offsetof(SearchMapCtrl_s, numMaps), "numMaps", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(SearchMapCtrl_s, nextMapID), "nextMapID", 0, ""}, + { DFI_TYPE_WORD , NULL , offsetof(SearchMapCtrl_s, nextMapID16), "nextMapID16", 0, ""}, + { DFI_TYPE_WORD , NULL , offsetof(SearchMapCtrl_s, padding), "padding", 0, ""}, + { DFI_TYPE_END , NULL , 0, "", 0, "" } +}; + + +DFI_DataFormatInformation_s DFI_ContextHandleInfo_s[] = { + { DFI_TYPE_BYTE , NULL , offsetof(ContextHandleInfo_s, handleID), "handleID", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(ContextHandleInfo_s, handleType), "handleType", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(ContextHandleInfo_s, reserved1), "reserved1", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(ContextHandleInfo_s, reserved2), "reserved2", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(ContextHandleInfo_s, useCount), "useCount", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(ContextHandleInfo_s, taskID), "taskID", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(ContextHandleInfo_s, semanticAgentID), "semanticAgentID", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(ContextHandleInfo_s, nameSpace), "nameSpace", 0, "NameSpace_s", sizeof(NameSpace_s), DFI_NameSpace_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(ContextHandleInfo_s, dirFile), "dirFile", 0, "File_s", sizeof(File_s), DFI_File_s}, + { DFI_TYPE_Zid_t , NULL , offsetof(ContextHandleInfo_s, fileParentZid), "fileParentZid", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(ContextHandleInfo_s, fileNameType), "fileNameType", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(ContextHandleInfo_s, reserved3), "reserved3", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(ContextHandleInfo_s, pssConn), "pssConn", 0, "NSSConnection_s", sizeof(NSSConnection_s), DFI_NSSConnection_s}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_ContextHandleCtrl_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(ContextHandleCtrl_s, cxhLatch), "cxhLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s}, + { DFI_TYPE_NINT , NULL , offsetof(ContextHandleCtrl_s, nextFree), "nextFree", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(ContextHandleCtrl_s, arraySize), "arraySize", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(ContextHandleCtrl_s, list), "list", 0, "ContextHandleInfo_s", sizeof(ContextHandleInfo_s), DFI_ContextHandleInfo_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(ContextHandleCtrl_s, sysLoginCxh), "sysLoginCxh", 0, "ContextHandleInfo_s", sizeof(ContextHandleInfo_s), DFI_ContextHandleInfo_s}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_NSSConnection_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(NSSConnection_s, link), "link", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(NSSConnection_s, contextHandles), "contextHandles", 0, "ContextHandleCtrl_s", sizeof(ContextHandleCtrl_s), DFI_ContextHandleCtrl_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(NSSConnection_s, searchMaps), "searchMaps", 0, "SearchMapCtrl_s", sizeof(SearchMapCtrl_s), DFI_SearchMapCtrl_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(NSSConnection_s, sAgentHandles), "sAgentHandles", 0, "SAgentHandleCtrl_s", sizeof(SAgentHandleCtrl_s), DFI_SAgentHandleCtrl_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(NSSConnection_s, authInfo), "authInfo", 0, "AuthCtrl_s", sizeof(AuthCtrl_s), DFI_AuthCtrl_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(NSSConnection_s, masters), "masters", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(NSSConnection_s, defaultMaster), "defaultMaster", 0, "Master_s", 0/*sizeof(Master_s)*/, DFI_Master_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(NSSConnection_s, shutDownLatch), "shutDownLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s}, + { DFI_TYPE_WORD , NULL , offsetof(NSSConnection_s, flags), "flags", 0, ""}, + { DFI_TYPE_WORD , NULL , offsetof(NSSConnection_s, connUseCount), "connUseCount", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(NSSConnection_s, connectionNumber), "connectionNumber", 0, ""}, + { DFI_TYPE_VolumeID_t , NULL , offsetof(NSSConnection_s, macVol), "macVol", 0, ""}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(NSSConnection_s, macAlarm), "macAlarm", 0, "OneShot_s", sizeof(OneShot_s), DFI_OneShot_s}, + { DFI_TYPE_NINT , NULL , offsetof(NSSConnection_s, tempMACAccess), "tempMACAccess", 0, ""}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_OpLockControl_s[] = { + { DFI_TYPE_BYTE , NULL , offsetof(OpLockControl_s, opState), "opState", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(OpLockControl_s, opHasPSA), "opHasPSA", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(OpLockControl_s, opFile), "opFile", 0, "File_s", sizeof(File_s), DFI_File_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(OpLockControl_s, opLockWaiters), "opLockWaiters", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(OpLockControl_s, opLocks), "opLocks", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_OpLock_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(OpLock_s, opLink), "opLink", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_FUNC_PTR , NULL , offsetof(OpLock_s, opCallback), "opCallback", 0, "statusfunc_t", sizeof(statusfunc_t)}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(OpLock_s, fileHandle), "fileHandle", 0, "FileHandle_s", sizeof(FileHandle_s), DFI_FileHandle_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(OpLock_s, control), "control", 0, "OpLockControl_s", sizeof(OpLockControl_s), DFI_OpLockControl_s}, + { DFI_TYPE_ADDR , NULL , offsetof(OpLock_s, opSaData), "opSaData", 0, ""}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(OpLock_s, tickle), "tickle", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_Histogram_s[] = { + { DFI_TYPE_NINT , NULL , offsetof(Histogram_s, currentCount), "currentCount", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Histogram_s, highWaterMark), "highWaterMark", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(Histogram_s, eventSum), "eventSum", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Histogram_s, totalCount), "totalCount", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Histogram_s, bucket), "bucket", BITS_PER_NINT, ""}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_ObjCache_s[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(ObjCache_s, OC_current), "OC_current", 0, "SlabHdr_s", 0/*sizeof(SlabHdr_s)*/, DFI_SlabHdr_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(ObjCache_s, others), "others", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t}, + { DFI_TYPE_char_STR , NULL , offsetof(ObjCache_s, name), "name", MAX_NAME, "char", sizeof(Name_t), NULL/*DFI_Name_t*/}, + { DFI_TYPE_NINT , NULL , offsetof(ObjCache_s, size), "size", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(ObjCache_s, objsPerSlab), "objsPerSlab", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(ObjCache_s, color), "color", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(ObjCache_s, nextColor), "nextColor", 0, ""}, + { DFI_TYPE_FUNC_PTR , NULL , offsetof(ObjCache_s, prefab), "prefab", 0, "voidfunc_t", sizeof(voidfunc_t)}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(ObjCache_s, full), "full", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(ObjCache_s, notFull), "notFull", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(ObjCache_s, myCache), "myCache", 0, "MyCache_s", sizeof(MyCache_s), DFI_MyCache_s}, +#if HISTOGRAM IS_ENABLED + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(ObjCache_s, histogram), "histogram", 0, "Histogram_s", sizeof(Histogram_s), DFI_Histogram_s}, +#endif + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_mObject_s[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(mObject_s, o_type), "o_type", 0, "mType_s", sizeof(mType_s), DFI_mType_s}, + { DFI_TYPE_NINT , NULL , offsetof(mObject_s, o_count), "o_count", 0, ""}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(mObject_s, o_instance), "o_instance", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t}, + { DFI_TYPE_NINT , NULL , offsetof(mObject_s, o_properties), "o_properties", 0, ""}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_mManager_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(mManager_s, obj), "obj", 0, "mObject_s", sizeof(mObject_s), DFI_mObject_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(mManager_s, doors), "doors", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(mManager_s, types), "types", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_mDoor_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(mDoor_s, dr_obj), "dr_obj", 0, "mObject_s", sizeof(mObject_s), DFI_mObject_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(mDoor_s, dr_next), "dr_next", 0, "mDoor_s", sizeof(mDoor_s), DFI_mDoor_s}, + { DFI_TYPE_Key_t , NULL , offsetof(mDoor_s, dr_key), "dr_key", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(mDoor_s, dr_owner), "dr_owner", 0, "mManager_s", sizeof(mManager_s), DFI_mManager_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(mDoor_s, dr_ownerList), "dr_ownerList", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_mTypeHeader_s[] = { + { DFI_TYPE_char_PTR , NULL , offsetof(mTypeHeader_s, name ), "name", 0, "" }, + { DFI_TYPE_NINT , NULL , offsetof(mTypeHeader_s, objSize), "objSize", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(mTypeHeader_s, numMethods), "numMethods", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(mTypeHeader_s, manager), "manager", 0, "mManager_s", sizeof(mManager_s), DFI_mManager_s}, + { DFI_TYPE_FUNC_PTR , NULL , offsetof(mTypeHeader_s, preconstructor), "preconstructor", 0, "voidfunc_t", sizeof(voidfunc_t)}, + { DFI_TYPE_FUNC_PTR , NULL , offsetof(mTypeHeader_s, constructor), "constructor", 0, "voidfunc_t", sizeof(voidfunc_t)}, + { DFI_TYPE_FUNC_PTR , NULL , offsetof(mTypeHeader_s, destructor), "destructor", 0, "voidfunc_t", sizeof(voidfunc_t)}, + { DFI_TYPE_FUNC_PTR , NULL , offsetof(mTypeHeader_s, notify), "notify", 0, "voidfunc_t", sizeof(voidfunc_t)}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(mTypeHeader_s, typeList), "typeList", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(mTypeHeader_s, instances), "instances", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(mTypeHeader_s, objCache), "objCache", 0, "ObjCache_s", sizeof(ObjCache_s), DFI_ObjCache_s}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_mType_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(mType_s, hdr), "hdr", 0, "mTypeHeader_s", sizeof(mTypeHeader_s), DFI_mTypeHeader_s}, + { DFI_TYPE_FUNC_PTR , NULL , offsetof(mType_s, method), "method", 1, "voidfunc_t", sizeof(voidfunc_t)}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_FileHandle_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(FileHandle_s, door), "door", 0, "mDoor_s", sizeof(mDoor_s), DFI_mDoor_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(FileHandle_s, bstLink), "bstLink", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(FileHandle_s, file), "file", 0, "File_s", sizeof(File_s), DFI_File_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(FileHandle_s, dataStream), "dataStream", 0, "NamedBeast_s", sizeof(NamedBeast_s), DFI_NamedBeast_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(FileHandle_s, compBeast), "compBeast", 0, "RootBeast_s", sizeof(RootBeast_s), DFI_RootBeast_s}, + { DFI_TYPE_Zid_t , NULL , offsetof(FileHandle_s, fileParentZid), "fileParentZid", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(FileHandle_s, fileNameUniquifier), "fileNameUniquifier", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(FileHandle_s, taskID), "taskID", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(FileHandle_s, grantedRights), "grantedRights", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(FileHandle_s, fileNameSpaceID), "fileNameSpaceID", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(FileHandle_s, fileNameType), "fileNameType", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(FileHandle_s, dataStreamNameSpaceID), "dataStreamNameSpaceID", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(FileHandle_s, dataStreamNameType), "dataStreamNameType", 0, ""}, + { DFI_TYPE_WORD , NULL , offsetof(FileHandle_s, fhState), "fhState", 0, ""}, +// { DFI_TYPE_BYTE , NULL , offsetof(FileHandle_s, pad), "pad", 1, ""}, + { DFI_TYPE_WORD , NULL , offsetof(FileHandle_s, parentIsImmCompress), "parentIsImmCompress", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(FileHandle_s, virtInfo), "virtInfo", 0, "VirtInfo_s", 0/*sizeof(VirtInfo_s)*/, DFI_VirtInfo_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(FileHandle_s, pssConn), "pssConn", 0, "NSSConnection_s", sizeof(NSSConnection_s), DFI_NSSConnection_s}, + { DFI_TYPE_LONG , NULL , offsetof(FileHandle_s, connID), "connID", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(FileHandle_s, semanticAgentID), "semanticAgentID", 0, ""}, + { DFI_TYPE_Blknum_t , NULL , offsetof(FileHandle_s, readAheadBlk), "readAheadBlk", 0, ""}, + { DFI_TYPE_Blknum_t , NULL , offsetof(FileHandle_s, lastBlkRead), "lastBlkRead", 0, ""}, + { DFI_TYPE_Time_t , NULL , offsetof(FileHandle_s, openedTime), "openedTime", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(FileHandle_s, smap), "smap", 0, "SearchMap_s", 0/*sizeof(SearchMap_s)*/, DFI_SearchMap_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(FileHandle_s, opLock), "opLock", 0, "OpLock_s", sizeof(OpLock_s), DFI_OpLock_s}, + { DFI_TYPE_NINT , NULL , offsetof(FileHandle_s, enterExitID), "enterExitID", 0, ""}, + { DFI_TYPE_STATUS , NULL , offsetof(FileHandle_s, enterRetStatus), "enterRetStatus", 0, ""}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(FileHandle_s, fhWaiters), "fhWaiters", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(FileHandle_s, FH_accessLease), "FH_accessLease", 0, "CROAccessLease_s", 0/*sizeof(CROAccessLease_s)*/, DFI_CROAccessLease_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(FileHandle_s, FH_csaVolObj), "FH_csaVolObj", 0, "CsaVolumeDoor_s", 0/*sizeof(CsaVolumeDoor_s)*/, DFI_CsaVolumeDoor_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(FileHandle_s, FH_asyncCloseFsm), "FH_asyncCloseFsm", 0, "FsmLite_s", sizeof(FsmLite_s), DFI_FsmLite_s}, + + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_ScanComponentMsg_s[] = { + { DFI_TYPE_NINT , NULL , offsetof(ScanComponentMsg_s, scanFlags), "scanFlags", 0, ""}, + { DFI_TYPE_BYTE_PTR , NULL , offsetof(ScanComponentMsg_s, asciiSrcPath), "asciiSrcPath", 0, "BYTE", sizeof(BYTE)}, + { DFI_TYPE_NINT , NULL , offsetof(ScanComponentMsg_s, asciiSrcLength), "asciiSrcLength", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(ScanComponentMsg_s, uniConversionType), "uniConversionType", 0, ""}, + { DFI_TYPE_BYTE_PTR , NULL , offsetof(ScanComponentMsg_s, asciiValidCharBitMap), "asciiValidCharBitMap", 0, "BYTE", sizeof(BYTE)}, + { DFI_TYPE_BYTE_PTR , NULL , offsetof(ScanComponentMsg_s, asciiWorkBuffer), "asciiWorkBuffer", 0, "BYTE", sizeof(BYTE)}, + { DFI_TYPE_unicode_t_PTR , NULL , offsetof(ScanComponentMsg_s, uniWorkBuffer1), "uniWorkBuffer1", 0, "unicode_t", sizeof(unicode_t)}, + { DFI_TYPE_unicode_t_PTR , NULL , offsetof(ScanComponentMsg_s, uniSrcPath), "uniSrcPath", 0, "unicode_t", sizeof(unicode_t)}, + { DFI_TYPE_unicode_t_PTR , NULL , offsetof(ScanComponentMsg_s, uniWorkBuffer2), "uniWorkBuffer2", 0, "unicode_t", sizeof(unicode_t)}, + { DFI_TYPE_BYTE_PTR , NULL , offsetof(ScanComponentMsg_s, retAsciiSrcPath), "retAsciiSrcPath", 0, "BYTE", sizeof(BYTE)}, + { DFI_TYPE_NINT , NULL , offsetof(ScanComponentMsg_s, retAsciiSrcLength), "retAsciiSrcLength", 0, ""}, + { DFI_TYPE_BYTE_PTR , NULL , offsetof(ScanComponentMsg_s, retAsciiComp), "retAsciiComp", 0, "BYTE", sizeof(BYTE)}, + { DFI_TYPE_NINT , NULL , offsetof(ScanComponentMsg_s, retAsciiCompLen), "retAsciiCompLen", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(ScanComponentMsg_s, retScanFlags), "retScanFlags", 0, ""}, + { DFI_TYPE_unicode_t_PTR , NULL , offsetof(ScanComponentMsg_s, retUniSrcPath), "retUniSrcPath", 0, "unicode_t", sizeof(unicode_t)}, + { DFI_TYPE_unicode_t_PTR , NULL , offsetof(ScanComponentMsg_s, retUnicodeComp), "retUnicodeComp", 0, "unicode_t", sizeof(unicode_t)}, + { DFI_TYPE_NINT , NULL , offsetof(ScanComponentMsg_s, retNextNameSpaceID), "retNextNameSpaceID", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(ScanComponentMsg_s, retNextNameType), "retNextNameType", 0, ""}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_ContextHandleIDP_s[] = { + { DFI_TYPE_NINT , NULL , offsetof(ContextHandleIDP_s, id), "id", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(ContextHandleIDP_s, ptr), "ptr", 0, "ContextHandleInfo_s", 0/*sizeof(ContextHandleInfo_s)*/, DFI_ContextHandleInfo_s}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_FileHandleIDP_s[] = { + { DFI_TYPE_Key_t , NULL , offsetof(FileHandleIDP_s, key), "key", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(FileHandleIDP_s, ptr), "ptr", 0, "FileHandle_s", 0/*sizeof(FileHandle_s)*/, DFI_FileHandle_s}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_NamingMsg_s[] = { + { DFI_TYPE_BYTE , NULL , offsetof(NamingMsg_s, handlePathType), "handlePathType", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(NamingMsg_s, pathFormat), "pathFormat", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(NamingMsg_s, parseMode), "parseMode", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(NamingMsg_s, pathCount), "pathCount", 0, ""}, + { DFI_TYPE_WORD , NULL , offsetof(NamingMsg_s, parseFlags), "parseFlags", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(NamingMsg_s, retParseFlags), "retParseFlags", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(NamingMsg_s, latchType), "latchType", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(NamingMsg_s, pathLength), "pathLength", 0, ""}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(NamingMsg_s, contextHandle), "contextHandle", 0, "ContextHandleIDP_s", sizeof(ContextHandleIDP_s), DFI_ContextHandleIDP_s}, + { DFI_TYPE_VolumeID_t , NULL , offsetof(NamingMsg_s, volumeID), "volumeID", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(NamingMsg_s, curvol), "curvol", 0, "Volume_s", sizeof(Volume_s), DFI_Volume_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(NamingMsg_s, fileHandle), "fileHandle", 0, "FileHandleIDP_s", sizeof(FileHandleIDP_s), DFI_FileHandleIDP_s}, + { DFI_TYPE_Zid_t , NULL , offsetof(NamingMsg_s, fileParentZid), "fileParentZid", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(NamingMsg_s, fileNameType), "fileNameType", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(NamingMsg_s, zidNameType), "zidNameType", 0, ""}, + { DFI_TYPE_Zid_t , NULL , offsetof(NamingMsg_s, fileZid), "fileZid", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(NamingMsg_s, curFile), "curFile", 0, "File_s", sizeof(File_s), DFI_File_s}, + { DFI_TYPE_Zid_t , NULL , offsetof(NamingMsg_s, dataStreamZid), "dataStreamZid", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(NamingMsg_s, curDataStream), "curDataStream", 0, "NamedBeast_s", sizeof(NamedBeast_s), DFI_NamedBeast_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(NamingMsg_s, hlFile), "hlFile", 0, "File_s", sizeof(File_s), DFI_File_s}, + { DFI_TYPE_Zid_t , NULL , offsetof(NamingMsg_s, hlParentZid), "hlParentZid", 0, ""}, + { DFI_TYPE_WORD , NULL , offsetof(NamingMsg_s, nameSpaceID), "nameSpaceID", 0, ""}, + { DFI_TYPE_WORD , NULL , offsetof(NamingMsg_s, nameType), "nameType", 0, ""}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(NamingMsg_s, path), "path", 0, "inline", 4}, + { DFI_TYPE_FUNC_PTR , NULL , offsetof(NamingMsg_s, path.voidPtr), "voidPtr", 0, "voidfunc_t", sizeof(voidfunc_t)}, + { DFI_TYPE_BYTE_PTR , NULL , offsetof(NamingMsg_s, path.ascii), "ascii", 0, "BYTE", sizeof(BYTE)}, + { DFI_TYPE_unicode_t_PTR , NULL , offsetof(NamingMsg_s, path.unicode), "unicode", 0, "unicode_t", sizeof(unicode_t)}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(NamingMsg_s, path), "path", 0, "inline", 4}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(NamingMsg_s, match), "match", 0, "zMatchAttr_s", sizeof(zMatchAttr_s), DFI_zMatchAttr_s}, + { DFI_TYPE_NINT , NULL , offsetof(NamingMsg_s, retPathLen), "retPathLen", 0, ""}, + { DFI_TYPE_VolumeID_t , NULL , offsetof(NamingMsg_s, retVolumeID), "retVolumeID", 0, "VolumeID_t", sizeof(VolumeID_t)}, + { DFI_TYPE_unicode_t_PTR , NULL , offsetof(NamingMsg_s, retPath), "retPath", 0, "unicode_t", sizeof(unicode_t)}, + { DFI_TYPE_unicode_t_PTR , NULL , offsetof(NamingMsg_s, workBuffer), "workBuffer", 0, "unicode_t", sizeof(unicode_t)}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(NamingMsg_s, workNameSpace), "workNameSpace", 0, "NameSpace_s", sizeof(NameSpace_s), DFI_NameSpace_s}, + { DFI_TYPE_BYTE , NULL , offsetof(NamingMsg_s, workNameSpaceID), "workNameSpaceID", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(NamingMsg_s, workNameType), "workNameType", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(NamingMsg_s, workPathCount), "workPathCount", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(NamingMsg_s, reserved), "reserved", 0, ""}, + { DFI_TYPE_BYTE_PTR , NULL , offsetof(NamingMsg_s, lastAsciiSrcPath), "lastAsciiSrcPath", 0, "BYTE", sizeof(BYTE)}, + { DFI_TYPE_NINT , NULL , offsetof(NamingMsg_s, lastAsciiSrcPathLen), "lastAsciiSrcPathLen", 0, ""}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(NamingMsg_s, scanMsg), "scanMsg", 0, "ScanComponentMsg_s", sizeof(ScanComponentMsg_s), DFI_ScanComponentMsg_s}, + { DFI_TYPE_FUNC_PTR , NULL, offsetof( NamingMsg_s, scanNextComponent ), "scanNextComponent", 0, "STATUS (*scanNextComponent)(GeneralMsg_s *, struct NamingMsg_s *)", 4 }, + + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_mDataArea_s[] = { + { DFI_TYPE_FUNC_PTR , NULL , offsetof(mDataArea_s, start), "start", 0, "voidfunc_t", sizeof(voidfunc_t)}, + { DFI_TYPE_NINT , NULL , offsetof(mDataArea_s, length), "length", 0, ""}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_mSystemMsg_s[] = { + { DFI_TYPE_STATUS , NULL , offsetof(mSystemMsg_s, status), "status", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(mSystemMsg_s, numDataAreas), "numDataAreas", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(mSystemMsg_s, readMask), "readMask", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(mSystemMsg_s, writeMask), "writeMask", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(mSystemMsg_s, padding), "padding", 0, ""}, + { DFI_TYPE_BYTE_PTR , NULL , offsetof(mSystemMsg_s, where), "where", 0, "BYTE", sizeof(BYTE)}, + { DFI_TYPE_Key_t , NULL , offsetof(mSystemMsg_s, passedKey), "passedKey", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(mSystemMsg_s, door), "door", 0, "mDoor_s", sizeof(mDoor_s), DFI_mDoor_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(mSystemMsg_s, owner), "owner", 0, "mManager_s", sizeof(mManager_s), DFI_mManager_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(mSystemMsg_s, data), "data", MAX_DATA_AREAS, "mDataArea_s", sizeof(mDataArea_s), DFI_mDataArea_s}, + { DFI_TYPE_FUNC_PTR , NULL , offsetof(mSystemMsg_s, callback), "callback", 0, "voidfunc_t", sizeof(voidfunc_t)}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +/* Have to do for an inline struct that is reused */ +typedef struct zNSSMsg_id_s +{ + Xid_t xid; /* Transaction ID */ + LONG taskID; /* Task ID (picked by user) */ + LONG internalFlags; /* Flags user does not see */ + QUAD externalFlags; /* Flags user sets in interface */ + LONG sa; /* Semantic agent ID */ +} zNSSMsg_id_s; + +DFI_DataFormatInformation_s DFI_zNSSMsg_id_s[] = { + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_id_s, xid), "xid", 0, "Xid_t", sizeof(Xid_t), 0}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_id_s, taskID), "taskID", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_id_s, internalFlags), "internalFlags", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_id_s, externalFlags), "externalFlags", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_id_s, sa), "sa", 0, ""}, + + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +/* Have to do for an inline struct that is reused */ +typedef struct zNSSMsg_name_s +{ + struct zNSSMsg_id_s id; /** we use zNSSMsg_id_s and not id_s as we are not in 'SCOPE' of id_s **/ + LONG nameSpace; + LONG padding; +} zNSSMsg_name_s; + +DFI_DataFormatInformation_s DFI_zNSSMsg_name_s[] = { +// { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, name), "name", 0, "inline", sizeof(name_s)}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_name_s, id), "id", 0, "id_s", sizeof(zNSSMsg_id_s), DFI_zNSSMsg_id_s}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_name_s, nameSpace), "nameSpace", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_name_s, padding), "padding", 0, ""}, +// { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, name), "name", 0, "inline", sizeof(name_s)}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_zNSSMsg_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, sys), "sys", 0, "mSystemMsg_s", sizeof(mSystemMsg_s), DFI_mSystemMsg_s}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body), "body", 0, "inline", 0}, +// { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.conn.std), "std", 0, "mBody_u", sizeof(mBody_u), DFI_mBody_u}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.conn), "conn", 0, "inline", 4}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.conn.connID), "connID", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.conn), "conn", 0, "inline", 4}, + + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.id), "id", 0, "id_s", sizeof(zNSSMsg_id_s), DFI_zNSSMsg_id_s}, +// { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, id), "id", 0, "inline", 4}, +// { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, id.xid), "xid", 0, "Xid_t", sizeof(Xid_t), DFI_Xid_t}, +// { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, id.taskID), "taskID", 0, ""}, +// { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, id.internalFlags), "internalFlags", 0, ""}, +// { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_s, id.externalFlags), "externalFlags", 0, ""}, +// { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, id.sa), "sa", 0, ""}, +// { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, id), "id", 0, "inline", 4}, + + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.beginX), "beginX", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.beginX.id), "id", 0, "id_s", sizeof(zNSSMsg_id_s), DFI_zNSSMsg_id_s}, + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_s, body.beginX.retXid), "retXid", 0, "Xid_t", sizeof(Xid_t), 0}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.beginX), "beginX", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.rw), "rw", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.rw.id), "id", 0, "id_s", sizeof(zNSSMsg_id_s), DFI_zNSSMsg_id_s}, + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_s, body.rw.startingOffset), "startingOffset", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_s, body.rw.length), "length", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.rw.timeout), "timeout", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.rw.numBytes), "numBytes", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.rw.totalBytes), "totalBytes", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.rw), "rw", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.read), "read", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.read.id), "id", 0, "id_s", sizeof(zNSSMsg_id_s), DFI_zNSSMsg_id_s}, + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_s, body.read.startingOffset), "startingOffset", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.read.numBytes), "numBytes", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.read.maxChunks), "maxChunks", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.read.numChunks), "numChunks", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.read.bytesRead), "bytesRead", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.read), "read", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.info), "info", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.info.id), "id", 0, "id_s", sizeof(zNSSMsg_id_s), DFI_zNSSMsg_id_s}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.info.version), "version", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.info), "info", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.map), "map", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.map.id), "id", 0, "id_s", sizeof(zNSSMsg_id_s), DFI_zNSSMsg_id_s}, + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_s, body.map.offset), "offset", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_s, body.map.retEndingOffset), "retEndingOffset", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.map.extentListFormat), "extentListFormat", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.map.retExtentListCount), "retExtentListCount", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.map), "map", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.dio), "dio", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.dio.id), "id", 0, "id_s", sizeof(zNSSMsg_id_s), DFI_zNSSMsg_id_s}, + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_s, body.dio.unitOffset), "unitOffset", 0, ""}, + { DFI_TYPE_ADDR , NULL , offsetof(zNSSMsg_s, body.dio.callBackContext), "callBackContext", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.dio), "dio", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.async), "async", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.async.id), "id", 0, "id_s", sizeof(zNSSMsg_id_s), DFI_zNSSMsg_id_s}, + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_s, body.async.startingOffset), "startingOffset", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_s, body.async.bytesToRead), "bytesToRead", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_s, body.async.retEof), "retEof", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.async.retActualBytes), "retActualBytes", 0, ""}, + { DFI_TYPE_ADDR , NULL , offsetof(zNSSMsg_s, body.async.callbackContext), "callbackContext", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.async), "async", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.wild), "wild", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.wild.id), "id", 0, "id_s", sizeof(zNSSMsg_id_s), DFI_zNSSMsg_id_s}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.wild.version), "version", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.wild.characterCode), "characterCode", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.wild.nameType), "nameType", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.wild.match), "match", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_s, body.wild.cookie), "cookie", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.wild), "wild", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.auth), "auth", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.auth.id), "id", 0, "id_s", sizeof(zNSSMsg_id_s), DFI_zNSSMsg_id_s}, + { DFI_TYPE_GUID_t , NULL , offsetof(zNSSMsg_s, body.auth.trustee), "trustee", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.auth.rights), "rights", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.auth.attributes), "attributes", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.auth.sequence), "sequence", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.auth.inheritedRightsMask), "inheritedRightsMask", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.auth), "auth", 0, "inline", 4}, + + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.name), "name", 0, "name_s", sizeof(zNSSMsg_name_s), DFI_zNSSMsg_name_s}, + + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.create), "create", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.create.name), "name", 0, "name_s", sizeof(zNSSMsg_name_s), DFI_zNSSMsg_name_s}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.create.requestedRights), "requestedRights", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.create.fileType), "fileType", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.create.fileAttributes), "fileAttributes", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.create), "create", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.delete), "delete", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.delete.name), "name", 0, "name_s", sizeof(zNSSMsg_name_s), DFI_zNSSMsg_name_s}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.delete.match), "match", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.delete), "delete", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.open), "open", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.open.name), "name", 0, "name_s", sizeof(zNSSMsg_name_s), DFI_zNSSMsg_name_s}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.open.requestedRights), "requestedRights", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.open), "open", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.infoByName), "infoByName", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.infoByName.name), "name", 0, "name_s", sizeof(zNSSMsg_name_s), DFI_zNSSMsg_name_s}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.infoByName.version), "version", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.infoByName), "infoByName", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.byZid), "byZid", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.byZid.name), "name", 0, "name_s", sizeof(zNSSMsg_name_s), DFI_zNSSMsg_name_s}, + { DFI_TYPE_VolumeID_t , NULL , offsetof(zNSSMsg_s, body.byZid.volumeID), "volumeID", 0, ""}, + { DFI_TYPE_Zid_t , NULL , offsetof(zNSSMsg_s, body.byZid.zid), "zid", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.byZid.requestedRights), "requestedRights", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.byZid), "byZid", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.dst), "dst", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.dst.name), "name", 0, "name_s", sizeof(zNSSMsg_name_s), DFI_zNSSMsg_name_s}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.dst.srcMatch), "srcMatch", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zNSSMsg_s, body.dst.nameSpace), "nameSpace", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.dst), "dst", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zNSSMsg_s, body.start), "start", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zNSSMsg_s, body.start.id), "id", 0, "id_s", sizeof(zNSSMsg_id_s), DFI_zNSSMsg_id_s}, + { DFI_TYPE_QUAD , NULL , offsetof(zNSSMsg_s, body.start.startingOffset), "startingOffset", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body.start), "start", 0, "inline", 4}, + + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zNSSMsg_s, body), "body", 0, "inline", 0}, + + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_ConnectionIDP_s[] = { + { DFI_TYPE_NINT , NULL , offsetof(ConnectionIDP_s, id), "id", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(ConnectionIDP_s, ptr), "ptr", 0, "NSSConnection_s", 0/*sizeof(NSSConnection_s)*/, DFI_NSSConnection_s}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_GeneralMsg_s[] = { + { DFI_TYPE_STATUS , NULL , offsetof(GeneralMsg_s, errStatus), "errStatus", 0, ""}, + { DFI_TYPE_BYTE_PTR , NULL , offsetof(GeneralMsg_s, errStatusSetter), "errStatusSetter", 0, "BYTE", sizeof(BYTE)}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(GeneralMsg_s, pssConn), "pssConn", 0, "ConnectionIDP_s", sizeof(ConnectionIDP_s), DFI_ConnectionIDP_s}, + { DFI_TYPE_NINT , NULL , offsetof(GeneralMsg_s, taskID), "taskID", 0, ""}, + { DFI_TYPE_WORD , NULL , offsetof(GeneralMsg_s, saID), "saID", 0, ""}, + { DFI_TYPE_WORD , NULL , offsetof(GeneralMsg_s, flags), "flags", 0, ""}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_zMacInfo_s[] = { + { DFI_TYPE_BYTE , NULL , offsetof(zMacInfo_s, finderInfo), "finderInfo", 32, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(zMacInfo_s, proDOSInfo), "proDOSInfo", 6, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(zMacInfo_s, filler), "filler", 2, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zMacInfo_s, dirRightsMask), "dirRightsMask", 0, ""}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_zUnixInfo_s[] = { + { DFI_TYPE_LONG , NULL , offsetof(zUnixInfo_s, fMode), "fMode", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zUnixInfo_s, rDev), "rDev", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zUnixInfo_s, myFlags), "myFlags", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zUnixInfo_s, nfsUID), "nfsUID", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zUnixInfo_s, nfsGID), "nfsGID", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zUnixInfo_s, nwUID), "nwUID", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zUnixInfo_s, nwGID), "nwGID", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zUnixInfo_s, nwEveryone), "nwEveryone", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zUnixInfo_s, nwUIDRights), "nwUIDRights", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zUnixInfo_s, nwGIDRights), "nwGIDRights", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zUnixInfo_s, nwEveryoneRights), "nwEveryoneRights", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(zUnixInfo_s, acsFlags), "acsFlags", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(zUnixInfo_s, firstCreated), "firstCreated", 0, ""}, + { DFI_TYPE_SWORD , NULL , offsetof(zUnixInfo_s, variableSize), "variableSize", 0, ""}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_zVolumeInfo_s[] = { + { DFI_TYPE_VolumeID_t , NULL , offsetof(zVolumeInfo_s, volumeID), "volumeID", 0, ""}, + { DFI_TYPE_GUID_t , NULL , offsetof(zVolumeInfo_s, ndsObjectID), "ndsObjectID", 0, "NDSid_t", sizeof(NDSid_t), NULL}, + { DFI_TYPE_LONG , NULL , offsetof(zVolumeInfo_s, volumeState), "volumeState", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zVolumeInfo_s, nameSpaceMask), "nameSpaceMask", 0, ""}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zVolumeInfo_s, features), "features", 0, "inline", 4}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, features.enabled), "enabled", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, features.enableModMask), "enableModMask", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, features.supported), "supported", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zVolumeInfo_s, features), "features", 0, "inline", 4}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, maximumFileSize), "maximumFileSize", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, totalSpaceQuota), "totalSpaceQuota", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, numUsedBytes), "numUsedBytes", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, numObjects), "numObjects", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, numFiles), "numFiles", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zVolumeInfo_s, authModelID), "authModelID", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zVolumeInfo_s, dataShreddingCount), "dataShreddingCount", 0, ""}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zVolumeInfo_s, salvage), "salvage", 0, "inline", 4}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, salvage.purgeableBytes), "purgeableBytes", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, salvage.nonPurgeableBytes), "nonPurgeableBytes", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, salvage.numDeletedFiles), "numDeletedFiles", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, salvage.oldestDeletedTime), "oldestDeletedTime", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zVolumeInfo_s, salvage.minKeepSeconds), "minKeepSeconds", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zVolumeInfo_s, salvage.maxKeepSeconds), "maxKeepSeconds", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zVolumeInfo_s, salvage.lowWaterMark), "lowWaterMark", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zVolumeInfo_s, salvage.highWaterMark), "highWaterMark", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zVolumeInfo_s, salvage), "salvage", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zVolumeInfo_s, comp), "comp", 0, "inline", 4}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, comp.numCompressedFiles), "numCompressedFiles", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, comp.numCompDelFiles), "numCompDelFiles", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, comp.numUncompressibleFiles), "numUncompressibleFiles", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, comp.numPreCompressedBytes), "numPreCompressedBytes", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zVolumeInfo_s, comp.numCompressedBytes), "numCompressedBytes", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zVolumeInfo_s, comp), "comp", 0, "inline", 4}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_zPoolInfo_s[] = { + { DFI_TYPE_VolumeID_t , NULL , offsetof(zPoolInfo_s, poolID), "poolID", 0, ""}, + { DFI_TYPE_GUID_t , NULL , offsetof(zPoolInfo_s, ndsObjectID), "ndsObjectID", 0, "NDSid_t", sizeof(NDSid_t), NULL}, + { DFI_TYPE_LONG , NULL , offsetof(zPoolInfo_s, poolState), "poolState", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zPoolInfo_s, nameSpaceMask), "nameSpaceMask", 0, ""}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zPoolInfo_s, features), "features", 0, "inline", 4}, + { DFI_TYPE_QUAD , NULL , offsetof(zPoolInfo_s, features.enabled), "enabled", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zPoolInfo_s, features.enableModMask), "enableModMask", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zPoolInfo_s, features.supported), "supported", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zPoolInfo_s, features), "features", 0, "inline", 4}, + { DFI_TYPE_QUAD , NULL , offsetof(zPoolInfo_s, totalSpace), "totalSpace", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zPoolInfo_s, numUsedBytes), "numUsedBytes", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zPoolInfo_s, purgeableBytes), "purgeableBytes", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zPoolInfo_s, nonPurgeableBytes), "nonPurgeableBytes", 0, ""}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_zInfo_s[] = { + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, infoVersion), "infoVersion", 0, ""}, + { DFI_TYPE_SLONG , NULL , offsetof(zInfo_s, totalBytes), "totalBytes", 0, ""}, + { DFI_TYPE_SLONG , NULL , offsetof(zInfo_s, nextByte), "nextByte", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, padding), "padding", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zInfo_s, retMask), "retMask", 0, ""}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zInfo_s, std), "std", 0, "inline", 4}, + { DFI_TYPE_Zid_t , NULL , offsetof(zInfo_s, std.zid), "zid", 0, ""}, + { DFI_TYPE_Zid_t , NULL , offsetof(zInfo_s, std.dataStreamZid), "dataStreamZid", 0, ""}, + { DFI_TYPE_Zid_t , NULL , offsetof(zInfo_s, std.parentZid), "parentZid", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zInfo_s, std.logicalEOF), "logicalEOF", 0, ""}, + { DFI_TYPE_VolumeID_t , NULL , offsetof(zInfo_s, std.volumeID), "volumeID", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, std.fileType), "fileType", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, std.fileAttributes), "fileAttributes", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, std.fileAttributesModMask), "fileAttributesModMask", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, std.padding), "padding", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zInfo_s, std), "std", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zInfo_s, storageUsed), "storageUsed", 0, "inline", 4}, + { DFI_TYPE_QUAD , NULL , offsetof(zInfo_s, storageUsed.physicalEOF), "physicalEOF", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zInfo_s, storageUsed.dataBytes), "dataBytes", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zInfo_s, storageUsed.metaDataBytes), "metaDataBytes", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zInfo_s, storageUsed), "storageUsed", 0, "inline", 4}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, primaryNameSpaceID), "primaryNameSpaceID", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, nameStart), "nameStart", 0, ""}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zInfo_s, names), "names", 0, "inline", 4}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, names.numEntries), "numEntries", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, names.fileNameArray), "fileNameArray", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zInfo_s, names), "names", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zInfo_s, time), "time", 0, "inline", 4}, + { DFI_TYPE_QUAD , NULL , offsetof(zInfo_s, time.created), "created", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zInfo_s, time.archived), "archived", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zInfo_s, time.modified), "modified", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zInfo_s, time.accessed), "accessed", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zInfo_s, time.metaDataModified), "metaDataModified", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zInfo_s, time), "time", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zInfo_s, id), "id", 0, "inline", 4}, + { DFI_TYPE_UserID_t , NULL , offsetof(zInfo_s, id.owner), "owner", 0, ""}, + { DFI_TYPE_UserID_t , NULL , offsetof(zInfo_s, id.archiver), "archiver", 0, ""}, + { DFI_TYPE_UserID_t , NULL , offsetof(zInfo_s, id.modifier), "modifier", 0, ""}, + { DFI_TYPE_UserID_t , NULL , offsetof(zInfo_s, id.metaDataModifier), "metaDataModifier", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zInfo_s, id), "id", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zInfo_s, blockSize), "blockSize", 0, "inline", 4}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, blockSize.size), "size", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, blockSize.sizeShift), "sizeShift", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zInfo_s, blockSize), "blockSize", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zInfo_s, count), "count", 0, "inline", 4}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, count.open), "open", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, count.hardLink), "hardLink", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zInfo_s, count), "count", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zInfo_s, dataStream), "dataStream", 0, "inline", 4}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, dataStream.count), "count", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, dataStream.totalNameSize), "totalNameSize", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zInfo_s, dataStream.totalDataSize), "totalDataSize", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zInfo_s, dataStream), "dataStream", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zInfo_s, extAttr), "extAttr", 0, "inline", 4}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, extAttr.count), "count", 0, ""}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, extAttr.totalNameSize), "totalNameSize", 0, ""}, + { DFI_TYPE_QUAD , NULL , offsetof(zInfo_s, extAttr.totalDataSize), "totalDataSize", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zInfo_s, extAttr), "extAttr", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zInfo_s, deleted), "deleted", 0, "inline", 4}, + { DFI_TYPE_QUAD , NULL , offsetof(zInfo_s, deleted.time), "time", 0, ""}, + { DFI_TYPE_UserID_t , NULL , offsetof(zInfo_s, deleted.id), "id", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zInfo_s, deleted), "deleted", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zInfo_s, macNS), "macNS", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zInfo_s, macNS.info), "info", 0, "zMacInfo_s", sizeof(zMacInfo_s), DFI_zMacInfo_s}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zInfo_s, macNS), "macNS", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(zInfo_s, unixNS), "unixNS", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zInfo_s, unixNS.info), "info", 0, "zUnixInfo_s", sizeof(zUnixInfo_s), DFI_zUnixInfo_s}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, unixNS.offsetToData), "offsetToData", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(zInfo_s, unixNS), "unixNS", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zInfo_s, vol), "vol", 0, "zVolumeInfo_s", sizeof(zVolumeInfo_s), DFI_zVolumeInfo_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(zInfo_s, pool), "pool", 0, "zPoolInfo_s", sizeof(zPoolInfo_s), DFI_zPoolInfo_s}, + { DFI_TYPE_LONG , NULL , offsetof(zInfo_s, extAttrUserFlags), "extAttrUserFlags", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(zInfo_s, variableData), "variableData", zGET_INFO_VARIABLE_DATA_SIZE, ""}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_CacheControl_s[] = { /* StrDump.pl generated modified by hand */ + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, waitQ), "waitQ", 0, "CIRhead_t", sizeof(CIRhead_t), DFI_CIRhead_t}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(CacheControl_s, bucket), "bucket", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(CacheControl_s, bucketPageBuffer), "bucketPageBuffer", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, lruQDirty), "lruQDirty", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, lruQBonded), "lruQBonded", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, lruQAvail), "lruQAvail", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, lruQAvailUser), "lruQAvailUser", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, lruQAvailMetaData), "lruQAvailMetaData", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, lruQNoLinuxPages), "lruQNoLinuxPages", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, lruQMetadataPage), "lruQMetadataPage", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, bufLists), "bufLists", 0, "STKtop_t", sizeof(STKtop_t), DFI_STKtop_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, noPageBufs), "noPageBufs", 0, "STKtop_t", sizeof(STKtop_t), DFI_STKtop_t}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, freePageBuffers), "freePageBuffers", 0, "STKtop_t", sizeof(STKtop_t), DFI_STKtop_t}, + { DFI_TYPE_NINT , NULL , offsetof(CacheControl_s, available), "available", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(CacheControl_s, control), "control", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(CacheControl_s, slabbed), "slabbed", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(CacheControl_s, waitInst), "waitInst", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(CacheControl_s, oldNumBuffers), "oldNumBuffers", 0, ""}, + { DFI_TYPE_BOOL , NULL , offsetof(CacheControl_s, isInitialized), "isInitialized", 0, ""}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(CacheControl_s, giver), "giver", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, giver.fsm), "fsm", 0, "FsmLite_s", sizeof(FsmLite_s), DFI_FsmLite_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, giver.alarm), "alarm", 0, "OneShot_s", sizeof(OneShot_s), DFI_OneShot_s}, + { DFI_TYPE_BOOL , NULL , offsetof(CacheControl_s, giver.isRunning), "isRunning", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(CacheControl_s, giver), "giver", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(CacheControl_s, taker), "taker", 0, "inline", 4}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, taker.fsm), "fsm", 0, "FsmLite_s", sizeof(FsmLite_s), DFI_FsmLite_s}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, taker.alarm), "alarm", 0, "OneShot_s", sizeof(OneShot_s), DFI_OneShot_s}, + { DFI_TYPE_BOOL , NULL , offsetof(CacheControl_s, taker.isRunning), "isRunning", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(CacheControl_s, taker), "taker", 0, "inline", 4}, + { DFI_TYPE_LONG , NULL , offsetof(CacheControl_s, loadModuleEventID), "loadModuleEventID", 0, ""}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(CacheControl_s, CC_HMCCacheTypeLatch ), "CC_HMCCacheTypeLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_Config_s[] = { /* StrDump.pl generated */ + { DFI_TYPE_UNION_HEADER , NULL , offsetof(Config_s, cache), "cache", 0, "inline", 4}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.numBuffers), "numBuffers", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.numBonds), "numBonds", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.numAsyncios), "numAsyncios", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.hashSize), "hashSize", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.hashMask), "hashMask", 0, ""}, + { DFI_TYPE_BOOL , NULL , offsetof(Config_s, cache.usePercentMemory), "usePercentMemory", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.percentOfOSFree), "percentOfOSFree", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.balanceTimerSecs), "balanceTimerSecs", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.minOSFree), "minOSFree", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.numPagesAllocated), "numPagesAllocated", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.maxNumBuffersToAddPerBalance), "maxNumBuffersToAddPerBalance", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.userPages), "userPages", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.percentUserPages), "percentUserPages", 0, ""}, + { DFI_TYPE_BOOL , NULL , offsetof(Config_s, cache.hmcCacheType), "hmcCacheType", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.privateHashSize), "privateHashSize", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.privateHashMask), "privateHashMask", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.privateCachePageBuffers), "privateCachePageBuffers", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.privateCachePages), "privateCachePages", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.privateCacheSizeRequest), "privateCacheSizeRequest", 0, ""}, + { DFI_TYPE_BOOL , NULL , offsetof(Config_s, cache.privateCacheSizeRequestStartup), "privateCacheSizeRequestStartup", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.metadataBlocksReadyForGroupWriteLimit), "metadataBlocksReadyForGroupWriteLimit", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, cache.metadataBlocksReadyForGroupWrite), "metadataBlocksReadyForGroupWrite", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(Config_s, cache), "cache", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(Config_s, os), "os", 0, "inline", 4}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, os.sizeMailbox), "sizeMailbox", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, os.workLimit), "workLimit", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, os.workDelayCnt), "workDelayCnt", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(Config_s, os), "os", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(Config_s, bst), "bst", 0, "inline", 4}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, bst.notInUseMax), "notInUseMax", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, bst.percentMemory), "percentMemory", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, bst.balanceTimerSecs), "balanceTimerSecs", 0, ""}, +// { DFI_TYPE_NINT , NULL , offsetof(Config_s, bst.hashShift), "hashShift", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, bst.hashSize), "hashSize", 0, ""}, +// { DFI_TYPE_NINT , NULL , offsetof(Config_s, bst.hashMask), "hashMask", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, bst.notInUseLimit), "notInUseLimit", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, bst.total), "total", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, bst.notInUse), "notInUse", 0, ""}, + { DFI_TYPE_SNINT , NULL , offsetof(Config_s, bst.remainingLimit), "remainingLimit", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(Config_s, bst), "bst", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(Config_s, sec), "sec", 0, "inline", 4}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, sec.beast), "beast", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, sec.xaction), "xaction", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, sec.chkpt), "chkpt", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, sec.opLockWait), "opLockWait", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, sec.journalGroupWriteTime), "journalGroupWriteTime", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, sec.metadataGroupWriteTime), "metadataGroupWriteTime", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, sec.userDataGroupWriteTime), "userDataGroupWriteTime", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(Config_s, sec), "sec", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(Config_s, msec_s), "msec_s", 0, "inline", 4}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, msec_s.workWait), "workWait", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(Config_s, msec_s), "msec_s", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(Config_s, tick), "tick", 0, "inline", 4}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, tick.beast), "beast", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, tick.xaction), "xaction", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, tick.chkpt), "chkpt", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, tick.opLockWait), "opLockWait", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(Config_s, tick), "tick", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(Config_s, work), "work", 0, "inline", 4}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, work.waiting), "waiting", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, work.waitingHigh), "waitingHigh", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(Config_s, work), "work", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(Config_s, xact), "xact", 0, "inline", 4}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, xact.numDelayed), "numDelayed", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(Config_s, xact), "xact", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(Config_s, zfs), "zfs", 0, "inline", 4}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, zfs.numXactions), "numXactions", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, zfs.numXdeletes), "numXdeletes", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(Config_s, zfs), "zfs", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(Config_s, Storage), "Storage", 0, "inline", 4}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, Storage.alarmThreshold), "alarmThreshold", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, Storage.resetThreshold), "resetThreshold", 0, ""}, + { DFI_TYPE_BOOL , NULL , offsetof(Config_s, Storage.sendAlert), "sendAlert", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, Storage.allocAhead), "allocAhead", 0, ""}, + { DFI_TYPE_BOOL , NULL , offsetof(Config_s, Storage.checker), "checker", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(Config_s, Storage), "Storage", 0, "inline", 4}, + { DFI_TYPE_UNION_HEADER , NULL , offsetof(Config_s, lv), "lv", 0, "inline", 4}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, lv.PurgeDelayAfterDeleteSeconds), "PurgeDelayAfterDeleteSeconds", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, lv.PurgeDelayAfterLoadSeconds), "PurgeDelayAfterLoadSeconds", 0, ""}, + { DFI_TYPE_NINT , NULL , offsetof(Config_s, lv.PurgeDelayAfterLastEntrySeconds), "PurgeDelayAfterLastEntrySeconds", 0, ""}, + { DFI_TYPE_UNION_TAIL , NULL , offsetof(Config_s, lv), "lv", 0, "inline", 4}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_PersistentPool_s[] = { + { DFI_TYPE_LONG , NULL, offsetof( PersistentPool_s, PP_blockSize ), "PP_blockSize", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentPool_s, PP_blockShift ), "PP_blockShift", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentPool_s, PP_rebuildCount ), "PP_rebuildCount", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentPool_s, PP_reserved0 ), "PP_reserved0", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( PersistentPool_s, PP_mac ), "PP_mac", 32, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentPool_s, PP_minKeepSeconds ), "PP_minKeepSeconds", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentPool_s, PP_maxKeepSeconds ), "PP_maxKeepSeconds", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( PersistentPool_s, PP_lowWaterMark ), "PP_lowWaterMark", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( PersistentPool_s, PP_highWaterMark ), "PP_highWaterMark", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( PersistentPool_s, PP_reserved2 ), "PP_reserved2", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentPool_s, PP_stateAttributes ), "PP_stateAttributes", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PersistentPool_s, PP_freeToUse ), "PP_freeToUse", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PersistentPool_s, PP_enabledFeatures ), "PP_enabledFeatures", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentPool_s, PP_mediaFormatMajor ), "PP_mediaFormatMajor", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentPool_s, PP_mediaFormatMinor ), "PP_mediaFormatMinor", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( PersistentPool_s, PP_ndsObjectID ), "PP_ndsObjectID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentPool_s, PP_reserved ), "PP_reserved", 64-22-4, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_LoggedPersistentPool_s[] = { + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentPool_s, LPP_totalBlocks ), "LPP_totalBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentPool_s, LPP_inUseBlocks ), "LPP_inUseBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentPool_s, LPP_purgeableBlocks ), "LPP_purgeableBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentPool_s, LPP_nonPurgeableBlocks ), "LPP_nonPurgeableBlocks", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( LoggedPersistentPool_s, LPP_reserved ), "LPP_reserved", 64-8, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_Pool_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, avfile ), "avfile", 0, "AdminVolFile_s", sizeof(AdminVolFile_s), DFI_AdminVolFile_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, p ), "p", 0, "PersistentPool_s", sizeof(PersistentPool_s), DFI_PersistentPool_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, logged ), "logged", 0, "LoggedPersistentPool_s", sizeof(LoggedPersistentPool_s), DFI_LoggedPersistentPool_s }, + { DFI_TYPE_QUAD , NULL, offsetof( Pool_s, supportedFeatures ), "supportedFeatures", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Pool_s, storageIndex ), "storageIndex", 0, "" }, + { DFI_TYPE_VolumeID_t , NULL, offsetof( Pool_s, volumeID ), "volumeID", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, masterPoolLink ), "masterPoolLink", 0, "SETlink_t", sizeof(SETlink_t), DFI_SETlink_t }, + { DFI_TYPE_NINT , NULL, offsetof( Pool_s, state ), "state", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, agent ), "agent", 0, "Agent_s", sizeof(Agent_s), DFI_Agent_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, cvsLatch ), "cvsLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, stateLatch ), "stateLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, rsrcLatch ), "rsrcLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_NINT , NULL, offsetof( Pool_s, maintenanceStatus ), "maintenanceStatus", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( Pool_s, maintenanceTime ), "maintenanceTime", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Pool_s, freeBlockAdjustment ), "freeBlockAdjustment", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Pool_s, nextTimeToCheck ), "nextTimeToCheck", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Pool_s, v_statusFlag ), "v_statusFlag", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Pool_s, v_keepActiveUseCount ), "v_keepActiveUseCount", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Pool_s, v_ioFlag ), "v_ioFlag", 0, "" }, + { DFI_TYPE_STATUS , NULL, offsetof( Pool_s, v_disableVolumeStatus ), "v_disableVolumeStatus", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Pool_s, v_alertUTCOfLNextUserWriteAlert ), "v_alertUTCOfLNextUserWriteAlert", 0, "" }, +#if VOL_DISABLE_USE_SYSTEMS_WORK_TO_DO + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, v_disableWorkToDoStructure ), "v_disableWorkToDoStructure", 0, "zWorkProc_s", sizeof(zWorkProc_s), DFI_zWorkProc_s }, +#else + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, v_disableWorkToDoFsm ), "v_disableWorkToDoFsm", 0, "FsmLite_s", sizeof(FsmLite_s), DFI_FsmLite_s }, +#endif + { DFI_TYPE_NINT , NULL, offsetof( Pool_s, v_alertListCount ), "v_alertListCount", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, v_alertList ), "v_alertList", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, v_alertWorkToDoFsm ), "v_alertWorkToDoFsm", 0, "FsmLite_s", sizeof(FsmLite_s), DFI_FsmLite_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, P_VolumeList ), "P_VolumeList", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( Pool_s, P_VolumeInternal ), "P_VolumeInternal", 0, "Volume_s", sizeof(Volume_s), DFI_Volume_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, P_FreezeThawLatch ), "P_FreezeThawLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, P_MaintenaceLatch ), "P_MaintenaceLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( Pool_s, P_Owner ), "P_Owner", 0, "PoolOwnership_s", sizeof(PoolOwnership_s), DFI_PoolOwnership_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( Pool_s, P_Inode ), "P_Inode", 0, "struct inode", sizeof(struct inode), DFI_inode_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Pool_s, P_MDHimemList ), "P_MDHimemList", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_PoolOwnership_s[] = { + { DFI_TYPE_LONG , NULL, offsetof( PoolOwnership_s, PO_signature ), "PO_signature", 0, "" }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( PoolOwnership_s, PO_pool ), "PO_pool", 0, "Pool_s", sizeof(Pool_s), DFI_Pool_s }, +// { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( PoolOwnership_s, PO_moduleHandle ), "PO_moduleHandle", 0, "struct LoadDefinitionStructure", 0/*sizeof(LoadDefinitionStructure)*/, DFI_LoadDefinitionStructure }, + { DFI_TYPE_char_STR , NULL , offsetof(PoolOwnership_s, PO_who), "PO_who", 128-12, "char", 128-12, NULL}, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_AdminVolFile_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( AdminVolFile_s, file ), "file", 0, "File_s", sizeof(File_s), DFI_File_s }, + { DFI_TYPE_Key_t , NULL, offsetof( AdminVolFile_s, specialBeastDirKey ), "specialBeastDirKey", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + + +DFI_DataFormatInformation_s DFI_SQhead_t[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( SQhead_t, next ), "next", 0, "SQlink_s", sizeof(struct SQlink_s), DFI_SQlink_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( SQhead_t, last ), "last", 0, "SQlink_s", sizeof(struct SQlink_s), DFI_SQlink_s }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +#if 0 +DFI_DataFormatInformation_s DFI_SQlink_t[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( SQlink_t, next ), "next", 0, "SQlink_t", sizeof(SQlink_t), DFI_SQlink_t }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; +#endif + +DFI_DataFormatInformation_s DFI_SQlink_s[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( struct SQlink_s, next ), "next", 0, "SQlink_s", sizeof(struct SQlink_s), DFI_SQlink_s }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_CMVolumeState_s[] = { + { DFI_TYPE_BOOL , NULL, offsetof( CMVolumeState_s, compActive ), "compActive", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( CMVolumeState_s, compRequestQHead ), "compRequestQHead", 0, "SQhead_t", sizeof(SQhead_t), DFI_SQhead_t }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_UserXactionLogMetaData_s[] = { + { DFI_TYPE_Seq_t , NULL, offsetof( UserXactionLogMetaData_s, lastLSN ), "nameUniquifier", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( UserXactionLogMetaData_s, curBlk ), "curBlk", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( UserXactionLogMetaData_s, lastBlk ), "lastBlk", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( UserXactionLogMetaData_s, insertOffset ), "insertOffset", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( UserXactionLogMetaData_s, logFileBlockSize ), "logFileBlockSize", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( UserXactionLogMetaData_s, logFileSizeInBlocks ), "logFileSizeInBlocks", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( UserXactionLogMetaData_s, logFileBlockSizeShiftFactor ), "logFileBlockSizeShiftFactor", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_zWorkProc_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( zWorkProc_s, zwork ), "named", 0, "zWork_s", sizeof(zWork_s), DFI_zWork_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( zWorkProc_s, info ), "info", 0, "void", 0, DFI_NotUsed_s }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_zWork_s[] = { + { DFI_TYPE_LONG , NULL, offsetof( zWork_s, osReserved ), "osReserved", 0, "" }, + { DFI_TYPE_FUNC_PTR , NULL, offsetof( zWork_s, ProcedureToCall ), "ProcedureToCall", 0, "voidfunc_t", sizeof( voidfunc_t ) }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( zWork_s, WorkResourceTag ), "WorkResourceTag", 0, "ResourceTagStructure", 0 /*sizeof(ResourceTagStructure)*/, DFI_ResourceTagStructure }, + { DFI_TYPE_LONG , NULL, offsetof( zWork_s, reserved ), "reserved", 2, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_Volume_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, avfile ), "avfile", 0, "AdminVolFile_s", sizeof(AdminVolFile_s), DFI_AdminVolFile_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, p ), "p", 0, "PersistentVolume_s", sizeof(PersistentVolume_s), DFI_PersistentVolume_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, logged ), "logged", 0, "LoggedPersistentVolume_s", sizeof(LoggedPersistentVolume_s), DFI_LoggedPersistentVolume_s }, + { DFI_TYPE_QUAD , NULL, offsetof( Volume_s, supportedAttributes ), "supportedAttributes", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( Volume_s, maximumFileSize ), "maximumFileSize", 0, "" }, + { DFI_TYPE_Zid_t , NULL, offsetof( Volume_s, zidInProcess ), "zidInProcess", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Volume_s, storageIndex ), "storageIndex", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Volume_s, authModelIndex ), "authModelIndex", 0, "" }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( Volume_s, authModel ), "authModel", 0, "AuthModelBeast_s", sizeof(AuthModelBeast_s), DFI_AuthModelBeast_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( Volume_s, rootdir ), "rootdir", 0, "File_s", sizeof(File_s), DFI_File_s }, + { DFI_TYPE_VolumeID_t , NULL, offsetof( Volume_s, volumeID ), "volumeID", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, masterVolLink ), "masterVolLink", 0, "SETlink_t", sizeof(SETlink_t), DFI_SETlink_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, beastList ), "beastList", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_NINT , NULL, offsetof( Volume_s, state ), "state", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Volume_s, maxBeastSize ), "maxBeastSize", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, agent ), "agent", 0, "Agent_s", sizeof(Agent_s), DFI_Agent_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, cvsLatch ), "cvsLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, stateLatch ), "stateLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_NINT , NULL, offsetof( Volume_s, maintenanceStatus ), "maintenanceStatus", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( Volume_s, maintenanceTime ), "maintenanceTime", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Volume_s, freeBlockAdjustment ), "freeBlockAdjustment", 0, "" }, + { DFI_TYPE_BOOL , NULL, offsetof( Volume_s, storageAlertHasBeenSent ), "storageAlertHasBeenSent", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Volume_s, nextTimeToCheck ), "nextTimeToCheck", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Volume_s, v_statusFlag ), "v_statusFlag", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Volume_s, v_keepActiveUseCount ), "v_keepActiveUseCount", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Volume_s, v_keepDeactiveUseCount ), "v_keepDeactiveUseCount", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Volume_s, v_ioFlag ), "v_ioFlag", 0, "" }, + { DFI_TYPE_STATUS , NULL, offsetof( Volume_s, v_disableVolumeStatus ), "v_disableVolumeStatus", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_alertUTCOfLNextUserWriteAlert ), "v_alertUTCOfLNextUserWriteAlert", 0, "" }, +#if VOL_DISABLE_USE_SYSTEMS_WORK_TO_DO + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, v_disableWorkToDoStructure ), "v_disableWorkToDoStructure", 0, "zWorkProc_s", sizeof(zWorkProc_s), DFI_zWorkProc_s }, +#else + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, v_disableWorkToDoFsm ), "v_disableWorkToDoFsm", 0, "FsmLite_s", sizeof(FsmLite_s), DFI_FsmLite_s }, +#endif + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_restartCount ), "v_restartCount", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Volume_s, v_alertListCount ), "v_alertListCount", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, v_alertList ), "v_alertList", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, v_alertWorkToDoFsm ), "v_alertWorkToDoFsm", 0, "FsmLite_s", sizeof(FsmLite_s), DFI_FsmLite_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, v_poolVolLink ), "v_poolVolLink", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( Volume_s, v_pool ), "v_pool", 0, "Pool_s", sizeof(Pool_s), DFI_Pool_s }, + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_stats.IO_user_readSize ), "v_stats.IO_user_readSize", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_stats.IO_user_read_success ), "v_stats.IO_user_read_success", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_stats.IO_user_writeSize ), "v_stats.IO_user_writeSize", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_stats.IO_user_write_success ), "v_stats.IO_user_write_success", 0, "" }, +#if NSS_DEBUG IS_ENABLED + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_stats.IO_system_readSize ), "v_stats.IO_system_readSize", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_stats.IO_system_read_success ), "v_stats.IO_system_read_success", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_stats.IO_system_writeSize ), "v_stats.IO_system_writeSize", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_stats.IO_system_write_success ), "v_stats.IO_system_write_success", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_stats.IO_user_read_failure ), "v_stats.IO_user_read_failure", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_stats.IO_user_write_failure ), "v_stats.IO_user_write_failure", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_stats.IO_system_read_failure ), "v_stats.IO_system_read_failure", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_stats.IO_system_write_failure ), "v_stats.IO_system_write_failure", 0, "" }, +#endif + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, cmVolumeState ), "cmVolumeState", 0, "CMVolumeState_s", sizeof(CMVolumeState_s), DFI_CMVolumeState_s }, + { DFI_TYPE_LONG , NULL, offsetof( Volume_s, v_pState ), "v_pState", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( Volume_s, decompFreeSpaceWarningTime ), "decompFreeSpaceWarningTime", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, UXactionLogFileHandleIDP ), "UXactionLogFileHandleIDP", 0, "FileHandleIDP_s", sizeof(FileHandleIDP_s), DFI_FileHandleIDP_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, UXMetaData ), "UXMetaData", 0, "UserXactionLogMetaData_s", sizeof(UserXactionLogMetaData_s), DFI_UserXactionLogMetaData_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Volume_s, HomeTimeOrderList ), "HomeTimeOrderList", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_NINT , NULL, offsetof( Volume_s, readAheadBlocks ), "readAheadBlocks", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_LoggedPersistentVolume_s[] = { + { DFI_TYPE_Zid_t , NULL, offsetof( LoggedPersistentVolume_s, nextZid ), "nextZid", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentVolume_s, numFiles ), "numFiles", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentVolume_s, numObjects ), "numObjects", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentVolume_s, totalBlocks ), "totalBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentVolume_s, inUseBlocks ), "inUseBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentVolume_s, purgeableBlocks ), "purgeableBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentVolume_s, nonPurgeableBlocks ), "nonPurgeableBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentVolume_s, numDeletedFiles ), "numDeletedFiles", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( LoggedPersistentVolume_s, renameSeqNum ), "renameSeqNum", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( LoggedPersistentVolume_s, reserved1 ), "reserved1", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentVolume_s, numCompressedFiles ), "numCompressedFiles", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentVolume_s, numCompDelFiles ), "numCompDelFiles", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentVolume_s, numUncompressibleFiles ), "numUncompressibleFiles", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentVolume_s, numCompressedFileBlocks ), "numCompressedFileBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( LoggedPersistentVolume_s, numPreCompressedFileBlocks ), "numPreCompressedFileBlocks", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( LoggedPersistentVolume_s, epoch ), "epoch", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( LoggedPersistentVolume_s, reservedEpoch ), "reservedEpoch", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( LoggedPersistentVolume_s, LPV_reserved ), "LPV_reserved", 32-30, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_PersistentVolume_s[] = { + { DFI_TYPE_VolumeID_t , NULL, offsetof( PersistentVolume_s, NUvolumeID ), "NUvolumeID", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PersistentVolume_s, beastVersionMask ), "beastVersionMask", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, blockSize ), "blockSize", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, blockShift ), "blockShift", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, oldVolAttributes ), "oldVolAttributes", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, nameSpaceMask ), "nameSpaceMask", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( PersistentVolume_s, mac ), "mac", 32, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, authModelID ), "authModelID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, minKeepSeconds ), "minKeepSeconds", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, maxKeepSeconds ), "maxKeepSeconds", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( PersistentVolume_s, lowWaterMark ), "lowWaterMark", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( PersistentVolume_s, highWaterMark ), "highWaterMark", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( PersistentVolume_s, beastVersion ), "beastVersion", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, stateAttributes ), "stateAttributes", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, rebuildCount ), "rebuildCount", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( PersistentVolume_s, ndsObjectID ), "ndsObjectID", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PersistentVolume_s, enabledAttributes ), "enabledAttributes", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( PersistentVolume_s, compAttributes.ImplMajorVersion ), "ImplMajorVersion", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( PersistentVolume_s, compAttributes.ImplMinorVersion ), "ImplMinorVersion", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( PersistentVolume_s, compAttributes.algoID ), "algoID", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( PersistentVolume_s, compAttributes.algoVersion ), "algoVersion", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, compAttributes.compFlags ), "compFlags", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PersistentVolume_s, compAttributes.chunkSize ), "chunkSize", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PersistentVolume_s, compAttributes.algorithms_used ), "algorithms_used", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, PV_mediaFormatMajor ), "PV_mediaFormatMajor", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, PV_mediaFormatMinor ), "PV_mediaFormatMinor", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, PV_mediaFormatMajorCreate ), "PV_mediaFormatMajorCreate", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, PV_mediaFormatMinorCreate ), "PV_mediaFormatMinorCreate", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( PersistentVolume_s, PV_createTimeUTC ), "PV_createTimeUTC", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( PersistentVolume_s, PV_verifyTimeUTC ), "PV_verifyTimeUTC", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( PersistentVolume_s, PV_rebuildTimeUTC ), "PV_rebuildTimeUTC", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( PersistentVolume_s, PV_activationTimeUTC ), "PV_activationTimeUTC", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, PV_shredCount ), "PV_shredCount", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, PV_reserved2 ), "PV_reserved2", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentVolume_s, PV_reserved3 ), "PV_reserved3", 64 - (offsetof(struct PersistentVolume_s, PV_reserved2)/sizeof(LONG) + 1), "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_File_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( File_s, auth ), "auth", 0, "AuthBeast_s", sizeof(AuthBeast_s), DFI_AuthBeast_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( File_s, p ), "p", 0, "PersistentFile_s", sizeof(PersistentFile_s), DFI_PersistentFile_s }, + { DFI_TYPE_DOSTime_t , NULL, offsetof( File_s, accessedDOSTime ), "accessedDOSTime", 0, "" }, + { DFI_TYPE_DOSTime_t , NULL, offsetof( File_s, createdDOSTime ), "createdDOSTime", 0, "" }, + { DFI_TYPE_DOSTime_t , NULL, offsetof( File_s, modifiedDOSTime ), "modifiedDOSTime", 0, "" }, + { DFI_TYPE_DOSTime_t , NULL, offsetof( File_s, metaDataModifiedDOSTime ), "metaDataModifiedDOSTime", 0, "" }, + { DFI_TYPE_DOSTime_t , NULL, offsetof( File_s, archivedDOSTime ), "archivedDOSTime", 0, "" }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( File_s, opLockControl ), "opLockControl", 0, "OpLockControl_s", sizeof(OpLockControl_s), DFI_OpLockControl_s }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_PersistentFile_s[] = { + { DFI_TYPE_Time_t , NULL, offsetof( PersistentFile_s, accessedTime ), "accessedTime", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( PersistentFile_s, createdTime ), "createdTime", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( PersistentFile_s, modifiedTime ), "modifiedTime", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( PersistentFile_s, metaDataModifiedTime ), "metaDataModifiedTime", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( PersistentFile_s, archivedTime ), "archivedTime", 0, "" }, + { DFI_TYPE_UserID_t , NULL, offsetof( PersistentFile_s, modifierID ), "modifierID", 0, "" }, + { DFI_TYPE_UserID_t , NULL, offsetof( PersistentFile_s, metaDataModifierID ), "metaDataModifierID", 0, "" }, + { DFI_TYPE_UserID_t , NULL, offsetof( PersistentFile_s, archiverID ), "archiverID", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_ACLEntry_s[] = { + { DFI_TYPE_UserID_t , NULL, offsetof( ACLEntry_s, trusteeID ), "trusteeID", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ACLEntry_s, rights ), "rights", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ACLEntry_s, attributes ), "attributes", 0, "" }, + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_VisEntry_s[] = { + { DFI_TYPE_UserID_t , NULL, offsetof( VisEntry_s, trusteeID ), "trusteeID", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( VisEntry_s, count ), "count", 0, "" }, + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_ZASPersistentAuthInfo_s[] = { + { DFI_TYPE_WORD , NULL, offsetof( ZASPersistentAuthInfo_s, version ), "version", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ZASPersistentAuthInfo_s, extra1 ), "extra1", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZASPersistentAuthInfo_s, extra2 ), "extra2", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZASPersistentAuthInfo_s, cacheIndex ), "cacheIndex", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZASPersistentAuthInfo_s, restartCount ), "restartCount", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZASPersistentAuthInfo_s, signature ), "signature", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZASPersistentAuthInfo_s, inheritedRightsMask ), "inheritedRightsMask", 0, "" }, + { DFI_TYPE_Zid_t , NULL, offsetof( ZASPersistentAuthInfo_s, trusteeOverflow ), "trusteeOverflow", 0, "" }, + { DFI_TYPE_Zid_t , NULL, offsetof( ZASPersistentAuthInfo_s, visibilityOverflow ), "visibilityOverflow", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ZASPersistentAuthInfo_s, numTrusteesAssigned ), "numTrusteesAssigned", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ZASPersistentAuthInfo_s, numVisibilityTrusteesAssigned ), "numVisibilityTrusteesAssigned", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZASPersistentAuthInfo_s, ACL ), "ACL", 4, "ACLEntry_s", sizeof(ACLEntry_s), DFI_ACLEntry_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZASPersistentAuthInfo_s, visibilityList ), "visibilityList", 4, "VisEntry_s", sizeof(VisEntry_s), DFI_VisEntry_s }, + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_ZASAuthorizeInfo_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZASAuthorizeInfo_s, authLatch ), "authLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_BYTE , NULL, offsetof( ZASAuthorizeInfo_s, flags ), "flags", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZASAuthorizeInfo_s, p ), "p", 0, "ZASPersistentAuthInfo_s", sizeof(ZASPersistentAuthInfo_s), DFI_ZASPersistentAuthInfo_s }, + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_UXASPersistentAuthInfo_s[] = { + { DFI_TYPE_WORD , NULL, offsetof( UXASPersistentAuthInfo_s, version ), "version", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( UXASPersistentAuthInfo_s, extra1 ), "extra1", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( UXASPersistentAuthInfo_s, mode ), "mode", 0, "" }, + { DFI_TYPE_UserID_t , NULL, offsetof( UXASPersistentAuthInfo_s, groupID ), "groupID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( UXASPersistentAuthInfo_s, unused ), "unused", 8, "" }, + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_UXASAuthorizeInfo_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( UXASAuthorizeInfo_s, p ), "p", 0, "UXASPersistentAuthInfo_s", sizeof(UXASPersistentAuthInfo_s), DFI_UXASPersistentAuthInfo_s }, + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_AuthBeast_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( AuthBeast_s, named ), "named", 0, "NamedBeast_s", sizeof(NamedBeast_s), DFI_NamedBeast_s }, + { DFI_TYPE_UNION_HEADER , NULL, offsetof( AuthBeast_s, authInfo ), "authInfo", 0, "inline", 4 }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( AuthBeast_s, authInfo.generic ), "generic", 0, "void", 0, DFI_NotUsed_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( AuthBeast_s, authInfo.zas ), "zas", 0, "ZASAuthorizeInfo_s", sizeof(ZASAuthorizeInfo_s), DFI_ZASAuthorizeInfo_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( AuthBeast_s, authInfo.unx ), "unx", 0, "ZASAuthorizeInfo_s", sizeof(UXASAuthorizeInfo_s), DFI_UXASAuthorizeInfo_s }, + { DFI_TYPE_UNION_TAIL , NULL, offsetof( AuthBeast_s, authInfo ), "authInfo", 0, "inline", 4 }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( AuthBeast_s, authModelOps ), "authModelOps", 0, "AuthModelOps_s", sizeof(AuthModelOps_s), DFI_AuthModelOps_s }, + { DFI_TYPE_FUNC_PTR , NULL, offsetof( AuthBeast_s, mayIDoThis ), "mayIDoThis", 0, "BeastSpecificDecisionFunc_t", sizeof(BeastSpecificDecisionFunc_t) }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_PersistentParentEntry_s[] = { + { DFI_TYPE_WORD , NULL, offsetof( PersistentParentEntry_s, /* cnt nameUniquifier*/ reserved1 ), "nameUniquifier", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( PersistentParentEntry_s, nameType ), "nameType", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( PersistentParentEntry_s, primaryNameSpaceID ), "primaryNameSpaceID", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( PersistentParentEntry_s, numNames ), "numNames", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( PersistentParentEntry_s, reserved ), "reserved", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentParentEntry_s, renameSeqNum ), "renameSeqNum", 0, "" }, + { DFI_TYPE_Zid_t , NULL, offsetof( PersistentParentEntry_s, zid ), "zid", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_DeletedPersistentParentEntry_s[] = { + { DFI_TYPE_Time_t , NULL, offsetof( DeletedPersistentParentEntry_s, time ), "time", 0, "" }, + { DFI_TYPE_UserID_t , NULL, offsetof( DeletedPersistentParentEntry_s, ID ), "ID", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_TypeSpecificPersistentParentEntry_s[] = { + { DFI_TYPE_UNION_HEADER , NULL, offsetof( TypeSpecificPersistentParentEntry_s, u ), "u", 0, "inline", sizeof (DeletedPersistentParentEntry_s ) }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( TypeSpecificPersistentParentEntry_s, u.deleted ), "deleted", 0, "DeletedPersistentParentEntry_s", sizeof(DeletedPersistentParentEntry_s), DFI_DeletedPersistentParentEntry_s }, + { DFI_TYPE_UNION_TAIL , NULL, offsetof( TypeSpecificPersistentParentEntry_s, u ), "u", 0, "inline", sizeof (DeletedPersistentParentEntry_s ) }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_ParentEntry_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ParentEntry_s, p ), "p", 0, "PersistentParentEntry_s", sizeof(PersistentParentEntry_s), DFI_PersistentParentEntry_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ParentEntry_s, t ), "t", 0, "TypeSpecificPersistentParentEntry_s", sizeof(TypeSpecificPersistentParentEntry_s), DFI_TypeSpecificPersistentParentEntry_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ParentEntry_s, names ), "names", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_PersistentNamed_s[] = { + { DFI_TYPE_Zid_t , NULL, offsetof( PersistentNamed3_s, nextChildZID ), "nextChildZID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentNamed3_s, attributes ), "attributes", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( PersistentNamed3_s, numChildZIDs ), "numChildZIDs", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( PersistentNamed3_s, numParents ), "numParents", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( PersistentNamed3_s, nameFlags ), "nameFlags", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( PersistentNamed3_s, reserved ), "reserved", 0, "" }, + { DFI_TYPE_Zid_t , NULL, offsetof( PersistentNamed3_s, hardLinkZid ), "hardLinkZID", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_NamedBeast_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( NamedBeast_s, root ), "root", 0, "RootBeast_s", sizeof(RootBeast_s), DFI_RootBeast_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( NamedBeast_s, p ), "p", 0, "PersistentNamed_s", sizeof(PersistentNamed3_s), DFI_PersistentNamed_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( NamedBeast_s, firstParent ), "firstParent", 0, "ParentEntry_s", sizeof(ParentEntry_s), DFI_ParentEntry_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( NamedBeast_s, /* cnt otherParents*/ reserved1 ), "otherParents", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( NamedBeast_s, startLocks ), "startLocks", 0, "RBP_Node_s", sizeof(RBP_Node_s), DFI_RBP_Node_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( NamedBeast_s, endLocks ), "endLocks", 0, "RBP_Node_s", sizeof(RBP_Node_s), DFI_RBP_Node_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( NamedBeast_s, openFileHandles ), "openFileHandles", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_NINT , NULL, offsetof( NamedBeast_s, openCount ), "openCount", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( NamedBeast_s, dioModeCount ), "dioModeCount", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( NamedBeast_s, readerCount ), "readerCount", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( NamedBeast_s, writerCount ), "writerCount", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( NamedBeast_s, denyReaderCount ), "denyReaderCount", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( NamedBeast_s, denyWriterCount ), "denyWriterCount", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( NamedBeast_s, dontDeleteWhileOpenCount ), "dontDeleteWhileOpenCount", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( NamedBeast_s, /* cnt lastNameUniquifier*/ reserved ), "lastNameUniquifier", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( NamedBeast_s, snapReaderCount ), "snapReaderCount", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( NamedBeast_s, pad ), "pad", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_RootBeast_s[] = { + { DFI_TYPE_Zid_t , NULL, offsetof( RootBeast_s, zid ), "zid", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( RootBeast_s, eof ), "eof", 0, "" }, + { DFI_TYPE_UserID_t , NULL, offsetof( RootBeast_s, ownerID ), "ownerID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( RootBeast_s, metaDataSeqNum ), "metaDataSeqNum", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( RootBeast_s, blkSizeShift ), "blkSizeShift", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( RootBeast_s, beastVersion ), "beastVersion", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( RootBeast_s, unused ), "unused", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( RootBeast_s, bstState ), "bstState", 0, "" }, +#if NSS_DEBUG IS_ENABLED + { DFI_TYPE_unicode_t_PTR, NULL, offsetof( RootBeast_s, name ), "name", 0, "" }, +#endif + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( RootBeast_s, beastClass ), "beastClass", 0, "BeastClass_s", sizeof(BeastClass_s), DFI_BeastClass_s }, +// FixFixFix add class id here for Randy +// FixFixFix add bitMask define for Randy + { DFI_TYPE_NINT , NULL, offsetof( RootBeast_s, useCount ), "useCount", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( RootBeast_s, volLink ), "volLink", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( RootBeast_s, hash ), "hash", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( RootBeast_s, notInUseLink ), "notInUseLink", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( RootBeast_s, fileSnapshotBeast ), "fileSnapshotBeast", 0, "RootBeast_s", sizeof(RootBeast_s), DFI_RootBeast_s }, + { DFI_TYPE_NINT_PTR , NULL, offsetof( RootBeast_s, bitMap ), "bitMap", 0, "NINT", sizeof(NINT) }, + { DFI_TYPE_Blknum_t , NULL, offsetof( RootBeast_s, bitCount ), "bitCount", 0, "" }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( RootBeast_s, rb_inode ), "rb_inode", 0, "struct inode", sizeof(struct inode), DFI_inode_s }, + { DFI_TYPE_UNION_HEADER , NULL, offsetof( RootBeast_s, vol ), "vol", 0, "inline", 4 }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( RootBeast_s, vol.volume ), "volume", 0, "Volume_s", sizeof(Volume_s), DFI_Volume_s }, + { DFI_TYPE_STRUCT_PTR , NULL/*SDM_ZfsVolume_s*/, offsetof( RootBeast_s, vol.zfsVol ), "zfsVol", 0, "ZfsVolume_s", 4/*sizeof(ZfsVolume_s)*/ }, + { DFI_TYPE_STRUCT_PTR , NULL/*SDM_AdminVolume_s*/, offsetof( RootBeast_s, vol.adminVol ), "adminVol", 0, "AdminVolume_s", 4/*sizeof(AdminVolume_s)*/ }, + { DFI_TYPE_UNION_TAIL , NULL, offsetof( RootBeast_s, vol ), "vol", 0, "inline", 4 }, + { DFI_TYPE_UNION_HEADER , NULL, offsetof( RootBeast_s, storage ), "storage", 0, "inline", 4 }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( RootBeast_s, storage.info ), "info", 0, "StorageInfo_s", sizeof(StorageInfo_s), DFI_StorageInfo_s }, + { DFI_TYPE_STRUCT_PTR , NULL/*SDM_ZFSStorageInfo_s*/, offsetof( RootBeast_s, storage.zfsInfo ), "zfsInfo", 0, "ZFSStorageInfo_s", 4/*sizeof(ZFSStorageInfo_s)*/ }, + { DFI_TYPE_STRUCT_PTR , NULL/*SDM_AdminVolStorageInfo_s*/, offsetof( RootBeast_s, storage.avInfo ), "avInfo", 0, "AdminVolStorageInfo_s", 4/*sizeof(AdminVolStorageInfo_s)*/ }, + { DFI_TYPE_UNION_TAIL , NULL, offsetof( RootBeast_s, storage ), "storage", 0, "inline", 4 }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( RootBeast_s, mycache ), "mycache", 0, "MyCache_s", sizeof(MyCache_s), DFI_MyCache_s }, + { DFI_TYPE_PTR_PTR , NULL, offsetof( RootBeast_s, variableData ), "variableData", 0, "void [RVD_MAX_ELEMENTS]", sizeof( void * ) * RVD_MAX_ELEMENTS }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_FsmLite_s[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( FsmLite_s, link ), "link", 0, "CIRlink_t", sizeof(struct CIRlink_s), DFI_CIRlink_t }, + { DFI_TYPE_FUNC_PTR , NULL, offsetof( FsmLite_s, action ), "action", 0, "voidfunc_t", sizeof( voidfunc_t ) }, + { DFI_TYPE_UNION_HEADER , NULL, offsetof( FsmLite_s, param ), "param", 0, "inline", 4 }, + { DFI_TYPE_SNINT , NULL, offsetof( FsmLite_s, param.count ), "count", 0, "" }, + { DFI_TYPE_ADDR , NULL, offsetof( FsmLite_s, param.user ), "user", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( FsmLite_s, param.latchType ), "latchType", 0, "" }, + { DFI_TYPE_UNION_TAIL , NULL, offsetof( FsmLite_s, param ), "param", 0, "inline", 4 }, +#if NSS_DEBUG IS_ENABLED + { DFI_TYPE_char_PTR , NULL, offsetof( FsmLite_s, type ), "type", 0, "char", sizeof(char) }, + { DFI_TYPE_NINT , NULL, offsetof( FsmLite_s, instance ), "instance", 0, "" }, +#endif + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_Latch_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Latch_s, waiting ), "waiting", 0, "CIRhead_t", sizeof(struct CIRlink_s), DFI_CIRhead_t }, + { DFI_TYPE_SNINT , NULL, offsetof( Latch_s, count ), "count", 0, "" }, + { DFI_TYPE_ADDR , NULL, offsetof( Latch_s, L_thread ), "thread", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_PubBuffer_s[] = { + { DFI_TYPE_BYTE_PTR , NULL, offsetof( PubBuffer_s, data ), "data", 0, "BYTE", sizeof(BYTE) }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( PubBuffer_s, mycache ), "mycache", 0, "MyCache_s", sizeof(MyCache_s), DFI_MyCache_s }, + { DFI_TYPE_Blknum_t , NULL, offsetof( PubBuffer_s, fileBlk ), "fileBlk", 0, "" }, +#if BLKNUM_64 IS_DISABLED + { DFI_TYPE_LONG , NULL, offsetof( PubBuffer_s, pad ), "pad", 0, "" }, +#endif + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + + +DFI_DataFormatInformation_s DFI_SEThead_t[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( SETlink_t, next ), "next", 0, "SETlink_t", sizeof(SETlink_t), DFI_SETlink_t }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( SETlink_t, prev ), "prev", 0, "SETlink_t", sizeof(SETlink_t), DFI_SETlink_t }, + { DFI_TYPE_SQUAD , NULL, offsetof( SETlink_t, setNum ), "setNum", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_SETlink_t[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( SETlink_t, next ), "next", 0, "SETlink_t", sizeof(SETlink_t), DFI_SETlink_t }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( SETlink_t, prev ), "prev", 0, "SETlink_t", sizeof(SETlink_t), DFI_SETlink_t }, + { DFI_TYPE_SQUAD , NULL, offsetof( SETlink_t, setNum ), "setNum", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_CIRhead_t[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( struct STKlink_s, next ), "next", 0, "CIRhead_t", sizeof(struct CIRlink_s), DFI_CIRhead_t }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_CIRlink_t[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( struct STKlink_s, next ), "next", 0, "CIRlink_t", sizeof(struct CIRlink_s), DFI_CIRlink_t }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_CIRlink_s[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( struct CIRlink_s, next ), "next", 0, "CIRlink_s", sizeof(struct CIRlink_s), DFI_CIRlink_s }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_OneShot_s[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( OneShot_s, link ), "link", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_NINT , NULL, offsetof( OneShot_s, firetime ), "firetime", 0, "" }, + { DFI_TYPE_FUNC_PTR , NULL, offsetof( OneShot_s, function ), "function", 0, "void (*function)(OneShot_s *)", 4 }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_STKtop_t[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( struct STKlink_s, next ), "next", 0, "STKtop_t", sizeof(struct STKlink_s), DFI_STKtop_t }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_STKlink_t[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( struct STKlink_s, next ), "next", 0, "STKlink_t", sizeof(struct STKlink_s), DFI_STKlink_t }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_STKlink_s[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( struct STKlink_s, next ), "next", 0, "STKlink_s", sizeof(struct STKlink_s), DFI_STKlink_s }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_DQhead_t[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( DQhead_t, next ), "next", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( DQhead_t, prev ), "prev", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_DQlink_t[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( DQlink_t, next ), "next", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( DQlink_t, prev ), "prev", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_RBP_Node_s[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( RBP_Node_s, p ), "p", 0, "RBP_Node_s", sizeof(RBP_Node_s), DFI_RBP_Node_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( RBP_Node_s, l ), "l", 0, "RBP_Node_s", sizeof(RBP_Node_s), DFI_RBP_Node_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( RBP_Node_s, r ), "r", 0, "RBP_Node_s", sizeof(RBP_Node_s), DFI_RBP_Node_s }, + { DFI_TYPE_BOOL , NULL , offsetof(RBP_Node_s, red), "red", 0, ""}, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_MyCache_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( MyCache_s, bufList ), "bufList", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( MyCache_s, agent ), "agent", 0, "Agent_s", sizeof(Agent_s), DFI_Agent_s }, + { DFI_TYPE_BYTE , NULL, offsetof( MyCache_s, bufSizeShift ), "bufSizeShift", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( MyCache_s, reserved ), "reserved", 1, "" }, + { DFI_TYPE_WORD , NULL, offsetof( MyCache_s, state ), "state", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_Agent_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Agent_s, fsm ), "fsm", 0, "FsmLite_s", sizeof(FsmLite_s), DFI_FsmLite_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Agent_s, latch ), "latch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Agent_s, timer ), "timer", 0, "OneShot_s", sizeof(OneShot_s), DFI_OneShot_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( Agent_s, signalList ), "signalList", 0, "STKtop_t", sizeof(STKtop_t), DFI_STKtop_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Agent_s, flushList ), "flushList", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_FUNC_PTR , NULL, offsetof( Agent_s, signal ), "signal", 0, "AgentSignalFunc_t", sizeof(AgentSignalFunc_t) }, + { DFI_TYPE_LONG , NULL, offsetof( Agent_s, numLeft ), "numLeft", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( Agent_s, state ), "state", 0, "" }, + { DFI_TYPE_STATUS , NULL, offsetof( Agent_s, status ), "status", 0, "" }, + { DFI_TYPE_FUNC_PTR , NULL, offsetof( Agent_s, bondFreedSignal ), "bondFreedSignal", 0, "AgentSignalFunc_t", sizeof(AgentSignalFunc_t) }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_BioReq_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( BioReq_s, br_link ), "br_link", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_FUNC_PTR , NULL, offsetof( BioReq_s, br_callback ), "br_callback", 0, "BioReqCallback_t", sizeof(BioReqCallback_t) }, + { DFI_TYPE_STATUS , NULL, offsetof( BioReq_s, br_status ), "br_status", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_Buffer_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Buffer_s, pBuf ), "pBuf", 0, "PubBuffer_s", sizeof(PubBuffer_s), DFI_PubBuffer_s }, + { DFI_TYPE_Blknum_t , NULL, offsetof( Buffer_s, volBlk ), "volBlk", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Buffer_s, agent ), "agent", 0, "Agent_s", sizeof(Agent_s), DFI_Agent_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Buffer_s, hashLink ), "hashLink", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Buffer_s, lruLink ), "lruLink", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Buffer_s, mycacheLink ), "mycacheLink", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Buffer_s, signalLink ), "signalLink", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_FUNC_PTR , NULL, offsetof( Buffer_s, writeDone ), "writeDone", 0, "AgentSignalFunc_t", sizeof(AgentSignalFunc_t) }, + { DFI_TYPE_BYTE , NULL, offsetof( Buffer_s, state ), "state", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( Buffer_s, bufSizeShift ), "bufSizeShift", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( Buffer_s, ioRetryCount ), "ioRetryCount", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( Buffer_s, pinned ), "pinned", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( Buffer_s, timeStamp ), "timeStamp", 0, "" }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(Buffer_s, eData), "eData", 0, "struct EncryptedBufPage_s", sizeof(struct EncryptedBufPage_s), DFI_EncryptedBufPage_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(Buffer_s, b_page), "b_page", 0, "struct page", sizeof(struct page), DFI_page_s}, + { DFI_TYPE_LONG , NULL, offsetof( Buffer_s, b_mapCount ), "b_mapCount", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( Buffer_s, bioReq ), "bioReq", 0, "BioReq_s", sizeof(BioReq_s), DFI_BioReq_s }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_PageBuffer_s[] = { + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(PageBuffer_s, PB_Page), "PB_Page", 0, "struct page", sizeof(struct page), DFI_page_s}, + { DFI_TYPE_ADDR , NULL , offsetof(PageBuffer_s, PB_KeyPart), "PB_KeyPart", 0, ""}, + { DFI_TYPE_Blknum_t , NULL , offsetof(PageBuffer_s, PB_FileBlk), "PB_FileBlk", 0, ""}, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(PageBuffer_s, PB_LruLink ), "PB_LruLink", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(PageBuffer_s, PB_HashLink ), "PB_HashLink", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(PageBuffer_s, PB_PoolLink ), "PB_PoolLink", 0, "DQlink_t", sizeof(DQlink_t), DFI_DQlink_t }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" } +}; + + +DFI_DataFormatInformation_s DFI_Asyncio_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(Asyncio_s, fsm), "fsm", 0, "Fsm_s", sizeof(Fsm_s), DFI_Fsm_s}, + { DFI_TYPE_FUNC_PTR , NULL , offsetof(Asyncio_s, stack), "stack", MAX_IO_FSM_DEPTH, "voidfunc_t", sizeof(voidfunc_t)}, + { DFI_TYPE_STATUS , NULL , offsetof(Asyncio_s, status), "status", 0, ""}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(Asyncio_s, mycache), "mycache", 0, "MyCache_s", sizeof(MyCache_s), DFI_MyCache_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(Asyncio_s, buffer), "buffer", 0, "Buffer_s", sizeof(Buffer_s), DFI_Buffer_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(Asyncio_s, xaction), "xaction", 0, "Xaction_s", sizeof(Xaction_s), DFI_Xaction_s}, + { DFI_TYPE_Blknum_t , NULL , offsetof(Asyncio_s, fileBlk), "fileBlk", 0, ""}, + { DFI_TYPE_Blknum_t , NULL , offsetof(Asyncio_s, volBlk), "volBlk", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(Asyncio_s, mode), "mode", 0, ""}, + { DFI_TYPE_BYTE , NULL , offsetof(Asyncio_s, align), "align", 3, ""}, + { DFI_TYPE_FUNC_PTR , NULL , offsetof(Asyncio_s, flush), "flush", 0, "voidfunc_t", sizeof(voidfunc_t)}, + { DFI_TYPE_FUNC_PTR , NULL , offsetof(Asyncio_s, action), "action", 0, "voidfunc_t", sizeof(voidfunc_t)}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_Fsm_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(Fsm_s, lite), "lite", 0, "FsmLite_s", sizeof(FsmLite_s), DFI_FsmLite_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof(Fsm_s, rtnfsm), "rtnfsm", 0, "Fsm_s", sizeof(Fsm_s), DFI_Fsm_s}, + { DFI_TYPE_FUNC_PTR , NULL , offsetof(Fsm_s, sp), "sp", 0, "voidfunc_t", sizeof(voidfunc_t)}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_Xaction_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof(Xaction_s, agent), "agent", 0, "Agent_s", sizeof(Agent_s), DFI_Agent_s}, + { DFI_TYPE_END , NULL , 0, "", 0, "" }, +}; + diff --git a/src/nwnss/library/debug/snp.c b/src/nwnss/library/debug/snp.c new file mode 100644 index 0000000..58f9e15 --- /dev/null +++ b/src/nwnss/library/debug/snp.c @@ -0,0 +1,528 @@ +/**************************************************************************** + | + | (C) Copyright 2001, 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Printf to a buffer with automatic growth + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Printf wrapper object that prints into a buffer. Object will + | increase buffer if the print is too big. + / + / + / Warning - This file is used by NT Utilities like zedRemote, ZlogGet and + / etc. DO NOT ADD NSS specific code. The define NTLIB is only defined + / when source file is compiled with NT Utilities. + +-------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include + +#include "snp.h" + + +#ifdef NTLIB +//int LB_vsnprintf( char *destBuf, size_t destBufSize, const char *format, va_list args ); +//#else + +char LB_vsnprintfBuffer[LB_VSN_PRINTF_LIMIT]; + +/* + * WARNING - + * You must not use this function if you may add more data than your + * buffer can hold AND the amount you may add is greater than + * LB_VSN_PRINTF_LIMIT bytes. + * + * LB_vsnprintf() - + * Partial implementation of snprintf(). + * + * WARNING - + * You must not use this function if you may add more data than your + * buffer can hold AND the amount you may add is greater than + * LB_VSN_PRINTF_LIMIT bytes. + * + * Returns - + * Amount added to destBuf (not including the NULL) OR the size + * that the buffer needs to be for the call to succeed next time. + */ +int LB_vsnprintf( + char *destBuf, + int destBufSize, + const char *format, + va_list args ) + +{ + int addedOrError; + /* BOGUS, but I'm not going to write sprintf + * that takes a buffer size at this time. + */ + + SNP_TRACE; + if ( destBufSize < sizeof(LB_vsnprintfBuffer) ) + { + SNP_TRACE; + addedOrError = vsprintf( LB_vsnprintfBuffer, format, args ); + SNP_TRACE; + if ( addedOrError < 0 ) + { + SNP_TRACE; + return( addedOrError ); + } + SNP_TRACE; + if ( addedOrError < destBufSize ) + { /* Place contents into user buffer since it has room */ + SNP_TRACE; + (void)sprintf( destBuf, "%s", LB_vsnprintfBuffer ); + SNP_TRACE; + } + SNP_TRACE; + return( addedOrError ); + } + SNP_TRACE; + addedOrError = vsprintf( destBuf, format, args ); + SNP_TRACE; + return( addedOrError ); + +} /* End of LB_vsnprintf() */ + + +int LB_snprintf( + char *destBuf, + size_t destBufSize, + const char *format, + ...) +{ + va_list args; + int addedOrError; /* Does not include the NULL */ + + va_start( args, format ); + addedOrError = LB_vsnprintf( destBuf, destBufSize, format, args ); + return( addedOrError ); + +} /* End of LB_snprintf() */ +#endif + + + +/* + * SNP_Construct1() - + * Used when you do not wish for your SPB_Data to automatically increase + * in size when it runs out of space. Generally used by fix buffer callers + * or when fixed limits should be placed on buffer growth. + * + * Note that caller could limit growth by using SNP_Construct2 and storing + * off a size limit that would cause SPB_Alloc to fail when called. + */ +SNP_PrintBuffer_s *SNP_Construct1( + char *where, + SNP_PrintBuffer_s *pb, + char *data, + size_t size, + void *callerPointer ) +{ + if ( pb == NULL ) + { + return( NULL ); + } + if ( data == NULL ) + { + return( NULL ); + } + if ( size == 0 ) + { /* Must not be ZERO as we have to Alloc routine */ + return( NULL ); + } + pb->SPB_Data = data; + pb->SPB_Size = size; + pb->SPB_StringLength = 0; + pb->SPB_Alloc = NULL; + pb->SPB_Free = NULL; + pb->SPB_CallerPointer = callerPointer; + pb->SPB_ConstructSetter = where; + pb->SPB_LastEncodeError = 0; + pb->SPB_LastEncodeErrorSetter = ""; + pb->SPB_LastSizeError = 0; + pb->SPB_LastSizeErrorSetter = ""; + pb->SPB_Signature = SNP_SPB_SIGNATURE; + return( pb ); + +} /* End of SNP_Construct1 */ + + +/* + * SNP_Construct2() - + * Used when you wish for your SPB_Data to automatically increase + * in size when it runs out of space. + * + * Note that caller could limit growth by having SPB_Alloc fail + * at some point in growth calls. + */ +SNP_PrintBuffer_s *SNP_Construct2( + char *where, + SNP_PrintBuffer_s *pb, + int (*allocRoutine)( struct SNP_PrintBuffer_s *, size_t ), + int (*freeRoutine)( struct SNP_PrintBuffer_s * ), + size_t size, + void *callerPointer ) +{ + if ( pb == NULL ) + { + return( NULL ); + } + if ( allocRoutine == NULL ) + { + return( NULL ); + } + if ( freeRoutine == NULL ) + { + return( NULL ); + } + if ( size == 0 ) + { + size = 1; /* Watcom does not handle vsprintf being called with a NULL pointer */ + } + pb->SPB_Data = NULL; + pb->SPB_Size = size; + pb->SPB_StringLength = 0; + pb->SPB_CallerPointer = callerPointer; + pb->SPB_Alloc = allocRoutine; + pb->SPB_Free = freeRoutine; + pb->SPB_ConstructSetter = where; + pb->SPB_LastEncodeError = 0; + pb->SPB_LastEncodeErrorSetter = ""; + pb->SPB_LastSizeError = 0; + pb->SPB_LastSizeErrorSetter = ""; + if ( size != 0 ) + { + pb->SPB_Alloc( pb, pb->SPB_Size ); + if ( pb->SPB_Data == NULL ) + { + return( NULL ); + } + } + pb->SPB_Signature = SNP_SPB_SIGNATURE; + return( pb ); + +} /* End of SNP_Construct2 */ + + +/* + * SNP_Destruct() - + * Destructor of SNP_PrintBuffer_s object. + * + * Warnings - + * Owner of SNP_PrintBuffer_s object must first clean up + * resources connected with the SPB_CallerPointer field + * (if they are using it). + */ +void SNP_Destruct( + char *where, + SNP_PrintBuffer_s *pb ) + +{ + + if ( pb->SPB_Signature != SNP_SPB_SIGNATURE ) + { + return; + } + if ( (pb->SPB_Alloc ) && (pb->SPB_Data != NULL) ) + { + pb->SPB_Free( pb ); + } + pb->SPB_Signature = SNP_SPB_SIGNATURE_DESTRUCT; + return; + +} /* End of SNP_Destruct */ + + +/* + * SNP_DataDelete() - + * Resets SNP_PrintBuffer_s object's SPB_Data to contain no information. + * + */ +int SNP_DataDelete( + char *where, + SNP_PrintBuffer_s *pb ) + +{ + + if ( pb->SPB_Signature != SNP_SPB_SIGNATURE ) + { + return( 1 ); + } + if ( pb->SPB_Size > 0 ) + { + bzero( pb->SPB_Data, pb->SPB_Size ); + } + pb->SPB_StringLength = 0; + return( 0 ); + +} /* End of SNP_DataDelete */ + + +int SNP_DisplayOnScreen = 0; /* Caller of Library can set so items get placed on screen also */ +/* + * SNP_snprintf() - + * Prints into the SNP_PrintBuffer_s data buffer. + * + * Notes - + * If the SNP_snprintf was created with ALLOC/FREE routines + * supplied then this call will try to enlarge the SNP_PrintBuffer_s + * data buffer if it is not big enough to hold the 'print' + * + */ +int SNP_snprintf( + char *where, + SNP_PrintBuffer_s *pb, + const char *format, + ...) +{ + va_list args; + int destBufLeft; + int addedOrError; /* Does not include the NULL */ + + + +#if 0 + // Note that the below code shows that Watcom returns 4 for rc when it should return 6. + // Therefore we can not use as it does not tell us +{ + int rc; + char test[123]; + + rc = _snprintf( test, 5, "%s", "sadasd" ); + printf("%s %d\n", test, rc ); +} +#endif + + SNP_TRACE; + destBufLeft = pb->SPB_Size - pb->SPB_StringLength; +//printf("%d %d\n", destBufLeft, destBufLeft ); + SNP_TRACE; +//printf("%s", format ); + +#if 1 /* Set to 1 to display each line as it is put into the buffer */ + /* Used to debug when we crash so that we can see what + * we are expanding. + */ + if ( SNP_DisplayOnScreen ) + { + va_start( args, format ); + vprintf( format, args ); + va_end( args ); + } +#endif + + va_start( args, format ); + // + // The next three lines crash Watcom programs because their vprintf does not reset args ap back to 0 + // I do not know WHO must set back to zero, but MSFT runs this code without crashing. + // + // vprintf( format, args ); + // vprintf( format, args ); + // vprintf( format, args ); + SNP_TRACE; + addedOrError = LB_vsnprintf( pb->SPB_Data + pb->SPB_StringLength, destBufLeft, format, args ); + va_end( args ); + SNP_TRACE; + if ( addedOrError < 0 ) + { /* Encoding error */ + SNP_TRACE; + pb->SPB_LastEncodeError = addedOrError; + pb->SPB_LastEncodeErrorSetter = where; + return( addedOrError ); + } + if ( addedOrError < destBufLeft ) + { + SNP_TRACE; + pb->SPB_StringLength += addedOrError; + return( addedOrError ); + } + SNP_TRACE; + pb->SPB_LastSizeError = addedOrError + 1 - destBufLeft; + pb->SPB_LastSizeErrorSetter = where; +//printf("%s %d %d %d %d\n",WHERE,addedOrError,destBufLeft, pb->SPB_LastSizeError,pb->SPB_StringLength); + if ( pb->SPB_Alloc != NULL ) + { + if ( pb->SPB_Alloc( pb, pb->SPB_LastSizeError + pb->SPB_Size ) != 0 ) + { /* Could not (or would not) add new space */ + SNP_TRACE; + return( addedOrError ); + } + destBufLeft = pb->SPB_Size - pb->SPB_StringLength; + va_start( args, format ); + addedOrError = LB_vsnprintf( pb->SPB_Data + pb->SPB_StringLength, destBufLeft, format, args ); + va_end( args ); + if ( addedOrError < 0 ) + { /* Encoding error */ +printf("This is bad as we should have increased the size by the correct amount\n"); + pb->SPB_LastEncodeError = addedOrError; + pb->SPB_LastEncodeErrorSetter = where; + return( addedOrError ); + } + if ( addedOrError < destBufLeft ) + { + SNP_TRACE; + pb->SPB_StringLength += addedOrError; + return( addedOrError ); + } +//printf("%s %d %d\n",WHERE,addedOrError,destBufLeft); + return( addedOrError ); + } + SNP_TRACE; + return( addedOrError ); + +} /* End of SNP_snprintf() */ + + +/* + * SNP_Display() - + * Displays the contents of the SNP_PrintBuffer_s to the screen. + * + */ +void SNP_Display( + char *where, + SNP_PrintBuffer_s *pb) + +{ + + if ( (pb->SPB_Data != NULL) && (pb->SPB_StringLength != 0) ) + { + printf( "%s", pb->SPB_Data ); + } + +} /* End of SNP_Display() */ + + + + +#ifdef SNP_UNIT_TEST + +int SNP_UT_SPBAllocRoutine( SNP_PrintBuffer_s *pb, size_t size ) +{ + char *data; + + SNP_TRACE; + if ( size < pb->SPB_Size ) + { + printf("New size not big enough\n"); + return( 1 ); + } + if ( pb->SPB_Data == NULL ) + { + pb->SPB_Data = malloc( size ); + if ( pb->SPB_Data != NULL ) + { + pb->SPB_Size = size; + return( 0 ); + } + return( 1 ); + } + /* Realloc logic */ + data = malloc( size ); + if ( data == NULL ) + { +printf("Out of memory\n"); + return( 1 ); + } + SNP_TRACE; + memcpy( data, pb->SPB_Data, pb->SPB_StringLength + 1 ); + free( pb->SPB_Data ); + pb->SPB_Data = data; + pb->SPB_Size = size; + return( 0 ); +} /* End of SNP_UT_SPBAllocRoutine() */ + + +int SNP_UT_SPBFreeRoutine( SNP_PrintBuffer_s *pb ) +{ + if ( pb->SPB_Data != NULL ) + { + free( pb->SPB_Data ); + pb->SPB_Data = NULL; + pb->SPB_Size = 0; + } + return( 0 ); +} /* End of SNP_UT_SPBFreeRoutine() */ + + +int main (int argc, char *argv[]) +{ + unsigned int parseErrors = 0; + int addedOrError1; + int addedOrError2; + SNP_PrintBuffer_s *rc; + SNP_PrintBuffer_s pb1; + SNP_PrintBuffer_s pb2; + char stuff[128]; + + rc = SNP_Construct1( WHERE, &pb1, stuff, sizeof( stuff ), NULL ); + if ( rc == NULL ) + { + printf(" SNP_Construct1 failed \n"); + return(-1); + } + rc = SNP_Construct2( WHERE, &pb2, SNP_UT_SPBAllocRoutine, SNP_UT_SPBFreeRoutine, 0, NULL ); + if ( rc == NULL ) + { + SNP_Destruct( WHERE, &pb1 ); + printf(" SNP_Construct2 failed \n"); + return(-1); + } + + addedOrError1 = SNP_snprintf( WHERE, &pb1, "Hi Dad %d %s\n", 123, "Everett" ); + addedOrError2 = SNP_snprintf( WHERE, &pb2, "Hi Mom %s\n", "Elaine" ); + addedOrError1 = SNP_snprintf( WHERE, &pb1, "Hi Brother %s\n", "Bruce" ); + addedOrError2 = SNP_snprintf( WHERE, &pb2, "Hi Sister %s\n", "Susan" ); + + addedOrError2 = SNP_snprintf( WHERE, &pb2, "Hi Dad %d %s\n", 123, "Everett" ); + addedOrError1 = SNP_snprintf( WHERE, &pb1, "Hi Mom %s\n", "Elaine" ); + addedOrError2 = SNP_snprintf( WHERE, &pb2, "Hi Brother %s\n", "Bruce" ); + addedOrError1 = SNP_snprintf( WHERE, &pb1, "Hi Sister %s\n", "Susan" ); + + printf( "addedOrError1 %d\n", addedOrError1 ); + printf( "addedOrError2 %d\n", addedOrError2 ); + + SNP_Display( WHERE, &pb1 ); + SNP_Display( WHERE, &pb2 ); + + SNP_Destruct( WHERE, &pb1 ); + SNP_Destruct( WHERE, &pb2 ); + + return( 0 ); + +} /* End of main() */ + +#endif /* #ifdef SNP_UNIT_TEST */ + + + + diff --git a/src/nwnss/library/debug/warn.c b/src/nwnss/library/debug/warn.c new file mode 100644 index 0000000..fac4c5b --- /dev/null +++ b/src/nwnss/library/debug/warn.c @@ -0,0 +1,64 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library routine that handles ASSERTION failures. + +-------------------------------------------------------------------------*/ +#include "procdefs.h" /* NetWare includes*/ + +#include /* NSS Library Includes*/ +#include + +const char WarningMsg[] = MSGNot("\nWARNING: %s\n"); + +/************************************************************************** + * Report Warnings once. + ***************************************************************************/ +int DBG_AssertWarning( + char *err, + int *cnt) +{ + ++(*cnt); + if (*cnt == 1) + { +#ifdef UNIX + printf(WarningMsg, err); +#else + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID,YELLOW, + (char *)WarningMsg, err); + OutputToScreenWithAttribute(COMN_Resource.debuggerScreenID,YELLOW, + (char *)WarningMsg, err); +#endif + } + return 0; +} diff --git a/src/nwnss/library/eDir/getDSGuid.c b/src/nwnss/library/eDir/getDSGuid.c new file mode 100644 index 0000000..a8cb6a3 --- /dev/null +++ b/src/nwnss/library/eDir/getDSGuid.c @@ -0,0 +1 @@ +#include diff --git a/src/nwnss/library/eDir/parseDSObjectName.c b/src/nwnss/library/eDir/parseDSObjectName.c index 92f0162..4a2335d 100644 --- a/src/nwnss/library/eDir/parseDSObjectName.c +++ b/src/nwnss/library/eDir/parseDSObjectName.c @@ -1,5 +1 @@ -/* - * NSS userspace translation unit for the NSS shared source import. - * Original NSS provenance: public_core/sharedsrc/parseDSObjectName.c.h. - */ -#include +#include diff --git a/src/nwnss/library/fsm/fsmnw.c b/src/nwnss/library/fsm/fsmnw.c index 81fa659..9a7d826 100644 --- a/src/nwnss/library/fsm/fsmnw.c +++ b/src/nwnss/library/fsm/fsmnw.c @@ -35,29 +35,24 @@ | Code and synchronization primitives used by | Finite State Machines (FSMs) +-------------------------------------------------------------------------*/ +#include #include #include -#include -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include "pssConfig.h" +#include "schedule.h" +#include "alarm.h" +#include "fsm.h" +#include "inst.h" +#include "intmem.h" +#include "nssDebug.h" // TODO(Perf): Default FSM set to 1. (Undo Paul's FSMs checkins? ) -#if defined(__linux__) && !defined(__KERNEL__) -/* Linux userspace port: keep the NSS FSM ready queue, interrupt mailbox, - * and execution semantics available without starting kernel/NSS worker - * threads. Userspace callers can enqueue work and drain it through - * fsmWorkToDo(); fsmStart()/fsmStop() initialise and release the mailbox. */ -#define NUM_FSM_THREADS 0 -#define DEFAULT_INTERRUPT_MAILBOX_SIZE 64 -#else #define NUM_FSM_THREADS 4 -#endif typedef struct FsmThread_s { Link_t fsm_next; @@ -74,6 +69,7 @@ unsigned FsmMax = 0; unsigned NumFsmThreads = 0; unsigned MaxFsmThreads = 0; +mpkSema_t FsmSemaphore; BOOL FsmStop = FALSE; #if NSS_DEBUG IS_ENABLED @@ -96,7 +92,7 @@ void fsmInit ( { NINT i; void (**stack)() = (void (**)())stk; - + ENTER(TFSM, fsmInit); ASSERT_MPKNSS_LOCK(); @@ -126,7 +122,7 @@ void fsmInit ( FsmInst_s FsmInst = {0}; /************************************************************************** - * + * ***************************************************************************/ void fsmWorkToDo () { @@ -152,7 +148,7 @@ void fsmWorkToDo () MSGNot("Calling FSM %08x (Thread=%08x)\n"),fsm,ThreadId())); FsmInst.fsmDone++; ++num; - ((void (*)(FsmLite_s *))fsm->action)(fsm); + fsm->action(fsm); DEBUG_PRINTF(TYIELDS,DBG_BOTH_NOINDENT,(LRED, MSGNot("Returned from FSM %08x (Thread=%08x)\n"),fsm,ThreadId())); @@ -168,7 +164,7 @@ void mailInterrupt (void (*function)(), void *object) Action_s *action; NINT kick; LONG flags ; - + ASSERT_MPKNSS_LOCK(); flags = DisableAndRetFlags(); @@ -177,7 +173,7 @@ void mailInterrupt (void (*function)(), void *object) MB_NEXT( &InterruptMailbox, action, Action_s); zASSERT(action != NULL); - action->action = (void (*)(void *))function; + action->action = function; action->object = object; MB_GIVE( &InterruptMailbox, Action_s); @@ -203,7 +199,7 @@ NINT fsmKick () STK_POP(FsmStack, f, FsmThread_s, fsm_next); if (f) { Continue(f->fsm_thread); - } + } return TRUE; } @@ -233,18 +229,7 @@ STATUS fsmStart () int i; ASSERT_MPKNSS_LOCK(); - FsmStop = FALSE; -#if defined(__linux__) && !defined(__KERNEL__) - (void)threadID; - interrupts = zalloc(DEFAULT_INTERRUPT_MAILBOX_SIZE * sizeof(Action_s)); - if (interrupts == NULL) - { - return zERR_NO_MEMORY; - } - MB_INIT( &InterruptMailbox, interrupts, - &interrupts[DEFAULT_INTERRUPT_MAILBOX_SIZE]); -#else interrupts = zalloc(Config.os.sizeMailbox * sizeof(Action_s)); if (interrupts == NULL) { @@ -255,7 +240,6 @@ STATUS fsmStart () for (i = 0; i < NUM_FSM_THREADS; i++) { ZOS_StartThread(threadID, "NSS Fsm", fsmWaitForWork, 0,0,0); } -#endif /* * Start the alarm system */ diff --git a/src/nwnss/library/functionPtrs.c b/src/nwnss/library/functionPtrs.c index 43984c5..99e1646 100644 --- a/src/nwnss/library/functionPtrs.c +++ b/src/nwnss/library/functionPtrs.c @@ -37,12 +37,20 @@ | need to make sure the function pointer is set before using. | if (functionPtr) functionPtr(arg1); +-------------------------------------------------------------------------*/ +#include + #include #include #include void (*Ptr_lsa_invalidate_dentry)(LSAInvalidateDentry_s *lsaInv); +EXPORT_SYMBOL(Ptr_lsa_invalidate_dentry); void (*Ptr_lsa_invalidate_vol)(VolumeID_t *volID); +EXPORT_SYMBOL(Ptr_lsa_invalidate_vol); void (*Ptr_lsa_noatime)(VolumeID_t *volID, BOOL on); +EXPORT_SYMBOL(Ptr_lsa_noatime); NINT (*Ptr_lsa_get_vol_namespace)(VolumeID_t *volID); +EXPORT_SYMBOL(Ptr_lsa_get_vol_namespace); struct inode *(*Ptr_lsa_get_inode)(VolumeID_t *volID, Zid_t zid); +EXPORT_SYMBOL(Ptr_lsa_get_inode); + diff --git a/src/nwnss/library/guid/guid.c b/src/nwnss/library/guid/guid.c index ee082bd..ced2292 100644 --- a/src/nwnss/library/guid/guid.c +++ b/src/nwnss/library/guid/guid.c @@ -1,2 +1 @@ -#include -#include "guid.c.h" +#include diff --git a/src/nwnss/library/id/id.c b/src/nwnss/library/id/id.c index 2acc88e..399ff39 100644 --- a/src/nwnss/library/id/id.c +++ b/src/nwnss/library/id/id.c @@ -34,11 +34,12 @@ | This module is used to: | This contains routines used when changing NDS IDs. +-------------------------------------------------------------------------*/ +#include #include -#include -#include -#include +#include "comnAuthorize.h" +#include "id.h" +#include "guid.h" /* * Routines for supporting a simple set of hash functions @@ -157,7 +158,7 @@ UserID_t findSmallestId (UserID_t *array, LONG *count) NINT i, index = 0; UserID_t retId = array[0]; - if (*count == 0) + if (*count == 0) { return zINVALID_USERID; } @@ -176,3 +177,4 @@ UserID_t findSmallestId (UserID_t *array, LONG *count) return retId; } + diff --git a/include/nwnss/library/intlatch.h b/src/nwnss/library/intlatch.h similarity index 98% rename from include/nwnss/library/intlatch.h rename to src/nwnss/library/intlatch.h index 423020b..fe092b2 100644 --- a/include/nwnss/library/intlatch.h +++ b/src/nwnss/library/intlatch.h @@ -44,7 +44,7 @@ extern "C" { #endif #ifndef _LATCH_H_ -#include +#include #endif /*------------------------------------------------------------------------- diff --git a/src/nwnss/library/latch/intlatch.c b/src/nwnss/library/latch/intlatch.c index 8cc5085..1c0b37a 100644 --- a/src/nwnss/library/latch/intlatch.c +++ b/src/nwnss/library/latch/intlatch.c @@ -36,8 +36,8 @@ | used by anthing but LIBRARY routines. They are here to support | debug OUTPUT so that the real LATCH code can do debug output. +-------------------------------------------------------------------------*/ -#include -#include +#include +#include "schedule.h" /*------------------------------------------------------------------------- * This structure is used to keep track of the threads waiting on a given @@ -127,3 +127,4 @@ void LB__internalUnXLatch( MPKNSS_UNLOCK(); } } + diff --git a/src/nwnss/library/latch/latch.c b/src/nwnss/library/latch/latch.c index 9a5a2c2..7a83afd 100644 --- a/src/nwnss/library/latch/latch.c +++ b/src/nwnss/library/latch/latch.c @@ -34,19 +34,26 @@ | This module is used to: | NSS Library source that supports latches +-------------------------------------------------------------------------*/ -#include /* Netware Includes */ -#include +#include "procdefs.h" /* Netware Includes */ +#include #include #include #include +#ifdef __linux__ +#if zLINUX_2_6 +#include +#else +#include +#endif +#endif -#include -#include -#include -#include -#include +#include "fsm.h" +#include "latch.h" +#include "schedule.h" +#include "histogram.h" +#include "pssDebug.h" /* Pre-declare the following structure(s) */ struct PCLSwitchDef_s; @@ -120,12 +127,12 @@ extern void GetClosestSymbol(BYTE *buffer, LONG address); /************************************************************************** - * + * ***************************************************************************/ Client_s *latchMoveToCount( - DQhead_t *latchList, - NINT linkMode, - int startEntry) + DQhead_t *latchList, + NINT linkMode, + int startEntry) { DQlink_t *next; NINT count = 0; @@ -200,8 +207,8 @@ void dumpLatchList( numLatches = 0; currentEntry = startEntry; lastEntryOnPage = startEntry + maxEntriesPerPage; - for (currentEntry = startEntry; - currentEntry < (lastEntryOnPage); + for (currentEntry = startEntry; + currentEntry < (lastEntryOnPage); currentEntry++) { if (client != NULL) @@ -316,7 +323,7 @@ newKey: break; case CURSOR_END_KEY: startEntry = (total <= (maxEntriesPerPage - 1)) ? - 1 : total - (maxEntriesPerPage - 1); + 1 : total - (maxEntriesPerPage - 1); client = latchMoveToCount(latchList, linkMode, startEntry); break; case CURSOR_PUP_KEY: @@ -336,20 +343,20 @@ newKey: goto newKey; } startEntry = (startEntry+(2*maxEntriesPerPage)-1) >= total ? - total - (maxEntriesPerPage - 1) : + total - (maxEntriesPerPage - 1) : startEntry + maxEntriesPerPage; client = latchMoveToCount(latchList, linkMode, startEntry); break; default: OutputToScreen(screen, MSGNot("\a")); goto newKey; - } + } OutputToScreenWithAttribute(screen, LGREEN, MSGNot("\n")); } } /************************************************************************** - * + * ***************************************************************************/ void DBGL_DumpLatches( struct ScreenStruct *screen, @@ -396,15 +403,15 @@ void DBGL_DumpLatches( ++NSS_DebugLatchCallerDisplay; break; default: - OutputToScreen(screen, MSGNot("Illegal command processed by " "NSS" + OutputToScreen(screen, MSGNot("Illegal command processed by " "NSS" ". Use '=h' to see a list of legal commands.\n")); - } + } } #endif // #ifndef __linux__ // LINUX_Debugger /************************************************************************** - * + * ***************************************************************************/ void clearClient (Client_s *client) { @@ -421,7 +428,7 @@ void clearClient (Client_s *client) } /************************************************************************** - * + * ***************************************************************************/ void setClient (Client_s *client, FsmLite_s *fsm) { @@ -435,7 +442,7 @@ void setClient (Client_s *client, FsmLite_s *fsm) } /************************************************************************** - * + * ***************************************************************************/ NINT isClient (Client_s *client) { @@ -567,7 +574,7 @@ void getMoreLatchClientsWithMPKLock () } /************************************************************************** - * + * ***************************************************************************/ void latchHold (Latch_s *latch, FsmLite_s *fsm, char *whence) { @@ -581,7 +588,7 @@ LDBG_INC(hold); { return; /* We'll try to go on but this may propogate more errors */ } - DQ_ENQ(&DBGL_LatchHolder[((ADDR)latch >> 2) & LATCH_HASH_MASK], + DQ_ENQ(&DBGL_LatchHolder[((ADDR)latch >> 2) & LATCH_HASH_MASK], client, typeLink); DQ_ENQ(&DBGL_LatchAll, client, allLink); setClient(client, fsm); @@ -592,7 +599,7 @@ LDBG_INC(hold); client->type = HOLDER; } /************************************************************************** - * + * ***************************************************************************/ void latchWait (Latch_s *latch, FsmLite_s *fsm, char *whence) { @@ -605,7 +612,7 @@ LDBG_INC(wait); { return; /* We'll try to go on but this may propogate more errors */ } - DQ_ENQ(&DBGL_LatchWaiter[((ADDR)latch >> 2) & LATCH_HASH_MASK], + DQ_ENQ(&DBGL_LatchWaiter[((ADDR)latch >> 2) & LATCH_HASH_MASK], client, typeLink); DQ_ENQ(&DBGL_LatchAll, client, allLink); setClient(client, fsm); @@ -617,7 +624,7 @@ LDBG_INC(wait); } /************************************************************************** - * + * ***************************************************************************/ void latchRelease (Latch_s *latch, char *whence) { @@ -626,7 +633,7 @@ void latchRelease (Latch_s *latch, char *whence) ASSERT_MPKNSS_LOCK(); LDBG_INC(release); - DQ_FOREACH(&DBGL_LatchHolder[((ADDR)latch >> 2) & LATCH_HASH_MASK], + DQ_FOREACH(&DBGL_LatchHolder[((ADDR)latch >> 2) & LATCH_HASH_MASK], client, Client_s, typeLink) { if ((latch == client->latch) && (isClient(client))) @@ -636,7 +643,7 @@ LDBG_INC(release); } } // ERRNULL(MSGNot("latchRelease: DBGL_LatchHolder not found")); - DQ_FOREACH(&DBGL_LatchHolder[((ADDR)latch >> 2) & LATCH_HASH_MASK], + DQ_FOREACH(&DBGL_LatchHolder[((ADDR)latch >> 2) & LATCH_HASH_MASK], client, Client_s, typeLink) { if (latch == client->latch) @@ -652,7 +659,7 @@ LDBG_INC(release); } /************************************************************************** - * + * ***************************************************************************/ void latchGrant (Latch_s *latch, void *clnt, NINT type, char *whence) { @@ -660,7 +667,7 @@ void latchGrant (Latch_s *latch, void *clnt, NINT type, char *whence) LDBG_INC(grant); ASSERT_MPKNSS_LOCK(); - DQ_FOREACH(&DBGL_LatchWaiter[((ADDR)latch >> 2) & LATCH_HASH_MASK], + DQ_FOREACH(&DBGL_LatchWaiter[((ADDR)latch >> 2) & LATCH_HASH_MASK], client, Client_s, typeLink) { if (latch == client->latch) @@ -670,7 +677,7 @@ void latchGrant (Latch_s *latch, void *clnt, NINT type, char *whence) { DQ_RMV(client, typeLink); /** Remove from waiter list **/ client->type = HOLDER; - DQ_ENQ(&DBGL_LatchHolder[((ADDR)latch >> 2) & LATCH_HASH_MASK], + DQ_ENQ(&DBGL_LatchHolder[((ADDR)latch >> 2) & LATCH_HASH_MASK], client, typeLink); return; } @@ -715,7 +722,7 @@ void DBGL_latchCleanup(void) } /************************************************************************** - * + * ***************************************************************************/ void prLatch (char *routine,Latch_s *latch) { @@ -951,9 +958,9 @@ STATUS doLatchInstDisplay ( NINT options, void *userParm) { - (void)switchDef; - (void)options; - (void)userParm; + aprintf(LGREEN, MSGNot("Delayed=%d\n"), Delayed); + prHistogram(COMN_Resource.consoleScreenID, LGREEN, &WaitHistogram); + return zOK; } @@ -1133,7 +1140,7 @@ void LBL_xSignal (Latch_s *latch WHENCE_ARG) NINT LBL_sLatch (Latch_s *latch WHENCE_ARG) { PR_LATCH_NAME(sLatch,latch); - + ASSERT_MPKNSS_LOCK(); LDBG_INC(slatch); @@ -1200,7 +1207,7 @@ NINT LBL_fsmSlatch (Latch_s *latch, FsmLite_s *fsm, voidfunc_t action WHENCE_ARG SET_FSM(latch, fsm); HOLD(latch, fsm); ASSERT_SLATCH(latch); - ((void (*)(FsmLite_s *))action)(fsm); + action(fsm); RTN_NINT(NOWAIT); } else if ((latch->count > IDLE_LATCH_STATE) @@ -1210,7 +1217,7 @@ NINT LBL_fsmSlatch (Latch_s *latch, FsmLite_s *fsm, voidfunc_t action WHENCE_ARG CLEAR_THREAD(latch); HOLD(latch, fsm); ASSERT_SLATCH(latch); - ((void (*)(FsmLite_s *))action)(fsm); + action(fsm); RTN_NINT(NOWAIT); } else @@ -1229,7 +1236,7 @@ NINT LBL_xLatch (Latch_s *latch WHENCE_ARG) ASSERT_MPKNSS_LOCK(); PR_LATCH_NAME(xLatch,latch); LDBG_INC(xlatch); - + if (latch->count == IDLE_LATCH_STATE) { HOLD(latch, NULL); @@ -1293,7 +1300,7 @@ NINT LBL_fsmXlatch (Latch_s *latch, FsmLite_s *fsm, voidfunc_t action WHENCE_ARG HOLD(latch, fsm); latch->count = X_LATCH_STATE; SET_FSM(latch, fsm); - ((void (*)(FsmLite_s *))action)(fsm); + action(fsm); RTN_NINT(NOWAIT); } else @@ -1312,7 +1319,7 @@ NINT LBL_upLatch (Latch_s *latch WHENCE_ARG) PR_LATCH_NAME(upLatch,latch); ASSERT_SLATCH(latch); ASSERT_MPKNSS_LOCK(); - + --latch->count; RELEASE(latch); LDBG_INC(unlatch); @@ -1392,7 +1399,7 @@ NINT LBL_fsmUpLatch (Latch_s *latch, FsmLite_s *fsm, voidfunc_t action WHENCE_AR latch->count = X_LATCH_STATE; HOLD(latch, fsm); SET_FSM(latch, fsm); - ((void (*)(FsmLite_s *))action)(fsm); + action(fsm); RTN_NINT(NOWAIT); } else @@ -1415,7 +1422,7 @@ NINT LBL_xBarrier (Latch_s *latch WHENCE_ARG) ASSERT_MPKNSS_LOCK(); PR_LATCH_NAME(xBarrier,latch); LDBG_INC(xlatch); - + if (latch->count == IDLE_LATCH_STATE) { SET_THREAD(latch); @@ -1631,7 +1638,7 @@ void LBL_grab (Latch_s *latch, SNINT count WHENCE_ARG) { ASSERT_MPKNSS_LOCK(); PR_LATCH_NAME(grab,latch); - + if (count > latch->count) { LBL_cntWait(latch, count WHENCE_PASS); @@ -1682,7 +1689,7 @@ void LBL_fsmGrab ( LDBG_CNT(grab, count); latch->count -= count; HOLD(latch, NULL); - ((void (*)(FsmLite_s *))action)(fsm); + action(fsm); } RTN_VOID(); } @@ -1756,7 +1763,7 @@ NINT NSS_StoreCallers (void **buffer, NINT bufferCount, SNINT skipCount) sfEBP = *(((void* **)&buffer) - 2); while ( (frameCount-skipCount) < (SNINT)bufferCount ) { /* Validate that we can get the next EBP and return address */ - if (ValidateAddressRangePresent(sfEBP, 2*(sizeof( void * )), + if (ValidateAddressRangePresent(sfEBP, 2*(sizeof( void * )), MMU_SUPERVISOR_READ) == MMU_ERROR) { break; @@ -1772,7 +1779,7 @@ NINT NSS_StoreCallers (void **buffer, NINT bufferCount, SNINT skipCount) sfEBP = (void **)*sfEBP; /* Do some simple verification of new address * 1) Stack Frame should be > than last Stack Frame - * 2) Stack Frame should not be too much higher than last + * 2) Stack Frame should not be too much higher than last * stack frame. This is subjective because a * routine can use a lot of stack, but in NSS we * do not. A proper test would be to check against @@ -1854,3 +1861,4 @@ NINT Latch_Waiter() return 0; } #endif + diff --git a/src/nwnss/library/libraryLKM.c b/src/nwnss/library/libraryLKM.c new file mode 100644 index 0000000..3af382d --- /dev/null +++ b/src/nwnss/library/libraryLKM.c @@ -0,0 +1,97 @@ +/**************************************************************************** + | + | (C) Copyright 2004 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NSS Linux initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2007-02-16 01:48:03 +0530 (Fri, 16 Feb 2007) $ + | + | $RCSfile$ + | $Revision: 1867 $ + | + |--------------------------------------------------------------------------- + | This module is used to: !!!Linux specific file!!! + | Init functions for library + | + +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +MODULE_AUTHOR("Novell, Inc."); +MODULE_DESCRIPTION("library"); +MODULE_LICENSE("GPL v2"); + +void __cyg_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void __cyg_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); + + +void __cyg_profile_func_enter (void *this_fn, void *call_site) +{ + nss_profile_func_enter(this_fn, call_site); + return; +} + +void __cyg_profile_func_exit (void *this_fn, void *call_site) +{ + nss_profile_func_exit(this_fn, call_site); + return; +} + +static struct miscdevice nss_device = { + MISC_DYNAMIC_MINOR, "nsscmd", &fops_nssui +}; + +int lib_init_module(void) +{ + /* View printk output with dmesg in a terminal */ +//printk(KERN_ALERT"VPRINT: init spin lock consoleLock=%d\n", consoleLock.lock); +// spin_lock_init(&consoleLock); + sema_init(&consoleSema, 1); +//printk(KERN_ALERT"VPRINT: finished init spin lock consoleLock=%d\n", consoleLock.lock); + misc_register(&nss_device); //register a misc char device Maj=10,Min=170 + NSS_UI_CreateProcEntries(); + + printk(KERN_INFO "library loaded\n"); + return(0); +} + +void lib_cleanup_module(void) +{ + NSS_UI_RemoveProcEntries(); + misc_deregister(&nss_device); + printk(KERN_INFO "library un-loaded\n"); +} + +module_init(lib_init_module); +module_exit(lib_cleanup_module); diff --git a/src/nwnss/library/libraryModules.mk b/src/nwnss/library/libraryModules.mk new file mode 100644 index 0000000..cec2eb3 --- /dev/null +++ b/src/nwnss/library/libraryModules.mk @@ -0,0 +1,494 @@ +############################################################################## +# +# (C) Copyright 2003 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +########################################################################### +# This defines what MODULES are being built for this LIBRARY +# +# $Author: bbhanuprakash $ +# $Date: 2008-03-04 15:24:09 +0530 (Tue, 04 Mar 2008) $ +# +# $RCSfile$ +# $Revision: 2291 $ +# +########################################################################### +MODULE_VERSION=15 + +TMPSUBSCRIPT:=/tmp/$${USER}.library.$${PPID} + +#-------------------------------------------------------------------------- +# If the version number is not defined here, the general product version +# number will be used (defined in bldVersion.bld) +# +# major version 1 to 99 +# minor version 1 to 99 +# sub version 1 to 26 +#-------------------------------------------------------------------------- +#MAJOR_VERSION= +#MINOR_VERSION= +#SUB_VERSION= + +#-------------------------------------------------------------------------- +# Build OPTIONS +#-------------------------------------------------------------------------- +BUILD_WITH_KERNEL_FLAGS=1 + +#set to 0 if you are NOT using source code control +IS_USING_SOURCE_CONTROL=1 + +#Set to ONE if you want the linked files to be copied to the SDK/BIN directory. +COPY_TO_SDK_BIN=1 + + #set to ONE if you only want to copy the OPTIMIZED version to SDK/BIN. + COPY_OPTIMIZED_ONLY=0 + +#Set this to ONE if you are building a NETWARE version independent NLM +#(not NETWARE version specific) +NETWARE_VERSION_INDEPENDENT=1 + + #if ONE include the NETWARE .H files in the compiler search paths. + USE_NETWARE_INCLUDES=1 + + #if ONE include the NETWARE import file at LINK time + USE_NETWARE_IMPORTS=1 + +#If ONE IMPORT the LIBNSS APIs and include in the search path SDK/LIBRARY +#and SDK/PUBLIC +IMPORT_INDEPENDENT_LIBNSS=1 + +#If ONE include in the search path SDK/LIBRARY and SDK/PUBLIC +USE_LIBNSS_INCLUDES=1 + +#If ONE then LINK with the NSS library and include all of the NSS library +#directories in the compiler search paths. This includes the SDK/PUBLIC, +#SDK/INCLUDE, SDK/INTERNAL, LIBRARY/SRC directories. +LINK_WITH_NSSLIB=0 + +#if ONE then IMPORT the NSS library and COMN layer APIS and include the +#SDK/PUBLIC directory in the compiler search paths. +IMPORT_NSSLIB=1 + + #If ONE and (LINK_WITH_NSSLIB==1 or IMPORT_NSSLIB==1) then do the same + #operation to the NSSLIB area you are doing to the local area. + CHECK_NSSLIB=0 + + #If ONE and (CHECK_NSSLIB==1) then we will clean the NSSLIB area when we + #clean the local area. + CLEAN_NSSLIB=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INCLUDE directory in + #the compiler search paths + USE_NSS_SDK_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/COMNSA directory in + #the compiler search paths + USE_NSS_SDK_COMNSA_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INTERNAL directory in + #the compiler search paths + USE_NSS_SDK_INTERNAL_INCLUDES=1 + + +#if ONE then do NOT import the NSS COMMON layer APIs +DONT_IMPORT_COMMON_LAYER=1 + +#if ONE, compile and link with the NETWARE sdk environment. +USE_NETWARE_SDK=1 + +#if ONE, include DS headers. +USE_NDS_INCLUDES=1 + +#if ONE, do LANGUAGE ENABLING processing +DO_LANGUAGE_ENABLING=1 + +#Set to null (i.e. no value) to not add XDC data to the NLM. For most +#NetWare 5.0 NLMs, the value should be -u. +MOAB_XDC_TOOL_OPTION=-n + +#************************************************************************** +# Global NAME and DIRECTORY definitions +#************************************************************************** +SOURCE_DIRECTORIES=\ + debug \ + id \ + eDir \ + fsm \ + guid \ + latch \ + linux \ + misc \ + os \ + parse \ + stdio \ + stdlib \ + unicode \ + utc \ + wio + +# tstlib\ + +#************************************************************************** +# Source Modules for NSS Library (.C .386) +#************************************************************************** +DEBUG_SRC=\ + debug/assert.c \ + debug/warn.c \ + debug/dbginit.c \ + debug/dbgerror.c \ + debug/dbgfatal.c \ + debug/enterDebug.c \ + debug/DebugPrintf.c \ + debug/DebugHexDump.c \ + debug/ncpTrace.c \ + debug/otherErrorTables.c \ + debug/snp.c \ + debug/dfi.c \ + debug/sdNSS.c \ + debug/sdBasic.c \ + debug/pssDebug.c + +ID_SRC=\ + id/id.c + +EDIR_SRC=\ + eDir/getDSGuid.c \ + eDir/parseDSObjectName.c + +FSM_SRC=\ + fsm/fsmnw.c + +GUID_SRC=\ + guid/guid.c + +LATCH_SRC=\ + latch/intlatch.c \ + latch/latch.c + +MISC_SRC=\ + misc/displayVersion.c \ + misc/format.c \ + misc/GetInstLen.c \ + misc/histogram.c \ + misc/lbVolume.c \ + misc/nssErrorTable.c \ + misc/NW_NCPFuncBoundaryError.c \ + misc/NW_NCPLengthError.c \ + misc/NW_NCPSubFuncLengthError.c \ + misc/NW_WriteBranchTableEntry.c \ + misc/sysimp.c \ + misc/register.c \ + misc/xmlNSS2.c + +OS_SRC=\ + os/alarm.c \ + os/config.c \ + os/crthread.c \ + os/delay.c \ + os/inst.c \ + os/mailbox.c \ + os/pssmpk.c \ + os/snooze.c \ + os/worktodo.c \ + os/ZOS_IsNLMLoaded.c + +LINUX_SRC=\ + linux/napiFormatDateAndTime.c \ + linux/napiUnitTests.c + +PARSE_SRC=\ + parse/pcmdline.c + +STDIO_SRC=\ + stdio/aprintf.c \ + stdio/errprintf.c \ + stdio/getchar.c \ + stdio/gets.c \ + stdio/printf.c \ + stdio/snprintf.c \ + stdio/sprintf.c \ + stdio/vaprintf.c \ + stdio/vprintf.c \ + stdio/vsprintf.c + +STDLIB_SRC=\ + stdlib/exit.c \ + stdlib/free.c \ + stdlib/freeForNCPReply.c \ + stdlib/freePage.c \ + stdlib/malloc.c \ + stdlib/mallocForNCPReply.c \ + stdlib/mallocPage.c \ + stdlib/mallocPageWithFlags.c \ + stdlib/realloc.c \ + stdlib/zalloc.c \ + stdlib/zallocPage.c \ + stdlib/zrealloc.c + +UNICODE_SRC=\ + unicode/ByteToUnicode.c \ + unicode/componentUnicpy.c \ + unicode/componentUnilen.c \ + unicode/getMacCodePageName.c \ + unicode/getNssUnicodeVersion.c \ + unicode/LenByteToUnicode.c \ + unicode/LenMacByteToUnicode.c \ + unicode/MacByteToUnicode.c \ + unicode/RegisterUnicodeConverter.c \ + unicode/unicat.c \ + unicode/unicmp.c \ + unicode/unicodeInit.c \ + unicode/unicodeParse.c \ + unicode/UnicodeToByte.c \ + unicode/UnicodeToMacByte.c \ + unicode/UnicodeToUntermByte.c \ + unicode/UnicodeToUntermMacByte.c \ + unicode/unicpy.c \ + unicode/uniicmp.c \ + unicode/uniicmpmac.c \ + unicode/unilen.c \ + unicode/unilwr.c \ + unicode/unimcpy.c \ + unicode/uninicmp.c \ + unicode/unitolower.c \ + unicode/unitoupper.c \ + unicode/uniupr.c \ + unicode/UnRegisterUnicodeConverter.c \ + unicode/utf_tolower.c \ + unicode/utf8ToUniChar.c \ + unicode/utf8LenToUniChar.c + +UTC_SRC=\ + utc/dos2str.c \ + utc/dost2str.c \ + utc/dosd2str.c \ + utc/dos2utc.c \ + utc/getutctime.c \ + utc/msTime2utc.c \ + utc/sec2utc.c \ + utc/str2dos.c \ + utc/str2dosd.c \ + utc/str2dost.c \ + utc/utc2dos.c \ + utc/utc2local.c \ + utc/utc2msTime.c \ + utc/utc2sec.c \ + utc/utc2str.c \ + utc/str2utc.c \ + utc/utcdata.c \ + utc/secsDiff.c + +WIO_SRC=\ + wio/wactivate.c \ + wio/waprintf.c \ + wio/wcenter.c \ + wio/wclrscr.c \ + wio/wclose.c \ + wio/wgetc.c \ + wio/wgetdim.c \ + wio/wgets.c \ + wio/wgetpos.c \ + wio/wio.c \ + wio/wlock.c \ + wio/wopen.c \ + wio/wpause.c \ + wio/wprintf.c \ + wio/wpromptYesNo.c \ + wio/wsetpos.c \ + wio/wSetStdio.c \ + wio/wsyncin.c \ + wio/wvprintf.c \ + wio/wWrapString.c \ + wio/nssUI.c \ + wio/lnxLog.c + +#-------------------------------------------------------------------------- +# Source files for LIBRARY +#------------------------------------------------------------------------- +SOURCE_FILES=\ + functionPtrs.c \ + libraryVersion.c \ + libraryLKM.c \ + ${DEBUG_SRC} \ + ${EDIR_SRC} \ + ${ID_SRC} \ + ${FSM_SRC} \ + ${GUID_SRC} \ + ${LATCH_SRC} \ + $(LINUX_SRC) \ + ${MISC_SRC} \ + ${OS_SRC} \ + ${PARSE_SRC} \ + ${STDIO_SRC} \ + ${STDLIB_SRC} \ + ${UNICODE_SRC} \ + ${UTC_SRC} \ + ${WIO_SRC} \ + qdiv.c \ + nssLIBRARYSym.c +ifndef OPT_ENV + SOURCE_FILES += unssLIBRARYSym.c +endif + +SOURCE_FILES_NODEBUG= + +#************************************************************************** +# Include files for LIBRARY +#************************************************************************* +INCLUDE_FILES=\ + intlatch.h \ + unicodeInit.h \ + utcData.h + +#------------------------------------------------------------------------- +# Additional source files that need to be checked out +#------------------------------------------------------------------------- +OTHER_FILES=\ + Module.supported + +#--------------------------------------------------------------------------- +# This defines what routines are being EXPORTED. You should put .IMP +# files in the "UTILITY_EXPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#--------------------------------------------------------------------------- +UTILITY_EXPORTS= + +UTILITY_EXPORTS_VIA_FILE= + +#--------------------------------------------------------------------------- +# This defines what routines are being IMPORTED. You should put .IMP +# files in the "UTILITY_IMPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#--------------------------------------------------------------------------- +UTILITY_IMPORTS= + +UTILITY_IMPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# Library definitions +# This defines additional libraries to LINK with and additional +# directories to put on out INCLUDE path. +#------------------------------------------------------------------------- +#additional libraries to link with +EXTRA_LIBRARIES= +EXTRA_STATIC_LIBRARIES= +EXTRA_DYNAMIC_LIBRARIES= +# This is done when USE_NETWARE_SDK is set to 1 +#EXTRA_LIBRARY_INCLPATH=${NWSDK_SRCHPATH} +EXTRA_LIBRARY_INCLPATH= + +#------------------------------------------------------------------------- +# Include path +# This defines additional include path to compile with +#------------------------------------------------------------------------- +#additional include path +EXTRA_INCLUDE_PATH=\ + ${BASEDIR}/public_core/sharedsrc \ + +#------------------------------------------------------------------------- +# Additional C and ASSEMBLY options to use +#------------------------------------------------------------------------- +EXTRA_C_OPTIONS= +EXTRA_ASM_OPTIONS= +EXTRA_LINK_OPTIONS= + +#--------------------------------------------------------------------------- +# Additional module attributes +#--------------------------------------------------------------------------- +MODULE_DESCRIPTION='NSS API Library' +MODULE_ADDITIONAL_COPYRIGHT= +MODULE_OPTIONS= +MODULE_DEPENDENCIES= +MODULE_TYPE= +MODULE_NAME=nsslibrary +MODULE_EXTENSION= +MODULE_START_ROUTINE= +MODULE_EXIT_ROUTINE= +#set to 1 if you want the optimized NLM to be packed +MODULE_PACK_NLM=1 + + +#========================================================================= +#========================================================================= +# LOCAL BUILD RULES +#========================================================================= +#========================================================================= + +#------------------------------------------------------------------------- +# Default BUILD rule +#------------------------------------------------------------------------- +DEFAULT: DEFAULT_BUILD + +#------------------------------------------------------------------------- +# Additional rules +#------------------------------------------------------------------------- +#BUILD_GREENRIVER_OPT: \ +# COMPILE_OPT_GREENRIVER \ +# LINK_OPT_GREENRIVER + +#BUILD_GREENRIVER_UNOPT: \ +# COMPILE_UNOPT_GREENRIVER \ +# LINK_UNOPT_GREENRIVER + +BUILD_MOAB_MP_UNOPT: \ + COMPILE_UNOPT_MP_MOAB \ + LINK_UNOPT_MP_MOAB + +BUILD_MOAB_MP_OPT: \ + COMPILE_OPT_MP_MOAB \ + LINK_OPT_MP_MOAB + + +BUILD_MOAB_SP_UNOPT: + @echo "...This NLM does not have an UNOPTIMIZED SP specific version" + +BUILD_MOAB_SP_OPT: + @echo "...This NLM does not have an OPTIMIZED SP specific version" + + +#BUILD_MOAB_SP_UNOPT: \ +# COMPILE_UNOPT_SP_MOAB \ +# LINK_UNOPT_SP_MOAB +# +#BUILD_MOAB_SP_OPT: \ +# COMPILE_OPT_SP_MOAB \ +# LINK_OPT_SP_MOAB + +#------------------------------------------------------------------------- +# Language Enabling rules +#------------------------------------------------------------------------- +mdb: \ + DEFAULT_MDB + +umdb: \ + LOCAL_MDB + +mdbCreate: \ + DEFAULT_CREATE_MDB_FILE + +#------------------------------------------------------------------------- +# Other rules +#------------------------------------------------------------------------- +deps: DEFAULT_DEPS + +cscope: DEFAULT_CSCOPE + diff --git a/src/nwnss/library/libraryVersion.c b/src/nwnss/library/libraryVersion.c new file mode 100644 index 0000000..d5c56ec --- /dev/null +++ b/src/nwnss/library/libraryVersion.c @@ -0,0 +1,46 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (PSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Holds build number for the given product + +-------------------------------------------------------------------------*/ +#include + +VersionInformation_s LIBRARY_VersionInfo = +{ + ZMAJV, + ZMINV, + ZSUBV, + ZBLDN, + VERINFO_NO_PATENT +}; diff --git a/src/nwnss/library/linux/napiFormatDateAndTime.c b/src/nwnss/library/linux/napiFormatDateAndTime.c new file mode 100644 index 0000000..eda3880 --- /dev/null +++ b/src/nwnss/library/linux/napiFormatDateAndTime.c @@ -0,0 +1,457 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Code from NetWare (enable.c) that implements FormatDateAndTime + +-------------------------------------------------------------------------*/ + +#include + +#include +#include +#include +//#include +#include "sysimp.h" + +#include "utcData.h" +#include "napi.h" + +#include "procdefs.h" +#include "utc.h" + +#define AM_STR MSG("am", 0) +#define PM_STR MSG("pm", 0) + + +#if NSS_MSG_TAGS IS_ENABLED +# define MONTH_NAMES_FULL(idx) (NSSMessageTable[MonthNamesFullIDX[(idx)]]) +# define WEEKDAY_NAMES_FULL(idx) (NSSMessageTable[WeekdayNamesFull[(idx)]]) +#else +# define MONTH_NAMES_FULL(idx) (MonthNamesFull[(idx)]) +# define WEEKDAY_NAMES_FULL(idx) (WeekdayNamesFull[(idx)]) +#endif + + +#if NSS_MSG_TAGS IS_ENABLED + +NINT MonthNamesFullIDX[13] = + {InxMSG("000",0),InxMSG("January", 0),InxMSG("February", 0),InxMSG("March", 0), + InxMSG("April", 0),InxMSG("May", 0),InxMSG("June", 0), + InxMSG("July", 0),InxMSG("August", 0),InxMSG("September", 0), + InxMSG("October", 0),InxMSG("November", 0),InxMSG("December", 0)}; + +NINT WeekdayNamesFull[7] = + { InxMSG("Sunday", 0), InxMSG("Monday", 0), InxMSG("Tuesday", 0), + InxMSG("Wednesday", 0), InxMSG("Thursday", 0), InxMSG("Friday", 0), InxMSG("Saturday", 0) }; + +#else + +char *MonthNamesFull[13] = + {MSG("000",0),MSG("January", 0),MSG("February", 0),MSG("March", 0), + MSG("April", 0),MSG("May", 0),MSG("June", 0), + MSG("July", 0),MSG("August", 0),MSG("September", 0), + MSG("October", 0),MSG("November", 0),MSG("December", 0)}; + +char *WeekdayNamesFull[7] = + { MSG("Sunday", 0), MSG("Monday", 0), MSG("Tuesday", 0), + MSG("Wednesday", 0), MSG("Thursday", 0), MSG("Friday", 0), MSG("Saturday", 0) }; + +#endif + + + +/* + DOS Country info structure +*/ +typedef struct { + WORD dateFmt; /* Date format */ + BYTE currencySym[5]; /* Currency symbol */ + BYTE thousandSep[2]; /* Thousands separator */ + BYTE decimalSep[2]; /* Decimal separator */ + BYTE dateSep[2]; /* Date separator */ + BYTE timeSep[2]; /* Time separator */ + BYTE currencyFmt; /* Currency format */ + BYTE currencyDig; /* Significant digits in currency */ + BYTE timeFmt; /* Time format */ + LONG caseMapRoutine; /* Routine to call for case mapping */ + BYTE dataListSep[2]; /* Data list separator */ + BYTE reserved[10]; /* Reserved */ +} DOSCountryInfoStructure_s; + + + +// +// FixFixFix(__linux__) +// This is the default for USA. We need to make an attempt to +// find these values on Linux to localize the structure at +// run-time. +// +// FixFixFix(__linux__) +// The NetWare code used INWsprintf which appears to be languaged +// enabled. I.E. it supports a translator changing the order +// of %format items. I do not know if the strings in the date/time +// code below need to be translated relative to &format order. Since +// I did not want to port INWsprintf I use sprintf instead. +// +DOSCountryInfoStructure_s DOSCountryInfo = { + 0, //; Date format (default mm/dd/yy) + { '$',0,0,0,0 }, //; Currency symbol + { ',',0 }, //; Thousands separator + { '.',0 }, //; Decimal separator + { '/',0 }, //; Date separator + { ':',0 }, //; Time separator + 0, //; Currency format (default $10.00) + 2, //; Significant decimals in currency + 0, //; Time format (def 12 hour clock) + 0, //; Case map function + { 0,0 }, //; Data list separator + { 0,0,0,0,0,0,0,0,0,0 } //; Reserved +}; + + +/* + Description: Calculate the day of the week for any date after + January 1, 1968. (1/1/68 was chosen because it is + the first leap year before 1970. 1970 is important + because 1/1/1970 is the origin for UTC calculations. + + The year can be given in NetWare format where, + 0 to 79 are 2000 to 2079 and 80 to 99 are 1980 to 1999, + or passed as a year greater than 1900. + + Returns: 0 to 6 for Sunday to Saturday. +*/ + +LONG CalcDayOfWeek1968(LONG year, LONG month, LONG day) +{ + /* Assumptions: */ + /* year is 80 to 99 for 1980 to 1999, */ + /* 100 and above for years after 2000 */ + /* 0 to 79 for 1900 to 1979, or */ + /* 1900 or greater. */ + /* month is 1 to 12. */ + /* day is 1 to 31. */ + + static WORD daysToCurrentMonth[] = + { + /* Month[0] = JAN. */ + 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 + }; + + LONG daysSinceEpoch; + + if (year < 1900) + { + if (year < 80) + year += 2000; + else + year += 1900; + } + + if (year < 1968) + return 0; /* Permanent Sunday before 1968 */ +/* + * Calculate days since 12/31/67, i.e. 1/1/68 = 1, 1/2/68 = 2, etc. + * This gives the correct offset in the modulo below... + */ + daysSinceEpoch = (year - 1968) * 365; + daysSinceEpoch += (year - 1968 + 3) / 4; + + daysSinceEpoch += day + daysToCurrentMonth[month - 1]; + + if ((year % 4 == 0) && (month > 2) ) + ++daysSinceEpoch; /* We are in a leap year */ + + return (daysSinceEpoch % 7); /* Jan. 1, 1968 is Monday, which is 1 */ +} + + +/* + Description: Format a date in country format +*/ +void FormatDate( + BYTE *buffer, /* Buffer for resulting text */ + LONG year, /* Year */ + LONG month, /* Month */ + LONG day, /* Day */ + LONG flags) /* Format flags */ + +{ + LONG datePos; /* Offset in buffer where date begins */ + LONG longYear; /* Year if converted to four digits */ + + /* + If the date is unreasonable, put in a string with no date set. + Year may be 0 to 79 for 2000 to 2079 or 80 to 99 for 1980 to 1999. + Year may also be 100 to 179 for 2000 to 2079. + Year may also be given explicitly as 19xx or 20xx, for example. + Month shoulde be 1 to 12. + A cursory check of the day limits days to 1 to 31 for all months. + */ + if (((year > 179) && (year < 1900)) || + month < 1 || month > 12 || + day < 1 || day > 31 + ) + { + if (flags & (EN_USE_ALPHA_MONTH | EN_INCLUDE_WEEKDAY)) + strcpy(buffer, MSG("Date and time are not set", 0)); + else + strcpy(buffer, MSG("", 0)); + + return; + } + + /* + If we need the weekday, put that in first + */ + if (flags & EN_INCLUDE_WEEKDAY) + { + strcpy(buffer, WEEKDAY_NAMES_FULL(CalcDayOfWeek1968(year, month, day))); + strcpy(buffer + strlen(buffer), MSG(", ", 0)); + datePos = strlen(buffer); + } + else + datePos = 0; + + /* + If the year should be four digits long, convert it + */ + if ((flags & EN_USE_4_DIGIT_YEAR) && year <= 179) + { + if (year < 80) /* 0 to 79 are 2000 to 2079*/ + longYear = year + 2000; + else /* year 80 to 179 are 1980 to 2079*/ + longYear = year + 1900; + } + else + { + if (year >= 100 && year <= 179) + { + longYear = year - 100; + } + else + { + longYear = year; + } + } + + /* + Now format the date + */ + if (flags & EN_USE_ABBREV_MONTH) + { + switch (DOSCountryInfo.dateFmt) + { + case 0: /* USA Month DD, YYYY */ + sprintf(buffer + datePos, MSG("%s %d, %02d", 0), + MONTH_NAMES(month), day, longYear); + break; + + case 1: /* Europe DD Month YYYY */ + sprintf(buffer + datePos, MSG("%2d %s %02d", 0), day, + MONTH_NAMES(month), longYear); + break; + + case 2: /* Japan YYYY Month DD */ + sprintf(buffer + datePos, MSG("%02d %s %d", 0), longYear, + MONTH_NAMES(month), day); + break; + } + } + else if (flags & EN_USE_ALPHA_MONTH) + { + switch (DOSCountryInfo.dateFmt) + { + case 0: /* USA Month DD, YYYY */ + sprintf(buffer + datePos, MSG("%s %d, %02d", 0), + MONTH_NAMES_FULL(month), day, longYear); + break; + + case 1: /* Europe DD Month YYYY */ + sprintf(buffer + datePos, MSG("%2d %s %02d", 0), day, + MONTH_NAMES_FULL(month), longYear); + break; + + case 2: /* Japan YYYY Month DD */ + sprintf(buffer + datePos, MSG("%02d %s %d", 0), longYear, + MONTH_NAMES_FULL(month), day); + break; + } + } + else + { + switch (DOSCountryInfo.dateFmt) + { + case 0: /* USA MM/DD/YYYY */ + sprintf(buffer + datePos, MSG("%2d%s%02d%s%02d", 0), month, + DOSCountryInfo.dateSep, day, + DOSCountryInfo.dateSep, longYear); + break; + + case 1: /* Europe DD/MM/YYYY */ + sprintf(buffer + datePos, MSG("%2d%s%02d%s%02d", 0), day, + DOSCountryInfo.dateSep, month, + DOSCountryInfo.dateSep, longYear); + break; + + case 2: /* Japan YYYY/MM/DD */ + sprintf(buffer + datePos, MSG("%02d%s%02d%s%02d", 0), longYear, + DOSCountryInfo.dateSep, month, + DOSCountryInfo.dateSep, day); + break; + } + } +} + + +/* + Description: Format a time in country format +*/ +void FormatTime( + + BYTE *buffer, /* Buffer for resulting text */ + LONG hour, /* Hour */ + LONG minute, /* Minute */ + LONG second, /* Second */ + LONG flags) /* Format flags */ + +{ + + BYTE *ampm; /* Am/Pm string */ + + /* + If the country requires 12 hour clock, convert it + */ + if (DOSCountryInfo.timeFmt == 0) + { + if (hour < 12) + { + if (hour == 0) + hour = 12; + ampm = AM_STR; + } + else + { + if (hour != 12) + hour -= 12; + ampm = PM_STR; + } + } + else + ampm = ""; + + /* + Decide whether to include seconds + */ + if (flags & EN_INCLUDE_SECONDS) + sprintf(buffer, MSG("%2d%s%02d%s%02d %s", 0), hour, DOSCountryInfo.timeSep, + minute, DOSCountryInfo.timeSep, second, ampm); + else + sprintf(buffer, MSG("%2d%s%02d %s", 0), hour, DOSCountryInfo.timeSep, + minute, ampm); + +} + + +/* + Description: Format a date and time in country format +*/ +// Warnings - +// This code is used by NSS's XML code to produce date/time +// strings. I.E. if you change how this code formats the date/time +// you may break so XML code that parses the current format. Although +// this code would need to handle the THREE country dependent formats +// that can be outputted. +// This code is used by NSS's XML so you MUST not add characters +// to the format that would break XML. For example, do not use '<' or +// '>' or '"' or etc. +// +// Note - +// The format of Netware's date and time is not very consist. +// Hours are printed with %d in EN_USE_ABBREV_MONTH USA format. +// This means that some dates have 3 spaces between day and +// time fields while some have 2. +// +// +void FormatDateAndTime( + BYTE *buffer, /* Buffer for results */ + LONG year, /* Year */ + LONG month, /* Month */ + LONG day, /* Day */ + LONG hour, /* Hour */ + LONG minute, /* Minute */ + LONG second, /* Second */ + LONG flags) /* Format flags */ +{ + // Format the date first + FormatDate(buffer, year, month, day, flags); + // Put in two spaces + strcpy(buffer + strlen(buffer), MSG(" ", 0)); + // Put in the time + FormatTime(buffer + strlen(buffer), hour, minute, second, flags); + +} + +void GetTimeAndDateVector(BYTE *TimeDateVector) +{ +timeVector *tv; +unsigned long dos_date, dos_time, time; + + tv = (timeVector *) TimeDateVector; + time = UTC2dosTime(GetUTCTime()); + dos_date = (time >> 16) & 0x0000ffff; + dos_time = time & 0x0000ffff; + + tv->CurrentDay = dos_date & 0x1f; + tv->CurrentMonth = (dos_date >> 5) & 0xf; + tv->CurrentYear = dos_date >> 9; + tv->CurrentSecond = (dos_time & 0x1f) << 1; + tv->CurrentMinute = (dos_time >> 5) & 0x3f; + tv->CurrentHour = dos_time >> 11; + tv->CurrentWeekDay = CalcDayOfWeek1968(tv->CurrentYear, tv->CurrentMonth, tv->CurrentDay); +} + +LONG GetDOSDateAndTime() +{ + return (UTC2dosTime(GetUTCTime())); +} + + +#if __linux__ +LONG SetTimeFromVector(LONG stationNumber, BYTE *timeVector, LONG reCalcDST) +{ + // FIXME + return(0xff); +} +#endif + diff --git a/src/nwnss/library/linux/napiUnitTests.c b/src/nwnss/library/linux/napiUnitTests.c new file mode 100644 index 0000000..6d4dce2 --- /dev/null +++ b/src/nwnss/library/linux/napiUnitTests.c @@ -0,0 +1,343 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Code from NetWare (enable.c) that implements FormatDateAndTime + +-------------------------------------------------------------------------*/ + +#if !zLINUX +#error This file must only be used in the LINUX version of NSS +#endif + +#include +#include +#include +#include + +#include "utc.h" +#include "napi.h" + + +#ifdef FDAT_UNIT_TEST +// +// +// This section contains the FormatDateAndTime Unit Test +// +// +// This test will be called by nss from its startup routine +// if FDAT_UNIT_TEST is defined. Since NSS only uses FormatDateAndTime +// from UTCTime2Str the unit test only tests with how UTCTime2Str uses +// FormatDateAndTime. +// +// + +#define FDAT_INVALID_UTC_TIME ((Time_t)0) /* invalid value for UTC times*/ + +/*------------------------------------------------------------------------- + * Defines the time breakout structure + *-------------------------------------------------------------------------*/ +typedef struct FDAT_TimeBreakout { + NINT CYear; + BYTE CMonth; /* 1 = January */ + BYTE CDay; /* 1 = 1st */ + BYTE CHour; /* 0-23 */ + BYTE CMinute; /* 0-59 */ + BYTE CSecond; /* 0-59 */ +} FDAT_TimeBreakout; + + +#define FDAT_SECONDS_IN_A_MINUTE (LONG)(60) +#define FDAT_SECONDS_IN_AN_HOUR (LONG)(60 * 60) +#define FDAT_SECONDS_IN_A_DAY (LONG)( 24 * 60 * 60) +#define FDAT_SECONDS_IN_A_YEAR (LONG)(365 * FDAT_SECONDS_IN_A_DAY) +#define FDAT_SECONDS_IN_A_LEAPYEAR (LONG)(366 * FDAT_SECONDS_IN_A_DAY) +#define FDAT_SECONDS_IN_4_YEARS (LONG)((FDAT_SECONDS_IN_A_YEAR * 3) + FDAT_SECONDS_IN_A_LEAPYEAR) + +#define FDAT_INITMONTH(d) (FDAT_SECONDS_IN_A_DAY * (d)) + + +NINT FDAT_secondsAtEndOfMonth[13] = + { + (0), + FDAT_INITMONTH(31), /* January */ + FDAT_INITMONTH(31+28), /* February */ + FDAT_INITMONTH(31+28+31), /* March */ + FDAT_INITMONTH(31+28+31+30), /* April */ + FDAT_INITMONTH(31+28+31+30+31), /* May */ + FDAT_INITMONTH(31+28+31+30+31+30), /* June */ + FDAT_INITMONTH(31+28+31+30+31+30+31), /* July */ + FDAT_INITMONTH(31+28+31+30+31+30+31+31), /* August */ + FDAT_INITMONTH(31+28+31+30+31+30+31+31+30), /* September */ + FDAT_INITMONTH(31+28+31+30+31+30+31+31+30+31), /* October */ + FDAT_INITMONTH(31+28+31+30+31+30+31+31+30+31+30), /* November */ + FDAT_INITMONTH(31+28+31+30+31+30+31+31+30+31+30+31) /* December */ + }; + +/*------------------------------------------------------------------------- + * Seconds in each month (leap-year) + *-------------------------------------------------------------------------*/ +NINT FDAT_secondsAtEndOfLeapMonth[13] = + { + (0), + FDAT_INITMONTH(31), /* January */ + FDAT_INITMONTH(31+29), /* February */ + FDAT_INITMONTH(31+29+31), /* March */ + FDAT_INITMONTH(31+29+31+30), /* April */ + FDAT_INITMONTH(31+29+31+30+31), /* May */ + FDAT_INITMONTH(31+29+31+30+31+30), /* June */ + FDAT_INITMONTH(31+29+31+30+31+30+31), /* July */ + FDAT_INITMONTH(31+29+31+30+31+30+31+31), /* August */ + FDAT_INITMONTH(31+29+31+30+31+30+31+31+30), /* September */ + FDAT_INITMONTH(31+29+31+30+31+30+31+31+30+31), /* October */ + FDAT_INITMONTH(31+29+31+30+31+30+31+31+30+31+30), /* November */ + FDAT_INITMONTH(31+29+31+30+31+30+31+31+30+31+30+31) /* December */ + }; + +/************************************************************************** + * This routine takes UTC time (seconds from Jan 1, 1970) and converts + * it to a structure. + * Note that it also converts the time to the local timezone of the + * server. + ***************************************************************************/ +// TODO: Use NSS version if we stay in library. Need to change FDAT_RequiredResults +// as they are currently in UTC and will need to be in local time. +// It may be easier to save off IgnoreTimeZone and set to FALSE while UT is running. +// Should not cause an issue as NSS has not really started running. +BOOL FDAT_UTCTime2struct( + Time_t utcTime, + FDAT_TimeBreakout *time) +{ + + NINT year,month,leapYear; + NINT numLeapYears; + + if (utcTime == FDAT_INVALID_UTC_TIME) + { + return FALSE; + } + + // Unit Test does not have as did not have SynchronizedClock +// if (!IgnoreTimeZone) +// { +// /* localtime = utcTime - TZ + DST */ +// utcTime -= SynchronizedClock.timezoneOffset; +// if (inDaylightSavingTime(utcTime, (NINT)SynchronizedClock.daylightOnOff)) +// utcTime += SynchronizedClock.daylightOffset; +// } + + numLeapYears = utcTime / FDAT_SECONDS_IN_4_YEARS; + utcTime -= numLeapYears * FDAT_SECONDS_IN_4_YEARS; + + + /* first unroll the years*/ + for (year=1970+(numLeapYears<<2),leapYear=2;;leapYear = (leapYear+1) & 0x03,year++) + { + if (leapYear == 0) + { + if (utcTime >= FDAT_SECONDS_IN_A_LEAPYEAR) + { + utcTime -= FDAT_SECONDS_IN_A_LEAPYEAR; + } + else + break; + + } + else + { + if (utcTime >= FDAT_SECONDS_IN_A_YEAR) + { + utcTime -= FDAT_SECONDS_IN_A_YEAR; + } + else + break; + } + } + + if (leapYear != 0) + { + /* Not a leap year */ + for (month=1;;month++) + { +// ASSERT(month<=12); + if (utcTime < FDAT_secondsAtEndOfMonth[month]) + { + utcTime -= FDAT_secondsAtEndOfMonth[month-1]; + break; + } + } + } + else + { + /* leap year */ + for (month=1;;month++) + { +// ASSERT(month<=12); + if (utcTime < FDAT_secondsAtEndOfLeapMonth[month]) + { + utcTime -= FDAT_secondsAtEndOfLeapMonth[month-1]; + break; + } + } + } + + time->CYear = year; + time->CMonth = month; /* Month should be 1 based not zero based */ + + time->CDay = (utcTime / FDAT_SECONDS_IN_A_DAY) + 1; /* Days are 1 based also*/ + utcTime = utcTime % FDAT_SECONDS_IN_A_DAY; + + time->CHour = utcTime / FDAT_SECONDS_IN_AN_HOUR; + utcTime = utcTime % FDAT_SECONDS_IN_AN_HOUR; + + time->CMinute = utcTime / FDAT_SECONDS_IN_A_MINUTE; + utcTime = utcTime % FDAT_SECONDS_IN_A_MINUTE; + + time->CSecond = utcTime; + return TRUE; +} + +char *FDAT_UTCTime2Str( + Time_t utcTime, + char *str) +{ + FDAT_TimeBreakout time; + + if (!FDAT_UTCTime2struct(utcTime, &time)) + { + sprintf(str,MSG("Invalid UTC Time", 237)); + return str; + } + + FormatDateAndTime( + str, + time.CYear, + time.CMonth, + time.CDay, + time.CHour, + time.CMinute, + time.CSecond, + EN_INCLUDE_SECONDS | EN_USE_4_DIGIT_YEAR | EN_USE_ABBREV_MONTH); + + return str; +} + +char *FDAT_RequiredResults[] = { + "Invalid UTC Time", "Jan 24, 1971 8:40:32 am", "Feb 16, 1972 5:21:04 pm", "Mar 11, 1973 2:01:36 am", + "Apr 3, 1974 10:42:08 am", "Apr 26, 1975 7:22:40 pm", "May 19, 1976 4:03:12 am", "Jun 11, 1977 12:43:44 pm", + "Jul 4, 1978 9:24:16 pm", "Jul 28, 1979 6:04:48 am", "Aug 19, 1980 2:45:20 pm", "Sep 11, 1981 11:25:52 pm", + "Oct 5, 1982 8:06:24 am", "Oct 28, 1983 4:46:56 pm", "Nov 20, 1984 1:27:28 am", "Dec 13, 1985 10:08:00 am", + "Jan 5, 1987 6:48:32 pm", "Jan 29, 1988 3:29:04 am", "Feb 20, 1989 12:09:36 pm", "Mar 15, 1990 8:50:08 pm", + "Apr 8, 1991 5:30:40 am", "Apr 30, 1992 2:11:12 pm", "May 23, 1993 10:51:44 pm", "Jun 16, 1994 7:32:16 am", + "Jul 9, 1995 4:12:48 pm", "Aug 1, 1996 12:53:20 am", "Aug 24, 1997 9:33:52 am", "Sep 16, 1998 6:14:24 pm", + "Oct 10, 1999 2:54:56 am", "Nov 1, 2000 11:35:28 am", "Nov 24, 2001 8:16:00 pm", "Dec 18, 2002 4:56:32 am", + "Jan 10, 2004 1:37:04 pm", "Feb 1, 2005 10:17:36 pm", "Feb 25, 2006 6:58:08 am", "Mar 20, 2007 3:38:40 pm", + "Apr 12, 2008 12:19:12 am", "May 5, 2009 8:59:44 am", "May 28, 2010 5:40:16 pm", "Jun 21, 2011 2:20:48 am", + "Jul 13, 2012 11:01:20 am", "Aug 5, 2013 7:41:52 pm", "Aug 29, 2014 4:22:24 am", "Sep 21, 2015 1:02:56 pm", + "Oct 13, 2016 9:43:28 pm", "Nov 6, 2017 6:24:00 am", "Nov 29, 2018 3:04:32 pm", "Dec 22, 2019 11:45:04 pm", + "Jan 14, 2021 8:25:36 am", "Feb 6, 2022 5:06:08 pm", "Mar 2, 2023 1:46:40 am", "Mar 24, 2024 10:27:12 am", + "Apr 16, 2025 7:07:44 pm", "May 10, 2026 3:48:16 am", "Jun 2, 2027 12:28:48 pm", "Jun 24, 2028 9:09:20 pm", + "Jul 18, 2029 5:49:52 am", "Aug 10, 2030 2:30:24 pm", "Sep 2, 2031 11:10:56 pm", "Sep 25, 2032 7:51:28 am", + "Oct 18, 2033 4:32:00 pm", "Nov 11, 2034 1:12:32 am", "Dec 4, 2035 9:53:04 am", "Dec 26, 2036 6:33:36 pm", + "Jan 19, 2038 3:14:08 am", "Feb 11, 2039 11:54:40 am", "Mar 5, 2040 8:35:12 pm", "Mar 29, 2041 5:15:44 am", + "Apr 21, 2042 1:56:16 pm", "May 14, 2043 10:36:48 pm", "Jun 6, 2044 7:17:20 am", "Jun 29, 2045 3:57:52 pm", + "Jul 23, 2046 12:38:24 am", "Aug 15, 2047 9:18:56 am", "Sep 6, 2048 5:59:28 pm", "Sep 30, 2049 2:40:00 am", + "Oct 23, 2050 11:20:32 am", "Nov 15, 2051 8:01:04 pm", "Dec 8, 2052 4:41:36 am", "Dec 31, 2053 1:22:08 pm", + "Jan 23, 2055 10:02:40 pm", "Feb 16, 2056 6:43:12 am", "Mar 10, 2057 3:23:44 pm", "Apr 3, 2058 12:04:16 am", + "Apr 26, 2059 8:44:48 am", "May 18, 2060 5:25:20 pm", "Jun 11, 2061 2:05:52 am", "Jul 4, 2062 10:46:24 am", + "Jul 27, 2063 7:26:56 pm", "Aug 19, 2064 4:07:28 am", "Sep 11, 2065 12:48:00 pm", "Oct 4, 2066 9:28:32 pm", + "Oct 28, 2067 6:09:04 am", "Nov 19, 2068 2:49:36 pm", "Dec 12, 2069 11:30:08 pm", "Jan 5, 2071 8:10:40 am", + "Jan 28, 2072 4:51:12 pm", "Feb 20, 2073 1:31:44 am", "Mar 15, 2074 10:12:16 am", "Apr 7, 2075 6:52:48 pm", + "Apr 30, 2076 3:33:20 am", "May 23, 2077 12:13:52 pm", "Jun 15, 2078 8:54:24 pm", "Jul 9, 2079 5:34:56 am", + "Jul 31, 2080 2:15:28 pm", "Aug 23, 2081 10:56:00 pm", "Sep 16, 2082 7:36:32 am", "Oct 9, 2083 4:17:04 pm", + "Nov 1, 2084 12:57:36 am", "Nov 24, 2085 9:38:08 am", "Dec 17, 2086 6:18:40 pm", "Jan 10, 2088 2:59:12 am", + "Feb 1, 2089 11:39:44 am", "Feb 24, 2090 8:20:16 pm", "Mar 20, 2091 5:00:48 am", "Apr 11, 2092 1:41:20 pm", + "May 4, 2093 10:21:52 pm", "May 28, 2094 7:02:24 am", "Jun 20, 2095 3:42:56 pm", "Jul 13, 2096 12:23:28 am" +}; + + +// +// FDAT_UnitTest - +// The unit test for FormatDateAndTime. +// +// Returns - +// Number of tests that failed. +// +int FDAT_UnitTest() +{ + Time_t i; + char dateAndTimeString[256]; + int result; + int wrong = 0; + BOOL originalIgnoreTimeZone; + + printk(KERN_INFO "FDAT_UnitTest(start)\n"); + printk(KERN_INFO " This test assumes USA locale.\n"); + strcpy( &dateAndTimeString[0], KERN_INFO ); + // This is legal as long as the unit test is running + // in NSSes start up routine. + originalIgnoreTimeZone = IgnoreTimeZone; + IgnoreTimeZone = TRUE; + (void)UTCTime2Str( 0x3a000000, &dateAndTimeString[3] ); + printk( dateAndTimeString ); + printk( "\n"); + (void)UTCTime2Str( 0x3b000000, &dateAndTimeString[3] ); + printk( dateAndTimeString ); + printk( "\n"); + for ( result = 0, i = 0x0; i < 0xf0000000; i += 0x2000000, ++result ) + { + (void)UTCTime2Str( i, &dateAndTimeString[3] ); + if ( strcmp( &dateAndTimeString[3], FDAT_RequiredResults[result] ) != 0 ) + { + printk( "Got " ); + printk( &dateAndTimeString[3] ); + printk( " needed " ); + printk( FDAT_RequiredResults[result] ); + printk( "\n"); + wrong += 1; + } + } + if ( wrong == 0 ) + { + printk( KERN_INFO "FDAT_UnitTest did not detect any errors in 116 tests.\n"); + } + else + { + printk( KERN_INFO "FDAT_UnitTest failed (see above).\n"); + } + IgnoreTimeZone = originalIgnoreTimeZone; + printk( KERN_INFO "FDAT_UnitTest(end)\n"); + return( wrong ); +} + +#endif // #ifdef FDAT_UNIT_TEST + diff --git a/src/nwnss/library/misc/.cvsignore b/src/nwnss/library/misc/.cvsignore new file mode 100644 index 0000000..b995632 --- /dev/null +++ b/src/nwnss/library/misc/.cvsignore @@ -0,0 +1 @@ +nssErrorTable.c diff --git a/src/nwnss/library/misc/GetInstLen.c b/src/nwnss/library/misc/GetInstLen.c new file mode 100644 index 0000000..b56f7f8 --- /dev/null +++ b/src/nwnss/library/misc/GetInstLen.c @@ -0,0 +1,1750 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module was taken from the NetWare 386 Disassembler (UNASM.C) + | + | Ported to 'C': Mel J Oyler + | date: February 15, 1991 + | + | asm code + | written by: Drew Major + | date: August 13, 1986 + ****************************************************************************/ +#if zNETWARE +#include +#include + +/****************************************************************************/ +/* Define the structures */ + +/****************************************************************************/ +/* Define the defines */ +#define WordValue 0x08 + +#define BYTE_SIZE 0 +#define WORD_SIZE 1 +#define DWORD_SIZE 2 + +/****************************************************************************/ +/* Define the external globals */ +/****************************************************************************/ +/* Define the internal procedures */ +void rm(void); +void aImmediate(void); +void DoSIB(void); + +/****************************************************************************/ +/* Define the internal globals */ + +BYTE *startOfInstruction; /* contains address of start of instruction*/ +BYTE *currentInstruction; /* contains current address of where we are inside of instruction*/ +BYTE *ptrToInst; /* ptr to buffer that holds the instruction data*/ +BYTE operandSize, addressSize; + +BYTE wordFlag, qwordFlag, scaledFlag, unaryFlag, segmentOverrideFlag; +BYTE modeValue, rmValue, regValue; +BYTE SIBBase, SIBScaledIndex, SIBMode; + + +/****************************************************************************/ +NINT GetInstLen( + BYTE *instruction, + NINT *instType) +{ + SNINT index; + BYTE opcode, backspace, tmp, nextOpcode; + BYTE repeatFlag; + + operandSize = addressSize = repeatFlag = 1; + wordFlag = qwordFlag = scaledFlag = unaryFlag = backspace = 0; + segmentOverrideFlag = 0; + startOfInstruction = currentInstruction = instruction; + *instType = INSTTYPE_NORMAL; + + ptrToInst = currentInstruction; + + while (repeatFlag) + { + repeatFlag = 0; + + opcode = *ptrToInst; + ptrToInst++; currentInstruction++; + nextOpcode = *ptrToInst; + switch (opcode) + { + case 0x01: /* ADD r/m16, r16 */ + wordFlag = WordValue; + case 0x00: /* ADD r/m8, r8 */ + rm(); + break; + + case 0x03: /* ADD r16, r/m16 */ + wordFlag = WordValue; + case 0x02: /* ADD r8, r/m8 */ + rm(); + break; + + case 0x05: /* ADD AX, imm16 */ + wordFlag = WordValue; + case 0x04: /* ADD AL, imm8 */ + aImmediate(); + break; + + case 0x06: /* PUSH ES */ + break; + + case 0x07: /* POP ES */ + break; + + case 0x09: /* OR r/m16, r16 */ + wordFlag = WordValue; + case 0x08: /* OR r/m8, r8 */ + rm(); + break; + + case 0x0B: /* OR r16, r/m16 */ + wordFlag = WordValue; + case 0x0A: /* OR r8, r/m8 */ + rm(); + break; + + case 0x0D: /* OR AX, imm16 */ + wordFlag = WordValue; + case 0x0C: /* OR AL, imm8 */ + aImmediate(); + break; + + case 0x0E: /* PUSH CS */ + break; + + case 0x0F: + opcode = nextOpcode; + ptrToInst++; currentInstruction++; + nextOpcode = *ptrToInst; + switch (opcode) + { + case 0x00: /* Group 6 */ + /* SLDT,STR,LLDT,LTR,VERR,VERW */ + wordFlag = WordValue; + rm(); + break; + + case 0x01: /* Group 7 */ + /* SGDT,SIDT,LGDT,LIDT,SMSW,LMSW,INVLPG */ + wordFlag = WordValue; + rm(); + break; + + case 0x02: /* LAR r16,rm16 */ + wordFlag = WordValue; + rm(); + break; + + case 0x03: /* LSL r16,r/m16 */ + wordFlag = WordValue; + rm(); + break; + + case 0x06: /* CLTS */ + break; + + case 0x08: /* INVD */ + break; + + case 0x09: /* WBINVD */ + break; + + case 0x20: /* MOV reg32,CR? */ + ptrToInst++; currentInstruction++; + break; + + case 0x21: /* MOV reg32,DR? */ + ptrToInst++; currentInstruction++; + break; + + case 0x22: /* MOV CR?,reg32 */ + ptrToInst++; currentInstruction++; + break; + + case 0x23: /* MOV DR?,reg32 */ + ptrToInst++; currentInstruction++; + break; + + case 0x24: /* MOV reg32,TR? */ + ptrToInst++; currentInstruction++; + break; + + case 0x26: /* MOV TR?,reg32 */ + ptrToInst++; currentInstruction++; + break; + + case 0x30: + break; + + case 0x31: + break; + + case 0x32: + break; + + + case 0x80: /* Jcc rel16/rel32 */ + case 0x81: + case 0x82: + case 0x83: + case 0x84: + case 0x85: + case 0x86: + case 0x87: + case 0x88: + case 0x89: + case 0x8A: + case 0x8B: + case 0x8C: + case 0x8D: + case 0x8E: + case 0x8F: + zASSERT( "Hooking Jcc instruction" == NULL ); + if (operandSize) + { + ptrToInst += 4; currentInstruction += 4; + } + else + { + ptrToInst += 2; currentInstruction += 2; + } + goto DoTheJumpAids; +/* START BLOCK COMMENT +** #* MJO jump aid #/ +** break; +END BLOCK COMMENT */ + + case 0x90: /* SETcc r/m8 */ + case 0x91: + case 0x92: + case 0x93: + case 0x94: + case 0x95: + case 0x96: + case 0x97: + case 0x98: + case 0x99: + case 0x9A: + case 0x9B: + case 0x9C: + case 0x9D: + case 0x9E: + case 0x9F: + rm(); + break; + + case 0xA0: /* PUSH FS */ + break; + + case 0xA1: /* POP FS */ + break; + + case 0xA2: + break; + + case 0xA3: /* BT r/m16,r */ + wordFlag = WordValue; + rm(); + break; + + case 0xA4: /* SHLD r/m16,r16,imm8 */ + wordFlag = WordValue; + rm(); + ptrToInst++; currentInstruction++; + break; + + case 0xA5: /* SHLD r/m16,r16,CL */ + wordFlag = WordValue; + rm(); + break; + + case 0xA6: /* XBTS r16,r/m16,AX,CL */ + wordFlag = WordValue; + rm(); + break; + + case 0xA7: /* IBTS r/m16,AX,CL,r16 */ + wordFlag = WordValue; + rm(); + break; + + case 0xA8: /* PUSH GS */ + break; + + case 0xA9: /* POP GS */ + break; + + case 0xAA: + break; + + case 0xAB: /* BTS r/m16,r */ + wordFlag = WordValue; + rm(); + break; + + case 0xAC: /* SHRD r/m16,r16,imm8 */ + wordFlag = WordValue; + rm(); + ptrToInst++; currentInstruction++; + break; + + case 0xAD: /* SHRD r/m16,r16,CL */ + wordFlag = WordValue; + rm(); + break; + + case 0xAF: /* IMUL r15,r/m16 */ + wordFlag = WordValue; + rm(); + break; + + case 0xB1: /* CMPXCHG r/m16, r16 */ + wordFlag = WordValue; + case 0xB0: /* CMPXCHG r/m8, r8 */ + rm(); + break; + + case 0xB2: /* LSS r16,r/m16 */ + wordFlag = WordValue; + rm(); + break; + + case 0xB3: /* BTR r/m16,r */ + wordFlag = WordValue; + rm(); + break; + + case 0xB4: /* LFS r16,r/m16 */ + wordFlag = WordValue; + rm(); + break; + + case 0xB5: /* LGS r16,r/m16 */ + wordFlag = WordValue; + rm(); + break; + + case 0xB6: /* MOVZX r16,r/m8 */ + operandSize = 0; + unaryFlag = 1; + rm(); + break; + + case 0xB7: /* MOVZX r32,r/m16 */ + wordFlag = WordValue; + operandSize = 0; + unaryFlag = 1; + rm(); + break; + + case 0xBA: /* Group 8 */ + wordFlag = WordValue; + unaryFlag = 1; + rm(); + ptrToInst++; currentInstruction++; + break; + + case 0xBB: /* BTC r/m16,r */ + wordFlag = WordValue; + rm(); + break; + + case 0xBC: /* BSF r16,r/m16 */ + wordFlag = WordValue; + rm(); + break; + + case 0xBD: /* BSR r16,r/m16 */ + wordFlag = WordValue; + rm(); + break; + + case 0xBE: /* MOVSX r16,r/m8 */ + operandSize = 0; + unaryFlag = 1; + rm(); + break; + + case 0xBF: /* MOVSX r32,r/m8 */ + wordFlag = WordValue; + operandSize = 0; + unaryFlag = 1; + rm(); + break; + + case 0xC1: /* XADD r/m16, r16 */ + wordFlag = WordValue; + case 0xC0: /* XADD r/m8, r8 */ + rm(); + break; + + case 0xC7: /* CMPXCHG8B m64 */ + unaryFlag = 1; + wordFlag = WordValue; + qwordFlag = 1; + rm(); + break; + + case 0xC8: + case 0xC9: + case 0xCA: + case 0xCB: + case 0xCC: + case 0xCD: + case 0xCE: + case 0xCF: + goto OutputGenRegFromOpcode; + + case 0x04: /* invalid opcode */ + case 0x05: + case 0x07: + case 0x0A: + case 0x0B: + case 0x0C: + case 0x0D: + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + case 0x25: + case 0x27: + case 0x28: + case 0x29: + case 0x2A: + case 0x2B: + case 0x2C: + case 0x2D: + case 0x2E: + case 0x2F: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + case 0x38: + case 0x39: + case 0x3A: + case 0x3B: + case 0x3C: + case 0x3D: + case 0x3E: + case 0x3F: + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + case 0x4F: + case 0x50: + case 0x51: + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + case 0x58: + case 0x59: + case 0x5A: + case 0x5B: + case 0x5C: + case 0x5D: + case 0x5E: + case 0x5F: + case 0x60: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + case 0x78: + case 0x79: + case 0x7A: + case 0x7B: + case 0x7C: + case 0x7D: + case 0x7E: + case 0x7F: + case 0xAE: + case 0xB8: + case 0xB9: + case 0xC2: + case 0xC3: + case 0xC4: + case 0xC5: + case 0xC6: + case 0xD0: + case 0xD1: + case 0xD2: + case 0xD3: + case 0xD4: + case 0xD5: + case 0xD6: + case 0xD7: + case 0xD8: + case 0xD9: + case 0xDA: + case 0xDB: + case 0xDC: + case 0xDD: + case 0xDE: + case 0xDF: + case 0xE0: + case 0xE1: + case 0xE2: + case 0xE3: + case 0xE4: + case 0xE5: + case 0xE6: + case 0xE7: + case 0xE8: + case 0xE9: + case 0xEA: + case 0xEB: + case 0xEC: + case 0xED: + case 0xEE: + case 0xEF: + case 0xF0: + case 0xF1: + case 0xF2: + case 0xF3: + case 0xF4: + case 0xF5: + case 0xF6: + case 0xF7: + case 0xF8: + case 0xF9: + case 0xFA: + case 0xFB: + case 0xFC: + case 0xFD: + case 0xFE: + case 0xFF: + default: + break; + } + break; + + case 0x11: /* ADC r/m16, r16 */ + wordFlag = WordValue; + case 0x10: /* ADC r/m8, r8 */ + rm(); + break; + + case 0x13: /* ADC r16, r/m16 */ + wordFlag = WordValue; + case 0x12: /* ADC r8, r/m8 */ + rm(); + break; + + case 0x15: /* ADC AX, imm16 */ + wordFlag = WordValue; + case 0x14: /* ADC AL, imm8 */ + aImmediate(); + break; + + case 0x16: /* PUSH SS */ + break; + + case 0x17: /* POP SS */ + break; + + case 0x19: /* SBB r/m16, r16 */ + wordFlag = WordValue; + case 0x18: /* SBB r/m8, r8 */ + rm(); + break; + + case 0x1B: /* SBB r16, r/m16 */ + wordFlag = WordValue; + case 0x1A: /* SBB r8, r/m8 */ + rm(); + break; + + case 0x1D: /* SBB AX, imm16 */ + wordFlag = WordValue; + case 0x1C: /* SBB AL, imm8 */ + aImmediate(); + break; + + case 0x1E: /* PUSH DS */ + break; + + case 0x1F: + break; + + case 0x21: /* AND r/m16, r16 */ + wordFlag = WordValue; + case 0x20: /* AND r/m8, r8 */ + rm(); + break; + + case 0x23: /* AND r16, r/m16 */ + wordFlag = WordValue; + case 0x22: /* AND r8, r/m8 */ + rm(); + break; + + case 0x25: /* AND AX, imm16 */ + wordFlag = WordValue; + case 0x24: /* AND AL, imm8 */ + aImmediate(); + break; + + case 0x26: /* ES: (override) */ + repeatFlag = 1; + segmentOverrideFlag = 1; + break; + + case 0x27: /* DAA */ + break; + + case 0x29: /* SUB r/m16, r16 */ + wordFlag = WordValue; + case 0x28: /* SUB r/m8, r8 */ + rm(); + break; + + case 0x2B: /* SUB r16, r/m16 */ + wordFlag = WordValue; + case 0x2A: /* SUB r8, r/m8 */ + rm(); + break; + + case 0x2D: /* SUB AX, imm16 */ + wordFlag = WordValue; + case 0x2C: /* SUB AL, imm8 */ + aImmediate(); + break; + + case 0x2E: /* CS: (override) */ + repeatFlag = 1; + segmentOverrideFlag = 2; + break; + + case 0x2F: /* DAS */ + break; + + case 0x31: /* XOR r/m16, r16 */ + wordFlag = WordValue; + case 0x30: /* XOR r/m8, r8 */ + rm(); + break; + + case 0x33: /* XOR r16, r/m16 */ + wordFlag = WordValue; + case 0x32: /* XOR r8, r/m8 */ + rm(); + break; + + case 0x35: /* XOR AX, imm16 */ + wordFlag = WordValue; + case 0x34: /* XOR AL, imm8 */ + aImmediate(); + break; + + case 0x36: /* SS: (override) */ + repeatFlag = 1; + segmentOverrideFlag = 3; + break; + + case 0x37: /* AAA */ + break; + + case 0x39: /* CMP r/m16, r16 */ + wordFlag = WordValue; + case 0x38: /* CMP r/m8, r8 */ + rm(); + break; + + case 0x3B: /* CMP r16, r/m16 */ + wordFlag = WordValue; + case 0x3A: /* CMP r8, r/m8 */ + rm(); + break; + + case 0x3D: /* CMP AX, imm16 */ + wordFlag = WordValue; + case 0x3C: /* CMP AL, imm8 */ + aImmediate(); + break; + + case 0x3E: /* DS: (override) */ + repeatFlag = 1; + segmentOverrideFlag = 4; + break; + + case 0x3F: /* AAS */ + break; + + case 0x40: /* INC EAX */ + case 0x41: /* INC ECX */ + case 0x42: /* INC EDX */ + case 0x43: /* INC EBX */ + case 0x44: /* INC ESP */ + case 0x45: /* INC EBP */ + case 0x46: /* INC ESI */ + case 0x47: /* INC EDI */ + goto OutputGenRegFromOpcode; + + case 0x48: /* DEC EAX */ + case 0x49: /* DEC ECX */ + case 0x4A: /* DEC EDX */ + case 0x4B: /* DEC EBX */ + case 0x4C: /* DEC ESP */ + case 0x4D: /* DEC EBP */ + case 0x4E: /* DEC ESI */ + case 0x4F: /* DEC EDI */ + goto OutputGenRegFromOpcode; + + case 0x50: /* PUSH EAX */ + case 0x51: /* PUSH ECX */ + case 0x52: /* PUSH EDX */ + case 0x53: /* PUSH EBX */ + case 0x54: /* PUSH ESP */ + case 0x55: /* PUSH EBP */ + case 0x56: /* PUSH ESI */ + case 0x57: /* PUSH EDI */ + goto OutputGenRegFromOpcode; + + case 0x58: /* POP EAX */ + case 0x59: /* POP ECX */ + case 0x5A: /* POP EDX */ + case 0x5B: /* POP EBX */ + case 0x5C: /* POP ESP */ + case 0x5D: /* POP EBP */ + case 0x5E: /* POP ESI */ + case 0x5F: /* POP EDI */ + +OutputGenRegFromOpcode:; + break; + + case 0x60: + break; + + case 0x61: + break; + + /* MJO ??? */ + case 0x62: /* BOUND r32, m32&32 */ + wordFlag = WordValue; + rm(); + break; + + case 0x63: /* ARPL r/m16, r16 */ + wordFlag = WordValue; + operandSize = 0; + rm(); + break; + + case 0x64: /* FS: (override) */ + repeatFlag = 1; + segmentOverrideFlag = 5; + break; + + case 0x65: /* GS: (override) */ + repeatFlag = 1; + segmentOverrideFlag = 6; + break; + + case 0x66: /* Operand Size Toggle */ + operandSize ^= operandSize; + repeatFlag = 1; + break; + + case 0x67: /* Address Size Toggle */ + addressSize ^= addressSize; + repeatFlag = 1; + break; + + case 0x68: /* PUSH imm16/32 */ + if (operandSize) + { + ptrToInst += 4; currentInstruction += 4; + } + else + { + ptrToInst += 2; currentInstruction += 2; + } + break; + + case 0x6B: /* IMUL r16/32, r/m16/32, imm8 */ + scaledFlag = 1; + case 0x69: /* IMUL r16/32, r/m16/32, imm16/32 */ + wordFlag = WordValue; + rm(); + if (scaledFlag) + { + ptrToInst++; currentInstruction++; + } + else if (operandSize) + { + ptrToInst += 4; currentInstruction += 4; + } + else + { + ptrToInst += 2; currentInstruction += 2; + } + break; + + case 0x6A: /* PUSH imm8 */ + ptrToInst++; currentInstruction++; + break; + + case 0x6C: /* INSB */ + break; + + case 0x6D: /* INSW/INSD */ + break; + + case 0x6E: /* OUTSB */ + break; + + case 0x6F: /* OUTSW/OUTSD */ + break; + + case 0x70: /* Jcc rel8 */ + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + case 0x78: + case 0x79: + case 0x7A: + case 0x7B: + case 0x7C: + case 0x7D: + case 0x7E: + case 0x7F: + ptrToInst++; currentInstruction++; +DoTheJumpAids: + break; + + /* Immediate operations (ADD,OR,ADC,SBB,AND,SUB,XOR,CMP) */ + case 0x83: + scaledFlag = 1; + case 0x81: + wordFlag = WordValue; + case 0x80: + rm(); + if (wordFlag) + { + if (scaledFlag) + { + ptrToInst++; currentInstruction++; + } + else + { + if (operandSize) + { + ptrToInst += 4; currentInstruction += 4; + } + else + { + ptrToInst += 2; currentInstruction += 2; + } + + } + } + else + { + ptrToInst++; currentInstruction++; + } + break; + + case 0x82: /* invalid op code */ + break; + + case 0x85: /* TEST r/m16, r16 */ + wordFlag = WordValue; + case 0x84: /* TEST r/m8, r8 */ + rm(); + break; + + case 0x87: /* XCHG r/m16, r16 */ + wordFlag = WordValue; + case 0x86: /* XCHG r/m8, r8 */ + rm(); + break; + + case 0x89: /* MOV r/m16, r16 */ + wordFlag = WordValue; + case 0x88: /* MOV r/m8, r8 */ + rm(); + break; + + case 0x8B: /* MOV r16, r/m16 */ + wordFlag = WordValue; + case 0x8A: /* MOV r8, r/m8 */ + rm(); + break; + + case 0x8C: /* MOV r/m16, SegmentRegister */ + wordFlag = WordValue; + operandSize = 0; + rm(); + break; + + case 0x8D: /* LEA r16, m */ + wordFlag = WordValue; + rm(); + break; + + case 0x8E: + wordFlag = WordValue; + operandSize = 0; + rm(); + break; + + case 0x8F: /* POP m16 */ + wordFlag = WordValue; + unaryFlag = 1; + rm(); + break; + + case 0x90: /* NOP */ + break; + + case 0x91: /* XCHG EAX/AX, r32/16 */ + case 0x92: + case 0x93: + case 0x94: + case 0x95: + case 0x96: + case 0x97: + break; + + case 0x98: /* CWDE/CBW */ + break; + + case 0x99: /* CDQ/CWD */ + break; + + case 0x9A: /* CALL segment:offset */ + zASSERT( "Hooking CALL instruction" == NULL ); + if (operandSize) + { + ptrToInst += 6; currentInstruction += 6; + } + else + { + ptrToInst += 4; currentInstruction += 4; + } + break; + + case 0x9B: /* WAIT */ + break; + + case 0x9C: /* PUSHF */ + break; + + case 0x9D: /* POPF */ + break; + + case 0x9E: /* SAHF */ + break; + + case 0x9F: /* LAHF */ + break; + + case 0xA0: /* MOV AL, moff8 */ + goto MoveALOffset; + + case 0xA1: /* MOV AX, moff16 */ + wordFlag = WordValue; + +MoveALOffset:; + if (segmentOverrideFlag) + { + segmentOverrideFlag = 0; + } + if (addressSize) + { + ptrToInst += 4; currentInstruction += 4; + } + else + { + ptrToInst += 2; currentInstruction += 2; + } + break; + + case 0xA3: /* MOV moff16, AX */ + wordFlag = WordValue; + + case 0xA2: /* MOV moff8, AL */ + if (segmentOverrideFlag) + { + segmentOverrideFlag = 0; + } + if (addressSize) + { + ptrToInst += 4; currentInstruction += 4; + } + else + { + ptrToInst += 2; currentInstruction += 2; + } + break; + + case 0xA4: /* MOVSB */ + break; + + case 0xA5: /* MOVSW */ + break; + + case 0xA6: /* CMPSB */ + break; + + case 0xA7: /* CMPSW */ + break; + + case 0xA9: /* TEST AX, immediate */ + wordFlag = WordValue; + case 0xA8: /* TEST AL, immediate */ + aImmediate(); + break; + + case 0xAA: /* STOSB */ + break; + + case 0xAB: /* STOSW */ + break; + + case 0xAC: /* LODSB */ + break; + + case 0xAD: /* LODSW */ + break; + + case 0xAE: /* SCASB */ + break; + + case 0xAF: /* SCASW */ + break; + + case 0xB0: /* MOV r8, imm8 */ + case 0xB1: + case 0xB2: + case 0xB3: + case 0xB4: + case 0xB5: + case 0xB6: + case 0xB7: + ptrToInst++; currentInstruction++; + break; + + case 0xB8: /* MOV r16, imm16 */ + case 0xB9: + case 0xBA: + case 0xBB: + case 0xBC: + case 0xBD: + case 0xBE: + case 0xBF: + if (operandSize) + { + ptrToInst += 4; currentInstruction += 4; + } + else + { + ptrToInst += 2; currentInstruction += 2; + } + break; + + case 0xC1: /* logic rm/16, imm8 */ + wordFlag = WordValue; + case 0xC0: /* logic rm/8, imm8 */ + unaryFlag = 1; + rm(); + ptrToInst++; currentInstruction++; + break; + + case 0xC2: /* RET imm16 */ + ptrToInst += 2; currentInstruction += 2; + break; + + case 0xC3: /* RET */ + break; + + case 0xC4: /* LES r, r/m16 */ + wordFlag = WordValue; + rm(); + break; + + case 0xC5: /* LDS r, r/m16 */ + wordFlag = WordValue; + rm(); + break; + + case 0xC7: /* MOV r/m16, imm16 */ + wordFlag = WordValue; + case 0xC6: /* MOV r/m8, imm8 */ + rm(); + if (wordFlag) + { + if (operandSize) + { + ptrToInst += 4; currentInstruction += 4; + } + else + { + ptrToInst += 2; currentInstruction += 2; + } + } + else + { + ptrToInst++; currentInstruction++; + } + + break; + + case 0xC8: /* ENTER imm16 */ + ptrToInst += 3; currentInstruction += 3; + break; + + case 0xC9: /* LEAVE */ + break; + + case 0xCA: /* RETF imm16 */ + ptrToInst += 2; currentInstruction += 2; + break; + + case 0xCB: /* RETF */ + break; + + case 0xCC: /* INT 3 */ + break; + + case 0xCD: /* INT imm8 */ + ptrToInst++; currentInstruction++; + break; + + case 0xCE: /* INTO */ + break; + + case 0xCF: /* IRET */ + break; + + case 0xD1: /* logic rm/16, 1 */ + wordFlag = WordValue; + case 0xD0: /* logic rm/8, 1 */ + unaryFlag = 1; + rm(); + break; + + case 0xD3: /* logic rm/16, CL */ + wordFlag = WordValue; + case 0xD2: /* logic rm/8, CL */ + unaryFlag = 1; + rm(); + break; + + case 0xD4: /* AAM */ + ptrToInst++; currentInstruction++; + if (nextOpcode == 0x0A) /* we really are testing the correct opcode*/ + ; + else + goto InvalidOpcode; + break; + + case 0xD5: /* AAD */ + ptrToInst++; currentInstruction++; + if (nextOpcode == 0x0A) /* we really are testing the correct opcode*/ + ; + else + goto InvalidOpcode; + break; + + case 0xD6: /* invalid opcode */ + goto InvalidOpcode; + + case 0xD7: /* XLT */ + break; + + case 0xDC: /* Group Float1 m64-real */ + qwordFlag = 1; + case 0xD8: /* Group Float1 m32-real */ + /* FADD,FMUL,FCOM,FCOMP,FSUB,FSUBR,FDIV,FDIVR */ + rmValue = nextOpcode & 7; + regValue = (nextOpcode >> 3) & 7; + modeValue = (nextOpcode >> 6) & 3; + if (modeValue == 3) + { + ptrToInst++; currentInstruction++; + } + else + { + operandSize = 1; + wordFlag = WordValue; + unaryFlag = 1; + rm(); + } + break; + + case 0xD9: /* Group Float4 */ + rmValue = nextOpcode & 7; + regValue = (nextOpcode >> 3) & 7; + modeValue = (nextOpcode >> 6) & 3; + if (modeValue != 3) + { + if (regValue < 4) + { + operandSize = 1; + unaryFlag = 1; + } + else if (regValue == 5 || regValue == 7) + { + operandSize = 0; + unaryFlag = 1; + } + wordFlag = WordValue; + rm(); + } + else + { + ptrToInst++; currentInstruction++; + } + break; + + case 0xDE: /* Group Float2 m16-integer */ + operandSize = 0; + goto SixteenBitInteger; + + case 0xDA: /* Group Float2 m32-integer */ + /* FIADD,FIMUL,FICOM,FICOMP,FISUB,FISUBR,FIDIV,FIDIVR */ + operandSize = 1; +SixteenBitInteger:; + rmValue = nextOpcode & 7; + regValue = (nextOpcode >> 3) & 7; + modeValue = (nextOpcode >> 6) & 3; + if (modeValue != 3) + { + wordFlag = WordValue; + unaryFlag = 1; + rm(); + } + else + { + ptrToInst++; currentInstruction++; + } + break; + + case 0xDB: /* Group Float5 */ + rmValue = nextOpcode & 7; + regValue = (nextOpcode >> 3) & 7; + modeValue = (nextOpcode >> 6) & 3; + if (modeValue != 3 && (regValue == 0 || regValue == 2 || + regValue == 3 || regValue == 5 || regValue == 7)) + { + if (regValue < 4) + { + unaryFlag = 1; + operandSize = 1; + } + wordFlag = WordValue; + rm(); + } + else + { + ptrToInst++; currentInstruction++; + } + break; + + case 0xDD: /* Group Float6 */ + rmValue = nextOpcode & 7; + regValue = (nextOpcode >> 3) & 7; + modeValue = (nextOpcode >> 6) & 3; + if (modeValue != 3 && regValue != 1 && regValue != 5) + { + if (regValue < 4) + { + unaryFlag = 1; + qwordFlag = 1; + } + else if (regValue == 7) + { + unaryFlag = 1; + } + wordFlag = WordValue; + rm(); + } + else + { + ptrToInst++; currentInstruction++; + } + break; + + case 0xDF: /* Group Float8 */ + rmValue = nextOpcode & 7; + regValue = (nextOpcode >> 3) & 7; + modeValue = (nextOpcode >> 6) & 3; + if (modeValue != 3 && regValue != 1) + { + if (regValue < 4) + { + unaryFlag = 1; + operandSize = 0; + } + else if (regValue & 1) + { + unaryFlag = 1; + qwordFlag = 1; + } + wordFlag = WordValue; + rm(); + } + else + { + ptrToInst++; currentInstruction++; + } + break; + + case 0xE0: /* LOOPNE rel8 */ + ptrToInst++; currentInstruction++; + break; + + case 0xE1: /* LOOPE rel8 */ + ptrToInst++; currentInstruction++; + break; + + case 0xE2: /* LOOP rel8 */ + ptrToInst++; currentInstruction++; + break; + + case 0xE3: /* JECXZ rel8 */ + if (operandSize) + { + ptrToInst++; currentInstruction++; + } + else + { + ptrToInst++; currentInstruction++; + } + break; + + case 0xE4: /* IN AL, imm8 */ + ptrToInst++; currentInstruction++; + break; + + case 0xE5: /* IN AX, imm8 */ + ptrToInst++; currentInstruction++; + break; + + case 0xE6: /* OUT AL, imm8 */ + ptrToInst++; currentInstruction++; + break; + + case 0xE7: /* OUT AX, imm8 */ + ptrToInst++; currentInstruction++; + break; + + case 0xE8: /* CALL rel16/32 */ + if (operandSize) + { + *instType = INSTTYPE_PCRELATIVE32; + ptrToInst += 4; currentInstruction += 4; + } + else + { + *instType = INSTTYPE_PCRELATIVE16; + ptrToInst += 2; currentInstruction += 2; + } + break; + + case 0xE9: /* JMP rel16/32 */ + if (operandSize) + { + *instType = INSTTYPE_PCRELATIVE32; + ptrToInst += 4; currentInstruction += 4; + } + else + { + *instType = INSTTYPE_PCRELATIVE16; + ptrToInst += 2; currentInstruction += 2; + } + break; + + case 0xEA: /* JMP segment:offset */ + zASSERT("Hooking JMP instruction" == NULL); + if (operandSize) + { + ptrToInst += 6; currentInstruction += 6; + } + else + { + ptrToInst += 4; currentInstruction += 4; + } + break; + + case 0xEB: /* JMP rel8 */ + *instType = INSTTYPE_PCRELATIVE8; + ptrToInst++; currentInstruction++; + break; + + case 0xEC: /* IN AL,DX */ + break; + + case 0xED: /* IN AX,DX */ + break; + + case 0xEE: /* OUT DX,AL */ + break; + + case 0xEF: /* OUT DX,AX */ + break; + + case 0xF0: /* LOCK */ + repeatFlag = 1; + break; + + case 0xF1: /* invalid opcode */ + goto InvalidOpcode; + + + case 0xF2: /* REPNE */ + repeatFlag = 1; + index = 0; + while (((tmp=*(ptrToInst+index)) + >= 0x64 && + tmp <= 0x67) || + tmp == 0x26 || + tmp == 0x2E || + tmp == 0x36 || + tmp == 0x3E) + index++; + + if (tmp == 0xA6 || tmp == 0xA7 || tmp == 0xAE || tmp == 0xAF) + { + backspace = 6; + } + break; + + case 0xF3: /* REPE */ + repeatFlag = 1; + index = 0; + while (((tmp=*(ptrToInst+index)) + >= 0x64 && + tmp <= 0x67) || + tmp == 0x26 || + tmp == 0x2E || + tmp == 0x36 || + tmp == 0x3E) + index++; + if (tmp == 0xA6 || tmp == 0xA7 || tmp == 0xAE || tmp == 0xAF) + { + backspace = 5; + } + else if ((tmp >= 0x6C && tmp <= 0x6F) || tmp == 0xA4 || + tmp == 0xA5 || tmp == 0xAA || tmp == 0xAB) + { + backspace = 4; + } + break; + + case 0xF4: /* HLT */ + break; + + case 0xF5: /* CMC */ + break; + + case 0xF7: /* Unary Group 3 */ + wordFlag = WordValue; + case 0xF6: /* Unary Group 3 */ + unaryFlag = 1; + rm(); + if (regValue == 0) /* TEST rm,immediate */ + { + if (wordFlag) + { + if (operandSize) + { + ptrToInst += 4; currentInstruction += 4; + } + else + { + ptrToInst += 2; currentInstruction += 2; + } + } + else + { + ptrToInst++; currentInstruction++; + } + } + break; + + case 0xF8: /* CLC */ + break; + + case 0xF9: /* STC */ + break; + + case 0xFA: /* CLI */ + break; + + case 0xFB: /* STI */ + break; + + case 0xFC: /* CLD */ + break; + + case 0xFD: /* STD */ + break; + + case 0xFE: /* INC/DEC memory (Unary 4) */ + regValue = (nextOpcode >> 3) & 7; + unaryFlag = 1; + rm(); + break; + + case 0xFF: /* Unary group 5 */ + wordFlag = WordValue; + regValue = (nextOpcode >> 3) & 7; + modeValue = (nextOpcode >> 6) & 3; + + if ((regValue < 2) || /* INC/DEC */ + (regValue >= 6)) /* PUSH/invalid command */ + { + unaryFlag = 1; + } + rm(); + break; + +InvalidOpcode:; + default: + break; + } + } + + /**instruction = currentInstruction;*/ + return currentInstruction - startOfInstruction; +} + +/****************************************************************************/ +void rm(void) +{ + BYTE tmp; + + tmp = *ptrToInst; + regValue = (tmp >> 3) & 7; + rmValue = tmp & 7; + modeValue = (tmp >> 6) & 3; + ptrToInst++; currentInstruction++; + if (modeValue == 3) + { + ; /* register value */ + } + else + { + if (segmentOverrideFlag) + { + segmentOverrideFlag = 0; + } + if (addressSize) + { + if (modeValue == 0) + { + if (rmValue != 4) + { + if (rmValue != 5) + { + ; /* register indirect */ + } + else + { + ptrToInst += 4; currentInstruction += 4; /* memory indirect */ + } + } + else + { + tmp = *ptrToInst; + SIBBase = tmp & 7; + if (SIBBase != 5) + { + DoSIB(); + } + else + { + SIBScaledIndex = (tmp >> 3) & 7; + if (SIBScaledIndex != 4) + { + SIBMode = (tmp >> 6) & 3; + ptrToInst++; currentInstruction++; + } + else + { + ptrToInst++; currentInstruction++; + } + ptrToInst += 4; currentInstruction += 4; + } + } + } + else if (modeValue == 1) + { + if (rmValue != 4) + { + ptrToInst++; currentInstruction++; + } + else + { + DoSIB(); + ptrToInst++; currentInstruction++; + } + } + else /* (modeValue == 2) */ + { + if (rmValue != 4) + { + ; + } + else + { + DoSIB(); + } + ptrToInst += 4; currentInstruction += 4; + } + } + else /* (AddressSize == 0) */ + { + if (modeValue == 0) + { + if (rmValue != 6) + { + ; + } + else + { + ptrToInst += 2; currentInstruction += 2; + } + } + else + { + if (modeValue == 1) + { + ptrToInst++; currentInstruction++; + } + else /* (modeValue == 2) */ + { + ptrToInst += 2; currentInstruction += 2; + } + } + } + } +} + +/****************************************************************************/ +void aImmediate(void) +{ + if (wordFlag) + { + if (operandSize) + { + ptrToInst += 4; currentInstruction += 4; + } + else + { + ptrToInst += 2; currentInstruction += 2; + } + } + else + { + ptrToInst++; currentInstruction++; + } +} + +/****************************************************************************/ +void DoSIB(void) +{ + BYTE tmp; + + tmp = *ptrToInst; + SIBBase = tmp & 7; + SIBScaledIndex = (tmp >> 3) & 7; + SIBMode = (tmp >> 6) & 3; + ptrToInst++; currentInstruction++; +} + +/****************************************************************************/ +/****************************************************************************/ + +#endif // #if zNETWARE diff --git a/src/nwnss/library/misc/NW_NCPFuncBoundaryError.c b/src/nwnss/library/misc/NW_NCPFuncBoundaryError.c new file mode 100644 index 0000000..3b11874 --- /dev/null +++ b/src/nwnss/library/misc/NW_NCPFuncBoundaryError.c @@ -0,0 +1,80 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_NCP +#include /* NetWare Includes*/ +#include +#include +#include +#include "nssOSAPIs.h" +#include + +/************************************************************************** + * This is an internal NCP handling routine that reports NCP FUNCTION + * BOUNDARY errors. This returns: + * TRUE: if NCP should be go ahead and be processed. + * FALSE: if NCP should return immediatly. + ***************************************************************************/ +LONG NW_NCPFuncBoundaryError( + struct RequestPacketStructure *ncppacket, + struct ReplyProceduresStructure *RP, + LONG subfunc) +{ + LONG connectionNumber = GET_LOHI_WORD(&ncppacket->RConnectionNumber); + + (*NW_NCPBoundCheckFailed)++; + if (*NW_NCPBoundCheckFlag) + { + if (*NW_NCPBoundWarningFlag) + { + NW_StationAttemptedToUseBadPacket->nwTargetStation = connectionNumber; + ZOS_NetWareAlert(( *NW_OSHandle, NW_StationAttemptedToUseBadPacket, 3, + connectionNumber, ncppacket->RRequestCode, subfunc)); + + } + MPKNSS_UNLOCK(); + (*RP->ReplyKeepNoFragments)(ncppacket, ERR_NCP_BOUNDARY_CHECK_FAILED); + MPKNSS_LOCK(); + return FALSE; + } + if (*NW_NCPBoundWarningFlag) + { + ZOS_NetWareAlert(( *NW_OSHandle, NW_StationUsedBadPacket, 3, + connectionNumber, ncppacket->RRequestCode, subfunc)); + } + return TRUE; +} +#endif diff --git a/src/nwnss/library/misc/NW_NCPLengthError.c b/src/nwnss/library/misc/NW_NCPLengthError.c new file mode 100644 index 0000000..5659de2 --- /dev/null +++ b/src/nwnss/library/misc/NW_NCPLengthError.c @@ -0,0 +1,75 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_NCP +#include /* NetWare Includes*/ +#include +#include +#include + +#include +#include "pssmpk.h" + +/************************************************************************** + * This is an internal NCP handling routine that reports NCP subfunction + * LENGTH errors. This returns: + * TRUE: if NCP should be go ahead and be processed. + * FALSE: if NCP should return immediatly. + ***************************************************************************/ +LONG NW_NCPLengthError( + struct RequestPacketStructure *ncppacket, + struct ReplyProceduresStructure *RP, + LONG subfunc) +{ + LONG connectionNumber = GET_LOHI_WORD(&ncppacket->RConnectionNumber); + LONG func = ncppacket->RRequestCode; + + ASSERT_MPKNSS_LOCK(); + if (*NW_NCPBoundCheckFlag) + { + NW_StationAttemptedToUseBadPacket->nwTargetStation = connectionNumber; + ZOS_NetWareAlert(( *NW_OSHandle, NW_StationAttemptedToUseBadPacket, 3, + connectionNumber, func, subfunc)); + MPKNSS_UNLOCK(); + (*RP->ReplyKeepNoFragments)(ncppacket, ERR_NCP_BOUNDARY_CHECK_FAILED); + MPKNSS_LOCK(); + return FALSE; + } + ZOS_NetWareAlert(( *NW_OSHandle, NW_StationUsedBadPacket, 3, + connectionNumber, func, subfunc)); + return TRUE; +} +#endif diff --git a/src/nwnss/library/misc/NW_NCPSubFuncLengthError.c b/src/nwnss/library/misc/NW_NCPSubFuncLengthError.c new file mode 100644 index 0000000..3693d04 --- /dev/null +++ b/src/nwnss/library/misc/NW_NCPSubFuncLengthError.c @@ -0,0 +1,80 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_NCP +#include /* NetWare Includes*/ +#include +#include +#include +#include "nssOSAPIs.h" +#include + +/************************************************************************** + * This is an internal NCP handling routine that reports NCP subfunction + * LENGTH errors. This returns: + * TRUE: if NCP should be go ahead and be processed. + * FALSE: if NCP should return immediatly. + ***************************************************************************/ +LONG NW_NCPSubFuncLengthError( + struct RequestPacketStructure *ncppacket, + struct ReplyProceduresStructure *RP, + LONG subfunc) +{ + LONG connectionNumber = GET_LOHI_WORD(&ncppacket->RConnectionNumber); + ASSERT_MPKNSS_LOCK(); + + (*NW_NCPCompCheckFailed)++; + if (*NW_NCPCompCheckFlag) + { + if (*NW_NCPCompWarningFlag) + { + NW_NCPHasBadSubFunctionLength->nwTargetStation = connectionNumber; + ZOS_NetWareAlert(( *NW_OSHandle, NW_NCPHasBadSubFunctionLength, 3, + connectionNumber, ncppacket->RRequestCode, subfunc)); + } + MPKNSS_UNLOCK(); + (*RP->ReplyKeepNoFragments)(ncppacket, ERR_NCP_BOUNDARY_CHECK_FAILED); + MPKNSS_LOCK(); + return FALSE; + } + if (*NW_NCPCompWarningFlag) + { + ZOS_NetWareAlert(( *NW_OSHandle, NW_NCPUsedBadSubFunctionLength, 3, + connectionNumber, ncppacket->RRequestCode, subfunc)); + } + return TRUE; +} +#endif diff --git a/src/nwnss/library/misc/NW_WriteBranchTableEntry.c b/src/nwnss/library/misc/NW_WriteBranchTableEntry.c new file mode 100644 index 0000000..5028ec3 --- /dev/null +++ b/src/nwnss/library/misc/NW_WriteBranchTableEntry.c @@ -0,0 +1,58 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library source + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_NCP +#include "sysimp.h" +#include "nssOSAPIs.h" + +/**************************************************************************** + * This is a local copy of a routine of the same name that is in the C + * code base version of NetWare. We have put it into the library for + * other versions of the OS. + * + * This routine generate a JUMP instruction to the given branch routine + * address. + ****************************************************************************/ +void NW_WriteBranchTableEntry( + NINT instruction, + struct NW_BranchTableEntry *entry, + void *branchRoutine) +{ + ASSERT_MPKNSS_LOCK(); + entry->OpCode = instruction; + entry->Target = (LONG)branchRoutine - ((LONG)entry + 5); +} +#endif diff --git a/src/nwnss/library/misc/displayVersion.c b/src/nwnss/library/misc/displayVersion.c index 9fc7eab..cd7783f 100644 --- a/src/nwnss/library/misc/displayVersion.c +++ b/src/nwnss/library/misc/displayVersion.c @@ -34,10 +34,10 @@ | This module is used to: | NSS Library routine +-------------------------------------------------------------------------*/ -#include -#include -#include -#include +#include +#include "nssOSAPIs.h" +#include +#include /************************************************************************** * This will generate a VERSION string. This assumes the return buffer @@ -70,7 +70,7 @@ char *FormatVersionString( vi->minorVersion, subver); - return retBuffer; + return retBuffer; } /************************************************************************** diff --git a/src/nwnss/library/misc/format.c b/src/nwnss/library/misc/format.c index 9fce356..e6ebef4 100644 --- a/src/nwnss/library/misc/format.c +++ b/src/nwnss/library/misc/format.c @@ -3,20 +3,20 @@ | (C) Copyright 1995-1998 Novell, Inc. | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | @@ -46,123 +46,123 @@ * NetWare and Linux builds. */ - /* Not languaged enabled because C:NSS.LOG is meant to - * be used by support and engineering to debug problems. - */ + /* Not languaged enabled because C:NSS.LOG is meant to + * be used by support and engineering to debug problems. + */ char *NSSLOG_TypeNames[] = { - "Unknown", /* NSSLOG_TYPE_UNKNOWN */ - "NSS", /* NSSLOG_TYPE_NSS */ - "ZLSS", /* NSSLOG_TYPE_ZLSS */ - "Error", /* NSSLOG_TYPE_ERRPRINTF */ - "MSAP", /* NSSLOG_TYPE_MSAP */ - "Upgrade", /* NSSLOG_TYPE_MEDIA_UPGRADE */ - "Ownership" /* NSSLOG_TYPE_OWNERSHIP */ + "Unknown", /* NSSLOG_TYPE_UNKNOWN */ + "NSS", /* NSSLOG_TYPE_NSS */ + "ZLSS", /* NSSLOG_TYPE_ZLSS */ + "Error", /* NSSLOG_TYPE_ERRPRINTF */ + "MSAP", /* NSSLOG_TYPE_MSAP */ + "Upgrade", /* NSSLOG_TYPE_MEDIA_UPGRADE */ + "Ownership" /* NSSLOG_TYPE_OWNERSHIP */ }; extern void LB_sprintf( - char *destBuf, - const char *format, - ...); + char *destBuf, + const char *format, + ...); void formatNumber( - QUAD num, - BYTE *str) /* at least holds 27 bytes, including null terminator */ -{ - /* the biggest number for a QUAD is 18,446,744,073,709,551,615*/ - BYTE temp[30]; - BYTE *s, *t; - LONG len; - LONG j; + QUAD num, + BYTE *str) /* at least holds 27 bytes, including null terminator */ +{ + /* the biggest number for a QUAD is 18,446,744,073,709,551,615*/ + BYTE temp[30]; + BYTE *s, *t; + LONG len; + LONG j; - LB_sprintf(temp, "%Lu", num); - len = strlen(temp); - j = len % 3; - s = str; - t = temp; + LB_sprintf(temp, "%Lu", num); + len = strlen(temp); + j = len % 3; + s = str; + t = temp; - len -= j; - while (j > 0) - { - *s++ = *t++; - j--; - } + len -= j; + while (j > 0) + { + *s++ = *t++; + j--; + } + + if (len) + { + if (s != str) + { + *s++ = ','; + } - if (len) - { - if (s != str) - { - *s++ = ','; - } + while (1) + { + *s++ = *t++; + *s++ = *t++; + *s++ = *t++; - while (1) - { - *s++ = *t++; - *s++ = *t++; - *s++ = *t++; + len -= 3; + if (len > 0) + { + *s++ = ','; + continue; + } + else + { + break; + } + } + } - len -= 3; - if (len > 0) - { - *s++ = ','; - continue; - } - else - { - break; - } - } - } - - *s = 0; - return; + *s = 0; + return; } void formatTime( - LONG time, - BYTE *str) /* holds at least 25 + x bytes, including null terminator. - x is the length of string format of days */ -{ - LONG i, len; + LONG time, + BYTE *str) /* holds at least 25 + x bytes, including null terminator. + x is the length of string format of days */ +{ + LONG i, len; - /* - * In the format of: xday xhr xmin xsec - * - * 1 minute = 60 seconds - * 1 hour = 60 * 60 = 3600 seconds - * 1 day = 24 * 3600 = 86400 seconds - */ - len = 0; + /* + * In the format of: xday xhr xmin xsec + * + * 1 minute = 60 seconds + * 1 hour = 60 * 60 = 3600 seconds + * 1 day = 24 * 3600 = 86400 seconds + */ + len = 0; + + /* day */ + if (time >= 86400) + { + i = time / 86400; + LB_sprintf(&str[len], "%u day ", i); + len += strlen(&str[len]); + time %= 86400; + } - /* day */ - if (time >= 86400) - { - i = time / 86400; - LB_sprintf(&str[len], "%u day ", i); - len += strlen(&str[len]); - time %= 86400; - } + /* hour */ + if (time >= 3600) + { + i = time / 3600; + LB_sprintf(&str[len], "%u hr ", i); + len += strlen(&str[len]); + time %= 3600; + } - /* hour */ - if (time >= 3600) - { - i = time / 3600; - LB_sprintf(&str[len], "%u hr ", i); - len += strlen(&str[len]); - time %= 3600; - } + /* minute */ + if (time >= 60) + { + i = time / 60; + LB_sprintf(&str[len], "%u min ", i); + len += strlen(&str[len]); + time %= 60; + } - /* minute */ - if (time >= 60) - { - i = time / 60; - LB_sprintf(&str[len], "%u min ", i); - len += strlen(&str[len]); - time %= 60; - } - - /* seconds */ - LB_sprintf(&str[len], "%u sec", time); - - return; + /* seconds */ + LB_sprintf(&str[len], "%u sec", time); + + return; } diff --git a/src/nwnss/library/misc/histogram.c b/src/nwnss/library/misc/histogram.c index cccbb29..2e46863 100644 --- a/src/nwnss/library/misc/histogram.c +++ b/src/nwnss/library/misc/histogram.c @@ -3,20 +3,20 @@ | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | @@ -34,38 +34,21 @@ | This module is used to: +-------------------------------------------------------------------------*/ -/* - * Imported from NSS public_core/library/misc/histogram.c. - * - * The core math/registration routines are kept for NSS MPK instrumentation. - * The original screen/console command handlers are compiled as inert Linux - * userspace hooks until the NSS console/admin command layer is imported. - */ -#include -#include -#include +#include +#include +#include #include -Timer_s *CurrentTimer = NULL; +#include "histogram.h" -typedef struct RegisteredHistogram_s +Timer_s *CurrentTimer = NULL; + + +NINT zffs (NINT word) { - char *name; - BOOL *isEnabled; - Histogram_s *histogram; -} RegisteredHistogram_s; - -enum { MAX_HISTOGRAMS = 20 }; - -static RegisteredHistogram_s RegisteredHistograms[MAX_HISTOGRAMS]; -static NINT NumHistograms = 0; - -static NINT -zffs(NINT word) -{ - NINT cnt; - NINT tmp; + NINT cnt; + NINT tmp; cnt = 0; @@ -106,10 +89,9 @@ zffs(NINT word) return cnt; } -void -incHistogram(Histogram_s *histogram) +void incHistogram (Histogram_s *histogram) { - NINT level = ++histogram->currentCount; + NINT level = ++histogram->currentCount; ++histogram->totalCount; ++histogram->bucket[zffs(level)]; @@ -120,8 +102,7 @@ incHistogram(Histogram_s *histogram) } } -void -eventHistogram(Histogram_s *histogram, NINT event) +void eventHistogram (Histogram_s *histogram, NINT event) { histogram->currentCount = event; histogram->eventSum += event; @@ -134,25 +115,61 @@ eventHistogram(Histogram_s *histogram, NINT event) } } -void -prHistogram( +void prHistogram ( struct ScreenStruct *screenID, - NINT attribute, - Histogram_s *histogram) + NINT attribute, + Histogram_s *histogram) { - (void)screenID; - (void)attribute; - (void)histogram; + NINT i; + + OutputToScreenWithAttribute(screenID, attribute, + MSGNot("High water mark %u"), histogram->highWaterMark); + OutputToScreenWithAttribute(screenID, attribute, + MSGNot("\tTotal count %u\n"), histogram->totalCount); + if (histogram->eventSum != 0) + { + OutputToScreenWithAttribute(screenID, attribute, + MSGNot("Sum of events %qu"), histogram->eventSum); + if (histogram->totalCount != 0) + { + QUAD average = histogram->eventSum / histogram->totalCount; + + OutputToScreenWithAttribute(screenID, attribute, + MSGNot("\tAvg event %qu\n"), average); + } + else + { + OutputToScreenWithAttribute(screenID, attribute, MSGNot("\n")); + } + } + for (i = 0; i < BITS_PER_NINT; ++i) + { + OutputToScreenWithAttribute(screenID, attribute, + MSGNot("%2d. %10u%c"), i, histogram->bucket[i], + (i%4 == 3) ? '\n' : ' '); + } } -static RegisteredHistogram_s * -lookupHistogram(char *name) + +typedef struct RegisteredHistogram_s { - NINT i; + char *name; + BOOL *isEnabled; + Histogram_s *histogram; +} RegisteredHistogram_s; + +enum { MAX_HISTOGRAMS = 20 }; + +RegisteredHistogram_s RegisteredHistograms[MAX_HISTOGRAMS]; +NINT NumHistograms = 0; + +RegisteredHistogram_s *lookupHistogram (char *name) +{ + NINT i; for (i = 0; i < NumHistograms; ++i) { - if (strcmp(name, RegisteredHistograms[i].name) == 0) + if (stricmp(name, RegisteredHistograms[i].name) == 0) { return &RegisteredHistograms[i]; } @@ -160,83 +177,137 @@ lookupHistogram(char *name) return NULL; } -STATUS -registerHistogram( - char *name, - BOOL *isEnabled, - Histogram_s *histogram) +STATUS registerHistogram ( + char *name, + BOOL *isEnabled, + Histogram_s *histogram) { if (NumHistograms == MAX_HISTOGRAMS) { + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID, RED, + MSGNot("No room for histogram %s\n"), name); return zFAILURE; } if (lookupHistogram(name) != NULL) { + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID, RED, + MSGNot("Already registered %s\n"), name); return zFAILURE; } - RegisteredHistograms[NumHistograms].name = name; + RegisteredHistograms[NumHistograms].name = name; RegisteredHistograms[NumHistograms].isEnabled = isEnabled; RegisteredHistograms[NumHistograms].histogram = histogram; ++NumHistograms; return zOK; } -STATUS -doDisplayHistogram( +RegisteredHistogram_s *findHistogram (char *name) +{ + NINT i; + + for (i = 0; i < NumHistograms; ++i) + { + if (stricmp(name, RegisteredHistograms[i].name) == 0) + { + return &RegisteredHistograms[i]; + } + } + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID, LRED, + MSGNot("Histogram :%s: not found\n"), + name); + return NULL; +} + +STATUS doListHistograms ( struct PCLSwitchDef_s *switchDef, NINT options, void *userParm) { - (void)switchDef; - (void)options; - (void)userParm; + NINT i; + + MPKNSS_LOCK(); + + for (i = 0; i < NumHistograms; ++i) + { + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID, LGREEN, + MSGNot("%s\n"), + RegisteredHistograms[i].name); + } + MPKNSS_UNLOCK(); return zOK; } -STATUS -doDisableHistogram( +STATUS doEnableHistogram ( struct PCLSwitchDef_s *switchDef, NINT options, void *userParm) { - (void)switchDef; - (void)options; - (void)userParm; + RegisteredHistogram_s *regHist; + + MPKNSS_LOCK(); + + regHist = lookupHistogram(switchDef->ret_value); + if (regHist) + { + *regHist->isEnabled = TRUE; + bzero(regHist->histogram, sizeof(Histogram_s)); + } + MPKNSS_UNLOCK(); return zOK; } -STATUS -doClearHistogram( +STATUS doDisableHistogram ( struct PCLSwitchDef_s *switchDef, NINT options, void *userParm) { - (void)switchDef; - (void)options; - (void)userParm; + RegisteredHistogram_s *regHist; + + MPKNSS_LOCK(); + + regHist = lookupHistogram(switchDef->ret_value); + if (regHist) + { + *regHist->isEnabled = FALSE; + } + MPKNSS_UNLOCK(); return zOK; } -STATUS -doListHistograms( +STATUS doDisplayHistogram ( struct PCLSwitchDef_s *switchDef, NINT options, void *userParm) { - (void)switchDef; - (void)options; - (void)userParm; + RegisteredHistogram_s *regHist; + + MPKNSS_LOCK(); + + regHist = lookupHistogram(switchDef->ret_value); + if (regHist) + { + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID, YELLOW, + MSGNot("%s: "), regHist->name); + prHistogram(COMN_Resource.consoleScreenID, LGREEN, regHist->histogram); + } + MPKNSS_UNLOCK(); return zOK; } -STATUS -doEnableHistogram( +STATUS doClearHistogram ( struct PCLSwitchDef_s *switchDef, NINT options, void *userParm) { - (void)switchDef; - (void)options; - (void)userParm; + RegisteredHistogram_s *regHist; + + MPKNSS_LOCK(); + + regHist = lookupHistogram(switchDef->ret_value); + if (regHist) + { + bzero(regHist->histogram, sizeof(Histogram_s)); + } + MPKNSS_UNLOCK(); return zOK; } diff --git a/src/nwnss/library/misc/lbVolume.c b/src/nwnss/library/misc/lbVolume.c index 20c0005..794a340 100644 --- a/src/nwnss/library/misc/lbVolume.c +++ b/src/nwnss/library/misc/lbVolume.c @@ -77,7 +77,7 @@ STATIC unicode_t *LB_UnicodeDigit[] = { * volName="NameName", uniSize=10, mangleKey = 2 then "Nam_SV002" * volName="NameNameName", uniSize=10, mangleKey = 0 then zERR_BUFFER_TOO_SMALL * volName="Name", uniSize=8, mangleKey = 0 then zERR_BUFFER_TOO_SMALL - * + * * * Returns - * zOK on success with mangleKey and newName changed. @@ -87,7 +87,7 @@ STATIC unicode_t *LB_UnicodeDigit[] = { * characters OR smaller than the passed in name. */ -STATUS LB_VolumeNameToNewName( +STATUS LB_VolumeNameToNewName( CONST unicode_t *volName, /* Current volume name */ CONST unicode_t *postfixBase, /* Base 3 unicode length string to post fix */ NINT *mangleKey, /* (input/output)Mangle key pointer, must point to 0 on first call */ @@ -176,7 +176,7 @@ STATUS LB_VolumeNameToNewName( * characters OR smaller than the passed in name. */ -STATUS LB_VolumeNameToSnapshotName( +STATUS LB_VolumeNameToSnapshotName( CONST unicode_t *volName, /* Current volume name */ NINT *mangleKey, /* (input/output)Mangle key pointer, must point to 0 on first call */ NINT uniSize, /* Number of unicode snapName can hold */ @@ -192,7 +192,7 @@ STATUS LB_VolumeNameToSnapshotName( /* See comments for LB_VolumeNameToSnapshotName */ -STATUS LB_VolumeNameToQSName( +STATUS LB_VolumeNameToQSName( CONST unicode_t *volName, /* Current volume name */ NINT *mangleKey, /* (input/output)Mangle key pointer, must point to 0 on first call */ NINT uniSize, /* Number of unicode newName can hold */ @@ -220,7 +220,7 @@ STATUS LB_VolumeNameToQSName( * unicode characters OR smaller than the passed in name. */ -STATUS LB_VolumeNameToAutoRenameName( +STATUS LB_VolumeNameToAutoRenameName( CONST unicode_t *volName, /* Current volume name */ NINT *mangleKey, /* (input/output)Mangle key pointer, must point to 0 on first call */ NINT uniSize, /* Number of unicode AutoRename Name can hold */ @@ -248,7 +248,7 @@ STATUS LB_VolumeNameToAutoRenameName( * volName="NameName", uniSize=10, mangleKey = 2 then "N_Pool002" * volName="NameNameName", uniSize=10, mangleKey = 0 then zERR_BUFFER_TOO_SMALL * volName="Name", uniSize=8, mangleKey = 0 then zERR_BUFFER_TOO_SMALL - * + * * * Returns - * zOK on success with mangleKey and poolName changed. @@ -258,7 +258,7 @@ STATUS LB_VolumeNameToAutoRenameName( * characters OR smaller than the passed in name. */ -STATUS LB_VolumeNameToPoolName( +STATUS LB_VolumeNameToPoolName( CONST unicode_t *volName, /* Current pool name */ NINT *mangleKey, /* (input/output)Mangle key pointer, must point to 0 on first call */ NINT uniSize, /* Number of unicode poolName can hold */ @@ -351,14 +351,14 @@ STATUS LB_VolumeNameToPoolName( *** This is a list of the valid characters that can be in a volume *** name. This was taken from the NSS Menu code. ***/ -STATIC char LB_VolumeCharsValid[] = +STATIC char LB_VolumeCharsValid[] = MSGNot("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_!@#$%&()"); /*** *** This is a list of volumes that can not be renamed. ***/ -STATIC unicode_t *LB_VolumeNamesRenameNo[] = +STATIC unicode_t *LB_VolumeNamesRenameNo[] = { AVOL_PERSISTENT_ADMIN_VOLUME_UNICODE, AVOL_ADMIN_VOLUME_UNICODE, @@ -369,7 +369,7 @@ STATIC unicode_t *LB_VolumeNamesRenameNo[] = *** This is a list of reserved volume names. This was taken from the *** NSS Menu code. ***/ -STATIC char *LB_VolumeNamesReserved[] = +STATIC char *LB_VolumeNamesReserved[] = { MSGNot("NUL"), MSGNot("CON"), @@ -499,7 +499,7 @@ STATUS LB_VolumeNameValid( unicode_t *volumeName ) /* * LB_VolumeRenameOK() - - * Determines if a volume can be renamed based on the volume's + * Determines if a volume can be renamed based on the volume's * current name. Simply checks if the volume is one of the * volume names that are not allowed to be renamed. * diff --git a/src/nwnss/library/misc/register.c b/src/nwnss/library/misc/register.c index f168d83..d9ee01c 100644 --- a/src/nwnss/library/misc/register.c +++ b/src/nwnss/library/misc/register.c @@ -34,24 +34,18 @@ | This module is used to: | NSS Library source +-------------------------------------------------------------------------*/ -#include /* NetWare includes*/ -#include /* NSS Include to do conditional compilation */ +#include /* NetWare includes*/ +#include /* NSS Include to do conditional compilation */ +#include "neb.h" /* NetWare Event Bus Interface */ #include /* NSS Library includes*/ #include -#include +#include #include -#include -#include -#include -#include - -/* Linux userspace port: the NSS intmem free-list checker belongs to the - * kernel/private allocator backend. malloc.c maps allocation to libc here. */ -#ifndef LB_CHECK_FREE_LIST -#define LB_CHECK_FREE_LIST() ((void)0) -#endif +#include +#include "nssOSAPIs.h" +#include /*------------------------------------------------------------------------- * Registration structure @@ -97,7 +91,7 @@ STATIC Tag_s InternalTags[] = {MSGNot("System Call"), SystemCallSignature, &COMN_Resource.systemCallRTag ,0 }, {MSGNot(""), 0, NULL ,0 } }; -#endif +#endif /*--------------------------------------------------------------------------- * Global varaibles which point to internal netware data items @@ -134,7 +128,7 @@ extern STATUS COMN_RegisterLibraryResourceTags( /*------------------------------------------------------------------------- * Do default initialization *-------------------------------------------------------------------------*/ - LB_strmcpy(COMN_Resource.name, name, sizeof(COMN_Resource.name)); + strmcpy(COMN_Resource.name, name, sizeof(COMN_Resource.name)); COMN_Resource.stdio = NULL; #ifdef __linux__ // LINUX_ResourceTags //FixFixFix(linux) caller should be passing in HANDLE!! @@ -155,7 +149,7 @@ extern STATUS COMN_RegisterLibraryResourceTags( strcpy(string, COMN_Resource.name); strcat(string, MSGNot(" ")); strcat(string, tag->label); - ZOS_AllocateResourceTag(*tag->tag, + ZOS_AllocateResourceTag(*tag->tag, COMN_Resource.moduleHandle, string, tag->signature); @@ -190,8 +184,8 @@ STATUS COMN_RegisterLibraryOwner( VersionInformation_s *versionInfo) { ASSERT_MPKNSS_LOCK(); - srand(GetUTCTime()); - LB_strmcpy(COMN_Resource.name, name, sizeof(COMN_Resource.name)); + srand(GetUTCTime()); + strmcpy(COMN_Resource.name, name, sizeof(COMN_Resource.name)); #ifndef __linux__ // LINUX_ResourceTags COMN_Resource.moduleHandle = handle; #endif @@ -230,7 +224,7 @@ STATUS COMN_RegisterLibraryOwner( /*--------------------------------------------------------------------------- * Initialize common sub-systems *---------------------------------------------------------------------------*/ - + /*------------------------------------------------------------------------- * see if we need to create a screen *-------------------------------------------------------------------------*/ diff --git a/src/nwnss/library/misc/sysimp.c b/src/nwnss/library/misc/sysimp.c index 6862767..e1939d2 100644 --- a/src/nwnss/library/misc/sysimp.c +++ b/src/nwnss/library/misc/sysimp.c @@ -1 +1 @@ -#include +#include diff --git a/src/nwnss/library/misc/timeline.c b/src/nwnss/library/misc/timeline.c new file mode 100644 index 0000000..00644e2 --- /dev/null +++ b/src/nwnss/library/misc/timeline.c @@ -0,0 +1,131 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996, 1998 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Track a time line of incidents or events. + +-------------------------------------------------------------------------*/ +#include +#include +#include + +#if zLINUX +#include +#define WHO() current +#endif + +#if zNETWARE +extern ADDR RunningProcess; +#define WHO() ((void *)RunningProcess) +#endif + +extern QUAD GetSuperHighResolutionTimer(); +#include + +#if NSS_DEBUG IS_ENABLED + enum { MAX_INCIDENTS = 2048 }; +#else + enum { MAX_INCIDENTS = 64 }; +#endif + +typedef struct TimeLineIncident_s +{ + NINT what; + void *who; + QUAD diff; +} TimeLineIncident_s; + +TimeLineIncident_s TimeLine[MAX_INCIDENTS]; +TimeLineIncident_s *NextTimeLine = TimeLine; +QUAD LastTime; +BOOL TimeLineClear = FALSE; +SPINLOCK TimeLineLock; +BOOL TimeLineInited = FALSE; + +void addWhat ( + NINT what) /* "what" should be a number to identify the incident */ +{ + TimeLineIncident_s *incident; + QUAD time = GetSuperHighResolutionTimer(); + + if (!TimeLineInited) + { + kSpinLockInit( &TimeLineLock); + } + kSpinLock( &TimeLineLock); + if (TimeLineClear) + { + bzero(TimeLine, sizeof(TimeLine)); + TimeLineClear = FALSE; + NextTimeLine = TimeLine; + } + incident = NextTimeLine++; + if (NextTimeLine == &TimeLine[MAX_INCIDENTS]) + { + NextTimeLine = TimeLine; + } + kSpinUnlock( &TimeLineLock); + incident->what = what; + incident->who = WHO(); + incident->diff = time - LastTime; + LastTime = time; +} + +void addWho ( + NINT what, /* "what" should be a number to identify the incident */ + void *who) +{ + TimeLineIncident_s *incident; + QUAD time = GetSuperHighResolutionTimer(); + + if (!TimeLineInited) + { + kSpinLockInit( &TimeLineLock); + } + kSpinLock( &TimeLineLock); + if (TimeLineClear) + { + bzero(TimeLine, sizeof(TimeLine)); + TimeLineClear = FALSE; + NextTimeLine = TimeLine; + } + incident = NextTimeLine++; + if (NextTimeLine == &TimeLine[MAX_INCIDENTS]) + { + NextTimeLine = TimeLine; + } + kSpinUnlock( &TimeLineLock); + incident->what = what; + incident->who = who; + incident->diff = time - LastTime; + LastTime = time; +} diff --git a/src/nwnss/library/misc/xmlNSS2.c b/src/nwnss/library/misc/xmlNSS2.c index e42b767..bf00544 100644 --- a/src/nwnss/library/misc/xmlNSS2.c +++ b/src/nwnss/library/misc/xmlNSS2.c @@ -50,9 +50,6 @@ #include "zError.h" #include "guid.h" #include "xmlNSS.h" -#include -#include -#include /* @@ -155,7 +152,7 @@ STATUS XML_UTF8ToGUID( if (status == zOK) { status = LB_GUIDValidate(guid); - } + } if ( newCursor != NULL ) *newCursor = endCursor + 1; return( status ); @@ -307,7 +304,7 @@ void XML_Display( buffer[amount-1] = 0; aprintf( LGREEN, "%s \"%s\"\n", messageString, buffer ); LB_free( buffer ); - + } /* End of XML_Display() */ diff --git a/src/nwnss/library/nssLIBRARYSym.c b/src/nwnss/library/nssLIBRARYSym.c new file mode 100644 index 0000000..e384b41 --- /dev/null +++ b/src/nwnss/library/nssLIBRARYSym.c @@ -0,0 +1,402 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2007-04-18 23:26:20 +0530 (Wed, 18 Apr 2007) $ + | + | $RCSfile$ + | $Revision: 1954 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export NSS symbols to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +EXPORT_SYMBOL(checkOrSetDSTConversionResults); +EXPORT_SYMBOL(COMN_RegisterLibraryOwner); +EXPORT_SYMBOL(COMN_RegisterLibraryResourceTags); +EXPORT_SYMBOL(COMN_Resource); +EXPORT_SYMBOL(COMN_UnregisterLibraryOwner); +EXPORT_SYMBOL(Config); +EXPORT_SYMBOL(CurrentTimer); +//WRONG PLACE//EXPORT_SYMBOL(DBG_DumpSpinLock); +//WRONG PLACE//EXPORT_SYMBOL(DBG_fatal); +//WRONG PLACE//EXPORT_SYMBOL(DBG_RestoreSpinLock); +//WRONG PLACE//EXPORT_SYMBOL(DBG_SaveSpinLock); +EXPORT_SYMBOL(DBG_UTCTime2Str); +//WRONG PLACE//EXPORT_SYMBOL(DDCAuthenticateConnectionPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCCheckConsoleOperatorPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCConnectToReferralPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCContextEntryIDPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCCreateContextPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCCreateEntryPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCDuplicateContextPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCFreeContextPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCGenerateKeyPairPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCGetEffectivePrivilegesPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCGetEntryInfoPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCGetServerNamePtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCListToBufferPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCLoginPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCLogoutPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCModifyEntryPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCModifyRDNPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCNameToIDPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCPingPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCReadToBufferPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCReadToCBPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCRemoveAttributePtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCRemoveEntryPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCResolveNamePtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCSetContextBaseDNPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCSetContextEntryIDPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDCSetContextFlagsPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDSGetLocalAgentInfoPtr); +//WRONG PLACE//EXPORT_SYMBOL(DDSGetLocalEntryNamePtr); +//WRONG PLACE//EXPORT_SYMBOL(DDSLoginAsServerPtr); +EXPORT_SYMBOL(DFI_Close); +EXPORT_SYMBOL(DFI_Display); +EXPORT_SYMBOL(DFI_DisplayStructure); +EXPORT_SYMBOL(DFI_Display_Header_ARRAY); +EXPORT_SYMBOL(DFI_Display_Header_Structure); +EXPORT_SYMBOL(DFI_Display_Tail_ARRAY); +EXPORT_SYMBOL(DFI_Display_Tail_Structure); +EXPORT_SYMBOL(DFI_Open); +EXPORT_SYMBOL(DFI_NotUsed_s); +EXPORT_SYMBOL(DFI_File_s); +EXPORT_SYMBOL(DFI_Agent_s); +EXPORT_SYMBOL(DFI_SQhead_t); +EXPORT_SYMBOL(DFI_SQlink_s); +EXPORT_SYMBOL(DFI_BioReq_s); +EXPORT_SYMBOL(DFI_Buffer_s); +EXPORT_SYMBOL(DFI_DQhead_t); +EXPORT_SYMBOL(DFI_Latch_s); +EXPORT_SYMBOL(DFI_zWorkProc_s); +EXPORT_SYMBOL(DFI_OneShot_s); +EXPORT_SYMBOL(DFI_Volume_s); +EXPORT_SYMBOL(DFI_Pool_s); +EXPORT_SYMBOL(DFI_FsmLite_s); +EXPORT_SYMBOL(DisplayVersionInformation); +EXPORT_SYMBOL(DOS2utcTime); +EXPORT_SYMBOL(DOSDateTime2Str); +EXPORT_SYMBOL(DSTStartInfo); +EXPORT_SYMBOL(DSTStopInfo); +EXPORT_SYMBOL(eventHistogram); +EXPORT_SYMBOL(formatNumber); +EXPORT_SYMBOL(formatTime); +EXPORT_SYMBOL(FsmInst); +EXPORT_SYMBOL(FsmReadyQ); +EXPORT_SYMBOL(getDSTChangeRules); +EXPORT_SYMBOL(GetErrorFromNumber); +//WRONG PLACE//EXPORT_SYMBOL(GetInstLen); +EXPORT_SYMBOL(Inst); +EXPORT_SYMBOL(InterruptMailbox); + +#if LATCH_MACRO IS_ENABLED + EXPORT_SYMBOL(LBL_sSignal); + EXPORT_SYMBOL(LBL_xSignal); + EXPORT_SYMBOL(LBL_sWait); + EXPORT_SYMBOL(LBL_xWait); + EXPORT_SYMBOL(LBL_fsmSwait); + EXPORT_SYMBOL(LBL_fsmXwait); + EXPORT_SYMBOL(LBL_cntSignal); + EXPORT_SYMBOL(LBL_cntWait); + EXPORT_SYMBOL(LBL_fsmCntWait); +#endif + +EXPORT_SYMBOL(LBL_xBarrier); +EXPORT_SYMBOL(LB_ByteToUnicode); +EXPORT_SYMBOL(LB_DisplayCmdlineHelp); +//WRONG PLACE//EXPORT_SYMBOL(LB_GetNssUnicodeVersion); +EXPORT_SYMBOL(LB_GUIDFromUTF8); +EXPORT_SYMBOL(LB_GUIDGenerate); +EXPORT_SYMBOL(LB_GUIDTimeToShortVolumeName); +EXPORT_SYMBOL(LB_GUIDToString); +EXPORT_SYMBOL(LB_GUIDToVolumeName); +EXPORT_SYMBOL(LB_GUIDValidate); +//WRONG PLACE//EXPORT_SYMBOL(LB_ImportNDSPublics); +//WRONG PLACE//EXPORT_SYMBOL(LB_ImportOptionalUnixlibStuff); +EXPORT_SYMBOL(LB_InitializeSystemImports); +EXPORT_SYMBOL(LB_LenByteToUnicode); +EXPORT_SYMBOL(LB_LenMacByteToUnicode); +EXPORT_SYMBOL(LB_MacByteToUnicode); +EXPORT_SYMBOL(LB_ParseCmdline); +EXPORT_SYMBOL(LB_RegisterUnicodeConverter); +EXPORT_SYMBOL(LB_UnicodeStartup); +EXPORT_SYMBOL(LB_UnicodeShutdown); +EXPORT_SYMBOL(LB_UnicodeToByte); +EXPORT_SYMBOL(LB_UnicodeToMacByte); +EXPORT_SYMBOL(LB_UnicodeToUntermByte); +EXPORT_SYMBOL(LB_UnicodeToUntermMacByte); +//WRONG PLACE//EXPORT_SYMBOL(LB_UnimportOptionalUnixlibStuff); +EXPORT_SYMBOL(LB_UninitializeSystemImports); +EXPORT_SYMBOL(LB_UnRegisterUnicodeConverter); +EXPORT_SYMBOL(LB_UTF8ToUniChar); +EXPORT_SYMBOL(LB_UTF8LenToUniChar); +EXPORT_SYMBOL(LB_VolumeNameToAutoRenameName); +EXPORT_SYMBOL(LB_VolumeNameToPoolName); +EXPORT_SYMBOL(LB_VolumeNameToSnapshotName); +EXPORT_SYMBOL(LB_VolumeNameToQSName); +EXPORT_SYMBOL(LB_VolumeNameValid); +EXPORT_SYMBOL(LB_VolumeRenameOK); +//WRONG PLACE//EXPORT_SYMBOL(LB__wioCreateWFile); +EXPORT_SYMBOL(LB_aprintf); +EXPORT_SYMBOL(LB_componentUnicpy); +EXPORT_SYMBOL(LB_componentUnilen); +EXPORT_SYMBOL(LB_delay); +EXPORT_SYMBOL(LB_errPrintf); +EXPORT_SYMBOL(LB_exitMyselfAndReturn); +EXPORT_SYMBOL(LB_free); +EXPORT_SYMBOL(LB_getchar); +//WRONG PLACE//EXPORT_SYMBOL(LB_GetDSGUID); +EXPORT_SYMBOL(LB_GetMacCodePageName); +EXPORT_SYMBOL(LB_gets); +EXPORT_SYMBOL(LB_malloc); +EXPORT_SYMBOL(LB_mallocPage); +EXPORT_SYMBOL(LB_mallocPageWithFlags); +EXPORT_SYMBOL(LB_mallocWithFlags); +EXPORT_SYMBOL(LB_ParseDSObjectName); +EXPORT_SYMBOL(LB_printf); +EXPORT_SYMBOL(LB_realloc); +EXPORT_SYMBOL(LB_snprintf); +EXPORT_SYMBOL(LB_sprintf); +EXPORT_SYMBOL(LB_unicat); +EXPORT_SYMBOL(LB_unichr); +EXPORT_SYMBOL(LB_unicmp); +EXPORT_SYMBOL(LB_unicpy); +EXPORT_SYMBOL(LB_uniicmp); +EXPORT_SYMBOL(LB_uniicmpMac); +EXPORT_SYMBOL(LB_unilen); +EXPORT_SYMBOL(LB_unilwr); +EXPORT_SYMBOL(LB_unimcpy); +EXPORT_SYMBOL(LB_unincat); +EXPORT_SYMBOL(LB_unincmp); +EXPORT_SYMBOL(LB_unincpy); +EXPORT_SYMBOL(LB_uninicmp); +EXPORT_SYMBOL(LB_unirchr); +EXPORT_SYMBOL(LB_unitolower); +EXPORT_SYMBOL(LB_unitoupper); +EXPORT_SYMBOL(LB_uniupr); +EXPORT_SYMBOL(LB_vsnprintf); +EXPORT_SYMBOL(LB_vsprintf); +EXPORT_SYMBOL(LB_wAPrintf); +//WRONG PLACE//EXPORT_SYMBOL(LB_wClose); +EXPORT_SYMBOL(LB_wGetPos); +EXPORT_SYMBOL(LB_wGetc); +EXPORT_SYMBOL(LB_wPause); +EXPORT_SYMBOL(LB_wPrintf); +EXPORT_SYMBOL(LB_wPromptForYesOrNo); +EXPORT_SYMBOL(LB_wSetPos); +EXPORT_SYMBOL(LB_zrealloc); +EXPORT_SYMBOL(Latch_All); +EXPORT_SYMBOL(Latch_Free); +EXPORT_SYMBOL(Latch_Holder); +EXPORT_SYMBOL(Latch_Waiter); +//WRONG PLACE//EXPORT_SYMBOL(LocalUtc2UTCTime); +//WRONG PLACE//EXPORT_SYMBOL(makeAESP); +EXPORT_SYMBOL(MSTime2utcTime); +EXPORT_SYMBOL(MallocTraceEnable); +//WRONG PLACE//EXPORT_SYMBOL(NDSDeleteEventFunc); +//WRONG PLACE//EXPORT_SYMBOL(NDSEventHandlerHandle); +//WRONG PLACE//EXPORT_SYMBOL(NDSRenameEventFunc); +EXPORT_SYMBOL(NSSDoubleByteToUnicodeTable); +EXPORT_SYMBOL(NSSMPK_InitNsslock); +EXPORT_SYMBOL(NSSMPK_LockNss); +EXPORT_SYMBOL(NSSMPK_LockNssNoInterrupts); +EXPORT_SYMBOL(NSSMPK_UnlockNss); +EXPORT_SYMBOL(NSSSingleByteToUnicodeTable); +EXPORT_SYMBOL(NSSUniToLower); +EXPORT_SYMBOL(NSSUniToUpper); +EXPORT_SYMBOL(NSSUnicodeFF); +EXPORT_SYMBOL(NSSUnicodeIsDoubleByteAsciiBitMap); +EXPORT_SYMBOL(NSSUnicodeIsDoubleByteMacAsciiBitMap); +EXPORT_SYMBOL(NSSUnicodeMappableToAsciiBitMap); +EXPORT_SYMBOL(NSSUnicodeMappableToMacAsciiBitMap); +EXPORT_SYMBOL(NSSUnicodeToByteTable); +EXPORT_SYMBOL(NSS_StoreCallers); +//WRONG PLACE//EXPORT_SYMBOL(NW_connectionTable); +//WRONG PLACE//EXPORT_SYMBOL(NW_DebuggerActive); +//WRONG PLACE//EXPORT_SYMBOL(NW_ErrCase); +//WRONG PLACE//EXPORT_SYMBOL(NW_LocaleTable); +//WRONG PLACE//EXPORT_SYMBOL(NW_MLIDMaximumPacketSize); +//WRONG PLACE//EXPORT_SYMBOL(NW_MaximumNumberOfServerProcesses); +//WRONG PLACE//EXPORT_SYMBOL(NW_MinimumNumberOfServerProcesses); +//WRONG PLACE//EXPORT_SYMBOL(NW_NCPFuncBoundaryError); +//WRONG PLACE//EXPORT_SYMBOL(NW_NCPLengthError); +//WRONG PLACE//EXPORT_SYMBOL(NW_NCPSubFuncLengthError); +//WRONG PLACE//EXPORT_SYMBOL(NW_NestedInterruptCount); +//WRONG PLACE//EXPORT_SYMBOL(NW_NumberOfVolumes); +//WRONG PLACE//EXPORT_SYMBOL(NW_numberOfConnectionSlots); +//WRONG PLACE//EXPORT_SYMBOL(NW_OSHandle); +//WRONG PLACE//EXPORT_SYMBOL(NW_PBInternalDelaySendPacketWithSignatures); +//WRONG PLACE//EXPORT_SYMBOL(NW_PBInternalSendPacketWithSignatures); +//WRONG PLACE//EXPORT_SYMBOL(NW_SkipReceiveBufferReturn); +//WRONG PLACE//EXPORT_SYMBOL(NW_SwitchVector); +//WRONG PLACE//EXPORT_SYMBOL(NW_WriteActiveList); +//WRONG PLACE//EXPORT_SYMBOL(NW_WriteBranchTableEntry); +//WRONG PLACE//EXPORT_SYMBOL(NW_WriteControlAvailList); +//WRONG PLACE//EXPORT_SYMBOL(NdsPublicsLoaded); +EXPORT_SYMBOL(Sec20002utcTime); +EXPORT_SYMBOL(Ticks); +EXPORT_SYMBOL(TimeToYield); +//WRONG PLACE//EXPORT_SYMBOL(UNIXLIB_MapDOSToNFSforNewNSSFilePtr); +//WRONG PLACE//EXPORT_SYMBOL(UNIXLIB_isLoaded); +//WRONG PLACE//EXPORT_SYMBOL(UNIXLIB_isUnloading); +//WRONG PLACE//EXPORT_SYMBOL(UNIXLIB_useCount); +EXPORT_SYMBOL(UTC2Sec2000Time); +EXPORT_SYMBOL(UTC2dosTime); +EXPORT_SYMBOL(UTC2LocalUtcTime); +EXPORT_SYMBOL(UTC2msTime); +EXPORT_SYMBOL(UTCTime2Str); +EXPORT_SYMBOL(UTCTime2UniversalStr); +//WRONG PLACE//EXPORT_SYMBOL(ZOS_IsNLMLoaded); +EXPORT_SYMBOL(configStartup); +EXPORT_SYMBOL(fillInWork); +EXPORT_SYMBOL(findId); +EXPORT_SYMBOL(findSmallestId); +EXPORT_SYMBOL(freeIds); +EXPORT_SYMBOL(fsmKick); +EXPORT_SYMBOL(harvestInst); +EXPORT_SYMBOL(initIds); +//WRONG PLACE//EXPORT_SYMBOL(kStartThreadWithModuleHandlePtr); +EXPORT_SYMBOL(mailInterrupt); +EXPORT_SYMBOL(mbInit); +EXPORT_SYMBOL(mbSetHigh); +EXPORT_SYMBOL(microSecondsDiffToStr); +EXPORT_SYMBOL(prHistogram); +EXPORT_SYMBOL(registerHistogram); +EXPORT_SYMBOL(resetInst); +EXPORT_SYMBOL(roust); +EXPORT_SYMBOL(secondsDiffToStr); +EXPORT_SYMBOL(setCyclic); +EXPORT_SYMBOL(setOneShot); +EXPORT_SYMBOL(snoozeSec); +EXPORT_SYMBOL(UniversalStr2utcTime); +EXPORT_SYMBOL(XML_UTF8ToGUID); +EXPORT_SYMBOL(XML_UTF8ToQUAD); +EXPORT_SYMBOL(XML_UTF8ToSQUAD); +EXPORT_SYMBOL(XML_UTF8ToUlong); +EXPORT_SYMBOL(XML_SingleNameToUnicodeName); +EXPORT_SYMBOL(XML_GetTagElementAtCurrentLevel); +EXPORT_SYMBOL(XML_Display); +EXPORT_SYMBOL(zADMINVOL_GUID); +EXPORT_SYMBOL(zINVALID_GUID); +EXPORT_SYMBOL(zZERO_GUID); +EXPORT_SYMBOL(SDM_Structure); +EXPORT_SYMBOL(SNP_snprintf); +EXPORT_SYMBOL(ZSD_Display_Type_BYTE); +EXPORT_SYMBOL(ZSD_Display_Type_LONG); +EXPORT_SYMBOL(ZSD_Display_Type_SLONG); +EXPORT_SYMBOL(ZSD_Display_Type_QUAD); +EXPORT_SYMBOL(ZSD_Display_Type_QUAD_ARRAY); +EXPORT_SYMBOL(ZSD_Display_Type_SWORD); +EXPORT_SYMBOL(ZSD_Display_Type_Time_t); +EXPORT_SYMBOL(ZSD_Display_Type_Time_t_ARRAY); +EXPORT_SYMBOL(ZSD_Display_Type_WORD); +EXPORT_SYMBOL(ZSD_Display_Type_Zid_t); +EXPORT_SYMBOL(IgnoreTimeZone); +EXPORT_SYMBOL(ResetTimeCache); +EXPORT_SYMBOL(BEASTHASH_InvalidateDOSTimesPtr); +EXPORT_SYMBOL(LB_StackFree); +EXPORT_SYMBOL(fsmStart); +//WRONG PLACE//EXPORT_SYMBOL(fsmInit); +EXPORT_SYMBOL(fsmStop); +EXPORT_SYMBOL(doDisplayHistogram); +EXPORT_SYMBOL(doDisableHistogram); +EXPORT_SYMBOL(doClearHistogram); +EXPORT_SYMBOL(doListHistograms); +EXPORT_SYMBOL(doEnableHistogram); +EXPORT_SYMBOL(incHistogram); +EXPORT_SYMBOL(initInst); +EXPORT_SYMBOL(PageInst); +EXPORT_SYMBOL(SDM_TableNSS); +EXPORT_SYMBOL(LB_ParseCmdlineMulti); +EXPORT_SYMBOL(LB_DisplayCmdlineHelpMulti); +EXPORT_SYMBOL(FDAT_UnitTest); +EXPORT_SYMBOL(LBL_incCountAndCheck); +EXPORT_SYMBOL(LB_wWrapString); +EXPORT_SYMBOL(doLatchInstEnable); +EXPORT_SYMBOL(doLatchInstDisplay); +EXPORT_SYMBOL(doLatchInstReset); +EXPORT_SYMBOL(RecordLatches); +EXPORT_SYMBOL(SNP_Construct1); +EXPORT_SYMBOL(FormatVersionString); +EXPORT_SYMBOL(LibModule); +EXPORT_SYMBOL(LB_vaprintf); +EXPORT_SYMBOL(LB_zalloc); +EXPORT_SYMBOL(LB_freePage); +EXPORT_SYMBOL(LB_zallocPage); +EXPORT_SYMBOL(LB_StackAllocate); +EXPORT_SYMBOL(ErrorTable); +EXPORT_SYMBOL(NSSLOG_Startup); +EXPORT_SYMBOL(NSSLOG_Shutdown); +EXPORT_SYMBOL(NSSLOG_printf); +EXPORT_SYMBOL(NSSLOG_TypeNames); +EXPORT_SYMBOL(utf_tolower); diff --git a/src/nwnss/library/os/ZOS_IsNLMLoaded.c b/src/nwnss/library/os/ZOS_IsNLMLoaded.c new file mode 100644 index 0000000..9d689bf --- /dev/null +++ b/src/nwnss/library/os/ZOS_IsNLMLoaded.c @@ -0,0 +1,50 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996-2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Wrapper for IsNLMLoaded + +-------------------------------------------------------------------------*/ +#if zNETWARE +#include "pssmpk.h" + +extern LONG IsNLMLoaded(BYTE *nlmName); +LONG ZOS_IsNLMLoaded (BYTE *nlmName) +{ + LONG result; + + MPKNSS_UNLOCK(); + result = IsNLMLoaded(nlmName); + MPKNSS_LOCK(); + return result; +} +#endif // #if zNETWARE diff --git a/src/nwnss/library/os/aeswork.c b/src/nwnss/library/os/aeswork.c new file mode 100644 index 0000000..af87392 --- /dev/null +++ b/src/nwnss/library/os/aeswork.c @@ -0,0 +1,176 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | define all of the prototypes and globals for the managment of + | the file system check points physical and logical + | + +-------------------------------------------------------------------------*/ +#include "procdefs.h" /* NetWare Include*/ + +#include "register.h" /* NSS Library Includes*/ +#include "schedule.h" +#include "stdlib.h" +#include "nssOSAPIs.h" + + +/*- this structure is only used in the automatic AES -*/ +typedef struct MakeAESP_s +{ + struct zAESProc_s process; + voidfunc_t realProcedure; +} MakeAESP_s; + + +/************************************************************************** + * make AES procedure to call + * + * this function is called by the AES Scheduler + * this routine will then free up the AES structure and call the process + * routine. This is used in conjunction with 'makeAESP' + * + ***************************************************************************/ +void makeAESProcedure(struct zAESP_s *zaesp) +{ + MakeAESP_s *autoaesp; + void *info; + voidfunc_t procedure; + MPKNSS_LOCK(); + + autoaesp = (MakeAESP_s *)zaesp; + info = autoaesp->process.info; + procedure = (voidfunc_t)autoaesp->realProcedure; + free(autoaesp); + procedure(info); + MPKNSS_UNLOCK(); + + return; +} + +/************************************************************************** + * create a AES structure, fill it in then Scheduled AES Process + * this is a single shot version that uses the 'makeAESProcedure' callback + * to then call the real routine. + * + ***************************************************************************/ +LONG makeAESP( + voidfunc_t procedureToCall, + LONG delayTime, + void *userParameter) +{ + MakeAESP_s *autoaesp; + zAESProc_s *process; + ASSERT_MPKNSS_LOCK(); + + if((autoaesp = (MakeAESP_s *)zalloc(sizeof(struct MakeAESP_s))) != NULL) + { + process = (zAESProc_s *)autoaesp; + + fillInAESP(process, (voidfunc_t)makeAESProcedure, delayTime, userParameter); + autoaesp->realProcedure = procedureToCall; + scheduleAESP(process); + return(zOK); + } + return(zFAILURE); +} + +/************************************************************************** + * Fill in a AES Process structure + * + * NOTE: + * aesp->timeDelay needs to be in timer ticks 18.2 per second + * this is used to fill an zAESProc_s structure that has been allocated + * use 'scheduleAESP' to start the event and 'cancelAESP' to stop before + * the trigger time. + * + ***************************************************************************/ +void fillInAESP(struct zAESProc_s *process, + voidfunc_t procedureToCall, + LONG delayTimeInSeconds, + void *userParameter) +{ + zAESP_s *aesp; + ASSERT_MPKNSS_LOCK(); + + aesp = (zAESP_s *)&process->zaesp; + + if(aesp != 0) + { + aesp->osReserved0 = NULL; + aesp->timeDelay = (delayTimeInSeconds * 182)/10; + aesp->osReserved1 = NULL; + aesp->ProcedureToCall = (voidfunc_t)procedureToCall; + aesp->AESResourceTag = COMN_Resource.aespRTag; + aesp->osReserved2 = NULL; + } + if(userParameter != 0) + process->info = userParameter; + + /*- set in use flag to NOT IN USE -*/ + process->inUseFlag = AESNOTINUSE; +} + +/************************************************************************** + * Schedule a AES Process + * + * use this to schedule a AES event using th zAESProc_s structure + * + ***************************************************************************/ +void scheduleAESP(struct zAESProc_s *process) +{ + ASSERT_MPKNSS_LOCK(); + if(process->inUseFlag == AESNOTINUSE) + { + /*- not scheduled yet! -*/ + process->inUseFlag = AESBEINGUSED; + ZOS_ScheduleSleepAESProcessEvent((struct AESProcessStructure *)process); + } +} + +/************************************************************************** + * Cancel a Scheduled AES Process + * + * use this to remove AES event from the queue before the delay time is up + * + ***************************************************************************/ +LONG cancelAESP(struct zAESProc_s *process) +{ + ASSERT_MPKNSS_LOCK(); + if(process->inUseFlag != AESNOTINUSE) + { + /*- event is scheduled, so cancel it -*/ + ZOS_CancelSleepAESProcessEvent((struct AESProcessStructure *)process); + process->inUseFlag = AESNOTINUSE; + } + return(zOK); +} diff --git a/src/nwnss/library/os/alarm.c b/src/nwnss/library/os/alarm.c index 2619515..0a96b07 100644 --- a/src/nwnss/library/os/alarm.c +++ b/src/nwnss/library/os/alarm.c @@ -34,19 +34,18 @@ | This module is used to: | Impelment alarm (timing) services for NSS +-------------------------------------------------------------------------*/ -#include +#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef HZ -#define HZ 1000 -#endif +#include +#include +#include +#include "fsm.h" +#include "alarm.h" +#include "latch.h" +#include "pssConfig.h" +#include "inst.h" +#include "nssOSAPIs.h" +#include "nssDebug.h" #define SPOKE_SHIFT 4 #define NUM_SPOKES (1 << SPOKE_SHIFT) @@ -87,18 +86,26 @@ extern void alarmPop(void); extern void fireAlarm(void); LONG TimeToYield = 0; +struct TimerDataStructure TimerNode = { 0, (void (*)(LONG))alarmPop }; +zWorkProc_s AlarmWorkToDo; #if zLINUX BOOL gYieldJiffy = FALSE; LONG gYieldCount = 0; LONG gYieldPeriodicCount = PERIODIC_YIELD_COUNT; + +EXPORT_SYMBOL(gYieldJiffy); +EXPORT_SYMBOL(gYieldCount); +EXPORT_SYMBOL(gYieldPeriodicCount); + +mpkSema_t AlarmSemaphore; #endif void alarmInit (void) { int i, j; Wheel_s *wheel; - + ASSERT_MPKNSS_LOCK(); for (i = 0; i < NUM_WHEELS; ++i) @@ -123,7 +130,7 @@ void setAlarm (OneShot_s *alarm) DQhead_t *spoke; LONG oldtime; LONG time = alarm->firetime - Ticks; - + ASSERT_MPKNSS_LOCK(); oldtime = time; @@ -147,7 +154,7 @@ void fireAlarm (void) OneShot_s *alarm; NINT wheelNum; NINT spokeNum; - + MPKNSS_LOCK(); if (AlarmStop) { @@ -191,15 +198,21 @@ void fireAlarm (void) } DQ_DEQ( &AlarmWork, alarm, OneShot_s, link); } - /* Linux userspace port: the imported alarm wheel is driven explicitly - * by callers/tests through fireAlarm(). The kernel/NSS interrupt - * callback re-arm is not available in mars-nwe userspace. */ +// if (DebugIsOn) +// { +// TimerNode.TCallBackWaitTime = 25000; +// } +// else +// { + TimerNode.TCallBackWaitTime = TICK; +// } + CScheduleInterruptTimeCallBack( &TimerNode); MPKNSS_UNLOCK(); } -void setOneShot (OneShot_s *alarm, LONG length, OneShotFunc_t function) +void setOneShot (OneShot_s *alarm, LONG length, void (*function)()) { - + ASSERT_MPKNSS_LOCK(); alarm->firetime = length + Ticks + 1; alarm->function = function; @@ -209,7 +222,7 @@ void setOneShot (OneShot_s *alarm, LONG length, OneShotFunc_t function) void resetCyclic (OneShot_s *alarm) { Cyclic_s *cyclic = (Cyclic_s *)alarm; - + ASSERT_MPKNSS_LOCK(); cyclic->function(cyclic); @@ -217,7 +230,7 @@ void resetCyclic (OneShot_s *alarm) setAlarm(alarm); } -void setCyclic (Cyclic_s *alarm, LONG length, CyclicFunc_t function) +void setCyclic (Cyclic_s *alarm, LONG length, void (*function)()) { ASSERT_MPKNSS_LOCK(); if (length == 0) @@ -234,23 +247,41 @@ void setCyclic (Cyclic_s *alarm, LONG length, CyclicFunc_t function) void alarmPop () { - /* Linux userspace port: no kernel timer semaphore is installed. */ + kSemaphoreSignal( &AlarmSemaphore); } void signalAlarm () { - /* Linux userspace port: alarms are drained explicitly with fireAlarm(). */ + while (!AlarmStop) + { + kSemaphoreWait( &AlarmSemaphore); + fireAlarm(); + } } void alarmStart (void) { ASSERT_MPKNSS_LOCK(); alarmInit(); + TimerNode.TResourceTag = COMN_Resource.timerRTag; + + fillInWork( &AlarmWorkToDo, signalAlarm, 0); + TimerNode.TCallBackWaitTime = TICK; + mpkSemaphoreInit( &AlarmSemaphore, "NSS Alarm AlarmSemaphore", 0); + ScheduleWork( &AlarmWorkToDo); + + CScheduleInterruptTimeCallBack( &TimerNode); } void alarmStop (void) { - ASSERT_MPKNSS_LOCK(); AlarmStop = TRUE; + ASSERT_MPKNSS_LOCK(); + INIT_X_LATCH( &AlarmStoppedLatch); + /* + * Wait until we have received the last alarm + * interrupt. + */ + X_BARRIER( &AlarmStoppedLatch); } diff --git a/src/nwnss/library/os/config.c b/src/nwnss/library/os/config.c index d4e07d4..e5d3a63 100644 --- a/src/nwnss/library/os/config.c +++ b/src/nwnss/library/os/config.c @@ -34,26 +34,27 @@ | This module is used to: | Initialize configuration values for PSS +-------------------------------------------------------------------------*/ -#include -#include -#include +#include +#include +#include +#include Config_s Config = { - { DEFAULT_NUM_BUFFERS, - DEFAULT_NUM_BONDS, - DEFAULT_NUM_ASYNCIOS, + { DEFAULT_NUM_BUFFERS, + DEFAULT_NUM_BONDS, + DEFAULT_NUM_ASYNCIOS, 0, 0, #ifdef __linux__ // LINUX_CacheBalance - FALSE, + FALSE, #else TRUE, #endif - PERCENT_OS_FREE_CACHE, + PERCENT_OS_FREE_CACHE, CACHE_BALANCE_TIMER_SECS, - MIN_OS_FREE_CACHE_BUFS, - 0, + MIN_OS_FREE_CACHE_BUFS, + 0, DEFAULT_NUM_BUFFERS_PER_SESSION, 0, MAX_PERCENT_FOR_USER_PAGES, @@ -68,17 +69,17 @@ Config_s Config = 0 /* Config.cache.metadataBlocksReadyForGroupWrite */ }, - { DEFAULT_SIZE_MAILBOX, - DEFAULT_WORK_LIMIT, + { DEFAULT_SIZE_MAILBOX, + DEFAULT_WORK_LIMIT, DEFAULT_WORK_DELAY_CNT }, - { DEFAULT_NOT_IN_USE_BEASTS, + { DEFAULT_NOT_IN_USE_BEASTS, DEFAULT_BEAST_PERCENT_MEM, DEFAULT_BEAST_BALANCE_SEC}, // DEFAULT_BEAST_HASH_SHIFT }, - { DEFAULT_SEC_BEAST, - DEFAULT_SEC_XACTION, + { DEFAULT_SEC_BEAST, + DEFAULT_SEC_XACTION, DEFAULT_SEC_CHKPT, DEFAULT_SEC_OPLOCKWAIT, DEFAULT_SEC_JOURNAL_GROUP_WRITE, @@ -89,17 +90,17 @@ Config_s Config = { 0 }, - { DEFAULT_MAX_WORK_WAITING, + { DEFAULT_MAX_WORK_WAITING, DEFAULT_MAX_HIGH_WORK_WAITING }, { DEFAULT_NUM_DELAYED_BEASTS }, - { DEFAULT_NUM_XACTIONS, + { DEFAULT_NUM_XACTIONS, DEFAULT_NUM_XDELETES }, - { DEFAULT_STORAGE_ALARM_THRESHOLD, - DEFAULT_STORAGE_RESET_THRESHOLD, - DEFAULT_STORAGE_SEND_ALERT, + { DEFAULT_STORAGE_ALARM_THRESHOLD, + DEFAULT_STORAGE_RESET_THRESHOLD, + DEFAULT_STORAGE_SEND_ALERT, DEFAULT_ALLOC_AHEAD_WRITE, DEFAULT_CHECKER, DEFAULT_FORCE_CHECKER }, diff --git a/src/nwnss/library/os/crthread.c b/src/nwnss/library/os/crthread.c new file mode 100644 index 0000000..d6f8dae --- /dev/null +++ b/src/nwnss/library/os/crthread.c @@ -0,0 +1,200 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library Source + +-------------------------------------------------------------------------*/ +#include "procdefs.h" /* NetWare Includes*/ + +#include "schedule.h" /* PSS Includes*/ +#include "register.h" +#include "que.h" +#include "stdlib.h" + +#define BLOCKSHIFT16K 14 + +#define PRIORITY_HIGH 0 +#define PRIORITY_NORMAL 50 +#define PRIORITY_LOW 250 + +#define PROCESSSTACKSIZE 1 << BLOCKSHIFT16K + +#if 0 + +DQhead_t MasterThreadList; + +typedef struct Thread_s +{ + DQlink_t link; + LONG processID; + BYTE *stack; +} Thread_s; + +/************************************************************************** + * Initialize the Thread Manager + * + ***************************************************************************/ +STATUS InitThreadProcess() +{ + /*- init master thread list to nil -*/ + DQ_INIT(&MasterThreadList); + + return(zOK); +} + +/************************************************************************** + * uninitialize the Thread Manager + * + ***************************************************************************/ +void UninitThreadProcess() +{ + Thread_s *thread; + + /*- destroy the master thread list -*/ + while(DQ_NOT_EMPTY(&MasterThreadList) != NULL) + { + DQ_DEQ_NO_CHECK(&MasterThreadList, thread, Thread_s, link); + + DestroyThread(thread->processID); + + /*- free thread stack -*/ + free(thread->stack); + + /*- free thread struct -*/ + free(thread); + thread = 0; + } + + /*- init master thread list to nil -*/ + DQ_INIT(&MasterThreadList); + + return; +} + +/************************************************************************** + * Create a Process Thread + * + * name length should not exceed 32 char. + ***************************************************************************/ +STATUS CreateThread( + void (*ExcuteRoutine)(), + char *threadName, + LONG priority, + LONG *retThreadID) +{ + LONG stacksize; + Thread_s *thread; + LONG order; + + stacksize = PROCESSSTACKSIZE; + *retThreadID = 0; + + switch(priority) + { + case THREAD_HIGH: + order = PRIORITY_HIGH; + break; + + case THREAD_MED: + order = PRIORITY_NORMAL; + break; + + case THREAD_LOW: + order = PRIORITY_LOW; + break; + + default: + order = PRIORITY_NORMAL; + break; + } + + if((thread = (Thread_s *)zalloc(sizeof(struct Thread_s))) != NULL) + { + if((thread->stack = (BYTE *)zalloc(stacksize)) != NULL) + { + /*- make any process as the last thing before leaving the initialization -*/ + if((thread->processID = CMakeProcess( + order, + ExcuteRoutine, + thread->stack + stacksize, + stacksize, + (BYTE *)threadName, + COMN_Resource.processRTag)) != NULL) + { + /*- link thread to master list -*/ + DQ_PUSH(&MasterThreadList, thread, link); + + *retThreadID = thread->processID; + + return(zOK); + } + free(thread->stack); + } + free(thread); + } + + return(zFAILURE); +} + +/************************************************************************** + * Destroy a Process Thread + * + ***************************************************************************/ +STATUS DestroyThread( + LONG ThreadID) +{ + Thread_s *thread; + + /*- scan the thread list -*/ + if(DQ_NOT_EMPTY(&MasterThreadList)) + { + thread = 0; + DQ_FOREACH(&MasterThreadList, thread, Thread_s, link) + { + if(thread->processID == ThreadID) + { + /*- remove this thread from the master list -*/ + DQ_RMV(thread, link); + + ZOS_DestroyProcess((THREAD)ThreadID); + free(thread->stack); + free(thread); + + return(zOK); + } + } + } + return(zFAILURE); +} + +#endif diff --git a/src/nwnss/library/os/delay.c b/src/nwnss/library/os/delay.c index 3658567..ea0ae92 100644 --- a/src/nwnss/library/os/delay.c +++ b/src/nwnss/library/os/delay.c @@ -34,18 +34,14 @@ | This module is used to: | NSS Library source +-------------------------------------------------------------------------*/ -#include +#include -#include -#include -#include -#include +/*#include */ -#include -#include -#include - -void ZOS_YieldThread(void); +#include "schedule.h" +#include "register.h" +#include "nssOSAPIs.h" +#include "alarm.h" /************************************************************************** * Delay the given number of milliseconeds @@ -55,112 +51,32 @@ LONG Delayed = 0; void LB_delay( NINT millisec) { - if (millisec <= 0) +#if 0 +//{ +// static NINT maxdelays = 100; +// if (--maxdelays) +// { +// zASSERT("too many delays"==0); +// } +//} +#endif + + if (millisec == 0) { - ZOS_YieldThread(); - return; + Yield(); + } - - Delayed += millisec; - BOOL hadLock = MPKNSS_I_OWN_SPINLOCK(); - if (hadLock) + else { + Delayed += millisec; MPKNSS_UNLOCK(); +#if zNETWARE + DelayMyself/*ZOS_DelayThread*/((millisec + (MILLISEC_PER_TICK-1)) / MILLISEC_PER_TICK, COMN_Resource.timerRTag); +#else + kDelayThread( millisec ); +#endif + MPKNSS_LOCK(); } - struct timespec req; - req.tv_sec = millisec / 1000; - req.tv_nsec = (long)(millisec % 1000) * 1000000L; - while (nanosleep(&req, &req) == -1 && errno == EINTR) - { - } - - if (hadLock) - { - MPKNSS_LOCK(); - } } -THREAD kCurrentThread(void) -{ - return (THREAD)(ADDR)pthread_self(); -} - -void ZOS_YieldThread(void) -{ - BOOL hadLock = MPKNSS_I_OWN_SPINLOCK(); - - if (hadLock) - { - MPKNSS_UNLOCK(); - } - - sched_yield(); - - if (hadLock) - { - MPKNSS_LOCK(); - } -} - -void CYieldUntilIdle(void) -{ - ZOS_YieldThread(); -} - -void ZOS_Sleep(void) -{ - /* The full NSS scheduler wait queues are imported later with FSM. - * Until then, preserve the userspace scheduling surface for non-contended - * internal latch users by yielding cooperatively. */ - ZOS_YieldThread(); -} - -void ZOS_WakeUp(THREAD thread) -{ - (void)thread; -} - -LONG GetSuperHighResolutionTimer(void) -{ - struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - return (LONG)(now.tv_sec * 1000000L + now.tv_nsec / 1000L); -} - -STATUS ZOS_ScheduleWorkToDo(struct WorkToDoStructure *work) -{ - zWork_s *zwork = (zWork_s *)work; - BOOL hadLock = MPKNSS_I_OWN_SPINLOCK(); - - if (zwork == NULL || zwork->ProcedureToCall == NULL) - { - return zERR_BAD_PARAMETER_VALUE; - } - - if (hadLock) - { - MPKNSS_UNLOCK(); - } - - ((void (*)(void *))zwork->ProcedureToCall)(work); - - if (hadLock) - { - MPKNSS_LOCK(); - } - - return zOK; -} - -STATUS ZOS_ScheduleFastWorkToDo(struct WorkToDoStructure *work, int priority) -{ - (void)priority; - return ZOS_ScheduleWorkToDo(work); -} - -STATUS ZOS_CancelWorkToDo(struct WorkToDoStructure *work) -{ - (void)work; - return zOK; -} diff --git a/src/nwnss/library/os/inst.c b/src/nwnss/library/os/inst.c index ebffb83..a9eedec 100644 --- a/src/nwnss/library/os/inst.c +++ b/src/nwnss/library/os/inst.c @@ -35,9 +35,11 @@ | Variables and routines for instrumentation. +-------------------------------------------------------------------------*/ -#include -#include -#include +#include + +#include +#include +#include "inst.h" Inst_s Inst; diff --git a/src/nwnss/library/os/mailbox.c b/src/nwnss/library/os/mailbox.c index f6ad58d..4c8f6f6 100644 --- a/src/nwnss/library/os/mailbox.c +++ b/src/nwnss/library/os/mailbox.c @@ -34,15 +34,15 @@ | This module is used to: | Impelment mailbox (ring buffer) protocol +-------------------------------------------------------------------------*/ -#include +#include -#include "include/mailbox.h" -#include "include/pssmpk.h" +#include "mailbox.h" +#include "pssmpk.h" void mbInit (Mailbox_s *mbox, void *start, void *end) { ASSERT_MPKNSS_LOCK(); - + mbox->start = start; mbox->take = start; mbox->give = start; diff --git a/src/nwnss/library/os/pssmpk.c b/src/nwnss/library/os/pssmpk.c index 91d365e..145fa76 100644 --- a/src/nwnss/library/os/pssmpk.c +++ b/src/nwnss/library/os/pssmpk.c @@ -1,26 +1,26 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996-1998 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996-1998 Novell, Inc. + | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) Initialization module + | NetWare Advance File Services (NSS) Initialization module | |--------------------------------------------------------------------------- | @@ -31,156 +31,218 @@ | $Revision: 1954 $ | |--------------------------------------------------------------------------- - | This module is used to: - | This contains the Spinlock routines used to incorporate SMP feature - | in Novell Storage Serivces. The code calling the following routines - | will grab or release for the Global Spinlock named MPKNSS_LOCK and - | acoordingly access shared code or data as and it is necessary. + | This module is used to: + | This contains the Spinlock routines used to incorporate SMP feature + | in Novell Storage Serivces. The code calling the following routines + | will grab or release for the Global Spinlock named MPKNSS_LOCK and + | acoordingly access shared code or data as and it is necessary. +-------------------------------------------------------------------------*/ +#include +#include -/* - * Imported from NSS public_core/library/os/pssmpk.c. - * - * mars-nwe is a Linux userspace server. The original Linux-kernel includes, - * EXPORT_SYMBOL declarations and task_struct ownership are ported to the core - * pthread spinlock backend and pthread_self() ownership. The original - * optimized NSS MPK shape, spinlock instrumentation globals and command entry - * points are kept so later latch/cache/beast imports see the expected API. - */ -#include -#include +#include +#include #include -#include -#include +#include -#include -#include +#if MPK_REAL IS_ENABLED -#ifndef EXPORT_SYMBOL -#define EXPORT_SYMBOL(_symbol) -#endif +#include -NSSMPK_Spinlock_t NSSMPK_spinlock; +NSSMPK_Spinlock_t NSSMPK_spinlock __cacheline_aligned_in_smp; EXPORT_SYMBOL(NSSMPK_spinlock); -Histogram_s SpinLockHeld; -Histogram_s SpinLockWait; -NINT SpinHeldStart; -BOOL MeasureSpinLock = FALSE; +#ifdef __LP64__ + #define rdtsc_nint rdtscll +#else + #define rdtsc_nint rdtscl +#endif + +#if NSS_DEBUG IS_ENABLED + + /* + * The NSS Global Spinlock. Linux Debug + */ + +Histogram_s SpinLockHeld; +Histogram_s SpinLockWait; +NINT SpinHeldStart; +BOOL MeasureSpinLock = FALSE; + +void NSSMPK_InitNsslock (char *where) +{ +#ifdef USE_SPINLOCK + spin_lock_init( &NSSMPK_spinlock.NSL_spinlock); +// kSpinLockInit( &NSSMPK_spinlock.NSL_spinlock); +// NSSMPK_spinlock.NSL_mutex = kMutexAlloc("NSS Spinlock"); +#else + mpkSemaphoreInit( &NSSMPK_spinlock.NSL_semaphore, "NSS Semaphore", 1); +#endif + registerHistogram("spinheld", &MeasureSpinLock, &SpinLockHeld); + registerHistogram("spinwait", &MeasureSpinLock, &SpinLockWait); +} + +NINT NSSMPK_LockNss (char *where) +{ + NINT waitStart; + +prs("LockNss", where); + if (MeasureSpinLock) + { + rdtsc_nint(waitStart); +#ifdef USE_SPINLOCK + spin_lock( &NSSMPK_spinlock.NSL_spinlock); +// NSSMPK_spinlock.NSL_flags = kSpinLockDisable( &NSSMPK_spinlock.NSL_spinlock); +// kMutexLock(NSSMPK_spinlock.NSL_mutex); +#else + kSemaphoreWait( &NSSMPK_spinlock.NSL_semaphore); +#endif + rdtsc_nint(SpinHeldStart); + eventHistogram( &SpinLockWait, SpinHeldStart - waitStart); + } + else + { +#ifdef USE_SPINLOCK + spin_lock( &NSSMPK_spinlock.NSL_spinlock); +// NSSMPK_spinlock.NSL_flags = kSpinLockDisable( &NSSMPK_spinlock.NSL_spinlock); +// kSpinLock( &NSSMPK_spinlock.NSL_spinlock); +// kMutexLock(NSSMPK_spinlock.NSL_mutex); +#else + kSemaphoreWait( &NSSMPK_spinlock.NSL_semaphore); +#endif + } + NSSMPK_spinlock.NSL_owner = (ADDR)current; + return TRUE; +} + +NINT NSSMPK_LockNssNoInterrupts (char *where) +{ + NINT waitStart; + +prs("LockNssNo", where); + if (MeasureSpinLock) + { + rdtsc_nint(waitStart); + +#ifdef USE_SPINLOCK + spin_lock( &NSSMPK_spinlock.NSL_spinlock); +// NSSMPK_spinlock.NSL_flags = kSpinLockDisable( &NSSMPK_spinlock.NSL_spinlock); +// kMutexLock(NSSMPK_spinlock.NSL_mutex); +#else + kSemaphoreWait( &NSSMPK_spinlock.NSL_semaphore); +#endif + + rdtsc_nint(SpinHeldStart); + eventHistogram( &SpinLockWait, SpinHeldStart - waitStart); + } + else + { +#ifdef USE_SPINLOCK + spin_lock( &NSSMPK_spinlock.NSL_spinlock); +// NSSMPK_spinlock.NSL_flags = kSpinLockDisable( &NSSMPK_spinlock.NSL_spinlock); +// kMutexLock(NSSMPK_spinlock.NSL_mutex); +#else + kSemaphoreWait( &NSSMPK_spinlock.NSL_semaphore); +#endif + } + NSSMPK_spinlock.NSL_owner = (ADDR)current; + return TRUE; +} + +NINT NSSMPK_UnlockNss (char *where) +{ + if (MeasureSpinLock) + { + NINT end; + + rdtsc_nint(end); + eventHistogram( &SpinLockHeld, end - SpinHeldStart); + } + NSSMPK_spinlock.NSL_owner = 0; +#ifdef USE_SPINLOCK + spin_unlock( &NSSMPK_spinlock.NSL_spinlock); +// kSpinUnlockRestore( &NSSMPK_spinlock.NSL_spinlock, NSSMPK_spinlock.NSL_flags); +// kMutexUnlock(NSSMPK_spinlock.NSL_mutex); +#else + kSemaphoreSignal( &NSSMPK_spinlock.NSL_semaphore); +#endif +prs("UnlockNss", where); + return TRUE; +} + +#else + /* Linux: Optimized */ +Histogram_s SpinLockHeld; +Histogram_s SpinLockWait; +NINT SpinHeldStart; +BOOL MeasureSpinLock = FALSE; EXPORT_SYMBOL(MeasureSpinLock); struct PCLSwitchDef_s; -static BOOL NSSMPK_initialized = FALSE; - -static ADDR -currentThreadId(void) -{ - union { - pthread_t thread; - ADDR addr; - } id; - - id.addr = 0; - id.thread = pthread_self(); - return id.addr; -} - -static NINT -rdtsc_nint(void) -{ - struct timespec ts; - - if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) - { - return 0; - } - return (NINT)((ts.tv_sec * 1000000000LL) + ts.tv_nsec); -} - -STATUS -doSpinLockInstEnable( +STATUS doSpinLockInstEnable ( struct PCLSwitchDef_s *switchDef, NINT options, - void *userParm) -{ - (void)switchDef; - (void)options; - (void)userParm; - return zOK; -} + void *userParm) { return( zOK ); } EXPORT_SYMBOL(doSpinLockInstEnable); -STATUS -doSpinLockInstDisplay( +STATUS doSpinLockInstDisplay ( struct PCLSwitchDef_s *switchDef, NINT options, - void *userParm) -{ - (void)switchDef; - (void)options; - (void)userParm; - return zOK; -} + void *userParm) { return( zOK ); } EXPORT_SYMBOL(doSpinLockInstDisplay); -STATUS -doSpinLockInstReset( +STATUS doSpinLockInstReset ( struct PCLSwitchDef_s *switchDef, NINT options, - void *userParm) -{ - (void)switchDef; - (void)options; - (void)userParm; - return zOK; -} + void *userParm) { return( zOK ); } EXPORT_SYMBOL(doSpinLockInstReset); -void -NSSMPK_InitNsslock(void) +void NSSMPK_InitNsslock (void) { #ifdef USE_SPINLOCK - spin_lock_init(&NSSMPK_spinlock.NSL_spinlock); + spin_lock_init( &NSSMPK_spinlock.NSL_spinlock); +// kSpinLockInit( &NSSMPK_spinlock.NSL_spinlock); +// NSSMPK_spinlock.NSL_mutex = kMutexAlloc("NSS Spinlock"); +#else + mpkSemaphoreInit( &NSSMPK_spinlock.NSL_semaphore, "NSS Semaphore", 1); #endif - NSSMPK_spinlock.NSL_owner = 0; registerHistogram("spinheld", &MeasureSpinLock, &SpinLockHeld); registerHistogram("spinwait", &MeasureSpinLock, &SpinLockWait); - NSSMPK_initialized = TRUE; } -NINT -NSSMPK_LockNss(void) +NINT NSSMPK_LockNss (void) { - NINT waitStart; - - if (!NSSMPK_initialized) - { - NSSMPK_InitNsslock(); - } + NINT waitStart; if (MeasureSpinLock) { - waitStart = rdtsc_nint(); + rdtsc_nint(waitStart); #ifdef USE_SPINLOCK - spin_lock(&NSSMPK_spinlock.NSL_spinlock); + spin_lock( &NSSMPK_spinlock.NSL_spinlock); +// NSSMPK_spinlock.NSL_flags = kSpinLockDisable( &NSSMPK_spinlock.NSL_spinlock); +// kMutexLock(NSSMPK_spinlock.NSL_mutex); +#else + kSemaphoreWait( &NSSMPK_spinlock.NSL_semaphore); #endif - SpinHeldStart = rdtsc_nint(); - eventHistogram(&SpinLockWait, SpinHeldStart - waitStart); + rdtsc_nint(SpinHeldStart); + eventHistogram( &SpinLockWait, SpinHeldStart - waitStart); } else { #ifdef USE_SPINLOCK #if 0 - /* - * Original NSS Linux kernel debug path kept disabled for userspace. - * It used show_stack(), task_struct and BUG() after long spin waits. - */ + /* + * To use this code + * 1. change the 0 to a 1, recompile + * 2. goto /user/src/linux/arch/i386/kernel/traps.c and EXPORT_SYMBOL(show_stack) + * 3. recompile kernel + */ { extern void show_stack(struct task_struct *tsk, unsigned long *sp); - int n = 100*1000*1000; + int n = 100*1000*1000; for (;;) { - if (spin_trylock(&NSSMPK_spinlock.NSL_spinlock)) break; + if (spin_trylock( &NSSMPK_spinlock.NSL_spinlock)) break; if (!n--) { printk("<1>---------------- Stack dump %lx ----------------\n", NSSMPK_spinlock.NSL_owner); @@ -192,96 +254,102 @@ NSSMPK_LockNss(void) } } #else - spin_lock(&NSSMPK_spinlock.NSL_spinlock); + spin_lock( &NSSMPK_spinlock.NSL_spinlock); #endif +// NSSMPK_spinlock.NSL_flags = kSpinLockDisable( &NSSMPK_spinlock.NSL_spinlock); +// kMutexLock(NSSMPK_spinlock.NSL_mutex); +#else + kSemaphoreWait( &NSSMPK_spinlock.NSL_semaphore); #endif } - NSSMPK_spinlock.NSL_owner = currentThreadId(); + NSSMPK_spinlock.NSL_owner = (ADDR)current; return TRUE; } -NINT -NSSMPK_LockNssNoInterrupts(void) +NINT NSSMPK_LockNssNoInterrupts (void) { - NINT waitStart; - - if (!NSSMPK_initialized) - { - NSSMPK_InitNsslock(); - } + NINT waitStart; if (MeasureSpinLock) { - waitStart = rdtsc_nint(); + rdtsc_nint(waitStart); #ifdef USE_SPINLOCK - spin_lock(&NSSMPK_spinlock.NSL_spinlock); + spin_lock( &NSSMPK_spinlock.NSL_spinlock); +// NSSMPK_spinlock.NSL_flags = kSpinLockDisable( &NSSMPK_spinlock.NSL_spinlock); +// kMutexLock(NSSMPK_spinlock.NSL_mutex); +#else + kSemaphoreWait( &NSSMPK_spinlock.NSL_semaphore); #endif - SpinHeldStart = rdtsc_nint(); - eventHistogram(&SpinLockWait, SpinHeldStart - waitStart); + + rdtsc_nint(SpinHeldStart); + eventHistogram( &SpinLockWait, SpinHeldStart - waitStart); } else { #ifdef USE_SPINLOCK - spin_lock(&NSSMPK_spinlock.NSL_spinlock); + spin_lock( &NSSMPK_spinlock.NSL_spinlock); +// NSSMPK_spinlock.NSL_flags = kSpinLockDisable( &NSSMPK_spinlock.NSL_spinlock); +// kMutexLock(NSSMPK_spinlock.NSL_mutex); +#else + kSemaphoreWait( &NSSMPK_spinlock.NSL_semaphore); #endif } - NSSMPK_spinlock.NSL_owner = currentThreadId(); + NSSMPK_spinlock.NSL_owner = (ADDR)current; return TRUE; } -BOOL -NSSMPK_IOwnSpinlock(void) -{ - return NSSMPK_spinlock.NSL_owner == currentThreadId(); -} - -NINT -NSSMPK_UnlockNss(void) +NINT NSSMPK_UnlockNss (void) { if (MeasureSpinLock) { - NINT end; + NINT end; - end = rdtsc_nint(); - eventHistogram(&SpinLockHeld, end - SpinHeldStart); + rdtsc_nint(end); + eventHistogram( &SpinLockHeld, end - SpinHeldStart); } NSSMPK_spinlock.NSL_owner = 0; #ifdef USE_SPINLOCK - spin_unlock(&NSSMPK_spinlock.NSL_spinlock); + spin_unlock( &NSSMPK_spinlock.NSL_spinlock); +// kSpinUnlockRestore( &NSSMPK_spinlock.NSL_spinlock, NSSMPK_spinlock.NSL_flags); +// kMutexUnlock(NSSMPK_spinlock.NSL_mutex); +#else + kSemaphoreSignal( &NSSMPK_spinlock.NSL_semaphore); #endif return TRUE; } -void -DBG_SaveSpinLock(void) -{ -} +#endif -void -DBG_RestoreSpinLock(void) -{ -} +#else // #if MPK_REAL IS_ENABLED -void -DBG_DumpSpinLock(struct ScreenStruct *debugScreen) -{ - (void)debugScreen; -} +int NSSMPK_spinlock; +void NSSMPK_InitNsslock(void) {} +NINT NSSMPK_UnlockNss(void) {return TRUE;} +NINT NSSMPK_LockNss(void) {return TRUE;} +NINT NSSMPK_LockNssNoInterrupts(void) {return TRUE;} -void -nssInitializeSpinLockCode(void) -{ - NSSMPK_InitNsslock(); -} +#if NSS_DEBUG IS_DISABLED +EXPORT_SYMBOL(MeasureSpinLock); -void -nssSpinLock(void) -{ - (void)NSSMPK_LockNss(); -} +struct PCLSwitchDef_s; -void -nssSpinUnlock(void) -{ - (void)NSSMPK_UnlockNss(); -} +STATUS doSpinLockInstEnable ( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) { return( zOK ); } +EXPORT_SYMBOL(doSpinLockInstEnable); + +STATUS doSpinLockInstDisplay ( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) { return( zOK ); } +EXPORT_SYMBOL(doSpinLockInstDisplay); + +STATUS doSpinLockInstReset ( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) { return( zOK ); } +EXPORT_SYMBOL(doSpinLockInstReset); +#endif + +#endif diff --git a/src/nwnss/library/os/snooze.c b/src/nwnss/library/os/snooze.c index 581bafb..c248f37 100644 --- a/src/nwnss/library/os/snooze.c +++ b/src/nwnss/library/os/snooze.c @@ -33,15 +33,17 @@ |--------------------------------------------------------------------------- | This module is used to: | Routines to let threads snooze for a few seconds while they wait - | for an event to occur. + | for an event to occur. | +-------------------------------------------------------------------------*/ -#include +#include -#include -#include -#include +#include "xError.h" + +#include "alarm.h" +#include "schedule.h" +#include "que.h" /* * Do we want to play with FSMs? @@ -80,7 +82,7 @@ STATUS snoozeSec (DQhead_t *list, NINT seconds) snooze.thread = ThreadId(); snooze.status = zOK; INIT_ONESHOT(snooze.alarm); - secOneShot( &snooze.alarm, seconds, (voidfunc_t)snoozeTimeOut); + secOneShot( &snooze.alarm, seconds, snoozeTimeOut); Wait(); diff --git a/src/nwnss/library/os/worktodo.c b/src/nwnss/library/os/worktodo.c index 1971d87..bd1b126 100644 --- a/src/nwnss/library/os/worktodo.c +++ b/src/nwnss/library/os/worktodo.c @@ -34,11 +34,11 @@ | This module is used to: | NSS Library source +-------------------------------------------------------------------------*/ -#include +#include "procdefs.h" /* NetWare Includes*/ -#include -#include -#include +#include "register.h" /* NSS Library Includes*/ +#include "schedule.h" +#include "stdlib.h" /* diff --git a/src/nwnss/library/parse/pcmdline.c b/src/nwnss/library/parse/pcmdline.c index 7237784..e86c37d 100644 --- a/src/nwnss/library/parse/pcmdline.c +++ b/src/nwnss/library/parse/pcmdline.c @@ -34,38 +34,21 @@ | This module is used to: | NSS Library source +-------------------------------------------------------------------------*/ -#include -#include +#include +#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include #include #include -#include #if zLINUX #include #endif - -#define aprintf LB_aprintf -#define errPrintf LB_errPrintf -#define memicmp LB_memicmp -#define stricmp LB_stricmp -#define strmcpy LB_strmcpy -#define strupr LB_strupr -#define vaprintf LB_vaprintf - /*------------------------------------------------------------------------- * Internal structure used to pass parameter among the internal routines *-------------------------------------------------------------------------*/ @@ -113,8 +96,8 @@ LONG NSSSetParmCategory; /* Define a stucture containing the titles that will be used when listing * the categories of help command. These strings must correspond in number and * order to the bit positions defined in pcmdline.h */ - -char *CmdLineCategories[SWHELP_CAT_COUNT] = + +char *CmdLineCategories[SWHELP_CAT_COUNT] = { MSGNot("\nMAINTENANCE PARAMETERS\n"), MSGNot("\nSTATUS PARAMETERS\n"), @@ -173,7 +156,7 @@ STATIC NINT pclGetNextToken( break; } else if (ch == '"') /* double quote*/ - { + { indq = !indq; pclAddChar(state,ch); leadingSpace = FALSE; @@ -272,7 +255,7 @@ STATIC void pclAllocSwitchvalue( switch(datatype) { case SWVAL_NINT: - case SWVAL_SNINT: + case SWVAL_SNINT: size = sizeof(NINT); break; case SWVAL_QUAD: @@ -366,7 +349,7 @@ STATIC void pclAllocSwitchvalue( qvalue = strtoq(str,NULL,0); break; - case SWVAL_SNINT: + case SWVAL_SNINT: case SWVAL_SLONG: case SWVAL_SWORD: case SWVAL_SBYTE: @@ -394,7 +377,7 @@ STATIC void pclAllocSwitchvalue( } *(NINT *)swdef->ret_value = (NINT)value; break; - case SWVAL_SNINT: + case SWVAL_SNINT: if (swdef->type & SWOPT_HAS_NUMERIC_RANGE) { if ((SNINT)value < (SNINT)swdef->vtype.numeric.minValue) @@ -566,7 +549,7 @@ STATIC PCLSwitchDef_s *pclMatchUnique( LocalState_s *state, NINT swtype, char *str) -{ +{ PCLSwitchDef_s *found; PCLSwitchDef_s *swdef; NINT sl; @@ -620,7 +603,7 @@ doneChecking: } else #endif - if ((found->type & SWOPT_RUNTIME_ONLY) && + if ((found->type & SWOPT_RUNTIME_ONLY) && (state->parseOptions & POPT_AT_STARTUP)) { found = (PCLSwitchDef_s *)MATCH_NOT_RUNTIME; @@ -854,7 +837,7 @@ STATUS LB_ParseCmdlineMulti( { for (;swdef->name != PCMDLINE_ENDOFLIST;swdef++) { - swdef->type &= SWTYPE_SET_START; /* init flag state */ + swdef->type &= SWTYPE_SET_START; /* init flag state */ if ((swdef->groupValue != 0) && !(swdef->type & SWPRV_GROUP_CHILD)) { val = swdef->groupValue; @@ -980,10 +963,10 @@ STATUS LB_ParseCmdlineMulti( { for (;swdef->name != PCMDLINE_ENDOFLIST;swdef++) { - if ((swdef->setParmName != NULL) && + if ((swdef->setParmName != NULL) && (swdef->type & SWPRV_SPECIFIED)) { - status = SetSetableParameterValue(0, + status = SetSetableParameterValue(0, swdef->setParmName, swdef->ret_value); } } @@ -1073,7 +1056,7 @@ STATIC void pclGetDisplayableReturnValue( case SWVAL_NINT: value = *(NINT *)swdef->ret_value; break; - case SWVAL_SNINT: + case SWVAL_SNINT: svalue = *(SNINT *)swdef->ret_value; break; case SWVAL_QUAD: @@ -1114,7 +1097,7 @@ STATIC void pclGetDisplayableReturnValue( sprintf(outstr,MSGNot("%u"),(NINT)value); break; - case SWVAL_SNINT: + case SWVAL_SNINT: case SWVAL_SQUAD: case SWVAL_SLONG: case SWVAL_SWORD: @@ -1135,7 +1118,7 @@ STATIC void pclGetDisplayableReturnValue( /************************************************************************** - * + * ***************************************************************************/ STATIC void pclHelpValuesCheck( char *buffer, @@ -1167,7 +1150,7 @@ STATIC void pclHelpValuesCheck( if (hasHeader) /* only do this if they put in a header */ { strcat(buffer,MSGNot("]")); - hasHeader = FALSE; + hasHeader = FALSE; } } } @@ -1178,7 +1161,7 @@ STATIC void pclHelpValuesCheck( * This will display one line of help. ***************************************************************************/ STATIC void pclDisplayHelpLine( - PCLSwitchDef_s *swdef, + PCLSwitchDef_s *swdef, char **messageTable, NINT initialIndent, NINT options) @@ -1200,7 +1183,7 @@ STATIC void pclHelpValuesCheck( aprintf(LRED, MSGNot("Message will not fit in line buffer\n")); return; } - + switch (GET_SWTYPE(swdef->type)) { @@ -1235,7 +1218,7 @@ STATIC void pclHelpValuesCheck( /*------------------------------------------------------------------------- * Calculate the current default value if available. *-------------------------------------------------------------------------*/ - + if (!(swdef->type & SWOPT_NO_HELP_VALUE)) { /* put in there help string */ @@ -1266,8 +1249,8 @@ STATIC void pclHelpValuesCheck( sprintf(&strbuf[strlen(strbuf)],MSG("Range=%u-%u", 160), swdef->vtype.numeric.minValue, swdef->vtype.numeric.maxValue); - } - pclHelpValuesCheck(strbuf,HELPOPT_TRAILER); + } + pclHelpValuesCheck(strbuf,HELPOPT_TRAILER); helpStr = strbuf; } else @@ -1283,8 +1266,8 @@ STATIC void pclHelpValuesCheck( { remLength = strlen(helpStr); /* if the line will fit, print it. If it won't fit, back off to the - * closest space. If not spaces found, enforce a wrap point - */ + * closest space. If not spaces found, enforce a wrap point + */ if(remLength <= spaceAvail) { endStr = helpStr + remLength; @@ -1298,10 +1281,10 @@ STATIC void pclHelpValuesCheck( { endStr = helpStr + spaceAvail; } - } + } for(;helpStr != endStr; helpStr++) aprintf(LGREEN,MSGNot("%c"), *helpStr); - aprintf(LGREEN, MSGNot("\n")); + aprintf(LGREEN, MSGNot("\n")); while(*helpStr == ' ') helpStr++; if(*helpStr) @@ -1311,7 +1294,7 @@ STATIC void pclHelpValuesCheck( } LB_delay(2); } - } + } else { aprintf(LGREEN, MSGNot("\n")); @@ -1395,8 +1378,8 @@ STATIC void pclDisplayHelpLine( sprintf(&strbuf[strlen(strbuf)],MSG("Range=%u-%u", 160), swdef->vtype.numeric.minValue, swdef->vtype.numeric.maxValue); - } - pclHelpValuesCheck(strbuf,HELPOPT_TRAILER); + } + pclHelpValuesCheck(strbuf,HELPOPT_TRAILER); outstr = strbuf; } else @@ -1427,7 +1410,7 @@ void LB_DisplayCmdlineHelpMulti( NINT sl; NINT row,col; NINT displayMask; - + PCLSwitchDef_s *swdef; /* switch definitions array*/ CmdNameSort_s (*sortArray)[]; /* sorted list of command pointers */ @@ -1453,7 +1436,7 @@ void LB_DisplayCmdlineHelpMulti( { for (;swdef->name != PCMDLINE_ENDOFLIST;swdef++) { - swdef->type &= SWTYPE_SET_START; /* init flag state */ + swdef->type &= SWTYPE_SET_START; /* init flag state */ } } /* Run through the list to find how many command lines we'll need to keep track of. */ @@ -1477,7 +1460,7 @@ void LB_DisplayCmdlineHelpMulti( cmdCnt++; } } - } + } if((cmdCnt == 0) || ((sortArray = malloc(cmdCnt * sizeof(CmdNameSort_s))) == NULL)) return; @@ -1493,7 +1476,7 @@ void LB_DisplayCmdlineHelpMulti( (!(options & POPT_AT_STARTUP))) && /* ((!(swdef->type & SWOPT_STARTUP_ONLY)) || ((options & POPT_AT_STARTUP))) && */ - + (((!hiddenFlag) && ((swdef->type & SWOPT_HIDDEN) == 0))|| (hiddenFlag && (swdef->type & SWOPT_HIDDEN))) && @@ -1505,15 +1488,15 @@ void LB_DisplayCmdlineHelpMulti( } } } - } - - /* bubble sort the array by switch names */ + } + + /* bubble sort the array by switch names */ lastIndex = cmdCnt - 1; for (sl=0; sl < lastIndex; sl++) { for (j=0; j < lastIndex - sl; j++) { - if(strcmp((*sortArray)[j].swdef->name, (*sortArray)[j+1].swdef->name) > 0) + if(strcmp((*sortArray)[j].swdef->name, (*sortArray)[j+1].swdef->name) > 0) { msgTable = (*sortArray)[j].msgTable; swdef = (*sortArray)[j].swdef; @@ -1563,7 +1546,7 @@ void LB_DisplayCmdlineHelpMulti( /*------------------------------------------------------------------------- * Free up to sort array *-------------------------------------------------------------------------*/ - free (sortArray); + free (sortArray); } /************************************************************************** @@ -1571,15 +1554,15 @@ void LB_DisplayCmdlineHelpMulti( * to display help for. ***************************************************************************/ void LB_DisplayCmdlineHelp( - PCLSwitchDef_s *swdef, + PCLSwitchDef_s *swdef, char **messageTable, NINT options, char *title, ...) { va_list args; - PCLMultiSwitchList_s multiArray[2]; - + PCLMultiSwitchList_s multiArray[2]; + if (title != NULL) { va_start(args,title); @@ -1589,7 +1572,7 @@ void LB_DisplayCmdlineHelp( multiArray[0].swList = swdef; multiArray[0].messageTable = messageTable; multiArray[0].moduleName = NULL; - multiArray[1].swList = NULL; + multiArray[1].swList = NULL; LB_DisplayCmdlineHelpMulti(&multiArray[0],options,FALSE,NULL); } @@ -1619,25 +1602,25 @@ void LB_RegisterSetParmsForNSS( ZOS_RegisterSetParameter(ccode, (LONG)COMN_Resource.moduleHandle, - COMN_Resource.setCmdRTag, - NSSSetParmCategory, - NULL, - swdef->setParmFlags, - (LONG *)swdef->ret_value, - swdef->setParmName, - msgTable ? - StructGetMSGStrWithTable(swdef->helpStr,msgTable) : + COMN_Resource.setCmdRTag, + NSSSetParmCategory, + NULL, + swdef->setParmFlags, + (LONG *)swdef->ret_value, + swdef->setParmName, + msgTable ? + StructGetMSGStrWithTable(swdef->helpStr,msgTable) : StructGetMSGStr(swdef->helpStr), - swdef->setParmType, - swdef->vtype.numeric.minValue, + swdef->setParmType, + swdef->vtype.numeric.minValue, swdef->vtype.numeric.maxValue); if (ccode != 0) { errPrintf(WHERE, LibModule, 636, - MSG("Could not register (Status = %d) set parameter: %s", + MSG("Could not register (Status = %d) set parameter: %s", 196), ccode, swdef->setParmName); } - + } } } @@ -1648,9 +1631,9 @@ void LB_RegisterSetParmsForNSS( * This routine is called to register set parameter options for NSS. ***************************************************************************/ void LB_UnRegisterSetParmsForNSS( - PCLSwitchDef_s *swlist) + PCLSwitchDef_s *swlist) { - PCLSwitchDef_s *swdef; + PCLSwitchDef_s *swdef; LONG ccode; ASSERT_MPKNSS_LOCK(); @@ -1663,14 +1646,14 @@ void LB_UnRegisterSetParmsForNSS( if (swdef->setParmName) { ZOS_DeRegisterSetParameter(ccode, - (LONG)COMN_Resource.moduleHandle, + (LONG)COMN_Resource.moduleHandle, COMN_Resource.setCmdRTag, NSSSetParmCategory, swdef->setParmName); if (ccode != 0) { errPrintf(WHERE, LibModule, 646, - MSG("Could not deregister (Status = %d) set parameter: %s", + MSG("Could not deregister (Status = %d) set parameter: %s", 197), ccode, swdef->setParmName); } } diff --git a/src/nwnss/library/qdiv.c b/src/nwnss/library/qdiv.c index 5a129cc..dad1a90 100644 --- a/src/nwnss/library/qdiv.c +++ b/src/nwnss/library/qdiv.c @@ -1,417 +1,412 @@ -/**************************************************************************** - | - |*************************************************************************** - | - | Novell Storage Services (NSS) module - | - |--------------------------------------------------------------------------- - | - | $Author: blarsen $ - | $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $ - | - | $RCSfile$ - | $Revision: 1325 $ - | - |--------------------------------------------------------------------------- - | This module is used to: - | Implement the quad division functions - +-------------------------------------------------------------------------*/ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Multiprecision divide. This algorithm is from Knuth vol. 2 (2nd ed), - * section 4.3.1, pp. 257--259. - */ - -#include -//#include -//#include -//#include -//#include - -/* - * Depending on the desired operation, we view a `long long' (aka SQUAD) in - * one or more of the following formats. - */ -union uu { - SQUAD q; /* as a (signed) quad */ - SQUAD uq; /* as an unsigned quad */ - SLONG sl[2]; /* as two signed longs */ - LONG ul[2]; /* as two unsigned longs */ -}; - -/* - * Define high and low longwords. - */ - -#define H 1 -#define L 0 - -/* - * Total number of bits in a SQUAD and in the pieces that make it up. - * These are used for shifting, and also below for halfword extraction - * and assembly. - */ -#define CHAR_BIT 8 -#define QUAD_BITS (sizeof(SQUAD) * CHAR_BIT) -#define LONG_BITS (sizeof(SLONG) * CHAR_BIT) -#define HALF_BITS (sizeof(SLONG) * CHAR_BIT / 2) - -/* - * Extract high and low shortwords from longword, and move low shortword of - * longword to upper half of long, i.e., produce the upper longword of - * ((SQUAD)(x) << (number_of_bits_in_long/2)). (`x' must actually be LONG.) - * - * These are used in the multiply code, to split a longword into upper - * and lower halves, and to reassemble a product as a SQUAD, shifted left - * (sizeof(long)*CHAR_BIT/2). - */ -#define HHALF(x) ((x) >> HALF_BITS) -#define LHALF(x) ((x) & ((1 << HALF_BITS) - 1)) -#define LHUP(x) ((x) << HALF_BITS) - - typedef unsigned int qshift_t; - - - -#define B (1 << HALF_BITS) /* digit base */ - -/* Combine two `digits' to make a single two-digit number. */ -#define COMBINE(_a, _b) (((LONG)(_a) << HALF_BITS) | (_b)) - -/* select a type for digits in base B: use unsigned short if they fit */ -//Brenda -//#if ULONG_MAX == 0xffffffff && USHRT_MAX >= 0xffff -//typedef unsigned short digit; -//#else -typedef LONG digit; -//#endif - -/* - * Shift p[0]..p[len] left `sh' bits, ignoring any bits that - * `fall out' the left (there never will be any such anyway). - * We may assume len >= 0. NOTE THAT THIS WRITES len+1 DIGITS. - */ -static void shl( - register digit *p, - register int len, - register int sh) -{ - register int i; - - for (i = 0; i < len; i++) - p[i] = LHALF(p[i] << sh) | (p[i + 1] >> (HALF_BITS - sh)); - p[i] = LHALF(p[i] << sh); -} - -/* - * __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v. - * - * We do this in base 2-sup-HALF_BITS, so that all intermediate products - * fit within LONG. As a consequence, the maximum length dividend and - * divisor are 4 `digits' in this base (they are shorter if they have - * leading zeros). - */ -QUAD __qdivrem( - QUAD uq, - QUAD vq, - QUAD *arq) -{ - union uu tmp; - digit *u, *v, *q; - register digit v1, v2; - LONG qhat, rhat, t; - int m, n, d, j, i; - digit uspace[5], vspace[5], qspace[5]; - -/* - * Take care of special cases: divide by zero, and u < v. - */ - if (vq == 0) { - /* divide by zero. */ - static volatile const unsigned int zero = 0; - - tmp.ul[H] = tmp.ul[L] = 1 / zero; - if (arq) - *arq = uq; - return (tmp.q); - } - if (uq < vq) { - if (arq) - *arq = uq; - return (0); - } - u = &uspace[0]; - v = &vspace[0]; - q = &qspace[0]; - -/* - * Break dividend and divisor into digits in base B, then - * count leading zeros to determine m and n. When done, we - * will have: - * u = (u[1]u[2]...u[m+n]) sub B - * v = (v[1]v[2]...v[n]) sub B - * v[1] != 0 - * 1 < n <= 4 (if n = 1, we use a different division algorithm) - * m >= 0 (otherwise u < v, which we already checked) - * m + n = 4 - * and thus - * m = 4 - n <= 2 - */ - tmp.uq = uq; - u[0] = 0; - u[1] = HHALF(tmp.ul[H]); - u[2] = LHALF(tmp.ul[H]); - u[3] = HHALF(tmp.ul[L]); - u[4] = LHALF(tmp.ul[L]); - tmp.uq = vq; - v[1] = HHALF(tmp.ul[H]); - v[2] = LHALF(tmp.ul[H]); - v[3] = HHALF(tmp.ul[L]); - v[4] = LHALF(tmp.ul[L]); - for (n = 4; v[1] == 0; v++) { - if (--n == 1) { - LONG rbj; /* r*B+u[j] (not root boy jim) */ - digit q1, q2, q3, q4; - -/* - * Change of plan, per exercise 16. - * r = 0; - * for j = 1..4: - * q[j] = floor((r*B + u[j]) / v), - * r = (r*B + u[j]) % v; - * We unroll this completely here. - */ - t = v[2]; /* nonzero, by definition */ - q1 = u[1] / t; - rbj = COMBINE(u[1] % t, u[2]); - q2 = rbj / t; - rbj = COMBINE(rbj % t, u[3]); - q3 = rbj / t; - rbj = COMBINE(rbj % t, u[4]); - q4 = rbj / t; - if (arq) - *arq = rbj % t; - tmp.ul[H] = COMBINE(q1, q2); - tmp.ul[L] = COMBINE(q3, q4); - return (tmp.q); - } - } - -/* - * By adjusting q once we determine m, we can guarantee that - * there is a complete four-digit quotient at &qspace[1] when - * we finally stop. - */ - for (m = 4 - n; u[1] == 0; u++) - m--; - for (i = 4 - m; --i >= 0;) - q[i] = 0; - q += 4 - m; - -/* - * Here we run Program D, translated from MIX to C and acquiring - * a few minor changes. - * - * * D1: choose multiplier 1 << d to ensure v[1] >= B/2. - */ - d = 0; - for (t = v[1]; t < B / 2; t <<= 1) - d++; - if (d > 0) { - shl(&u[0], m + n, d); /* u <<= d */ - shl(&v[1], n - 1, d); /* v <<= d */ - } -/* - * D2: j = 0. - */ - j = 0; - v1 = v[1]; /* for D3 -- note that v[1..n] are constant */ - v2 = v[2]; /* for D3 */ - do { - register digit uj0, uj1, uj2; - -/* - * D3: Calculate qhat (\^q, in TeX notation). - * Let qhat = min((u[j]*B + u[j+1])/v[1], B-1), and - * let rhat = (u[j]*B + u[j+1]) mod v[1]. - * While rhat < B and v[2]*qhat > rhat*B+u[j+2], - * decrement qhat and increase rhat correspondingly. - * Note that if rhat >= B, v[2]*qhat < rhat*B. - */ - uj0 = u[j + 0]; /* for D3 only -- note that u[j+...] change */ - uj1 = u[j + 1]; /* for D3 only */ - uj2 = u[j + 2]; /* for D3 only */ - if (uj0 == v1) { - qhat = B; - rhat = uj1; - goto qhat_too_big; - } else { - LONG nn = COMBINE(uj0, uj1); - qhat = nn / v1; - rhat = nn % v1; - } - while (v2 * qhat > COMBINE(rhat, uj2)) { -qhat_too_big: - qhat--; - if ((rhat += v1) >= B) - break; - } -/* - * D4: Multiply and subtract. - * The variable `t' holds any borrows across the loop. - * We split this up so that we do not require v[0] = 0, - * and to eliminate a final special case. - */ - for (t = 0, i = n; i > 0; i--) { - t = u[i + j] - v[i] * qhat - t; - u[i + j] = LHALF(t); - t = (B - HHALF(t)) & (B - 1); - } - t = u[j] - t; - u[j] = LHALF(t); -/* - * D5: test remainder. - * There is a borrow if and only if HHALF(t) is nonzero; - * in that (rare) case, qhat was too large (by exactly 1). - * Fix it by adding v[1..n] to u[j..j+n]. - */ - if (HHALF(t)) { - qhat--; - for (t = 0, i = n; i > 0; i--) { /* D6: add back. */ - t += u[i + j] + v[i]; - u[i + j] = LHALF(t); - t = HHALF(t); - } - u[j] = LHALF(u[j] + t); - } - q[j] = qhat; - } while (++j <= m); /* D7: loop on j. */ - -/* - * If caller wants the remainder, we have to calculate it as - * u[m..m+n] >> d (this is at most n digits and thus fits in - * u[m+1..m+n], but we may need more source digits). - */ - if (arq) { - if (d) { - for (i = m + n; i > m; --i) - u[i] = (u[i] >> d) | LHALF(u[i - 1] << (HALF_BITS - d)); - u[i] = 0; - } - tmp.ul[H] = COMBINE(uspace[1], uspace[2]); - tmp.ul[L] = COMBINE(uspace[3], uspace[4]); - *arq = tmp.q; - } - - tmp.ul[H] = COMBINE(qspace[1], qspace[2]); - tmp.ul[L] = COMBINE(qspace[3], qspace[4]); - return (tmp.q); -} - -/* - * Return remainder after dividing two unsigned quads. - */ -QUAD __umoddi3( - QUAD a, - QUAD b) -{ - QUAD r; - - (void)__qdivrem(a, b, &r); - return (r); -} - -/* - * Divide two unsigned quads. - */ -QUAD __udivdi3( - QUAD a, - QUAD b) -{ - return (__qdivrem(a, b, (QUAD *)0)); -} - -/* - * Return remainder after dividing two signed quads. - * - * The original NSS source typed these compiler-helper arguments as QUAD. - * In this userspace build QUAD is unsigned, so keep the exported helper names - * but type the signed helper arguments as SQUAD to preserve the documented - * signed division semantics. - * - * If -1/2 should produce -1 on this machine, this code is wrong. - */ -SQUAD __moddi3( - SQUAD a, - SQUAD b) -{ - QUAD ua, ub, ur; - int neg; - - if (a < 0) - ua = -(QUAD)a, neg = 1; - else - ua = a, neg = 0; - if (b < 0) - ub = -(QUAD)b; - else - ub = b; - (void)__qdivrem(ua, ub, &ur); - return (neg ? -ur : ur); -} - -/* - * Divide two signed quads. - * if -1/2 should produce -1 on this machine, this code is wrong - */ -SQUAD __divdi3( - SQUAD a, - SQUAD b) -{ - QUAD ua, ub, uq; - int neg; - - if (a < 0) - ua = -(QUAD)a, neg = 1; - else - ua = a, neg = 0; - if (b < 0) - ub = -(QUAD)b, neg ^= 1; - else - ub = b; - uq = __qdivrem(ua, ub, (QUAD *)0); - return (neg ? -uq : uq); -} +/**************************************************************************** + | + |*************************************************************************** + | + | Novell Storage Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $ + | + | $RCSfile$ + | $Revision: 1325 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Implement the quad division functions + +-------------------------------------------------------------------------*/ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Multiprecision divide. This algorithm is from Knuth vol. 2 (2nd ed), + * section 4.3.1, pp. 257--259. + */ + +#include +//#include +//#include +//#include +//#include + +/* + * Depending on the desired operation, we view a `long long' (aka SQUAD) in + * one or more of the following formats. + */ +union uu { + SQUAD q; /* as a (signed) quad */ + SQUAD uq; /* as an unsigned quad */ + SLONG sl[2]; /* as two signed longs */ + LONG ul[2]; /* as two unsigned longs */ +}; + +/* + * Define high and low longwords. + */ + +#define H 1 +#define L 0 + +/* + * Total number of bits in a SQUAD and in the pieces that make it up. + * These are used for shifting, and also below for halfword extraction + * and assembly. + */ +#define CHAR_BIT 8 +#define QUAD_BITS (sizeof(SQUAD) * CHAR_BIT) +#define LONG_BITS (sizeof(SLONG) * CHAR_BIT) +#define HALF_BITS (sizeof(SLONG) * CHAR_BIT / 2) + +/* + * Extract high and low shortwords from longword, and move low shortword of + * longword to upper half of long, i.e., produce the upper longword of + * ((SQUAD)(x) << (number_of_bits_in_long/2)). (`x' must actually be LONG.) + * + * These are used in the multiply code, to split a longword into upper + * and lower halves, and to reassemble a product as a SQUAD, shifted left + * (sizeof(long)*CHAR_BIT/2). + */ +#define HHALF(x) ((x) >> HALF_BITS) +#define LHALF(x) ((x) & ((1 << HALF_BITS) - 1)) +#define LHUP(x) ((x) << HALF_BITS) + + typedef unsigned int qshift_t; + + + +#define B (1 << HALF_BITS) /* digit base */ + +/* Combine two `digits' to make a single two-digit number. */ +#define COMBINE(_a, _b) (((LONG)(_a) << HALF_BITS) | (_b)) + +/* select a type for digits in base B: use unsigned short if they fit */ +//Brenda +//#if ULONG_MAX == 0xffffffff && USHRT_MAX >= 0xffff +//typedef unsigned short digit; +//#else +typedef LONG digit; +//#endif + +/* + * Shift p[0]..p[len] left `sh' bits, ignoring any bits that + * `fall out' the left (there never will be any such anyway). + * We may assume len >= 0. NOTE THAT THIS WRITES len+1 DIGITS. + */ +static void shl( + register digit *p, + register int len, + register int sh) +{ + register int i; + + for (i = 0; i < len; i++) + p[i] = LHALF(p[i] << sh) | (p[i + 1] >> (HALF_BITS - sh)); + p[i] = LHALF(p[i] << sh); +} + +/* + * __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v. + * + * We do this in base 2-sup-HALF_BITS, so that all intermediate products + * fit within LONG. As a consequence, the maximum length dividend and + * divisor are 4 `digits' in this base (they are shorter if they have + * leading zeros). + */ +QUAD __qdivrem( + QUAD uq, + QUAD vq, + QUAD *arq) +{ + union uu tmp; + digit *u, *v, *q; + register digit v1, v2; + LONG qhat, rhat, t; + int m, n, d, j, i; + digit uspace[5], vspace[5], qspace[5]; + +/* + * Take care of special cases: divide by zero, and u < v. + */ + if (vq == 0) { + /* divide by zero. */ + static volatile const unsigned int zero = 0; + + tmp.ul[H] = tmp.ul[L] = 1 / zero; + if (arq) + *arq = uq; + return (tmp.q); + } + if (uq < vq) { + if (arq) + *arq = uq; + return (0); + } + u = &uspace[0]; + v = &vspace[0]; + q = &qspace[0]; + +/* + * Break dividend and divisor into digits in base B, then + * count leading zeros to determine m and n. When done, we + * will have: + * u = (u[1]u[2]...u[m+n]) sub B + * v = (v[1]v[2]...v[n]) sub B + * v[1] != 0 + * 1 < n <= 4 (if n = 1, we use a different division algorithm) + * m >= 0 (otherwise u < v, which we already checked) + * m + n = 4 + * and thus + * m = 4 - n <= 2 + */ + tmp.uq = uq; + u[0] = 0; + u[1] = HHALF(tmp.ul[H]); + u[2] = LHALF(tmp.ul[H]); + u[3] = HHALF(tmp.ul[L]); + u[4] = LHALF(tmp.ul[L]); + tmp.uq = vq; + v[1] = HHALF(tmp.ul[H]); + v[2] = LHALF(tmp.ul[H]); + v[3] = HHALF(tmp.ul[L]); + v[4] = LHALF(tmp.ul[L]); + for (n = 4; v[1] == 0; v++) { + if (--n == 1) { + LONG rbj; /* r*B+u[j] (not root boy jim) */ + digit q1, q2, q3, q4; + +/* + * Change of plan, per exercise 16. + * r = 0; + * for j = 1..4: + * q[j] = floor((r*B + u[j]) / v), + * r = (r*B + u[j]) % v; + * We unroll this completely here. + */ + t = v[2]; /* nonzero, by definition */ + q1 = u[1] / t; + rbj = COMBINE(u[1] % t, u[2]); + q2 = rbj / t; + rbj = COMBINE(rbj % t, u[3]); + q3 = rbj / t; + rbj = COMBINE(rbj % t, u[4]); + q4 = rbj / t; + if (arq) + *arq = rbj % t; + tmp.ul[H] = COMBINE(q1, q2); + tmp.ul[L] = COMBINE(q3, q4); + return (tmp.q); + } + } + +/* + * By adjusting q once we determine m, we can guarantee that + * there is a complete four-digit quotient at &qspace[1] when + * we finally stop. + */ + for (m = 4 - n; u[1] == 0; u++) + m--; + for (i = 4 - m; --i >= 0;) + q[i] = 0; + q += 4 - m; + +/* + * Here we run Program D, translated from MIX to C and acquiring + * a few minor changes. + * + * * D1: choose multiplier 1 << d to ensure v[1] >= B/2. + */ + d = 0; + for (t = v[1]; t < B / 2; t <<= 1) + d++; + if (d > 0) { + shl(&u[0], m + n, d); /* u <<= d */ + shl(&v[1], n - 1, d); /* v <<= d */ + } +/* + * D2: j = 0. + */ + j = 0; + v1 = v[1]; /* for D3 -- note that v[1..n] are constant */ + v2 = v[2]; /* for D3 */ + do { + register digit uj0, uj1, uj2; + +/* + * D3: Calculate qhat (\^q, in TeX notation). + * Let qhat = min((u[j]*B + u[j+1])/v[1], B-1), and + * let rhat = (u[j]*B + u[j+1]) mod v[1]. + * While rhat < B and v[2]*qhat > rhat*B+u[j+2], + * decrement qhat and increase rhat correspondingly. + * Note that if rhat >= B, v[2]*qhat < rhat*B. + */ + uj0 = u[j + 0]; /* for D3 only -- note that u[j+...] change */ + uj1 = u[j + 1]; /* for D3 only */ + uj2 = u[j + 2]; /* for D3 only */ + if (uj0 == v1) { + qhat = B; + rhat = uj1; + goto qhat_too_big; + } else { + LONG nn = COMBINE(uj0, uj1); + qhat = nn / v1; + rhat = nn % v1; + } + while (v2 * qhat > COMBINE(rhat, uj2)) { +qhat_too_big: + qhat--; + if ((rhat += v1) >= B) + break; + } +/* + * D4: Multiply and subtract. + * The variable `t' holds any borrows across the loop. + * We split this up so that we do not require v[0] = 0, + * and to eliminate a final special case. + */ + for (t = 0, i = n; i > 0; i--) { + t = u[i + j] - v[i] * qhat - t; + u[i + j] = LHALF(t); + t = (B - HHALF(t)) & (B - 1); + } + t = u[j] - t; + u[j] = LHALF(t); +/* + * D5: test remainder. + * There is a borrow if and only if HHALF(t) is nonzero; + * in that (rare) case, qhat was too large (by exactly 1). + * Fix it by adding v[1..n] to u[j..j+n]. + */ + if (HHALF(t)) { + qhat--; + for (t = 0, i = n; i > 0; i--) { /* D6: add back. */ + t += u[i + j] + v[i]; + u[i + j] = LHALF(t); + t = HHALF(t); + } + u[j] = LHALF(u[j] + t); + } + q[j] = qhat; + } while (++j <= m); /* D7: loop on j. */ + +/* + * If caller wants the remainder, we have to calculate it as + * u[m..m+n] >> d (this is at most n digits and thus fits in + * u[m+1..m+n], but we may need more source digits). + */ + if (arq) { + if (d) { + for (i = m + n; i > m; --i) + u[i] = (u[i] >> d) | LHALF(u[i - 1] << (HALF_BITS - d)); + u[i] = 0; + } + tmp.ul[H] = COMBINE(uspace[1], uspace[2]); + tmp.ul[L] = COMBINE(uspace[3], uspace[4]); + *arq = tmp.q; + } + + tmp.ul[H] = COMBINE(qspace[1], qspace[2]); + tmp.ul[L] = COMBINE(qspace[3], qspace[4]); + return (tmp.q); +} + +/* + * Return remainder after dividing two unsigned quads. + */ +QUAD __umoddi3( + QUAD a, + QUAD b) +{ + QUAD r; + + (void)__qdivrem(a, b, &r); + return (r); +} + +/* + * Divide two unsigned quads. + */ +QUAD __udivdi3( + QUAD a, + QUAD b) +{ + return (__qdivrem(a, b, (QUAD *)0)); +} + +/* + * Return remainder after dividing two signed quads. + * + * If -1/2 should produce -1 on this machine, this code is wrong. + */ +SQUAD __moddi3( + QUAD a, + QUAD b) +{ + QUAD ua, ub, ur; + int neg; + + if (a < 0) + ua = -(QUAD)a, neg = 1; + else + ua = a, neg = 0; + if (b < 0) + ub = -(QUAD)b; + else + ub = b; + (void)__qdivrem(ua, ub, &ur); + return (neg ? -ur : ur); +} + +/* + * Divide two signed quads./* + * if -1/2 should produce -1 on this machine, this code is wrong/* + */ +SQUAD __divdi3( + QUAD a, + QUAD b) +{ + QUAD ua, ub, uq; + int neg; + + if (a < 0) + ua = -(QUAD)a, neg = 1; + else + ua = a, neg = 0; + if (b < 0) + ub = -(QUAD)b, neg ^= 1; + else + ub = b; + uq = __qdivrem(ua, ub, (QUAD *)0); + return (neg ? -uq : uq); +} diff --git a/src/nwnss/library/stdio/aprintf.c b/src/nwnss/library/stdio/aprintf.c index af742a7..f2d6fb9 100644 --- a/src/nwnss/library/stdio/aprintf.c +++ b/src/nwnss/library/stdio/aprintf.c @@ -34,7 +34,7 @@ | This module is used to: | NSS Library File that implements printf +-------------------------------------------------------------------------*/ -#include +#include /************************************************************************** * This will display a message on the NSS screen @@ -50,3 +50,4 @@ void LB_aprintf( LB__wioOutput(wStdout,attr,format,args); va_end(args); } + diff --git a/src/nwnss/library/stdio/errprintf.c b/src/nwnss/library/stdio/errprintf.c index d015f28..4e66492 100644 --- a/src/nwnss/library/stdio/errprintf.c +++ b/src/nwnss/library/stdio/errprintf.c @@ -34,13 +34,18 @@ | This module is used to: | NSS Library source +-------------------------------------------------------------------------*/ -#include -#include +#include +#include #include #include +#include + +#include + +#ifdef MPK +#include "nssLog.h" +#endif -#include -#include /* * Table of ranges for error numbers -- note: these are not error codes @@ -156,8 +161,8 @@ void LB_errPrintf( (void)NSSLOG_printf( NULL, where, LOG_ERR, NSSLOG_TYPE_ERRPRINTF, -// MSGNot("%s %s%s-%s-%s: %s\n %s" ), - MSGNot("%s %s%s-%s-%s:\n %s" ), +// MSGNot("%s %s%s-%s-%s: %s\n %s" ), + MSGNot("%s %s%s-%s-%s:\n %s" ), UTCTime2Str(GetUTCTime(),aStack->time), COMN_Resource.name, aStack->mname, diff --git a/src/nwnss/library/stdio/getchar.c b/src/nwnss/library/stdio/getchar.c new file mode 100644 index 0000000..bb00e8a --- /dev/null +++ b/src/nwnss/library/stdio/getchar.c @@ -0,0 +1,46 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library File that implements "getchar" + +-------------------------------------------------------------------------*/ +#include + +/************************************************************************** + * This will read and return a single key from the keyboard. + ***************************************************************************/ +int LB_getchar(void) +{ + return wGetc(wStdin); +} + diff --git a/src/nwnss/library/stdio/gets.c b/src/nwnss/library/stdio/gets.c new file mode 100644 index 0000000..9e1e913 --- /dev/null +++ b/src/nwnss/library/stdio/gets.c @@ -0,0 +1,50 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2007-10-06 01:42:31 +0530 (Sat, 06 Oct 2007) $ + | + | $RCSfile$ + | $Revision: 2229 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library File that implements "gets" + +-------------------------------------------------------------------------*/ +#include +#include + +/************************************************************************** + * This routine will get a line from the screen and return it. This will + * not return a line bigger then 256 bytes. + ***************************************************************************/ +char *LB_gets( + char *buf) +{ + strcpy( buf, WHERE ); + return buf; +} + diff --git a/src/nwnss/library/stdio/printf.c b/src/nwnss/library/stdio/printf.c index 57b5461..2155583 100644 --- a/src/nwnss/library/stdio/printf.c +++ b/src/nwnss/library/stdio/printf.c @@ -34,7 +34,7 @@ | This module is used to: | NSS Library File that implements "printf" +-------------------------------------------------------------------------*/ -#include +#include /************************************************************************** * This will display a message on the PSS screen @@ -49,3 +49,4 @@ void LB_printf( LB__wioOutput(wStdout,LGRAY,formatStr,args); va_end(args); } + diff --git a/src/nwnss/library/stdio/snprintf.c b/src/nwnss/library/stdio/snprintf.c index e9aad0c..24c5080 100644 --- a/src/nwnss/library/stdio/snprintf.c +++ b/src/nwnss/library/stdio/snprintf.c @@ -34,9 +34,7 @@ | This module is used to: | NSS Library File that poorly implements "snprintf" +-------------------------------------------------------------------------*/ -#include -#include -#include +#include #include /* NSS Library Includes*/ #include #include @@ -47,26 +45,11 @@ // have been added (i.e. %L). This enables us to have a set of format strings. // -#ifndef CHAR_BIT #define CHAR_BIT 8 -#endif -#ifndef CHAR_MAX #define CHAR_MAX 255 -#endif #include #include -#include -#include - -/* Linux userspace port: snprintf.c uses NSS STACK_ALLOC only for small - * formatter-local work buffers. Keep the original local Stack_s shape, but - * use the automatic-storage path here until the full NSS private stack - * allocator is imported with the scheduler/MPK runtime. */ -#undef STACK_ALLOC -#define STACK_ALLOC() Stack_s localStack; Stack_s *aStack = &localStack; -#undef STACK_FREE -#define STACK_FREE() aStack = NULL; #define NSS_STYLE_FORMAT /* Uses %L to display quads */ @@ -100,7 +83,7 @@ const struct lconv g_C_locale = // the C or en-us locale... TRUE, // char n_cs_precedes; FALSE, // char n_sep_by_space; 0, // char n_sign_posn; - 0, // char reserved; + 0, // char reserved; // 0x40 ----------------------------------- // [International Monetary Conventions] @@ -139,7 +122,7 @@ const struct lconv g_C_locale = // the C or en-us locale... // 0x360 ---------------------------------- }; -struct lconv g_default_locale; +struct lconv g_default_locale; typedef struct lconv LocConv; // sizeof(LocConv) == 0x2C0 (704.) @@ -214,12 +197,12 @@ static int doputb( { if (room) prp->curptr = _qcpy(cp, src, room); // copy what we can - + prp->roomleft = 0; // indicate that we are full prp->total += len; // fake that we copied all of it return 0; } - + if ((room -= len) < INT_MAX) prp->roomleft = room; } @@ -335,7 +318,7 @@ static int revgrp PAD( zero_s, prp->width, prp); prp->width = 0; } - + rc = 0; break; } @@ -430,9 +413,9 @@ int DobprintfNeedsInit = TRUE; // Floating point is not supported (NSS version only) // int dobprint( - FILE_t *fp, + FILE_t *fp, const CHAR *orig_fmt, - va_list ap ) + va_list ap ) { // int isText; // file state for newline expansion, fprintf() // int isConsole; // to output screen, i.e.: printf() @@ -449,7 +432,7 @@ int dobprint( const UCHAR *regfmt; // start of regular characters in 'fmt' va_list_U curpos; // current va_list position uint64_t ull = 0; // 64 bit integer for conversion. - register ADDR ulp = 0; + register ADDR ulp = 0; register uint32_t ul32 = 0; LocConv *loc; // locale (for decimal, grouping, etc. typedef struct Stack_s { @@ -577,11 +560,11 @@ NormalChar : goto OneByte; } -Percent : +Percent : n = fmt - regfmt; /* if there are characters to put out */ if ( n ) { - OUT( regfmt, n * sizeof(CHAR), &pr ); + OUT( regfmt, n * sizeof(CHAR), &pr ); } regular = 0; @@ -810,9 +793,9 @@ Star_set : if (pos_arg_flag) /* first time */ { pos_arg_flag = 0; - + aStack->cached[0] = *(va_list_U *) ≈ - + _parglist(orig_fmt, aStack->cached, NARGS, 0, 0); } @@ -864,14 +847,14 @@ Star_set : if (pr.flags & ffHALF) { short *shortp = va_arg(curpos.ap, short *); - + VALIDATE_AND_ESCAPE(shortp, goto Done); *shortp = pr.total/sizeof(CHAR); } else if (pr.flags & ffHALF_HALF) { char *charp = va_arg(curpos.ap, char *); - + VALIDATE_AND_ESCAPE(charp, goto Done); *charp = pr.total/sizeof(CHAR); } @@ -885,7 +868,7 @@ Star_set : { // This case is for long, int, size_t, and ptrdiff_t long *longp = va_arg(curpos.ap, long *); - + VALIDATE_AND_ESCAPE(longp, goto Done); *longp = pr.total/sizeof(CHAR); } @@ -896,8 +879,8 @@ Star_set : // wchar_t *uptr; // FixFixFix - Vandana needs to address this but I will just... unicode_t *uptr; NINT cnt; - int len; - + int len; + if (regular) goto NormalChar; /* @@ -945,7 +928,7 @@ percentU : len = (pr.flags & ffDOT) ? pr.prec : unilen(uptr) + 1; -XLATE_WC2BC: +XLATE_WC2BC: pr.beg = pr.buf; pr.end = pr.beg; @@ -1003,13 +986,13 @@ XLATE_WC2BC: pr.end = pr.beg + pr.prec + 1; else pr.end = pr.beg + *pr.beg + 1; - + pr.beg++; // point to the beginning of the string - + break; } } - + case 'c': if (regular) goto NormalChar; @@ -1044,7 +1027,7 @@ OneByte : */ if (regular) goto NormalChar; - + if (pr.flags & ffLONG_LONG) goto percentQ; @@ -1082,7 +1065,7 @@ Decimal : pr.prec = 1; pr.end = (unsigned char *) &pr.buf[sizeof(pr.buf)]; - p = &pr.buf[sizeof(pr.buf)]; + p = &pr.buf[sizeof(pr.buf)]; if (ul32) { @@ -1156,7 +1139,7 @@ DecimalDone : case 'p': { int shift; - uint32_t mask; + uint32_t mask; register UCHAR *p; register const uint8_t *digs; @@ -1267,7 +1250,7 @@ Get_pow2 : ull = va_arg(curpos.ap, uint64_t); else ulp = va_arg(curpos.ap, uint32_t); - + if (pr.flags & ffHALF) ulp = (unsigned short) ulp; else if (pr.flags & ffHALF_HALF) @@ -1280,8 +1263,8 @@ Get_pow2 : Number_pow2 : pr.end = (unsigned char *) &pr.buf[sizeof(pr.buf)]; - p = &pr.buf[sizeof(pr.buf)]; - + p = &pr.buf[sizeof(pr.buf)]; + if (pr.flags & ffLONG_LONG) { while (ull != 0) @@ -1350,7 +1333,7 @@ Number_pow2 : break; } - + case 'Q' : { register UCHAR *p; @@ -1365,7 +1348,7 @@ Number_pow2 : ** decimal character. Some this code is used for the %ll specifier, converting ** to hex, etc. */ -percentQ : +percentQ : if (regular) goto NormalChar; @@ -1398,7 +1381,7 @@ LLDecimal : pr.prec = 1; pr.end = (unsigned char *) &pr.buf[sizeof(pr.buf)]; - p = &pr.buf[sizeof(pr.buf)]; + p = &pr.buf[sizeof(pr.buf)]; if (ull) { @@ -1453,7 +1436,7 @@ LLDecimalDone : { Cvt cvt; register uint8_t *p; - + case 'E': pr.flags |= ffCAPS; /*FALLTHROUGH*/ @@ -1472,16 +1455,16 @@ LLDecimalDone : ** ducing the exponent. The exponent always contains at least two digits. If ** the value is zero, the exponent is zero. */ - + SET_LOC(loc); - + cvt.buf = &pr.buf[2]; /* room for sign and radix */ - + if (pr.flags & ffCAPS) cvt.mode = CVT_E | CVT_CAPS; else cvt.mode = CVT_E; - + if (pr.flags & ffDOT) { if ((cvt.ndig = NDIG_DEC) > pr.prec) @@ -1492,11 +1475,11 @@ LLDecimalDone : pr.prec = 6; cvt.ndig = 6 + 1; } - + // use the global values for these down the _cvtl() call path nanStr = NULL; infStr = NULL; - + cvt.val.dval.d = va_arg(curpos.ap, double); p = _cvt(&cvt, nanStr, infStr); @@ -1506,7 +1489,7 @@ LLDecimalDone : NaN_or_Infinity : pr.beg = cvt.buf; pr.end = pr.beg + cvt.len; - + if (cvt.decpt == CVT_INF && pr.prec < cvt.len && pr.width < cvt.len) pr.end = &pr.beg[3]; /* only infinity */ @@ -1527,7 +1510,7 @@ NaN_or_Infinity_signed : pr.prefix = blanks; else pr.prefix = lc_p0x; - + pr.nprefix = 1; pr.flags |= ffBEFORE; } @@ -1562,7 +1545,7 @@ E_Format : pr.prefix = blanks; else pr.prefix = lc_p0x; - + pr.nprefix = 1; pr.flags |= ffBEFORE; } @@ -1585,7 +1568,7 @@ E_Format : */ p[-1] = p[0]; p[0] = loc->decimal_point[0]; - + if (pr.prec < cvt.len) /* digits are sufficient */ { if (pr.prec != 0) @@ -1596,7 +1579,7 @@ E_Format : else /* zeros after digits */ { p += --cvt.len; - + if ((pr.nright0 = pr.prec - cvt.len) > &pr.buf[sizeof(pr.buf)] - p) { pr.flags |= ffAFTER; @@ -1616,14 +1599,14 @@ E_Format : { register int n; register uint8_t *cp; - + if ((n = cvt.decpt - 1) < 0) /* radix at +1 */ n = -n; - + cp = &pr.suf[sizeof(pr.suf)]; - + _ULTOS(cp, n); - + if ((n = &pr.suf[sizeof(pr.suf)] - cp) == 1) { *--cp = '0'; @@ -1642,27 +1625,27 @@ E_Format : else { p += 2; - + do { *++p = *cp; } while (++cp < &pr.suf[sizeof(pr.suf)]); - + cp = p - (n + 1); } - + if (cvt.decpt <= 0) cp[1] = '-'; else cp[1] = '+'; - + if (pr.flags & ffCAPS) cp[0] = 'E'; else cp[0] = 'e'; } - + pr.end = p + 1; break; case 'F': @@ -1683,14 +1666,14 @@ E_Format : */ SET_LOC( loc); - + cvt.buf = &pr.buf[2]; /* room for sign and radix */ - + if (pr.flags & ffCAPS) cvt.mode = CVT_F | CVT_CAPS; else cvt.mode = CVT_F; - + if (pr.flags & ffDOT) { if ((cvt.ndig = NDIG_DEC) > pr.prec) @@ -1701,14 +1684,14 @@ E_Format : pr.prec = 6; cvt.ndig = 6; } - + // use the global values for these down the _cvtl() call path nanStr = NULL; infStr = NULL; - + cvt.val.dval.d = va_arg(curpos.ap, double); p = _cvt(&cvt, nanStr, infStr); - + #ifdef _IEEE if (p == 0) /* NaN or Infinity */ goto NaN_or_Infinity; @@ -1735,19 +1718,19 @@ FloatingPointFormat : pr.beg = &pr.buf[1]; /* leave room for prefix */ pr.buf[1] = '0'; cvt.decpt = -cvt.decpt; - + if (pr.prec <= sizeof(pr.buf) - 3) { /* room for radix, 0s, digits, and 0s */ pr.end = &pr.buf[3] + pr.prec; - + if (!cvt.len || cvt.decpt >= pr.prec) { /* all zero result */ if (pr.prec) /* zero fill */ { p = &pr.buf[2]; - + do { *++p = '0'; @@ -1762,13 +1745,13 @@ FloatingPointFormat : else /* decpt buffer, w/digits */ { register uint8_t *cp = &pr.suf[0]; - + pr.flags |= ffAFTER; pr.suffix = cp; pr.prec -= cvt.decpt; - + if ((pr.nsuffix = pr.prec) > cvt.len) { /* use special zero-padding suffix */ pr.nsuf0 = pr.nsuffix - cvt.len; - + do { *cp++ = *p++; @@ -1847,14 +1830,14 @@ FloatingPointFormat : else /* enough digits for precision */ { pr.nsuf0 = 0; - + do { *cp++ = *p++; } while (--pr.prec); } - + if (cvt.decpt >= sizeof(pr.buf) - 2) { pr.nright0 = cvt.decpt; @@ -1863,10 +1846,10 @@ FloatingPointFormat : else /* zero fill now */ { p = &pr.buf[2]; - + while (--cvt.decpt >= 0) *++p = '0'; - + pr.end = p + 1; } } @@ -1876,22 +1859,22 @@ FloatingPointFormat : else if (cvt.decpt >= cvt.len) /* all digits on left */ { register size_t sz; - + pr.beg = p; p += cvt.len; cvt.decpt -= cvt.len; sz = &pr.buf[sizeof(pr.buf)] - p; - + if (cvt.decpt < sz) /* at least room for radix */ { sz -= cvt.decpt; - + while (--cvt.decpt >= 0) *p++ = '0'; - + p[0] = loc->decimal_point[0]; pr.radix = p; /* only for ffQUOTE */ - + if (pr.prec == 0) { if ((pr.flags & ffSHARP) == 0) @@ -1908,7 +1891,7 @@ FloatingPointFormat : pr.flags |= ffAFTER; pr.nright0 = pr.prec; } - + pr.end = p + 1; } else /* not enough room to reach radix */ @@ -1918,7 +1901,7 @@ FloatingPointFormat : pr.end = p; /* entire _cvt result */ pr.radix = 0; /* only for ffQUOTE */ pr.nsuffix = 1 + pr.prec; - + if (pr.prec == 0) { if (pr.flags & ffSHARP) @@ -1937,7 +1920,7 @@ FloatingPointFormat : pr.suffix = p = &pr.suf[0]; p[0] = loc->decimal_point[0]; - + do { *++p = '0'; @@ -1958,10 +1941,10 @@ FloatingPointFormat : { pr.beg = p; p += cvt.decpt; - + if (pr.flags & ffSHARP) *p++ = loc->decimal_point[0]; - + pr.end = p; pr.radix = p; /* only for ffQUOTE */ } @@ -1970,16 +1953,16 @@ FloatingPointFormat : /* move digits one to the left until reach radix */ pr.beg = --p; cvt.len -= cvt.decpt; - + do { p[0] = p[1]; } while (++p, --cvt.decpt); - + p[0] = loc->decimal_point[0]; pr.radix = p; /* only for ffQUOTE */ - + if (pr.prec <= cvt.len) { p += pr.prec; /* was rounded */ @@ -1994,18 +1977,18 @@ FloatingPointFormat : { p += cvt.len; pr.prec -= cvt.len; - + do { *++p = '0'; } while (--pr.prec); } - + pr.end = p + 1; } } - + /* add on prefix, if any */ if (pr.flags & ffZERO) { @@ -2021,7 +2004,7 @@ FloatingPointFormat : pr.prefix = blanks; else pr.prefix = lc_p0x; - + pr.nprefix = 1; pr.flags |= ffBEFORE; } @@ -2040,7 +2023,7 @@ FloatingPointFormat : if (pr.flags & ffQUOTE) goto Quote; break; - + case 'G': pr.flags |= ffCAPS; /*FALLTHROUGH*/ @@ -2059,14 +2042,14 @@ FloatingPointFormat : ** only if it is followed by a digit. */ SET_LOC( loc); - + cvt.buf = &pr.buf[2]; /* room for sign and radix */ - + if (pr.flags & ffCAPS) cvt.mode = CVT_E | CVT_CAPS; else cvt.mode = CVT_E; - + if (pr.flags & ffDOT) { if ((cvt.ndig = NDIG_DEC) > pr.prec) @@ -2081,10 +2064,10 @@ FloatingPointFormat : pr.prec = cvt.ndig = 6; } - + nanStr = NULL; infStr = NULL; - + cvt.val.dval.d = va_arg(curpos.ap, double); p = _cvt(&cvt, nanStr, infStr); @@ -2094,7 +2077,7 @@ FloatingPointFormat : #endif { register size_t n = pr.prec; - + if ((pr.flags & ffSHARP) == 0) { if (cvt.len < n) @@ -2106,7 +2089,7 @@ FloatingPointFormat : } while (--n); } - + if (cvt.decpt > 0) { if (cvt.decpt > pr.prec) @@ -2114,7 +2097,7 @@ FloatingPointFormat : pr.prec = n - 1; goto E_Format; } - + if (cvt.decpt >= n) { pr.prec = 0; @@ -2126,7 +2109,7 @@ FloatingPointFormat : pr.prec = n - 1; goto E_Format; } - + /* know that -4 < cvt.decpt < n, thus pr.prec will be [1,n+3] */ pr.prec = n - cvt.decpt; goto FloatingPointFormat; @@ -2239,7 +2222,7 @@ Done : Exit : va_end(curpos.ap); - + if (rc > 0) { rc /= sizeof(CHAR); // return number of characters (not bytes) written @@ -2361,7 +2344,7 @@ void _parglist( if (*s == '$') // move to specified argument { - if ((n = atoi(x + 1)) <= 0)// bad position + if ((n = LB_atoi(x + 1)) <= 0)// bad position n = 1; argno = n; } @@ -2409,13 +2392,13 @@ Again : ** Positional width or precision. Always has 'int' type: Default ** behavior does the right stuff. */ - if (high == 0 && (n = atoi(s)) > 0 && n <= len && n > maxpos) + if (high == 0 && (n = LB_atoi(s)) > 0 && n <= len && n > maxpos) maxpos = n; while (++s, isdigit(*s)) ; - goto Again; // *s should be '$' + goto Again; // *s should be '$' } n = '*'; @@ -2454,7 +2437,7 @@ Again : continue; // bogus spec. type = T_LPTR; break; - + case 'X': case 'b': case 'd': @@ -2640,7 +2623,7 @@ int LB_snprintf( va_end(args); *stfp.ptr = 0; - + return rc; } @@ -2677,6 +2660,6 @@ int LB_vsnprintf( rc = dobprint( &stfp, fmt, args); *stfp.ptr = 0; - + return rc; } diff --git a/include/nwnss/library/stdio/snprintf.h b/src/nwnss/library/stdio/snprintf.h similarity index 99% rename from include/nwnss/library/stdio/snprintf.h rename to src/nwnss/library/stdio/snprintf.h index 2767861..0a4ca0f 100644 --- a/include/nwnss/library/stdio/snprintf.h +++ b/src/nwnss/library/stdio/snprintf.h @@ -38,8 +38,7 @@ #ifndef _SNPRINTF_H_ #define _SNPRINTF_H_ -#include -#include +#include #ifdef __cplusplus extern "C" { @@ -156,7 +155,7 @@ extern "C" { #define ffSTAR 0x00020000 // '*' #define ffSIGN 0x00040000 // floating point sign #define ffALLOC 0x00100000 // indicates a temporary allocation -#define ffDASH 0x00200000 // +#define ffDASH 0x00200000 // #define ffAFTER 0x00400000 // #define ffBEFORE 0x00800000 // #define ffBLANK 0x01000000 // @@ -431,7 +430,7 @@ typedef struct _iob // ANSI FILE_t stream structure -typedef struct // used by doprint.c and nwprint.c +typedef struct // used by doprint.c and nwprint.c { // locals shared between _i[w[s]]doprint and other functions FILE_t *fp; // the stream; strings provide fake one unsigned char *curptr; // output placed here diff --git a/src/nwnss/library/stdio/sprintf.c b/src/nwnss/library/stdio/sprintf.c index 3bff28f..fe8fd64 100644 --- a/src/nwnss/library/stdio/sprintf.c +++ b/src/nwnss/library/stdio/sprintf.c @@ -34,11 +34,11 @@ | This module is used to: | NSS Library File that implements "sprintf" +-------------------------------------------------------------------------*/ -#include /* NetWare Include*/ +#include /* NetWare Include*/ -#include /* NSS Library Includes*/ +#include /* NSS Library Includes*/ #include -#include +#include /************************************************************************** * This will display a message into the specified buffer. @@ -59,3 +59,4 @@ void LB_sprintf( va_end(args); } + diff --git a/src/nwnss/library/stdio/vaprintf.c b/src/nwnss/library/stdio/vaprintf.c index 9f2541a..ed9b072 100644 --- a/src/nwnss/library/stdio/vaprintf.c +++ b/src/nwnss/library/stdio/vaprintf.c @@ -34,7 +34,7 @@ | This module is used to: | NSS Library File that implements "printf" +-------------------------------------------------------------------------*/ -#include +#include /************************************************************************** * This will display a message on the PSS screen diff --git a/src/nwnss/library/stdio/vprintf.c b/src/nwnss/library/stdio/vprintf.c index 6aa0067..1f68005 100644 --- a/src/nwnss/library/stdio/vprintf.c +++ b/src/nwnss/library/stdio/vprintf.c @@ -34,7 +34,7 @@ | This module is used to: | NSS Library File that implements "printf" +-------------------------------------------------------------------------*/ -#include +#include /************************************************************************** * This will display a message on the PSS screen diff --git a/src/nwnss/library/stdio/vsprintf.c b/src/nwnss/library/stdio/vsprintf.c index 32b9cde..af5a55b 100644 --- a/src/nwnss/library/stdio/vsprintf.c +++ b/src/nwnss/library/stdio/vsprintf.c @@ -34,11 +34,11 @@ | This module is used to: | NSS Library File that implements "sprintf" +-------------------------------------------------------------------------*/ -#include /* NetWare Include*/ +#include /* NetWare Include*/ -#include /* NSS Library Includes*/ +#include /* NSS Library Includes*/ #include -#include +#include /************************************************************************** * This will display a message on the PSS screen diff --git a/src/nwnss/library/stdlib/exit.c b/src/nwnss/library/stdlib/exit.c index 848cc1c..e216c23 100644 --- a/src/nwnss/library/stdlib/exit.c +++ b/src/nwnss/library/stdlib/exit.c @@ -1,32 +1,80 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) module + | NetWare Advance File Services (NSS) module | |--------------------------------------------------------------------------- | - | Source(s): public_core/library/stdlib/exit.c + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ | |--------------------------------------------------------------------------- - | mars-nwe userspace port note: - | Original Linux NSS already leaves LB_exitMyselfAndReturn as a no-op command - | line/runtime boundary. Standalone userspace NSS cannot kill an NLM/kernel module; - | keep both public exit entry points as no-op status boundaries. + | This module is used to: + | NSS Library source +-------------------------------------------------------------------------*/ -#include +#include /* NetWare Includes*/ -void LB_exitMyselfAndWait(struct LoadDefinitionStructure *moduleHandle, int status) -{ - (void)moduleHandle; - (void)status; -} +#include "xStdlib.h" +//#include "register.h" +#include "schedule.h" -void LB_exitMyselfAndReturn(struct LoadDefinitionStructure *moduleHandle, int status) +/************************************************************************** + * This will kill the current NLM. This should be used if running on + * the nlms own thread. + ***************************************************************************/ +#if zNETWARE +void LB_exitMyselfAndWait( + struct LoadDefinitionStructure *moduleHandle, + int status) { - (void)moduleHandle; - (void)status; + ZOS_KillMe((LONG)moduleHandle); + Wait(); } +#endif + + +/************************************************************************** + * This will kill the current NLM but this does not SLEEP. This should + * be used when running on the console commands thread. + ***************************************************************************/ +#if zNETWARE +void LB_exitMyselfAndReturn( + struct LoadDefinitionStructure *moduleHandle, + int status) +{ + ZOS_KillMe((LONG)moduleHandle); +} +#endif + + +#ifdef __linux__ // LINUX_Exit + // FixFixFix(Linux) - port unless we do not need after we change commandline to be in user space +void LB_exitMyselfAndReturn( + struct LoadDefinitionStructure *moduleHandle, + int status) +{ + return; +} +#endif diff --git a/src/nwnss/library/stdlib/free.c b/src/nwnss/library/stdlib/free.c index 054394b..c36e314 100644 --- a/src/nwnss/library/stdlib/free.c +++ b/src/nwnss/library/stdlib/free.c @@ -1,26 +1,355 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996, 2002 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996, 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) module + | NetWare Advance File Services (NSS) module | |--------------------------------------------------------------------------- | - | Source(s): public_core/library/stdlib/free.c + | $Author: gpachner $ + | $Date: 2005-03-18 23:26:41 +0530 (Fri, 18 Mar 2005) $ + | + | $RCSfile$ + | $Revision: 879 $ | |--------------------------------------------------------------------------- - | mars-nwe userspace port note: - | - | The original file is built on NSS allocation metadata and delayed-free - | debug lists. The standalone userspace NSS allocator currently maps that OS/NSS - | memory boundary to libc, while preserving the public LB_free symbol. + | This module is used to: + | NSS Library source +-------------------------------------------------------------------------*/ -#include +#include /* Netware includes */ -void LB_free(void *ptr) +#include /* NSS Library Fields*/ +#include +#include +#include +#include + +DQhead_t MKL_head = DQ_STATIC_INIT(MKL_head); +BOOL MallocTraceEnable = FALSE; + + +BOOL MKL_Symbols = FALSE; /* TRUE to display symbol of addresses during + * alloc/free calls in =d buffer. When TRUE + * memory calls are very slow because symbol + * lookup is very slow. Storing is only done + * if recording memory allocs/frees in the + * =d buffer. See the global MallocTraceEnable. + */ + +#if MEM_KEEP_LIST IS_ENABLED +DQhead_t MKL_FreeHead = DQ_STATIC_INIT(MKL_FreeHead); + +BOOL MKL_ImediateFreeDefault = FALSE; /* When TRUE we free to OS immediately which + * prevents us from detecting memory use + * after a free. Nakoma OS has added stack + * saving information, but still does not control + * how quickly the memory is re-allocated. + */ +BOOL MKL_ImmediateFree = TRUE; /* !!!! DO NOT CHANGE DEFAULT VALUE !!!! + * Must be TRUE until after timer code inited. + * At which time MKL_ImediateFreeDefault is written + * over the TRUE. + */ +BOOL MKL_StoreCallers = TRUE; /* TRUE to store callers addresses. Not too + * slow. + */ + +BOOL MKL_FreeScheduled = FALSE; + +QUAD MKL_Insert; /* Number of malloc/zalloc/realloc/etc calls */ +QUAD MKL_Remove; /* Number of frees/realloc/etc calls */ +QUAD MKL_FreeToNSS; +QUAD MKL_FreeToOS; +#endif + + +#if MEM_KEEP_LIST IS_ENABLED + +#include "fsm.h" +#include "alarm.h" +#include "xCache.h" + +OneShot_s MKL_FreeOneShot; + +#if 1 +zWorkProc_s MKL_FreeFSMWorkToDoStructure; +#else +FsmLite_s MKL_FreeFSM; +#endif + +void MKL_FreeAlarm( OneShot_s *freeAlarm ); + +int MKL_FreeHoldSeconds = 90; /* Number of seconds to hold NSS freed memory before + * freeing it to the OS. This allows us to + * detect memory use after free. This is a little + * better than the OS check because we still have + * all of our alloc/free caller(owner) information. + */ + +/* + * Free all memory that is old back to the OS. We have been holding + * the memory so that if someone pokes it we still have our caller alloc + * and free history. + */ +void MKL_FreeThread( +#if 1 + zWorkProc_s *work ) +#else + FsmLite_s *freeFSM, + ADDR unused ) +#endif { - free(ptr); + MKL_Header_s *mkl; + +// WORK_PROCESS_INIT(); +// MPKNSS_LOCK(); + + ASSERT_MPKNSS_LOCK(); + zASSERT( MKL_FreeScheduled ); + while ( DQ_NOT_EMPTY(&MKL_FreeHead) ) + { + DQ_PEEK( &MKL_FreeHead, mkl, MKL_Header_s, MH_link); + zASSERT( mkl != NULL ); + if ( ((mkl->MH_freeTime + MKL_FreeHoldSeconds) <= GetUTCTime()) || MKL_ImmediateFree ) + { + NINT i; + NINT longLength; /* Length of USER memory */ + LONG *uMem; + BOOL poked = FALSE; + + longLength = (MKL_ORIG_SIZE(SizeOfAllocBlock(mkl)))/sizeof(LONG); + uMem = MKL_TO_UMEM( mkl ); + /* Validate that memory has not been poked */ + for( i = 0; i < longLength; ++i, ++uMem ) + { + if ( *uMem != FILL_PATTERN ) + { + zASSERT("NSS freed memory has been poked" == NULL ); + poked = TRUE; + break; + } + } + if ( poked ) + { + ZOS_Abend(MSGNot("NSS freed memory has been poked.") ); + } + DQ_RMV(mkl, MH_link); + ++MKL_FreeToOS; + ZOS_Free( mkl ); + } + else + { /* Item not ready to be freed to OS, so set us to + * run again when item will be ready. In a busy + * system with lots of frees this will be in one + * second. + */ + Time_t nextItemTime = MKL_FreeHoldSeconds - (GetUTCTime() - mkl->MH_freeTime); + + if ( nextItemTime > MKL_FreeHoldSeconds ) + { + nextItemTime = MKL_FreeHoldSeconds; + } +// printf("next time %d %lx %lx\n",nextItemTime, GetUTCTime(), mkl->MH_freeTime); + secOneShot( &MKL_FreeOneShot, nextItemTime, MKL_FreeAlarm ); + return; + } + PERIODIC_YIELD(); + } + MKL_FreeScheduled = FALSE; +// MPKNSS_UNLOCK(); + +} /* End of MKL_FreeThread() */ + + +/* + * Alarm must not block so schedule a work-to-do that can block. + */ +void MKL_FreeAlarm( + OneShot_s *freeAlarm ) +{ +#if 1 + fillInWork( &MKL_FreeFSMWorkToDoStructure, MKL_FreeThread, 0); + ScheduleWork( &MKL_FreeFSMWorkToDoStructure ); +#else + FSMLITE_INIT( &MKL_FreeFSM, "NSSDelayedFree", 0 ); + WORK_Schedule( &MKL_FreeFSM, MKL_FreeThread, 0 ); +#endif + } + + +void MKL_ScheduleFree( void ) +{ + ASSERT_MPKNSS_LOCK(); + zASSERT( !MKL_FreeScheduled ); + if ( MKL_FreeScheduled ) + { + return; + } + MKL_FreeScheduled = TRUE; + INIT_ONESHOT( MKL_FreeOneShot ); +// printf("next time %d %lx\n",MKL_FreeHoldSeconds, GetUTCTime() ); + secOneShot( &MKL_FreeOneShot, MKL_FreeHoldSeconds, MKL_FreeAlarm ); +} + + +void MKL_AllocStart( void ) +{ + + MKL_ImmediateFree = MKL_ImediateFreeDefault; + +} +EXPORT_SYMBOL(MKL_AllocStart); + +void MKL_AllocStop( void ) +{ + + MKL_ImmediateFree = TRUE; + MKL_FreeHoldSeconds = 1; + /* Every once in a while we will have to wait for an alarm up to + * the original MKL_FreeHoldSeconds (because the one shot is + * already scheduled). + */ + MKL_ScheduleFree( ); + while ( MKL_FreeScheduled ) + { + LB_delay( 100 ); + } + +} +EXPORT_SYMBOL(MKL_AllocStop); +#endif + + +/************************************************************************** + * Free memory + ***************************************************************************/ +void LB_free( + void *uMem) +{ + void *mkl; + BOOL iOwnSpinlock = MPKNSS_I_OWN_SPINLOCK(); + + zASSERT(!((ADDR)uMem & 0x3)); + +#if MEM_KEEP_LIST IS_ENABLED + if ( uMem == 0 ) + { /* No header if NULL being freed */ + mkl = 0; + } + else + { + mkl = (void *)(((ADDR)uMem) - sizeof( MKL_Header_s )); + } +#else + mkl = uMem; +#endif + + if (iOwnSpinlock) + { + LB_MEMREPORT(MSGNot("free"),mkl,uMem); + if (mkl != NULL) + { + MKL_REMOVE(uMem); + MKL_FREE(mkl); + } + } + else + { +#if MEM_KEEP_LIST IS_ENABLED + MPKNSS_LOCK(); + LB_MEMREPORT(MSGNot("free"),mkl,uMem); + if (uMem != NULL) + { + MKL_REMOVE(uMem); + MKL_FREE(mkl); + } + MPKNSS_UNLOCK(); +#else +#if NSS_DEBUG IS_ENABLED + MPKNSS_LOCK(); + LB_MEMREPORT(MSGNot("free"),mkl,uMem); + MPKNSS_UNLOCK(); +#endif + if (mkl != NULL) + { + Free(mkl); + } +#endif + } +} + +#if MALLOC_TRACE IS_ENABLED && NSS_DEBUG IS_ENABLED +/**************************************************************************** + * + *****************************************************************************/ +void LB_MEMORY_DISPLAY_SETUP(void) +{ + INITDBGIO(); + //wPause(zDbgScreen,-1); + //ReportMallocs = TRUE; +} + +/**************************************************************************** + * + *****************************************************************************/ +void LB_MEMORY_DISPLAY_SHUTDOWN(void) +{ + MallocTraceEnable = FALSE; + //wPause(zDbgScreen,0); +} +#endif + +#if MEM_KEEP_LIST IS_ENABLED +/**************************************************************************** + * this will display all memory that has not been returned by pss + *****************************************************************************/ +void LB_CHECK_FREE_LIST(void) +{ + MKL_Header_s *memleft; + NINT found = 0; + NINT displaycnt = 0; + + DQ_FOREACH(&MKL_head, memleft, MKL_Header_s, MH_link) + { + found++; + displaycnt++; + if(found == 1) + { + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID,YELLOW, + MSGNot("Memory Resources NOT returned by NSS. (below is Location of Allocation)\n")); + } + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID,LGREEN, + MSGNot(" [%x] "), memleft->MH_allocCallers[0]); + if(displaycnt == 6) + { + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID,LGREEN,MSGNot("\n")); + displaycnt = 0; + } + } + if(found != 0) + { + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID,LGREEN, + MSGNot("\nCount of Unreturned memory: %d\n"), found); +// zASSERT(found == 0); + } +} +#endif diff --git a/src/nwnss/library/stdlib/freeForNCPReply.c b/src/nwnss/library/stdlib/freeForNCPReply.c index 8360309..84f0c3f 100644 --- a/src/nwnss/library/stdlib/freeForNCPReply.c +++ b/src/nwnss/library/stdlib/freeForNCPReply.c @@ -1,29 +1,73 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) module + | NetWare Advance File Services (NSS) module | |--------------------------------------------------------------------------- | - | Source(s): public_core/library/stdlib/freeForNCPReply.c + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ | |--------------------------------------------------------------------------- - | mars-nwe userspace port note: - | See mallocForNCPReply.c. Keep the NSS/NCP reply free symbols distinct even - | though the current userspace backing allocator is libc free. + | This module is used to: + | NSS Library source +-------------------------------------------------------------------------*/ -#include +#include /* Netware includes */ -void LB_freeForNCPReply(void *ptr) -{ - free(ptr); -} +#include /* NSS Library Fields*/ +#include +#include +#include +#include -void freeForNCPReply(void *ptr) +/************************************************************************** + * Free memory + ***************************************************************************/ +void freeForNCPReply ( + void *mem) { - LB_freeForNCPReply(ptr); + BOOL iOwnSpinlock = MPKNSS_I_OWN_SPINLOCK(); + + if (iOwnSpinlock) + { + LB_MEMREPORT(MSGNot("free"), mem, mem); + if (mem != NULL) + { + ZOS_Free(mem); + } + } + else + { +#if NSS_DEBUG IS_ENABLED + MPKNSS_LOCK(); + LB_MEMREPORT(MSGNot("free"), mem, mem); + MPKNSS_UNLOCK(); +#endif + if (mem != NULL) + { + Free(mem); + } + } } diff --git a/src/nwnss/library/stdlib/freePage.c b/src/nwnss/library/stdlib/freePage.c index ee450b8..5597f14 100644 --- a/src/nwnss/library/stdlib/freePage.c +++ b/src/nwnss/library/stdlib/freePage.c @@ -1,48 +1,72 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) module + | NetWare Advance File Services (NSS) module | |--------------------------------------------------------------------------- + | | $Author: taysom $ | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | | $RCSfile$ | $Revision: 465 $ | |--------------------------------------------------------------------------- - | This module is used to: - | NSS Library source - | - | mars-nwe userspace port: keep the original freePage helper and provide the - | exported LB_freePage form declared by xStdlib.h. + | This module is used to: + | NSS Library source +-------------------------------------------------------------------------*/ -#include -#include +#include /* NetWare includes*/ +#include + +#include /* NSS Library includes*/ +#include +#include +#include #include /************************************************************************** - * This frees the given number of pages from the NLM. The size of a page - * is defined by PAGE_SIZE. + * This frees the given number of pages from the NLM. The size of a page + * is defined by PAGE_SIZE. ***************************************************************************/ void freePage( - void *page, - size_t numPages) + void *page, + size_t numPages) { - if (page != NULL) - { - PageInst.pgFree += numPages; - PageInst.pgTotal -= numPages; - } - free(page); -} + LONG pagecnt = numPages * PAGES_PER_PAGE; -void LB_freePage( - void *page, - size_t numPages) -{ - freePage(page, numPages); +#if NSS_DEBUG IS_ENABLED + { + NINT junk; + junk = *(NINT *)page; /* access the page to make sure it is mapped */ + } +#endif + + LB_MEMREPORTPAGE(MSGNot("freePage"),page,pagecnt,page); + zASSERT(page != 0); +#if NSS_DEBUG IS_ENABLED + memlset(page,FILL_PATTERN,(pagecnt*PAGE_SIZE)/sizeof(LONG)); +#endif +// UnRegisterPagesWithNLM((BYTE *)page,pagecnt,COMN_Resource.moduleHandle); + ZOS_DeAllocatePhysicalPages(page,pagecnt); + PageInst.pgFree += pagecnt; + PageInst.pgTotal -= pagecnt; } diff --git a/src/nwnss/library/stdlib/malloc.c b/src/nwnss/library/stdlib/malloc.c index 30b7a62..7d162cd 100644 --- a/src/nwnss/library/stdlib/malloc.c +++ b/src/nwnss/library/stdlib/malloc.c @@ -1,73 +1,259 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) module + | NetWare Advance File Services (NSS) module | |--------------------------------------------------------------------------- | - | Source(s): public_core/library/stdlib/malloc.c + | $Author: gpachner $ + | $Date: 2007-10-25 21:23:52 +0530 (Thu, 25 Oct 2007) $ + | + | $RCSfile$ + | $Revision: 2242 $ | |--------------------------------------------------------------------------- - | mars-nwe userspace port note: - | - | The original Linux NSS allocator routes through the NSS OS/private-stack - | memory runtime (nssOSAPIs.h/intmem.h/MKL_*). That memory runtime is not yet - | imported as a standalone userspace component, so this file keeps the NSS API - | entry points but maps the allocation boundary onto libc. Keep this file in - | the stdlib audit block; do not hide additional allocator aliases in public - | NSS headers. + | This module is used to: + | NSS Library source +-------------------------------------------------------------------------*/ -#include -#include +#include /* Netware includes */ +#include "nssOSAPIs.h" +#include /* NSS Library Fields*/ +#include +#include +#include "inlines.h" +#include "intmem.h" +#include "schedule.h" #ifdef __linux__ -#include +#include "mpk.h" #endif -#ifndef ZERO_FILL -#define ZERO_FILL 0x0002 +#if NSS_DEBUG IS_ENABLED +LONG MemoryErrorCount; +BOOL FakeBlockingAlloc = FALSE; #endif -static size_t nss_malloc_full_size(void *ptr, size_t requested) +void outOfMemory (char *where, LONG caller, size_t size) { -#ifdef __linux__ - size_t usable; + BOOL iOwnSpinlock = MPKNSS_I_OWN_SPINLOCK(); - if (ptr == NULL) - return 0; - usable = malloc_usable_size(ptr); - if (usable > requested) - return usable; + if (!iOwnSpinlock) + { + MPKNSS_LOCK(); + } +#if NSS_DEBUG IS_ENABLED + { + char buffer[40]; + + ++MemoryErrorCount; + + DBG_DebugPrintf(CYAN, + MSGNot("Malloc: Caller=0x%x; MemoryErrorCount=%d; Time=%s\n"), + caller, MemoryErrorCount, + UTCTime2Str(GetUTCTime(), &buffer[0])); + } +#endif + +#if NSS_DEBUG IS_DISABLED + if (size == 0) + { + if (!iOwnSpinlock) + { + MPKNSS_UNLOCK(); + } + return; + } +#endif + + errPrintf(where, LibModule, 217, + MSG("Error allocating %d bytes of memory.\n" + "You may not have enough memory. Either close some " + "other applications or " + "add more memory.", 226), size); + if (!iOwnSpinlock) + { + MPKNSS_UNLOCK(); + } +} + +/************************************************************************** + * Call Allocate memory, reporting out of memory errors on the console + ***************************************************************************/ +void *LB_malloc ( + size_t size) +{ + BOOL iOwnSpinlock = MPKNSS_I_OWN_SPINLOCK(); + void *mkl; + + if (iOwnSpinlock) + { +#if NSS_DEBUG IS_ENABLED + if (FakeBlockingAlloc) Yield(); + if (size == 0) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } +#endif + ZOS_AllocSleepOK(mkl, MKL_NEW_SIZE(size),COMN_Resource.memoryRTag,0); + + if (mkl == NULL) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } + MKL_INSERT(mkl, size); + LB_MEMREPORT(MSGNot("malloc"), mkl, size); + } + else + { /* + * Called malloc without spinlock + */ +#if NSS_DEBUG IS_ENABLED + if (FakeBlockingAlloc) kYieldThread(); + if (size == 0) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } +#endif + mkl = AllocSleepOK(MKL_NEW_SIZE(size), COMN_Resource.memoryRTag, 0); + + if (mkl == NULL) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } +#if MEM_KEEP_LIST IS_ENABLED + MPKNSS_LOCK(); + MKL_INSERT(mkl, size); + LB_MEMREPORT(MSGNot("malloc"), mkl, size); + MPKNSS_UNLOCK(); +#endif + } + return( MKL_TO_UMEM(mkl) ); +} + +void *LB_mallocWithFlags ( + size_t size, + unsigned int flags) +{ + void *mkl; + NINT fullSize; + BOOL iOwnSpinlock = MPKNSS_I_OWN_SPINLOCK(); + + if (iOwnSpinlock) + { +#if NSS_DEBUG IS_ENABLED + if (size == 0) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } +#endif + if (flags & ALLOC_SLEEP_OK) + { + ZOS_AllocSleepOK(mkl, MKL_NEW_SIZE(size), COMN_Resource.memoryRTag, 0); + } + else + { + ZOS_Alloc(mkl, MKL_NEW_SIZE(size), COMN_Resource.memoryRTag); + } + if (mkl == NULL) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } + MKL_INSERT(mkl, size); + LB_MEMREPORT(MSGNot("mallocWithFlags"), mkl, size); + } + else + { +#if NSS_DEBUG IS_ENABLED + if (size == 0) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } +#endif + if (flags & ALLOC_SLEEP_OK) + { + mkl = AllocSleepOK(MKL_NEW_SIZE(size), COMN_Resource.memoryRTag, 0); + } + else + { + mkl = Alloc(MKL_NEW_SIZE(size), COMN_Resource.memoryRTag); + } + if (mkl == NULL) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } +#if MEM_KEEP_LIST IS_ENABLED + MPKNSS_LOCK(); + MKL_INSERT(mkl, size); + LB_MEMREPORT(MSGNot("mallocWithFlags"), mkl, size); + MPKNSS_UNLOCK(); +#endif + } + if (flags & ZERO_FILL) + { + fullSize = MKL_ORIG_SIZE(SizeOfAllocBlock(mkl)); +#ifdef _WATCOMC_ + inline_bzero(MKL_TO_UMEM(mkl), fullSize); #else - (void)ptr; + bzero(MKL_TO_UMEM(mkl), fullSize); #endif - return requested; + } + return( MKL_TO_UMEM(mkl) ); } -void *LB_malloc(size_t size) +#ifdef __linux__ +/* + * LB_StackAllocate() - + * Allocate Linux 'stack' space. Will always be able to allocate memory + * unless 'stack' use goes above 32K (the NetWare limit). + * + * Warnings - + * LB_StackAllocate and LB_StackFree MUST be called in 'stack' order. + * I.E. memory allocated via LB_StackAllocate must be freed in LIFO order. + * This requirement will make the implentation of LB_StackAllocate easier + * and will allow for debug code to catch callers who do not free memory. + * + */ +void *LB_StackAllocate( size_t size ) { - return malloc(size); + return mpkPrivateAlloc( size ); } -void *LB_mallocWithFlags(size_t size, unsigned int flags) + +/* + * LB_StackFree() - + * Frees memory allocated by a previous LB_StackAllocate. Must be + * called in LIFO order. See warnings in LB_StackAllocate(). + * + */ +void LB_StackFree( void *aStack, size_t size ) { - void *ptr = LB_malloc(size); - - if (ptr != NULL && (flags & ZERO_FILL)) - memset(ptr, 0, nss_malloc_full_size(ptr, size)); - return ptr; + return mpkPrivateFree( aStack, size ); } -void *LB_StackAllocate(size_t size) -{ - return malloc(size); -} - -void LB_StackFree(void *ptr, size_t size) -{ - (void)size; - free(ptr); -} +#endif diff --git a/src/nwnss/library/stdlib/mallocForNCPReply.c b/src/nwnss/library/stdlib/mallocForNCPReply.c index 01f35b6..48b2684 100644 --- a/src/nwnss/library/stdlib/mallocForNCPReply.c +++ b/src/nwnss/library/stdlib/mallocForNCPReply.c @@ -1,32 +1,95 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) module + | NetWare Advance File Services (NSS) module | |--------------------------------------------------------------------------- | - | Source(s): public_core/library/stdlib/mallocForNCPReply.c + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ | |--------------------------------------------------------------------------- - | mars-nwe userspace port note: - | - | The original function allocates reply memory outside the NSS internal malloc - | debug path because the NetWare NCP handler frees it itself. In standalone - | libnwnss there is no separate NCP allocator yet, so preserve the symbol and - | allocate with libc malloc. + | This module is used to: + | NSS Library source +-------------------------------------------------------------------------*/ -#include +#include /* Netware includes */ +#include "nssOSAPIs.h" +#include /* NSS Library Fields*/ +#include +#include +#include +#include "intmem.h" +#include "schedule.h" -void *LB_mallocForNCPReply(size_t size) -{ - return malloc(size); -} +#if zNETWARE +#define localRTag NW_OSGeneralWorkAllocTag +#endif -void *mallocForNCPReply(size_t size) +#if zLINUX +#define localRTag COMN_Resource.memoryRTag +#endif + +extern void outOfMemory(char *where, LONG caller, size_t size); + +/************************************************************************** + * This is a special call to allocate memory that should be used for + * generating NCP reply packets. The only difference between this and the + * real "malloc" routine is that it NEVER uses our internal malloc debug. + * This is because the Netware NCP handler does its own free of this memory. + ***************************************************************************/ +void *mallocForNCPReply ( + size_t size) { - return LB_mallocForNCPReply(size); + void *mem; + BOOL iOwnSpinlock = MPKNSS_I_OWN_SPINLOCK(); + + if (iOwnSpinlock) + { + ZOS_AllocSleepOK(mem, size, localRTag, 0); + + if (mem == NULL) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } + LB_MEMREPORT(MSGNot("malloc"),mem,size); + } + else + { + mem = AllocSleepOK(size, localRTag, 0); + + if (mem == NULL) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } +#if NSS_DEBUG IS_ENABLED + MPKNSS_LOCK(); + LB_MEMREPORT(MSGNot("malloc"), mem, size); + MPKNSS_UNLOCK(); +#endif + } + return mem; } diff --git a/src/nwnss/library/stdlib/mallocPage.c b/src/nwnss/library/stdlib/mallocPage.c index 1ac765c..22852f3 100644 --- a/src/nwnss/library/stdlib/mallocPage.c +++ b/src/nwnss/library/stdlib/mallocPage.c @@ -1,63 +1,88 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) module + | NetWare Advance File Services (NSS) module | |--------------------------------------------------------------------------- + | | $Author: taysom $ | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | | $RCSfile$ | $Revision: 465 $ | |--------------------------------------------------------------------------- - | This module is used to: - | NSS Library source - | - | mars-nwe userspace port: keep the original NSS page-allocation entry point - | and map the physical-page allocation boundary onto page-aligned libc memory. + | This module is used to: + | NSS Library source +-------------------------------------------------------------------------*/ -#include -#ifndef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200112L -#endif -#include +#include /* NetWare Includes*/ +#include "nssOSAPIs.h" +#include /* PSS Includes*/ +#include +#include +#include -#if defined(NSS_USERSPACE) -extern int posix_memalign(void **memptr, size_t alignment, size_t size); -#endif -#include -#include - -PageInst_s PageInst = { 0 }; +PageInst_s PageInst = { 0 }; /************************************************************************** - * This allocates the given number of pages to this NLM, - * reporting errors appropriatly. The size of the page is defined by - * PAGE_SIZE. + * This allocates the given number of pages to this NLM, + * reporting errors appropriatly. The size of the page is defined by + * PAGE_SIZE. ***************************************************************************/ void *LB_mallocPage( - size_t numPages) + size_t numPages) { - void *page = NULL; - size_t bytes = numPages * PAGE_SIZE; + void *page; + LONG pagecnt = numPages * PAGES_PER_PAGE; + + ZOS_AllocatePhysicalPages(page, pagecnt,1 /*AOPT_OkToSleep*/,0); - if ((numPages == 0) || (posix_memalign(&page, PAGE_SIZE, bytes) != 0)) - return NULL; + if (page == NULL) + { + errPrintf(WHERE, LibModule, 219, + MSG("Error allocating %d pages of memory.\n" + "You may not have enough memory. Either close some other " + "applications or add more memory.", 228), pagecnt); + } + else + { + PageInst.pgAlloc += numPages; + PageInst.pgTotal += numPages; - PageInst.pgAlloc += numPages; - PageInst.pgTotal += numPages; - return page; +// if (RegisterPagesWithNLM((BYTE *)page, pagecnt, +// COMN_Resource.moduleHandle) != 0) +// { +// errPrintf(WHERE, LibModule, -1, +// MSG("Error registering %d pages to " "NSS" ".", 23), pagecnt); +// ZOS_DeAllocatePhysicalPages(page, pagecnt); +// page = NULL; +// } +#if NSS_DEBUG IS_ENABLED + { + NINT junk; + junk = *(NINT *)page; /* access the page to make sure it is mapped */ + } +#endif + } + LB_MEMREPORTPAGE(MSGNot("mallocPage"),page,pagecnt,numPages); + return page; } diff --git a/src/nwnss/library/stdlib/mallocPageWithFlags.c b/src/nwnss/library/stdlib/mallocPageWithFlags.c index f7f883e..78470f3 100644 --- a/src/nwnss/library/stdlib/mallocPageWithFlags.c +++ b/src/nwnss/library/stdlib/mallocPageWithFlags.c @@ -1,61 +1,97 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) module + | NetWare Advance File Services (NSS) module | |--------------------------------------------------------------------------- + | | $Author: taysom $ | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | | $RCSfile$ | $Revision: 465 $ | |--------------------------------------------------------------------------- - | This module is used to: - | NSS Library source - | - | mars-nwe userspace port: preserve the NSS page allocator API while mapping - | physical-page flags onto page-aligned libc allocation semantics. + | This module is used to: + | NSS Library source +-------------------------------------------------------------------------*/ -#ifndef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200112L -#endif -#include - -#if defined(NSS_USERSPACE) -extern int posix_memalign(void **memptr, size_t alignment, size_t size); -#endif -#include -#include -#include - -#ifndef ZERO_FILL -#define ZERO_FILL 0x0002 -#endif +#include /* NetWare Includes*/ +#include "nssOSAPIs.h" +#include /* PSS Includes*/ +#include +#include +#include +#include "schedule.h" /************************************************************************** - * This allocates the given number of pages to this NLM, - * reporting errors appropriatly. The size of the page is defined by - * PAGE_SIZE. The flags field defines whether it needs to - * to be zero filled and/or if it is OK to sleep during alloc + * This allocates the given number of pages to this NLM, + * reporting errors appropriatly. The size of the page is defined by + * PAGE_SIZE. The flags field defines whether it needs to + * to be zero filled and/or if it is OK to sleep during alloc ***************************************************************************/ void *LB_mallocPageWithFlags( - size_t numPages, - unsigned int flags) + size_t numPages, + unsigned int flags) { - void *page = NULL; - size_t bytes = numPages * PAGE_SIZE; + void *page; + LONG pagecnt = numPages * PAGES_PER_PAGE; - if ((numPages == 0) || (posix_memalign(&page, PAGE_SIZE, bytes) != 0)) - return NULL; - - if (flags & ZERO_FILL) - memset(page, 0, bytes); - - PageInst.pgAlloc += numPages; - PageInst.pgTotal += numPages; - return page; +#if NSS_DEBUG IS_ENABLED + if ( flags & ALLOC_SLEEP_OK ) + { + } +#endif + ZOS_AllocatePhysicalPages(page, pagecnt,(flags & ALLOC_SLEEP_OK) ? TRUE : FALSE, 0); + if (page == NULL) + { + errPrintf(WHERE, LibModule, 220, + MSG("Error allocating %d pages of memory.", 35), pagecnt); + } + else + { +// if (RegisterPagesWithNLM((BYTE *)page, pagecnt, +// COMN_Resource.moduleHandle) != 0) +// { +// errPrintf(WHERE, LibModule, -1, +// MSG("Error registering %d pages to " "NSS" ".", 25), pagecnt); +// ZOS_DeAllocatePhysicalPages(page, pagecnt); +// page = NULL; +// } +#if NSS_DEBUG IS_ENABLED + { + NINT junk; + junk = *(NINT *)page; /* access the page to make sure it is mapped */ + } +#endif + LB_MEMREPORTPAGE(MSGNot("mallocPage"),page,pagecnt,numPages); + if (flags & ZERO_FILL) + { + /* zero it because allocate does not*/ +#ifdef _WATCOMC_ + inline_bzero(page,pagecnt << PAGE_SHIFT); +#else + bzero(page,pagecnt << PAGE_SHIFT); +#endif + } + } + return page; } diff --git a/src/nwnss/library/stdlib/realloc.c b/src/nwnss/library/stdlib/realloc.c index 248a5e3..89981dc 100644 --- a/src/nwnss/library/stdlib/realloc.c +++ b/src/nwnss/library/stdlib/realloc.c @@ -1,64 +1,81 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) module + | NetWare Advance File Services (NSS) module | |--------------------------------------------------------------------------- | - | Source(s): public_core/library/stdlib/realloc.c + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ | |--------------------------------------------------------------------------- - | mars-nwe userspace port note: - | - | Original NSS realloc uses MKL allocation metadata to copy the previous full - | allocation size. Until the full NSS memory runtime is imported, use libc allocation but keep - | the original allocate/copy/free shape and copy the previous full allocation - | block where libc exposes that size. + | This module is used to: + | NSS Library source +-------------------------------------------------------------------------*/ -#include +#include "procdefs.h" + +#include #include -#ifdef __linux__ -#include -#endif +#include "intmem.h" -static size_t nss_realloc_full_size(void *ptr) +/************************************************************************** + * This always allocates a new buffer and then copies the correct amount + * of OLD or NEW data into the buffer. + ***************************************************************************/ +void *LB_realloc( + void *old, + size_t newSize) { -#ifdef __linux__ - return ptr ? malloc_usable_size(ptr) : 0; -#else - (void)ptr; - return 0; + NINT oldFullSize; + void *newbuf; + + if (old == NULL) + { + return malloc(newSize); + } + else if (newSize == 0) + { + free(old); + return NULL; + } +#if MEM_KEEP_LIST IS_ENABLED + { + MKL_Header_s *mkl; + mkl = UMEM_TO_MKL(old); + zASSERT( mkl->MH_signature == MKL_SIGN_ALLOC ); + } #endif -} - -void *LB_realloc(void *ptr, size_t size) -{ - size_t oldFullSize; - size_t copySize; - void *newPtr; - - if (ptr == NULL) - return malloc(size); - if (size == 0) { - free(ptr); - return NULL; - } - - oldFullSize = nss_realloc_full_size(ptr); - if (oldFullSize == size) - return ptr; - - newPtr = malloc(size); - if (newPtr == NULL) - return NULL; - - copySize = size < oldFullSize ? size : oldFullSize; - if (copySize != 0) - memcpy(newPtr, ptr, copySize); - free(ptr); - return newPtr; + oldFullSize = MKL_ORIG_SIZE(SizeOfAllocBlock(UMEM_TO_MKL(old))); + if (newSize == oldFullSize) + return old; + + newbuf = malloc(newSize); + if (newbuf == NULL) + return NULL; + + memcpy(newbuf,old,((newSize < oldFullSize) ? newSize : oldFullSize)); + free(old); + return newbuf; } diff --git a/src/nwnss/library/stdlib/zalloc.c b/src/nwnss/library/stdlib/zalloc.c index 2d3c7ed..0dc401f 100644 --- a/src/nwnss/library/stdlib/zalloc.c +++ b/src/nwnss/library/stdlib/zalloc.c @@ -1,67 +1,121 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) module + | NetWare Advance File Services (NSS) module | |--------------------------------------------------------------------------- | - | Source(s): public_core/library/stdlib/zalloc.c + | $Author: gpachner $ + | $Date: 2005-03-18 23:26:41 +0530 (Fri, 18 Mar 2005) $ + | + | $RCSfile$ + | $Revision: 879 $ | |--------------------------------------------------------------------------- - | This userspace NSS import keeps the NSS allocator API names available outside - | the NSS loader/runtime. The original NSS file allocates through NSS OS - | memory tracking (nssOSAPIs.h/intmem.h/MKL_*); the userspace NSS build maps that userland - | allocation to libc while preserving the public NSS symbols. The original - | file zeroes the full OS/MKL allocation block, not just the requested byte - | count, because zrealloc relies on that tail being clean. On Linux preserve - | that observable contract with malloc_usable_size(). + | This module is used to: + | NSS Library source +-------------------------------------------------------------------------*/ -#include -#include -#ifdef __linux__ -#include +#include /* NetWare Includes*/ +#include "nssOSAPIs.h" +#include +#include +#include +#include "inlines.h" +#include "intmem.h" +#include "schedule.h" + + +#if NSS_DEBUG IS_ENABLED +extern BOOL FakeBlockingAlloc; #endif -static size_t nss_zalloc_full_size(void *ptr, size_t requested) +extern void outOfMemory(char *where, LONG caller, size_t size); + +/************************************************************************** + * This will allocate a block of memory and zero it. This reports an + * error on the console if we can't get the memory. WARNING: this routine + * get the full allocated size of the block from the OS so that it can zero + * that portion of memory between the end of our request and how much the + * OS actually got. If we don't do this the "zrealloc" routine will fail. + ***************************************************************************/ +void *zalloc ( + size_t size) { -#ifdef __linux__ - if (ptr != NULL) { - size_t usable = malloc_usable_size(ptr); - if (usable > requested) - return usable; + BOOL iOwnSpinlock = MPKNSS_I_OWN_SPINLOCK(); + void *uMem; + void *mkl; + NINT fullSize; + + if (iOwnSpinlock) + { +#if NSS_DEBUG IS_ENABLED + if (FakeBlockingAlloc) Yield(); + if (size == 0) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } +#endif + ZOS_AllocSleepOK(mkl, MKL_NEW_SIZE(size),COMN_Resource.memoryRTag,0); + + if (mkl == NULL) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } + MKL_INSERT(mkl, size); + LB_MEMREPORT(MSGNot("zalloc"),mkl,size); } -#else - (void)ptr; + else + { +#if NSS_DEBUG IS_ENABLED + if (FakeBlockingAlloc) Yield(); + if (size == 0) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } #endif - return requested; -} + mkl = AllocSleepOK(MKL_NEW_SIZE(size), COMN_Resource.memoryRTag, 0); -void *LB_zalloc(size_t size) -{ - void *ptr = malloc(size); - - if (ptr != NULL) - memset(ptr, 0, nss_zalloc_full_size(ptr, size)); - return ptr; -} - -void *zalloc(size_t size) -{ - return LB_zalloc(size); + if (mkl == NULL) + { + outOfMemory(WHERE, *(((LONG *)&size) - 1), size); + return NULL; + } +#if MEM_KEEP_LIST IS_ENABLED + MPKNSS_LOCK(); + MKL_INSERT(mkl, size); + LB_MEMREPORT(MSGNot("zalloc"), mkl, size); + MPKNSS_UNLOCK(); +#endif + } + uMem = MKL_TO_UMEM(mkl); +/* WARNING: we must zero the FULL size of the block (read note in header) */ + fullSize = MKL_ORIG_SIZE(SizeOfAllocBlock(mkl)); +#ifdef _WATCOMC_ + inline_bzero(uMem, fullSize); +#else + bzero(uMem, fullSize); +#endif + return uMem; } diff --git a/src/nwnss/library/stdlib/zallocPage.c b/src/nwnss/library/stdlib/zallocPage.c index 0010583..2560c69 100644 --- a/src/nwnss/library/stdlib/zallocPage.c +++ b/src/nwnss/library/stdlib/zallocPage.c @@ -1,58 +1,86 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) module + | NetWare Advance File Services (NSS) module | |--------------------------------------------------------------------------- + | | $Author: taysom $ | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | | $RCSfile$ | $Revision: 465 $ | |--------------------------------------------------------------------------- - | This module is used to: - | NSS Library source - | - | mars-nwe userspace port: preserve the NSS zero-filled page allocator API - | while mapping the physical-page allocation boundary onto page-aligned libc - | memory. + | This module is used to: + | NSS Library source +-------------------------------------------------------------------------*/ -#ifndef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200112L -#endif -#include - -#if defined(NSS_USERSPACE) -extern int posix_memalign(void **memptr, size_t alignment, size_t size); -#endif -#include -#include -#include +#include +#include "nssOSAPIs.h" +#include +#include +#include +#include +#include +#include "schedule.h" /************************************************************************** - * This allocates the given number of pages to this NLM, - * reporting errors appropriatly. The size of the page is defined by - * PAGE_SIZE. + * This allocates the given number of pages to this NLM, + * reporting errors appropriatly. The size of the page is defined by + * PAGE_SIZE. ***************************************************************************/ -void *LB_zallocPage( - size_t numPages) +void *zallocPage( + size_t numPages) { - void *page = NULL; - size_t bytes = numPages * PAGE_SIZE; + void *page; + LONG pagecnt = numPages * PAGES_PER_PAGE; - if ((numPages == 0) || (posix_memalign(&page, PAGE_SIZE, bytes) != 0)) - return NULL; - - memset(page, 0, bytes); - PageInst.pgZalloc += numPages; - PageInst.pgTotal += numPages; - return page; + ASSERT_MPKNSS_LOCK(); + ZOS_AllocatePhysicalPages(page,pagecnt,TRUE,0); + if (page == NULL) + { + errPrintf(WHERE, LibModule, 222, + MSG("Error allocating %d pages of memory.\r\n" + "You may not have enough memory. Either close some other " + "applications or add more memory.", 230), pagecnt); + } + else + { + PageInst.pgZalloc += numPages; + PageInst.pgTotal += numPages; +// if (RegisterPagesWithNLM((BYTE *)page, pagecnt, +// COMN_Resource.moduleHandle) != 0) +// { +// errPrintf(WHERE, LibModule, -1, +// MSG("Error registering %d pages of memory.", 28), pagecnt); +// ZOS_DeAllocatePhysicalPages(page, pagecnt); +// page = NULL; +// } + LB_MEMREPORTPAGE(MSGNot("zallocPage"),page,pagecnt,numPages); +#ifdef _WATCOMC_ + inline_bzero(page,pagecnt << PAGE_SHIFT); /* zero it because allocate is not*/ +#else + bzero(page,pagecnt << PAGE_SHIFT); +#endif + } + return page; } diff --git a/src/nwnss/library/stdlib/zrealloc.c b/src/nwnss/library/stdlib/zrealloc.c index 3c5201c..bcc1b01 100644 --- a/src/nwnss/library/stdlib/zrealloc.c +++ b/src/nwnss/library/stdlib/zrealloc.c @@ -1,79 +1,118 @@ /**************************************************************************** | - | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) module + | NetWare Advance File Services (NSS) module | |--------------------------------------------------------------------------- | - | Source(s): public_core/library/stdlib/zrealloc.c + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ | |--------------------------------------------------------------------------- - | mars-nwe userspace port note: - | Original NSS zrealloc uses MKL allocation metadata and zero-fills newly - | grown tail space up to the OS allocation size. The userspace port has no - | MKL metadata yet; on Linux use malloc_usable_size() and a manual - | allocate/copy/free sequence to preserve the important observable contract: - | the old full allocation block is copied when growing, and bytes newly - | exposed by growth or shrink-tail capacity are zero-filled. + | This module is used to: + | NSS Library source +-------------------------------------------------------------------------*/ -#include +#include "procdefs.h" + +#include #include -#ifdef __linux__ -#include -#endif +#include "intmem.h" +#include "inlines.h" -static size_t nss_alloc_full_size(void *ptr, size_t requested) +/************************************************************************** + * This always allocates a new buffer and then copies the correct amount + * of OLD or NEW data into the buffer. If the new buffer is larger, this + * will zero the new space. + * + * Warning: because we don't know exactly how many bytes the user requested + * in the OLD memory (all we have is the full size allocated by + * the OS) we always zero from the given requested size to the + * full size (even when we shrink) so that the next grow will + * have everything zeroed properly. + ***************************************************************************/ +void *zrealloc( + void *old, + size_t newSize) { -#ifdef __linux__ - if (ptr != NULL) { - size_t usable = malloc_usable_size(ptr); - if (usable > requested) - return usable; - } + NINT oldFullSize; + NINT newFullSize; + NINT zeroSize; + void *newbuf; + + ASSERT_MPKNSS_LOCK(); + if (old == NULL) + { + return zalloc(newSize); + } + else if (newSize == 0) + { + free(old); + return NULL; + } + +#if MEM_KEEP_LIST IS_ENABLED + { + MKL_Header_s *mkl; + mkl = UMEM_TO_MKL(old); + zASSERT( mkl->MH_signature == MKL_SIGN_ALLOC ); + } +#endif + newbuf = malloc(newSize); + if (newbuf == NULL) + return NULL; + + oldFullSize = MKL_ORIG_SIZE(SizeOfAllocBlock(UMEM_TO_MKL(old))); + newFullSize = MKL_ORIG_SIZE(SizeOfAllocBlock(UMEM_TO_MKL(newbuf))); +/*------------------------------------------------------------------------- + * Get the FULLSIZE of the OLD buffer, note that this includes the ROUNDUP + * space. Also get the FULLSIZE of the NEW buffer for copies. + *-------------------------------------------------------------------------*/ + if (newSize < oldFullSize) /* shrinking the buffer? */ + { /* Shrinking buffer */ + memcpy(newbuf,old,newSize); + if ((zeroSize = newFullSize-newSize) > 0) + { +#ifdef _WATCOMC_ + inline_bzero((void *)((ADDR)newbuf+newSize),zeroSize); #else - (void)ptr; + bzero((void *)((ADDR)newbuf+newSize),zeroSize); #endif - return requested; -} - -void *LB_zrealloc(void *ptr, size_t size) -{ - size_t oldFullSize; - size_t newFullSize; - size_t copySize; - void *newPtr; - - if (ptr == NULL) { - newPtr = malloc(size); - if (newPtr != NULL) - memset(newPtr, 0, nss_alloc_full_size(newPtr, size)); - return newPtr; - } - if (size == 0) { - free(ptr); - return NULL; - } - - oldFullSize = nss_alloc_full_size(ptr, 0); - newPtr = malloc(size); - if (newPtr == NULL) - return NULL; - - newFullSize = nss_alloc_full_size(newPtr, size); - copySize = size < oldFullSize ? size : oldFullSize; - if (copySize != 0) - memcpy(newPtr, ptr, copySize); - if (newFullSize > copySize) - memset((unsigned char *)newPtr + copySize, 0, newFullSize - copySize); - free(ptr); - return newPtr; -} - -void *zrealloc(void *ptr, size_t size) -{ - return LB_zrealloc(ptr, size); + } + } + else + { /* Growing buffer */ + memcpy(newbuf,old,oldFullSize); + if ((zeroSize = newFullSize-oldFullSize) > 0) + { +#ifdef _WATCOMC_ + inline_bzero((void *)((ADDR)newbuf+oldFullSize),zeroSize); +#else + bzero((void *)((ADDR)newbuf+oldFullSize),zeroSize); +#endif + } + } + free(old); + return newbuf; } diff --git a/src/nwnss/library/unicode/ByteToUnicode.c b/src/nwnss/library/unicode/ByteToUnicode.c index 49148f5..b610c98 100644 --- a/src/nwnss/library/unicode/ByteToUnicode.c +++ b/src/nwnss/library/unicode/ByteToUnicode.c @@ -37,9 +37,15 @@ | 9/14/01: Instead of calling system routines for unicode conversion, NSS | has created is own set of conversion functions that are MP safe and fast. +-------------------------------------------------------------------------*/ +#if zLINUX +#include "nssOSAPIs.h" +#endif #include -#include -#include +#include +#include +#if zNETWARE +#include "nssOSAPIs.h" +#endif /************************************************************************** @@ -55,11 +61,11 @@ STATUS LB_ByteToUnicode( NINT *retActualLength) /* may be NULL, returns length of unicode_t string*/ { BYTE *p; - unicode_t *u; + unicode_t *u; STATUS status; unicode_t *singleByteToUnicode; unicode_t *doubleByteToUnicode; - + if ((conversionType > NSS_UNI_CONVERSION_COUNT) || (conversionType < 1) || @@ -85,18 +91,18 @@ STATUS LB_ByteToUnicode( } *u = singleByteToUnicode[*p]; - if (!*u) /* check if a single byte is a valid unicode */ - { + if (!*u) /* check if a single byte is a valid unicode */ + { if (*(p + 1)) { - *u = doubleByteToUnicode[*p * 256 + *(p + 1)]; + *u = doubleByteToUnicode[*p * 256 + *(p + 1)]; } if (!*u) /* check if double bytes is a valid unicode */ { /* FF is a weird beast. In the LONG namespace, it can be * a beginning of a double byte wildcard sequence, or it can * be a single byte character. If we get to this error point, - * and the character is a single byte FF, just manually + * and the character is a single byte FF, just manually * translate it as a single byte. */ if ((*p == 0xFF) && @@ -114,7 +120,7 @@ STATUS LB_ByteToUnicode( } ++p; } - ++u; + ++u; --outputBufferLen; } if (retActualLength) @@ -127,7 +133,7 @@ STATUS LB_ByteToUnicode( *retActualLength = u - unicodeOutput; } *u = 0; - + return zOK; error: @@ -137,4 +143,4 @@ error: } *unicodeOutput = 0; /* return NULL string */ return status; -} +} diff --git a/src/nwnss/library/unicode/LenByteToUnicode.c b/src/nwnss/library/unicode/LenByteToUnicode.c index b65a70e..ae4e346 100644 --- a/src/nwnss/library/unicode/LenByteToUnicode.c +++ b/src/nwnss/library/unicode/LenByteToUnicode.c @@ -37,9 +37,15 @@ | 9/14/01: Instead of calling system routines for unicode conversion, NSS | has created is own set of conversion functions that are MP safe and fast. +-------------------------------------------------------------------------*/ +#if zLINUX +#include "nssOSAPIs.h" +#endif #include -#include -#include +#include +#include +#if zNETWARE +#include "nssOSAPIs.h" +#endif /************************************************************************** * This will convert an unterminated ASCII string with a length into a @@ -53,7 +59,7 @@ STATUS LB_LenByteToUnicode( CONST char *byteInput, /* Buffer for input bytes*/ NINT inLength, /* length of input string */ NINT *retActualLength) /* may be NULL, return unicode_t string length*/ -{ +{ unicode_t *u; BYTE *p; STATUS status; @@ -74,7 +80,7 @@ STATUS LB_LenByteToUnicode( p = (BYTE *)byteInput; u = unicodeOutput; --outputBufferLen; /* leave a space for null terminator */ - + for (;inLength; --inLength) { if (outputBufferLen == 0) @@ -86,16 +92,16 @@ STATUS LB_LenByteToUnicode( if (!*u) /* check if a single byte is a valid unicode */ { - if (inLength >= 2) + if (inLength >= 2) { - *u = doubleByteToUnicode[*p * 256 + *(p + 1)]; + *u = doubleByteToUnicode[*p * 256 + *(p + 1)]; } if (!*u) /* check if double bytes is a valid unicode */ { /* FF is a weird beast. In the LONG namespace, it can be * a beginning of a double byte wildcard sequence, or it can * be a single byte character. If we get to this error point, - * and the character is a single byte FF, just manually + * and the character is a single byte FF, just manually * translate it as a single byte. */ if ((*p == 0xFF) && @@ -116,7 +122,7 @@ STATUS LB_LenByteToUnicode( --inLength; } ++p; - ++u; + ++u; --outputBufferLen; } if (retActualLength) @@ -138,4 +144,4 @@ error: } *unicodeOutput = 0; /* return NULL string */ return status; -} +} diff --git a/src/nwnss/library/unicode/LenMacByteToUnicode.c b/src/nwnss/library/unicode/LenMacByteToUnicode.c index 989d720..ab60c81 100644 --- a/src/nwnss/library/unicode/LenMacByteToUnicode.c +++ b/src/nwnss/library/unicode/LenMacByteToUnicode.c @@ -35,9 +35,15 @@ | Routine to convert MAC ascii to unicode_t | +-------------------------------------------------------------------------*/ +#if zLINUX +#include "nssOSAPIs.h" +#endif #include -#include -#include +#include +#include +#if zNETWARE +#include "nssOSAPIs.h" +#endif /************************************************************************** * This will convert an unterminated ASCII string with a length into a @@ -51,7 +57,7 @@ STATUS LB_LenMacByteToUnicode( CONST char *byteInput, /* Buffer for input bytes*/ NINT inLength, /* length of input string */ NINT *retActualLength) /* may be NULL, return unicode_t string length*/ -{ +{ unicode_t *u; BYTE *p; STATUS status; @@ -70,7 +76,7 @@ STATUS LB_LenMacByteToUnicode( p = (BYTE *)byteInput; u = unicodeOutput; --outputBufferLen; /* leave a space for null terminator */ - + for (;inLength; --inLength) { if (outputBufferLen == 0) @@ -82,16 +88,16 @@ STATUS LB_LenMacByteToUnicode( if (!*u) /* check if a single byte is a valid unicode */ { - if (inLength >= 2) + if (inLength >= 2) { - *u = doubleByteToUnicode[*p * 256 + *(p + 1)]; + *u = doubleByteToUnicode[*p * 256 + *(p + 1)]; } if (!*u) /* check if double bytes is a valid unicode */ { /* FF is a weird beast. In the LONG namespace, it can be * a beginning of a double byte wildcard sequence, or it can * be a single byte character. If we get to this error point, - * and the character is a single byte FF, just manually + * and the character is a single byte FF, just manually * translate it as a single byte. */ if ((*p == 0xFF) && @@ -112,7 +118,7 @@ STATUS LB_LenMacByteToUnicode( --inLength; } ++p; - ++u; + ++u; --outputBufferLen; } if (retActualLength) @@ -134,4 +140,4 @@ error: } *unicodeOutput = 0; /* return NULL string */ return status; -} +} diff --git a/src/nwnss/library/unicode/MacByteToUnicode.c b/src/nwnss/library/unicode/MacByteToUnicode.c index d552f38..273e303 100644 --- a/src/nwnss/library/unicode/MacByteToUnicode.c +++ b/src/nwnss/library/unicode/MacByteToUnicode.c @@ -35,9 +35,15 @@ | Routine to convert MAC ascii to unicode_t | +-------------------------------------------------------------------------*/ +#if zLINUX +#include "nssOSAPIs.h" +#endif #include -#include -#include +#include +#include +#if zNETWARE +#include "nssOSAPIs.h" +#endif /************************************************************************** @@ -53,11 +59,11 @@ STATUS LB_MacByteToUnicode( NINT *retActualLength) /* may be NULL, returns length of unicode_t string*/ { BYTE *p; - unicode_t *u; + unicode_t *u; STATUS status; unicode_t *singleByteToUnicode; unicode_t *doubleByteToUnicode; - + if (conversionType != NSS_UNI_CONVERSION_RAW) { @@ -81,18 +87,18 @@ STATUS LB_MacByteToUnicode( } *u = singleByteToUnicode[*p]; - if (!*u) /* check if a single byte is a valid unicode */ - { + if (!*u) /* check if a single byte is a valid unicode */ + { if (*(p + 1)) { - *u = doubleByteToUnicode[*p * 256 + *(p + 1)]; + *u = doubleByteToUnicode[*p * 256 + *(p + 1)]; } if (!*u) /* check if double bytes is a valid unicode */ { /* FF is a weird beast. In the LONG namespace, it can be * a beginning of a double byte wildcard sequence, or it can * be a single byte character. If we get to this error point, - * and the character is a single byte FF, just manually + * and the character is a single byte FF, just manually * translate it as a single byte. */ if ((*p == 0xFF) && @@ -110,7 +116,7 @@ STATUS LB_MacByteToUnicode( } ++p; } - ++u; + ++u; --outputBufferLen; } if (retActualLength) @@ -123,7 +129,7 @@ STATUS LB_MacByteToUnicode( *retActualLength = u - unicodeOutput; } *u = 0; - + return zOK; error: @@ -133,4 +139,4 @@ error: } *unicodeOutput = 0; /* return NULL string */ return status; -} +} diff --git a/src/nwnss/library/unicode/RegisterUnicodeConverter.c b/src/nwnss/library/unicode/RegisterUnicodeConverter.c index db25ab8..d958355 100644 --- a/src/nwnss/library/unicode/RegisterUnicodeConverter.c +++ b/src/nwnss/library/unicode/RegisterUnicodeConverter.c @@ -34,14 +34,16 @@ | This module is used to: | Register a user-defined unicode_t converter type +-------------------------------------------------------------------------*/ -#ifndef _NSS_INTERNAL_ -#define _NSS_INTERNAL_ +#if zLINUX +#include "nssOSAPIs.h" #endif -#include #include -#include -#include -#include +#include +#include +#include +#if zNETWARE +#include "nssOSAPIs.h" +#endif /* Don't do the debug tables written to a file option */ //#define UNICODE_FILE_DEBUG @@ -95,13 +97,13 @@ STATUS LB_RegisterUnicodeConverter( if (status != 0) { goto error_unRegister; - } - + } + status = buildUnicodeToByteTable(idx); if (status != 0) { goto error_unRegister; - } + } #ifdef UNICODE_FILE_DEBUG /* This is debug code for writing out the contents of our unicode tables diff --git a/src/nwnss/library/unicode/UnRegisterUnicodeConverter.c b/src/nwnss/library/unicode/UnRegisterUnicodeConverter.c index 3301190..a742733 100644 --- a/src/nwnss/library/unicode/UnRegisterUnicodeConverter.c +++ b/src/nwnss/library/unicode/UnRegisterUnicodeConverter.c @@ -34,14 +34,16 @@ | This module is used to: | Register a user-defined unicode_t converter type +-------------------------------------------------------------------------*/ -#ifndef _NSS_INTERNAL_ -#define _NSS_INTERNAL_ +#if zLINUX +#include "nssOSAPIs.h" #endif -#include #include -#include -#include +#include +#include #include +#if zNETWARE +#include "nssOSAPIs.h" +#endif /**************************************************************************** @@ -55,7 +57,7 @@ void LB_UnRegisterUnicodeConverter( (converterType >= NSS_UNI_CONVERSION_COUNT)) { /* Invalid converterType. We can't use this function to unregister - * the Library built-in defaults, and we can't use it to unregister + * the Library built-in defaults, and we can't use it to unregister * converter types that are >= the array size */ return; } @@ -68,13 +70,13 @@ void LB_UnRegisterUnicodeConverter( free(NSSSingleByteToUnicodeTable[converterType]); NSSSingleByteToUnicodeTable[converterType] = NULL; } - + if (NSSDoubleByteToUnicodeTable[converterType] != NULL) { free(NSSDoubleByteToUnicodeTable[converterType]); NSSDoubleByteToUnicodeTable[converterType] = NULL; } - + if (NSSUnicodeToByteTable[converterType] != NULL) { free(NSSUnicodeToByteTable[converterType]); @@ -89,3 +91,4 @@ void LB_UnRegisterUnicodeConverter( NSSUnicodeConverterDefined[converterType] = FALSE; } } + diff --git a/src/nwnss/library/unicode/UnicodeToByte.c b/src/nwnss/library/unicode/UnicodeToByte.c index a01bc1b..8709f0d 100644 --- a/src/nwnss/library/unicode/UnicodeToByte.c +++ b/src/nwnss/library/unicode/UnicodeToByte.c @@ -37,9 +37,15 @@ | 9/14/01: Instead of calling system routines for unicode conversion, NSS | has created is own set of conversion functions that are MP safe and fast. +-------------------------------------------------------------------------*/ +#if zLINUX +#include "nssOSAPIs.h" +#endif #include -#include -#include +#include +#include +#if zNETWARE +#include "nssOSAPIs.h" +#endif /************************************************************************** @@ -72,9 +78,9 @@ STATUS LB_UnicodeToByte( p = (BYTE *)byteOutput; --outputBufferLen; /* leave a space for null terminator */ - + for (u = unicodeInput; *u; u++) - { + { if (outputBufferLen == 0) { status = zERR_BUFFER_TOO_SMALL; @@ -91,7 +97,7 @@ STATUS LB_UnicodeToByte( --outputBufferLen; if (IS_UNICODE_DOUBLE_BYTE_ASCII(*u)) - { + { if (outputBufferLen) { *p++ = unicodeToByte[*u * 2 + 1]; @@ -103,7 +109,7 @@ STATUS LB_UnicodeToByte( goto error; } } - + } if (retActualLength) { @@ -118,5 +124,5 @@ error: { *retActualLength = 0; } - return status; -} + return status; +} diff --git a/src/nwnss/library/unicode/UnicodeToMacByte.c b/src/nwnss/library/unicode/UnicodeToMacByte.c index 70dd2b2..290cac5 100644 --- a/src/nwnss/library/unicode/UnicodeToMacByte.c +++ b/src/nwnss/library/unicode/UnicodeToMacByte.c @@ -37,9 +37,15 @@ | 9/14/01: Instead of calling system routines for unicode conversion, NSS | has created is own set of conversion functions that are MP safe and fast. +-------------------------------------------------------------------------*/ +#if zLINUX +#include "nssOSAPIs.h" +#endif #include -#include -#include +#include +#include +#if zNETWARE +#include "nssOSAPIs.h" +#endif /************************************************************************** @@ -70,9 +76,9 @@ STATUS LB_UnicodeToMacByte( p = (BYTE *)byteOutput; --outputBufferLen; /* leave a space for null terminator */ - + for (u = unicodeInput; *u; u++) - { + { if (outputBufferLen == 0) { status = zERR_BUFFER_TOO_SMALL; @@ -89,7 +95,7 @@ STATUS LB_UnicodeToMacByte( --outputBufferLen; if (IS_UNICODE_DOUBLE_BYTE_MAC_ASCII(*u)) - { + { if (outputBufferLen) { *p++ = unicodeToByte[*u * 2 + 1]; @@ -101,7 +107,7 @@ STATUS LB_UnicodeToMacByte( goto error; } } - + } if (retActualLength) { @@ -116,5 +122,5 @@ error: { *retActualLength = 0; } - return status; -} + return status; +} diff --git a/src/nwnss/library/unicode/UnicodeToUntermByte.c b/src/nwnss/library/unicode/UnicodeToUntermByte.c index d23a493..b96da55 100644 --- a/src/nwnss/library/unicode/UnicodeToUntermByte.c +++ b/src/nwnss/library/unicode/UnicodeToUntermByte.c @@ -37,9 +37,15 @@ | 9/14/01: Instead of calling system routines for unicode conversion, NSS | has created is own set of conversion functions that are MP safe and fast. +-------------------------------------------------------------------------*/ +#if zLINUX +#include "nssOSAPIs.h" +#endif #include -#include -#include +#include +#include +#if zNETWARE +#include "nssOSAPIs.h" +#endif /************************************************************************** @@ -55,7 +61,7 @@ STATUS LB_UnicodeToUntermByte( NINT *retActualLength) { BYTE *p; - unicode_t *u; + unicode_t *u; BYTE *unicodeToByte; STATUS status; @@ -102,7 +108,7 @@ STATUS LB_UnicodeToUntermByte( status = zERR_BUFFER_TOO_SMALL; goto error; } - } + } } *retActualLength = (NINT)(p - (BYTE *)byteOutput); @@ -112,4 +118,4 @@ error: *retActualLength = 0; *byteOutput = 0; /* return NULL string */ return status; -} +} diff --git a/src/nwnss/library/unicode/UnicodeToUntermMacByte.c b/src/nwnss/library/unicode/UnicodeToUntermMacByte.c index af07ee9..4accf84 100644 --- a/src/nwnss/library/unicode/UnicodeToUntermMacByte.c +++ b/src/nwnss/library/unicode/UnicodeToUntermMacByte.c @@ -35,9 +35,15 @@ | Routine to convert MAC ascii to unicode_t | +-------------------------------------------------------------------------*/ +#if zLINUX +#include "nssOSAPIs.h" +#endif #include -#include -#include +#include +#include +#if zNETWARE +#include "nssOSAPIs.h" +#endif /************************************************************************** @@ -53,7 +59,7 @@ STATUS LB_UnicodeToUntermMacByte( NINT *retActualLength) { BYTE *p; - unicode_t *u; + unicode_t *u; BYTE *unicodeToByte; STATUS status; @@ -98,7 +104,7 @@ STATUS LB_UnicodeToUntermMacByte( status = zERR_BUFFER_TOO_SMALL; goto error; } - } + } } *retActualLength = (NINT)(p - (BYTE *)byteOutput); @@ -108,4 +114,4 @@ error: *retActualLength = 0; *byteOutput = 0; /* return NULL string */ return status; -} +} diff --git a/src/nwnss/library/unicode/componentUnicpy.c b/src/nwnss/library/unicode/componentUnicpy.c index f09f39d..e301940 100644 --- a/src/nwnss/library/unicode/componentUnicpy.c +++ b/src/nwnss/library/unicode/componentUnicpy.c @@ -34,7 +34,7 @@ | This module is used to: | NSS Library Routine +-------------------------------------------------------------------------*/ -#include +#include /************************************************************************** @@ -53,7 +53,7 @@ unicode_t *LB_componentUnicpy( /* Copy next individual component, including it's NULL */ while( (*dest++ = *src++) != (unicode_t)0 ) ; - } + } *dest = 0; return(odest); } diff --git a/src/nwnss/library/unicode/componentUnilen.c b/src/nwnss/library/unicode/componentUnilen.c index ed5f9b1..728d30d 100644 --- a/src/nwnss/library/unicode/componentUnilen.c +++ b/src/nwnss/library/unicode/componentUnilen.c @@ -35,7 +35,7 @@ | This is a temporary routine to emulate what the real unicode_t | routines will do. +-------------------------------------------------------------------------*/ -#include +#include /************************************************************************** * Returns the number of characters in the string diff --git a/src/nwnss/library/unicode/getMacCodePageName.c b/src/nwnss/library/unicode/getMacCodePageName.c index 4f478a8..ed8bf66 100644 --- a/src/nwnss/library/unicode/getMacCodePageName.c +++ b/src/nwnss/library/unicode/getMacCodePageName.c @@ -37,12 +37,12 @@ | 9/14/01: Instead of calling system routines for unicode conversion, NSS | has created is own set of conversion functions that are MP safe and fast. +-------------------------------------------------------------------------*/ -#if zLINUX && !defined(NSS_USERSPACE) +#if zLINUX #include "nssOSAPIs.h" #endif #include -#include -#include +#include +#include #include #if zNETWARE #include "nssOSAPIs.h" @@ -92,4 +92,4 @@ STATUS LB_GetMacCodePageName( strcpy(nameBuffer, MacintoshCodePageName); } return zOK; -} +} diff --git a/src/nwnss/library/unicode/getNssUnicodeVersion.c b/src/nwnss/library/unicode/getNssUnicodeVersion.c index 20911f5..ae91607 100644 --- a/src/nwnss/library/unicode/getNssUnicodeVersion.c +++ b/src/nwnss/library/unicode/getNssUnicodeVersion.c @@ -34,8 +34,9 @@ | This module is used to: | Get the version of NSS unicode translation +-------------------------------------------------------------------------*/ -#include -#include +#ifndef __linux__ +#include +#include /**************************************************************************** @@ -52,8 +53,10 @@ NINT LB_GetNssUnicodeVersion( void ) * * Versions returned by this funciton are: * - * 1 - using LIBC, first version checked in 10/31/03 + * 1 - using LIBC, first version checked in 10/31/03 * */ return(1); -} +} +#endif + diff --git a/src/nwnss/library/unicode/unicat.c b/src/nwnss/library/unicode/unicat.c index 9e30303..edd9b45 100644 --- a/src/nwnss/library/unicode/unicat.c +++ b/src/nwnss/library/unicode/unicat.c @@ -1 +1 @@ -#include "unicat.c.h" +#include diff --git a/src/nwnss/library/unicode/unicmp.c b/src/nwnss/library/unicode/unicmp.c index 4967e4f..8d732d3 100644 --- a/src/nwnss/library/unicode/unicmp.c +++ b/src/nwnss/library/unicode/unicmp.c @@ -1 +1 @@ -#include "unicmp.c.h" +#include diff --git a/src/nwnss/library/unicode/unicodeInit.c b/src/nwnss/library/unicode/unicodeInit.c index 2b42852..d8d1ae1 100644 --- a/src/nwnss/library/unicode/unicodeInit.c +++ b/src/nwnss/library/unicode/unicodeInit.c @@ -46,13 +46,13 @@ #include #include #else -#include +#include #include -#include -#include +#include +#include #include #include -#include +#include #endif /* Don't do the debug tables written to a file option */ //#define UNICODE_FILE_DEBUG @@ -60,7 +60,6 @@ LONG serverCodePage = 0; extern LONG OSGetCodePage(void); -void LB_UnicodeShutdown(void); /************************************************************************** * Global Variables for UNICODE @@ -85,15 +84,15 @@ NINT NSSUnicodeMappableToAsciiBitMap[ 64 * 1024 / (sizeof(NINT)*8) ]; * It is used to know if a unicode_t char maps to a Double-Byte ASCII char */ NINT NSSUnicodeIsDoubleByteAsciiBitMap[ 64 * 1024 / (sizeof(NINT)*8) ]; -/* This is an array used to store mapped unicode if a single byte +/* This is an array used to store mapped unicode if a single byte * character is mappable to a unicode */ unicode_t *NSSSingleByteToUnicodeTable[NSS_UNI_CONVERSION_COUNT]; - -/* This is an array used to store mapped unicode if a single byte + +/* This is an array used to store mapped unicode if a single byte * character is mappable to a unicode */ unicode_t *NSSDoubleByteToUnicodeTable[NSS_UNI_CONVERSION_COUNT]; -/* This is an array used to store mapped double bytes if a unicode +/* This is an array used to store mapped double bytes if a unicode * character is mappable */ BYTE *NSSUnicodeToByteTable[NSS_UNI_CONVERSION_COUNT]; @@ -116,15 +115,15 @@ NINT NSSUnicodeMappableToMacAsciiBitMap[ 64 * 1024 / (sizeof(NINT)*8) ]; * in the current Macintosh Code Page */ NINT NSSUnicodeIsDoubleByteMacAsciiBitMap[ 64 * 1024 / (sizeof(NINT)*8) ]; -/* This is an array used to store mapped unicode if a single Mac byte +/* This is an array used to store mapped unicode if a single Mac byte * character is mappable to a unicode */ unicode_t *NSSMacSingleByteToUnicodeTable; - -/* This is an array used to store mapped unicode if a single Mac byte + +/* This is an array used to store mapped unicode if a single Mac byte * character is mappable to a unicode */ unicode_t *NSSMacDoubleByteToUnicodeTable; -/* This is an array used to store mapped double Mac bytes if a unicode +/* This is an array used to store mapped double Mac bytes if a unicode * character is mappable */ BYTE *NSSMacUnicodeToByteTable; @@ -143,12 +142,12 @@ unicode_t NSSUniToLower[1 << BITS_PER_WORD]; unicode_t NSSUniToUpper[1 << BITS_PER_WORD]; /* This is a global variable that contains the raw translation value - * for a single ASCII FF character in unicode + * for a single ASCII FF character in unicode */ unicode_t NSSUnicodeFF; /* This is a global variable that contains the raw translation value - * for a single Macintosh ASCII FF character in unicode + * for a single Macintosh ASCII FF character in unicode */ unicode_t NSSUnicodeMacFF; @@ -208,7 +207,7 @@ STATUS ImportLIBCFunctionPtrs(void) if (LIBC_chr2lwr == NULL) { LIBC_chr2lwr = (void *)ImportPublicSymbol( - (LONG)COMN_Resource.moduleHandle, + (LONG)COMN_Resource.moduleHandle, (BYTE *)LIBC_chr2lwr_API); if (LIBC_chr2lwr == NULL) @@ -220,7 +219,7 @@ STATUS ImportLIBCFunctionPtrs(void) if (LIBC_chr2upr == NULL) { LIBC_chr2upr = (void *)ImportPublicSymbol( - (LONG)COMN_Resource.moduleHandle, + (LONG)COMN_Resource.moduleHandle, (BYTE *)LIBC_chr2upr_API); if (LIBC_chr2upr == NULL) @@ -232,7 +231,7 @@ STATUS ImportLIBCFunctionPtrs(void) if (LIBC_uni2loc == NULL) { LIBC_uni2loc = (void *)ImportPublicSymbol( - (LONG)COMN_Resource.moduleHandle, + (LONG)COMN_Resource.moduleHandle, (BYTE *)LIBC_uni2loc_API); if (LIBC_uni2loc == NULL) @@ -244,7 +243,7 @@ STATUS ImportLIBCFunctionPtrs(void) if (LIBC_uni2locpath == NULL) { LIBC_uni2locpath = (void *)ImportPublicSymbol( - (LONG)COMN_Resource.moduleHandle, + (LONG)COMN_Resource.moduleHandle, (BYTE *)LIBC_uni2locpath_API); if (LIBC_uni2locpath == NULL) @@ -256,7 +255,7 @@ STATUS ImportLIBCFunctionPtrs(void) if (LIBC_loc2uni == NULL) { LIBC_loc2uni = (void *)ImportPublicSymbol( - (LONG)COMN_Resource.moduleHandle, + (LONG)COMN_Resource.moduleHandle, (BYTE *)LIBC_loc2uni_API); if (LIBC_loc2uni == NULL) @@ -268,7 +267,7 @@ STATUS ImportLIBCFunctionPtrs(void) if (LIBC_loc2unipath == NULL) { LIBC_loc2unipath = (void *)ImportPublicSymbol( - (LONG)COMN_Resource.moduleHandle, + (LONG)COMN_Resource.moduleHandle, (BYTE *)LIBC_loc2unipath_API); if (LIBC_loc2unipath == NULL) @@ -280,7 +279,7 @@ STATUS ImportLIBCFunctionPtrs(void) if (LIBC_uniGetMacintoshTable == NULL) { LIBC_uniGetMacintoshTable = (void *)ImportPublicSymbol( - (LONG)COMN_Resource.moduleHandle, + (LONG)COMN_Resource.moduleHandle, (BYTE *)LIBC_uniGetMacintoshTable_API); if (LIBC_uniGetMacintoshTable == NULL) @@ -292,11 +291,6 @@ STATUS ImportLIBCFunctionPtrs(void) /* In Linux we import them by symbol */ #else printk("Importing LibC Unicode support\n"); - if (InitUniLibGlobals() != 0) - { - return zFAILURE; - } - if (LIBC_chr2lwr == NULL) { LIBC_chr2lwr = &chr2lwr; @@ -361,7 +355,7 @@ STATUS ImportLIBCFunctionPtrs(void) } #endif - + return zOK; } @@ -452,14 +446,14 @@ STATUS InitUnicodeBitMaps(void) asciiBuf[1] = 0; status = LIBC_loc2uni( UNI_LOCAL_DEFAULT, uniBuf, asciiBuf, 0, UNI_MAP_NO_CHAR ); if (status == 0) - { + { NSSUnicodeFF = uniBuf[0]; } else { /* If it failed there is no valid translation for 0xFF */ NSSUnicodeFF = UNI_INVALID2; - } + } return(zOK); } @@ -538,7 +532,7 @@ STATUS InitMacUnicodeBitMaps(void) MacintoshCodePageName = MSGNot("Roman"); break; } - + /* Get the rule table for the macintosh Code Page */ status = LIBC_uniGetMacintoshTable(MacintoshCodePageName, &MacCodePageUnicodeHandle); @@ -597,14 +591,14 @@ STATUS InitMacUnicodeBitMaps(void) asciiBuf[1] = 0; status = LIBC_loc2uni( MacCodePageUnicodeHandle, uniBuf, asciiBuf, 0, UNI_MAP_NO_CHAR ); if (status == 0) - { + { NSSUnicodeMacFF = uniBuf[0]; } else { /* If it failed there is no valid translation for 0xFF */ NSSUnicodeMacFF = UNI_INVALID2; - } + } return(zOK); } @@ -612,15 +606,6 @@ STATUS InitMacUnicodeBitMaps(void) /************************************************************************** * Build byte to unicode table according to the conversion type. ***************************************************************************/ -static BOOL IsNSSWildcardUnicode(unicode_t ch) -{ - return ((ch == UNI_WILD_QMARK) || - (ch == UNI_WILD_ASTERISK) || - (ch == UNI_WILD_AUG_QMARK) || - (ch == UNI_WILD_AUG_ASTERISK) || - (ch == UNI_WILD_AUG_PERIOD)); -} - STATUS buildByteToUnicodeTable( NINT conversionType) { @@ -631,21 +616,21 @@ STATUS buildByteToUnicodeTable( unicode_t uniBuf[2]; /* Allow space for double byte mappings */ NINT retActualLength; - NSSSingleByteToUnicodeTable[conversionType] = + NSSSingleByteToUnicodeTable[conversionType] = zalloc(256 * sizeof(unicode_t)); if (!NSSSingleByteToUnicodeTable[conversionType]) { return UNI_ERR_MEM_ALLOC; } - NSSDoubleByteToUnicodeTable[conversionType] = + NSSDoubleByteToUnicodeTable[conversionType] = zalloc(256 * 256 * sizeof(unicode_t)); if (!NSSDoubleByteToUnicodeTable[conversionType]) - { + { free(NSSSingleByteToUnicodeTable[conversionType]); return UNI_ERR_MEM_ALLOC; } - + buf[1] = 0; for (nextChr=1; nextChr < 256; nextChr++) { @@ -657,7 +642,7 @@ STATUS buildByteToUnicodeTable( */ if (NSSUnicodeOverrideByte2Uni[conversionType]( &uniBuf[0], buf)) { - /* The override function mapped this one. */ + /* The override function mapped this one. */ uniBuf[1] = 0; /* If the override function returns an invalid character it @@ -689,32 +674,32 @@ STATUS buildByteToUnicodeTable( status = LIBC_loc2unipath( UNI_LOCAL_DEFAULT, uniBuf, buf, NULL ); } if (status == 0) - { + { retActualLength = LB_unilen(uniBuf); if (!IS_INVALID_UNICODE_CHAR(uniBuf[0])) { zASSERT(uniBuf[0] != 0); zASSERT(retActualLength == 1); - + NSSSingleByteToUnicodeTable[conversionType][nextChr] = uniBuf[0]; } } - else if (status != UNI_ERR_UNMAPPABLE_CHAR) + else if (status != UNI_ERR_UNMAPPABLE_CHAR) { goto error_return; } } - + /* process all possible double bytes characters, one at a time */ buf[2] = 0; for (nextChr=1; nextChr < 256; nextChr++) - { + { if (NSSSingleByteToUnicodeTable[conversionType][nextChr]) { continue; } - + buf[0] = (BYTE)nextChr; for (idx = 0; idx < 256; idx++) { @@ -726,7 +711,7 @@ STATUS buildByteToUnicodeTable( */ if (NSSUnicodeOverrideByte2Uni[conversionType]( &uniBuf[0], buf)) { - /* The override function mapped this one. */ + /* The override function mapped this one. */ uniBuf[1] = 0; /* If the override function returns an invalid character it @@ -781,19 +766,19 @@ STATUS buildByteToUnicodeTable( status = LIBC_loc2unipath( UNI_LOCAL_DEFAULT, uniBuf, buf, NULL); } if (status == 0) - { + { retActualLength = LB_unilen(uniBuf); if (!IS_INVALID_UNICODE_CHAR(uniBuf[0])) { zASSERT(uniBuf[0] != 0); zASSERT(retActualLength == 1); - + NSSDoubleByteToUnicodeTable [conversionType][nextChr * 256 + idx] = uniBuf[0]; } } - else if (status != UNI_ERR_UNMAPPABLE_CHAR) + else if (status != UNI_ERR_UNMAPPABLE_CHAR) { goto error_return; } @@ -802,8 +787,8 @@ STATUS buildByteToUnicodeTable( return zOK; error_return: - return status; -} + return status; +} /************************************************************************** * Build Mac byte to unicode table @@ -825,11 +810,11 @@ STATUS buildMacByteToUnicodeTable( void ) NSSMacDoubleByteToUnicodeTable = zalloc(256 * 256 * sizeof(unicode_t)); if (!NSSDoubleByteToUnicodeTable) - { + { free(NSSMacSingleByteToUnicodeTable); return UNI_ERR_MEM_ALLOC; } - + buf[1] = 0; for (nextChr=1; nextChr < 256; nextChr++) { @@ -839,32 +824,32 @@ STATUS buildMacByteToUnicodeTable( void ) status = LIBC_loc2unipath( MacCodePageUnicodeHandle, uniBuf, buf, NULL); if (status == 0) - { + { retActualLength = LB_unilen(uniBuf); if (!IS_INVALID_UNICODE_CHAR(uniBuf[0])) { zASSERT(uniBuf[0] != 0); zASSERT(retActualLength == 1); - + NSSMacSingleByteToUnicodeTable[nextChr] = uniBuf[0]; } } - else if (status != UNI_ERR_UNMAPPABLE_CHAR) + else if (status != UNI_ERR_UNMAPPABLE_CHAR) { goto error_return; } } - + /* process all possible double bytes characters, one at a time */ buf[2] = 0; for (nextChr=1; nextChr < 256; nextChr++) - { + { if (NSSMacSingleByteToUnicodeTable[nextChr]) { continue; } - + buf[0] = (BYTE)nextChr; for (idx = 0; idx < 256; idx++) { @@ -874,18 +859,18 @@ STATUS buildMacByteToUnicodeTable( void ) status = LIBC_loc2unipath( MacCodePageUnicodeHandle, uniBuf, buf, NULL); if (status == 0) - { + { retActualLength = LB_unilen(uniBuf); if (!IS_INVALID_UNICODE_CHAR(uniBuf[0])) { zASSERT(uniBuf[0] != 0); zASSERT(retActualLength == 1); - + NSSMacDoubleByteToUnicodeTable[nextChr * 256 + idx] = uniBuf[0]; } } - else if (status != UNI_ERR_UNMAPPABLE_CHAR) + else if (status != UNI_ERR_UNMAPPABLE_CHAR) { goto error_return; } @@ -894,8 +879,8 @@ STATUS buildMacByteToUnicodeTable( void ) return zOK; error_return: - return status; -} + return status; +} /************************************************************************** * Build the unicode to byte table according to the conversion type. @@ -918,19 +903,19 @@ STATUS buildUnicodeToByteTable( /* Process all possible unicode characters, one at a time */ uniBuf[1] = 0; for (nextChr=1; nextChr < 256 * 256; nextChr++) - { + { if (!IS_UNICODE_MAPPABLE_TO_ASCII(nextChr)) { continue; } - + /* Call the Uni2Byte override function for conversion type. * If it returns TRUE then we have our translation. Otherwise, * call the LIBC function to translate it */ if ((NSSUnicodeOverrideUni2Byte[conversionType])( buf, nextChr )) { - /* The override function mapped this one. */ + /* The override function mapped this one. */ status = 0; } else @@ -942,31 +927,26 @@ STATUS buildUnicodeToByteTable( retActualLength = strlen(buf); if (status == 0) - { + { zASSERT((!IS_UNICODE_DOUBLE_BYTE_ASCII(nextChr) && (retActualLength == 1)) - || (IS_UNICODE_DOUBLE_BYTE_ASCII(nextChr) && (retActualLength == 2))); - - NSSUnicodeToByteTable[conversionType][nextChr * 2] = buf[0]; + || (IS_UNICODE_DOUBLE_BYTE_ASCII(nextChr) && (retActualLength == 2))); + + NSSUnicodeToByteTable[conversionType][nextChr * 2] = buf[0]; if (IS_UNICODE_DOUBLE_BYTE_ASCII(nextChr)) { NSSUnicodeToByteTable[conversionType][nextChr * 2 + 1] = buf[1]; } } - else + else { - if ((status == UNI_ERR_UNMAPPABLE_CHAR) && - IsNSSWildcardUnicode((unicode_t)nextChr)) - { - continue; - } goto error_return; } - } - + } + return zOK; error_return: - return status; + return status; } @@ -990,12 +970,12 @@ STATUS buildUnicodeToMacByteTable( void ) /* Process all possible unicode characters, one at a time */ uniBuf[1] = 0; for (nextChr=1; nextChr < 256 * 256; nextChr++) - { + { if (!IS_UNICODE_MAPPABLE_TO_MAC_ASCII(nextChr)) { continue; } - + uniBuf[0] = (unicode_t)nextChr; status = LIBC_uni2loc( MacCodePageUnicodeHandle, buf, uniBuf, 0, @@ -1004,26 +984,26 @@ STATUS buildUnicodeToMacByteTable( void ) retActualLength = strlen(buf); if (status == 0) - { + { zASSERT((!IS_UNICODE_DOUBLE_BYTE_MAC_ASCII(nextChr) && (retActualLength == 1)) - || (IS_UNICODE_DOUBLE_BYTE_MAC_ASCII(nextChr) && (retActualLength == 2))); - - NSSMacUnicodeToByteTable[nextChr * 2] = buf[0]; + || (IS_UNICODE_DOUBLE_BYTE_MAC_ASCII(nextChr) && (retActualLength == 2))); + + NSSMacUnicodeToByteTable[nextChr * 2] = buf[0]; if (IS_UNICODE_DOUBLE_BYTE_MAC_ASCII(nextChr)) { NSSMacUnicodeToByteTable[nextChr * 2 + 1] = buf[1]; } } - else + else { goto error_return; } - } - + } + return zOK; error_return: - return status; + return status; } @@ -1043,11 +1023,11 @@ void CheckUnicodeToAsciiReversible() NINT retActualLength; BYTE asciiBuf[4]; unicode_t uniBuf[2]; - + /* Process all possible unicode characters, one at a time */ uniBuf[1] = 0; for (nextChr=1; nextChr < 256 * 256; nextChr++) - { + { uniBuf[0] = (unicode_t)nextChr; /* Translate it with our own NSS library */ @@ -1093,7 +1073,7 @@ void CheckUnicodeToAsciiReversible() CLR_BIT(NSSUnicodeMappableToAsciiBitMap, nextChr); } } - } + } } /**************************************************************************** @@ -1112,11 +1092,11 @@ void CheckUnicodeToMacAsciiReversible() NINT retActualLength; BYTE asciiBuf[4]; unicode_t uniBuf[2]; - + /* Process all possible unicode characters, one at a time */ uniBuf[1] = 0; for (nextChr=1; nextChr < 256 * 256; nextChr++) - { + { uniBuf[0] = (unicode_t)nextChr; /* Translate it with our own NSS library */ @@ -1150,12 +1130,12 @@ void CheckUnicodeToMacAsciiReversible() CLR_BIT(NSSUnicodeMappableToMacAsciiBitMap, nextChr); } } - } + } } /************************************************************************** * Initialize: - * a single byte to unicode table + * a single byte to unicode table * a double byte to unicode table * a unicode to byte table ***************************************************************************/ @@ -1163,11 +1143,11 @@ STATUS InitByteUnicodeTable() { NINT idx; STATUS status; - - memset(NSSSingleByteToUnicodeTable, 0, sizeof(NSSSingleByteToUnicodeTable)); - memset(NSSDoubleByteToUnicodeTable, 0, sizeof(NSSDoubleByteToUnicodeTable)); - memset(NSSUnicodeToByteTable, 0, sizeof(NSSUnicodeToByteTable)); - + + bzero(NSSSingleByteToUnicodeTable, sizeof(NSSSingleByteToUnicodeTable)); + bzero(NSSDoubleByteToUnicodeTable, sizeof(NSSDoubleByteToUnicodeTable)); + bzero(NSSUnicodeToByteTable, sizeof(NSSUnicodeToByteTable)); + for (idx = 0; idx < NSS_UNI_CONVERSION_COUNT; idx++) { if (NSSUnicodeConverterDefined[idx]) @@ -1177,7 +1157,7 @@ STATUS InitByteUnicodeTable() { return status; } - + status = buildUnicodeToByteTable(idx); if (status) { @@ -1192,27 +1172,27 @@ STATUS InitByteUnicodeTable() * character when the translation is reversed using our tables. */ CheckUnicodeToAsciiReversible(); - + return zOK; } /************************************************************************** * Initialize: - * a single byte to unicode table + * a single byte to unicode table * a double byte to unicode table * a unicode to byte table ***************************************************************************/ STATUS InitMacByteUnicodeTable() { STATUS status; - + status = buildMacByteToUnicodeTable(); if (status) { return status; } - + status = buildUnicodeToMacByteTable(); if (status) { @@ -1225,7 +1205,7 @@ STATUS InitMacByteUnicodeTable() * character when the translation is reversed using our tables. */ CheckUnicodeToMacAsciiReversible(); - + return zOK; } @@ -1301,7 +1281,7 @@ void DBG_WriteUnicodeDebugFile( return; } offset += numberOfBytes; - + sprintf(buffer, "--------------------------------------------------------------------------------\n"); numberOfBytes = strlen(buffer); ZOS_LDOSWrite( status, handle, offset, buffer, numberOfBytes, &actualBytes); @@ -1459,17 +1439,17 @@ void DBG_WriteUnicodeDebugFile( } offset += numberOfBytes; } - } - + } + /* process all possible double bytes characters, one at a time */ asciiBuf1[2] = 0; for (nextChr=1; nextChr < 256; nextChr++) - { + { if (NSSSingleByteToUnicodeTable[ruleTableID][nextChr]) { continue; } - + asciiBuf1[0] = (BYTE)nextChr; for (idx = 0; idx < 256; idx++) { @@ -1485,7 +1465,7 @@ void DBG_WriteUnicodeDebugFile( if ((status == 0) && (!IS_INVALID_UNICODE_CHAR(uniBuf1[0]))) - { + { sprintf(buffer, "0x%02x:%02x 0x%04x ",asciiBuf1[0],asciiBuf1[1],uniBuf1[0]); /* Translate this character to unicode using the PATH version. */ @@ -1595,7 +1575,7 @@ void DBG_WriteUnicodeDebugFile( offset += numberOfBytes; } } - } + } @@ -1626,7 +1606,7 @@ void DBG_WriteUnicodeDebugFile( /* Process all possible unicode characters, one at a time */ uniBuf1[1] = 0; for (nextChr=1; nextChr < 256 * 256; nextChr++) - { + { pathDifferent = FALSE; reverseDifferent = FALSE; nonPathDifferent = FALSE; @@ -1636,9 +1616,9 @@ void DBG_WriteUnicodeDebugFile( /* Translate it with our own NSS library */ status = LB_UnicodeToByte(ruleTableID, asciiBuf1, sizeof(asciiBuf1), uniBuf1, &retActualLength); - + if ((status == 0) && (retActualLength < 3)) - { + { sprintf(buffer, "0x%04x ",uniBuf1[0]); if (retActualLength == 1) @@ -1771,8 +1751,8 @@ void DBG_WriteUnicodeDebugFile( } offset += numberOfBytes; } - } - + } + /*----------------------------------------------------------------------- * Write out the Unicode lower case tables *-----------------------------------------------------------------------*/ @@ -1800,7 +1780,7 @@ void DBG_WriteUnicodeDebugFile( /* Process all possible unicode characters, one at a time */ uniBuf1[1] = 0; for (nextChr=1; nextChr < 256 * 256; nextChr++) - { + { if (nextChr != NSSUniToLower[nextChr]) { uniBuf1[0] = nextChr; @@ -1820,8 +1800,8 @@ void DBG_WriteUnicodeDebugFile( } offset += numberOfBytes; } - } - + } + /*----------------------------------------------------------------------- * Write out the Unicode upper case tables *-----------------------------------------------------------------------*/ @@ -1849,7 +1829,7 @@ void DBG_WriteUnicodeDebugFile( /* Process all possible unicode characters, one at a time */ uniBuf1[1] = 0; for (nextChr=1; nextChr < 256 * 256; nextChr++) - { + { if (nextChr != NSSUniToUpper[nextChr]) { uniBuf1[0] = nextChr; @@ -1869,8 +1849,8 @@ void DBG_WriteUnicodeDebugFile( } offset += numberOfBytes; } - } - + } + ZOS_LDOSClose( handle ); } @@ -1923,7 +1903,7 @@ void DBG_WriteMacUnicodeDebugFile( void ) return; } offset += numberOfBytes; - + sprintf(buffer, "--------------------------------------------------------------------------------\n"); numberOfBytes = strlen(buffer); ZOS_LDOSWrite( status, handle, offset, buffer, numberOfBytes, &actualBytes); @@ -2081,17 +2061,17 @@ void DBG_WriteMacUnicodeDebugFile( void ) } offset += numberOfBytes; } - } - + } + /* process all possible double bytes characters, one at a time */ asciiBuf1[2] = 0; for (nextChr=1; nextChr < 256; nextChr++) - { + { if (NSSMacSingleByteToUnicodeTable[nextChr]) { continue; } - + asciiBuf1[0] = (BYTE)nextChr; for (idx = 0; idx < 256; idx++) { @@ -2107,7 +2087,7 @@ void DBG_WriteMacUnicodeDebugFile( void ) if ((status == 0) && (!IS_INVALID_UNICODE_CHAR(uniBuf1[0]))) - { + { sprintf(buffer, "0x%02x:%02x 0x%04x ",asciiBuf1[0],asciiBuf1[1],uniBuf1[0]); /* Translate this character to unicode using the PATH version. */ @@ -2217,7 +2197,7 @@ void DBG_WriteMacUnicodeDebugFile( void ) offset += numberOfBytes; } } - } + } @@ -2248,7 +2228,7 @@ void DBG_WriteMacUnicodeDebugFile( void ) /* Process all possible unicode characters, one at a time */ uniBuf1[1] = 0; for (nextChr=1; nextChr < 256 * 256; nextChr++) - { + { pathDifferent = FALSE; reverseDifferent = FALSE; nonPathDifferent = FALSE; @@ -2258,9 +2238,9 @@ void DBG_WriteMacUnicodeDebugFile( void ) /* Translate it with our own NSS library */ status = LB_UnicodeToMacByte(NSS_UNI_CONVERSION_RAW, asciiBuf1, sizeof(asciiBuf1), uniBuf1, &retActualLength); - + if ((status == 0) && (retActualLength < 3)) - { + { sprintf(buffer, "0x%04x ",uniBuf1[0]); if (retActualLength == 1) @@ -2393,8 +2373,8 @@ void DBG_WriteMacUnicodeDebugFile( void ) } offset += numberOfBytes; } - } - + } + ZOS_LDOSClose( handle ); } #endif @@ -2415,7 +2395,7 @@ STATUS LB_UnicodeStartup(void) MPKNSS_UNLOCK(); serverCodePage = OSGetCodePage(); - + status = ImportLIBCFunctionPtrs(); if (status != zOK) { @@ -2430,21 +2410,21 @@ STATUS LB_UnicodeStartup(void) * DEFAULT UNICODE to BYTE and BYTE to UNICODE converter for wildcarding *-------------------------------------------------------------------------*/ NSSUnicodeConverterDefined[NSS_UNI_CONVERSION_WILD] = TRUE; - NSSUnicodeOverrideUni2Byte[NSS_UNI_CONVERSION_WILD] = Uni2ByteOverride; + NSSUnicodeOverrideUni2Byte[NSS_UNI_CONVERSION_WILD] = Uni2ByteOverride; NSSUnicodeOverrideByte2Uni[NSS_UNI_CONVERSION_WILD] = Byte2UniDefaultOverride; /*------------------------------------------------------------------------- * RAW UNICODE to BYTE and BYTE to UNICODE converter *-------------------------------------------------------------------------*/ NSSUnicodeConverterDefined[NSS_UNI_CONVERSION_RAW] = TRUE; - NSSUnicodeOverrideUni2Byte[NSS_UNI_CONVERSION_RAW] = Uni2ByteOverride; + NSSUnicodeOverrideUni2Byte[NSS_UNI_CONVERSION_RAW] = Uni2ByteOverride; NSSUnicodeOverrideByte2Uni[NSS_UNI_CONVERSION_RAW] = Byte2UniRawOverride; /*------------------------------------------------------------------------- * DOS UNICODE to BYTE and BYTE to UNICODE converter for wildcarding *-------------------------------------------------------------------------*/ NSSUnicodeConverterDefined[NSS_UNI_CONVERSION_WILD_DOS] = TRUE; - NSSUnicodeOverrideUni2Byte[NSS_UNI_CONVERSION_WILD_DOS] = Uni2ByteOverride; + NSSUnicodeOverrideUni2Byte[NSS_UNI_CONVERSION_WILD_DOS] = Uni2ByteOverride; NSSUnicodeOverrideByte2Uni[NSS_UNI_CONVERSION_WILD_DOS] = Byte2UniDOSOverride; /*--------------------------------------------------------------------------- @@ -2485,7 +2465,7 @@ STATUS LB_UnicodeStartup(void) DBG_WriteUnicodeDebugFile(NSS_UNI_CONVERSION_RAW); DBG_WriteUnicodeDebugFile(NSS_UNI_CONVERSION_WILD_DOS); DBG_WriteMacUnicodeDebugFile(); - } + } #endif #endif @@ -2507,7 +2487,7 @@ error_byteUnicodeTable: printk("\nNSS-2.70-408: Error initializing byte-unicode table (%d).\n" "Contact your Novell Technical Support Provider.\n", status); #endif - goto error_cleanup; + goto error_cleanup; error_noMapBitMap: #ifndef __linux__ @@ -2519,7 +2499,7 @@ error_noMapBitMap: printk("\nNSS-2.70-227: Error initializing unicode bitMaps (%d).\n" "Contact your Novell Technical Support Provider.\n", status); #endif - goto error_cleanup; + goto error_cleanup; error_noMapMacBitMap: #ifndef __linux__ @@ -2531,7 +2511,7 @@ error_noMapMacBitMap: printk("\nNSS-2.70-229: Error initializing unicode bitMaps for Macintosh (%d).\n" "Contact your Novell Technical Support Provider.\n", status); #endif - goto error_cleanup; + goto error_cleanup; error_noLibcImports: #ifndef __linux__ @@ -2564,12 +2544,12 @@ void LB_UnicodeShutdown(void) { free(NSSSingleByteToUnicodeTable[i]); } - + if (NSSDoubleByteToUnicodeTable[i] != NULL) { free(NSSDoubleByteToUnicodeTable[i]); } - + if (NSSUnicodeToByteTable[i] != NULL) { free(NSSUnicodeToByteTable[i]); @@ -2594,7 +2574,7 @@ STATUS UnicodeErrorTranslate( case UNI_ERR_MEM_ALLOC: nssError = zERR_NO_MEMORY; break; - case UNI_ERR_TOO_FEW_BYTES: + case UNI_ERR_TOO_FEW_BYTES: nssError = zERR_BUFFER_TOO_SMALL; break; case UNI_ERR_PREMATURE_END: @@ -2609,18 +2589,3 @@ STATUS UnicodeErrorTranslate( } return nssError; } - -#if zLINUX && !defined(__KERNEL__) -__attribute__((constructor)) -static void mars_nss_unicode_startup_constructor(void) -{ - /* LB_UnicodeStartup() follows the original NSS convention: caller enters - * with MPKNSS held, the routine drops it while building the large unicode - * tables, then reacquires it before returning. The userspace constructor - * must therefore establish the same lock state instead of calling it bare. - */ - MPKNSS_LOCK(); - (void)LB_UnicodeStartup(); - MPKNSS_UNLOCK(); -} -#endif diff --git a/src/nwnss/library/unicode/unicodeParse.c b/src/nwnss/library/unicode/unicodeParse.c index d114536..08e66e8 100644 --- a/src/nwnss/library/unicode/unicodeParse.c +++ b/src/nwnss/library/unicode/unicodeParse.c @@ -34,15 +34,11 @@ | This module is used to: | Contains unicode_t parsing routines +-------------------------------------------------------------------------*/ -/* MARS-NWE: expose NSS internal converter globals from xUnicode.h. */ -#ifndef _NSS_INTERNAL_ -#define _NSS_INTERNAL_ -#endif -#if zLINUX && !defined(NSS_USERSPACE) +#if zLINUX #include "nssOSAPIs.h" #endif #include -#include +#include #include #include #if zNETWARE @@ -91,7 +87,7 @@ BOOL Byte2UniDefaultOverride( /* We did NOT translate this ASCII character */ return(FALSE); -} +} /************************************************************************** @@ -146,11 +142,11 @@ BOOL Byte2UniDOSOverride( /* We did NOT translate this ASCII character */ return(FALSE); -} +} /************************************************************************** - * uni2Byte Override funciton that will override unicode to ASCII + * uni2Byte Override funciton that will override unicode to ASCII * translations for the NSS_UNI_CONVERSION_WILD, NSS_UNI_CONVERSION_RAW and * NSS_UNI_CONVERSION_WILD_DOS converter types. ***************************************************************************/ @@ -191,7 +187,7 @@ BOOL Uni2ByteOverride( output[2] = 0; /* We DID translate this unicode character */ return(TRUE); -} +} /************************************************************************** @@ -202,11 +198,11 @@ BOOL Byte2UniRawOverride( unicode_t *output, BYTE *input) { - /* This function currently does not do any overrides for the RAW + /* This function currently does not do any overrides for the RAW * translations. The LIBC tables are fine for our needs. This is * just a space filler in case we ever need to add any overrides. */ /* We did NOT translate any ASCII character */ return(FALSE); -} +} diff --git a/src/nwnss/library/unicode/unicpy.c b/src/nwnss/library/unicode/unicpy.c index b3c2d9c..27fd11c 100644 --- a/src/nwnss/library/unicode/unicpy.c +++ b/src/nwnss/library/unicode/unicpy.c @@ -1 +1 @@ -#include "unicpy.c.h" +#include diff --git a/src/nwnss/library/unicode/uniicmp.c b/src/nwnss/library/unicode/uniicmp.c index aeb3799..e85481b 100644 --- a/src/nwnss/library/unicode/uniicmp.c +++ b/src/nwnss/library/unicode/uniicmp.c @@ -34,7 +34,7 @@ | This module is used to: | Do a case insenstive compare of a pair of two unicode strings +-------------------------------------------------------------------------*/ -#include +#include int LB_uniicmp( register const unicode_t *s1, diff --git a/src/nwnss/library/unicode/uniicmpmac.c b/src/nwnss/library/unicode/uniicmpmac.c index ed43398..7eccbfa 100644 --- a/src/nwnss/library/unicode/uniicmpmac.c +++ b/src/nwnss/library/unicode/uniicmpmac.c @@ -35,7 +35,7 @@ | NSS Library Routine for uniicmp with MAC rules +-------------------------------------------------------------------------*/ #include -#include +#include /* return <0 if s0 if s>t */ diff --git a/src/nwnss/library/unicode/unilen.c b/src/nwnss/library/unicode/unilen.c index ed77a6e..c6a27b7 100644 --- a/src/nwnss/library/unicode/unilen.c +++ b/src/nwnss/library/unicode/unilen.c @@ -1 +1 @@ -#include "unilen.c.h" +#include diff --git a/src/nwnss/library/unicode/unilwr.c b/src/nwnss/library/unicode/unilwr.c index 7c5025d..e0c44b7 100644 --- a/src/nwnss/library/unicode/unilwr.c +++ b/src/nwnss/library/unicode/unilwr.c @@ -34,7 +34,14 @@ | This module is used to: | NSS Library Routine +-------------------------------------------------------------------------*/ -#include +#if zLINUX +#include "nssOSAPIs.h" +#endif +#include +#include +#if zNETWARE +#include "nssOSAPIs.h" +#endif /************************************************************************** * Convert the string to LOWER case. diff --git a/src/nwnss/library/unicode/unimcpy.c b/src/nwnss/library/unicode/unimcpy.c index 918cae1..f3b52a3 100644 --- a/src/nwnss/library/unicode/unimcpy.c +++ b/src/nwnss/library/unicode/unimcpy.c @@ -1 +1 @@ -#include "unimcpy.c.h" +#include diff --git a/src/nwnss/library/unicode/uninicmp.c b/src/nwnss/library/unicode/uninicmp.c index 2b58485..9d8315a 100644 --- a/src/nwnss/library/unicode/uninicmp.c +++ b/src/nwnss/library/unicode/uninicmp.c @@ -35,7 +35,7 @@ | Do a case insenstive compare of a pair of two unicode strings | to n characters. +-------------------------------------------------------------------------*/ -#include +#include int LB_uninicmp( register const unicode_t *s1, diff --git a/src/nwnss/library/unicode/unitolower.c b/src/nwnss/library/unicode/unitolower.c index 31e1347..184fd34 100644 --- a/src/nwnss/library/unicode/unitolower.c +++ b/src/nwnss/library/unicode/unitolower.c @@ -34,10 +34,18 @@ | This module is used to: | NSS Library Routine +-------------------------------------------------------------------------*/ -#include +#if zLINUX +#include "nssOSAPIs.h" +#endif +#include +#include +#if zNETWARE +#include "nssOSAPIs.h" +#endif unicode_t LB_unitolower( CONST unicode_t ch) { return NSSUniToLower[ch]; } + diff --git a/src/nwnss/library/unicode/unitoupper.c b/src/nwnss/library/unicode/unitoupper.c index 9e9a7a1..e9e6506 100644 --- a/src/nwnss/library/unicode/unitoupper.c +++ b/src/nwnss/library/unicode/unitoupper.c @@ -34,10 +34,18 @@ | This module is used to: | NSS Library Routine +-------------------------------------------------------------------------*/ -#include +#if zLINUX +#include "nssOSAPIs.h" +#endif +#include +#include +#if zNETWARE +#include "nssOSAPIs.h" +#endif unicode_t LB_unitoupper( CONST unicode_t ch) { return NSSUniToUpper[ch]; } + diff --git a/src/nwnss/library/unicode/uniupr.c b/src/nwnss/library/unicode/uniupr.c index e9b7c7a..ca7ff93 100644 --- a/src/nwnss/library/unicode/uniupr.c +++ b/src/nwnss/library/unicode/uniupr.c @@ -34,7 +34,14 @@ | This module is used to: | NSS Library Routine +-------------------------------------------------------------------------*/ -#include +#if zLINUX +#include "nssOSAPIs.h" +#endif +#include +#include +#if zNETWARE +#include "nssOSAPIs.h" +#endif /************************************************************************** * Convert the string to UPPER case. diff --git a/src/nwnss/library/unicode/utf8LenToUniChar.c b/src/nwnss/library/unicode/utf8LenToUniChar.c index d0c854b..d47e613 100644 --- a/src/nwnss/library/unicode/utf8LenToUniChar.c +++ b/src/nwnss/library/unicode/utf8LenToUniChar.c @@ -35,8 +35,8 @@ | Convert the next character of a UTF8 string to unicode +-------------------------------------------------------------------------*/ #include -#include -#include +#include +#include /************************************************************************** * This converts the next character sequence of a NULL terminated UTF8 string @@ -59,11 +59,11 @@ STATUS LB_UTF8LenToUniChar( NINT bytesConsumed; /* If the buffer is empty, return a NULL unicode character */ - if (utf8InputLen == 0) + if (utf8InputLen == 0) { uniChar = 0; *retNextUtf8Input = utf8Input; - *retUtf8Len = utf8InputLen; + *retUtf8Len = utf8InputLen; goto functionExit; } @@ -121,13 +121,13 @@ STATUS LB_UTF8LenToUniChar( if (uniChar != 0) { *retNextUtf8Input = tempPtr; - *retUtf8Len = utf8InputLen - bytesConsumed; + *retUtf8Len = utf8InputLen - bytesConsumed; } else { /* Don't advance next input pointer if we hit a NULL char */ *retNextUtf8Input = utf8Input; - *retUtf8Len = utf8InputLen; + *retUtf8Len = utf8InputLen; } functionExit: @@ -138,6 +138,6 @@ functionExit: InvalidChar: *retUnicodeChar = 0; *retNextUtf8Input = utf8Input; - *retUtf8Len = utf8InputLen; + *retUtf8Len = utf8InputLen; return(zERR_INVALID_UTF8_CHAR); -} +} diff --git a/src/nwnss/library/unicode/utf8ToUniChar.c b/src/nwnss/library/unicode/utf8ToUniChar.c index 90e78ce..efe61ca 100644 --- a/src/nwnss/library/unicode/utf8ToUniChar.c +++ b/src/nwnss/library/unicode/utf8ToUniChar.c @@ -35,8 +35,8 @@ | Convert the next character of a UTF8 string to unicode +-------------------------------------------------------------------------*/ #include -#include -#include +#include +#include /************************************************************************** * This converts the next character sequence of a NULL terminated UTF8 string @@ -104,4 +104,4 @@ STATUS LB_UTF8ToUniChar( } *retUnicodeChar = uniChar; return(zOK); -} +} diff --git a/src/nwnss/library/unicode/utf_tolower.c b/src/nwnss/library/unicode/utf_tolower.c index cdd183e..f57f927 100644 --- a/src/nwnss/library/unicode/utf_tolower.c +++ b/src/nwnss/library/unicode/utf_tolower.c @@ -37,7 +37,7 @@ | invalid utf8 char, we just return what we have done so far. +-------------------------------------------------------------------------*/ -#include +#include /* * UTF-8 is a encoding of Unicode developed by Bell Labs @@ -51,7 +51,7 @@ * 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx * 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx * - * The last two formats are for 32 bit unicode. + * The last two formats are for 32 bit unicode. * * Information taken from "Java in a Nutshell": * 1. All ASCII characters are one-byte UTF-8 characters. A legal @@ -84,7 +84,7 @@ int utf_tolower ( { if( c >= 'A' && c <= 'Z' ) { - c = c - 'A' + 'a'; + c = c - 'A' + 'a'; } if (p_utf) { diff --git a/include/nwnss/unicodeInit.h b/src/nwnss/library/unicodeInit.h similarity index 97% rename from include/nwnss/unicodeInit.h rename to src/nwnss/library/unicodeInit.h index 6ae4892..f6afb60 100644 --- a/include/nwnss/unicodeInit.h +++ b/src/nwnss/library/unicodeInit.h @@ -44,7 +44,7 @@ #endif #ifndef _XUNICODE_H_ -#include +#include #endif /*------------------------------------------------------------------------- @@ -62,8 +62,8 @@ extern BYTE *MacintoshCodePageName; /* Code page name defines for DOS/Windows code pages */ #define CP_DOS_LATIN 437 #define CP_DOS_GREEK_ 737 -#define CP_DOS_BALTIC 775 -#define CP_DOS_CANADA 850 +#define CP_DOS_BALTIC 775 +#define CP_DOS_CANADA 850 #define CP_DOS_SLAVIC 852 #define CP_DOS_CYRILLIC 855 #define CP_DOS_TURKISH 857 @@ -115,3 +115,5 @@ extern BOOL Uni2ByteOverride( unicode_t input); #endif + + diff --git a/src/nwnss/library/unssLIBRARYSym.c b/src/nwnss/library/unssLIBRARYSym.c new file mode 100644 index 0000000..8730afc --- /dev/null +++ b/src/nwnss/library/unssLIBRARYSym.c @@ -0,0 +1,122 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export library debug symbols to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +EXPORT_SYMBOL(DBG_AssertError); +EXPORT_SYMBOL(DBG_AssertError_MP); +EXPORT_SYMBOL(DBG_AssertErrorStub); +EXPORT_SYMBOL(DBG_AssertWarning); +EXPORT_SYMBOL(DBG_DebugBreak); +EXPORT_SYMBOL(DBG_DebugEnabled); +EXPORT_SYMBOL(DBG_DebugFlag); +EXPORT_SYMBOL(DBG_DebugFormatBinary); +EXPORT_SYMBOL(DBG_DebugHexDump); +EXPORT_SYMBOL(DBG_DebugMask); +EXPORT_SYMBOL(DBG_debugLogMask); +EXPORT_SYMBOL(DBG_debugLogBuffer); +EXPORT_SYMBOL(DBG_debugLogBufferInsert); +EXPORT_SYMBOL(DBG_debugLogBufferRemove); +EXPORT_SYMBOL(DBG_DebugLogBufferSize); +EXPORT_SYMBOL(DBG_DebugPrintf); +EXPORT_SYMBOL(DBG_Denter); +EXPORT_SYMBOL(DBG_Dindent); +EXPORT_SYMBOL(DBG_DrtnNINT); +EXPORT_SYMBOL(DBG_DrtnPtr); +EXPORT_SYMBOL(DBG_DrtnStatus); +EXPORT_SYMBOL(DBG_DrtnVoid); +EXPORT_SYMBOL(DBG_error); +//WRONG PLACE//EXPORT_SYMBOL(DBG_fatal); +//WRONG PLACE//EXPORT_SYMBOL(DBG_HookNCPLog); +//WRONG PLACE//EXPORT_SYMBOL(DBG_HookNCPTrace); +EXPORT_SYMBOL(DBG_InitDebug); +EXPORT_SYMBOL(DBG_NotImpDbgMsg); +EXPORT_SYMBOL(DBG_PageSize); +EXPORT_SYMBOL(DBG_Paging); +EXPORT_SYMBOL(DBG_prseq); +EXPORT_SYMBOL(DBG_SavedDebugFlag); +EXPORT_SYMBOL(DBG_SavedTraceFlag); +EXPORT_SYMBOL(DBG_ScreenAPrintf); +EXPORT_SYMBOL(DBG_ScreenDebug); +EXPORT_SYMBOL(DBG_ScreenSwitches); +EXPORT_SYMBOL(DBG_Shutdown); +EXPORT_SYMBOL(DBG_Startup); +EXPORT_SYMBOL(DBG_Stub); +EXPORT_SYMBOL(DBG_TraceEnabled); +EXPORT_SYMBOL(DBG_TraceFlag); +//WRONG PLACE//EXPORT_SYMBOL(DBG_UnHookNCPLog); +//WRONG PLACE//EXPORT_SYMBOL(DBG_UnHookNCPTrace); +EXPORT_SYMBOL(DBG_UninitDebug); +EXPORT_SYMBOL(LBL_sForce); +EXPORT_SYMBOL(LBL_xForce); +EXPORT_SYMBOL(LBL_addLatch); +EXPORT_SYMBOL(LBL_initLatch); +EXPORT_SYMBOL(LBL_initSlatch); +EXPORT_SYMBOL(LBL_initXlatch); +EXPORT_SYMBOL(LBL_sLatch); +EXPORT_SYMBOL(LBL_sNoWait); +EXPORT_SYMBOL(LBL_fsmSlatch); +EXPORT_SYMBOL(LBL_xLatch); +EXPORT_SYMBOL(LBL_xNoWait); +EXPORT_SYMBOL(LBL_fsmXlatch); +EXPORT_SYMBOL(LBL_upLatch); +EXPORT_SYMBOL(LBL_upNoWait); +EXPORT_SYMBOL(LBL_fsmUpLatch); +EXPORT_SYMBOL(LBL_downLatch); +EXPORT_SYMBOL(LBL_unsLatch); +EXPORT_SYMBOL(LBL_unxLatch); +EXPORT_SYMBOL(LBL_unLatch); +EXPORT_SYMBOL(LBL_initCount); +EXPORT_SYMBOL(LBL_incCount); +EXPORT_SYMBOL(LBL_decCount); +EXPORT_SYMBOL(LBL_grab); +EXPORT_SYMBOL(LBL_drop); +EXPORT_SYMBOL(LBL_fsmGrab); +EXPORT_SYMBOL(DBGL_latchSetup); +EXPORT_SYMBOL(DBGL_latchCleanup); +EXPORT_SYMBOL(LB_MEMORY_DISPLAY_SETUP); +EXPORT_SYMBOL(fsmInit); diff --git a/src/nwnss/library/utc/default.dsc b/src/nwnss/library/utc/default.dsc new file mode 100644 index 0000000000000000000000000000000000000000..0b3592df28d8f28b1d699a6025d31b15a4b54d0a GIT binary patch literal 2571 zcmaEVc6FyqW@1i$x`In;adJ^+K}lwQo`PFuPO5@$VqRi;YLP;ip`HQ5?HX5G4h9AW z=g^=aSHBP-3ksY|i;7b7N)(*)bMlK6f>TRMGV{`lVX{CvCEe9_0w-92{r~^}+#uG8 z3s)GRYzG((6b8!!`3wy}4pf{S$Y4WK4_4FA(14JKs0ES`{U8QNJ&X@xBlCeKGs4V< z(Ek}x%=^#41kwxB|DS<@8R#Sy7#|zW0M!FC59DTKbq5X{-~#c{G1MIthlhg$Qg{I^ z0h$XW$qx?{^M+t}G*CG_P|O>G;o$(xQP8voN`sWA4`lO(Vt7!w{BS@vZwQ7*1A_xq z(+7%qLohrX9H^XMkj)#4;Q=W#Ky^2j$`5cE1Tk+2h6e+c^9zc3bP5kfP(=U)nm`O< F0|4LefI$EN literal 0 HcmV?d00001 diff --git a/src/nwnss/library/utc/dos2str.c b/src/nwnss/library/utc/dos2str.c index 70bff84..d3efe56 100644 --- a/src/nwnss/library/utc/dos2str.c +++ b/src/nwnss/library/utc/dos2str.c @@ -35,7 +35,7 @@ | NSS Library source routine that converts dos time to an ascii | date and time string +-------------------------------------------------------------------------*/ -#include +#include #include #include diff --git a/src/nwnss/library/utc/dos2utc.c b/src/nwnss/library/utc/dos2utc.c index 461c57f..922acf1 100644 --- a/src/nwnss/library/utc/dos2utc.c +++ b/src/nwnss/library/utc/dos2utc.c @@ -34,8 +34,8 @@ | This module is used to: | NSS Library source routine that converts time +-------------------------------------------------------------------------*/ -#include /* NetWare include */ -#include /* NSS LIBRARY Include */ +#include /* NetWare include */ +#include /* NSS LIBRARY Include */ #include #ifdef _NWMOAB_ @@ -43,7 +43,7 @@ # include #endif -#include /* NSS LIBRARY include */ +#include /* NSS LIBRARY include */ extern WORD monthTotal[]; extern WORD monthLeapTotal[]; @@ -63,7 +63,7 @@ Time_t doDOS2utcTime( if (DOSTime == INVALID_DOS_TIME) return(INVALID_UTC_TIME); - + seconds = (DOSTime & 0x1f) << 1; minutes = (DOSTime >> 5) & 0x3f; hours = (DOSTime >> 11) & 0x1f; @@ -90,16 +90,16 @@ Time_t doDOS2utcTime( UTC = totalDays * (24 * 60 * 60) + hours * (60 * 60) + minutes * 60 + seconds; - /* + /* * Adjust the local time to UTC using time zone and DST offsets * unless the state is set to take times without adjustment. */ if (!IgnoreTimeZone) { - if (inDaylightSavingTime(UTC, NSS_DaylightOnOff)) + if (inDaylightSavingTime(UTC, NSS_DaylightOnOff)) UTC -= NSS_DaylightOffset; - + UTC += NSS_TimeZoneOffset; } return UTC; @@ -113,11 +113,11 @@ struct { Time_t DOS2utcTime( DOSTime_t DOSTime) { - enum - { - dosSHIFT = 10, - dosSIZE = 1 << dosSHIFT, - dosMASK = dosSIZE - 1 + enum + { + dosSHIFT = 10, + dosSIZE = 1 << dosSHIFT, + dosMASK = dosSIZE - 1 }; static struct @@ -156,12 +156,12 @@ Time_t DOS2utcTime( ResetTimeCache &= ~TIME_DOS2UTC; } - if (dosHash[hashKey].dos == DOSTime) + if (dosHash[hashKey].dos == DOSTime) { ++Dos2utc.hits; return dosHash[hashKey].utc; - } - else + } + else { ++Dos2utc.misses; dosHash[hashKey].dos = DOSTime; diff --git a/src/nwnss/library/utc/dosd2str.c b/src/nwnss/library/utc/dosd2str.c index c6a6809..8567c03 100644 --- a/src/nwnss/library/utc/dosd2str.c +++ b/src/nwnss/library/utc/dosd2str.c @@ -35,7 +35,7 @@ | NSS Library source routine that converts dos time to an ascii | date string +-------------------------------------------------------------------------*/ -#include +#include #include #include "utcData.h" diff --git a/src/nwnss/library/utc/dost2str.c b/src/nwnss/library/utc/dost2str.c index a6faabe..0fc3912 100644 --- a/src/nwnss/library/utc/dost2str.c +++ b/src/nwnss/library/utc/dost2str.c @@ -35,7 +35,7 @@ | NSS Library source routine that converts dos time to an ascii | time string +-------------------------------------------------------------------------*/ -#include +#include #include /************************************************************************** diff --git a/src/nwnss/library/utc/gethres.386 b/src/nwnss/library/utc/gethres.386 new file mode 100644 index 0000000..8653436 --- /dev/null +++ b/src/nwnss/library/utc/gethres.386 @@ -0,0 +1,63 @@ +;***************************************************************************** +;* +;* (C) Copyright 1986-1995 Novell, Inc. +;* All Rights Reserved. +;* +;* This program is free software; you can redistribute it and/or +;* modify it under the terms of version 2 of the GNU General Public +;* License as published by the Free Software Foundation. +;* +;* This program is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;* GNU General Public License for more details. +;* +;* You should have received a copy of the GNU General Public License +;* along with this program; if not, contact Novell, Inc. +;* +;* To contact Novell about this file by physical or electronic mail, +;* you may find current contact information at www.novell.com +;* +;* +;* $Author: taysom $ +;* $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ +;* +;* $RCSfile$ +;* $Revision: 465 $ +;* +;***************************************************************************** + .prot + name GETHRES.386 + +;***************************************************************************** + + assume ds: OSDATA, es: OSDATA, ss: OSDATA + +OSDATA segment rw public 'DATA' +OSDATA ends + +;***************************************************************************** +OSCODE segment er public 'CODE' + + assume cs: OSCODE + + public GetHighResClock + extrn GetHighResolutionTimer: near + +;---------------------------------------------------------------------------- +; This reads the high resolution timer out of NetWare and returns it. +; This preserves interrupts because NetWare ALWAYS returns with +; interrupts enabled. The unis are in 100's of micro seconds +; (1/10,000 of a second) +;---------------------------------------------------------------------------- +GetHighResClock proc + + pushfd + call GetHighResolutionTimer ;get value in eax from OS + popfd + ret + +GetHighResClock endp + +OSCODE ends + end diff --git a/src/nwnss/library/utc/getutctime.c b/src/nwnss/library/utc/getutctime.c index 436e901..bb3883f 100644 --- a/src/nwnss/library/utc/getutctime.c +++ b/src/nwnss/library/utc/getutctime.c @@ -36,7 +36,7 @@ +-------------------------------------------------------------------------*/ /* We are currently using an inline macro, so we don't need this routine*/ #if 0 -//#include +//#include // //extern volatile LONG SynchronizedClock; /* NetWare Variable */ // diff --git a/src/nwnss/library/utc/local2utc.c b/src/nwnss/library/utc/local2utc.c index d66f614..c8a89cb 100644 --- a/src/nwnss/library/utc/local2utc.c +++ b/src/nwnss/library/utc/local2utc.c @@ -34,12 +34,13 @@ | This module is used to: | NSS Library source routine that converts time +-------------------------------------------------------------------------*/ -#include +#include #include -#include -#include +#include +#include +extern volatile Synchronized_Clock_T SynchronizedClock; /************************************************************************** * This routine takes a localalized version of UTC time @@ -47,15 +48,15 @@ ***************************************************************************/ Time_t LocalUtc2UTCTime (Time_t utc) { - /* + /* * Adjust local time to UTC time using time zone and DST offsets */ /* UTC time = local + TZ - DST*/ - utc += NSS_TimeZoneOffset; - if (inDaylightSavingTime(utc, NSS_DaylightOnOff)) + utc += SynchronizedClock.timezoneOffset; + if (inDaylightSavingTime(utc, (NINT)SynchronizedClock.daylightOnOff)) { - utc -= NSS_DaylightOffset; + utc -= SynchronizedClock.daylightOffset; } return(utc); } diff --git a/src/nwnss/library/utc/msTime2utc.c b/src/nwnss/library/utc/msTime2utc.c index c2f6bb7..049e927 100644 --- a/src/nwnss/library/utc/msTime2utc.c +++ b/src/nwnss/library/utc/msTime2utc.c @@ -34,9 +34,9 @@ | This module is used to: | NSS Library source routine that converts time +-------------------------------------------------------------------------*/ -#include -#include /* NSS LIBRARY Include */ -#include +#include +#include /* NSS LIBRARY Include */ +#include #include @@ -60,9 +60,9 @@ Time_t doMsTime2utcTime( time = ((msTime/10000000) - ((SQUAD)DAYS_FROM_1601_TO_1970 * SECS_IN_A_DAY)); - /* + /* * Adjust UTC time with the daylight savings offset. This is as per the - * spec in section 3.6. + * spec in section 3.6. * IE MSTime = UTC + Tdaf - Tdan * unless the state is set to take times without adjustment. */ @@ -93,11 +93,11 @@ struct { Time_t MSTime2utcTime( MSTime_t msTime) { - enum - { - msTimeSHIFT = 10, - msTimeSIZE = 1 << msTimeSHIFT, - msTimeMASK = msTimeSIZE - 1 + enum + { + msTimeSHIFT = 10, + msTimeSIZE = 1 << msTimeSHIFT, + msTimeMASK = msTimeSIZE - 1 }; static struct @@ -132,11 +132,11 @@ Time_t MSTime2utcTime( ResetTimeCache &= ~TIME_MSTIME2UTC; } - if (msTimeHash[hashKey].msTime == msTime) + if (msTimeHash[hashKey].msTime == msTime) { ++MsTime2utc.hits; - } - else + } + else { ++MsTime2utc.misses; msTimeHash[hashKey].msTime = msTime; diff --git a/src/nwnss/library/utc/sec2utc.c b/src/nwnss/library/utc/sec2utc.c index 8eecd76..5e5cf7a 100644 --- a/src/nwnss/library/utc/sec2utc.c +++ b/src/nwnss/library/utc/sec2utc.c @@ -34,14 +34,14 @@ | This module is used to: | NSS Library source routine that converts time +-------------------------------------------------------------------------*/ -#include -#include /* NSS LIBRARY Include */ +#include +#include /* NSS LIBRARY Include */ #include -#include +#include /************************************************************************** - * This routine takes seconds from the year 2000 (in local time) + * This routine takes seconds from the year 2000 (in local time) * and converts it to the UTC time (seconds from Jan 1, 1970) . ***************************************************************************/ Time_t doSec20002utcTime( @@ -49,7 +49,7 @@ Time_t doSec20002utcTime( { time += YEAR_2000_IN_UTC; - /* + /* * Adjust the local time to UTC using time zone and DST offsets * unless the state is set to take times without adjustment. */ @@ -58,7 +58,7 @@ Time_t doSec20002utcTime( { if (inDaylightSavingTime(time, NSS_DaylightOnOff)) time -= NSS_DaylightOffset; - + time += NSS_TimeZoneOffset; } @@ -73,11 +73,11 @@ struct { Time_t Sec20002utcTime( Time_t secTime) { - enum - { - secSHIFT = 10, - secSIZE = 1 << secSHIFT, - secMASK = secSIZE - 1 + enum + { + secSHIFT = 10, + secSIZE = 1 << secSHIFT, + secMASK = secSIZE - 1 }; static struct @@ -116,12 +116,12 @@ Time_t Sec20002utcTime( ResetTimeCache &= ~TIME_SEC2UTC; } - if (secHash[hashKey].sec == secTime) + if (secHash[hashKey].sec == secTime) { ++Sec2utc.hits; return secHash[hashKey].utc; - } - else + } + else { ++Sec2utc.misses; secHash[hashKey].sec = secTime; diff --git a/src/nwnss/library/utc/secsDiff.c b/src/nwnss/library/utc/secsDiff.c index f81ce52..2e684b1 100644 --- a/src/nwnss/library/utc/secsDiff.c +++ b/src/nwnss/library/utc/secsDiff.c @@ -32,9 +32,9 @@ | |--------------------------------------------------------------------------- | This module is used to: - | + | +-------------------------------------------------------------------------*/ -#include +#include #include /**************************************************************************** diff --git a/src/nwnss/library/utc/str2dos.c b/src/nwnss/library/utc/str2dos.c index 8924e9c..5916567 100644 --- a/src/nwnss/library/utc/str2dos.c +++ b/src/nwnss/library/utc/str2dos.c @@ -35,7 +35,7 @@ | NSS Library source routine that converts an ascii date string to | a DOSTime_t structure. +-------------------------------------------------------------------------*/ -#include +#include #include #include #include @@ -122,7 +122,7 @@ DOSTime_t Str2dosDateTime( if ((month == 2) && ((year%4) != 0)) /* is February and is NOT leap year */ { if (day > 28) - return INVALID_DOS_TIME; + return INVALID_DOS_TIME; } /*--------------------------------------------------------------------------- @@ -136,7 +136,7 @@ DOSTime_t Str2dosDateTime( /*--------------------------------------------------------------------------- * Convert the minute to decimal *---------------------------------------------------------------------------*/ - ++nextStr; + ++nextStr; minute = strtol(nextStr,&nextStr,10); if ((minute > 59) || (*nextStr != ':')) return INVALID_DOS_TIME; @@ -144,7 +144,7 @@ DOSTime_t Str2dosDateTime( /*--------------------------------------------------------------------------- * Convert the seconds to decimal *---------------------------------------------------------------------------*/ - ++nextStr; + ++nextStr; second = strtol(nextStr,&nextStr,10); if (second > 59) return INVALID_DOS_TIME; diff --git a/src/nwnss/library/utc/str2dosd.c b/src/nwnss/library/utc/str2dosd.c index 2f5c872..f335a62 100644 --- a/src/nwnss/library/utc/str2dosd.c +++ b/src/nwnss/library/utc/str2dosd.c @@ -35,7 +35,7 @@ | NSS Library source routine that converts an ascii date string to | a DOSTime_t structure. +-------------------------------------------------------------------------*/ -#include +#include #include #include #include @@ -115,7 +115,7 @@ DOSTime_t Str2dosDate( if ((month == 2) && ((year%4) != 0)) /* is February and is NOT leap year */ { if (day > 28) - return INVALID_DOS_TIME; + return INVALID_DOS_TIME; } /*--------------------------------------------------------------------------- diff --git a/src/nwnss/library/utc/str2dost.c b/src/nwnss/library/utc/str2dost.c index 8aae8d8..43bb292 100644 --- a/src/nwnss/library/utc/str2dost.c +++ b/src/nwnss/library/utc/str2dost.c @@ -35,7 +35,7 @@ | NSS Library source routine that converts an ascii time string to | a DOSTime_t structure. +-------------------------------------------------------------------------*/ -#include +#include #include #include @@ -62,7 +62,7 @@ DOSTime_t Str2dosTime( /*--------------------------------------------------------------------------- * Convert the minute to decimal *---------------------------------------------------------------------------*/ - ++nextStr; + ++nextStr; minute = strtol(nextStr,&nextStr,10); if ((minute > 59) || (*nextStr != ':')) return INVALID_DOS_TIME; @@ -70,7 +70,7 @@ DOSTime_t Str2dosTime( /*--------------------------------------------------------------------------- * Convert the seconds to decimal *---------------------------------------------------------------------------*/ - ++nextStr; + ++nextStr; second = strtol(nextStr,&nextStr,10); if (second > 59) return INVALID_DOS_TIME; diff --git a/src/nwnss/library/utc/str2utc.c b/src/nwnss/library/utc/str2utc.c index 832e9f4..75c33d2 100644 --- a/src/nwnss/library/utc/str2utc.c +++ b/src/nwnss/library/utc/str2utc.c @@ -34,9 +34,9 @@ | This module is used to: | NSS Library source routine that converts time +-------------------------------------------------------------------------*/ -#include +#include -#include +#include #include #include #include @@ -119,7 +119,7 @@ Time_t Str2utcTime( if ((months == 2) && ((years%4) != 0)) /* is February and is NOT leap year */ { if (days > 28) - return INVALID_UTC_TIME; + return INVALID_UTC_TIME; } /*--------------------------------------------------------------------------- @@ -133,7 +133,7 @@ Time_t Str2utcTime( /*--------------------------------------------------------------------------- * Convert the minute to decimal *---------------------------------------------------------------------------*/ - ++nextStr; + ++nextStr; minutes = strtol(nextStr,&nextStr,10); if ((minutes > 59) || (*nextStr != ':')) return INVALID_UTC_TIME; @@ -141,7 +141,7 @@ Time_t Str2utcTime( /*--------------------------------------------------------------------------- * Convert the seconds to decimal *---------------------------------------------------------------------------*/ - ++nextStr; + ++nextStr; seconds = strtol(nextStr,&nextStr,10); if (seconds > 59) return INVALID_UTC_TIME; @@ -154,21 +154,21 @@ Time_t Str2utcTime( totalDays += years % 4 ? monthTotal[months] : monthLeapTotal[months]; UTC = totalDays * (24 * 60 * 60) + hours * (60 * 60) + minutes * 60 + seconds; - - /* + + /* * Adjust the local time to UTC using time zone and DST offsets * unless the state is set to take times without adjustment. */ if (!IgnoreTimeZone) { - if (inDaylightSavingTime(UTC, NSS_DaylightOnOff)) + if (inDaylightSavingTime(UTC, NSS_DaylightOnOff)) UTC -= NSS_DaylightOffset; - + UTC += NSS_TimeZoneOffset; } - - return UTC; + + return UTC; } diff --git a/src/nwnss/library/utc/utc2dos.c b/src/nwnss/library/utc/utc2dos.c index 38d7058..df5b82a 100644 --- a/src/nwnss/library/utc/utc2dos.c +++ b/src/nwnss/library/utc/utc2dos.c @@ -34,18 +34,16 @@ | This module is used to: | NSS Library source routine that converts time +-------------------------------------------------------------------------*/ -#include +#include -#include -#include +#include +#include #include -#if defined(__KERNEL__) #include #include "nssOSAPIs.h" -#endif -extern NINT secondsAtEndOfMonth[]; -extern NINT secondsAtEndOfLeapMonth[]; +extern LONG secondsAtEndOfMonth[]; +extern LONG secondsAtEndOfLeapMonth[]; /*------------------------------------------------------------------------- * Defines the time breakout structure @@ -88,8 +86,8 @@ DOSTime_t doUTC2dosTime( if (UTC == INVALID_UTC_TIME) return(INVALID_DOS_TIME); - - /* + + /* * Adjust UTC time to local time using time zone and DST offsets * unless the state is set to take times without adjustment. */ @@ -134,7 +132,7 @@ DOSTime_t doUTC2dosTime( { return INVALID_DOS_TIME; } - + if (year < 2000) CYear = year - 1900; else @@ -168,7 +166,7 @@ DOSTime_t doUTC2dosTime( } CMonth = month; /* Month should be 1 based not zero based */ - + CDay = (UTC / SECONDS_IN_A_DAY) + 1; /* Days are 1 based also*/ UTC = UTC % SECONDS_IN_A_DAY; @@ -215,11 +213,11 @@ struct { DOSTime_t UTC2dosTime (Time_t utc) { - enum - { - utcSHIFT = 10, - utcSIZE = 1 << utcSHIFT, - utcMASK = utcSIZE - 1 + enum + { + utcSHIFT = 10, + utcSIZE = 1 << utcSHIFT, + utcMASK = utcSIZE - 1 }; static struct @@ -262,12 +260,12 @@ DOSTime_t UTC2dosTime (Time_t utc) ResetTimeCache &= ~TIME_UTC2DOS; } - if (utcHash[hashKey].utc == utc) + if (utcHash[hashKey].utc == utc) { ++Utc2dos.hits; return utcHash[hashKey].dos; - } - else + } + else { ++Utc2dos.misses; utcHash[hashKey].utc = utc; diff --git a/src/nwnss/library/utc/utc2local.c b/src/nwnss/library/utc/utc2local.c index 5a7353a..e40cf50 100644 --- a/src/nwnss/library/utc/utc2local.c +++ b/src/nwnss/library/utc/utc2local.c @@ -34,11 +34,11 @@ | This module is used to: | NSS Library source routine that converts time +-------------------------------------------------------------------------*/ -#include +#include #include -#include -#include +#include +#include /************************************************************************** @@ -47,7 +47,7 @@ ***************************************************************************/ Time_t UTC2LocalUtcTime (Time_t utc) { - /* + /* * Adjust UTC time to local time using time zone and DST offsets */ diff --git a/src/nwnss/library/utc/utc2msTime.c b/src/nwnss/library/utc/utc2msTime.c index 5f1b31c..2ccfa16 100644 --- a/src/nwnss/library/utc/utc2msTime.c +++ b/src/nwnss/library/utc/utc2msTime.c @@ -34,9 +34,9 @@ | This module is used to: | NSS Library source routine that converts UTC time to Microsoft CIFS time +-------------------------------------------------------------------------*/ -#include -#include -#include +#include +#include +#include #include @@ -59,9 +59,9 @@ MSTime_t doUTC2msTime( { MSTime_t msTime; - /* + /* * Adjust UTC time with the daylight savings offset. This is as per the - * spec in section 3.6. + * spec in section 3.6. * IE MSTime = UTC + Tdaf - Tdan * unless the state is set to take times without adjustment. */ @@ -142,7 +142,7 @@ MSTime_t UTC2msTime( ResetTimeCache &= ~TIME_UTC2MSTIME; } - if (utcHash[hashKey].utc == utc) + if (utcHash[hashKey].utc == utc) { ++Utc2MsTime.hits; } diff --git a/src/nwnss/library/utc/utc2sec.c b/src/nwnss/library/utc/utc2sec.c index e13932c..72ba7ad 100644 --- a/src/nwnss/library/utc/utc2sec.c +++ b/src/nwnss/library/utc/utc2sec.c @@ -34,11 +34,11 @@ | This module is used to: | NSS Library source routine that converts time +-------------------------------------------------------------------------*/ -#include +#include #include -#include -#include +#include +#include #if zLINUX BOOL IgnoreTimeZone = FALSE; /* If this is true then time conversion ignores time zone and daylight Savings time */ @@ -54,7 +54,7 @@ void (*BEASTHASH_InvalidateDOSTimesPtr)(void) = NULL; Time_t doUTC2Sec2000Time( Time_t UTC) { - /* + /* * Adjust UTC time to local time using time zone and DST offsets * unless the state is set to take times without adjustment. */ @@ -117,7 +117,7 @@ Time_t UTC2Sec2000Time (Time_t utc) ResetTimeCache &= ~TIME_UTC2SEC; } - if (utcHash[hashKey].utc == utc) + if (utcHash[hashKey].utc == utc) { ++Utc2sec.hits; return utcHash[hashKey].sec; diff --git a/src/nwnss/library/utc/utc2str.c b/src/nwnss/library/utc/utc2str.c index e0c475c..f61c05c 100644 --- a/src/nwnss/library/utc/utc2str.c +++ b/src/nwnss/library/utc/utc2str.c @@ -34,10 +34,10 @@ | This module is used to: | NSS Library source routine that converts time +-------------------------------------------------------------------------*/ -#include -#include +#include +#include -#include +#include #include #include @@ -81,7 +81,7 @@ BOOL UTCTime2struct( return FALSE; } - /* + /* * Adjust UTC time to local time using time zone and DST offsets * unless the state is set to take times without adjustment. */ @@ -151,7 +151,7 @@ BOOL UTCTime2struct( time->CYear = year; time->CMonth = month; /* Month should be 1 based not zero based */ - + time->CDay = (utcTime / SECONDS_IN_A_DAY) + 1; /* Days are 1 based also*/ utcTime = utcTime % SECONDS_IN_A_DAY; @@ -176,20 +176,22 @@ char *UTCTime2Str( char *str) { TimeBreakout time; - + if (!UTCTime2struct(utcTime, &time)) { sprintf(str,MSG("Invalid UTC Time", 237)); return str; } - sprintf(str, "%02d-%s-%04d %02d:%02d:%02d", - time.CDay, - MONTH_NAMES(time.CMonth), + ZOS_FormatDateAndTime( + str, time.CYear, + time.CMonth, + time.CDay, time.CHour, time.CMinute, - time.CSecond); + time.CSecond, + EN_INCLUDE_SECONDS | EN_USE_4_DIGIT_YEAR | EN_USE_ABBREV_MONTH); return str; } @@ -205,7 +207,7 @@ char *UTCTime2UniversalStr( char *str) { TimeBreakout time; - + if (!UTCTime2struct(utcTime, &time)) { sprintf(str, "00000000000000"); diff --git a/src/nwnss/library/utc/utcdata.c b/src/nwnss/library/utc/utcdata.c index 1cd4a35..00302ec 100644 --- a/src/nwnss/library/utc/utcdata.c +++ b/src/nwnss/library/utc/utcdata.c @@ -34,9 +34,9 @@ | This module is used to: | NSS Library source routine that converts time +-------------------------------------------------------------------------*/ -#include +#include -#include +#include #include #include @@ -133,7 +133,7 @@ NINT MonthDays[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31}; /*------------------------------------------------------------------------- * These are the month names used in the time format commands. This deals - * with language-enabled vrs non-language-enabled systems. + * with language-enabled vrs non-language-enabled systems. *-------------------------------------------------------------------------*/ #if NSS_MSG_TAGS IS_ENABLED NINT MonthNamesIDX[13] = @@ -172,7 +172,7 @@ char *Weekday_Names[DAYS_IN_WEEK] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; -char *Ordinal_Week[WEEKS_IN_MONTH +1] = +char *Ordinal_Week[WEEKS_IN_MONTH +1] = {"None", "First", "Second", "Third", "Fourth", "Fifth", "Last"}; #define EPOCH_WEEKDAY 4 /* 1970 started on Thursday */ @@ -185,8 +185,8 @@ char *Ordinal_Week[WEEKS_IN_MONTH +1] = #define SECONDS_IN_4_YEARS (NINT)((SECONDS_IN_A_YEAR * 3) + SECONDS_IN_A_LEAPYEAR) /*------------------------------------------------------------------------- - * This macro does not handle the rules prior to 1752, and the year must be - * unbiased (not relative to 1970 or 1900 + * This macro does not handle the rules prior to 1752, and the year must be + * unbiased (not relative to 1970 or 1900 *-------------------------------------------------------------------------*/ #define ISLEAPYEAR(x) (((x) % 4) == 0 && (((x) % 100) || ((x) % 400) == 0)) @@ -202,7 +202,7 @@ char *Ordinal_Week[WEEKS_IN_MONTH +1] = ((checkingDate) > (DSTChangeDate)) : ((checkingHour) >= (DSTChangeHour))) #define IN_DST_OFF_MONTH(checkingHour, DSTChangeHour, checkingDate, DSTChangeDate) \ ((checkingDate) != (DSTChangeDate))? \ - ((checkingDate) < (DSTChangeDate)) : ((checkingHour) < (DSTChangeHour)) + ((checkingDate) < (DSTChangeDate)) : ((checkingHour) < (DSTChangeHour)) #define ORDINAL 0 @@ -228,7 +228,7 @@ typedef struct TimeInfoDetail_s *-------------------------------------------------------------------------*/ void getUTCTimeInfo( Time_t utcTime, - TimeInfoDetail_s *time) + TimeInfoDetail_s *time) { NINT year,month,leapYear; NINT numLeapYears; @@ -287,8 +287,8 @@ void getUTCTimeInfo( } time->year = year; - time->month = month; /* Month should be 1 based not zero based */ - + time->month = month; /* Month should be 1 based not zero based */ + time->date = (utcTime / SECONDS_IN_A_DAY) + 1; /* Days are 1 based also*/ utcTime = utcTime % SECONDS_IN_A_DAY; @@ -305,7 +305,7 @@ void getUTCTimeInfo( /*--------------------------------------------------------------------------- * Appears: "(month" (likely"(APRIL") *---------------------------------------------------------------------------*/ -NINT parseMonth( +NINT parseMonth( char *s, char **next) /* helps choke up past parsed elements */ { @@ -354,7 +354,7 @@ NINT parseDigit( char *s, char **next) /* helps choke up past parsed elements */ { - char *p, *q; + char *p, *q; char number[10]; p = (char *) s; @@ -371,7 +371,7 @@ NINT parseDigit( if (!*p) return -1; - /* + /* * digits in the parse string can't be "0", we can mark the return value as 0 * to indicate the following part is "weekday" */ @@ -392,7 +392,7 @@ NINT parseDigit( /*--------------------------------------------------------------------------- * appears: "weekday" (likely "SUNDAY") *---------------------------------------------------------------------------*/ -NINT parseDay( +NINT parseDay( char *s, char **next) /* helps choke up past parsed elements */ { @@ -431,10 +431,10 @@ NINT parseDay( /*--------------------------------------------------------------------------- * appears: "ordinal" (likely "first") or like (">=1" or "<=31") *---------------------------------------------------------------------------*/ -NINT parseOrdinalWeek( +NINT parseOrdinalWeek( char *s, NINT *afterBeforeOrdinal, - char **next) + char **next) { char week[30]; NINT i; @@ -507,7 +507,7 @@ NINT parseOrdinalWeek( /*--------------------------------------------------------------------------- * appears: "hh:mm:ss" (likely "2:00:00") *---------------------------------------------------------------------------*/ -NINT parseTimeOffset( +NINT parseTimeOffset( char *s, char **next) /* helps choke up past parsed elements */ { @@ -562,7 +562,7 @@ NINT parseTimeOffset( /*--------------------------------------------------------------------------- * appears: "hh:mm:ss am_pm" (likely "2:00:00 AM") *---------------------------------------------------------------------------*/ -NINT parseHour( +NINT parseHour( char *s, char **next) /* helps choke up past parsed elements */ { @@ -605,14 +605,14 @@ NINT parseMeridian( } /*--------------------------------------------------------------------------- - * For the infomation we get from the system, like (APRIL SUNDAY FIRST + * For the infomation we get from the system, like (APRIL SUNDAY FIRST * 2:00:00 AM), we store them in ChangeDate_s structure for later usage. *---------------------------------------------------------------------------*/ void getDSTChangeRules( char *systemInfo, ChangeDate_s *dateInfo) { - /* + /* * first, decide if the parse string is a simple time or a rule. only rules * will be rescheduled next year. */ @@ -631,13 +631,13 @@ void getDSTChangeRules( if (dateInfo->date < 0 || dateInfo->date > MonthDays[dateInfo->month]) goto ErrorExit; - /* + /* * after month, it is a date. Now need to decide what is the format: - * simple time: month date year hh:mm:ss or rule: (month date hh:mm:ss) + * simple time: month date year hh:mm:ss or rule: (month date hh:mm:ss) */ dateInfo->year = 0; - if (dateInfo->date != 0) - { + if (dateInfo->date != 0) + { /* is a simple time, we need to get the year */ if (dateInfo->isRule != TRUE) { @@ -646,13 +646,13 @@ void getDSTChangeRules( if (dateInfo->year <= 1970) goto ErrorExit; } - - /* it can't have weekday information, so mark it */ + + /* it can't have weekday information, so mark it */ dateInfo->day = 7; goto GetTime; } - /* + /* * now we know the parse string must be like one of these: * April Sunday >= 1 2:00:00 AM or April Sunday First 2:00:00 AM */ @@ -660,7 +660,7 @@ void getDSTChangeRules( dateInfo->day = parseDay(systemInfo, &systemInfo); if (dateInfo->day < 0 || dateInfo->day > 6) goto ErrorExit; - + /* decide change from which weekday in the month */ dateInfo->which = parseOrdinalWeek(systemInfo, &dateInfo->afterBeforeOrdinal, &systemInfo); if (dateInfo->afterBeforeOrdinal == ORDINAL) @@ -668,8 +668,8 @@ void getDSTChangeRules( if (dateInfo->which <= KNONE || dateInfo->which > KLAST) goto ErrorExit; } - else - { + else + { if (dateInfo->which <= 0 || dateInfo->which > MonthDays[dateInfo->month]) goto ErrorExit; } @@ -681,7 +681,7 @@ GetTime: goto ErrorExit; dateInfo->isOK = TRUE; - return; + return; ErrorExit: dateInfo->isOK = FALSE; @@ -698,11 +698,11 @@ void checkOrSetDSTConversionResults( { if (startIsOK != -1) DSTStartInfo.isOK = (NINT)startIsOK; - + if (stopIsOK != -1) DSTStopInfo.isOK = (NINT)stopIsOK; - - if (offset != -1) + + if (offset != -1) { DSTOffset = (NINT)offset; } @@ -739,15 +739,15 @@ void checkOrSetDSTConversionResults( } } DSTValidation = TRUE; - return; + return; ErrorExit: - DSTValidation = FALSE; + DSTValidation = FALSE; return; } /*--------------------------------------------------------------------------- * This function deals with the situation that DST turn-on month is the - * same as DST turn-off month. + * same as DST turn-off month. *---------------------------------------------------------------------------*/ BOOL DSTStartStopSameMonth( NINT checkingDate, /* date needs to be checked */ @@ -778,7 +778,7 @@ BOOL DSTStartStopSameMonth( return TRUE; if (IS_BEYOND_START_STOP(checkingDate, DSTStartHour, DSTStopHour - DSTOffset)) - return FALSE; + return FALSE; if (DSTStartHour != DSTStopHour - DSTOffset) { @@ -789,12 +789,12 @@ BOOL DSTStartStopSameMonth( return FALSE; } - /* + /* * if we reach this step, the checking time either equals to DSTStopHour - DSTOffset, * or DSTStartHour = DSTStopHour - DSTOffset, the case we think actually there's no * daylight saving time. */ - + return FALSE; } } @@ -803,7 +803,7 @@ BOOL DSTStartStopSameMonth( * This function will return the ordinal weekday of the first day of * this month, this year. *---------------------------------------------------------------------------*/ -NINT firstWeekDayOfMonth( +NINT firstWeekDayOfMonth( NINT year, NINT month) { @@ -937,13 +937,13 @@ void getDSTChangeDate( } /*------------------------------------------------------------------------- - * This function is used to verify in the present time zone, whether the - * input time (in UTC seconds) is in the duration of Daylight Saving Time. - * In order to check it, we use GetSetableParameterValue() to get "start of + * This function is used to verify in the present time zone, whether the + * input time (in UTC seconds) is in the duration of Daylight Saving Time. + * In order to check it, we use GetSetableParameterValue() to get "start of * Daylight Savings Time" and "End of Daylight Saving Time". And assume * the rule of how to change it was the same in the past years too. * From server, we can get four types of format, like: - * 1. simple time + * 1. simple time * like: April 4(,) 1993 2:00:00 AM * 2. change rules (all rules are specified in "( )" * like: (April 4 2:00:00 AM) @@ -957,7 +957,7 @@ BOOL inDaylightSavingTime( NINT systemDSTOnOff ) { - TimeInfoDetail_s timeInfo; + TimeInfoDetail_s timeInfo; /*------------------------------------------------------------------------- * check if the DST converted information is valid. If not, goto EarlyExit. @@ -966,7 +966,7 @@ BOOL inDaylightSavingTime( goto EarlyExit; /*------------------------------------------------------------------------- - * Get the information of the input utcTime + * Get the information of the input utcTime *-------------------------------------------------------------------------*/ getUTCTimeInfo(utcTime, &timeInfo); @@ -977,14 +977,14 @@ BOOL inDaylightSavingTime( { if (DSTStartInfo.year != timeInfo.year) { - DSTStartInfo.year = timeInfo.year; - + DSTStartInfo.year = timeInfo.year; + if (DSTStartInfo.day != 7) DSTStartInfo.date = 0; - - getDSTChangeDate(&DSTStartInfo); - } - + + getDSTChangeDate(&DSTStartInfo); + } + if (DSTStopInfo.year != timeInfo.year) { DSTStopInfo.year = timeInfo.year; @@ -994,13 +994,13 @@ BOOL inDaylightSavingTime( getDSTChangeDate(&DSTStopInfo); } - - if (DSTStartInfo.date == 0 || DSTStopInfo.date == 0) + + if (DSTStartInfo.date == 0 || DSTStopInfo.date == 0) goto EarlyExit; } /*------------------------------------------------------------------------- - * check if the time is within the time specified by DST simple format. + * check if the time is within the time specified by DST simple format. *-------------------------------------------------------------------------*/ if (IS_BEYOND_START_STOP(timeInfo.year, DSTStartInfo.year, DSTStopInfo.year) || ((DSTStartInfo.year != DSTStopInfo.year) ? @@ -1014,45 +1014,45 @@ BOOL inDaylightSavingTime( /* in the same month of turn-on month */ if (timeInfo.year == DSTStartInfo.year && timeInfo.month == DSTStartInfo.month) return IN_DST_ON_MONTH(timeInfo.hour, DSTStartInfo.hour, timeInfo.date, DSTStartInfo.date); - + /* in the same month of turn-off month */ if (timeInfo.year == DSTStopInfo.year && timeInfo.month == DSTStopInfo.month) - return IN_DST_OFF_MONTH(timeInfo.hour, DSTStopInfo.hour - DSTOffset, - timeInfo.date, DSTStopInfo.date); + return IN_DST_OFF_MONTH(timeInfo.hour, DSTStopInfo.hour - DSTOffset, + timeInfo.date, DSTStopInfo.date); - /* the rest must be TRUE */ + /* the rest must be TRUE */ return TRUE; } /* DST start and stop time is in the same year. Rules format and some of simple * time format fall into this category */ else - { + { if (IS_BETWEEN_START_STOP(timeInfo.month, DSTStartInfo.month, DSTStopInfo.month)) return TRUE; if (IS_BEYOND_START_STOP(timeInfo.month, DSTStartInfo.month, DSTStopInfo.month)) - return FALSE; - + return FALSE; + /* we know now the checking month is the same as DST turn-on month, - * or the same as DST turn-off month, or both + * or the same as DST turn-off month, or both */ if (DSTStartInfo.month != DSTStopInfo.month) - { + { if (timeInfo.month == DSTStartInfo.month) { - return IN_DST_ON_MONTH(timeInfo.hour, DSTStartInfo.hour, + return IN_DST_ON_MONTH(timeInfo.hour, DSTStartInfo.hour, timeInfo.date, DSTStartInfo.date); } else - { + { return IN_DST_OFF_MONTH(timeInfo.hour, DSTStopInfo.hour - DSTOffset, timeInfo.date, DSTStopInfo.date); } } else { - /* DST turn-on month is the same as DST turn-off month, which is + /* DST turn-on month is the same as DST turn-off month, which is * also the same as checking month */ return DSTStartStopSameMonth(timeInfo.date, timeInfo.hour, DSTStartInfo.date, DSTStartInfo.hour, DSTStopInfo.date, DSTStopInfo.hour); @@ -1060,13 +1060,13 @@ BOOL inDaylightSavingTime( } EarlyExit: - /* + /* * It's the last chance to check the DST. Since the reasons we come here are * because either system doesn't provide DST information, which means there's no * DST set on the server, or system information can't be processed correctly. * We just check system DSTOnOff status to see if we need to do any adjustment, * since it's supposed to match the correct status of server DST setting. - */ + */ return systemDSTOnOff; } diff --git a/include/nwnss/utcData.h b/src/nwnss/library/utcData.h similarity index 98% rename from include/nwnss/utcData.h rename to src/nwnss/library/utcData.h index 6a27b85..f0c8429 100644 --- a/include/nwnss/utcData.h +++ b/src/nwnss/library/utcData.h @@ -41,7 +41,7 @@ #define _UTCDATA_H_ #ifndef _OMNI_H_ -# include +# include #endif /*------------------------------------------------------------------------- diff --git a/src/nwnss/library/wio/lnxLog.c b/src/nwnss/library/wio/lnxLog.c index a8063b8..9d91757 100644 --- a/src/nwnss/library/wio/lnxLog.c +++ b/src/nwnss/library/wio/lnxLog.c @@ -35,22 +35,11 @@ | Has UI routines for NSS on Linux | +-------------------------------------------------------------------------*/ -#if !defined(NSS_USERSPACE) #include -#endif #include #include #include -#if defined(NSS_USERSPACE) -#ifndef MPKNSS_UNLOCK -#define MPKNSS_UNLOCK() ((void)0) -#endif -#ifndef MPKNSS_LOCK -#define MPKNSS_LOCK() ((void)0) -#endif -#endif - // FixFixFix(Linux) - port to Linux void NSSLOG_Startup( ) @@ -123,7 +112,7 @@ STATUS NSSLOG_printf( NINT logLevel, NINT typeNumber, /* Type; see NSSLOG_TYPE_... defines */ const char *format, - ...) + ...) { STATUS status; va_list args; diff --git a/src/nwnss/library/wio/nssUI.c b/src/nwnss/library/wio/nssUI.c index 8856177..37bd9f6 100644 --- a/src/nwnss/library/wio/nssUI.c +++ b/src/nwnss/library/wio/nssUI.c @@ -1,121 +1,682 @@ /**************************************************************************** | - | (C) Copyright 2004 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 2004 Novell, Inc. + | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NSS Linux initialization module + | NSS Linux initialization module | |--------------------------------------------------------------------------- - | Derived from public_core/library/wio/nssUI.c. The original file is - | a Linux kernel/procfs console provider; this port keeps the NSS - | console formatter path in Linux userspace and writes to stdout. + | + | $Author: taysom $ + | $Date: 2007-10-06 01:42:31 +0530 (Sat, 06 Oct 2007) $ + | + | $RCSfile$ + | $Revision: 2229 $ + | + |--------------------------------------------------------------------------- + | This module is used to: !!!Linux specific file!!! + | Has UI routines for NSS on Linux + | +-------------------------------------------------------------------------*/ -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include +#include +#include +#include "linuxmpk.h" -#define NSS_UI_CONSOLE_BUFFER_MAX (400 * 1024) +//--------------------------------------------------- +// Prototypes: +// LB_vsnprintf - used to print to console buffer +//--------------------------------------------------- +int LB_vsnprintf(char *string, size_t len, const char *fmt, va_list args); -static pthread_mutex_t consoleSema = PTHREAD_MUTEX_INITIALIZER; +static const char *NSS_MainDirName = "nss"; +static const char *NSS_UI_ConsoleName = "console"; +static const char *NSS_UI_CommandLineName = "commandline"; + +static struct proc_dir_entry *NSS_MainProcDir = NULL; +static struct proc_dir_entry *NSS_UI_ConsoleFile = NULL; +static struct proc_dir_entry *NSS_UI_CommandLineFile = NULL; + +DECLARE_WAIT_QUEUE_HEAD( NSS_KeyCodeHead ); // Queue that NSS KLM waits on while waiting for keyboard input + +//------------------------------------------ +// set up wait queue for character driver +//----------------------------------------- +wait_queue_head_t my_queue; +DECLARE_WAIT_QUEUE_HEAD(my_queue); +//spinlock_t consoleLock; +struct semaphore consoleSema; +atomic_t nsscmd_inuse; + +//-------------------------------------------- +// macros for nss_device_lock +//-------------------------------------------- +#define NSS_INC_DEVICE_COUNT atomic_inc(&nsscmd_inuse); +#define NSS_DEC_DEVICE_COUNT atomic_dec(&nsscmd_inuse); +#define NSS_DEVICE_IN_USE atomic_read(&nsscmd_inuse) + +#define NSS_UI_CONSOLE_BUFFER_MAX (400*1024) static char NSS_UI_ConsoleBuffer[NSS_UI_CONSOLE_BUFFER_MAX]; + +// Number of chars currently in NSS_UI_ConsoleBuffer. +// NSSUI removes chars by reading /proc/nss/console. +// NSS adds chars by doing aprintf, +// errprintf, etc. NSS also adds chars when it needs user input. +// NSS_UI_ConsoleBufferCurrentSize +// will NEVER be > NSS_UI_CONSOLE_BUFFER_MAX. static unsigned int NSS_UI_ConsoleBufferCurrentSize = 0; +#define NSS_UI_COMMAND_LINE_MAX (512) +static char NSS_UI_CommandLineBuffer[NSS_UI_COMMAND_LINE_MAX]; + +//------------------------------------------------------ +// NSS_wgetch is not intented to be used anymore. +// It is still here for the couple of places that still +// have reference to it +//------------------------------------------------------ int NSS_wgetch(int typeOfKey) { - UNUSED_PARAM(typeOfKey); - return -1; + int key = -1; + return key; } -int NSS_UI_vprintf(unsigned attr, const char *format, va_list args) +//--------------------------------------------------------------------------- +//NSS_UI_vprintf() +// Add items to the NSS_UI_ConsoleBuffer buffer so that +// they can be displayed +// by user space application (NSS System Console Application). +//--------------------------------------------------------------------------- +int NSS_UI_vprintf( unsigned attr, const char *format, va_list args ) { - char *curBuf; - size_t sizeLeft; - char *format_temp; - int size; - int fgColor; - int bold; - int added_size; - unsigned int oldSize; - static BOOL bufferWasFull = FALSE; + char *curBuf; + size_t sizeLeft; + char * format_temp; + int size; + int fgColor; + int bold; +/* char convert_attr[3];*/ + int added_size; + static BOOL bufferWasFull = FALSE; - size = (int)(strlen(format) + strlen("\033[0;40;40m\033[0;37;40m") + 1); - format_temp = malloc((size_t)size); - if (!format_temp) - { - return 0; - } + //Determine size for kmalloc + size = strlen(format)+strlen("\033[0;40;40m\033[0;37;40m")+1; - pthread_mutex_lock(&consoleSema); + format_temp = kmalloc(size,GFP_KERNEL); + + if (!format_temp) + { + printk("<1>" "NSS_UI_vprintf unable to allocate memory \n"); + return 0; + } +//printk("<1>" " NSS_UI_ConsoleBufferCurrentSize (%d)\n", NSS_UI_ConsoleBufferCurrentSize ); +// spin_lock(&consoleLock); //Console single access to NSS_UI_ConsoleBuffer + down(&consoleSema); //Console single access to NSS_UI_ConsoleBuffer + + curBuf = &NSS_UI_ConsoleBuffer[NSS_UI_ConsoleBufferCurrentSize]; + + sizeLeft = sizeof( NSS_UI_ConsoleBuffer ) - NSS_UI_ConsoleBufferCurrentSize; - oldSize = NSS_UI_ConsoleBufferCurrentSize; - curBuf = &NSS_UI_ConsoleBuffer[NSS_UI_ConsoleBufferCurrentSize]; - sizeLeft = sizeof(NSS_UI_ConsoleBuffer) - NSS_UI_ConsoleBufferCurrentSize; + /*------------------------------------------------------------ + * Convert from NetWare color mapping to ANSI STD color codes + *------------------------------------------------------------*/ + /* Bold if NetWare attribute bit 4 is set */ + bold = (attr & 0x8) ? 1 : 0; - bold = (attr & 0x8) ? 1 : 0; - attr %= 8; + /* There are really only 8 color values + with bold on or off for 16 visible colors */ + attr %= 8; - switch (attr) - { - case BLACK: - fgColor = 30; - break; - case BLUE: - fgColor = 34; - break; - case GREEN: - fgColor = 32; - break; - case CYAN: - fgColor = 36; - break; - case RED: - fgColor = 31; - break; - case MAGENTA: - fgColor = 35; - break; - case BROWN: - fgColor = 33; - break; - case LGRAY: - fgColor = 37; - break; - default: - fgColor = 37; - bold = 0; - break; - } + /* Select the ANSI color code */ + switch(attr) + { + case BLACK: + fgColor = 30; + break; - snprintf(format_temp, (size_t)size, "\033[%d;%d;40m", bold, fgColor); - strcat(format_temp, format); - strcat(format_temp, "\033[0;37;40m"); + case BLUE: + fgColor = 34; + break; - added_size = LB_vsnprintf(curBuf, sizeLeft, format_temp, args); - if ((size_t)added_size >= sizeLeft) - { - bufferWasFull = TRUE; - } - else - { - bufferWasFull = FALSE; - NSS_UI_ConsoleBufferCurrentSize += (unsigned int)strlen(curBuf); - fputs(&NSS_UI_ConsoleBuffer[oldSize], stdout); - fflush(stdout); - } + case GREEN: + fgColor = 32; + break; - UNUSED_PARAM(bufferWasFull); - pthread_mutex_unlock(&consoleSema); - free(format_temp); - return 0; + case CYAN: + fgColor = 36; + break; + + case RED: + fgColor = 31; + break; + + case MAGENTA: + fgColor = 35; + break; + + case BROWN: + fgColor = 33; + break; + + case LGRAY: + fgColor = 37; + break; + + /* Assume non-bold white (light gray) if attribute unrecognised */ + default: + fgColor = 37; + bold = 0; + break; + } + + sprintf(format_temp,"\033[%d;%d;40m", bold, fgColor); /* Black background (40) */ + strcat(format_temp,format); + strcat(format_temp,"\033[0;37;40m"); + + added_size = LB_vsnprintf( curBuf, sizeLeft, format_temp, args ); + //-------------------------------------------- + //Check to see if buffer was full + //-------------------------------------------- + if (added_size > sizeLeft) + { + if (!bufferWasFull) + { + printk("<1>" "NSS Console buffer was full\n"); + bufferWasFull = TRUE; + } + } + else + { + bufferWasFull = FALSE; + } + + + NSS_UI_ConsoleBufferCurrentSize += strlen( curBuf ); + + if (NSS_UI_ConsoleBufferCurrentSize > 0) + { + //------------------------------------------ + // wake up any code waiting on a device_read + //------------------------------------------ + wake_up_interruptible(&my_queue); + } + +// spin_unlock(&consoleLock); //control single access to ConsoleBuffer + up(&consoleSema); //control single access to ConsoleBuffer + kfree(format_temp); + return( 0 ); } + + +//------------------------------------------------------------------------- +// Proc interface routine +// +// Called when the NSS System Console UI has a command line input for +// the NSS KLM. +//------------------------------------------------------------------------- +static int NSS_UI_CommandLineIn(struct file *file, + const char *userCommandLine, + unsigned long count, + void *data) +{ + int sts; + int (*funcPtr)(); + + // Need to make this single threaded - + // just fail 2nd, 3rd and etc caller. + if (!NSS_UI_CommandLineFile) + { + return( -ENXIO ); + } + + if (count >= sizeof(NSS_UI_CommandLineBuffer)) + { + // We do not accept partial command lines + // as they could cause unwanted actions + return( -EINVAL ); + } + + sts = copy_from_user(NSS_UI_CommandLineBuffer, userCommandLine, count); + if (sts) + { + return( -EFAULT ); + } + + //------------------------------------ + //'count' should not include a '\0'. + //------------------------------------ + NSS_UI_CommandLineBuffer[count] = '\0'; + + mpkEnter(); + + // Now process the command via the nss command line parser +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) + funcPtr = inter_module_get("NSS_ConsoleCmdParser"); +#else + funcPtr = nss_get_module("NSS_ConsoleCmdParser"); +#endif + if (funcPtr == NULL) + { + mpkExit(); + return(count); + } + funcPtr(NSS_UI_CommandLineBuffer); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) + inter_module_put("NSS_ConsoleCmdParser"); +#else + nss_put_module("NSS_ConsoleCmdParser"); +#endif + + mpkExit(); + + return(count); +} + +//--------------------------------------------------------------------- +// Proc interface routine +// +// Called by NSSUI when it needs console output. +// +// Because we 'eat' the chars that we output we do not need to use +// 'large file' mode. This means we do not use 'start' or 'off'. +//----------------------------------------------------------------------- +static int NSS_UI_ConsoleOut(char *systemPage, char **start, + off_t off, int count, int *eof, void *data) +{ + //--------------------------------------------------------- + //Only allow one user program to open device in write mode + //Multiple read mode is enabled + //--------------------------------------------------------- +#define INUSE_MESSAGE "proc/nss/console or /dev/nsscmd already open in write mode\n" + if (NSS_DEVICE_IN_USE) + { + printk("<1>" INUSE_MESSAGE); + return -EBUSY; + } + + NSS_INC_DEVICE_COUNT; + +// spin_lock(&consoleLock); + down(&consoleSema); + + //printk("<1>" "NSS::%s[%d] counts are (%d,%d)\n", + // __FILE__, __LINE__, count, NSS_UI_ConsoleBufferCurrentSize ); + + if ( count == 0 ) + { //TODO: what is the proper return here??? + *eof = 1; + + // printk("<1>" "NSS::%s[%d] counts are (%d,%d)\n", + // __FILE__, __LINE__, count, + // NSS_UI_ConsoleBufferCurrentSize ); +// spin_unlock(&consoleLock); + up(&consoleSema); + NSS_DEC_DEVICE_COUNT; + return( 0 ); + } + + if (!NSS_UI_ConsoleFile) + { + //printk("<1>" "NSS::%s[%d] counts are (%d,%d)\n", + // __FILE__, __LINE__, count, + // NSS_UI_ConsoleBufferCurrentSize ); +// spin_unlock(&consoleLock); + up(&consoleSema); + NSS_DEC_DEVICE_COUNT; + return( -ENXIO ); + } + + if ( NSS_UI_ConsoleBufferCurrentSize == 0 ) + { + *eof = 1; + //printk("<1>" "NSS::%s[%d] counts are (%d,%d)\n", + // __FILE__, __LINE__, count, + // NSS_UI_ConsoleBufferCurrentSize ); +// spin_unlock(&consoleLock); + up(&consoleSema); + NSS_DEC_DEVICE_COUNT; + return( 0 ); + } + + if ( count >= NSS_UI_ConsoleBufferCurrentSize ) + { + count = NSS_UI_ConsoleBufferCurrentSize; + } + + // TODO: If this is really a sysetmPage + // I assume no validating is needed??? + memcpy( systemPage, &NSS_UI_ConsoleBuffer[0], count ); + NSS_UI_ConsoleBufferCurrentSize -= count; + + // FixFixFix - use a wrapping buffer for performance + if ( NSS_UI_ConsoleBufferCurrentSize ) + { + memcpy( NSS_UI_ConsoleBuffer, NSS_UI_ConsoleBuffer + count, + NSS_UI_ConsoleBufferCurrentSize ); + } + + *start = systemPage; + *eof = 0; // TODO: not sure how to or when to set + + //printk("<1>" "NSS::%s[%d] counts are (%d,%d)\n", + // __FILE__, __LINE__, count, NSS_UI_ConsoleBufferCurrentSize ); + +// spin_unlock(&consoleLock); + up(&consoleSema); + + NSS_DEC_DEVICE_COUNT; + + return(count); +} + +void NSS_UI_CreateProcEntries(void) +{ + /* Create the NSS skeleton proc directory */ + NSS_MainProcDir = proc_mkdir(NSS_MainDirName, NULL); + if (NSS_MainProcDir) { + NSS_MainProcDir->owner=THIS_MODULE; + NSS_UI_ConsoleFile = create_proc_entry( + NSS_UI_ConsoleName, + 0400, + NSS_MainProcDir); + if (NSS_UI_ConsoleFile) { + NSS_UI_ConsoleFile->data = NULL; + NSS_UI_ConsoleFile->read_proc = NSS_UI_ConsoleOut; + NSS_UI_ConsoleFile->write_proc = NULL; + NSS_UI_ConsoleFile->owner = THIS_MODULE; + } else { + printk("<1>" "NSS::%s[%d] Unable to create %s\n", + __FILE__, __LINE__, + NSS_UI_ConsoleName ); + } + + NSS_UI_CommandLineFile = create_proc_entry( + NSS_UI_CommandLineName, + 0200, + NSS_MainProcDir); + if (NSS_UI_CommandLineFile) { + NSS_UI_CommandLineFile->data = NULL; + NSS_UI_CommandLineFile->read_proc = NULL; + NSS_UI_CommandLineFile->write_proc = NSS_UI_CommandLineIn; + NSS_UI_CommandLineFile->owner = THIS_MODULE; + } else { + printk("<1>" "NSS::%s[%d] Unable to create %s\n", + __FILE__, __LINE__, + NSS_UI_CommandLineName ); + } + } else { + /* Error out */ + printk("<1>" "NSS::%s[%d] Unable to create %s\n", + __FILE__, __LINE__, NSS_MainDirName ); + /* + * Normally, we would return a failure value indicating why + * we could + * not create the /proc/nssSkeleton directory. i.e. -ENOMEM + * --- However for simplicity, we just leave the pointer NULL --- + */ + } + return; +} + +void NSS_UI_RemoveProcEntries(void) +{ + if (NSS_MainProcDir) { + if (NSS_UI_ConsoleFile) { + remove_proc_entry(NSS_UI_ConsoleName, NSS_MainProcDir); + } + if (NSS_UI_CommandLineFile) { + remove_proc_entry(NSS_UI_CommandLineName, + NSS_MainProcDir); + } + + remove_proc_entry(NSS_MainDirName, NULL); + } + return; +} + +char NSS_CommandLine[512]; + +//----------------------------------------------------------------- +// Implement a character device for console command input / display +//----------------------------------------------------------------- +typedef struct device_message { + char msg[256]; + int msg_size; + char *msg_ptr; +}device_message; + + +static int device_open(struct inode *inode, struct file *file) +{ + struct device_message *message; + + //--------------------------------------------------------- + //Only allow one user program to open device in write mode + //Multiple read mode is enabled + //--------------------------------------------------------- + //printk("<1>" "/dev/nsscmd device_open -- f_flags: %d\n",file->f_flags); + if (NSS_DEVICE_IN_USE) + { + if ( !(file->f_flags & O_WRONLY) ) + { + printk("<1>" "/dev/nsscmd already open\n"); + return -EBUSY; + } + } + + //----------------------------------------------------- + //Initialize the message structure for this device + //The message structure holds the command_line written + //from the userspace program + // + //This message structure is a bit of an overkill for now + //But it does provide the path in the future to support + //mulitple concurrent opens + //----------------------------------------------------- + message = kmalloc(sizeof(device_message),GFP_KERNEL); + if(!message) + { + printk("<1>" "device_open unable to allocate memory \n"); + return -ENOMEM; + } + memset(message->msg,0,256); + file->private_data = message; + message->msg_size = 0; + message->msg_ptr = message->msg; + + //------------------------------------------------------------- + //Increment the use count. Device is now marked as busy/inuse + //------------------------------------------------------------- + if ( !(file->f_flags & O_WRONLY) ) + { + NSS_INC_DEVICE_COUNT; + } + + return 0; +} + +static int device_release(struct inode *inode, struct file *file) +{ + // printk("<1>" "/dev/nsscmd device_release called \n"); + // Free the message buffer + kfree(file->private_data); + + if ( !(file->f_flags & O_WRONLY) ) + { + NSS_DEC_DEVICE_COUNT; + } + + return 0; +} + +static ssize_t device_read(struct file *filp, char *buffer, + size_t length, loff_t *offset) +{ + size_t bytes_read = 0; + int sts; + +// spin_lock(&consoleLock); //provide single access to NSS_UI_ConsoleBuffer + down(&consoleSema); + + // printk("<1>" "/dev/nsscmd device_read called length:%d \n",length); + + //------------------------------------------------------------------- + //If the userspace program has requested a non-blocking open and + //the buffer is empty then don't block and return + //------------------------------------------------------------------- + if((filp->f_flags & O_NONBLOCK)&&(NSS_UI_ConsoleBufferCurrentSize==0)) + { +// spin_unlock(&consoleLock); + up(&consoleSema); + return -EAGAIN; + } + + //-------------------------------------------------------- + //If the buffer is empty or the requested number of bytes + //to read is 0 then exit + //-------------------------------------------------------- + if ( length==0 ) + { + goto read_exit; + } + + //------------------------------------------------------------ + //If buffer is empty then block waiting for data to be written + //into the buffer + //------------------------------------------------------------ + if (NSS_UI_ConsoleBufferCurrentSize == 0) + { + //printk("<1>" "NSS_UI_ConsoleBufferCurrentSize is 0 \n"); +// spin_unlock(&consoleLock); + up(&consoleSema); + interruptible_sleep_on(&my_queue); +// spin_lock(&consoleLock); //provide single access to NSS_UI_ConsoleBuffer + down(&consoleSema); + } + + bytes_read = length; + + if ( bytes_read >= NSS_UI_ConsoleBufferCurrentSize ) + { + bytes_read = NSS_UI_ConsoleBufferCurrentSize; + } + + //----------------------------------------------------------- + //copy from kernel to userspace + //----------------------------------------------------------- + //printk("<1>" "copy_to_user bytes_read:%d\n",bytes_read); + sts = copy_to_user( buffer, &NSS_UI_ConsoleBuffer[0], bytes_read ); + + + NSS_UI_ConsoleBufferCurrentSize -= bytes_read; + + if ( NSS_UI_ConsoleBufferCurrentSize ) + { + // shift the buffer + memcpy( NSS_UI_ConsoleBuffer, NSS_UI_ConsoleBuffer + bytes_read, + NSS_UI_ConsoleBufferCurrentSize ); + } + +read_exit: + //printk("<1>" "/dev/nsscmd bytes_read: %d\n",bytes_read); + filp->f_pos = bytes_read; +// spin_unlock(&consoleLock); + up(&consoleSema); + return bytes_read; +} + +static ssize_t device_write(struct file *filp, + const char *buff, size_t len, loff_t *off) +{ + struct device_message *message; + char *msg_end; + int (*funcPtr)(); + int sts; + + //printk("<1>" "/dev/nsscmd device_write called length:%d \n",len); + mpkEnter(); + if (len >= sizeof(message->msg)) + { + len = sizeof(message->msg)-1; + } + + message = filp->private_data; + + if (message->msg_size == 0 ) message->msg_ptr = message->msg; + + sts = copy_from_user(message->msg_ptr,buff,len); + msg_end = message->msg_ptr + len; + + *msg_end='\0'; + + message->msg_size =+ len; + + //printk("<1>" "message->msg_size: %d\n",message->msg_size); + //printk("<1>" " message: %s \n",message->msg_ptr); + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) + funcPtr = inter_module_get("NSS_ConsoleCmdParser"); +#else + funcPtr = nss_get_module("NSS_ConsoleCmdParser"); +#endif + if (funcPtr == NULL) + { + mpkExit(); + //printk("<1>" "funcPtr is NULL for calling NSS_ConsoleCmdParser\n"); + return 0; + } + funcPtr(message->msg_ptr); + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) + inter_module_put("NSS_ConsoleCmdParser"); +#else + nss_put_module("NSS_ConsoleCmdParser"); +#endif + + message->msg_size = 0; // reset message buffer + + mpkExit(); + + return len; +} + +static int device_ioctl(struct inode *inode, struct file * filp, unsigned int intval, unsigned long longval) +{ + //printk("<1>" "device_ioctl called: %d: %d\n",intval,longval); + return 0; +} + +struct file_operations fops_nssui = { + .read = device_read, + .write = device_write, + .open = device_open, + .release = device_release, + .ioctl = device_ioctl +}; diff --git a/src/nwnss/library/wio/wSetStdio.c b/src/nwnss/library/wio/wSetStdio.c new file mode 100644 index 0000000..5fe6257 --- /dev/null +++ b/src/nwnss/library/wio/wSetStdio.c @@ -0,0 +1,52 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library Routine + +-------------------------------------------------------------------------*/ +#include + +/************************************************************************** + * This will process a KEYBOARD event. It will wake all threads waiting + * for a KEY. + * NOTE: THIS IS CALLED AT INTERRUPT TIME AND INTERRUPTS ARE ALREADY MASKED + ***************************************************************************/ +WFile_s *LB_wSetStdio( + WFile_s *file) +{ + WFile_s *oldFile; + + oldFile = COMN_Resource.stdio; + COMN_Resource.stdio = file; + return oldFile; +} diff --git a/src/nwnss/library/wio/wWrapString.c b/src/nwnss/library/wio/wWrapString.c index 01f519f..4b27257 100644 --- a/src/nwnss/library/wio/wWrapString.c +++ b/src/nwnss/library/wio/wWrapString.c @@ -34,9 +34,8 @@ | This module is used to: | NSS Library File that implements "printf" +-------------------------------------------------------------------------*/ -// NSS import: public_core/library/wio/wWrapString.c -#include -#include +#include /* netware */ +#include #include #include @@ -56,7 +55,7 @@ void LB_writeLineSegment( *endOfLine = 0; wAPrintf(wfile,attr,MSGNot("%s\n"),frontOfLine); *endOfLine = savech; -} +} /************************************************************************** @@ -87,7 +86,7 @@ void LB_wWrapString( { maxLineLen = width-col; /* width of screen minus current column */ if (strlen(frontLastLine) < maxLineLen) /* Hey, string fits */ - { + { /* no special handling needed, so write the line and get out of here */ wAPrintf(wfile,attr,MSGNot("%s\n"),frontLastLine); @@ -96,9 +95,9 @@ void LB_wWrapString( /* s is the beginning of the next line, but this is artificial, since we need to find a good place to break. The search has to go - from beginning to end because OSIsDoubleByteCharacter will + from beginning to end because OSIsDoubleByteCharacter will not return accurate information otherwise. */ - s = frontLastLine; + s = frontLastLine; lastSpace = frontLastLine; lastChar = frontLastLine; /* Stop after passing maxLineLen so that we can get as close to @@ -115,7 +114,7 @@ void LB_wWrapString( found */ ZOS_OSIsDoubleByteCharacter(result,*s); if (result) - { + { lastChar = s; ++s; ++i; @@ -125,12 +124,12 @@ void LB_wWrapString( } /* This will always work whether single or double-byte character */ if (lastSpace != frontLastLine) - { + { s = lastSpace; } else if (lastChar != frontLastLine) { - s = lastChar; + s = lastChar; } LB_writeLineSegment(wfile,attr,frontLastLine,s); /* skip extra white space */ @@ -151,7 +150,7 @@ void LB_wWrapString( } /* prepare to process more of string */ - frontLastLine = s; + frontLastLine = s; if (strlen(frontLastLine) <= 0) break; diff --git a/src/nwnss/library/wio/wactivate.c b/src/nwnss/library/wio/wactivate.c new file mode 100644 index 0000000..9829deb --- /dev/null +++ b/src/nwnss/library/wio/wactivate.c @@ -0,0 +1,51 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Activate the given window + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_ScreenIO +#include /* NetWare Includes*/ + +#include +#include "nssOSAPIs.h" + +/************************************************************************** + * This will activate the given window. + ***************************************************************************/ +void LB_wActivate( + WFile_s *wfile) +{ + ZOS_ActivateScreen(GET_SCREENID(wfile)); +} +#endif diff --git a/src/nwnss/library/wio/waprintf.c b/src/nwnss/library/wio/waprintf.c index d80b225..a8594bf 100644 --- a/src/nwnss/library/wio/waprintf.c +++ b/src/nwnss/library/wio/waprintf.c @@ -34,7 +34,7 @@ | This module is used to: | NSS Library File that implements "printf" +-------------------------------------------------------------------------*/ -#include +#include /************************************************************************** * This will display a message on the PSS screen @@ -51,3 +51,4 @@ void LB_wAPrintf( LB__wioOutput(file,attr,formatStr,args); va_end(args); } + diff --git a/src/nwnss/library/wio/wcenter.c b/src/nwnss/library/wio/wcenter.c new file mode 100644 index 0000000..0e1aaf1 --- /dev/null +++ b/src/nwnss/library/wio/wcenter.c @@ -0,0 +1,67 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This will center a line on the given screen + +-------------------------------------------------------------------------*/ +#include +#include +#include + +/************************************************************************** + * This will display a message on the PSS screen + ***************************************************************************/ +void LB_wCenter( + WFile_s *file, + const char *format, + ...) +{ + va_list args; + size_t len; + NINT scrHeight,scrWidth,row,col; + char destBuf[512]; + + LB_wGetDimensions(file,&scrHeight,&scrWidth); + va_start(args,format); + vsprintf((char *)destBuf,format,args); + + len = strlen(destBuf); + if (len < scrWidth) + { + len = ((scrWidth - len) / 2); + LB_wGetPos(file,&row,&col); + LB_wSetPos(file,row,len); + } + LB_wAPrintf(file,LGRAY,MSGNot("%s"),destBuf); +} + diff --git a/include/nwnss/include/nameScan.h b/src/nwnss/library/wio/wclose.c similarity index 60% rename from include/nwnss/include/nameScan.h rename to src/nwnss/library/wio/wclose.c index a5ff7b5..c2c07b2 100644 --- a/include/nwnss/include/nameScan.h +++ b/src/nwnss/library/wio/wclose.c @@ -32,40 +32,34 @@ | |--------------------------------------------------------------------------- | This module is used to: - | This defines the interfaces into the PSS portion of the connection - | structure. + | NSS Library Routine +-------------------------------------------------------------------------*/ -#ifndef _NAMESCAN_H_ -#define _NAMESCAN_H_ +#ifndef __linux__ // LINUX_ScreenIO +#include /* NetWare Includes*/ +#include -/*--------------------------------------------------------------------------- - * Internal Common Layer Prototypes for working with name messages - *---------------------------------------------------------------------------*/ -extern STATUS NMSG_ScanNextComponent( - GeneralMsg_s *genMsg, - NamingMsg_s *nameMsg); +/************************************************************************** + * This will close the given window + ***************************************************************************/ +void LB_wClose( + WFile_s *file) +{ + NINT flags; + struct ScreenStruct *screenID; -extern STATUS NMSG_ValidateNameMsg( - GeneralMsg_s *genMsg, - NamingMsg_s *nameMsg); + if (file == NULL) + return; -extern STATUS NMSG_ReparseNameMsgDOSComponent( - GeneralMsg_s *genMsg, - NamingMsg_s *nameMsg); + flags = file->flags; + screenID = file->screenID; -extern void NMSG_ShutdownWorkBufferMemory(void); + LB__wioDeleteWFile(file); -STATUS TestScanComponents( - NINT nameSpaceID, - NINT pathFormat, - void *path, - NINT parseFlags, - NINT scanFlags, - NINT sizeRetPath, - unicode_t *ret_path, - NINT *ret_parseFlags, - NINT *ret_scanFlags, - NINT *ret_numComponents); - -#endif /* _NAMESCAN_H_ */ + if (!(flags & WFLAGS_SCREEN_EXTERNAL)) + { + zASSERT(!(screenID->flags & KEYBOARD_INPUT_ACTIVE)); + ZOS_CloseScreen(screenID); + } +} +#endif diff --git a/src/nwnss/library/wio/wclrscr.c b/src/nwnss/library/wio/wclrscr.c new file mode 100644 index 0000000..7f957ac --- /dev/null +++ b/src/nwnss/library/wio/wclrscr.c @@ -0,0 +1,50 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This will clear the given screen + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_ScreenIO +#include /* NetWare Includes*/ + +#include + +/************************************************************************** + * This will display a message on the PSS screen + ***************************************************************************/ +void LB_wClearScreen( + WFile_s *wfile) +{ + ZOS_ClearScreen(GET_SCREENID(wfile)); +} +#endif diff --git a/src/nwnss/library/wio/wgetc.c b/src/nwnss/library/wio/wgetc.c new file mode 100644 index 0000000..b0a6d06 --- /dev/null +++ b/src/nwnss/library/wio/wgetc.c @@ -0,0 +1,135 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library File that implements "getchar" + +-------------------------------------------------------------------------*/ +#include /* NetWare Includes*/ + +#include +#include +#include "intlatch.h" + +/************************************************************************** + * Get the next character and RETURN it. + ***************************************************************************/ +#if zNETWARE +int LB_wGetc( + WFile_s *file) +{ + BYTE keyType; + BYTE keyValue; + BYTE keyStatus; + BYTE keyScanCode; + int retval; + struct ScreenStruct *screenID; /* screen ID of window*/ + + if ((file == NULL) || (file->flags & WFLAGS_CLOSING_SCREEN)) + return EOF; + + if (!(file->flags & WFLAGS_NOLATCH_IO)) + LB__internalXLatch(&file->latch); + + if (file->flags & WFLAGS_CLOSING_SCREEN) + return EOF; /* the latch has been cleared by __wioDeleteWFile*/ + + screenID = GET_SCREENID(file); + while ((screenID->flags & KEYBOARD_INPUT_ACTIVE) || + !CheckKeyStatus(screenID)) + { + file->keyWaitThread = (LONG)kCurrentThread(); + Wait(); + zASSERT(file->keyWaitThread == NULL); + if (file->flags & WFLAGS_CLOSING_SCREEN) + return EOF; /* the latch has been cleared by __wioDeleteWFile*/ + } + + ZOS_GetKey(screenID,&keyType,&keyValue,&keyStatus,&keyScanCode,1); + + if (keyType == ESCAPE_KEY && keyScanCode == 1) + { + retval = 27; + } + else + { + switch (keyType) + { + case NORMAL_KEY: + retval = keyValue; + break; + case FUNCTION_KEY: + retval = EOF; + break; + case ENTER_KEY: + retval = 13; + break; + case ESCAPE_KEY: + retval = 27; + break; + case BACKSPACE_KEY: + retval = 8; + break; + case DELETE_KEY: + retval = 127; + break; + case INSERT_KEY: + case CURSOR_UP_KEY: + case CURSOR_DOWN_KEY: + case CURSOR_RIGHT_KEY: + case CURSOR_LEFT_KEY: + case CURSOR_HOME_KEY: + case CURSOR_END_KEY: + case CURSOR_PUP_KEY: + case CURSOR_PDOWN_KEY: + retval = keyType; + break; + default: + retval = EOF; + break; + } + } + if (!(file->flags & WFLAGS_NOLATCH_IO)) + LB__internalUnXLatch(&file->latch); + return retval; +} +#endif // #if zNETWARE + +#ifdef __linux__ // LINUX_ScreenIO + // FixFixFix(Linux) - after DEMO this needs to use ncurses and moved to user space +int LB_wGetc( WFile_s *file) +{ + int key; + key = NSS_wgetch( NSS_TYPE_OF_KEY_NORMAL ); // Retrieve a key from Kernel Space (We block until we key a key from NSS SCA) + return key; +} +#endif diff --git a/src/nwnss/library/wio/wgetdim.c b/src/nwnss/library/wio/wgetdim.c new file mode 100644 index 0000000..e279e58 --- /dev/null +++ b/src/nwnss/library/wio/wgetdim.c @@ -0,0 +1,64 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This will center a line on the given screen + +-------------------------------------------------------------------------*/ +#include /* NetWare Includes*/ + +#include + +/************************************************************************** + * This will display a message on the PSS screen + ***************************************************************************/ +#if zNETWARE +void LB_wGetDimensions( + WFile_s *wfile, + NINT *height, + NINT *width) +{ + ZOS_GetActualScreenSize(GET_SCREENID(wfile),(LONG *)height,(LONG *)width,NULL); +} +#endif + +#ifdef __linux__ // LINUX_ScreenIO + // FixFixFix(Linux) - after DEMO this needs to use ncurses and moved to user space +void LB_wGetDimensions( + WFile_s *wfile, + NINT *height, + NINT *width) +{ + if ( height ) *height = 80; + if ( width ) *width = 24; +} +#endif diff --git a/src/nwnss/library/wio/wgetpos.c b/src/nwnss/library/wio/wgetpos.c index bdfe244..5aaf37c 100644 --- a/src/nwnss/library/wio/wgetpos.c +++ b/src/nwnss/library/wio/wgetpos.c @@ -34,10 +34,9 @@ | This module is used to: | This will center a line on the given screen +-------------------------------------------------------------------------*/ -// NSS import: public_core/library/wio/wgetpos.c -#include +#include /* NetWare Includes*/ -#include +#include /************************************************************************** * This will get the current position of the OUTPUT cursor. diff --git a/src/nwnss/library/wio/wgets.c b/src/nwnss/library/wio/wgets.c new file mode 100644 index 0000000..96620b6 --- /dev/null +++ b/src/nwnss/library/wio/wgets.c @@ -0,0 +1,79 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library File that implements "wgets" + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_ScreenIO +#include /* NetWare Includes*/ + +#include +#include +#include "intlatch.h" + +/************************************************************************** + * This routine will get a line from the screen and return it. This will + * not return a line bigger then 256 bytes. + ***************************************************************************/ +char *LB_wGets( + WFile_s *file, + char *buf) +{ + struct ScreenStruct *screenID; /* screen ID of window*/ + + if ((file == NULL) || (file->flags & WFLAGS_CLOSING_SCREEN)) + return NULL; + + if (!(file->flags & WFLAGS_NOLATCH_IO)) + LB__internalXLatch(&file->latch); + + screenID = GET_SCREENID(file); + while (screenID->flags & KEYBOARD_INPUT_ACTIVE) + { + file->keyWaitThread = (LONG)kCurrentThread(); + Wait(); + zASSERT(file->keyWaitThread == NULL); + if (file->flags & WFLAGS_CLOSING_SCREEN) + return NULL; /* the latch has been cleared by __wioDeleteWFile*/ + } + + file->flags |= WFLAGS_READLINE_PENDING; + ZOS_SetInputToOutputCursorPosition(screenID); + ZOS_InputFromKeyboard(screenID,MSGNot("\x01..\xff"),zMAX_FULL_NAME,zMAX_FULL_NAME,(BYTE *)buf,0,0,0); + file->flags &= ~WFLAGS_READLINE_PENDING; + + if (!(file->flags & WFLAGS_NOLATCH_IO)) + LB__internalUnXLatch(&file->latch); + return buf; +} +#endif diff --git a/src/nwnss/library/wio/wio.c b/src/nwnss/library/wio/wio.c index a16c839..3b6f587 100644 --- a/src/nwnss/library/wio/wio.c +++ b/src/nwnss/library/wio/wio.c @@ -35,13 +35,13 @@ | NSS Library Routine +-------------------------------------------------------------------------*/ #ifndef __linux__ // LINUX_ScreenIO -#include /* NetWare Includes*/ +#include /* NetWare Includes*/ #include -#include /* NSS Library includes */ +#include /* NSS Library includes */ #include -#include -#include +#include +#include #include #include "intlatch.h" @@ -71,7 +71,7 @@ void LB_KeyEventHandler( DQ_FOREACH(&WFileMasterList,file,WFile_s,link) { - if ((file->keyWaitThread) /*&& + if ((file->keyWaitThread) /*&& (GET_SCREENID(file)->flags & KEYBOARD_INPUT_ACTIVE)*/) { Continue(file->keyWaitThread); @@ -196,7 +196,7 @@ void LB__wioCheckPause( ZOS_UnformattedOutputWithAttribute(screenID,YELLOW, MSG("-cancel output C-continuous -next line -next screen",269)); - /* This new line is needed for languages other than English, to + /* This new line is needed for languages other than English, to force a uniform prompt length. */ ZOS_UnformattedOutputWithAttribute(screenID,BLACK,MSGNot("\n")); @@ -287,7 +287,7 @@ void LB__wioOutput( } else { - OutputToScreenPointerAttribute(screenID,attr,(void *)format,*args); + OutputToScreenPointerAttribute(screenID,attr,(void *)format,*args); } } else if (file->curPauseLine != -1) @@ -311,7 +311,7 @@ void LB__wioOutput( while ((ch = *s++)) { if (ch == '\n') - { + { LB__wioCheckPause(file,screenID); ch = s[0]; /* save first char of next line*/ s[0] = NULL; /* null terminate line*/ @@ -333,7 +333,7 @@ void LB__wioOutput( file->curLineLength = 0;/* because we already grabbed 1st char*/ } else if (file->curLineLength >= 79) - { + { s--; LB__wioCheckPause(file,screenID); ch = s[0]; /* save first char of next line*/ @@ -352,7 +352,7 @@ void LB__wioOutput( } } s[0] = ch; /* restore first char of next line*/ - s[1] = ch2; /* restore 2nd character*/ + s[1] = ch2; /* restore 2nd character*/ line = s; /* restart the line*/ if (file->curPauseLine != -1) file->curPauseLine++; /* bump line count*/ @@ -387,8 +387,7 @@ void LB__wioOutput( #endif #ifdef __linux__ // LINUX_ScreenIO -#include -#include +#include /************************************************************************** * This is the LOW LEVEL write routine that outputs the given data @@ -422,3 +421,5 @@ void LB__wioOutput( return; } #endif + + diff --git a/src/nwnss/library/wio/wlock.c b/src/nwnss/library/wio/wlock.c new file mode 100644 index 0000000..dac607e --- /dev/null +++ b/src/nwnss/library/wio/wlock.c @@ -0,0 +1,63 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library Routine + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_ScreenIO +#include +#include + +/************************************************************************** + * This is for externally locking the screen so you can do multiple IOs + * to it. + ***************************************************************************/ +void LB_wLock( + WFile_s *file) +{ + if (file != NULL) + LB__internalXLatch(&file->groupedIOlatch); +} + + +/************************************************************************** + * This unlocks the screen. + ***************************************************************************/ +void LB_wUnlock( + WFile_s *file) +{ + if (file != NULL) + LB__internalUnXLatch(&file->groupedIOlatch); +} +#endif + diff --git a/src/nwnss/library/wio/wopen.c b/src/nwnss/library/wio/wopen.c new file mode 100644 index 0000000..fb4f1a0 --- /dev/null +++ b/src/nwnss/library/wio/wopen.c @@ -0,0 +1,78 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library Routine + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_ScreenIO +#include /* NetWare Includes*/ + +#include +#include +#include "nssOSAPIs.h" + +/************************************************************************** + * This will open a window of the given name and will switch to it. + * If the return value is NON-NULL then this was successful else it + * failed. + ***************************************************************************/ +WFile_s *LB_wOpen( + const char *screenName, + NINT flags) +{ + struct ScreenStruct *screenID; + WFile_s *file; + LONG result; + ZOS_OpenScreen(result, (void *)screenName, COMN_Resource.screenRTag, &screenID); + if (result != 0) + { + errPrintf(WHERE, LibModule, 224, + MSG("Unable to open screen \"%s\". You may not " + "have enough memory.", 270), screenName); + return NULL; + } + + file = LB__wioCreateWFile(screenID,0); + if (file == NULL) + { + ZOS_CloseScreen(screenID); + return NULL; + } + + ZOS_ClearScreen(screenID); + if (!(flags & WOPEN_NOACTIVATE)) + ZOS_ActivateScreen(screenID); + + return file; +} +#endif diff --git a/src/nwnss/library/wio/wpause.c b/src/nwnss/library/wio/wpause.c index 52ff495..3622e7e 100644 --- a/src/nwnss/library/wio/wpause.c +++ b/src/nwnss/library/wio/wpause.c @@ -86,7 +86,7 @@ NINT LB_wPause( if ((length != 0) && (wfile->pauseBuffer == NULL)) { wfile->pauseBuffer = (BYTE *)malloc(WPAUSE_BUFFER_SIZE); - } + } else if ((length == 0) && (wfile->pauseBuffer != NULL)) { free(wfile->pauseBuffer); @@ -114,3 +114,4 @@ NINT LB_wPause( return( 0 ); } #endif + diff --git a/src/nwnss/library/wio/wprintf.c b/src/nwnss/library/wio/wprintf.c index 58f51cb..a13819a 100644 --- a/src/nwnss/library/wio/wprintf.c +++ b/src/nwnss/library/wio/wprintf.c @@ -34,7 +34,7 @@ | This module is used to: | NSS Library File that implements "wprintf" +-------------------------------------------------------------------------*/ -#include +#include /************************************************************************** * This will display a message on the PSS screen @@ -50,3 +50,4 @@ void LB_wPrintf( LB__wioOutput(file,LGRAY,formatStr,args); va_end(args); } + diff --git a/src/nwnss/library/wio/wpromptYesNo.c b/src/nwnss/library/wio/wpromptYesNo.c new file mode 100644 index 0000000..2cd6203 --- /dev/null +++ b/src/nwnss/library/wio/wpromptYesNo.c @@ -0,0 +1,172 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library File that implements "PromptForYesOrNo" + +-------------------------------------------------------------------------*/ +#ifdef __linux__ + +#include + +static char *yesNo = "ynYN"; + +// +// PromptForYesOrNo() - DEMO version of code. +// +// Original source is from NetWare's scrinput.c +// +LONG PromptForYesOrNo( LONG defaultValue, char *promptText, ... ) +{ + va_list args; + int keyValue; + LONG returnValue; + + va_start( args, promptText ); + LB_vaprintf( 0, promptText, args ); // FixFixFix - should not include attribute + va_end( args ); + + LB_printf( "%c", (defaultValue & TRUE) ? yesNo[0] : yesNo[1] ); + (void)NSS_wgetch( NSS_TYPE_OF_KEY_MOVE_2 ); // Move curser back two. Do not actually get a key + for (;;) + { + keyValue = NSS_wgetch( NSS_TYPE_OF_KEY_YES_OR_NO ); // No echo (beep on illegal key) +#if 0 + LB_aprintf( 0, "Key in LKM 0x%x\n", keyValue ); +#endif + if ( (keyValue == yesNo[0]) || (keyValue == yesNo[2]) ) + { + returnValue = TRUE; + break; + } + if ( (keyValue == yesNo[1]) || (keyValue == yesNo[3]) ) + { + returnValue = FALSE; + break; + } + if ( (keyValue == KEY_ENTER) || (keyValue == 0x0d) ) + { + returnValue = (defaultValue & TRUE); + break; + } + if ( keyValue == 0x1b ) // escape + { + if (defaultValue & ~TRUE) + { + returnValue = (LONG) -1; + } + else + { + returnValue = (defaultValue & TRUE); + } + break; + } +// beep(); + } + LB_printf( "%c\n", (returnValue & TRUE) ? yesNo[0] : yesNo[1]); + return (returnValue); + +} + + +/************************************************************************** + * Get the next character and RETURN it. Return TRUE if they type a YES + * or return FALSE if the type a NO. If the screen we are reading from is + * busy the "responseIfCantRead" error is returned. + ***************************************************************************/ +BOOL LB_wPromptForYesOrNo( + WFile_s *file, + BOOL defaultResponse, + BOOL responseIfCantRead, // FixFixFix - For the DEMO this is OK to ignore + char *promptText) +{ + BOOL response; + LONG result; + + result = PromptForYesOrNo( defaultResponse, promptText ); + response = (BOOL)result; + + return(response); +} + +#endif + +#ifndef __linux__ + +#include /* NetWare Includes*/ + +#include +#include "intlatch.h" + +/************************************************************************** + * Get the next character and RETURN it. Return TRUE if they type a YES + * or return FALSE if the type a NO. If the screen we are reading from is + * busy the "responseIfCantRead" error is returned. + ***************************************************************************/ +BOOL LB_wPromptForYesOrNo( + WFile_s *file, + BOOL defaultResponse, + BOOL responseIfCantRead, + char *promptText) + +{ + BOOL response; + LONG result; + struct ScreenStruct *screenID; /* screen ID of window*/ + + if ((file == NULL) || (file->flags & WFLAGS_CLOSING_SCREEN)) + return(defaultResponse); + + if (!(file->flags & WFLAGS_NOLATCH_IO)) + LB__internalXLatch(&file->latch); + + if (file->flags & WFLAGS_CLOSING_SCREEN) + return(defaultResponse); + + screenID = GET_SCREENID(file); + + if (screenID->flags & KEYBOARD_INPUT_ACTIVE) + { + response = responseIfCantRead; + goto exit; + } + ZOS_PromptForYesOrNo(result,screenID, 1, defaultResponse, promptText); + + response = (BOOL)result; + +exit: + if (!(file->flags & WFLAGS_NOLATCH_IO)) + LB__internalUnXLatch(&file->latch); + + return(response); +} +#endif diff --git a/src/nwnss/library/wio/wsetpos.c b/src/nwnss/library/wio/wsetpos.c index 7281d56..2ed712b 100644 --- a/src/nwnss/library/wio/wsetpos.c +++ b/src/nwnss/library/wio/wsetpos.c @@ -34,10 +34,9 @@ | This module is used to: | This will center a line on the given screen +-------------------------------------------------------------------------*/ -// NSS import: public_core/library/wio/wsetpos.c -#include +#include /* NetWare Includes*/ -#include +#include /************************************************************************** * This will display a message on the PSS screen diff --git a/src/nwnss/library/wio/wsyncin.c b/src/nwnss/library/wio/wsyncin.c new file mode 100644 index 0000000..15eefb7 --- /dev/null +++ b/src/nwnss/library/wio/wsyncin.c @@ -0,0 +1,61 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This will center a line on the given screen + +-------------------------------------------------------------------------*/ +#include /* NetWare Includes*/ + +#include "wio.h" +#include "nssOSAPIs.h" +/************************************************************************** + * This routine will set the OUTPUT cursor to the same value as the + * INPUT cursor. + ***************************************************************************/ +#if zNETWARE +void LB_wSyncToInputCursor( + WFile_s *wfile) +{ + struct ScreenStruct *screenID; + WORD wrow,wcol; + + screenID = GET_SCREENID(wfile); + ZOS_GetInputCursorPosition(screenID,&wrow,&wcol); + ZOS_PositionOutputCursor(screenID,wrow,wcol); +} +#endif + +#ifdef __linux__ // LINUX_ScreenIO + // FixFixFix(Linux) - after DEMO this needs to use ncurses and moved to user space +void LB_wSyncToInputCursor(WFile_s *wfile){} +#endif diff --git a/src/nwnss/library/wio/wvprintf.c b/src/nwnss/library/wio/wvprintf.c index ff9a638..75aba43 100644 --- a/src/nwnss/library/wio/wvprintf.c +++ b/src/nwnss/library/wio/wvprintf.c @@ -34,7 +34,7 @@ | This module is used to: | NSS Library source +-------------------------------------------------------------------------*/ -#include +#include /************************************************************************** * This will display a message on the PSS screen diff --git a/src/nwnss/lsa/Makefile b/src/nwnss/lsa/Makefile new file mode 100644 index 0000000..f59bda1 --- /dev/null +++ b/src/nwnss/lsa/Makefile @@ -0,0 +1,32 @@ +### +### ../nss/public_core/lsa Makefile +### + +############################################################################## +# +# (C) Copyright 2004 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +BASEDIR=../.. + +SUBDIRS= \ + +include ${BASEDIR}/buildtools/Makefile.default + diff --git a/src/nwnss/lsa/Module.supported b/src/nwnss/lsa/Module.supported new file mode 100644 index 0000000..3e9a858 --- /dev/null +++ b/src/nwnss/lsa/Module.supported @@ -0,0 +1,2 @@ +nsslsa.ko + diff --git a/src/nwnss/lsa/lsa.c b/src/nwnss/lsa/lsa.c new file mode 100644 index 0000000..b22fdcc --- /dev/null +++ b/src/nwnss/lsa/lsa.c @@ -0,0 +1,81 @@ +/**************************************************************************** + | + | (C) Copyright 1995 - 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: randys $ + | $Date: 2007-02-28 22:36:45 +0530 (Wed, 28 Feb 2007) $ + | + | $RCSfile$ + | $Revision: 1898 $ + | + |--------------------------------------------------------------------------- + | This module is used to: Finish the startup of the Linux Semantic Agent + +-------------------------------------------------------------------------*/ + +#include +#include + +#include "comnBeasts.h" +#include "lsa.h" +#include "lsaStartup.h" +#include + +BOOL Kprint = TRUE; +LONG LSA_LinuxNobodyUID = 0; +BOOL LSA_HaveNobodyUID = FALSE; +extern STATUS (*GetLinuxAuthIDsListPtr)(); +extern BOOL (*GetLinuxIsSupervisorPtr)(); +extern Key_t (*userKeyPtr)(); + +STATUS LSA_Startup(void) +{ + int sts; + + ASSERT_MPKNSS_LOCK(); + + MPKNSS_UNLOCK(); + sts = ndp_GetUIDFromName("nobody", &LSA_LinuxNobodyUID ); + MPKNSS_LOCK(); + if (sts == 0) + { + LSA_HaveNobodyUID = TRUE; + } + else + { + printk(KERN_ALERT "LSA_Startup - Failed to acquire Linux UID for nobody\n"); + } + + lsaInitErrorTable(); + GetLinuxAuthIDsListPtr = &GetLinuxAuthIDsList; + GetLinuxIsSupervisorPtr = &GetLinuxIsSupervisor; + userKeyPtr = &userKey; + return zOK; +} + +void LSA_Shutdown(void) +{ + ASSERT_MPKNSS_LOCK(); + userShutdown(); +} diff --git a/src/nwnss/lsa/lsaAid.h b/src/nwnss/lsa/lsaAid.h new file mode 100644 index 0000000..29a2596 --- /dev/null +++ b/src/nwnss/lsa/lsaAid.h @@ -0,0 +1,93 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (PSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Things to help us debug LSA on Linux + +-------------------------------------------------------------------------*/ + +#ifndef _AID_H_ +#define _AID_H_ + +#ifndef _STDIO_H +#include +#endif + +#ifndef MAGIC_STRING + #define MAGIC_STRING(_x_) # _x_ + #define MAKE_STRING(_x_) MAGIC_STRING(_x_) +#endif + +#ifndef WHERE + #ifdef FNAM_ + #define WHERE FNAM_ "[" MAKE_STRING(__LINE__) "]" + #else + #define WHERE __FILE__ "[" MAKE_STRING(__LINE__) "]" + #endif +#endif + +#define DUCK(item, type, linkField) \ + ((type *)(((addr)(item)) - offsetof(type, linkField))) + +#undef assert +int assertError (char *msg) +{ + printk(KERN_EMERG "ASSERT FAILED:%s\n", msg); + return 0; +} + +#define assert(_e_) \ + ((void)((_e_) || (assertError(WHERE " (" # _e_ ")")))) + +#if NSS_DEBUG IS_ENABLED + +#define PR_LEVEL "<0>" + +extern BOOL Kprint; + +#define pr(_x) (Kprint && printk(PR_LEVEL "lsa:%s\n", # _x)) +#define prp(_x) (Kprint && printk(PR_LEVEL "lsa:%s=%p\n", # _x, _x)) +#define prx(_x) (Kprint && printk(PR_LEVEL "lsa:%s=%x\n", # _x, _x)) +#define prd(_x) (Kprint && printk(PR_LEVEL "lsa:%s=%d\n", # _x, _x)) +#define prs(_x) (Kprint && printk(PR_LEVEL "lsa:%s=%s\n", # _x, _x)) + +#else + +#define pr(_x) ((void) 0) +#define prp(_x) ((void) 0) +#define prx(_x) ((void) 0) +#define prd(_x) ((void) 0) +#define prs(_x) ((void) 0) + +#endif + +#endif diff --git a/src/nwnss/lsa/lsaCmdline.c b/src/nwnss/lsa/lsaCmdline.c new file mode 100644 index 0000000..e31c4de --- /dev/null +++ b/src/nwnss/lsa/lsaCmdline.c @@ -0,0 +1,120 @@ +/**************************************************************************** + | + | (C) Copyright 1995 - 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2008-05-08 21:52:15 +0530 (Thu, 08 May 2008) $ + | + | $RCSfile$ + | $Revision: 2335 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | command line options for all input action + | + +-------------------------------------------------------------------------*/ +#include +#include +#include "comnBeasts.h" +#include "lsaStartup.h" /* local */ +#include "lsaPrivate.h" + +/*--------------------------------------------------------------------------- + * Global variables + *-------------------------------------------------------------------------*/ + +/*--------------------------------------------------------------------------- + * Help definitions + *-------------------------------------------------------------------------*/ + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*------------------ START OF ROUTINES ------------------------------------*/ + +/*--------------------------------------------------------------------------- + | + +-------------------------------------------------------------------------*/ + +/*- (FUNCTION) ----- LSA_CommandLineSwitches() ------------------------------ + | + | Command line switches for LSA + | + +-------------------------------------------------------------------------*/ +PCLSwitchDef_s LSA_CommandLineSwitches[] = +{ + { MSGNot("SendfileSupport"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_BOOLEAN|SWVAL_BOOL, + 0, 0, + NULL,&LSASendfile, + {{0,0}},0,0, + StructMSGNot("Support sendfile.") + }, + + { MSGNot("CtimeIsMetadataModTime"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_BOOLEAN|SWVAL_BOOL, + 0, 0, + NULL,&LSACtimeIsMetadataModTime, + {{0,0}},0,0, + StructMSGNot("Inode Ctime is set to Metdata Modified time. If OFF then it is set to Create Time.") + }, + + { MSGNot("ListXattrNWmetadata"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_BOOLEAN|SWVAL_BOOL, + 0, 0, + NULL,&LSAReturnNWmetadata, + {{0,0}},0,0, + StructMSGNot("At ListXattr time, return netware metadata also") + }, + + { MSGNot("UpdateAccessTimeForReaddir"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_BOOLEAN|SWVAL_BOOL, + 0, 0, + NULL,&LSAUpdateDirAccessTime, + {{0,0}},0,0, + StructMSGNot("When enumerating directories, update the accessed time. This is default POSIX behavior. ") + }, + + { MSGNot("PosixPermissionMask"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_VALUE|SWVAL_LONG, + 0, 0, + NULL,&LSAPosixPermissionMask, + {{0,0}},0,0, + StructMSGNot("Mask for which bits of rwxrwxrwx will be set. Default 0777") + }, + + {PCMDLINE_ENDOFLIST} +}; + + + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ diff --git a/src/nwnss/lsa/lsaComn.c b/src/nwnss/lsa/lsaComn.c index 3accbf1..38c32da 100644 --- a/src/nwnss/lsa/lsaComn.c +++ b/src/nwnss/lsa/lsaComn.c @@ -34,10 +34,12 @@ | This module is used to: | LSA operations that parallel comn ops. +-------------------------------------------------------------------------*/ -#include -#include +#include +#include +#include +#include +#include #include -#include #include #include #include @@ -54,21 +56,8 @@ #include #include #include -#include -#include -#ifdef NSS_USERSPACE -#include -#endif - - -#ifdef NSS_USERSPACE -static struct { LONG fsuid; } nssLsaComnCurrent = { 0 }; -#define current (&nssLsaComnCurrent) -#undef MSG_USE_DOOR -#undef MSG_RELEASE_DOOR -#define MSG_USE_DOOR(_door) ((void)(_door)) -#define MSG_RELEASE_DOOR(_door) ((void)(_door)) -#endif +#include "lsa.h" +#include "lsaStartup.h" typedef STATUS (*info_f)(GeneralMsg_s *genMsg, File_s *file, void *in, void *out); @@ -89,27 +78,27 @@ static STATUS lookup_apply ( Key_t key; BOOL cleanNameMsg = FALSE; BOOL unlatchBeast = FALSE; - + typedef struct Stack_s { GeneralMsg_s genMsg; NamingMsg_s nameMsg; } Stack_s; STACK_ALLOC(); - + if ((current->fsuid == 0) && lsaInode) { MPKNSS_LOCK(); - + if (lsaInode->li_beast != NULL) { - + COMN_SETUP_GENERAL_MSG_NOSA(&aStack->genMsg); unlatchBeast = TRUE; file = lsaInode->li_beast; - + COMN_USE_BEAST(&file->FILEroot); S_LATCH(&file->FILEbeastLatch); @@ -196,15 +185,10 @@ static STATUS lookup_apply ( if (file->FILEroot.rb_inode != NULL) { -#ifdef NSS_USERSPACE - struct LsaInode_s *rb_lsaInode = - NssLsaXattrUserspaceInodePrivate(file->FILEroot.rb_inode); -#else - struct LsaInode_s *rb_lsaInode = STRUCT(file->FILEroot.rb_inode, + struct LsaInode_s *rb_lsaInode = STRUCT(file->FILEroot.rb_inode, LsaInode_s, li_inode); -#endif - rb_beast = rb_lsaInode->li_beast; - + rb_beast = rb_lsaInode->li_beast; + if (rb_beast != NULL) { rb_lsaInode->li_beast = NULL; @@ -224,7 +208,7 @@ static STATUS lookup_apply ( { lsaInode->li_beast = file; COMN_USE_BEAST(&file->FILEroot); - file->FILEroot.rb_inode = lsaInode->li_inode; + file->FILEroot.rb_inode = &lsaInode->li_inode; } if (rb_beast) @@ -240,8 +224,8 @@ exit: if (cleanNameMsg) { COMN_CleanupNameMsg(&aStack->genMsg, &aStack->nameMsg); - } - if (unlatchBeast) + } + if (unlatchBeast) { COMN_UnlatchAndRelease(&file, SLATCHED); } @@ -384,7 +368,7 @@ STATUS lsa_getTrusteeCount (GeneralMsg_s *genMsg, File_s *file, NINT *count) return rc; } authInfo = file->FILEauth.AUTHauthInfo.zas; - if ((authInfo->p.numTrusteesAssigned == 0) && + if ((authInfo->p.numTrusteesAssigned == 0) && (authInfo->p.trusteeOverflow == zINVALID_ZID)) { return rc; @@ -520,7 +504,7 @@ static STATUS lsa_metadata (GeneralMsg_s *genMsg, File_s *file, void *in, void * status = lsa_getTrusteeCount(genMsg, file, &count); if (status != zOK) { - return status; + return status; } size = offsetof(zNW_metadata_s, nwm_trustee); size += (count * sizeof(zNW_trustee_s)); @@ -690,7 +674,7 @@ STATUS LSACOMN_Delete( mDoor_s *door; FileHandle_s *fh; Key_t key; - + typedef struct Stack_s { GeneralMsg_s genMsg; NamingMsg_s nameMsg; @@ -702,7 +686,7 @@ STATUS LSACOMN_Delete( { return zERR_INVALID_NAME; } - + STACK_ALLOC_NO_ASTACK(); key = userKey(current->fsuid); /* Should not have the MPK LOCK when calling @@ -780,7 +764,7 @@ STATUS LSACOMN_Rename( mDoor_s *door; FileHandle_s *fh; Key_t key; - + typedef struct Stack_s { GeneralMsg_s genMsg; NamingMsg_s srcNameMsg; @@ -793,7 +777,7 @@ STATUS LSACOMN_Rename( { return zERR_INVALID_NAME; } - + STACK_ALLOC_NO_ASTACK(); key = userKey(current->fsuid); /* Should not have the MPK LOCK when calling @@ -862,7 +846,7 @@ STATUS LSACOMN_Rename( COMN_STRUCT_INIT(aStack->renameMsg); COMN_SETUP_RENAME_MSG(&aStack->renameMsg, renameFlags); - status = COMN_Rename(&aStack->genMsg, &aStack->srcNameMsg, + status = COMN_Rename(&aStack->genMsg, &aStack->srcNameMsg, &aStack->dstNameMsg, &aStack->renameMsg); COMN_CleanupNameMsg(&aStack->genMsg, &aStack->srcNameMsg); @@ -893,13 +877,13 @@ STATUS LSACOMN_ModifyInfo( FileHandle_s *fh; Key_t key; zInfo_s *info = (zInfo_s *)modifyInfo; - + typedef struct Stack_s { GeneralMsg_s genMsg; NamingMsg_s nameMsg; ModifyInfoMsg_s infoMsg; } Stack_s; - + STACK_ALLOC(); key = userKey(current->fsuid); /* Should not have the MPK LOCK when calling @@ -942,12 +926,12 @@ STATUS LSACOMN_ModifyInfo( COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&aStack->nameMsg); COMN_STRUCT_INIT(aStack->infoMsg); - COMN_SETUP_MODIFY_TYPE_INFO_MSG(&aStack->infoMsg, modifyInfoMask, + COMN_SETUP_MODIFY_TYPE_INFO_MSG(&aStack->infoMsg, modifyInfoMask, info, modifyInfoMask, &info->vol); aStack->infoMsg.modifyFlags = MF_DONT_AUTO_SET_DELETE_RENAME_INHIBIT; info->infoVersion = infoVersion; - - status = COMN_ModifyInfo( &aStack->genMsg, &aStack->nameMsg, + + status = COMN_ModifyInfo( &aStack->genMsg, &aStack->nameMsg, &aStack->infoMsg ); if (status != zOK) { @@ -965,7 +949,6 @@ STATUS LSACOMN_ModifyInfo( -#ifndef NSS_USERSPACE #define SB_NUM_BUCKETS 17 #define SB_HASH(_vid) ((_vid)->timeLow % SB_NUM_BUCKETS) @@ -1126,7 +1109,7 @@ struct dentry *lsa_get_dentry (struct dentry *parent, const char *name) } #if 0 -void lsa_invalidate_inode ( Zid_t zid, Zid_t parentZid, VolumeID_t *volID) +void lsa_invalidate_inode ( Zid_t zid, Zid_t parentZid, VolumeID_t *volID) { struct inode *i_inode = NULL; struct inode *i_parent = NULL; @@ -1196,7 +1179,7 @@ exitLock: * in. If the child zid is passed in we are doing a delete and we delete * the dentry and reduce the nlink count for the inode of the child. */ -void lsa_invalidate_dentry ( LSAInvalidateDentry_s *lsaInv ) +void lsa_invalidate_dentry ( LSAInvalidateDentry_s *lsaInv ) { VolumeID_t *volID = &lsaInv->lid_volID; Zid_t zid = lsaInv->lid_zid; @@ -1229,7 +1212,7 @@ pr("lsa_invalidate_dentry"); MPKNSS_UNLOCK(); if (zid != zINVALID_ZID) - { + { /* We are deleting the dentry and not just invalidating it */ i_inode = ilookup(super->sb_super_block, zid); if (!i_inode) @@ -1505,7 +1488,7 @@ pr("lsa_enumerate"); !(dir->FILEvolume->VOLenabledAttributes & zATTR_READONLY)) { /* Make the Hardlink flags accurately reflect whether or not - * curFile is a hardlink beast. This does not need + * curFile is a hardlink beast. This does not need * to be part of a transaction. The data is considered "Messy" * meaning it doesn't matter if it makes it back to disk or not. * If the system crashes before it is flushed, it will just get @@ -1546,7 +1529,7 @@ pr("lsa_enumerate"); DOWN_LATCH(&dir->FILEbeastLatch); } - if ((info->miscFlags & (HL_FLAG_IS_VALID|HL_FLAG_IS_HARD_LINK)) == + if ((info->miscFlags & (HL_FLAG_IS_VALID|HL_FLAG_IS_HARD_LINK)) == (HL_FLAG_IS_VALID|HL_FLAG_IS_HARD_LINK)) { beast = COMN_LookupByZidWhileWildcarding( &genMsg, dir->FILEvolume, @@ -1564,7 +1547,7 @@ pr("lsa_enumerate"); } } - if ((workNameSpace->flags & NSFLforceLowerIfForcedUpper) && + if ((workNameSpace->flags & NSFLforceLowerIfForcedUpper) && (info->flagsAndLen & NAMEforcedUpper)) { unilwr(info->name); @@ -1582,7 +1565,7 @@ pr("lsa_enumerate"); goto exit_unlatch; } file->f_pos = cookie; - + MPKNSS_UNLOCK(); done = fillDirFunc(dirent, aStack->name, length, cookie, info->zid, @@ -1649,8 +1632,6 @@ exit_unlock: */ -#endif /* !NSS_USERSPACE */ - /************************************************************************** * BrowseUsers ***************************************************************************/ @@ -1688,3 +1669,5 @@ STATUS LSACOMN_BrowseUsers( MPKNSS_UNLOCK(); return GetErrno(&genMsg); } + + diff --git a/src/nwnss/lsa/lsaErr.c b/src/nwnss/lsa/lsaErr.c index ecca472..c672658 100644 --- a/src/nwnss/lsa/lsaErr.c +++ b/src/nwnss/lsa/lsaErr.c @@ -34,7 +34,8 @@ | This module is used to: | Tranlates from internal NSS errors in LNX errors. +-------------------------------------------------------------------------*/ -#include +#include +#include #include #include diff --git a/src/nwnss/lsa/lsaLKM.c b/src/nwnss/lsa/lsaLKM.c new file mode 100644 index 0000000..f518aba --- /dev/null +++ b/src/nwnss/lsa/lsaLKM.c @@ -0,0 +1,568 @@ +/**************************************************************************** + | + | (C) Copyright 1995 - 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2008-04-19 03:14:27 +0530 (Sat, 19 Apr 2008) $ + | + | $RCSfile$ + | $Revision: 2323 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Initialize the Linux Symantic Agent (LSA) + +-------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include +#include + +#include /* nss */ +#include +#include +#include /* nss */ +#include +#include +#include "comnBeasts.h" +#include "lsa.h" +#include "lsaStartup.h" +#include "zFriends.h" +#include "guid.h" + +extern int lsa_pool_fill_super( + struct super_block *sb, + void *data, + int isSilent); + +extern int lsa_vol_fill_super( + struct super_block *sb, + void *data, + int isSilent); + +extern int lsa_admin_fill_super( + struct super_block *sb, + void *data, + int isSilent); + + +void lsa_pool_kill_super (struct super_block *sb) +{ + LsaSuper_s *lsaSuper; + +PR(lsa_pool_kill_super); + kill_block_super(sb); + lsaSuper = sb->s_fs_info; + if (lsaSuper) + { + mpkEnter(); + free(lsaSuper); + mpkExit(); + } +} + +void lsa_vol_kill_super (struct super_block *sb) +{ + LsaSuper_s *lsaSuper; + +PR(lsa_vol_kill_super); +// kill_litter_super(sb); +// generic_shutdown_super(sb); + kill_anon_super(sb); + lsaSuper = sb->s_fs_info; + if (lsaSuper) + { + mpkEnter(); + free(lsaSuper); + mpkExit(); + } +} + +void lsa_admin_kill_super (struct super_block *sb) +{ + LsaSuper_s *lsaSuper; + +PR(lsa_admin_kill_super); + kill_anon_super(sb); + lsaSuper = sb->s_fs_info; + if (lsaSuper) + { + mpkEnter(); + free(lsaSuper); + mpkExit(); + } +} + +/* Pool FS Type */ +static struct super_block *lsa_pool_get_sb(struct file_system_type *fs_type, + int flags, const char *dev_name, void *data) +{ + return get_sb_bdev(fs_type, flags, dev_name, data, lsa_pool_fill_super); +} + +static struct file_system_type lsa_pool_fs_type = { + .owner = THIS_MODULE, + .name = "nsspool", + .get_sb = lsa_pool_get_sb, + .kill_sb = lsa_pool_kill_super, + .fs_flags = FS_REQUIRES_DEV, +}; + +static int lsa_set_super(struct super_block *sb, void *data) +{ + return set_anon_super(sb, NULL); +} + +static int lsa_test_super(struct super_block *sb, void *data) +{ + LsaSuper_s *lsa_sb = sb->s_fs_info; + VolumeID_t volID; + LONG volNameLen; + LONG dataNameLen; + typedef struct Stack_s { + unicode_t uniVolName[zMAX_COMPONENT_NAME+2]; + } Stack_s; + + if (sb->s_fs_info == NULL) + { + return FALSE; + } + /* lsa_sb->sb_volName has a :/ after the volName */ + /* data had vol name passed on the command line */ + volNameLen = strlen(lsa_sb->sb_volName); + volNameLen -= 2; + dataNameLen = strlen(data); + + /* Checking to see if the vol names match */ + if (volNameLen != dataNameLen) + { + return FALSE; + } + if (strnicmp(data, lsa_sb->sb_volName, volNameLen) != 0) + { + return FALSE; + } + /* There is a super structure with the vol name. Check to make sure + * that this volname does not belong to a deleted volume that could not + * be umounted cleanly + */ + { + STACK_ALLOC(); + if (utf2uni(data, aStack->uniVolName, sizeof(aStack->uniVolName)) != -1) + { + STACK_FREE(); + return FALSE; + } + if (xVolumeNameToGUID(aStack->uniVolName, &volID) != zOK) + { + STACK_FREE(); + return FALSE; + } + STACK_FREE(); + } + /* Compare the GUID stored in the super to the vol GUID to make sure they + * match + */ + if (LB_GUIDCompare(&volID, &lsa_sb->sb_volID) != 0) + { + return FALSE; + } + return TRUE; +} + +static struct super_block *lsa_get_sb_nodev(struct file_system_type *fs_type, + int flags, void *data, + int (*fill_super)(struct super_block *, void *, int)) +{ + int error; + struct super_block *sb; + typedef struct Stack_s { + char volName[zMAX_COMPONENT_NAME]; + } Stack_s; + Stack_s *aStack; + + mpkEnter(); + STACK_ALLOC_NO_ASTACK(); + + error = LSA_GetOptions(data, aStack->volName, zMAX_COMPONENT_NAME, NULL, NULL, NULL, NULL); + if (error) + { + sb = ERR_PTR(error); + goto out; + } + + sb = sget(fs_type, lsa_test_super, lsa_set_super, aStack->volName); + + if (IS_ERR(sb)) + { + goto out; + } + + if (sb->s_root) + { + if ((flags ^ sb->s_flags) & MS_RDONLY) + { + up_write(&sb->s_umount); + deactivate_super(sb); + sb = ERR_PTR(-EBUSY); + } + goto out; + } + + sb->s_flags = flags; + + error = fill_super(sb, data, flags & MS_VERBOSE ? 1 : 0); + if (error) + { + up_write(&sb->s_umount); + deactivate_super(sb); + sb = ERR_PTR(error); + goto out; + } + + sb->s_flags |= MS_ACTIVE; +out: + STACK_FREE(); + mpkExit(); + return sb; + +} + +/* Volume FS Type */ +static struct super_block *lsa_vol_get_sb(struct file_system_type *fs_type, + int flags, const char *dev_name, void *data) +{ + return lsa_get_sb_nodev(fs_type, flags, data, lsa_vol_fill_super); +// return get_sb_nodev(fs_type, flags, data, lsa_vol_fill_super); +} + +static struct file_system_type lsa_vol_fs_type = { + .owner = THIS_MODULE, + .name = "nssvol", + .get_sb = lsa_vol_get_sb, + .kill_sb = lsa_vol_kill_super, +// .kill_sb = kill_block_super, + .fs_flags = 0, +}; + +/* Admin FS Type */ +static struct super_block *lsa_admin_get_sb(struct file_system_type *fs_type, + int flags, const char *dev_name, void *data) +{ + /* Currently we do not have any options that we support for admin + * volume, so the data (command line) is ignored, and instead just the + * name "_ADMIN" is passed on in the data field + */ + return lsa_get_sb_nodev(fs_type, flags, "_ADMIN", lsa_admin_fill_super); +// return get_sb_nodev(fs_type, flags, data, lsa_admin_fill_super); +} + +static struct file_system_type lsa_admin_fs_type = { + .owner = THIS_MODULE, + .name = "nssadmin", + .get_sb = lsa_admin_get_sb, + .kill_sb = lsa_admin_kill_super, + .fs_flags = 0, +}; + +#if 0 +static const char *LSA_MainDirName = "nssLSA"; +static const char *LSA_CreatePool = "createPool"; + +static struct proc_dir_entry *LSA_MainProcDir = NULL; +static struct proc_dir_entry *LSA_CreatePoolFile = NULL; +#endif + +/*------------------------------------------------------------------------- + * Global variables + *-------------------------------------------------------------------------*/ +static LONG LSA_ModuleIsLoaded = 0; +#define LOADED_MAGIC 0x54494E4A + +struct LoadDefinitionStructure *LSA_ModuleHandle; +struct ScreenStruct *LSA_ConsoleScreen; + +char **NSSMessageTable; + +/*------------------------------------------------------------------------- + * Defines the name of this MODULE. + *-------------------------------------------------------------------------*/ +STATIC char myNLMName[] = MODULE_NAME; +const char Module[] = MODULE_NAME; + +/*------------------------------------------------------------------------- + * Defines the CallBacks for NSS + *-------------------------------------------------------------------------*/ +NSSRegistrationCallBacks_s LSA_CallBacks = {NLM_Startup, NULL}; + + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*------------------ START OF ROUTINES ------------------------------------*/ + +/*- (FUNCTION) ----- GenericStartRoutine() ---------------------------------- + | + | Load function for the NLM initialization process + | + +-------------------------------------------------------------------------*/ +LONG GenericStartRoutine( + void *handle) +{ + STATUS status; + + if ((status = lsa_init_inodecache()) != 0) + { + printk("<1> Error allocating slab for inodes\n"); + return status; + } + /*----------------------------------------------------------------------- + | Init global variables + +---------------------------------------------------------------------*/ + MPKNSS_LOCK(); + + LSA_ModuleHandle = handle; + + { + // sksmith - this version and copyright string are for the MSG file + char *ver = MSG("VeRsIoN=4.00 Novell Storage Services (NSS) Linux Symantic Agent",23); + char *copyR = MSG("CoPyRiGhT=(c) 2003-2004 Novell, Inc. All rights reserved.",24); + if (ver && copyR) + { + } + } + + /* + * Plug global function pointers + */ + Ptr_lsa_invalidate_dentry = lsa_invalidate_dentry; + Ptr_lsa_invalidate_vol = lsa_invalidate_vol; + Ptr_lsa_noatime = lsa_noatime; + Ptr_lsa_get_vol_namespace = lsa_get_vol_namespace; + Ptr_lsa_get_inode = lsa_get_inode; + + /*----------------------------------------------------------------------- + | Register with NSS and tell them we are HERE. + +---------------------------------------------------------------------*/ + status = NSS_RegisterExternalNLM( + myNLMName, + LSA_ModuleHandle, + NSSMessageTable, + NSSMODULETYPE_LSS, + NSSREGFLAG_REQUIRED, + &LSA_VersionInfo, + NSSAPI_VERSION, + NSS_SNAPDATE, + NSS_DEBUG_STATE, + NSS_MP_FLAG, + LSA_CommandLineSwitches, + &LSA_CallBacks); + + if(status != zOK) + { + status = zFAILURE; + goto GSRExit; + } + + LSA_ModuleIsLoaded = LOADED_MAGIC; + +GSRExit: + MPKNSS_UNLOCK(); + return(status); +} + + +/*- (FUNCTION) ----- GenericExitRoutine() ----------------------------------- + | + | This routine is called to UNLOAD the nlm + | + +-------------------------------------------------------------------------*/ +LONG GenericExitRoutine(void) +{ + MPKNSS_LOCK(); + + /* + * Clear global function pointers + */ + Ptr_lsa_invalidate_dentry = NULL; + Ptr_lsa_invalidate_vol = NULL; + Ptr_lsa_noatime = NULL; + Ptr_lsa_get_vol_namespace = NULL; + Ptr_lsa_get_inode = NULL; + + if(LSA_ModuleIsLoaded == LOADED_MAGIC) + { + NLM_Shutdown(); + NSS_UnRegisterExternalNLM(myNLMName); + } + + MPKNSS_UNLOCK(); + return zOK; +} + +#if 0 +void LSA_CreateProcEntries(void) +{ + LSA_MainProcDir = proc_mkdir(LSA_MainDirName, NULL); + + if (LSA_MainProcDir) + { + LSA_MainProcDir->owner = THIS_MODULE; + + LSA_CreatePoolFile = create_proc_entry( + LSA_CreatePool, + 0222, + LSA_MainProcDir); + if (LSA_CreatePoolFile) + { + LSA_CreatePoolFile->data = NULL; + LSA_CreatePoolFile->read_proc = NULL; + LSA_CreatePoolFile->write_proc = LSA_CreatePoolRequest; + LSA_CreatePoolFile->owner = THIS_MODULE; + + } + else + { + printk("<1>" "NSSLSA::%s[%d] Unable to create %s\n", + __FILE__, __LINE__, LSA_CreatePool); + } + } + else + { + printk("<1>" "NSSLSA::%s[%d] Unable to create %s\n", + __FILE__, __LINE__, LSA_MainDirName); + } +} + +void LSA_RemoveProcEntries(void) +{ + if (LSA_MainProcDir) + { + if (LSA_CreatePoolFile) + { + remove_proc_entry(LSA_CreatePool, LSA_MainProcDir); + } + + remove_proc_entry(LSA_MainDirName, NULL); + } +} +#endif + +void __cyg_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void __cyg_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); + + +void __cyg_profile_func_enter (void *this_fn, void *call_site) +{ + nss_profile_func_enter(this_fn, call_site); + return; +} + +void __cyg_profile_func_exit (void *this_fn, void *call_site) +{ + nss_profile_func_exit(this_fn, call_site); + return; +} + +int __init lsa_init (void) +{ + LONG rc; + + printk("<1>" "LSA::%s[%d]\n", __FILE__, __LINE__ ); + mpkEnter(); + rc = GenericStartRoutine( &init_module); + printk("<1>" "LSA::%s\n", WHERE); + mpkExit(); + if (rc != 0) + { + printk("<1>" "LSA::failed to initialize %d\n", rc); + return -ENOMEM; + } + rc = register_filesystem( &lsa_pool_fs_type); + if (rc != 0) + { + return rc; + } + rc = register_filesystem( &lsa_vol_fs_type); + if (rc != 0) + { + return rc; + } + rc = register_filesystem( &lsa_admin_fs_type); + if (rc != 0) + { + return rc; + } + +#if 0 + LSA_CreateProcEntries(); +#endif + + return 0; +} + + +void __exit lsa_exit (void) +{ + STATUS rc; + +#if 0 + LSA_RemoveProcEntries(); +#endif + + unregister_filesystem( &lsa_admin_fs_type); + unregister_filesystem( &lsa_vol_fs_type); + unregister_filesystem( &lsa_pool_fs_type); + + mpkEnter(); + printk("<1>" "LSA::%s[%d]\n", __FILE__, __LINE__ ); + rc = GenericExitRoutine(); + printk("<1>" "LSA::%s[%d]\n", __FILE__, __LINE__ ); + mpkExit(); +} + + +MODULE_AUTHOR("Novell, Inc."); +MODULE_DESCRIPTION("LSA"); +MODULE_LICENSE("GPL v2"); + + +module_init(lsa_init) +module_exit(lsa_exit) + + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + + diff --git a/src/nwnss/lsa/lsaModules.mk b/src/nwnss/lsa/lsaModules.mk new file mode 100644 index 0000000..d22d74f --- /dev/null +++ b/src/nwnss/lsa/lsaModules.mk @@ -0,0 +1,290 @@ +############################################################################## +# +# (C) Copyright 2003 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +########################################################################## +# This defines what MODULES are being built for this NLM +# +# $Author: ghorlacher $ +# $Date: 2007-09-13 03:51:53 +0530 (Thu, 13 Sep 2007) $ +# +# $RCSfile$ +# $Revision: 2206 $ +# +########################################################################## +MODULE_VERSION=15 + +#------------------------------------------------------------------------- +# If the version number is not defined here, the general product version +# number will be used (defined in bldVersion.bld) +# +# major version 1 to 99 +# minor version 1 to 99 +# sub version 1 to 26 +#------------------------------------------------------------------------- +#MAJOR_VERSION= +#MINOR_VERSION= +#SUB_VERSION= + +#------------------------------------------------------------------------- +# Build OPTIONS +#------------------------------------------------------------------------- + +BUILD_WITH_KERNEL_FLAGS=1 + +#set to 0 if you are NOT using source code control +IS_USING_SOURCE_CONTROL=1 + +#Set to ONE if you want the linked files to be copied to the SDK/BIN directory. +COPY_TO_SDK_BIN=1 + + #set to ONE if you only want to copy the OPTIMIZED version to SDK/BIN. + COPY_OPTIMIZED_ONLY=0 + +#Set this to ONE if you are building a NETWARE version independent NLM +#(not NETWARE version specific) +NETWARE_VERSION_INDEPENDENT=1 + + #if ONE include the NETWARE .H files in the compiler search paths. + USE_NETWARE_INCLUDES=1 + + #if ONE include the NETWARE import file at LINK time + USE_NETWARE_IMPORTS=1 + +#If ONE IMPORT the LIBNSS APIs and include in the search path SDK/LIBRARY +#and SDK/PUBLIC +IMPORT_INDEPENDENT_LIBNSS=1 + +#If ONE include in the search path SDK/LIBRARY and SDK/PUBLIC +USE_LIBNSS_INCLUDES=1 + +#If ONE then LINK with the NSS library and include all of the NSS library +#directories in the compiler search paths. This includes the SDK/PUBLIC, +#SDK/INCLUDE, SDK/INTERNAL, LIBRARY/SRC directories. +LINK_WITH_NSSLIB=0 + +#if ONE then IMPORT the NSS library and COMN layer APIS and include the +#SDK/PUBLIC directory in the compiler search paths. +IMPORT_NSSLIB=1 + + #If ONE and (LINK_WITH_NSSLIB==1 or IMPORT_NSSLIB==1) then do the same + #operation to the NSSLIB area you are doing to the local area. + CHECK_NSSLIB=0 + + #If ONE and (CHECK_NSSLIB==1) then we will clean the NSSLIB area when we + #clean the local area. + CLEAN_NSSLIB=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INCLUDE directory in + #the compiler search paths + USE_NSS_SDK_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/COMNSA directory in + #the compiler search paths + USE_NSS_SDK_COMNSA_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INTERNAL directory in + #the compiler search paths + USE_NSS_SDK_INTERNAL_INCLUDES=1 + +#if ONE then do NOT import the NSS COMMON layer APIs +DONT_IMPORT_COMMON_LAYER=0 + +#if ONE, compile and link with the NETWARE sdk environment. +USE_NETWARE_SDK=0 + +#if ONE, include DS headers. +USE_NDS_INCLUDES=1 + +#if ONE, do LANGUAGE ENABLING processing +DO_LANGUAGE_ENABLING=0 + +#Set to null (i.e. no value) to not add XDC data to the NLM. For most +#NetWare 5.0 NLMs, the value should be -u. +MOAB_XDC_TOOL_OPTION=-n + +#************************************************************************* +# List of source directories for NSS +#************************************************************************* +SOURCE_DIRECTORIES= + +#************************************************************************* +# Source Modules for NSS (.C .386) +#************************************************************************* +SOURCE_FILES=\ + lsa.c \ + lsaCmdline.c \ + lsaErr.c \ + lsaLKM.c \ + lsaStartup.c \ + lsaSuper.c \ + lsaSuperPool.c \ + lsaSuperVol.c \ + lsaVersion.c \ + lsaUser.c \ + lsaXattr.c \ + lsaComn.c \ + lsaNSSKR.c + +SOURCE_FILES_NODEBUG= + +#************************************************************************* +# Source Include files for NSS (.H .inc) +#************************************************************************* +INCLUDE_FILES=\ + lsa.h \ + lsaAid.h \ + lsaStartup.h + + +#------------------------------------------------------------------------- +# Additional source files that need to be checked out +#------------------------------------------------------------------------- +OTHER_FILES=\ + Module.supported + +#------------------------------------------------------------------------- +# This defines what routines are being EXPORTED. You should put .IMP +# files in the "UTILITY_EXPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_EXPORTS= + + +#UTILITY_EXPORTS_VIA_FILE= +UTILITY_EXPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# This defines what routines are being IMPORTED. You should put .IMP +# files in the "UTILITY_IMPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_IMPORTS= + +UTILITY_IMPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# Library definitions +# This defines additional libraries to LINK with and additional +# directories to put on out INCLUDE path. +#------------------------------------------------------------------------- +#additional libraries to link with +EXTRA_LIBRARIES= +EXTRA_STATIC_LIBRARIES= +EXTRA_DYNAMIC_LIBRARIES= +EXTRA_LIBRARY_INCLPATH= + +#------------------------------------------------------------------------- +# Include path +# This defines additional include path to compile with +#------------------------------------------------------------------------- +#additional include path +EXTRA_INCLUDE_PATH= + + +#------------------------------------------------------------------------- +# Additional C and ASSEMBLY options to use +#------------------------------------------------------------------------- +EXTRA_C_OPTIONS= +EXTRA_ASM_OPTIONS= +EXTRA_LINK_OPTIONS= + +#------------------------------------------------------------------------- +# Additional module attributes +#------------------------------------------------------------------------- +MODULE_DESCRIPTION='NSS Media Access Layer (LSA)' +MODULE_ADDITIONAL_COPYRIGHT= +MODULE_OPTIONS= +MODULE_DEPENDENCIES= +MODULE_TYPE= +MODULE_NAME=nsslsa +MODULE_EXTENSION= +MODULE_START_ROUTINE= +MODULE_EXIT_ROUTINE= +#set to 1 if you want the optimized NLM to be packed +MODULE_PACK_NLM=1 + +#========================================================================= +#========================================================================= +# LOCAL BUILD RULES +#========================================================================= +#========================================================================= + +#------------------------------------------------------------------------- +# Default BUILD rule +#------------------------------------------------------------------------- +DEFAULT: DEFAULT_BUILD + +#------------------------------------------------------------------------- +# Additional rules +#------------------------------------------------------------------------- + +#BUILD_GREENRIVER_OPT: +# @echo "...This NLM does not have an OPTIMIZED GREENRIVER specific version" + +#BUILD_GREENRIVER_UNOPT: +# @echo "...This NLM does not have an UNOPTIMIZED GREENRIVER specific version" + +BUILD_MOAB_MP_UNOPT: \ + COMPILE_UNOPT_MP_MOAB \ + LINK_UNOPT_MP_MOAB + +BUILD_MOAB_MP_OPT: \ + COMPILE_OPT_MP_MOAB \ + LINK_OPT_MP_MOAB + +BUILD_MOAB_SP_UNOPT: + @echo "...This NLM does not have an UNOPTIMIZED SP specific version" + +BUILD_MOAB_SP_OPT: + @echo "...This NLM does not have an OPTIMIZED SP specific version" + + +#BUILD_MOAB_SP_UNOPT: \ +# COMPILE_UNOPT_SP_MOAB \ +# LINK_UNOPT_SP_MOAB +# +#BUILD_MOAB_SP_OPT: \ +# COMPILE_OPT_SP_MOAB \ +# LINK_OPT_SP_MOAB + + +#------------------------------------------------------------------------- +# Language Enabling rules +#------------------------------------------------------------------------- +mdb: \ + DEFAULT_MDB + +umdb: \ + LOCAL_MDB + +mdbcreate: \ + DEFAULT_CREATE_MDB_FILE + +#------------------------------------------------------------------------- +# Other rules +#------------------------------------------------------------------------- +deps: DEFAULT_DEPS + +cscope: DEFAULT_CSCOPE + diff --git a/src/nwnss/lsa/lsaNSSKR.c b/src/nwnss/lsa/lsaNSSKR.c new file mode 100644 index 0000000..73a4b08 --- /dev/null +++ b/src/nwnss/lsa/lsaNSSKR.c @@ -0,0 +1,1009 @@ +/**************************************************************************** + | + | (C) Copyright 2004 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: ajack $ + | $Date: 2006-12-14 21:27:33 +0530 (Thu, 14 Dec 2006) $ + | + | $RCSfile$ + | $Revision: 1768 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Make kernel calls available to nssulib + +-------------------------------------------------------------------------*/ +//#include +#include + +#define _LOOSE_KERNEL_NAMES + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // zPoolVerify prototype + +/* in authorize.c: */ +extern SNINT COMN_FindAuthModelByName(utf8_t *name); + + +/**************************************************************************** + * + * MapClusterSoftwareIsCheckingPoolStateChanges + * + ****************************************************************************/ + +STATUS MapClusterSoftwareIsCheckingPoolStateChanges( + nsskr_ClusterSoftwareIsChecking_t *request) +{ + request->result = COMN_ClusterSoftwareIsCheckingPoolStateChanges(); + return zOK; +} + +/**************************************************************************** + * + * MapFindAuthModelByName + * + ****************************************************************************/ + +STATUS MapFindAuthModelByName(nsskr_FindAuthModelByName_t *request) +{ + request->result = COMN_FindAuthModelByName(request->name); + return zOK; +} + +/**************************************************************************** + * + * MapGetRegisteredLSSFeatures + * + ****************************************************************************/ + +STATUS MapGetRegisteredLSSFeatures(nsskr_GetRegisteredLSSFeatures_t *request) +{ + GeneralMsg_s genMsg; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + request->rc = COMN_GetRegisteredLSSFeatures(&genMsg, + &request->numberOfLSSs, + request->buffer, + request->bufSize); + if (request->rc != zOK) + { + request->error_num = GetErrno(&genMsg); + } + return zOK; +} + +/**************************************************************************** + * + * MapGUIDGenerate + * + ****************************************************************************/ + +STATUS MapGUIDGenerate(nsskr_GUIDGenerate_t *request) +{ + LB_GUIDGenerate(&request->guid); + return zOK; +} + +/**************************************************************************** + * + * MapVolumeNameAcceptable + * + ****************************************************************************/ + +STATUS MapVolumeNameAcceptable(nsskr_VolumeNameAcceptable_t *request) +{ + request->status = LB_VolumeNameAcceptable(request->uniVolName); + return zOK; +} + +/**************************************************************************** + * + * MapVolumeNameValid + * + ****************************************************************************/ + +STATUS MapVolumeNameValid(nsskr_VolumeNameValid_t *request) +{ + request->status = LB_VolumeNameValid(request->uniVolName); + return zOK; +} + +/**************************************************************************** + * + * MapPoolNameAcceptable + * + ****************************************************************************/ + +STATUS MapPoolNameAcceptable(nsskr_PoolNameAcceptable_t *request) +{ + request->status = LB_PoolNameAcceptable(request->uniPoolName); + return zOK; +} + +/**************************************************************************** + * + * MapGetAuthModelID + * + ****************************************************************************/ + +STATUS MapGetAuthModelID(nsskr_GetAuthModelID_t *request) +{ + request->id = GetAuthModelID(request->name); + return zOK; +} + +/**************************************************************************** + * + * MapCreateVolumeInPool + * + ****************************************************************************/ + +STATUS MapCreateVolumeInPool(nsskr_CreateVolumeInPool_t *request) +{ + unicode_t *password = NULL; + + /* Make it so we only pass non-NULL password if it contains valid data. + * First, we check the length, because the old version of this structure + * did not include space for a password. If an old version of manageus + * is running, it will pass a shorter structure with no password. + * Second, Only pass the pointer if the password contains non-zero data. + */ + if (request->len >= sizeof(nsskr_CreateVolumeInPool_t)) + { + if (unilen(&(request->uniPassword[0])) > 0) + { + password = request->uniPassword; + } + } + + request->status = CreateVolumeInPool(request->uniPoolName, + request->uniVolName, + request->authModelID, + request->volumeGUID, + password, + &request->isClustered, + &request->errIndex); + return zOK; +} + +/**************************************************************************** + * + * MapSetNDSInfoOnVolume + * + ****************************************************************************/ + +STATUS MapSetNDSInfoOnVolume(nsskr_SetNDSInfoOnVolume_t *request) +{ + request->status = SetNDSInfoOnVolume(request->uniVolName, + &request->info, + request->lock, + request->onlineOnly); + return zOK; +} + +/**************************************************************************** + * + * MapSetNDSInfoOnPool + * + ****************************************************************************/ + +STATUS MapSetNDSInfoOnPool(nsskr_SetNDSInfoOnPool_t *request) +{ + request->status = SetNDSInfoOnPool(request->uniPoolName, &request->info); + return zOK; +} + +/**************************************************************************** + * + * MapModifyVolumeAttributes + * + ****************************************************************************/ + +STATUS MapModifyVolumeAttributes(nsskr_ModifyVolumeAttributes_t *request) +{ + request->status = ModifyVolumeAttributes(request->uniVolName, + request->modifyInfoMask, + &request->info, + request->readAhead, + &request->errIndex); + + return zOK; +} + +/**************************************************************************** + * + * MapGetNSSVolumeHostPool + * + ****************************************************************************/ + +STATUS MapGetNSSVolumeHostPool(nsskr_GetNSSVolumeHostPool_t *request) +{ + request->status = GetNSSVolumeHostPool(request->volumeName, + request->poolName); + + return zOK; +} + +/**************************************************************************** + * + * MapGetDeletedVolumeLSSInfo + * + ****************************************************************************/ + +STATUS MapGetDeletedVolumeLSSInfo(nsskr_GetDeletedVolumeLSSInfo_t *request) +{ + request->status = GetDeletedVolumeLSSInfo(request->volumeName, + request->uniVolName, + request->buf, + request->bufLen, + &request->retLen); + + return zOK; +} + +/**************************************************************************** + * + * MapZPoolVerify + * Pull items out of ioctl 'message' and pass to actual zPoolVerify. + * + ****************************************************************************/ + +STATUS MapZPoolVerify(nsskr_ZPoolVerify_t *request) +{ + request->NZPV_Status = zPoolVerify(request->NZPV_Action, + request->NZPV_BufferSize, + request->NZPV_Buffer ); + + return zOK; +} + +/**************************************************************************** + * + * MapNSSVolumeFound + * + ****************************************************************************/ + +STATUS MapNSSVolumeFound(nsskr_NSSVolumeFound_t *request) +{ + request->status = NSSVolumeFound(request->uniVolName, + request->include_internal, + &request->isDeleted, + &request->readAhead, + &request->volumeState, + request->authModelName, + &request->volNameGUID); + + return zOK; +} + +/**************************************************************************** + * + * MapGetZInfo + * + ****************************************************************************/ + +STATUS MapGetZInfo(nsskr_GetZInfo_t *request) +{ + request->status = GetZInfo(request->path, + request->getInfoMask, + &request->info, + &request->errIndex); + + return zOK; +} + +/**************************************************************************** + * + * MapRemoveNSSVolume + * + ****************************************************************************/ + +STATUS MapRemoveNSSVolume(nsskr_RemoveNSSVolume_t *request) +{ + request->status = RemoveNSSVolume(request->uniVolName); + + return zOK; +} + +/**************************************************************************** + * + * MapRenameNSSVolume + * + ****************************************************************************/ + +STATUS MapRenameNSSVolume(nsskr_RenameNSSVolume_t *request) +{ + request->status = RenameNSSVolume(request->uniVolName, request->uniNewName); + + return zOK; +} + +/**************************************************************************** + * + * MapChangeVolumeState + * + ****************************************************************************/ + +STATUS MapChangeVolumeState(nsskr_ChangeVolumeState_t *request) +{ + request->status = ChangeVolumeState(request->uniVolName, + request->activateVolume, + request->volumePassword, + &request->errIndex); + + return zOK; +} + +/**************************************************************************** + * + * MapPerformDeletedVolAction + * + ****************************************************************************/ + +STATUS MapPerformDeletedVolAction(nsskr_PerformDeletedVolAction_t *request) +{ + request->status = PerformDeletedVolumeAction(request->uniVolName, + request->action); + + return zOK; +} + +/**************************************************************************** + * + * MapRenameSalvagedVolume + * + ****************************************************************************/ + +STATUS MapRenameSalvagedVolume(nsskr_RenameSalvagedVolume_t *request) +{ + request->status = RenameSalvagedVolume(request->uniVolName, + request->uniNewName, + &request->state); + + return zOK; +} + +/**************************************************************************** + * + * MapRemoveUserFromIDStore + * + ****************************************************************************/ + +STATUS MapRemoveUserFromIDStore(nsskr_RemoveUserFromIDStore_t *request) +{ + request->status = RemoveUserFromIDStore(request->uniVolName, + &request->userID, + &request->errIndex); + + return zOK; +} + +/**************************************************************************** + * + * MapGetNextVolumeName + * + ****************************************************************************/ + +STATUS MapGetNextVolumeName(nsskr_GetNextVolumeName_t *request) +{ + request->status = GetNextVolumeName(request->firstTime, + &request->cookie, + request->uniVolName, + request->uniNameLen, + &request->isLogical); + + return zOK; +} + +/**************************************************************************** + * + * MapUTCTime2Str + * + ****************************************************************************/ + +STATUS MapUTCTime2Str(nsskr_UTCTime2Str_t *request) +{ + (void) UTCTime2Str(request->utcTime, request->str); + + return zOK; +} + +/**************************************************************************** + * + * MapCheckVolumesPool + * + ****************************************************************************/ + +STATUS MapCheckVolumesPool(nsskr_CheckVolumesPool_t *request) +{ + MPKNSS_UNLOCK(); + request->status = MNDS_CheckVolumesPool(request->volName, + request->poolName, + &request->matchedPool); + MPKNSS_LOCK(); + + return zOK; +} + +/**************************************************************************** + * + * MapDoesPoolExist + * + ****************************************************************************/ + +STATUS MapDoesPoolExist(nsskr_DoesPoolExist_t *request) +{ + request->status = DoesPoolExist(request->poolName, + &request->poolID, + &request->ndsID); + + return zOK; +} + +/**************************************************************************** + * + * MapDoesVolumeExist + * + ****************************************************************************/ + +STATUS MapDoesVolumeExist(nsskr_DoesVolumeExist_t *request) +{ + request->status = DoesVolumeExist(request->volName); + + return zOK; +} + + +/**************************************************************************** + * + * MapGetPoolLSSType + * + ****************************************************************************/ + +STATUS MapGetPoolLSSType(nsskr_GetPoolLSSType_t *request) +{ + request->LSStype = GetPoolLSSType(request->uniPoolName); + + return zOK; +} + + +/**************************************************************************** + * + * MapChangePoolState + * + ****************************************************************************/ + +STATUS MapChangePoolState(nsskr_ChangePoolState_t *request) +{ + request->status = ChangePoolState(request->uniPoolName, + request->newPoolState, + request->mode); + + return zOK; +} + + +/**************************************************************************** + * + * MapGetPoolState + * + ****************************************************************************/ + +STATUS MapGetPoolState(nsskr_GetPoolState_t *request) +{ + request->poolState = GetPoolState(request->uniPoolName); + + return zOK; +} + + +/**************************************************************************** + * + * MapGetNextPoolName + * + ****************************************************************************/ + +STATUS MapGetNextPoolName(nsskr_GetNextPoolName_t *request) +{ + request->status = GetNextPoolName(request->firstTime, + &request->cookie, + request->uniPoolName, + request->uniNameLen, + request->noSnapshot, + &request->poolState, + &request->isShared, + &request->enabledAttr); + + return zOK; +} + +/**************************************************************************** + * + * MapGetNextVolumeInfo + * + ****************************************************************************/ + +STATUS MapGetNextVolumeInfo(nsskr_GetNextVolumeInfo_t *request) +{ + request->status = GetNextVolumeInfo(request->uniPoolName, + request->firstTime, + request->deletedVolume, + &request->cookie, + request->uniVolName, + request->uniVolNameLen); + + return zOK; +} + + +/**************************************************************************** + * + * MapGetLSSFeatures + * + ****************************************************************************/ + +STATUS MapGetLSSFeatures(nsskr_GetLSSFeatures_t *request) +{ + request->status = GetLSSFeatures(request->lssID, + &request->volSupportedFeatures, + &request->volDefaultEnabledFeatures, + &request->volChangableFeatures); + return zOK; +} + + +/**************************************************************************** + * + * MapGetPoolID + * + ****************************************************************************/ + +STATUS MapGetPoolID(nsskr_GetPoolID_t *request) +{ + request->status = GetPoolID(request->uniPoolName, &request->poolID); + + return zOK; +} + +/**************************************************************************** + * + * MapGetNextUserInVolume + * + ****************************************************************************/ + +STATUS MapGetNextUserInVolume(nsskr_GetNextUserInVolume_t *request) +{ + request->status = GetNextUserInVolume(request->uniVolName, + &request->lastUser, + &request->restrictionAmount, + &request->usedAmount, + &request->numEntries); + + return zOK; +} + +/**************************************************************************** + * + * MapSetUserSpaceRestriction + * + ****************************************************************************/ + +STATUS MapSetUserSpaceRestriction(nsskr_SetUserSpaceRestriction_t *request) +{ + request->status = SetUserSpaceRestriction(request->uniVolName, + request->userGUID, + request->quota); + + return zOK; +} + +/**************************************************************************** + * + * MapGetUserSpaceRestriction + * + ****************************************************************************/ + +STATUS MapGetUserSpaceRestriction(nsskr_GetUserSpaceRestriction_t *request) +{ + request->status = GetUserSpaceRestriction(request->uniVolName, + request->userGUID, + &request->usedAmount, + &request->restrictionAmount); + + return zOK; +} + +/**************************************************************************** + * + * MapBrowseBeastsInVolume + * + ****************************************************************************/ + +STATUS MapBrowseBeastsInVolume(nsskr_BrowseBeastsInVolume_t *request) +{ + GeneralMsg_s genMsg; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + request->status = COMN_BrowseBeastsInVolume(&genMsg, + request->uniVolName, + request->onlineOnly, + request->selectionCriteria, + request->numBeastsRequested, + &request->lastZidReturned, + (Zid_t *)request->zidsBuffer, + &request->numBeastsReturned); + + if (request->status != zOK) + { + request->status = GetErrno(&genMsg); + } + return zOK; +} + +/**************************************************************************** + * + * MapGetBeastInfoXML + * + ****************************************************************************/ + +STATUS MapGetBeastInfoXML(nsskr_GetBeastInfo_t *request) +{ + GeneralMsg_s genMsg; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + request->status = COMN_GetBeastInfoXML(&genMsg, + request->uniVolName, + request->onlineOnly, + request->getCompBeastInfo, + request->zid, + request->typeOfInfo, + &request->bufLen, + request->buffer); + + if (request->status != zOK) + { + request->status = GetErrno(&genMsg); + } + return zOK; +} + +/**************************************************************************** + * + * MapSetBeastInfoXML + * + ****************************************************************************/ + +STATUS MapSetBeastInfoXML(nsskr_SetBeastInfo_t *request) +{ + GeneralMsg_s genMsg; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + request->status = COMN_SetBeastInfoXML(&genMsg, + request->uniVolName, + request->onlineOnly, + request->zid, + request->ignoreOpenFile, + request->oldDataMatch, + request->bufLen, + request->buffer); + + if (request->status != zOK) + { + request->status = GetErrno(&genMsg); + } + return zOK; +} + + +/**************************************************************************** + * + * MapDeleteBeast + * + ****************************************************************************/ + +STATUS MapDeleteBeast(nsskr_DeleteBeast_t *request) +{ + GeneralMsg_s genMsg; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + request->status = COMN_DeleteBeast(&genMsg, + request->uniVolName, + request->onlineOnly, + request->zid); + + if (request->status != zOK) + { + request->status = GetErrno(&genMsg); + } + return zOK; +} + +/**************************************************************************** + * + * MapGetBeastFullName + * + ****************************************************************************/ + +STATUS MapGetBeastFullName(nsskr_GetBeastFullName_t *request) +{ + GeneralMsg_s genMsg; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + request->status = COMN_GetBeastFullName(&genMsg, + request->uniVolName, + request->onlineOnly, + request->zid, + request->nameSpaceID, + request->buffer, + request->bufLen); + + if (request->status != zOK) + { + request->status = GetErrno(&genMsg); + } + return zOK; +} + +/**************************************************************************** + * + * MapFixVolumeCompStats + * + ****************************************************************************/ + +STATUS MapFixVolumeCompStats(nsskr_FixVolumeCompStats_t *request) +{ + GeneralMsg_s genMsg; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + request->status = COMN_FixVolumeCompStats(&genMsg, + request->uniVolName); + + if (request->status != zOK) + { + request->status = GetErrno(&genMsg); + } + return zOK; +} + +/**************************************************************************** + * + * LSA_process_mapped_request + * This function makes a kernel function call on behalf of a user process. + * We got here through lsa_ioctl - The user process issues an ioctl to the + * _admin volume. + * + ****************************************************************************/ + +STATUS LSA_process_mapped_request(nsskr_generic_t *request) +{ + STATUS status; + + MPKNSS_LOCK(); + switch(request->opcode) + { + case NSSKR_NOP: + status = zOK; + break; + + case NSSKR_ClusterSoftwareIsCheckingPoolStateChanges: + status = MapClusterSoftwareIsCheckingPoolStateChanges( + (nsskr_ClusterSoftwareIsChecking_t *) request); + break; + + case NSSKR_FindAuthModelByName: + status = MapFindAuthModelByName((nsskr_FindAuthModelByName_t *) request); + break; + + case NSSKR_GUIDGenerate: + status = MapGUIDGenerate((nsskr_GUIDGenerate_t *) request); + break; + + case NSSKR_VolumeNameAcceptable: + status = MapVolumeNameAcceptable((nsskr_VolumeNameAcceptable_t *) request); + break; + + case NSSKR_VolumeNameValid: + status = MapVolumeNameValid((nsskr_VolumeNameValid_t *) request); + break; + + case NSSKR_PoolNameAcceptable: + status = MapPoolNameAcceptable((nsskr_PoolNameAcceptable_t *) request); + break; + + case NSSKR_GetAuthModelID: + status = MapGetAuthModelID((nsskr_GetAuthModelID_t *) request); + break; + + case NSSKR_CreateVolumeInPool: + status = MapCreateVolumeInPool((nsskr_CreateVolumeInPool_t *) request); + break; + + case NSSKR_SetNDSInfoOnVolume: + status = MapSetNDSInfoOnVolume((nsskr_SetNDSInfoOnVolume_t *) request); + break; + + case NSSKR_SetNDSInfoOnPool: + status = MapSetNDSInfoOnPool((nsskr_SetNDSInfoOnPool_t *) request); + break; + + case NSSKR_ModifyVolumeAttributes: + status = MapModifyVolumeAttributes((nsskr_ModifyVolumeAttributes_t *) request); + break; + + case NSSKR_GetNSSVolumeHostPool: + status = MapGetNSSVolumeHostPool((nsskr_GetNSSVolumeHostPool_t *) request); + break; + + case NSSKR_GetDeletedVolumeLSSInfo: + status = MapGetDeletedVolumeLSSInfo((nsskr_GetDeletedVolumeLSSInfo_t *) request); + break; + + case NSSKR_ZPoolVerify: + status = MapZPoolVerify((nsskr_ZPoolVerify_t *) request); + break; + + case NSSKR_NSSVolumeFound: + status = MapNSSVolumeFound((nsskr_NSSVolumeFound_t *) request); + break; + + case NSSKR_GetZInfo: + status = MapGetZInfo((nsskr_GetZInfo_t *) request); + break; + + case NSSKR_RemoveNSSVolume: + status = MapRemoveNSSVolume((nsskr_RemoveNSSVolume_t *) request); + break; + + case NSSKR_RenameNSSVolume: + status = MapRenameNSSVolume((nsskr_RenameNSSVolume_t *) request); + break; + + case NSSKR_ChangeVolumeState: + status = MapChangeVolumeState((nsskr_ChangeVolumeState_t *) request); + break; + + case NSSKR_PerformDeletedVolAction: + status = MapPerformDeletedVolAction((nsskr_PerformDeletedVolAction_t *) request); + break; + + case NSSKR_RenameSalvagedVolume: + status = MapRenameSalvagedVolume((nsskr_RenameSalvagedVolume_t *) request); + break; + + case NSSKR_RemoveUserFromIDStore: + status = MapRemoveUserFromIDStore((nsskr_RemoveUserFromIDStore_t *) request); + break; + + case NSSKR_GetNextVolumeName: + status = MapGetNextVolumeName((nsskr_GetNextVolumeName_t *) request); + break; + + case NSSKR_UTCTime2Str: + status = MapUTCTime2Str((nsskr_UTCTime2Str_t *) request); + break; + + case NSSKR_CheckVolumesPool: + status = MapCheckVolumesPool((nsskr_CheckVolumesPool_t *) request); + break; + + case NSSKR_DoesPoolExist: + status = MapDoesPoolExist((nsskr_DoesPoolExist_t *) request); + break; + + case NSSKR_DoesVolumeExist: + status = MapDoesVolumeExist((nsskr_DoesVolumeExist_t *) request); + break; + + case NSSKR_GetPoolLSSType: + status = MapGetPoolLSSType((nsskr_GetPoolLSSType_t *) request); + break; + + case NSSKR_ChangePoolState: + status = MapChangePoolState((nsskr_ChangePoolState_t *) request); + break; + + case NSSKR_GetPoolState: + status = MapGetPoolState((nsskr_GetPoolState_t *) request); + break; + + case NSSKR_GetNextPoolName: + status = MapGetNextPoolName((nsskr_GetNextPoolName_t *) request); + break; + + case NSSKR_GetNextVolumeInfo: + status = MapGetNextVolumeInfo((nsskr_GetNextVolumeInfo_t *) request); + break; + + + case NSSKR_GetLSSFeatures: + status = MapGetLSSFeatures((nsskr_GetLSSFeatures_t *) request); + break; + + case NSSKR_GetPoolID: + status = MapGetPoolID((nsskr_GetPoolID_t *) request); + break; + + case NSSKR_GetNextUserInVolume: + status = MapGetNextUserInVolume((nsskr_GetNextUserInVolume_t *) request); + break; + + case NSSKR_SetUserSpaceRestriction: + status = MapSetUserSpaceRestriction((nsskr_SetUserSpaceRestriction_t *) request); + break; + + case NSSKR_GetUserSpaceRestriction: + status = MapGetUserSpaceRestriction((nsskr_GetUserSpaceRestriction_t *) request); + break; + + case NSSKR_BrowseBeastsInVolume: + status = MapBrowseBeastsInVolume((nsskr_BrowseBeastsInVolume_t *) request); + break; + + case NSSKR_GetBeastInfo: + status = MapGetBeastInfoXML((nsskr_GetBeastInfo_t *) request); + break; + + case NSSKR_SetBeastInfo: + status = MapSetBeastInfoXML((nsskr_SetBeastInfo_t *) request); + break; + + case NSSKR_DeleteBeast: + status = MapDeleteBeast((nsskr_DeleteBeast_t *) request); + break; + + case NSSKR_GetBeastFullName: + status = MapGetBeastFullName((nsskr_GetBeastFullName_t *) request); + break; + + case NSSKR_FixVolumeCompStats: + status = MapFixVolumeCompStats((nsskr_FixVolumeCompStats_t *) request); + break; + + default: + status = zERR_NOT_SUPPORTED; + break; + } + MPKNSS_UNLOCK(); + return status; +} + diff --git a/include/nwnss/lsa/lsaPrivate.h b/src/nwnss/lsa/lsaPrivate.h similarity index 98% rename from include/nwnss/lsa/lsaPrivate.h rename to src/nwnss/lsa/lsaPrivate.h index 802b248..e390bdc 100644 --- a/include/nwnss/lsa/lsaPrivate.h +++ b/src/nwnss/lsa/lsaPrivate.h @@ -39,10 +39,6 @@ #ifndef _LSAPRIVATE_H_ #define _LSAPRIVATE_H_ 1 -#include - -struct dentry; - extern BOOL LSASendfile; extern BOOL LSACtimeIsMetadataModTime; extern BOOL LSAReturnNWmetadata; diff --git a/src/nwnss/lsa/lsaStartup.c b/src/nwnss/lsa/lsaStartup.c new file mode 100644 index 0000000..4eaa75c --- /dev/null +++ b/src/nwnss/lsa/lsaStartup.c @@ -0,0 +1,59 @@ +/**************************************************************************** + | + | (C) Copyright 1995 - 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-03-08 03:54:02 +0530 (Tue, 08 Mar 2005) $ + | + | $RCSfile$ + | $Revision: 836 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Initialize LSA + | + +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include "lsaStartup.h" +#include "lsa.h" + +STATUS NLM_Startup(void) +{ + ASSERT_MPKNSS_LOCK(); + if(LSA_Startup() != zOK) + { + return zFAILURE; + } + return zOK; +} + +void NLM_Shutdown(void) +{ + LSA_Shutdown(); + return; +} diff --git a/include/nwnss/lsa/lsaStartup.h b/src/nwnss/lsa/lsaStartup.h similarity index 100% rename from include/nwnss/lsa/lsaStartup.h rename to src/nwnss/lsa/lsaStartup.h diff --git a/src/nwnss/lsa/lsaSuper.c b/src/nwnss/lsa/lsaSuper.c new file mode 100644 index 0000000..b79e11f --- /dev/null +++ b/src/nwnss/lsa/lsaSuper.c @@ -0,0 +1,2631 @@ +/**************************************************************************** + | + | (C) Copyright 1995 - 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2008-05-08 21:52:15 +0530 (Thu, 08 May 2008) $ + | + | $RCSfile$ + | $Revision: 2335 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | super block operations for LSA + +-------------------------------------------------------------------------*/ +//#include +#include + +#define _LOOSE_KERNEL_NAMES + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include + +BOOL LSASendfile = TRUE; +BOOL LSACtimeIsMetadataModTime = TRUE; +BOOL LSAUpdateDirAccessTime = TRUE; +LONG LSAPosixPermissionMask = 0777; + +/* DFS federated name prefixes. By definition, these MUST be lower-case */ +#define LINK_PREFIX "/../" +#define JUNCTION_PREFIX "/../junction/" +#define SYMLINK_PREFIX "/../symlink/" +#define UNC_PREFIX "/../unc/" +#define URL_PREFIX "/../url/" + +#define MAX_SYMLINK_SIZE (PAGE_SIZE - 128) + +extern STATUS LSA_process_mapped_request(nsskr_generic_t *request); + +extern struct inode_operations lsa_dir_inode_ops; +extern struct inode_operations lsa_file_inode_ops; +extern struct inode_operations lsa_symlink_inode_operations; +extern struct dentry_operations lsa_dentry_ops; + +LONG getMode (LONG attr) +{ + LONG mode = 0666; + + if (attr & zFA_SUBDIRECTORY) + { + mode |= S_IFDIR; + } + else if (attr & zFA_IS_LINK) + { + mode |= S_IFLNK; + } + else + { + mode |= S_IFREG; + } + if (attr & zFA_READ_ONLY) + { + mode &= ~0222; /* Turn off write permission */ + } + if (attr & zFA_HIDDEN) + { + mode &= ~0444; /* Turn off read permission */ + } + if ((attr & zFA_SUBDIRECTORY) + || (attr & zFA_EXECUTE)) + { + mode |= 0111; /* Turn on execute/search permission */ + } + mode = mode & (LSAPosixPermissionMask | ~0777); + + return mode; +} + +static void setMode (LONG mode, zInfo_s *zInfo) +{ + zInfo->std.fileAttributes = 0; + zInfo->std.fileAttributesModMask = zFA_READ_ONLY | + zFA_HIDDEN | + zFA_EXECUTE; + + if (S_ISDIR(mode)) + { + zInfo->std.fileAttributes |= zFA_SUBDIRECTORY; + zInfo->std.fileAttributesModMask |= zFA_SUBDIRECTORY; + } + + if (S_ISLNK(mode)) + { + zInfo->std.fileAttributes |= zFA_IS_LINK; + zInfo->std.fileAttributesModMask |= zFA_IS_LINK; + } + + if (!(mode & 0200)) + { + zInfo->std.fileAttributes |= zFA_READ_ONLY; + } + if (!(mode & 0400)) + { + zInfo->std.fileAttributes |= zFA_HIDDEN; + } + if ((mode & 0111) && !(S_ISDIR(mode))) + { + zInfo->std.fileAttributes |= zFA_EXECUTE; + } + return; +} + +LONG getUid (UserID_t *ownerGuid) +{ + LONG uid; + STATUS status; + + MPKNSS_LOCK(); + if (COMN_MapNDSGUIDToUID( &status, ownerGuid, &uid) != zOK) + { + if (LSA_HaveNobodyUID) + { + uid = LSA_LinuxNobodyUID; + } + else + { + uid = 0; + } + } + MPKNSS_UNLOCK(); + return uid; +} + +static STATUS getGuid(LONG uid, UserID_t *guid) +{ + STATUS status = zOK; + + MPKNSS_LOCK(); + if (COMN_MapUIDToNDSGUID( &status, uid, guid) != zOK) + { + *guid = zINVALID_GUID; + } + MPKNSS_UNLOCK(); + return(status); +} + +static int lsa_readpage ( + struct file *file, + struct page *page) +{ + LsaFile_s *f; +// NINT bytesRead; + int rc; +// char *kaddr = kmap(page); + Key_t key; + QUAD offset = ((QUAD)page->index << PAGE_CACHE_SHIFT); + NSSChunk_s chunks[1]; + NINT numChunks = 0; + struct inode *inode = page->mapping->host; + LsaSuper_s *super = inode->i_sb->s_fs_info; + +pr("lsa_readpage"); + mpkEnter(); + + unlock_page(page); + + if (super->sb_type == LSA_SB_TYPE_ADMIN) + { +// printk("<1> read_page on admin volume will return error\n"); + rc = -EINVAL; + goto exit; + } + if (file == NULL) + { + NINT nameSpace = super->sb_nameSpace; + + if (inode->i_mode & S_IFLNK) + { + nameSpace |= zMODE_LINK; + } + rc = zZIDOpen(userKey(current->fsuid), zNO_TASK, nameSpace, + &super->sb_volID, inode->i_ino, + zRR_READ_ACCESS | zRR_DONT_UPDATE_ACCESS_TIME, &key); + if (rc != 0) + { + rc = nss2linuxError(rc); + goto exit; + } + } + else + { + f = file->private_data; + if (f == NULL) + { + rc = -EPERM; + goto exit; + } + key = f->f_key; + } + + /* zRead will find the page that was created and sent to us */ + rc = zReadPageChunks(key, zNILXID, offset, + PAGE_CACHE_SIZE, chunks, 1, &numChunks); + + if (file == NULL) + { + zClose(key); + } + + if (rc == 0) + { + if (numChunks == 0) + { + goto exit; + } + if ((chunks[0].nc_handle) && + (((Buffer_s *)chunks[0].nc_handle)->b_page != page)) + { + printk("<1>readpage page did not match zReadChunks page\n"); + rc = -EINVAL; + } + } + + zReleasePageChunks(chunks, numChunks); + + if (rc != 0) + { + rc = nss2linuxError(rc); + goto exit; + } + + if (!PageUptodate(page)) + { + lock_page(page); + SetPageUptodate(page); + unlock_page(page); + } +// if (bytesRead < PAGE_CACHE_SIZE) +// { +// bzero(kaddr+bytesRead, PAGE_CACHE_SIZE - bytesRead); +// } +exit: +// kunmap(page); +// SetPageUptodate(page); +// unlock_page(page); +//linux_2_6// wakeup_page_waiters(page); + + mpkExit(); + return rc; +} + +#if 0 +static int lsa_readpage ( + struct file *file, + struct page *page) +{ + LsaFile_s *f; + int rc; + char *kaddr = kmap(page); + Key_t key; + QUAD offset = ((QUAD)page->index << PAGE_CACHE_SHIFT); + +pr("lsa_readpage"); +printk("<1> lsa_readpage page =%x\n", page); + mpkEnter(); + + if (file == NULL) + { + struct inode *inode = page->mapping->host; + LsaSuper_s *super = inode->i_sb->s_fs_info; + NINT nameSpace = super->sb_nameSpace; + + if (inode->i_mode & S_IFLNK) + { + nameSpace |= zMODE_LINK; + } + rc = zZIDOpen(userKey(current->fsuid), zNO_TASK, nameSpace, + &super->sb_volID, inode->i_ino, + zRR_READ_ACCESS | zRR_DONT_UPDATE_ACCESS_TIME, &key); + if (rc != 0) + { + rc = nss2linuxError(rc); + goto exit; + } + } + else + { + f = file->private_data; + if (f == NULL) + { + rc = -EPERM; + goto exit; + } + key = f->f_key; + } + bzero(kaddr, PAGE_CACHE_SIZE); + rc = zDIORead(key, offset >> 9 , 8, 0, NULL, kaddr); + + if (file == NULL) + { + zClose(key); + } + if (rc != 0) + { + rc = nss2linuxError(rc); + goto exit; + } +exit: + kunmap(page); + SetPageUptodate(page); + unlock_page(page); +//linux_2_6// wakeup_page_waiters(page); + mpkExit(); + return rc; +} +#endif + + +/* Since we have a buffer_s associated with the page, we set page private + * and we are notified when page is being destroyed or needs to be reclaimed + */ +static int lsa_invalidatepage (struct page *page, unsigned long offset) +{ + Buffer_s *buffer; + int ret = 1; + + mpkEnter(); + MPKNSS_LOCK(); + + buffer = (Buffer_s *)page->private; + if ((buffer != NSSPrivateBuffer) && (buffer != NULL)) + { + if (buffer->b_page == NULL) + { + retBuffer_s(buffer); + } + else + { + ret = 0; + buffer->state |= CACHE_STATE_INVALID; + } + } + ClearPagePrivate(page); + page->private = 0; + page_cache_release(page); + MPKNSS_UNLOCK(); + + mpkExit(); + return ret; +} + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) +static int lsa_releasepage (struct page *page, int gfp_mask) +#else +static int lsa_releasepage (struct page *page, gfp_t gfp_mask) +#endif +{ + Buffer_s *buffer; + int ret = 1; + + mpkEnter(); + MPKNSS_LOCK(); + + buffer = (Buffer_s *)page->private; + if ((buffer != NSSPrivateBuffer) && (buffer != NULL)) + { + if (buffer->b_page == NULL) + { + retBuffer_s(buffer); + } + else + { + ret = 0; + goto retPageInUse; + } + } + ClearPagePrivate(page); + page->private = 0; + page_cache_release(page); + +retPageInUse: + MPKNSS_UNLOCK(); + mpkExit(); + return ret; +} + +static struct address_space_operations lsa_address_ops = +{ + + readpage: lsa_readpage, // int (*readpage)(struct file *, + // struct page *); + invalidatepage: lsa_invalidatepage, // int (*invalidatepage) ( + // struct page *, unsigned long); + releasepage: lsa_releasepage, // int (*releasepage) (struct page *, + // int); + +// writepage: lsa_writepage, // int (*writepage)(struct page *); +// prepare_write: lsa_prepare_write, // int (*prepare_write)(struct file *, + // struct page *, unsigned, unsigned); +// commit_write: lsa_commit_write, // int (*commit_write)(struct file *, + // struct page *, unsigned, unsigned); + + // int (*sync_page)(struct page *); + // void (*removepage)(struct page *); /* called when page gets removed from the inode */ + // /* Unfortunately this kludge is needed for FIBMAP. Don't use it */ + // int (*bmap)(struct address_space *, long); + // int (*flushpage) (struct page *, unsigned long); +}; + + +void lsa_irefill ( + zInfo_s *zinfo, + struct inode *inode) +{ + QUAD blocks; +pr("lsa_irefill"); + + if (!(zinfo->std.fileAttributes & zFA_SUBDIRECTORY)) + { + inode->i_nlink = zinfo->count.hardLink; + } + inode->i_mode = getMode(zinfo->std.fileAttributes); + inode->i_uid = getUid(&zinfo->id.owner); + inode->i_gid = 0; + inode->i_atime.tv_sec = zinfo->time.accessed; + inode->i_atime.tv_nsec = 0; + inode->i_mtime.tv_sec = zinfo->time.modified; + inode->i_mtime.tv_nsec = 0; + if (LSACtimeIsMetadataModTime) + { + inode->i_ctime.tv_sec = zinfo->time.metaDataModified; + } + else + { + inode->i_ctime.tv_sec = zinfo->time.created; + } + inode->i_ctime.tv_nsec = 0; /* Not a great match but + * metaDataModified changes + * for too many reasons. + */ + inode->i_size = zinfo->std.logicalEOF; + + blocks = (zinfo->storageUsed.dataBytes + zinfo->blockSize.size - 1) + >> zinfo->blockSize.sizeShift; + inode->i_blocks = blocks << 3; +} + +static void lsa_info_irefill ( + LSAInfo_s *lsaInfo, + struct inode *inode) +{ + QUAD blocks; +pr("lsa_info_irefill"); + + if (!(lsaInfo->fileAttributes & zFA_SUBDIRECTORY)) + { + inode->i_nlink = lsaInfo->hardLinkCount; + } + inode->i_mode = getMode(lsaInfo->fileAttributes); + inode->i_uid = getUid(&lsaInfo->ownerID); + inode->i_gid = 0; + inode->i_atime.tv_sec = lsaInfo->accessedTime; + inode->i_atime.tv_nsec = 0; + inode->i_mtime.tv_sec = lsaInfo->modifiedTime; + inode->i_mtime.tv_nsec = 0; + if (LSACtimeIsMetadataModTime) + { + inode->i_ctime.tv_sec = lsaInfo->metaDataModifiedTime; + } + else + { + inode->i_ctime.tv_sec = lsaInfo->createdTime; + } + inode->i_ctime.tv_nsec = 0; /* Not a great match but + * metaDataModified changes + * for too many reasons. + */ + inode->i_size = lsaInfo->logicalEOF; + + blocks = (lsaInfo->dataBytes + lsaInfo->blockSize - 1) + >> lsaInfo->blockSizeShift; + inode->i_blocks = blocks << 3; +} + +static int lsa_sync_file ( + struct file *file, + struct dentry *dentry, + int datasync) +{ + struct inode *inode = dentry->d_inode; + LsaSuper_s *super = inode->i_sb->s_fs_info; + STATUS rc; + Key_t key; + + mpkEnter(); +pr("lsa_sync_file"); + + if ((file == NULL) || (file->private_data == NULL)) + { + rc = zZIDOpen(userKey(current->fsuid), zNO_TASK, + super->sb_nameSpace | zMODE_UTF8 | zMODE_LINK, + &super->sb_volID, inode->i_ino, + zRR_DONT_UPDATE_ACCESS_TIME, &key); + if (rc != 0) + { + goto exit; + } + } + else + { + key = ((LsaFile_s *)file->private_data)->f_key; + } + + rc = zFlush(key); + + if ((file == NULL) || (file->private_data == NULL)) + { + zClose(key); + } + +exit: + mpkExit(); + return rc ? nss2linuxError(rc) : 0; +} + +#ifdef I_DONT_NEED_THIS +static STATUS lsa_create_open ( + struct inode *inode, + struct file *file, + LsaFile_s *f, + NINT rights) +{ + LsaSuper_s *super = inode->i_sb->s_fs_info; + NINT createFlags; + NINT attributes; + STATUS rc; + +pr("lsa_create_open"); + + createFlags = (file->f_flags & O_EXCL) ? 0 : zCREATE_OPEN_IF_THERE; + if (file->f_flags & O_TRUNC) + { + createFlags |= zCREATE_TRUNCATE_IF_THERE; + } + + attributes = (file->f_mode & 0200) ? 0 : zFA_READ_ONLY; + if (file->f_mode & 0100) + { + attributes |= zFA_EXECUTE; + } + + rc = zZIDCreate(userKey(current->fsuid), zNO_TASK, zNILXID, + super->sb_nameSpace | zMODE_UTF8, + &super->sb_volID, inode->i_ino, + file->f_dentry->d_name.name, + zFILE_REGULAR, + attributes, createFlags, + rights, + &f->f_key); + return rc; +} +#endif +#ifdef I_GOT_THIS_WRONG + if (file->f_flags & ~O_ACCMODE) + { +#ifdef WHEN_LINUX_GETS_FILE_LOCKING + if (file->f_flags & O_EXLOCK) + { + rights |= (zRR_DENY_WRITE | zRR_DENY_READ); + } + else if (file->f_flags & O_SHLOCK) + { + rights |= zRR_DENY_WRITE; + } +#endif + if (file->f_flags & O_CREAT) + { + rc = lsa_create_open(inode, file, f, rights); + if (rc != zOK) + { + goto error; + } + file->private_data = f; + goto exit; + } + } + +error: + if (f) + { + free(f); + } + goto exit; +#endif + +static int lsa_opendir (struct inode *inode, struct file *file) +{ + LsaSuper_s *super = inode->i_sb->s_fs_info; + LsaFile_s *f = NULL; + NINT rights; + int rc; + +pr("lsa_opendir"); + if ((rc = generic_file_open(inode, file)) != 0) + { + return rc; + } + mpkEnter(); + f = zalloc(sizeof(LsaFile_s)); + if (f == NULL) + { + rc = -ENOMEM; + goto exit; + } + rights = zRR_SCAN_ACCESS; + if (!LSAUpdateDirAccessTime) + { + rights |= zRR_DONT_UPDATE_ACCESS_TIME; + } + if ((inode->i_sb->s_flags & MS_NOATIME) + || (inode->i_sb->s_flags & MS_NODIRATIME) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,6)) + || (file->f_vfsmnt && (file->f_vfsmnt->mnt_flags & MNT_NOATIME)) + || (file->f_vfsmnt && (file->f_vfsmnt->mnt_flags & MNT_NODIRATIME)) +#endif + ) + { + rights |= zRR_DONT_UPDATE_ACCESS_TIME; + } + rc = zZIDOpen(userKey(current->fsuid), zNO_TASK, + super->sb_nameSpace | zMODE_UTF8 | zMODE_VFS_OPEN, + &super->sb_volID, inode->i_ino, + rights, + &f->f_key); + if (rc != 0) + { + free(f); + goto exit; + } + file->private_data = f; +exit: + mpkExit(); + return rc ? nss2linuxError(rc) : 0; +} + +static int lsa_open (struct inode *inode, struct file *file) +{ + LsaSuper_s *super = inode->i_sb->s_fs_info; + LsaFile_s *f = NULL; + NINT rights; + int rc; + NINT nameSpace = super->sb_nameSpace | zMODE_UTF8 | zMODE_VFS_OPEN; + +pr("lsa_open"); + if ((rc = generic_file_open(inode, file)) != 0) + { + return rc; + } + mpkEnter(); + f = zalloc(sizeof(LsaFile_s)); + if (f == NULL) + { + rc = -ENOMEM; + goto exit; + } + rights = (file->f_flags & O_ACCMODE) + 1; /* A bit of magic */ + rights |= zRR_SCAN_ACCESS; + + if (file->f_flags & O_NOATIME) + { + rights |= zRR_DONT_UPDATE_ACCESS_TIME; + } + if ((inode->i_sb->s_flags & MS_NOATIME) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,6)) + || (file->f_vfsmnt && (file->f_vfsmnt->mnt_flags & MNT_NOATIME)) +#endif + ) + { + rights |= zRR_DONT_UPDATE_ACCESS_TIME; + } + if (inode->i_mode & S_IFLNK) + { + nameSpace |= zMODE_LINK; + } + rc = zZIDOpen(userKey(current->fsuid), zNO_TASK, nameSpace, + &super->sb_volID, inode->i_ino, + rights, + &f->f_key); + if (rc != 0) + { + free(f); + goto exit; + } + if (!(inode->i_mode & 0222) && (rights & zRR_WRITE_ACCESS)) + { + typedef struct Stack_s { + zInfo_s zInfo; + } Stack_s; + STACK_ALLOC(); + + aStack->zInfo.std.fileAttributesModMask = zFA_READ_ONLY; + aStack->zInfo.std.fileAttributes |= zFA_READ_ONLY; + + zModifyInfo(f->f_key, zNILXID, zMOD_FILE_ATTRIBUTES, sizeof(zInfo_s), + zINFO_VERSION_A, &aStack->zInfo); + + STACK_FREE(); + } + file->private_data = f; +exit: + mpkExit(); + return rc ? nss2linuxError(rc) : 0; +} + +static ssize_t lsa_file_read ( + struct file *file, + char __user *buf, + size_t count, + loff_t *ppos) +{ + LsaFile_s *f = file->private_data; + NINT bytesRead; + int rc; + +pr("lsa_file_read"); + if (f == NULL) + { + return -EPERM; + } + mpkEnter(); + rc = zRead(f->f_key, zNILXID, *ppos, count, buf, &bytesRead); + if (rc != 0) + { + rc = nss2linuxError(rc); + goto exit; + } + *ppos += bytesRead; + rc = bytesRead; +exit: + mpkExit(); + return rc; +} + +static ssize_t lsa_file_write ( + struct file *file, + const char __user *buf, + size_t count, + loff_t *ppos) +{ + LsaFile_s *f = file->private_data; + QUAD pos; + NINT bytesWritten; + int rc; + LSAInfo_s lsaInfo; + STATUS status; + struct inode *inode = file->f_dentry->d_inode; + +pr("lsa_file_write"); + if (f == NULL) + { + return -EPERM; + } + mpkEnter(); + + if (file->f_flags & O_APPEND) + { // __liniux__ fixfixfix would like to do this in COMN + pos = inode->i_size; + } + else + { + pos = *ppos; + } + rc = zWrite(f->f_key, zNILXID, pos, count, buf, &bytesWritten); + if (rc != 0) + { + rc = nss2linuxError(rc); + goto exit; + } + pos += bytesWritten; + if (pos > inode->i_size) + { + inode->i_size = pos; + } + *ppos = pos; + rc = bytesWritten; + + if ((status = LSACOMN_InfoByKey(f->f_key, &lsaInfo)) == zOK) + { + lsa_info_irefill(&lsaInfo, inode); + } + + if (status != zOK) + { + inode->i_blocks = (inode->i_size + 511) >> 9; + } + if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) + { + zFlush(f->f_key); + } + + /* all NSS user data is now a inode page, so no need to invalidate */ +// invalidate_inode_pages(inode->i_mapping); + +exit: + mpkExit(); + return rc; +} + +static int lsa_release ( + struct inode *inode, + struct file *file) +{ + LsaFile_s *f = file->private_data; + STATUS rc; + +pr("lsa_release"); + if (f == NULL) + { + return -EBADF; + } + mpkEnter(); + + rc = zClose(f->f_key); + if (rc != zOK) + { + rc = nss2linuxError(rc); + } + if (f->f_info) + { + free(f->f_info); + } + free(f); + mpkExit(); + return rc; +} + + +static ssize_t lsa_file_sendfile(struct file *in_file, loff_t *ppos, + size_t count, read_actor_t actor, void __user *target) +{ + if (LSASendfile) + { + return generic_file_sendfile(in_file, ppos, count, actor, target); + } + return -EINVAL; +} + +static struct file_operations lsa_file_ops = +{ + // struct module *owner; + + llseek: generic_file_llseek, // loff_t (*llseek) (struct file *, + // loff_t, int); + + read: lsa_file_read, // ssize_t (*read) (struct file *, + // char __user *, size_t, loff_t *); + + // ssize_t (*new_read) (struct file *, char *, size_t, loff_t *, int); + + write: lsa_file_write, // ssize_t (*write) (struct file *, + // const char __user *, size_t, loff_t *); + + // ssize_t (*new_write) (struct file *, const char *, size_t, + // loff_t *, int); + // int (*readdir) (struct file *, void *, filldir_t); + // unsigned int (*poll) (struct file *, struct poll_table_struct *); + // int (*ioctl) (struct inode *, struct file *, unsigned int, + // unsigned long); + + mmap: generic_file_mmap, // int (*mmap) (struct file *, + // struct vm_area_struct *); + + open: lsa_open, // int (*open) (struct inode *, struct file *); + // int (*flush) (struct file *); + release: lsa_release, // int (*release) (struct inode *, struct file *); + + fsync: lsa_sync_file, // int (*fsync) (struct file *, + // struct dentry *, int datasync); + + sendfile: lsa_file_sendfile, + + // int (*fasync) (int, struct file *, int); + // int (*lock) (struct file *, int, struct file_lock *); + // ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, + // loff_t *); + // ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, + // loff_t *); + // ssize_t (*sendpage) (struct file *, struct page *, int, size_t, + // loff_t *, int); + // unsigned long (*get_unmapped_area)(struct file *, unsigned long, + // unsigned long, unsigned long, unsigned long); + + // /* in-kernel fully async api */ + // int (*kvec_read)(struct file *, kvec_cb_t, size_t, loff_t); + // int (*kvec_write)(struct file *, kvec_cb_t, size_t, loff_t); + + // /* userland aio ops */ + // ssize_t (*aio_read)(struct file *, struct kiocb *, struct iocb); + // ssize_t (*aio_readx)(struct file *, struct kiocb *, struct iocb); + // ssize_t (*aio_write)(struct file *, struct kiocb *, struct iocb); + // ssize_t (*aio_fsync)(struct file *, struct kiocb *, struct iocb); + // int (*munmap) (struct vm_area_struct *, unsigned long, size_t); +}; + +extern STATUS lsa_enumerate( + struct file *file, + void *dirent, + filldir_t fillDirFunc); + +static int lsa_readdir ( + struct file *file, + void *dirent, + filldir_t fillDirFunc) +{ + LsaFile_s *f; + int done = FALSE; + STATUS rc = 0; + +pr("lsa_readdir"); + + mpkEnter(); + + f = file->private_data; + if (f == NULL) + { + rc = lsa_opendir(file->f_dentry->d_inode, file); + if (rc != 0) + { + goto exit; + } + f = file->private_data; + } + if (f->f_info == NULL) + { + f->f_info = zalloc(sizeof(FullDirectoryInfo_s)); + if (f->f_info == NULL) + { + rc = zERR_NO_MEMORY; + goto exit; + } + } + switch (file->f_pos) + { + case LSA_NO_MORE: + goto exit; + + case LSA_DOT: /* dot */ + done = fillDirFunc(dirent, ".", sizeof(".")-1, + LSA_DOT, file->f_dentry->d_inode->i_ino, DT_DIR); + if (done) + { + goto exit; + } + file->f_pos = LSA_DOT_DOT; + /* FALLTHRU */ + case LSA_DOT_DOT: /* dot-dot */ + done = fillDirFunc(dirent, "..", sizeof("..")-1, + LSA_DOT_DOT, file->f_dentry->d_parent->d_inode->i_ino, DT_DIR); + if (done) + { + goto exit; + } + file->f_pos = LSA_MORE; + /* FALLTHRU */ + default: + rc = lsa_enumerate(file, dirent, fillDirFunc); + break; + } +exit: + mpkExit(); + return rc ? nss2linuxError(rc) : 0; +} + +int lsa_ioctl(struct inode *inode, + struct file *file, + unsigned int request, + unsigned long arg) +{ + STATUS rc = 0; + char *buffer; + char *p; + nsskr_generic_t header; + nsskr_generic_t *reqbuf; + + (void) inode; + (void) file; + + mpkEnter(); + buffer = (char *) arg; + + switch(request) + { + case NSSKR_REQUEST: + /* Copy down the common header */ + p = (char *) &header; + header.signature = ~NSSKR_SIGNATURE; + if ((copy_from_user(p, buffer, sizeof(header)) != 0) || + (header.signature != NSSKR_SIGNATURE)) + { + rc = zERR_BAD_PARAMETER_VALUE; + break; + } + + /* Apparent kernel request from nssulib - make sure it's valid */ + /* Must be root to make this call */ + /* FixFixFix - is CAP_SYS_ADMIN more appropriate here??? */ + /* There are three calls that are exeption. They do their own security checks */ + if ((header.opcode != NSSKR_GetNextUserInVolume) && + (header.opcode != NSSKR_SetUserSpaceRestriction) && + (header.opcode != NSSKR_GetUserSpaceRestriction)) + { + if (!capable(CAP_SYS_MODULE)) + { + rc = zERR_ACCESS_DENIED/* -EPERM */; + break; + } + } + + /* Looks valid - copy the rest of the buffer down */ + if ((reqbuf = malloc(header.len)) == NULL) + { + rc = zERR_NO_MEMORY; + break; + } + memcpy(reqbuf, &header, sizeof(header)); + /* Now copy the rest of the buffer down */ + p = (char *) reqbuf; + p += sizeof(header); + buffer += sizeof(header); + if (copy_from_user(p, buffer, header.len - sizeof(header)) != 0) + { + /* Bad buffer pointer? */ + rc = zERR_BAD_PARAMETER_VALUE; + free(reqbuf); + break; + } + rc = LSA_process_mapped_request(reqbuf); + buffer = (char *) arg; + p = (char *) reqbuf; + if ((rc == zOK) && (copy_to_user(buffer, p, header.len) != 0)) + { + /* We have read access but don't have write access to buffer? */ + rc = zERR_BAD_PARAMETER_VALUE; + } + free(reqbuf); + break; + + default: + /* Unknown request type */ + rc = zERR_BAD_PARAMETER_VALUE; + break; + } + + mpkExit(); + return rc ? nss2linuxError(rc) : 0; +} + +/* get the link contents into pagecache */ +static char *lsa_getlink(struct dentry * dentry, struct page **ppage) +{ + struct page * page; + struct address_space *mapping = dentry->d_inode->i_mapping; + page = read_cache_page(mapping, 0, (filler_t *)mapping->a_ops->readpage, + NULL); + if (IS_ERR(page)) + goto sync_fail; + wait_on_page_locked(page); + if (!PageUptodate(page)) + goto async_fail; + *ppage = page; + return kmap(page); + +async_fail: + page_cache_release(page); + return ERR_PTR(-EIO); + +sync_fail: + return (char*)page; +} + +int lsa_readlink(struct dentry *dentry, char __user *buffer, int buflen) +{ + int res; + struct page *page = NULL; + char *s = lsa_getlink(dentry, &page); + + if (IS_ERR(s)) + { + return PTR_ERR(s); + } + + if (strncmp(s, LINK_PREFIX, strlen(LINK_PREFIX)) == 0) + { + /* It's a special NSS link (junction, etc) */ + switch(s[strlen(LINK_PREFIX)]) + { + case 'j': + /* Looks like a junction */ + /*** PLACE HOLDER ***/ + /*** May want to do something special here in the future ***/ + break; + + case 's': + /* Looks like a symlink - make sure */ + if (strstr(s, SYMLINK_PREFIX) == s) + { + /* Strip off the prefix so it looks like a regular symlink */ + s = &s[strlen(SYMLINK_PREFIX)]; + } + break; + + default: + /* UNC or URL or unknown link type - not supported (yet) */ + /* Just display the file contents */ + break; + } + } + if (strnlen(s, MAX_SYMLINK_SIZE) < MAX_SYMLINK_SIZE) + { + res = vfs_readlink(dentry, buffer, buflen, s); + } + else + { + res = -ENAMETOOLONG; + } + + if (page) + { + kunmap(page); + page_cache_release(page); + } + return res; +} + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) +int lsa_follow_link(struct dentry *dentry, struct nameidata *nd) +#else +void *lsa_follow_link(struct dentry *dentry, struct nameidata *nd) +#endif +{ + int res; + struct page *page = NULL; + char *s = lsa_getlink(dentry, &page); + + if (IS_ERR(s)) + { +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) + return PTR_ERR(s); +#else + return s; +#endif + } + + if (strncmp(s, LINK_PREFIX, strlen(LINK_PREFIX)) == 0) + { + /* It's a special NSS link (junction, etc) */ + switch(s[strlen(LINK_PREFIX)]) + { + case 'j': + /* Looks like a junction */ + /* Future: Handle links where target is same box here */ + /* Future: Hand off links where target is another box here */ + /* iff calling service is not link-aware */ + res = -EREMOTE; + goto exit; + + case 's': + /* Looks like a symlink - make sure */ + if (strstr(s, SYMLINK_PREFIX) == s) + { + s = &s[strlen(SYMLINK_PREFIX)]; + } + else + { + /* Looks like garbage to me - let the client deal with it */ + res = -EREMOTE; + goto exit; + } + break; + + default: + /* UNC or URL or unknown link type - not supported (yet) */ + res = -EREMOTE; + goto exit; + } + } + + res = vfs_follow_link(nd, s); + exit: + if (page) + { + kunmap(page); + page_cache_release(page); + } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) + return res; +#else + return ERR_PTR(res); +#endif +} + +static struct file_operations lsa_dir_ops = +{ + // struct module *owner; + // loff_t (*llseek) (struct file *, loff_t, int); + +// read: generic_file_read, // ssize_t (*read) (struct file *, + // char *, size_t, loff_t *); + + // ssize_t (*new_read) (struct file *, char *, size_t, loff_t *, int); + // ssize_t (*write) (struct file *, const char *, size_t, loff_t *); + // ssize_t (*new_write) (struct file *, const char *, size_t, + // loff_t *, int); + + readdir: lsa_readdir, // int (*readdir) (struct file *, void *, + // filldir_t); + + // unsigned int (*poll) (struct file *, struct poll_table_struct *); + // int (*ioctl) (struct inode *, struct file *, unsigned int, + // unsigned long); + ioctl: lsa_ioctl, + // int (*mmap) (struct file *, struct vm_area_struct *); + // int (*open) (struct inode *, struct file *); + // int (*flush) (struct file *); + release: lsa_release, // int (*release) (struct inode *, struct file *); + + fsync: lsa_sync_file, // int (*fsync) (struct file *, + // struct dentry *, int datasync); + + // int (*fasync) (int, struct file *, int); + // int (*lock) (struct file *, int, struct file_lock *); + // ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, + // loff_t *); + // ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, + // loff_t *); + // ssize_t (*sendpage) (struct file *, struct page *, int, size_t, + // loff_t *, int); + // unsigned long (*get_unmapped_area)(struct file *, unsigned long, + // unsigned long, unsigned long, unsigned long); + + // /* in-kernel fully async api */ + // int (*kvec_read)(struct file *, kvec_cb_t, size_t, loff_t); + // int (*kvec_write)(struct file *, kvec_cb_t, size_t, loff_t); + + // /* userland aio ops */ + // ssize_t (*aio_read)(struct file *, struct kiocb *, struct iocb); + // ssize_t (*aio_readx)(struct file *, struct kiocb *, struct iocb); + // ssize_t (*aio_write)(struct file *, struct kiocb *, struct iocb); + // ssize_t (*aio_fsync)(struct file *, struct kiocb *, struct iocb); + // int (*munmap) (struct vm_area_struct *, unsigned long, size_t); +}; + +void lsa_ifill ( + struct inode *inode, + zInfo_s *zinfo) +{ +pr("lsa_ifill"); + inode->i_ino = zinfo->std.zid; + inode->i_blkbits = zinfo->blockSize.sizeShift; + inode->i_blksize = zinfo->blockSize.size; +// inode->i_blocks = (zinfo->storageUsed.dataBytes + zinfo->blockSize.size - 1) +// >> zinfo->blockSize.sizeShift; + inode->i_rdev = inode->i_sb->s_dev; /* Need a similar trick to nfs. Must + * be a unique value per volume. + */ + inode->i_mapping->a_ops = &lsa_address_ops; + lsa_irefill(zinfo, inode); + switch (inode->i_mode & S_IFMT) + { + default: + init_special_inode(inode, inode->i_mode, /*dev*/ 0); + break; + case S_IFREG: + inode->i_op = &lsa_file_inode_ops; + inode->i_fop = &lsa_file_ops; + break; + case S_IFDIR: + inode->i_op = &lsa_dir_inode_ops; + inode->i_fop = &lsa_dir_ops; + break; + case S_IFLNK: + inode->i_op = &lsa_symlink_inode_operations; + break; + } +} + +void lsa_info_ifill ( + struct inode *inode, + LSAInfo_s *lsaInfo) +{ +pr("lsa_info_ifill"); + inode->i_ino = lsaInfo->zid; + inode->i_blkbits = lsaInfo->blockSizeShift; + inode->i_blksize = lsaInfo->blockSize; +// inode->i_blocks = (lsaInfo->dataBytes + lsaInfo->blockSize - 1) +// >> lsaInfo->blockSizeShift; + inode->i_rdev = inode->i_sb->s_dev; /* Need a similar trick to nfs. + * Must be unique per volume. + */ + inode->i_mapping->a_ops = &lsa_address_ops; + lsa_info_irefill(lsaInfo, inode); + switch (inode->i_mode & S_IFMT) + { + default: + init_special_inode(inode, inode->i_mode, /*dev*/ 0); + break; + case S_IFREG: + inode->i_op = &lsa_file_inode_ops; + inode->i_fop = &lsa_file_ops; + break; + case S_IFDIR: + inode->i_op = &lsa_dir_inode_ops; + inode->i_fop = &lsa_dir_ops; + break; + case S_IFLNK: + inode->i_op = &lsa_symlink_inode_operations; + break; + } +} + +void lsa_dfill ( + struct dentry *dentry, + LsaSuper_s *super) +{ + switch (super->sb_nameSpace) + { + case zNSPACE_LONG: + case zNSPACE_DOS: + case zNSPACE_MAC: + dentry->d_op = &lsa_dentry_ops; + break; + + case zNSPACE_UNIX: + default: + break; + } + return; +} + + +static int lsa_mknod_comn ( + struct inode *dir, + struct dentry *dentry, + int mode, + int dev, + const char *symName) +{ + struct inode *child = NULL; + + LsaSuper_s *super = dir->i_sb->s_fs_info; + NINT attr; + Key_t key = 0; + STATUS rc; + NINT bWritten = 0; + LSAInfo_s lsaInfo; +// LsaInode_s *lsaInode; + +pr("lsa_mknod_comn"); + + mpkEnter(); + + switch (mode & S_IFMT) + { + default: rc = zERR_BAD_PARAMETER_VALUE; goto error; + case S_IFREG: attr = 0; break; + case S_IFDIR: attr = zFA_SUBDIRECTORY; break; + case S_IFLNK: attr = zFA_IS_LINK; break; + } + if (mode & 0100) /* Owner execute bit is set */ + { + if (!S_ISDIR(mode)) + { + attr |= zFA_EXECUTE; + } + } + if (!(mode & 0200)) /* Owner write bit is clear */ + { + if (mode & S_IFDIR) + { + attr |= zFA_READ_ONLY; + } + } + if (!(mode & 0400)) + { + attr |= zFA_HIDDEN; + } + if (!S_ISDIR(mode)) + { + attr |= zFA_ARCHIVE; + } + + rc = zZIDCreate(userKey(current->fsuid), zNO_TASK, zNILXID, + super->sb_nameSpace|zMODE_UTF8|zMODE_LINK, + &super->sb_volID, dir->i_ino, + dentry->d_name.name, zFILE_REGULAR, attr, + zCREATE_KEEP_VFS_CACHE, + zRR_WRITE_ACCESS, symName ? &key : NULL); + + if (rc != zOK) + { + goto error; + } + if (symName) + { + rc = zWrite(key, zNILXID, 0, strlen(symName)+1, symName, &bWritten); + if (rc != zOK) + { + zClose(key); + goto error; + } + rc = LSACOMN_InfoByKey(key, &lsaInfo); + zClose(key); + } + else + { + rc = LSACOMN_Lookup(&super->sb_volID, dir->i_ino, super->sb_nameSpace, + dentry->d_name.name, &lsaInfo, NULL); + } + + if (rc != zOK) + { + goto error; + } + /* Do a iget instead of new_inode because create with open will create the + * inode + */ + child = iget(dir->i_sb, lsaInfo.zid); +// child = new_inode(dir->i_sb); + if (!child) + { + rc = zFAILURE; + goto error; + } + + lsa_info_ifill(child, &lsaInfo); + lsa_dfill(dentry, super); + + dir->i_mtime.tv_sec = GetUTCTime(); + if (!(mode & 0200)) /* Owner write bit is clear */ + { + child->i_mode &= ~0222; + } + + + /* no need to insert_inode_hash as iget will do that + * no iput because d_instantiate gives inode to dentry + */ +// insert_inode_hash(child); + //mark_inode_dirty(child); + d_instantiate(dentry, child); +exit: + mpkExit(); + return rc; + +error: + if (child) + { +// make_bad_inode(child); + iput(child); // Error case only if no d_instantiate + } + rc = nss2linuxError(rc); + goto exit; +} + +static int lsa_create ( + struct inode *dir, + struct dentry *dentry, + int mode, + struct nameidata *nd) +{ +pr("lsa_create"); + return lsa_mknod_comn(dir, dentry, (mode & ~S_IFMT) | S_IFREG, 0, NULL); +} + +static int lsa_link ( + struct dentry *old_dentry, + struct inode *dir, + struct dentry *dentry) +{ + LsaSuper_s *super = dir->i_sb->s_fs_info; + STATUS rc; + struct inode *inode = old_dentry->d_inode; + LSAInfo_s lsaInfo; + LsaInode_s *lsaInode = STRUCT(inode, LsaInode_s, li_inode); +pr("lsa_link"); + + mpkEnter(); + + rc = zZIDLink(userKey(current->fsuid), zNILXID, + &super->sb_volID, + inode->i_ino, dir->i_ino, + super->sb_nameSpace | zMODE_UTF8 | zMODE_LINK, + dentry->d_name.name, + zLF_KEEP_VFS_CACHE | zLF_HARD_LINK); + if (rc != 0) + { + goto exit; + } + + rc = LSACOMN_Lookup(&super->sb_volID, inode->i_ino, + super->sb_nameSpace | zMODE_LINK, + NULL, &lsaInfo, lsaInode); + if (rc != zOK) + { + goto exit; + } + /* Update the inode with current info and then ... */ + lsa_info_irefill( &lsaInfo, inode); + lsa_dfill(dentry, super); + + dir->i_mtime.tv_sec = GetUTCTime(); + + atomic_inc(&inode->i_count); + d_instantiate(dentry, inode); /* removes negative entry */ + +exit: + mpkExit(); + return rc ? nss2linuxError(rc) : 0; +} + +static struct dentry *lsa_lookup ( + struct inode *dir, + struct dentry *dentry, + struct nameidata *nd) +{ + LsaSuper_s *super = dir->i_sb->s_fs_info; + struct inode *child = NULL; + struct dentry *retdentry = NULL; + STATUS rc; + LSAInfo_s lsaInfo; + +pr("lsa_lookup"); + + mpkEnter(); + + rc = LSACOMN_Lookup(&super->sb_volID, dir->i_ino, super->sb_nameSpace, + dentry->d_name.name, &lsaInfo, NULL); + if (rc != zOK) + { + if (rc == zERR_NAME_NOT_FOUND_IN_DIRECTORY) + { + rc = zOK; + goto not_found; + } + goto error; + } + child = iget(dir->i_sb, lsaInfo.zid); + if (!child) + { + goto error; + } + + lsa_info_ifill(child, &lsaInfo); + lsa_dfill(dentry, super); + + retdentry = d_splice_alias(child, dentry); +exit: + if (rc) + { + retdentry = ERR_PTR(nss2linuxError(rc)); + } + mpkExit(); + return retdentry; + +error: + if (child) + { + make_bad_inode(child); + } + goto exit; + +not_found: + d_add(dentry, child); + goto exit; +} + +#ifdef IT_HAS_DISAPPEARED_NOW_WHAT_DO_WE_DO +static int lsa_revalidate ( + struct dentry *dentry) +{ + struct inode *inode = dentry->d_inode; + LsaSuper_s *super = inode->i_sb->s_fs_info; + Key_t key; + STATUS rc; + + typedef struct Stack_s { + zInfo_s zinfo; + } Stack_s; + +pr("lsa_revalidate"); + + mpkEnter(); + STACK_ALLOC(); + + rc = zZIDOpen(userKey(current->fsuid), zNO_TASK, super->sb_nameSpace, + &super->sb_volID, inode->i_ino, 0, &key); + if (rc != zOK) + { + goto exit; + } + rc = zGetInfo(key, LINUX_INFO, LINUX_INFO_SIZE, zINFO_VERSION_A, + &aStack->zinfo); + zClose(key); + if (rc != zOK) + { + goto exit; + } + lsa_irefill( &aStack->zinfo, inode); + lsa_dfill(dentry, super); +exit: + STACK_FREE(); + mpkExit(); + return rc ? nss2linuxError(rc) : 0; +} +#endif + +static int lsa_unlink (struct inode *dir, struct dentry *dentry) +{ + struct inode *inode = dentry->d_inode; + LsaSuper_s *super = dir->i_sb->s_fs_info; + STATUS rc; + +pr("lsa_unlink"); + + mpkEnter(); + + rc = LSACOMN_Delete(&super->sb_volID, dir->i_ino, + dentry->d_name.name, + super->sb_nameSpace|zMODE_UTF8|zMODE_LINK, + zDELETE_KEEP_VFS_CACHE); + if (rc != zOK) + { + goto error; + } + dir->i_mtime.tv_sec = GetUTCTime(); + if (inode) + { + --inode->i_nlink; /* Everything is handled in VFS layer (Ha, no really) */ + } +exit: + mpkExit(); + return rc; + +error: + rc = nss2linuxError(rc); + goto exit; +} + +static int lsa_mkdir ( + struct inode *dir, + struct dentry *dentry, + int mode) +{ +pr("lsa_mkdir"); + return lsa_mknod_comn(dir, dentry, (mode & ~S_IFMT) | S_IFDIR, 0, NULL); +} + +static int lsa_rename ( + struct inode *old_dir, + struct dentry *old_dentry, + struct inode *new_dir, + struct dentry *new_dentry) +{ + LsaSuper_s *old_super = old_dir->i_sb->s_fs_info; + LsaSuper_s *new_super = new_dir->i_sb->s_fs_info; + STATUS rc = 0; + NINT renameFlags = zRENAME_ALLOW_RENAMES_TO_MYSELF + | zRENAME_KEEP_VFS_CACHE; + +pr("lsa_rename"); + + if (old_super != new_super) + { + return -EXDEV; + } + mpkEnter(); + if (new_dentry->d_inode) + { + renameFlags |= zRENAME_DELETE_FILE_IF_THERE; + new_dentry->d_inode->i_nlink--; + } + rc = LSACOMN_Rename( &new_super->sb_volID, + old_dir->i_ino, old_dentry->d_name.name, + new_dir->i_ino, new_dentry->d_name.name, + new_super->sb_nameSpace | zMODE_UTF8 | zMODE_LINK, + renameFlags); + if (rc != 0) + { + goto exit; + } + old_dir->i_mtime.tv_sec = GetUTCTime(); + new_dir->i_mtime.tv_sec = GetUTCTime(); +exit: + mpkExit(); + return rc ? nss2linuxError(rc) : 0; +} + +static int lsa_setattr ( + struct dentry *dentry, + struct iattr *attr) +{ + struct inode *inode = dentry->d_inode; + LsaSuper_s *super = inode->i_sb->s_fs_info; + unsigned int ia_valid = attr->ia_valid; + STATUS rc = 0; + STATUS status; + QUAD infoMask = 0; + + typedef struct Stack_s { + zInfo_s zinfo; + } Stack_s; + Stack_s *aStack; + +pr("lsa_setattr"); + + mpkEnter(); + STACK_ALLOC_NO_ASTACK(); + + if (ia_valid & ATTR_SIZE) + { + rc = vmtruncate(inode, attr->ia_size); + if (rc) + { + goto exit; + } + } + if (ia_valid & ATTR_UID) + { + status = getGuid(attr->ia_uid, &aStack->zinfo.id.owner); + if (status != zOK || LB_GUIDCompare(&aStack->zinfo.id.owner, &zINVALID_GUID) == 0) + { + /* We couldn't get a valid GUID, don't modify the UID */ + ia_valid &= ~ATTR_UID; + } + else + { + /* We have a valid guid, modify the owner */ + infoMask |= zMOD_OWNER_ID; + } + } + if (ia_valid & ATTR_GID) // Linux - FixFixFix + { + inode->i_gid = attr->ia_gid; + } + if (ia_valid & ATTR_ATIME) + { + aStack->zinfo.time.accessed = attr->ia_atime.tv_sec; + infoMask |= zMOD_ACCESSED_TIME; + } + if (ia_valid & ATTR_MTIME) + { + aStack->zinfo.time.modified = attr->ia_mtime.tv_sec; + infoMask |= zMOD_MODIFIED_TIME; + } + if (ia_valid & ATTR_CTIME) + { + if (LSACtimeIsMetadataModTime) + { + aStack->zinfo.time.metaDataModified = attr->ia_ctime.tv_sec; + infoMask |= zMOD_METADATA_MODIFIED_TIME; + } + else + { + aStack->zinfo.time.created = attr->ia_ctime.tv_sec; + infoMask |= zMOD_CREATED_TIME; + } + } + if (ia_valid & ATTR_MODE) + { + setMode(attr->ia_mode, &aStack->zinfo); + infoMask |= zMOD_FILE_ATTRIBUTES; + } + // Do Modify Info then set inode + if (infoMask == 0) + { + goto exit; + } + rc = LSACOMN_ModifyInfo(&super->sb_volID, super->sb_nameSpace, + inode->i_ino, infoMask, sizeof(zInfo_s), + zINFO_VERSION_A, &aStack->zinfo); + if (rc != zOK) + { + goto exit; + } +//????? lsa_irefill( &aStack->zinfo, inode); + + if (ia_valid & ATTR_UID) + { + inode->i_uid = attr->ia_uid; + } + if (ia_valid & ATTR_GID) + { + inode->i_gid = attr->ia_gid; + } + if (ia_valid & ATTR_ATIME) + { + inode->i_atime = attr->ia_atime; + } + if (ia_valid & ATTR_MTIME) + { + inode->i_mtime = attr->ia_mtime; + } + if (ia_valid & ATTR_CTIME) + { + inode->i_ctime = attr->ia_ctime; + } + if (ia_valid & ATTR_MODE) + { + inode->i_mode = attr->ia_mode; + if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID)) + { + inode->i_mode &= ~S_ISGID; + } + } +exit: + STACK_FREE(); + mpkExit(); + return rc ? nss2linuxError(rc) : 0; +} + + + +/**************************************************************************** + * + *****************************************************************************/ +static int lsa_getattr ( + struct vfsmount *mount, + struct dentry *dentry, + struct kstat *stat) +{ + struct inode *inode = dentry->d_inode; + LsaSuper_s *super = inode->i_sb->s_fs_info; + STATUS rc; + LSAInfo_s lsaInfo; + LsaInode_s *lsaInode = STRUCT(inode, LsaInode_s, li_inode); + +pr("lsa_getattr"); + + mpkEnter(); + rc = LSACOMN_Lookup(&super->sb_volID, inode->i_ino, super->sb_nameSpace, + NULL, &lsaInfo, lsaInode); + if (rc != zOK) + { + goto exit; + } + /* Update the inode with current info and then ... */ + lsa_info_irefill(&lsaInfo, inode); + + /* ... Use the generic linux function to fill in the stat reply */ + generic_fillattr(dentry->d_inode, stat); + + +exit: + mpkExit(); + return rc ? nss2linuxError(rc) : 0; +} + + +/**************************************************************************** + * Extented Attributes + *****************************************************************************/ + +static char NwPrefix[] = zNW_PREFIX; +#define NW_PREFIX_SIZE (sizeof(NwPrefix) - 1) + +static int lsa_setxattr ( + struct dentry *dentry, + const char *name, + const void *value, + size_t size, + int flags) +{ + struct inode *inode = dentry->d_inode; + LsaSuper_s *super = inode->i_sb->s_fs_info; + Key_t fileKey; + Key_t eaKey; + STATUS rc; + NINT createMode; + NINT bytesWritten; + NINT nameSpace = super->sb_nameSpace; + +pr("lsa_setxattr"); + + if (strncmp(NwPrefix, name, NW_PREFIX_SIZE) == 0) + { + return netware_setxattr(dentry, name+NW_PREFIX_SIZE, value, size); + } + + mpkEnter(); + + if (inode->i_mode & S_IFLNK) + { + nameSpace |= zMODE_LINK; + } + /* Open the file/dir for which the EA will be set */ + rc = zZIDOpen(userKey(current->fsuid), zNO_TASK, nameSpace, + &super->sb_volID, inode->i_ino, + zRR_DONT_UPDATE_ACCESS_TIME, &fileKey); + if (rc != zOK) + { + pr("lsa_setxattr - zZIDOpen of file/dir failed"); + goto error_xlate; + } + + if (flags & XATTR_REPLACE) + { + /* The EA must exist or we return ENODATA */ + rc = zOpen(fileKey, zNO_TASK, zNSPACE_EXTENDED_ATTRIBUTE|zMODE_UTF8, + name, zRR_WRITE_ACCESS|zRR_DONT_UPDATE_ACCESS_TIME, &eaKey); + if (rc != zOK) + { + zClose(fileKey); + if (rc == zERR_NAME_NOT_FOUND_IN_DIRECTORY) + { + rc = -ENODATA; + pr("lsa_setxattr XATTR_REPLACE - existing EA not found "); + goto exit; + } + pr("lsa_setxattr XATTR_REPLACE - failed existing EA lookup "); + goto error_xlate; + } + + /* The EA does exist, truncate it and replace it */ + pr("lsa_setxattr XATTR_REPLACE - successfully found existing EA"); + zSetEOF(eaKey, zNILXID, 0, 0); + } + else + { + if (flags & XATTR_CREATE) + { + /* Creates, but fails if already there */ + pr("lsa_setxattr XATTR_CREATE"); + createMode = 0; + } + else + { + /* Creates, but truncates if already there */ + pr("lsa_setxattr NORMAL Flags behavior"); + createMode = zCREATE_TRUNCATE_IF_THERE; + } + + /* Create/open the EA */ + rc = zCreate(fileKey, zNO_TASK, zNILXID, + zNSPACE_EXTENDED_ATTRIBUTE|zMODE_UTF8, + name, zFILE_EXTENDED_ATTRIBUTE, 0 /*fileAttributes*/, createMode, + zRR_WRITE_ACCESS, &eaKey); + } + + zClose(fileKey); + + /* Test the zCreate status */ + if (rc != zOK) + { + pr("lsa_setxattr - zCreate failed on new EA"); + goto error_xlate; + } + + /* Write the EA contents */ + rc = zWrite(eaKey, zNILXID, 0, size, value, &bytesWritten); + zClose(eaKey); + + /* Test the zWrite status */ + if (rc != zOK) + { + pr("lsa_setxattr - zWrite failed on new EA"); + goto error_xlate; + } + + pr("lsa_setxattr - new EA was created, written and closed"); + +exit: + mpkExit(); + return rc; + +error_xlate: + rc = nss2linuxError(rc); + goto exit; +} + + + +/**************************************************************************** + * + *****************************************************************************/ + +static ssize_t lsa_getxattr ( + struct dentry *dentry, + const char *name, + void *value, + size_t size) +{ + struct inode *inode = dentry->d_inode; + LsaSuper_s *super = inode->i_sb->s_fs_info; + Key_t fileKey; + Key_t eaKey; + STATUS rc = 0; + ssize_t retSize = 0; + NINT bytesRead; + NINT nameSpace = super->sb_nameSpace; + + typedef struct Stack_s { + zInfo_s zinfo; + } Stack_s; + Stack_s *aStack; + + +pr("lsa_getxattr"); + + if (strncmp(NwPrefix, name, NW_PREFIX_SIZE) == 0) + { + return netware_getxattr(dentry, name+NW_PREFIX_SIZE, value, size); + } + + mpkEnter(); + STACK_ALLOC_NO_ASTACK(); + + if (inode->i_mode & S_IFLNK) + { + nameSpace |= zMODE_LINK; + } + /* Open the file/dir for which the EA will be set */ + rc = zZIDOpen(userKey(current->fsuid), zNO_TASK, nameSpace, + &super->sb_volID, inode->i_ino, + zRR_DONT_UPDATE_ACCESS_TIME, &fileKey); + if (rc != zOK) + { + pr("lsa_getxattr - zZIDOpen of file/dir failed"); + goto error_xlate; + } + + /* Open the EA itself */ + rc = zOpen(fileKey, zNO_TASK, zNSPACE_EXTENDED_ATTRIBUTE|zMODE_UTF8, name, + zRR_READ_ACCESS|zRR_DONT_UPDATE_ACCESS_TIME, &eaKey); + zClose(fileKey); + + /* Test the zOpen status */ + if (rc != zOK) + { + if (rc == zERR_NAME_NOT_FOUND_IN_DIRECTORY) + { + rc = -ENODATA; + pr("lsa_getxattr - EA not found "); + goto exit; + } + pr("lsa_getxattr - failed EA lookup "); + goto error_xlate; + } + + rc = zGetInfo(eaKey, zGET_STD_INFO, LINUX_INFO_SIZE, zINFO_VERSION_A, + &aStack->zinfo); + if (rc != zOK) + { + zClose(eaKey); + goto error_xlate; + } + retSize = aStack->zinfo.std.logicalEOF; + + /* If they pass in a size of zero, we simply tell them how big the + * file is. + */ + if (size == 0) + { + rc = 0; /* causes retSize to be returned */ + zClose(eaKey); + goto exit; + } + + /* If their buffer is not big enough, return ERANGE */ + if (size < retSize) + { + rc = -ERANGE; + zClose(eaKey); + pr("lsa_getxattr - buffer not big enough"); + goto exit; + } + + /* Read the EA */ + rc = zRead(eaKey, zNILXID, 0, size, value, &bytesRead); + retSize = bytesRead; /* Just in case EA got smaller in timing window */ + zClose(eaKey); + + /* Test the zRead status */ + if (rc != zOK) + { + pr("lsa_getxattr - zRead failed on EA"); + goto error_xlate; + } + + rc = 0; /* force to Return the size */ + +exit: + STACK_FREE(); + mpkExit(); + /* If a failure, return the error code instead of the size */ + if (rc < 0) + { + retSize = rc; + } + return (retSize); + +error_xlate: + rc = nss2linuxError(rc); + goto exit; +} + + + +BOOL LSAReturnNWmetadata = FALSE; + +static int lsa_listxattr_size( + int numBytes, + size_t size, + ssize_t *retSize, + char **retPtr, + char *name) +{ + STATUS rc = 0; + + /* Add the length of this name to our return size */ + *retSize += (numBytes + 1); + + /* If we were asked to return the data ... */ + if (size != 0) + { + /* If the data won't fit in the caller's buffer force ERANGE */ + if (*retSize > size) + { + rc = -ERANGE; + goto exit; + } + + /* Copy the data */ + memcpy(*retPtr, name, (numBytes + 1)); + *retPtr += (numBytes + 1); + } +exit: + return rc; +} +/**************************************************************************** + * + *****************************************************************************/ +static ssize_t lsa_listxattr ( + struct dentry *dentry, + char *list, + size_t size) +{ + struct inode *inode = dentry->d_inode; + LsaSuper_s *super = inode->i_sb->s_fs_info; + Key_t fileKey; + QUAD cookie; + int numBytes; + STATUS rc = 0; + ssize_t retSize = 0; + char *retPtr = list; + NINT nameSpace = zNSPACE_EXTENDED_ATTRIBUTE | zMODE_UTF8; + NINT totalCount; + NINT totalXattrs; + NINT i; + + typedef struct Stack_s { + zInfo_s zinfo; + char name[LSA_NAME_LEN+1]; + } Stack_s; + Stack_s *aStack; + +pr("lsa_listxattr"); + + mpkEnter(); + STACK_ALLOC_NO_ASTACK(); + + if (inode->i_mode & S_IFLNK) + { + nameSpace |= zMODE_LINK; + } + rc = zZIDOpen(userKey(current->fsuid), zNO_TASK, nameSpace, + &super->sb_volID, inode->i_ino, + zRR_SCAN_ACCESS|zRR_DONT_UPDATE_ACCESS_TIME, &fileKey); + if (rc != 0) + { + goto error_xlate; + } + + if (LSAReturnNWmetadata && capable(CAP_SYS_ADMIN)) + { + numBytes = strlen(zNW_METADATA); + + rc = lsa_listxattr_size(numBytes, size, &retSize, &retPtr, + zNW_METADATA); + if (rc != 0) + { + goto closeExit; + } +#if 0 + rc = LSACOMN_GetTrusteeCountByKey(fileKey, &totalCount); + if (rc != 0) + { + zClose(fileKey); + goto error_xlate; + } + + totalXattrs = (totalCount + zMAX_XATTR_USERS - 1)/zMAX_XATTR_USERS; +printk("<1> Total users = %d, total xattrs for trustees = %d\n", totalCount, totalXattrs); + for (i = 0; i < totalXattrs; i++) + { + sprintf(aStack->name, "%s.%d", zNW_TRUSTEE, i ); + numBytes = strlen(aStack->name); + rc = lsa_listxattr_size(numBytes, size, &retSize, &retPtr, + aStack->name); + if (rc != 0) + { + goto closeExit; + } + } +#endif + + if (inode->i_ino == zROOTDIR_ZID) + { + rc = LSACOMN_BrowseUsers(zSYS_CONNECTION, &super->sb_volID, + 0, NULL, NULL, &totalCount, + BROWSE_USERS_GET_ONLY_RESTRICTED| BROWSE_USERS_GET_COUNT); + if (rc != 0) + { +//printk("zBrowseUsers rc = %d\n", rc); + zClose(fileKey); + goto error_xlate; + } + + totalXattrs = (totalCount + zMAX_XATTR_USERS - 1)/zMAX_XATTR_USERS; +//printk("<1> Total users = %d, total xattrs for user quotas = %d\n", totalCount, totalXattrs); + for (i = 0; i < totalXattrs; i++) + { + sprintf(aStack->name, "%s.%d", zNW_USERQUOTA, i ); + numBytes = strlen(aStack->name); + rc = lsa_listxattr_size(numBytes, size, &retSize, &retPtr, + aStack->name); + if (rc != 0) + { + goto closeExit; + } + } + } + } + + cookie = 0; + for (;;) + { + rc = zEnumerate(fileKey, cookie, zNTYPE_EXTENDED_ATTRIBUTE, 0, + zGET_NAME, sizeof(zInfo_s), + zINFO_VERSION_A, &aStack->zinfo, &cookie); + if (rc != 0) + { + zClose(fileKey); + if (rc == zERR_NAME_NOT_FOUND_IN_DIRECTORY) + { + /* We are done. Return the cumulative size of the buffer */ + rc = 0; + goto exit; + } + goto error_xlate; + } + + numBytes = uni2utf(zINFO_NAME( &aStack->zinfo), aStack->name, + LSA_NAME_LEN+1); + + rc = lsa_listxattr_size(numBytes,size,&retSize,&retPtr,aStack->name); + if (rc != 0) + { + goto closeExit; + } + } + +closeExit: + zClose(fileKey); + +exit: + STACK_FREE(); + mpkExit(); + /* If a failure, return the error code instead of the size */ + if (rc < 0) + { + retSize = rc; + } + return (retSize); + +error_xlate: + rc = nss2linuxError(rc); + goto exit; +} + + + +/**************************************************************************** + * + *****************************************************************************/ +static int lsa_removexattr ( + struct dentry *dentry, + const char *name) +{ + struct inode *inode = dentry->d_inode; + LsaSuper_s *super = inode->i_sb->s_fs_info; + Key_t fileKey; + STATUS rc; + NINT nameSpace = super->sb_nameSpace; + +pr("lsa_removexattr"); + + if (name && (strncmp(NwPrefix, name, NW_PREFIX_SIZE) == 0)) + { + if ( capable(CAP_SYS_ADMIN) ) + { + return netware_removexattr(dentry, name+NW_PREFIX_SIZE); + } + else + { + return -ENODATA; + } + } + + mpkEnter(); + + if (inode->i_mode & S_IFLNK) + { + nameSpace |= zMODE_LINK; + } + /* Open the file/dir for which the EA will be set */ + rc = zZIDOpen(userKey(current->fsuid), zNO_TASK, nameSpace, + &super->sb_volID, inode->i_ino, + zRR_DONT_UPDATE_ACCESS_TIME, &fileKey); + if (rc != zOK) + { + pr("lsa_removexattr - zZIDOpen of file/dir failed"); + goto error_xlate; + } + + /* Delete the EA */ + rc = zDelete(fileKey, zNILXID, zNSPACE_EXTENDED_ATTRIBUTE|zMODE_UTF8, + name, 0 /*matchAttributes*/, 0 /*deleteFlags*/); + zClose(fileKey); + + /* Test the zDelete status */ + if (rc != zOK) + { + if (rc == zERR_NAME_NOT_FOUND_IN_DIRECTORY) + { + rc = -ENODATA; + pr("lsa_removexattr - existing EA not found "); + goto exit; + } + pr("lsa_removexattr - zDelete failed on EA"); + goto error_xlate; + } + +exit: + mpkExit(); + return rc; + +error_xlate: + rc = nss2linuxError(rc); + goto exit; +} + +void lsa_truncate(struct inode *inode) +{ + LsaSuper_s *super = inode->i_sb->s_fs_info; + Key_t key; + STATUS rc; + QUAD truncSize = inode->i_size; + + /* Set the inode->i_size into a local because that is the new + * truncate size, and inode i_size can change and get reset if + * someone does an get info on it + */ +pr("lsa_truncate"); + mpkEnter(); + + rc = zZIDOpen(userKey(current->fsuid), zNO_TASK, super->sb_nameSpace, + &super->sb_volID, inode->i_ino, + zRR_WRITE_ACCESS | zRR_DONT_UPDATE_ACCESS_TIME, &key); + if (rc != zOK) + { + goto exit; + } + rc = zSetEOF(key, zNILXID, truncSize, 0); + if (rc) + { + printk("<1>zSetEOF returned error = %d\n", rc); + } + zClose(key); + +exit: + mpkExit(); + return; +} + +int lsa_symlink ( + struct inode *dir, + struct dentry *dentry, + const char *symName) +{ +pr("lsa_symlink"); + return lsa_mknod_comn(dir, dentry, S_IFLNK | S_IRWXUGO, 0, symName); +} + +struct inode_operations lsa_file_inode_ops = +{ +// create: lsa_create, // int (*create) (struct inode *, + // struct dentry *,int, + // struct nameidata *); +// lookup: lsa_lookup, // struct dentry * (*lookup) (struct inode *, + // struct dentry *, + // struct nameidata *); +// link: lsa_link, // int (*link) (struct dentry *,struct inode *, + // struct dentry *); +// unlink: lsa_unlink, // int (*unlink) (struct inode *,struct dentry *); +// symlink:lsa_symlink, // int (*symlink) (struct inode *, + // struct dentry *,const char *); +// mkdir: lsa_mkdir, // int (*mkdir) (struct inode *, + // struct dentry *,int); +// rmdir: lsa_unlink, // int (*rmdir) (struct inode *, + // struct dentry *); +// mknod: lsa_mknod, // int (*mknod) (struct inode *, + // struct dentry *,int,int); +// rename: lsa_rename, // int (*rename) (struct inode *, struct dentry *, + // struct inode *, struct dentry *); + // int (*readlink) (struct dentry *, char *,int); + // int (*follow_link) (struct dentry *, struct nameidata *); + truncate: lsa_truncate, // void (*truncate) (struct inode *); + // int (*permission) (struct inode *, int); +//What do we call to replace this guy?? +// revalidate: lsa_revalidate, // int (*revalidate) (struct dentry *); + setattr: lsa_setattr, // int (*setattr) (struct dentry *, struct iattr *); + getattr: lsa_getattr, // int (*getattr) (struct vfsmount *, struct dentry *, + // struct kstat *); + setxattr: lsa_setxattr, // int (*setxattr) (struct dentry *, + // const char *, const void *, + // size_t,int); + getxattr: lsa_getxattr, // ssize_t (*getxattr) (struct dentry *, + // const char *, void *, size_t); + listxattr: lsa_listxattr, // ssize_t (*listxattr) (struct dentry *, + // char *, size_t); + removexattr: lsa_removexattr,// int (*removexattr) (struct dentry *, + // const char *); +}; +struct inode_operations lsa_dir_inode_ops = +{ + create: lsa_create, // int (*create) (struct inode *, + // struct dentry *,int, + // struct nameidata *); + lookup: lsa_lookup, // struct dentry * (*lookup) (struct inode *, + // struct dentry *, + // struct nameidata *); + link: lsa_link, // int (*link) (struct dentry *,struct inode *, + // struct dentry *); + unlink: lsa_unlink, // int (*unlink) (struct inode *,struct dentry *); + symlink:lsa_symlink, // int (*symlink) (struct inode *, + // struct dentry *,const char *); + mkdir: lsa_mkdir, // int (*mkdir) (struct inode *, + // struct dentry *,int); + rmdir: lsa_unlink, // int (*rmdir) (struct inode *, + // struct dentry *); +// mknod: lsa_mknod, // int (*mknod) (struct inode *, + // struct dentry *,int,int); + rename: lsa_rename, // int (*rename) (struct inode *, struct dentry *, + // struct inode *, struct dentry *); + // int (*readlink) (struct dentry *, char *,int); + // int (*follow_link) (struct dentry *, struct nameidata *); +// truncate: lsa_truncate, // void (*truncate) (struct inode *); + // int (*permission) (struct inode *, int); +//What do we call to replace this guy?? +// revalidate: lsa_revalidate, // int (*revalidate) (struct dentry *); + setattr: lsa_setattr, // int (*setattr) (struct dentry *, struct iattr *); + getattr: lsa_getattr, // int (*getattr) (struct vfsmount *, struct dentry *, + // struct kstat *); + setxattr: lsa_setxattr, // int (*setxattr) (struct dentry *, + // const char *, const void *, + // size_t,int); + getxattr: lsa_getxattr, // ssize_t (*getxattr) (struct dentry *, + // const char *, void *, size_t); + listxattr: lsa_listxattr, // ssize_t (*listxattr) (struct dentry *, + // char *, size_t); + removexattr: lsa_removexattr,// int (*removexattr) (struct dentry *, + // const char *); +}; + +struct inode_operations lsa_symlink_inode_operations = { + .readlink = lsa_readlink, + .follow_link = lsa_follow_link, + .setattr = lsa_setattr, + .getattr = lsa_getattr, + .setxattr = lsa_setxattr, + .getxattr = lsa_getxattr, + .listxattr = lsa_listxattr, + .removexattr = lsa_removexattr, +}; + +/*****************************************************************************/ +int lsa_d_hash( + struct dentry *dentry, + struct qstr *qstr) +{ + unsigned long hash; + const unsigned char *name = qstr->name; + +pr("lsa_d_hash"); + + hash = init_name_hash(); + while (name < &qstr->name[qstr->len]) + { + hash = partial_name_hash(utf_tolower(name, &name), hash); + } + qstr->hash = end_name_hash(hash); + + return 0; +} + +int lsa_d_compare( + struct dentry *dentry, + struct qstr *qstr1, + struct qstr *qstr2) +{ + const unsigned char *name1 = qstr1->name; + const unsigned char *name2 = qstr2->name; + +pr("lsa_d_compare"); + + /* + * The lower case version of a file name may not be the + * same length as the upper case version. + */ + while ((name1 < &qstr1->name[qstr1->len]) + && (name2 < &qstr2->name[qstr2->len])) + { + if (utf_tolower(name1, &name1) != utf_tolower(name2, &name2)) + { + return 1; + } + } + if ( (name1 != &qstr1->name[qstr1->len]) + || (name2 != &qstr2->name[qstr2->len])) + { + return 1; + } + return 0; +} + +static int lsa_d_revalidate (struct dentry *dentry, struct nameidata *nd) +{ + if (!dentry->d_inode + && nd + && !(nd->flags & LOOKUP_CONTINUE) + && (nd->flags & LOOKUP_CREATE)) { + /* + * negative dentry is dropped, in order to make sure + * to use the name which a user desires if this is + * create path. + */ + return 0; + } + return 1; +} + +struct dentry_operations lsa_dentry_ops = +{ + d_revalidate: lsa_d_revalidate, // int (*d_revalidate)(struct dentry *, + // struct nameidata *); + d_hash: lsa_d_hash, // int (*d_hash) (struct dentry *, + // struct qstr *); + d_compare: lsa_d_compare, // int (*d_compare) (struct dentry *, + // struct qstr *, struct qstr *); +// lsa_d_delete: // int (*d_delete)(struct dentry *); +// lsa_d_release: // void (*d_release)(struct dentry *); +// lsa_d_iput: // void (*d_iput)(struct dentry *, struct inode *); + +}; + +/*****************************************************************************/ diff --git a/src/nwnss/lsa/lsaSuperPool.c b/src/nwnss/lsa/lsaSuperPool.c new file mode 100644 index 0000000..102698b --- /dev/null +++ b/src/nwnss/lsa/lsaSuperPool.c @@ -0,0 +1,602 @@ +/**************************************************************************** + | + | (C) Copyright 1995 - 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: mvijai $ + | $Date: 2008-03-20 02:12:01 +0530 (Thu, 20 Mar 2008) $ + | + | $RCSfile$ + | $Revision: 2306 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | super block operations for Pools + +-------------------------------------------------------------------------*/ +//#include +#include + +#define _LOOSE_KERNEL_NAMES + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "lsa.h" + +#define ADMIN_VOL_PATH MSGNot("_ADMIN:/Volumes/") + +static int not_valid () +{ + return -EPERM; +} + +static struct file_operations lsa_pool_dir_ops = +{ +}; + +static struct inode_operations lsa_pool_inode_ops = +{ + create: not_valid, + lookup: NULL, // This blocks most operations. + link: not_valid, + unlink: not_valid, + mkdir: not_valid, + rmdir: not_valid, + rename: not_valid, + setattr:not_valid, +}; + +static struct address_space_operations lsa_pool_address_ops = +{ +}; + +#if 0 +static void lsa_print_inode_info (struct inode *inode, char *calledfrom) +{ + printk("<1>inodeprint:inode= 0x%x, %s\n", inode, calledfrom); + printk("<1>inode: i_count= %d, i_ino= %d\n", inode->i_count, inode->i_ino); + printk("<1>inode mapping: nrpages= %d\n", inode->i_mapping->nrpages); + printk("<1>inode mapping: Add nrpages= %p\n", &inode->i_mapping->nrpages); +} +#endif + +static void lsa_set_root_inode (struct inode *inode) +{ + struct super_block *sb = inode->i_sb; + +pr("lsa_set_root_inode"); + + if (inode->i_ino != zROOTDIR_ZID) + { + goto error; + } + inode->i_blkbits = sb->s_blocksize_bits; + inode->i_blksize = sb->s_blocksize; + inode->i_rdev = sb->s_dev; + inode->i_mode = S_IFDIR; + inode->i_uid = 0; + inode->i_gid = 0; + inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + inode->i_size = 0; + inode->i_blocks = 0; + inode->i_op = &lsa_pool_inode_ops; + inode->i_fop = &lsa_pool_dir_ops; + inode->i_mapping->a_ops = &lsa_pool_address_ops; + +exit: + return; + +error: + make_bad_inode(inode); + goto exit; +} + +static void lsa_put_super_pool (struct super_block *sb) +{ + struct block_device *dev = sb->s_bdev; + LsaSuper_s *super = sb->s_fs_info; + LONG rc; + + /* + * Frees the super block. Have to make sure everyone is done + * referencing it. + */ +pr("lsa_put_super_pool"); + mpkEnter(); + + zClose(super->sb_rootKey); /* This closes all keys */ + + if ((rc = MAL_RemoveDeposit ( dev )) != zOK) + { + printk("<1>""RemoveDeposit got error %d\n", rc); + } + iput(super->sb_inode); + sb->s_dirt = 0; + + free(super); + sb->s_fs_info = NULL; + mpkExit(); +} + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)) +static int lsa_pool_statfs (struct dentry *dentry, struct kstatfs *statfs) +{ + struct super_block *sb = dentry->d_sb; +#elif ((LINUX_VERSION_CODE == KERNEL_VERSION(2,6,16)) && (EXTRAVERSION > 56)) +static int lsa_pool_statfs (struct dentry *dentry, struct kstatfs *statfs) +{ + struct super_block *sb = dentry->d_sb; +#else +static int lsa_pool_statfs (struct super_block *sb, struct kstatfs *statfs) +{ +#endif + LsaSuper_s *super = sb->s_fs_info; + STATUS rc; + Key_t volKey; + QUAD totalBlocks, inUseBlocks; + + typedef struct Stack_s { + char volNameOnAdmin[zMAX_FULL_NAME]; + zInfo_s zinfo; + } Stack_s; + Stack_s *aStack; + +pr("lsa_pool_statfs"); + + mpkEnter(); + STACK_ALLOC_NO_ASTACK(); + + /* We must open the IV as stored on the ADMIN volume, + * otherwise non-active pools will get an error from zOpen and + * that results in lot of errors (in cluster environments). + * + * And, ignore ":/" from sb_volName. + */ + strcpy( aStack->volNameOnAdmin, ADMIN_VOL_PATH ); + strncat( aStack->volNameOnAdmin, super->sb_volName, + strlen(super->sb_volName) - strlen(":/") ); + + rc = zOpen(super->sb_rootKey, zNO_TASK, zNSPACE_LONG | zMODE_UTF8, + &aStack->volNameOnAdmin[0], zRR_DONT_UPDATE_ACCESS_TIME, &volKey); + if (rc) + { + printk("<1>lsa_pool_statfs: zOpen = %d\n", rc); + goto error; + } + + rc = zGetInfo(volKey, + zGET_VOLUME_INFO | zGET_POOL_INFO | zGET_VOL_SALVAGE_INFO, + LINUX_INFO_SIZE, zINFO_VERSION_A, &aStack->zinfo); + zClose(volKey); + if (rc) + { + printk("<1>lsa_pool_statfs: zGetInfo = %d\n", rc); + goto error; + } + statfs->f_type = sb->s_magic; + statfs->f_bsize = sb->s_blocksize; + totalBlocks = aStack->zinfo.pool.totalSpace >> PAGE_SHIFT; + statfs->f_blocks = totalBlocks; + + inUseBlocks = (aStack->zinfo.pool.numUsedBytes - + aStack->zinfo.pool.purgeableBytes) >> PAGE_SHIFT; + +#if 0 +printk("<1> POOL Total Pool Bytes = %lld\n", aStack->zinfo.pool.totalSpace); +printk("<1> POOL Total Pool used Bytes = %lld\n", aStack->zinfo.pool.numUsedBytes); +printk("<1> POOL Total Pool Purgeable Bytes = %lld\n", aStack->zinfo.pool.purgeableBytes); + +printk("<1> POOL total Blocks = %lld\n", totalBlocks); +printk("<1> POOL In Use Blocks = %lld\n", inUseBlocks); +#endif + + if (inUseBlocks > totalBlocks) + { + statfs->f_bfree = 0; + } + else + { + statfs->f_bfree = totalBlocks - inUseBlocks; + } + statfs->f_bavail = statfs->f_bfree; + statfs->f_files = aStack->zinfo.vol.numObjects; + statfs->f_ffree = 0; + statfs->f_fsid.val[0] = sb->s_dev; + statfs->f_fsid.val[1] = 0; + statfs->f_namelen = NAME_MAX; + +exit: + STACK_FREE(); + mpkExit(); + return 0; + +error: + statfs->f_type = sb->s_magic; + statfs->f_bsize = sb->s_blocksize; + statfs->f_blocks = 0; + statfs->f_bfree = 0; + statfs->f_bavail = 0; + statfs->f_files = 0; + statfs->f_ffree = 0; + statfs->f_fsid.val[0] = sb->s_dev; + statfs->f_fsid.val[1] = 0; + statfs->f_namelen = NAME_MAX; + goto exit; +} + +int lsa_sync_pool_fs(struct super_block *sb, int wait) +{ + LsaSuper_s *super = sb->s_fs_info; + GeneralMsg_s genMsg; + Pool_s *pool; + +pr("lsa_sync_pool_fs"); + + mpkEnter(); + MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE(&genMsg); + + if ((pool = COMN_PoolIDLookup(&genMsg, &super->sb_volID, TRUE)) == NULL) + { +// printk("<1>lsa_sync_pool_fs: poolLookup failed = %d\n", GetErrno(&genMsg)); + goto exit; + } + if (COMN_PoolActiveLock(&genMsg, pool) != zOK) + { +// printk("<1>lsa_sync_fs: poolLock failed = %d\n", GetErrno(&genMsg)); + goto exitRelease; + } + + (void)POOL_FlushPool(&genMsg, pool); + + COMN_PoolActiveUnlock(pool); +exitRelease: + COMN_Release(&pool); +exit: + MPKNSS_UNLOCK(); + mpkExit(); + return 0; + + +} +void lsa_write_super_pool(struct super_block *sb) +{ +pr("lsa_write_super_pool"); + lsa_sync_pool_fs(sb, 1); +} + +/* + * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called + * without the big kernel lock held in all filesystems. + */ +static struct super_operations LsaSuperOpsPool = +{ +// .alloc_inode = lsa_alloc_inode, +// .destroy_inode = lsa_destroy_inode, + .read_inode = lsa_set_root_inode, + // void (*dirty_inode) (struct inode *); + // void (*write_inode) (struct inode *, int); + // void (*put_inode) (struct inode *); + // void (*drop_inode) (struct inode *); + // void (*delete_inode) (struct inode *); +// .delete_inode = lsa_delete_inode, + .put_super = lsa_put_super_pool, + .write_super = lsa_write_super_pool, // void (*write_super) (struct super_block *); + .sync_fs = lsa_sync_pool_fs, // int (*sync_fs)(struct super_block *sb, int wait); + // void (*write_super_lockfs) (struct super_block *); + // void (*unlockfs) (struct super_block *); + .statfs = lsa_pool_statfs, + // int (*remount_fs) (struct super_block *, int *, char *); + // void (*clear_inode) (struct inode *); + // void (*umount_begin) (struct super_block *); + // int (*show_options)(struct seq_file *, struct vfsmount *); +}; + +STATUS lsa_pool_root (struct super_block *sb, utf8_t *volName) +{ + LsaSuper_s *super = sb->s_fs_info; + Key_t rootKey = 0; + STATUS rc; + Key_t volKey; + + typedef struct Stack_s { + char volNameOnAdmin[zMAX_FULL_NAME]; + zInfo_s zinfo; + } Stack_s; + STACK_ALLOC(); + +pr("lsa_pool_root"); + rc = zRootKey(0, &rootKey); + if (rc) + { + printk("<1>lsa_pool_root: zRootKey=%d\n", rc); + goto exit; + } + + /* size of volName (including null) passed to this function is <= + * zMAX_COMPONENT_NAME and sb_volName is of size zMAX_COMPONENT_NAME + * + 6 for _IV_:/ */ + strcpy(super->sb_volName, volName); + strcat(super->sb_volName, "_IV_:/"); + /* Aug 30, 2006 - We must open the IV as stored on the ADMIN volume, + * otherwise non-active pools will get an error from zOpen and therefore + * not get mounted. + */ + strcpy( aStack->volNameOnAdmin, ADMIN_VOL_PATH ); + strcat( aStack->volNameOnAdmin, volName ); + strcat( aStack->volNameOnAdmin, "_IV_"); + + rc = zOpen(rootKey, zNO_TASK, zNSPACE_LONG | zMODE_UTF8, + &aStack->volNameOnAdmin[0], zRR_DONT_UPDATE_ACCESS_TIME, &volKey); + if (rc) + { + printk("<1>lsa_pool_root: zOpen=%d\n", rc); + zClose(rootKey); + goto exit; + } + rc = zGetInfo(volKey, zGET_POOL_INFO, LINUX_INFO_SIZE, + zINFO_VERSION_A, &aStack->zinfo); + if (rc) + { + printk("<1>lsa_pool_root: zGetInfo=%d\n", rc); + zClose(volKey); + zClose(rootKey); + goto exit; + } + + super->sb_volID = aStack->zinfo.pool.poolID; + super->sb_rootKey = rootKey; + zClose(volKey); +exit: + STACK_FREE(); + return rc; +} + +// +///* +// * Set the shared state of the pool +// */ +//int lsa_set_pool_shared ( +// char *poolName, +// BOOL shared) +//{ +// int i; +// int rc = -1; +// +// typedef struct Stack_s { +// msgUpdateDeposit_s req; +// MALAccMsg_s msg; +// } Stack_s; +// +// STACK_ALLOC(); +// +// /* Upper case the name.*/ +// for (i = 0; poolName[i] != '\0'; i++) +// { +// poolName[i] = +// toupper(poolName[i]); +// } +// poolName[i] = '\0'; +// +// /* pool name to unicode */ +// if (utf2uni(poolName, aStack->req.name, +// sizeof(aStack->req.name)) == -1) +// { +// printk(KERN_WARNING"Error converting pool name to unicode while setting pool shared state\n"); +// goto exit; +// } +// +// /* Get the pool id */ +// aStack->req.msg.key_subid = MAL_MGR_GETID; +// MPKNSS_LOCK(); +// if((rc = ZLSSCON_Access((MALAccMsg_s *)&aStack->req)) != zOK) +// { +// printk(KERN_WARNING"Unable to get pool ID while setting pool shared state"); +// MPKNSS_UNLOCK(); +// goto exit; +// } +// +// /* Update the pool shared state in NSS */ +// aStack->msg.key_subid = MAL_MGR_CHANGESHARED; +// aStack->msg.key_opid = aStack->req.id; +// aStack->msg.ret_key = shared ? 1 : 0; +// if ((rc = ZLSSCON_Access(&aStack->msg)) != zOK) +// { +// printk(KERN_WARNING"Unable to update NSS with the pool's shared state"); +// MPKNSS_UNLOCK(); +// goto exit; +// } +// MPKNSS_UNLOCK(); +// rc = 0; +// +//exit: +// STACK_FREE(); +// return rc; +//} + +int lsa_pool_fill_super ( /* Init superblock */ + struct super_block *sb, + void *data, /* Command line */ + int isSilent) +{ + struct inode *inode = NULL; + struct block_device *dev = sb->s_bdev; + NINT sectorSize; + LsaSuper_s *super; + LONG rc, rctmp; + BOOL shared; + BOOL barrier; + unsigned int flags = 0; + typedef struct Stack_s { + char poolName[zMAX_COMPONENT_NAME]; + char snapName[zMAX_COMPONENT_NAME]; + } Stack_s; + Stack_s *aStack; + +pr("lsa_pool_fill_super"); + sectorSize = sb_min_blocksize(sb, BLOCK_SIZE); + if (sectorSize > PAGE_SIZE) + { /* + * Not going to deal with mongo sectors today + */ + return -EMEDIUMTYPE; + } + mpkEnter(); + STACK_ALLOC_NO_ASTACK(); + /* + * set_blocksize actually returns an error value but because + * fs.h says it is a void, we can't check it. It is important + * the PAGE_SIZE be a power of 2, >= sector size and <= page + * size. + */ + set_blocksize(dev, PAGE_SIZE); + sb->s_blocksize = PAGE_SIZE; + sb->s_blocksize_bits = PAGE_SHIFT; + sb->s_maxbytes = LSA_MAX_FILE_SIZE; + sb->s_magic = LSA_MAGIC_SB; + sb->s_op = &LsaSuperOpsPool; + sb->s_root = NULL; + + super = zalloc(sizeof(LsaSuper_s)); + if (super == NULL) + { + rc = -ENOMEM; + goto error; + } + if (data == NULL) + { + printf("PoolName not provided\n"); + rc = -EINVAL; + goto error; + } + + rc = LSA_GetOptions(data, aStack->poolName, zMAX_COMPONENT_NAME, &shared, NULL, &barrier, aStack->snapName); + if (rc != 0) + { + goto error; + } + super->sb_nameSpace = zNSPACE_UNIX; + super->sb_type = LSA_SB_TYPE_POOL; + + inode = iget(sb, zROOTDIR_ZID); + if (inode == NULL) + { + rc = -EIO; + goto error; + } + sb->s_root = d_alloc_root(inode); + if (sb->s_root == NULL) + { + iput(inode); + rc = -EIO; + goto error; + } + super->sb_inode = igrab(inode); // Additional use count because passing to pool + + if (shared) + { + flags |= ZLSS_DEV_FLAG_SHARED; + } + if (barrier) + { + flags |= ZLSS_DEV_FLAG_BARRIER; + } + if (aStack->snapName[0] != '\0') + { + flags |= ZLSS_DEV_FLAG_SNAPSHOT; + } + + rc = MAL_ForwardDepositToConsumer(dev, PAGE_SIZE, aStack->poolName, flags, aStack->snapName, inode); + if (rc != zOK) + { + goto error; + } + + sb->s_fs_info = super; + super->sb_super_block = sb; + + if (MAL_GetPoolNameFromDevice(dev, aStack->poolName, + zMAX_COMPONENT_NAME) != zOK) + { + printk(KERN_ERR "MAL_GetPoolNameFromDevice could not find the pool\n"); + goto errorRemoveDeposit; + } + + rc = lsa_pool_root(sb, aStack->poolName); + if (rc != zOK) + { + printk(KERN_ERR "lsa_pool_root got an error %d\n", rc); + goto errorRemoveDeposit; + } +// lsa_set_pool_shared(aStack->poolName, shared); +pr("Mounted"); +exit: + STACK_FREE(); + mpkExit(); + return rc ? nss2linuxError(rc) : 0; + +errorRemoveDeposit: + if ((rctmp = MAL_RemoveDeposit ( dev )) != zOK) + { + printk(KERN_ERR "RemoveDeposit got error %d\n", rctmp); + } + +error: + if (super) + { + zClose(super->sb_rootKey); +// zClose(super->sb_volKey); + if (super->sb_inode) + { + iput(super->sb_inode); + } + free(super); + sb->s_fs_info = NULL; + } + if (sb->s_root) + { + dput(sb->s_root); + sb->s_root = NULL; + } + goto exit; +} diff --git a/src/nwnss/lsa/lsaSuperVol.c b/src/nwnss/lsa/lsaSuperVol.c new file mode 100644 index 0000000..92548a2 --- /dev/null +++ b/src/nwnss/lsa/lsaSuperVol.c @@ -0,0 +1,1164 @@ +/**************************************************************************** + | + | (C) Copyright 1995 - 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2008-04-19 03:14:27 +0530 (Sat, 19 Apr 2008) $ + | + | $RCSfile$ + | $Revision: 2323 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | super block volume operations for LSA + +-------------------------------------------------------------------------*/ +//#include +#include + +#define _LOOSE_KERNEL_NAMES + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "lsa.h" +#include "lsaStartup.h" + +extern void lsa_ifill ( + struct inode *inode, + zInfo_s *zinfo); + +extern void lsa_info_ifill ( + struct inode *inode, + LSAInfo_s *lsaInfo); + +extern void lsa_dfill ( + struct dentry *dentry, + LsaSuper_s *super); + +/****************************************************************************/ + +struct dentry *lsa_get_parent( struct dentry *child) +{ + struct inode *inode = child->d_inode; + LsaSuper_s *super = inode->i_sb->s_fs_info; + STATUS rc; + Zid_t parentZid; + struct dentry *parent = ERR_PTR(-ENOENT); + struct inode *parentInode; + LSAInfo_s lsaInfo; + LsaInode_s *lsaInode = STRUCT(inode, LsaInode_s, li_inode); + +pr("lsa_get_parent"); + + mpkEnter(); + + if (inode->i_ino == zROOTDIR_ZID) + { + parentZid = zROOTDIR_ZID; + goto alreadyHaveIt; + } + if ((current->fsuid == 0) && (lsaInode->li_beast)) + { + parentZid = lsaInode->li_beast->FILEfirstParentZid; + goto alreadyHaveIt; + } + + rc = LSACOMN_Lookup(&super->sb_volID, inode->i_ino, + super->sb_nameSpace, NULL, &lsaInfo, lsaInode); + if (rc != zOK) + { + goto exit; + } + parentZid = lsaInfo.parentZid; + + if (parentZid == zINVALID_ZID) + { + goto exit; + } + +alreadyHaveIt: + parentInode = iget(inode->i_sb, parentZid); + if (!parentInode) + { + goto exit; + } + + parent = d_alloc_anon(parentInode); + if (!parent) + { + iput(parentInode); + parent = ERR_PTR(-ENOMEM); + } + +exit: + mpkExit(); + return parent; +} + +static struct export_operations lsa_export_ops = +{ +// decode_fh: lsa_decode_fh, // struct dentry *(*decode_fh)( + // struct super_block *sb, + // __u32 *fh, int fh_len, + // int fh_type, + // int (*acceptable)( + // void *context, + // struct dentry *de), + // void *context); +// encode_fh: lsa_encode_fh, // int (*encode_fh)(struct dentry *de, + // __u32 *fh, int *max_len, + // int connectable); + + /* the following are only called from the filesystem itself */ +// get_name: lsa_get_name, // int (*get_name)(struct dentry *parent, + // char *name, + // struct dentry *child); + get_parent: lsa_get_parent, // struct dentry * (*get_parent)( + // struct dentry *child); +// get_dentry: lsa_get_dentry, // struct dentry * (*get_dentry)( + // struct super_block *sb, + // void *inump); + + /* This is set by the exporting module to a standard helper */ +// struct dentry * (*find_exported_dentry)( + // struct super_block *sb, void *obj, + // void *parent, + // int (*acceptable)(void *context, + // struct dentry *de), + // void *context); +}; + +/****************************************************************************/ + +static kmem_cache_t *lsa_inode_cachep; + +static struct inode *lsa_alloc_inode( + struct super_block *sb) +{ + LsaInode_s *lsaInode; + +pr("lsa_alloc_inode"); + lsaInode = (LsaInode_s *)kmem_cache_alloc(lsa_inode_cachep, SLAB_KERNEL); + if (!lsaInode) + { + return NULL; + } + return &lsaInode->li_inode; +} + +static void lsa_clear_inode ( + struct inode *inode) +{ + LsaInode_s *lsaInode = STRUCT(inode, LsaInode_s, li_inode); + File_s *file; + +pr("lsa_clear_inode"); + + mpkEnter(); + MPKNSS_LOCK(); + /* the lsaInode structure is protected by the NSS spink lock */ + if (lsaInode->li_beast != NULL) + { + file = lsaInode->li_beast; + lsaInode->li_beast = NULL; + + if (file->FILEroot.rb_inode != inode) + { + if (file->FILEroot.rb_inode == NULL) + { + printk("<1> Beast Inode is NULL\n"); + } + } + else + { + file->FILEroot.rb_inode = NULL; + } + COMN_Release(&file); + } + MPKNSS_UNLOCK(); + mpkExit(); +} + +static void lsa_destroy_inode( + struct inode *inode) +{ + LsaInode_s *lsaInode = STRUCT(inode, LsaInode_s, li_inode); +// File_s *file; + +pr("lsa_destroy_inode"); + + BUG_ON(lsaInode->li_beast != NULL); + +#if 0 // clear_inode should take care of this + mpkEnter(); + MPKNSS_LOCK(); + /* the lsaInode structure is protected by the NSS spink lock */ + if (lsaInode->li_beast != NULL) + { + file = lsaInode->li_beast; + lsaInode->li_beast = NULL; + + if (file->FILEroot.rb_inode != inode) + { + if (file->FILEroot.rb_inode == NULL) + { + printk("<1> Beast Inode is NULL\n"); + } + } + else + { + file->FILEroot.rb_inode = NULL; + } + COMN_Release(&file); + } + MPKNSS_UNLOCK(); + mpkExit(); +#endif + + kmem_cache_free(lsa_inode_cachep, lsaInode); +} + +static void init_once( + void *inode, + kmem_cache_t *cachep, + unsigned long flags) +{ + LsaInode_s *lsaInode = (LsaInode_s *)inode; + + if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == + SLAB_CTOR_CONSTRUCTOR) + { + inode_init_once(&lsaInode->li_inode); + lsaInode->li_beast = NULL; + } +} + +STATUS lsa_init_inodecache(void) +{ + lsa_inode_cachep = kmem_cache_create("lsa_inode_cache", + sizeof(LsaInode_s), 0, + SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, + init_once, NULL); + if (lsa_inode_cachep == NULL) + { + return -ENOMEM; + } + return zOK; +} + +static void lsa_read_inode (struct inode *inode) +{ + LsaSuper_s *super; + STATUS rc; + LSAInfo_s lsaInfo; + LsaInode_s *lsaInode = STRUCT(inode, LsaInode_s, li_inode); + +pr("lsa_read_inode"); + + mpkEnter(); + + super = inode->i_sb->s_fs_info; + + rc = LSACOMN_Lookup(&super->sb_volID, inode->i_ino, super->sb_nameSpace, + NULL, &lsaInfo, lsaInode); + if (rc != zOK) + { + goto error; + } + lsa_info_ifill(inode, &lsaInfo); +exit: + mpkExit(); + return; + +error: + make_bad_inode(inode); + goto exit; +} + +#if 0 +static void lsa_read_inode_admin (struct inode *inode) +{ + LsaSuper_s *super; + Key_t key; + STATUS rc; + typedef struct Stack_s { + zInfo_s zinfo; + } Stack_s; + +pr("lsa_read_inode"); + + mpkEnter(); + STACK_ALLOC(); + + super = inode->i_sb->s_fs_info; + + rc = zZIDOpen(userKey(current->fsuid), zNO_TASK, super->sb_nameSpace, + &super->sb_volID, inode->i_ino, + zRR_DONT_UPDATE_ACCESS_TIME, &key); + if (rc != zOK) + { + goto error; + } + rc = zGetInfo(key, LINUX_INFO, LINUX_INFO_SIZE, zINFO_VERSION_A, + &aStack->zinfo); + zClose(key); + if (rc != zOK) + { + goto error; + } + lsa_ifill(inode, &aStack->zinfo); +exit: + STACK_FREE(); + mpkExit(); + return; + +error: + make_bad_inode(inode); + goto exit; +} +#endif + + // I'm not sure what is going on here +//static void lsa_delete_inode (struct inode *inode) +//{ +// mpkEnter(); +// +//pr(lsa_delete_inode); +// +// clear_inode(inode); +// mpkExit(); +//} + +void LSA_DeactivateVolume(VolumeID_t *volumeID) +{ + GeneralMsg_s genMsg; + Volume_s *volume; + STATUS rc; + +pr("LSA_DeactivateVolume"); + + MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE(&genMsg); + + volume = COMN_VolumeIDLookup(&genMsg, volumeID, TRUE); + if (volume == NULL) + { +// printf("Volume not found\n"); + goto exit; + } + + rc = COMN_ChangeVolumeState(&genMsg, volume, + zVOLSTATE_DEACTIVE, VOLMODE_VERBOSE); + COMN_Release(&volume); + + if (rc != zOK) + { + printf("Volume Change State failed. Error = %d\n", rc); + goto exit; + } + +exit: + MPKNSS_UNLOCK(); + return; +} + +static void lsa_put_super_vol (struct super_block *sb) +{ + LsaSuper_s *super = sb->s_fs_info; + /* + * Frees the super block. Have to make sure everyone is done + * referencing it. + */ + mpkEnter(); + +pr("lsa_put_super_vol"); + lsa_delete_super(super); + zClose(super->sb_rootKey); /* This closes all keys */ + + LSA_DeactivateVolume(&super->sb_volID); + sb->s_dirt = 0; + + sb->s_fs_info = NULL; + free(super); + mpkExit(); +} + +static void lsa_put_super_admin (struct super_block *sb) +{ + LsaSuper_s *super = sb->s_fs_info; + /* + * Frees the super block. Have to make sure everyone is done + * referencing it. + */ + mpkEnter(); + +pr("lsa_put_super_admin"); + lsa_delete_super(super); + zClose(super->sb_rootKey); /* This closes all keys */ + sb->s_fs_info = NULL; + free(super); + + mpkExit(); +} + +#define ADMIN_VOL_PATH MSGNot("_ADMIN:/Volumes/") + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)) +static int lsa_vol_statfs (struct dentry *dentry, struct kstatfs *statfs) +{ + struct super_block *sb = dentry->d_sb; +#elif ((LINUX_VERSION_CODE == KERNEL_VERSION(2,6,16)) && (EXTRAVERSION > 56)) +static int lsa_vol_statfs (struct dentry *dentry, struct kstatfs *statfs) +{ + struct super_block *sb = dentry->d_sb; +#else +static int lsa_vol_statfs (struct super_block *sb, struct kstatfs *statfs) +{ +#endif + LsaSuper_s *super = sb->s_fs_info; + STATUS rc; + QUAD inUseBlocks, totalBlocks, freeBlocks; + QUAD inUseBlocksPool, totalBlocksPool, freeBlocksPool; + Key_t volKey; + + typedef struct Stack_s { + char volNameOnAdmin[zMAX_FULL_NAME]; + zInfo_s zinfo; + } Stack_s; + Stack_s *aStack; + +pr("lsa_vol_statfs"); + + mpkEnter(); + STACK_ALLOC_NO_ASTACK(); + + /* + * Use the volume as stored on the ADMIN volume, otherwise zOpen + * errors out for non-active volumes. + * + * And, ignore ":/" from sb_volName. + */ + strcpy (aStack->volNameOnAdmin, ADMIN_VOL_PATH); + strncat (aStack->volNameOnAdmin, super->sb_volName, + strlen(super->sb_volName) - strlen(":/")); + + rc = zOpen(super->sb_rootKey, zNO_TASK, zNSPACE_LONG | zMODE_UTF8, + &aStack->volNameOnAdmin[0], + zRR_DONT_UPDATE_ACCESS_TIME, + &volKey); + if (rc != zOK) + { + printk("<1>lsa_vol_statfs: zOpen = %d\n", rc); + goto error; + } + + rc = zGetInfo( volKey, + zGET_VOLUME_INFO | zGET_POOL_INFO | zGET_VOL_SALVAGE_INFO, + LINUX_INFO_SIZE, zINFO_VERSION_A, &aStack->zinfo); + zClose(volKey); + if (rc != zOK) + { + printk("<1>lsa_vol_statfs: zGetInfo = %d\n", rc); + goto error; + } + statfs->f_type = sb->s_magic; + statfs->f_bsize = sb->s_blocksize; + + totalBlocksPool = aStack->zinfo.pool.totalSpace >> PAGE_SHIFT; + inUseBlocksPool = (aStack->zinfo.pool.numUsedBytes - + aStack->zinfo.pool.purgeableBytes) >> PAGE_SHIFT; + freeBlocksPool = (inUseBlocksPool > totalBlocksPool) ? + 0 : (totalBlocksPool - inUseBlocksPool); + + if (aStack->zinfo.vol.totalSpaceQuota == zLV_NO_QUOTA_SIZE) + { + totalBlocks = totalBlocksPool; + } + else + { + totalBlocks = aStack->zinfo.vol.totalSpaceQuota >> PAGE_SHIFT; + } + inUseBlocks = (aStack->zinfo.vol.numUsedBytes - + aStack->zinfo.vol.salvage.purgeableBytes) >> PAGE_SHIFT; + freeBlocks = (inUseBlocks > totalBlocks) ? + 0 : (totalBlocks - inUseBlocks); +#if 0 +printk("<1> Total Pool Bytes = %lld\n", aStack->zinfo.pool.totalSpace); +printk("<1> Total Volume Bytes = %lld\n", aStack->zinfo.vol.totalSpaceQuota); +printk("<1> Total Pool used Bytes = %lld\n", aStack->zinfo.pool.numUsedBytes); +printk("<1> Total Volume used Bytes = %lld\n", aStack->zinfo.vol.numUsedBytes); +printk("<1> Total Pool Purgeable Bytes = %lld\n", aStack->zinfo.pool.purgeableBytes); +printk("<1> Total Volume Purgeable Bytes = %lld\n", aStack->zinfo.vol.salvage.purgeableBytes); + +printk("<1> Total Pool Blocks = %lld\n", totalBlocksPool); +printk("<1> Pool In Use Blocks = %lld\n", inUseBlocksPool); +printk("<1> Pool Free Blocks = %lld\n", freeBlocksPool); +printk("<1> Total Volume Blocks = %lld\n", totalBlocks); +printk("<1> In Use Blocks = %lld\n", inUseBlocks); +printk("<1> Free Blocks = %lld\n", freeBlocks); +#endif + + statfs->f_blocks = totalBlocks; + statfs->f_bfree = freeBlocks; + + /* This accounts for overbooking, if you don't want to account for + * overbooking, then set f_bavail to f_bfree */ + if (freeBlocks > freeBlocksPool) + { + statfs->f_bavail = freeBlocksPool; + } + else + { + statfs->f_bavail = freeBlocks; + } + statfs->f_files = aStack->zinfo.vol.numObjects; + statfs->f_ffree = 0; + statfs->f_fsid.val[0] = sb->s_dev; + statfs->f_fsid.val[1] = 0; + statfs->f_namelen = NAME_MAX; + +exit: + STACK_FREE(); + mpkExit(); + return 0; + +error: + statfs->f_type = sb->s_magic; + statfs->f_bsize = sb->s_blocksize; + statfs->f_blocks = 0; + statfs->f_bfree = 0; + statfs->f_bavail = 0; + statfs->f_files = 0; + statfs->f_ffree = 0; + statfs->f_fsid.val[0] = sb->s_dev; + statfs->f_fsid.val[1] = 0; + statfs->f_namelen = NAME_MAX; + goto exit; +} + + +int lsa_sync_fs(struct super_block *sb, int wait) +{ + LsaSuper_s *super = sb->s_fs_info; + GeneralMsg_s genMsg; + Volume_s *volume; + +pr("lsa_sync_fs"); + + mpkEnter(); + MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE(&genMsg); + + if ((volume = COMN_VolumeIDLookup(&genMsg, &super->sb_volID, TRUE)) == NULL) + { +// printk("<1>lsa_sync_fs: volLookup failed = %d\n", GetErrno(&genMsg)); + goto exit; + } + if (COMN_LockVolumeActive(&genMsg, volume, FALSE) != zOK) + { +// printk("<1>lsa_sync_fs: volLock failed = %d\n", GetErrno(&genMsg)); + goto exitRelease; + } + + (void)VOL_FlushVolume(&genMsg, volume); + + COMN_UnlockVolumeActive(volume, FALSE); +exitRelease: + COMN_Release(&volume); +exit: + MPKNSS_UNLOCK(); + mpkExit(); + return 0; +} + +void lsa_write_super(struct super_block *sb) +{ +pr("lsa_write_super"); + lsa_sync_fs(sb, 1); +} + + +static struct super_operations LsaSuperOpsVol = +{ + .alloc_inode = lsa_alloc_inode, + .destroy_inode = lsa_destroy_inode, + .read_inode = lsa_read_inode, + // void (*dirty_inode) (struct inode *); + // void (*write_inode) (struct inode *, int); + // void (*put_inode) (struct inode *); + // void (*drop_inode) (struct inode *); +// .delete_inode = lsa_delete_inode, + .put_super = lsa_put_super_vol, + .write_super = lsa_write_super, // void (*write_super) (struct super_block *); + .sync_fs = lsa_sync_fs, // int (*sync_fs)(struct super_block *sb, int wait); + // void (*write_super_lockfs) (struct super_block *); + // void (*unlockfs) (struct super_block *); + .statfs = lsa_vol_statfs, + // int (*remount_fs) (struct super_block *, int *, char *); + .clear_inode = lsa_clear_inode, // void (*clear_inode) (struct inode *); + // void (*umount_begin) (struct super_block *); + // int (*show_options)(struct seq_file *, struct vfsmount *); +}; + +static struct super_operations LsaSuperOpsAdmin = +{ + .alloc_inode = lsa_alloc_inode, + .destroy_inode = lsa_destroy_inode, + .read_inode = lsa_read_inode, + // void (*dirty_inode) (struct inode *); + // void (*write_inode) (struct inode *, int); + // void (*put_inode) (struct inode *); + // void (*drop_inode) (struct inode *); +// .delete_inode = lsa_delete_inode, + .put_super = lsa_put_super_admin, + // void (*write_super) (struct super_block *); + // int (*sync_fs)(struct super_block *sb, int wait); + // void (*write_super_lockfs) (struct super_block *); + // void (*unlockfs) (struct super_block *); + .statfs = lsa_vol_statfs, + // int (*remount_fs) (struct super_block *, int *, char *); + .clear_inode = lsa_clear_inode, // void (*clear_inode) (struct inode *); + // void (*umount_begin) (struct super_block *); + // int (*show_options)(struct seq_file *, struct vfsmount *); +}; + +STATUS lsa_nss_root (struct super_block *sb, utf8_t *volName, BOOL isIV) +{ + LsaSuper_s *super = sb->s_fs_info; + Key_t rootKey = 0; + Key_t volKey = 0; + STATUS rc; + + typedef struct Stack_s { + zInfo_s zinfo; + } Stack_s; + STACK_ALLOC(); + +pr("lsa_nss_root"); + rc = zRootKey(0, &rootKey); + if (rc) + { + printk("<1>nss_lsa_root: zRootKey=%d\n", rc); + goto exit; + } + + /* size of volName (including null) passed to this function is <= + * zMAX_COMPONENT_NAME and sb_volName is of size zMAX_COMPONENT_NAME + * + 6 for _IV_:/ */ + strcpy(super->sb_volName, volName); + if (isIV) + { + strcat(super->sb_volName, "_IV_"); + } + strcat(super->sb_volName, ":/"); + + rc = zOpen(rootKey, zNO_TASK, zNSPACE_LONG | zMODE_UTF8, + super->sb_volName, zRR_DONT_UPDATE_ACCESS_TIME, &volKey); + if (rc) + { + printk("<1>lsa_nss_root: zOpen=%d\n", rc); + zClose(rootKey); + goto exit; + } + rc = zGetInfo(volKey, zGET_STD_INFO | zGET_VOLUME_INFO, + LINUX_INFO_SIZE, zINFO_VERSION_A, &aStack->zinfo); + if (rc) + { + printk("<1>lsa_nss_root: zGetInfo=%d\n", rc); + zClose(volKey); + zClose(rootKey); + goto exit; + } + + super->sb_volID = aStack->zinfo.std.volumeID; + super->sb_rootKey = rootKey; + if (!(sb->s_flags & MS_NOATIME)) { + if (aStack->zinfo.vol.features.enabled & zATTR_NO_ATIME) { + sb->s_flags |= MS_NOATIME; + } + } + zClose(volKey); +exit: + STACK_FREE(); + return rc; +} + +/* + * Get the options from a mount command + * Return: 0 = success + * -1 = failure because the name buffer is too small + */ +int LSA_GetOptions ( + utf8_t *options, + char *name, + int maxNameLen, + BOOL *shared, + NINT *nameSpace, + BOOL *barrier, + char *snapname) +{ +#define LSA_NAME_OPTION "name" +#define LSA_SHARED_OPTION "shared" +#define LSA_NSPACE_OPTION "ns" +#define LSA_BARRIER_OPTION "barrier" +#define LSA_NORENAME_OPTION "norename" +#define LSA_SNAPNAME_OPTION "snapname" + char *startOption; + char *endOption; + char *endOfOptions = options + strlen(options); + int optionLen; + char *optionNameEnd; + int optionNameLen; + BOOL moreOptions = TRUE; + char temp[64]; + int len; + + name[0] = '\0'; + + if (shared) + { + *shared = FALSE; + } + + if (barrier) + { + *barrier = TRUE; + } + + if (snapname) + { + snapname[0] = '\0'; + } + + /* Handle the old form where the only option was the name */ + if (LB_strstr(options, "=") == NULL && LB_strstr(options, ",") == NULL) + { + if (options[0] == '\0' || strlen(options) >= maxNameLen) + { + return -EINVAL; + } + strcpy(name, options); + return 0; + } + + /* Check each option */ + startOption = options; + while (moreOptions) + { + endOption = LB_strstr(startOption, ","); + if (endOption == NULL) + { + endOption = endOfOptions; + moreOptions = FALSE; + } + optionLen = endOption - startOption; + optionNameEnd = LB_strstr(startOption, "="); + if (optionNameEnd && (optionNameEnd < endOption)) + { + optionNameLen = optionNameEnd - startOption; + } + else + { + optionNameLen = optionLen; + } + + /* Check for name */ + if ((optionNameLen != optionLen) && + (optionNameLen == strlen(LSA_NAME_OPTION)) && + (memcmp(startOption, LSA_NAME_OPTION, optionNameLen) == 0)) + { + len = optionLen - optionNameLen - 1; + if (len >= maxNameLen) + { + return -EINVAL; + } + memcpy(name, optionNameEnd + 1, len); + name[len] = '\0'; + } + /* Check for shared */ + else if ( (optionNameLen == strlen(LSA_SHARED_OPTION)) && + (memcmp(startOption, LSA_SHARED_OPTION, optionNameLen) == 0)) + { + if (shared) + { + *shared = TRUE; + } + } + else if ((optionNameLen != optionLen) && + (optionNameLen == strlen(LSA_NSPACE_OPTION)) && + (memcmp(startOption, LSA_NSPACE_OPTION, optionNameLen) == 0)) + { + len = optionLen - optionNameLen -1; + if (len >= sizeof(temp)) + { + len = sizeof(temp) - 1; + } + memcpy(temp, optionNameEnd + 1, len); + temp[len] = '\0'; + + if (nameSpace) + { + if (strcmp(temp, "dos") == 0) + { + *nameSpace = zNSPACE_DOS; + } + else if (strcmp(temp, "mac") == 0) + { + *nameSpace = zNSPACE_MAC; + } + else if (strcmp(temp, "unix") == 0) + { + *nameSpace = zNSPACE_UNIX; + } + else if (strcmp(temp, "long") == 0) + { + *nameSpace = zNSPACE_LONG; + } + else + { + printk( KERN_INFO + "Volume Mount Name Space option %s= has unknown value: %s\n" + "Valid values are dos, mac, unix, long.\n" + "Mounted Volume will use the default UNIX nameSpace option.\n", + LSA_NSPACE_OPTION, temp); + } + } + } + else if ( (optionNameLen != optionLen) && + (optionNameLen == strlen(LSA_BARRIER_OPTION)) && + (memcmp(startOption, LSA_BARRIER_OPTION, optionNameLen) == 0)) + { + len = optionLen - optionNameLen -1; + if (len >= sizeof(temp)) + { + len = sizeof(temp) - 1; + } + memcpy(temp, optionNameEnd + 1, len); + temp[len] = '\0'; + + if (barrier) + { + if (strcmp(temp, "none") == 0) + { + *barrier = FALSE; + } + else if (strcmp(temp, "flush") == 0) + { + *barrier = TRUE; + } + else + { + printk( KERN_INFO + "Pool Mount option %s has invalid value: %s\n" + "Valid values are none and flush.\n" + "Mounted Volume will use the default barrier=flush option.\n", + LSA_BARRIER_OPTION, temp); + } + } + } + else if ( (optionNameLen == strlen(LSA_NORENAME_OPTION)) && + (memcmp(startOption, LSA_NORENAME_OPTION, optionNameLen) == 0)) + { + /* Nothing to do * norename is a valid option */ + ; + } + else if ((optionNameLen != optionLen) && + (optionNameLen == strlen(LSA_SNAPNAME_OPTION)) && + (memcmp(startOption, LSA_SNAPNAME_OPTION, optionNameLen) == 0)) + { + len = optionLen - optionNameLen - 1; + if (len >= maxNameLen) + { + return -EINVAL; + } + if (snapname) + { + memcpy(snapname, optionNameEnd + 1, len); + snapname[len] = '\0'; + } + } + else + { + if (optionNameLen >= sizeof(temp)) + { + optionNameLen = sizeof(temp) - 1; + } + memcpy(temp, startOption, optionNameLen); + temp[optionNameLen] = '\0'; + printk(KERN_INFO "Pool/volume mount has an unknown option: %s\n", temp); + } + startOption = endOption + 1; + } + + if (name[0] == '\0') + { + return -EINVAL; + } + return 0; +} + +STATUS LSA_ActivateVolume(utf8_t *volName) +{ + GeneralMsg_s genMsg; + STATUS rc = zOK; + typedef struct Stack_s { + unicode_t uniName[zMAX_COMPONENT_NAME]; + } Stack_s; + + STACK_ALLOC(); + + MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE(&genMsg); + + utf2uni(volName, aStack->uniName, sizeof(aStack->uniName)); + uniupr(aStack->uniName); + + rc = COMN_ChangeVolumeStateByName(&genMsg, aStack->uniName, + zVOLSTATE_ACTIVE, VOLMODE_VERBOSE); + if (rc != zOK) + { + rc = GetErrno(&genMsg); + printk(KERN_WARNING"Volume Change State failed. Error = %d\n", rc); + goto exit; + } + +exit: + MPKNSS_UNLOCK(); + STACK_FREE(); + return rc; +} + +int lsa_vol_fill_super ( /* Init superblock */ + struct super_block *sb, + void *data, /* Command line */ + int isSilent) +{ + struct inode *inode; + LsaSuper_s *super = NULL; + LONG rc = 0; + typedef struct Stack_s { + char volName[zMAX_COMPONENT_NAME]; + } Stack_s; + Stack_s *aStack; + NINT nameSpace = zNSPACE_LONG; // Fixed case preserving bug + //NINT nameSpace = zNSPACE_UNIX; + +pr("lsa_vol_fill_super"); + mpkEnter(); + STACK_ALLOC_NO_ASTACK(); + /* + * set_blocksize actually returns an error value but because + * fs.h says it is a void, we can't check it. It is important + * the PAGE_SIZE be a power of 2, >= sector size and <= page + * size. + */ + sb->s_blocksize = PAGE_SIZE; + sb->s_blocksize_bits = PAGE_SHIFT; + sb->s_maxbytes = LSA_MAX_FILE_SIZE; + sb->s_magic = LSA_MAGIC_SB; + sb->s_op = &LsaSuperOpsVol; + sb->s_export_op = &lsa_export_ops; + sb->s_fs_info = NULL; + + super = zalloc(sizeof(LsaSuper_s)); + if (super == NULL) + { + rc = -ENOMEM; + goto error; + } + if (data == NULL) + { + rc = -EINVAL; + goto error; + } + + rc = LSA_GetOptions(data, aStack->volName, zMAX_COMPONENT_NAME, NULL, &nameSpace, NULL, NULL); + if (rc != 0) + { + goto error; + } + super->sb_nameSpace = nameSpace; + super->sb_type = LSA_SB_TYPE_VOLUME; + + rc = LSA_ActivateVolume(aStack->volName); + if (rc != zOK) + { + if (rc == zERR_VOLUME_NOT_FOUND || + rc == zERR_BAD_VOLUME_NAME) + { + rc = -EINVAL; + goto error; + } + goto errorConvert; + } + sb->s_fs_info = super; + super->sb_super_block = sb; + rc = lsa_nss_root(sb, aStack->volName, FALSE); + if (rc != zOK) + { + goto errorConvert; + } + inode = iget(sb, zROOTDIR_ZID); + if (inode == NULL) + { + rc = -EIO; + goto error; + } + sb->s_root = d_alloc_root(inode); + if (sb->s_root == NULL) + { + rc = -EIO; + goto error; + } + lsa_dfill(sb->s_root, super); + lsa_add_super(super); +pr("Mounted"); + +exit: + STACK_FREE(); + mpkExit(); + return rc; + +errorConvert: + rc = nss2linuxError(rc); +error: + if (super) + { + sb->s_fs_info = NULL; + zClose(super->sb_rootKey); +// zClose(super->sb_volKey); + free(super); + } + goto exit; +} + + +int lsa_admin_fill_super ( /* Init superblock */ + struct super_block *sb, + void *data, /* Command line */ + int isSilent) +{ + struct inode *inode; + LsaSuper_s *super = NULL; + LONG rc = 0; + BOOL mpk = FALSE; + +pr("lsa_admin_fill_super"); + + mpkEnter(); mpk = TRUE; + /* + * set_blocksize actually returns an error value but because + * fs.h says it is a void, we can't check it. It is important + * the PAGE_SIZE be a power of 2, >= sector size and <= page + * size. + */ + sb->s_blocksize = PAGE_SIZE; + sb->s_blocksize_bits = PAGE_SHIFT; + sb->s_maxbytes = LSA_MAX_FILE_SIZE; + sb->s_magic = LSA_MAGIC_SB; + sb->s_op = &LsaSuperOpsAdmin; + + super = zalloc(sizeof(LsaSuper_s)); + if (super == NULL) + { + rc = -ENOMEM; + goto error; + } + super->sb_nameSpace = zNSPACE_UNIX; + super->sb_type = LSA_SB_TYPE_ADMIN; + + sb->s_fs_info = super; + super->sb_super_block = sb; + /* Currently we do not have any options that we support for admin + * volume, so the data (command line is ignored, and instead just the + * name "_ADMIN" is passed on in the data field + */ + rc = lsa_nss_root(sb, data, FALSE); + if (rc != zOK) + { + goto error; + } + inode = iget(sb, zROOTDIR_ZID); + if (inode == NULL) + { + rc = -EIO; + goto error; + } + mpkExit(); mpk = FALSE; + + sb->s_root = d_alloc_root(inode); + if (sb->s_root == NULL) + { + rc = -EIO; + goto error; + } + lsa_dfill(sb->s_root, super); + lsa_add_super(super); + +pr("Mounted"); +exit: + return rc ? nss2linuxError(rc) : 0; + +error: + if (super) + { + if (!mpk) + { + mpkEnter(); mpk = TRUE; + } + sb->s_fs_info = NULL; + zClose(super->sb_rootKey); +// zClose(super->sb_volKey); + free(super); + } + if (mpk) mpkExit(); + + goto exit; +} + +/*****************************************************************************/ + diff --git a/src/nwnss/lsa/lsaUser.c b/src/nwnss/lsa/lsaUser.c index 73cc7fb..f815795 100644 --- a/src/nwnss/lsa/lsaUser.c +++ b/src/nwnss/lsa/lsaUser.c @@ -34,9 +34,8 @@ | This module is used to: | Manage Linux users +-------------------------------------------------------------------------*/ -#include -#include -#include +#include // printk +#include #include #include #include @@ -75,7 +74,7 @@ struct User_s }; static User_s *Users[USER_HASH]; -static spinlock_t User_lock; +static spinlock_t User_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; static SQhead_t Deleted_users = { NULL, (SQlink_t)&Deleted_users }; static BOOL registeredConnectionCallbacks = FALSE; @@ -137,7 +136,7 @@ exit: /* * addUser has to check if this user was added by another thread * while we were setting up this user. - */ + */ static User_s *addUserToHash (User_s *new) { NINT hash = HASH(new->u_uid); @@ -236,7 +235,7 @@ static User_s *allocUser () { user = NULL; } - } + } spin_unlock( &User_lock); if (user) @@ -268,7 +267,7 @@ static void freeUser (User_s *user) } /**************************************************************************** - * Create a new User_s structure for the specified uid and add it to the + * Create a new User_s structure for the specified uid and add it to the * user hash. *****************************************************************************/ static void userNew (LONG uid) @@ -355,14 +354,14 @@ static void userNew (LONG uid) if (status != zOK) { printk("<1>" "**** Couldn't create a connection for uid %d, status=%d\n", uid, status); - goto error; + goto error; } // printk("<1>" "**** back from COMN_CreatePSSConnection, status = %d\n", status); /* Now, get the root key for this user. We have to do this last, - * becaue zRootKey needs to resolve the connection by UID, and + * becaue zRootKey needs to resolve the connection by UID, and * the connection is now created and added ... */ if ((status = zRootKey(uid, &user->u_rootKey)) != 0) { @@ -455,7 +454,7 @@ STATUS GetLinuxAuthIDsList( User_s *user; size_t guidSEVCount; GUID_t *guidSEV = NULL; - + ASSERT_MPKNSS_LOCK(); /* Pre-init in case of errors */ @@ -465,7 +464,7 @@ STATUS GetLinuxAuthIDsList( /* Locate the User structure */ // printk("<1>" "**** GetLinuxAuthIDsList(Enter, uid=%d)\n", uid); user = lookupUser(uid); - if (!user) + if (!user) { printk(KERN_INFO "Unable to find user for uid (%d) while getting ID list.\n", uid); status = zERR_NOT_CONNECTED; @@ -521,7 +520,7 @@ STATUS GetLinuxAuthIDsList( // { // printk("<1>" "GUID %d = 0x%8x 0x%8x 0x%8x 0x%8x\n", idx, (GUID_t)*(*AuthIDList+idx)); // } -// } +// } // printk("<1>" "**** GetLinuxAuthIDsList(Exit - success)\n"); return(zOK); @@ -540,14 +539,14 @@ errorExit: *AuthIDList = NULL; } return(status); - + } /**************************************************************************** * Given a uid, return TRUE if the uid is Supervisor equivalent * * This is a callback function, provided by this LSA, and called by the - * common layer code. The common layer uses this to find out if a + * common layer code. The common layer uses this to find out if a * connectionID (uid) is supervisor equivalent. * *****************************************************************************/ @@ -670,7 +669,7 @@ Key_t userKey (LONG uid) LinuxConnectionCallbackFunctions_s callbackFuncs; - /* On the first time in, make sure the common layer callbacks are + /* On the first time in, make sure the common layer callbacks are * registered. */ if (!registeredConnectionCallbacks) @@ -729,3 +728,5 @@ void userShutdown (void) } } } + + diff --git a/src/nwnss/lsa/lsaVersion.c b/src/nwnss/lsa/lsaVersion.c new file mode 100644 index 0000000..5a36439 --- /dev/null +++ b/src/nwnss/lsa/lsaVersion.c @@ -0,0 +1,47 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1998 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Holds build number for the given product + | + +-------------------------------------------------------------------------*/ +#include + +VersionInformation_s LSA_VersionInfo = +{ + ZMAJV, + ZMINV, + ZSUBV, + ZBLDN, + VERINFO_NO_PATENT +}; diff --git a/src/nwnss/lsa/lsaXattr.c b/src/nwnss/lsa/lsaXattr.c index 0e729e7..e5c68a1 100644 --- a/src/nwnss/lsa/lsaXattr.c +++ b/src/nwnss/lsa/lsaXattr.c @@ -34,17 +34,15 @@ | This module is used to: | Implement "netware." name space for extended attributes. +-------------------------------------------------------------------------*/ -#include -#include -#include +#include #define _LOOSE_KERNEL_NAMES +#include //#include //#include //#include -#include #include #include #include @@ -58,40 +56,16 @@ #include #include #include -#include #include #include #include -#include - -#ifdef NSS_USERSPACE -static void -mpkEnter(void) -{ -} -static void -mpkExit(void) -{ -} -static struct { - LONG fsuid; -} nssLsaCurrent = { 0 }; -#define current (&nssLsaCurrent) -#endif +#include "lsaPrivate.h" #ifndef ENOATTR #define ENOATTR ENODATA #endif -#ifdef NSS_USERSPACE -#define LSA_XATTR_INODE_PRIVATE(_inode) \ - NssLsaXattrUserspaceInodePrivate((_inode)) -#else -#define LSA_XATTR_INODE_PRIVATE(_inode) \ - STRUCT((_inode), LsaInode_s, li_inode) -#endif - /* xattr_get_ncpstat: gets attributes used by NCP */ int xattr_get_ncpstat ( struct dentry *dentry, @@ -101,7 +75,7 @@ int xattr_get_ncpstat ( { struct inode *inode = dentry->d_inode; LsaSuper_s *super = inode->i_sb->s_fs_info; - LsaInode_s *lsaInode = LSA_XATTR_INODE_PRIVATE(inode); + LsaInode_s *lsaInode = STRUCT(inode, LsaInode_s, li_inode); zNW_ncpstat_s *ncpstat = value; LSAInfo_s lsaInfo; int rc; @@ -148,6 +122,7 @@ error: mpkExit(); return rc; } + /* xattr_set_ncpstat: sets attributes used by NCP */ int xattr_set_ncpstat ( struct dentry *dentry, @@ -201,7 +176,7 @@ pr("xattr_set_ncpstat"); aStack->zinfo.time.accessed = ncpstat->nws_accessed; } rc = LSACOMN_ModifyInfo(&super->sb_volID, super->sb_nameSpace, - inode->i_ino, infoMask, sizeof(zInfo_s), + inode->i_ino, infoMask, sizeof(zInfo_s), zINFO_VERSION_A, &aStack->zinfo); if (rc != zOK) { @@ -239,6 +214,7 @@ error: mpkExit(); return rc ? nss2linuxError(rc) : 0; } + /* * xattr_get_quota: gets the lesser of user's quota and * directory space restriction @@ -251,7 +227,7 @@ int xattr_get_quota ( { struct inode *inode = dentry->d_inode; LsaSuper_s *super = inode->i_sb->s_fs_info; - LsaInode_s *lsaInode = LSA_XATTR_INODE_PRIVATE(inode); + LsaInode_s *lsaInode = STRUCT(inode, LsaInode_s, li_inode); zNW_quota_s *quota = value; GUID_t guid; GUID_t *gp = NULL; @@ -278,9 +254,10 @@ pr("xattr_get_quota"); rc = LSACOMN_Quotas( &super->sb_volID, inode->i_ino, super->sb_nameSpace, lsaInode, gp, quota); - mpkExit(); + mpkExit(); return rc ? nss2linuxError(rc) : sizeof(*quota); } + /* * xattr_get_metadata: returns file metadata and trustees for back-up. */ @@ -292,7 +269,7 @@ int xattr_get_metadata ( { struct inode *inode = dentry->d_inode; LsaSuper_s *super = inode->i_sb->s_fs_info; - LsaInode_s *lsaInode = LSA_XATTR_INODE_PRIVATE(inode); + LsaInode_s *lsaInode = STRUCT(inode, LsaInode_s, li_inode); zNW_metadata_s *metadata = value; NINT size = val_size; int rc; @@ -303,9 +280,10 @@ pr("xattr_get_metadata"); rc = LSACOMN_Metadata( &super->sb_volID, inode->i_ino, super->sb_nameSpace, lsaInode, &size, metadata); - mpkExit(); + mpkExit(); return rc ? nss2linuxError(rc) : size; } + int xattr_set_metadata ( struct dentry *dentry, const char *name, @@ -433,7 +411,7 @@ pr("xattr_set_metadata"); } rc = LSACOMN_ModifyInfo(&super->sb_volID, super->sb_nameSpace, - inode->i_ino, infoMask, info_size, + inode->i_ino, infoMask, info_size, zINFO_VERSION_C, zinfo); if (rc != zOK) { @@ -478,6 +456,7 @@ error: mpkExit(); return rc ? nss2linuxError(rc) : 0; } + int xattr_get_volumeinfo ( struct dentry *dentry, const char *name, @@ -506,7 +485,7 @@ pr("xattr_get_volumeinfo"); { return -ERANGE; } - + mpkEnter(); STACK_ALLOC_NO_ASTACK(); @@ -533,9 +512,10 @@ pr("xattr_get_volumeinfo"); exit: STACK_FREE(); - mpkExit(); + mpkExit(); return rc ? nss2linuxError(rc) : size; } + int xattr_get_userquota ( struct dentry *dentry, const char *name, @@ -580,7 +560,7 @@ int xattr_get_userquota ( userCount = zMAX_XATTR_USERS; } - size = offsetof(zNW_user_quota_s, nwuq_user) + + size = offsetof(zNW_user_quota_s, nwuq_user) + userCount * sizeof(zNW_user_restriction_s); if (value == NULL) @@ -625,11 +605,11 @@ int xattr_get_userquota ( MPKNSS_LOCK(); for (i = 0; i < userCount; i++) { - userQuota->nwuq_user[i].nwur_restriction = + userQuota->nwuq_user[i].nwur_restriction = userEntries[i].restrictionAmount; userQuota->nwuq_user[i].nwur_reserved_2 = 0; #if 0 - rc = COMN_MapNDSGUIDToName( &userEntries[i].userID, + rc = COMN_MapNDSGUIDToName( &userEntries[i].userID, sizeof(userQuota->nwuq_user[i].nwur_dnsname), userQuota->nwuq_user[i].nwur_dnsname); if (rc != 0) @@ -648,9 +628,10 @@ int xattr_get_userquota ( free(userEntries); exit: - mpkExit(); + mpkExit(); return rc ? nss2linuxError(rc) : size; } + int xattr_set_userquota ( struct dentry *dentry, const char *name, @@ -681,7 +662,7 @@ pr("xattr_set_userquota"); { return -EFAULT; } - + if ((userQuota->nwuq_byteorder != zNW_BYTEORDER) || (userQuota->nwuq_version != zNW_METADATA_VERSION)) { @@ -726,6 +707,7 @@ error: mpkExit(); return rc ? nss2linuxError(rc) : size; } + #if 0 int xattr_get_trustee ( struct dentry *dentry, @@ -745,7 +727,7 @@ int xattr_get_trustee ( NINT userCount = 0; NINT startUser; zNW_trustee_name_s *trustee = value; - ACLEntry_s *acl_list; + ACLEntry_s *acl_list; pr("xattr_get_trustee"); @@ -765,7 +747,7 @@ pr("xattr_get_trustee"); rc = zZIDOpen(userKey(current->fsuid), zNO_TASK, nameSpace, &super->sb_volID, inode->i_ino, - zRR_DONT_UPDATE_ACCESS_TIME, &fileKey); + zRR_DONT_UPDATE_ACCESS_TIME, &fileKey); if (rc != 0) { goto exit; @@ -787,7 +769,7 @@ pr("xattr_get_trustee"); userCount = zMAX_XATTR_USERS; } - size = offsetof(zNW_trustee_name_s, nwtn_user) + + size = offsetof(zNW_trustee_name_s, nwtn_user) + userCount * sizeof(zNW_user_trustee_s); if (value == NULL) @@ -835,7 +817,7 @@ printk("usercount = %d\n", userCount); } trustee->nwtn_user[j].nwut_rights = acl_list[i].rights; trustee->nwtn_user[j].nwut_reserved_2 = 0; - rc = COMN_MapNDSGUIDToName( &acl_list[i].trusteeID, + rc = COMN_MapNDSGUIDToName( &acl_list[i].trusteeID, sizeof(trustee->nwtn_user[j].nwut_dnsname), trustee->nwtn_user[j].nwut_dnsname); j++; @@ -856,6 +838,7 @@ exit: return rc ? nss2linuxError(rc) : size; } + int xattr_set_trustee ( struct dentry *dentry, const char *name, @@ -922,10 +905,10 @@ int xattr_remove_metadata ( struct inode *inode = dentry->d_inode; LsaSuper_s *super = inode->i_sb->s_fs_info; - typedef struct Stack_s { - GeneralMsg_s genMsg; - NamingMsg_s nameMsg; - UserID_t userID; + typedef struct Stack_s { + GeneralMsg_s genMsg; + NamingMsg_s nameMsg; + UserID_t userID; } Stack_s; Stack_s *aStack; @@ -938,7 +921,7 @@ int xattr_remove_metadata ( COMN_SETUP_GENERAL_MSG_NOSA(&aStack->genMsg); COMN_INIT_NAMING_MSG(&aStack->nameMsg); - COMN_SETUP_NAMING_MSG_VOLUME_ZID( &aStack->nameMsg, super->sb_volID, + COMN_SETUP_NAMING_MSG_VOLUME_ZID( &aStack->nameMsg, super->sb_volID, zINVALID_ZID, inode->i_ino, inode->i_ino, XLATCHED, super->sb_nameSpace, zNTYPE_FILE, NULL); @@ -953,7 +936,7 @@ int xattr_remove_metadata ( for(;;) { sequence = 0; - if (COMN_ZAS_getACLEntry(&aStack->genMsg, &aStack->nameMsg, &sequence, + if (COMN_ZAS_getACLEntry(&aStack->genMsg, &aStack->nameMsg, &sequence, &aStack->userID, &rights, &attributes) != zOK) { rc = GetErrno(&aStack->genMsg); @@ -965,7 +948,7 @@ int xattr_remove_metadata ( } /* actually remove the trustee */ - if (COMN_ZAS_removeACLEntry(&aStack->genMsg, &aStack->nameMsg, + if (COMN_ZAS_removeACLEntry(&aStack->genMsg, &aStack->nameMsg, &aStack->userID, FALSE) != zOK) { rc = GetErrno(&aStack->genMsg); @@ -980,12 +963,13 @@ exit: mpkExit(); return rc ? nss2linuxError(rc) : 0; } + int xattr_remove_userquota ( struct dentry *dentry, const char *name) { - /* Should this routine remove all the user space restrictions on the - * volume? + /* Should this routine remove all the user space restrictions on the + * volume? */ return 0; #if 0 @@ -1021,7 +1005,7 @@ int xattr_remove_userquota ( { goto exit; } - + MPKNSS_LOCK(); for (i = 0; i < userReturned; i++) { @@ -1043,6 +1027,7 @@ exit: return rc ? nss2linuxError(rc) : 0; #endif } + typedef int (*xget_f)( struct dentry *dentry, const char *name, @@ -1091,6 +1076,7 @@ Xattr_s *xattr_lookup (const char *name) } return NULL; } + /* netware_getxattr: call the get function for the named attribute */ ssize_t netware_getxattr ( struct dentry *dentry, @@ -1113,6 +1099,7 @@ pr("netware_getxattr"); return xattr->x_get(dentry, name, value, size); } + /* netware_setxattr: call the set function for the named attribute */ ssize_t netware_setxattr ( struct dentry *dentry, @@ -1134,6 +1121,7 @@ pr("netware_setxattr"); } return xattr->x_set(dentry, name, value, size); } + int netware_removexattr ( struct dentry *dentry, const char *name) @@ -1152,3 +1140,4 @@ pr("netware_removexattr"); } return xattr->x_remove(dentry, name); } + diff --git a/src/nwnss/manage/Makefile b/src/nwnss/manage/Makefile new file mode 100644 index 0000000..d893324 --- /dev/null +++ b/src/nwnss/manage/Makefile @@ -0,0 +1,32 @@ +### +### ../nss/public_core/manage Makefile +### + +############################################################################## +# +# (C) Copyright 2004 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +BASEDIR=../.. + +SUBDIRS= \ + +include ${BASEDIR}/buildtools/Makefile.default + diff --git a/src/nwnss/manage/Module.supported b/src/nwnss/manage/Module.supported new file mode 100644 index 0000000..f000c18 --- /dev/null +++ b/src/nwnss/manage/Module.supported @@ -0,0 +1,2 @@ +nssmanage.ko + diff --git a/src/nwnss/manage/manage.c b/src/nwnss/manage/manage.c new file mode 100644 index 0000000..cc4de73 --- /dev/null +++ b/src/nwnss/manage/manage.c @@ -0,0 +1 @@ +#include diff --git a/src/nwnss/manage/manageAFP.c b/src/nwnss/manage/manageAFP.c new file mode 100644 index 0000000..f408955 --- /dev/null +++ b/src/nwnss/manage/manageAFP.c @@ -0,0 +1,394 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage CIFS using XML + | + +-------------------------------------------------------------------------*/ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "manage.h" +#include "manageNlm.h" +#include "manageStartup.h" +#include "xmlTags.h" + + +/* Processor function prototypes */ +STATUS MNSS_AFPGetServerConfiguration(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_AFPSetServerConfiguration(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + + +/* Tag to function mapping */ +SiblingElements_s AFPElements[] = +{ + {TAG_GETSERVERCONFIGURATION, MNSS_AFPGetServerConfiguration}, + {TAG_SETSERVERCONFIGURATION, MNSS_AFPSetServerConfiguration}, + {0} +}; + +#define AFP_NLM MSGNot("\x0A" "AFPTCP.NLM") + +/**************************************************************************** + * + *****************************************************************************/ +void AFPAddStatus( + VirtInfo_s *virtInfo, + STATUS status) +{ + switch (status) + { + case zOK: + MNSS_BuildResult(virtInfo, status, "zOK"); + break; + + case zERR_NO_MEMORY: + MNSS_BuildResult(virtInfo, status, "Out of memory"); + break; + + case zERR_BAD_PARAMETER_VALUE: + MNSS_BuildResult(virtInfo, status, "Bad parameter"); + break; + + case zERR_END_OF_FILE: + MNSS_BuildResult(virtInfo, status, "End of file reached"); + break; + + case zERR_XML_IS_BAD: + MNSS_BuildResult(virtInfo, status, "XML request is bad"); + break; + + case zERR_OBJECT_NOT_FOUND: + MNSS_BuildResult(virtInfo, status, "Context not found"); + break; + + case zERR_AFP_NLM_NOT_LOADED: + MNSS_BuildResult(virtInfo, status, "The AFP NLM is not currently loaded"); + break; + + case zERR_AFP_INVALID_MODIFY_PARAMS: + MNSS_BuildResult(virtInfo, status, "The parameters to AFP_SetServerConfiguration are not valid for this server type"); + break; + + case zERR_AFP_NLM_FAILED_TO_UNLOAD: + MNSS_BuildResult(virtInfo, status, "An attempt to unload the AFP NLMs failed"); + break; + + default: + if (status < 0) + { + MNSS_BuildResult(virtInfo, status, "NDS Error"); + } + else + { + MNSS_BuildResult(virtInfo, status, "Failure"); + } + break; + } +} + + +/**************************************************************************** + * + *****************************************************************************/ +STATUS MNSS_AFPGetServerConfiguration( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status = zOK; + + ASSERT_MPKNSS_LOCK(); + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* isOnline */ + if (ZOS_IsNLMLoaded(AFP_NLM) != 0) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_ISONLINE, + NULL, FALSE)) != zOK) + { + return status; + } + } + + AFPAddStatus(virtInfo, status); + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} + + +/************************************************************************** + * Thread to load AFP nlms + ***************************************************************************/ +void LoadAfpNlmsThread( + FsmLite_s *fsm, + ADDR *parms) +{ + STATUS status; + + status = LoadAfpNlms(); + if (status != zOK) + { + aprintf(LRED, "Error %d doing background AFPSTRT.NCF\n", status); + } + zASSERT(status == zOK); + free(fsm); +} + + +/**************************************************************************** + * Load the AFP NLMs + *****************************************************************************/ +STATUS LoadAfpNlms() +{ + STATUS status; + char tmpBuf[zMAX_COMPONENT_NAME]; + NINT idx = 0; + + + ASSERT_MPKNSS_LOCK(); + + if (ZOS_IsNLMLoaded(AFP_NLM) == 0) + { + LB_strcpy(tmpBuf, MSGNot("AFPSTRT")); + ZOS_ParseCommand(tmpBuf); + } + + /* Give the AFP NLM time to load before saying it worked/failed */ + while ((ZOS_IsNLMLoaded(AFP_NLM) == 0) && (idx < 5)) + { + LB_delay(1000); + idx++; + } + + /* See if we can access the public APIs */ + if (ZOS_IsNLMLoaded(AFP_NLM) == 0) + { + status = zERR_AFP_NLM_NOT_LOADED; + goto functionExit; + } + + status = zOK; + +functionExit: + return(status); +} + +/************************************************************************** + * Thread to unload AFP nlms + ***************************************************************************/ +void UnloadAfpNlmsThread( + FsmLite_s *fsm, + ADDR *parms) +{ + STATUS status; + + status = UnloadAfpNlms(); + if (status != zOK) + { + aprintf(LRED, "Error %d doing background AFPSTOP.NCF\n", status); + } + zASSERT(status == zOK); + free(fsm); +} + +/**************************************************************************** + * Shutdown the AFP NLMs + *****************************************************************************/ +STATUS UnloadAfpNlms() +{ + STATUS status; + char tmpBuf[zMAX_COMPONENT_NAME]; + NINT idx = 0; + + /* Only try to unload the NLM if it is actually loaded */ + if (ZOS_IsNLMLoaded(AFP_NLM) != 0) + { + /* make temporary copy of command line, as ParseCommand munges it */ + strcpy(tmpBuf, MSGNot("AFPSTOP")); + ZOS_ParseCommand(tmpBuf); + + /* Give AFP time to exit and unload. Test for 5 seconds. */ + while ((ZOS_IsNLMLoaded(AFP_NLM) != 0) && (idx < 5)) + { + LB_delay(1000); + idx++; + } + + if (ZOS_IsNLMLoaded(AFP_NLM) != 0) + { + status = zERR_AFP_NLM_FAILED_TO_UNLOAD; + goto functionExit; + } + } + status = zOK; + +functionExit: + return status; +} + +/**************************************************************************** + * + *****************************************************************************/ +STATUS MNSS_AFPSetServerConfiguration( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status = zOK; + BOOL modAfpOnlineStatus; + BOOL afpOnline; + FsmLite_s *fsm; +#if NSS_DEBUG IS_ENABLED + STATIC NINT fsmInstance = 0; +#endif + + + const TagRequest_s tags[] = + { + {TAG_ISONLINE, TR_OPTIONAL}, + {0} + }; + + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + ISONLINE = 0, + }; + + ASSERT_MPKNSS_LOCK(); + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* Read out the tags */ + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + goto AddStatus; + } + + /* If there is a new isOnline specified */ + if (tagContent[ISONLINE].flags & TR_TAG_FOUND) + { + modAfpOnlineStatus = TRUE; + + if (XML_GetTagAttribute(ATR_ENABLED, + &tagContent[ISONLINE].element) != zOK) + { + status = zERR_AFP_INVALID_MODIFY_PARAMS; + goto AddStatus; + } + if ((tagContent[ISONLINE].element.attributeValueLen == 3) && + (memcmp(tagContent[ISONLINE].element.attributeValueStart, + MSGNot("yes"),3) == 0)) + { + afpOnline = TRUE; + } + else if ((tagContent[ISONLINE].element.attributeValueLen == 2) && + (memcmp(tagContent[ISONLINE].element.attributeValueStart, + MSGNot("no"),2) == 0)) + { + afpOnline = FALSE; + } + else + { + status = zERR_AFP_INVALID_MODIFY_PARAMS; + goto AddStatus; + } + } + + /* If we need to modify AUTOEXEC.NCF and load/unload AFP, do it now */ + if (modAfpOnlineStatus) + { + status = ModifyNFAPAutoExec( FALSE, afpOnline ); + + if (status == zOK) + { + fsm = malloc(sizeof(FsmLite_s)); + if (fsm == NULL) + { + status = zERR_NO_MEMORY; + goto AddStatus; + } + + /* Now, put AFP in the desired state */ + if (afpOnline) + { + /* Schedule separate thread to load AFP nlms */ + FSMLITE_INIT(fsm, "FSM for loading AFP nlms", ++fsmInstance); + WORK_Schedule(fsm, LoadAfpNlmsThread, NULL); + status = zOK; + } + else + { + /* Schedule separate thread to unload AFP nlms */ + FSMLITE_INIT(fsm, "FSM for unloading AFP nlms", ++fsmInstance); + WORK_Schedule(fsm, UnloadAfpNlmsThread, NULL); + status = zOK; + } + } + } + + +AddStatus: + AFPAddStatus(virtInfo, status); + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} diff --git a/src/nwnss/manage/manageAdapter.c b/src/nwnss/manage/manageAdapter.c new file mode 100644 index 0000000..f2efe9c --- /dev/null +++ b/src/nwnss/manage/manageAdapter.c @@ -0,0 +1,398 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2006-12-30 03:27:16 +0530 (Sat, 30 Dec 2006) $ + | + | $RCSfile$ + | $Revision: 1799 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage NSS using XML + | + +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "manage.h" +#include "manageNlm.h" +#include "manageStartup.h" +#include "comnPublics.h" +#include "comnAuthorize.h" +#include "virtualIO.h" +#include "xmlTags.h" + + +STATUS MNSS_ProcessGetAdapterInfo(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ + +SiblingElements_s AdapterElements[] = +{ + {TAG_GETADAPTERINFO, MNSS_ProcessGetAdapterInfo}, + {0} +}; + + +/**************************************************************************** + * + * This function gets an adapter's information. + * + ****************************************************************************/ +STATUS MNSS_ProcessGetAdapterInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_ADAPTERID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + ADAPTER_ID = 0 + }; + + OBID adapterID; + LONG ccode = MM_OK; + STATUS status; + struct Adapter_Info_s adapterPlusInfo; + utf8_t tempBuf[512] = ""; + NINT idx; + BOOL infoTagAdded = FALSE; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + MNSS_LoadSubSystemIDs(); + + // Get the specific information on the adapter. + adapterID = atol(tagContent[ADAPTER_ID].content); + + MPKNSS_UNLOCK(); + + // Get the sub system id. + ccode = MM_ReturnObjectSpecificInfo(adapterID, sizeof(struct AdapterSpecificInfoDef), + &adapterPlusInfo); + + MPKNSS_LOCK(); + + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, TAG_ADAPTERINFO, ccode, + MSGNot("Error getting adapter specific info")); + goto exit; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_ADAPTERINFO, + FALSE, TRUE)) != zOK) + { + goto exit; + } + + sprintf(tempBuf, + "<"TAG_ADAPTERID">%u" + "<"TAG_NAME">%s" + "<"TAG_ADAPTERDRIVERID">%u" + "<"TAG_ADAPTERDRIVERNAME">%s" + "<"TAG_ADAPTERNUMBER">%u" + "<"TAG_ADAPTERSLOT">%u", + adapterID, + adapterPlusInfo.aInfo.systemname, + adapterPlusInfo.aInfo.assigneddriverid, + adapterPlusInfo.aInfo.drivername, + adapterPlusInfo.aInfo.adapternumber, + adapterPlusInfo.aInfo.configinfo.CSlot); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + + // Check if we want to return the sub-system type. + if (adapterPlusInfo.aInfo.subsystemid == NWPASubSystemID) + { + sprintf(tempBuf, + "<"TAG_ADAPTERSUBSYSTEMID">NWPA"); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + } + else if (adapterPlusInfo.aInfo.subsystemid == CIOSSubSystemID) + { + sprintf(tempBuf, + "<"TAG_ADAPTERSUBSYSTEMID">CIOS"); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + } + + // Check if need to add primary and secondary interrupts. + infoTagAdded = FALSE; + for (idx = 0 ; idx < 2 ; idx++) + { + if (adapterPlusInfo.aInfo.configinfo.CIntLine[idx] == 0xFF) + { + continue; + } + + if (infoTagAdded == FALSE) + { + infoTagAdded = TRUE; + + if ((ccode = VIRT_AddResultData(virtInfo, "<"TAG_ADAPTERINTERRUPTINFO">")) != zOK) + { + goto exit; + } + } + + sprintf(tempBuf, + "<"TAG_ADAPTERINTERRUPT">%u", + adapterPlusInfo.aInfo.configinfo.CIntLine[idx]); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + } + + // Close the repeat tag. + if (infoTagAdded == TRUE) + { + if ((ccode = VIRT_AddResultData(virtInfo, "")) != zOK) + { + goto exit; + } + } + + // Check if need to add primary and secondary DMA Channels. + infoTagAdded = FALSE; + for (idx = 0 ; idx < 2 ; idx++) + { + if (adapterPlusInfo.aInfo.configinfo.CDMALine[idx] == 0xFF) + { + continue; + } + + if (infoTagAdded == FALSE) + { + infoTagAdded = TRUE; + + if ((ccode = VIRT_AddResultData(virtInfo, "<"TAG_ADAPTERDMAINFO">")) != zOK) + { + goto exit; + } + } + + sprintf(tempBuf, + "<"TAG_ADAPTERDMACHANNEL">%u", + adapterPlusInfo.aInfo.configinfo.CDMALine[idx]); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + } + + // Close the repeat tag. + if (infoTagAdded == TRUE) + { + if ((ccode = VIRT_AddResultData(virtInfo, "")) != zOK) + { + goto exit; + } + } + + // Check if need to add physical memory addresses, the physical address' + // length and the virtual memory address. + infoTagAdded = FALSE; + for (idx = 0 ; idx < 2 ; idx++) + { + if (adapterPlusInfo.aInfo.configinfo.CMemoryDecodeAndLength[idx].MemoryAddress == 0) + { + continue; + } + + + if (infoTagAdded == FALSE) + { + infoTagAdded = TRUE; + + if ((ccode = VIRT_AddResultData(virtInfo, "<"TAG_ADAPTERMEMORYINFO">")) != zOK) + { + goto exit; + } + } + sprintf(tempBuf, + "<"TAG_ADAPTERMEMORYPHYADDRESS">%u" + "<"TAG_ADAPTERMEMORYPHYLENGTH">%u", + adapterPlusInfo.aInfo.configinfo.CMemoryDecodeAndLength[idx].MemoryAddress, + adapterPlusInfo.aInfo.configinfo.CMemoryDecodeAndLength[idx].MemoryRangeParagraphs * + PARAGRAPH_SIZE_MM); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + + if (adapterPlusInfo.aInfo.configinfo.CLinearMemory[idx] != 0) + { + sprintf(tempBuf, + "<"TAG_ADAPTERMEMORYVIRTADDRESS">%u", + adapterPlusInfo.aInfo.configinfo.CLinearMemory[idx]); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + } + } + + // Close the repeat tag. + if (infoTagAdded == TRUE) + { + if ((ccode = VIRT_AddResultData(virtInfo, "")) != zOK) + { + goto exit; + } + } + + // Test if the sub system id is NWPA. + if (adapterPlusInfo.aInfo.subsystemid == NWPASubSystemID || + adapterPlusInfo.aInfo.subsystemid == CIOSSubSystemID) + { + MPKNSS_UNLOCK(); + + // For NWPA adapters, we can get more information. + ccode = MM_ReturnObjectSpecificInfo(adapterID, sizeof(adapterPlusInfo), + &adapterPlusInfo); + + MPKNSS_LOCK(); + + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, TAG_ADAPTERINFO, ccode, + MSGNot("Error getting second adapter specific info")); + goto exit; + } + + sprintf(tempBuf, + "<"TAG_ADAPTERSUPPORTEDTARGETIDS">%u" + "<"TAG_ADAPTERSUPPORTEDUNITNUMBERS">%u" + "<"TAG_ADAPTERCARDTARGETID">%u" + "<"TAG_ADAPTERFLAGS">%u", + adapterPlusInfo.hInfo.supportedtargetids, + adapterPlusInfo.hInfo.supportedunitnumbers, + adapterPlusInfo.hInfo.cardtargetid, + adapterPlusInfo.hInfo.infoflags); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + + // Return the type of adapter + if (adapterPlusInfo.hInfo.hatype == 1) + { + sprintf(tempBuf, + "<"TAG_ADAPTERTYPE">SCSI"); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + } + else if (adapterPlusInfo.hInfo.hatype == 2) + { + sprintf(tempBuf, + "<"TAG_ADAPTERTYPE">IDE-ATA"); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + } + else + { + sprintf(tempBuf, + "<"TAG_ADAPTERTYPE">%u", + adapterPlusInfo.hInfo.hatype); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_ADAPTERINFO, + TRUE, TRUE)) != zOK) + { + goto exit; + } + } + +exit: + if ((ccode == MM_OBJECT_NOT_FOUND) || (ccode == MM_OK)) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error getting adapter information")); + } + + return zOK; +} + diff --git a/src/nwnss/manage/manageCmdline.c b/src/nwnss/manage/manageCmdline.c new file mode 100644 index 0000000..ac8a108 --- /dev/null +++ b/src/nwnss/manage/manageCmdline.c @@ -0,0 +1,89 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | command line options for all input action + | + +-------------------------------------------------------------------------*/ +#include /* NetWare Include files*/ +#include + +#include /* NSS Library Includes*/ +#include +#include +#include +#include + +#include "manageStartup.h" + +/*--------------------------------------------------------------------------- + * Global variables + *-------------------------------------------------------------------------*/ +#ifndef __linux__ +#if NSS_DEBUG IS_ENABLED +BOOL ManageDescription = FALSE; +#endif +#endif + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*------------------ START OF ROUTINES ------------------------------------*/ + +/*- (FUNCTION) ----- ADMIN_CommandLineSwitches() ---------------------------- + | + | Command line switches for Menu + | + +-------------------------------------------------------------------------*/ +PCLSwitchDef_s MANAGE_CommandLineSwitches[] = +{ +#ifndef __linux__ +#if NSS_DEBUG IS_ENABLED + {MSGNot("ViewDescription"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_BOOLEAN|SWVAL_BOOL|SWOPT_HIDDEN, + 0,0, + NULL, &ManageDescription, + {0,0},0,0, + StructMSGNot("dummy command as place holder for new functions.") + }, +#endif +#endif + + {PCMDLINE_ENDOFLIST} +}; + + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ diff --git a/src/nwnss/manage/manageFile.c b/src/nwnss/manage/manageFile.c new file mode 100644 index 0000000..8fceaa8 --- /dev/null +++ b/src/nwnss/manage/manageFile.c @@ -0,0 +1,4841 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: gpachner $ + | $Date: 2007-05-04 05:30:24 +0530 (Fri, 04 May 2007) $ + | + | $RCSfile$ + | $Revision: 1972 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage NSS using XML + | + +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include /* netware */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "comnPublics.h" +#include "comnAuthorize.h" +#include "manage.h" +#include "manageNlm.h" +#include "manageStartup.h" +#include "virtualIO.h" +#include "xmlTags.h" +#include "comnZAS.h" +#include "msgName.h" +#include "dirQuotas.h" +#include "xnfsNetStorage.h" +#include "NdsilibNetStorage.h" +#include "unixAuthModel.h" +#include "lsa.h" +#include "ndp_idbroker.h" +#include "nssDebug.h" +#include "zasAuthModel.h" + +//extern unsigned long get_stack_use(void); + +#define MFILE_xnfsGetNFSInfo_API MSGNot("\x0E" "xnfsGetNFSInfo") +#define MFILE_xnfsSetNFSInfo_API MSGNot("\x0E" "xnfsSetNFSInfo") +#define MFILE_NDSIGetGroupByNWGID_API MSGNot("\x13" "NDSIGetGroupByNWGID") +#define MFILE_NDSIGetUserByNWUID_API MSGNot("\x12" "NDSIGetUserByNWUID") +#define MFILE_NDSIGetUserByUnixUID_API MSGNot("\x14" "NDSIGetUserByUnixUID") +#define MFILE_NDSIGetGroupByUnixGID_API MSGNot("\x15" "NDSIGetGroupByUnixGID") +#define UE_LIST_LEN 256 + +#define OS_NAME_SPACE zNSPACE_UNIX +typedef struct AddTrusteeParms_s +{ + GeneralMsg_s genMsg; + UserID_t id; + NINT rights; + utf8_t file[zMAX_FULL_NAME]; +} AddTrusteeParms_s; + +STATUS MFILE_ProcessModifyIRF(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessGetFileInfo(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessSetFileInfo(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessGetEffectiveRightsByID(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessAddTrustee(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessRemoveTrustee(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessRemoveAllTrustees(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessAddQuota(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +STATUS MFILE_ProcessScanSalvageableFiles(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessSalvageDeletedFile(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessPurgeDeletedFile(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +STATUS MFILE_ProcessGetArchiveServer(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +STATUS MFILE_ProcessChangeOwnerGroup(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessChangeMode(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessGetUnixInfo(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessGetEffectiveRightsByUser(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessGetAllEffectiveRights(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MFILE_ProcessGetInheritedRightsForUser(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ + +SiblingElements_s FileInfoElements[] = +{ + {TAG_GETFILEINFO, MFILE_ProcessGetFileInfo}, + {TAG_SETFILEINFO, MFILE_ProcessSetFileInfo}, + {TAG_GETEFFECTIVERIGHTSBYID, MFILE_ProcessGetEffectiveRightsByID}, + {TAG_GETEFFECTIVERIGHTSBYUSER, MFILE_ProcessGetEffectiveRightsByUser}, + {TAG_GETALLEFFECTIVERIGHTS, MFILE_ProcessGetAllEffectiveRights}, + {TAG_GETINHERITEDRIGHTSFORUSER, MFILE_ProcessGetInheritedRightsForUser}, + {0} +}; + +SiblingElements_s TrusteeElements[] = +{ + {TAG_ADDTRUSTEE, MFILE_ProcessAddTrustee}, + {TAG_REMOVETRUSTEE, MFILE_ProcessRemoveTrustee}, + {TAG_REMOVEALLTRUSTEES, MFILE_ProcessRemoveAllTrustees}, + {TAG_MODIFYINHERITEDRIGHTSFILTER, MFILE_ProcessModifyIRF}, + {0} +}; + +SiblingElements_s DirectoryQuotaElements[] = +{ + {TAG_ADDQUOTA, MFILE_ProcessAddQuota}, + {0} +}; + +SiblingElements_s SalvageElements[] = +{ + {TAG_SCANSALVAGEABLEFILES, MFILE_ProcessScanSalvageableFiles}, + {TAG_SALVAGEDELETEDFILE, MFILE_ProcessSalvageDeletedFile}, + {TAG_PURGEDELETEDFILE, MFILE_ProcessPurgeDeletedFile}, + {0} +}; + +SiblingElements_s ArkElements[] = +{ + {TAG_GETARCHIVESERVER, MFILE_ProcessGetArchiveServer}, + {0} +}; + +SiblingElements_s UnixPermissionsElements[] = +{ + {TAG_CHANGEOWNERGROUP, MFILE_ProcessChangeOwnerGroup}, + {TAG_CHANGEMODE, MFILE_ProcessChangeMode}, + {TAG_GETINFO, MFILE_ProcessGetUnixInfo}, + {0} +}; + +// Security equivalence list +Latch_s UELatch = {0}; +UserID_t TUser = {0,0,0,0,0, {0,0,0,0,0,0}}; +LONG UserEquivalentIDsCount = 0; +UserID_t *UserEquivalentGUIDs = NULL; + +/**************************************************************************** + * + * Take the given path and return volume and zid + * + ****************************************************************************/ +STATUS MFILE_LinuxPathToZid( + utf8_t *path, + VolumeID_t *volID, + Zid_t *pzid, + Zid_t *zid) +{ + struct nameidata nameData; + struct dentry *dentry; + struct inode *inode; + struct super_block *sb; + LsaSuper_s *lsaSuper; + STATUS status = zFAILURE; + int error; + + MPKNSS_UNLOCK(); + +//printk(KERN_ALERT "==========MFILE_LinuxPathToZid (enter)\n"); + error = path_lookup(path, LOOKUP_FOLLOW, &nameData); + if (error != 0) + { +//printk(KERN_ALERT "==========MFILE_LinuxPathToZid. Error after user_path_walk: %d\n", error); + status = zFAILURE; + goto exit; + } + + dentry = nameData.dentry; + inode= dentry->d_inode; + *pzid = dentry->d_parent->d_inode->i_ino; + sb = inode->i_sb; + if (sb->s_magic != LSA_MAGIC_SB) + { +//printk(KERN_ALERT "=================not NSS magic\n"); + goto exitClose; + } + + lsaSuper = sb->s_fs_info; + *volID = lsaSuper->sb_volID; + *zid = inode->i_ino; +//printk(KERN_ALERT "=================pzid: %llu zid: %llu\n", *pzid, *zid); + status = zOK; + +exitClose: + path_release(&nameData); +exit: + MPKNSS_LOCK(); + return status; +} + +typedef struct NameMsgInfo_s +{ + GeneralMsg_s *genMsg; + utf8_t *path; + NamingMsg_s *nameMsg; + VirtInfo_s *virtInfo; + utf8_t *tagName; + STATUS status; + BOOL nameMsgInited; + Latch_s latch; +} NameMsgInfo_s; + +/**************************************************************************** + * + * Take the path and do a lookup with the name message. + * + ****************************************************************************/ +void MFILE_GetNameMessage( + GeneralMsg_s *genMsg, + utf8_t *path, + NamingMsg_s *nameMsg) +{ + VolumeID_t volID; + Zid_t zid; + Zid_t pzid; + + COMN_INIT_NAMING_MSG(nameMsg); + if (MFILE_LinuxPathToZid(path, &volID, &pzid, &zid) != zOK) + { + COMN_INIT_NAMING_MSG(nameMsg); + COMN_SETUP_NAMING_MSG_SIMPLE(nameMsg, path, zPFMT_UTF8, + NAMPMODE_Undefined, XLATCHED, zNSPACE_LONG, zNTYPE_FILE, NULL); + } + else + { + COMN_SETUP_NAMING_MSG_VOLUME_ZID(nameMsg, volID, /* cnt zFNU_FIRST_PARENT,*/ pzid, + zid, zid, XLATCHED, zNSPACE_UNIX, zNTYPE_FILE, NULL); + } + return; +} + +/**************************************************************************** + * + * Take the given user name and get its ID + * + ****************************************************************************/ +STATUS MFILE_ConvertNametoID( + utf8_t *context, + utf8_t *name, + UserID_t *id) +{ + STATUS status; + + if (stricmp(name, "[Public]") == 0) + { + *id = zANYONE_USERID; + return zOK; + } + else + { + /* Resolve the user's name to an ID */ + if ((status = MFILE_FindUserIDByDN(context, name, id)) != zOK) + { + return status; + } + } + return zOK; +} + +/**************************************************************************** + * + * This function takes the mask and produces file attribute tags. The tags are + * inserted into the result buffer. + * + ****************************************************************************/ +void MFILE_ConvertMaskToFileAttributes( + VirtInfo_s *virtInfo, + NINT mask) +{ + NINT bit; + NINT index; + NINT bitsToCheck = ( + zFA_READ_ONLY | zFA_HIDDEN | zFA_SYSTEM | zFA_EXECUTE | + zFA_SUBDIRECTORY | zFA_ARCHIVE | zFA_SHAREABLE | + zFA_SMODE_BITS | zFA_NO_SUBALLOC | zFA_TRANSACTION | + zFA_NOT_VIRTUAL_FILE | zFA_IMMEDIATE_PURGE | + zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT | + zFA_IS_ADMIN_LINK | zFA_IS_LINK | zFS_REMOTE_DATA_ACCESS | + zFA_REMOTE_DATA_INHIBIT | zFA_COMPRESS_FILE_IMMEDIATELY | + zFA_DATA_STREAM_IS_COMPRESSED | zFA_DO_NOT_COMPRESS_FILE | + zFA_CANT_COMPRESS_DATA_STREAM | zFA_ATTR_ARCHIVE | + zFA_VOLATILE); + + utf8_t rightsTags[32][20] = + { + {TAG_READONLY}, + {TAG_HIDDEN}, + {TAG_SYSTEM}, + {TAG_EXECUTE}, + + {TAG_SUBDIRECTORY}, + {TAG_ARCHIVE}, + {""}, + {TAG_SHAREABLE}, + + {""}, + {""}, + {""}, + {TAG_NOSUBALLOC}, + + {TAG_TRANSACTION}, + {TAG_NOTVIRTUAL}, + {""}, + {""}, + + {TAG_IMMEDIATEPURGE}, + {TAG_RENAMEINHIBIT}, + {TAG_DELETEINHIBIT}, + {TAG_COPYINHIBIT}, + + {TAG_ADMINLINK}, + {TAG_LINK}, + {TAG_REMOTEDATAACCESS}, + {TAG_REMOTEDATAINHIBIT}, + + {""}, + {TAG_COMPRESSIMMEDIATE}, + {TAG_DATASTREAMCOMPRESS}, + {TAG_DONOTCOMPRESS}, + + {""}, + {TAG_NOSTREAMCOMPRESS}, + {TAG_ATTRARCHIVE}, + {TAG_VOLATILE}, + }; + + mask &= bitsToCheck; + + /* Convert the mask to a list of tags */ + for (bit = 1, index = 0; bit != 0; bit <<= 1, index++) + { + if (mask & bit) + { + VIRT_AddResultData(virtInfo, MSGNot("<")); + VIRT_AddResultData(virtInfo, rightsTags[index]); + VIRT_AddResultData(virtInfo, MSGNot("/>")); + } + } +} + +/**************************************************************************** + * + * This function takes file attribute tags and creates the bit masks that can + * be sent to modify info. + * + ****************************************************************************/ +STATUS MFILE_ConvertFileAttributesToMask( + VirtInfo_s *virtInfo, + utf8_t *attributes, + LONG *mask, + LONG *modMask, + BOOL *dosCompatibleRO) +{ + utf8_t *start; + utf8_t *end; + utf8_t *attrName; + NINT tagLen; + BOOL setAttr; + XML_ElementInfo_s attrElement; + + *dosCompatibleRO = FALSE; + start = attributes; + end = attributes + strlen(attributes); + *modMask = *mask = 0; + for(;;) + { + /* + * Get the next attributes tag. + */ + if (XML_GetNextTag(start, end, &attrElement, + &attrName, &tagLen) != zOK) + { + break; /* we have all of the elements */ + } + start = attrElement.elementEnd + 1; + + if (XML_GetTagAttribute(ATR_ENABLED, &attrElement) != zOK) + { + MNSS_BuildResult(virtInfo, zERR_XML_IS_BAD, + MSGNot("A tag is missing the attribute \""ATR_ENABLED"\"")); + goto error; + } + else + { + if (attrElement.attributeValueLen == 3 && + memcmp(attrElement.attributeValueStart, MSGNot("yes"), 3) == 0) + { + setAttr = TRUE; + } + else if (attrElement.attributeValueLen == 2 && + memcmp(attrElement.attributeValueStart, MSGNot("no"), 2) == 0) + { + setAttr = FALSE; + } + else + { + MNSS_BuildResult(virtInfo, zERR_XML_IS_BAD, + MSGNot("attribute \""ATR_ENABLED"\" needs a yes/no value")); + goto error; + } + } + + /* Set the correct bits in the mask */ + if (memcmp(attrName, TAG_READONLY, tagLen) == 0) + { + *modMask |= zFA_READ_ONLY; + if (setAttr) + { + *mask |= zFA_READ_ONLY; + } + if (XML_GetTagAttribute(ATR_COMPATIBLE, &attrElement) == zOK) + { + if (attrElement.attributeValueLen == 3 && + memcmp(attrElement.attributeValueStart, MSGNot("DOS"), 3) == 0) + { + *dosCompatibleRO = TRUE; + } + } + } + else if (memcmp(attrName, TAG_HIDDEN, tagLen) == 0) + { + *modMask |= zFA_HIDDEN; + if (setAttr) + { + *mask |= zFA_HIDDEN; + } + } + else if (memcmp(attrName, TAG_SYSTEM, tagLen) == 0) + { + *modMask |= zFA_SYSTEM; + if (setAttr) + { + *mask |= zFA_SYSTEM; + } + } + else if (memcmp(attrName, TAG_EXECUTE, tagLen) == 0) + { + *modMask |= zFA_EXECUTE; + if (setAttr) + { + *mask |= zFA_EXECUTE; + } + } +//rks else if (memcmp(attrName, TAG_SUBDIRECTORY, tagLen) == 0) +//rks { +//rks *modMask |= zFA_SUBDIRECTORY; +//rks if (setAttr) +//rks { +//rks *mask |= zFA_SUBDIRECTORY; +//rks } +//rks } + else if (memcmp(attrName, TAG_ARCHIVE, tagLen) == 0) + { + *modMask |= zFA_ARCHIVE; + if (setAttr) + { + *mask |= zFA_ARCHIVE; + } + } + else if (memcmp(attrName, TAG_SHAREABLE, tagLen) == 0) + { + *modMask |= zFA_SHAREABLE; + if (setAttr) + { + *mask |= zFA_SHAREABLE; + } + } +//rks else if (memcmp(attrName, TAG_NOSUBALLOC, tagLen) == 0) +//rks { +//rks *modMask |= zFA_NO_SUBALLOC; +//rks if (setAttr) +//rks { +//rks *mask |= zFA_NO_SUBALLOC; +//rks } +//rks } + else if (memcmp(attrName, TAG_TRANSACTION, tagLen) == 0) + { + *modMask |= zFA_TRANSACTION; + if (setAttr) + { + *mask |= zFA_TRANSACTION; + } + } + else if (memcmp(attrName, TAG_NOTVIRTUAL, tagLen) == 0) + { + *modMask |= zFA_NOT_VIRTUAL_FILE; + if (setAttr) + { + *mask |= zFA_NOT_VIRTUAL_FILE; + } + } + else if (memcmp(attrName, TAG_IMMEDIATEPURGE, tagLen) == 0) + { + *modMask |= zFA_IMMEDIATE_PURGE; + if (setAttr) + { + *mask |= zFA_IMMEDIATE_PURGE; + } + } + else if (memcmp(attrName, TAG_RENAMEINHIBIT, tagLen) == 0) + { + *modMask |= zFA_RENAME_INHIBIT; + if (setAttr) + { + *mask |= zFA_RENAME_INHIBIT; + } + } + else if (memcmp(attrName, TAG_DELETEINHIBIT, tagLen) == 0) + { + *modMask |= zFA_DELETE_INHIBIT; + if (setAttr) + { + *mask |= zFA_DELETE_INHIBIT; + } + } + else if (memcmp(attrName, TAG_COPYINHIBIT, tagLen) == 0) + { + *modMask |= zFA_COPY_INHIBIT; + if (setAttr) + { + *mask |= zFA_COPY_INHIBIT; + } + } + else if (memcmp(attrName, TAG_ADMINLINK, tagLen) == 0) + { + *modMask |= zFA_IS_ADMIN_LINK; + if (setAttr) + { + *mask |= zFA_IS_ADMIN_LINK; + } + } + else if (memcmp(attrName, TAG_LINK, tagLen) == 0) + { + *modMask |= zFA_IS_LINK; + if (setAttr) + { + *mask |= zFA_IS_LINK; + } + } + else if (memcmp(attrName, TAG_REMOTEDATAACCESS, tagLen) == 0) + { + *modMask |= zFS_REMOTE_DATA_ACCESS; + if (setAttr) + { + *mask |= zFS_REMOTE_DATA_ACCESS; + } + } + else if (memcmp(attrName, TAG_REMOTEDATAINHIBIT, tagLen) == 0) + { + *modMask |= zFA_REMOTE_DATA_INHIBIT; + if (setAttr) + { + *mask |= zFA_REMOTE_DATA_INHIBIT; + } + } + else if (memcmp(attrName, TAG_COMPRESSIMMEDIATE, tagLen) == 0) + { + *modMask |= zFA_COMPRESS_FILE_IMMEDIATELY; + if (setAttr) + { + *mask |= zFA_COMPRESS_FILE_IMMEDIATELY; + } + } + else if (memcmp(attrName, TAG_DATASTREAMCOMPRESS, tagLen) == 0) + { + *modMask |= zFA_DATA_STREAM_IS_COMPRESSED; + if (setAttr) + { + *mask |= zFA_DATA_STREAM_IS_COMPRESSED; + } + } + else if (memcmp(attrName, TAG_DONOTCOMPRESS, tagLen) == 0) + { + *modMask |= zFA_DO_NOT_COMPRESS_FILE; + if (setAttr) + { + *mask |= zFA_DO_NOT_COMPRESS_FILE; + } + } + else if (memcmp(attrName, TAG_NOSTREAMCOMPRESS, tagLen) == 0) + { + *modMask |= zFA_CANT_COMPRESS_DATA_STREAM; + if (setAttr) + { + *mask |= zFA_CANT_COMPRESS_DATA_STREAM; + } + } + else if (memcmp(attrName, TAG_ATTRARCHIVE, tagLen) == 0) + { + *modMask |= zFA_ATTR_ARCHIVE; + if (setAttr) + { + *mask |= zFA_ATTR_ARCHIVE; + } + } + else if (memcmp(attrName, TAG_VOLATILE, tagLen) == 0) + { + *modMask |= zFA_VOLATILE; + if (setAttr) + { + *mask |= zFA_VOLATILE; + } + } + } + return zOK; + +error: + return zFAILURE; +} + +/**************************************************************************** + * + * This function takes the mask and produces rights tags. The tags are + * inserted into the result buffer. + * + ****************************************************************************/ +void MFILE_ConvertMaskToRights( + VirtInfo_s *virtInfo, + NINT mask) +{ + NINT bit; + NINT index; + NINT bitsToCheck = ( + zAUTHORIZE_READ_CONTENTS | zAUTHORIZE_WRITE_CONTENTS | + zAUTHORIZE_CREATE_ENTRY | zAUTHORIZE_DELETE_ENTRY | + zAUTHORIZE_ACCESS_CONTROL | zAUTHORIZE_SEE_FILES | + zAUTHORIZE_MODIFY_METADATA | zAUTHORIZE_SUPERVISOR | + zAUTHORIZE_SALVAGE | zAUTHORIZE_SECURE); + + utf8_t rightsTags[16][20] = + { + {TAG_READ}, + {TAG_WRITE}, + {""}, + {TAG_CREATE}, + {TAG_ERASE}, + {TAG_ACCESSCONTROL}, + {TAG_FILESCAN}, + {TAG_MODIFY}, + {TAG_SUPERVISOR}, + {TAG_SALVAGE}, + {""}, + {""}, + {""}, + {""}, + {""}, + {TAG_SECURE} + }; + + mask &= bitsToCheck; + + /* Convert the mask to a list of tags */ + for (bit = 1, index = 0; bit != 0; bit <<= 1, index++) + { + if (mask & bit) + { + VIRT_AddResultData(virtInfo, MSGNot("<")); + VIRT_AddResultData(virtInfo, rightsTags[index]); + VIRT_AddResultData(virtInfo, MSGNot("/>")); + } + } +} + +/**************************************************************************** + * + * This function takes the rights tags and creates a mask + * + ****************************************************************************/ +NINT MFILE_ConvertRightsToMask( + utf8_t *rights) +{ + NINT mask = 0; + utf8_t *start; + utf8_t *end; + utf8_t *rightsName; + NINT tagLen; + XML_ElementInfo_s rightsElement; + + start = rights; + end = rights + strlen(rights); + for(;;) + { + /* + * Get the next rights tag. + */ + if (XML_GetNextTag(start, end, &rightsElement, + &rightsName, &tagLen) != zOK) + { + break; /* we have all of the elements */ + } + start = rightsElement.elementEnd + 1; + + /* Set the correct bits in the mask */ + if (memcmp(rightsName, TAG_READ, tagLen) == 0) + { + mask |= zAUTHORIZE_READ_CONTENTS; + } + else if (memcmp(rightsName, TAG_WRITE, tagLen) == 0) + { + mask |= zAUTHORIZE_WRITE_CONTENTS; + } + else if (memcmp(rightsName, TAG_CREATE, tagLen) == 0) + { + mask |= zAUTHORIZE_CREATE_ENTRY; + } + else if (memcmp(rightsName, TAG_ERASE, tagLen) == 0) + { + mask |= zAUTHORIZE_DELETE_ENTRY; + } + else if (memcmp(rightsName, TAG_ACCESSCONTROL, tagLen) == 0) + { + mask |= zAUTHORIZE_ACCESS_CONTROL; + } + else if (memcmp(rightsName, TAG_FILESCAN, tagLen) == 0) + { + mask |= zAUTHORIZE_SEE_FILES; + } + else if (memcmp(rightsName, TAG_MODIFY, tagLen) == 0) + { + mask |= zAUTHORIZE_MODIFY_METADATA; + } + else if (memcmp(rightsName, TAG_SUPERVISOR, tagLen) == 0) + { + mask |= zAUTHORIZE_SUPERVISOR; + } + else if (memcmp(rightsName, TAG_SALVAGE, tagLen) == 0) + { + mask |= zAUTHORIZE_SALVAGE; + } + else if (memcmp(rightsName, TAG_SECURE, tagLen) == 0) + { + mask |= zAUTHORIZE_SECURE; + } + } + return mask; +} + +/**************************************************************************** + * + * This function modifies the inherited rights filter + * + ****************************************************************************/ +STATUS MFILE_ProcessModifyIRF( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + NINT rights; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + + const TagRequest_s tags[] = + { + {TAG_INHERITEDRIGHTSFILTER, 0}, + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + INHERITED_RIGHTS_FILTER = 0, + FILE_NAME = 1 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit1; + } + return status; + } + + if (tagContent[INHERITED_RIGHTS_FILTER].flags & TR_CONTENT_FOUND) + { + rights = MFILE_ConvertRightsToMask( + tagContent[INHERITED_RIGHTS_FILTER].content); + } + else + { + rights = 0; + } + + /* Set up the file to modify the inherited rights filter */ + genMsg = virtInfo->genMsg; + MFILE_GetNameMessage(genMsg, tagContent[FILE_NAME].content, &nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exit; + } + + if (COMN_ZAS_setInheritedRightsMask(genMsg, &nameMsg, rights, TRUE) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error modifying the inherited rights filter")); + goto exit; + } + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + COMN_CleanupNameMsg(genMsg, &nameMsg); +exit1: + return zOK; +} + +/************************************************************************** + * Function to add trustees to a file. + * + * The errorMsg parameter should be al least 80 characters long. + * + ***************************************************************************/ +void MFILE_AddTrustee( + GeneralMsg_s *genMsg, + UserID_t *id, + NINT rights, + utf8_t *fileName, + NINT *error, + utf8_t *errorMsg) +{ + NamingMsg_s nameMsg; + + *error = zOK; + strcpy(errorMsg, XML_SUCCESS); + + /* actually add the trustee */ + MFILE_GetNameMessage(genMsg, fileName, &nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + *error = GetErrno(genMsg); + strcpy(errorMsg, "Error finding file"); + goto exit; + } + + if (COMN_ZAS_addACLEntry(genMsg, &nameMsg, id, rights, + zAUTHORIZE_INHERIT_DOWN | zAUTHORIZE_INHERIT_UP) != zOK) + { + *error = GetErrno(genMsg); + strcpy(errorMsg, "Error adding trustee"); + goto exit; + } + +exit: + COMN_CleanupNameMsg(genMsg, &nameMsg); + return; + +} + +/************************************************************************** + * Thread to add a trustee to a file. + ***************************************************************************/ +void MFILE_AddTrusteeThread( + FsmLite_s *fsm, + AddTrusteeParms_s *parms) +{ + NINT error; + utf8_t errorMsg[80]; + + MFILE_AddTrustee(&parms->genMsg, &parms->id, parms->rights, parms->file, + &error, errorMsg); + if (error != zOK) + { + aprintf(LRED, "Error %d doing background add of a trustee: %s\n", + error, errorMsg); + } + zASSERT(error == zOK); + free(parms); + free(fsm); +} + +/**************************************************************************** + * + * This function adds a trustee to a file/directory + * + ****************************************************************************/ +STATUS MFILE_ProcessAddTrustee( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + utf8_t *rights; + UserID_t ndsGUID; + NINT mask; + NINT error; + utf8_t errorMsg[80]; + FsmLite_s *fsm; + GeneralMsg_s *genMsg; +#if NSS_DEBUG IS_ENABLED + STATIC NINT fsmInstance = 0; +#endif + AddTrusteeParms_s *parms; + + const TagRequest_s tags[] = + { + {TAG_CONTEXT, TR_OPTIONAL}, + {TAG_NAME, TR_CONTENT_REQUIRED}, + {TAG_RIGHTS, 0}, + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {TAG_BACKGROUND, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + CONTEXT = 0, + NAME = 1, + RIGHTS = 2, + FILE_NAME = 3, + BACKGROUND = 4 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Resolve the user's name to an ID */ + if ((status = MFILE_ConvertNametoID(tagContent[CONTEXT].content, + tagContent[NAME].content, + &ndsGUID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Bad user name")); + goto exit; + } + + /* rights */ + rights = tagContent[RIGHTS].content; + if (rights == NULL) + { + mask = 0; + } + else + { + /* convert the rights */ + mask = MFILE_ConvertRightsToMask(rights); + } + + genMsg = virtInfo->genMsg; + if (tagContent[BACKGROUND].flags & TR_TAG_FOUND) + { + /* Add the trustee on a seperate thread */ + fsm = malloc(sizeof(FsmLite_s)); + if (fsm == NULL) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_MEMORY, + MSGNot("No memory to start background thread")); + goto exit; + } + parms = malloc(sizeof(AddTrusteeParms_s)); + if (parms == NULL) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_MEMORY, + MSGNot("No memory to start background thread")); + goto exit; + } + parms->id = ndsGUID; + parms->rights = mask; + parms->genMsg = *genMsg; + strcpy(parms->file, tagContent[FILE_NAME].content); + FSMLITE_INIT(fsm, "FSM for adding trustees", ++fsmInstance); + WORK_Schedule(fsm, MFILE_AddTrusteeThread, (ADDR)parms); + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + } + else + { + MFILE_AddTrustee(genMsg, &ndsGUID, mask, tagContent[FILE_NAME].content, + &error, errorMsg); + MNSS_ReturnResult(virtInfo, tagName, error, errorMsg); + } + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function removes a trustee from a file/directory + * + ****************************************************************************/ +STATUS MFILE_ProcessRemoveTrustee( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; +#if !zLINUX + LONG trusteeID; +#endif + UserID_t ndsGUID; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + + const TagRequest_s tags[] = + { + {TAG_CONTEXT, TR_OPTIONAL}, + {TAG_NAME, TR_CONTENT_REQUIRED}, + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + CONTEXT = 0, + NAME = 1, + FILE_NAME = 2 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit2; + } + return status; + } + + if (stricmp(tagContent[NAME].content, "[Public]") == 0) + { + ndsGUID = zANYONE_USERID; + } + else + { + /* Resolve the user's name to an ID */ +#if zLINUX + if ((status = MFILE_FindUserIDByDN(tagContent[CONTEXT].content, + tagContent[NAME].content, + &ndsGUID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Bad user name")); + goto exit2; + } +#else + if ((status = MNSS_GetObjectIDFromName(tagContent[CONTEXT].content, + tagContent[NAME].content, + &trusteeID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Bad user name")); + goto exit2; + } + + if (COMN_MapNDSIDToGUID(&status, trusteeID, &ndsGUID) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Trustee to GUID conversion error")); + goto exit2; + } +#endif + } + + /* actually remove the trustee */ + genMsg = virtInfo->genMsg; + MFILE_GetNameMessage(genMsg, tagContent[FILE_NAME].content, &nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exit; + } + + if (COMN_ZAS_removeACLEntry(genMsg, &nameMsg, &ndsGUID, FALSE) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error removing trustee")); + goto exit; + } + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + COMN_CleanupNameMsg(genMsg, &nameMsg); +exit2: + return zOK; +} + +/**************************************************************************** + * + * This function removes all trustees from a file/directory + * + ****************************************************************************/ +STATUS MFILE_ProcessRemoveAllTrustees( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + NINT sequence; + UserID_t userID; + NINT rights; + NINT attributes; + + const TagRequest_s tags[] = + { + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + FILE_NAME = 0 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit2; + } + return status; + } + + genMsg = virtInfo->genMsg; + MFILE_GetNameMessage(genMsg, tagContent[FILE_NAME].content, &nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exit; + } + + for(;;) + { + sequence = 0; + if (COMN_ZAS_getACLEntry(genMsg, &nameMsg, &sequence, &userID, + &rights, &attributes) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error getting a trustee")); + goto exit; + } + if (sequence == -1) + { + break; + } + + /* actually remove the trustee */ + if (COMN_ZAS_removeACLEntry(genMsg, &nameMsg, &userID, FALSE) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error removing trustee")); + goto exit; + } + } + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + COMN_CleanupNameMsg(genMsg, &nameMsg); +exit2: + return zOK; +} + +/**************************************************************************** + * + * This function lists the visibility entries on a file/directory + * + ****************************************************************************/ +void MFILE_ListVisibility( + GeneralMsg_s *genMsg, + NamingMsg_s *nameMsg, + VirtInfo_s *virtInfo) +{ + AuthBeast_s *authBeast = (AuthBeast_s *)nameMsg->curFile; + NINT index; + NINT totalVis; + VisEntry_s *tempBuf; + NINT numVis; + char id[GUID_FORMAT_SIZE]; + typedef struct Stack_s { + char nameBuf[MAX_DN_CHARS]; + } Stack_s; + + STACK_ALLOC(); + + /* Check to see if the requester has admin rights */ + if (authBeast->AUTHmayIDoThis(genMsg, authBeast, + nameMsg->hlFile ? nameMsg->hlParentZid : nameMsg->fileParentZid, + MAY_I_SUPERVISE) != zOK) + { + MNSS_BuildResult(virtInfo, GetErrno(genMsg), + MSGNot("Insufficient rights to get visibility info")); + goto exit; + } + + if (COMN_ZAS_getVisibilityCount(genMsg, nameMsg, &totalVis) != zOK) + { + MNSS_BuildResult(virtInfo, GetErrno(genMsg), + MSGNot("Error getting visibility count")); + goto exit; + } + if (totalVis == 0) + { + goto exit; + } + tempBuf = malloc(totalVis * sizeof(VisEntry_s)); + if (tempBuf == NULL) + { + MNSS_BuildResult(virtInfo, GetErrno(genMsg), + MSGNot("Error allocating memory")); + goto exit; + } + + if (COMN_ZAS_getVisibilityEntries(genMsg, nameMsg, totalVis, + tempBuf, &numVis) != zOK) + { + MNSS_BuildResult(virtInfo, GetErrno(genMsg), + MSGNot("Error getting a visibility entry")); + free(tempBuf); + goto exit; + } + zASSERT(totalVis >= numVis); + + for(index = 0; index < numVis; index++) + { + /* Get the name from the ID */ + if (MNSS_GetNDSNameFromGUID(NULL, &tempBuf[index].trusteeID, aStack->nameBuf) != zOK) + { + continue; + } + + /* Get the string representation of the ID */ + (void)LB_GUIDToString(&tempBuf[index].trusteeID, GUID_FORMAT_SIZE, id); + + VIRT_AddResultData(virtInfo,"<"TAG_VISIBILITYENTRY">"); + VIRT_AddResultCDataElement(virtInfo, TAG_NAME, aStack->nameBuf, FALSE); + VIRT_AddResultData(virtInfo,"<"TAG_ID">"); + VIRT_AddResultData(virtInfo,id); + VIRT_AddResultData(virtInfo,""); + VIRT_AddResultData(virtInfo, "\n"); + } + free(tempBuf); +exit: + STACK_FREE(); + return; +} + +/**************************************************************************** + * + * Fill the user equivalent list for the target user + * + ****************************************************************************/ +void MFILE_FillUserEquivalantList( + UserID_t *targetGUID) +{ + BOOL isSupervisor; + STATUS status = zOK; + + if (!UserEquivalentGUIDs || LB_GUIDCompare(&TUser, targetGUID) != 0) + { + if (UserEquivalentGUIDs) + { + free(UserEquivalentGUIDs); + } + UserEquivalentGUIDs = malloc(sizeof(UserID_t) * UE_LIST_LEN); + if (!UserEquivalentGUIDs) + { + printk(KERN_WARNING"Unable to allocate memory for user equivalents\n"); + return; + } + + status = COMN_GetSecurityEquivalenceList(targetGUID, UE_LIST_LEN, + UserEquivalentGUIDs, &UserEquivalentIDsCount, &isSupervisor); + if (status != 0) + { /* if there is an error */ + free(UserEquivalentGUIDs); + UserEquivalentGUIDs = NULL; + printk(KERN_WARNING"Unable to get user equivalent list\n"); + return; + } + TUser = *targetGUID; + } +} + +/**************************************************************************** + * + * Check to if the trustee is equivenent to the current user + * + ****************************************************************************/ +BOOL MFILE_CheckForEquivalence( + UserID_t *targetGUID, + UserID_t *userGUID) +{ + int i; + BOOL found = FALSE; + + ASSERT_MPKNSS_LOCK(); + X_LATCH(&UELatch); + MFILE_FillUserEquivalantList(targetGUID); + for (i = 0; i < UserEquivalentIDsCount; i++) + { + if (LB_GUIDCompare(userGUID, &UserEquivalentGUIDs[i]) == 0) + { + found = TRUE; + break; + } + } + UNX_LATCH(&UELatch); + return found; +} + +/**************************************************************************** + * + * This function lists the trustees on a file/directory + * + ****************************************************************************/ +STATUS MFILE_ListEquivalentTrustees( + GeneralMsg_s *genMsg, + NamingMsg_s *nameMsg, + VirtInfo_s *virtInfo, + UserID_t *targetUser) +{ + STATUS status = zOK; + NINT sequence; + UserID_t userID; + NINT rights; + NINT attributes; + char id[GUID_FORMAT_SIZE]; + typedef struct Stack_s { + char nameBuf[MAX_DN_CHARS]; + } Stack_s; + + STACK_ALLOC(); + + if (VIRT_AddResultTag(virtInfo, TAG_TRUSTEELIST, FALSE, TRUE) != zOK) + { + goto error; + } + sequence = 0; + for(;;) + { + if (COMN_ZAS_getACLEntry(genMsg, nameMsg, &sequence, &userID, + &rights, &attributes) != zOK) + { + MNSS_BuildResult(virtInfo, GetErrno(genMsg), + MSGNot("Error getting a trustee")); + goto exit; + } + if (sequence == -1) + { + break; + } + if (LB_GUIDCompare(targetUser, &userID) == 0 || + MFILE_CheckForEquivalence(targetUser, &userID)) + { + /* Get the name from the user ID */ + if (MNSS_GetNDSNameFromGUID(NULL, &userID, aStack->nameBuf) != zOK) + { + continue; + } + (void)LB_GUIDToString(&userID, GUID_FORMAT_SIZE, id); + + VIRT_AddResultData(virtInfo,"<"TAG_TRUSTEEINFO">"); + VIRT_AddResultCDataElement(virtInfo, TAG_TRUSTEE, aStack->nameBuf, FALSE); + VIRT_AddResultData(virtInfo,"<"TAG_ID">"); + VIRT_AddResultData(virtInfo,id); + VIRT_AddResultData(virtInfo,"<"TAG_RIGHTS">"); + MFILE_ConvertMaskToRights(virtInfo, rights); + VIRT_AddResultData(virtInfo, "\n"); + } + } +exit: + status = VIRT_AddResultTag(virtInfo, TAG_TRUSTEELIST, TRUE, TRUE); +error: + STACK_FREE(); + return status; +} + +/**************************************************************************** + * + * This function lists the trustees on a file/directory + * + ****************************************************************************/ +STATUS MFILE_ListTrustees( + GeneralMsg_s *genMsg, + NamingMsg_s *nameMsg, + VirtInfo_s *virtInfo) +{ + STATUS status = zOK; + NINT sequence; + UserID_t userID; + NINT rights; + NINT attributes; + char id[GUID_FORMAT_SIZE]; + typedef struct Stack_s { + char nameBuf[MAX_DN_CHARS]; + } Stack_s; + + STACK_ALLOC(); + + if (VIRT_AddResultTag(virtInfo, TAG_TRUSTEELIST, FALSE, TRUE) != zOK) + { + goto error; + } + sequence = 0; + for(;;) + { + if (COMN_ZAS_getACLEntry(genMsg, nameMsg, &sequence, &userID, + &rights, &attributes) != zOK) + { + MNSS_BuildResult(virtInfo, GetErrno(genMsg), + MSGNot("Error getting a trustee")); + goto exit; + } + if (sequence == -1) + { + break; + } + /* Get the name from the user ID */ + if (MNSS_GetNDSNameFromGUID(NULL, &userID, aStack->nameBuf) != zOK) + { + continue; + } + (void)LB_GUIDToString(&userID, GUID_FORMAT_SIZE, id); + + VIRT_AddResultData(virtInfo,"<"TAG_TRUSTEEINFO">"); + VIRT_AddResultCDataElement(virtInfo, TAG_TRUSTEE, aStack->nameBuf, FALSE); + VIRT_AddResultData(virtInfo,"<"TAG_ID">"); + VIRT_AddResultData(virtInfo,id); + VIRT_AddResultData(virtInfo,"<"TAG_RIGHTS">"); + MFILE_ConvertMaskToRights(virtInfo, rights); + VIRT_AddResultData(virtInfo, "\n"); + } +exit: + status = VIRT_AddResultTag(virtInfo, TAG_TRUSTEELIST, TRUE, TRUE); +error: + STACK_FREE(); + return status; +} + +/**************************************************************************** + * + * This function puts in the inherited rights filter + * + ****************************************************************************/ +STATUS MFILE_ListIRF( + GeneralMsg_s *genMsg, + NamingMsg_s *nameMsg, + VirtInfo_s *virtInfo) +{ + STATUS status = zOK; + NINT inheritedRights; + + if (VIRT_AddResultTag(virtInfo, TAG_INHERITEDRIGHTSFILTER, FALSE, FALSE) != zOK) + { + goto error; + } + if (COMN_ZAS_getInheritedRightsMask(genMsg, nameMsg, &inheritedRights) != zOK) + { + MNSS_BuildResult(virtInfo, GetErrno(genMsg), + MSGNot("Error getting inherited rights filter")); + goto exit; + } + + MFILE_ConvertMaskToRights(virtInfo, inheritedRights); +exit: + status = VIRT_AddResultTag(virtInfo, TAG_INHERITEDRIGHTSFILTER, TRUE, TRUE); +error: + return status; +} + +/**************************************************************************** + * + * This function puts in the effective rights + * + ****************************************************************************/ +STATUS MFILE_GetEffectiveRights( + GeneralMsg_s *genMsg, + NamingMsg_s *nameMsg, + VirtInfo_s *virtInfo) +{ + STATUS status = zOK; + NINT effectiveRights; + + if (VIRT_AddResultTag(virtInfo, TAG_EFFECTIVERIGHTS, FALSE, FALSE) != zOK) + { + goto error; + } + if (COMN_ZAS_getEffectiveRights(genMsg, nameMsg, &effectiveRights) != zOK) + { + MNSS_BuildResult(virtInfo, GetErrno(genMsg), + MSGNot("Error getting effective rights")); + goto exit; + } + + MFILE_ConvertMaskToRights(virtInfo, effectiveRights); +exit: + status = VIRT_AddResultTag(virtInfo, TAG_EFFECTIVERIGHTS, TRUE, TRUE); +error: + return status; +} + +/**************************************************************************** + * + * This function puts in the effective rights + * + ****************************************************************************/ +STATUS MFILE_GetEffectiveRightsByID( + GeneralMsg_s *genMsg, + NamingMsg_s *nameMsg, + VirtInfo_s *virtInfo, + UserID_t *userID) +{ + STATUS status = zOK; + NINT effectiveRights; + + if (VIRT_AddResultTag(virtInfo, TAG_EFFECTIVERIGHTS, FALSE, FALSE) != zOK) + { + goto error; + } + if (COMN_ZAS_getEffectiveRightsByID(genMsg, nameMsg, userID, + &effectiveRights) != zOK) + { + MNSS_BuildResult(virtInfo, GetErrno(genMsg), + MSGNot("Error getting effective rights")); + goto exit; + } + + MFILE_ConvertMaskToRights(virtInfo, effectiveRights); + X_LATCH(&UELatch); + MFILE_FillUserEquivalantList(userID); + status = ZAS_CheckInheritedVisibility(genMsg, (AuthBeast_s *)nameMsg->curFile, + UserEquivalentIDsCount, UserEquivalentGUIDs); + UNX_LATCH(&UELatch); + if (status == zOK) + { // found visibility rights + VIRT_AddResultData(virtInfo,"<"TAG_VISIBILITY"/>"); + } + +exit: + status = VIRT_AddResultTag(virtInfo, TAG_EFFECTIVERIGHTS, TRUE, TRUE); +error: + return status; +} + +/**************************************************************************** + * + * Generate the XML for the "standard info" section of file info + * + ****************************************************************************/ +void MFILE_FillInStandardInfo( + VirtInfo_s *virtInfo, + zInfoB_s *info, + Volume_s *volume) +{ + typedef struct Stack_s { + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + utf8_t volName[zMAX_COMPONENT_NAME]; + utf8_t buffer[256]; + } Stack_s; + + STACK_ALLOC(); + + VIRT_AddResultTag(virtInfo, TAG_STANDARDINFO, FALSE, TRUE); + COMN_GetVolumeName(virtInfo->genMsg, volume, aStack->uniVolName, zMAX_COMPONENT_NAME); + if (uni2utf(aStack->uniVolName, aStack->volName, zMAX_COMPONENT_NAME) != -1) + { + VIRT_AddResultCDataElement(virtInfo, TAG_VOLUMENAME, aStack->volName, TRUE); + } + sprintf(aStack->buffer, "<"TAG_ID">%Lu\n" + "<"TAG_PARENTID">%Lu\n" + "<"TAG_LOGICALEOF">%Lu\n" + "<"TAG_PHYSICALEOF">%Lu\n", + info->std.zid, info->std.parentZid, info->std.logicalEOF, + info->storageUsed.physicalEOF); + VIRT_AddResultData(virtInfo, aStack->buffer); + + VIRT_AddResultTag(virtInfo, TAG_ATTRIBUTES, FALSE, FALSE); + MFILE_ConvertMaskToFileAttributes(virtInfo, info->std.fileAttributes); + VIRT_AddResultTag(virtInfo, TAG_ATTRIBUTES, TRUE, TRUE); + + VIRT_AddResultTag(virtInfo, TAG_STANDARDINFO, TRUE, TRUE); + + STACK_FREE(); + return; +} + +/**************************************************************************** + * + * Generate the XML for the "time info" section of file info + * + ****************************************************************************/ +void MFILE_FillInATime( + VirtInfo_s *virtInfo, + utf8_t *tag, + QUAD time) +{ + typedef struct Stack_s { + utf8_t buffer[256]; + char timeString[32]; + } Stack_s; + + STACK_ALLOC(); + sprintf(aStack->buffer, "<"TAG_UTC">%Lu" + "<"TAG_STRING">%s", + time, UTCTime2UniversalStr(time, aStack->timeString)); + + VIRT_AddResultElement(virtInfo, tag, aStack->buffer, TRUE); + + STACK_FREE(); + return; +} + +/**************************************************************************** + * + * Generate the XML for the "time info" section of file info + * + ****************************************************************************/ +void MFILE_FillInTimeInfo( + VirtInfo_s *virtInfo, + zInfoB_s *info) +{ + VIRT_AddResultTag(virtInfo, TAG_TIMEINFO, FALSE, TRUE); + MFILE_FillInATime(virtInfo, TAG_CREATEDTIME, info->time.created); + MFILE_FillInATime(virtInfo, TAG_ARCHIVEDTIME, info->time.archived); + MFILE_FillInATime(virtInfo, TAG_MODIFIEDTIME, info->time.modified); + MFILE_FillInATime(virtInfo, TAG_ACCESSEDTIME, info->time.accessed); + MFILE_FillInATime(virtInfo, TAG_METADATAMODIFIEDTIME, + info->time.metaDataModified); + VIRT_AddResultTag(virtInfo, TAG_TIMEINFO, TRUE, TRUE); + return; +} + +/**************************************************************************** + * + * Generate the XML for the "time info" section of file info + * + ****************************************************************************/ +void MFILE_FillInAnID( + VirtInfo_s *virtInfo, + utf8_t *tag, + UserID_t *id) +{ + typedef struct Stack_s { + char idString[MAX_DN_CHARS]; + char guid[GUID_FORMAT_SIZE]; + } Stack_s; + + STACK_ALLOC(); + /* Get the name from the ID */ + if (MNSS_GetNDSNameFromGUID(NULL, id, aStack->idString) != zOK) + { + strcpy(aStack->idString,"Unknown User"); + } + (void)LB_GUIDToString(id, GUID_FORMAT_SIZE, aStack->guid); + if (tag) + { + VIRT_AddResultTag(virtInfo, tag, FALSE, FALSE); + } + VIRT_AddResultCDataElement(virtInfo, TAG_NAME, aStack->idString, FALSE); + VIRT_AddResultElement(virtInfo, TAG_ID, aStack->guid, FALSE); + if (tag) + { + VIRT_AddResultTag(virtInfo, tag, TRUE, TRUE); + } + + STACK_FREE(); + return; +} + +/**************************************************************************** + * + * Generate the XML for the "id info" section of file info + * + ****************************************************************************/ +void MFILE_FillInIDInfo( + VirtInfo_s *virtInfo, + zInfoB_s *info) +{ + VIRT_AddResultTag(virtInfo, TAG_IDINFO, FALSE, TRUE); + MFILE_FillInAnID(virtInfo, TAG_CREATOR, &info->id.owner); + MFILE_FillInAnID(virtInfo, TAG_ARCHIVER, &info->id.archiver); + MFILE_FillInAnID(virtInfo, TAG_MODIFIER, &info->id.modifier); + MFILE_FillInAnID(virtInfo, TAG_METADATAMODIFIER, + &info->id.metaDataModifier); + VIRT_AddResultTag(virtInfo, TAG_IDINFO, TRUE, TRUE); + return; +} + +/**************************************************************************** + * + * Generate the XML for the "quota info" section of file info + * + ****************************************************************************/ +void MFILE_FillInQuotaInfo( + VirtInfo_s *virtInfo, + zInfoB_s *info) +{ + typedef struct Stack_s { + utf8_t buffer[128]; + } Stack_s; + + STACK_ALLOC(); + VIRT_AddResultTag(virtInfo, TAG_QUOTAINFO, FALSE, TRUE); + sprintf(aStack->buffer, "<"TAG_QUOTAAMOUNT">%Ld\n" + "<"TAG_USEDAMOUNT">%Ld\n", + info->dirQuota.quota, info->dirQuota.usedAmount); + VIRT_AddResultData(virtInfo, aStack->buffer); + VIRT_AddResultTag(virtInfo, TAG_QUOTAINFO, TRUE, TRUE); + + STACK_FREE(); + return; +} + + +/**************************************************************************** + * + ****************************************************************************/ +void MFILE_FillInNFSInfo( + VirtInfo_s *virtInfo, + GetNFSInfo_s *nfsInfo) +{ + char resultData[32]; + ServUserEnt_T *userEnt = NULL; + ServGroupEnt_T *groupEnt = NULL; + NWDSCCODE dscc; + NWDSCCODE (*NDSIGetUserByUnixUID_PTR)(long, ServUserEnt_T *) = NULL; + NWDSCCODE (*NDSIGetGroupByUnixGID_PTR)(long, ServGroupEnt_T *) = NULL; + + /* Import the NFS functions to do user and group ID to name conversions */ + ZOS_ImportPublicSymbol(NDSIGetUserByUnixUID_PTR, (LONG)MANAGE_ModuleHandle, (BYTE *)MFILE_NDSIGetUserByUnixUID_API); + ZOS_ImportPublicSymbol(NDSIGetGroupByUnixGID_PTR, (LONG)MANAGE_ModuleHandle, (BYTE *)MFILE_NDSIGetGroupByUnixGID_API); + if ((NDSIGetUserByUnixUID_PTR == NULL) || (NDSIGetGroupByUnixGID_PTR == NULL)) + { + goto CleanupExit; + } + + /* Allocate memory for the user and group information */ + userEnt = malloc(sizeof(ServUserEnt_T)); + groupEnt = malloc(sizeof(ServGroupEnt_T)); + if ((userEnt == NULL) || (groupEnt == NULL)) + { + goto CleanupExit; + } + + /* Start the NFS info data */ + if (VIRT_AddResultTag(virtInfo, TAG_NFSINFO, FALSE, + TRUE) != zOK) + { + goto CleanupExit; + } + + /* Add the NFS name */ + if (VIRT_AddResultCDataElement(virtInfo, TAG_NFSNAME, nfsInfo->abzUnixName, + TRUE) != zOK) + { + goto CleanupExit; + } + + /* Add the share mode */ + switch (nfsInfo->lExpMode) + { + case INDEPENDENT_MODE: + strcpy(resultData, "Independent"); + break; + + case NETWARE_MODE: + strcpy(resultData, "NetWare"); + break; + + default: + strcpy(resultData, "Unexported"); + break; + } + + if (VIRT_AddResultElement(virtInfo, TAG_MODE, resultData, TRUE) != zOK) + { + goto CleanupExit; + } + + if (nfsInfo->bIsSymLink) + { + if (VIRT_AddResultElement(virtInfo, TAG_SYMLINK, NULL, TRUE) != zOK) + { + goto CleanupExit; + } + } + + /* FIXFIXFIX - The following user and group names will be in code page so + * should probably be returned as XML cdata */ + + /* Add the user details */ + if (VIRT_AddResultTag(virtInfo, TAG_USER, FALSE, + TRUE) != zOK) + { + goto CleanupExit; + } + sprintf(resultData, "%d", nfsInfo->lNfsUID); + if (VIRT_AddResultElement(virtInfo, TAG_ID, resultData, TRUE) != zOK) + { + goto CleanupExit; + } + MPKNSS_UNLOCK(); + dscc = NDSIGetUserByUnixUID_PTR(nfsInfo->lNfsUID, userEnt); + MPKNSS_LOCK(); + if (dscc != 0) + { + goto closeUser; + } + if (VIRT_AddResultCDataElement(virtInfo, TAG_NAME, userEnt->name, TRUE) != zOK) + { + goto CleanupExit; + } +closeUser: + if (VIRT_AddResultTag(virtInfo, TAG_USER, TRUE, + TRUE) != zOK) + { + goto CleanupExit; + } + + /* Add the group details */ + if (VIRT_AddResultTag(virtInfo, TAG_GROUP, FALSE, + TRUE) != zOK) + { + goto CleanupExit; + } + sprintf(resultData, "%d", nfsInfo->lNfsGID); + if (VIRT_AddResultElement(virtInfo, TAG_ID, resultData, TRUE) != zOK) + { + goto CleanupExit; + } + MPKNSS_UNLOCK(); + dscc = NDSIGetGroupByUnixGID_PTR(nfsInfo->lNfsGID, groupEnt); + MPKNSS_LOCK(); + if (dscc != 0) + { + goto closeGroup; + } + if (VIRT_AddResultCDataElement(virtInfo, TAG_NAME, groupEnt->name, TRUE) != zOK) + { + goto CleanupExit; + } +closeGroup: + if (VIRT_AddResultTag(virtInfo, TAG_GROUP, TRUE, TRUE) != zOK) + { + goto CleanupExit; + } + + /* Add the rights data as a 3 digit octal value */ + sprintf(resultData, "%03o", nfsInfo->lFMode & 0777); + if (VIRT_AddResultElement(virtInfo, TAG_RIGHTS, resultData, TRUE) != zOK) + { + goto CleanupExit; + } + + /* End the NFS info */ + if (VIRT_AddResultTag(virtInfo, TAG_NFSINFO, TRUE, + TRUE) != zOK) + { + goto CleanupExit; + } + +CleanupExit: + /* Free any memory we used */ + if (userEnt != NULL) + { + free(userEnt); + } + if (groupEnt != NULL) + { + free(groupEnt); + } + + /* Unimport any symbols we used */ + if (NDSIGetGroupByUnixGID_PTR != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)MFILE_NDSIGetGroupByUnixGID_API); + } + if (NDSIGetUserByUnixUID_PTR != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)MFILE_NDSIGetUserByUnixUID_API); + } +} + +/**************************************************************************** + * + * Generate the XML for the "standard info" section of file info + * + ****************************************************************************/ +void MFILE_FillInDataStreamInfo( + VirtInfo_s *virtInfo, + zInfoB_s *info) +{ + typedef struct Stack_s { + utf8_t buffer[256]; + } Stack_s; + + STACK_ALLOC(); + + VIRT_AddResultTag(virtInfo, TAG_DATASTREAMINFO, FALSE, TRUE); + sprintf(aStack->buffer, "<"TAG_COUNT">%d\n" + "<"TAG_TOTALDATASIZE">%Lu\n", + info->dataStream.count, info->dataStream.totalDataSize); + VIRT_AddResultData(virtInfo, aStack->buffer); + VIRT_AddResultTag(virtInfo, TAG_DATASTREAMINFO, TRUE, TRUE); + + STACK_FREE(); + return; +} + +/**************************************************************************** + * + * Generate the XML for the "standard info" section of file info + * + ****************************************************************************/ +void MFILE_FillInPrimaryNameSpaceInfo( + VirtInfo_s *virtInfo, + zInfoB_s *info) +{ + switch(info->primaryNameSpaceID) + { + case zNSPACE_DOS: + VIRT_AddResultData(virtInfo, "<"TAG_NAMESPACEINFO">DOS\n"); + break; + case zNSPACE_LONG: + VIRT_AddResultData(virtInfo, "<"TAG_NAMESPACEINFO">Long\n"); + break; + case zNSPACE_MAC: + VIRT_AddResultData(virtInfo, "<"TAG_NAMESPACEINFO">Macintosh\n"); + break; + case zNSPACE_UNIX: + VIRT_AddResultData(virtInfo, "<"TAG_NAMESPACEINFO">Unix\n"); + break; + case zNSPACE_EXTENDED_ATTRIBUTE: + VIRT_AddResultData(virtInfo, "<"TAG_NAMESPACEINFO">ExtendedAttribute\n"); + break; + case zNSPACE_DATA_STREAM: + VIRT_AddResultData(virtInfo, "<"TAG_NAMESPACEINFO">DataStream\n"); + break; + default: + VIRT_AddResultData(virtInfo, "<"TAG_NAMESPACEINFO">Unknown\n"); + break; + } + + return; +} + +/**************************************************************************** + * + * Generate the XML for the "standard info" section of file info + * + ****************************************************************************/ +void MFILE_FillInDeletedInfo( + VirtInfo_s *virtInfo, + zInfoB_s *info) +{ + VIRT_AddResultTag(virtInfo, TAG_DELETEDINFO, FALSE, TRUE); + MFILE_FillInATime(virtInfo, TAG_DELETEDTIME, info->deleted.time); + MFILE_FillInAnID(virtInfo, TAG_DELETORID, &info->deleted.id); + VIRT_AddResultTag(virtInfo, TAG_DELETEDINFO, TRUE, TRUE); + + return; +} + +/**************************************************************************** + * + * This function gets information about a file/directory + * + ****************************************************************************/ +STATUS MFILE_ProcessGetFileInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status = zOK; + utf8_t *searchStart; + NINT tagLen; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + XML_ElementInfo_s getInfoElement; + utf8_t *nextTagName; + NINT infoMask = 0; + NINT getInfoMask = 0; + GetInfoMsg_s infoMsg; + zInfoB_s *info = NULL; + GetNFSInfo_s *nfsInfo = NULL; + BOOLEAN namingMsgInitd = FALSE; + STATUS nfsStatus = zFAILURE; + + const TagRequest_s tags[] = + { + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {TAG_TYPEOFINFO, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + FILE_NAME = 0, + TYPE_OF_INFO = 1 + }; + + enum /* info - bit mask */ + { + STANDARD = 1, + TIME = 2, + ID = 4, + NFS = 8, + QUOTAS = 16 + }; + + ASSERT_MPKNSS_LOCK(); + + genMsg = virtInfo->genMsg; + + info = malloc(sizeof(zInfoB_s)); + nfsInfo = malloc(sizeof(nfsInfo)); + if (!info || !nfsInfo) + { + status = zERR_NO_MEMORY; + goto addStatus; + } + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto addStatus; + } + return status; + } + + /* open the file to get the info */ + MFILE_GetNameMessage(genMsg, tagContent[FILE_NAME].content, &nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + namingMsgInitd = TRUE; + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exitCleanup; + } + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + searchStart = tagContent[TYPE_OF_INFO].element.dataStart; + for(;;) + { + /* + * Get the next tag which should be a type of info to fill in. + */ + if (XML_GetNextTag(searchStart, + tagContent[TYPE_OF_INFO].element.dataEnd, &getInfoElement, + &nextTagName, &tagLen) != zOK) + { + break; /* we have all of the elements */ + } + searchStart = getInfoElement.elementEnd + 1; + + + if (memcmp(nextTagName, TAG_RIGHTSINFO, tagLen) == 0) + { + /* + * File system rights + */ + + if (VIRT_AddResultTag(virtInfo, TAG_RIGHTSINFO, FALSE, TRUE) != zOK) + { + goto exitCleanup; + } + + /* Trustee info */ + if (MFILE_ListTrustees(genMsg, &nameMsg, virtInfo) == zOK) + { + /* Inherited rights filter */ + if (MFILE_ListIRF(genMsg, &nameMsg, virtInfo) == zOK) + { + /* Effective rights */ + if (MFILE_GetEffectiveRights(genMsg, &nameMsg, virtInfo) == + zOK) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + } + } + if (VIRT_AddResultTag(virtInfo, TAG_RIGHTSINFO, TRUE, TRUE) != zOK) + { + goto exitCleanup; + } + } + else if (memcmp(nextTagName, TAG_STANDARDINFO, tagLen) == 0) + { + infoMask |= STANDARD; + getInfoMask |= (zGET_STD_INFO | zGET_STORAGE_USED); + } + else if (memcmp(nextTagName, TAG_TIMEINFO, tagLen) == 0) + { + infoMask |= TIME; + getInfoMask |= zGET_TIMES_IN_SECS; + } + else if (memcmp(nextTagName, TAG_IDINFO, tagLen) == 0) + { + infoMask |= ID; + getInfoMask |= zGET_IDS; + } + else if (memcmp(nextTagName, TAG_NFSINFO, tagLen) == 0) + { + infoMask |= NFS; + } + else if (memcmp(nextTagName, TAG_VISIBILITYINFO, tagLen) == 0) + { + /* + * Visibility entries + */ + + if (VIRT_AddResultTag(virtInfo, TAG_VISIBILITYINFO, FALSE, + TRUE) != zOK) + { + goto exitCleanup; + } + MFILE_ListVisibility(genMsg, &nameMsg, virtInfo); + if (VIRT_AddResultTag(virtInfo, TAG_VISIBILITYINFO, TRUE, + TRUE) != zOK) + { + goto exitCleanup; + } + } + else if (memcmp(nextTagName, TAG_DIRECTORYQUOTAINFO, tagLen) == 0) + { + infoMask |= QUOTAS; + getInfoMask |= zGET_DIR_QUOTA; + } + } + + COMN_STRUCT_INIT(infoMsg); + COMN_SETUP_GET_INFO_MSG(&infoMsg, getInfoMask, OS_NAME_SPACE, + (zInfo_s *)info, sizeof(*info), zINFO_VERSION_B); + status = COMN_GetInfo(genMsg, &nameMsg, &infoMsg); + if (status != zOK) + { + goto addStatus; + } + + if (infoMask & STANDARD) + { + MFILE_FillInStandardInfo(virtInfo, info, nameMsg.curvol); + } + if (infoMask & TIME) + { + MFILE_FillInTimeInfo(virtInfo, info); + } + if (infoMask & ID) + { + MFILE_FillInIDInfo(virtInfo, info); + } + if ((infoMask & NFS) && (nfsStatus == zOK)) + { + MFILE_FillInNFSInfo(virtInfo, nfsInfo); + } + if (infoMask & QUOTAS) + { + MFILE_FillInQuotaInfo(virtInfo, info); + } + +addStatus: + switch(status) + { + case zOK: + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + break; + + default: + MNSS_BuildResult(virtInfo, status, MSGNot("Failed to get file info.")); + break; + } + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exitCleanup: + if (namingMsgInitd) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + } + free(info); + free(nfsInfo); + return zOK; +} + + +STATUS MFILE_GetGUIDFromName( + VirtInfo_s *virtInfo, + utf8_t *tagName, + utf8_t *name, + utf8_t *type, + UserID_t *ndsGUID) +{ + STATUS status = zOK; + typedef struct Stack_s { + BYTE buf[256]; + } Stack_s; + + STACK_ALLOC(); + /* Resolve the user's name to an ID */ + if ((status = MFILE_FindUserIDByDN(NULL, name, ndsGUID)) != zOK) + { + sprintf(aStack->buf, MSGNot("Bad %s name"), type); + MNSS_ReturnResult(virtInfo, tagName, status, aStack->buf); + goto exit; + } + +exit: + STACK_FREE(); + return status; +} + +STATUS MFILE_SetIDInfoProcessing( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element, + QUAD *setInfoMask, + zInfo_s *info) +{ + STATUS status = zOK; + UserID_t ndsGUID; + + const TagRequest_s tags[] = + { + {TAG_CREATOR, TR_OPTIONAL}, + {TAG_ARCHIVER, TR_OPTIONAL}, + {TAG_MODIFIER, TR_OPTIONAL}, + {TAG_METADATAMODIFIER, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags) - 1]; + + enum + { + CREATOR = 0, + ARCHIVER = 1, + MODIFIER = 2, + METAMODIFIER = 3, + }; + + /* Parse out the id tags */ + if ((status = MNSS_GetTagContents(virtInfo, TAG_IDINFO, element, tags, tagContent)) != zOK) + { + goto exit; + } + + if (tagContent[CREATOR].flags & TR_CONTENT_FOUND) + { + *setInfoMask |= zMOD_OWNER_ID; + + /* Resolve the user's name to an ID */ + if ((status = MFILE_GetGUIDFromName(virtInfo, tagName, + tagContent[CREATOR].content, TAG_CREATOR, &ndsGUID)) != zOK) + { + goto exit; + } + + info->id.owner = ndsGUID; + } + + if (tagContent[ARCHIVER].flags & TR_CONTENT_FOUND) + { + *setInfoMask |= zMOD_ARCHIVER_ID; + + /* Resolve the user's name to an ID */ + if ((status = MFILE_GetGUIDFromName(virtInfo, tagName, + tagContent[ARCHIVER].content, TAG_ARCHIVER, &ndsGUID)) != zOK) + { + goto exit; + } + + info->id.archiver = ndsGUID; + } + + if (tagContent[MODIFIER].flags & TR_CONTENT_FOUND) + { + *setInfoMask |= zMOD_MODIFIER_ID; + + /* Resolve the user's name to an ID */ + if ((status = MFILE_GetGUIDFromName(virtInfo, tagName, + tagContent[MODIFIER].content, TAG_MODIFIER, &ndsGUID)) != zOK) + { + goto exit; + } + + info->id.modifier = ndsGUID; + } + + if (tagContent[METAMODIFIER].flags & TR_CONTENT_FOUND) + { + *setInfoMask |= zMOD_METADATA_MODIFIER_ID; + + /* Resolve the user's name to an ID */ + if ((status = MFILE_GetGUIDFromName(virtInfo, tagName, + tagContent[METAMODIFIER].content, TAG_METADATAMODIFIER, &ndsGUID)) != zOK) + { + goto exit; + } + + info->id.metaDataModifier = ndsGUID; + } + +exit: + return status; +} + +STATUS MFILE_SetStandardInfoProcessing( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element, + QUAD *setInfoMask, + zInfo_s *info, + BOOL *dosCompatibleRO) +{ + STATUS status = zOK; + + const TagRequest_s tags[] = + { + {TAG_ATTRIBUTES, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags) - 1]; + + enum + { + ATTRIBUTES = 0, + }; + + /* Parse out the standard info tags */ + if ((status = MNSS_GetTagContents(virtInfo, TAG_STANDARDINFO, element, tags, tagContent)) != zOK) + { + goto exit; + } + + if (tagContent[ATTRIBUTES].flags & TR_CONTENT_FOUND) + { + *setInfoMask |= zMOD_FILE_ATTRIBUTES; + if (MFILE_ConvertFileAttributesToMask(virtInfo, + tagContent[ATTRIBUTES].content, &info->std.fileAttributes, + &info->std.fileAttributesModMask, dosCompatibleRO) != zOK) + { + goto exit; + } + } + +exit: + return status; +} + + +STATUS MFILE_SetTimeInfoProcessing( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element, + QUAD *setInfoMask, + zInfo_s *info) +{ + STATUS status = zOK; + + const TagRequest_s tags[] = + { + {TAG_CREATETIME, TR_OPTIONAL}, + {TAG_ARCHIVEDTIME, TR_OPTIONAL}, + {TAG_ACCESSEDTIME, TR_OPTIONAL}, + {TAG_MODIFIEDTIME, TR_OPTIONAL}, + {TAG_METADATAMODIFIEDTIME, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags) - 1]; + + enum + { + CREATE = 0, + ARCHIVED = 1, + ACCESSED = 2, + MODIFIED = 3, + METAMODIFIED = 4, + }; + + /* Parse out the id tags */ + if ((status = MNSS_GetTagContents(virtInfo, TAG_TIMEINFO, element, tags, tagContent)) != zOK) + { + goto exit; + } + + if (tagContent[CREATE].flags & TR_CONTENT_FOUND) + { + *setInfoMask |= zMOD_CREATED_TIME; + + info->time.created = UniversalStr2utcTime(tagContent[CREATE].content); + } + + if (tagContent[ARCHIVED].flags & TR_CONTENT_FOUND) + { + *setInfoMask |= zMOD_ARCHIVED_TIME; + + info->time.archived = UniversalStr2utcTime(tagContent[ARCHIVED].content); + } + + if (tagContent[ACCESSED].flags & TR_CONTENT_FOUND) + { + *setInfoMask |= zMOD_ACCESSED_TIME; + + info->time.accessed = UniversalStr2utcTime(tagContent[ACCESSED].content); + } + + if (tagContent[MODIFIED].flags & TR_CONTENT_FOUND) + { + *setInfoMask |= zMOD_MODIFIED_TIME; + + info->time.modified = UniversalStr2utcTime(tagContent[MODIFIED].content); + } + + if (tagContent[METAMODIFIED].flags & TR_CONTENT_FOUND) + { + *setInfoMask |= zMOD_METADATA_MODIFIED_TIME; + + info->time.metaDataModified = UniversalStr2utcTime(tagContent[METAMODIFIED].content); + } + +exit: + return status; +} + +/**************************************************************************** + * + * This function modifies information on a file/directory + * + ****************************************************************************/ +STATUS MFILE_ProcessSetFileInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status = zOK; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + QUAD setInfoMask = 0; + ModifyInfoMsg_s infoMsg; + zInfo_s info; +#if !zLINUX + LONG ownerID; +#endif + UserID_t ndsGUID; + BOOL dosCompatibleRO = FALSE; + + const TagRequest_s tags[] = + { + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {TAG_OWNER, TR_OPTIONAL}, + {TAG_ATTRIBUTES, TR_OPTIONAL}, + {TAG_NFSINFO, TR_OPTIONAL}, + {TAG_IDINFO, TR_OPTIONAL}, + {TAG_STANDARDINFO, TR_OPTIONAL}, + {TAG_TIMEINFO, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + FILE_NAME = 0, + OWNER = 1, + ATTRIBUTES = 2, + NFS = 3, + ID = 4, + STANDARD = 5, + TIME = 6, + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + +#ifndef __linux__ + /* If we are going to set NFS info we need to get it first and now, before we + * do an XLatched lookup for non-NFS info. Check if the tag + * name exists in the child XML where it might be expected and this + * at least prevents doing repeated symbol imports for no real reason. */ + if (tagContent[NFS].flags & TR_CONTENT_FOUND) + { + /* FIXFIXFIX Our XML parser doesn't handle nested tags with the same name as peers of its + * parent tag if that peer of the parent is optional and not included in a given request. + * For example, we have owner as an optional tag that is a peer of nfsInfo and an owner + * tag as a child of nfsInfo. If the top level owner tag is not present the parser finds + * the owner that is a child of the nfsInfo tag and uses it. So, we need to hack that + * problem out for now by detecting if the owner tag is inside the NFS data. In the longer + * term, fix the parser to handle that case since this fix prevents the peer of the parent + * owner tag in the example being found if it comes after the nfsInfo tag. */ + if ((tagContent[OWNER].flags & TR_CONTENT_FOUND) + && (tagContent[OWNER].content >= tagContent[NFS].element.dataStart) + && (tagContent[OWNER].content <= tagContent[NFS].element.dataEnd)) + { + /* Make the owner tag not present after all */ + tagContent[OWNER].flags &= ~TR_CONTENT_FOUND; + + /* and fixup the NULL we inserted when we thought we found the tag */ + tagContent[OWNER].element.dataEnd[1] = '<'; + } + status = MFILE_SetNFSInfoProcessing(virtInfo, &tagContent[NFS].element, + tagContent[FILE_NAME].content); + if (status != zOK) + { + goto addStatus; + } + } +#endif + + /* open the file to modify the info */ + genMsg = virtInfo->genMsg; + MFILE_GetNameMessage(genMsg, tagContent[FILE_NAME].content, &nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exitCleanup; + } + + /* + * Modify owner ID + */ + if (tagContent[OWNER].flags & TR_CONTENT_FOUND) + { + setInfoMask |= zMOD_OWNER_ID; + + /* Resolve the user's name to an ID */ +#if zLINUX + if ((status = MFILE_FindUserIDByDN(NULL, tagContent[OWNER].content, + &ndsGUID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Bad owner name")); + goto exitCleanup; + } +#else + if ((status = MNDS_GetObjectIDFromName(NULL, tagContent[OWNER].content, + &ownerID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Bad owner name")); + goto exitCleanup; + } + if (COMN_MapNDSIDToGUID(&status, ownerID, &ndsGUID) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_USER_ID, + MSGNot("Trustee to GUID conversion error")); + goto exitCleanup; + } +#endif + info.id.owner = ndsGUID; + } + /* + * Modify ID + */ + if (tagContent[ID].flags & TR_CONTENT_FOUND) + { + status = MFILE_SetIDInfoProcessing(tagName, virtInfo, &tagContent[ID].element, + &setInfoMask, &info); + if (status != zOK) + { + goto exitCleanup; + } + } + + /* + * Modify attributes + */ + if (tagContent[ATTRIBUTES].flags & TR_CONTENT_FOUND) + { + setInfoMask |= zMOD_FILE_ATTRIBUTES; + if (MFILE_ConvertFileAttributesToMask(virtInfo, + tagContent[ATTRIBUTES].content, &info.std.fileAttributes, + &info.std.fileAttributesModMask, &dosCompatibleRO) != zOK) + { + goto exitCleanup; + } + } + /* Modify standard Info, everything except for attributes */ + if (tagContent[STANDARD].flags & TR_CONTENT_FOUND) + { + status = MFILE_SetStandardInfoProcessing(tagName, virtInfo, + &tagContent[STANDARD].element, &setInfoMask, &info, &dosCompatibleRO); + if (status != zOK) + { + goto exitCleanup; + } + } + + /* Modify time info */ + if (tagContent[TIME].flags & TR_CONTENT_FOUND) + { + status = MFILE_SetTimeInfoProcessing(tagName, virtInfo, + &tagContent[TIME].element, &setInfoMask, &info); + if (status != zOK) + { + goto exitCleanup; + } + } + + /* + * Do the actual modify operation + */ + if (setInfoMask) + { + COMN_STRUCT_INIT(infoMsg); + COMN_SETUP_MODIFY_INFO_MSG(&infoMsg, setInfoMask, &info, + zINFO_VERSION_A); + + if (!dosCompatibleRO) + { + infoMsg.modifyFlags = MF_DONT_AUTO_SET_DELETE_RENAME_INHIBIT; + } + + if (COMN_ModifyInfo(genMsg, &nameMsg, &infoMsg) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Unable to modify file information")); + goto exitCleanup; + } + } + +exitCleanup: + COMN_CleanupNameMsg(genMsg, &nameMsg); + +#ifndef __linux__ +addStatus: +#endif + switch (status) + { + case zOK: + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + break; + default: + MNSS_BuildResult(virtInfo, status, MSGNot("Failed to set file attributes")); + break; + } + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function gets effective rights of the specifed user name for a + * file/directory. + * + ****************************************************************************/ +STATUS MFILE_ProcessGetEffectiveRightsByUser( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status = zOK; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + AuthBeast_s *authBeast; + UserID_t userID; + + const TagRequest_s tags[] = + { + {TAG_CONTEXT, TR_OPTIONAL}, + {TAG_NAME, TR_CONTENT_REQUIRED}, + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + CONTEXT = 0, + NAME = 1, + FILE_NAME = 2 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + status = zOK; + goto exit; + } + return status; + } + + /* open the file to get the effective rights */ + genMsg = virtInfo->genMsg; + MFILE_GetNameMessage(genMsg, tagContent[FILE_NAME].content, &nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exitCleanup; + } + + authBeast = (AuthBeast_s *)nameMsg.curFile; + /* Check to see if the requester has admin rights */ + if (authBeast->AUTHmayIDoThis(genMsg, authBeast, + nameMsg.hlFile ? nameMsg.hlParentZid : nameMsg.fileParentZid, + MAY_I_SUPERVISE) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Insufficient rights to get effective rights")); + goto exitCleanup; + } + + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto exitCleanup; + } + + /* Resolve the user's name to an ID */ + if ((status = MFILE_ConvertNametoID(tagContent[CONTEXT].content, + tagContent[NAME].content, + &userID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Bad user name")); + goto exitCloseTag; + } + + if ((status = MFILE_GetEffectiveRightsByID(genMsg, &nameMsg, + virtInfo, &userID)) != zOK) + { + goto exitCloseTag; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + +exitCloseTag: + status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exitCleanup: + COMN_CleanupNameMsg(genMsg, &nameMsg); + +exit: + return status; +} + +/**************************************************************************** + * + * This function gets effective rights of the specifed user ID for a + * file/directory. + * + ****************************************************************************/ +STATUS MFILE_ProcessGetEffectiveRightsByID( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status = zOK; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + AuthBeast_s *authBeast; + UserID_t userID; + + const TagRequest_s tags[] = + { + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {TAG_USERID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + FILE_NAME = 0, + USER_ID = 1 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + status = zOK; + goto exit; + } + return status; + } + + /* open the file to get the effective rights */ + genMsg = virtInfo->genMsg; + MFILE_GetNameMessage(genMsg, tagContent[FILE_NAME].content, &nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exitCleanup; + } + + authBeast = (AuthBeast_s *)nameMsg.curFile; + /* Check to see if the requester has admin rights */ + if (authBeast->AUTHmayIDoThis(genMsg, authBeast, + nameMsg.hlFile ? nameMsg.hlParentZid : nameMsg.fileParentZid, + MAY_I_SUPERVISE) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Insufficient rights to get visibility info")); + goto exitCleanup; + } + + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto exitCleanup; + } + + if (LB_GUIDFromUTF8(tagContent[USER_ID].content, &userID) != zOK) + { + MNSS_BuildResult(virtInfo, GetErrno(genMsg), + MSGNot("Bad format for the User ID")); + goto exitCloseTag; + } + + if ((status = MFILE_GetEffectiveRightsByID(genMsg, &nameMsg, + virtInfo, &userID)) != zOK) + { + goto exitCloseTag; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + +exitCloseTag: + status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exitCleanup: + COMN_CleanupNameMsg(genMsg, &nameMsg); + +exit: + return status; +} + +/**************************************************************************** + * + * This function gets all effective rights ID for a file/directory. + * + ****************************************************************************/ +STATUS MFILE_ProcessGetAllEffectiveRights( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status = zOK; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + AuthBeast_s *authBeast; + ACLEntry_s *aclEntries = NULL; + NINT numEntries; + NINT i; + utf8_t tmpStr[16]; + NINT rights; + + const TagRequest_s tags[] = + { + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + FILE_NAME = 0, + USER_ID = 1 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + status = zOK; + goto exit; + } + return status; + } + + /* open the file to get the effective rights */ + genMsg = virtInfo->genMsg; + MFILE_GetNameMessage(genMsg, tagContent[FILE_NAME].content, &nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exitCleanup; + } + + authBeast = (AuthBeast_s *)nameMsg.curFile; + /* Check to see if the requester has admin rights */ + if (authBeast->AUTHmayIDoThis(genMsg, authBeast, + nameMsg.hlFile ? nameMsg.hlParentZid : nameMsg.fileParentZid, + MAY_I_SUPERVISE) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Insufficient rights to get all effective rights")); + goto exitCleanup; + } + + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto exitCleanup; + } + + if (COMN_ZAS_getEffectiveACL(genMsg, &nameMsg, &aclEntries, + &numEntries) != zOK) + { + MNSS_BuildResult(virtInfo, GetErrno(genMsg), + MSGNot("Error getting effective access rights")); + aclEntries = NULL; + goto exitCloseTag; + } + + if ((status = VIRT_AddResultTagForAttribute(virtInfo, + TAG_ALLACCESSRIGHTS)) != zOK) + { + goto exitCleanup; + } + + sprintf(tmpStr, MSGNot("%u"), numEntries); + if ((status = VIRT_AddAttribute(virtInfo, ATR_COUNT, tmpStr, TRUE, FALSE, + TRUE)) != zOK) + { + goto exitCleanup; + } + + for (i = 0; i < numEntries; i++) + { + if (COMN_ZAS_getEffectiveRightsByID(genMsg, &nameMsg, + &aclEntries[i].trusteeID, &rights) != zOK) + { + MNSS_BuildResult(virtInfo, GetErrno(genMsg), + MSGNot("Error getting effective rights")); + VIRT_AddResultTag(virtInfo, TAG_ALLACCESSRIGHTS, TRUE, TRUE); + goto exitCloseTag; + } + + if ((status = VIRT_AddResultTag(virtInfo, TAG_ACCESSRIGHTS, + FALSE, FALSE)) != zOK) + { + goto exitCleanup; + } + MFILE_FillInAnID(virtInfo, NULL, &aclEntries[i].trusteeID); + if ((status = VIRT_AddResultTag(virtInfo, TAG_RIGHTS, + FALSE, FALSE)) != zOK) + { + goto exitCleanup; + } + + MFILE_ConvertMaskToRights(virtInfo, rights); + if ((status = VIRT_AddResultTag(virtInfo, TAG_RIGHTS, + TRUE, FALSE)) != zOK) + { + goto exitCleanup; + } + if ((status = VIRT_AddResultTag(virtInfo, TAG_ACCESSRIGHTS, + TRUE, TRUE)) != zOK) + { + goto exitCleanup; + } + } + + if ((status = VIRT_AddResultTag(virtInfo, TAG_ALLACCESSRIGHTS, TRUE, + TRUE)) != zOK) + { + goto exitCleanup; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + +exitCloseTag: + status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exitCleanup: + COMN_CleanupNameMsg(genMsg, &nameMsg); + if (aclEntries) + { + free(aclEntries); + } +exit: + return status; +} + +/**************************************************************************** + * + * This function return the inheritance structure for a user. + * + ****************************************************************************/ +STATUS MFILE_ProcessGetInheritedRightsForUser( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + GeneralMsg_s *genMsg; + STATUS status; + NamingMsg_s nameMsg; + AuthBeast_s *authBeast; + UserID_t userID; + VolumeID_t volID; + Zid_t zid; + Zid_t pzid; + NINT namelen; + unicode_t *ucname = NULL; + utf8_t *cname = NULL; + + const TagRequest_s tags[] = + { + {TAG_CONTEXT, TR_OPTIONAL}, + {TAG_NAME, TR_CONTENT_REQUIRED}, + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + CONTEXT = 0, + NAME = 1, + FILE_NAME = 2 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + status = zOK; + goto exit; + } + return status; + } + genMsg = virtInfo->genMsg; + + // Resolve the user's name to an ID + if ((status = MFILE_ConvertNametoID(tagContent[CONTEXT].content, + tagContent[NAME].content, + &userID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Bad user name")); + goto exit; + } + + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto exit; + } + + cname = malloc(zMAX_COMPONENT_NAME * sizeof(utf8_t)+1); + ucname = malloc(zMAX_COMPONENT_NAME * sizeof(unicode_t)+1); + if (cname == NULL || ucname == NULL) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_MEMORY, + MSGNot("Error allocating memory for name")); + goto exit; + } + + /* open the file to get the info */ + MFILE_GetNameMessage(genMsg, tagContent[FILE_NAME].content, &nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exitCleanup; + } + + authBeast = (AuthBeast_s *)nameMsg.curFile; + volID = authBeast->AUTHvolume->volumeID; + zid = authBeast->AUTHzid; + pzid = zINVALID_ZID; + COMN_CleanupNameMsg(genMsg, &nameMsg); + +// if ((status = MFILE_LinuxPathToZid(tagContent[FILE_NAME].content, &volID, +// &pzid, &zid)) != zOK) +// { +// MNSS_ReturnResult(virtInfo, tagName, status, +// MSGNot("Error looking up file")); +// goto exit; +// } + + do + { + if (VIRT_AddResultTag(virtInfo, TAG_FILE, FALSE, TRUE) != zOK) + { + goto exitCloseTag; + } + + COMN_INIT_NAMING_MSG(&nameMsg); + COMN_SETUP_NAMING_MSG_VOLUME_ZID(&nameMsg, volID, pzid, + zid, zid, XLATCHED, zNSPACE_UNIX, zNTYPE_FILE, NULL); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exitCloseFileTag; + } + authBeast = (AuthBeast_s *)nameMsg.curFile; + pzid = authBeast->AUTHfirstParentZid; + + /* Check to see if the requester has admin rights */ + if (authBeast->AUTHmayIDoThis(genMsg, authBeast, + nameMsg.hlFile ? nameMsg.hlParentZid : nameMsg.fileParentZid, + MAY_I_SUPERVISE) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Insufficient rights to get effective rights")); + goto exitCloseFileTag; + } + + if (pzid == zINVALID_ZID) + { + strcpy(cname, "/"); + } + else + { + if ((status = COMN_GetNameFromBeast(genMsg, authBeast, zNSPACE_UNIX, + zMAX_COMPONENT_NAME+1, ucname, &namelen)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Unable to get path component")); + goto exitCloseFileTag; + } + if (uni2utf(ucname, cname, zMAX_COMPONENT_NAME) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, -1, + MSGNot("Error converting unicode to UTF8")); + goto exitCloseFileTag; + } + } + VIRT_AddResultCDataElement(virtInfo, TAG_NAME, cname, TRUE); + + if ((status = MFILE_ListIRF(genMsg, &nameMsg, virtInfo)) != zOK) + { + goto exitCloseFileTag; + } + if ((status = MFILE_ListEquivalentTrustees(genMsg, &nameMsg, virtInfo, + &userID)) != zOK) + { + goto exitCloseFileTag; + } + if ((status = MFILE_GetEffectiveRightsByID(genMsg, &nameMsg, virtInfo, + &userID)) != zOK) + { + goto exitCloseFileTag; + } + + if ((status = VIRT_AddResultTag(virtInfo, TAG_FILE, TRUE, + TRUE)) != zOK) + { + goto exitCleanup; + } + zid = pzid; + pzid = zINVALID_ZID; + COMN_CleanupNameMsg(genMsg, &nameMsg); + } while (zid != zINVALID_ZID); + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + goto exitCloseTag; + +exitCloseFileTag: + VIRT_AddResultTag(virtInfo, TAG_FILE, TRUE, TRUE); + +exitCleanup: + COMN_CleanupNameMsg(genMsg, &nameMsg); + +exitCloseTag: + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + free(cname); + free(ucname); + return zOK; +} + +/**************************************************************************** + * + * This function adds a quota to a directory + * + ****************************************************************************/ +STATUS MFILE_ProcessAddQuota( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + SQUAD quota; + const TagRequest_s tags[] = + { + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {TAG_QUOTAAMOUNT, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + FILE_NAME = 0, + QUOTA_AMOUNT = 1 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + quota = atoq(tagContent[QUOTA_AMOUNT].content); + + /* add the quota */ + genMsg = virtInfo->genMsg; + MFILE_GetNameMessage(genMsg, tagContent[FILE_NAME].content, &nameMsg); + /* Do NOT operate on link here. A junction may look like a subdirectory */ + /* to the user, but it isn't. */ + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exit; + } + + /* If quota requested is -1 it means completely restricted */ + if (quota < 0) + { + quota = 0; + } + if (quota == zDIR_NO_QUOTA) + { /* remove the quota */ + if (DIRQ_RemoveDirectoryQuota(genMsg, nameMsg.curvol, nameMsg.curFile) + != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error removing quota")); + goto exit; + } + } + else + { /* add the quota */ + if (DIRQ_SetDirectoryQuota(genMsg, nameMsg.curvol, nameMsg.curFile, + quota) != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error adding quota")); + goto exit; + } + } + COMN_CleanupNameMsg(genMsg, &nameMsg); + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function scans salvageable files + * + ****************************************************************************/ +STATUS MFILE_ProcessScanSalvageableFiles( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + SearchMsg_s searchMsg; + QUAD scanSequence; + VolumeID_t volumeID; + Volume_s *volume = NULL; + NINT nameSpaceID; + Zid_t dirZid = zINVALID_ZID; + QUAD infoMask = 0; + zInfoB_s *zInfo = NULL; + GetInfoMsg_s infoMsg; + utf8_t *searchStart; + XML_ElementInfo_s getInfoElement; + utf8_t *nextTagName; + NINT tagLen; + typedef struct Stack_s { + unicode_t uniName[zMAX_COMPONENT_NAME]; + utf8_t utf8Name[zMAX_COMPONENT_NAME]; + BYTE buf[1024]; + } Stack_s; + + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_OPTIONAL}, + {TAG_SCANSEQUENCE, TR_CONTENT_REQUIRED}, + {TAG_PARENTID, TR_OPTIONAL}, + {TAG_PARENTPATH, TR_OPTIONAL}, + {TAG_PARENTFULLPATH, TR_OPTIONAL}, + {TAG_NAMESPACE, TR_CONTENT_REQUIRED}, + {TAG_TYPEOFINFO, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + VOLUME_NAME = 0, + SCAN_SEQUENCE = 1, + PARENT_ID = 2, + PARENT_PATH = 3, + PARENT_FULL_PATH = 4, + NAME_SPACE = 5, + TYPE_OF_INFO = 6, + }; + + STACK_ALLOC(); + + ASSERT_MPKNSS_LOCK(); + + genMsg = virtInfo->genMsg; + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + STACK_FREE(); + return status; + } + + /* now get the deleted file info */ + zInfo = malloc(sizeof(zInfoB_s)); + if (!zInfo) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_MEMORY, + MSGNot("Not enough memory")); + goto exit; + } + + /* name space id */ + nameSpaceID = atoi(tagContent[NAME_SPACE].content); + + scanSequence = strtouq(tagContent[SCAN_SEQUENCE].content, NULL, 10); + + /* + * The full path must contain enough info for us to find the volume. If + * it is used then the path and id are ignored. + */ + if (tagContent[PARENT_FULL_PATH].flags & TR_TAG_FOUND) + { + if ((tagContent[PARENT_PATH].flags & TR_TAG_FOUND) || + (tagContent[PARENT_ID].flags & TR_TAG_FOUND)) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Cannot specify full path and path or id")); + goto exit; + } + MFILE_GetNameMessage(genMsg, tagContent[PARENT_FULL_PATH].content, &nameMsg); + } + else + { + if (!(tagContent[VOLUME_NAME].flags & TR_TAG_FOUND)) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("If there is not path then a volume must be specified")); + goto exit; + } + + /* use either the path or the id to find the directory */ + if ((tagContent[PARENT_PATH].flags & TR_TAG_FOUND) + || tagContent[PARENT_ID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if (tagContent[PARENT_ID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if (tagContent[PARENT_PATH].flags & TR_TAG_FOUND) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Either specify scan directory's zid or path, but not both")); + goto exit; + } + else + { + dirZid = strtouq(tagContent[PARENT_ID].content, NULL, 10); + } + } + else + { + if (!(tagContent[PARENT_PATH].flags & TR_CONTENT_FOUND)) + { + dirZid = zROOTDIR_ZID; + tagContent[PARENT_PATH].flags = 0; + tagContent[PARENT_ID].flags = (TR_TAG_FOUND | TR_CONTENT_FOUND); + } + } + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Scan directory's zid or path is missing")); + goto exit; + } + + /* find volume by name and lock it into memory */ + if (utf2uni(tagContent[VOLUME_NAME].content, aStack->uniName, + sizeof(aStack->uniName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + + if ((volume = COMN_VolumeNameLookup(genMsg, aStack->uniName, + TRUE, &volumeID)) == NULL) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error looking up volume by name")); + goto exit; + } + + if (COMN_LockVolumeActive(genMsg, volume, FALSE) != zOK) + { + COMN_Release(&volume); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error locking volume active")); + goto exit; + } + + /* setup nameMsg */ + COMN_INIT_NAMING_MSG(&nameMsg); + COMN_SET_NAMING_MSG_VOLUME(&nameMsg, volume); + + if (tagContent[PARENT_PATH].flags & TR_TAG_FOUND) + { + COMN_SETUP_NAMING_MSG_VOLUME(&nameMsg, volumeID, + tagContent[PARENT_PATH].content, zPFMT_UTF8, + NAMPMODE_Undefined, SLATCHED, nameSpaceID, + zNTYPE_FILE, NULL, NULL, NULL, NULL); + + #ifndef __linux__ + if (nameSpaceID == zNSPACE_DOS) + { + COMN_SET_NAMING_MSG_DONT_UPPERCASE_ASCII(&nameMsg); + COMN_SET_NAMING_MSG_ASCII_CONVERT_OVERRIDES(&nameMsg, NULL, + NW_LocaleTable->DOSValidCharBitMapNoLower); + } + /* This is from NWSA_SetupNameMsgFromHandlePath + * In traditional NetWare, there were some client issues which came up + * which caused some major confusion between the LONG and DOS name spaces. + * There are many cases where a client will lookup a file in the LONG name + * space, and it needs to find the file, whether the name is a LONG name + * or just a simple 8.3 DOS name. Traditional NetWare solved this by + * adding code to all of the "GenNSxx" APIs such that if a lookup in the + * long name space fails, they try it in DOS. + * The reason we set this bit here and only here, is that every place where + * traditional NetWare does this "multi-mode" parsing corresponds one for + * one with every API/NCP that has a NWHandlePath structure. In NSS, every + * place that has a NWHandlePath structure calls this function to parse + * it. + */ + COMN_SET_NAMING_MSG_TRY_DOS_IF_LONG_FAILS(&nameMsg); + #endif + } + else + { + COMN_SETUP_NAMING_MSG_VOLUME_ZID(&nameMsg, volumeID, + /* cnt zFNU_FIRST_PARENT,*/ zINVALID_ZID, dirZid, dirZid, + SLATCHED, OS_NAME_SPACE, zNTYPE_FILE, NULL); + } + } + + /** + * Setup for the searchMsg for searching in the zNTYPE_DELETED_FILE nameType + */ + COMN_STRUCT_INIT(searchMsg); + COMN_SETUP_SEARCH_MSG (&searchMsg, scanSequence, + SMAPOPT_32BitMode | SMAPOPT_matchAllEntries, zNTYPE_DELETED_FILE); + if ((searchMsg.srchMap.id == 0xffffffff) || + (searchMsg.srchMap.id <= zROOTDIR_ZID)) + { + /** + * This is the FIRST time in, init the SMAP structure + */ + if (COMN_WildOpen(genMsg,&nameMsg,&searchMsg) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error wild open directory")); + goto cleanupNamingMsg; + } + } + else + { + /* + * Refind the searchmap from the ZID + */ + /* Do NOT operate on link here. */ + if (COMN_Lookup(genMsg,&nameMsg) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error looking up directory")); + goto cleanupNamingMsg; + } + + if (COMN_WildFindOpenContainerWithZID(genMsg, &searchMsg, &nameMsg, + (Zid_t)searchMsg.srchMap.id) !=zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error wild find open directory")); + goto cleanupNamingMsg; + } + } + + /* search for the file */ + genMsg->flags |= DO_NOT_SEND_FSHOOKS; + status = COMN_WildRead(genMsg, &nameMsg, &searchMsg); + COMN_CleanupSearchMsg( &searchMsg); + if (status != zOK) + { + genMsg->flags &= ~DO_NOT_SEND_FSHOOKS; + + if (GetErrno(genMsg) == zERR_NAME_NOT_FOUND_IN_DIRECTORY) + { + ClearErrno(genMsg); + VIRT_AddResultElement(virtInfo, tagName, "", TRUE); +// SetErrno(&genMsg, zERR_NO_MORE_NAMES_IN_PATH); +// MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), +// MSGNot("Error finding deleted file")); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error wild read directory")); + } + goto cleanupNamingMsg; + } + genMsg->flags &= ~DO_NOT_SEND_FSHOOKS; + + /* get file name */ + if (COMN_GetNameFromBeast(genMsg, nameMsg.curFile, + /* cnt nameMsg.fileNameUniquifier,*/ nameSpaceID, + zMAX_COMPONENT_NAME, aStack->uniName, NULL) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error getting file name")); + goto cleanupNamingMsg; + } + + if (uni2utf(aStack->uniName, aStack->utf8Name, zMAX_COMPONENT_NAME) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error converting name to utf8 format")); + goto cleanupNamingMsg; + } + + sprintf(aStack->buf, + "<"TAG_NEXTSCANSEQUENCE">%Lu" + "<"TAG_FILENAME">\n", + nameMsg.curFile->FILEzid, + aStack->utf8Name); + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + if ((status = VIRT_AddResultData(virtInfo, aStack->buf)) != zOK) + { + MNSS_BuildResult(virtInfo, status, MSGNot("Error adding name info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto cleanupNamingMsg; + } + + if (tagContent[TYPE_OF_INFO].flags & TR_TAG_FOUND) + { + VIRT_AddResultTag(virtInfo, TAG_TYPEOFINFO, FALSE, TRUE); + + searchStart = tagContent[TYPE_OF_INFO].element.dataStart; + for(;;) + { + /* + * Get the next tag which should be a type of info to fill in. + */ + if (XML_GetNextTag(searchStart, + tagContent[TYPE_OF_INFO].element.dataEnd, &getInfoElement, + &nextTagName, &tagLen) != zOK) + { + break; /* we have all of the elements */ + } + searchStart = getInfoElement.elementEnd + 1; + + + if (memcmp(nextTagName, TAG_RIGHTSINFO, tagLen) == 0) + { + /* + * File system rights + */ + + if (VIRT_AddResultTag(virtInfo, TAG_RIGHTSINFO, FALSE, TRUE) != zOK) + { + VIRT_AddResultTag(virtInfo, TAG_TYPEOFINFO, TRUE, TRUE); + MNSS_BuildResult(virtInfo, status, MSGNot("Error adding tag")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto cleanupNamingMsg; + } + + /* Trustee info */ + if (MFILE_ListTrustees(genMsg, &nameMsg, virtInfo) == zOK) + { + /* Inherited rights filter */ + if (MFILE_ListIRF(genMsg, &nameMsg, virtInfo) == zOK) + { + /* Effective rights */ + if (MFILE_GetEffectiveRights(genMsg, &nameMsg, virtInfo) != zOK) + { + VIRT_AddResultTag(virtInfo, TAG_RIGHTSINFO, TRUE, TRUE); + VIRT_AddResultTag(virtInfo, TAG_TYPEOFINFO, TRUE, TRUE); + MNSS_BuildResult(virtInfo, status, MSGNot("Error adding rights info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto cleanupNamingMsg; + } + } + } + if (VIRT_AddResultTag(virtInfo, TAG_RIGHTSINFO, TRUE, TRUE) != zOK) + { + VIRT_AddResultTag(virtInfo, TAG_TYPEOFINFO, TRUE, TRUE); + MNSS_BuildResult(virtInfo, status, MSGNot("Error adding tag")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto cleanupNamingMsg; + } + } + else if (memcmp(nextTagName, TAG_STANDARDINFO, tagLen) == 0) + { + infoMask |= zGET_STD_INFO | zGET_STORAGE_USED; + } + else if (memcmp(nextTagName, TAG_TIMEINFO, tagLen) == 0) + { + infoMask |= zGET_TIMES_IN_SECS; + } + else if (memcmp(nextTagName, TAG_IDINFO, tagLen) == 0) + { + infoMask |= zGET_IDS; + } + else if (memcmp(nextTagName, TAG_DATASTREAMINFO, tagLen) == 0) + { + infoMask |= zGET_DATA_STREAM_INFO; + } + else if (memcmp(nextTagName, TAG_NAMESPACEINFO, tagLen) == 0) + { + infoMask |= zGET_PRIMARY_NAMESPACE; + } + else if (memcmp(nextTagName, TAG_DELETEDINFO, tagLen) == 0) + { + infoMask |= zGET_DELETED_INFO; + } + } + + COMN_STRUCT_INIT(infoMsg); + COMN_SETUP_GET_INFO_MSG(&infoMsg, infoMask, nameMsg.nameSpaceID, + (zInfo_s *)zInfo, sizeof(*zInfo), zINFO_VERSION_B); + status = COMN_GetInfo(genMsg, &nameMsg, &infoMsg); + if (status != zOK) + { + VIRT_AddResultTag(virtInfo, TAG_TYPEOFINFO, TRUE, TRUE); + MNSS_BuildResult(virtInfo, status, MSGNot("Error getting file info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto cleanupNamingMsg; + } + + if (infoMask & zGET_STD_INFO) + { + MFILE_FillInStandardInfo(virtInfo, zInfo, nameMsg.curvol); + } + if (infoMask & zGET_TIMES_IN_SECS) + { + MFILE_FillInTimeInfo(virtInfo, zInfo); + } + if (infoMask & zGET_IDS) + { + MFILE_FillInIDInfo(virtInfo, zInfo); + } + if (infoMask & zGET_DATA_STREAM_INFO) + { + MFILE_FillInDataStreamInfo(virtInfo, zInfo); + } + if (infoMask & zGET_PRIMARY_NAMESPACE) + { + MFILE_FillInPrimaryNameSpaceInfo(virtInfo, zInfo); + } + if (infoMask & zGET_DELETED_INFO) + { + MFILE_FillInDeletedInfo(virtInfo, zInfo); + } + + VIRT_AddResultTag(virtInfo, TAG_TYPEOFINFO, TRUE, TRUE); + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +cleanupNamingMsg: + COMN_CleanupNameMsg(genMsg, &nameMsg); + +exit: + if (zInfo != NULL) + { + free(zInfo); + } + STACK_FREE(); + return zOK; + +} + +/**************************************************************************** + * + * This function salvages a file + * + ****************************************************************************/ +STATUS MFILE_ProcessSalvageDeletedFile( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + NamingMsg_s dstNameMsg; + RenameMsg_s renameMsg; + Zid_t zid; + VolumeID_t volumeID; + Volume_s *volume = NULL; + NINT nameSpaceID; + Zid_t dstDirZid = zINVALID_ZID; + utf8_t *searchStart; + XML_ElementInfo_s getInfoElement; + utf8_t *nextTagName; + NINT tagLen; + BOOL fullPath = FALSE; + typedef struct Stack_s { + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + } Stack_s; + + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_OPTIONAL}, + {TAG_ID, TR_CONTENT_REQUIRED}, + {TAG_DSTPARENTID, TR_OPTIONAL}, + {TAG_DSTPARENTPATH, TR_OPTIONAL}, + {TAG_DSTPARENTFULLPATH, TR_OPTIONAL}, + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {TAG_NAMESPACE, TR_CONTENT_REQUIRED}, + {TAG_VOLUME, TR_OPTIONAL}, + {TAG_TYPEOFINFO, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + VOLUME_NAME = 0, + FILE_ZID = 1, + DST_PARENT_ZID = 2, + DST_PARENT_PATH = 3, + DST_PARENT_FULL_PATH = 4, + FILE_NAME = 5, + NAME_SPACE = 6, + VOLUME = 7, + TYPE_OF_INFO = 8, + }; + + STACK_ALLOC(); + + ASSERT_MPKNSS_LOCK(); + + genMsg = virtInfo->genMsg; + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + STACK_FREE(); + return status; + } + +#ifdef __linux__ + // Check for excessively long rename request + + if(strlen(tagContent[FILE_NAME].content) > LSA_NAME_LEN) + { + STACK_FREE(); + return zERR_INVALID_NAME; + } +#endif + + /* + * The full path must contain enough info for us to find the volume. If + * it is used then the path and id are ignored. + */ + if (tagContent[DST_PARENT_FULL_PATH].flags & TR_TAG_FOUND) + { + if ((tagContent[DST_PARENT_PATH].flags & TR_TAG_FOUND) || + (tagContent[DST_PARENT_ZID].flags & TR_TAG_FOUND)) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Cannot specify full path and path or id")); + goto exit; + } + fullPath = TRUE; + } + else if ((tagContent[DST_PARENT_PATH].flags & TR_TAG_FOUND) + || tagContent[DST_PARENT_ZID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if (tagContent[DST_PARENT_ZID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if (tagContent[DST_PARENT_PATH].flags & TR_TAG_FOUND) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Either specify target parent's zid or path, but not both")); + goto exit; + } + else + { + dstDirZid = strtouq(tagContent[DST_PARENT_ZID].content, NULL, 10); + } + } + else + { + if (!(tagContent[DST_PARENT_PATH].flags & TR_CONTENT_FOUND)) + { + dstDirZid = zROOTDIR_ZID; + tagContent[DST_PARENT_PATH].flags = 0; + tagContent[DST_PARENT_ZID].flags = (TR_TAG_FOUND | TR_CONTENT_FOUND); + } + } + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Target parent zid or path is missing")); + goto exit; + } + + /* deleted file's zid */ + zid = strtouq(tagContent[FILE_ZID].content, NULL, 10); + + /* name space id */ + nameSpaceID = atoi(tagContent[NAME_SPACE].content); + + /* find volume by name and lock it into memory */ + if (tagContent[VOLUME_NAME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if (utf2uni(tagContent[VOLUME_NAME].content, aStack->uniVolName, + sizeof(aStack->uniVolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + } + else if (tagContent[VOLUME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + /* there was an inconsistancy in the vfs doc and first version + * of implementation. This part is done for backward support + */ + if (utf2uni(tagContent[VOLUME].content, aStack->uniVolName, + sizeof(aStack->uniVolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Volume name is missing")); + goto exit; + } + + if ((volume = COMN_VolumeNameLookup(genMsg, aStack->uniVolName, + TRUE, &volumeID)) == NULL) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error looking up volume by name")); + goto exit; + } + + if (COMN_LockVolumeActive(genMsg, volume, FALSE) != zOK) + { + COMN_Release(&volume); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error locking volume active")); + goto exit; + } + + /* look up a deleted file */ + COMN_INIT_NAMING_MSG(&nameMsg); + COMN_SET_NAMING_MSG_VOLUME(&nameMsg, volume); + COMN_SETUP_NAMING_MSG_VOLUME_ZID(&nameMsg, volumeID, + /* cnt zFNU_FIRST_PARENT,*/ zINVALID_ZID, zid, zid, + XLATCHED, OS_NAME_SPACE, zNTYPE_DELETED_FILE, NULL); + COMN_SET_NAMING_MSG_NAMETYPES(&nameMsg, zNTYPE_DELETED_FILE); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + /* don't ever auto-forward on a hardlink for salvage */ + nameMsg.parseFlags |= NAMPFL_dontProcessHardLink; + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding deleted file")); + goto exit; + } + + if (nameMsg.nameType != zNTYPE_DELETED_FILE) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, zERR_ACCESS_DENIED, + MSGNot("Error finding deleted file")); + goto exit; + } + + /* setup dstNameMsg */ + if (!fullPath) + { + COMN_INIT_NAMING_MSG(&dstNameMsg); + + COMN_USE_BEAST(&volume->VOLroot); + COMN_LockVolumeActive(genMsg, volume, FALSE); + COMN_SET_NAMING_MSG_VOLUME(&dstNameMsg, volume); + } + + if (tagContent[DST_PARENT_PATH].flags & TR_TAG_FOUND || fullPath) + { + if (fullPath) + { + MFILE_GetNameMessage(genMsg, tagContent[DST_PARENT_FULL_PATH].content, + &dstNameMsg); + if (LB_GUIDCompare(&dstNameMsg.volumeID, &volume->volumeID) != 0) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + COMN_CleanupNameMsg(genMsg, &dstNameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("New volume must match original volume")); + goto exit; + } + } + else + { + /* dst parent is passed in by path, get it's zid first */ + COMN_SETUP_NAMING_MSG_VOLUME(&dstNameMsg, volumeID, + tagContent[DST_PARENT_PATH].content, zPFMT_UTF8, + NAMPMODE_Undefined, XLATCHED, nameSpaceID, + zNTYPE_FILE, NULL, NULL, NULL, NULL); + } + /* Do NOT operate on link here - this should be a directory */ + if (COMN_Lookup(genMsg, &dstNameMsg) != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + COMN_CleanupNameMsg(genMsg, &dstNameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding parent directory")); + goto exit; + } + dstDirZid = dstNameMsg.curFile->FILEzid; + COMN_UNLATCH_AND_RELEASE_NAMEMSG_BEASTS_KEEP_LATCHTYPE(&dstNameMsg); + + COMN_INIT_NAMING_MSG(&dstNameMsg); + COMN_SET_NAMING_MSG_VOLUME(&dstNameMsg, volume); + } + + COMN_SETUP_NAMING_MSG_VOLUME_ZID_PATH(&dstNameMsg, volumeID, + /* cnt zFNU_FIRST_PARENT,*/ dstDirZid, zNTYPE_FILE, + tagContent[FILE_NAME].content, zPFMT_UTF8, + NAMPMODE_Undefined, XLATCHED, nameSpaceID, + zNTYPE_FILE, NULL, 0, NULL, NULL); + + COMN_STRUCT_INIT(renameMsg); + COMN_SETUP_RENAME_MSG(&renameMsg, 0); + + if (COMN_Rename(genMsg, &nameMsg, &dstNameMsg, &renameMsg) != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + COMN_CleanupNameMsg(genMsg, &dstNameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error renaming a salvageable file")); + goto exit; + } + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + + if (tagContent[TYPE_OF_INFO].flags & TR_TAG_FOUND) + { + VIRT_AddResultTag(virtInfo, TAG_TYPEOFINFO, FALSE, TRUE); + + searchStart = tagContent[TYPE_OF_INFO].element.dataStart; + for(;;) + { + /* + * Get the next tag which should be a type of info to fill in. + */ + if (XML_GetNextTag(searchStart, + tagContent[TYPE_OF_INFO].element.dataEnd, &getInfoElement, + &nextTagName, &tagLen) != zOK) + { + break; /* we have all of the elements */ + } + searchStart = getInfoElement.elementEnd + 1; + + + if (memcmp(nextTagName, TAG_RIGHTSINFO, tagLen) == 0) + { + /* + * File system rights + */ + + if (VIRT_AddResultTag(virtInfo, TAG_RIGHTSINFO, FALSE, TRUE) != zOK) + { + VIRT_AddResultTag(virtInfo, TAG_TYPEOFINFO, TRUE, TRUE); + MNSS_BuildResult(virtInfo, status, MSGNot("Error adding tag")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto cleanupNamingMsg; + } + + /* Trustee info */ + if (MFILE_ListTrustees(genMsg, &nameMsg, virtInfo) == zOK) + { + /* Inherited rights filter */ + if (MFILE_ListIRF(genMsg, &nameMsg, virtInfo) == zOK) + { + /* Effective rights */ + if (MFILE_GetEffectiveRights(genMsg, &nameMsg, virtInfo) != zOK) + { + VIRT_AddResultTag(virtInfo, TAG_RIGHTSINFO, TRUE, TRUE); + VIRT_AddResultTag(virtInfo, TAG_TYPEOFINFO, TRUE, TRUE); + MNSS_BuildResult(virtInfo, status, MSGNot("Error adding rights info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto cleanupNamingMsg; + } + } + } + if (VIRT_AddResultTag(virtInfo, TAG_RIGHTSINFO, TRUE, TRUE) != zOK) + { + VIRT_AddResultTag(virtInfo, TAG_TYPEOFINFO, TRUE, TRUE); + MNSS_BuildResult(virtInfo, status, MSGNot("Error adding tag")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto cleanupNamingMsg; + } + } + } + + VIRT_AddResultTag(virtInfo, TAG_TYPEOFINFO, TRUE, TRUE); + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +cleanupNamingMsg: + COMN_CleanupNameMsg(genMsg, &nameMsg); + COMN_CleanupNameMsg(genMsg, &dstNameMsg); + +exit: + STACK_FREE(); + return zOK; + +} + +/**************************************************************************** + * + * This function purges a salvageable file + * + ****************************************************************************/ +STATUS MFILE_ProcessPurgeDeletedFile( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + DeleteMsg_s deleteMsg; + Zid_t zid; + VolumeID_t volumeID; + Volume_s *volume; + typedef struct Stack_s { + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + } Stack_s; + + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_OPTIONAL}, + {TAG_ID, TR_CONTENT_REQUIRED}, + {TAG_VOLUME, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + VOLUME_NAME = 0, + FILE_ZID = 1, + VOLUME = 2 + }; + + STACK_ALLOC(); + + ASSERT_MPKNSS_LOCK(); + + genMsg = virtInfo->genMsg; + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + STACK_FREE(); + return status; + } + + /* zid */ + zid = strtouq(tagContent[FILE_ZID].content, NULL, 10); + + /* find volume by name and lock it into memory */ + if (tagContent[VOLUME_NAME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + if (utf2uni(tagContent[VOLUME_NAME].content, aStack->uniVolName, + sizeof(aStack->uniVolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + } + else if (tagContent[VOLUME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + /* there was an inconsistancy in the vfs doc and first version + * of implementation. This part is done for backward support + */ + if (utf2uni(tagContent[VOLUME].content, aStack->uniVolName, + sizeof(aStack->uniVolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Volume name is missing")); + goto exit; + } + + if ((volume = COMN_VolumeNameLookup(genMsg, aStack->uniVolName, + TRUE, &volumeID)) == NULL) + { + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error looking up volume by name")); + goto exit; + } + + if (COMN_LockVolumeActive(genMsg, volume, FALSE) != zOK) + { + COMN_Release(&volume); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error locking volume active")); + goto exit; + } + + /* look up a deleted file */ + COMN_INIT_NAMING_MSG(&nameMsg); + COMN_SET_NAMING_MSG_VOLUME(&nameMsg, volume); + COMN_SETUP_NAMING_MSG_VOLUME_ZID(&nameMsg, volumeID, + /* cnt zFNU_FIRST_PARENT,*/ zINVALID_ZID, zid, zid, + XLATCHED, OS_NAME_SPACE, zNTYPE_DELETED_FILE, NULL); + COMN_SET_NAMING_MSG_NAMETYPES(&nameMsg, zNTYPE_DELETED_FILE); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding deleted file")); + goto exit; + } + + if (nameMsg.nameType != zNTYPE_DELETED_FILE) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, zERR_ACCESS_DENIED, + MSGNot("Error finding deleted file")); + goto exit; + } + + + /* delete it */ + COMN_DISALLOW_WILDCARDING(&nameMsg); + COMN_SETUP_DELETE_FILE_MSG(&deleteMsg, 0); + + if (COMN_Delete(genMsg, &nameMsg, &deleteMsg) != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error deleting a salvageable file")); + goto exit; + } + + COMN_CleanupNameMsg(genMsg, &nameMsg); + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + STACK_FREE(); + return zOK; + +} + +/**************************************************************************** + * + * This function gets the name and address of the archive server for a + * volume. + * + ****************************************************************************/ +STATUS MFILE_ProcessGetArchiveServer( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ +#ifndef __linux__ + enum {READLEN = 222}; + + STATUS status; + GeneralMsg_s *genMsg; + LONG numRead; + NINT offset; + utf8_t buffer[READLEN]; + utf8_t temp; + NINT len; + LONG handle; + LONG tempDirNum; + void *dirEntryPtr; + LONG volnum; + LONG pathBase; + LONG pathCount; + char retPathString[32]; + + const TagRequest_s tags[] = + { + {TAG_VOLUME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + VOLUME_NAME = 0, + FILE_ZID = 1 + }; + + + ASSERT_MPKNSS_LOCK(); + + genMsg = virtInfo->genMsg; + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + + MPKNSS_UNLOCK(); + status = ConvertPathString(0, 0, "\x1B""sys:\\ArkManager\\archive.cfg", &volnum, + &pathBase, retPathString, &pathCount); + MPKNSS_LOCK(); + if (status != 0) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error converting path string")); + goto exit; + } + + MPKNSS_UNLOCK(); + status = OpenFile(0, NSS_TASK, volnum, pathBase, retPathString, pathCount, + OS2NameSpace, 0, READ_ACCESS_BIT, PrimaryDataStream, &handle, + &tempDirNum, &dirEntryPtr); + MPKNSS_LOCK(); + if (status != 0) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error opening config file")); + goto exit; + } + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + for(offset = 0;; offset += READLEN) + { + MPKNSS_UNLOCK(); + status = ReadFile(0, handle, offset, READLEN, &numRead, buffer); + MPKNSS_LOCK(); + if (status != 0) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Error reading config file")); + goto exitClose; + + } + if (numRead != READLEN) + { + break; + } + + /* + * If this is the volume we are looking for then get the server name + * and IP and return them + */ + len = strlen(tagContent[VOLUME_NAME].content) + 1; + temp = buffer[len]; + buffer[len] = '\0'; + if (stricmp(tagContent[VOLUME_NAME].content, &buffer[1]) == 0) + { + NINT i; + + buffer[len] = temp; /* must restore this because it could be the first character of the server name */ + + /* Server name */ + for (i = 128; i > 64; i--) + { + if (buffer[i] != ' ') + { + break; + } + } + i++; + temp = buffer[i]; + buffer[i] = '\0'; + VIRT_AddResultCDataElement(virtInfo, TAG_SERVERNAME, &buffer[65], TRUE); + buffer[i] = temp; + + /* IP address */ + for (i = 143; i > 128; i--) + { + if (buffer[i] != ' ') + { + break; + } + } + i++; + temp = buffer[i]; + buffer[i] = '\0'; + VIRT_AddResultElement(virtInfo, TAG_SERVERIPADDRESS, &buffer[129], + TRUE); + buffer[i] = temp; + + /* CIFS server name */ + for (i = 221; i > 157; i--) + { + if (buffer[i] != ' ') + { + break; + } + } + i++; + temp = buffer[i]; + buffer[i] = '\0'; + VIRT_AddResultCDataElement(virtInfo, TAG_CIFSSERVERNAME, &buffer[158], + TRUE); + buffer[i] = temp; + + break; + } + else + { + buffer[len] = temp; + } + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exitClose: + MPKNSS_UNLOCK(); + CloseFile(0, NSS_TASK, handle); + MPKNSS_LOCK(); +exit: + return zOK; +#else + return zFAILURE; +#endif +} + +/**************************************************************************** + * + * This function changes the Unix owner/group name. + * + ****************************************************************************/ +STATUS MFILE_ProcessChangeOwnerGroup( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + UserID_t groupID = zINVALID_USERID; + UserID_t ownerID = zINVALID_USERID; +#if !zLINUX + LONG id; +#endif + const TagRequest_s tags[] = + { + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {TAG_OWNERID, TR_OPTIONAL | TR_CONTENT_REQUIRED}, + {TAG_OWNERNAME, TR_OPTIONAL | TR_CONTENT_REQUIRED}, + {TAG_GROUPID, TR_OPTIONAL | TR_CONTENT_REQUIRED}, + {TAG_GROUPNAME, TR_OPTIONAL | TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + FILE_NAME = 0, + OWNERID = 1, + OWNERNAME = 2, + GROUPID = 3, + GROUPNAME = 4 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Get the owner ID */ + if (tagContent[OWNERID].flags & TR_TAG_FOUND) + { + UXAS_StoreIDInGUID(atol(tagContent[OWNERID].content), &ownerID); + } + + if (tagContent[OWNERNAME].flags & TR_TAG_FOUND) + { + /* Resolve the user's name to an ID */ +#if zLINUX + if ((status = MFILE_FindUserIDByDN(NULL, + tagContent[OWNERNAME].content, &ownerID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Bad owner name")); + goto exit; + } +#else + if ((status = MNDS_GetObjectIDFromName(NULL, + tagContent[OWNERNAME].content, &id)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Bad owner name")); + goto exit; + } + + if (COMN_MapNDSIDToGUID(&status, id, &ownerID) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Owner ID to GUID conversion error")); + goto exit; + } +#endif + } + + /* Get the group ID */ + if (tagContent[GROUPID].flags & TR_TAG_FOUND) + { + UXAS_StoreIDInGUID(atol(tagContent[GROUPID].content), &groupID); + } + + if (tagContent[GROUPNAME].flags & TR_TAG_FOUND) + { + /* Resolve the user's name to an ID */ +#if zLINUX + if ((status = MFILE_FindUserIDByDN(NULL, + tagContent[GROUPNAME].content, &groupID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Bad group name")); + goto exit; + } +#else + if ((status = MNDS_GetObjectIDFromName(NULL, + tagContent[GROUPNAME].content, &id)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Bad group name")); + goto exit; + } + + if (COMN_MapNDSIDToGUID(&status, id, &groupID) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Group ID to GUID conversion error")); + goto exit; + } +#endif + } + + /* change the owner */ + genMsg = virtInfo->genMsg; + MFILE_GetNameMessage(genMsg, tagContent[FILE_NAME].content, &nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exit; + } + + if (COMN_UNIX_chown(genMsg, &nameMsg, &ownerID, &groupID) != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error changing owner/group")); + goto exit; + } + COMN_CleanupNameMsg(genMsg, &nameMsg); + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function changes the Unix mode field. + * + ****************************************************************************/ +STATUS MFILE_ProcessChangeMode( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + NINT mode; + + const TagRequest_s tags[] = + { + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {TAG_MODE, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + FILE_NAME = 0, + MODE = 1, + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* change the mode */ + genMsg = virtInfo->genMsg; + MFILE_GetNameMessage(genMsg, tagContent[FILE_NAME].content, &nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exit; + } + + mode = strtoul(tagContent[MODE].content, (char**)NULL, 0); + if (COMN_UNIX_chmod(genMsg, &nameMsg, mode) != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error changing mode")); + goto exit; + } + COMN_CleanupNameMsg(genMsg, &nameMsg); + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function changes the Unix mode field. + * + ****************************************************************************/ +STATUS MFILE_ProcessGetUnixInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + GeneralMsg_s *genMsg; + NamingMsg_s nameMsg; + UserID_t ownerID; + UserID_t groupID; + NINT mode; + typedef struct Stack_s { + char idString[MAX_DN_CHARS]; + } Stack_s; + + const TagRequest_s tags[] = + { + {TAG_FILENAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + FILE_NAME = 0, + MODE = 1, + }; + + STACK_ALLOC(); + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + STACK_FREE(); + return status; + } + + /* Open the file */ + genMsg = virtInfo->genMsg; + MFILE_GetNameMessage(genMsg, tagContent[FILE_NAME].content, &nameMsg); + COMN_SET_NAMING_MSG_OPERATE_ON_LINK(&nameMsg); + + if (COMN_Lookup(genMsg, &nameMsg) != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error finding file")); + goto exit; + } + + if (COMN_UNIX_statAuth(genMsg, &nameMsg, &ownerID, &groupID, &mode) != zOK) + { + COMN_CleanupNameMsg(genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(genMsg), + MSGNot("Error getting info")); + goto exit; + } + COMN_CleanupNameMsg(genMsg, &nameMsg); + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + + /* owner */ + if (ownerID.clockSeqHighAndReserved == 0xFF) + { + sprintf(aStack->idString, "%u", ownerID.timeLow); + VIRT_AddResultElement(virtInfo, TAG_OWNERID, aStack->idString, TRUE); + } + else + { + if (MNSS_GetNDSNameFromGUID(NULL, &ownerID, aStack->idString) != zOK) + { + strcpy(aStack->idString,"Unknown User"); + } + VIRT_AddResultCDataElement(virtInfo, TAG_OWNERNAME, aStack->idString, TRUE); + } + + /* group */ + if (groupID.clockSeqHighAndReserved == 0xFF) + { + sprintf(aStack->idString, "%u", groupID.timeLow); + VIRT_AddResultElement(virtInfo, TAG_GROUPID, aStack->idString, TRUE); + } + + else + { + if (MNSS_GetNDSNameFromGUID(NULL, &groupID, aStack->idString) != zOK) + { + strcpy(aStack->idString,"Unknown User"); + } + VIRT_AddResultCDataElement(virtInfo, TAG_GROUPNAME, aStack->idString, TRUE); + } + + sprintf(aStack->idString, "0x%x", mode); + VIRT_AddResultElement(virtInfo, TAG_MODE, aStack->idString, TRUE); + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); +exit: + STACK_FREE(); + return zOK; +} diff --git a/src/nwnss/manage/manageLKM.c b/src/nwnss/manage/manageLKM.c new file mode 100644 index 0000000..6135ba4 --- /dev/null +++ b/src/nwnss/manage/manageLKM.c @@ -0,0 +1,255 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Initialize the management functions + | + +-------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include + +#include /* nss */ +#include +#include /* nss */ +#include + +#include "manageStartup.h" + +/*------------------------------------------------------------------------- + * external Global variables + *-------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------- + * Global variables + *-------------------------------------------------------------------------*/ +#define LOADED_MAGIC 0x54494E4A + +struct LoadDefinitionStructure *MANAGE_ModuleHandle; +struct ScreenStruct *MANAGE_ConsoleScreen; +static LONG MANAGE_ModuleIsLoaded = 0; + +char **NSSMessageTable; + +/*------------------------------------------------------------------------- + * Defines the name of this MODULE. + *-------------------------------------------------------------------------*/ +STATIC char myNLMName[] = MODULE_NAME; +const char Module[] = MODULE_NAME; + +/*------------------------------------------------------------------------- + * Defines the CallBacks for NSS + *-------------------------------------------------------------------------*/ +NSSRegistrationCallBacks_s MANAGE_CallBacks = {MANAGE_GlobalStartup, NULL}; + + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*------------------ START OF ROUTINES ------------------------------------*/ + +/*- (FUNCTION) ----- GenericStartRoutine() ---------------------------------- + | + | Load function for the NLM initialization process + | + +-------------------------------------------------------------------------*/ +LONG GenericStartRoutine( + void *handle, + void *errorScreen, + BYTE *cmdLine) +{ + STATUS status; +#ifndef __linux__ + LONG numMessages; + LONG languageID; + BYTE *helpFile; + LONG result; +#endif + char manage_CommandLine[128]; + + /*----------------------------------------------------------------------- + | Init global variables + +---------------------------------------------------------------------*/ + Enable(); /* Because interrupts comes in masked*/ + MPKNSS_LOCK(); + + MANAGE_ModuleHandle = handle; + MANAGE_ConsoleScreen = errorScreen; + strmcpy(manage_CommandLine, cmdLine, sizeof(manage_CommandLine)); + + /*----------------------------------------------------------------------- + | setup message file + +---------------------------------------------------------------------*/ +#ifndef __linux__ + ZOS_ReturnMessageInformation(result, (LONG)handle, &NSSMessageTable, + &numMessages, &languageID, &helpFile); + if(result != zOK) + { + ERROR_LOADING_MSG_TABLES(MANAGE_ConsoleScreen); + status = zFAILURE; + goto exit; + } +#endif + + /*----------------------------------------------------------------------- + | See if the module is already loaded, if so, return now. If not init + | the SYSTEM. + *---------------------------------------------------------------------*/ + if(MANAGE_ModuleIsLoaded == LOADED_MAGIC) + { + status = zOK; + goto exit; + } + + LB_ParseCmdline(MANAGE_CommandLineSwitches, POPT_AT_STARTUP, + manage_CommandLine, NULL); + + { + // sksmith - this version and copyright string are for the MSG file + char *ver = MSG("VeRsIoN=3.00 Novell Storage Services (NSS) Management Functions",1); + char *copyR = MSG("CoPyRiGhT=(c) 1995-2001 Novell, Inc. All rights reserved.",2); + if (ver && copyR) + { + } + } + + /*----------------------------------------------------------------------- + | Register with NSS and tell them we are HERE. + +---------------------------------------------------------------------*/ + status = NSS_RegisterExternalNLM( + myNLMName, + MANAGE_ModuleHandle, + NSSMessageTable, + NSSMODULETYPE_COMMON, + NSSREGFLAG_REQUIRED, + &MANAGE_VersionInfo, + NSSAPI_VERSION, + NSS_SNAPDATE, + NSS_DEBUG_STATE, + NSS_MP_FLAG, + MANAGE_CommandLineSwitches, + &MANAGE_CallBacks); + + if(status != zOK) + { + status = zFAILURE; + goto exit; + } + + MANAGE_ModuleIsLoaded = LOADED_MAGIC; + +exit: + MPKNSS_UNLOCK(); + return(status); +} + + +/*- (FUNCTION) ----- GenericExitRoutine() ----------------------------------- + | + | This routine is called to UNLOAD the nlm + | + +-------------------------------------------------------------------------*/ +LONG GenericExitRoutine(void) +{ + Enable(); /* Because it comes in masked*/ + MPKNSS_LOCK(); + + if(MANAGE_ModuleIsLoaded == LOADED_MAGIC) + { + MANAGE_GlobalShutdown(); + NSS_UnRegisterExternalNLM(myNLMName); + } + + MPKNSS_UNLOCK(); + return zOK; +} + +void __cyg_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void __cyg_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); + + +void __cyg_profile_func_enter (void *this_fn, void *call_site) +{ + nss_profile_func_enter(this_fn, call_site); + return; +} + +void __cyg_profile_func_exit (void *this_fn, void *call_site) +{ + nss_profile_func_exit(this_fn, call_site); + return; +} + +static int __init manage_init (void) +{ + LONG retc; + + mpkEnter(); + printk("<1>" "MANAGE::%s[%d]\n", __FILE__, __LINE__ ); + retc = GenericStartRoutine( &init_module, "", "" ); + printk("<1>" "MANAGE::%s[%d]\n", __FILE__, __LINE__ ); + mpkExit(); + return(retc); // TODO: Is this correct for LINUX +} + + +static void __exit manage_exit (void) +{ + mpkEnter(); + printk("<1>" "MANAGE::%s[%d]\n", __FILE__, __LINE__ ); + GenericExitRoutine(); + printk("<1>" "MANAGE::%s[%d]\n", __FILE__, __LINE__ ); + mpkExit(); +} + + +MODULE_AUTHOR("Novell, Inc."); +MODULE_DESCRIPTION("MANAGE"); +MODULE_LICENSE("GPL v2"); + +module_init(manage_init) +module_exit(manage_exit) + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + + diff --git a/src/nwnss/manage/manageLinux.c b/src/nwnss/manage/manageLinux.c new file mode 100644 index 0000000..83b4aa1 --- /dev/null +++ b/src/nwnss/manage/manageLinux.c @@ -0,0 +1,1040 @@ +/**************************************************************************** + | + | (C) Copyright 2001, 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2007-04-06 05:25:29 +0530 (Fri, 06 Apr 2007) $ + | + | $RCSfile$ + | $Revision: 1929 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage Linux kernel operations using XML (Linux only) + | + +-------------------------------------------------------------------------*/ +#include +#include + +#include +#include +#include + +#include "manage.h" +#include "manageNlm.h" +#include "manageStartup.h" +#include "comnPublics.h" +#include "lsa.h" +#include "virtualIO.h" +#include "comnAuthorize.h" +#include "xmlTags.h" + +#include "zPool.h" +#include "guid.h" +#include "mal.h" +#include "zFriends.h" +#include "dconst.h" +#include "lsa.h" + +extern LONG MAL_CreateDeposit(struct block_device *bdev, LONG unitSize, char *poolName); + +STATUS MLNX_ProcessAddPool(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MLNX_ProcessAddVolume(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MLNX_ProcessPoolUpdate(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MLNX_ProcessPoolIDToName(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MLNX_ProcessVolumeIDToName(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MLNX_ProcessUserIDToName(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MLNX_ProcessVolumeIDFileIDToPath(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MLNX_ProcessGetVolumeInfo(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MLNX_ProcessResetIDs(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MLNX_ProcessUIDToEquivalentGUIDS(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ + +SiblingElements_s LinuxElements[] = +{ + {TAG_ADDPOOL, MLNX_ProcessAddPool}, + {TAG_ADDVOLUME, MLNX_ProcessAddVolume}, + {TAG_POOLUPDATE, MLNX_ProcessPoolUpdate}, + {TAG_POOLIDTONAME, MLNX_ProcessPoolIDToName}, + {TAG_VOLUMEIDTONAME, MLNX_ProcessVolumeIDToName}, + {TAG_USERIDTONAME, MLNX_ProcessUserIDToName}, + {TAG_VOLUMEIDFILEIDTOPATH, MLNX_ProcessVolumeIDFileIDToPath}, + {TAG_GETVOLUMEINFO, MLNX_ProcessGetVolumeInfo}, + {TAG_RESETIDS, MLNX_ProcessResetIDs}, + {TAG_UIDTOEQUIVALENTGUIDS, MLNX_ProcessUIDToEquivalentGUIDS}, + {0} +}; + +// Run time function pointers +STATUS (*GetLinuxAuthIDsListPtr)(); +EXPORT_SYMBOL(GetLinuxAuthIDsListPtr); +BOOL (*GetLinuxIsSupervisorPtr)(); +EXPORT_SYMBOL(GetLinuxIsSupervisorPtr); +Key_t (*userKeyPtr)(); +EXPORT_SYMBOL(userKeyPtr); + +/**************************************************************************** + * + * This function creates a pool on a Linux "device". + * + ****************************************************************************/ +STATUS MLNX_ProcessAddPool( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + GeneralMsg_s genMsg; + unicode_t uni_poolName[zMAX_COMPONENT_NAME]; + NINT i; +// utf8_t *retContainer = NULL; +// utf8_t *retName = NULL; +// OBID deviceID = 0; + struct block_device *dev; + + const TagRequest_s tags[] = + { + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_DEVICE, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + enum + { + POOL_NAME = 0, + DEVICE = 1, + }; + + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + /* + * Upper case the name. It is done before the unicode conversion because + * we use both the unicode and utf8 versions. + */ + for (i = 0; tagContent[POOL_NAME].content[i] != '\0'; i++) + { + tagContent[POOL_NAME].content[i] = + toupper(tagContent[POOL_NAME].content[i]); + } + tagContent[POOL_NAME].content[i] = '\0'; + + /* pool name to unicode */ + if (utf2uni(tagContent[POOL_NAME].content, uni_poolName, + sizeof(uni_poolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting pool name to unicode")); + goto exit; + } + + if ((status = LB_PoolNameAcceptable(uni_poolName)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid pool name")); + goto exit; + } + +// printk(KERN_ALERT "Mal create deposit called. device: %s name:%s\n", +// tagContent[POOL_NAME].content, tagContent[POOL_NAME].content); + MPKNSS_UNLOCK(); + +//printk(KERN_ALERT "----------------before open_bdev_excl\n"); + dev = open_bdev_excl(tagContent[DEVICE].content, 0, NULL); +//printk(KERN_ALERT "----------------after open_bdev_excl\n"); + if (IS_ERR(dev)) + { +//printk(KERN_ALERT "----------------error in open_bdev_excl\n"); + MPKNSS_LOCK(); + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error getting device pointer")); + goto exit; + } +//printk(KERN_ALERT "----------------before MAL_CreateDeposit\n"); + status = MAL_CreateDeposit(dev, PAGE_SIZE, tagContent[POOL_NAME].content); + if (status != zOK) + { + close_bdev_excl(dev); + MPKNSS_LOCK(); + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error creating deposit")); + goto exit; + } +//printk(KERN_ALERT "----------------before close_bdev_excl\n"); + close_bdev_excl(dev); +//printk(KERN_ALERT "----------------after close_bdev_excl\n"); + MPKNSS_LOCK(); + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; +} + + +/**************************************************************************** + * + * This function adds a volume to a pool. Additionally, it adds the volume + * object to NDS. + * + ****************************************************************************/ +STATUS MLNX_ProcessAddVolume( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + GeneralMsg_s genMsg; + Pool_s *pool = NULL; + Volume_s *volume = NULL; + VCO_VolumeCommonOps_s *parms; + NINT i; + NINT authModelID = zFTYPE_ZAS_AUTH_MODEL; + + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + VOLUME_NAME = 0, + POOL_NAME = 1, + }; + + ASSERT_MPKNSS_LOCK(); + +//printk(KERN_ALERT "tag name=%s\n", tagName); + parms = zalloc(sizeof(*parms)); + if (parms == NULL) + { + return zERR_NO_MEMORY; + } + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + free(parms); + return status; + } + + /* volume name */ + /* + * Upper case the name. It is done before the unicode conversion because + * we use both the unicode and utf8 versions. + */ + for (i = 0; tagContent[VOLUME_NAME].content[i] != '\0'; i++) + { + tagContent[VOLUME_NAME].content[i] = + toupper(tagContent[VOLUME_NAME].content[i]); + } + + if (utf2uni(tagContent[VOLUME_NAME].content, parms->u.create.volumeName, + sizeof(parms->u.create.volumeName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + + if ((status = LB_VolumeNameAcceptable(parms->u.create.volumeName)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid volume name")); + goto exit; + } + + /* pool name */ + for (i = 0; tagContent[POOL_NAME].content[i] != '\0'; i++) + { + tagContent[POOL_NAME].content[i] = + toupper(tagContent[POOL_NAME].content[i]); + } + + tagContent[POOL_NAME].content[i] = '\0'; + + if (utf2uni(tagContent[POOL_NAME].content, parms->u.create.poolName, + sizeof(parms->u.create.poolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error converting pool name to unicode")); + goto exit; + } + + /* + * The pool is being validated against the volume rules for now. + */ + if ((status = LB_VolumeNameValid(parms->u.create.poolName)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid pool name")); + goto exit; + } + + parms->u.create.authModelID = authModelID; + parms->u.create.guid = zINVALID_GUID; + + parms->u.create.quota = zLV_NO_QUOTA_SIZE; + parms->u.create.virtualFileFlag = FALSE; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + pool = COMN_PoolNameLookup(&genMsg, parms->u.create.poolName, TRUE, + NULL); + if (pool == NULL) + { + status = GetErrno(&genMsg); + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error finding pool in NSS")); + goto exit; + } + + /* + * Note -- We are getting a use count because the command function will + * decrement the use count and we still need to use the pool object later + * on. + */ + COMN_USE_BEAST(&pool->POOLroot); + if ((status = pool->VOLcomnVolOps.VOL_commandFunction(&genMsg, pool, + VCO_VOLUME_CREATE_NUMBER, parms, 0, NULL, 0, NULL, 0, 0, NULL, NULL)) + != zOK) + { + status = GetErrno(&genMsg); + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error creating volume")); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + if (volume != NULL) + { + COMN_Release(&volume); + } + if (pool != NULL) + { + COMN_Release(&pool); + } + free(parms); + return zOK; +} + +/**************************************************************************** + * + * This function get the name space the volume is mounted with. + * + ****************************************************************************/ +STATUS MLNX_ProcessGetVolumeInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + NINT i; + NINT nameSpaceID; + utf8_t nameSpace[16]; + VolumeID_t volumeID; + + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + VOLUME_NAME = 0, + }; + + typedef struct Stack_s { + unicode_t uni_volumeName[zMAX_COMPONENT_NAME]; + } Stack_s; + Stack_s *aStack; + + ASSERT_MPKNSS_LOCK(); + STACK_ALLOC_NO_ASTACK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + STACK_FREE(); + return status; + } + + /* volume name */ + /* + * Upper case the name. It is done before the unicode conversion because + * we use both the unicode and utf8 versions. + */ + for (i = 0; tagContent[VOLUME_NAME].content[i] != '\0'; i++) + { + tagContent[VOLUME_NAME].content[i] = + toupper(tagContent[VOLUME_NAME].content[i]); + } + + if (utf2uni(tagContent[VOLUME_NAME].content, aStack->uni_volumeName, + sizeof(aStack->uni_volumeName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + + MPKNSS_UNLOCK(); + status = xVolumeNameToGUID(aStack->uni_volumeName, &volumeID); + MPKNSS_LOCK(); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to translate volume name to an ID")); + goto exit; + } + + if (*Ptr_lsa_get_vol_namespace) + { + VIRT_AddResultTag(virtInfo, TAG_NAMESPACE, FALSE, FALSE); + nameSpaceID = Ptr_lsa_get_vol_namespace(&volumeID); + switch (nameSpaceID) + { + case zNSPACE_DOS: + { + strcpy(nameSpace, "dos"); + break; + } + case zNSPACE_LONG: + { + strcpy(nameSpace, "long"); + break; + } + case zNSPACE_MAC: + { + strcpy(nameSpace, "mac"); + break; + } + case zNSPACE_UNIX: + { + strcpy(nameSpace, "unix"); + break; + } + default: + { + strcpy(nameSpace, "unknown"); + break; + } + } + VIRT_AddResultData(virtInfo, nameSpace); + VIRT_AddResultTag(virtInfo, TAG_NAMESPACE, TRUE, TRUE); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to get the name space")); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + STACK_FREE(); + return zOK; +} + +/**************************************************************************** + * + * This function allows updating of pool internal information such as pool size + * and shared state. + * + ****************************************************************************/ +STATUS MLNX_ProcessPoolUpdate( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + unicode_t uniName[POOL_MAXNAME]; + QUAD size; + BOOL shared = FALSE; + NINT i; + struct block_device *bdev; + + const TagRequest_s tags[] = + { + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_SIZE, TR_OPTIONAL | TR_CONTENT_REQUIRED}, + {TAG_SHARED, TR_OPTIONAL}, + {TAG_NOTSHARED, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + POOL_NAME = 0, + SIZE = 1, + SHARED = 2, + NOT_SHARED = 3, + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + bzero(&uniName, sizeof(uniName)); + + /* + * Upper case the name. It is done before the unicode conversion because + * we use both the unicode and utf8 versions. + */ + for (i = 0; tagContent[POOL_NAME].content[i] != '\0'; i++) + { + tagContent[POOL_NAME].content[i] = + toupper(tagContent[POOL_NAME].content[i]); + } + tagContent[POOL_NAME].content[i] = '\0'; + + /* pool name to unicode */ + if (utf2uni(tagContent[POOL_NAME].content, uniName, + sizeof(uniName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting pool name to unicode")); + goto exit; + } + + if((status = ZLSS_GetPoolDev(uniName, &bdev)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to get pool ID")); + goto exit; + } + + if (tagContent[SIZE].flags & TR_TAG_FOUND) + { + size = atoq(tagContent[SIZE].content); + + /* Update the pool size in NSS */ + size = size / DEFAULT_BLOCK_SIZE; /* size in blocks */ + if ((status = ZLSS_SetPoolSize(bdev, size)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to update NSS with the pool's size")); + goto exit; + } + } + + if (tagContent[SHARED].flags & TR_TAG_FOUND || + tagContent[NOT_SHARED].flags & TR_TAG_FOUND) + { + /* Update the pool shared state in NSS */ + if(tagContent[NOT_SHARED].flags & TR_TAG_FOUND) + { + shared = FALSE; + } + if(tagContent[SHARED].flags & TR_TAG_FOUND) + { + shared = TRUE; + } + if ((status = ZLSS_SetPoolShared(bdev, shared)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to update NSS with the pool's shared state")); + goto exit; + } + } + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function translates a pool ID (GUID) to a name + * + ****************************************************************************/ +STATUS MLNX_ProcessPoolIDToName( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + GeneralMsg_s genMsg; + VolumeID_t poolID; + + const TagRequest_s tags[] = + { + {TAG_POOLID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + enum + { + POOL_ID = 0, + }; + + typedef struct Stack_s { + unicode_t uni_poolName[zMAX_COMPONENT_NAME]; + utf8_t poolName[zMAX_COMPONENT_NAME]; + } Stack_s; + Stack_s *aStack; + + ASSERT_MPKNSS_LOCK(); + STACK_ALLOC_NO_ASTACK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + STACK_FREE(); + return status; + } + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + if ((status = LB_GUIDFromUTF8(tagContent[POOL_ID].content, &poolID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid ID (GUID) format")); + goto exit; + } + + MPKNSS_UNLOCK(); + status = xPoolGUIDToName(&poolID, aStack->uni_poolName, zMAX_COMPONENT_NAME); + MPKNSS_LOCK(); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to translate pool ID")); + goto exit; + } + uni2utf(aStack->uni_poolName, aStack->poolName, zMAX_COMPONENT_NAME); + + VIRT_AddResultTag(virtInfo,tagName, FALSE, TRUE); + VIRT_AddResultElement(virtInfo, TAG_POOLNAME, aStack->poolName, TRUE); + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + VIRT_AddResultTag(virtInfo,tagName, TRUE, TRUE); + +exit: + STACK_FREE(); + return zOK; +} + +/**************************************************************************** + * + * This function translates a volume ID (GUID) to a name + * + ****************************************************************************/ +STATUS MLNX_ProcessVolumeIDToName( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + GeneralMsg_s genMsg; + VolumeID_t volumeID; + + const TagRequest_s tags[] = + { + {TAG_VOLUMEID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + enum + { + VOLUME_ID = 0, + }; + + typedef struct Stack_s { + unicode_t uni_volumeName[zMAX_COMPONENT_NAME]; + utf8_t volumeName[zMAX_COMPONENT_NAME]; + } Stack_s; + Stack_s *aStack; + + ASSERT_MPKNSS_LOCK(); + STACK_ALLOC_NO_ASTACK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + STACK_FREE(); + return status; + } + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + if ((status = LB_GUIDFromUTF8(tagContent[VOLUME_ID].content, &volumeID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid ID (GUID) format")); + goto exit; + } + + MPKNSS_UNLOCK(); + status = xVolumeGUIDToName(&volumeID, aStack->uni_volumeName, zMAX_COMPONENT_NAME); + MPKNSS_LOCK(); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to translate volume ID")); + goto exit; + } + uni2utf(aStack->uni_volumeName, aStack->volumeName, zMAX_COMPONENT_NAME); + + VIRT_AddResultTag(virtInfo,tagName, FALSE, TRUE); + VIRT_AddResultElement(virtInfo, TAG_VOLUMENAME, aStack->volumeName, TRUE); + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + VIRT_AddResultTag(virtInfo,tagName, TRUE, TRUE); + +exit: + STACK_FREE(); + return zOK; +} + +/**************************************************************************** + * + * This function translates a users ID (GUID) to a name + * + ****************************************************************************/ +STATUS MLNX_ProcessUserIDToName( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + GeneralMsg_s genMsg; + UserID_t userID; + + const TagRequest_s tags[] = + { + {TAG_USERID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + enum + { + USER_ID = 0, + }; + + typedef struct Stack_s { + char nameBuf[MAX_DN_CHARS]; + } Stack_s; + Stack_s *aStack; + + ASSERT_MPKNSS_LOCK(); + STACK_ALLOC_NO_ASTACK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + STACK_FREE(); + return status; + } + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + if ((status = LB_GUIDFromUTF8(tagContent[USER_ID].content, &userID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid ID (GUID) format")); + goto exit; + } + + /* Get the name from the user ID */ + if ((status = MNSS_GetNDSNameFromGUID(NULL, &userID, aStack->nameBuf)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to translate user ID")); + goto exit; + } + + VIRT_AddResultTag(virtInfo,tagName, FALSE, TRUE); + VIRT_AddResultElement(virtInfo, TAG_USERNAME, aStack->nameBuf, TRUE); + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + VIRT_AddResultTag(virtInfo,tagName, TRUE, TRUE); + +exit: + STACK_FREE(); + return zOK; +} + +/**************************************************************************** + * + * This function translates a volume ID and ZID to a path + * + ****************************************************************************/ +STATUS MLNX_ProcessVolumeIDFileIDToPath( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + GeneralMsg_s genMsg; + VolumeID_t volID; + Zid_t fileZid; + + const TagRequest_s tags[] = + { + {TAG_VOLUMEID, TR_CONTENT_REQUIRED}, + {TAG_FILEID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + enum + { + VOLUME_ID = 0, + FILE_ID = 1, + }; + + typedef struct Stack_s { + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + utf8_t volName[zMAX_COMPONENT_NAME]; + unicode_t uniPath[zMAX_FULL_NAME]; + utf8_t path[zMAX_FULL_NAME]; + } Stack_s; + Stack_s *aStack; + + ASSERT_MPKNSS_LOCK(); + STACK_ALLOC_NO_ASTACK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + STACK_FREE(); + return status; + } + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + if ((status = LB_GUIDFromUTF8(tagContent[VOLUME_ID].content, &volID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid ID (GUID) format for Volume ID")); + goto exit; + } + + fileZid = atoq(tagContent[FILE_ID].content); + + + MPKNSS_UNLOCK(); + if (COMN_ZidToFileName(&volID, fileZid, zNSPACE_UNIX, aStack->uniPath, + aStack->uniVolName) != zOK) + { + MPKNSS_LOCK(); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(&genMsg), + MSGNot("Error finding path")); + goto exit; + } + MPKNSS_LOCK(); + + if ((status = uni2utf(aStack->uniVolName, aStack->volName, + zMAX_COMPONENT_NAME)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error converting volumeName to utf8")); + goto exit; + } + + if ((status = uni2utf(aStack->uniPath, aStack->path, zMAX_FULL_NAME)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error converting path to utf8")); + goto exit; + } + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + VIRT_AddResultElement(virtInfo, TAG_VOLUMENAME, aStack->volName, TRUE); + VIRT_AddResultElement(virtInfo, TAG_PATH, aStack->path, TRUE); + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + STACK_FREE(); + return zOK; +} + +/**************************************************************************** + * + * This function resets the ID caches. + * + ****************************************************************************/ +STATUS MLNX_ProcessResetIDs( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + ASSERT_MPKNSS_LOCK(); + G2I_InvalidateCache(); + I2G_InvalidateCache(TRUE); + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + return zOK; +} + +/**************************************************************************** + * + * This function translates a Linux UID to the GUIDs in the security + * equivalence vector. + * + ****************************************************************************/ +STATUS MLNX_ProcessUIDToEquivalentGUIDS( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + GeneralMsg_s genMsg; + int index; + LONG numIDs; + uid_t uid; + char *endptr; + UserID_t *userIDs = NULL; + char id[GUID_FORMAT_SIZE]; + Key_t key; + + const TagRequest_s tags[] = + { + {TAG_UID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + enum + { + UID = 0, + }; + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + uid = strtoul(tagContent[UID].content, &endptr, 10); + if (endptr == tagContent[UID].content) + { + MNSS_ReturnResult(virtInfo, tagName, -1, + MSGNot("Unable to convert UID to a number")); + goto exit; + } + + MPKNSS_UNLOCK(); + key = userKeyPtr(uid); + MPKNSS_LOCK(); + if (!key) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_SUCH_USER, + MSGNot("Error finding UID")); + goto exit; + } + if ((status = GetLinuxAuthIDsListPtr(uid, &numIDs, &userIDs)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error getting security equivalence list")); + goto exit; + } + + VIRT_AddResultTag(virtInfo,tagName, FALSE, TRUE); + if (GetLinuxIsSupervisorPtr(uid)) + { + VIRT_AddResultElement(virtInfo, TAG_SUPERVISOR, NULL, TRUE); + } + VIRT_AddResultTag(virtInfo, TAG_EQUIVALENTIDS, FALSE, TRUE); + for(index = 0; index < numIDs; index++) + { + /* Get the name from the ID */ + /* Get the string representation of the ID */ + (void)LB_GUIDToString(&userIDs[index], GUID_FORMAT_SIZE, id); + VIRT_AddResultElement(virtInfo, TAG_USERID, id, TRUE); + } + VIRT_AddResultTag(virtInfo, TAG_EQUIVALENTIDS, TRUE, TRUE); + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + free(userIDs); + return zOK; +} + diff --git a/src/nwnss/manage/manageModules.mk b/src/nwnss/manage/manageModules.mk new file mode 100644 index 0000000..8033dca --- /dev/null +++ b/src/nwnss/manage/manageModules.mk @@ -0,0 +1,305 @@ +############################################################################## +# +# (C) Copyright 2003 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +########################################################################## +# This defines what MODULES are being built for this NLM +# +# $Author: ghorlacher $ +# $Date: 2007-09-13 03:51:53 +0530 (Thu, 13 Sep 2007) $ +# +# $RCSfile$ +# $Revision: 2206 $ +# +########################################################################## +MODULE_VERSION=15 + +#------------------------------------------------------------------------- +# If the version number is not defined here, the general product version +# number will be used (defined in bldVersion.bld) +# +# major version 1 to 99 +# minor version 1 to 99 +# sub version 1 to 26 +#------------------------------------------------------------------------- +#MAJOR_VERSION= +#MINOR_VERSION= +#SUB_VERSION= + +#------------------------------------------------------------------------- +# Build OPTIONS +#------------------------------------------------------------------------- +BUILD_WITH_KERNEL_FLAGS=1 + +#set to 0 if you are NOT using source code control +IS_USING_SOURCE_CONTROL=1 + +#Set to ONE if you want the linked files to be copied to the SDK/BIN directory. +COPY_TO_SDK_BIN=1 + + #set to ONE if you only want to copy the OPTIMIZED version to SDK/BIN. + COPY_OPTIMIZED_ONLY=0 + +#Set this to ONE if you are building a NETWARE version independent NLM +#(not NETWARE version specific) +NETWARE_VERSION_INDEPENDENT=1 + + #if ONE include the NETWARE .H files in the compiler search paths. + USE_NETWARE_INCLUDES=1 + + #if ONE include the NETWARE import file at LINK time + USE_NETWARE_IMPORTS=1 + +#If ONE IMPORT the LIBNSS APIs and include in the search path SDK/LIBRARY +#and SDK/PUBLIC +IMPORT_INDEPENDENT_LIBNSS=1 + +#If ONE include in the search path SDK/LIBRARY and SDK/PUBLIC +USE_LIBNSS_INCLUDES=1 + +#If ONE then LINK with the NSS library and include all of the NSS library +#directories in the compiler search paths. This includes the SDK/PUBLIC, +#SDK/INCLUDE, SDK/INTERNAL, LIBRARY/SRC directories. +LINK_WITH_NSSLIB=0 + +#if ONE then IMPORT the NSS library and COMN layer APIS and include the +#SDK/PUBLIC directory in the compiler search paths. +IMPORT_NSSLIB=1 + + #If ONE and (LINK_WITH_NSSLIB==1 or IMPORT_NSSLIB==1) then do the same + #operation to the NSSLIB area you are doing to the local area. + CHECK_NSSLIB=0 + + #If ONE and (CHECK_NSSLIB==1) then we will clean the NSSLIB area when we + #clean the local area. + CLEAN_NSSLIB=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INCLUDE directory in + #the compiler search paths + USE_NSS_SDK_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/COMNSA directory in + #the compiler search paths + USE_NSS_SDK_COMNSA_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INTERNAL directory in + #the compiler search paths + USE_NSS_SDK_INTERNAL_INCLUDES=1 + +#if ONE then do NOT import the NSS COMMON layer APIs +DONT_IMPORT_COMMON_LAYER=0 + +#if ONE, compile and link with the NETWARE sdk environment. +USE_NETWARE_SDK=1 + +#if ONE, include DS headers. +USE_NDS_INCLUDES=1 + +#if ONE, do LANGUAGE ENABLING processing +DO_LANGUAGE_ENABLING=0 + +#Set to null (i.e. no value) to not add XDC data to the NLM. For most +#NetWare 5.0 NLMs, the value should be -u. +MOAB_XDC_TOOL_OPTION=-n + +#************************************************************************* +# List of source directories for NSS +#************************************************************************* +SOURCE_DIRECTORIES= + +#************************************************************************* +# Source Modules for NSS (.C .386) +#************************************************************************* +SOURCE_FILES=\ + manageLKM.c \ + manageStartup.c \ + manageCmdline.c \ + manageLinux.c \ + managePool.c \ + manageVolume.c \ + manageServer.c \ + manageNDS.c \ + manageUserSpaceRestr.c \ + manageVersion.c \ + manageFile.c \ + manage.c \ + nssMANAGESym.c +# manageAdapter.c \ +# manageDevice.c \ +# manageDFS.c \ +# manageJunction.c \ +# managePartition.c \ +# manageRAID.c \ +# manageVcu.c \ +# manageVLDB.c \ +# manageVolMN.c \ +# manageUserSpaceRestr.c \ +# manageCIFS.c \ + +SOURCE_FILES_NODEBUG= + +#************************************************************************* +# Source Include files for NSS (.H .inc) +#************************************************************************* +INCLUDE_FILES=\ + manageNlm.h \ + manageVolume.h \ + managePool.h \ + manageNDS.h \ + manageServer.h \ + manageStartup.h \ + manageUserSpaceRestr.h \ + xmlTags.h + + +#------------------------------------------------------------------------- +# Additional source files that need to be checked out +#------------------------------------------------------------------------- +OTHER_FILES=\ + Module.supported + +#------------------------------------------------------------------------- +# This defines what routines are being EXPORTED. You should put .IMP +# files in the "UTILITY_EXPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_EXPORTS= + + +#UTILITY_EXPORTS_VIA_FILE= +UTILITY_EXPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# This defines what routines are being IMPORTED. You should put .IMP +# files in the "UTILITY_IMPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_IMPORTS= + +UTILITY_IMPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# Library definitions +# This defines additional libraries to LINK with and additional +# directories to put on out INCLUDE path. +#------------------------------------------------------------------------- +#additional libraries to link with +EXTRA_LIBRARIES= +EXTRA_STATIC_LIBRARIES= +EXTRA_DYNAMIC_LIBRARIES= +EXTRA_LIBRARY_INCLPATH= + +#------------------------------------------------------------------------- +# Include path +# This defines additional include path to compile with +#------------------------------------------------------------------------- +#additional include path +EXTRA_INCLUDE_PATH=\ + ${BASEDIR}/public_core/sharedsrc \ + +#------------------------------------------------------------------------- +# Additional C and ASSEMBLY options to use +#------------------------------------------------------------------------- +EXTRA_C_OPTIONS= +EXTRA_ASM_OPTIONS= +EXTRA_LINK_OPTIONS= + +#------------------------------------------------------------------------- +# Additional module attributes +#------------------------------------------------------------------------- +MODULE_DESCRIPTION='NSS Management Functions' +MODULE_ADDITIONAL_COPYRIGHT= +MODULE_OPTIONS= +MODULE_DEPENDENCIES= +MODULE_TYPE= +MODULE_NAME=nssmanage +MODULE_EXTENSION= +MODULE_START_ROUTINE= +MODULE_EXIT_ROUTINE= +#set to 1 if you want the optimized NLM to be packed +MODULE_PACK_NLM=1 + +#========================================================================= +#========================================================================= +# LOCAL BUILD RULES +#========================================================================= +#========================================================================= + +#------------------------------------------------------------------------- +# Default BUILD rule +#------------------------------------------------------------------------- +DEFAULT: DEFAULT_BUILD + +#------------------------------------------------------------------------- +# Additional rules +#------------------------------------------------------------------------- + +#BUILD_GREENRIVER_OPT: +# @echo "...This NLM does not have an OPTIMIZED GREENRIVER specific version" + +#BUILD_GREENRIVER_UNOPT: +# @echo "...This NLM does not have an UNOPTIMIZED GREENRIVER specific version" + +BUILD_MOAB_MP_UNOPT: \ + COMPILE_UNOPT_MP_MOAB \ + LINK_UNOPT_MP_MOAB + +BUILD_MOAB_MP_OPT: \ + COMPILE_OPT_MP_MOAB \ + LINK_OPT_MP_MOAB + +BUILD_MOAB_SP_UNOPT: + @echo "...This NLM does not have an UNOPTIMIZED SP specific version" + +BUILD_MOAB_SP_OPT: + @echo "...This NLM does not have an OPTIMIZED SP specific version" + + +#BUILD_MOAB_SP_UNOPT: \ +# COMPILE_UNOPT_SP_MOAB \ +# LINK_UNOPT_SP_MOAB +# +#BUILD_MOAB_SP_OPT: \ +# COMPILE_OPT_SP_MOAB \ +# LINK_OPT_SP_MOAB + + +#------------------------------------------------------------------------- +# Language Enabling rules +#------------------------------------------------------------------------- +mdb: \ + DEFAULT_MDB + +umdb: \ + LOCAL_MDB + +mdbcreate: \ + DEFAULT_CREATE_MDB_FILE + +#------------------------------------------------------------------------- +# Other rules +#------------------------------------------------------------------------- +deps: DEFAULT_DEPS + +cscope: DEFAULT_CSCOPE + diff --git a/src/nwnss/manage/manageNDS.c b/src/nwnss/manage/manageNDS.c new file mode 100644 index 0000000..7e2f933 --- /dev/null +++ b/src/nwnss/manage/manageNDS.c @@ -0,0 +1 @@ +#include diff --git a/src/nwnss/manage/manageNLM.c b/src/nwnss/manage/manageNLM.c new file mode 100644 index 0000000..b7899a8 --- /dev/null +++ b/src/nwnss/manage/manageNLM.c @@ -0,0 +1,195 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Initialize the management functions + | + +-------------------------------------------------------------------------*/ +#include /* netware */ + +#include +#include /* nss */ +#include + +#include "manageStartup.h" +#include "pssmpk.h" + +/*------------------------------------------------------------------------- + * external Global variables + *-------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------- + * Global variables + *-------------------------------------------------------------------------*/ +#define LOADED_MAGIC 0x54494E4A + +struct LoadDefinitionStructure *MANAGE_ModuleHandle; +struct ScreenStruct *MANAGE_ConsoleScreen; +static LONG MANAGE_ModuleIsLoaded = 0; + +char **NSSMessageTable; + +/*------------------------------------------------------------------------- + * Defines the name of this MODULE. + *-------------------------------------------------------------------------*/ +STATIC char myNLMName[] = MODULE_NAME; +const char Module[] = MODULE_NAME; + +/*------------------------------------------------------------------------- + * Defines the CallBacks for NSS + *-------------------------------------------------------------------------*/ +NSSRegistrationCallBacks_s MANAGE_CallBacks = {MANAGE_GlobalStartup, NULL}; + + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*------------------ START OF ROUTINES ------------------------------------*/ + +/*- (FUNCTION) ----- GenericStartRoutine() ---------------------------------- + | + | Load function for the NLM initialization process + | + +-------------------------------------------------------------------------*/ +LONG GenericStartRoutine( + struct LoadDefinitionStructure *handle, + struct ScreenStruct *errorScreen, + BYTE *cmdLine) +{ + STATUS status; + LONG numMessages; + LONG languageID; + BYTE *helpFile; + LONG result; + char manage_CommandLine[128]; + + /*----------------------------------------------------------------------- + | Init global variables + +---------------------------------------------------------------------*/ + Enable(); /* Because interrupts comes in masked*/ + MPKNSS_LOCK(); + + MANAGE_ModuleHandle = handle; + MANAGE_ConsoleScreen = errorScreen; + strmcpy(manage_CommandLine, cmdLine, sizeof(manage_CommandLine)); + + /*----------------------------------------------------------------------- + | setup message file + +---------------------------------------------------------------------*/ + ZOS_ReturnMessageInformation(result, (LONG)handle, &NSSMessageTable, + &numMessages, &languageID, &helpFile); + if(result != zOK) + { + ERROR_LOADING_MSG_TABLES(MANAGE_ConsoleScreen); + status = zFAILURE; + goto exit; + } + + /*----------------------------------------------------------------------- + | See if the module is already loaded, if so, return now. If not init + | the SYSTEM. + *---------------------------------------------------------------------*/ + if(MANAGE_ModuleIsLoaded == LOADED_MAGIC) + { + status = zOK; + goto exit; + } + + LB_ParseCmdline(MANAGE_CommandLineSwitches, POPT_AT_STARTUP, + manage_CommandLine, NULL); + + { + // sksmith - this version and copyright string are for the MSG file + char *ver = MSG("VeRsIoN=3.00 Novell Storage Services (NSS) Management Functions",1); + char *copyR = MSG("CoPyRiGhT=(c) 1995-2001 Novell, Inc. All rights reserved.",2); + if (ver && copyR) + { + } + } + + /*----------------------------------------------------------------------- + | Register with NSS and tell them we are HERE. + +---------------------------------------------------------------------*/ + status = NSS_RegisterExternalNLM( + myNLMName, + (NINT)MANAGE_ModuleHandle, + NSSMessageTable, + NSSMODULETYPE_COMMON, + NSSREGFLAG_REQUIRED, + &MANAGE_VersionInfo, + NSSAPI_VERSION, + NSS_SNAPDATE, + NSS_DEBUG_STATE, + NSS_MP_FLAG, + MANAGE_CommandLineSwitches, + &MANAGE_CallBacks); + + if(status != zOK) + { + status = zFAILURE; + goto exit; + } + + MANAGE_ModuleIsLoaded = LOADED_MAGIC; + +exit: + MPKNSS_UNLOCK(); + return(status); +} + + +/*- (FUNCTION) ----- GenericExitRoutine() ----------------------------------- + | + | This routine is called to UNLOAD the nlm + | + +-------------------------------------------------------------------------*/ +LONG GenericExitRoutine(void) +{ + Enable(); /* Because it comes in masked*/ + MPKNSS_LOCK(); + + if(MANAGE_ModuleIsLoaded == LOADED_MAGIC) + { + MANAGE_GlobalShutdown(); + NSS_UnRegisterExternalNLM(myNLMName); + } + + MPKNSS_UNLOCK(); + return zOK; +} + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + + diff --git a/src/nwnss/manage/managePartition.c b/src/nwnss/manage/managePartition.c new file mode 100644 index 0000000..2cd9d0a --- /dev/null +++ b/src/nwnss/manage/managePartition.c @@ -0,0 +1 @@ +#include diff --git a/src/nwnss/manage/managePool.c b/src/nwnss/manage/managePool.c new file mode 100644 index 0000000..b4f51f1 --- /dev/null +++ b/src/nwnss/manage/managePool.c @@ -0,0 +1,2 @@ +#include + diff --git a/src/nwnss/manage/manageServer.c b/src/nwnss/manage/manageServer.c new file mode 100644 index 0000000..4617c34 --- /dev/null +++ b/src/nwnss/manage/manageServer.c @@ -0,0 +1 @@ +#include diff --git a/src/nwnss/manage/manageStartup.c b/src/nwnss/manage/manageStartup.c new file mode 100644 index 0000000..8ab9f69 --- /dev/null +++ b/src/nwnss/manage/manageStartup.c @@ -0,0 +1,73 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Initialize MANAGE.NSS + | + +-------------------------------------------------------------------------*/ +#include +#include + +#include "manageStartup.h" +#include "manage.h" + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*------------------ START OF ROUTINES ------------------------------------*/ + +/*- (FUNCTION) ----- NLM_GlobalStartup() ------------------------------------ + | + | The will initialize the system + | + +-------------------------------------------------------------------------*/ +STATUS MANAGE_GlobalStartup(void) +{ + ASSERT_MPKNSS_LOCK(); + return MANAGE_Startup(); +} + +/*- (FUNCTION) ----- NLM_Shutdown() ----------------------------------------- + | + | Uninitilaize the system + | + +-------------------------------------------------------------------------*/ +void MANAGE_GlobalShutdown(void) +{ + MANAGE_Shutdown(); + return; +} + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ diff --git a/src/nwnss/manage/manageStartup.h b/src/nwnss/manage/manageStartup.h new file mode 100644 index 0000000..fb436c0 --- /dev/null +++ b/src/nwnss/manage/manageStartup.h @@ -0,0 +1,81 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | command line options for all input action + | + +-------------------------------------------------------------------------*/ +#ifndef _MANAGESTARTUP_H_ +#define _MANAGESTARTUP_H_ + +#include + +#ifndef _OMNI_H_ +# include +#endif + +#ifndef _DISPLAYVERSION_H_ +# include +#endif + + +#define MODULE_NAME MSGNot("MANAGE") +extern const char Module[]; + +/*------------------------------------------------------------------------- + * Global variables + *-------------------------------------------------------------------------*/ +extern struct ScreenStruct *MANAGE_ConsoleScreen; +extern struct LoadDefinitionStructure *MANAGE_ModuleHandle; +extern struct ScreenStruct *MANAGE_DefaultScreen; +extern VersionInformation_s MANAGE_VersionInfo; + +extern struct PCLSwitchDef_s MANAGE_CommandLineSwitches[]; + +/*--------------------------------------------------------------------------- + * Global startup + *---------------------------------------------------------------------------*/ +extern STATUS MANAGE_GlobalStartup(void); +extern void MANAGE_GlobalShutdown(void); +extern STATUS MANAGE_DisplayVersion(void); + +/*--------------------------------------------------------------------------- + * MANAGE + * + * Routines INIT/UNINIT the NSS management layer + *---------------------------------------------------------------------------*/ + +extern STATUS MANAGE_Startup(); +extern void MANAGE_Shutdown(); + +#endif /* _MANAGESTARTUP_H_ */ diff --git a/src/nwnss/manage/manageUserSpaceRestr.c b/src/nwnss/manage/manageUserSpaceRestr.c new file mode 100644 index 0000000..e492b9d --- /dev/null +++ b/src/nwnss/manage/manageUserSpaceRestr.c @@ -0,0 +1 @@ +#include diff --git a/src/nwnss/manage/manageUserSpaceRestr.h b/src/nwnss/manage/manageUserSpaceRestr.h new file mode 100644 index 0000000..c308f6e --- /dev/null +++ b/src/nwnss/manage/manageUserSpaceRestr.h @@ -0,0 +1,72 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Prototypes for kernel functions in manageUserSpaceRestr.c + | + +-------------------------------------------------------------------------*/ +#ifndef _MANAGE_USERSPACERESTR_H_ +#define _MANAGE_USERSPACERESTR_H_ + +/*#ifndef _ZPARAMS_H_ +#include +#endif +*/ +#ifdef __cplusplus +extern "C" { +#endif + +extern STATUS GetNextUserInVolume( + unicode_t *uniVolName, + UserID_t *lastUser, + SQUAD *restrictionAmount, + SQUAD *usedAmount, + NINT *numEntries); + +extern STATUS SetUserSpaceRestriction( + unicode_t *uniVolName, + NDSid_t userGUID, + SQUAD quota); + +extern STATUS GetUserSpaceRestriction( + unicode_t *uniVolName, + NDSid_t userGUID, + SQUAD *usedAmount, + SQUAD *restrictionAmount); + +#ifdef __cplusplus +} +#endif + +#endif /* _MANAGE_USERSPACERESTR_H_ */ + diff --git a/src/nwnss/manage/manageVcu.c b/src/nwnss/manage/manageVcu.c new file mode 100644 index 0000000..68e08ab --- /dev/null +++ b/src/nwnss/manage/manageVcu.c @@ -0,0 +1,495 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2006-12-30 03:27:16 +0530 (Sat, 30 Dec 2006) $ + | + | $RCSfile$ + | $Revision: 1799 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage NSS using XML + | + +-------------------------------------------------------------------------*/ +#include + +#include +#include +#include +#include +#include + +#include "manage.h" +#include "manageNlm.h" +#include "manageStartup.h" +#include "comnPublics.h" +#include "comnAuthorize.h" +#include "virtualIO.h" +#include "xmlTags.h" + + +#define VCU_NLM MSGNot("\x7" "VCU.NLM") + +extern LONG IsNLMLoaded(BYTE *nlmName); + + +typedef struct ManageVcuStatus_s +{ + Latch_s latch; + NINT stage; + BOOL vcuAborted; + BOOL newInfo; + struct CopyStatus_s + { + BYTE fileName[20]; /* in dos format */ + BYTE parent[20]; /* in dos format */ + NINT dirDepth; + QUAD fileSize; + QUAD movedDir; + QUAD movedFile; + QUAD errors; + }copyStatus; + struct VCUMsg_s + { + BOOL isErrMsg; + BYTE msg[200]; + }msg; + struct Waiting_s + { + THREAD threadID; + BOOL userInput; + BOOL answer; + }waiting; +}ManageVcuStatus_s; + +ManageVcuStatus_s manageVcuStatus = {0}; + +#define MANAGE_VCU_SET_INFO_NEW() \ + manageVcuStatus.newInfo = TRUE + + +#define MANAGE_VCU_SET_INFO_OLD() \ + manageVcuStatus.newInfo = FALSE + +#define MANAGE_VCU_NEW_INFO() \ + manageVcuStatus.newInfo == TRUE + + +/* It has to be matched with the one defined in vcu.h */ +enum VCUProcessStage_e +{ + VCU_BEFORE_COPY, + VCU_COPY_FILE, + VCU_AFTER_COPY, + VCU_FINISHED +}; + + +STATUS MNSS_ProcessVCUParameters(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessVCUStatus(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessVCUAbort(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessVCUResume(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + + +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ + +SiblingElements_s vcuElements[] = +{ + {TAG_VCUABORT, MNSS_ProcessVCUAbort}, + {TAG_VCUPARAMETER, MNSS_ProcessVCUParameters}, + {TAG_VCURESUME, MNSS_ProcessVCUResume}, + {TAG_VCUSTATUS, MNSS_ProcessVCUStatus}, + + + {0} +}; + + +/**************************************************************************** + * + * This function gets VCU commandline parameters. + * + ****************************************************************************/ +STATUS MNSS_ProcessVCUParameters( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + utf8_t tmpBuf[512]; + STATUS status; + + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_SWITCHES, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + tag_volume = 0, + tag_pool = 1, + tag_switches = 2, + }; + + ASSERT_MPKNSS_LOCK(); + + manageVcuStatus.vcuAborted = FALSE; + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* check if VCU is loaded, if it isn't, load it. There can be only one + * VCU running at any moment + */ + /* load nwidk.nlm if necessary */ + if (ZOS_IsNLMLoaded(VCU_NLM)) + { + status = zERR_MODULE_NAME_ALREADY_USED; + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("VCU is already running on the server.")); + goto exit; + + } + + sprintf(tmpBuf, "VCU %s %s %s", + (tagContent[tag_switches].flags & TR_CONTENT_FOUND) ? tagContent[tag_switches].content : "", + tagContent[tag_volume].content, tagContent[tag_pool].content); + + printf("tmpBuf: %s\n", tmpBuf); + + ZOS_LoadModule(status, GetSystemConsoleScreen(), tmpBuf, LO_LOAD_SILENT); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("VCU couldn't be loaded.")); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; + +} + + + +STATUS MNSS_ProcessVCUResume( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + + const TagRequest_s tags[] = + { + {TAG_VCUANSWER, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + tag_vcuanswer = 0, + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + manageVcuStatus.waiting.answer = (!strcmp(tagContent[tag_vcuanswer].content, "yes")) ? 1 : 0; + + MNSS_BuildResult(virtInfo, status, XML_SUCCESS); + + Continue(manageVcuStatus.waiting.threadID); + +exit: + return status; +} + + +STATUS MNSS_ProcessVCUStatus( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + BYTE tmpStr[50]; + + ASSERT_MPKNSS_LOCK(); + + X_LATCH(&manageVcuStatus.latch); + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto exit; + } + + sprintf(tmpStr, "%s", MANAGE_VCU_NEW_INFO()? "TRUE" : "FALSE"); + if ((status = VIRT_AddResultElement(virtInfo, TAG_VCUINFONEW, + tmpStr, TRUE)) != zOK) + { + goto exit; + } + + sprintf(tmpStr, "%d", manageVcuStatus.stage); + if ((status = VIRT_AddResultElement(virtInfo, TAG_VCUCOPYSTAGE, + tmpStr, TRUE)) != zOK) + { + goto exit; + } + + if (manageVcuStatus.stage != VCU_COPY_FILE) + { + sprintf(tmpStr, "%s", manageVcuStatus.waiting.userInput ? "TRUE" : "FALSE"); + if ((status = VIRT_AddResultElement(virtInfo, TAG_VCUWAITING, + tmpStr, TRUE)) != zOK) + { + goto exit; + } + + sprintf(tmpStr, "%s", manageVcuStatus.msg.isErrMsg ? "TRUE" : "FALSE"); + if ((status = VIRT_AddResultElement(virtInfo, TAG_VCUISERRMSG, + tmpStr, TRUE)) != zOK) + { + goto exit; + } + + if ((status = VIRT_AddResultElement(virtInfo, TAG_VCUMESSAGE, + manageVcuStatus.msg.msg, TRUE)) != zOK) + { + goto exit; + } + } + else + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_FILENAME, + manageVcuStatus.copyStatus.fileName, TRUE)) != zOK) + { + goto exit; + } + + if ((status = VIRT_AddResultElement(virtInfo, TAG_PARENT, + manageVcuStatus.copyStatus.parent, TRUE)) != zOK) + { + goto exit; + } + + formatNumber(manageVcuStatus.copyStatus.dirDepth, tmpStr); + if ((status = VIRT_AddResultElement(virtInfo, TAG_VCUDIRDEPTH, + tmpStr, TRUE)) != zOK) + { + goto exit; + } + + formatNumber(manageVcuStatus.copyStatus.fileSize, tmpStr); + if ((status = VIRT_AddResultElement(virtInfo, TAG_FILESIZE, + tmpStr, TRUE)) != zOK) + { + goto exit; + } + + formatNumber(manageVcuStatus.copyStatus.movedDir, tmpStr); + if ((status = VIRT_AddResultElement(virtInfo, TAG_VCUMOVEDDIR, + tmpStr, TRUE)) != zOK) + { + goto exit; + } + + formatNumber(manageVcuStatus.copyStatus.movedFile, tmpStr); + if ((status = VIRT_AddResultElement(virtInfo, TAG_VCUMOVEDFILE, + tmpStr, TRUE)) != zOK) + { + goto exit; + } + + formatNumber(manageVcuStatus.copyStatus.errors, tmpStr); + if ((status = VIRT_AddResultElement(virtInfo, TAG_VCUERRORS, + tmpStr, TRUE)) != zOK) + { + goto exit; + } + } + + if (!manageVcuStatus.waiting.userInput + && manageVcuStatus.waiting.threadID + && MANAGE_VCU_NEW_INFO()) + { + Continue(manageVcuStatus.waiting.threadID); + } + + MNSS_BuildResult(virtInfo, status, XML_SUCCESS); + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + MANAGE_VCU_SET_INFO_OLD(); + +exit: + UNX_LATCH(&manageVcuStatus.latch); + + return status; +} + + +STATUS MNSS_ProcessVCUAbort( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + ASSERT_MPKNSS_LOCK(); + + manageVcuStatus.vcuAborted = TRUE; + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + + return zOK; +} + + +void setManageVCUCopyStatus( + BYTE *fileName, /* in dos format & length proceeded */ + BYTE *parent, /* in dos format & length proceeded */ + NINT dirDepth, + QUAD fileSize, + QUAD movedDir, + QUAD movedFile, + QUAD errors) +{ + MPKNSS_LOCK(); + + X_LATCH(&manageVcuStatus.latch); + + MANAGE_VCU_SET_INFO_NEW(); + + manageVcuStatus.stage = VCU_COPY_FILE; + + if (fileName) + { + strcpy(manageVcuStatus.copyStatus.fileName, &fileName[1]); + } + else + { + manageVcuStatus.copyStatus.fileName[0] = 0; + } + + if (parent) + { + strcpy(manageVcuStatus.copyStatus.parent, &parent[1]); + } + else + { + manageVcuStatus.copyStatus.parent[0] = 0; + } + + manageVcuStatus.copyStatus.dirDepth = dirDepth; + manageVcuStatus.copyStatus.fileSize = fileSize; + manageVcuStatus.copyStatus.movedDir = movedDir; + manageVcuStatus.copyStatus.movedFile = movedFile; + manageVcuStatus.copyStatus.errors = errors; + + /* no waiting */ + manageVcuStatus.waiting.threadID = NULL; + manageVcuStatus.waiting.userInput = FALSE; + + UNX_LATCH(&manageVcuStatus.latch); + + MPKNSS_UNLOCK(); +} + + +void setManageVCUProcessMsg( + NINT stage, + BOOL isErrMsg, + THREAD waitingThread, + BOOL userInput, + BYTE *format, + void *args) +{ + MPKNSS_LOCK(); + + X_LATCH(&manageVcuStatus.latch); + + MANAGE_VCU_SET_INFO_NEW(); + + manageVcuStatus.stage = stage; + manageVcuStatus.waiting.threadID = waitingThread; + manageVcuStatus.waiting.userInput = userInput; + + manageVcuStatus.msg.isErrMsg = isErrMsg; + + sprintfWithPointer(manageVcuStatus.msg.msg, format, args); + + UNX_LATCH(&manageVcuStatus.latch); + + MPKNSS_UNLOCK(); +} + + +BOOL getManageVCUAbort() +{ + BOOL vcuAborted; + + MPKNSS_LOCK(); + vcuAborted = manageVcuStatus.vcuAborted; + MPKNSS_UNLOCK(); + + return vcuAborted; +} + +BOOL getManageVCUAnswer() +{ + BOOL vcuAnswer; + + MPKNSS_LOCK(); + vcuAnswer = manageVcuStatus.waiting.answer; + MPKNSS_UNLOCK(); + + return vcuAnswer; +} diff --git a/src/nwnss/manage/manageVersion.c b/src/nwnss/manage/manageVersion.c new file mode 100644 index 0000000..e1229c8 --- /dev/null +++ b/src/nwnss/manage/manageVersion.c @@ -0,0 +1,47 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Holds build number for the given product + | + +-------------------------------------------------------------------------*/ +#include + +VersionInformation_s MANAGE_VersionInfo = +{ + ZMAJV, + ZMINV, + ZSUBV, + ZBLDN, + VERINFO_NO_PATENT +}; diff --git a/src/nwnss/manage/manageVolMN.c b/src/nwnss/manage/manageVolMN.c new file mode 100644 index 0000000..39cd67b --- /dev/null +++ b/src/nwnss/manage/manageVolMN.c @@ -0,0 +1,2405 @@ +/**************************************************************************** + | + | (C) Copyright 2002, 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage NSS Volume Manager using XML + | + +-------------------------------------------------------------------------*/ + + +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "manage.h" +#include "manageNlm.h" +#include "manageStartup.h" +#include "xmlTags.h" + +#define FILE_LIST_BUFFER_SIZE (4096) + +/* Names of functions we will import */ +#define JOBMODE_MOVE 0 +#define JOBMODE_SPLIT 1 +#define JOBMODE_COPY 2 + +#define DDSGetLocalAgentInfoAPI MSGNot("\x14""DDSGetLocalAgentInfo") +#define VOLMAN_ConnectAPI MSGNot("\x14" "VOLMAN_ConnectToHost") +#define VOLMAN_DisconnectAPI MSGNot("\x11" "VOLMAN_Disconnect") +#define VOLMAN_ListOperationsAPI MSGNot("\x15" "VOLMAN_ListOperations") +#define VOLMAN_GetOperationStatusAPI MSGNot("\x19" "VOLMAN_GetOperationStatus") +#define VOLMAN_MapVolumeToGUIDAPI MSGNot("\x16" "VOLMAN_MapVolumeToGUID") +#define VOLMAN_CopyVolume2API MSGNot("\x12" "VOLMAN_CopyVolume2") +#define VOLMAN_MoveVolume2API MSGNot("\x12" "VOLMAN_MoveVolume2") +#define VOLMAN_SplitVolume2API MSGNot("\x13" "VOLMAN_SplitVolume2") +#define VOLMAN_ScheduleAPI MSGNot("\x0F" "VOLMAN_Schedule") +#define VOLMAN_PauseAPI MSGNot("\x0C" "VOLMAN_Pause") +#define VOLMAN_ResumeAPI MSGNot("\x0D" "VOLMAN_Resume") +#define VOLMAN_AbortOperationAPI MSGNot("\x15" "VOLMAN_AbortOperation") +#define VOLMAN_GetConfigAPI MSGNot("\x10" "VOLMAN_GetConfig") +#define VOLMAN_SetConfigAPI MSGNot("\x10" "VOLMAN_SetConfig") +#define VOLMAN_GetStatisticsAPI MSGNot("\x14" "VOLMAN_GetStatistics") +#define VOLMAN_GetFileNameListAPI MSGNot("\x16" "VOLMAN_GetFileNameList") + +/* Special job start time string */ +#define START_NOW "NOW" + + +/* Local prototypes */ +STATUS MNSS_VolMNChangeJobState(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_VolMNGetJobList(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_VolMNGetJobStatus(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_VolMNCreateJob(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_VolMNConfig(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_VolMNStats(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_VolMNListFiles(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + + +SiblingElements_s volmnElements[] = +{ + {TAG_GETJOBLIST, MNSS_VolMNGetJobList}, + {TAG_GETJOBSTATUS, MNSS_VolMNGetJobStatus}, + {TAG_CREATEJOB, MNSS_VolMNCreateJob}, + {TAG_CHANGEJOBSTATE, MNSS_VolMNChangeJobState}, + {TAG_CONFIG, MNSS_VolMNConfig}, + {TAG_STATISTICS, MNSS_VolMNStats}, + {TAG_LISTSKIPPEDFILES, MNSS_VolMNListFiles}, + {0} +}; + +/* Starting day of month. This table has two sections: the first is for */ +/* non-leap years, and the second is for leap years. In leap years, we */ +/* have to adjust January and February to take out the leap day that we have */ +/* already factored in... */ +NINT StartDay[] = +{ + /* Non leap years: */ + 0, /* January (31 days) */ + 31, /* February (28 days) */ + 59, /* March (31 days) */ + 90, /* April (30 days) */ + 120, /* May (31 days) */ + 151, /* June (30 days) */ + 181, /* July (31 days) */ + 212, /* August (31 days) */ + 243, /* September (30 days) */ + 273, /* October (31 days) */ + 304, /* November (30 days) */ + 334, /* December (31 days) */ + + /* Leap years: */ + -1, /* January (31 days) */ + 30, /* February (29 days) */ + 59, /* March (31 days) */ + 90, /* April (30 days) */ + 120, /* May (31 days) */ + 151, /* June (30 days) */ + 181, /* July (31 days) */ + 212, /* August (31 days) */ + 243, /* September (30 days) */ + 273, /* October (31 days) */ + 304, /* November (30 days) */ + 334 /* December (31 days) */ +}; + +/* Latch for access control to assign to the following function pointers */ +Latch_s ManageVolManLatch = {0}; +NINT ManageVolManUseCount = 0; + + +/* Function pointers to store volume manager APIs */ +STATUS (*volManConnectToHost)(unicode_t *server, + void **handle, + unicode_t *userName, + char *password) = NULL; +STATUS (*volManDisconnect)(void *handle) = NULL; +STATUS (*volManListOperations)(void *handle, + LONG *numEntries, + LONG operationList[]) = NULL; +STATUS (*volManGetOperationStatus)(void *handle, + LONG operationID, + struct VOLMNStatus *status) = NULL; +STATUS (*volManMapVolumeToGUID)(void *handle, + unicode_t *volumeName, + GUID_t *volumeGUID) = NULL; +STATUS (*volManCopyVolume2)(void *handle, + LONG *operationID, + struct jobDesc *jobInfo) = NULL; +STATUS (*volManMoveVolume2)(void *handle, + LONG *operationID, + struct jobDesc *jobInfo) = NULL; +STATUS (*volManSplitVolume2)(void *handle, + LONG *operationID, + struct jobDesc *jobInfo) = NULL; +STATUS (*volManAbortOperation)(void *handle, + LONG operationID) = NULL; +STATUS (*volManSchedule)(void *handle, + LONG operationID, + QUAD startTime) = NULL; +STATUS (*volManResume)(void *handle, + LONG operationID) = NULL; +STATUS (*volManPause)(void *handle, + LONG operationID, + unicode_t *comment) = NULL; +STATUS (*volManGetConfig)(void *handle, + struct VOLMANConfig *config) = NULL; +STATUS (*volManSetConfig)(void *handle, + struct VOLMANConfig *config) = NULL; +STATUS (*volManGetStatistics)(void *handle, + size_t bufsize, + struct VOLMANStatistics *stats) = NULL; +STATUS (*volManGetFileNameList)(void *handle, + LONG operationID, + LONG *cookie, + LONG bufsize, + unicode_t *buffer) = NULL; + +/* Import all the required Volume Manager RPC functions */ +STATUS ImportVolManRPCFunctionPtrs(void) +{ + /* Latch and use count the function pointer import */ + X_LATCH(&ManageVolManLatch); + ManageVolManUseCount++; + + /* If the function pointers are already imported */ + if (ManageVolManUseCount > 1) + { + goto successExit; + } + + if (volManConnectToHost == NULL) + { + ZOS_ImportPublicSymbol(volManConnectToHost, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_ConnectAPI); + if (volManConnectToHost == NULL) + { + goto errorExit; + } + } + + if (volManDisconnect == NULL) + { + ZOS_ImportPublicSymbol(volManDisconnect, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_DisconnectAPI); + if (volManDisconnect == NULL) + { + goto errorExit; + } + } + + if (volManListOperations == NULL) + { + ZOS_ImportPublicSymbol(volManListOperations, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_ListOperationsAPI); + if (volManListOperations == NULL) + { + goto errorExit; + } + } + + if (volManGetOperationStatus == NULL) + { + ZOS_ImportPublicSymbol(volManGetOperationStatus, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_GetOperationStatusAPI); + if (volManGetOperationStatus == NULL) + { + goto errorExit; + } + } + + if (volManMapVolumeToGUID == NULL) + { + ZOS_ImportPublicSymbol(volManMapVolumeToGUID, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_MapVolumeToGUIDAPI); + if (volManMapVolumeToGUID == NULL) + { + goto errorExit; + } + } + + if (volManCopyVolume2 == NULL) + { + ZOS_ImportPublicSymbol(volManCopyVolume2, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_CopyVolume2API); + if (volManCopyVolume2 == NULL) + { + goto errorExit; + } + } + + if (volManMoveVolume2 == NULL) + { + ZOS_ImportPublicSymbol(volManMoveVolume2, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_MoveVolume2API); + if (volManMoveVolume2 == NULL) + { + goto errorExit; + } + } + + if (volManSplitVolume2 == NULL) + { + ZOS_ImportPublicSymbol(volManSplitVolume2, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_SplitVolume2API); + if (volManSplitVolume2 == NULL) + { + goto errorExit; + } + } + + if (volManAbortOperation == NULL) + { + ZOS_ImportPublicSymbol(volManAbortOperation, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_AbortOperationAPI); + if (volManAbortOperation == NULL) + { + goto errorExit; + } + } + + if (volManSchedule == NULL) + { + ZOS_ImportPublicSymbol(volManSchedule, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_ScheduleAPI); + if (volManSchedule == NULL) + { + goto errorExit; + } + } + + if (volManResume == NULL) + { + ZOS_ImportPublicSymbol(volManResume, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_ResumeAPI); + if (volManResume == NULL) + { + goto errorExit; + } + } + + if (volManPause == NULL) + { + ZOS_ImportPublicSymbol(volManPause, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_PauseAPI); + if (volManPause == NULL) + { + goto errorExit; + } + } + + + if (volManGetConfig == NULL) + { + ZOS_ImportPublicSymbol(volManGetConfig, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_GetConfigAPI); + if (volManGetConfig == NULL) + { + goto errorExit; + } + } + + + if (volManSetConfig == NULL) + { + ZOS_ImportPublicSymbol(volManSetConfig, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_SetConfigAPI); + if (volManSetConfig == NULL) + { + goto errorExit; + } + } + + if (volManGetStatistics == NULL) + { + ZOS_ImportPublicSymbol(volManGetStatistics, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_GetStatisticsAPI); + if (volManGetStatistics == NULL) + { + goto errorExit; + } + } + + if (volManGetFileNameList == NULL) + { + ZOS_ImportPublicSymbol(volManGetFileNameList, + (LONG)MANAGE_ModuleHandle, + (BYTE *)VOLMAN_GetFileNameListAPI); + if (volManGetFileNameList == NULL) + { + goto errorExit; + } + } + +successExit: + UNX_LATCH(&ManageVolManLatch); + return zOK; + +errorExit: + UNX_LATCH(&ManageVolManLatch); + UnimportVolManRPCFunctionPtrs(); + return zFAILURE; +} + + +void UnimportVolManRPCFunctionPtrs(void) +{ + /* Latch and use count the function pointer release */ + X_LATCH(&ManageVolManLatch); + ManageVolManUseCount--; + + /* If there is another user don't release the function pointers */ + if (ManageVolManUseCount > 0) + goto noUnimport; + + if (volManConnectToHost != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_ConnectAPI); + volManConnectToHost = NULL; + } + + if (volManDisconnect != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_DisconnectAPI); + volManDisconnect = NULL; + } + + if (volManListOperations != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_ListOperationsAPI); + volManListOperations = NULL; + } + + if (volManGetOperationStatus != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_GetOperationStatusAPI); + volManGetOperationStatus = NULL; + } + + if (volManMapVolumeToGUID != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_MapVolumeToGUIDAPI); + volManMapVolumeToGUID = NULL; + } + + if (volManCopyVolume2 != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_CopyVolume2API); + volManCopyVolume2 = NULL; + } + + if (volManMoveVolume2 != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_MoveVolume2API); + volManMoveVolume2 = NULL; + } + + if (volManSplitVolume2 != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_SplitVolume2API); + volManSplitVolume2 = NULL; + } + + if (volManSchedule != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_ScheduleAPI); + volManSchedule = NULL; + } + + if (volManAbortOperation != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_AbortOperationAPI); + volManAbortOperation = NULL; + } + + if (volManResume != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_ResumeAPI); + volManResume = NULL; + } + + if (volManPause != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_PauseAPI); + volManPause = NULL; + } + + if (volManGetConfig != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_GetConfigAPI); + volManGetConfig = NULL; + } + + if (volManSetConfig != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_SetConfigAPI); + volManSetConfig = NULL; + } + + if (volManGetStatistics != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_GetStatisticsAPI); + volManGetStatistics = NULL; + } + + if (volManGetFileNameList != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)VOLMAN_GetFileNameListAPI); + volManGetFileNameList = NULL; + } + +noUnimport: + UNX_LATCH(&ManageVolManLatch); + return; +} + + +STATUS connectToVolMan(void **session) +{ + STATUS status = zOK; + + // Check to see if the VLRPC.NLM has been loaded. + if ((status = ImportVolManRPCFunctionPtrs()) != zOK) + { + goto ReadyToReturn; + } + + // Connect to the local host's volume manager + MPKNSS_UNLOCK(); + status = volManConnectToHost(NULL, session, L"", ""); + MPKNSS_LOCK(); + if (status != zOK) + status = zFAILURE; + +ReadyToReturn: + return status; +} + + +STATUS disconnectFromVolMan(void *session) +{ + STATUS status = zOK; + + if ((session != NULL) && (volManDisconnect != NULL)) + { + /* Disconnect from the Volume Manager. */ + MPKNSS_UNLOCK(); + status = volManDisconnect(session); + if (status != zOK) + status = zFAILURE; + MPKNSS_LOCK(); + } + + /* Unimport the symbols */ + UnimportVolManRPCFunctionPtrs(); + + return status; +} + + +STATUS getVolManJobList(void *handle, LONG *numEntries, LONG **jobList) +{ + STATUS status; + + /* Validate arguments */ + if ((handle == NULL) || (numEntries == NULL) || (jobList == NULL)) + return zFAILURE; + + /* Find out how big a buffer we need for the job list */ + zASSERT(volManListOperations != NULL); + MPKNSS_UNLOCK(); + status = volManListOperations(handle, numEntries, NULL); + MPKNSS_LOCK(); + if (status != zOK) + return status; + + /* No jobs? */ + if (*numEntries == 0) + { + *jobList = NULL; + goto Success; + } + + /* Allocate a buffer */ + *jobList = malloc(*numEntries * sizeof(LONG)); + if (*jobList == NULL) + return zFAILURE; + + /* Get the job list */ + MPKNSS_UNLOCK(); + status = volManListOperations(handle, numEntries, *jobList); + MPKNSS_LOCK(); + if (status != zOK) + { + free(*jobList); + *jobList = NULL; + return status; + } + +Success: + return zOK; +} + + +STATUS MNSS_VolMNGetJobList(utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status = zOK; + void *session = NULL; + LONG entry; + LONG numEntries; + LONG *jobList = NULL; + utf8_t jobIDText[16]; + + ASSERT_MPKNSS_LOCK(); + + /* Don't validate the paramter data, if any, since we don't need it + * and this lets us be forward compatible with later versions that + * might have some parameter data */ + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* Connect to volume manager */ + status = connectToVolMan(&session); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to connect to Host Volume Manager")); + goto Exit; + } + + status = getVolManJobList(session, &numEntries, &jobList); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to get job list from Volume Manager")); + goto Exit; + } + + /* Populate the response */ + for (entry = 0; entry < numEntries; entry++) + { + sprintf(jobIDText, "%d", jobList[entry]); + if ((status = VIRT_AddResultElement(virtInfo, TAG_ID, jobIDText, TRUE)) != zOK) + { + goto freeExit; + } + } + +freeExit: + if (jobList != NULL) + { + free(jobList); + } + +Exit: + /* Disconnect from the Volume Manager + * Need to use this even if connect failed + * so that the symbols get unimported */ + (void)disconnectFromVolMan(session); + + /* Add the result tag - already done if we failed */ + if (status == zOK) + { + MNSS_BuildResult(virtInfo, status, "zOK"); + } + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} + + +char *OpcodeString(WORD opcode) +{ + switch(opcode) + { + case VOLMN_MSG_OP_VOLUME_COPY: + return(MSGNot("COPY")); + + case VOLMN_MSG_OP_VOLUME_MOVE: + return(MSGNot("MOVE")); + + case VOLMN_MSG_OP_VOLUME_SPLIT: + return(MSGNot("SPLIT")); + + default: + return(MSGNot("UNKNOWN")); + } +} + + +char *StateString(WORD state) +{ + switch(state) + { + case VOLMN_PROC_INVALID: + return(MSGNot("Invalid")); + + case VOLMN_PROC_RUNNING: + return(MSGNot("Running")); + + case VOLMN_PROC_COMPLETED: + return(MSGNot("Completed")); + + case VOLMN_PROC_PRESCAN: + return(MSGNot("Scanning")); + + case VOLMN_PROC_CANCELLED: + return(MSGNot("Cancelled")); + + case VOLMN_PROC_PAUSED: + case VOLMN_PROC_PAUSED2: + case VOLMN_PROC_PAUSED3: + return(MSGNot("Paused")); + + case VOLMN_PROC_SCHEDULED: + return(MSGNot("Scheduled")); + + case VOLMN_PROC_UPDATING: + return(MSGNot("Updating")); + + case VOLMN_PROC_NAME_SELECT: + return(MSGNot("NameSelect")); + + case VOLMN_PROC_RENAMING: + return(MSGNot("Renaming")); + + case VOLMN_PROC_CREATE_JUNC: + return(MSGNot("CreateJunc")); + + case VOLMN_PROC_CLEANUP: + return(MSGNot("Cleanup")); + + case VOLMN_PROC_REPLAYING_LOG: + return(MSGNot("ReplayingLog")); + + case VOLMN_PROC_RENAME_LOGFILE: + return(MSGNot("RenameLogfile")); + + case VOLMN_PROC_NEW_LOGFILE: + return(MSGNot("NewLogfile")); + + case VOLMN_PROC_MOVE_TRUSTEES: + return(MSGNot("MoveTrustees")); + + case VOLMN_PROC_NEW_EFL: + return(MSGNot("NewEFL")); + + case VOLMN_PROC_REPLAYING_EFL: + return(MSGNot("ReplayingEFL")); + + case VOLMN_PROC_STARTING: + return(MSGNot("Starting")); + + case VOLMN_PROC_CANCELLING: + return(MSGNot("Cancelling")); + + case VOLMN_PROC_PAUSING: + case VOLMN_PROC_PAUSING2: + case VOLMN_PROC_PAUSING3: + return(MSGNot("Pausing")); + + case VOLMN_PROC_SUSPENDING: + return(MSGNot("Suspending")); + + case VOLMN_PROC_RETRY_UPDATING: + return(MSGNot("RetryUpdating")); + + case VOLMN_PROC_RETRY_NAME_SELECT: + return(MSGNot("RetryNameSelect")); + + case VOLMN_PROC_RETRY_RENAMING: + return(MSGNot("RetryRenaming")); + + case VOLMN_PROC_RETRY_CREATE_JUNC: + return(MSGNot("RetryCreateJunc")); + + case VOLMN_PROC_RETRY_CLEANUP: + return(MSGNot("RetryCleanup")); + + case VOLMN_PROC_RETRY_REPLAY: + return(MSGNot("RetryReplay")); + + case VOLMN_PROC_RETRY_RENAME_LOGFILE: + return(MSGNot("RetryRenameLogfile")); + + case VOLMN_PROC_RETRY_NEW_LOGFILE: + return(MSGNot("RetryNewLogfile")); + + case VOLMN_PROC_RETRY_MOVE_TRUSTEES: + return(MSGNot("RetryMoveTrustees")); + + case VOLMN_PROC_RETRY_NEW_EFL: + return(MSGNot("RetryNewEFL")); + + case VOLMN_PROC_RETRY_REPLAY_EFL: + return(MSGNot("RetryReplayEFL")); + + case VOLMN_PROC_FILES_SKIPPED: + return(MSGNot("FilesSkipped")); + + case VOLMN_PROC_CLEANUP_FAILED: + return(MSGNot("CleanupFailed")); + + case VOLMN_PROC_FAILED: + return(MSGNot("Failed")); + + case VOLMN_PROC_FAILED_FILE_READ: + return(MSGNot("FailedFileRead")); + + case VOLMN_PROC_FAILED_FILE_RESTORE: + return(MSGNot("FailedFileRestore")); + + case VOLMN_PROC_FAILED_BEGIN_BACKUP: + return(MSGNot("FailedBeginBackup")); + + case VOLMN_PROC_FAILED_LOGIN: + return(MSGNot("FailedLogin")); + + case VOLMN_PROC_FAILED_TARGET_VERSION: + return(MSGNot("FailedTargetVersion")); + + case VOLMN_PROC_FAILED_NO_MANAGEMENT_CONTEXT: + return(MSGNot("FailedNoManagementContext")); + + case VOLMN_PROC_FAILED_NOT_SAME_MANAGEMENT_CONTEXT: + return(MSGNot("FailedNotSameManagementContext")); + + case VOLMN_PROC_FAILED_LOG_FILE: + return(MSGNot("FailedLogFile")); + + default: + return(MSGNot("Unknown")); + } +} + + +STATUS MNSS_VolMNGetJobStatus(utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status = zOK; + void *session = NULL; + XML_ElementInfo_s curElement; + utf8_t *start; + utf8_t *end; + utf8_t *tag; + NINT tagLen; + NINT entry; + NINT nameBufLen; + BOOL allJobs = FALSE; + LONG tagCount = 0; + LONG *jobList = NULL; + utf8_t tagVal[32]; + utf8_t *nameWSpace = NULL; + struct VOLMNStatus *jobStatus = NULL; + + ASSERT_MPKNSS_LOCK(); + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* We need to count the number of ID tags that are children of getJobStatus */ + start = element->dataStart; + end = element->dataEnd; + while((start < end) + && (start != NULL) + && (end != NULL) + && (XML_GetNextTag(start, end, &curElement, &tag, &tagLen) == zOK)) + { + /* ID is the only supported tag, but don't fail on those we don't recognise */ + if ((tagLen == 2) && (memcmp(tag, TAG_ID, 2) == 0)) + tagCount++; + + /* Move on to the next tag */ + start = curElement.elementEnd + 1; + } + + /* Connect to volume manager */ + status = connectToVolMan(&session); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to connect to Host Volume Manager")); + goto exit; + } + + /* If tagCount is zero we are gettings status for all jobs */ + if (tagCount == 0) + { + /* Get the job list */ + allJobs = TRUE; + status = getVolManJobList(session, &tagCount, &jobList); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to get job list from Volume Manager")); + goto freeExit; + } + } + + /* If we get here with no jobs we are done */ + if (tagCount == 0) + { + MNSS_BuildResult(virtInfo, VMRPC_ERR_OPERATION_NOT_FOUND, + MSGNot("No jobs found")); + goto freeExit; + } + + /* Allocate memory for the job IDs */ + if (!allJobs) + jobList = malloc(sizeof(LONG) * tagCount); + jobStatus = malloc(sizeof(*jobStatus)); + nameBufLen = 3 + (((zMAX_FULL_NAME > 256) ? zMAX_FULL_NAME : 256) * 3) / 2; + nameWSpace = malloc(nameBufLen); + if ((jobList == NULL) || (jobStatus == NULL) || (nameWSpace == NULL)) + { + MNSS_BuildResult(virtInfo, zERR_NO_MEMORY, + MSGNot("No jobs found")); + goto freeExit; + } + + if (!allJobs) + { + /* Populate the job list from the request message */ + entry = 0; + start = element->dataStart; + end = element->dataEnd; + while((start < end) + && (start != NULL) + && (end != NULL) + && (XML_GetNextTag(start, end, &curElement, &tag, &tagLen) == zOK) + && (entry < tagCount)) + { + /* ID is the only supported tag, but don't fail on those we don't recognise + * or those with bad data */ + if ((tagLen == 2) + && (memcmp(tag, TAG_ID, 2) == 0) + && (curElement.dataLen < 11) + && (curElement.dataLen > 0)) + { + /* We're at an ID tag, convert from string to integer */ + memcpy(tagVal, curElement.dataStart, curElement.dataLen); + tagVal[curElement.dataLen] = 0; + jobList[entry] = atoi(tagVal); + entry++; + } + + /* Move on to the next tag */ + start = curElement.elementEnd + 1; + } + + /* The actual count is the number of legal job IDs */ + tagCount = entry; + } + + /* If we get here with no jobs we are done */ + if (tagCount == 0) + { + MNSS_BuildResult(virtInfo, VMRPC_ERR_OPERATION_NOT_FOUND, + MSGNot("No jobs found")); + goto freeExit; + } + + /* By now we have a list of job IDs in binary form, create a response from them */ + for (entry = 0; entry < tagCount; entry++) + { + /* Encapsulate the job */ + VIRT_AddResultTag(virtInfo, TAG_JOB, FALSE, TRUE); + sprintf(tagVal, "%d", jobList[entry]); + if ((status = VIRT_AddResultElement(virtInfo, TAG_ID, tagVal, TRUE)) != zOK) + goto badJobExit; + + MPKNSS_UNLOCK(); + status = volManGetOperationStatus(session, jobList[entry], jobStatus); + MPKNSS_LOCK(); + if (status == zOK) + { + /* Return the job type */ + sprintf(tagVal, "%s", OpcodeString(jobStatus->opcode)); + status = VIRT_AddResultElement(virtInfo, TAG_JOBTYPE, tagVal, TRUE); + if (status != zOK) + goto badJobExit; + + /* Return the source path */ + if (uni2utf(jobStatus->src_path, nameWSpace, nameBufLen) == -1) + goto badJobExit; + status = VIRT_AddResultElement(virtInfo, TAG_SOURCEPATH, nameWSpace, TRUE); + if (status != zOK) + goto badJobExit; + + /* Return the current state */ + sprintf(tagVal, "%s", StateString(jobStatus->state)); + status = VIRT_AddResultElement(virtInfo, TAG_STATE, tagVal, TRUE); + if (status != zOK) + goto badJobExit; + + /* Return the percent complete */ + sprintf(tagVal, "%d", jobStatus->pct_complete); + status = VIRT_AddResultElement(virtInfo, TAG_PCTCOMPLETE, tagVal, TRUE); + if (status != zOK) + goto badJobExit; + + /* Return the time value (UTC time) */ + sprintf(tagVal, "%Ld", jobStatus->time.finish); + status = VIRT_AddResultElement(virtInfo, TAG_TIME, tagVal, TRUE); + if (status != zOK) + goto badJobExit; + + /* Return the comment if the job is paused */ + if (jobStatus->state == VOLMN_PROC_PAUSED) + { + if (uni2utf(jobStatus->comment, nameWSpace, nameBufLen) == -1) + goto badJobExit; + status = VIRT_AddResultElement(virtInfo, TAG_COMMENT, nameWSpace, TRUE); + if (status != zOK) + goto badJobExit; + } + + /* Return the retry count if the job is replaying the EFL */ + if (jobStatus->state == VOLMN_PROC_REPLAYING_EFL) + { + sprintf(tagVal, "%d", jobStatus->eflAttempt); + status = VIRT_AddResultElement(virtInfo, TAG_RETRYCOUNT, tagVal, TRUE); + if (status != zOK) + goto badJobExit; + } + + /* Return the skipped file count if the job is completed or stuck */ + if ((jobStatus->state == VOLMN_PROC_COMPLETED) || + (jobStatus->state == VOLMN_PROC_FILES_SKIPPED)) + { + sprintf(tagVal, "%Ld", jobStatus->skipped); + status = VIRT_AddResultElement(virtInfo, TAG_SKIPPEDFILECOUNT, tagVal, TRUE); + if (status != zOK) + goto badJobExit; + } + + /* Return the (current) total file count if the job is not completed or failed */ + if ((jobStatus->state != VOLMN_PROC_COMPLETED) && + (! (jobStatus->state & VOLMN_PROC_FAILED))) + { + sprintf(tagVal, "%Ld", jobStatus->file_count); + status = VIRT_AddResultElement(virtInfo, TAG_TOTALFILES, tagVal, TRUE); + if (status != zOK) + goto badJobExit; + } + } + else + { + sprintf(tagVal, "%d", status); + status = VIRT_AddResultElement(virtInfo, TAG_STATUS, tagVal, TRUE); + if (status != zOK) + goto badJobExit; + } + + /* Encapsulate the job */ + VIRT_AddResultTag(virtInfo, TAG_JOB, TRUE, TRUE); + } + +badJobExit: + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Error building job status response")); + } + +freeExit: + if (nameWSpace != NULL) + free(nameWSpace); + if (jobStatus != NULL) + free(jobStatus); + if (jobList != NULL) + free(jobList); + +exit: + /* Disconnect from the Volume Manager. */ + (void)disconnectFromVolMan(session); + + /* Add the result tag - already done if we failed */ + if (status == zOK) + { + MNSS_BuildResult(virtInfo, status, "zOK"); + } + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} + + +STATUS convertTagDataToUnicode(unicode **buffer, utf8_t *tagData, NINT dataLen) +{ + STATUS status = zOK; + utf8_t savedChar; + + /* Allocate storage for the converted string */ + *buffer = malloc(sizeof(unicode_t) + sizeof(unicode_t) * dataLen); + if (*buffer == NULL) + { + status = zERR_NO_MEMORY; + goto Exit; + } + + /* Make the string look null terminated and translate it to unicode */ + savedChar = tagData[dataLen]; + tagData[dataLen] = 0; + if (utf2uni(tagData, *buffer, sizeof(unicode_t) + sizeof(unicode_t) * dataLen) == -1) + { + status = zERR_BAD_PARAMETER_VALUE; + } + tagData[dataLen] = savedChar; + +Exit: + return status; +} + + +static NINT ctoh(char c) +{ + if ((c >= '0') && (c <= '9')) + { + return(c - '0'); + } + else if ((c >= 'a') && (c <= 'f')) + { + return(c - 'a' + 10); + } + else if ((c >= 'A') && (c <= 'F')) + { + return(c - 'A' + 10); + } + else + { + return(-1); + } +} + +STATUS MNSS_VolMNCreateJob(utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status = zOK; + void *session = NULL; + NINT dnLen; + NINT state; + NINT i; + int bufsize; + int mode = JOBMODE_MOVE; + LONG operationID; + BOOL plaintext = FALSE; + VolumeID_t volumeGUID; + unicode_t *srcVol = NULL; + unicode_t *serverName = NULL; + unicode_t *treeName = NULL; + char *unp = NULL; + char *userName = NULL; + char *password = NULL; + struct jobDesc jobInfo; + char ascTreeName[256]; + utf8_t tagVal[32]; + LONG (*ddsGetLocalAgentInfo)(NINT *, void *) = NULL; + + const TagRequest_s tags[] = + { + {TAG_SOURCEVOLUME, TR_CONTENT_REQUIRED}, + {TAG_SOURCEPATH, TR_OPTIONAL}, + {TAG_TARGETSERVER, TR_CONTENT_REQUIRED}, + {TAG_TARGETVOLUME, TR_CONTENT_REQUIRED}, + {TAG_TIME, TR_CONTENT_REQUIRED}, + {TAG_IMMEDIATEPURGE, TR_OPTIONAL}, + {TAG_USER, TR_OPTIONAL}, + {TAG_PASSWORD, TR_OPTIONAL}, + {TAG_UNP, TR_OPTIONAL}, + {TAG_COPY, TR_OPTIONAL}, + {TAG_TARGETTREE, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + SOURCE_VOL = 0, + SOURCE_PATH = 1, + TARGET_SERVER = 2, + TARGET_VOL = 3, + START_TIME = 4, + IMMEDIATE_PURGE = 5, + USERNAME = 6, + PASSWORD = 7, + UNP = 8, + COPY_FLAG = 9, + TARGET_TREE = 10, + }; + + + ASSERT_MPKNSS_LOCK(); + + jobInfo.flags = 0; + jobInfo.volumeGUID = &volumeGUID; + jobInfo.pathName = NULL; + jobInfo.physName = NULL; + jobInfo.serverName = NULL; + + /* Read out the tags */ + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto freeExit; + } + return status; + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* Validate the tag data */ + if (tagContent[SOURCE_VOL].element.dataLen > 16) + { + status = zERR_BAD_PARAMETER_VALUE; + MNSS_BuildResult(virtInfo, status, + MSGNot("Invalid volume name")); + goto freeExit; + } + status = convertTagDataToUnicode(&srcVol, tagContent[SOURCE_VOL].content, tagContent[SOURCE_VOL].element.dataLen); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Translation error or out of memory parsing source volume")); + goto freeExit; + } + + if(tagContent[SOURCE_PATH].flags & TR_TAG_FOUND) + { + mode = JOBMODE_SPLIT; + status = convertTagDataToUnicode(&jobInfo.pathName, tagContent[SOURCE_PATH].content, tagContent[SOURCE_PATH].element.dataLen); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Translation error or out of memory parsing source path")); + goto freeExit; + } + } + + status = convertTagDataToUnicode(&serverName, tagContent[TARGET_SERVER].content, tagContent[TARGET_SERVER].element.dataLen); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Translation error or out of memory parsing target server")); + goto freeExit; + } + dnLen = tagContent[TARGET_SERVER].element.dataLen; + + status = convertTagDataToUnicode(&jobInfo.physName, tagContent[TARGET_VOL].content, tagContent[TARGET_VOL].element.dataLen); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Translation error or out of memory parsing target volume")); + goto freeExit; + } + + if (ConvertGeneralizedTimeToUTC(&jobInfo.startTime, tagContent[START_TIME].content, tagContent[START_TIME].element.dataLen) != zOK) + { + status = zERR_BAD_PARAMETER_VALUE; + MNSS_BuildResult(virtInfo, status, + MSGNot("Invalid start time")); + goto freeExit; + } + + /* Must supply either userName & password (plaintext) or upn (protected) */ + if ((tagContent[USERNAME].flags & TR_CONTENT_FOUND) && + (tagContent[PASSWORD].flags & TR_CONTENT_FOUND)) + { + plaintext = TRUE; + userName = malloc(tagContent[USERNAME].element.dataLen + 1); + if (userName == NULL) + { + status = zERR_NO_MEMORY; + MNSS_BuildResult(virtInfo, status, + MSGNot("Out of memory")); + goto freeExit; + } + strcpy(userName, tagContent[USERNAME].content); + + password = malloc(tagContent[PASSWORD].element.dataLen + 1); + if (password == NULL) + { + status = zERR_NO_MEMORY; + MNSS_BuildResult(virtInfo, status, + MSGNot("Out of memory")); + goto freeExit; + } + strcpy(password, tagContent[PASSWORD].content); + } + else if (tagContent[UNP].flags & TR_CONTENT_FOUND) + { + plaintext = FALSE; + bufsize = tagContent[UNP].element.dataLen / 2; + unp = malloc(bufsize); + if (unp == NULL) + { + status = zERR_NO_MEMORY; + MNSS_BuildResult(virtInfo, status, + MSGNot("Out of memory")); + goto freeExit; + } + /* Convert from ASCII hex to binary */ + for (i = 0; i < bufsize; i++) + { + unp[i] = (ctoh(tagContent[UNP].content[i*2]) << 4) + ctoh(tagContent[UNP].content[i*2+1]); + } + } + else + { + status = zERR_INVALID_USER_ID; + MNSS_BuildResult(virtInfo, status, + MSGNot("No user identification provided")); + goto freeExit; + } + + if (tagContent[COPY_FLAG].flags & TR_TAG_FOUND) + { + mode = JOBMODE_COPY; + } + + if (tagContent[IMMEDIATE_PURGE].flags & TR_TAG_FOUND) + { + jobInfo.flags |= VOLMAN_FLAG_PURGE_IMMEDIATE; + } + + if (tagContent[TARGET_TREE].flags & TR_TAG_FOUND) + { + status = convertTagDataToUnicode(&treeName, tagContent[TARGET_TREE].content, tagContent[TARGET_TREE].element.dataLen); + dnLen += tagContent[TARGET_TREE].element.dataLen; + } + else + { + /* Import a DS symbol that we can use to get the tree name */ + ZOS_ImportPublicSymbol(ddsGetLocalAgentInfo, + (LONG)MANAGE_ModuleHandle, + (BYTE *)DDSGetLocalAgentInfoAPI); + /* Get the tree name */ + if (ddsGetLocalAgentInfo != NULL) + { + status = ddsGetLocalAgentInfo(&state, ascTreeName); + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, + (BYTE *)DDSGetLocalAgentInfoAPI); + ddsGetLocalAgentInfo = NULL; + } + else + { + status = zFAILURE; + } + + if (status != 0) + { + status = zFAILURE; + MNSS_BuildResult(virtInfo, status, + MSGNot("Unable to determine treename for local server")); + goto freeExit; + } + + /* The tree name is in code page, convert it to Unicode */ + status = convertTagDataToUnicode(&treeName, ascTreeName, strlen(ascTreeName)); + dnLen += strlen(ascTreeName); + } + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Translation error or out of memory parsing tree name")); + goto freeExit; + } + + /* Build the FDN for the target server */ + jobInfo.serverName = malloc((dnLen + 4) * sizeof(unicode_t)); + if (jobInfo.serverName == NULL) + { + status = zERR_NO_MEMORY; + MNSS_BuildResult(virtInfo, status, + MSGNot("Out of memory")); + goto freeExit; + } + if (serverName[0] == L'.') + { + jobInfo.serverName[0] = 0; + } + else + { + unicpy(jobInfo.serverName, L"."); + } + unicat(jobInfo.serverName, serverName); + unicat(jobInfo.serverName, L"."); + unicat(jobInfo.serverName, treeName); + unicat(jobInfo.serverName, L"."); + + + /* Verify that all the required tags were supplied */ + if ((plaintext && ((userName == NULL) || (password == NULL))) + || ((! plaintext) && (unp == NULL)) + || (srcVol[0] == 0) + || (serverName == NULL) + || (jobInfo.physName == NULL) + || ((mode == JOBMODE_SPLIT) && (jobInfo.pathName == NULL))) + { + status = zERR_BAD_PARAMETER_VALUE; + MNSS_BuildResult(virtInfo, status, + MSGNot("Invalid paramters for move, split or copy")); + goto freeExit; + } + + /* Connect to volume manager */ + status = connectToVolMan(&session); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to connect to Host Volume Manager")); + goto disconnectExit; + } + + /* We need the source volume as a GUID */ + MPKNSS_UNLOCK(); + status = volManMapVolumeToGUID(session, srcVol, &volumeGUID); + MPKNSS_LOCK(); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to find a GUID for suplied source volume")); + goto disconnectExit; + } + + /* Now we can create the job */ + MPKNSS_UNLOCK(); + if (plaintext) + { + jobInfo.userInfo.up.userName = userName; + jobInfo.userInfo.up.password = password; + } + else + { + jobInfo.flags |= VOLMAN_FLAG_AUTH_BLOB; + jobInfo.userInfo.blob.blobLen = bufsize; + jobInfo.userInfo.blob.blob = unp; + } + switch (mode) + { + case JOBMODE_MOVE: + status = volManMoveVolume2(session, + &operationID, + &jobInfo); + break; + + case JOBMODE_SPLIT: + status = volManSplitVolume2(session, + &operationID, + &jobInfo); + break; + + case JOBMODE_COPY: + status = volManCopyVolume2(session, + &operationID, + &jobInfo); + break; + + default: + status = zERR_BAD_PARAMETER_VALUE; + break; + } + MPKNSS_LOCK(); + + /* If we failed */ + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to create job")); + goto disconnectExit; + } + + /* Return the job ID */ + sprintf(tagVal, "%d", operationID); + status = VIRT_AddResultElement(virtInfo, TAG_ID, tagVal, TRUE); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Job created but failed to create response")); + goto disconnectExit; + } + + /* Add the result tag - already done if we failed */ + if (status == zOK) + { + MNSS_BuildResult(virtInfo, status, "zOK"); + } + +disconnectExit: + /* Disconnect from the Volume Manager + * Need to use this even if connect failed + * so that the symbols get unimported */ + (void)disconnectFromVolMan(session); + +freeExit: + if (jobInfo.serverName != NULL) + { + free(jobInfo.serverName); + } + if (treeName != NULL) + { + free(treeName); + } + if (unp != NULL) + { + free(unp); + } + if (password != NULL) + { + free(password); + } + if (userName != NULL) + { + free(userName); + } + if (jobInfo.physName != NULL) + { + free(jobInfo.physName); + } + if (serverName != NULL) + { + free(serverName); + } + if (jobInfo.pathName != NULL) + { + free(jobInfo.pathName); + } + if (srcVol != NULL) + { + free(srcVol); + } + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} + + +STATUS MNSS_VolMNChangeJobState(utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + void *session = NULL; + STATUS status = zOK; + BOOL pause = FALSE; + BOOL abort = FALSE; + BOOL resume = FALSE; + NINT tagLen; + NINT trueCount = 0; + LONG jobID = 0; + QUAD startTime = 0; + utf8_t savedChar; + utf8_t *start; + utf8_t *end; + utf8_t *tag; + unicode_t *pauseComment = NULL; + XML_ElementInfo_s curElement; + + ASSERT_MPKNSS_LOCK(); + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* Walk the request decoding tags */ + start = element->dataStart; + end = element->dataEnd; + while((start < end) + && (start != NULL) + && (end != NULL) + && (XML_GetNextTag(start, end, &curElement, &tag, &tagLen) == zOK)) + { + if ((tagLen == 2) && (memcmp(tag, TAG_ID, 2) == 0)) + { + savedChar = curElement.dataStart[curElement.dataLen]; + curElement.dataStart[curElement.dataLen] = 0; + jobID = atoi(curElement.dataStart); + curElement.dataStart[curElement.dataLen] = savedChar; + } + else if ((tagLen == 4) && (memcmp(tag, TAG_TIME, 4) == 0)) + { + savedChar = curElement.dataStart[curElement.dataLen]; + curElement.dataStart[curElement.dataLen] = 0; + status = ConvertGeneralizedTimeToUTC(&startTime, curElement.dataStart, curElement.dataLen); + curElement.dataStart[curElement.dataLen] = savedChar; + if (status != zOK) + { + status = zERR_BAD_PARAMETER_VALUE; + MNSS_BuildResult(virtInfo, status, + MSGNot("Invalid start time")); + goto freeExit; + } + } + else if ((tagLen == 5) && (memcmp(tag, TAG_PAUSE, 5) == 0)) + { + pause = TRUE; + trueCount++; + status = convertTagDataToUnicode(&pauseComment, curElement.dataStart, curElement.dataLen); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Translation error or out of memory parsing pause comment")); + goto freeExit; + } + } + else if ((tagLen == 5) && (memcmp(tag, TAG_ABORT, 5) == 0)) + { + abort = TRUE; + trueCount++; + } + else if ((tagLen == 6) && (memcmp(tag, TAG_RESUME, 6) == 0)) + { + resume = TRUE; + trueCount++; + } + + /* Move on to the next tag */ + start = curElement.elementEnd + 1; + } + + /* Validate the arguments */ + if ((jobID == 0) + || (trueCount > 1) + || ((trueCount == 1) && (startTime != 0)) + || ((trueCount == 0) && (startTime == 0))) + { + status = zERR_BAD_PARAMETER_VALUE; + MNSS_BuildResult(virtInfo, status, + MSGNot("Invalid parameter")); + goto freeExit; + } + + /* Connect to volume manager */ + status = connectToVolMan(&session); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to connect to Host Volume Manager")); + goto disconnectExit; + } + + /* Now execute the operation */ + MPKNSS_UNLOCK(); + if (startTime != 0) + status = volManSchedule(session, jobID, startTime); + else if (abort) + status = volManAbortOperation(session, jobID); + else if (resume) + status = volManResume(session, jobID); + else if (pause) + status = volManPause(session, jobID, pauseComment); + MPKNSS_LOCK(); + + /* Handle errors */ + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to change job state")); + goto disconnectExit; + } + + /* Add the result tag - already done if we failed */ + if (status == zOK) + { + MNSS_BuildResult(virtInfo, status, "zOK"); + } + +disconnectExit: + /* Disconnect from the Volume Manager + * Need to use this even if connect failed + * so that the symbols get unimported */ + (void)disconnectFromVolMan(session); + +freeExit: + if (pauseComment != NULL) + { + free(pauseComment); + } + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} + + +void populateTimeRestrictions(BYTE *timeArray, NINT startBit, NINT endBit, BOOL allow) +{ + NINT startByte = startBit / 8; + NINT endByte = endBit / 8; + NINT startByteBits = startBit % 8; + NINT endByteBits = endBit % 8; + NINT bitNum; + BYTE workSpace; + + /* Populate any intermediate bytes because they are easy */ + if (endByte - startByte > 1) + { + memset(&timeArray[startByte + 1], allow ? 0 : 0xFF, endByte - startByte - 1); + } + + /* If the start byte is fully populated, it's easy too */ + if ((startByteBits == 0) && ((endByte != startByte) || (endByteBits == 7))) + { + timeArray[startByte] = allow ? 0 : 0xFF; + goto finishedStartByte; + } + + /* If the first byte is not fully populated */ + for (bitNum = startByteBits; bitNum <= ((startByte == endByte) ? endByteBits : 7); bitNum++) + { + workSpace = (1 << bitNum); + if (allow) + timeArray[startByte] &= ~workSpace; + else + timeArray[startByte] |= workSpace; + } + +finishedStartByte: + /* We're finished if the start and end bits are in the same byte */ + if (startByte == endByte) + return; + + /* If the end byte is fully populated, it's easy too */ + if (endByteBits == 7) + { + timeArray[endByte] = allow ? 0 : 0xFF; + goto finishedEndByte; + } + + /* Now do the end byte */ + for(bitNum = 0; bitNum <= endByteBits; bitNum++) + { + workSpace = (1 << bitNum); + if (allow) + timeArray[endByte] &= ~workSpace; + else + timeArray[endByte] |= workSpace; + } + +finishedEndByte: + return; +} + + +STATUS MNSS_VolMNConfig(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element) +{ + void *session = NULL; + STATUS status = zOK; + BOOL doTimes = FALSE; + BOOL didSomething = FALSE; + NINT allow; + NINT tagLen; + NINT startTime; + NINT endTime; + char wspace[10]; + utf8_t savedChar; + utf8_t *dashPos = NULL; + utf8_t *start; + utf8_t *end; + utf8_t *tag; + utf8_t *workPos; + XML_ElementInfo_s curElement; + struct VOLMANConfig volManCfg; + + ASSERT_MPKNSS_LOCK(); + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* Connect to volume manager */ + status = connectToVolMan(&session); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to connect to Host Volume Manager")); + goto disconnectExit; + } + + /* Get the current configuration */ + volManCfg.flags = VOLMAN_CONFIG_FLAG_NUM_THREADS | VOLMAN_CONFIG_FLAG_TIME_RESTRICTIONS; + MPKNSS_UNLOCK(); + status = volManGetConfig(session, &volManCfg); + MPKNSS_LOCK(); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to obtain volume manager configuration")); + goto disconnectExit; + } + + /* Walk the request decoding tags */ + start = element->dataStart; + end = element->dataEnd; + while((start < end) + && (start != NULL) + && (end != NULL) + && (XML_GetNextTag(start, end, &curElement, &tag, &tagLen) == zOK)) + { + /* Make the tag data look like a C string */ + if (curElement.dataLen > 0) + { + savedChar = curElement.dataStart[curElement.dataLen]; + curElement.dataStart[curElement.dataLen] = 0; + + /* Find any minus sign in it, used by allow and deny syntax */ + dashPos = strchr(curElement.dataStart, '-'); + } + else + dashPos = NULL; + + /* Split out each field of a dash delimited value */ + if (dashPos != NULL) + { + *dashPos = 0; + startTime = atoi(curElement.dataStart); + endTime = atoi(dashPos + 1); + if ((endTime < startTime) + || (startTime > 335) + || (endTime > 335) + || (startTime < 0) + || (endTime < 0)) + { + status = zERR_BAD_PARAMETER_VALUE; + MNSS_BuildResult(virtInfo, status, + MSGNot("Invalid time range")); + goto disconnectExit; + } + } + + if ((tagLen == 10) && (memcmp(tag, TAG_NUMTHREADS, 10) == 0) && (curElement.dataLen > 0)) + { + volManCfg.num_threads = atoi(curElement.dataStart); + didSomething = TRUE; + } + else if ((tagLen == 8) && (memcmp(tag, TAG_BITARRAY, 8) == 0) && (curElement.dataLen > 0)) + { + doTimes = TRUE; + for(workPos = curElement.dataStart, startTime = 0; (*workPos != 0) && (startTime < 336); workPos++, startTime++) + { + allow = (*workPos == '0') ? 1 : (*workPos == '1') ? 0 : 2; + if (allow == 2) + { + status = zERR_BAD_PARAMETER_VALUE; + MNSS_BuildResult(virtInfo, status, + MSGNot("Invalid time array value")); + goto disconnectExit; + } + populateTimeRestrictions(volManCfg.time_restrictions, startTime, startTime, allow); + didSomething = TRUE; + } + } + else if ((tagLen == 5) && (memcmp(tag, TAG_ALLOW, 5) == 0) && (dashPos != NULL)) + { + doTimes = TRUE; + allow = 1; + populateTimeRestrictions(volManCfg.time_restrictions, startTime, endTime, TRUE); + didSomething = TRUE; + } + else if ((tagLen == 4) && (memcmp(tag, TAG_DENY, 4) == 0) && (dashPos != NULL)) + { + doTimes = TRUE; + allow = 0; + populateTimeRestrictions(volManCfg.time_restrictions, startTime, endTime, FALSE); + didSomething = TRUE; + } + else if ((tagLen == 8) && (memcmp(tag, TAG_ALLOWALL, 8) == 0)) + { + doTimes = TRUE; + memset(volManCfg.time_restrictions, 0, sizeof(volManCfg.time_restrictions)); + didSomething = TRUE; + } + else if ((tagLen == 7) && (memcmp(tag, TAG_DENYALL, 7) == 0)) + { + doTimes = TRUE; + memset(volManCfg.time_restrictions, 0xFF, sizeof(volManCfg.time_restrictions)); + didSomething = TRUE; + } + + /* Restore any dash we removed */ + if (dashPos != NULL) + *dashPos = '-'; + + /* Restore the tag data from a C string to its original form */ + if (curElement.dataLen > 0) + curElement.dataStart[curElement.dataLen] = savedChar; + + /* Move on to the next tag */ + start = curElement.elementEnd + 1; + } + + /* Already connected to Volume Manager, set the config if we changed it */ + if (didSomething) + { + MPKNSS_UNLOCK(); + status = volManSetConfig(session, &volManCfg); + MPKNSS_LOCK(); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to set Volume Manager configuration")); + goto disconnectExit; + } + } + + /* Return the configuration we currently have (modified or not) */ + sprintf(wspace, "%d", volManCfg.num_threads); + status = VIRT_AddResultElement(virtInfo, TAG_NUMTHREADS, wspace, TRUE); + if (status != zOK) + goto responseFailExit; + status = VIRT_AddResultTag(virtInfo, TAG_TIMERESTRICTIONS, FALSE, FALSE); + if (status != zOK) + goto responseFailExit; + for (allow = 0; allow < 42; allow++) + { + wspace[0] = 0; + startTime = volManCfg.time_restrictions[allow]; + endTime = 0; + do + { + strcat(wspace, (startTime & 1) ? "1" : "0"); + startTime >>= 1; + endTime++; + } while (endTime < 8); + status = VIRT_AddResultData(virtInfo, wspace); + if (status != zOK) + goto responseFailExit; + } + status = VIRT_AddResultTag(virtInfo, TAG_TIMERESTRICTIONS, TRUE, TRUE); + if (status != zOK) + goto responseFailExit; + + /* Add the result tag - already done if we failed */ + if (status == zOK) + { + MNSS_BuildResult(virtInfo, status, "zOK"); + } + +responseFailExit: + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to create response message")); + goto disconnectExit; + } + +disconnectExit: + /* Disconnect from the Volume Manager + * Need to use this even if connect failed + * so that the symbols get unimported */ + (void)disconnectFromVolMan(session); + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} + + +STATUS MNSS_VolMNStats(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element) +{ + STATUS status = zOK; + void *session = NULL; + struct VOLMANStatistics stats; + utf8_t statTxt[24]; + + ASSERT_MPKNSS_LOCK(); + + /* Don't validate the paramter data, if any, since we don't need it + * and this lets us be forward compatible with later versions that + * might have some parameter data */ + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* Connect to volume manager */ + status = connectToVolMan(&session); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to connect to Host Volume Manager")); + goto Exit; + } + + MPKNSS_UNLOCK(); + status = volManGetStatistics(session, sizeof(stats), &stats); + MPKNSS_LOCK(); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to get statistics from Volume Manager")); + goto Exit; + } + + /* Populate the response */ + sprintf(statTxt, "%d", stats.current_state); + status = VIRT_AddResultElement(virtInfo, TAG_CURRENTSTATE, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.release_level); + status = VIRT_AddResultElement(virtInfo, TAG_RELEASELEVEL, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.build_date); + status = VIRT_AddResultElement(virtInfo, TAG_BUILDDATE, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.load_time); + status = VIRT_AddResultElement(virtInfo, TAG_LOADTIME, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.num_threads); + status = VIRT_AddResultElement(virtInfo, TAG_NUMTHREADS, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.copy_count); + status = VIRT_AddResultElement(virtInfo, TAG_COPYCOUNT, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.move_count); + status = VIRT_AddResultElement(virtInfo, TAG_MOVECOUNT, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.split_count); + status = VIRT_AddResultElement(virtInfo, TAG_SPLITCOUNT, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.total_requests); + status = VIRT_AddResultElement(virtInfo, TAG_TOTALREQUESTS, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.error_count); + status = VIRT_AddResultElement(virtInfo, TAG_ERRORCOUNT, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.auth_errors); + status = VIRT_AddResultElement(virtInfo, TAG_AUTHERRORS, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.queue_length); + status = VIRT_AddResultElement(virtInfo, TAG_QUEUELENGTH, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.average_copy_time); + status = VIRT_AddResultElement(virtInfo, TAG_AVECOPYTIME, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.average_move_time); + status = VIRT_AddResultElement(virtInfo, TAG_AVEMOVETIME, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.average_split_time); + status = VIRT_AddResultElement(virtInfo, TAG_AVESPLITTIME, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.average_queued_time); + status = VIRT_AddResultElement(virtInfo, TAG_AVEQUEUEDTIME, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.flush_count); + status = VIRT_AddResultElement(virtInfo, TAG_FLUSHCOUNT, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.average_flush_time); + status = VIRT_AddResultElement(virtInfo, TAG_AVEFLUSHTIME, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.getmc_count); + status = VIRT_AddResultElement(virtInfo, TAG_GETMCCOUNT, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.average_getmc_time); + status = VIRT_AddResultElement(virtInfo, TAG_AVEGETMCTIME, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.delete_count); + status = VIRT_AddResultElement(virtInfo, TAG_DELETECOUNT, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.average_delete_time); + status = VIRT_AddResultElement(virtInfo, TAG_AVEDELETETIME, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.rename_count); + status = VIRT_AddResultElement(virtInfo, TAG_RENAMECOUNT, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + sprintf(statTxt, "%d", stats.average_rename_time); + status = VIRT_AddResultElement(virtInfo, TAG_AVERENAMETIME, statTxt, TRUE); + if (status != zOK) + goto badStatExit; + +badStatExit: + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to store Volume Manager statistic")); + } + +Exit: + /* Disconnect from the Volume Manager + * Need to use this even if connect failed + * so that the symbols get unimported */ + (void)disconnectFromVolMan(session); + + /* Add the result tag - already done if we failed */ + if (status == zOK) + { + MNSS_BuildResult(virtInfo, status, "zOK"); + } + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} + + +STATUS MNSS_VolMNListFiles(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element) +{ + STATUS status = zOK; + LONG operationID; + LONG cookie; + void *session = NULL; + unicode_t *up; + unicode_t *buffer = NULL; + utf8_t *tmpBuf = NULL; + + const TagRequest_s tags[] = + { + {TAG_ID, TR_CONTENT_REQUIRED}, + {TAG_COOKIE, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + ID = 0, + COOKIE = 1, + }; + + ASSERT_MPKNSS_LOCK(); + + /* Read out the tags */ + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto freeExit; + } + return status; + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* Allocate a buffer to hold response */ + buffer = malloc(FILE_LIST_BUFFER_SIZE + sizeof(unicode_t)); + tmpBuf = malloc(FILE_LIST_BUFFER_SIZE * 3 + 1); + if ((buffer == NULL) || (tmpBuf == NULL)) + { + MNSS_BuildResult(virtInfo, zERR_NO_MEMORY, MSGNot("Out of memory")); + goto Exit; + } + memset(buffer, 0, FILE_LIST_BUFFER_SIZE + sizeof(unicode_t)); + + operationID = atoi(tagContent[ID].content); + cookie = atoi(tagContent[COOKIE].content); + + /* Connect to volume manager */ + status = connectToVolMan(&session); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to connect to Host Volume Manager")); + goto Exit; + } + + MPKNSS_UNLOCK(); + status = volManGetFileNameList(session, operationID, &cookie, FILE_LIST_BUFFER_SIZE, buffer); + MPKNSS_LOCK(); + if (status != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to get statistics from Volume Manager")); + goto Exit; + } + + /* Populate the response */ + /* Operation ID & new cookie value */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_ID, tagContent[ID].content, TRUE)) != zOK) + { + goto Exit; + } + if (cookie != 0xFFFFFFFF) + { + sprintf(tmpBuf, "%d", cookie); + } + else + { + sprintf(tmpBuf, "%s", MSGNot("DONE")); + } + if ((status = VIRT_AddResultElement(virtInfo, TAG_COOKIE, tmpBuf, TRUE)) != zOK) + { + goto Exit; + } + + /* File name list */ + for (up = buffer; *up != '\0'; up += unilen(up) + 1) + { + /* Convert unicode names to utf-8 */ + if (uni2utf(up, tmpBuf, FILE_LIST_BUFFER_SIZE * 3 + 1) == -1) + { + status = zFAILURE; + goto Exit; + } + if ((status = VIRT_AddResultElement(virtInfo, TAG_FILENAME, tmpBuf, TRUE)) != zOK) + { + goto Exit; + } + } + +Exit: + /* Disconnect from the Volume Manager + * Need to use this even if connect failed + * so that the symbols get unimported */ + (void)disconnectFromVolMan(session); + + /* Add the result tag - already done if we failed */ + if (status == zOK) + { + MNSS_BuildResult(virtInfo, status, "zOK"); + } + +freeExit: + if (tmpBuf != NULL) + { + free(tmpBuf); + } + if (buffer != NULL) + { + free(buffer); + } + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} + +/* Get a decimal number. The number is pointed to by the num argument, */ +/* and the length is specified by numDigits. */ +/* Returns: pointer to nexxt character following the number on success, */ +/* NULL on failure (invalid arguments or non-numeric string) */ +utf8_t *GetDecimal(utf8_t *num, NINT numDigits, NINT *value) +{ + NINT i; + NINT result; + + if ((num == NULL) || (numDigits <= 0)) + { + return(NULL); + } + result = 0; + for (i = 0; i < numDigits; i++) + { + if ((*num < '0') || (*num > '9')) + { + /* Invalid decimal string */ + return(NULL); + } + result = result * 10 + (*num++ - '0'); + } + *value = result; + return(num); +} + +/* Convert a GeneralizedTime string to the form needed by the Volume Manager */ +/* (UTC time value). The following formats are supported for the */ +/* GeneralizedTime string: */ +/* 1. Local time "YYYYMMDDHHMMSS" */ +/* 2. UTC time "YYYYMMDDHHMMSSZ" */ +/* Fractional seconds are not supported, nor are time offsets (+/-HHMM) */ +STATUS ConvertGeneralizedTimeToUTC(QUAD *result, utf8_t *tagData, NINT dataLen) +{ + NINT year, month, day, hour, minute, second, leaps; + BOOL zulu, isLeap; + QUAD startTime; + utf8_t *p; + + startTime = (QUAD) 0; + if (stricmp(tagData, START_NOW) == 0) + { + *result = startTime; + return(zOK); + } + + /* GeneralizedTime format supported is YYYYMMDDHHMMSS[Z] where the */ + /* optional Z indicates Zulu time (GMT) and lack of Z indicates */ + /* server "wall clock time" */ + zulu = FALSE; + p = GetDecimal(tagData, 4, &year); + if (p == NULL) + { + return(zFAILURE); + } + p = GetDecimal(p, 2, &month); + if (p == NULL) + { + return(zFAILURE); + } + p = GetDecimal(p, 2, &day); + if (p == NULL) + { + return(zFAILURE); + } + p = GetDecimal(p, 2, &hour); + if (p == NULL) + { + return(zFAILURE); + } + p = GetDecimal(p, 2, &minute); + if (p == NULL) + { + return(zFAILURE); + } + p = GetDecimal(p, 2, &second); + if (p == NULL) + { + return(zFAILURE); + } + if ((*p == 'z') || (*p == 'Z')) + { + zulu = TRUE; + } + + /* Basic sanity checking */ + if ((month < 1) || (month > 12) || + (day < 1) || (day > 31) || + (hour < 0) || (hour > 24) || + (minute < 0) || (minute > 59) || + (second < 0) || (second > 59)) + { + return(zFAILURE); + } + year -= 2000; + /* +1 here because Y2K was a leap year & we have to count it */ + leaps = year / 4 - year / 100 + year / 400 + 1; + isLeap = (((year % 4) == 0) && ((year % 100) != 0)) || ((year % 400) == 0); + if (isLeap) + { + /* Use alternate table for leap years */ + month += 12; + } + startTime = (year * 365 + leaps + StartDay[month - 1] + (day - 1)) * (QUAD) SECS_IN_A_DAY; + startTime += hour * 3600 + minute * 60 + second; + + if (zulu) + { + /* Adjust to seconds since 1970 instead of since 2000 */ + startTime += YEAR_2000_IN_UTC; + /* Now we have UTC time format */ + *result = startTime; + } + else + { + /* Convert server local time to UTC */ + *result = (QUAD) Sec20002utcTime((Time_t) startTime); + } + return(zOK); +} diff --git a/src/nwnss/manage/manageVolume.c b/src/nwnss/manage/manageVolume.c new file mode 100644 index 0000000..7a91249 --- /dev/null +++ b/src/nwnss/manage/manageVolume.c @@ -0,0 +1 @@ +#include diff --git a/src/nwnss/manage/nssMANAGESym.c b/src/nwnss/manage/nssMANAGESym.c new file mode 100644 index 0000000..ee2e945 --- /dev/null +++ b/src/nwnss/manage/nssMANAGESym.c @@ -0,0 +1,94 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export manage symbles to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include + + +//WRONG PLACE//EXPORT_SYMBOL(MANAGE_fileCommand); +//WRONG PLACE//EXPORT_SYMBOL(MANAGE_nssCommand); +EXPORT_SYMBOL(MANAGE_linuxCommand); +//WRONG PLACE//EXPORT_SYMBOL(MANAGE_ndsCommand); +EXPORT_SYMBOL(MANAGE_ReadDataStream); +EXPORT_SYMBOL(MANAGE_WriteDataStream); +//WRONG PLACE//EXPORT_SYMBOL(MNDS_ResolveName); +//WRONG PLACE//EXPORT_SYMBOL(MNSS_GetTagContents); +//WRONG PLACE//EXPORT_SYMBOL(getManageVCUAbort); +//WRONG PLACE//EXPORT_SYMBOL(getManageVCUAnswer); +//WRONG PLACE//EXPORT_SYMBOL(setManageVCUCopyStatus); +//WRONG PLACE//EXPORT_SYMBOL(setManageVCUProcessMsg); +EXPORT_SYMBOL(CreateVolumeInPool); +EXPORT_SYMBOL(RemoveUserFromIDStore); +EXPORT_SYMBOL(ModifyVolumeAttributes); +EXPORT_SYMBOL(DoesVolumeExist); +EXPORT_SYMBOL(GetPoolState); +EXPORT_SYMBOL(GetNextVolumeName); +EXPORT_SYMBOL(GetZInfo); +EXPORT_SYMBOL(DoesPoolExist); +EXPORT_SYMBOL(GetAuthModelID); +EXPORT_SYMBOL(GetNSSVolumeHostPool); +EXPORT_SYMBOL(PerformDeletedVolumeAction); +EXPORT_SYMBOL(RenameSalvagedVolume); +EXPORT_SYMBOL(SetNDSInfoOnVolume); +EXPORT_SYMBOL(GetDeletedVolumeLSSInfo); +EXPORT_SYMBOL(RenameNSSVolume); +EXPORT_SYMBOL(SetNDSInfoOnPool); +EXPORT_SYMBOL(ChangeVolumeState); +EXPORT_SYMBOL(ChangePoolState); +EXPORT_SYMBOL(MNDS_CheckVolumesPool); +EXPORT_SYMBOL(GetPoolLSSType); +EXPORT_SYMBOL(RemoveNSSVolume); +EXPORT_SYMBOL(NSSVolumeFound); +EXPORT_SYMBOL(GetNextPoolName); +EXPORT_SYMBOL(GetNextVolumeInfo); +EXPORT_SYMBOL(GetLSSFeatures); +EXPORT_SYMBOL(GetPoolID); +EXPORT_SYMBOL(GetNextUserInVolume); +EXPORT_SYMBOL(GetUserSpaceRestriction); +EXPORT_SYMBOL(SetUserSpaceRestriction); diff --git a/src/nwnss/ndpmod/Makefile b/src/nwnss/ndpmod/Makefile new file mode 100644 index 0000000..6556778 --- /dev/null +++ b/src/nwnss/ndpmod/Makefile @@ -0,0 +1,32 @@ +### +### ../nss/public_core/ndpmod Makefile +### + +############################################################################## +# +# (C) Copyright 2004 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +BASEDIR=../.. + +SUBDIRS= \ + +include ${BASEDIR}/buildtools/Makefile.default + diff --git a/src/nwnss/ndpmod/Module.supported b/src/nwnss/ndpmod/Module.supported new file mode 100644 index 0000000..7102ff7 --- /dev/null +++ b/src/nwnss/ndpmod/Module.supported @@ -0,0 +1 @@ +ndpmod.ko diff --git a/src/nwnss/ndpmod/NDPDEBUG.NOTES b/src/nwnss/ndpmod/NDPDEBUG.NOTES new file mode 100644 index 0000000..c51d996 --- /dev/null +++ b/src/nwnss/ndpmod/NDPDEBUG.NOTES @@ -0,0 +1,21 @@ +Debug Levels of NDP routines/data + +1 = options +1 = init/cleanup +1 = open/close /dev/ndp +1 = echo +1 = bind/unbind ID Broker Functions +1 = init/cleanup ID Broker Functions +2 = ID Broker Message Handler +2 = ID Broker Functions +3 = getXmlTagValue... +3 = NDP Message Handler +4&5 = register/deregister +5 = read/write/print from/to GUID +6 = exchange +7 = extract/insert +8&9 = find +10 = new/free + = read/write /dev/ndp + = ndp_msgrcv + diff --git a/src/nwnss/ndpmod/ndp_comn.c b/src/nwnss/ndpmod/ndp_comn.c new file mode 100644 index 0000000..87113ce --- /dev/null +++ b/src/nwnss/ndpmod/ndp_comn.c @@ -0,0 +1,2 @@ +#include + diff --git a/src/nwnss/ndpmod/ndp_guids.c b/src/nwnss/ndpmod/ndp_guids.c new file mode 100644 index 0000000..7888a6e --- /dev/null +++ b/src/nwnss/ndpmod/ndp_guids.c @@ -0,0 +1,2 @@ +#include + diff --git a/src/nwnss/ndpmod/ndp_idbroker.c b/src/nwnss/ndpmod/ndp_idbroker.c new file mode 100644 index 0000000..1c2e61d --- /dev/null +++ b/src/nwnss/ndpmod/ndp_idbroker.c @@ -0,0 +1,2 @@ +#include + diff --git a/src/nwnss/ndpmod/ndp_messagehandler.c b/src/nwnss/ndpmod/ndp_messagehandler.c new file mode 100644 index 0000000..588c4e5 --- /dev/null +++ b/src/nwnss/ndpmod/ndp_messagehandler.c @@ -0,0 +1,2 @@ +#include + diff --git a/src/nwnss/ndpmod/ndp_mod.c b/src/nwnss/ndpmod/ndp_mod.c new file mode 100644 index 0000000..c3293b8 --- /dev/null +++ b/src/nwnss/ndpmod/ndp_mod.c @@ -0,0 +1,695 @@ +/**************************************************************************** + | + | (C) Copyright 2004 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell's User/Kernel Data Portal (NDP) Module program file. + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This file is used to: + | ... + +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/****************************************************************************** +* Declare and initialize NDP MODULE_* information (and associated variables) +******************************************************************************/ +MODULE_AUTHOR("Novell, Inc."); +MODULE_DESCRIPTION("NDP - Novell's Data Portal"); +//MODULE_PARM_DESC(""); +MODULE_VERSION("0.0"); +MODULE_LICENSE("GPL v2"); + +/* Can be set (turned on) at startup or any time thereafter */ +int ndp_debug = 0; +module_param(ndp_debug, int, 0); +MODULE_PARM_DESC(ndp_debug, "Debug level (0-n): 0=off (default), 1=minimal"); + +/* Can be set only after setup via the /proc/drivers/ndp/test entry */ +int ndp_test = 0; + +/****************************************************************************** +* Declare and initialize NDP Module "Globals" +******************************************************************************/ +ndpContext_t *ndpContext = NULL; + +/****************************************************************************** +* Declare and initialize the NDP wait queue +******************************************************************************/ + +/****************************************************************************** +* Define some NDP Module specific data values +******************************************************************************/ +static unsigned char ndpModShortName[] = "ndp"; +static unsigned char ndpModLongName[] = "ndpmod"; +static unsigned char ndpProcDir[] = "driver/ndp"; + +/****************************************************************************** +* Pre-Declare the functions in this file +******************************************************************************/ +static int ndp_open( + struct inode *inodep, + struct file *filep); + +static int ndp_release( + struct inode *inodep, + struct file *filep); + +static ssize_t ndp_read( + struct file *filep, + char __user *ubuf, + size_t count, + loff_t *offset); + +static ssize_t ndp_write( + struct file *filep, + const char __user *ubuf, + size_t count, + loff_t *offset); + +static ndpContext_t *new_ndp_context(void); + +static void free_ndp_context( + ndpContext_t *ndpContext); + +static int ndp_debug_proc_read( + char *page, + char **start, + off_t offset, + int count, + int *eof, + void *data); + +static int ndp_debug_proc_write( + struct file *fp, + const char __user *ubuf, + unsigned long count, + void *data); + +static int ndp_test_proc_read( + char *page, + char **start, + off_t offset, + int count, + int *eof, + void *data); + +static int ndp_test_proc_write( + struct file *fp, + const char __user *ubuf, + unsigned long count, + void *data); + +static void ndp_create_proc_entries( + ndpContext_t *ndpContext); + +static void ndp_remove_proc_entries( + ndpContext_t *ndpContext); + +static int __init ndp_init_module(void); + +static void __exit ndp_cleanup_module(void); + +/****************************************************************************** +* The "open" routine associated with ndpDevice (default: /dev/ndp) +******************************************************************************/ +static int ndp_open( + struct inode *inodep, + struct file *filep) +{ + int retval = 0; + + ndpDbgPrintf(11, "ndp_open(Enter)\n"); + ndpDbgPrintf(11, "ndp_open(Leave:%d)\n", retval); + return(retval); +} /* ndp_open() */ + +/****************************************************************************** +* The "release" (close) routine associated with ndpDevice (default: /dev/ndp) +******************************************************************************/ +static int ndp_release( + struct inode *inodep, + struct file *filep) +{ + int retval = 0; + + ndpDbgPrintf(11, "ndp_release(Enter)\n"); + ndpDbgPrintf(11, "ndp_release(Leave:%d)\n", retval); + return(retval); +} /* ndp_release() */ + +/****************************************************************************** +* The "read" routine associated with ndpDevice (default: /dev/ndp) +******************************************************************************/ +static ssize_t ndp_read( + struct file *filep, + char __user *ubuf, + size_t count, + loff_t *offset) +{ + static ndp_msgqueue_t *msgqueueentry = NULL; + static LONG msglengthremaining = 0L; + ssize_t retval = -EFAULT; + int sts; + + ndpDbgPrintf(11, "ndp_read(Enter)\n"); + + if (msgqueueentry == NULL) { + /* Loop until we have something to be read (unless non-blocking I/O) */ + msgqueueentry = extract_ndp_msgqueue_entry( + ndpContext->ndpMsgQueueContext); + if (filep->f_flags & O_NONBLOCK) { + if (msgqueueentry == NULL) { + retval = -EAGAIN; + } + } else { + while (msgqueueentry == NULL) { + /* Go to sleep and wake and try again later */ + //ndpDbgPrintf(11, "ndp_read(PRE:wait_event_interruptible)\n"); + sts = wait_event_interruptible( + *(ndpContext->ndpMsgQueueContext->msgwaitqueue), + (ndpContext->ndpMsgQueueContext->msgCount > 0)); + //ndpDbgPrintf(11, "ndp_read(PST:wait_event_interruptible:%d:%d)\n", sts, ndpContext->ndpMsgQueueContext->msgCount); + /* + * Call schedule() to give the system time to look at things + * just in case we are in a very tight read loop. + * This will give the user some response to kill the app. + */ + //FixFixFix - 385538 - research needs to be done as to whether + //or not this schedule is necessary + schedule(); + if (sts) { + /* We were interrupted (i.e. ^C), let the OS handle it */ + retval = -ERESTARTSYS; + break; + } else { + msgqueueentry = extract_ndp_msgqueue_entry( + ndpContext->ndpMsgQueueContext); + } + } + } + } + /* + * Call schedule() to give the system time to look at things + * just in case we are in a very tight read loop. + * This will give the user some response to kill the app. + */ + //FixFixFix - 385538 - research needs to be done as to whether + //or not this schedule is necessary + schedule(); + /* If we have some data to be read */ + if (msgqueueentry) { + if (retval == -ERESTARTSYS) { + /* Throw away any remaining message */ + free_ndp_msgqueue_entry(msgqueueentry); + msgqueueentry = NULL; + msglengthremaining = 0; + } else { + LONG msglength; + LONG msgremainingoffset; + unsigned char *data; + msglength = ((MIN_MSG_SIZE) + (msgqueueentry->msg->length)); + if (msglengthremaining <= 0) { + msglengthremaining = msglength; + msgremainingoffset = 0; + } else { + msgremainingoffset = msglength - msglengthremaining; + } + data = &((unsigned char *)msgqueueentry->msg)[msgremainingoffset]; + if (count > msglengthremaining) { + count = msglengthremaining; + } + /* It is possible that not all data will be sent at this time */ + msglengthremaining -= count; + ndpDbgDumpDataInHex(20, "ndp_read(MOD)", count, data); + sts = copy_to_user(ubuf, data, count); + if (sts) { + retval = -EFAULT; + } else { + retval = count; + } + if (msglengthremaining <= 0) { + free_ndp_msgqueue_entry(msgqueueentry); + msgqueueentry = NULL; + msglengthremaining = 0; + } + } + } + ndpDbgPrintf(11, "ndp_read(Leave:%d)\n", retval); + return(retval); +} /* ndp_read() */ + +/****************************************************************************** +* The "write" routine associated with ndpDevice (default: /dev/ndp) +******************************************************************************/ +static ssize_t ndp_write( + struct file *filep, + const char __user *ubuf, + size_t count, + loff_t *offset) +{ + ssize_t retval = 0; + char *kbuf; + int sts; + + ndpDbgPrintf(11, "ndp_write(Enter)\n"); + if (count < (MIN_MSG_SIZE)) { + retval = -EINVAL; /* Invalid argument */ + } else { + kbuf = (char *)ndpMalloc(count+1, GFP_KERNEL); + if (kbuf == NULL) { + /* Malloc failure */ + retval = -ENOMEM; + } else { + sts = copy_from_user(kbuf, ubuf, count); + if (sts) { + retval = -EFAULT; + } else { + ndp_msg_t *msg; + msg = (ndp_msg_t *)kbuf; + ndpDbgDumpDataInHex(20, "ndp_write(MOD)", count, kbuf); + if (count != (MIN_MSG_SIZE + msg->length)) { + retval = -EINVAL; /* Invalid argument */ + } else { + ndp_guidmsgcontext_t *guidmsgcontext; + guidmsgcontext = find_ndp_guidmsgcontext( + ndpContext->guidListContext, + &msg->dstGuid); + if (guidmsgcontext == NULL) { + retval = -EFAULT; + } else { + ndp_msgqueue_t *msgqueueentry; + msgqueueentry = new_ndp_msgqueue_entry( + &msg->srcGuid, + &msg->dstGuid, + msg->length, + &msg->data[0]); + if (msgqueueentry == NULL) { + retval = -ENOMEM; + } else { + sts = insert_ndp_msgqueue_entry(guidmsgcontext, + msgqueueentry); + if (memcmp(&msg->dstGuid, &ndpModGuid, sizeof(GUID_t)) == 0) { + ndp_messagehandler(ndpContext, + NULL, NULL, 0L, NULL); + } + if (sts) { + retval = -EBUSY; + } else { + retval = count; + } + } + } + } + } + ndpFree(kbuf); + } + } + ndpDbgPrintf(11, "ndp_write(Leave:%d)\n", retval); + return(retval); +} /* ndp_read() */ + +/****************************************************************************** +* The file operations associated with ndpDevice (default: /dev/ndp) +******************************************************************************/ +static struct file_operations ndp_fops = +{ + owner: THIS_MODULE, + open: ndp_open, + release: ndp_release, + read: ndp_read, + write: ndp_write, +}; + +static struct miscdevice ndp_miscdev = +{ + minor: ndpMINOR, + name: ndpModShortName, + fops: &ndp_fops, +}; + +/****************************************************************************** +* Allocate and fill in a new NDP Module Context +******************************************************************************/ +static ndpContext_t *new_ndp_context(void) +{ + ndpContext_t *ndpContext; + + ndpDbgPrintf(20, "new_ndp_context(Enter)\n"); + ndpContext = (ndpContext_t *) + ndpMalloc(sizeof(ndpContext_t), GFP_KERNEL); + if (ndpContext) { + memset((void *)ndpContext, 0, sizeof(ndpContext_t)); + ndpContext->modName = ndpModLongName; + memcpy(&ndpContext->modGuid, &ndpModGuid, sizeof(GUID_t)); + ndpContext->ndpMsgQueueContext = new_ndp_guidmsgcontext(); + ndpContext->guidListContext = new_ndp_guidlistcontext(); + if ((ndpContext->ndpMsgQueueContext == NULL) + || (ndpContext->guidListContext == NULL)) { + free_ndp_context(ndpContext); + ndpContext = NULL; + } + } + ndpDbgPrintf(20, "new_ndp_context(Leave:%08X)\n", ndpContext); + return(ndpContext); +} /* new_ndp_context() */ + +/****************************************************************************** +* Free a previously allocated NDP Module Context +******************************************************************************/ +static void free_ndp_context( + ndpContext_t *ndpContext) +{ + ndpDbgPrintf(20, "free_ndp_context(Enter:%08X)\n", ndpContext); + if (ndpContext) { + free_ndp_guidmsgcontext(ndpContext->ndpMsgQueueContext); + free_ndp_guidlistcontext(ndpContext->guidListContext); + ndpFree((char *)ndpContext); + } + ndpDbgPrintf(20, "free_ndp_context(Leave)\n"); + return; +} /* free_ndp_context() */ + +/****************************************************************************** +* The "read" routine associated with ndp_debug (/proc/drivers/ndp/debug) +******************************************************************************/ +static int ndp_debug_proc_read( + char *page, + char **start, + off_t offset, + int count, + int *eof, + void *data) +{ + int length = 0; + + ndpDbgPrintf(11, "ndp_debug_proc_read(Enter)\n"); + length += sprintf(page + length, "ndp_debug: %d\n", ndp_debug); +#if (1) + /* Dump the registered guid list */ + if (ndp_debug) { + ndp_guidlistcontext_t *guidlistcontext; + ndp_guidlist_t *entry = NULL; + guidlistcontext = ndpContext->guidListContext; + length += sprintf(page + length, "guidCount: %d\n", guidlistcontext->guidCount); + RDLOCK_GUIDLIST(guidlistcontext); + DQ_FOREACH(&guidlistcontext->dqHead, entry, ndp_guidlist_t, dqLink) { + length += sprintf(page + length, "name=%s\n", entry->name); + //length += sprintf(page + length, "guid=%s\n", entry->guid); + //length += sprintf(page + length, "guid=%s\n", entry->guidPrime); + } + RDUNLOCK_GUIDLIST(guidlistcontext); + } +#endif + //if (length <= (offset + count)) { + *eof = 1; + //} + length -= offset; + if (length > count) length = count; + if (length < 0) length = 0; + ndpDbgPrintf(11, "ndp_debug_proc_read(Leave:%d)\n", length); + return(length); +} /* ndp_debug_proc_read() */ + +/****************************************************************************** +* The "write" routine associated with ndp_debug (/proc/drivers/ndp/debug) +******************************************************************************/ +static int ndp_debug_proc_write( + struct file *fp, + const char __user *ubuf, + unsigned long count, + void *data) +{ + int length; + char *kbuf; + int sts; + + ndpDbgPrintf(11, "ndp_debug_proc_write(Enter)\n"); + kbuf = (char *)ndpMalloc(count+1, GFP_KERNEL); + if (kbuf == NULL) { + /* Malloc failure */ + length = -ENOMEM; + } else { + sts = copy_from_user(kbuf, ubuf, count); + if (sts) { + length = -EFAULT; + } else { + kbuf[count] = '\0'; + ndp_debug = ndp_atoi(kbuf); /* Determine new debug value */ + length = count; + ndpDbgPrintf(11, "ndp_debug_proc_write: %d\n", ndp_debug); + } + } + ndpDbgPrintf(11, "ndp_debug_proc_write(Leave:%d)\n", length); + return(length); +} /* ndp_debug_proc_write() */ + +/****************************************************************************** +* The "read" routine associated with ndp_test (/proc/drivers/ndp/test) +******************************************************************************/ +static int ndp_test_proc_read( + char *page, + char **start, + off_t offset, + int count, + int *eof, + void *data) +{ + int length = 0; + + ndpDbgPrintf(11, "ndp_test_proc_read(Enter)\n"); + length += sprintf(page + length, "%d\n", ndp_test); +#if (1) + /* Dump the registered guid list */ + switch (ndp_test) { +#ifdef BUILD_NDP_IDBROKER + case 1: /* ndp_namGetUserFDNfromUID() */ + { + /* ndp_namGetUserFDNfromUID() */ + int sts; + int uid = 102; + unicode_t *uniFdn = NULL; + utf8_t *utf8Fdn = NULL; + sts = ndp_namGetUserFDNfromUID(uid, &uniFdn); + if ((sts > 0) && (uniFdn)) { + utf8Fdn = ndpMalloc( ((unilen(uniFdn) + 1) * 3), GFP_KERNEL); + if (utf8Fdn) + { + uni2utf(uniFdn, utf8Fdn, ((unilen(uniFdn) + 1) * 3) ); + } + } + length += sprintf(page + length, + "ndp_namGetUserFDNfromUID(%d): sts=%d: fdn=%s\n", uid, sts, + utf8Fdn?(unsigned char *)utf8Fdn:(unsigned char *)"NULL"); + if (uniFdn) + { + ndpFree(uniFdn); + } + if (utf8Fdn) + { + ndpFree(utf8Fdn); + } + break; + } +#endif /* BUILD_NDP_IDBROKER */ + default: + break; + } +#endif + //if (length <= (offset + count)) { + *eof = 1; + //} + length -= offset; + if (length > count) length = count; + if (length < 0) length = 0; + ndpDbgPrintf(11, "ndp_test_proc_read(Leave:%d)\n", length); + return(length); +} /* ndp_test_proc_read() */ + +/****************************************************************************** +* The "write" routine associated with ndp_test (/proc/drivers/ndp/test) +******************************************************************************/ +static int ndp_test_proc_write( + struct file *fp, + const char __user *ubuf, + unsigned long count, + void *data) +{ + int length; + char *kbuf; + int sts; + + ndpDbgPrintf(11, "ndp_test_proc_write(Enter)\n"); + kbuf = (char *)ndpMalloc(count+1, GFP_KERNEL); + if (kbuf == NULL) { + /* Malloc failure */ + length = -ENOMEM; + } else { + sts = copy_from_user(kbuf, ubuf, count); + if (sts) { + length = -EFAULT; + } else { + kbuf[count] = '\0'; + ndp_test = ndp_atoi(kbuf); /* Determine new test value */ + length = count; + ndpDbgPrintf(11, "ndp_test_proc_write: %d\n", ndp_test); + } + } + ndpDbgPrintf(11, "ndp_test_proc_write(Leave:%d)\n", length); + return(length); +} /* ndp_test_proc_write() */ + +/****************************************************************************** +* Create /proc/drivers/ndp/* entries and associate routines with each entry +* ndp_debug (/proc/drivers/ndp/debug) +* ndp_test (/proc/drivers/ndp/test) +******************************************************************************/ +static void ndp_create_proc_entries( + ndpContext_t *ndpContext) +{ + ndpDbgPrintf(11, "ndp_create_proc_entries(Enter)\n"); + ndpContext->proc.dir = create_proc_entry(ndpProcDir, S_IFDIR, NULL); + if ((ndpContext) && (ndpContext->proc.dir)) { + ndpContext->proc.debug = + create_proc_entry("debug", 0644, ndpContext->proc.dir); + if (ndpContext->proc.debug) { + ndpContext->proc.debug->read_proc = ndp_debug_proc_read; + ndpContext->proc.debug->write_proc = ndp_debug_proc_write; + } + ndpContext->proc.test = + create_proc_entry("test", 0644, ndpContext->proc.dir); + if (ndpContext->proc.test) { + ndpContext->proc.test->read_proc = ndp_test_proc_read; + ndpContext->proc.test->write_proc = ndp_test_proc_write; + } + } + ndpDbgPrintf(11, "ndp_create_proc_entries(Leave)\n"); + return; +} /* ndp_create_proc_entries() */ + +/****************************************************************************** +* Remove /proc/drivers/ndp/* entries and their associate routines +******************************************************************************/ +static void ndp_remove_proc_entries( + ndpContext_t *ndpContext) +{ + ndpDbgPrintf(11, "ndp_remove_proc_entries(Enter)\n"); + if ((ndpContext) && (ndpContext->proc.dir)) { + if (ndpContext->proc.test) { + ndpContext->proc.test->read_proc = NULL; + ndpContext->proc.test->write_proc = NULL; + remove_proc_entry("test", ndpContext->proc.dir); + ndpContext->proc.test = NULL; + } + if (ndpContext->proc.debug) { + ndpContext->proc.debug->read_proc = NULL; + ndpContext->proc.debug->write_proc = NULL; + remove_proc_entry("debug", ndpContext->proc.dir); + ndpContext->proc.debug = NULL; + } + remove_proc_entry(ndpProcDir, NULL); + ndpContext->proc.dir = NULL; + } + ndpDbgPrintf(11, "ndp_remove_proc_entries(Leave)\n"); + return; +} /* ndp_remove_proc_entries() */ + +/****************************************************************************** +* The NDP Module initialization routine +******************************************************************************/ +static int __init ndp_init_module(void) +{ + int retval = -ENOMEM; + + ndpDbgPrintf(11, "ndp_init(Enter)\n"); + ndpDbgPrintf(11, "ndp_debug=%d\n", ndp_debug); + ndpDbgPrintf(11, "ndp_test=%d\n", ndp_test); + ndpContext = new_ndp_context(); + if (ndpContext) { + retval = 0; + if (retval == 0) { + retval = misc_register(&ndp_miscdev); + } + if (retval == 0) { + ndp_create_proc_entries(ndpContext); + } + if (retval == 0) { + retval = ndp_registerGuid(&ndpModGuid, + &ndpModGuidPrime, ndpModLongName); + } +#ifdef BUILD_NDP_IDBROKER + if (retval == 0) { + retval = ndp_init_idBroker(); + } +#endif /* BUILD_NDP_IDBROKER */ + } + if (retval == 0) { + ndpPrintf("Module %s installed\n", ndpModLongName); + } else { + ndp_cleanup_module(); + } + ndpDbgPrintf(11, "ndp_init(Leave:%d)\n", retval); + return(retval); +} /* ndp_init_module() */ +module_init(ndp_init_module); + +/****************************************************************************** +* The NDP Module cleanup & exit routine +******************************************************************************/ +static void __exit ndp_cleanup_module(void) +{ + ndpDbgPrintf(11, "ndp_cleanup_module(Enter)\n"); + if (ndpContext) { +#ifdef BUILD_NDP_IDBROKER + ndp_cleanup_idBroker(); +#endif /* BUILD_NDP_IDBROKER */ + ndp_deregisterGuid(&ndpModGuidPrime); + ndp_remove_proc_entries(ndpContext); + remove_proc_entry(ndpProcDir, NULL); + misc_deregister(&ndp_miscdev); + free_ndp_context(ndpContext); + ndpPrintf("Module %s removed\n", ndpModLongName); + } + ndpDbgPrintf(11, "ndp_cleanup_module(Leave)\n"); + return; +} /* ndp_cleanup_module() */ +module_exit(ndp_cleanup_module); + diff --git a/src/nwnss/ndpmod/ndp_mod.h b/src/nwnss/ndpmod/ndp_mod.h new file mode 100644 index 0000000..366448f --- /dev/null +++ b/src/nwnss/ndpmod/ndp_mod.h @@ -0,0 +1,85 @@ +/**************************************************************************** + | + | (C) Copyright 2004 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell's User/Kernel Data Portal (NDP) Module include file. + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This file is used to: + | ... + +-------------------------------------------------------------------------*/ + +#ifndef NDP_MOD_H +#define NDP_MOD_H + +/* NOTE: ndp_comn.h needs included before anything else in application land */ +#include + +/****************************************************************************** +* Define the context structure containing the command line options. Keep the +* options and the context structure option variables in sync. +******************************************************************************/ +typedef struct ndpModOptions_t { + // int debug; /* USE ndp_debug INSTEAD */ +} ndpModOptions_t; + +/****************************************************************************** +* Define the structure mapping the /proc/drivers/ndp/* file system entries +******************************************************************************/ +typedef struct ndpProcEntries_t { + struct proc_dir_entry *dir; + struct proc_dir_entry *debug; + struct proc_dir_entry *test; +} ndpProcEntries_t; + +/****************************************************************************** +* Define the NDP Module Context Structure +******************************************************************************/ +typedef struct ndpContext_t { + char *modName; + GUID_t modGuid; + GUID_t modGuidPrime; + ndpModOptions_t options; + ndp_guidmsgcontext_t *ndpMsgQueueContext; + ndp_guidlistcontext_t *guidListContext; + ndpProcEntries_t proc; +} ndpContext_t; + +/****************************************************************************** +* Pre-Declare NDP Module Global Variables +******************************************************************************/ +//extern int ndp_debug; +//extern int ndp_test; + +/****************************************************************************** +* Pre-Declare the NDP Module functions to be seen externally +******************************************************************************/ + +#endif /* NDP_MOD_H */ + diff --git a/src/nwnss/ndpmod/ndpmodModules.mk b/src/nwnss/ndpmod/ndpmodModules.mk new file mode 100644 index 0000000..f70c536 --- /dev/null +++ b/src/nwnss/ndpmod/ndpmodModules.mk @@ -0,0 +1,264 @@ +############################################################################## +# +# (C) Copyright 2003 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +########################################################################## +# This defines what MODULES are being built for this NLM +# +# $Author: ghorlacher $ +# $Date: 2007-09-13 03:51:53 +0530 (Thu, 13 Sep 2007) $ +# +# $RCSfile$ +# $Revision: 2206 $ +# +########################################################################## +MODULE_VERSION=15 + +#------------------------------------------------------------------------- +# If the version number is not defined here, the general product version +# number will be used (defined in bldVersion.bld) +# +# major version 1 to 99 +# minor version 1 to 99 +# sub version 1 to 26 +#------------------------------------------------------------------------- +MAJOR_VERSION=1 +MINOR_VERSION=0 +SUB_VERSION=0 + +#------------------------------------------------------------------------- +# Build OPTIONS +#------------------------------------------------------------------------- +BUILD_WITH_KERNEL_FLAGS=1 +BUILD_NO_INSTRUMENT_FUNCTIONS=1 + +#set to 0 if you are NOT using source code control +IS_USING_SOURCE_CONTROL=1 + +#Set to ONE if you want the linked files to be copied to the SDK/BIN directory. +COPY_TO_SDK_BIN=1 + + #set to ONE if you only want to copy the OPTIMIZED version to SDK/BIN. + COPY_OPTIMIZED_ONLY=0 + +#Set this to ONE if you are building a NETWARE version independent NLM +#(not NETWARE version specific) +NETWARE_VERSION_INDEPENDENT=1 + + #if ONE include the NETWARE .H files in the compiler search paths. + USE_NETWARE_INCLUDES=1 + + #if ONE include the NETWARE import file at LINK time + USE_NETWARE_IMPORTS=0 + +#If ONE IMPORT the LIBNSS APIs and include in the search path SDK/LIBRARY +#and SDK/PUBLIC +IMPORT_INDEPENDENT_LIBNSS=0 + +#If ONE include in the search path SDK/LIBRARY and SDK/PUBLIC +USE_LIBNSS_INCLUDES=1 + +#If ONE then LINK with the NSS library and include all of the NSS library +#directories in the compiler search paths. This includes the SDK/PUBLIC, +#SDK/INCLUDE, SDK/INTERNAL, LIBRARY/SRC directories. +LINK_WITH_NSSLIB=0 + +#if ONE then IMPORT the NSS library and COMN layer APIS and include the +#SDK/PUBLIC directory in the compiler search paths. +IMPORT_NSSLIB=1 + + #If ONE and (LINK_WITH_NSSLIB==1 or IMPORT_NSSLIB==1) then do the same + #operation to the NSSLIB area you are doing to the local area. + CHECK_NSSLIB=0 + + #If ONE and (CHECK_NSSLIB==1) then we will clean the NSSLIB area when we + #clean the local area. + CLEAN_NSSLIB=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INCLUDE directory in + #the compiler search paths + USE_NSS_SDK_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/COMNSA directory in + #the compiler search paths + USE_NSS_SDK_COMNSA_INCLUDES=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INTERNAL directory in + #the compiler search paths + USE_NSS_SDK_INTERNAL_INCLUDES=0 + +#if ONE then do NOT import the NSS COMMON layer APIs +DONT_IMPORT_COMMON_LAYER=0 + +#if ONE, compile and link with the NETWARE sdk environment. +USE_NETWARE_SDK=0 + +#if ONE, include DS headers. +USE_NDS_INCLUDES=0 + +#if ONE, use all NSS includes (SDK\INCLUDE and others) +USE_SDK_INCLUDE=1 + +#if ONE, do LANGUAGE ENABLING processing +DO_LANGUAGE_ENABLING=0 + +#Set to null (i.e. no value) to not add XDC data to the NLM. For most +#NetWare 5.0 NLMs, the value should be -u. +MOAB_XDC_TOOL_OPTION= + +#************************************************************************* +# List of source directories for NSS +#************************************************************************* +SOURCE_DIRECTORIES= + +#************************************************************************* +# Source Modules for NSS (.C .386) +#************************************************************************* +SOURCE_FILES=\ + ndp_mod.c \ + ndp_comn.c \ + ndp_messagehandler.c \ + ndp_guids.c \ + ndp_idbroker.c \ + +SOURCE_FILES_NODEBUG= + +#************************************************************************* +# Source Include files for NSS (.H .inc) +#************************************************************************* +INCLUDE_FILES=\ + ndp_mod.h \ + ndp_comn.h \ + ndp_messagehandler.h \ + ndp_guids.h \ + ndp_idbroker.h \ + +#------------------------------------------------------------------------- +# Additional source files that need to be checked out +#------------------------------------------------------------------------- +OTHER_FILES=\ + Module.supported + +#------------------------------------------------------------------------- +# This defines what routines are being EXPORTED. You should put .IMP +# files in the "UTILITY_EXPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_EXPORTS= + +#UTILITY_EXPORTS_VIA_FILE= +UTILITY_EXPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# This defines what routines are being IMPORTED. You should put .IMP +# files in the "UTILITY_IMPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_IMPORTS= + +UTILITY_IMPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# Library definitions +# This defines addition libraries to LINK with and additional +# directories to put on out INCLUDE path. +#------------------------------------------------------------------------- +#additional libraries to link with +EXTRA_LIBRARIES= +EXTRA_LIBRARY_INCLPATH= + +#------------------------------------------------------------------------- +# Include path +# This defines addition include path to compile with +#------------------------------------------------------------------------- +#additional include path +EXTRA_INCLUDE_PATH=${BASEDIR}/public_core/sharedsrc + +#------------------------------------------------------------------------- +# Additional C and ASSEMBLY options to use +#------------------------------------------------------------------------- +EXTRA_C_OPTIONS= -DBUILD_NDP_IDBROKER +EXTRA_ASM_OPTIONS= + +#------------------------------------------------------------------------- +# Additional module attributes +#------------------------------------------------------------------------- +MODULE_DESCRIPTION='Novell Data Portal' +MODULE_ADDITIONAL_COPYRIGHT= +MODULE_OPTIONS= +MODULE_DEPENDENCIES= +MODULE_TYPE= +MODULE_EXTENSION=nss +MODULE_START_ROUTINE= +MODULE_EXIT_ROUTINE= +#set to 1 if you want the optimized NLM to be packed +MODULE_PACK_NLM=1 + +#========================================================================= +#========================================================================= +# LOCAL BUILD RULES +#========================================================================= +#========================================================================= + +#------------------------------------------------------------------------- +# Default BUILD rule +#------------------------------------------------------------------------- +DEFAULT: DEFAULT_BUILD + +#------------------------------------------------------------------------- +# Additional rules +#------------------------------------------------------------------------- + +BUILD_MOAB_MP_UNOPT: \ + COMPILE_UNOPT_MP_MOAB \ + LINK_UNOPT_MP_MOAB + +BUILD_MOAB_MP_OPT: \ + COMPILE_OPT_MP_MOAB \ + LINK_OPT_MP_MOAB + +BUILD_MOAB_SP_UNOPT: + @echo "...This NLM does not have an UNOPTIMIZED SP specific version" + +BUILD_MOAB_SP_OPT: + @echo "...This NLM does not have an OPTIMIZED SP specific version" + +#------------------------------------------------------------------------- +# Language Enabling rules +#------------------------------------------------------------------------- +mdb: \ + DEFAULT_MDB + +umdb: \ + LOCAL_MDB + +mdbcreate: \ + DEFAULT_CREATE_MDB_FILE + +#------------------------------------------------------------------------- +# Other rules +#------------------------------------------------------------------------- +deps: DEFAULT_DEPS + +cscope: DEFAULT_CSCOPE + diff --git a/src/nwnss/ndpmod/ndpmodVersion.c b/src/nwnss/ndpmod/ndpmodVersion.c new file mode 100644 index 0000000..3030f83 --- /dev/null +++ b/src/nwnss/ndpmod/ndpmodVersion.c @@ -0,0 +1,45 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (PSS) module + | + |--------------------------------------------------------------------------- + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + |--------------------------------------------------------------------------- + | This module is used to: + | Holds build number for the given product + +-------------------------------------------------------------------------*/ + +#include + +VersionInformation_s NDPMODVersionInfo = +{ + ZMAJV, + ZMINV, + ZSUBV, + ZBLDN, + VERINFO_NO_PATENT +}; diff --git a/src/nwnss/nebdrv/Makefile b/src/nwnss/nebdrv/Makefile new file mode 100644 index 0000000..241870b --- /dev/null +++ b/src/nwnss/nebdrv/Makefile @@ -0,0 +1,31 @@ +### +### ../nss/neb/nebdrv Makefile +### +############################################################################ +# +# (C) Copyright 1995 - 2000 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################ + +BASEDIR=../.. + +SUBDIRS= \ + +include ${BASEDIR}/buildtools/Makefile.default + diff --git a/src/nwnss/nebdrv/Module.supported b/src/nwnss/nebdrv/Module.supported new file mode 100644 index 0000000..2c659a0 --- /dev/null +++ b/src/nwnss/nebdrv/Module.supported @@ -0,0 +1 @@ +nebdrv.ko diff --git a/src/nwnss/nebdrv/nebdrvModules.mk b/src/nwnss/nebdrv/nebdrvModules.mk new file mode 100644 index 0000000..b27f151 --- /dev/null +++ b/src/nwnss/nebdrv/nebdrvModules.mk @@ -0,0 +1,274 @@ +############################################################################ +# +# (C) Copyright 1995 - 2000 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################ +########################################################################## +# This defines what MODULES are being built for this NLM +# +# $Author: ghorlacher $ +# $Date: 2007-09-13 03:51:53 +0530 (Thu, 13 Sep 2007) $ +# +# $RCSfile$ +# $Revision: 2206 $ +# +########################################################################## +MODULE_VERSION=15 + +#------------------------------------------------------------------------- +# If the version number is not defined here, the general product version +# number will be used (defined in bldVersion.bld) +# +# major version 1 to 99 +# minor version 1 to 99 +# sub version 1 to 26 +#------------------------------------------------------------------------- +#MAJOR_VERSION= +#MINOR_VERSION= +#SUB_VERSION= + +#------------------------------------------------------------------------- +# Build OPTIONS +#------------------------------------------------------------------------- +BUILD_WITH_KERNEL_FLAGS=1 +BUILD_NO_INSTRUMENT_FUNCTIONS=1 + +#set to 0 if you are NOT using source code control +IS_USING_SOURCE_CONTROL=1 + +#Set to ONE if you want the linked files to be copied to the SDK/BIN directory. +COPY_TO_SDK_BIN=1 + + #set to ONE if you only want to copy the OPTIMIZED version to SDK/BIN. + COPY_OPTIMIZED_ONLY=0 + +#Set this to ONE if you are building a NETWARE version independent NLM +#(not NETWARE version specific) +NETWARE_VERSION_INDEPENDENT=1 + + #if ONE include the NETWARE .H files in the compiler search paths. + USE_NETWARE_INCLUDES=0 + + #if ONE include the NETWARE import file at LINK time + USE_NETWARE_IMPORTS=0 + +#If ONE IMPORT the LIBNSS APIs and include in the search path SDK/LIBRARY +#and SDK/PUBLIC +IMPORT_INDEPENDENT_LIBNSS=1 + +#If ONE include in the search path SDK/LIBRARY and SDK/PUBLIC +USE_LIBNSS_INCLUDES=1 + +#If ONE then LINK with the NSS library and include all of the NSS library +#directories in the compiler search paths. This includes the SDK/PUBLIC, +#SDK/INCLUDE, SDK/INTERNAL, LIBRARY/SRC directories. +LINK_WITH_NSSLIB=0 + +#if ONE then IMPORT the NSS library and COMN layer APIS and include the +#SDK/PUBLIC directory in the compiler search paths. +IMPORT_NSSLIB=1 + + #If ONE and (LINK_WITH_NSSLIB==1 or IMPORT_NSSLIB==1) then do the same + #operation to the NSSLIB area you are doing to the local area. + CHECK_NSSLIB=0 + + #If ONE and (CHECK_NSSLIB==1) then we will clean the NSSLIB area when we + #clean the local area. + CLEAN_NSSLIB=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INCLUDE directory in + #the compiler search paths + USE_NSS_SDK_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/COMNSA directory in + #the compiler search paths + USE_NSS_SDK_COMNSA_INCLUDES=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INTERNAL directory in + #the compiler search paths + USE_NSS_SDK_INTERNAL_INCLUDES=0 + +#if ONE then do NOT import the NSS COMMON layer APIs +DONT_IMPORT_COMMON_LAYER=0 + +#if ONE, compile and link with the NETWARE sdk environment. +USE_NETWARE_SDK=0 + +#if ONE, include DS headers. +USE_NDS_INCLUDES=0 + +#if ONE, do LANGUAGE ENABLING processing +DO_LANGUAGE_ENABLING=0 + +#Set to null (i.e. no value) to not add XDC data to the NLM. For most +#NetWare 5.0 NLMs, the value should be -u. +MOAB_XDC_TOOL_OPTION=-n + +#************************************************************************* +# List of source directories for NSS +#************************************************************************* +SOURCE_DIRECTORIES= + +#************************************************************************* +# Source Modules for NSS (.C .386) +#************************************************************************* +SOURCE_FILES=\ + unebdrvLKM.c \ + unebserv.c + +SOURCE_FILES_NODEBUG= + +#************************************************************************* +# Source Include files for NSS (.H .inc) +#************************************************************************* +INCLUDE_FILES= + + +#------------------------------------------------------------------------- +# Additional source files that need to be checked out +#------------------------------------------------------------------------- +OTHER_FILES=\ + Module.supported + +#------------------------------------------------------------------------- +# This defines what routines are being EXPORTED. You should put .IMP +# files in the "UTILITY_EXPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_EXPORTS= + +#UTILITY_EXPORTS_VIA_FILE= +UTILITY_EXPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# This defines what routines are being IMPORTED. You should put .IMP +# files in the "UTILITY_IMPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_IMPORTS= + +UTILITY_IMPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# Library definitions +# This defines additional libraries to LINK with and additional +# directories to put on out INCLUDE path. +#------------------------------------------------------------------------- +#additional libraries to link with +EXTRA_LIBRARIES= +EXTRA_STATIC_LIBRARIES= +EXTRA_DYNAMIC_LIBRARIES= +EXTRA_LIBRARY_INCLPATH= + +#------------------------------------------------------------------------- +# Include path +# This defines additional include path to compile with +#------------------------------------------------------------------------- +#additional include path +EXTRA_INCLUDE_PATH= + + +#------------------------------------------------------------------------- +# Additional C and ASSEMBLY options to use +#------------------------------------------------------------------------- +EXTRA_C_OPTIONS= +EXTRA_ASM_OPTIONS= +EXTRA_LINK_OPTIONS= + +#------------------------------------------------------------------------- +# Additional module attributes +#------------------------------------------------------------------------- +MODULE_DESCRIPTION='Upcall mechanism for User Mode NEB' +MODULE_ADDITIONAL_COPYRIGHT= +MODULE_OPTIONS= +MODULE_DEPENDENCIES= +MODULE_TYPE= +MODULE_NAME=nebdrv +MODULE_EXTENSION= +MODULE_START_ROUTINE= +MODULE_EXIT_ROUTINE= +#set to 1 if you want the optimized NLM to be packed +MODULE_PACK_NLM=1 + +#========================================================================= +#========================================================================= +# LOCAL BUILD RULES +#========================================================================= +#========================================================================= + +#------------------------------------------------------------------------- +# Default BUILD rule +#------------------------------------------------------------------------- +DEFAULT: DEFAULT_BUILD + +#------------------------------------------------------------------------- +# Additional rules +#------------------------------------------------------------------------- + +#BUILD_GREENRIVER_OPT: +# @echo "...This NLM does not have an OPTIMIZED GREENRIVER specific version" + +#BUILD_GREENRIVER_UNOPT: +# @echo "...This NLM does not have an UNOPTIMIZED GREENRIVER specific version" + +BUILD_MOAB_MP_UNOPT: \ + COMPILE_UNOPT_MP_MOAB \ + LINK_UNOPT_MP_MOAB + +BUILD_MOAB_MP_OPT: \ + COMPILE_OPT_MP_MOAB \ + LINK_OPT_MP_MOAB + +BUILD_MOAB_SP_UNOPT: + @echo "...This NLM does not have an UNOPTIMIZED SP specific version" + +BUILD_MOAB_SP_OPT: + @echo "...This NLM does not have an OPTIMIZED SP specific version" + + +#BUILD_MOAB_SP_UNOPT: \ +# COMPILE_UNOPT_SP_MOAB \ +# LINK_UNOPT_SP_MOAB +# +#BUILD_MOAB_SP_OPT: \ +# COMPILE_OPT_SP_MOAB \ +# LINK_OPT_SP_MOAB + + +#------------------------------------------------------------------------- +# Language Enabling rules +#------------------------------------------------------------------------- +mdb: \ + DEFAULT_MDB + +umdb: \ + LOCAL_MDB + +mdbcreate: \ + DEFAULT_CREATE_MDB_FILE + +#------------------------------------------------------------------------- +# Other rules +#------------------------------------------------------------------------- +deps: DEFAULT_DEPS + +cscope: DEFAULT_CSCOPE + diff --git a/src/nwnss/nebdrv/nebdrvVersion.c b/src/nwnss/nebdrv/nebdrvVersion.c new file mode 100644 index 0000000..51da90f --- /dev/null +++ b/src/nwnss/nebdrv/nebdrvVersion.c @@ -0,0 +1,46 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (PSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Holds build number for the given product + +-------------------------------------------------------------------------*/ +#include + +VersionInformation_s NEBDRV_VersionInfo = +{ + ZMAJV, + ZMINV, + ZSUBV, + ZBLDN, + VERINFO_NO_PATENT +}; diff --git a/src/nwnss/nebdrv/unebdrvLKM.c b/src/nwnss/nebdrv/unebdrvLKM.c new file mode 100644 index 0000000..72e3db6 --- /dev/null +++ b/src/nwnss/nebdrv/unebdrvLKM.c @@ -0,0 +1,66 @@ +/**************************************************************************** + | + | (C) Copyright 1995 - 2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + +-------------------------------------------------------------------------*/ + +#include +#include +#include + +MODULE_INFO(vermagic, VERMAGIC_STRING); + +MODULE_AUTHOR("Novell, Inc."); +MODULE_DESCRIPTION("NEB driver"); +MODULE_LICENSE("GPL v2"); + + +#if 0 +static const struct modversion_info ____versions[] +__attribute_used__ +__attribute__((section("__versions"))) = { + { 0xbd2f2811, "struct_module" }, + { 0x1ce0d372, "malloc_sizes" }, + { 0x8b18496f, "__copy_to_user_ll" }, + { 0xc280a525, "__copy_from_user_ll" }, + { 0x1b7d4074, "printk" }, + { 0x28c3bbf5, "__down_failed_interruptible" }, + { 0x6dba0e14, "kmem_cache_alloc" }, + { 0x116e71da, "register_chrdev" }, + { 0x37a0cba, "kfree" }, + { 0x9d669763, "memcpy" }, + { 0xc192d491, "unregister_chrdev" }, + { 0xd22b546, "__up_wakeup" }, + { 0xf2520b76, "__down_failed" }, +}; +#endif + +static const char __module_depends[] +__attribute_used__ +__attribute__((section(".modinfo"))) = +"depends="; + diff --git a/src/nwnss/nebdrv/unebserv.c b/src/nwnss/nebdrv/unebserv.c new file mode 100644 index 0000000..c5b1afd --- /dev/null +++ b/src/nwnss/nebdrv/unebserv.c @@ -0,0 +1,1076 @@ +/**************************************************************************** + | + | (C) Copyright 2002-2005 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2007-03-07 06:45:10 +0530 (Wed, 07 Mar 2007) $ + | + | $RCSfile$ + | $Revision: 1908 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Userspace NEB interface on Linux + +-------------------------------------------------------------------------*/ + +/**************************************************************************** + * + * File Created: 04/20/2004 + * + * Engineering Contact: K.Y. Srinivasan + * + * Target Platform: COMMON_SOURCE + * + * + * File Description: + * An implementation of the user mode NEB server. + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Include MPK header files. + */ +//#include +#include + +#include + +#include + +#define NELEMS(_array) ( sizeof(_array) / sizeof(_array[0]) ) + +struct unebNSSEventDetails_s; + + +static int PS_noPackedSize(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event); +static void P_noPack(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int eventDataMarshalledOffset, int variableAreaOffset); +static int PS_EventLVolRenameEnter_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event); +static void P_EventLVolRenameEnter_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int eventDataMarshalledOffset, int variableAreaOffset); +static int PS_EventLVolRenameExit_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event); +static void P_EventLVolRenameExit_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int eventDataMarshalledOffset, int variableAreaOffset); +static int PS_EventPoolRenameEnter_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event); +static void P_EventPoolRenameEnter_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int eventDataMarshalledOffset, int variableAreaOffset); +static int PS_EventPoolRenameExit_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event); +static void P_EventPoolRenameExit_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int eventDataMarshalledOffset, int variableAreaOffset); +static int unebMarshallComplex(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int marshalledAmount ); + + + +typedef int (*unebMarshall_t)(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int marshalledAmount); +typedef int (*unebVariablePackedSize_t)(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event); +typedef void (*unebVariablePack_t)(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int eventDataMarshalledOffset, int variableAreaOffset); + +typedef struct unebNSSEventDetails_s { + const char *NNE_EventName; + unebMarshall_t NNE_MarshallRoutine; + const NEBMarshallInfo_s *NNE_MarshallInfo; + unebVariablePackedSize_t NNE_VariablePackedSize; + unebVariablePack_t NNE_VariablePack; +} unebNSSEventDetails_s; + + +const NEBMarshallInfo_s NMI_Simple = { sizeof(NEBMarshallInfo_s), 0, {0, 0} }; +const NEBMarshallInfo_s NMI_EventLVolRenameEnter_s = + { sizeof(NEBMarshallInfo_s), 2, {offsetof( EventLVolRenameEnter_s, oldName ), offsetof( EventLVolRenameEnter_s, newName )} }; +const NEBMarshallInfo_s NMI_EventLVolRenameExit_s = + { sizeof(NEBMarshallInfo_s), 1, {offsetof( EventLVolRenameExit_s, volName ), 0 } }; +const NEBMarshallInfo_s NMI_EventPoolRenameEnter_s = + { sizeof(NEBMarshallInfo_s), 2, {offsetof( EventPoolRenameEnter_s, oldName ), offsetof( EventPoolRenameEnter_s, newName )} }; +const NEBMarshallInfo_s NMI_EventPoolRenameExit_s = + { sizeof(NEBMarshallInfo_s), 2, {offsetof( EventPoolRenameExit_s, oldName ), offsetof( EventPoolRenameExit_s, newName )} }; + + + + +/* + * State mantained on behalf of each registered event. + */ + +typedef struct unebEvent { + struct unebEvent *next; + unsigned int eventSize; + BYTE ue_event[4096-128]; +} unebEvent_t; + +typedef struct unebOpenState { + spinlock_t lock; + void *userCookie; + int numEvents; + struct unebEvent *first; + struct unebEvent *last; + int shutDown; /* !0 device is being closed.*/ + int needToUnregister; /*!0 need to unregister */ + /* + * If state is 0; no event is currently registered; !0, + * an event has been registered. + */ + int state; + /* + * Semaphore on which the client waits for events. + */ + struct semaphore waitSema; + /* + * Semaphore for supporting synchronous consumer. + */ + struct semaphore synchSema; + /* + * Return code from the user-level event handler. + */ +// int hdlrReturnCode; + unebClientStatus_s UOS_fromUser; + /* + * Consumer registration info. + */ + struct ConsumerRegistrationInfo UOS_consumerInfo; + char UOS_eventName[256]; // Need to keep a copy for us. + char UOS_consumerName[256]; + +} unebOpenState_t; + + +/* + * This variable keeps track of the major number associated with this driver. + */ +int unebMajor; +/* + * Name of the NEB driver. + */ +char *unebServName = UNEB_SERV_NAME; + + +/* + This table holds ALL of the events that we support in user space. It is used to reject registrations + requests for non-supported events. Its main purpose is to allow for table driven marshalling. + + Refer to "NSS.AddTrustee.Enter" for an example of an NSS event that does not have pointers + in the eventData. Good Events. + + Refer to "NSS.PoolRename.Enter" for an example of an NSS event that has pointers in the + eventData. Evil events. Support for this type of events where added January + 2005. This was needed for the last minute request of pool and volume rename events. + */ +unebNSSEventDetails_s UnebEventDetails[] = { + { "NSS.AddTrustee.Enter", unebMarshallComplex, &NMI_Simple, PS_noPackedSize, P_noPack }, + { "NSS.AddTrustee.Exit", unebMarshallComplex, &NMI_Simple, PS_noPackedSize, P_noPack }, + { "NSS.ChangePoolState.Enter", unebMarshallComplex, &NMI_Simple, PS_noPackedSize, P_noPack }, + { "NSS.ChangePoolState.Exit", unebMarshallComplex, &NMI_Simple, PS_noPackedSize, P_noPack }, + { "NSS.ChangeVolState.Enter", unebMarshallComplex, &NMI_Simple, PS_noPackedSize, P_noPack }, + { "NSS.ChangeVolState.Exit", unebMarshallComplex, &NMI_Simple, PS_noPackedSize, P_noPack }, + { "NSS.LVolumeRename.Enter", unebMarshallComplex, &NMI_EventLVolRenameEnter_s, PS_EventLVolRenameEnter_s, P_EventLVolRenameEnter_s }, + { "NSS.LVolumeRename.Exit", unebMarshallComplex, &NMI_EventLVolRenameExit_s, PS_EventLVolRenameExit_s, P_EventLVolRenameExit_s }, + { "NSS.PoolRename.Enter", unebMarshallComplex, &NMI_EventPoolRenameEnter_s, PS_EventPoolRenameEnter_s, P_EventPoolRenameEnter_s }, + { "NSS.PoolRename.Exit", unebMarshallComplex, &NMI_EventPoolRenameExit_s, PS_EventPoolRenameExit_s, P_EventPoolRenameExit_s }, + { "NSS.RemoveTrustee.Enter", unebMarshallComplex, &NMI_Simple, PS_noPackedSize, P_noPack }, + { "NSS.RemoveTrustee.Exit", unebMarshallComplex, &NMI_Simple, PS_noPackedSize, P_noPack }, + { "NSS.SetInheritedRights.Enter", unebMarshallComplex, &NMI_Simple, PS_noPackedSize, P_noPack }, + { "NSS.SetInheritedRights.Exit", unebMarshallComplex, &NMI_Simple, PS_noPackedSize, P_noPack }, +}; + + + /* Ensure that we are being compiled corrrectly */ +int NSS_UnicodeIsAssumedToBe2Bytes[ (sizeof(unicode_t) == 2) ? 1 : 0 ]; + +/* This is a copy of code in NSS. Needed for last minute addition of complex marshalling. + */ +static unicode_t *unicpy( + unicode_t *dest, + const unicode_t *src) +{ + unicode_t *odest = dest; + + while( (*dest++ = *src++) != (unicode_t)0 ) + ; + return(odest); +} + + +/* This is a copy of code in NSS. Needed for last minute addition of complex marshalling. + */ +static size_t unilen(const unicode_t *s) +{ + const unicode_t *s0 = s; + + while (*s != 0) + s++; + return (s - s0); +} + +/* + packedSizeOfUniString() - + Calculate number of bytes to store a NULL terimated unicode string. This + includes the two bytes needed to store the NULL. + + Returns - + The number of bytes to store a NULL terimated unicode string. + */ +static int packedSizeOfUniString( const unicode_t *uniString ) +{ + return( (unilen( uniString ) + 1) * sizeof(unicode_t) ); +} + +/* + PS_noPackedSize() - + Calculates the number of bytes needed to marshall our variable data. Default + function to use when an NSS eventData does not have any addresses in it. + + Returns - + The number of bytes that we need to be able to marshall our variable data. + */ +static int PS_noPackedSize(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event) +{ + return 0; +} + +/* + P_noPack() - + Marshalls variable data. I.E. copies are variable data into the marshall + buffer and fixes address that point to this data to be OFFSETs. Default + function to use when an NSS eventData does not have any addresses in it. + + Notes - + The addresses are replaced by OFFSETs that are relative to the NSS + eventData. This was done to elimanate code to fix the offsets + that the compilier stored in the NEBMarshallInfo_s fields using offsetof. + */ +static void P_noPack(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int eventDataMarshalledOffset, int variableAreaOffset) +{ + return; +} + + +/* + PS_EventPoolRenameEnter_s() - + Calculates the number of bytes needed to marshall our variable data. + + Returns - + The number of bytes that we need to be able to marshall our variable data. + */ +static int PS_EventPoolRenameEnter_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event) +{ + const EventPoolRenameEnter_s *eventData; + int packedSize = 0; + + eventData = (EventPoolRenameEnter_s *)event->EBEventData; + packedSize += packedSizeOfUniString( eventData->oldName ); + packedSize += packedSizeOfUniString( eventData->newName ); + return packedSize; +} + + +/* + P_EventPoolRenameEnter_s() - + Marshalls variable data. I.E. copies are variable data into the marshall + buffer and fixes address that point to this data to be OFFSETs. + + Notes - + The addresses are replaced by OFFSETs that are relative to the NSS + eventData. This was done to elimanate code to fix the offsets + that the compilier stored in the NEBMarshallInfo_s fields using offsetof. + */ +static void P_EventPoolRenameEnter_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int eventDataMarshalledOffset, int variableAreaOffset) +{ + int packedSize = 0; + const EventPoolRenameEnter_s *eventData; + EventPoolRenameEnter_s *eventDataMarshalled; /* Location within marshallBuffer (ue_event) to store marshalled eventData */ + BYTE *ourVariableArea; /* Location within marshallBuffer (ue_event) to store any marshalled variable eventData */ + unicode_t *cVA; + + eventData = (EventPoolRenameEnter_s *)event->EBEventData; + eventDataMarshalled = (EventPoolRenameEnter_s *)(marshallBuffer + eventDataMarshalledOffset); + ourVariableArea = marshallBuffer + variableAreaOffset; + + cVA = (unicode_t *)(ourVariableArea + packedSize); + unicpy( cVA, eventData->oldName ); + eventDataMarshalled->oldName = (unicode_t *)(ADDR)(variableAreaOffset - eventDataMarshalledOffset + packedSize); + packedSize += packedSizeOfUniString( eventData->oldName ); + + cVA = (unicode_t *)(ourVariableArea + packedSize); + unicpy( cVA, eventData->newName ); + eventDataMarshalled->newName = (unicode_t *)(ADDR)(variableAreaOffset - eventDataMarshalledOffset + packedSize); +// packedSize += packedSizeOfUniString( eventData->newName ); + + return; +} + + +static int PS_EventPoolRenameExit_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event) +{ + const EventPoolRenameExit_s *eventData; + int packedSize = 0; + + eventData = (EventPoolRenameExit_s *)event->EBEventData; + packedSize += packedSizeOfUniString( eventData->oldName ); + packedSize += packedSizeOfUniString( eventData->newName ); + return packedSize; +} + +static void P_EventPoolRenameExit_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int eventDataMarshalledOffset, int variableAreaOffset) +{ + int packedSize = 0; + const EventPoolRenameExit_s *eventData; + EventPoolRenameExit_s *eventDataMarshalled; + BYTE *ourVariableArea; + unicode_t *cVA; + + eventData = (EventPoolRenameExit_s *)event->EBEventData; + eventDataMarshalled = (EventPoolRenameExit_s *)(marshallBuffer + eventDataMarshalledOffset); + ourVariableArea = marshallBuffer + variableAreaOffset; + + cVA = (unicode_t *)(ourVariableArea + packedSize); + unicpy( cVA, eventData->oldName ); + eventDataMarshalled->oldName = (unicode_t *)(ADDR)(variableAreaOffset - eventDataMarshalledOffset + packedSize); + packedSize += packedSizeOfUniString( eventData->oldName ); + + cVA = (unicode_t *)(ourVariableArea + packedSize); + unicpy( cVA, eventData->newName ); + eventDataMarshalled->newName = (unicode_t *)(ADDR)(variableAreaOffset - eventDataMarshalledOffset + packedSize); +// packedSize += packedSizeOfUniString( eventData->newName ); + + return; +} + + +static int PS_EventLVolRenameEnter_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event) +{ + const EventLVolRenameEnter_s *eventData; + int packedSize = 0; + + eventData = (EventLVolRenameEnter_s *)event->EBEventData; + packedSize += packedSizeOfUniString( eventData->oldName ); + packedSize += packedSizeOfUniString( eventData->newName ); + return packedSize; +} + +static void P_EventLVolRenameEnter_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int eventDataMarshalledOffset, int variableAreaOffset) +{ + int packedSize = 0; + const EventLVolRenameEnter_s *eventData; + EventLVolRenameEnter_s *eventDataMarshalled; + BYTE *ourVariableArea; + unicode_t *cVA; + +// printk( "<1>P_EventLVolRenameEnter_s(%s)\n", eDetails->NNE_EventName ); + eventData = (EventLVolRenameEnter_s *)event->EBEventData; + eventDataMarshalled = (EventLVolRenameEnter_s *)(marshallBuffer + eventDataMarshalledOffset); + ourVariableArea = marshallBuffer + variableAreaOffset; + + cVA = (unicode_t *)(ourVariableArea + packedSize); + unicpy( cVA, eventData->oldName ); +// printk( "<1>P_EventLVolRenameEnter_s(%u)\n", variableAreaOffset ); +// printk( "<1>P_EventLVolRenameEnter_s(%u)\n", eventDataMarshalledOffset ); +// printk( "<1>P_EventLVolRenameEnter_s(%u)\n", packedSize ); + eventDataMarshalled->oldName = (unicode_t *)(ADDR)(variableAreaOffset - eventDataMarshalledOffset + packedSize); + packedSize += packedSizeOfUniString( eventData->oldName ); + + cVA = (unicode_t *)(ourVariableArea + packedSize); +// printk( "<1>P_EventLVolRenameEnter_s(%u)\n", variableAreaOffset ); +// printk( "<1>P_EventLVolRenameEnter_s(%u)\n", eventDataMarshalledOffset ); +// printk( "<1>P_EventLVolRenameEnter_s(%u)\n", packedSize ); + unicpy( cVA, eventData->newName ); + eventDataMarshalled->newName = (unicode_t *)(ADDR)(variableAreaOffset - eventDataMarshalledOffset + packedSize); +// packedSize += packedSizeOfUniString( eventData->newName ); + + return; +} + +static int PS_EventLVolRenameExit_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event) +{ + const EventLVolRenameExit_s *eventData; + int packedSize = 0; + + eventData = (EventLVolRenameExit_s *)event->EBEventData; + packedSize += packedSizeOfUniString( eventData->volName ); + return packedSize; +} + + +static void P_EventLVolRenameExit_s(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int eventDataMarshalledOffset, int variableAreaOffset) +{ + int packedSize = 0; + const EventLVolRenameExit_s *eventData; + EventLVolRenameExit_s *eventDataMarshalled; + BYTE *ourVariableArea; + unicode_t *cVA; + + eventData = (EventLVolRenameExit_s *)event->EBEventData; + eventDataMarshalled = (EventLVolRenameExit_s *)(marshallBuffer + eventDataMarshalledOffset); + ourVariableArea = marshallBuffer + variableAreaOffset; + + cVA = (unicode_t *)(ourVariableArea + packedSize); + unicpy( cVA, eventData->volName ); + eventDataMarshalled->volName = (unicode_t *)(ADDR)(variableAreaOffset - eventDataMarshalledOffset + packedSize); +// packedSize += packedSizeOfUniString( eventData->volName ); + + return; +} + + + + +/* + unebMarshallComplex() - + Marshall NSS portion of data. Creates a Marshall header, eventData + and variable eventData. Will convert addresses in eventData into + offsets. The Marshall header is filled in with information to allow for + a generic conversion of eventData offsets back into addresses in user space. + + Returns - + How many BYTES that we marshalled. + + Notes - + If EBEventData is !NULL then we need to copy EBEventDataLength + worth of bytes to do marshalling. + +*/ +static int unebMarshallComplex(const struct unebNSSEventDetails_s *eDetails, const struct EventBlock *event, BYTE *marshallBuffer, int bufferSize, int marshalledAmount ) +{ + BYTE *marshallInfoArea; + BYTE *eventData; + BYTE *eventDataMarshalled; // Area that is fixed size. Fixed PER event, not for all events. + BYTE *ourVariableArea; + int eventDataMarshalledAmount; + int ourVariableAmount; + int marshallInfoAreaAmount; + +// printk( "<1>unebMarshallComplex(start)\n" ); +// printk( "<1>unebMarshallComplex(%s)\n", eDetails->NNE_EventName ); + eventData = event->EBEventData; + if ( eventData == NULL ) + { + return 0; + } + eventDataMarshalledAmount = event->EBEventDataLength; +// printk( "<1>unebMarshallComplex(vd %u)\n", eventDataMarshalledAmount ); + if ( eventDataMarshalledAmount == 0 ) + { + return 0; + } +// printk( "<1>unebMarshallComplex(marshall)\n" ); +// printk( "<1>unebMarshallComplex(eb %u)\n", marshalledAmount ); + marshallInfoArea = marshallBuffer + marshalledAmount; + marshallInfoAreaAmount = eDetails->NNE_MarshallInfo->NMI_SizeOf; +// printk( "<1>unebMarshallComplex(mi %u)\n", marshallInfoAreaAmount ); + eventDataMarshalled = marshallInfoArea + marshallInfoAreaAmount; + ourVariableArea = eventDataMarshalled + eventDataMarshalledAmount; + ourVariableAmount = eDetails->NNE_VariablePackedSize( eDetails, event ); +// printk( "<1>unebMarshallComplex(va %u)\n", ourVariableAmount ); + if ( (marshalledAmount + marshallInfoAreaAmount + eventDataMarshalledAmount + ourVariableAmount) > bufferSize ) + { // Not enough space to marshall our data fixfixfix + printk("<1>UNEB: Not enough space to Marshall NEB event\n"); + return 0; + } + memcpy( marshallInfoArea, eDetails->NNE_MarshallInfo, marshallInfoAreaAmount ); + memcpy( eventDataMarshalled, eventData, eventDataMarshalledAmount ); + // Do last so that PACK routine can also change Addresses into OFFSETs (in eventData area of the marshall buffer). + eDetails->NNE_VariablePack( eDetails, event, marshallBuffer, bufferSize, marshalledAmount+marshallInfoAreaAmount, marshalledAmount+marshallInfoAreaAmount+eventDataMarshalledAmount ); + //printk( "<1>unebMarshallComplex(packed bytes %u)\n", marshallInfoAreaAmount+eventDataMarshalledAmount+ourVariableAmount ); + return marshallInfoAreaAmount+eventDataMarshalledAmount+ourVariableAmount; + +} + + +void +assert_wait(void) +{ +} + +/* + unebGetEventDetails() - + Returns a events unebNSSEventDetails_s information. NULL + if we do not have information about the event. Which would + mean we can not marshall its data. +*/ +unebNSSEventDetails_s *unebGetEventDetails( const char *eventName ) +{ + int i; + + for ( i = 0; i < NELEMS(UnebEventDetails); ++i ) + { + if ( strcmp( eventName, UnebEventDetails[i].NNE_EventName ) == 0 ) + { + return &UnebEventDetails[i]; + } + } + return NULL; +} + +/* + * int + * unebMarshall(struct EventBlock *event, int *marshallBuffer, int bufferSize) + * Marshall the event pointed to by EventBlock into the buffer + * pointed to by the parameter "marshallBuffer". The parameter bufferSize + * specifies the size of the marshallBuffer. + * + * Calling/Exit State: + * Does not block. + * + */ + +int +unebMarshall(unebOpenState_t *unebDev, struct EventBlock *event, BYTE *marshallBuffer, int bufferSize) +{ + unebNSSEventDetails_s *eventDetails; + int marshalledAmount; + + // First Store off EventBlock + *((struct EventBlock *)marshallBuffer) = *event; // This is doing a BIG memcopy + marshalledAmount = sizeof(*event); + // Now store off NSS event specific data + eventDetails = unebGetEventDetails( unebDev->UOS_eventName ); + if ( eventDetails == NULL ) + { // This should not occur as we only allow user to register for supported NSS events. + printk("<1>UNEB: Event %s not found\n",unebDev->UOS_eventName); + return marshalledAmount; + } + marshalledAmount += eventDetails->NNE_MarshallRoutine( eventDetails, event, marshallBuffer, bufferSize, marshalledAmount ); + return (marshalledAmount); +} +/* + * Our consumer callback functions. + */ + +unsigned long numEventsPosted=0; +/* + * NEB_STATUS unebConsumerCB(struct EventBlock *eventBlock) + * Consumer callback. + * + * Calling/Exit State. + * May block. + */ + +NEB_STATUS +unebConsumerCB(struct EventBlock *eventBlock) +{ + struct unebEvent *curEvent; + unebOpenState_t *unebDev; + NEB_STATUS retCode; + +//printk("In unebConsumerCB\n"); + unebDev = eventBlock->EBUserParameter; + + if ((in_interrupt() || in_softirq())) { + /* + * NSS needs support for synchronous NEB consumers; hence + * we NEED a process context here. + */ + printk("<1>UNEB: Non-process context posting NEB event\n"); + BUG(); + } + if (unebDev->shutDown != 0) { + //printk("End unebConsumerCB(shutDown)\n"); + return (SUCCESS); + } + if ( unebDev->needToUnregister == 0 ) + { // fixfixfix - we are eating the 'produce ESR event'. maybe someone wants to see it. + // Code added to prevent a deadlock. + //printk("End unebConsumerCB(needToUnregister)\n"); + return (SUCCESS); + } + + curEvent = kmalloc(sizeof(struct unebEvent), GFP_KERNEL); + if ( curEvent == NULL ) + { + printk("<1>UNEB: Lost NEB event(no memory)\n"); + return SUCCESS; + } + /* + * Before we marshall the event set the user parameter in the event + * to what the user-level app specified. + */ + eventBlock->EBUserParameter = unebDev->userCookie; + /* + * Need to marshall the event into our marshallBuffer. + */ + curEvent->eventSize = unebMarshall(unebDev, eventBlock, curEvent->ue_event, sizeof(curEvent->ue_event) ); +//printk("<1>In unebConsumerCB(unebMarshall)\n"); + /* + * Reset the user parameter in the event after the event is + * marshalled. + */ + eventBlock->EBUserParameter = unebDev; + /* + * Now queue up the marshalled event and wakeup the user thread. + */ + curEvent->next = NULL; + spin_lock_irq(&unebDev->lock); + if (unebDev->first == NULL) { + ASSERT(unebDev->last == NULL); + ASSERT(unebDev->numEvents == 0); + unebDev->first = curEvent; + unebDev->last = curEvent; + unebDev->numEvents = 1; + } else { + ASSERT(unebDev->last != NULL); + ASSERT(unebDev->numEvents != 0); + unebDev->last->next = curEvent; + unebDev->last = curEvent; + unebDev->numEvents++; + } + spin_unlock_irq(&unebDev->lock); +//printk("In unebConsumerCB(before up)\n"); + up(&unebDev->waitSema); +//printk("In unebConsumerCB(up)\n"); + /* + * Now wait for the user to rule on this event. + */ + down(&unebDev->synchSema); +//printk("In unebConsumerCB(down)\n"); + if (unebDev->shutDown != 0) { + //printk("End unebConsumerCB(shutDown(2))\n"); + return (0); + } +// retCode = unebDev->hdlrReturnCode; + retCode = unebDev->UOS_fromUser.UCS_NEBStatus; + eventBlock->EBParm0 = unebDev->UOS_fromUser.UCS_NEBParm0; + eventBlock->EBParm1 = unebDev->UOS_fromUser.UCS_NEBParm1; +// unebDev->hdlrReturnCode = 0; + memset( &unebDev->UOS_fromUser, 0, sizeof(unebDev->UOS_fromUser) ); + +//printk("End unebConsumerCB\n"); + return (retCode); +} + + +/* + * int unebServUnRegisterConsumer(unebOpenState_t *unebDev) + * Unregister the event. + * + * Calling/Exit State: + * May block. + */ + +int +unebServUnRegisterConsumer(unebOpenState_t *unebDev) +{ + NEB_STATUS retVal; + unebEvent_t *eventToFree; + + /* + * First unregister the consumer. + */ + if (unebDev->needToUnregister != 0) { + /* + * Before invoking the NEB API, transform the calling + * thread to an MPK thread. + */ + mpkEnter(); + retVal = + UnRegisterConsumer(unebDev->UOS_consumerInfo.CRIConsumerID, + unebDev); + ASSERT(retVal == 0); + mpkExit(); + unebDev->needToUnregister = 0; + } + + /* + * Now cleanup the state on the device. + */ + unebDev->state = 0; + unebDev->shutDown = 1; + /* + * Wakeup the clone that might be blocked. + */ + up(&unebDev->waitSema); + /* + * Wakeup all the event posting threads that may be blocked here. + */ + while(unebDev->synchSema.sleepers != 0) { + up(&unebDev->synchSema); + } + /* + * Now cleanup all queued messages. + */ + while (unebDev->first != NULL) { + eventToFree = unebDev->first; + unebDev->first = eventToFree->next; + kfree(eventToFree); + } + return (0); +} + + + +/* + * int unebServRegisterConsumer(consumerInfo_t_t *regState, + * unebOpenState_t *unebDev) + * Register as a consumer for the specified event. + * + * Calling/Exit State: + * May block. + */ + +int +unebServRegisterConsumer(consumerInfo_t *regState, unebOpenState_t *unebDev) +{ + NEB_STATUS nebStatus; + + if ( (regState->eventName == NULL) || ( strlen(regState->eventName) >= sizeof(unebDev->UOS_eventName) ) ) + { + return (-EINVAL); + } + if ( (regState->consumerName == NULL) || ( strlen(regState->consumerName) >= sizeof(unebDev->UOS_consumerName) ) ) + { + return (-EINVAL); + } + strcpy( unebDev->UOS_consumerName, regState->consumerName ); + strcpy( unebDev->UOS_eventName, regState->eventName ); + if ( unebGetEventDetails( unebDev->UOS_eventName ) == NULL ) + { // Have no details so event must not be supported in user space. + return (-EINVAL); + } + //printk("<4>UNEB Event Register(%s,%s)\n",unebDev->UOS_consumerName,unebDev->UOS_eventName ); + unebDev->shutDown = 0; + unebDev->userCookie = regState->consumerCookie; + + ASSERT(unebDev->state == 1); + ASSERT(unebDev->numEvents == 0); + ASSERT(unebDev->first == NULL); + ASSERT(unebDev->last == NULL); + + unebDev->UOS_consumerInfo.CRIVersion = 1; + unebDev->UOS_consumerInfo.CRIConsumerName = &unebDev->UOS_consumerName[0]; + unebDev->UOS_consumerInfo.CRIEventName = &unebDev->UOS_eventName[0]; + + unebDev->UOS_consumerInfo.CRIUserParameter = unebDev; + unebDev->UOS_consumerInfo.CRIEventFlags = regState->eventFlags; + /* + * We don't support MAY_NOT_SLEEO_BIT. + */ + unebDev->UOS_consumerInfo.CRIEventFlags &= ~MAY_NOT_SLEEP_BIT; + unebDev->UOS_consumerInfo.CRIOwnerID = (void *)0xffffffff; + unebDev->UOS_consumerInfo.CRIConsumerESR = unebConsumerCB; +// unebDev->UOS_consumerInfo.CRIConsumerESR = NULL; + unebDev->UOS_consumerInfo.CRISecurityToken = 0; + unebDev->UOS_consumerInfo.CRIConsumerFlags = regState->consumerFlags; + unebDev->UOS_consumerInfo.CRIFilterName = NULL; + unebDev->UOS_consumerInfo.CRIFilterDataLength = 0; + unebDev->UOS_consumerInfo.CRIFilterData = NULL; + unebDev->UOS_consumerInfo.CRIConsumerCallback = unebConsumerCB; + unebDev->UOS_consumerInfo.CRIConsumerType = regState->consumerType; + unebDev->UOS_consumerInfo.CRIOrder = regState->consumerOrder; + +//printk("Before call to RegisterConsumer\n"); + /* + * Before we invoke the NEB API; make the calling thread an MPK + * thread. + */ + mpkEnter(); + nebStatus = RegisterConsumer(&unebDev->UOS_consumerInfo); + /* + * Leave the MPK environment. + */ + mpkExit(); +//printk("After call to RegisterConsumer\n"); + if (nebStatus != 0) { + printk("<1>UNEB: Register error is %d\n", nebStatus); + } + switch (nebStatus) { + case SUCCESS: + unebDev->needToUnregister = 1; +//printk("End unebServRegisterConsumer(SUCCESS)\n"); + return (0); + case INVALID_PARAMETER: + case EVENT_CONFLICT: + case CONSUMER_ALREADY_REGISTERED: + case INVALID_CONSUMER_TYPE: + case INVALID_FILTER: +//printk("End unebServRegisterConsumer(EINVAL)\n"); + return (-EINVAL); + + case OUT_OF_RESOURCES: +//printk("End unebServRegisterConsumer(ENOMEM)\n"); + return (-ENOMEM); + + default: +//printk("End unebServRegisterConsumer(default)\n"); + return (-EINVAL); + } +} + + +/* + * int unebServOpen(struct inode *inode, struct file *filp) + * The Open routine. + * + * Calling/Exit State: + * May block. + */ + +int +unebServOpen(struct inode *inode, struct file *filp) +{ + unebOpenState_t *unebDev; + + unebDev = filp->private_data = + kmalloc(sizeof(unebOpenState_t), GFP_KERNEL); + + if (unebDev == NULL) { + printk("<1>UNEB: Cannot Allocate Memory\n"); + return (-ENOMEM); + } + /* + * Initialize the open state. + */ + unebDev->userCookie = NULL; + unebDev->first = NULL; + unebDev->last = NULL; + unebDev->numEvents = 0; + unebDev->shutDown = 0; + unebDev->needToUnregister = 0; + unebDev->state = 0; + memset( &unebDev->UOS_fromUser, 0, sizeof(unebDev->UOS_fromUser) ); +// unebDev->hdlrReturnCode = 0; + spin_lock_init(&unebDev->lock); + sema_init(&unebDev->waitSema, 0); + sema_init(&unebDev->synchSema, 0); + return (0); +} + +/* + * int unebServClose(struct inode *inode, struct file *filp) + * Close the device. + * + * Calling/Exit State: + * May block. + * + */ + +int +unebServClose(struct inode *inode, struct file *filp) +{ + unebOpenState_t *unebDev = filp->private_data; + int error; + error = unebServUnRegisterConsumer(unebDev); + ASSERT(error == 0); + /* + * Free up the device state. + */ + kfree(unebDev); + return (0); +} + +unsigned long numEventsProcessed=0; + +/* + * int unebServIoCtl(struct inode *inode, struct file *filp, unsigned int cmd, + * unsigned long ag) + * Device ioctl. + * + * Calling/Exit State: + * May block. + * + */ + +int +unebServIoCtl(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + int error; + unebOpenState_t *unebDev = filp->private_data; + consumerInfo_t regState; + +//printk("Start unebServIoCtl\n"); + + if ((_IOC_TYPE(cmd) < UNEBDRV_IOCTL_MAGIC) || + (_IOC_NR(cmd) > UNEBDRV_IOCTL_MAXNR)) { + printk("<1>UNEB: End unebServIoCtl(ENOTTY)\n"); + return (-ENOTTY); + } + switch(cmd) { + case UNEBDRV_IOCTL_GET_EVENT: +//printk("In unebServIoCtl(UNEBDRV_IOCTL_GET_EVENT)\n"); + if (unebDev->state == 0 ) { + /* + * The client has not registered for + * any event; return error. + */ +//printk("End unebServIoCtl(UNEBDRV_IOCTL_GET_EVENT,EINVAL)\n"); + return (-EINVAL); + } +processEvent: +//printk("In unebServIoCtl(UNEBDRV_IOCTL_GET_EVENT,processEvent:)\n"); + + spin_lock_irq(&unebDev->lock); + if (unebDev->first != NULL) { + unebEvent_t *curEvent; + /* + * Dequeue the event and return. + */ +//printk("In unebServIoCtl(UNEBDRV_IOCTL_GET_EVENT,first)\n"); + curEvent = unebDev->first; + unebDev->first = curEvent->next; + unebDev->numEvents--; + if (unebDev->numEvents == 0) { + ASSERT(unebDev->first == NULL); + unebDev->last = NULL; + } + spin_unlock_irq(&unebDev->lock); + /* + * Now copyout the event. + */ +//printk("In unebServIoCtl(UNEBDRV_IOCTL_GET_EVENT,pre copy_to_user)\n"); + error = + copy_to_user((void *)arg, curEvent->ue_event, + curEvent->eventSize); +//printk("In unebServIoCtl(UNEBDRV_IOCTL_GET_EVENT,copy_to_user)\n"); + numEventsProcessed++; + /* + * Free up the event we have processed. + */ + kfree(curEvent); +//printk("End unebServIoCtl(UNEBDRV_IOCTL_GET_EVENT,0)\n"); + return (0); + } + spin_unlock_irq(&unebDev->lock); +//printk("In unebServIoCtl(234)\n"); + /* + * Currently no event is pending; wait for events to + * come in. Note that since semaphores are + * stateful, we will not miss the wakeup. + */ + error = down_interruptible(&unebDev->waitSema); + /* + * We may be awakened because we are closing. + */ + if ((unebDev->shutDown != 0) || (error != 0)) { + //printk("End unebServIoCtl(EINVAL)\n"); + return (-EINVAL); + } + /* + * Some event has materialized; go back and deal + * with it. + */ + goto processEvent; + + case UNEBDRV_IOCTL_REGISTER_CONSUMER: +//printk("In unebServIoCtl(UNEBDRV_IOCTL_REGISTER_CONSUMER)\n"); + spin_lock(&unebDev->lock); + if (unebDev->state != 0 ) { + spin_unlock(&unebDev->lock); +//printk("End unebServIoCtl(UNEBDRV_IOCTL_REGISTER_CONSUMER,EINVAL)\n"); + return (-EINVAL); + } + unebDev->state =1; + spin_unlock(&unebDev->lock); + + error = + copy_from_user((void *)®State, (void *)arg, + sizeof(consumerInfo_t)); + if (error != 0) { +//printk("End unebServIoCtl(UNEBDRV_IOCTL_REGISTER_CONSUMER,EFAULT)\n"); + return (-EFAULT); + } + // FixFixFix - someone needs to validate that consumerName and eventName are NULL terminated + /* + * Now register the event with NEB as a consumer. + */ + error = unebServRegisterConsumer(®State, unebDev); + if (error != 0) { + printk("<1>UNEB: Register error %d\n", error); + } +//printk("End unebServIoCtl(UNEBDRV_IOCTL_REGISTER_CONSUMER,error)\n"); + return (error); + + case UNEBDRV_IOCTL_UNREGISTER_CONSUMER: +//printk("In unebServIoCtl(UNEBDRV_IOCTL_UNREGISTER_CONSUMER)\n"); + if (unebDev->state == 0 ) { +//printk("End unebServIoCtl(UNEBDRV_IOCTL_UNREGISTER_CONSUMER,EINVAL)\n"); + return (-EINVAL); + } + /* + * Now register the event with NEB as a consumer. + */ + error = unebServUnRegisterConsumer(unebDev); + if (error != 0) { + //printk("Failed Un-Register Consumer\n"); + printk("<1>UNEB: Unregister error is %d\n", error); + } +//printk("End unebServIoCtl(UNEBDRV_IOCTL_UNREGISTER_CONSUMER,error)\n"); + return (error); + + case UNEBDRV_IOCTL_REPORT_STATUS: +//printk("End unebServIoCtl(UNEBDRV_IOCTL_REPORT_STATUS)\n"); + ASSERT(unebDev->state != 0); + ASSERT(unebDev->shutDown == 0); +// unebDev->hdlrReturnCode = (int)arg; + unebDev->UOS_fromUser = *((unebClientStatus_s *)arg); /* A structure copy */ + /* + * Now wakeup the event posting context. + */ + up(&unebDev->synchSema); + return (0); + + default: +//printk("End unebServIoCtl(default)\n"); + return (-EINVAL); + } +//printk("End unebServIoCtl(0)\n"); + return (0); +} + +/* + * Module init entry point. + */ + +struct file_operations unebServOps = { + owner: THIS_MODULE, + open: unebServOpen, + release: unebServClose, + ioctl: unebServIoCtl, +}; + +int init_module(void) +{ + unebMajor = + register_chrdev(0, unebServName, &unebServOps); + if (unebMajor < 0) { + printk("<1>UNEB: Could not register the Uneb Serv device\n"); + return (unebMajor); + } + return (0); +} + +/* + * void cleanup_module(void) + * Module cleanup entry point. + */ +void +cleanup_module(void) +{ + unregister_chrdev(unebMajor, unebServName); +} diff --git a/src/nwnss/nss/Makefile b/src/nwnss/nss/Makefile new file mode 100644 index 0000000..5197fce --- /dev/null +++ b/src/nwnss/nss/Makefile @@ -0,0 +1,32 @@ +### +### ../nss/public_core/nss Makefile +### + +############################################################################## +# +# (C) Copyright 2004 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +BASEDIR=../.. + +SUBDIRS= \ + +include ${BASEDIR}/buildtools/Makefile.default + diff --git a/src/nwnss/nss/Module.supported b/src/nwnss/nss/Module.supported new file mode 100644 index 0000000..b6dacf6 --- /dev/null +++ b/src/nwnss/nss/Module.supported @@ -0,0 +1 @@ +nss.ko diff --git a/src/nwnss/nss/cache/asyncio.c b/src/nwnss/nss/cache/asyncio.c index 1ab9e64..d9f54a2 100644 --- a/src/nwnss/nss/cache/asyncio.c +++ b/src/nwnss/nss/cache/asyncio.c @@ -35,10 +35,12 @@ | Routines for allocating and managing structures for asynchronous | requests. +-------------------------------------------------------------------------*/ +#include + #include -#include -#include -#include +#include +#include +#include /* * Set up the system pool of async IO control structures @@ -52,7 +54,7 @@ void ASYNCIO_Init (DefaultAsyncio_s *asyncio) static int instance = 0; ASSERT_MPKNSS_LOCK(); - FSM_INIT( &asyncio->io.fsm, asyncio->io.stack, + FSM_INIT( &asyncio->io.fsm, asyncio->io.stack, MAX_IO_FSM_DEPTH, MSGNot("Asyncio"), instance) ++instance; } @@ -63,14 +65,14 @@ STATUS ASYNCIO_Startup (void) ASSERT_MPKNSS_LOCK(); status = CONTROL_Startup( &AsyncioControl, Config.cache.numAsyncios, - sizeof(DefaultAsyncio_s), (voidfunc_t)ASYNCIO_Init); + sizeof(DefaultAsyncio_s), ASYNCIO_Init); if (status != zOK) { return status; } status = CONTROL_Startup( &AsyncioControlRA, Config.cache.numAsyncios, - sizeof(DefaultAsyncio_s), (voidfunc_t)ASYNCIO_Init); - + sizeof(DefaultAsyncio_s), ASYNCIO_Init); + return status; } @@ -129,7 +131,7 @@ void LB_freeAsyncio (Asyncio_s *asyncio) #if NSS_DEBUG IS_ENABLED zASSERT(asyncio->fsm.sp[-1] == FSM_STACK_BOUNDARY); - asyncio->mycache = NULL; + asyncio->mycache = NULL; #endif CONTROL_FREE(asyncio); } @@ -140,7 +142,7 @@ void LB_freeAsyncioRA (Asyncio_s *asyncio) #if NSS_DEBUG IS_ENABLED zASSERT(asyncio->fsm.sp[-1] == FSM_STACK_BOUNDARY); - asyncio->mycache = NULL; + asyncio->mycache = NULL; #endif CONTROL_FREE(asyncio); } diff --git a/src/nwnss/nss/cache/bond.c b/src/nwnss/nss/cache/bond.c index 82616da..0ba59e9 100644 --- a/src/nwnss/nss/cache/bond.c +++ b/src/nwnss/nss/cache/bond.c @@ -33,10 +33,12 @@ |--------------------------------------------------------------------------- | This module is used to: +-------------------------------------------------------------------------*/ +#include + #include #include -#include -#include +#include +#include ControlStore_s BondControl; /* Structure for Controlling allocation and * tracking of bond strucutures. @@ -58,7 +60,7 @@ void BOND_Shutdown (void) } /************************************************************************** - * + * * Agent 'toSignal' is dependent on 'toFlush' occuring(written) first. So * a good way to remember the relationships recorded by this function is * that AGENT @@ -92,15 +94,15 @@ void LB_bind (Agent_s *toSignal, Agent_s *toFlush) ///************************************************************************** -// * +// * // ***************************************************************************/ //void initBind (Bond_s *bond, Agent_s *toSignal, Agent_s *toFlush) //{ // zASSERT(bond != NULL); // -// bond->toSignal = toSignal; -// bond->toFlush = toFlush; -// STK_PUSH(toFlush->signalList, bond, signalLink); +// bond->toSignal = toSignal; +// bond->toFlush = toFlush; +// STK_PUSH(toFlush->signalList, bond, signalLink); // DQ_ENQ( &toSignal->flushList, bond, flushLink); //} @@ -115,13 +117,13 @@ void freeBond (Bond_s *bond) zASSERT(!QMEMBER( &bond->flushLink)); // zASSERT((bond->toFlush == NULL) || DQ_EMPTY( &bond->toFlush->flushList)); // zASSERT((bond->toFlush == NULL) || (bond->toFlush->numLeft == 0)); - + CONTROL_FREE(bond); RTN_VOID(); } /************************************************************************** - * + * ***************************************************************************/ void initAgent ( Agent_s *agent, @@ -136,11 +138,11 @@ void initAgent ( FSMLITE_INIT( &agent->fsm, name, instance); INIT_LATCH( &agent->latch); INIT_ONESHOT(agent->timer); - STK_INIT(agent->signalList); - DQ_INIT( &agent->flushList); - agent->signal = (signal) ? signal : defaultSignal; + STK_INIT(agent->signalList); + DQ_INIT( &agent->flushList); + agent->signal = (signal) ? signal : defaultSignal; agent->numLeft = 0; - agent->state = 0; + agent->state = 0; agent->status = zOK; agent->bondFreedSignal = NULL; return; @@ -162,7 +164,7 @@ void LB_defaultSignal(Agent_s *agent) // I'm removing the NO_BONDS assert, because if the agent is a beast then, // it is possible that we are doing a cacheFlushMyCacheBufs (which will be // followed by a defaultFlush), and new bonds are being put on the beast. -// The defaultFlush that will happen after will take care of the new +// The defaultFlush that will happen after will take care of the new // bonds. We could get around this whole thing by X_LATCHING the beast // while in cacheFlushMyCacheBufs. But at this point we do not want to // take the risk of making that change. Vandana - 11/21/00 @@ -280,7 +282,7 @@ void LB_lazyFlush (Agent_s *agent) * clean ourself up. */ defaultFlush(agent); - } + } else { ASSERT_NOLATCH( &agent->latch); @@ -299,7 +301,7 @@ void LB_lazyFlush (Agent_s *agent) *=========================================================================*/ /************************************************************************** - * + * ***************************************************************************/ void prDepth (NINT depth) { @@ -312,7 +314,7 @@ void prDepth (NINT depth) } /************************************************************************** - * + * ***************************************************************************/ void prSignals (Agent_s *agent, NINT depth) { @@ -327,7 +329,7 @@ void prSignals (Agent_s *agent, NINT depth) } /************************************************************************** - * + * ***************************************************************************/ void prFlushes (Agent_s *agent, NINT depth) { @@ -342,7 +344,7 @@ void prFlushes (Agent_s *agent, NINT depth) } /************************************************************************** - * + * ***************************************************************************/ void prBondControl (Agent_s *agent) { diff --git a/src/nwnss/nss/cache/cache.c b/src/nwnss/nss/cache/cache.c index 201c5ab..0f566b6 100644 --- a/src/nwnss/nss/cache/cache.c +++ b/src/nwnss/nss/cache/cache.c @@ -1,569 +1,3905 @@ /**************************************************************************** | | (C) Copyright 1995-1998,2007 Novell, Inc. - | All Rights Reserved. + | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. | - |------------------------------------------------------------------------- + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | - | Userspace port note: - | This file is derived from public_core/nss/cache/cache.c. The Linux - | kernel page-cache and disk I/O portions are intentionally not enabled in - | mars-nwe: the imported xCache runtime is used as a library substrate for - | NSS semantics, while persistence is provided by Mars/NWFS adapters. + |*************************************************************************** | + | NetWare Advance File Services (NSS) Initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2008-02-07 00:03:59 +0530 (Thu, 07 Feb 2008) $ + | + | $RCSfile$ + | $Revision: 2282 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Implements the caching layer. +-------------------------------------------------------------------------*/ +#include +#include +#include -#if defined(NSS_USERSPACE) -/* - * cache.c is a Mars userspace cache-runtime boundary. The original Linux NSS - * source includes as the NSS internal header, but this file also - * contains a local userspace page-buffer carrier backed by host - * posix_memalign(). Keep that host prototype local to this boundary shim and - * leave the following include on the original NSS path. - */ -#include -#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "inst.h" +#include "fsm.h" +#include "pssDebug.h" +#include "latch.h" +#include "pssmpk.h" +#include "bitmap.h" -CIRhead_t WaitForCacheQ; -Latch_s ReserveBuffers; -Latch_s ReserveResource; -Buffer_s CACHE_SparseBuffer; -CacheControl_s Cache = {0}; +#include "pssConfig.h" +#include "cacheControl.h" -LONG LinuxPages = 0; -CIRhead_t LinuxWaitQ; -LONG TotalBuffer_s = 0; -LONG MaxBuffer_s = 1350000; +#include "nssDebug.h" + +LONG LinuxPages = 0; +CIRhead_t LinuxWaitQ; +LONG TotalBuffer_s = 0; +/* Setting a value, but in reality will be recalculated */ +LONG MaxBuffer_s = 1350000; + +static BOOL MinCacheBuffersSetUI = FALSE; + +/* Setting a value, but in reality will be recalculated */ +/* Number of dirty or bonded user pages. */ LONG NumPagesToWait = 30000; -unsigned long NSSPrivateBufferPtr; +/* Set up a dummy buffer_s address to use as a key in the page->private that + * buffer_s has been reused. + */ +unsigned long NSSPrivateBufferPtr; const Buffer_s *NSSPrivateBuffer = (Buffer_s *)&NSSPrivateBufferPtr; -static BOOL cacheStarted = FALSE; - -void CACHE_LinuxStatsUpdate(BOOL user, NINT mode, BOOL missLinux) +static inline void *kmap_low_mem (struct page *page) { - if (mode == CACHE_WRITE) - { + if (PageHighMem(page)) { + BUG(); + } + return page_address(page); +} + +/* + cacheStatsUpdate() - + Update our global cache stats. These can be viewed via 'nss /cachestat' + or the _admin/Manage_NSS/BufferCache.xml file. + + BEWARE that the stat items with 'UserSystem' tracks BOTH user and system blocks. + */ +static inline void cacheStatsUpdate( BOOL user, NINT mode ) +{ + if ( mode == CACHE_WRITE ) { return; } - if (missLinux) - { - Inst.cache.ioMissLinuxUserSystem++; - if (!user) - { - Inst.cache.ioMissLinuxSystem++; - } - } - else - { - Inst.cache.ioHitLinuxUserSystem++; - if (!user) - { - Inst.cache.ioHitLinuxSystem++; - } - } + Inst.cache.ioMissUserSystem++; /* Tracks BOTH user and system blocks */ + if ( !user ) { + Inst.cache.ioMissSystem++; + } } -void changeCacheBuffers(void) +void CACHE_LinuxStatsUpdate( BOOL user, NINT mode, BOOL missLinux ) { - Cache.oldNumBuffers = Config.cache.numBuffers; + if ( mode == CACHE_WRITE ) { + return; + } + if (missLinux) { + Inst.cache.ioMissLinuxUserSystem++; + if ( !user ) { + Inst.cache.ioMissLinuxSystem++; + } + } else { + Inst.cache.ioHitLinuxUserSystem++; + if (!user) { + Inst.cache.ioHitLinuxSystem++; + } + } + return; +} +EXPORT_SYMBOL(CACHE_LinuxStatsUpdate); + +#define FREE_PAGE(_buffer) \ +{ \ + if (!(_buffer->state & CACHE_HAS_LINUX_PAGE) && \ + (buffer->b_page)) \ + { \ + MPKNSS_UNLOCK(); \ + if (_buffer->pBuf.data != NULL) \ + kunmap(_buffer->b_page); \ + __free_page(_buffer->b_page); \ + MPKNSS_LOCK(); \ + } \ } -static void *cacheAllocBufferData(size_t size) +#define HASH_RMV(_buf) \ +{ \ + if (QMEMBER( &((_buf)->hashLink))) \ + { \ + DQ_RMV(_buf, hashLink); \ + } \ +} + +#define NUM_BUF_S_ALLOC (PAGE_SIZE/sizeof(Buffer_s)) + +/* + * FixFixFix move back to inlines.h but we have to check all calls to + * routines that paly with enabling/disabling interrupts. + */ +#define ENABLE_INTS() + +STATUS addACacheBuffer(Buffer_s *buf); + +void WORK_Schedule_HIGH(FsmLite_s *fsm, voidfunc_t action, ADDR parameter); // FixFixFix - From work.c + + +typedef struct CacheWait_s { - void *data = NULL; + FsmLite_s fsm; + ADDR thread; +} CacheWait_s; - if (posix_memalign(&data, PAGE_SIZE, size) != 0) - { - return NULL; - } - return data; -} - -static void initBuffer(Buffer_s *buffer, MyCache_s *mycache, Blknum_t fileBlk, - Blknum_t volBlk, AgentSignalFunc_t signal, NINT mode) +typedef struct BufferList_s { - memset(buffer, 0, sizeof(*buffer)); - buffer->pBuf.mycache = mycache; - buffer->pBuf.fileBlk = fileBlk; - buffer->volBlk = volBlk; - buffer->bufSizeShift = mycache ? mycache->bufSizeShift : 12; - buffer->pBuf.data = (BYTE *)cacheAllocBufferData((size_t)1 << buffer->bufSizeShift); - buffer->hashLink.next = buffer->hashLink.prev = NULL; - buffer->lruLink.next = buffer->lruLink.prev = NULL; - buffer->mycacheLink.next = buffer->mycacheLink.prev = NULL; - buffer->signalLink.next = buffer->signalLink.prev = NULL; - initAgent(&buffer->agent, signal, "Buffer"); - buffer->pinned = 1; - if (mode == CACHE_WRITE || mode == CACHE_UPDATE) - { - X_LATCH(&buffer->agent.latch); - } - else - { - S_LATCH(&buffer->agent.latch); - } + STKlink_t bufLink; + Buffer_s buffers[1]; +} BufferList_s; + + +CacheControl_s Cache = { 0 }; +Buffer_s CACHE_SparseBuffer; /* Special buffer for sparse files */ +Latch_s ReserveResource; /* Counting semaphore for reserving buffers */ + +#define MAX_USER_PERCENT() (Config.cache.userPages >= \ + ((Config.cache.numPagesAllocated - Cache.control - Cache.slabbed) * \ + Config.cache.percentUserPages / 100)) + +#define CACHE_PERCENT_AVAILABLE(_pAvail) \ + _pAvail = ((SNINT)( Config.cache.numPagesAllocated - \ + Cache.control - Cache.slabbed ) <= 0 ) ? 0 : \ + (Cache.available * 100) / \ + ( Config.cache.numPagesAllocated - \ + Cache.control - Cache.slabbed ); + + +Buffer_s *cacheAllocBufferForCopy ( + MyCache_s *mycache, + Blknum_t fileBlk, + Blknum_t volBlk, + AgentSignalFunc_t signal, + BOOL userBuffer, + NINT mode); + +STATUS RemoveCacheBuffers(NINT numBuffers); + +static void checkGiveCache(void); +static void checkTakeCache(void); + +static void *cacheRequestPage(void); + +//#define LRU_EMPTY() DQ_EMPTY( &Cache.lruQ) +#define LRU_MEMBER(_buf) QMEMBER( &((_buf)->lruLink)) + +#define LRU_ENQ(_buf) LruEnq(_buf); + +static void LruEnq(Buffer_s *buffer) +{ + ENTER(TCACHE, LruEnq); + buffer->timeStamp = Ticks; +// if (buffer->pBuf.data != NULL) +// { +// kunmap(buffer->b_page); +// buffer->pBuf.data = NULL; +// } + zASSERT(buffer->b_page != NULL); + if (buffer->state & CACHE_DIRTY) + { + DQ_ENQ( &Cache.lruQDirty, buffer, lruLink); + } + else if (HAVE_BONDS(&buffer->agent)) + { + DQ_ENQ( &Cache.lruQBonded, buffer, lruLink); + } + else + { + if (buffer->state & CACHE_USER_BUFFER) + { + DQ_ENQ( &Cache.lruQAvailUser, buffer, lruLink); + } + else + { + DQ_ENQ( &Cache.lruQAvailMetaData, buffer, lruLink); + } + ++Cache.available; + } + FSM_READYALL(Cache.waitQ); + return; } +NINT gEnqAvailDirty = 0; +NINT gEnqAvailHasBonds = 0; + +#define LRU_ENQ_AVAIL(_buf) LruEnqAvail(_buf); + +static void LruEnqAvail(Buffer_s *buffer) +{ + ENTER(TCACHE, LruEnqAvail); + buffer->timeStamp = Ticks; +// if (buffer->pBuf.data != NULL) +// { +// kunmap(buffer->b_page); +// buffer->pBuf.data = NULL; +// } + zASSERT(buffer->b_page != NULL); + if (buffer->state & CACHE_DIRTY) + { + /* This should never be TRUE when Enq Avail*/ + zASSERT(!(buffer->state & CACHE_DIRTY)); +gEnqAvailDirty++; + DQ_ENQ( &Cache.lruQDirty, buffer, lruLink); + } + else if (HAVE_BONDS(&buffer->agent)) + { + /* This should never be TRUE when Enq Avail*/ + zASSERT(!HAVE_BONDS(&buffer->agent)); +gEnqAvailHasBonds++; + DQ_ENQ( &Cache.lruQBonded, buffer, lruLink); + } + else + { + if (buffer->state & CACHE_USER_BUFFER) + { + Config.cache.userPages--; + buffer->state &= ~CACHE_USER_BUFFER; + } + DQ_ENQ( &Cache.lruQAvail, buffer, lruLink); + + ++Cache.available; + } + FSM_READYALL(Cache.waitQ); + return; +} + +#define LRU_ENQ_LNX(_buf) LruEnqLnx(_buf); + +static void LruEnqLnx(Buffer_s *buffer) +{ + ENTER(TCACHE, LruEnqLnx); + buffer->timeStamp = Ticks; +// if (buffer->pBuf.data != NULL) +// { +// kunmap(buffer->b_page); +// buffer->pBuf.data = NULL; +// } + if (buffer->state & CACHE_DIRTY) + { + DQ_ENQ( &Cache.lruQDirty, buffer, lruLink); + } + else if (HAVE_BONDS(&buffer->agent)) + { + DQ_ENQ( &Cache.lruQBonded, buffer, lruLink); + } + else + { + if (buffer->b_page) + { + if (!(buffer->state & CACHE_STATE_INVALID)) + { + if (buffer->state & CACHE_VICTIM) + { + if (buffer->b_page->private == (ADDR)buffer) + { + buffer->b_page->private = (ADDR)NSSPrivateBuffer; + buffer->state |= CACHE_STATE_INVALID; + } + else + { + printk("<1> page private and buffer do not match\n"); + } + } + else + { + mark_page_accessed(buffer->b_page); + } + } + + page_cache_release(buffer->b_page); + LinuxPages--; + if (buffer->state & CACHE_STATE_INVALID) + { + retBuffer_s(buffer); + FSM_READYALL(LinuxWaitQ); + return; + } + buffer->b_page = NULL; + buffer->state &= ~CACHE_HAS_LINUX_PAGE; + } + DQ_ENQ( &Cache.lruQNoLinuxPages, buffer, lruLink); + FSM_READYALL(LinuxWaitQ); + } + return; +} + +#define LRU_DEQ(_buf) ((_buf) = LruDeq()); + +static Buffer_s *LruDeq(void) +{ + Buffer_s *buf, *buf1, *buf2; + + ENTER(TCACHE, LruDeq); + DQ_DEQ( &Cache.lruQAvail, buf, Buffer_s, lruLink); + if ((buf == NULL) && (MAX_USER_PERCENT())) + { + DQ_DEQ( &Cache.lruQAvailUser, buf, Buffer_s, lruLink); + if (buf != NULL) + { + Config.cache.userPages--; + } + } + if (buf == NULL) + { + DQ_PEEK( &Cache.lruQAvailUser, buf1, Buffer_s, lruLink); + DQ_PEEK( &Cache.lruQAvailMetaData, buf2, Buffer_s, lruLink); + if ((buf1 != NULL) && (buf2 != NULL)) + { + if (buf1->timeStamp < buf2->timeStamp) + { + DQ_DEQ( &Cache.lruQAvailUser, buf, Buffer_s, lruLink); + Config.cache.userPages--; + } + else + { + DQ_DEQ( &Cache.lruQAvailMetaData, buf, Buffer_s, lruLink); + } + } + else if (buf1 != NULL) + { + DQ_DEQ( &Cache.lruQAvailUser, buf, Buffer_s, lruLink); + Config.cache.userPages--; + } + else if (buf2 != NULL) + { + DQ_DEQ( &Cache.lruQAvailMetaData, buf, Buffer_s, lruLink); + } + else + { + buf = NULL; + } + } + + if (buf != NULL) + { + --Cache.available; +// zASSERT(buf->pBuf.data == NULL); + zASSERT(buf->b_page != NULL); +// buf->pBuf.data = kmap_low_mem(buf->b_page); + zASSERT(buf->pBuf.data != NULL); + } + return buf; +} + +#define LRU_DEQ_USER(_buf) ((_buf) = LruDeqUser()); + +static Buffer_s *LruDeqUser(void) +{ + Buffer_s *buf; + + ENTER(TCACHE, LruDeqUser); + DQ_DEQ( &Cache.lruQAvailUser, buf, Buffer_s, lruLink); + if (buf != NULL) + { + Config.cache.userPages--; + --Cache.available; +// zASSERT(buf->pBuf.data == NULL); + zASSERT(buf->b_page != NULL); +// buf->pBuf.data = kmap_low_mem(buf->b_page); + zASSERT(buf->pBuf.data != NULL); + } + return buf; +} + +#define LRU_DEQ_LNX(_buf) ((_buf) = LruDeqLnx()); + +static Buffer_s *LruDeqLnx(void) +{ + Buffer_s *buf; + RootBeast_s *beast; + struct page *page; + + ENTER(TCACHE, LruDeqLnx); +tryAgain: + DQ_DEQ( &Cache.lruQNoLinuxPages, buf, Buffer_s, lruLink); + if (buf != NULL) + { + MYCACHE_RMV(buf); + HASH_RMV(buf); + if (buf->pBuf.mycache != NULL && (ADDR)buf->pBuf.mycache != 0xbeadfade) + { + beast = STRUCT(buf->pBuf.mycache, RootBeast_s, mycache); + page = find_get_page(beast->rb_inode->i_mapping, buf->pBuf.fileBlk); + if (page == NULL) + { + return buf; + } + page->private = (unsigned long)NSSPrivateBuffer; + page_cache_release(page); + } + else + { + printk("<1>Found a buffer on lruQNoLinuxPages that is a victim\n"); + goto tryAgain; + } + } +//printk("<1> Return from LRU_DEQ_LNX = %x\n", buf); + return buf; +} + +#define LRU_RMV(_buf) LruRmv(_buf) + +static void LruRmv(Buffer_s *buf) +{ + ENTER(TCACHE, LruRmv); + if ((buf->b_page) && !(buf->state & CACHE_HAS_LINUX_PAGE)) + { + --Cache.available; +// if (buf->pBuf.data == NULL) +// { +// buf->pBuf.data = kmap_low_mem(buf->b_page); +// } + } + if (LRU_MEMBER(buf)) + { + DQ_RMV(buf, lruLink); + } +} + + +#define LRU_NEXT(_buf) ONEXT(_buf, Buffer_s, lruLink) +#define LRU_PREV(_buf) OPREV(_buf, Buffer_s, lruLink) +#define LRU_SCAN_BONDED(_buf) \ + DQ_FOREACH( &Cache.lruQBonded, _buf, Buffer_s, lruLink) +#define LRU_SCAN_DIRTY(_buf) \ + DQ_FOREACH( &Cache.lruQDirty, _buf, Buffer_s, lruLink) +#define LRU_SCAN_AVAIL(_buf) \ + DQ_FOREACH( &Cache.lruQAvail, _buf, Buffer_s, lruLink) +#define LRU_SCAN_AVAIL_USER(_buf) \ + DQ_FOREACH( &Cache.lruQAvailUser, _buf, Buffer_s, lruLink) +#define LRU_SCAN_AVAIL_METADATA(_buf) \ + DQ_FOREACH( &Cache.lruQAvailMetaData, _buf, Buffer_s, lruLink) + + +static void takerSleep (NINT ticks) +{ + if (!ONESHOT_SET(Cache.taker.alarm)) + { + setOneShot( &Cache.taker.alarm, ticks, checkTakeCache); + } +} + +static void giverSleep (NINT ticks) +{ + if (!ONESHOT_SET(Cache.giver.alarm)) + { + setOneShot( &Cache.giver.alarm, ticks, checkGiveCache); + } +} + + /* + * allocBuffer_s allocates the given number of Buffer_s structures. + * It puts the memory on a linked list to be freed when the system + * is shutdown. All the buffers allocated are put the Cache.noPageBufs + * free list. + */ +static Buffer_s *allocBuffer_s (NINT numBuffers) +{ + BufferList_s *bufferList; + Buffer_s *buf; + NINT i; + + bufferList = zalloc(sizeof(BufferList_s) + + ((numBuffers - 1) * sizeof(Buffer_s))); + if (bufferList == NULL) + { + return NULL; + } + STK_PUSH(Cache.bufLists, bufferList, bufLink); + for (i = 0; i < numBuffers; ++i) + { + STK_PUSH(Cache.noPageBufs, &bufferList->buffers[i], lruLink); + } + STK_POP(Cache.noPageBufs, buf, Buffer_s, lruLink); + TotalBuffer_s+=numBuffers; + return buf; +} + + /* + * numBufsToGive returns the number of cache buffers NSS could give + * back the OS at this instance. A 0 or negative number indicates + * we can't give any pages back. We never let the number of cache + * buffers drop below MIN_NUM_BUFFERS. + */ +static SNINT numBufsToGive (void) +{ + SNINT extraOSbufs; + SNINT extraNSSbufs; + SNINT percent; + + if (NUM_RESOURCES() < MIN_NUM_BUFFERS) + { + return 0; + } + if (Config.cache.numPagesAllocated < MIN_NUM_BUFFERS) + { + return 0; + } + extraOSbufs = CurrentNumberOfCacheBuffers - Config.cache.minOSFree; + if (extraOSbufs < 0) + { + return -extraOSbufs; + } + extraNSSbufs = Config.cache.numPagesAllocated - Config.cache.numBuffers; + if (extraNSSbufs < 0) + { + return extraNSSbufs; + } + if (Config.cache.usePercentMemory) + { + percent = PERCENT_OF_OS_BUFS(extraNSSbufs + extraOSbufs); + return extraNSSbufs - percent; + } + else + { + return extraNSSbufs; + } +} + + /* + * numBufsToTake returns the number of cache buffers NSS could + * return to the OS at this instance. If the "giver" is curretly + * running. We can't take memory so return 0. Only a positive + * number indicates we can take more memory. + */ +static SNINT numBufsToTake (void) +{ + SNINT extraOSbufs; + SNINT extraNSSbufs; + SNINT percent; + + if (Cache.giver.isRunning) + { + return 0; + } + extraOSbufs = CurrentNumberOfCacheBuffers - Config.cache.minOSFree; + if (extraOSbufs < 0) + { + return extraOSbufs; + } + extraNSSbufs = Config.cache.numPagesAllocated - Cache.control + - Cache.slabbed - Config.cache.numBuffers; + if (extraNSSbufs < 0) + { + if (Config.cache.usePercentMemory) + { + percent = PERCENT_OF_OS_BUFS(extraOSbufs + extraNSSbufs); + return percent - extraNSSbufs; + } + else + { + return -extraNSSbufs; + } + } + if (Config.cache.usePercentMemory) + { + percent = PERCENT_OF_OS_BUFS(extraNSSbufs + extraOSbufs); + return percent - extraNSSbufs; + } + else + { + return -extraNSSbufs; + } +} + + /* + * giveCache is called from a thread to actually give memory back + * to the system. Since this can block, giveCache must be run + * from a Work-to-do or other thread that allows blocking (not + * a fast Work-to-do). + */ +static void giveCache (void) +{ + SNINT numBufs; + + CANCEL_ALARM(Cache.giver.alarm); + numBufs = numBufsToGive(); + if (numBufs > 0) + { + RemoveCacheBuffers(numBufs); + } + if (Config.cache.usePercentMemory) + { + giverSleep(1); + } + Cache.giver.isRunning = FALSE; + return; +} + + + /* + * takeCache takes cache buffers from the OS until numBufsToTake + * says we can't take any more by returning a 0 or negative number. + * numBufsToTake is checked during each iteration and if we allocate + * more Buffer_s structures. + */ +static STATUS takeCache (void) +{ + Buffer_s *buf; + SNINT numBufs; + STATUS status = zOK; + Seq_t startTime = Ticks; + enum { TICKS_TO_RUN = 2, TICKS_TO_WAIT = 4 }; + + ENABLE_INTS(); + + CANCEL_ALARM(Cache.taker.alarm); + for (;;) + { + zASSERT(!QMEMBER(&Cache.taker.fsm.link)); + if (Cache.giver.isRunning) + { + break; + } + numBufs = numBufsToTake(); + if (numBufs <= 0) + { + break; + } + if ((Ticks > startTime + TICKS_TO_RUN) && + (Config.cache.numPagesAllocated > MIN_NUM_BUFFERS)) + { + takerSleep(TICKS_TO_WAIT); + Cache.taker.isRunning = FALSE; + return zOK; + } + STK_POP(Cache.noPageBufs, buf, Buffer_s, lruLink); + if (buf == NULL) + { + buf = allocBuffer_s(numBufs); + if (buf == NULL) + { + status = zERR_NO_MEMORY; + break; + } + if (numBufsToTake() <= 0) + { + STK_PUSH(Cache.noPageBufs, buf, lruLink); + break; + } + } + if (addACacheBuffer(buf) != zOK) + { + STK_PUSH(Cache.noPageBufs, buf, lruLink); + status = zERR_NO_MEMORY; + break; + } + } + zASSERT(!QMEMBER(&Cache.taker.fsm.link)); + if (Config.cache.usePercentMemory) + { + takerSleep(SEC2TICK(Config.cache.balanceTimerSecs)); + } + Cache.taker.isRunning = FALSE; + return status; +} + +static void takeCache2( void ) +{ + (void)takeCache(); +} + + +/************************************************************************** + * checkGiveCache and checkTakecache conditionally schedule a work-to-do + * to handle the reallocation of resources. We have to set up a regular + * work-to-do so we can block. + ***************************************************************************/ + + /* + * checkGiveCache checks if NSS can give cache buffers back to the OS. + * It is called by the alarm pop code and is scheduled every clock tick. + * If NSS needs to give cache buffers back to the OS, giveCache is + * scheduled to run on a worker thread. + * + * checkGiveCache only runs if we have turned on cache balancing. + */ +static void checkGiveCache (void) +{ + if (Cache.giver.isRunning) + { + return; + } + if (numBufsToGive() > 0) + { + Cache.giver.isRunning = TRUE; + WORK_Schedule_HIGH( &Cache.giver.fsm, giveCache, 0); + } + else + { + giverSleep(1); + } +} + + /* + * checkTakeCache is called periodically (determined by the cache + * balance timer) to see if we can take more cache buffers from + * the OS. We only take if the number of cache buffers we can + * get is greater than the CACHE_HYSTERESIS which is currenly set + * at 256 or 1 Meg of memory. + * + * checkTakeCache only runs if we have turned on cache balancing. + */ +static void checkTakeCache (void) +{ + if (Cache.taker.isRunning) + { + return; + } + zASSERT(!QMEMBER(&Cache.taker.fsm.link)); + if (numBufsToTake() > CACHE_HYSTERESIS) + { + Cache.taker.isRunning = TRUE; + WORK_Schedule( &Cache.taker.fsm, takeCache2, 0); + } + else + { + takerSleep(SEC2TICK(Config.cache.balanceTimerSecs)); + } +} + + /* + * SetupForCacheChange is called during initialization to set things up + * for cache balancing. + */ +void SetupForCacheChange() {} + +/************************************************************************** + * + ***************************************************************************/ +void SPARSE_Shutdown (void) +{ + ASSERT_MPKNSS_LOCK(); + UNS_LATCH(&CACHE_SparseBuffer.agent.latch); + if (CACHE_SparseBuffer.pBuf.data != NULL) + { + freePage(CACHE_SparseBuffer.pBuf.data, 1); + } +} + +/************************************************************************** + * + ***************************************************************************/ +void BUFFERS_Shutdown (void) +{ + BufferList_s *bufferList; + + ASSERT_MPKNSS_LOCK(); + while(STK_NOT_EMPTY(Cache.bufLists)) + { + STK_POP_NO_CHECK(Cache.bufLists, bufferList, BufferList_s, bufLink); + free(bufferList); + } +} + +/************************************************************************** + * + ***************************************************************************/ +void PAGES_Shutdown (void) +{ + Buffer_s *buffer; + ASSERT_MPKNSS_LOCK(); + + LRU_SCAN_AVAIL(buffer) + { + zASSERT(buffer->pBuf.data != NULL); + + FREE_PAGE(buffer); + PERIODIC_YIELD(); + } + LRU_SCAN_AVAIL_USER(buffer) + { + zASSERT(buffer->pBuf.data != NULL); + + FREE_PAGE(buffer); + PERIODIC_YIELD(); + } + LRU_SCAN_AVAIL_METADATA(buffer) + { + zASSERT(buffer->pBuf.data != NULL); + + FREE_PAGE(buffer); + PERIODIC_YIELD(); + } + LRU_SCAN_DIRTY(buffer) + { + zASSERT(buffer->pBuf.data != NULL); + + FREE_PAGE(buffer); + PERIODIC_YIELD(); + } + LRU_SCAN_BONDED(buffer) + { + zASSERT(buffer->pBuf.data != NULL); + + FREE_PAGE(buffer); + PERIODIC_YIELD(); + } +} + +/************************************************************************** + * + ***************************************************************************/ +void HASH_Shutdown (void) +{ + free(Cache.bucket); +} + + +/************************************************************************** + * + ***************************************************************************/ +void BALANCE_Shutdown (void) +{ + ASSERT_MPKNSS_LOCK(); + CANCEL_ALARM(Cache.giver.alarm); /* Cancel Cache giver */ + CANCEL_ALARM(Cache.taker.alarm); /* Cancel Cache taker */ +} + + /* + * addACacheBuffer gets a page for a single Buffer_s structure. + * It the resouce reservation adn numPagesAllocated. It also + * makes sure we periodically yield so we don't hog the processor. + */ +STATUS addACacheBuffer (Buffer_s *buf) +{ + initAgent( &buf->agent, defaultSignal, MSGNot("Buffer")); + buf->state = CACHE_CLEAR; + /* I am using GFP_USER for now instead of GFP_HIGHUSER. If I use + * GFP_HIGHUSER, then the number of kmaps are limited for the high pages, + * and kmap can sleep, so I need to unlock the mpknss spinlock and + * I cannot call the kmap and kunmap from the LRU code like I do now. + */ + MPKNSS_UNLOCK(); + buf->b_page = alloc_page(GFP_USER); + MPKNSS_LOCK(); + buf->bufSizeShift = PAGE_SHIFT; + if (buf->b_page == NULL) + { + printk("<1> Error return from addACacheBuffer\n"); + return zFAILURE; + } + /* June 2007: Because we use GFP_USER, it guarantees that the page + * is in low memory and page_address will give us the virtual mapping + * for it, without doing a kmap. This change is to facilitate debugging + * and instead of keeping data pointer NULL, it will now always be + * filled for the cache pages maintained by NSS. We use high memory + * for data and metadata through different methods, and this list + * of cache buffers always has low memory pages, hence I can keep it + * mapped. + */ + buf->pBuf.data = kmap_low_mem(buf->b_page); + + LRU_ENQ_AVAIL(buf); + ++Config.cache.numPagesAllocated; + INC_RSRC_CHECK(1); + + PERIODIC_YIELD(); + + return zOK; +} + +/************************************************************************** + * + ***************************************************************************/ + +STATUS RemoveCacheBuffers (NINT numBuffers) +{ + NINT i; + BYTE *page; + + ASSERT_MPKNSS_LOCK(); + + for (i = 0; i < numBuffers; i++) + { + page = cacheRequestPage(); + if (page == NULL) + { + break; + } + MPKNSS_UNLOCK(); + __free_page((struct page *)page); + MPKNSS_LOCK(); + PERIODIC_YIELD(); + if (NUM_RESOURCES() < MIN_NUM_BUFFERS) + { + break; + } + } + return zOK; +} + + /* + * changeCacheBuffers can be called from the nss command interface + * at run time to change the minimum number of cache buffers NSS trys + * to keep. + */ +void changeCacheBuffers (void) +{ + /* + * We do nothing if called from the nss startup command line. + */ + if (!Cache.isInitialized) + { + MinCacheBuffersSetUI = TRUE; + return; + } + /* + * When this routine is called, numBuffers has been set. + */ + if (Config.cache.numBuffers < Config.cache.numPagesAllocated) + { + checkGiveCache(); + } + else + { +// zASSERT(!QMEMBER(&Cache.taker.fsm.link)); + checkTakeCache(); + } +} + + +static void cache_workqueue_init(void); + +/************************************************************************** + * Allocate all of the memory for the CACHE system + ***************************************************************************/ STATUS CACHE_Startup(void) { - STATUS status; + NINT i; + struct sysinfo si; - ASSERT_MPKNSS_LOCK(); - if (cacheStarted) - { - return zOK; - } + ENTER(TCACHE, CACHE_Startup); + ASSERT_MPKNSS_LOCK(); - DQ_INIT(&Cache.lruQDirty); - DQ_INIT(&Cache.lruQBonded); - DQ_INIT(&Cache.lruQAvail); - DQ_INIT(&Cache.lruQAvailUser); - DQ_INIT(&Cache.lruQAvailMetaData); - DQ_INIT(&Cache.lruQNoLinuxPages); - DQ_INIT(&Cache.lruQMetadataPage); - STK_INIT(Cache.bufLists); - STK_INIT(Cache.noPageBufs); - STK_INIT(Cache.freePageBuffers); - CIR_INIT(WaitForCacheQ); - CIR_INIT(LinuxWaitQ); - CIR_INIT(Cache.waitQ); - INIT_LATCH(&ReserveBuffers); - INIT_COUNT(&ReserveResource, -PRERESERVE_FOR_BEAST_FLUSH); + Cache.oldNumBuffers = Config.cache.numBuffers; + CIR_INIT(Cache.waitQ); + CIR_INIT(LinuxWaitQ); + STK_INIT(Cache.bufLists); + STK_INIT(Cache.noPageBufs); + STK_INIT(Cache.freePageBuffers); - memset(&CACHE_SparseBuffer, 0, sizeof(CACHE_SparseBuffer)); - CACHE_SparseBuffer.pBuf.data = NULL; - CACHE_SparseBuffer.pBuf.mycache = NULL; - CACHE_SparseBuffer.state = CACHE_MEMORY_BUFFER | CACHE_DATA_VALID; - CACHE_SparseBuffer.pinned = 1; - initAgent(&CACHE_SparseBuffer.agent, defaultSignal, "SparseBuffer"); + DQ_INIT(&Cache.lruQDirty); + DQ_INIT(&Cache.lruQBonded); + DQ_INIT(&Cache.lruQAvail); + DQ_INIT(&Cache.lruQAvailUser); + DQ_INIT(&Cache.lruQAvailMetaData); + DQ_INIT(&Cache.lruQNoLinuxPages); + DQ_INIT(&Cache.lruQMetadataPage); + + INIT_COUNT(&ReserveResource, -PRERESERVE_FOR_BEAST_FLUSH); + INIT_ONESHOT(Cache.taker.alarm); + INIT_ONESHOT(Cache.giver.alarm); + FSMLITE_INIT( &Cache.taker.fsm, MSGNot("Cache.taker.fsm"), 0); + FSMLITE_INIT( &Cache.giver.fsm, MSGNot("Cache.giver.fsm"), 0); + zASSERT(!QMEMBER(&Cache.taker.fsm.link)); - status = BOND_Startup(); - if (status != zOK) - { - return status; - } - status = ASYNCIO_Startup(); - if (status != zOK) - { - BOND_Shutdown(); - return status; - } - status = WORK_Startup(); - if (status != zOK) - { - ASYNCIO_Shutdown(); - BOND_Shutdown(); - return status; - } + INIT_LATCH(&Cache.CC_HMCCacheTypeLatch); + Cache.isInitialized = TRUE; + cache_workqueue_init(); - cacheStarted = TRUE; - return zOK; + /* Once we use highmem also use totalram_pages rather than just low_pages */ + si_meminfo(&si); + if (!MinCacheBuffersSetUI) + { + Config.cache.numBuffers = (si.totalram - si.totalhigh)/7; + } +//TODO(Perf): Are MaxBuffer_s and NumPagesToWait good +#if defined(__i386__) + MaxBuffer_s = (((si.totalram - si.totalhigh)/sizeof(Buffer_s))*4096)/4; + if (MaxBuffer_s > 250000) + { + MaxBuffer_s = 250000; + } +#elif defined(__x86_64__) + /* On a 64-bit machine not limited to 1 Gig Kernel memory */ + MaxBuffer_s = (si.totalram - si.totalhigh); /* Max pages */ +#else +#error Need to define based on the memory available in the kernel +#endif + + printk("<1> MaxBuffer_s = %d\n", MaxBuffer_s); + /* + * allocate and init the CACHE HASH + */ + + Config.cache.hashSize = 1 << (findHighBit(MaxBuffer_s) + 1); + Config.cache.hashMask = Config.cache.hashSize - 1; + + Cache.bucket = zalloc(Config.cache.hashSize * sizeof(DQhead_t)); + if (Cache.bucket == NULL) + { + goto HASH_Failed; + } + if (fsmStart() != zOK) + { + goto FSM_Failed; + } + if (WORK_Startup() != zOK) + { + goto WORK_Failed; + } +#if defined(__i386__) + NumPagesToWait = si.totalram/10; + if (NumPagesToWait > 100000) + { + NumPagesToWait = 100000; + } +#elif defined(__x86_64__) + /* On a 64-bit machine not limited to 1 Gig Kernel memory */ + NumPagesToWait = si.totalram/4; +#else +#error Need to define based on the memory available in the kernel +#endif + printk("<1> NumPagesToWait = %d\n", NumPagesToWait); + + Cache.taker.isRunning = TRUE; + if (takeCache() != zOK) + { + goto PAGES_Failed; + } + /* + * Set up buffer used for reading sparse files + */ + initAgent( &CACHE_SparseBuffer.agent, defaultSignal, MSGNot("SparseBuffer")); + CACHE_SparseBuffer.pBuf.fileBlk = 0; + CACHE_SparseBuffer.pBuf.mycache = NULL; + CACHE_SparseBuffer.volBlk = 0; + CACHE_SparseBuffer.state = CACHE_CLEAR; + CACHE_SparseBuffer.bufSizeShift = PAGE_SHIFT; + CACHE_SparseBuffer.pBuf.data = (BYTE *)zallocPage(1); + if (CACHE_SparseBuffer.pBuf.data == NULL) + { + goto SPARSE_Failed; + } + S_FORCE( &CACHE_SparseBuffer.agent.latch); + + for (i = 0; i < Config.cache.hashSize; ++i) + { + DQ_INIT(&Cache.bucket[i]); + } + if (SLAB_Startup() != zOK) + { + goto SLAB_Failed; + } + if (MSG_Startup() != zOK) + { + goto MSG_Failed; + } + if (BOND_Startup() != zOK) + { + goto BOND_Failed; + } + if (ASYNCIO_Startup() != zOK) + { + goto ASYNCIO_Failed; + } + + if (Config.cache.numPagesAllocated < MIN_NUM_BUFFERS) + { + goto OSMIN_Failed; + } + + if (Config.cache.usePercentMemory) + { + /** To cleanup if anything fails after this call BALANCE_Shutdown **/ + SetupForCacheChange(); + } + initInst(); + + RTN_STATUS(zOK); +/*=========================================================================*/ + +OSMIN_Failed: + ASYNCIO_Shutdown(); +ASYNCIO_Failed: + BOND_Shutdown(); +BOND_Failed: + MSG_Shutdown(); +MSG_Failed: + SLAB_Shutdown(); +SLAB_Failed: + SPARSE_Shutdown(); +SPARSE_Failed: +PAGES_Failed: + PAGES_Shutdown(); + BUFFERS_Shutdown(); + WORK_Shutdown(); +WORK_Failed: + fsmStop(); +FSM_Failed: + HASH_Shutdown(); +HASH_Failed: + RTN_STATUS(zERR_NO_MEMORY); } +/************************************************************************** + * Free all of the CACHE system memory + * CACHE_Shutdown has been designed that it can be called from any + * place in the CACHE_Startup routine if initialization fails. This + * includes the routines that allocate bonds, work-to-do structures, + * and asynio strutures. + ***************************************************************************/ void CACHE_Shutdown(void) { - ASSERT_MPKNSS_LOCK(); - if (!cacheStarted) - { - return; - } + ENTER(TCACHE, CACHE_Shutdown); +// WARN(DQ_EMPTY(&CacheClients)); - WORK_Shutdown(); - ASYNCIO_Shutdown(); - BOND_Shutdown(); - cacheStarted = FALSE; + ASSERT_MPKNSS_LOCK(); + BALANCE_Shutdown(); + + /* + * When we shutdown, we should free resources in the reverse + * order that we aquired them. This is in case there is + * some dependencies. + * Exception: MSG_Shutdown is called first to clean things out. + */ + MSG_Shutdown(); + + ASYNCIO_Shutdown(); + BOND_Shutdown(); + SLAB_Shutdown(); + SPARSE_Shutdown(); + PAGES_Shutdown(); + BUFFERS_Shutdown(); + WORK_Shutdown(); + fsmStop(); + HASH_Shutdown(); + + RTN_VOID(); } -void SetupForCacheChange(void) +/************************************************************************** + * Changed hashing to better support many small files -- which implies + * lot of blocks with logical number 0. + ***************************************************************************/ + +/* Pre April 2007 Hash shipping with NSS */ +//#define HASH(_my, _blk) ((((ADDR)(_my) >> 3) ^ (_blk)) & Config.cache.hashMask) + +/* Hash candidate 1 with extra shift and xor */ +//#define HASH(_my, _blk) (( (((ADDR)(_my) >> 3) ^ ((ADDR)(_my) >> 17)) \ +// ^ (_blk)) & Config.cache.hashMask) + +/* Hash candidate 2 with module op, is slightly slower that 1 */ +//#define HASH(_my, _blk) ((((ADDR)(_my) % 2576767) ^ (_blk)) & Config.cache.hashMask) + +static inline NINT cache_buffer_hash(MyCache_s *mycache, Blknum_t fileBlk) { + return ((((ADDR)mycache % 2576767) ^ fileBlk) & Config.cache.hashMask); } -void SPARSE_Shutdown(void) +Buffer_s *cacheFind ( + MyCache_s *mycache, + Blknum_t fileBlk) { + NINT hashKey; + DQhead_t *head; + Buffer_s *buffer; + + ENTER(TCACHE, cacheFind); + ASSERT_MPKNSS_LOCK(); + hashKey = cache_buffer_hash(mycache, fileBlk); + head = &Cache.bucket[hashKey]; + + DQ_FOREACH(head, buffer, Buffer_s, hashLink) + { + if ( (buffer->pBuf.mycache == mycache) + && (buffer->pBuf.fileBlk == fileBlk)) + { + ++Inst.cache.ioHitUserSystem; + RTN_PTR(buffer); + } + } + RTN_PTR(NULL); } -void BUFFERS_Shutdown(void) +/************************************************************************** + * + ***************************************************************************/ +static void cachePush (Buffer_s *buffer) { + NINT hashKey; + DQhead_t *head; + + ENTER(TCACHE, cachePush); + ASSERT_MPKNSS_LOCK(); + hashKey = cache_buffer_hash(buffer->pBuf.mycache, buffer->pBuf.fileBlk); + head = &Cache.bucket[hashKey]; + DQ_PUSH(head, buffer, hashLink); + + RTN_VOID(); } -void PAGES_Shutdown(void) +/************************************************************************** + * This is the code to do group writes. We group the metadata blocks, + * the journal blocks and the data blocks into separate linked lists. + * Instead of setting the buffer flush timer on them we put them on + * respective lists and call queue_delayed_work. We use separate timers + * for separate lists. When the work is called we defaultFlush the complete + * list of buffers. + * + * Journal: These should go out relatively quickly as a crash means that + * our consistency point is further back in time.. + * Data: On a crash we would lose this many seconds of user data. Hence + * we want to keep the timer on this short also. + * Metadata: Since the journal has already been written, we can set + * the timer on the metadata to be longer. This will allow us + * to group more MD during the writes. We have to ensure this + * list does not get too long: + * 1) The time for redo/undo will increase + * Config.cache.metadataBlocksReadyForGroupWriteLimit is + * checked when we Queue writes to limit this. + * 2) The journal can start throttling + * So in zlog.c we check the blocks in use and flush when + * journal gets a certain percent full to prevent this. + * 3) We run out of available cache buffers + * We use CacheFlushAtAvailPercent to flush when avail + * buffers gets too low. + ***************************************************************************/ + +/* Config.cache.metadataBlocksReadyForGroupWriteLimit + * We limit the max number of metadata blocks that are queued to make sure + * Redo/undo does not become too long. With the worse write times (every + * write is a seek), we can write ~ 200 blocks/sec. On fast writes we can + * ~ 3000 blocks/sec. This equates to a range of 6000 to 90000 blocks + * written in a minute. (And we want to bring a pool back up relatively + * quickly) Using that as a basis I (Vandana) am picking 20000 as the + * limit of the number of metadata blocks queued. + */ + +//TODO(Perf): Command line configurable?? +BOOL CachePercentFlushFlag = FALSE; +LONG CacheFlushAtAvailPercent = 35; + +static struct workqueue_struct *nssio_wq_journal; +static struct workqueue_struct *nssio_wq_metadata; +static struct workqueue_struct *nssio_wq_data; + +static struct work_struct nss_work_journal; +static struct work_struct nss_work_metadata; +static struct work_struct nss_work_data; + +DQhead_t nsswork_list_journal = DQ_STATIC_INIT(nsswork_list_journal); +DQhead_t nsswork_list_metadata = DQ_STATIC_INIT(nsswork_list_metadata); +DQhead_t nsswork_list_data = DQ_STATIC_INIT(nsswork_list_data); + +static inline void cacheUnplugQueue(DQhead_t *ioList) { + Buffer_s *buffer; + DQhead_t ioHead; + + DQ_INIT(&ioHead); + DQ_APPEND(&ioHead, ioList); + + while (1) + { + DQ_DEQ(&ioHead, buffer, Buffer_s, bioReq.br_link); + if (buffer == NULL) + { + break; + } + if (ioList == &nsswork_list_metadata) + { + Config.cache.metadataBlocksReadyForGroupWrite--; + } + defaultFlush(&buffer->agent); + } + return; } -void HASH_Shutdown(void) +static void cacheWorkFlush(void *p) { -} + DQhead_t *ioList = p; -void BALANCE_Shutdown(void) -{ -} + mpkEnter(); + MPKNSS_LOCK(); -void cacheFlushAll(void) -{ -} +// if (ioList == &nsswork_list_metadata) +// { +// printk("<1> Unplugging Metadata Queue on Timer Count = %d\n", +// Config.cache.metadataBlocksReadyForGroupWrite); +// } + cacheUnplugQueue(ioList); + MPKNSS_UNLOCK(); + mpkExit(); +} void cacheFlushMetadataBuffers(void) { - cacheFlushAll(); +// printk("<1> Unplugging metadata queue Count = %d\n", +// Config.cache.metadataBlocksReadyForGroupWrite); + cacheUnplugQueue(&nsswork_list_metadata); +} +EXPORT_SYMBOL(cacheFlushMetadataBuffers); + + +static void checkCachePercentAvail() +{ + NINT percentAvail; + CACHE_PERCENT_AVAILABLE(percentAvail); + + if (!CachePercentFlushFlag && (percentAvail <= CacheFlushAtAvailPercent)) + { +// printk("<1> Cache Avail is less than %d \n", CacheFlushAtAvailPercent); + cacheFlushMetadataBuffers(); + CachePercentFlushFlag = TRUE; + } + else if (CachePercentFlushFlag && (percentAvail > CacheFlushAtAvailPercent)) + { + CachePercentFlushFlag = FALSE; + } } -void cachePrepareToFlush(Buffer_s *buffer) +static void cache_workqueue_init(void) { - (void)buffer; + MPKNSS_UNLOCK(); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) + /* work queue names can't be more than 10 chars long */ + INIT_WORK(&nss_work_data, cacheWorkFlush, &nsswork_list_data); + nssio_wq_data = create_workqueue("data_wq"); + INIT_WORK(&nss_work_metadata, cacheWorkFlush, &nsswork_list_metadata); + nssio_wq_metadata = create_workqueue("meta_wq"); + INIT_WORK(&nss_work_journal, cacheWorkFlush, &nsswork_list_journal); + nssio_wq_journal = create_workqueue("log_wq"); +#else + INIT_WORK(&nss_work_data, cacheWorkFlush, &nsswork_list_data); + nssio_wq_data = create_workqueue("nssdata_wq"); + INIT_WORK(&nss_work_metadata, cacheWorkFlush, &nsswork_list_metadata); + nssio_wq_metadata = create_workqueue("nssmetadata_wq"); + INIT_WORK(&nss_work_journal, cacheWorkFlush, &nsswork_list_journal); + nssio_wq_journal = create_workqueue("nssjournal_wq"); +#endif + MPKNSS_LOCK(); } -void cacheMarkDirty(Buffer_s *buffer) + +/* + Under Linux, we use this routine to cause I/Os to be grouped + together. This is standard practice for Linux FSs. This + replaces the NetWare concept of cacheTimerPop. +*/ +//TODO(Perf): This looks like ZLSS specific code!!!! +static void cacheTimerQueue(Buffer_s *buf) { - if (buffer != NULL) + RootBeast_s *root; + + if (QMEMBER(&buf->bioReq.br_link)) + { + return; + } + root = STRUCT(buf->pBuf.mycache, RootBeast_s, ROOTmycache); +//TODO(Perf): is there a inline/macro for this test? Not in the cache layer!!! + if ( (buf->pBuf.fileBlk < 0) || (buf->volBlk == 0) || (root->zid < 127)) { - buffer->state |= CACHE_DIRTY; - } -} - -void cacheRelease(Buffer_s *buffer) -{ - if (buffer == NULL) - { - return; - } - if (buffer->pinned > 0) - { - buffer->pinned--; - } - UN_LATCH(&buffer->agent.latch); -} - -void cacheReleaseToss(Buffer_s *buffer) -{ - cacheToss(buffer); -} - -void cacheSignalRelease(Buffer_s *buffer) -{ - if (buffer != NULL && buffer->agent.signal != NULL) - { - buffer->agent.signal(&buffer->agent); - } - cacheRelease(buffer); -} - -void cacheSignalReleaseToss(Buffer_s *buffer) -{ - if (buffer != NULL && buffer->agent.signal != NULL) - { - buffer->agent.signal(&buffer->agent); - } - cacheToss(buffer); -} - -void cacheFlush(Buffer_s *buffer) -{ - if (buffer != NULL) - { - buffer->state &= ~CACHE_DIRTY; - } -} - -BOOL cacheUnpinned(Buffer_s *buffer) -{ - return (buffer == NULL || buffer->pinned == 0) ? TRUE : FALSE; -} - -void cacheUnpin(Buffer_s *buffer) -{ - if (buffer != NULL && buffer->pinned > 0) - { - buffer->pinned--; - } -} - -void cacheFlushMyCache(MyCache_s *mycache) -{ - (void)mycache; -} - -void cacheFlushMyCacheBufs(MyCache_s *mycache) -{ - (void)mycache; -} - -static Buffer_s *cacheAllocLocal(MyCache_s *mycache, Blknum_t fileBlk, - Blknum_t volBlk, AgentSignalFunc_t signal, NINT mode) -{ - Buffer_s *buffer = (Buffer_s *)LB_malloc(sizeof(Buffer_s)); - if (buffer == NULL) - { - return NULL; - } - initBuffer(buffer, mycache, fileBlk, volBlk, signal, mode); - if (buffer->pBuf.data == NULL) - { - LB_free(buffer); - return NULL; - } - if (mycache != NULL) - { - DQ_ENQ(&mycache->bufList, buffer, mycacheLink); - } - return buffer; -} - -Buffer_s *cacheAllocBuffer(MyCache_s *mycache, Blknum_t fileBlk, Blknum_t volBlk, - AgentSignalFunc_t signal, NINT mode) -{ - return cacheAllocLocal(mycache, fileBlk, volBlk, signal, mode); -} - -Buffer_s *cacheAllocBufferForUserData(MyCache_s *mycache, Blknum_t fileBlk, - Blknum_t volBlk, AgentSignalFunc_t signal, NINT mode) -{ - Buffer_s *buffer = cacheAllocLocal(mycache, fileBlk, volBlk, signal, mode); - if (buffer != NULL) - { - buffer->state |= CACHE_USER_BUFFER; - } - return buffer; -} - -Buffer_s *cacheAllocBufferForCopy(MyCache_s *mycache, Blknum_t fileBlk, - Blknum_t volBlk, AgentSignalFunc_t signal, BOOL userBuffer, NINT mode) -{ - Buffer_s *buffer = cacheAllocLocal(mycache, fileBlk, volBlk, signal, mode); - if (buffer != NULL && userBuffer) - { - buffer->state |= CACHE_USER_BUFFER; - } - return buffer; -} - -Buffer_s *cacheFind(MyCache_s *mycache, Blknum_t fileBlk) -{ - Buffer_s *buffer; - if (mycache == NULL) - { - return NULL; - } - DQ_FOREACH(&mycache->bufList, buffer, Buffer_s, mycacheLink) - { - if (buffer->pBuf.fileBlk == fileBlk) + if (buf->pBuf.fileBlk < 0) { - return buffer; - } - } - return NULL; -} - -NINT isCached(Asyncio_s *asyncio, voidfunc_t action) -{ - (void)action; - if (asyncio == NULL) - { - return 0; - } - asyncio->buffer = cacheFind(asyncio->mycache, asyncio->fileBlk); - return (asyncio->buffer != NULL) ? 1 : 0; -} - -Buffer_s *cacheLookup(MyCache_s *mycache, Blknum_t fileBlk, NINT mode) -{ - Buffer_s *buffer = cacheFind(mycache, fileBlk); - if (buffer != NULL) - { - CACHE_PIN(buffer); - if (mode == CACHE_READ) - { - S_LATCH(&buffer->agent.latch); + /* Metadata block */ + DQ_ENQ(&nsswork_list_metadata, buf, bioReq.br_link); + Config.cache.metadataBlocksReadyForGroupWrite++; + queue_delayed_work(nssio_wq_metadata, &nss_work_metadata, + Config.sec.metadataGroupWriteTime*HZ); + if (Config.cache.metadataBlocksReadyForGroupWrite >= Config.cache.metadataBlocksReadyForGroupWriteLimit) + { +// printk("<1> Config.cache.metadataBlocksReadyForGroupWrite is %d\n", +// Config.cache.metadataBlocksReadyForGroupWrite); + cacheFlushMetadataBuffers(); + } } else - { - X_LATCH(&buffer->agent.latch); + { /* Journal block */ + /* Journal blocks are really driven to disk by the Barrier + logic (ZlssBarrier_s) in ZLSS. We still use the + nsswork_list_journal just in case some journal blocks do not + go through the barrier logic. For example, logical undo does + not use the barrier code. Although, it does defaultFlush the + pool at some point. If it was not so close to FCS I would + remove the nsswork_list_journal list. So instead I will just + add 59 seconds to the group write time so that we mostly let + the barrier code flush the journal blocks. We will only do + once per minute in the default case. The Barrier code will + do it 60 times a minute. */ + DQ_ENQ(&nsswork_list_journal, buf, bioReq.br_link); + queue_delayed_work(nssio_wq_journal, &nss_work_journal, + (59+Config.sec.journalGroupWriteTime)*HZ); } } - return buffer; -} - -Buffer_s *fastCache(MyCache_s *mycache, Blknum_t fileBlk, NINT mode) -{ - return cacheLookup(mycache, fileBlk, mode); -} - -Buffer_s *fastReadCache(MyCache_s *mycache, Blknum_t fileBlk) -{ - return cacheLookup(mycache, fileBlk, CACHE_READ); -} - -void cacheToss(Buffer_s *buffer) -{ - if (buffer == NULL || buffer == &CACHE_SparseBuffer) + else { - return; - } - MYCACHE_RMV(buffer); - LB_free(buffer->pBuf.data); - buffer->pBuf.data = NULL; - LB_free(buffer); -} - -void cacheTossAll(MyCache_s *mycache) -{ - Buffer_s *buffer; - if (mycache == NULL) - { - return; - } - DQ_DEQ(&mycache->bufList, buffer, Buffer_s, mycacheLink); - while (buffer != NULL) - { - LB_free(buffer->pBuf.data); - LB_free(buffer); - DQ_DEQ(&mycache->bufList, buffer, Buffer_s, mycacheLink); + /* User Data block */ + DQ_ENQ(&nsswork_list_data, buf, bioReq.br_link); + queue_delayed_work(nssio_wq_data, &nss_work_data, Config.sec.userDataGroupWriteTime*HZ); } } -void cacheTossIfThere(MyCache_s *mycache, Blknum_t fileBlk) +/************************************************************************** + * + ***************************************************************************/ +#if 0 +static void cacheTimerPop (OneShot_s *alarm) { - cacheToss(cacheFind(mycache, fileBlk)); + Agent_s *agent = STRUCT(alarm, Agent_s, timer); + Buffer_s *buffer = STRUCT(agent, Buffer_s, agent); + ASSERT_MPKNSS_LOCK(); + ENTER(TCACHE, cacheTimerPop); + if (buffer->state & CACHE_DIRTY) + { + DEBUG_PRINTF(TCACHE, DBG_BOTH_NOINDENT, + (CYAN,MSGNot("cacheTimerPop: buf=%08x mycache=%08x logical=%d blk#=%d\n"), + buffer, + buffer->pBuf.mycache, + //STRUCT(buffer->pBuf.mycache, StorageInfo_s, mycache)->beast, + //STRUCT(buffer->pBuf.mycache, StorageInfo_s, mycache)->beast->name, + buffer->pBuf.fileBlk, + buffer->volBlk)); + defaultFlush(agent); + } + RTN_VOID(); +} +#endif + + /* + * After unlatching the buffer, cacheRelease checks if this is the last + * thing using the buffer and if so, put it back on the LRU queue. If + * needed, it sets an alarm on a dirty buffer. + */ +void cacheRelease (Buffer_s *buffer) +{ + ENTER(TCACHE, cacheRelease); + ASSERT_MPKNSS_LOCK(); + zASSERT(buffer != NULL); + +#if LOG_TEST IS_ENABLED + if (buffer->state & CACHE_LOG_TEST) + RTN_VOID(); +#endif + + if (IS_XLATCHED( &(buffer->agent.latch))) + { + if (!(buffer->state & CACHE_TOSS) + && (buffer->state & CACHE_DIRTY) + && !(buffer->agent.state & AGENT_FLUSHING) + && !ONESHOT_SET(buffer->agent.timer)) + { +// setOneShot( &buffer->agent.timer, +// Config.tick.buffer, cacheTimerPop); + cacheTimerQueue(buffer); + } + UNX_LATCH( &(buffer->agent.latch)); + } + else + { + UNS_LATCH( &(buffer->agent.latch)); + } + + zASSERT( (buffer->state & CACHE_DIRTY) || + (NO_BONDS( &(buffer->agent)) && NO_SIGNALS( &(buffer->agent))) || + (buffer->agent.state & AGENT_FLUSHING) || + ((buffer->state & CACHE_ATTACHED) && HAVE_BONDS(&buffer->agent)) ); + + if (buffer == &CACHE_SparseBuffer) + { + ASSERT_SLATCH( &CACHE_SparseBuffer.agent.latch); + //zASSERT(CACHE_SparseBuffer.state == CACHE_CLEAR); + zASSERT(CACHE_SparseBuffer.state == CACHE_CLEAR); + RTN_VOID(); + } + + if (LATCH_FREE( &(buffer->agent.latch))) + { + if (!buffer->pinned) + { + if (!(buffer->b_page) || (buffer->state & CACHE_HAS_LINUX_PAGE)) + { + LRU_ENQ_LNX(buffer); + } + else if (buffer->state & CACHE_VICTIM) + { + LRU_ENQ_AVAIL(buffer); + } + else + { + LRU_ENQ(buffer); + } + } + } + RTN_VOID(); } -void cacheTruncateMyCache(MyCache_s *mycache, Blknum_t truncAt, Blkcnt_t count) + +void cacheMarkDirty (Buffer_s *buffer) { - (void)count; - Buffer_s *buffer; - Buffer_s *next; - if (mycache == NULL) + ENTER(TCACHE, cacheMarkDirty); + ASSERT_MPKNSS_LOCK(); + zASSERT(buffer != NULL); + zASSERT(buffer != &CACHE_SparseBuffer); + zASSERT(!ONESHOT_SET(buffer->agent.timer)); + ASSERT_XLATCH( &(buffer->agent.latch)); + + buffer->state |= CACHE_DIRTY; +// setOneShot( &buffer->agent.timer, Config.tick.buffer, cacheTimerPop); + cacheTimerQueue(buffer); + + RTN_VOID(); +} + + /* + * After doing a normal release of the buffer (unlatching it), + * it releases the buffer from the mycache associated with it. + */ +void cacheReleaseToss (Buffer_s *buffer) +{ + ENTER(TCACHE, cacheReleaseToss); + ASSERT_MPKNSS_LOCK(); +#if LOG_TEST IS_ENABLED + if (buffer->state & CACHE_LOG_TEST) + RTN_VOID(); +#endif + + UN_LATCH( &(buffer->agent.latch)); + X_BARRIER( &buffer->agent.latch); + cacheToss(buffer); + + RTN_VOID(); +} + + /* + * Handles the unpinning of a buffer, returns TRUE + * for use in CACHE_UNPIN macro. + */ +BOOL cacheUnpinned (Buffer_s *buffer) +{ + ENTER(TCACHE, cacheUnpinned); + ASSERT_MPKNSS_LOCK(); +/* zASSERT(buffer != &CACHE_SparseBuffer);*/ + + if (LATCH_FREE( &(buffer->agent.latch))) + { + if (!(buffer->b_page) || (buffer->state & CACHE_HAS_LINUX_PAGE)) + { + LRU_ENQ_LNX(buffer); + } + else if (buffer->state & CACHE_VICTIM) + { + LRU_ENQ_AVAIL(buffer); + } + else + { + LRU_ENQ(buffer); + } + } + RTN_BOOL(TRUE); +} + +void cacheUnpin (Buffer_s *buffer) +{ + zASSERT(buffer->pinned != 0); + + if (--buffer->pinned == 0) + { + cacheUnpinned(buffer); + } +} + + /* + * This routine MUST only be called from Signal Handlers. It is a + * special case because the buffer has already been unlatched but + * has not yet been put back on the LRU, which this routine does. + */ +void cacheSignalRelease (Buffer_s *buffer) +{ + + ENTER(TCACHE, cacheSignaldRelease); + ASSERT_MPKNSS_LOCK(); + zASSERT(buffer != NULL); + zASSERT(buffer != &CACHE_SparseBuffer); + zASSERT((buffer->state & CACHE_DIRTY) || (NO_BONDS( &(buffer->agent)) + && NO_SIGNALS( &(buffer->agent)))); + + if (LATCH_FREE( &(buffer->agent.latch))) + { + if (!(buffer->state & CACHE_TOSS) + && (buffer->state & CACHE_DIRTY) + && !ONESHOT_SET(buffer->agent.timer)) + { +// setOneShot( &buffer->agent.timer, +// Config.tick.buffer, cacheTimerPop); + cacheTimerQueue(buffer); + } + if (!buffer->pinned) + { + if (!(buffer->b_page) || (buffer->state & CACHE_HAS_LINUX_PAGE)) + { + LRU_ENQ_LNX(buffer); + } + else if (buffer->state & CACHE_VICTIM) + { + LRU_ENQ_AVAIL(buffer); + } + else + { + LRU_ENQ(buffer); + } + } + } + RTN_VOID(); +} + + /* + * This is a special routine only called by signal handlers. This + * routine removes the buffer from the given myCache and puts the + * buffer at the front of the LRU. This is typically called when + * a write error occurs but it can also be called if you want to + * immediatly remove a buffer from the my cache when a write completes + * (the transaction log file does this). + */ +void cacheSignalReleaseToss (Buffer_s *buffer) +{ + ENTER(TCACHE, cacheSignalReleaseToss); + ASSERT_MPKNSS_LOCK(); + cacheToss(buffer); + + RTN_VOID(); +} + + /* + * Fastpath version to look at cache. Only works if + * we can give the cache right back to the requestor + * without blocking. + */ +Buffer_s *fastReadCache (MyCache_s *mycache, Blknum_t fileBlk) +{ + Buffer_s *buffer; + NINT nowait; + + ENTER(TCACHE, fastCache); + + ASSERT_MPKNSS_LOCK(); + + buffer = cacheFind(mycache, fileBlk); + if (buffer != NULL) + { + if (buffer->state & CACHE_FAKE_BUFFER) + { + RTN_PTR(NULL); + } + if ((buffer->b_page == NULL) && (LinuxPages > NumPagesToWait)) + { +//printk("<1> fastReadCache return NULL\n"); + RTN_PTR(NULL); + } + + S_NOWAIT( &buffer->agent.latch, nowait); + if (nowait) + { + if (buffer->b_page == NULL) + { + RootBeast_s *beast = STRUCT(mycache, RootBeast_s, mycache); + + if (!(beast->rb_inode)) + { + printk(KERN_INFO "fastReadCache - Buffer's should always have an inode\n"); + UNS_LATCH( &buffer->agent.latch); + RTN_PTR(NULL); + } + buffer->b_page = + find_get_page(beast->rb_inode->i_mapping, fileBlk); + if (buffer->b_page == NULL) + { + printk(KERN_INFO "fastReadCache - Buffer should always find a page \n"); + UNS_LATCH( &buffer->agent.latch); + RTN_PTR(NULL); + } + buffer->state |= CACHE_HAS_LINUX_PAGE; + LinuxPages++; + } + LRU_RMV(buffer); + if (buffer->agent.status != zOK) + { + CACHE_RELEASE(buffer); + buffer = NULL; + } + } + else + { + buffer = NULL; + } + } + RTN_PTR(buffer); +} + +#if 0 +static Buffer_s *fastUpdateCache (MyCache_s *mycache, Blknum_t fileBlk) +{ + Buffer_s *buffer; + NINT nowait; + + ENTER(TCACHE, fastCache); + + + buffer = cacheFind(mycache, fileBlk); + if (buffer != NULL) + { + if (buffer->state & CACHE_FAKE_BUFFER) + { + RTN_PTR(NULL); + } + if ((buffer->b_page == NULL) && (LinuxPages > NumPagesToWait)) + { +//printk("<1> fastUpdateCache return NULL\n"); + RTN_PTR(NULL); + } + X_NOWAIT( &buffer->agent.latch, nowait); + if (nowait) + { + if (buffer->b_page == NULL) + { + RootBeast_s *beast = STRUCT(mycache, RootBeast_s, mycache); + + if (!(beast->rb_inode)) + { + printk(KERN_INFO "fastUpdateCache - Buffer's should always have an inode\n"); + UNX_LATCH( &buffer->agent.latch); + RTN_PTR(NULL); + } + buffer->b_page = + find_get_page(beast->rb_inode->i_mapping, fileBlk); + if (buffer->b_page == NULL) + { + printk(KERN_INFO "fastUpdateCache - Buffer should always find a page \n"); + UNX_LATCH( &buffer->agent.latch); + RTN_PTR(NULL); + } + buffer->state |= CACHE_HAS_LINUX_PAGE; + LinuxPages++; + } + LRU_RMV(buffer); + if (buffer->agent.status != zOK) + { + CACHE_RELEASE(buffer); + buffer = NULL; + } + } + else + { + buffer = NULL; + } + } + RTN_PTR(buffer); +} +#endif + +Buffer_s *fastCache (MyCache_s *mycache, Blknum_t fileBlk, NINT mode) +{ + Buffer_s *buffer; + NINT nowait; + + ENTER(TCACHE, fastCache); + + + buffer = cacheFind(mycache, fileBlk); + if (buffer != NULL) + { + if (buffer->state & CACHE_FAKE_BUFFER) + { + RTN_PTR(NULL); + } + if ((buffer->b_page == NULL) && (LinuxPages > NumPagesToWait)) + { +//printk("<1> fastCache return NULL\n"); + RTN_PTR(NULL); + } + if (mode == CACHE_READ) + { + S_NOWAIT( &buffer->agent.latch, nowait); + } + else + { + X_NOWAIT( &buffer->agent.latch, nowait); + } + if (nowait) + { + if (buffer->b_page == NULL) + { + RootBeast_s *beast = STRUCT(mycache, RootBeast_s, mycache); + + if (!(beast->rb_inode)) + { + printk(KERN_INFO "fastCache - Buffer's should always have an inode\n"); + UN_LATCH( &buffer->agent.latch); + RTN_PTR(NULL); + } + buffer->b_page = + find_get_page(beast->rb_inode->i_mapping, fileBlk); + if (buffer->b_page == NULL) + { + printk(KERN_INFO "fastCache - Buffer should always find a page \n"); + UN_LATCH( &buffer->agent.latch); + RTN_PTR(NULL); + } + buffer->state |= CACHE_HAS_LINUX_PAGE; + LinuxPages++; + } + LRU_RMV(buffer); + if (buffer->agent.status != zOK) + { + CACHE_RELEASE(buffer); + buffer = NULL; + } + } + else + { + buffer = NULL; + } + } + RTN_PTR(buffer); +} + +static void isCachedContinue(FsmLite_s *fsm) +{ + Asyncio_s *aio = STRUCT(fsm, Asyncio_s, fsm.lite); + + if (aio->buffer->state & CACHE_FAKE_BUFFER) + { + CACHE_RELEASE(aio->buffer); + aio->buffer = NULL; + if (isCached(aio, NULL)) + { + RTN_VOID(); + } + else + { + printk("<1>NSS: Buffer not in memory when it should be"); + zASSERT("Buffer not in memory when it should be" == NULL); + RTN_VOID(); + } + } + else if (aio->buffer->agent.status != zOK) + { + aio->status = aio->buffer->agent.status; + CACHE_RELEASE(aio->buffer); + aio->buffer = NULL; + } + FSM_RUN(&aio->fsm); +} + + /* + * See if the given buffer is in cache + * THIS IS AN FSM CALLABLE ROUTINE (DON'T YIELD) + * + */ +BOOL isCached (Asyncio_s *asyncio, voidfunc_t action) +{ + Buffer_s *buffer; + MyCache_s *mycache = asyncio->mycache; + RootBeast_s *beast; + + ENTER(TCACHE, isCached); + + + buffer = cacheFind(mycache, asyncio->fileBlk); + if (buffer != NULL) + { + if ((buffer->b_page == NULL) && !(buffer->state & CACHE_FAKE_BUFFER)) + { + if ((LinuxPages > NumPagesToWait)) + { +//printk("<1> isCached do Nothing\n"); + } + beast = STRUCT(mycache, RootBeast_s, mycache); + + if (!(beast->rb_inode)) + { + printk(KERN_INFO"isCached - Buffer's should always have an inode\n"); + RTN_BOOL(FALSE); + } + buffer->b_page = + find_get_page(beast->rb_inode->i_mapping, asyncio->fileBlk); + if (buffer->b_page == NULL) + { + printk(KERN_INFO "isCached - Buffer should always find a page\n"); + RTN_BOOL(FALSE); + } + buffer->state |= CACHE_HAS_LINUX_PAGE; + LinuxPages++; + } + LRU_RMV(buffer); + asyncio->buffer = buffer; + asyncio->status = zOK; + + if (action != NULL) + FSM_PUSH(&asyncio->fsm, action); + + if (asyncio->mode == CACHE_READ) + { + FSM_S_LATCH( &buffer->agent.latch, &asyncio->fsm.lite, + isCachedContinue); + } + else + { + FSM_X_LATCH( &buffer->agent.latch, &asyncio->fsm.lite, + isCachedContinue); + } + RTN_BOOL(TRUE); + } + else + { + RTN_BOOL(FALSE); + } +} + + +/* This routine is used to allow buffers that are on the bonded list to be + * moved to the appropriate list, when the bond is removed. It is called + * before freeing the bond. + */ +static void cacheBondFreed(Agent_s *toSignal) +{ + Buffer_s *buffer; + + buffer = STRUCT(toSignal, Buffer_s, agent); + + if (LRU_MEMBER(buffer)) + { + LRU_RMV(buffer); + if (!(buffer->b_page) || (buffer->state & CACHE_HAS_LINUX_PAGE)) + { + LRU_ENQ_LNX(buffer); + } + else if (buffer->state & CACHE_VICTIM) + { + LRU_ENQ_AVAIL(buffer); + } + else + { + LRU_ENQ(buffer); + } + } + if (!(HAVE_BONDS(toSignal))) + { + toSignal->bondFreedSignal = NULL; + } + return; +} + + +#if NSS_COPY_ON_XLATCH IS_ENABLED + +NINT gCopyingXLatchedBuffer=0; /* Number of times a buffer is XTACHed + * while it is being flushed. + */ +NINT gThrowAwayCopiedBuffer=0; /* Number of times we had to toss our + * new copy of a flushing buffers because + * its current state is incorrect after + * the copy. Comes about because we used + * a shared latch to do the copy. + */ +QUAD gTotalCyclesUsedByCopy=0; /* Number of total cycles used in the code + * that copies flushing buffers. + */ +NINT gTossingBufferHasBonds=0; /* Number of times that the buffer being + * tossed + * has a bond on it + */ +#endif + +typedef struct CacheCopyThrottle_s +{ + QUAD CCT_delayNone; + QUAD CCT_delay100ms; + QUAD CCT_delay200ms; + QUAD CCT_delay500ms; + QUAD CCT_delay1s; + QUAD CCT_delay2s; + QUAD CCT_delay5s; + QUAD CCT_delay7s; + QUAD CCT_delay8s; + QUAD CCT_delay10s; + QUAD CCT_delay15s; + QUAD CCT_delay20s; +} CacheCopyThrottle_s; + +CacheCopyThrottle_s CCTStats = {0}; + +static void CacheCopyDelayedAmount(delayAmount) +{ + if (delayAmount <= 100) + { + CCTStats.CCT_delay100ms++; + } + else if (delayAmount <= 200) + { + CCTStats.CCT_delay200ms++; + } + else if (delayAmount <= 500) + { + CCTStats.CCT_delay500ms++; + } + else if (delayAmount <= 1000) + { + CCTStats.CCT_delay1s++; + } + else if (delayAmount <= 2000) + { + CCTStats.CCT_delay2s++; + } + else if (delayAmount <= 5000) + { + CCTStats.CCT_delay5s++; + } + else if (delayAmount <= 7000) + { + CCTStats.CCT_delay7s++; + } + else if (delayAmount <= 8000) + { + CCTStats.CCT_delay8s++; + } + else if (delayAmount <= 10000) + { + CCTStats.CCT_delay10s++; + } + else if (delayAmount <= 15000) + { + CCTStats.CCT_delay15s++; + } + else + { + CCTStats.CCT_delay20s++; + } +} + +static NINT CacheCopyComputeDelayAmount() +{ + NINT percentAvail; + NINT delayAmount; + + CACHE_PERCENT_AVAILABLE(percentAvail); + + if (percentAvail > 50) + { + CCTStats.CCT_delayNone++; + delayAmount = 0; /* no delay */ + } + else if (percentAvail > 45) + { + delayAmount = 100; /* .1 sec */ + } + else if (percentAvail > 40) + { + delayAmount = 200; /* .2 sec */ + } + else if (percentAvail > 35) + { + delayAmount = 500; /* .5 sec */ + } + else if (percentAvail > 30) + { + delayAmount = 1000; /* 1 sec */ + } + else if (percentAvail > 25) + { + delayAmount = 2000; /* 2 sec */ + } + else if (percentAvail > 20) + { + delayAmount = 5000; /* 5 sec */ + } + else if (percentAvail > 15) + { + delayAmount = 7000; /* 7 sec */ + } + else if (percentAvail > 10) + { + delayAmount = 8000; /* 8 sec */ + } + else if (percentAvail > 5) + { + delayAmount = 10000; /* 10 sec */ + } + else if (percentAvail > 0) + { + delayAmount = 15000; /* 15 sec */ + } + else + { + delayAmount = 20000; /* 20 sec */ + } + return delayAmount; +} + +static void CacheCopyThrottleIfNeeded() +{ + NINT delayAmount; + NINT newDelayAmount; + NINT i; + + delayAmount = CacheCopyComputeDelayAmount(); + if (delayAmount == 0) + { + return; + } + + for (i = 0; i < delayAmount; ) + { + LB_delay(100); + i += 100; + + newDelayAmount = CacheCopyComputeDelayAmount(); + if (newDelayAmount <= i) + { + CacheCopyDelayedAmount(i); + return; + } + } + CacheCopyDelayedAmount(i); + return; +} + +static void cacheAllocLinuxBufferContinue (FsmLite_s *fsm) +{ + CacheWait_s *wait = (CacheWait_s *)fsm; + ASSERT_MPKNSS_LOCK(); + Continue(wait->thread); +} + /* + * too many linux buffers so we have to wait. + */ +static void waitForLinuxCacheBuffer (void) +{ + CacheWait_s wait; + + ENTER(TCACHE, waitForCacheBuffer); + ASSERT_MPKNSS_LOCK(); + + FSMLITE_INIT( &wait.fsm, MSGNot("waitForCacheBuffer"), Cache.waitInst++); + + wait.fsm.action = cacheAllocLinuxBufferContinue; + wait.thread = ThreadId(); + CIR_ENQ(LinuxWaitQ, &wait, fsm.link); + Wait(); + + RTN_VOID(); +} + /* + * This looks to see if the file block is in the cache. If it is it returns + * the buffer appropriatly latched based on mode. If not it returns a NULL. + */ +Buffer_s *cacheLookup (MyCache_s *mycache, Blknum_t fileBlk, NINT mode) +{ + Buffer_s *buffer; + ENTER(TCACHE, cacheLookup); + + ASSERT_MPKNSS_LOCK(); + PERIODIC_YIELD(); /* OK to yield here, not FSM callable */ + +retryReadForRealBuffer: + buffer = cacheFind(mycache, fileBlk); + if (buffer != NULL) + { + if (buffer->state & CACHE_FAKE_BUFFER) + { + /** We got a pointer to the FAKE buffer because someone else + ** was trying to read it from disk at this time. + ** We will yield and try to find it again. + **/ + if (mode == CACHE_READ) + { + S_LATCH(&buffer->agent.latch); + } + else + { + X_LATCH(&buffer->agent.latch); + } + CACHE_RELEASE(buffer); + buffer = NULL; + goto retryReadForRealBuffer; + } + if ((buffer->b_page == NULL) && (LinuxPages > NumPagesToWait)) + { +//printk("<1> cacheLookup Loop around\n"); + waitForLinuxCacheBuffer(); + buffer = NULL; + goto retryReadForRealBuffer; + } + if (buffer->b_page == NULL) + { + RootBeast_s *beast = STRUCT(mycache, RootBeast_s, mycache); + + if (!(beast->rb_inode)) + { + printk("<1> Buffer's should always have an inode\n"); + RTN_PTR(NULL); + } + buffer->b_page = + find_get_page(beast->rb_inode->i_mapping, fileBlk); + if (buffer->b_page == NULL) + { + printk("<1> Buffer should always find a page\n"); + RTN_PTR(NULL); + } + buffer->state |= CACHE_HAS_LINUX_PAGE; + LinuxPages++; + } + LRU_RMV(buffer); + if (mode == CACHE_READ) + { + S_LATCH( &buffer->agent.latch); + if (buffer->agent.status != zOK) + { + CACHE_RELEASE(buffer); + buffer = NULL; + } + } + else + { +#if NSS_COPY_ON_XLATCH IS_ENABLED + if ((gNSSCopyOnXLatch) && + !(buffer->state & CACHE_HAS_LINUX_PAGE) && (buffer->b_page) ) + { + NINT waitFlag; + QUAD CT1=0; + QUAD CT2=0; + + X_NOWAIT( &buffer->agent.latch, waitFlag ); + /* Did we get the XLATCH? */ + if ( (waitFlag == NOWAIT) ) + { /* YES - then we are done */ + if (buffer->agent.status != zOK) + { + CACHE_RELEASE(buffer); + buffer = NULL; + } + RTN_PTR(buffer); + } + /* We did not get a LATCH on the buffer because someone else + * has one. + * + * Is the buffer being flusded? + */ + if ( (buffer->agent.state & AGENT_FLUSHING) && + (buffer->agent.latch.count == 1) && + CIR_EMPTY(buffer->agent.latch.waiting) && + (buffer->pinned == 0) ) + { + /* YES - The buffer is being flushed so we copy the + * buffer verses waiting for one or more I/Os to + * complete. + * We only copy the buffer if it is being flushed and + * and no one else is waiting to get a latch and if + * it is not pinned in memory. + */ + Buffer_s *newBuf; + Bond_s *bond; + + rdtscll(CT1); + ++gCopyingXLatchedBuffer; + if ( buffer->agent.status != zOK ) + { + RTN_PTR(NULL); + } + + /* We do not need to worry about SparseBuffer since it + * is never written. + * This will work for both data and metadata buffers, + * so there is no need to be exclusive on metadata + * buffers + */ + S_LATCH( &buffer->agent.latch ); + + /* This call can block */ + bond = GET_BOND(); + + /* All blocking calls must be before the + * cacheAllocBuffer call + * cacheAllocBuffer can also block + */ + newBuf = cacheAllocBufferForCopy( mycache, + buffer->pBuf.fileBlk, + buffer->volBlk, + buffer->agent.signal, + (buffer->state & CACHE_USER_BUFFER), + CACHE_WRITE); + if (newBuf == NULL) + { + FREE_UNUSED_BOND(bond); + /* I should do a UNS_LATCH and not CACHE_RELEASE + * because CACHE_RELEASE can put the buffer + * back on the LRU and we don't want that because + * we are going to return this buffer to the + * caller + */ + UNS_LATCH( &buffer->agent.latch ); + /* Do normal cache wait code */ + X_LATCH( &buffer->agent.latch ); + if (buffer->agent.status != zOK) + { + CACHE_RELEASE(buffer); + buffer = NULL; + } + RTN_PTR(buffer); + } + + /* VERY IMPORTANT NOTE: + * When cacheAllocBuffer returns, BOTH the new buffer + * and the old buffer are on the buffer HASH list. + * cacheAllocBuffer does not block after it puts + * the buffer on the HASH list and before it returns. + * At this point without blocking we must either + * remove the new buffer or the old buffer from the + * HASH list + */ + /* We recheck for correct state because if the + * above calls blocked the buffer state may have + * changed. + */ + if ( (buffer->agent.state & AGENT_FLUSHING) && + (buffer->agent.latch.count == 2) && + CIR_EMPTY(buffer->agent.latch.waiting) && + (buffer->pinned == 0) ) + { + /* Buffer still in copyable state!!! */ + /* Remove the 'old' buffer from the hash and + * mycache. This prevents + * this buffer from being found by cacheFind(). + * This in turn ensures that our new buffer is + * the one that is found. + */ + MYCACHE_RMV( buffer ); + HASH_RMV( buffer ); + + /* Copy the old buffer data */ + memcpy( newBuf->pBuf.data, buffer->pBuf.data, + 1 << newBuf->bufSizeShift ); +// CMovFast( newBuf->pBuf.data, buffer->pBuf.data, +// 1 << newBuf->bufSizeShift ); + + /* Set up that 'old' buffer must be written first */ + SETUP_BOND( bond, &newBuf->agent, &buffer->agent ); + newBuf->agent.bondFreedSignal = cacheBondFreed; +#if NSS_ASSERT IS_ENABLED + newBuf->state |= CACHE_ATTACHED; +#endif + /* We do not handle write errors. If the old + * buffer gets an error we have no way to handle + * it. Write errors are asynchronous and not + * reported to user. + * + * Setting victim here puts the buffer on the LRU + * after the I/O is done. + * + * UP_LATCHes will violate our "if" conditions. + * So they are not an issue. If someone does an up + * latch they will either have an S_LATCH (before + * they attempt the UP) OR they will wait for an + * X_LATCH or they will get an X_LATCH. + * The flush code does not do an UP_LATCH. + * + * The mycache flushes do not assume that there are + * no binds between mycache buffers. + */ + buffer->state |= CACHE_VICTIM; /* This will cause + * 'old' buffer + * to be TOSSED after + * last release. + */ + CACHE_RELEASE( buffer ); + rdtscll(CT2); + gTotalCyclesUsedByCopy += CT2 - CT1; + + CacheCopyThrottleIfNeeded(); + RTN_PTR( newBuf ); + } + else + { /* The 'old' buffer is not in an acceptable state + * to copy contents. We need to get rid of our + * 'new' buffer and wait for the IO to complete. + */ + ++gThrowAwayCopiedBuffer; + HASH_RMV( newBuf ); + MYCACHE_RMV( newBuf ); + FREE_UNUSED_BOND(bond); + newBuf->state |= CACHE_VICTIM; /* This will causse + * 'new' buffer + * to be TOSSED after + * last release. + */ + CACHE_RELEASE( newBuf ); + rdtscll(CT2); + gTotalCyclesUsedByCopy += CT2 - CT1; + /* I should do a UNS_LATCH and not CACHE_RELEASE + * because CACHE_RELEASE can put the buffer + * back on the LRU and we don't want that because + * we are going to return this buffer to the + * caller + */ + UNS_LATCH( &buffer->agent.latch ); + /* Do normal cache wait code */ + X_LATCH( &buffer->agent.latch ); + if (buffer->agent.status != zOK) + { + CACHE_RELEASE(buffer); + buffer = NULL; + } + RTN_PTR(buffer); + } + + } + } +#endif + + { + X_LATCH( &buffer->agent.latch ); + } + if (buffer->agent.status != zOK) + { + CACHE_RELEASE(buffer); + buffer = NULL; + } + } + } + RTN_PTR(buffer); +} + + /* + * Toss the given buffer from its MYCACHE list. This includes + * removing it from the hash list, canceling any alarms, and + * setting the state so that if someone is still using the cache + * buffer, it is tossed when it is released. + */ +void cacheToss (Buffer_s *buffer) +{ + ASSERT_MPKNSS_LOCK(); + ENTER(TCACHE, cacheToss); + DEBUG_PRINTF(TCACHE, DBG_INDENT, + (CYAN,MSGNot("buf=%08x mycache=%08x logical=%d blk#=%d\n"), + buffer, + buffer->pBuf.mycache, + buffer->pBuf.fileBlk, + buffer->volBlk)); + + + zASSERT( (buffer->state & CACHE_DIRTY) || + (NO_BONDS( &(buffer->agent)) && NO_SIGNALS( &(buffer->agent))) || + ((buffer->state & CACHE_ATTACHED) && HAVE_BONDS( &buffer->agent))); + + CANCEL_ALARM(buffer->agent.timer); + MYCACHE_RMV(buffer); + if (!(buffer->b_page) && !(buffer->state & CACHE_STATE_INVALID)) + { + RootBeast_s *beast = STRUCT(buffer->pBuf.mycache, RootBeast_s, mycache); + + if (beast->rb_inode) + { + buffer->b_page = find_get_page( beast->rb_inode->i_mapping, + buffer->pBuf.fileBlk); + if (buffer->b_page != NULL) + { + buffer->state |= CACHE_HAS_LINUX_PAGE; + LinuxPages++; + } + } + } + + buffer->pBuf.mycache = (MyCache_s *)0xbeadfade; + HASH_RMV(buffer); + + if (HAVE_BONDS( &(buffer->agent))) + { +#if NSS_COPY_ON_XLATCH IS_ENABLED + gTossingBufferHasBonds++; + zASSERT(buffer->state & CACHE_ATTACHED); +#endif + buffer->state |= (CACHE_TOSS | CACHE_VICTIM); + defaultFlushWait( &(buffer->agent)); + } + if (buffer->state & CACHE_DIRTY) + { + buffer->state |= (CACHE_TOSS | CACHE_VICTIM); + defaultFlush( &(buffer->agent)); + } + else if (LATCH_FREE( &(buffer->agent.latch)) && !buffer->pinned) + { + zASSERT(NO_BONDS( &(buffer->agent))); + LRU_RMV(buffer); + if (buffer->state & CACHE_USER_BUFFER) + { + Config.cache.userPages--; + buffer->state &= ~CACHE_USER_BUFFER; + } + if (!(buffer->b_page) || (buffer->state & CACHE_HAS_LINUX_PAGE)) + { + buffer->state |= CACHE_VICTIM; + LRU_ENQ_LNX(buffer); + } + else + { + buffer->state = CACHE_CLEAR; + LRU_ENQ_AVAIL(buffer); + } + } + else + { + buffer->state |= (CACHE_TOSS | CACHE_VICTIM); + } + + + RTN_VOID(); +} + + /* + * cacheTossAll removes all cache buffers from the given MYCACHE list. + */ +void cacheTossAll (MyCache_s *mycache) +{ + Buffer_s *buffer; + + ENTER(TCACHE, cacheTossAll); + ASSERT_MPKNSS_LOCK(); + + while (mycache->state & MYCACHE_STATE_USING_BUFLIST) { - return; + Yield(); } - DQ_FOREACH(&mycache->bufList, buffer, Buffer_s, mycacheLink) - { - next = DQ_NEXT(&mycache->bufList, buffer, Buffer_s, mycacheLink); - if (buffer->pBuf.fileBlk >= truncAt) + + mycache->state |= MYCACHE_STATE_USING_BUFLIST; + DQ_DEQ( &mycache->bufList, buffer, Buffer_s, mycacheLink); + while (buffer != NULL) + { + X_BARRIER( &buffer->agent.latch); + cacheToss(buffer); + + DQ_DEQ( &mycache->bufList, buffer, Buffer_s, mycacheLink); + } + mycache->state &= ~MYCACHE_STATE_USING_BUFLIST; + RTN_VOID(); +} + +NINT CacheTossIfThereCount = 0; /* Number of times we have TOSSed a buffer + * that was a freed metadata block. + */ + +/* Toss this buffer from cache if we find it in the cache. */ +void cacheTossIfThere (MyCache_s *mycache, Blknum_t fileBlk) +{ + Buffer_s *buffer; + + ENTER(TCACHE, cacheTossIfThere); + ASSERT_MPKNSS_LOCK(); + + buffer = cacheFind(mycache, fileBlk); + if (buffer != NULL) + { + ASSERT_NOLATCH( &(buffer->agent.latch)); + zASSERT( !(buffer->state & CACHE_DIRTY) && + NO_BONDS( &(buffer->agent)) && + NO_SIGNALS( &(buffer->agent)) ); + cacheToss(buffer); + CacheTossIfThereCount++; + } + RTN_VOID(); + +} + + /* + * This creates a bond between the buffers and the + * beast and each dirty buffer. + */ +void cacheFlushMyCacheBufs (MyCache_s *mycache) +{ + Buffer_s *next; + DQhead_t tmpQ; + + ENTER(TCACHE, cacheFlushMyCacheBufs); + ASSERT_MPKNSS_LOCK(); + DQ_INIT( &tmpQ); + + while (mycache->state & MYCACHE_STATE_USING_BUFLIST) + { + Yield(); + } + mycache->state |= MYCACHE_STATE_USING_BUFLIST; + for (;;) + { + if (mycache->state & + (MYCACHE_STATE_TRUNCATING|MYCACHE_STATE_PURGING)) + { + break; + } + DQ_DEQ( &mycache->bufList, next, Buffer_s, mycacheLink); + if (next == NULL) + { + break; + } + DQ_ENQ( &tmpQ, next, mycacheLink); + if (next->state & CACHE_DIRTY) + { + bind(&mycache->agent, &next->agent); + defaultFlush( &next->agent); + } + PERIODIC_YIELD(); + } + DQ_APPEND( &mycache->bufList, &tmpQ); + mycache->state &= ~MYCACHE_STATE_USING_BUFLIST; + + RTN_VOID(); +} + + /* + * This is called when we want to flush all of the buffers and know when + * it is completed. This creates a bond between the buffers and the + * beast and each dirty buffer and then calls default flush. + */ +void cacheFlushMyCache (MyCache_s *mycache) +{ + ENTER(TCACHE, cacheFlushMyCache); + ASSERT_MPKNSS_LOCK(); + + cacheFlushMyCacheBufs(mycache); + defaultFlush( &mycache->agent); + + RTN_VOID(); +} + + /* + * This is a SYNCHRONOUS request to remove all cache buffers from the + * given mycache that are at the given fileBlk block number or larger. + * It does not matter if the buffers are dirty, they are tossed anyway. + */ +void cacheTruncateMyCache ( + MyCache_s *mycache, + Blknum_t truncAt, + Blkcnt_t count) +{ + Buffer_s *buffer; + DQhead_t head; + ASSERT_MPKNSS_LOCK(); + UNUSED_PARAM(count); /* For future if we allow deletion from + * middle of file. + */ + ENTER(TCACHE, cacheTruncateMyCache); + + DQ_INIT( &head); + + ASSERT_XLATCH(&mycache->agent.latch); + + if (truncAt == 0) + { + mycache->state |= MYCACHE_STATE_TRUNCATING; + } + + while (mycache->state & MYCACHE_STATE_USING_BUFLIST) + { + Yield(); + } + + mycache->state |= MYCACHE_STATE_USING_BUFLIST; + + for (;;) + { + DQ_DEQ( &mycache->bufList, buffer, Buffer_s, mycacheLink) + if (buffer == NULL) + { + break; + } + + if (buffer->pBuf.fileBlk >= truncAt) + { + + CANCEL_ALARM(buffer->agent.timer); +// if (!(buffer->agent.state & AGENT_FLUSHING)) +// { +// buffer->state &= ~CACHE_DIRTY; +// } + + X_BARRIER( &buffer->agent.latch); + cacheToss(buffer); + } + else + { + DQ_ENQ( &head, buffer, mycacheLink); + } + } + DQ_APPEND( &mycache->bufList, &head); + mycache->state &= ~(MYCACHE_STATE_TRUNCATING | MYCACHE_STATE_USING_BUFLIST); + RTN_VOID(); +} + + /* + * This is a SYNCHRONOUS request to write and toss all cache buffers from + * the given mycache that are data blocks (skip negative fileblock numbers). + */ +void cacheFlushAndTossMyCacheUserData ( + MyCache_s *mycache) +{ + Buffer_s *buffer; + DQhead_t head1; + DQhead_t head2; + ASSERT_MPKNSS_LOCK(); + + ENTER(TCACHE, cacheFlushAndTossMyCacheUserData); + + DQ_INIT( &head1); + DQ_INIT( &head2); + + ASSERT_XLATCH(&mycache->agent.latch); + + while (mycache->state & MYCACHE_STATE_USING_BUFLIST) + { + Yield(); + } + + mycache->state |= MYCACHE_STATE_USING_BUFLIST; + + for (;;) + { + DQ_DEQ( &mycache->bufList, buffer, Buffer_s, mycacheLink); + if (buffer == NULL) + { + break; + } + + if (buffer->pBuf.fileBlk >= 0) + { + DQ_ENQ( &head1, buffer, mycacheLink); + + CANCEL_ALARM(buffer->agent.timer); + if (buffer->state & CACHE_DIRTY) + { + defaultFlush (&buffer->agent); + } + } + else + { + DQ_ENQ( &head2, buffer, mycacheLink); + } + PERIODIC_YIELD(); + } + DQ_APPEND( &mycache->bufList, &head2); + for (;;) + { + DQ_DEQ( &head1, buffer, Buffer_s, mycacheLink); + if (buffer == NULL) + { + break; + } + X_BARRIER( &buffer->agent.latch); + cacheToss(buffer); + } + mycache->state &= ~MYCACHE_STATE_USING_BUFLIST; + RTN_VOID(); +} + + /* + * This is a SYNCHRONOUS request to move all cache buffers from the + * given src mycache to the dst mycache. + */ +#if 0 +/* Can not be used in Linux because inodes are used to cache pages. */ +void cacheMoveMyCacheBufList ( + MyCache_s *dstMycache, + MyCache_s *srcMycache) +{ + Buffer_s *buffer; + + ENTER(TCACHE, cacheMoveMyCacheBufList); + + while (srcMycache->state & MYCACHE_STATE_USING_BUFLIST) + { + Yield(); + } + srcMycache->state |= MYCACHE_STATE_USING_BUFLIST; + + for (;;) + { + DQ_DEQ( &srcMycache->bufList, buffer, Buffer_s, mycacheLink) + if (buffer == NULL) + { + break; + } + HASH_RMV(buffer); + + zASSERT(buffer->pBuf.mycache == srcMycache); + buffer->pBuf.mycache = dstMycache; + + cachePush(buffer); + DQ_ENQ( &dstMycache->bufList, buffer, mycacheLink); + } + srcMycache->state &= ~MYCACHE_STATE_USING_BUFLIST; + + RTN_VOID(); +} +#endif + +void cachePrepareToFlush (Buffer_s *buffer) +{ + ENTER(TCACHE, cachePrepareToFlush); + ASSERT_MPKNSS_LOCK(); + ASSERT_SLATCH( &buffer->agent.latch); + + if (QMEMBER(&buffer->bioReq.br_link)) + { + if (buffer->pBuf.fileBlk < 0) + { + Config.cache.metadataBlocksReadyForGroupWrite--; + } + DQ_RMV(buffer, bioReq.br_link); + } + + if (buffer->b_page == NULL) + { + RootBeast_s *beast = STRUCT(buffer->pBuf.mycache, RootBeast_s, mycache); + + printk("<1> Dirty page should not have been returned to Linux\n"); + if (!(beast->rb_inode)) + { + printk(KERN_INFO "crashPrepareToFlush - Buffer's should always have an inode\n"); + LRU_RMV(buffer); + RTN_VOID(); + } + buffer->b_page = + find_get_page(beast->rb_inode->i_mapping, buffer->pBuf.fileBlk); + if (buffer->b_page == NULL) + { + printk(KERN_INFO "crashPrepareToFlush - Buffer should always find a page \n"); + LRU_RMV(buffer); + RTN_VOID(); + } + buffer->state |= CACHE_HAS_LINUX_PAGE; + LinuxPages++; + } + LRU_RMV(buffer); + + RTN_VOID(); +} + +static void asyncCacheAllocBufferContinue (Asyncio_s *asyncio) +{ + ENTER(TCACHE, asyncCacheAllocBufferContinue); + ASSERT_MPKNSS_LOCK(); + /** + ** I pass in a NULL instead of asyncio->action, because action is the + ** routine that is used to read the data from disk for this + ** buffer. If the buffer is already in cache, we SHOULD NOT + ** re-read the data again from disk. + **/ + if (!isCached(asyncio, NULL)) + { + asyncCacheAllocBuffer(asyncio, asyncio->action, asyncio->flush); + } + RTN_VOID(); +} + +static void asyncCacheAllocBufferContinueForUser (Asyncio_s *asyncio) +{ + ENTER(TCACHE, asyncCacheAllocBufferContinueForUser); + ASSERT_MPKNSS_LOCK(); + /** + ** I pass in a NULL instead of asyncio->action, because action is the + ** routine that is used to read the data from disk for this + ** buffer. If the buffer is already in cache, we SHOULD NOT + ** re-read the data again from disk. + **/ + if (!isCached(asyncio, NULL)) + { + asyncCacheAllocBufferForUserData(asyncio, asyncio->action, + asyncio->flush); + } + RTN_VOID(); +} + +static void asyncLinuxCacheAllocBufferContinue (Asyncio_s *asyncio) +{ + ENTER(TCACHE, asyncCacheAllocBufferContinueForUser); + ASSERT_MPKNSS_LOCK(); + /** + ** I pass in a NULL instead of asyncio->action, because action is the + ** routine that is used to read the data from disk for this + ** buffer. If the buffer is already in cache, we SHOULD NOT + ** re-read the data again from disk. + **/ + if (!isCached(asyncio, NULL)) + { + asyncCacheAllocBufferForUserData(asyncio, asyncio->action, + asyncio->flush); + } + RTN_VOID(); +} + + +/** + ** action HAS to be the routine to read from disk. If the block is + ** found in cache when asyncCacheAllocBufferContinue is called, then the + ** routine to read from disk is not called. + **/ +static void asyncCacheAlloc ( + Asyncio_s *asyncio, + voidfunc_t action, + AgentSignalFunc_t signal, + BOOL userBuffer) +{ + Buffer_s *buffer; + Buffer_s *pageBuffer; + MyCache_s *mycache = asyncio->mycache; + RootBeast_s *beast = STRUCT(mycache, RootBeast_s, mycache); + struct page *page; + struct inode *inode; + BOOL readFromDisk = TRUE; + + ENTER(TCACHE, asyncCacheAllocBuffer); + ASSERT_MPKNSS_LOCK(); + + if ((userBuffer) && (beast->rb_inode != NULL)) + { + /* On Linux we can't do a userBuffer copy because we have to + * ask the Linux cache for a page for this fileBlk, and they will + * just return the page we are already writing. + */ + /* The beast has a inode, so we will allocate a page for it from + * the linux user cache. If we have come to this point then we + * know that a buffer_s does not already exist for this page. + */ + if ((inode = igrab(beast->rb_inode)) == NULL) + { + if (isCached(asyncio, NULL)) + { + RTN_VOID(); + } + goto useNSScache; + } + + if (isCached(asyncio, NULL)) + { + MPKNSS_UNLOCK(); + iput(inode); + MPKNSS_LOCK(); + RTN_VOID(); + } + if (LinuxPages > NumPagesToWait) + { +//printk("<1> asyncCacheAlloc wait \n"); + asyncio->flush = signal; + asyncio->action = action; + asyncio->fsm.lite.action = asyncLinuxCacheAllocBufferContinue; + CIR_ENQ(LinuxWaitQ, asyncio, fsm.lite.link); + MPKNSS_UNLOCK(); + iput(inode); + MPKNSS_LOCK(); + RTN_VOID(); + } + + STK_POP(Cache.noPageBufs, buffer, Buffer_s, lruLink); + + if ((buffer == NULL) && (TotalBuffer_s < MaxBuffer_s)) + { + buffer = allocBuffer_s(NUM_BUF_S_ALLOC); + if (buffer == NULL) + { + MPKNSS_UNLOCK(); + iput(inode); + MPKNSS_LOCK(); + goto useNSScache; + } + if (isCached(asyncio, NULL)) + { + STK_PUSH(Cache.noPageBufs, buffer, lruLink); + MPKNSS_UNLOCK(); + iput(inode); + MPKNSS_LOCK(); + RTN_VOID(); + } + } + if (buffer == NULL) + { + LRU_DEQ_LNX(buffer); + } + if (buffer == NULL) + { +//printk("<1> Return NULL from LRU_DEQ_LNX \n"); + asyncio->flush = signal; + asyncio->action = action; + asyncio->fsm.lite.action = asyncLinuxCacheAllocBufferContinue; + CIR_ENQ(LinuxWaitQ, asyncio, fsm.lite.link); + MPKNSS_UNLOCK(); + iput(inode); + MPKNSS_LOCK(); + RTN_VOID(); + } + MPKNSS_UNLOCK(); + page = grab_cache_page(inode->i_mapping, asyncio->fileBlk); + MPKNSS_LOCK(); + + if (page == NULL) + { + STK_PUSH(Cache.noPageBufs, buffer, lruLink); + MPKNSS_UNLOCK(); + iput(inode); + MPKNSS_LOCK(); + goto useNSScache; + } + if (isCached(asyncio, NULL)) + { + STK_PUSH(Cache.noPageBufs, buffer, lruLink); + MPKNSS_UNLOCK(); + unlock_page(page); + page_cache_release(page); + iput(inode); + MPKNSS_LOCK(); + RTN_VOID(); + } + pageBuffer = (Buffer_s *)page->private; + if (pageBuffer == NSSPrivateBuffer) + { +//printk("<1> Return readFromDisk is FALSE \n"); + readFromDisk = FALSE; + } + else if ((pageBuffer != NULL) && (pageBuffer->b_page == NULL)) + { + retBuffer_s(pageBuffer); + } + else + { + page_cache_get(page); + SetPagePrivate(page); + } + page->private = (unsigned long)buffer; + + buffer->b_page = page; + + buffer->state = CACHE_CLEAR; + buffer->state |= CACHE_HAS_LINUX_PAGE; + LinuxPages++; + buffer->pBuf.fileBlk = asyncio->fileBlk; + buffer->pBuf.mycache = mycache; + buffer->volBlk = asyncio->volBlk; + buffer->pBuf.data = NULL; + buffer->b_mapCount = 0; + + cacheStatsUpdate( TRUE, (NINT)asyncio->mode ); + CACHE_LinuxStatsUpdate( TRUE, (NINT)asyncio->mode, readFromDisk ); + initAgent(&buffer->agent, signal, "Linux Buffer"); + buffer->bufSizeShift = mycache->bufSizeShift; + + cachePush(buffer); + + DQ_ENQ( &mycache->bufList, buffer, mycacheLink); + + X_FORCE( &(buffer->agent.latch)); + + MPKNSS_UNLOCK(); + unlock_page(page); + iput(inode); + MPKNSS_LOCK(); + +// MPKNSS_UNLOCK(); +// buffer->pBuf.data = kmap(page); +// MPKNSS_LOCK(); + + asyncio->buffer = buffer; + asyncio->status = zOK; + if (readFromDisk) + { + action(asyncio); + } + else + { +//printk("<1> Will do a FSM_RUN\n"); + FSM_RUN(&asyncio->fsm); + } + RTN_VOID(); + } + +useNSScache: + if ((userBuffer) && (MAX_USER_PERCENT())) + { + LRU_DEQ_USER(buffer); + } + else + { + LRU_DEQ(buffer); + } + + if (buffer) + { + zASSERT(!ONESHOT_SET(buffer->agent.timer)); + zASSERT(buffer->pinned == 0); + zASSERT(NO_BONDS( &buffer->agent)); + MYCACHE_RMV(buffer); + HASH_RMV(buffer); + mycache = asyncio->mycache; + buffer->pBuf.fileBlk = asyncio->fileBlk; + buffer->pBuf.mycache = mycache; + buffer->volBlk = asyncio->volBlk; + buffer->state = CACHE_CLEAR; + buffer->agent.signal = (signal) ? signal : defaultSignal; + buffer->agent.status = zOK; + buffer->bufSizeShift = mycache->bufSizeShift; + + cachePush(buffer); + + DQ_ENQ( &mycache->bufList, buffer, mycacheLink); + + X_FORCE( &(buffer->agent.latch)); + if (userBuffer) { - cacheToss(buffer); + Config.cache.userPages++; + buffer->state |= CACHE_USER_BUFFER; } - buffer = next; - if (buffer == NULL) - { - break; - } - } + cacheStatsUpdate( userBuffer, (NINT)asyncio->mode ); + asyncio->buffer = buffer; + asyncio->status = zOK; + action(asyncio); + + checkCachePercentAvail(); + RTN_VOID(); + } + +// printk("<1> Out of avail cache buffers \n"); + cacheFlushMetadataBuffers(); + /* + * NO free buffers so we have to wait. + */ + asyncio->flush = signal; + asyncio->action = action; + if (userBuffer) + { + asyncio->fsm.lite.action = asyncCacheAllocBufferContinueForUser; + } + else + { + asyncio->fsm.lite.action = asyncCacheAllocBufferContinue; + } + CIR_ENQ(Cache.waitQ, asyncio, fsm.lite.link); + RTN_VOID(); } -void cacheFlushAndTossMyCacheUserData(MyCache_s *mycache) + + /* + * THIS IS AN FSM CALLABLE ROUTINE (DON'T YIELD) + */ +void asyncCacheAllocBuffer ( + Asyncio_s *asyncio, + voidfunc_t action, + AgentSignalFunc_t signal) { - cacheTossAll(mycache); + asyncCacheAlloc(asyncio, action, signal, FALSE); } -Buffer_s *cacheAllocSlab(MyCache_s *mycache, AgentSignalFunc_t signal) + /* + * THIS IS AN FSM CALLABLE ROUTINE (DON'T YIELD) + */ +void asyncCacheAllocBufferForUserData ( + Asyncio_s *asyncio, + voidfunc_t action, + AgentSignalFunc_t signal) { - return cacheAllocLocal(mycache, 0, 0, signal, CACHE_WRITE); + asyncCacheAlloc(asyncio, action, signal, TRUE); } -Buffer_s *cacheGrabSlab(MyCache_s *mycache) + +static void cacheAllocBufferContinue (FsmLite_s *fsm) { - (void)mycache; - return NULL; + CacheWait_s *wait = (CacheWait_s *)fsm; + ASSERT_MPKNSS_LOCK(); + Continue(wait->thread); } -void cacheReleaseSlab(Buffer_s *buffer) + /* + * NO free buffers so we have to wait. + */ +static void waitForCacheBuffer (void) { - cacheToss(buffer); + CacheWait_s wait; + + ENTER(TCACHE, waitForCacheBuffer); + ASSERT_MPKNSS_LOCK(); + +// printk("<1> Out of avail cache buffers \n"); + cacheFlushMetadataBuffers(); + + FSMLITE_INIT( &wait.fsm, MSGNot("waitForCacheBuffer"), Cache.waitInst++); + + wait.fsm.action = cacheAllocBufferContinue; + wait.thread = ThreadId(); + CIR_ENQ(Cache.waitQ, &wait, fsm.link); + Wait(); + + RTN_VOID(); } -Buffer_s *cacheTakeBuffer(void) +/** + ** cacheAllocBuffer can yield because of the periodic yield or due to + ** unavailability of cache blocks and the wait call. During the yield + ** another thread can come in and request to allocate a cache buffer + ** for the same block for this file blk and myCache. To prevent this + ** before yielding we initialize a fake Buffer on the stack and put it + ** on the Cache Hash list. This fake buffer has a X_LATCH on it. + ** + ** Now if another thread does a cacheFind for this blk it will find + ** the fake buffer. The fake buffer has a special state bit set. + ** + ** Callers of cacheFind look for the fake bit and either return a NULL, or + ** wait to get a latch on the fake buffer, which they will get when the + ** real buffer is in memory and the next call to cacheFind will find it. + ** + **/ +static void initFakeBuffer( + Buffer_s *fakeBuffer, + MyCache_s *mycache, + Blknum_t fileBlk, + Blknum_t volBlk) { - return cacheAllocLocal(NULL, 0, 0, defaultSignal, CACHE_WRITE); + fakeBuffer->pBuf.fileBlk = fileBlk; + fakeBuffer->pBuf.mycache = mycache; + fakeBuffer->volBlk = volBlk; + initAgent(&fakeBuffer->agent, defaultSignal, MSGNot("FakeBuffer")); + fakeBuffer->bufSizeShift = mycache->bufSizeShift; + X_FORCE(&fakeBuffer->agent.latch); + fakeBuffer->state = CACHE_FAKE_BUFFER; + NULLIFY(&fakeBuffer->hashLink); + NULLIFY(&fakeBuffer->lruLink); + cachePush(fakeBuffer); } -void cacheGiveBuffer(Buffer_s *buffer) + /* + * This searches the LRU looking for an available cache buffer to use. + * If the top of the LRU is not available, a write requested is sent on + * the buffer and then we look at the next buffer on the LRU to see if we + * can use it. If the LRU goes empty we will wait wait for a buffer to + * become free. + */ + +static Buffer_s *cacheAlloc ( + MyCache_s *mycache, + Blknum_t fileBlk, + Blknum_t volBlk, + AgentSignalFunc_t signal, + BOOL userBuffer, + BOOL copyBuffer, + NINT mode ) /* This is NOT always CACHE_WRITE, + * CACHE_UPDATE or CACHE_READ. It can also + * be STAT_CACHE_ALLOCATE. This mode MUST + * only be used to detect if counts + * should be changed. + */ { - cacheToss(buffer); + Buffer_s *buffer; + Buffer_s *pageBuffer; + Buffer_s fakeBuffer; + BOOL fakeBufferExists = FALSE; + RootBeast_s *beast = STRUCT(mycache, RootBeast_s, mycache); + struct page *page; + struct inode *inode; + BOOL readFromDisk = TRUE; + + ENTER(TCACHE, cacheAlloc); + ASSERT_MPKNSS_LOCK(); + + if ((userBuffer) && !(copyBuffer) && (beast->rb_inode != NULL)) + { + /* On Linux we don't cant do a userBuffer copy because we have to + * ask the Linux cache for a page for this fileBlk, and they will + * just return the page we are already writing. + */ + /* The beast has a inode, so we will allocate a page for it from + * the linux user cache. If we have come to this point then we + * know that a buffer_s does not already exist for this page. + */ + initFakeBuffer(&fakeBuffer, mycache, fileBlk, volBlk); + fakeBufferExists = TRUE; + + + if ((inode = igrab(beast->rb_inode)) == NULL) + { + printk("<1> No inode for the beast\n"); + goto useNSScache; + } + + while (LinuxPages > NumPagesToWait) + { +//printk("<1> cacheAlloc wait \n"); + waitForLinuxCacheBuffer(); + } + +TryForBufferAgain: + STK_POP(Cache.noPageBufs, buffer, Buffer_s, lruLink); + + if ((buffer == NULL) && (TotalBuffer_s < MaxBuffer_s)) + { + buffer = allocBuffer_s(NUM_BUF_S_ALLOC); + if (buffer == NULL) + { + MPKNSS_UNLOCK(); + iput(inode); + MPKNSS_LOCK(); + printk("<1> No memory for buffer_s \n"); + goto useNSScache; + } + } + if (buffer == NULL) + { + LRU_DEQ_LNX(buffer); + } + if (buffer == NULL) + { +//printk("<1> Waiting\n"); + waitForLinuxCacheBuffer(); + goto TryForBufferAgain; + } + MPKNSS_UNLOCK(); + page = grab_cache_page(inode->i_mapping, fileBlk); + MPKNSS_LOCK(); + + if (page == NULL) + { + STK_PUSH(Cache.noPageBufs, buffer, lruLink); + MPKNSS_UNLOCK(); + iput(inode); + MPKNSS_LOCK(); + printk("<1> No page found \n"); + goto useNSScache; + } + pageBuffer = (Buffer_s *)page->private; + if (pageBuffer == NSSPrivateBuffer) + { + readFromDisk = FALSE; + } + else if ((pageBuffer != NULL) && (pageBuffer->b_page == NULL)) + { + retBuffer_s(pageBuffer); + } + else + { + page_cache_get(page); + SetPagePrivate(page); + } + page->private = (unsigned long)buffer; + + buffer->b_page = page; + + buffer->state = CACHE_CLEAR; + buffer->state |= CACHE_HAS_LINUX_PAGE; + LinuxPages++; + buffer->pBuf.fileBlk = fileBlk; + buffer->pBuf.mycache = mycache; + buffer->volBlk = volBlk; + buffer->pBuf.data = NULL; + buffer->b_mapCount = 0; + + cacheStatsUpdate( TRUE, mode ); + CACHE_LinuxStatsUpdate( TRUE, mode, readFromDisk ); + initAgent(&buffer->agent, signal, "Linux Buffer"); + buffer->bufSizeShift = mycache->bufSizeShift; + + cachePush(buffer); + + DQ_ENQ( &mycache->bufList, buffer, mycacheLink); + + X_FORCE( &(buffer->agent.latch)); + +// MPKNSS_UNLOCK(); +// buffer->pBuf.data = kmap(page); +// MPKNSS_LOCK(); + + + HASH_RMV(&fakeBuffer); + UNX_LATCH(&fakeBuffer.agent.latch); + X_BARRIER(&fakeBuffer.agent.latch); + + MPKNSS_UNLOCK(); + unlock_page(page); + iput(beast->rb_inode); + MPKNSS_LOCK(); + + if (!readFromDisk) + { + buffer->state |= CACHE_DATA_VALID; + } + + RTN_PTR(buffer); + } + +useNSScache: + for (;;) + { + if ((userBuffer) && (MAX_USER_PERCENT())) + { + LRU_DEQ_USER(buffer); + } + else + { + LRU_DEQ(buffer); + } + if (buffer) + { + zASSERT(!ONESHOT_SET(buffer->agent.timer)); + zASSERT(buffer->pinned == 0); + zASSERT(NO_BONDS( &buffer->agent)); + MYCACHE_RMV(buffer); + HASH_RMV(buffer); + + buffer->pBuf.fileBlk = fileBlk; + buffer->pBuf.mycache = mycache; + buffer->volBlk = volBlk; + buffer->state = CACHE_CLEAR; + buffer->agent.signal = (signal) ? signal : defaultSignal; + buffer->agent.status = zOK; + buffer->bufSizeShift = mycache->bufSizeShift; + + cachePush(buffer); + + DQ_ENQ( &mycache->bufList, buffer, mycacheLink); + + X_FORCE( &(buffer->agent.latch)); + + if (userBuffer) + { + Config.cache.userPages++; + buffer->state |= CACHE_USER_BUFFER; + } + cacheStatsUpdate( userBuffer, mode ); + + if (fakeBufferExists) + { + HASH_RMV(&fakeBuffer); + UNX_LATCH(&fakeBuffer.agent.latch); + X_BARRIER(&fakeBuffer.agent.latch); + } + checkCachePercentAvail(); + RTN_PTR(buffer); + } + /* + * NO free buffers so we have to wait. + */ + if (copyBuffer) + { + /* If we are making copies of cacheBuffers and are running low + * on cache buffers, don't make copies, just wait for the real + * buffer + */ + RTN_PTR(NULL); + } + if (!fakeBufferExists) + { + initFakeBuffer(&fakeBuffer, mycache, fileBlk, volBlk); + fakeBufferExists = TRUE; + } + waitForCacheBuffer(); + } } -void initMyCache(MyCache_s *mycache, AgentSignalFunc_t signal, NINT bufSizeShift, - char *name) +Buffer_s *cacheAllocBuffer ( + MyCache_s *mycache, + Blknum_t fileBlk, + Blknum_t volBlk, + AgentSignalFunc_t signal, + NINT mode ) /* This is NOT always CACHE_WRITE, CACHE_UPDATE + * or CACHE_READ. It can also be + * STAT_CACHE_ALLOCATE. This mode MUST only be + * used to detect if counts should be changed. + */ { - zASSERT(mycache != NULL); - DQ_INIT(&mycache->bufList); - initAgent(&mycache->agent, signal, name); - mycache->bufSizeShift = (BYTE)bufSizeShift; - mycache->state = 0; + return cacheAlloc(mycache, fileBlk, volBlk, signal, FALSE, FALSE, mode); } -void checkMyCache(MyCache_s *mycache) +Buffer_s *cacheAllocBufferForUserData ( + MyCache_s *mycache, + Blknum_t fileBlk, + Blknum_t volBlk, + AgentSignalFunc_t signal, + NINT mode ) /* This is NOT always CACHE_WRITE, CACHE_UPDATE + * or CACHE_READ. It can also be + * STAT_CACHE_ALLOCATE. This mode MUST only be + * used to detect if counts should be changed. + */ { - zASSERT(mycache != NULL); + return cacheAlloc(mycache, fileBlk, volBlk, signal, TRUE, FALSE, mode); } -void asyncCacheAllocBuffer(Asyncio_s *asyncio, voidfunc_t action, - AgentSignalFunc_t signal) + /* + * This version of the cacheAllocBuffer code does not do a fake buffer + * initialize, because it is for use with the copy cache buffer code + * only. In the copy cache buffer code, the old buffer is already on the + * hash list, and so we should not put the fake buffer on the hash too. + * We also prevent the old buffer from getting put back on the LRU, + * because we get an additional SLATCH on it before calling this code. + * The code is only called in extremely stringent conditions defined in + * cacheLookup. + * + * This routine can return NULL. It does not wait for cache buffers, if + * there are none available currently. + */ + +Buffer_s *cacheAllocBufferForCopy ( + MyCache_s *mycache, + Blknum_t fileBlk, + Blknum_t volBlk, + AgentSignalFunc_t signal, + BOOL userBuffer, + NINT mode ) /* This is NOT always CACHE_WRITE, CACHE_UPDATE + * or CACHE_READ. It can also be + * STAT_CACHE_ALLOCATE. This mode MUST only be + * used to detect if counts should be changed. + */ { - if (asyncio != NULL) - { - asyncio->buffer = cacheAllocBuffer(asyncio->mycache, asyncio->fileBlk, - asyncio->volBlk, signal, asyncio->mode); - } - if (action != NULL) - { - ((void (*)(Asyncio_s *))action)(asyncio); - } + /* On Linux we don't cant do a userBuffer copy because we have to + * ask the Linux cache for a page for this fileBlk, and they will + * just return the page we are already writing. + */ + return cacheAlloc(mycache, fileBlk, volBlk, signal, userBuffer, TRUE, mode); } -void asyncCacheAllocBufferForUserData(Asyncio_s *asyncio, voidfunc_t action, - AgentSignalFunc_t signal) + /* + * Like cacheAllocBuffer but optimized to work with the slab allocator + * (see slab.c) We don't need fake buffers because nobody can hash + * to these guys and we don't latch the buffer. The slab allocator + * does funny things with the mycacheLink so we don't put it in the + * mycache list. + */ +Buffer_s *cacheAllocSlab ( + MyCache_s *mycache, + AgentSignalFunc_t signal) { - if (asyncio != NULL) - { - asyncio->buffer = cacheAllocBufferForUserData(asyncio->mycache, - asyncio->fileBlk, asyncio->volBlk, signal, asyncio->mode); - } - if (action != NULL) - { - ((void (*)(Asyncio_s *))action)(asyncio); - } + Buffer_s *buffer; + + ASSERT_MPKNSS_LOCK(); + for (;;) + { + if (MAX_USER_PERCENT()) + { + LRU_DEQ_USER(buffer); + } + else + { + LRU_DEQ(buffer); + } + if (buffer) + { + zASSERT(!ONESHOT_SET(buffer->agent.timer)); + zASSERT(buffer->pinned == 0); + zASSERT(NO_BONDS( &buffer->agent)); + MYCACHE_RMV(buffer); + HASH_RMV(buffer); + + buffer->pBuf.fileBlk = -1; + buffer->pBuf.mycache = mycache; + buffer->volBlk = -1; + buffer->state = CACHE_CLEAR; + buffer->agent.signal = (signal) ? signal : defaultSignal; + buffer->agent.status = zOK; + buffer->bufSizeShift = mycache->bufSizeShift; + + DEC_RSRC(1); + ++Cache.slabbed; + return buffer; + } + /* + * NO free buffers so check if we can get from the + * system then wait. This is to solve the problem + * of the NSS slab allocator taking all the cache + * buffers when cache balance is turned off and the + * system is set to a minumum number of cache buffers + * for NSS. + */ + checkTakeCache(); + waitForCacheBuffer(); + } } -void mapBufferPage(Buffer_s *buf) + /* + * Grabs a cache buffer that slab-allocator returned to the + * LRU but it is still allocated to the slab-allocator. + */ +Buffer_s *cacheGrabSlab (MyCache_s *mycache) { - if (buf != NULL) - { - buf->b_mapCount++; - } + Buffer_s *buffer; + + ASSERT_MPKNSS_LOCK(); + + DQ_DEQ( &mycache->bufList, buffer, Buffer_s, mycacheLink); + if (buffer == NULL) + { + return NULL; + } + DEC_RSRC(1); + LRU_RMV(buffer); + ++Cache.slabbed; + return buffer; } + /* + * The slab-allocator releases the buffer. Because we don't have + * a latch on it, there is a lot less work to do. The cache buffer + * is still in a state where it can be grabbed back by the slab- + * allocator. + */ +void cacheReleaseSlab (Buffer_s *buffer) +{ + ASSERT_MPKNSS_LOCK(); + zASSERT(buffer != NULL); + zASSERT(NO_BONDS( &(buffer->agent)) && NO_SIGNALS( &(buffer->agent))); + + LRU_ENQ_AVAIL(buffer); + --Cache.slabbed; + MYCACHE_RMV(buffer); + DQ_ENQ( &buffer->pBuf.mycache->bufList, buffer, mycacheLink); + INC_RSRC_CHECK(1); +} + + /* + * cacheTakeBuffer is used to take a cache buffer away from the + * cache along with its Buffer_s structure (that can be over + * written except for the data and number fields). + */ +Buffer_s *cacheTakeBuffer (void) +{ + Buffer_s *buffer; + + ENTER(TCACHE, cacheTakeBuffer); + ASSERT_MPKNSS_LOCK(); + for (;;) + { + if (MAX_USER_PERCENT()) + { + LRU_DEQ_USER(buffer); + } + else + { + LRU_DEQ(buffer); + } + if (buffer) + { +// /* The have bonds check is for the case where we copy buffers, +// * since they are bonded but they may not be dirty +// */ +// if (buffer->state & CACHE_DIRTY) +// { +// buffer->state |= CACHE_VICTIM; +// defaultFlush( &buffer->agent); +// PERIODIC_YIELD(); +// LRU_DEQ(buffer); /* Get buffer for next iteration */ +// } +// else if (HAVE_BONDS(&buffer->agent)) +// { +// LRU_ENQ(buffer); +// PERIODIC_YIELD(); +// LRU_DEQ(buffer); /* Get next buffer for next iteration */ +// } +// else +// { + zASSERT(!ONESHOT_SET(buffer->agent.timer)); + zASSERT(NO_BONDS( &buffer->agent)); + zASSERT(buffer->pinned == 0); + MYCACHE_RMV(buffer); + HASH_RMV(buffer); + ++Cache.control; + RTN_PTR(buffer); +// } + } + waitForCacheBuffer(); + } +} + + /* + * cacheGiveBuffer is used to give back a buffer obtained by + * cacheTakeBuffer. We assume the data (and number) field(s) + * are still set. We reinitialize all other fields. + */ +void cacheGiveBuffer (Buffer_s *buffer) +{ + BYTE *data = buffer->pBuf.data; + struct page *page = buffer->b_page; + + ASSERT_MPKNSS_LOCK(); + bzero(buffer, sizeof(Buffer_s)); + + buffer->pBuf.data = data; + + initAgent( &(buffer->agent), defaultSignal, MSGNot("Buffer")); + buffer->state = CACHE_CLEAR; + buffer->bufSizeShift = PAGE_SHIFT; + --Cache.control; + buffer->b_page = page; + zASSERT(buffer->b_page != NULL); + LRU_ENQ_AVAIL(buffer); +} + + /* + * Initialize the MYCACHE structure + */ +void initMyCache( + MyCache_s *mycache, + AgentSignalFunc_t signal, + NINT bufSizeShift, + char *name) +{ + ENTER(TCACHE, myCacheInit); + ASSERT_MPKNSS_LOCK(); + DQ_INIT( &mycache->bufList); + initAgent( &mycache->agent, signal, name); + mycache->bufSizeShift = bufSizeShift; + mycache->state = 0; + + RTN_VOID(); +} + + /* + * Cleanup the MYCACHE structure + */ +void checkMyCache( + MyCache_s *mycache) +{ + ENTER(TCACHE, myCacheUninit); + ASSERT_MPKNSS_LOCK(); + zASSERT(DQ_EMPTY(&mycache->bufList)); + zASSERT(DQ_EMPTY(&mycache->agent.flushList)); + zASSERT(STK_EMPTY(mycache->agent.signalList)); + zASSERT(mycache->agent.numLeft == 0); + zASSERT(CIR_EMPTY(mycache->agent.fsm.link)); + + RTN_VOID(); +} + + +static void *cacheRequestPage (void) +{ + + Buffer_s *buf = cacheTakeBuffer(); + struct page *page = buf->b_page; + if (buf->pBuf.data != NULL) + { + kunmap(page); + buf->pBuf.data = NULL; + } + + buf->b_page = NULL; + + STK_PUSH(Cache.noPageBufs, buf, lruLink); + --Cache.control; + --Cache.available; + --Config.cache.numPagesAllocated; + DEC_RSRC(1); + + return page; +} + + +/* Buffer_s that has no page associated with it is returned to available + * noPageBufs list + */ +void retBuffer_s(Buffer_s *buf) +{ + if (LRU_MEMBER(buf)) + { + DQ_RMV(buf, lruLink); + } + MYCACHE_RMV(buf); + HASH_RMV(buf); + + buf->pBuf.data = NULL; + buf->b_page = NULL; + buf->state = CACHE_CLEAR; + buf->b_mapCount = 0; + + STK_PUSH(Cache.noPageBufs, buf, lruLink); +} +EXPORT_SYMBOL(retBuffer_s); + +/* We no longer keep user data pages mapped in memory all the time. + * Any time some one wants to read/write the data on a user buffer, they have + * to map and unmap the buffer. Otherwise pBuf.data will be NULL. + * Note: this is a blocking call. + * This is necessary to enable us to use Linux cache for user data. + * Linux only keeps a small address space in which they map the pages + * associated with higher than 1 G memory. + * So either use kmap_atomic and kumap_atomic (If you are sure you will not + * sleep in between : those are non-blocking calls ) + * or you have to call the mapBufferPage and umapBufferPage routines + */ +void mapBufferPage(Buffer_s *buf) +{ + void *kaddr; + + if (!(buf->state & CACHE_HAS_LINUX_PAGE)) + { + return; + } + + buf->b_mapCount++; + + if (buf->pBuf.data == NULL) + { + MPKNSS_UNLOCK(); + kaddr = kmap(buf->b_page); + MPKNSS_LOCK(); + if (buf->pBuf.data == NULL) + { + /* Nobody else kmapped it already */ + buf->pBuf.data = kaddr; + } + else + { + MPKNSS_UNLOCK(); + kunmap(buf->b_page); + MPKNSS_LOCK(); + } + } +} +EXPORT_SYMBOL(mapBufferPage); + void unmapBufferPage(Buffer_s *buf) { - if (buf != NULL && buf->b_mapCount > 0) - { - buf->b_mapCount--; - } + if (!(buf->state & CACHE_HAS_LINUX_PAGE)) + { + return; + } + + buf->b_mapCount--; + if (buf->b_mapCount == 0) + { + buf->pBuf.data = NULL; + MPKNSS_UNLOCK(); + kunmap(buf->b_page); + MPKNSS_LOCK(); + } } +EXPORT_SYMBOL(unmapBufferPage); + diff --git a/src/nwnss/nss/cache/control.c b/src/nwnss/nss/cache/control.c index 4942019..3058365 100644 --- a/src/nwnss/nss/cache/control.c +++ b/src/nwnss/nss/cache/control.c @@ -34,21 +34,17 @@ | This module is used to: | Code for allocating and freeing controls +-------------------------------------------------------------------------*/ +#include - -#include /* NSS Library */ -#include -#include -#include -#include -#include -#include -#include -#include - -/* Linux userspace port: dynamic control expansion from cache buffers is - * enabled later with the real xCache runtime. Until then, CONTROL_get() - * uses the preallocated pool and waits/yields if it is exhausted. */ +#include /* NSS Library */ +#include +#include +#include +#include +#include +#include +#include +#include /* * PURPOSE: Allocate the control structures needed by NSS such as bonds, @@ -86,7 +82,7 @@ * ControlBlock_s; */ #ifdef __linux__ - /* We need the last field of Buffer_s saved in Linux as it contains the + /* We need the last field of Buffer_s saved in Linux as it contains the * page pointer. That should not get overwritten */ NINT IsSizeofControlBlockOk[sizeof(ControlBlock_s) <= (offsetof(Buffer_s, b_page))]; @@ -94,8 +90,6 @@ NINT IsSizeofControlBlockOk[sizeof(ControlBlock_s) <= (offsetof(Buffer_s, b_pag NINT IsSizeofControlBlockOk[sizeof(ControlBlock_s) <= (sizeof(Buffer_s))]; #endif -typedef void (*control_initfunc_t)(void *, NINT); - void initControlSpace ( ControlHead_s *head, NINT total, @@ -107,7 +101,7 @@ void initControlSpace ( Control_s *instance; ASSERT_MPKNSS_LOCK(); - LB_bzero(head->space, total * size); + bzero(head->space, total * size); offset = (ADDR)head->space; for (i = 0; i < total; ++i, offset += size) { @@ -115,7 +109,7 @@ void initControlSpace ( instance->control = head; if (initFunction != NULL) { - ((control_initfunc_t)initFunction)(instance->userData, i); + initFunction(instance->userData, i); } } LBQ_STKinitElements( &head->freeList, @@ -170,7 +164,7 @@ void CONTROL_Shutdown (ControlStore_s *control) #if NSS_DEBUG IS_ENABLED NINT i; FakeControl_s *fake; - + ASSERT_MPKNSS_LOCK(); /* * Count all the items on the free list and make sure @@ -186,12 +180,9 @@ void CONTROL_Shutdown (ControlStore_s *control) #endif ASSERT_MPKNSS_LOCK(); /* - * Need to free up cache blocks we allocated. The Linux userspace - * import starts with the fixed preallocated pool; cache-backed - * expansion is enabled when the real xCache runtime is imported. + * Need to free up cache blocks we allocated */ zASSERT(DQ_EMPTY( &control->noFree)); -#ifndef __linux__ DQ_DEQ( &control->someFree, cblk, ControlBlock_s, link); while (cblk != NULL) { @@ -200,15 +191,11 @@ void CONTROL_Shutdown (ControlStore_s *control) cacheGiveBuffer((Buffer_s *)cblk); DQ_DEQ( &control->someFree, cblk, ControlBlock_s, link); } -#else - (void)cblk; - zASSERT(DQ_EMPTY( &control->someFree)); -#endif - LB_free(control->head.space); + free(control->head.space); } void freeBufferTimerPop (OneShot_s *alarm) -{ +{ ControlBlock_s *cblk = STRUCT(alarm, ControlBlock_s, alarm); ControlStore_s *control = cblk->control; @@ -218,17 +205,12 @@ void freeBufferTimerPop (OneShot_s *alarm) zASSERT(cblk->numAllocated == 0); zASSERT(control->numCacheBufs > 0); -#ifndef __linux__ --control->numCacheBufs; DQ_RMV(cblk, link); cacheGiveBuffer((Buffer_s *)cblk); INC_RSRC_CHECK(1); -#else - (void)cblk; - (void)control; -#endif - RTN_VOID(); + RTN_VOID(); } void someFree (FakeControl_s *fake) @@ -396,7 +378,6 @@ void *CONTROL_get (ControlStore_s *control) DQ_PEEK( &control->someFree, cblk, ControlBlock_s, link); } { -#ifndef __linux__ /* * We are going to have to go get another cache block * This is where we want to put something optional for @@ -429,10 +410,6 @@ void *CONTROL_get (ControlStore_s *control) cblk->numAllocated = 0; initControlSpace( &cblk->head, total, control->size, control->initFunction); -#else - (void)cblk; - return CONTROL_wait(control); -#endif } } } diff --git a/src/nwnss/nss/cache/work.c b/src/nwnss/nss/cache/work.c index 8150650..139595b 100644 --- a/src/nwnss/nss/cache/work.c +++ b/src/nwnss/nss/cache/work.c @@ -35,24 +35,25 @@ | Routines for allocating and managing structures for | spinning off worktodos. +-------------------------------------------------------------------------*/ -#include /* NetWare Includes*/ +#include /* NetWare Includes*/ -#include /* NSS Library includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include /* NSS Library includes */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "nssOSAPIs.h" - -NINT WorkWaitingCount = 0; -NINT WorkHighWaitingCount = 0; -NINT WorkLowWaitingCount = 0; +NINT WorkWaitingCount = 0; +NINT WorkHighWaitingCount = 0; +NINT WorkLowWaitingCount = 0; #define ACTIVE_WORK_WAIT_LIST 0 #define ACTIVE_WORK_HIGH_WAIT_LIST 1 @@ -67,7 +68,7 @@ CIRhead_t WorkHighWaitingListHead; CIRhead_t WorkLowWaitingListHead; NINT ActiveWorkWaitingList = ACTIVE_WORK_WAIT_LIST; -#if zLINUX && !defined(NSS_USERSPACE) +#if zLINUX extern STATUS kSchedulePrioWorkToDo(struct WorkToDoStructure *work); #endif @@ -86,7 +87,7 @@ typedef struct Work_s NINT instance; #endif } Work_s; - + ControlStore_s WorkControl; ControlStore_s WorkControlHigh; ControlStore_s WorkControlLow; @@ -97,11 +98,11 @@ extern void WORK_RunHigh(Work_s *work); extern void WORK_RunLow(Work_s *work); /************************************************************************** - * + * ***************************************************************************/ void WORK_Init (Work_s *work) { - work->worktodo.ProcedureToCall = (voidfunc_t)WORK_Run; + work->worktodo.ProcedureToCall = WORK_Run; work->worktodo.WorkResourceTag = COMN_Resource.workToDoRTag; #if NSS_DEBUG IS_ENABLED @@ -117,7 +118,7 @@ void WORK_Init (Work_s *work) void WORK_InitHigh (Work_s *work) { - work->worktodo.ProcedureToCall = (voidfunc_t)WORK_RunHigh; + work->worktodo.ProcedureToCall = WORK_RunHigh; work->worktodo.WorkResourceTag = COMN_Resource.workToDoRTag; #if NSS_DEBUG IS_ENABLED @@ -133,7 +134,7 @@ void WORK_InitHigh (Work_s *work) void WORK_InitLow (Work_s *work) { - work->worktodo.ProcedureToCall = (voidfunc_t)WORK_RunLow; + work->worktodo.ProcedureToCall = WORK_RunLow; work->worktodo.WorkResourceTag = COMN_Resource.workToDoRTag; #if NSS_DEBUG IS_ENABLED @@ -175,7 +176,7 @@ void WORK_ThreadTestWorkToDoRoutine( FsmLite_s *workToDoFsm ) Time_t diffTime; char buffer[40]; - + WORK_PROCESS_INIT(); ++gNSSThreadTestCount; @@ -196,28 +197,28 @@ void WORK_ThreadTestWorkToDoRoutine( FsmLite_s *workToDoFsm ) if ( diffTime >= gNSSThreadTestTimeAssert ) { DBG_DebugPrintf( LRED, - MSGNot("NSS Thread Test schedule delayed for %lu seconds ending at %s.\n"), + MSGNot("NSS Thread Test schedule delayed for %lu seconds ending at %s.\n"), (unsigned long)diffTime, UTCTime2Str(cTime,&buffer[0]) ); // // Because we can queue up a lot of pending work, this is not that unusual // // /* We print to screen so that testers can see delay time */ -// aprintf(LRED, - MSGNot("NSS Thread Test schedule delayed for %lu seconds ending at %s.\n"), +// aprintf(LRED, +// MSGNot("NSS Thread Test schedule delayed for %lu seconds ending at %s.\n"), // (unsigned long)diffTime, UTCTime2Str(cTime,&buffer[0]) ); // zASSERT( "It appears that scheduling is really slow" == NULL ); // } /* Is this the maximum delay for a schedule? */ - if ( diffTime > gNSSThreadTestTimeMax ) + if ( diffTime > gNSSThreadTestTimeMax ) { /* Yes - update max time and when max time occurred. */ gNSSThreadTestTimeMax = diffTime; gNSSThreadTestTimeMaxTime = cTime; /* Display in debugger buffer */ DBG_DebugPrintf( LRED, - MSGNot("NSS Thread Test new MAX delay of %lu seconds ending at %s.\n"), + MSGNot("NSS Thread Test new MAX delay of %lu seconds ending at %s.\n"), (unsigned long)gNSSThreadTestTimeMax, - UTCTime2Str(gNSSThreadTestTimeMaxTime,&buffer[0]) ); + UTCTime2Str(gNSSThreadTestTimeMaxTime,&buffer[0]) ); } LB_delay( 1 * 1000 ); /* 1 second delay - can not do a yield because * GreenRiver was complaining that low priority @@ -229,21 +230,21 @@ void WORK_ThreadTestWorkToDoRoutine( FsmLite_s *workToDoFsm ) gNSSThreadTestTimeLast = GetUTCTime(); WORK_Schedule( &gNSSThreadTestWorkToDoFsm, WORK_ThreadTestWorkToDoRoutine, 0); - - + + return; } /* Mark that we are not running the test anymore */ DBG_DebugPrintf(CYAN,MSGNot("... Thread Test has stopped\n")); gNSSThreadTestState = TT_NOT_RUNNING; - + return; } /* End of WORK_ThreadTestWorkToDoRoutine() */ #endif /************************************************************************** - * + * ***************************************************************************/ STATUS WORK_Startup (void) { @@ -257,11 +258,11 @@ STATUS WORK_Startup (void) CIR_INIT(WorkLowWaitingListHead); status = CONTROL_Startup( &WorkControl, Config.os.workLimit, - sizeof(Work_s), (voidfunc_t)WORK_Init); + sizeof(Work_s), WORK_Init); status = CONTROL_Startup( &WorkControlHigh, WORK_COUNT_HIGH, - sizeof(Work_s), (voidfunc_t)WORK_InitHigh); + sizeof(Work_s), WORK_InitHigh); status = CONTROL_Startup( &WorkControlLow, WORK_COUNT_LOW, - sizeof(Work_s), (voidfunc_t)WORK_InitLow); + sizeof(Work_s), WORK_InitLow); #if NSS_DEBUG IS_ENABLED FSMLITE_INIT( &gNSSThreadTestWorkToDoFsm /* Lite FSM */, @@ -326,7 +327,7 @@ void WORK_WaitForPending() #ifdef __linux__ if (PendingWork != okCount) { - LB_aprintf(0, ".........PendingWork=%d okCount=%d, delayCount=%d\n", PendingWork, okCount, delayCount); + printk("<1>" ".........PendingWork=%d okCount=%d, delayCount=%d\n",PendingWork,okCount,delayCount); } #else zASSERT(PendingWork == okCount); @@ -373,7 +374,7 @@ void WORK_Schedule (FsmLite_s *fsm, voidfunc_t action, ADDR parameter) INC_HISTOGRAM(WorkControl.histogram); - fsm->action = (voidfunc_t)action; + fsm->action = action; fsm->param.user = parameter; STK_POP(WorkControl.head.freeList, fake, FakeControl_s, link); @@ -388,10 +389,10 @@ void WORK_Schedule (FsmLite_s *fsm, voidfunc_t action, ADDR parameter) //Yield(); // I hate this. Paul T. } else - { + { PendingWork++; work = (Work_s *)&fake->link; - work->fsm = fsm; + work->fsm = fsm; ScheduleWork(work); } RTN_VOID(); @@ -411,7 +412,7 @@ void WORK_Schedule_HIGH (FsmLite_s *fsm, voidfunc_t action, ADDR parameter) ENTER(TFSM, WORK_Schedule); INC_HISTOGRAM(WorkControlHigh.histogram); - fsm->action = (voidfunc_t)action; + fsm->action = action; fsm->param.user = parameter; STK_POP(WorkControlHigh.head.freeList, fake, FakeControl_s, link); @@ -429,8 +430,8 @@ void WORK_Schedule_HIGH (FsmLite_s *fsm, voidfunc_t action, ADDR parameter) { PendingWork++; work = (Work_s *)&fake->link; - work->fsm = fsm; -#if zLINUX && !defined(NSS_USERSPACE) + work->fsm = fsm; +#if zLINUX MPKNSS_UNLOCK(); kSchedulePrioWorkToDo((struct WorkToDoStructure *)work); MPKNSS_LOCK(); @@ -449,7 +450,7 @@ void WORK_Schedule_HIGH (FsmLite_s *fsm, voidfunc_t action, ADDR parameter) ***************************************************************************/ void WORK_Queue (FsmLite_s *fsm, voidfunc_t action, ADDR parameter) { - fsm->action = (voidfunc_t)action; + fsm->action = action; fsm->param.user = parameter; if (PendingWork > 0) @@ -461,7 +462,7 @@ void WORK_Queue (FsmLite_s *fsm, voidfunc_t action, ADDR parameter) { WORK_Schedule(fsm, action, parameter); } -} +} /************************************************************************** @@ -477,7 +478,7 @@ void WORK_Schedule_LOW (FsmLite_s *fsm, voidfunc_t action, ADDR parameter) ENTER(TFSM, WORK_Schedule); INC_HISTOGRAM(WorkControlLow.histogram); - fsm->action = (voidfunc_t)action; + fsm->action = action; fsm->param.user = parameter; STK_POP(WorkControlLow.head.freeList, fake, FakeControl_s, link); @@ -491,7 +492,7 @@ void WORK_Schedule_LOW (FsmLite_s *fsm, voidfunc_t action, ADDR parameter) { PendingWork++; work = (Work_s *)&fake->link; - work->fsm = fsm; + work->fsm = fsm; ScheduleWork(work); } RTN_VOID(); @@ -525,7 +526,7 @@ void WORK_Run (Work_s *work) MSGNot("Scheduling WORK (Thread=%08x)\n"),ThreadId())); } #endif - ((void (*)(FsmLite_s *, ADDR))fsm->action)(fsm, fsm->param.user); + fsm->action(fsm, fsm->param.user); CHECK_INTERRUPTS(); DEC_HISTOGRAM(WorkControl.histogram); @@ -660,7 +661,7 @@ void WORK_RunHigh (Work_s *work) MSGNot("Scheduling WORK (Thread=%08x)\n"),ThreadId())); } #endif - ((void (*)(FsmLite_s *, ADDR))fsm->action)(fsm, fsm->param.user); + fsm->action(fsm, fsm->param.user); CHECK_INTERRUPTS(); DEC_HISTOGRAM(WorkControlHigh.histogram); @@ -721,7 +722,7 @@ void WORK_RunLow (Work_s *work) MSGNot("Scheduling WORK (Thread=%08x)\n"),ThreadId())); } #endif - ((void (*)(FsmLite_s *, ADDR))fsm->action)(fsm, fsm->param.user); + fsm->action(fsm, fsm->param.user); CHECK_INTERRUPTS(); DEC_HISTOGRAM(WorkControlLow.histogram); @@ -758,3 +759,4 @@ void WORK_RunLow (Work_s *work) } } } + diff --git a/src/nwnss/nss/dbgView.c b/src/nwnss/nss/dbgView.c new file mode 100644 index 0000000..d108e7c --- /dev/null +++ b/src/nwnss/nss/dbgView.c @@ -0,0 +1,2110 @@ +/**************************************************************************** + | + | (C) Copyright 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: gpachner $ + | $Date: 2006-11-02 22:23:15 +0530 (Thu, 02 Nov 2006) $ + | + | $RCSfile$ + | $Revision: 1606 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | All NSS specific assembly debugger commands. + +-------------------------------------------------------------------------*/ +#include /* NetWare includes */ +#include +#include + +#include +#include /* NSS Library includes */ +#include +#include +#include +#include +#include +#include +#include + +#include "zPublics.h" +#include "comnBeasts.h" +#include "pssmpk.h" +#include "zError.h" +#include "comnPublics.h" +#include "sdNSS.h" +#include "dbgView.h" +#include "xmlNSS.h" +#include /* For "-?" command */ + + +#if zNETWARE +extern BOOL DBG_EnteredDebugger; +void DBG_TranslateError( + struct ScreenStruct *debugScreen, + char **commandL, + struct StackFrame *stackFrame ); +void DBG_DisplayNCPLog( + struct ScreenStruct *debugScreen); + +/* + * Used by DBG_CV_Register to track the owners that have registered + * to support the '=v' command. The owners register that subcommands + * (i.e. structures) that they can display. + * + */ +CommandViewInfo_s *DBG_CV_Infos[4]; + +ADDR CVO_Stuff; +BOOL CVO_XMLColor = TRUE; +BOOL CVO_XMLMode = FALSE; +char CVO_Types[256]; +char CVO_Names[256]; +char CVO_TypesDefault[256] = {'*', 0,}; /* Last setting via command line */ +char CVO_NamesDefault[256] = {'*', 0,}; /* Last setting via command line */ + + + +BOOL matchit( + char *w, + char *n ) +{ + while( *n ) + { + switch( *w ) + { + case '\0' : + return( FALSE ); + case '*' : + while ( *(w+1) == '*' ) + { + ++w; + } + if ( matchit( (w+1), n ) ) + { + return( TRUE ); + } + ++n; + break; + default : + if( (*w == *n) || (*w == '?') ) + { + ++w; + ++n; + break; + } + return( FALSE ); + } + } + while( *w == '*' ) + { + ++w; + } + if ( *w == '\0' ) + { + return( TRUE ); + } + return( FALSE ); + +} + + +/* + * + * Returns + * TRUE = name matches the wildcard string + */ +BOOL wmatch( + char *wild, /* Wildcard string */ + char *name ) /* Name to match */ + +{ + + if ( *wild == '^' ) + { + ++wild; + return( !matchit(wild,name) ); + } + return( matchit(wild,name) ); + +} + + +STATUS DBG_CV_Register( + CommandViewInfo_s *cvi ) /* Pointer must be valid UNTIL after unregister is called */ +{ + unsigned int owners; + + for ( owners = 0; owners < NELEMS( DBG_CV_Infos ); ++owners ) + { + if ( DBG_CV_Infos[owners] == NULL ) + { + DBG_CV_Infos[owners] = cvi; + cvi->CVI_Index = owners; + return( zOK ); + } + } + return( zERR_NO_MEMORY ); +} + + +STATUS DBG_CV_Unregister( + CommandViewInfo_s *cvi ) /* Pointer must be valid UNTIL after unregister is called */ + +{ + + if ( DBG_CV_Infos[cvi->CVI_Index] != cvi ) + { + return( zERR_NWCS_NOT_THE_OWNER ); + } + DBG_CV_Infos[cvi->CVI_Index] = NULL; + return( zOK ); + +} + +SDM_Table_s *DBG_CV_GetNextInATable( + SDM_Table_s *table, + char *currentName ) +{ + unsigned int i; + + for ( i = 0; table[i].ST_Name != NULL; ++i ) + { + if ( stricmp( currentName, table[i].ST_Name ) < 0 ) + { + return( &table[i] ); + } + } + return( NULL ); + +} + + +SDM_Table_s *DBG_CV_GetNextInATableSize( + SDM_Table_s *table, + SIZEOF currentSize, + unsigned int match ) +{ + unsigned int i; + + for ( i = 0; table[i].ST_Name != NULL; ++i ) + { + if ( currentSize == table[i].ST_SizeOf ) + { + if ( match == 0 ) + { + return( &table[i] ); + } + --match; + } + } + return( NULL ); + +} + + +SDM_Table_s *DBG_CV_GetNextInATableSizeAndName( + SDM_Table_s *table, + SIZEOF currentSize, + char *currentName ) +{ + unsigned int i; + SDM_Table_s *cTableEntry; + SIZEOF bestSize = UINT_MAX; + unsigned int match = 0; + + for ( ;; ) + { + cTableEntry = DBG_CV_GetNextInATableSize( table, currentSize, match ); + if ( cTableEntry == NULL ) + { + break; + } + if ( stricmp( currentName, cTableEntry->ST_Name ) < 0 ) + { + return( cTableEntry ); + } + ++match; + } + /* Done with entries of this size in this table */ + /* Get next biggest entry - must look at + * ALL items as not in size order. + */ + for ( i = 0; table[i].ST_Name != NULL; ++i ) + { + if ( currentSize < table[i].ST_SizeOf ) + { + if ( bestSize > table[i].ST_SizeOf ) + { + bestSize = table[i].ST_SizeOf; + cTableEntry = &table[i]; + } + } + } + return( cTableEntry ); + +} + + +SDM_Table_s *DBG_CV_GetNextInAllTables( + char *currentName, + CommandViewInfo_s **cvi ) + +{ + SDM_Table_s *currentTable; + SDM_Table_s *currentBest = NULL; + unsigned int owners; + + *cvi = NULL; + for ( owners = 0; owners < NELEMS( DBG_CV_Infos ); ++owners ) + { + if ( DBG_CV_Infos[owners] != NULL ) + { + currentTable = DBG_CV_GetNextInATable( DBG_CV_Infos[owners]->CVI_Table, currentName ); + if ( currentTable != NULL ) + { + if ( (currentBest == NULL) || (stricmp( currentTable->ST_Name, currentBest->ST_Name ) < 0) ) + { + currentBest = currentTable; + *cvi = DBG_CV_Infos[owners]; + } + } + } + } + return( currentBest ); + +} /* End of DBG_CV_GetNextInAllTables() */ + + +SDM_Table_s *DBG_CV_GetNextInAllTablesSize( + SIZEOF currentSize, + char *currentName, + CommandViewInfo_s **cvi ) + +{ + SDM_Table_s *currentTable; + SDM_Table_s *currentBest = NULL; + unsigned int owners; + + *cvi = NULL; + for ( owners = 0; owners < NELEMS( DBG_CV_Infos ); ++owners ) + { + if ( DBG_CV_Infos[owners] != NULL ) + { + currentTable = DBG_CV_GetNextInATableSizeAndName( DBG_CV_Infos[owners]->CVI_Table, currentSize, currentName ); + if ( currentTable != NULL ) + { + if ( (currentBest == NULL) || (currentTable->ST_SizeOf < currentBest->ST_SizeOf) || + ( (currentTable->ST_SizeOf == currentBest->ST_SizeOf) && (stricmp( currentTable->ST_Name, currentBest->ST_Name ) < 0) ) ) + { + currentBest = currentTable; + *cvi = DBG_CV_Infos[owners]; + } + } + } + } + return( currentBest ); + +} /* End of DBG_CV_GetNextInAllTablesSize() */ + + +STATUS DBG_CV_DisplayHelpAlpha( + struct ScreenStruct *screen ) + +{ + STATUS status; + LONG linesUsed = 0; + SDM_Table_s *cTable; + char *currentName = " "; + CommandViewInfo_s *cvi; + + for ( ;; ) + { + cTable = DBG_CV_GetNextInAllTables( currentName, &cvi ); + if ( cTable == NULL ) + { + break; + } + status = DBG_CV_DisplayItem( screen, cvi, cTable, &linesUsed ); + if ( status != zOK ) + { + return( status ); + } + currentName = cTable->ST_Name; + } + return( zOK ); + +} /* End of DBG_CV_DisplayHelpAlpha() */ + + +STATUS DBG_CV_DisplayHelpSize( + struct ScreenStruct *screen ) + +{ + STATUS status; + LONG linesUsed = 0; + SDM_Table_s *cTable; + char *currentName = " "; + SIZEOF currentSize = 0; + CommandViewInfo_s *cvi; + + for ( ;; ) + { + cTable = DBG_CV_GetNextInAllTablesSize( currentSize, currentName, &cvi ); + if ( cTable == NULL ) + { + break; + } + status = DBG_CV_DisplayItem( screen, cvi, cTable, &linesUsed ); + if ( status != zOK ) + { + return( status ); + } + currentName = cTable->ST_Name; + currentSize = cTable->ST_SizeOf; + } + return( zOK ); + +} /* End of DBG_CV_DisplayHelpSize() */ + + +STATUS DBG_CV_DisplayItem( + struct ScreenStruct *screen, + CommandViewInfo_s *cvi, + SDM_Table_s *table, + LONG *linesUsed ) + +{ + LONG stopDisplay; + + stopDisplay = DBG_CheckForPause( screen, linesUsed, 1); /* 1 is the number of lines we need to display */ + if ( stopDisplay ) + { /* User has request us to stop the output */ + return( zERR_USER_ABORTED ); + } + OutputToScreenWithAttribute( screen, CYAN, " %32s", table->ST_Name ); + OutputToScreenWithAttribute( screen, CYAN, " %5d", (unsigned int)table->ST_SizeOf ); + OutputToScreenWithAttribute( screen, LGREEN, " %s\n", cvi->CVI_OwnerName ); + return( zOK ); + +} /* End of DBG_CV_DisplayItem() */ + + + +/* + * Returns - + * -1 to indicate we DID not handle the command. + */ +STATUS DBG_CommandView( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame ) +{ + STATUS status = zERR_NOT_SUPPORTED; + +#if 0 + if ( CVO_Stuff != 0x7777 ) + { + if ( **commandL == 'c' ) + { /* Attempt to turn on the '=v' commands. */ + (*commandL)++; + status = DBG_CommandViewCommand( screen, commandL, stackFrame, TRUE ); + } + OutputToScreen( screen, MSGNot("Illegal command processed by NSS. Use '=h' to see a list of legal commands.\n")); + return( zERR_NOT_SUPPORTED ); + } +#endif + switch(**commandL) + { + case 'a': /* Display the structures that we handle (and their sizes) */ + (*commandL)++; + status = DBG_CommandViewAlpha( screen, commandL ); + break; +#if 0 + case 'c': /* Turn off the '=v' commands */ + (*commandL)++; + status = DBG_CommandViewCommand( screen, commandL, stackFrame, FALSE ); + break; +#endif + case 'h': /* Display help */ + (*commandL)++; + status = DBG_CommandViewHelp( screen, commandL ); + break; + case '?': /* Display the structures that we handle (and their sizes) */ + (*commandL)++; + status = DBG_CommandViewView( screen, commandL ); + break; + case 'o': /* Change display options */ + (*commandL)++; + status = DBG_CommandViewOption( screen, commandL ); + break; + case 's': /* Display the structures that we handle (and their sizes) */ + (*commandL)++; + status = DBG_CommandViewSize( screen, commandL ); + break; + case ' ': /* Real view command - see if we handle the 'subCommand' */ + (*commandL)++; + status = DBG_CommandViewMemory( screen, commandL, stackFrame ); + break; + default: + OutputToScreen( screen, MSGNot("Illegal command processed by NSS. Use '=h' to see a list of legal commands.\n")); + break; + } + if ( status != zOK ) + { + OutputToScreenWithAttribute( screen, LRED, " %lx(%ld) -- %s\n", status, status, (char *)GetErrorFromNumber(status) ); + } + return status; + +} /* End of DBG_CommandView() */ + + +#if MEM_KEEP_LIST IS_ENABLED +/* + * Code for "=?" NSS debugger command + * + * Returns - + */ +STATUS DBG_MemoryView( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame ) +{ + NINT allocChunks = 0; + NINT freeChunks = 0; + QUAD allocBytes = 0; + QUAD freeBytes = 0; + QUAD allocUserBytes = 0; + QUAD freeUserBytes = 0; + ADDR address; + MKL_Header_s *mkl; + BOOL found = FALSE; + NINT index; + NINT length; + BYTE buffer[514]; + + while (**commandL == ' ') + { /* Eat extra spaces */ + (*commandL)++; + } + if (CEvaluateNumericExpression( commandL, stackFrame, &address) != NULL) + { +// OutputToScreenWithAttribute( screen, LRED, " Required address bad or missing\n" ); +// return( FALSE ); + address = 0; /* Do statistics mode */ + } + + /* Go through allocated memory. This is also required when address is 0 + * because we need to gather up the statistics before we display them. + */ + DQ_FOREACH(&MKL_head, mkl, MKL_Header_s, MH_link) + { + allocChunks += 1; + length = SizeOfAllocBlock( mkl ); + allocBytes += length; + allocUserBytes += length - sizeof( *mkl ); + + if ( address < (ADDR)mkl ) + { + continue; + } + if ( address >= ( ((ADDR)mkl) + length ) ) + { + continue; + } + /* Found a match */ + found = TRUE; +// OutputToScreenWithAttribute( screen, LGREEN, "Address in NSS allocation space\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " Header: %8lX\n", (unsigned long)mkl ); + OutputToScreenWithAttribute( screen, LGREEN, " User: %8lX\n", (unsigned long)MKL_TO_UMEM(mkl) ); + OutputToScreenWithAttribute( screen, LGREEN, " Length: %8lX(%d)\n", + (unsigned long)SizeOfAllocBlock(mkl), + (unsigned long)SizeOfAllocBlock(mkl) ); + OutputToScreenWithAttribute( screen, LGREEN, " User length: %8lX(%d)\n", + (unsigned long)MKL_ORIG_SIZE(SizeOfAllocBlock(mkl)), + (unsigned long)MKL_ORIG_SIZE(SizeOfAllocBlock(mkl)) ); + OutputToScreenWithAttribute( screen, LGREEN, " Allocated at %8lX\n", (unsigned long)mkl->MH_allocTime ); + +// OutputToScreenWithAttribute(screen, LGREEN, MSGNot(" Alloc\n") ); + for ( index = 0; index < mkl->MH_allocCallersNumber; ++index ) + { + GetClosestSymbol(buffer, (LONG)mkl->MH_allocCallers[index]); + OutputToScreenWithAttribute(screen, LGREEN, + MSGNot(" %s"),buffer); + } + } + DQ_FOREACH(&MKL_FreeHead, mkl, MKL_Header_s, MH_link) + { + freeChunks += 1; + length = SizeOfAllocBlock( mkl ); + freeBytes += length; + freeUserBytes += length - sizeof( *mkl ); + if ( address < (ADDR)mkl ) + { + continue; + } + if ( address >= ( ((ADDR)mkl) + length ) ) + { + continue; + } + /* Found a match */ + found = TRUE; +// OutputToScreenWithAttribute( screen, LGREEN, "Address in NSS freed space\n" ); + OutputToScreenWithAttribute( screen, MAGENTA, " Header: %8lX\n", (unsigned long)mkl ); + OutputToScreenWithAttribute( screen, MAGENTA, " User: %8lX\n", (unsigned long)MKL_TO_UMEM(mkl) ); + OutputToScreenWithAttribute( screen, MAGENTA, " Length: %8lX(%d)\n", + (unsigned long)SizeOfAllocBlock(mkl), + (unsigned long)SizeOfAllocBlock(mkl) ); + OutputToScreenWithAttribute( screen, MAGENTA, " User length: %8lX(%d)\n", + (unsigned long)MKL_ORIG_SIZE(SizeOfAllocBlock(mkl)), + (unsigned long)MKL_ORIG_SIZE(SizeOfAllocBlock(mkl)) ); + OutputToScreenWithAttribute( screen, LGREEN, " Allocated at %8lX\n", (unsigned long)mkl->MH_allocTime ); + OutputToScreenWithAttribute( screen, MAGENTA, " Freed at %8lX\n", (unsigned long)mkl->MH_freeTime ); + +// OutputToScreenWithAttribute(screen, LGREEN, MSGNot(" Alloc\n") ); + for ( index = 0; index < mkl->MH_allocCallersNumber; ++index ) + { + GetClosestSymbol(buffer, (LONG)mkl->MH_allocCallers[index]); + OutputToScreenWithAttribute(screen, LGREEN, + MSGNot(" %s"),buffer); + } + +// OutputToScreenWithAttribute(screen, MAGENTA, MSGNot(" Free\n") ); + for ( index = 0; index < mkl->MH_freeCallersNumber; ++index ) + { + GetClosestSymbol(buffer, (LONG)mkl->MH_freeCallers[index]); + OutputToScreenWithAttribute(screen, MAGENTA, + MSGNot(" %s"),buffer); + } + } + + if ( !found ) + { + if ( address == 0 ) + { + OutputToScreenWithAttribute( screen, LGREEN, " NSS alloc statistics\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " Current allocated chunks %12d\n", allocChunks ); + OutputToScreenWithAttribute( screen, LGREEN, " Current free chunks %12d\n", freeChunks ); + OutputToScreenWithAttribute( screen, LGREEN, " Current allocBytes %12Ld\n", allocBytes ); + OutputToScreenWithAttribute( screen, LGREEN, " Current allocUserBytes %12Ld\n", allocUserBytes ); + OutputToScreenWithAttribute( screen, LGREEN, " Current freeBytes %12Ld\n", freeBytes ); + OutputToScreenWithAttribute( screen, LGREEN, " Current freeUserBytes %12Ld\n", freeUserBytes ); + } + else + { + OutputToScreenWithAttribute( screen, LRED, "Address not owned by NSS malloc\n" ); + } + } + + + return zOK; + +} /* End of DBG_MemoryView() */ +#endif + + +STATUS DBG_DisplayHelp( + struct ScreenStruct *screen, + char *tableName, + SDM_Table_s *table, + DFI_CallerOptions_s *co, + LONG *linesUsed ) + +{ + LONG stopDisplay; + unsigned int i; + + stopDisplay = DBG_CheckForPause( screen, linesUsed, 1); /* 1 is the number of lines we need to display */ + if ( stopDisplay ) + { /* User has request us to stop the output */ + return( zERR_USER_ABORTED ); + } + OutputToScreenWithAttribute( screen, LGREEN, "%s\n", tableName ); + for ( i = 0; table[i].ST_Name != NULL; ++i ) + { + stopDisplay = DBG_CheckForPause( screen, linesUsed, 1); /* 1 is the number of lines we need to display */ + if ( stopDisplay ) + { /* User has request us to stop the output */ + return( zERR_USER_ABORTED ); + } + OutputToScreenWithAttribute( screen, CYAN, " %30s", table[i].ST_Name ); + OutputToScreenWithAttribute( screen, CYAN, " %3x(%d)\n", (unsigned int)table[i].ST_SizeOf, (unsigned int)table[i].ST_SizeOf ); + } + return( zOK ); + +} /* End of DBG_DisplayHelp() */ + + +/* + * DBG_CommandViewHelp() - + * Implements debug command "=vh" + */ +STATUS DBG_CommandViewHelp( + struct ScreenStruct *screen, + char **commandL ) + +{ + + OutputToScreenWithAttribute( screen, MAGENTA, "'=v' Command Help\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " =vox Toggle XML output.\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " =voc Toggle Color output.\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " =vom MASK Change XML output contents.\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " 0001 name 0002 value 0004 type\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " 0008 address 0010 size 0020 index of array\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " =voa VALUE Change auth value used to unpack beasts.\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " 0 ZAS 1 Unix\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " =vh This help screen.\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " =v? List supported structures in module order.\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " =vs List supported structures in size order.\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " =va List supported structures in alpha order.\n" ); +#if 0 + OutputToScreenWithAttribute( screen, LGREEN, " =vc Turn off '=v' commands.\n" ); +#endif + OutputToScreenWithAttribute( screen, LGREEN, " =v ADDR STRUCT {NAME} {TYPE} Display structures.\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " Where ADDR is the address to display.\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " Where STRUCT is structure to display.\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " Where NAME is the WILDCARD to apply to elements names(case sensitive).\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " Where TYPE is the WILDCARD to apply to elements types(case sensitive).\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " Where WILDCARD is a optional '^' and then any characters or '*' or '?'.\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " For example,\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " To display only items with a name with zid use '=v addr file_s *zid*'.\n" ); + OutputToScreenWithAttribute( screen, LGREEN, " To display only items of type Zid_t use '=v addr Pool_s * Zid_t'.\n" ); + return( zOK ); + +} + + +/* + * DBG_CommandViewView() - + * Implements debug command "=v?" + */ +STATUS DBG_CommandViewView( + struct ScreenStruct *screen, + char **commandL ) + +{ + STATUS status; + LONG linesUsed = 0; + unsigned int owners; + + for ( owners = 0; owners < NELEMS( DBG_CV_Infos ); ++owners ) + { + if ( DBG_CV_Infos[owners] != NULL ) + { + status = DBG_DisplayHelp( screen, DBG_CV_Infos[owners]->CVI_OwnerName, DBG_CV_Infos[owners]->CVI_Table, NSSCo, &linesUsed ); + if ( status != zOK ) + { + return( status ); + } + } + } + return( zOK ); + +} + + +/* + * DBG_CommandViewAlpha() - + * Implements debug command "=va" + */ +STATUS DBG_CommandViewAlpha( + struct ScreenStruct *screen, + char **commandL ) + +{ + STATUS status; + + status = DBG_CV_DisplayHelpAlpha( screen ); + return( status ); + +} + + + +/* + * DBG_CommandViewSize() - + * Implements debug command "=vs" + */ +STATUS DBG_CommandViewSize( + struct ScreenStruct *screen, + char **commandL ) + +{ + STATUS status; + + status = DBG_CV_DisplayHelpSize( screen ); + return( status ); + +} + + +#define MMU_SUPERVISOR_READ 5 +#define MMU_ERROR -1 +extern LONG ValidateAddressRangePresent(void *address, LONG range, LONG flag); + + +/* START -- Taken from OS cdebug.c */ +#define DEFAULT_LINES_PER_SCREEN 24 + +/* + * Returns - + * 0 - Continue else Stop output. + */ +LONG DBG_CheckForPause( + struct ScreenStruct *screen, + LONG *linesUsed, + LONG linesNeeded) +{ + if (((*linesUsed + linesNeeded) > DEFAULT_LINES_PER_SCREEN) || + (linesNeeded == 0)) + { +#if NSS_DEBUG IS_ENABLED +//DBG_DebugPrintf( CYAN, "%s\n", WHERE ); +#endif + if (PauseWithEscape(screen) != NULL) + { + return (-1); + } + else + { + *linesUsed = linesNeeded; + return (0); + } + } + *linesUsed += linesNeeded; + return (0); +} +/* END -- Taken from OS cdebug.c */ + + +/* + * SNP_Display2() - + * Displays the contents of the SNP_PrintBuffer_s to the specified screen. + * + */ +STATUS SNP_Display2( + struct ScreenStruct *screen, + char *where, + SNP_PrintBuffer_s *pb) + +{ + STATUS status = zOK; + + if ( (pb->SPB_Data != NULL) && (pb->SPB_StringLength != 0) ) + { + status = SNP_DisplayWithPause( screen, where, pb->SPB_Data ); + } + return( status ); + +} /* End of SNP_Display2() */ + + +/* + * SNP_DisplayWithPause() - + * Displays the contents of the specified string to the specified screen. + * + * Notes - + * We do not handle '\r\n'. Use '\n' only!!! + * + */ +STATUS SNP_DisplayWithPause( + struct ScreenStruct *screen, + char *where, + char *data) /* NULL terminate string */ + +{ + STATUS status; + LONG linesUsed = 0; + BOOL stopDisplay; + char oldChar; + char *lineEnd; + char *lineStart; + NINT count; /* Number of characters in current line. Does + * not include '\n' in count. + */ + +#if NSS_DEBUG IS_ENABLED + /* This gets all the display into the =d buffer which + * allows user to 'serach' for a specific item. + */ + if ( strlen( data ) < (0x8000-10) ) + { /* Function only handle ~32K strings */ + DBG_DebugPrintf( CYAN, "%s\n", data ); + } +#endif + /* Print a line at a time so that we can pause */ + for ( lineStart = data, lineEnd = lineStart; TRUE; lineEnd = lineStart ) + { + count = 0; + /* We do not handle '\r\n'. Use '\n' only!!! */ + while ( (*lineEnd != '\n') && (*lineEnd != 0) && (count < 80) ) + { + ++count; + ++lineEnd; + } + + stopDisplay = DBG_CheckForPause( screen, &linesUsed, 1); /* 1 is the number of lines we need to display */ + if ( stopDisplay ) + { /* User has request us to stop the output */ + return( zERR_USER_ABORTED ); + } + oldChar = *lineEnd; + /*** START - do not exit without restoring oldChar ***/ + *lineEnd = 0; +#if NSS_DEBUG IS_ENABLED +// DBG_DebugPrintf( CYAN, "%s linesUsed %d Count %d OldChar %d lineend+1 %d\n", WHERE, linesUsed, count, oldChar, (*(lineEnd+1)) ); +#endif + if ( (count == 0) && (oldChar == NULL) ) + { /* At end with nothing to display */ + status = zOK; + break; + } + /*** Have something to display so do it ***/ + OutputToScreen( screen, "%s", lineStart ); + lineStart = lineEnd; + if ( count == 80 ) + { /* NetWare did a '\n' for us */ + if ( oldChar == '\n' ) + { /* Had 80 chars then a '\n', we need to eat the \n */ + ++lineStart; + } + } + else + { + OutputToScreen( screen, "\n" ); + if ( (oldChar == '\n') && (count != 0) ) + { + ++lineStart; + } + } + if ( oldChar == NULL ) + { + status = zOK; + break; + } + + *lineEnd = oldChar; + /*** END - do not exit without restoring oldChar ***/ + } + return( zOK ); + +} /* End of SNP_DisplayWithPause() */ + + +//#define DEBUG_SNP_Display3_1 + +STATUS SNP_Display3_1( + struct ScreenStruct *screen, + SNP_PrintBuffer_s *pb, + utf8_t *searchStart, + utf8_t *searchEnd, + NINT displayLevel, + NINT *currentLevel, + NINT *column, + LONG *linesUsed ) + +{ + BOOL display; + STATUS status; + utf8_t oldChar; + utf8_t *tagName; + NINT tagLen; + unsigned long indexValue; + LONG stopDisplay; + XML_ElementInfo_s actionElement; +#ifdef DEBUG_SNP_Display3_1 + static char stuff[1234]; +#endif + + *currentLevel += 1; +#ifdef DEBUG_SNP_Display3_1 +OutputToScreenWithAttribute( screen, LRED, ">%d>", *currentLevel ); +OutputToScreenWithAttribute( screen, LRED, "start 0x%lx End 0x%lx", searchStart, searchEnd ); +#endif + for(;;) + { + utf8_t *name = NULL; + utf8_t *nameEnd = NULL; + NINT realNameLen = 0; + NINT nameLen = 0; + + display = TRUE; /* Default is to display */ + if (XML_GetNextTag(searchStart, searchEnd, + &actionElement, &tagName, &tagLen) != zOK) + { +#ifdef DEBUG_SNP_Display3_1 + OutputToScreenWithAttribute( screen, LRED, "<%s>", WHERE ); +#endif + break; /* we have all of the elements */ + } +#ifdef DEBUG_SNP_Display3_1 + strncpy( &stuff, tagName, tagLen ); + stuff[tagLen] = '\0'; + OutputToScreenWithAttribute( screen, LRED, "", stuff ); + OutputToScreenWithAttribute( screen, MAGENTA, "start 0x%lx End 0x%lx", actionElement.dataStart, actionElement.dataEnd ); + OutputToScreenWithAttribute( screen, BLUE, " End 0x%lx", actionElement.elementEnd ); +#endif + if (memcmp(tagName, "Basic", tagLen) == 0) + { + utf8_t *value = NULL; + utf8_t *date = NULL; + utf8_t *valueEnd = NULL; + utf8_t *dateEnd = NULL; + NINT valueLen = 0; + NINT dateLen = 0; + NINT indexLen; + char indexString[24]; + + if ( XML_GetTagAttribute( "Index", &actionElement) == zOK ) + { + + oldChar = *(actionElement.attributeValueEnd + 1); + *(actionElement.attributeValueEnd + 1) = '\0'; + indexValue = strtoul( actionElement.attributeValueStart, NULL, 10 ); + *(actionElement.attributeValueEnd + 1) = oldChar; + sprintf( indexString, "[%lu]", indexValue ); + indexLen = strlen(indexString); + } + else + { + indexString[0] = '\0'; + indexLen = 0; + } + if ( XML_GetTagAttribute( "Name", &actionElement) == zOK ) + { + name = actionElement.attributeValueStart; + nameEnd = actionElement.attributeValueEnd; + realNameLen = actionElement.attributeValueEnd - actionElement.attributeValueStart + 1; + nameLen = realNameLen + 0; + oldChar = *(nameEnd + 1); + *(nameEnd + 1) = '\0'; + if ( display ) + { + display = wmatch( CVO_Names, name ); + } + *(nameEnd + 1) = oldChar; + } + if ( XML_GetTagAttribute( "Value", &actionElement) == zOK ) + { + value = actionElement.attributeValueStart; + valueEnd = actionElement.attributeValueEnd; + valueLen = actionElement.attributeValueEnd - actionElement.attributeValueStart + 1 + 3; /* 3 for " - " */ + } + if ( XML_GetTagAttribute( "Date", &actionElement) == zOK ) + { + date = actionElement.attributeValueStart; + dateEnd = actionElement.attributeValueEnd; + dateLen = actionElement.attributeValueEnd - actionElement.attributeValueStart + 1 + 2; /* 2 for "()" */ + } + if ( XML_GetTagAttribute( "Type", &actionElement) == zOK ) + { + utf8_t *type; + utf8_t *typeEnd; + + type = actionElement.attributeValueStart; + typeEnd = actionElement.attributeValueEnd; + oldChar = *(typeEnd + 1); + *(typeEnd + 1) = '\0'; + if ( display ) + { + display = wmatch( CVO_Types, type ); + } + *(nameEnd + 1) = oldChar; + } + if ( display ) + { + *column = *column + dateLen + valueLen + nameLen + indexLen + 1; + if ( *column >= 80 ) /* FixFixFix - should not be hard coded */ + { + OutputToScreenWithAttribute( screen, YELLOW, "\n" ); + stopDisplay = DBG_CheckForPause( screen, linesUsed, 1); /* 1 is the number of lines we need to display */ + if ( stopDisplay ) + { /* User has request us to stop the output */ + *currentLevel -= 1; + return( zERR_USER_ABORTED ); + } + *column = dateLen + valueLen + nameLen + indexLen + 1; + } + if ( name ) + { + oldChar = *(nameEnd + 1); + *(nameEnd + 1) = '\0'; + OutputToScreenWithAttribute( screen, YELLOW, "%s%s", name, indexString ); + *(nameEnd + 1) = oldChar; + } + if ( value ) + { + oldChar = *(valueEnd + 1); + *(valueEnd + 1) = '\0'; + OutputToScreenWithAttribute( screen, CYAN, " - %s", value ); + *(valueEnd + 1) = oldChar; + } + if ( date ) + { + oldChar = *(dateEnd + 1); + *(dateEnd + 1) = '\0'; + OutputToScreenWithAttribute( screen, LGREEN, "(%s)", date ); + *(dateEnd + 1) = oldChar; + } + OutputToScreenWithAttribute( screen, YELLOW, " " ); + } + + } + else if (memcmp(tagName, "Structure", tagLen) == 0) + { + if ( XML_GetTagAttribute( "Name", &actionElement) == zOK ) + { + name = actionElement.attributeValueStart; + nameEnd = actionElement.attributeValueEnd; + realNameLen = actionElement.attributeValueEnd - actionElement.attributeValueStart + 1; + nameLen = realNameLen + 2; /* 2 for the spaces */ + *column = *column + nameLen; + if ( *column >= 80 ) /* FixFixFix - should not be hard coded */ + { + OutputToScreenWithAttribute( screen, YELLOW, "\n" ); + stopDisplay = DBG_CheckForPause( screen, linesUsed, 1); /* 1 is the number of lines we need to display */ + if ( stopDisplay ) + { /* User has request us to stop the output */ + *currentLevel -= 1; + return( zERR_USER_ABORTED ); + } + *column = nameLen; + } + oldChar = *(actionElement.attributeValueEnd + 1); + *(actionElement.attributeValueEnd + 1) = '\0'; + OutputToScreenWithAttribute( screen, LGREEN, " %s ", actionElement.attributeValueStart ); + *(actionElement.attributeValueEnd + 1) = oldChar; + } + } + else if (memcmp(tagName, "Union", tagLen) == 0) + { + if ( XML_GetTagAttribute( "Name", &actionElement) == zOK ) + { + name = actionElement.attributeValueStart; + nameEnd = actionElement.attributeValueEnd; + realNameLen = actionElement.attributeValueEnd - actionElement.attributeValueStart + 1; + nameLen = realNameLen + 2; /* 2 for the spaces */ + *column = *column + nameLen; + if ( *column >= 80 ) /* FixFixFix - should not be hard coded */ + { + OutputToScreenWithAttribute( screen, YELLOW, "\n" ); + stopDisplay = DBG_CheckForPause( screen, linesUsed, 1); /* 1 is the number of lines we need to display */ + if ( stopDisplay ) + { /* User has request us to stop the output */ + *currentLevel -= 1; + return( zERR_USER_ABORTED ); + } + *column = nameLen; + } + oldChar = *(actionElement.attributeValueEnd + 1); + *(actionElement.attributeValueEnd + 1) = '\0'; + OutputToScreenWithAttribute( screen, LGREEN, " %s ", actionElement.attributeValueStart ); + *(actionElement.attributeValueEnd + 1) = oldChar; + } + } + if ( actionElement.dataStart != NULL ) + { /* Process nested Tags */ + status = SNP_Display3_1( screen, pb, actionElement.dataStart, actionElement.dataEnd, displayLevel, currentLevel, column, linesUsed ); + if ( status != zOK ) + { + *currentLevel -= 1; + return( status ); + } + if ( name ) + { /* Display a ending nested tag label */ + *column = *column + realNameLen + 2; /* Two is for spaces */ + if ( *column >= 80 ) /* FixFixFix - should not be hard coded */ + { + OutputToScreenWithAttribute( screen, YELLOW, "\n" ); + stopDisplay = DBG_CheckForPause( screen, linesUsed, 1); /* 1 is the number of lines we need to display */ + if ( stopDisplay ) + { /* User has request us to stop the output */ + *currentLevel -= 1; + return( zERR_USER_ABORTED ); + } + *column = realNameLen + 2; /* Two is for spaces */ + } + oldChar = *(nameEnd + 1); + *(nameEnd + 1) = '\0'; + OutputToScreenWithAttribute( screen, GREEN, " %s ", name ); + *(nameEnd + 1) = oldChar; + } + } + searchStart = actionElement.elementEnd + 1; +#ifdef DEBUG_SNP_Display3_1 + OutputToScreenWithAttribute( screen, LRED, "=%d= start 0x%lx End 0x%lx", *currentLevel, searchStart, searchEnd ); +#endif + } +#ifdef DEBUG_SNP_Display3_1 + OutputToScreenWithAttribute( screen, LRED, "<%d<", *currentLevel ); +#endif + *currentLevel -= 1; + return( zOK ); + +} /* End of SNP_Display3_1() */ + + +/* + * SNP_Display3() - + * Displays the contents of the SNP_PrintBuffer_s to the specified screen. + * Only NAMES and VALUES are displayed. And only those that match the + * wildcard lists CVO_Names and CVO_Types. + * + */ +STATUS SNP_Display3( + struct ScreenStruct *screen, + char *where, + SNP_PrintBuffer_s *pb) + +{ + NINT displayLevel = 9; + NINT currentLevel = 0; + NINT column = 0; + LONG linesUsed = 1; /* Normally this would be 0, but + * because we dont ask to pause + * until AFTER we display a line + * we need to set to one. + */ + + if ( (pb->SPB_Data != NULL) && (pb->SPB_StringLength != 0) ) + { + SNP_Display3_1( screen, pb, pb->SPB_Data, pb->SPB_Data+pb->SPB_StringLength-1, displayLevel, ¤tLevel, &column, &linesUsed ); + OutputToScreenWithAttribute( screen, CYAN, "\n" ); + } + return( zOK ); + +} /* End of SNP_Display3() */ + + +/* + * DBG_CommandViewOptionMask() - + * Implements debug command "=vom" + * + * Change the options of what is displayed. For a complete + * list see the DCO_DETAILS_xxx defines. + * + * For Example, given + 0x0001 Output names of elements. + 0x0002 Output value of elements. + 0x0004 Output type of elements. + 0x0008 Output address information of elements. + 0x0010 Output size information of elements. + 0x0020 Output index information of elements. + * Then a value of + * 1C would display size, address and type + */ +STATUS DBG_CommandViewOptionMask( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame ) + +{ + ADDR detailsMask; + + while (**commandL == ' ') + { /* Eat extra spaces */ + (*commandL)++; + } + if (CEvaluateNumericExpression( commandL, stackFrame, &detailsMask) != NULL) + { + OutputToScreenWithAttribute( screen, LRED, "Invalid details mask syntax\n"); + return( zERR_NOT_SUPPORTED ); + } + /* Change the display options */ + NSSCo->DCO_Details = detailsMask; + return( zOK ); + +} /* End of DBG_CommandViewOptionMask() */ + + +/* + * DBG_CommandViewOptionAuth() - + * Implements debug command "=voa" + * + * Changes between ZAS and Unix as the format of the auth information + * in a beast. I.E. for us to display a beast tree leaf correctly we + * need to be told if the leaf contains ZAS or Unix packed auth data. + * + * For Example, given + * 0x0000 ZAS. + * 0x0001 Unix. + */ +STATUS DBG_CommandViewOptionAuth( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame ) + +{ + ADDR detailsMask; + + while (**commandL == ' ') + { /* Eat extra spaces */ + (*commandL)++; + } + if (CEvaluateNumericExpression( commandL, stackFrame, &detailsMask) != NULL) + { + OutputToScreenWithAttribute( screen, LRED, "Invalid Auth System\n"); + return( zERR_NOT_SUPPORTED ); + } + /* Change the display options */ + NSSCo->DCO_AuthType = detailsMask; + return( zOK ); + +} /* End of DBG_CommandViewOptionAuth() */ + + +/* + * DBG_CommandViewOptionTypes() - + * Handles debug command "=vot" + */ +STATUS DBG_CommandViewOptionTypes( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame ) + +{ + + while (**commandL == ' ') + { /* Eat extra spaces */ + (*commandL)++; + } + strncpy( CVO_TypesDefault, *commandL, sizeof(CVO_TypesDefault) ); + CVO_TypesDefault[ NELEMS(CVO_TypesDefault) - 1 ] = '\0'; + return( zOK ); + +} /* End of DBG_CommandViewOptionTypes() */ + +/* + * DBG_CommandViewOptionColor() - + * Implements debug command "=voc" + */ +STATUS DBG_CommandViewOptionColor( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame ) + +{ + + CVO_XMLColor = !CVO_XMLColor; + OutputToScreenWithAttribute( screen, LGREEN, "Color mode is now %s\n", CVO_XMLColor ? "on" : "off" ); + return( zOK ); + +} /* End of DBG_CommandViewOptionColor() */ + + +STATUS DBG_CommandViewOptionXML( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame ) + +{ + + CVO_XMLMode = !CVO_XMLMode; + OutputToScreenWithAttribute( screen, LGREEN, "XML mode is now %s\n", CVO_XMLMode ? "on" : "off" ); + return( zOK ); + +} /* End of DBG_CommandViewOptionXML() */ + + +STATUS DBG_CommandViewOptionNames( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame ) + +{ + + while (**commandL == ' ') + { /* Eat extra spaces */ + (*commandL)++; + } + strncpy( CVO_NamesDefault, *commandL, sizeof(CVO_NamesDefault) ); + CVO_NamesDefault[ NELEMS(CVO_NamesDefault) - 1 ] = '\0'; + return( zOK ); + +} /* End of DBG_CommandViewOptionNames() */ + + +/* + * DBG_CommandViewOption() - + * Handles all debug command "=vo*" + */ +STATUS DBG_CommandViewOption( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame ) + +{ + STATUS status = zERR_NOT_SUPPORTED; + + switch(**commandL) + { + case 'a': /* Changes auth model type to use in unpack of auth beasts */ + (*commandL)++; + status = DBG_CommandViewOptionAuth( screen, commandL, stackFrame ); + break; + case 'c': /* Toogles on/off Color mode (default is on) */ + (*commandL)++; + status = DBG_CommandViewOptionColor( screen, commandL, stackFrame ); + break; + case 'm': /* Change XML output masks */ + (*commandL)++; + status = DBG_CommandViewOptionMask( screen, commandL, stackFrame ); + break; + case 'n': /* Display the structures that we handle (and their sizes) */ + (*commandL)++; + status = DBG_CommandViewOptionNames( screen, commandL, stackFrame ); + break; + case 't': /* Change display options */ + (*commandL)++; + status = DBG_CommandViewOptionTypes( screen, commandL, stackFrame ); + break; + case 'x': /* Toogles on/off XML mode (default is off) */ + (*commandL)++; + status = DBG_CommandViewOptionXML( screen, commandL, stackFrame ); + break; + default: + OutputToScreen( screen, MSGNot("Illegal '=vo' command processed by NSS. Use '=h' to see a list of legal commands.\n")); + break; + } + if ( status != zOK ) + { + OutputToScreenWithAttribute( screen, LRED, " %lx(%ld) -- %s\n", status, status, (char *)GetErrorFromNumber(status) ); + } + return status; + +} /* End of DBG_CommandViewOption() */ + + +#if 0 +STATUS DBG_CommandViewCommand( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame, + BOOL onAttempt ) + +{ + ADDR address; + + while (**commandL == ' ') + { /* Eat extra spaces */ + (*commandL)++; + } + if ( onAttempt ) + { + if (CEvaluateNumericExpression( commandL, stackFrame, &address) != NULL) + { + return( FALSE ); + } + CVO_Stuff = address; + return( zOK ); + } + CVO_Stuff = 0; + return( zOK ); +} +#endif + + +/* + * DBG_CommandViewMemory() - + * Implements debug command "=v" + */ +STATUS DBG_CommandViewMemory( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame ) + +{ + char subCommand[256]; + ADDR address; + BOOL parsedOK; + STATUS status; + NINT addressBytes = 4096*2; /* ZlogBeast is on the 4000+ range */ + unsigned int owners; + + parsedOK = DBG_CommandViewMemoryParse( screen, commandL, stackFrame, + subCommand, sizeof( subCommand ), &address ); + if ( !parsedOK ) + { + return( zERR_NOT_SUPPORTED ); + } + + /* FixFixFix - Validate address and get correct size */ + /* FixFixFix - Validate address and get correct size */ + /* FixFixFix - Validate address and get correct size */ + + if ( ValidateAddressRangePresent((void *)address, 4, + MMU_SUPERVISOR_READ) == MMU_ERROR) + { + OutputToScreenWithAttribute( screen, LRED, "%s %lx\n", WHERE, address ); + return( zERR_BAD_ADDRESS ); + } + + for ( owners = 0; owners < NELEMS( DBG_CV_Infos ); ++owners ) + { + if ( DBG_CV_Infos[owners] != NULL ) + { + (void)SNP_DataDelete( WHERE, NSSCo->DCO_SNPOutput ); + /* Moved delete to here so I could debug contents of buffer */ + status = SDM_Display( screen, DBG_CV_Infos[owners]->CVI_Table, NSSCo, subCommand, 0, (BYTE *)address, addressBytes ); + if ( status == zOK ) + { /* Display to screen with pause */ + if ( CVO_XMLMode ) + { + (void)SNP_Display2( screen, WHERE, NSSCo->DCO_SNPOutput ); + } + if ( CVO_XMLColor ) + { + (void)SNP_Display3( screen, WHERE, NSSCo->DCO_SNPOutput ); + } + } +// (void)SNP_DataDelete( WHERE, NSSCo->DCO_SNPOutput ); + if ( status != zERR_OBJECT_NOT_FOUND ) + { + return( status ); + } + } + } + OutputToScreen( screen, MSGNot("Illegal '=v' subcommand ('%s'). Use '=vh' to see a list of legal subcommands.\n"),subCommand); + return( zOK ); + +} /* End of DBG_CommandViewMemory() */ + + + +/* + * Parses ' address structureName' of the '=v address structureName' command. + */ +BOOL DBG_CommandViewMemoryParse( + struct ScreenStruct *screen, + char **commandL, + struct StackFrame *stackFrame, + char *structureName, + unsigned int structureNameSize, /* Must be at least 3 */ + ADDR *address ) +{ + int index; + + while (**commandL == ' ') + { /* Eat extra spaces */ + (*commandL)++; + } +#if 0 + *address = (ADDR)strtoul( *commandL, commandL, 16 ); /* Base 16 is default for assembler debugger */ +#else + if (CEvaluateNumericExpression( commandL, stackFrame, address) != NULL) + { + OutputToScreenWithAttribute( screen, LRED, "Invalid address syntax\n"); + return( FALSE ); + } +#endif + + while (**commandL == ' ') + { /* Eat extra spaces */ + (*commandL)++; + } + + index = 0; + while ( (**commandL != ' ') && (**commandL != NULL) && (index < (structureNameSize - 2) ) ) + { /* Get 1st parameter - MUST be 'structure' name */ + structureName[ index ] = **commandL; + index++; + (*commandL)++; + } + structureName[index] = NULL; + + /*** All other parameters are OPTIONAL ***/ + + /* If options not present we use the default values. */ + strcpy( CVO_Names, CVO_NamesDefault ); + strcpy( CVO_Types, CVO_TypesDefault ); + + while (**commandL == ' ') + { /* Eat extra spaces */ + (*commandL)++; + } + + if ( **commandL == '\0' ) + { + return TRUE; + } + /** First OPTIONAL option is wildcard NAME pattern **/ + index = 0; + while ( (**commandL != ' ') && (**commandL != NULL) && (index < (sizeof(CVO_Names) - 2) ) ) + { /* Get 1st parameter - MUST be 'structure' name */ + CVO_Names[ index ] = **commandL; + index++; + (*commandL)++; + } + CVO_Names[index] = NULL; + + while (**commandL == ' ') + { /* Eat extra spaces */ + (*commandL)++; + } + + if ( **commandL == '\0' ) + { + return TRUE; + } + index = 0; + /** 2nd OPTIONAL option is wildcard TYPE pattern **/ + while ( (**commandL != ' ') && (**commandL != NULL) && (index < (sizeof(CVO_Types) - 2) ) ) + { + CVO_Types[ index ] = **commandL; + index++; + (*commandL)++; + } + CVO_Types[index] = NULL; + + return TRUE; + +} /* End of DBG_CommandViewMemoryParse() */ + + +#if 0 +/**************************************************************************** + * + * This function modifies the attributes of a volume + * + ****************************************************************************/ +STATUS MNSS_ProcessModifyVolumeInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + GeneralMsg_s genMsg; + ModifyInfoMsg_s modInfoMsg; + Volume_s *volume; + zVolumeInfo_s info; + XML_ElementInfo_s parmElement; + utf8_t *attrTagName; + NINT tagLen; + NINT i; + NINT bit; + NINT count; + NINT modifyInfoMask = 0; + utf8_t *searchStart; + unicode uniVolName[zMAX_COMPONENT_NAME]; + + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_VOLUMEQUOTA, TR_OPTIONAL}, + {TAG_ENABLEDATTRIBUTES, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + VOLUME_NAME = 0, + VOLUME_QUOTA = 1, + ENABLED_ATTRIBUTES = 2, + }; + + + enum + { + VOLA_YES_NO = 0, + VOLA_NO_YES = 1, + VOLA_SHRED = 2, + }; + + struct + { + utf8_t *tagName; + NINT tagLen; + NINT modBit; + NINT type; + } const attrTable [] = + { + {TAG_SALVAGE, 7, zATTR_SALVAGE, VOLA_YES_NO}, + {TAG_COMPRESSION, 11, zATTR_COMPRESSION, VOLA_YES_NO}, + {TAG_DIRECTORYQUOTA, 14, zATTR_DIR_QUOTAS, VOLA_YES_NO}, + {TAG_USERQUOTA, 9, zATTR_USER_SPACE_RESTRICTIONS, VOLA_YES_NO}, + {TAG_FLUSHFILES, 10, zATTR_HIGH_INTEGRITY, VOLA_YES_NO}, + {TAG_CFS_MASTER, 10, zATTR_CFS_MASTER, VOLA_YES_NO}, + {TAG_SHREDDING, 9, zATTR_SHRED_DATA, VOLA_SHRED}, + {TAG_MFL, 3, zATTR_MFL, VOLA_YES_NO}, + {TAG_SNAPSHOT, 8, zATTR_COW, VOLA_YES_NO}, + {TAG_BACKUP, 6, zATTR_DONT_BACKUP, VOLA_NO_YES}, + {TAG_MIGRATION, 9, zATTR_MIGRATION, VOLA_YES_NO}, + {TAG_USERTRANSACTION, 15, zATTR_USER_TRANSACTION, VOLA_YES_NO}, + {0}, + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* volume name */ + if ((status = LB_ByteToUnicode(NSS_UNI_CONVERSION_RAW, uniVolName, + NELEMS(uniVolName), tagContent[VOLUME_NAME].content, NULL)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + + info.features.enabled = 0; + info.features.enableModMask = 0; + + /* + * Match the next tag with possible volume attributes. + */ + if ((tagContent[ENABLED_ATTRIBUTES].flags & TR_TAG_FOUND) && + (tagContent[ENABLED_ATTRIBUTES].flags & TR_CONTENT_FOUND)) + { + searchStart = tagContent[ENABLED_ATTRIBUTES].element.dataStart; + while (XML_GetNextTag(searchStart, + tagContent[ENABLED_ATTRIBUTES].element.dataEnd, &parmElement, + &attrTagName, &tagLen) == zOK) + { + searchStart = parmElement.elementEnd + 1; + for(i = 0; attrTable[i].tagName != NULL; i++) + { + if ((tagLen == attrTable[i].tagLen) && + (memcmp(attrTagName, attrTable[i].tagName, tagLen) == 0)) + { /* we have a match */ + if (attrTable[i].type == VOLA_YES_NO || + attrTable[i].type == VOLA_NO_YES) + { /* needs an enabled attribute */ + if (XML_GetTagAttribute(ATR_ENABLED, &parmElement) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("A tag is missing attribute \""ATR_ENABLED"\"")); + status = zERR_XML_IS_BAD; + goto exit; + } + else + { + modifyInfoMask |= zMOD_VOL_ATTRIBUTES; + bit = attrTable[i].modBit; + if (parmElement.attributeValueLen == 3 && + memcmp(parmElement.attributeValueStart, MSGNot("yes"), 3) == 0) + { + info.features.enableModMask |= bit; + if (attrTable[i].type == VOLA_YES_NO) + { + info.features.enabled |= bit; + } + else + { + info.features.enabled &= ~bit; + } + } + else if (parmElement.attributeValueLen == 2 && + memcmp(parmElement.attributeValueStart, MSGNot("no"), 2) == 0) + { + info.features.enableModMask |= bit; + if (attrTable[i].type == VOLA_YES_NO) + { + info.features.enabled &= ~bit; + } + else + { + info.features.enabled |= bit; + } + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("attribute \""ATR_ENABLED"\" needs a yes/no value")); + status = zERR_XML_IS_BAD; + goto exit; + } + } + } + else if (attrTable[i].type == VOLA_SHRED) + { + if (XML_GetTagAttribute(ATR_COUNT, &parmElement) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("A tag is missing attribute \""ATR_COUNT"\"")); + status = zERR_XML_IS_BAD; + goto exit; + } + else + { + /* convert the input value to a number */ + modifyInfoMask |= zMOD_VOL_ATTRIBUTES; + *(parmElement.attributeValueEnd + 1) = 0; + count = atol(parmElement.attributeValueStart); + info.features.enableModMask |= zATTR_SHRED_DATA; + if (count > 0) + { + info.features.enabled |= zATTR_SHRED_DATA; + info.dataShreddingCount = count; + modifyInfoMask |= zMOD_VOL_DATA_SHREDDING_COUNT; + } + else + { + info.features.enabled &= ~zATTR_SHRED_DATA; + } + } + } + } + } + } + } + + if (tagContent[VOLUME_QUOTA].flags & TR_TAG_FOUND) + { + if (XML_GetTagAttribute(ATR_QUOTA, &tagContent[VOLUME_QUOTA].element) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("A tag is missing attribute \""ATR_QUOTA"\"")); + status = zERR_XML_IS_BAD; + goto exit; + } + else + { + *(tagContent[VOLUME_QUOTA].element.attributeValueEnd + 1) = 0; + if (strcmp(tagContent[VOLUME_QUOTA].element.attributeValueStart, + MSGNot("none")) == 0) + { + info.totalSpaceQuota = zLV_NO_QUOTA_SIZE; + } + else + { + /* convert the input value to a number */ + info.totalSpaceQuota = + atoq(tagContent[VOLUME_QUOTA].element.attributeValueStart); + } + modifyInfoMask |= zMOD_VOL_QUOTA; + } + } + + return zOK; +} + +/* + * XML_GetTagElementAtCurrentLevel() - + * Find the tag specified within the current level and returns + * info about the element. + * + * See Also - + * XML_GetTagElement + * + * Example - + * Passed in XML must look like the following + * + * 1 + * 2 + * 3 + * 4 + * 5 Error finding pool in NSS + * 6 + * 7 + * 8 + * 9 + * 10 zOK + * 11 + * 12 + * + * Then a search of would result in it not being found. If + * the XML passed in was lines 2 to 11 then the on lines + * 9 to 11 would be returned. + * + */ +typedef struct XML_ElementInfo_s +{ + utf8_t *startOfAttributes; + utf8_t *elementEnd; + utf8_t *dataStart; + utf8_t *dataEnd; + NINT dataLen; + utf8_t *attributeValueStart; + utf8_t *attributeValueEnd; + NINT attributeValueLen; +} XML_ElementInfo_s; + + +STATUS XML_GetTagElementAtCurrentLevel( + utf8_t *tagToFindString, + utf8_t *bufferStart, + utf8_t *bufferEnd, /* Address of last utf8_t */ + XML_ElementInfo_s *returnedInfo) +{ + STATUS status; + utf8_t *tagName; + NINT tagLen; + NINT tagToFindStringLen; + + tagToFindStringLen = strlen( tagToFindString ); + for ( ;; ) + { + status = XML_GetNextTag( bufferStart, bufferEnd, + returnedInfo, &tagName, &tagLen ); + if ( status != zOK ) + { + return( status ); + } + if ( tagLen == tagToFindStringLen ) + { + if ( memcmp( tagName, tagToFindString, tagLen ) == 0 ) + { + return( zOK ); + } + } + /* We skip over this tag (and any tags that may be nested + * in it). This is the magic line that allows us to skip + * over nested tags. + */ + bufferStart = returnedInfo->elementEnd + 1; + } + +} /* End of XML_GetTagElementAtCurrentLevel() */ + + + + utf8_t *tagName; + utf8_t *searchStart; + NINT tagLen; + XML_ElementInfo_s mainElement; + XML_ElementInfo_s actionElement; + + + searchStart = mainElement.dataStart; + for(;;) + { + if (XML_GetNextTag(searchStart, mainElement.dataEnd, + &actionElement, &tagName, &tagLen) != zOK) + { + break; /* we have all of the elements */ + } + searchStart = actionElement.elementEnd + 1; + + if (memcmp(tagName, "Basic", tagLen) == 0) + { + if ( XML_GetTagAttribute( "Name", &actionElement) == zOK ) + { + *(parmElement.attributeValueEnd + 1) = '\0'; + OutputToScreenWithAttribute( screen, YELLOW, "%s", parmElement.attributeValueStart ); + } + if ( XML_GetTagAttribute( "Value", &actionElement) == zOK ) + { + *(parmElement.attributeValueEnd + 1) = '\0'; + OutputToScreenWithAttribute( screen, CYAN, " - %s", parmElement.attributeValueStart ); + } + if ( XML_GetTagAttribute( "Date", &actionElement) == zOK ) + { + *(parmElement.attributeValueEnd + 1) = '\0'; + OutputToScreenWithAttribute( screen, LGREEN, "(%s)", parmElement.attributeValueStart ); + } + OutputToScreenWithAttribute( screen, YELLOW, " " ); + + } + else if (memcmp(tagName, "Structure", tagLen) == 0) + { + } + + } +#endif + + + + +#if NSS_DEBUG IS_ENABLED +/*************************************************************************** + * display debugger help + ***************************************************************************/ +STATIC void displayHelpDEBUG( + struct ScreenStruct *debugScreen) +{ + OutputToScreen(debugScreen, MSGNot("\n" + "NSS debug commands begin with '='\n" + " =d Dump the debug log to the screen\n" + " =e Translate decimal error number to string\n" + " =ex Translate hex evaluated error number to string\n" + " =h This help message\n" + " =lc Toggle if other latch commands display calling routines\n" + " =lh Display the latch holders\n" + " =ll Display the latch holders/waiters in time sequence\n" + " =lw Display the latch waiters\n" + " =n Display the ncp log\n" + " =s Save the debug log to a file\n" + " =sl Display contents of the global spinlock structure\n" + " =vh Display help on =v commands\n" + )); +#if MEM_KEEP_LIST IS_ENABLED + OutputToScreen(debugScreen, MSGNot( + " =? Display alloc/free information about specific address\n" )); +#endif + OutputToScreen(debugScreen, MSGNot( "\n" )); +} +#else +STATIC void displayHelpOPT( + struct ScreenStruct *debugScreen) +{ + OutputToScreen(debugScreen, MSGNot("\n" + "NSS debug commands begin with '='\n" + " =e Translate decimal error number to error string\n" + " =ex Translate hex evaluated error number to error string\n" + " =h This help message\n" + " =vh Display help on =v commands\n" + )); +#if MEM_KEEP_LIST IS_ENABLED + OutputToScreen(debugScreen, MSGNot( + " =? Display alloc/free information about specific address\n" )); +#endif + OutputToScreen(debugScreen, MSGNot( "\n" )); +} + +#endif + +/*************************************************************************** + * parse a debugger command and dispatch it to the appropriate routine + ***************************************************************************/ +LONG DBG_DoNSSDebuggerCommand( + struct ScreenStruct *debugScreen, + char *commandLine, + struct StackFrame *stackFrame) /* Allows access to registers. Can be used + * in commands like '=v Latch_s esi' + */ +{ + char *commandL; + + DBG_EnteredDebugger = TRUE; + + commandL = commandLine; + while (*commandL == ' ') + commandL++; + +// Commented out so NSS debug help is not always displayed with the help +// if (*commandL == 'h') +// { +// displayHelp(debugScreen); +// if (PauseWithEscape(debugScreen)) +// { +// return 0; +// } +// return -1; +// } + + if (*commandL++ != '=') + { /* If not '=' then NOT a NSS command */ + return -1; + } + +#if NSS_DEBUG IS_ENABLED + /*** + *** Comands in DEBUG NSS + ***/ + switch(*commandL) + { + case 'd': /* show the debug log buffer contents */ + commandL++; + DBG_DumpLogBuffer(debugScreen); + break; + case 'e': /* translate an error value to the #define string */ + commandL++; + DBG_TranslateError(debugScreen, &commandL, stackFrame ); + break; + case 'h': /* display the NSS help */ + commandL++; + displayHelpDEBUG(debugScreen); + break; + case 'l': /* display the latch holder and latchwaiter tables */ + commandL++; + DBGL_DumpLatches(debugScreen, &commandL); + break; + case 'n': /* display the ncp log */ + commandL++; + DBG_DisplayNCPLog(debugScreen); + break; + case 's': /* save the debug log to a file */ + commandL++; + if (*commandL == 'l') + { + DBG_DumpSpinLock(debugScreen); + } + else + { + DBG_SaveSpinLock(); + DBG_SaveDebugLogToFile(debugScreen); + DBG_RestoreSpinLock(); + } + break; + case 'v': /* View Structures */ + commandL++; + DBG_CommandView(debugScreen, &commandL, stackFrame ); + break; +#if MEM_KEEP_LIST IS_ENABLED + case '?': /* Display information about NSS memory */ + commandL++; + DBG_MemoryView(debugScreen, &commandL, stackFrame ); + break; +#endif + default: + OutputToScreen(debugScreen, MSGNot("Illegal command processed by NSS. Use '=h' to see a list of legal commands.\n")); + } +#else + /*** + *** Comands in OPT NSS + ***/ + switch(*commandL) + { + case 'e': /* translate an error value to the #define string */ + commandL++; + DBG_TranslateError(debugScreen, &commandL, stackFrame ); + break; + case 'h': /* display the NSS help */ + commandL++; + displayHelpOPT(debugScreen); + break; + case 'v': /* View Structures */ + commandL++; + DBG_CommandView(debugScreen, &commandL, stackFrame ); + break; +#if MEM_KEEP_LIST IS_ENABLED + case '?': /* Display information about NSS memory */ + commandL++; + DBG_MemoryView(debugScreen, &commandL, stackFrame ); + break; +#endif + default: + OutputToScreen(debugScreen, MSGNot("Illegal command processed by NSS. Use '=h' to see a list of legal commands.\n")); + } +#endif + + return 0; +} + +#endif // #if zNETWARE + +#ifdef __linux__ // LINUX_Debugger + // FixFixFix(Linux) - Port +STATUS DBG_CV_Register( CommandViewInfo_s *cvi ){ return( zFAILURE ); } +STATUS DBG_CV_Unregister( CommandViewInfo_s *cvi ){return( zOK ); } +#endif // #ifndef __linux__ diff --git a/src/nwnss/nss/lib/bitmap.c b/src/nwnss/nss/lib/bitmap.c index ec48bb3..2e190c4 100644 --- a/src/nwnss/nss/lib/bitmap.c +++ b/src/nwnss/nss/lib/bitmap.c @@ -35,21 +35,9 @@ | Define routines for manipulating bit maps. +-------------------------------------------------------------------------*/ #include -#include -/* - * MARS-NWE imports this NSS low-level helper with its original public - * function names and header name. The file is installed directly in the - * libnwnss source directory so - * the original NSS API remains recognizable. The original NSS source path - * is public_core/nss/lib/bitmap.c. zalloc() is provided by the imported - * userspace NSS stdlib compatibility layer. - */ - -/* Direct core imports of the original NSS headers; reference copies remain - * under include/nwfs/nss/sdk/... for SDK/source-audit compatibility. */ -#include "library/omni.h" -#include "library/bitmap.h" +#include "omni.h" +#include "bitmap.h" NINT getMaxBits (BitMap_s *bitMap) { @@ -69,7 +57,7 @@ void setAbit (BitMap_s *bitMap, NINT bitNum) } } -void setBits (BitMap_s *bitMap, NINT startBit, NINT numBits) +void setBits (BitMap_s *bitMap, NINT startBit, NINT numBits) { NINT *bits = bitMap->bits; NINT endBit = startBit + numBits; diff --git a/src/nwnss/nss/lib/crc.c b/src/nwnss/nss/lib/crc.c index aac55dc..6bdb21e 100644 --- a/src/nwnss/nss/lib/crc.c +++ b/src/nwnss/nss/lib/crc.c @@ -37,9 +37,9 @@ * taken from the PNG Specification: Sample CRC Code * PNG (Portable Network Graphics) Specification, * Version 1.2 - * + * * 15. Appendix: Sample CRC Code - * + * * The following sample code represents a practical * implementation of the CRC (Cyclic Redundancy Check) * employed in PNG chunks. (See also ISO 3309 or @@ -49,17 +49,9 @@ * Collision 5858dda3 Workplace.scc cci1 */ +#include #include -#include "library/crc.h" -#include - -/* - * MARS-NWE imports this NSS low-level helper with its original public - * function names and header name. The original NSS source path is - * public_core/nss/lib/crc.c. Unicode lowercase folding now goes through - * the imported xUnicode.h/unitolower interface and the exported - * NSSUniToLower[] table in libnwnss. - */ +#include "crc.h" /* * Table of CRCs of all 8-bit messages. @@ -146,7 +138,7 @@ static const crc_t CRCtable[256] = * Initially false. */ int CRCtableComputed = 0; - + /* * Make the table for a fast CRC. */ @@ -176,7 +168,7 @@ void makeCRCtable(void) } if (!CRCtableComputed) makeCRCtable(); #endif - + /* * Update a running CRC with the bytes * buf[0..len-1]--the CRC should be @@ -203,7 +195,7 @@ crc_t updateCRC ( /* * Update a running CRC with the characters - * of a NULL terminated ASCII string--the + * of a NULL terminated ASCII string--the * CRC should be initialized to all 1's, and the * transmitted value is the 1's complement * of the final running CRC (see the @@ -225,7 +217,7 @@ crc_t updateCRCFromString ( /* - * Update a running CRC with the bytes of a + * Update a running CRC with the bytes of a * NULL terminated Unicode string--the CRC should be * initialized to all 1's, and the * transmitted value is the 1's complement @@ -250,8 +242,8 @@ crc_t updateCRCFromUnicode ( } /* - * Update a running CRC with the bytes of a - * NULL terminated Unicode string converting + * Update a running CRC with the bytes of a + * NULL terminated Unicode string converting * the characters to lowercase--the CRC should be * initialized to all 1's, and the * transmitted value is the 1's complement @@ -278,7 +270,7 @@ crc_t updateCRCFromLowerUnicode ( /* * Update a running CRC with the characters * of a NULL terminated ASCII string, converting - * the string to lowercase as we go--the + * the string to lowercase as we go--the * CRC should be initialized to all 1's, and the * transmitted value is the 1's complement * of the final running CRC (see the @@ -302,7 +294,7 @@ crc_t updateCRCFromLowerString ( /* * Update a running CRC with the characters * of a non-NULL terminated ASCII string, converting - * the string to lowercase as we go--the + * the string to lowercase as we go--the * CRC should be initialized to all 1's, and the * transmitted value is the 1's complement * of the final running CRC (see the @@ -310,7 +302,7 @@ crc_t updateCRCFromLowerString ( */ crc_t updateCRCFromLowerStringWithLen ( crc_t crc, - char *t, + char *t, NINT len) { register crc_t c = crc; @@ -342,7 +334,7 @@ crc_t stringCRC (char *t) } /* - * Generates CRC for a NULL terminated string, using + * Generates CRC for a NULL terminated string, using * only the lowercase version of each character. */ crc_t lowerStringCRC (char *t) @@ -378,7 +370,7 @@ crc_t hashString (char *t) /* * Use CRC to generate a hash value for a - * NULL terminated string, converting it + * NULL terminated string, converting it * to lowercase. */ crc_t hashLowerString (char *t) @@ -416,7 +408,7 @@ crc_t hashUnicode (unicode_t *t) /* * Use CRC to generate a hash value for a - * NULL terminated Unicode string, converting + * NULL terminated Unicode string, converting * it to lowercase. */ crc_t hashLowerUnicode (unicode_t *t) diff --git a/src/nwnss/nss/lib/hash.c b/src/nwnss/nss/lib/hash.c index 48ca514..9ec8791 100644 --- a/src/nwnss/nss/lib/hash.c +++ b/src/nwnss/nss/lib/hash.c @@ -37,12 +37,14 @@ | can at load time pick-up the right routines. This requires creating | yet another library in NSS which I'm not ready to do yet. +-------------------------------------------------------------------------*/ +#include + #include #include #include -#include "library/omni.h" -#include "library/bit.h" -#include "library/hash.h" +#include +#include +#include "hash.h" /* * The generic hash code provides a basic set of functions for @@ -127,7 +129,7 @@ HashRecord_s *hashLookup ( bucket = crc & ht->mask; next = ht->table[bucket]; - + if (next == NULL) { return NULL; diff --git a/src/nwnss/nss/lib/setErrno.c b/src/nwnss/nss/lib/setErrno.c index 55f12d3..8635c0d 100644 --- a/src/nwnss/nss/lib/setErrno.c +++ b/src/nwnss/nss/lib/setErrno.c @@ -34,17 +34,16 @@ | This module is used to: | General PSS Error handling routines +-------------------------------------------------------------------------*/ +#include + #include -#include +#include "msgGen.h" +#include "msg.h" +#include "utc.h" -#include -#include -#include - -/* Linux userspace port: NSS kernel RunningProcess is represented by 0 here. */ -#ifndef RunningProcess -#define RunningProcess ((ADDR)0) +#if zNETWARE +extern ADDR RunningProcess; #endif #if NSS_DEBUG IS_ENABLED @@ -71,7 +70,7 @@ typedef struct NSSErrorLog_s } NSSErrorLog_s; -NSSErrorLog_s NSS_ErrorItems = +NSSErrorLog_s NSS_ErrorItems = { 0, ERROR_LOG_SIZE, &NSS_ErrorItems.NEL_ErrorLog[0] }; @@ -151,7 +150,7 @@ void MSG_SetStatus ( if (msg->sys.status == zOK) { msg->sys.status = status; - msg->sys.where = (QUAD)(uintptr_t)where; + msg->sys.where = where; } else { @@ -160,7 +159,7 @@ void MSG_SetStatus ( (status == zERR_OUT_OF_SPACE))) { msg->sys.status = status; - msg->sys.where = (QUAD)(uintptr_t)where; + msg->sys.where = where; } } LOG_ERROR(status, where); diff --git a/src/nwnss/nss/msg/msg.c b/src/nwnss/nss/msg/msg.c index f8a413b..f64355b 100644 --- a/src/nwnss/nss/msg/msg.c +++ b/src/nwnss/nss/msg/msg.c @@ -58,10 +58,11 @@ * Suicide - Self destruction of an object * */ +#include + #include #include #include -#include #include @@ -74,28 +75,6 @@ void *constructManager(mTypeHeader_s *type, mManager_s *manager); void msgFreeDoor(mDoor_s *door); -#ifndef __KERNEL__ -static void -mpkEnter(void) -{ -} - -static void -mpkExit(void) -{ -} -#endif - -#define MSG_PTR_TO_QUAD(_ptr) ((QUAD)(uintptr_t)(_ptr)) -#define MSG_QUAD_TO_PTR(_type, _quad) ((_type *)(uintptr_t)(_quad)) - -typedef STATUS (*MSG_ObjDestructorFunc_t)(void *obj); -typedef void *(*MSG_ObjConstructorFunc_t)(mTypeHeader_s *type, void *obj); -typedef void (*MSG_ObjNotifyFunc_t)(void *obj); -typedef BOOL (*MSG_MatchFunc_t)(void *obj, void *args); -typedef STATUS (*MSG_MethodFunc_t)(Msg_s *msg); - - mVirtualType_s ManagerType = { MSG_INIT_TYPE("ManagerType", NULL, sizeof(mManager_s), 0, NULL, constructManager, NULL, NULL, NULL) @@ -122,7 +101,7 @@ int prMsg (char *where, Key_t key, NINT method, void *m) mDoor_s *door; mDoor_s *passed; char *name; - + door = findDoor(key); if (door == NULL) { @@ -139,7 +118,7 @@ int prMsg (char *where, Key_t key, NINT method, void *m) } passed = findDoor(msg->sys.passedKey); if (passed == NULL) - { + { DBG_DebugPrintf(WHITE, "MSG :%s\n key=%x->%s method=%d passedKey=INVALIDE\n", where, (NINT)key, name, method); @@ -221,7 +200,7 @@ STATUS initMsgBufs () CIR_INIT(AwaitMsgBuf); for (i = 0; i < NUM_MSG_BUFS; ++i) { - fillInWork(&MsgBuf[i].work, (voidfunc_t)MSG_SendAsyncWork, 0); + fillInWork(&MsgBuf[i].work, MSG_SendAsyncWork, 0); MsgBuf[i].page = mallocPage(1); if (MsgBuf[i].page == NULL) { @@ -258,7 +237,7 @@ XIPC_Msg_s *allocMsgBuf () void freeMsgBuf (XIPC_Msg_s *xmsg) { WaitingForMsgBuf_s *wait; - + CIR_ENQ(FreeMsgBufs, xmsg, link); ++NumFreeMsgBufs; CIR_DEQ(AwaitMsgBuf, wait, WaitingForMsgBuf_s, link); @@ -268,7 +247,7 @@ void freeMsgBuf (XIPC_Msg_s *xmsg) } Continue(wait->thread); } - + #if NSS_DEBUG IS_ENABLED # define MAX_HASH (1 << 3) /* Must be a power of 2 */ @@ -476,7 +455,7 @@ void freeObj (mObject_s *obj) { ++obj->o_count; obj->o_properties |= mKEY_DESTRUCT; - if (((MSG_ObjDestructorFunc_t)destructor)(obj) == zERR_DONT_FREE_OBJECT) + if (destructor(obj) == zERR_DONT_FREE_OBJECT) { /* * Code handling zERR_DONT_FREE_OBJECT will need @@ -535,13 +514,13 @@ void *MSG_CreateObject ( if (type->constructor) { - obj = ((MSG_ObjConstructorFunc_t)type->constructor)(type, obj); + obj = type->constructor(type, obj); } else if (type->parent) { if (type->parent->constructor) { - obj = ((MSG_ObjConstructorFunc_t)type->parent->constructor)(type->parent, obj); + obj = type->parent->constructor(type->parent, obj); } } return obj; @@ -554,7 +533,7 @@ void MSG_ReleaseObject (mObject_s *obj) type = obj->o_type; if (type->hdr.unregister) { - ((MSG_ObjNotifyFunc_t)type->hdr.unregister)(obj); + type->hdr.unregister(obj); } else { @@ -633,7 +612,7 @@ void MSG_BreakSetOfDoors ( while (door != NULL) { nextDoor = DQ_NEXT( &type->instances, door, mDoor_s, dr_obj.o_instance); - if (((MSG_MatchFunc_t)match)(door, args)) + if (match(door, args)) { MSG_BreakDoor(door); } @@ -661,7 +640,7 @@ void MSG_DestroySetOfKeys ( } DQ_ENQ( &hold, door, dr_ownerList); object = (mObject_s *)door; - if (( &object->o_type->hdr == type) && (((MSG_MatchFunc_t)match)(object, args))) + if (( &object->o_type->hdr == type) && (match(object, args))) { MSG_DestroyKey(door->dr_key); } @@ -697,7 +676,7 @@ STATUS MSG_RegisterType ( { if (((mType_s *)type)->method[i] == NULL) { - ((mType_s *)type)->method[i] = (statusfunc_t)unimplemented; + ((mType_s *)type)->method[i] = unimplemented; } } return zOK; @@ -790,14 +769,14 @@ STATUS MSG_DestroyKey (Key_t key) } door->dr_obj.o_properties |= mKEY_DYING; /* - * Send the Pre Close Notify events when needed + * Send the Pre Close Notify events when needed * WARNING: The code that ends up being called * by notifyDoor can change the key. */ notify = door->dr_obj.o_type->hdr.notify; if (notify) { - ((MSG_ObjNotifyFunc_t)notify)(door); + notify(door); } if (rmvDoor(door)) { @@ -827,11 +806,11 @@ STATUS MSG_Call (Key_t key, NINT method, Msg_s *msg) door = findDoor(key); if (door == NULL) { - msg->sys.owner = 0; + msg->sys.owner = NULL; SetStatus(msg, zERR_BAD_KEY); return zERR_BAD_KEY; } - msg->sys.owner = MSG_PTR_TO_QUAD(door->dr_owner); + msg->sys.owner = door->dr_owner; MSG_USE_DOOR(door); @@ -847,9 +826,9 @@ STATUS MSG_Call (Key_t key, NINT method, Msg_s *msg) SetStatus(msg, zERR_BAD_METHOD); goto finished; } - msg->sys.door = MSG_PTR_TO_QUAD(door); + msg->sys.door = door; msg->sys.passedKey = INVALID_KEY; - status = ((MSG_MethodFunc_t)type->method[method])(msg); + status = type->method[method](msg); if (status != zOK) { status = msg->sys.status; @@ -890,17 +869,17 @@ STATUS mpkMSG_Call (Key_t key, NINT method, Msg_s *msg) void MSG_SendAsyncWork (zWorkProc_s *work) { - XIPC_Msg_s *xmsg; - mDoor_s *door; + XIPC_Msg_s *xmsg; + mDoor_s *door; WORK_PROCESS_INIT(); MPKNSS_LOCK(); xmsg = STRUCT(work, XIPC_Msg_s, work); - door = MSG_QUAD_TO_PTR(mDoor_s, xmsg->net.msg.sys.door); + door = xmsg->net.msg.sys.door; prMsg("MSG_SendAsyncWork", xmsg->net.key, xmsg->net.method, &xmsg->net.msg); - ((MSG_MethodFunc_t)door->dr_obj.o_type->method[xmsg->net.method])( &xmsg->net.msg); + door->dr_obj.o_type->method[xmsg->net.method]( &xmsg->net.msg); MSG_RELEASE_DOOR(door); @@ -928,7 +907,7 @@ PR(MSG_Send); door = findDoor(key); if (door == NULL) { - msg->sys.owner = 0; + msg->sys.owner = NULL; SetStatus(msg, zERR_BAD_KEY); //zASSERT("zERR_BAD_KEY" == 0); return zERR_BAD_KEY; @@ -943,7 +922,7 @@ PRx(type); if (door->dr_obj.o_properties & mKEY_REMOTE) { STATUS rc; - + rc = XIPC_RemoteSendPtr(door, method, msg); MSG_RELEASE_DOOR(door); return rc; @@ -959,8 +938,8 @@ zASSERT("ERR_BAD_METHOD" == 0); xmsg->net.key = key; // For msg tracing xmsg->net.method = method; xmsg->net.msg.sys.status = 0; - xmsg->net.msg.sys.owner = MSG_PTR_TO_QUAD(door->dr_owner); - xmsg->net.msg.sys.door = MSG_PTR_TO_QUAD(door); + xmsg->net.msg.sys.owner = door->dr_owner; + xmsg->net.msg.sys.door = door; xmsg->net.msg.sys.passedKey = INVALID_KEY; xmsg->net.msg.sys.numDataAreas = msg->sys.numDataAreas; xmsg->net.msg.body = msg->body; @@ -973,8 +952,8 @@ zASSERT("ERR_BAD_METHOD" == 0); { length = msg->sys.data[i].length; xmsg->net.msg.sys.data[i].length = length; - xmsg->net.msg.sys.data[i].start = MSG_PTR_TO_QUAD(data); - memcpy(data, MSG_QUAD_TO_PTR(void, msg->sys.data[i].start), length); + xmsg->net.msg.sys.data[i].start = data; + memcpy(data, msg->sys.data[i].start, length); data += length; zASSERT((ADDR)data - (ADDR)xmsg->page <= PAGE_SIZE); @@ -1015,7 +994,7 @@ zASSERT("zERR_BAD_KEY Passed (need new error code)" == 0); door = findDoor(key); if (door == NULL) { - msg->sys.owner = 0; + msg->sys.owner = NULL; SetStatus(msg, zERR_BAD_KEY); zASSERT("zERR_BAD_KEY" == 0); return zERR_BAD_KEY; @@ -1029,7 +1008,7 @@ zASSERT("zERR_BAD_KEY" == 0); if (door->dr_obj.o_properties & mKEY_REMOTE) { STATUS rc; - + rc = XIPC_RemoteSendKeyPtr(door, method, msg, passedDoor); MSG_RELEASE_DOOR(door); return rc; @@ -1045,8 +1024,8 @@ zASSERT("zERR_BAD_METHOD" == 0); xmsg->net.key = key; // For msg tracing xmsg->net.method = method; xmsg->net.msg.sys.status = 0; - xmsg->net.msg.sys.owner = MSG_PTR_TO_QUAD(door->dr_owner); - xmsg->net.msg.sys.door = MSG_PTR_TO_QUAD(door); + xmsg->net.msg.sys.owner = door->dr_owner; + xmsg->net.msg.sys.door = door; xmsg->net.msg.sys.passedKey = msg->sys.passedKey; xmsg->net.msg.sys.numDataAreas = msg->sys.numDataAreas; xmsg->net.msg.body = msg->body; @@ -1059,8 +1038,8 @@ zASSERT("zERR_BAD_METHOD" == 0); { length = msg->sys.data[i].length; xmsg->net.msg.sys.data[i].length = length; - xmsg->net.msg.sys.data[i].start = MSG_PTR_TO_QUAD(data); - memcpy(data, MSG_QUAD_TO_PTR(void, msg->sys.data[i].start), length); + xmsg->net.msg.sys.data[i].start = data; + memcpy(data, msg->sys.data[i].start, length); data += length; zASSERT((ADDR)data - (ADDR)xmsg->page <= PAGE_SIZE); diff --git a/src/nwnss/nss/msg/slab.c b/src/nwnss/nss/msg/slab.c index 54a1dcb..c7fb8ba 100644 --- a/src/nwnss/nss/msg/slab.c +++ b/src/nwnss/nss/msg/slab.c @@ -81,22 +81,22 @@ * WARNING: the first ADDR of the allocated structure will be set to NULL. * I've looked at all the data strutures and this seems OK. */ -#include +#include #include #include #include -#include +#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "omni.h" +#include "que.h" +#include "latch.h" +#include "utc.h" +#include "xCache.h" +#include "reserveResources.h" +#include "alarm.h" +#include "slab.h" #define SLAB_MAGIC_ALLOC 0xCA11ACAB @@ -139,15 +139,13 @@ struct Slab_s DQhead_t ObjCaches; -void slabShouldNotBeSignaled (Agent_s *agent) +void slabShouldNotBeSignaled () { - (void)agent; zASSERT("Slab was signaled" == NULL); } -void slabControlShouldNotBeSignaled (Agent_s *agent) +void slabControlShouldNotBeSignaled () { - (void)agent; zASSERT("Slab controller was signaled" == NULL); } @@ -170,7 +168,7 @@ Buffer_s *allocSlab (ObjCache_s *objCache) STK_INIT(slab->hdr.top); slab->hdr.inUse = 0; slab->hdr.objCache = objCache; - + data = slab->data; if (objCache->color) { @@ -188,7 +186,7 @@ Buffer_s *allocSlab (ObjCache_s *objCache) { if (objCache->prefab != NULL) { - ((void (*)(void *))objCache->prefab)(&data[i * objCache->size]); + objCache->prefab( &data[i * objCache->size]); } else { @@ -201,7 +199,7 @@ Buffer_s *allocSlab (ObjCache_s *objCache) debug->magic = SLAB_MAGIC_FREE; debug->caller = 0; - } + } #endif } @@ -380,7 +378,7 @@ STATUS objCacheCreate ( */ if (size < (ALIGNMENT / 2)) { - size = ALIGN(size, sizeof(NINT)); + size = ALIGN(size, sizeof(NINT)); } else { @@ -490,7 +488,7 @@ void objCacheDestroy (ObjCache_s *objCache) STATUS objSlabStats (Slab_s *slab, ObjSlabStats_s *stats) { - return zOK; + return zOK; } STATUS objCacheStats (ObjCache_s *objCache, ObjCacheStats_s *stats) diff --git a/src/nwnss/nss/msg/switchboard.c b/src/nwnss/nss/msg/switchboard.c index 979655e..284fe01 100644 --- a/src/nwnss/nss/msg/switchboard.c +++ b/src/nwnss/nss/msg/switchboard.c @@ -1,26 +1,26 @@ /**************************************************************************** | - | (C) Copyright 2002 Novell, Inc. - | All Rights Reserved. + | (C) Copyright 2002 Novell, Inc. + | All Rights Reserved. | - | This program is free software; you can redistribute it and/or - | modify it under the terms of version 2 of the GNU General Public - | License as published by the Free Software Foundation. + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. | - | This program is distributed in the hope that it will be useful, - | but WITHOUT ANY WARRANTY; without even the implied warranty of - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - | GNU General Public License for more details. + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. | - | You should have received a copy of the GNU General Public License - | along with this program; if not, contact Novell, Inc. + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. | - | To contact Novell about this file by physical or electronic mail, - | you may find current contact information at www.novell.com + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com | |*************************************************************************** | - | NetWare Advance File Services (NSS) Initialization module + | NetWare Advance File Services (NSS) Initialization module | |--------------------------------------------------------------------------- | @@ -31,8 +31,8 @@ | $Revision: 1177 $ | |--------------------------------------------------------------------------- - | This module is used to: - | Switchboard for exchanging keys in cluster. + | This module is used to: + | Switchboard for exchanging keys in cluster. +-------------------------------------------------------------------------*/ #include @@ -42,47 +42,47 @@ #include "switchboard.h" #if NSS_DEBUG IS_ENABLED -#define PR(_n) DBG_DebugPrintf(WHITE, "SWBD:%x:" # _n "\n",kCurrentThread()) -#define PRx(_x) DBG_DebugPrintf(WHITE, "\t" # _x "=%x\n", (_x)) +#define PR(_n) DBG_DebugPrintf(WHITE, "SWBD:%x:" # _n "\n",kCurrentThread()) +#define PRx(_x) DBG_DebugPrintf(WHITE, "\t" # _x "=%x\n", (_x)) #else -#define PR(_n) ((void) 0) -#define PRx(_x) ((void) 0) +#define PR(_n) ((void) 0) +#define PRx(_x) ((void) 0) #endif -#define DUMMY_LENGTH 8 +#define DUMMY_LENGTH 8 typedef struct NamedKey_s { - DQlink_t namedLink; - DQhead_t supplied; - DQhead_t demanded; - unicode_t name[DUMMY_LENGTH]; + DQlink_t namedLink; + DQhead_t supplied; + DQhead_t demanded; + unicode_t name[DUMMY_LENGTH]; } NamedKey_s; typedef struct PeerKey_s { - DQlink_t peerLink; - Key_t key; + DQlink_t peerLink; + Key_t key; } PeerKey_s; typedef struct SwitchboardKey_s { - Key_t key; - SWBDClient_s *client; - BOOL local; - DQlink_t named; - DQlink_t clientele; + Key_t key; + SWBDClient_s *client; + BOOL local; + DQlink_t named; + DQlink_t clientele; } SwitchboardKey_s; -DQhead_t NamedKeys = DQ_STATIC_INIT(NamedKeys); -DQhead_t PeerKeys = DQ_STATIC_INIT(PeerKeys); +DQhead_t NamedKeys = DQ_STATIC_INIT(NamedKeys); +DQhead_t PeerKeys = DQ_STATIC_INIT(PeerKeys); -Latch_s SwitchboardLatch = { 0 }; +Latch_s SwitchboardLatch = { 0 }; STATUS BeginSwitchboard () { - return zOK; + return zOK; } void EndSwitchboard () @@ -91,354 +91,355 @@ void EndSwitchboard () STATUS fullP(char **p, int len, char *buf, int *newLen) { - if(len >= 0) - { - *p += len; - *newLen -= len; - return FALSE; - } - return TRUE; + if(len >= 0) + { + *p += len; + *newLen -= len; + return FALSE; + } + return TRUE; } void SWBD_DumpSwitchboard (char *buf, int bufLen) { - NamedKey_s *namedKey; - SwitchboardKey_s *swbdKey; - char *p = buf; - int newLen = bufLen; + NamedKey_s *namedKey; + SwitchboardKey_s *swbdKey; + char *p = buf; + int newLen = bufLen; #if NSS_DEBUG IS_ENABLED - DQ_FOREACH( &NamedKeys, namedKey, NamedKey_s, namedLink) - { - DBG_DebugPrintf(WHITE, "name:%s supplied\n", namedKey->name); - DQ_FOREACH( &namedKey->supplied, swbdKey, SwitchboardKey_s, named) - { - DBG_DebugPrintf(WHITE, "\t%s:%x %s\n", - swbdKey->client->swbdName, (NINT)swbdKey->key, - swbdKey->local ? "local" : "remote"); - } - DBG_DebugPrintf(WHITE, "name:%s demanded\n", namedKey->name); - DQ_FOREACH( &namedKey->demanded, swbdKey, SwitchboardKey_s, named) - { - DBG_DebugPrintf(WHITE, "\t%s:%x\n", - swbdKey->client->swbdName, (NINT)swbdKey->key); - } - } + DQ_FOREACH( &NamedKeys, namedKey, NamedKey_s, namedLink) + { + DBG_DebugPrintf(WHITE, "name:%s supplied\n", namedKey->name); + DQ_FOREACH( &namedKey->supplied, swbdKey, SwitchboardKey_s, named) + { + DBG_DebugPrintf(WHITE, "\t%s:%x %s\n", + swbdKey->client->swbdName, (NINT)swbdKey->key, + swbdKey->local ? "local" : "remote"); + } + DBG_DebugPrintf(WHITE, "name:%s demanded\n", namedKey->name); + DQ_FOREACH( &namedKey->demanded, swbdKey, SwitchboardKey_s, named) + { + DBG_DebugPrintf(WHITE, "\t%s:%x\n", + swbdKey->client->swbdName, (NINT)swbdKey->key); + } + } #endif - *p = '\0'; + *p = '\0'; - DQ_FOREACH( &NamedKeys, namedKey, NamedKey_s, namedLink) - { - if (fullP( &p, LB_snprintf(p, newLen, "name:%s supplied\n", - namedKey->name), buf, &newLen)) - { - return; - } - DQ_FOREACH( &namedKey->supplied, swbdKey, SwitchboardKey_s, named) - { - if (fullP( &p, LB_snprintf(p, newLen, "\t%s:%x %s\n", - swbdKey->client->swbdName, (NINT)swbdKey->key, - swbdKey->local ? "local" : "remote"), - buf, &newLen)) - { - return; - } - } - if (fullP( &p, LB_snprintf(p, newLen, "name:%s demanded\n", - namedKey->name), buf, &newLen)) - { - return; - } - DQ_FOREACH( &namedKey->demanded, swbdKey, SwitchboardKey_s, named) - { - if (fullP( &p, LB_snprintf(p, newLen, "\t%s:%x\n", - swbdKey->client->swbdName, (NINT)swbdKey->key), - buf, &newLen)) - { - return; - } - } - } + DQ_FOREACH( &NamedKeys, namedKey, NamedKey_s, namedLink) + { + if (fullP( &p, LB_snprintf(p, newLen, "name:%s supplied\n", + namedKey->name), buf, &newLen)) + { + return; + } + DQ_FOREACH( &namedKey->supplied, swbdKey, SwitchboardKey_s, named) + { + if (fullP( &p, LB_snprintf(p, newLen, "\t%s:%x %s\n", + swbdKey->client->swbdName, (NINT)swbdKey->key, + swbdKey->local ? "local" : "remote"), + buf, &newLen)) + { + return; + } + } + if (fullP( &p, LB_snprintf(p, newLen, "name:%s demanded\n", + namedKey->name), buf, &newLen)) + { + return; + } + DQ_FOREACH( &namedKey->demanded, swbdKey, SwitchboardKey_s, named) + { + if (fullP( &p, LB_snprintf(p, newLen, "\t%s:%x\n", + swbdKey->client->swbdName, (NINT)swbdKey->key), + buf, &newLen)) + { + return; + } + } + } } NamedKey_s *lookupNamedKey (unicode_t *name) { - NamedKey_s *namedKey; + NamedKey_s *namedKey; PR(lookupNamedKey); - DQ_FOREACH( &NamedKeys, namedKey, NamedKey_s, namedLink) - { - if (unicmp(name, namedKey->name) == 0) - { - return namedKey; - } - } - return NULL; + DQ_FOREACH( &NamedKeys, namedKey, NamedKey_s, namedLink) + { + if (unicmp(name, namedKey->name) == 0) + { + return namedKey; + } + } + return NULL; } NamedKey_s *newNamedKey (unicode_t *name) { - NINT length; - NamedKey_s *namedKey; + NINT length; + NamedKey_s *namedKey; PR(newNamedKey); - if (name == NULL) return NULL; + if (name == NULL) return NULL; - length = (unilen(name) + 1) * sizeof(unicode_t); - if (length == 0) - { - return NULL; - } - namedKey = zalloc(sizeof(NamedKey_s) - sizeof(namedKey->name) + length); - if (namedKey == NULL) - { - return NULL; - } + length = (unilen(name) + 1) * sizeof(unicode_t); + if (length == 0) + { + return NULL; + } + namedKey = zalloc(sizeof(NamedKey_s) - sizeof(namedKey->name) + length); + if (namedKey == NULL) + { + return NULL; + } - DQ_ENQ( &NamedKeys, namedKey, namedLink); + DQ_ENQ( &NamedKeys, namedKey, namedLink); - DQ_INIT( &namedKey->supplied); - DQ_INIT( &namedKey->demanded); + DQ_INIT( &namedKey->supplied); + DQ_INIT( &namedKey->demanded); - unicpy(namedKey->name, name); + unicpy(namedKey->name, name); - return namedKey; + return namedKey; } PeerKey_s *newPeerKey (Key_t key) { - PeerKey_s *peer; + PeerKey_s *peer; PR(newPeerKey); - peer = zalloc(sizeof(PeerKey_s)); + peer = zalloc(sizeof(PeerKey_s)); - if (peer == NULL) - { - return NULL; - } - peer->key = key; - DQ_ENQ( &PeerKeys, peer, peerLink); + if (peer == NULL) + { + return NULL; + } + peer->key = key; + DQ_ENQ( &PeerKeys, peer, peerLink); - return peer; + return peer; } STATUS supplyPeers (unicode_t *name, Key_t key) { - SWBD_Msg_s msg; - PeerKey_s *peer; + SWBD_Msg_s msg; + PeerKey_s *peer; PR(supplyPeers); - DQ_FOREACH( &PeerKeys, peer, PeerKey_s, peerLink) - { - msg.sys.passedKey = key; - msg.sys.numDataAreas = 0; - unincpy(msg.b.name.name, name, MAX_SWBD_NAME); - msg.b.name.name[MAX_SWBD_NAME] = 0; - MSG_SendKey(peer->key, SWBRD_SUPPLIED, (Msg_s *)&msg); - } - return zOK; + DQ_FOREACH( &PeerKeys, peer, PeerKey_s, peerLink) + { + msg.sys.passedKey = key; + msg.sys.numDataAreas = 0; + unincpy(msg.b.name.name, name, MAX_SWBD_NAME); + msg.b.name.name[MAX_SWBD_NAME] = 0; + MSG_SendKey(peer->key, SWBRD_SUPPLIED, (Msg_s *)&msg); + } + return zOK; } SwitchboardKey_s *newSwitchboardKey ( - SWBDClient_s *client, - DQhead_t *list, - Key_t key, - BOOL local) + SWBDClient_s *client, + DQhead_t *list, + Key_t key, + BOOL local) { - SwitchboardKey_s *swbrdKey; + SwitchboardKey_s *swbrdKey; PR(newSwitchboardKey); - swbrdKey = zalloc(sizeof(SwitchboardKey_s)); - if (swbrdKey == NULL) - { - return NULL; - } + swbrdKey = zalloc(sizeof(SwitchboardKey_s)); + if (swbrdKey == NULL) + { + return NULL; + } - swbrdKey->key = key; - swbrdKey->client = client; - swbrdKey->local = local; - DQ_ENQ(list, swbrdKey, named); - DQ_ENQ( &client->swbdMyKeys, swbrdKey, clientele); + swbrdKey->key = key; + swbrdKey->client = client; + swbrdKey->local = local; + DQ_ENQ(list, swbrdKey, named); + DQ_ENQ( &client->swbdMyKeys, swbrdKey, clientele); - return swbrdKey; -} + return swbrdKey; +} STATUS SWBD_SupplyLocal (SWBDClient_s *client, unicode_t *name, Key_t key) { - Msg_s msg; - NamedKey_s *namedKey; - SwitchboardKey_s *suppliedKey; - SwitchboardKey_s *demandedKey; + Msg_s msg; + NamedKey_s *namedKey; + SwitchboardKey_s *suppliedKey; + SwitchboardKey_s *demandedKey; PR(SWBD_SupplyLocal); - namedKey = lookupNamedKey(name); - if (namedKey == NULL) - { - namedKey = newNamedKey(name); - if (namedKey == NULL) return zFAILURE; - } + namedKey = lookupNamedKey(name); + if (namedKey == NULL) + { + namedKey = newNamedKey(name); + if (namedKey == NULL) return zFAILURE; + } - suppliedKey = newSwitchboardKey(client, &namedKey->supplied, key, TRUE); - if (suppliedKey == NULL) return zFAILURE; + suppliedKey = newSwitchboardKey(client, &namedKey->supplied, key, TRUE); + if (suppliedKey == NULL) return zFAILURE; - DQ_FOREACH( &namedKey->demanded, demandedKey, SwitchboardKey_s, named) - { - msg.sys.passedKey = key; - msg.sys.numDataAreas = 0; - MSG_SendKey(demandedKey->key, SWBRD_SUPPLIED, &msg); - } - return zOK; + DQ_FOREACH( &namedKey->demanded, demandedKey, SwitchboardKey_s, named) + { + msg.sys.passedKey = key; + msg.sys.numDataAreas = 0; + MSG_SendKey(demandedKey->key, SWBRD_SUPPLIED, &msg); + } + return zOK; } STATUS SWBD_SupplyRemote (SWBDClient_s *client, unicode_t *name, Key_t key) { - Msg_s msg; - NamedKey_s *namedKey; - SwitchboardKey_s *suppliedKey; - SwitchboardKey_s *demandedKey; + Msg_s msg; + NamedKey_s *namedKey; + SwitchboardKey_s *suppliedKey; + SwitchboardKey_s *demandedKey; PR(SWBD_SupplyLocal); - namedKey = lookupNamedKey(name); - if (namedKey == NULL) - { - namedKey = newNamedKey(name); - if (namedKey == NULL) return zFAILURE; - } + namedKey = lookupNamedKey(name); + if (namedKey == NULL) + { + namedKey = newNamedKey(name); + if (namedKey == NULL) return zFAILURE; + } - suppliedKey = newSwitchboardKey(client, &namedKey->supplied, key, FALSE); - if (suppliedKey == NULL) return zFAILURE; + suppliedKey = newSwitchboardKey(client, &namedKey->supplied, key, FALSE); + if (suppliedKey == NULL) return zFAILURE; - DQ_FOREACH( &namedKey->demanded, demandedKey, SwitchboardKey_s, named) - { - msg.sys.passedKey = key; - msg.sys.numDataAreas = 0; - MSG_SendKey(demandedKey->key, SWBRD_SUPPLIED, &msg); - } - return zOK; + DQ_FOREACH( &namedKey->demanded, demandedKey, SwitchboardKey_s, named) + { + msg.sys.passedKey = key; + msg.sys.numDataAreas = 0; + MSG_SendKey(demandedKey->key, SWBRD_SUPPLIED, &msg); + } + return zOK; } STATUS SWBD_SupplyKey (SWBDClient_s *client, unicode_t *name, Key_t key) { - STATUS rc; + STATUS rc; PR(SWBD_SupplyKey); - rc = SWBD_SupplyLocal(client, name, key); - if (rc != zOK) - { - return rc; - } - supplyPeers(name, key); + rc = SWBD_SupplyLocal(client, name, key); + if (rc != zOK) + { + return rc; + } + supplyPeers(name, key); - return zOK; + return zOK; } STATUS SWBD_DemandKey (SWBDClient_s *client, unicode_t *name, Key_t key) { - Msg_s msg; - NamedKey_s *namedKey; - SwitchboardKey_s *suppliedKey; - SwitchboardKey_s *demandedKey; + Msg_s msg; + NamedKey_s *namedKey; + SwitchboardKey_s *suppliedKey; + SwitchboardKey_s *demandedKey; - ASSERT_MPKNSS_LOCK(); + ASSERT_MPKNSS_LOCK(); PR(SWBD_DemandKey); - X_LATCH( &SwitchboardLatch); + X_LATCH( &SwitchboardLatch); - namedKey = lookupNamedKey(name); - if (namedKey == NULL) - { - namedKey = newNamedKey(name); - if (namedKey == NULL) - { - goto error; - } - } + namedKey = lookupNamedKey(name); + if (namedKey == NULL) + { + namedKey = newNamedKey(name); + if (namedKey == NULL) + { + goto error; + } + } - demandedKey = newSwitchboardKey(client, &namedKey->demanded, key, TRUE); - if (demandedKey == NULL) - { - goto error; - } - DQ_FOREACH( &namedKey->supplied, suppliedKey, SwitchboardKey_s, named) - { - msg.sys.passedKey = suppliedKey->key; - msg.sys.numDataAreas = 0; - MSG_SendKey(key, SWBRD_SUPPLIED, &msg); - } - UNX_LATCH( &SwitchboardLatch); - return zOK; + demandedKey = newSwitchboardKey(client, &namedKey->demanded, key, TRUE); + if (demandedKey == NULL) + { + goto error; + } + DQ_FOREACH( &namedKey->supplied, suppliedKey, SwitchboardKey_s, named) + { + msg.sys.passedKey = suppliedKey->key; + msg.sys.numDataAreas = 0; + MSG_SendKey(key, SWBRD_SUPPLIED, &msg); + } + UNX_LATCH( &SwitchboardLatch); + return zOK; error: - UNX_LATCH( &SwitchboardLatch); - return zFAILURE; - + UNX_LATCH( &SwitchboardLatch); + return zFAILURE; + } STATUS SWBD_SupplyAll (Key_t key) { - SWBD_Msg_s msg; - NamedKey_s *namedKey; - SwitchboardKey_s *suppliedKey; + SWBD_Msg_s msg; + NamedKey_s *namedKey; + SwitchboardKey_s *suppliedKey; PR(SWBD_SupplyAll); - if (newPeerKey(key) == NULL) - { - return zFAILURE; - } - DQ_FOREACH( &NamedKeys, namedKey, NamedKey_s, namedLink) - { - DQ_FOREACH( &namedKey->supplied, suppliedKey, SwitchboardKey_s, named) - { - if (suppliedKey->local) - { - msg.sys.passedKey = suppliedKey->key; - msg.sys.numDataAreas = 0; - unincpy(msg.b.name.name, namedKey->name, MAX_SWBD_NAME); - msg.b.name.name[MAX_SWBD_NAME] = 0; - MSG_SendKey(key, SWBRD_SUPPLIED, (Msg_s *)&msg); - } - } - } - return zOK; + if (newPeerKey(key) == NULL) + { + return zFAILURE; + } + DQ_FOREACH( &NamedKeys, namedKey, NamedKey_s, namedLink) + { + DQ_FOREACH( &namedKey->supplied, suppliedKey, SwitchboardKey_s, named) + { + if (suppliedKey->local) + { + msg.sys.passedKey = suppliedKey->key; + msg.sys.numDataAreas = 0; + unincpy(msg.b.name.name, namedKey->name, MAX_SWBD_NAME); + msg.b.name.name[MAX_SWBD_NAME] = 0; + MSG_SendKey(key, SWBRD_SUPPLIED, (Msg_s *)&msg); + } + } + } + return zOK; } SWBDClient_s *SWBD_NewClient (char *name) { - SWBDClient_s *client; + SWBDClient_s *client; PR(SWBD_NewClient); - client = zalloc(sizeof(SWBDClient_s)); - if (client == NULL) - { - return NULL; - } - COPY_NAME(client->swbdName, name); + client = zalloc(sizeof(SWBDClient_s)); + if (client == NULL) + { + return NULL; + } + COPY_NAME(client->swbdName, name); - DQ_INIT( &client->swbdMyKeys); + DQ_INIT( &client->swbdMyKeys); - return client; + return client; } void SWBD_KillClient (SWBDClient_s *client) { - SwitchboardKey_s *swbrdKey; + SwitchboardKey_s *swbrdKey; PR(SWBD_KillClient); - if (client == NULL) - { - return; - } - for (;;) - { - DQ_DEQ( &client->swbdMyKeys, swbrdKey, SwitchboardKey_s, clientele); - if (swbrdKey == NULL) - { - break; - } - DQ_RMV(swbrdKey, named); - MSG_DestroyKey(swbrdKey->key); - free(swbrdKey); - } - free(client); + if (client == NULL) + { + return; + } + for (;;) + { + DQ_DEQ( &client->swbdMyKeys, swbrdKey, SwitchboardKey_s, clientele); + if (swbrdKey == NULL) + { + break; + } + DQ_RMV(swbrdKey, named); + MSG_DestroyKey(swbrdKey->key); + free(swbrdKey); + } + free(client); } + diff --git a/src/nwnss/nss/nssCmdline.c b/src/nwnss/nss/nssCmdline.c new file mode 100644 index 0000000..2d2264f --- /dev/null +++ b/src/nwnss/nss/nssCmdline.c @@ -0,0 +1,1935 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996-1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) Command Line Support module + | + |--------------------------------------------------------------------------- + | + | $Author: gpachner $ + | $Date: 2008-08-30 01:43:58 +0530 (Sat, 30 Aug 2008) $ + | + | $RCSfile$ + | $Revision: 2460 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | command line options for all input action + | + +-------------------------------------------------------------------------*/ +#if zLINUX +#include +#endif +#include /* NetWare Include files*/ +#include +#include + +#include +#ifdef _NWMOAB_ +# include +# include +#endif + +#include +#include /* Library */ +#include /* Library */ +#include +#include +#include +#include +#include +#include +#include + + // These next added for NetWare classic IO use +#include +#include +#include +#include +#include +#include +#include + +#include "msgGen.h" +#include "zParams.h" +#include "comnPublics.h" +#include "nssStartup.h" +#include "xError.h" +#include "eventSys.h" +#include "nssOSAPIs.h" +#include "setcmd.h" +#include "utc.h" +#include "nssPubs.h" + +/*------------------------------------------------------------------------- + * Structure definition for the USER parameter passed to the command + * line parser + *-------------------------------------------------------------------------*/ +typedef struct UserParm_s +{ + NINT *didHelp; +} UserParm_s; + +/*--------------------------------------------------------------------------- + * Internal structure used to sort command paramter names + *---------------------------------------------------------------------------*/ +typedef struct +{ + char **msgTable; + PCLSwitchDef_s *swdef; +} CmdNameSort_s; + + +/*------------------------------------------------------------------------- + * Defines how many modules with command lines we can handle at the same + * time. + *-------------------------------------------------------------------------*/ +#define MAX_CMDLINE_MODULES 21 + +static NINT doProcessExit = FALSE; + +/*------------------------------------------------------------------------- + * Define the various command line messages. Since the message processor + * will not look at message strings inside #IF definition, we have them + * in different macros + *-------------------------------------------------------------------------*/ +#define ATStartupTimeMsg_UNOPT MSG("\nusage: load U" "NSS" " \n", 199) +#define ATRunTimeMsg_UNOPT MSG("usage: " "NSS" " \n", 200) +#define ATStartupTimeMsg_OPT MSG("\nusage: load " "NSS" " \n", 201) +#define ATRunTimeMsg_OPT MSG("usage: " "NSS" " \n", 202) + +#ifdef UNOPT +# define ATStartupTimeMsg ATStartupTimeMsg_UNOPT +# define ATRunTimeMsg ATRunTimeMsg_UNOPT +#else +# define ATStartupTimeMsg ATStartupTimeMsg_OPT +# define ATRunTimeMsg ATRunTimeMsg_OPT +#endif + +extern BOOL RecordLatches; +extern BOOL ResetRecording; + +Latch_s NSSConsoleCmdLatch; + +/************************************************************************** + * This routine will parse the console commands that come from the Netware + * command line. + ***************************************************************************/ +/* STATUS NSS_ParseCommandLine( +// char *cmdline, +// NINT options, +// NINT *didHelp) +//{ +// UserParm_s userparm; +// +// if (didHelp) +// *didHelp = FALSE; +// userparm.didHelp = didHelp; +// userparm.options = options; +// +// if (LB_ParseCmdline(NSS_CommandLineSwitches,options,cmdline,&userparm) != zOK) +// return zFAILURE; +// return zOK; +//} +*/ +/*------------------------------------------------------------------------- + * Define the various menu options + *-------------------------------------------------------------------------*/ +#define NSSMENU 0 +#define NWCONFIGMENU 1 +#define NSSDEBUGMENU 2 + +char *MenuNLMs[] = +{ + MSGNot("MENUNSS"), + MSGNot("MENUCFG"), + MSGNot("MENUDBG") +}; + + +/************************************************************************** + * This is called to fill out an array with all of the command line + * definitions from all of the loaded modles. + ***************************************************************************/ +void BuildMultiList( + PCLMultiSwitchList_s *multiList) +{ + RegisteredNLMs_s *rnlm; + NINT mi; + + ASSERT_MPKNSS_LOCK(); + + /* set our NLMs switches */ + multiList[0].moduleName = MSGNot("NSS"); + multiList[0].swList = NSS_CommandLineSwitches; +#ifdef _LANGUAGEENABLED_ + multiList[0].messageTable = NSSMessageTable; +#else + multiList[0].messageTable = NULL; +#endif + + mi = 1; + DQ_FOREACH(&RegisteredNLMsList,rnlm,RegisteredNLMs_s,link) + { + if (rnlm->commandLineSwitches != NULL) + { + multiList[mi].swList = rnlm->commandLineSwitches; + multiList[mi].moduleName = rnlm->moduleName; + multiList[mi].messageTable = rnlm->messageTable; + if (++mi >= (MAX_CMDLINE_MODULES-1)) + { + zASSERT("Loaded too many modules with command lines" == NULL); + break; + } + } + } + multiList[mi].swList = NULL; +} + + +/************************************************************************** + * Display list of HELP commands + ***************************************************************************/ +void DisplayNSSHelp( + NINT options) +{ + char *header; + typedef struct Stack_s { + PCLMultiSwitchList_s multiList[MAX_CMDLINE_MODULES]; + } Stack_s; + Stack_s *aStack; + ASSERT_MPKNSS_LOCK(); + + wPause(stdout, -1); + if (options & POPT_AT_STARTUP) + { + header = ATStartupTimeMsg; + } + else + { + header = ATRunTimeMsg; + } + + STACK_ALLOC_NO_ASTACK(); + BuildMultiList(aStack->multiList); + LB_DisplayCmdlineHelpMulti(aStack->multiList,options,FALSE,header); + STACK_FREE(); + + wPause(stdout, 0); +} + + +/************************************************************************** + * Display list of HIDDEN commands + ***************************************************************************/ +void DisplayNSSHidden ( + NINT options) +{ + char *header; + typedef struct Stack_s { + PCLMultiSwitchList_s multiList[MAX_CMDLINE_MODULES]; + } Stack_s; + Stack_s *aStack; + + ASSERT_MPKNSS_LOCK(); + + wPause(stdout, -1); + if (options & POPT_AT_STARTUP) + { + header = ATStartupTimeMsg; + } + else + { + header = ATRunTimeMsg; + } + + STACK_ALLOC_NO_ASTACK(); + BuildMultiList(aStack->multiList); + LB_DisplayCmdlineHelpMulti(aStack->multiList,options,TRUE,header); + STACK_FREE(); + + wPause(stdout, 0); +} + /*======================================================================== + *======================================================================== + * Routines called by the NetWare command parser + *======================================================================== + *========================================================================*/ + +/**************************************************************************** + * This does the initial parse of the command line at STARTUP time. This + * looks at switches from NSS, not any of the other modules. + *****************************************************************************/ +STATUS NSS_ParseFirstStartupCmdline( + BYTE *commandLine, + BOOL *didHelp) +{ + UserParm_s userparm; + ASSERT_MPKNSS_LOCK(); + *didHelp = FALSE; + userparm.didHelp = didHelp; + +#if zNETWARE + return LB_ParseCmdline(NSS_CommandLineSwitches, + POPT_AT_STARTUP|POPT_NO_UNKNOWN_SWITCH_ERRORS|POPT_FIRST_PARSE,commandLine, &userparm); +#endif +#if zLINUX + return LB_ParseCmdline(NSS_CommandLineSwitches, + POPT_AT_STARTUP|POPT_NO_UNKNOWN_SWITCH_ERRORS|POPT_FIRST_PARSE|POPT_NO_PARSE_TIME_ERRORS, + commandLine, &userparm); +#endif +} + + +/************************************************************************** + * We have loaded all of the modules, this will see if there are any + * switches for them. + ***************************************************************************/ +STATUS NSS_ParseSecondStartupCmdline( + BYTE *commandLine, + BOOL *didHelp) +{ + typedef struct Stack_s { + PCLMultiSwitchList_s multiList[MAX_CMDLINE_MODULES]; + } Stack_s; + Stack_s *aStack; + STATUS status; + UserParm_s userparm; + + + ASSERT_MPKNSS_LOCK(); + + *didHelp = FALSE; + userparm.didHelp = didHelp; + + STACK_ALLOC_NO_ASTACK(); + BuildMultiList(aStack->multiList); +#if zNETWARE + status = LB_ParseCmdlineMulti(multiList,POPT_AT_STARTUP,commandLine,&userparm, + NULL); +#endif +#if zLINUX + status = LB_ParseCmdlineMulti(aStack->multiList,POPT_AT_STARTUP|POPT_NO_PARSE_TIME_ERRORS,commandLine,&userparm, + NULL); +#endif + STACK_FREE(); + return status; +} + + +/************************************************************************** + * We have loaded all of the modules, this will see if there are any + * switches for them. + ***************************************************************************/ +STATUS NSS_ParseFinishStartupCmdline( + BYTE *commandLine, + BOOL *didHelp) +{ + typedef struct Stack_s { + PCLMultiSwitchList_s multiList[MAX_CMDLINE_MODULES]; + } Stack_s; + Stack_s *aStack; + STATUS status; + UserParm_s userparm; + + ASSERT_MPKNSS_LOCK(); + + *didHelp = FALSE; + userparm.didHelp = didHelp; + + STACK_ALLOC_NO_ASTACK(); + BuildMultiList(aStack->multiList); +#if zNETWARE + status = LB_ParseCmdlineMulti(multiList,POPT_AT_RUNTIME,commandLine,&userparm,NULL); +#endif +#if zLINUX + status = LB_ParseCmdlineMulti(aStack->multiList,POPT_AT_RUNTIME|POPT_NO_PARSE_TIME_ERRORS|POPT_NO_UNKNOWN_SWITCH_ERRORS, + commandLine,&userparm,NULL); +#endif + STACK_FREE(); + return status; +} +/**************************************************************************** + *****************************************************************************/ +LONG NSS_UnloadModuleFailEventID = 0; + +#if zNETWARE +void NSS_UnloadFailed(LONG moduleHandle) +{ + MPKNSS_LOCK(); + if (moduleHandle == (LONG)NSS_ModuleHandle) + { +#ifndef __linux__ // LINUX_Events + ZOS_EventNotificationUnReg(NSS_UnloadModuleFailEventID); +#endif + NSS_CommandLineStartup(); + NSS_UnloadModuleFailEventID = 0; + } + MPKNSS_UNLOCK(); +} +#endif + +#ifdef __linux__ // LINUX_ConsoleCommands + /* FixFixFix(linux) - port NSSConsoleCmdParser() and other NetWare specific command line functions */ +/* functions */ +#define HelpOnCommand 0x00000000 +#define GetSubCommands 0x00000001 +#define ProcessCommand 0x00000002 +#endif + +/**************************************************************************** + * If this detects it is a NSS command it routes it to internal handling + * routines. + *****************************************************************************/ +LONG NSSConsoleCmdParser( + LONG function, + struct ScreenStruct *systemConsoleScreen, + BYTE *commandLine, + BYTE *UprCommandLine, + LONG callerData) +{ + STATUS status; + typedef struct Stack_s { + PCLMultiSwitchList_s multiList[MAX_CMDLINE_MODULES]; + } Stack_s; + Stack_s *aStack; + + MPKNSS_LOCK(); + status = zOK; + + X_LATCH(&NSSConsoleCmdLatch); + + /* "NSS" has already been stripped from the commandline string */ + + if ((*commandLine == 0) || /* see if it was the only thing on the line*/ + (function == HelpOnCommand) || (function == GetSubCommands)) + { + DisplayNSSHelp(POPT_AT_RUNTIME); /* yes, display help */ + UNX_LATCH(&NSSConsoleCmdLatch); + MPKNSS_UNLOCK(); + return 0; + } + +/*------------------------------------------------------------------------- + * Setup and parse the command line. + *-------------------------------------------------------------------------*/ + STACK_ALLOC_NO_ASTACK(); + BuildMultiList(aStack->multiList); + LB_ParseCmdlineMulti(aStack->multiList,POPT_AT_RUNTIME,commandLine,NULL, + NSS_ValidateSWList); + STACK_FREE(); +/*------------------------------------------------------------------------- + * We have to defer the processing of the exit command until we have + * returned from the command line parser because our exit unloads NLMs + * and we are still looking at the command line switch arrays from these + * foreign NLMs inside the PARSE routine. + *-------------------------------------------------------------------------*/ + if (doProcessExit) + { +#ifndef __linux__ // LINUX_Exit +#define COMN_ChangeVolumeStateByNameAPI "\x1C""COMN_ChangeVolumeStateByName" + STATUS (*COMN_ChangeVolumeStateByNamePtr)(GeneralMsg_s *genMsg, + unicode_t *name, NINT destState, NINT mode); +#endif // #ifndef __linux__ + doProcessExit = FALSE; /* On any failure we need this to be off. + * Had bug that is user rejected exit + * because files are open that we would + * re-execute this code on every NSS + * command. + */ +#ifndef __linux__ // LINUX_Exit + ZOS_ImportPublicSymbol(COMN_ChangeVolumeStateByNamePtr, + (LONG)NSS_ModuleHandle, (BYTE *)COMN_ChangeVolumeStateByNameAPI); + + if (COMN_ChangeVolumeStateByNamePtr != NULL) + { + GeneralMsg_s genMsg; + + COMN_STRUCT_INIT(genMsg); + COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE(&genMsg); + /* This is where we deactivate all the volumes when + * the user types 'NSS exit'. Note is the user then + * abort a deactivate because some files are open then + * we do not compete the exit part of the command either. + */ + if ((COMN_ChangeVolumeStateByNamePtr(&genMsg,L"all", + zVOLSTATE_DEACTIVE, + VOLMODE_VERBOSE|VOLMODE_USER_ABORTABLE|iVOLMODE_NSS_UNLOADING) == zOK) || + (GetErrno(&genMsg) != zERR_VOLUME_STATE_CHANGE_ABORTED)) + { + ZOS_UnImportPublicSymbol((LONG)NSS_ModuleHandle, + (BYTE *)COMN_ChangeVolumeStateByNameAPI); + if (NSS_UnloadNLMs(NULL) != zOK) + { + UNX_LATCH(&NSSConsoleCmdLatch); + MPKNSS_UNLOCK(); + return 0; + } + ZOS_EventNotificationReg(NSS_UnloadModuleFailEventID, + EVENT_MODULE_UNLOAD_FAIL, + NULL, NSS_UnloadFailed); + if (NSS_UnloadModuleFailEventID != 0) + { + NSS_CommandLineShutdown(); + } + LB_exitMyselfAndReturn(COMN_Resource.moduleHandle,0); + } + else + { + /* The unload was aborted by the user, don't unload */ + ZOS_UnImportPublicSymbol((LONG)NSS_ModuleHandle, + (BYTE *)COMN_ChangeVolumeStateByNameAPI); + } + } + else +#endif // #ifndef __linux__ // LINUX_Exit + { +#ifndef __linux__ // LINUX_Events + ZOS_EventNotificationReg(NSS_UnloadModuleFailEventID, + EVENT_MODULE_UNLOAD_FAIL, + NULL, NSS_UnloadFailed); +#endif // #ifndef __linux__ // LINUX_Events + if (NSS_UnloadModuleFailEventID != 0) + { + NSS_CommandLineShutdown(); + } +#ifdef __linux__ // LINUX_Exit + LB_exitMyselfAndReturn(NULL,0); +#endif // #ifndef __linux__ // LINUX_Exit +#ifndef __linux__ // LINUX_Exit + LB_exitMyselfAndReturn(COMN_Resource.moduleHandle,0); +#endif // #ifndef __linux__ // LINUX_Exit + } + } + UNX_LATCH(&NSSConsoleCmdLatch); + MPKNSS_UNLOCK(); + return 0; /* say we consumed the line */ +} + +/* + * Added NSS_ConsoleCmdParser for Linux nss Console + * Description: processes a command_line + * + */ +int NSS_ConsoleCmdParser(char *commandLine) +{ + UserParm_s userparm; + typedef struct Stack_s { + PCLMultiSwitchList_s multiList[MAX_CMDLINE_MODULES]; + } Stack_s; + Stack_s *aStack; + + userparm.didHelp = FALSE; + MPKNSS_LOCK(); + + STACK_ALLOC_NO_ASTACK(); + BuildMultiList(aStack->multiList); + LB_ParseCmdlineMulti(aStack->multiList,POPT_AT_RUNTIME,commandLine,&userparm, + NULL); + STACK_FREE(); + MPKNSS_UNLOCK(); + return 0; +} + +#if 0 +/**************************************************************************** + * If this detects it is a NSS command it routes it to internal handling + * routines. + *****************************************************************************/ +LONG NSS_ConsoleCmdParser( + struct ScreenStruct *systemConsoleScreen, + BYTE *commandLine) +{ + STATUS status; + PCLMultiSwitchList_s multiList[MAX_CMDLINE_MODULES]; + + static char nssName[] = MSGNot("NSS"); + +# define NSSNAME_LEN (sizeof(nssName)-1) + MPKNSS_LOCK(); + status = 0; + + if (memicmp(commandLine,nssName,NSSNAME_LEN) != 0) + { + MPKNSS_UNLOCK(); + return -1; + } + + commandLine += NSSNAME_LEN; + if (*commandLine == 0) /* see if it was the only thing on the line*/ + { + DisplayNSSHelp(POPT_AT_RUNTIME); /* yes, display help */ + MPKNSS_UNLOCK(); + return 0; + } + + if (*commandLine != ' ') /* there was a letter immediatly following NSS*/ + { /* so it is some other command */ + MPKNSS_UNLOCK(); + return -1; + } +/*------------------------------------------------------------------------- + * Setup and parse the command line. + *-------------------------------------------------------------------------*/ + BuildMultiList(multiList); + LB_ParseCmdlineMulti(multiList,POPT_AT_RUNTIME,commandLine,NULL, + NSS_ValidateSWList); +/*------------------------------------------------------------------------- + * We have to defer the processing of the exit command until we have + * returned from the command line parser because our exit unloads NLMs + * and we are still looking at the command line switch arrays from these + * foreign NLMs inside the PARSE routine. + *-------------------------------------------------------------------------*/ + if (doProcessExit) + { +#define COMN_ChangeVolumeStateByNameAPI "\x1C""COMN_ChangeVolumeStateByName" + STATUS (*COMN_ChangeVolumeStateByNamePtr)(GeneralMsg_s *genMsg, + unicode_t *name, NINT destState, NINT mode); + + doProcessExit = FALSE; /* On any failure we need this to be off. + * Had bug that is user rejected exit + * because files are open that we would + * re-execute this code on every NSS + * command. + */ + ZOS_ImportPublicSymbol(COMN_ChangeVolumeStateByNamePtr, + (LONG)NSS_ModuleHandle, (BYTE *)COMN_ChangeVolumeStateByNameAPI); + + if (COMN_ChangeVolumeStateByNamePtr != NULL) + { + GeneralMsg_s genMsg; + + COMN_STRUCT_INIT(genMsg); + COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE(&genMsg); + /* This is where we deactivate all the volumes when + * the user types 'NSS exit'. Note is the user then + * abort a deactivate because some files are open then + * we do not compete the exit part of the command either. + */ + if ((COMN_ChangeVolumeStateByNamePtr(&genMsg,L"all", + zVOLSTATE_DEACTIVE, + VOLMODE_VERBOSE|VOLMODE_USER_ABORTABLE|iVOLMODE_NSS_UNLOADING) == zOK) || + (GetErrno(&genMsg) != zERR_VOLUME_STATE_CHANGE_ABORTED)) + { + ZOS_UnImportPublicSymbol((LONG)NSS_ModuleHandle, + (BYTE *)COMN_ChangeVolumeStateByNameAPI); + if (NSS_UnloadNLMs(NULL) != zOK) + { + MPKNSS_UNLOCK(); + return 0; + } + ZOS_EventNotificationReg(NSS_UnloadModuleFailEventID, + EVENT_MODULE_UNLOAD_FAIL, + NULL, NSS_UnloadFailed); + if (NSS_UnloadModuleFailEventID != 0) + { + NSS_CommandLineShutdown(); + } + LB_exitMyselfAndReturn(COMN_Resource.moduleHandle,0); + } + else + { + /* The unload was aborted by the user, don't unload */ + ZOS_UnImportPublicSymbol((LONG)NSS_ModuleHandle, + (BYTE *)COMN_ChangeVolumeStateByNameAPI); + } + } + else + { + ZOS_EventNotificationReg(NSS_UnloadModuleFailEventID, + EVENT_MODULE_UNLOAD_FAIL, + NULL, NSS_UnloadFailed); + if (NSS_UnloadModuleFailEventID != 0) + { + NSS_CommandLineShutdown(); + } + LB_exitMyselfAndReturn(COMN_Resource.moduleHandle,0); + } + } + MPKNSS_UNLOCK(); + return 0; /* say we consumed the line */ +} + +#endif + +/************************************************************************** + * This is called by NetWares command process when help is requested. + ***************************************************************************/ +/*LONG PSSCommandHelp( + struct ScreenStruct *screen, + BYTE *uprCmdln, + BYTE *keyword, + LONG callerSuppliedData) +{ + UNUSED_PARAM(screen); + UNUSED_PARAM(uprCmdln); + UNUSED_PARAM(keyword); + UNUSED_PARAM(callerSuppliedData); + + DisplayPSSHelp(FALSE); + return 0; +} +*/ +/************************************************************************** + * This routine will parse the console commands that come from the Netware + * command line. + ***************************************************************************/ +/*LONG PSSCommandParser( + struct ScreenStruct *screen, + BYTE *cmdln, + BYTE *upperCmdln, + LONG callerSuppliedData) +{ + UNUSED_PARAM(screen); + UNUSED_PARAM(upperCmdln); + UNUSED_PARAM(callerSuppliedData); + + return ParsePSSCommandLine(cmdln,FALSE,NULL); +} +*/ + +/*======================================================================== + *======================================================================== + * Routines to register our command line into NetWare + *======================================================================== + *========================================================================*/ +//struct commandParserStructure NSSConsoleCmdParserCtrl; + +/************************************************************************** + * Initialize NetWare console command parser for NSS. + ***************************************************************************/ +STATUS NSS_CommandLineStartup(void) +{ +#ifndef __linux__ // LINUX_ConsoleCommands + LONG result; +#endif // #ifndef __linux__ // LINUX_ConsoleCommands +/** NSSConsoleCmdParserCtrl.parseRoutine = NSS_ConsoleCmdParser; + ** NSSConsoleCmdParserCtrl.RTag = COMN_Resource.consoleCmdRTag; **/ + + ASSERT_MPKNSS_LOCK(); + +/** RegisterCommand((LONG)Resource.appHandle,COMN_Resource.cmdLineRTag,0, + ** MSGNot("NSS"),0,0,PSSCommandParser,PSSCommandHelp,0); **/ +/** ZOS_RegisterConsoleCommand(result,&NSSConsoleCmdParserCtrl); **/ + +#ifndef __linux__ // LINUX_ConsoleCommands + MPKNSS_UNLOCK(); + + result = RegisterCommand((LONG)COMN_Resource.moduleHandle, + COMN_Resource.cmdLineRTag, 0, MSGNot("NSS"), + AnyProcessBit, 0, NSSConsoleCmdParser, 0); + MPKNSS_LOCK(); + + if (result != zOK) + { + errPrintf(WHERE, Module, 401, + MSG("Registering NSS Console Command Parser.", 203)); + return zFAILURE; + } + +#endif // #ifndef __linux__ // LINUX_ConsoleCommands + + INIT_LATCH(&NSSConsoleCmdLatch); + + return zOK; +} + +/************************************************************************** + * Remove Netware console command parser. + ***************************************************************************/ +void NSS_CommandLineShutdown(void) +{ + ASSERT_MPKNSS_LOCK(); +/* ZOS_UnRegisterConsoleCommand(&NSSConsoleCmdParserCtrl); */ +/* DeRegisterCommand((LONG)Resource.appHandle,COMN_Resource.cmdLineRTag,0,MSGNot("NSS"));*/ +#ifndef __linux__ // LINUX_ConsoleCommands + MPKNSS_UNLOCK(); + DeRegisterCommand((LONG)COMN_Resource.moduleHandle, + COMN_Resource.cmdLineRTag, 0, MSGNot("NSS")); + MPKNSS_LOCK(); +#endif // #ifndef __linux__ // LINUX_ConsoleCommands +} + + + +/*========================================================================= + *========================================================================= + *========================================================================= + * Command Line Parsing Stuff + *========================================================================= + *========================================================================= + *=========================================================================*/ + +/************************************************************************** + * Flag that we need to EXIT the NLMs + ***************************************************************************/ +STATUS doExit( + PCLSwitchDef_s *switchDef, + NINT parseOptions, + void *userParm) +{ + MPKNSS_LOCK(); + doProcessExit = TRUE; + MPKNSS_UNLOCK(); + return zOK; +} + +/************************************************************************** + * Display HELP information + ***************************************************************************/ +STATUS doHelp( + PCLSwitchDef_s *switchDef, + NINT parseOptions, + void *userParm) +{ + MPKNSS_LOCK(); + UNUSED_PARAM(switchDef); + + DisplayNSSHelp(parseOptions); + +#ifndef __linux__ //LINUX_ConsoleCommands + if (userParm) + { + *((UserParm_s *)userParm)->didHelp = TRUE; + } +#endif + MPKNSS_UNLOCK(); + return zOK; +} + +/************************************************************************** + * Display HIDDEN information + ***************************************************************************/ +STATUS doHidden ( + PCLSwitchDef_s *switchDef, + NINT parseOptions, + void *userParm) +{ + MPKNSS_LOCK(); + UNUSED_PARAM(switchDef); + + DisplayNSSHidden(parseOptions); +#ifndef __linux__ + if (userParm) + { + *((UserParm_s *)userParm)->didHelp = TRUE; + } +#endif + MPKNSS_UNLOCK(); + return zOK; +} + +/************************************************************************** + * Display HIDDEN information + ***************************************************************************/ +STATUS doIgnoreTimeZone ( + PCLSwitchDef_s *switchDef, + NINT parseOptions, + void *userParm) +{ + UNUSED_PARAM(switchDef); + NSS_SetIgnoreTimeZone(*(BOOL *)switchDef->ret_value); + return zOK; +} + +/************************************************************************** + * Display version Information + ***************************************************************************/ +void NSS_doDisplayVersion(void) +{ + MPKNSS_LOCK(); + DISPLAY_DEFAULT_VERSION_INFORMATION(MSG("Enabled\n",204)); + MPKNSS_UNLOCK(); +} + + +/*------------------------------------------------------------------------- + * Handle the NSS configuration menu and all menu loading + *-------------------------------------------------------------------------*/ +void NSS_doMenuLoad(LONG startmenu, char *cmdline) +{ + + MPKNSS_LOCK(); + /* This is the same message that nwconfig displays */ + aprintf(YELLOW,MSG("ConsoleOne now provides these options on the Media tab of the server properties page.\n",285) ); + MPKNSS_UNLOCK(); + return; +} + +STATUS doMenuNSS( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ +// NSS_doMenuLoad(NSSMENU, NULL); +// return zOK; + /* Make it so that nss /menu will load nssmu.nlm */ +#ifndef __linux__ // LINUX_NSSMU + return LoadModule(NSS_DefaultScreen, MSGNot("NSSMU.NLM"), 0); +#endif // #ifndef __linux__ //LINUX_NSSMU +#ifdef __linux__ //LINUX_NSSMU + return( zFAILURE ); +#endif // #ifndef __linux__ //LINUX_NSSMU +} + +STATUS getErrString( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + aprintf(YELLOW, MSG("Error=%s\n", 275), + GetErrorFromNumber(*(NINT *)switchDef->ret_value)); + return zOK; +} + +extern STATUS doListHistograms( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doEnableHistogram( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doDisableHistogram( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doDisplayHistogram( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doClearHistogram( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + + +extern STATUS doLatchInstEnable( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doLatchInstReset( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doLatchInstDisplay( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +#if NSS_DEBUG IS_DISABLED + +extern BOOL MeasureSpinLock; + +extern STATUS doSpinLockInstEnable( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doSpinLockInstDisplay( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doSpinLockInstReset( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +#endif + +/************************************************************************** + * Search for a command that meets a regular expression definition + ***************************************************************************/ +# define MSG_INDENT 24 +# define INITIAL_INDENT 0 + +void FindCommand(char *expression, NINT hiddenFlag) +{ +#define MSG_INDENT 24 +#define SCREEN_WIDTH 79 +#define LINE_BUF_LEN 1024 + + typedef struct Stack_s { + PCLMultiSwitchList_s multiList[MAX_CMDLINE_MODULES]; + } Stack_s; + Stack_s *aStack; + + PCLSwitchDef_s *swdef; /* switch definitions array*/ + + NINT sl,j; + NINT cmdCnt; + NINT lastIndex; + + char *outstr; + char *helpStr; + char *endStr; + int numBlanks; + int nextCharPos = 0; + int remLength; + int spaceAvail; + int indent = MSG_INDENT; + char *strbuf; + char **msgTable; + CmdNameSort_s (*sortArray)[]; /* sorted list of command pointers */ + + ASSERT_MPKNSS_LOCK(); + + wPause(stdout, -1); + + if((strbuf = malloc(LINE_BUF_LEN)) == NULL) + { + aprintf(LRED, MSGNot("Message will not fit in line buffer \n")); + return; + } + + STACK_ALLOC_NO_ASTACK(); + BuildMultiList(aStack->multiList); + +/* + Count how many elements we'll need to sort +*/ + for (sl=cmdCnt=0;(swdef = aStack->multiList[sl].swList) != NULL;sl++) + { + if (swdef->name != PCMDLINE_ENDOFLIST) + { + for (;swdef->name != PCMDLINE_ENDOFLIST;swdef++) + { + if(((!hiddenFlag) && ((swdef->type & SWOPT_HIDDEN) == 0))|| + (hiddenFlag && (swdef->type & SWOPT_HIDDEN))) + { + strcpy(strbuf, swdef->name); + for(outstr = strbuf; (*outstr = toupper(*outstr)) != '\0'; outstr++); + /* do the expression compare here, and if match, display it */ + if(isMatch(expression,strbuf)) + cmdCnt++; + } + } + } + } + +/* + Allocate an array to sort +*/ + if((cmdCnt == 0) || ((sortArray = malloc(cmdCnt * sizeof(CmdNameSort_s))) == NULL)) + { + if(strbuf) + { + free(strbuf); + } + STACK_FREE(); + return; + } + +/* + Fill in the array with the pointers to the switches to display +*/ + for (sl=cmdCnt=0;(swdef = aStack->multiList[sl].swList) != NULL;sl++) + { + if (swdef->name != PCMDLINE_ENDOFLIST) + { + for (;swdef->name != PCMDLINE_ENDOFLIST;swdef++) + { + if(((!hiddenFlag) && ((swdef->type & SWOPT_HIDDEN) == 0))|| + (hiddenFlag && (swdef->type & SWOPT_HIDDEN))) + { + strcpy(strbuf, swdef->name); + for(outstr = strbuf; (*outstr = toupper(*outstr)) != '\0'; outstr++); + /* do the expression compare here, and if match, save it it */ + if(isMatch(expression,strbuf)) + { + (*sortArray)[cmdCnt].msgTable = aStack->multiList[sl].messageTable; + (*sortArray)[cmdCnt].swdef = swdef; + cmdCnt++; + } + } + } + } + } + + /* bubble sort the array by switch names */ + lastIndex = cmdCnt - 1; + for (sl=0; sl < lastIndex; sl++) + { + for (j=0; j < lastIndex - sl; j++) + { + if(strcmp((*sortArray)[j].swdef->name, (*sortArray)[j+1].swdef->name) > 0) + { + msgTable = (*sortArray)[j].msgTable; + swdef = (*sortArray)[j].swdef; + (*sortArray)[j].msgTable = (*sortArray)[j+1].msgTable; + (*sortArray)[j].swdef = (*sortArray)[j+1].swdef; + (*sortArray)[j+1].msgTable = msgTable; + (*sortArray)[j+1].swdef = swdef; + } + } + } +/* + Now output the sorted array +*/ + for (sl=0; sltype)) + { + case SWTYPE_NAME: + case SWTYPE_REQUIRED: + case SWTYPE_OPTIONAL: + aprintf(CYAN,MSGNot(" %s "),swdef->name); + nextCharPos = 6; + break; + case SWTYPE_BOOLEAN: + aprintf(CYAN,MSGNot("/(No)%s "),swdef->name); + nextCharPos = 6; + break; + case SWTYPE_VALUE: + aprintf(CYAN,MSGNot(" /%s= "),swdef->name); + nextCharPos = 7; + break; + } + nextCharPos += strlen(swdef->name); + if(nextCharPos < indent) + { + for(numBlanks = indent - nextCharPos; numBlanks > 0; numBlanks--) + { + aprintf(CYAN,MSGNot(" ")); + } + spaceAvail = SCREEN_WIDTH-indent; + } + else + { + spaceAvail = SCREEN_WIDTH - nextCharPos; + } + + + strbuf[0] = 0; + helpStr = StructGetMSGStrWithTable(swdef->helpStr, msgTable); + helpStr = (helpStr != NULL) ? helpStr : MSGNot(""); + + if(*helpStr) + { + while(*helpStr) + { + remLength = strlen(helpStr); + /* if the line wil fit, print it. If it won't fit, back off to the + * closest space. If not space found, enfource a wrap point + */ + if(remLength <= spaceAvail) + { + endStr = helpStr + remLength; + } + else + { + for(endStr = helpStr+spaceAvail; + (endStr != helpStr) && (*endStr != ' '); endStr--); + + if(endStr == helpStr) + { + endStr = helpStr + spaceAvail; + } + } + for(;helpStr != endStr; helpStr++) + aprintf(LGREEN, MSGNot("%c"), *helpStr); + aprintf(LGREEN, MSGNot("\n")); + while(*helpStr == ' ') + helpStr++; + if(*helpStr) + { + aprintf(LGREEN, MSGNot(" ")); + spaceAvail = SCREEN_WIDTH - indent; + } + LB_delay(2); + } + } + else + { + aprintf(LGREEN, MSGNot("\n")); + } + +#else + { + NINT row, col; + swdef = (*sortArray)[sl].swdef; + msgTable = (*sortArray)[sl].msgTable; + + printf(MSGNot(" ")); /* this forces something out so the line will scroll*/ + wGetPos(wStdout,&row,&col); + wSetPos(wStdout,row,INITIAL_INDENT); + + switch (GET_SWTYPE(swdef->type)) + { + case SWTYPE_NAME: + aprintf(CYAN,MSGNot(" %s "),swdef->name); + break; + case SWTYPE_REQUIRED: + aprintf(CYAN,MSGNot(" %s "),swdef->name); + break; + case SWTYPE_OPTIONAL: + aprintf(CYAN,MSGNot(" %s "),swdef->name); + break; + case SWTYPE_BOOLEAN: + aprintf(CYAN,MSGNot("/(No)%s "),swdef->name); + break; + case SWTYPE_VALUE: + aprintf(CYAN,MSGNot(" /%s= "),swdef->name); + break; + } + wGetPos(wStdout,&row,&col); + if (col < MSG_INDENT) + wSetPos(wStdout,row,MSG_INDENT); + + helpStr = StructGetMSGStrWithTable(swdef->helpStr,msgTable); + outstr = ((helpStr != NULL) ? helpStr : MSGNot("")); + + LB_wWrapString(wStdout,LGREEN,MSG_INDENT,outstr); + } +#endif + } + free(strbuf); + free (sortArray); + wPause(stdout, 0); + STACK_FREE(); + return; +} + + +STATUS doFindVisibleCommand( + PCLSwitchDef_s *switchDef, + NINT parseOptions, + void *userParm) +{ + MPKNSS_LOCK(); + + FindCommand(switchDef->ret_value, FALSE ); + + MPKNSS_UNLOCK(); + return zOK; +} + + +STATUS doFindHiddenCommand( + PCLSwitchDef_s *switchDef, + NINT parseOptions, + void *userParm) +{ + MPKNSS_LOCK(); + + FindCommand(switchDef->ret_value, TRUE); + + MPKNSS_UNLOCK(); + return zOK; +} + +#if NSS_DEBUG IS_ENABLED +/*------------------------------------------------------------------------- + * Handle BOOLEAN trace value + *-------------------------------------------------------------------------*/ +STATUS doBoolDebug( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + MPKNSS_LOCK(); + + if (*(BOOL *)switchDef->ret_value) + { + DBG_DebugFlag = DBG_SavedDebugFlag; + DBG_InitDebug(); + } + else + { + DBG_DebugFlag = TNONE; + if ((DBG_DebugFlag == TNONE) && (DBG_TraceFlag == TNONE)) + { + DBG_UninitDebug(); + } + } + MPKNSS_UNLOCK(); + return zOK; +} + +/*------------------------------------------------------------------------- + * Handle an explicit Debug value + *-------------------------------------------------------------------------*/ +STATUS doValueDebug( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + MPKNSS_LOCK(); + + if (DBG_DebugFlag != 0) + { + DBG_SavedDebugFlag = DBG_DebugFlag; + DBG_InitDebug(); + } + else + { + if ((DBG_DebugFlag == TNONE) && (DBG_TraceFlag == TNONE)) + { + DBG_UninitDebug(); + } + } + MPKNSS_UNLOCK(); + + return zOK; +} + +/*------------------------------------------------------------------------- + * Handle BOOLEAN trace value + *-------------------------------------------------------------------------*/ +STATUS doScreenDebug( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + MPKNSS_LOCK(); + + if (*(BOOL *)switchDef->ret_value) + { + DBG_debugLogMask |= DEBUG_LOG_SCREEN; + } + else + { + DBG_debugLogMask &= ~DEBUG_LOG_SCREEN; + } + MPKNSS_UNLOCK(); + return zOK; +} + + +/*------------------------------------------------------------------------- + * Handle BOOLEAN trace value + *-------------------------------------------------------------------------*/ +STATUS doBoolTrace( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + MPKNSS_LOCK(); + if (*(NINT *)switchDef->ret_value) + { + DBG_TraceFlag = DBG_SavedTraceFlag; + DBG_InitDebug(); + } + else + { + DBG_TraceFlag = TNONE; + if ((DBG_DebugFlag == TNONE) && (DBG_TraceFlag == TNONE)) + { + DBG_UninitDebug(); + } + } + MPKNSS_UNLOCK(); + return zOK; +} + +/*------------------------------------------------------------------------- + * Handle an explicit TRACE value + *-------------------------------------------------------------------------*/ +STATUS doValueTrace( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + MPKNSS_LOCK(); + if (DBG_TraceFlag != 0) + { + DBG_SavedTraceFlag = DBG_TraceFlag; + DBG_InitDebug(); + } + else + { + if ((DBG_DebugFlag == TNONE) && (DBG_TraceFlag == TNONE)) + { + DBG_UninitDebug(); + } + } + MPKNSS_UNLOCK(); + return zOK; +} + +/*------------------------------------------------------------------------- + * Handle the start of the debug storage menu + *-------------------------------------------------------------------------*/ +STATUS doMenuDBG( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + NSS_doMenuLoad(NSSDEBUGMENU, NULL); + return zOK; +} + +STATUS doMenuCFG( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + NSS_doMenuLoad(NWCONFIGMENU, NULL); + return zOK; +} + /*------------------------------------------------------------------------- + * Test GUID generation + *-------------------------------------------------------------------------*/ +STATUS doGUIDDebug( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + GUID_t newGUID; +/* NINT saveDebugMask; */ + NINT i; + MPKNSS_LOCK(); +/* saveDebugMask = DBG_debugLogMask; + DBG_debugLogMask |= DEBUG_LOG_SCREEN; +*/ + for (i=0; i<1000; i++) + { + LB_GUIDGenerate(&newGUID); + if (!LB_GUIDValidate(&newGUID)) + { + DBG_DebugPrintf(LRED, "Error in the GUID!\n"); + } + } + +/* DBG_debugLogMask = saveDebugMask; */ + MPKNSS_UNLOCK(); + return zOK; +} + +#endif + + + +#if zNETWARE +extern STATUS doSetDefaultNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doSetZLSSNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doSetCDDVDNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doSetNWPRVNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doSetDOSFATNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doSetnoLSSNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doSetallLSSNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); + +extern STATUS doSetallallLSSNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); +#endif + +#ifndef __linux__ +STATUS doClearDataCache ( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + xReleaseAllPages(); + return zOK; +} +#endif + +/*------------------------------------------------------------------------- + * Definition of allowable commands from the NetWare command line. + *-------------------------------------------------------------------------*/ +#define swHelpHelp StructMSG("Display this help information.", 205) + + +#if NSS_COPY_ON_XLATCH IS_ENABLED +BOOL gNSSCopyOnXLatch=TRUE; +#endif + + +/*--------------------------------------------------------------------------- + * General command line switch table + *---------------------------------------------------------------------------*/ +PCLSwitchDef_s NSS_CommandLineSwitches[] = +{ +#if NSS_COPY_ON_XLATCH IS_ENABLED + {MSGNot("CopyBuffersOnXLatch"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_BOOLEAN|SWVAL_BOOL|SWOPT_HIDDEN, + 0, 0, + NULL,&gNSSCopyOnXLatch, + {{0,0}},0,0, + {0} + }, +#endif + + {MSGNot("Xit"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_RUNTIME_ONLY|SWOPT_HIDDEN, + 0, 0, + doExit,NULL, + {{0,0}},0,0, + StructMSG("Unload " "NSS" " and all of its modules.", 206), + }, + + {MSGNot("Version"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_NAME|SWOPT_IGNORE_STATUS|SWOPT_RUNTIME_ONLY, + 0, 0, + (PCLFunction_t)NSS_doDisplayVersion,NULL, + {{0,0}},0,0, + StructMSG("Display version information for " "NSS" ".", 207) + }, + + {MSGNot("Modules"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_NAME|SWOPT_IGNORE_STATUS|SWOPT_RUNTIME_ONLY, + 0, 0, + (PCLFunction_t)NSS_doDisplayModules,NULL, + {{0,0}},0,0, + StructMSG("Display information about all of the modules loaded into " "NSS" ".",208) + }, + + {MSGNot("Help"), + NULL, + SWHELP_CAT_MISC|SWTYPE_NAME, + 0, 0, + doHelp,NULL, + {{0,0}},0,0, + swHelpHelp + }, + + {MSGNot("?"), + NULL, + SWHELP_CAT_MISC|SWTYPE_NAME|SWOPT_HELP_ADD_SLASH, + 0, 0, + doHelp,NULL, + {{0,0}},0,0, + swHelpHelp + }, + + {MSGNot("Hidden"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_NAME|SWOPT_HELP_ADD_SLASH|SWOPT_HIDDEN, + 0, 0, + doHidden,NULL, + {{0,0}},0,0, + StructMSGNot("Display hidden commands.") + }, + + {MSGNot("SkipLoadModules"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_BOOLEAN|SWVAL_BOOL|SWOPT_STARTUP_ONLY, + 0, 0, + NULL,&NSS_SkipLoadModules, + {{0,0}},0,0, + StructMSG("If specified, skip the auto loading of the " "NSS" " support modules.",209) + }, + +#if zNETWARE + {MSGNot("noLSS"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_STARTUP_ONLY, + 0, 0, + doSetnoLSSNLMs,NULL, + {{0,0}},0,0, + StructMSG("If specified, do not load any LSS module.",210) + }, + + {MSGNot("allLSS"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_STARTUP_ONLY, + 0, 0, + doSetallLSSNLMs,NULL, + {{0,0}},0,0, + StructMSG("If specified, load all the LSS modules.",211) + }, + + {MSGNot("knownLSS"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_STARTUP_ONLY|SWOPT_HIDDEN, + 0, 0, + doSetallallLSSNLMs,NULL, + {{0,0}},0,0, + StructMSG("If specified, load each and every LSS module available, including all the debug ones.", 212) + }, + + {MSGNot("defaultNLMs"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_STARTUP_ONLY, + 0, 0, + doSetDefaultNLMs,NULL, + {{0,0}},0,0, + StructMSG("If specified, load only default NSS NLMs, and any additional LSS modules specified on the command line.",213) + }, + + {MSGNot("CDDVD"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_STARTUP_ONLY, + 0, 0, + doSetCDDVDNLMs,NULL, + {{0,0}},0,0, + StructMSG("If specified, load only those modules essential for CDDVD support.",214) + }, + + {MSGNot("DOSFAT"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_STARTUP_ONLY, + 0, 0, + doSetDOSFATNLMs,NULL, + {{0,0}},0,0, + StructMSG("If specified, load only those modules essential for DOSFAT support.",217) + }, + + {MSGNot("zLSS"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_STARTUP_ONLY, + 0, 0, + doSetZLSSNLMs,NULL, + {{0,0}},0,0, + StructMSG("If specified, load only those modules essential for zLSS support.",219) + }, + + {MSGNot("NWPRV"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_STARTUP_ONLY|SWOPT_HIDDEN, + 0, 0, + doSetNWPRVNLMs,NULL, + {{0,0}},0,0, + StructMSG("If specified, load NWPRV and specify the LSS' that you want to load on the command line.",220) + }, +#endif // #if zNETWARE + + {MSGNot("Menu"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_RUNTIME_ONLY|SWOPT_HIDDEN, + 0, 0, + doMenuNSS,NULL, + {{0,0}},0,0, + StructMSG("Start the NSS Configuration Menu.", 221) + }, + + {MSGNot("ErrorCode"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_VALUE|SWVAL_NINT, + 0, 0, + (PCLFunction_t)getErrString, 0, + {{ERR_NSS_FIRST_ERROR, ERR_NSS_LAST_ERROR}}, 0, 0, + StructMSG("Translate error code to a string", 276) + }, + + {MSGNot("IgnoreTimeZone"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_BOOLEAN|SWVAL_BOOL|SWOPT_HIDDEN, + 0, 0, + doIgnoreTimeZone, &IgnoreTimeZone, + {{0, 0}}, 0, 0, + StructMSG("If set then DOS/UTC time conversions do not adjust for the time zone.", 153) + }, + + {MSGNot("ListHistograms"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_NAME|SWOPT_HIDDEN, + 0,0, + doListHistograms, NULL, + {{0,0}},0,0, + StructMSGNot("Print list of registered histograms.") + }, + + {MSGNot("EnableHistogram"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_VALUE|SWVAL_CHAR|SWOPT_HIDDEN, + 0,0, + doEnableHistogram,NULL, + {{0,0}},0,0, + StructMSGNot("Enable the named histogram.") + }, + + {MSGNot("DisableHistogram"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_VALUE|SWVAL_CHAR|SWOPT_HIDDEN, + 0,0, + doDisableHistogram,NULL, + {{0,0}},0,0, + StructMSGNot("Disable the named histogram.") + }, + + {MSGNot("DisplayHistogram"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_VALUE|SWVAL_CHAR|SWOPT_HIDDEN, + 0,0, + doDisplayHistogram,NULL, + {{0,0}},0,0, + StructMSGNot("Display the named histogram.") + }, + + {MSGNot("ClearHistogram"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_VALUE|SWVAL_CHAR|SWOPT_HIDDEN, + 0,0, + doClearHistogram,NULL, + {{0,0}},0,0, + StructMSGNot("Clear the named histogram.") + }, + + + {MSGNot("LatchInstEnable"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_BOOLEAN|SWVAL_BOOL|SWOPT_HIDDEN, + 0,0, + doLatchInstEnable,&RecordLatches, + {{0,0}},0,0, + StructMSGNot("Turn on/off latch instrumentation.") + }, + + {MSGNot("LatchInstDisplay"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_NAME|SWOPT_RUNTIME_ONLY|SWOPT_NO_HELP_VALUE|SWOPT_HIDDEN, + 0,0, + doLatchInstDisplay,NULL, + {{0,0}},0,0, + StructMSGNot("Display latch instrumentation.") + }, + + {MSGNot("LatchInstReset"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_NAME|SWOPT_RUNTIME_ONLY|SWOPT_NO_HELP_VALUE|SWOPT_HIDDEN, + 0,0, + doLatchInstReset,NULL, + {{0,0}},0,0, + StructMSGNot("Reset latch instrumentation.") + }, + +#ifndef __linux__ + {MSGNot("ClearDataCache"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_RUNTIME_ONLY|SWOPT_HIDDEN, + 0,0, + doClearDataCache,NULL, + {{0,0}},0,0, + StructMSGNot("Clear as much from the data cache as possible.") + }, +#endif + +#if NSS_DEBUG IS_DISABLED + {MSGNot("SpinLockInstEnable"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_BOOLEAN|SWVAL_BOOL|SWOPT_HIDDEN, + 0,0, + doSpinLockInstEnable,&MeasureSpinLock, + {{0,0}},0,0, + StructMSGNot("Turn on/off latch instrumentation.") + }, + + {MSGNot("SpinLockInstDisplay"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_NAME|SWOPT_RUNTIME_ONLY|SWOPT_NO_HELP_VALUE|SWOPT_HIDDEN, + 0,0, + doSpinLockInstDisplay,NULL, + {{0,0}},0,0, + StructMSGNot("Display latch instrumentation.") + }, + + {MSGNot("SpinLockInstReset"), + NULL, + SWHELP_CAT_STATUS|SWTYPE_NAME|SWOPT_RUNTIME_ONLY|SWOPT_NO_HELP_VALUE|SWOPT_HIDDEN, + 0,0, + doSpinLockInstReset,NULL, + {{0,0}},0,0, + StructMSGNot("Reset latch instrumentation.") + }, +#endif + +#if NSS_DEBUG IS_ENABLED + /* Misc DEBUG switches */ + {MSGNot("Debug"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_BOOLEAN|SWVAL_BOOL|SWOPT_DEBUG|SWOPT_HIDDEN, + 0, 0, + doBoolDebug,&DBG_DebugEnabled, + {{0,0}},0,0, + StructMSGNot("Set debugging ON or OFF.") + }, + + {MSGNot("Debug"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_VALUE|SWVAL_QUAD|SWOPT_DEBUG|SWOPT_HIDDEN, + 0, 0, + doValueDebug,&DBG_DebugFlag, + {{0,0}},0,0, + StructMSGNot("Set which items to debug (bitmap).") + }, + + {MSGNot("Trace"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_BOOLEAN|SWVAL_BOOL|SWOPT_DEBUG|SWOPT_HIDDEN, + 0, 0, + doBoolTrace,&DBG_TraceEnabled, + {{0,0}},0,0, + StructMSGNot("Set tracing ON or OFF.") + }, + + {MSGNot("Trace"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_VALUE|SWVAL_QUAD|SWOPT_DEBUG|SWOPT_HIDDEN, + 0, 0, + doValueTrace,&DBG_TraceFlag, + {{0,0}},0,0, + StructMSGNot("Set which items to trace (bitmap).") + }, + + {MSGNot("StubMsgTrace"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_BOOLEAN|SWVAL_BOOL|SWOPT_HIDDEN, + 0, 0, + NULL,&DBG_Stub, + {{0,0}},0,0, + StructMSGNot("Set Stub Message Tracing ON or OFF.") + }, + + {MSGNot("MallocTrace"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_BOOLEAN|SWVAL_BOOL|SWOPT_DEBUG|SWOPT_HIDDEN, + 0, 0, + NULL,&MallocTraceEnable, + {{0,0}},0,0, + StructMSGNot("Set Memory Allocating Tracing ON or OFF.") + }, + + {MSGNot("ScreenDebug"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_BOOLEAN|SWVAL_BOOL|SWOPT_DEBUG|SWOPT_HIDDEN, + 0, 0, + doScreenDebug,&DBG_ScreenDebug, + {{0,0}},0,0, + StructMSGNot("Set debug output to the screen ON or OFF.") + }, + + {MSGNot("DebugPaging"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_BOOLEAN|SWVAL_BOOL|SWOPT_DEBUG|SWOPT_HIDDEN, + 0, 0, + NULL,&DBG_Paging, + {{0,0}},0,0, + StructMSGNot("Set paging of the debug window ON or OFF.") + }, + + {MSGNot("DebugPageSize"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_VALUE|SWVAL_NINT|SWOPT_HAS_NUMERIC_RANGE|SWOPT_HIDDEN, + 0, 0, + NULL,&DBG_PageSize, + {{5,100}},0,0, + StructMSGNot("Set the page size of the debug window.") + }, + + {MSGNot("GUIDdebug"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_RUNTIME_ONLY|SWOPT_HIDDEN, + 0, 0, + doGUIDDebug,NULL, + {{0,0}},0,0, + StructMSGNot("Do a GUID debug test.") + }, + + {MSGNot("DebugBufferSize"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_VALUE|SWVAL_NINT|SWOPT_STARTUP_ONLY|SWOPT_HIDDEN, + 0, 0, + NULL,&DBG_DebugLogBufferSize, + {{0,0}},0,0, + StructMSGNot("Set size (in bytes) of '=d' buffer.") + }, + + {MSGNot("DbgMenu"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_RUNTIME_ONLY|SWOPT_HIDDEN, + 0, 0, + doMenuDBG,NULL, + {{0,0}},0,0, + StructMSGNot("Start the Storage Debug Menu.") + }, + + {MSGNot("NWCfgMenu"), + NULL, + SWHELP_CAT_CONTROL|SWTYPE_NAME|SWOPT_RUNTIME_ONLY|SWOPT_HIDDEN, + 0, 0, + doMenuCFG,NULL, + {{0,0}},0,0, + StructMSGNot("Start the NSS Configuration Menu.") + }, +#endif + +#ifdef __linux__ // LINUX_SetParms + // FixFixFix(Linux) - Need to port + // These are SET PARAM related and not need in linux. +#define SP_STARTUP_ONLY 0x00000001 +#define SP_TYPE_NUMBER 0 +#endif + + {MSGNot("Find"), + NULL, + SWHELP_CAT_MISC|SWTYPE_VALUE|SWVAL_CHAR|SWOPT_MAPUPPER|SWOPT_RUNTIME_ONLY, + 0, 0, + doFindVisibleCommand,NULL, + {{0,0}},0,0, + StructMSGNot("Find NSS command using regular expression search.") + }, + + {MSGNot("HiddenFind"), + NULL, + SWHELP_CAT_MISC|SWTYPE_VALUE|SWVAL_CHAR|SWOPT_MAPUPPER|SWOPT_RUNTIME_ONLY|SWOPT_HIDDEN, + 0, 0, + doFindHiddenCommand,NULL, + {{0,0}},0,0, + StructMSGNot("Find Hidden NSS command using regular expression search.") + }, + + {PCMDLINE_ENDOFLIST} +}; diff --git a/src/nwnss/nss/nssLKM.c b/src/nwnss/nss/nssLKM.c new file mode 100644 index 0000000..d1c2031 --- /dev/null +++ b/src/nwnss/nss/nssLKM.c @@ -0,0 +1,407 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NSS Linux initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2007-07-12 22:53:52 +0530 (Thu, 12 Jul 2007) $ + | + | $RCSfile$ + | $Revision: 2091 $ + | + |--------------------------------------------------------------------------- + | This module is used to: !!!Linux specific file!!! + | Preforms all program (LKM) initialization. See also nssNLM.c for + | NetWare version + | + +-------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include // FixFixFix(Linux) for test of LB_wPromptForYesOrNo() +#include "linuxmpk.h" +#include "nssStartup.h" + +const char Module[] = MODULE_NAME; +void *NSS_ModuleHandle = NULL; // Linux does not use +void *NSS_DefaultScreen; // FixFixFix(Linux) - Linux will not need at ship time + +int NSS_ConsoleCmdParser(char *commandline); + +//--------------------------------------------------------- +// CommandLine for placing entries read from the +// startup config file. +//--------------------------------------------------------- +#define CONFIG_FILENAME "/etc/opt/novell/nss/nssstart.cfg" +char NSS_CommandLine[1024]; + +//------------------------------------------------------- +//Parse the startupconfig file +//------------------------------------------------------- +void ParseNSSConfigFile( + BYTE *nssCmdLine, + NINT startPositionNssCmdLine, + SLONG maxLen) +{ + SLONG len; + int fd; + int filesize; + char *buffer; + char *bufferStart; + char *command_ptr; + char *comment_ptr; + char *endofline_ptr; + char *endoffile_ptr; + char **token_ptr; + int clearsize; + + //---------------------------------------------------------- + // nssCmdLine points to the position in the NSS_CommandLine + // where we can start to add startup commands + //---------------------------------------------------------- + nssCmdLine += startPositionNssCmdLine; + + //-------------------------------------------------------------- + // maxLen contains the number of characters left NSS_CommandLine + //-------------------------------------------------------------- + maxLen -= startPositionNssCmdLine; + maxLen--; // adjust for the null that will be needed + + //--------------------------------------------------------- + // Open config file and find the size. The size is used + // to create a buffer large enough to hold the whole file + //--------------------------------------------------------- + filesize = 0; + fd = mpkOpen(CONFIG_FILENAME, O_RDONLY, 0); + if (fd != -1) + { + char tmpBuf[128]; + while ( (len = mpkRead(fd, tmpBuf, 128)) > 0 ) + { + filesize+=len; + } + mpkClose(fd); + } + else + { + printk("<1>" "Unable to open: %s \n",CONFIG_FILENAME); + return; + } + + //-------------------------------------------------- + //Now allocate buffer big enough to read file + // then read file into buffer + //mark end of buffer with a 0 + //------------------------------------------------- + filesize++; + len = 0; + buffer = bufferStart = kmalloc(filesize,GFP_KERNEL); + if (buffer != NULL) + { + printk("<1>" "now open config files: %s\n",CONFIG_FILENAME); + fd = mpkOpen(CONFIG_FILENAME, O_RDONLY, 0); + if (fd == -1) + { + printk("<1>" "Unable to open: %s\n",CONFIG_FILENAME); + kfree(buffer); + return; + } + else + { + len = mpkRead(fd, buffer, filesize); + if (len !=0 ) + { + *(buffer+len) = 0; + } + } + } + + //------------------------------------------------------ + //Parse file + // Strip off comments to end of the line + // by changing comment text to spaces + //------------------------------------------------------ + endoffile_ptr = buffer+len; + while ( (comment_ptr = strchr(buffer,'#')) !=NULL) + { + endofline_ptr = strchr(comment_ptr,'\n'); + if (endofline_ptr == NULL) + { + endofline_ptr = endoffile_ptr; + } + clearsize = endofline_ptr - comment_ptr; + memset(comment_ptr,' ',clearsize); + } + + //--------------------------------------- + // Change line feeds and carraige returns to spaces + //--------------------------------------- + while ( (endofline_ptr = strchr(buffer,'\n')) !=NULL) + { + *endofline_ptr = ' '; + } + while ( (endofline_ptr = strchr(buffer,'\r')) !=NULL) + { + *endofline_ptr = ' '; + } + + //------------------------------------------ + // Now add tokens in buffer to command_line + //------------------------------------------ + token_ptr = &buffer; + while ( (command_ptr = strsep(token_ptr," ")) != NULL) + { + len = strlen(command_ptr); + + if ( len > 0 ) + { + if( maxLen > 0) + { + // Add a space before appending command + *nssCmdLine++ = ' '; + *nssCmdLine = 0; + maxLen--; + } + else + { + printk("<1>" "Too many commands in config file\n"); + } + } + + //----------------------------- + // Append command + //----------------------------- + if ( len > 0 ) + { + if( maxLen -len > 0) + { + memcpy(nssCmdLine,command_ptr,len); + nssCmdLine +=len; + *nssCmdLine = 0; //terminate string + maxLen -=len; + } + else + { + printk("<1>" "Too many commands in config file\n"); + } + } + } + + kfree(bufferStart); + + mpkClose(fd); //close config file + + return; +} + + +int nss_init_module(void) +{ +// BOOL upgrade; +// int key; +#if 0 + unsigned long long aQuad = UI64_CONST(0x123456789abcdef0); + long long aSQuad = I64_CONST(0xF123456789abcde0); +#endif + NINT maxLen = sizeof(NSS_CommandLine); + + MPKNSS_INIT_LOCK(); + +/* Include these lines to delay initialisation for remote debugging */ +#if 0 + mpkEnter(); + kDelayThread(5000); + mpkExit(); +#endif + + /* View printk output with dmesg in a terminal */ + printk("<1>" "NSS::%s[%d]\n", __FILE__, __LINE__ ); + mpkEnter(); + nkEventBusInit(); + printk("<1>" "NSS::%s[%d]\n", __FILE__, __LINE__ ); +#if 0 + { + void *m1,*m2,*m3,*m4; + void *m5,*m6; + int m5Amount, m6Amount; + + m1 = LB_zalloc( 512 ); + m2 = LB_zalloc( 512 ); + m3 = LB_zalloc( 512 ); +// m4 = LB_zalloc( 512 ); +// m2 = LB_zalloc( 1024*100 ); +// m3 = LB_zalloc( 1024*500 ); + m4 = LB_zalloc( 1024*1000 ); + m5Amount = 100; + m6Amount = 1; + m5 = LB_mallocPage( m5Amount ); + m6 = LB_mallocPage( m6Amount ); + printk("<1>" "NSS::%s[%d] %lx %lx %lx %lx\n", __FILE__, __LINE__, (ADDR)m1, (ADDR)m2, (ADDR)m3, (ADDR)m4 ); + if ( m1 ) + { + LB_free( m1 ); + } + if ( m2 ) + { + LB_free( m2 ); + } + if ( m3 ) + { + LB_free( m3 ); + } + if ( m4 ) + { + LB_free( m4 ); + } + if ( m5 ) + { + LB_freePage( m5, m5Amount ); + } + if ( m6 ) + { + LB_freePage( m6, m6Amount ); + } + } +#endif +#if 0 + LB_printf( "Please enter a key for NSS KLM " ); + key = NSS_wgetch( NSS_TYPE_OF_KEY_NORMAL ); // Retrieve a key from Kernel Space (We block until we key a key from NSS SCA) + LB_printf( "Please enter another key for NSS KLM " ); + key = NSS_wgetch( NSS_TYPE_OF_KEY_NORMAL ); // Retrieve a key from Kernel Space (We block until we key a key from NSS SCA) + LB_aprintf( 0, "Build A %d and a quad 0x%Lx(%Ld) and then the line again %d\n", __LINE__, aSQuad, aSQuad, __LINE__ ); + LB_aprintf( 0, "Build A %d and a quad 0x%Lx(%Ld) and then the line again %d\n", __LINE__, aSQuad, aSQuad, __LINE__ ); + LB_aprintf( 0, "Build A %d and a quad 0x%Lx(%Ld) and then the line again %d\n", __LINE__, aSQuad, aSQuad, __LINE__ ); + LB_printf( "Please enter 3rd key for NSS KLM " ); + key = NSS_wgetch( NSS_TYPE_OF_KEY_NORMAL ); // Retrieve a key from Kernel Space (We block until we key a key from NSS SCA) + + LB_aprintf( 0, + "Before proceeding, make sure that all processes relating to the\n" + "NetWare 65 upgrade have completed. For more information see the\n" + "Novell Storage Services Administration Guide at\n" + "http://www.novell.com/documentation/lg/nw65. Upgrading before the\n" + "server is ready can cause loss of trustees.\n" ); + upgrade = LB_wPromptForYesOrNo(NULL, FALSE, FALSE, "\nDo you wish to continue the upgrade now? " ); + upgrade = LB_wPromptForYesOrNo(NULL, TRUE, TRUE, "\nDo you wish to continue the upgrade? " ); + upgrade = LB_wPromptForYesOrNo(NULL, FALSE, FALSE, "\nDo you? " ); + +#endif + /* This reads NSSSTART.CFG from the dos default drive and the dos current + * directory. + */ +printk("<1>register NSS_ConsoleCmdParser\n"); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) + inter_module_register("NSS_ConsoleCmdParser",THIS_MODULE,NSS_ConsoleCmdParser); +#else + nss_register_module("NSS_ConsoleCmdParser",NSS_ConsoleCmdParser,THIS_MODULE); +#endif +printk("<1>ParseNSSConfigFile\n"); + ParseNSSConfigFile(NSS_CommandLine, strlen(NSS_CommandLine), maxLen); +printk("<1>NSSGlobal_Startup\n"); + NSSGlobal_Startup(); +printk("<1>mpkExit\n"); + mpkExit(); + printk("<1>" "NSS::%s[%d]\n", __FILE__, __LINE__ ); + + return(0); +} + + +/************************************************************************** + * This routine is called to UNLOAD the LKM + ***************************************************************************/ +void nss_cleanup_module(void) +{ + mpkEnter(); + nkEventBusDeInit(); + printk("<1>" "NSS::%s[%d]\n", __FILE__, __LINE__ ); + MPKNSS_LOCK(); + NSSGlobal_Shutdown(); + MPKNSS_UNLOCK(); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) + inter_module_unregister("NSS_ConsoleCmdParser"); +#else + nss_unregister_module("NSS_ConsoleCmdParser"); +#endif + printk("<1>" "NSS::%s[%d]\n", __FILE__, __LINE__ ); + mpkExit(); +} + + +//#include // For LB_vaprintf +// This should work until we get all UI out of the LKM for ship +// +// For the DEMO this output will be queued to go to user space (NSS SCA will display) +// FixFixFix(Linux) - change for ship!!! +// For ship we should not be using or can convert to a printk() +// +void OutputToScreenWithAttribute( void *screen, int attr, char *format, ... ) +{ + va_list args; + + va_start(args,format); + LB_vaprintf( attr, format, args ); + va_end( args ); + +} + +void __cyg_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void __cyg_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); + + +void __cyg_profile_func_enter (void *this_fn, void *call_site) +{ + nss_profile_func_enter(this_fn, call_site); + return; +} + +void __cyg_profile_func_exit (void *this_fn, void *call_site) +{ + nss_profile_func_exit(this_fn, call_site); + return; +} + + +module_init(nss_init_module); +module_exit(nss_cleanup_module); + +MODULE_AUTHOR("Novell, Inc."); +MODULE_DESCRIPTION("NSS LKM"); +MODULE_LICENSE("GPL v2"); diff --git a/src/nwnss/nss/nssLoadNLMs.c b/src/nwnss/nss/nssLoadNLMs.c new file mode 100644 index 0000000..6b9bdd3 --- /dev/null +++ b/src/nwnss/nss/nssLoadNLMs.c @@ -0,0 +1,668 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $ + | + | $RCSfile$ + | $Revision: 1325 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // NSS_Startup + // FixFixFix(Linux) - Port to Linux +#include /* NetWare */ +#include + +#include /* Library */ +#include +#include +#include +#include + +#include "nssStartup.h" +#include "nssLog.h" + +/*------------------------------------------------------------------------- + * Struct used to control what NLMs are loaded + *-------------------------------------------------------------------------*/ +typedef struct NLMLoadControl_s +{ + char *name; + NINT flags; +} NLMLoadControl_s; + +#define NLCFL_required 0x00000001 /* required for NSS to load */ + +#define MAX_LSS_COUNT 12 +#define NO_LSS_COUNT 5 +/*------------------------------------------------------------------------- + * List of NLMs to always load. + *-------------------------------------------------------------------------*/ + +NLMLoadControl_s cddvdNLM = {MSGNot("CDDVD"),0}; +NLMLoadControl_s dosfatNLM = {MSGNot("DOSFAT"),0}; +NLMLoadControl_s zlssNLM = {MSGNot("ZLSS"), 0}; +NLMLoadControl_s gsegNLM = {MSGNot("GSEG"), 0}; +NLMLoadControl_s nwprvNLM = {MSGNot("NWPRV"), 0}; +NLMLoadControl_s nssidkNLM = {MSGNot("NSSIDK"), 0}; + + +NINT noLSSNLMsCount = NO_LSS_COUNT; +NINT maxLSSNLMsCount = MAX_LSS_COUNT; +BOOL NoLssSwitch = FALSE; +BOOL AllLssSwitch = FALSE; +BOOL AllAllLssSwitch = FALSE; + + +NLMLoadControl_s nolssNssNLMs[] = +{ + {MSGNot("COMN"), NLCFL_required}, + {MSGNot("MANAGE"), NLCFL_required}, + {MSGNot("MAL"), NLCFL_required}, +// {MSGNot("MMPRV"), NLCFL_required}, + {MSGNot("NWSA"), NLCFL_required}, + {NULL}, /* gseg */ + {NULL}, /* zlss */ + {NULL}, /* nwprv */ + {NULL}, /* cd9660 */ + {NULL}, /* cdhfs */ + {NULL}, /* dosfat */ + {NULL}, /* udf */ +/* {NULL}, + {NULL}, + {NULL}, + {NULL}, */ + NULL +}; + +NLMLoadControl_s alllssNssNLMs[] = +{ + {MSGNot("COMN"), NLCFL_required}, + {MSGNot("MANAGE"), NLCFL_required}, + {MSGNot("MAL"), NLCFL_required}, +// {MSGNot("GSEG"), NLCFL_required}, +// {MSGNot("MMPRV"), NLCFL_required}, +// {MSGNot("NWPRV"), 0}, + {MSGNot("ZLSS"), 0}, + {MSGNot("NSSIDK"), NLCFL_required}, + {MSGNot("NWSA"), 0}, + {MSGNot("VOLMN"), 0}, +/* {MSGNot("DOSFAT"), 0}, */ + {MSGNot("CDDVD"), 0}, +/* {MSGNot("UDF"), 0}, */ + NULL +}; + +NLMLoadControl_s allalllssNssNLMs[] = +{ + {MSGNot("COMN"), NLCFL_required}, + {MSGNot("MANAGE"), NLCFL_required}, + {MSGNot("MAL"), NLCFL_required}, +// {MSGNot("GSEG"), NLCFL_required}, +// {MSGNot("MMPRV"), NLCFL_required}, +// {MSGNot("NWPRV"), 0}, + {MSGNot("ZLSS"), NLCFL_required}, + {MSGNot("NWSA"), NLCFL_required}, + {MSGNot("VOLMN"), 0}, + {MSGNot("NSSIDK"), NLCFL_required}, + {MSGNot("DOSFAT"), 0}, + {MSGNot("CDDVD"), 0}, + NULL +}; + +NLMLoadControl_s defaultNssNLMs[] = +{ + {MSGNot("COMN"), NLCFL_required}, + {MSGNot("MANAGE"), NLCFL_required}, + {MSGNot("MAL"), NLCFL_required}, +// {MSGNot("GSEG"), NLCFL_required}, +// {MSGNot("MMPRV"), NLCFL_required}, +/* {MSGNot("NWPRV"), 0}, */ + {MSGNot("ZLSS"), NLCFL_required}, + {MSGNot("NWSA"), NLCFL_required}, + {MSGNot("VOLMN"), 0}, + {MSGNot("NSSIDK"), NLCFL_required}, + {MSGNot("CDDVD"), 0}, +/* {MSGNot("DOSFAT"), 0}, */ + NULL +}; + +NLMLoadControl_s *NssNLMs = defaultNssNLMs; + + +/*static NLMLoadControl_s *lookupNLM (char *name) +{ + NINT i; + + for (i = 0; NssNLMs[i].name != NULL; ++i) + { + if (strcmp(name, NssNLMs[i].name) == 0) + { + return &NssNLMs[i]; + } + } + return NULL; +} +*/ + +STATUS addToTheNLMsList( + NINT options, + NLMLoadControl_s *loadControl) +{ + if ((NoLssSwitch != TRUE) && (AllLssSwitch != TRUE) && + (AllAllLssSwitch != TRUE) && (options & POPT_FIRST_PARSE)) + { + NssNLMs = nolssNssNLMs; + if (noLSSNLMsCount < maxLSSNLMsCount) + { + memcpy( &nolssNssNLMs[noLSSNLMsCount], + loadControl, + sizeof(NLMLoadControl_s)); + } + noLSSNLMsCount++; + } + return zOK; +} + +STATUS doSetDefaultNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + MPKNSS_LOCK(); +// addToTheNLMsList(options, &gsegNLM); + addToTheNLMsList(options, &zlssNLM);; +/* addToTheNLMsList(options, &nwprvNLM); +*/ + MPKNSS_UNLOCK(); + return zOK; +} + +STATUS doSetCDDVDNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + MPKNSS_LOCK(); + addToTheNLMsList(options, &cddvdNLM); + MPKNSS_UNLOCK(); + return zOK; +} + +STATUS doSetDOSFATNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + MPKNSS_LOCK(); + addToTheNLMsList(options, &dosfatNLM); + MPKNSS_UNLOCK(); + return zOK; +} + +STATUS doSetZLSSNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + MPKNSS_LOCK(); +// addToTheNLMsList(options, &gsegNLM); + addToTheNLMsList(options, &zlssNLM); + addToTheNLMsList(options, &nssidkNLM); + MPKNSS_UNLOCK(); + return zOK; +} + +STATUS doSetNWPRVNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + MPKNSS_LOCK(); +// addToTheNLMsList(options, &nwprvNLM); + MPKNSS_UNLOCK(); + return zOK; +} + +STATUS doSetnoLSSNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + MPKNSS_LOCK(); + if (options & POPT_FIRST_PARSE) + { + NoLssSwitch = TRUE; + NssNLMs = nolssNssNLMs; + } + MPKNSS_UNLOCK(); + return zOK; +} + +STATUS doSetallLSSNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + + MPKNSS_LOCK(); + if ((NoLssSwitch != TRUE) && (options & POPT_FIRST_PARSE)) + { + AllLssSwitch = TRUE; + NssNLMs = alllssNssNLMs; + } + MPKNSS_UNLOCK(); + return zOK; +} + +STATUS doSetallallLSSNLMs( + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + MPKNSS_LOCK(); + if ((NoLssSwitch != TRUE) && (options & POPT_FIRST_PARSE)) + { + AllAllLssSwitch = TRUE; + NssNLMs = allalllssNssNLMs; + } + MPKNSS_UNLOCK(); + return zOK; +} + +/************************************************************************** + * This will loop through and load all of the standard NSS NLMs + * or load the selected NSS NLM + ***************************************************************************/ +STATUS NSS_LoadNLMs(char *nlmname, char *newcmds) +{ + SNINT i; + NINT status; + BOOL didHelp; +# define INVALID_ERROR_SIGNATURE 0x790a3b82 +#define NSS_CMD_LINE_LENGTH 1024 + char *cmdLine; /* Removed from stack becuase 1K is LOTS of stack + * space. In pure DEBUG 6Pack system we would + * use too much stack when play purge log in ZLSS. + */ + RegisteredNLMs_s *rnlm; + + ASSERT_MPKNSS_LOCK(); + cmdLine = LB_zalloc( NSS_CMD_LINE_LENGTH ); + if ( cmdLine == NULL ) + { + aprintf(LRED,MSG("NSS could not load NLM because not enough memory",273) ); + return( zFAILURE ); + } + if(nlmname == NULL) + { + /*------------------------------------------------------------------- + * Loop through and LOAD the nlms + *-----------------------------------------------------------------*/ + for (i=0;NssNLMs[i].name != NULL;i++) + { + strcpy(cmdLine,NssNLMs[i].name); + strcat(cmdLine,MSGNot(".nss")); + + aprintf(LGREEN,MSG("Loading %s...\n",86),cmdLine); + LastRegisteredNLMstatus = INVALID_ERROR_SIGNATURE; + ZOS_LoadModule(status, NSS_ErrorScreen,cmdLine,LO_LOAD_SILENT); + + if (status != 0) + { + aprintf(LRED,MSG(" Load of %s failed, status=%d.\n",87), cmdLine,status); + if (NssNLMs[i].flags & NLCFL_required) + goto cleanupUnload; + } + else + { + if (LastRegisteredNLMstatus == INVALID_ERROR_SIGNATURE) + { + aprintf(LRED,MSG("The module \"%s\" did not " + "properly register with NSS.",88),cmdLine); + goto cleanupUnload; + } + } + } + /*------------------------------------------------------------------- + * Before activating, re-parse the command line and make sure we + * account for all of the switches. + *-----------------------------------------------------------------*/ + if ((NSS_ParseSecondStartupCmdline(NSS_CommandLine,&didHelp) != zOK) || didHelp) + { + goto cleanupUnload; + } + /*------------------------------------------------------------------- + * Now activate all of the modules + *-----------------------------------------------------------------*/ + DQ_FOREACH(&RegisteredNLMsList,rnlm,RegisteredNLMs_s,link) + { + aprintf(YELLOW,MSG("Starting Module %s...\n",89),rnlm->moduleName); + status = rnlm->callBacks.startup(); + if (status != zOK) + { +/* NLMLoadControl_s *nssNLM; */ + + aprintf(LRED, + MSG("Start of Module %s failed (status=%d).\n",90), + rnlm->moduleName, status); +/* nssNLM = lookupNLM(rnlm->moduleName); */ +/* if ((nssNLM != NULL) && (nssNLM->flags & NLCFL_required)) */ + if (rnlm->registrationFlags & NSSREGFLAG_REQUIRED) + { + goto cleanupUnload; + } + } + + if (PublicsIsResolved == FALSE) + { + ResolvePublics(); + } + +#ifdef ADMIN_NSS +// if (SYSAvailabilityIsChecked == FALSE) +// { +// CheckAndRegisterSYSVolEvent(); +// } +#endif + + if (PublicsIsResolved) + { + NSS_addMgmtFile(rnlm); + } + } + } + else + { + strcpy(cmdLine,nlmname); + aprintf(LGREEN,MSG("Loading %s...\n",91), cmdLine); + strcat(cmdLine,MSGNot(".nss")); + + if(newcmds != NULL) + { + strcat(cmdLine, MSGNot(" ")); + strcat(cmdLine, newcmds); + } + + LastRegisteredNLMstatus = INVALID_ERROR_SIGNATURE; + ZOS_LoadModule(status,NSS_ErrorScreen, cmdLine, LO_LOAD_SILENT); + + if(status != 0) + { + aprintf(LRED,MSG(" Load of %s failed, status=%d.\n",92), cmdLine,status); + LB_free(cmdLine); + return(zFAILURE); + } + else + { + if (LastRegisteredNLMstatus == INVALID_ERROR_SIGNATURE) + { + aprintf(LRED,MSG("The module \"%s\" did not " + "properly register with NSS.",93),cmdLine); + goto cleanupUnload; + } + } + } + LB_free(cmdLine); + return zOK; + +/*=========================================================================== + * Error handling + *=========================================================================*/ +cleanupUnload: + LB_free(cmdLine); + NSS_UnloadNLMs(NULL); + return zFAILURE; +} + + + +/************************************************************************** + * This will loop through and unload all of the standard NSS NLMs + * or unload the selected NSS NLM + ***************************************************************************/ +STATUS NSS_UnloadNLMs(char *nlmname) +{ + NINT status; + NINT modHandle; + char loadname[32]; + char cmdline[32]; + RegisteredNLMs_s *rnlm; + struct LoadDefinitionStructure *handle; + ASSERT_MPKNSS_LOCK(); + + printf(MSGNot("\n")); + + if(nlmname == NULL) + { + while (DQ_NOT_EMPTY(&RegisteredNLMsList)) + { + DQ_PEEK_END(&RegisteredNLMsList,rnlm,RegisteredNLMs_s,link); + strmcpy(cmdline,rnlm->moduleName,sizeof(cmdline)); + strupr(cmdline); + if(NSS_StartupCompleted) + { + aprintf(LGREEN,MSG("Unloading %s...\n",94),rnlm->moduleName); + } + + if (strstr(cmdline, MSGNot("COMN"))) + { + UnResolvePublics(); +#ifdef ADMIN_NSS +// UnRegisterSYSVolEvent(); +#endif + } + + modHandle = rnlm->moduleHandle; + + ZOS_UnloadModule(status,NSS_ErrorScreen,cmdline); + ZOS_ValidateModuleHandle(handle , modHandle) ; + if ( handle != NULL) + { + if (strstr(cmdline, MSGNot("COMN"))) + { + ResolvePublics(); +#ifdef ADMIN_NSS +// CheckAndRegisterSYSVolEvent(); +#endif + } + + aprintf(LRED, MSG("Unloading %s... has failed, Module is in use.\n",95),rnlm->moduleName); + return zFAILURE; + } + + /*FixFixFix6 Why Neal did this, neither Mike, nor Craig, nor Steve can figure out. */ /* Vandana can guess though. */ + if(status != zOK) + { + zASSERT("We got an error UNLOADING MODULES" == 0); + DQ_RMV(rnlm,link); + free(rnlm); + } + } + } + else + { + /* fix up the base input name */ + strcpy(loadname,nlmname); +/* strupr(loadname); */ + + DQ_FOREACH(&RegisteredNLMsList,rnlm,RegisteredNLMs_s,link) + { + strmcpy(cmdline,rnlm->moduleName,sizeof(cmdline)); + if(stricmp(loadname, cmdline) == zOK) + { + aprintf(LGREEN,MSG("Unloading %s...\n",96), rnlm->moduleName); + strcat(cmdline,MSGNot(".nss")); + strupr(cmdline); + + if (strstr(cmdline, MSGNot("COMN"))) + { + UnResolvePublics(); +#ifdef ADMIN_NSS +// UnRegisterSYSVolEvent(); +#endif + } + + modHandle = rnlm->moduleHandle; + + ZOS_UnloadModule(status,NSS_ErrorScreen, cmdline); + + if (ValidateModuleHandle(modHandle) != NULL) + { + if (strstr(cmdline, MSGNot("COMN"))) + { + ResolvePublics(); +#ifdef ADMIN_NSS +// CheckAndRegisterSYSVolEvent(); +#endif + } + aprintf(LRED, MSG("Unloading %s... has failed, Module is in use.\n",97),rnlm->moduleName); + return zFAILURE; + } + + /*fixfixfixsix Why Neal did this, neither Mike, nor Craig, nor Steve can figure out. */ + if(status != zOK) + { + zASSERT("We got an error UNLOADING MODULES" == 0); + DQ_RMV(rnlm,link); + free(rnlm); + } + return zOK; + } + } + return zFAILURE; + } + return zOK; +} + +/**************************************************************************** + * This will loop through the loaded NSS modules and return find first/next + * for the selected type + ***************************************************************************/ +STATUS findModuleType(NINT moduletype, RegisteredNLMs_s **rnlm) +{ + RegisteredNLMs_s *scanrnlm; + NINT startvalue; + + if(*rnlm == NULL) + startvalue = -1; + else + startvalue = 0; + ASSERT_MPKNSS_LOCK(); + if(DQ_NOT_EMPTY(&RegisteredNLMsList)) + { + DQ_FOREACH(&RegisteredNLMsList,scanrnlm,RegisteredNLMs_s,link) + { + if(moduletype == scanrnlm->moduleType) + { + if(startvalue == -1) + { + *rnlm = scanrnlm; + return(zOK); + } + else + { + if(*rnlm == scanrnlm) + startvalue = -1; + } + } + } + } + *rnlm = NULL; + return(zFAILURE); +} + + +/************************************************************************** + * This is a NetWare event handling routine. This event is called when a + * downServer request was made. This will loop thorugh and call the down + * routine in each of the loaded modules. + ***************************************************************************/ +void NSS_GlobalServerDownHandler(void) +{ + RegisteredNLMs_s *rnlm; + +/*------------------------------------------------------------------------- + * Down the SEMANTIC AGENTS first + *-------------------------------------------------------------------------*/ + MPKNSS_LOCK(); + DQ_FOREACH(&RegisteredNLMsList,rnlm,RegisteredNLMs_s,link) + { + if (rnlm->moduleType == NSSMODULETYPE_SEMANTIC_AGENT) + { + /*aprintf(YELLOW,MSG("Downing Module %s...\n",0),rnlm->moduleName);*/ + if (rnlm->callBacks.downServer) + { + MPKNSS_UNLOCK(); + rnlm->callBacks.downServer(); + MPKNSS_LOCK(); + } + rnlm->registrationState |= NSSREGSTATE_SERVERDOWNED; + } + } +/*------------------------------------------------------------------------- + * Now down the SYSTEMO modules (COMN layer) + *-------------------------------------------------------------------------*/ + DQ_FOREACH(&RegisteredNLMsList,rnlm,RegisteredNLMs_s,link) + { + if (rnlm->moduleType == NSSMODULETYPE_COMMON) + { + /*aprintf(YELLOW,MSG("Downing Module %s...\n",0),rnlm->moduleName); */ + if (rnlm->callBacks.downServer) + { + MPKNSS_UNLOCK(); + rnlm->callBacks.downServer(); + MPKNSS_LOCK(); + } + rnlm->registrationState |= NSSREGSTATE_SERVERDOWNED; + } + } +/*------------------------------------------------------------------------- + * Now down all other modules + *-------------------------------------------------------------------------*/ + DQ_FOREACH(&RegisteredNLMsList,rnlm,RegisteredNLMs_s,link) + { + if (!(rnlm->registrationState & NSSREGSTATE_SERVERDOWNED)) + { + /*aprintf(YELLOW,MSG("Downing Module %s...\n",0),rnlm->moduleName);*/ + if (rnlm->callBacks.downServer) + { + MPKNSS_UNLOCK(); + rnlm->callBacks.downServer(); + MPKNSS_LOCK(); + } + rnlm->registrationState |= NSSREGSTATE_SERVERDOWNED; + } + } + NSSLOG_Shutdown(); + MPKNSS_UNLOCK(); +} + +#endif // #ifndef __linux__ // NSS_Startup + diff --git a/src/nwnss/nss/nssLog.c b/src/nwnss/nss/nssLog.c new file mode 100644 index 0000000..05c3633 --- /dev/null +++ b/src/nwnss/nss/nssLog.c @@ -0,0 +1,389 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: gpachner $ + | $Date: 2005-05-11 04:36:52 +0530 (Wed, 11 May 2005) $ + | + | $RCSfile$ + | $Revision: 974 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Log NSS messages to the c:NSS.LOG log file. This LOG is intended + | to contain items that do not occur too frequently. Do not use if you + | will be generating more than 30 messages an hour. Create your own log + | instead of filling the C:NSS.LOG! + | The log is intended to be used by Novell to help track down + | NSS issues. The messages should NOT be languaged enabled. + | The contents will be viewed by customers + | + +-------------------------------------------------------------------------*/ +#if zLINUX +#include +#endif +#include +#include +#include +#include + +#include "nssStartup.h" +#include "nssOSAPIs.h" +#include "nssLog.h" + + +/* + * Limit of NSS.LOG file before it starts to wrap. + * + */ +#define NSS_LOG_FILE_LIMIT (1*1024*1024) /* Bytes to limit LOG file.*/ + + /* File handle that syslog has assigned to "C:NSS.LOG" */ +int NSSLOG_FileNumber = -1; + +#if 0 /* This is now in format.c */ + /* Not languaged enabled because C:NSS.LOG is meant to + * be used by support and engineering to debug problems. + */ +char *NSSLOG_TypeNames[] = { + "Unknown", /* NSSLOG_TYPE_UNKNOWN */ + "NSS", /* NSSLOG_TYPE_NSS */ + "ZLSS", /* NSSLOG_TYPE_ZLSS */ + "Error", /* NSSLOG_TYPE_ERRPRINTF */ + "MSAP", /* NSSLOG_TYPE_MSAP */ + "Upgrade", /* NSSLOG_TYPE_MEDIA_UPGRADE */ + "Ownership" /* NSSLOG_TYPE_OWNERSHIP */ +}; +#endif + + +#if zNETWARE +/* + * NSSLOG_Startup() - + * Init the NSSLOG system (i.e. open the C:NSS.LOG file). + */ +void NSSLOG_Startup( ) +{ + int rc; + int maxFileSize = NSS_LOG_FILE_LIMIT; + + MPKNSS_UNLOCK(); + rc = open_logfile( NSS_ModuleHandle, NSSLOG_FILENAME ); /* In boot directory */ + MPKNSS_LOCK(); + if ( rc < 0 ) + { /* ALl logged messages will now be 'aprintf' to the screen!!! */ + aprintf( LRED, "open_logfile returned error %d\n", rc ); + } + else + { + NSSLOG_FileNumber = rc; + (void)NSSLOG_EventLog( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Log started" ); + MPKNSS_UNLOCK(); + rc = logger_set_property( NSSLOG_FileNumber, LOGFILE_LIMIT_BY_FILESIZE, (void *)maxFileSize ); + MPKNSS_LOCK(); + if ( rc != LOGFILE_SUCCESSFUL ) + { + aprintf( LRED, "logger_set_property(LOGFILE_LIMIT_BY_FILESIZE) returned error %d\n", rc ); + } + MPKNSS_UNLOCK(); + rc = logger_set_property( NSSLOG_FileNumber, LOGFILE_ROLLOVER_RENAME, NULL ); + MPKNSS_LOCK(); + if ( rc != LOGFILE_SUCCESSFUL ) + { + aprintf( LRED, "logger_set_property(LOGFILE_ROLLOVER_RENAME) returned error %d\n", rc ); + } + } + +#if NSS_DEBUG IS_ENABLED +/* NSSLOG_UnitTest();*/ +#endif + + +} /* End of NSSLOG_Startup() */ + + +/* + * NSSLOG_Shutdown() - + * Free up NSSLOG resources (i.e. close the C:NSS.LOG file). + * + * Notes - + * This routine is called when nss is unloaded (NEVER). It + * is also called when the server is 'downed'. + */ +void NSSLOG_Shutdown( ) +{ + int rc; + int temp; + + if ( NSSLOG_FileNumber != -1 ) + { +//zASSERT("NSSLOG_Shutdown"==NULL); + (void)NSSLOG_EventLog( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Log stopped" ); + temp = NSSLOG_FileNumber; + NSSLOG_FileNumber = -1; + MPKNSS_UNLOCK(); + rc = close_logfile( temp ); + MPKNSS_LOCK(); + if ( rc != LOGFILE_SUCCESSFUL ) + { + printf("close_logfile returned error %d\n", rc ); + } + } + +} /* End of NSSLOG_Shutdown() */ + + +/* + * NSSLOG_EventLog() - + * Log a message to C:NSS.LOG using syslog.nlm. Your message MUST + * be less than LB_VSN_PRINTF_LIMIT (including the NULL). + * + * Notes - + * The log is intended to be used by Novell to help track down + * NSS issues. Messages should not be languaged enabled. + * If you attempt to log more that 240 characters then your message + * will be truncated. + * + */ +STATUS NSSLOG_EventLog( + struct LoadDefinitionStructure *moduleHandle, + const char *where, + NINT logLevel, + NINT typeNumber, /* Type; see NSSLOG_TYPE_... defines */ + char *message ) /* strlen message + strlen type must be less than 384 characters */ + +{ + STATUS status; + + zASSERT( where != NULL ); + zASSERT( message != NULL ); + + status = NSSLOG_printf( moduleHandle, where, logLevel, typeNumber, "%s", message ); + return( status ); + +} /* End of NSSLOG_EventLog() */ + + +/* + * NSSLOG_vprintf() - + * Log a formated message to C:NSS.LOG using syslog.nlm. The message + * generated by 'format' and 'args' MUST be less than LB_VSN_PRINTF_LIMIT + * (including the NULL). + * + * Notes - + * The log is intended to be used by Novell to help track down + * NSS issues. Messages should not be languaged enabled. + * + */ +STATUS NSSLOG_vprintf( + struct LoadDefinitionStructure *moduleHandle, + const char *where, + NINT logLevel, + NINT typeNumber, /* Type; see NSSLOG_TYPE_... defines */ + const char *format, + va_list args ) +{ + STATUS status; + char *type; + + zASSERT( where != NULL ); + + if ( typeNumber >= NSSLOG_NUM_TYPENAMES ) + { /* If typeNumber too big then set to unknown */ + typeNumber = NSSLOG_TYPE_UNKNOWN; + } + type = NSSLOG_TypeNames[typeNumber]; + + if ( NSSLOG_FileNumber != -1 ) + { + int rc; + int addedOrError1; + int addedOrError2; + char message[241]; /* 240 characters and then a NULL */ + char log_information[261]; /* 260 characters and then a NULL */ + + addedOrError1 = LB_vsnprintf( message, sizeof(message), format, args ); + if ( (addedOrError1 >= 0) ) + { /* LB_snprintf succeeded */ + + addedOrError2 = LB_snprintf( log_information, sizeof( log_information ), + MSGNot("[%s] %s\n %s"), type, where, message ); + if ( (addedOrError2 >= 0) ) + { /* LB_snprintf succeeded */ + MPKNSS_UNLOCK(); +#if NSS_DEBUG IS_ENABLED +#ifdef USER_GPACHNER + DBG_DebugPrintf( LRED, MSGNot("NSSLOG ==> %s\n"), log_information ); +#endif +#endif + rc = logger( NSSLOG_FileNumber, moduleHandle, logLevel, log_information ); + MPKNSS_LOCK(); + if ( rc == LOGFILE_SUCCESSFUL ) + { /**** Success exits here!!! ****/ + /**** Success exits here!!! ****/ + /**** Success exits here!!! ****/ + if ( (addedOrError1 >= sizeof(message)) || + (addedOrError2 >= sizeof(log_information)) ) + { /* If message was truncated because it was too big + * return an error to the caller. + */ + return( zERR_LOG_MESSAGE_TOO_BIG ); + } + return( zOK ); + /**** Success exits here!!! ****/ + /**** Success exits here!!! ****/ + /**** Success exits here!!! ****/ + } + status = zERR_LOG_WRITE_ERROR; + } + else + { /* Encoding error */ + status = zERR_LOG_MESSAGE_ENCODING_ERROR; + } + } + else + { /* Encoding error (rc < 0) else buffer not big enough */ + status = zERR_LOG_MESSAGE_ENCODING_ERROR; + } + } + else + { + status = zERR_LOG_NOT_OPEN; + } +#ifdef USER_GPACHNER + zASSERT("Some sort of log error"==NULL); +#endif + /* FixFixFix(Upgrade) - Do we need to do an ALERT every so often to say not logging? + * As of March 2003 we don't get errors because syslog queues item and then + * get errors in the daemon that does the writes. + */ + /* FixFixFix(Upgrade) - Shoud we display on console screen? */ + /* Maybe we should have a NSS screen that gets these messages? */ +// aprintf( YELLOW, MSGNot("NSSLOG(%d) [%s]\n"), status, type ); +// vprintf( format, args ); +// aprintf( YELLOW, MSGNot("\n") ); + return( status ); + +} /* End of NSSLOG_vprintf() */ + + +/* + * NSSLOG_printf() - + * Log a formated message to C:NSS.LOG using syslog.nlm. The message + * generated by 'format' and '...' MUST be less than LB_VSN_PRINTF_LIMIT + * (including the NULL). + * + * Notes - + * The log is intended to be used by Novell to help track down + * NSS issues. Messages should not be languaged enabled. + * + */ +STATUS NSSLOG_printf( + struct LoadDefinitionStructure *moduleHandle, + const char *where, + NINT logLevel, + NINT typeNumber, /* Type; see NSSLOG_TYPE_... defines */ + const char *format, + ...) +{ + STATUS status; + va_list args; + + va_start( args, format ); + status = NSSLOG_vprintf( moduleHandle, where, logLevel, typeNumber, format, args ); + va_end( args ); + return( status ); + +} /* End of NSSLOG_printf() */ + + + + +#if NSS_DEBUG IS_ENABLED +void NSSLOG_UnitTest() +{ + STATUS status; + + (void)NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Unit Test started" ); + + status = NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "A value \"%d\" A string \"%s\".", 5, "Test started" ); + (void)NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Status was %d", status ); + zASSERT( status == zOK ); + + status = NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "A value \"%d\" A UNICODE string \"%U\" A unsigned QUAD value \"%Lx\" A signed QUAD value \"%Lx\".", 5, L"Test started", 0x1234567890ui64, -1i64 ); + (void)NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Status was %d", status ); + zASSERT( status == zOK ); + + + status = NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "%s %s %s", "Test started", "Test started", "Test started"); + (void)NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Status was %d", status ); + zASSERT( status == zOK ); + + status = NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "%s%s%s", "0123456789", "0123456789", "0123456789" ); + (void)NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Status was %d", status ); + zASSERT( status == zOK ); + + status = NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "%s%s%s%s%s%s", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789" ); + (void)NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Status was %d", status ); + zASSERT( status == zOK ); + + status = NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "%s%s%s%s%s%s%s%s%s%s%s%s", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789" ); + (void)NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Status was %d", status ); + zASSERT( status == zOK ); + + status = NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", "239 6789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "012345678" ); + (void)NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Status was %d", status ); + zASSERT( status == zOK ); + + status = NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", "240 6789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789" ); + (void)NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Status was %d", status ); + zASSERT( status == zOK ); + + status = NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", "241 6789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "01234567890" ); + (void)NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Status was %d", status ); + zASSERT( status == zERR_LOG_MESSAGE_TOO_BIG ); + + status = NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", "242 6789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "0123456789", "012345678901" ); + (void)NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Status was %d", status ); + zASSERT( status == zERR_LOG_MESSAGE_TOO_BIG ); + + (void)NSSLOG_printf( NSS_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_NSS, "Unit Test Finished" ); + + + errPrintf(WHERE, Module, -1, + MSGNot("Unable to initialize screen \"%s\".\n" + "A non-NSS error has occurred. Contact your Novell Technical Support Provider." + ), "test error"); + errPrintf(WHERE, Module, 255, MSGNot("Unable to upport Provider.") ); +} +#endif + +#endif //#if zNETWARE + + +#if zLINUX +// This code is now in the library under wio/lnxLog.c +#endif + diff --git a/src/nwnss/nss/nssModules.mk b/src/nwnss/nss/nssModules.mk new file mode 100644 index 0000000..b379115 --- /dev/null +++ b/src/nwnss/nss/nssModules.mk @@ -0,0 +1,314 @@ +############################################################################## +# +# (C) Copyright 2003 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +########################################################################## +# This defines what MODULES are being built for this NLM +# +# $Author: ghorlacher $ +# $Date: 2007-09-13 03:51:53 +0530 (Thu, 13 Sep 2007) $ +# +# $RCSfile$ +# $Revision: 2206 $ +# +########################################################################## +MODULE_VERSION=15 + +#------------------------------------------------------------------------- +# If the version number is not defined here, the general product version +# number will be used (defined in bldVersion.bld) +# +# major version 1 to 99 +# minor version 1 to 99 +# sub version 1 to 26 +#------------------------------------------------------------------------- +#MAJOR_VERSION= +#MINOR_VERSION= +#SUB_VERSION= + +#------------------------------------------------------------------------- +# Build OPTIONS +#------------------------------------------------------------------------- +BUILD_WITH_KERNEL_FLAGS=1 + +#set to 0 if you are NOT using source code control +IS_USING_SOURCE_CONTROL=1 + +#Set to ONE if you want the linked files to be copied to the SDK/BIN directory. +COPY_TO_SDK_BIN=1 + + #set to ONE if you only want to copy the OPTIMIZED version to SDK/BIN. + COPY_OPTIMIZED_ONLY=0 + +#Set this to ONE if you are building a NETWARE version independent NLM +#(not NETWARE version specific) +NETWARE_VERSION_INDEPENDENT=0 + + #if ONE include the NETWARE .H files in the compiler search paths. + USE_NETWARE_INCLUDES=1 + +#If ONE IMPORT the LIBNSS APIs and include in the search path SDK/LIBRARY +#and SDK/PUBLIC +IMPORT_INDEPENDENT_LIBNSS=1 + +#If ONE include in the search path SDK/LIBRARY and SDK/PUBLIC +USE_LIBNSS_INCLUDES=1 + +#If ONE then LINK with the NSS library and include all of the NSS library +#directories in the compiler search paths. This includes the SDK/PUBLIC, +#SDK/INCLUDE, SDK/INTERNAL, LIBRARY/SRC directories. +LINK_WITH_NSSLIB=0 + +#if ONE then IMPORT the NSS library and COMN layer APIS and include the +#SDK/PUBLIC directory in the compiler search paths. +IMPORT_NSSLIB=1 + + #If ONE and (LINK_WITH_NSSLIB==1 or IMPORT_NSSLIB==1) then do the same + #operation to the NSSLIB area you are doing to the local area. + CHECK_NSSLIB=0 + + #If ONE and (CHECK_NSSLIB==1) then we will clean the NSSLIB area when we + #clean the local area. + CLEAN_NSSLIB=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INCLUDE directory in + #the compiler search paths + USE_NSS_SDK_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/COMNSA directory in + #the compiler search paths + USE_NSS_SDK_COMNSA_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INTERNAL directory in + #the compiler search paths + USE_NSS_SDK_INTERNAL_INCLUDES=1 + +#if ONE then do NOT import the NSS COMMON layer APIs +DONT_IMPORT_COMMON_LAYER=1 + +#if ONE, compile and link with the NETWARE sdk environment. +USE_NETWARE_SDK=1 + +#if ONE, include DS headers. +USE_NDS_INCLUDES=1 + +#if ONE, do LANGUAGE ENABLING processing +DO_LANGUAGE_ENABLING=1 + +#Set to null (i.e. no value) to not add XDC data to the NLM. For most +#NetWare 5.0 NLMs, the value should be -u. +MOAB_XDC_TOOL_OPTION=-n + +#************************************************************************* +# List of source directories for NSS +#************************************************************************* +SOURCE_DIRECTORIES=\ + cache \ + msg \ + lib \ + setcmd + +#************************************************************************* +# Source Modules for NSS (.C .386) +#************************************************************************* +CACHE_SRC=\ + cache/asyncio.c \ + cache/bond.c \ + cache/cache.c \ + cache/control.c \ + cache/work.c + +CONNECT_SRC= + +MSG_SRC=\ + msg/msg.c \ + msg/switchboard.c \ + msg/slab.c + +LIB_SRC=\ + lib/setErrno.c \ + lib/bitmap.c \ + lib/hash.c \ + lib/crc.c + +SETCMD_SRC=\ + setcmd/setcmd.c + +SOURCE_FILES=\ + nssLKM.c \ + nssStartup.c \ + nssLoadNLMs.c \ + nssLog.c \ + nssCmdline.c \ + nssVersion.c \ + nssRegistration.c \ + dbgView.c \ + $(CACHE_SRC) \ + $(CONNECT_SRC) \ + $(LIB_SRC) \ + $(MSG_SRC) \ + $(SETCMD_SRC) \ + nssNSSSym.c +ifeq (${UNOPT_ENV},1) + SOURCE_FILES += unssNSSSym.c +endif + +SOURCE_FILES_NODEBUG= + +#************************************************************************* +# Source Include files for NSS (.H .inc) +#************************************************************************* +INCLUDE_FILES=\ + nssStartup.h \ + setcmd.h + +#************************************************************************* +# Additional source files that need to be checked out +#************************************************************************* +OTHER_FILES=\ + Module.supported + +#------------------------------------------------------------------------- +# This defines what routines are being EXPORTED. You should put .IMP +# files in the "UTILITY_EXPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_EXPORTS= + +UTILITY_EXPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# This defines what routines are being IMPORTED. You should put .IMP +# files in the "UTILITY_IMPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_IMPORTS= + +UTILITY_IMPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# Library definitions +# This defines additional libraries to LINK with and additional +# directories to put on out INCLUDE path. +#------------------------------------------------------------------------- +#additional libraries to link with +EXTRA_LIBRARIES= +EXTRA_STATIC_LIBRARIES= +EXTRA_DYNAMIC_LIBRARIES= +#additional include directories +EXTRA_LIBRARY_INCLPATH= + +#------------------------------------------------------------------------- +# Include path +# This defines additional include path to compile with +#------------------------------------------------------------------------- +#additional include path +EXTRA_INCLUDE_PATH= + + +#------------------------------------------------------------------------- +# Additional C and ASSEMBLY options to use +#------------------------------------------------------------------------- +EXTRA_C_OPTIONS= +EXTRA_ASM_OPTIONS= +EXTRA_LINK_OPTIONS= + +#------------------------------------------------------------------------- +# Additional module attributes +#------------------------------------------------------------------------- +MODULE_DESCRIPTION='NSS (Novell Storage Services)' +MODULE_ADDITIONAL_COPYRIGHT= Patents 5,787,439; 5,903,720; 5,915,253; 6,466,944 Other Patents Pending. +#MODULE_OPTIONS=OPTION reentrant +MODULE_OPTIONS= +MODULE_DEPENDENCIES=nsswin.nlm neb.nlm libnss.nlm syslog.nlm +MODULE_TYPE= +MODULE_EXTENSION= +MODULE_START_ROUTINE= +MODULE_EXIT_ROUTINE= +#set to 1 if you want the optimized NLM to be packed +MODULE_PACK_NLM=1 + +#========================================================================= +#========================================================================= +# LOCAL BUILD RULES +#========================================================================= +#========================================================================= + +#------------------------------------------------------------------------- +# Default BUILD rule +#------------------------------------------------------------------------- +DEFAULT: DEFAULT_BUILD + +#------------------------------------------------------------------------- +# Additional rules +#------------------------------------------------------------------------- + +#BUILD_GREENRIVER_OPT: +# @echo "...This NLM does not have an OPTIMIZED GREENRIVER specific version" + +#BUILD_GREENRIVER_UNOPT: +# @echo "...This NLM does not have an UNOPTIMIZED GREENRIVER specific version" + +BUILD_MOAB_MP_UNOPT: \ + COMPILE_UNOPT_MP_MOAB \ + LINK_UNOPT_MP_MOAB + +BUILD_MOAB_MP_OPT: \ + COMPILE_OPT_MP_MOAB \ + LINK_OPT_MP_MOAB + +BUILD_MOAB_SP_UNOPT: + @echo "...This NLM does not have an UNOPTIMIZED SP specific version" + +BUILD_MOAB_SP_OPT: + @echo "...This NLM does not have an OPTIMIZED SP specific version" + + +#BUILD_MOAB_SP_UNOPT: \ +# COMPILE_UNOPT_SP_MOAB \ +# LINK_UNOPT_SP_MOAB +# +#BUILD_MOAB_SP_OPT: \ +# COMPILE_OPT_SP_MOAB \ +# LINK_OPT_SP_MOAB + + +#------------------------------------------------------------------------- +# Language Enabling rules +#------------------------------------------------------------------------- +mdb: \ + DEFAULT_MDB + +umdb: \ + LOCAL_MDB + +mdbCreate: \ + DEFAULT_CREATE_MDB_FILE + +#------------------------------------------------------------------------- +# Other rules +#------------------------------------------------------------------------- +deps: DEFAULT_DEPS + +cscope: DEFAULT_CSCOPE + diff --git a/src/nwnss/nss/nssNLM.c b/src/nwnss/nss/nssNLM.c new file mode 100644 index 0000000..907b4cc --- /dev/null +++ b/src/nwnss/nss/nssNLM.c @@ -0,0 +1,412 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 - 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) Initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: !!!NetWare specific file!!! + | Preforms all program (LKM) initialization. See also nssLinux.c for + | Linux version. + | + | + +-------------------------------------------------------------------------*/ +#include /* netware */ +#include +#include + +#include /* NSS Library */ +/*#include */ +#include +#include +#include + + +#include "nssStartup.h" + +/*------------------------------------------------------------------------- + * Global variables + *-------------------------------------------------------------------------*/ +char **NSSMessageTable; + +static LONG NSS_ModuleIsLoaded = 0; +# define LOADED_MAGIC 0x54494E49 + +struct LoadDefinitionStructure *NSS_ModuleHandle; +struct ScreenStruct *NSS_DefaultScreen; /* This will be set up to the MAIN + * console screen. If a NON console + * thread attempts to write it will + * go to the LOGGER screen. + */ +struct ScreenStruct *NSS_ErrorScreen; /* This is the Screen that we get + * during Generic start. Jim Nicolet + * said this should only be used during + * generic start. + */ +char NSS_CommandLine[512]; + +LONG NSS_InitSystemEventID = 0; + +const char Module[ ] = MODULE_NAME; + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*------------------ START OF PROGRAM -------------------------------------*/ + + +#if NSS_DEBUG IS_ENABLED + +boolfunc_t NSS_QAssertErrorCallback = NULL; +boolfunc_t NSS_DQAuditCallback = NULL; + +BOOL NSS_QAssertError (char *msg, Link_t item) +{ + static char assertmsg[] = MSGNot("\tNSS QASSERT ERROR: %s item=0x%x next=0x%x\n"); + + BOOL iOwnSpinlock = MPKNSS_I_OWN_SPINLOCK(); + + if (!iOwnSpinlock) + { + MPKNSS_LOCK(); + } + + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID,LRED,assertmsg,msg,item,item->next); + OutputToScreenWithAttribute(COMN_Resource.debuggerScreenID,LRED,assertmsg,msg,item,item->next); + + ZOS_EnterDebugger(); + + if (!iOwnSpinlock) + { + MPKNSS_UNLOCK(); + } + return TRUE; +} + +BOOL NSS_QAuditError (DQhead_t *head, DQlink_t *member, int count) +{ + static char qAuditMsg[] = + MSGNot("\tNSS DQ AUDIT ERROR: head=0x%x member=0x%x cnt=%d\n"); + + BOOL iOwnSpinlock = MPKNSS_I_OWN_SPINLOCK(); + + if (!iOwnSpinlock) + { + MPKNSS_LOCK(); + } + + OutputToScreenWithAttribute(COMN_Resource.consoleScreenID, LRED, + qAuditMsg, head, member, count); + OutputToScreenWithAttribute(COMN_Resource.debuggerScreenID,LRED, + qAuditMsg, head, member, count); + + ZOS_EnterDebugger(); + + if (!iOwnSpinlock) + { + MPKNSS_UNLOCK(); + } + return TRUE; +} + +#endif + + +void ParseLoaderCommandLine ( + BYTE *loaderCmdLine, + BYTE *nssCmdLine, + NINT startPositionNssCmdLine) +{ + NINT maxLen = sizeof(NSS_CommandLine); + NINT loaderCmdLineLen = *loaderCmdLine; + + loaderCmdLine++; /* It is length preceded and ?NULL terminated? */ + + while ((loaderCmdLineLen != 0) && (*loaderCmdLine != 0)) + { + if ((*loaderCmdLine == '-') || (*loaderCmdLine == '/')) + { + loaderCmdLine++; + if (--loaderCmdLineLen == 0) + return; + switch (*loaderCmdLine++) + { + case 'z': + case 'Z': + { + if (--loaderCmdLineLen == 0) + return; + goto copyLoaderCmdLineToNSSCmdLine; + break; + } + default: + { + loaderCmdLineLen--; + break; + } + } + } + else + { + loaderCmdLine++; + loaderCmdLineLen--; + } + } + return; + +copyLoaderCmdLineToNSSCmdLine: + nssCmdLine += startPositionNssCmdLine; + maxLen -= startPositionNssCmdLine; + if (maxLen == 1) + { + goto nullTerminateAndReturn;; + } + *nssCmdLine++ = ' '; /* Add a space before appending the other cmd line */ + if (--maxLen == 1) + { + goto nullTerminateAndReturn; + } + + if (*loaderCmdLine == '"') + { + loaderCmdLine++; + if (--loaderCmdLineLen == 0) + { + goto nullTerminateAndReturn; + } + + while ((*loaderCmdLine != '"') && (*loaderCmdLine != 0)) + { + *nssCmdLine++ = *loaderCmdLine++; + if ((--maxLen == 1) || (--loaderCmdLineLen == 0)) + { + goto nullTerminateAndReturn; + } + } + } + else + { + while ((*loaderCmdLine != ' ') && (*loaderCmdLine != 0)) + { + *nssCmdLine++ = *loaderCmdLine++; + if ((--maxLen == 1) || (--loaderCmdLineLen == 0)) + { + goto nullTerminateAndReturn; + } + } + } +nullTerminateAndReturn: + *nssCmdLine = 0; + return; +} + +void ParseNSSConfigFile ( + BYTE *nssCmdLine, + NINT startPositionNssCmdLine) +{ + LONG fileHandle; + LONG len; + NINT maxLen = sizeof(NSS_CommandLine); + BYTE dosPath[64]; + LONG driveNumber; + LONG result; + LONG cCode; + + nssCmdLine += startPositionNssCmdLine; + maxLen -= startPositionNssCmdLine; + if (maxLen == 1) + { + goto nullTerminateAndReturn; + } + *nssCmdLine++ = ' '; /* Add a space before appending the other cmd line */ + if (--maxLen == 1) + { + goto nullTerminateAndReturn; + } + + ZOS_INWDOSGetDefaultDrive(driveNumber); + ZOS_INWsprintf((&dosPath[0], MSGNot("%c:\\"), driveNumber + 0x40)); + ZOS_INWDOSGetCurrentDirectory(result,driveNumber, &dosPath[CStrLen(dosPath)]); + if (result != 0) + { + goto nullTerminateAndReturn; + } + ZOS_INWsprintf((&dosPath[CStrLen(dosPath)], MSGNot("\\NSSSTART.CFG"))); + ZOS_LDOSOpen(cCode, &dosPath[0], &fileHandle, 0) + if (cCode == 0) + { + ZOS_LDOSRead(cCode,fileHandle, 0, nssCmdLine, maxLen - 1, &len); + nssCmdLine += len; + ZOS_LDOSClose(fileHandle); + } + +nullTerminateAndReturn: + *nssCmdLine = 0; + return; +} + +/************************************************************************** + * + ***************************************************************************/ +/*- (FUNCTION) ----- GenericStartRoutine() ---------------------------------- + | + | load function for the NLM initialization process + | + +-------------------------------------------------------------------------*/ +LONG GenericStartRoutine( + struct LoadDefinitionStructure *handle, + struct ScreenStruct *errorScreen, + BYTE *commandLine) +{ + LONG numMessages; + LONG languageID; + BYTE *helpFile; + BYTE loaderCmdLine[512]; + NINT loaderCmdLineLen; + LONG result; + + MPKNSS_INIT_LOCK(); + MPKNSS_LOCK(); + +#if NSS_DEBUG IS_ENABLED + + NSS_QAssertErrorCallback = NSS_QAssertError; + NSS_DQAuditCallback = NSS_QAuditError; + +#endif + + +/*------------------------------------------------------------------------- + * Init global variables + *-------------------------------------------------------------------------*/ + + NSS_ModuleHandle = handle; + NSS_ErrorScreen = errorScreen; + ZOS_GetSystemConsoleScreen(NSS_DefaultScreen); + strmcpy(NSS_CommandLine,commandLine,sizeof(NSS_CommandLine)); + + /* This gets the command line from whats typed with server.exe when + * the server is first brought up + */ + ZOS_GetLoaderCommandLine(loaderCmdLineLen,loaderCmdLine); + + if (loaderCmdLineLen) + { + ParseLoaderCommandLine(loaderCmdLine, + NSS_CommandLine, strlen(NSS_CommandLine)); + } + + /* This reads NSSSTART.CFG from the dos default drive and the dos current + * directory. + */ + ParseNSSConfigFile(NSS_CommandLine, strlen(NSS_CommandLine)); + +/*------------------------------------------------------------------------- + * setup message file + *-------------------------------------------------------------------------*/ + ZOS_ReturnMessageInformation(result,(LONG)handle, &NSSMessageTable, + &numMessages, &languageID, &helpFile); + if ( result != zOK) + { + ERROR_LOADING_MSG_TABLES(errorScreen); + MPKNSS_UNLOCK(); + return zFAILURE; + } + + /*- ck if module is already loaded, yet return now -*/ + if(NSS_ModuleIsLoaded == LOADED_MAGIC) + { + MPKNSS_UNLOCK(); + return zOK; + } + + /* mark module loaded */ + NSS_ModuleIsLoaded = LOADED_MAGIC; + + { + /* sksmith - this version and copyright string are for the MSG file*/ + char *ver = MSG("VeRsIoN=3.00 Novell Storage Services (NSS) Startup Module",271); + char *copyR = MSG("CoPyRiGhT=(c) 1995-2001 Novell, Inc. All rights reserved.",272); + if (ver && copyR) + { + } + } +/*------------------------------------------------------------------------- + * Allocate all of the Resource Tags now. + *-------------------------------------------------------------------------*/ + if (COMN_RegisterLibraryResourceTags(MSGNot("NSS"),handle,errorScreen) != zOK) + { + MPKNSS_UNLOCK(); + return zFAILURE; + } +/*------------------------------------------------------------------------- + * This will register for the MODULE_LOAD event which will be called + * immediatly after we return from this startup routine. We do this + * because in the event routine we can load other NLMs (which we can not + * do from the startup routine) but we are still in the startup path. + *-------------------------------------------------------------------------*/ + ZOS_EventNotificationReg(NSS_InitSystemEventID, + EVENT_MODULE_LOAD, NULL, + NSSGlobal_Startup); + zASSERT(NSS_InitSystemEventID != 0); + MPKNSS_UNLOCK(); + return zOK; +} + +/************************************************************************** + * This routine is called to UNLOAD the nlm + ***************************************************************************/ +LONG GenericExitRoutine(void) +{ + Enable(); /* Because it comes in masked*/ + LB_MEMORY_DISPLAY_SHUTDOWN(); + MPKNSS_LOCK(); + + if (NSS_ModuleIsLoaded == LOADED_MAGIC) + { + WORD row,col; + + ZOS_GetOutputCursorPosition(NSS_ErrorScreen,&row,&col); + ZOS_PositionOutputCursor(NSS_ErrorScreen,row,col); + NSSGlobal_Shutdown(); + } + + COMN_UnregisterLibraryOwner(); + + +#if NSS_DEBUG IS_ENABLED + + NSS_QAssertErrorCallback = NULL; + NSS_DQAuditCallback = NULL; + +#endif + MPKNSS_UNLOCK(); + return zOK; +} + diff --git a/src/nwnss/nss/nssNSSSym.c b/src/nwnss/nss/nssNSSSym.c new file mode 100644 index 0000000..c122051 --- /dev/null +++ b/src/nwnss/nss/nssNSSSym.c @@ -0,0 +1,225 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: gpachner $ + | $Date: 2007-07-11 05:18:49 +0530 (Wed, 11 Jul 2007) $ + | + | $RCSfile$ + | $Revision: 2084 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export NSS symbols to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +EXPORT_SYMBOL(AVFileMgmtDir); +EXPORT_SYMBOL(AVFileMgmtDirLen); +EXPORT_SYMBOL(AVFileOSMgmtDir); +EXPORT_SYMBOL(AVFileOSMgmtDirLen); +EXPORT_SYMBOL(AdminVolAsciiName); +EXPORT_SYMBOL(AdminVolNameLen); +EXPORT_SYMBOL(AdminVolUnicodeName); +//WRONG PLACE//EXPORT_SYMBOL(BEASTHASH_InvalidateDOSTimesPtr); +EXPORT_SYMBOL(Cache); +EXPORT_SYMBOL(CACHE_Shutdown); +EXPORT_SYMBOL(CACHE_SparseBuffer); +EXPORT_SYMBOL(CACHE_Startup); +EXPORT_SYMBOL(CONTROL_get); +EXPORT_SYMBOL(CONTROL_getNoAllocNoWait); +EXPORT_SYMBOL(CONTROL_Shutdown); +EXPORT_SYMBOL(CONTROL_Startup); +EXPORT_SYMBOL(crc); +EXPORT_SYMBOL(hashLowerString); +EXPORT_SYMBOL(hashLowerUnicode); +EXPORT_SYMBOL(hashString); +EXPORT_SYMBOL(hashUnicode); +//WRONG PLACE//EXPORT_SYMBOL(IgnoreTimeZone); +EXPORT_SYMBOL(LB_bind); +EXPORT_SYMBOL(LB_continueFlush); +EXPORT_SYMBOL(LB_defaultFlush); +EXPORT_SYMBOL(LB_defaultFlushWait); +EXPORT_SYMBOL(LB_defaultSignal); +EXPORT_SYMBOL(LB_freeAsyncio); +EXPORT_SYMBOL(LB_freeAsyncioRA); +EXPORT_SYMBOL(LB_getAsyncio); +EXPORT_SYMBOL(LB_getAsyncioNoWait); +EXPORT_SYMBOL(LB_getAsyncioNoWaitRA); +EXPORT_SYMBOL(LB_lazyFlush); +EXPORT_SYMBOL(lowerStringCRC); +EXPORT_SYMBOL(MSG_BreakDoor); +EXPORT_SYMBOL(MSG_BreakSetOfDoors); +EXPORT_SYMBOL(MSG_Call); +EXPORT_SYMBOL(MSG_Send); +EXPORT_SYMBOL(MSG_SendKey); +EXPORT_SYMBOL(MSG_ChangeOwner); +EXPORT_SYMBOL(MSG_CreateDoor); +EXPORT_SYMBOL(MSG_CreateObject); +EXPORT_SYMBOL(MSG_DestroyKey); +EXPORT_SYMBOL(MSG_DestroySetOfKeys); +EXPORT_SYMBOL(MSG_KillManager); +EXPORT_SYMBOL(MSG_LookupShortKey); +EXPORT_SYMBOL(MSG_RegisterType); +EXPORT_SYMBOL(MSG_ReleaseObject); +EXPORT_SYMBOL(MSG_SetStatus); +EXPORT_SYMBOL(MSG_UnregisterType); +EXPORT_SYMBOL(Manager); +EXPORT_SYMBOL(ManagerType); +EXPORT_SYMBOL(msgFreeDoor); +//EXPORT_SYMBOL(NSS_LoadNLMs); +EXPORT_SYMBOL(NSS_RegisterExternalNLM); +EXPORT_SYMBOL(NSS_ResetTimeCaches); +EXPORT_SYMBOL(NSS_SetIgnoreTimeZone); +EXPORT_SYMBOL(NSS_UnRegisterExternalNLM); +//EXPORT_SYMBOL(NSS_UnloadNLMs); +EXPORT_SYMBOL(NSS_doMenuLoad); +EXPORT_SYMBOL(NullMethod); +EXPORT_SYMBOL(PendingWork); +EXPORT_SYMBOL(PersistAdminVolUnicodeName); +EXPORT_SYMBOL(QueuedThreads); +EXPORT_SYMBOL(QueuedThreadsHigh); +EXPORT_SYMBOL(RNLM_readFunction); +EXPORT_SYMBOL(ReserveResource); +//WRONG PLACE//EXPORT_SYMBOL(ResetTimeCache); +EXPORT_SYMBOL(stringCRC); +EXPORT_SYMBOL(updateCRC); +EXPORT_SYMBOL(updateCRCFromString); +EXPORT_SYMBOL(updateCRCFromLowerString); +EXPORT_SYMBOL(updateCRCFromLowerStringWithLen); +EXPORT_SYMBOL(updateCRCFromLowerUnicode); +EXPORT_SYMBOL(updateCRCFromUnicode); +EXPORT_SYMBOL(WORK_Queue); +EXPORT_SYMBOL(WORK_Schedule); +EXPORT_SYMBOL(WORK_Schedule_HIGH); +EXPORT_SYMBOL(WORK_Schedule_LOW); +EXPORT_SYMBOL(WORK_WaitForPending); +EXPORT_SYMBOL(WorkControl); +EXPORT_SYMBOL(WorkHighWaitingCount); +EXPORT_SYMBOL(WorkInst); +EXPORT_SYMBOL(WorkWaitingCount); +EXPORT_SYMBOL(asyncCacheAllocBuffer); +EXPORT_SYMBOL(asyncCacheAllocBufferForUserData); +EXPORT_SYMBOL(cacheAllocBuffer); +EXPORT_SYMBOL(cacheAllocBufferForUserData); +EXPORT_SYMBOL(cacheAllocBufferForCopy); +//EXPORT_SYMBOL(cacheBalance); +EXPORT_SYMBOL(cacheFind); +EXPORT_SYMBOL(cacheFlushMyCache); +EXPORT_SYMBOL(cacheFlushMyCacheBufs); +EXPORT_SYMBOL(cacheLookup); +EXPORT_SYMBOL(cacheMarkDirty); +//EXPORT_SYMBOL(cacheMoveMyCacheBufList); +EXPORT_SYMBOL(cachePrepareToFlush); +EXPORT_SYMBOL(cacheRelease); +EXPORT_SYMBOL(cacheReleaseToss); +EXPORT_SYMBOL(cacheSignalRelease); +EXPORT_SYMBOL(cacheSignalReleaseToss); +EXPORT_SYMBOL(cacheToss); +EXPORT_SYMBOL(cacheTossAll); +EXPORT_SYMBOL(cacheTossIfThere); +EXPORT_SYMBOL(cacheTruncateMyCache); +EXPORT_SYMBOL(cacheFlushAndTossMyCacheUserData); +EXPORT_SYMBOL(cacheUnpin); +EXPORT_SYMBOL(cacheUnpinned); +EXPORT_SYMBOL(changeCacheBuffers); +EXPORT_SYMBOL(checkMyCache); +EXPORT_SYMBOL(clearBits); +EXPORT_SYMBOL(fastReadCache); +EXPORT_SYMBOL(findBits); +EXPORT_SYMBOL(findDoor); +EXPORT_SYMBOL(hashApply); +EXPORT_SYMBOL(hashDelete); +EXPORT_SYMBOL(hashDestroy); +EXPORT_SYMBOL(hashFind); +EXPORT_SYMBOL(hashGrow); +EXPORT_SYMBOL(hashInit); +EXPORT_SYMBOL(hashInsert); +EXPORT_SYMBOL(hashShrink); +EXPORT_SYMBOL(hashStats); +EXPORT_SYMBOL(initAgent); +EXPORT_SYMBOL(initMyCache); +EXPORT_SYMBOL(isCached); +EXPORT_SYMBOL(newBitMap); +//EXPORT_SYMBOL(NSSLOG_EventLog); +//WRONG PLACE//EXPORT_SYMBOL(NSSLOG_printf); +EXPORT_SYMBOL(objCacheAlloc); +EXPORT_SYMBOL(objCacheCreate); +EXPORT_SYMBOL(objCacheDestroy); +EXPORT_SYMBOL(objCacheFree); +EXPORT_SYMBOL(setBits); +EXPORT_SYMBOL(zANYONE_USERID); +EXPORT_SYMBOL(zMSG_Call); +EXPORT_SYMBOL(mpkMSG_Call); +EXPORT_SYMBOL(zSECURE_CONNECTION_USERID); +EXPORT_SYMBOL(zSUPERVISOR_USERID); +EXPORT_SYMBOL(zTREENAME_ID); +EXPORT_SYMBOL(DBG_CV_Register); +EXPORT_SYMBOL(DBG_CV_Unregister); +EXPORT_SYMBOL(MSG_RegisterXIPC); +EXPORT_SYMBOL(MSG_UnregisterXIPC); +EXPORT_SYMBOL(SWBD_DemandKey); +EXPORT_SYMBOL(SWBD_KillClient); +EXPORT_SYMBOL(SWBD_SupplyAll); +EXPORT_SYMBOL(SWBD_SupplyKey); +EXPORT_SYMBOL(SWBD_SupplyLocal); +EXPORT_SYMBOL(SWBD_SupplyRemote); +EXPORT_SYMBOL(SWBD_NewClient); +EXPORT_SYMBOL(SWBD_DumpSwitchboard); +EXPORT_SYMBOL(allocMsgBuf); +EXPORT_SYMBOL(freeMsgBuf); +EXPORT_SYMBOL(LB_SetErrno); +EXPORT_SYMBOL(LB_ForceSetErrnoWithWhere); +EXPORT_SYMBOL(DoorType); +EXPORT_SYMBOL(NSSPrivateBuffer); +EXPORT_SYMBOL(WorkLowWaitingListHead); diff --git a/src/nwnss/nss/nssRegistration.c b/src/nwnss/nss/nssRegistration.c new file mode 100644 index 0000000..b5860db --- /dev/null +++ b/src/nwnss/nss/nssRegistration.c @@ -0,0 +1,2523 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $ + | + | $RCSfile$ + | $Revision: 1325 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | + +-------------------------------------------------------------------------*/ +#if zLINUX +#include +#endif +#include +#include +#include +#include +#include +#include + +#include /* Library */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nssStartup.h" +#include "nssPubs.h" +#include "comnPublics.h" +#include "virtualIO.h" +#include "xmlTags.h" + +/*------------------------------------------------------------------------- + * Globals for managing Registered NLMs + *-------------------------------------------------------------------------*/ +DQhead_t RegisteredNLMsList = DQ_STATIC_INIT(RegisteredNLMsList); + +volatile STATUS LastRegisteredNLMstatus = zOK; +/*volatile RegisteredNLMs_s *LastRegisteredNLM = NULL; */ + +#define AVFILEDIRATTR (zFA_SUBDIRECTORY | zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT) +#define AVFILEFILEATTR (zFA_DELETE_INHIBIT | zFA_RENAME_INHIBIT | zFA_COPY_INHIBIT) + +#ifdef ADMIN_NSS +///* NSS data type tag, they always appear as pairs. */ +//#define NSSNONE 0 /* every element is preformatted */ +//#define NSSNUMBER 2 /* the tag will be */ +//#define NSSSTRING 4 /* the tag will be */ +//#define NSSPERCENT 6 /* the tag will be */ +// +// +///* XML Form method */ +//#define NONE 0 +//#define PUT 1 +//#define POST 2 +//#define GET 3 +#endif + +typedef struct RegAVFileInst_s +{ + BYTE *tag; + STATUS (*function)( + RegisteredNLMs_s *rnlm, + BYTE *data); +}RegAVFileInst_s; + +/*--------------------------------------------------------------------------* + * zPublic routines * + *--------------------------------------------------------------------------*/ +typedef struct Publics_t +{ + char *name; + statusfunc_t addr; +}Publics_t; + +Publics_t Pubs[] = +{ + {MSGNot("zCreate"),0}, + {MSGNot("zDelete"),0}, + {MSGNot("zRootKey"),0}, + {MSGNot("zClose"),0}, +#ifdef ADMIN_NSS +// {MSGNot("XMLConvert"),0}, +// {MSGNot("XMLUnConvert"),0}, +#endif + {MSGNot("MGMTS_MakeFunctionVirtualFile"),0}, + {MSGNot("VIRT_AddResultData"),0}, + {MSGNot("VIRT_AddResultElement"),0}, + {MSGNot("VIRT_AddResultTag"),0}, + {0} +}; + + +#define REG_ZCREATE 0 +#define REG_ZDELETE 1 +#define REG_ZROOTKEY 2 +#define REG_ZCLOSE 3 +#ifdef ADMIN_NSS +//#define REG_XMLCONVERT 4 +//#define REG_XMLUNCONVERT 5 +#endif +#define REG_MGMT_MAKEFUNCTIONVIRTUALFILE 4 +#define REG_VIRT_ADDRESULTDATA 5 +#define REG_VIRT_ADDRESULTELEMENT 6 +#define REG_VIRT_ADDRESULTTAG 7 + + +BOOL PublicsIsResolved = FALSE; +#ifdef ADMIN_NSS +//BOOL SYSAvailabilityIsChecked = FALSE; +//BOOL SYSIsAvailable = FALSE; +#endif +LONG SYSMountNotifyNSSEventID = 0; /* event for mounting sys volume */ +LONG SYSDisMountNotifyNSSEventID = 0; /* event for dismounting sys volume */ +NINT NSSSetParmStarted = 0; +BOOL SetParmBaseDirStarted = FALSE; +BOOL ModuleBaseDirStarted = FALSE; + +NINT SetParmStroeFileOpenCount = 0; +NINT PublicsInUseCount = 0; + +/**************************************************************************** + * FixFixFix6: This will resolve optional publics symbols to the given public + * After zAPIs is made to load with NSSLIB, this function needs to be changed. + *****************************************************************************/ +void ResolvePublics() +{ + NINT i; + char lbuf[64]; + + ASSERT_MPKNSS_LOCK(); + for (i=0; Pubs[i].name != NULL; i++) + { + strcpy(&lbuf[1],Pubs[i].name); /* copy name because OS wants to write to it*/ + lbuf[0] = strlen(&lbuf[1]); /* make length preceded string*/ + // FixFixFix(Linux) - may need to support some of these imported symbols + ZOS_ImportPublicSymbol(Pubs[i].addr,(LONG)COMN_Resource.moduleHandle, (BYTE *)lbuf); + if (Pubs[i].addr == NULL) + { + aprintf(CYAN,MSGNot("Unable to import Optional NSS symbol %s\n"),Pubs[i].name); + PublicsIsResolved = FALSE; + return; + } + } + PublicsIsResolved = TRUE; + return; +} + + +/**************************************************************************** + * FixFixFix6: This will unresolve optional publics symbols to the given public + * After zAPIs is made to load with NSSLIB, this function needs to be changed. + *****************************************************************************/ +void UnResolvePublics() +{ + NINT i; + char lbuf[64]; + + ASSERT_MPKNSS_LOCK(); + PublicsIsResolved = FALSE; + while (PublicsInUseCount) + { + /* delay 0.5 seconds */ + LB_delay(500); + } + + for (i=0; Pubs[i].name != NULL;i++) + { + strcpy(&lbuf[1],Pubs[i].name); /* copy name because OS wants to write to it*/ + lbuf[0] = strlen(&lbuf[1]); /* make length preceded string*/ + // FixFixFix(Linux) - may need to support some of these imported symbols + ZOS_UnImportPublicSymbol((LONG)COMN_Resource.moduleHandle, (BYTE *)lbuf); + } + return; +} + + +#ifdef ADMIN_NSS +///**************************************************************************** +// * Open file sys:\nss_setparm, if it doesn't exist, create and open it * +// * we use Openfile call since we don't know sys is an NSS volume or * +// * Legacy volume. It is only a temporary resolution before we find * +// * another way to store all the set parms * +// * FixFixFix6: When Admin Volume become persistent, this function needs to * +// * be fixed. * +// ****************************************************************************/ +//STATUS openSetParmStoreFile(LONG *fileHandle) +//{ +// BYTE *fileName = MSGNot("\x1C""sys:\\$$NSS$$.PRV\\NSS_SETPARM"); +// BYTE *dirName = MSGNot("\x10""sys:\\$$NSS$$.PRV"); +// BYTE pathString[zMAX_FULL_NAME]; +// LONG volume, pathBase, pathCount; +// LONG dirNumber; +// void *dirEntry; +// STATUS status; +// LONG result; +// +// ASSERT_MPKNSS_LOCK(); +// if (SYSIsAvailable == FALSE) +// { +// return zFAILURE; +// } +// +// ZOS_ConvertPathString(result,0, 0, fileName, &volume, &pathBase, +// pathString, &pathCount); +// if (result != zOK) +// { +// zASSERT("Failed to convert dir path string" == NULL); +// return zFAILURE; +// } +// +// ZOS_OpenFile(result, 0, zNSS_TASK, volume, pathBase, pathString, pathCount, +// zNSPACE_LONG, +// zFA_HIDDEN|zFA_SYSTEM, +// zRR_READ_ACCESS|zRR_WRITE_ACCESS, +// PrimaryDataStream, fileHandle, +// &dirNumber, &dirEntry); +// if (result != zOK) +// { +//#if NSS_DEBUG IS_ENABLED +//// aprintf(BROWN,MSGNot("Failed to open file sys:\\$$NSS$$.prv\\nss_setparm, will try to create it.\n")); +//#endif +// ZOS_CreateFile(status, 0, zNSS_TASK, volume, pathBase, pathString, pathCount, +// zNSPACE_LONG, +// zFA_HIDDEN|zFA_SYSTEM|zFA_DELETE_INHIBIT|zFA_RENAME_INHIBIT, +// 0, PrimaryDataStream, +// fileHandle, &dirNumber, &dirEntry); +// /* it may not exist, try to create it */ +// if (status != zOK) +// { +// if (status == ERR_INVALID_PATH) +// { +// ZOS_ConvertPathString(result,0, 0, dirName, &volume, &pathBase, +// pathString, &pathCount); +// /* $$NSS$$.PRV doesn't exist, create it now */ +// if (result != zOK) +// { +// zASSERT(MSGNot("Failed to convert dir path string") == NULL); +// return zFAILURE; +// } +// +// ZOS_CreateDirectory(result, 0, volume, pathBase, pathString, pathCount, +// zNSPACE_LONG, 0, &dirNumber, &dirEntry); +// if (result != zOK) +// { +// zASSERT(MSGNot("Failed to create directory $$nss$$.prv") == NULL); +// return zFAILURE; +// } +// +// ZOS_ConvertPathString(result,0, 0, fileName, &volume, &pathBase, +// pathString, &pathCount)/* recreate the file again */ +// if (result != zOK) +// { +// zASSERT(MSGNot("Failed to convert file path string") == NULL); +// return zFAILURE; +// } +// ZOS_CreateFile(status,0, zNSS_TASK, volume, pathBase, pathString, pathCount, +// zNSPACE_LONG, +// zFA_HIDDEN|zFA_SYSTEM|zFA_DELETE_INHIBIT|zFA_RENAME_INHIBIT, +// 0, PrimaryDataStream, +// fileHandle, &dirNumber, &dirEntry); +// +// if (status != zOK) +// { +// return zFAILURE; +// } +// } +// else +// { +// return zFAILURE; +// } +// } +// } +// return zOK; +//} +// +// +///**************************************************************************** +// * FixFixFix6: This calls after sys volume is available. It will start up * +// * all modules cmdline set params in RegisteredNLMsList (we skip to do it * +// * if sys vol is not available. After the admin volume is made to be * +// * persistent, this function needs to be changed * +// ****************************************************************************/ +//void SYSMountNotifyEventFunc(LONG UsedParm) +//{ +// RegisteredNLMs_s *rnlm; +// BYTE moduleName[64]; +// +// MPKNSS_LOCK(); +// SYSIsAvailable = TRUE; +// +// /* NSS is not in RegisteredNLMsList, starts it if it hasn't been started */ +// if (NSSSetParmStarted == 0) +// { +// sprintf(moduleName, MSGNot("NSS")); +// RNLM_StartupSetParam(moduleName, &NSSSetParmStarted, +// NSS_CommandLineSwitches); +// } +// +// if (DQ_NOT_EMPTY(&RegisteredNLMsList)) +// { +// DQ_FOREACH(&RegisteredNLMsList, rnlm, RegisteredNLMs_s, link) +// { +// strcpy(moduleName, rnlm->moduleName); +// RNLM_StartupSetParam(moduleName, +// &rnlm->registrationState, +// rnlm->commandLineSwitches); +// } +// } +// MPKNSS_UNLOCK(); +// +//} +// +// +///**************************************************************************** +// * FixFixFix6: This calls before sys volume is going down. * +// ****************************************************************************/ +//void SYSDisMountNotifyEventFunc(LONG UsedParm) +//{ +//// SYSAvailabilityIsChecked = FALSE; +// SYSIsAvailable = FALSE; +// +// MPKNSS_LOCK(); +// /* check if there's anybody is using set parm stor file */ +// while (SetParmStroeFileOpenCount) +// { +// /* delay 0.5 seconds */ +// LB_delay(500); +// } +// MPKNSS_UNLOCK(); +// +//} +// +// +///**************************************************************************** +// * FixFixFix6: This will check if sys volume is available. After the admin * +// * volume is made to be persistent, this function needs to be changed * +// ****************************************************************************/ +//void CheckAndRegisterSYSVolEvent() +//{ +// BYTE *sysVolName = MSGNot("\x3""SYS"); +// LONG volume; +// LONG result; +// +// ASSERT_MPKNSS_LOCK(); +// if (SYSAvailabilityIsChecked == FALSE) +// { +// ZOS_MapVolumeNameToNumber(result,sysVolName, &volume); +// /* check if sys volume is available */ +// if (result != zOK) +// { +// SYSIsAvailable = FALSE; +// } +// else +// { +// ZOS_GetVolumeMountedFlag(result,volume); +// if (result) +// { +// SYSIsAvailable = TRUE; +// } +// else +// { +// SYSIsAvailable = FALSE; +// } +// } +// +// /* register mount event */ +// SYSMountNotifyNSSEventID = EventNotificationReg(EVENT_VOL_SYS_MOUNT, +// NULL, SYSMountNotifyEventFunc); +// if (SYSMountNotifyNSSEventID == NULL) +// { +// zASSERT(MSGNot("Error registering for event EVENT_VOL_SYS_MOUNT") == NULL); +// } +// +// /* register dismount event */ +// SYSDisMountNotifyNSSEventID = EventNotificationReg(EVENT_VOL_SYS_DISMOUNT, +// NULL, SYSDisMountNotifyEventFunc); +// if (SYSDisMountNotifyNSSEventID == NULL) +// { +// zASSERT(MSGNot("Error registering for event EVENT_VOL_SYS_DISMOUNT") == NULL); +// } +// +// SYSAvailabilityIsChecked = TRUE; +// } +//} +// +// +///**************************************************************************** +// * FixFixFix6: This will check if sys volume is available. After the admin * +// * volume is made to be persistent, this function needs to be changed * +// *****************************************************************************/ +//void UnRegisterSYSVolEvent() +//{ +// ASSERT_MPKNSS_LOCK(); +// if (SYSMountNotifyNSSEventID) +// EventNotificationUnReg(SYSMountNotifyNSSEventID); +// if (SYSDisMountNotifyNSSEventID) +// EventNotificationUnReg(SYSDisMountNotifyNSSEventID); +// +// SYSAvailabilityIsChecked = FALSE; +// +// return; +//} +#endif + +/**************************************************************************** + * Call zCreate + ****************************************************************************/ +STATUS REG_zCreate ( + Key_t key, + NINT taskID, + Xid_t xid, + NINT nameSpace, + void *path, + NINT fileType, + QUAD fileAttributes, + NINT createFlags, + NINT requestedRights, + Key_t *retKey) +{ + STATUS status; + + MPKNSS_UNLOCK(); + status = (*Pubs[REG_ZCREATE].addr)(key, taskID, xid, nameSpace, + path, fileType, fileAttributes, createFlags, requestedRights, + retKey); + MPKNSS_LOCK(); + return status; +} + +/**************************************************************************** + * Call zDelete + ****************************************************************************/ +STATUS REG_zDelete ( + Key_t key, + Xid_t xid, + NINT nameSpace, + void *path, + NINT match, + NINT deleteFlags) +{ + STATUS status; + + MPKNSS_UNLOCK(); + status = (*Pubs[REG_ZDELETE].addr)(key, xid, nameSpace, path, match, + deleteFlags); + MPKNSS_LOCK(); + return status; +} + +/**************************************************************************** + * Call zRootKey + ****************************************************************************/ +STATUS REG_zRootKey ( + NINT connectionID, + Key_t *retRootKey) +{ + STATUS status; + + MPKNSS_UNLOCK(); + status = (*Pubs[REG_ZROOTKEY].addr)(connectionID, retRootKey); + MPKNSS_LOCK(); + return status; +} + +/**************************************************************************** + * Call zClose + ****************************************************************************/ +STATUS REG_zClose ( + Key_t key) +{ + STATUS status; + + MPKNSS_UNLOCK(); + status = (*Pubs[REG_ZCLOSE].addr)(key); + MPKNSS_LOCK(); + return status; +} + +#ifdef ADMIN_NSS +///**************************************************************************** +// * Call correct XML parser +// ****************************************************************************/ +//STATUS REG_xmlConvert( +// BYTE *path, +// BYTE *data, +// NINT type, +// BYTE *desc, +// BYTE *misc, +// NINT method, +// BYTE *action, +// BYTE *done, +// BYTE *prompt, +// BYTE *buffer, +// NINT bufferLength) +//{ +// STATUS status = zFAILURE; +// +// ASSERT_MPKNSS_LOCK(); +// +// if (PublicsIsResolved == FALSE) +// { +// return zFAILURE; +// } +// PublicsInUseCount++; +// +// status = (*Pubs[REG_XMLCONVERT].addr)(path, data, type, +// desc, misc, method, action, done, prompt, buffer, bufferLength); +// +// PublicsInUseCount--; +// return status; +//} +// +///**************************************************************************** +// * Get string or number from XML file +// ****************************************************************************/ +//STATUS REG_xmlUnConvert( +// BYTE *buffer, +// NINT bufLen, +// BYTE *content, +// size_t *retLen, +// void *number, /* can be NULL */ +// BOOL *isQuad, /* can be NULL */ +// NINT *type) /* can be NULL */ +//{ +// ASSERT_MPKNSS_LOCK(); +// +// if (PublicsIsResolved == FALSE) +// { +// return zFAILURE; +// } +// PublicsInUseCount++; +// +// (*Pubs[REG_XMLUNCONVERT].addr)(buffer, bufLen, content, retLen, number, +// isQuad, type); +// +// PublicsInUseCount--; +// return zOK; +//} +#endif + +/**************************************************************************** + * Call MGMT_MakeFunctionVirtualFile + ****************************************************************************/ +STATUS REG_MGMT_MakeFunctionVirtualFile( + Key_t key, + utf8_t *readRoutine, + utf8_t *readParm, + utf8_t *writeRoutine, + utf8_t *writeParm) +{ + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + if (PublicsIsResolved == FALSE) + { + return zFAILURE; + } + PublicsInUseCount++; + + status = (*Pubs[REG_MGMT_MAKEFUNCTIONVIRTUALFILE].addr)(key, + readRoutine, readParm, writeRoutine, writeParm, FALSE); + + PublicsInUseCount--; + return status; +} + +/**************************************************************************** + * Call VIRT_AddResultData + ****************************************************************************/ +STATUS REG_VIRT_AddResultData( + VirtInfo_s *virtInfo, + utf8_t *data) +{ + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + if (PublicsIsResolved == FALSE) + { + return zFAILURE; + } + PublicsInUseCount++; + + status = (*Pubs[REG_VIRT_ADDRESULTDATA].addr)(virtInfo, data); + + PublicsInUseCount--; + return status; +} + +/**************************************************************************** + * Call VIRT_AddResultElement + ****************************************************************************/ +STATUS REG_VIRT_AddResultElement( + VirtInfo_s *virtInfo, + utf8_t *tagName, + utf8_t *data) +{ + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + if (PublicsIsResolved == FALSE) + { + return zFAILURE; + } + PublicsInUseCount++; + + status = (*Pubs[REG_VIRT_ADDRESULTELEMENT].addr)(virtInfo, tagName, data); + + PublicsInUseCount--; + return status; +} + +/**************************************************************************** + * Call VIRT_AddResultTag + ****************************************************************************/ +STATUS REG_VIRT_AddResultTag( + VirtInfo_s *virtInfo, + utf8_t *tagName, + BOOL endTag, + BOOL newLine) +{ + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + if (PublicsIsResolved == FALSE) + { + return zFAILURE; + } + PublicsInUseCount++; + + status = (*Pubs[REG_VIRT_ADDRESULTTAG].addr)(virtInfo, tagName, endTag, + newLine); + + PublicsInUseCount--; + return status; +} + +/**************************************************************************** + * Given a path and a file name, find which module this management file * + * belongs to. * + ****************************************************************************/ +STATUS findModule( + BYTE *module, + RegisteredNLMs_s **rnlm) +{ + ASSERT_MPKNSS_LOCK(); + + zASSERT(DQ_NOT_EMPTY(&RegisteredNLMsList)); + if (DQ_EMPTY(&RegisteredNLMsList)) + { + return zERR_MODULE_NOT_FOUND; + } + + DQ_FOREACH(&RegisteredNLMsList, *rnlm, RegisteredNLMs_s, link) + { + if (stricmp(module, (*rnlm)->moduleName) == 0) + { + return zOK; + } + } + + /* check if it is "NSS" module */ + if (stricmp(module, MSGNot("NSS")) == 0) + { + *rnlm = NULL; + return zOK; + } + + return zERR_MODULE_NOT_FOUND; +} + + +/**************************************************************************** + * Find the version number of a module + ****************************************************************************/ +STATUS RNLM_version( + RegisteredNLMs_s *rnlm, + BYTE *data) +{ + ASSERT_MPKNSS_LOCK(); + if (rnlm != NULL) + { + FormatVersionString(&rnlm->versionInfo, data); + } + else + { + /* it is NSS module */ + FormatVersionString(&NSS_VersionInfo, data); + } + return zOK; +} + + +/**************************************************************************** + * Find the build number of a module + ****************************************************************************/ +STATUS RNLM_build( + RegisteredNLMs_s *rnlm, + BYTE *data) +{ + NINT buildNumber; + + ASSERT_MPKNSS_LOCK(); + if (rnlm != NULL) + { + buildNumber = rnlm->versionInfo.buildNumber; + } + else + { + buildNumber = NSS_VersionInfo.buildNumber; + } + + sprintf(data, MSGNot("%d"), buildNumber); + return zOK; +} + + +/**************************************************************************** + * Find the snap date of a module + ****************************************************************************/ +STATUS RNLM_snapDate( + RegisteredNLMs_s *rnlm, + BYTE *data) +{ + NINT snapDate; + + ASSERT_MPKNSS_LOCK(); + if (rnlm != NULL) + { + snapDate = rnlm->snapDate; + } + else + { + snapDate = NSS_SNAPDATE; + } + + sprintf(data, MSGNot("%x"), snapDate); + return zOK; +} + + +/**************************************************************************** + * Find the snap date of a module + ****************************************************************************/ +STATUS RNLM_os( + RegisteredNLMs_s *rnlm, + BYTE *data) +{ + ASSERT_MPKNSS_LOCK(); +#if zNETWARE + strcpy(data, "NetWare"); +#endif +#if zLINUX + strcpy(data, "Linux"); +#endif + return zOK; +} + + +BYTE *ModuleSubDir; +NINT ModuleSubDirLen; +RegAVFileInst_s ModuleInst[] = +{ + {NULL, &RNLM_build}, + {NULL, &RNLM_version}, + {NULL, &RNLM_snapDate}, + {NULL, &RNLM_os}, + {0}, +}; + +void initMgmtFile () +{ + NINT i; + + ASSERT_MPKNSS_LOCK(); + ModuleSubDir = MSG("Module", 286); + ModuleSubDirLen = strlen(ModuleSubDir); + i = 0; + ModuleInst[i++].tag = TAG_BUILD; + ModuleInst[i++].tag = TAG_VERSION; + ModuleInst[i++].tag = TAG_SNAPDATE; + ModuleInst[i++].tag = TAG_OS; +} + +#ifdef ADMIN_NSS +///**************************************************************************** +// * For set params of each module * +// ****************************************************************************/ +//#define MAX_CMDLINE_MODULES 50 /* copy from nssCmdline.c */ +// +///**************************************************************************** +// * This function will loop through all registered modules (including NSS) * +// * to find which module the pass in paramName resides in. It will return * +// * the switch. Also, if moduleName and msgTable are not NULL, it will fill * +// * in the necessary information * +// ****************************************************************************/ +//STATUS findSwitch( +// char *paramName, +// BOOL isBOOLType, +// char **moduleName, +// PCLSwitchDef_s **swdef, +// char ***msgTable) +//{ +// NINT i; +// PCLMultiSwitchList_s multiList[MAX_CMDLINE_MODULES]; +// +// ASSERT_MPKNSS_LOCK(); +// BuildMultiList(multiList); +// +// for (i = 0; (*swdef = multiList[i].swList) != NULL; i++) +// { +// for (; (*swdef)->name != PCMDLINE_ENDOFLIST; (*swdef)++) +// { +// if ((!strcmp(paramName, (*swdef)->name)) +// && ((isBOOLType) ? +// ((*swdef)->type & SWTYPE_BOOLEAN) : +// !((*swdef)->type & SWTYPE_BOOLEAN))) +// { +// if (moduleName) +// { +// *moduleName = multiList[i].moduleName; +// } +// +// if (msgTable) +// { +// *msgTable = multiList[i].messageTable; +// } +// return zOK; +// } +// } +// } +// +// return zFAILURE; +//} +// +///**************************************************************************** +// * This the generic read function for all modules set param management files +// ****************************************************************************/ +//STATUS RNLM_setParmRead( +// NINT parmLen, +// utf8_t *parm, +// NINT bufferLength, +// BYTE *buffer, +// NINT *retLen, +// FileHandle_s *fileHandle) +//{ +// BYTE paramName[zMAX_FULL_NAME]; +// BYTE *pr; +// BYTE *rDescription; +// LONG rType, rValue; +// LONG strLen; +// NINT i; +// NINT pos; +// BYTE data[256]; +// BOOL isBOOLType = FALSE; +// PCLSwitchDef_s *swdef; +// char **messageTable; +// utf8_t type; +// STATUS status; +// +// MPKNSS_LOCK(); +// +// /* +// * The last byte of the parm is an 'x' if we want the data in the XML +// * format. Otherwise just return the data as a string. +// */ +// type = parm[--parmLen]; +// +// status = zFAILURE; +// +// /* get the parameter name */ +// memcpy(paramName, parm, parmLen); +// paramName[parmLen] = 0; /* null terminate */ +// +// /* get rid of the extension */ +// pr = strrchr(paramName, '.'); +// if (pr) +// { +// *pr = 0; +// } +// +// pos = 0; +// while (pr = strstr(¶mName[pos], MSG("\\", 169))) +// { +// pos = pr + strlen(MSG("\\", 170)) - paramName; +// } +// +// /* get rid of the leading "(No)" if it exists (it happens on BOOL type switch */ +// if (pr = strstr(¶mName[pos], MSGNot("(No)"))) +// { +// pos += strlen(MSGNot("(No)")); /* length of (No) */ +// isBOOLType = TRUE; +// } +// +// /* find the correct switch */ +// if (findSwitch(¶mName[pos], isBOOLType, NULL, &swdef, &messageTable)) +// { +// /* failed to find switch */ +//// status = zFAILURE; +// goto Exit; +// } +// +// zASSERT(swdef->name != PCMDLINE_ENDOFLIST); +// if (swdef->name == PCMDLINE_ENDOFLIST) +// { +//// status = zFAILURE; +// goto Exit; +// } +// +// /* get the description for this switch*/ +// rDescription = StructGetMSGStrWithTable(swdef->helpStr, messageTable); +// zASSERT(rDescription != NULL); +// +// /* format the description */ +// strLen = 0; +// if (rDescription != NULL) +// { +// strLen = strlen(rDescription); +// i = 0; +// pr = rDescription; +// while (1) /* set one line to 75 characters */ +// { +//#define oneLineChar 75 +// if (strLen <= (oneLineChar - 2)) +// { +// sprintf(&buffer[i], MSGNot("# %s\r\n"), pr); +// break; +// } +// else +// { +// memcpy(&buffer[i], MSGNot("# "), 2); +// memcpy(&buffer[i + 2], pr, oneLineChar - 2); +// strLen -= oneLineChar - 2; +// i += oneLineChar; +// /* get rid of any incomplete word */ +// while (buffer[--i] != ' ') +// { +// strLen++; +// } +// buffer[i++] = '\r'; +// buffer[i++] = '\n'; +// pr = rDescription + strlen(rDescription) - strLen; +// } +// } +// +// strLen = strlen(buffer); +// } +// +// /* Get the full path again */ +// memcpy(paramName, parm, parmLen); +// paramName[parmLen] = 0; /* null terminate */ +// if (isBOOLType == TRUE) +// { +// pos -= strlen(MSGNot("(No)")); /* length of (No) */ +// } +// /* now get the current value */ +// rType = GET_SWTYPE(swdef->type); +// switch(rType) +// { +// case SWTYPE_VALUE: +// rValue = GET_SWVAL(swdef->type); +// /* get the value range */ +// if (((rValue != SWVAL_CHAR) || (rValue != SWVAL_UNICODE)) +// && (swdef->vtype.numeric.minValue +// != swdef->vtype.numeric.maxValue)) +// { +// sprintf(&buffer[strLen], MSG("# Limit: %u - %u\r\n", 171), +// swdef->vtype.numeric.minValue, +// swdef->vtype.numeric.maxValue); +// } +// switch(rValue) +// { +// case SWVAL_CHAR: +// sprintf(data, MSGNot("%s\r\n"), swdef->ret_value); +// if (type == 'x') +// { +// status = REG_xmlConvert(paramName, data, NSSSTRING, +// buffer, NULL, POST, ¶mName[pos], MSGNot("."), +// MSG("Please Enter the new value:", 172), +// buffer, bufferLength); +// } +// else +// { +// strcpy(buffer, data); +// status = zOK; +// } +// break; +// case SWVAL_UNICODE: +// sprintf(data, MSGNot("%U\r\n"), swdef->ret_value); +// if (type == 'x') +// { +// status = REG_xmlConvert(paramName, data, NSSSTRING, +// buffer, NULL, POST, ¶mName[pos], MSGNot("."), +// MSG("Please Enter the new value:", 173), +// buffer, bufferLength); +// } +// else +// { +// strcpy(buffer, data); +// status = zOK; +// } +// break; +// default: +// sprintf(data, MSGNot("%u\r\n"), *(LONG *)swdef->ret_value); +// if (type == 'x') +// { +// status = REG_xmlConvert(paramName, data, NSSNUMBER, +// buffer, NULL, POST, ¶mName[pos], MSGNot("."), +// MSG("Please Enter the new value:", 174), +// buffer, bufferLength); +// } +// else +// { +// strcpy(buffer, data); +// status = zOK; +// } +// break; +// } +// break; +// case SWTYPE_BOOLEAN: +// sprintf(data, MSGNot("%s\r\n"), (*(BOOL *)swdef->ret_value) ? +// MSGNot("ON") : MSGNot("OFF")); +// if (type == 'x') +// { +// status = REG_xmlConvert(paramName, data, NSSSTRING, +// buffer, NULL, POST, ¶mName[pos], MSGNot("."), +// MSG("Please Enter the new value:", 175), +// buffer, bufferLength); +// } +// else +// { +// strcpy(buffer, data); +// status = zOK; +// } +// break; +// default: +//// status = zFAILURE; +// break; +// } +// +// *retLen = strlen(buffer); +// +//Exit: +// MPKNSS_UNLOCK(); +// +// return status; +//} +// +// +///**************************************************************************** +// * This the generic writeoverride for all modules set param management files* +// * FixFixFix6: When Admin Volume becomes persistent, this function needs to * +// * be changed. * +// ****************************************************************************/ +//STATUS RNLM_setParmWrite( +// NINT parmLen, +// utf8_t *parm, +// NINT bufferLength, +// BYTE *buffer, +// NINT offset, +// FileHandle_s *fileHandle) +//{ +// BYTE paramName[zMAX_FULL_NAME]; +// BYTE *pr; +// LONG rType, rValue; +// BYTE *buf; +// NINT dist; +// NINT pos; +// BYTE *newValueStr = NULL; +// unicode_t *newValueUni = NULL; +// NINT newValueLong; +// QUAD fileEOF; +// NINT strLen; +// BYTE *fileContent = NULL; +// BOOL isBOOLType = FALSE; +// PCLSwitchDef_s *swdef; +// BOOL modifyEntry = FALSE; +// char *moduleName; +// LONG result; +// LONG storeFileHandle = 0; +// utf8_t type; +// STATUS status; +// +// MPKNSS_LOCK(); +// +// /* +// * The last byte of the parm is an 'x' if we want the data in the XML +// * format. Otherwise just return the data as a string. +// */ +// type = parm[--parmLen]; +// +// status = zFAILURE; +// +///*----------------------------------------------------------------------* +// * Open sys:\$$nss$$.prv\set_param file, and get its content * +// *----------------------------------------------------------------------*/ +// if (openSetParmStoreFile(&storeFileHandle) != zOK) +// { +// goto Exit; +// } +// +// SetParmStroeFileOpenCount++; +// +// newValueStr = (BYTE *)zalloc(bufferLength + 1); +// if (type == 'x') +// { +// REG_xmlUnConvert(buffer, bufferLength, newValueStr, &strLen, NULL, NULL, +// NULL); +// if (strLen == -1) +// { +// memcpy(newValueStr, buffer, bufferLength); +// newValueStr[bufferLength] = 0; +// } +// else if (strLen == 0) +// { +// /* something wrong inside NSS tag */ +// goto Exit; +// } +// else +// { +// newValueStr[strLen] = 0; +// } +// } +// else +// { +// memcpy(newValueStr, buffer, bufferLength); +// newValueStr[bufferLength] = 0; +// } +// +// /* now newValueStr only has the value of set parms. */ +// +// /* get the parameter name */ +// memcpy(paramName, parm, parmLen); +// paramName[parmLen] = 0; /* null terminate */ +// +// /* get rid of the extension */ +// pr = strrchr(paramName, '.'); +// if (pr) +// { +// *pr = 0; +// } +// +// pos = 0; +// while (pr = strstr(¶mName[pos], MSG("\\", 176))) +// { +// pos = pr + strlen(MSG("\\", 177)) - paramName; +// } +// +// /* get rid of the leading "(No)" if it exists */ +// if (pr = strstr(¶mName[pos], MSGNot("(No)"))) +// { +// pos += strlen(MSGNot("(No)")); /* length of (No) */ +// isBOOLType = TRUE; +// } +// +// /* find the correct switch */ +// if (findSwitch(¶mName[pos], isBOOLType, &moduleName, &swdef, NULL)) +// { +// goto Exit; +// } +// +// zASSERT(swdef->name != PCMDLINE_ENDOFLIST); +// if (swdef->name == PCMDLINE_ENDOFLIST) +// { +// goto Exit; +// } +// +// /* now get the current value */ +// rType = GET_SWTYPE(swdef->type); +// switch(rType) +// { +// case SWTYPE_VALUE: +// rValue = GET_SWVAL(swdef->type); +// +// switch(rValue) +// { +// case SWVAL_CHAR: +// if ((stricmp(swdef->ret_value, newValueStr)) +// && (strlen(newValueStr) <= swdef->vtype.string.ret_valueLen)) +// { +// modifyEntry = TRUE; +// strcpy(swdef->ret_value, newValueStr); +// } +// break; +// case SWVAL_UNICODE: +// newValueUni = (unicode_t *)zalloc(sizeof(unicode_t) * (strLen + 1)); +// LB_ByteToUnicode(NSS_UNI_CONVERSION_RAW, newValueUni, +// strLen + 1, newValueStr, NULL); +// +// if ((uniicmp(swdef->ret_value, newValueUni)) +// && (unilen(newValueUni) <= swdef->vtype.string.ret_valueLen)) +// { +// modifyEntry = TRUE; +// unicpy(swdef->ret_value, newValueUni); +// } +// +// free(newValueUni); +// break; +// default: +// newValueLong = atol(newValueStr); +// if ((swdef->vtype.numeric.minValue != swdef->vtype.numeric.maxValue) +// && ((newValueLong < swdef->vtype.numeric.minValue) +// || (newValueLong > swdef->vtype.numeric.maxValue))) +// { +// /* invalid value, just exit */ +// goto Exit; +// } +// if (newValueLong != *(LONG *)swdef->ret_value) +// { +// modifyEntry = TRUE; +// *(LONG *)swdef->ret_value = newValueLong; +// itoa(newValueLong, newValueStr, 10); +// } +// break; +// } +// break; +// case SWTYPE_BOOLEAN: +// if (*(BOOL *)swdef->ret_value != ((!stricmp(newValueStr, MSGNot("ON"))) ? TRUE : FALSE)) +// { +// modifyEntry = TRUE; +// *(BOOL *)swdef->ret_value = (!stricmp(newValueStr, MSGNot("ON"))) ? TRUE : FALSE; +// } +// break; +// default: +//// status = zFAILURE; +// goto Exit; +// } +// +// if (modifyEntry) +// { +// /* call process if one is defined. we have no way to get the +// options and userparams. Fortunately, most of processes +// defined in this field don't use them all. For those who +// do use these parameters, either they have no ret_value, +// or startup only. We don't need to worry about it as long +// as we don't support them in our file methods. */ +// if (swdef->process) +// { +// MPKNSS_UNLOCK(); +// swdef->process(swdef, POPT_AT_RUNTIME, (void *)swdef->userInfo); +// MPKNSS_LOCK(); +// } +// +// /* +// * now get the contents of sys:\$$nss$$.prv\nss_setparm, since we are going to +// * change something +// */ +// if (storeFileHandle) +// { +// ZOS_GetFileSize(result, 0, storeFileHandle, (LONG *)&fileEOF); +// if (result != zOK) +// { +// zASSERT(MSGNot("Failed to get file size") == NULL); +//// status = zFAILURE; +// goto Exit; +// } +// } +// if (storeFileHandle) +// { +// fileContent = (BYTE *)zalloc(fileEOF + 1); +// ZOS_ReadFile(result,0, storeFileHandle, 0, fileEOF, (LONG *)&fileEOF, fileContent); +// if (result != zOK) +// { +// zASSERT(MSGNot("Failed to read file") == NULL); +//// status = zFAILURE; +// goto Exit; +// } +// } +// +// fileContent[fileEOF] = '\0'; +// +// /* Update the file sys:\nss_setparm, find the entry of it */ +// if (isBOOLType) +// { +// /* we go back for the length of "(No)", to get the entry */ +//// paramName -= strlen(MSGNot("(No)")); +// pos -= strlen(MSGNot("(No)")); +// } +// +// pr = fileContent; +// while (pr = strstr(pr, ¶mName[pos])) +// { +// pr += strlen(¶mName[pos]); +// /* if it's not a part of the word, we find it */ +// if (((*(pr - strlen(¶mName[pos]) - 1) == ' ') || (*(pr - strlen(¶mName[pos]) - 1) == '\n')) +// && ((*pr == ' ') || (*pr == '='))) +// { +// break; +// } +// } +// +// /* find it, pr is pointing the content after the ¶mName[pos] */ +// if (pr) +// { +// while (*pr != '=') +// { +// pr++; +// } +// while (*++pr == ' ') +// { +// ; +// } +// dist = pr - fileContent; +// /* we need to rewrite everything from this point to file again */ +// buf = strchr(pr, '\n'); +// if (buf) +// { +// buf++; +// } +// } +// else +// { +// /* we need to insert this entry */ +// if ((pr = strstr(fileContent, moduleName)) == NULL) +// { +// /* can't find the module in the file, something wrong happened */ +//// status = zFAILURE; +// goto Exit; +// } +// +// pr = strchr(pr, '\n') + 1; /* this line is ended by '\n' */ +// strLen = strlen(¶mName[pos]); +// dist = pr - fileContent; +// +// if (storeFileHandle) +// { +// ZOS_WriteFile(result,0, storeFileHandle, dist, strLen, +// ¶mName[pos]); +// if (result != zOK) +// { +// zASSERT(MSGNot("Failed to write file") == NULL); +//// status = zFAILURE; +// goto Exit; +// } +// } +// dist += strLen; +// if (storeFileHandle) +// { +// ZOS_WriteFile(result,0, storeFileHandle, dist, +// strlen(" = "), " = "); +// if (result != zOK) +// { +// zASSERT(MSGNot("Failed to write file") == NULL); +//// status = zFAILURE; +// goto Exit; +// } +// } +// +// dist += strlen(" = "); +// /* we need to rewrite everything from this point to file again */ +// buf = pr; +// } +// +// /* write the new value to the entry */ +// strcat(newValueStr, "\n"); +// strLen = strlen(newValueStr); +// if (storeFileHandle) +// { +// ZOS_WriteFile(result,0, storeFileHandle, dist, strLen, newValueStr); +// if (result != zOK) +// { +// zASSERT(MSGNot("Failed to write file") == NULL); +//// status = zFAILURE; +// goto Exit; +// } +// } +// dist += strLen; +// +// if (storeFileHandle) +// { +// ZOS_WriteFile(result,0, storeFileHandle, dist, strlen(buf), buf); +// /* rewrite the things trailing to this point */ +// if (result != zOK) +// { +// zASSERT(MSGNot("Failed to write file") == NULL); +//// status = zFAILURE; +// goto Exit; +// } +// } +// } +// status = zOK; +// +// /* fail to find the matching file */ +//// status = zFAILURE; +// +//Exit: +// if (fileContent) +// free(fileContent); +// if (newValueStr) +// free(newValueStr); +// if (storeFileHandle) +// { +// ZOS_CloseFile(0, zNSS_TASK, storeFileHandle); +// SetParmStroeFileOpenCount--; +// } +// +// MPKNSS_UNLOCK(); +// return status; +//} +// +// +// +///**************************************************************************** +// * This is the generic startup routine for all modules set param management * +// * files. It also checks sys:set_param to see if any value is changed and * +// * recorded. If so, it will change the value of corresponding parameter. * +// * Note: If set param switch has type of SWOPT_STARTUP_ONLY, SWOPT_HIDDEN, * +// * or has NULL swdef->ret_value, it will skip to set it up. * +// * FixFixFix6: When Admin Volume becomes persistent, this function needs to * +// * be changed. * +// ****************************************************************************/ +//STATUS RNLM_StartupSetParam( +// char *moduleName, +// NINT *registrationState, +// PCLSwitchDef_s *commandLineSwitches) +//{ +// NINT i; +// NINT strLen; +// NINT rType; +// NINT rValue; +// BYTE path[zMAX_FULL_NAME]; +// QUAD fileEOF = 0; +// BYTE *buffer = NULL; +// BYTE *pr; +// BYTE *entry; +// BYTE *buf; +// char oldChar; +// unicode_t *uni; +// NINT newValueLong; +// PCLSwitchDef_s *swdef; +// BOOL deleteEntry; +// LONG result; +// STATUS status; +// LONG fileHandle = 0; +// Key_t rootKey; +// Key_t retKey; +// GeneralMsg_s genMsg; +// +// ASSERT_MPKNSS_LOCK(); +// +// COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE(&genMsg); +// +///*----------------------------------------------------------------------* +// * If this module has no cmdline set params, simply return * +// *----------------------------------------------------------------------*/ +// if (commandLineSwitches == NULL) +// { +// *registrationState |= NSSREGSTATE_SETPARMSTARTED; +// return zOK; +// } +// +///*----------------------------------------------------------------------* +// * If this module's cmdline switch has already been started * +// *----------------------------------------------------------------------*/ +// if (*registrationState & NSSREGSTATE_SETPARMSTARTED) +// { +// return zOK; +// } +// +///*----------------------------------------------------------------------* +// * Check if zAPIs have been resolved * +// *----------------------------------------------------------------------*/ +// zASSERT(PublicsIsResolved != FALSE); +// if (PublicsIsResolved == FALSE) +// { +// return zFAILURE; +// } +// PublicsInUseCount++; +// +///*----------------------------------------------------------------------* +// * Open sys:\$$nss$$.prv\set_param file, and get its content * +// *----------------------------------------------------------------------*/ +// if (openSetParmStoreFile(&fileHandle) != zOK) +// { +// PublicsInUseCount--; +// return zFAILURE; +// } +// SetParmStroeFileOpenCount++; +// +// if (fileHandle) +// { +// ZOS_GetFileSize(result, 0, fileHandle, (LONG *)&fileEOF); +// if (result != zOK) +// { +// zASSERT(MSGNot("Failed to get file size") == NULL); +// goto errorExit; +// } +// } +// +// buffer = (BYTE *)zalloc(fileEOF + 1); +// if (fileHandle) +// { +// ZOS_ReadFile(result, 0, fileHandle, 0, fileEOF, (LONG *)&fileEOF, buffer); +// if (result != zOK) +// { +// zASSERT(MSGNot("Failed to read file") == NULL); +// goto errorExit; +// } +// } +// +// buffer[fileEOF] = '\0'; +// +///*----------------------------------------------------------------------* +// * Prepare necessary path information * +// *----------------------------------------------------------------------*/ +// +// strcpy(path, AVFileMgmtDir); +// +// +// /* check if there's an entry for this module in the file */ +// if ((pr = strstr(buffer, moduleName)) == NULL) +// { +// /* we need to set up necessary entries. it only needs to be done for once */ +// sprintf(path, MSGNot("[%s]\n\n\n"), moduleName); +// buffer = realloc(buffer, fileEOF + strlen(path) + 1); +// strcpy(&buffer[fileEOF], path); +// } +// +///*----------------------------------------------------------------------* +// * next, create set params under this "Configuration\\NSS" * +// * if "Configuration\\NSS" is not set up, set it up now. * +// *----------------------------------------------------------------------*/ +// if (REG_zRootKey(0, &rootKey) != zOK) +// { +// zASSERT("Error opening root key" == 0); +// goto errorExit; +// } +// +// strcpy(path, AVFileMgmtDir); +// sprintf(&path[AVFileMgmtDirLen], MSG("Config_NSS\\", 178)); +// if (SetParmBaseDirStarted == FALSE) +// { +// if (REG_zCreate(rootKey, zNO_TASK, 0, +// zNSPACE_LONG | zMODE_UTF8, path, zFILE_REGULAR, AVFILEDIRATTR, +// zCREATE_OPEN_IF_THERE, 0, &retKey) != zOK) +// { +// zASSERT("Error creating dir" == 0); +// goto errorClose; +// } +// REG_zClose(retKey); +// SetParmBaseDirStarted = TRUE; +// } +// +// strLen = strlen(path); +// for(swdef = commandLineSwitches, i = 0; swdef->name != PCMDLINE_ENDOFLIST; swdef++, i++) +// { +// deleteEntry = FALSE; +// +// /* We skip to create a set param file which has following conditions */ +// if ((swdef->type & (SWOPT_STARTUP_ONLY | SWOPT_HIDDEN)) +// || swdef->ret_value == NULL) +// { +// continue; +// } +// +// /* If it is a boolean type, add "(No)" ahead of file name. */ +// if (swdef->type & SWTYPE_BOOLEAN) +// { +// sprintf(&path[strLen], MSGNot("(No)%s.xml"), swdef->name); +// } +// else +// { +// sprintf(&path[strLen], MSGNot("%s.xml"), swdef->name); +// } +// +// /* create the file */ +// if (REG_zCreate(rootKey, zNO_TASK, 0, +// zNSPACE_LONG | zMODE_UTF8, path, zFILE_REGULAR, AVFILEFILEATTR, +// zCREATE_OPEN_IF_THERE, 0, &retKey) != zOK) +// { +// zASSERT("Error creating file" == 0); +// goto errorClose; +// } +// +// status = REG_MGMT_MakeFunctionVirtualFile(&genMsg, retKey, +// "RNLM_setParmRead", path, "RNLM_setParmWrite", path); +// REG_zClose(retKey); +// if (status != zOK) +// { +// zASSERT("Error making template" == 0); +// goto errorClose; +// } +// +//// if (RegAVFileAddLink(&RegNLMSetParmMgmtFiles, path, zid) != zOK) +//// { +//// goto errorClose; +//// } +// +// /* get rid of the ".xml" extension from path */ +// pr = strrchr(path, '.'); +// *pr = 0; +// +// /* set values if it is different from it's default value */ +// pr = buffer; +// while (pr = strstr(pr, &path[strLen])) +// { +// entry = pr; +// pr += strlen(&path[strLen]); +// /* if it's not a part of the word, we find it */ +// if (((*(pr - strlen(&path[strLen]) - 1) == ' ') || (*(pr - strlen(&path[strLen]) - 1) == '\n')) +// && ((*pr == ' ') || (*pr == '='))) +// { +// while (*pr != '=') +// { +// pr++; +// } +// while (*++pr == ' ') +// { +// ; +// } +// +// /* get the value part */ +// if (!(buf = strchr(pr, '\n'))) +// { +// /* last entry in the file */ +// buf = pr + strlen(pr) - 1; +// } +// while ((*buf == ' ') || (*buf == '\r') || (*buf == '\n')) +// { +// buf--; +// } +// /* buf points to the next character following value */ +// buf++; +// oldChar = *buf; +// *buf = '\0'; +// +// rType = GET_SWTYPE(swdef->type); +// switch(rType) +// { +// case SWTYPE_VALUE: +// rValue = GET_SWVAL(swdef->type); +// +// switch(rValue) +// { +// case SWVAL_CHAR: +// /* default value, delete this entry */ +// if (!stricmp(swdef->ret_value, pr)) +// { +// deleteEntry = TRUE; +// } +// /* different */ +// else if (strlen(pr) <= swdef->vtype.string.ret_valueLen) +// { +// strcpy(swdef->ret_value, pr); +// } +// break; +// case SWVAL_UNICODE: +// uni = (unicode_t *)zalloc(sizeof(unicode_t) * (strlen(pr) + 1)); +// LB_ByteToUnicode(NSS_UNI_CONVERSION_RAW, uni, +// strlen(pr) + 1, pr, NULL); +// +// /* default value, delete this entry */ +// if (!uniicmp(swdef->ret_value, uni)) +// { +// deleteEntry = TRUE; +// } +// /* different */ +// else if (unilen(uni) <= swdef->vtype.string.ret_valueLen) +// { +// unicpy(swdef->ret_value, uni); +// } +// free(uni); +// break; +// default: +// newValueLong = atol(pr); +// /* default value, delete this entry */ +// if (*(NINT *)swdef->ret_value == newValueLong) +// { +// deleteEntry = TRUE; +// } +// /* different */ +// else if ((swdef->vtype.numeric.minValue +// != swdef->vtype.numeric.maxValue) +// && ((newValueLong >= swdef->vtype.numeric.minValue) +// && (newValueLong <= swdef->vtype.numeric.maxValue))) +// { +// *(NINT *)swdef->ret_value = newValueLong; +// } +// break; +// } +// break; +// case SWTYPE_BOOLEAN: +// /* default value, delete this entry */ +// if (*(BOOL *)swdef->ret_value == ((!strcmp(pr, MSGNot("ON"))) ? TRUE : FALSE)) +// { +// deleteEntry = TRUE; +// } +// else +// { +// *(BOOL *)swdef->ret_value = (!strcmp(pr, MSGNot("ON"))) ? TRUE : FALSE; +// } +// break; +// default: +// /* if something wrong, we simply don't set the value */ +// break; +// } +// +// /* call process if one is defined. we have no way to get the +// options and userparams. Fortunately, most of processes +// defined in this field don't use them all. For those who +// do use these parameters, either they have no ret_value, +// or startup only. We don't need to worry about it as long +// as we don't support them in our file methods. */ +// if ((deleteEntry == FALSE) && (swdef->process)) +// { +// MPKNSS_UNLOCK(); +// swdef->process( +// swdef, POPT_AT_RUNTIME, +// (void *)swdef->userInfo); +// MPKNSS_LOCK(); +// } +// +// *buf = oldChar; +// +// /* delete entry if the value is default */ +// if (deleteEntry) +// { +// if (buf = strchr(pr, '\n')) +// { +// /* not the last entry in file */ +// strcpy(&buffer[entry - buffer], buf + 1); +// } +// else +// { +// /* last entry */ +// buffer[entry - buffer] = '\0'; +// } +// } +// /* break from the while loop */ +// break; +// } +// } +// } +// +// REG_zClose(rootKey); +// +// if (fileHandle) +// { +// ZOS_WriteFile(result,0, fileHandle, 0, strlen(buffer), buffer); +// /* rewrite file in case any change is made */ +// if (result != zOK) +// { +// zASSERT(MSGNot("Failed to write file") == NULL); +// /* we don't return error code since we've started up */ +// } +// } +// +// if (fileHandle) +// { +// ZOS_WriteFile(result,0, fileHandle, strlen(buffer), 0, NULL); +// /* reset file size */ +// if (result != zOK) +// { +// zASSERT(MSGNot("Failed to reset file size") == NULL); +// /* we don't return error code since we've started up */ +// } +// } +// +// if (fileHandle) +// { +// ZOS_CloseFile(0, zNSS_TASK, fileHandle); +// } +// SetParmStroeFileOpenCount--; +// +// if (buffer) +// { +// free(buffer); +// } +// +// *registrationState |= NSSREGSTATE_SETPARMSTARTED; +// +// PublicsInUseCount--; +// +// return zOK; +// +//errorClose: +// REG_zClose(rootKey); +// +//errorExit: +// if (fileHandle) +// { +// ZOS_CloseFile(0, zNSS_TASK, fileHandle); +// } +// SetParmStroeFileOpenCount--; +// +// if (buffer) +// { +// free(buffer); +// } +// +// PublicsInUseCount--; +// +// return zFAILURE; +//} +// +// +///**************************************************************************** +// * This the generic shutdown routine for all modules set param management +// * files. +// * Note: for COMN and NSS nlm management files, because CMN_GlobalShutdown +// * happens before this routine is called, which means AdminVol_shutdown +// * has already removed all the files user created on the admin volume, +// * here we only need to free all the allocated memory. +// ****************************************************************************/ +//void RNLM_ShutdownSetParam( +// BYTE *moduleName, +// NINT *registrationState, +// PCLSwitchDef_s *commandLineSwitches) +//{ +// PCLSwitchDef_s *swdef; +// NINT strLen; +// BYTE path[zMAX_FULL_NAME]; +// Key_t rootKey; +// +// ASSERT_MPKNSS_LOCK(); +// if (commandLineSwitches == NULL) +// { +// *registrationState &= ~NSSREGSTATE_SETPARMSTARTED; +// return; +// } +// +// if (!(*registrationState & NSSREGSTATE_SETPARMSTARTED)) +// { +// return; +// } +// +// strcpy(path, moduleName); +// strupr(path); +// if (strstr(path, MSGNot("COMN"))) +// { +// NSSSetParmStarted = FALSE; +// SetParmBaseDirStarted = FALSE; +// return; +// } +// +// /* zAPIs is resolved */ +// zASSERT(PublicsIsResolved != FALSE); +// if (PublicsIsResolved == FALSE) +// { +// return; +// } +// PublicsInUseCount++; +// +// strcpy((char *)path, (char *)AVFileMgmtDir); +// +// sprintf(&path[AVFileMgmtDirLen], MSG("Configuration\\%s\\", 179), MSGNot("NSS")); +// strLen = strlen(path); +// +// if (REG_zRootKey(0, &rootKey) != zOK) +// { +// zASSERT("Error opening root key" == 0); +// goto errorExit; +// } +// +// for (swdef = commandLineSwitches; swdef->name != PCMDLINE_ENDOFLIST; swdef++) +// { +// if ((swdef->type & (SWOPT_STARTUP_ONLY | SWOPT_HIDDEN)) +// || swdef->ret_value == NULL) +// { +// continue; +// } +// +// if (swdef->type & SWTYPE_BOOLEAN) +// { +// sprintf(&path[strLen], MSGNot("(No)%s.xml"), swdef->name); +// } +// else +// { +// sprintf(&path[strLen], MSGNot("%s.xml"), swdef->name); +// } +// +// REG_zDelete(rootKey, 0, zNSPACE_LONG | zMODE_UTF8, path, zMATCH_ALL, +// zDELETE_FORCE_DELETE); +// } +// REG_zClose(rootKey); +// +//errorExit: +// *registrationState &= ~NSSREGSTATE_SETPARMSTARTED; +// +// PublicsInUseCount--; +// +// return; +//} +#endif + +/******************************************************************************** + * All management files (defined above) under MgmtFiles directory + * use the same readOverride. + ********************************************************************************/ +/* VIRTUAL FILE -- READ FUNCTION */ +STATUS RNLM_readFunction( + NINT parmLen, + utf8_t *parm, + VirtInfo_s *virtInfo) +{ + NINT index; + STATUS status = zOK; + RegisteredNLMs_s *rnlm; + + typedef struct Stack_s { + BYTE data[4096]; /* must be large enough for largest element content */ + } Stack_s; + STACK_ALLOC(); + + MPKNSS_LOCK(); + + if ((status = REG_VIRT_AddResultTag(virtInfo, TAG_NSSREPLY, FALSE, + TRUE)) != zOK) + { + goto exit; + } + if ((status = REG_VIRT_AddResultTag(virtInfo, TAG_MODULE, FALSE, + TRUE)) != zOK) + { + goto exit; + } + /* + * For each tag in the table, generate an element in the return XML. + */ + memcpy(aStack->data, parm, parmLen); + aStack->data[parmLen] = 0; + if ((status = findModule(aStack->data, &rnlm)) != zOK) + { + goto exit; + } + + for (index = 0; ModuleInst[index].tag != NULL; index++) + { + /* Generate the actual element data */ + status = ModuleInst[index].function(rnlm, aStack->data); + if ((status = REG_VIRT_AddResultElement(virtInfo, + ModuleInst[index].tag, aStack->data)) != zOK) + { + break; + } + } + if ((status = REG_VIRT_AddResultTag(virtInfo, TAG_MODULE, TRUE, + TRUE)) != zOK) + { + goto exit; + } + status = REG_VIRT_AddResultTag(virtInfo, TAG_NSSREPLY, TRUE, TRUE); + +exit: + MPKNSS_UNLOCK(); + STACK_FREE(); + return status; +} + +/**************************************************************************** + * This is the generic startup routine for all modules MODULE management * + * files. * + ****************************************************************************/ +STATUS RNLM_StartupModule(BYTE *moduleName) +{ + Key_t rootKey; + Key_t retKey; + GeneralMsg_s genMsg; + + typedef struct Stack_s { + BYTE pathStr[zMAX_FULL_NAME]; + } Stack_s; + STACK_ALLOC(); + + ASSERT_MPKNSS_LOCK(); + zASSERT(PublicsIsResolved != FALSE); + + COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE(&genMsg); + + if (PublicsIsResolved == FALSE) + { + STACK_FREE(); + return zFAILURE; + } + PublicsInUseCount++; + + if (REG_zRootKey(0, &rootKey) != zOK) + { + zASSERT("Error opening root key" == 0); + goto errorExit; + } + + strcpy((char *)aStack->pathStr, (char *)AVFileMgmtDir); + + if (ModuleBaseDirStarted == FALSE) + { + strcpy(&aStack->pathStr[AVFileMgmtDirLen], ModuleSubDir); + + if (REG_zCreate(rootKey, zNO_TASK, 0, + zNSPACE_LONG | zMODE_UTF8, aStack->pathStr, zFILE_REGULAR, AVFILEDIRATTR, + zCREATE_OPEN_IF_THERE, 0, &retKey) != zOK) + { + zASSERT("Error creating directory" == 0); + goto errorClose; + } + REG_zClose(retKey); + ModuleBaseDirStarted = TRUE; + } + + strcpy(&aStack->pathStr[AVFileMgmtDirLen], ModuleSubDir); /* add the sub directory name */ + aStack->pathStr[AVFileMgmtDirLen+ModuleSubDirLen] = '\\'; + strcpy(&aStack->pathStr[AVFileMgmtDirLen+ModuleSubDirLen+1], moduleName); + strcat(aStack->pathStr, MSG(".xml", 152)); + if (REG_zCreate(rootKey, zNO_TASK, 0, + zNSPACE_LONG | zMODE_UTF8, aStack->pathStr, zFILE_REGULAR, AVFILEFILEATTR, + zCREATE_OPEN_IF_THERE, 0, &retKey) != zOK) + { + zASSERT("Error creating file" == 0); + goto errorClose; + } + + /* Write the transformation template to the file */ + if (REG_MGMT_MakeFunctionVirtualFile(retKey, + MSGNot("RNLM_readFunction"), moduleName, NULL, NULL) != zOK) + { + zASSERT("Error making template" == 0); + REG_zClose(retKey); + goto errorClose; + } + REG_zClose(retKey); + REG_zClose(rootKey); + + PublicsInUseCount--; + STACK_FREE(); + return zOK; + +errorClose: + REG_zClose(rootKey); + +errorExit: + PublicsInUseCount--; + STACK_FREE(); + return zFAILURE; +} + + +/**************************************************************************** + * This the generic shutdown routine for all modules MODULE management + * files. + * Note: for COMN and NSS nlm management files, because CMN_GlobalShutdown + * happens before this routine is called, which means AdminVol_shutdown + * has already removed all the files user created on the admin volume, + * here we only need to free all the allocated memory. + ****************************************************************************/ +void RNLM_ShutdownModule(BYTE *moduleName) +{ + Key_t rootKey; + typedef struct Stack_s { + BYTE pathStr[zMAX_FULL_NAME]; + } Stack_s; + + STACK_ALLOC(); + + ASSERT_MPKNSS_LOCK(); + + strcpy(aStack->pathStr, moduleName); + strupr(aStack->pathStr); + if (strstr(aStack->pathStr, MSGNot("COMN"))) + { + ModuleBaseDirStarted = FALSE; + STACK_FREE(); + return; + } + + zASSERT(PublicsIsResolved !=FALSE); + if (PublicsIsResolved == FALSE) + { + STACK_FREE(); + return; + } + PublicsInUseCount++; + + strcpy((char *)aStack->pathStr, (char *)AVFileMgmtDir); + if (REG_zRootKey(0, &rootKey) != zOK) + { + zASSERT("Error opening root key" == 0); + goto errorExit; + } + + strcpy(&aStack->pathStr[AVFileMgmtDirLen], ModuleSubDir); /* add the sub directory name */ + aStack->pathStr[AVFileMgmtDirLen+ModuleSubDirLen] = '\\'; + strcpy(&aStack->pathStr[AVFileMgmtDirLen+ModuleSubDirLen+1], moduleName); + REG_zDelete(rootKey, 0, zNSPACE_LONG | zMODE_UTF8, aStack->pathStr, + zMATCH_ALL, zDELETE_FORCE_DELETE); + REG_zClose(rootKey); + +errorExit: + PublicsInUseCount--; + + STACK_FREE(); + return; +} + + +/**************************************************************************** + * Add loaded module as management files, it includes two parts: * + * 1. Add module build/version * + * 2. Add set params (configuration) * + ****************************************************************************/ +STATUS NSS_addMgmtFile(RegisteredNLMs_s *rnlm) +{ + BYTE moduleName[64]; + + ASSERT_MPKNSS_LOCK(); +/*----------------------------------------------------------------------* + * Startup module management file * + *----------------------------------------------------------------------*/ + /* we need to add NSS module because it's not in RegisteredNLMsList */ + if (!ModuleBaseDirStarted && !SetParmBaseDirStarted) + { + initMgmtFile(); + + sprintf(moduleName, MSGNot("NSS")); + RNLM_StartupModule(moduleName); +#ifdef ADMIN_NSS +// RNLM_StartupSetParam(moduleName, +// &NSSSetParmStarted, +// NSS_CommandLineSwitches); +#endif + } + + /* create module build/version instance */ + strcpy(moduleName, rnlm->moduleName); + RNLM_StartupModule(moduleName); +#ifdef ADMIN_NSS +// RNLM_StartupSetParam(moduleName, +// &rnlm->registrationState, +// rnlm->commandLineSwitches); +#endif + + return zOK; +} + + +/**************************************************************************** + * Remove loaded module as management files.It happens when a module is * + * unloading (unregister NLM). * + ****************************************************************************/ +void NSS_removeMgmtFile(RegisteredNLMs_s *rnlm) +{ + ASSERT_MPKNSS_LOCK(); + RNLM_ShutdownModule(rnlm->moduleName); +#ifdef ADMIN_NSS +// RNLM_ShutdownSetParam(rnlm->moduleName, &rnlm->registrationState, +// rnlm->commandLineSwitches); +#endif + return; +} + + +/************************************************************************** + * Display loaded module information + ***************************************************************************/ +void NSS_doDisplayModules(void) +{ + RegisteredNLMs_s *rnlm; + char versionString[16]; + + MPKNSS_LOCK(); + printf(MSG(" Modules Version Build Snap Date\n",180)); + printf(MSG(" ----------- ------- ----- ---------\n",181)); + FormatVersionString(&NSS_VersionInfo,versionString); + printf(MSG(" %-11s %6s %5d %05x\n",182),MSGNot("NSS"),versionString,NSS_VersionInfo.buildNumber, NSS_SNAPDATE); + DQ_FOREACH(&RegisteredNLMsList,rnlm,RegisteredNLMs_s,link) + { + FormatVersionString(&rnlm->versionInfo,versionString); + printf(MSG(" %-11s %6s %5d %05x\n",183),rnlm->moduleName,versionString,rnlm->versionInfo.buildNumber, rnlm->snapDate); + } + MPKNSS_UNLOCK(); +} + + +/************************************************************************** + * Internal routine to locate the given module definition. + ***************************************************************************/ +STATIC RegisteredNLMs_s *NSS_locateLoadedNLM( + char *moduleName) +{ + RegisteredNLMs_s *rnlm; + ASSERT_MPKNSS_LOCK(); + + DQ_FOREACH(&RegisteredNLMsList,rnlm,RegisteredNLMs_s,link) + { + if (stricmp(moduleName,rnlm->moduleName) == 0) + { + return rnlm; + } + } + return NULL; +} + +/************************************************************************** + * used as a call back check to validate if the module is still loaded when + * in the middle of a comandline parse and the modules is unloaded. + ***************************************************************************/ +BOOL NSS_ValidateSWList( PCLSwitchDef_s *checkswdef ) +{ + RegisteredNLMs_s *rnlm; + + if(checkswdef == NSS_CommandLineSwitches) + return TRUE; + + DQ_FOREACH(&RegisteredNLMsList,rnlm,RegisteredNLMs_s,link) + { + if(rnlm->commandLineSwitches == checkswdef) + { + return TRUE; + } + } + return FALSE; +} + +/************************************************************************** + * This will loop through and load all of the standars NSS NLMs + ***************************************************************************/ +extern STATUS NSS_RegisterExternalNLM( + char *moduleName, + void *moduleHandle, + char **messageTable, + NINT moduleType, + NINT registrationFlags, + VersionInformation_s *versionInfo, + NINT APIVersion, + NINT snapDate, + NINT debugEnabled, + NINT mpEnabled, + PCLSwitchDef_s *commandLineSwitches, + NSSRegistrationCallBacks_s *callBacks) +{ + RegisteredNLMs_s *rnlm; + STATUS status; + char moduleVersion[16]; + char ourVersion[16]; +#ifdef __linux__ + BOOL didHelp = FALSE; +#endif + + ASSERT_MPKNSS_LOCK(); + +/*------------------------------------------------------------------------- + * validate that we have a consistent module. + *-------------------------------------------------------------------------*/ + + if (NSS_locateLoadedNLM(moduleName) != NULL) + { + errPrintf(WHERE, Module, 402, + MSG("The module name \"%s\" is already in use",184), moduleName); + status = zERR_MODULE_NAME_ALREADY_USED; + goto errorCleanup; + } + if ((versionInfo->majorVersion != NSS_VersionInfo.majorVersion) || + (versionInfo->minorVersion != NSS_VersionInfo.minorVersion) || + (versionInfo->subVersion != NSS_VersionInfo.subVersion)) + { + errPrintf(WHERE, Module, 403, + MSG("The module \"%s\" has an invalid version " + "number of %s. It should be %s.\n" + "Load the version displayed on the screen.",185), + moduleName, + FormatVersionString(versionInfo,moduleVersion), + FormatVersionString( &NSS_VersionInfo,ourVersion)); + + status = zERR_INVALID_MODULE_VERSION; + goto errorCleanup; + } + if (APIVersion != NSSAPI_VERSION) + { + errPrintf(WHERE, Module, 404, + MSG("The module \"%s\" has an incompatible API " + "version number of %d. It should be %d.\n" + "Load the version displayed on the screen.",186), + moduleName, + APIVersion,NSSAPI_VERSION); + + status = zERR_INVALID_MODULE_VERSION; + goto errorCleanup; + } + if (snapDate != NSS_SNAPDATE) + { + errPrintf(WHERE, Module, 404, + MSG("The module \"%s\" has an incompatible snap date of %x.\n" + "It should be %x. You have a mismatched set of NSS NLMs.\n" + "Please load the correct set of NLMs.",187), + moduleName, + snapDate,NSS_SNAPDATE); + + status = zERR_INVALID_MODULE_VERSION; + goto errorCleanup; + } + if (debugEnabled != NSS_DEBUG_STATE) + { + errPrintf(WHERE, Module, 405, + MSG("The module \"%s\" has an incompatible DEBUG " + "STATE of %s. It should be %s.",188), + moduleName, + (debugEnabled ? MSG("Enabled",189) : MSG("Disabled",190)), + (NSS_DEBUG_STATE ? MSG("Enabled",191) : MSG("Disabled",192))); + + status = zERR_INCOMPATIBLE_DEBUG_STATE; + goto errorCleanup; + } + if (mpEnabled != NSS_MP_FLAG) + { + errPrintf(WHERE, Module, 405, + MSG("The module \"%s\" has an incompatible MP FLAG " + "of %s. It should be %s.",113), + moduleName, + (mpEnabled ? MSG("MP Enabled",114) : MSG("MP Disabled",115)), + (NSS_MP_FLAG ? MSG("MP Enabled",116) : MSG("MP Disabled",117))); + + status = zERR_INCOMPATIBLE_MP_FLAG; + goto errorCleanup; + } +/*------------------------------------------------------------------------- + * When we get here, we know it is a compatible module. + *-------------------------------------------------------------------------*/ + rnlm = zalloc(sizeof(RegisteredNLMs_s)); + if (rnlm == NULL) + { + status = zERR_NO_MEMORY; + goto errorCleanup; + } + + strmcpy(rnlm->moduleName, moduleName, sizeof(rnlm->moduleName)); + rnlm->moduleHandle = moduleHandle; + rnlm->moduleType = moduleType; + rnlm->messageTable = messageTable; + rnlm->registrationFlags = registrationFlags; + rnlm->versionInfo = *versionInfo; + rnlm->APIVersion = APIVersion; + rnlm->snapDate = snapDate; + rnlm->debugEnabled = debugEnabled; + rnlm->commandLineSwitches = commandLineSwitches; + rnlm->callBacks = *callBacks; +/*------------------------------------------------------------------------- + * validate the MODULE TYPE + *-------------------------------------------------------------------------*/ + switch (moduleType) + { + case NSSMODULETYPE_COMMON: + case NSSMODULETYPE_LSS: + case NSSMODULETYPE_SEMANTIC_AGENT: + case NSSMODULETYPE_NAMESPACE: + case NSSMODULETYPE_PROVIDER: + case NSSMODULETYPE_MENU: + case NSSMODULETYPE_DFS: + + break; + default: + errPrintf(WHERE, Module, 406, + MSG("The module \"%s\" has an unknown module type of %d.\n" + "An incorrect NLM has been loaded. Load the correct NLM from the CD.",193), + moduleType); + + status = zERR_UNKNOWN_MODULE_TYPE; + goto errorCleanupAndFree; + } + +/*------------------------------------------------------------------------- + * Check to see if set parms need to be registered + *-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_SetParms + if (commandLineSwitches != NULL) + LB_RegisterSetParmsForNSS(commandLineSwitches, messageTable); +#endif +/*------------------------------------------------------------------------- + * If they load after STARTUP has completed, then go ahead and init them + * now. If not, then we will init all of them later. + *-------------------------------------------------------------------------*/ + if (NSS_StartupCompleted) + { +#if zLINUX + if ((status = LB_ParseCmdline(commandLineSwitches, + POPT_AT_STARTUP|POPT_NO_UNKNOWN_SWITCH_ERRORS|POPT_NO_PARSE_TIME_ERRORS, + NSS_CommandLine, &didHelp)) != zOK) + { + aprintf(LRED, MSGNot("Error parsing commandLine\n")); + goto errorCleanupAndFree; + } +#endif + status = rnlm->callBacks.startup(); + if (status != zOK) + { + aprintf(LRED, + + MSG(" NSS-2.70-50: The module \"%s\" failed to initialize, status=%d.\r\n" + " You do not have enough memory or your memory is bad.\r\n" + " Check to see if your resources are bad.\n",194), + moduleName, status); + goto errorCleanupAndFree; + } + +// if (SYSAvailabilityIsChecked == FALSE) +// { +// CheckAndRegisterSYSVolEvent(); +// } + + if (PublicsIsResolved == FALSE) + { + ResolvePublics(); + if (PublicsIsResolved) + { + /* startup every module which hasn't been started up */ + if (DQ_NOT_EMPTY(&RegisteredNLMsList)) + { + RegisteredNLMs_s *pnlm; + + DQ_FOREACH(&RegisteredNLMsList, pnlm, RegisteredNLMs_s, link) + { + NSS_addMgmtFile(pnlm); + } + } + } + } + + if (PublicsIsResolved) + { + NSS_addMgmtFile(rnlm); + } + } + +/*------------------------------------------------------------------------- + * Link the module into the list. + *-------------------------------------------------------------------------*/ + DQ_ENQ(&RegisteredNLMsList,rnlm,link); /* add to linked list */ + LastRegisteredNLMstatus = zOK; + +/*------------------------------------------------------------------------- + * The module is now running, parse the command line again to look for + * commands that can only be executed while running + *-------------------------------------------------------------------------*/ + +#if zLINUX + LB_ParseCmdline(commandLineSwitches, POPT_AT_RUNTIME|POPT_NO_UNKNOWN_SWITCH_ERRORS|POPT_NO_PARSE_TIME_ERRORS, + NSS_CommandLine, &didHelp); +#endif + + return zOK; + +/*========================================================================= + * Error handling + *=========================================================================*/ +errorCleanupAndFree: +#ifndef __linux__ // LINUX_SetParms + if (commandLineSwitches != NULL) + LB_UnRegisterSetParmsForNSS(commandLineSwitches); +#endif + free(rnlm); + +errorCleanup: + /*LastRegisteredNLMwasRequired = (registrationFlags & NSSREGFLAG_REQUIRED); */ + LastRegisteredNLMstatus = status; + + return status; +} + + + +/************************************************************************** + * This is called to inform NSS that an EXTERNAL NLM is unloading. This + * must be the last thing called before the NLM unloaded. It is assumed + * that all other NSS cleanup has already been performed by the given + * NLM. + ***************************************************************************/ +STATUS NSS_UnRegisterExternalNLM( + char *moduleName) +{ + RegisteredNLMs_s *rnlm; + + ASSERT_MPKNSS_LOCK(); + rnlm = NSS_locateLoadedNLM(moduleName); + if (rnlm == NULL) + { + return zERR_MODULE_NAME_NOT_FOUND; + } + + /* Unregister any set parms */ +#ifndef __linux__ // LINUX_SetParms + if (rnlm->commandLineSwitches) + LB_UnRegisterSetParmsForNSS(rnlm->commandLineSwitches); +#endif + + /* before unload it, we delete those management files belong to it */ + NSS_removeMgmtFile(rnlm); + + DQ_RMV(rnlm,link); + free(rnlm); + return zOK; +} diff --git a/src/nwnss/nss/nssStartup.c b/src/nwnss/nss/nssStartup.c new file mode 100644 index 0000000..9282e4e --- /dev/null +++ b/src/nwnss/nss/nssStartup.c @@ -0,0 +1,713 @@ +/**************************************************************************** + | + | (C) Copyright 1995-2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2007-09-08 04:18:02 +0530 (Sat, 08 Sep 2007) $ + | + | $RCSfile$ + | $Revision: 2193 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | + +-------------------------------------------------------------------------*/ +#include /* netware */ +#include +#include +#include +#include +#include +#include +#include + +#include /* Library */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nssStartup.h" +#include "nssOSAPIs.h" +#include "nssPubs.h" +#include "zError.h" +#include "comnPublics.h" +#include "nssErrorTable.h" +#include "utc.h" +#include "dfi.h" +#include "snp.h" +#include "dbgView.h" +#include "sdNSS.h" +#include "xmlTags.h" +#include "nssLog.h" +#include "napi.h" + +/*------------------------------------------------------------------------- + * Global variables - Development Test variables + *-------------------------------------------------------------------------*/ +BOOL NSS_StartupCompleted = FALSE; +BOOL NSS_SkipLoadModules = FALSE; + +/*------------------------------------------------------------------------- + * Global variables + *-------------------------------------------------------------------------*/ + +NEBEventInfo_s startupEvent; +LONG NSS_ServerDownEventID = 0; +BOOL ShutdownNSS = FALSE; /* set to TRUE when the server is shutdown */ + +#define NSS_SetParm_Category MSGNot("Novell Storage Services") + + +DFI_CallerOptions_s *NSSCo; /* Key for use with structure display APIs */ +char NSSCoBuffer[128*1024]; /* Buffer for NSSCoPrintBuffer below */ +SNP_PrintBuffer_s NSSCoPrintBuffer; /* Fixed sized SNP buffer used by + * debug =view command. Fixed + * size so we do not have to alloc + * within the debugger. + */ + + +/* all variables that have the hard coded name for the admin vol are here */ +unicode_t *AdminVolUnicodeName = AVOL_ADMIN_VOLUME_UNICODE; +unicode_t *PersistAdminVolUnicodeName = AVOL_PERSISTENT_ADMIN_VOLUME_UNICODE; +BYTE *AdminVolAsciiName = AVOL_ADMIN_VOLUME; +NINT AdminVolNameLen = 0; +BYTE AVFileMgmtDir[MAX_MGMTDIR_LEN]; /* All NSS management files are under this directory */ +NINT AVFileMgmtDirLen = 0; +BYTE AVFileOSMgmtDir[MAX_MGMTDIR_LEN]; /* All OS management files are under this directory */ +NINT AVFileOSMgmtDirLen = 0; + +/* + * zCONNECTION_ZERO_USERID must be the lowest numbered GUID possible + * because it is expected to be in the first slot of an effective ACL. + * This is for efficiency in computing rights in the ZAS auth model. + */ +GUID_t zSECURE_CONNECTION_USERID = {0,0,0,0,0, {0,0,0,0,0,1} }; +GUID_t zANYONE_USERID = {2,0,0,0,0, {0,0,0,0,0,0} }; +GUID_t zSUPERVISOR_USERID = {3,0,0,0,0, {0,0,0,0,0,0} }; +GUID_t zTREENAME_ID = {999,0,0,0,0, {0,0,0,0,0,0} }; + +void UnregisterAsProducerForNSSStartup(void) +{ + ZOS_UnRegisterProducer((struct ProducerInfo *)startupEvent.producerID, + (void *)NULL); +} + +STATUS RegisterAsProducerForNSSStartup(void) +{ + struct ProducerRegistrationInfo reg; + LONG status; + ASSERT_MPKNSS_LOCK(); + reg.PRIVersion = NEB_PRODUCER_VERSION1; + reg.PRIProducerName = MSGNot("NSS"); + reg.PRIEventName = MSGNot("NSS.StartupCompleted"); + reg.PRIUserParameter = (void *)NULL; + reg.PRIEventFlags = 0; + reg.PRIOwnerID = NSS_ModuleHandle; + reg.PRIProducerESR = NULL; + reg.PRISecurityToken = 0; + reg.PRIProducerFlags = 0; + reg.PRIPriority = 0; + ZOS_RegisterProducer(status, ®); + if ( status != 0 ) + { + errPrintf(WHERE, Module, 407, + MSG("Unable to register as NSS.StartupCompleted event producer.\n" + "No Event will be sent when NSS Startup is complete.", 123)); + return zFAILURE; + } + startupEvent.producerID = (NINT)reg.PRIProducerID; + startupEvent.eventID = (NINT)reg.PRIEventID; + return zOK; +} + +CommandViewInfo_s CommandViewInfoNSS; + +/************************************************************************** + * This function takes an XML with "add trustee" info and passes it on to + * the _admin file that will add a trustee. + ***************************************************************************/ +void NSS_AddTrustee( + Key_t rootKey, + utf8_t *xml) +{ + #define XML_BUFFER_SIZE 4096 + #define MAX_XML_RETRIES 20 /*200*/ + Key_t fileKey; + utf8_t *buffer; + NINT len; + STATUS status; + XML_ElementInfo_s addTrusteeElement; + XML_ElementInfo_s resultElement; + XML_ElementInfo_s descriptionElement; + NINT error; + NINT retryCount; + BYTE path[zMAX_FULL_NAME]; + + buffer = malloc(XML_BUFFER_SIZE); + if (buffer == NULL) + { + aprintf(LRED, MSG("Cannot allocate memory to send add trustee request when adding special trustees.\n", 158)); + return; + } + + /* Set up :\files.cmd */ + strcpy(path, AVFileMgmtDir); + strcat(path, MSGNot("files.cmd")); + + if ((status = (*zOpenPtr)(rootKey, zNSS_TASK, zNSPACE_LONG | zMODE_UTF8, + path, zRR_READ_ACCESS | zRR_WRITE_ACCESS, &fileKey)) != zOK) + { + aprintf(LRED, MSG("Error %d opening _admin file to add special trustees\n", 164), status); + printk(KERN_WARNING MSG("Error %d opening _admin file to add special trustees\n", 164), status); + goto exit; + } + + for (retryCount = 0; retryCount < MAX_XML_RETRIES; retryCount++) + { + strcpy(buffer, MSGNot("")); + strcat(buffer, MSGNot("<"TAG_FILEREQUEST"><"TAG_TRUSTEES"><"TAG_ADDTRUSTEE">")); + strcat(buffer, xml); + strcat(buffer,MSGNot("")); + +//aprintf(LCYAN, "command xml:%s\n", buffer); + if ((*zWritePtr)(fileKey, 0, 0, strlen(buffer), buffer, &len) != zOK) + { + aprintf(LRED, MSG("Error writing to _admin file to add special trustees\n", 165)); + printk(KERN_WARNING MSG("Error writing to _admin file to add special trustees\n", 165)); + goto exitClose; + } + if ((*zReadPtr)(fileKey, 0, 0, XML_BUFFER_SIZE, buffer, &len) != zOK) + { + aprintf(LRED, MSG("Error reading from _admin file while adding special trustees\n", 166)); + printk(KERN_WARNING MSG("Error reading from _admin file while adding special trustees\n", 166)); + goto exitClose; + } + +//*(buffer+len) = 0; +//aprintf(LGREEN, "return xml:%s\n", buffer); + if (XML_GetTagElement(TAG_ADDTRUSTEE, buffer, buffer + len - 1, + &addTrusteeElement) != zOK) + { + aprintf(LRED, MSG("Could not find tag in add trustee reply\n", 167)); + printk(KERN_WARNING MSG("Could not find tag in add trustee reply\n", 167)); + goto exitClose; + } + + if (XML_GetTagElement(TAG_RESULT, addTrusteeElement.dataStart, + addTrusteeElement.dataEnd, &resultElement) != zOK) + { + aprintf(LRED, MSG("Could not find tag in add trustee reply\n", 168)); + printk(KERN_WARNING MSG("Could not find tag in add trustee reply\n", 168)); + goto exitClose; + } + + if (XML_GetTagAttribute(ATR_VALUE, &resultElement) != zOK) + { + aprintf(LRED, MSG("Could not find error attribute in add trustee reply\n", 169)); + printk(KERN_WARNING MSG("Could not find error attribute in add trustee reply\n", 169)); + goto exitClose; + } + + *(resultElement.attributeValueEnd + 1) = '\0'; + error = atoi(resultElement.attributeValueStart); +//aprintf(YELLOW, "Special trustee add -- error=%d count=%d\n", error, retryCount); + if (error == 0 || error == ERR_NO_SUCH_ENTRY || + error == ERR_ALL_REFERRALS_FAILED || ShutdownNSS) + { + break; + } + MPKNSS_LOCK(); + LB_delay(5 * 1000); + MPKNSS_UNLOCK(); + } + + if (error) + { + if (error == ERR_NO_SUCH_ENTRY) + { + XML_GetTagElement(TAG_NAME, xml, xml + strlen(xml) - 1, + &descriptionElement); + *(descriptionElement.dataEnd + 1) = '\0'; + aprintf(LRED, MSG("Trustee name %s not found during special trustee add\n", 170), + descriptionElement.dataStart); + printk(KERN_WARNING MSG("Trustee name %s not found during special trustee add\n", 170), + descriptionElement.dataStart); + } + else + { + if (XML_GetTagElement(TAG_DESCRIPTION, resultElement.dataStart, + resultElement.dataEnd, &descriptionElement) != zOK) + { + aprintf(LRED, MSG("Could not find tag in add trustee reply\n", 171)); + goto exitClose; + } + *(descriptionElement.dataEnd + 1) = '\0'; + aprintf(LRED, MSG("Error adding special trustees: %d(%s)\n", 172), error, + descriptionElement.dataStart); + printk(KERN_WARNING MSG("Error adding special trustees: %d(%s)\n", 172), error, + descriptionElement.dataStart); + } + } +exitClose: + (*zClosePtr)(fileKey); +exit: + free(buffer); +} + +/************************************************************************** + * Add trustees to the files specified in the special trustee file. + ***************************************************************************/ +void NSS_AddSpecialTrustees() +{ + Key_t rootKey; + BYTE *buf; + STATUS status; + NINT len; + utf8_t *tagName; + utf8_t *searchStart; + NINT tagLen; + LONG fileSize; + XML_ElementInfo_s mainElement; + XML_ElementInfo_s actionElement; + int fd; +#define TRUSTEE_FILE_NAME "sys:\\etc\\trustees.xml" +#define LNX_TRUSTEE_FILE_NAME "/etc/opt/novell/nss/trustees.xml" + MPKNSS_UNLOCK(); + + if ((*zRootKeyPtr)(0, &rootKey) != zOK) + { + zASSERT("Error getting root key for special trustee file" == NULL); + MPKNSS_LOCK(); + return; + } + + /* + * Open config file and find the size. The size is used + * to create a buffer large enough to hold the whole file + */ + fileSize = 0; + fd = mpkOpen(LNX_TRUSTEE_FILE_NAME, O_RDONLY, 0); + if (fd != -1) + { + char tmpBuf[128]; + while ( (len = mpkRead(fd, tmpBuf, 128)) > 0 ) + { + fileSize+=len; + } + mpkClose(fd); + } + else + { + printk(KERN_WARNING "Unable to open: %s \n",LNX_TRUSTEE_FILE_NAME); + goto exit; + } + + + /* + * Now allocate buffer big enough to read file + * then read file into buffer + * mark end of buffer with a 0 + */ + fileSize++; + len = 0; + buf = malloc(fileSize); + if (buf != NULL) + { + printk(KERN_INFO "Opening trustee file: %s\n",LNX_TRUSTEE_FILE_NAME); + fd = mpkOpen(LNX_TRUSTEE_FILE_NAME, O_RDONLY, 0); + if (fd == -1) + { + printk(KERN_WARNING "Unable to open: %s\n",LNX_TRUSTEE_FILE_NAME); + free(buf); + goto exit; + } + else + { + len = mpkRead(fd, buf, fileSize); + if (len !=0 ) + { + *(buf+len) = 0; + } + } + } + if ((status = XML_GetTagElement(TAG_SPECIALTRUSTEES, buf, buf + len - 1, + &mainElement)) != zOK) + { + aprintf(LRED, "Could not find tag in special trustee file\n"); + printk(KERN_WARNING "Could not find tag in special trustee file\n"); + zASSERT("Could not find " == NULL); + goto exitFree; + } + + searchStart = mainElement.dataStart; + for(;;) + { + if (XML_GetNextTag(searchStart, mainElement.dataEnd, + &actionElement, &tagName, &tagLen) != zOK) + { + break; /* we have all of the elements */ + } + searchStart = actionElement.elementEnd + 1; + if (memcmp(tagName, TAG_ADDTRUSTEE, tagLen) != 0) + { + aprintf(LRED, MSG("Found a bad tag in the special trustee file: %s\n", 173), + tagName); + printk(KERN_WARNING MSG("Found a bad tag in the special trustee file: %s\n", 173), + tagName); + continue; + } + *(actionElement.dataEnd + 1) = '\0'; +//aprintf(YELLOW, "xml to send:%s\n", actionElement.dataStart); + NSS_AddTrustee(rootKey, actionElement.dataStart); + } + +exitFree: + free(buf); + mpkClose(fd); +exit: + (*zClosePtr)(rootKey); + MPKNSS_LOCK(); + return; +} + +/************************************************************************** + * Thread to add trustees to the files specified in the special trustee file. + ***************************************************************************/ +void NSS_AddSpecialTrusteesThread( + FsmLite_s *fsm, + NINT *dummy) +{ + if (!ShutdownNSS) + { + int i; + BOOL found = FALSE; + + for (i = 0; i < (5 * 60 * 60) / 10; i++) + { + if (ImportNSSPublics() == zOK) + { + found = TRUE; + break; + } + LB_delay(10*1000); + } + if (found) + { + NSS_AddSpecialTrustees(); + UnimportNSSPublics(); + } + else + { + aprintf(LRED, MSG("Unable to import symbols to set special trustees\n", 174)); + } + } + free (fsm); +} +EXPORT_SYMBOL(NSS_AddSpecialTrusteesThread); + +/************************************************************************** + * This is the actual NSS global startup routine. This is called as an + * event which allows us to LOAD other NLMs. + ***************************************************************************/ +void NSSGlobal_Startup(void) +{ + struct EventBlock evblk; + STATUS eventStatus; + LONG result; +#if NSS_DEBUG IS_ENABLED + STATIC NINT fsmInstance = 0; +#endif + BOOL didHelp = FALSE; + + MPKNSS_LOCK(); + ASSERT_MPKNSS_LOCK(); + Enable(); /* Because interrupts come in masked*/ +/*------------------------------------------------------------------------- + * Remove our event notification because we only want to get ourselves. + *-------------------------------------------------------------------------*/ + + NSSLOG_Startup(); + +/*------------------------------------------------------------------------- + * Get initial resource tags and register with libraries + *-------------------------------------------------------------------------*/ + if (COMN_RegisterLibraryOwner( + MSGNot("NSS"), + &NSS_VersionInfo) != zOK) + { + goto REGISTER_LIBRARY_Failed; + } +/*------------------------------------------------------------------------- + * setup commands for the NetWare debugger + *-------------------------------------------------------------------------*/ + + + (void)SNP_Construct1( WHERE, &NSSCoPrintBuffer, NSSCoBuffer, sizeof( NSSCoBuffer ), NULL ); + /* We include DCO_DETAILS_TYPE in default open so that the wildcard matches on TYPES work */ + NSSCo = DFI_Open( &NSSCoPrintBuffer, &NSSCoPrintBuffer, DCO_OUTPUT_TYPE_XML, DCO_DETAILS_TYPE|DCO_DETAILS_NAME|DCO_DETAILS_VALUE|DCO_DETAILS_INDEX, 0, 0, 0, 0 ); + /* Register that we ASSEMBLY DEBUGGER structures + * that can be displayed. + */ + CommandViewInfoNSS.CVI_OwnerName = "NSS"; + CommandViewInfoNSS.CVI_Table = SDM_TableNSS; + DBG_CV_Register( &CommandViewInfoNSS ); + +/*------------------------------------------------------------------------- + * Initialize UNICODE + *-------------------------------------------------------------------------*/ + if (LB_UnicodeStartup() != zOK) + { + // zASSERT("UNICODE FAILED" == NULL); + + goto UNICODE_Failed; + } + // zASSERT("UNICODE SUCCESS" == NULL); + + +/*------------------------------------------------------------------------- + * Initialize NetWare SYSTEM imports. + *-------------------------------------------------------------------------*/ + if (LB_InitializeSystemImports() != zOK) + { + goto SYSIMPORTS_Failed; + } + +/*------------------------------------------------------------------------- + * Parse the command line, If they did a HELP command, then terminate now. + *-------------------------------------------------------------------------*/ + if ((NSS_ParseFirstStartupCmdline(NSS_CommandLine,&didHelp) != zOK) || didHelp) + { + // Defect: 307803 - system hangs if an invalid command line + // is in the nssstart.cfg file. To recover, required using + // rescue media. By commenting out this goto, the error is + // not flagged at this point. It does limit how much of NSS + // comes up but does not hang the system. You can even use + // nsscon to look at the error generated from the bad command. + //goto PARSE_COMMANDLINE_Failed; + } +/*------------------------------------------------------------------------- + * Register to produce the NSS startup completed event + *-------------------------------------------------------------------------*/ + eventStatus = RegisterAsProducerForNSSStartup(); + +/*------------------------------------------------------------------------- + * Now start initing the different systems. + *-------------------------------------------------------------------------*/ +#if NSS_DEBUG IS_ENABLED + DBG_Startup(); +#endif + + if (NSS_CommandLineStartup() != zOK) + goto COMMANDLINE_Failed; + + LB_MEMORY_DISPLAY_SETUP(); + +#if NSS_DEBUG IS_ENABLED + /* Check that we do not have out of order or + * duplicate zERR_. If some one wishes to have a + * dup number then they can add code here to + * exclude that errno as an error below. + */ + { + NINT i; + + for (i = 1; ErrorTable[i].number != 0; i++) + { + if (ErrorTable[i-1].number >= ErrorTable[i].number) + { + aprintf(LRED, MSGNot("Out of order zERR_ defines\n %s(%d) and %s(%d)"), + ErrorTable[i-1].define, + ErrorTable[i-1].number, + ErrorTable[i].define, + ErrorTable[i].number ); + zASSERT("Someone needs to fix the above problem"==NULL); + } + } + } +#endif + +/*------------------------------------------------------------------------- + * Set up the admin volume names + *-------------------------------------------------------------------------*/ + AdminVolNameLen = strlen(AdminVolAsciiName); + + strcpy(AVFileMgmtDir, AVOL_MANGEMENT_PATH); + AVFileMgmtDirLen = strlen(AVFileMgmtDir); + zASSERT(AVFileMgmtDirLen < MAX_MGMTDIR_LEN); + + strcpy(AVFileOSMgmtDir, AVOL_OS_MANGEMENT_PATH); + AVFileOSMgmtDirLen = strlen(AVFileOSMgmtDir); + zASSERT(AVFileOSMgmtDirLen < MAX_MGMTDIR_LEN); + ZOS_ModuleRegister(RNLM_readFunction); +/*------------------------------------------------------------------------- + * Load the requested NLMs + *-------------------------------------------------------------------------*/ + printf(MSGNot("\n")); + MPKNSS_UNLOCK(); + NSS_doDisplayVersion(); + MPKNSS_LOCK(); + aprintf(YELLOW, MSG("\nFor help enter \"" "NSS" " help\" on the command line.\n\n", 125)); + + if (eventStatus == zOK) + { + evblk.EBVersion = NEB_EVENT_VERSION1; + evblk.EBStamp = EVENT_BLOCK_STAMP; + evblk.EBRTag = COMN_Resource.eventBlkRTag; + evblk.EBProducerID = (void *)startupEvent.producerID; + evblk.EBUserParameter = (void *)startupEvent.eventID; + evblk.EBEventData = (void *)NULL; + + ZOS_ProduceEvent(result,&evblk); + } + + NSS_StartupCompleted = TRUE; + +/*------------------------------------------------------------------- + * Now that we are done, re-parse the command line and make sure we + * account for all of the switches. + *-----------------------------------------------------------------*/ + NSS_ParseFinishStartupCmdline(NSS_CommandLine,&didHelp); + + +#ifdef FDAT_UNIT_TEST + FDAT_UnitTest(); +#endif + + MPKNSS_UNLOCK(); + return; + +/*========================================================================= + * Error handling + *=========================================================================*/ + /*NSS_UnloadNLMs();*/ + + +COMMANDLINE_Failed: +#if NSS_DEBUG IS_ENABLED + DBG_Shutdown(); + DBG_UninitDebug(); +#endif + UnregisterAsProducerForNSSStartup(); + +//PARSE_COMMANDLINE_Failed: + LB_UninitializeSystemImports(); + +SYSIMPORTS_Failed: + LB_UnicodeShutdown(); + +UNICODE_Failed: + DBG_CV_Unregister( &CommandViewInfoNSS ); + if ( NSSCo != NULL ) + { + (void)DFI_Close( NSSCo ); + } + + COMN_UnregisterLibraryOwner(); + +REGISTER_LIBRARY_Failed: + NSSLOG_Shutdown(); + LB_exitMyselfAndReturn(NSS_ModuleHandle,0); /* unloads this NLM */ + MPKNSS_UNLOCK(); + return; +} + + +/************************************************************************** + * uninitialize all global data and return all resources + ***************************************************************************/ +void NSSGlobal_Shutdown(void) +{ + + ASSERT_MPKNSS_LOCK(); + + if (NSS_StartupCompleted) + { + + if (NSS_UnloadModuleFailEventID != 0) + { + } + else + { + NSS_CommandLineShutdown(); + } + ZOS_ModuleUnregister(RNLM_readFunction); + UnregisterAsProducerForNSSStartup(); + + LB_UninitializeSystemImports(); + LB_UnicodeShutdown(); + + DBG_CV_Unregister( &CommandViewInfoNSS ); + if ( NSSCo != NULL ) + { + (void)DFI_Close( NSSCo ); + } +#if NSS_DEBUG IS_ENABLED + DBG_Shutdown(); + DBG_UninitDebug(); +#endif + NSSLOG_Shutdown(); + NSS_StartupCompleted = FALSE; /* flag not inited */ + OutputToScreenWithAttribute(NSS_DefaultScreen,CYAN,MSGNot("NSS:")); + OutputToScreenWithAttribute(NSS_DefaultScreen,CYAN,MSG(" Disabled\n", 140)); + ShutdownNSS = TRUE; + } + +} + +/************************************************************************** + * NSS_IgnoreTimeZone + ***************************************************************************/ +void NSS_ResetTimeCaches() +{ + MPKNSS_LOCK(); + ResetTimeCache = -1; /* reset all caches */ + + /* Force the cache status to be evaluated */ + if (BEASTHASH_InvalidateDOSTimesPtr) + { + (*BEASTHASH_InvalidateDOSTimesPtr)(); + } + UTC2dosTime(1000); + UTC2Sec2000Time(1000); + DOS2utcTime(1000); + Sec20002utcTime(1000); + MPKNSS_UNLOCK(); +} + +/************************************************************************** + * NSS_IgnoreTimeZone + ***************************************************************************/ +void NSS_SetIgnoreTimeZone( + BOOL ignore) +{ + IgnoreTimeZone = ignore; + NSS_ResetTimeCaches(); +} diff --git a/src/nwnss/nss/nssStartup.h b/src/nwnss/nss/nssStartup.h new file mode 100644 index 0000000..e92802d --- /dev/null +++ b/src/nwnss/nss/nssStartup.h @@ -0,0 +1,190 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $ + | + | $RCSfile$ + | $Revision: 1325 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This defines globals and prototypes for the initialization. + +-------------------------------------------------------------------------*/ +#ifndef _NSSSTARTUP_H_ +#define _NSSSTARTUP_H_ + +#ifndef _QUE_H_ +# include +#endif + +#ifndef _DISPLAYVERSION_H_ +# include +#endif + +#ifndef _NSSREGISTRATION_H_ +# include +#endif + +/*------------------------------------------------------------------------- + * Global defines + *-------------------------------------------------------------------------*/ +#define MODULE_NAME MSGNot("NSS") +extern const char Module[]; + + + +/*------------------------------------------------------------------------- + * Structure used to TRACK all of the loaded modules + *-------------------------------------------------------------------------*/ +typedef struct RegisteredNLMs_s +{ + DQlink_t link; + /* parameter from NSS_RegisterExternalNLM */ + char moduleName[64]; + void *moduleHandle; + NINT moduleType; + char **messageTable; /* this may be NULL */ + NINT registrationFlags; + NINT registrationState; + VersionInformation_s versionInfo; + NINT APIVersion; + NINT snapDate; + NINT debugEnabled; + struct PCLSwitchDef_s *commandLineSwitches; + NSSRegistrationCallBacks_s callBacks; +} RegisteredNLMs_s; + +/*------------------------------------------------------------------------- + * This defines module STATE flags + *-------------------------------------------------------------------------*/ +#define NSSREGSTATE_ACTIVATED 0x00000001 /* if SET, this module was + * successfully started ACTIVATED */ +#define NSSREGSTATE_SERVERDOWNED 0x00000002 /* if SET, this module has had + * the SERVERDOWN event sent to it*/ +#define NSSREGSTATE_SETPARMSTARTED 0x00000004 /* if SET, this module's cmdline + * set parameter file has been started */ + +/*--------------------------------------------------------------------------- + * Startup variables + *---------------------------------------------------------------------------*/ +extern VersionInformation_s NSS_VersionInfo; + +#if zNETWARE +extern struct LoadDefinitionStructure *NSS_ModuleHandle; +#endif +#if zLINUX +extern void *NSS_ModuleHandle; +#endif +#if zNETWARE +extern struct ScreenStruct *NSS_DefaultScreen; +#endif +#if zLINUX +extern void *NSS_DefaultScreen; +#endif +extern struct ScreenStruct *NSS_ErrorScreen; +extern char NSS_CommandLine[]; + +extern LONG NSS_InitSystemEventID; +extern LONG NSS_UnloadModuleFailEventID; + +extern DQhead_t RegisteredNLMsList; +extern volatile STATUS LastRegisteredNLMstatus; +//extern volatile RegisteredNLMs_s *LastRegisteredNLM; + +extern BOOL NSS_StartupCompleted; +extern BOOL NSS_SkipLoadModules; +//extern BOOL NSS_SkipActivateModules; + +extern struct PCLSwitchDef_s NSS_CommandLineSwitches[]; + +extern DQhead_t RegNLMMgmtFiles; +/*------------------------------------------------------------------------- + * Initialization + *-------------------------------------------------------------------------*/ +extern void NSSGlobal_Startup(void); +extern void NSSGlobal_Shutdown(void); + +extern void NSS_doDisplayVersion(void); +extern void NSS_doDisplayModules(void); + +//extern STATUS NSS_LoadNLMs(char *nlmname, char *newcmds); +//extern void NSS_UnloadNLMs(char *nlmname); + +extern void NSS_GlobalServerDownHandler(void); + +/*--------------------------------------------------------------------------- + * Command line prototypes + *---------------------------------------------------------------------------*/ +extern STATUS NSS_CommandLineStartup(void); + +extern void NSS_CommandLineShutdown(void); + +extern STATUS NSS_ParseFirstStartupCmdline( + BYTE *commandLine, + BOOL *didHelp); + +extern STATUS NSS_ParseSecondStartupCmdline( + BYTE *commandLine, + BOOL *didHelp); + +extern STATUS NSS_ParseFinishStartupCmdline( + BYTE *commandLine, + BOOL *didHelp); + + +extern BOOL NSS_ValidateSWList(struct PCLSwitchDef_s *checkswdef); + +/*--------------------------------------------------------------------------- + * Registered NLM Modules search prototypes + *---------------------------------------------------------------------------*/ +#ifndef _PARSE_H_ +typedef struct PCLMultiSwitchList_s PCLMultiSwitchList_s; +#endif + +extern void BuildMultiList(struct PCLMultiSwitchList_s *multiList); +extern STATUS findModuleType(NINT moduletype, RegisteredNLMs_s **rnlm); + +/*--------------------------------------------------------------------------- + * Management files stuff + *---------------------------------------------------------------------------*/ +extern BOOL PublicsIsResolved; +#ifdef ADMIN_NSS +//extern BOOL SYSAvailabilityIsChecked; +#endif + +extern void ResolvePublics(); +extern void UnResolvePublics(); + +extern STATUS NSS_addMgmtFile(RegisteredNLMs_s *rnlm); +extern void NSS_removeMgmtFile(RegisteredNLMs_s *rnlm); + +#ifdef ADMIN_NSS +//extern void CheckAndRegisterSYSVolEvent(); +//extern void UnRegisterSYSVolEvent(); +#endif + +#endif /* _NSSSTARTUP_H_ */ diff --git a/src/nwnss/nss/nssVersion.c b/src/nwnss/nss/nssVersion.c new file mode 100644 index 0000000..beba605 --- /dev/null +++ b/src/nwnss/nss/nssVersion.c @@ -0,0 +1,46 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (PSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Holds build number for the given product + +-------------------------------------------------------------------------*/ +#include + +VersionInformation_s NSS_VersionInfo = +{ + ZMAJV, + ZMINV, + ZSUBV, + ZBLDN, + VERINFO_NO_PATENT +}; diff --git a/src/nwnss/nss/setcmd.h b/src/nwnss/nss/setcmd.h new file mode 100644 index 0000000..98a6dd4 --- /dev/null +++ b/src/nwnss/nss/setcmd.h @@ -0,0 +1,102 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | define all of the prototypes and globals for the + | set command infrastructure. + | + | + +-------------------------------------------------------------------------*/ +#ifndef _SETCMD_H_ +#define _SETCMD_H_ + +#ifndef _OMNI_H_ +# include +#endif + + +#include +#include + + +/*- Set Command Parameter Type Defines -*/ +#define NSS_SP_TYPE_NUMBER 0 +#define NSS_SP_TYPE_BOOLEAN 1 +#define NSS_SP_TYPE_TICKS 2 +#define NSS_SP_TYPE_STRING 5 + + +/*- Set Command Flag Defines -*/ +#define NSS_SP_STARTUP_ONLY 0x01 /* Can ONLY be set in startup file */ +#define NSS_SP_HIDE 0x02 /* ??? */ +#define NSS_SP_ADVANCED 0x04 /* ??? */ +#define NSS_SP_STARTUP_OR_LATER 0x08 /* Can be set in startup file */ +#define NSS_SP_NOT_SECURED_CONSOLE 0x10 /* Can't be performed on secured console*/ +#define NSS_SP_RPC_LOCKOUT 0x20 /* Lockout Console RPC from changing value */ + + +/*- Set Command Catagory Defines -*/ +#define NSS_SP_FILE_SYSTEM 4 + + +/*- Type Defs -*/ +typedef struct PSSSetParameterStructure_s +{ + const char *parameterName; + NINT parameterNameMsgNum; + const char *parameterDescription; + NINT parameterDescMsgNum; + void *parameter; + NINT parameterType; + NINT flags; + NINT lowerLimit; + NINT upperLimit; + void (*callBackProcedure)(LONG oldValue); +} PSSSetParameterStructure_s; + + + +/*- prototypes used by setcmd.c -*/ + +extern LONG RegisterSetableParameter (struct SetableParametersStructure *setParameter); +extern LONG DeRegisterSetableParameter (struct SetableParametersStructure *setParameter); + + +/*- prototypes used by the nlm interface -*/ + +void PSSSetCmdUnInit(); +STATUS PSSSetCmdInit(); +void PSSSetCmdDeRegister(PSSSetParameterStructure_s pssSetParameterArray[], NINT numElements); +STATUS PSSSetCmdRegister(PSSSetParameterStructure_s pssSetParameterArray[], NINT numElements); + +#endif /* _SETCMD_H_ */ diff --git a/src/nwnss/nss/setcmd/setcmd.c b/src/nwnss/nss/setcmd/setcmd.c new file mode 100644 index 0000000..cef42b0 --- /dev/null +++ b/src/nwnss/nss/setcmd/setcmd.c @@ -0,0 +1,326 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2007-06-23 03:33:49 +0530 (Sat, 23 Jun 2007) $ + | + | $RCSfile$ + | $Revision: 2068 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | implement the set command infrastructure. + | The following pubic routines are defined: + | PSSSetCmdInit() + | PSSSetCmdUnInit() + | PSSSetCmdRegister() + | PSSSetCmdDeRegister() + | + | The following internal routines are defined: + | PSSSetCmdCleanUpList() + | + | + +-------------------------------------------------------------------------*/ +#ifndef __linux__ // LINUX_SetParms +#include +#include +#include +#include +#include +#include +#include + +#include "setcmd.h" + + +/*- Global vars -*/ +DQhead_t SetCmdList; + + +/*- Type Defs -*/ +typedef struct PSSSetCmdRegistryStructure_s +{ + DQlink_t link; + const char *regParameterName; + struct SetableParametersStructure *regSetParmStruc; +} PSSSetCmdRegistryStructure_s; + + +/*- prototpes used internally -*/ +void PSSSetCmdCleanUpList(DQhead_t *setCmdMiniList); + + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*------------------ START OF ROUTINES ------------------------------------*/ + + +/*- (FUNCTION) ----- PSSSetCmdInit() ----------------------------------- + | + | initialize the Set Command services + | + | + +-------------------------------------------------------------------------*/ +STATUS PSSSetCmdInit() +{ + /**************************************************************** + * check legacy set param defines for compatablility + ****************************************************************/ + + /*______________________________________________________________ + * definitions for set command parameter types + *______________________________________________________________*/ + zASSERT(NSS_SP_TYPE_NUMBER==SP_TYPE_NUMBER); + zASSERT(NSS_SP_TYPE_BOOLEAN==SP_TYPE_BOOLEAN); + zASSERT(NSS_SP_TYPE_TICKS==SP_TYPE_TICKS); + zASSERT(NSS_SP_TYPE_STRING==SP_TYPE_STRING); + + /*______________________________________________________________ + * definitions for set command parameter flags + *______________________________________________________________*/ + zASSERT(NSS_SP_STARTUP_ONLY==SP_STARTUP_ONLY); + zASSERT(NSS_SP_HIDE==SP_HIDE); + zASSERT(NSS_SP_ADVANCED==SP_ADVANCED); + zASSERT(NSS_SP_STARTUP_OR_LATER==SP_STARTUP_OR_LATER); + zASSERT(NSS_SP_NOT_SECURED_CONSOLE==SP_NOT_SECURED_CONSOLE); + zASSERT(NSS_SP_RPC_LOCKOUT==SP_RPC_LOCKOUT); + + DQ_INIT(&SetCmdList); + return(zOK); +} + + + +/*- (FUNCTION) ----- PSSSetCmdUnInit() --------------------------------- + | + | uninitialize the Set Command services + | + +-------------------------------------------------------------------------*/ +void PSSSetCmdUnInit() +{ + PSSSetCmdCleanUpList(&SetCmdList); + return; +} + + + +/*- (FUNCTION) ----- PSSSetCmdCleanUpList() --------------------------------- + | + | internal routine to uninitialize a registry + | used by PSSSetCmdRegistry() + | PSSSetCmdUnInit() + | + +-------------------------------------------------------------------------*/ +void PSSSetCmdCleanUpList(DQhead_t *setCmdMiniList) +{ + LONG result; + PSSSetCmdRegistryStructure_s *setcmd_el; + + /*- remove all set commands from mini list -*/ + DQ_PEEK(setCmdMiniList,setcmd_el,PSSSetCmdRegistryStructure_s, link); + while(setcmd_el != NULL) + { + DQ_DROP(setCmdMiniList /* , setcmd_el, link*/); + + ZOS_DeRegisterSetableParameter(result,setcmd_el->regSetParmStruc); + free(setcmd_el->regSetParmStruc); + free(setcmd_el); + DQ_PEEK(setCmdMiniList, setcmd_el, PSSSetCmdRegistryStructure_s, link); + } + return; +} + + + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*- (FUNCTION) ----- PSSSetCmdRegister() ------------------------------ + | + | register a group of set commands + | + | returns zOK = all registered + | zFAILURE = none registered + | + +-------------------------------------------------------------------------*/ +STATUS PSSSetCmdRegister( + PSSSetParameterStructure_s pssSetParameterArray[], + NINT numElements) +{ + int i; + struct SetableParametersStructure *setCmdParamPtr; + PSSSetCmdRegistryStructure_s *setCmdRegStrucPtr; + DQhead_t miniList; /* mini registry */ + LONG result; + + DQ_INIT(&miniList); /* init the mini registry*/ + + /* for each set command in the array */ + for ( i = 0; i < numElements; i++) + { + /*- allocate a registry struc -*/ + if((setCmdRegStrucPtr = zalloc(sizeof(struct PSSSetCmdRegistryStructure_s))) != NULL) + { + /*- allocate a parameter struc -*/ + if((setCmdParamPtr = zalloc(sizeof(struct SetableParametersStructure))) != NULL) + { +#if NSS_DEBUG IS_ENABLED + PSSSetCmdRegistryStructure_s *registryStrucPtr; + + DQ_FOREACH(&SetCmdList, registryStrucPtr, PSSSetCmdRegistryStructure_s, link) + { + /* is this the one we're looking for? */ + if (stricmp(registryStrucPtr->regParameterName, pssSetParameterArray[i].parameterName)==0) + { + ZOS_DeRegisterSetableParameter(result,registryStrucPtr->regSetParmStruc) + /* yes, deregister to see if we're out of sync */ + if (result!=0) + { + /* its in our list, but not registrered */ + zASSERT( "Set Command Registry Out of Sync during registration" == NULL ); + } + else + { + /* it was already registered */ + ZOS_RegisterSetableParameter(result,registryStrucPtr->regSetParmStruc); + zASSERT( "Already registered this set command" == NULL ); + } + } + } +#endif + + /*- setup the allocated registry struc -*/ + setCmdRegStrucPtr->regSetParmStruc = setCmdParamPtr; + setCmdRegStrucPtr->regParameterName = pssSetParameterArray[i].parameterName; + + /*- setup the parameter struc -*/ + setCmdParamPtr->SPLink = NULL; + setCmdParamPtr->SPParameter = pssSetParameterArray[i].parameter; + setCmdParamPtr->SPResourceTag = COMN_Resource.setCmdRTag; + setCmdParamPtr->SPParameterName = (void *)pssSetParameterArray[i].parameterName; + setCmdParamPtr->SPParameterType = pssSetParameterArray[i].parameterType; + setCmdParamPtr->SPFlags = pssSetParameterArray[i].flags; + setCmdParamPtr->SPCategory = NSS_SP_FILE_SYSTEM; + setCmdParamPtr->SPUnUsed = 0; + setCmdParamPtr->SPLowerLimit = pssSetParameterArray[i].lowerLimit; + setCmdParamPtr->SPUpperLimit = pssSetParameterArray[i].upperLimit; + setCmdParamPtr->SPCallBackProcedure = pssSetParameterArray[i].callBackProcedure; + setCmdParamPtr->SPParameterDescription = (void *)pssSetParameterArray[i].parameterDescription; + setCmdParamPtr->SPParmNameMsgNum = pssSetParameterArray[i].parameterNameMsgNum; + setCmdParamPtr->SPParmDescMsgNum = pssSetParameterArray[i].parameterDescMsgNum; + + ZOS_RegisterSetableParameter(result,setCmdParamPtr); + /*- register the parameter struc withe NetWare -*/ + if(result != 0) + { + /* registration error, free mem and clean up list */ + goto FreeAll; + } + + /*- registered ok, add to the mini registry list -*/ + DQ_ENQ(&miniList, setCmdRegStrucPtr, link); + } + else + { + /* SetableParameterSturcture allocation error */ + goto FreeRegistry; + } + } + else + { + /* PSSSetCmdRegistryStructure allocation error */ + goto CleanUp; + } + } + + /* all set commands in Array registered successfully, */ + /* so we need to append them to main command registry list*/ + DQ_APPEND(&SetCmdList, &miniList); + return(zOK); + +FreeAll: + free(setCmdParamPtr); + +FreeRegistry: + free(setCmdRegStrucPtr); + +CleanUp: + PSSSetCmdCleanUpList(&miniList); + return(zFAILURE); + +} + + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*- (FUNCTION) ----- PSSSetCmdDeRegister() ------------------------------ + | + | deregister a group of set commands + | + | returns zOK or zFAILURE + | + +-------------------------------------------------------------------------*/ +void PSSSetCmdDeRegister( + struct PSSSetParameterStructure_s *pssSetParameterArray, + NINT numElements) +{ + PSSSetCmdRegistryStructure_s *setCmdRegStrucPtr; + int i; + LONG result; + + /* for each set command in the array */ + for ( i = 0; i < numElements; i++ ) + { + DQ_FOREACH(&SetCmdList, setCmdRegStrucPtr, PSSSetCmdRegistryStructure_s, link) + { + /* is this the one we're looking for? */ + if (stricmp(setCmdRegStrucPtr->regParameterName, pssSetParameterArray[i].parameterName)==0) + { + /* yes, deregister and free allocated strucs */ + ZOS_DeRegisterSetableParameter(result,setCmdRegStrucPtr->regSetParmStruc); + free(setCmdRegStrucPtr->regSetParmStruc); + DQ_RMV(setCmdRegStrucPtr, link); + free(setCmdRegStrucPtr); + goto DoNextSetCommand; /* quit looking (next I) */ + } + } + + /* If we get here, we did not find the command in */ + /* our command registry and may be out of sync. */ + /* It's not in our list but if we can deregister it, we're */ + /* out of sync and its a bug! */ +#if NSS_ASSERT IS_ENABLED + ZOS_DeRegisterSetableParameter(result,setCmdRegStrucPtr->regSetParmStruc); +#endif + zASSERT(result!=0); + DoNextSetCommand: /* next I */; + } +} + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +#endif // #ifndef __linux__ // LINUX_SetParms + diff --git a/src/nwnss/nss/trustees.xml b/src/nwnss/nss/trustees.xml new file mode 100644 index 0000000..a602072 --- /dev/null +++ b/src/nwnss/nss/trustees.xml @@ -0,0 +1,23 @@ + + + + [public] + _admin:manage_nss\files.cmd + + + + + + [public] + _admin:manage_nss\user.cmd + + + + + + [public] + _admin:manage_nss\module\nss.xml + + + + \ No newline at end of file diff --git a/src/nwnss/nss/unssNSSSym.c b/src/nwnss/nss/unssNSSSym.c new file mode 100644 index 0000000..5fddc4a --- /dev/null +++ b/src/nwnss/nss/unssNSSSym.c @@ -0,0 +1,44 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export NSS debug symbols to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB + +#include + +#include +#include + +//EXPORT_SYMBOL(DBG_DoNSSDebuggerCommand); diff --git a/src/nwnss/nsslnxlib/Makefile b/src/nwnss/nsslnxlib/Makefile new file mode 100644 index 0000000..2d9d2ea --- /dev/null +++ b/src/nwnss/nsslnxlib/Makefile @@ -0,0 +1,32 @@ +### +### ../nss/public_core/nsslnxlib Makefile +### + +############################################################################## +# +# (C) Copyright 2004 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +BASEDIR=../.. + +SUBDIRS= \ + +include ${BASEDIR}/buildtools/Makefile.default + diff --git a/src/nwnss/nsslnxlib/Module.supported b/src/nwnss/nsslnxlib/Module.supported new file mode 100644 index 0000000..8169d9d --- /dev/null +++ b/src/nwnss/nsslnxlib/Module.supported @@ -0,0 +1 @@ +nsslnxlib.ko diff --git a/src/nwnss/nsslnxlib/allocRTag.c b/src/nwnss/nsslnxlib/allocRTag.c new file mode 100644 index 0000000..467ffc2 --- /dev/null +++ b/src/nwnss/nsslnxlib/allocRTag.c @@ -0,0 +1,62 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Fake an implementation of NetWare resource tags for Linux + +-------------------------------------------------------------------------*/ + +#include + + +struct LoadDefinitionStructure; + +LONG AllocateResourceTag( + struct LoadDefinitionStructure *LoadRecord, + void *ResourceDescriptionString, + LONG ResourceSignature) +{ + static LONG rtag = 0; + + /* Ignore the arguments */ + (void)LoadRecord; + (void)ResourceDescriptionString; + (void)ResourceSignature; + + rtag++; + if (rtag < 1) + { + rtag = 1; + } + + return rtag; +} diff --git a/src/nwnss/nsslnxlib/kfile.c b/src/nwnss/nsslnxlib/kfile.c new file mode 100644 index 0000000..e0a8555 --- /dev/null +++ b/src/nwnss/nsslnxlib/kfile.c @@ -0,0 +1,119 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Definitions for Linux kernel file I/O helpers + +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + + +struct file *kFileOpen(const char * filename, int flags, int mode) +{ + struct file *result = NULL; + mm_segment_t oldfs; + + oldfs = get_fs(); + set_fs(KERNEL_DS); + + result = filp_open(filename, flags, mode); + + set_fs(oldfs); + + return result; +} + + +/* Implementation of a lseek function to handle kernel file I/O without complexity */ +off_t klseek(struct file *filep, off_t offset, unsigned int origin) +{ + if (!filep || !filep->f_op || !filep->f_op->read) + { + return -1; + } + + if (filep->f_op->llseek) + { + filep->f_op->llseek(filep, offset, origin); + } + else + { + /* This only implements absolute seek, at some point add relative seeks */ + if (origin == 0) + { + filep->f_pos = offset; + } + } + + return filep->f_pos; +} + + +/* Implementation of a read function to handle kernel file I/O without complex implementation */ +int kFileRead(struct file *filep, void *buffer, int bufSize) +{ + int bytesRead; + int bytesRem = bufSize; + unsigned char *loc = (unsigned char *)buffer; + mm_segment_t oldfs; + + if (!filep || !filep->f_op || !filep->f_op->read) + { + return -1; + } + + oldfs = get_fs(); + set_fs(KERNEL_DS); + do { + bytesRead = filep->f_op->read(filep, loc, bytesRem, &filep->f_pos); + if (bytesRead > 0) + { + bytesRem -= bytesRead; + loc += bytesRead; + } + } while ((bytesRead > 0) && (bytesRem > 0)); + set_fs(oldfs); + + if ((bytesRem != 0) || (bytesRead < 1)) + { + return -1; + } + + return bufSize; +} + + diff --git a/src/nwnss/nsslnxlib/kfile.h b/src/nwnss/nsslnxlib/kfile.h new file mode 100644 index 0000000..e61fe8a --- /dev/null +++ b/src/nwnss/nsslnxlib/kfile.h @@ -0,0 +1,45 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Declarations for Linux kernel file I/O helpers + +-------------------------------------------------------------------------*/ + +#ifndef __KFILE_H__ +#define __KFILE_H__ + +struct file *kFileOpen(const char * filename, int flags, int mode); +off_t klseek(struct file *filep, off_t offset, unsigned int origin); +int kFileRead(struct file *filep, void *buffer, int bufSize); + +#endif diff --git a/src/nwnss/nsslnxlib/microSecondTimer.c b/src/nwnss/nsslnxlib/microSecondTimer.c new file mode 100644 index 0000000..c3895d6 --- /dev/null +++ b/src/nwnss/nsslnxlib/microSecondTimer.c @@ -0,0 +1,54 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2005-04-23 03:50:19 +0530 (Sat, 23 Apr 2005) $ + | + | $RCSfile$ + | $Revision: 954 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | return a microsecond timer (millionths of a second, 1/1,000,000). + +-------------------------------------------------------------------------*/ + +#include "zOmni.h" +#include + + /* + * We have to do this extra level of indirection because in "procdefs.h", + * GetSuperHighResolutionTimer is defined to return a LONG but it really + * does return a QUAD. So that is how we want to use it. You can just + * use the least significant part by assigning it to a LONG. + * + * THE ABOVE IS NOT TRUE FOR LINUX. + * + * MPK users should use GetSuperHighResolutionTimer. + */ +QUAD microSecondTimer (void) +{ + return GetSuperHighResolutionTimer(); +} diff --git a/src/nwnss/nsslnxlib/nssLnxDummy.c b/src/nwnss/nsslnxlib/nssLnxDummy.c new file mode 100644 index 0000000..2798651 --- /dev/null +++ b/src/nwnss/nsslnxlib/nssLnxDummy.c @@ -0,0 +1,526 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Fake an implementation of NetWare's ... + +-------------------------------------------------------------------------*/ + +#include +#include // For jiffies (timer ticks since boot) I.E. NetWare's CurrentTime global +#include + +#include "omni.h" +#include "linuxmpk.h" + +#include "timer.h" // For TimerDataStructure +#include "nssLnxLib.h" + +void *NMM_Alloc( size_t sizeInBytes, int mpkFlags ); +void NMM_Free( void *uMem ); +LONG SizeOfAllocBlock( void *uMem ); + +// +// FixFixFix(__linux__) - Change PERIODIC_YIELD to Linux specific code +// and then remove fake CurrentTime variable. +// +//volatile LONG CurrentTime = 0x4b771119; + +// +// FixFixFix(__linux__) - Change caching code to Linux specific code +// and then remove fake CurrentNumberOfCacheBuffers variable. +// +//volatile LONG CurrentNumberOfCacheBuffers = 0x1019; MPK has + +// +// FixFixFix(__linux__) - Change caching code to Linux specific code +// and then remove fake NestedInterruptCount variable. If you +// attempt to keep this for some reason it is per-CPU on NetWare. +// +//volatile LONG NestedInterruptCount = 0; MPK has + +// +// FixFixFix(__linux__) - Used by NSS because CurrentTime is broken +// at boot time because the timezone gets added to it. +// +//volatile LONG UpTimeInSeconds = 0x37383738; MPK has implemented + + + +// +// FixFixFix(__linux__) - determine if Linux has a similar feature. +// +void GetClosestSymbol( BYTE *buffer, LONG address ) +{ + + strcpy( buffer, "No GetClosestSymbol in Linux" ); + +} + + + +// +// AllocatePhysicalPages() - +// +// Warning - +// NetWare allows the caller to allocate multiple pages and then free them +// individually. The MPK routines do not support this feature which should NOT +// be an issue as NSS only allocates a page at a time. AllocatePhysicalPages +// will enforce this (a single page) requirement. +// +void *AllocatePhysicalPages( + LONG numberOf4KPages, + LONG sleepOKFlag, + LONG *sleptFlag) +{ + unsigned long size; + int flags; + void *page; + + if ( sleptFlag != NULL ) + { // We do not support this feature because + // 1) NSS does not use. + // 2) MPK does not support. + NSSLinuxStats.NLS_SleptFlagBad1 += 1; + *sleptFlag = FALSE; + return( NULL ); + } +// if ( numberOf4KPages > (ULONG_MAX >> PAGE_SHIFT) ) +// { +// NSSLinuxStats.NLS_NumberOf4KPagesBad1 += 1; +// return( NULL ); +// } + // DeAllocatePhysicalPages assumes that AllocatePhysicalPages is + // limiting the numberOf4KPages of allocates to ONE. + if ( numberOf4KPages > 1 ) + { // FixFixFix(__linux__) For now it is much safer to fail any + // multiple page allocate as it prevents NSS from thinking + // it can free the 1st page of multiple page buffer (Linux will free + // all pages allocated with that page, but NSS will think it still + // owns the pages it did not free!!!). + NSSLinuxStats.NLS_NumberOf4KPagesNot1AllocBad += 1; + return( NULL ); + } + if ( numberOf4KPages == 0 ) + { // mpkPageAlloc does not support 0 so we do (NetWare returns NULL also). + NSSLinuxStats.NLS_NumberOf4KPagesZero1 += 1; + return( NULL ); + } + if ( sleepOKFlag ) + { + NSSLinuxStats.NLS_SleepOKRequests1 += 1; + flags = MPK_SLEEP_OK; + } + else + { + NSSLinuxStats.NLS_SleepNotOKRequests += 1; + flags = MPK_SLEEP_NOT_OK; + } + +#if PAGE_SHIFT != 12 +#error NSS assumes that page size is 4K (i.e. 1 << 12) +#endif + size = numberOf4KPages << PAGE_SHIFT; + NSSLinuxStats.NLS_MPKPageAlloc2 += 1; + page = mpkPageAlloc( size, flags ); + return( page ); + +} /* End of AllocatePhysicalPages() */ + + +// +// DeAllocatePhysicalPages() - +// +// +// FixFixFix(__linux__) +// NSS will not like the fact that we can ONLY free pages that were +// allocated as a unit. Since we allocate one page at a time it forces +// us to free one at a time. +// +void DeAllocatePhysicalPages( + void *memory, + LONG numberOf4KPages) +{ + LONG pagesLeftToFree = numberOf4KPages; + + if ( memory == NULL ) + { + NSSLinuxStats.NLS_NumberOf4KPagesNULL += 1; + return; + } + + if ( numberOf4KPages == 0 ) + { + NSSLinuxStats.NLS_NumberOf4KPagesZero2 += 1; + return; + } + + if ( numberOf4KPages != 1 ) + { // Since we always allocate one we must only free one page at a time. + ++NSSLinuxStats.NLS_NumberOf4KPagesNot1FreeWarning; + } + // Since we force single allocates we should be able to single free by adding 4k to memory and doing multiple frees + do { + NSSLinuxStats.NLS_MPKPageFree2 += 1; + mpkPageFree( memory ); + --pagesLeftToFree; + } while ( pagesLeftToFree != 0 ); + return; +} /* End of DeAllocatePhysicalPages() */ + + +int AllocSleepOKAssumes[ ( sizeof( size_t ) == sizeof( unsigned long ) ) ? 1 : -1 ]; + +void *AllocSleepOK ( + LONG sizeInBytes, + struct ResourceTagStructure *rtag, + LONG *sleptFlag) +{ + void *memory; + + if ( sleptFlag != NULL ) + { // We do not support this feature because + // 1) NSS does not use. + // 2) MPK does not support. +printk("<1>" "NSSLNXLIB::%s[%d]\n", __FILE__, __LINE__ ); + NSSLinuxStats.NLS_SleptFlagBad2 += 1; + *sleptFlag = FALSE; + return( NULL ); + } + +#if 0 + if ( sizeInBytes > ULONG_MAX ) + { + ++NSSLinuxStats.NLS_SizeInBytesBad1; + return( NULL ); + } +#endif + + NSSLinuxStats.NLS_SleepOKRequests1 += 1; + memory = NMM_Alloc( (size_t)sizeInBytes, MPK_SLEEP_OK ); + return( memory ); + +} /* End of AllocSleepOK() */ + + +// +// Free() - +// Free memory that was allocated with AllocSleepOK or Alloc. Must +// not be called with memory allocated via other methods. +// +// Notes +// Legal to free NULL. +// +void Free( + void *address) +{ + + if ( address == NULL ) + { + NSSLinuxStats.NLS_FreeNULL += 1; + return; + } + NMM_Free( address ); + return; + +} /* End of Free() */ + + +int AllocAssumes[ ( sizeof( size_t ) == sizeof( unsigned long ) ) ? 1 : -1 ]; + +// +// +// Warnings - +// Not a full implemenation of NetWare's Alloc(). See alloc.c +// and alloc.h in NetWare for details. In general, NetWare's Alloc() +// operates differently base on the type of 'rtag'. +// +void *Alloc( + LONG sizeInBytes, + struct ResourceTagStructure *rtag ) +{ + void *memory; + +#if 0 + if ( sizeInBytes > ULONG_MAX ) + { + ++NSSLinuxStats.NLS_SizeInBytesBad2; + return( NULL ); + } +#endif + + NSSLinuxStats.NLS_SleepNotOKRequests1 += 1; + memory = NMM_Alloc( (size_t)sizeInBytes, MPK_SLEEP_NOT_OK ); + return( memory ); + +} /* End of Alloc() */ + + + +// +// CScheduleInterruptTimeCallBack() - +// +// +// FixFixFix(__linux__) +// See if Paul is OK with removing this function from NSS and replacing it +// with direct calls to kScheduleCallOut. +// +void CScheduleInterruptTimeCallBack( struct TimerDataStructure *tds ) +{ + ERROR error; + + tds->TDS_mpk.TimeOutValue = tds->TCallBackWaitTime; + tds->TDS_mpk.FunctionArgument = (void *)tds->TCallBackEBXParameter; + tds->TDS_mpk.pFunction = (void *)tds->TCallBackProcedure; + error = kScheduleCallOut( &tds->TDS_mpk ); +// zASSERT(error == kSUCCESS); Can not do ASSERT from nsslnxlib!!! + return; + +} + +/*********************************************************************** + * For the COMN layer + ***********************************************************************/ +// +// FixFixFix(__linux__) - determine if Linux has similar features. +// +LONG GetCurrentTime() +{ // This is good, if callers do not assume there are 18.2 ticks in a second. + // In Linux there are HZ ticks in a second. + return (LONG)jiffies; +} + +void CYieldUntilIdle() +{ + kYieldThread(); +} + +LONG GetHighResolutionTimer() +{ + return jiffies; +} + + + + +// +// NMM - NSS Memory Management +// Linux can not allocate more than 128K via kmalloc (which is what +// mpkAlloc uses). NSS will look at the sizeInBytes of a mmeory allocation +// to determine which allocation routine to call (mpkAlloc or mpkPageAlloc). +// Since these routines to not share a common free routine NSS will need +// to track which routine was used to allocate a chunk of memory. +// + + +// +// NA_Header_s is used to support NetWare's SizeOfAllocBlock under Linux and +// used to determine which free to call (mpkFree or mpkPageFree). +// +// See MKL_Header_s which is used by generic NSS to track who, what +// when and where of allocations (malloc and zalloc). +// +typedef struct NA_Header_s { + LONG NH_Magic; /* Magic to make sure nobody stomped us */ +#define NA_MAGIC 0x4D4D454D /* MMEM */ + LONG NH_Flags; +#define NA_NO_SLEEP 0x00000001 /* Caller can not sleep */ +#define NA_SMALL 0x00000002 +#define NA_BIG 0x00000004 +#define NA_MPK_ALLOC 0x00000010 +#define NA_MPK_PAGE_ALLOC 0x00000020 + LONG NH_ChunkSize; /* Bytes that are in the block (NH_ChunkSize >= NH_Size) */ + LONG NH_Signature; /* At end as more likily to be poked */ +#define NA_SIGN_ALLOC 0x42415858 /* "BAXX" */ +#define NA_SIGN_FREE 0x42465959 /* "BFYY" */ +} NA_Header_s; + + +#define NSS_ALLOC_NEW_SIZE(size) ((size) + sizeof(NA_Header_s)) +#define NA_USER_MEMORY( _sMem ) ((void *)( ((BYTE *)_sMem) + sizeof(NA_Header_s) ) ) +#define NA_OUR_MEMORY( _uMem ) ((NA_Header_s *)( ((BYTE *)_uMem) - sizeof(NA_Header_s) ) ) + +size_t NMM_SwitchSize = (12*1024); /* Size <= to this value will use mpkAlloc(kmalloc) */ + + +// +// NMM_Alloc() - +// Alloc memory. +// +// Notes - +// Uses either mpkAlloc or mpkPageAlloc based on sizeInBytes and +// possibly 'mpkFlags' value. +// +void *NMM_Alloc( size_t sizeInBytes, int mpkFlags ) +{ + NA_Header_s *sMem; + size_t size; + LONG flags; + + if ( sizeInBytes == 0 ) + { + return( NULL ); + } + size = NSS_ALLOC_NEW_SIZE( sizeInBytes ); + if ( size < sizeInBytes ) + { +//printk("<1>" "NSSLNXLIB::%s[%d]\n", __FILE__, __LINE__ ); + return( NULL ); + } + if ( sizeInBytes < NMM_SwitchSize ) + { + flags = NA_SMALL | NA_MPK_ALLOC; + NSSLinuxStats.NLS_MPKAlloc += 1; + sMem = mpkAlloc( size, mpkFlags ); + } + else + { + flags = NA_BIG | NA_MPK_PAGE_ALLOC; + NSSLinuxStats.NLS_MPKPageAlloc += 1; + sMem = mpkPageAlloc( size, mpkFlags ); + } + if ( sMem == NULL ) + { +//printk("<1>" "NSSLNXLIB::%s[%d]\n", __FILE__, __LINE__ ); + return( NULL ); + } + sMem->NH_Flags = flags; + sMem->NH_Magic = NA_MAGIC; + sMem->NH_ChunkSize = size; // TODO: Support the actual size */ + sMem->NH_Signature = NA_SIGN_ALLOC; +//printk("<1>" "NSSLNXLIB::%s[%d]\n", __FILE__, __LINE__ ); + return( NA_USER_MEMORY( sMem ) ); + +} /* End of NMM_Alloc() */ + + +// +// NMM_Free() - +// Frees memory allocated by NMM_Alloc. +// +// Rules - +// Must only be called with an address returned by NMM_Alloc. Must be +// called once and only once for a given non-null address. 'uMem' can be NULL. +// +void NMM_Free( void *uMem ) +{ + NA_Header_s *sMem; + + if ( uMem == NULL ) + { + return; + } + sMem = NA_OUR_MEMORY( uMem ); +// zASSERT( sMem->NH_Signature == NA_SIGN_ALLOC ); + if ( sMem->NH_Signature != NA_SIGN_ALLOC ) + { /* Do not poke memory that does not appear to be allocated */ + return; + } + + if (sMem->NH_Magic != NA_MAGIC) + { + LONG *data; + int i; + + printk("<1> Magic got poked and is 0x%x\n", sMem->NH_Magic); + printk("<1> Chunksize is 0x%x\n", sMem->NH_ChunkSize); + printk("<1> umem = %p, sMem = %p\n", (ADDR)uMem, (ADDR)sMem); + data = (LONG *)((ADDR)sMem & ~((ADDR)0xfff)); + + for (i = 0; i < 1024; i+=4) + { + printk("<1> %p 0x%08x 0x%08x 0x%08x 0x%08x\n", + &data[i], data[i], data[i+1], data[i+2], data[i+3]); + + } + + BUG(); + } + + sMem->NH_Signature = NA_SIGN_FREE; + if ( sMem->NH_Flags & NA_MPK_ALLOC ) + { + NSSLinuxStats.NLS_MPKFree += 1; + mpkFree( sMem ); + } + else if ( sMem->NH_Flags & NA_MPK_PAGE_ALLOC ) + { + NSSLinuxStats.NLS_MPKPageFree += 1; + mpkPageFree( sMem ); + } + else + { + BUG(); + } + +} /* End of NMM_Free() */ + + +// - NetWare Function +// SizeOfAllocBlock() - +// Return that size of the memory that the user could use. This +// is either the requested size (at alloc time) or larger if the memory +// was given out of a fixed size chunk. +// +// Parameters - +// uMem - must be an address returned by NMM_Alloc. +// +// NetWare will tell the caller HOW much memory is in the chunk that +// that was given to the user. This chunk can be BIGGER than the +// amount requested by the user. +// +LONG SizeOfAllocBlock( void *uMem ) +{ + NA_Header_s *sMem; + + if ( uMem == NULL ) + { + return( 0 ); + } + sMem = NA_OUR_MEMORY( uMem ); +// zASSERT( sMem->NH_Signature == NA_SIGN_ALLOC ); + if ( sMem->NH_Signature != NA_SIGN_ALLOC ) + { /* Better to say 0 for memory that does not appear to be allocated */ + return 0; + } + /* User is NEVER told about the memory used by NA_Header_s */ + return( sMem->NH_ChunkSize - sizeof(NA_Header_s) ); + +} /* End of SizeOfAllocBlock() */ + + + +LONG OSGetCodePage() + +{ + return 437; +} diff --git a/src/nwnss/nsslnxlib/nssLnxLib.h b/src/nwnss/nsslnxlib/nssLnxLib.h new file mode 100644 index 0000000..4e4dfd4 --- /dev/null +++ b/src/nwnss/nsslnxlib/nssLnxLib.h @@ -0,0 +1,68 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NSS Linux Library + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | + +-------------------------------------------------------------------------*/ + + // Just in case Paul needs to have his ints. +typedef unsigned long long STATCount_t; + +// +// Statistics that can be read via /proc/nll/statistics +// +typedef struct NSSLinuxStats { + STATCount_t NLS_MPKAlloc; + STATCount_t NLS_MPKPageAlloc; + STATCount_t NLS_MPKPageAlloc2; + STATCount_t NLS_MPKFree; + STATCount_t NLS_MPKPageFree; + STATCount_t NLS_MPKPageFree2; + STATCount_t NLS_SleptFlagBad1; + STATCount_t NLS_SleptFlagBad2; + STATCount_t NLS_SizeInBytesBad1; + STATCount_t NLS_SizeInBytesBad2; + STATCount_t NLS_NumberOf4KPagesBad1; + STATCount_t NLS_NumberOf4KPagesZero1; + STATCount_t NLS_NumberOf4KPagesNULL; + STATCount_t NLS_FreeNULL; + STATCount_t NLS_NumberOf4KPagesZero2; + STATCount_t NLS_NumberOf4KPagesNot1AllocBad; + STATCount_t NLS_NumberOf4KPagesNot1FreeWarning; + STATCount_t NLS_SleepOKRequests1; + STATCount_t NLS_SleepOKRequests2; + STATCount_t NLS_SleepNotOKRequests; + STATCount_t NLS_SleepNotOKRequests1; +} NSSLinuxStats_s; + +extern NSSLinuxStats_s NSSLinuxStats; diff --git a/src/nwnss/nsslnxlib/nssLnxLibLKM.c b/src/nwnss/nsslnxlib/nssLnxLibLKM.c new file mode 100644 index 0000000..189a976 --- /dev/null +++ b/src/nwnss/nsslnxlib/nssLnxLibLKM.c @@ -0,0 +1,223 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Main entry point into NSS Linux Library. + +-------------------------------------------------------------------------*/ + +#include +#include +#include + +#include +#include +#include + + +#include "nssLnxLib.h" + +static const char *NLL_MainDirName = "nll"; +static const char *NLL_UI_StatisticsName = "statistics"; + +static struct proc_dir_entry *NLL_MainProcDir = NULL; +static struct proc_dir_entry *NLL_UI_StatisticsFile = NULL; + + +extern int InitUniLibGlobals(void); +extern void DeinitUniLibGlobals(void); + +NSSLinuxStats_s NSSLinuxStats; // All stats in here can be obtained via reading /proc/nll/statistics + + +// +// +// +static int NLL_UI_StatisticsOutMain( char *systemPage, int count, int *eof ) +{ +// int sts; + +//printk("<1>" "NSS::%s[%d] counts are (%d,%d)\n", __FILE__, __LINE__, count, sizeof(NSSLinuxStats) ); + if ( count == 0 ) + { //TODO: what is the proper return here??? + *eof = 1; +printk("<1>" "NLL::%s[%d] counts are (%d,%d)\n", __FILE__, __LINE__, count, sizeof(NSSLinuxStats) ); + return( 0 ); + } + if (!NLL_UI_StatisticsFile) + { +printk("<1>" "NLL::%s[%d] counts are (%d,%d)\n", __FILE__, __LINE__, count, sizeof(NSSLinuxStats) ); + return( -ENXIO ); + } + + if ( count >= sizeof(NSSLinuxStats) ) + { + count = sizeof(NSSLinuxStats); + } + // TODO: If this is really a sysetmPage I assume no validating is needed??? + memcpy( systemPage, &NSSLinuxStats, count ); + *eof = 1; // TODO: not sure how to or when to set +printk("<1>" "NLL::%s[%d] counts are (%d,%d)\n", __FILE__, __LINE__, count, sizeof(NSSLinuxStats) ); + return(count); +} + + + +// +// Proc interface routine +// +// Called by NSSUI when it needs console output. +// +// Because we 'eat' the chars that we output we do not need to use 'large file' +// mode. This means we do not use 'start' or 'off'. +// +static int NLL_UI_StatisticsOut(char *systemPage, char **start, + off_t off, int count, int *eof, void *data) +{ + int len; + +#if zLINUX_2_6 + try_module_get(THIS_MODULE); +#else + MOD_INC_USE_COUNT; +#endif + len = NLL_UI_StatisticsOutMain( systemPage, count, eof ); +#if zLINUX_2_6 + module_put(THIS_MODULE); +#else + MOD_DEC_USE_COUNT; +#endif + return(len); +} + + + + +void NLL_UI_CreateProcEntries(void) +{ + NLL_MainProcDir = proc_mkdir( NLL_MainDirName, NULL ); + if ( NLL_MainProcDir ) + { + NLL_MainProcDir->owner = THIS_MODULE; + NLL_UI_StatisticsFile = create_proc_entry( NLL_UI_StatisticsName, 0444, NLL_MainProcDir ); + if ( NLL_UI_StatisticsFile ) + { + NLL_UI_StatisticsFile->data = NULL; + NLL_UI_StatisticsFile->read_proc = NLL_UI_StatisticsOut; + NLL_UI_StatisticsFile->write_proc = NULL; + NLL_UI_StatisticsFile->owner = THIS_MODULE; + } + else + { + printk("<1>" "NLL::%s[%d] Unable to create %s\n", __FILE__, __LINE__, NLL_UI_StatisticsName ); + } + } + +} + +void NSS_UI_RemoveProcEntries(void) +{ + if (NLL_MainProcDir) + { + if (NLL_UI_StatisticsFile) + { + remove_proc_entry(NLL_UI_StatisticsName, NLL_MainProcDir ); + } + remove_proc_entry(NLL_MainDirName, NULL); + } + return; +} + +void __cyg_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void __cyg_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); + + +void __cyg_profile_func_enter (void *this_fn, void *call_site) +{ + nss_profile_func_enter(this_fn, call_site); + return; +} + +void __cyg_profile_func_exit (void *this_fn, void *call_site) +{ + nss_profile_func_exit(this_fn, call_site); + return; +} + +int __init lnxlib_init_module(void) +{ + int err; + +/* Include the following section to delay startup for remote debugging */ +#if 0 + mpkEnter(); + kDelayThread(5000); + mpkExit(); +#endif + + NLL_UI_CreateProcEntries(); + + printk(KERN_INFO "nsslnxlib loading...\n"); + err = InitUniLibGlobals(); + if (!err) + { + printk(KERN_INFO "nsslnxlib loaded\n"); + } + else + { + printk(KERN_INFO " nsslnxlib failed to init UniLib\n"); + } + + return(err); +} + +void __exit lnxlib_cleanup_module(void) +{ + NSS_UI_RemoveProcEntries(); + + DeinitUniLibGlobals(); + + printk(KERN_INFO "nsslnxlib un-loaded\n"); +} + +MODULE_AUTHOR("Novell, Inc."); +MODULE_DESCRIPTION("nsslnxlib"); +MODULE_LICENSE("GPL v2"); + +module_init(lnxlib_init_module) +module_exit(lnxlib_cleanup_module) diff --git a/src/nwnss/nsslnxlib/nssNSSLNXLIBSym.c b/src/nwnss/nsslnxlib/nssNSSLNXLIBSym.c new file mode 100644 index 0000000..e0d98fc --- /dev/null +++ b/src/nwnss/nsslnxlib/nssNSSLNXLIBSym.c @@ -0,0 +1,95 @@ +/**************************************************************************** + | + | (C) Copyright 2004 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2005-04-23 03:50:19 +0530 (Sat, 23 Apr 2005) $ + | + | $RCSfile$ + | $Revision: 954 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export NSS symbols to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB + +#include + +#include +#include +#include +#include +#include +#include +#include + +EXPORT_SYMBOL(kFileOpen); +EXPORT_SYMBOL(klseek); +EXPORT_SYMBOL(SizeOfAllocBlock); +//WRONG PLACE//EXPORT_SYMBOL(GetClosestSymbol); +EXPORT_SYMBOL(AllocatePhysicalPages); +EXPORT_SYMBOL(DeAllocatePhysicalPages); +EXPORT_SYMBOL(AllocSleepOK); +EXPORT_SYMBOL(Alloc); +EXPORT_SYMBOL(CScheduleInterruptTimeCallBack); +EXPORT_SYMBOL(GetCurrentTime); +EXPORT_SYMBOL(CYieldUntilIdle); +EXPORT_SYMBOL(GetHighResolutionTimer); +EXPORT_SYMBOL(ReturnOSLanguageID); +EXPORT_SYMBOL(GetCompanyName); +EXPORT_SYMBOL(GetSoftwareRevision); +EXPORT_SYMBOL(GetCopyrightNotice); +EXPORT_SYMBOL(GetPatentNotice); +EXPORT_SYMBOL(GetSoftwareDate); +EXPORT_SYMBOL(GetVirtualConsoleVersionNumber); +EXPORT_SYMBOL(GetVAPVersionNumber); +EXPORT_SYMBOL(GetQueueingVersionNumber); +EXPORT_SYMBOL(GetSecurityRestrictionsLevel); +EXPORT_SYMBOL(GetAllowUnencryptedPasswords); +EXPORT_SYMBOL(GetSFTLevel); +EXPORT_SYMBOL(GetTTSLevel); +EXPORT_SYMBOL(GetFileServerMajorVersionNumber); +EXPORT_SYMBOL(GetFileServerMinorVersionNumber); +EXPORT_SYMBOL(GetFileServerRevisionNumber); +EXPORT_SYMBOL(GetProductMajorVersionNumber); +EXPORT_SYMBOL(GetProductMinorVersionNumber); +EXPORT_SYMBOL(GetProductRevisionNumber); +EXPORT_SYMBOL(ReturnFileServerName); +EXPORT_SYMBOL(RingTheBell); +EXPORT_SYMBOL(OutputToScreenWithAttribute); +EXPORT_SYMBOL(OutputToScreen); +EXPORT_SYMBOL(NetWareAlert); +EXPORT_SYMBOL(loc2uni); +EXPORT_SYMBOL(loc2unipath); +EXPORT_SYMBOL(uni2loc); +EXPORT_SYMBOL(uni2locpath); +EXPORT_SYMBOL(chr2lwr); +EXPORT_SYMBOL(chr2upr); +EXPORT_SYMBOL(UniGetMacintoshTable); +EXPORT_SYMBOL(OSGetCodePage); +EXPORT_SYMBOL(Free); +EXPORT_SYMBOL(NW_LocaleTable); +EXPORT_SYMBOL(microSecondTimer); diff --git a/src/nwnss/nsslnxlib/nsslnxlibModules.mk b/src/nwnss/nsslnxlib/nsslnxlibModules.mk new file mode 100644 index 0000000..e1df4ad --- /dev/null +++ b/src/nwnss/nsslnxlib/nsslnxlibModules.mk @@ -0,0 +1,280 @@ +############################################################################## +# +# (C) Copyright 2003 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +########################################################################## +# This defines what MODULES are being built for this NLM +# +# $Author: ghorlacher $ +# $Date: 2007-09-13 03:51:53 +0530 (Thu, 13 Sep 2007) $ +# +# $RCSfile$ +# $Revision: 2206 $ +# +########################################################################## +MODULE_VERSION=15 + +#------------------------------------------------------------------------- +# If the version number is not defined here, the general product version +# number will be used (defined in bldVersion.bld) +# +# major version 1 to 99 +# minor version 1 to 99 +# sub version 1 to 26 +#------------------------------------------------------------------------- +#MAJOR_VERSION= +#MINOR_VERSION= +#SUB_VERSION= + +#------------------------------------------------------------------------- +# Build OPTIONS +#------------------------------------------------------------------------- +BUILD_WITH_KERNEL_FLAGS=1 + +#set to 0 if you are NOT using source code control +IS_USING_SOURCE_CONTROL=1 + +#Set to ONE if you want the linked files to be copied to the SDK/BIN directory. +COPY_TO_SDK_BIN=1 + + #set to ONE if you only want to copy the OPTIMIZED version to SDK/BIN. + COPY_OPTIMIZED_ONLY=0 + +#Set this to ONE if you are building a NETWARE version independent NLM +#(not NETWARE version specific) +NETWARE_VERSION_INDEPENDENT=1 + + #if ONE include the NETWARE .H files in the compiler search paths. + USE_NETWARE_INCLUDES=1 + +#If ONE IMPORT the LIBNSS APIs and include in the search path SDK/LIBRARY +#and SDK/PUBLIC +IMPORT_INDEPENDENT_LIBNSS=0 + +#If ONE include in the search path SDK/LIBRARY and SDK/PUBLIC +USE_LIBNSS_INCLUDES=1 + +#If ONE then LINK with the NSS library and include all of the NSS library +#directories in the compiler search paths. This includes the SDK/PUBLIC, +#SDK/INCLUDE, SDK/INTERNAL, LIBRARY/SRC directories. +LINK_WITH_NSSLIB=0 + +#if ONE then IMPORT the NSS library and COMN layer APIS and include the +#SDK/PUBLIC directory in the compiler search paths. +IMPORT_NSSLIB=1 + + #If ONE and (LINK_WITH_NSSLIB==1 or IMPORT_NSSLIB==1) then do the same + #operation to the NSSLIB area you are doing to the local area. + CHECK_NSSLIB=0 + + #If ONE and (CHECK_NSSLIB==1) then we will clean the NSSLIB area when we + #clean the local area. + CLEAN_NSSLIB=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INCLUDE directory in + #the compiler search paths + USE_NSS_SDK_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/COMNSA directory in + #the compiler search paths + USE_NSS_SDK_COMNSA_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INTERNAL directory in + #the compiler search paths + USE_NSS_SDK_INTERNAL_INCLUDES=1 + +#if ONE then do NOT import the NSS COMMON layer APIs +DONT_IMPORT_COMMON_LAYER=0 + +#if ONE, compile and link with the NETWARE sdk environment. +USE_NETWARE_SDK=1 + +#if ONE, include DS headers. +USE_NDS_INCLUDES=1 + +#if ONE, do LANGUAGE ENABLING processing +DO_LANGUAGE_ENABLING=0 + +#Set to null (i.e. no value) to not add XDC data to the NLM. For most +#NetWare 5.0 NLMs, the value should be -u. +MOAB_XDC_TOOL_OPTION=-n + +#************************************************************************* +# List of source directories for Generic Library +#************************************************************************* +SOURCE_DIRECTORIES= + +#************************************************************************* +# Source Modules for NSS (.C .386) +#************************************************************************* +SOURCE_FILES= \ + nssLnxLibLKM.c \ + allocRTag.c \ + kfile.c \ + microSecondTimer.c \ + nwlocale.c \ + nssLnxDummy.c \ + procdefslnx.c \ + unilib.c \ + nssNSSLNXLIBSym.c \ + nsslnxlibVersion.c +ifeq (${UNOPT_ENV},1) + SOURCE_FILES += unssNSSLNXLIBSym.c +endif + +SOURCE_FILES_NODEBUG= + +#************************************************************************* +# Source Include files for NSS (.H .inc) +#************************************************************************* +INCLUDE_FILES= \ + nssunilib.h + +#------------------------------------------------------------------------- +# Additional source files that need to be checked out +#------------------------------------------------------------------------- +OTHER_FILES=\ + Module.supported + +#------------------------------------------------------------------------- +# This defines what routines are being EXPORTED. You should put .IMP +# files in the "UTILITY_EXPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_EXPORTS= + +UTILITY_EXPORTS_VIA_FILE=\ + $(NSSLNXLIB_IMPORT) + +#------------------------------------------------------------------------- +# This defines what routines are being IMPORTED. You should put .IMP +# files in the "UTILITY_IMPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_IMPORTS= + +UTILITY_IMPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# Library definitions +# This defines additional libraries to LINK with and additional +# directories to put on out INCLUDE path. +#------------------------------------------------------------------------- +#additional libraries to link with +EXTRA_LIBRARIES= +EXTRA_STATIC_LIBRARIES= +EXTRA_DYNAMIC_LIBRARIES= +EXTRA_LIBRARY_INCLPATH= + +#------------------------------------------------------------------------- +# Include path +# This defines additional include path to compile with +#------------------------------------------------------------------------- +#additional include path +EXTRA_INCLUDE_PATH= + + +#------------------------------------------------------------------------- +# Additional C and ASSEMBLY options to use +#------------------------------------------------------------------------- +EXTRA_C_OPTIONS= +EXTRA_ASM_OPTIONS= +EXTRA_LINK_OPTIONS= + +#------------------------------------------------------------------------- +# Additional module attributes +#------------------------------------------------------------------------- +MODULE_DESCRIPTION='Generic Library used by NSS on Linux' +MODULE_ADDITIONAL_COPYRIGHT= +MODULE_OPTIONS=OPTION reentrant +MODULE_DEPENDENCIES= +MODULE_TYPE= +MODULE_EXTENSION= +MODULE_START_ROUTINE= +MODULE_EXIT_ROUTINE= +#set to 1 if you want the optimized NLM to be packed +MODULE_PACK_NLM=1 + +#========================================================================= +#========================================================================= +# LOCAL BUILD RULES +#========================================================================= +#========================================================================= + +#------------------------------------------------------------------------- +# Default BUILD rule +#------------------------------------------------------------------------- +DEFAULT: DEFAULT_BUILD + +#------------------------------------------------------------------------- +# Additional rules +#------------------------------------------------------------------------- + +#BUILD_GREENRIVER_OPT: +# @echo "...This NLM does not have an OPTIMIZED GREENRIVER specific version" + +#BUILD_GREENRIVER_UNOPT: +# @echo "...This NLM does not have an UNOPTIMIZED GREENRIVER specific version" + +BUILD_MOAB_MP_UNOPT: \ + COMPILE_UNOPT_MP_MOAB \ + LINK_UNOPT_MP_MOAB + +BUILD_MOAB_MP_OPT: \ + COMPILE_OPT_MP_MOAB \ + LINK_OPT_MP_MOAB + +BUILD_MOAB_SP_UNOPT: + @echo "...This NLM does not have an UNOPTIMIZED SP specific version" + +BUILD_MOAB_SP_OPT: + @echo "...This NLM does not have an OPTIMIZED SP specific version" + + +#BUILD_MOAB_SP_UNOPT: \ +# COMPILE_UNOPT_SP_MOAB \ +# LINK_UNOPT_SP_MOAB +# +#BUILD_MOAB_SP_OPT: \ +# COMPILE_OPT_SP_MOAB \ +# LINK_OPT_SP_MOAB + +#------------------------------------------------------------------------- +# Language Enabling rules +#------------------------------------------------------------------------- +mdb: \ + DEFAULT_MDB + +umdb: \ + LOCAL_MDB + +mdbcreate: \ + DEFAULT_CREATE_MDB_FILE + +#------------------------------------------------------------------------- +# Other rules +#------------------------------------------------------------------------- +deps: DEFAULT_DEPS + +cscope: DEFAULT_CSCOPE + diff --git a/src/nwnss/nsslnxlib/nsslnxlibVersion.c b/src/nwnss/nsslnxlib/nsslnxlibVersion.c new file mode 100644 index 0000000..2933b95 --- /dev/null +++ b/src/nwnss/nsslnxlib/nsslnxlibVersion.c @@ -0,0 +1,46 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Holds build number for the module + +-------------------------------------------------------------------------*/ +#include + +VersionInformation_s VLDB_VersionInfo = +{ + ZMAJV, + ZMINV, + ZSUBV, + ZBLDN, + VERINFO_NO_PATENT +}; diff --git a/include/nwnss/nsslnxlib/nssunilib.h b/src/nwnss/nsslnxlib/nssunilib.h similarity index 72% rename from include/nwnss/nsslnxlib/nssunilib.h rename to src/nwnss/nsslnxlib/nssunilib.h index 0041897..7b9a488 100644 --- a/include/nwnss/nsslnxlib/nssunilib.h +++ b/src/nwnss/nsslnxlib/nssunilib.h @@ -28,8 +28,6 @@ #ifndef _UNILIB_H_ #define _UNILIB_H_ -#include - #ifdef __cplusplus extern "C" { #endif @@ -41,23 +39,6 @@ typedef unsigned short unicode_t; typedef int UniRuleTable_t;/* more a cookie than anything else */ -/* Public LibC Unicode error and no-map constants used by NSS unicodeInit.c. */ -#define UNI_ERR_MEM_ALLOC (-494) -#define UNI_ERR_BAD_HANDLE (-496) -#define UNI_ERR_TABLE_CORRUPT (-498) -#define UNI_ERR_TOO_FEW_BYTES (-500) -#define UNI_ERR_FILE_OPEN (-501) -#define UNI_ERR_FILE_READ (-504) -#define UNI_ERR_PREMATURE_END (-506) -#define UNI_ERR_UNMAPPABLE_CHAR (-532) -#define UNI_LOCAL_DEFAULT (-1) -#define UNI_MAP_NO_CHAR 0 -#define UNI_MAP_CHAR 1 -#define UNI_MAP_BY_FUNC 1 -#define UNI_MAP_SELF 2 -#define UNI_NOMAP_DEFAULT '?' - - int loc2uni( UniRuleTable_t handle, unicode_t *dest, @@ -69,7 +50,7 @@ int loc2unipath( UniRuleTable_t handle, unicode_t *dest, const char *source, - size_t *dryRunSize); + unsigned int *dryRunSize); int uni2loc( UniRuleTable_t handle, @@ -82,13 +63,11 @@ int uni2locpath( UniRuleTable_t handle, char *dest, const unicode_t *src, - size_t *dryRunSize); + unsigned int *dryRunSize); unicode_t chr2lwr(unicode_t ch); unicode_t chr2upr(unicode_t ch); int UniGetMacintoshTable(const char *name, UniRuleTable_t *handle); -int InitUniLibGlobals(void); -void DeinitUniLibGlobals(void); LONG OSGetCodePage(void); diff --git a/src/nwnss/nsslnxlib/nwlocale.c b/src/nwnss/nsslnxlib/nwlocale.c index 1c99127..a887b47 100644 --- a/src/nwnss/nsslnxlib/nwlocale.c +++ b/src/nwnss/nsslnxlib/nwlocale.c @@ -32,7 +32,7 @@ | |--------------------------------------------------------------------------- | This module is used to: - | Ported OS code page tables for CP 437 (can be overlaid with other + | Ported OS code page tables for CP 437 (can be overlaid with other | code pages +-------------------------------------------------------------------------*/ @@ -42,70 +42,70 @@ struct LocaleTableStruct LocaleTable = { //int OSLanguageID = 4, -//int OSDoubleBytePresentFlag = +//int OSDoubleBytePresentFlag = 0, -//char OSDoubleByteSpace[2] = +//char OSDoubleByteSpace[2] = 0x20, 0, -//unsigned char OSUpperCaseTable[] = +//unsigned char OSUpperCaseTable[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, + 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, + 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, + 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }, 0, -//unsigned char OSSortTable[] = +//unsigned char OSSortTable[] = { - 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x2F, 0x5D, 0x5E, 0x20, - 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x20, - 0x43, 0x55, 0x45, 0x41, 0x41, 0x41, 0x41, 0x43, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x41, 0x41, - 0x45, 0x41, 0x41, 0x4F, 0x4F, 0x4F, 0x55, 0x55, 0x59, 0x4F, 0x55, 0x24, 0x24, 0x24, 0x24, 0x24, - 0x41, 0x49, 0x4F, 0x55, 0x4E, 0x4E, 0xA6, 0xA7, 0x3F, 0xA9, 0xAA, 0xAB, 0xAC, 0x21, 0x22, 0x22, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0x53, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF + 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x2F, 0x5D, 0x5E, 0x20, + 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x20, + 0x43, 0x55, 0x45, 0x41, 0x41, 0x41, 0x41, 0x43, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x41, 0x41, + 0x45, 0x41, 0x41, 0x4F, 0x4F, 0x4F, 0x55, 0x55, 0x59, 0x4F, 0x55, 0x24, 0x24, 0x24, 0x24, 0x24, + 0x41, 0x49, 0x4F, 0x55, 0x4E, 0x4E, 0xA6, 0xA7, 0x3F, 0xA9, 0xAA, 0xAB, 0xAC, 0x21, 0x22, 0x22, + 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0x53, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }, 0, -{ 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 +{ 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, 0, -//unsigned char OSFirstByteBitMap[] = +//unsigned char OSFirstByteBitMap[] = { 0x00, 0x00, 0x00, 0x00, /* 00h - 1Fh */ 0x00, 0x00, 0x00, 0x00, /* 20h - 3Fh */ @@ -118,7 +118,7 @@ struct LocaleTableStruct LocaleTable = { }, 0, -//unsigned char DOSValidCharBitMap[] = +//unsigned char DOSValidCharBitMap[] = { 0x00, 0x00, 0x07, 0x00, /* 00h - 1Fh */ 0xFE, 0x63, 0xFF, 0x03, /* 20h - 3Fh */ @@ -131,7 +131,7 @@ struct LocaleTableStruct LocaleTable = { }, -//unsigned char DOSValidCharBitMapNoLower[] = +//unsigned char DOSValidCharBitMapNoLower[] = { 0x00, 0x00, 0x00, 0x00, /* 00h - 1Fh */ 0xFE, 0x63, 0xFF, 0x03, /* 20h - 3Fh */ @@ -144,7 +144,7 @@ struct LocaleTableStruct LocaleTable = { }, -//unsigned char DOSFirstByteBitMap[] = +//unsigned char DOSFirstByteBitMap[] = { 0x00, 0x00, 0x00, 0x00, /* 00h - 1Fh */ 0x00, 0x00, 0x00, 0x00, /* 20h - 3Fh */ @@ -157,7 +157,7 @@ struct LocaleTableStruct LocaleTable = { }, -//unsigned char DOSSecondByteBitMap[] = +//unsigned char DOSSecondByteBitMap[] = { 0x00, 0x00, 0x00, 0x00, /* 00h - 1Fh */ 0x00, 0x00, 0x00, 0x00, /* 20h - 3Fh */ @@ -170,65 +170,65 @@ struct LocaleTableStruct LocaleTable = { }, -//unsigned char DOSUpperCaseTable[] = +//unsigned char DOSUpperCaseTable[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0xBF, 0xAE, 0xAA, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0xBF, 0xAE, 0xAA, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, + 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, + 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, + 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }, -//unsigned char DOSToMAC[] = +//unsigned char DOSToMAC[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x82, 0x9F, 0x8E, 0x89, 0x8A, 0x88, 0x8C, 0x8D, 0x90, 0x91, 0x8F, 0x95, 0x94, 0x93, 0x80, 0x81, - 0x83, 0xBE, 0xAE, 0x99, 0x9A, 0x98, 0x9E, 0x9D, 0xD8, 0x85, 0x86, 0xA2, 0xA3, 0xB4, 0xCC, 0xC4, - 0x87, 0x92, 0x97, 0x9C, 0x96, 0x84, 0xBB, 0xBC, 0xC0, 0x8B, 0xC2, 0x9B, 0xA0, 0xC1, 0xC7, 0xC8, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xCD, 0xD7, 0xCE, 0xCF, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, - 0xA4, 0xA7, 0xA6, 0xB9, 0xB7, 0xA8, 0xB5, 0xA9, 0xAA, 0xAB, 0xBD, 0xB6, 0xB0, 0xBF, 0xCB, 0xAD, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, + 0x82, 0x9F, 0x8E, 0x89, 0x8A, 0x88, 0x8C, 0x8D, 0x90, 0x91, 0x8F, 0x95, 0x94, 0x93, 0x80, 0x81, + 0x83, 0xBE, 0xAE, 0x99, 0x9A, 0x98, 0x9E, 0x9D, 0xD8, 0x85, 0x86, 0xA2, 0xA3, 0xB4, 0xCC, 0xC4, + 0x87, 0x92, 0x97, 0x9C, 0x96, 0x84, 0xBB, 0xBC, 0xC0, 0x8B, 0xC2, 0x9B, 0xA0, 0xC1, 0xC7, 0xC8, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xCD, 0xD7, 0xCE, 0xCF, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, + 0xA4, 0xA7, 0xA6, 0xB9, 0xB7, 0xA8, 0xB5, 0xA9, 0xAA, 0xAB, 0xBD, 0xB6, 0xB0, 0xBF, 0xCB, 0xAD, 0xAF, 0xB1, 0xB3, 0xB2, 0xB8, 0xBA, 0xD6, 0xC5, 0xA1, 0xA5, 0xE1, 0xC3, 0xAC, 0xC6, 0xC9, 0xCA }, -//unsigned char MACToDOS[] = +//unsigned char MACToDOS[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x8E, 0x8F, 0x80, 0x90, 0xA5, 0x99, 0x9A, 0xA0, 0x85, 0x83, 0x84, 0xA9, 0x86, 0x87, 0x82, 0x8A, - 0x88, 0x89, 0xA1, 0x8D, 0x8C, 0x8B, 0xA5, 0xA2, 0x95, 0x93, 0x94, 0xAB, 0xA3, 0x97, 0x96, 0x81, - 0xAC, 0xF8, 0x9B, 0x9C, 0xE0, 0xF9, 0xE2, 0xE1, 0xE5, 0xE7, 0xE8, 0xE9, 0xFC, 0xEF, 0x92, 0xF0, - 0xEC, 0xF1, 0xF3, 0xF2, 0x9D, 0xE6, 0xEB, 0xE4, 0xF4, 0xE3, 0xF5, 0xA6, 0xA7, 0xEA, 0x91, 0xED, - 0xA8, 0xAD, 0xAA, 0xFB, 0x9F, 0xF7, 0xFD, 0xAE, 0xAF, 0xFE, 0xFF, 0xEE, 0x9E, 0xB6, 0xB8, 0xB9, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0x98, 0xC1, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xFA, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, + 0x8E, 0x8F, 0x80, 0x90, 0xA5, 0x99, 0x9A, 0xA0, 0x85, 0x83, 0x84, 0xA9, 0x86, 0x87, 0x82, 0x8A, + 0x88, 0x89, 0xA1, 0x8D, 0x8C, 0x8B, 0xA5, 0xA2, 0x95, 0x93, 0x94, 0xAB, 0xA3, 0x97, 0x96, 0x81, + 0xAC, 0xF8, 0x9B, 0x9C, 0xE0, 0xF9, 0xE2, 0xE1, 0xE5, 0xE7, 0xE8, 0xE9, 0xFC, 0xEF, 0x92, 0xF0, + 0xEC, 0xF1, 0xF3, 0xF2, 0x9D, 0xE6, 0xEB, 0xE4, 0xF4, 0xE3, 0xF5, 0xA6, 0xA7, 0xEA, 0x91, 0xED, + 0xA8, 0xAD, 0xAA, 0xFB, 0x9F, 0xF7, 0xFD, 0xAE, 0xAF, 0xFE, 0xFF, 0xEE, 0x9E, 0xB6, 0xB8, 0xB9, + 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0x98, 0xC1, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + 0xC0, 0xFA, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF } @@ -238,21 +238,21 @@ struct LocaleTableStruct *NW_LocaleTable = &LocaleTable; /* unsigned char LongNameUpperCaseTable[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0xBF, 0xAE, 0xAA, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0xBF, 0xAE, 0xAA, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, + 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, + 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, + 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }; */ diff --git a/src/nwnss/nsslnxlib/procdefslnx.c b/src/nwnss/nsslnxlib/procdefslnx.c new file mode 100644 index 0000000..c305720 --- /dev/null +++ b/src/nwnss/nsslnxlib/procdefslnx.c @@ -0,0 +1,206 @@ +/**************************************************************************** + | + | (C) Copyright 2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + +-------------------------------------------------------------------------*/ +#include "procdefs.h" + +#include /* NSS Library includes*/ +#include +#include +#include "alert.h" +/***************************************************************************** + * + * + * + ****************************************************************************/ + +static unsigned long VirtualConsoleVersionNumber = 0; +static unsigned long VAPVersionNumber = 0; +static unsigned long QueueingVersionNumber = 0; +static unsigned long SecurityRestrictionsLevel = 0; +static unsigned long AllowUnencryptedPasswords = 0; +static unsigned long SFTLevel = 0; +static unsigned long TTSLevel = 0; +static unsigned long FileServerMajorVersionNumber = 0; +static unsigned long FileServerMinorVersionNumber = 0; +static unsigned long FileServerRevisionNumber = 0; +static unsigned long ProductMajorVersionNumber = 0; +static unsigned long ProductMinorVersionNumber = 0; +static unsigned long ProductRevisionNumber = 0; + + +static BYTE company_name[128] = {"Novell, Inc."}; +static BYTE software_revision[128] = {"Software revision Fixme"}; +static BYTE copyright_notice[128] = {"Copyright notice Fixme"}; +static BYTE patent_notice[128] = {"Patent notice Fixme"}; +static BYTE software_date[128] = {"Software date Fixme"}; +static BYTE file_server_name[128] = {"File_server_name_Fixme"}; + +/***************************************************************************** + * + * + * + ****************************************************************************/ + +void GetCompanyName(BYTE *nameBuffer) +{ + strcpy(nameBuffer, company_name); +} + +void GetSoftwareRevision(BYTE *nameBuffer) +{ + strcpy(nameBuffer, software_revision); +} + +void GetCopyrightNotice(BYTE *nameBuffer) +{ + strcpy(nameBuffer, copyright_notice); +} + +void GetPatentNotice(BYTE *nameBuffer) +{ + strcpy(nameBuffer, patent_notice); +} + +void GetSoftwareDate(BYTE *nameBuffer) +{ + strcpy(nameBuffer, software_date); +} + +LONG GetVirtualConsoleVersionNumber() +{ + return(VirtualConsoleVersionNumber); +} + +LONG GetVAPVersionNumber() +{ + return(VAPVersionNumber); +} + +LONG GetQueueingVersionNumber() +{ + return(QueueingVersionNumber); +} + +LONG GetSecurityRestrictionsLevel() +{ + return(SecurityRestrictionsLevel); +} + +LONG GetAllowUnencryptedPasswords() +{ + return(AllowUnencryptedPasswords); +} + +LONG GetSFTLevel() +{ + return(SFTLevel); +} + +LONG GetTTSLevel() +{ + return(TTSLevel); +} + +LONG GetFileServerMajorVersionNumber() +{ + return(FileServerMajorVersionNumber); +} + +LONG GetFileServerMinorVersionNumber() +{ + return(FileServerMinorVersionNumber); +} + +LONG GetFileServerRevisionNumber() +{ + return(FileServerRevisionNumber); +} + +LONG GetProductMajorVersionNumber() +{ + return(ProductMajorVersionNumber); +} + +LONG GetProductMinorVersionNumber() +{ + return(ProductMinorVersionNumber); +} + +LONG GetProductRevisionNumber() +{ + return(ProductRevisionNumber); +} + +LONG ReturnFileServerName(BYTE *nameBuffer) +{ + nameBuffer[0] = sprintf(nameBuffer + 1, file_server_name); + return((LONG)nameBuffer[0]); +} + +void RingTheBell() +{ +// +// Fix me +// +} + +int OutputToScreenWithAttribute(struct ScreenStruct *ScreenID, int I, ...) +{ +// +// Fix me +// + return(-1); +} + +LONG OutputToScreen( + struct ScreenStruct *screenID, + void *controlString, + ...) +{ +// +// Fix me +// + return(-1); +} + +void NetWareAlert( + struct LoadDefinitionStructure *nlm, + NetWareAlertStructure *nwAlert, + LONG ParameterCount, ...) +{ +// +// Fix me +// +} + + + diff --git a/src/nwnss/nsslnxlib/unilib.c b/src/nwnss/nsslnxlib/unilib.c index dde48ad..fc6a072 100644 --- a/src/nwnss/nsslnxlib/unilib.c +++ b/src/nwnss/nsslnxlib/unilib.c @@ -35,23 +35,23 @@ | Ported LibC base Unicode services +-------------------------------------------------------------------------*/ -#include +#include "zOmni.h" +#include +#include #include -#include -#include - -#include -#include +#include +#include +extern LONG OSGetCodePage(void); int LoadHostLocale(void *whatever, void *NLMHandle); // Manifest constants #define CODEPAGES 52 /* we know of this many so far */ #define CURRENT_UNI_TAB_VERSION 1 -#define UNI_ERR_MEM_ALLOC (-494) /* no memory for allocation */ -#define UNI_ERR_TABLE_CORRUPT (-498) /* table corruption detected */ -#define UNI_ERR_FILE_OPEN (-501) /* unable to open data file */ -#define UNI_ERR_FILE_READ (-504) /* unable to read data file */ +#define UNI_ERR_MEM_ALLOC (-494) /* no memory for allocation */ +#define UNI_ERR_TABLE_CORRUPT (-498) /* table corruption detected */ +#define UNI_ERR_FILE_OPEN (-501) /* unable to open data file */ +#define UNI_ERR_FILE_READ (-504) /* unable to read data file */ #define UNI_ERR_UNMAPPABLE_CHAR (-532) /* discovered during translation */ #define UNI_UNDEFINED 0xFFFD /* Source code page character has no Unicode conversion */ @@ -246,7 +246,7 @@ void *LIBALLOC(unsigned int bytes, int unused) #define LIBFREE(x) mpkPageFree(x) /* Scary stuff to permit LibC NetWare specifics to compile */ -struct +struct { int allocRTag; } LibCGlobals = {0}; @@ -263,12 +263,12 @@ int InitUniLibGlobals(void) UniLibGlobals.signature = UniLibGlobals.signature2 = kUniLibSig; - UniLibGlobals.paddington[0] = - UniLibGlobals.paddington[1] = + UniLibGlobals.paddington[0] = + UniLibGlobals.paddington[1] = UniLibGlobals.paddington[2] = padSig; UniLibGlobals.lock = LIBC_INIT_LOCK("Unicode Tables", (vm_t *) NULL); - /* FIXFIXFIX - Fake the code page to 437 for now but we need a persistent + /* FIXFIXFIX - Fake the code page to 437 for now but we need a persistent * way to store the code page for the host */ UniLibGlobals.codepage = OSGetCodePage(); @@ -438,6 +438,12 @@ int ReadCollationAndCaseTables(void *index, void *data) return -1; } + if (!filep->f_op || !filep->f_op->read) + { + printk("NSSLNXLIB: Unicode table file pointer has no operations table or read operation\n"); + err = -1; + goto Exit; + } #if 0 if (err) @@ -459,7 +465,7 @@ int ReadCollationAndCaseTables(void *index, void *data) { // set sUniTabDir so that it will be recalculated sUniTabDir[0] = '\0'; - + /* ** Try LibC's load path only for collation and case tables. In the ** NetWare 5 overlay install this is the only place they exist. @@ -573,12 +579,12 @@ STATIC int uniLoadUni2MBTables(struct file *filep, RuleTable_t *table, unsigned // load first lookup table... if ((err = uniAllocAndRead(filep, (void **)&table->uniTab1, filePosition, - sizeof(unsigned short), 256))) + sizeof(unsigned short), 256))) goto Exit; // load phase 2 tables... err = uniAllocAndRead(filep, (void **)&table->uniTab2, filePosition, - sizeof(unsigned short), tab2Size); + sizeof(unsigned short), tab2Size); Exit : return err; } @@ -654,7 +660,7 @@ STATIC int uniLoadMB2UniTables(struct file *filep, RuleTable_t *table, unsigned // load table 2... err = uniAllocAndRead(filep, (void **)&table->cpTab2, filePosition, - sizeof(unicode_t), tab2Size); + sizeof(unicode_t), tab2Size); } Exit : @@ -829,7 +835,7 @@ STATIC int OpenUnicodeTable(int codepage, const char *filename, UniRuleTable_t * return UNI_ERR_TABLE_CORRUPT; memset(&table, 0, sizeof(table)); - + // initialize UniRuleTable_t struct... table.codepage = codepage; @@ -851,6 +857,12 @@ STATIC int OpenUnicodeTable(int codepage, const char *filename, UniRuleTable_t * err = -1; goto Exit; } + if (!filep->f_op || !filep->f_op->read) + { + printk("Bad file pointer opening Unicode table file: %s\n", filepath); + err = -1; + goto Exit; + } } #if 0 @@ -866,7 +878,7 @@ STATIC int OpenUnicodeTable(int codepage, const char *filename, UniRuleTable_t * // now try in the current directory if (err = ProposeTableOnServerLoadPath(sUniTabDir, FALSE)) return UNI_ERR_FILE_OPEN; - + strlist(filepath, sUniTabDir, filename, (char *) NULL); if (err = DOSOpenWithAccess(filepath, &fh, 0)) @@ -1253,7 +1265,7 @@ int loc2unipath UniRuleTable_t handle, // 0 means all characters from Unicode 0 unicode_t *dest, const char *source, - size_t *dryRunSize // don't copy, only measure if present + unsigned int *dryRunSize // don't copy, only measure if present ) { int multibyte; @@ -1411,7 +1423,7 @@ int uni2locpath UniRuleTable_t handle, // 0 means local host code page char *dest, // rule of thumb: unilen(src) + 20% const unicode_t *src, - size_t *dryRunSize // don't copy, only measure if present + unsigned int *dryRunSize // don't copy, only measure if present ) { unsigned short ch; // holds potentially two byte characters @@ -1485,7 +1497,7 @@ int uni2locpath { *((unsigned short *) dest) = ch; dest += CPCharSize(ch);// skip bytes corresponding to size... - } // ...of the resulting character + } // ...of the resulting character break; } @@ -1554,3 +1566,5 @@ int UniGetMacintoshTable(const char *name, UniRuleTable_t *handle) return OpenUnicodeTable(mac->codepage, mac->dosname, handle); } + + diff --git a/include/nwnss/support/lnxmbINC/locks.h b/src/nwnss/nsslnxlib/unssNSSLNXLIBSym.c similarity index 58% rename from include/nwnss/support/lnxmbINC/locks.h rename to src/nwnss/nsslnxlib/unssNSSLNXLIBSym.c index dbf6b5d..5ce4bc0 100644 --- a/include/nwnss/support/lnxmbINC/locks.h +++ b/src/nwnss/nsslnxlib/unssNSSLNXLIBSym.c @@ -1,6 +1,6 @@ /**************************************************************************** | - | (C) Copyright 2004 Novell, Inc. + | (C) Copyright 2004 Novell, Inc. | All Rights Reserved. | | This program is free software; you can redistribute it and/or @@ -18,32 +18,26 @@ | To contact Novell about this file by physical or electronic mail, | you may find current contact information at www.novell.com | - |***************************************************************************/ + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export NSS symbols to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB +#include -#define MULTIWAIT 0x20 +#include -#define FLBIT 1 -#define OSBIT 2 -#define LOGFBIT 4 -#define OLBIT 8 - -#define LOCKBITS (FLBIT | OSBIT | LOGFBIT | OLBIT) - -#define LOCKBIT 1 - - -#define LOCKERR 255 -#define UNLKERR 255 -#define TRANSERR 255 -#define LOGSERR 255 -#define RSERR 255 -#define TIMEOUT 254 -#define LOCKCOLLISION 253 -#define WAITING 252 -#define HOLDISLOCKED 250 -#define MEMERR 150 -#define ERR_REVOKE_HANDLE_RIGHTS_NOT_FOUND 115 /* 0x73 */ -#define ERR_REMOTE_NOT_ALLOWED 116 /* 0x74 */ -#define OPENCOLLISION 127 -#define TRANSRESTART 254 +EXPORT_SYMBOL(GetClosestSymbol); diff --git a/src/nwnss/nwraid/Makefile b/src/nwnss/nwraid/Makefile new file mode 100644 index 0000000..4c66ac1 --- /dev/null +++ b/src/nwnss/nwraid/Makefile @@ -0,0 +1,10 @@ +### +### ../nss/volmgmt/nwraid Makefile +### + +BASEDIR=../.. + +SUBDIRS= \ + +include ${BASEDIR}/buildtools/Makefile.default + diff --git a/src/nwnss/nwraid/Module.supported b/src/nwnss/nwraid/Module.supported new file mode 100644 index 0000000..1c5a7fe --- /dev/null +++ b/src/nwnss/nwraid/Module.supported @@ -0,0 +1 @@ +nwraid.ko diff --git a/src/nwnss/nwraid/dmio.c b/src/nwnss/nwraid/dmio.c new file mode 100644 index 0000000..6e8a27e --- /dev/null +++ b/src/nwnss/nwraid/dmio.c @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2008 Novell, Inc. + * + * This file is released under the GPL. + */ + +/* This file is used to convert the older DM-IO calls used in SLES10-PS1 to + * the newer DM_IO calls used in SLES10-SP2. The DM IO calls were changed + * and the older calls were no longer supported. This was done to maintain + * code compatability between the two. + */ + +#include "dm-io.h" +#include + +#if ((LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)) || \ + ((LINUX_VERSION_CODE == KERNEL_VERSION(2,6,16)) && (EXTRAVERSION >= 60))) + +struct dm_io_client *io_client = NULL; +int client_count = 0; + +int dm_io_get(unsigned int num_pages) +{ + if (client_count == 0) { + io_client = dm_io_client_create(64); + if (io_client != NULL) { + client_count = 1; + return(0); + } + else { + return(-ENOMEM); + } + } + else { + client_count++; + return(0); + } +} + +void dm_io_put(unsigned int num_pages) +{ + if (client_count > 0) { + client_count--; + if (client_count == 0) { + dm_io_client_destroy(io_client); + io_client = NULL; + } + } +} + +int dm_io_sync_vm(unsigned int num_regions, struct io_region *where, int rw, + void *data, unsigned long *error_bits) +{ + struct dm_io_request req; + + req.bi_rw = rw; + req.mem.type = DM_IO_VMA; + req.mem.ptr.vma = data; + req.mem.offset = 0; + req.notify.fn = NULL; + req.client = io_client; + + return(dm_io(&req, num_regions, where, error_bits)); +} + + +int dm_io_async(unsigned int num_regions, struct io_region *where, int rw, + struct page_list *list, unsigned int offset, + io_notify_fn fn, void *context) +{ + struct dm_io_request req; + + req.bi_rw = rw; + req.mem.type = DM_IO_PAGE_LIST; + req.mem.ptr.pl = list; + req.mem.offset = offset; + req.notify.fn = fn; + req.notify.context = context; + req.client = io_client; + + return(dm_io(&req, num_regions, where, NULL)); +} + + +int dm_io_sync(unsigned int num_regions, struct io_region *where, int rw, + struct page_list *list, unsigned int offset, + unsigned long *error_bits) +{ + struct dm_io_request req; + + req.bi_rw = rw; + req.mem.type = DM_IO_PAGE_LIST; + req.mem.ptr.pl = list; + req.mem.offset = offset; + req.notify.fn = NULL; + req.client = io_client; + + return(dm_io(&req, num_regions, where, error_bits)); +} + + +int dm_io_async_bvec(unsigned int num_regions, struct io_region *where, int rw, + struct bio_vec *bvec, io_notify_fn fn, void *context) +{ + struct dm_io_request req; + + req.bi_rw = rw; + req.mem.type = DM_IO_BVEC; + req.mem.ptr.bvec = bvec; + req.mem.offset = 0; + req.notify.fn = fn; + req.notify.context = context; + req.client = io_client; + + return(dm_io(&req, num_regions, where, NULL)); +} + +int dm_io_async_vm(unsigned int num_regions, struct io_region *where, int rw, + void *data, io_notify_fn fn, void *context) +{ + struct dm_io_request req; + + req.bi_rw = rw; + req.mem.type = DM_IO_VMA; + req.mem.ptr.vma = data; + req.mem.offset = 0; + req.notify.fn = fn; + req.notify.context = context; + req.client = io_client; + + return(dm_io(&req, num_regions, where, NULL)); +} + + +#endif diff --git a/src/nwnss/nwraid/dmio.h b/src/nwnss/nwraid/dmio.h new file mode 100644 index 0000000..708120a --- /dev/null +++ b/src/nwnss/nwraid/dmio.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2008 Novell, Inc. + * + * This file is released under the GPL. + */ + +/* This file is used to convert the older DM-IO calls used in SLES10-PS1 to + * the newer DM_IO calls used in SLES10-SP2. The DM IO calls were changed + * and the older calls were no longer supported. This was done to maintain + * code compatability between the two. + */ + +#include + +#if ((LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)) || \ + ((LINUX_VERSION_CODE == KERNEL_VERSION(2,6,16)) && (EXTRAVERSION >= 60))) + + +int dm_io_get(unsigned int num_pages); +void dm_io_put(unsigned int num_pages); + +int dm_io_sync_vm(unsigned int num_regions, struct io_region *where, int rw, + void *data, unsigned long *error_bits); + + +int dm_io_async(unsigned int num_regions, struct io_region *where, int rw, + struct page_list *list, unsigned int offset, + io_notify_fn fn, void *context); + +int dm_io_sync(unsigned int num_regions, struct io_region *where, int rw, + struct page_list *list, unsigned int offset, + unsigned long *error_bits); + +int dm_io_async_bvec(unsigned int num_regions, struct io_region *where, int rw, + struct bio_vec *bvec, io_notify_fn fn, void *context); + +int dm_io_async_vm(unsigned int num_regions, struct io_region *where, int rw, + void *data, io_notify_fn fn, void *context); + + +#endif diff --git a/src/nwnss/nwraid/nwraid.h b/src/nwnss/nwraid/nwraid.h new file mode 100644 index 0000000..23e4d5c --- /dev/null +++ b/src/nwnss/nwraid/nwraid.h @@ -0,0 +1,327 @@ + + +#ifndef _NWRAID_H +#define _NWRAID_H + +#define RAID_VERSION 2 +#define MAX_ELEMENTS 14 +#define MIN_ENGINE_COUNT 8 +#ifdef __x86_64__ +#define LOG_MAP_SIZE 64 /* in unsigned long */ +#else +#define LOG_MAP_SIZE 128 /* in unsigned long */ +#endif + +/* Restripe states */ +#define NO_RESTRIPE 0 +#define INIT_RESTRIPE 1 +#define RESTRIPEING 2 +#define DONE_SENDING 3 +#define DONE 4 +#define STOPPING 5 + +/* Engine flags */ +#define TO_ERROR 0x00000001 +#define FROM_ERROR 0x00000002 +#define PARITY_ERROR 0x00000004 +#define READ_MAP 0x00000010 +#define READ_PARITY 0x00000020 +#define WRITE_MISSING 0x00000040 + +#define FALSE 0 +#define TRUE 1 + +#define RAID0 0 +#define RAID5 5 + +/* Defines for flag field within RaidCacheDef */ +#define CACHE_ALLOCATED 0x0001 +#define CACHE_INUSE 0x0002 +#define CACHE_LINKED 0x0004 /* onto the process queue */ +#define CACHE_READ 0x0008 +#define CACHE_WRITE 0x0010 +#define CACHE_PARITY_MISSING 0x0020 + +/* Defines for flag field within raid_set */ +#define DEACTIVE_FLAG 0x0001 +#define SHARED_FLAG 0x0002 +#define INSYNC_FLAG 0x0004 +#define FLUSH_FLAG 0x0008 +#define NOIO_FLAG 0x0010 +#define SUSPEND_FLAG 0x0020 +#define RESTRIPE_ENABLED 0x0040 +#define RESTRIPE_ABORT 0x0080 +#define PROCESS_WRITES 0x0100 +#define RESYNC_FLAG 0x0200 +#define RESTRIPE_RESTART 0x0400 + +#define CACHE_BUFFERS 400 +//#define CACHE_SIZE 4096 /* in bytes */ +#define CACHE_SIZE PAGE_SIZE +#define CACHE_SECTORS 8 /* in sectors */ + +struct raid_set; +struct RaidCacheDef; +struct iocontext; +struct iocontext_block; +/*----------------------------------------------------------------- + * Raid set structures. + *---------------------------------------------------------------*/ +typedef struct split_context { + struct raid_set *rs; + uint32_t group; + int count; + int err; + void *private; +}split_context; + +struct element { + atomic_t error_count; + struct dm_dev *dev; + sector_t offset; + struct dm_dev *flush_dev; + sector_t flush_offset; +}; + +typedef struct raid_stamp_s { + unsigned char version; + unsigned char stamptext[15]; + + uint32_t raidtype; + uint32_t elementsize; + uint32_t identifier; + uint32_t elementcount; + + uint32_t elementindex; + uint32_t capacity; + uint32_t raidstripeshift; + uint32_t oldelementcount; + + uint32_t flushed_block; + uint32_t missingelement; + uint32_t resyncparityflag; + uint32_t lastblock; + + uint32_t bitmapsize; + uint32_t groupshift; + uint32_t stamptime; + uint32_t reserved; + + unsigned char name[128]; + unsigned char guid[16]; + unsigned char owner[16]; + +} __attribute__((packed)) raid_stamp_t; + +struct engine { + struct engine *link; + sector_t block; + sector_t stripe; + sector_t readstripe; + uint32_t group; + uint32_t flags; + uint32_t fromindex; + uint32_t toindex; + uint32_t parity; + struct raid_set *rs; + struct page_list *list; + struct io_region to; +}; + +struct ReadMap +{ + struct engine *engine; + struct engine *link; + sector_t stripe; + uint32_t count; +}; + +struct RestripeMap +{ + struct engine *engine; + sector_t stripe; + uint32_t count; +}; + +struct GroupMap +{ + unsigned long group; + unsigned long count; +}; + +struct RaidCachePtr +{ + struct RaidCacheDef *cache; + uint32_t index; +}; + +struct RaidCacheDef +{ + /* These 4 pointers must be the first 4 elements. */ + struct RaidCacheDef *useNext; + struct RaidCacheDef *usePrev; + struct RaidCacheDef *orderNext; + struct RaidCacheDef *orderPrev; + struct RaidCacheDef *link; + + struct raid_set *rs; + sector_t sectoroffset; + unsigned long parity; + unsigned long flags; + unsigned long validmap; + unsigned long writemap; + unsigned long err_mask; + + atomic_t writecount; + atomic_t readcount; + uint32_t elementcount; + spinlock_t localcachelock; + + struct iocontext *readlist; + struct iocontext *writelist; + struct iocontext *paritylist; + + struct RaidCacheDef *alloclink; + struct page_list buffers[MAX_ELEMENTS]; + struct RaidCachePtr index[MAX_ELEMENTS]; +}; + +struct raid_set { + struct dm_target *ti; + struct list_head list; + struct workqueue_struct *wq; + struct work_struct *work; + + spinlock_t lock; /* protects changes to this set */ + struct bio_list reads; + struct bio_list writes; + struct bio_list readas; /* read aheads */ + + unsigned long nr_elements; + unsigned long temp_elements; + unsigned long loadedmap; + unsigned long activemap; + uint16_t flags; + unsigned char restripestate; + unsigned char reserved; + atomic_t *wakecount; + + spinlock_t cachelock; + struct RaidCacheDef *useNext; + struct RaidCacheDef *usePrev; + struct RaidCacheDef *orderNext; + struct RaidCacheDef *orderPrev; + + struct RaidCacheDef *cache; + struct RaidCacheDef *lastfind; + struct RaidCacheDef *process_head; + struct RaidCacheDef *process_tail; + struct RaidCacheDef *readcomplete_head; + struct RaidCacheDef *readcomplete_tail; + struct RaidCacheDef *parity_write; + uint32_t cachecount; + + sector_t elementsize; + struct element elements[MAX_ELEMENTS]; + spinlock_t iolock; + struct iocontext_block *ioblocklist; + struct iocontext *iolist; + uint32_t context_count; + struct iocontext *queue_readhead; + struct iocontext *queue_readtail; + struct iocontext *queue_writehead; + struct iocontext *queue_writetail; + struct iocontext *returnlist; + struct iocontext *cachewrite; + struct iocontext *fast_head; + struct iocontext *fast_tail; + struct iocontext *errorlist; + struct iocontext *splitlist; + + struct iocontext *flushlist; + spinlock_t flushlock; + /* Restripe data */ + spinlock_t rlock; + sector_t restripe_block; + sector_t completed_block; + sector_t laststripe; + sector_t lastblock; + unsigned long restripe_count; + unsigned long lockedgroup; + unsigned long groupstripes; + unsigned long stripesize; + unsigned long enginecount; + unsigned long readmapcount; + uint16_t *lockmapcount; + struct engine *engine; + spinlock_t irqlock; + struct engine *read; + struct engine *writehead; + struct engine *writetail; + struct engine *completehead; + struct engine *completetail; + struct engine *parity; + + struct RestripeMap *map; + struct ReadMap *readmap; + struct GroupMap *groupmap; + + /* Log data */ + raid_stamp_t stamp; + unsigned long *bitmap; // for raid5 fast resync + atomic_t ioreadcount; + atomic_t iopending; + atomic_t iototal; +}; + +struct PCPartitionDef +{ + unsigned char bootflag; + unsigned char bhead; + unsigned char bsector; /* Only the 6 least significant bits. The 2 most */ + unsigned char bcylinder; /* significant bits belong to the 10 bit cylinder */ + unsigned char sysflag; + unsigned char ehead; + unsigned char esector; + unsigned char ecylinder; + uint32_t beginningsector; + uint32_t numberofsectors; +}; + +struct PCBootSectorDef +{ + unsigned char bootcode[0x1BE]; + struct PCPartitionDef partition[4]; + uint16_t signature; +}; + +void wake(struct raid_set *rs); +int flush_log(struct raid_set *rs); +int refresh_log(struct raid_set *rs); +void AdjustLastBlock(struct raid_set *rs, struct bio *bio); +int CheckGroupLock(struct raid_set *rs, sector_t lastsector, unsigned long group); +void stop_IO(struct raid_set *rs); +void start_IO(struct raid_set *rs); +int stop_restripe(struct raid_set *rs); +int start_restripe(struct raid_set *rs); +void queue_bio(struct raid_set *rs, struct bio *bio, int rw); +struct bio * split_bio( + struct bio *bio, + unsigned int size, + unsigned short *idx, + unsigned int *length, + unsigned int *offset); +int raid_status(struct dm_target *ti, status_type_t type, + char *result, unsigned int maxlen); + +int alloc_raid_set(struct dm_target *ti, + unsigned int argc, + char **argv, + struct raid_set **raid); +void free_raid_set(struct raid_set *rs); +void raid_suspend(struct dm_target *ti); +void raid_resume(struct dm_target *ti); +int CountBits(unsigned long *lptr, int size); +void process_raid5_io(struct raid_set *rs); + +#endif diff --git a/src/nwnss/nwraid/nwraid0.c b/src/nwnss/nwraid/nwraid0.c new file mode 100644 index 0000000..52fdf20 --- /dev/null +++ b/src/nwnss/nwraid/nwraid0.c @@ -0,0 +1,2470 @@ +/* + * Copyright (C) 2004-2005 Novell, Inc. + * + * This file is released under the GPL. + */ + +#include "dm.h" +#include "dm-bio-list.h" +#include "dm-io.h" +#include "dm-log.h" +#include "kcopyd.h" + +//#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nwraid.h" +#include "dmio.h" + +#define DM_MSG_PREFIX "nwraid0" + +static int io_callback(struct bio *bio, unsigned int done, int error); + +typedef struct iocontext { + struct iocontext *link; + struct raid_set *rs; + void *private; + bio_end_io_t *endio; + unsigned long group; +}iocontext; + +struct iocontext_block { + struct iocontext_block *next; + iocontext list[1]; +}; + +#define IOBLOCK_COUNT (4068 / sizeof(iocontext)) + +static struct workqueue_struct *_kraid_wq; +static struct work_struct _kraid_work; +static atomic_t wakecount; + +void wake(struct raid_set *rs) +{ + if (atomic_dec_and_test(rs->wakecount)) { + queue_work(rs->wq, rs->work); + } +} + +static int alloc_io_context(struct raid_set *rs) +{ + int i; + struct iocontext_block *block; + iocontext *io; + unsigned long flags; + + if ((block = kmalloc(4072, GFP_KERNEL)) != NULL) { + + spin_lock_irqsave(&rs->irqlock, flags); + for (i=IOBLOCK_COUNT, io=block->list; i>0; i--, io++) { + io->rs = rs; + io->link = rs->iolist; + rs->iolist = io; + } + block->next = rs->ioblocklist; + rs->ioblocklist = block; + spin_unlock_irqrestore(&rs->irqlock, flags); + +// printk(KERN_ALERT"NWRAID0: Allocated io context block\n"); + return(0); + } + else + return(-ENOMEM); +} + +static int get_context(struct raid_set *rs, + struct bio *bio, + uint32_t group) +{ + iocontext *context; + unsigned long flags; + + spin_lock_irqsave(&rs->irqlock, flags); + if ((context = rs->iolist) == NULL) { + spin_unlock_irqrestore(&rs->irqlock, flags); + alloc_io_context(rs); + spin_lock_irqsave(&rs->irqlock, flags); + if ((context = rs->iolist) == NULL) { + spin_unlock_irqrestore(&rs->irqlock, flags); +// printk(KERN_ALERT"NWRAID0: No context messages\n"); + return(-ENOMEM); + } + } + rs->iolist = context->link; + spin_unlock_irqrestore(&rs->irqlock, flags); + + context->endio = bio->bi_end_io; + context->private = bio->bi_private; + context->group = group; + bio->bi_end_io = (bio_end_io_t*) io_callback; + bio->bi_private = (void*) context; + + return(0); +} + +int flush_log(struct raid_set *rs) +{ + + unsigned int i, r = 0, temp; + struct io_region io; + struct element *e; + raid_stamp_t *stamp; + unsigned char *buffer; + unsigned long ebits; + + if (rs->flags & DEACTIVE_FLAG) { + return(-EPERM); + } +// printk(KERN_ALERT"NWRAID: flushing log.\n"); + if ((buffer = vmalloc(1024)) == NULL) { +// printk(KERN_ALERT"NWRAID: flushing log errored out.\n"); + return(-ENOMEM); + } + + rs->flags &= ~FLUSH_FLAG; + rs->stamp.stamptime++; + + stamp = (raid_stamp_t*) buffer; + + memset(buffer, 0, 1024); + memcpy(buffer, &rs->stamp, sizeof(raid_stamp_t)); + if (rs->stamp.raidtype == RAID5) { + memcpy(&buffer[512], rs->bitmap, 512); + } + + for (i = 0; i < rs->nr_elements; i++) { + if ((test_bit(i, &rs->loadedmap)) && + (i != rs->stamp.missingelement)) { + + e = &rs->elements[i]; + + io.bdev = e->flush_dev->bdev; + io.sector = e->flush_offset; + io.count = 2; + stamp->elementindex = i; + temp = dm_io_sync_vm(1, &io, WRITE, + buffer, &ebits); + if ((temp) && (!r)) + r = temp; + } + } + vfree(buffer); + + dm_table_flush_all(rs->ti->table); + return(r); +} + +int refresh_log(struct raid_set *rs) +{ + int r=-ENODATA, i; + struct io_region io; + unsigned long ebits; + raid_stamp_t *stamp; + struct element *e; + + stamp = vmalloc(512); + if (stamp == NULL) { + return -ENOMEM; + } + + printk(KERN_ALERT"NWRAID: Refreshing log.\n"); + dm_table_flush_all(rs->ti->table); + + for (i=0; iloadedmap)) { + io.bdev = rs->elements[i].flush_dev->bdev; + io.sector = rs->elements[i].flush_offset; + io.count = 1; + + r = dm_io_sync_vm(1, &io, READ, stamp, &ebits); +// printk(KERN_ALERT"NWRAID: Read stamp ccode = %d\n", r); + + if (r == 0) { + if ((stamp->version != RAID_VERSION) || + (memcmp(&stamp->stamptext, "RaId_PaRtItIoN", 14) != 0) || + (stamp->identifier != rs->stamp.identifier)) { + + printk(KERN_ALERT"NWRAID: Invalid stamp\n"); + r = -ENODATA; + continue; + } + } + +// printk(KERN_ALERT"NWRAID: Stamp times rs=%d, stamp=%d\n", +// rs->stamp.stamptime, stamp->stamptime); + if ((r == 0) && + (rs->stamp.stamptime < stamp->stamptime)) { + + /* Delete out any elements that are gone. */ + if ((rs->stamp.missingelement == -1) && + (stamp->missingelement != -1)) { + + e = &rs->elements[stamp->missingelement]; + dm_put_device(rs->ti, e->dev); + dm_put_device(rs->ti, e->flush_dev); + e->dev = NULL; + e->flush_dev = NULL; + e->offset = 0; + e->flush_offset = 0; + rs->nr_elements--; + clear_bit(stamp->missingelement, &rs->loadedmap); + clear_bit(stamp->missingelement, &rs->activemap); +// printk(KERN_ALERT"NWRAID: Element count=%d\n",rs->nr_elements); + } + /* Copy in the information from the newer stamp. */ + memcpy(&rs->stamp, stamp, sizeof(raid_stamp_t)); + +// printk(KERN_ALERT"NWRAID: Stamp Updated\n"); + } + } + } + +// printk(KERN_ALERT"NWRAID: type = %d\n", rs->stamp.raidtype); +// printk(KERN_ALERT"NWRAID: ecount = %d\n", rs->stamp.elementcount); +// printk(KERN_ALERT"NWRAID: old = %d\n", rs->stamp.oldelementcount); +// printk(KERN_ALERT"NWRAID: missing = %x\n", rs->stamp.missingelement); +// printk(KERN_ALERT"NWRAID: cap = %d\n", rs->stamp.capacity); +// printk(KERN_ALERT"NWRAID: last = %d\n", rs->stamp.lastblock); +// printk(KERN_ALERT"NWRAID: flush = %d\n", rs->stamp.flushed_block); +// printk(KERN_ALERT"NWRAID: groups = %d\n", rs->stamp.bitmapsize); +// printk(KERN_ALERT"NWRAID: resync = %d\n", rs->stamp.resyncparityflag); +// if ((rs->stamp.resyncparityflag) && (rs->bitmap)) { +// printk(KERN_ALERT"NWRAID: bitmap count = %d\n", CountBits(rs->bitmap, rs->stamp.bitmapsize)); +// } + + vfree(stamp); + return(r); +} + +void AdjustLastBlock( + struct raid_set *rs, + struct bio *bio) +{ + struct PCBootSectorDef *mbr; + unsigned long i, temp, stripe, endsector = 0; + + mbr = kmap_atomic(bio->bi_io_vec[bio->bi_idx].bv_page, KM_USER1); + + if (mbr->signature != 0xAA55) + { + kunmap_atomic(mbr, KM_USER1); + return; + } + + /* If there is a signature, then we need to restripe at least + ** the first block */ + if (rs->stamp.raidtype == RAID5) + endsector = 1 << rs->stamp.raidstripeshift; + + for (i=0; i<4; i++) + { + if (mbr->partition[i].sysflag != 0) + { + temp = mbr->partition[i].beginningsector + + mbr->partition[i].numberofsectors; + + if (temp > endsector) + endsector = temp; + } + } + + kunmap_atomic(mbr, KM_USER1); + + if (rs->stamp.raidtype == RAID0) { + /* See if it is <= MBR or first stripe (that doesn't need restripe)*/ + temp = (rs->stamp.oldelementcount << rs->stamp.raidstripeshift); + if (temp<32) {temp = 32;} + if (endsector <= temp) { endsector = 0; } + } + + if (endsector != 0) + { + /* Round up to the nearest block */ + endsector--; + rs->stamp.lastblock = endsector >> rs->stamp.raidstripeshift; + + if (rs->stamp.raidtype == RAID5) + { + /* Now round it to the new stripe size. */ + i = rs->stamp.elementcount - 1; + stripe = rs->stamp.lastblock / i; + temp = (stripe * i); + temp += (i-1); + rs->stamp.lastblock = temp; + + if (rs->stamp.resyncparityflag) { + temp = stripe * rs->stamp.elementcount; + rs->lastblock = temp += i; + } + } + } + else + { + rs->stamp.oldelementcount = rs->stamp.elementcount; + + if (rs->stamp.resyncparityflag) + { + rs->stamp.resyncparityflag = 0; + rs->stamp.missingelement = -1; + } + + if (rs->stamp.raidtype == RAID5) + { + rs->stamp.capacity = + rs->stamp.elementsize * (rs->stamp.oldelementcount - 1); + } + else + { + rs->stamp.capacity = + rs->stamp.elementsize * rs->stamp.oldelementcount; + } + + rs->stamp.lastblock = + rs->stamp.flushed_block = + rs->stamp.capacity >> rs->stamp.raidstripeshift; + + } + + rs->flags |= FLUSH_FLAG; + return; +} + +/* CheckGroupLock checks to see if we need to get a lock during a +** restripe. Return codes are as follows: +** 0 = OK, no lock needed. +** 1 = Lock needed and received. +** 2 = Unable to get the lock. +** 3 = No lock, but need new disk configuration. +*/ + +int CheckGroupLock( + struct raid_set *rs, + sector_t lastsector, + unsigned long group) +{ + int ccode = 0; + unsigned long flags; + sector_t block; + +// printk(KERN_ALERT"NWRAID: Enter Check lock\n"); + + if (rs->restripestate > INIT_RESTRIPE) + { + spin_lock(&rs->rlock); + /* First, see if we can get a lock on the group. */ + if (rs->flags & RESYNC_FLAG) + { + /* If the block is already restriped, no need to lock. */ + if (!(test_bit(group, rs->bitmap))) + { + /* Need to lock it. */ + if (group != rs->lockedgroup) + { + spin_lock_irqsave(&rs->irqlock, flags); + rs->lockmapcount[group]++; + spin_unlock_irqrestore(&rs->irqlock, flags); + ccode = 1; + } + else + { + ccode = 2; + } + } + } + else + { + /* Round the block to the last completed stripe. */ + /* If below the restripe zone, no need to lock. */ + block = rs->completed_block; + flags = sector_div(block, (rs->stamp.elementcount - 1)); + block = rs->completed_block - flags; + + if ((lastsector >> rs->stamp.raidstripeshift) < block) + { + ccode = 3; + } + else + { + if ((group <= rs->lockedgroup + 2) || + (rs->lockmapcount[group] == 65535)) + { + ccode = 2; + } + else + { + spin_lock_irqsave(&rs->irqlock, flags); + rs->lockmapcount[group]++; + spin_unlock_irqrestore(&rs->irqlock, flags); + ccode = 1; + } + } + } + spin_unlock(&rs->rlock); + } + else + { + if (rs->stamp.oldelementcount != rs->stamp.elementcount) + { + /* If below the restripe zone, no need to lock. */ + block = rs->completed_block; + flags = sector_div(block, (rs->stamp.elementcount - 1)); + block = rs->completed_block - flags; + + if ((lastsector >> rs->stamp.raidstripeshift) < block) + { + ccode = 3; + } + } + } +// printk(KERN_ALERT"NWRAID: Check lock=%d group=%d count=%d\n", +// ccode, group, rs->lockmapcount[group]); + + return(ccode); +} + +void stop_IO(struct raid_set *rs) +{ + int j; + + printk(KERN_ALERT"NWRAID: Stop IO start count=%d\n", atomic_read(&rs->iopending)); + if (rs->stamp.raidtype == 0) { +// rs->flags |= NOIO_FLAG; + dm_table_flush_all(rs->ti->table); + } + else { + rs->flags |= NOIO_FLAG; + while ((j = atomic_read(&rs->iopending)) > 0) { + process_raid5_io(rs); + set_current_state(TASK_INTERRUPTIBLE); +// io_schedule(); + } + set_current_state(TASK_RUNNING); + } + printk(KERN_ALERT"NWRAID: Stop IO complete\n"); +} + +void start_IO(struct raid_set *rs) +{ + printk(KERN_ALERT"NWRAID: Start IO\n"); + rs->flags &= ~NOIO_FLAG; + wake(rs); +} + +/* + * Conversion fns + */ + +/*----------------------------------------------------------------- + * Bitmap functions + *---------------------------------------------------------------*/ + +/*----------------------------------------------------------------- + * Restripe. + *---------------------------------------------------------------*/ +void free_restripe(struct raid_set *rs) +{ + int i; + struct engine *engine; + struct page_list *list; + + rs->read = NULL; + rs->writehead = NULL; + rs->writetail = NULL; + rs->completehead = NULL; + rs->completetail = NULL; + rs->parity = NULL; + + engine = rs->engine; + if (engine != NULL) { + for (i=0; ienginecount; i++, engine++) { + list = engine->list; + while (list) { + if (list->page != NULL) { + ClearPageLocked(list->page); + __free_page(list->page); + } + list = list->next; + } + if (engine->list) { + kfree(engine->list); + } + } + + kfree(rs->engine); + rs->engine = NULL; + } + + if (rs->lockmapcount != NULL) { + kfree(rs->lockmapcount); + rs->lockmapcount = NULL; + } + + if (rs->map != NULL) { + kfree(rs->map); + rs->map = NULL; + } + + if (rs->readmap != NULL) { + kfree(rs->readmap); + rs->readmap = NULL; + } + + if (rs->groupmap != NULL) { + kfree(rs->groupmap); + rs->groupmap = NULL; + } + + rs->flags &= ~RESTRIPE_ABORT; + +} + +int stop_restripe(struct raid_set *rs) +{ + struct engine *list, *engine; + struct ReadMap *readmap; + struct RestripeMap *map; + unsigned long flags; + int i; + + if (rs->restripestate == NO_RESTRIPE) + return(0); + + if (rs->restripestate != STOPPING) { + + rs->flags |= RESTRIPE_ABORT; + + printk(KERN_ALERT"NWRAID: Stop Restripe start engine count = %d\n",rs->restripe_count); + /* Free up all the engines in the list */ + spin_lock_irqsave(&rs->irqlock, flags); + list = rs->writehead; + rs->writehead = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + if (list) { + spin_lock(&rs->rlock); + while (list) { + engine = list; + list = list->link; + engine->link = rs->read; + rs->read = engine; + rs->restripe_count--; +// printk(KERN_ALERT"NWRAID: decrement writehead count = %d\n",rs->restripe_count); + } + spin_unlock(&rs->rlock); + } + + /* Free up any engines that might be in the maps. */ + if (rs->readmap) { + spin_lock(&rs->rlock); + readmap = rs->readmap; + for (i=rs->readmapcount; i>0; i--, readmap++) { + if (readmap->stripe != -1) { + if (readmap->engine) { + readmap->engine->link = rs->read; + rs->read = readmap->engine; + rs->restripe_count--; +// printk(KERN_ALERT"NWRAID: decrement readmap engine count = %d\n",rs->restripe_count); + } + while (readmap->link) { + engine = readmap->link; + readmap->link = engine->link; + engine->link = rs->read; + rs->read = engine; + rs->restripe_count--; +// printk(KERN_ALERT"NWRAID: decrement readmap list count = %d\n",rs->restripe_count); + } + readmap->stripe = -1; + } + } + spin_unlock(&rs->rlock); + } + if (rs->map) { + spin_lock(&rs->rlock); + map = rs->map; + for (i=rs->stamp.elementcount; i>0; i--, map++) { + if (map->stripe != -1) { + if (map->engine) { + map->engine->link = rs->read; + rs->read = map->engine; + rs->restripe_count--; +// printk(KERN_ALERT"NWRAID: decrement map engine count = %d\n",rs->restripe_count); + } + map->stripe = -1; + } + } + spin_unlock(&rs->rlock); + } + +// printk(KERN_ALERT"NWRAID: Stop Restripe State = %d, Count = %d\n", +// rs->restripestate, rs->restripe_count); + + /* Wait for other engines to return */ + while (rs->restripestate == INIT_RESTRIPE) { + + set_current_state(TASK_INTERRUPTIBLE); + io_schedule(); + } + set_current_state(TASK_RUNNING); + } + + if (rs->restripe_count != 0) { + /* Keep processing until all engines are done. */ + rs->restripestate = STOPPING; + wake(rs); + return(0); + } + +// printk(KERN_ALERT"NWRAID: Stop Restripe count = 0\n"); + + stop_IO(rs); + + spin_lock(&rs->rlock); + + rs->restripestate = NO_RESTRIPE; + if (rs->flags & RESYNC_FLAG) { + rs->flags &= ~RESYNC_FLAG; + i = 0; + } + else { + i = 1; + } + + free_restripe(rs); + + spin_unlock(&rs->rlock); + + start_IO(rs); + + printk(KERN_ALERT"NWRAID: Stop Restripe complete\n"); + + rs->stamp.flushed_block = rs->completed_block; + rs->flags |= FLUSH_FLAG; + wake(rs); + + if ((rs->stamp.raidtype == RAID5) && + (i) && + (rs->stamp.flushed_block == rs->stamp.lastblock)) { + + start_restripe(rs); + } + + return(0); +} + + +int start_restripe(struct raid_set *rs) +{ + int i, j, pages, restripedone=0; + struct engine *engine; + sector_t block; + struct page_list *list; + + printk(KERN_ALERT"NWRAID: Got to start_restripe \n"); + + i = rs->stamp.elementcount; + if (rs->stamp.missingelement != -1) { + i--; + } + + if ((!(rs->flags & RESTRIPE_ENABLED)) || (rs->nr_elements < i)) + { + printk(KERN_ALERT"NWRAID: Restripe not permitted \n"); + return(-EPERM); + } + + if ((rs->stamp.flushed_block >= rs->stamp.lastblock) || + (rs->stamp.oldelementcount == rs->stamp.elementcount)){ + restripedone = 1; + } + + if (rs->stamp.raidtype == RAID5) + { + if ((rs->stamp.resyncparityflag) && (restripedone)) + { + if ((rs->stamp.missingelement > rs->stamp.elementcount) || + (!(test_bit(rs->stamp.missingelement, &rs->activemap)))) { + printk(KERN_ALERT"NWRAID: Resync aborted. Element not loaded.\n"); + return(-EPIPE); + } + } + } + + spin_lock(&rs->rlock); + + /* Check to see if we are already in sync */ + i = 0; + if (restripedone){ + + rs->stamp.oldelementcount = rs->stamp.elementcount; + rs->flags |= FLUSH_FLAG; + + if ((rs->stamp.raidtype != RAID5) || + (!(rs->stamp.resyncparityflag)) || + (CountBits(rs->bitmap, rs->stamp.bitmapsize) == rs->stamp.bitmapsize)) { + rs->stamp.resyncparityflag = 0; + rs->stamp.missingelement = -1; + rs->restripestate = NO_RESTRIPE; + rs->ti->len = rs->stamp.capacity; + rs->flags |= INSYNC_FLAG; + rs->restripe_block = + rs->stamp.lastblock = + rs->stamp.flushed_block = + rs->completed_block = + rs->stamp.capacity >> rs->stamp.raidstripeshift; + spin_unlock(&rs->rlock); + wake(rs); + printk(KERN_ALERT"NWRAID: Restripe in sync\n"); + return(0); + } + else { + i = 1; + } + } + + if (i) { + printk(KERN_ALERT"NWRAID: Resyncing\n"); + } + else { + printk(KERN_ALERT"NWRAID: Restriping\n"); + } + + if (rs->restripestate != NO_RESTRIPE) { + spin_unlock(&rs->rlock); + printk(KERN_ALERT"NWRAID: Restripe running=%d\n",rs->restripestate); + return(0); + } + + rs->flags &= ~(RESTRIPE_ABORT | RESYNC_FLAG | RESTRIPE_RESTART); + if (i) { + rs->flags |= RESYNC_FLAG; + } + + rs->enginecount = rs->stamp.elementcount * 2; +// rs->enginecount = rs->stamp.oldelementcount * 2; +// if (rs->enginecount < MIN_ENGINE_COUNT) { +// rs->enginecount = MIN_ENGINE_COUNT; +// } + + rs->restripestate = INIT_RESTRIPE; + + spin_unlock(&rs->rlock); + + if (rs->engine == NULL) + rs->engine = kmalloc((sizeof(struct engine) * rs->enginecount), + GFP_KERNEL); + if (rs->engine == NULL) { + rs->restripestate = NO_RESTRIPE; + printk(KERN_ALERT"NWRAID: Restripe aborted. Alloc failure.\n"); + return(-ENOMEM); + } + + if (rs->lockmapcount == NULL) + rs->lockmapcount = kmalloc(rs->stamp.bitmapsize * 2, GFP_KERNEL); + + if (rs->lockmapcount == NULL) { + rs->restripestate = NO_RESTRIPE; + kfree(rs->engine); + printk(KERN_ALERT"NWRAID: Restripe aborted. Alloc failure.\n"); + return(-ENOMEM); + } + + engine = rs->engine; + pages = dm_div_up(rs->stripesize,8); +// printk(KERN_ALERT"NWRAID: Buffer pages = %d RSize = %d\n", pages, rs->stripesize); + + for (i=0; ienginecount; i++, engine++) { + engine->rs = rs; + engine->list = list = kmalloc(pages * sizeof(struct page_list), GFP_KERNEL); + if (list) { + j = 0; + while (j < pages) { + list->next = NULL; + if ((list->page = alloc_page(GFP_KERNEL)) == NULL) { + free_restripe(rs); + return(-ENOMEM); + } + SetPageLocked(list->page); + j++; + if (j < pages) { + list->next = &engine->list[j]; + } + list++; + } + } + else { + free_restripe(rs); + printk(KERN_ALERT"NWRAID: Restripe aborted. Alloc failure.\n"); + return(-ENOMEM); + } + engine->link = rs->read; + rs->read = engine; + } + + rs->restripe_count = 0; + memset(rs->lockmapcount, 0, rs->stamp.bitmapsize * 2); + + /* If RAID 5, allocate a restripe map. */ + if (rs->stamp.raidtype == RAID5) + { + rs->map = kmalloc( + (rs->stamp.elementcount * sizeof(struct RestripeMap)), + GFP_KERNEL); + + if (rs->map == NULL) + { + free_restripe(rs); + rs->restripestate = NO_RESTRIPE; + printk(KERN_ALERT"NWRAID: Restripe aborted. Alloc failure.\n"); + return(-ENOMEM); + } + + rs->readmapcount = rs->stamp.oldelementcount; + + rs->readmap = kmalloc( + (rs->readmapcount * sizeof(struct ReadMap)), + GFP_KERNEL); + + if (rs->readmap == NULL) + { + free_restripe(rs); + rs->restripestate = NO_RESTRIPE; + printk(KERN_ALERT"NWRAID: Restripe aborted. Alloc failure.\n"); + return(-ENOMEM); + } + + if (rs->groupstripes != 0) + { + rs->groupmap = kmalloc( + (rs->stamp.elementcount * sizeof(struct GroupMap)), + GFP_KERNEL); + + if (rs->groupmap == NULL) + { + free_restripe(rs); + rs->restripestate = NO_RESTRIPE; + printk(KERN_ALERT"NWRAID: Restripe aborted. Alloc failure.\n"); + return(-ENOMEM); + } + + memset(rs->groupmap, 0xFF, + (rs->stamp.elementcount * sizeof(struct GroupMap))); + } + + memset(rs->map, 0xFF, + (rs->stamp.elementcount * sizeof(struct RestripeMap))); + + memset(rs->readmap, 0xFF, + (rs->readmapcount * sizeof(struct ReadMap))); + + if (rs->flags & RESYNC_FLAG) { +// rs->stamp.flushed_block = 0; + rs->lastblock = rs->stamp.bitmapsize; + rs->lastblock <<= rs->stamp.groupshift; + rs->lastblock *= rs->stamp.elementcount; + rs->lastblock--; + +// rs->lastblock += (rs->stamp.elementcount - 2); +// sector_div(rs->lastblock, (rs->stamp.elementcount - 1)); +// rs->lastblock *= (rs->stamp.elementcount - 1); +// rs->lastblock += (rs->stamp.elementcount - 2); + + rs->laststripe = rs->lastblock; + sector_div(rs->laststripe, rs->stamp.elementcount); + } + else { + rs->lastblock = rs->stamp.lastblock; + rs->laststripe = rs->lastblock; + sector_div(rs->laststripe, (rs->stamp.elementcount - 1)); + + /* If we are restriping and have a missing element, make sure the bitmap is cleared. */ + if (rs->stamp.missingelement != -1) { + memset(rs->bitmap, 0, 512); + /* Adjust last block to end on a read stripe */ + rs->lastblock += (rs->stamp.oldelementcount - 2); + sector_div(rs->lastblock, (rs->stamp.oldelementcount - 1)); + rs->lastblock *= (rs->stamp.oldelementcount - 1); + rs->lastblock += (rs->stamp.oldelementcount - 2); + } + } + } + else { + rs->lastblock = rs->stamp.lastblock; + rs->laststripe = rs->lastblock; + sector_div(rs->laststripe, rs->stamp.elementcount); + } + + stop_IO(rs); + + if (rs->flags & RESYNC_FLAG) { + rs->restripe_block = 0; + } + else { + rs->restripe_block = rs->stamp.flushed_block; + } + + /* The first stripe of the old count of RAID 0 doesn't need restriped. */ + if (rs->stamp.raidtype == RAID0) + { + if (rs->restripe_block < rs->stamp.oldelementcount) + rs->restripe_block = rs->stamp.oldelementcount; + } + + if ((rs->stamp.raidtype == RAID5) && + (!(rs->flags & RESYNC_FLAG)) && + (rs->restripe_block != 0)) + { + /* We need to start on a stripe. */ + block = rs->restripe_block; + rs->restripe_block -= sector_div(block, (rs->stamp.elementcount - 1)); + rs->stamp.flushed_block = rs->completed_block = rs->restripe_block; + /* Readjust restripe block to start at the old element stripe */ + if (rs->stamp.missingelement != -1) { + block = rs->restripe_block; + rs->restripe_block -= sector_div(block, (rs->stamp.oldelementcount - 1)); + } + + block = rs->restripe_block; + sector_div(block, (rs->stamp.oldelementcount - 1)); + rs->lockedgroup = block >> rs->stamp.groupshift; + } + else { + if (rs->flags & RESYNC_FLAG) { + rs->lockedgroup = -1; + } + else { + rs->stamp.flushed_block = rs->completed_block = rs->restripe_block; + rs->lockedgroup = rs->restripe_block >> rs->stamp.groupshift; + } + } + + if (rs->flags & RESTRIPE_ABORT) { + stop_restripe(rs); + printk(KERN_ALERT"NWRAID: Restripe aborted\n"); + start_IO(rs); + return(-EPERM); + } + + rs->restripestate = RESTRIPEING; + start_IO(rs); + + wake(rs); + + printk(KERN_ALERT"NWRAID: Restripe started start="SECTOR_FORMAT" last="SECTOR_FORMAT" last stripe="SECTOR_FORMAT"\n", + rs->restripe_block, rs->lastblock, rs->laststripe); + +// printk(KERN_ALERT"NWRAID: Restripe started\n"); + return(0); +} + +static void restripe_complete(struct raid_set *rs) +{ + struct engine *list, *engine, *temp; + int done=0; + unsigned long flags; + + while (1) { + spin_lock_irqsave(&rs->irqlock, flags); + if ((list = rs->completehead) == NULL) { + spin_unlock_irqrestore(&rs->irqlock, flags); + return; + } + rs->completehead = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + spin_lock(&rs->rlock); + + while (list) { + if (rs->flags & RESTRIPE_ABORT) { + engine = list; + list = list->link; + engine->link = rs->read; + rs->read = engine; + rs->restripe_count--; + continue; + } + + if (list->block == rs->completed_block) { +// printk(KERN_ALERT"NWRAID: Restripe complete block " SECTOR_FORMAT "\n", list->block); + engine = list; + list = list->link; + engine->link = rs->read; + rs->read = engine; + rs->completed_block++; + rs->restripe_count--; + continue; + } + else { + temp = list; + engine = list->link; + while (engine) { + if (engine->block == rs->completed_block) { +// printk(KERN_ALERT"NWRAID: Restripe complete block " SECTOR_FORMAT "\n", engine->block); + temp->link = engine->link; + engine->link = rs->read; + rs->read = engine; + rs->completed_block++; + rs->restripe_count--; + break; + } + temp = engine; + engine = engine->link; + } + if (engine == NULL) { + break; + } + } + } + + if (rs->completed_block > rs->stamp.lastblock) { + done = 1; + rs->restripestate = DONE; + rs->flags |= (INSYNC_FLAG | FLUSH_FLAG); +// rs->stamp.flushed_block = rs->stamp.lastblock; + rs->stamp.oldelementcount = rs->stamp.elementcount; + + rs->ti->len = + rs->stamp.capacity = + rs->stamp.elementsize * rs->stamp.oldelementcount; + + rs->restripe_block = + rs->stamp.lastblock = + rs->stamp.flushed_block = + rs->completed_block = + rs->stamp.capacity >> rs->stamp.raidstripeshift; + } + + spin_unlock(&rs->rlock); + + if (done) { + printk(KERN_ALERT"NWRAID: Restripe Complete\n"); + wake(rs); + dm_table_event(rs->ti->table); + } + + if (list) { + /* Put the extras back on the list and return */ + spin_lock_irqsave(&rs->irqlock, flags); + while (list) { + engine = list; + list = list->link; + if (rs->completehead == NULL) + rs->completetail = engine; + engine->link = rs->completehead; + rs->completehead = engine; + } + spin_unlock_irqrestore(&rs->irqlock, flags); + return; + } + } +} + +static void restripe_write_callback(unsigned long error, void *context) +{ + struct engine *engine = (struct engine*) context; + struct raid_set *rs = engine->rs; + unsigned long flags; + + if (error) { + rs->flags |= RESTRIPE_ABORT; + } + +// printk(KERN_ALERT"NWRAID: Restripe write callback " SECTOR_FORMAT "\n", engine->block); + spin_lock_irqsave(&rs->irqlock, flags); + if (rs->completehead == NULL) { + rs->completehead = rs->completetail = engine; + } + else { + rs->completetail->link = engine; + rs->completetail = engine; + } + engine->link = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + wake(rs); +} + +static void restripe_write(struct raid_set *rs) +{ + struct engine *list, *engine; + unsigned long flags; + + while (1) { + spin_lock_irqsave(&rs->irqlock, flags); + if ((list = rs->writehead) == NULL) { + spin_unlock_irqrestore(&rs->irqlock, flags); + return; + } + rs->writehead = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + while (list) { + engine = list; + list = list->link; +// printk(KERN_ALERT"NWRAID: Restripe write block " SECTOR_FORMAT "\n", engine->block); + if (rs->flags & RESTRIPE_ABORT) { + spin_lock(&rs->rlock); + engine->link = rs->read; + rs->read = engine; + rs->restripe_count--; + spin_unlock(&rs->rlock); + continue; + } + + if (dm_io_async(1, &engine->to, WRITE, engine->list, 0, + restripe_write_callback, engine) != 0) { + spin_lock(&rs->rlock); + rs->flags |= RESTRIPE_ABORT; + engine->link = rs->read; + rs->read = engine; + rs->restripe_count--; + spin_unlock(&rs->rlock); + } + } + } +} + +static void restripe_read_callback(unsigned long error, void *context) +{ + struct engine *engine = (struct engine*) context; + struct raid_set *rs = engine->rs; + unsigned long flags; + + if (error) { + rs->flags |= RESTRIPE_ABORT; + } + +// printk(KERN_ALERT"NWRAID: Restripe read callback block " SECTOR_FORMAT "\n", engine->block); + spin_lock_irqsave(&rs->irqlock, flags); + if (rs->writehead == NULL) { + rs->writehead = rs->writetail = engine; + } + else { + rs->writetail->link = engine; + rs->writetail = engine; + } + engine->link = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + wake(rs); +} + +static void do_raid0_restripe(struct raid_set *rs) +{ + sector_t block, checkblock, stripe; + unsigned long count, element, shift, group; + struct engine *engine; + struct io_region from; + + while (1) { + + if (rs->flags & RESTRIPE_ABORT) + return; + +// printk(KERN_ALERT"NWRAID: Do Restripe\n"); + spin_lock(&rs->rlock); + + if ((engine = rs->read) == NULL) { +// printk(KERN_ALERT"NWRAID: No engines available\n"); + spin_unlock(&rs->rlock); + return; + } + rs->read = engine->link; + + /* Find the next region */ + block = rs->restripe_block++; +// printk(KERN_ALERT"NWRAID: Restriping block=" SECTOR_FORMAT " last=%d\n", +// block, rs->stamp.lastblock); + if (block > rs->stamp.lastblock) + { + /* We are done! */ + rs->restripe_block--; + rs->restripestate = DONE_SENDING; + spin_unlock(&rs->rlock); + return; + } + + engine->block = block; + rs->restripe_count++; + + /* Calculate the write sector and element. */ + shift = rs->stamp.raidstripeshift; + count = rs->stamp.elementcount; + stripe = block; + element = sector_div(stripe, count); + + group = (uint32_t) stripe >> rs->stamp.groupshift; + if (group > rs->lockedgroup) { + rs->lockedgroup = group; +// printk(KERN_ALERT"NWRAID: Restriping lockgroup=%d\n", group); + + if (rs->lockmapcount[group] != 0) { + spin_unlock(&rs->rlock); + stop_IO(rs); + rs->lockmapcount[group] = 0; + start_IO(rs); + spin_lock(&rs->rlock); + } + } + + spin_unlock(&rs->rlock); + + engine->to.bdev = rs->elements[element].dev->bdev; + engine->to.sector = rs->elements[element].offset + (stripe << shift); + engine->to.count = rs->stripesize; + + /* Calculate the check block to see if it is time to flush. */ + count = rs->stamp.oldelementcount; + if (element >= count) + element = count - 1; + + checkblock = (stripe * count) + element; + if ((checkblock >= rs->stamp.flushed_block) + || ((rs->stamp.flushed_block - checkblock) > 4096)) + { +// printk(KERN_ALERT"NWRAID: Flush block=%d check=%d\n", +// block, checkblock); + if (rs->completed_block > rs->stamp.flushed_block) + rs->stamp.flushed_block = rs->completed_block-1; + flush_log(rs); + } + + /* Calculate the read sector and element. */ + stripe = block; + element = sector_div(stripe, count); + + from.bdev = rs->elements[element].dev->bdev; + from.sector = rs->elements[element].offset + (stripe << shift); + from.count = rs->stripesize; + + if (dm_io_async(1, &from, READ, engine->list, 0, + restripe_read_callback, engine) != 0) { + spin_lock(&rs->rlock); + rs->restripe_count--; + engine->link = rs->read; + rs->read = engine; + spin_unlock(&rs->rlock); + stop_restripe(rs); + return; + } + } +} + +/*----------------------------------------------------------------- + * Reads/Writes + *---------------------------------------------------------------*/ +void queue_bio(struct raid_set *rs, struct bio *bio, int rw) +{ + int wakeup = 0; + struct bio_list *bl; + +// printk(KERN_ALERT"NWRAID: queue_bio = %s\n", (rw == READ) ? "READ" : "WRITE"); + + if (rw == WRITE) { + bl= &rs->writes; + } + else if (rw == READ) { + bl= &rs->reads; + } + else { + bl= &rs->readas; + } + + spin_lock(&rs->lock); + wakeup = !(bl->head); + bio_list_add(bl, bio); + spin_unlock(&rs->lock); + + if (wakeup) + wake(rs); +} + +struct bio * split_bio( + struct bio *bio, + unsigned int size, + unsigned short *idx, + unsigned int *length, + unsigned int *offset) +{ + int count=0; + struct bio *new; + struct bio_vec *vec; + unsigned int tempsize; + unsigned int len; + + if (*length == 0) + return(NULL); + + tempsize = size; + + /* Do this once to get the count */ + if (*length > tempsize) + len = tempsize; + else + len = *length; + + vec = &bio->bi_io_vec[*idx]; + + while (tempsize) { + count++; + tempsize -= len; + if (tempsize) { + vec++; + len = vec->bv_len; + if (len > tempsize) + len = tempsize; + } + } + + if ((new = bio_alloc(GFP_NOIO, count)) == NULL) { + return(NULL); + } + + /* Fill in the new bio */ + new->bi_rw = bio->bi_rw; + new->bi_vcnt = count; + new->bi_size = size; + new->bi_max_vecs = count; + new->bi_private = bio; + + /* Repeat the process to fill out the bio */ + tempsize = size; + count = 0; + + if (*length > tempsize) + len = tempsize; + else + len = *length; + + vec = &bio->bi_io_vec[*idx]; + + while (tempsize) { + new->bi_io_vec[count].bv_page = vec->bv_page; + new->bi_io_vec[count].bv_len = len; + new->bi_io_vec[count].bv_offset = *offset; + + tempsize -= len; + if (tempsize) { + count++; + vec++; + *idx += 1; + *offset = vec->bv_offset; + len = vec->bv_len; + if (len > tempsize) { + len = tempsize; + } + } + else { + /* We are done with this bio. Set the values for the next one */ + if (len < vec->bv_len) { + /* Adjust the length and offset */ + *length -= len; + *offset += len; + } + else { + /* We finished this vec. Set up for the next. */ + if (*idx < bio->bi_vcnt) { + *idx += 1; + vec++; + *length = vec->bv_len; + *offset = vec->bv_offset; + } + else { + *length = 0; + } + } + } + } + return(new); +} + +static int MultiIOCallback(struct bio *clone, unsigned int done, int err) +{ + struct bio *bio = (struct bio*) clone->bi_private; + split_context *context = (split_context*) bio->bi_private; + struct raid_set *rs = context->rs; + int complete = 0; + unsigned long flags; + + +// printk(KERN_ALERT"NWRAID: Split callback = %x, bio=%x\n",clone, bio); + spin_lock_irqsave(&rs->irqlock, flags); + + context->count--; + if (err) { + if (context->err == 0) + context->err = -EIO; + } + + if (context->count == 0) { + complete = 1; + + if (context->group != -1) { + if (rs->lockmapcount[context->group] > 0) + rs->lockmapcount[context->group]--; + } + } + + spin_unlock_irqrestore(&rs->irqlock, flags); + + bio_put(clone); + + if (complete) { +// printk(KERN_ALERT"NWRAID: Split bio %x complete.\n", bio); + bio->bi_private = context->private; + bio_endio(bio, bio->bi_size, context->err); + kfree(context); + } + + return(0); +} + +static int io_callback(struct bio *bio, unsigned int done, int error) +{ + iocontext *context = (iocontext*) bio->bi_private; + struct raid_set *rs; + unsigned long flags; + + rs = context->rs; + bio->bi_private = context->private; + bio->bi_end_io = context->endio; + + spin_lock_irqsave(&rs->irqlock, flags); + + if (context->group != -1) { + if (rs->lockmapcount[context->group] > 0) + rs->lockmapcount[context->group]--; + } + + context->link = rs->iolist; + rs->iolist = context; + + spin_unlock_irqrestore(&rs->irqlock, flags); + + if (error) { + error = -EIO; + } + bio_endio(bio, bio->bi_size, error); + + return(0); +} + +static int do_raid0_io(struct raid_set *rs, + struct bio *bio) +{ + int rw = bio_rw(bio); + sector_t sector, block, stripe, iosector, offset; + unsigned int size; + unsigned int disks, shift, group, locked=0, element; + struct bio *clone; + unsigned int bv_len, bv_offset, bio_size; + unsigned short idx; + split_context *context; + + if (rs->flags & DEACTIVE_FLAG) { +// printk(KERN_ALERT"NWRAID0: Device not active\n"); + return(-EIO); + } + + if (rs->flags & (SUSPEND_FLAG | NOIO_FLAG)) { + queue_bio(rs, bio, rw); + return 0; + } + + disks = rs->stamp.oldelementcount; + if ((disks == 0) || (disks > rs->nr_elements)) /* (Bug 253595) */ + { + printk(KERN_ALERT"NWRAID0: Error, disk count = %d\n", disks); + return(-EIO); + } + + sector = bio->bi_sector - rs->ti->begin; + shift = rs->stamp.raidstripeshift; + stripe = block = sector >> shift; + element = sector_div(stripe, disks); + group = stripe >> rs->stamp.groupshift; + + /* If this is a sector 0 write, update the last block. */ + if ((sector == 0) && (rw == WRITE)) + { + AdjustLastBlock(rs, bio); + } + + /* Check to see if the block is in a restripe state or not . */ + if (!(rs->flags & INSYNC_FLAG)) + { + if ((locked = CheckGroupLock(rs, sector + (bio->bi_size >> 9), group)) > 1) + { + if (locked == 2) + { + /* Don't have the lock, so just link it. */ + queue_bio(rs, bio, rw); + return(0); + } + if (locked == 3) + { + disks = rs->stamp.elementcount; + if (disks == 0) + { + return(-EIO); + } + + stripe = block; + element = sector_div(stripe, disks); + if ((rs->restripestate != NO_RESTRIPE) && + (stripe > rs->laststripe)) + { + queue_bio(rs, bio, rw); + return(0); + } + + group = stripe >> rs->stamp.groupshift; + } + } + } + + offset = sector - (block << shift); + iosector = (stripe << shift) + offset; + size = ((1 << shift) - offset) << 9; /* size in bytes */ + + if (size < bio->bi_size) { + /* We need to split this up into multiple segments. */ +// printk(KERN_ALERT"NWRAID: Split bio %x size %d.\n", bio, bio->bi_size); + + /* Allocate a split context */ + context = kmalloc(sizeof(split_context), GFP_KERNEL); + if (context == NULL) { + /* Can't get the memory. queue, and exit */ + queue_bio(rs, bio, rw); + return(0); + } + + context->private = bio->bi_private; + context->rs = rs; + if (locked == 1) + context->group = group; + else + context->group = -1; + context->err = 0; + context->count = 0; + + idx = bio->bi_idx; + bio_size = bio->bi_size; + bv_len = bio->bi_io_vec[idx].bv_len; + bv_offset = bio->bi_io_vec[idx].bv_offset; + bio->bi_next = NULL; + + while (bio_size) { + clone = split_bio(bio, size, &idx, &bv_len, &bv_offset); + if (clone) { +// printk(KERN_ALERT"NWRAID: Clone successful = %x size %d\n", clone, clone->bi_size); + clone->bi_bdev = rs->elements[element].dev->bdev; + clone->bi_sector = rs->elements[element].offset + iosector; + clone->bi_next = bio->bi_next; + bio->bi_next = clone; + clone->bi_end_io = MultiIOCallback; + + context->count++; + bio_size -= size; + if (bio_size) { + size = 1 << (shift + 9); + if (size > bio_size) + size = bio_size; + + element++; + if (element == disks) + { + element = 0; + stripe++; + } + + iosector = (stripe << shift); + } + } + else { + /* Failed to get the clone, so return them, queue, and exit */ + while (bio->bi_next) { + clone = bio->bi_next; + bio->bi_next = clone->bi_next; + bio_put(clone); + } + + kfree(context); + queue_bio(rs, bio, rw); + printk(KERN_ALERT"NWRAID: Error splitting the bio.\n"); + return(0); + } + } + + bio->bi_private = context; + /* Now send all the clones */ + while (bio->bi_next) { + clone = bio->bi_next; + bio->bi_next = clone->bi_next; + generic_make_request(clone); + } + + return(0); + } + + if (locked == 1) { + if (get_context(rs, bio, group) != 0) { + queue_bio(rs, bio, rw); + return 0; + } + } + + bio->bi_bdev = rs->elements[element].dev->bdev; + bio->bi_sector = rs->elements[element].offset + iosector; + return(1); +} + +static void do_raid0_rw(struct raid_set *rs, struct bio *list) +{ + struct bio *bio; + int r; + + while (list != NULL) { +// printk(KERN_ALERT"NWRAID: Doing a delayed request.\n"); + bio = list; + list = bio->bi_next; + bio->bi_next = NULL; + if ((r = do_raid0_io(rs, bio)) == 1) { + generic_make_request(bio); + } + else if (r < 0) { + bio_endio(bio, bio->bi_size, r); + } + } +} + +/*----------------------------------------------------------------- + * Work + *---------------------------------------------------------------*/ +static LIST_HEAD(_raid_sets); +static DECLARE_RWSEM(_raid_sets_lock); + +static void do_raid(struct raid_set *rs) +{ + struct bio *reads, *writes; + + if (rs->flags & (SUSPEND_FLAG | NOIO_FLAG)) { + reads = NULL; + writes = NULL; + } + else { + spin_lock(&rs->lock); + reads = bio_list_get(&rs->reads); + writes = bio_list_get(&rs->writes); + spin_unlock(&rs->lock); + } + + if (rs->restripestate != NO_RESTRIPE) { + if (rs->writehead) { + restripe_write(rs); + } + + if (rs->completehead) { + restripe_complete(rs); + } + + if (rs->restripestate == RESTRIPEING) { + do_raid0_restripe(rs); + } + else if (rs->restripestate == DONE) + stop_restripe(rs); + } + + do_raid0_rw(rs, reads); + do_raid0_rw(rs, writes); + if (rs->flags & FLUSH_FLAG) { + flush_log(rs); + } + + dm_table_unplug_all(rs->ti->table); +} + +static void do_work(void *ignored) +{ + struct raid_set *rs; + + atomic_set(&wakecount, 1); + down_read(&_raid_sets_lock); + list_for_each_entry (rs, &_raid_sets, list) + do_raid(rs); + up_read(&_raid_sets_lock); +} + +/*----------------------------------------------------------------- + * Target functions + *---------------------------------------------------------------*/ +static void free_context(struct raid_set *rs) +{ + int i,j; + struct dm_target *ti = rs->ti; + struct RaidCacheDef *cache; + struct page *page; + +// printk(KERN_ALERT"NWRAID: Free Context\n"); + + if (!ti) { +// printk(KERN_ALERT"NWRAID: ti = NULL in free_context\n"); + return; + } + + ti->private = NULL; + + for (i=0; istamp.elementcount; i++) { + if (test_bit(i, &rs->loadedmap)) { + if (rs->elements[i].dev) { + dm_put_device(ti, rs->elements[i].dev); + rs->elements[i].dev = NULL; + } + if (rs->elements[i].flush_dev) { + dm_put_device(ti, rs->elements[i].flush_dev); + rs->elements[i].flush_dev = NULL; + } + } + } + + while (rs->cache) + { + cache = rs->cache; + rs->cache = cache->alloclink; + + for (j=0; jstamp.elementcount; j++) { + if ((page = cache->buffers[j].page) != NULL) { + ClearPageLocked(page); + __free_page(page); + } + } + kfree(cache); + } + + if (rs->bitmap) { +// printk(KERN_ALERT"NWRAID: Free bitmap\n"); + kfree(rs->bitmap); + } + +// printk(KERN_ALERT"NWRAID: Free rs\n"); + kfree(rs); +// printk(KERN_ALERT"NWRAID: Free Context complete\n"); +} + +static int get_raid(struct raid_set *rs, + struct dm_target *ti, + unsigned int raid, + char **argv) +{ + int r, index; + sector_t offset, foffset; + struct dm_dev *dev, *flush; + raid_stamp_t *stamp; + struct io_region io; + unsigned long ebits; + struct element *e; + char *buffer; + + index = rs->nr_elements * 2; + + if (sscanf(argv[index + 1], SECTOR_FORMAT, &offset) != 1) { + ti->error = "nwraid: Invalid offset"; + return -EINVAL; + } + + if (sscanf(argv[1], SECTOR_FORMAT, &foffset) != 1) { + ti->error = "nwraid: Invalid flush offset"; + return -EINVAL; + } + + if (dm_get_device(ti, argv[index], offset, rs->elementsize, + dm_table_get_mode(ti->table), + &dev)) { + ti->error = "nwraid: Device lookup failure"; + return -ENXIO; + } + + if (dm_get_device(ti, argv[0], foffset, 32, + dm_table_get_mode(ti->table), + &flush)) { + ti->error = "nwraid: Flush device lookup failure"; + dm_put_device(ti, dev); + return -ENXIO; + } + + /* Read the header stamp */ + io.bdev = flush->bdev; + io.sector = foffset; + io.count = 2; + + stamp = vmalloc(1024); + if (stamp == NULL) { + dm_put_device(ti, dev); + dm_put_device(ti, flush); + return -ENOMEM; + } + + r = dm_io_sync_vm(1, &io, READ, stamp, &ebits); +// printk(KERN_ALERT"NWRAID: Stamp ccode = %d\n", r); + + if (r == 0) { + printk(KERN_ALERT"NWRAID: Stamp = %s time=%d index=%d\n", + &stamp->stamptext, stamp->stamptime, stamp->elementindex); + if ((stamp->version == RAID_VERSION) && + (memcmp(&stamp->stamptext, "RaId_PaRtItIoN", 14) == 0)) { + + e = &rs->elements[stamp->elementindex]; + e->dev = dev; + e->offset = offset; + e->flush_dev = flush; + e->flush_offset = foffset; + set_bit(stamp->elementindex, &rs->loadedmap); + set_bit(stamp->elementindex, &rs->activemap); + } + else { + r = -ENODATA; + } + } + + if (r == 0) { + if (raid == 0) { + memcpy(&rs->stamp, stamp, sizeof(raid_stamp_t)); + if (stamp->raidtype == RAID5) { + if (!(rs->bitmap)) { + rs->bitmap = kmalloc(512, GFP_KERNEL); + } + if (rs->bitmap) { + buffer = (char*) stamp; + memcpy(rs->bitmap, &buffer[512], 512); + } + } + } + else { + /* See if we have newer data */ + if (rs->stamp.stamptime < stamp->stamptime) { + /* Read in the information from the newer stamp. */ + memcpy(&rs->stamp, stamp, sizeof(raid_stamp_t)); + if ((stamp->raidtype == RAID5) && (rs->bitmap)) { + buffer = (char*) stamp; + memcpy(rs->bitmap, &buffer[512], 512); + } + } + else { + /* if element is missing, see if the bitmap is cleared */ + if ((stamp->raidtype == RAID5) && + (rs->bitmap) && + (stamp->elementindex == rs->stamp.missingelement)) { + + buffer = (char*) stamp; + buffer = &buffer[512]; + if (CountBits((unsigned long*) buffer, rs->stamp.bitmapsize) == 0) { + /* This is a new element, so clear out the buffer */ + memset(rs->bitmap, 0, 512); + } + } + } + } + } + else { + dm_put_device(ti, dev); + dm_put_device(ti, flush); + } + + vfree(stamp); + +// printk(KERN_ALERT"NWRAID: Get Raid ccode = %d\n", r); + return r; +} + +static int add_raid_set(struct raid_set *rs) +{ + down_write(&_raid_sets_lock); + list_add_tail(&rs->list, &_raid_sets); + up_write(&_raid_sets_lock); + + return 0; +} + +static void del_raid_set(struct raid_set *rs) +{ + down_write(&_raid_sets_lock); + list_del(&rs->list); + up_write(&_raid_sets_lock); +} + +/* + * Create dirty log: log_type #log_parars + */ +//static struct dirty_log *create_dirty_log(struct dm_target *ti, +// unsigned int argc, char **argv, +// unsigned int *args_used) +//{ +// unsigned int param_count; +// struct dirty_log *dl; +// +// if (argc < 2) { +// ti->error = "nw-mirror: Insufficient mirror log arguments"; +// return NULL; +// } +// +// if (sscanf(argv[1], "%u", ¶m_count) != 1 || param_count != 1) { +// ti->error = "nw-mirror: Invalid mirror log argument count"; +// return NULL; +// } +// +// *args_used = 2 + param_count; +// +// if (argc < *args_used) { +// ti->error = "nw-mirror: Insufficient mirror log arguments"; +// return NULL; +// } +// +// dl = dm_create_dirty_log(argv[0], ti->len, param_count, argv + 2); +// if (!dl) { +// ti->error = "nw-mirror: Error creating mirror dirty log"; +// return NULL; +// } +// +// if (!_check_region_size(ti, dl->type->get_region_size(dl))) { +// ti->error = "nw-mirror: Invalid region size"; +// dm_destroy_dirty_log(dl); +// return NULL; +// } +// +// return dl; +//} + +/* + * Construct a mirror mapping: + * + * log_type #log_parars + * #mirrors [mirror_path offset]{2,} + * + */ + +#define DM_IO_PAGES 64 +int alloc_raid_set(struct dm_target *ti, + unsigned int argc, + char **argv, + struct raid_set **raid) +{ + int r; + unsigned int sharedflag; + unsigned int nr_elements, e, args_used = 2; + uint32_t temp, temp2; + sector_t size; + struct raid_set *rs; +// struct dirty_log *dl; + + *raid = NULL; + +// dl = create_dirty_log(ti, argc, argv, &args_used); +// if (!dl) +// return -EINVAL; + + printk(KERN_ALERT"NWRAID: Got to constructor. ti=%x argc=%d\n", ti, argc); + argv += args_used; + argc -= args_used; + + if (!argc || + sscanf(argv[0], SECTOR_FORMAT, &size) != 1 || + size > ti->len) { + + ti->error = "raid: Invalid number of raid elements"; +// dm_destroy_dirty_log(dl); + return -EINVAL; + } + + argv++, argc--; + + if (!argc || + sscanf(argv[0], "%u", &sharedflag) != 1 || + sharedflag > 3) { + + ti->error = "raid: Invalid shared flag"; +// dm_destroy_dirty_log(dl); + return -EINVAL; + } + + argv++, argc--; + + if (!argc || + sscanf(argv[0], "%u", &nr_elements) != 1 || + nr_elements < 2 || + nr_elements > MAX_ELEMENTS) { + + ti->error = "raid: Invalid number of raid elements"; +// dm_destroy_dirty_log(dl); + return -EINVAL; + } + + argv++, argc--; + + if (argc != (nr_elements * 4)) { + ti->error = "raid: Wrong number of raid arguments"; +// dm_destroy_dirty_log(dl); + return -EINVAL; + } + + rs = kmalloc(sizeof(struct raid_set), GFP_KERNEL); + if (!rs) { + ti->error = "raid: Cannot allocate raid context"; +// dm_destroy_dirty_log(dl); + return -ENOMEM; + } + + memset(rs, 0, sizeof(struct raid_set)); + spin_lock_init(&rs->lock); + spin_lock_init(&rs->rlock); + spin_lock_init(&rs->iolock); + spin_lock_init(&rs->cachelock); + spin_lock_init(&rs->flushlock); + spin_lock_init(&rs->irqlock); + bio_list_init(&rs->reads); + bio_list_init(&rs->writes); + bio_list_init(&rs->readas); + atomic_set(&rs->ioreadcount,0); + atomic_set(&rs->iopending,0); + atomic_set(&rs->iototal,0); + + rs->nr_elements = nr_elements; + rs->elementsize = size; + if (sharedflag) { + rs->flags |= SHARED_FLAG; + if (sharedflag & 2) { + rs->flags |= RESTRIPE_ENABLED; + } + } + else { + rs->flags |= RESTRIPE_ENABLED; + } + + rs->ti = ti; + ti->private = rs; + + printk(KERN_ALERT"NWRAID: Raid count = %d\n", nr_elements); + + dm_table_flush_all(rs->ti->table); + + /* Get the raid sets */ + for (e = 0; e < nr_elements; e++) { + r = get_raid(rs, ti, e, argv); + if (r) { + free_context(rs); + return r; + } + argv += 2; + argc -= 2; + } + + if (rs->stamp.bitmapsize == 0) + { + /* Find the bitmap size */ + temp = rs->stamp.elementsize >> rs->stamp.raidstripeshift; + temp2 = 0; + rs->stamp.groupshift = 0; + while (temp > 4096) + { + if (temp & 1) + temp2 = 1; + + rs->stamp.groupshift++; + temp >>= 1; + } + rs->stamp.bitmapsize = temp + temp2; + rs->flags |= FLUSH_FLAG; + } + + /* Check if all the segments are present */ + if (nr_elements != rs->stamp.elementcount) { + if (rs->stamp.raidtype == RAID5) { + if (nr_elements == (rs->stamp.elementcount - 1)) { + if (rs->stamp.missingelement == -1) { + /* Set the missing element */ + for (e=0; estamp.elementcount; e++) { + if (!(test_bit(e, &rs->loadedmap))) { + rs->stamp.missingelement = e; + rs->stamp.resyncparityflag = 1; + rs->flags &= ~INSYNC_FLAG; + rs->flags |= FLUSH_FLAG; + break; + } + } + } + } + else { + rs->flags |= DEACTIVE_FLAG; + } + } + else { + rs->flags |= DEACTIVE_FLAG; + } + } + + if ((rs->stamp.missingelement == -1) && + (rs->stamp.flushed_block >= (rs->stamp.capacity >> rs->stamp.raidstripeshift))) { + + rs->flags |= INSYNC_FLAG; + } + + rs->restripe_block = rs->completed_block = rs->stamp.flushed_block; + rs->groupstripes = (1 << rs->stamp.groupshift) - 1; + rs->laststripe = -1; + rs->stripesize = 1 << rs->stamp.raidstripeshift; + + printk(KERN_ALERT"NWRAID: type = %d\n", rs->stamp.raidtype); + printk(KERN_ALERT"NWRAID: ecount = %d\n", rs->stamp.elementcount); + printk(KERN_ALERT"NWRAID: old = %d\n", rs->stamp.oldelementcount); + printk(KERN_ALERT"NWRAID: missing = %x\n", rs->stamp.missingelement); + printk(KERN_ALERT"NWRAID: cap = %d\n", rs->stamp.capacity); + printk(KERN_ALERT"NWRAID: last = %d\n", rs->stamp.lastblock); + printk(KERN_ALERT"NWRAID: flush = %d\n", rs->stamp.flushed_block); + printk(KERN_ALERT"NWRAID: groups = %d\n", rs->stamp.bitmapsize); + printk(KERN_ALERT"NWRAID: resync = %d\n", rs->stamp.resyncparityflag); + if ((rs->stamp.resyncparityflag) && (rs->bitmap)) { + printk(KERN_ALERT"NWRAID: bitmap count = %d\n", CountBits(rs->bitmap, rs->stamp.bitmapsize)); + } + + *raid = rs; + return 0; +} + +static int raid0_ctr(struct dm_target *ti, unsigned int argc, char **argv) +{ + int r; + struct raid_set *rs; + + if ((r = alloc_raid_set(ti,argc,argv,&rs)) == 0) { + + rs->wq = _kraid_wq; + rs->work = &_kraid_work; + rs->wakecount = &wakecount; + add_raid_set(rs); + } + + printk(KERN_ALERT"NWRAID: Constructor completed with %d\n",r); + return r; +} + +void free_raid_set(struct raid_set *rs) +{ + if (rs->restripestate > NO_RESTRIPE) + stop_restripe(rs); + + free_context(rs); +} + +static void raid0_dtr(struct dm_target *ti) +{ + struct raid_set *rs; + + if (!ti) { + printk(KERN_ALERT"NWRAID0: ti = NULL on destructor\n"); + return; + } + + rs = (struct raid_set *) ti->private; + + if (rs) { + printk(KERN_ALERT"NWRAID: Destructor called ti=%x\n", ti); + del_raid_set(rs); + free_raid_set(rs); + } +} + +/* + * RAID0 mapping function + */ +static int raid0_map(struct dm_target *ti, struct bio *bio, + union map_info *map_context) +{ + struct raid_set *rs = (struct raid_set*) ti->private; + + if (rs) { + if ((bio->bi_sector - rs->ti->begin) > rs->stamp.capacity) { + return(-EPERM); + } + + return(do_raid0_io(rs, bio)); + } + else + return(-EIO); +} + +static int raid0_end_io(struct dm_target *ti, struct bio *bio, + int error, union map_info *map_context) +{ + struct raid_set *rs; + + if (error) { +// printk(KERN_ALERT"NWRAID0: Received error %d\n", error); + rs = (struct raid_set *) ti->private; + rs->flags |= DEACTIVE_FLAG; + } + return error; +} + +void raid_suspend(struct dm_target *ti) +{ + struct raid_set *rs = (struct raid_set *) ti->private; + if (rs) { + printk(KERN_ALERT"NWRAID: Suspend called\n"); + stop_restripe(rs); + flush_log(rs); + rs->flags |= SUSPEND_FLAG; + } +} + +void raid_resume(struct dm_target *ti) +{ + struct raid_set *rs = (struct raid_set *) ti->private; + if (rs) { + printk(KERN_ALERT"NWRAID: Resume called\n"); + refresh_log(rs); + +// /* If new element has been added to an empty raid set (no associated pool) */ +// /* before it has been activated, reset old element count back to valid value, */ +// /* to protect do_raid0/5_io from using an invalid element count. (Bug 253595) */ +// if (rs->stamp.oldelementcount > rs->nr_elements) { +// printk(KERN_ALERT"NWRAID: Invalid old element stamp count detected\n"); +// printk(KERN_ALERT"NWRAID: oldelemcount=%u, nr_elements=%u\n", +// rs->stamp.oldelementcount, rs->nr_elements); +// rs->stamp.oldelementcount = rs->nr_elements; +// } + + /* Clear the suspend and deactive flag so we can try again */ + rs->flags &= ~(SUSPEND_FLAG | DEACTIVE_FLAG); + + start_restripe(rs); + } +} + +int raid_status(struct dm_target *ti, status_type_t type, + char *result, unsigned int maxlen) +{ + char buffer[32]; + unsigned int m, sz = 0; + unsigned long totalsize, complete; + struct raid_set *rs = (struct raid_set *) ti->private; + + if (!rs) + return(-EPERM); + + switch (type) { + case STATUSTYPE_INFO: + /* If shared and not enabled, get the current status from disk */ + if ((rs->flags & (SHARED_FLAG | RESTRIPE_ENABLED)) == SHARED_FLAG ) { + refresh_log(rs); + } + + m = (rs->flags & RESTRIPE_ENABLED) ? 1 : 0; + if (rs->flags & DEACTIVE_FLAG) { + m |= 4; + } + if (rs->flags & SHARED_FLAG) { + m |= 8; + } + if (rs->flags & SUSPEND_FLAG) { + m |= 16; + } + if (rs->flags & NOIO_FLAG) { + m |= 32; + } + + if (rs->restripestate != NO_RESTRIPE) { + m |= 2; + if (rs->flags & RESYNC_FLAG) { + totalsize = rs->stamp.bitmapsize; + complete = CountBits(rs->bitmap, rs->stamp.bitmapsize); + } + else { + totalsize = rs->stamp.lastblock; + complete = rs->completed_block; + } + } + else { + if ((rs->flags & INSYNC_FLAG) || + (rs->stamp.flushed_block < rs->stamp.lastblock) || + (rs->stamp.oldelementcount != rs->stamp.elementcount)){ + + totalsize = rs->stamp.lastblock; + complete = rs->completed_block; + } + else { + totalsize = rs->stamp.bitmapsize; + complete = CountBits(rs->bitmap, rs->stamp.bitmapsize); + } + } + + sz += snprintf(result + sz, maxlen - sz, +// "%d %d %d %u " SECTOR_FORMAT " %u %u %u %u %u %u ", + "%d %d %d %u %u %u %u %u %u %u %u ", + rs->stamp.elementcount, + rs->nr_elements, + rs->stamp.missingelement, + totalsize, + complete, + rs->stamp.flushed_block, + rs->loadedmap, + rs->activemap, + (rs->flags & INSYNC_FLAG) ? 1 : 0, + m, + rs->stamp.stamptime); + + for (m = 0; m < MAX_ELEMENTS; m++) { + if (test_bit(m, &rs->loadedmap)) { + format_dev_t(buffer, rs->elements[m].dev->bdev->bd_dev); + sz += scnprintf(result + sz, maxlen - sz, + "%s ", buffer); + } + } + + break; + + case STATUSTYPE_TABLE: + sz += snprintf(result + sz, maxlen - sz, +// "%s 1 " SECTOR_FORMAT " %d ", +// rs->rh.log->type->name, + "nwraid 0 %d %d %d ", + rs->elementsize, + (rs->flags & SHARED_FLAG) ? 1 : 0, + rs->nr_elements); + + for (m = 0; m < MAX_ELEMENTS; m++) { + if (test_bit(m, &rs->loadedmap)) { + format_dev_t(buffer, rs->elements[m].flush_dev->bdev->bd_dev); + sz += scnprintf(result + sz, maxlen - sz, + "%s " SECTOR_FORMAT " ", + buffer, rs->elements[m].flush_offset); + } + } + + for (m = 0; m < MAX_ELEMENTS; m++) { + if (test_bit(m, &rs->loadedmap)) { + format_dev_t(buffer, rs->elements[m].dev->bdev->bd_dev); + sz += scnprintf(result + sz, maxlen - sz, + "%s " SECTOR_FORMAT " ", + buffer, rs->elements[m].offset); + } + } + } + + return 0; +} + +static int raid0_message(struct dm_target *ti, unsigned argc, char **argv) +{ + char *bptr; + int i, r = -EINVAL; + struct raid_set *rs = (struct raid_set *) ti->private; + + for (i=0; ilock); + rs->flags |= RESTRIPE_ENABLED; + spin_unlock(&rs->lock); + refresh_log(rs); + start_restripe(rs); + printk(KERN_ALERT"NWRAID0: Restripe enabled\n"); + r = 0; + } + else if (memcmp(bptr, "off", 3) == 0) { + spin_lock(&rs->lock); + if (!(rs->flags & RESTRIPE_ENABLED)) { + spin_unlock(&rs->lock); + r = 0; + continue; + } + rs->flags &= ~RESTRIPE_ENABLED; + spin_unlock(&rs->lock); + stop_restripe(rs); + flush_log(rs); + printk(KERN_ALERT"NWRAID0: Restripe disabled\n"); + r = 0; + } + } + } + + return(r); +} + +static struct target_type raid0_target = { + .name = "raid0", + .version = {1, 0, 1}, + .module = THIS_MODULE, + .ctr = raid0_ctr, + .dtr = raid0_dtr, + .map = raid0_map, + .end_io = raid0_end_io, + .postsuspend = raid_suspend, + .resume = raid_resume, + .status = raid_status, + .message = raid0_message, +}; + +int nw_raid0_init(void) +{ + int r; + + printk(KERN_ALERT"NWRAID: Initializing\n"); +// r = dm_dirty_log_init(); +// if (r) +// return r; + + atomic_set(&wakecount, 1); + _kraid_wq = create_workqueue("nwraid0"); + if (!_kraid_wq) { + DMERR("couldn't start work queue"); +// dm_dirty_log_exit(); + return -ENOMEM; + } + INIT_WORK(&_kraid_work, do_work, NULL); + + + r = dm_register_target(&raid0_target); + if (r < 0) { + DMERR("%s: Failed to register mirror target", + raid0_target.name); +// dm_dirty_log_exit(); + destroy_workqueue(_kraid_wq); + return r; + } + + r = dm_io_get(1); + if (r < 0) { + DMERR("%s: Failed to initialize io pool"); +// dm_dirty_log_exit(); + destroy_workqueue(_kraid_wq); + dm_unregister_target(&raid0_target); + } + + return r; +} + +void nw_raid0_exit(void) +{ + int r; + + printk(KERN_ALERT"NWRAID: Exiting\n"); + r = dm_unregister_target(&raid0_target); + if (r < 0) + DMERR("%s: unregister failed %d", raid0_target.name, r); + + destroy_workqueue(_kraid_wq); +// dm_dirty_log_exit(); + + dm_io_put(1); +} + diff --git a/src/nwnss/nwraid/nwraid1.c b/src/nwnss/nwraid/nwraid1.c new file mode 100644 index 0000000..239825c --- /dev/null +++ b/src/nwnss/nwraid/nwraid1.c @@ -0,0 +1,3120 @@ +/* + * Copyright (C) 2004-2005 Novell, Inc. + * + * This file is released under the GPL. + */ + +#include "dm.h" +#include "dm-bio-list.h" +#include "dm-io.h" +#include "dm-log.h" + +//#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dmio.h" + +#define DM_MSG_PREFIX "nwraid1" + +extern int nw_raid0_init(void); +extern void nw_raid0_exit(void); +extern int nw_raid5_init(void); +extern void nw_raid5_exit(void); + +typedef typeof(jiffies) jiffy_t; + +static struct workqueue_struct *_kmirrord_wq; +static struct work_struct _kmirrord_work; + +static inline void wake(void) +{ + queue_work(_kmirrord_wq, &_kmirrord_work); +} + +#define MAX_MIRRORS 4 /* Max mirror elements */ +#define MAX_READCOUNT 32 /* How many sequential reads on an element */ +#define MAX_REMIRROR_COUNT 4 /* How many remirror engines */ +#ifdef __x86_64__ +#define LOG_MAP_SIZE 64 /* in unsigned long */ +#else +#define LOG_MAP_SIZE 128 /* in unsigned long */ +#endif + +/* Mirror states */ +#define NO_REMIRROR 0 +#define INIT_REMIRROR 1 +#define REMIRRORING 2 +#define DONE_SENDING 3 +#define DONE 4 + +/* Bit Flags */ +#define NEW_FLAG 1 + +#define FALSE 0 +#define TRUE 1 + +/* context flag defines */ +#define CFLAGS_LOCKED 1 + +static int read_callback(struct bio *bio, unsigned int done, int error); +struct mirror_set; +/*----------------------------------------------------------------- + * Mirror set structures. + *---------------------------------------------------------------*/ +typedef uint32_t mregion_t; + +typedef struct iocontext { + struct iocontext *link; + struct mirror_set *ms; + struct bio *bio; + unsigned long map; + unsigned long error; + mregion_t region; + unsigned short count; + unsigned short flags; +}iocontext; + +#define IOBLOCK_COUNT (4068/sizeof(iocontext)) + +struct iocontext_block { + struct iocontext_block *next; + iocontext list[IOBLOCK_COUNT]; +}; + +typedef struct read_context { + struct read_context *link; + struct mirror_set *ms; + void *private; + bio_end_io_t *endio; + uint32_t index; +}read_context; + +struct read_context_block { + struct read_context_block *next; + read_context list[1]; +}; + +#define READ_BLOCK_COUNT (4068 / sizeof(read_context)) + +struct region_map { + mregion_t region; + unsigned long sent; + unsigned long complete; +}; + +struct mirror { + atomic_t error_count; + struct dm_dev *dev; + sector_t offset; + struct dm_dev *flush_dev; + sector_t flush_offset; +}; + +typedef struct raid1_stamp_s { + unsigned char version; + unsigned char stamptext[15]; + + uint32_t stamptime; + uint32_t partitiontype; + uint32_t raididentifier; + uint32_t elementcount; + + uint32_t elementindex; + uint32_t membermap; + uint32_t insyncmap; + uint32_t raidcapacity; + + uint32_t regionshift; + uint32_t nr_regions; + + unsigned char name[80]; + unsigned char guid[16]; + unsigned char owner[16]; + + uint32_t minor; +} __attribute__((packed)) raid1_stamp_t; + +struct logdata { + raid1_stamp_t stamp; + unsigned char filler[512 - sizeof(raid1_stamp_t)]; + unsigned long sync[MAX_MIRRORS][LOG_MAP_SIZE]; + unsigned long dirty[LOG_MAP_SIZE]; +}__attribute__((packed)); + +struct engine { + struct engine *link; + mregion_t region; + unsigned long map; + unsigned long count; + unsigned long index; + struct mirror_set *ms; + struct page_list *list; + struct io_region to[MAX_MIRRORS-1]; +}; + +struct mirror_set { + struct dm_target *ti; + struct list_head list; + + spinlock_t lock; /* protects changes to this set */ + struct bio_list reads; + struct bio_list writes; + struct bio_list readas; /* read aheads */ + struct bio_list retry; + + unsigned long nr_mirrors; + unsigned long loadedmap; + unsigned long activemap; + unsigned char sharedflag; + unsigned char flushflag; + unsigned char suspendflag; + unsigned char pauseflag; + unsigned char bitflags; + unsigned char remirrorenabled; + unsigned char remirrorstate; + unsigned char remirrorabort; + unsigned long remirrormaster; + unsigned long remirrorslave; + + sector_t readnext[MAX_MIRRORS]; + atomic_t readcount[MAX_MIRRORS]; + unsigned long lastreadindex; + atomic_t writecount; + + struct mirror mirror[MAX_MIRRORS]; + struct iocontext_block *ioblocklist; + iocontext *iolist; + iocontext *iohead; + iocontext *iotail; + + struct read_context_block *readblocklist; + read_context *readlist; + atomic_t iocount; + + /* Remirror data */ + spinlock_t rlock; + mregion_t remirror_region; + atomic_t remirror_count; + int flush_count; + mregion_t sync_count[MAX_MIRRORS]; + unsigned int bio_per_region; + struct engine *engine; + unsigned short *remirrorwrite; + unsigned long *remirrorbits; + struct region_map *rmap; + spinlock_t irqlock; + struct engine *read; + struct engine *writehead; + struct engine *writetail; + struct engine *completehead; + struct engine *completetail; + + /* Log data */ + struct logdata log; + unsigned long currentwrite[LOG_MAP_SIZE]; + jiffy_t writetime; + +}; + +static int flush_log(struct mirror_set *ms) +{ + + unsigned int i, r = 0, temp; + struct io_region io; + struct mirror *m; + raid1_stamp_t *buffer; + unsigned long map; + unsigned long ebits; + + if ((buffer = vmalloc(3072)) == NULL) { + return(-ENOMEM); + } + + spin_lock(&ms->lock); + ms->flushflag = 0; + map = ms->loadedmap & ms->activemap; + ms->log.stamp.stamptime++; +// printk(KERN_ALERT"NWRAID1: Flush log time = %d\n", ms->log.stamp.stamptime); + + memcpy(buffer, &ms->log, 3072); + spin_unlock(&ms->lock); + + io.count = 6; + + for (i = 0; i < MAX_MIRRORS; i++) { + if (test_bit(i, &map)) { + + m = &ms->mirror[i]; + + io.bdev = m->flush_dev->bdev; + io.sector = m->flush_offset; + buffer->elementindex = i; + temp = dm_io_sync_vm(1, &io, WRITE, + buffer, &ebits); + if ((temp) && (!r)) + r = temp; + } + } + vfree(buffer); + + dm_table_flush_all(ms->ti->table); + return(r); +} + +static int alloc_io_context(struct mirror_set *ms) +{ + int i; + struct iocontext_block *block; + iocontext *io; + + if ((block = kmalloc(sizeof(struct iocontext_block), GFP_KERNEL)) != NULL) { + + spin_lock(&ms->lock); + for (i=0, io=block->list; ims = ms; + io->link = ms->iolist; + ms->iolist = io; + } + block->next = ms->ioblocklist; + ms->ioblocklist = block; + spin_unlock(&ms->lock); + +// printk(KERN_ALERT"NWRAID1: Allocated context block\n"); + return(0); + } + else + return(-ENOMEM); +} + +static void return_context(iocontext *context) +{ + int count, wakeup=0; + mregion_t region; + struct mirror_set *ms = context->ms; + + if ((context->flags & CFLAGS_LOCKED) && (ms->remirrorwrite != NULL)) { + + region = context->region; + + spin_lock(&ms->rlock); + + for (count = context->count; count>0; count--, region++) { + if (ms->remirrorwrite[region]) { + if (--ms->remirrorwrite[region] == 0) { + if (test_bit(region, ms->remirrorbits)) { + wakeup=1; + } + } + } + else { + printk(KERN_ALERT"NWRAID1: remirror clear region=%d already zero\n", + region); + } + } + + spin_unlock(&ms->rlock); + } + + if (wakeup) { + wake(); + } + + spin_lock(&ms->lock); + context->link = ms->iolist; + ms->iolist = context; + spin_unlock(&ms->lock); +} + +static int alloc_read_context(struct mirror_set *ms) +{ + int i; + struct read_context_block *block; + read_context *io; + unsigned long flags; + + if ((block = kmalloc(4072, GFP_KERNEL)) != NULL) { + + spin_lock_irqsave(&ms->irqlock, flags); + for (i=READ_BLOCK_COUNT, io=block->list; i>0; i--, io++) { + io->ms = ms; + io->link = ms->readlist; + ms->readlist = io; + } + block->next = ms->readblocklist; + ms->readblocklist = block; + spin_unlock_irqrestore(&ms->irqlock, flags); + +// printk(KERN_ALERT"NWRAID1: Allocated read context block\n"); + return(0); + } + else + return(-ENOMEM); +} + +static int alloc_read(struct mirror_set *ms, + struct bio *bio, + uint32_t index) +{ + read_context *context; + unsigned long flags; + + spin_lock_irqsave(&ms->irqlock, flags); + if ((context = ms->readlist) == NULL) { + spin_unlock_irqrestore(&ms->irqlock, flags); + alloc_read_context(ms); + spin_lock_irqsave(&ms->irqlock, flags); + if ((context = ms->readlist) == NULL) { + spin_unlock_irqrestore(&ms->irqlock, flags); +// printk(KERN_ALERT"NWRAID: No context messages\n"); + return(-ENOMEM); + } + } + ms->readlist = context->link; + spin_unlock_irqrestore(&ms->irqlock, flags); + + context->endio = bio->bi_end_io; + context->private = bio->bi_private; + context->index = index; + bio->bi_end_io = (bio_end_io_t*) read_callback; + bio->bi_private = (void*) context; + + return(0); +} + +static void return_read_bio(struct bio *bio, int error) +{ + read_context *context; + struct mirror_set *ms; + unsigned long flags; + +// if (error) +// printk(KERN_ALERT"NWRAID1: Return read bio completed with err=%d\n", error); + + context = (read_context*) bio->bi_private; + ms = context->ms; + bio->bi_private = context->private; + bio->bi_end_io = context->endio; + + spin_lock_irqsave(&ms->irqlock, flags); + context->link = ms->readlist; + ms->readlist = context; + spin_unlock_irqrestore(&ms->irqlock, flags); + + if (error) { + error = -EIO; + } + + bio_endio(bio, bio->bi_size, error); +} + +/* + * Conversion fns + */ + +/* bio_to_region will return a region in the pointer, and a count + * in return. A count of 0 is an error, otherwise, the number of + * regions will be returned. +*/ +static int bio_to_region(struct mirror_set *ms, + struct bio *bio, + mregion_t *region) +{ + mregion_t start, end; + sector_t endsector; + + start = (mregion_t) bio->bi_sector >> ms->log.stamp.regionshift; + *region = start; + + if (start >= ms->log.stamp.nr_regions) { + return(0); + } + + endsector = bio->bi_size >> 9; + if (!endsector) { + return(1); + } + + endsector = (endsector + bio->bi_sector) - 1; + end = (mregion_t) endsector >> ms->log.stamp.regionshift; + + if (end == start) { + return(1); + } + +// printk(KERN_ALERT"NWRAID1: bio_to_reg reg=%d end=%d sec=%lld size=%d\n", start, end, bio->bi_sector, bio->bi_size); + + if (end >= ms->log.stamp.nr_regions) { + return(0); + } + + return((end - start) + 1); +} + +/*----------------------------------------------------------------- + * Bitmap functions + *---------------------------------------------------------------*/ +static int sync_clear(struct mirror_set *ms, + struct bio *bio, + unsigned long map) +{ + int count, i, j; + mregion_t region; + + map &= ms->log.stamp.membermap; + if (map == 0) + return(0); + + count = bio_to_region(ms, bio, ®ion); + if (count == 0) + return(EINVAL); + + spin_lock(&ms->lock); + + for (j=0; jlog.sync[i])) { + clear_bit(region, ms->log.sync[i]); +// printk(KERN_ALERT"NWRAID1: Clear region=%d\n", region); + ms->sync_count[i]--; + ms->flushflag = 1; + } + } + } + } + + spin_unlock(&ms->lock); + + if (ms->flushflag) { + wake(); + } + + return(0); +} + +/* + * Return true if ANY of the affected regions are already set. + */ +static int remirror_bts(iocontext *context) +{ + int count, i; + int set = FALSE; + mregion_t region; + struct mirror_set *ms = context->ms; + +// if (ms->remirrorwrite == NULL) +// return(TRUE); + + spin_lock(&ms->rlock); + + if (ms->remirrorstate <= INIT_REMIRROR) { + spin_unlock(&ms->rlock); + return(FALSE); + } + + count = context->count; + region = context->region; + + for (i=0; iremirrorbits)) { + set = TRUE; +// printk(KERN_ALERT"NWRAID1: IO region %d waiting for remirror\n", region); + /* Back out the counts we set */ + for (; i>0; i--) { + region--; + ms->remirrorwrite[region]--; + } + context->flags &= ~CFLAGS_LOCKED; + break; + } + else { + if (ms->remirrorwrite[region] < 65535) { + ms->remirrorwrite[region]++; + context->flags |= CFLAGS_LOCKED; + } + else { + set = TRUE; + + /* Back out the counts we set */ + for (; i>0; i--) { + region--; + ms->remirrorwrite[region]--; + } + context->flags &= ~CFLAGS_LOCKED; + break; + } + } + } + + spin_unlock(&ms->rlock); + + return(set); +} + +/* + * Return true only if ALL the affected regions are already set. + */ +static int dirty_bts(struct mirror_set *ms, + struct bio *bio) +{ + int count, i; + int set = TRUE; + mregion_t region; + + count = bio_to_region(ms, bio, ®ion); + if (count == 0) + return(FALSE); + + spin_lock(&ms->lock); + + for (i=0; ilog.dirty)) { + set = FALSE; + set_bit(region, ms->log.dirty); + } + set_bit(region, ms->currentwrite); + } + + spin_unlock(&ms->lock); + + return(set); +} + +/*----------------------------------------------------------------- + * Recovery. + * + * When a mirror is first activated we may find that some regions + * are in the no-sync state. We have to recover these by + * recopying from the default mirror to all the others. + *---------------------------------------------------------------*/ +int CountBits( + unsigned long *ulptr, + int size) /* in bits */ +{ + int ulongs, i, j, count=0; + uint32_t *lptr; + register unsigned long bits; + + lptr = (uint32_t*) ulptr; + + ulongs = size >> 5; /* Divide by 32 */ + + /* First count the bits in full longs */ + for (i=0; ilog.stamp.membermap & ms->activemap; + + for (i=0; ilog.stamp.insyncmap)) + { + ms->sync_count[i] = ms->log.stamp.nr_regions; + sync++; + if (sync == 1) + ms->remirrormaster = i; + } + else + { + if ((ms->sync_count[i] = CountBits(ms->log.sync[i], + ms->log.stamp.nr_regions)) + >= ms->log.stamp.nr_regions) { + +// printk(KERN_ALERT"NWRAID1: Count %d = %d\n", i, ms->sync_count[i]); + /* This element is already remirrored. */ + if (ms->sync_count[i] > ms->log.stamp.nr_regions) + ms->sync_count[i] = ms->log.stamp.nr_regions; + + set_bit(i, (unsigned long*) &ms->log.stamp.insyncmap); + ms->flushflag = 1; + sync++; + if (sync == 1) + ms->remirrormaster = i; + wake(); + } + else { +// printk(KERN_ALERT"NWRAID1: Count %d = %d\n", i, ms->sync_count[i]); + if (ms->remirrorstate == REMIRRORING) { + /* Validate the sync and remirror bits */ + synclog = ms->log.sync[i]; + + j = 0; + while (j < ms->log.stamp.nr_regions) { + j = find_next_zero_bit(synclog, + ms->log.stamp.nr_regions, + j); + + if (j >= ms->log.stamp.nr_regions) + break; + + if (test_bit(j, ms->remirrorbits) == 0) + break; + + j++; + } + + if (j >= ms->log.stamp.nr_regions) + continue; + } + + count++; + + if (count == 1) + { + maxcount = ms->sync_count[i]; + ms->remirrorslave = i; + } + else + { + /* We want the element with the most set to get it remirrored faster. */ + if (ms->sync_count[i] > maxcount) + { + maxcount = ms->sync_count[i]; + ms->remirrorslave = i; + } + } + } + } + } + } + if ((count == 0) || (sync == 0)) + { + if (sync == 0) + return(-2); + else + return(-1); + } + + return(0); +} + +void free_remirror(struct mirror_set *ms) +{ + int i; + struct engine *engine; + struct page_list *list; + + ms->read = NULL; + ms->writehead = NULL; + ms->writetail = NULL; + ms->completehead = NULL; + ms->completetail = NULL; + + engine = ms->engine; + if (engine != NULL) { + for (i=0; ilist; + while (list) { + if (list->page != NULL) { + ClearPageLocked(list->page); + __free_page(list->page); + } + list = list->next; + } + if (engine->list) { + kfree(engine->list); + } + } + + kfree(ms->engine); + ms->engine = NULL; + } + + if (ms->remirrorbits != NULL) { + kfree(ms->remirrorbits); + ms->remirrorbits = NULL; + } + + if (ms->remirrorwrite != NULL) { + kfree(ms->remirrorwrite); + ms->remirrorwrite = NULL; + } + + if (ms->rmap != NULL) { + kfree(ms->rmap); + ms->rmap = NULL; + } + + ms->remirrorabort = 0; +} + +static void remirror_complete(struct mirror_set *ms) +{ + struct engine *list, *engine; + int i, done=0, count=0, regOK; + unsigned long flags; + struct region_map *rmap; + + + while (1) { + spin_lock_irqsave(&ms->irqlock, flags); + if ((list = ms->completehead) == NULL) { + spin_unlock_irqrestore(&ms->irqlock, flags); + return; + } + ms->completehead = NULL; + spin_unlock_irqrestore(&ms->irqlock, flags); + + spin_lock(&ms->rlock); + + while (list) { + engine = list; + list = list->link; + + if (ms->remirrorabort == 0) { + if (ms->bio_per_region > 1) { + regOK = 0; + if (engine->index < MAX_REMIRROR_COUNT) { + rmap = &ms->rmap[engine->index]; + + if (rmap->region == engine->region) { + if (++rmap->complete == ms->bio_per_region) { + rmap->region = -1; + regOK = 1; + } + } + else { + ms->remirrorabort = 1; + } + } + else { + ms->remirrorabort = 1; + } + } + else { + regOK = 1; + } + + if (regOK) { + + /* Occasionally, flush the sync buffers during remirror to + ** save the work being done. */ + if (++ms->flush_count > 100) { + ms->flushflag = 1; + ms->flush_count = 0; + } + + for (i=0; imap & (1<region); + set_bit(engine->region, ms->log.sync[i]); + if (++ms->sync_count[i] >= ms->log.stamp.nr_regions) { + done=1; + set_bit(i, (unsigned long*) &ms->log.stamp.insyncmap); + ms->flushflag = 1; + } + } + } + +// printk(KERN_ALERT"NWRAID1: Clearing remirror bit %d\n", engine->region); + clear_bit(engine->region, ms->remirrorbits); + } + } + count = atomic_dec_and_test(&ms->remirror_count); + engine->link = ms->read; + ms->read = engine; + + if (ms->remirrorabort) { + clear_bit(engine->region, ms->remirrorbits); + if (count) { + ms->remirrorstate = DONE; + } + } + } + + spin_unlock(&ms->rlock); + + if (done) { + if ((ms->log.stamp.insyncmap == ms->activemap) && + (count)) { + + printk(KERN_ALERT"NWRAID1: Remirror Complete\n"); + /* the sync is complete */ + ms->remirrorstate = DONE; + + dm_table_event(ms->ti->table); + } + } + + wake(); + } +} + +static void remirror_write_callback(unsigned long error, void *context) +{ + struct engine *engine = (struct engine*) context; + struct mirror_set *ms = engine->ms; + unsigned long flags; + + if (error) { + ms->remirrorabort = 1; + } + + spin_lock_irqsave(&ms->irqlock, flags); + if (ms->completehead == NULL) { + ms->completehead = ms->completetail = engine; + } + else { + ms->completetail->link = engine; + ms->completetail = engine; + } + engine->link = NULL; + spin_unlock_irqrestore(&ms->irqlock, flags); + + wake(); +} + +static void remirror_write(struct mirror_set *ms) +{ + struct engine *list, *engine; + unsigned long flags; + + while (1) { + spin_lock_irqsave(&ms->irqlock, flags); + if ((list = ms->writehead) == NULL) { + spin_unlock_irqrestore(&ms->irqlock, flags); + return; + } + ms->writehead = NULL; + spin_unlock_irqrestore(&ms->irqlock, flags); + + while (list) { + engine = list; + list = list->link; +// printk(KERN_ALERT"NWRAID1: Remirror write block=%d count=%d mask=%x\n", +// engine->region, engine->count, engine->map); + if (ms->remirrorabort) { + spin_lock(&ms->rlock); + if (atomic_dec_and_test(&ms->remirror_count)) { + ms->remirrorstate = DONE; + } + engine->link = ms->read; + ms->read = engine; + clear_bit(engine->region, ms->remirrorbits); + spin_unlock(&ms->rlock); + continue; + } + + if (dm_io_async(engine->count, engine->to, WRITE, engine->list, 0, + remirror_write_callback, engine) != 0) { + ms->remirrorabort = 1; + spin_lock(&ms->rlock); + if (atomic_dec_and_test(&ms->remirror_count)) { + ms->remirrorstate = DONE; + } + engine->link = ms->read; + ms->read = engine; + clear_bit(engine->region, ms->remirrorbits); + spin_unlock(&ms->rlock); + } + } + } +} + +static void remirror_read_callback(unsigned long error, void *context) +{ + struct engine *engine = (struct engine*) context; + struct mirror_set *ms = engine->ms; + unsigned long flags; + + spin_lock_irqsave(&ms->irqlock, flags); + if (error) { + ms->remirrorabort = 1; + clear_bit(ms->remirrormaster, (unsigned long*) &ms->activemap); + } + + if (ms->writehead == NULL) { + ms->writehead = ms->writetail = engine; + } + else { + ms->writetail->link = engine; + ms->writetail = engine; + } + engine->link = NULL; + spin_unlock_irqrestore(&ms->irqlock, flags); + + wake(); +} + +static void do_remirror(struct mirror_set *ms) +{ + mregion_t region; + uint32_t i, count, map, index; + unsigned long *sync = ms->log.sync[ms->remirrorslave]; + struct engine *engine; + struct io_region from, *dest; + struct mirror *m; + sector_t s=0, offset=0; + + if ((ms->remirrorabort) || + (ms->suspendflag) || + (ms->remirrorstate >= DONE_SENDING)) { + return; + } + + while (1) { + + spin_lock(&ms->rlock); + + if ((engine = ms->read) == NULL) { +// printk(KERN_ALERT"NWRAID1: No engines available\n"); + spin_unlock(&ms->rlock); + return; + } + + ms->read = engine->link; + + /* Find the next region */ + region = ms->remirror_region; + + if ((region == 0) && + (ms->log.stamp.partitiontype == 0x1AD) && + (ms->log.stamp.regionshift <= 6)) { + /* Skip this region */ + region = (65 >> ms->log.stamp.regionshift); + } + + region = find_next_zero_bit(sync, + ms->log.stamp.nr_regions, + region); +// printk(KERN_ALERT"NWRAID1: Found region %d\n", region); + + if (region >= ms->log.stamp.nr_regions) { + if (atomic_read(&ms->remirror_count) != 0) { +// printk(KERN_ALERT"NWRAID1: Remirror count not 0\n"); + engine->link = ms->read; + ms->read = engine; + spin_unlock(&ms->rlock); + return; + } + + /* If we get here, then the set is done */ +// printk(KERN_ALERT"NWRAID1: Finished with slave %d\n", ms->remirrorslave); + set_bit(ms->remirrorslave, (unsigned long*) &ms->log.stamp.insyncmap); + if (find_remirror_set(ms) == 0) { +// printk(KERN_ALERT"NWRAID1: New set with slave=%d\n", ms->remirrorslave); + /* jump out and retry with new set */ + ms->remirror_region = 0; + engine->link = ms->read; + ms->read = engine; + spin_unlock(&ms->rlock); + wake(); + return; + } + else { + printk(KERN_ALERT"NWRAID1: All done\n"); + ms->remirrorstate = DONE; + engine->link = ms->read; + ms->read = engine; + spin_unlock(&ms->rlock); + wake(); + return; + } + } + + if (ms->remirrorwrite[region] != 0) { +// printk(KERN_ALERT"NWRAID1: Wait for write on region %d\n", region); + engine->link = ms->read; + ms->read = engine; + spin_unlock(&ms->rlock); + return; + } + + if (ms->bio_per_region > 1) { + /* Find an available region map */ + index = -1; + for (i=0; irmap[i].region == region) { + offset = 1024 * ms->rmap[i].sent; + if (++ms->rmap[i].sent == ms->bio_per_region) { + ms->remirror_region = region + 1; + } + + if (region == (ms->log.stamp.nr_regions - 1)) { + /* + * The final region may be smaller than + * region_size. + */ + s = ms->ti->len & ((1 << ms->log.stamp.regionshift) - 1); + if (!s) { + s = (1 << ms->log.stamp.regionshift); + } + s -= offset; + if (s > 1024) { + s = 1024; + } else { + ms->remirror_region = region + 1; + ms->rmap[i].complete += (ms->bio_per_region - ms->rmap[i].sent); + } + } else { + s = 1024; + } + engine->index = i; + break; + } + + if ((index == -1) && (ms->rmap[i].region == -1)) { + index = i; + } + } + + if (i == MAX_REMIRROR_COUNT) { + if ((index != -1) && (atomic_read(&ms->iocount) == 0) && (ms->pauseflag == 0)) { + /* Set the bit to hold off any further IO to this region */ +// printk(KERN_ALERT"NWRAID1: Setting remirror bit %d\n", region); + set_bit(region, ms->remirrorbits); + + ms->rmap[index].region = region; + ms->rmap[index].sent = 1; + ms->rmap[index].complete = 0; + offset = 0; + s = 1024; + engine->index = index; + } + else { + engine->link = ms->read; + ms->read = engine; + spin_unlock(&ms->rlock); + return; + } + } + } + else { + if (atomic_read(&ms->iocount) || (ms->pauseflag)) { + /* There are IOs pending, so let them complete */ + engine->link = ms->read; + ms->read = engine; + spin_unlock(&ms->rlock); + return; + } + + /* Set the bit to hold off any further IO to this region */ +// printk(KERN_ALERT"NWRAID1: Setting remirror bit %d\n", region); + set_bit(region, ms->remirrorbits); + + ms->remirror_region = region + 1; + offset = 0; + if (region == (ms->log.stamp.nr_regions - 1)) { + /* + * The final region may be smaller than + * region_size. + */ + s = ms->ti->len & ((1 << ms->log.stamp.regionshift) - 1); + if (!s) { + s = (1 << ms->log.stamp.regionshift); + } + } else { + s = (1 << ms->log.stamp.regionshift); + } + } + + engine->region = region; + atomic_inc(&ms->remirror_count); + spin_unlock(&ms->rlock); + + /* fill in the source */ + m = &ms->mirror[ms->remirrormaster]; + from.bdev = m->dev->bdev; + from.sector = m->offset + (region << ms->log.stamp.regionshift) + offset; + from.count = s; + + /* Don't remirror the first 65 sectors of an SBD partition. */ + if ((ms->log.stamp.partitiontype == 0x1AD) && + ((s = (region << ms->log.stamp.regionshift)) < 65)) { + s = 65 - s; + from.sector = m->offset + 65; + from.count -= s; + } + + /* fill in the destinations */ + count = 0; + map = ms->log.stamp.membermap & ms->activemap; + engine->map = 0; + + for (i = 0; i < MAX_MIRRORS; i++) { + index = 1 << i; + if ((map & index) && + (i != ms->remirrormaster) && + (test_bit(region, ms->log.sync[i]) == 0)) { + + m = &ms->mirror[i]; + dest = &engine->to[count]; + + dest->bdev = m->dev->bdev; + dest->sector = from.sector; + dest->count = from.count; + count++; + engine->map |= index; + } + } + engine->count = count; + +// printk(KERN_ALERT"NWRAID1: Sending region=%d master=%d count="SECTOR_FORMAT"\n", +// engine->region, ms->remirrormaster, from.count); + if (dm_io_async(1, &from, READ, engine->list, 0, + remirror_read_callback, engine) != 0) { + +// printk(KERN_ALERT"NWRAID1: Error Sending region=%d master=%d count="SECTOR_FORMAT"\n", +// engine->region, ms->remirrormaster, from.count); + spin_lock(&ms->rlock); + engine->link = ms->read; + ms->read = engine; + if (atomic_dec_and_test(&ms->remirror_count)) { + ms->remirrorstate = DONE; + } + clear_bit(region, ms->remirrorbits); + spin_unlock(&ms->rlock); + return; + } + } +} + +static int stop_remirror(struct mirror_set *ms, int waitflag) +{ + unsigned char pflag = ms->pauseflag; + + printk(KERN_ALERT"NWRAID1: Stop Remirror (start) count=%d state=%d wait=%d\n", + atomic_read(&ms->remirror_count), ms->remirrorstate, waitflag); + + if (ms->remirrorstate == NO_REMIRROR) { + printk(KERN_ALERT"NWRAID1: not remirroring (end)\n"); + return(0); + } + + spin_lock(&ms->rlock); + + ms->pauseflag = 0; + + if (ms->remirrorstate != DONE) { + ms->remirrorabort = 1; + } + + spin_unlock(&ms->rlock); + + if (waitflag) { + while (1) { + set_current_state(TASK_UNINTERRUPTIBLE); + if ((atomic_read(&ms->remirror_count) == 0) && + ( ms->remirrorstate != INIT_REMIRROR)) { + break; + } + io_schedule(); + } + set_current_state(TASK_RUNNING); + } + else { + if (atomic_read(&ms->remirror_count) != 0) { + wake(); + return(1); + } + + while (ms->remirrorstate == INIT_REMIRROR) { + set_current_state(TASK_UNINTERRUPTIBLE); + io_schedule(); + } + set_current_state(TASK_RUNNING); + } + +// printk(KERN_ALERT"NWRAID1: Count is 0\n"); + spin_lock(&ms->rlock); + + if (ms->remirrorstate == NO_REMIRROR) { + spin_unlock(&ms->rlock); + printk(KERN_ALERT"NWRAID1: already cleaned up\n"); + return(0); + } + + ms->remirrorstate = NO_REMIRROR; + + free_remirror(ms); + + ms->pauseflag = pflag; + + spin_unlock(&ms->rlock); + + printk(KERN_ALERT"NWRAID1: Stop Remirror (end)\n"); + + return(0); +} + +static int start_remirror(struct mirror_set *ms) +{ + uint32_t i, j, size, pages; + struct engine *engine; + struct page_list *list; + +// printk(KERN_ALERT"NWRAID1: Got to start_remirror Regions=%d\n", +// ms->log.stamp.nr_regions); + + spin_lock(&ms->rlock); + + if (ms->remirrorenabled == 0) { + spin_unlock(&ms->rlock); + return(-EPERM); + } + + if (ms->remirrorstate != NO_REMIRROR) { + spin_unlock(&ms->rlock); +// printk(KERN_ALERT"NWRAID1: Remirror running=%d\n",ms->remirrorstate); + return(0); + } + + if (ms->pauseflag != 0) { + ms->pauseflag = 2; + spin_unlock(&ms->rlock); + printk(KERN_ALERT"NWRAID1: Remirror paused\n"); + return(0); + } + + ms->remirrorstate = INIT_REMIRROR; + spin_unlock(&ms->rlock); + + /* Round the size up to the nearest long */ + i = ms->log.stamp.nr_regions % (sizeof(unsigned long) * 8); + if (i) + size = ms->log.stamp.nr_regions + ((sizeof(unsigned long) * 8) - i); + else + size = ms->log.stamp.nr_regions; + + i = ms->log.stamp.nr_regions * sizeof(unsigned short); + + /* convert to bytes */ + size >>= 3; + + if (ms->engine == NULL) + ms->engine = kmalloc((sizeof(struct engine) * MAX_REMIRROR_COUNT), + GFP_KERNEL); + if (ms->engine == NULL) { + ms->remirrorstate = NO_REMIRROR; + return(-ENOMEM); + } + + memset(ms->engine, 0, (sizeof(struct engine) * MAX_REMIRROR_COUNT)); + + if (ms->remirrorbits == NULL) + ms->remirrorbits = kmalloc(size, GFP_KERNEL); + + if (ms->remirrorbits == NULL) { + spin_lock(&ms->rlock); + kfree(ms->engine); + ms->engine = NULL; + ms->remirrorstate = NO_REMIRROR; + spin_unlock(&ms->rlock); + return(-ENOMEM); + } + + if (ms->remirrorwrite == NULL) + ms->remirrorwrite = kmalloc(i, GFP_KERNEL); + + if (ms->remirrorwrite == NULL) { + spin_lock(&ms->rlock); + free_remirror(ms); + ms->remirrorstate = NO_REMIRROR; + spin_unlock(&ms->rlock); + return(-ENOMEM); + } + + if (ms->bio_per_region > 1) { + if (ms->rmap == NULL) + ms->rmap = kmalloc((sizeof(struct region_map) * MAX_REMIRROR_COUNT), + GFP_KERNEL); + + if (ms->rmap == NULL) { + spin_lock(&ms->rlock); + free_remirror(ms); + ms->remirrorstate = NO_REMIRROR; + spin_unlock(&ms->rlock); + return(-ENOMEM); + } + + for (j=0; jrmap[j].region = -1; + } + + pages = 128; + } + else { + pages = dm_div_up((1 << ms->log.stamp.regionshift),8); + } + + memset(ms->remirrorbits, 0, size); + memset(ms->remirrorwrite, 0, i); + atomic_set(&ms->remirror_count,0); + + engine = ms->engine; + +// printk(KERN_ALERT"NWRAID: Buffer pages = %d RSize = %d\n", pages, (1 << ms->log.stamp.regionshift)); + for (i=0; ims = ms; + engine->list = list = kmalloc(pages * sizeof(struct page_list), GFP_KERNEL); + if (list) { + j = 0; + while (j < pages) { + list->next = NULL; + if ((list->page = alloc_page(GFP_KERNEL)) == NULL) { + free_remirror(ms); + return(-ENOMEM); + } + SetPageLocked(list->page); + j++; + if (j < pages) { + list->next = &engine->list[j]; + } + list++; + } + } + else { + free_remirror(ms); + return(-ENOMEM); + } + engine->link = ms->read; + ms->read = engine; + } + + spin_lock(&ms->rlock); + ms->remirror_region = 0; + + if (find_remirror_set(ms) != 0) { + ms->remirrorstate = DONE; + spin_unlock(&ms->rlock); + stop_remirror(ms, 0); +// printk(KERN_ALERT"NWRAID1: Nothing to remirror\n"); + return(-EPERM); + } + + ms->remirrorstate = REMIRRORING; + + if (ms->remirrorabort) { + spin_unlock(&ms->rlock); + stop_remirror(ms, 0); +// printk(KERN_ALERT"NWRAID1: Remirror aborted\n"); + return(-EPERM); + } + + spin_unlock(&ms->rlock); + + wake(); + + printk(KERN_ALERT"NWRAID1: Remirror started with master=%d\n", ms->remirrormaster); + return(0); +} + +/*----------------------------------------------------------------- + * Reads + *---------------------------------------------------------------*/ +static void queue_bio(struct mirror_set *ms, struct bio *bio, int rw) +{ + int wakeup = 0; + struct bio_list *bl; + + if (rw == WRITE) { + bl= &ms->writes; + } + else if (rw == READ) { + bl= &ms->reads; + } + else { + bl= &ms->readas; + } + + spin_lock(&ms->lock); + wakeup = !(bl->head); + bio_list_add(bl, bio); + spin_unlock(&ms->lock); + +// if (wakeup && !ms->suspendflag) + if (wakeup) { + wake(); + } +} + +static unsigned long choose_mirror(struct mirror_set *ms, struct bio *bio) +{ + uint32_t element, selected, first, next, index; + unsigned long syncmap; + + if (ms->log.stamp.elementcount == 1) + { + /* We only have one choice. Find it and send the message. */ + for (element = 0; element < MAX_MIRRORS; element++) + { + if (test_bit(element, (unsigned long*) &ms->loadedmap)) + { + break; + } + } + + return(element); + } + + syncmap = ms->log.stamp.membermap + & ms->activemap + & ms->log.stamp.insyncmap; + +// if (syncmap != ms->log.stamp.membermap) { +// printk(KERN_ALERT"NWRAID1: syncmap = %x\n", syncmap); +// } + /* Find the first one in sync. */ + for (element = 0; element < MAX_MIRRORS; element++) + { + if (test_bit(element, &syncmap)) + break; + } + + if (element == MAX_MIRRORS) + { + if ((ms->remirrorenabled != 1) + && (ms->log.stamp.partitiontype == 0x1AD)) + { + /* The SBD can read from insync partitions. */ + /* Find an active element and set it as the insync element */ + syncmap = ms->log.stamp.membermap & ms->activemap; + + for (element = 0; element < MAX_MIRRORS; element++) + { + if (test_bit(element, &syncmap)) + break; + } + if (element != MAX_MIRRORS) + { + ms->log.stamp.insyncmap = syncmap = 1 << element; + } + else + { + return(element); + } + } + else + { + return(element); + } + } + + /* Check to see if we have another element in sync */ + if (!(syncmap & ~(1 << element))) + { + /* Only 1 choice, so just use it. */ + return(element); + } + else + { + /* If remirroring, try to avoid the master. */ + if (ms->remirrorstate > INIT_REMIRROR) + clear_bit(ms->remirrormaster, &syncmap); + + selected = first = next = -1; + + /* From the remaining elements find the best one to use. */ + for (index = element; index < MAX_MIRRORS; index++) + { + if (test_bit(index, &syncmap)) + { + if ((ms->readnext[index] == bio->bi_sector) && + (atomic_read(&ms->readcount[index]) < MAX_READCOUNT)) + { + selected = index; + atomic_inc(&ms->readcount[index]); + break; + } + + if (first == -1) + first = index; + + if ((index > ms->lastreadindex) && + (next == -1)) + { + /* This is the next in the round robin. */ + next = index; + } + } + } + if (selected != -1) + element = selected; + else + { + if (next != -1) + element = next; + else if (first != 1) + element = first; + + ms->lastreadindex = element; + atomic_set(&ms->readcount[element], 0); + } + + if (element < MAX_MIRRORS) { + ms->readnext[element] = bio->bi_sector + (bio->bi_size >> 9); + } + } + + return element; +} + +/* + * remap a buffer to a particular mirror. + */ +static void map_bio(struct mirror_set *ms, + struct mirror *m, + struct bio *bio) +{ + bio->bi_bdev = m->dev->bdev; + bio->bi_sector = m->offset + (bio->bi_sector - ms->ti->begin); +} + +static int read_callback(struct bio *bio, unsigned int done, int error) +{ + read_context *context = (read_context*) bio->bi_private; + struct mirror_set *ms; + unsigned long flags; + + if (error) { + /* Log errored elements and retry reads. */ + if (bio_rw(bio) == READ) { + /* Set this element as bad, and retry */ + if (context->index < MAX_MIRRORS) { + ms = context->ms; + spin_lock_irqsave(&ms->irqlock, flags); + bio_list_add(&ms->retry, bio); + spin_unlock_irqrestore(&ms->irqlock, flags); + wake(); + return(1); + } + } + } + + return_read_bio(bio, error); + return(0); +} + +static void do_reads(struct mirror_set *ms, struct bio *reads) +{ + struct bio *bio; + uint32_t index; + + while (reads != NULL) { + bio = reads; + reads = bio->bi_next; + bio->bi_next = NULL; + index = choose_mirror(ms, bio); + if (alloc_read(ms, bio, index) == 0) { + map_bio(ms, &ms->mirror[index], bio); + generic_make_request(bio); + } + else { + queue_bio(ms, bio, READ); + } + } +} + +static void retry_callback(unsigned long error, void *rtncontext) +{ + struct bio *bio = (struct bio*) rtncontext; + read_context *context = (read_context*) bio->bi_private; + struct mirror_set *ms = context->ms; + unsigned long flags; + + +// printk(KERN_ALERT"NWRAID1: Retry completed with %x\n", error); + spin_lock_irqsave(&ms->irqlock, flags); + + if (error) { + /* Log errored elements and retry reads. */ + if (bio_rw(bio) == READ) { + /* Set this element as bad, and retry */ + if (context->index < MAX_MIRRORS) { + bio_list_add(&ms->retry, bio); + spin_unlock_irqrestore(&ms->irqlock, flags); + wake(); + return; + } + } + } + + bio->bi_private = context->private; + bio->bi_end_io = context->endio; + + context->link = ms->readlist; + ms->readlist = context; + spin_unlock_irqrestore(&ms->irqlock, flags); + + if (error) { + error = -EIO; + } + + bio_endio(bio, bio->bi_size, error); +} + +static void do_retrys(struct mirror_set *ms, struct bio *reads) +{ + struct bio *bio; + read_context *context; + struct io_region io; + int r; + unsigned long flags; + + while (reads != NULL) { + bio = reads; + reads = bio->bi_next; + bio->bi_next = NULL; + context = (read_context*) bio->bi_private; + spin_lock(&ms->lock); + clear_bit(context->index, (unsigned long*) &ms->activemap); + spin_unlock(&ms->lock); +// printk(KERN_ALERT"NWRAID1: Read retry activemap=%x\n", ms->activemap); + bio->bi_flags |= (1 << BIO_UPTODATE); + if (ms->activemap) { + if ((context->index = choose_mirror(ms, bio)) < MAX_MIRRORS) { + io.bdev = ms->mirror[context->index].dev->bdev; + io.sector = ms->mirror[context->index].offset + (bio->bi_sector - ms->ti->begin); + io.count = bio->bi_size >> 9; + r = dm_io_async_bvec(1, &io, bio_rw(bio), + bio->bi_io_vec + bio->bi_idx, + retry_callback, bio); + if (r) { + spin_lock_irqsave(&ms->irqlock, flags); + bio_list_add(&ms->retry, bio); + spin_unlock_irqrestore(&ms->irqlock, flags); + wake(); + } + } + else { + return_read_bio(bio, -EIO); + } + } + else { + return_read_bio(bio, -EIO); + } + } +} + +/*----------------------------------------------------------------- + * Writes. + *---------------------------------------------------------------*/ + +/* check_write checks to see if there is only 1 element to write to. */ +static int check_write(struct mirror_set *ms, struct bio *bio) +{ + int element; + unsigned long syncmap; + + if (ms->log.stamp.elementcount == 1) + { + /* We only have one choice. Find it and send the message. */ + for (element = 0; element < MAX_MIRRORS; element++) + { + if (test_bit(element, (unsigned long*) &ms->loadedmap)) + { + return(element); + } + } + + /* If we get here, we didn't find a mirror */ + return(-EIO); + } + + /* If remirroring, queue it. */ + if (ms->remirrorstate > INIT_REMIRROR) { + return(MAX_MIRRORS); + } + + /* Ignore the sync map for SBD partitions */ + if (ms->log.stamp.partitiontype != 0x1AD) { + syncmap = ms->log.stamp.membermap + & ms->activemap + & ms->log.stamp.insyncmap; + } + else { + syncmap = ms->log.stamp.membermap & ms->activemap; + } + + /* Find the first one in sync. */ + for (element = 0; element < MAX_MIRRORS; element++) + { + if (test_bit(element, &syncmap)) + break; + } + + if (element == MAX_MIRRORS) { + /* Couldn't find an element in sync. */ + return(-EIO); + } + else if (!(syncmap & (~(1 << element)))) { + /* Only 1 choice, so just use it. */ + /* clear the sync bits for this region */ + sync_clear(ms, bio, ~syncmap); + return(element); + } + else + { + /* Multiple writes needed. Just queue it. */ + return(MAX_MIRRORS); + } +} + +static void write_complete(struct mirror_set *ms) +{ + unsigned int i, j, index, rc; + unsigned long flags; + iocontext *list, *io; + struct bio *bio; + mregion_t region; + + while (1) { + spin_lock_irqsave(&ms->irqlock, flags); + if ((list = ms->iohead) == NULL) { + spin_unlock_irqrestore(&ms->irqlock, flags); + return; + } + ms->iohead = NULL; + spin_unlock_irqrestore(&ms->irqlock, flags); + + while (list) { + io = list; + list = list->link; + + if (io->error) { + /* + * only error the io if all mirrors failed. + */ + rc = -EIO; + index = 0; + +// printk(KERN_ALERT"NWRAID1: Write error=%d iomap=%d \n", io->error, io->map); + spin_lock(&ms->lock); + for (i = 0; i < MAX_MIRRORS; i++) { + if (test_bit(i, &io->map)) { + if (test_bit(index, &io->error)) { + /* Check if this is the only active path. If so, don't clear the + ** bits (we need at least 1 good path) but fail the message */ + j = ~(1 << i); + if ((ms->activemap & j) != 0) { + clear_bit(i, &ms->activemap); + clear_bit(i, (unsigned long*) &ms->log.stamp.insyncmap); + region = io->region; + for (j=0; jcount; j++, region++) { + if (test_bit(region, ms->log.sync[i])) { + clear_bit(region, ms->log.sync[i]); + // printk(KERN_ALERT"NWRAID1: Clear region=%d\n", region); + ms->sync_count[i]--; + ms->flushflag = 1; + } + } + } + } + else { + rc = 0; + } + index++; + } + } + spin_unlock(&ms->lock); + } + else { + rc = 0; + } + + bio = io->bio; + return_context(io); + bio_endio(bio, bio->bi_size, rc); + + } + } +} + +static void write_callback(unsigned long error, void *rtncontext) +{ + iocontext *context = (iocontext*) rtncontext; + struct mirror_set *ms = context->ms; + unsigned long flags; + + context->error = error; + + spin_lock_irqsave(&ms->irqlock, flags); + if (ms->iohead == NULL) { + ms->iohead = ms->iotail = context; + } + else { + ms->iotail->link = context; + ms->iotail = context; + } + context->link = NULL; + spin_unlock_irqrestore(&ms->irqlock, flags); + + wake(); +} + +static void do_write(iocontext *context) +{ + struct mirror_set *ms = context->ms; + struct bio *bio = context->bio; + uint32_t i, count, index, sync; + struct io_region io[MAX_MIRRORS]; + struct mirror *m; + mregion_t region; + + + spin_lock(&ms->lock); + + context->map = 0; + + for (i = 0, index = 0; i < MAX_MIRRORS; i++) { + if (test_bit(i, (unsigned long*) &ms->log.stamp.membermap) == 0) + continue; + + if (test_bit(i, &ms->activemap) == 0) { + /* Set the out of sync bits for this mirror element */ + count = context->count; + region = context->region; + while (count) { + if (test_bit(region, ms->log.sync[i])) { + clear_bit(region, ms->log.sync[i]); +// printk(KERN_ALERT"NWRAID1: Clear region=%d\n", region); + ms->sync_count[i]--; + ms->flushflag = 1; + } + count--; + region++; + } + + clear_bit(i, (unsigned long*) &ms->log.stamp.insyncmap); + + continue; + } + else { + /* Skip non-synced elements if not SBD*/ + if (ms->log.stamp.partitiontype != 0x1AD) { + sync = 0; + count = context->count; + region = context->region; + while (count) { + if (test_bit(region, ms->log.sync[i])) { + sync = 1; + break; + } + count--; + region++; + } + + if (sync == 0) + continue; + } + } + + m = &ms->mirror[i]; + set_bit(i, &context->map); + io[index].bdev = m->dev->bdev; + io[index].sector = m->offset + (bio->bi_sector - ms->ti->begin); + io[index].count = bio->bi_size >> 9; + index++; + } + + spin_unlock(&ms->lock); + + if (index == 0) { + /* No elements to write to ! */ + return_context(context); + bio_endio(bio, bio->bi_size, -EIO); + return; + } + + i = dm_io_async_bvec(index, io, WRITE, + bio->bi_io_vec + bio->bi_idx, + write_callback, context); + + if (i) { + /* Error sending the request */ + return_context(context); + bio_endio(bio, bio->bi_size, i); + return; + } +} + +static void do_writes(struct mirror_set *ms, struct bio *writes) +{ + struct bio *bio; + unsigned int elapsed; + iocontext *context, *head=NULL, *tail=NULL; + + + if (writes == NULL) + return; + + /* + * Look at all the writes. If the dirty bit is already set, + * send the write down. If not, set the dirty bit and wait + * for the dirty map to get flushed. + */ + + while (writes != NULL) { + + bio = writes; + writes = bio->bi_next; + bio->bi_next = NULL; + + /* Get an IO context */ + spin_lock(&ms->lock); + + if ((context = ms->iolist) == NULL) { + spin_unlock(&ms->lock); + alloc_io_context(ms); + spin_lock(&ms->lock); + if ((context = ms->iolist) == NULL) { + spin_unlock(&ms->lock); +// printk(KERN_ALERT"NWRAID: No context messages\n"); + queue_bio(ms, bio, WRITE); + continue; + } + } + ms->iolist = context->link; + spin_unlock(&ms->lock); + + context->bio = bio; + context->error = 0; + context->count = (unsigned short) bio_to_region(ms, bio, &context->region); + context->link = NULL; + context->flags = 0; + + if (ms->remirrorstate > INIT_REMIRROR) { + /* Check to see if the region is busy */ + if (remirror_bts(context)) { + /* It's busy, so requeue */ +// printk(KERN_ALERT"NWRAID1: Remirror bit %d busy\n", context->region); + return_context(context); + queue_bio(ms, bio, WRITE); + continue; + } + } + + if ((dirty_bts(ms, bio)) && (head == NULL)) { + do_write(context); + } + else { + if (head == NULL) { + head = tail = context; + } + else { + tail->link = context; + tail = context; + } + context->link = NULL; + } + } + + /* Check to see if it is time to update the dirty bits */ + if (jiffies < ms->writetime) { + elapsed = (60*15); + } + else { + elapsed = (jiffies - ms->writetime) / HZ; + } + + if (elapsed >= (60*15)) { /* 15 minutes */ + if (memcmp(ms->log.dirty, ms->currentwrite, LOG_MAP_SIZE*sizeof(unsigned long))) { + memcpy(ms->log.dirty, ms->currentwrite, LOG_MAP_SIZE*sizeof(unsigned long)); + ms->flushflag = 1; + } + memset(ms->currentwrite, 0, LOG_MAP_SIZE*sizeof(unsigned long)); + ms->writetime = jiffies; + } + + /* + * Now that all the dirty bits are set, flush them. + * Then send down the writes. + */ + if (head) { + flush_log(ms); + + while (head) { + context = head; + head = head->link; + do_write(context); + } + } + +} + +/*----------------------------------------------------------------- + * kmirrord + *---------------------------------------------------------------*/ +static LIST_HEAD(_mirror_sets); +static DECLARE_RWSEM(_mirror_sets_lock); + +static void do_mirror(struct mirror_set *ms) +{ + struct bio *reads, *writes; + unsigned long flags; + + if (ms->iohead) { + write_complete(ms); + } + + if (ms->remirrorstate != NO_REMIRROR) { + if (ms->writehead) { + remirror_write(ms); + } + + if (ms->completehead) { + remirror_complete(ms); + } + + if (ms->remirrorstate == REMIRRORING) { + do_remirror(ms); + } + else if (ms->remirrorstate == DONE) { + stop_remirror(ms, 0); + } + } + +// if (ms->suspendflag) { +// return; +// } + + if (ms->retry.head) { + spin_lock_irqsave(&ms->irqlock, flags); + reads = bio_list_get(&ms->retry); + spin_unlock_irqrestore(&ms->irqlock, flags); + + do_retrys(ms, reads); + } + + spin_lock(&ms->lock); + + reads = bio_list_get(&ms->reads); + writes = bio_list_get(&ms->writes); + + spin_unlock(&ms->lock); + + do_reads(ms, reads); + do_writes(ms, writes); + + if (ms->flushflag) { + flush_log(ms); + } + + dm_table_unplug_all(ms->ti->table); +} + +static void do_work(void *ignored) +{ + struct mirror_set *ms; + + down_read(&_mirror_sets_lock); + list_for_each_entry (ms, &_mirror_sets, list) + do_mirror(ms); + up_read(&_mirror_sets_lock); +} + +/*----------------------------------------------------------------- + * Target functions + *---------------------------------------------------------------*/ +static void free_context(struct mirror_set *ms) +{ + int i; + struct dm_target *ti = ms->ti; + struct iocontext_block *block; + struct read_context_block *rblock; + + for (i=0; imirror[i].dev) { + dm_put_device(ti, ms->mirror[i].dev); + } + if (ms->mirror[i].flush_dev) { + dm_put_device(ti, ms->mirror[i].flush_dev); + } + } + + while ((block = ms->ioblocklist) != NULL) { + ms->ioblocklist = block->next; + kfree(block); + } + + while ((rblock = ms->readblocklist) != NULL) { + ms->readblocklist = rblock->next; + kfree(block); + } + + kfree(ms); +} + +static int refresh_log(struct mirror_set *ms) +{ + int r=-ENODATA, i, j, flush=0; + struct io_region io; + unsigned long mask, ebits; + raid1_stamp_t *stamp; + struct mirror *m; + + mask = ms->log.stamp.insyncmap & ms->loadedmap; + + stamp = vmalloc(3072); + if (stamp == NULL) { + return -ENOMEM; + } + +// printk(KERN_ALERT"NWRAID1: Refreshing log. Mask = %d\n", mask); + for (i=0; imirror[i].flush_dev->bdev; + io.sector = ms->mirror[i].flush_offset; + io.count = 6; + + dm_table_flush_all(ms->ti->table); + r = dm_io_sync_vm(1, &io, READ, stamp, &ebits); + + if (r == 0) { + if ((stamp->version != 0) || + (memcmp(&stamp->stamptext, "RaId1_PaRtItIoN", 15) != 0) || + (stamp->raididentifier != ms->log.stamp.raididentifier)) { + +// printk(KERN_ALERT"NWRAID1: Invalid stamp\n"); + r = -ENODATA; + continue; + } + } + +// printk(KERN_ALERT"NWRAID1: Stamp times ms=%d, stamp=%d\n", +// ms->log.stamp.stamptime, stamp->stamptime); + if ((r == 0) && + (ms->log.stamp.stamptime < stamp->stamptime)) { + /* Copy in the information from the newer stamp. */ + memcpy(&ms->log.stamp, stamp, 3072); + mask = ms->loadedmap ^ ms->log.stamp.membermap; + mask &= ms->loadedmap; + /* Delete out any elements that are gone. */ + if (mask != 0) { +// printk(KERN_ALERT"NWRAID1:Adjust mask=%d\n",mask); + memset(stamp, 0, 3072); + for (j=0; jmirror[j]; + io.bdev = m->flush_dev->bdev; + io.sector = m->flush_offset; + io.count = 6; + dm_io_sync_vm(1, &io, WRITE, stamp, &ebits); + clear_bit(j, &ms->loadedmap); + clear_bit(j, &ms->activemap); + dm_put_device(ms->ti, m->dev); + dm_put_device(ms->ti, m->flush_dev); + m->dev = NULL; + m->flush_dev = NULL; + m->offset = 0; + m->flush_offset = 0; + ms->nr_mirrors--; + flush = 1; + printk(KERN_ALERT"NWRAID1: Removed element %d\n",j); + } + } + } + + } + + break; + } + } + + vfree(stamp); + if (flush) { + flush_log(ms); + } + wake(); + return(r); +} + +static int get_mirror(struct mirror_set *ms, + struct dm_target *ti, + unsigned int mirror, + char **argv) +{ + int r, index; + sector_t offset, foffset; + struct dm_dev *dev, *flush; + raid1_stamp_t *stamp; + struct io_region io; + unsigned long ebits; + struct mirror *m; + + index = ms->nr_mirrors * 2; + + if (sscanf(argv[index + 1], SECTOR_FORMAT, &offset) != 1) { + ti->error = "nw-mirror: Invalid offset"; + return -EINVAL; + } + + if (sscanf(argv[1], SECTOR_FORMAT, &foffset) != 1) { + ti->error = "nw-mirror: Invalid flush offset"; + return -EINVAL; + } + + if (dm_get_device(ti, argv[index], offset, ti->len, + dm_table_get_mode(ti->table), + &dev)) { + ti->error = "nw-mirror: Device lookup failure"; + return -ENXIO; + } + + if (dm_get_device(ti, argv[0], foffset, 32, + dm_table_get_mode(ti->table), + &flush)) { + ti->error = "nw-mirror: Flush device lookup failure"; + dm_put_device(ti, dev); + return -ENXIO; + } + + /* Read the header stamp */ + io.bdev = flush->bdev; + io.sector = foffset; + io.count = 6; + + stamp = vmalloc(3072); + if (stamp == NULL) { + dm_put_device(ti, dev); + dm_put_device(ti, flush); + return -ENOMEM; + } + + r = dm_io_sync_vm(1, &io, READ, stamp, &ebits); + printk(KERN_ALERT"NWRAID1: Stamp ccode = %d\n", r); + + if (r == 0) { + if ((stamp->version == 0) && + (memcmp(&stamp->stamptext, "RaId1_PaRtItIoN", 15) == 0)) { + + m = &ms->mirror[stamp->elementindex]; + m->dev = dev; + m->offset = offset; + m->flush_dev = flush; + m->flush_offset = foffset; + set_bit(stamp->elementindex, &ms->loadedmap); + set_bit(stamp->elementindex, &ms->activemap); + } + else { + r = -ENODATA; + } + } + + if (r == 0) { + if (mirror == 0) { + memcpy(&ms->log.stamp, stamp, 3072); + } + else { + /* See if we have newer data */ + if (ms->log.stamp.stamptime < stamp->stamptime) { + /* Read in the information from the newer stamp. */ + memcpy(&ms->log.stamp, stamp, 3072); + } + } + } + else { + dm_put_device(ti, dev); + dm_put_device(ti, flush); + } + + vfree(stamp); + + return r; +} + +static int AdjustMapsUsingWriteMap(struct mirror_set *ms) +{ + uint32_t i, j, ulongs, insync = 1; + unsigned long *writemap; + unsigned long mask; + + /* If only one element, ignore the write map. */ + if (ms->log.stamp.elementcount <= 1) + return 0; + + /* Find an element in sync */ + mask = ms->log.stamp.membermap + & ms->log.stamp.insyncmap + & ms->activemap; +// printk(KERN_ALERT"NWRAID1: Adjust mask=%d\n", mask); + for (i=0; ilog.stamp.membermap; + clear_bit(i, &mask); + +// j = CountBits(ms->log.dirty, ms->log.stamp.nr_regions); +// printk(KERN_ALERT"NWRAID1: Adjust count=%d\n", j); + + writemap = ms->log.dirty; + + ulongs = ms->log.stamp.nr_regions / (sizeof(unsigned long) * 8); + + /* Do all the full longs */ + for (i=0; ilog.sync[j][i] &= ~(*writemap); + if (insync) + clear_bit(j, (unsigned long*) &ms->log.stamp.insyncmap); + } + } + insync = 0; + } + } + + /* Fix up the last long */ + ulongs = ms->log.stamp.nr_regions - (ulongs / (sizeof(unsigned long) * 8)); + if (ulongs) { + *writemap &= (1 << ulongs) - 1; + if (*writemap != 0) + { + for (j=0; jlog.sync[j][i] &= ~(*writemap); + if (insync) + clear_bit(j, (unsigned long*) &ms->log.stamp.insyncmap); + } + } + } + } + + /* Set the sync counts */ + for (i=0; ilog.stamp.membermap)) { + if ((ms->sync_count[i] = CountBits(ms->log.sync[i], + ms->log.stamp.nr_regions)) + < ms->log.stamp.nr_regions) { + clear_bit(i, (unsigned long*) &ms->log.stamp.insyncmap); + } + else { + set_bit(i, (unsigned long*) &ms->log.stamp.insyncmap); + } + printk(KERN_ALERT"NWRAID1: Sync count %d =%d\n", i, ms->sync_count[i]); + } + } + + if (ms->log.stamp.insyncmap == 0) { + /* We cleared all the sync bit. Set the master back in sync */ + for (i=0; ilog.stamp.insyncmap); + memset(ms->log.sync[i], 0xFF, LOG_MAP_SIZE * sizeof(unsigned long)); + break; + } + } + } + +// printk(KERN_ALERT"NWRAID1: New Sync map=%d\n", ms->log.stamp.insyncmap); + return 0; +} + +static int add_mirror_set(struct mirror_set *ms) +{ + down_write(&_mirror_sets_lock); + list_add_tail(&ms->list, &_mirror_sets); + up_write(&_mirror_sets_lock); + + return 0; +} + +static void del_mirror_set(struct mirror_set *ms) +{ + down_write(&_mirror_sets_lock); + list_del(&ms->list); + up_write(&_mirror_sets_lock); +} + +/* + * Create dirty log: log_type #log_params + */ +//static struct dirty_log *create_dirty_log(struct dm_target *ti, +// unsigned int argc, char **argv, +// unsigned int *args_used) +//{ +// unsigned int param_count; +// struct dirty_log *dl; +// +// if (argc < 2) { +// ti->error = "nw-mirror: Insufficient mirror log arguments"; +// return NULL; +// } +// +// if (sscanf(argv[1], "%u", ¶m_count) != 1 || param_count != 1) { +// ti->error = "nw-mirror: Invalid mirror log argument count"; +// return NULL; +// } +// +// *args_used = 2 + param_count; +// +// if (argc < *args_used) { +// ti->error = "nw-mirror: Insufficient mirror log arguments"; +// return NULL; +// } +// +// dl = dm_create_dirty_log(argv[0], ti->len, param_count, argv + 2); +// if (!dl) { +// ti->error = "nw-mirror: Error creating mirror dirty log"; +// return NULL; +// } +// +// if (!_check_region_size(ti, dl->type->get_region_size(dl))) { +// ti->error = "nw-mirror: Invalid region size"; +// dm_destroy_dirty_log(dl); +// return NULL; +// } +// +// return dl; +//} + +/* + * Construct a mirror mapping: + * + * log_type #log_params + * #mirrors [mirror_path offset]{2,} + * + */ +#define DM_IO_PAGES 64 +static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) +{ + int r; + unsigned int sharedflag; + unsigned int nr_mirrors, m, args_used = 3; + struct mirror_set *ms; +// struct dirty_log *dl; + +// dl = create_dirty_log(ti, argc, argv, &args_used); +// if (!dl) +// return -EINVAL; + + printk(KERN_ALERT"NWRAID1: Got to constructor. ti=%x argc=%d\n", ti, argc); + argv += args_used; + argc -= args_used; + + if (!argc || + sscanf(argv[0], "%u", &sharedflag) != 1 || + sharedflag > 3) { + + ti->error = "raid1: Invalid shared flag"; +// dm_destroy_dirty_log(dl); + return -EINVAL; + } + + argv++, argc--; + + if (!argc || + sscanf(argv[0], "%u", &nr_mirrors) != 1 || + nr_mirrors < 1 || + nr_mirrors > MAX_MIRRORS) { + + ti->error = "raid1: Invalid number of mirrors"; +// dm_destroy_dirty_log(dl); + return -EINVAL; + } + + argv++, argc--; + + if (argc != (nr_mirrors * 4)) { + ti->error = "raid1: Wrong number of mirror arguments"; +// dm_destroy_dirty_log(dl); + return -EINVAL; + } + + ms = kmalloc(sizeof(struct mirror_set), GFP_KERNEL); + if (!ms) { + ti->error = "raid1: Cannot allocate mirror context"; +// dm_destroy_dirty_log(dl); + return -ENOMEM; + } + + memset(ms, 0, sizeof(struct mirror_set)); + spin_lock_init(&ms->lock); + spin_lock_init(&ms->rlock); + spin_lock_init(&ms->irqlock); + bio_list_init(&ms->reads); + bio_list_init(&ms->writes); + bio_list_init(&ms->readas); + bio_list_init(&ms->retry); + atomic_set(&ms->remirror_count,0); + atomic_set(&ms->iocount,0); + ms->writetime = jiffies; + ms->bitflags |= NEW_FLAG; + + alloc_io_context(ms); + alloc_read_context(ms); + ms->nr_mirrors = nr_mirrors; + if (sharedflag) { + ms->sharedflag = 1; + if (sharedflag & 2) { + ms->remirrorenabled = 1; + } + } + else { + ms->remirrorenabled = 1; + } + + ms->ti = ti; + ti->private = ms; + + printk(KERN_ALERT"NWRAID1: Mirror count =%d\n", nr_mirrors); + + dm_table_flush_all(ms->ti->table); + + /* Get the mirror logs and parameter sets */ + for (m = 0; m < nr_mirrors; m++) { + r = get_mirror(ms, ti, m, argv); + if (r) { + free_context(ms); + return r; + } + + argv += 2; + argc -= 2; + + } + if (ms->log.stamp.regionshift > 10) { + ms->bio_per_region = 1 << (ms->log.stamp.regionshift - 10); + } + else { + ms->bio_per_region = 1; + } + + printk(KERN_ALERT"NWRAID1: element count = %d\n", ms->log.stamp.elementcount); + printk(KERN_ALERT"NWRAID1: membermap = %x\n", ms->log.stamp.membermap); + printk(KERN_ALERT"NWRAID1: syncmap = %x\n", ms->log.stamp.insyncmap); + printk(KERN_ALERT"NWRAID1: loadedmap = %x\n", ms->loadedmap); + printk(KERN_ALERT"NWRAID1: activemap = %x\n", ms->activemap); + printk(KERN_ALERT"NWRAID1: capacity = %d\n", ms->log.stamp.raidcapacity); + printk(KERN_ALERT"NWRAID1: regions = %d\n", ms->log.stamp.nr_regions); + printk(KERN_ALERT"NWRAID1: shared = %d remirror = %d\n", ms->sharedflag, ms->remirrorenabled); + +// AdjustMapsUsingWriteMap(ms); +// printk(KERN_ALERT"NWRAID1: adjusted syncmap = %x\n", ms->log.stamp.insyncmap); +// +// /* Clear out all the sync blocks where there are no members */ +// for (m=0; mlog.stamp.membermap)) { +// memset(ms->log.sync[m], 0, LOG_MAP_SIZE * sizeof(unsigned long)); +// } +// } +// +// flush_log(ms); + + add_mirror_set(ms); + + printk(KERN_ALERT"NWRAID1: Constructor completed OK\n"); + return 0; +} + +static void mirror_dtr(struct dm_target *ti) +{ + struct mirror_set *ms = (struct mirror_set *) ti->private; + + printk(KERN_ALERT"NWRAID1: Destructor called ti=%x\n", ti); + del_mirror_set(ms); + + if (ms->remirrorstate > NO_REMIRROR) { + stop_remirror(ms, 1); + } + +// /* I assume all IOs are complete. Clear the write map */ +// memset(&ms->log.dirty, 0, 512); +// flush_log(ms); + free_context(ms); +} + +/* + * Mirror mapping function + */ +static int mirror_map(struct dm_target *ti, struct bio *bio, + union map_info *map_context) +{ + int rw = bio_rw(bio); + unsigned long flags, index; + struct mirror_set *ms = (struct mirror_set*) ti->private; + struct io_region io; + int r; + + /* + * We don't want to fast track a recovery just for a read + * ahead. So we just let it silently fail. + * FIXME: get rid of this. + */ + if (rw == READA) { + return -EIO; + } + +// printk(KERN_ALERT"NWRAID5: Received a %s request. Sector=" SECTOR_FORMAT "\n", +// (rw == READ) ? "READ" : "WRITE", bio->bi_sector - ti->begin); + atomic_inc(&ms->iocount); + +// if (ms->suspendflag) { +// queue_bio(ms, bio, rw); +// return 0; +// } + + if (rw == WRITE) { + /* First check if there is only one write to perform */ + if ((r = check_write(ms, bio)) >= 0) { + if (r < MAX_MIRRORS) { + /* Only 1 valid element, so do it. */ + if (alloc_read(ms, bio, (unsigned long) r) == 0) { + map_bio(ms, &ms->mirror[r], bio); + return(1); + } + else { + queue_bio(ms, bio, rw); + return 0; + } + } + else { + /* Multiple writes, so queue it. */ + queue_bio(ms, bio, rw); + return 0; + } + } + else { + atomic_dec(&ms->iocount); + return(r); + } + } + + index = choose_mirror(ms, bio); + if (index >= MAX_MIRRORS) { + atomic_dec(&ms->iocount); + printk(KERN_ALERT"NWRAID1: Choose mirror returned error\n"); + return -EIO; + } + + if (alloc_read(ms, bio, index) == 0) { + io.bdev = ms->mirror[index].dev->bdev; + io.sector = ms->mirror[index].offset + (bio->bi_sector - ms->ti->begin); + io.count = bio->bi_size >> 9; + r = dm_io_async_bvec(1, &io, bio_rw(bio), + bio->bi_io_vec + bio->bi_idx, + retry_callback, bio); + if (r) { + spin_lock_irqsave(&ms->irqlock, flags); + bio_list_add(&ms->retry, bio); + spin_unlock_irqrestore(&ms->irqlock, flags); + wake(); + } + return(0); + } + else { + queue_bio(ms, bio, rw); + return 0; + } +} + +static int mirror_end_io(struct dm_target *ti, struct bio *bio, + int error, union map_info *map_context) +{ + struct mirror_set *ms = (struct mirror_set *) ti->private; + int count; + +// if (error) +// printk(KERN_ALERT"NWRAID1: ENDIO bio completed with err=%d\n", error); + count = atomic_dec_and_test(&ms->iocount); +// if (ms->remirrorstate == REMIRRORING) { +// printk(KERN_ALERT"NWRAID1: IOCount = %d\n", count); +// } + if ((count) && (ms->remirrorstate == REMIRRORING)) { + wake(); + } + return error; +} + +static void mirror_suspend(struct dm_target *ti) +{ + struct mirror_set *ms = (struct mirror_set *) ti->private; +// printk(KERN_ALERT"NWRAID1: Suspended called ti = %x\n", ti); + stop_remirror(ms, 1); +// printk(KERN_ALERT"NWRAID1: Refreshing log\n"); + refresh_log(ms); + memset(&ms->log.dirty, 0, 512); +// printk(KERN_ALERT"NWRAID1: Flushing log\n"); + flush_log(ms); + ms->suspendflag = 1; +// printk(KERN_ALERT"NWRAID1: Suspend Complete\n"); +} + +static void mirror_resume(struct dm_target *ti) +{ + struct mirror_set *ms = (struct mirror_set *) ti->private; + unsigned int i; + +// printk(KERN_ALERT"NWRAID1: Resume called ti = %x\n", ti); + refresh_log(ms); + + if (ms->bitflags & NEW_FLAG) { + AdjustMapsUsingWriteMap(ms); + printk(KERN_ALERT"NWRAID1: adjusted syncmap = %x\n", ms->log.stamp.insyncmap); + + /* Clear out all the sync blocks where there are no members */ + for (i=0; ilog.stamp.membermap)) { + memset(ms->log.sync[i], 0, LOG_MAP_SIZE * sizeof(unsigned long)); + } + } + +// printk(KERN_ALERT"NWRAID1: Flushing log\n"); + flush_log(ms); + ms->bitflags &= ~NEW_FLAG; + } + + ms->suspendflag = 0; + start_remirror(ms); + wake(); +// printk(KERN_ALERT"NWRAID1: Resume Complete\n"); +} + +static int mirror_status(struct dm_target *ti, status_type_t type, + char *result, unsigned int maxlen) +{ + char buffer[32]; + unsigned int m, sz = 0; + struct mirror_set *ms = (struct mirror_set *) ti->private; + + switch (type) { + case STATUSTYPE_INFO: + /* If shared and not enabled, get the current status from disk */ + if (ms->sharedflag && !ms->remirrorenabled) { + refresh_log(ms); + } + + m = ms->remirrorenabled; + if (ms->remirrorstate != NO_REMIRROR) + m |= 2; + if (ms->sharedflag) { + m |= 8; + } + if (ms->suspendflag) { + m |= 16; + } + if (ms->pauseflag) { + m |= 32; + } + + sz += snprintf(result + sz, maxlen - sz, "%d %u %u %u %u %u %u ", + ms->nr_mirrors, + ms->log.stamp.nr_regions, + ms->log.stamp.membermap, + ms->loadedmap, + ms->activemap, + ms->log.stamp.insyncmap, + m); + + for (m = 0; m < MAX_MIRRORS; m++) { + if (test_bit(m, (unsigned long*) &ms->loadedmap)) { + format_dev_t(buffer, ms->mirror[m].dev->bdev->bd_dev); + sz += scnprintf(result + sz, maxlen - sz, + "%s %u ", buffer, ms->sync_count[m]); + } + } + + break; + + case STATUSTYPE_TABLE: +// printk(KERN_ALERT"NWRAID1: Returning status\n"); + sz += snprintf(result + sz, maxlen - sz, + "nwraid1 0 %d %d %d ", + (1 << ms->log.stamp.regionshift), + ms->sharedflag, + ms->nr_mirrors); + + for (m = 0; m < MAX_MIRRORS; m++) { + if (test_bit(m, (unsigned long*) &ms->loadedmap)) { + format_dev_t(buffer, ms->mirror[m].flush_dev->bdev->bd_dev); + sz += scnprintf(result + sz, maxlen - sz, + "%s " SECTOR_FORMAT " ", + buffer, ms->mirror[m].flush_offset); + } + } + for (m = 0; m < MAX_MIRRORS; m++) { + if (test_bit(m, (unsigned long*) &ms->loadedmap)) { + format_dev_t(buffer, ms->mirror[m].dev->bdev->bd_dev); + sz += scnprintf(result + sz, maxlen - sz, + "%s " SECTOR_FORMAT " ", + buffer, ms->mirror[m].offset); + } + } + } + + return 0; +} + +static int mirror_message(struct dm_target *ti, unsigned argc, char **argv) +{ + char *bptr; + int i, j, r = -EINVAL; + uint32_t loadedmask, mask; + struct mirror_set *ms = (struct mirror_set *) ti->private; + +// printk(KERN_ALERT"NWRAID1: Got message for ti=%p, argc=%d\n", ti, argc); +// if (argc > 0) { +// printk(KERN_ALERT"NWRAID1: message:%s\n", argv[0]); +// } + for (i=0; iremirrorenabled = 1; +// printk(KERN_ALERT"NWRAID1: refresh log\n"); + refresh_log(ms); +// printk(KERN_ALERT"NWRAID1: start remirror\n"); + start_remirror(ms); + wake(); + printk(KERN_ALERT"NWRAID1: Remirror enabled\n"); + r = 0; + } + else if (memcmp(bptr, "off", 3) == 0) { +// printk(KERN_ALERT"NWRAID1: enable turned off\n"); + if (ms->remirrorenabled == 0) { + continue; + } + ms->remirrorenabled = 0; +// printk(KERN_ALERT"NWRAID1: stop remirror\n"); + stop_remirror(ms, 1); + dm_table_flush_all(ti->table); + memset(&ms->log.dirty, 0, 512); +// printk(KERN_ALERT"NWRAID1: flush log\n"); + flush_log(ms); + printk(KERN_ALERT"NWRAID1: Remirror disabled\n"); + r = 0; + } + else if (memcmp(bptr, "pause", 5) == 0) { +// printk(KERN_ALERT"NWRAID1: pause remirror\n"); + ms->pauseflag = 1; + r = 0; + } + else if (memcmp(bptr, "resume", 6) == 0) { +// printk(KERN_ALERT"NWRAID1: resume remirror\n"); + if (ms->pauseflag == 2) { + ms->pauseflag = 0; + start_remirror(ms); + } + else { + ms->pauseflag = 0; + } + wake(); + r = 0; + } + else if (memcmp(bptr, "force", 5) == 0) { +// printk(KERN_ALERT"NWRAID1: force mirror in sync\n"); + refresh_log(ms); + if (ms->nr_mirrors == 1) { + /* Set it in sync */ + loadedmask = ms->log.stamp.membermap & ms->loadedmap; + for (j=0; jlog.stamp.insyncmap |= mask; + memset(ms->log.sync[j], 0xFF, LOG_MAP_SIZE*sizeof(unsigned long)); + flush_log(ms); + break; + } + } + } + r = 0; + } + } + } + + return(r); +} + +static struct target_type raid1_target = { + .name = "raid1", + .version = {1, 0, 1}, + .module = THIS_MODULE, + .ctr = mirror_ctr, + .dtr = mirror_dtr, + .map = mirror_map, + .end_io = mirror_end_io, + .postsuspend = mirror_suspend, + .resume = mirror_resume, + .status = mirror_status, + .message = mirror_message, +}; + +static int nw_mirror_init(void) +{ + int r; + + printk(KERN_ALERT"NWRAID1: Initializing\n"); +// r = dm_dirty_log_init(); +// if (r) +// return r; + + _kmirrord_wq = create_workqueue("nwmirrord"); + if (!_kmirrord_wq) { + DMERR("couldn't start kmirrord"); +// dm_dirty_log_exit(); + return -ENOMEM; + } + INIT_WORK(&_kmirrord_work, do_work, NULL); + + + r = dm_register_target(&raid1_target); + if (r < 0) { + DMERR("%s: Failed to register mirror target", + raid1_target.name); +// dm_dirty_log_exit(); + destroy_workqueue(_kmirrord_wq); + return r; + } + + r = dm_io_get(1); + if (r < 0) { + DMERR("NWRAID1: Failed to initialize io pool"); +// dm_dirty_log_exit(); + destroy_workqueue(_kmirrord_wq); + dm_unregister_target(&raid1_target); + } + + return r; +} + +static void nw_mirror_exit(void) +{ + int r; + + printk(KERN_ALERT"NWRAID1: Exiting\n"); + r = dm_unregister_target(&raid1_target); + if (r < 0) + DMERR("%s: unregister failed %d", raid1_target.name, r); + + destroy_workqueue(_kmirrord_wq); +// dm_dirty_log_exit(); + + dm_io_put(1); +} + +static int __init nw_raid_init(void) +{ + int r; + + if ((r = nw_mirror_init()) == 0) { + if ((r = nw_raid0_init()) == 0) { + if ((r = nw_raid5_init()) != 0) { + nw_raid0_exit(); + nw_mirror_exit(); + } + } + else { + nw_mirror_exit(); + } + } + return(r); +} + +static void __exit nw_raid_exit(void) +{ + nw_mirror_exit(); + nw_raid5_exit(); + nw_raid0_exit(); +} +/* Module hooks */ +module_init(nw_raid_init); +module_exit(nw_raid_exit); + +MODULE_DESCRIPTION(DM_NAME " nwraid1 target"); +MODULE_AUTHOR("Allen Jack "); +MODULE_LICENSE("GPL"); + diff --git a/src/nwnss/nwraid/nwraid5.c b/src/nwnss/nwraid/nwraid5.c new file mode 100644 index 0000000..ee62d55 --- /dev/null +++ b/src/nwnss/nwraid/nwraid5.c @@ -0,0 +1,4217 @@ +/* + * Copyright (C) 2004-2005 Novell, Inc. + * + * This file is released under the GPL. + */ + +#include "dm.h" +#include "dm-bio-list.h" +#include "dm-io.h" +#include "dm-log.h" + +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LOCKEDMASK 0x80000000 + +/* iocontext status defines */ +#define WRITE_ERR_DATA 0x0001 +#define WRITE_ERR_PARITY 0x0002 +#define IO_COMPLETE 0x0004 +#define DATA_MISSING 0x0008 +#define PARITY_MISSING 0x0010 + + +#include "nwraid.h" +#include "dmio.h" + +#define DM_MSG_PREFIX "nwraid5" + +//static void ProcessCacheMessages( +// struct RaidCacheDef *cache, +// uint32_t ccode); + +typedef struct iocontext { + struct iocontext *link; + struct raid_set *rs; + struct bio *bio; + struct RaidCacheDef *cache; + sector_t offset; + unsigned long group; + unsigned long sector; + unsigned long element; + unsigned long parity; + unsigned long err; + atomic_t count; + unsigned long elementcount; + unsigned long status; +}iocontext; + +#define IOBLOCK_COUNT (4068 / sizeof(iocontext)) + +struct iocontext_block { + struct iocontext_block *next; + iocontext list[IOBLOCK_COUNT]; +}; + +static struct workqueue_struct *_kraid_wq; +static struct work_struct _kraid_work; +static atomic_t wakecount; + + +void ClearRestripeIOFlag( + struct raid_set *rs, + unsigned long group) +{ + unsigned long flags; + + spin_lock_irqsave(&rs->irqlock, flags); + + if (rs->lockmapcount[group] > 0) + rs->lockmapcount[group]--; + +// printk(KERN_ALERT"NWRAID5: clear flag unlock group=%d count=%d\n", +// group, rs->lockmapcount[group]); + spin_unlock_irqrestore(&rs->irqlock, flags); +} + +static iocontext *alloc_io_context(struct raid_set *rs) +{ + int i; + struct iocontext_block *block; + iocontext *io; + + /* Only allocate enough buffers to handle all the cache */ + if (rs->context_count > ((CACHE_BUFFERS*2) * rs->stamp.elementcount)) { + return(NULL); + } + + if ((block = kmalloc(4072, GFP_KERNEL)) != NULL) { + + spin_lock(&rs->iolock); + for (i=0, io=block->list; irs = rs; + io->link = rs->iolist; + rs->iolist = io; + } + + /* return the last context */ + io->rs = rs; + io->link = NULL; + /* Link up the block */ + block->next = rs->ioblocklist; + rs->ioblocklist = block; + rs->context_count += IOBLOCK_COUNT; + spin_unlock(&rs->iolock); + + io->err = 0; + io->status = 0; + io->group = 0; +// printk(KERN_ALERT"NWRAID5: Allocated more context.\n"); + return(io); + } + else { +// printk(KERN_ALERT"NWRAID5: Failed to get context.\n"); + return(NULL); + } +} + +static iocontext *get_context(struct raid_set *rs) +{ + iocontext *context, *list; + unsigned long flags; + + spin_lock(&rs->iolock); + if ((context = rs->iolist) == NULL) { + if (rs->returnlist != NULL) { + spin_unlock(&rs->iolock); + spin_lock_irqsave(&rs->irqlock, flags); + list = rs->returnlist; + rs->returnlist = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); +// printk(KERN_ALERT"NWRAID5: Got returned contexts.\n"); + spin_lock(&rs->iolock); + if (list) { + if (rs->iolist == NULL) { + rs->iolist = list; + } + else { + while (list) { + context = list; + list = list->link; + context->link = rs->iolist; + rs->iolist = context; + } + } + } + if ((context = rs->iolist) == NULL) { + spin_unlock(&rs->iolock); + return(NULL); + } + } + else { + spin_unlock(&rs->iolock); + context = alloc_io_context(rs); + return(context); + } + } + rs->iolist = context->link; + context->link = NULL; + context->err = 0; + context->status = 0; + context->group = 0; + spin_unlock(&rs->iolock); + + return(context); +} + +static void put_context(iocontext *context) +{ + struct raid_set *rs = context->rs; + + if (context->group & LOCKEDMASK) { + ClearRestripeIOFlag(rs, (context->group & ~LOCKEDMASK)); + } + + spin_lock(&rs->iolock); + context->link = rs->iolist; + rs->iolist = context; + context->bio = NULL; + spin_unlock(&rs->iolock); +} + +static void queue_context(iocontext *context, int rw) +{ + struct raid_set *rs = context->rs; + int wakeup; + +// printk(KERN_ALERT"NWRAID5: queue context\n"); + + /* If the context is locked, we need to send it back to the beginning */ + if (context->group & LOCKEDMASK) { + queue_bio(rs, context->bio, bio_rw(context->bio)); + put_context(context); + atomic_dec(&rs->iopending); + return; +// ClearRestripeIOFlag(rs, (context->group & ~LOCKEDMASK)); + } + + atomic_dec(&rs->iopending); + + spin_lock(&rs->lock); + if (rw == READ) { + if (rs->queue_readhead == NULL) { + wakeup = 1; + rs->queue_readhead = context; + } + else { + rs->queue_readtail->link = context; + wakeup = 0; + } + rs->queue_readtail = context; + } + else { + if (rs->queue_writehead == NULL) { + rs->queue_writehead = context; + wakeup = 1; + } + else { + rs->queue_writetail->link = context; + wakeup = 0; + } + rs->queue_writetail = context; + } + + context->link = NULL; + spin_unlock(&rs->lock); + + if (wakeup) + wake(rs); +} + +static void return_context(iocontext *context) +{ + struct raid_set *rs = context->rs; + unsigned long flags; + unsigned long group; + +// printk(KERN_ALERT"NWRAID5: return context\n"); + spin_lock_irqsave(&rs->irqlock, flags); + + if (context->group & LOCKEDMASK) { + group = context->group & ~LOCKEDMASK; + if (rs->lockmapcount[group] > 0) { + rs->lockmapcount[group]--; + } + } + + context->link = rs->returnlist; + rs->returnlist = context; + context->bio = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); +} + +static void complete_request(iocontext *context, int r) +{ + if (context->bio != NULL) { + bio_endio(context->bio, context->bio->bi_size, r); + put_context(context); + } +} + +void CalculateParity( + unsigned long *copybuffer, + unsigned long *databuffer, + unsigned long length) +{ + unsigned long i; + + length /= (sizeof(unsigned long) * 8); + + for (i=length; i!=0; i--) + { + copybuffer[0] ^= databuffer[0]; // doing this 8 times reduces the amount + copybuffer[1] ^= databuffer[1]; // of time spent in the for loop + copybuffer[2] ^= databuffer[2]; + copybuffer[3] ^= databuffer[3]; + copybuffer[4] ^= databuffer[4]; + copybuffer[5] ^= databuffer[5]; + copybuffer[6] ^= databuffer[6]; + copybuffer[7] ^= databuffer[7]; + + copybuffer+=8; + databuffer+=8; + } +} + +static void do_engine_parity(struct engine *from, struct engine *to) +{ + struct page_list *fromlist, *tolist; + + unsigned long i, pages; + + pages = from->rs->stripesize >> 3; + fromlist = from->list; + tolist = to->list; + + for (i=0; ipage), + (unsigned long *) page_address(fromlist->page), + PAGE_SIZE); + } +} + +/*----------------------------------------------------------------- + * Error functions + *---------------------------------------------------------------*/ + +static int SetError( + struct raid_set *rs, + uint32_t element) +{ + int ccode = -EIO, i = 0; + struct bio *reads=NULL, *writes=NULL, *bio; + iocontext *readlist=NULL, *writelist=NULL, *context; + struct ReadMap *readmap; + struct RestripeMap *map; + struct engine *engine; + + +// printk(KERN_ALERT"NWRAID5: SetError called element=%d missing=%d\n", +// element, rs->stamp.missingelement); + spin_lock(&rs->lock); + + if (rs->stamp.missingelement == -1) + { + rs->stamp.missingelement = element; + rs->stamp.resyncparityflag = 1; + clear_bit(element, &rs->activemap); + rs->flags &= ~INSYNC_FLAG; + rs->flags |= FLUSH_FLAG; + i = 1; + + /* Signal user that the device is degraded */ + } + + if (rs->stamp.missingelement == element) + { + ccode = 0; + } + else + { + /* deactivate raid */ + if (!(rs->flags & DEACTIVE_FLAG)) { + + rs->flags |= DEACTIVE_FLAG; + reads = rs->reads.head; + writes = rs->writes.head; + rs->reads.head = rs->reads.tail = rs->writes.head = rs->writes.tail = NULL; + readlist = rs->queue_readhead; + writelist = rs->queue_writehead; + rs->queue_readhead = NULL; + rs->queue_writehead = NULL; + } + } + + spin_unlock(&rs->lock); + + /* Return all the queued requests */ + while (reads) { + bio = reads; + reads = bio->bi_next; + bio->bi_next = NULL; + atomic_inc(&rs->iopending); /* endio will decrement it */ + bio_endio(bio, bio->bi_size, -EIO); + } + + while (writes) { + bio = writes; + writes = bio->bi_next; + bio->bi_next = NULL; + atomic_inc(&rs->iopending); /* endio will decrement it */ + bio_endio(bio, bio->bi_size, -EIO); + } + + while (readlist) { + context = readlist; + readlist = readlist->link; + atomic_inc(&rs->iopending); /* endio will decrement it */ + complete_request(context, -EIO); + } + + while (writelist) { + context = writelist; + writelist = writelist->link; + atomic_inc(&rs->iopending); /* endio will decrement it */ + complete_request(context, -EIO); + } + + if (i) { + wake(rs); + } + + if (rs->restripestate > NO_RESTRIPE) + { + if ((ccode) || (rs->flags & RESYNC_FLAG)) { + spin_lock(&rs->rlock); + rs->flags |= RESTRIPE_ABORT; + if (rs->flags & RESYNC_FLAG) { + rs->restripestate = DONE; + } + if (rs->flags & DEACTIVE_FLAG) { + /* Abort all the engines in the maps */ + if (rs->readmap) { + readmap = rs->readmap; + for (i=rs->readmapcount; i>0; i--, readmap++) { + if (readmap->stripe != -1) { + if (readmap->engine) { + readmap->engine->link = rs->read; + rs->read = readmap->engine; + rs->restripe_count--; + } + while (readmap->link) { + engine = readmap->link; + readmap->link = engine->link; + engine->link = rs->read; + rs->read = engine; + rs->restripe_count--; + } + readmap->stripe = -1; + } + } + } + + if (rs->map) { + map = rs->map; + for (i=rs->stamp.elementcount; i>0; i--, map++) { + if (map->stripe != -1) { + if (map->engine) { + map->engine->link = rs->read; + rs->read = map->engine; + rs->restripe_count--; + } + map->stripe = -1; + } + } + } + } + spin_unlock(&rs->rlock); + } + } + + return(ccode); +} + +static void clear_bitmap(iocontext *context) +{ + unsigned long group = context->group & ~LOCKEDMASK; + int dowake = 0; + +// printk(KERN_ALERT"NWRAID5: clear bitmap group = %d\n", group); + spin_lock(&context->rs->lock); + if (test_bit(group, context->rs->bitmap)) { + clear_bit(group, context->rs->bitmap); + context->rs->flags |= FLUSH_FLAG; + dowake = 1; + } + spin_unlock(&context->rs->lock); + + if (dowake) { + wake(context->rs); + } +} + +/*----------------------------------------------------------------- + * Restripe. + *---------------------------------------------------------------*/ +static void reset_restripe_count(struct raid_set *rs, struct engine *engine) +{ + struct ReadMap *readmap; + struct RestripeMap *map; + struct engine *temp; + sector_t stripe; + int i; + + + spin_lock(&rs->rlock); + + /* First check if we already reset the count */ + if (rs->flags & RESTRIPE_ABORT) { + rs->restripe_count--; + engine->link = rs->read; + rs->read = engine; + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + spin_unlock(&rs->rlock); + return; + } + + rs->flags |= (RESTRIPE_ABORT | RESTRIPE_RESTART); + + /* Clear out all the sync bits */ + memset(rs->bitmap, 0, 512); + /* Reset the block to the beginning of the stripe */ + stripe = rs->restripe_block = rs->completed_block = + engine->stripe * (rs->stamp.elementcount - 1); + rs->restripe_block -= sector_div(stripe, (rs->stamp.oldelementcount - 1)); + + /* Readjust the last block to end on a stripe. */ + rs->lastblock += (rs->stamp.oldelementcount - 2); + sector_div(rs->lastblock, (rs->stamp.oldelementcount - 1)); + rs->lastblock *= (rs->stamp.oldelementcount - 1); + rs->lastblock += (rs->stamp.oldelementcount - 2); + + rs->restripe_count--; + engine->link = rs->read; + rs->read = engine; +// printk(KERN_ALERT"NWRAID5: restripe read error block="SECTOR_FORMAT" reset block="SECTOR_FORMAT"\n", +// engine->block, rs->restripe_block); + /* Make sure there are no engines in the read map */ + readmap = rs->readmap; + for (i=rs->readmapcount; i>0; i--, readmap++) { + if (readmap->stripe != -1) { + if (readmap->engine) { + rs->restripe_count--; + readmap->engine->link = rs->read; + rs->read = readmap->engine; + } + while (readmap->link) { + temp = readmap->link; + readmap->link = temp->link; + rs->restripe_count--; + temp->link = rs->read; + rs->read = temp; + } + readmap->stripe = -1; + } + } + map = rs->map; + for (i=rs->stamp.elementcount; i>0; i--, map++) { + if (map->stripe != -1) { + if (map->engine) { + map->engine->link = rs->read; + rs->read = map->engine; + rs->restripe_count--; + } + map->stripe = -1; + } + } + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + spin_unlock(&rs->rlock); +} + +static void restripe_parity_complete(struct raid_set *rs) +{ + struct engine *list, *engine; + unsigned long flags, done = 0; + sector_t stripe = 0; + + spin_lock_irqsave(&rs->irqlock, flags); + if ((list = rs->parity) == NULL) { + spin_unlock_irqrestore(&rs->irqlock, flags); + return; + } + rs->parity = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + spin_lock(&rs->rlock); + + while (list) { + engine = list; + list = list->link; +// printk(KERN_ALERT"NWRAID5: restripe parity complete stripe="SECTOR_FORMAT"\n", +// engine->stripe); + if (engine->flags & PARITY_ERROR) { + spin_unlock(&rs->rlock); + SetError(rs, engine->parity); + spin_lock(&rs->rlock); + } + if (engine->stripe > stripe) { + stripe = engine->stripe; + } + engine->link = rs->read; + rs->read = engine; + rs->restripe_count--; + } + + if (rs->flags & RESTRIPE_ABORT) { + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + spin_unlock(&rs->rlock); + wake(rs); + return; + } + +// if ((rs->completed_block > rs->stamp.lastblock) && + if ((stripe >= rs->laststripe) && + (rs->stamp.oldelementcount != rs->stamp.elementcount)) { + done = 1; +// printk(KERN_ALERT"NWRAID5: restripe parity complete set to DONE\n"); + rs->restripestate = DONE; + if (rs->stamp.missingelement == -1) + rs->flags |= (INSYNC_FLAG | FLUSH_FLAG); + else + rs->flags |= FLUSH_FLAG; +// rs->stamp.flushed_block = rs->stamp.lastblock; + rs->stamp.oldelementcount = rs->stamp.elementcount; + + rs->ti->len = + rs->stamp.capacity = + rs->stamp.elementsize * (rs->stamp.oldelementcount - 1); + +// memset(rs->bitmap, 0xFF, 512); + + rs->restripe_block = + rs->stamp.lastblock = + rs->stamp.flushed_block = + rs->completed_block = + rs->stamp.capacity >> rs->stamp.raidstripeshift; + } + + spin_unlock(&rs->rlock); + + if (done) { + printk(KERN_ALERT"NWRAID: Restripe Complete\n"); + dm_table_event(rs->ti->table); + } + + wake(rs); +} + +static void restripe_parity_callback(unsigned long error, void *context) +{ + struct engine *engine = (struct engine*) context; + struct raid_set *rs = engine->rs; + unsigned long flags; + + if (error) { +// printk(KERN_ALERT"NWRAID5: error in restripe_parity_callback. flag=%d\n", +// (rs->flags & RESTRIPE_ABORT)); + engine->flags |= PARITY_ERROR; + } + +// printk(KERN_ALERT"NWRAID5: restripe parity callback stripe="SECTOR_FORMAT"\n", +// engine->stripe); + spin_lock_irqsave(&rs->irqlock, flags); + engine->link = rs->parity; + rs->parity = engine; + spin_unlock_irqrestore(&rs->irqlock, flags); + + wake(rs); +} + +static void restripe_parity_routine(struct engine *engine) +{ + struct raid_set *rs; + struct RestripeMap *map; + +// sector_t stripe; + uint32_t i; + + rs = engine->rs; + + rs->completed_block++; + +// printk(KERN_ALERT"NWRAID5: restripe parity block="SECTOR_FORMAT" completed="SECTOR_FORMAT" stripe="SECTOR_FORMAT"\n", +// engine->block, rs->completed_block, engine->stripe); + + if (engine->parity == rs->stamp.missingelement) { + restripe_parity_callback(0, engine); + return; + } + + /* Check the map and update parity. */ + map = rs->map; + for (i=rs->stamp.elementcount; i>0; i--, map++) + { + if (map->stripe == engine->stripe) + { + do_engine_parity(engine, map->engine); + engine->link = rs->read; + rs->read = engine; + rs->restripe_count--; + + if (++map->count == rs->stamp.elementcount) + { +// /* Calculate the parity element. */ +// element = (rs->stamp.elementcount - 1) - +// (sector_div(map->stripe, rs->stamp.elementcount)); + map->stripe = -1; + engine = map->engine; + +// printk(KERN_ALERT"NWRAID5: write parity block="SECTOR_FORMAT"\n",engine->block); + engine->to.bdev = rs->elements[engine->parity].dev->bdev; + engine->to.sector = rs->elements[engine->parity].offset + + (engine->stripe << rs->stamp.raidstripeshift); + + if (dm_io_async(1, &engine->to, WRITE, engine->list, 0, + restripe_parity_callback, engine) != 0) { + +// printk(KERN_ALERT"NWRAID5: error in restripe_parity_routine. flag=%d\n", +// (rs->flags & RESTRIPE_ABORT)); + if (SetError(rs, engine->parity) != 0) { + rs->restripe_count--; + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + engine->link = rs->read; + rs->read = engine; + } + } + } + + return; + } + } + + if (i == 0) + { + /* Find a free space to put the engine. */ + map = rs->map; + for (i=rs->stamp.elementcount; i>0; i--, map++) + { + if (map->stripe == -1) + { +// printk(KERN_ALERT"NWRAID5: Engine in map Block= "SECTOR_FORMAT" Stripe="SECTOR_FORMAT"\n", +// engine->block, engine->stripe); + map->engine = engine; + map->stripe = engine->stripe; + map->count = 2; + + return; + } + } + } + + /* If we get here, we didn't find the stripe, nor a free space */ + printk(KERN_ALERT"NWRAID5: Critical error - could not find restripe map\n"); + rs->flags |= RESTRIPE_ABORT; + rs->restripe_count--; + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + engine->link = rs->read; + rs->read = engine; +} + +static void restripe_complete(struct raid_set *rs) +{ + struct engine *list, *engine, *temp; + unsigned long flags; + + while (1) { + spin_lock_irqsave(&rs->irqlock, flags); + if ((list = rs->completehead) == NULL) { + spin_unlock_irqrestore(&rs->irqlock, flags); + return; + } + rs->completehead = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + spin_lock(&rs->rlock); + + while (list) { +// printk(KERN_ALERT"NWRAID5: restripe complete block="SECTOR_FORMAT"\n", +// list->block); + + if (list->flags & TO_ERROR) { + spin_unlock(&rs->rlock); + SetError(rs, list->toindex); + spin_lock(&rs->rlock); + list->flags &= ~TO_ERROR; + } + + if (rs->flags & RESTRIPE_ABORT) { + engine = list; + list = list->link; + rs->restripe_count--; + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + engine->link = rs->read; + rs->read = engine; + continue; + } + + if (list->block == rs->completed_block) { + engine = list; + list = list->link; + restripe_parity_routine(engine); + continue; + } + else { + temp = list; + engine = list->link; + while (engine) { + if (engine->block == rs->completed_block) { + temp->link = engine->link; + restripe_parity_routine(engine); + break; + } + temp = engine; + engine = engine->link; + } + if (engine == NULL) { + break; + } + } + } + spin_unlock(&rs->rlock); + + if (list) { + /* Put the extras back on the list and return */ + spin_lock_irqsave(&rs->irqlock, flags); + while (list) { + engine = list; + list = list->link; + if (rs->completehead == NULL) + rs->completetail = engine; + engine->link = rs->completehead; + rs->completehead = engine; + } + spin_unlock_irqrestore(&rs->irqlock, flags); + return; + } + } +} + +static void restripe_write_callback(unsigned long error, void *context) +{ + struct engine *engine = (struct engine*) context; + struct raid_set *rs = engine->rs; + unsigned long flags; + + if (error) { +// printk(KERN_ALERT"NWRAID5: error in restripe_write_callback. flag=%d\n", +// (rs->flags & RESTRIPE_ABORT)); + engine->flags |= TO_ERROR; + } + +// printk(KERN_ALERT"NWRAID5: restripe write callback block="SECTOR_FORMAT"\n", +// engine->block); + spin_lock_irqsave(&rs->irqlock, flags); + if (rs->completehead == NULL) { + rs->completehead = rs->completetail = engine; + } + else { + rs->completetail->link = engine; + rs->completetail = engine; + } + engine->link = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + wake(rs); +} + +static void send_write(struct raid_set *rs, struct engine *engine) +{ +// printk(KERN_ALERT"NWRAID5: send write block="SECTOR_FORMAT" completed="SECTOR_FORMAT" flags=%x\n", +// engine->block, rs->completed_block, engine->flags); + + if (engine->block >= rs->completed_block) { + if (!(engine->flags & WRITE_MISSING)) { + if (dm_io_async(1, &engine->to, WRITE, engine->list, 0, + restripe_write_callback, engine) != 0) { + +// printk(KERN_ALERT"NWRAID5: error in send_write. flag=%d\n", +// (rs->flags & RESTRIPE_ABORT)); + if (SetError(rs, engine->toindex) == 0) { + restripe_write_callback(0, engine); + } + else { + spin_lock(&rs->rlock); + rs->restripe_count--; + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + engine->link = rs->read; + rs->read = engine; + spin_unlock(&rs->rlock); + } + } + } + else { + /* This element is missing, so just call the callback */ + restripe_write_callback(0, engine); + } + } + else { + spin_lock(&rs->rlock); + rs->restripe_count--; + engine->link = rs->read; + rs->read = engine; + spin_unlock(&rs->rlock); + } +} + +static void restripe_write(struct raid_set *rs) +{ + struct engine *list, *engine, *temp; + struct ReadMap *map; + unsigned long flags; + unsigned long i; + + while (1) { + spin_lock_irqsave(&rs->irqlock, flags); + if ((list = rs->writehead) == NULL) { + spin_unlock_irqrestore(&rs->irqlock, flags); + return; + } + rs->writehead = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + while (list) { + engine = list; + list = list->link; +// printk(KERN_ALERT"NWRAID5: restripe write block="SECTOR_FORMAT" flags=%x\n", +// engine->block, engine->flags); + + if (engine->flags & FROM_ERROR) { + engine->flags &= ~FROM_ERROR; + if (SetError(rs, engine->fromindex) == 0) { + reset_restripe_count(rs, engine); + continue; + } + } + + if (rs->flags & RESTRIPE_ABORT) { +// printk(KERN_ALERT"NWRAID5: restripe write aborted block="SECTOR_FORMAT"\n", +// engine->block); + spin_lock(&rs->rlock); + rs->restripe_count--; + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + engine->link = rs->read; + rs->read = engine; + spin_unlock(&rs->rlock); + } + else { + if (engine->flags & READ_MAP) { + map = rs->readmap; + for (i=rs->readmapcount; i>0; i--, map++) + { + if (map->stripe == engine->readstripe) + { +// printk(KERN_ALERT"NWRAID5: Found readmap block="SECTOR_FORMAT" stripe="SECTOR_FORMAT" flags=%x\n", +// engine->block, engine->readstripe, engine->flags); + if (engine->flags & READ_PARITY) { + map->engine = engine; + while (map->link) { + temp = map->link; + map->link = temp->link; + do_engine_parity(temp, engine); + map->count++; + send_write(rs, temp); + } + } + else if (map->engine) { + do_engine_parity(engine, map->engine); + map->count++; + send_write(rs, engine); + } + else { + engine->link = map->link; + map->link = engine; + } + + if (map->count == rs->readmapcount) + { + map->stripe = -1; + engine = map->engine; + send_write(rs, engine); + } + + break; + } + } + + if (i != 0) { + continue; + } + + /* Find a free space to put the engine. */ + map = rs->readmap; + for (i=rs->readmapcount; i>0; i--, map++) + { + if (map->stripe == -1) + { +// printk(KERN_ALERT"NWRAID5: Engine in readmap Block= "SECTOR_FORMAT" Stripe="SECTOR_FORMAT"\n", +// engine->block, engine->readstripe); + if (engine->flags & READ_PARITY) { + map->engine = engine; + map->link = NULL; + } + else { + map->link = engine; + engine->link = NULL; + map->engine = NULL; + } + map->stripe = engine->readstripe; + map->count = 2; + + break; + } + } + + if (i != 0) { + continue; + } + + /* If we get here, we didn't find the stripe, nor a free space */ + printk(KERN_ALERT"NWRAID5: Critical error - could not find restripe map\n"); + spin_lock(&rs->rlock); + rs->flags |= RESTRIPE_ABORT; + rs->restripe_count--; + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + engine->link = rs->read; + rs->read = engine; + spin_unlock(&rs->rlock); + } + + send_write(rs, engine); + } + } + } +} + +static void restripe_read_callback(unsigned long error, void *context) +{ + struct engine *engine = (struct engine*) context; + struct raid_set *rs = engine->rs; + unsigned long flags; + + if (error) { + engine->flags |= FROM_ERROR; +// printk(KERN_ALERT"NWRAID5: error in restripe_read_callback. flag=%d\n", +// (rs->flags & RESTRIPE_ABORT)); + + } + + spin_lock_irqsave(&rs->irqlock, flags); + if (rs->writehead == NULL) { + rs->writehead = rs->writetail = engine; + } + else { + rs->writetail->link = engine; + rs->writetail = engine; + } + engine->link = NULL; +// printk(KERN_ALERT"NWRAID5: restripe read callback block="SECTOR_FORMAT" head="SECTOR_FORMAT"\n", +// engine->block, rs->writehead->block); + spin_unlock_irqrestore(&rs->irqlock, flags); + + wake(rs); +} + +static void raid5_restripe(struct raid_set *rs) +{ + sector_t block, checkblock, stripe; + unsigned long i, count, element, group, shift; + struct engine *engine; + struct io_region from; + + while (1) { + + if (rs->flags & RESTRIPE_ABORT) + return; + + spin_lock(&rs->rlock); + if ((engine = rs->read) == NULL) { + spin_unlock(&rs->rlock); +// printk(KERN_ALERT"NWRAID5: No Engines\n"); + return; + } + rs->read = engine->link; + engine->flags = 0; + + /* Find the next region */ + block = rs->restripe_block++; +// printk(KERN_ALERT"NWRAID: Restriping block="SECTOR_FORMAT" last=%d lock=%d\n", +// block, rs->stamp.lastblock, rs->lockedgroup); +// if (block > rs->stamp.lastblock) + if (block > rs->lastblock) + { + /* We are done! */ + rs->restripe_block--; + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + }else { + rs->restripestate = DONE_SENDING; + } + printk(KERN_ALERT"NWRAID5: Done sending. count=%d state=%d\n", + rs->restripe_count, rs->restripestate); + engine->link = rs->read; + rs->read = engine; + spin_unlock(&rs->rlock); + return; + } + + engine->block = block; + rs->restripe_count++; + + /* Calculate the write sector and element. */ + shift = rs->stamp.raidstripeshift; + count = rs->stamp.elementcount; + stripe = block; + engine->toindex = sector_div(block, count); + sector_div(stripe, (count-1)); + engine->stripe = stripe; + engine->parity = (count - 1) - (sector_div(stripe, count)); + + /* Calculate the read sector and element. */ + count = rs->stamp.oldelementcount; + stripe = block = engine->block; + engine->fromindex = sector_div(block, count); + sector_div(stripe, (count-1)); + engine->readstripe = stripe; + group = (unsigned long) stripe >> rs->stamp.groupshift; + engine->group = group; + + if (group != rs->lockedgroup) { + rs->lockedgroup = group; +// printk(KERN_ALERT"NWRAID: Restriping lockgroup=%d count=%d\n", +// group, rs->lockmapcount[group]); + } + + if (rs->lockmapcount[group] != 0) { + rs->restripe_block--; +// printk(KERN_ALERT"NWRAID5: Waiting for count. Group=%d Count=%d Block="SECTOR_FORMAT"\n", +// group, rs->lockmapcount[group], engine->block); + /* We need to wait for the count to go to 0 */ + rs->restripe_count--; + engine->link = rs->read; + rs->read = engine; + spin_unlock(&rs->rlock); + wake(rs); + return; + } + + spin_unlock(&rs->rlock); + + engine->to.count = rs->stripesize; + element = engine->toindex; + + if (element != rs->stamp.missingelement) { + engine->to.bdev = rs->elements[element].dev->bdev; + engine->to.sector = rs->elements[element].offset + (engine->stripe << shift); + } + else { + engine->flags |= WRITE_MISSING; + } + + /* Calculate the check block to see if it is time to flush. */ + if (engine->stripe == 0) + checkblock = 0; + else + { + if (element >= count) + element = 0; + else + { + /* adjust using the parity */ + if (element > engine->parity) + { + element = (element - engine->parity) - 1; + } + } + checkblock = (engine->stripe * (count-1)) + element; + } + + if ((checkblock >= rs->stamp.flushed_block) + || ((rs->stamp.flushed_block - checkblock) > 4096)) + { +// printk(KERN_ALERT"NWRAID: Flush block="SECTOR_FORMAT" check="SECTOR_FORMAT"\n", +// engine->block, checkblock); + if (rs->completed_block > rs->stamp.flushed_block) + rs->stamp.flushed_block = rs->completed_block-1; + flush_log(rs); + } + + /* Calculate the read sector and element. */ + element = engine->fromindex; + + /* Check if we are missing an element within the old count */ + if (rs->stamp.missingelement < count) { + /* Find the parity. */ + block = stripe; + i = (count-1) - sector_div(block, count); + /* If parity is missing, then we don't care */ +// printk(KERN_ALERT"NWRAID5: Parity Check block="SECTOR_FORMAT" parity=%d element=%d\n", +// engine->block, i, element); + if (rs->stamp.missingelement != i) { + /* If element is missing, read the parity instead */ + if (element == rs->stamp.missingelement) { + element = i; + engine->flags |= READ_PARITY; + } + engine->flags |= READ_MAP; + } + } + + from.bdev = rs->elements[element].dev->bdev; + from.sector = rs->elements[element].offset + (stripe << shift); + from.count = rs->stripesize; + + if (dm_io_async(1, &from, READ, engine->list, 0, + restripe_read_callback, engine) != 0) { + +// printk(KERN_ALERT"NWRAID5: error in raid5_restripe. flag=%d\n", +// (rs->flags & RESTRIPE_ABORT)); + if (SetError(rs, element) == 0) { + reset_restripe_count(rs, engine); + } + else { + spin_lock(&rs->rlock); + rs->restripe_count--; + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + engine->link = rs->read; + rs->read = engine; + spin_unlock(&rs->rlock); + return; + } + } + } +} + +/*----------------------------------------------------------------- + * Resync. + *---------------------------------------------------------------*/ +static void clear_resync_state(struct raid_set *rs) +{ + rs->restripestate = DONE; + rs->flags |= (INSYNC_FLAG | FLUSH_FLAG); +// rs->stamp.oldelementcount = rs->stamp.elementcount; + rs->stamp.missingelement = -1; + rs->stamp.resyncparityflag = 0; + + rs->ti->len = + rs->stamp.capacity = + rs->stamp.elementsize * (rs->stamp.oldelementcount - 1); + + memset(rs->bitmap, 0xFF, 512); + + if (rs->stamp.oldelementcount == rs->stamp.elementcount) { + rs->restripe_block = + rs->stamp.lastblock = + rs->stamp.flushed_block = + rs->completed_block = + rs->stamp.capacity >> rs->stamp.raidstripeshift; + } +} + +static int do_end_of_group(struct engine *engine) +{ + struct raid_set *rs = engine->rs; + int done=0; + + set_bit(engine->group, rs->bitmap); + rs->flags |= FLUSH_FLAG; +// printk(KERN_ALERT"NWRAID: Finished group %d stripe="SECTOR_FORMAT" last="SECTOR_FORMAT"\n", +// engine->group, engine->stripe, rs->laststripe); + + if (engine->stripe >= rs->laststripe) { + done = 1; + } + else if (rs->restripestate == DONE_SENDING) { +// printk(KERN_ALERT"NWRAID: Finished group %d and done sending \n", engine->group); + if (CountBits(rs->bitmap, rs->stamp.bitmapsize) == rs->stamp.bitmapsize) { + done = 1; + } + } + + if (done) { + clear_resync_state(rs); + } + return(done); +} + +static void resync_parity_complete(struct raid_set *rs) +{ + struct engine *list, *engine; + unsigned long i; + int done = 0; + struct GroupMap *groupmap; + + spin_lock_irqsave(&rs->irqlock, i); + if ((list = rs->parity) == NULL) { + spin_unlock_irqrestore(&rs->irqlock, i); + return; + } + rs->parity = NULL; + spin_unlock_irqrestore(&rs->irqlock, i); + + spin_lock(&rs->rlock); + + while (list) { + engine = list; + list = list->link; + engine->link = rs->read; + rs->read = engine; + rs->restripe_count--; + + if (rs->flags & RESTRIPE_ABORT) { + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + continue; + } + +// printk(KERN_ALERT"NWRAID5: Parity complete block "SECTOR_FORMAT" stripe "SECTOR_FORMAT" group %d\n", +// engine->block, engine->stripe, engine->group); + + if ((rs->groupstripes == 0) || (engine->stripe >= rs->laststripe)) { + done = do_end_of_group(engine); + } + else { + groupmap = rs->groupmap; + for (i=rs->stamp.elementcount; i>0; i--, groupmap++) + { + if (groupmap->group == engine->group) + { + groupmap->count--; +// printk(KERN_ALERT"NWRAID5: Found groupmap group %d count %d index %d\n", +// groupmap->group, groupmap->count, i); + if (groupmap->count == 0) + { + /* We are finished with this group. */ + groupmap->group = -1; + done = do_end_of_group(engine); + } + + break; + } + } + + if (i == 0) + { + /* Find a free space in the group map. */ + groupmap = rs->groupmap; + for (i=rs->stamp.elementcount; i>0; i--, groupmap++) + { + if (groupmap->group == -1) + { +// printk(KERN_ALERT"NWRAID5: Found empty groupmap group %d index %d\n", engine->group, i); + groupmap->group = engine->group; + groupmap->count = rs->groupstripes; + break; + } + } + } + } + } + + spin_unlock(&rs->rlock); + + if (done) { + printk(KERN_ALERT"NWRAID: Resync Complete\n"); + dm_table_event(rs->ti->table); + } + + wake(rs); +} + +static void resync_parity_callback(unsigned long error, void *context) +{ + struct engine *engine = (struct engine*) context; + struct raid_set *rs = engine->rs; + unsigned long flags; + + if (error) { + rs->flags |= RESTRIPE_ABORT; + } + + spin_lock_irqsave(&rs->irqlock, flags); + engine->link = rs->parity; + rs->parity = engine; + spin_unlock_irqrestore(&rs->irqlock, flags); + + wake(rs); +} + +static void resync_parity(struct raid_set *rs) +{ + struct engine *list, *engine; + int i; + unsigned long flags; + struct RestripeMap *map; + + while (1) { + spin_lock_irqsave(&rs->irqlock, flags); + if ((list = rs->completehead) == NULL) { + spin_unlock_irqrestore(&rs->irqlock, flags); + return; + } + rs->completehead = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + spin_lock(&rs->rlock); + + while (list) { + engine = list; + list = list->link; + if (rs->flags & RESTRIPE_ABORT) { + rs->restripe_count--; + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + engine->link = rs->read; + rs->read = engine; + continue; + } + + map = rs->map; +// printk(KERN_ALERT"NWRAID5: Callback called for block "SECTOR_FORMAT" stripe "SECTOR_FORMAT" group %d\n", +// engine->block, engine->stripe, engine->group); + for (i=rs->stamp.elementcount; i>0; i--, map++) + { + if (map->stripe == engine->stripe) + { + do_engine_parity(engine, map->engine); + + rs->restripe_count--; + engine->link = rs->read; + rs->read = engine; + +// printk(KERN_ALERT"NWRAID5: found map stripe = "SECTOR_FORMAT" count = %d.\n", +// map->stripe, map->count); + if (++map->count == rs->stamp.elementcount) + { + map->stripe = -1; + engine = map->engine; + + engine->to.bdev = rs->elements[rs->stamp.missingelement].dev->bdev; + engine->to.sector = rs->elements[rs->stamp.missingelement].offset + + (map->engine->stripe << rs->stamp.raidstripeshift); + + if (dm_io_async(1, &engine->to, WRITE, engine->list, 0, + resync_parity_callback, engine) != 0) { + + rs->flags |= RESTRIPE_ABORT; + rs->restripe_count--; + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + engine->link = rs->read; + rs->read = engine; + } + } + break; + } + } + + if (i == 0) + { + /* Find a free space to put the engine. */ + map = rs->map; + for (i=rs->stamp.elementcount; i>0; i--, map++) + { + if (map->stripe == -1) + { + map->engine = engine; + map->stripe = engine->stripe; + map->count = 2; + + break; + } + } + if (i == 0) { + /* If we get here, we didn't find the stripe, nor a free space */ + printk(KERN_ALERT"NWRAID5: Critical error - could not find empty resync map\n"); + rs->flags |= RESTRIPE_ABORT; + rs->restripe_count--; + if (rs->restripe_count == 0) { + rs->restripestate = DONE; + } + engine->link = rs->read; + rs->read = engine; + } + } + } + spin_unlock(&rs->rlock); + } +} + +static void resync_read_callback(unsigned long error, void *context) +{ + struct engine *engine = (struct engine*) context; + struct raid_set *rs = engine->rs; + unsigned long flags; + + if (error) { + rs->flags |= RESTRIPE_ABORT; + } + +// printk(KERN_ALERT"NWRAID5: Resync read callback block = "SECTOR_FORMAT"\n", engine->block); + spin_lock_irqsave(&rs->irqlock, flags); + if (rs->completehead == NULL) { + rs->completehead = rs->completetail = engine; + } + else { + rs->completetail->link = engine; + rs->completetail = engine; + } + engine->link = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + wake(rs); +} + +static void raid5_resync(struct raid_set *rs) +{ + sector_t block, stripe; + unsigned long count, element, shift, group; + struct engine *engine; + + while (1) { + + if (rs->flags & RESTRIPE_ABORT) + return; + +// printk(KERN_ALERT"NWRAID: Do Restripe\n"); + + spin_lock(&rs->rlock); + if ((engine = rs->read) == NULL) { + spin_unlock(&rs->rlock); + return; + } + rs->read = engine->link; + + /* Find the next region */ + shift = rs->stamp.raidstripeshift; + count = rs->stamp.elementcount; + while (1) { + block = rs->restripe_block++; +// printk(KERN_ALERT"NWRAID5: Resyncing block="SECTOR_FORMAT" last="SECTOR_FORMAT"\n", +// block, rs->lastblock); + if (block > rs->lastblock) + { + /* We are done! */ + rs->restripe_block--; + rs->restripestate = DONE_SENDING; +// printk(KERN_ALERT"NWRAID5: Done sending, count=%d\n", rs->restripe_block); + if (rs->restripe_count == 0) { + clear_resync_state(rs); + } + spin_unlock(&rs->rlock); + return; + } + stripe = block; + element = sector_div(stripe, count); + if (element == rs->stamp.missingelement) { + continue; + } + + group = stripe >> rs->stamp.groupshift; + + if (group != rs->lockedgroup) { + /* Find the next group that needs to be resynced. */ + group = find_next_zero_bit(rs->bitmap, + rs->stamp.bitmapsize, + group); + if (group >= rs->stamp.bitmapsize) { + /* We are done! */ + rs->restripe_block = rs->lastblock; + rs->restripestate = DONE_SENDING; + printk(KERN_ALERT"NWRAID5: Done sending, count=%d\n", rs->restripe_block); + if (rs->restripe_count == 0) { + clear_resync_state(rs); + } + spin_unlock(&rs->rlock); + return; + } + + stripe = group << rs->stamp.groupshift; + block = rs->restripe_block = stripe * count; + rs->restripe_block++; + + rs->lockedgroup = group; +// printk(KERN_ALERT"NWRAID5: Resyncing lockgroup=%d\n", group); + + if (rs->lockmapcount[group] != 0) { + /* We need to wait for the count to go to 0 */ + rs->restripe_block--; + engine->link = rs->read; + rs->read = engine; + spin_unlock(&rs->rlock); + return; + } + + stripe = block; + element = sector_div(stripe, count); + if (element == rs->stamp.missingelement) { + continue; + } + + break; + } + else { + break; + } + } + + engine->stripe = stripe; + engine->block = block; + engine->group = group; + rs->restripe_count++; + + spin_unlock(&rs->rlock); + + engine->to.bdev = rs->elements[element].dev->bdev; + engine->to.sector = rs->elements[element].offset + (stripe << shift); + engine->to.count = rs->stripesize; + + + if (dm_io_async(1, &engine->to, READ, engine->list, 0, + resync_read_callback, engine) != 0) { + spin_lock(&rs->rlock); + rs->restripe_count--; + engine->link = rs->read; + rs->read = engine; + spin_unlock(&rs->rlock); + stop_restripe(rs); + return; + } + } +} + +/*----------------------------------------------------------------- + * Cache functions + *---------------------------------------------------------------*/ + +/* NOTE: validate_cache MUST be called with the cachelock locked */ +static int validate_cache( + struct RaidCacheDef *cache, + iocontext *context) +{ + struct raid_set *rs = cache->rs; + uint32_t i, elementcount = context->elementcount; + struct page *page; + + if (cache->elementcount != elementcount) + { + cache->validmap = 0; + + spin_unlock(&rs->cachelock); + /* Allocate buffers for the new elements. */ + for (i=0; ibuffers[i].page == NULL) + { + if ((page = alloc_page(GFP_KERNEL)) == NULL) + { + spin_lock(&rs->cachelock); + return(-EAGAIN); + } + cache->buffers[i].page = page; + SetPageLocked(page); + } + } + + spin_lock(&rs->cachelock); + cache->elementcount = elementcount; + cache->parity = context->parity; + } + return(0); +} + +static int FindNewCache( + struct raid_set *rs, + iocontext *context, + struct RaidCacheDef **rtncache) +{ + struct RaidCacheDef *cache, *head, *cachelink; + int count = 0; + + head = (struct RaidCacheDef*) &rs->useNext; + cache = rs->useNext; + +// printk(KERN_ALERT"NWRAID5: FindNewCache \n"); + do + { + if ((cache->flags & + (CACHE_INUSE | CACHE_ALLOCATED)) + == CACHE_ALLOCATED) + { + /* Found one so use it. */ + break; + } + + if (count++ > rs->cachecount) { +// printk(KERN_ALERT"NWRAID5: Exceeded cache count \n"); + return(-EAGAIN); + } + + if ((cache = cache->useNext) == head) + { +// printk(KERN_ALERT"NWRAID5: Could not find new cache \n"); + return(-EAGAIN); + } + + }while (1); + + cachelink = *rtncache; + + /* Link in the order */ + if (cachelink != cache) + { + cache->orderNext->orderPrev = cache->orderPrev; + cache->orderPrev->orderNext = cache->orderNext; + + cache->orderNext = cachelink->orderNext; + cache->orderPrev = cachelink; + cachelink->orderNext->orderPrev = cache; + cachelink->orderNext = cache; + } + + /* Link use onto the end of the list. */ + if (rs->usePrev != cache) + { + cache->useNext->usePrev = cache->usePrev; + cache->usePrev->useNext = cache->useNext; + + cache->usePrev = head->usePrev; + cache->useNext = head; + head->usePrev->useNext = cache; + head->usePrev = cache; + } + + /* Set flag so we know we have to reread the data. */ + spin_lock(&cache->localcachelock); + cache->validmap = 0; + cache->writemap = 0; + cache->err_mask = 0; + cache->readlist = NULL; + cache->writelist = NULL; + cache->paritylist = NULL; + + cache->sectoroffset = context->offset; + cache->parity = context->parity; + cache->flags = CACHE_ALLOCATED; + + if (context->status & PARITY_MISSING) { + cache->flags |= CACHE_PARITY_MISSING; + } + spin_unlock(&cache->localcachelock); + + context->cache = cache; + *rtncache = cache; + +// printk(KERN_ALERT"NWRAID5: New Cache Found\n"); + return(0); +} + +/* FindCache will look for a cache with the matching cacheoffset. +** Return codes are as follows: +** 0 = found (or allocated) an existing cache with matching offset. +** NOMEM = No matching cache found. +*/ + +static int FindCache( + struct raid_set *rs, + iocontext *context, + struct RaidCacheDef **rtncache) +{ + struct RaidCacheDef *cache, *head; + sector_t cacheoffset = context->offset; + +// printk(KERN_ALERT"NWRAID5: FindCache Offset="SECTOR_FORMAT"\n", cacheoffset); + head = (struct RaidCacheDef*) &rs->useNext; + + /* See if we are on the same cache as before */ + if (((cache = rs->lastfind) != NULL) + && (cacheoffset == cache->sectoroffset)) + { + /* Link use onto the end of the list. */ + if (rs->usePrev != cache) + { + cache->useNext->usePrev = cache->usePrev; + cache->usePrev->useNext = cache->useNext; + + cache->usePrev = head->usePrev; + cache->useNext = head; + head->usePrev->useNext = cache; + head->usePrev = cache; + } + + spin_lock(&cache->localcachelock); + if (context->status & PARITY_MISSING) { + cache->flags |= CACHE_PARITY_MISSING; + } + else { + cache->flags &= ~CACHE_PARITY_MISSING; + } + spin_unlock(&cache->localcachelock); + + context->cache = cache; + *rtncache = cache; + return(0); + } + + /* First check if the stripe is lower than lowest on the order list. */ + if (cacheoffset < rs->orderNext->sectoroffset) + { + *rtncache = head; + return(ENOMEM); + } + + /* Check if the stripe is higher than highest on the order list. */ + if (cacheoffset > rs->orderPrev->sectoroffset) + { + *rtncache = head->orderPrev; + return(ENOMEM); + } + + /* Start from the last search and go from there. */ + if (cache == NULL) + cache = rs->orderNext; + + /* Search high */ + do + { + if (cache->sectoroffset > cacheoffset) + { + cache = cache->orderPrev; + break; + } + + if (cache->sectoroffset == cacheoffset) + { + rs->lastfind = cache; + + /* Link use onto the end of the list. */ + if (rs->usePrev != cache) + { + cache->useNext->usePrev = cache->usePrev; + cache->usePrev->useNext = cache->useNext; + + cache->usePrev = head->usePrev; + cache->useNext = head; + head->usePrev->useNext = cache; + head->usePrev = cache; + } + + spin_lock(&cache->localcachelock); + if (context->status & PARITY_MISSING) { + cache->flags |= CACHE_PARITY_MISSING; + } + else { + cache->flags &= ~CACHE_PARITY_MISSING; + } + spin_unlock(&cache->localcachelock); + + context->cache = cache; + *rtncache = cache; + return(0); + } + + cache = cache->orderNext; + + }while (cache != head); + + /* Search low */ + do + { + if (cache->sectoroffset < cacheoffset) + { + break; + } + + if (cache->sectoroffset == cacheoffset) + { + rs->lastfind = cache; + + /* Link use onto the end of the list. */ + if (rs->usePrev != cache) + { + cache->useNext->usePrev = cache->usePrev; + cache->usePrev->useNext = cache->useNext; + + cache->usePrev = head->usePrev; + cache->useNext = head; + head->usePrev->useNext = cache; + head->usePrev = cache; + } + + spin_lock(&cache->localcachelock); + if (context->status & PARITY_MISSING) { + cache->flags |= CACHE_PARITY_MISSING; + } + else { + cache->flags &= ~CACHE_PARITY_MISSING; + } + spin_unlock(&cache->localcachelock); + + context->cache = cache; + *rtncache = cache; + return(0); + } + + cache = cache->orderPrev; + + }while (cache != head); + + *rtncache = cache; + return(ENOMEM); +} + +static void process_cache_writes(struct raid_set *rs) +{ + struct RaidCacheDef *cache; + iocontext *list, *context; + unsigned long flags, error; + + spin_lock_irqsave(&rs->irqlock, flags); + list = rs->cachewrite; + rs->cachewrite = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + while (list) { + context = list; + list = list->link; + error = 0; + + if (context->status & WRITE_ERR_DATA) { + if (SetError(rs, context->element) != 0) { + error = -EIO; + } + clear_bitmap(context); + } + + if (context->status & WRITE_ERR_PARITY) { + if (rs->stamp.missingelement == context->element) { + error = -EIO; + } + clear_bitmap(context); + } + +// printk(KERN_ALERT"NWRAID5: CacheWriteCallback Offset="SECTOR_FORMAT" Err=%d\n", +// context->offset, error); + + cache = context->cache; + +// printk(KERN_ALERT"NWRAID5: Calling complete_request from process_cache_writes err %d\n", error); + complete_request(context, error); + + if (atomic_dec_and_test(&cache->writecount)) { + spin_lock(&rs->cachelock); + spin_lock(&cache->localcachelock); +// printk(KERN_ALERT"NWRAID5: cache "SECTOR_FORMAT" count = 0\n",cache->sectoroffset); + + if (cache->writelist == NULL) { + cache->flags &= ~(CACHE_INUSE | CACHE_WRITE); +// printk(KERN_ALERT"NWRAID5: cache write cleared offset="SECTOR_FORMAT" \n", cache->sectoroffset); + } + else { + if (!(cache->flags & CACHE_LINKED)) { + if (rs->process_head == NULL) { + rs->process_head = cache; + } + else { + rs->process_tail->link = cache; + } + rs->process_tail = cache; + cache->link = NULL; + cache->flags |= CACHE_LINKED; + } +// printk(KERN_ALERT"NWRAID5: cache write cleared offset="SECTOR_FORMAT" \n", cache->sectoroffset); + cache->flags &= ~CACHE_WRITE; + } + spin_unlock(&cache->localcachelock); + spin_unlock(&rs->cachelock); + } +// else { +// printk(KERN_ALERT"NWRAID5: cache "SECTOR_FORMAT" count = %d\n", +// cache->sectoroffset, atomic_read(&cache->writecount)); +// } + } +} + +static void DataWriteCallback(unsigned long error, void *rtncontext) +{ + iocontext *context = (iocontext*) rtncontext; + struct raid_set *rs = context->rs; + unsigned long flags; + + if (error) { +// printk(KERN_ALERT"NWRAID5: DataWriteCallback Offset="SECTOR_FORMAT" error %d, status %x\n", +// context->offset, error, context->status); + spin_lock_irqsave(&rs->irqlock, flags); + if (context->err == 0) { + context->err = -EIO; + } + context->status |= WRITE_ERR_DATA; + spin_unlock_irqrestore(&rs->irqlock, flags); + } + +// printk(KERN_ALERT"NWRAID5: DataWriteCallback Offset="SECTOR_FORMAT" error %d, status %x\n", +// context->offset, error, context->status); + if (atomic_dec_and_test(&context->count)) { + spin_lock_irqsave(&rs->irqlock, flags); + context->link = rs->cachewrite; + rs->cachewrite = context; + spin_unlock_irqrestore(&rs->irqlock, flags); + wake(rs); + } +} + +static void process_parity_writes(struct raid_set *rs) +{ + struct RaidCacheDef *cache, *list; + unsigned long flags; + + spin_lock_irqsave(&rs->irqlock, flags); + list = rs->parity_write; + rs->parity_write = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + while (list) { + cache = list; + list = list->link; + + spin_lock(&rs->cachelock); + spin_lock(&cache->localcachelock); +// printk(KERN_ALERT"NWRAID5: process parity called offset="SECTOR_FORMAT" \n", cache->sectoroffset); + if (cache->writelist == NULL) { + cache->flags &= ~(CACHE_INUSE | CACHE_WRITE); +// printk(KERN_ALERT"NWRAID5: cache write cleared offset="SECTOR_FORMAT" \n", cache->sectoroffset); + } + else { + if (!(cache->flags & CACHE_LINKED)) { + if (rs->process_head == NULL) { + rs->process_head = cache; + } + else { + rs->process_tail->link = cache; + } + rs->process_tail = cache; + cache->link = NULL; + cache->flags |= CACHE_LINKED; + } +// printk(KERN_ALERT"NWRAID5: cache write cleared offset="SECTOR_FORMAT" \n", cache->sectoroffset); + cache->flags &= ~CACHE_WRITE; + } + spin_unlock(&cache->localcachelock); + spin_unlock(&rs->cachelock); + } +} + +static void ParityWriteCallback(unsigned long error, void *rtncontext) +{ + struct RaidCacheDef *cache = (struct RaidCacheDef*) rtncontext; + iocontext *paritylist, *context; + struct raid_set *rs = cache->rs; + unsigned long flags; + int dowake = 0; + +// if (error) +// { +// printk(KERN_ALERT"NWRAID5: Got to ParityWriteCallback error=%d list=%p\n", error, cache->paritylist); +// } + + spin_lock_irqsave(&rs->irqlock, flags); + + paritylist = cache->paritylist; + cache->paritylist = NULL; + + while(paritylist) { + context = paritylist; + paritylist = context->link; + + if (error) { + if (context->err == 0) { + context->err = -EIO; + } + context->status |= WRITE_ERR_PARITY; + } + +// printk(KERN_ALERT"NWRAID5: ParityWriteCallback Offset="SECTOR_FORMAT" status %x\n", context->offset, context->status); + if (atomic_dec_and_test(&context->count)) { + context->link = rs->cachewrite; + rs->cachewrite = context; + dowake = 1; + } + } + + if (atomic_dec_and_test(&cache->writecount)) { + cache->link = rs->parity_write; + rs->parity_write = cache; +// printk(KERN_ALERT"NWRAID5: parity cache "SECTOR_FORMAT" count = 0\n",cache->sectoroffset); + dowake = 1; + } +// else { +// printk(KERN_ALERT"NWRAID5: parity cache "SECTOR_FORMAT" count = %d\n", +// cache->sectoroffset, atomic_read(&cache->writecount)); +// } + + spin_unlock_irqrestore(&rs->irqlock, flags); + + if (dowake) { + wake(rs); + } +} + +static void CacheReadCallback(unsigned long error, void *context) +{ + struct RaidCachePtr *cacheptr = (struct RaidCachePtr *) context; + struct RaidCacheDef *cache = cacheptr->cache; + struct raid_set *rs = cache->rs; + unsigned long flags; + int dowake=0; + +// printk(KERN_ALERT"NWRAID5: CacheReadCallback Offset="SECTOR_FORMAT" Err=%d\n", +// cache->sectoroffset, error); + + spin_lock_irqsave(&rs->irqlock, flags); + + if (error) { +// printk(KERN_ALERT"NWRAID5: Error in CacheReadCallback Err=%d Index=%d\n", +// error, cacheptr->index); + set_bit(cacheptr->index, &cache->err_mask); + } + else { + set_bit(cacheptr->index, &cache->validmap); + } + + if (atomic_dec_and_test(&cache->readcount)) { + if (rs->readcomplete_head == NULL) { + rs->readcomplete_head = cache; + } + else { + rs->readcomplete_tail->link = cache; + } + rs->readcomplete_tail = cache; + cache->link = NULL; + dowake = 1; + } + + spin_unlock_irqrestore(&rs->irqlock, flags); + + if (dowake) { + wake(rs); + } +} + +static int write_element(iocontext *context, unsigned long *queueit) +{ + struct raid_set *rs = context->rs; + struct RaidCacheDef *cache = context->cache; + char *bptr, *pptr; + int r, ccode; + unsigned int count; + uint32_t element = context->element; + struct bio_vec *vec; + struct io_region io; + + bptr = page_address(cache->buffers[element].page); + bptr += (context->sector * 512); + *queueit = 0; + +// printk(KERN_ALERT"NWRAID5: write_element offset="SECTOR_FORMAT" status = %x\n", +// context->offset, context->status); + + count = context->bio->bi_size; + vec = &context->bio->bi_io_vec[context->bio->bi_idx]; + while (count) { + if (count > vec->bv_len) { + pptr = kmap_atomic(vec->bv_page, KM_USER0); + memcpy(bptr, pptr + vec->bv_offset, vec->bv_len); + kunmap_atomic(pptr, KM_USER0); + count -= vec->bv_len; + bptr += vec->bv_len; + vec++; + } + else { + pptr = kmap_atomic(vec->bv_page, KM_USER0); + memcpy(bptr, pptr + vec->bv_offset, count); + kunmap_atomic(pptr, KM_USER0); + break; + } + } + + spin_lock(&cache->localcachelock); + set_bit(element, &cache->validmap); + clear_bit(context->parity, &cache->validmap); + spin_unlock(&cache->localcachelock); + + atomic_inc(&cache->writecount); + + /* If the parity is missing, don't bother with the parity list */ + if (context->status & PARITY_MISSING) { + clear_bitmap(context); + atomic_set(&context->count, 1); + } + else { + /* Link it into the parity list to wait for parity calculation*/ + *queueit = 1; + atomic_set(&context->count, 2); + } + + /* If the element is missing, don't send anything */ + if (context->status & DATA_MISSING) { + clear_bitmap(context); + atomic_set(&context->count, 1); + return(0); + } + + /* Now send the write command */ + io.bdev = rs->elements[element].dev->bdev; + io.sector = rs->elements[element].offset + cache->sectoroffset + context->sector; + io.count = context->bio->bi_size >> 9; + r = dm_io_async(1, &io, context->bio->bi_rw, &cache->buffers[element], context->sector * 512, + DataWriteCallback, context); + if (r) + { + ccode = SetError(rs, element); + clear_bitmap(context); +// printk(KERN_ALERT"NWRAID5: Error %d in write_element offset "SECTOR_FORMAT" seterror=%d\n", +// r, context->offset, ccode); + + if (!ccode) { + /* Keep on the parity list and wait for the parity to be written */ + atomic_dec(&context->count); + } + else { + /* Don't queue it on the parity list */ + *queueit = 0; + atomic_dec(&cache->writecount); +// printk(KERN_ALERT"NWRAID5: Calling complete_request from write_element err=%d\n", r); + complete_request(context, -EIO); + } + } + + return(0); +} + +static void write_parity(struct RaidCacheDef *cache) +{ + int r, i, parity; + struct raid_set *rs = cache->rs; + struct io_region io; + + +// printk(KERN_ALERT"NWRAID5: Writing parity flags=%x\n", cache->flags); + + if (cache->flags & CACHE_PARITY_MISSING) { + /* No use writing parity if missing */ + + ParityWriteCallback(-EIO, cache); + return; + } + + r = 0; + parity = cache->parity; + for (i=0; ielementcount; i++) + { + if (i != parity) + { + if (r == 0) + { + memcpy(page_address(cache->buffers[parity].page), + page_address(cache->buffers[i].page), + CACHE_SIZE); + r = 1; + } + else + { + CalculateParity( (unsigned long*) page_address(cache->buffers[parity].page), + (unsigned long*) page_address(cache->buffers[i].page), + CACHE_SIZE); + } + } + } + + spin_lock(&cache->localcachelock); + set_bit(parity, &cache->validmap); + spin_unlock(&cache->localcachelock); + + io.bdev = rs->elements[parity].dev->bdev; + io.sector = rs->elements[parity].offset + cache->sectoroffset; + io.count = CACHE_SECTORS; + r = dm_io_async(1, &io, WRITE, &cache->buffers[parity], 0, + ParityWriteCallback, cache); + if (r) + { + i = SetError(rs, parity); +// printk(KERN_ALERT"NWRAID5: Error %d in WriteData offset "SECTOR_FORMAT"\n", +// r, cache->sectoroffset); + + ParityWriteCallback(r, cache); + } +} + +/* NOTE: This routine MUST be called with the localcachelock locked, +** and will return with it unlocked. */ +static int read_in_cache(struct RaidCacheDef *cache) +{ + unsigned long i, element; + unsigned long validmap, map = 0; + int r; + struct raid_set *rs = cache->rs; + struct io_region io; + + if (cache->flags & CACHE_READ) { + validmap = cache->validmap; + } + else { + validmap = cache->validmap | cache->writemap; + } + + if (rs->stamp.missingelement != -1) { + element = rs->stamp.missingelement; + /* If element is not the parity, we need all the elements to regenerate the data */ + if (element != cache->parity) { + validmap = 0; + } + } + else { + element = cache->parity; + } + + atomic_set(&cache->readcount, 0); + cache->err_mask = 0; + + /* First find the elements to read in */ + for (i=0; ielementcount; i++) { + if ((i != element) && + (!(test_bit(i, &validmap))) && + (test_bit(i, &rs->loadedmap))) { + + atomic_inc(&cache->readcount); + set_bit(i, &map); + } + } + +// printk(KERN_ALERT"NWRAID5: read_in_cache element = %d validmap = %x map = %x\n",element, validmap, map); + + if (map == 0) { + /* We already have all the elements we need */ + element = rs->stamp.missingelement; + if ((element != -1) && + (element != cache->parity) && + (!(test_bit(element, &validmap)))) { + + /* Calculate the element from the parity */ + r = 0; + for (i=0; ielementcount; i++) + { + if (i != element) + { + if (r == 0) + { + memcpy(page_address(cache->buffers[element].page), + page_address(cache->buffers[i].page), + CACHE_SIZE); + r = 1; + } + else + { + CalculateParity((unsigned long*) page_address(cache->buffers[element].page), + (unsigned long*) page_address(cache->buffers[i].page), + CACHE_SIZE); + } + } + } + set_bit(element, &cache->validmap); + } + cache->flags &= ~CACHE_READ; + return(1); + } + + cache->flags |= CACHE_READ; + spin_unlock(&cache->localcachelock); + + /* Now send down the IOs */ + for (i=0; ielementcount; i++) { + if (test_bit(i, &map)) { + io.bdev = rs->elements[i].dev->bdev; + io.sector = rs->elements[i].offset + cache->sectoroffset; + io.count = CACHE_SECTORS; +// printk(KERN_ALERT"NWRAID5: ReadInElement=%d Buffer=%x\n",i, page_address(cache->buffers[i].page)); + + r = dm_io_async(1, &io, READ, &cache->buffers[i], 0, + CacheReadCallback, &cache->index[i]); + if (r) + { +// printk(KERN_ALERT"NWRAID5: ReadInElement FAILED %d\n",r); + CacheReadCallback(r, &cache->index[i]); + } + } + } + + return(0); +} + +static void process_cache_list(struct raid_set *rs) +{ + struct RaidCacheDef *list, *cache; + unsigned long mask; + iocontext *context, *readlist, *retrylist, + *writelist, *completelist, + *parityhead, *paritytail; + char *bptr, *pptr; + unsigned int count, done; + struct bio_vec *vec; + unsigned long flags; + + /* Get the list */ + spin_lock(&rs->cachelock); + list = rs->process_head; + rs->process_head = NULL; + spin_unlock(&rs->cachelock); + + while (list) { + cache = list; + list = list->link; + done=0; + retrylist=NULL; + completelist=NULL; + + spin_lock(&cache->localcachelock); + + cache->flags &= ~CACHE_LINKED; + + /* See if we need to read some elements */ + if (cache->flags & CACHE_READ) { + if (read_in_cache(cache) == 0) { + /* NOTE: Lock unlocked in read_in_cache */ + continue; + } + } + else { + mask = (1 << cache->elementcount) - 1; + clear_bit(cache->parity, &mask); + + if (((cache->validmap | cache->writemap) & mask) != mask) { + if (read_in_cache(cache) == 0) { + /* NOTE: Lock unlocked in read_in_cache */ + continue; + } + } + } + + /* If we get here, time to process the messages */ + if ((cache->writelist != NULL) && (!(cache->flags & CACHE_WRITE))) { + writelist = cache->writelist; + cache->writelist = NULL; + cache->writemap = 0; + cache->flags |= CACHE_WRITE; +// printk(KERN_ALERT"NWRAID5: cache write set offset="SECTOR_FORMAT" \n", cache->sectoroffset); + } + else { + writelist = NULL; + } + + readlist = cache->readlist; + cache->readlist = NULL; + + spin_unlock(&cache->localcachelock); + + while (readlist) { + context = readlist; + readlist = context->link; + if (test_bit(context->element, &cache->validmap)) { +// printk(KERN_ALERT"NWRAID5: process_cache read offset="SECTOR_FORMAT"\n", context->offset); + bptr = page_address(cache->buffers[context->element].page); + bptr += (context->sector * 512); + count = context->bio->bi_size; + vec = &context->bio->bi_io_vec[context->bio->bi_idx]; + while (count) { + if (count > vec->bv_len) { + pptr = kmap_atomic(vec->bv_page, KM_USER0); + memcpy(pptr + vec->bv_offset, bptr, vec->bv_len); + kunmap_atomic(pptr, KM_USER0); + count -= vec->bv_len; + bptr += vec->bv_len; + vec++; + } + else { + pptr = kmap_atomic(vec->bv_page, KM_USER0); + memcpy(pptr + vec->bv_offset, bptr, count); + kunmap_atomic(pptr, KM_USER0); + break; + } + } + context->link = completelist; + completelist = context; + } + else { + context->link = retrylist; + retrylist = context; + } + } + + /* Process the writes */ + if (writelist) { +// printk(KERN_ALERT"NWRAID5: writing cache="SECTOR_FORMAT"\n", cache->sectoroffset); + atomic_inc(&cache->writecount); /* This is for the parity */ + parityhead = paritytail = NULL; + while (writelist) { + context = writelist; + writelist = writelist->link; + write_element(context, &flags); + if (flags) { + /* Link onto the paritylist */ + if (parityhead == NULL) { + parityhead = paritytail = context; + } + else { + paritytail->link = context; + paritytail = context; + } + context->link = NULL; + } + } + if (parityhead) { +// printk(KERN_ALERT"NWRAID5: Attaching parity list\n"); + /* Attach the parity list to the cache */ + spin_lock_irqsave(&rs->irqlock, flags); + paritytail->link = cache->paritylist; + cache->paritylist = parityhead; + spin_unlock_irqrestore(&rs->irqlock, flags); + } + write_parity(cache); + } + else { + done=1; + } + + /* Try the reads again because we might have new valid cache from the writes. */ + while (retrylist) { + context = retrylist; + retrylist = context->link; + if (test_bit(context->element, &cache->validmap)) { + bptr = page_address(cache->buffers[context->element].page); + bptr += (context->sector * 512); + count = context->bio->bi_size; + vec = &context->bio->bi_io_vec[context->bio->bi_idx]; + while (count) { + if (count > vec->bv_len) { + pptr = kmap_atomic(vec->bv_page, KM_USER0); + memcpy(pptr + vec->bv_offset, bptr, vec->bv_len); + kunmap_atomic(pptr, KM_USER0); + count -= vec->bv_len; + bptr += vec->bv_len; + vec++; + } + else { + pptr = kmap_atomic(vec->bv_page, KM_USER0); + memcpy(pptr + vec->bv_offset, bptr, count); + kunmap_atomic(pptr, KM_USER0); + break; + } + } + context->link = completelist; + completelist = context; + } + else { + context->link = completelist; + completelist = context; + context->err = -EIO; + } + } + + if (done) { + spin_lock(&cache->localcachelock); + if (cache->writelist == NULL) { + cache->flags &= ~CACHE_INUSE; +// printk(KERN_ALERT"NWRAID5: process list cleared inuse offset="SECTOR_FORMAT" \n", cache->sectoroffset); + } + spin_unlock(&cache->localcachelock); + } + + while (completelist) { + context = completelist; + completelist = completelist->link; +// printk(KERN_ALERT"NWRAID5: process_cache complete %d\n", context->err); + complete_request(context, context->err); + } + } +} + + +static void process_invalid_cache(struct RaidCacheDef *cache) +{ + iocontext *context, *readlist, *writelist, *paritylist; + + /* Complete all the linked requests */ + spin_lock(&cache->localcachelock); + readlist = cache->readlist; + cache->readlist = NULL; + writelist = cache->writelist; + cache->writelist = NULL; + paritylist = cache->paritylist; + cache->paritylist = NULL; + + cache->flags = CACHE_ALLOCATED; + spin_unlock(&cache->localcachelock); + + while (readlist) { + context = readlist; + readlist = context->link; + complete_request(context, -EIO); + } + while (writelist) { + context = writelist; + writelist = context->link; + complete_request(context, -EIO); + } + while (paritylist) { + context = paritylist; + paritylist = context->link; + complete_request(context, -EIO); + } +} + +static void process_cache_reads(struct raid_set *rs) +{ + struct RaidCacheDef *list, *cache; + struct io_region io; + uint32_t missingelement; + unsigned long i,count, copied, error; + int r; + + spin_lock_irqsave(&rs->irqlock, i); + list = rs->readcomplete_head; + rs->readcomplete_head = NULL; + spin_unlock_irqrestore(&rs->irqlock, i); + + + while (list) { + cache = list; + list = list->link; + atomic_dec(&rs->ioreadcount); +// printk(KERN_ALERT"NWRAID5: End cache read count=%d\n", atomic_read(&rs->ioreadcount)); + + +// printk(KERN_ALERT"NWRAID5: process_cache_reads Offset="SECTOR_FORMAT" err=%x\n", +// cache->sectoroffset, cache->err_mask); + + if (cache->err_mask) { + if (rs->restripestate >= RESTRIPEING) { + rs->flags |= RESTRIPE_ABORT; + rs->restripestate = DONE; + } + + error = 0; + + /* Find the index of this object. */ + count = cache->elementcount; + for (i=0; ierr_mask)) { + error = -EIO; + if (SetError(rs, i) != 0) { + if (i == cache->parity) { + spin_lock(&cache->localcachelock); + cache->flags |= CACHE_PARITY_MISSING; + spin_unlock(&cache->localcachelock); + } + break; + } + } + } + + if (i < count) { + /* We have multiple error, so cache is invalid */ + process_invalid_cache(cache); + continue; + } + else if (error){ + /* Got an error, so go get the parity */ +// printk(KERN_ALERT"NWRAID5: process_cache_reads -get parity\n"); + + atomic_inc(&cache->readcount); + cache->err_mask = 0; + i = cache->parity; + io.bdev = rs->elements[i].dev->bdev; + io.sector = rs->elements[i].offset + cache->sectoroffset; + io.count = CACHE_SECTORS; + r = dm_io_async(1, &io, READ, &cache->buffers[i], 0, + CacheReadCallback, &cache->index[i]); + if (r) { + process_invalid_cache(cache); + atomic_dec(&cache->readcount); + continue; + } + else { + atomic_inc(&rs->ioreadcount); + continue; + } + } + } + + + if ((missingelement = rs->stamp.missingelement) != -1) + { +// printk(KERN_ALERT"NWRAID5: process_cache_reads -recalc parity\n"); + /* Fix up the missing element */ + count = cache->elementcount; + copied = 0; + + for (i=0; ibuffers[missingelement].page), + page_address(cache->buffers[i].page), + CACHE_SIZE); + copied = 1; + } + else + { + CalculateParity((unsigned long*) page_address(cache->buffers[missingelement].page), + (unsigned long*) page_address(cache->buffers[i].page), + CACHE_SIZE); + } + } + } + spin_lock(&cache->localcachelock); + set_bit(missingelement, &cache->validmap); + spin_unlock(&cache->localcachelock); + } + + spin_lock(&rs->cachelock); + spin_lock(&cache->localcachelock); + cache->flags &= ~CACHE_READ; + + /* Put on the list to process the messages */ + if (!(cache->flags & CACHE_LINKED)) { + if (rs->process_head == NULL) { + rs->process_head = cache; + } + else { + rs->process_tail->link = cache; + } + rs->process_tail = cache; + cache->link = NULL; + cache->flags |= CACHE_LINKED; + spin_unlock(&cache->localcachelock); + spin_unlock(&rs->cachelock); + } + else { + spin_unlock(&cache->localcachelock); + spin_unlock(&rs->cachelock); + } + } +} + +static void fast_complete(struct raid_set *rs) +{ + iocontext *list, *context; + + spin_lock(&rs->cachelock); + list = rs->fast_head; + rs->fast_head = NULL; + spin_unlock(&rs->cachelock); + + while (list) { + context = list; + list = list->link; +// printk(KERN_ALERT"NWRAID5: Calling complete_request from fast_complete err=0\n"); + complete_request(context, 0); + } +} + +static void error_retry(struct raid_set *rs) +{ + iocontext *list, *context; + unsigned long flags; + + spin_lock_irqsave(&rs->irqlock, flags); + list = rs->errorlist; + rs->errorlist = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + while (list) { + context = list; + list = list->link; + if (SetError(rs, context->element) == 0) { + /* Just retry this request again */ +// printk(KERN_ALERT"NWRAID5: Retry Context=%p sector="SECTOR_FORMAT" element=%d\n", +// context, (context->bio->bi_sector - rs->ti->begin), context->element); + queue_context(context, bio_rw(context->bio)); + } + else { + complete_request(context, -EIO); + } + } +} + +static void split_retry(struct raid_set *rs) +{ + iocontext *list, *context; + unsigned long flags; + uint32_t i; + + spin_lock_irqsave(&rs->irqlock, flags); + list = rs->splitlist; + rs->splitlist = NULL; + spin_unlock_irqrestore(&rs->irqlock, flags); + + while (list) { + context = list; + list = list->link; + atomic_inc(&rs->iopending); + if (context->element == -1) { + complete_request(context, context->err); + } + else { + for (i=0; istamp.elementcount; i++) { + if (test_bit(i, (unsigned long*) &context->element)) { + if (SetError(rs, context->element) != 0) { + complete_request(context, -EIO); + break; + } + } + } + + if (i == rs->stamp.elementcount) { + /* Just retry this request again */ + queue_context(context, bio_rw(context->bio)); + } + } + } +} + +static int read_from_cache( + struct raid_set *rs, + iocontext *context) +{ + struct RaidCacheDef *cache; + int ccode = -1; + char *bptr, *pptr; + unsigned int count; + struct bio_vec *vec; + + spin_lock(&rs->cachelock); + +// printk(KERN_ALERT"NWRAID5: ReadFromCache Offset="SECTOR_FORMAT" element=%d\n", context->offset, context->element); + if ((!(rs->flags & SHARED_FLAG)) && (FindCache(rs, context, &cache) == 0)) + { +// printk(KERN_ALERT"NWRAID5: Found cache Offset="SECTOR_FORMAT"\n", context->offset); + if ((ccode = validate_cache(cache, context)) != 0) { + spin_unlock(&rs->cachelock); + + if (rs->stamp.missingelement == context->element) + return(ccode); + else + return(1); + } + + if (test_bit(context->element, &cache->validmap)) { + spin_unlock(&rs->cachelock); + /* Copy over the data and complete the message */ + bptr = page_address(cache->buffers[context->element].page); + bptr += (context->sector * 512); + + count = context->bio->bi_size; + vec = &context->bio->bi_io_vec[context->bio->bi_idx]; + while (count) { + if (count > vec->bv_len) { + pptr = kmap_atomic(vec->bv_page, KM_USER0); + memcpy(pptr + vec->bv_offset, bptr, vec->bv_len); + kunmap_atomic(pptr, KM_USER0); + count -= vec->bv_len; + bptr += vec->bv_len; + vec++; + } + else { + pptr = kmap_atomic(vec->bv_page, KM_USER0); + memcpy(pptr + vec->bv_offset, bptr, count); + kunmap_atomic(pptr, KM_USER0); + break; + } + } + + spin_lock(&rs->cachelock); + + /* We read in the data fast from the cache */ + if (rs->fast_head == NULL) { + rs->fast_head = context; + } + else { + rs->fast_tail->link = context; + } + rs->fast_tail = context; + context->link = NULL; + spin_unlock(&rs->cachelock); + wake(rs); + return(0); + } + else { + spin_lock(&cache->localcachelock); + + if (cache->flags & CACHE_READ) { + context->link = cache->readlist; + cache->readlist = context; + spin_unlock(&cache->localcachelock); + spin_unlock(&rs->cachelock); + } + else if (rs->stamp.missingelement == context->element) + { + if (!(cache->flags & CACHE_LINKED)) { + if (rs->process_head == NULL) { + rs->process_head = cache; + } + else { + rs->process_tail->link = cache; + } + rs->process_tail = cache; + cache->link = NULL; + cache->flags |= CACHE_LINKED; + } + + cache->flags |= (CACHE_INUSE | CACHE_READ); + context->link = cache->readlist; + cache->readlist = context; + spin_unlock(&cache->localcachelock); + spin_unlock(&rs->cachelock); + } + else + { + spin_unlock(&cache->localcachelock); + spin_unlock(&rs->cachelock); + ccode = 1; + } + } + } + else + { + if (rs->stamp.missingelement == context->element) + { + /* If clustering, find a cache */ + if (rs->flags & SHARED_FLAG) + { + if ((ccode = FindCache(rs, context, &cache)) != 0) + { + ccode = FindNewCache(rs, context, &cache); + } + } + else + { + ccode = FindNewCache(rs, context, &cache); + } + + if (ccode == 0) { + +// printk(KERN_ALERT"NWRAID5: Found new cache Offset="SECTOR_FORMAT"\n", context->offset); + if ((ccode = validate_cache(cache, context)) != 0) { + spin_unlock(&rs->cachelock); + return(ccode); + } + + spin_lock(&cache->localcachelock); + cache->flags |= (CACHE_INUSE | CACHE_READ | CACHE_LINKED); + + /* Link it onto the process list */ + if (rs->process_head == NULL) { + rs->process_head = cache; + } + else { + rs->process_tail->link = cache; + } + rs->process_tail = cache; + cache->link = NULL; + + context->link = cache->readlist; + cache->readlist = context; + spin_unlock(&cache->localcachelock); + spin_unlock(&rs->cachelock); + + wake(rs); + } + else { + spin_unlock(&rs->cachelock); + } + } + else + { + spin_unlock(&rs->cachelock); +// printk(KERN_ALERT"NWRAID5: Shared read no cache\n"); + ccode = 1; + } + } + + return(ccode); +} + +static int write_to_cache( + struct raid_set *rs, + iocontext *context) +{ + struct RaidCacheDef *cache; + int ccode = 0; + +// printk(KERN_ALERT"NWRAID5: write_to_cache Offset="SECTOR_FORMAT" status=%x\n", context->offset, context->status); + + /* If the parity is missing, forget the cache and just do the IO */ + if (context->status & PARITY_MISSING) { + clear_bitmap(context); + return(1); + } + + spin_lock(&rs->cachelock); + + if (FindCache(rs, context, &cache) == 0) + { +// printk(KERN_ALERT"NWRAID5: Found cache Offset="SECTOR_FORMAT"\n", context->offset); + + /* If the element count is not the same, then the cache is invalid. */ + if ((ccode = validate_cache(cache, context)) != 0) { + spin_unlock(&rs->cachelock); + return(ccode); + } + + } + else { + if ((ccode = FindNewCache(rs, context, &cache)) == 0) { +// printk(KERN_ALERT"NWRAID5: Found new cache Offset="SECTOR_FORMAT"\n", context->offset); + if ((ccode = validate_cache(cache, context)) != 0) { + spin_unlock(&rs->cachelock); + return(ccode); + } + } + } + + if (ccode == 0) { + spin_lock(&cache->localcachelock); + + cache->flags |= CACHE_INUSE; + if (!(cache->flags & (CACHE_LINKED | CACHE_READ | CACHE_WRITE))) { +// if (!(cache->flags & (CACHE_LINKED | CACHE_READ))) { + if (rs->process_head == NULL) { + rs->process_head = cache; + } + else { + rs->process_tail->link = cache; + } + rs->process_tail = cache; + cache->link = NULL; + cache->flags |= CACHE_LINKED; + } + + context->link = cache->writelist; + cache->writelist = context; + + /* Set the write map bit */ + if ((context->sector == 0) && + (context->bio->bi_size == CACHE_SIZE)) { + + set_bit(context->element, &cache->writemap); + } + + spin_unlock(&cache->localcachelock); + spin_unlock(&rs->cachelock); + + wake(rs); + } + else { + spin_unlock(&rs->cachelock); + } + + return(ccode); +} + +/*----------------------------------------------------------------- + * Reads + *---------------------------------------------------------------*/ +static int MultiIOCallback(struct bio *clone, unsigned int done, int err) +{ + struct bio *bio = (struct bio*) clone->bi_private; + iocontext *split = (iocontext*) bio->bi_private; + struct raid_set *rs = split->rs; + int i, complete = 0; + unsigned long flags; + unsigned long group; + + +// printk(KERN_ALERT"NWRAID5: Split callback = %x, bio=%x, err=%d\n",clone, bio, err); + spin_lock_irqsave(&rs->irqlock, flags); + if (err) { + if (err == -EAGAIN) { + if (split->err == 0) + split->err = err; + } + else if ((split->err == 0) || (split->err == -EAGAIN)) { + split->err = err; + /* Get the index of this request. */ + for (i=0; istamp.elementcount; i++) { + if ((test_bit(i, &rs->loadedmap)) && + (clone->bi_bdev == rs->elements[i].dev->bdev) && + (clone->bi_sector >= rs->elements[i].offset) && + (clone->bi_sector < (rs->elements[i].offset + rs->stamp.elementsize))) { + + /* Found the element. */ + set_bit(i, (unsigned long*) &split->element); + break; + } + } + if (i == rs->stamp.elementcount) { + split->element = -1; /* Set all the bits since we couldn't find which one */ + } + } + } + + if (atomic_dec_and_test(&split->count)) { + complete = 1; + err = split->err; + + if (split->group & LOCKEDMASK) { + group = split->group & ~LOCKEDMASK; + if (rs->lockmapcount[group] > 0) + rs->lockmapcount[group]--; + } + + split->group = 0; + + if ((err != 0) && (err != -EAGAIN)) { + atomic_dec(&rs->iopending); + split->link = rs->splitlist; + rs->splitlist = split; + complete = 2; + } + else { + split->link = rs->returnlist; + rs->returnlist = split; + } + } + + spin_unlock_irqrestore(&rs->irqlock, flags); + + if (complete == 1) { + bio->bi_private = split->cache; +// printk(KERN_ALERT"NWRAID: Split bio %x complete.\n", bio); + if (err == -EAGAIN) { + atomic_dec(&rs->iopending); + queue_bio(rs, bio, bio_rw(bio)); + } + else { + bio_endio(bio, bio->bi_size, err); + } + } + else if (complete == 2) { + wake(rs); + } + + bio_put(clone); + + return(0); +} + +static int raid5_io(struct raid_set *rs, + struct bio *bio, + iocontext *context) +{ + int r, rw = bio_rw(bio); + sector_t sector, block, stripe; + sector_t stripemask, cacheoffset; + unsigned long disks, disks0, shift, group, locked=0; + unsigned long size, dataelement, parelement, offset; + struct bio *clone; + unsigned int bv_len, bv_offset, bio_size; + unsigned short idx; + iocontext *list, *clonecontext; + + if (rs->flags & DEACTIVE_FLAG) { +// printk(KERN_ALERT"NWRAID5: IO Error, RAID is deactive\n"); + return(-EIO); + } + + if (rs->flags & (SUSPEND_FLAG | NOIO_FLAG)) { + return(-EAGAIN); + } + + disks = rs->stamp.oldelementcount; + if ((disks <= 1) || /* (Bug 253595) */ + ((disks > rs->nr_elements) && (rs->stamp.missingelement == -1))) + { + printk(KERN_ALERT"NWRAID5: IO Error, only %d disks in the array\n", disks); + return(-EIO); + } + + disks0 = disks - 1; + sector = bio->bi_sector - rs->ti->begin; + shift = rs->stamp.raidstripeshift; + stripe = block = sector >> shift; + sector_div(stripe, disks0); + group = (unsigned long) stripe >> rs->stamp.groupshift; +// printk(KERN_ALERT"NWRAID5: Doing a %s request. Sector=" SECTOR_FORMAT " Stripe=" SECTOR_FORMAT " group=%d\n", +// (rw == READ) ? "READ" : "WRITE", sector, stripe, group); + + if ((sector == 0) && (rw == WRITE)) { + AdjustLastBlock(rs, bio); + } + + /* Check to see if the block is in a restripe state or not . */ + if (!(rs->flags & INSYNC_FLAG)) + { + if ((locked = CheckGroupLock(rs, sector + (bio->bi_size >> 9), group)) > 1) + { +// printk(KERN_ALERT"NWRAID5: Check group completed with %d\n", locked); + if (locked == 2) + { + /* Don't have the lock, so just link it. */ +// printk(KERN_ALERT"NWRAID5: IO lock rejected group=%d count=%d\n", +// group, rs->lockmapcount[group]); + return(-EAGAIN); + } + if (locked == 3) + { + disks = rs->stamp.elementcount; + if (disks <= 1) + { + return(-EIO); + } + + disks0 = disks - 1; + stripe = block; + sector_div(stripe, disks0); + group = (uint32_t) stripe >> rs->stamp.groupshift; + } + } + } + + context->bio = bio; + context->group = group; + if (locked == 1) { +// printk(KERN_ALERT"NWRAID5: IO group %d locked count=%d\n", +// group, rs->lockmapcount[group]); + context->group |= LOCKEDMASK; + } + + stripemask = (1 << shift) - 1; + dataelement = sector_div(block, disks); + block = stripe; + parelement = disks0 - sector_div(block, disks); + offset = (uint32_t) sector & stripemask; + cacheoffset = (offset & (~(CACHE_SECTORS - 1))) + (stripe << shift); + offset &= (CACHE_SECTORS - 1); + size = (CACHE_SECTORS - offset) << 9; /* size in bytes */ + + /* Set the missing bits */ +// if ((rs->stamp.missingelement != -1) && +// (rs->stamp.missingelement < disks)){ + if (rs->stamp.missingelement < disks) { + + if ((rs->restripestate <= INIT_RESTRIPE) || + (!(test_bit(group, rs->bitmap)))) { + + if (rs->stamp.missingelement == dataelement) { + context->status |= DATA_MISSING; + } + else if (rs->stamp.missingelement == parelement){ + context->status |= PARITY_MISSING; + } + } + } + + atomic_inc(&rs->iopending); + + if (size >= bio->bi_size) { + /* A single message can handle this request. */ + + context->element = dataelement; + context->parity = parelement; + context->sector = offset; + context->offset = cacheoffset; + context->elementcount = disks; + + if (rw == READ) { + r = read_from_cache(rs, context); + } + else { + r = write_to_cache(rs, context); + } + + if (r) { + if (r == 1) { + if (test_bit(dataelement, &rs->loadedmap) == 0) { +// printk(KERN_ALERT"NWRAID5: single request not loaded\n"); + atomic_dec(&rs->iopending); + return(-EPIPE); + } + +// printk(KERN_ALERT"NWRAID5: Sending single request\n"); + bio->bi_bdev = rs->elements[dataelement].dev->bdev; + bio->bi_sector = rs->elements[dataelement].offset + cacheoffset + offset; + } + else { + atomic_dec(&rs->iopending); + } + } + return(r); + } + else + { + /* We need multiple message for this request. */ +// printk(KERN_ALERT"NWRAID5: We need to split the request\n"); + + context->cache = (struct RaidCacheDef*) bio->bi_private; /* Overload this variable for split */ + atomic_set(&context->count,0); + context->element = 0; + + idx = bio->bi_idx; + bio_size = bio->bi_size; + bv_len = bio->bi_io_vec[idx].bv_len; + bv_offset = bio->bi_io_vec[idx].bv_offset; + list = NULL; + + while (bio_size) { + clone = split_bio(bio, size, &idx, &bv_len, &bv_offset); + if (clone) { +// printk(KERN_ALERT"NWRAID: Clone successful = %x size %d\n", clone, clone->bi_size); + if ((clonecontext = get_context(rs)) == NULL) { + bio_put(clone); + goto io_error_out; + } + + clonecontext->group = 0; + + if ((dataelement != rs->stamp.missingelement) && + (test_bit(dataelement, &rs->loadedmap) == 0)) { + + if (locked == 1) + { + ClearRestripeIOFlag(rs, group); + } + bio_put(clone); + put_context(clonecontext); + + while (list) { + clonecontext = list; + list = list->link; + bio_put(clonecontext->bio); + put_context(clonecontext); + } + +// printk(KERN_ALERT"NWRAID: Error splitting the bio.\n"); + atomic_dec(&rs->iopending); + return(-EPIPE); + } + + clonecontext->element = dataelement; + clonecontext->parity = parelement; + clonecontext->sector = offset; + clonecontext->offset = cacheoffset; + clonecontext->bio = clone; + clonecontext->elementcount = disks; + clonecontext->link = list; + list = clonecontext; + + clone->bi_bdev = rs->elements[dataelement].dev->bdev; + clone->bi_sector = rs->elements[dataelement].offset + offset + cacheoffset; + clone->bi_end_io = MultiIOCallback; + + atomic_inc(&context->count); + bio_size -= size; + if (bio_size) { + offset = 0; + size = CACHE_SIZE; + if (size > bio_size) + size = bio_size; + + cacheoffset += CACHE_SECTORS; + + if ((cacheoffset & stripemask) == 0) + { + if (dataelement == disks0) + dataelement = 0; + else + dataelement++; + + if (dataelement == parelement) + { + /* Reset the parity element for this stripe as well. */ + if (parelement == 0) + parelement = disks0; + else + parelement--; + + stripe++; + } + + cacheoffset = stripe << shift; + } + } + } + else { + /* Failed to get the clone, so return them, queue, and exit */ +io_error_out: while (list) { + clonecontext = list; + list = list->link; + bio_put(clonecontext->bio); + put_context(clonecontext); + } + +// printk(KERN_ALERT"NWRAID: Error splitting the bio.\n"); + atomic_dec(&rs->iopending); + return(-EAGAIN); + } + } + + bio->bi_private = context; + /* Now send all the clones */ + while (list) { + context = list; + list = context->link; + + if (rw == READ) { + r = read_from_cache(rs, context); + } + else { + r = write_to_cache(rs, context); + } + + if (r) { + if (r == 1) { + generic_make_request(context->bio); + if (rw == WRITE) + clear_bitmap(context); + } + else { + MultiIOCallback(context->bio, 0, r); + } + put_context(context); + } + } + + return(0); + } +} + +static int ReadIOCallback(struct bio *clone, unsigned int done, int err) +{ + iocontext *context = (iocontext*) clone->bi_private; + struct raid_set *rs; + unsigned long flags; + +// printk(KERN_ALERT"NWRAID5: ReadIOCallback Offset="SECTOR_FORMAT" Err=%d\n", +// context->offset, err); + if (err) { + rs = context->rs; + spin_lock_irqsave(&rs->irqlock, flags); + context->link = rs->errorlist; + rs->errorlist = context; + spin_unlock_irqrestore(&rs->irqlock, flags); + + bio_put(clone); + return(0); + } + +// printk(KERN_ALERT"NWRAID5: Calling complete_request from ReadIOCallback err=%d\n", err); + bio_endio(context->bio, context->bio->bi_size, 0); + return_context(context); + bio_put(clone); + return(0); +} + +void do_raid5_context(struct raid_set *rs, iocontext *list, int rw) +{ + iocontext *head = NULL, *tail = NULL, *context; + struct bio *clone; +// unsigned long flags, group; + int r; + + while (list) { + context = list; + list = list->link; + + + /* Update the missing bits */ + context->status = 0; + + if (rs->stamp.missingelement != -1) { + if ((rs->restripestate <= INIT_RESTRIPE) || + (!(test_bit((context->group & ~LOCKEDMASK), rs->bitmap)))) { + + if (rs->stamp.missingelement == context->element) { + context->status |= DATA_MISSING; + } + else if (rs->stamp.missingelement == context->parity){ + context->status |= PARITY_MISSING; + } + } + } + + atomic_inc(&rs->iopending); + + if (rw == READ) { + r = read_from_cache(rs, context); + } + else { + r = write_to_cache(rs, context); + } + +// printk(KERN_ALERT"NWRAID5: Do Context: Context=%x sector="SECTOR_FORMAT" element= %d status= %x, r=%d\n", +// context, (context->bio->bi_sector - rs->ti->begin), context->element, context->status, r); + if (r) { + /* A single message can handle this request. */ + if (r == 1) { + if (test_bit(context->element, &rs->loadedmap) == 0) { + complete_request(context, -EPIPE); +// atomic_dec(&rs->iopending); + continue; + } + clone = bio_clone(context->bio,GFP_NOIO); + if (clone) { + clone->bi_bdev = rs->elements[context->element].dev->bdev; + clone->bi_sector = rs->elements[context->element].offset + context->offset + context->sector; + clone->bi_end_io = ReadIOCallback; + clone->bi_private = context; + generic_make_request(clone); + } + else { + atomic_dec(&rs->iopending); +// if (context->group & LOCKEDMASK) { +// ClearRestripeIOFlag(rs, (context->group & ~LOCKEDMASK)); +// } + /* queue it and try later later */ + if (head == NULL) { + head = context; + } + else { + tail->link = context; + } + tail = context; + context->link = NULL; + } + } + else { + if (r == -EAGAIN) + { + atomic_dec(&rs->iopending); +// if (context->group & LOCKEDMASK) { +// ClearRestripeIOFlag(rs, (context->group & ~LOCKEDMASK)); +// } + if (head == NULL) { + head = context; + } + else { + tail->link = context; + } + tail = context; + context->link = NULL; + } + else { + complete_request(context, r); + } + } + } + } + if (head) { + spin_lock(&rs->lock); + if (rw == READ) { + if (rs->queue_readhead == NULL) { + rs->queue_readtail = tail; + } + else { + tail->link = rs->queue_readhead; + } + rs->queue_readhead = head; + } + else { + if (rs->queue_writehead == NULL) { + rs->queue_writetail = tail; + } + else { + tail->link = rs->queue_writehead; + } + rs->queue_writehead = head; + } + spin_unlock(&rs->lock); + wake(rs); + } + +// printk(KERN_ALERT"NWRAID5: raid context count = %d.\n", count); +} + +void do_raid5_io(struct raid_set *rs, struct bio_list *list) +{ + struct bio *bio, *clone; + iocontext *context; + int r; + struct bio_list *list2, queue; + + queue.head = queue.tail = NULL; + + while (list->head != NULL) { +// printk(KERN_ALERT"NWRAID: Doing a delayed %s request at sector %d.\n", (bio_rw(list->head) == READ) ? "READ" : "WRITE", list->head->bi_sector); + if ((context = get_context(rs)) == NULL) { + /* No more contexts, so just return the list. */ + if (queue.head != NULL) { + queue.tail->bi_next = list->head; + list->head = queue.head; + } + + if (bio_rw(list->head) == READ) + list2 = &rs->reads; + else + list2 = &rs->writes; + + spin_lock(&rs->lock); + list->tail->bi_next = list2->head; + if (list2->head == NULL) + list2->tail = list->tail; + list2->head = list->head; + spin_unlock(&rs->lock); + wake(rs); + return; + } + + bio = list->head; + list->head = bio->bi_next; + bio->bi_next = NULL; + + if ((r = raid5_io(rs, bio, context)) == 1) { + clone = bio_clone(bio,GFP_NOIO); + if (clone) { + clone->bi_end_io = ReadIOCallback; + clone->bi_private = context; + generic_make_request(clone); + } + else { + /* queue it and try later later */ + queue_context(context,bio_rw(bio)); + } + } + else if (r) { + if (r == -EAGAIN) { + bio_list_add(&queue, bio); + put_context(context); + } + else { +// printk(KERN_ALERT"NWRAID5: Error IO request. %d\n", r); + put_context(context); + atomic_inc(&rs->iopending); /* endio will decrement it */ + bio_endio(bio, bio->bi_size, r); + } + } + } + + if (queue.head != NULL) { + if (bio_rw(queue.head) == READ) + list2 = &rs->reads; + else + list2 = &rs->writes; + + spin_lock(&rs->lock); + queue.tail->bi_next = list2->head; + if (list2->head == NULL) + list2->tail = queue.tail; + list2->head = queue.head; + spin_unlock(&rs->lock); + wake(rs); + } +} + +/*----------------------------------------------------------------- + * Writes. + *---------------------------------------------------------------*/ + +/*----------------------------------------------------------------- + * Work + *---------------------------------------------------------------*/ +static LIST_HEAD(_raid_sets); +static DECLARE_RWSEM(_raid_sets_lock); + +static int add_raid_set(struct raid_set *rs) +{ + down_write(&_raid_sets_lock); + list_add_tail(&rs->list, &_raid_sets); + up_write(&_raid_sets_lock); + + return 0; +} + +static void del_raid_set(struct raid_set *rs) +{ + down_write(&_raid_sets_lock); + list_del(&rs->list); + up_write(&_raid_sets_lock); +} + +void process_raid5_io(struct raid_set *rs) +{ +// printk(KERN_ALERT"NWRAID: process_raid5_io start\n"); + if (rs->fast_head) { + fast_complete(rs); + } + + if (rs->errorlist) { + error_retry(rs); + } + + if (rs->readcomplete_head) { + process_cache_reads(rs); + } + + if (rs->cachewrite) { + process_cache_writes(rs); + } + + if (rs->parity_write) { + process_parity_writes(rs); + } + + if (rs->process_head) { + process_cache_list(rs); + } +// printk(KERN_ALERT"NWRAID: process_raid5_io end\n"); +} + +static void do_raid(struct raid_set *rs) +{ + struct bio_list reads, writes; + iocontext *readlist, *writelist; + +// printk(KERN_ALERT"NWRAID5: Do Raid state=%d\n", rs->restripestate); + + if (rs->fast_head) { + fast_complete(rs); + } + + if (rs->errorlist) { + error_retry(rs); + } + + if (rs->splitlist) { + split_retry(rs); + } + + if (rs->readcomplete_head) { + process_cache_reads(rs); + } + + if (rs->cachewrite) { + process_cache_writes(rs); + } + + if (rs->parity_write) { + process_parity_writes(rs); + } + + if (rs->restripestate != NO_RESTRIPE) { + if (rs->writehead) { + restripe_write(rs); + } + + if (rs->completehead) { + if (rs->flags & RESYNC_FLAG) { + resync_parity(rs); + } + else { + restripe_complete(rs); + } + } + + if (rs->parity) { + if (rs->flags & RESYNC_FLAG) { + resync_parity_complete(rs); + } + else { + restripe_parity_complete(rs); + } + } + + if (rs->restripestate == RESTRIPEING) { + if (rs->flags & RESYNC_FLAG) { + raid5_resync(rs); + } + else { + raid5_restripe(rs); + } + } + + if ((rs->restripestate == DONE) || (rs->restripestate == STOPPING)){ + if ((rs->flags & (RESTRIPE_RESTART | DEACTIVE_FLAG)) == RESTRIPE_RESTART) { + rs->flags &= ~(RESTRIPE_ABORT | RESTRIPE_RESTART); + rs->restripestate = RESTRIPEING; + raid5_restripe(rs); + } + else { + stop_restripe(rs); + } + } + } + + if (rs->flags & (SUSPEND_FLAG | NOIO_FLAG)) { + reads.head = NULL; + writes.head = NULL; + readlist = NULL; + writelist = NULL; + } + else { + spin_lock(&rs->lock); + reads.head = rs->reads.head; + reads.tail = rs->reads.tail; + writes.head = rs->writes.head; + writes.tail = rs->writes.tail; + rs->reads.head = rs->reads.tail = rs->writes.head = rs->writes.tail = NULL; + if (writes.head) { + rs->flags |= PROCESS_WRITES; + } + readlist = rs->queue_readhead; + writelist = rs->queue_writehead; + rs->queue_readhead = NULL; + rs->queue_writehead = NULL; + spin_unlock(&rs->lock); + } + + if (readlist) + do_raid5_context(rs, readlist, READ); + if (writelist) + do_raid5_context(rs, writelist, WRITE); + if (reads.head) + do_raid5_io(rs, &reads); + if (writes.head) { + do_raid5_io(rs, &writes); + spin_lock(&rs->lock); + rs->flags &= ~PROCESS_WRITES; + spin_unlock(&rs->lock); + } + + if (rs->process_head) { + process_cache_list(rs); + } + + if (rs->flags & FLUSH_FLAG) { + flush_log(rs); + } + + dm_table_unplug_all(rs->ti->table); +} + +static void do_work(void *ignored) +{ + struct raid_set *rs; + +// printk(KERN_ALERT"NWRAID5: Do Work\n"); + atomic_set(&wakecount,1); + down_read(&_raid_sets_lock); + list_for_each_entry (rs, &_raid_sets, list) + do_raid(rs); + up_read(&_raid_sets_lock); +} + +/*----------------------------------------------------------------- + * Target functions + *---------------------------------------------------------------*/ +static int AllocateCacheBuffers( struct raid_set *rs) +{ + struct RaidCacheDef *cache, *head, *prev; + struct page *page; + int i, j, ccode = 0; + + + /* Link up the caches */ + head = (struct RaidCacheDef*) &rs->useNext; + prev = head; + rs->cachecount = 0; + + for (i=0; irs = rs; + cache->sectoroffset = -1; + spin_lock_init(&cache->localcachelock); + atomic_set(&cache->writecount,0); + atomic_set(&cache->readcount,0); + + for (j=0; j < MAX_ELEMENTS; j++) { + cache->index[j].cache = cache; + cache->index[j].index = j; + } + + cache->usePrev = + cache->orderPrev = prev; + prev->useNext = + prev->orderNext = cache; + + prev = cache; + + cache->alloclink = rs->cache; + rs->cache = cache; + rs->cachecount++; + } + } + + head->usePrev = + head->orderPrev = prev; + prev->useNext = + prev->orderNext = head; + + cache = rs->cache; + + /* Now allocate the buffers for each cache */ + + /* This loop may take awhile, so add an occasional threadswitch */ + while(cache) + { + if (!(cache->flags & CACHE_ALLOCATED)) { + for (j=0; jstamp.elementcount; j++) + { + if (cache->buffers[j].page == NULL) + { + if ((page = alloc_page(GFP_KERNEL)) == NULL) + { + ccode = -ENOMEM; + break; + } + cache->buffers[j].page = page; + SetPageLocked(page); +// printk(KERN_ALERT"NWRAID5: Alloc page %x\n", page_address(cache->buffers[j].page)); + } + } + + if (ccode) + { + /* We failed, so quit. */ + break; + } + else + { + cache->flags |= CACHE_ALLOCATED; + } + } + cache = cache->alloclink; + } + + return(ccode); +} + +static int raid5_ctr(struct dm_target *ti, unsigned int argc, char **argv) +{ + int r; + struct raid_set *rs; + + if ((r = alloc_raid_set(ti,argc,argv,&rs)) == 0) { + + rs->wq = _kraid_wq; + rs->work = &_kraid_work; + rs->wakecount = &wakecount; + if (AllocateCacheBuffers(rs) != 0) { + free_raid_set(rs); + return(-ENOMEM); + } + + add_raid_set(rs); + + if (rs->flags & FLUSH_FLAG) { + wake(rs); + } + } + + printk(KERN_ALERT"NWRAID: Constructor completed with %d\n",r); + return r; +} + +static void raid5_dtr(struct dm_target *ti) +{ + struct raid_set *rs; + + if (!ti) { + printk(KERN_ALERT"NWRAID5: ti = NULL on destructor\n"); + return; + } + + rs = (struct raid_set *) ti->private; + + if (rs) { + printk(KERN_ALERT"NWRAID: Destructor called ti=%x\n", ti); + del_raid_set(rs); + free_raid_set(rs); + } +} + +/* + * RAID0 mapping function + */ +static int raid5_map(struct dm_target *ti, struct bio *bio, + union map_info *map_context) +{ + int r, rw = bio_rw(bio); + struct raid_set *rs = (struct raid_set*) ti->private; + iocontext *context; + + + if (!rs) { + return(-EIO); + } + + if (rs->flags & DEACTIVE_FLAG) { +// printk(KERN_ALERT"NWRAID5: Raid Deactive\n"); + return(-EIO); + } + + if ((bio->bi_sector - rs->ti->begin) > rs->stamp.capacity) { + return(-EPERM); + } + +// printk(KERN_ALERT"NWRAID5: Received a %s request. Sector=" SECTOR_FORMAT "\n", +// (rw == READ) ? "READ" : "WRITE", bio->bi_sector - ti->begin); +// atomic_inc(&rs->iototal); + + map_context->ptr = NULL; + + if ((rw == READ) || (rw == WRITE)) { + /* If we have writes queued, queue it behind. */ + if (rw == WRITE) { +// if ((rs->writes.head != NULL) || (rs->flags & PROCESS_WRITES)) { + queue_bio(rs, bio, WRITE); + return(0); +// } + } + + if ((context = get_context(rs)) == NULL) { +// printk(KERN_ALERT"NWRAID5: No more context\n"); + queue_bio(rs, bio, rw); + return(0); + } + + r = raid5_io(rs, bio, context); + if (r) { + if (r == 1) { + map_context->ptr = context; + } + else if (r == -EAGAIN) { + queue_bio(rs, bio, rw); + put_context(context); + r = 0; + } + else { +// atomic_dec(&rs->iototal); + put_context(context); + } + } + return(r); + } + else { + /* We don't do read aheads */ +// atomic_dec(&rs->iototal); + return(-EIO); + } +} + +static int raid5_end_io(struct dm_target *ti, struct bio *bio, + int error, union map_info *map_context) +{ + struct raid_set *rs = (struct raid_set *) ti->private; + iocontext *context = (iocontext*) map_context->ptr; + unsigned long flags; + + atomic_dec(&rs->iopending); +// atomic_dec(&rs->iototal); + +// flags = atomic_read(&rs->iopending); +// printk(KERN_ALERT"NWRAID5: EndIO iocount=%d\n", flags); +// +// if (error) { +// printk(KERN_ALERT"NWRAID5: EndIO Context=%p sector="SECTOR_FORMAT" err=%d iocount=%d total=%d\n", +// context, (bio->bi_sector - rs->ti->begin), error, flags, atomic_read(&rs->iototal)); +// } +// else if ((flags < 10) && (rs->flags & DEACTIVE_FLAG)) { +// printk(KERN_ALERT"NWRAID5: EndIO iocount=%d total=%d\n", flags, atomic_read(&rs->iototal)); +// } + + if (context && rs) { + if (error) { + atomic_inc(&rs->iopending); +// atomic_inc(&rs->iototal); + spin_lock_irqsave(&rs->irqlock, flags); + context->link = rs->errorlist; + rs->errorlist = context; + spin_unlock_irqrestore(&rs->irqlock, flags); + wake(rs); + map_context->ptr = NULL; + error = 1; + } + else { + return_context(context); + } + } + + wake(rs); + return error; +} + +static int raid5_message(struct dm_target *ti, unsigned argc, char **argv) +{ + char *bptr; + int i, r = -EINVAL; + struct raid_set *rs = (struct raid_set *) ti->private; + struct RaidCacheDef *cache; + + for (i=0; ilock); + rs->flags |= RESTRIPE_ENABLED; + spin_unlock(&rs->lock); + refresh_log(rs); + stop_IO(rs); + + cache = rs->cache; + while (cache) + { + cache->sectoroffset = -1; + cache = cache->alloclink; + } + + start_IO(rs); + start_restripe(rs); + printk(KERN_ALERT"NWRAID5: Restripe enabled\n"); + r = 0; + } + else if (memcmp(bptr, "off", 3) == 0) { + spin_lock(&rs->lock); + if (!(rs->flags & RESTRIPE_ENABLED)) { + spin_unlock(&rs->lock); + r = 0; + continue; + } + rs->flags &= ~RESTRIPE_ENABLED; + spin_unlock(&rs->lock); + stop_restripe(rs); + flush_log(rs); + printk(KERN_ALERT"NWRAID5: Restripe disabled\n"); + r = 0; + } + } + } + + return(r); +} + +static struct target_type raid5_target = { + .name = "raid5", + .version = {1, 0, 1}, + .module = THIS_MODULE, + .ctr = raid5_ctr, + .dtr = raid5_dtr, + .map = raid5_map, + .end_io = raid5_end_io, + .postsuspend = raid_suspend, + .resume = raid_resume, + .status = raid_status, + .message = raid5_message, +}; + +int nw_raid5_init(void) +{ + int r; + + printk(KERN_ALERT"NWRAID5: Initializing\n"); +// r = dm_dirty_log_init(); +// if (r) +// return r; + + atomic_set(&wakecount, 1); + _kraid_wq = create_workqueue("nwraid5"); + if (!_kraid_wq) { + DMERR("couldn't start work queue"); +// dm_dirty_log_exit(); + return -ENOMEM; + } + INIT_WORK(&_kraid_work, do_work, NULL); + + r = dm_register_target(&raid5_target); + if (r < 0) { + DMERR("%s: Failed to register mirror target", + raid5_target.name); +// dm_dirty_log_exit(); + destroy_workqueue(_kraid_wq); + return r; + } + + r = dm_io_get(1); + if (r < 0) { + DMERR("%s: Failed to initialize io pool"); +// dm_dirty_log_exit(); + destroy_workqueue(_kraid_wq); + dm_unregister_target(&raid5_target); + } + + return r; +} + +void nw_raid5_exit(void) +{ + int r; + + printk(KERN_ALERT"NWRAID5: Exiting\n"); + r = dm_unregister_target(&raid5_target); + if (r < 0) + DMERR("%s: unregister failed %d", raid5_target.name, r); + + destroy_workqueue(_kraid_wq); +// dm_dirty_log_exit(); + + dm_io_put(1); +} + diff --git a/src/nwnss/nwraid/nwraidModules.mk b/src/nwnss/nwraid/nwraidModules.mk new file mode 100644 index 0000000..f6245ac --- /dev/null +++ b/src/nwnss/nwraid/nwraidModules.mk @@ -0,0 +1,280 @@ +############################################################################ +# +# (C) Copyright 2004 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################ + +########################################################################## +# This defines what MODULES are being built for this NLM +# +# $Author: ajack $ +# $Date: 2008-03-04 06:19:02 +0530 (Tue, 04 Mar 2008) $ +# +# $RCSfile$ +# $Revision: 2289 $ +# +########################################################################## +MODULE_VERSION=15 + +#------------------------------------------------------------------------- +# If the version number is not defined here, the general product version +# number will be used (defined in bldVersion.bld) +# +# major version 1 to 99 +# minor version 1 to 99 +# sub version 1 to 26 +#------------------------------------------------------------------------- +MAJOR_VERSION=1 +MINOR_VERSION=0 +SUB_VERSION=0 + +#------------------------------------------------------------------------- +# Build OPTIONS +#------------------------------------------------------------------------- + +BUILD_WITH_KERNEL_FLAGS=1 +BUILD_NO_INSTRUMENT_FUNCTIONS=1 + +#set to 0 if you are NOT using source code control +IS_USING_SOURCE_CONTROL=1 + +#Set to ONE if you want the linked files to be copied to the SDK/BIN directory. +COPY_TO_SDK_BIN=1 + + #set to ONE if you only want to copy the OPTIMIZED version to SDK/BIN. + COPY_OPTIMIZED_ONLY=0 + +#Set this to ONE if you are building a NETWARE version independent NLM +#(not NETWARE version specific) +NETWARE_VERSION_INDEPENDENT=1 + + #if ONE include the NETWARE .H files in the compiler search paths. + USE_NETWARE_INCLUDES=0 + + #if ONE include the NETWARE import file at LINK time + USE_NETWARE_IMPORTS=0 + +#If ONE IMPORT the LIBNSS APIs and include in the search path SDK/LIBRARY +#and SDK/PUBLIC +IMPORT_INDEPENDENT_LIBNSS=0 + +#If ONE include in the search path SDK/LIBRARY and SDK/PUBLIC +USE_LIBNSS_INCLUDES=0 + +#If ONE then LINK with the NSS library and include all of the NSS library +#directories in the compiler search paths. This includes the SDK/PUBLIC, +#SDK/INCLUDE, SDK/INTERNAL, LIBRARY/SRC directories. +LINK_WITH_NSSLIB=0 + +#if ONE then IMPORT the NSS library and COMN layer APIS and include the +#SDK/PUBLIC directory in the compiler search paths. +IMPORT_NSSLIB=0 + + #If ONE and (LINK_WITH_NSSLIB==1 or IMPORT_NSSLIB==1) then do the same + #operation to the NSSLIB area you are doing to the local area. + #CHECK_NSSLIB=0 + + #If ONE and (CHECK_NSSLIB==1) then we will clean the NSSLIB area when we + #clean the local area. + #CLEAN_NSSLIB=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INCLUDE directory in + #the compiler search paths + #USE_NSS_SDK_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/COMNSA directory in + #the compiler search paths + #USE_NSS_SDK_COMNSA_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INTERNAL directory in + #the compiler search paths + #USE_NSS_SDK_INTERNAL_INCLUDES=1 + +#if ONE then do NOT import the NSS COMMON layer APIs +DONT_IMPORT_COMMON_LAYER=1 + +#if ONE, compile and link with the NETWARE sdk environment. +USE_NETWARE_SDK=0 + +#if ONE, include DS headers. +USE_NDS_INCLUDES=0 + +#if ONE, do LANGUAGE ENABLING processing +DO_LANGUAGE_ENABLING=0 + +#Set to null (i.e. no value) to not add XDC data to the NLM. For most +#NetWare 5.0 NLMs, the value should be -u. +MOAB_XDC_TOOL_OPTION=-n + +#************************************************************************* +# List of source directories for NSS +#************************************************************************* +SOURCE_DIRECTORIES= + +#************************************************************************* +# Source Modules for NSS (.C .386) +#************************************************************************* +SOURCE_FILES=\ + nwraid1.c \ + nwraid0.c \ + nwraid5.c \ + dmio.c \ + +SOURCE_FILES_NODEBUG= + +#************************************************************************* +# Source Include files for NSS (.H .inc) +#************************************************************************* +INCLUDE_FILES=\ + nwraid.h \ + dmio.h \ + +#------------------------------------------------------------------------- +# Additional source files that need to be checked out +#------------------------------------------------------------------------- +OTHER_FILES=\ + Module.supported + +#------------------------------------------------------------------------- +# This defines what routines are being EXPORTED. You should put .IMP +# files in the "UTILITY_EXPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_EXPORTS= + + +#UTILITY_EXPORTS_VIA_FILE= +UTILITY_EXPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# This defines what routines are being IMPORTED. You should put .IMP +# files in the "UTILITY_IMPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_IMPORTS= + +UTILITY_IMPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# Library definitions +# This defines additional libraries to LINK with and additional +# directories to put on out INCLUDE path. +#------------------------------------------------------------------------- +#additional libraries to link with +EXTRA_LIBRARIES= +EXTRA_STATIC_LIBRARIES= +EXTRA_DYNAMIC_LIBRARIES= +EXTRA_LIBRARY_INCLPATH= + +#------------------------------------------------------------------------- +# Include path +# This defines additional include path to compile with +#------------------------------------------------------------------------- +#additional include path +EXTRA_INCLUDE_PATH=\ + ${srctree}/drivers/md \ + +#------------------------------------------------------------------------- +# Additional C and ASSEMBLY options to use +#------------------------------------------------------------------------- +EXTRA_C_OPTIONS= +EXTRA_ASM_OPTIONS= +EXTRA_LINK_OPTIONS= + +#------------------------------------------------------------------------- +# Additional module attributes +#------------------------------------------------------------------------- +MODULE_DESCRIPTION='NW RAID for DM' +MODULE_ADDITIONAL_COPYRIGHT= +MODULE_OPTIONS= +MODULE_DEPENDENCIES= +MODULE_TYPE= +MODULE_NAME=nwraid +MODULE_EXTENSION=ko +MODULE_START_ROUTINE=nw_raid_init +MODULE_EXIT_ROUTINE=nw_raid_exit +#set to 1 if you want the optimized NLM to be packed +MODULE_PACK_NLM=0 + +#========================================================================= +#========================================================================= +# LOCAL BUILD RULES +#========================================================================= +#========================================================================= + +#------------------------------------------------------------------------- +# Default BUILD rule +#------------------------------------------------------------------------- +DEFAULT: DEFAULT_BUILD + +#------------------------------------------------------------------------- +# Additional rules +#------------------------------------------------------------------------- + +#BUILD_GREENRIVER_OPT: +# @echo "...This NLM does not have an OPTIMIZED GREENRIVER specific version" + +#BUILD_GREENRIVER_UNOPT: +# @echo "...This NLM does not have an UNOPTIMIZED GREENRIVER specific version" + +BUILD_MOAB_MP_UNOPT: \ + COMPILE_UNOPT_MP_MOAB \ + LINK_UNOPT_MP_MOAB + +BUILD_MOAB_MP_OPT: \ + COMPILE_OPT_MP_MOAB \ + LINK_OPT_MP_MOAB + +BUILD_MOAB_SP_UNOPT: + @echo "...This NLM does not have an UNOPTIMIZED SP specific version" + +BUILD_MOAB_SP_OPT: + @echo "...This NLM does not have an OPTIMIZED SP specific version" + + +#BUILD_MOAB_SP_UNOPT: \ +# COMPILE_UNOPT_SP_MOAB \ +# LINK_UNOPT_SP_MOAB +# +#BUILD_MOAB_SP_OPT: \ +# COMPILE_OPT_SP_MOAB \ +# LINK_OPT_SP_MOAB + + +#------------------------------------------------------------------------- +# Language Enabling rules +#------------------------------------------------------------------------- +mdb: \ + DEFAULT_MDB + +umdb: \ + LOCAL_MDB + +mdbcreate: \ + DEFAULT_CREATE_MDB_FILE + +#------------------------------------------------------------------------- +# Other rules +#------------------------------------------------------------------------- +deps: DEFAULT_DEPS + +cscope: DEFAULT_CSCOPE + diff --git a/src/nwnss/sharedsrc/README b/src/nwnss/sharedsrc/README new file mode 100644 index 0000000..07c24c1 --- /dev/null +++ b/src/nwnss/sharedsrc/README @@ -0,0 +1,12 @@ +#################################### +### public_core/sharedsrc/README ### +#################################### + +The files in this directory are shared source files (thus the .c.h extension). +This means that they are source files (.c) that are included by other source +files (.c) that are then compiled multiple times. These files are typically +not fitting to put in a library, as they are built multiple ways (i.e. once +for a kernel module, and once for an application). Wherever possible, if the +files could be put together into a library with reasonable effort, it should +be considered. + diff --git a/src/nwnss/sharedsrc/dbginit.c.h b/src/nwnss/sharedsrc/dbginit.c.h index e8ae8ae..be29837 100644 --- a/src/nwnss/sharedsrc/dbginit.c.h +++ b/src/nwnss/sharedsrc/dbginit.c.h @@ -141,7 +141,7 @@ WFile_s *DBG_DbgScreen = NULL; void DBG_Startup(void) { ASSERT_MPKNSS_LOCK(); - + if (DBG_debugLogBuffer == NULL) { DBG_debugLogBuffer = malloc(DBG_DebugLogBufferSize + 0x8000); @@ -196,7 +196,7 @@ void DBG_InitDebug(void) } /************************************************************************** - * Deactivate the DEBUG screen + * Deactivate the DEBUG screen ***************************************************************************/ void DBG_UninitDebug(void) { @@ -601,7 +601,7 @@ void DBG_SaveDebugLogToFile( /* The -1 below is so we do not write the NULL */ if (LDOSWrite(debugLogFileHandle, writeOffset, - &DBG_debugLogBuffer[removeIndex+sizeof(DebugEntryHeader_s)], + &DBG_debugLogBuffer[removeIndex+sizeof(DebugEntryHeader_s)], lenToWrite-1, &numWritten) != 0) { OutputToScreenWithAttribute(debugScreen, LRED, @@ -754,3 +754,4 @@ utf8_t *GetErrorFromNumber( } return(MSGNot("zERR_UNKNOWN_ERROR")); } + diff --git a/src/nwnss/sharedsrc/getDSGuid.c.h b/src/nwnss/sharedsrc/getDSGuid.c.h new file mode 100644 index 0000000..1dc3d65 --- /dev/null +++ b/src/nwnss/sharedsrc/getDSGuid.c.h @@ -0,0 +1,128 @@ +/**************************************************************************** + | + | (C) Copyright 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: randys $ + | $Date: 2005-08-02 05:17:19 +0530 (Tue, 02 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1150 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | NSS Library Routine + +-------------------------------------------------------------------------*/ +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +#include +#if zNETWARE +#include "pssmpk.h" +#include +#endif +#include +#include + +#include "zError.h" +#if zNETWARE +#include "eDir.h" +#include "sysimp.h" +#endif +#include "guid.h" +#if zLINUX && !defined(__KERNEL__) +#define stricmp(_str1, _str2) strcasecmp(_str1, _str2) +#include +extern void syslog(int __pri, __const char *__fmt, ...) + __attribute__ ((__format__(__printf__, 2, 3))); +#endif + +/**************************************************************************** + * + * Get the GUID for the current context + * Only runs in user space on Linux, since it calls DClient function + * + ****************************************************************************/ +STATUS LB_GetDSGUID( + LONG context, + NDSid_t *NDSid, + LONG *uid) +{ + enum + { + ATTR_DATA_SIZE = 4096 + }; + + unsigned int count; + int i; + int err = 0; + DDCVALUE *attributeData; + DDCVALUE *curValue; + char *nameList[3]; + DDCReadFilter filter; + + attributeData = calloc(1, ATTR_DATA_SIZE); + if (attributeData == NULL) + { + err = zERR_NO_MEMORY; + goto out; + } + + nameList[0] = "GUID"; + nameList[1] = "uidNumber"; + nameList[2] = 0; + + filter.syncFormat = 0; + filter.attributes = (void *)&nameList; + filter.minValueTime.seconds = 0; + + *NDSid = zINVALID_GUID; + for (; ;) + { + err = DDCReadToBuffer(context, &filter, DS_VALUE_INFO, + ATTR_DATA_SIZE - 1, ATTR_DATA_SIZE - 1, attributeData, &count); + if ((count == 0) || (err != 0)) + { + break; + } + + for (i = 0, curValue = attributeData; i < count; i++, curValue++) + { + if (stricmp(curValue->attrName, "GUID") == 0) + { + memcpy(NDSid, curValue->data, 16); + } + else if (stricmp(curValue->attrName, "uidNumber") == 0) + { + if (uid != NULL) + { + *uid = *(LONG *) curValue->data; + } + } + } + } + + free(attributeData); +out: + return err; +} +#endif diff --git a/src/nwnss/sharedsrc/guid.c.h b/src/nwnss/sharedsrc/guid.c.h index b0699d4..a174ea6 100644 --- a/src/nwnss/sharedsrc/guid.c.h +++ b/src/nwnss/sharedsrc/guid.c.h @@ -155,31 +155,27 @@ ****************************************************************************/ #if zNETWARE || (zLINUX && defined(__KERNEL__)) -#include +#include #include #endif #include #include #include -#include #if zNETWARE || (zLINUX && defined(__KERNEL__)) -#include +#include #endif -#include +#include #if zNETWARE || (zLINUX && defined(__KERNEL__)) -#include +#include #include #else #include -#include -#include #define TRUE 1 #define FALSE 0 #endif -#include -#include +#include GUID_t zZERO_GUID = {0,0,0,0,0, {0,0,0,0,0,0} }; @@ -202,39 +198,26 @@ void GUID_init(); /*************************************************************************** * - * Get OS time - returns in 100 nanosecond ticks since Oct. 15, 1582 + * Get OS time - returns in 100 nonsecond tics since Oct. 15, 1582 * ****************************************************************************/ -QUAD GUID_getTime(void) -{ #if zNETWARE || (zLINUX && defined(__KERNEL__)) +QUAD GUID_getTime() +{ Time_t utc; - /* * Get current time */ utc = GetUTCTime(); - /* - * Convert into 100 nano-second units and add the offset between DTSS - * formatted times and UTC formatted times. - * DTSS UTC base time is October 15, 1582. - * UTC base time is January 1, 1970. - */ + /* + * Convert into 100 nano-second units and add the offset between DTSS + * formatted times and UTC formatted times. + * DTSS UTC base time is October 15, 1582. + * UTC base time is January 1, 1970. + */ return (((((QUAD)utc * 1000000) + (microSecondTimer() % 1000000)) * 10) + - (QUAD)0x01B21DD213814000ULL); -#else - struct timespec ts; - - if (clock_gettime(CLOCK_REALTIME, &ts) != 0) - { - ts.tv_sec = time(NULL); - ts.tv_nsec = 0; - } - return ((QUAD)ts.tv_sec * 10000000ULL) + - ((QUAD)ts.tv_nsec / 100ULL) + - (QUAD)0x01B21DD213814000ULL; -#endif + UI64_CONST(0x01B21DD213814000)); } /**************************************************************************** @@ -258,7 +241,7 @@ void LB_GUIDGenerate( { /* we need to init the GUID generation system */ GUID_init(); } - + currentTime = GUID_getTime(); if (currentTime <= GUIDsavedTime) { /* the clock has backed up or at least not changed */ @@ -290,6 +273,7 @@ void LB_GUIDGenerate( retGUID->node[4], retGUID->node[5]); #endif } +#endif /**************************************************************************** * @@ -344,34 +328,14 @@ void GUID_init() { /* unable to get the NIC address -- generate a random node value */ #if zNETWARE || (zLINUX && defined(__KERNEL__)) srand(microSecondTimer()); // kernel - for (i=0; i < 6; i++) - { - temp = rand(); - GUIDnode[i] = temp & 0xFF; - } #else - int fd = open("/dev/urandom", O_RDONLY); - if (fd >= 0) - { - ssize_t got = read(fd, GUIDnode, sizeof(GUIDnode)); - close(fd); - if (got == (ssize_t)sizeof(GUIDnode)) - { - GUIDnode[0] |= 0x01; - GUIDclockSeq = (GUIDnode[4] << 8 | GUIDnode[5]) & 0x3FFF; - GUIDinitDone = TRUE; - return; - } - } - srand((unsigned)time(NULL) ^ (unsigned)getpid()); + srandom(time(NULL)); +#endif for (i=0; i < 6; i++) { temp = rand(); GUIDnode[i] = temp & 0xFF; } - GUIDnode[0] |= 0x01; - GUIDclockSeq = rand() & 0x3FFF; -#endif } GUIDinitDone = TRUE; return; @@ -419,7 +383,7 @@ int LB_GUIDValidate( * base 16. * * Notes - This function doesn't validate guid's value. It only checks - * its string format and converts it. + * its string format and converts it. * */ @@ -507,8 +471,8 @@ STATUS LB_GUIDFromUTF8( utf8_t *p, GUID_t *guid ) } /* GUID validation is no more done here. It's upon individual user - to decide whether GUID needs to be validated. - if ( !LB_GUIDValidate( guid) ) + to decide whether GUID needs to be validated. + if ( !LB_GUIDValidate( guid) ) { return zERR_INVALID_VOLUME_ID; } @@ -532,14 +496,14 @@ STATUS LB_GUIDToString( const GUID_t *guid, unsigned int bufferSize, char *buffe { - if ( bufferSize < GUID_FORMAT_SIZE ) + if ( bufferSize < GUID_FORMAT_SIZE ) { *buffer = '\0'; return zERR_BUFFER_TOO_SMALL; } sprintf(buffer,"%08lx-%04x-%04x-%02x-%02x-%02x%02x%02x%02x%02x%02x", - (unsigned long)guid->timeLow, + guid->timeLow, guid->timeMid, guid->timeHighAndVersion, guid->clockSeqHighAndReserved, @@ -565,6 +529,7 @@ STATUS LB_GUIDToString( const GUID_t *guid, unsigned int bufferSize, char *buffe * zERR... indicates specific error */ +#if zNETWARE || (zLINUX && defined(__KERNEL__)) STATUS LB_GUIDToVolumeName( const GUID_t *guid, NINT bufferSize, /* Size in BYTES */ @@ -575,14 +540,14 @@ STATUS LB_GUIDToVolumeName( char charBuffer[GUID_FORMAT_SIZE]; ASSERT_MPKNSS_LOCK(); -// if ( bufferSize < GUID_FORMAT_SIZE ) +// if ( bufferSize < GUID_FORMAT_SIZE ) // { // *buffer = 0; // return zERR_BUFFER_TOO_SMALL; // } sprintf(charBuffer, "%08lX_%04X_%04X_%02X_%02X_%02X%02X%02X%02X%02X%02X", - (unsigned long)guid->timeLow, + guid->timeLow, guid->timeMid, guid->timeHighAndVersion, guid->clockSeqHighAndReserved, @@ -598,6 +563,7 @@ STATUS LB_GUIDToVolumeName( return( status ); } /* End of LB_GUIDToVolumeName() */ +#endif /* @@ -611,6 +577,7 @@ STATUS LB_GUIDToVolumeName( * zERR... indicates specific error */ +#if zNETWARE || (zLINUX && defined(__KERNEL__)) STATUS LB_GUIDTimeToShortVolumeName( const GUID_t *guid, NINT bufferSize, /* Size in BYTES */ @@ -643,3 +610,4 @@ STATUS LB_GUIDTimeToShortVolumeName( return( status ); } /* End of LB_GUIDTimeToShortVolumeName() */ +#endif diff --git a/src/nwnss/sharedsrc/manage.c.h b/src/nwnss/sharedsrc/manage.c.h new file mode 100644 index 0000000..6a21fee --- /dev/null +++ b/src/nwnss/sharedsrc/manage.c.h @@ -0,0 +1,2093 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: tprem $ + | $Date: 2008-04-02 17:39:59 +0530 (Wed, 02 Apr 2008) $ + | + | $RCSfile$ + | $Revision: 2312 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage NSS using XML + | + +-------------------------------------------------------------------------*/ +#if zLINUX && defined(__KERNEL__) +#include +#include +#endif + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +#include /* NetWare */ +#endif +#include +#if zLINUX && !defined(__KERNEL__) +#include +#include +#include +extern void syslog (int __pri, __const char *__fmt, ...) + __attribute__ ((__format__(__printf__, 2, 3))); +#include +#include +#endif +#include +#include +#include +#ifndef __linux__ +#include +#include +#endif + +#ifndef __linux__ +#include + +#include +#endif + +#include "manage.h" +#include "manageNlm.h" +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +#include "manageStartup.h" +#endif +#include "comnPublics.h" +#include "nssPubs.h" +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +#include "virtualIO.h" +#endif +#include "mgmt.h" +#include "xmlTags.h" + +#ifndef __linux__ +#include "sysimp.h" +#endif + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +#include "comnAuthorize.h" +#include "comnZAS.h" +#include "msgName.h" +#include "dirQuotas.h" +#endif +#include "utc.h" + + +#if zLINUX && defined(__KERNEL__) +void NSS_AddSpecialTrusteesThread( + FsmLite_s *fsm, + NINT *dummy); +#endif + +#if zLINUX && !defined(__KERNEL__) +#define MPKNSS_LOCK() ((void) 0) +#define MPKNSS_UNLOCK() ((void) 0) +#define ASSERT_MPKNSS_LOCK() ((void) 0) +#endif + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +OBID FSAPPid = -1; +OBID NSSAPPid = -1; +OBID LEGACYAPPid = -1; +OBID RAIDMgrID = -1; +OBID FailoverMgrID = -1; + +OBID NWPASubSystemID = -1; +OBID CIOSSubSystemID = -1; + +STATUS MNSS_ProcessAddTrustee(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessAddQuota(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +//extern unsigned long get_stack_use(void); + +typedef struct DataStreamCookie_s +{ + NINT currentOp; + NINT requestedOp; +#define DS_OP_NONE 0 +#define DS_OP_READ_REPLY 1 +#define DS_OP_READ_DS 2 +#define DS_OP_WRITE_DS 3 +#define DS_OP_DELETE_DS 4 +#define DS_OP_RENAME_DS 5 +#define DS_OP_LIST_DS 6 +#define DS_OP_DONE 7 + + NINT namespace; + QUAD offset; + utf8_t fileName[zMAX_FULL_NAME]; + utf8_t dataStreamName[zMAX_COMPONENT_NAME]; + utf8_t newName[zMAX_COMPONENT_NAME]; + Key_t rootKey; + Key_t fileKey; + Key_t dsKey; + NINT resultLen; + utf8_t resultBuf[4096]; +} DataStreamCookie_s; + +#ifndef __linux__ + +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ + +SiblingElements_s AuthorizeNWElements[] = +{ + {TAG_ADDTRUSTEE, MNSS_ProcessAddTrustee}, + {0} +}; + +SiblingElements_s DirQuotaElements[] = +{ + {TAG_ADDQUOTA, MNSS_ProcessAddQuota}, + {0} +}; + +/****************************************************************************** + * + * MNSS_LoadSubSystemIDs - Find the sub system IDs for NWPA and CIOS adapters. + * + *****************************************************************************/ +STATUS MNSS_LoadSubSystemIDs(void) +{ + LONG ccode = zOK; + OBID subSystemID = -1; + + ASSERT_MPKNSS_LOCK(); + + if (NWPASubSystemID == -1) + { + /* + * Get the media manager sub system objects + */ + ZMM_FindObjectType(ccode, MM_IO_SUBSYSTEM_CLASS, MM_SUBSYSTEM_NWPA, + &subSystemID); + if (ccode == MM_OK) + { + NWPASubSystemID = subSystemID; + } + } + + if (CIOSSubSystemID == -1) + { + ZMM_FindObjectType(ccode, MM_IO_SUBSYSTEM_CLASS, MM_SUBSYSTEM_CIOS, + &subSystemID); + if (ccode == MM_OK) + { + CIOSSubSystemID = subSystemID; + } + } + + return zOK; +}; + +/****************************************************************************** + * + * LoadAppIDs - Find application IDs for NSS and Traditional file system. + * Also find the ManagerID for the raid devices. + * + *****************************************************************************/ +STATUS MNSS_LoadAppIDs(void) +{ + struct ApplicationGenericInfoDef appGenInfo; + struct ObjectManagerGenericInfoDef mgrGen; + + LONG ccode = zOK; + OBID fsappID = -1; + OBID mgrID = -1; + + ASSERT_MPKNSS_LOCK(); + + if (NSSAPPid == -1 || LEGACYAPPid == -1) + { + /* + * Get the media manager file system application objects + */ + ZMM_FindObjectType(ccode, MM_APPLICATION_CLASS, MM_FILE_SYSTEM_APPLICATION, + &fsappID); + while (ccode == MM_OK) /* an F.S.A has been found */ + { + ZMM_ReturnObjectGenericInfo(ccode, fsappID, sizeof(appGenInfo), + &appGenInfo); + if (ccode == MM_OK) + { + if (appGenInfo.identifier == MM_NSS_FILESYSTEM_ID) + { + NSSAPPid = fsappID; + } + else if (appGenInfo.identifier == MM_CLASSIC_FILESYSTEM_ID) + { + LEGACYAPPid = fsappID; + } + } + ZMM_FindObjectType(ccode, MM_APPLICATION_CLASS, + MM_FILE_SYSTEM_APPLICATION, &fsappID); + } + } + + if (RAIDMgrID == -1) + { + /* + * Get the raid object ID. This will be the same as long as MM is loaded, + * so we only need to get it once. + */ + ccode = MM_OK; + RAIDMgrID = -1; + while (ccode == MM_OK) + { + ZMM_FindObjectType(ccode, MM_OBJECT_MANAGER_CLASS, MM_DEVICE_OBJECT, + &mgrID); + if (ccode == MM_OK) + { + ZMM_ReturnObjectGenericInfo(ccode, mgrID, sizeof(mgrGen), + &mgrGen); + if (ccode == MM_OK) + { + if (mgrGen.identifier == RAID_DEVICE_IDENTIFIER) + { + RAIDMgrID = mgrID; + } + else if (mgrGen.identifier == FAILOVER_DEVICE_IDENTIFIER) + { + FailoverMgrID = mgrID; + } + } + } + } + } + + return zOK; +} +#endif +#endif + +/**************************************************************************** + * + * Process a bunch of XML commands at the same XML level + * + ****************************************************************************/ +STATUS MNSS_ProcessElements( + VirtInfo_s *virtInfo, + utf8_t *parentTag, + XML_ElementInfo_s *parentElement, + SiblingElements_s *elements) +{ + STATUS status; + utf8_t *tagName; + utf8_t *elementStart; + NINT tagLen; + XML_ElementInfo_s oneElement; + NINT i; + + ASSERT_MPKNSS_LOCK(); + + if ((status = VIRT_AddResultTag(virtInfo, parentTag, FALSE, TRUE)) != zOK) + { + goto error; + } + elementStart = parentElement->dataStart; + + for(;;) + { + /* + * Get the next tag inside the parent element + */ + if (XML_GetNextTag(elementStart, parentElement->dataEnd, + &oneElement, &tagName, &tagLen) != zOK) + { + break; /* we have completed all of the elements */ + } + elementStart = oneElement.elementEnd + 1; + + for (i = 0; elements[i].tag != NULL; i++) + { + if ((*(elements[i].tag + tagLen) == 0) && + (memcmp(tagName, elements[i].tag, tagLen) == 0)) + { + /* process command */ + if ((status = elements[i].processFunction(elements[i].tag, + virtInfo, &oneElement)) != zOK) + { + goto end; + } + } + } + } +end: + VIRT_AddResultTag(virtInfo, parentTag, TRUE, TRUE); + +error: + return status; +} + + + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +#ifndef __linux__ +/**************************************************************************** + * + * This function adds a trustee to a file/directory + * + ****************************************************************************/ +STATUS MNSS_ProcessAddTrustee( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + GeneralMsg_s genMsg; + NamingMsg_s nameMsg; + STATUS status; + utf8_t *rights; + LONG trusteeID; + UserID_t ndsGUID; + NINT len; + NINT mask; + NINT i; + char right; + TagContent_s tagContent[4]; + const TagRequest_s tags[] = + { + {TAG_CONTEXT, 0}, + {TAG_NAME, 0}, + {TAG_RIGHTS, 0}, + {TAG_FILENAME, 0}, + {0} + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Resolve the user's name to an ID */ + if (MNDS_GetObjectIDFromName(tagContent[0].content, tagContent[1].content, + &trusteeID) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Bad user name")); + goto exit; + } + + if (COMN_MapNDSIDToGUID(&status, trusteeID, &ndsGUID) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Trustee to GUID conversion error")); + goto exit; + } + + /* rights */ + rights = tagContent[2].content; + + /* convert the rights */ + len = strlen(rights); + mask = 0; + for (i = 0; i < len; i++, rights++) + { + right = *rights; + if (right < 'a') + { + right += 0x20; + } + switch (right) + { + case 'a': + mask |= zAUTHORIZE_ACCESS_CONTROL; + break; + case 'c': + mask |= zAUTHORIZE_CREATE_ENTRY; + break; + case 'e': + mask |= zAUTHORIZE_DELETE_ENTRY; + break; + case 'f': + mask |= zAUTHORIZE_SEE_FILES; + break; + case 'm': + mask |= zAUTHORIZE_MODIFY_METADATA; + break; + case 'r': + mask |= zAUTHORIZE_READ_CONTENTS; + break; + case 's': + mask |= zAUTHORIZE_SUPERVISOR; + break; + case 'w': + mask |= zAUTHORIZE_WRITE_CONTENTS; + break; + default: + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Bad trustee rights")); + goto exit; + } + } + + /* actually add the trustee */ + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + COMN_INIT_NAMING_MSG(&nameMsg); + COMN_SETUP_NAMING_MSG_SIMPLE(&nameMsg, tagContent[3].content, zPFMT_UTF8, + NAMPMODE_Undefined, XLATCHED, zNSPACE_LONG, zNTYPE_FILE, NULL); + + if (COMN_Lookup(&genMsg, &nameMsg) != zOK) + { + COMN_CleanupNameMsg(&genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(&genMsg), + MSGNot("Error finding file")); + goto exit; + } + + if (COMN_ZAS_addACLEntry(&genMsg, &nameMsg, &ndsGUID, mask, + zAUTHORIZE_INHERIT_DOWN | zAUTHORIZE_INHERIT_UP) != zOK) + { + COMN_CleanupNameMsg(&genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(&genMsg), + MSGNot("Error adding trustee")); + goto exit; + } + COMN_CleanupNameMsg(&genMsg, &nameMsg); + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; +} +#endif + +/**************************************************************************** + * + * This function adds a quota to a file/directory + * + ****************************************************************************/ +STATUS MNSS_ProcessAddQuota( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + GeneralMsg_s genMsg; + NamingMsg_s nameMsg; + SQUAD quota; + const TagRequest_s tags[] = + { + {TAG_FILENAME, 0}, + {TAG_QUOTAAMOUNT, 0}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + FILE_NAME = 0, + QUOTA_AMOUNT = 1 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + quota = atoq(tagContent[QUOTA_AMOUNT].content); + + /* add the quota */ + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + COMN_INIT_NAMING_MSG(&nameMsg); + COMN_SETUP_NAMING_MSG_SIMPLE(&nameMsg, tagContent[FILE_NAME].content, + zPFMT_UTF8, NAMPMODE_Undefined, XLATCHED, zNSPACE_LONG, zNTYPE_FILE, + NULL); + + if (COMN_Lookup(&genMsg, &nameMsg) != zOK) + { + COMN_CleanupNameMsg(&genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(&genMsg), + MSGNot("Error finding file")); + goto exit; + } + + if (DIRQ_SetDirectoryQuota(&genMsg, nameMsg.curvol, nameMsg.curFile, + quota) != zOK) + { + COMN_CleanupNameMsg(&genMsg, &nameMsg); + MNSS_ReturnResult(virtInfo, tagName, GetErrno(&genMsg), + MSGNot("Error adding trustee")); + goto exit; + } + COMN_CleanupNameMsg(&genMsg, &nameMsg); + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; +} +#endif + +/**************************************************************************** + * Add a utc time tag to the output XML + *****************************************************************************/ + STATUS AddUTCTimeTag( + VirtInfo_s *virtInfo, + utf8_t *tagName, + Time_t time) +{ + STATUS status; + utf8_t tmpStr[zMAX_COMPONENT_NAME]; + + if ((status = VIRT_AddResultTagForAttribute(virtInfo, tagName)) + != zOK) + { + return status; + } + sprintf(tmpStr, MSGNot("%u"), time); + if ((status = VIRT_AddAttribute(virtInfo, ATR_VALUE, tmpStr, TRUE, + FALSE, FALSE)) != zOK) + { + return status; + } + UTCTime2Str(time, tmpStr); + if ((status = VIRT_AddResultData(virtInfo, tmpStr)) != zOK) + { + return(status); + } + if ((status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE)) != zOK) + { + return(status); + } + return(zOK); +} + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) + +#if !defined(__KERNEL__) +NINT OpenNCPServ() +{ + NINT err = 0; + static BOOL firstTime = TRUE; + + if (firstTime) + { + firstTime = FALSE; + err = OpenNCPServLib(); + } + if (err != 0) + { + syslog(LOG_INFO, "Error %d from OpenNSSAdminLib\n", err); + goto exit; + } +exit: + return err; +} +#endif + +/**************************************************************************** + * + * This is the command function for limited management of NDS using XML + * + ****************************************************************************/ +/* VIRTUAL FILE -- WRITE FUNCTION */ +STATUS MANAGE_loopback( + NINT parmLen, + utf8_t *parm, + NINT bufferLength, + BYTE *buffer, + NINT offset, + VirtInfo_s *virtInfo) +{ + VIRT_AddResultData(virtInfo, "["); + VIRT_AddResultData(virtInfo, (utf8_t *)buffer); + VIRT_AddResultData(virtInfo, "]"); + return zOK; +} + +/**************************************************************************** + * + * This is the command function for limited management of NDS using XML + * + ****************************************************************************/ +/* VIRTUAL FILE -- WRITE FUNCTION */ +STATUS MANAGE_ndsCommand( + NINT parmLen, + utf8_t *parm, + NINT bufferLength, + BYTE *buffer, + NINT offset, + VirtInfo_s *virtInfo) +{ + STATUS status; + utf8_t *tagName; + utf8_t *searchStart; + NINT tagLen; + XML_ElementInfo_s mainElement; + XML_ElementInfo_s actionElement; + + MPKNSS_LOCK(); + /* Check to see if we have the entire XML command */ + if ((status = MGMT_FindFirstElement(virtInfo, TAG_NDSREQUEST, bufferLength, + buffer, offset, &mainElement)) != zOK) + { + goto error; + } + + if ((status = VIRT_AddResultTag(virtInfo, TAG_NDSREPLY, FALSE, TRUE)) + != zOK) + { + goto error; + } + searchStart = mainElement.dataStart; + for(;;) + { + /* + * Get the next tag which should be an action for NDS + */ + if (XML_GetNextTag(searchStart, mainElement.dataEnd, + &actionElement, &tagName, &tagLen) != zOK) + { + break; /* we have all of the elements */ + } + searchStart = actionElement.elementEnd + 1; + + /* NDS User */ + if (memcmp(tagName, TAG_NDSUSER, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_NDSUSER, + &actionElement, NDSUserElements)) != zOK) + { + break; + } + } + else if (memcmp(tagName, TAG_NDSVOLUME, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_NDSVOLUME, + &actionElement, NDSVolumeElements)) != zOK) + { + break; + } + } + else if (memcmp(tagName, TAG_NDSPOOL, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_NDSPOOL, + &actionElement, NDSPoolElements)) != zOK) + { + break; + } + } + else if (memcmp(tagName, TAG_NDSOBJECT, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_NDSOBJECT, + &actionElement, NDSObjectElements)) != zOK) + { + break; + } + } + + } + MGMT_ReturnResultNSS(virtInfo, status); + VIRT_AddResultTag(virtInfo, TAG_NDSREPLY, TRUE, TRUE); + +error: + MPKNSS_UNLOCK(); + return status; +} + +/**************************************************************************** + * + * This is the command function for managing NSS using XML + * + ****************************************************************************/ +/* VIRTUAL FILE -- WRITE FUNCTION */ +STATUS MANAGE_nssCommand( + NINT parmLen, + utf8_t *parm, + NINT bufferLength, + BYTE *buffer, + NINT offset, + VirtInfo_s *virtInfo) +{ + STATUS status; + utf8_t *tagName; + utf8_t *searchStart; + NINT tagLen; + XML_ElementInfo_s mainElement; + XML_ElementInfo_s actionElement; + + MPKNSS_LOCK(); + + /* Check to see if we have the entire XML command */ + if ((status = MGMT_FindFirstElement(virtInfo, TAG_NSSREQUEST, bufferLength, + buffer, offset, &mainElement)) != zOK) + { + goto error; + } + + if ((status = VIRT_AddResultTag(virtInfo, TAG_NSSREPLY, FALSE, TRUE)) + != zOK) + { + goto error; + } + searchStart = mainElement.dataStart; + for(;;) + { + /* + * Get the next tag which should be an action for NSS + */ + if (XML_GetNextTag(searchStart, mainElement.dataEnd, + &actionElement, &tagName, &tagLen) != zOK) + { + break; /* we have all of the elements */ + } + searchStart = actionElement.elementEnd + 1; + + /* Pool operations */ + if (memcmp(tagName, TAG_POOL, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_POOL, + &actionElement, PoolElements)) != zOK) + { + break; + } + } + /* Volume operations */ + else if (memcmp(tagName, TAG_VOLUME, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_VOLUME, + &actionElement, VolumeElements)) != zOK) + { + break; + } + } +#ifndef __linux__ + + /* NetWare authorization */ + else if (memcmp(tagName, TAG_AUTHORIZENW, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_AUTHORIZENW, + &actionElement, AuthorizeNWElements)) != zOK) + { + break; + } + } + /* Directory Quotas */ + else if (memcmp(tagName, TAG_DIRECTORYQUOTA, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_DIRECTORYQUOTA, + &actionElement, DirQuotaElements)) != zOK) + { + break; + } + } +#endif + /* Deleted Volume operations */ + else if (memcmp(tagName, TAG_DELETEDVOLUME, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_DELETEDVOLUME, + &actionElement, DeletedVolumeElements)) != zOK) + { + break; + } + } + /* server operations */ + else if (memcmp(tagName, TAG_SERVER, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_SERVER, + &actionElement, ServerElements)) != zOK) + { + break; + } + } +#ifndef __linux__ + /* adapter operations */ + else if (memcmp(tagName, TAG_ADAPTER, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_ADAPTER, + &actionElement, AdapterElements)) != zOK) + { + break; + } + } +#endif + /* device operations */ + else if (memcmp(tagName, TAG_DEVICE, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_DEVICE, + &actionElement, DeviceElements)) != zOK) + { + break; + } + } + /* partition operations */ + else if (memcmp(tagName, TAG_PARTITION, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_PARTITION, + &actionElement, PartitionElements)) != zOK) + { + break; + } + } + /* DFS operations */ + else if (memcmp(tagName, TAG_DFS, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_DFS, + &actionElement, DFSElements)) != zOK) + { + break; + } + } + /* LSS operations */ + else if (memcmp(tagName, TAG_LSS2, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_LSS2, + &actionElement, LSSElements)) != zOK) + { + break; + } + } + /* RAID operations */ + else if (memcmp(tagName, TAG_RAID, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_RAID, + &actionElement, RAIDElements)) != zOK) + { + break; + } + } + /* Junction operations */ + else if (memcmp(tagName, TAG_JUNCTION, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_JUNCTION, + &actionElement, junctionElements)) != zOK) + { + break; + } + } +#ifndef __linux__ + /* VCU operations */ + else if (memcmp(tagName, TAG_VCU, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_VCU, + &actionElement, vcuElements)) != zOK) + { + break; + } + } +#endif + /* VLDB operations */ + else if (memcmp(tagName, TAG_VLDB, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_VLDB, + &actionElement, vldbElements)) != zOK) + { + break; + } + } + /* Volume Manager operations */ + else if (memcmp(tagName, TAG_VOLMN, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_VOLMN, + &actionElement, volmnElements)) != zOK) + { + break; + } + } + /* User space restrictions operations */ + else if (memcmp(tagName, TAG_USERSPACERESTRICTIONS, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_USERSPACERESTRICTIONS, + &actionElement, UserSpaceRestrictionsElements)) != zOK) + { + break; + } + } + else if (memcmp(tagName, TAG_BEAST, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_BEAST, + &actionElement, beastInfoElements)) != zOK) + { + break; + } + } + /* CIFS operations */ + else if (memcmp(tagName, TAG_CIFS, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_CIFS, + &actionElement, CIFSElements)) != zOK) + { + break; + } + } +#ifndef __linux__ + /* AFP operations */ + else if (memcmp(tagName, TAG_AFP, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_AFP, + &actionElement, AFPElements)) != zOK) + { + break; + } + } +#endif + + } + MGMT_ReturnResultNSS(virtInfo, status); + VIRT_AddResultTag(virtInfo, TAG_NSSREPLY, TRUE, TRUE); + +error: + MPKNSS_UNLOCK(); + return status; +} + +/**************************************************************************** + * + * This is the command function for managing user based operation using XML + * + ****************************************************************************/ +/* VIRTUAL FILE -- WRITE FUNCTION */ +STATUS MANAGE_userCommand( + NINT parmLen, + utf8_t *parm, + NINT bufferLength, + BYTE *buffer, + NINT offset, + VirtInfo_s *virtInfo) +{ + STATUS status; + utf8_t *tagName; + utf8_t *searchStart; + NINT tagLen; + XML_ElementInfo_s mainElement; + XML_ElementInfo_s actionElement; + + MPKNSS_LOCK(); + + /* Check to see if we have the entire XML command */ + if ((status = MGMT_FindFirstElement(virtInfo, TAG_USERREQUEST, bufferLength, + buffer, offset, &mainElement)) != zOK) + { + goto error; + } + + if ((status = VIRT_AddResultTag(virtInfo, TAG_USERREPLY, FALSE, TRUE)) + != zOK) + { + goto error; + } + searchStart = mainElement.dataStart; + for(;;) + { + /* + * Get the next tag which should be an action for user operations + */ + if (XML_GetNextTag(searchStart, mainElement.dataEnd, + &actionElement, &tagName, &tagLen) != zOK) + { + break; /* we have all of the elements */ + } + searchStart = actionElement.elementEnd + 1; + + /* quota operations */ + if (memcmp(tagName, TAG_USERQUOTA, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_USERQUOTA, + &actionElement, UserSpaceRestrictionsElements)) != zOK) + { + break; + } + } + + } + MGMT_ReturnResultNSS(virtInfo, status); + VIRT_AddResultTag(virtInfo, TAG_USERREPLY, TRUE, TRUE); + +error: + MPKNSS_UNLOCK(); + return status; +} + +#endif + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) + +/**************************************************************************** + * + * This is the command function for managing files and directories using XML + * + ****************************************************************************/ +/* VIRTUAL FILE -- WRITE FUNCTION */ +STATUS MANAGE_fileCommand( + NINT parmLen, + utf8_t *parm, + NINT bufferLength, + BYTE *buffer, + NINT offset, + VirtInfo_s *virtInfo) +{ + STATUS status; + utf8_t *tagName; + utf8_t *searchStart; + NINT tagLen; + XML_ElementInfo_s mainElement; + XML_ElementInfo_s actionElement; + + MPKNSS_LOCK(); + /* Check to see if we have the entire XML command */ + if ((status = MGMT_FindFirstElement(virtInfo, TAG_FILEREQUEST, bufferLength, + buffer, offset, &mainElement)) != zOK) + { + goto error; + } + + if ((status = VIRT_AddResultTag(virtInfo, TAG_FILEREPLY, FALSE, TRUE)) + != zOK) + { + goto error; + } + searchStart = mainElement.dataStart; + for(;;) + { + /* + * Get the next tag which should be an action + */ + if (XML_GetNextTag(searchStart, mainElement.dataEnd, + &actionElement, &tagName, &tagLen) != zOK) + { + break; /* we have all of the elements */ + } + searchStart = actionElement.elementEnd + 1; + + /* File info */ + if (memcmp(tagName, TAG_FILEINFO, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_FILEINFO, + &actionElement, FileInfoElements)) != zOK) + { + break; + } + } + /* NetWare authorization */ + else if (memcmp(tagName, TAG_TRUSTEES, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_TRUSTEES, + &actionElement, TrusteeElements)) != zOK) + { + break; + } + } + /* Directory Quotas */ + else if (memcmp(tagName, TAG_DIRECTORYQUOTAS, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_DIRECTORYQUOTAS, + &actionElement, DirectoryQuotaElements)) != zOK) + { + break; + } + } + /* Salvage */ + else if (memcmp(tagName, TAG_SALVAGE, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_SALVAGE, + &actionElement, SalvageElements)) != zOK) + { + break; + } + } + else if (memcmp(tagName, TAG_ARCHIVE, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_ARCHIVE, + &actionElement, ArkElements)) != zOK) + { + break; + } + } + /* Unix authorization */ + else if (memcmp(tagName, TAG_UNIXPERMISSIONS, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_UNIXPERMISSIONS, + &actionElement, UnixPermissionsElements)) != zOK) + { + break; + } + } + } + MGMT_ReturnResultNSS(virtInfo, status); + VIRT_AddResultTag(virtInfo, TAG_FILEREPLY, TRUE, TRUE); + +error: + MPKNSS_UNLOCK(); + return status; +} + +#if zLINUX +/**************************************************************************** + * + * This is the command function for managing files and directories using XML + * + ****************************************************************************/ +/* VIRTUAL FILE -- WRITE FUNCTION */ +STATUS MANAGE_linuxCommand( + NINT parmLen, + utf8_t *parm, + NINT bufferLength, + BYTE *buffer, + NINT offset, + VirtInfo_s *virtInfo) +{ + STATUS status; + utf8_t *tagName; + utf8_t *searchStart; + NINT tagLen; + XML_ElementInfo_s mainElement; + XML_ElementInfo_s actionElement; + + MPKNSS_LOCK(); + /* Check to see if we have the entire XML command */ + + if ((status = MGMT_FindFirstElement(virtInfo, TAG_LINUXREQUEST, bufferLength, + buffer, offset, &mainElement)) != zOK) + { + goto error; + } + + if ((status = VIRT_AddResultTag(virtInfo, TAG_LINUXREPLY, FALSE, TRUE)) + != zOK) + { + goto error; + } + searchStart = mainElement.dataStart; + for(;;) + { + /* + * Get the next tag which should be an action + */ + if (XML_GetNextTag(searchStart, mainElement.dataEnd, + &actionElement, &tagName, &tagLen) != zOK) + { + break; /* we have all of the elements */ + } + searchStart = actionElement.elementEnd + 1; + + /* Storage management */ + if (memcmp(tagName, TAG_STORAGE, tagLen) == 0) + { + if ((status = MNSS_ProcessElements(virtInfo, TAG_STORAGE, + &actionElement, LinuxElements)) != zOK) + { + break; + } + } + } + MGMT_ReturnResultNSS(virtInfo, status); + VIRT_AddResultTag(virtInfo, TAG_LINUXREPLY, TRUE, TRUE); + +error: + MPKNSS_UNLOCK(); + return status; +} +#endif + +/**************************************************************************** + * Cleanup at file close time + ****************************************************************************/ +void cleanupDataStreamCookie( + VirtInfo_s *virtInfo) +{ + DataStreamCookie_s *dsCookie; + + MPKNSS_UNLOCK(); + dsCookie = virtInfo->otherPtr; + if (dsCookie->dsKey) + { + zClose(dsCookie->dsKey); + dsCookie->dsKey = 0; + } + if (dsCookie->fileKey) + { + zClose(dsCookie->fileKey); + dsCookie->fileKey = 0; + } + if (dsCookie->rootKey) + { + zClose(dsCookie->rootKey); + dsCookie->rootKey = 0; + } + MPKNSS_LOCK(); + return; +} + +/**************************************************************************** + * Allocate a cookie structure for datastream handling. + ****************************************************************************/ +STATUS allocateDataStreamCookie( + VirtInfo_s *virtInfo) +{ + DataStreamCookie_s *dsCookie; + + /* If we have not allocated a cookie then do so. */ + if (virtInfo->otherPtr == NULL) + { + dsCookie = malloc(sizeof(DataStreamCookie_s)); + if (dsCookie == NULL) + { + return zERR_NO_MEMORY; + } + virtInfo->otherPtr = dsCookie; + virtInfo->closeFunc = cleanupDataStreamCookie; + dsCookie->currentOp = DS_OP_NONE; + dsCookie->requestedOp = DS_OP_NONE; + dsCookie->namespace = zNSPACE_LONG; + dsCookie->offset = 0; + dsCookie->rootKey = 0; + dsCookie->fileKey = 0; + dsCookie->dsKey = 0; + dsCookie->offset = 0; + dsCookie->resultLen = 0; + } + return zOK; +} + +/**************************************************************************** + * + * This copies and normalized a file name to the vol:path form if it is in + * slash form. + * + ****************************************************************************/ +void MANAGE_NormalizeFileName( + utf8_t *outName, + utf8_t *inName, + int nameLen) +{ + if (inName[0] == '/') + { /* convert the name */ + NINT i; + NINT insPtr = 0; + + for (i = 1; i < nameLen; i++) + { + if (inName[i] == '/') + { /* found the end of the volume name */ + i++; + outName[insPtr++] = ':'; + break; + } + outName[insPtr++] = inName[i]; + } + + for (; i < nameLen; i++) + { + outName[insPtr++] = inName[i] == '/' ? '\\' : inName[i]; + } + outName[insPtr] = '\0'; + } + else + { + memcpy(outName, inName, nameLen); + outName[nameLen] = '\0'; + } +} + +/**************************************************************************** + * + * This is the write function for reading/writing a datastream + * + ****************************************************************************/ +/* VIRTUAL FILE -- WRITE FUNCTION */ +STATUS MANAGE_WriteDataStream( + NINT parmLen, + utf8_t *parm, + NINT bufferLength, + BYTE *buffer, + NINT offset, + VirtInfo_s *virtInfo) +{ + GeneralMsg_s genMsg; + STATUS status; + XML_ElementInfo_s mainElement; + XML_ElementInfo_s tagElement; + DataStreamCookie_s *dsCookie; + utf8_t *description=NULL; + NINT nameType = zNTYPE_INVALID; + NINT fileType = zFTYPE_INVALID; + NINT retLen; + + MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + if ((status = allocateDataStreamCookie(virtInfo)) != zOK) + { + goto done; + } + + dsCookie = (DataStreamCookie_s *)virtInfo->otherPtr; + + if (dsCookie->currentOp == DS_OP_NONE) + { + /* Namespace is optional - defaults to LONG */ + if (XML_GetTagElement(TAG_NSSDATASTREAM, buffer, buffer + bufferLength, + &mainElement) != zOK) + { + description = "Could not find " TAG_NSSDATASTREAM " tag"; + status = zERR_XML_IS_BAD; + goto sendResult; + } + + /* Get the operation type */ + if (XML_GetTagAttribute(ATR_OPERATION, &mainElement) != zOK) + { + description = "Could not find " ATR_OPERATION " atttribute"; + status = zERR_XML_IS_BAD; + goto sendResult; + } + if (memcmp(mainElement.attributeValueStart, MSGNot("read"), + mainElement.attributeValueLen) == 0) + { + dsCookie->requestedOp = DS_OP_READ_DS; + } + else if (memcmp(mainElement.attributeValueStart, MSGNot("write"), + mainElement.attributeValueLen) == 0) + { + dsCookie->requestedOp = DS_OP_WRITE_DS; + } + else if (memcmp(mainElement.attributeValueStart, MSGNot("delete"), + mainElement.attributeValueLen) == 0) + { + dsCookie->requestedOp = DS_OP_DELETE_DS; + } + else if (memcmp(mainElement.attributeValueStart, MSGNot("rename"), + mainElement.attributeValueLen) == 0) + { + dsCookie->requestedOp = DS_OP_RENAME_DS; + } + else if (memcmp(mainElement.attributeValueStart, MSGNot("list"), + mainElement.attributeValueLen) == 0) + { + dsCookie->requestedOp = DS_OP_LIST_DS; + } + else + { + description = "Attribute " ATR_OPERATION " has a bad value"; + status = zERR_XML_IS_BAD; + goto sendResult; + } + + /* Get the type (datastream or EA) */ + if (dsCookie->requestedOp != DS_OP_LIST_DS) + { + if (XML_GetTagAttribute(ATR_TYPE, &mainElement) != zOK) + { + description = "Could not find " ATR_TYPE " atttribute"; + status = zERR_XML_IS_BAD; + goto sendResult; + } + if (memcmp(mainElement.attributeValueStart, MSGNot("dataStream"), + mainElement.attributeValueLen) == 0) + { + nameType = zNSPACE_DATA_STREAM; + fileType = zFILE_NAMED_DATA_STREAM; + } + else if (memcmp(mainElement.attributeValueStart, + MSGNot("extendedAttribute"), + mainElement.attributeValueLen) == 0) + { + nameType = zNSPACE_EXTENDED_ATTRIBUTE; + fileType = zFILE_EXTENDED_ATTRIBUTE; + } + else + { + description = "Attribute " ATR_TYPE " has a bad value"; + status = zERR_XML_IS_BAD; + goto sendResult; + } + } + + /* Namespace is optional - defaults to LONG */ + if (XML_GetTagElement(TAG_NAMESPACE, mainElement.dataStart, + mainElement.dataEnd, &tagElement) == zOK) + { + tagElement.dataEnd[1] = '\0'; + dsCookie->namespace = atoi(tagElement.dataStart); + } + + /* Filename is required */ + if (XML_GetTagElement(TAG_FILENAME, mainElement.dataStart, + mainElement.dataEnd, &tagElement) != zOK) + { + description = "Could not find " TAG_FILENAME " tag"; + status = zERR_XML_IS_BAD; + goto sendResult; + } +// memcpy(dsCookie->fileName, tagElement.dataStart, tagElement.dataLen); +// dsCookie->fileName[tagElement.dataLen] = '\0'; + MANAGE_NormalizeFileName(dsCookie->fileName, tagElement.dataStart, + tagElement.dataLen); + + /* Datastream name is required */ + if (dsCookie->requestedOp != DS_OP_LIST_DS) + { + if (XML_GetTagElement(TAG_DATASTREAM, mainElement.dataStart, + mainElement.dataEnd, &tagElement) != zOK) + { + description = "Could not find " TAG_DATASTREAM " tag"; + status = zERR_XML_IS_BAD; + goto sendResult; + } + memcpy(dsCookie->dataStreamName, tagElement.dataStart, + tagElement.dataLen); + dsCookie->dataStreamName[tagElement.dataLen] = '\0'; + } + + /* Get the root key */ + MPKNSS_UNLOCK(); + if ((status = zRootKey(0, &dsCookie->rootKey)) != zOK) + { + MPKNSS_LOCK(); + description = "Error opening root key"; + goto sendResult; + } + + /* Open the file */ + if ((status = zOpen(dsCookie->rootKey, zNO_TASK, + dsCookie->namespace | zMODE_UTF8, dsCookie->fileName, + zRR_READ_ACCESS | zRR_SCAN_ACCESS, &dsCookie->fileKey)) != zOK) + { + MPKNSS_LOCK(); + description = "Error opening file"; + goto sendResult; + } + + /* Open the datastream/EA */ + if (dsCookie->requestedOp == DS_OP_WRITE_DS) + { + if ((status = zCreate(dsCookie->fileKey, zNO_TASK, zNILXID, + nameType | zMODE_UTF8, dsCookie->dataStreamName, + fileType, 0, zCREATE_TRUNCATE_IF_THERE, zRR_WRITE_ACCESS, + &dsCookie->dsKey)) != zOK) + { + MPKNSS_LOCK(); + description = "Error creating a data stream or extended attribute"; + goto sendResult; + } + } + else if (dsCookie->requestedOp == DS_OP_READ_DS) + { + if ((status = zOpen(dsCookie->fileKey, zNO_TASK, + nameType | zMODE_UTF8, dsCookie->dataStreamName, + zRR_READ_ACCESS, &dsCookie->dsKey)) != zOK) + { + MPKNSS_LOCK(); + description = "Error opening a data stream or extended attribute"; + goto sendResult; + } + } + else if (dsCookie->requestedOp == DS_OP_DELETE_DS) + { + if ((status = zDelete(dsCookie->fileKey, zNILXID, + nameType | zMODE_UTF8, dsCookie->dataStreamName, + zMATCH_ALL, 0)) != zOK) + { + MPKNSS_LOCK(); + description = "Error deleting a data stream or extended attribute"; + goto sendResult; + } + } + else if (dsCookie->requestedOp == DS_OP_RENAME_DS) + { + if (XML_GetTagElement(TAG_NEWNAME, mainElement.dataStart, + mainElement.dataEnd, &tagElement) != zOK) + { + description = "Could not find " TAG_DATASTREAM " tag"; + status = zERR_XML_IS_BAD; + goto sendResult; + } + memcpy(dsCookie->newName, tagElement.dataStart, + tagElement.dataLen); + dsCookie->newName[tagElement.dataLen] = '\0'; + + if ((status = zRename(dsCookie->fileKey, zNILXID, + nameType | zMODE_UTF8, dsCookie->dataStreamName, + zMATCH_ALL, nameType | zMODE_UTF8, + dsCookie->dataStreamName, zRENAME_THIS_NAME_SPACE_ONLY)) + != zOK) + { + MPKNSS_LOCK(); + description = "Error renaming a data stream or extended attribute"; + goto sendResult; + } + } + MPKNSS_LOCK(); + } + else if (dsCookie->currentOp == DS_OP_WRITE_DS) + { + ZOS_zWrite(status, dsCookie->dsKey, zNILXID, + dsCookie->offset, bufferLength, buffer, &retLen); + if (status != zOK || retLen != bufferLength) + { + goto done; + } + dsCookie->offset += bufferLength; + status = zOK; + goto done; + } + else + { + status = zERR_XML_IS_BAD; + description = "Not expecting a write operation"; + } + +sendResult: + /* send out the start of the reply tag */ + strcpy(dsCookie->resultBuf, MSGNot("<"TAG_NSSDATASTREAMREPLY">\n")); + dsCookie->resultLen = strlen(dsCookie->resultBuf); + if (status == zOK) + { + MGMT_BuildResultElement(status, MSGNot("success"), + dsCookie->resultBuf + dsCookie->resultLen); + } + else + { + MGMT_BuildResultElement(status, description, + dsCookie->resultBuf + dsCookie->resultLen); + } + dsCookie->resultLen = strlen(dsCookie->resultBuf); + sprintf(dsCookie->resultBuf + dsCookie->resultLen, + MSGNot("\n")); + dsCookie->resultLen += strlen(dsCookie->resultBuf + dsCookie->resultLen); + dsCookie->currentOp = DS_OP_READ_REPLY; + status = zOK; + +done: + MPKNSS_UNLOCK(); + return status; +} + +/**************************************************************************** + * + * This is the read function for reading/writing a datastream + * + ****************************************************************************/ +/* VIRTUAL FILE -- READ FUNCTION */ +STATUS MANAGE_ReadDataStream( + NINT parmLen, + utf8_t *parm, + VirtInfo_s *virtInfo) +{ + DataStreamCookie_s *dsCookie; + NINT retLen; + STATUS status; + + if (virtInfo->otherPtr == NULL) + { + return zERR_INVALID_STATE; + } + dsCookie = virtInfo->otherPtr; + + if (dsCookie->currentOp == DS_OP_READ_REPLY) + { + if (dsCookie->requestedOp == DS_OP_LIST_DS) + { + STATUS status = zOK; + utf8_t *description = NULL; + typedef struct Stack_s { + zInfo_s info; + utf8_t utf8Name[zMAX_COMPONENT_NAME * 3]; + } Stack_s; + STACK_ALLOC(); + + bzero(&aStack->info, sizeof(zInfo_s)); + VIRT_AddResultTag(virtInfo, TAG_NSSDATASTREAMREPLY, FALSE, TRUE); + + MPKNSS_LOCK(); + /* get list of data streams */ + while (TRUE) + { + ZOS_zWildRead(status, dsCookie->fileKey, zPFMT_UTF8, + zNTYPE_DATA_STREAM, NULL, 0, zGET_NAME | zGET_STD_INFO, sizeof(zInfo_s), + zINFO_VERSION_A, &aStack->info); + if (status != zOK) + { + if (status == zERR_NAME_NOT_FOUND_IN_DIRECTORY) + { /* last entry found */ + status = zOK; + break; + } + else + { + description = "Failed to enumerate data streams"; + goto listExit; + } + } + else + { + if (uni2utf((unicode_t *)((BYTE *)&aStack->info + aStack->info.nameStart), + aStack->utf8Name, sizeof(aStack->utf8Name)) == -1) + { + status = zERR_UNICODE_CONVERSION_ERROR; + description = "Failed to convert name"; + goto listExit; + } + VIRT_AddResultTag(virtInfo, TAG_DATASTREAM, FALSE, FALSE); + VIRT_AddResultCDataElement(virtInfo, TAG_NAME, aStack->utf8Name, FALSE); + VIRT_AddResultElement(virtInfo, TAG_TYPE, "dataStream", FALSE); + VIRT_AddResultTag(virtInfo, TAG_DATASTREAM, TRUE, FALSE); + } + } + + /* get list of extended attributes */ + ZOS_zWildRewind(status, dsCookie->fileKey); + while (TRUE) + { + ZOS_zWildRead(status, dsCookie->fileKey, zPFMT_UTF8, + zNTYPE_EXTENDED_ATTRIBUTE, NULL, 0, zGET_NAME | zGET_STD_INFO, sizeof(zInfo_s), + zINFO_VERSION_A, &aStack->info); + if (status != zOK) + { + if (status == zERR_NAME_NOT_FOUND_IN_DIRECTORY) + { /* last entry found */ + status = zOK; + break; + } + description = "Failed to enumerate extended attributes"; + break; + } + else + { + if (uni2utf((unicode_t *)((BYTE *)&aStack->info + aStack->info.nameStart), + aStack->utf8Name, sizeof(aStack->utf8Name)) == -1) + { + status = zERR_UNICODE_CONVERSION_ERROR; + description = "Failed to convert name"; + break; + } + VIRT_AddResultTag(virtInfo, TAG_DATASTREAM, FALSE, FALSE); + VIRT_AddResultCDataElement(virtInfo, TAG_NAME, aStack->utf8Name, FALSE); + VIRT_AddResultElement(virtInfo, TAG_TYPE, "extendedAttribute", FALSE); + VIRT_AddResultTag(virtInfo, TAG_DATASTREAM, TRUE, FALSE); + } + } +listExit: + MPKNSS_UNLOCK(); + + if (status == zOK) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, status, description); + } + VIRT_AddResultTag(virtInfo, TAG_NSSDATASTREAMREPLY, TRUE, TRUE); + + dsCookie->currentOp = dsCookie->requestedOp; + + STACK_FREE(); + return zOK; + } + else + { + int len = strlen(dsCookie->resultBuf); + + if (len < virtInfo->resultBufferSize) + { + strcpy(virtInfo->resultBuffer, dsCookie->resultBuf); + virtInfo->resultEOF += strlen(virtInfo->resultBuffer); + } + else + { + return zERR_BUFFER_TOO_SMALL; + } + dsCookie->currentOp = dsCookie->requestedOp; + return zOK; + } + } + else if (dsCookie->currentOp == DS_OP_READ_DS) + { + status = zRead(dsCookie->dsKey, zNILXID, + dsCookie->offset, virtInfo->resultBufferSize, + virtInfo->resultBuffer, &retLen); + if (status != zOK) + { + return status; + } + virtInfo->resultEOF = retLen == virtInfo->resultBufferSize ? + virtInfo->resultBufferSize : retLen; + dsCookie->offset += virtInfo->resultEOF; + return zOK; + } + else + { + return zERR_INVALID_STATE; + } +} +#endif + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) + /**************************************************************************** + * + * This function is to create management files for the access of ConsoleOne + * NSS snapins. The path is: :CONTROL\ACCESS.TXT + * + ****************************************************************************/ +STATUS MANAGE_StartupNSSManagement() +{ + BYTE path[zMAX_FULL_NAME]; + STATUS status; + STATUS tempStatus; + Key_t rootKey; + Key_t retKey; + + ASSERT_MPKNSS_LOCK(); + + ZOS_zRootKey(status, 0, &rootKey); + if (status != zOK) + { + goto errorExit; + } + + /* Set up :\manage.cmd */ + strcpy(path, AVFileMgmtDir); + strcat(path, MSGNot("manage.cmd")); + + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, path, + zFILE_REGULAR, zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT + | zFA_COPY_INHIBIT | zFA_VOLATILE, + zCREATE_OPEN_IF_THERE, 0, &retKey); + if (status != zOK) + { + goto errorClose; + } + +#if zLINUX + if ((status = MGMTS_MakeUserCommandVirtualFileWithHelp(retKey, + MSG("This file is used to manage NSS\n", 3), + MSGNot("libmanageus.so"), MSGNot("MANAGE_nssCommand"), "")) != zOK) +#else + ZOS_ModuleRegister(MANAGE_nssCommand); + if ((status = MGMTS_MakeCommandVirtualFileWithHelp(retKey, + MSG("This file is used to manage NSS\n", 3), + MSGNot("MANAGE_nssCommand"), "")) != zOK) +#endif + { + ZOS_zClose(tempStatus, retKey); + goto errorClose; + } + ZOS_zClose(status, retKey); + + /* Set up :\user.cmd */ + strcpy(path, AVFileMgmtDir); + strcat(path, MSGNot("user.cmd")); + + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, path, + zFILE_REGULAR, zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT + | zFA_COPY_INHIBIT | zFA_VOLATILE, + zCREATE_OPEN_IF_THERE, 0, &retKey); + if (status != zOK) + { + goto errorClose; + } + + if ((status = MGMTS_MakeUserCommandVirtualFileWithHelp(retKey, + MSG("This file is used to manage user operations\n", 3), + MSGNot("libmanageus.so"), MSGNot("MANAGE_userCommand"), "")) != zOK) + { + ZOS_zClose(tempStatus, retKey); + goto errorClose; + } + ZOS_zClose(status, retKey); + + /* Set up :\NDS.cmd */ + strcpy(path, AVFileMgmtDir); + strcat(path, MSGNot("NDS.cmd")); + + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, path, + zFILE_REGULAR, zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT + | zFA_COPY_INHIBIT | zFA_VOLATILE, + zCREATE_OPEN_IF_THERE, 0, &retKey); + if (status != zOK) + { + goto errorClose; + } + +#if zLINUX + if ((status = MGMTS_MakeUserCommandVirtualFileWithHelp(retKey, + MSG("This file is used to manage NDS\n", 4), + MSGNot("libmanageus.so"), MSGNot("MANAGE_ndsCommand"), "")) != zOK) +#else + if ((status = MGMTS_MakeCommandVirtualFileWithHelp(retKey, + MSG("This file is used to manage NDS\n", 4), + MSGNot("MANAGE_ndsCommand"), "")) != zOK) +#endif + { + ZOS_zClose(tempStatus, retKey); + goto errorClose; + } + ZOS_zClose(status, retKey); + + /* Set up :\files.cmd */ + strcpy(path, AVFileMgmtDir); + strcat(path, MSGNot("files.cmd")); + + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, path, + zFILE_REGULAR, zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT + | zFA_COPY_INHIBIT | zFA_VOLATILE, + zCREATE_OPEN_IF_THERE, 0, &retKey); + if (status != zOK) + { + goto errorClose; + } + + ZOS_ModuleRegister(MANAGE_fileCommand); + if ((status = MGMTS_MakeCommandVirtualFileWithHelp(retKey, + MSG("This file is used to manage files and directories\n", 5), + MSGNot("MANAGE_fileCommand"), "")) != zOK) + { + ZOS_zClose(tempStatus, retKey); + goto errorClose; + } + ZOS_zClose(status, retKey); + + +#if zLINUX + ZOS_ModuleRegister(MANAGE_linuxCommand); + /* Set up :\linux.cmd */ + strcpy(path, AVFileMgmtDir); + strcat(path, MSGNot("linux.cmd")); + + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, path, + zFILE_REGULAR, zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT + | zFA_COPY_INHIBIT | zFA_VOLATILE, + zCREATE_OPEN_IF_THERE, 0, &retKey); + if (status != zOK) + { + goto errorClose; + } + + if ((status = MGMTS_MakeCommandVirtualFileWithHelp(retKey, + MSG("This file is used to perform Linux specific functions\n", 5), + MSGNot("MANAGE_linuxCommand"), "")) != zOK) + { + ZOS_zClose(tempStatus, retKey); + goto errorClose; + } + ZOS_zClose(status, retKey); +#endif + + /* Set up :\dataStream.cmd */ + strcpy(path, AVFileMgmtDir); + strcat(path, MSGNot("dataStream.cmd")); + + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, path, + zFILE_REGULAR, zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT | zFA_HIDDEN + | zFA_COPY_INHIBIT | zFA_VOLATILE, + zCREATE_OPEN_IF_THERE, 0, &retKey); + if (status != zOK) + { + goto errorClose; + } + + if ((status = MGMTS_MakeFunctionVirtualFileWithHelp(retKey, + MSG("This file is used to read and write data streams and extended attributes\n", 6), + MSGNot("MANAGE_ReadDataStream"), "", + MSGNot("MANAGE_WriteDataStream"), "", TRUE)) != zOK) + { + ZOS_zClose(tempStatus, retKey); + goto errorClose; + } + ZOS_zClose(status, retKey); + + status = zOK; + +errorClose: + ZOS_zClose(tempStatus, rootKey); + +errorExit: + return status; +} + + +/**************************************************************************** + * + * This function is to cleanup management files for the access of ConsoleOne + * NSS snapins. The path is: :CONTROL\ACCESS.TXT + * + ****************************************************************************/ +void MANAGE_ShutdownNSSManagement() +{ + BYTE path[zMAX_FULL_NAME]; + STATUS status; + Key_t rootKey; + GeneralMsg_s genMsg; + + ASSERT_MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + +#ifndef __linux__ + ZOS_ModuleUnregister(MANAGE_nssCommand); +#endif +#if zLINUX + ZOS_ModuleUnregister(MANAGE_linuxCommand); +#endif + + /* + * Remove the directory for management files + */ + + ZOS_zRootKey(status, 0, &rootKey); + if (status != zOK) + { + goto errorExit; + } + + /* Clean up :\manage.cmd */ + strcpy(path, AVFileMgmtDir); + strcat(path, MSGNot("manage.cmd")); + + ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, path, + zMATCH_ALL, zDELETE_FORCE_DELETE); + zASSERT(status == zOK); + + /* Clean up :\NDS.cmd */ + strcpy(path, AVFileMgmtDir); + strcat(path, MSGNot("NDS.cmd")); + + ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, path, + zMATCH_ALL, zDELETE_FORCE_DELETE); + zASSERT(status == zOK); + + ZOS_zClose(status, rootKey); + zASSERT(status == zOK); + +errorExit: + return; +} + +Latch_s MNSS_MasterFreezeLatch; /* Latch used to keep Ftreeze/thaw master + * link from changing on us. + */ + +#if zLINUX +/**************************************************************************** +* +* Assign trustees from the trustees.xml file +* +*****************************************************************************/ +void parseTrusteeFile(void) +{ +#if NSS_DEBUG IS_ENABLED + STATIC NINT fsmInstance = 0; +#endif + FsmLite_s *fsm; + + /* + * Parse the trustees.xml file (must be done after LSA is running) + */ + fsm = malloc(sizeof(FsmLite_s)); + if (fsm != NULL) + { + FSMLITE_INIT(fsm, "FSM for setting special trustees", ++fsmInstance); + WORK_Schedule(fsm, NSS_AddSpecialTrusteesThread, 0); + } + else + { + printk(KERN_WARNING MSG("Unable to set special trustees because of low memory\n", 0)); + } +} +#endif + +/**************************************************************************** +* +* Startup NSS management using XML +* +*****************************************************************************/ +STATUS MANAGE_Startup() +{ + ASSERT_MPKNSS_LOCK(); + + INIT_LATCH( &MNSS_MasterFreezeLatch ); + /* start up NSS management files */ + if (MANAGE_StartupNSSManagement() != zOK) + { + goto errorExit; + } + +#if zLINUX + parseTrusteeFile(); +#endif + + return zOK; + +errorExit: + return zFAILURE; +} +/**************************************************************************** +* +* Shutdown NSS management using XML +* +*****************************************************************************/ +void MANAGE_Shutdown() +{ +#ifndef __linux__ + FreezeThawEntry_s *fte; +#endif + + ASSERT_MPKNSS_LOCK(); + MANAGE_ShutdownNSSManagement(); + + /* Tell all XML Freeze items/threads that we are unloading. No new + * ones can start because the management files have been + * removed from the _ADMIN volume. + */ +#ifndef __linux__ + X_LATCH( &MNSS_MasterFreezeLatch ); + + + DQ_FOREACH( &MNSS_MasterFreezeList, fte, FreezeThawEntry_s, FTE_LinkAll ) + { + fte->FTE_Unload = TRUE; + } + UNX_LATCH( &MNSS_MasterFreezeLatch ); + + /* Now wait for all the threads to stop */ + while ( DQ_NOT_EMPTY( &MNSS_MasterFreezeList ) ) + { + LB_delay( 250 ); + } +#endif + /* A little extra time from release of resource to offical termination */ + LB_delay( 333 ); + return; + +} +#endif + diff --git a/src/nwnss/sharedsrc/manageDevice.c.h b/src/nwnss/sharedsrc/manageDevice.c.h new file mode 100644 index 0000000..15f4b26 --- /dev/null +++ b/src/nwnss/sharedsrc/manageDevice.c.h @@ -0,0 +1,6138 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2005 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: bbhanuprakash $ + | $Date: 2008-09-09 15:37:52 +0530 (Tue, 09 Sep 2008) $ + | + | $RCSfile$ + | $Revision: 2468 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage NSS using XML + | + +-------------------------------------------------------------------------*/ +#if zNETWARE +#include +#endif + +#include +#include +#include +#include + +#if zNETWARE +#include +#include +#include +#include +#include "manageStartup.h" +#endif + +#if zLINUX && !defined(__KERNEL__) +#include +#define stricmp(p1,p2) strcasecmp(p1,p2) +#include +#include +#include +extern void syslog (int __pri, __const char *__fmt, ...) + __attribute__ ((__format__(__printf__, 2, 3))); +#include +#include +#include +#include "manageEVMS.h" +#endif + +#include "volume.h" +#include "managePool.h" +#include "nssPubs.h" +#include +#include "manage.h" +#include "manageNlm.h" +#include "comnPublics.h" +#include "comnAuthorize.h" +#include "manageNDS.h" +#include "virtualIO.h" +#include "xmlTags.h" + +#if !defined(__KERNEL__) + + +STATUS EVMS_DEV_GetDeviceInfo(VirtInfo_s *virtInfo, utf8_t *devID); +STATUS Linux_getPartitionsOnDevice(VirtInfo_s *virtInfo, utf8_t *devID); +STATUS Linux_getPoolsOnDevice(utf8_t *tagName, VirtInfo_s *virtInfo, utf8_t *devID); +STATUS Linux_initializeDevice(utf8_t *tagName, VirtInfo_s *virtInfo, utf8_t *devID); +STATUS Linux_modifyDevice(utf8_t *tagName, VirtInfo_s *virtInfo, utf8_t *devID, BOOL shared); +#endif + +STATUS MNSS_ProcessModifyDevice(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessInitializeDevice(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessListDevices(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessScanDevices(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetDeviceInfo(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetDeviceInfoSimple(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessListDevicePools(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessListDevicePartitions(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ + +SiblingElements_s DeviceElements[] = +{ + {TAG_MODIFYDEVICE, MNSS_ProcessModifyDevice}, + {TAG_LISTDEVICES, MNSS_ProcessListDevices}, + {TAG_INITIALIZEDEVICE, MNSS_ProcessInitializeDevice}, + {TAG_SCANDEVICES, MNSS_ProcessScanDevices}, + {TAG_GETDEVICEINFO, MNSS_ProcessGetDeviceInfo}, + {TAG_GETDEVICEINFOSIMPLE, MNSS_ProcessGetDeviceInfoSimple}, + {TAG_LISTDEVICEPOOLS, MNSS_ProcessListDevicePools}, + {TAG_LISTDEVICEPARTITIONS, MNSS_ProcessListDevicePartitions}, + {0} +}; + +#if !defined(__KERNEL__) +static u_int8_t BootStart[] = +{ + 0xFA, 0xEB, 0x74, 0x43, 0x6F, 0x70, 0x79, 0x72, + 0x69, 0x67, 0x68, 0x74, 0x20, 0x28, 0x63, 0x29, + 0x20, 0x31, 0x39, 0x38, 0x36, 0x20, 0x2D, 0x20, + 0x4E, 0x6F, 0x76, 0x65, 0x6C, 0x6C, 0x2C, 0x20, + 0x49, 0x6E, 0x63, 0x2E, 0x00, 0x1A, 0x18, 0x49, + 0x6E, 0x76, 0x61, 0x6C, 0x69, 0x64, 0x20, 0x70, + 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6F, 0x6E, + 0x20, 0x74, 0x61, 0x62, 0x6C, 0x65, 0x00, 0x4D, + 0x69, 0x73, 0x73, 0x69, 0x6E, 0x67, 0x20, 0x6F, + 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6E, 0x67, + 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x00, + 0x45, 0x72, 0x72, 0x6F, 0x72, 0x20, 0x6C, 0x6F, + 0x61, 0x64, 0x69, 0x6E, 0x67, 0x20, 0x6F, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6E, 0x67, 0x20, + 0x73, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x00, 0x33, + 0xC0, 0x8E, 0xC0, 0x8E, 0xD8, 0x8E, 0xD0, 0xBC, + 0x00, 0x7C, 0xFB, 0xBE, 0x00, 0x7C, 0xBF, 0x00, + 0x06, 0xB9, 0x00, 0x02, 0xFC, 0xF3, 0xA4, 0xEA, + 0x94, 0x06, 0x00, 0x00, 0xB9, 0x04, 0x00, 0xBE, + 0xBE, 0x07, 0x80, 0x3C, 0x80, 0x74, 0x16, 0x83, + 0xC6, 0x10, 0xE2, 0xF6, 0xBE, 0x27, 0x06, 0xAC, + 0x0A, 0xC0, 0x74, 0x06, 0xB4, 0x0E, 0xCD, 0x10, + 0xEB, 0xF5, 0xFB, 0xEB, 0xFE, 0x8B, 0xFE, 0x49, + 0x74, 0x0D, 0x83, 0xC6, 0x10, 0x80, 0x3C, 0x80, + 0x75, 0xF5, 0xBE, 0x27, 0x06, 0xEB, 0xE0, 0xBE, + 0x05, 0x00, 0x8B, 0x15, 0x8B, 0x4D, 0x02, 0xBB, + 0x00, 0x7C, 0xB8, 0x01, 0x02, 0xCD, 0x13, 0x73, + 0x0C, 0x33, 0xC0, 0xCD, 0x13, 0x4E, 0x75, 0xEF, + 0xBE, 0x58, 0x06, 0xEB, 0xC2, 0x59, 0x81, 0x3E, + 0xFE, 0x7D, 0x55, 0xAA, 0x74, 0x05, 0xBE, 0x3F, + 0x06, 0xEB, 0xB4, 0x8B, 0xF7, 0xEA, 0x00, 0x7C, + 0x00, 0x00 +}; +#endif + +/**************************************************************************** + * + * This function lists the devices on a server. + * + ****************************************************************************/ +STATUS MNSS_ProcessListDevices( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + utf8_t tempBuf[512] = ""; +#if !defined(__KERNEL__) + EvmsObjectArray_s *deviceObjects = NULL; + handle_object_info_t *object_info = NULL; + storage_object_info_t *info; + EvmsExtendInfo_s evmsExtInfo; + BOOL infoFound = FALSE; + NINT i; + NINT len; + int ccode; + NINT flags; + extended_info_array_t *extended_info = NULL; +#endif + + ASSERT_MPKNSS_LOCK(); + + if ((ccode = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return zOK; + } + + /* Find all devices */ +#if !defined(__KERNEL__) + +// syslog(LOG_INFO, "In MNSS_ProcessListDevices\n"); + + ASSERT_MPKNSS_LOCK(); + +// ZOS_evms_open_engine(ccode, NULL, EVMS_ENGINE_READONLY, NULL, -1, NULL); + ccode = evmsOpenEngine(EVMS_ENGINE_READONLY); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error opening EVMS engine. It might be " + "opened by another application")); + goto exit; + } + + ccode = evmsGetDevices(DEVICE_ALL, &deviceObjects); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting devices: %s"), evmsGetErrString(ccode)); + MNSS_BuildResult(virtInfo, ccode, tempBuf); + goto exit; + } + + if (deviceObjects == NULL) + { + /* It could happen, although we should find at least one hard disk */ + goto exit; + } + +// syslog(LOG_INFO, "deviceObjects count: %d\n", deviceObjects->count); + for (i = 0; i < deviceObjects->count; i++) + { +// syslog(LOG_INFO, "object handle: %d\n", deviceObjects->object[i].handle); +// syslog(LOG_INFO, "object type: %d\n", deviceObjects->object[i].deviceType); + ZOS_evms_get_info(ccode, deviceObjects->object[i].handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device generic info: %s"), evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, ccode, tempBuf); + goto free_object; + } + + info = &object_info->info.disk; + + flags = 0; + ccode = evmsGetExtendedInfo2(info->handle, (BYTE *)MSGNot("Flags"), + &infoFound, FALSE, &extended_info, &evmsExtInfo); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device flags info: %s"), evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, ccode, tempBuf); + goto free_object; + } + if (infoFound) + { + flags = evmsExtInfo.value.ui32; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_DEVICEINFO, + FALSE, TRUE)) != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, ccode, + MSGNot("Error adding opening deviceInfo tag")); + goto free_object; + } + +// syslog(LOG_INFO, "cylinders: %u\n", info.geometry.cylinders); +// syslog(LOG_INFO, "heads: %u\n", info.geometry.heads); +// syslog(LOG_INFO, "boot cylinder limit: %u\n", info.geometry.boot_cylinder_limit); +// syslog(LOG_INFO, "block size: %u\n", info.geometry.block_size); +// syslog(LOG_INFO, "alignment: %u\n", info.geometry.sectors_per_track * info.geometry.heads); + + sprintf(tempBuf, + "<"TAG_DEVICENAME">%s" + "<"TAG_DEVICEID">%s" + "<"TAG_DEVICETYPE">%u" + "<"TAG_UNITSIZE">%u" + "<"TAG_SECTORS">%u" + "<"TAG_CAPACITY">%Lu", + info->name, + info->name, + 0, /* evms only list hard disks, i.e., MM_DIRECT_ACCESS_DEVICE */ + EVMS_VSECTOR_SIZE, + info->geometry.sectors_per_track, + info->size); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, ccode, + MSGNot("Error adding disk info")); + goto free_object; + } + + sprintf(tempBuf, + "<"TAG_ALIGNMENT">%u", + info->geometry.sectors_per_track * info->geometry.heads); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, ccode, + MSGNot("Error adding disk info")); + goto free_object; + } + +// if (info->flags & SOFLAG_CLUSTER_SHARED) + if (flags & STATUS_SHARED) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_DEVICESHARED, "", FALSE)) != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, ccode, + MSGNot("Error adding disk shared info")); + goto free_object; + } + } + +// evmsPrintExtendedInfo(info.handle); + + // check for the object type here + if (deviceObjects->object[i].deviceType == DEVICE_RAID) + { + // it is a raid device + ccode = evmsGetExtendedInfo2(info->handle, (BYTE *)MSGNot("Raid Type"), &infoFound, + FALSE, &extended_info, &evmsExtInfo); + if (ccode != 0 || !infoFound) + { + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, -1, MSGNot("Error getting raid type")); + goto free_object; + } + sprintf(tempBuf, "<"TAG_RAIDTYPE">%u", evmsExtInfo.value.ui32); + len = strlen(tempBuf); + + ccode = evmsGetExtendedInfo2(info->handle, (BYTE *)MSGNot("Element Size"), &infoFound, + FALSE, &extended_info, &evmsExtInfo); + + if (ccode != 0 || !infoFound) + { + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, -1, MSGNot("Error getting element size")); + goto free_object; + } + sprintf(&tempBuf[len], "<"TAG_ELEMENTSIZE">%Lu", + (QUAD)(evmsExtInfo.value.ui32 * EVMS_VSECTOR_SIZE)); + len = strlen(tempBuf); + + ccode = evmsGetExtendedInfo2(info->handle, (BYTE *)MSGNot("Stripe Size"), &infoFound, + FALSE, &extended_info, &evmsExtInfo); + + if (ccode != 0 || !infoFound) + { + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, -1, MSGNot("Error getting stripe size")); + goto free_object; + } + sprintf(&tempBuf[len], "<"TAG_STRIPESIZE">%u", + evmsExtInfo.value.ui32 * 1024); + len = strlen(tempBuf); + +// ccode = evmsGetExtendedInfo(info->handle, MSGNot("Restripe Flag"), &infoFound, &evmsExtInfo); +// if (ccode != 0 || !infoFound) +// { +// MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, -1, MSGNot("Error getting restripe flag")); +// goto free_object; +// } + if (flags & STATUS_RESTRIPE) + { + sprintf(&tempBuf[len], "<"TAG_RESTRIPEFLAG">1"); + } + else + { + sprintf(&tempBuf[len], "<"TAG_RESTRIPEFLAG">0"); + } + + len = strlen(tempBuf); + + if ((ccode = VIRT_AddResultElement(virtInfo, TAG_DEVICERAID, tempBuf, FALSE)) != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, ccode, tempBuf); + goto free_object; + } + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_DEVICEINFO, + TRUE, TRUE)) != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, ccode, + MSGNot("Error adding ending deviceInfo tag")); + goto free_object; + } + + ZOS_evms_free(extended_info); + extended_info = NULL; + + ZOS_evms_free(object_info); + object_info = NULL; + } + +free_object: + if (extended_info != NULL) + { + ZOS_evms_free(extended_info); + } + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + if (deviceObjects != NULL) + { + free(deviceObjects); + } + + evmsCloseEngine(); + if (ccode ==0) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error getting device list")); + } +exit: + +#endif + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +// syslog(LOG_INFO, "MNSS_ProcessListDevices exit\n"); + return zOK; +} + +/**************************************************************************** + * + * This function implements a dynamic binding to a NCS function + * + ****************************************************************************/ +CLSTR_ERRORS NWCLSTR_IsClusterEnabled(BYTE *poolVolName, POOL_WORK type, unicode_t *poolFDN, UINT32 len) +{ +#define NWCLSTR_IsClusterEnabledAPI MSGNot("\x18NWCLSTR_IsClusterEnabled") +#define NWCLSTR_IsClusterEnabledAPI_LNX "NWCLSTR_IsClusterEnabled" +#if zLINUX + void *libHandle; +#endif + CLSTR_ERRORS status; + CLSTR_ERRORS (*NWCLSTR_IsClusterEnabled_PTR)(BYTE *poolVolName, POOL_WORK type, unicode_t *poolFDN, UINT32 len) = NULL; + + MPKNSS_UNLOCK(); +#if zNETWARE + NWCLSTR_IsClusterEnabled_PTR = (void *)ImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)NWCLSTR_IsClusterEnabledAPI); +#endif +#if zLINUX + libHandle = dlopen(NWCLSTR_LIBNAME, RTLD_LAZY); + if (libHandle) + { + NWCLSTR_IsClusterEnabled_PTR = dlsym(libHandle, NWCLSTR_IsClusterEnabledAPI_LNX); + } +#endif + if (NWCLSTR_IsClusterEnabled_PTR != NULL) + { + status = NWCLSTR_IsClusterEnabled_PTR(poolVolName, type, poolFDN, len); +#if zNETWARE + UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)NWCLSTR_IsClusterEnabledAPI); +#endif + } + else + { + /* Couldn't import the NCS symbol */ + status = zERR_NCS_SYMBOL_IMPORT_ERROR; + } +#if zLINUX + if (libHandle) + { + dlclose(libHandle); + } +#endif + MPKNSS_LOCK(); + + return status; +} + +/**************************************************************************** + * + * This function modifies a devices on a server. + * + ****************************************************************************/ +STATUS MNSS_ProcessModifyDevice( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_DEVICEID, TR_CONTENT_REQUIRED}, + {TAG_SHARED, 0}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + DEVICE_ID = 0, + SHARED = 1 + }; + + STATUS status; + XML_ElementInfo_s *parmElement; + BOOL shared; +#if zNETWARE + STATUS stat2; + LONG retVal; + LONG *partitions = NULL; + LONG pCount = 0; + LONG pNum; + NINT devID; + NINT savedPoolState; + BOOL clusterPool; + BOOL wasShared; + UserID_t guid; + utf8_t *errorString; + utf8_t *retContainer = NULL; + utf8_t *retName = NULL; + utf8_t *ndsName = NULL; + utf8_t *srvName = NULL; + utf8_t *srvContainer = NULL; + utf8_t *container = NULL; + unicode_t *uni_poolName = NULL; + unsigned char *poolName = NULL; + zInfo_s poolInfo; + GeneralMsg_s genMsg; + ModifyInfoMsg_s modInfoMsg; + VolumeID_t poolID; + Pool_s *pool; + struct IOObjectGenericInfoDef genInfo; +#endif + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit1; + } + return status; + } + + parmElement = &tagContent[SHARED].element; + if (XML_GetTagAttribute(ATR_STATE, parmElement) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("The \""TAG_SHARED"\" tag is missing attribute \""ATR_STATE"\"")); + status = zERR_XML_IS_BAD; + goto exit1; + } + else + { + if (parmElement->attributeValueLen == 3 && + memcmp(parmElement->attributeValueStart, MSGNot("yes"), 3) == 0) + { + shared = TRUE; + } + else if (parmElement->attributeValueLen == 2 && + memcmp(parmElement->attributeValueStart, MSGNot("no"), 2) == 0) + { + shared = FALSE; + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("attribute \""ATR_STATE"\" needs a yes/no value")); + status = zERR_XML_IS_BAD; + goto exit1; + } + } + +#if zNETWARE + /* Allocate memory for all the names we will need */ + ndsName = malloc(zMAX_COMPONENT_NAME); + srvName = malloc(zMAX_COMPONENT_NAME); + srvContainer = malloc(zMAX_COMPONENT_NAME); + container = malloc(zMAX_COMPONENT_NAME); + uni_poolName = malloc(zMAX_COMPONENT_NAME * sizeof(unicode_t)); + poolName = malloc(zMAX_COMPONENT_NAME); + + /* If any of the allocations failed we cannot continue */ + if ((ndsName == NULL) || (srvName == NULL) || (srvContainer == NULL) + || (container == NULL) || (uni_poolName == NULL) || (poolName == NULL)) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_MEMORY, + MSGNot("Failed to allocate memory for modify device pool operations")); + status = zERR_NO_MEMORY; + goto exit; + } + + /* Get the generic info on the device */ + devID = atol(tagContent[DEVICE_ID].content); + ZMM_ReturnObjectGenericInfo(retVal, devID, + sizeof(struct IOObjectGenericInfoDef), &genInfo); + if (retVal != MM_OK) + { + zASSERT("MM_ReturnObjectGenericInfo on device failed"==NULL); + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Error getting device generic info")); + goto exit; + } + + /* Get the server name for later use in forming pool names */ + if (stat2 = MNDS_GetServerNameFromNDS(srvName, srvContainer) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error Getting Server Name from NDS")); + goto exit; + } + + /* Check if any excluded cases are being attempted during a share state change */ + wasShared = (genInfo.status & MM_IOOBJECT_SHARED) ? TRUE : FALSE; + if (wasShared != shared) + { + /* Enumerate the partitions on the device */ + pCount = getNSSPartitionsOnDevice(devID, &partitions); + if (pCount > 0) + { + /* Get the pool for each partition */ + for (pNum = 0; pNum < pCount; pNum++) + { + getPoolNameFromPartitionID(partitions[pNum], poolName); + + /* No pool */ + if (poolName[0] == 0) + continue; + + /* Test if this is a cluster pool */ + clusterPool = (NWCLSTR_IsClusterEnabled(poolName, POOL_INQUIRY, NULL, 0) == CLSTR_RESOURCE_FOUND); +#if 0 + status = NWCLSTR_PoolNames(poolName, + ndsName, container, cifsVirtualServerName); +#endif + /* If the pool is cluster enabled */ + if (clusterPool) + { + /* Fail the whole operation because we don't want to share enable + a pool when a cluster pool object already exists with the same + name and we don't want to disable sharing when a pool is + cluster enabled on the device. */ + MNSS_ReturnResult(virtInfo, tagName, zERR_NWCS_SHARE_VIOLATION, + MSGNot("Cluster sharing violation")); + goto exit; + } + } + } + } + + ZMM_ObjectControl(retVal, + genInfo.objectmanagerid, + MM_CHANGE_SHARED_STATUS, + devID, + shared ? 1 : 0, + 0, 0, 0); + if (retVal != MM_OK) + { + zASSERT("MM_ObjectControl changing device share state failed"==NULL); + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Error setting device shared state")); + goto exit; + } + + /* If the share state for a device has been changed we need to do some other updates */ + if (wasShared != shared) + { + if (pCount > 0) + { + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + /* Get the pool for each partition */ + for (pNum = 0; pNum < pCount; pNum++) + { + getPoolNameFromPartitionID(partitions[pNum], poolName); + + /* No pool */ + if (poolName[0] == 0) + continue; + + /* Get the pool */ + pool = NULL; + if (LB_ByteToUnicode(NSS_UNI_CONVERSION_RAW, uni_poolName, zMAX_COMPONENT_NAME, poolName, NULL) == zOK) + { + pool = COMN_PoolNameLookup(&genMsg, uni_poolName, FALSE, &poolID); + } + if (pool == NULL) + { + status = GetErrno(&genMsg); + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error finding pool in NSS")); + goto exit; + } + + /* Get the current pool object name... */ + if ((status = MNSS_GetPoolNDSName(poolName, + ndsName, container, &guid, &errorString)) != zOK) + { + /* ...or generate the default pool name */ + strcpy(ndsName, srvName); + strcat(ndsName, "_"); + strcat(ndsName, poolName); + strcat(ndsName, "_POOL"); + strcpy(container, srvContainer); + } + + /* Delete any existing pool object */ + stat2 = MNDS_RemoveObjectFromNDS(container, ndsName, "nssfsPool"); + + /* Create the pool object */ + if ((status = MNDS_AddPoolToNDS(virtInfo, container, + ndsName, poolName, + &poolID, shared, &poolInfo.pool.ndsObjectID, + &retContainer, &retName, NULL)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error adding pool to NDS")); + COMN_Release(&pool); + goto exit; + } + + /* The pool must be active to modify the GUID of a shared pool */ + savedPoolState = pool->POOLstate; + if (savedPoolState != zVOLSTATE_ACTIVE) + { + if ((status = COMN_ChangePoolState(&genMsg, pool, + zVOLSTATE_ACTIVE, VOLMODE_OVERRIDE_SHARED)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error activating pool to set NDS object's GUID")); + COMN_Release(&pool); + goto exit; + } + } + + /* Store the DS object GUID in the pool */ + COMN_STRUCT_INIT(modInfoMsg); + COMN_SETUP_MODIFY_INFO_MSG(&modInfoMsg, zMOD_POOL_NDS_OBJECT_ID, + &poolInfo, zINFO_VERSION_A); + + modInfoMsg.parentZid = pool->POOLfirstParentZid; + + X_LATCH(&pool->POOLbeastLatch); + status = pool->POOLcomnBeastOps.BST_modifyInfo(&genMsg, &pool->POOLroot, + &modInfoMsg, NULL); + UNX_LATCH(&pool->POOLbeastLatch); + + /* De-activate the pool if it was not active when we started */ + if (savedPoolState != zVOLSTATE_ACTIVE) + { + COMN_ChangePoolState(&genMsg, pool, savedPoolState, + VOLMODE_OVERRIDE_SHARED); + } + COMN_Release(&pool); + } + } + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + if (retContainer != NULL) + { + free(retContainer); + } + if (retName != NULL) + { + free(retName); + } + if (partitions != NULL) + { + free(partitions); + } + if (ndsName != NULL) + { + free(ndsName); + } + if (srvName != NULL) + { + free(srvName); + } + if (srvContainer != NULL) + { + free(srvContainer); + } + if (container != NULL) + { + free(container); + } + if (uni_poolName != NULL) + { + free(uni_poolName); + } + if (poolName != NULL) + { + free(poolName); + } +#endif +#if zLINUX && !defined(__KERNEL__) + Linux_modifyDevice(tagName, virtInfo, tagContent[DEVICE_ID].content, shared); +#endif + +exit1: + return zOK; +} + +#if zNETWARE +/**************************************************************************** + * + * This function renames a device. + * + ****************************************************************************/ +STATUS MNSS_ProcessRenameDevice( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_DEVICEID, TR_CONTENT_REQUIRED}, + {TAG_NAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + DEVICE_ID = 0, + NAME = 1 + }; + + STATUS status; + LONG ccode; + NINT deviceID; + + ASSERT_MPKNSS_LOCK(); + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + + deviceID = atol(tagContent[DEVICE_ID].content); + MPKNSS_UNLOCK(); + + ccode = MM_RenameObject(deviceID, tagContent[NAME].content); + if (ccode != MM_OK) + { + zASSERT("MM_RenameObject on device failed"==NULL); + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error renaming device")); + MPKNSS_LOCK(); + goto exit; + } + + MPKNSS_LOCK(); + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; +} +#endif + +/**************************************************************************** + * + * This function initializes a devices on a server. + * + ****************************************************************************/ +STATUS MNSS_ProcessInitializeDevice( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_DEVICEID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + DEVICE_ID = 0, + }; + + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + +#if zNETWARE + /* Initialize the device */ + + /* Check to see if the PARTAPI.NLM has been loaded. */ + if (PART_SetupToCallPARTAPI() != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Setup to call PART API failed")); + return zOK; + } + + MPKNSS_UNLOCK(); + PARTAPIInitializePartitionTablePtr(atol(tagContent[DEVICE_ID].content)); + MPKNSS_LOCK(); + + /* Unload the PARTAPI.NLM. */ + PART_CleanupCallToPARTAPI(); + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); +#endif +#if zLINUX && !defined(__KERNEL__) +// syslog(LOG_INFO, "in MNSS_ProcessInitializeDevice"); + Linux_initializeDevice(tagName, virtInfo, tagContent[DEVICE_ID].content); +#endif + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function scans for new devices on a server. + * + ****************************************************************************/ +STATUS MNSS_ProcessScanDevices( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + ASSERT_MPKNSS_LOCK(); + +#if zNETWARE +{ + LONG retVal; + + ZMM_ScanForNewDevices(); + + /* Scan all devices for all partitions */ + ZMM_ScanForNewPartitions(retVal, -1); + if (retVal != MM_OK) + { + zASSERT("MM_ScanForNewPartitions failed"==NULL); + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Error scanning for new partitions")); + goto exit; + } +} +#endif +#if zLINUX && !defined(__KERNEL__) +{ + int retVal; + + retVal = evmsOpenEngine(EVMS_ENGINE_READONLY); + if (retVal != 0) + { + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Error scanning for new devices")); + goto exit; + } + evmsCloseEngine(); +} +#endif + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + + return zOK; +} + +/**************************************************************************** + * + * MNSS_ProcessGetDeviceInfo - This function returns information about a + * specific device. + * + ****************************************************************************/ +STATUS MNSS_ProcessGetDeviceInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_OBJECTID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + enum + { + OBJECT_ID = 0, + }; + STATUS status; + +#if zLINUX && !defined(__KERNEL__) + utf8_t *objectID; +#endif + +#if zNETWARE + OBID objectID; + BOOL foundMirror; +#endif + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + goto exit; + } + +#if zLINUX && !defined(__KERNEL__) + objectID = tagContent[OBJECT_ID].content; + status = EVMS_DEV_GetDeviceInfo(virtInfo, objectID); +#endif +#if zNETWARE + objectID = atol(tagContent[OBJECT_ID].content); + + status = PART_CheckForMirror(objectID, &foundMirror); + if (status != MM_OK) + { + MNSS_BuildResult(virtInfo, status, MSGNot("Error getting device information.")); + goto exit; + } + + if (!foundMirror) + { + status = MM_DEV_GetDeviceInfo(virtInfo, tagName, objectID); + } + else + { + status = MM_DEV_GetMirrorInfo(virtInfo, objectID); + } +#endif + +exit: + + if (status == zOK) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } +#if zNETWARE + else if (status == MM_OBJECT_NOT_FOUND) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } +#endif + else if (status == zERR_XML_IS_BAD) + { + MNSS_BuildResult(virtInfo, status, MSGNot("Bad XML was passed in.")); + } + else + { + MNSS_BuildResult(virtInfo, status, MSGNot("Error getting device information.")); + } + + return zOK; +} + +/**************************************************************************** + * + * MNSS_ProcessGetDeviceInfoSimple - This function returns information about a + * specific device. + * + ****************************************************************************/ +STATUS MNSS_ProcessGetDeviceInfoSimple( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_OBJECTID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + OBJECT_ID = 0, + }; + + STATUS status; + +#if zLINUX && !defined(__KERNEL__) + utf8_t *objectID; +#endif + +#if zNETWARE + OBID objectID; + BOOL foundMirror; +#endif + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_GETDEVICEINFOSIMPLE, status, + MSGNot("Bad XML was passed in.")); + goto exit; + } + +#if zLINUX && !defined(__KERNEL__) + objectID = tagContent[OBJECT_ID].content; + status = EVMS_DEV_GetDeviceInfo(virtInfo, objectID); +#endif + +#if zNETWARE + objectID = atol(tagContent[OBJECT_ID].content); + + status = PART_CheckForMirror(objectID, &foundMirror); + if (status != MM_OK) + { + MNSS_ReturnResult(virtInfo, TAG_GETDEVICEINFOSIMPLE, status, + MSGNot("Error getting device information.")); + goto exit; + } + + + if (!foundMirror) + { + status = MM_DEV_GetDeviceInfo(virtInfo, tagName, objectID); + } + else + { + status = MM_DEV_GetMirrorInfoSimple(virtInfo, objectID); + } +#endif + +exit: + return zOK; +} + +#if zNETWARE +/**************************************************************************** + * + * This function parses and executes the multipath tags. + * + ****************************************************************************/ +STATUS MNSS_ProcessMultiPath( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + return MNSS_ProcessElements(virtInfo, TAG_MULTIPATH, element, + MultiPathElements); +} + +#endif + +/**************************************************************************** + * + * This function get the list of pools on the device + * + ****************************************************************************/ +STATUS MNSS_ProcessListDevicePools( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_OBJECTID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + OBJECT_ID = 0, + }; + + LONG ccode; + + ASSERT_MPKNSS_LOCK(); + + if ((ccode = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (ccode == zERR_XML_IS_BAD) + { + return zOK; + } + return ccode; + } + + +#if zLINUX && !defined(__KERNEL__) + return Linux_getPoolsOnDevice(tagName, virtInfo, tagContent[OBJECT_ID].content); +#endif + +#if zNETWARE + MNSS_LoadAppIDs(); + return NW_getPoolsOnDevice(tagName, virtInfo, atol(tagContent[OBJECT_ID].content)); +#endif +} + + +/**************************************************************************** + * + * This function get the list of partitions on the device + * + ****************************************************************************/ +STATUS MNSS_ProcessListDevicePartitions( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_DEVICEID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + DEVICE_ID = 0, + }; + + LONG ccode; + + + ASSERT_MPKNSS_LOCK(); + + if ((ccode = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (ccode == zERR_XML_IS_BAD) + { + return zOK; + } + return ccode; + } + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + +#if zNETWARE + MNSS_LoadAppIDs(); + + ccode = NW_getPartitionsOnDevice(virtInfo, atol(tagContent[DEVICE_ID].content)); +#endif +#if zLINUX && !defined(__KERNEL__) + ccode = Linux_getPartitionsOnDevice(virtInfo, tagContent[DEVICE_ID].content); +#endif + + if(ccode == zOK) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error getting device partitions")); + } + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} + +#if 0 +/**************************************************************************** + * + * This function get the list of pools on the device + * + ****************************************************************************/ +STATUS MNSS_ProcessListDevicePools( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_OBJECTID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + OBJECTID = 0, + }; + + NINT objID; + GeneralMsg_s genMsg; + Pool_s *pool; + struct VolumeMappingInfo *volMapping = NULL; + NINT i, numElements = 1; + LONG ccode = zOK; + OBID deviceID; + utf8_t poolName[zMAX_COMPONENT_NAME]; + utf8_t xmlBuffer[zMAX_COMPONENT_NAME]; + unicode_t poolNameInUnicode[zMAX_COMPONENT_NAME]; + struct IOObjectGenericInfoDef objectGen; + struct IOObjectGenericInfoDef partGen; + struct LogicalPartitionMappingInfo *mappingInfo = NULL; + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + + if ((ccode = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (ccode == zERR_XML_IS_BAD) + { + return zOK; + } + return ccode; + } + + objID = atol(tagContent[OBJECTID].content); + + ZMM_ReturnObjectGenericInfo(ccode, objID, sizeof(struct IOObjectGenericInfoDef), &objectGen); + if(ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error getting device generic info")); + return zOK; + } + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + // This is an mirrored partition + if(objectGen.type == MM_MIRROR_OBJECT) + { + // See if this partition contains a pool. + if ((ccode = PART_GetPartitionSegmentInfo(NETWARE_NSS_PARTITION, objID, &mappingInfo)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error getting partition mapping info")); + goto mirrorError; + } + + if ((mappingInfo->element[0].volumeName != NULL) && + (mappingInfo->element[0].volumeName[0] != 0)) + { + if ((ccode = LB_ByteToUnicode(NSS_UNI_CONVERSION_RAW, + poolNameInUnicode, NELEMS(poolNameInUnicode), + mappingInfo->element[0].volumeName, NULL)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error converting pool name to unicode")); + goto mirrorError; + } + + pool = COMN_PoolNameLookup(&genMsg, poolNameInUnicode, FALSE, NULL); + if (pool == NULL) + { + ccode = GetErrno(&genMsg); + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error finding pool in NSS")); + goto mirrorError; + } + if(pool->p.PP_enabledFeatures & zPOOL_FEATURE_SHARED_CLUSTER) + { + sprintf(xmlBuffer, "<"TAG_POOLSIMPLEINFO"><" + TAG_POOLNAME">%s<" + TAG_POOLSTATE">%u<" + TAG_SHARED"/>", + mappingInfo->element[0].volumeName, pool->state); + } + else + { + sprintf(xmlBuffer, "<"TAG_POOLSIMPLEINFO"><" + TAG_POOLNAME">%s<" + TAG_POOLSTATE">%u", + mappingInfo->element[0].volumeName, pool->state); + } + if ((ccode = VIRT_AddResultData(virtInfo, xmlBuffer)) != zOK) + { + goto mirrorError; + } + if (mappingInfo) + { + free(mappingInfo); + mappingInfo = NULL; + } + } + } + else if(objectGen.type == MM_DEVICE_OBJECT || objectGen.type == MM_VIRTUAL_DEVICE_OBJECT) + { + SET_FOREACHBLOCKING(&NSSMasterPoolList, pool, Pool_s, masterPoolLink) + { /*** You MUST NOT use continue in this loop because the macro + *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called + *** every time through the loop. Technically, you + *** can use a continue BEFORE any blocking calls. + ***/ + + COMN_USE_BEAST( &pool->POOLroot ); + X_LATCH( &pool->cvsLatch ); + + (void)COMN_GetPoolName(&genMsg, pool, poolNameInUnicode, NELEMS(poolNameInUnicode)); + ClearErrno( &genMsg ); + + /* + * Upper case the name. It is done before the unicode conversion because + * we use both the unicode and utf8 versions. + */ + // Convert the pool name from unicode to byte + if ((ccode = LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, poolName, + sizeof(poolName), poolNameInUnicode, NULL)) != zOK) + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error converting from unicode")); + goto exit; + } + + for (i = 0; poolName[i] != '\0'; i++) + { + poolName[i] = toupper(poolName[i]); + } + + do + { + // If the buffer is too small, free it, and reallocate it + if(volMapping != NULL && ccode == MM_BUFFER_TOO_SMALL) + { + numElements = volMapping->numberOfElements; + free(volMapping); + volMapping = NULL; + } + + // If the buffer is empty, allocate it + if(volMapping == NULL) + { + volMapping = (struct VolumeMappingInfo *)malloc( + sizeof(struct VolumeMappingInfo) + + ((numElements-1) * sizeof(struct VolumeMappingElementDef))); + if (volMapping == NULL) + { + ccode = zERR_NO_MEMORY; + goto exit; + } + } + // Get the partitions for the pool + volMapping->volumeName = poolName; + ZMM_ObjectControl(ccode, + NSSAPPid, + MM_POOL_RETURN_MAPPING, + 0, 0, 0, + numElements, + volMapping); + + if (ccode != MM_OK && ccode != MM_BUFFER_TOO_SMALL) + { + goto exit; + } + }while(ccode == MM_BUFFER_TOO_SMALL); + + // Convert the pool name from Unicode to UTF8 + if (uni2utf(poolNameInUnicode, poolName, sizeof(poolName) == -1) + { + MNSS_BuildResult(virtInfo, zERR_UNICODE_CONVERSION_ERROR, + MSGNot("Error converting from unicode")); + goto exit; + } + + for(i = 0; i < volMapping->numberOfElements; i++) + { + ZMM_ReturnObjectGenericInfo(ccode, volMapping->element[i].logicalPartition, + sizeof(struct IOObjectGenericInfoDef), &partGen); + + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error getting generic info for a partition from media manager")); + goto exit; + } + + // This is a mirrored partition, just ignore it + if(partGen.type != MM_MIRROR_OBJECT) + { + // Find the device that each partition belongs to + ZMM_ReturnObjectProgenitor(ccode, volMapping->element[i].logicalPartition, MM_DEVICE_OBJECT, &deviceID); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_SUCH_OBJECT, + MSGNot("Bad partition ID")); + zASSERT("MM_ReturnObjectGenericInfo failed"==NULL); + goto exit; + } + // If this partition is on the device that we are interested in, add the pool the xml reply + if(deviceID == objID) + { + if ((ccode = VIRT_AddResultData(virtInfo, + "<"TAG_POOLSIMPLEINFO"><"TAG_POOLNAME">")) != zOK) + { + goto exit; + } + break; + + if ((ccode = VIRT_AddResultData(virtInfo, poolName)) + != zOK) + { + goto exit; + } + break; + + // Check if this pool is on shared devices + if(pool->p.PP_enabledFeatures & zPOOL_FEATURE_SHARED_CLUSTER) + { + sprintf(xmlBuffer, "<" + TAG_POOLSTATE">%u<" + TAG_SHARED"/>", + pool->state); + } + else + { + sprintf(xmlBuffer, "<" + TAG_POOLSTATE">%u", + pool->state); + } + + if ((ccode = VIRT_AddResultData(virtInfo, xmlBuffer)) != zOK) + { + goto exit; + } + break; + } + } + } + UNX_LATCH( &pool->cvsLatch ); + COMN_Release( &pool ); + SET_FOREACHBLOCKINGEND(&NSSMasterPoolList, pool, Pool_s, masterPoolLink) + } + } + else + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Invalid object")); + return zOK; + } + MNSS_BuildResult(virtInfo, ccode, XML_SUCCESS); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + if(volMapping != NULL) + free(volMapping); + return ccode; + +mirrorError: + if (pool) + { + COMN_Release(&pool); + } + + if (mappingInfo) + { + free(mappingInfo); + mappingInfo = NULL; + } + return zOK; +exit: + UNX_LATCH( &pool->cvsLatch ); + COMN_Release( &pool ); + if(volMapping != NULL) + free(volMapping); + return ccode; +} +#endif + + +#if zNETWARE +/**************************************************************************** + * + * This function get the device and path info. + * + ****************************************************************************/ +STATUS MNSS_ProcessMultiPathInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + enum + { + BUF_SIZE = 16 * sizeof(struct PathInfoDef) + 24 + }; + struct IOObjectGenericInfoDef devGen; + struct FailoverDeviceInfoDef *deviceInfo; + OBID devid = -1; + LONG ccode; + NINT i; + + BYTE *tempBuf; + BYTE *buffer; + + MNSS_LoadAppIDs(); + + tempBuf = malloc(1024); + if (tempBuf == NULL) + { + MNSS_ReturnResult(virtInfo, TAG_MULTIPATHINFO, zERR_NO_MEMORY, + MSGNot("Error getting temporary buffer")); + return zOK; + } + + buffer = malloc(BUF_SIZE); + if (buffer == NULL) + { + MNSS_ReturnResult(virtInfo, TAG_MULTIPATHINFO, zERR_NO_MEMORY, + MSGNot("Error getting info buffer")); + free(tempBuf); + return zOK; + } + + do + { + MPKNSS_UNLOCK(); + ccode = MM_FindObjectType(MM_IO_CLASS, MM_DEVICE_OBJECT, &devid); + if (ccode != MM_OK) + { + MPKNSS_LOCK(); + break; + } + + ccode = MM_ReturnObjectGenericInfo(devid, sizeof(devGen), &devGen); + if (ccode != MM_OK) + { + MPKNSS_LOCK(); + MNSS_ReturnResult(virtInfo, TAG_MULTIPATHINFO, ccode, + MSGNot("Error getting device generic info")); + continue; /* go to the next device */ + } + + if (!(devGen.status & MM_IOOBJECT_INFO_COMPLETE) || + !(devGen.status & MM_OBJECT_FUNCTIONAL) || + devGen.objectmanagerid != FailoverMgrID) + { + MPKNSS_LOCK(); + continue; /* go to the next device */ + } + + ccode = MM_ObjectControl(FailoverMgrID, MM_RETURN_FAILOVER_INFO, + devid, 0, 0, BUF_SIZE, buffer); + if (ccode != MM_OK) + { + MPKNSS_LOCK(); + if (ccode == MM_BUFFER_TOO_SMALL) + { + BYTE *hold; + NINT bufSize; + + bufSize = ((struct FailoverDeviceInfoDef *)buffer)->numberOfPaths + * sizeof(struct PathInfoDef) + 24; + hold = buffer; + buffer = realloc(buffer, bufSize); + if (buffer == NULL) + { + MNSS_ReturnResult(virtInfo, TAG_MULTIPATHINFO, + zERR_NO_MEMORY, + MSGNot("Error getting info buffer")); + free(hold); + free(tempBuf); + return zOK; + } + ccode = MM_ObjectControl(FailoverMgrID, MM_RETURN_FAILOVER_INFO, + devid, 0, 0, bufSize, buffer); + + } + if (ccode != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_MULTIPATHINFO, ccode, + MSGNot("Error getting failover info")); + ccode = MM_OK; + continue; /* go to the next device */ + } + MPKNSS_UNLOCK(); + } + + MPKNSS_LOCK(); + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_MULTIPATHINFO, + FALSE, TRUE)) != zOK) + { + break; + } + + sprintf(tempBuf, + "<"TAG_DEVICENAME">%s" + "<"TAG_DEVICEID">%u\n", + devGen.name, + devid); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + break; + } + + deviceInfo = (struct FailoverDeviceInfoDef *)buffer; + for (i = 0; i < deviceInfo->numberOfPaths; i++) + { + ZMM_ReturnObjectGenericInfo(ccode, deviceInfo->path[i].pathID, + sizeof(devGen), &devGen); + if (ccode != MM_OK) + { + break; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PATHINFO, + FALSE, TRUE)) != zOK) + { + goto done; + } + + sprintf(tempBuf, + "<"TAG_PATHNAME">%s" + "<"TAG_PATHID">%u" + "<"TAG_PRIORITY">%u" + "<"TAG_ADAPTERID">%u" + "<"TAG_PORT">%u\n", + devGen.name, + deviceInfo->path[i].pathID, + deviceInfo->path[i].priority, + deviceInfo->path[i].adapterID, + deviceInfo->path[i].port); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto done; + } + + /* Fill in the status info */ + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_STATUS, FALSE, FALSE)) + != zOK) + { + goto done; + } + + if (deviceInfo->path[i].status & FAILOVER_ELEMENT_UP) + { + if ((ccode = VIRT_AddResultElement(virtInfo, TAG_UP, NULL, + FALSE)) != zOK) + { + goto done; + } + } + + if (deviceInfo->path[i].status & FAILOVER_ELEMENT_SELECTED) + { + if ((ccode = VIRT_AddResultElement(virtInfo, TAG_SELECTED, NULL, + FALSE)) != zOK) + { + goto done; + } + } + + if (deviceInfo->path[i].status & FAILOVER_ELEMENT_LOAD_BALANCE) + { + if ((ccode = VIRT_AddResultElement(virtInfo, TAG_LOADBALANCE, + NULL, FALSE)) != zOK) + { + goto done; + } + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_STATUS, TRUE, TRUE)) + != zOK) + { + goto done; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PATHINFO, + TRUE, TRUE)) != zOK) + { + break; + } + } + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_MULTIPATHINFO, + TRUE, TRUE)) != zOK) + { + break; + } + }while (ccode == MM_OK); + +done: + if (ccode == MM_OBJECT_NOT_FOUND) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error getting device list")); + } + + free(buffer); + free(tempBuf); + return zOK; +} + +/**************************************************************************** + * + * This function get list of multipath for a device + * + ****************************************************************************/ +STATUS MNSS_ProcessListMultiPaths( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_DEVICEID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + DEVICE_ID = 0, + }; + + enum + { + BUF_SIZE = 16 * sizeof(struct PathInfoDef) + 24 + }; + + struct IOObjectGenericInfoDef devGen; + struct FailoverDeviceInfoDef *deviceInfo; + OBID devid = -1; + LONG ccode; + NINT i; + + BYTE *tempBuf; + BYTE *buffer; + + MNSS_LoadAppIDs(); + if ((ccode = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (ccode == zERR_XML_IS_BAD) + { + goto exit; + } + return ccode; + } + + devid = atol(tagContent[DEVICE_ID].content); + + tempBuf = malloc(1024); + if (tempBuf == NULL) + { + MNSS_ReturnResult(virtInfo, TAG_LISTMULTIPATHS, zERR_NO_MEMORY, + MSGNot("Error getting temporary buffer")); + return zOK; + } + + buffer = malloc(BUF_SIZE); + if (buffer == NULL) + { + MNSS_ReturnResult(virtInfo, TAG_LISTMULTIPATHS, zERR_NO_MEMORY, + MSGNot("Error getting info buffer")); + free(tempBuf); + return zOK; + } + + ZMM_ReturnObjectGenericInfo(ccode, devid, sizeof(devGen), &devGen); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, TAG_LISTMULTIPATHS, ccode, + MSGNot("Error getting device generic info")); + free(buffer); + free(tempBuf); + return zOK; + } + + if (!(devGen.status & MM_IOOBJECT_INFO_COMPLETE) || + !(devGen.status & MM_OBJECT_FUNCTIONAL) || + devGen.objectmanagerid != FailoverMgrID) + { + goto done; + } + + ZMM_ObjectControl(ccode, FailoverMgrID, MM_RETURN_FAILOVER_INFO, + devid, 0, 0, BUF_SIZE, buffer); + if (ccode != MM_OK) + { + if (ccode == MM_BUFFER_TOO_SMALL) + { + BYTE *hold; + NINT bufSize; + + bufSize = ((struct FailoverDeviceInfoDef *)buffer)->numberOfPaths + * sizeof(struct PathInfoDef) + 24; + hold = buffer; + buffer = realloc(buffer, bufSize); + if (buffer == NULL) + { + MNSS_ReturnResult(virtInfo, TAG_LISTMULTIPATHS, + zERR_NO_MEMORY, + MSGNot("Error getting info buffer")); + free(hold); + free(tempBuf); + return zOK; + } + ZMM_ObjectControl(ccode, FailoverMgrID, MM_RETURN_FAILOVER_INFO, + devid, 0, 0, bufSize, buffer); + + } + if (ccode != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_LISTMULTIPATHS, ccode, + MSGNot("Error getting failover info")); + + free(buffer); + free(tempBuf); + return zOK; + } + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_LISTMULTIPATHS, + FALSE, TRUE)) != zOK) + { + goto done; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_MULTIPATHS, + FALSE, TRUE)) != zOK) + { + goto done; + } + + deviceInfo = (struct FailoverDeviceInfoDef *)buffer; + for (i = 0; i < deviceInfo->numberOfPaths; i++) + { + sprintf(tempBuf, + "<"TAG_PATHID">%u\n", + deviceInfo->path[i].pathID); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + break; + } + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_MULTIPATHS, + TRUE, TRUE)) != zOK) + { + goto done; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_LISTMULTIPATHS, + TRUE, TRUE)) != zOK) + { + goto done; + } + +done: + + if (ccode == zOK) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error getting multipaths")); + } + + free(buffer); + free(tempBuf); + +exit: + return zOK; +} + + +/**************************************************************************** + * + * This function get path info. + * + ****************************************************************************/ +STATUS MNSS_ProcessGetPathInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_DEVICEID, TR_CONTENT_REQUIRED}, + {TAG_PATHID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + DEVICE_ID = 0, + PATH_ID = 1 + }; + + enum + { + BUF_SIZE = 16 * sizeof(struct PathInfoDef) + 24 + }; + struct IOObjectGenericInfoDef devGen; + struct FailoverDeviceInfoDef *deviceInfo; + OBID devid = -1; + OBID pathid; + LONG ccode; + NINT i; + + BYTE *tempBuf; + BYTE *buffer; + + MNSS_LoadAppIDs(); + + if ((ccode = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (ccode == zERR_XML_IS_BAD) + { + goto exit; + } + return ccode; + } + + devid = atol(tagContent[DEVICE_ID].content); + pathid = atol(tagContent[PATH_ID].content); + + tempBuf = malloc(1024); + if (tempBuf == NULL) + { + MNSS_ReturnResult(virtInfo, TAG_GETPATHINFO, zERR_NO_MEMORY, + MSGNot("Error getting temporary buffer")); + return zOK; + } + + buffer = malloc(BUF_SIZE); + if (buffer == NULL) + { + MNSS_ReturnResult(virtInfo, TAG_GETPATHINFO, zERR_NO_MEMORY, + MSGNot("Error getting info buffer")); + free(tempBuf); + return zOK; + } + + ZMM_ObjectControl(ccode, FailoverMgrID, MM_RETURN_FAILOVER_INFO, + devid, 0, 0, BUF_SIZE, buffer); + if (ccode != MM_OK) + { + if (ccode == MM_BUFFER_TOO_SMALL) + { + BYTE *hold; + NINT bufSize; + + bufSize = ((struct FailoverDeviceInfoDef *)buffer)->numberOfPaths + * sizeof(struct PathInfoDef) + 24; + hold = buffer; + buffer = realloc(buffer, bufSize); + if (buffer == NULL) + { + MNSS_ReturnResult(virtInfo, TAG_GETPATHINFO, + zERR_NO_MEMORY, + MSGNot("Error getting info buffer")); + free(hold); + free(tempBuf); + return zOK; + } + ZMM_ObjectControl(ccode, FailoverMgrID, MM_RETURN_FAILOVER_INFO, + devid, 0, 0, bufSize, buffer); + + } + if (ccode != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_GETPATHINFO, ccode, + MSGNot("Error getting failover info")); + + free(buffer); + free(tempBuf); + return zOK; + } + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_GETPATHINFO, + FALSE, TRUE)) != zOK) + { + goto done; + } + + ZMM_ReturnObjectGenericInfo(ccode, devid, sizeof(devGen), &devGen); + if (ccode != MM_OK) + { + goto done; + } + + deviceInfo = (struct FailoverDeviceInfoDef *)buffer; + for (i = 0; i < deviceInfo->numberOfPaths; i++) + { + if(pathid == deviceInfo->path[i].pathID) + { + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PATHINFO, + FALSE, TRUE)) != zOK) + { + goto done; + } + + sprintf(tempBuf, "<"TAG_DEVICENAME">%s\n", + devGen.name); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto done; + } + + ZMM_ReturnObjectGenericInfo(ccode, pathid, + sizeof(devGen), &devGen); + if (ccode != MM_OK) + { + goto done; + } + + sprintf(tempBuf, + "<"TAG_PATHNAME">%s" + "<"TAG_PRIORITY">%u" + "<"TAG_ADAPTERID">%u" + "<"TAG_PORT">%u\n", + devGen.name, + deviceInfo->path[i].priority, + deviceInfo->path[i].adapterID, + deviceInfo->path[i].port); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto done; + } + + /* Fill in the status info */ + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_STATUS, FALSE, FALSE)) + != zOK) + { + goto done; + } + + if (deviceInfo->path[i].status & FAILOVER_ELEMENT_UP) + { + if ((ccode = VIRT_AddResultElement(virtInfo, TAG_UP, NULL, + FALSE)) != zOK) + { + goto done; + } + } + + if (deviceInfo->path[i].status & FAILOVER_ELEMENT_SELECTED) + { + if ((ccode = VIRT_AddResultElement(virtInfo, TAG_SELECTED, NULL, + FALSE)) != zOK) + { + goto done; + } + } + + if (deviceInfo->path[i].status & FAILOVER_ELEMENT_LOAD_BALANCE) + { + if ((ccode = VIRT_AddResultElement(virtInfo, TAG_LOADBALANCE, + NULL, FALSE)) != zOK) + { + goto done; + } + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_STATUS, TRUE, TRUE)) + != zOK) + { + goto done; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PATHINFO, + TRUE, TRUE)) != zOK) + { + goto done; + } + } + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + VIRT_AddResultTag(virtInfo, TAG_GETPATHINFO, TRUE, TRUE); + +done: + + if (ccode == zOK) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error getting path info")); + } + + free(tempBuf); + free(buffer); +exit: + return zOK; +} + + +/**************************************************************************** + * + * This function get the device and path info. + * + ****************************************************************************/ +STATUS MNSS_ProcessSetPathPriority( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_PATHID, TR_CONTENT_REQUIRED}, + {TAG_PRIORITY, TR_CONTENT_REQUIRED}, + {TAG_INSERT, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + PATH_ID = 0, + PRIORITY = 1, + INSERT = 2 + }; + + STATUS status; + LONG ccode; + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + ZMM_ObjectControl(ccode, + FailoverMgrID, + MM_ASSIGN_FAILOVER_PRIORITY, + atol(tagContent[PATH_ID].content), + atol(tagContent[PRIORITY].content), + tagContent[INSERT].flags & TR_TAG_FOUND ? 1 : 0, + 0, + 0); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error setting priority")); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + } + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function get the device and path info. + * + ****************************************************************************/ +STATUS MNSS_ProcessSelectPath( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_PATHID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + PATH_ID = 0, + }; + + STATUS status; + LONG ccode; + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + ZMM_ObjectControl(ccode, + FailoverMgrID, + MM_MOVE_FAILOVER, + atol(tagContent[PATH_ID].content), + 0, + 0, + 0, + 0); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error selecting path")); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + } + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function sets the path state (up or down). + * + ****************************************************************************/ +STATUS MNSS_ProcessSetPathState( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_PATHID, TR_CONTENT_REQUIRED}, + {TAG_STATE, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + PATH_ID = 0, + STATE = 1 + }; + + STATUS status; + LONG ccode; + NINT state; + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + if (strcmp(tagContent[STATE].content, MSGNot("up")) == 0) + { + state = 0; + } + else if (strcmp(tagContent[STATE].content, MSGNot("down")) == 0) + { + state = 1; + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Invalid state (should be up or down)")); + goto exit; + } + + ZMM_ObjectControl(ccode, + FailoverMgrID, + MM_ASSIGN_FAILOVER_STATUS, + atol(tagContent[PATH_ID].content), + state, + 0, + 0, + 0); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error setting path state")); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + } + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function resets to the default path. + * + ****************************************************************************/ +STATUS MNSS_ProcessSelectDefaultPath( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_DEVICEID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + DEVICE_ID = 0, + }; + + STATUS status; + LONG ccode; + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + ZMM_ObjectControl(ccode, + FailoverMgrID, + MM_RESTORE_FAILOVER, + atol(tagContent[DEVICE_ID].content), + 0, + 0, + 0, + 0); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error selecting the default path for a device")); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + } + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function resets the media manager registery for failover (multipath + * functions). + * + ****************************************************************************/ +STATUS MNSS_ProcessResetRegistry( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + LONG ccode; + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + ZMM_ObjectControl(ccode, + FailoverMgrID, + MM_RESET_FAILOVER_REGISTRY, 0, 0, 0, 0, 0); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error resetting registry")); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + } + + return zOK; +} +#endif + + +#if zNETWARE +/****************************************************************************** + * MM_DEV_GetFreeSpaceList - Given a device ID, get a list of free space on + * that device + ******************************************************************************/ +STATUS MM_DEV_GetFreeSpaceList( + OBID devID, + DQhead_t *freeSpaceList) +{ + struct IOObjectGenericInfoDef tempGenInfo; + struct PartitionSpecificInfoDef partInfo; + UINT32 retCode, childIndex, index; + OBID targetOBID; + LONG *mappingInfo = NULL; + NINT mappingInfoSize = 0; + Pool_Segment_s *freeSegment; + OBID partID; + NINT neededMappingInfoSize = 0; + BOOL mergedPartition = FALSE; + + ASSERT_MPKNSS_LOCK(); + + retCode = MM_OK; + targetOBID = devID; + + MPKNSS_UNLOCK(); + + retCode = MM_ReturnObjectGenericInfo(targetOBID, + sizeof(struct IOObjectGenericInfoDef), &tempGenInfo); + if (retCode != MM_OK) + { + zASSERT("MM_ReturnObjectGenericInfo on obj FAILED"==NULL); + goto errorExit; + } + /* This is a partition object */ + if (tempGenInfo.type != MM_DEVICE_OBJECT) + { + goto errorExit; + } + + /* traverse the tree begin with the device, find the child */ + /* if the child type is partition, then we stop */ + while (retCode == MM_OK) + { + retCode = MM_ReturnObjectGenericInfo(targetOBID, + sizeof(struct IOObjectGenericInfoDef), &tempGenInfo); + if (retCode != MM_OK) + { + zASSERT("MM_ReturnObjectGenericInfo on obj FAILED"==NULL); + goto errorExit; + } + /* This is a partition object */ + if (tempGenInfo.type == MM_PARTITION_OBJECT) + { + /* mappingInfo[2] contains the childCount */ + /* looping through all the childen, that is, all the partitions or free space */ + /* on that device */ + for(childIndex = 0; childIndex < mappingInfo[2]; childIndex++) + { + partID = mappingInfo[index+childIndex]; + /* Get the specific info on the partition */ + bzero(&partInfo, sizeof(struct PartitionSpecificInfoDef)); + retCode = MM_ReturnObjectSpecificInfo(partID, + sizeof(struct PartitionSpecificInfoDef), &partInfo); + if (retCode != MM_OK) + { + zASSERT("MM_ReturnObjectSpecificInfo on partition obj FAILED"==NULL); + goto errorExit; + } + + /* we are only interested in the free space */ + if(partInfo.partitiontype == NETWARE_FREE_PARTITION + && partInfo.partitionsize != 0) + { + + /* Check to see if this is next to another free partition. + If so, add the size to the existing partition. + */ + DQ_FOREACH(freeSpaceList, freeSegment, Pool_Segment_s, next) + { + if (freeSegment->offset < partInfo.partitionoffset) + { + if ((freeSegment->offset + freeSegment->numSector) == partInfo.partitionoffset) + { + freeSegment->numSector += partInfo.partitionsize; + mergedPartition = TRUE; + } + } + else if ((partInfo.partitionoffset + partInfo.partitionsize) == freeSegment->offset) + { + freeSegment->numSector += partInfo.partitionsize; + freeSegment->offset = partInfo.partitionoffset; + mergedPartition = TRUE; + } + } + + /* If the partition was not joined with another one, add + it to the freeSegmentList. */ + if (!mergedPartition) + { + MPKNSS_LOCK(); + /* Need to add this to our linked list. */ + freeSegment = (Pool_Segment_s *)malloc(sizeof(Pool_Segment_s)); + + if (freeSegment == NULL) + { + MPKNSS_UNLOCK(); + goto errorExit; + } + bzero(freeSegment, sizeof(Pool_Segment_s)); + freeSegment->devID = devID; + freeSegment->partID = partID; + freeSegment->offset = partInfo.partitionoffset; + freeSegment->numSector = partInfo.partitionsize; + NULLIFY(&freeSegment->next); + DQ_ENQ(freeSpaceList, freeSegment, next); + MPKNSS_UNLOCK(); + } + + mergedPartition = FALSE; + } + } + /* now we are done with our job */ + break; + } + if(tempGenInfo.childcount == 0) + goto errorExit; + + /* Figure out how much space we need for the returned mapping info, + * and make sure our "mappingINfo" pointer points to a buffer big + * enough for the reply. + */ + neededMappingInfoSize = sizeof(LONG) * + (3 + /* Generic header with parentCount, siblingCount & childCount */ + tempGenInfo.parentcount + + tempGenInfo.siblingcount + + tempGenInfo.childcount); + + /* we need a bigger buffer */ + if (neededMappingInfoSize > mappingInfoSize) + { + MPKNSS_LOCK(); + if (mappingInfo != NULL) + { + free(mappingInfo); + } + mappingInfo = zalloc(neededMappingInfoSize); + MPKNSS_UNLOCK(); + mappingInfoSize = neededMappingInfoSize; + } + if (mappingInfo == NULL) + { + zASSERT("MM_DEV_GetFreeSpaceList unable to allocate memory for mappingInfo"==NULL); + goto errorExit; + } + + /* Get the OBID of the first child object */ + retCode = MM_ReturnObjectMappingInfo(targetOBID, MM_IO_CLASS, + mappingInfoSize, mappingInfo); + if (retCode == MM_OK ) + { + /* We cant use a structure here, because the parent and sibling + * arrays are in-line flat in the IOObjectJappingTableDef. + */ + index = 3 + /* Accounts for parentCount, siblingCount, and childCount fields offsets */ + mappingInfo[0] + /* Accounts for parentOBIDs[parentCount] fields offsets */ + mappingInfo[1]; /* Accounts for siblingOBIDs[siblingCount] fields offsets */ + + /* Now we're at the offset of the childOBIDs[]. Use the first child */ + targetOBID = mappingInfo[index]; + } + } + MPKNSS_LOCK(); + return(zOK); + +/*===========================================================================*/ +errorExit: + + MPKNSS_LOCK(); + if (mappingInfo != NULL) + { + free(mappingInfo); + } + return(zFAILURE); +} + +/****************************************************************************** + * MM_DEV_GetFreeSize - Given a device ID, get a free space total on + * that device + ******************************************************************************/ +STATUS MM_DEV_GetFreeSize( + OBID devID, + QUAD *freeSize) +{ + struct IOObjectGenericInfoDef genInfo; + struct PartitionSpecificInfoDef partInfo; + UINT32 childIndex, index; + OBID targetID; + LONG ccode = MM_OK; + LONG *mappingInfo = NULL; + NINT mappingInfoSize = 0; + OBID partID; + NINT neededMappingInfoSize = 0; + BOOL hasPool; + BOOL partDeleted; + + ASSERT_MPKNSS_LOCK(); + + MPKNSS_UNLOCK(); + + ccode = MM_ReturnObjectGenericInfo(devID, + sizeof(struct IOObjectGenericInfoDef), &genInfo); + if (ccode != MM_OK) + { + zASSERT("MM_DEV_GetFreeSpaceSize - MM_ReturnObjectGenericInfo on obj FAILED"==NULL); + MPKNSS_LOCK(); + goto exit; + } + // This is a device object + if (genInfo.type != MM_DEVICE_OBJECT) + { + MPKNSS_LOCK(); + goto exit; + } + + targetID = devID; + *freeSize = 0; + + MPKNSS_LOCK(); + + // Delete any NSS or Traditional partitions that are not mirrored and do + // contain a pool or traditional volume. + PART_RemoveEmptyPartitions(); + + MPKNSS_UNLOCK(); + + // traverse the tree begin with the device, find the child + // if the child type is partition, then we process and then stop + while (ccode == MM_OK) + { + ccode = MM_ReturnObjectGenericInfo(targetID, + sizeof(struct IOObjectGenericInfoDef), &genInfo); + if (ccode != MM_OK) + { + zASSERT("MM_DEV_GetFreeSpaceSize - MM_ReturnObjectGenericInfo on obj FAILED"==NULL); + MPKNSS_LOCK(); + goto exit; + } + + if (genInfo.type == MM_PARTITION_OBJECT) + { + // mappingInfo[2] contains the childCount + // looping through all the childen, that is, all the partitions or free space + // on that device + for(childIndex = 0; childIndex < mappingInfo[2]; childIndex++) + { + partID = mappingInfo[index+childIndex]; + + // Get the specific info on the partition + bzero(&partInfo, sizeof(struct PartitionSpecificInfoDef)); + ccode = MM_ReturnObjectSpecificInfo(partID, + sizeof(struct PartitionSpecificInfoDef), &partInfo); + if (ccode != MM_OK) + { + zASSERT("MM_DEV_GetFreeSpaceSize - MM_ReturnObjectSpecificInfo on partition obj FAILED"==NULL); + MPKNSS_LOCK(); + goto exit; + } + + // we are only interested in the free space + if(partInfo.partitiontype == NETWARE_FREE_PARTITION + && partInfo.partitionsize != 0) + { + *freeSize += partInfo.partitionsize; + } + else if ((partInfo.partitiontype == NETWARE_NSS_PARTITION) || + (partInfo.partitiontype == NETWARE_386_PARTITION)) + { + MPKNSS_LOCK(); + + // Check if this partition already has a pool on it. + // If not, add the space to freeSize. + if ((ccode = PART_CheckPartitionForPool( + partID, + &hasPool, + &partDeleted)) != MM_OK) + { + zASSERT("MM_DEV_GetFreeSpaceSize - Could not determine if the partition contains a pool."==NULL); + goto exit; + } + + if (!hasPool) + { + *freeSize += partInfo.partitionsize; + } + MPKNSS_UNLOCK(); + } + } + + // finished + break; + } + + if(genInfo.childcount == 0) + { + MPKNSS_LOCK(); + goto exit; + } + + // Figure out how much space we need for the returned mapping info, + // and make sure our "mappingINfo" pointer points to a buffer big + // enough for the reply. + neededMappingInfoSize = sizeof(LONG) * + (3 + // Generic header with parentCount, siblingCount & childCount + genInfo.parentcount + + genInfo.siblingcount + + genInfo.childcount); + + // we need a bigger buffer + if (neededMappingInfoSize > mappingInfoSize) + { + MPKNSS_LOCK(); + if (mappingInfo != NULL) + { + free(mappingInfo); + } + mappingInfo = zalloc(neededMappingInfoSize); + MPKNSS_UNLOCK(); + mappingInfoSize = neededMappingInfoSize; + } + if (mappingInfo == NULL) + { + zASSERT("MM_DEV_GetFreeSpaceSize - Unable to allocate memory for mappingInfo"==NULL); + MPKNSS_LOCK(); + ccode = zERR_NO_MEMORY; + goto exit; + } + + // Get the OBID of the first child object + ccode = MM_ReturnObjectMappingInfo(targetID, MM_IO_CLASS, + mappingInfoSize, mappingInfo); + if (ccode == MM_OK ) + { + // Can't use a structure here, because the parent and sibling + // arrays are in-line flat in the IOObjectMappingTableDef. + index = 3 + // Accounts for parentCount, siblingCount, and childCount fields offsets + mappingInfo[0] + // Accounts for parentOBIDs[parentCount] fields offsets + mappingInfo[1]; // Accounts for siblingOBIDs[siblingCount] fields offsets + + // Now we're at the offset of the childOBIDs[]. Use the first child + targetID = mappingInfo[index]; + } + } + + *freeSize = *freeSize * genInfo.unitsize; + + MPKNSS_LOCK(); + +exit: + + if (mappingInfo != NULL) + { + free(mappingInfo); + } + + return ccode; +} + + +/**************************************************************************** + * Add the device tag. This will include totalObjects and + * zero or more segmentID tags. + *****************************************************************************/ +LONG MM_DEV_GetSegmentList( + OBID devID, + VirtInfo_s *virtInfo) +{ + struct IOObjectGenericInfoDef devGen; + LONG ccode; + LONG *mappingInfo = NULL; + NINT size = 0; + NINT idx; + utf8_t tempBuf[512] = ""; + + ASSERT_MPKNSS_LOCK(); + + ZMM_ReturnObjectGenericInfo(ccode, devID, sizeof(devGen), &devGen); + + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, TAG_SEGMENTINFO, ccode, + MSGNot("Error getting device generic info")); + goto errorExit; + } + + /* Figure out how much space we need for the returned mapping info, + * and make sure our "mappingINfo" pointer points to a buffer big + * enough for the reply. + */ + size = sizeof(LONG) * + (3 + /* Generic header with parentCount, siblingCount & childCount */ + devGen.parentcount + + devGen.siblingcount + + devGen.childcount); + + mappingInfo = zalloc(size); + + if (mappingInfo == NULL) + { + MNSS_ReturnResult(virtInfo, TAG_SEGMENTINFO, ccode, + MSGNot("Error allocating memory")); + goto errorExit; + } + + ZMM_ReturnObjectMappingInfo( + ccode, + devID, + MM_IO_CLASS, + size, + mappingInfo); + + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, TAG_SEGMENTINFO, ccode, + MSGNot("Error getting object mapping info")); + goto errorExit; + } + + /* Add the opening tag */ + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_SEGMENTINFO, FALSE, TRUE)) != zOK) + { + return ccode; + } + + sprintf(tempBuf, + "<"TAG_NUMSEGMENTS">%u", + mappingInfo[0]); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_SEGMENTINFO, ccode, + MSGNot("Error building reply XML.")); + goto errorExit; + } + + for (idx = 0 ; idx < mappingInfo[0] ; idx++) + { + + /* set mirrorpercentage as -1 to show this is not mirrored */ + if((ccode = MM_DEV_GetSegmentInfo(mappingInfo[idx+3], -1, virtInfo)) != zOK) + { + continue; + } + } + +errorExit: + + /* Add the closing tag */ + ccode = VIRT_AddResultTag(virtInfo, TAG_SEGMENTINFO, TRUE, TRUE); + + if (mappingInfo != NULL) + { + free(mappingInfo); + mappingInfo = NULL; + } + + return ccode; +} + +/**************************************************************************** + * Add the device tag. This will include totalObjects and + * zero or more segmentID tags. + *****************************************************************************/ +LONG MM_DEV_GetSegmentInfo( + OBID segmentID, + LONG mirrorPercentage, + VirtInfo_s *virtInfo) +{ + LONG ccode; + utf8_t tempBuf[512] = ""; + OBID deviceID; + struct IOObjectGenericInfoDef partGen; + struct IOObjectGenericInfoDef deviceGen; + + ASSERT_MPKNSS_LOCK(); + + ZMM_ReturnObjectGenericInfo(ccode, segmentID, + sizeof(struct IOObjectGenericInfoDef), &partGen); + if (ccode != MM_OK) + { + goto exit; + } + + ZMM_ReturnObjectProgenitor(ccode, segmentID, MM_DEVICE_OBJECT, &deviceID); + if (ccode != MM_OK) + { + goto exit; + } + + ZMM_ReturnObjectGenericInfo(ccode, deviceID, + sizeof(struct IOObjectGenericInfoDef), &deviceGen); + if (ccode != MM_OK) + { + goto exit; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_SEGMENT, FALSE, TRUE)) + != zOK) + { + goto exit; + } + + if(mirrorPercentage >= 0) + { + /* remirroring percentage for mirror */ + sprintf(tempBuf, MSGNot("<"TAG_MIRRORPERCENT">%u"), + mirrorPercentage); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + } + + /* device name */ + if ((ccode = VIRT_AddResultElement(virtInfo, TAG_DEVICENAME, deviceGen.name, + FALSE)) != zOK) + { + goto exit; + } + + /* segment name */ + if ((ccode = VIRT_AddResultElement(virtInfo, TAG_SEGMENTNAME, partGen.name, + FALSE)) != zOK) + { + goto exit; + } + + /* device id and segment ID */ + sprintf(tempBuf, MSGNot("<"TAG_DEVICEID">%u<" + TAG_SEGMENTID">%u"), + deviceID, + segmentID); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + + ccode = VIRT_AddResultTag(virtInfo, TAG_SEGMENT, TRUE, TRUE); + +exit: + + return ccode; +} + + +/**************************************************************************** + * + * MM_DEV_CheckForDOSPartition - This function checks if a device contains a + * DOS partition + ****************************************************************************/ +STATUS MM_DEV_CheckForDOSPartition( + OBID devID, + BOOL *hasDOS) +{ + LONG ccode = MM_OK; + OBID deviceID; + OBID partID; + struct PartitionSpecificInfoDef partInfo; + + ASSERT_MPKNSS_LOCK(); + + *hasDOS = FALSE; + + partID = -1; + do + { + ZMM_FindObjectType(ccode, MM_IO_CLASS, MM_PARTITION_OBJECT, &partID); + if (ccode != MM_OK) + { + if (ccode != MM_OBJECT_NOT_FOUND) + { + goto exit; + } + break; /* Exit main while loop -- no more partitions */ + } + + ZMM_ReturnObjectProgenitor(ccode, partID, MM_DEVICE_OBJECT, &deviceID); + if (ccode != MM_OK) + { + goto exit; + } + + if(deviceID != devID) + { + continue; + } + + ZMM_ReturnObjectSpecificInfo(ccode, partID, + sizeof(struct PartitionSpecificInfoDef), &partInfo); + if (ccode != MM_OK) + { + goto exit; + } + + if(partInfo.partitiontype == DOS_PARTITION || + partInfo.partitiontype == BIG_DOS_PARTITION) + { + *hasDOS = TRUE; + break; + } + } while (ccode == MM_OK); + +exit: + if(ccode == MM_OBJECT_NOT_FOUND) + { + return MM_OK; + } + return ccode; +} + + +/**************************************************************************** + * + * + - This function retrieves device information and builds + * the XML for a specific device. + * + ****************************************************************************/ +STATUS MM_DEV_GetDeviceInfo( + VirtInfo_s *virtInfo, + utf8_t *tagName, + OBID devID) +{ + LONG ccode = MM_OK; + struct IOObjectGenericInfoDef devGen; + struct RaidDeviceSpecificInfoDef raidDevSpecInfo; + QUAD totSize; + QUAD freeSize; + utf8_t tempBuf[512] = ""; + BOOL hasDOS; + + ASSERT_MPKNSS_LOCK(); + + ZMM_ReturnObjectGenericInfo(ccode, devID, sizeof(devGen), &devGen); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error getting device generic info")); + goto exit; + } + + if (!(devGen.status & MM_IOOBJECT_INFO_COMPLETE) || + !(devGen.status & MM_OBJECT_FUNCTIONAL)) + { + MNSS_ReturnResult(virtInfo, tagName, MM_INVALID_OBJECT, + MSGNot("Device Status was not complete or functional.")); + goto exit; + } + ZMM_ReturnObjectSpecificInfo(ccode, devID, sizeof(raidDevSpecInfo), + &raidDevSpecInfo); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error getting device specific info")); + ccode = MM_OK; + goto exit; + } + + if ((raidDevSpecInfo.deviceInfo.devicetype == + MM_DIRECT_ACCESS_DEVICE ) || + (raidDevSpecInfo.deviceInfo.devicetype == MM_MO_DEVICE)) + { + if ((ccode = VIRT_AddResultTag(virtInfo, tagName, + FALSE, TRUE)) != zOK) + { + goto exit; + } + + // Get the device's freespace. + totSize = ((QUAD)raidDevSpecInfo.deviceInfo.capacity) * raidDevSpecInfo.deviceInfo.unitsize; + // All sizes are returned in bytes. + sprintf(tempBuf, + "<"TAG_NAME">%s" + "<"TAG_OBJECTID">%u" + "<"TAG_TYPE">%u" + "<"TAG_SIZE">%Lu", + devGen.name, + devID, + raidDevSpecInfo.deviceInfo.devicetype, + totSize); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + + // Get the device's freespace. + if ((ccode = MM_DEV_GetFreeSize(devID, &freeSize)) == zOK) + { + sprintf(tempBuf, + "<"TAG_FREESIZE">%Lu", + freeSize); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + } + else + { + MNSS_ReturnResult(virtInfo, TAG_FREESIZE, ccode, + MSGNot("Error getting device free size.")); + } + ccode = NW_getPartitionsOnDevice(virtInfo, devID); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, TAG_PARTITIONS, ccode, + MSGNot("Error getting device partitions.")); + } + + ccode = MM_DEV_CheckForDOSPartition(devID, &hasDOS); + if (ccode == MM_OK) + { + /* check if this device has dos partition on it */ + if(hasDOS == TRUE) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_HASDOS, "", FALSE)) != zOK) + { + goto exit; + } + } + } + else + { + MNSS_ReturnResult(virtInfo, TAG_HASDOS, ccode, + MSGNot("Error checking if the device has DOS partitions.")); + } + + /* check if this device has multipath enabled */ + if(devGen.objectmanagerid == FailoverMgrID) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_MULTIPATH, "", FALSE)) != zOK) + { + goto exit; + } + } + + + if (devGen.status & MM_IOOBJECT_SHARED) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_SHARED, "", FALSE)) != zOK) + { + goto exit; + } + } + + if (devGen.status & MM_IOOBJECT_REMOVABLE) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_REMOVABLE, "", FALSE)) != zOK) + { + goto exit; + } + } + + if (devGen.status & MM_IOOBJECT_RAID) + { + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_DEVICERAID, + FALSE, TRUE)) != zOK) + { + goto exit; + } + + totSize = ((QUAD)raidDevSpecInfo.elementSize) * 512; + sprintf(tempBuf, + "<"TAG_RAIDTYPE">%u" + "<"TAG_ELEMENTSIZE">%Lu" + "<"TAG_ELEMENTCOUNT">%u" + "<"TAG_STRIPESIZE">%u" + "<"TAG_RESTRIPEFLAG">%u", + raidDevSpecInfo.raidType, + totSize, + raidDevSpecInfo.elementCount, + raidDevSpecInfo.stripeSize * 512, + raidDevSpecInfo.restripeFlag); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + + // Get the segment list. Don't need to exit here if there is a + // problem - want to return the rest of the information. + ccode = MM_DEV_GetSegmentList(devID, virtInfo); + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_DEVICERAID, + TRUE, TRUE)) != zOK) + { + goto exit; + } + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + ccode = VIRT_AddResultTag(virtInfo, tagName, + TRUE, TRUE); + } + +exit: + + return ccode; +} + +/**************************************************************************** + * + * MM_DEV_GetMirrorInfo - This function retrieves device information and builds + * the XML for a specific device. + * + ****************************************************************************/ +LONG MM_DEV_GetMirrorInfo( + VirtInfo_s *virtInfo, + OBID mirrorID) +{ + struct MirrorSpecificInfoDef mirrorInfo; + LONG ccode = MM_OK; + utf8_t tempBuf[512] = ""; + QUAD totSize; + QUAD freeSize; + LONG type; + BOOL shared; + NINT numMirrors; + NINT idx; + BYTE mirrorName[MM_MAX_OBJECT_STRING_LEN]; + + ASSERT_MPKNSS_LOCK(); + + bzero(mirrorName, sizeof(mirrorName)); + bzero(&mirrorInfo, sizeof(mirrorInfo)); + + if ((ccode = PART_GetMirrorInfo( + mirrorID, + &type, + &totSize, + &freeSize, + &shared, + &mirrorName, + &mirrorInfo)) != MM_OK) + { + MNSS_ReturnResult(virtInfo, TAG_GETDEVICEINFO, ccode, + MSGNot("Error getting mirror device's information.")); + goto exit; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_GETDEVICEINFO, FALSE, TRUE)) != zOK) + { + goto exit; + } + + sprintf(tempBuf, + "<"TAG_NAME">%s" + "<"TAG_OBJECTID">%u" + "<"TAG_TYPE">%u" + "<"TAG_SIZE">%Lu" + "<"TAG_FREESIZE">%Lu", + mirrorName, + mirrorID, + type, + totSize, + freeSize); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + + // Since this is a mirrored device, pass back the mirrored tag. + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_MIRRORED, "", FALSE)) != zOK) + { + goto exit; + } + + if (shared) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_SHARED, "", FALSE)) != zOK) + { + goto exit; + } + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_DEVICEMIRROR, + FALSE, TRUE)) != zOK) + { + goto exit; + } + + numMirrors = mirrorInfo.mirrorcount; + + sprintf(tempBuf, + "<"TAG_MIRRORGROUPSTATUS">%u" + "<"TAG_MIRRORGROUPPERCENT">%u" + "<"TAG_NUMMIRRORS">%u\n", + mirrorInfo.status, + mirrorInfo.remirrorpercentage, + numMirrors); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + + /* Now, add each Mirror to the buffer */ + for (idx=0; idx" + "<"TAG_ID">%u" + "<"TAG_MIRRORPERCENT">%u" + "\n", + mirrorInfo.mirrormembers[idx], + mirrorInfo.memberpercentremirrored[idx]); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_DEVICEMIRROR, + TRUE, TRUE)) != zOK) + { + goto exit; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + ccode = VIRT_AddResultTag(virtInfo, TAG_GETDEVICEINFO, TRUE, TRUE); +exit: + + return ccode; +} + + +/**************************************************************************** + * + * MM_DEV_GetMirrorInfo - This function retrieves device information and builds + * the XML for a specific device. + * + ****************************************************************************/ +LONG MM_DEV_GetMirrorInfoSimple( + VirtInfo_s *virtInfo, + OBID mirrorID) +{ + struct MirrorSpecificInfoDef mirrorInfo; + LONG ccode = MM_OK; + utf8_t tempBuf[512] = ""; + QUAD totSize; + QUAD freeSize; + LONG type; + BOOL shared; + NINT numMirrors; + NINT idx; + BYTE mirrorName[MM_MAX_OBJECT_STRING_LEN]; + + ASSERT_MPKNSS_LOCK(); + + bzero(mirrorName, sizeof(mirrorName)); + + if ((ccode = PART_GetMirrorInfo( + mirrorID, + &type, + &totSize, + &freeSize, + &shared, + &mirrorName, + &mirrorInfo)) != MM_OK) + { + MNSS_ReturnResult(virtInfo, TAG_GETDEVICEINFOSIMPLE, ccode, + MSGNot("Error getting mirror device's information.")); + goto exit; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_GETDEVICEINFOSIMPLE, + FALSE, TRUE)) != zOK) + { + goto exit; + } + + sprintf(tempBuf, + "<"TAG_NAME">%s" + "<"TAG_OBJECTID">%u" + "<"TAG_TYPE">%u" + "<"TAG_SIZE">%Lu" + "<"TAG_FREESIZE">%Lu", + mirrorName, + mirrorID, + type, + totSize, + freeSize); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + + // Since this is a mirrored device, pass back the mirrored tag. + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_MIRRORED, "", FALSE)) != zOK) + { + goto exit; + } + + if (shared) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_SHARED, "", FALSE)) != zOK) + { + goto exit; + } + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_DEVICEMIRROR, + FALSE, TRUE)) != zOK) + { + goto exit; + } + + numMirrors = mirrorInfo.mirrorcount; + + sprintf(tempBuf, + "<"TAG_MIRRORGROUPSTATUS">%u" + "<"TAG_MIRRORGROUPPERCENT">%u" + "<"TAG_NUMMIRRORS">%u\n", + mirrorInfo.status, + mirrorInfo.remirrorpercentage, + numMirrors); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_MIRRORINFO, + FALSE, TRUE)) != zOK) + { + goto exit; + } + + /* Now, add each Mirror to the buffer */ + for (idx=0; idxpoolName, poolName) == 0) + { + foundPool = TRUE; + break; + } + } + if(foundPool == FALSE) + { + + devicePool = (Device_Pool_s *)malloc(sizeof(Device_Pool_s)); + if (devicePool == NULL) + { + ccode = zERR_NO_MEMORY; + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to get buffer")); + goto FreeExit; + } + + bzero(devicePool, sizeof(Device_Pool_s)); + strcpy(devicePool->poolName, poolName); + NULLIFY(&devicePool->next); + DQ_ENQ(&poolList, devicePool, next); + } + } + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + + DQ_FOREACH(&poolList, devicePool, Device_Pool_s, next) + { + pool = NULL; + if ((ccode = LB_ByteToUnicode(NSS_UNI_CONVERSION_RAW, + uPoolName, NELEMS(uPoolName), + devicePool->poolName, NULL)) != zOK) + { + // There was a problem converting the pool name to unicode - + // don't bail - just return info with a failed state (-1). + sprintf(xmlBuffer, "<"TAG_POOLSIMPLEINFO"><" + TAG_POOLNAME">%s<" + TAG_POOLSTATE">0", + devicePool->poolName); + goto poolRelease; + } + + pool = COMN_PoolNameLookup(&genMsg, uPoolName, FALSE, NULL); + if (pool == NULL) + { + // There was a problem in COMN_PoolNameLookup - don't bail - + // just return info with a failed state (-1). + sprintf(xmlBuffer, "<"TAG_POOLSIMPLEINFO"><" + TAG_POOLNAME">%s<" + TAG_POOLSTATE">0", + devicePool->poolName); + goto poolRelease; + } + + if(pool->p.PP_enabledFeatures & zPOOL_FEATURE_SHARED_CLUSTER) + { + sprintf(xmlBuffer, "<"TAG_POOLSIMPLEINFO"><" + TAG_POOLNAME">%s<" + TAG_POOLSTATE">%u<" + TAG_SHARED"/>", + devicePool->poolName, pool->state); + } + else + { + sprintf(xmlBuffer, "<"TAG_POOLSIMPLEINFO"><" + TAG_POOLNAME">%s<" + TAG_POOLSTATE">%u", + devicePool->poolName, pool->state); + } + +poolRelease: + if (pool) + { + COMN_Release(&pool); + } + + if ((ccode = VIRT_AddResultData(virtInfo, xmlBuffer)) != zOK) + { + goto FreeExit; + } + } + +FreeExit: + if ((partitions != NULL) && (partitions != &objID)) + { + free(partitions); + } + + while (DQ_NOT_EMPTY(&poolList)) + { + DQ_DEQ(&poolList, devicePool, Device_Pool_s, next); + if(devicePool != NULL) + { + free(devicePool); + } + } + + if(ccode == zOK) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error getting device pools")); + } + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} + + +/**************************************************************************** + * + * This function gets a list of partition object IDs for a device + * + ****************************************************************************/ +LONG NW_getPartitionsOnDevice(VirtInfo_s *virtInfo, LONG devID) +{ + struct IOObjectGenericInfoDef genInfo; + struct DeviceSpecificInfoDef devInfo; + struct PartitionSpecificInfoDef partInfo; + LONG *mappingInfo; + OBID partID; + LONG size; + LONG index; + LONG childIndex; + LONG ccode; + utf8_t tempBuf[512] = ""; + + ZMM_ReturnObjectSpecificInfo(ccode, devID, sizeof(devInfo), &devInfo); + if (ccode != MM_OK) + goto exit; + + ZMM_ReturnObjectGenericInfo(ccode, devInfo.mmmediaid, sizeof(genInfo), &genInfo); + if (ccode != MM_OK) + goto exit; + + size = sizeof(LONG) * + (3 + /* Generic header with parentCount, siblingCount & childCount */ + genInfo.parentcount + + genInfo.siblingcount + + genInfo.childcount); + + mappingInfo = malloc(size); + if (mappingInfo == NULL) + { + ccode = zERR_NO_MEMORY; + goto exit; + } + + ZMM_ReturnObjectMappingInfo(ccode, devInfo.mmmediaid, MM_IO_CLASS, size, mappingInfo); + if (ccode != MM_OK) + goto freeExit; + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PARTITIONS, + FALSE, TRUE)) != zOK) + { + goto freeExit; + } + + index = 3 + /* Accounts for parentCount, siblingCount, and childCount fields offsets */ + mappingInfo[0] + /* Accounts for parentOBIDs[parentCount] fields offsets */ + mappingInfo[1]; /* Accounts for siblingOBIDs[siblingCount] fields offsets */ + + /* mappingInfo[2] contains the childCount */ + for(childIndex = 0; childIndex < mappingInfo[2]; childIndex++) + { + partID = mappingInfo[index+childIndex]; + ZMM_ReturnObjectGenericInfo(ccode, partID, sizeof(genInfo), &genInfo); + if (ccode != MM_OK) + { + continue; + } + + ZMM_ReturnObjectSpecificInfo(ccode, partID, sizeof(partInfo), &partInfo); + if (ccode != MM_OK) + { + continue; + } + + /* skip the free partition */ + if (partInfo.partitiontype == NETWARE_FREE_PARTITION) + { + continue; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PARTITION, + FALSE, TRUE)) != zOK) + { + goto freeExit; + } + + sprintf(tempBuf, + "<"TAG_PARTITIONID">%u" + "<"TAG_PARTITIONTYPE">%u\n", + partID, + partInfo.partitiontype & 0xff); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto freeExit; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PARTITION, + TRUE, TRUE)) != zOK) + { + goto freeExit; + } + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PARTITIONS, + TRUE, TRUE)) != zOK) + { + goto freeExit; + } +freeExit: + free(mappingInfo); + +exit: + return ccode; +} +#endif + +#if zLINUX && !defined(__KERNEL__) + +/**************************************************************************** + * + * composeDeviceInfoPartitionList - This function retrieves device partition + * information and builds the XML for patition list. + * In evms, segment is partition + * + ****************************************************************************/ +NINT composeDeviceInfoPartitionList( + VirtInfo_s *virtInfo, + storage_object_info_t *info) +{ + NINT i; + utf8_t tempBuf[512] = ""; + EvmsSegmentInfoArray_s *segments = NULL; + NINT partitionType; + NINT ccode; + NINT len; + BYTE poolName[zMAX_COMPONENT_NAME]; + BOOL hasPool; + MountPointArray_s *mountPointArray = NULL; + EvmsExtendInfo_s evmsExtInfo; + BOOL infoFound = FALSE; + NINT flags = 0; + handle_object_info_t *parent_info; + + if ((ccode = evmsGetDeviceSegments(info, TRUE, &segments, NULL)) != 0) + { + return ccode; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PARTITIONS, + FALSE, TRUE)) != zOK) + { + free(segments); + return ccode; + } + + if (segments != NULL) + { + /* get mount point information from /etc/fstab */ + /* Fixfixfix needs to get mount point info from EVMS, too */ + evmsGetMountPointFromFstab(&mountPointArray); + + for (i = 0; i < segments->count; i++) + { + if (segments->segment[i].data_type != META_DATA_TYPE) + { + if ((ccode = evmsGetSegmentType(segments->segment[i].handle, + segments->segment[i].data_type, &partitionType)) != 0) + { + goto free_object; + } + + sprintf(tempBuf, + "<"TAG_PARTITION">" + "<"TAG_PARTITIONID">%s" + "<"TAG_PARTITIONTYPE">%u", + segments->segment[i].name, partitionType & 0xFF); + len = strlen(tempBuf); + + if (segments->segment[i].data_type != FREE_SPACE_TYPE) + { + flags = 0; + ccode = evmsGetExtendedInfo(segments->segment[i].handle, + (BYTE *)MSGNot("Flags"), &infoFound, &evmsExtInfo); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object flags info for %s: %s"), + segments->segment[i].name, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, TAG_PARTITION, ccode, tempBuf); + goto free_object; + } + if (infoFound) + { + flags = evmsExtInfo.value.ui32; + } + + /* if its bootable */ + if (flags & STATUS_BOOT) + { + sprintf(&tempBuf[len], "<"TAG_BOOTABLE"/>"); + len = strlen(tempBuf); + } + + /* get possible "SYS" pool name */ + hasPool = FALSE; + if ((ccode = evmsGetPoolNameFromExtendInfo(segments->segment[i].handle, + &hasPool, poolName)) != 0) + { + sprintf(tempBuf, MSGNot("Error getting pool info for %s: %s"), + segments->segment[i].name, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, TAG_PARTITION, ccode, tempBuf); + goto free_object; + } + + if (hasPool && !stricmp(MSGNot("SYS"), (char *)poolName)) + { + sprintf(&tempBuf[len], "<"TAG_HASSYS"/>"); + len = strlen(tempBuf); + } + + /* try to get mount point from evms first */ + infoFound = FALSE; + ccode = evmsGetTopMostParentInfo(segments->segment[i].handle, &parent_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting top most parent info for %s: %s"), + segments->segment[i].name, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, TAG_PARTITION, ccode, tempBuf); + goto free_object; + } + if (parent_info == NULL) + { + continue; + } + +// syslog(LOG_INFO, "parent_info type: %d\n", parent_info->type); +// syslog(LOG_INFO, "parent_info name: %s\n", parent_info->info.volume.name); + + if (parent_info->type == VOLUME && parent_info->info.volume.mount_point != NULL) + { + infoFound = TRUE; + sprintf(&tempBuf[len], + "<"TAG_MOUNTPOINT">%s", + parent_info->info.volume.mount_point); + len = strlen(tempBuf); + } + ZOS_evms_free(parent_info); + + /* try to get mount point from fstab */ + if (!infoFound && mountPointArray != NULL) + { + int idx; + BYTE *p; + + for (idx = 0; idx < mountPointArray->count; idx++) + { + /* check devices listed under "/dev" */ + p = (BYTE *)strstr((char *)(mountPointArray->mountPoints[idx].device), MSGNot("/dev/")); + if (p != NULL && p == mountPointArray->mountPoints[idx].device) + { + p += strlen(MSGNot("/dev/")); +// syslog(LOG_INFO, "device: %s", p); + if (!stricmp((char *)p, (char *)(segments->segment[i].name))) + { + sprintf(&tempBuf[len], + "<"TAG_MOUNTPOINT">%s", + mountPointArray->mountPoints[idx].path); + len = strlen(tempBuf); + break; + } + } + } + } + } + + sprintf(&tempBuf[len], "\n"); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto free_object; + } + } + } + } + +free_object: + ccode = VIRT_AddResultTag(virtInfo, TAG_PARTITIONS, TRUE, TRUE); + + if (mountPointArray != NULL) + { + free(mountPointArray); + } + if (segments != NULL) + { + free(segments); + } + return ccode; +} + + +/**************************************************************************** + * + * EVMS_DEV_GetDeviceInfo - This function retrieves device information and builds + * the XML for a specific device. + * + ****************************************************************************/ +STATUS EVMS_DEV_GetDeviceInfo( + VirtInfo_s *virtInfo, + utf8_t *devID) +{ + int ccode; + utf8_t tempBuf[4096] = ""; + handle_object_info_t *object_info = NULL; + storage_object_info_t *info = NULL; + object_handle_t object_handle; + object_handle_t segment_handle; + NINT objectType; + QUAD freeSpace; + NINT deviceType = DEVICE_PHYSICAL; + EvmsExtendInfo_s evmsExtInfo; + BOOL infoFound = FALSE; + NINT flags = 0; + NINT i; + NINT len = 0; + EvmsSegmentInfoArray_s *segments = NULL; + BYTE deviceName[zMAX_COMPONENT_NAME]; + extended_info_array_t *extended_info = NULL; + extended_info_array_t *extended_info2 = NULL; + QUAD elementSize; + + ASSERT_MPKNSS_LOCK(); + + ccode = evmsOpenEngine(EVMS_ENGINE_READONLY); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, TAG_GETDEVICEINFOSIMPLE, ccode, + MSGNot("Error opening evms engine. It might be opened by other application")); + return zOK; + } + + objectType = DISK; + ZOS_evms_get_object_handle_for_name(ccode, objectType, devID, &object_handle); + if (ccode != 0) + { + /* RAID device is listed as region type */ + objectType = REGION; + ZOS_evms_get_object_handle_for_name(ccode, objectType, devID, &object_handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object handle for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, TAG_GETDEVICEINFOSIMPLE, ccode, tempBuf); + goto close_engine; + } + } + + /* get object info */ + ZOS_evms_get_info(ccode, object_handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object info for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, TAG_GETDEVICEINFOSIMPLE, ccode, tempBuf); + goto close_engine; + } + + ccode = evmsGetExtendedInfo2(object_handle, (BYTE *)MSGNot("Flags"), &infoFound, + FALSE, &extended_info2, &evmsExtInfo); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object flags info for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, TAG_GETDEVICEINFOSIMPLE, ccode, tempBuf); + goto close_engine; + } + if (infoFound) + { + flags = evmsExtInfo.value.ui32; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_GETDEVICEINFOSIMPLE, FALSE, TRUE)) != zOK) + { + goto close_engine; + } + + ccode = evmsGetDeviceType(object_handle, &deviceType, NULL, &elementSize); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device type for %s: %s"), + devID, evmsGetErrString(ccode)); + goto free_object; + } + +// syslog(LOG_INFO, "object type: %d\n", objectType); + if (objectType == DISK) + { + info = &object_info->info.disk; + } + else if (objectType == REGION) + { + info = &object_info->info.region; + } + + freeSpace = 0; + if (deviceType == DEVICE_MIRROR) + { + /* raid 1 device doesn't have partition within it. If there's + * no pool created on top of it, it's free, get its size instead + */ + if (info->parent_objects == NULL || info->parent_objects->count == 0) + { + freeSpace = elementSize * EVMS_VSECTOR_SIZE; + } + } + else + { + if ((ccode = evmsGetDeviceSegments(info, TRUE, NULL, &freeSpace)) != 0) + { + sprintf(tempBuf, MSGNot("Error getting free space info for %s:"), + devID, evmsGetErrString(ccode)); + goto free_object; + } + } + + // All sizes are returned in bytes. + sprintf(tempBuf, + "<"TAG_NAME">%s" + "<"TAG_OBJECTID">%s" + "<"TAG_MAJORVERSION">%u" + "<"TAG_MINORVERSION">%u" + "<"TAG_TYPE">%u" + "<"TAG_SIZE">%Lu" + "<"TAG_FREESIZE">%Lu\n", + devID, + devID, + info->dev_major, + info->dev_minor, + 0, /* evms only list hard disks, i.e., MM_DIRECT_ACCESS_DEVICE */ + //info->size * info->geometry.bytes_per_sector, + info->size * EVMS_VSECTOR_SIZE, // sizes are always in 512 byte sizes. + freeSpace); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + sprintf(tempBuf, MSGNot("Error result data\n")); + goto free_object; + } + + if (info->flags & SOFLAG_CLUSTER_SHARED) +// if (flags & STATUS_SHARED) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_SHARED, "", FALSE)) != zOK) + { + strcpy(tempBuf, MSGNot("Error adding disk shared info")); + goto free_object; + } + } + + ccode = composeDeviceInfoPartitionList(virtInfo, info); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, TAG_PARTITIONS, ccode, MSGNot("Error getting device partitions.")); + /* keep going */ + ccode = 0; + } + + if (deviceType == DEVICE_RAID) + { + // it is a raid device + ccode = evmsGetExtendedInfo2(info->handle, (BYTE *)MSGNot("Raid Type"), &infoFound, + FALSE, &extended_info2, &evmsExtInfo); + if (ccode != 0) + { + strcpy(tempBuf, MSGNot("Error getting raid type")); + goto free_object; + } + sprintf(tempBuf, "<"TAG_RAIDTYPE">%u", evmsExtInfo.value.ui32); + len = strlen(tempBuf); + + ccode = evmsGetExtendedInfo2(info->handle, (BYTE *)MSGNot("Element Size"), &infoFound, + FALSE, &extended_info2, &evmsExtInfo); + if (ccode != 0) + { + strcpy(tempBuf, MSGNot("Error getting element size")); + goto free_object; + } + + sprintf(&tempBuf[len], "<"TAG_ELEMENTSIZE">%Lu", + (QUAD)(evmsExtInfo.value.ui64 * EVMS_VSECTOR_SIZE)); + len = strlen(tempBuf); + + ccode = evmsGetExtendedInfo2(info->handle, (BYTE *)MSGNot("Elements"), &infoFound, + FALSE, &extended_info2, &evmsExtInfo); + if (ccode != 0) + { + strcpy(tempBuf, MSGNot("Error getting elements")); + goto free_object; + } + + sprintf(&tempBuf[len], "<"TAG_ELEMENTCOUNT">%u", evmsExtInfo.value.ui32); + len = strlen(tempBuf); + + ccode = evmsGetExtendedInfo2(info->handle, (BYTE *)MSGNot("Stripe Size"), &infoFound, + FALSE, &extended_info2, &evmsExtInfo); + if (ccode != 0 || !infoFound) + { + if (!infoFound && ccode == 0) + { + ccode = -1; + } + strcpy(tempBuf, MSGNot("Error getting stripe size")); + goto free_object; + } + sprintf(&tempBuf[len], "<"TAG_STRIPESIZE">%u", + evmsExtInfo.value.ui32 * 1024); + len = strlen(tempBuf); + +// ccode = evmsGetExtendedInfo(info->handle, MSGNot("Restripe Flag"), &infoFound, &evmsExtInfo); +// if (ccode != 0 || !infoFound) +// { +// strcpy(tempBuf, MSGNot("Error getting restripe flag")); +// goto free_object; +// } + if (flags & STATUS_RESTRIPE_ENABLE) + { + sprintf(&tempBuf[len], "<"TAG_RESTRIPEENABLED">1"); + } + else + { + sprintf(&tempBuf[len], "<"TAG_RESTRIPEENABLED">0"); + } + + if (flags & STATUS_RESTRIPE) + { + sprintf(&tempBuf[len], "<"TAG_RESTRIPEFLAG">1"); + len = strlen(tempBuf); + } + else + { + sprintf(&tempBuf[len], "<"TAG_RESTRIPEFLAG">0"); + len = strlen(tempBuf); + } + /* Get individual element info */ + ZOS_evms_get_extended_info(ccode, info->handle, "Elements", &extended_info); + if (ccode != 0) + { + strcpy(tempBuf, MSGNot("Error getting mirror elements extended info")); + goto free_object; + } + + sprintf(&tempBuf[len], "<"TAG_SEGMENTINFO">"); + len += strlen(&tempBuf[len]); + + sprintf(&tempBuf[len], "<"TAG_NUMSEGMENTS">%d", + extended_info->count/2); + len += strlen(&tempBuf[len]); + + for (i = 0; i < extended_info->count;) + { + sprintf(&tempBuf[len], "<"TAG_SEGMENT">"); + len = strlen(tempBuf); + + /* first info is element name */ + ccode = evmsGetSegmentHandleByName((BYTE *)(extended_info->info[i].value.s), + &segment_handle, deviceName); + if (ccode == 0) + { + sprintf(&tempBuf[len], + MSGNot("<"TAG_DEVICENAME">%s" + "<"TAG_DEVICEID">%s" + "<"TAG_SEGMENTNAME">%s" + "<"TAG_SEGMENTID">%s"), + deviceName, deviceName, + extended_info->info[i].value.s, extended_info->info[i].value.s); + } + else + { + sprintf(&tempBuf[len], + MSGNot("<"TAG_DEVICENAME">" + "<"TAG_DEVICEID">" + "<"TAG_SEGMENTNAME">%s" + "<"TAG_SEGMENTID">%s"), + extended_info->info[i].value.s, extended_info->info[i].value.s); + } + len = strlen(tempBuf); + + /* second info is element "is active" */ + i++; + sprintf(&tempBuf[len], + MSGNot("<"TAG_RAIDACTIVE">%u"), + extended_info->info[i].value.b); + len = strlen(tempBuf); + + sprintf(&tempBuf[len], ""); + len = strlen(tempBuf); + + i++; + } + + ZOS_evms_free(extended_info); + + sprintf(&tempBuf[len], ""); + if ((ccode = VIRT_AddResultElement(virtInfo, TAG_DEVICERAID, tempBuf, TRUE)) != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, ccode, tempBuf); + goto free_object; + } + + } + + if (flags & STATUS_MIRRORED) + { + if ((ccode = VIRT_AddResultElement(virtInfo, TAG_MIRRORED, "", FALSE)) != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, ccode, tempBuf); + goto free_object; + } + } + + if (deviceType == DEVICE_MIRROR) + { + if (flags & STATUS_RAID_INSYNC) + { + sprintf(&tempBuf[len], "<"TAG_MIRRORGROUPSTATUS">1"); + } + else + { + sprintf(&tempBuf[len], "<"TAG_MIRRORGROUPSTATUS">0"); + } + len = strlen(tempBuf); + + // it is a raid device + ccode = evmsGetExtendedInfo2(info->handle, (BYTE *)MSGNot("Remirror Percent"), &infoFound, + FALSE, &extended_info2, &evmsExtInfo); + if (ccode != 0) + { + strcpy(tempBuf, MSGNot("Error getting remirror percent")); + goto free_object; + } + sprintf(&tempBuf[len], "<"TAG_MIRRORGROUPPERCENT">%u", evmsExtInfo.value.ui32); + len = strlen(tempBuf); + + ccode = evmsGetExtendedInfo2(info->handle, (BYTE *)MSGNot("Elements"), &infoFound, + FALSE, &extended_info2, &evmsExtInfo); + if (ccode != 0) + { + strcpy(tempBuf, MSGNot("Error getting elements")); + goto free_object; + } + sprintf(&tempBuf[len], "<"TAG_NUMMIRRORS">%u", evmsExtInfo.value.ui32); + len = strlen(tempBuf); + + /* Get individual element info */ + ZOS_evms_get_extended_info(ccode, info->handle, "Elements", &extended_info); + if (ccode != 0) + { + strcpy(tempBuf, MSGNot("Error getting mirror elements extended info")); + goto free_object; + } + + /* STATUS_RESTRIPE_ENABLE indicates if remirror is enabled for a mirror device */ + if (flags & STATUS_RESTRIPE_ENABLE) + { + sprintf(&tempBuf[len], "<"TAG_REMIRRORENABLED">1"); + } + else + { + sprintf(&tempBuf[len], "<"TAG_REMIRRORENABLED">0"); + } + len = strlen(tempBuf); + + sprintf(&tempBuf[len], "<"TAG_MIRRORINFO">"); + len = strlen(tempBuf); + + for (i = 0; i < extended_info->count;) + { + sprintf(&tempBuf[len], "<"TAG_SEGMENT">"); + len = strlen(tempBuf); + + ccode = evmsGetSegmentHandleByName((BYTE *)(extended_info->info[i].value.s), + &segment_handle, deviceName); + + if (ccode == 0) + { + /* first info is element name */ + sprintf(&tempBuf[len], + MSGNot("<"TAG_DEVICENAME">%s" + "<"TAG_DEVICEID">%s" + "<"TAG_SEGMENTNAME">%s" + "<"TAG_SEGMENTID">%s"), + deviceName, deviceName, + extended_info->info[i].value.s, extended_info->info[i].value.s); + } + else + { + sprintf(&tempBuf[len], + MSGNot("<"TAG_DEVICENAME">" + "<"TAG_DEVICEID">" + "<"TAG_SEGMENTNAME">%s" + "<"TAG_SEGMENTID">%s"), + extended_info->info[i].value.s, extended_info->info[i].value.s); + } + len = strlen(tempBuf); + + /* second info is element remirror percent */ + i++; + sprintf(&tempBuf[len], + MSGNot("<"TAG_MIRRORPERCENT">%u"), + extended_info->info[i].value.ui32); + len = strlen(tempBuf); + + /* third info is element "is active" */ + i++; + sprintf(&tempBuf[len], + MSGNot("<"TAG_MIRRORACTIVE">%u"), + extended_info->info[i].value.b); + len = strlen(tempBuf); + + /* fourth info is element "in sync" */ + i++; + sprintf(&tempBuf[len], + MSGNot("<"TAG_MIRRORSTATUS">%u"), + extended_info->info[i].value.b); + len = strlen(tempBuf); + + sprintf(&tempBuf[len], ""); + len = strlen(tempBuf); + + i++; + } + + ZOS_evms_free(extended_info); + + sprintf(&tempBuf[len], ""); + len = strlen(tempBuf); + + if ((ccode = VIRT_AddResultElement(virtInfo, TAG_DEVICEMIRROR, tempBuf, TRUE)) != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_DEVICEINFO, ccode, tempBuf); + goto free_object; + } + } + +/* fixfixfix */ +#if 0 + /* check if this device has multipath enabled */ + if(devGen.objectmanagerid == FailoverMgrID) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_MULTIPATH, "", FALSE)) != zOK) + { + goto exit; + } + } +#endif + + +free_object: + if (extended_info2 != NULL) + { + ZOS_evms_free(extended_info2); + } + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + if (segments != NULL) + { + free(segments); + } + + if (ccode ==0) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, tempBuf); + } + + VIRT_AddResultTag(virtInfo, TAG_GETDEVICEINFOSIMPLE, + TRUE, TRUE); + +close_engine: + + evmsCloseEngine(); + + return zOK; +} + +/**************************************************************************** + * + * This function gets a list of partition object IDs for a device + * + ****************************************************************************/ +STATUS Linux_getPartitionsOnDevice( + VirtInfo_s *virtInfo, + utf8_t *devID) +{ + int ccode; + LONG i; + utf8_t tempBuf[512] = ""; + EvmsSegmentInfoArray_s *segments = NULL; + NINT partitionType; + handle_object_info_t *object_info = NULL; + storage_object_info_t *info = NULL; + object_handle_t object_handle; + NINT objectType; + + + ccode = evmsOpenEngine(EVMS_ENGINE_READONLY); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, TAG_PARTITIONS, ccode, + MSGNot("Error opening evms engine. It might be opened by other application")); + return zOK; + } + + objectType = DISK; + ZOS_evms_get_object_handle_for_name(ccode, objectType, devID, &object_handle); + if (ccode != 0) + { + /* RAID device is listed as region type */ + objectType = REGION; + ZOS_evms_get_object_handle_for_name(ccode, objectType, devID, &object_handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object handle for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, TAG_PARTITIONS, ccode, tempBuf); + goto close_engine; + } + } + + /* get object info */ + ZOS_evms_get_info(ccode, object_handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object info for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, TAG_PARTITIONS, ccode, tempBuf); + goto close_engine; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PARTITIONS, + FALSE, TRUE)) != zOK) + { + goto close_engine; + } + +// syslog(LOG_INFO, "object type: %d\n", objectType); + if (objectType == DISK) + { + info = &object_info->info.disk; + } + else if (objectType == REGION) + { + info = &object_info->info.region; + } + + if ((ccode = evmsGetDeviceSegments(info, TRUE, &segments, NULL)) != 0) + { + sprintf(tempBuf, MSGNot("Error getting free space info for %s: %s"), + devID, evmsGetErrString(ccode)); + goto free_object; + } + + if (segments == NULL) + { + goto free_object; + } + + for(i = 0; i < segments->count; i++) + { + if (segments->segment[i].data_type != DATA_TYPE) + { + continue; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PARTITION, + FALSE, TRUE)) != zOK) + { + goto free_object; + } + + evmsGetSegmentType(segments->segment[i].handle, + segments->segment[i].data_type, + &partitionType); + sprintf(tempBuf, + "<"TAG_PARTITIONID">%s" + "<"TAG_PARTITIONTYPE">%u\n", + segments->segment[i].name, + partitionType & 0xFF); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto free_object; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PARTITION, + TRUE, TRUE)) != zOK) + { + goto free_object; + } + } + +free_object: + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + if (segments != NULL) + { + free(segments); + } + + if (ccode ==0) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, tempBuf); + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PARTITIONS, + TRUE, TRUE)) != zOK) + { + goto free_object; + } + +close_engine: + evmsCloseEngine(); + + return zOK; +} + +LONG getPoolInfoFromObjectHandle( + object_handle_t handle, + BOOL *poolFound, + BYTE *poolName, + BOOL *shared, /* can be NULL */ + BOOL *mounted, /* can be NULL */ + BOOL *state) /* can be NULL */ +{ + LONG ccode; + handle_object_info_t *parent_info = NULL; + BOOL infoFound; + EvmsExtendInfo_s evmsExtInfo; + zInfo_s info; + NINT errIndex; + NINT getInfoMask; + BYTE path[zMAX_FULL_NAME]; + + *poolFound = FALSE; + + /* try to get mount point from evms first */ + ccode = evmsGetTopMostParentInfo(handle, &parent_info); + if (ccode != 0 || parent_info == NULL) + { + goto free_object; + } + +// syslog(LOG_INFO, "parent_info type: %d", parent_info->type); + + if (parent_info->type == VOLUME) + { + if (mounted) + { + *mounted = FALSE; + } + if (state) + { + *state = zVOLSTATE_UNKNOWN; + } + if (shared) + { + *shared = FALSE; + } + infoFound = FALSE; + + /* name got from parent_info->info.volume.name is something like + * /dev/evms/POOL0, we just need POOL0 instead + */ + ccode = evmsGetPoolNameFromExtendInfo(handle, + poolFound, poolName); + if (ccode != 0) + { + goto free_object; + } + + if (*poolFound) + { +// syslog(LOG_INFO, "pool name: %s", poolName); + } + } + else + { + goto free_object; + } + + if (mounted && parent_info->info.volume.mount_point != NULL) + { + *mounted = TRUE; + } + + /* get pool state */ + if (state && *poolFound) + { + sprintf((char *)path, "%s%s", ADMIN_POOL_PATH, poolName); + getInfoMask = zGET_POOL_INFO; + +// syslog(LOG_INFO, "path: %s", path); + + if ((ccode = GetZInfo(path, getInfoMask, &info, &errIndex)) != zOK) + { + goto free_object; + } + *state = info.pool.poolState; + } + + if (shared) + { +// syslog(LOG_INFO, "get flags"); + + /* get shared info, it can be find in logical partition */ + ccode = evmsGetExtendedInfo(parent_info->info.volume.object, (BYTE *)MSGNot("Flags"), + &infoFound, &evmsExtInfo); + if (ccode != 0) + { + goto free_object; + } + + /* Check if device is shared */ + if (infoFound) + { + // if (info->flags & SOFLAG_CLUSTER_SHARED) + if (evmsExtInfo.value.ui32 & STATUS_SHARED) + { + *shared = TRUE; + } + } + } + +free_object: + if (parent_info != NULL) + { + ZOS_evms_free(parent_info); + } + + return ccode; +} + +void composeDevicePoolInfo( + utf8_t *tempBuf, + BYTE *poolName, + BOOL shared, + BOOL mounted, + BOOL poolState) +{ + NINT len; + + sprintf(tempBuf, + "<"TAG_POOLSIMPLEINFO">" + "<"TAG_POOLNAME">%s", + poolName); + len = strlen(tempBuf); + + if (mounted) + { + sprintf(&tempBuf[len], "<"TAG_POOLSTATE">%s", TAG_MOUNT); + } + else + { + sprintf(&tempBuf[len], "<"TAG_POOLSTATE">%s", + MLIB_GetPoolStateName(poolState)); + } + len = strlen(tempBuf); + + if (shared) + { + sprintf(&tempBuf[len], "<"TAG_SHARED"/>"); + len = strlen(tempBuf); + } + + sprintf(&tempBuf[len], ""); + + return; +} + +/**************************************************************************** + * + * This function gets a list of pool object IDs for a device + * + ****************************************************************************/ +STATUS Linux_getPoolsOnDevice( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *devID) +{ + LONG ccode; + LONG i, j; + utf8_t tempBuf[512] = ""; + EvmsSegmentInfoArray_s *segments = NULL; + handle_object_info_t *object_info = NULL; + storage_object_info_t *info = NULL; + object_handle_t object_handle; + NINT objectType; + NINT deviceType; + BOOL infoFound; + BYTE poolName[zMAX_COMPONENT_NAME]; + BOOL shared; + BOOL poolState; + BOOL mounted; + + ccode = evmsOpenEngine(EVMS_ENGINE_READONLY); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error opening evms engine. It might be opened by other application")); + return zOK; + } + + objectType = DISK; + ZOS_evms_get_object_handle_for_name(ccode, objectType, devID, &object_handle); + if (ccode != 0) + { + /* RAID device is listed as region type */ + objectType = REGION; + ZOS_evms_get_object_handle_for_name(ccode, objectType, devID, &object_handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object handle for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + ccode = evmsGetDeviceType(object_handle, &deviceType, NULL, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device type for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + } + + /* get object info */ + ZOS_evms_get_info(ccode, object_handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object info for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + /* Raid 1 device is different from other devices in terms of getting + * pool info + */ + if (deviceType == DEVICE_MIRROR) + { + ccode = getPoolInfoFromObjectHandle(object_handle, &infoFound, + poolName, &shared, &mounted, &poolState); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting mirror device pool info: %s"), + evmsGetErrString(ccode)); + goto close_engine; + } + if (infoFound) + { +// syslog(LOG_INFO, "pool name: %s\n", poolName); + + composeDevicePoolInfo(tempBuf, poolName, shared, mounted, poolState); + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + ccode = VIRT_AddResultData(virtInfo, tempBuf); + } + goto exit; + } + +// syslog(LOG_INFO, "object type: %d\n", objectType); + if (objectType == DISK) + { + info = &object_info->info.disk; + } + else if (objectType == REGION) + { + info = &object_info->info.region; + } + + if ((ccode = evmsGetDeviceSegments(info, TRUE, &segments, NULL)) != 0) + { + sprintf(tempBuf, MSGNot("Error getting free space info for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + if (segments == NULL) + { + goto exit; + } + + /* We will store pool name in segment.name area, since this function + * doesn't need segment name. This way we can keep track of pool + * name to avoid send back duplicated information + */ + for(i = 0; i < segments->count; i++) + { + segments->segment[i].name[0] = '\0'; + } + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + + /* If it is a physical device, we shouldn't include segments that are + * used for RAID device + */ + for(i = 0; i < segments->count; i++) + { + if (segments->segment[i].data_type != DATA_TYPE) + { + continue; + } + + ccode = getPoolInfoFromObjectHandle(segments->segment[i].handle, + &infoFound, poolName, &shared, &mounted, &poolState); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting pool info from segment: %s"), + evmsGetErrString(ccode)); + continue; + } + + if (infoFound) + { + BOOL duplicate = FALSE; + +// syslog(LOG_INFO, "pool name: %s shared=%d mounted=%d poolstate=%d\n", poolName, shared, mounted, poolState); + + /* check if previous segments have the same pool name */ + for (j = 0; j < i; j++) + { + if (!strcmp((char *)(segments->segment[j].name), (char *)poolName)) + { + duplicate = TRUE; + break; + } + } + + if (!duplicate) + { + strcpy((char *)(segments->segment[i].name), (char *)poolName); + composeDevicePoolInfo(tempBuf, poolName, shared, mounted, poolState); + ccode = VIRT_AddResultData(virtInfo, tempBuf); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error adding device pools data")); + goto exit; + } + } + } + } + +exit: + if(ccode == zOK) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, tempBuf); + } + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +close_engine: + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + if (segments != NULL) + { + free(segments); + } + + evmsCloseEngine(); + + + return zOK; +} + +LONG linuxInitializeDevice( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *devID) +{ + LONG ccode; + LONG i; + utf8_t tempBuf[512] = ""; + EvmsSegmentInfoArray_s *segments = NULL; + handle_object_info_t *object_info = NULL; + storage_object_info_t *info = NULL; + object_handle_t object_handle; + object_handle_t parent_handle = 0; + NINT objectType; + BOOL repeat; + utf8_t name[zMAX_COMPONENT_NAME]; +// object_handle_t regionHandle; /* return -1 if no parent region found */ + NINT regionType; +// QUAD regionSize; + handle_object_info_t *parent_info = NULL; + utf8_t *parent_name = NULL; + NINT deviceType; + NINT prevNumSegs; + int fd, rc; + + objectType = DISK; + deviceType = DEVICE_PHYSICAL; + ZOS_evms_get_object_handle_for_name(ccode, objectType, devID, &object_handle); + if (ccode != 0) + { + /* RAID device is listed as region type */ + objectType = REGION; + ZOS_evms_get_object_handle_for_name(ccode, objectType, devID, &object_handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object handle for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + + ccode = evmsGetDeviceType(object_handle, &deviceType, NULL, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device type for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + + if (deviceType == DEVICE_MIRROR) + { + ccode = -1; + sprintf(tempBuf, MSGNot("Error mirror device can't be initialized: %s"), + devID); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + } + + /* get object info */ + do + { + ZOS_evms_get_info(ccode, object_handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object info for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + +//syslog(LOG_INFO, "xxxx during get info -- object type: %d\n", objectType); + if (objectType == DISK) + { + info = &object_info->info.disk; + } + else if (objectType == REGION) + { + info = &object_info->info.region; + } + + repeat = FALSE; + if ((ccode = evmsGetDeviceSegments(info, TRUE, &segments, NULL)) != 0) + { + sprintf(tempBuf, MSGNot("Error getting segments info for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + + if (segments == NULL) + { + /* no more segments */ + break; + } + +// syslog(LOG_INFO, "object type: %d\n", objectType); +// if (objectType == DISK) +// { +// /* need to keep segments that make up a virtual device */ +// for (i = 0; i < segments->count; i++) +// { +// if (segments->segment[i].data_type == DATA_TYPE) +// { +// ccode = evmsGetParentRegion(segments->segment[i].handle, ®ionHandle, +// ®ionType, name, ®ionSize); +// if (ccode != 0) +// { +// sprintf(tempBuf, MSGNot("Error getting segment region info for %s: %s"), +// segments->segment[i].name, evmsGetErrString(ccode)); +// MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); +// goto Exit; +// } +// +//// syslog(LOG_INFO, "segment name: %s, region type: %d, region handle: %d\n", +//// segments->segment[i].name, regionType, regionHandle); +// if (regionHandle != -1 && regionType == REGION_RAID) +// { +// syslog(LOG_INFO, "segment name: %s, region name: %s\n", segments->segment[i].name, name); +// +// segments->segment[i].handle = 0; +// } +// } +// } +// } + + for(i = 0; i < segments->count; i++) + { + if (segments->segment[i].handle == 0) + { + continue; + } + + if (segments->segment[i].data_type != DATA_TYPE) + { + continue; + } + +// syslog(LOG_INFO, "xxxx segment name: %s\n", segments->segment[i].name); + + ccode = evmsGetTopMostParentInfo(segments->segment[i].handle, &parent_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting top most parent info for %s: %s"), + segments->segment[i].name, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + if (parent_info == NULL) + { + continue; + } + if (parent_info->type == SEGMENT && parent_info->info.segment.data_type != DATA_TYPE) + { + continue; + } + +// syslog(LOG_INFO, "xxxx parent type: %d\n", parent_info->type); + + if (parent_info->type == DISK || parent_info->type == SEGMENT || + parent_info->type == EVMS_OBJECT) + { + parent_handle = parent_info->info.segment.handle; + parent_name = parent_info->info.segment.name; + } + else if (parent_info->type == REGION) + { + parent_handle = parent_info->info.region.handle; + parent_name = parent_info->info.region.name; + + ccode = evmsGetRegionInfo(parent_handle, ®ionType, NULL, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting region info for %s: %s"), + parent_name, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + + if (regionType == REGION_RAID || regionType == REGION_MIRROR) + { + /* need to clean up everything that is created on this device */ + if ((ccode = linuxRemoveRaid2(tagName, virtInfo, parent_name, + parent_handle) != 0)) + { + goto Exit; + } + else + { + ZOS_evms_free(parent_info); + parent_info = NULL; + repeat = TRUE; + break; + } + } + } + else if (parent_info->type == VOLUME) + { + NINT poolFound = FALSE; + + /* it has to be top most parent, name in parent_info->info.volume.name is + * something like /dev/evms/POOL0, we only need POOL0 here */ + ccode = evmsGetPoolNameFromExtendInfo(segments->segment[i].handle, + &poolFound, (BYTE *)name); + if (ccode != 0) + { + goto Exit; + } + + if (poolFound) + { + ccode = removePoolSimple(tagName, virtInfo, FALSE, name, FALSE); + if (ccode != 0) + { + goto Exit; + } + repeat = TRUE; + } + + ZOS_evms_free(parent_info); + parent_info = NULL; + break; + } + else + { + parent_handle = parent_info->info.container.handle; + parent_name = parent_info->info.container.name; + } + + ZOS_evms_free(parent_info); + parent_info = NULL; + +// syslog(LOG_INFO, "parent name: %s\n", parent_name); + + ccode = evmsDestroyObjectByHandle(parent_handle, FALSE); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error destroying %s's parent %s: %s"), + segments->segment[i].name, parent_name, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + repeat = TRUE; + + break; + } + + free(segments); + segments = NULL; + + ZOS_evms_free(object_info); + object_info = NULL; + +// syslog(LOG_INFO, "repeat: %d\n", repeat); + } while (repeat); + + // + // Cleanup any segments that only have free segments as children + // + prevNumSegs = 0; + do + { + ZOS_evms_get_info(ccode, object_handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object info for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + + if (objectType == DISK) + { + info = &object_info->info.disk; + } + else if (objectType == REGION) + { + info = &object_info->info.region; + } + + if ((ccode = evmsGetDeviceSegments(info, TRUE, &segments, NULL)) != 0) + { + sprintf(tempBuf, MSGNot("Error getting segments info for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + + if (segments == NULL) + { + /* no more segments */ + break; + } + + if (prevNumSegs == segments->count) + { + /* nothing is being deleted */ + break; + } + + prevNumSegs = segments->count; + for (i = 0; i < segments->count; i++) + { + (void)emvsDestroyFreeSegement(segments->segment[i].handle); + } + free(segments); + segments = NULL; + ZOS_evms_free(object_info); + object_info = NULL; + } while (repeat); + + /* Now that everything is deleted, write out the MBR */ + sprintf(name, "/dev/evms/.nodes/%s",devID); + fd = open(name, O_RDWR, 0); + if (fd <= 0) { + ccode = errno; + sprintf(tempBuf, MSGNot("Error %d opening device %s : %s"), errno, devID, strerror(errno)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } else { + /* Initialize the boot record */ + memset(tempBuf, 0, 512); + memcpy(tempBuf, BootStart, sizeof(BootStart) ); + tempBuf[510] = 0x55; + tempBuf[511] = 0xAA; + + rc = write(fd, tempBuf, 512); + if (rc < 0) { + ccode = errno; + sprintf(tempBuf, MSGNot("Error %d writing to device %s : %s"), errno, devID, strerror(errno)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + } + + /* Erase any LVM label at sector 1 */ + memset(tempBuf, 0, 512); + rc = write(fd, tempBuf, 512); + if (rc < 0) { + ccode = errno; + sprintf(tempBuf, MSGNot("Error %d writing to device %s : %s"), errno, devID, strerror(errno)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + } + + close(fd); + } + + +Exit: + if (parent_info != NULL) + { + ZOS_evms_free(parent_info); + } + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + if (segments != NULL) + { + free(segments); + } + + return ccode; +} + +/* it is a dangerous action */ +STATUS Linux_initializeDevice( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *devID) +{ + LONG ccode; + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error opening evms engine. It might be opened by other application")); + return zOK; + } + + if (linuxInitializeDevice(tagName, virtInfo, devID) == 0) + { + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + } + + evmsCloseEngine(); + + return zOK; +} + + +STATUS addPoolNameToArray( + BYTE **poolArray, /* first byte stores pool name count */ + BYTE *poolName) +{ + NINT poolCount = 0; + NINT i; + BYTE *p = NULL; + BYTE *temp = NULL; + + /* check for duplicates */ + if (*poolArray != NULL) + { + poolCount = **poolArray; + p = *poolArray + 1; + + for (i = 0; i < poolCount; i++, p += EVMS_NAME_SIZE + 1) + { + if (!strcmp ((char *)p, (char *)poolName)) + { + return 0; + } + } + } + + if (*poolArray == NULL) + { + *poolArray = malloc(EVMS_NAME_SIZE + 1); + } + else + { + temp = *poolArray; + *poolArray = realloc(*poolArray, (poolCount + 1) * (EVMS_NAME_SIZE + 1)); + } + + if (*poolArray == NULL) + { + free(temp); + return zERR_NO_MEMORY; + } + + **poolArray = poolCount + 1; + + p = *poolArray + 1 + poolCount * (EVMS_NAME_SIZE + 1); + strcpy((char *)p, (char *)poolName); + + return 0; +} + +LONG getPoolNamesFromDevice( + object_handle_t object_handle, + NINT deviceType, + BYTE **poolArray) +{ + LONG ccode; + LONG i; + EvmsSegmentInfoArray_s *segments = NULL; + handle_object_info_t *object_info = NULL; + storage_object_info_t *info; + BOOL infoFound; + BYTE poolName[EVMS_NAME_SIZE + 1]; + object_handle_t regionHandle; + NINT regionType; + + + ZOS_evms_get_info(ccode, object_handle, &object_info); + if (ccode != 0) + { + goto exit; + } + + if (deviceType == DEVICE_PHYSICAL) + { + info = &object_info->info.disk; + } + else + { + info = &object_info->info.region; + } + + if (deviceType == DEVICE_MIRROR) + { + /* mirror device doesn't have any type of partition */ + if (info->parent_objects != NULL && info->parent_objects->count != 0) + { + ccode = getPoolInfoFromObjectHandle(object_handle, &infoFound, poolName, + NULL, NULL, NULL); + if (ccode != 0) + { + goto exit; + } + + if (infoFound) + { + ccode = addPoolNameToArray(poolArray, poolName); + } + + } + goto exit; + } + + /* Physical device or raid device segments */ + ccode = evmsGetDeviceSegments(info, TRUE, &segments, NULL); + if (ccode != 0) + { + goto exit; + } + if(segments == NULL ) + { + goto exit; + } + for (i = 0; i < segments->count; i++) + { + if (segments->segment[i].data_type == DATA_TYPE) + { + ccode = evmsGetParentRegion(segments->segment[i].handle, ®ionHandle, + ®ionType, NULL, NULL); + if (ccode != 0) + { + goto exit; + } + + if (regionHandle != -1) + { + if (regionType == REGION_MIRROR) + { + ccode = getPoolNamesFromDevice(regionHandle, DEVICE_MIRROR, poolArray); + if (ccode != 0) + { + goto exit; + } + } + else if (regionType == REGION_RAID) + { + ccode = getPoolNamesFromDevice(regionHandle, DEVICE_RAID, poolArray); + if (ccode != 0) + { + goto exit; + } + } + else if (regionType == REGION_LOGICALPARTITION) + { + ccode = getPoolInfoFromObjectHandle(segments->segment[i].handle, &infoFound, poolName, + NULL, NULL, NULL); + if (ccode != 0) + { + goto exit; + } + + if (infoFound) + { + ccode = addPoolNameToArray(poolArray, poolName); + if (ccode != 0) + { + goto exit; + } + } + } + } + } + } + +exit: + if (object_info) + { + ZOS_evms_free(object_info); + } + + if (segments) + { + free(segments); + } + return ccode; +} + +STATUS Linux_modifyDevice( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *devID, + BOOL shared) +{ + LONG ccode; + STATUS status; + LONG i; + utf8_t tempBuf[512] = ""; + EvmsSegmentInfoArray_s *segments = NULL; + handle_object_info_t *object_info = NULL; + object_handle_t object_handle; + plugin_handle_t plugin_handle; + value_t value; + NINT partitionType; + utf8_t *poolArray = NULL; + NINT poolCount = 0; + utf8_t *poolName; + BOOL changed; + NINT savedPoolState; + UserID_t guid; + utf8_t *errorString; + utf8_t *retContainer = NULL; + utf8_t *retName = NULL; + utf8_t *ndsName = NULL; + utf8_t *srvName = NULL; + utf8_t *srvContainer = NULL; + utf8_t *container = NULL; + unicode_t *uniPoolName = NULL; + zInfo_s poolInfo; + VolumeID_t poolID; + BOOL emptyDevice = TRUE; + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error opening evms engine. It might be opened by other application")); + return zOK; + } + + /* only physical disk is allowed to change shared status */ + ZOS_evms_get_object_handle_for_name(ccode, DISK, devID, &object_handle); + if (ccode != 0) + { + ZOS_evms_get_object_handle_for_name(ccode, REGION, devID, &object_handle); + if (ccode == 0) + { + MNSS_ReturnResult(virtInfo, tagName, -1, MSGNot("Error only physical device can be modified")); + } + else + { + sprintf(tempBuf, MSGNot("Error getting device handle for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + } + goto close_engine; + } + + ZOS_evms_get_plugin_by_name(ccode, PLUGIN_NWSEGMGR, &plugin_handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting segment plugin handle: %s"), + evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + ZOS_evms_get_info(ccode, object_handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object info for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + /* check if shared state needs to be changed */ + if (((object_info->info.disk.flags & SOFLAG_CLUSTER_SHARED) && shared) + || (!(object_info->info.disk.flags & SOFLAG_CLUSTER_SHARED) && !shared)) + { + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + goto close_engine; + } + + ccode = getPoolNamesFromDevice(object_handle, DEVICE_PHYSICAL, (BYTE **)&poolArray); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting pools from device for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + if (poolArray != NULL) + { + poolCount = *poolArray; + poolName = poolArray + 1; + +//syslog(LOG_INFO, "Linux_modifyDevice -- **********poolCount: %d", poolCount); + for (i = 0; i < poolCount; i++, poolName += EVMS_NAME_SIZE + 1) + { +//syslog(LOG_INFO, "Linux_modifyDevice -- Found pool: %s", poolName); + /* Test if this is a cluster pool */ + if (NWCLSTR_IsClusterEnabled((BYTE *)poolName, POOL_INQUIRY, NULL, 0) == CLSTR_RESOURCE_FOUND) + { + /* Fail the whole operation because we don't want to share enable + a pool when a cluster pool object already exists with the same + name and we don't want to disable sharing when a pool is + cluster enabled on the device. */ + MNSS_ReturnResult(virtInfo, tagName, zERR_NWCS_SHARE_VIOLATION, + MSGNot("Cluster sharing violation")); + goto close_engine; + } + } + } + + /* now change disk's shared status */ + ccode = evmsGetDeviceSegments(&object_info->info.disk, TRUE, &segments, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device segments for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + if (segments == NULL) + { + ccode = -1; + sprintf(tempBuf, MSGNot("Error no device segment found for %s: Device either " + "uninitialized or malfunctioning."), + devID); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + changed = FALSE; + + /* try to modify device through data_type segments first */ + /* 01-07-2005 Allen said we should do this way: + * If there's any data_type segments that are NSS type, virtual device type, + * or SBD type that has NetWare bit in its flag, we'll try to set shared bit + * on one of them. If can't find any of them, we will try to set shared bit + * on a free_space_type segment, even though there are other data_type + * segments created on the device (not managed by NSS or SBD with no NetWare bit). + */ + for (i = 0; i < segments->count; i++) + { + /* check if this segment is managed by NSS */ + if (segments->segment[i].data_type == DATA_TYPE) + { + emptyDevice = FALSE; + if (segments->segment[i].plugin == plugin_handle) + { + /* Get the partition type */ + ccode = evmsGetSegmentType(segments->segment[i].handle, + segments->segment[i].data_type, &partitionType); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting segment type for %s: %s"), + segments->segment[i].name, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + if (partitionType != NSS_PARTITION && + partitionType != VIRTUAL_DEVICE_PARTITION && + partitionType != SBD_PARTITION) + { /* if not a Novell partition then skip it */ + continue; + } + + if (partitionType == SBD_PARTITION) + { + BOOL infoFound = FALSE; + EvmsExtendInfo_s evmsExtInfo; + + ccode = evmsGetExtendedInfo(segments->segment[i].handle, (BYTE *)MSGNot("Flags"), + &infoFound, &evmsExtInfo); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting segment flags for %s: %s"), + segments->segment[i].name, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + if (!infoFound || !(evmsExtInfo.value.ui32 & STATUS_NETWARE)) + { + continue; + } + } + + value.b = shared; + ccode = evmsChangeObjectValue(segments->segment[i].handle, SEG_CHANGE_SHARED, + (BYTE *)MSGNot("Shared"), &value, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error changing shared state for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + changed = TRUE; + break; + } + } + } + + /* try to change the shared bit through free space partition if it is + * managed by nwsegmgr + */ + + /* change the segment manager if device is empty */ + if (!changed && emptyDevice && object_info->info.disk.plugin != plugin_handle) + { + ZOS_evms_unassign(ccode, object_handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error unassigning segment manager for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + ZOS_evms_commit_changes(ccode); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error committing segment manager change for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + ZOS_evms_assign(ccode, object_handle, plugin_handle, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error unassigning segment manager for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + ZOS_evms_commit_changes(ccode); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error committing segment manager change for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + free(segments); + segments = NULL; + ZOS_evms_free(object_info); + + ZOS_evms_get_info(ccode, object_handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object info for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + ccode = evmsGetDeviceSegments(&object_info->info.disk, TRUE, &segments, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device segments for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + if (segments == NULL) + { + ccode = -1; + sprintf(tempBuf, MSGNot("Error no device segment found for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + } + + /* If device doesn't have NSS, virtual device, or SBD with NetWare bit partitions, + * modify device through free_space_type */ + if (!changed) + { + for (i = 0; i < segments->count; i++) + { + if (segments->segment[i].data_type == FREE_SPACE_TYPE && + segments->segment[i].plugin == plugin_handle) + { + value.b = shared; + ccode = evmsChangeObjectValue(segments->segment[i].handle, SEG_CHANGE_SHARED, + (BYTE *)MSGNot("Shared"), &value, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error changing shared state for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + changed = TRUE; + break; + } + } + } + + /* create a small NSS partition and sets device shared bit through it */ + if (!changed) + { + NINT oneMB = 1024 * 1024; + object_handle_t newPartitionHandle; + + for (i = 0; i < segments->count; i++) + { + if (segments->segment[i].data_type != FREE_SPACE_TYPE) + { + continue; + } + + if (segments->segment[i].size < oneMB) + { + continue; + } + + ccode = evmsAddPartition(segments->segment[i].handle, + oneMB / EVMS_VSECTOR_SIZE, + getPartitionTypeNameByValue(NSS_PARTITION | 0x100), + (BYTE *)"shared", &newPartitionHandle); + + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error creating an NSS partition for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + value.b = shared; + ccode = evmsChangeObjectValue(newPartitionHandle, SEG_CHANGE_SHARED, + (BYTE *)MSGNot("Shared"), &value, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error changing shared state for %s: %s"), + devID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + changed = TRUE; + break; + } + } + + if (!changed) + { + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + goto close_engine; + } + + /* If the share state for a device has been changed we need to do some other updates */ + if (poolArray != NULL) + { + /* Allocate memory for all the names we will need */ + ndsName = malloc(zMAX_COMPONENT_NAME); + srvName = malloc(zMAX_COMPONENT_NAME); + srvContainer = malloc(zMAX_COMPONENT_NAME); + container = malloc(zMAX_COMPONENT_NAME); + uniPoolName = malloc(zMAX_COMPONENT_NAME * sizeof(unicode_t)); + + /* If any of the allocations failed we cannot continue */ + if ((ndsName == NULL) || (srvName == NULL) || (srvContainer == NULL) + || (container == NULL) || (uniPoolName == NULL)) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_MEMORY, + MSGNot("Failed to allocate memory for modify device pool operations")); + ccode = zERR_NO_MEMORY; + goto close_engine; + } + + /* Get the server name for later use in forming pool names */ + if ((status = MNDS_GetServerNameFromNDS(srvName, srvContainer)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error Getting Server Name from NDS")); + goto close_engine; + } + + poolName = poolArray + 1; + + for (i = 0; i < poolCount; i++, poolName += EVMS_NAME_SIZE + 1) + { + /* Get the pool id */ + if (utf2uni(poolName, uniPoolName, zMAX_COMPONENT_NAME) == -1) + { + sprintf(tempBuf, MSGNot("Error converting pool %s to unicode name"), poolName); + MNSS_ReturnResult(virtInfo, tagName, -1, tempBuf); + goto close_engine; + } + + status = GetPoolID(uniPoolName, &poolID); + if (status != zOK) + { + sprintf(tempBuf, MSGNot("Error finding pool %s in NSS"), poolName); + MNSS_ReturnResult(virtInfo, tagName, status, tempBuf); + goto close_engine; + } + + /* Get the current pool object name... */ + if ((status = MNSS_GetPoolNDSName(poolName, + ndsName, container, &guid, &errorString)) != zOK) + { + /* ...or generate the default pool name */ + strcpy(ndsName, srvName); + strcat(ndsName, "_"); + strcat(ndsName, poolName); + strcat(ndsName, "_POOL"); + strcpy(container, srvContainer); + } + + /* Delete any existing pool object */ + MNDS_RemoveObjectFromNDS(container, ndsName, "nssfsPool"); + + /* Create the pool object */ + if ((status = MNDS_AddPoolToNDS(virtInfo, container, + ndsName, poolName, + &poolID, shared, &poolInfo.pool.ndsObjectID, + &retContainer, &retName, NULL)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error adding pool to NDS")); + goto close_engine; + } + + /* The pool must be active to modify the GUID of a shared pool */ + savedPoolState = GetPoolState(uniPoolName); + if (savedPoolState != zVOLSTATE_ACTIVE) + { + if ((status = ChangePoolState(uniPoolName, + zVOLSTATE_ACTIVE, VOLMODE_OVERRIDE_SHARED)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error activating pool to set NDS object's GUID")); + goto close_engine; + } + } + + /* Store the DS object GUID in the pool */ + if ((status = SetNDSInfoOnPool(uniPoolName, &poolInfo)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error setting pool's NDS object GUID")); + goto close_engine; + } + + /* De-activate the pool if it was not active when we started */ + if (savedPoolState != zVOLSTATE_ACTIVE) + { + /* ignore any error */ + ChangePoolState(uniPoolName, savedPoolState, VOLMODE_OVERRIDE_SHARED); + } + } + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +close_engine: + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + if (poolArray != NULL) + { + free(poolArray); + } + + if (segments != NULL) + { + free(segments); + } + + if (retContainer != NULL) + { + free(retContainer); + } + if (retName != NULL) + { + free(retName); + } + if (ndsName != NULL) + { + free(ndsName); + } + if (srvName != NULL) + { + free(srvName); + } + if (srvContainer != NULL) + { + free(srvContainer); + } + if (container != NULL) + { + free(container); + } + if (uniPoolName != NULL) + { + free(uniPoolName); + } + + evmsCloseEngine(); + + + return zOK; +} + +#endif + diff --git a/src/nwnss/sharedsrc/manageNDS.c.h b/src/nwnss/sharedsrc/manageNDS.c.h new file mode 100644 index 0000000..f2981fc --- /dev/null +++ b/src/nwnss/sharedsrc/manageNDS.c.h @@ -0,0 +1,3426 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2006-12-30 03:27:16 +0530 (Sat, 30 Dec 2006) $ + | + | $RCSfile$ + | $Revision: 1799 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage NSS using XML + | + +-------------------------------------------------------------------------*/ +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +#include /* NetWare */ +#endif +#include +#include +#include +#include +#if zLINUX && !defined(__KERNEL__) +#define stricmp(p1,p2) strcasecmp(p1,p2) +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +extern void syslog(int __pri, __const char *__fmt, ...) + __attribute__ ((__format__(__printf__, 2, 3))); +#define MPKNSS_LOCK() ((void) 0) +#define MPKNSS_UNLOCK() ((void) 0) +#define ASSERT_MPKNSS_LOCK() ((void) 0) +#undef zASSERT +#define zASSERT(_e_) ((void) 0) +#define MANAGE_ModuleHandle getpid() +#endif +#if zLINUX && defined(__KERNEL__) +#include +#include +#endif +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +#include +#include +#endif +#include +#include + +#include + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +//#ifndef __linux__ +//#include +//#endif +#endif + +#include "manage.h" +#include "manageNlm.h" +#include "manageNDS.h" +#include "mgmt.h" +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +#include "manageVolume.h" +#endif +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +#include "manageStartup.h" +#endif +#include "comnPublics.h" +#include "nssPubs.h" +#include "virtualIO.h" +#include "xmlTags.h" +#include "sysimp.h" +#include "comnAuthorize.h" +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +#include "comnZAS.h" +#include "msgName.h" +#include "dirQuotas.h" +#endif +#include "utc.h" +#include "eDir.h" + +/* In manageVolMN.c: */ +extern STATUS ConnectToVolMan(void **session); +extern STATUS DisconnectFromVolMan(void *session); +extern STATUS (*volManMapVolumeToGUID)(void *handle, + unicode_t *volumeName, + GUID_t *volumeGUID); + +#if zLINUX +#if !defined(__KERNEL__) +#define VOL_MOUNT_POINT_FIELD "linuxNCPMountPoint" +#endif + +extern int NCSetDefaultIdentity(int nsType, int idHandle); +extern int NCRemoveIdentity(int idHandle); + +extern int DDCSetContextIdentity(int context, int idHandle); +extern int DDCAddIdentity(long taskID, const unicode *dn, uint32 periodBegin, + uint32 periodEnd, const char *certificate, + const char *privateKey, int *idHandle); +#endif + +/* Manifest constants */ +#define NWCLSTR_IsClusterEnabledAPI "\x18NWCLSTR_IsClusterEnabled" +#define NWCLSTR_IsClusterEnabledAPI_LNX "NWCLSTR_IsClusterEnabled" +#define NWCLSTR_ClusterNameAPI "\x13""NWCLSTR_ClusterName" +#define NWCLSTR_ClusterNameAPI_LNX "NWCLSTR_ClusterName" + +STATUS MNDS_ProcessGetAttribute(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNDS_ProcessAddUser(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNDS_ProcessRemoveObject(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNDS_ProcessAddVolumeObject(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNDS_ProcessAddPoolObject(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +void MNSS_ConvertToRootLeft(utf8_t *name, utf8_t *newName); +void MNSS_ConvertToRootRight(utf8_t *name, utf8_t *newName); +BOOL VerifyObjectClass(int dsContext, char *baseClass); + +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +SiblingElements_s NDSObjectElements[] = +{ + {TAG_GETATTRIBUTE, MNDS_ProcessGetAttribute}, + {0} +}; + +SiblingElements_s NDSVolumeElements[] = +{ + {TAG_ADDVOLUME, MNDS_ProcessAddVolumeObject}, + {TAG_REMOVEVOLUME, MNDS_ProcessRemoveObject}, + {0} +}; + +SiblingElements_s NDSPoolElements[] = +{ + {TAG_ADDPOOL, MNDS_ProcessAddPoolObject}, + {TAG_REMOVEPOOL, MNDS_ProcessRemoveObject}, + {0} +}; + +SiblingElements_s NDSUserElements[] = +{ + {TAG_ADDUSER, MNDS_ProcessAddUser}, + {TAG_REMOVEUSER, MNDS_ProcessRemoveObject}, + {0} +}; + + + + +/**************************************************************************** + * + * This function will make sure we have an xref if needed + * + ****************************************************************************/ +void MNDS_MakeXref( + int oldContext) +{ + int context; + NINT err; + NDSid_t guid; + struct + { + unicode_t *namePtr; + unicode_t data[MAX_DN_BYTES]; + } *alloc = NULL; + const unicode_t delims[] = + { + DELIM_CFG_FALSE, DELIM_CFG_TRUE, DELIM_DF_RDN, DELIM_DF_RDN, + DELIM_DV, DELIM_VALUE, DELIM_WILD, DELIM_DF_ESCAPE, 0 + }; + + err = DDCDuplicateContext(oldContext, &context); + if (err != 0) + { + syslog(LOG_INFO, + "MNDS_MakeXref:Error %d from duplicating context.\n", err); + return; + } + + MPKNSS_LOCK(); + alloc = malloc(sizeof(*alloc)); + MPKNSS_UNLOCK(); + if (!alloc) + { + syslog(LOG_INFO, "MNDS_MakeXref: malloc error\n"); + goto errorExit; + } + + /* + * Get the name from the passed in context + */ + err = (*DDCSetContextFlagsPtr)(context, DDC_UNICODE_STRINGS, 0); + if (err != 0) + { + syslog(LOG_INFO, + "MNDS_MakeXref:Error %d from DDCSetContextFlags.\n", err); + goto errorExit; + } + + err = DDCSetContextBaseDN(context, NULL, delims); + if (err != 0) + { + syslog(LOG_INFO, + "MNDS_MakeXref: DDCSetContextBasDN returned %d\n", err); + } + + err = (*DDCGetEntryInfoPtr)(context, DSI_ENTRY_DN, sizeof(*alloc), + alloc); + if (err != 0) + { + syslog(LOG_INFO, + "MNDS_MakeXref:Error %d from DDCGetEntryInfo.\n", err); + goto errorExit; + } + + err = OpenNCPServ(); + if (err != 0) + { + syslog(LOG_INFO, "MNDS_MakeXref:Error %d opening service\n", err); + goto errorExit; + } + + err = NCPMapDNToGUID(TRUE, alloc->namePtr, (char *)&guid); + if (err != 0) + { + syslog(LOG_INFO, "MNDS_MakeXref:Error %d mapping DN to GUID\n", err); + goto errorExit; + } + +errorExit: + DDCFreeContext(context); + MPKNSS_LOCK(); + free(alloc); + MPKNSS_UNLOCK(); + return; +} + +/**************************************************************************** + * + * This function will resolve to an NDS context and then re-authenticate + * + ****************************************************************************/ +NINT MNDS_ResolveName( + NINT context, + NINT flags, + const void *dn) +{ + NINT err; + + err = (*DDCResolveNamePtr)(context, flags, dn); + if (err != 0) + { + return err; + } + + return (*DDCAuthenticateConnectionPtr)(context); +} + +/**************************************************************************** + * + * This function will get the name of the cluster if clustering is running. + * + * The passed in pointer should be able to hold at least MAX_DN_CHARS. + * + ****************************************************************************/ +STATUS MNSS_GetClusterName( + utf8_t *clusterName) +{ + LONG (*NWCLSTR_ClusterNamePtr)(); + NINT size = MAX_DN_CHARS; + STATUS status = zFAILURE; +#if zLINUX + void *libHandle; +#endif + + /* + * Try to import the function. If we cannot then clustering is not loaded. + */ +#if zNETWARE + NWCLSTR_ClusterNamePtr = + (LONG (*)())ImportPublicSymbol((LONG)MANAGE_ModuleHandle, + NWCLSTR_ClusterNameAPI); +#endif +#if zLINUX + NWCLSTR_ClusterNamePtr = NULL; + MPKNSS_UNLOCK(); + libHandle = dlopen(NWCLSTR_LIBNAME, RTLD_LAZY); + if (libHandle) + { + NWCLSTR_ClusterNamePtr = dlsym(libHandle, NWCLSTR_ClusterNameAPI_LNX); + } + MPKNSS_LOCK(); +#endif + if (NWCLSTR_ClusterNamePtr) + { + if ((*NWCLSTR_ClusterNamePtr)(clusterName, &size) == 0) + { + status = zOK; + } +#if zNETWARE + UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, NWCLSTR_ClusterNameAPI); +#endif + } +#if zLINUX + if (libHandle) + { + MPKNSS_UNLOCK(); + dlclose(libHandle); + MPKNSS_LOCK(); + } +#endif + return status; +} +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +/**************************************************************************** + * + * This function calls the dclient interfaces to get an attribute from an + * object. + * + ****************************************************************************/ +STATUS MNDS_GetAttributeFromNDS( + VirtInfo_s *virtInfo, + utf8_t *container, + utf8_t *ndsName, + utf8_t *attributeName) +{ +#define ATTR_DATA_SIZE 4096 +#define ATTR_TEMP_SIZE 1024 + unsigned int count; + int dsContext; + int agentIdentityHandle; + int err = zOK; + DDCVALUE *attributeData; + char tempBuffer[ATTR_TEMP_SIZE]; + char *nameList[2]; + DDCReadFilter filter; + NINT i; + NINT dataLen; + BOOL needTagAttributes = TRUE; + + if (!NdsPublicsLoaded) + { + if (LB_ImportNDSPublics((LONG)MANAGE_ModuleHandle) != zOK) + { + err = zERR_UNABLE_TO_IMPORT_NDS_PUBLICS; + zASSERT("Error importing NDS publics" == NULL); + goto out; + } + } + + nameList[0] = attributeName; + nameList[1] = 0; + + filter.syncFormat = 0; + filter.attributes = (DDCString **) &nameList; + filter.minValueTime.seconds = 0; + +#if zNETWARE + attributeData = zalloc(ATTR_DATA_SIZE); +#else + attributeData = calloc(1, ATTR_DATA_SIZE); +#endif + if (attributeData == NULL) + { + err = zERR_NO_MEMORY; + goto out; + } + + MPKNSS_UNLOCK(); + + /* Create a DClient Context */ + err = (*DDCCreateContextPtr)((SAL_ModHandle)(long)MANAGE_ModuleHandle, &dsContext); + if (err != 0) + { + goto exit; + } + + /* Login as a server to have all rights */ + err = LoginToNDS(dsContext, &agentIdentityHandle); + if (err != 0) + { + goto cleanup; + } + + /* Resolve to appropriate object */ + sprintf(tempBuffer, MSGNot("%s\\%s"), container, ndsName); + err = MNDS_ResolveName(dsContext, DS_READABLE | DS_DEREFERENCE_ALIASES, + tempBuffer); + if (err != 0) + { +// printf("Resolve object name failed with error code %d\n", err); + goto logout; + } + + /* Get the attribute of the object pointed to by the current context. */ + VIRT_AddResultTagForAttribute(virtInfo, TAG_NDSATTRIBUTE); + do + { + err = (*DDCReadToBufferPtr)(dsContext, &filter, DS_VALUE_INFO, + ATTR_DATA_SIZE-1, ATTR_DATA_SIZE-1, attributeData, &count); + if (err != 0) + { + // printf("Read to buffer failed with error code %d\n", err); + goto logout; + } + + for (i = 0; i < count; i++) + { + if (needTagAttributes) + { + needTagAttributes = FALSE; + sprintf(tempBuffer, MSGNot("%d"), attributeData[i].syntax); + VIRT_AddAttribute(virtInfo, ATR_NAME, + (utf8_t *)attributeData[i].attrName, FALSE, FALSE, FALSE); + VIRT_AddAttribute(virtInfo, ATR_SYNTAX, tempBuffer, TRUE, FALSE, + TRUE); + } +#ifndef __linux__ + zASSERT(stricmp(attributeName, attributeData[i].attrName) == 0); +#endif + + VIRT_AddResultTag(virtInfo, TAG_VALUE, FALSE, FALSE); + dataLen = attributeData[i].size; + if (dataLen > ATTR_TEMP_SIZE - 1) + { + dataLen = ATTR_TEMP_SIZE - 1; + } + memcpy(tempBuffer, attributeData[i].data, dataLen); + tempBuffer[dataLen] = 0; + VIRT_AddResultData(virtInfo, tempBuffer); + VIRT_AddResultTag(virtInfo, TAG_VALUE, TRUE, TRUE); + } + } while (count > 0); + VIRT_AddResultTag(virtInfo, TAG_NDSATTRIBUTE, TRUE, TRUE); + +logout: + LogoutFromNDS(dsContext, agentIdentityHandle); +cleanup: + (*DDCFreeContextPtr)(dsContext); +exit: + MPKNSS_LOCK(); + free(attributeData); +out: + return err; +} + +/**************************************************************************** + * + * This function calls the dclient interfaces to add the specified user + * + ****************************************************************************/ +STATUS MNDS_AddUserToNDS( + VirtInfo_s *virtInfo, + utf8_t *container, + utf8_t *surname, + utf8_t *givenName, + utf8_t *fullName, + utf8_t *ndsName, + utf8_t *description, + utf8_t *securityEquals, + utf8_t *password) +{ + int dsContext; + int agentIdentityHandle; + int err; + DDCVALUE attributeValues[6]; + DDCVALUE *currentattributeValuePointer = attributeValues; + char userName[MAX_DN_CHARS]; + NINT numAttributeValues; + + ASSERT_MPKNSS_LOCK(); + + if (!NdsPublicsLoaded) + { + if (LB_ImportNDSPublics((LONG)MANAGE_ModuleHandle) != zOK) + { + err = zERR_UNABLE_TO_IMPORT_NDS_PUBLICS; + zASSERT("Error importing NDS publics" == NULL); + goto out; + } + } + + MPKNSS_UNLOCK(); + memset(&attributeValues, 0, sizeof attributeValues); + + /* Create a DClient Context */ + err = (*DDCCreateContextPtr)((SAL_ModHandle)(long)MANAGE_ModuleHandle, &dsContext); + if (err != 0) + { + goto exit; + } + + /* Login as a server to have all rights */ + err = LoginToNDS(dsContext, &agentIdentityHandle); + if (err != 0) + { + goto cleanup; + } + + /* Set Object Class = User */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_CLASS_NAME; + currentattributeValuePointer->attrName = "object class"; + currentattributeValuePointer->data = "user"; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + + /* Set SurName Attribute */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_CI_STRING; + currentattributeValuePointer->attrName = "surname"; + currentattributeValuePointer->data = surname; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + numAttributeValues = 2; + + if (description != NULL) + { + /* Set the Description Attribute of this User */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_CI_STRING; + currentattributeValuePointer->attrName = "description"; + currentattributeValuePointer->data = description; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + numAttributeValues++; + } + + if (securityEquals != NULL) + { + /* Set the "Security Equals" Attribute of this User */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_DIST_NAME; + currentattributeValuePointer->attrName = "security equals"; + currentattributeValuePointer->data = securityEquals; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + numAttributeValues++; + } + + if (fullName != NULL) + { + /* Set the "Full Name" Attribute of this User */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_CI_STRING; + currentattributeValuePointer->attrName = "full name"; + currentattributeValuePointer->data = fullName; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + numAttributeValues++; + } + + if (givenName != NULL) + { + /* Set the "Given Name" Attribute of this User */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_CI_STRING; + currentattributeValuePointer->attrName = "given name"; + currentattributeValuePointer->data = givenName; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + numAttributeValues++; + } + + /* Resolve to appropriate Container */ + err = MNDS_ResolveName(dsContext, DS_WRITABLE | DS_DEREFERENCE_ALIASES, + container); + if (err != 0) + { +// printf("Resolve container name failed with error code %d\n", err); + goto logout; + } + + /* Create user under the object pointed to by the current context. */ + err = (*DDCCreateEntryPtr)(dsContext, ndsName, numAttributeValues, + attributeValues); + if (err != 0) + { +// printf("CreateEntry failed with error code %d\n", err); + goto logout; + } + + /* Resolve to the user we just created. */ + sprintf(userName, MSGNot("%s\\%s"), container, ndsName); + err = MNDS_ResolveName(dsContext, DS_WRITABLE | DS_DEREFERENCE_ALIASES, + userName); + if (err != 0) + { +// printf("Resolve user name failed with error code %d\n", err); + goto logout; + } + + /* Generate a Key Pair and set the password for this User */ + err = (*DDCGenerateKeyPairPtr)(dsContext, password); + if (err != 0) + { +// printf("Could not generate KeyPair. Error code = %d\n", err); + goto logout; + } + + /* + * If we are adding a user object as security equal then we need to add + * the current object to that objects "equivalent to me" attribute. + */ + if (securityEquals != NULL) + { + /* Resolve to the "equal" user */ + err = MNDS_ResolveName(dsContext, + DS_WRITABLE | DS_DEREFERENCE_ALIASES, securityEquals); + if (err != 0) + { +// printf("Resolve equal user name failed with error code %d\n", err); + goto logout; + } + /* Set the "Equivalent to me" attribute */ + attributeValues[0].operation = DS_ADD_VALUE; + attributeValues[0].syntax = SYN_DIST_NAME; + attributeValues[0].attrName = "equivalent to me"; + attributeValues[0].data = userName; + attributeValues[0].size = strlen(attributeValues[0].data) + 1; + err = (*DDCModifyEntryPtr)(dsContext, 1, attributeValues); + if (err != 0) + { +// printf("modify user failed with error code %d\n", err); + goto logout; + } + } + + +logout: + LogoutFromNDS(dsContext, agentIdentityHandle); +cleanup: + (*DDCFreeContextPtr)(dsContext); +exit: + MPKNSS_LOCK(); +out: + return err; +} + +/**************************************************************************** + * + * This function gets the server name from NDS and separates it into + * container part & object name + * + ****************************************************************************/ +STATUS GetServerNameFromNDS(int dsContext, + DDCString *serverName, + utf8_t *server, + utf8_t *container) +{ + int err = zOK; + BOOL needToFreeServerName = FALSE; +#if zLINUX + int type; + size_t addrSize; + BYTE addr[32]; +#if 0 + NINT nameEnd; + unicode_t uniName[MAX_DN_CHARS]; + utf8_t tempName[MAX_DN_CHARS]; +#endif +#endif + + /* FixFixFix Only need to get the name once from NDS */ + if (serverName == NULL) + { + serverName = malloc(NDS_SERVER_SIZE); + if (serverName == NULL) + { + err = zERR_NO_MEMORY; + goto exit; + } + needToFreeServerName = TRUE; + } + +#if zLINUX + err = (*DDCGetDefaultAddressPtr)(&type, sizeof(addr), &addrSize, addr); + if (err == 0) + { + err = (*DDCConnectToAddressPtr)(dsContext, 0, type, addrSize, addr); + } +#if 0 + err = NCPGetServerDN(sizeof(uniName), uniName); + if (err == 0) + { + uni2utf(uniName, tempName, NDS_SERVER_SIZE); + /* Workaround for strange names */ + nameEnd = strlen(tempName); + if ((nameEnd >= 2) && (strcmp(&tempName[nameEnd - 2], "+.") == 0)) + { + tempName[nameEnd - 2] = '\0'; + } + MNSS_ConvertToRootLeft(tempName, serverName); + } +#endif +#endif + err = (*DDCGetServerNamePtr)(dsContext, serverName, NDS_SERVER_SIZE, + NULL, NULL); + if (err == 0) + { + /* divide the server name into the container part and the object name */ + LB_ParseDSObjectName(serverName, container, server); + } + + if (needToFreeServerName) + { + free(serverName); + } +exit: + return err; +} + +/**************************************************************************** + * + * This function calls the dclient interfaces to remove the specified user + * + ****************************************************************************/ +STATUS MNDS_RemoveObjectFromNDS( + utf8_t *container, + utf8_t *ndsName, + char *baseClass) +{ + int dsContext; + int agentIdentityHandle; + int err = zOK; +// int guidErr; +// LONG uid; +// GUID_t guid; + DDCVALUE attributeValues[3]; + char fullName[MAX_DN_CHARS]; + BOOL allocedContainer = FALSE; + + ASSERT_MPKNSS_LOCK(); + + if (!NdsPublicsLoaded) + { + if (LB_ImportNDSPublics((LONG)MANAGE_ModuleHandle) != zOK) + { + err = zERR_UNABLE_TO_IMPORT_NDS_PUBLICS; + zASSERT("Error importing NDS publics" == NULL); + goto exit; + } + } + + MPKNSS_UNLOCK(); + memset(&attributeValues, 0, sizeof attributeValues); + + /* Create a DClient Context */ + err = (*DDCCreateContextPtr)((SAL_ModHandle)(long)MANAGE_ModuleHandle, &dsContext); + if (err != 0) + { +#if zLINUX + syslog(LOG_INFO, "MNDS_RemoveObjectFromNDS: Error %d creating NDS context\n", err); +#endif + goto lock; + } + + /* Login as a server to have all rights */ + err = LoginToNDS(dsContext, &agentIdentityHandle); + if (err != 0) + { +#if zLINUX + syslog(LOG_INFO, "MNDS_RemoveObjectFromNDS: Error %d logging into NDS\n", err); +#endif + goto cleanup; + } + + /* + * If no container is specified then use the server object's container + */ + if (container == NULL) + { + container = malloc(NDS_SERVER_SIZE); + if (container == NULL) + { + err = zERR_NO_MEMORY; + goto logout; + } + allocedContainer = TRUE; + + /* Get the server's NDS name */ + err = GetServerNameFromNDS(dsContext, NULL, NULL, container); + if (err != 0) + { + goto logout; + } + } + + /* Resolve to the object */ + sprintf(fullName, MSGNot("%s\\%s"), container, ndsName); + err = MNDS_ResolveName(dsContext, DS_WRITABLE | DS_DEREFERENCE_ALIASES, + fullName); + if (err != 0) + { +// printf("Resolve object name failed with error code %d\n", err); +#if zLINUX + syslog(LOG_INFO, "MNDS_RemoveObjectFromNDS: Error %d resolving to %s\n", err, fullName); +#endif + if (err == ERR_NO_SUCH_ENTRY) + { + err = 0; + } + goto logout; + } + + if (baseClass != NULL) + { + if (! VerifyObjectClass(dsContext, baseClass)) + { + err = ERR_INCORRECT_BASE_CLASS; + goto logout; + } + } + +// guidErr = LB_GetDSGUID(dsContext, &guid, &uid); + + /* remove user */ + err = (*DDCRemoveEntryPtr)(dsContext); + if (err != 0) + { +// printf("RemoveEntry failed with error code %d\n", err); + goto logout; + } + + /* Delete entry from idbroker */ +// if (guidErr == 0) +// { +//Brenda Removed when eliminating idbrokerd +//Brenda err = NCPDeleteEntryForGUID((char *) &guid); +// } + +logout: + if (allocedContainer) + { + free(container); + } + LogoutFromNDS(dsContext, agentIdentityHandle); +cleanup: + (*DDCFreeContextPtr)(dsContext); +lock: + MPKNSS_LOCK(); +exit: + return err; +} + +#if zLINUX +/**************************************************************************** + * + * This function takes the mount point and adds a file system type to the + * front of it. + * + ****************************************************************************/ +STATUS MNDS_MakeMountInfo( + utf8_t *mountPoint, + utf8_t **mountInfo) +{ + STATUS err = zOK; + + *mountInfo = malloc(strlen(mountPoint)+10); + if (*mountInfo == NULL) + { + err = zERR_NO_MEMORY; + } + else + { + strcpy(*mountInfo, "NSS "); + strcat(*mountInfo, mountPoint); + } + return err; +} +#endif + +/**************************************************************************** + * + * This function calls the dclient interfaces to add the specified volume + * + ****************************************************************************/ +STATUS MNDS_AddVolumeToNDS( + VirtInfo_s *virtInfo, + BOOL nssVolume, + utf8_t *container, + utf8_t *ndsName, + utf8_t *poolName, + utf8_t *volumeName, + utf8_t *ndsPoolName, +#if zLINUX + utf8_t *mountPoint, +#endif + GUID_t *dfsGUID, + NDSid_t *NDSid, + BOOL isClustered) +{ + int dsContext; + int agentIdentityHandle; + int err = zOK; + DDCVALUE attributeValues[6]; + DDCVALUE *currentattributeValuePointer = attributeValues; + DDCString *serverName = NULL; + NINT numAttributeValues; + utf8_t *name = NULL; + utf8_t *pname = NULL; + SNINT nameIndex; + LONG uid; + utf8_t server[MAX_DN_CHARS + 1]; + char objectName[MAX_DN_CHARS + 1]; + BOOL allocedContainer = FALSE; + UserID_t poolGUID = zINVALID_USERID; +#if zLINUX + utf8_t *mountInfo = NULL; + unicode_t uniName[MAX_DN_CHARS + 1]; + void *libHandle; +#endif + CLSTR_ERRORS cerr; + CLSTR_ERRORS (*NWCLSTR_IsClusterEnabled_PTR)(BYTE *poolVolName, POOL_WORK type, unicode *poolFDN, UINT32 len) = NULL; +// struct +// { +// unicode_t *namePtr; +// unicode_t tunedName[MAX_TUNED_NAME_SIZE]; +// unicode_t uniVolName[MAX_DN_CHARS]; +// unicode_t uniServerName[MAX_DN_CHARS]; +// unicode_t uniName[MAX_DN_CHARS]; +// unicode_t uniContainer[MAX_DN_CHARS]; +// } *alloc; + + +//printf("MNDS_AddVolumeToNDS -- enter. mountPoint=%s\n", mountPoint); + ASSERT_MPKNSS_LOCK(); + + /* Begin by checking if the volume is cluster hosted, if so we + * must leave the DS object creation to NCS */ +#if zNETWARE + ZOS_ImportPublicSymbol(NWCLSTR_IsClusterEnabled_PTR, (LONG)MANAGE_ModuleHandle, (BYTE *)NWCLSTR_IsClusterEnabledAPI); +#endif +#if zLINUX + NWCLSTR_IsClusterEnabled_PTR = NULL; + MPKNSS_UNLOCK(); + libHandle = dlopen(NWCLSTR_LIBNAME, RTLD_LAZY); + if (libHandle) + { + NWCLSTR_IsClusterEnabled_PTR = dlsym(libHandle, NWCLSTR_IsClusterEnabledAPI_LNX); + } + MPKNSS_LOCK(); +#endif + if (NWCLSTR_IsClusterEnabled_PTR != NULL) + { + MPKNSS_UNLOCK(); + cerr = NWCLSTR_IsClusterEnabled_PTR((BYTE *)volumeName, VOLUME_LOOK, NULL, 0); + MPKNSS_LOCK(); + /* NB: What if the volume is cluster hosted and NCS isn't loaded - this implementation doesn't handle that? */ + if (cerr == CLSTR_RESOURCE_FOUND) + { + /* The pool is cluster enabled, we must behave as a no-op */ + goto out; + } + } + + if (!NdsPublicsLoaded) + { + if (LB_ImportNDSPublics((LONG)MANAGE_ModuleHandle) != zOK) + { + zASSERT("Error importing NDS publics" == NULL); + goto out; + } + } + + serverName = malloc(NDS_SERVER_SIZE); + if (serverName == NULL) + { + err = zERR_NO_MEMORY; + goto out; + } + + name = malloc(NDS_SERVER_SIZE); + if (name == NULL) + { + err = zERR_NO_MEMORY; + goto exit1; + } + + pname = malloc(NDS_SERVER_SIZE); + if (pname == NULL) + { + err = zERR_NO_MEMORY; + goto exit2; + } + + if (container == NULL) + { + container = malloc(NDS_SERVER_SIZE); + if (container == NULL) + { + err = zERR_NO_MEMORY; + goto exit3; + } + allocedContainer = TRUE; + } + + MPKNSS_UNLOCK(); + memset(&attributeValues, 0, sizeof attributeValues); + + /* Create a DClient Context */ + err = (*DDCCreateContextPtr)((SAL_ModHandle)(long)MANAGE_ModuleHandle, &dsContext); + if (err != 0) + { + goto exit; + } + + /* Login as a server to have all rights */ + err = LoginToNDS(dsContext, &agentIdentityHandle); + if (err != 0) + { + goto cleanup; + } + +// syslog(LOG_INFO, "MNDS_AddVolumeToNDS: Getting server name (uh-oh!)...\n"); + /* Get the server's NDS name */ + err = GetServerNameFromNDS(dsContext, serverName, server, + allocedContainer ? container : NULL); + if (err != 0) + { +// syslog(LOG_INFO, "Couldn't get server name. err = %d\n", err); + goto logout; + } +// syslog(LOG_INFO, "Server name = %s\n", serverName); + + /* build the volume's NDS name */ + if (ndsName) + { + strcpy(name, ndsName); + } + else + { + /* + * Build the nds name by prepending the server name to the volume + * name. + */ + strcpy(name, server); + nameIndex = strlen(name); + name[nameIndex] = '_'; + strcpy(&name[nameIndex + 1], volumeName); + } + + if (nssVolume) + { + /* build the pool's NDS name */ + strcpy(pname, container); + strcat(pname, "\\"); + if (ndsPoolName) + { + strcat(pname, ndsPoolName); + } + else + { + utf8_t *errorString; + STATUS status; + /* + * Get the NDS pool name from the actual pool object. + */ + MPKNSS_LOCK(); + status = MNSS_GetPoolNDSName(poolName, &pname[strlen(pname)], + objectName, &poolGUID, &errorString); + MPKNSS_UNLOCK(); + if (status != zOK) + { +// DBG_DebugPrintf(LRED, "Error %d from MNSS_GetPoolNDSName: %s\n", status, errorString); + /* + * Build the nds name by prepending the server name to the pool + * name and appending _pool to the end. + */ + strcat(pname, server); + strcat(pname, "_"); + strcat(pname, poolName); + strcat(pname, "_POOL"); + } + } + } + + /* Set Object Class = volume */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_CLASS_NAME; + currentattributeValuePointer->attrName = "object class"; + currentattributeValuePointer->data = "volume"; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + + /* Set host resource name (volume's name in NSS) */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_CI_STRING; + currentattributeValuePointer->attrName = "host resource name"; +// currentattributeValuePointer->data = alloc->uniVolName; + currentattributeValuePointer->data = volumeName; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + + /* Set host server (name of NDS server object where the volume is) */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_DIST_NAME; + currentattributeValuePointer->attrName = "host server"; +// currentattributeValuePointer->data = alloc->uniServerName; + currentattributeValuePointer->data = serverName; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + + numAttributeValues = 3; + +#if zLINUX + err = MNDS_MakeMountInfo(mountPoint, &mountInfo); + if (err != zOK) + { + goto logout; + } +//printf("MNDS_AddVolumeToNDS -- mountInfo=%s\n", mountInfo); + + /* Set host resource name (volume's name in NSS) */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_CI_STRING; + currentattributeValuePointer->attrName = VOL_MOUNT_POINT_FIELD; + currentattributeValuePointer->data = mountInfo; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + + numAttributeValues = 4; +#endif + + if (nssVolume) + { +// if (LB_GUIDCompare(&poolGUID, &zINVALID_USERID) != 0) +// { +// int poolContext; +// LONG poolID; +// +// /* +// * Get the tuned name in case we are working on a local xref that +// * is a collided name. +// */ +// +// /* +// * create new context +// */ +// err = (*DDCCreateContextPtr)((LONG)MANAGE_ModuleHandle, &poolContext); +// if (err != 0) +// { +// aprintf(LRED, "MNDS_AddVolumeToNDS: Error %d from DDCCreateContext.\n", err); +// goto continueExecution; +// } +// +// /* Make sure we are local */ +// err = (*DDCConnectToReferralPtr)(poolContext, 0, NULL); +// if (err != 0) +// { +// aprintf(LRED, +// "MNDS_AddVolumeToNDS:Error %d from DDSConnectToReferralPtr.\n", err); +// goto continueFree; +// } +// +// /* Login as a server */ +// err = LoginToNDS(poolContext); +// if (err != 0) +// { +// aprintf(LRED, +// "MNDS_AddVolumeToNDS:Error %d from DDSLoginAsServerPtr.\n", err); +// goto continueFree; +// } +// +//// /* resolve to the pool name */ +//// err = MNDS_ResolveName(poolContext, +//// DS_READABLE | DS_DEREFERENCE_ALIASES, pname); +//// if (err != 0) +//// { +//// aprintf(LRED, +//// "MNDS_AddVolumeToNDS:Error %d from MNDS_ResolveName.\n", err); +//// goto continueLogout; +//// } +// +// /* Set context from the GUID */ +// err = (*(NameService.MapGUIDToObjectID))((char *)&poolGUID, &poolID); +// if (err != 0) +// { +// aprintf(LRED, +// "MNDS_AddVolumeToNDS:Error %d from MapGUIDToObjectID.\n", +// err); +// goto continueLogout; +// } +// +// err = (*DDCSetContextEntryIDPtr)(poolContext, poolID); +// if (err != 0) +// { +// aprintf(LRED, +// "MNDS_AddVolumeToNDS:Error %d from DDCSetContextEntryID.\n", err); +// goto continueLogout; +// } +// +// /* Set context flags */ +// err = (*DDCSetContextFlagsPtr)(poolContext, +// DDC_REQ_TUNED_NAMES | DDC_UNICODE_STRINGS, 0); +// if (err != 0) +// { +// aprintf(LRED, +// "MNDS_AddVolumeToNDS:Error %d from DDCSetContextFlags.\n", err); +// goto continueLogout; +// } +// +//aprintf(LMAGENTA, "Getting the tuned name\n"); +// /* Get the tuned name */ +// err = (*DDCGetEntryInfoPtr)(poolContext, DSI_ENTRY_DN, sizeof(*alloc), +// alloc); +// if (err != 0) +// { +// aprintf(LRED, +// "MNDS_AddVolumeToNDS:Error %d from DDCGetEntryInfo.\n", err); +// goto continueLogout; +// } +// pname = (utf8_t *)alloc->tunedName; +// +//continueLogout: +// LogoutFromNDS(poolContext); +//continueFree: +// (*DDCFreeContextPtr)(poolContext); +// } +//continueExecution: + + /* Set pool name where the volume resides */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_DIST_NAME; + currentattributeValuePointer->attrName = "nssfsPool"; + currentattributeValuePointer->data = pname; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + + ++numAttributeValues; + } + + if (LB_GUIDCompare(dfsGUID,&zINVALID_GUID) != 0) + { + /* Set the GUID used by DFS */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_OCTET_STRING; + currentattributeValuePointer->attrName = "dfs-volume-guid"; + currentattributeValuePointer->data = dfsGUID; + currentattributeValuePointer->size = 16; + currentattributeValuePointer++; + + ++numAttributeValues; + } + + /* Resolve to appropriate Container */ + + err = MNDS_ResolveName(dsContext, DS_WRITABLE | DS_DEREFERENCE_ALIASES, + container); + if (err != 0) + { +// syslog(LOG_INFO, "Error from ResolveName. err = %d\n", err); + goto logout; + } + + err = (*DDCCreateEntryPtr)(dsContext, name, numAttributeValues, + attributeValues); + if (err != 0) + { +// DBG_DebugPrintf(LRED, "CreateEntry failed with error code %d\n", err); +// syslog(LOG_INFO, "Error from CreateEntry. err = %d\n", err); + goto logout; + } + + /* + * Return the GUID for the volume + */ + + /* Resolve to the object */ + sprintf(objectName, MSGNot("%s\\%s"), container, name); + err = MNDS_ResolveName(dsContext, DS_READABLE | DS_DEREFERENCE_ALIASES, + objectName); + if (err != 0) + { +// syslog(LOG_INFO, "Error from ResolveName(2). err = %d\n", err); + goto logout; + } + + /* Make sure the name is in a local xref if applicable */ + MNDS_MakeXref(dsContext); + + /* get GUID from the NDS object */ + err = LB_GetDSGUID(dsContext, NDSid, &uid); + if (err != 0) + { +// syslog(LOG_INFO, "Error from LB_GetDSGUID. err = %d\n", err); + goto logout; + } + +#if zLINUX + /* Convert object name to dot form */ + /* Reusing server buffer here because it's convenient */ + MNSS_ConvertToRootRight(objectName, server); + + /* Now to unicode */ + if (utf2uni(server, uniName, sizeof(uniName)) != -1) + { + /* Let NCP Mapping code know about it */ +//Brenda Removed when eliminating idbrokerd +//Brenda err = NCPUpdateDNGUIDMapping(dsContext, (char *) NDSid, uniName, uid); + } +#endif + + /* Cluster enable if needed */ + if (isClustered) + { + MPKNSS_LOCK(); + err = NWCLSTR_ClusterEnable((BYTE *)objectName, (BYTE *)"777.777.777.777", NULL, NULL, + FALSE, NULL, 0, FALSE, dsContext); + MPKNSS_UNLOCK(); + } + +logout: + LogoutFromNDS(dsContext, agentIdentityHandle); +cleanup: + (*DDCFreeContextPtr)(dsContext); +exit: + MPKNSS_LOCK(); + if (allocedContainer) + { + free(container); + } +exit3: +// free(alloc); + free(pname); +exit2: + free(name); +exit1: + free(serverName); +out: +#if zNETWARE + if (NWCLSTR_IsClusterEnabled_PTR != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)NWCLSTR_IsClusterEnabledAPI); + } +#endif +#if zLINUX + if (libHandle) + { + MPKNSS_UNLOCK(); + dlclose(libHandle); + MPKNSS_LOCK(); + } + free(mountInfo); +#endif + return err; +} + +/**************************************************************************** + * + * This function checks if the current object is the expected type + * + ****************************************************************************/ +BOOL VerifyObjectClass(int dsContext, char *baseClass) +{ + int err; + struct + { + DDCString *baseClass; + char buffer[MAX_DN_BYTES + 128]; + } dsBuffer; + + if ((err = (*DDCGetEntryInfoPtr)(dsContext, DSI_BASE_CLASS, + sizeof(dsBuffer), (void *) &dsBuffer)) == 0) + { + if (stricmp(dsBuffer.baseClass, baseClass) == 0) + { + return TRUE; + } + } + return FALSE; +} + +/**************************************************************************** + * + * This function calls the dclient interfaces to rename a volume in NDS + * + ****************************************************************************/ +STATUS MNDS_RenameVolumeInNDS( + VirtInfo_s *virtInfo, + utf8_t *container, + utf8_t *ndsName, + utf8_t *volumeName, + utf8_t *newNDSName, + utf8_t *newVolumeName) +{ + int dsContext; + int agentIdentityHandle; + int err = zOK; + DDCVALUE attributeValue; + BOOL allocedContainer = FALSE; + utf8_t server[MAX_DN_CHARS + 1]; + char fullName[MAX_DN_CHARS + 1]; + utf8_t *newName; +#if zLINUX + LONG uid; + int idbErr; + NDSid_t NDSid; + char dotName[MAX_DN_CHARS + 1]; + unicode_t uniName[MAX_DN_CHARS + 1]; +#endif + + ASSERT_MPKNSS_LOCK(); + + if (!NdsPublicsLoaded) + { + if (LB_ImportNDSPublics((LONG)MANAGE_ModuleHandle) != zOK) + { + err = zERR_UNABLE_TO_IMPORT_NDS_PUBLICS; + zASSERT("Error importing NDS publics" == NULL); + goto out; + } + } + + newName = malloc(NDS_SERVER_SIZE); + if (newName == NULL) + { + err = zERR_NO_MEMORY; + goto out; + } + + if (container == NULL) + { + container = malloc(NDS_SERVER_SIZE); + if (container == NULL) + { + err = zERR_NO_MEMORY; + goto exit2; + } + allocedContainer = TRUE; + } + + MPKNSS_UNLOCK(); + memset(&attributeValue, 0, sizeof attributeValue); + + /* Create a DClient Context */ + err = (*DDCCreateContextPtr)((SAL_ModHandle)(long)MANAGE_ModuleHandle, &dsContext); + if (err != 0) + { + goto exit3; + } + + /* Login as a server to have all rights */ + err = LoginToNDS(dsContext, &agentIdentityHandle); + if (err != 0) + { + goto cleanup; + } + + /* Get the server's NDS name */ + err = GetServerNameFromNDS(dsContext, NULL, server, allocedContainer ? container : NULL); + if (err != 0) + { + goto logout; + } + + /* build the volume's newNDS name */ + if (newNDSName) + { + strcpy(newName, newNDSName); + } + else + { + utf8_t *ptr; + + /* + * Build the new NDS name by replacing the volume name in the old name + * with the new volume name. If the volume name is not found then + * leave the NDS object name as it was. + */ + ptr = strstr(ndsName, volumeName); + if (ptr) + { + NINT len = ptr - ndsName; + strncpy(newName, ndsName, len); + newName[len] = '\0'; + strcat(newName, newVolumeName); + strcat(newName, ptr + strlen(volumeName)); + } + else + { + strcpy(newName, ndsName); + } + } + + /* Resolve to the object */ + sprintf(fullName, MSGNot("%s\\%s"), container, ndsName); + err = MNDS_ResolveName(dsContext, DS_WRITABLE | DS_DEREFERENCE_ALIASES, + fullName); + if (err != 0) + { + goto logout; + } + + /* Verify that it's a Volume object */ + if (! VerifyObjectClass(dsContext, "Volume")) + { + err = ERR_INCORRECT_BASE_CLASS; + goto logout; + } + + /* rename the object */ + err = (*DDCModifyRDNPtr)(dsContext, newName, TRUE); + if (err != 0) + { + goto logout; + } + + /* Modify the value of "Host Resource Name" */ + attributeValue.operation = DS_OVERWRITE_VALUE; + attributeValue.syntax = SYN_CI_STRING; +// attributeValue.attrName = "host resource name"; + attributeValue.attrName = A_HOST_RESOURCE_NAME; + attributeValue.data = newVolumeName; + attributeValue.size = strlen(newVolumeName); + + err = (*DDCModifyEntryPtr)(dsContext, 1, &attributeValue); + +#if zLINUX + /* Tell idbroker that the name has changed */ + /* get GUID from the NDS object */ + idbErr = LB_GetDSGUID(dsContext, &NDSid, &uid); + if (idbErr != 0) + { + if (err == 0) + { + err = idbErr; + } + syslog(LOG_INFO, "MNDS_RenameVolumeInNDS: Error from LB_GetDSGUID. err = %d\n", idbErr); + goto logout; + } + + /* convert newName to unicode */ + sprintf(fullName, MSGNot("%s\\%s"), container, newName); + MNSS_ConvertToRootRight(fullName, dotName); + utf2uni(dotName, uniName, sizeof(uniName)); +//Brenda Removed when eliminating idbrokerd +//Brenda idbErr = NCPUpdateDNGUIDMapping(dsContext, (char *) &NDSid, uniName, uid); +//Brenda if (err == 0) +//Brenda { +//Brenda err = idbErr; +//Brenda } +#endif + +logout: + LogoutFromNDS(dsContext, agentIdentityHandle); +cleanup: + (*DDCFreeContextPtr)(dsContext); +exit3: + MPKNSS_LOCK(); + if (allocedContainer) + { + free(container); + } +exit2: + free(newName); +out: + return err; +} + +#if zLINUX +/**************************************************************************** + * + * This function calls the dclient interfaces to change the mount point stored + * in the volume object in NDS + * + ****************************************************************************/ +STATUS MNDS_ChangeVolumeMountPointInNDS( + utf8_t *container, + utf8_t *ndsName, + utf8_t *mountPoint) +{ + int dsContext; + int agentIdentityHandle; + int err = zOK; + DDCVALUE attributeValue; + char fullName[MAX_DN_CHARS + 1]; + utf8_t *mountInfo = NULL; + +//printf("MNDS_ChangeVolumeMountPointInNDS -- mountpoint=%s\n", mountPoint); + ASSERT_MPKNSS_LOCK(); + + if (!NdsPublicsLoaded) + { + if (LB_ImportNDSPublics((LONG)MANAGE_ModuleHandle) != zOK) + { + err = zERR_UNABLE_TO_IMPORT_NDS_PUBLICS; + zASSERT("Error importing NDS publics" == NULL); + goto out; + } + } + + MPKNSS_UNLOCK(); + memset(&attributeValue, 0, sizeof attributeValue); + + /* Create a DClient Context */ + err = (*DDCCreateContextPtr)((SAL_ModHandle)(long)MANAGE_ModuleHandle, &dsContext); + if (err != 0) + { + goto exit; + } + + /* Login as a server to have all rights */ + err = LoginToNDS(dsContext, &agentIdentityHandle); + if (err != 0) + { + goto cleanup; + } + + /* Resolve to the object */ + sprintf(fullName, MSGNot("%s\\%s"), container, ndsName); + err = MNDS_ResolveName(dsContext, DS_WRITABLE | DS_DEREFERENCE_ALIASES, + fullName); + if (err != 0) + { + goto logout; + } + + /* Verify that it's a Volume object */ + if (! VerifyObjectClass(dsContext, "Volume")) + { + err = ERR_INCORRECT_BASE_CLASS; + goto logout; + } + + err = MNDS_MakeMountInfo(mountPoint, &mountInfo); + if (err != zOK) + { + goto logout; + } + + // Remove the attribute and reinsert it. This is done because this + // is currently defined as a multi-valued attribute and we only + // want a single attribute. + err = DDCRemoveAttribute(dsContext, VOL_MOUNT_POINT_FIELD); + if (err != 0 && err != ERR_NO_SUCH_ATTRIBUTE) + { + goto logout; + } + + /* Modify the mount point value */ + attributeValue.operation = DS_OVERWRITE_VALUE; + attributeValue.syntax = SYN_CI_STRING; + attributeValue.attrName = VOL_MOUNT_POINT_FIELD; + attributeValue.data = mountInfo; + attributeValue.size = strlen(mountInfo); + err = (*DDCModifyEntryPtr)(dsContext, 1, &attributeValue); + +logout: + LogoutFromNDS(dsContext, agentIdentityHandle); +cleanup: + (*DDCFreeContextPtr)(dsContext); +exit: + MPKNSS_LOCK(); +out: + free(mountInfo); + return err; +} +#endif + +/**************************************************************************** + * + * This function calls the dclient interfaces to add the specified pool + * + * If retDSContext is non-NULL, the caller is given the DS context, and the + * caller must logout and free the context. + * + ****************************************************************************/ +STATUS MNDS_AddPoolToNDS( + VirtInfo_s *virtInfo, + utf8_t *container, + utf8_t *ndsName, + utf8_t *poolName, + VolumeID_t *poolID, + BOOL shared, + NDSid_t *NDSid, + utf8_t **retContainer, + utf8_t **retName, + int *retDSContext) +{ + int dsContext; + int agentIdentityHandle; + int err = zOK; + DDCVALUE attributeValues[5]; + DDCVALUE *currentattributeValuePointer = attributeValues; + DDCString *serverName; + NINT numAttributeValues; + utf8_t *pname; + LONG uid; + utf8_t server[MAX_DN_CHARS]; + char objectName[MAX_DN_CHARS]; + BOOL allocedContainer = FALSE; +#if zLINUX + unicode_t uniName[MAX_DN_CHARS]; + void *libHandle; +#endif + CLSTR_ERRORS cerr; + CLSTR_ERRORS (*NWCLSTR_IsClusterEnabled_PTR)(BYTE *poolVolName, POOL_WORK type, unicode *poolFDN, UINT32 len) = NULL; + + ASSERT_MPKNSS_LOCK(); + + if (retName) + { + *retName = NULL; + } + if (retContainer) + { + *retContainer = NULL; + } + if (retDSContext) + { + *retDSContext = 0; + } + + /* Begin by checking if the pool is cluster hosted, if so we + * must leave the DS object creation to NCS */ +#if zNETWARE + ZOS_ImportPublicSymbol(NWCLSTR_IsClusterEnabled_PTR, (LONG)MANAGE_ModuleHandle, (BYTE *)NWCLSTR_IsClusterEnabledAPI); +#endif +#if zLINUX + NWCLSTR_IsClusterEnabled_PTR = NULL; + MPKNSS_UNLOCK(); + libHandle = dlopen(NWCLSTR_LIBNAME, RTLD_LAZY); + if (libHandle) + { + NWCLSTR_IsClusterEnabled_PTR = dlsym(libHandle, NWCLSTR_IsClusterEnabledAPI_LNX); + } + MPKNSS_LOCK(); +#endif + + if (NWCLSTR_IsClusterEnabled_PTR != NULL) + { + MPKNSS_UNLOCK(); + cerr = NWCLSTR_IsClusterEnabled_PTR((BYTE *)poolName, POOL_INQUIRY, NULL, 0); + MPKNSS_LOCK(); + /* NB: What if the pool is cluster hosted and NCS isn't loaded - this implementation doesn't handle that? */ + if (cerr == CLSTR_RESOURCE_FOUND) + { + /* The pool is cluster enabled, we must behave as a no-op */ + goto out; + } + } + + if (!NdsPublicsLoaded) + { + if (LB_ImportNDSPublics((LONG)MANAGE_ModuleHandle) != zOK) + { + zASSERT("Error importing NDS publics" == NULL); + goto out; + } + } + + serverName = malloc(NDS_SERVER_SIZE); + if (serverName == NULL) + { + err = zERR_NO_MEMORY; + goto out; + } + + pname = malloc(NDS_SERVER_SIZE); + if (pname == NULL) + { + err = zERR_NO_MEMORY; + goto exit1; + } + + if (container == NULL) + { + container = malloc(NDS_SERVER_SIZE); + if (container == NULL) + { + err = zERR_NO_MEMORY; + goto exit1; + } + allocedContainer = TRUE; + } + + MPKNSS_UNLOCK(); + memset(&attributeValues, 0, sizeof attributeValues); + + /* Create a DClient Context */ + err = (*DDCCreateContextPtr)((SAL_ModHandle)(long)MANAGE_ModuleHandle, &dsContext); + if (err != 0) + { + goto exit; + } + + /* Login as a server */ + err = LoginToNDS(dsContext, &agentIdentityHandle); + if (err != 0) + { + goto cleanup; + } + + /* Get the server's NDS name */ + err = GetServerNameFromNDS(dsContext, serverName, server, allocedContainer ? container : NULL); + if (err != 0) + { + goto logout; + } + + /* build the pool's NDS name */ + if (ndsName) + { + strcpy(pname, ndsName); + } + else + { + /* + * Build the nds name by prepending the server name to the pool + * name and appending _pool to the end. + */ + strcpy(pname, server); + strcat(pname, "_"); + strcat(pname, poolName); + strcat(pname, "_POOL"); + } + + /* Set Object Class = POOL */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_CLASS_NAME; + currentattributeValuePointer->attrName = "object class"; + currentattributeValuePointer->data = "nssfspool"; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + + /* Set host resource name (pool's name in NSS) */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_CI_STRING; + currentattributeValuePointer->attrName = "host resource name"; + currentattributeValuePointer->data = poolName; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + + /* Set host server (name of NDS server object where the pool is) */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_DIST_NAME; + currentattributeValuePointer->attrName = "host server"; + currentattributeValuePointer->data = serverName; + currentattributeValuePointer->size = + strlen(currentattributeValuePointer->data) + 1; + currentattributeValuePointer++; + + /* Set pool ID (guid) */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_OCTET_STRING; + currentattributeValuePointer->attrName = "nssfsPoolID"; + currentattributeValuePointer->data = poolID; + currentattributeValuePointer->size = 16; + currentattributeValuePointer++; + + + /* Set the shared attribute of this User */ + currentattributeValuePointer->operation = DS_ADD_ATTRIBUTE; + currentattributeValuePointer->syntax = SYN_BOOLEAN; + currentattributeValuePointer->attrName = "nssfsShared"; + currentattributeValuePointer->data = &shared; + currentattributeValuePointer->size = 1; + currentattributeValuePointer++; + + numAttributeValues = 5; + + /* Resolve to appropriate Container */ + err = MNDS_ResolveName(dsContext, DS_WRITABLE | DS_DEREFERENCE_ALIASES, + container); + if (err != 0) + { +// printf("Resolve container name failed with error code %d\n", err); +#if zLINUX + syslog(LOG_INFO, "MNDS_AddPoolToNDS: Error %d from ResolveName(%s)\n", err, container); +#endif + goto logout; + } + + /* Create pool under the object pointed to by the current context. */ + err = (*DDCCreateEntryPtr)(dsContext, pname, numAttributeValues, + attributeValues); + if (err != 0) + { +// printf("CreateEntry failed with error code %d\n", err); +#if zLINUX + syslog(LOG_INFO, "MNDS_AddPoolToNDS: Error %d from DDCCreateEntry(%s)\n", err, pname); +#endif + goto logout; + } + + /* + * Return the GUID for the pool + */ + + /* Resolve to the object */ + sprintf(objectName, MSGNot("%s\\%s"), container, pname); + err = MNDS_ResolveName(dsContext, DS_READABLE | DS_DEREFERENCE_ALIASES, + objectName); + if (err != 0) + { +#if zLINUX + syslog(LOG_INFO, "MNDS_AddPoolToNDS: Error %d from ResolveName(%s)\n", err, objectName); +#endif + goto logout; + } + + /* Make sure the name is in a local xref if applicable */ + MNDS_MakeXref(dsContext); + + /* Get the GUID from the NDS object */ + err = LB_GetDSGUID(dsContext, NDSid, &uid); + if (err != 0) + { +#if zLINUX + syslog(LOG_INFO, "MNDS_AddPoolToNDS: Error %d from LB_GetDSGUID\n", err); +#endif + goto logout; + } + +#if zLINUX + /* Convert object name to dot form */ + /* Reusing server buffer here because it's convenient */ + MNSS_ConvertToRootRight(objectName, server); + + /* Now to unicode */ + if (utf2uni(server, uniName, sizeof(uniName)) != -1) + { + /* Let NCP Mapping code know about it */ +//Brenda Removed when eliminating idbrokerd +//Brenda err = NCPUpdateDNGUIDMapping(dsContext, (char *) NDSid, uniName, uid); +//Brenda if (err != 0) +//Brenda { +//Brenda syslog(LOG_INFO, "MNDS_AddPoolToNDS: Error %d from NCPUpdateDNGUIDMapping\n", err); +//Brenda } + } +#endif + + /* If the caller asked us to return the DS Context, don't logout */ + if (retDSContext != NULL) + { + *retDSContext = dsContext; + goto exit; + } + +logout: + LogoutFromNDS(dsContext, agentIdentityHandle); +cleanup: + (*DDCFreeContextPtr)(dsContext); +exit: + MPKNSS_LOCK(); + if (allocedContainer) + { + if (err || !retContainer) + { + free(container); + } + else + { + *retContainer = container; + } + } + if (retName) + { + *retName = pname; + } + else + { + free(pname); + } +exit1: + free(serverName); +out: +#if zNETWARE + if (NWCLSTR_IsClusterEnabled_PTR != NULL) + { + ZOS_UnImportPublicSymbol((LONG)MANAGE_ModuleHandle, (BYTE *)NWCLSTR_IsClusterEnabledAPI); + } +#endif +#if zLINUX + if (libHandle) + { + MPKNSS_UNLOCK(); + dlclose(libHandle); + MPKNSS_LOCK(); + } +#endif + return err; +} + +/**************************************************************************** + * + * This function calls the dclient interfaces to rename a pool in NDS + * + ****************************************************************************/ +STATUS MNDS_RenamePoolInNDS( + VirtInfo_s *virtInfo, + utf8_t *container, + utf8_t *ndsName, + utf8_t *poolName, + utf8_t *newNDSName, + utf8_t *newPoolName) +{ + int dsContext; + int agentIdentityHandle; + int err = zOK; + DDCVALUE attributeValue; + BOOL allocedContainer = FALSE; + utf8_t server[MAX_DN_CHARS + 1]; + char fullName[MAX_DN_CHARS + 1]; + DDCString *serverName; + utf8_t *newName; + utf8_t *ptr; +#if zLINUX + int idbErr; + LONG uid; + NDSid_t NDSid; + char dotName[MAX_DN_CHARS + 1]; + unicode_t uniName[MAX_DN_CHARS + 1]; +#endif + + ASSERT_MPKNSS_LOCK(); + + if (!NdsPublicsLoaded) + { + if (LB_ImportNDSPublics((LONG)MANAGE_ModuleHandle) != zOK) + { + err = zERR_UNABLE_TO_IMPORT_NDS_PUBLICS; + zASSERT("Error importing NDS publics" == NULL); + goto out; + } + } + + serverName = malloc(NDS_SERVER_SIZE); + if (serverName == NULL) + { + err = zERR_NO_MEMORY; + goto out; + } + + newName = malloc(NDS_SERVER_SIZE); + if (newName == NULL) + { + err = zERR_NO_MEMORY; + goto exit1; + } + + if (container == NULL) + { + container = malloc(NDS_SERVER_SIZE); + if (container == NULL) + { + err = zERR_NO_MEMORY; + goto exit2; + } + allocedContainer = TRUE; + } + + MPKNSS_UNLOCK(); + memset(&attributeValue, 0, sizeof attributeValue); + + /* Create a DClient Context */ + err = (*DDCCreateContextPtr)((SAL_ModHandle)(long)MANAGE_ModuleHandle, &dsContext); + if (err != 0) + { + goto exit3; + } + + /* Login as a server to have all rights */ + err = LoginToNDS(dsContext, &agentIdentityHandle); + if (err != 0) + { + goto cleanup; + } + + /* Get the server's NDS name */ + err = GetServerNameFromNDS(dsContext, NULL, server, allocedContainer ? container : NULL); + if (err != 0) + { + goto logout; + } + + /* build the volume's newNDS name */ + if (newNDSName) + { + strcpy(newName, newNDSName); + } + else + { + + /* + * Build the new NDS name by replacing the pool name in the old name + * with the new pool name. If the pool name is not found then leave the + * NDS object name as it was. + */ + ptr = strstr(ndsName, poolName); + if (ptr) + { + NINT len = ptr - ndsName; + strncpy(newName, ndsName, len); + newName[len] = '\0'; + strcat(newName, newPoolName); + strcat(newName, ptr + strlen(poolName)); + } + else + { + strcpy(newName, ndsName); + } + } + + /* Resolve to the object */ + sprintf(fullName, MSGNot("%s\\%s"), container, ndsName); + err = MNDS_ResolveName(dsContext, DS_WRITABLE | DS_DEREFERENCE_ALIASES, + fullName); + if (err != 0) + { + goto logout; + } + + /* Verify that it's a Pool object */ + if (! VerifyObjectClass(dsContext, "nssfsPool")) + { + err = ERR_INCORRECT_BASE_CLASS; + goto logout; + } + + /* rename the object */ + err = (*DDCModifyRDNPtr)(dsContext, newName, TRUE); + if (err != 0) + { + goto logout; + } + + /* Modify the value of "Host Resource Name" */ + attributeValue.operation = DS_OVERWRITE_VALUE; + attributeValue.syntax = SYN_CI_STRING; +// attributeValue.attrName = "host resource name"; + attributeValue.attrName = A_HOST_RESOURCE_NAME; + attributeValue.data = newPoolName; + attributeValue.size = strlen(newPoolName); + + err = (*DDCModifyEntryPtr)(dsContext, 1, &attributeValue); + +#if zLINUX + /* Tell idbroker that the name has changed */ + /* get GUID from the NDS object */ + idbErr = LB_GetDSGUID(dsContext, &NDSid, &uid); + if (idbErr != 0) + { + syslog(LOG_INFO, "MNDS_RenamePoolInNDS: Error from LB_GetDSGUID. err = %d\n", idbErr); + if (err == 0) + { + err = idbErr; + } + goto logout; + } + + /* convert newName to unicode */ + sprintf(fullName, MSGNot("%s\\%s"), container, newName); + MNSS_ConvertToRootRight(fullName, dotName); + utf2uni(dotName, uniName, sizeof(uniName)); +//Brenda Removed when eliminating idbrokerd +//Brenda idbErr = NCPUpdateDNGUIDMapping(dsContext, (char *) &NDSid, uniName, uid); +//Brenda if (err == 0) +//Brenda { +//Brenda err = idbErr; +//Brenda } +#endif + + /* + * If clustering is loaded then rename the cluster virtual server object + * for this pool. + */ + if (MNSS_GetClusterName(serverName) == zOK) + { + /* Only proceed if the NDS name has the cluster name. */ + ptr = strstr(ndsName, serverName); + if (ptr) + { + strcpy(serverName, ndsName); + strcat(serverName, "_SERVER"); + + /* Resolve to the object */ + sprintf(fullName, MSGNot("%s\\%s"), container, serverName); + if (MNDS_ResolveName(dsContext, + DS_WRITABLE | DS_DEREFERENCE_ALIASES, fullName) == 0) + { + /* rename the object */ + strcat(newName, "_SERVER"); + (void)(*DDCModifyRDNPtr)(dsContext, newName, TRUE); + } + } + } + + +logout: + LogoutFromNDS(dsContext, agentIdentityHandle); +cleanup: + (*DDCFreeContextPtr)(dsContext); +exit3: + MPKNSS_LOCK(); + if (allocedContainer) + { + free(container); + } +exit2: + free(newName); +exit1: + free(serverName); +out: + return err; +} +#endif + + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +/**************************************************************************** + * + * This function checks to see if the given volume is in the indicated pool + * Called with spinlock NOT held + * + ****************************************************************************/ +STATUS MNDS_CheckVolumesPool( + char *volName, + utf8_t *poolName, + BOOL *matchedPool) +{ + GeneralMsg_s genMsg; + STATUS status; + Volume_s *volume; + Pool_s *pool; + typedef struct Stack_s { + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + } Stack_s; + + STACK_ALLOC(); + + MPKNSS_LOCK(); + + /* Convert the names to unicode */ + + if ((status = LB_ByteToUnicode(NSS_UNI_CONVERSION_RAW, + aStack->uniVolName, NELEMS(aStack->uniVolName), volName, NULL)) != zOK) + { + goto exit2; + } + if (utf2uni(poolName, aStack->uniPoolName, sizeof(aStack->uniPoolName)) == -1) + { + status = zERR_INVALID_UTF8_CHAR; + goto exit2; + } + + /* + * Check the volume's pool pointer to see if it is the pool that was passed + * in. + */ + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + volume = COMN_VolumeNameLookup(&genMsg, aStack->uniVolName, FALSE, NULL); + if (volume == NULL) + { + if (GetErrno(&genMsg) == zERR_VOLUME_NOT_FOUND) + { + *matchedPool = FALSE; + status = zOK; + } + else + { + status = GetErrno(&genMsg); + } + goto exit2; + } + pool = COMN_PoolNameLookup(&genMsg, aStack->uniPoolName, FALSE, NULL); + if (pool == NULL) + { + status = GetErrno(&genMsg); + goto exit1; + } + + *matchedPool = (volume->v_pool == pool); + + COMN_Release(&pool); +exit1: + COMN_Release(&volume); +exit2: + MPKNSS_UNLOCK(); + STACK_FREE(); + return status; +} +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +/**************************************************************************** + * + * This function updates the field in the volume object that links it to the + * pool object. + * + ****************************************************************************/ +STATUS MDNS_UpdateVolumeLink( + int context, + utf8_t *container, + utf8_t *poolName) +{ + int err = zOK; + DDCVALUE attributeValue; + BYTE *ndsName; + + + MPKNSS_LOCK(); + ndsName = malloc(512); + if (!ndsName) + { + return zERR_NO_MEMORY; + } + + strcpy((char *)ndsName, container); + strcat((char *)ndsName, "\\"); + strcat((char *)ndsName, poolName); + + attributeValue.operation = DS_OVERWRITE_VALUE; + attributeValue.syntax = SYN_DIST_NAME; + attributeValue.attrName = "nssfsPool"; + attributeValue.data = ndsName; + attributeValue.size = strlen((char *)ndsName); + + MPKNSS_UNLOCK(); + err = (*DDCModifyEntryPtr)(context, 1, &attributeValue); + MPKNSS_LOCK(); + + free(ndsName); + MPKNSS_UNLOCK(); + return err; +} + +/**************************************************************************** + * + * This function finds all of the volume objects for a pool in a container + * and updates their pool name to the given one. + * + ****************************************************************************/ +STATUS MNDS_LinkVolumes( + utf8_t *container, + utf8_t *ndsName, + utf8_t *poolName) +{ + enum + { + LIST_BUFFER_SIZE = 520, + READ_BUFFER_SIZE = 600 + }; + + int dsContext; + int agentIdentityHandle; + int objectIdentityHandle; + int objectContext; + int err = zOK; + unsigned int listCount; + unsigned int readCount; + char *nameList[3]; + DDCListFilter listFilter; + DDCReadFilter readFilter; + NINT i; + NINT j; + NINT dataLen; + BOOL matchedServer; + BOOL matchedPool; +#if zLINUX + int type; + size_t addrSize; + BYTE addr[32]; +#endif +typedef struct +{ + BYTE serverName[NDS_SERVER_SIZE]; + BYTE *listData[LIST_BUFFER_SIZE]; + DDCVALUE readData[READ_BUFFER_SIZE]; +} AllocStuff_s; + + AllocStuff_s *as; + + ASSERT_MPKNSS_LOCK(); + + if (!NdsPublicsLoaded) + { + if (LB_ImportNDSPublics((LONG)MANAGE_ModuleHandle) != zOK) + { + zASSERT("Error importing NDS publics" == NULL); + goto out; + } + } + + as = malloc(sizeof(*as)); + if (as == NULL) + { + err = zERR_NO_MEMORY; + goto out; + } + + MPKNSS_UNLOCK(); + + nameList[0] = "Host Server"; + nameList[1] = "Host Resource Name"; + nameList[2] = 0; + + readFilter.syncFormat = 0; + readFilter.attributes = (DDCString **) &nameList; + readFilter.minValueTime.seconds = 0; + + /* Create a DClient Context */ + err = (*DDCCreateContextPtr)((SAL_ModHandle)(long)MANAGE_ModuleHandle, &dsContext); + if (err != 0) + { + goto exit; + } + + /* Create a DClient Context for reading list values*/ + err = (*DDCCreateContextPtr)((SAL_ModHandle)(long)MANAGE_ModuleHandle, &objectContext); + if (err != 0) + { + goto cleanup1; + } + + /* Login as a server to have all rights */ + err = LoginToNDS(dsContext, &agentIdentityHandle); + if (err != 0) + { + goto cleanup; + } + + err = LoginToNDS(objectContext, &objectIdentityHandle); + if (err != 0) + { + goto logoutDS; + } + + /* Get the server's NDS name */ +#if zLINUX + err = (*DDCGetDefaultAddressPtr)(&type, sizeof(addr), &addrSize, addr); + if (err == 0) + { + err = (*DDCConnectToAddressPtr)(dsContext, 0, type, addrSize, addr); + } +#endif + err = (*DDCGetServerNamePtr)(dsContext, as->serverName, NDS_SERVER_SIZE, + NULL, NULL); + if (err != 0) + { + goto logout; + } + + /* Resolve to the container */ + err = MNDS_ResolveName(dsContext, DS_READABLE | DS_DEREFERENCE_ALIASES, + container); + if (err != 0) + { + goto logout; + } + + listFilter.includeAllContainers = FALSE; + listFilter.excludeNonContainers = FALSE; + listFilter.filterOnDerefBaseClass = TRUE; + listFilter.listExtRefs = TRUE; + listFilter.baseClass = "Volume"; + listFilter.rdn = NULL; + listFilter.minModTime.seconds = 0; + listFilter.minModTime.replicaNumber = 0; + listFilter.minModTime.event = 0; + + /* Find each volume object and fix it up if it part of this pool */ + + do + { + err = (*DDCListToBufferPtr)(dsContext, &listFilter, DSI_ENTRY_DN, + LIST_BUFFER_SIZE, as->listData, &listCount); + if (err != 0) + { + zASSERT("Error from DDCListToBuffer" == NULL); + goto logout; + } + for (i = 0; i < listCount; i++) + { + /* Resolve to the volume object */ + err = MNDS_ResolveName(objectContext, + DS_READABLE | DS_DEREFERENCE_ALIASES, as->listData[i]); + if (err != 0) + { + zASSERT("Error from MNDS_ResolveName" == NULL); + goto logout; + } + matchedServer = FALSE; + matchedPool = FALSE; + do + { + err = (*DDCReadToBufferPtr)(objectContext, &readFilter, + DS_VALUE_INFO, READ_BUFFER_SIZE-1, READ_BUFFER_SIZE-1, as->readData, + &readCount); + if (err != 0) + { + zASSERT("Error from DDCReadToBufferPtr" == NULL); + goto logout; + } + for (j = 0; j < readCount; j++) + { + char tmp[512]; + + dataLen = as->readData[j].size; + if (dataLen > ATTR_TEMP_SIZE - 1) + { + dataLen = ATTR_TEMP_SIZE - 1; + } + memcpy(tmp, as->readData[j].data, dataLen); + tmp[dataLen] = '\0'; + + /* Compare the server and pool names. */ + if (stricmp(as->readData[j].attrName, + MSGNot("Host Server")) == 0) + { + if (strcmp(tmp, (char *)as->serverName) == 0) + { + matchedServer = TRUE; + } + } + else if (stricmp(as->readData[j].attrName, + MSGNot("Host Resource Name")) == 0) + { + if ((err = MNDS_CheckVolumesPool(tmp, poolName, + &matchedPool)) != zOK) + { + zASSERT(MSGNot("Error Checking volume's pool") == NULL); + goto logout; + } + } + else + { + zASSERT(MSGNot("Unknown attribute read during a DDCReadToBuffer") == NULL); + } + } + } while (readCount > 0); + /* + * If the pool and server names matched for this volume then update + * its link to the pool object. + */ + if (matchedServer && matchedPool) + { + if ((err = MDNS_UpdateVolumeLink(objectContext, container, + ndsName)) != zOK) + { + zASSERT(MSGNot("Error updating volume link") == NULL); + goto logout; + } + } + } + } while (listCount > 0); + + +logout: + LogoutFromNDS(objectContext, objectIdentityHandle); +logoutDS: + LogoutFromNDS(dsContext, agentIdentityHandle); +cleanup: + (*DDCFreeContextPtr)(objectContext); +cleanup1: + (*DDCFreeContextPtr)(dsContext); +exit: + MPKNSS_LOCK(); + free(as); +out: + return err; +} + +/**************************************************************************** + * + * This function gets the fields from the XML to then get an attributes info + * from an object. + * + ****************************************************************************/ +STATUS MNDS_ProcessGetAttribute( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + TagContent_s tagContent[3]; + const TagRequest_s tags[] = + { + {TAG_NAME, 0}, + {TAG_CONTEXT, 0}, + {TAG_ATTRIBUTENAME, 0}, + {0} + }; + + enum + { + NAME = 0, + CONTEXT = 1, + ATTRIBUTE_NAME = 2 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + if ((status = MNDS_GetAttributeFromNDS(virtInfo, + tagContent[CONTEXT].content, tagContent[NAME].content, + tagContent[ATTRIBUTE_NAME].content)) != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Error getting attribute from NDS")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + return zOK; +} +#endif + + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +/**************************************************************************** + * + * This function checks whether the specified pool exists or not + * KERNEL FUNC + * + ****************************************************************************/ +STATUS DoesPoolExist(utf8_t *poolName, VolumeID_t *poolID, NDSid_t *ndsID) +{ + STATUS status = zOK; + Pool_s *pool = NULL; + unicode_t *uniPoolName; + GeneralMsg_s genMsg; + + uniPoolName = malloc(zMAX_COMPONENT_NAME); + + if ((uniPoolName == NULL) || + (utf2uni(poolName, uniPoolName, zMAX_COMPONENT_NAME) == -1)) + { + status = zERR_NO_MEMORY; + goto exit; + } + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + pool = COMN_PoolNameLookup(&genMsg, uniPoolName, TRUE, poolID); + if (pool == NULL) + { + status = GetErrno(&genMsg); + goto exit; + } + if (ndsID != NULL) + { + *ndsID = pool->POOLndsObjectID; + } + COMN_Release(&pool); + +exit: + if (uniPoolName != NULL) + { + free(uniPoolName); + } + return status; +} +#endif + + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +/**************************************************************************** + * + * This function checks whether the specified volume exists or not + * KERNEL FUNC + * + ****************************************************************************/ +STATUS DoesVolumeExist(utf8_t *volName) +{ + STATUS status = zOK; + Volume_s *volume = NULL; + unicode_t *uniVolName; + GeneralMsg_s genMsg; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + uniVolName = malloc(zMAX_COMPONENT_NAME); + + if ((uniVolName == NULL) || + (utf2uni(volName, uniVolName, zMAX_COMPONENT_NAME) == -1)) + { + status = zERR_NO_MEMORY; + goto exit; + } + + volume = COMN_VolumeNameLookup(&genMsg, uniVolName, FALSE, NULL); + if (volume == NULL) + { + status = GetErrno(&genMsg); + goto exit; + } + COMN_Release(&volume); + +exit: + if (uniVolName != NULL) + { + free(uniVolName); + } + return status; +} +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +/**************************************************************************** + * + * This function gets the fields from the XML to add a volume + * + ****************************************************************************/ +STATUS MNDS_ProcessAddVolumeObject( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + void *session; + GUID_t dfsGUID; + zVolumeInfo_s info; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + NINT i; + BOOL nssVolume = TRUE; +#if zLINUX + char mountPoint[MOUNT_POINT_MAX_SIZE]; +#endif + + const TagRequest_s tags[] = + { + {TAG_NAME, 0}, + {TAG_CONTEXT, 0}, + {TAG_VOLUMENAME, 0}, + {TAG_DFSGUID, TR_OPTIONAL}, + {TAG_POOLNAME, TR_OPTIONAL | TR_CONTENT_REQUIRED}, + {TAG_NDSPOOLNAME, TR_OPTIONAL}, + {ATR_TYPE, TR_ATTRIBUTE | TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + NAME = 0, + CONTEXT = 1, + VOLUME_NAME = 2, + DFS_GUID = 3, + POOL_NAME = 4, + NDS_POOL_NAME = 5, + TYPE = 6 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto cleanup; + } + return status; + } + + if (tagContent[TYPE].flags & TR_TAG_FOUND) + { + if (stricmp(tagContent[TYPE].content,"NSS") == 0) + { + nssVolume = TRUE; + } + else if (stricmp(tagContent[TYPE].content,"traditional") == 0) + { + nssVolume = FALSE; + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Invalid volume type specified")); + goto cleanup; + } + } + + if (nssVolume) + { + if (!(tagContent[POOL_NAME].flags & TR_TAG_FOUND) || + !(tagContent[NDS_POOL_NAME].flags & TR_TAG_FOUND)) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Missing NDS name or context")); + goto cleanup; + } + + /* Uppercase and validate that the pool name is a real active pool*/ + for (i = 0; tagContent[POOL_NAME].content[i] != '\0'; i++) + { + tagContent[POOL_NAME].content[i] = + toupper(tagContent[POOL_NAME].content[i]); + } + + tagContent[POOL_NAME].content[i] = '\0'; + + if ((status = DoesPoolExist(tagContent[POOL_NAME].content, NULL, NULL)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error finding pool in NSS")); + goto cleanup; + } + } + + /* Uppercase and validate that the volume name exists. */ + for (i = 0; tagContent[VOLUME_NAME].content[i] != '\0'; i++) + { + tagContent[VOLUME_NAME].content[i] = + toupper(tagContent[VOLUME_NAME].content[i]); + } + + if (nssVolume) + { + tagContent[VOLUME_NAME].content[i] = '\0'; + if (utf2uni(tagContent[VOLUME_NAME].content, uniVolName, + sizeof(uniVolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to unicode")); + goto cleanup; + } + + if ((status = DoesVolumeExist(tagContent[VOLUME_NAME].content)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error finding volume in NSS")); + goto cleanup; + } + } + + /* process the optional dfs GUID */ + if ((tagContent[DFS_GUID].flags & TR_TAG_FOUND) && + (tagContent[DFS_GUID].content)) + { + if ((status = LB_GUIDFromUTF8(tagContent[DFS_GUID].content, + &dfsGUID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error converting dfs GUID")); + goto cleanup; + } + + if (!LB_GUIDValidate(&dfsGUID)) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid dfs GUID")); + goto cleanup; + } + } + else + { + /* If the volume already has a DFS GUID assigned, just use that */ + if (ConnectToVolMan(&session) == zOK) + { + MPKNSS_UNLOCK(); + if (volManMapVolumeToGUID(session, uniVolName, &dfsGUID) != zOK) + { + dfsGUID = zINVALID_GUID; + } + MPKNSS_LOCK(); + (void) DisconnectFromVolMan(session); + } + else + { + dfsGUID = zINVALID_GUID; + } + } + +#if zLINUX + /* + * Check fstab then mtab then use the default + */ + if ((MNSS_GetMountPoint(tagContent[VOLUME_NAME].content, FALSE, mountPoint, + NULL, NULL, NULL, NULL) <= 0) && + (MNSS_GetMountPoint(tagContent[VOLUME_NAME].content, TRUE, mountPoint, + NULL, NULL, NULL, NULL) <= 0)) + { + sprintf(mountPoint, MSGNot("%s%s"), VOLUME_MOUNT_POINT, + tagContent[VOLUME_NAME].content); + } +#endif + + /* Now, add the object to NDS */ + if ((status = MNDS_AddVolumeToNDS(virtInfo, nssVolume, + tagContent[CONTEXT].content, + tagContent[NAME].content, tagContent[POOL_NAME].content, + tagContent[VOLUME_NAME].content, tagContent[NDS_POOL_NAME].content, +#if zLINUX + mountPoint, +#endif + &dfsGUID, &info.ndsObjectID, FALSE)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error adding volume to NDS")); + goto cleanup; + } + + if (nssVolume) + { + status = SetNDSInfoOnVolume(uniVolName, &info, FALSE, FALSE); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error setting NDS object ID for NSS volume")); + goto cleanup; + } + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +cleanup: + return zOK; +} +#endif + + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +/**************************************************************************** + * + * This function... + * KERNEL FUNC + * + ****************************************************************************/ + +STATUS SetNDSInfoOnPool(unicode_t *uniPoolName, zInfo_s *info) +{ + STATUS status; + GeneralMsg_s genMsg; + VolumeID_t poolID; + Pool_s *pool; + ModifyInfoMsg_s modInfoMsg; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + pool = COMN_PoolNameLookup(&genMsg, uniPoolName, TRUE, &poolID); + if (pool == NULL) + { + status = GetErrno(&genMsg); + return status; + } + + COMN_STRUCT_INIT(modInfoMsg); + COMN_SETUP_MODIFY_INFO_MSG(&modInfoMsg, zMOD_POOL_NDS_OBJECT_ID, + info, zINFO_VERSION_A); + + modInfoMsg.parentZid = pool->VOLfirstParentZid; + + X_LATCH(&pool->POOLbeastLatch); + status = pool->POOLcomnBeastOps.BST_modifyInfo(&genMsg,&pool->POOLroot, &modInfoMsg, + NULL); + UNX_LATCH(&pool->POOLbeastLatch); + COMN_Release(&pool); + + return status; +} +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +/**************************************************************************** + * + * This function gets the fields from the XML to add a pool + * + ****************************************************************************/ +STATUS MNDS_ProcessAddPoolObject( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + utf8_t *poolName; + VolumeID_t poolID; + zInfo_s info; + BOOL shared; + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + utf8_t *retContainer = NULL; + utf8_t *retName = NULL; + const TagRequest_s tags[] = + { + {TAG_NAME, 0}, + {TAG_CONTEXT, 0}, + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_SHARED, TR_OPTIONAL}, + {TAG_LINKVOLUMES, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + NAME = 0, + CONTEXT = 1, + POOL_NAME = 2, + SHARED = 3, + LINK_VOLUMES = 4 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto cleanup; + } + return status; + } + + poolName = tagContent[POOL_NAME].content; + + if (utf2uni(poolName, uniPoolName, sizeof(uniPoolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting to unicode")); + goto cleanup; + } + if ((status = DoesPoolExist(poolName, &poolID, NULL)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error finding pool in NSS")); + goto cleanup; + } + + shared = (tagContent[SHARED].flags & TR_TAG_FOUND) ? TRUE : FALSE; + + if ((status = MNDS_AddPoolToNDS(virtInfo, tagContent[CONTEXT].content, + tagContent[NAME].content, poolName, &poolID, shared, + &info.pool.ndsObjectID, &retContainer, &retName, NULL)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error adding pool to NDS")); + goto cleanup; + } + + /* If we get here with no error, no supplied context for the pool + and the MNDS_AddPoolToNDS returns no container (retContainer) + in which it created the pool then no object was created. This + happens for shared pools. */ + if ((tagContent[CONTEXT].content == NULL) && (retContainer == NULL)) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NOT_SUPPORTED, + MSGNot("A default named pool object cannot be created for an existing shared pool")); + goto cleanup; + } + + status = SetNDSInfoOnPool(uniPoolName, &info); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error setting NDS object ID for NSS pool")); + goto cleanup; + } + + if (tagContent[LINK_VOLUMES].flags & TR_TAG_FOUND) + { + if ((status = MNDS_LinkVolumes( + tagContent[CONTEXT].content ? tagContent[CONTEXT].content : retContainer, + retName, poolName)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error linking volumeobjects to the pool object")); + goto cleanup; + } + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +cleanup: + if (retName) + { + free(retName); + } + if (retContainer) + { + free(retContainer); + } + + return zOK; +} + +/**************************************************************************** + * + * This function gets the fields from the XML to remove a user + * + ****************************************************************************/ +STATUS MNDS_ProcessRemoveObject( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + TagContent_s tagContent[2]; + const TagRequest_s tags[] = + { + {TAG_NAME, 0}, + {TAG_CONTEXT, 0}, + {0}, + }; + + enum + { + NAME = 0, + CONTEXT = 1 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + if ((status = MNDS_RemoveObjectFromNDS(tagContent[CONTEXT].content, + tagContent[NAME].content, NULL)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error removing an object from NDS")); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; +} + + +/**************************************************************************** + * + * This function gets the fields from the XML to add a user + * + ****************************************************************************/ +STATUS MNDS_ProcessAddUser( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) + +{ + STATUS status; + TagContent_s tagContent[8]; + const TagRequest_s tags[] = + { + {TAG_NAME, 0}, + {TAG_CONTEXT, 0}, + {TAG_SURNAME, 0}, + {TAG_USERDESCRIPTION, TR_OPTIONAL}, + {TAG_SECURITYEQUALS, TR_OPTIONAL}, + {TAG_FULLNAME, TR_OPTIONAL}, + {TAG_GIVENNAME, TR_OPTIONAL}, + {TAG_PASSWORD, 0}, + {0} + }; + + enum + { + NAME = 0, + CONTEXT = 1, + SURNAME = 2, + USER_DESC = 3, + SECURITY_EQ = 4, + FULL_NAME = 5, + GIVEN_NAME = 6, + PASSWORD = 7 + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + if ((status = MNDS_AddUserToNDS(virtInfo, tagContent[CONTEXT].content, + tagContent[SURNAME].content, tagContent[GIVEN_NAME].content, + tagContent[FULL_NAME].content, tagContent[NAME].content, + tagContent[USER_DESC].content, tagContent[SECURITY_EQ].content, + tagContent[PASSWORD].content)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error adding user to NDS")); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function calls the dclient interfaces to get the server name from NDS + * + ****************************************************************************/ +STATUS MNDS_GetServerNameFromNDS( + utf8_t *serverName, + utf8_t *container) +{ + int dsContext; + int agentIdentityHandle; + int err = zOK; + + ASSERT_MPKNSS_LOCK(); + + if (!NdsPublicsLoaded) + { + if ((err = LB_ImportNDSPublics((LONG)MANAGE_ModuleHandle)) != zOK) + { + zASSERT("Error importing NDS publics" == NULL); + goto exit; + } + } + + MPKNSS_UNLOCK(); + + /* Create a DClient Context */ + err = (*DDCCreateContextPtr)((SAL_ModHandle)(long)MANAGE_ModuleHandle, &dsContext); + if (err != 0) + { +// syslog(LOG_INFO, "Couldn't create NDS context!\n"); + goto reLockNSS; + } + + /* Login as a server to have all rights */ + err = LoginToNDS(dsContext, &agentIdentityHandle); + if (err != 0) + { +// syslog(LOG_INFO, "Couldn't log in to NDS!\n"); + goto cleanup; + } + + /* Get the server's NDS name */ + err = GetServerNameFromNDS(dsContext, NULL, serverName, container); + if (err != 0) + { +// syslog(LOG_INFO, "Couldn't get server name!\n"); + goto logout; + } + +logout: + LogoutFromNDS(dsContext, agentIdentityHandle); +cleanup: + (*DDCFreeContextPtr)(dsContext); +reLockNSS: + MPKNSS_LOCK(); +exit: + return err; +} +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +/**************************************************************************** + * + * This function takes the passed in distinguished name for an object and + * returns it in root right form (dot delimited). + * + ****************************************************************************/ +void MNSS_ConvertToRootRight( + utf8_t *name, + utf8_t *newName) +{ + NINT i; + BOOL rootRight = FALSE; + SNINT objectIndex; + SNINT startIndex = 0; + BOOL putInDot; + SNINT leftMost; + NINT nameEnd; + NINT nameStart; + NINT len; + + for (i = 0; name[i] != '\0'; i++) + { + if (name[i] == '.') + { + rootRight = TRUE; + } + } + + if (rootRight) + { + strcpy(newName, name); + } + else + { + /* skip over leading slash */ + if (name[0] == '\\') + { + putInDot = TRUE; + leftMost = 1; + } + else + { + putInDot = FALSE; + leftMost = 0; + } + + objectIndex = strlen(name) - 1; + if (name[objectIndex] == '\\') + { /* skip trailing slash */ + nameEnd = --objectIndex; + } + else + { + nameEnd = objectIndex; + } + + startIndex = 0; + newName[0] = '\0'; + + /* Switch the object order from left root to right root */ + for (; objectIndex >= leftMost; objectIndex--) + { + nameStart = objectIndex; + if ((name[objectIndex] == '\\') || (objectIndex == leftMost)) + { /* found the start of the next object */ + if (objectIndex == leftMost) + { + nameStart--; + } + if (putInDot) + { + newName[startIndex++] = '.'; + } + putInDot = TRUE; + len = nameEnd - nameStart; + memcpy(&newName[startIndex], &name[nameStart + 1], len); + startIndex += len; + newName[startIndex] = '\0'; + nameEnd = objectIndex - 1; + } + } + + /* Add trailing dot */ + newName[startIndex++] = '.'; + newName[startIndex] = '\0'; + } +//aprintf(YELLOW, "Convert DN\n name:%s\n new name:%s\n", name, newName); +} +#endif diff --git a/src/nwnss/sharedsrc/managePartition.c.h b/src/nwnss/sharedsrc/managePartition.c.h new file mode 100644 index 0000000..c1fd78c --- /dev/null +++ b/src/nwnss/sharedsrc/managePartition.c.h @@ -0,0 +1,4033 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2005 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: bbhanuprakash $ + | $Date: 2008-08-20 10:01:15 +0530 (Wed, 20 Aug 2008) $ + | + | $RCSfile$ + | $Revision: 2440 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage NSS using XML + | + +-------------------------------------------------------------------------*/ +#if zNETWARE +#include +#endif + +#include +#include + +#include +#include + +#if zNETWARE +#include // Temp until Allen moves the parttion prototypes into mmpublic.h +#include +#include +#include +#include +#include "manageStartup.h" +#endif + +#if zLINUX && !defined(__KERNEL__) +#include +#include +#include +extern void syslog (int __pri, __const char *__fmt, ...) + __attribute__ ((__format__(__printf__, 2, 3))); +#include "manageEVMS.h" +#endif + +#include +#include +#include "manage.h" +#include "manageNlm.h" +#include "nssPubs.h" +#include "comnPublics.h" +#include "comnAuthorize.h" +#include "virtualIO.h" +#include "xmlTags.h" + +#if zLINUX && !defined(__KERNEL__) +STATUS Linux_RemovePartition(utf8_t *tagName, VirtInfo_s *virtInfo, utf8_t *partitionID, BOOL ignoreShare); +STATUS Linux_FillInPartitionInfo(utf8_t *tagName, VirtInfo_s *virtInfo, utf8_t *partitionID); +STATUS Linux_addPartitions2(utf8_t *tagName, VirtInfo_s *virtInfo, utf8_t *freeSpaceID, + NINT partitionType, QUAD size, utf8_t *label, BOOL ignoreShare); +STATUS Linux_modifyPartition(utf8_t *tagName, VirtInfo_s *virtInfo, utf8_t *partitionID, + utf8_t *label, QUAD growSize, QUAD shrinkSize); +#endif + + +#if zNETWARE +#define PARTAPI_NLM_NAME MSGNot("PARTAPI.NLM") +#define PARTAPI_NLM MSGNot("\x0b" "PARTAPI.NLM") +#define MM_CreateHotFixAPI MSGNot("\x0f" "MM_CreateHotFix") +#define MM_CreateMirrorAPI MSGNot("\x0f" "MM_CreateMirror") +#define MM_CreatePartitionAPI MSGNot("\x12" "MM_CreatePartition") +#define MM_AddMirrorObjectToMirrorGroupAPI MSGNot("\x1f" "MM_AddMirrorObjectToMirrorGroup") +#define MM_DelPartitionFromMirrorGroupAPI MSGNot("\x1e" "MM_DelPartitionFromMirrorGroup") +#define MM_DeleteHotFixAPI MSGNot("\x0f" "MM_DeleteHotFix") +#define MM_DeleteMirrorAPI MSGNot("\x0f" "MM_DeleteMirror") +#define MM_DeletePartitionAPI MSGNot("\x12" "MM_DeletePartition") +#define MM_InitializePartitionTableAPI MSGNot("\x1b" "MM_InitializePartitionTable") +#define MM_ReturnPartitionTableInfoAPI MSGNot("\x1b" "MM_ReturnPartitionTableInfo") +#define MM_ForceMirrorGroupInSyncAPI MSGNot("\x19" "MM_ForceMirrorGroupInSync") +STATUS PART_FillInPartitionInfo(VirtInfo_s *virtInfo, utf8_t *tagName, LONG partID, OBID deviceID); +STATUS PART_SetPartitionLabel(LONG pid, BYTE *partitionLabel); +STATUS NW_modifyPartition(utf8_t *tagName, VirtInfo_s *virtInfo, OBID partID, utf8_t *label); + +LONG (*PARTAPICreatePartitionPtr)( + LONG devid, + LONG pType, + LONG startSector, + LONG sectors, + LONG *pid) = NULL; + +LONG (*PARTAPICreateHotfixPtr)( + LONG partid, + LONG hotfixSize, + LONG *hotfixid) = NULL; + +LONG (*PARTAPICreateMirrorPtr)( + LONG partid, + LONG *mirrorid) = NULL; + +LONG (*PARTAPIAddMirrorObjectToMirrorGroupPtr)( + LONG mirrorID, + LONG mirrorToID) = NULL; + +LONG (*PARTAPIDeleteHotfixPtr)( + LONG hotFixObjectID) = NULL; + +LONG (*PARTAPIDeleteMirrorPtr)( + LONG mirrorObjectID) = NULL; + +LONG (*PARTAPIDeletePartitionPtr)( + LONG pid, + LONG pType, + LONG startSector, + LONG sectors) = NULL; + +LONG (*PARTAPIDelPartitionFromMirrorGroupPtr)( + LONG pid ) = NULL; + +LONG (*PARTAPIInitializePartitionTablePtr)( + LONG deviceObjectHandle) = NULL; + +LONG (*PARTAPIReturnPartTableInfoPtr)( + LONG deviceObjectHandle, + LONG *partitionTableStatus, + LONG *alignment, + LONG *areaStart, + LONG *areaLength, + LONG *partitionCount, + struct MM_PartitionInfoStruct *partitionInfo) = NULL; + +LONG (*PARTAPIForceMirrorGroupInSyncPtr)( + LONG mirrorGroupID) = NULL; + +BOOL ILoadedPARTAPI = FALSE; +#endif + +#if zNETWARE +STATUS MNSS_ProcessListPartitions(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessAddPartition(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetPartitionMirrorStats(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessAddPartitionToMirror(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessRemovePartitionFromMirror(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessResyncPartitionMirror(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +#endif +STATUS MNSS_ProcessRemovePartition(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetPartitionInfo(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessAddPartition2(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessModifyPartition(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ +SiblingElements_s PartitionElements[] = +{ +#if zNETWARE + {TAG_LISTPARTITIONS, MNSS_ProcessListPartitions}, + {TAG_ADDPARTITION, MNSS_ProcessAddPartition}, + {TAG_GETPARTITIONMIRRORSTATS, MNSS_ProcessGetPartitionMirrorStats}, + {TAG_ADDPARTITIONTOMIRROR, MNSS_ProcessAddPartitionToMirror}, + {TAG_REMOVEPARTITIONFROMMIRROR, MNSS_ProcessRemovePartitionFromMirror}, + {TAG_RESYNCPARTITIONMIRROR, MNSS_ProcessResyncPartitionMirror}, +#endif + {TAG_REMOVEPARTITION, MNSS_ProcessRemovePartition}, + {TAG_GETPARTITIONINFO, MNSS_ProcessGetPartitionInfo}, + {TAG_ADDPARTITION2, MNSS_ProcessAddPartition2}, + {TAG_MODIFYPARTITION, MNSS_ProcessModifyPartition}, + {0} +}; + + +#if zNETWARE +/****************************************************************************** +* Functions to load PARTAPI.NLM and import it's functions. +* These are needed to call the Media Manager Partition API's. +* +******************************************************************************/ + +STATUS PART_ImportPARTAPIFunctionPtrs() +{ + ASSERT_MPKNSS_LOCK(); + + if (PARTAPICreatePartitionPtr == NULL) + { + ZOS_ImportPublicSymbol(PARTAPICreatePartitionPtr, + (LONG)MANAGE_ModuleHandle, (BYTE *)MM_CreatePartitionAPI); + if (PARTAPICreatePartitionPtr == NULL) + { + goto ReturnError; + } + } + + if (PARTAPICreateHotfixPtr == NULL) + { + ZOS_ImportPublicSymbol(PARTAPICreateHotfixPtr, + (LONG)MANAGE_ModuleHandle, (BYTE *)MM_CreateHotFixAPI); + if (PARTAPICreateHotfixPtr == NULL) + { + goto ReturnError; + } + } + + if (PARTAPICreateMirrorPtr == NULL) + { + ZOS_ImportPublicSymbol(PARTAPICreateMirrorPtr, + (LONG)MANAGE_ModuleHandle, (BYTE *)MM_CreateMirrorAPI); + if (PARTAPICreateMirrorPtr == NULL) + { + goto ReturnError; + } + } + + if (PARTAPIAddMirrorObjectToMirrorGroupPtr == NULL) + { + ZOS_ImportPublicSymbol(PARTAPIAddMirrorObjectToMirrorGroupPtr, + (LONG)MANAGE_ModuleHandle, (BYTE *)MM_AddMirrorObjectToMirrorGroupAPI); + if (PARTAPIAddMirrorObjectToMirrorGroupPtr == NULL) + { + goto ReturnError; + } + } + + if (PARTAPIDeleteHotfixPtr == NULL) + { + ZOS_ImportPublicSymbol(PARTAPIDeleteHotfixPtr, + (LONG)MANAGE_ModuleHandle, (BYTE *)MM_DeleteHotFixAPI); + if (PARTAPIDeleteHotfixPtr == NULL) + { + goto ReturnError; + } + } + + if (PARTAPIDeleteMirrorPtr == NULL) + { + ZOS_ImportPublicSymbol(PARTAPIDeleteMirrorPtr, + (LONG)MANAGE_ModuleHandle, (BYTE *)MM_DeleteMirrorAPI); + if (PARTAPIDeleteMirrorPtr == NULL) + { + goto ReturnError; + } + } + + if (PARTAPIDeletePartitionPtr == NULL) + { + ZOS_ImportPublicSymbol(PARTAPIDeletePartitionPtr, + (LONG)MANAGE_ModuleHandle, (BYTE *)MM_DeletePartitionAPI); + if (PARTAPIDeletePartitionPtr == NULL) + { + goto ReturnError; + } + } + + if (PARTAPIDelPartitionFromMirrorGroupPtr == NULL) + { + ZOS_ImportPublicSymbol(PARTAPIDelPartitionFromMirrorGroupPtr, + (LONG)MANAGE_ModuleHandle, (BYTE *)MM_DelPartitionFromMirrorGroupAPI); + if (PARTAPIDelPartitionFromMirrorGroupPtr == NULL) + { + goto ReturnError; + } + } + + if (PARTAPIInitializePartitionTablePtr == NULL) + { + ZOS_ImportPublicSymbol(PARTAPIInitializePartitionTablePtr, + (LONG)MANAGE_ModuleHandle, (BYTE *)MM_InitializePartitionTableAPI); + if (PARTAPIInitializePartitionTablePtr == NULL) + { + goto ReturnError; + } + } + + if (PARTAPIReturnPartTableInfoPtr == NULL) + { + ZOS_ImportPublicSymbol(PARTAPIReturnPartTableInfoPtr, + (LONG)MANAGE_ModuleHandle, (BYTE *)MM_ReturnPartitionTableInfoAPI); + if (PARTAPIReturnPartTableInfoPtr == NULL) + { + goto ReturnError; + } + } + + if (PARTAPIForceMirrorGroupInSyncPtr == NULL) + { + ZOS_ImportPublicSymbol(PARTAPIForceMirrorGroupInSyncPtr, + (LONG)MANAGE_ModuleHandle, (BYTE *)MM_ForceMirrorGroupInSyncAPI); + if (PARTAPIForceMirrorGroupInSyncPtr == NULL) + { + goto ReturnError; + } + } + return zOK; + +ReturnError: + return zFAILURE; +} + + +void PART_UnimportPARTAPIFunctionPtrs(void) +{ + ASSERT_MPKNSS_LOCK(); + + if (PARTAPICreatePartitionPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)MANAGE_ModuleHandle, MM_CreatePartitionAPI); + PARTAPICreatePartitionPtr = NULL; + } + + if (PARTAPICreateHotfixPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)MANAGE_ModuleHandle, MM_CreateHotFixAPI); + PARTAPICreateHotfixPtr = NULL; + } + + if (PARTAPICreateMirrorPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)MANAGE_ModuleHandle, MM_CreateMirrorAPI); + PARTAPICreateMirrorPtr = NULL; + } + + if (PARTAPIAddMirrorObjectToMirrorGroupPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)MANAGE_ModuleHandle, MM_AddMirrorObjectToMirrorGroupAPI); + PARTAPIAddMirrorObjectToMirrorGroupPtr = NULL; + } + + if (PARTAPIDeleteHotfixPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)MANAGE_ModuleHandle, MM_DeleteHotFixAPI); + PARTAPIDeleteHotfixPtr = NULL; + } + + if (PARTAPIDeleteMirrorPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)MANAGE_ModuleHandle, MM_DeleteMirrorAPI); + PARTAPIDeleteMirrorPtr = NULL; + } + + if (PARTAPIDeletePartitionPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)MANAGE_ModuleHandle, MM_DeletePartitionAPI); + PARTAPIDeletePartitionPtr = NULL; + } + + if (PARTAPIDelPartitionFromMirrorGroupPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)MANAGE_ModuleHandle, MM_DelPartitionFromMirrorGroupAPI); + PARTAPIDelPartitionFromMirrorGroupPtr = NULL; + } + + if (PARTAPIInitializePartitionTablePtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)MANAGE_ModuleHandle, MM_InitializePartitionTableAPI); + PARTAPIInitializePartitionTablePtr = NULL; + } + + if (PARTAPIReturnPartTableInfoPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)MANAGE_ModuleHandle, MM_ReturnPartitionTableInfoAPI); + PARTAPIReturnPartTableInfoPtr = NULL; + } + + if (PARTAPIForceMirrorGroupInSyncPtr != NULL) + { + ZOS_UnImportPublicSymbol( + (LONG)MANAGE_ModuleHandle, MM_ForceMirrorGroupInSyncAPI); + PARTAPIForceMirrorGroupInSyncPtr = NULL; + } + +} + +/****************************************************************************** + * SetupToCallPARTAPI - Make sure that the PARTAPI.NLM is loaded, and then + * import the function pointers. + * + *****************************************************************************/ + +STATUS PART_SetupToCallPARTAPI(void) +{ +// LONG ccode; + + ASSERT_MPKNSS_LOCK(); + +// if ((ILoadedPARTAPI == FALSE) && (ZOS_IsNLMLoaded(PARTAPI_NLM) == 0)) +// { +// ZOS_LoadModule(ccode, MANAGE_ConsoleScreen, PARTAPI_NLM_NAME, +// LO_LOAD_SILENT); +// if (ccode != 0) +// { +// return zFAILURE; +// } +// else +// { +// ILoadedPARTAPI = TRUE; +// } +// } + + if (PART_ImportPARTAPIFunctionPtrs() != zOK) + { + return zFAILURE; + } + + return zOK; +} + + +/****************************************************************************** + * CleanupCallToPARTAPI - Un-import the function pointers to the Media Manager + * partition API's, and then unload PARTAPI.NLM. + * + *****************************************************************************/ + +void PART_CleanupCallToPARTAPI(void) +{ + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + PART_UnimportPARTAPIFunctionPtrs(); + + if (ILoadedPARTAPI == TRUE) + { + ZOS_UnloadModule(status, MANAGE_ConsoleScreen, PARTAPI_NLM); + ILoadedPARTAPI = FALSE; + } + + return; +} + +/***************************************************************************** + * Set the label on A Partition + *****************************************************************************/ +STATUS PART_SetPartitionLabel( + LONG pid, + BYTE *partitionLabel) +{ + LONG ccode; + struct IOObjectGenericInfoDef partGen; + + ASSERT_MPKNSS_LOCK(); + + /* If we were asked to set a label, set one now */ + if (partitionLabel && (strlen(partitionLabel) != 0)) + { + ZMM_ReturnObjectGenericInfo(ccode, pid, + sizeof(struct IOObjectGenericInfoDef), &partGen); + if (ccode != MM_OK) + { + zASSERT("MM_ReturnObjectGenericInfo on pid FAILED"==NULL); + return(zERR_OBJECT_NOT_FOUND); + } + + ZMM_ObjectControl(ccode, + partGen.objectmanagerid, + MM_SET_PARTITION_LABEL, + pid, + 0, + 0, + LB_strlen( partitionLabel ), + partitionLabel ); + + if (ccode != MM_OK) + { + zASSERT("MM_ObjectControl MM_SET_PARTITION_LABEL on obid FAILED"==NULL); + return(zERR_OBJECT_NOT_FOUND); + } + } + return(zOK); +} + +/**************************************************************************** + * Get the raid device ID for a partition object + *****************************************************************************/ +STATIC OBID PART_GetRaidDeviceID(OBID partID) +{ + LONG *mappingInfo = NULL; + OBID raidID = 0; + UINT32 index; + NINT mappingInfoSize = 0; + STATUS retCode = MM_BUFFER_TOO_SMALL; + + raidID = -1; + + ASSERT_MPKNSS_LOCK(); + + /* + * Start with a generic size of 512 - and increase if the buffer is too + * small. + */ + mappingInfoSize = 512; + + while (retCode == MM_BUFFER_TOO_SMALL) + { + if (mappingInfo != NULL) + { + free(mappingInfo); + mappingInfo = NULL; + } + + mappingInfo = zalloc(mappingInfoSize); + if (mappingInfo == NULL) + { + zASSERT("getRaidDeviceID unable to allocate memory for mappingInfo"==NULL); + goto ReadyToReturn; + } + + /* Get the OBID of the partition object */ + ZMM_ReturnObjectMappingInfo(retCode, + partID, + MM_IO_CLASS, + mappingInfoSize, + mappingInfo); + if (retCode == MM_OK ) + { + /* We cant use a structure here, because the parent and sibling + * arrays are in-line flat in the IOObjectMappingTableDef. + */ + index = 3 + /* Accounts for parentCount, siblingCount, and childCount fields offsets */ + mappingInfo[0] + /* Accounts for parentOBIDs[parentCount] fields offsets */ + mappingInfo[1]; /* Accounts for siblingOBIDs[siblingCount] fields offsets */ + + /* Now we're at the offset of the childOBIDs[]. Use the first child */ + raidID = mappingInfo[index]; + } + else if (retCode == MM_BUFFER_TOO_SMALL) + { + mappingInfoSize += 512; + } + } + +ReadyToReturn: + if (mappingInfo != NULL) + { + free(mappingInfo); + } + + return raidID; +} + + +/**************************************************************************** + * Get info on a partitions object + *****************************************************************************/ +STATUS PART_GetOnePartitionInfo( + OBID partID, + struct IOObjectGenericInfoDef *partGen, + struct PartitionSpecificInfoDef *partInfo, + struct IOObjectGenericInfoDef *devGen, + OBID *devID) +{ + LONG ccode; + + ASSERT_MPKNSS_LOCK(); + MPKNSS_UNLOCK(); + + /* Get the generic info on the partition */ + if (partGen != NULL) + { + bzero(partGen, sizeof(struct IOObjectGenericInfoDef)); + ccode = MM_ReturnObjectGenericInfo(partID, + sizeof(struct IOObjectGenericInfoDef), partGen); + if (ccode != MM_OK) + { + MPKNSS_LOCK(); + zASSERT("MM_ReturnObjectGenericInfo on partition FAILED"==NULL); + return(ccode); + } + } + + /* Get the specific info on the partition */ + if (partInfo != NULL) + { + bzero(partInfo, sizeof(struct PartitionSpecificInfoDef)); + ccode = MM_ReturnObjectSpecificInfo(partID, + sizeof(struct PartitionSpecificInfoDef), partInfo); + if (ccode != MM_OK) + { + MPKNSS_LOCK(); + zASSERT("MM_ReturnObjectSpecificInfo on partition obj FAILED"==NULL); + return(ccode); + } + } + + /* Get generic info on the device containing the partition */ + if (devGen != NULL) + { + ccode = MM_ReturnObjectProgenitor(partID, MM_DEVICE_OBJECT, devID); + if (ccode != MM_OK) + { + MPKNSS_LOCK(); + zASSERT("MM_ReturnObjectProgenitor on partition obj FAILED"==NULL); + + *devID = 0; + return(ccode); + } + + bzero(devGen, sizeof(struct IOObjectGenericInfoDef)); + ccode = MM_ReturnObjectGenericInfo(*devID, + sizeof(struct IOObjectGenericInfoDef), devGen); + if (ccode != MM_OK) + { + MPKNSS_LOCK(); + zASSERT("MM_ReturnObjectGenericInfo on device obj FAILED"==NULL); + return(ccode); + } + } + + MPKNSS_LOCK(); + return(zOK); +} + + +/**************************************************************************** + * Walk the partition's child list looking for the logical partition. In + * the meantime, save any hotfix and mirror info that we find. + *****************************************************************************/ +STATUS PART_GetLogicalPartition( + OBID partid, + OBID *logicalPartID, + OBID *mirrorID, + OBID *hotFixID, + struct IOObjectGenericInfoDef *logicalPartGen, + struct HotfixSpecificInfoDef *hotFixInfo) +{ + struct IOObjectGenericInfoDef tempGenInfo; + struct IOObjectGenericInfoDef retGenInfo; + UINT32 retCode, index; + OBID targetOBID; + LONG *mappingInfo = NULL; + NINT mappingInfoSize = 0; + NINT neededMappingInfoSize = 0; + LONG ccode; + + ASSERT_MPKNSS_LOCK(); + + /* + ** The MM_ObjectControl() function expects the OBID input + ** parameter to be the OBID of the object acting as the + ** highest level of abstraction to the physical partition. + ** Since we receive the OBID of the physical partition in + ** this routine, we must find the OBID of the highest + ** abstraction object which is the nth child object of the + ** physical partition (usually a mirror object). + */ + + *logicalPartID = 0; + *hotFixID = 0; + *mirrorID = 0; + bzero(logicalPartGen, sizeof(struct HotfixSpecificInfoDef)); + bzero(hotFixInfo, sizeof(struct HotfixSpecificInfoDef)); + + retCode = MM_OK; + targetOBID = partid; + + MPKNSS_UNLOCK(); + while (retCode == MM_OK) + { + retCode = MM_ReturnObjectGenericInfo(targetOBID, + sizeof(struct IOObjectGenericInfoDef), &tempGenInfo ); + if (retCode != MM_OK) + { + MPKNSS_LOCK(); + zASSERT("MM_ReturnObjectGenericInfo on obj FAILED"==NULL); + goto errorExit; + } + /* If this is a hotfix object, get and save its info */ + if (tempGenInfo.type == MM_PARTITION_OBJECT) + { + /* Save this gen info in case we find a Group object */ + memcpy(&retGenInfo, &tempGenInfo, + sizeof(struct IOObjectGenericInfoDef)); + } + else if (tempGenInfo.type == MM_HOTFIX_OBJECT) + { + *hotFixID = targetOBID; + /* Save this gen info in case we find a Group object */ + memcpy(&retGenInfo, &tempGenInfo, + sizeof(struct IOObjectGenericInfoDef)); + + ccode = MM_ReturnObjectSpecificInfo(targetOBID, + sizeof(struct HotfixSpecificInfoDef), hotFixInfo); + if (ccode != MM_OK) + { + MPKNSS_LOCK(); + zASSERT("MM_ReturnObjectSpecificInfo on hotfix obj FAILED"==NULL); + goto errorExit; + } + } + else if (tempGenInfo.type == MM_MIRROR_OBJECT) + { + /* Save this gen info in case we find a Group object */ + memcpy(&retGenInfo, &tempGenInfo, + sizeof(struct IOObjectGenericInfoDef)); + *mirrorID = targetOBID; + } + + if (tempGenInfo.status & MM_LOGICAL_PARTITION_OBJECT) + { + *logicalPartID = targetOBID; + /* Dont copy the group object gen info. Instead, save the higher + * of either Partition, Hotfix or Mirror. + */ + memcpy(logicalPartGen, &retGenInfo, + sizeof(struct IOObjectGenericInfoDef)); + break; + } + + /* We haven't found the logical partition yet, so there better + * be more children. + */ + +#if NSS_DEBUG IS_ENABLED + MPKNSS_LOCK(); + zASSERT((tempGenInfo.childcount > 0) && + (tempGenInfo.childcount < 2)); + MPKNSS_UNLOCK(); +#endif + + if (tempGenInfo.childcount == 0) + { + goto okExit; + } + + /* Figure out how much space we need for the returned mapping info, + * and make sure our "mappingINfo" pointer points to a buffer big + * enough for the reply. + */ + neededMappingInfoSize = sizeof(LONG) * + (3 + /* Generic header with parentCount, siblingCount & childCount */ + tempGenInfo.parentcount + + tempGenInfo.siblingcount + + tempGenInfo.childcount); + + if (neededMappingInfoSize > mappingInfoSize) + { + MPKNSS_LOCK(); + if (mappingInfo != NULL) + { + free(mappingInfo); + } + mappingInfo = zalloc(neededMappingInfoSize); + MPKNSS_UNLOCK(); + mappingInfoSize = neededMappingInfoSize; + } + if (mappingInfo == NULL) + { + MPKNSS_LOCK(); + zASSERT("getLogicalPartition unable to allocate memory for mappingInfo"==NULL); + goto errorExit; + } + + /* Get the OBID of the first child object */ + retCode = MM_ReturnObjectMappingInfo(targetOBID, MM_IO_CLASS, + mappingInfoSize, mappingInfo); + if (retCode == MM_OK ) + { + /* We cant use a structure here, because the parent and sibling + * arrays are in-line flat in the IOObjectJappingTableDef. + */ + index = 3 + /* Accounts for parentCount, siblingCount, and childCount fields offsets */ + mappingInfo[0] + /* Accounts for parentOBIDs[parentCount] fields offsets */ + mappingInfo[1]; /* Accounts for siblingOBIDs[siblingCount] fields offsets */ + + /* Now we're at the offset of the childOBIDs[]. Use the first child */ + targetOBID = mappingInfo[index]; + } + } +okExit: + MPKNSS_LOCK(); + if (mappingInfo != NULL) + { + free(mappingInfo); + } + return(zOK); + +/*===========================================================================*/ +errorExit: + if (mappingInfo != NULL) + { + free(mappingInfo); + } + return(zFAILURE); +} + +/****************************************************************************** + * + * PART_GetPartitionSegmentInfo - Find information about a specified partition's + * pool/volume segments + * + ******************************************************************************/ + +STATUS PART_GetPartitionSegmentInfo( + NINT partType, + LONG partID, + struct LogicalPartitionMappingInfo **mappingInfoPtr) +{ + struct LogicalPartitionMappingInfo *mappingInfo = NULL; + struct LogicalPartitionMappingInfo *temp = NULL; + struct LogicalPartitionMappingElementDef *currentelement; + struct VolumeLimitDef limits; + OBID FSAPPid; + + STATUS status = zFAILURE; + NINT idx = 0; + NINT numberofelements = 0; + NINT size = 0; + + ASSERT_MPKNSS_LOCK(); + + if(partType == NETWARE_NSS_PARTITION) + { + FSAPPid = NSSAPPid; + } + else + { + FSAPPid = LEGACYAPPid; + } + + ZMM_ObjectControl(status, FSAPPid, MM_VOLUME_RETURN_LIMITS, 0, 0, 0, + sizeof(limits), &limits); + if ( status == MM_OK ) + { + /* + * Allocate enough memory to get all elements. + * If more than 1 meg is required to get names then bail out. This + * prevents a loop that exhausts memory resources. + */ + do + { + numberofelements += 8; /* expect 8 more segments */ + size += 8 * (sizeof(struct LogicalPartitionMappingElementDef) + + limits.maxVolumeNameSize) + + sizeof(struct LogicalPartitionMappingInfo); + if (mappingInfo == NULL) + { + mappingInfo = (struct LogicalPartitionMappingInfo*) zalloc(size); + } + else + { + temp = mappingInfo; + mappingInfo = (struct LogicalPartitionMappingInfo*) + realloc(mappingInfo, size); + } + if(mappingInfo != NULL) + { + bzero( mappingInfo,size ); + currentelement = &mappingInfo->element[0]; + + for (idx = 0; idx < numberofelements; idx++) + { + currentelement->volumeName = + ((BYTE *)&mappingInfo->element[numberofelements]) + + (idx * limits.maxVolumeNameSize); + ++currentelement; + } + + ZMM_ObjectControl(status, FSAPPid, + (partType == NETWARE_NSS_PARTITION) ? + MM_POOL_RETURN_PARTITION_MAPPING : + MM_VOLUME_RETURN_PARTITION_MAPPING, + partID, 0, 0, numberofelements, mappingInfo); + + if(status==MM_OK) + { + break; + } + } + else + { + free(temp); + temp = NULL; + status = MM_MEMORY_ALLOCATION_ERROR; + } + } while (status == MM_BUFFER_TOO_SMALL); + } + + *mappingInfoPtr = mappingInfo; + return(status); +} + + +/****************************************************************************** + * + * PART_GetServerPartitionInfo - Get free space for a partition, not used by a + * pool. This free space may be physical, mirrored or on a raid. + * + ******************************************************************************/ + +STATUS PART_GetServerPartitionInfo( + VirtInfo_s *virtInfo, + LONG partID, + OBID *devID, + OBID *mirrorID, + BYTE *devName, + LONG *devStatus, + LONG *devUnitSize, + QUAD *freeSpaceSize, + QUAD *offset) +{ + struct IOObjectGenericInfoDef devGen; + struct IOObjectGenericInfoDef partGen; + struct PartitionSpecificInfoDef partInfo; + struct IOObjectGenericInfoDef logicalPartGen; + struct HotfixSpecificInfoDef hotFixInfo; + OBID logicalPartID = 0; + OBID hotFixID = 0; + STATUS status; + LONG numSectors = 0; + BOOL hasPool; + BOOL partDeleted; + + *devID = 0; + *mirrorID = 0; + *devUnitSize = 0; + *freeSpaceSize = 0; + + + ASSERT_MPKNSS_LOCK(); + + if ((status = PART_GetOnePartitionInfo(partID, &partGen, &partInfo, &devGen, + devID)) != zOK) + { + // There was a problem getting the partition information. The details + // were ASSERTed in PART_GetOnePartitionInfo. We want to just skip this + // partition. + status = zOK; + goto exit; + } + + strcpy(devName, devGen.name); + *devStatus = devGen.status; + *devUnitSize = devGen.unitsize; + + switch (partInfo.partitiontype) + { + // If the partition does not contain a pool or volume, then the + // partition will be deleted in PART_CheckPartitionForPool. + // So that is why we test for both NSS and Traditional. + case NETWARE_NSS_PARTITION: + case NETWARE_386_PARTITION: + if ((status = PART_GetLogicalPartition(partID, &logicalPartID, + mirrorID, &hotFixID, &logicalPartGen, &hotFixInfo)) != zOK) + { + goto exit; + } + + if ((status = PART_CheckPartitionForPool(partID, &hasPool, &partDeleted)) != MM_OK) + { + // This partition is used by a pool + goto exit; + } + + if (partDeleted == TRUE) + { + goto exit; + } + + if (!hasPool) + { + numSectors = partInfo.partitionsize; + } + + break; + + case NETWARE_FREE_PARTITION: + numSectors = partInfo.partitionsize; + *offset = partInfo.partitionoffset; + break; + + default: + goto exit; + } + + *freeSpaceSize = numSectors; + +exit: + + return status; +} + + +/****************************************************************************** + * + * PART_FillInPartitionInfo - Find information about a specified + * partition and add the information to the return buffer. + * + ******************************************************************************/ + +STATUS PART_FillInPartitionInfo( + VirtInfo_s *virtInfo, + utf8_t *tagName, + LONG partID, + OBID deviceID) +{ + struct IOObjectGenericInfoDef logicalPartGen; + struct IOObjectGenericInfoDef partGen; + struct IOObjectGenericInfoDef devGen; + struct PartitionSpecificInfoDef partInfo; + struct HotfixSpecificInfoDef hotFixInfo; + struct LogicalPartitionMappingInfo *mappingInfo = NULL; + OBID devID; + OBID logicalPartID; + OBID mirrorID; + OBID hotFixID; + STATUS status; + utf8_t tempBuf[512]; + NINT idx; + + ASSERT_MPKNSS_LOCK(); + + + if ((status = PART_GetOnePartitionInfo(partID, &partGen, &partInfo, &devGen, + &devID)) != zOK) + { + MNSS_ReturnResult(virtInfo, TAG_PARTITIONINFO, status, + MSGNot("Error getting partition info")); + return zOK; + } + + + /* + * If a device ID was specified then filter out the other entries + */ + if (deviceID != -1 && deviceID != devID) + { + return zOK; + } + + if(tagName != NULL) + { + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) + != zOK) + { + return status; + } + } + + /* device name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_DEVICENAME, devGen.name, + FALSE)) != zOK) + { + return status; + } + + /* partition name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_PARTITIONNAME, partGen.name, + FALSE)) != zOK) + { + return status; + } + + /* partition type and partition ID */ + sprintf(tempBuf, MSGNot("<"TAG_DEVICEID">%u<" + TAG_PARTITIONTYPE">%u<" + TAG_STATE">%s<" + TAG_PARTITIONID">%u"), + devID, + partInfo.partitiontype & 0xFF, + (partInfo.partitiontype == NETWARE_FREE_PARTITION) ? "free" : "used", + partID); + if ((status = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + return status; + } + + /* partition label */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_LABEL, partInfo.label, + FALSE)) != zOK) + { + return status; + } + + /* offset and size */ + sprintf(tempBuf, + MSGNot("<"TAG_STARTINGSECTOR">%u<" + TAG_NUMSECTORS">%u\n"), + partInfo.partitionoffset, partInfo.partitionsize); + if ((status = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + return status; + } + + switch (partInfo.partitiontype) + { + case NETWARE_386_PARTITION: + case NETWARE_NSS_PARTITION: + case ORION_SBD_PARTITION: + case NOVELL_ISCSI_PARTITION: + if ((status = PART_GetLogicalPartition(partID, &logicalPartID, + &mirrorID, &hotFixID, &logicalPartGen, &hotFixInfo)) != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Error getting logical partition info")); + goto exit; + } + sprintf(tempBuf, + MSGNot("<"TAG_LOGICALPARTITIONID">%u<"TAG_LOGICALPARTITIONCAPACITY">%u<"TAG_MIRRORID">%u<"TAG_HOTFIXID">%u<"TAG_HOTFIXSIZE">%Lu<"TAG_HOTFIXAVAILSIZE">%Lu\n"), + logicalPartID, + logicalPartGen.capacity, + mirrorID, + hotFixID, + (QUAD)hotFixInfo.numberoftotalblocks * 8, + (QUAD)hotFixInfo.numberofavailableblocks * 8); + if ((status = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + return status; + } + + if ((status = PART_GetPartitionSegmentInfo(partInfo.partitiontype, + (mirrorID!=0 ? mirrorID:partID), &mappingInfo)) != zOK) + { + goto exit; + } + + if (partInfo.partitiontype == NETWARE_NSS_PARTITION) + { + zASSERT(mappingInfo->numberOfElements <= 1); + if ((mappingInfo->element[0].volumeName != NULL) && + (mappingInfo->element[0].volumeName[0] != 0)) + { + /* We should never have more than one pool in a partition */ + sprintf(tempBuf, + MSGNot("<"TAG_POOLNAME">%s\n"), + mappingInfo->element[0].volumeName); + + if ((status = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + free(mappingInfo); + return status; + } + } + } + else /* Traditional NetWare Partition */ + { + BOOL volTagAdded = FALSE; + + for(idx=0; idxnumberOfElements; idx++) + { + /* Ignore volumes with an empty name. On Traditional partitions + * these just represent unused volume space + */ + if ((mappingInfo->element[idx].volumeName == NULL) || + (mappingInfo->element[idx].volumeName[0] == 0)) + { + continue; + } + + if ((!volTagAdded) && + ((status = VIRT_AddResultTag(virtInfo, TAG_VOLUMES, + FALSE, TRUE)) != zOK)) + { + return status; + } + volTagAdded = TRUE; + + if ((status = VIRT_AddResultTag(virtInfo, TAG_VOLUMEINFO, + FALSE, TRUE)) != zOK) + { + return status; + } + + // Add the volume name, starting unit, and number of units to the + // output buffer. + sprintf(tempBuf, + MSGNot("<"TAG_VOLUMENAME">%s<" + TAG_VOLSTARTINGSECTOR">%u<" + TAG_VOLNUMSECTORS">%u\n"), + mappingInfo->element[idx].volumeName, + mappingInfo->element[idx].startingUnit, + mappingInfo->element[idx].numberOfUnits); + + if ((status = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + free(mappingInfo); + return status; + } + + status = VIRT_AddResultTag(virtInfo, TAG_VOLUMEINFO, + TRUE, TRUE); + } + if (volTagAdded) + { + status = VIRT_AddResultTag(virtInfo, TAG_VOLUMES, TRUE, TRUE); + } + } + break; + + case NETWARE_VDEVICE_PARTITION: + sprintf(tempBuf, MSGNot("<"TAG_RAIDID">%u\n"), + PART_GetRaidDeviceID(partID)); + if ((status = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + return status; + } + break; + default: + break; + } + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + +exit: + if(tagName != NULL) + { + status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + } + if (mappingInfo) + { + free(mappingInfo); + mappingInfo = NULL; + } + return status; +} + +/****************************************************************************** + * PART_CreatePartition - Give a freespace, create a partition. + ******************************************************************************/ +STATUS PART_CreatePartition( + OBID devID, + QUAD sectorswanted, + OBID *freeSpaceID) +{ + STATUS retVal; + + ASSERT_MPKNSS_LOCK(); + + // Check to see if the PARTAPI.NLM has been loaded. + retVal = PART_SetupToCallPARTAPI(); + if (retVal != zOK) + { + return retVal; + } + + MPKNSS_UNLOCK(); + retVal = PARTAPICreatePartitionPtr( + devID, + NETWARE_NSS_PARTITION, // partition type + 0, // startsector + sectorswanted, + freeSpaceID); + + MPKNSS_LOCK(); + + return retVal; +} + + +/****************************************************************************** + * + * PART_FillInSegmentInfo - Find information about a specified + * partition and add the information to the return buffer. + * + ******************************************************************************/ + +STATUS PART_FillInSegmentInfo( + VirtInfo_s *virtInfo, + OBID partID, + char *poolName) +{ + struct IOObjectGenericInfoDef logicalPartGen; + struct IOObjectGenericInfoDef partGen; + struct IOObjectGenericInfoDef devGen; + struct PartitionSpecificInfoDef partInfo; + struct HotfixSpecificInfoDef hotFixInfo; + struct LogicalPartitionMappingInfo *mappingInfo = NULL; + OBID devID; + OBID logicalPartID; + OBID mirrorID; + OBID hotFixID; + STATUS status; + utf8_t tempBuf[512]; + + ASSERT_MPKNSS_LOCK(); + + if ((status = PART_GetOnePartitionInfo(partID, &partGen, &partInfo, &devGen, + &devID)) != zOK) + { + return zOK; + } + + /* + * If this is not an NSS partition, don't do anything. + */ + if (partInfo.partitiontype != NETWARE_NSS_PARTITION) + { + return zOK; + } + + if ((status = PART_GetLogicalPartition(partID, &logicalPartID, + &mirrorID, &hotFixID, &logicalPartGen, &hotFixInfo)) != zOK) + { + goto exit; + } + + if ((status = PART_GetPartitionSegmentInfo(partInfo.partitiontype, + (mirrorID!=0 ? mirrorID:partID), &mappingInfo)) != zOK) + { + goto exit; + } + + // Check if we got the segment pool name back. If so, check if it is the + // pool that we are looking for. + zASSERT(mappingInfo->numberOfElements <= 1); + if ((mappingInfo->element[0].volumeName != NULL) && + (mappingInfo->element[0].volumeName[0] != 0) && + (LB_strcmp(poolName, (char *)mappingInfo->element[0].volumeName) != 0)) + { + return zOK; + } + + // This is the pool we are looking for, so build the segment info tag. + if ((status = VIRT_AddResultTag(virtInfo, TAG_SEGMENT, FALSE, TRUE)) + != zOK) + { + return status; + } + + /* device name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_DEVICENAME, devGen.name, + FALSE)) != zOK) + { + return status; + } + + /* partition name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_PARTITIONNAME, partGen.name, + FALSE)) != zOK) + { + return status; + } + + /* partition type and partition ID */ + sprintf(tempBuf, MSGNot("<"TAG_DEVICEID">%u<" + TAG_PARTITIONTYPE">%u<" + TAG_PARTITIONID">%u"), + devID, + partInfo.partitiontype & 0xFF, + partID); + if ((status = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + return status; + } + + /* partition label */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_LABEL, partInfo.label, + FALSE)) != zOK) + { + return status; + } + + /* offset and size */ + sprintf(tempBuf, + MSGNot("<"TAG_STARTINGSECTOR">%u<" + TAG_NUMSECTORS">%u\n"), + partInfo.partitionoffset, partInfo.partitionsize); + if ((status = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + return status; + } + + sprintf(tempBuf, + MSGNot("<"TAG_LOGICALPARTITIONID">%u<"TAG_LOGICALPARTITIONCAPACITY">%u<"TAG_MIRRORID">%u<"TAG_HOTFIXID">%u<"TAG_HOTFIXSIZE">%Lu<"TAG_HOTFIXAVAILSIZE">%Lu\n"), + logicalPartID, + logicalPartGen.capacity, + mirrorID, + hotFixID, + (QUAD)hotFixInfo.numberoftotalblocks * 8, + (QUAD)hotFixInfo.numberofavailableblocks * 8); + if ((status = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + return status; + } + + status = VIRT_AddResultTag(virtInfo, TAG_SEGMENT, TRUE, TRUE); + +exit: + if (mappingInfo) + { + free(mappingInfo); + mappingInfo = NULL; + } + return status; +} + +STATUS NW_modifyPartition( + utf8_t *tagName, + VirtInfo_s *virtInfo, + OBID partID, + utf8_t *label) +{ + int ccode; + BYTE tempBuf[512]; + + if (label != NULL) + { + ccode = PART_SetPartitionLabel(partID, label); + + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error changing partition label")); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto exit; + } + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); +exit: + return zOK; +} + + +/**************************************************************************** + * + * This function lists all partitions for a device or for all devices + * + ****************************************************************************/ +STATUS MNSS_ProcessListPartitions( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + TagContent_s tagContent[1]; + const TagRequest_s tags[] = + { + {TAG_DEVICEID, TR_OPTIONAL}, + {0} + }; + + enum + { + DEVICE_ID = 0, + }; + + OBID deviceID = -1; + OBID partID; + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + return zOK; + } + return status; + } + + /* + * If a device is specified then scan for partitions on that device. + * Otherwise, scan all devices for all partitions. + */ + +//PMc - Allen said that we do not need to call this. +//PMc ZMM_ScanForNewPartitions(ccode, -1); + + if ((tagContent[DEVICE_ID].flags & TR_TAG_FOUND) && + (tagContent[DEVICE_ID].flags & TR_CONTENT_FOUND)) + { + deviceID = atol(tagContent[DEVICE_ID].content); + } + + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + partID = -1; + do + { + ZMM_FindObjectType(status, MM_IO_CLASS, MM_PARTITION_OBJECT, &partID); + if (status != MM_OK) + { + if (status != MM_OBJECT_NOT_FOUND) + { + zASSERT("MM_FindObjectType FAILED"==NULL); + } + break; /* Exit main while loop -- no more partitions */ + } + + if ((status = PART_FillInPartitionInfo(virtInfo, TAG_PARTITIONINFO, partID, + deviceID)) + != zOK) + { + goto exit; + } + } while (status == MM_OK); + +exit: + if (status == 0 || status == MM_OBJECT_NOT_FOUND) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, status, MSGNot("Error getting partition list")); + } + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} +#endif + +/**************************************************************************** + * + * This function lists a partition's info + * + ****************************************************************************/ +STATUS MNSS_ProcessGetPartitionInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + TagContent_s tagContent[1]; + const TagRequest_s tags[] = + { + {TAG_PARTITIONID, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + PARTITION_ID = 0, + }; + LONG ccode; + +#if zNETWARE + OBID devID; + OBID partID; +#endif + + ASSERT_MPKNSS_LOCK(); + + if ((ccode = MNSS_GetTagContents(virtInfo, tagName, element, tags, tagContent)) != zOK) + { + if (ccode == zERR_XML_IS_BAD) + { + goto exit; + } + return ccode; + } + +#if zLINUX && !defined(__KERNEL__) + Linux_FillInPartitionInfo(tagName, + virtInfo, tagContent[PARTITION_ID].content); +#endif +#if zNETWARE + MNSS_LoadAppIDs(); + + partID = atol(tagContent[PARTITION_ID].content); + + ZMM_ReturnObjectProgenitor(ccode, partID, MM_DEVICE_OBJECT, &devID); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Failed to get partition's device ID")); + goto exit; + } + + if ((ccode = PART_FillInPartitionInfo(virtInfo, tagName, partID, devID)) + != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Failed to get partition's info")); + goto exit; + } +#endif + +exit: + return zOK; +} + +#if zNETWARE +/**************************************************************************** + * + * This function adds a Partition. + * + ****************************************************************************/ +STATUS MNSS_ProcessAddPartition( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_DEVICEID, TR_CONTENT_REQUIRED}, + {TAG_PARTITIONTYPE, TR_CONTENT_REQUIRED}, + {TAG_STARTINGSECTOR, TR_CONTENT_REQUIRED}, + {TAG_NUMSECTORS, TR_CONTENT_REQUIRED}, + {TAG_FREESPACEID, TR_CONTENT_REQUIRED}, + {TAG_HOTFIXSIZE, TR_CONTENT_REQUIRED}, + {TAG_MIRRORID, TR_OPTIONAL}, + {TAG_LABEL, TR_OPTIONAL}, + {TAG_IGNORESHARESTATE, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + DEVICE_ID = 0, + PARTITION_TYPE = 1, + STARTING_SECTOR = 2, + NUM_SECTORS = 3, + FREE_SPACE_ID = 4, + HOT_FIX_SIZE = 5, + MIRROR_ID = 6, + PARTITION_LABEL = 7, + IGNORE_SHARE_STATE = 8 + }; + + enum + { + MIN_HOT_FIX_SECTORS = 200, + MAX_HOT_FIX_SECTORS = 245760 + }; + + struct IOObjectGenericInfoDef genInfo; + struct PartitionSpecificInfoDef partInfo; + + LONG devID; + LONG pType; + LONG startSector; + LONG sectorswanted; + LONG freeSpaceID; + LONG hotFixSizeInSectors; + LONG mirrorToID = 0; + + LONG pid = -1; + LONG ccode; +// LONG dataSize = 0; +// LONG hotfixID = 0; +// LONG mirrorID = 0; + BOOL createMirror = FALSE; + STATUS retVal; + BYTE errorString[80]; + + ASSERT_MPKNSS_LOCK(); + + if ((retVal = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (retVal == zERR_XML_IS_BAD) + { + goto exit; + } + return retVal; + } + + /* Device ID */ + devID = atol(tagContent[DEVICE_ID].content); + + /* Partition Type */ + pType = atol(tagContent[PARTITION_TYPE].content) + 0x100; + + /* Starting Sector */ + startSector = atol(tagContent[STARTING_SECTOR].content); + + /* Part Size in Sector */ + sectorswanted = atol(tagContent[NUM_SECTORS].content); + + /* Free Space ID */ + freeSpaceID = atol(tagContent[FREE_SPACE_ID].content); + + /* HotFix Size */ + hotFixSizeInSectors = atol(tagContent[HOT_FIX_SIZE].content); + + /* + * If the free partition is on a shared device and clustering is not + * running and we are not overriding the shared protection then + * quit. + */ + if (!(tagContent[IGNORE_SHARE_STATE].flags & TR_TAG_FOUND) && + !COMN_ClusterSoftwareIsCheckingPoolStateChanges()) + { + /* Get the generic info on the device object */ + ZMM_ReturnObjectGenericInfo(ccode, devID, + sizeof(struct IOObjectGenericInfoDef), &genInfo); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_SUCH_OBJECT, + MSGNot("Bad \"device\" ID")); + zASSERT("MM_ReturnObjectGenericInfo on device FAILED"==NULL); + return zOK; + } + + if (genInfo.status & MM_IOOBJECT_SHARED) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NCS_CVB_NOT_REGISTERED, + MSGNot("CVB has not registered for pool events")); + return zOK; + } + } + + /* + * Mirroring ID -- If there is no tag then this is not a mirrored partition. + * If the tag is there, but it has no content then this is creating a + * mirrored group. Otherwise the content identifies the "mirror to" + * partition. + */ + if (tagContent[MIRROR_ID].flags & TR_TAG_FOUND) + { + if (tagContent[MIRROR_ID].flags & TR_CONTENT_FOUND) + { + createMirror = TRUE; + mirrorToID = atol(tagContent[MIRROR_ID].content); + } + } + + // Check to see if the PARTAPI.NLM has been loaded. + retVal = PART_SetupToCallPARTAPI(); + if (retVal != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Setup to call PART API failed")); + return zOK; + } + + /* Locate the mirror-to partition if one was specified */ + if (mirrorToID) + { + /* Get the generic info on the mirror object */ + ZMM_ReturnObjectGenericInfo(ccode, mirrorToID, + sizeof(struct IOObjectGenericInfoDef), &genInfo); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_SUCH_OBJECT, + MSGNot("Bad \"mirror to\" ID")); + zASSERT("MM_ReturnObjectGenericInfo on mirrorToID FAILED"==NULL); + return zOK; + } + /* Get the specific info on the partition associated with this mirror. */ + if (genInfo.type == MM_PARTITION_OBJECT) + { + pid = mirrorToID; + } + else + { + ZMM_ReturnObjectProgenitor(ccode, mirrorToID, MM_PARTITION_OBJECT, &pid); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_SUCH_OBJECT, + MSGNot("Cannot find partition object from mirror ID")); + return zOK; + } + } + + ZMM_ReturnObjectSpecificInfo( ccode, pid, sizeof(partInfo), &partInfo); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_SUCH_OBJECT, + MSGNot("Cannot get partition information")); + return zOK; + } + + if (sectorswanted < partInfo.partitionsize) + { + /* There is not enough room in the sectorswanted to handle the + * mirrorTo partition's datasize */ + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Partition too small for mirror")); + return zOK; + } + + sectorswanted = partInfo.partitionsize; + } + + /* Now create the actual partition */ + pid = freeSpaceID; + + MPKNSS_UNLOCK(); + retVal = PARTAPICreatePartitionPtr( + devID, + pType, + startSector, + sectorswanted, + &pid); + MPKNSS_LOCK(); + + if(retVal != MM_OK) + { + if(retVal == MM_PARTITION_TABLE_FULL) + { + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Partition table full")); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Partition create failed")); + } + return zOK; + } + +// /* The partition is created. Now, create the hotfix and mirror objects */ +// if (hotFixSizeInSectors != 0) +// { +// /* Lets read back the partition info and make sure the size did not adjust. */ +// ZMM_ReturnObjectSpecificInfo( ccode, pid, sizeof(partInfo), &partInfo); +// if (ccode == MM_OK) +// { +// if (partInfo.partitionsize != sectorswanted) +// { +// sectorswanted = partInfo.partitionsize; +// if (mirrorToID) +// { +// /* Readjust the hotFixSize for the new partition size. */ +// hotFixSizeInSectors = sectorswanted - genInfo.capacity; +// } +// } +// } +// +// if (dataSize == 0) +// { +// dataSize = sectorswanted - hotFixSizeInSectors; +// } +// +// if ((hotFixSizeInSectors < MIN_HOT_FIX_SECTORS) || +// (hotFixSizeInSectors > MAX_HOT_FIX_SECTORS)) +// { +// strcpy(errorString, "Bad hot fix size"); +// goto DeletePartition; +// } +// +// /* Create hotfix */ +// MPKNSS_UNLOCK(); +// retVal = PARTAPICreateHotfixPtr( +// pid, +// dataSize, +// &hotfixID); +// MPKNSS_LOCK(); +// if(retVal != MM_OK) +// { +// strcpy(errorString, "Error creating hot fix area"); +// goto DeletePartition; +// } +// } +// else +// { +// if (createMirror) +// { +// retVal = zERR_XML_IS_BAD; +// strcpy(errorString, "No hot fix specified for mirror creation"); +// goto DeletePartition; +// } +// } +// +// if (createMirror) +// { +// /* Create Mirror object */ +// MPKNSS_UNLOCK(); +// retVal = PARTAPICreateMirrorPtr( +// pid, +// &mirrorID); +// MPKNSS_LOCK(); +// if(retVal != MM_OK) +// { +// strcpy(errorString, "Error creating mirror partition"); +// goto DeletePartition; +// } +// } +// + /* If we created a mirror object and we were asked to mirror this partition + * to an existing mirror group, do that now + */ + if(createMirror && mirrorToID != 0) + { + MPKNSS_UNLOCK(); + retVal = PARTAPIAddMirrorObjectToMirrorGroupPtr(pid, mirrorToID); + MPKNSS_LOCK(); + if(retVal != MM_OK) + { + strcpy(errorString, "Unable to add mirror partition to group"); + goto DeletePartition; + } + + MPKNSS_UNLOCK(); + retVal = PARTAPIForceMirrorGroupInSyncPtr(mirrorToID); + MPKNSS_LOCK(); + if(retVal != MM_OK) + { + /* We can't force them in sync, so start the remirror process. */ + strcpy(errorString, "Error forcing mirror group in sync"); + goto RemoveMirror; + } + } + + PART_SetPartitionLabel(pid, tagContent[PARTITION_LABEL].content); + + /* Unload the PARTAPI.NLM. */ + PART_CleanupCallToPARTAPI(); + + /* Get information about the new partition */ + PART_FillInPartitionInfo(virtInfo, tagName, pid, -1); + + return retVal; + +/*===========================================================================*/ +/* Error Processing */ +/*===========================================================================*/ +/* We got an error creating either the hotfix or the mirror objects. Before + * returning we need to delete the partition. + */ +RemoveMirror: + MPKNSS_UNLOCK(); + PARTAPIDelPartitionFromMirrorGroupPtr(pid); + MPKNSS_LOCK(); + +//DeleteMirror: +// /* delete the mirror */ +// MPKNSS_UNLOCK(); +// PARTAPIDeleteMirrorPtr(mirrorID); +// MPKNSS_LOCK(); +// +//DeleteHotFix: +// /* delete the hot fix since the mirror didn't work */ +// MPKNSS_UNLOCK(); +// PARTAPIDeleteHotfixPtr(hotfixID); +// MPKNSS_LOCK(); + +DeletePartition: + ZMM_ReturnObjectSpecificInfo( ccode, pid, sizeof(partInfo), &partInfo); + if(ccode != MM_OK) + { + /* We cannot delete the created partition because we can't get + * specific info on it. I guess we can't do anything else so + * just return + */ + goto errorReturn; + } + + MPKNSS_UNLOCK(); + ccode = PARTAPIDeletePartitionPtr( + pid, + -1, + partInfo.partitionoffset, + partInfo.partitionsize); + MPKNSS_LOCK(); +errorReturn: + MNSS_ReturnResult(virtInfo, tagName, retVal, errorString); +exit: + return zOK; +} +#endif + +/**************************************************************************** + * + * This function adds a Partition. + * + ****************************************************************************/ +STATUS MNSS_ProcessAddPartition2( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_FREESPACEID, TR_CONTENT_REQUIRED}, + {TAG_PARTITIONTYPE, TR_CONTENT_REQUIRED}, + {TAG_SIZE, TR_CONTENT_REQUIRED}, + {TAG_LABEL, TR_OPTIONAL}, + {TAG_IGNORESHARESTATE, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + FREE_SPACE_ID = 0, + PARTITION_TYPE = 1, + SIZE = 2, + PARTITION_LABEL = 3, + IGNORE_SHARE_STATE = 4 + }; + + STATUS ccode; + + ASSERT_MPKNSS_LOCK(); + + if ((ccode = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (ccode == zERR_XML_IS_BAD) + { + goto exit; + } + return ccode; + } + +#if zNETWARE +/* Fixfixfix needs to add a new function */ +// return NW_addPartitions2(tagName, virtInfo, details); + return zOK; +#endif +#if zLINUX && !defined(__KERNEL__) + return Linux_addPartitions2(tagName, virtInfo, + tagContent[FREE_SPACE_ID].content, + strtoul(tagContent[PARTITION_TYPE].content, NULL, 10), + strtoull(tagContent[SIZE].content, NULL, 10), + tagContent[PARTITION_LABEL].content, + tagContent[IGNORE_SHARE_STATE].flags & TR_TAG_FOUND); +#endif +exit: + return zOK; + +} + +/**************************************************************************** + * + * This function adds a Partition. + * + ****************************************************************************/ +STATUS MNSS_ProcessModifyPartition( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_PARTITIONID, TR_CONTENT_REQUIRED}, + {TAG_LABEL, TR_OPTIONAL}, + {TAG_GROWSIZE, TR_OPTIONAL}, + {TAG_SHRINKSIZE, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + PARTITION_ID = 0, + LABEL = 1, + GROW_SIZE = 2, + SHRINK_SIZE = 3, + }; + + STATUS ccode; + QUAD growSize = 0; + QUAD shrinkSize = 0; + utf8_t *label = NULL; + + ASSERT_MPKNSS_LOCK(); + + if ((ccode = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (ccode == zERR_XML_IS_BAD) + { + goto exit; + } + return ccode; + } + + if (tagContent[LABEL].flags & TR_TAG_FOUND) + { + label = tagContent[LABEL].content; + } + +#if zNETWARE + if (tagContent[GROW_SIZE].flags & TR_TAG_FOUND) + { + growSize = strtouq(tagContent[GROW_SIZE].content, NULL, 10); + } + + if (tagContent[SHRINK_SIZE].flags & TR_TAG_FOUND) + { + shrinkSize = strtouq(tagContent[SHRINK_SIZE].content, NULL, 10); + } + + return NW_modifyPartition(tagName, virtInfo, atol(tagContent[PARTITION_ID].content), + label); +#endif + +#if zLINUX && !defined(__KERNEL__) + if (tagContent[GROW_SIZE].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + growSize = strtoull(tagContent[GROW_SIZE].content, NULL, 10); + } + + if (tagContent[SHRINK_SIZE].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) + { + shrinkSize = strtoull(tagContent[SHRINK_SIZE].content, NULL, 10); + } + + return Linux_modifyPartition(tagName, virtInfo, + tagContent[PARTITION_ID].content, + label, growSize, shrinkSize); +#endif +exit: + return zOK; + +} + +/**************************************************************************** + * + * This function removes a partition. + * + ****************************************************************************/ +STATUS MNSS_ProcessRemovePartition( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_PARTITIONID, 0}, + {TAG_IGNORESHARESTATE, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + PARTITION_ID = 0, + IGNORE_SHARE_STATE = 1 + }; + +#if zNETWARE + struct IOObjectGenericInfoDef genInfo; + struct PartitionSpecificInfoDef partInfo; + OBID partID; + LONG ccode; +#endif + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + +#if zLINUX && !(__KERNEL__) + Linux_RemovePartition(tagName, virtInfo, tagContent[PARTITION_ID].content, + tagContent[IGNORE_SHARE_STATE].flags & TR_TAG_FOUND); +#endif +#if zNETWARE + partID = atol(tagContent[PARTITION_ID].content); + + /* + * If the partition is on a shared device and clustering is not + * running and we are not overriding the shared protection then + * quit. + */ + if (!(tagContent[IGNORE_SHARE_STATE].flags & TR_TAG_FOUND) && + !COMN_ClusterSoftwareIsCheckingPoolStateChanges()) + { + /* Get the generic info on the partition object */ + ZMM_ReturnObjectGenericInfo(ccode, partID, + sizeof(struct IOObjectGenericInfoDef), &genInfo); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_SUCH_OBJECT, + MSGNot("Bad partition ID")); + zASSERT("MM_ReturnObjectGenericInfo on free space FAILED"==NULL); + return zOK; + } + + if (genInfo.status & MM_IOOBJECT_SHARED) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NCS_CVB_NOT_REGISTERED, + MSGNot("CVB has not registered for pool events")); + return zOK; + } + } + + // Check to see if the PARTAPI.NLM has been loaded. + if (PART_SetupToCallPARTAPI() == zOK) + { + ZMM_ReturnObjectSpecificInfo(ccode, partID, sizeof(partInfo), &partInfo); + if(ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Remove Partition - failure to get specific info")); + goto EndDeletePartition; + } + + MPKNSS_UNLOCK(); + ccode = PARTAPIDeletePartitionPtr( + partID, + -1, + partInfo.partitionoffset, + partInfo.partitionsize); + MPKNSS_LOCK(); + + if(ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Remove Partition - failure to get specific info")); + goto EndDeletePartition; + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + + +EndDeletePartition: + // Unload the PARTAPI.NLM. + PART_CleanupCallToPARTAPI(); + } +#endif + +exit: + return zOK; +} + +#if zNETWARE +/**************************************************************************** + * + * This function gets mirror statistics for a mirrored partition. + * + ****************************************************************************/ +STATUS MNSS_ProcessGetPartitionMirrorStats( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_MIRRORID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + MIRROR_ID = 0, + }; + + LONG mirrorID = 0; + struct MirrorSpecificInfoDef mirrorInfo; + NINT numMirrors; + LONG ccode; + STATUS status; + utf8_t tempBuf[512] = ""; + NINT idx; + + ASSERT_MPKNSS_LOCK(); + + bzero(&mirrorInfo, sizeof(mirrorInfo)); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + mirrorID = atol(tagContent[MIRROR_ID].content); + + ZMM_ReturnObjectSpecificInfo(ccode, mirrorID, sizeof(mirrorInfo), &mirrorInfo); + if(ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Get Partition Mirror Stats- failure to get specific info")); + goto exit; + } + + numMirrors = mirrorInfo.mirrorcount; + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + sprintf(tempBuf, + "<"TAG_MIRRORGROUPSTATUS">%u" + "<"TAG_MIRRORGROUPPERCENT">%u" + "<"TAG_NUMMIRRORS">%u\n", + mirrorInfo.status, + mirrorInfo.remirrorpercentage, + numMirrors); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + return status; + } + + /* Now, add each Mirror to the buffer */ + for (idx=0; idx" + "<"TAG_HOTFIXID">%u" + "<"TAG_MIRRORPERCENT">%u" + "\n", + mirrorInfo.mirrormembers[idx], + mirrorInfo.memberpercentremirrored[idx]); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + return status; + } + } + + /* Add a result tag */ + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function adds a partition to a mirror group + * + ****************************************************************************/ +STATUS MNSS_ProcessAddPartitionToMirror( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + STATUS retVal; + LONG ccode; + OBID mirrorToID; + OBID newPartID; + OBID logicalPartID; + OBID mirrorID; + OBID hotFixID; + utf8_t *start; + LONG hotFixSizeInSector; + XML_ElementInfo_s partitionElement; + struct IOObjectGenericInfoDef mirrorToGen; + struct IOObjectGenericInfoDef newPartGen; + struct IOObjectGenericInfoDef logicalPartGen; + struct HotfixSpecificInfoDef hotFixInfo; + + const TagRequest_s tags[] = + { + {TAG_MIRRORID, TR_CONTENT_REQUIRED}, + {TAG_PARTITIONS, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + MIRROR_ID = 0, + PARTITIONS = 1, + }; + + enum + { + MIN_HOT_FIX_SECTORS = 200, + MAX_HOT_FIX_SECTORS = 245760 + }; + + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + mirrorToID = atol(tagContent[MIRROR_ID].content); + + // Get size information on the "Mirror To" partition + bzero(&mirrorToGen, sizeof(struct IOObjectGenericInfoDef)); + ZMM_ReturnObjectGenericInfo( ccode, mirrorToID, + sizeof(struct IOObjectGenericInfoDef), &mirrorToGen ); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Failed to get generic info on mirror ID")); + goto exit; + } + + /* Check to see if the PARTAPI.NLM has been loaded. */ + status = PART_SetupToCallPARTAPI(); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Setup to call PART API failed")); + goto exit; + } + + /* Add the specified partitions to the mirror group */ + start = tagContent[PARTITIONS].element.dataStart; + for(;;) + { + /* find the next partition ID */ + if (XML_GetTagElement(TAG_PARTITIONID, start, + tagContent[PARTITIONS].element.dataEnd, &partitionElement) != zOK) + { + break; /* we cannot find anymore partitions */ + } + + start = partitionElement.elementEnd; + if (partitionElement.dataStart == NULL || + partitionElement.dataStart[0] == '/0') + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Missing value in a partition ID tag")); + goto cleanupExit; + } + + *(partitionElement.dataEnd + 1) = 0; + newPartID = atol(partitionElement.dataStart); + + /* + * Get the information about the partition that is to be added to the + * Mirror Group. + * Get size information on the "Mirror To" partition + */ + bzero(&newPartGen, sizeof(struct IOObjectGenericInfoDef)); + ZMM_ReturnObjectGenericInfo( ccode, newPartID, + sizeof(struct IOObjectGenericInfoDef), &newPartGen ); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Failed to get generic info on partion to be added")); + goto cleanupExit; + } + if ((retVal = PART_GetLogicalPartition(newPartID, &logicalPartID, &mirrorID, + &hotFixID, &logicalPartGen, &hotFixInfo)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Failed to get logical partition info on partion to be added")); + goto cleanupExit; + } + + /* Adjust the capacity of this new partition to match the mirror group */ + if (logicalPartGen.capacity != mirrorToGen.capacity) + { + /* adjust hotFix size to the dataSize will be identical to + * the mirrorToGen capacity */ + hotFixSizeInSector = newPartGen.capacity - mirrorToGen.capacity; + + /* The maximum hotfix size is 120 MB */ + if ((hotFixSizeInSector < MIN_HOT_FIX_SECTORS) || + (hotFixSizeInSector > MAX_HOT_FIX_SECTORS)) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("New partition size is not compatible with the mirror group size")); + goto cleanupExit; + } + + /* Delete the old mirror */ + MPKNSS_UNLOCK(); + retVal = PARTAPIDeleteMirrorPtr(mirrorID); + MPKNSS_LOCK(); + if(retVal != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Failed to delete old mirror object on the partition being added")); + goto cleanupExit; + } + + /* Delete the old hotfix */ + MPKNSS_UNLOCK(); + retVal = PARTAPIDeleteHotfixPtr(hotFixID); + MPKNSS_LOCK(); + if(retVal != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Failed to delete old hotfix object on the partition being added")); + goto cleanupExit; + } + + /* Create the new hotfix with the correct size */ + MPKNSS_UNLOCK(); + retVal = PARTAPICreateHotfixPtr( newPartID, mirrorToGen.capacity, + &hotFixID); + MPKNSS_LOCK(); + if(retVal != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Failed to create new hotfix object on the partition being added")); + goto cleanupExit; + } + + /* Create the new mirror object */ + MPKNSS_UNLOCK(); + retVal = PARTAPICreateMirrorPtr( newPartID, &mirrorID); + MPKNSS_LOCK(); + if(retVal != MM_OK) + { + /* delete the hot fix since the mirror didn't work */ + MPKNSS_UNLOCK(); + PARTAPIDeleteHotfixPtr(hotFixID); + MPKNSS_LOCK(); + + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Failed to create new mirror object on the partition being added")); + goto cleanupExit; + } + } + + /* Now add the partition to the mirror group */ + MPKNSS_UNLOCK(); + retVal = PARTAPIAddMirrorObjectToMirrorGroupPtr(mirrorID, mirrorToID); + MPKNSS_LOCK(); + if(retVal != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Failed to add the partition to the mirror group")); + goto cleanupExit; + } + } + + MPKNSS_UNLOCK(); + retVal = PARTAPIForceMirrorGroupInSyncPtr(mirrorToID); + MPKNSS_LOCK(); + if(retVal != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Unable to force expanded mirror group in sync")); + goto cleanupExit; + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +cleanupExit: + /* Unload the PARTAPI.NLM. */ + PART_CleanupCallToPARTAPI(); + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function removes a partition from a mirror group + * + ****************************************************************************/ +STATUS MNSS_ProcessRemovePartitionFromMirror( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_PARTITIONID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + PARTITION_ID = 0, + }; + + LONG partID; + STATUS retVal; + LONG ccode; +// struct IOObjectGenericInfoDef partGen; +// struct PartitionSpecificInfoDef partInfo; +// struct IOObjectGenericInfoDef logicalPartGen; +// struct HotfixSpecificInfoDef hotFixInfo; +// struct IOObjectGenericInfoDef hotFixGen; +// OBID logicalPartID; +// OBID mirrorID; +// OBID hotFixID; +// OBID devID; + + ASSERT_MPKNSS_LOCK(); + + if ((retVal = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (retVal == zERR_XML_IS_BAD) + { + goto exit; + } + return retVal; + } + + partID = atol(tagContent[PARTITION_ID].content); + + /* Check to see if the PARTAPI.NLM has been loaded. */ + retVal = PART_SetupToCallPARTAPI(); + if (retVal != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Setup to call PART API failed")); + goto exit; + } + + MPKNSS_UNLOCK(); + ccode = PARTAPIDelPartitionFromMirrorGroupPtr(partID); + MPKNSS_LOCK(); + if(ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Delete Partition From Mirror Group failed")); + goto cleanupExit; + } + +// bzero(&partGen, sizeof(struct IOObjectGenericInfoDef)); +// ZMM_ReturnObjectGenericInfo( ccode, partID, sizeof(partGen), &partGen ); +// if (ccode != MM_OK) +// { +// MNSS_ReturnResult(virtInfo, tagName, ccode, +// MSGNot("Failed to get generic info on partition")); +// goto cleanupExit; +// } +// +// ZMM_ReturnObjectSpecificInfo(ccode, partID, sizeof(partInfo), &partInfo); +// if(ccode != MM_OK) +// { +// MNSS_ReturnResult(virtInfo, tagName, ccode, +// MSGNot("Failed to get specific info on partition")); +// goto cleanupExit; +// } +// +// /* Get generic info on the device containing the partition */ +// ZMM_ReturnObjectProgenitor(ccode, partID, MM_DEVICE_OBJECT, &devID); +// if (ccode != MM_OK) +// { +// MNSS_ReturnResult(virtInfo, tagName, ccode, +// MSGNot("Failed to get partition's device ID")); +// goto cleanupExit; +// } +// if ((retVal = PART_GetLogicalPartition(partID, &logicalPartID, &mirrorID, +// &hotFixID, &logicalPartGen, &hotFixInfo)) != zOK) +// { +// MNSS_ReturnResult(virtInfo, tagName, retVal, +// MSGNot("Failed to get partition's logical partition info")); +// goto cleanupExit; +// } +// bzero(&hotFixGen, sizeof(struct IOObjectGenericInfoDef)); +// ZMM_ReturnObjectGenericInfo( ccode, hotFixID, sizeof(hotFixGen), &hotFixGen ); +// if (ccode != MM_OK) +// { +// MNSS_ReturnResult(virtInfo, tagName, ccode, +// MSGNot("Failed to get generic info on partition's hotfix object")); +// goto cleanupExit; +// } +// +// /* Delete the old mirror object */ +// MPKNSS_UNLOCK(); +// retVal = PARTAPIDeleteMirrorPtr(mirrorID); +// MPKNSS_LOCK(); +// if(retVal != MM_OK) +// { +// MNSS_ReturnResult(virtInfo, tagName, retVal, +// MSGNot("Failed to delete the partition's mirror object")); +// goto cleanupExit; +// } +// +// /* Delete the old hotfix */ +// MPKNSS_UNLOCK(); +// retVal = PARTAPIDeleteHotfixPtr(hotFixID); +// MPKNSS_LOCK(); +// if(retVal != MM_OK) +// { +// MNSS_ReturnResult(virtInfo, tagName, retVal, +// MSGNot("Failed to delete the partition's hotfix object")); +// goto cleanupExit; +// } +// +// /* Delete the old partition */ +// MPKNSS_UNLOCK(); +// retVal = PARTAPIDeletePartitionPtr(partID, -1, +// partInfo.partitionoffset, partInfo.partitionsize); +// MPKNSS_LOCK(); +// if(retVal != MM_OK) +// { +// MNSS_ReturnResult(virtInfo, tagName, retVal, +// MSGNot("Failed to delete the old partition object")); +// goto cleanupExit; +// } +// +// /* Now, recreate the same partition with the same sizes and offsets */ +// MPKNSS_UNLOCK(); +// retVal = PARTAPICreatePartitionPtr( devID, partInfo.partitiontype, +// partInfo.partitionoffset, partInfo.partitionsize, &partID); +// MPKNSS_LOCK(); +// if(retVal != MM_OK) +// { +// MNSS_ReturnResult(virtInfo, tagName, retVal, +// MSGNot("Failed to re-create the partition object")); +// goto cleanupExit; +// } +// +// /* Create the new hotfix with the correct size */ +// MPKNSS_UNLOCK(); +// retVal = PARTAPICreateHotfixPtr( partID, hotFixGen.capacity, &hotFixID); +// MPKNSS_LOCK(); +// if(retVal != MM_OK) +// { +// MNSS_ReturnResult(virtInfo, tagName, retVal, +// MSGNot("Failed to re-add the hotfix object")); +// goto cleanupExit; +// } +// +// /* Create the new mirror object */ +// MPKNSS_UNLOCK(); +// retVal = PARTAPICreateMirrorPtr( partID, &mirrorID); +// MPKNSS_LOCK(); +// if(retVal != MM_OK) +// { +// // delete the hot fix since the mirror didn't work +// MPKNSS_UNLOCK(); +// PARTAPIDeleteHotfixPtr(hotFixID); +// MPKNSS_LOCK(); +// +// MNSS_ReturnResult(virtInfo, tagName, retVal, +// MSGNot("Failed to re-add the mirror object")); +// goto cleanupExit; +// } +// +// /* Restore the partition label to what it was before */ +// retVal = PART_SetPartitionLabel(partID, partInfo.label); + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +cleanupExit: + /* Unload the PARTAPI.NLM. */ + PART_CleanupCallToPARTAPI(); + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function resyncs a partition mirror group + * + ****************************************************************************/ +STATUS MNSS_ProcessResyncPartitionMirror( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_MIRRORID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + MIRROR_ID = 0, + }; + + STATUS status; + LONG retVal; + LONG logicalPartID; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Initialize the device */ + logicalPartID = atol(tagContent[MIRROR_ID].content); + + /* Check to see if the PARTAPI.NLM has been loaded. */ + retVal = PART_SetupToCallPARTAPI(); + if (retVal != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Setup to call PART API failed")); + goto exit; + } + + MPKNSS_UNLOCK(); + retVal = PARTAPIForceMirrorGroupInSyncPtr(logicalPartID); + MPKNSS_LOCK(); + if (retVal != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, retVal, + MSGNot("Force Mirror Group In Sync failed")); + goto exit; + } + + /* Unload the PARTAPI.NLM. */ + PART_CleanupCallToPARTAPI(); + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; +} + +/****************************************************************************** + * PART_ListMirrors - Build a list of the server's mirrored partitions. + ******************************************************************************/ +LONG PART_ListMirrors( + DQhead_t *dqHead) +{ + struct PartitionSpecificInfoDef partInfo; + struct IOObjectGenericInfoDef mirrorGen; + Mirror_Info_s *mInfo; + LONG ccode = MM_OK; + OBID mirrorID; + OBID partID; + + ASSERT_MPKNSS_LOCK(); + + DQ_INIT(dqHead); + + MPKNSS_UNLOCK(); + + mirrorID = -1; + + ccode = MM_ScanForNewPartitions(-1); + + do + { + // Find a mirror group object. + if ((ccode = MM_FindObjectType( + MM_IO_CLASS, + MM_MIRROR_OBJECT, + &mirrorID)) != MM_OK) + { + if (ccode == MM_OBJECT_NOT_FOUND) + { + ccode = MM_OK; + } + break; // Exit main while loop -- no more partitions + } + + // Get the partition id. + if ((ccode = MM_ReturnObjectProgenitor( + mirrorID, + MM_PARTITION_OBJECT, + &partID)) != MM_OK) + { + break; + } + + /* Get the specific info on the partition */ + if ((ccode = MM_ReturnObjectSpecificInfo( + partID, + sizeof(struct PartitionSpecificInfoDef), + &partInfo)) != MM_OK) + { + break; + } + + if (partInfo.partitiontype != NETWARE_NSS_PARTITION) + { + // Only interested in NSS mirrored partitions. + continue; + } + + if ((ccode = MM_ReturnObjectGenericInfo( + mirrorID, + sizeof(struct IOObjectGenericInfoDef), + &mirrorGen)) != MM_OK) + { + break; + } + + // Need to add this partition to our linked list. + mInfo = (Mirror_Info_s *)malloc(sizeof(Mirror_Info_s)); + if (!mInfo) + { + break; + } + + bzero(mInfo, sizeof(Mirror_Info_s)); + mInfo->devID = mirrorID; + strncpy(mInfo->devName, mirrorGen.name, strlen(mirrorGen.name)); + mInfo->devStatus = partInfo.status; + NULLIFY(&mInfo->next); + DQ_ENQ(dqHead, mInfo, next); + + } while (ccode == MM_OK); // Find all mirrored partitions on all devices. + + MPKNSS_LOCK(); + + return ccode; +} + +/**************************************************************************** + * + * PART_DeleteEmptyPartition - If a partition is empty an un-mirrored and + * not shared then this function will be deleted. + * + ****************************************************************************/ +LONG PART_DeleteEmptyPartition( + OBID objectID) +{ + struct IOObjectGenericInfoDef genInfo; + struct PartitionSpecificInfoDef partInfo; + LONG ccode; + + ASSERT_MPKNSS_LOCK(); + + /* Get the generic info on the partition object */ + ZMM_ReturnObjectGenericInfo(ccode, objectID, + sizeof(struct IOObjectGenericInfoDef), &genInfo); + + if (ccode != MM_OK) + { + goto exit; + } + + // Check if this object is shared. + if (genInfo.status & MM_IOOBJECT_SHARED) + { + return MM_INVALID_OBJECT; + } + + // Check if this object is a partition object. This will get rid of + // mirrored object and any other weird objects that we don't expect. + if (!(genInfo.type & MM_PARTITION_OBJECT)) + { + return MM_INVALID_OBJECT; + } + + ZMM_ReturnObjectSpecificInfo(ccode, objectID, sizeof(partInfo), &partInfo); + if(ccode != MM_OK) + { + goto exit; + } + + ZMM_DeletePartition(ccode, + objectID, + -1, // not used, pass in -1 + partInfo.partitionoffset, + partInfo.partitionsize); + +exit: + return ccode; +} + +/****************************************************************************** + * PART_CheckPartitionForPool - Check to see if this partition contains a pool. + * If the partition does not contain a pool or a traditional volume, then the + * partition will be deleted. + ******************************************************************************/ +LONG PART_CheckPartitionForPool( + OBID objectID, + BOOL *poolFound, + BOOL *partDeleted) +{ + struct IOObjectGenericInfoDef objectGen; + OBID objectManagerID, nextobject = objectID; + LONG ccode = MM_OK; + BYTE poolName[MM_MAX_OBJECT_STRING_LEN]; + LONG *mappingInfo = NULL; + NINT size = 0; + BOOL mirrorFound; + + ASSERT_MPKNSS_LOCK(); + + MPKNSS_UNLOCK(); + + mirrorFound = FALSE; + *poolFound = TRUE; + *partDeleted = FALSE; + + // Get the generic info on the partition. + if ((ccode = MM_ReturnObjectGenericInfo( + objectID, + sizeof(struct IOObjectGenericInfoDef), + &objectGen)) != MM_OK) + { + MPKNSS_LOCK(); + goto exit; + } + + // Save the managerID while we look up the mirror information. + objectManagerID = objectGen.objectmanagerid; + + // If there is a child count, then we need to check to see if this + // is a Mirrored virtual device (partition). + while (objectGen.childcount != 0) + { + // Figure out how much space we need for the returned mapping info, + // and make sure our "mappingINfo" pointer points to a buffer big + // enough for the reply. + size = sizeof(LONG) * + (3 + // Generic header with parentCount, siblingCount & childCount + objectGen.parentcount + + objectGen.siblingcount + + objectGen.childcount); + + MPKNSS_LOCK(); + + mappingInfo = zalloc(size); + + if (mappingInfo == NULL) + { + goto exit; + } + + MPKNSS_UNLOCK(); + + if ((ccode = MM_ReturnObjectMappingInfo( + nextobject, + MM_IO_CLASS, + size, + mappingInfo)) != MM_OK) + { + MPKNSS_LOCK(); + goto exit; + } + + nextobject = mappingInfo[mappingInfo[0] + mappingInfo[1] + 3]; + + if ((ccode = MM_ReturnObjectGenericInfo( + nextobject, // Ship to the first child OBID. + sizeof(struct IOObjectGenericInfoDef), + &objectGen)) != MM_OK) + { + MPKNSS_LOCK(); + goto exit; + } + + free(mappingInfo); + mappingInfo = NULL; + if (objectGen.type == MM_MIRROR_OBJECT) + { + // This is a mirror. + mirrorFound = TRUE; + break; + } + } + + // See if this partition contains a pool. + if ((ccode = MM_ObjectControl( + objectManagerID, + MM_GET_POOL_NAME, + objectID, + 0, + 0, + sizeof(poolName), + &poolName)) != MM_OK) + { + MPKNSS_LOCK(); + goto exit; + } + + if (poolName[0] == 0) + { + *poolFound = FALSE; + } + + MPKNSS_LOCK(); + + // If this object does not have a pool and it is not on a mirrored + // partition, try to delete it. + if ((!(*poolFound)) && (!mirrorFound)) + { + if ((ccode = PART_DeleteEmptyPartition(objectID)) != MM_OK) + { + // Either the partition was mirrored, sharable or there was some + // other problem deleting it. Just reset the return value and continue. + ccode = MM_OK; + } + else + { + *partDeleted = TRUE; + } + } + +exit: + + if (mappingInfo != NULL) + { + free(mappingInfo); + mappingInfo = NULL; + } + + return ccode; +} + +/****************************************************************************** + * PART_CheckPartitionForMirror - Check to see if this is a mirrored partition. + ******************************************************************************/ +LONG PART_CheckForMirror( + OBID objectID, + BOOL *foundMirror) +{ + struct IOObjectGenericInfoDef objectGen; + LONG ccode = MM_OK; + + ASSERT_MPKNSS_LOCK(); + + *foundMirror = FALSE; + + ZMM_ReturnObjectGenericInfo( + ccode, + objectID, + sizeof(struct IOObjectGenericInfoDef), + &objectGen); + if (ccode == MM_OK) + { + if (objectGen.type == MM_MIRROR_OBJECT) + { + // This is a mirror. + *foundMirror = TRUE; + } + } + + return ccode; +} + +/****************************************************************************** + * PART_GetMirrorInfo - Return the information about a specific mirrored partition. + ******************************************************************************/ +LONG PART_GetMirrorInfo( + OBID mirrorID, + LONG *type, + QUAD *totSize, + QUAD *freeSize, + BOOL *shared, + BYTE *mirrorName, + struct MirrorSpecificInfoDef *mirrorInfo) +{ + struct IOObjectGenericInfoDef mirrorGen; + OBID partID; + LONG ccode = MM_OK; + BOOL hasPool; + BOOL partDeleted; + + ASSERT_MPKNSS_LOCK(); + + *type = 0; + *totSize = 0; + *freeSize = 0; + + MPKNSS_UNLOCK(); +// ******** After Allen makes it so that we can check if a partition has a pool with the mirror id, we can delete this code. + + // Get the partition id. + if ((ccode = MM_ReturnObjectProgenitor( + mirrorID, + MM_PARTITION_OBJECT, + &partID)) != MM_OK) + { + MPKNSS_LOCK(); + goto exit; + } +// ******** END OF After Allen makes it so that we can check if a partition has a pool with the mirror id, we can delete this code. + + if ((ccode = MM_ReturnObjectGenericInfo( + mirrorID, + sizeof(struct IOObjectGenericInfoDef), + &mirrorGen)) != MM_OK) + { + MPKNSS_LOCK(); + goto exit; + } + + MPKNSS_LOCK(); + +// if ((ccode = PART_CheckPartitionForPool(mirrorID, &hasPool)) != MM_OK) // After Allen makes his change above use this line instead of the next one. + if ((ccode = PART_CheckPartitionForPool(partID, &hasPool, &partDeleted)) != MM_OK) + { + MPKNSS_LOCK(); + goto exit; + } + + strcpy(mirrorName, mirrorGen.name); + *type = mirrorGen.type; + *totSize = mirrorGen.capacity; + *totSize = *totSize * mirrorGen.unitsize; + *shared = (mirrorGen.status & MM_IOOBJECT_SHARED); + *freeSize = (hasPool == TRUE) ? 0 : *totSize; + + // Get Mirror stats + ZMM_ReturnObjectSpecificInfo(ccode, mirrorID, sizeof(struct MirrorSpecificInfoDef), mirrorInfo); + if(ccode != MM_OK) + { + goto exit; + } + +exit: + + return ccode; +} + +/**************************************************************************** + * + * This function will go through all of the partitions and check if they + * contain a pool or a traditional volume. If it does not, then the partition + * will be deleted. + * + ****************************************************************************/ +void PART_RemoveEmptyPartitions() +{ + LONG ccode = MM_OK; + OBID partID; + BOOL hasPool; + BOOL partDeleted; + + struct PartitionSpecificInfoDef partInfo; + + ASSERT_MPKNSS_LOCK(); + + // This loop will go through all of the partitions on all of the devices. + do + { + partID = -1; + partDeleted = FALSE; + + // This loop will see if the partition contains a pool or volume. + do + { + ZMM_FindObjectType(ccode, MM_IO_CLASS, MM_PARTITION_OBJECT, &partID); + if (ccode != MM_OK) + { + break; /* Exit outer while loop -- no more partitions */ + } + + // Get the partition information. + bzero(&partInfo, sizeof(struct PartitionSpecificInfoDef)); + ZMM_ReturnObjectSpecificInfo(ccode, partID, + sizeof(struct PartitionSpecificInfoDef), &partInfo); + if (ccode == MM_OK) + { + switch (partInfo.partitiontype) + { + // If the partition does not contain a pool or volume, then the + // partition will be deleted in PART_CheckPartitionForPool. + // So that is why we test for both NSS and Traditional. + case NETWARE_NSS_PARTITION: + case NETWARE_386_PARTITION: + PART_CheckPartitionForPool(partID, &hasPool, &partDeleted); + break; + + default: + break; + } + } + + + } while (partDeleted == FALSE); // No partitions were deleted. + } while (partDeleted == TRUE); // Find all partitions on all devices. + +} + +#endif + + +#if zLINUX && !defined(__KERNEL__) +STATUS Linux_RemovePartition( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *partitionID, + BOOL ignoreShare) +{ + int ccode; + utf8_t tempBuf[512] = ""; + handle_object_info_t *object_info = NULL; + object_handle_t handle; + BOOL isEVMSObjectType = FALSE; + handle_array_t *objectList = NULL; + + ASSERT_MPKNSS_LOCK(); + + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, MSGNot("Error opening EVMS engine. It might be " + "opened by another application")); + goto exit; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto close_engine; + } + + ccode = evmsGetSegmentHandleByName((BYTE *)partitionID, &handle, NULL); + if (ccode != 0) + { + /* try to use object type to get handle, it might be a RAID device's missing element */ + ZOS_evms_get_object_handle_for_name(ccode, EVMS_OBJECT, partitionID, &handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting segment handle for %s: %s"), + partitionID, evmsGetErrString(ccode)); + goto close_engine; + } + isEVMSObjectType = TRUE; + } + + if (!ignoreShare && !COMN_ClusterSoftwareIsCheckingPoolStateChanges()) + { + /* Get the generic info on the partition object */ + ZOS_evms_get_info(ccode, handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting segment info for %s: %s"), + partitionID, evmsGetErrString(ccode)); + goto close_engine; + } + + if (object_info->info.segment.flags & SOFLAG_CLUSTER_SHARED) + { + ccode = zERR_NCS_CVB_NOT_REGISTERED; + sprintf(tempBuf, MSGNot("CVB has not registered for pool events")); + goto close_engine; + } + } + + /* check if it's parent raid is a virtual device */ + { + object_handle_t regionHandle; + NINT regionType; + LONG raidType; + NINT action = 0; + BOOL infoFound = FALSE; + EvmsExtendInfo_s info; + + ccode = evmsGetParentRegion(handle, ®ionHandle, + ®ionType, NULL, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Couldn't get parent region for %s: %s"), + partitionID, evmsGetErrString(ccode)); + goto close_engine; + } + + if (regionHandle != -1) + { + /* Allen said this on 09-10-2004: + * You should never delete a partition that is still a member of a RAID, + * or in a pool region. You must do the following: + * + * RAID1: use the add/remove element functions of the RAID1 region object. + * If the last one, delete the RAID1. (09-15-2004: Looks like now if there's + * only one element left, it's not allowed to be removed) + * RAID0: Use expand to grow the RAID, you are not allowed to shrink it. + * RAID5: Use expand to add partitions to the RAID; use remove function to + * delete partition if no element is missing. + * Pool (linear): Use the expand to grow the region. You cannot shrink it. + * If you want to delete the RAID or pool, use the corresponding delete + * functions for each region. Either use the recursive option to delete + * the partitions, or delete the partitions after eth region is deleted. + * + * NOTE: In order to delete a RAID0 or 5, you must first make sure that + * the segment manager is removed from them. + */ + + ccode = evmsGetExtendedInfo(regionHandle, (BYTE *)"Elements", &infoFound, &info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Couldn't get extended info: %s"), + evmsGetErrString(ccode)); + goto close_engine; + } + + if (regionType == REGION_MIRROR) + { + if (info.value.ui32 > 1) + { + action = R1_DELETE_ELEMENT; + + objectList = malloc(sizeof(handle_array_t) + sizeof(object_handle_t)); + if (objectList == NULL) + { + ccode = zERR_NO_MEMORY; + goto close_engine; + } + + objectList->count = 1; + objectList->handle[0] = handle; + ccode = evmsMakeTask(regionHandle, action, objectList, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Couldn't remove partition from raid 1 device: %s"), + evmsGetErrString(ccode)); + goto close_engine; + } + } + } + else if (regionType == REGION_RAID) + { + /* get raid type */ + ccode = evmsGetDeviceType(regionHandle, ®ionType, &raidType, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Couldn't get device type: %s"), + evmsGetErrString(ccode)); + goto close_engine; + } + + if (raidType == 0) + { + ccode = -1; + sprintf(tempBuf, MSGNot("Raid 0 device's partition is not allowed to " + "be deleted")); + goto close_engine; + } + else if (raidType == 5) + { + EvmsSegmentInfoArray_s *segments = NULL; + handle_object_info_t *object_info; + NINT elementCount; + + ZOS_evms_get_info(ccode, regionHandle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object info for raid 5 device: %s"), + evmsGetErrString(ccode)); + goto close_engine; + } + + ccode = evmsGetDeviceSegments(&object_info->info.region, FALSE, &segments, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object info for raid 5 device: %s"), + evmsGetErrString(ccode)); + ZOS_evms_free(object_info); + goto close_engine; + } + + elementCount = segments->count; + + ZOS_evms_free(object_info); + free(segments); + if (info.value.ui32 > elementCount) + { + ccode = -1; + sprintf(tempBuf, MSGNot("Could't remove partition from Raid 5 device because " + "at least one partition is already missing")); + // Nothing else needs to be done. + goto close_engine; + } + else + { + action = RAID_REMOVE_ELEMENT; + + objectList = malloc(sizeof(handle_array_t) + sizeof(object_handle_t)); + if (objectList == NULL) + { + ccode = zERR_NO_MEMORY; + goto close_engine; + } + + objectList->count = 1; + objectList->handle[0] = handle; + ccode = evmsMakeTask(regionHandle, action, objectList, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Couldn't remove partition from raid 5 device: %s"), + evmsGetErrString(ccode)); + goto close_engine; + } + } + } + } + } + } + + if (!isEVMSObjectType) + { + ccode = evmsDeleteObjectByHandle(handle, FALSE); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error removing partition %s: %s"), + partitionID, evmsGetErrString(ccode)); + goto close_engine; + } + } + +// ZOS_evms_delete(ccode, handle); +// if (ccode != 0) +// { +// sprintf(tempBuf, MSGNot("Error removing partition %s: %s"), +// partitionID, evmsGetErrString(ccode)); +// goto close_engine; +// } +// +// ZOS_evms_commit_changes(ccode); +// if (ccode != 0) +// { +// sprintf(tempBuf, MSGNot("Error committing changes: %s"), +// evmsGetErrString(ccode)); +// goto close_engine; +// } + +close_engine: + if (objectList != NULL) + { + free(objectList); + } + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + evmsCloseEngine(); + + if (ccode == 0) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, tempBuf); + } + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + + return zOK; +} + +STATUS Linux_FillInPartitionInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *partitionID) +{ + int ccode; + utf8_t tempBuf[512] = ""; + NINT partitionType; + handle_object_info_t *object_info = NULL; + storage_object_info_t *info; + object_handle_t handle; + EvmsExtendInfo_s extendInfo; + utf8_t name[zMAX_COMPONENT_NAME]; + BOOL infoFound = FALSE; + NINT len; + + ASSERT_MPKNSS_LOCK(); + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, MSGNot("Error opening EVMS engine. It might be " + "opened by another application")); + goto exit; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto close_engine; + } + + ccode = evmsGetSegmentHandleByName((BYTE *)partitionID, &handle, (BYTE *)name); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting segment handle for %s: %s"), + partitionID, evmsGetErrString(ccode)); + goto close_engine; + } + + ZOS_evms_get_info(ccode, handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting segment info for %s: %s"), + partitionID, evmsGetErrString(ccode)); + goto close_engine; + } + + info = &object_info->info.segment; + ccode = evmsGetSegmentType(info->handle, info->data_type, &partitionType); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting segment type for %s: %s"), + partitionID, evmsGetErrString(ccode)); + goto close_engine; + } + +// evmsPrintExtendedInfo(info->handle); + sprintf(tempBuf, + "<"TAG_PARTITIONID">%s" + "<"TAG_DEVICEID">%s" + "<"TAG_STATE">%s" + "<"TAG_PARTITIONTYPE">%u" + "<"TAG_STARTINGSECTOR">%Lu" + "<"TAG_NUMSECTORS">%Lu", + partitionID, + name, + info->data_type == DATA_TYPE ? "used" : "free", + partitionType & 0xFF, + info->start, + info->size); + len = strlen(tempBuf); + + // get label information + ccode = evmsGetExtendedInfo(handle, (BYTE *)MSGNot("Label"), &infoFound, &extendInfo); + if(ccode != 0) + { + return ccode; + } + + if (infoFound && strcmp(extendInfo.value.s, "")) + { + sprintf(&tempBuf[len], + "<"TAG_LABEL">%s", + extendInfo.value.s); + len = strlen(tempBuf); + evmsFreeExtendedInfo(&extendInfo); + } + + if ((ccode = evmsGetPoolNameFromExtendInfo(handle, + &infoFound, (BYTE *)name)) != 0) + { + goto close_engine; + } + + if (infoFound) + { + sprintf(&tempBuf[len], + "<"TAG_POOLNAME">%s", + name); + len = strlen(tempBuf); + } + + ZOS_evms_can_expand(ccode, handle); + if (ccode == 0) + { + expand_handle_array_t *expand_points; + NINT k; + sector_count_t sectors = 0; + + /* can expand */ + ZOS_evms_get_expand_points(ccode, handle, &expand_points); + if (ccode != 0) + { + goto close_engine; + } + + for (k = 0; k < expand_points->count; k++) + { + sectors += expand_points->expand_point[k].max_expand_size; + } + + ZOS_evms_free(expand_points); + + sprintf(&tempBuf[len], + "<"TAG_GROWABLE"/>" + "<"TAG_GROWSIZE">%u", + sectors * EVMS_VSECTOR_SIZE); + len = strlen(tempBuf); + } + + ZOS_evms_can_shrink(ccode, handle); + if (ccode == 0) + { + sprintf(&tempBuf[len], "<"TAG_SHRINKABLE"/>"); + len = strlen(tempBuf); + } + +/*Fixfixfix need to add hotfix tags */ + { + object_handle_t regionHandle; + NINT regionType; + BYTE regionName[zMAX_COMPONENT_NAME]; + QUAD regionSize; + + ccode = evmsGetParentRegion(handle, ®ionHandle, + ®ionType, regionName, ®ionSize); + if (ccode != 0) + { + goto close_engine; + } + + if (regionHandle != -1) + { + if (regionType == REGION_LOGICALPARTITION) + { + sprintf(&tempBuf[len], + "<"TAG_LOGICALPARTITIONID">%s" + "<"TAG_LOGICALPARTITIONCAPACITY">%u", + regionName, + regionSize); + } + else if (regionType == REGION_MIRROR) + { + /* this is a special case */ + sprintf(&tempBuf[len], + "<"TAG_MIRRORID">%s", + regionName); + len = strlen(tempBuf); + + ccode = evmsGetParentRegion(handle, &handle, + ®ionType, regionName, ®ionSize); + if (ccode != 0) + { + VIRT_AddResultTag(virtInfo, TAG_PARTITION, TRUE, TRUE); + goto close_engine; + } + + if (handle != -1 && regionType == REGION_LOGICALPARTITION) + { + sprintf(&tempBuf[len], + "<"TAG_LOGICALPARTITIONID">%s" + "<"TAG_LOGICALPARTITIONCAPACITY">%Lu", + regionName, + regionSize); + } + } + else if (regionType == REGION_RAID) + { + sprintf(&tempBuf[len], + "<"TAG_RAIDID">%s", + regionName); + } + len = strlen(tempBuf); + } + } + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + sprintf(tempBuf, MSGNot("Error add result data")); + goto close_engine; + } + +close_engine: + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + evmsCloseEngine(); + + if (ccode == 0) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, tempBuf); + } + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + + return zOK; + + +} + +STATUS Linux_addPartitions2( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *freeSpaceID, + NINT partitionType, + QUAD size, /* in bytes */ + utf8_t *label, + BOOL ignoreShare) +{ + int ccode; + utf8_t tempBuf[512]; + handle_object_info_t *object_info = NULL; + object_handle_t handle; + + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, MSGNot("Error opening EVMS engine. It might be " + "opened by another application")); + goto exit; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto close_engine; + } + + ZOS_evms_get_object_handle_for_name(ccode, SEGMENT, + freeSpaceID, &handle); + if (ccode != 0) + { + /* We also present unused raid1 space as free space, here we + * should give out a seperate warning + */ + ZOS_evms_get_object_handle_for_name(ccode, REGION, + freeSpaceID, &handle); + if (ccode == 0) + { + sprintf(tempBuf, MSGNot("Error creating a segment on a mirror device is not allowed")); + } + else + { + sprintf(tempBuf, MSGNot("Error getting segment handle for %s: %s"), + freeSpaceID, evmsGetErrString(ccode)); + } + goto close_engine; + } + + /* Get the generic info on the partition object */ + ZOS_evms_get_info(ccode, handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting segment info for %s: %s"), + freeSpaceID, evmsGetErrString(ccode)); + goto close_engine; + } + + /* + * If the free partition is on a shared device and clustering is not + * running and we are not overriding the shared protection then + * quit. + */ + if (!ignoreShare && + !COMN_ClusterSoftwareIsCheckingPoolStateChanges()) + { + if (object_info->info.segment.flags & SOFLAG_CLUSTER_SHARED) + { + ccode = zERR_NCS_CVB_NOT_REGISTERED; + sprintf(tempBuf, MSGNot("CVB has not registered for pool events")); + goto close_engine; + } + } + + ccode = evmsAddPartition(handle, + size / EVMS_VSECTOR_SIZE, + getPartitionTypeNameByValue(partitionType | 0x100), + (BYTE *)label, NULL); + + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error adding partition: %s"), + evmsGetErrString(ccode)); + goto close_engine; + } + +close_engine: + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + evmsCloseEngine(); + + if (ccode == 0) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, tempBuf); + } + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + return zOK; + +} + +STATUS Linux_modifyPartition( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *partitionID, + utf8_t *label, + QUAD growSize, /* in bytes */ + QUAD shrinkSize) /* in bytes */ +{ + int ccode; + utf8_t tempBuf[512]; + handle_object_info_t *object_info = NULL; + object_handle_t handle; + option_array_t options; + value_t value; + + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, MSGNot("Error opening EVMS engine. It might be " + "opened by another application")); + return zOK; + } + + ZOS_evms_get_object_handle_for_name(ccode, SEGMENT, partitionID, &handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting segment handle for %s: %s"), + partitionID, evmsGetErrString(ccode)); + goto exit; + } + + if (label != NULL) + { + value.s = label; + ccode = evmsChangeObjectValue(handle, RENAME_FUNCTION, (BYTE *)MSGNot("Rename"), + &value, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error changing name: %s"), + evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto exit; + } + } + + if (growSize != 0 || shrinkSize != 0) + { + /* Get the generic info on the partition object */ + ZOS_evms_get_info(ccode, handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting partition info for %s: %s"), + partitionID, evmsGetErrString(ccode)); + goto exit; + } + + options.count = 1; + options.option[0].name = MSGNot("Size"); + options.option[0].is_number_based = FALSE; + options.option[0].type = EVMS_Type_Unsigned_Int64; + + if (growSize != 0) + { + ccode = evms_can_expand(handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error %s can't be expanded: %s"), + partitionID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto exit; + } + + options.option[0].value.ui64 = growSize / EVMS_VSECTOR_SIZE; + + ZOS_evms_expand(ccode, handle, NULL, &options); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error failed to expand %s: %s"), + partitionID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto exit; + } + } + else if (shrinkSize != 0) + { + ccode = evms_can_shrink(handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error %s can't be shrunk: %s"), + partitionID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto exit; + } + + options.option[0].value.ui64 = shrinkSize / EVMS_VSECTOR_SIZE; + ZOS_evms_shrink(ccode, handle, NULL, &options); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error failed to shrink %s: %s"), + partitionID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto exit; + } + } + + ZOS_evms_commit_changes(ccode); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error committing change made on %s: %s"), + partitionID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto exit; + } + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); +exit: + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + evmsCloseEngine(); + return zOK; +} + +#endif diff --git a/src/nwnss/sharedsrc/managePool.c.h b/src/nwnss/sharedsrc/managePool.c.h new file mode 100644 index 0000000..c009a52 --- /dev/null +++ b/src/nwnss/sharedsrc/managePool.c.h @@ -0,0 +1,8083 @@ +/**************************************************************************** + | + | (C) Copyright 2001, 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: bbhanuprakash $ + | $Date: 2008-06-26 16:06:00 +0530 (Thu, 26 Jun 2008) $ + | + | $RCSfile$ + | $Revision: 2405 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage NSS using XML + | + +-------------------------------------------------------------------------*/ +#if zLINUX && defined(__KERNEL__) +#include +#else +typedef unsigned long OBID; +#endif + +#include +#include +#include +#include +#if zLINUX && !defined(__KERNEL__) +#define atoq(p1) LB_atoq(p1) +#define stricmp(p1,p2) strcasecmp(p1,p2) +#define strnicmp(p1,p2,p3) strncasecmp(p1,p2,p3) +extern SQUAD LB_atoq(const char *__nptr ); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define MPKNSS_LOCK() ((void) 0) +#define MPKNSS_UNLOCK() ((void) 0) +#define ASSERT_MPKNSS_LOCK() ((void) 0) +#endif + +#include +#include + +#include "sysimp.h" + +#include "comnAuthorize.h" +#include "manage.h" +#include "manageNlm.h" +#include "managePool.h" + +#if zLINUX +#define POOL_MOUNT_POINT "/opt/novell/nss/mnt/.pools/" +#endif + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +#include "manageNDS.h" +#endif +#if zLINUX && !defined(__KERNEL__) +#include +#include +extern void syslog (int __pri, __const char *__fmt, ...) + __attribute__ ((__format__(__printf__, 2, 3))); +#endif +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +#include "manageStartup.h" +#include "manageVolume.h" +#endif +#include "comnPublics.h" +#include "virtualIO.h" +#include "xmlTags.h" + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +typedef struct Pool_Volume_s +{ + DQlink_t next; + Volume_s volume; +} Pool_Volume_s; +#endif + +//#ifndef __linux__ +//#include "clstrlib.h" +//#endif +#include "zPool.h" +#include "utc.h" +#include "eDir.h" + +#define MAX_CIFS_VIRTUAL_SERVER_NAME 16 + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +//#include "repair.h" +#include "virtualIO.h" + +#include "repairRAVUser.h" +#endif + +extern char *ManageVolumeErrorMessages[]; + +int make_directory(char * dir_name, mode_t mode); + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +STATUS MNSS_ProcessAddPoolSimple(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetPoolInfo(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessPoolVerify( utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessModifyPoolState(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetPoolDevices(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetLSSVolumeInfo(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessRemovePoolSimple(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessRenamePool(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetPoolNDSName(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessExpandPoolSimple(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetDefaultClusterNames(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +STATUS MNSS_ProcessAddPoolSnapshot(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessRemovePoolSnapshot(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessActivatePoolSnapshot(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessDeactivatePoolSnapshot(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessListPoolSnapshots(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetPoolSnapshotInfo(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessListEvmsVolumes(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +#endif +#if zNETWARE +STATUS MNSS_ProcessRenamePoolSnapshot(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +STATUS MNSS_ProcessAddPool(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessRemovePool(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessExpandPool(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessModifyPoolInfo(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetPoolState(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessListPools(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetLSSInfo(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +STATUS MNSS_ProcessPoolFreeze(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessPoolFreezeStatus(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessPoolThaw(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + + +LONG POOL_AddPoolSegment(BOOL isFirstPartition, OBID partID, char *poolName, LONG poolNameLength); +LONG PART_DeleteEmptyPartition( OBID objectID); +#endif + +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ + +SiblingElements_s PoolElements[] = +{ +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) + {TAG_ADDPOOLSIMPLE, MNSS_ProcessAddPoolSimple}, + {TAG_GETPOOLINFO, MNSS_ProcessGetPoolInfo}, + {TAG_MODIFYSTATE, MNSS_ProcessModifyPoolState}, + {TAG_GETPOOLDEVICES, MNSS_ProcessGetPoolDevices}, + {TAG_REMOVEPOOLSIMPLE, MNSS_ProcessRemovePoolSimple}, + {TAG_RENAMEPOOL, MNSS_ProcessRenamePool}, + {TAG_GETNDSNAME, MNSS_ProcessGetPoolNDSName}, + {TAG_EXPANDPOOLSIMPLE, MNSS_ProcessExpandPoolSimple}, + {TAG_GETDEFAULTCLUSTERNAMES, MNSS_ProcessGetDefaultClusterNames}, + {TAG_POOLVERIFY, MNSS_ProcessPoolVerify}, /* zPoolVerify XML handler */ + + /* pool snap shot */ + {TAG_ADDPOOLSNAPSHOT, MNSS_ProcessAddPoolSnapshot}, + {TAG_REMOVEPOOLSNAPSHOT, MNSS_ProcessRemovePoolSnapshot}, + {TAG_ACTIVATEPOOLSNAPSHOT, MNSS_ProcessActivatePoolSnapshot}, + {TAG_DEACTIVATEPOOLSNAPSHOT, MNSS_ProcessDeactivatePoolSnapshot}, + {TAG_LISTPOOLSNAPSHOTS, MNSS_ProcessListPoolSnapshots}, + {TAG_GETPOOLSNAPSHOTINFO, MNSS_ProcessGetPoolSnapshotInfo}, + {TAG_LISTEVMSVOLUMES, MNSS_ProcessListEvmsVolumes}, + +#endif +#if zNETWARE + {TAG_RENAMEPOOLSNAPSHOT, MNSS_ProcessRenamePoolSnapshot}, + + {TAG_LISTPOOLS, MNSS_ProcessListPools}, + {TAG_ADDPOOL, MNSS_ProcessAddPool}, + {TAG_MODIFYPOOLINFO, MNSS_ProcessModifyPoolInfo}, + {TAG_REMOVEPOOL, MNSS_ProcessRemovePool}, + {TAG_EXPANDPOOL, MNSS_ProcessExpandPool}, + {TAG_GETSTATE, MNSS_ProcessGetPoolState}, + + /* pool freeze/thaw */ + {TAG_POOLFREEZE, MNSS_ProcessPoolFreeze}, + {TAG_POOLFREEZESTATUS, MNSS_ProcessPoolFreezeStatus}, + {TAG_POOLTHAW, MNSS_ProcessPoolThaw}, +#endif + + {0} +}; + + +SiblingElements_s LSSElements[] = +{ +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) + {TAG_GETLSSVOLUMEINFO, MNSS_ProcessGetLSSVolumeInfo}, +#endif + {0} +}; + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +/* + * This is an actual function that mirrors the real clustering function. + * I defined it this way so that we will get a compile error if this definition + * ever varies from the one in clstrlib.h + */ +CLSTR_ERRORS NWCLSTR_ClusterEnable( + IN UINT8 *Fdn, + IN UINT8 *strIP, + IN UINT8 *specialVirt, + IN UINT8 *CIFSVirt, + IN UINT32 AutoOnline, + OUT UINT16 *UDNClustRes, + IN UINT32 Advertise, + IN UINT32 IsPool, + IN UINT32 OtherNDSContext) +{ +#if zLINUX + void *libHandle; +#endif + #define NWCLSTR_ClusterEnableAPI MSGNot("\x15" "NWCLSTR_ClusterEnable") + #define NWCLSTR_ClusterEnableAPI_LNX "NWCLSTR_ClusterEnable" + + CLSTR_ERRORS status; + CLSTR_ERRORS (*NWCLSTR_ClusterEnablePtr)(IN UINT8 *Fdn, IN UINT8 *strIP, + IN UINT8 *specialVirt, IN UINT8 *CIFSVirt, IN UINT32 AutoOnline, + OUT UINT16 *UDNClustRes, IN UINT32 Advertise, IN UINT32 IsPool, + IN UINT32 OtherNDSContext) = NULL; + + MPKNSS_UNLOCK(); + +#if zLINUX + libHandle = dlopen(NWCLSTR_LIBNAME, RTLD_LAZY); + if (libHandle) + { + NWCLSTR_ClusterEnablePtr = dlsym(libHandle, NWCLSTR_ClusterEnableAPI_LNX); + } +#endif + if (NWCLSTR_ClusterEnablePtr == NULL) + { + status = zERR_NCS_SYMBOL_IMPORT_ERROR; + goto exit; + } + status = NWCLSTR_ClusterEnablePtr(Fdn, strIP, specialVirt, CIFSVirt, + AutoOnline, UDNClustRes, Advertise, IsPool, OtherNDSContext); + +exit: +#if zLINUX + if (libHandle) + { + dlclose(libHandle); + } +#endif + MPKNSS_LOCK(); + return(status); +} + +/* + * This is an actual function that mirrors the real clustering function. + * I defined it this way so that we will get a compile error if this definition + * ever varies from the one in clstrlib.h + */ +CLSTR_ERRORS NWCLSTR_PoolNames( + IN UINT8 *PoolName, + OUT UINT8 *ClusterPool, + OUT UINT8 *ClusterVirtServer, + OUT UINT8 *ClusterCIFSVirtServer) +{ +#if zLINUX + void *libHandle; +#endif + #define NWCLSTR_PoolNamesAPI MSGNot("\x11" "NWCLSTR_PoolNames") + #define NWCLSTR_PoolNamesAPI_LNX "NWCLSTR_PoolNames" + + CLSTR_ERRORS status; + CLSTR_ERRORS (*NWCLSTR_PoolNamesPtr)(IN UINT8 *PoolName, + OUT UINT8 *ClusterPool, OUT UINT8 *ClusterVirtServer, + OUT UINT8 *ClusterCIFSVirtServer) = NULL; + + MPKNSS_UNLOCK(); + +#if zLINUX + NWCLSTR_PoolNamesPtr = NULL; + libHandle = dlopen(NWCLSTR_LIBNAME, RTLD_LAZY); + if (libHandle) + { + NWCLSTR_PoolNamesPtr = dlsym(libHandle, NWCLSTR_PoolNamesAPI_LNX); + } +#endif + if (NWCLSTR_PoolNamesPtr == NULL) + { + status = zERR_NCS_SYMBOL_IMPORT_ERROR; + goto exit; + } + + status = NWCLSTR_PoolNamesPtr(PoolName, ClusterPool, ClusterVirtServer, + ClusterCIFSVirtServer); + +exit: +#if zLINUX + if (libHandle) + { + dlclose(libHandle); + } +#endif + MPKNSS_LOCK(); + return(status); +} +#endif + +#if zLINUX && !defined(__KERNEL__) +/**************************************************************************** + * + * Create the region and compatilibity volume, then install the file system + * to create a pool. + * + ****************************************************************************/ +STATUS LNXPOOL_CreatePool( + handle_array_t *partList, + char *poolName) +{ + int ccode; + plugin_handle_t pluginHandle; + handle_array_t *outputObjects = NULL; + STATUS status = zFAILURE; + object_handle_t objectHandle = 0; + object_handle_t volHandle; + NINT i; + option_array_t *options = NULL; + handle_object_info_t *objectInfo = NULL; + node_list_t *nodeList; + + /* + * Create a region + */ + ZOS_evms_get_plugin_by_name(ccode, PLUGIN_NWPOOLMGR, &pluginHandle); + if (ccode != 0) + { + syslog(LOG_NOTICE, "Error getting pool plugin handle: %s\n", evmsGetErrString(ccode)); + goto error; + } + + ZOS_evms_create(ccode, pluginHandle, partList, NULL, &outputObjects); + if (ccode != 0) + { + syslog(LOG_NOTICE, "Error creating region: %s\n", evmsGetErrString(ccode)); + goto error; + } + + for (i = 0; i < outputObjects->count; i++) + { + storage_object_info_t *storageInfo; + handle_object_info_t *resultObjectInfo; + + ZOS_evms_get_info(ccode, outputObjects->handle[i], &resultObjectInfo); + if (ccode != 0) + { + syslog(LOG_NOTICE, "CreatePOOL: Cannot get info on new segment\n"); + ZOS_evms_free(outputObjects); + goto error; + } + storageInfo = &resultObjectInfo->info.region; + + if (resultObjectInfo->type == REGION && storageInfo->data_type == DATA_TYPE) + { + objectHandle = outputObjects->handle[i]; + ZOS_evms_free(resultObjectInfo); + break; + } + ZOS_evms_free(resultObjectInfo); + } + ZOS_evms_free(outputObjects); + + ZOS_evms_create_compatibility_volume(ccode, objectHandle); + if (ccode != 0) + { + syslog(LOG_NOTICE, "Error creating EVMS compatibility volume: %d(%s)\n", ccode, evmsGetErrString(ccode)); + goto error; + } + + ZOS_evms_get_plugin_by_name(ccode, PLUGIN_NSSFS, &pluginHandle); + if (ccode != 0) + { + syslog(LOG_NOTICE, "Error getting file system plugin handle: %s\n", evmsGetErrString(ccode)); + goto error; + } + + ZOS_evms_get_info(ccode, objectHandle, &objectInfo); + if (ccode != 0) + { + syslog(LOG_NOTICE, "Error getting region info duringfile system create on pool : %s\n", evmsGetErrString(ccode)); + goto error; + } + volHandle = objectInfo->info.region.volume; + ZOS_evms_free(objectInfo); + + options = malloc(sizeof(option_array_t) + sizeof(key_value_pair_t)); + if (options == NULL) + { + goto error; + } + options->count = 1; + options->option[0].is_number_based = FALSE; + options->option[0].name = MSGNot("name"); + options->option[0].type = EVMS_Type_String; + options->option[0].value.s = poolName; + options->option[0].flags = 0; + + ZOS_evms_mkfs(ccode, volHandle, pluginHandle, options); + free(options); + if (ccode != 0) + { + syslog(LOG_NOTICE, "Error creating file system on pool: %s\n", evmsGetErrString(ccode)); + goto error; + } + + ZOS_evms_commit_changes(ccode); + if (ccode != 0) + { + syslog(LOG_NOTICE, "Error commiting pool create operations: %s\n", evmsGetErrString(ccode)); + goto error; + } + + /* If we working on a cluster, close and reopen engine so that nodes get updated immediately */ + /* --effectively an evms_activate. */ + ZOS_evms_get_node_list(ccode, ACTIVE_NODES_ONLY, &nodeList); + if (ccode == 0) + { + ZOS_evms_free(nodeList); + evmsCloseEngine(); + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + syslog(LOG_NOTICE, "Error opening engine: %s\n", evmsGetErrString(ccode)); + goto error; + } + } + + status = zOK; + +error: + return status; +} +#endif + +#if zLINUX && !defined(__KERNEL__) +/**************************************************************************** + * + * Expand an existing pool using the supplied partitions + * + ****************************************************************************/ +STATUS LNXPOOL_ExpandPool( + handle_array_t *partList, + char *poolName) +{ + int ccode; + STATUS status = zFAILURE; + object_handle_t poolHandle; + node_list_t *nodeList; + + ZOS_evms_get_object_handle_for_name(ccode, (REGION|EVMS_OBJECT), poolName, &poolHandle); + if (ccode != 0) + { + syslog(LOG_NOTICE, "Error getting pool handle: %s\n", evmsGetErrString(ccode)); + goto error; + } + + ZOS_evms_expand(ccode, poolHandle, partList, NULL); + if (ccode != 0) + { + syslog(LOG_NOTICE, "Error adding new partitions to pool: %s\n", evmsGetErrString(ccode)); + /* Adding the call to evms_can_expand in this error path as this function seems to + be failing in some cases (normal pools) even when the evms_expand call succeeds. */ + ZOS_evms_can_expand(ccode, poolHandle); + if(ccode != 0) + { + status = zERR_NOT_SUPPORTED; + } + goto error; + } + + ZOS_evms_commit_changes(ccode); + if (ccode != 0) + { + syslog(LOG_NOTICE, "Error committing changes: %s\n", evmsGetErrString(ccode)); + goto error; + } + + /* If we working on a cluster, close and reopen engine so that nodes get updated immediately */ + /* --effectively an evms_activate. */ + ZOS_evms_get_node_list(ccode, ACTIVE_NODES_ONLY, &nodeList); + if (ccode == 0) + { + ZOS_evms_free(nodeList); + evmsCloseEngine(); + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + syslog(LOG_NOTICE, "Error opening engine: %s\n", evmsGetErrString(ccode)); + goto error; + } + } + + status = zOK; + +error: + return status; +} +#endif + +#if zLINUX && !defined(__KERNEL__) +/**************************************************************************** + * + * Build partitions(segments) in the free space and queue the info for the + * segment so it can be used to build the pool. + * + ****************************************************************************/ +STATUS LNXPOOL_BuildSegmentList( + EvmsStorageArray_s *freeSegments, + QUAD selectedSize, + handle_array_t **partList) +{ + NINT i; + STATUS status = zOK; + EvmsStorageInfo_s *segment; + object_handle_t partHandle; + handle_array_t *temp = NULL; + + ASSERT_MPKNSS_LOCK(); + + if (*partList == NULL) + { + *partList = malloc(sizeof(handle_array_t) + + (freeSegments->count) * sizeof(object_handle_t)); + if (*partList == NULL) + { + return zERR_NO_MEMORY; + } + (*partList)->count = 0; + } + else + { + temp = *partList; + *partList = realloc(*partList, sizeof(handle_array_t) + + (freeSegments->count + (*partList)->count) * sizeof(object_handle_t)); + if (*partList == NULL) + { + free(temp); + return zERR_NO_MEMORY; + } + } + + /* + * See if there is a segment big enough to handle the requested size. + */ + for (i = 0; i < freeSegments->count; i++) + { + segment = &freeSegments->entry[i]; + /* the segment size should be at least one MB */ + if(segment->size < ONE_MB) + { + continue; + } + + if(selectedSize <= segment->size) + { +//syslog(LOG_DEBUG, "====Creating list from one segment. Free size:%llu Alloc size:%llu\n", segment->size, selectedSize); + if (segment->isMirrored) + { + partHandle = segment->handle; + } + else + { + status = evmsCreateSegment(segment->handle, NSS_PARTITION_NAME_STRING, + selectedSize, &partHandle); + if(status != zOK) + { + // Could not create a partition from this freespace, skip this + // space and continue. + continue; + } + } + (*partList)->handle[(*partList)->count] = partHandle; + (*partList)->count++; + goto Exit; + } + } + + /* + * The requested size will be broken up between segments + */ + for (i = 0; i < freeSegments->count; i++) + { + segment = &freeSegments->entry[i]; + if(selectedSize <= segment->size) + { +//syslog(LOG_DEBUG, "====Creating last segment. Free size:%llu Alloc size:%llu\n", segment->size, selectedSize); + if (segment->isMirrored) + { + partHandle = segment->handle; + } + else + { + status = evmsCreateSegment(segment->handle, NSS_PARTITION_NAME_STRING, + selectedSize, &partHandle); + if(status != zOK) + { + // Could not create a partition from this freespace, skip this + // space and continue. + continue; + } + } + (*partList)->handle[(*partList)->count] = partHandle; + (*partList)->count++; + break; + } + else + { +//syslog(LOG_DEBUG, "====Creating a segment. Free/Alloc size:%llu\n", segment->size); + if (segment->isMirrored) + { + partHandle = segment->handle; + } + else + { + status = evmsCreateSegment(segment->handle, NSS_PARTITION_NAME_STRING, + segment->size, &partHandle); + if(status != zOK) + { + // Could not create a partition from this freespace, skip this + // space and continue. + continue; + } + } + selectedSize -= segment->size; + (*partList)->handle[(*partList)->count] = partHandle; + (*partList)->count++; + } + } + +Exit: + // Clear out the list of segments + return status; +} + +int linux_getDeviceFromChildObjects( + utf8_t *tagName, + VirtInfo_s *virtInfo, + PoolDeviceInfoArray_s **deviceArray, + handle_object_info_t *parent_object_info, + handle_array_t *child_objects) +{ + object_handle_t handle = 0; + handle_object_info_t *object_info = NULL; + handle_array_t *tmpArray = NULL; + NINT deviceType; + BOOL deviceFound; + NINT oldCount; + NINT i, j; + utf8_t tempBuf[4096] = ""; + BOOL infoFound; + EvmsExtendInfo_s evmsExtInfo; + PoolDeviceInfoArray_s *temp = NULL; + int ccode = 0; + + if (child_objects == NULL || child_objects->count == 0) + { + return zOK; + } + + for (i = 0; i < child_objects->count; i++) + { + ZOS_evms_get_info(ccode, child_objects->handle[i], &object_info); + if (ccode != 0) + { + if (virtInfo && tagName) + { + sprintf(tempBuf, MSGNot("Error getting object info: %s"), evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + } + goto exit; + } + + deviceFound = FALSE; + + if (object_info->type == DISK) + { + handle = object_info->info.disk.handle; + deviceType = DEVICE_PHYSICAL; + deviceFound = TRUE; + } + else if (object_info->type == REGION) + { + handle = object_info->info.region.handle; + + ccode = evmsGetDeviceType(handle, &deviceType, NULL, NULL); + if (ccode != 0) + { + if (virtInfo && tagName) + { + sprintf(tempBuf, MSGNot("Error getting device type: %s"), evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + } + goto exit; + } + + if (deviceType == DEVICE_MIRROR || deviceType == DEVICE_RAID) + { + deviceFound = TRUE; + } + else + { + ccode = linux_getDeviceFromChildObjects(tagName, virtInfo, deviceArray, + object_info, object_info->info.region.child_objects); + if (ccode != 0) + { + goto exit; + } + } + } + else if (object_info->type == SEGMENT) + { + ccode = linux_getDeviceFromChildObjects(tagName, virtInfo, deviceArray, + object_info, object_info->info.segment.child_objects); + if (ccode != 0) + { + goto exit; + } + } + else if (object_info->type == CONTAINER) + { + ccode = linux_getDeviceFromChildObjects(tagName, virtInfo, deviceArray, + object_info, object_info->info.container.objects_consumed); + if (ccode != 0) + { + goto exit; + } + } + else if (object_info->type == EVMS_OBJECT) + { + ccode = linux_getDeviceFromChildObjects(tagName, virtInfo, deviceArray, + object_info, object_info->info.object.child_objects); + if (ccode != 0) + { + goto exit; + } + } + else if (object_info->type == VOLUME) + { + tmpArray = malloc(sizeof(handle_array_t) + sizeof(object_handle_t)); + if (tmpArray == NULL) + { + ccode = ENOMEM; + goto exit; + } + + tmpArray->count = 1; + tmpArray->handle[0] = object_info->info.volume.object; + ccode = linux_getDeviceFromChildObjects(tagName, virtInfo, deviceArray, + object_info, tmpArray); + if (ccode != 0) + { + goto exit; + } + } + else + { + ccode = zFAILURE; + if (virtInfo && tagName) + { + sprintf(tempBuf, MSGNot("Invalid object type: %s"), object_info->type); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + } + goto exit; + } + + /* get rid of duplicated device handle */ + if (deviceFound && *deviceArray != NULL) + { + for (j = 0; j < (*deviceArray)->count; j++) + { + if (handle == (*deviceArray)->deviceInfo[j].handle) + { + if (deviceType != DEVICE_MIRROR) + { + /* need to add segment size */ + (*deviceArray)->deviceInfo[j].sizeUsedByPool += parent_object_info->info.segment.size * + EVMS_VSECTOR_SIZE; + } + + deviceFound = FALSE; + break; + } + } + } + + if (deviceFound) + { + if (*deviceArray == NULL) + { + oldCount = 0; + *deviceArray = calloc(sizeof(PoolDeviceInfoArray_s), 1); + } + else + { + oldCount = (*deviceArray)->count; + temp = *deviceArray; + *deviceArray = realloc(*deviceArray, sizeof(PoolDeviceInfoArray_s) + + oldCount * sizeof(PoolDeviceInfo_s)); + } + + if (*deviceArray == NULL) + { + ccode = ENOMEM; + free(temp); + if (tagName && virtInfo) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, MSGNot("Out of memory")); + } + goto exit; + } + + (*deviceArray)->count = oldCount + 1; + (*deviceArray)->deviceInfo[oldCount].handle = handle; + if (deviceType == DEVICE_MIRROR) + { + (*deviceArray)->deviceInfo[oldCount].sizeUsedByPool = object_info->info.region.size * + EVMS_VSECTOR_SIZE; + } + else + { + (*deviceArray)->deviceInfo[oldCount].sizeUsedByPool = parent_object_info->info.segment.size * + EVMS_VSECTOR_SIZE; + } + + if (deviceType == DEVICE_PHYSICAL) + { + strcpy((char *)((*deviceArray)->deviceInfo[oldCount].name), object_info->info.disk.name); + } + else + { + strcpy((char *)((*deviceArray)->deviceInfo[oldCount].name), object_info->info.region.name); + } + + if (deviceType == DEVICE_PHYSICAL) + { + ccode = evmsGetExtendedInfo(parent_object_info->info.segment.handle, + (BYTE *)MSGNot("Flags"), &infoFound, &evmsExtInfo); + } + else + { + ccode = evmsGetExtendedInfo(object_info->info.segment.handle, + (BYTE *)MSGNot("Flags"), &infoFound, &evmsExtInfo); + } + + if (ccode != 0) + { + if (tagName && virtInfo) + { + sprintf(tempBuf, MSGNot("Error getting object flags info: %s"), evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + } + goto exit; + } + + (*deviceArray)->deviceInfo[oldCount].isMirrored = FALSE; + (*deviceArray)->deviceInfo[oldCount].isShared = FALSE; + if (infoFound) + { + if (evmsExtInfo.value.ui32 & STATUS_MIRRORED) + { + (*deviceArray)->deviceInfo[oldCount].isMirrored = TRUE; + } + + if (evmsExtInfo.value.ui32 & STATUS_SHARED) + { + (*deviceArray)->deviceInfo[oldCount].isShared = TRUE; + } + } + } + + ZOS_evms_free(object_info); + object_info = NULL; + } + +exit: + if (tmpArray != NULL) + { + free(tmpArray); + } + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + return ccode; +} + +STATUS LNXPOOL_getPoolDevices( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *poolName) +{ + int ccode; + object_handle_t regionHandle; + PoolDeviceInfoArray_s *deviceArray = NULL; + utf8_t tempBuf[4096] = ""; + handle_object_info_t *pool_object_info = NULL; + storage_object_info_t *pool_info = NULL; + NINT i; + NINT len = 0; + + ccode = evmsOpenEngine(EVMS_ENGINE_READONLY); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Error openin evms engine")); + return zOK; + } + + ZOS_evms_get_object_handle_for_name(ccode, REGION | EVMS_OBJECT, poolName, ®ionHandle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting region handle for %s: %s"), + poolName, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + /* get object info */ + ZOS_evms_get_info(ccode, regionHandle, &pool_object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object info for %s: %s"), + poolName, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + pool_info = &pool_object_info->info.region; + + if (pool_info->child_objects != NULL && pool_info->child_objects->count == 0) + { + sprintf(tempBuf, MSGNot("Error no child info for %s: %s"), + poolName, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + ccode = linux_getDeviceFromChildObjects(tagName, virtInfo, &deviceArray, + pool_object_info, pool_info->child_objects); + if (ccode != 0) + { + goto close_engine; + } + + /* add xml */ + if ((ccode = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto close_engine; + } + + for (i = 0; i < deviceArray->count; i++) + { + sprintf(tempBuf, + MSGNot("<"TAG_DEVICESIMPLEINFO">" + "<"TAG_OBJECTID">%s" + "<"TAG_NAME">%s" + "<"TAG_SIZE">%Lu"), + deviceArray->deviceInfo[i].name, + deviceArray->deviceInfo[i].name, + deviceArray->deviceInfo[i].sizeUsedByPool); + + len = strlen(tempBuf); + + if (deviceArray->deviceInfo[i].isMirrored) + { + strcpy(&tempBuf[len], "<"TAG_MIRRORED"/>"); + len = strlen(tempBuf); + } + + if (deviceArray->deviceInfo[i].isShared) + { + strcpy(&tempBuf[len], "<"TAG_SHARED"/>"); + len = strlen(tempBuf); + } + + strcpy(&tempBuf[len], "\n"); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + sprintf(tempBuf, MSGNot("Error result data\n")); + goto exit; + } + } + +exit: + if (ccode == zOK) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, tempBuf); + } + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +close_engine: + if (deviceArray != NULL) + { + free(deviceArray); + } + + if (pool_object_info != NULL) + { + ZOS_evms_free(pool_object_info); + } + + evmsCloseEngine(); + + return zOK; +} +#endif + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +/**************************************************************************** + * + ****************************************************************************/ +STATUS GetPoolID(unicode_t *uni_poolName, VolumeID_t *poolID) +{ + STATUS status = zOK; + GeneralMsg_s genMsg; + Pool_s *pool; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + pool = COMN_PoolNameLookup(&genMsg, uni_poolName, FALSE, poolID); + if (pool == NULL) + { + status = GetErrno(&genMsg); + } + else + { + COMN_Release(&pool); + } + + return status; +} +#endif + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +#if zLINUX +/**************************************************************************** + * + * This function removes a pool from EVMS + * + ****************************************************************************/ +STATUS MNSS_RemovePool( + BOOL openEVMSEngine, + utf8_t *poolName) +{ + long ccode; + STATUS status = zFAILURE; + char realPoolName[512]; + object_handle_t handle; + node_list_t *nodeList; + + if (openEVMSEngine) + { + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + return status; + } + } + strcpy(realPoolName, EVMS_DEVICE_PATH); + strcat(realPoolName, poolName); + + /* Is clustering enabled? */ + ZOS_evms_get_node_list(ccode, ACTIVE_NODES_ONLY, &nodeList); + if (ccode == 0) + { + /* have list of active cluster nodes */ + char myHostName[HOST_NAME_MAX]; + int i; + + // syslog(LOG_DEBUG, "Unmounting pool from cluster\n"); + + /* If using gethostname() ever fails, NCS saves the local node name in the file + * /etc/opt/novell/ncs/nodename. + */ + if ((ccode = gethostname(myHostName, HOST_NAME_MAX)) == 0) + { + ZOS_evms_get_object_handle_for_name(ccode, VOLUME, realPoolName, &handle); + if (ccode != 0) + { + status = ccode; + goto exit; + } + + ZOS_evms_unmkfs(ccode, handle); + if (ccode != 0) + { + if (ccode != EBUSY) + { + syslog(LOG_DEBUG, "Remove pool: Error removing the file system: %s\n", strerror(ccode)); + status = ccode; + ZOS_evms_free(nodeList); + goto exit; + } +// syslog(LOG_DEBUG, "Remove pool: Error removing the file system: %s\n", strerror(ccode)); + } + + /* send unmount to all nodes in cluster */ + for (i = 0; i < nodeList->count; i++) + { + int local; + + ZOS_evms_set_current_node(ccode, (char *)nodeList->node_info[i].node_name); + local = (strcmp(myHostName, nodeList->node_info[i].node_name) == 0); + + if (ccode == 0) + { + // syslog(LOG_DEBUG, "Unmounting pool from cluster node %s\n", nodeList->node_info[i].node_name); + ZOS_evms_get_object_handle_for_name(ccode, VOLUME, realPoolName, &handle); + if (ccode == 0) + { + evmsUnmountByHandle(handle); + } + else + { + if (local) + { + status = ccode; + ZOS_evms_free(nodeList); + goto exit; + } + } + } + } + + ZOS_evms_free(nodeList); + + /* reset focus back to local node and complete pool device removal */ + ZOS_evms_set_current_node(ccode, myHostName); + if (ccode != 0) + { + // syslog(LOG_DEBUG, "Local cluster node name %s not recognized\n", myHostName); + status = ccode; + goto exit; + } + + ZOS_evms_get_object_handle_for_name(ccode, VOLUME, realPoolName, &handle); + if (ccode != 0) + { + status = ccode; + goto exit; + } + + ccode = evmsDestroyObjectByHandle(handle, FALSE); + if (ccode != 0) + { + status = ccode; + goto exit; + } + + /* close and open engine one more time so that other nodes remove pool device now */ + evmsCloseEngine(); + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + syslog(LOG_NOTICE, "Error opening engine: %s\n", evmsGetErrString(ccode)); + status = ccode; + goto exit; + } + } + else + { + // syslog(LOG_DEBUG, "Error getting host name\n"); + status = ccode; + goto exit; + } + } + else + { + /* local, not in cluster */ + // syslog(LOG_DEBUG, "Unmounting pool (not in cluster)\n"); + ZOS_evms_get_object_handle_for_name(ccode, VOLUME, realPoolName, &handle); + if (ccode != 0) + { + status = ccode; + goto exit; + } + + ZOS_evms_unmkfs(ccode, handle); + if (ccode != 0) + { + if (ccode != EBUSY){ + status = ccode; + goto exit; + } + // syslog(LOG_DEBUG, "Remove pool: Error removing the file system: %s\n", strerror(ccode)); + } + + ccode = evmsUnmountByHandle(handle); + // if (ccode == 0) + // { + // syslog(LOG_DEBUG, "----Remove pool - pool unmount worked.\n"); + // } + // else + // { + // syslog(LOG_DEBUG, "----Remove pool - unable to unmount pool.\n"); + // } + + ccode = evmsDestroyObjectByHandle(handle, FALSE); + if (ccode != 0) + { + status = ccode; + goto exit; + } + } + + status = zOK; + +exit: + if (openEVMSEngine) + { + evmsCloseEngine(); + } + return status; +} +#endif + +/**************************************************************************** + * + * This function creates a pool: In this version, the user select the device + * and how much to use in this device to create the pool, instead of selecting + * the partition. + ****************************************************************************/ +STATUS MNSS_ProcessAddPoolSimple( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; +#if zNETWARE + GeneralMsg_s genMsg; +#endif + unicode_t uni_poolName[zMAX_COMPONENT_NAME]; + utf8_t *start; + XML_ElementInfo_s addPoolDeviceInfoElement; + QUAD selectedSize = 0; + NINT i; + utf8_t *ndsNamePtr; + DDCString *fullyDistinguishedName = NULL; + VolumeID_t poolID; + zInfo_s poolInfo; + BOOL shared = FALSE; + utf8_t ndsName[zMAX_COMPONENT_NAME]; + utf8_t virtualServerName[zMAX_COMPONENT_NAME]; + utf8_t cifsVirtualServerName[MAX_CIFS_VIRTUAL_SERVER_NAME+1]; + NINT mode = 0; + NINT savedPoolState; + BOOL activate = FALSE; + BOOL deactivate = FALSE; +#if zNETWARE + LONG ccode; + BOOL isFirstPartition = TRUE; + OBID groupID; + OBID devID; + struct IOObjectGenericInfoDef devGen; + OBID newGroupID = -1; + struct IOObjectGenericInfoDef objectGen; + BOOL failToAddSegment = FALSE; + QUAD actualPoolSize = 0; +#endif + int retDSContext = 0; + utf8_t *retContainer = NULL; + utf8_t *retName = NULL; +#if zNETWARE + DQhead_t poolSegmentList; + Pool_Segment_s *poolSegment = NULL; + OBID objectID = 0; +#endif +#if zLINUX + int ccode; + BOOL engineOpen = FALSE; + EvmsStorageArray_s *freeSegments = NULL; + handle_array_t *partitionList = NULL; + QUAD freeSpaceSize; + object_handle_t objHandle; +#endif + + const TagRequest_s tags[] = + { + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_NDSNAME, TR_OPTIONAL}, + {TAG_CONTEXT, TR_OPTIONAL}, + {TAG_NONDSOBJECT, TR_OPTIONAL}, + {TAG_DEVICES, TR_CONTENT_REQUIRED}, + {TAG_LSSTYPE, TR_OPTIONAL|TR_CONTENT_REQUIRED}, + {TAG_IGNORESHARESTATE, TR_OPTIONAL}, + {TAG_CLUSTER, TR_OPTIONAL|TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + enum + { + POOL_NAME = 0, + NDS_NAME = 1, + CONTEXT = 2, + NO_NDS_OBJECT = 3, + DEVICES = 4, + LSS_TYPE = 5, + IGNORE_SHARE_STATE = 6, + CLUSTER = 7, + }; + + /* Tags for parsing */ + const TagRequest_s clusterTags[] = + { + {TAG_ADVERTISINGPROTOCOLS, TR_OPTIONAL}, + {TAG_IPADDRESS, TR_CONTENT_REQUIRED}, + {TAG_VIRTUALSERVERNAME, TR_CONTENT_REQUIRED}, + {TAG_CIFSVIRTUALSERVERNAME, TR_OPTIONAL|TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s clusterTagContent[NELEMS(clusterTags)-1]; + enum + { + ADVERTISING_PROTOCOLS = 0, + IP_ADDRESS = 1, + VIRTUAL_SERVER_NAME = 2, + CIFS_VIRTUAL_SERVER_NAME = 3, + }; + + /* Tags for parsing */ + const TagRequest_s addPoolDeviceInfoTags[] = + { + {TAG_OBJECTID, TR_CONTENT_REQUIRED}, + {TAG_SIZE, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s addPoolDeviceInfoTagContent[NELEMS(addPoolDeviceInfoTags)-1]; + + enum + { + OBJECTID = 0, + SIZE = 1, + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + if (tagContent[CLUSTER].flags & TR_TAG_FOUND) + { + if ((status = MNSS_GetTagContents(virtInfo,tagName, + &tagContent[CLUSTER].element, + clusterTags, clusterTagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + fullyDistinguishedName = malloc(NDS_SERVER_SIZE); + if (fullyDistinguishedName == NULL) + { + return zERR_NO_MEMORY; + } + } + + if (tagContent[LSS_TYPE].flags & TR_TAG_FOUND) + { + if (strcmp(tagContent[LSS_TYPE].content, MSGNot("ZLSS")) != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, MSGNot("Invalid LSS")); + goto exit; + } + } + + /* + * Upper case the name. It is done before the unicode conversion because + * we use both the unicode and utf8 versions. + */ + for (i = 0; tagContent[POOL_NAME].content[i] != '\0'; i++) + { + tagContent[POOL_NAME].content[i] = + toupper(tagContent[POOL_NAME].content[i]); + } + + /* pool name to unicode */ + if (utf2uni(tagContent[POOL_NAME].content, uni_poolName, + sizeof(uni_poolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting pool name to unicode")); + goto exit; + } + + if ((status = LB_PoolNameAcceptable(uni_poolName)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid pool name")); + goto exit; + } + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to open the EVMS engine")); + goto exit; + } + + engineOpen = TRUE; + + /* Make sure an object does NOT already exist for specified poolName */ + ZOS_evms_get_object_handle_for_name(ccode, + (DISK | SEGMENT | REGION | EVMS_OBJECT | CONTAINER | VOLUME), + tagContent[POOL_NAME].content, &objHandle); + + if (ccode == 0) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_NAME, + MSGNot("Invalid pool name")); + goto exit; + } + + start = tagContent[DEVICES].element.dataStart; + for(;;) + { + /* find the next device */ + if (XML_GetTagElement(TAG_ADDPOOLDEVICEINFO, start, + tagContent[DEVICES].element.dataEnd, &addPoolDeviceInfoElement) != zOK) + { + break; /* we cannot find anymore devices */ + } + + if ((status = MNSS_GetTagContents(virtInfo, tagName, &addPoolDeviceInfoElement, + addPoolDeviceInfoTags, addPoolDeviceInfoTagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + if (addPoolDeviceInfoTagContent[SIZE].flags & TR_TAG_FOUND) + { + selectedSize = atoq(addPoolDeviceInfoTagContent[SIZE].content); + } + else + { + //zASSERT("Size for pool segment is not found" == NULL); + selectedSize = 0; /* this should never happen */ + } + + ccode = evmsGetDeviceSharedState( + addPoolDeviceInfoTagContent[OBJECTID].content, &shared); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error getting device shared state")); + goto exit; + } + + ccode = evmsGetDeviceFreeSegments( + addPoolDeviceInfoTagContent[OBJECTID].content, &freeSegments, + &freeSpaceSize); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_UNABLE_TO_GET_EVMS_SEGMENTS, + MSGNot("Error getting enough available evms partition space to satisfy request")); + goto exit; + } + +//{ +// int i; +// for (i = 0; i < freeSegments->count; i++) +// { +// syslog(LOG_DEBUG, "====Free segment(%d) handle=%d size=%llu, isMirrored=%d\n", +// i, freeSegments->entry[i].handle, freeSegments->entry[i].size, freeSegments->entry[i].isMirrored); +// } +//} + + /* Verify that we got pool segments */ + if (freeSpaceSize < selectedSize || freeSegments->count == 0) + { + status = zERR_UNABLE_TO_GET_ENOUGH_SIZE; + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to get enough pool size")); + goto exit; + } + + if (!(tagContent[IGNORE_SHARE_STATE].flags & TR_TAG_FOUND) && + !COMN_ClusterSoftwareIsCheckingPoolStateChanges() && + shared) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NCS_CVB_NOT_REGISTERED, + MSGNot("CVB has not registered for pool events")); + goto exit; + } + +#if zLINUX + status = LNXPOOL_BuildSegmentList(freeSegments, selectedSize, + &partitionList); + if(status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_UNABLE_TO_GET_EVMS_SEGMENTS, + MSGNot("Error getting enough available evms partition space to satisfy request")); + goto exit; + } +#endif +// { +// int i; +// for (i = 0; i < partitionList->count; i++) +// { +// syslog(LOG_DEBUG, "====Partition list(%d) handle=%d\n", i, partitionList->handle[i]); +// printf("====Partition list(%d) handle=%d\n", i, partitionList->handle[i]); +// } +// } + free(freeSegments); + freeSegments = NULL; + + start = addPoolDeviceInfoTagContent[SIZE].element.elementEnd; + } + +#if zLINUX + if (LNXPOOL_CreatePool(partitionList, tagContent[POOL_NAME].content) != zOK) + { + status = zERR_UNABLE_TO_GET_ENOUGH_SIZE; + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to create pool")); + goto exit; + } +#endif + + /* + * Check to see if the pool should be left deactive, active. + */ + if (XML_GetTagAttribute(ATR_STATE, element) == zOK) + { + mode = VOLMODE_VERBOSE; + if (tagContent[IGNORE_SHARE_STATE].flags & TR_TAG_FOUND) + { + mode |= VOLMODE_OVERRIDE_SHARED; + } + *(element->attributeValueEnd + 1) = 0; + if (strcmp(element->attributeValueStart, + MSGNot("active")) == 0) + { + activate = TRUE; + } + else if (strcmp(element->attributeValueStart, + MSGNot("deactive")) == 0) + { + deactivate = TRUE; + } + } + + /* + * Add the NDS object if it should be there + */ + if (!(tagContent[NO_NDS_OBJECT].flags & TR_TAG_FOUND)) + { + if (tagContent[CLUSTER].flags & TR_TAG_FOUND) + { + /* First, try to use the clustering software to get the default names. + * If that fails, we will generate our own using the NDS server name. + */ + ndsNamePtr = ndsName; + status = NWCLSTR_PoolNames((BYTE *)(tagContent[POOL_NAME].content), + (BYTE *)ndsName, (BYTE *)virtualServerName, (BYTE *)cifsVirtualServerName); + if (status == zERR_NCS_SYMBOL_IMPORT_ERROR) //Cluster function not available + { + if (tagContent[IGNORE_SHARE_STATE].flags & TR_TAG_FOUND) + { + /* We are ignoring share state, and clustering is not + * available. + * Prevent further attempts to cluster enable + */ + tagContent[CLUSTER].flags &= ~TR_TAG_FOUND; + ndsNamePtr = NULL; + status = zOK; + } + else + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Clustering software is not loaded")); + goto exit; + } + } + else if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to get Default Pool NDS name for Clustered Pool")); + goto exit; + } + } + else + { + /* No cluster info provided. Just use NDS default names for POOL object*/ + ndsNamePtr = NULL; + } + +// These are supposed to be optional! +// if (!(tagContent[NDS_NAME].flags & TR_TAG_FOUND) || +// !(tagContent[CONTEXT].flags & TR_TAG_FOUND)) +// { +// MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, +// MSGNot("Missing NDS name or context")); +// goto exit; +// } + + /* If the caller specified an NDS name in XML, ignore any defaults + * generated by us or by clustering and use the passed in name. + */ + if ((ndsNamePtr == NULL) || + ((tagContent[NDS_NAME].content != NULL) && + (tagContent[NDS_NAME].content[0] != 0))) + { + ndsNamePtr = tagContent[NDS_NAME].content; + } + + status = GetPoolID(uni_poolName, &poolID); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error finding pool in NSS")); + goto exit; + } + + if ((status = MNDS_AddPoolToNDS(virtInfo, tagContent[CONTEXT].content, + ndsNamePtr, tagContent[POOL_NAME].content, + &poolID, shared, &poolInfo.pool.ndsObjectID, + &retContainer, &retName, &retDSContext)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error adding pool to NDS")); + goto exit; + } + +//#ifndef __linux__ + /* The pool must be active to modify the GUID of a shared pool */ + savedPoolState = GetPoolState(uni_poolName); + if (savedPoolState != zVOLSTATE_ACTIVE) + { + if ((status = ChangePoolState(uni_poolName, + zVOLSTATE_ACTIVE, VOLMODE_OVERRIDE_SHARED)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error activating pool to set NDS object's GUID")); + goto exit; + } + } +//#endif + + status = SetNDSInfoOnPool(uni_poolName, &poolInfo); +//#ifndef __linux__ + if (savedPoolState != zVOLSTATE_ACTIVE) + { + ChangePoolState(uni_poolName, savedPoolState, + VOLMODE_OVERRIDE_SHARED); + } +//#endif + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error setting NDS object ID for NSS pool")); + goto exit; + } + + /* + * Process the cluster options if they exist. Note, all three of these + * options must be specified with non-null content in order to execute + * the code inside of the "if statement". + */ + if (tagContent[CLUSTER].flags & TR_TAG_FOUND) + { + NINT clusterAdvertise = 0; + + if (clusterTagContent[ADVERTISING_PROTOCOLS].flags & TR_TAG_FOUND) + { + utf8_t *prPtr = clusterTagContent[ADVERTISING_PROTOCOLS].content; + while ((prPtr != NULL) && (*prPtr != 0)) + { + /* Skip white space */ + while(isspace(*prPtr)) + { + ++prPtr; + } + if ((strnicmp(prPtr,"cifs",4) == 0) && + ((isspace(*(prPtr+4))) || (*(prPtr+4) == 0))) + { + clusterAdvertise |= CIFS_ADVERTISE; + prPtr += 4; + continue; + } + if ((strnicmp(prPtr,"ncp",3) == 0) && + ((isspace(*(prPtr+3))) || (*(prPtr+3) == 0))) + { + clusterAdvertise |= NCP_ADVERTISE; + prPtr += 3; + continue; + } + if ((strnicmp(prPtr,"afp",3) == 0) && + ((isspace(*(prPtr+3))) || (*(prPtr+3) == 0))) + { + clusterAdvertise |= AFP_ADVERTISE; + prPtr += 3; + continue; + } + /* Skip unrecognized string */ + while ((*prPtr) && !isspace(*prPtr)) + { + ++prPtr; + } + } + } + + /* Call the actual clustering software to cluster enable this pool */ + sprintf(fullyDistinguishedName, MSGNot("%s\\%s"), + (tagContent[CONTEXT].content ? tagContent[CONTEXT].content : retContainer), + retName); + status = NWCLSTR_ClusterEnable( + fullyDistinguishedName, + (BYTE *)clusterTagContent[IP_ADDRESS].content, + (BYTE *)clusterTagContent[VIRTUAL_SERVER_NAME].content, + (BYTE *)clusterTagContent[CIFS_VIRTUAL_SERVER_NAME].content, + activate, NULL, clusterAdvertise, TRUE, retDSContext); + if (status != CLSTR_OK) + { + STATUS cleanupStatus1; + if (status == CLSTR_IP_DUPLICATE) + { + /* Return zERROR for this DUP IP Error */ + status = zERR_NWCS_DUPLICATE_IP_ADDRESS; + } + + if (status != CLSTR_OBJECT_NOT_FOUND) + { + /* Remove the pool NDS object */ + cleanupStatus1 = MNDS_RemoveObjectFromNDS( + (tagContent[CONTEXT].content ? tagContent[CONTEXT].content : retContainer), + ndsNamePtr, NULL); + +#if zLINUX + (void)MNSS_RemovePool(FALSE, tagContent[POOL_NAME].content); +#endif + } + else + { + status = zERR_NWCS_OBJECT_NOT_FOUND; + } + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error cluster enabling the NSS pool")); + goto exit; + } + } + } + + /* + * Check to see if the pool should be left deactive, active. + */ + if (activate) + { + ChangePoolState(uni_poolName, zVOLSTATE_ACTIVE, mode); + } + else if (deactivate) + { + ChangePoolState(uni_poolName, zVOLSTATE_DEACTIVE, mode); + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: +#if zLINUX + if (engineOpen) + { + evmsCloseEngine(); + engineOpen = FALSE; + } + + free(freeSegments); + free(partitionList); +#endif + if (retDSContext != 0) + { +// zASSERT(NdsPublicsLoaded); + MPKNSS_UNLOCK(); + (*DDCLogoutPtr)(retDSContext); + (*DDCFreeContextPtr)(retDSContext); + MPKNSS_LOCK(); + } + if (retName) + { + free(retName); + } + if (retContainer) + { + free(retContainer); + } + if (fullyDistinguishedName) + { + free(fullyDistinguishedName); + } + + return zOK; +} +#endif + + +/**************************************************************************** + * This function... + * KERNEL FUNC + *****************************************************************************/ +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +NINT GetPoolLSSType(unicode_t *uniPoolName) +{ + NINT classID; + Pool_s *pool; + GeneralMsg_s genMsg; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + if ((pool = COMN_PoolNameLookup(&genMsg, uniPoolName, FALSE, NULL)) == NULL) + { + return zFTYPE_INVALID; + } + + X_LATCH( &pool->cvsLatch ); + classID = pool->POOLroot.beastClass->classID; + UNX_LATCH( &pool->cvsLatch ); + COMN_Release(&pool); + return classID; +} +#endif + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +/**************************************************************************** + * Add the pool tag and all of its contents. + *****************************************************************************/ +STATUS AddPoolBasicInfo( + VirtInfo_s *virtInfo, + char *poolName, + zInfo_s *info, + unicode_t *uniPoolName) +{ + STATUS status; + NINT classID; + utf8_t tmpStr[zMAX_FULL_NAME]; + char *stateString; + GUID_t *ptrGUID; + char *lssString; + + ASSERT_MPKNSS_LOCK(); + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_BASICINFO, FALSE, TRUE)) != zOK) + { + return status; + } + + /* pool name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_POOLNAME, + poolName, FALSE)) != zOK) + { + return status; + } + +#if zLINUX + /* mount point */ + sprintf(tmpStr, MSGNot("%s%s"), POOL_MOUNT_POINT, poolName); + if ((status = VIRT_AddResultElement(virtInfo, TAG_MOUNTPOINT, + tmpStr, FALSE)) != zOK) + { + return status; + } +#endif + + /* NDS pool name */ + if ((status = MNSS_GetNDSNameFromGUID(NULL, &info->pool.ndsObjectID, + tmpStr)) != zOK) + { + tmpStr[0] = 0; + } + + if ((status = VIRT_AddResultElement(virtInfo, TAG_NDSPOOLNAME, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* NDS GUID */ + ptrGUID = (GUID_t *)&info->pool.ndsObjectID; + bzero(tmpStr, sizeof(tmpStr)); + LB_GUIDToString(ptrGUID, sizeof(tmpStr), tmpStr); + if ((status = VIRT_AddResultElement(virtInfo, TAG_NDSPOOLGUID, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* NSS GUID */ + ptrGUID = (GUID_t *)&info->pool.poolID; + bzero(tmpStr, sizeof(tmpStr)); + LB_GUIDToString(ptrGUID, sizeof(tmpStr), tmpStr); + if ((status = VIRT_AddResultElement(virtInfo, TAG_POOLGUID, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* State */ + stateString = MLIB_GetPoolStateName(info->pool.poolState); + if ((status = VIRT_AddResultElement(virtInfo, TAG_POOLSTATE, + stateString, FALSE)) != zOK) + { + return status; + } + + /* Name spaces */ + if ((status = VIRT_AddResultTagForAttribute(virtInfo, TAG_NAMESPACES)) + != zOK) + { + return status; + } + sprintf(tmpStr, MSGNot("%u"), info->pool.nameSpaceMask); + if ((status = VIRT_AddAttribute(virtInfo, ATR_VALUE, tmpStr, TRUE, + FALSE, FALSE)) != zOK) + { + return status; + } + tmpStr[0] = 0; + if (info->pool.nameSpaceMask & (1 << zNSPACE_DOS)) + { + strcat(tmpStr, MSGNot("DOS ")); + } + if (info->pool.nameSpaceMask & (1 << zNSPACE_LONG)) + { + strcat(tmpStr, MSGNot("Long ")); + } + if (info->pool.nameSpaceMask & (1 << zNSPACE_MAC)) + { + strcat(tmpStr, MSGNot("Macintosh ")); + } + if (info->pool.nameSpaceMask & (1 << zNSPACE_UNIX)) + { + strcat(tmpStr, MSGNot("Unix ")); + } + if (info->pool.nameSpaceMask & (1 << zNSPACE_EXTENDED_ATTRIBUTE)) + { + strcat(tmpStr, MSGNot("ExtendedAttribute ")); + } + if (info->pool.nameSpaceMask & (1 << zNSPACE_DATA_STREAM)) + { + strcat(tmpStr, MSGNot("DataStream ")); + } + if ((status = VIRT_AddResultData(virtInfo, tmpStr)) != zOK) + { + return(status); + } + if ((status = VIRT_AddResultTag(virtInfo, TAG_NAMESPACES, TRUE, TRUE)) != zOK) + { + return(status); + } + + /* FixFixFix - Need to get from get info when this is not the default size. + * Block Size */ +// sprintf(tmpStr, MSGNot("%u"), info->blockSize.size); + sprintf(tmpStr, MSGNot("%u"), DEFAULT_BLOCK_SIZE); + if ((status = VIRT_AddResultElement(virtInfo, TAG_BLOCKSIZE, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Size */ + sprintf(tmpStr, MSGNot("%Lu"), info->pool.totalSpace); + if ((status = VIRT_AddResultElement(virtInfo, TAG_SIZE, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Used space */ + sprintf(tmpStr, MSGNot("%Lu"), info->pool.numUsedBytes); + if ((status = VIRT_AddResultElement(virtInfo, TAG_USEDSIZE, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Created Time */ + if ((status = AddUTCTimeTag(virtInfo, TAG_CREATEDTIME, + (Time_t)(info->time.created))) != zOK) + { + return(status); + } + + /* Modified Time */ + if ((status = AddUTCTimeTag(virtInfo, TAG_MODIFIEDTIME, + (Time_t)(info->time.modified))) != zOK) + { + return status; + } + + /* lss Type */ + classID = GetPoolLSSType(uniPoolName); + switch (classID) + { + case zFTYPE_ZLSS_ZFSPOOL: + case zFTYPE_ZLSS_LOGICAL_POOL: + lssString = MSGNot("ZLSS"); + break; + + default: + lssString = MSGNot("unknown"); + break; + } + if ((status = VIRT_AddResultElement(virtInfo, TAG_LSSTYPE, + lssString, FALSE)) != zOK) + { + return status; + } + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_BASICINFO, TRUE, TRUE)) != zOK) + { + return status; + } + return(zOK); +} + +/**************************************************************************** + * Add the tag and all of its contents. + *****************************************************************************/ +STATUS FillPoolAttributeInfo( + VirtInfo_s *virtInfo, + char *tagName, + QUAD attributes) +{ + STATUS status; + utf8_t tmpStr[zMAX_COMPONENT_NAME]; + + ASSERT_MPKNSS_LOCK(); + +#if zPOOL_FEATURE_LIST != 0xff + /* This #if ensures that when someone adds a new POOL feature + * that they look at this file. + */ + #error Someone added a new Pool feature without updating... +#endif + + if ((status = VIRT_AddResultTagForAttribute(virtInfo, tagName)) != zOK) + { + return status; + } + sprintf(tmpStr, MSGNot("%Lu"), attributes); + if ((status = VIRT_AddAttribute(virtInfo, ATR_VALUE, tmpStr, TRUE, + FALSE, FALSE)) != zOK) + { + return status; + } + + if (attributes & zPOOL_FEATURE_PERSISTENT_FEATURES) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_PERSISTENTFEATURES, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zPOOL_FEATURE_SHARED_CLUSTER) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_SHARED, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zPOOL_FEATURE_READ_ONLY) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_READONLY, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zPOOL_FEATURE_VERIFY) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_VERIFY, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zPOOL_FEATURE_REBUILD) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_REBUILD, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zPOOL_FEATURE_MULTIPLE_VOLUMES) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_MULTIPLEVOLUMES, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zPOOL_FEATURE_SNAPSHOT) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_SNAPSHOT, + NULL, FALSE)) != zOK) + { + return status; + } + } + + if (attributes & zPOOL_FEATURE_MSAP) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_MSAP, + NULL, FALSE)) != zOK) + { + return status; + } + } + + if ((status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE)) != zOK) + { + return(status); + } + return(zOK); +} + +/**************************************************************************** + * Add the pool tag and all of its contents. + *****************************************************************************/ +STATUS AddPoolAttrInfo( + VirtInfo_s *virtInfo, + zInfo_s *info) +{ + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_ATTRIBUTEINFO, + FALSE, TRUE)) != zOK) + { + return status; + } + + /* SupportedAttributes */ + if ((status = FillPoolAttributeInfo(virtInfo, TAG_SUPPORTEDATTRIBUTES, + info->pool.features.supported)) != zOK) + { + return status; + } + + /* EnabledAttributes */ + if ((status = FillPoolAttributeInfo(virtInfo, TAG_ENABLEDATTRIBUTES, + info->pool.features.enabled)) != zOK) + { + return status; + } + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_ATTRIBUTEINFO, TRUE, TRUE)) != zOK) + { + return status; + } + return(zOK); +} + +/**************************************************************************** + * Add the pool tag and all of its contents. + *****************************************************************************/ +STATUS AddPoolSalvageInfo( + VirtInfo_s *virtInfo, + zInfo_s *info) +{ + STATUS status; + utf8_t tmpStr[zMAX_COMPONENT_NAME]; + + ASSERT_MPKNSS_LOCK(); + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_SALVAGEINFO, FALSE, TRUE)) != zOK) + { + return status; + } + + /* Purgeable bytes */ + sprintf(tmpStr, MSGNot("%Lu"), info->pool.purgeableBytes); + if ((status = VIRT_AddResultElement(virtInfo, TAG_FREEABLESIZE, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Non-purgeable bytes */ + sprintf(tmpStr, MSGNot("%Lu"), info->pool.nonPurgeableBytes); + if ((status = VIRT_AddResultElement(virtInfo, TAG_NONFREEABLESIZE, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_SALVAGEINFO, TRUE, TRUE)) != zOK) + { + return status; + } + return(zOK); +} + +/**************************************************************************** + * Add the pool tag and all of its contents. + *****************************************************************************/ +STATUS AddPoolVolumeInfo( + VirtInfo_s *virtInfo, + unicode_t *uniPoolName) +{ + STATUS status; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + utf8_t volName[zMAX_COMPONENT_NAME]; + BOOL firstTime; + GUID_t cookie; + BOOL deletedVolume = FALSE; + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_VOLUMEINFO, FALSE, TRUE)) != zOK) + { + goto exit; + } + + firstTime = TRUE; + while ((status = GetNextVolumeInfo(uniPoolName, firstTime, deletedVolume, &cookie, uniVolName, sizeof(uniVolName))) == zOK) + { + firstTime = FALSE; + + if (uni2utf(uniVolName, volName, sizeof(volName)) == -1) + { + MNSS_ReturnResult(virtInfo, TAG_VOLUMEINFO, + zERR_UNICODE_CONVERSION_ERROR, + MSGNot("Error unable to convert volume name to unicode")); + break; + } + + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMENAME, + volName, TRUE)) != zOK) + { + goto exit; + } + } + + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_VOLUMEINFO, TRUE, TRUE)) != zOK) + { + goto exit; + } + +exit: + return status; +} + +/**************************************************************************** + * Add the pool tag and all of its contents. + *****************************************************************************/ +STATUS AddPoolDeletedVolumeInfo( + VirtInfo_s *virtInfo, + unicode_t *uniPoolName) +{ + STATUS status; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + utf8_t volName[zMAX_COMPONENT_NAME]; + BOOL firstTime; + GUID_t cookie; + BOOL deletedVolume = TRUE; + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_DELETEDVOLUMEINFO, FALSE, TRUE)) != zOK) + { + goto exit; + } + + firstTime = TRUE; + while ((status = GetNextVolumeInfo(uniPoolName, firstTime, deletedVolume, &cookie, uniVolName, sizeof(uniVolName))) == zOK) + { + firstTime = FALSE; + + if (uni2utf(uniVolName, volName, sizeof(volName)) == -1) + { + MNSS_ReturnResult(virtInfo, TAG_DELETEDVOLUMEINFO, + zERR_UNICODE_CONVERSION_ERROR, + MSGNot("Error unable to convert volume name to unicode")); + break; + } + + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMENAME, + volName, TRUE)) != zOK) + { + goto exit; + } + } + + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_DELETEDVOLUMEINFO, TRUE, TRUE)) != zOK) + { + goto exit; + } + +exit: + return status; +} + +#if zLINUX && !defined(__KERNEL__) +/**************************************************************************** + * Find all of the segments in a pool and fill in their info. + *****************************************************************************/ +STATUS LNXPOOL_FillInPoolsSegments( + VirtInfo_s *virtInfo, + char *poolName) +{ + STATUS status; + object_handle_t deviceHandle; + int ccode; + handle_array_t *segments = NULL; + int i; + QUAD segOffset; + QUAD segSize; + utf8_t tempBuf[512]; + handle_object_info_t *deviceInfo; + handle_object_info_t *segmentInfo; + storage_object_info_t *diskInfo; + storage_object_info_t *segInfo; + extended_info_array_t *extendedInfo = NULL; + char realPoolName[512]; + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + syslog(LOG_DEBUG, "LNXPOOL_FillInPoolsSegments: Error opening evms: %s\n", strerror(ccode)); + return ccode; + } + + strcpy(realPoolName, EVMS_DEVICE_PATH); + strcat(realPoolName, poolName); + ccode = evmsGetChildrenByType(realPoolName, VOLUME, SEGMENT, &segments); + if (ccode != 0) + { + syslog(LOG_DEBUG, "evmDestroyObjectByName: Error getting handle from name: %s\n", strerror(ccode)); + status = ccode; + goto exit; + } + + if (segments != NULL) + { + for (i = 0; i < segments->count; i++) + { + // This is the pool we are looking for, so build the segment info tag. + if ((status = VIRT_AddResultTag(virtInfo, TAG_SEGMENT, FALSE, TRUE)) + != zOK) + { + goto exit; + } + + ccode = evmsGetSegmentsDevice(segments->handle[i], &deviceHandle); + if (ccode != 0) + { + goto closeTag; + } + + ZOS_evms_get_info(ccode, deviceHandle, &deviceInfo); + if (ccode != 0) + { + goto closeTag; + } + + diskInfo = &deviceInfo->info.disk; + + /* device name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_DEVICENAME, diskInfo->name, + FALSE)) != zOK) + { + goto closeTag; + } + + ZOS_evms_get_info(ccode, segments->handle[i], &segmentInfo); + if (ccode != 0) + { + goto closeTag; + } + + segInfo = &segmentInfo->info.segment; + + /* segment name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_SEGMENTNAME, segInfo->name, + FALSE)) != zOK) + { + goto closeTag; + } + + /* device id */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_DEVICEID, diskInfo->name, + FALSE)) != zOK) + { + goto closeTag; + } + + /* segment id */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_SEGMENTID, segInfo->name, + FALSE)) != zOK) + { + goto closeTag; + } + + ZOS_evms_get_extended_info(ccode, segments->handle[i], "Label", &extendedInfo); + if (ccode == 0) + { + /* partition label */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_LABEL, extendedInfo->info[0].value.s, + FALSE)) != zOK) + { + goto closeTag; + } + } + + /* segment offset and size */ + segOffset = segInfo->start; + segSize = segInfo->size * EVMS_VSECTOR_SIZE; + sprintf(tempBuf, + MSGNot("<"TAG_OFFSET">%llu<" + TAG_SIZE">%llu\n"), + segOffset, + segSize); + if ((status = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto closeTag; + } + +closeTag: + status = VIRT_AddResultTag(virtInfo, TAG_SEGMENT, TRUE, TRUE); + evms_free(extendedInfo); + extendedInfo = NULL; + } + } + +exit: + evms_free(segments); + evmsCloseEngine(); + return ccode; +} +#endif + +/**************************************************************************** + * Add the pool tag and all of its contents. + *****************************************************************************/ +STATUS AddPoolSegmentInfo( + VirtInfo_s *virtInfo, + char *poolName) +{ + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_SEGMENTINFO, FALSE, TRUE)) != zOK) + { + return status; + } + + +#if zLINUX && !defined(__KERNEL__) + LNXPOOL_FillInPoolsSegments(virtInfo, poolName); +#endif + + /* Add the closing tag */ + status = VIRT_AddResultTag(virtInfo, TAG_SEGMENTINFO, TRUE, TRUE); + + return status; +} + +/**************************************************************************** + * + * This function returns the attributes of a pool + * + ****************************************************************************/ +STATUS MNSS_ProcessGetPoolInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_BASICINFO, TR_OPTIONAL}, + {TAG_SALVAGE, TR_OPTIONAL}, + {TAG_ATTRIBUTES, TR_OPTIONAL}, + {TAG_VOLUMES, TR_OPTIONAL}, + {TAG_DELETEDVOLUMES, TR_OPTIONAL}, + {TAG_SEGMENTS, TR_OPTIONAL}, + {ATR_TYPE, TR_ATTRIBUTE | TR_OPTIONAL}, + {0} + }; + + enum + { + POOL_NAME = 0, + BASIC = 1, + SALVAGE = 2, + ATTRIBUTES = 3, + VOLUMES = 4, + DELETEDVOLUMES = 5, + SEGMENTS = 6, + TYPE = 7, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + STATUS status; + NINT errIndex; + BYTE path[zMAX_FULL_NAME]; + unicode_t uni_poolName[zMAX_COMPONENT_NAME]; + QUAD getInfoMask; + zInfo_s info; + NINT i; + + NINT infoBits = 0; + enum + { + BASIC_INFO = 0x0001, + SALVAGE_INFO = 0x0002, + ATTRIBUTES_INFO = 0x0004, + VOLUMES_INFO = 0x0008, + DELETEDVOLUMES_INFO = 0x0010, + SEGMENTS_INFO = 0x0020, + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Uppercase the pool name */ + for (i = 0; tagContent[POOL_NAME].content[i] != '\0'; i++) + { + tagContent[POOL_NAME].content[i] = + toupper(tagContent[POOL_NAME].content[i]); + } + + /* The old method of selecting what to return was a single tag that + * allowed one option to be selected (with all being one option). + * This has been augmented with a tag per option to allow other + * combinations than one or all - see the cases below this tag. */ + if (tagContent[TYPE].flags & TR_TAG_FOUND) + { + if (stricmp(tagContent[TYPE].content,"all") == 0) + { + infoBits = -1; + } + else if (stricmp(tagContent[TYPE].content,"basic") == 0) + { + infoBits |= BASIC_INFO; + } + else if (stricmp(tagContent[TYPE].content,"salvage") == 0) + { + infoBits |= SALVAGE_INFO; + } + else if (stricmp(tagContent[TYPE].content,"attributes") == 0) + { + infoBits |= ATTRIBUTES_INFO; + } + else if (stricmp(tagContent[TYPE].content,"volumes") == 0) + { + infoBits |= VOLUMES_INFO; + } + else if (stricmp(tagContent[TYPE].content,"deletedVolumes") == 0) + { + infoBits |= DELETEDVOLUMES_INFO; + } + else if (stricmp(tagContent[TYPE].content,"segments") == 0) + { + infoBits |= SEGMENTS_INFO; + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Invalid info type specified")); + goto exit; + } + } + + /* Allow individual options to be selected one at a time to create combinations. + * NB: Due to the need to support the previous functionality this actually results + * in obtaining the sum of both sets, based and individual item based */ + if (tagContent[BASIC].flags & TR_TAG_FOUND) + { + infoBits |= BASIC_INFO; + } + if (tagContent[SALVAGE].flags & TR_TAG_FOUND) + { + infoBits |= SALVAGE_INFO; + } + if (tagContent[ATTRIBUTES].flags & TR_TAG_FOUND) + { + infoBits |= ATTRIBUTES_INFO; + } + if (tagContent[VOLUMES].flags & TR_TAG_FOUND) + { + infoBits |= VOLUMES_INFO; + } + if (tagContent[DELETEDVOLUMES].flags & TR_TAG_FOUND) + { + infoBits |= DELETEDVOLUMES_INFO; + } + if (tagContent[SEGMENTS].flags & TR_TAG_FOUND) + { + infoBits |= SEGMENTS_INFO; + } + + /* + * If there has been no info requested then assume that the request is for + * all info. + */ + if (!infoBits) + { + infoBits = -1; + } + + // Change pool name to unicode. + if (utf2uni(tagContent[POOL_NAME].content, uni_poolName, + sizeof(uni_poolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_UNICODE_CONVERSION_ERROR, + MSGNot("Error converting pool name to unicode")); + goto exit; + } + + /* Get the file key. This is the key to the pool object in the + * NSS admin volumes directory. + */ + sprintf((char *)path, "%s%s", ADMIN_POOL_PATH, tagContent[POOL_NAME].content); + getInfoMask = zGET_TIMES_IN_SECS | zGET_IDS | zGET_POOL_INFO | + zGET_VOL_SALVAGE_INFO; + + if ((status = GetZInfo(path, getInfoMask, &info, &errIndex)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, ManageVolumeErrorMessages[errIndex]); + goto exit; + } + + /* Basic Volume Information */ + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto statusExit; + } + + /* Add the basic information */ + if (infoBits & BASIC_INFO) + { + if ((status = AddPoolBasicInfo(virtInfo, + tagContent[POOL_NAME].content, &info, uni_poolName)) != zOK) + { + goto statusExit; + } + } + + /* Add the salvage information */ + if (infoBits & SALVAGE_INFO) + { + if ((status = AddPoolSalvageInfo(virtInfo, &info)) != zOK) + { + goto statusExit; + } + } + + /* Add the attribute information */ + if (infoBits & ATTRIBUTES_INFO) + { + if ((status = AddPoolAttrInfo(virtInfo, &info)) != zOK) + { + goto statusExit; + } + } + + /* Add the volume information */ + if (infoBits & VOLUMES_INFO) + { + if ((status = AddPoolVolumeInfo(virtInfo, uni_poolName)) != zOK) + { + goto statusExit; + } + } + + /* Add the deletedVolume information */ + if (infoBits & DELETEDVOLUMES_INFO) + { + if ((status = AddPoolDeletedVolumeInfo(virtInfo, uni_poolName)) != zOK) + { + goto statusExit; + } + } + + /* Add the segment information */ + if (infoBits & SEGMENTS_INFO) + { + if ((status = AddPoolSegmentInfo(virtInfo, tagContent[POOL_NAME].content)) != zOK) + { + goto statusExit; + } + } + + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE)) != zOK) + { + goto statusExit; + } + +exit: + return zOK; + +/*===========================================================================*/ +statusExit: + return(status); +} +#endif +#if zLINUX && !defined(__KERNEL__) + +static STATUS canUnMount(BOOL openEVMSEngine, utf8_t *poolName) +{ + STATUS status = zOK; + long ccode; + char realPoolName[512]; + object_handle_t handle; + + if(openEVMSEngine) + { + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if(ccode != 0) + { + return zFAILURE; + } + } + strcpy(realPoolName, EVMS_DEVICE_PATH); + strcat(realPoolName, poolName); + + ZOS_evms_get_object_handle_for_name(ccode, VOLUME, realPoolName, &handle); + if(ccode != 0) + { + status = ccode; + goto exit; + } + ZOS_evms_can_unmkfs(ccode, handle); + if(ccode != 0) + { + if(ccode != EBUSY) + { + status = ccode; + } + + } + +exit: + if(openEVMSEngine) + { + evmsCloseEngine(); + } + + return status; +} +#endif + +#if !defined(__KERNEL__) +STATUS removePoolSimple( + utf8_t *tagName, + VirtInfo_s *virtInfo, + BOOL openEVMSEngine, + utf8_t *poolName, + BOOL ignoreShared) +{ + STATUS status = zFAILURE; + STATUS ndsStatus = zOK; + LONG ccode; + BOOL errDeletePartition = FALSE; + STATUS retCode = 0; + BOOL isShared; + POOLSNAP_TYPE snapshotType; + + ASSERT_MPKNSS_LOCK(); + + /* + * If the pool is on a shared device and clustering is not + * running and we are not overriding the shared protection then + * quit. + */ + ccode = LINUX_GetPoolSharedState(openEVMSEngine, poolName, &isShared); + if (ccode != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Failed to determine share state of device hosting the pool")); + goto exit; + } + if (!ignoreShared && + !COMN_ClusterSoftwareIsCheckingPoolStateChanges() && + isShared) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NCS_CVB_NOT_REGISTERED, + MSGNot("CVB has not registered for pool events")); + goto exit; + } + + ccode = canUnMount(openEVMSEngine, poolName); + if(ccode != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Can not remove the pool")); + goto exit; + } + ccode = LINUX_GetPoolSnapshotType(openEVMSEngine, poolName, &snapshotType); + if(ccode != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Failed to determine the snapshot state of the pool")); + goto exit; + } + + if(snapshotType == POOL_SNAPSHOTORIGIN) + { + ccode = zERR_NOT_SUPPORTED; + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Operation not supported. Snapshots exist for this pool.")); + goto exit; + } + + MNDS_RemovePoolVolumes(virtInfo, poolName); + ndsStatus = MNDS_DestroyPoolDSObjects(virtInfo, + poolName, TRUE); + + ccode = MNSS_RemovePool(openEVMSEngine, poolName); + if (ccode != 0) + { + syslog(LOG_DEBUG, "Error %d removing a pool\n", ccode); + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error removing the pool")); + goto exit; + } + if(errDeletePartition == TRUE) + { + MNSS_ReturnResult(virtInfo, tagName, retCode, + MSGNot("Remove pool - failure to remove pool segments")); + goto exit; + } + + if(ndsStatus != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, ndsStatus, + MSGNot("Remove pool - failure to remove NDS object")); + status = zOK; + goto exit; + } + + status = zOK; + +exit: + return status; +} + +/**************************************************************************** + * + * This function removes a pool - delete a pool, its NDS object, all volumes + * owned by this pool, and all the partitions used by this pool + * + ****************************************************************************/ +STATUS MNSS_ProcessRemovePoolSimple( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_IGNORESHARESTATE, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + POOL_NAME = 0, + IGNORE_SHARE_STATE = 1 + }; + + NINT i; + STATUS status = zOK; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* + * Upper case the name. It is done before the unicode conversion because + * we use both the unicode and utf8 versions. + */ + for (i = 0; tagContent[POOL_NAME].content[i] != '\0'; i++) + { + tagContent[POOL_NAME].content[i] = + toupper(tagContent[POOL_NAME].content[i]); + } + + status = removePoolSimple(tagName, virtInfo, TRUE, + tagContent[POOL_NAME].content, + tagContent[IGNORE_SHARE_STATE].flags & TR_TAG_FOUND); + + if (status == zOK) + { + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + } + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function renames a pool. + * + ****************************************************************************/ +STATUS MNSS_ProcessRenamePool( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_NEWPOOLNAME, TR_CONTENT_REQUIRED}, + {TAG_NEWNDSNAME, TR_OPTIONAL}, + {TAG_DONTRENAMENDSOBJECT, TR_OPTIONAL}, + {TAG_IGNORESHARESTATE, TR_OPTIONAL}, + {0} + }; + + enum + { + POOL_NAME = 0, + NEW_POOL_NAME = 1, + NEW_NDS_NAME = 2, + DONT_RENAME_NDS_OBJECT = 3, + IGNORE_SHARE_STATE = 4, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + unicode_t uni_poolName[zMAX_COMPONENT_NAME]; + STATUS status; + NINT i; + utf8_t container[MAX_DN_CHARS]; + utf8_t object[MAX_DN_CHARS]; + utf8_t *errorString; + UserID_t guid; + BOOL shared; +#if zLINUX + int ccode; + utf8_t oldName[512]; + POOLSNAP_TYPE snapshotType; +#endif + + ASSERT_MPKNSS_LOCK(); + + syslog(LOG_NOTICE, "Pool rename XML request\n"); + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Upper case the names */ + for (i = 0; tagContent[POOL_NAME].content[i] != '\0'; i++) + { + tagContent[POOL_NAME].content[i] = + toupper(tagContent[POOL_NAME].content[i]); + } + for (i = 0; tagContent[NEW_POOL_NAME].content[i] != '\0'; i++) + { + tagContent[NEW_POOL_NAME].content[i] = + toupper(tagContent[NEW_POOL_NAME].content[i]); + } + + /* pool name to unicode */ + if (utf2uni(tagContent[NEW_POOL_NAME].content, uni_poolName, + sizeof(uni_poolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting pool name to unicode")); + goto exit; + } + + if ((status = LB_PoolNameAcceptable(uni_poolName)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid target pool name")); + goto exit; + } + + /* + * If the pool is either a snapshot or it has snapshots, do not + * allow renaming. This will be removed once the support is added. + */ +#if zLINUX + ccode = LINUX_GetPoolSnapshotType(TRUE, tagContent[POOL_NAME].content, &snapshotType); + if(ccode != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Failed to determine the snapshot state of the pool")); + goto exit; + } + + if(snapshotType == POOL_SNAPSHOTORIGIN) + { + ccode = zERR_NOT_SUPPORTED; + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Operation not supported. Snapshots exist for this pool.")); + goto exit; + } + else if (snapshotType == POOL_SNAPSHOT) + { + ccode = zERR_NOT_SUPPORTED; + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Operation not supported on the snapshot pool.")); + goto exit; + } +#endif + + /* + * If the pool is on a shared device and clustering is not + * running and we are not overriding the shared protection then + * quit. + */ +#if zLINUX + ccode = LINUX_GetPoolSharedState(TRUE, tagContent[POOL_NAME].content, &shared); +#endif + if (ccode != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Failed to determine share state of device hosting the pool")); + goto exit; + } + if (!(tagContent[IGNORE_SHARE_STATE].flags & TR_TAG_FOUND) && + !COMN_ClusterSoftwareIsCheckingPoolStateChanges() && + shared) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NCS_CVB_NOT_REGISTERED, + MSGNot("CVB has not registered for pool events")); + goto exit; + } + + /* Do this before EVMS unloads the pool. We can only + get the Pool's eDIR ID from a activate pool. When + EVMS reloads the pool the pool may or may not + be activate when the load is done. Depends on + load time policies which by default activates + LOCAL pools and does NOT activate SHARED pools. */ + if (!(tagContent[DONT_RENAME_NDS_OBJECT].flags & TR_TAG_FOUND)) + { + if (!(tagContent[NEW_NDS_NAME].flags & TR_TAG_FOUND)) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Missing new NDS name")); + goto exit; + } + if ((status = MNSS_GetPoolNDSName(tagContent[POOL_NAME].content, + object, container, &guid, &errorString)) != zOK) + { + if ((status = MNDS_GetServerNameFromNDS(object, container)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error Getting Server Name from NDS")); + goto exit; + } + strcat(object,"_"); + strcat(object,tagContent[POOL_NAME].content); + strcat(object,"_POOL"); + syslog(LOG_NOTICE, " Pool rename (current eDIR Name) - %s\n", object); + } + else + { + syslog(LOG_NOTICE, " Pool rename (current eDIR Name from eDIR GUID) - %s\n", object); + } + } + + /* + * Rename the actual pool + */ +#if zLINUX + strcpy(oldName, EVMS_DEVICE_PATH); + strcat(oldName, tagContent[POOL_NAME].content); + ccode = evmsRenameObject(oldName, tagContent[NEW_POOL_NAME].content, + VOLUME, TRUE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error renaming pool")); + goto exit; + } +#endif + + /* + * Rename the NDS object if requested + * Do this last, as lack of NDS object should not cause the operation to fail + */ + if (!(tagContent[DONT_RENAME_NDS_OBJECT].flags & TR_TAG_FOUND)) + { + if ((status = MNDS_RenamePoolInNDS(virtInfo, container, object, + tagContent[POOL_NAME].content, + tagContent[NEW_NDS_NAME].content, + tagContent[NEW_POOL_NAME].content)) != zOK) + { + syslog(LOG_NOTICE, " Pool rename (eDIR rename failed) - %s\n", container); + syslog(LOG_NOTICE, " Pool rename (eDIR rename failed) - %s\n", object); + syslog(LOG_NOTICE, " Pool rename (eDIR rename failed) - %s\n", tagContent[POOL_NAME].content); + syslog(LOG_NOTICE, " Pool rename (eDIR rename failed) - %s\n", tagContent[NEW_NDS_NAME].content); + syslog(LOG_NOTICE, " Pool rename (eDIR rename failed) - %s\n", tagContent[NEW_POOL_NAME].content); + syslog(LOG_NOTICE, " Pool rename (eDIR rename failed) - %d\n", status); + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error renaming pool in NDS")); + goto exit; + } + } + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + goto exit; /* The release was done by VOL_commandFunction */ + +exit: + return zOK; +} +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +/**************************************************************************** + * + * This function increases the size of a pool: In this version, the user + * select the device and how much to use in this device to create the pool, + * instead of selecting the partition. + * + ****************************************************************************/ +STATUS MNSS_ProcessExpandPoolSimple( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + NINT i; + utf8_t *start; + XML_ElementInfo_s addPoolDeviceInfoElement; + QUAD selectedSize; +#if zLINUX + int ccode; + BOOL engineOpen = FALSE; + EvmsStorageArray_s *freeSegments = NULL; + handle_array_t *partitionList = NULL; + QUAD freeSpaceSize; +#endif + + const TagRequest_s tags[] = + { + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_DEVICES, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + POOL_NAME = 0, + DEVICES = 1, + }; + + /* Tags for parsing */ + const TagRequest_s addPoolDeviceInfoTags[] = + { + {TAG_OBJECTID, TR_CONTENT_REQUIRED}, + {TAG_SIZE, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s addPoolDeviceInfoTagContent[NELEMS(addPoolDeviceInfoTags)-1]; + + enum + { + OBJECTID = 0, + SIZE = 1, + }; + + ASSERT_MPKNSS_LOCK(); +//printf("Entering expand processing\n"); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* + * Upper case the name. + */ + for (i = 0; tagContent[POOL_NAME].content[i] != '\0'; i++) + { + tagContent[POOL_NAME].content[i] = + toupper(tagContent[POOL_NAME].content[i]); + } + +#if zLINUX + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to open the EVMS engine")); + goto exit; + } + engineOpen = TRUE; +#endif + +// get all devices selected + start = tagContent[DEVICES].element.dataStart; + for(;;) + { + /* find the next device */ + if (XML_GetTagElement(TAG_ADDPOOLDEVICEINFO, start, + tagContent[DEVICES].element.dataEnd, &addPoolDeviceInfoElement) != zOK) + { + break; /* we cannot find anymore devices */ + } + + if ((status = MNSS_GetTagContents(virtInfo, tagName, &addPoolDeviceInfoElement, + addPoolDeviceInfoTags, addPoolDeviceInfoTagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + selectedSize = atoq(addPoolDeviceInfoTagContent[SIZE].content); +#if zLINUX +//printf("Get device free segments\n"); + ccode = evmsGetDeviceFreeSegments( + addPoolDeviceInfoTagContent[OBJECTID].content, &freeSegments, + &freeSpaceSize); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_UNABLE_TO_GET_EVMS_SEGMENTS, + MSGNot("Error getting enough available evms partition space to satisfy request")); + goto exit; + } + +//{ +// int i; +// for (i = 0; i < freeSegments->count; i++) +// { +//printf("====Free segment(%d) handle=%d size=%llu\n", i, freeSegments->entry[i].handle, freeSegments->entry[i].size); +// syslog(LOG_DEBUG, "====Free segment(%d) handle=%d size=%llu\n", i, freeSegments->entry[i].handle, freeSegments->entry[i].size); +// } +//} + + /* Verify that we got pool segments */ + if (freeSpaceSize < selectedSize || freeSegments->count == 0) + { + status = zERR_UNABLE_TO_GET_ENOUGH_SIZE; + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to get enough pool size")); + goto exit; + } + + status = LNXPOOL_BuildSegmentList(freeSegments, selectedSize, + &partitionList); + if(status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_UNABLE_TO_GET_EVMS_SEGMENTS, + MSGNot("Error getting device free space list")); + goto exit; + } +//{ +// int i; +// for (i = 0; i < partitionList->count; i++) +// { +//printf("====Partition list(%d) handle=%d\n", i, partitionList->handle[i]); +// syslog(LOG_DEBUG, "====Partition list(%d) handle=%d\n", i, partitionList->handle[i]); +// } +//} + + free(freeSegments); + freeSegments = NULL; +#endif + start = addPoolDeviceInfoTagContent[SIZE].element.elementEnd; + } + +#if zLINUX + status = LNXPOOL_ExpandPool(partitionList, tagContent[POOL_NAME].content); + if(status != zOK) + { + if(status == zERR_NOT_SUPPORTED) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Expansion of pool not possible now")); + } + else + { + status = zERR_UNABLE_TO_GET_ENOUGH_SIZE; + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to expand pool")); + } + goto exit; + } +#endif + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: +#if zLINUX + if (engineOpen) + { + evmsCloseEngine(); + engineOpen = FALSE; + } + + free(freeSegments); + free(partitionList); +#endif + + return zOK; +} +#endif + +/**************************************************************************** + * + * This function gets the devices used by a pool. + * + ****************************************************************************/ +STATUS MNSS_ProcessGetPoolDevices(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + POOL_NAME = 0, + }; + + NINT i; + STATUS status; + + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* + * Upper case the name. It is done before the unicode conversion because + * we use both the unicode and utf8 versions. + */ + for (i = 0; tagContent[POOL_NAME].content[i] != '\0'; i++) + { + tagContent[POOL_NAME].content[i] = + toupper(tagContent[POOL_NAME].content[i]); + } + +#if zLINUX && !defined(__KERNEL__) + LNXPOOL_getPoolDevices(tagName, virtInfo, tagContent[POOL_NAME].content); +#endif + +exit: + + return zOK; +} + + +/**************************************************************************** + * + * This function gets the NDS name for a pool. + * + ****************************************************************************/ +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +STATUS MNSS_GetPoolNDSName( + utf8_t *poolName, + utf8_t *ndsPoolName, + utf8_t *ndsContainer, + UserID_t *poolNameGUID, + utf8_t **errorString) +{ + STATUS status; + utf8_t objectName[MAX_DN_CHARS]; + NINT i; + VolumeID_t poolID; + + *ndsPoolName = '\0'; + *ndsContainer = '\0'; + + /* Upper case the name */ + for (i = 0; poolName[i] != '\0'; i++) + { + poolName[i] = toupper(poolName[i]); + } + + if ((status = DoesPoolExist(poolName, &poolID, poolNameGUID)) != zOK) + { + *errorString = MSGNot("Error finding pool in NSS"); + return status; + } + + if ((status = MNSS_GetNDSNameFromGUID(NULL, poolNameGUID, objectName)) + != zOK) + { +// syslog(LOG_NOTICE, "MNSS_GetNDSNameFromGUID returned error %d\n", status); + *errorString = MSGNot("Error converting GUID to name"); + return status; + } + + LB_ParseDSObjectName(objectName, ndsContainer, ndsPoolName); + return zOK; +} +#endif + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +/**************************************************************************** + * + * This function process a request to get the NDS name for a pool. + * + ****************************************************************************/ +STATUS MNSS_ProcessGetPoolNDSName( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + TagContent_s tagContent[1]; + const TagRequest_s tags[] = + { + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + POOL_NAME = 0, + }; + + STATUS status; + utf8_t container[MAX_DN_CHARS]; + utf8_t object[MAX_DN_CHARS]; + utf8_t *errorString; + UserID_t guid; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + if ((status = MNSS_GetPoolNDSName(tagContent[POOL_NAME].content, + object, container, &guid, &errorString)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, errorString); + goto exit; + } + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + + if ((status = VIRT_AddResultElement(virtInfo, TAG_NDSNAME, object, + FALSE)) != zOK) + { + return status; + } + + if ((status = VIRT_AddResultElement(virtInfo, TAG_CONTEXT, container, + FALSE)) != zOK) + { + return status; + } + + MNSS_BuildResult(virtInfo, 0, XML_SUCCESS); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + return zOK; +} +#endif + + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +STATUS ChangePoolState(unicode_t *uniPoolName, NINT newPoolState, NINT mode) +{ + STATUS status; + GeneralMsg_s genMsg; + Pool_s *pool; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + pool = COMN_PoolNameLookup(&genMsg, uniPoolName, FALSE, NULL); + if (pool == NULL) + { + status = GetErrno(&genMsg); +// MNSS_ReturnResult(virtInfo, tagName, status, +// MSGNot("Error finding pool in NSS")); + return status; + } + + if ((status = COMN_ChangePoolStateByName(&genMsg, uniPoolName, + newPoolState, mode, 0)) != zOK) + { + status = GetErrno(&genMsg); +// MNSS_ReturnResult(virtInfo, tagName, status, +// MSGNot("Pool state was not changed successfully")); + } + COMN_Release(&pool); + return status; +} + +NINT GetPoolState(unicode_t *uniPoolName) +{ + NINT poolState = -1; + GeneralMsg_s genMsg; + Pool_s *pool; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + pool = COMN_PoolNameLookup(&genMsg, uniPoolName, FALSE, NULL); + if (pool != NULL) + { + poolState = pool->POOLstate; + COMN_Release(&pool); + } + + return poolState; +} +#endif + + +/**************************************************************************** + * + * This function modifies the state of a pool. + * + ****************************************************************************/ +#if zLINUX && !defined(__KERNEL__) +STATUS MNSS_ProcessModifyPoolState( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_POOLSTATE, TR_CONTENT_REQUIRED}, + {TAG_IGNORESHARESTATE, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + POOL_NAME = 0, + POOL_STATE = 1, + IGNORE_SHARE_STATE = 2, + }; + + unicode_t uni_poolName[zMAX_COMPONENT_NAME]; + NINT newPoolState; + STATUS status; + NINT mode; + NINT i; + BOOL shared = FALSE; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Upper case the names */ + for (i = 0; tagContent[POOL_NAME].content[i] != '\0'; i++) + { + tagContent[POOL_NAME].content[i] = + toupper(tagContent[POOL_NAME].content[i]); + } + + /* pool name to unicode */ + if (utf2uni(tagContent[POOL_NAME].content, uni_poolName, + sizeof(uni_poolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting pool name to unicode")); + goto exit; + } + + if (strcmp(tagContent[POOL_STATE].content, MSGNot("active")) == 0) + { + newPoolState = zVOLSTATE_ACTIVE; + } + else if (strcmp(tagContent[POOL_STATE].content, MSGNot("deactive")) == 0) + { + newPoolState = zVOLSTATE_DEACTIVE; + } + else if (strcmp(tagContent[POOL_STATE].content, MSGNot("maintenance")) == 0) + { + newPoolState = zVOLSTATE_MAINTENANCE; + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Unsupported pool state value")); + goto exit; + } + + status = LINUX_GetPoolSharedState(TRUE, tagContent[POOL_NAME].content, &shared); + if (status != zOK) + { + /* Ignore the error and proceed further */ + shared = FALSE; + status = zOK; + } + + /* + * For cluster volumes, remove the mount point folder as well + * as cluster pool could be deleted from other nodes as well + * and we don't want to leave stale entries in other nods. + */ + if(shared) + { + (void) DismountAndRemovePoolVolumesEntries(tagContent[POOL_NAME].content, TRUE); + } + else + { + (void) DismountAndRemovePoolVolumesEntries(tagContent[POOL_NAME].content, FALSE); + } + + mode = VOLMODE_VERBOSE; + if (tagContent[IGNORE_SHARE_STATE].flags & TR_TAG_FOUND) + { + mode |= VOLMODE_OVERRIDE_SHARED; + } + if ((status = ChangePoolState(uni_poolName, newPoolState, mode)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Pool state was not changed successfully")); + goto exit; + } + + if (GetPoolState(uni_poolName) != newPoolState) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Pool state was not changed successfully")); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + +exit: + return zOK; +} +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +/**************************************************************************** + * This function gets vol info on a given LSS. The info we get is about + * whether or not the LSS supports external creates of volumes, and + * information about its supported/default/changable features for volumes + *****************************************************************************/ +STATUS MNSS_ProcessGetLSSVolumeInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; +// LSSInfo_s lssInfo; + QUAD volSupportedFeatures; + QUAD volDefaultEnabledFeatures; + QUAD volChangableFeatures; + + LONG lssID; + + const TagRequest_s tags[] = + { + {TAG_LSSNAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + LSS_NAME = 0, + }; + + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto statusExit; + } + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto statusExit; + } + + /* LSS Name */ + if(stricmp(tagContent[LSS_NAME].content, MSGNot("ZLSS")) == 0) + { + lssID = zLSS_ID_ZLSS; + } + else if(stricmp(tagContent[LSS_NAME].content, MSGNot("CD9660")) == 0) + { + lssID = zLSS_ID_ISO9660; + } + else if(stricmp(tagContent[LSS_NAME].content, MSGNot("CDHFS")) == 0) + { + lssID = zLSS_ID_HFSCD; + } + else if(stricmp(tagContent[LSS_NAME].content, MSGNot("CDUDF")) == 0) + { + lssID = zLSS_ID_UDFCD; + } + else if(stricmp(tagContent[LSS_NAME].content, MSGNot("DOSFAT")) == 0) + { + lssID = zLSS_ID_FAT; + } + else if(stricmp(tagContent[LSS_NAME].content, MSGNot("DOSFAT32")) == 0) + { + lssID = zLSS_ID_FAT32; + } + else + { + lssID = zLSS_ID_INVALID; + } + +// if((status = GetLSSFeatures(lssID, (BYTE*)(&lssInfo))) != zOK) + if((status = GetLSSFeatures(lssID, &volSupportedFeatures, &volDefaultEnabledFeatures, &volChangableFeatures)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unable to acquire the LSS features list")); + goto statusExit; + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_LSSVOLUMEINFO, FALSE, TRUE)) != zOK) + { + goto statusExit; + } + + /* Vol supported features */ + if ((status = FillVolAttributeInfo(virtInfo, TAG_VOLSUPPORTEDFEATURES, + TRUE, volSupportedFeatures, 0)) != zOK) + { + goto statusExit; + } + + /* Vol default features */ + if ((status = FillVolAttributeInfo(virtInfo, TAG_VOLDEFAULTFEATURES, + TRUE, volDefaultEnabledFeatures, 0)) != zOK) + { + goto statusExit; + } + + /* Vol changeable features */ + if ((status = FillVolAttributeInfo(virtInfo, TAG_VOLCHANGEABLEFEATURES, + TRUE, volChangableFeatures, 0)) != zOK) + { + goto statusExit; + } + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_LSSVOLUMEINFO, TRUE, TRUE)) != zOK) + { + goto statusExit; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE)) != zOK) + { + goto statusExit; + } + + return(zOK); + +/*===========================================================================*/ +statusExit: + return(status); +} + +/**************************************************************************** + * + * This function, given a physical pool name to be created, returns default + * names for the pool NDS object and the pool virtualServer object. + * + ****************************************************************************/ +STATUS MNSS_ProcessGetDefaultClusterNames( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + POOL_NAME = 0, + }; + + STATUS status; + NINT idx; + utf8_t virtualServerName[zMAX_COMPONENT_NAME]; + utf8_t cifsVirtualServerName[MAX_CIFS_VIRTUAL_SERVER_NAME+1]; + utf8_t ndsName[zMAX_COMPONENT_NAME]; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + goto statusExit; + } + + /* Upper case the name. */ + for (idx = 0; tagContent[POOL_NAME].content[idx] != '\0'; idx++) + { + tagContent[POOL_NAME].content[idx] = + toupper(tagContent[POOL_NAME].content[idx]); + } + tagContent[POOL_NAME].content[idx] = '\0'; + + /* First, try to use the clustering software to get the default names. + * If that fails, we will generate our own using the NDS server name. + */ + status = NWCLSTR_PoolNames((BYTE *)tagContent[POOL_NAME].content, + (BYTE *)ndsName, (BYTE *)virtualServerName, (BYTE *)cifsVirtualServerName); + if (status != CLSTR_OK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Clustering software failed to return default names")); + goto exit; + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto statusExit; + } + + /* pool name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_POOLNAME, + tagContent[POOL_NAME].content, FALSE)) != zOK) + { + goto statusExit; + } + + /* NDS Name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_NDSNAME, + ndsName, FALSE)) != zOK) + { + goto statusExit; + } + + /* Virtual Server Name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_VIRTUALSERVERNAME, + virtualServerName, FALSE)) != zOK) + { + goto statusExit; + } + + /* Virtual Server Name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_CIFSVIRTUALSERVERNAME, + cifsVirtualServerName, FALSE)) != zOK) + { + goto statusExit; + } + + /* Add a result tag */ + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + return zOK; + +/*===========================================================================*/ +statusExit: + return(status); +} +#endif + +#if (zLINUX && !defined(__KERNEL__)) +/***************************************************************************** + * This function Add pool snap shot + *****************************************************************************/ +STATUS MNSS_ProcessAddPoolSnapshot( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_FREESPACEID, TR_CONTENT_REQUIRED}, + {TAG_NUMSECTORS, TR_CONTENT_REQUIRED}, + {TAG_SNAPNAME, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + POOL_NAME = 0, + FREE_SPACE = 1, + NUM_SECTORS = 2, + SNAP_NAME = 3, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + NINT i, j; + BOOL engineOpen = FALSE, volShared=FALSE, freeShared=FALSE; + BOOL freeMirrored = FALSE; + STATUS status; + LONG ccode; + char ch, volName[128], mountPoint[128], mountOptions[80]; + object_handle_t volhandle, snaphandle; + plugin_handle_t pluginHandle; + plugin_handle_t FSMplugin; + handle_array_t *outputObjects = NULL; + handle_array_t *input = NULL; + option_array_t *options = NULL; + handle_object_info_t *info = NULL; + handle_object_info_t *FSMinfo = NULL; + EvmsStorageArray_s *freeSegments = NULL; + QUAD freeSpaceSize, rtnSize; + unicode_t uni_snapName[zMAX_COMPONENT_NAME]; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to open the EVMS engine")); + goto exit; + } + + engineOpen = TRUE; + + /* Make sure the pool name is a valid volume */ + ZOS_evms_get_object_handle_for_name(ccode, VOLUME, + tagContent[POOL_NAME].content, + &volhandle); + if (ccode != 0) + { + syslog(LOG_INFO, "Bad volume name %s \n", tagContent[POOL_NAME].content); + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_NAME, + MSGNot("Invalid volume/pool name")); + goto exit; + } + + ZOS_evms_get_info(ccode, volhandle, &info); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, + MSGNot("Error getting volume info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + + if (info->info.volume.flags & VOLFLAG_CLUSTER_SHARED) + { + volShared = TRUE; + } + + FSMplugin = info->info.volume.file_system_manager; + + ZOS_evms_get_info(ccode, FSMplugin, &FSMinfo); + + if ((FSMinfo != NULL) && + (strcmp(FSMinfo->info.plugin.short_name, PLUGIN_NSSFS) == 0)) + { + /* Uppercase the snap name for NSS pools */ + for (i = 0; tagContent[SNAP_NAME].content[i] != '\0'; i++) + { + tagContent[SNAP_NAME].content[i] = + toupper(tagContent[SNAP_NAME].content[i]); + } + + /* Snapshot name to unicode */ + if (utf2uni(tagContent[SNAP_NAME].content, uni_snapName, + sizeof(uni_snapName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting snapshot name to unicode")); + goto exit; + } + + if ((status = LB_PoolNameAcceptable(uni_snapName)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid snapshot name")); + goto exit; + } + } + + + ZOS_evms_free(info); + info = NULL; + + /* Make sure an object does NOT already exist for specified snapshot */ + strcpy(volName, EVMS_DEVICE_PATH); + strcat(volName, tagContent[SNAP_NAME].content); + ZOS_evms_get_object_handle_for_name(ccode, VOLUME, + volName, &volhandle); + + if (ccode == 0) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_NAME, + MSGNot("Invalid snapshot name")); + goto exit; + } + + /* Get the handle for the snap partition */ + ZOS_evms_get_object_handle_for_name(ccode, + (DISK | SEGMENT | REGION | EVMS_OBJECT | CONTAINER), + tagContent[FREE_SPACE].content, &snaphandle); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_NAME, + MSGNot("Invalid object for snapshot")); + goto exit; + } + + /* If the object is free space, create a partition from it */ + ZOS_evms_get_info(ccode, snaphandle, &info); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, + MSGNot("Error getting freespace info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + + freeSpaceSize = strtouq(tagContent[NUM_SECTORS].content, NULL, 0) + 32; + /* If a disk/region type, find a freespace segment that is big enough */ + if (info->type == DISK || info->type == REGION) + { + if (info->type == DISK && + (info->info.disk.flags & SOFLAG_CLUSTER_SHARED)) + { + freeShared = TRUE; + } + else if (info->type == REGION && + (info->info.region.flags & SOFLAG_CLUSTER_SHARED)) + { + freeShared = TRUE; + } + + if (volShared != freeShared) + { + MNSS_BuildResult(virtInfo, -1, + MSGNot("Error: Volume/pool shared state must match freespace shared state")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + + ccode = evmsGetDeviceFreeSegments( + tagContent[FREE_SPACE].content, &freeSegments, + &rtnSize); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_UNABLE_TO_GET_EVMS_SEGMENTS, + MSGNot("Error getting enough available evms partition space to satisfy request")); + goto exit; + } + + /* Change sectors to bytes */ + rtnSize = freeSpaceSize * EVMS_VSECTOR_SIZE; + + for (i=0; icount; i++) + { + if (freeSegments->entry[i].size >= rtnSize) + { + snaphandle = freeSegments->entry[i].handle; + if(freeSegments->entry[i].isMirrored) + { + freeMirrored = TRUE; + } + ZOS_evms_free(info); + ZOS_evms_get_info(ccode, snaphandle, &info); +// syslog(LOG_INFO, "Found freespace %s\n", info->info.segment.name); + break; + } + } + + free(freeSegments); + } + else if ((info->type != SEGMENT) || + (info->info.segment.data_type != FREE_SPACE_TYPE)) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Invalid free space parameter")); + goto exit; + } + else + { + if (info->info.segment.flags & SOFLAG_CLUSTER_SHARED) + { + freeShared = TRUE; + } + + if (volShared != freeShared) + { + MNSS_BuildResult(virtInfo, -1, + MSGNot("Error: Volume/pool shared state must match freespace shared state")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + } + + pluginHandle = info->info.segment.plugin; + ZOS_evms_free(info); + info = NULL; + + if(freeMirrored) + { + /* For mirrored devices, don't create the partition + and instead use the device handle itself. + */ + } + else + { + /* Create the partition */ + ZOS_evms_get_info(ccode, pluginHandle, &info); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, + MSGNot("Error getting plugin info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + + // syslog(LOG_INFO, "Plugin name = %s\n", info->info.plugin.short_name); + if (strcmp(info->info.plugin.short_name, "DosSegMgr") == 0) + { + if ((ccode = evmsAddDosPartition(pluginHandle, + snaphandle, + freeSpaceSize, + 0x83, &snaphandle)) != 0) + { + ccode = evmsAddPartition(snaphandle, + freeSpaceSize, + (BYTE*)"Traditional", + NULL, &snaphandle); + } + } + else + { + ccode = evmsAddPartition(snaphandle, + freeSpaceSize, + (BYTE*)NSS_PARTITION_NAME_STRING, // NSS as the partition type. + NULL, &snaphandle); + } + + // syslog(LOG_INFO, "Add partition completed = %d with handle %d\n", ccode, snaphandle); + ZOS_evms_free(info); + info = NULL; + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to create snapshot partition")); + goto exit; + } + } + + ZOS_evms_get_plugin_by_name(ccode, PLUGIN_SNAPSHOT, &pluginHandle); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to get Snapshot plugin handle")); + goto exit; + } + +// syslog(LOG_INFO, "Got Snapshot plugin handle = %d\n", pluginHandle); + input = malloc(sizeof(handle_array_t) + sizeof(object_handle_t)); + if (input == NULL) + { + ccode = zERR_NO_MEMORY; + goto exit; + } + input->count = 1; + input->handle[0] = snaphandle; + + i=2; /* number of options */ + options = malloc(sizeof(option_array_t) + + (sizeof(key_value_pair_t) * i)); + if (!options) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Unable to allocate memory")); + goto exit; + } + options->count = i; + options->option[0].number = 0; + options->option[0].is_number_based = TRUE; + options->option[0].type = EVMS_Type_String; + options->option[0].flags = 0; + options->option[0].value.s = tagContent[POOL_NAME].content; + options->option[1].number = 1; + options->option[1].is_number_based = TRUE; + options->option[1].type = EVMS_Type_String; + options->option[1].flags = 0; + options->option[1].value.s = tagContent[SNAP_NAME].content; +// options->option[2].number = 2; +// options->option[2].is_number_based = TRUE; +// options->option[2].type = EVMS_Type_Unsigned_Int32; +// options->option[2].flags = 0; +// options->option[2].value.ui32 = 4096; +// options->option[3].number = 3; +// options->option[3].is_number_based = TRUE; +// options->option[3].type = EVMS_Type_Boolean; +// options->option[3].flags = 0; +// options->option[3].value.b = TRUE; + /* + * Create the pool snapshot + */ +// syslog(LOG_INFO, "Creating the snapshot\n"); + ZOS_evms_create(ccode, pluginHandle, input, options, &outputObjects); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error creating snapshot")); + goto exit; + } + + if ((outputObjects == NULL) || (outputObjects->count < 1)) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Error getting snapshot object")); + goto exit; + } + +// ZOS_evms_commit_changes(ccode); +// if (ccode != 0) +// { +// MNSS_ReturnResult(virtInfo, tagName, ccode, +// MSGNot("Error committing snapshot")); +// goto exit; +// } + + /* Find the right handle */ + for (i = 0; i < outputObjects->count; i++) + { + ZOS_evms_get_info(ccode, outputObjects->handle[i], &info); + if ((ccode == 0) && (strcmp(info->info.object.name, tagContent[SNAP_NAME].content) == 0)) + { + break; + } + + ZOS_evms_free(info); + info = NULL; + } + + if (i == outputObjects->count) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Error finding new snapshot object")); + goto exit; + } + +// syslog(LOG_INFO, "Creating the volume\n"); + /* Create an EVMS volume on the snapahot */ + ZOS_evms_create_volume(ccode, outputObjects->handle[i], tagContent[SNAP_NAME].content); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error creating snapshot volume")); + /* + * Destroy the snapshot object if the volume creation fails. + */ + evmsDestroyObjectByHandle(outputObjects->handle[i], 0); + goto exit; + } + + ZOS_evms_commit_changes(ccode); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error committing snapshot volume")); + /* + * Destroy the snapshot object if evms commit fails. + */ + evmsDestroyObjectByName(volName, VOLUME, 0, 0); + goto exit; + } + +// syslog(LOG_INFO, "Get the volume\n"); + /* Now mount it with the snapshot option */ + ZOS_evms_get_object_handle_for_name(ccode, VOLUME, + volName, &volhandle); + + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error getting new snapshot volume")); + goto exit; + } + +// for (i = 0; tagContent[SNAP_NAME].content[i] != '\0'; i++) +// { +// tagContent[SNAP_NAME].content[i] = +// toupper(tagContent[SNAP_NAME].content[i]); +// } + + if ((FSMinfo != NULL) && + (strcmp(FSMinfo->info.plugin.short_name, PLUGIN_NSSFS) == 0)) + { + i = 0; + j = -1; + while((ch = tagContent[POOL_NAME].content[i]) != 0) + { + if (ch == '/') + { + j = i; + } + i++; + } + if (j == -1) + j = 0; + else + j++; + + sprintf(mountPoint, "/opt/novell/nss/mnt/.pools/%s", tagContent[SNAP_NAME].content); + sprintf(mountOptions, "-t nsspool -oname=%s,snapname=%s", + &tagContent[POOL_NAME].content[j], + tagContent[SNAP_NAME].content); + if (volShared) + { + strcat(mountOptions, ",shared"); + } + } + else + { + sprintf(mountPoint, "/mnt/snapshot/%s", tagContent[SNAP_NAME].content); + mountOptions[0] = '\0'; + } + +// syslog(LOG_INFO, "mountpoint=%s", mountPoint); +// syslog(LOG_INFO, "options=%s", mountOptions); + ccode = make_directory(mountPoint, 0777); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error creating mountpoint directory")); + goto exit; + } +// syslog(LOG_INFO, "Mount the volume\n"); + ZOS_evms_mount(ccode, volhandle, mountPoint, mountOptions); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error mounting new snapshot volume")); + goto exit; + } + + /* In order to keep all the snapshot pools from being mounted, let's umount + ** the snapshot. + ** NOTE: It was first mounted to get the special first time mount options. */ + + ZOS_evms_unmount(ccode, volhandle); + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + +exit: + if (input != NULL) + { + free(input); + } + if (outputObjects != NULL) + { + ZOS_evms_free(outputObjects); + } + if (options) + { + free(options); + } + if (info) + { + ZOS_evms_free(info); + } + if (FSMinfo) + { + ZOS_evms_free(FSMinfo); + } + if (engineOpen) + { + evmsCloseEngine(); + engineOpen = FALSE; + } + + return zOK; +} + + +/***************************************************************************** + * This function remove pool snap shot + *****************************************************************************/ +STATUS MNSS_ProcessRemovePoolSnapshot( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_SNAPNAME, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + SNAP_NAME = 0, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + NINT i; + BOOL engineOpen = FALSE; + STATUS status; + STATUS ndsStatus; + LONG ccode; + object_handle_t handle; + char volumeName[256]; + handle_object_info_t *info = NULL; + handle_object_info_t *FSMinfo = NULL; + plugin_handle_t FSMplugin = 0; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + +// /* Upper case the names */ +// for (i = 0; tagContent[SNAP_NAME].content[i] != '\0'; i++) +// { +// tagContent[SNAP_NAME].content[i] = +// toupper(tagContent[SNAP_NAME].content[i]); +// } + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to open the EVMS engine")); + goto exit; + } + + engineOpen = TRUE; + + /* See if the volume object exist for specified snapshot */ + strcpy(volumeName, EVMS_DEVICE_PATH); + strcat(volumeName, tagContent[SNAP_NAME].content); + + ZOS_evms_get_object_handle_for_name(ccode, VOLUME, + volumeName, &handle); + + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_NAME, + MSGNot("Invalid snapshot name")); + goto exit; + } + + /* Check if the volume is mounted */ +// syslog(LOG_INFO, "Get info on %s", volumeName); + ZOS_evms_get_info(ccode, handle, &info); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, + MSGNot("Error getting volume info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + + /* + * Remove the corresponding volumes and DS objects + * for NSS pools. + */ + + FSMplugin = info->info.volume.file_system_manager; + + if(FSMplugin != 0) + { + ZOS_evms_get_info(ccode, FSMplugin, &FSMinfo); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, + MSGNot("Error getting plugin info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + + if ((FSMinfo != NULL) && + (strcmp(FSMinfo->info.plugin.short_name, PLUGIN_NSSFS) == 0)) + { + /* Uppercase the snap name for NSS pools */ + for (i = 0; tagContent[SNAP_NAME].content[i] != '\0'; i++) + { + tagContent[SNAP_NAME].content[i] = + toupper(tagContent[SNAP_NAME].content[i]); + } + + MNDS_RemovePoolVolumes(virtInfo, tagContent[SNAP_NAME].content); + ndsStatus = MNDS_DestroyPoolDSObjects(virtInfo, + tagContent[SNAP_NAME].content, TRUE); + } + + ZOS_evms_free(FSMinfo); + FSMinfo = NULL; + } + else + { + syslog(LOG_INFO, "MNSS_ProcessRemovePoolSnapshot: Unable to determine the file system type\n"); + } + + if (info->info.volume.mount_point != NULL) + { + /* Unmount the volume */ + ZOS_evms_unmount(ccode, handle); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error unmounting snapshot")); + goto exit; + } + rmdir(info->info.volume.mount_point); + } + + /* + * Delete the snapshot + */ + ZOS_evms_destroy(ccode, handle); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error deleting snapshot")); + goto exit; + } + + ZOS_evms_commit_changes(ccode); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error committing snapshot volume")); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + +exit: + if (info) + { + ZOS_evms_free(info); + } + if (engineOpen) + { + evmsCloseEngine(); + engineOpen = FALSE; + } + + return zOK; +} + + +/***************************************************************************** + * The following function validate/create the mount point + *****************************************************************************/ +int make_directory(char * dir_name, mode_t mode) { + + char name_buf[128]; + char * tmp_ptr = name_buf; + struct stat statbuf; + int status = 0; + + /* See if this directory exists */ + status = stat(dir_name, &statbuf); + if (status != 0) { + if (errno == ENOENT) { + /* This directory doesn't exist. */ + strcpy(name_buf, dir_name); + tmp_ptr = strrchr(name_buf, '/'); + + if ((tmp_ptr != NULL) && (tmp_ptr != name_buf)) { + /* + * This directory has a parent directory. + * Peel off the directory name and call myself + * recursively to make the parent directory. + */ + *tmp_ptr = 0; + + status = make_directory(name_buf, mode); + + } else { + status = 0; + } + + if (status == 0) { + status = mkdir(dir_name, mode); + + if (status != 0) { + status = errno; + } + } + + } else { + status = errno; + } + + } else { + /* Make sure this is a directory */ + if (!(statbuf.st_mode & S_IFDIR)) { + status = EINVAL; + } + } + + return status; +} + +/***************************************************************************** + * The following function mounts/dismounts snap shots + *****************************************************************************/ +static pid_t do_fork_and_execvp(char * argv[], + int stdin_pipe[2], + int stdout_pipe[2], + int stderr_pipe[2]) { + + pid_t pid; + + /* Fork and execute the program. */ + pid = fork(); + + if (pid == 0) { + /* Child process */ + + int dev_null_fd = -1; + + if ((stdout_pipe == NULL) || (stderr_pipe == NULL)) { + dev_null_fd = open("/dev/null", O_WRONLY); + } + + if (stdin_pipe != NULL) { + dup2(stdin_pipe[0], 0); /* Route stdin to pipe's read fd */ + } + + if (stdout_pipe != NULL) { + dup2(stdout_pipe[1], 1);/* Route stdout to pipe's write fd */ + } else { + if (dev_null_fd > 0) { + dup2(dev_null_fd, 1);/* Route stdout to the bit bucket */ + } + } + + if (stderr_pipe != NULL) { + dup2(stderr_pipe[1], 2);/* Route stderr to pipe's write fd */ + } else { + if (dev_null_fd > 0) { + dup2(dev_null_fd, 2);/* Route stderr to the bit bucket */ + } + } + + execvp(argv[0], argv); + + /* If the execvp() works it won't return here. */ + /* Using exit() can hang GUI, use _exit */ + _exit(errno); + } + + return pid; +} + +static inline int set_arg(char **argv, int index, char *str) +{ + if ((argv[index] = malloc(strlen(str)+1)) != NULL) + { + strcpy(argv[index], str); + return(0); + } + else + { + return(ENOMEM); + } +} + +static int mountsnap(char *snapname, char *mountpoint, boolean mount, boolean shared) +{ + int status; + char *argv[9]; + pid_t pidm; + int fds2[2]; // pipe for stderr and stdout 0=read,1=write + int bytes_read; + char *buffer = NULL; + int opt_count = 0; + + status = pipe(fds2); + if (status) { + status = errno; + return(status); + } + + if (!(buffer = malloc(256))) { + close(fds2[0]); + close(fds2[1]); + return(ENOMEM); + } + + if (mount) { + if ((status = make_directory(mountpoint, 0777)) != 0) { + free(buffer); + close(fds2[0]); + close(fds2[1]); + return status; + } + + status = set_arg(argv, opt_count++, "mount"); + } + else { + status = set_arg(argv, opt_count++, "umount"); + } + + if (status == 0) { + if (mount) + { + status = set_arg(argv, opt_count++, "-t"); + if (status == 0) { + status = set_arg(argv, opt_count++, "nsspool"); + } + } + if (status == 0) { + bytes_read = sprintf(buffer, "%s%s", + EVMS_DEVICE_PATH, snapname); + status = set_arg(argv, opt_count++, buffer); + if (status == 0) { + if (mount) { + status = set_arg(argv, opt_count++, mountpoint); + if (status == 0) { + status = set_arg(argv, opt_count++, "-o"); + if (status == 0) { + bytes_read = sprintf(buffer, "name=%s%s", + snapname, + (shared) ? ",shared" : ""); + status = set_arg(argv, opt_count++, buffer); + memset(buffer,0,bytes_read); //clear out message + + if (status == 0) { + /* NULL terminate the argument array */ + argv[opt_count] = NULL; + } + } + } + } + else { + argv[opt_count] = NULL; + } + } + } + } + + if (status == 0) { + pidm = do_fork_and_execvp(argv, NULL, fds2, fds2); + if (pidm != -1) { + fcntl(fds2[0], F_SETFL, fcntl(fds2[0], F_GETFL,0) | O_NONBLOCK); + while (!(waitpid( pidm, &status, WNOHANG ))) { + bytes_read = read(fds2[0],buffer,256); + if (bytes_read > 0) { + if (mount) { + syslog(LOG_INFO, "mount output: \n%s",buffer); + } + else { + syslog(LOG_INFO, "umount output: \n%s",buffer); + } + + memset(buffer,0,bytes_read); //clear out message + } + usleep(10000); // don't hog all the cpu + } + if (WIFEXITED(status) && (WEXITSTATUS(status) != ENOENT)) { + do { + bytes_read = read(fds2[0],buffer,256); + if (bytes_read > 0) { + if (mount) { + syslog(LOG_INFO, "mount output: \n%s",buffer); + } + else { + syslog(LOG_INFO, "umount output: \n%s",buffer); + } + } + } while (bytes_read > 0); + + status = WEXITSTATUS(status); + + } else { + status = EINTR; + } + } else { + status = EIO; + } + } + + /* Free the argv */ + for (opt_count = 0; argv[opt_count] != NULL; opt_count++) + { + free(argv[opt_count]); + } + + free(buffer); + close(fds2[0]); + close(fds2[1]); + return status; +} + +/***************************************************************************** + * The following functions activate pool snap shot + *****************************************************************************/ +STATUS MNSS_ProcessActivatePoolSnapshot( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_SNAPNAME, TR_CONTENT_REQUIRED}, + {TAG_SHARED, TR_OPTIONAL}, + {0} + }; + + enum + { + SNAP_NAME = 0, + SHARED = 1, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + STATUS status; + LONG ccode; + boolean shared = FALSE, engineOpen = FALSE; + object_handle_t volhandle; + char mountPoint[128], mountOptions[80]; + handle_object_info_t *info = NULL; + handle_object_info_t *FSMinfo = NULL; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + if (tagContent[SHARED].flags & TR_TAG_FOUND) + { + shared = TRUE; + } + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to open the EVMS engine")); + goto exit; + } + + engineOpen = TRUE; + + strcpy(mountPoint, EVMS_DEVICE_PATH); + strcat(mountPoint, tagContent[SNAP_NAME].content); + ZOS_evms_get_object_handle_for_name(ccode, VOLUME, + mountPoint, &volhandle); + + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_NAME, + MSGNot("Invalid volume/pool name")); + goto exit; + } + + ZOS_evms_get_info(ccode, volhandle, &info); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, + MSGNot("Error getting volume info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + + if (info->info.volume.flags & VOLFLAG_CLUSTER_SHARED) + { + shared = TRUE; + } + + ZOS_evms_get_info(ccode, info->info.volume.file_system_manager, &FSMinfo); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, + MSGNot("Error getting plugin info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + + if ((FSMinfo != NULL) && + (strcmp(FSMinfo->info.plugin.short_name, PLUGIN_NSSFS) == 0)) + { + sprintf(mountPoint, "/opt/novell/nss/mnt/.pools/%s", tagContent[SNAP_NAME].content); + sprintf(mountOptions, "-t nsspool -oname=%s", tagContent[SNAP_NAME].content); + if (shared) + { + strcat(mountOptions, ",shared"); + } + } + else + { + sprintf(mountPoint, "/mnt/snapshot/%s", tagContent[SNAP_NAME].content); + mountOptions[0] = '\0'; + } + +// syslog(LOG_INFO, "mountpoint=%s", mountPoint); +// syslog(LOG_INFO, "options=%s", mountOptions); + ccode = make_directory(mountPoint, 0777); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error creating mountpoint directory")); + goto exit; + } + + /* + * Activate the snapshot + */ + +// syslog(LOG_INFO, "Mount the volume\n"); + ZOS_evms_mount(ccode, volhandle, mountPoint, mountOptions); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error mounting new snapshot volume")); + goto exit; + } + +// ccode = mountsnap(tagContent[SNAP_NAME].content, mountpoint, TRUE, shared); +// if (ccode != 0) +// { +// MNSS_ReturnResult(virtInfo, tagName, ccode, +// MSGNot("Error activating snapshot")); +// goto exit; +// } + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + +exit: + if (info) + { + ZOS_evms_free(info); + } + if (FSMinfo) + { + ZOS_evms_free(FSMinfo); + } + if (engineOpen) + { + evmsCloseEngine(); + engineOpen = FALSE; + } + + return zOK; +} + + +/***************************************************************************** + * This function deactivate pool snap shot + *****************************************************************************/ +STATUS MNSS_ProcessDeactivatePoolSnapshot( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_SNAPNAME, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + SNAP_NAME = 0, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + STATUS status; + LONG ccode; + NINT i; + char volumeName[256] ; + handle_object_info_t *info = NULL; + handle_object_info_t *FSIMInfo = NULL; + object_handle_t volhandle; + plugin_handle_t FSIMHandle; + BOOL volumeIsNSS = FALSE; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + ccode = evmsOpenEngine(EVMS_ENGINE_READONLY); + if(ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot ("Unable to open the EVMS engine")); + goto exit; + } + + strcpy(volumeName, EVMS_DEVICE_PATH); + strcat(volumeName, tagContent[SNAP_NAME].content); + ZOS_evms_get_object_handle_for_name(ccode, VOLUME, + volumeName, &volhandle); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_NAME, + MSGNot ("Invalid volume/pool name")); + goto exit; + } + + ZOS_evms_get_info(ccode, volhandle, &info); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot ("Error getting volume info")); + goto exit; + } + + FSIMHandle = info->info.volume.file_system_manager; + ZOS_evms_free (info); + info = NULL; + + ZOS_evms_get_info(ccode, FSIMHandle, &FSIMInfo); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot ("Error getting plugin info")); + goto exit; + } + + if (!strcmp(FSIMInfo->info.plugin.short_name, "NSSFS")) + { + volumeIsNSS = TRUE; + } + ZOS_evms_free(FSIMInfo); + evmsCloseEngine() ; + + if(volumeIsNSS) + { + /* Upper case the names */ + for(i = 0; tagContent[SNAP_NAME].content[i] != '\0'; i++) + { + tagContent[SNAP_NAME].content[i] = + toupper(tagContent[SNAP_NAME].content[i]); + } + + /* + * Unmount the volumes and remove the volume entries from mount point folders. + * This is done during pool activation for snapshot pools as it is possible to + * delete the snapshot pool even when it is not mounted (unlike normal pools). + * When the pools are not mounted, the current delete code does not delete the + * volumes and the related mount point entries. So we unmount the volumes and + * remove the mount point entries at deactivation time for snapshot pools. + */ + (void)DismountAndRemovePoolVolumesEntries(tagContent[SNAP_NAME].content, TRUE); + } + + /* + * Dismount the pool snapshot + */ + ccode = mountsnap(tagContent[SNAP_NAME].content, NULL, FALSE, FALSE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error deactivating snapshot")); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + +exit: + return zOK; +} + + +/***************************************************************************** + * Fill pool snap shot's information + *****************************************************************************/ +STATUS FillPoolSnapshotInfo( + VirtInfo_s *virtInfo, + utf8_t *tagName, + object_handle_t handle, + BOOL listDetails, + utf8_t *poolName) +{ + STATUS status = zFAILURE; + LONG ccode; + char tmpStr[80], pname[80], *pstr, ch; + NINT i,j; + handle_object_info_t *info = NULL, *childInfo = NULL, *volume = NULL; + extended_info_array_t *info_array = NULL; + handle_array_t *child; + + ZOS_evms_get_info(ccode, handle, &info); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, + MSGNot("Error getting snapshot object info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + + ZOS_evms_get_extended_info(ccode, handle, NULL, &info_array); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, + MSGNot("Error getting snapshot information")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + + if (strcmp(info_array->info[0].name, "SnapShot") == 0) + { + status = zOK; + goto exit; + } + + /* Get the pool name */ + i = 0; + j = -1; + while((ch = info_array->info[0].value.s[i]) != 0) + { + if (ch == '/') + { + j = i; + } + i++; + } + if (j == -1) + j = 0; + else + j++; + + strcpy(pname, &info_array->info[0].value.s[j]); + + if (poolName) + { + /* check if this is the pool we are looking at */ + if (stricmp(pname, poolName)) + { + status = zOK; + goto exit; + } + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLSNAPSHOTINFO, FALSE, TRUE)) != zOK) + { + goto exit; + } + + /* snap name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_SNAPNAME, + info->info.object.name, TRUE)) != zOK) + { + goto exit; + } + + if (listDetails) + { + /* pool name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_POOLNAME, + pname, TRUE)) != zOK) + { + goto exit; + } + + child = info->info.object.child_objects; + if (child->count >= 1) + { + ZOS_evms_get_info(ccode, child->handle[0], &childInfo); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, + MSGNot("Error getting data object info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + } + else + { + goto exit; + } + + /* snapshot name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_SNAPPOOLNAME, + childInfo->info.object.name, TRUE)) != zOK) + { + goto exit; + } + + /* snap shot size */ + sprintf(tmpStr, MSGNot("%Lu"), childInfo->info.object.size); + if ((status = VIRT_AddResultElement(virtInfo, TAG_ALLOCATEDSIZE, + tmpStr, TRUE)) != zOK) + { + goto exit; + } + + status = zFAILURE; + + /* pool size */ + sprintf(tmpStr, MSGNot("%Lu"), info->info.object.size); + if ((status = VIRT_AddResultElement(virtInfo, TAG_POOLSIZE, + tmpStr, TRUE)) != zOK) + { + goto exit; + } + +// /* time */ +// sprintf(tmpStr, MSGNot("%u"), snapshotInfo->timestamp); +// if ((status = VIRT_AddResultElement(virtInfo, TAG_TIME, +// tmpStr, TRUE)) != zOK) +// { +// goto exit; +// } + + /* percent full */ + if (info_array->info[4].type == EVMS_Type_String) + { + pstr = info_array->info[4].value.s; + } + else + { + sprintf(tmpStr, "%u", info_array->info[4].value.ui); + pstr = tmpStr; + } + if ((status = VIRT_AddResultElement(virtInfo, TAG_PERCENTFULL, + pstr, TRUE)) != zOK) + { + goto exit; + } + + /* snap shot state */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_STATE, + info_array->info[3].value.s, TRUE)) != zOK) + { + goto exit; + } + + /* Get the mountpoint */ + ZOS_evms_get_info(ccode, info->info.object.volume, &volume); + if (ccode == 0) + { + if (volume->info.volume.mount_point != NULL) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_MOUNTPOINT, + volume->info.volume.mount_point, TRUE)) != zOK) + { + goto exit; + } + } + else + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_MOUNTPOINT, + "not mounted", TRUE)) != zOK) + { + goto exit; + } + } + } + else + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_MOUNTPOINT, + "not mounted", TRUE)) != zOK) + { + goto exit; + } + } + + /* writeable status */ + if (info_array->info[2].value.b) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_WRITEABLE, + NULL, FALSE)) != zOK) + { + goto exit; + } + } + + } + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLSNAPSHOTINFO, TRUE, TRUE)) != zOK) + { + goto exit; + } + +exit: + if (info) + { + ZOS_evms_free(info); + } + if (childInfo) + { + ZOS_evms_free(childInfo); + } + if (info_array) + { + ZOS_evms_free(info_array); + } + if (volume) + { + ZOS_evms_free(volume); + } + + return status; +} + + +/***************************************************************************** + * This function list all pool snap shots and return their information + *****************************************************************************/ +STATUS MNSS_ProcessListPoolSnapshots( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + LONG ccode; + NINT i; + BOOL listDetails; + BOOL engineOpen = FALSE; + plugin_handle_t pluginHandle; + handle_array_t *object_list = NULL; + const TagRequest_s tags[] = + { + {TAG_DETAILS, TR_OPTIONAL}, + {TAG_POOLNAME, TR_OPTIONAL}, + {0} + }; + + enum + { + DETAILS = 0, + POOL_NAME = 1, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + ASSERT_MPKNSS_LOCK(); + +// syslog(LOG_INFO, "MNSS: Got to list snapshots"); + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + goto exit; + } + + if (tagContent[DETAILS].flags == TR_TAG_FOUND) + { + listDetails = TRUE; + } + else + { + listDetails = FALSE; + } + +// syslog(LOG_INFO, "MNSS: list details = %d", listDetails); + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto exit; + } + + /* get list of snap shots */ + ccode = evmsOpenEngine(EVMS_ENGINE_READONLY); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to open the EVMS engine")); + goto exit; + } + + engineOpen = TRUE; + +// syslog(LOG_INFO, "MNSS List: opened engine"); + ZOS_evms_get_plugin_by_name(ccode, PLUGIN_SNAPSHOT, &pluginHandle); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Unable to get Snapshot plugin handle")); + goto exit; + } + +// syslog(LOG_INFO, "MNSS List: got plugin handle"); + ZOS_evms_get_object_list(ccode, 0, DATA_TYPE, pluginHandle, 0, 0, &object_list); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error getting snapshot list")); + goto exit; + } + +// syslog(LOG_INFO, "MNSS List: got list, count=%d", object_list->count); + if (object_list != NULL && object_list->count != 0) + { + for (i = 0; i < object_list->count; i++) + { + if ((status = FillPoolSnapshotInfo(virtInfo, tagName, object_list->handle[i], + listDetails, tagContent[POOL_NAME].content)) != zOK) + { + if (status != zERR_NO_MEMORY) + { + status = zOK; + } + goto exit; + } + } + } + +// syslog(LOG_INFO, "MNSS List: list done"); + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE)) != zOK) + { + goto exit; + } + +exit: + if (object_list != NULL) + { + ZOS_evms_free(object_list); + } + if (engineOpen) + { + evmsCloseEngine(); + engineOpen = FALSE; + } + + return status; +} + + +/***************************************************************************** + * This function get a pool snap shot's information + *****************************************************************************/ +STATUS MNSS_ProcessGetPoolSnapshotInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_SNAPNAME, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + SNAP_NAME = 0, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + +// NINT i; + BOOL engineOpen = FALSE; + STATUS status; + LONG ccode; + object_handle_t handle; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + +// /* Upper case the names */ +// for (i = 0; tagContent[SNAP_NAME].content[i] != '\0'; i++) +// { +// tagContent[SNAP_NAME].content[i] = +// toupper(tagContent[SNAP_NAME].content[i]); +// } + + /* get list of snap shots */ + ccode = evmsOpenEngine(EVMS_ENGINE_READONLY); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to open the EVMS engine")); + goto exit; + } + + engineOpen = TRUE; + + ZOS_evms_get_object_handle_for_name(ccode, EVMS_OBJECT, + tagContent[SNAP_NAME].content, &handle); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to get Snapshot handle")); + goto exit; + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto exit; + } + + if ((status = FillPoolSnapshotInfo(virtInfo, tagName, handle, + TRUE, NULL)) != zOK) + { + if (status != zERR_NO_MEMORY) + { + status = zOK; + } + goto exit; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE)) != zOK) + { + goto exit; + } + + +exit: + if (engineOpen) + { + evmsCloseEngine(); + engineOpen = FALSE; + } + + return status; +} + +/***************************************************************************** + * This function get a list of the volumes in EVMS + *****************************************************************************/ +STATUS MNSS_ProcessListEvmsVolumes( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + + NINT i; + BOOL engineOpen = FALSE; + STATUS status=zFAILURE; + LONG ccode; + handle_array_t *handles = NULL; + object_handle_t object; + plugin_handle_t snap_plugin; + handle_object_info_t *volume = NULL; + handle_object_info_t *info = NULL; + extended_info_array_t *info_array = NULL; + + ASSERT_MPKNSS_LOCK(); + + ccode = evmsOpenEngine(EVMS_ENGINE_READONLY); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to open the EVMS engine")); + goto exit; + } + + engineOpen = TRUE; + + ZOS_evms_get_plugin_by_name(ccode, PLUGIN_SNAPSHOT, &snap_plugin); + if (ccode != 0) + { + snap_plugin = 0; + } + + ZOS_evms_get_volume_list(ccode, 0, 0, 0, &handles); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to get volume list")); + goto exit; + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto exit; + } + + for (i=0; icount; i++) + { + ZOS_evms_get_info(ccode, handles->handle[i], &volume); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, + MSGNot("Error getting volume object info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + + if ((volume->info.volume.flags & VOLFLAG_READ_ONLY) == 0) + { + if ((object = volume->info.volume.object) == 0) + { + ZOS_evms_free(volume); + volume = NULL; + continue; + } + + ZOS_evms_get_info(ccode, object, &info); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, + MSGNot("Error getting volume object's info")); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + goto exit; + } + + if (info->info.object.plugin == snap_plugin) + { + /* Check if it is the origin */ + ZOS_evms_get_extended_info(ccode, object, NULL, &info_array); + if (ccode == 0) + { + if (strcmp(info_array->info[0].name, "SnapShot") != 0) + { + ZOS_evms_free(info_array); + ZOS_evms_free(info); + info = NULL; + ZOS_evms_free(volume); + volume = NULL; + continue; + } + } + else + { + ZOS_evms_free(info); + info = NULL; + ZOS_evms_free(volume); + volume = NULL; + continue; + } + + ZOS_evms_free(info_array); + } + + ZOS_evms_free(info); + info = NULL; + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_VOLUMEINFO, FALSE, TRUE)) != zOK) + { + goto exit; + } + /* volume name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMENAME, + volume->info.volume.name, TRUE)) != zOK) + { + goto exit; + } + + /* volume shared state */ + if (volume->info.volume.flags & VOLFLAG_CLUSTER_SHARED) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMESTATE, + "Yes", TRUE)) != zOK) + { + goto exit; + } + } + else + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMESTATE, + "No", TRUE)) != zOK) + { + goto exit; + } + } + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_VOLUMEINFO, TRUE, TRUE)) != zOK) + { + goto exit; + } + } + ZOS_evms_free(volume); + volume = NULL; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE)) != zOK) + { + goto exit; + } + + +exit: + if (handles) + { + ZOS_evms_free(handles); + } + + if (info) + { + ZOS_evms_free(info); + } + + if (volume) + { + ZOS_evms_free(volume); + } + + if (engineOpen) + { + evmsCloseEngine(); + engineOpen = FALSE; + } + + return status; +} + +#endif + +#if zNETWARE + +/**************************************************************************** + * + * This function renames a pool. + * + ****************************************************************************/ +STATUS MNSS_ProcessRenamePoolSnapshot( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_SNAPNAME, TR_CONTENT_REQUIRED}, + {TAG_NEWSNAPNAME, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + SNAP_NAME = 0, + NEW_SNAP_NAME = 1, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + NINT i; + STATUS status; + LONG ccode; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + MNSS_LoadAppIDs(); + + /* Upper case the names */ + for (i = 0; tagContent[SNAP_NAME].content[i] != '\0'; i++) + { + tagContent[SNAP_NAME].content[i] = + toupper(tagContent[SNAP_NAME].content[i]); + } + + for (i = 0; tagContent[NEW_SNAP_NAME].content[i] != '\0'; i++) + { + tagContent[NEW_SNAP_NAME].content[i] = + toupper(tagContent[NEW_SNAP_NAME].content[i]); + } + + /* + * Rename the pool snapshot + */ + ZMM_RenameSnapshot(ccode, tagContent[SNAP_NAME].content, + tagContent[NEW_SNAP_NAME].content); + + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error calling MM_RenameSnapshot")); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + +exit: + return zOK; +} + + + /* The Master List of all outstanding XML freeze/thaw requests */ +DQhead_t MNSS_MasterFreezeList = DQ_STATIC_INIT(MNSS_MasterFreezeList); + /* Estimate of number of FAS needed */ +unsigned int MNSS_NeededEntriesFAS = 15; + + +/* + * FUT_FASNew() - + * Used to allocate and init a FreezeApplicationStatus_s. + */ +FreezeApplicationStatus_s *FUT_FASNew( + unsigned int elements ) +{ + FreezeApplicationStatus_s *fas; + + if ( elements < 1 ) + { + return( NULL ); + } + fas = zalloc( sizeof(*fas) + ( sizeof(fas->FAS_Entries) * (elements - 1) ) ); + if ( fas == NULL ) + { + return( NULL ); + } + fas->FAS_AllocatedEntries = elements; + return( fas ); + +} /* End of FUT_FASNew() */ + + +/* + * FUT_FASDelete() - + * Used to delete a FreezeApplicationStatus_s. + */ +void FUT_FASDelete( + FreezeApplicationStatus_s *fas ) +{ + if ( fas == NULL ) + { + return; + } + free( fas ); + return; + +} /* End of FUT_FASDelete() */ + + +/* + * FreezeThawUse() - + * Used to indicate that the caller is using a FreezeThawEntry_s. + */ +void FreezeThawUse( + FreezeThawEntry_s *fte ) +{ + zASSERT( fte->FTE_UseCount != 0 ); + ++fte->FTE_UseCount; +} /* End of FreezeThawUse() */ + + +/* + * FreezeThawRelease() - + * Used to indicate that the caller is NO LONGER using a FreezeThawEntry_s. + */ +void FreezeThawRelease( + FreezeThawEntry_s *fte ) +{ + zASSERT( fte->FTE_UseCount != 0 ); + --fte->FTE_UseCount; + if ( fte->FTE_UseCount == 0 ) + { + FreezeThawDelete( fte ); + } +} /* End of FreezeThawRelease() */ + + +/* + * FreezeThawNew() - + * Allocates and inits a single FreezeThawEntry_s. The FreezeThawEntry_s + * is returned with a use count on it (that the caller must release). The + * FreezeThawEntry_s is also X_LATCHed (that the caller must release). + */ +FreezeThawEntry_s *FreezeThawNew( + STATUS *status, + unicode_t *poolName, + int holdSeconds, + int timeOutSeconds, + int applications ) +{ + FreezeThawEntry_s *fte; + + if ( unilen( poolName ) >= NELEMS( fte->FTE_PoolName ) ) + { + *status = zERR_POOL_NOT_FOUND; + return( NULL ); + } + fte = zalloc( sizeof(*fte) ); + if ( fte == NULL ) + { + *status = zERR_NO_MEMORY; + return( fte ); + } + INIT_X_LATCH( &fte->FTE_Latch ); + fte->FTE_Stamp = FTE_STAMP; + fte->FTE_Unload = FALSE; + NULLIFY( &fte->FTE_LinkAll ); + fte->FTE_UseCount = 1; + fte->FTE_Trace = WHERE; + fte->FTE_ThawStatus = zOK; + fte->FTE_ThawIsDone = FALSE; + fte->FTE_FreezeIsDone = FALSE; + fte->FTE_TimeOut = timeOutSeconds; + fte->FTE_TimeOutUTCTime = 0; /* Set in thread */ + fte->FTE_ResultsHeldUTCTime = 0; /* Set in thread */ + fte->FTE_HeldSeconds = holdSeconds; + fte->FTE_FreezeStatus = zOK; + unicpy( fte->FTE_PoolName, poolName ); + fte->FTE_ThreadScheduled = FALSE; + fte->FTE_ThreadSceduleUTC = 0; + fte->FTE_FreezeApplicationStatus = FUT_FASNew( applications ); + fte->FTE_ThawKey = 0; + fte->FTE_ThawNow = FALSE; + fte->FTE_ThawOpRetCode = zOK; + LB_GUIDGenerate( &fte->FTE_UserKey ); + return( fte ); + +} /* End of FreezeThawNew() */ + + +/* + * FreezeThawDelete() - + * Frees a FreezeThawEntry_s. + * + * Notes - + * Must only be called by the release code. + */ +void FreezeThawDelete( + FreezeThawEntry_s *fte ) + +{ + + zASSERT( fte->FTE_Stamp == FTE_STAMP ); + zASSERT( fte->FTE_UseCount == 0 ); + if ( QMEMBER( &fte->FTE_LinkAll ) ) + { + X_LATCH( &MNSS_MasterFreezeLatch ); + DQ_RMV(fte, FTE_LinkAll); + UNX_LATCH( &MNSS_MasterFreezeLatch ); + } + else + { + zASSERT("Why not a member?"==NULL); + } + FUT_FASDelete( fte->FTE_FreezeApplicationStatus ); + fte->FTE_FreezeApplicationStatus = NULL; + free( fte ); + +} /* End of FreezeThawDelete() */ + + +/* + * MNSS_zPoolLookup() - + * Looks up a FreezeThawEntry_s via the userKey. The FreezeThawEntry_s + * is protected from going away only as long as the NSS spinlock is held. + */ +FreezeThawEntry_s *MNSS_zPoolLookup( GUID_t *userKey ) +{ + FreezeThawEntry_s *fte; + + ASSERT_MPKNSS_LOCK(); + + S_LATCH( &MNSS_MasterFreezeLatch ); + DQ_FOREACH( &MNSS_MasterFreezeList, fte, FreezeThawEntry_s, FTE_LinkAll ) + { + if ( LB_GUIDCompare( &fte->FTE_UserKey, userKey ) == 0 ) + { + FreezeThawUse( fte ); + UNS_LATCH( &MNSS_MasterFreezeLatch ); + return( fte ); + } + } + UNS_LATCH( &MNSS_MasterFreezeLatch ); + return( NULL ); + +} /* End of MNSS_zPoolLookup() */ + + +/* + * MNSS_ProcessPoolFreeze() - + * Freezes a pool via XML. + */ +STATUS MNSS_ProcessPoolFreeze( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + int holdSeconds; + int timeOut; + GUID_t userKey; + STATUS status; + unicode_t uni_poolName[zMAX_COMPONENT_NAME]; + char guidBuffer[GUID_FORMAT_SIZE]; + + + const TagRequest_s tags[] = + { + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_POOLTIMEOUT, TR_CONTENT_REQUIRED}, + {TAG_POOLHOLD, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + POOL_NAME = 0, + TIME_OUT = 1, + HOLD_SECONDS = 2, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + + ASSERT_MPKNSS_LOCK(); +// zASSERT("In MNSS_ProcessPoolFreeze"==NULL); + status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, &tagContent); + if ( status != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Change the pool name to unicode. */ + status = utf2uni(tagContent[POOL_NAME].content, uni_poolName, + sizeof(uni_poolName)); + if ( status == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting pool name to unicode")); + goto exit; + } + timeOut = atoi( tagContent[TIME_OUT].content ); + holdSeconds = atoi( tagContent[HOLD_SECONDS].content ); + + status = MNSS_zPoolFreeze( uni_poolName, holdSeconds, timeOut, MNSS_NeededEntriesFAS + 10, &userKey ); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, MSGNot("Error calling MNSS_zPoolFreeze")); + goto exit; + } + LB_GUIDToString( &userKey, sizeof(guidBuffer), guidBuffer ); + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLFREEZE, FALSE, TRUE)) != zOK) + { + goto exit; + } + + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_USERKEY" "ATR_VALUE"=\"%s\"/>\n"), guidBuffer ); + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_POOLNAME" "ATR_VALUE"=\"%U\"/>\n"), uni_poolName ); + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLFREEZE, TRUE, TRUE)) != zOK) + { + goto exit; + } +exit: + return zOK; + +} /* End of MNSS_ProcessPoolFreeze() */ + + +/* + * MNSS_ProcessPoolFreeze() - + * Thaws a pool via XML. + */ +STATUS MNSS_ProcessPoolThaw( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + FreezeThawEntry_s *fte; + GUID_t userKey; + STATUS status; + STATUS retOpCode; + char guidBuffer[GUID_FORMAT_SIZE]; + + const TagRequest_s tags[] = + { + {TAG_USERKEY, TR_CONTENT_REQUIRED}, + {TAG_POOLTHAWOPRETCODE, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + USER_KEY = 0, + THAW_OP_RET_CODE = 1, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + + ASSERT_MPKNSS_LOCK(); +// zASSERT("In MNSS_ProcessPoolThaw"==NULL); + + status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, &tagContent); + if ( status != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + status = LB_GUIDFromUTF8( tagContent[USER_KEY].content, &userKey ); + if ( status != zOK ) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot(TAG_USERKEY" value is not in the correct format")); + goto exit; + } + retOpCode = atoi( tagContent[THAW_OP_RET_CODE].content ); + + LB_GUIDToString( &userKey, sizeof(guidBuffer), guidBuffer ); + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto exit; + } + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_USERKEY" "ATR_VALUE"=\"%s\"/>\n"), guidBuffer ); + + fte = MNSS_zPoolLookup( &userKey ); /* On success, we get a use count */ + if ( fte == NULL ) + { + MNSS_BuildResult(virtInfo, zERR_BAD_KEY, MSGNot("Key not found")); + goto exit2; + } + + S_LATCH( &fte->FTE_Latch ); + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_POOLNAME" "ATR_VALUE"=\"%U\"/>\n"), fte->FTE_PoolName ); + if ( fte->FTE_ThawNow ) + { /* Someone has already called this */ + MNSS_BuildResult(virtInfo, zERR_POOL_FREEZE_ALREADY_THAWED, MSGNot("Operation has already been done") ); + } + else + { + fte->FTE_ThawOpRetCode = retOpCode; + fte->FTE_ThawNow = TRUE; + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + UNS_LATCH( &fte->FTE_Latch ); + FreezeThawRelease( fte ); + fte = NULL; +exit2: + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE)) != zOK) + { + goto exit; + } + +exit: + return zOK; + +} /* End of MNSS_ProcessPoolThaw() */ + + +/* + * MNSS_ProcessPoolFreeze() - + * Returns status on a XML freeze/thaw request. + */ +STATUS MNSS_ProcessPoolFreezeStatus( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + FreezeThawEntry_s *fte; + GUID_t userKey; + STATUS status; + char guidBuffer[GUID_FORMAT_SIZE]; + + const TagRequest_s tags[] = + { + {TAG_USERKEY, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + USER_KEY = 0, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + + ASSERT_MPKNSS_LOCK(); +// zASSERT("In MNSS_ProcessPoolFreezeStatus"==NULL); + + status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, &tagContent); + if ( status != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + status = LB_GUIDFromUTF8( tagContent[USER_KEY].content, &userKey ); + if ( status != zOK ) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot(TAG_USERKEY" value is not in the correct format")); + goto exit; + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLFREEZESTATUS, FALSE, TRUE)) != zOK) + { + goto exit; + } + LB_GUIDToString( &userKey, sizeof(guidBuffer), guidBuffer ); + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_USERKEY" "ATR_VALUE"=\"%s\"/>\n"), guidBuffer ); + + fte = MNSS_zPoolLookup( &userKey ); /* On success, we get a use count */ + if ( fte == NULL ) + { + MNSS_BuildResult(virtInfo, zERR_BAD_KEY, MSGNot("Key not found")); + goto exit2; + } + S_LATCH( &fte->FTE_Latch ); + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_POOLNAME" "ATR_VALUE"=\"%U\"/>\n"), fte->FTE_PoolName ); + + { + int tTime; + int hTime; + int now = GetUTCTime(); + + if ( fte->FTE_ThreadSceduleUTC == 0 ) + { /* Time not set so lie a little */ + hTime = fte->FTE_HeldSeconds; + tTime = fte->FTE_TimeOut; + } + else + { + hTime = fte->FTE_ResultsHeldUTCTime - now; + tTime = fte->FTE_TimeOutUTCTime - now; + } + if ( hTime < 0 ) + { + hTime = 0; + } + if ( tTime < 0 ) + { + tTime = 0; + } + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_POOLTIMEOUT" "ATR_VALUE"=\"%d\"/>\n"), tTime ); + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_POOLHOLD" "ATR_VALUE"=\"%d\"/>\n"), hTime ); + } + if ( !fte->FTE_FreezeIsDone ) + { /* Freeze not done so give very simply status */ + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_POOLFREEZEDONE" "ATR_VALUE"=\"%s\"/>\n"), "FALSE" ); + } + else + { /* Freeze is done so give all status */ + if ( fte->FTE_ThawIsDone ) + { + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_POOLTHAWDONE" "ATR_VALUE"=\"%s\"/>\n"), "TRUE" ); + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_POOLTHAWSTATUS2" "ATR_VALUE"=\"%d\"/>\n"), fte->FTE_ThawStatus ); + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_POOLTHAWOPRETCODE" "ATR_VALUE"=\"%d\"/>\n"), fte->FTE_ThawOpRetCode ); + } + else + { + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_POOLTHAWDONE" "ATR_VALUE"=\"%s\"/>\n"), "FALSE" ); + } + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_POOLFREEZEDONE" "ATR_VALUE"=\"%s\"/>\n"), "TRUE" ); + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_POOLFREEZESTATUS2" "ATR_VALUE"=\"%d\"/>\n"), fte->FTE_FreezeStatus ); + (void)VIRT_AddResultTag(virtInfo, TAG_POOLAPPSTATUS, FALSE, TRUE); + if ( fte->FTE_FreezeApplicationStatus ) + { + FreezeApplicationStatus_s *fas = fte->FTE_FreezeApplicationStatus; + int i; + + (void)VIRT_ssprintf( virtInfo, "\n", fas->FAS_UsedEntries, fas->FAS_NeededEntries ); + for ( i = 0; i < fas->FAS_UsedEntries; ++i ) + { + (void)VIRT_AddResultTag(virtInfo, TAG_POOLAPPSTATUS2, FALSE, TRUE); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), fas->FAS_Entries[i].FASE_Status ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), fas->FAS_Entries[i].FASE_ApplicationName ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), fas->FAS_Entries[i].FASE_ApplicationMessage ); + (void)VIRT_AddResultTag(virtInfo, TAG_POOLAPPSTATUS2, TRUE, TRUE); + } + if ( fas->FAS_NeededEntries > MNSS_NeededEntriesFAS ) + { /* Track largest needed entries */ + MNSS_NeededEntriesFAS = fas->FAS_NeededEntries; + } + if ( fas->FAS_NeededEntries > fas->FAS_AllocatedEntries ) + { + (void)VIRT_ssprintf( virtInfo, MSGNot("\n") ); + } + } + else + { + (void)VIRT_ssprintf( virtInfo, MSGNot("\n") ); + } + (void)VIRT_AddResultTag(virtInfo, TAG_POOLAPPSTATUS, TRUE, TRUE); + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + + UNS_LATCH( &fte->FTE_Latch ); + FreezeThawRelease( fte ); + fte = NULL; +exit2: + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLFREEZESTATUS, TRUE, TRUE)) != zOK) + { + goto exit; + } + +exit: + return zOK; + +} /* End of MNSS_ProcessPoolFreezeStatus() */ + + +/* MNSS_zPoolFreezeThread() - + * This is the thread that runs to do the work of XML freeze. + * It will freeze the pool and they thaw it when told or the auto + * thaw time occurs. + * + */ +void *MNSS_zPoolFreezeThread( + THREAD threadID, + FreezeThawEntry_s *fte ) +{ + STATUS status; + LONG now = GetUTCTime(); + + MPKNSS_LOCK(); + ASSERT_MPKNSS_LOCK(); + zASSERT( fte->FTE_Stamp == FTE_STAMP ); + zASSERT( fte->FTE_UseCount > 0 ); /* We must be called with a use count */ + +#if NSS_DEBUG IS_ENABLED + DBG_DebugPrintf( CYAN, "MNSS_zPoolFreezeThread is now running\n" ); +#endif + X_LATCH( &fte->FTE_Latch ); + fte->FTE_ThreadSceduleUTC = now; + /* We set here just in case it told a long time for + * MNSS_zPoolFreezeThread to be scheduled. + */ + fte->FTE_TimeOutUTCTime = now + fte->FTE_TimeOut; + fte->FTE_ResultsHeldUTCTime = now + fte->FTE_HeldSeconds; + fte->FTE_Trace = WHERE; + UNX_LATCH( &fte->FTE_Latch ); + MPKNSS_UNLOCK(); + /* The next call may take a little time to complete */ + status = zPoolFreeze( fte->FTE_PoolName, fte->FTE_TimeOut, fte->FTE_FreezeApplicationStatus, &fte->FTE_ThawKey ); + MPKNSS_LOCK(); + X_LATCH( &fte->FTE_Latch ); + fte->FTE_FreezeStatus = status; + fte->FTE_FreezeIsDone = TRUE; + + if ( fte->FTE_FreezeStatus == zOK ) + { /* Must only call zPoolThawRequired/zPoolThaw if freeze returned zOK */ + /* Hang around until XML thaw call is made or we have waited + * long enough for the XML thaw call. We also wait in cases + * that zPoolFreeze returned an error. This allows the XML caller + * to retrieve the error before we free up our 'fte' that stores + * the error. + */ + do + { + fte->FTE_Trace = WHERE; + UNX_LATCH( &fte->FTE_Latch ); + LB_delay( 250 ); + X_LATCH( &fte->FTE_Latch ); + UNX_LATCH( &fte->FTE_Latch ); + MPKNSS_UNLOCK(); + /* This call will return non zOK when timeout occurs + * or deactivate requested or etc. + */ + status = zPoolThawRequired( fte->FTE_ThawKey ); + MPKNSS_LOCK(); + X_LATCH( &fte->FTE_Latch ); + } while ( (!fte->FTE_ThawNow) && (status == zOK) && (!fte->FTE_Unload) ); + + if ( status != zOK ) + { /* zPoolThawRequired caused us to call thaw we MUST pass in + * the error code that it returned. + */ + fte->FTE_ThawOpRetCode = status; + /* Setting will cause any NEW XML THAW calls to report + * an error. Plus the XML THAW will not overwrite our error + * with theirs. + */ + fte->FTE_ThawNow = TRUE; + } + else if ( fte->FTE_Unload ) + { + fte->FTE_ThawOpRetCode = zERR_USER_ABORTED; + fte->FTE_ThawNow = TRUE; + } + + UNX_LATCH( &fte->FTE_Latch ); + MPKNSS_UNLOCK(); + status = zPoolThaw( fte->FTE_ThawKey, fte->FTE_ThawOpRetCode ); + MPKNSS_LOCK(); + X_LATCH( &fte->FTE_Latch ); + fte->FTE_ThawStatus = status; + fte->FTE_ThawIsDone = TRUE; + zASSERT( status == zOK ); + } + + /* This holds the results for a little while which gives + * the XML caller time to check on the results. + */ + do + { + fte->FTE_Trace = WHERE; + UNX_LATCH( &fte->FTE_Latch ); + LB_delay( 250 ); + X_LATCH( &fte->FTE_Latch ); + } while ( (GetUTCTime() < fte->FTE_ResultsHeldUTCTime) && (!fte->FTE_Unload) ); + + /* This frees up our resources connected with the MNSS Pool Freeze */ + UNX_LATCH( &fte->FTE_Latch ); + FreezeThawRelease( fte ); + fte = NULL; +#if NSS_DEBUG IS_ENABLED + DBG_DebugPrintf(CYAN, "MNSS_zPoolFreezeThread is complete\n" ); +#endif + MPKNSS_UNLOCK(); + return(NULL); + +} /* End of MNSS_zPoolFreezeThread() */ + + +/* + * + * Notes - + * Caller must supply us with a use count on 'fte'. + */ +STATUS MNSS_zPoolFreezeThreadStart( + FreezeThawEntry_s *fte ) + +{ + THREAD threadID; + + FreezeThawUse( fte ); /* Get use count for thread */ + ZOS_StartThreadWithModuleHandle(threadID, "FreezeThawXML", + MNSS_zPoolFreezeThread, + 0, 0, fte, (LONG)MANAGE_ModuleHandle); + + if ( !threadID ) + { + FreezeThawRelease( fte ); + fte = NULL; + return( zERR_NO_MEMORY ); + } + return( zOK ); +} /* ENd of MNSS_zPoolFreezeThreadStart() */ + + +/* + * MNSS_zPoolFreeze() - + * Allocates 'fte' and starts thread that will do the work of an XML + * pool freeze/thaw. + * + * Returns - + * zOK if we were able to go async with our zPoolFreeze call. + */ +STATUS MNSS_zPoolFreeze( + unicode_t *poolName, + int holdSeconds, + int timeOutSeconds, + int applications, + GUID_t *userKey ) /* Output - user key used for status and thaw interfaces */ + +{ + STATUS status; + FreezeThawEntry_s *fte; + + ASSERT_MPKNSS_LOCK(); + /* Init callers guid to invalid so that we have a consistent + * interface. Plus we can detect if other routines called + * with a invalid GUID. + */ + *userKey = zINVALID_GUID; + fte = FreezeThawNew( &status, poolName, holdSeconds, timeOutSeconds, applications ); + if ( fte == NULL ) + { + return( status ); + } + *userKey = fte->FTE_UserKey; + X_LATCH( &MNSS_MasterFreezeLatch ); + DQ_ENQ( &MNSS_MasterFreezeList, fte, FTE_LinkAll ); + UNX_LATCH( &MNSS_MasterFreezeLatch ); + fte->FTE_Trace = WHERE; + /* Schedule a thread to do the work later (so we will not block for a long time) */ + fte->FTE_ThreadScheduled = FALSE; + status = MNSS_zPoolFreezeThreadStart( fte ); + UNX_LATCH( &fte->FTE_Latch ); + FreezeThawRelease( fte ); + fte = NULL; /* After schedule we MUST not use 'fte' again as it could + * already be freed. + */ + return( status ); + +} /* End of MNSS_zPoolFreeze() */ +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +STATUS MNDS_DestroyPoolDSObjects( + VirtInfo_s *virtInfo, + utf8_t *poolName, + BOOL isUtf8) +{ + STATUS status = zOK; + STATUS retCode = 0; + BOOL errDeleteNDSVol = FALSE; + BOOL errDeleteNDSPool = FALSE; + BOOL firstTime = TRUE; + UserID_t ndsObjectID; + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + utf8_t container[MAX_DN_CHARS]; + utf8_t object[MAX_DN_CHARS]; + utf8_t objectName[256]; + utf8_t volName[zMAX_COMPONENT_NAME]; +//#ifndef __linux__ + utf8_t virtualServerName[zMAX_COMPONENT_NAME]; + utf8_t cifsVirtualServerName[MAX_CIFS_VIRTUAL_SERVER_NAME+1]; +//#endif + UserID_t guid; + utf8_t *errorString; + GUID_t cookie; + BOOL isDeleted; + + /* pool name to unicode */ + if (isUtf8) + { + if (utf2uni(poolName, uniPoolName, sizeof(uniPoolName)) == -1) + { + goto exit; + } + } + else + { + status = zERR_NOT_SUPPORTED; + goto exit; + } + + firstTime = TRUE; + while ((status = GetNextVolumeInfo(uniPoolName, firstTime, FALSE, &cookie, uniVolName, sizeof(uniVolName))) == zOK) + { + firstTime = FALSE; + + if ((status = NSSVolumeFound(uniVolName, FALSE, &isDeleted, NULL, NULL, NULL, &ndsObjectID)) == zOK) + { + if (isDeleted) + { + continue; + } + status = MNSS_GetNDSNameFromGUID(NULL, &ndsObjectID, objectName); + } + + if (status != zOK) + { + if ((status = MNDS_GetServerNameFromNDS(object, container)) != zOK) + { + errDeleteNDSVol = TRUE; + retCode = status; + continue; + } + + uni2utf(uniVolName, volName, sizeof(volName)); + strcat(object,"_"); + strcat(object, volName); + } + else + { + LB_ParseDSObjectName(objectName, container, object); + } + + status = MNDS_RemoveObjectFromNDS(container, object, "Volume"); + if (status != zOK) + { + retCode = status; + errDeleteNDSVol = TRUE; + continue; + } + } + + /* delete NDS pool object */ + if ((status = MNSS_GetPoolNDSName(poolName, + object, container, &guid, &errorString)) != zOK) + { +#if zLINUX + syslog(LOG_INFO, "MNDS_DestroyPoolDSObjects: MNSS_GetPoolNDSName returned %d\n", status); +#endif + if ((status = MNDS_GetServerNameFromNDS(object, container)) != zOK) + { + errDeleteNDSPool = TRUE; + retCode = status; + } + else + { + strcat(object,"_"); + strcat(object,(char *)poolName); + strcat(object, "_POOL"); + } + } + if (!errDeleteNDSPool) + { + if ((status = MNDS_RemoveObjectFromNDS(container, object, "nssfsPool")) + != zOK) + { + errDeleteNDSPool = TRUE; + retCode = status; + } + } + + // If we could not delete the pool object - either could not get the guid + // or the NDS name, or we got an -601 back from the remove function - then + // try to get the cluster pool name and delete that. +//#ifndef __linux__ + if ((errDeleteNDSPool == TRUE) || + (status == ERR_NO_SUCH_ENTRY)) + { + errDeleteNDSPool = FALSE; + if ((status = NWCLSTR_PoolNames((BYTE *)poolName, + (BYTE *)object, (BYTE *)virtualServerName, (BYTE *)cifsVirtualServerName)) != zOK) + { + strcat(object,"_"); + strcat(object,(char *)poolName); + strcat(object, "_POOL"); + } + // Delete the pool cluster object. + if ((status = MNDS_RemoveObjectFromNDS(container, object, NULL)) != zOK) + { + errDeleteNDSPool = TRUE; + retCode = status; + } + } +//#endif + + if (errDeleteNDSPool == TRUE) + { + status = retCode; + goto exit; + } + + if(errDeleteNDSVol == TRUE) + { + status = retCode; + goto exit; + } + +exit: + + return status; +} + +/* + * Remove the volume on a pool + */ +void MNDS_RemovePoolVolumes( + VirtInfo_s *virtInfo, + utf8_t *poolName) +{ + STATUS status; + BOOL firstTime = TRUE; + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + utf8_t volName[zMAX_COMPONENT_NAME]; + GUID_t cookie; + BOOL isDeleted; + utf8_t *returnMsg; + + /* pool name to unicode */ + if (utf2uni(poolName, uniPoolName, sizeof(uniPoolName)) == -1) + { + goto exit; + } + + firstTime = TRUE; + while ((status = GetNextVolumeInfo(uniPoolName, firstTime, FALSE, &cookie, uniVolName, sizeof(uniVolName))) == zOK) + { + firstTime = FALSE; + + if ((status = NSSVolumeFound(uniVolName, FALSE, &isDeleted, NULL, NULL, NULL, NULL)) == zOK) + { + if (isDeleted) + { + continue; + } + uni2utf(uniVolName, volName, sizeof(volName)); + if (MNSS_RemoveVolume(volName, TRUE, TRUE, &returnMsg, TRUE) != zOK) + { +#if zLINUX + syslog(LOG_WARNING, "Volume %s not deleted from pool %s during pool delete\n", volName, poolName); +#endif + } + } + } + +exit: + return; +} + +#endif + +/**************************************************************************** + * Return the name non-translateable name for pool state + ****************************************************************************/ +char * MLIB_GetPoolStateName( + NINT state) + +{ + char *stateName; + +/*------------------------------------------------------------------------- + * Calculate the STATE name + *-------------------------------------------------------------------------*/ + switch (state) + { + case zVOLSTATE_UNKNOWN: + default: + stateName = MSGNot("unknown"); + break; + + case zVOLSTATE_ACTIVE: + stateName = MSGNot("active"); + break; + + case zVOLSTATE_MAINTENANCE: + stateName = MSGNot("maintenance"); + break; + + case zVOLSTATE_DEACTIVE: + stateName = MSGNot("deactive"); + break; + } + + return stateName; +} + +#if zLINUX && !defined(__KERNEL__) +STATUS LINUX_GetPoolSharedState( + BOOL openEVMSEngine, + utf8_t *poolName, + BOOL *isShared) +{ + int ccode; + object_handle_t regionHandle; + PoolDeviceInfoArray_s *deviceArray = NULL; + handle_object_info_t *pool_object_info = NULL; + storage_object_info_t *pool_info = NULL; + NINT i; + QUAD getInfoMask; + zInfo_s info; + NINT errIndex; + BYTE path[zMAX_FULL_NAME]; + + sprintf((char *)path, "%s%s", ADMIN_POOL_PATH, poolName); + getInfoMask = zGET_POOL_INFO; + if (GetZInfo(path, getInfoMask, &info, &errIndex) == zOK) + { + *isShared = (info.pool.features.enabled & zPOOL_FEATURE_SHARED_CLUSTER) ? TRUE : FALSE; + return zOK; + } + + *isShared = FALSE; + if (openEVMSEngine) + { + ccode = evmsOpenEngine(EVMS_ENGINE_READONLY); + if (ccode != 0) + { + goto exit; + } + } + + ZOS_evms_get_object_handle_for_name(ccode, REGION, poolName, ®ionHandle); + if (ccode != 0) + { + goto close_engine; + } + + /* get object info */ + ZOS_evms_get_info(ccode, regionHandle, &pool_object_info); + if (ccode != 0) + { + goto close_engine; + } + pool_info = &pool_object_info->info.region; + + if (pool_info->child_objects != NULL && pool_info->child_objects->count == 0) + { + goto close_engine; + } + + ccode = linux_getDeviceFromChildObjects(NULL, NULL, &deviceArray, + pool_object_info, pool_info->child_objects); + if (ccode != 0) + { + goto close_engine; + } + + for (i = 0; i < deviceArray->count; i++) + { + if (deviceArray->deviceInfo[i].isShared) + { + *isShared = TRUE; + break; + } + } + +close_engine: + if (deviceArray != NULL) + { + free(deviceArray); + } + + if (pool_object_info != NULL) + { + ZOS_evms_free(pool_object_info); + } + + if (openEVMSEngine) + { + evmsCloseEngine(); + } +exit: + return ccode; +} + + +STATUS LINUX_GetPoolSnapshotType( + BOOL openEVMSEngine, + utf8_t *poolName, + POOLSNAP_TYPE *snapshotType) +{ + int ccode; + int i; + object_handle_t volumeHandle; + handle_object_info_t *info = NULL; + extended_info_array_t *info_array = NULL; + char volumeName[256]; + + *snapshotType = POOL_NORMAL; + if (openEVMSEngine) + { + ccode = evmsOpenEngine(EVMS_ENGINE_READONLY); + if (ccode != 0) + { + goto exit; + } + } + + strcpy(volumeName, EVMS_DEVICE_PATH); + strcat(volumeName, poolName); + + ZOS_evms_get_object_handle_for_name(ccode, VOLUME, volumeName, &volumeHandle); + if (ccode != 0) + { + goto close_engine; + } + + /* get object info */ + ZOS_evms_get_info(ccode, volumeHandle, &info); + if (ccode != 0) + { + goto close_engine; + } + + ZOS_evms_get_extended_info(ccode, info->info.volume.object, NULL, &info_array); + if (ccode != 0) + { + goto close_engine; + } + + for(i = 0; i < info_array->count; i++) + { + if(!strcmp(info_array->info[i].name, "SnapShot")) + { + /* This pool has snapshots */ + *snapshotType = POOL_SNAPSHOTORIGIN; + break; + } + else if (!strcmp(info_array->info[i].name, "Original") || + !strcmp(info_array->info[i].name, "iOriginal")) + { + /* This is a snapshot pool */ + *snapshotType = POOL_SNAPSHOT; + break; + } + } + +close_engine: + if (info_array != NULL) + { + ZOS_evms_free(info_array); + } + + if (info != NULL) + { + ZOS_evms_free(info); + } + + if (openEVMSEngine) + { + evmsCloseEngine(); + } +exit: + return ccode; +} + +#endif + + +#if defined(__KERNEL__) +/**************************************************************************** + * Get the list of volumes on a pool + *****************************************************************************/ +STATUS GetNextVolumeInfo( + unicode_t *uniPoolName, + BOOL firstTime, + BOOL deletedVolume, + GUID_t *cookie, + unicode_t *uniVolName, + NINT uniVolNameLen + ) +{ + GeneralMsg_s genMsg; + Pool_s *pool; + Volume_s *vol = NULL; + STATUS status; + Volume_s *holdVolume = NULL; + GUID_t holdCookie; + BOOL foundAVolume = FALSE; + + ASSERT_MPKNSS_LOCK(); + + if (firstTime) + { + *cookie = zZERO_GUID; + } + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + pool = COMN_PoolNameLookup(&genMsg, uniPoolName, FALSE, NULL); + if (pool == NULL) + { + status = GetErrno(&genMsg); + return(status); + } + + X_LATCH(&pool->cvsLatch); + POOL_FOR_EACH_LOADED_VOLUME(pool, vol) + { + if(deletedVolume) + { + /* Skip non-deleted volumes. */ + if (vol->VOLpState != zVOL_PSTATE_DELETION) + { + continue; + } + } + else + { + if (!VOL_ACCESSIBLE1(vol)) + { + continue; + } + } + if (LB_GUIDCompare(cookie, &vol->volumeID) < 0) + { + if (!foundAVolume || (LB_GUIDCompare(&holdCookie, &vol->volumeID) > 0)) + { + holdVolume = vol; + holdCookie = vol->volumeID; + foundAVolume = TRUE; + } + } + } + UNX_LATCH(&pool->cvsLatch); + COMN_Release( &pool ); + + if (foundAVolume) + { + *cookie = holdCookie; + status = COMN_GetVolumeName(&genMsg, holdVolume, uniVolName, + uniVolNameLen); + if (status != zOK) + { + status = GetErrno(&genMsg); + } + } + else + { + status = zERR_END_OF_FILE; + } + return status; +} + + +/**************************************************************************** + * Get the LSS features + *****************************************************************************/ +STATUS GetLSSFeatures(LONG lssID, + QUAD *volSupportedFeatures, + QUAD *volDefaultEnabledFeatures, + QUAD *volChangableFeatures) +{ + LSSInfo_s *lp; + NINT numLss; + NINT idx; + GeneralMsg_s genMsg; + BYTE *lssBuf; + NINT bufSize; + STATUS status = zOK; + + ASSERT_MPKNSS_LOCK(); + + /* Assume up to 10 LSS modules loaded by default. */ + bufSize = 10 * sizeof(LSSInfo_s); + +startOver: + lssBuf = zalloc( bufSize ); + if (lssBuf == NULL) + { + status = zERR_NO_MEMORY; + return status; + } + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + status = COMN_GetRegisteredLSSFeatures(&genMsg,&numLss,lssBuf,bufSize); + if (status == zFAILURE) + { + if (GetErrno(&genMsg) == zERR_BUFFER_TOO_SMALL) + { + bufSize = numLss * sizeof(LSSInfo_s); + free(lssBuf); + goto startOver; + } + free(lssBuf); + return status; + } + + lp=(LSSInfo_s *)lssBuf; + for (idx=0; idxlssID == lssID) + { + *volSupportedFeatures = lp->volSupportedFeatures; + *volDefaultEnabledFeatures = lp->volDefaultEnabledFeatures; + *volChangableFeatures = lp->volChangableFeatures; + break; + } + lp++; + } + + free(lssBuf); + return status; +} +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) + +STATUS VP_RAVStatusHeaderToXML( VirtInfo_s *virtInfo, ZVP_StatusHeader_s *zVS ) +{ + STATUS status; + + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), zVS->ZSH_ResultsReturned ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), zVS->ZSH_ResultsTotal ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), zVS->ZSH_ResultsReturned ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), zVS->ZSH_Format ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), zVS->ZSH_Flag ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), zVS->ZSH_SearchKey ); + status = VIRT_ssprintf( virtInfo, MSGNot("\n"), zVS->ZSH_NextKey ); + return status; +} /* End of VP_RAVStatusHeaderToXML() */ +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +STATUS VP_RAVStatusToXML( VirtInfo_s *virtInfo, ZVP_StatusEntry_s *cEntry ) +{ + STATUS status; + Time_t now; + char aBuffer[80]; + + zASSERT( GUID_FORMAT_SIZE <= sizeof(aBuffer) ); // Must be at least GUID_FORMAT_SIZE for GUIDs + + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_USERKEY" "ATR_VALUE"=\"%Lu\"/>\n"), cEntry->ZSE_Key ); + bzero(aBuffer, sizeof(aBuffer)); + LB_GUIDToString( &cEntry->ZSE_poolVolID, sizeof(aBuffer), aBuffer ); + (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_POOLGUID" "ATR_VALUE"=\"%s\"/>\n"), aBuffer ); + /* No CDATA_START and CDATA_END as poolName should be legal PLUS you cannot use in an attribute!!! */ + // Linux userspace is broken in that NSS does not support %U!!! + (void)VIRT_ssprintf( virtInfo, "<"TAG_POOLNAME" "ATR_VALUE"=\"" ); + (void)VIRT_AddUnicode(virtInfo, cEntry->ZSE_PoolName ); + (void)VIRT_ssprintf( virtInfo, "\"/>\n" ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), cEntry->ZSE_Status ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), cEntry->ZSE_FinalStatus ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), cEntry->ZSE_FinalStatusSetter ); + now = cEntry->ZSE_UTCStart; + (void)VIRT_ssprintf( virtInfo, "\n", now, UTCTime2Str(now, &aBuffer[0]) ); + now = cEntry->ZSE_UTCEnd; + (void)VIRT_ssprintf( virtInfo, "\n", now, UTCTime2Str(now, &aBuffer[0]) ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), cEntry->ZSE_State ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), cEntry->ZSE_vmFlag ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), cEntry->ZSE_cmd ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), cEntry->ZSE_UIOptions ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), cEntry->ZSE_DebugLevel ); + status = VIRT_ssprintf( virtInfo, MSGNot("\n"), cEntry->ZSE_Terminate ); + + return status; + +} /* End of VP_RAVStatusToXML() */ +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +STATUS VP_VS_Display_LossLimits_s( + VirtInfo_s *virtInfo, + const ZSR_LossLimits_s *limits ) +{ + + VIRT_ssprintf( virtInfo, "\n", limits->ZLL_PruneIV ? "Yes" : "No" ); + VIRT_ssprintf( virtInfo, "\n", limits->ZLL_PruneUnknownLosses ? "Yes" : "No" ); +//g VIRT_ssprintf( virtInfo, "\n", limits->ZLL_BlockLossMax ); + return VIRT_ssprintf( virtInfo, "\n", limits->ZLL_FileLossMax ); + +} /* End of VP_VS_Display_LossLimits_s() */ +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +STATUS VP_RebuildStatusToXML( VirtInfo_s *virtInfo, ZVP_StatusHeader_s *zVS ) +{ + ZVP_StatusEntry_s *cEntry; + ZVP_RebuildStatusEntry_s *entry; + STATUS status; + unsigned int item = 0; + + (void)VIRT_ssprintf( virtInfo, MSGNot("") ); + (void)VP_RAVStatusHeaderToXML( virtInfo, zVS ); + + for ( item = 0; item < zVS->ZSH_ResultsReturned; ++item ) + { + cEntry = &zVS->ZSH_Entry[item]; + entry = (ZVP_RebuildStatusEntry_s *)cEntry; + + (void)VIRT_ssprintf( virtInfo, MSGNot("") ); + (void)VP_RAVStatusToXML( virtInfo, cEntry ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), entry->ZRSE_RezidThreshold ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), entry->ZRSE_Purge ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), entry->ZRSE_UIPruneWait ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), entry->ZRSE_UIPruneSet ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), entry->ZRSE_UIPruneStatus ); + (void)VIRT_ssprintf( virtInfo, MSGNot("") ); + (void)VP_VS_Display_LossLimits_s( virtInfo, &entry->ZRSE_LimitStart ); + (void)VIRT_ssprintf( virtInfo, MSGNot("") ); +//ggg (void)VIRT_ssprintf( virtInfo, MSGNot("") ); +//ggg (void)VP_VS_Display_LossLimits_s( virtInfo, &entry->ZRSE_UIPruneStatus ); +//ggg (void)VIRT_ssprintf( virtInfo, MSGNot("") ); + (void)VIRT_ssprintf( virtInfo, MSGNot("") ); + } + status = VIRT_ssprintf( virtInfo, MSGNot("") ); + return status; + +} /* End of VP_RebuildStatusToXML() */ +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +STATUS VP_VerifyStatusToXML( VirtInfo_s *virtInfo, ZVP_StatusHeader_s *zVS ) +{ + ZVP_StatusEntry_s *cEntry; + ZVP_VerifyStatusEntry_s *entry; + STATUS status; + unsigned int item = 0; + + (void)VIRT_ssprintf( virtInfo, MSGNot("") ); + (void)VP_RAVStatusHeaderToXML( virtInfo, zVS ); + + for ( item = 0; item < zVS->ZSH_ResultsReturned; ++item ) + { + cEntry = &zVS->ZSH_Entry[item]; + entry = (ZVP_VerifyStatusEntry_s *)cEntry; + + (void)VIRT_ssprintf( virtInfo, MSGNot("") ); + (void)VP_RAVStatusToXML( virtInfo, cEntry ); +//g (void)VIRT_ssprintf( virtInfo, MSGNot("<"TAG_FILENAME" "ATR_VALUE"=\"%U\"/>\n"), entry->ZVSE_SavedFileName ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), entry->ZVSE_CrossValidation ); + (void)VIRT_ssprintf( virtInfo, MSGNot("") ); + } + status = VIRT_ssprintf( virtInfo, MSGNot("") ); + return status; + +} /* End of VP_VerifyStatusToXML() */ +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +/* + * MNSS_ProcessPoolVerify() - + * Starts a verify via XML. + */ +STATUS MNSS_ProcessPoolVerify( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + int action; + QUAD userKey; + QUAD fileLossMax = 0; + QUAD uiOptions = 0; + QUAD debugLevel = 0; + STATUS uiPruneStatus = 0; + BOOL uiOptionsSet = FALSE; + BOOL debugLevelSet = FALSE; + BOOL uiPruneStatusSet = FALSE; + STATUS status3; + STATUS status; +// unicode_t uni_fileName[2048]; + unicode_t uni_poolName[64]; + +#define TAG_NAMETYPE "nameType" +#define TAG_ITEMTYPE "itemType" +#define TAG_ITEMKEY "itemKey" + +#define TAG_UIPRUNESTATUS "uiPruneStatus" +#define TAG_UIOPTIONS "uiOptions" +#define TAG_DEBUGLEVEL "debugLevel" +#define TAG_PRUNEIV "pruneIV" // Use is not recommended +#define TAG_PRUNEUNKNOWNLOSSES "pruneUnknownLosses" +#define TAG_FILELOSSMAX "fileLossMax" +#define TAG_UIPRUNEWAIT "uiPruneWait" + + const TagRequest_s tags[] = + { + {TAG_USERKEY, TR_OPTIONAL|TR_CONTENT_REQUIRED}, + {TAG_POOLNAME, TR_OPTIONAL|TR_CONTENT_REQUIRED}, + {TAG_ACTION, TR_CONTENT_REQUIRED}, + {TAG_FILENAME, TR_OPTIONAL|TR_CONTENT_REQUIRED}, + {"multiple", TR_OPTIONAL}, // For zPOOL_VERIFY_DETAILS_WITH_KEY and zPOOL_REBUILD_DETAILS_WITH_KEY + {"crossValidation", TR_OPTIONAL}, // For zPOOL_VERIFY_START + {"reconfigure", TR_OPTIONAL}, // For zPOOL_VERIFY_DAEMON_SET + {"reset", TR_OPTIONAL}, // For zPOOL_VERIFY_DAEMON_SET (Daemon should only use) + {"wait", TR_OPTIONAL}, // For zPOOL_VERIFY_DETAILS_WITH_KEY and zPOOL_REBUILD_DETAILS_WITH_KEY + {"purge", TR_OPTIONAL}, // For zPOOL_REBUILD_START + {"rezidThreshold", TR_OPTIONAL|TR_CONTENT_REQUIRED},// For zPOOL_REBUILD_START + {TAG_ZID, TR_OPTIONAL}, // For zPOOL_REVERSE_NAME_LOOKUP + {TAG_NAMESPACE, TR_OPTIONAL}, // For zPOOL_REVERSE_NAME_LOOKUP + {TAG_NAMETYPE, TR_OPTIONAL}, // For zPOOL_REVERSE_NAME_LOOKUP + {TAG_VOLUMEID, TR_OPTIONAL}, // For zPOOL_REVERSE_NAME_LOOKUP + {TAG_ITEMTYPE, TR_OPTIONAL}, // For zPOOL_RAV_ITEM_REMOVE_WITH_KEY + {TAG_ITEMKEY, TR_OPTIONAL}, // For zPOOL_RAV_ITEM_REMOVE_WITH_KEY + {TAG_PRUNEIV, TR_OPTIONAL}, // For zPOOL_REBUILD_START and zPOOL_REBUILD_LIMIT_POST_WITH_KEY + {TAG_PRUNEUNKNOWNLOSSES, TR_OPTIONAL}, // For zPOOL_REBUILD_START and zPOOL_REBUILD_LIMIT_POST_WITH_KEY + {TAG_FILELOSSMAX, TR_OPTIONAL|TR_CONTENT_REQUIRED}, // For zPOOL_REBUILD_START and zPOOL_REBUILD_LIMIT_POST_WITH_KEY + {TAG_DEBUGLEVEL, TR_OPTIONAL|TR_CONTENT_REQUIRED }, // For zPOOL_REBUILD_START, zPOOL_RAV_SET_WITH_KEY and zPOOL_VERIFY_START + {TAG_UIPRUNEWAIT, TR_OPTIONAL}, // For zPOOL_REBUILD_START + {TAG_UIOPTIONS, TR_OPTIONAL|TR_CONTENT_REQUIRED }, // For zPOOL_REBUILD_START, zPOOL_RAV_SET_WITH_KEY and zPOOL_VERIFY_START + {TAG_UIPRUNESTATUS, TR_OPTIONAL|TR_CONTENT_REQUIRED }, // For zPOOL_RAV_SET_WITH_KEY + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + USERKEY = 0, + POOLNAME = 1, + ACTION = 2, + FILENAME = 3, + MULTIPLE = 4, + CROSSVALIDATION = 5, + RECONFIGURE = 6, + RESET = 7, + WAIT = 8, + PURGE = 9, + REZIDTHRESHOLD = 10, + ZID = 11, + NAMESPACE = 12, + NAMETYPE = 13, + VOLUMEID = 14, + ITEMTYPE = 15, + ITEMKEY = 16, + PRUNEIV = 17, + PRUNEUNKNOWNLOSSES = 18, + FILELOSSMAX = 19, + DEBUGLEVEL = 20, + UIPRUNEWAIT = 21, + UIOPTIONS = 22, + UIPRUNESTATUS = 23, + }; + + ASSERT_MPKNSS_LOCK(); + + status = MNSS_GetTagContents(virtInfo, tagName, element, tags, tagContent); + if ( status != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto errorInXMLBufferAlready; + } + return status; + } + action = atoi( tagContent[ACTION].content ); + if ( (action == zPOOL_VERIFY_DETAILS_WITH_KEY) || + (action == zPOOL_REBUILD_DETAILS_WITH_KEY) || + (action == zPOOL_RAV_REMOVE_WITH_KEY) || +//ggg (action == zPOOL_VERIFY_DAEMON_SAVED_WITH_KEY) || + (action == zPOOL_RAV_ITEM_REMOVE_WITH_KEY) || + (action == zPOOL_RAV_SET_WITH_KEY) || +//ggg (action == zPOOL_REBUILD_LIMIT_POST_WITH_KEY) || + (action == zPOOL_RAV_STATUS_WITH_KEY) ) // Command(s) that require userKey + { + if ( !(tagContent[USERKEY].flags & TR_TAG_FOUND) ) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, MSGNot("Tag " TAG_USERKEY " required given action value") ); + goto errorInXMLBufferAlready; + } + userKey = strtouq( tagContent[USERKEY].content, NULL, 0 ); + } + if ( (action == zPOOL_VERIFY_START) || (action == zPOOL_RAV_STATUS) || // Commands that require poolname + (action == zPOOL_REBUILD_START) ) + { + if ( !(tagContent[POOLNAME].flags & TR_TAG_FOUND) ) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, MSGNot("Tag " TAG_POOLNAME " required given action value") ); + goto errorInXMLBufferAlready; + } + /* Change the pool name to unicode. */ + status = utf2uni(tagContent[POOLNAME].content, uni_poolName, sizeof(uni_poolName)); + if ( status == -1 ) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting pool name to unicode")); + goto errorInXMLBufferAlready; + } + } + if ( (action == zPOOL_REBUILD_START) || + (action == zPOOL_VERIFY_START) || + (action == zPOOL_RAV_SET_WITH_KEY) ) // Command(s) that OPTIONALY require debugLevel + { + if ( tagContent[DEBUGLEVEL].flags & TR_TAG_FOUND ) + { + debugLevelSet = TRUE; + debugLevel = strtouq( tagContent[DEBUGLEVEL].content, NULL, 0 ); + } + else + { // Default if not specified + debugLevelSet = FALSE; + debugLevel = 0; + } + } + if ( action == zPOOL_RAV_SET_WITH_KEY ) // Command(s) that OPTIONALY require uiPruneStatus + { + if ( tagContent[UIPRUNESTATUS].flags & TR_TAG_FOUND ) + { + uiPruneStatusSet = TRUE; + uiPruneStatus = strtoul( tagContent[UIPRUNESTATUS].content, NULL, 0 ); + } + else + { // Default if not specified + uiPruneStatusSet = FALSE; + uiPruneStatus = zOK; + } + } + if ( (action == zPOOL_REBUILD_START) || + (action == zPOOL_VERIFY_START) || + (action == zPOOL_RAV_SET_WITH_KEY) ) // Command(s) that OPTIONALY require uiOptions + { + if ( tagContent[UIOPTIONS].flags & TR_TAG_FOUND ) + { + uiOptionsSet = TRUE; + uiOptions = strtouq( tagContent[UIOPTIONS].content, NULL, 0 ); + } + else + { // Default if not specified + uiOptionsSet = FALSE; + uiOptions = 0; + } + } + if ( action == zPOOL_REBUILD_START ) +//ggg (action == zPOOL_REBUILD_LIMIT_POST_WITH_KEY) ) // Command(s) that OPTIONALY require fileLossMax + { + if ( tagContent[FILELOSSMAX].flags & TR_TAG_FOUND ) + { + fileLossMax = strtouq( tagContent[FILELOSSMAX].content, NULL, 0 ); + } + else + { // Default if not specified + fileLossMax = 100; + } + } +#if 0 + if ( action == zPOOL_VERIFY_DAEMON_SAVED_WITH_KEY ) // Commands that require file name + { + if ( !(tagContent[FILENAME].flags & TR_TAG_FOUND) ) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, MSGNot("Tag " TAG_FILENAME " required given action value") ); + goto errorInXMLBufferAlready; + } + /* Change the pool name to unicode. */ + status = utf2uni(tagContent[FILENAME].content, uni_fileName, sizeof(uni_fileName)); + if ( status == -1 ) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, MSGNot("Error converting file name to unicode")); + goto errorInXMLBufferAlready; + } + } +#endif + // + // No returns or goto's in the switch statement because we have added the start tag + // and must add the end tag to have legal XML. + // + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + switch ( action ) + { + case zPOOL_VERIFY_START: + { + BOOL crossValidation = FALSE; + ZVS_Start_s *buf; + buf = malloc( sizeof(*buf) ); + status = zERR_NO_MEMORY; + if ( buf != NULL ) + { + bzero( buf, sizeof(*buf) ); + if ( (tagContent[CROSSVALIDATION].flags & TR_TAG_FOUND) ) + { + crossValidation = TRUE; + } + unicpy( buf->ZVSS_PoolName, uni_poolName ); + buf->ZVSS_CrossValidation = crossValidation; + buf->ZVSS_DebugLevel = debugLevel; + buf->ZVSS_UIOptions = uiOptions; + status = zPoolVerify( zPOOL_VERIFY_START, sizeof(*buf), buf ); + if ( status == zOK ) + { + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), buf->ZVSS_Key ); + } + free( buf ); + } + break; + } + case zPOOL_RAV_STATUS: + status = zPoolVerify( zPOOL_RAV_STATUS, sizeof(uni_poolName), uni_poolName ); + break; +#if 0 + case zPOOL_VERIFY_DAEMON_SET: + { + BOOL reset = FALSE; + BOOL reconfigure = FALSE; + ZVS_DaemonSet_s *buf; + + buf = malloc( sizeof(*buf) ); + status = zERR_NO_MEMORY; + if ( buf != NULL ) + { + bzero( buf, sizeof(*buf) ); + if ( (tagContent[RECONFIGURE].flags & TR_TAG_FOUND) ) + { + reconfigure = TRUE; + } + if ( (tagContent[RESET].flags & TR_TAG_FOUND) ) + { + reset = TRUE; + } + buf->ZDS_Reconfigure = reconfigure; + buf->ZDS_Reset = reset; + status = zPoolVerify( zPOOL_VERIFY_DAEMON_SET, sizeof(*buf), buf ); + free( buf ); + } + break; + } +#endif +#if 0 + case zPOOL_VERIFY_DAEMON_GET: + { + ZVS_DaemonGet_s *buf; + + buf = malloc( sizeof(*buf) ); + status = zERR_NO_MEMORY; + if ( buf != NULL ) + { + bzero( buf, sizeof(*buf) ); + status = zPoolVerify( zPOOL_VERIFY_DAEMON_GET, sizeof(*buf), buf ); + if ( status == zOK ) + { + if ( buf->ZDG_Reconfigure ) + { + (void)VIRT_ssprintf( virtInfo, MSGNot("\n") ); + } + } + free( buf ); + } + break; + } +#endif + case zPOOL_VERIFY_DETAILS_WITH_KEY: + { + ZVP_StatusHeader_s *buf; + NINT flags; + unsigned int items; + unsigned int size; + + if ( tagContent[MULTIPLE].flags & TR_TAG_FOUND ) + { + flags = ZSH_FLAG_MULTIPLE; + items = 10; + } + else + { + flags = ZSH_FLAG_SINGLE; + items = 1; + } + if ( tagContent[WAIT].flags & TR_TAG_FOUND ) + { // This will cause a deadlock as of May 2004 because ADMIN owns resources when it calls us! + flags |= ZSH_FLAG_WAIT; + } + size = offsetof(ZVP_StatusHeader_s,ZSH_Entry) + ((items) * sizeof(ZVP_VerifyStatusEntry_s)); + buf = malloc( size ); + status = zERR_NO_MEMORY; + if ( buf != NULL ) + { + bzero( buf, size ); + buf->ZSH_Format = ZVP_VSH_FORMAT; + buf->ZSH_Flag = flags; + buf->ZSH_SearchKey = userKey; + buf->ZSH_ResultsNeeded = items; + status = zPoolVerify( zPOOL_VERIFY_DETAILS_WITH_KEY, size, buf ); + if ( status == zOK ) + { + status = VP_VerifyStatusToXML( virtInfo, buf ); + } + free( buf ); + } + break; + } + case zPOOL_RAV_STATUS_WITH_KEY: + status = zPoolVerify( zPOOL_RAV_STATUS_WITH_KEY, sizeof(userKey), &userKey ); + break; + case zPOOL_RAV_REMOVE_WITH_KEY: + status = zPoolVerify( zPOOL_RAV_REMOVE_WITH_KEY, sizeof(userKey), &userKey ); + break; + case zPOOL_RAV_ITEM_REMOVE_WITH_KEY: + { + ZVS_ItemRemoveWithKey_s *buf; + buf = malloc( sizeof(*buf) ); + status = zERR_NO_MEMORY; + if ( buf != NULL ) + { + bzero( buf, sizeof(*buf) ); + if ( !(tagContent[ITEMTYPE].flags & TR_TAG_FOUND) ) + { + MNSS_BuildResult2(virtInfo, zERR_XML_TAG_NOT_FOUND, MSGNot("Tag " TAG_ITEMTYPE " required given action value"), WHERE, NULL ); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + free( buf ); + goto errorInXMLBufferAlready; + } + buf->ZIRWK_ItemType = strtoul( tagContent[ITEMTYPE].content, NULL, 0 ); // type of item being removed + if ( !(tagContent[ITEMKEY].flags & TR_TAG_FOUND) ) + { + MNSS_BuildResult2(virtInfo, zERR_XML_TAG_NOT_FOUND, MSGNot("Tag " TAG_ITEMKEY " required given action value"), WHERE, NULL ); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + free( buf ); + goto errorInXMLBufferAlready; + } + buf->ZIRWK_ItemKey = strtouq( tagContent[ITEMKEY].content, NULL, 0 ); // Keys <= than this will be removed + buf->ZIRWK_Key = userKey; + status = zPoolVerify( zPOOL_RAV_ITEM_REMOVE_WITH_KEY, sizeof(*buf), buf ); + free( buf ); + } + break; + } +#if 0 + case zPOOL_VERIFY_DAEMON_SAVED_WITH_KEY: + { + ZVS_Saved_s *buf; + buf = malloc( sizeof(*buf) ); + status = zERR_NO_MEMORY; + if ( buf != NULL ) + { + bzero( buf, sizeof(*buf) ); + buf->ZVSS_Key = userKey; +//g unicpy( buf->ZVSS_FileName, uni_fileName ); + status = zPoolVerify( zPOOL_VERIFY_DAEMON_SAVED_WITH_KEY, sizeof(*buf), buf ); + free( buf ); + } + break; + } +#endif + case zPOOL_REVERSE_NAME_LOOKUP: + { + ZVS_ReverseNameLookup_s *buf; + + buf = malloc( sizeof(*buf) ); + status = zERR_NO_MEMORY; + if ( buf != NULL ) + { + bzero( buf, sizeof(*buf) ); + if ( !(tagContent[ZID].flags & TR_TAG_FOUND) ) + { + MNSS_BuildResult2(virtInfo, zERR_XML_TAG_NOT_FOUND, MSGNot("Tag " TAG_ZID " required given action value"), WHERE, NULL ); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + free( buf ); + goto errorInXMLBufferAlready; + } + buf->ZRNL_Zid = strtouq( tagContent[ZID].content, NULL, 0 ); + if ( !(tagContent[NAMESPACE].flags & TR_TAG_FOUND) ) + { + MNSS_BuildResult2(virtInfo, zERR_XML_TAG_NOT_FOUND, MSGNot("Tag " TAG_NAMESPACE " required given action value"), WHERE, NULL ); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + free( buf ); + goto errorInXMLBufferAlready; + } + buf->ZRNL_NameSpace = strtoul( tagContent[NAMESPACE].content, NULL, 0 ); + if ( !(tagContent[NAMETYPE].flags & TR_TAG_FOUND) ) + { + MNSS_BuildResult2(virtInfo, zERR_XML_TAG_NOT_FOUND, MSGNot("Tag " TAG_NAMETYPE " required given action value"), WHERE, NULL ); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + free( buf ); + goto errorInXMLBufferAlready; + } + buf->ZRNL_NameType = strtoul( tagContent[NAMETYPE].content, NULL, 0 ); + if ( !(tagContent[VOLUMEID].flags & TR_TAG_FOUND) ) + { + MNSS_BuildResult2(virtInfo, zERR_XML_TAG_NOT_FOUND, MSGNot("Tag " TAG_VOLUMEID " required given action value"), WHERE, NULL ); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + free( buf ); + goto errorInXMLBufferAlready; + } + status = LB_GUIDFromUTF8( (utf8_t *)(tagContent[VOLUMEID].content), &buf->ZRNL_VolumeID ); + if ( status != zOK ) + { + MNSS_BuildResult2(virtInfo, status, MSGNot("Tag " TAG_VOLUMEID " content error"), WHERE, NULL ); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + free( buf ); + goto errorInXMLBufferAlready; + } + status = zPoolVerify( zPOOL_REVERSE_NAME_LOOKUP, sizeof(*buf), buf ); + if ( status == zOK ) + { + (void)VIRT_ssprintf( virtInfo, ""CDATA_START ); + status = VIRT_AddUnicode( virtInfo, buf->ZRNL_FullName ); + if ( status != zOK ) + { + free( buf ); + goto exit2; + } + (void)VIRT_ssprintf( virtInfo, CDATA_END"\n" ); + (void)VIRT_ssprintf( virtInfo, ""CDATA_START ); + (void)VIRT_AddUnicode( virtInfo, buf->ZRNL_VolumeName ); + status = VIRT_ssprintf( virtInfo, CDATA_END"\n" ); + if ( status != zOK ) + { + free( buf ); + goto exit2; + } + } + free( buf ); + } + break; + } + case zPOOL_REBUILD_START: + { + ZRS_Start_s *buf; + buf = malloc( sizeof(*buf) ); + status = zERR_NO_MEMORY; + if ( buf != NULL ) + { + BOOL pruneUnknownLosses = FALSE; + BOOL pruneIV = FALSE; + BOOL rezidThreshold = ZRSS_REZID_THRESHOLD_DEFAULT; + BOOL purge = FALSE; + BOOL uiPruneWait = FALSE; + + bzero( buf, sizeof(*buf) ); + if ( (tagContent[REZIDTHRESHOLD].flags & TR_TAG_FOUND) ) + { + rezidThreshold = strtoul( tagContent[REZIDTHRESHOLD].content, NULL, 0 ); + } + if ( (tagContent[PURGE].flags & TR_TAG_FOUND) ) + { + purge = TRUE; + } + if ( (tagContent[PRUNEIV].flags & TR_TAG_FOUND) ) + { + pruneIV = TRUE; + } + if ( (tagContent[PRUNEUNKNOWNLOSSES].flags & TR_TAG_FOUND) ) + { + pruneUnknownLosses = TRUE; + } + if ( (tagContent[UIPRUNEWAIT].flags & TR_TAG_FOUND) ) + { + uiPruneWait = TRUE; + } + unicpy( buf->ZRSS_PoolName, uni_poolName ); + buf->ZRSS_DebugLevel = debugLevel; + buf->ZRSS_UIOptions = uiOptions; + buf->ZRSS_RezidThreshold = rezidThreshold; + buf->ZRSS_Purge = purge; + buf->ZRSS_UIPruneWait = uiPruneWait; +//g buf->ZRSS_Limit.ZLL_BlockLossMax = 100; // Fixfixfix(zrpDone,2,.2) - Allow user to set or remove - remove!!! + buf->ZRSS_Limit.ZLL_FileLossMax = fileLossMax; + buf->ZRSS_Limit.ZLL_PruneUnknownLosses = pruneUnknownLosses; + buf->ZRSS_Limit.ZLL_PruneIV = pruneIV; + status = zPoolVerify( zPOOL_REBUILD_START, sizeof(*buf), buf ); + if ( status == zOK ) + { + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), buf->ZRSS_Key ); + } + free( buf ); + } + break; + } + case zPOOL_RAV_SET_WITH_KEY: + { + ZVS_Set_s *buf; + buf = malloc( sizeof(*buf) ); + status = zERR_NO_MEMORY; + if ( buf != NULL ) + { + bzero( buf, sizeof(*buf) ); + buf->ZS_Key = userKey; + buf->ZS_UIOptionsSet = uiOptionsSet; + buf->ZS_DebugLevelSet = debugLevelSet; + buf->ZS_UIPruneStatusSet = uiPruneStatusSet; + buf->ZS_UIOptions = uiOptions; + buf->ZS_DebugLevel = debugLevel; + buf->ZS_UIPruneStatus = uiPruneStatus; + status = zPoolVerify( zPOOL_RAV_SET_WITH_KEY, sizeof(*buf), buf ); + free( buf ); + } + break; + } + case zPOOL_RAV_VERSION_INFORMATION: + { + ZVP_VersionInformation_s *buf; + buf = malloc( sizeof(*buf) ); + status = zERR_NO_MEMORY; + if ( buf != NULL ) + { + bzero( buf, sizeof(*buf) ); + status = zPoolVerify( zPOOL_RAV_VERSION_INFORMATION, sizeof(*buf), buf ); + if ( status == zOK ) + { + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), buf->ZVI_VersionMajor ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), buf->ZVI_VersionMinor ); + (void)VIRT_ssprintf( virtInfo, MSGNot("\n"), buf->ZVI_XMLVersionMajor ); + status = VIRT_ssprintf( virtInfo, MSGNot("\n"), buf->ZVI_XMLVersionMinor ); + if ( status != zOK ) + { + free( buf ); + goto exit2; + } + } + free( buf ); + } + break; + } +#if 0 + case zPOOL_REBUILD_LIMIT_POST_WITH_KEY: + { + ZVS_LimitPost_s *buf; + buf = malloc( sizeof(*buf) ); + status = zERR_NO_MEMORY; + if ( buf != NULL ) + { + BOOL pruneIV = FALSE; + BOOL pruneUnknownLosses = FALSE; + + bzero( buf, sizeof(*buf) ); + if ( (tagContent[PRUNEIV].flags & TR_TAG_FOUND) ) + { + pruneIV = TRUE; + } + if ( (tagContent[PRUNEUNKNOWNLOSSES].flags & TR_TAG_FOUND) ) + { + pruneUnknownLosses = TRUE; + } + buf->ZLP_Key = userKey; +//g buf->ZLP_LimitsPost.ZLL_BlockLossMax = 100; + buf->ZLP_LimitsPost.ZLL_FileLossMax = fileLossMax; + buf->ZLP_LimitsPost.ZLL_PruneIV = pruneIV; + buf->ZLP_LimitsPost.ZLL_PruneUnknownLosses = pruneUnknownLosses; + status = zPoolVerify( zPOOL_REBUILD_LIMIT_POST_WITH_KEY, sizeof(*buf), buf ); + free( buf ); + } + break; + } +#endif + case zPOOL_REBUILD_DETAILS_WITH_KEY: + { + ZVP_StatusHeader_s *buf; + NINT flags; + unsigned int items; + unsigned int size; + + if ( tagContent[MULTIPLE].flags & TR_TAG_FOUND ) + { + flags = ZSH_FLAG_MULTIPLE; + items = 10; + } + else + { + flags = ZSH_FLAG_SINGLE; + items = 1; + } + if ( tagContent[WAIT].flags & TR_TAG_FOUND ) + { // This will cause a deadlock as of May 2004 because ADMIN owns resources when it calls us! + flags |= ZSH_FLAG_WAIT; + } + size = offsetof(ZVP_StatusHeader_s,ZSH_Entry) + ((items) * sizeof(ZVP_RebuildStatusEntry_s)); + buf = malloc( size ); + status = zERR_NO_MEMORY; + if ( buf != NULL ) + { + bzero( buf, size ); + buf->ZSH_Format = ZVP_VSH_FORMAT; + buf->ZSH_Flag = flags; + buf->ZSH_SearchKey = userKey; + buf->ZSH_ResultsNeeded = items; + status = zPoolVerify( zPOOL_REBUILD_DETAILS_WITH_KEY, size, buf ); + if ( status == zOK ) + { + status = VP_RebuildStatusToXML( virtInfo, buf ); + } + free( buf ); + } + break; + } + default: + status = zERR_BAD_PARAMETER_VALUE; + break; + } +// MNSS_ReturnResult(virtInfo, tagName, status, MSGNot("Result from zPoolVerify operation")); + MNSS_BuildResult2(virtInfo, status, MSGNot("Result from zPoolVerify operation"), WHERE, NULL ); + status3 = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); +// if ( status3 != zOK ) +// { +// return status3; +// } + return zOK; + // + // No returns or goto's in the switch statement because we have added the start tag + // and must add the end tag to have legal XML. + // + +errorInXMLBufferAlready: + return zOK; + +exit2: // Exit here when the XML buffer is too full to add an XML error tag. + // If we EVER return non zOK then are clients are screwed because VIRT_ChunkyRead will + // force ALL reads to offset 0. This causes the clients to read FOREVER as they + // are doing fseeks and waiting for EOF!!!! + status = zOK; + return status; + +} /* End of MNSS_ProcessPoolVerify() */ + #endif + + +#if zLINUX && !defined(__KERNEL__) + +/* + * DismountAndRemovePoolVolumesEntries() - + * a) Dismounts the volumes + * b) Removes the entries (fstab, mountpoint) for volumes that correspond to this pool. + */ +STATUS DismountAndRemovePoolVolumesEntries( + utf8_t *poolName, + BOOL removeMountPointFolder) +{ + STATUS status; + BOOL firstTime = TRUE; + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + utf8_t volName[zMAX_COMPONENT_NAME]; + GUID_t cookie; + BOOL isDeleted; + utf8_t *returnMsg = NULL; + + /* pool name to unicode */ + if(utf2uni(poolName, uniPoolName, sizeof(uniPoolName)) == -1) + { + status = zERR_INVALID_UTF8_CHAR; + goto exit; + } + + firstTime = TRUE; + while((status = GetNextVolumeInfo(uniPoolName, firstTime, FALSE, &cookie, uniVolName, sizeof(uniVolName))) == zOK) + { + firstTime = FALSE; + + if((status = NSSVolumeFound(uniVolName, FALSE, &isDeleted, NULL, NULL, NULL, NULL)) == zOK) + { + if(isDeleted) + { + continue; + } + uni2utf(uniVolName, volName, sizeof(volName)); + if(DismountAndRemoveVolumeEntries(volName, &returnMsg, TRUE, removeMountPointFolder) != zOK) + { +#if zLINUX + syslog(LOG_WARNING, "Entries for Volume %s from pool %s are not removed during pool deactivation\n", volName, poolName); +#endif + } + } + } + +exit: + return status; +} + +#endif diff --git a/src/nwnss/sharedsrc/manageRAID.c.h b/src/nwnss/sharedsrc/manageRAID.c.h new file mode 100644 index 0000000..cea06f6 --- /dev/null +++ b/src/nwnss/sharedsrc/manageRAID.c.h @@ -0,0 +1,2462 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: cganapathi $ + | $Date: 2008-08-21 11:55:50 +0530 (Thu, 21 Aug 2008) $ + | + | $RCSfile$ + | $Revision: 2443 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage NSS using XML + | + +-------------------------------------------------------------------------*/ +#include +#include + +#include +#include + +#if zNETWARE +#include +#include +#include +#include +#include +#include "manageStartup.h" +#endif + +#if zLINUX && !defined(__KERNEL__) +#define stricmp(p1,p2) strcasecmp(p1,p2) +#include +#include +#include +extern void syslog (int __pri, __const char *__fmt, ...) + __attribute__ ((__format__(__printf__, 2, 3))); +#include +#include "manageEVMS.h" +#endif + +#include +#include "manage.h" +#include "manageNlm.h" +#include "nssPubs.h" +#include "comnPublics.h" +#include "comnAuthorize.h" +#include "virtualIO.h" +#include "xmlTags.h" + +#if zNETWARE +LONG getNSSPartitionsOnDevice(LONG obID, LONG **partitions); + + +STATUS MNSS_ProcessAddRAID(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessRemoveRAID(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +#endif +STATUS MNSS_ProcessAddRAIDSimple(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessRemoveRAIDSimple(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessExpandRAID(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessRestripeRAID(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessRenameRAID(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ + +SiblingElements_s RAIDElements[] = +{ +#if zNETWARE + {TAG_ADDRAID, MNSS_ProcessAddRAID}, + {TAG_REMOVERAID, MNSS_ProcessRemoveRAID}, +#endif + {TAG_ADDRAIDSIMPLE, MNSS_ProcessAddRAIDSimple}, + {TAG_REMOVERAIDSIMPLE, MNSS_ProcessRemoveRAIDSimple}, + {TAG_EXPANDRAID, MNSS_ProcessExpandRAID}, + {TAG_RESTRIPERAID, MNSS_ProcessRestripeRAID}, + {TAG_RENAMERAID, MNSS_ProcessRenameRAID}, + {0} +}; + +#if zNETWARE +/**************************************************************************** + * Media manager structure not included in mmpublic.h + ****************************************************************************/ +struct IOObjectMappingTableInfoDef +{ + LONG parentCount; + LONG siblingCount; + LONG childCount; + LONG parentOBIDs[1]; +}; + + +/**************************************************************************** + * RAID_deleteRAIDPartition + *****************************************************************************/ +STATUS RAID_deleteRAIDPartition( + LONG pid) +{ + struct PartitionSpecificInfoDef partInfo; + STATUS ccode; + + ASSERT_MPKNSS_LOCK(); + + ZMM_ReturnObjectSpecificInfo(ccode, pid, sizeof(partInfo), &partInfo); + if (ccode == MM_OK) + { + MPKNSS_UNLOCK(); + ccode = PARTAPIDeletePartitionPtr(pid, -1, + partInfo.partitionoffset, partInfo.partitionsize); + MPKNSS_LOCK(); + } + + return(ccode); +} + +STATUS NW_addRaid2( + utf8_t *tagName, + VirtInfo_s *virtInfo, + LONG raidType, + BYTE *raidName, + LONG stripeSectors, + QUAD numSectors, + utf8_t *segmentsStart, + utf8_t *segmentsEnd) +{ + utf8_t *start; + LONG deviceID; + LONG freeSpaceID; + LONG partitionType; + NINT partitionsAdded = 0; + LONG ccode; + STATUS status; + LONG newRaidID; + XML_ElementInfo_s segElement; + utf8_t tempBuf[512] = ""; + + /* Tags for parsing */ + const TagRequest_s segTags[] = + { + {TAG_DEVICEID, TR_CONTENT_REQUIRED}, + {TAG_FREESPACEID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s segTagContent[NELEMS(segTags)-1]; + + enum + { + DEVICE_ID = 0, + FREE_SPACE_ID = 1, + }; + + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + + /* Make sure that we have the RAIDMgrID - if not bail. */ + if (RAIDMgrID == -1) + { + return zFAILURE; + } + + /* Check to see if the PARTAPI.NLM has been loaded. */ + ccode = PART_SetupToCallPARTAPI(); + if (ccode != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Setup to call PART API failed")); + goto exit; + } + + /* Raid device stripe size. */ + if(raidType == 1) + { + partitionType = NETWARE_NSS_PARTITION; + } + else + { + partitionType = NETWARE_VDEVICE_PARTITION; + } + + start = segmentsStart; + for(;;) + { + /* find the next raid segment */ + if (XML_GetTagElement(TAG_SEGMENT, start, + segmentsEnd, &segElement) != zOK) + { + break; /* we cannot find any more RAID segments */ + } + + start = segElement.elementEnd; + + if (segElement.dataStart == NULL || + segElement.dataStart[0] == '\0') + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Missing value in a raidSegments tag")); + goto exit; + } + + if ((status = MNSS_GetTagContents(virtInfo, tagName, + &segElement, &segTags, &segTagContent)) != zOK) + { + if (status != zERR_XML_IS_BAD) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Missing value in a volSegments tag")); + } + goto exit; + } + + deviceID = atol(segTagContent[DEVICE_ID].content); + freeSpaceID = atol(segTagContent[FREE_SPACE_ID].content); + + if (partitionsAdded == 0) + { + MPKNSS_UNLOCK(); + ccode = MM_CreateRaidWithNewPartition(partitionType, + raidType, &freeSpaceID, + numSectors, stripeSectors, + raidName, &newRaidID); + MPKNSS_LOCK(); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Failed to create raid")); + goto exit; + } + } + else + { + /* Create the raid device */ + MPKNSS_UNLOCK(); + ccode = MM_ExpandRaidWithNewPartition(newRaidID, &freeSpaceID); + MPKNSS_LOCK(); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Unable to expand the RAID device")); + /* Delete the RAID that we couldn't add to the raid */ + ZMM_DeleteRaid(ccode, newRaidID); + goto exit; + } + } + ++partitionsAdded; + } + + if(raidType == 1) + { + MPKNSS_UNLOCK(); + ccode = MM_ForceMirrorGroupInSync(newRaidID); + MPKNSS_LOCK(); + } + else + { + // Initialize the RAID device. + MPKNSS_UNLOCK(); + ccode = PARTAPIInitializePartitionTablePtr(newRaidID); + MPKNSS_LOCK(); + } + + /* Unload the PARTAPI.NLM */ + PART_CleanupCallToPARTAPI(); + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + + sprintf(tempBuf, + "<"TAG_RAIDID">%u", newRaidID); + VIRT_AddResultData(virtInfo, tempBuf); + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + return zOK; +} + +STATUS NW_removeRaid2( + utf8_t *tagName, + VirtInfo_s *virtInfo, + LONG raidID) +{ + LONG ccode; + LONG pCount; + LONG pNum; + LONG *partitions = NULL; + LONG *map = NULL; + unsigned char poolName[64]; + STATUS status; + BOOL errDeleteNDSObjects = FALSE; + + MNSS_LoadAppIDs(); + + /* Make sure that we have the RAIDMgrID - if not bail. */ + if (RAIDMgrID == -1) + { + return zFAILURE; + } + + /* Check to see if the PARTAPI.NLM has been loaded. */ + ccode = PART_SetupToCallPARTAPI(); + if (ccode != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Setup to call PART API failed")); + goto exit; + } + + /* Get the partitions for the device */ + pCount = getNSSPartitionsOnDevice(raidID, &partitions); + if (pCount == 0) + goto justDeleteRAID; + + zASSERT(partitions != NULL); + + /* Get the pool for each partition */ + for (pNum = 0; pNum < pCount; pNum++) + { + getPoolNameFromPartitionID(partitions[pNum], poolName); + + /* No pool */ + if (poolName[0] == 0) + continue; + + /* ManagePool.c has services to destroy all DS objects + * associated with a pool (including volumes). No need + * to write all that again */ + + status = MNDS_DestroyPoolDSObjects(virtInfo, poolName, FALSE); + if (status != zOK) + { + errDeleteNDSObjects = TRUE; + } + } + + if (partitions != NULL) + free(partitions); + +justDeleteRAID: + /* Delete the raid device. */ + ZMM_DeleteRaid(ccode, raidID); + + /* Unload the PARTAPI.NLM */ + PART_CleanupCallToPARTAPI(); + + if(ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Failure to delete the RAID device")); + goto exit; + } + + if (errDeleteNDSObjects == TRUE) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Remove RAID - failure to remove NDS object")); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + if (map != NULL) + free(map); + return zOK; +} + +STATUS NW_expandRaid( + utf8_t *tagName, + VirtInfo_s *virtInfo, + LONG raidID, + utf8_t *segmentsStart, + utf8_t *segmentsEnd) +{ + utf8_t *start; + LONG deviceID; + LONG freeSpaceID; + LONG ccode; + STATUS status; + XML_ElementInfo_s segElement; + BOOL foundMirror; + + /* Tags for parsing */ + const TagRequest_s segTags[] = + { + {TAG_DEVICEID, TR_CONTENT_REQUIRED}, + {TAG_FREESPACEID, TR_CONTENT_REQUIRED}, + {TAG_STARTINGSECTOR, TR_OPTIONAL}, +// {TAG_NUMSECTORS, TR_OPTIONAL}, + {0} + }; + TagContent_s segTagContent[NELEMS(segTags)-1]; + + enum + { + DEVICE_ID = 0, + FREE_SPACE_ID = 1, + STARTING_SECTOR = 2, +// NUM_SECTORS = 3 + }; + + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + + /* Make sure that we have the RAIDMgrID - if not bail. */ + if (RAIDMgrID == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Invalid RAID manager ID")); + goto exit; + } + + /* Check to see if the PARTAPI.NLM has been loaded. */ + ccode = PART_SetupToCallPARTAPI(); + if (ccode != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Setup to call PART API failed")); + goto exit; + } + + /* Get the attributes of the RAID device */ + status = PART_CheckForMirror(raidID, &foundMirror); + if (status != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, status, MSGNot("Error getting device information.")); + goto exit; + } + + /* Create the partitions and add them to the RAID device. */ + start = segmentsStart; + for(;;) + { + /* find the next raid segment */ + if (XML_GetTagElement(TAG_SEGMENT, start, segmentsEnd, &segElement) != zOK) + { + break; /* we cannot find any more RAID segments */ + } + + start = segElement.elementEnd; + + if (segElement.dataStart == NULL || + segElement.dataStart[0] == '\0') + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Missing value in a raidSegments tag")); + goto exit; + } + + if ((status = MNSS_GetTagContents(virtInfo, tagName, + &segElement, &segTags, &segTagContent)) != zOK) + { + if (status != zERR_XML_IS_BAD) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Missing value in a volSegments tag")); + } + goto exit; + } + + deviceID = atol(segTagContent[DEVICE_ID].content); + freeSpaceID = atol(segTagContent[FREE_SPACE_ID].content); + + /* expand the raid device */ + MPKNSS_UNLOCK(); + ccode = MM_ExpandRaidWithNewPartition(raidID, &freeSpaceID); + MPKNSS_LOCK(); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Unable to expand the RAID device")); + goto exit; + } + } + + /* Unload the PARTAPI.NLM */ + PART_CleanupCallToPARTAPI(); + + if(foundMirror) + { + MPKNSS_UNLOCK(); + ccode = MM_ForceMirrorGroupInSync(raidID); + MPKNSS_LOCK(); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error starting a synchronization process")); + goto exit; + } + } + else + { + /* Start the restriping process. */ + ZMM_ObjectControl(ccode, RAIDMgrID, MM_RESTRIPE_RAID, raidID, 0, 0, 0, 0); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error starting a restripe process")); + goto exit; + } + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; +} +#endif + +#if zLINUX && !defined(__KERNEL__) +STATUS Linux_addRaid2( + utf8_t *tagName, + VirtInfo_s *virtInfo, + LONG raidType, + utf8_t *raidName, + LONG stripeSectors, + QUAD numSectors, + LONG numSegments, + utf8_t *segmentsStart, + utf8_t *segmentsEnd) +{ + object_handle_t freeSegmentHandle; + object_handle_t raidHandle; + handle_object_info_t *object_info = NULL; + utf8_t *start; +// utf8_t *deviceID; + utf8_t *freeSpaceID; + LONG partitionType; + int ccode; + STATUS status; + XML_ElementInfo_s segElement; + utf8_t tempBuf[512] = ""; + handle_array_t *segmentHandles = NULL; + int added = 0, existing=0; + + /* Tags for parsing */ + const TagRequest_s segTags[] = + { +// {TAG_DEVICEID, TR_CONTENT_REQUIRED}, + {TAG_FREESPACEID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s segTagContent[NELEMS(segTags)-1]; + + enum + { +// DEVICE_ID = 0, + FREE_SPACE_ID = 0, + }; + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Error openin evms engine")); + return zOK; + } + + segmentHandles = malloc(sizeof(handle_array_t) + + sizeof(object_handle_t) * (numSegments)); + if (segmentHandles == NULL) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Error no memory")); + goto exit; + } + segmentHandles->count = numSegments; + + if(raidType == 1) + { + partitionType = NSS_PARTITION; + } + else if (raidType == 0 || raidType == 5) + { + partitionType = VIRTUAL_DEVICE_PARTITION; + } + else + { + sprintf(tempBuf, MSGNot("Invalid raid type: %d"), raidType); + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, tempBuf); + goto exit; + } + + + /* Create the partitions and add them to the RAID device. */ + start = segmentsStart; + for(;;) + { + /* find the next raid segment */ + if (XML_GetTagElement(TAG_SEGMENT, start, + segmentsEnd, &segElement) != zOK) + { + break; /* we cannot find any more RAID segments */ + } + + start = segElement.elementEnd; + + if (segElement.dataStart == NULL || + segElement.dataStart[0] == '\0') + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Missing value in a raidSegments tag")); + goto freeSegments; + } + + if ((status = MNSS_GetTagContents(virtInfo, tagName, + &segElement, segTags, segTagContent)) != zOK) + { + if (status != zERR_XML_IS_BAD) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Missing value in a volSegments tag")); + } + goto freeSegments; + } + +// deviceID = segTagContent[DEVICE_ID].content; + freeSpaceID = segTagContent[FREE_SPACE_ID].content; + + ZOS_evms_get_object_handle_for_name(ccode, SEGMENT, + freeSpaceID, &freeSegmentHandle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting segment handle for %s: %s"), + freeSpaceID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, tempBuf); + goto freeSegments; + } + + ZOS_evms_get_info(ccode, freeSegmentHandle, &object_info); + if (ccode == 0) + { + if (object_info->info.segment.data_type == FREE_SPACE_TYPE) + { + /* Now create the actual partition */ + ccode = evmsAddPartition(freeSegmentHandle, numSectors, + getPartitionTypeNameByValue(partitionType), + NULL, + &segmentHandles->handle[added]); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error adding segment on %s: %s"), + freeSpaceID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, tempBuf); + goto freeSegments; + } + + added++; + } + else + { + segmentHandles->handle[added] = freeSegmentHandle; + added++; + existing++; + } + } + + } + + /* create raid device */ + ccode = evmsAddRaidDevice(segmentHandles, raidType, + stripeSectors * 512, (BYTE *)raidName, &raidHandle, existing); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error creating raid: %s"), + evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, tempBuf); + goto freeSegments; + } + + /* raidName is optional, get it from the created raid object now */ + ZOS_evms_get_info(ccode, raidHandle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting raid name: %s"), + evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, tempBuf); + goto exit; + } + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + + sprintf(tempBuf, "%s", object_info->info.region.name); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto exit; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + if (segmentHandles != NULL) + { + free(segmentHandles); + } + + evmsCloseEngine(); + + return zOK; + +freeSegments: + while (--added >= 0) + { + ZOS_evms_delete(ccode, segmentHandles->handle[added]); + } + ZOS_evms_commit_changes(ccode); + goto exit; +} + +STATUS linuxRemoveRaid2( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *raidID, + object_handle_t handle) +{ + int ccode; + utf8_t tempBuf[512] = ""; + NINT deviceType; + + ccode = evmsGetDeviceType(handle, &deviceType, NULL, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device type for %s: %s"), + raidID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + + if (deviceType == DEVICE_RAID) + { + if ((ccode = linuxInitializeDevice(tagName, virtInfo, raidID)) != 0) + { + goto Exit; + } + { + #define MAX_RETRIES 6 + int i; + + for (i = 0; i < MAX_RETRIES; i++) + { + sleep(1); + ccode = evmsDestroyObjectByHandle(handle, TRUE); + if (!ccode) + { + break; + } + } + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error destroying %s: %s"), + raidID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + } + } + else if (deviceType == DEVICE_MIRROR) + { + BOOL infoFound = FALSE; + utf8_t poolName[zMAX_COMPONENT_NAME]; + + /* mirror device is different */ + ccode = getPoolInfoFromObjectHandle(handle, &infoFound, + (BYTE *)poolName, NULL, NULL, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting mirror device pool info: %s"), + evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + if (infoFound) + { + syslog(LOG_INFO, "pool name: %s\n", poolName); + ccode = removePoolSimple(tagName, virtInfo, FALSE, poolName, FALSE); + if (ccode != zOK) + { + goto Exit; + } + } + else + { + ccode = evmsDestroyObjectByHandle(handle, FALSE); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error destroying %s: %s"), + raidID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + } + } + else + { + ccode = -1; + sprintf(tempBuf, MSGNot("Invalid device type for %s: %d"), + raidID, deviceType); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto Exit; + } + +Exit: + return ccode; +} + + +STATUS Linux_removeRaid2( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *raidID) +{ + int ccode; + object_handle_t handle; + utf8_t tempBuf[512] = ""; + + ASSERT_MPKNSS_LOCK(); + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, MSGNot("Error opening EVMS engine. It might be " + "opened by another application")); + goto exit; + } + + ZOS_evms_get_object_handle_for_name(ccode, REGION, raidID, &handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting region handle for %s: %s"), + raidID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto close_engine; + } + + if ((ccode = linuxRemoveRaid2(tagName, virtInfo, raidID, handle)) != 0) + { + goto close_engine; + } + +close_engine: + evmsCloseEngine(); + + if (ccode == 0) + { + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + } + +exit: + return zOK; +} + +STATUS Linux_expandRaid( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *raidID, + LONG numSegments, + utf8_t *segmentsStart, + utf8_t *segmentsEnd) +{ + utf8_t *start; +// utf8_t *deviceID; + utf8_t *freeSpaceID; + int ccode; + STATUS status; + XML_ElementInfo_s segElement; + object_handle_t handle; + object_handle_t freeSegmentHandle; + NINT deviceType; + handle_array_t *segmentHandles; + QUAD numSectors; + utf8_t tempBuf[512] = ""; + NINT partitionType; + int added; + NINT action; + + /* Tags for parsing */ + const TagRequest_s segTags[] = + { + {TAG_FREESPACEID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s segTagContent[NELEMS(segTags)-1]; + + enum + { + FREE_SPACE_ID = 0, + }; + + + ASSERT_MPKNSS_LOCK(); + +// syslog(LOG_INFO, "in Linux_expandRaid"); + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Error openin evms engine")); + return zOK; + } + + segmentHandles = malloc(sizeof(handle_array_t) + + sizeof(object_handle_t) * (numSegments)); + if (segmentHandles == NULL) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Error no memory")); + goto exit; + } + segmentHandles->count = numSegments; + + ZOS_evms_get_object_handle_for_name(ccode, REGION, raidID, &handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object handle for %s: %s"), + raidID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto exit; + } + + evmsPrintExtendedInfo(handle); + + ccode = evmsGetDeviceType(handle, &deviceType, NULL, &numSectors); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device type for %s: %s"), + raidID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto exit; + } + + if (deviceType == DEVICE_RAID) + { + partitionType = VIRTUAL_DEVICE_PARTITION; +// ZOS_evms_get_plugin_by_name(ccode, PLUGIN_NWRAIDMGR, &plugin_handle); + } + else + { + partitionType = NSS_PARTITION; +// ZOS_evms_get_plugin_by_name(ccode, PLUGIN_NWRAID1MGR, &plugin_handle); + } +// if (ccode != 0) +// { +// sprintf(tempBuf, MSGNot("Error getting plugin handle for %s: %s"), +// raidID, evmsGetErrString(ccode)); +// MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); +// goto exit; +// } + + /* Create the partitions and add them to the RAID device. */ + added = 0; + start = segmentsStart; + for(;;) + { + /* find the next raid segment */ + if (XML_GetTagElement(TAG_SEGMENT, start, + segmentsEnd, &segElement) != zOK) + { + break; /* we cannot find any more RAID segments */ + } + + start = segElement.elementEnd; + + if (segElement.dataStart == NULL || + segElement.dataStart[0] == '\0') + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Missing value in a raidSegments tag")); + goto freeSegments; + } + + if ((status = MNSS_GetTagContents(virtInfo, tagName, + &segElement, segTags, segTagContent)) != zOK) + { + if (status != zERR_XML_IS_BAD) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Missing value in a volSegments tag")); + } + goto freeSegments; + } + + freeSpaceID = segTagContent[FREE_SPACE_ID].content; + + ZOS_evms_get_object_handle_for_name(ccode, SEGMENT, + freeSpaceID, &freeSegmentHandle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting segment handle for %s: %s"), + freeSpaceID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, tempBuf); + goto freeSegments; + } + + /* Now create the actual partition */ + ccode = evmsAddPartition(freeSegmentHandle, numSectors + 32, + getPartitionTypeNameByValue(partitionType), + NULL, + &segmentHandles->handle[added]); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error adding segment on %s: %s"), + freeSpaceID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, tempBuf); + goto freeSegments; + } + + added++; + } + + if (deviceType == DEVICE_MIRROR) + { + action = R1_ADD_ELEMENT; + } + else + { + action = RAID_ADD_ELEMENT; + } + + /* Need to expand RAID in one call. defect 402884 */ + ccode = evmsMakeTask(handle, action, segmentHandles, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Couldn't add partition to raid 1 device: %s"), + evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, tempBuf); + goto freeSegments; + } +#if 0 + } + else + { + ZOS_evms_can_expand(ccode, handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error raid %s can't be expanded: %s"), + raidID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, tempBuf); + goto exit; + } + + // ccode = evmsMakeTask(handle, EVMS_Task_Expand, segmentHandles, NULL); + ZOS_evms_expand(ccode, handle, segmentHandles, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error expanding raid %s: %s"), + raidID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, tempBuf); + goto freeSegments; + } + } +#endif + + ZOS_evms_commit_changes(ccode); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Couldn't commit expand device change for %s: %s"), + raidID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, tempBuf); + goto freeSegments; + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + if (segmentHandles != NULL) + { + free(segmentHandles); + } + + evmsCloseEngine(); + + return zOK; + +freeSegments: + while (--added >= 0) + { + ZOS_evms_delete(ccode, segmentHandles->handle[added]); + } + ZOS_evms_commit_changes(ccode); + goto exit; +} + +STATUS Linux_renameRaid( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *oldRaidID, + utf8_t *newRaidID) +{ + utf8_t tempBuf[512] = ""; + object_handle_t handle; + int ccode; + value_t value; + +// syslog(LOG_INFO, "in Linux_renameRaid"); + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Error openin evms engine")); + return zOK; + } + + ZOS_evms_get_object_handle_for_name(ccode, REGION, oldRaidID, &handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object handle for %s: %s"), + oldRaidID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto exit; + } + + value.s = newRaidID; + ccode = evmsChangeObjectValue(handle, RENAME_FUNCTION, (BYTE *)MSGNot("Name"), + &value, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error changing raid name: %s"), + evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + evmsCloseEngine(); + + return zOK; +} + +STATUS Linux_restripeRaid( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *raidID) +{ + utf8_t tempBuf[512] = ""; + object_handle_t handle; + int ccode; + handle_array_t *objectList = NULL; + LONG action; + NINT deviceType; + +// syslog(LOG_INFO, "in Linux_restripeRaid"); + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Error openin evms engine")); + return zOK; + } + + ZOS_evms_get_object_handle_for_name(ccode, REGION, raidID, &handle); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting object handle for %s: %s"), + raidID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto exit; + } + + ccode = evmsGetDeviceType(handle, &deviceType, NULL, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device type for %s: %s"), + raidID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, ccode, tempBuf); + goto exit; + } + + if (deviceType == DEVICE_RAID) + { + action = R1_REMIRROR; + } + else + { + action = RAID_RESTRIPE; + } + + objectList = malloc(sizeof(handle_array_t) + sizeof(object_handle_t)); + if (objectList == NULL) + { + ccode = zERR_NO_MEMORY; + goto exit; + } + + objectList->count = 1; + objectList->handle[0] = handle; + ccode = evmsMakeTask(handle, action, objectList, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Couldn't restripe/remirror device %s: %s"), + raidID, evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, tempBuf); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + if (objectList != NULL) + { + free(objectList); + } + + evmsCloseEngine(); + + return zOK; +} + +#endif + +#if zNETWARE +/**************************************************************************** + * + * This function creates a RAID device with a NETWARE_VDEVICE_PARTITION type. + * + ****************************************************************************/ +STATUS MNSS_ProcessAddRAID( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + LONG stripeSize; + LONG raidType; + utf8_t *start; + LONG deviceID; + LONG freeSpaceID; + LONG startSector; + LONG numSectors; + LONG stripeSectors; + LONG pid = -1; + BOOL maxElements = FALSE; + NINT numPartitions = 0; + NINT partitionsCreated = 0; + NINT partitionsAdded = 0; + NINT cleanupFailedCount = 0; + LONG ccode; + STATUS status; + STATUS partialRetVal = zOK; + LONG newRaidID; + XML_ElementInfo_s segElement; + + const TagRequest_s tags[] = + { + {TAG_STRIPESIZE, TR_CONTENT_REQUIRED}, + {TAG_RAIDTYPE, TR_CONTENT_REQUIRED}, + {TAG_RAIDSEGMENTS, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + STRIPE_SIZE = 0, + RAID_TYPE = 1, + RAID_SEGMENTS = 2, + }; + + /* Tags for parsing */ + const TagRequest_s segTags[] = + { + {TAG_DEVICEID, TR_CONTENT_REQUIRED}, + {TAG_FREESPACEID, TR_CONTENT_REQUIRED}, + {TAG_STARTINGSECTOR, TR_CONTENT_REQUIRED}, + {TAG_NUMSECTORS, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s segTagContent[NELEMS(segTags)-1]; + + enum + { + DEVICE_ID = 0, + FREE_SPACE_ID = 1, + STARTING_SECTOR = 2, + NUM_SECTORS = 3 + }; + + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + + /* Make sure that we have the RAIDMgrID - if not bail. */ + if (RAIDMgrID == -1) + { + return zFAILURE; + } + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Check to see if the PARTAPI.NLM has been loaded. */ + ccode = PART_SetupToCallPARTAPI(); + if (ccode != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Setup to call PART API failed")); + goto exit; + } + + /* Raid device stripe size. */ + stripeSize = atol(tagContent[STRIPE_SIZE].content); + stripeSectors = stripeSize / 512; + if (stripeSectors < 8) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Could not create the RAID because the stripe size was too small.")); + goto exit; + } + + + /* Raid device stripe size. */ + raidType = atol(tagContent[RAID_TYPE].content); + + /* Create the partitions and add them to the RAID device. */ + start = tagContent[RAID_SEGMENTS].element.dataStart; + for(;;) + { + /* find the next raid segment */ + if (XML_GetTagElement(TAG_SEGMENT, start, + tagContent[RAID_SEGMENTS].element.dataEnd, &segElement) != zOK) + { + break; /* we cannot find any more RAID segments */ + } + + start = segElement.elementEnd; + + if (segElement.dataStart == NULL || + segElement.dataStart[0] == '\0') + { + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + MNSS_BuildResult(virtInfo, zFAILURE, + MSGNot("Missing value in a raidSegments tag")); + goto partialExitCheck; + } + + if ((status = MNSS_GetTagContents(virtInfo, tagName, + &segElement, &segTags, &segTagContent)) != zOK) + { + if (status != zERR_XML_IS_BAD) + { + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + MNSS_BuildResult(virtInfo, zFAILURE, + MSGNot("Missing value in a volSegments tag")); + } + goto partialExitCheck; + } + + ++numPartitions; + + deviceID = atol(segTagContent[DEVICE_ID].content); + freeSpaceID = atol(segTagContent[FREE_SPACE_ID].content); + startSector = atol(segTagContent[STARTING_SECTOR].content); + + /* Modify partition size to line up on a stripe boundry. */ + numSectors = atol(segTagContent[NUM_SECTORS].content); + numSectors = ((numSectors / stripeSectors) * stripeSectors) + 32; + + /* Now create the actual partition */ + pid = freeSpaceID; + + MPKNSS_UNLOCK(); + ccode = PARTAPICreatePartitionPtr( + deviceID, NETWARE_VDEVICE_PARTITION, startSector, + numSectors, &pid); + MPKNSS_LOCK(); + if (ccode != MM_OK) + { + /* This partition could not be created. Save the reason */ + if (partialRetVal == zOK) + { + partialRetVal = ccode; + } + /* Loop and see if we can create the next partition. */ + continue; + } + ++partitionsCreated; + + /* Create or expand the RAID device based on the partitionsAdded count. */ + if (partitionsAdded == 0) + { + + /* Create the raid device */ + ZMM_ObjectControl(ccode, RAIDMgrID, MM_CREATE_RAID, pid, raidType, + stripeSectors, sizeof(newRaidID), &newRaidID ); + + if (ccode != MM_OK) + { + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + MNSS_BuildResult(virtInfo, ccode, + MSGNot("Unable to create the RAID device")); + + /* Delete the partition that we couldn't add to the raid */ + ccode = RAID_deleteRAIDPartition(pid); + if (ccode != MM_OK) + { + ++cleanupFailedCount; + } + goto partialExitCheck; + } + + /* We successfully created the raid */ + ++partitionsAdded; + } + else + { + /* Expand the raid device with this new partition */ + ZMM_ObjectControl(ccode, RAIDMgrID, MM_EXPAND_RAID, + newRaidID, pid, 0, 0, 0); + if (ccode != MM_OK) + { + if (ccode == MM_MAX_RAID_ELEMENTS_EXCEEDED) + { + /* Successful, but too many segments */ + maxElements = TRUE; + } + /* Save the reason this add raid failed */ + if (partialRetVal == zOK) + { + partialRetVal = ccode; + } + + /* Delete the partition that we couldn't add to the raid */ + ccode = RAID_deleteRAIDPartition(pid); + if (ccode != MM_OK) + { + ++cleanupFailedCount; + } + } + else + { + ++partitionsAdded; + } + } + } + + if ((partitionsAdded == numPartitions) && (partitionsAdded > 0)) + { + // Initialize the RAID device. + MPKNSS_UNLOCK(); + ccode = PARTAPIInitializePartitionTablePtr(newRaidID); + MPKNSS_LOCK(); + } + + /* Unload the PARTAPI.NLM */ + PART_CleanupCallToPARTAPI(); + + /* Add the opening tag separately because we are including some + * extra status values and we have to build it all manually + */ + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + + if (partitionsAdded == 0) + { + /* For some reason, we were unsuccessful in creating and adding any + * partitions. No RAID was created. + */ + MNSS_BuildResult(virtInfo, partialRetVal, + MSGNot("Unable to create the RAID device")); + } + else + { + /* At least one partition was added to the RAID. Give partial success*/ + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + +partialExitCheck: + /* Check if we need to return the partialResult tag with the individual + * stats + */ + if ((partialRetVal != zOK) || (cleanupFailedCount) || (maxElements) || + (partitionsAdded != numPartitions)) + { + utf8_t tempBuf[256]; + + sprintf(tempBuf, MSGNot("<"TAG_PARTIALRESULT" "ATR_VALUE + "=\"%d\"><"TAG_DESCRIPTION">"), partialRetVal); + VIRT_AddResultData(virtInfo, tempBuf); + VIRT_AddResultData(virtInfo, MSGNot("The RAID device was created, but there was a partial failure")); + VIRT_AddResultData(virtInfo, MSGNot("\n")); + + sprintf(tempBuf, MSGNot( + "<"TAG_PARTITIONSREQUESTED">%u" + "<"TAG_PARTITIONSCREATED">%u" + "<"TAG_PARTITIONSADDED">%u" + "<"TAG_PARTITIONSSTRANDED">%u"), + numPartitions, partitionsCreated, partitionsAdded, cleanupFailedCount); + VIRT_AddResultData(virtInfo, tempBuf); + + if (maxElements) + { + VIRT_AddResultElement(virtInfo, TAG_MAXPARTITIONS, "", FALSE); + } + + VIRT_AddResultData(virtInfo, MSGNot("\n")); + } + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + return zOK; +} +#endif + +/**************************************************************************** + * + * This function creates a RAID device with a NETWARE_VDEVICE_PARTITION type. + * + ****************************************************************************/ +STATUS MNSS_ProcessAddRAIDSimple( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + LONG stripeSize = 0; + LONG raidType; + QUAD numSectors; + LONG stripeSectors = 0; + STATUS status; + utf8_t *raidName = NULL; + + const TagRequest_s tags[] = + { + {TAG_STRIPESIZE, TR_OPTIONAL}, + {TAG_RAIDTYPE, TR_CONTENT_REQUIRED}, + {TAG_RAIDSEGMENTS, TR_CONTENT_REQUIRED}, + {TAG_RAIDNAME, TR_OPTIONAL}, + {TAG_NUMSECTORS, TR_CONTENT_REQUIRED}, +#if zLINUX && !defined(__KERNEL__) + {TAG_NUMSEGMENTS, TR_CONTENT_REQUIRED}, +#endif + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + STRIPE_SIZE = 0, + RAID_TYPE = 1, + RAID_SEGMENTS = 2, + RAID_NAME = 3, + NUM_SECTORS = 4, +#if zLINUX && !defined(__KERNEL__) + NUM_SEGMENTS = 5, +#endif + }; + + + ASSERT_MPKNSS_LOCK(); +// syslog(LOG_INFO, "in MNSS_ProcessAddRAIDSimple"); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Raid device stripe size. */ + raidType = atol(tagContent[RAID_TYPE].content); + + /* Raid device stripe size. */ + if(tagContent[STRIPE_SIZE].flags & TR_TAG_FOUND) + { + stripeSize = atol(tagContent[STRIPE_SIZE].content); + stripeSectors = stripeSize / 512; + if (stripeSectors < 8) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Could not create the RAID because the stripe size was too small.")); + goto exit; + } + } + else + { + if(raidType != 1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Missing stripe size")); + goto exit; + } + } + + /* Since the number of sectors needs to be the same for all segments anyway + * we can let it be specified outside the segment definitions */ +#if zNETWARE + numSectors = strtouq(tagContent[NUM_SECTORS].content, NULL, 10); +#endif +#if zLINUX && !defined(__KERNEL__) + numSectors = strtoull(tagContent[NUM_SECTORS].content, NULL, 10); +#endif + if (numSectors == 0) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, MSGNot("Illegal size for virtual device segment")); + goto exit; + } + + /* Modify partition size to line up on a stripe boundry. */ + if(raidType != 1) + { + numSectors = ((numSectors / stripeSectors) * stripeSectors) + 32; + } + + if(tagContent[RAID_NAME].flags & TR_TAG_FOUND) + { + raidName = tagContent[RAID_NAME].content; + } + +#if zNETWARE + /* Fixfixfix needs to modify XML reply to match new doc */ + status = NW_addRaid2(tagName, virtInfo, raidType, raidName, stripeSectors, numSectors, + tagContent[RAID_SEGMENTS].element.dataStart, tagContent[RAID_SEGMENTS].element.dataEnd); +#endif +#if zLINUX && !defined(__KERNEL__) + status = Linux_addRaid2(tagName, virtInfo, raidType, raidName, stripeSectors, numSectors, + atol(tagContent[NUM_SEGMENTS].content), + tagContent[RAID_SEGMENTS].element.dataStart, tagContent[RAID_SEGMENTS].element.dataEnd); +#endif +exit: + return status; +} + + + +/* Replaced with better functionality */ +#if 0 +/**************************************************************************** + * + * This function expands a RAID device with a NETWARE_VDEVICE_PARTITION type. + * + ****************************************************************************/ +STATUS MNSS_ProcessExpandRAID( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + utf8_t *start; + LONG raidID; + LONG deviceID; + LONG freeSpaceID; + LONG startSector; + LONG numSectors; + LONG pid = -1; + BOOL maxElements = FALSE; + NINT numPartitions = 0; + NINT partitionsCreated = 0; + NINT partitionsAdded = 0; + NINT cleanupFailedCount = 0; + LONG ccode; + STATUS status; + STATUS partialRetVal = zOK; + XML_ElementInfo_s segElement; + + const TagRequest_s tags[] = + { + {TAG_RAIDID, TR_CONTENT_REQUIRED}, + {TAG_RAIDSEGMENTS, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + RAID_ID = 0, + RAID_SEGMENTS = 1, + }; + + /* Tags for parsing */ + const TagRequest_s segTags[] = + { + {TAG_DEVICEID, TR_CONTENT_REQUIRED}, + {TAG_FREESPACEID, TR_CONTENT_REQUIRED}, + {TAG_STARTINGSECTOR, TR_CONTENT_REQUIRED}, + {TAG_NUMSECTORS, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s segTagContent[NELEMS(segTags)-1]; + + enum + { + DEVICE_ID = 0, + FREE_SPACE_ID = 1, + STARTING_SECTOR = 2, + NUM_SECTORS = 3 + }; + + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + + /* Make sure that we have the RAIDMgrID - if not bail. */ + if (RAIDMgrID == -1) + { + return zFAILURE; + } + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Check to see if the PARTAPI.NLM has been loaded. */ + ccode = PART_SetupToCallPARTAPI(); + if (ccode != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Setup to call PART API failed")); + goto exit; + } + + /* Raid device ID. */ + raidID = atol(tagContent[RAID_ID].content); + + /* Create the partitions and add them to the RAID device. */ + start = tagContent[RAID_SEGMENTS].element.dataStart; + for(;;) + { + /* find the next raid segment */ + if (XML_GetTagElement(TAG_SEGMENT, start, + tagContent[RAID_SEGMENTS].element.dataEnd, &segElement) != zOK) + { + break; /* we cannot find any more RAID segments */ + } + + start = segElement.elementEnd; + + if (segElement.dataStart == NULL || + segElement.dataStart[0] == '\0') + { + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + MNSS_BuildResult(virtInfo, zFAILURE, + MSGNot("Missing value in a raidSegments tag")); + goto partialExitCheck; + } + + if ((status = MNSS_GetTagContents(virtInfo, tagName, + &segElement, &segTags, &segTagContent)) != zOK) + { + if (status != zERR_XML_IS_BAD) + { + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + MNSS_BuildResult(virtInfo, zFAILURE, + MSGNot("Missing value in a volSegments tag")); + } + goto partialExitCheck; + } + + ++numPartitions; + + deviceID = atol(segTagContent[DEVICE_ID].content); + freeSpaceID = atol(segTagContent[FREE_SPACE_ID].content); + startSector = atol(segTagContent[STARTING_SECTOR].content); + + /* Modify partition size to line up on a stripe boundry. */ + numSectors = atol(segTagContent[NUM_SECTORS].content); + numSectors += 32; + + /* Now create the actual partition */ + pid = freeSpaceID; + + MPKNSS_UNLOCK(); + ccode = PARTAPICreatePartitionPtr( + deviceID, NETWARE_VDEVICE_PARTITION, startSector, + numSectors, &pid); + MPKNSS_LOCK(); + if (ccode != MM_OK) + { + /* This partition could not be created. Save the reason */ + if (partialRetVal == zOK) + { + partialRetVal = ccode; + } + /* Loop and see if we can create the next partition. */ + continue; + } + ++partitionsCreated; + + /* Expand the raid device with this new partition */ + ZMM_ObjectControl(ccode, RAIDMgrID, MM_EXPAND_RAID, raidID, pid, 0, 0, 0); + if (ccode != MM_OK) + { + if (ccode == MM_MAX_RAID_ELEMENTS_EXCEEDED) + { + /* Successful, but too many segments */ + maxElements = TRUE; + } + /* Save the reason this add raid failed */ + if (partialRetVal == zOK) + { + partialRetVal = ccode; + } + + /* Delete the partition that we couldn't add to the raid */ + ccode = RAID_deleteRAIDPartition(pid); + if (ccode != MM_OK) + { + ++cleanupFailedCount; + } + } + else + { + ++partitionsAdded; + } + } + + /* Unload the PARTAPI.NLM */ + PART_CleanupCallToPARTAPI(); + + /* Add the opening tag separately because we are including some + * extra status values and we have to build it all manually + */ + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + + if (partitionsAdded == 0) + { + /* For some reason, we were unsuccessful in adding any + * partitions. No RAID was modified. + */ + MNSS_BuildResult(virtInfo, partialRetVal, + MSGNot("Unable to expand the RAID device")); + } + else + { + /* At least one partition was added to the RAID. Give partial success*/ + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + +partialExitCheck: + /* If any partitions were added, start a restriping process. */ + if (partitionsAdded != 0) + { + ZMM_ObjectControl(ccode, RAIDMgrID, MM_RESTRIPE_RAID, raidID, 0, 0, 0, 0); + } + + /* Check if we need to return the partialResult tag with the individual + * stats + */ + if ((partialRetVal != zOK) || (cleanupFailedCount) || (maxElements) || + (partitionsAdded != numPartitions)) + { + utf8_t tempBuf[256]; + + sprintf(tempBuf, MSGNot("<"TAG_PARTIALRESULT" "ATR_VALUE + "=\"%d\"><"TAG_DESCRIPTION">"), partialRetVal); + VIRT_AddResultData(virtInfo, tempBuf); + VIRT_AddResultData(virtInfo, MSGNot("The RAID device was expanded, but there was a partial failure")); + VIRT_AddResultData(virtInfo, MSGNot("\n")); + + sprintf(tempBuf, MSGNot( + "<"TAG_PARTITIONSREQUESTED">%u" + "<"TAG_PARTITIONSCREATED">%u" + "<"TAG_PARTITIONSADDED">%u" + "<"TAG_PARTITIONSSTRANDED">%u"), + numPartitions, partitionsCreated, partitionsAdded, cleanupFailedCount); + VIRT_AddResultData(virtInfo, tempBuf); + + if (maxElements) + { + VIRT_AddResultElement(virtInfo, TAG_MAXPARTITIONS, "", FALSE); + } + + VIRT_AddResultData(virtInfo, MSGNot("\n")); + } + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + return zOK; +} +#endif + +/**************************************************************************** + * + * This function starts a restripe on a RAID device + * + ****************************************************************************/ +STATUS MNSS_ProcessRestripeRAID( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ +#if zNETWARE + LONG ccode; + LONG raidID; + BOOL foundMirror; +#endif + STATUS status; + + const TagRequest_s tags[] = + { + {TAG_RAIDID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + RAID_ID = 0, + }; + + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + +#if zNETWARE + MNSS_LoadAppIDs(); + + /* Make sure that we have the RAIDMgrID - if not bail. */ + if (RAIDMgrID == -1) + { + return zFAILURE; + } + + /* Check to see if the PARTAPI.NLM has been loaded. */ + ccode = PART_SetupToCallPARTAPI(); + if (ccode != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Setup to call PART API failed")); + goto exit; + } + + raidID = atol(tagContent[RAID_ID].content); + /* Get the attributes of the RAID device */ + status = PART_CheckForMirror(raidID, &foundMirror); + if (status != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, status, MSGNot("Error getting device information.")); + goto cleanupExit; + } + + /* Start the restriping process. */ + if(foundMirror) + { + MPKNSS_UNLOCK(); + ccode = MM_ForceMirrorGroupInSync(raidID); + MPKNSS_LOCK(); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error starting a synchronization process")); + goto cleanupExit; + } + } + else + { + ZMM_ObjectControl(ccode, RAIDMgrID, MM_RESTRIPE_RAID, + raidID, 0, 0, 0, 0); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error starting a restripe process")); + goto cleanupExit; + } + } + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + +cleanupExit: + /* Unload the PARTAPI.NLM */ + PART_CleanupCallToPARTAPI(); + +#endif +#if zLINUX && !defined(__KERNEL__) + status = Linux_restripeRaid(tagName, virtInfo, tagContent[RAID_ID].content); +#endif + + +exit: + return status; +} + +#if zNETWARE +/**************************************************************************** + * + * This function removes a RAID device + * + ****************************************************************************/ +STATUS MNSS_ProcessRemoveRAID( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + LONG raidID; + LONG ccode; + STATUS status; + + const TagRequest_s tags[] = + { + {TAG_RAIDID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + RAID_ID = 0, + }; + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + + /* Make sure that we have the RAIDMgrID - if not bail. */ + if (RAIDMgrID == -1) + { + return zFAILURE; + } + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, &tags, + &tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Raid device ID. */ + raidID = atol(tagContent[RAID_ID].content); + + /* Delete the raid device. */ + ZMM_ObjectControl(ccode, RAIDMgrID, MM_DELETE_RAID, raidID, 0, 0, 0, 0); + if(ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Remove RAID - failure to delete the RAID device")); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function returns a list of MM partition object IDs for a device + * NB: The function allocates memory and stores the address in *partitions + * This function assumes that all partitions hosted on a device are MM + * objects at the same nesting level (i.e. all partitions on a device are + * siblings). + * + ****************************************************************************/ +LONG getNSSPartitionsOnDevice(LONG obID, LONG **partitions) +{ + GenInfoDef_s info; + ParInfoDef_s obInfo; + struct IOObjectMappingTableInfoDef *map; + LONG *curID; + LONG infLen; + LONG retval = 0; + LONG itemsFound = 0; + LONG item; + LONG cc; + BOOL foundHere = FALSE; + + infLen = sizeof(struct IOObjectMappingTableInfoDef) + (256 * sizeof(LONG)); + map = malloc(infLen); + if (map == NULL) + goto Exit; + + ZMM_ReturnObjectMappingInfo(cc, obID, MM_IO_CLASS, infLen, map); + if (cc != MM_OK) + goto freeExit; + + if (map->childCount == 0) + { + goto freeExit; + } + + /* Enumerate the child objects */ + *partitions = NULL; + curID = map->parentOBIDs; + curID += map->parentCount; + curID += map->siblingCount; + for (item = 0; item < map->childCount; item++, curID++) + { + ZMM_ReturnObjectGenericInfo(cc, *curID, sizeof(info), &info); + if (cc != MM_OK) + continue; + + /* If the object is a partition,... */ + if (info.type == MM_PARTITION_OBJECT) + { + ZMM_ReturnObjectSpecificInfo(cc, *curID, sizeof(obInfo), &obInfo); + if (cc != MM_OK) + continue; + + /* ...a NSS partition */ + if (obInfo.partitiontype == NETWARE_NSS_PARTITION) + { + /* Count it */ + itemsFound++; + foundHere = TRUE; + } + } + + /* If we have seen no partitions and the object has children, scan the children recursively + * NB: This assumes all partition objects will be found at the same nesting depth */ + if ((!foundHere) && (info.childcount > 0)) + { + retval = getNSSPartitionsOnDevice(*curID, partitions); + if (retval != 0) + { + break; + } + } + } + + /* If we exit the loop above having found nothing at this nesting level we're done */ + if (!foundHere) + goto freeExit; + + /* Allocate memory for the partition IDs */ + *partitions = malloc(sizeof(LONG) * itemsFound); + if (*partitions == NULL) + goto freeExit; + + /* Enumerate the child objects again and extract the partition IDs this time */ + curID = map->parentOBIDs; + curID += map->parentCount; + curID += map->siblingCount; + for (item = 0; item < map->childCount; item++, curID++) + { + ZMM_ReturnObjectGenericInfo(cc, *curID, sizeof(info), &info); + if (cc != MM_OK) + continue; + + /* If the object is a partition,... */ + if (info.type == MM_PARTITION_OBJECT) + { + ZMM_ReturnObjectSpecificInfo(cc, *curID, sizeof(obInfo), &obInfo); + if (cc != MM_OK) + continue; + + /* ... a NSS partition */ + if (obInfo.partitiontype == NETWARE_NSS_PARTITION) + { + /* Store its ID */ + (*partitions)[retval] = *curID; + retval++; + if (retval == itemsFound) + { + /* Stop when we have as many items as we found in the first loop */ + break; + } + } + } + } + +freeExit: + free(map); + +Exit: + return retval; +} + + +void getPoolNameFromPartitionID(LONG partID, unsigned char *poolName) +{ + struct LogicalPartitionMappingInfo mapInfo; + LONG cc; + + if (poolName == NULL) + return; + + mapInfo.element[0].volumeName = poolName; + ZMM_ObjectControl(cc, NSSAPPid, MM_POOL_RETURN_PARTITION_MAPPING, partID, + 0, 0, 1, &mapInfo); + if ((cc != MM_OK) || (mapInfo.numberOfElements != 1)) + poolName[0] = 0; +} + + +/**************************************************************************** + * Get the object mapping for a RAID device + ****************************************************************************/ +STATUS getDeviceObjectMapping(LONG devID, LONG **map) +{ + LONG cc; + LONG mapLen; + NINT iterations = 0; + struct IOObjectGenericInfoDef info; + + *map = NULL; + do + { + /* Get the generic info for the device */ + ZMM_ReturnObjectGenericInfo(cc, devID, sizeof(info), &info); + if (cc != MM_OK) + break; + /* Allocate memory for the map */ + mapLen = (info.parentcount + info.siblingcount + info.childcount + 3) * sizeof(LONG); + if (*map != NULL) + free(*map); + *map = malloc(mapLen); + if (*map == NULL) + break; + + /* Get the object mapping */ + ZMM_ReturnObjectMappingInfo(cc, devID, MM_IO_CLASS, mapLen, *map); + + /* Prevent looping forever */ + if (++iterations > 10) + break; + } while (cc == MM_BUFFER_TOO_SMALL); + + if (cc != MM_OK) + return zFAILURE; + + return zOK; +} +#endif + + +/**************************************************************************** + * + * This function removes a RAID device and removes associated DS objects + * e.g. for Pools and Volumes + * + ****************************************************************************/ +STATUS MNSS_ProcessRemoveRAIDSimple( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + + const TagRequest_s tags[] = + { + {TAG_RAIDID, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + RAID_ID = 0, + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + +#if zNETWARE + status = NW_removeRaid2(tagName, virtInfo, atol(tagContent[RAID_ID].content)); +#endif +#if zLINUX && !defined(__KERNEL__) + status = Linux_removeRaid2(tagName, virtInfo, tagContent[RAID_ID].content); +#endif +exit: + return status; +} + + +/**************************************************************************** + * + * This function expands a RAID device with a NETWARE_VDEVICE_PARTITION type. + * + ****************************************************************************/ +STATUS MNSS_ProcessExpandRAID( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + + const TagRequest_s tags[] = + { + {TAG_RAIDID, TR_CONTENT_REQUIRED}, + {TAG_RAIDSEGMENTS, TR_CONTENT_REQUIRED}, +#if zLINUX && !defined(__KERNEL__) + {TAG_NUMSEGMENTS, TR_CONTENT_REQUIRED}, +#endif + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + RAID_ID = 0, + RAID_SEGMENTS = 1, +#if zLINUX && !defined(__KERNEL__) + NUM_SEGMENTS = 2, +#endif + }; + + + ASSERT_MPKNSS_LOCK(); + +// syslog(LOG_INFO, "in MNSS_ProcessExpandRAID"); + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + +#if zNETWARE + /* Fixfixfix needs to modify XML reply to match new doc */ + status = NW_expandRaid(tagName, virtInfo, atol(tagContent[RAID_ID].content), + tagContent[RAID_SEGMENTS].element.dataStart, + tagContent[RAID_SEGMENTS].element.dataEnd); +#endif +#if zLINUX && !defined(__KERNEL__) + status = Linux_expandRaid(tagName, virtInfo, tagContent[RAID_ID].content, + atol(tagContent[NUM_SEGMENTS].content), + tagContent[RAID_SEGMENTS].element.dataStart, + tagContent[RAID_SEGMENTS].element.dataEnd); +#endif + +exit: + return status; +} + + +/**************************************************************************** + * + * This function renames a RAID. + * + ****************************************************************************/ +STATUS MNSS_ProcessRenameRAID( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_RAIDID, TR_CONTENT_REQUIRED}, + {TAG_NAME, TR_CONTENT_REQUIRED}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + RAID_ID = 0, + NAME = 1 + }; + + STATUS status; +#if zNETWARE + LONG ccode; +#endif + + ASSERT_MPKNSS_LOCK(); + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + +#if zNETWARE + MPKNSS_UNLOCK(); + + status = zOK; + ccode = MM_RenameObject(atol(tagContent[RAID_ID].content), tagContent[NAME].content); + if (ccode != MM_OK) + { + MNSS_ReturnResult(virtInfo, tagName, ccode, + MSGNot("Error renaming RAID")); + MPKNSS_LOCK(); + goto exit; + } + + MPKNSS_LOCK(); + + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + +#endif +#if zLINUX && !defined(__KERNEL__) + status = Linux_renameRaid(tagName, virtInfo, tagContent[RAID_ID].content, + tagContent[NAME].content); +#endif + +exit: + return status; +} + diff --git a/src/nwnss/sharedsrc/manageServer.c.h b/src/nwnss/sharedsrc/manageServer.c.h new file mode 100644 index 0000000..e12bc52 --- /dev/null +++ b/src/nwnss/sharedsrc/manageServer.c.h @@ -0,0 +1,1679 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2005 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: bbhanuprakash $ + | $Date: 2008-05-09 09:36:54 +0530 (Fri, 09 May 2008) $ + | + | $RCSfile$ + | $Revision: 2336 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage NSS using XML + | + +-------------------------------------------------------------------------*/ +#if defined(__KERNEL__) +#include +#endif +#include +#include +#include + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +#include "manageStartup.h" +#endif +#if zLINUX && !defined(__KERNEL__) +#define stricmp(p1,p2) strcasecmp(p1,p2) +#include +#include +extern void syslog (int __pri, __const char *__fmt, ...) + __attribute__ ((__format__(__printf__, 2, 3))); +#include +#include "manageEVMS.h" +#endif + +#include +#include +#include + +#include "manage.h" +#include "manageNlm.h" +#include "manageServer.h" +#include "comnPublics.h" +#include "comnAuthorize.h" +#include "virtualIO.h" +#include "xmlTags.h" + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) + +STATUS MNSS_ProcessGetFreespace(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessListServerDevices(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessListServerPartitions(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ProcessListServerPools(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +extern STATUS FillPoolAttributeInfo( + VirtInfo_s *virtInfo, + char *tagName, + QUAD attributes); + +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ + +SiblingElements_s ServerElements[] = +{ + {TAG_GETSERVERFREESPACE, MNSS_ProcessGetFreespace}, + {TAG_LISTDEVICES, MNSS_ProcessListServerDevices}, + {TAG_LISTPARTITIONS, MNSS_ProcessListServerPartitions}, + {TAG_LISTPOOLS, MNSS_ProcessListServerPools}, + {0} +}; +#endif + + + +#if zLINUX && !defined(__KERNEL__) +STATUS Linux_GetFreespace( + utf8_t *tagName, + VirtInfo_s *virtInfo, + BOOL details) +{ + int ccode; + QUAD freeSpaceSize; + utf8_t tempBuf[512] = ""; + NINT len; + NINT i, j; + EvmsObjectArray_s *deviceObjects = NULL; + handle_object_info_t *object_info = NULL; + EvmsSegmentInfoArray_s *segments = NULL; + storage_object_info_t *info; + EvmsExtendInfo_s evmsExtInfo; + BOOL infoFound = FALSE; + NINT regionType; + QUAD elementSize; + + ASSERT_MPKNSS_LOCK(); + + if ((ccode = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return zOK; + } + + ccode = evmsOpenEngine(EVMS_ENGINE_READONLY); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error opening EVMS engine. It might be " + "opened by another application")); + goto exit; + } + + ccode = evmsGetDevices(DEVICE_ALL, &deviceObjects); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting devices")); + goto close_engine; + } + + if (deviceObjects == NULL) + { + /* It could happen, although we should find at least one hard disk */ + goto close_engine; + } + + for (i = 0; i < deviceObjects->count; i++) + { + ZOS_evms_get_info(ccode, deviceObjects->object[i].handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device info: %s"), evmsGetErrString(ccode)); + goto close_engine; + } + + if (deviceObjects->object[i].deviceType == DEVICE_PHYSICAL) + { + info = &object_info->info.disk; + regionType = DEVICE_PHYSICAL; + + // FixFixFix + // Because of limitiations in the partitioning scheme used by NetWare + // (based on the DOS partitioning scheme). We currently cannot support + // devices greater than 2.2 terabytes (2^32 * 512 bytes). + // + if (info->size > 0xffffffff ) + { + goto next; + } + } + else + { + info = &object_info->info.region; + + // get virtual device type + ccode = evmsGetDeviceType(deviceObjects->object[i].handle, ®ionType, NULL, &elementSize); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Couldn't get device type: %s"), + evmsGetErrString(ccode)); + goto close_engine; + } + } + + freeSpaceSize = 0; + if (regionType == DEVICE_MIRROR) + { + /* raid 1 device doesn't have partition within it. If there's + * no pool created on top of it, it's free, get its size instead + */ + if (info->parent_objects == NULL || info->parent_objects->count == 0) + { + freeSpaceSize = elementSize * EVMS_VSECTOR_SIZE; + } + } + else + { + ccode = evmsGetDeviceSegments(info, TRUE, &segments, &freeSpaceSize); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device free space info: %s"), + evmsGetErrString(ccode)); + goto close_engine; + } + } + +// syslog(LOG_INFO, "free space: %u\n", freeSpaceSize); + if (freeSpaceSize == 0) + { + goto next; + } + + if (details == FALSE) + { + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_DEVICESIMPLEINFO, + FALSE, TRUE)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding tag\n")); + goto close_engine; + } + sprintf(tempBuf, + "<"TAG_OBJECTID">%s" + "<"TAG_NAME">%s" + "<"TAG_SIZE">%Lu", + info->name, + info->name, + freeSpaceSize); + len = strlen(tempBuf); + + if (deviceObjects->object[i].deviceType == DEVICE_RAID) + { + + strcpy(&tempBuf[len], "<"TAG_RAID">"); + } + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding result data\n")); + goto close_engine; + } + } + else + { + /* Commenting this block for 252461. Don't + know why it was there at the first place. + */ +#if 0 + /* Skip RAID devices */ + if (deviceObjects->object[i].deviceType == DEVICE_RAID) + { + goto next; + } +#endif + /* skip the freespace whose size is less than 10 MB */ + if (freeSpaceSize <= 0) + { + goto next; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_DEVICESIMPLEINFO, + FALSE, TRUE)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding tag\n")); + goto close_engine; + } + + sprintf(tempBuf, + "<"TAG_OBJECTID">%s" + "<"TAG_NAME">%s" + "<"TAG_UNITSIZE">%u", + info->name, + info->name, + EVMS_VSECTOR_SIZE); + + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding result data\n")); + goto close_engine; + } + + if (segments != NULL) + { + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_FREESPACES, + FALSE, TRUE)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding tag\n")); + goto close_engine; + } + + for (j = 0; j < segments->count; j++) + { + if (segments->segment[j].data_type == FREE_SPACE_TYPE) + { + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_FREESPACEINFO, + FALSE, TRUE)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding tag\n")); + goto close_engine; + } + + sprintf(tempBuf, "<"TAG_FREESPACEID">%s" + "<"TAG_SIZE">%Lu" + "<"TAG_OFFSET">%Lu", + segments->segment[j].name, segments->segment[j].size, + (QUAD)(segments->segment[j].start * segments->segment[j].sectorSize)); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding result data\n")); + goto close_engine; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_FREESPACEINFO, + TRUE, TRUE)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding tag\n")); + goto close_engine; + } + } + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_FREESPACES, + TRUE, TRUE)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding tag\n")); + goto close_engine; + } + } + else + { + /* raid 1 device. Because there's no partition within it, + * use device info instead + */ + sprintf(tempBuf, + "<"TAG_FREESPACES">""<"TAG_FREESPACEINFO">" + "<"TAG_FREESPACEID">%s" + "<"TAG_SIZE">%Lu" + "<"TAG_OFFSET">0" + """", + info->name, freeSpaceSize); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding result data\n")); + goto close_engine; + } + } + } + + if (deviceObjects->object[i].deviceType == DEVICE_PHYSICAL) + { + if (info->flags & SOFLAG_CLUSTER_SHARED) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_SHARED, "", FALSE)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding element\n")); + goto close_engine; + } + } + } + else + { + ccode = evmsGetExtendedInfo(deviceObjects->object[i].handle, (BYTE *)MSGNot("Flags"), + &infoFound, &evmsExtInfo); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device flags info: %s"), evmsGetErrString(ccode)); + goto close_engine; + } + + if (infoFound) + { + if (evmsExtInfo.value.ui32 & STATUS_MIRRORED) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_MIRRORED, "", FALSE)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding element\n")); + goto close_engine; + } + } + + // Check if device is shared. + // if (info->flags & SOFLAG_CLUSTER_SHARED) + if (evmsExtInfo.value.ui32 & STATUS_SHARED) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_SHARED, "", FALSE)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding element\n")); + goto close_engine; + } + } + } + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_DEVICESIMPLEINFO, + TRUE, TRUE)) != zOK) + { + sprintf(tempBuf, MSGNot("Error adding tag\n")); + goto close_engine; + } +next: + if (segments != NULL) + { + free(segments); + segments = NULL; + } + + ZOS_evms_free(object_info); + object_info = NULL; + } + + +close_engine: + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + evmsCloseEngine(); + +exit: + if (ccode == 0) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, tempBuf); + } + + if (segments != NULL) + { + free(segments); + } + + if (deviceObjects != NULL) + { + free(deviceObjects); + } + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} + + +STATUS Linux_ListServerDevices( + utf8_t *tagName, + VirtInfo_s *virtInfo, + NINT deviceType) +{ + int ccode; + NINT i; + utf8_t tempBuf[512] = ""; + EvmsObjectArray_s *deviceObjects = NULL; + handle_object_info_t *object_info = NULL; + storage_object_info_t *info; + EvmsExtendInfo_s evmsExtInfo; + BOOL infoFound = FALSE; + +// syslog(LOG_INFO, "Linux_ListServerDevices, deviceType = %d\n", deviceType); + + ASSERT_MPKNSS_LOCK(); + + if ((ccode = VIRT_AddResultTag(virtInfo, tagName, + FALSE, TRUE)) != zOK) + { + ccode = zOK; + goto exit; + } + + ccode = evmsOpenEngine(EVMS_ENGINE_READONLY); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error opening EVMS engine. It might be " + "opened by another application")); + goto exit; + } + + ccode = evmsGetDevices(deviceType, &deviceObjects); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error getting devices")); + goto close_engine; + } + + if (deviceObjects == NULL) + { + /* it could happen especially when device type is raid or mirror */ + goto close_engine; + } + + for (i = 0; i < deviceObjects->count; i++) + { + ZOS_evms_get_info(ccode, deviceObjects->object[i].handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device generic info: %s"), + evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, TAG_SERVERDEVICEINFO, ccode, tempBuf); + goto close_engine; + } + + if (deviceObjects->object[i].deviceType == DEVICE_PHYSICAL) + { + info = &object_info->info.disk; + } + else + { + info = &object_info->info.region; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_SERVERDEVICEINFO, + FALSE, TRUE)) != zOK) + { + goto close_engine; + } + + sprintf(tempBuf, + "<"TAG_OBJECTID">%s" + "<"TAG_NAME">%s", + info->name, + info->name); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto close_engine; + } + + if (deviceObjects->object[i].deviceType == DEVICE_PHYSICAL) + { + if (info->flags & SOFLAG_CLUSTER_SHARED) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_SHARED, "", FALSE)) != zOK) + { + goto close_engine; + } + } + } + else + { + ccode = evmsGetExtendedInfo(deviceObjects->object[i].handle, (BYTE *)MSGNot("Flags"), + &infoFound, &evmsExtInfo); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device flags info: %s"), evmsGetErrString(ccode)); + MNSS_BuildResult(virtInfo, ccode, tempBuf); + VIRT_AddResultTag(virtInfo, TAG_SERVERDEVICEINFO, TRUE, TRUE); + goto close_engine; + } + + if (infoFound) + { + if (evmsExtInfo.value.ui32 & STATUS_MIRRORED) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_MIRRORED, "", FALSE)) != zOK) + { + goto close_engine; + } + } + + // Check if device is shared. + // if (info->flags & SOFLAG_CLUSTER_SHARED) + if (evmsExtInfo.value.ui32 & STATUS_SHARED) + { + if ((ccode = VIRT_AddResultElement(virtInfo, + TAG_SHARED, "", FALSE)) != zOK) + { + goto close_engine; + } + } + } + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_SERVERDEVICEINFO, + TRUE, TRUE)) != zOK) + { + goto close_engine; + } + + ZOS_evms_free(object_info); + object_info = NULL; + } + +close_engine: + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + evmsCloseEngine(); + + if (ccode == 0) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error getting device list")); + } + +exit: + if (deviceObjects != NULL) + { + free(deviceObjects); + } + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; +} + +STATUS Linux_ListServerPartitions( + utf8_t *tagName, + VirtInfo_s *virtInfo, + BOOL details) +{ + int ccode; + utf8_t tempBuf[4096] = ""; + NINT len; + NINT i, j; + NINT partitionType; + EvmsObjectArray_s *deviceObjects = NULL; + handle_object_info_t *object_info = NULL; + EvmsSegmentInfoArray_s *segments = NULL; + storage_object_info_t *info; + BOOL hasPool; + BYTE poolName[zMAX_COMPONENT_NAME]; + + ASSERT_MPKNSS_LOCK(); + + if ((ccode = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return zOK; + } + + ccode = evmsOpenEngine(EVMS_ENGINE_READWRITE); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error opening EVMS engine. It might be " + "opened by another application")); + goto exit; + } + + ccode = evmsGetDevices(DEVICE_ALL, &deviceObjects); + if (ccode != 0) + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error getting devices")); + goto close_engine; + } + + if (deviceObjects == NULL) + { + /* It could happen, although we should find at least one hard disk */ + goto close_engine; + } + + for (i = 0; i < deviceObjects->count; i++) + { + ZOS_evms_get_info(ccode, deviceObjects->object[i].handle, &object_info); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device generic info: %s"), + evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, TAG_PARTITION, ccode, tempBuf); + goto close_engine; + } + + if (deviceObjects->object[i].deviceType == DEVICE_PHYSICAL) + { + info = &object_info->info.disk; + } + else + { + info = &object_info->info.region; + } + +// syslog(LOG_INFO, "device type: %d\n", deviceObjects->object[i].deviceType); + + ccode = evmsGetDeviceSegments(info, TRUE, &segments, NULL); + if (ccode != 0) + { + sprintf(tempBuf, MSGNot("Error getting device free space info: %s"), + evmsGetErrString(ccode)); + MNSS_ReturnResult(virtInfo, TAG_PARTITION, ccode, tempBuf); + goto close_engine; + } + + if (segments == NULL) + { + goto next; + } + +// syslog(LOG_INFO, "segment count: %d\n", segments->count); + for (j = 0; j < segments->count; j++) + { + EvmsSegmentInfo_s *segInfo; + handle_object_info_t *parentInfo; + +// syslog(LOG_INFO, "name: %s\n", segments->segment[j].name); + if (segments->segment[j].data_type == META_DATA_TYPE) + { + continue; + } + + // If this is a segment that is a child of another segment + // then ignore it. + segInfo = &segments->segment[j]; + if (segInfo->parentCount > 1) + { + continue; + } + if (segInfo->parentCount == 1) + { + ZOS_evms_get_info(ccode, segInfo->firstParentHandle, &parentInfo); + if (ccode == 0) + { + if (parentInfo->type == SEGMENT) + { + ZOS_evms_free(parentInfo); + continue; + } + ZOS_evms_free(parentInfo); + } + else + { + syslog(LOG_WARNING, "Error %d getting EVMS info on an objects parent\n", ccode); + } + } + + ccode = evmsGetSegmentType(segments->segment[j].handle, + segments->segment[j].data_type, &partitionType); + if (ccode != 0) + { + goto close_engine; + } + + sprintf(tempBuf, + "<"TAG_PARTITION">" + "<"TAG_PARTITIONID">%s" + "<"TAG_TYPE">%d", + segments->segment[j].name, + partitionType & 0xFF); + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + goto close_engine; + } + + if (details) + { + sprintf(tempBuf, + "<"TAG_DETAILS">" + "<"TAG_STATE">%s" + "<"TAG_DEVICEID">%s", + segments->segment[j].data_type == DATA_TYPE ? "used" : "free", + info->name); + len = strlen(tempBuf); + + if ((ccode = evmsGetPoolNameFromExtendInfo(segments->segment[j].handle, + &hasPool, poolName)) != 0) + { + VIRT_AddResultTag(virtInfo, TAG_PARTITION, TRUE, TRUE); + goto close_engine; + } + + // get label information + { + BOOL infoFound = FALSE; + EvmsExtendInfo_s extendInfo; + + ccode = evmsGetExtendedInfo(segments->segment[j].handle, + (BYTE *)MSGNot("Label"), &infoFound, &extendInfo); + if(ccode != 0) + { + VIRT_AddResultTag(virtInfo, TAG_PARTITION, TRUE, TRUE); + goto close_engine; + } + + if (infoFound && strcmp(extendInfo.value.s, "")) + { + sprintf(&tempBuf[len], + "<"TAG_LABEL">%s", + extendInfo.value.s); + len = strlen(tempBuf); + evmsFreeExtendedInfo(&extendInfo); + } + } + + if (hasPool) + { + sprintf(&tempBuf[len], + "<"TAG_POOLNAME">%s", + poolName); + } +/* Bug:303796. Pool name is not stored for snapshot partitions. Here snapshot + * name is displayed when the file system installed is NSSFS + */ + else + { + object_handle_t volHandle; + plugin_handle_t fsHandle; + handle_object_info_t *volInfo = NULL; + handle_object_info_t *fsInfo = NULL; + handle_object_info_t *segInfo = NULL; + + ZOS_evms_get_info(ccode, segments->segment[j].handle, &segInfo); + if(ccode == 0) + { + volHandle = segInfo->info.segment.volume; + if(volHandle) + { + ZOS_evms_get_info(ccode, volHandle, &volInfo); + if(ccode == 0) + { + fsHandle = volInfo->info.volume.file_system_manager; + if(fsHandle) + { + ZOS_evms_get_info(ccode, fsHandle, &fsInfo); + if(ccode == 0) + { + if(!strcmp(fsInfo->info.plugin.short_name, PLUGIN_NSSFS)) + { + sprintf(&tempBuf[len], + "<"TAG_POOLNAME">%s" + "", + strrchr(volInfo->info.volume.name, '/')+1); + + } + } + if(fsInfo) + { + + ZOS_evms_free(fsInfo); + } + } + } + + if(volInfo) + { + ZOS_evms_free(volInfo); + } + } + } + if(segInfo) + { + ZOS_evms_free(segInfo); + } + } + + len = strlen(tempBuf); + + sprintf(&tempBuf[len], + "<"TAG_STARTINGSECTOR">%u", segments->segment[j].start); + len = strlen(tempBuf); + + sprintf(&tempBuf[len], + "<"TAG_SIZE">%Lu", segments->segment[j].size); + len = strlen(tempBuf); + + ZOS_evms_can_expand(ccode, segments->segment[j].handle); + if (ccode == 0) + { + expand_handle_array_t *expand_points; + NINT k; + sector_count_t sectors = 0; + + /* can expand */ + ZOS_evms_get_expand_points(ccode, segments->segment[j].handle, &expand_points); + if (ccode != 0) + { + VIRT_AddResultTag(virtInfo, TAG_PARTITION, TRUE, TRUE); + goto close_engine; + } + + for (k = 0; k < expand_points->count; k++) + { + sectors += expand_points->expand_point[i].max_expand_size; + } + + ZOS_evms_free(expand_points); + + sprintf(&tempBuf[len], + "<"TAG_GROWABLE"/>" + "<"TAG_GROWSIZE">%Lu", + (QUAD)(sectors * segments->segment[j].sectorSize)); + len = strlen(tempBuf); + } + + ZOS_evms_can_shrink(ccode, segments->segment[j].handle); + if (ccode == 0) + { + sprintf(&tempBuf[len], "<"TAG_SHRINKABLE"/>"); + len = strlen(tempBuf); + } + +/*Fixfixfix need to add hotfix tags */ + { + object_handle_t handle; + NINT regionType; + BYTE regionName[zMAX_COMPONENT_NAME]; + QUAD regionSize; + + ccode = evmsGetParentRegion(segments->segment[j].handle, &handle, + ®ionType, regionName, ®ionSize); + if (ccode != 0) + { + VIRT_AddResultTag(virtInfo, TAG_PARTITION, TRUE, TRUE); + goto close_engine; + } + +// syslog(LOG_INFO, "name: %s\n", segments->segment[j].name); +// syslog(LOG_INFO, "handle: %u", handle); + if (handle != -1) + { + if (regionType == REGION_LOGICALPARTITION) + { + sprintf(&tempBuf[len], + "<"TAG_LOGICALPARTITIONID">%s" + "<"TAG_LOGICALPARTITIONCAPACITY">%Lu", + regionName, + regionSize); + } + else if (regionType == REGION_MIRROR) + { + /* this is a special case */ + sprintf(&tempBuf[len], + "<"TAG_MIRRORID">%s", + regionName); + len = strlen(tempBuf); + + ccode = evmsGetParentRegion(handle, &handle, + ®ionType, regionName, ®ionSize); + if (ccode != 0) + { + VIRT_AddResultTag(virtInfo, TAG_PARTITION, TRUE, TRUE); + goto close_engine; + } + + if (handle != -1 && regionType == REGION_LOGICALPARTITION) + { + sprintf(&tempBuf[len], + "<"TAG_LOGICALPARTITIONID">%s" + "<"TAG_LOGICALPARTITIONCAPACITY">%Lu", + regionName, + regionSize); + } + } + else if (regionType == REGION_RAID) + { + sprintf(&tempBuf[len], + "<"TAG_RAIDID">%s", + regionName); + } + } + } + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + VIRT_AddResultTag(virtInfo, TAG_PARTITION, TRUE, TRUE); + goto close_engine; + } + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_DETAILS, + TRUE, TRUE)) != zOK) + { + VIRT_AddResultTag(virtInfo, TAG_PARTITION, TRUE, TRUE); + goto close_engine; + } + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_PARTITION, + TRUE, TRUE)) != zOK) + { + goto close_engine; + } + } + +next: + if (segments != NULL) + { + free(segments); + segments = NULL; + } + + ZOS_evms_free(object_info); + object_info = NULL; + } + + +close_engine: + if (object_info != NULL) + { + ZOS_evms_free(object_info); + } + + evmsCloseEngine(); + + if (ccode == 0) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error getting partition list")); + } + +exit: + if (segments != NULL) + { + free(segments); + } + + if (deviceObjects != NULL) + { + free(deviceObjects); + } + + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return zOK; + + +} +#endif + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) +/**************************************************************************** + * + * This function gets a server's free space. This will return a list of raw + * physical freespace, mirror group freespace and raid virtual device + * freespace. + * + ****************************************************************************/ +STATUS MNSS_ProcessGetFreespace( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + BOOL details = FALSE; + + const TagRequest_s tags[] = + { + {ATR_TYPE, TR_ATTRIBUTE | TR_OPTIONAL}, + {0} + }; + + enum + { + TYPE = 0, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + ASSERT_MPKNSS_LOCK(); + + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + return zOK; + } + return status; + } + + if (tagContent[TYPE].flags & TR_TAG_FOUND) + { + if (stricmp(tagContent[TYPE].content, MSGNot("detail")) == 0) + { + details = TRUE; + } + } + +#if zNETWARE + return NW_GetFreespace(tagName, virtInfo, details); +#endif +#if zLINUX && !defined(__KERNEL__) + return Linux_GetFreespace(tagName, virtInfo, details); +#endif +} + +/**************************************************************************** + * + * This function gets a server's devices. + * + ****************************************************************************/ +STATUS MNSS_ProcessListServerDevices( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_PHYSICAL, TR_OPTIONAL}, + {TAG_RAID, TR_OPTIONAL}, + {TAG_MIRROR, TR_OPTIONAL}, + {TAG_VIRTUAL, TR_OPTIONAL}, + {ATR_TYPE, TR_ATTRIBUTE | TR_OPTIONAL}, + {0} + }; + + enum + { + PHYSICAL = 0, + RAID = 1, + MIRROR = 2, + VIRTUAL = 3, + TYPE = 4, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + STATUS status; + NINT deviceType = 0; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + return zOK; + } + return status; + } + + /* The old method of selecting what to return was a single tag that + * allowed one option to be selected (with all being one option). + * This has been augmented with a tag per option to allow other + * combinations than one or all - see the cases below this tag. */ + if (tagContent[TYPE].flags & TR_TAG_FOUND) + { + if (stricmp(tagContent[TYPE].content, MSGNot("all")) == 0) + { + deviceType = DEVICE_ALL; + } + else if (stricmp(tagContent[TYPE].content, MSGNot("physical")) == 0) + { + deviceType = DEVICE_PHYSICAL; + } + else if (stricmp(tagContent[TYPE].content, MSGNot("raid")) == 0) + { + deviceType = DEVICE_RAID; + } + else if (stricmp(tagContent[TYPE].content, MSGNot("mirror")) == 0) + { + deviceType = DEVICE_MIRROR; + } + else if (stricmp(tagContent[TYPE].content, MSGNot("virtual")) == 0) + { + deviceType = DEVICE_RAID | DEVICE_MIRROR; + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Invalid device type specified")); + return zOK; + } + } + + /* Allow individual options to be selected one at a time to create combinations. + * NB: Due to the need to support the previous functionality this actually results + * in obtaining the sum of both sets, based and individual item based */ + if (tagContent[PHYSICAL].flags & TR_TAG_FOUND) + { + deviceType |= DEVICE_PHYSICAL; + } + if (tagContent[RAID].flags & TR_TAG_FOUND) + { + deviceType |= DEVICE_RAID; + } + if (tagContent[MIRROR].flags & TR_TAG_FOUND) + { + deviceType |= DEVICE_MIRROR; + } + if (tagContent[VIRTUAL].flags & TR_TAG_FOUND) + { + deviceType |= DEVICE_RAID | DEVICE_MIRROR; + } + + if (deviceType == 0) + { + deviceType |= DEVICE_ALL; + } + +#if zNETWARE + return NW_ListServerDevices(tagName, virtInfo, deviceType); +#endif +#if zLINUX && !defined(__KERNEL__) + return Linux_ListServerDevices(tagName, virtInfo, deviceType); +#endif +} + +/**************************************************************************** + * + * This function gets a server's partitions. (Linux) + * + ****************************************************************************/ +STATUS MNSS_ProcessListServerPartitions( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + BOOL details = FALSE; + STATUS status; + + const TagRequest_s tags[] = + { + {ATR_TYPE, TR_ATTRIBUTE | TR_OPTIONAL}, + {0} + }; + + enum + { + TYPE = 0, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + ASSERT_MPKNSS_LOCK(); + + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + return zOK; + } + return status; + } + + if (tagContent[TYPE].flags & TR_TAG_FOUND) + { + if (stricmp(tagContent[TYPE].content, MSGNot("detail")) == 0) + { + details = TRUE; + } + } + +#if zNETWARE + return NW_ListServerPartitions(tagName, virtInfo, details); +#endif +#if zLINUX && !defined(__KERNEL__) + return Linux_ListServerPartitions(tagName, virtInfo, details); +#endif +} + + +#ifndef __linux__ +/**************************************************************************** + * + * This function lists the adapters on a server. + * + ****************************************************************************/ +STATUS MNSS_ProcessListAdapters( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + OBID adapterID; + LONG ccode = MM_OK; + struct AdapterSpecificInfoDef adapterSpecInfo; + utf8_t tempBuf[512] = ""; + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadSubSystemIDs(); + + // Find all adapters + + adapterID=-1; + + do + { + MPKNSS_UNLOCK(); + ccode = MM_FindObjectType(MM_IO_CLASS, MM_ADAPTER_OBJECT, &adapterID); + if (ccode != MM_OK) + { + MPKNSS_LOCK(); + break; + } + + // Get the information on this adapter. + ccode = MM_ReturnObjectSpecificInfo(adapterID, sizeof(adapterSpecInfo), + &adapterSpecInfo); + if (ccode != MM_OK) + { + MPKNSS_LOCK(); + MNSS_ReturnResult(virtInfo, TAG_ADAPTERINFO, ccode, + MSGNot("Error getting adapter specific info")); + ccode = MM_OK; + continue; // go to the next adapter + } + + MPKNSS_LOCK(); + + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_ADAPTERINFO, + FALSE, TRUE)) != zOK) + { + break; + } + + sprintf(tempBuf, + "<"TAG_ADAPTERID">%u" + "<"TAG_NAME">%s", + adapterID, + adapterSpecInfo.systemname); + + if ((ccode = VIRT_AddResultData(virtInfo, tempBuf)) != zOK) + { + break; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + if ((ccode = VIRT_AddResultTag(virtInfo, TAG_ADAPTERINFO, + TRUE, TRUE)) != zOK) + { + break; + } + } while (ccode == MM_OK); + + if (ccode == MM_OBJECT_NOT_FOUND) + { + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + } + else + { + MNSS_BuildResult(virtInfo, ccode, MSGNot("Error getting adapter list")); + } + + return zOK; +} +#endif //__linux__ +#endif + + +#if zNETWARE || (zLINUX && defined(__KERNEL__)) +/* Get the setNum value for a Set item */ +/* This belongs in que.h */ +#define SET_GETSETNUM(item, linkField) \ + item->linkField.setNum + +/* Find the entry following the specified _setNum */ +/* This belongs in que.h */ +#define SET_FINDENTRY(head, item, type, linkField, _setNum) \ + { \ + type *_item; \ + SETlink_t _dummySet; \ + \ + _dummySet.setNum = _setNum; \ + item = NULL; \ + SET_FOREACH(head, _item, type, linkField) \ + { \ + if (SET_GT(&(_item)->linkField, &_dummySet)) \ + { \ + item = _item; \ + break; \ + } \ + } \ + } + +/**************************************************************************** + * + * This function is the kernel piece to list all pools on the server + * + ****************************************************************************/ +STATUS GetNextPoolName(BOOL firstTime, + SQUAD *cookie, + unicode_t *uniName, + NINT uniNameLen, + BOOL noSnapshot, + NINT *poolState, + BOOL *isShared, + QUAD *enabledAttr) +{ + STATUS status = zFAILURE; + GeneralMsg_s genMsg; + Pool_s *pool; + Pool_s *dummyPool = NULL; +#ifndef __linux__ + char poolNameAndOther[zMAX_COMPONENT_NAME]; +#endif + BOOL isSnapshot; + + ASSERT_MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + if (firstTime) + { + SET_PEEK(&NSSMasterPoolList, pool, Pool_s, masterPoolLink); + } + else + { + SET_FINDENTRY(&NSSMasterPoolList, pool, Pool_s, masterPoolLink, *cookie); + } + + while (pool != NULL) + { + COMN_USE_BEAST( &pool->POOLroot ); + X_LATCH( &pool->cvsLatch ); + + (void)COMN_GetPoolName(&genMsg, pool, uniName, uniNameLen); + ClearErrno( &genMsg ); + +#ifdef __linux__ + if(noSnapshot == TRUE) + { + if(pool->p.PP_enabledFeatures & zPOOL_FEATURE_SNAPSHOT) + { + isSnapshot = TRUE; + status = zFAILURE; + goto nextPool; + } + } +#else + if(noSnapshot == TRUE) + { + /* pool name */ + if ((status = LB_UnicodeToByte(NSS_UNI_CONVERSION_RAW, poolNameAndOther, + sizeof(poolNameAndOther), uniName, NULL)) != zOK) + { + UNX_LATCH( &pool->cvsLatch ); + COMN_Release( &pool ); + return status; + } + + if((status = SERV_IsSnapshot(poolNameAndOther, &isSnapshot)) != zOK) + { + UNX_LATCH( &pool->cvsLatch ); + COMN_Release( &pool ); + return status; + } + + if(isSnapshot == TRUE) + { + status = zFAILURE; + goto nextPool; + } + } +#endif + status = zOK; + *cookie = SET_GETSETNUM(pool, masterPoolLink); + break; + +nextPool: + UNX_LATCH( &pool->cvsLatch ); + dummyPool = pool; + pool = SET_NEXT(&NSSMasterPoolList, pool, Pool_s, masterPoolLink); + COMN_Release( &dummyPool ); + } + + if (pool != NULL) + { + if (status == zOK) + { + *poolState = pool->state; + *isShared = pool->p.PP_enabledFeatures & zPOOL_FEATURE_SHARED_CLUSTER; + *enabledAttr = pool->p.PP_enabledFeatures; + } + UNX_LATCH( &pool->cvsLatch ); + COMN_Release( &pool ); + } + return(status); +} +#endif + + +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) + +/**************************************************************************** + * + * This function lists all pools on the server + * + ****************************************************************************/ +STATUS MNSS_ProcessListServerPools( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + BOOL noSnapshot = FALSE; + BOOL firstTime; + BOOL isShared; + NINT poolState; + char *stateString; + SQUAD cookie; + QUAD enabledAttr; + utf8_t poolNameAndOther[zMAX_COMPONENT_NAME]; + unicode_t pname[zMAX_COMPONENT_NAME]; + + const TagRequest_s tags[] = + { + {TAG_NOSNAPSHOT, TR_OPTIONAL}, + {0} + }; + + enum + { + no_Snapshot = 0, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + goto exit; + } + + if (tagContent[no_Snapshot].flags == TR_TAG_FOUND) + { + noSnapshot = TRUE; + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto exit; + } + + firstTime = TRUE; + cookie = -1; + while ((status = GetNextPoolName(firstTime, &cookie, pname, NELEMS(pname), + noSnapshot, &poolState, &isShared, &enabledAttr)) == zOK) + { + firstTime = FALSE; + + /* pool name */ + if (uni2utf(pname, poolNameAndOther, sizeof(poolNameAndOther)) == -1) + { + status = zFAILURE; + MNSS_BuildResult(virtInfo, status, MSGNot("Error converting from unicode")); + goto poolError; + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLSIMPLEINFO, FALSE, TRUE)) + != zOK) + { + return status; + } + + if ((status = VIRT_AddResultElement(virtInfo, TAG_POOLNAME, + poolNameAndOther, FALSE)) != zOK) + { + return status; + } + + stateString = MLIB_GetPoolStateName(poolState); + + // Check if this pool is on shared devices + if(isShared) + { + sprintf(poolNameAndOther, "<"TAG_POOLSTATE">%s<" + TAG_SHARED"/>", stateString); + } + else + { + sprintf(poolNameAndOther, "<"TAG_POOLSTATE">%s", stateString); + } + + if ((status = VIRT_AddResultData(virtInfo, poolNameAndOther)) != zOK) + { + return status; + } + + /* EnabledAttributes */ + if ((status = FillPoolAttributeInfo(virtInfo, TAG_ENABLEDATTRIBUTES, + enabledAttr)) != zOK) + { + return status; + } + + if ((status = VIRT_AddResultTag(virtInfo, TAG_POOLSIMPLEINFO, TRUE, TRUE)) != + zOK) + { + + MNSS_BuildResult(virtInfo, status, + MSGNot("Error adding pool info result tag")); + goto poolError; + } + } + + status = zOK; + MNSS_BuildResult(virtInfo, status, XML_SUCCESS); + +poolError: + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); +exit: + return status; +} +#endif + +#ifndef __linux__ +STATUS SERV_IsSnapshot( + char *poolName, + BOOL *isSnapshot) +{ + LONG ccode; + NINT numElements; + struct VolumeMappingInfo *volMapping = NULL; + struct IOObjectGenericInfoDef genInfo; + + ASSERT_MPKNSS_LOCK(); + + MNSS_LoadAppIDs(); + + *isSnapshot = FALSE; + + numElements = 1; + do + { + if(volMapping != NULL) + { + numElements = volMapping->numberOfElements; + free(volMapping); + } + + volMapping = (struct VolumeMappingInfo *)malloc( + sizeof(struct VolumeMappingInfo) + + ((numElements-1) * sizeof(struct VolumeMappingElementDef))); + if (volMapping == NULL) + { + ccode = zERR_NO_MEMORY; + goto exit; + } + + // Get the partitions for the pool (by pool name) + volMapping->volumeName = poolName; + ZMM_ObjectControl(ccode, + NSSAPPid, + MM_POOL_RETURN_MAPPING, + 0, 0, 0, + numElements, + volMapping); + + if (ccode != MM_OK && ccode != MM_BUFFER_TOO_SMALL) + { + goto exit; + } + }while((ccode == MM_BUFFER_TOO_SMALL) && (numElements == 1)); + + // Get the generic info on the partition object + ZMM_ReturnObjectGenericInfo(ccode, + volMapping->element[0].logicalPartition, + sizeof(struct IOObjectGenericInfoDef), &genInfo); + + if (ccode != MM_OK) + { + goto exit; + } + + if (genInfo.type == MM_SNAPSHOT_OBJECT) + { + *isSnapshot = TRUE; + } + +exit: + if(volMapping != NULL) + { + free(volMapping); + volMapping = NULL; + } + return ccode; +} + +#endif //__linux__ diff --git a/src/nwnss/sharedsrc/manageUserSpaceRestr.c.h b/src/nwnss/sharedsrc/manageUserSpaceRestr.c.h new file mode 100644 index 0000000..d341a19 --- /dev/null +++ b/src/nwnss/sharedsrc/manageUserSpaceRestr.c.h @@ -0,0 +1,1284 @@ +/**************************************************************************** + | + | (C) Copyright 2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2007-07-17 23:17:26 +0530 (Tue, 17 Jul 2007) $ + | + | $RCSfile$ + | $Revision: 2097 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage NSS Volume User Space Restrictions + | + +-------------------------------------------------------------------------*/ +#if defined(__KERNEL__) +#include +#endif +#include +#include +#include + +#if !defined(__KERNEL__) +#define atoq(p1) LB_atoq(p1) +#define stricmp(p1,p2) strcasecmp(p1,p2) +extern SQUAD LB_atoq(const char *__nptr ); +#include +#include +extern void syslog (int __pri, __const char *__fmt, ...) + __attribute__ ((__format__(__printf__, 2, 3))); +#include +#include +#include +#endif + +#include +#include +#include +#include "nssPubs.h" +#include +#include "manage.h" +#include "sysimp.h" +#include "manageNlm.h" +#include "manageUserSpaceRestr.h" +#include "comnPublics.h" +#include "comnAuthorize.h" +#include "virtualIO.h" +#include "xmlTags.h" + +/* Manifest constants */ +#define MUSR_QUOTA_VALUE_SUPPLIED 1 +#define MUSR_QUOTA_NONE_SUPPLIED 2 +#define MUSR_QUOTA_RESTICTED_SUPPLIED 4 + +#if !defined(__KERNEL__) +STATUS Linux_getUserList(VirtInfo_s *virtInfo, unicode_t *uniVolName, BOOL allUsers); +STATUS Linux_MapDNToGUID(utf8_t *objName, NDSid_t *objGUID); +#endif + +/* Local prototypes */ +#if !defined(__KERNEL__) +STATUS MNSS_BrowseUserSpaceRestrictions(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_GetUserSpaceRestrictions(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_SetUserSpaceRestrictions(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); +STATUS MNSS_ListUsers(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element); + +STATUS StripTreeFromTypedDN(utf8_t *objName); +STATUS StripTreeFromTypelessDN(utf8_t *objName); +STATUS StripTypesFromDN(utf8_t *objName); + + +#if !defined(__KERNEL__) +extern GUID_t zANYONE_USERID; +extern GUID_t zSUPERVISOR_USERID; +#endif + +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ +SiblingElements_s UserSpaceRestrictionsElements[] = +{ + {TAG_BROWSE, MNSS_BrowseUserSpaceRestrictions}, + {TAG_GET, MNSS_GetUserSpaceRestrictions}, + {TAG_SET, MNSS_SetUserSpaceRestrictions}, + {TAG_LIST, MNSS_ListUsers}, + {0} +}; +#endif + +#if !defined(__KERNEL__) +STATUS Linux_MapDNToGUID(utf8_t *objName, NDSid_t *objGUID) +{ + STATUS status; + utf8_t dnWithTree[MAX_DN_CHARS]; + utf8_t treeName[MAX_DN_CHARS]; + unicode_t uniTreeName[MAX_DN_CHARS]; + unicode_t uniDNWithTree[MAX_DN_CHARS]; + SNINT nameLen; + BOOL foundTree = FALSE; + BOOL addDot = FALSE; + SNINT beginTree; + SNINT endTree; + SNINT treeLen; + + if ((objName == NULL) || (objGUID == NULL)) + { + status = zERR_BAD_PARAMETER_VALUE; + return status; + } + + if(*objName != '.') + { + strcpy(dnWithTree, "."); + strcat(dnWithTree, objName); + } + else + { + strcpy(dnWithTree, objName); + } + + status = OpenNCPServ(); + if (status != 0) + { + syslog(LOG_INFO, "Error %d from OpenNSSAdminLib\n", status); + return status; + } + + status = NCPLocalTreeName(sizeof(uniTreeName), uniTreeName); + if(status != 0) + { + syslog(LOG_INFO, "Error %d from NCPLocalTreeName\n", status); + return status; + } + + uni2utf(uniTreeName, treeName, sizeof(treeName)); + + /* Check if there is a tree name */ + nameLen = strlen(dnWithTree); + if (dnWithTree[nameLen - 1] != '.') + { + addDot = TRUE; + strcat(dnWithTree, "."); + nameLen++; + } + treeLen = strlen(treeName); + endTree = nameLen - 1; + beginTree = endTree - treeLen; + + if (beginTree > 1) + { + if (dnWithTree[beginTree-1] == '.' || dnWithTree[beginTree-1] == '=') + { + if (strncasecmp(&dnWithTree[beginTree], treeName, treeLen) == 0) + { + foundTree = TRUE; + } + } + } + + /* If the tree name is not already present */ + if (!foundTree) + { + strcat(dnWithTree, treeName); + strcat(dnWithTree, "."); + } + + status = utf2uni(dnWithTree, uniDNWithTree, + sizeof(uniDNWithTree)); + if (status == -1) + { + return status; + } + + status = NCPMapDNToGUID(TRUE, uniDNWithTree, (char *)objGUID); + if (status != zOK) + { + // If the org and tree names are the same we may have failed to + // add on the tree name when we needed to. + if (addDot && foundTree) + { + strcat(dnWithTree, treeName); + strcat(dnWithTree, "."); + } + status = utf2uni(dnWithTree, uniDNWithTree, sizeof(uniDNWithTree)); + if (status == -1) + { + return status; + } + status = NCPMapDNToGUID(TRUE, uniDNWithTree, (char *)objGUID); + } + + return status; +} + +STATUS Linux_getUserList( + VirtInfo_s *virtInfo, + unicode_t *uniVolName, + BOOL allUsers) +{ + STATUS status = zOK; + STATUS perUserStatus; + NINT numEntries; + utf8_t userName[MAX_DN_CHARS]; + unicode_t uniUserName[MAX_DN_CHARS]; + UserID_t lastUser; + SQUAD restrictionAmount; + SQUAD usedAmount; + char id[GUID_FORMAT_SIZE]; + + lastUser = zINVALID_USERID; + status = OpenNCPServ(); + if (status != 0) + { + syslog(LOG_INFO, "Error %d from OpenNSSAdminLib\n", status); + return status; + } + + /* Start the user list */ + status = VIRT_AddResultTag(virtInfo, TAG_USERLIST, FALSE, TRUE); + if (status != zOK) + { + return status; + } + + while(((status = GetNextUserInVolume(uniVolName, &lastUser, &restrictionAmount, &usedAmount, &numEntries)) == zOK) + && (numEntries == 1)) + { + /* Only do this user if they have a restriction or we are doing allUsers */ + if ((restrictionAmount == zUSER_NO_RESTRICTIONS) && !allUsers) + { + continue; + } + + /* Return the GUID */ + (void)LB_GUIDToString(&lastUser, GUID_FORMAT_SIZE, id); + + /* Get and return the user object's name */ + if (lastUser.timeHighAndVersion == 0) + { /* special guid */ + if (LB_GUIDCompare(&lastUser, &zSUPERVISOR_USERID) == 0) + { + strcpy(userName, "[Supervisor]"); + } + else if (LB_GUIDCompare(&lastUser, &zANYONE_USERID) == 0) + { + strcpy(userName, "[Public]"); + } + else + { + strcpy(userName, "** User Not Found ** ["); + strcat(userName, id); + strcat(userName, "]"); + } + } + else + { + status = NCPMapGUIDToDN((char*)&lastUser, sizeof(uniUserName), uniUserName); + if (status == zOK) + { + uni2utf(uniUserName, userName, sizeof(userName)); + + // (void)StripTreeFromTypedDN(userName); + status = StripTypesFromDN(userName); + if (status != zOK) + { + continue; + } + status = StripTreeFromTypelessDN(userName); + if (status != zOK) + { + continue; + } + } + else + { + strcpy(userName, "** User Not Found ** ["); + strcat(userName, id); + strcat(userName, "]"); + } + } + + /* Start this user */ + status = VIRT_AddResultTag(virtInfo, TAG_USER, FALSE, TRUE); + if (status != zOK) + { + break; + } + + status = VIRT_AddResultElement(virtInfo, TAG_ID, id, TRUE); + if (status != zOK) + { + goto CloseUser; + } + + status = VIRT_AddResultElement(virtInfo, TAG_USERNAME, userName, TRUE); + if (status != zOK) + { + goto CloseUser; + } + + /* Return the space restriction for the user */ + if (restrictionAmount == 0) + { + status = VIRT_AddResultElement(virtInfo, TAG_FULLYRESTRICTED, NULL, TRUE); + } + else if (restrictionAmount == zUSER_NO_RESTRICTIONS) + { + status = VIRT_AddResultElement(virtInfo, TAG_NOQUOTA, NULL, TRUE); + } + else + { + sprintf(userName, "%Ld", restrictionAmount); + status = VIRT_AddResultElement(virtInfo, TAG_QUOTA, userName, TRUE); + } + + if (status != zOK) + { + goto CloseUser; + } + + /* Return the storage in use by the user */ + sprintf(userName, "%Ld", usedAmount); + status = VIRT_AddResultElement(virtInfo, TAG_SPACEUSED, userName, TRUE); + +CloseUser: + perUserStatus = status; + /* End the user */ + status = VIRT_AddResultTag(virtInfo, TAG_USER, TRUE, TRUE); + if (status != zOK) + { + /* If we fail to add the close user tag the response XML is unbalanced, + * just fail the whole request */ + status = zFAILURE; + return status; + } + + /* If we closed the user due to error then break the loop */ + if (perUserStatus != zOK) + { + break; + } + } + + /* End the user list */ + status = VIRT_AddResultTag(virtInfo, TAG_USERLIST, TRUE, TRUE); + if (status != zOK) + { + /* if we can't add the closing tag for the list we have unbalanced XML, + * just fail the whole request */ + status = zFAILURE; + } + return status; +} + +STATUS Linux_getNextUsers( + VirtInfo_s *virtInfo, + unicode_t *uniVolName, + UserID_t lastUser, + long maxEntries, + BOOL allUsers) +{ + STATUS status = zOK; + STATUS saveStatus; + STATUS perUserStatus; + NINT numEntries; + utf8_t userName[MAX_DN_CHARS]; + unicode_t uniUserName[MAX_DN_CHARS]; + SQUAD restrictionAmount; + SQUAD usedAmount; + char id[GUID_FORMAT_SIZE]; + NINT numFound = 0; + + status = OpenNCPServ(); + if (status != 0) + { + syslog(LOG_INFO, "Error %d from OpenNSSAdminLib\n", status); + return status; + } + + /* Start the user list */ + status = VIRT_AddResultTag(virtInfo, TAG_USERLIST, FALSE, TRUE); + if (status != zOK) + { + return status; + } + + while((numFound < maxEntries) && + ((status = GetNextUserInVolume(uniVolName, &lastUser, &restrictionAmount, &usedAmount, &numEntries)) == zOK) + && (numEntries == 1)) + { + /* Only do this user if they have a restriction or we are doing allUsers */ + if ((restrictionAmount == zUSER_NO_RESTRICTIONS) && !allUsers) + { + continue; + } + + /* Return the GUID */ + (void)LB_GUIDToString(&lastUser, GUID_FORMAT_SIZE, id); + + /* Get and return the user object's name */ + if (lastUser.timeHighAndVersion == 0) + { /* special guid */ + if (LB_GUIDCompare(&lastUser, &zSUPERVISOR_USERID) == 0) + { + strcpy(userName, "[Supervisor]"); + } + else if (LB_GUIDCompare(&lastUser, &zANYONE_USERID) == 0) + { + strcpy(userName, "[Public]"); + } + else + { + strcpy(userName, "** User Not Found ** ["); + strcat(userName, id); + strcat(userName, "]"); + } + } + else + { + status = NCPMapGUIDToDN((char*)&lastUser, sizeof(uniUserName), uniUserName); + if (status == zOK) + { + uni2utf(uniUserName, userName, sizeof(userName)); + + // (void)StripTreeFromTypedDN(userName); + status = StripTypesFromDN(userName); + if (status != zOK) + { + continue; + } + status = StripTreeFromTypelessDN(userName); + if (status != zOK) + { + continue; + } + } + else + { + strcpy(userName, "** User Not Found ** ["); + strcat(userName, id); + strcat(userName, "]"); + } + } + + numFound += numEntries; + /* Start this user */ + status = VIRT_AddResultTag(virtInfo, TAG_USER, FALSE, TRUE); + if (status != zOK) + { + break; + } + + status = VIRT_AddResultElement(virtInfo, TAG_ID, id, TRUE); + if (status != zOK) + { + goto CloseUser; + } + + status = VIRT_AddResultElement(virtInfo, TAG_USERNAME, userName, TRUE); + if (status != zOK) + { + goto CloseUser; + } + + /* Return the space restriction for the user */ + if (restrictionAmount == 0) + { + status = VIRT_AddResultElement(virtInfo, TAG_FULLYRESTRICTED, NULL, TRUE); + } + else if (restrictionAmount == zUSER_NO_RESTRICTIONS) + { + status = VIRT_AddResultElement(virtInfo, TAG_NOQUOTA, NULL, TRUE); + } + else + { + sprintf(userName, "%Ld", restrictionAmount); + status = VIRT_AddResultElement(virtInfo, TAG_QUOTA, userName, TRUE); + } + + if (status != zOK) + { + goto CloseUser; + } + + /* Return the storage in use by the user */ + sprintf(userName, "%Ld", usedAmount); + status = VIRT_AddResultElement(virtInfo, TAG_SPACEUSED, userName, TRUE); + +CloseUser: + perUserStatus = status; + /* End the user */ + status = VIRT_AddResultTag(virtInfo, TAG_USER, TRUE, TRUE); + if (status != zOK) + { + /* If we fail to add the close user tag the response XML is unbalanced, + * just fail the whole request */ + status = zFAILURE; + return status; + } + + /* If we closed the user due to error then break the loop */ + if (perUserStatus != zOK) + { + break; + } + } + saveStatus = status; + + /* End the user list */ + status = VIRT_AddResultTag(virtInfo, TAG_USERLIST, TRUE, TRUE); + if (status != zOK) + { + /* if we can't add the closing tag for the list we have unbalanced XML, + * just fail the whole request */ + status = zFAILURE; + } + if (saveStatus != zOK) + { + status = saveStatus; + } + return status; +} +#endif + +#if !defined(__KERNEL__) +STATUS StripTreeFromTypedDN(utf8_t *objName) +{ + STATUS status = zOK; + utf8_t *tree; + + if (objName == NULL) + { + status = zERR_BAD_PARAMETER_VALUE; + goto Exit; + } + + tree = strstr(objName, ".T="); + if (tree != NULL) + { + *tree = 0; + } + +Exit: + return status; +} + +STATUS StripTreeFromTypelessDN(utf8_t *objName) +{ + STATUS status = zOK; + utf8_t newName[MAX_DN_CHARS]; + utf8_t *begin = objName; + utf8_t *end = objName + strlen(objName) - 1; + utf8_t *newNamePos = newName; + + if (begin == NULL) + { + status = zERR_BAD_PARAMETER_VALUE; + goto Exit; + } + + if(*end == '.') + { + end--; + } + + if(*begin == '.') + { + begin++; + } + + /* strip the tree name */ + while(end != begin && *end != '.') + { + end--; + } + + while(begin != end) + { + *newNamePos++ = *begin++; + } + + /* Terminate the new string and copy it back to the source */ + *newNamePos = 0; + strcpy(objName, newName); + +Exit: + return status; +} + +STATUS StripTypesFromDN(utf8_t *objName) +{ + STATUS status = zOK; + BOOL dot; + utf8_t newName[MAX_DN_CHARS]; + utf8_t *src = objName; + utf8_t *insPos = newName; + + if (src == NULL) + { + status = zERR_BAD_PARAMETER_VALUE; + goto Exit; + } + + /* The name needs to have types */ + if (strchr(src, '=') == NULL) + { + goto Exit; + } + + /* Ignore any leading dot */ + if (*src == '.') + { + src++; + } + + /* Expect a type at the start */ + dot = TRUE; + + while (*src) + { + /* If we are parsing a type ID */ + if (dot) + { + /* If we reach the end of the type */ + if (*src == '=') + { + dot = FALSE; + } + + src++; + continue; + } + + /* Switch to type parsing on finding a dot */ + if (*src == '.') + { + dot = TRUE; + } + + /* Copy the character */ + *(insPos++) = *(src++); + } + + /* Terminate the new string and copy it back to the source */ + *insPos = 0; + strcpy(objName, newName); + +Exit: + return status; +} + + +STATUS MNSS_GetGUID( + TagContent_s nameTag, + TagContent_s guidTag, + NDSid_t *guid) +{ + STATUS status; + char *pos1; + char *pos2; + + if (guidTag.flags & TR_TAG_FOUND) + { + status = LB_GUIDFromUTF8(guidTag.content, guid); + if (status == zERR_INVALID_VOLUME_ID) + { + status = zERR_INVALID_USER_ID; + } + return status; + } + + if (nameTag.flags & TR_TAG_FOUND) + { + status = Linux_MapDNToGUID(nameTag.content, guid); + /* Check to see if the GUID is encoded in the name */ + if (status != zOK) + { + if ((pos1 = strstr(nameTag.content, "[")) != NULL && + (pos2 = strstr(nameTag.content, "]")) != NULL && + strlen(pos1) >= 39) + { + STATUS stat; + char hold = *pos2; + *pos2 = '\0'; + stat = LB_GUIDFromUTF8(pos1+1, guid); + *pos2 = hold; + if (stat == zOK) + { + return zOK; + } + } + } + return status; + } + return zERR_NO_SUCH_USER; +} + +STATUS MNSS_BrowseUserSpaceRestrictions(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element) +{ + STATUS status = zOK; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + BOOL allUsers = FALSE; + + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_ALLUSERS, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + VOLNAME = 0, + ALLUSERS = 1, + }; + + ASSERT_MPKNSS_LOCK(); + + /* Read out the tags */ + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + return status; + } + + /* Add the opening reply tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* vol name to unicode */ + status = utf2uni(tagContent[VOLNAME].content, uniVolName, + sizeof(uniVolName)); + if (status == -1) + { + MNSS_BuildResult(virtInfo, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to Unicode")); + goto CloseTagExit; + } + + if(tagContent[ALLUSERS].flags & TR_TAG_FOUND) + { + allUsers = TRUE; + } + + status = Linux_getUserList(virtInfo, uniVolName, allUsers); + + if (status == zOK) + { + MNSS_BuildResult(virtInfo, status, "zOK"); + } + else + { + MNSS_BuildResult(virtInfo, status, "Failed to add a user list entry"); + } + +CloseTagExit: + /* Add the closing tag */ + status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return status; +} + +STATUS MNSS_ListUsers( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status = zOK; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + BOOL allUsers = FALSE; + UserID_t lastUser; + long numEntries; + + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_LASTUSERID, TR_CONTENT_REQUIRED}, + {TAG_NUMENTRIES, TR_CONTENT_REQUIRED}, + {TAG_ALLUSERS, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + VOLNAME = 0, + LASTUSERID = 1, + NUMENTRIES = 2, + ALLUSERS = 3, + }; + + ASSERT_MPKNSS_LOCK(); + + /* Read out the tags */ + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + return status; + } + + /* Add the opening reply tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* vol name to unicode */ + status = utf2uni(tagContent[VOLNAME].content, uniVolName, + sizeof(uniVolName)); + if (status == -1) + { + MNSS_BuildResult(virtInfo, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to Unicode")); + goto CloseTagExit; + } + + if(tagContent[ALLUSERS].flags & TR_TAG_FOUND) + { + allUsers = TRUE; + } + + if ((status = LB_GUIDFromUTF8(tagContent[LASTUSERID].content, + &lastUser)) != zOK) + { + goto CloseTagExit; + } + + numEntries = atol(tagContent[NUMENTRIES].content); + if (numEntries < 1) + { + MNSS_BuildResult(virtInfo, zFAILURE, "No entries requested"); + goto CloseTagExit; + } + + status = Linux_getNextUsers(virtInfo, uniVolName, lastUser, numEntries, allUsers); + + if (status == zOK) + { + MNSS_BuildResult(virtInfo, status, "zOK"); + } + else + { + MNSS_BuildResult(virtInfo, status, "Failed to list a user entry"); + } + +CloseTagExit: + /* Add the closing tag */ + status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return status; +} + +STATUS MNSS_GetUserSpaceRestrictions(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element) +{ + STATUS status = zOK; + SQUAD usedAmount; + SQUAD restrictionAmount; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + NDSid_t userGUID; + utf8_t txt[256]; + + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_ID, TR_OPTIONAL}, + {TAG_USERNAME, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + VOLNAME = 0, + ID = 1, + USERNAME = 2 + }; + + ASSERT_MPKNSS_LOCK(); + + /* Read out the tags */ + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + return status; + } + + /* Add the opening reply tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* We need either a name or a GUID */ + if (!(tagContent[ID].flags & TR_TAG_FOUND) && + !(tagContent[USERNAME].flags & TR_TAG_FOUND)) + { + MNSS_BuildResult(virtInfo, zERR_NO_SUCH_USER, + MSGNot("Nither the ID or the user name were specified")); + goto CloseTagExit; + } + + /* vol name to unicode */ + status = utf2uni(tagContent[VOLNAME].content, uniVolName, + sizeof(uniVolName)); + if (status == -1) + { + MNSS_BuildResult(virtInfo, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to Unicode")); + goto CloseTagExit; + } + + if (tagContent[USERNAME].element.dataLen < 1) + { + goto InvalidUserExit; + } + + /* We need the username as a GUID */ + status = MNSS_GetGUID(tagContent[USERNAME], tagContent[ID], &userGUID); + if (status != zOK) + { + goto InvalidUserExit; + } + + status = GetUserSpaceRestriction(uniVolName, userGUID, &usedAmount, &restrictionAmount); + + /* Add the result tags */ + if (status == zOK) + { + if (restrictionAmount == 0) + { + status = VIRT_AddResultElement(virtInfo, TAG_FULLYRESTRICTED, NULL, TRUE); + } + else if (restrictionAmount == zUSER_NO_RESTRICTIONS) + { + status = VIRT_AddResultElement(virtInfo, TAG_NOQUOTA, NULL, TRUE); + } + else + { + sprintf(txt, "%Ld", restrictionAmount); + status = VIRT_AddResultElement(virtInfo, TAG_QUOTA, txt, TRUE); + } + + if (status != zOK) + { + MNSS_BuildResult(virtInfo, zFAILURE, + MSGNot("Failed to add quota to response")); + goto CloseTagExit; + } + + sprintf(txt, "%Ld", usedAmount); + status = VIRT_AddResultElement(virtInfo, TAG_SPACEUSED, txt, TRUE); + + if (status != zOK) + { + MNSS_BuildResult(virtInfo, zFAILURE, + MSGNot("Failed to add space used to response")); + goto CloseTagExit; + } + + MNSS_BuildResult(virtInfo, status, "zOK"); + } + else if(status == zERR_NO_SUCH_USER) + { + sprintf(txt, "<"TAG_NOQUOTA"/><"TAG_SPACEUSED">0"); + if ((status = VIRT_AddResultData(virtInfo, txt)) != zOK) + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to add tags to response")); + goto CloseTagExit; + } + } + else + { + MNSS_BuildResult(virtInfo, status, + MSGNot("Failed to get user space restriction")); + } + + /* Skip the invalid user error code if we get here */ + goto CloseTagExit; + +InvalidUserExit: + MNSS_BuildResult(virtInfo, zERR_BAD_PARAMETER_VALUE, + MSGNot("Invalid user name")); + +CloseTagExit: + /* Add the closing tag */ + status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + + return status; +} + +STATUS MNSS_SetUserSpaceRestrictions(utf8_t *tagName, VirtInfo_s *virtInfo, XML_ElementInfo_s *element) +{ + STATUS status = zOK; + SQUAD quota = 0; + NINT qFlags = 0; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + NDSid_t userGUID; + + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_ID, TR_OPTIONAL}, + {TAG_USERNAME, TR_OPTIONAL}, + {TAG_QUOTA, TR_OPTIONAL}, + {TAG_NOQUOTA, TR_OPTIONAL}, + {TAG_FULLYRESTRICTED, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + VOLNAME = 0, + ID = 1, + USERNAME = 2, + QUOTA = 3, + NOQUOTA = 4, + FULLYRESTRICTED = 5 + }; + + ASSERT_MPKNSS_LOCK(); + + /* Read out the tags */ + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + return status; + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* We need either a name or a GUID */ + if (!(tagContent[ID].flags & TR_TAG_FOUND) && + !(tagContent[USERNAME].flags & TR_TAG_FOUND)) + { + MNSS_BuildResult(virtInfo, zERR_NO_SUCH_USER, + MSGNot("Neither the ID or the user name were specified")); + goto CloseTagExit; + } + + /* vol name to unicode */ + status = utf2uni(tagContent[VOLNAME].content, uniVolName, + sizeof(uniVolName)); + if (status == -1) + { + MNSS_BuildResult(virtInfo, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to Unicode")); + goto CloseTagExit; + } + + if (tagContent[USERNAME].element.dataLen < 1) + { + goto InvalidUserExit; + } + + /* We need the username as a GUID */ + status = MNSS_GetGUID(tagContent[USERNAME], tagContent[ID], &userGUID); + if (status != zOK) + { + goto InvalidUserExit; + } + + if (tagContent[QUOTA].flags & TR_TAG_FOUND) + { + /* Only one quota type/value allowed */ + if (qFlags != 0) + { + goto MultipleQuotasExit; + } + qFlags |= MUSR_QUOTA_VALUE_SUPPLIED; + quota = atoq(tagContent[QUOTA].content); + } + + if (tagContent[NOQUOTA].flags & TR_TAG_FOUND) + { + /* Only one quota type/value allowed */ + if (qFlags != 0) + { + goto MultipleQuotasExit; + } + qFlags |= MUSR_QUOTA_NONE_SUPPLIED; + quota = zUSER_NO_RESTRICTIONS; + } + + if (tagContent[FULLYRESTRICTED].flags & TR_TAG_FOUND) + { + /* Only one quota type/value allowed */ + if (qFlags != 0) + { + goto MultipleQuotasExit; + } + qFlags |= MUSR_QUOTA_RESTICTED_SUPPLIED; + quota = 0; + } + + /* We are required to have one of the quota tags supplied */ + if (qFlags == 0) + { + MNSS_BuildResult(virtInfo, zERR_XML_IS_BAD, + MSGNot("No quota supplied for user")); + goto CloseTagExit; + } + + status = SetUserSpaceRestriction(uniVolName, userGUID, quota); + /* Add the result tag - already done if we failed */ + if (status == zOK) + { + MNSS_BuildResult(virtInfo, status, "zOK"); + } + else + { + MNSS_BuildResult(virtInfo, status, "Failed to set user space restriction"); + } + + /* If we get here we can skip the invalid user and multiple quotas code */ + goto CloseTagExit; + +MultipleQuotasExit: + MNSS_BuildResult(virtInfo, zERR_XML_IS_BAD, + MSGNot("Multiple quotas supplied for user")); + goto CloseTagExit; + +InvalidUserExit: + status = zERR_BAD_PARAMETER_VALUE; + MNSS_BuildResult(virtInfo, status, + MSGNot("Invalid user name")); + +CloseTagExit: + /* Add the closing tag */ + status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + return status; +} +#endif + +#if defined(__KERNEL__) +/**************************************************************************** + * Get the list of users on a volume + *****************************************************************************/ +STATUS GetNextUserInVolume( + unicode_t *uniVolName, + UserID_t *lastUser, + SQUAD *restrictionAmount, + SQUAD *usedAmount, + NINT *numEntries) +{ + GeneralMsg_s genMsg; + Volume_s *volume = NULL; + STATUS status = zOK; + COMNUserRest_s userData; + + ASSERT_MPKNSS_LOCK(); + COMN_SETUP_GENERAL_MSG(&genMsg, current->fsuid, zNO_TASK,zSAGENT_NONE); + volume = COMN_VolumeNameLookup(&genMsg, uniVolName, TRUE, NULL); + if (volume == NULL) + { + status = GetErrno(&genMsg); + return(status); + } + + status = VOL_BrowseUsersInVolume(&genMsg, volume, 1, lastUser, &userData, numEntries, BROWSE_USERS_GET_USED_OR_RESTRICTED); + *lastUser = userData.userID; + *restrictionAmount = userData.restrictionAmount; + *usedAmount = userData.usedAmount; + + if (volume != NULL) + { + COMN_Release(&volume); + } + return status; +} +#endif + +#if defined(__KERNEL__) +/**************************************************************************** + * Set the user quota + *****************************************************************************/ +STATUS GetUserSpaceRestriction( + unicode_t *uniVolName, + NDSid_t userGUID, + SQUAD *usedAmount, + SQUAD *restrictionAmount) +{ + GeneralMsg_s genMsg; + Volume_s *volume = NULL; + STATUS status = zOK; + + /* Get the volume object */ + COMN_SETUP_GENERAL_MSG(&genMsg, current->fsuid, zNO_TASK,zSAGENT_NONE); + volume = COMN_VolumeNameLookup(&genMsg, uniVolName, FALSE, NULL); + if (volume == NULL) + { + status = GetErrno(&genMsg); + return(status); + } + + if (volume->VOLmayIDoThis(&genMsg, volume->rootdir, zINVALID_ZID, + MAY_I_SUPERVISE) != zOK) + { + COMN_Release(&volume); + return(zERR_ACCESS_DENIED); + } + + /* Now we can get the user space restriction */ + status = VOL_GetUserSpaceInfo(&genMsg, volume, &userGUID, usedAmount, restrictionAmount); + if(status != zOK) + { + status = GetErrno(&genMsg); + } + if (volume != NULL) + { + COMN_Release(&volume); + } + return status; +} + +/**************************************************************************** + * Set the user quota + *****************************************************************************/ +STATUS SetUserSpaceRestriction( + unicode_t *uniVolName, + NDSid_t userGUID, + SQUAD quota) +{ + GeneralMsg_s genMsg; + Volume_s *volume = NULL; + STATUS status = zOK; + + /* Get the volume object */ + COMN_SETUP_GENERAL_MSG(&genMsg, current->fsuid, zNO_TASK,zSAGENT_NONE); + volume = COMN_VolumeNameLookup(&genMsg, uniVolName, FALSE, NULL); + if (volume == NULL) + { + status = GetErrno(&genMsg); + return(status); + } + + /* Now we can set the user space restriction */ + S_LATCH(&volume->rootdir->FILEbeastLatch); + status = VOL_SetUserSpaceRestriction(&genMsg, volume, &userGUID, quota); + if (status != zOK) + { + status = GetErrno(&genMsg); + } + UNS_LATCH(&volume->rootdir->FILEbeastLatch); + + if (volume != NULL) + { + COMN_Release(&volume); + } + return status; +} +#endif diff --git a/src/nwnss/sharedsrc/manageVolume.c.h b/src/nwnss/sharedsrc/manageVolume.c.h new file mode 100644 index 0000000..f840270 --- /dev/null +++ b/src/nwnss/sharedsrc/manageVolume.c.h @@ -0,0 +1,6301 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2005 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS) support module + | + |--------------------------------------------------------------------------- + | + | $Author: nbalachandran $ + | $Date: 2008-08-25 10:45:18 +0530 (Mon, 25 Aug 2008) $ + | + | $RCSfile$ + | $Revision: 2448 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Manage NSS using XML + | + +-------------------------------------------------------------------------*/ +#if !defined(__KERNEL__) +#include +#include +#include +#include +#include +#include +#endif + +#if defined(__KERNEL__) +#include /* NetWare */ +#include +#include +#endif + + +#include +#include +#include +#include +#if !defined(__KERNEL__) +#define atoq(p1) LB_atoq(p1) +#define stricmp(p1,p2) strcasecmp(p1,p2) +extern SQUAD LB_atoq(const char *__nptr ); + +#include +#include +#include +#include +#include +#include +#include +#include +extern void syslog(int __pri, __const char *__fmt, ...) + __attribute__ ((__format__(__printf__, 2, 3))); +#define ASSERT_MPKNSS_LOCK() ((void) 0) +#endif +#if defined(__KERNEL__) +#include + +#include +#endif +#ifndef __linux__ +#include + +#include "sysimp.h" +#endif + +#include "manage.h" +#include "manageNlm.h" +#include "manageVolume.h" +#if !defined(__KERNEL__) +#include +#endif + +#if defined(__KERNEL__) +#include "manageStartup.h" +#endif +#include "comnPublics.h" +#include "virtualIO.h" +#include "xmlTags.h" +#if defined(__KERNEL__) +#include "comnAuthorize.h" +#include "utc.h" +#else +#include +#include +#endif +#include "eDir.h" +#include "vldberr.h" +#include "evs.h" + +#define CREATE_DIR_MODE 0777 +#define NAME_SPACE_MAX_SIZE 32 + +#if !defined(__KERNEL__) +/* Clustering defines */ +typedef int (*NCSRFPTR)(LONG (*callback)(), char *, NCS_EPOCH_CHANGE_CALLBACK, + void *, void *, NCS_HANDLE *); +typedef int (*NCSDFPTR)(NCS_HANDLE); +typedef int (*NCSFFPTR)(NCS_HANDLE, char *, NCS_POOL_INFO *); + +#ifdef __x86_64 +#define NCS_LIB_NAME "/usr/lib64/libncssdk.so" +#else +#define NCS_LIB_NAME "/usr/lib/libncssdk.so" +#endif + +#define NCS_REGISTER_FUNCTION_NAME "NCS_Register" +#define NCS_DEREGISTER_FUNCTION_NAME "NCS_Deregister" +#define NCS_FIND_FUNCTION_NAME "NCS_FindVirtualServer" + + +/* Funciton Prototypes */ +STATUS MNSS_ProcessBrowseBeasts(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetVolumeNDSName(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetVolumeInfo(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessListVolumes(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessModifyVolumeState(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessAddVolume(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessRemoveVolume(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessRenameVolume(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessModifyVolumeInfo(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessGetVolumeState(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessSalvageVolume(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessPurgeVolume(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessPauseDeletedVolumeState(utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessContinueDeletedVolumeState(utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessRemoveUser(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +STATUS MNSS_ProcessFixCompStats(utf8_t *tagName, VirtInfo_s *virtInfo, + XML_ElementInfo_s *element); +#endif + +/* Functions in manageVLDB.c: */ +extern STATUS AddVolumeToVLDB(GUID_t *GUID, unicode_t *uni_ServerName, + unicode_t *uni_VolName, char **errText); +extern STATUS AddVolumeServerToVLDB(GUID_t *GUID, unicode_t *uni_ServerName, + unicode_t *uni_VolName, char **errText); +extern STATUS RemoveVolumeFromVLDB(GUID_t *GUID, char **errText); +extern STATUS RemoveVolumeServerFromVLDB(GUID_t *GUID, + unicode_t *uni_ServerName, + unicode_t *uni_VolName, + char **errText); +extern void RemoveTypes(unicode_t *name); +extern void ConvertToDottedName(unicode_t *name); +extern void InitLocalServerName(void); +extern unicode_t *LocalTreeName; + + +#if !defined(__KERNEL__) +STATUS MountVolume(utf8_t *volName, BOOL notifyNCP, utf8_t *options); +STATUS DismountVolume(utf8_t *volMountPoint, BOOL lazyUmount); +STATUS RemoveMountPoint(utf8_t *volName); +STATUS RenameMountPoint(utf8_t *volName, utf8_t *newVolName, + utf8_t *mountPoint, utf8_t *newMountPoint, + BOOL mounted); +/* NCP server functions in ipc2ncp.c */ +int IPCAddNSSVolume(char *volumeName); +int IPCRemoveNSSVolume(char *volumeName); +#endif + +char *ManageVolumeErrorMessages[] = +{ +/* 0 */ MSGNot("Error finding pool in NSS"), +/* 1 */ MSGNot("Error creating volume"), +/* 2 */ MSGNot("Error finding volume in NSS"), +/* 3 */ MSGNot("Unable to lock the volume active"), +/* 4 */ MSGNot("Error setting volume attributes"), +/* 5 */ MSGNot("Error getting rootKey for zAPI"), +/* 6 */ MSGNot("Error opening _ADMIN file for the specified volume"), +/* 7 */ MSGNot("Error getting volume info"), +/* 8 */ MSGNot("Error converting volume password to unicode"), +/* 9 */ MSGNot("Unsuccessful in activating the volume"), +/* 10 */ MSGNot("Unsuccessful in deactivating the volume"), +/* 11 */ MSGNot("Volume not active"), +/* 12 */ MSGNot("Error removing user from volume"), +/* 13 */ MSGNot("Out of memory"), +/* 14 */ MSGNot("Error mapping function call to kernel") +}; + +/**************************************************************************** + * + * Elements to be processed as siblings + * + ****************************************************************************/ + +#if !defined(__KERNEL__) +SiblingElements_s VolumeElements[] = +{ + {TAG_BROWSEBEASTS, MNSS_ProcessBrowseBeasts}, + {TAG_GETNDSNAME, MNSS_ProcessGetVolumeNDSName}, + {TAG_GETVOLUMEINFO, MNSS_ProcessGetVolumeInfo}, + {TAG_LISTVOLUMES, MNSS_ProcessListVolumes}, + {TAG_MODIFYSTATE, MNSS_ProcessModifyVolumeState}, + {TAG_ADDVOLUME, MNSS_ProcessAddVolume}, + {TAG_MODIFYVOLUMEINFO, MNSS_ProcessModifyVolumeInfo}, + {TAG_REMOVEVOLUME, MNSS_ProcessRemoveVolume}, + {TAG_RENAMEVOLUME, MNSS_ProcessRenameVolume}, + {TAG_GETSTATE, MNSS_ProcessGetVolumeState}, + {TAG_REMOVEUSER, MNSS_ProcessRemoveUser}, + {TAG_FIXCOMPSTATS, MNSS_ProcessFixCompStats}, + {0} +}; + +SiblingElements_s DeletedVolumeElements[] = +{ + {TAG_SALVAGEVOLUME, MNSS_ProcessSalvageVolume}, + {TAG_PURGEVOLUME, MNSS_ProcessPurgeVolume}, + {TAG_PAUSESTATE, MNSS_ProcessPauseDeletedVolumeState}, + {TAG_CONTINUESTATE, MNSS_ProcessContinueDeletedVolumeState}, + {0} +}; +#endif + + +/**************************************************************************** + * + * Kernel Functions + * On Linux, these run in the kernel + * On NetWare, everything runs in the kernel... + * + ****************************************************************************/ + +#if defined(__KERNEL__) + +/**************************************************************************** + * + * GetAuthModelID + * KERNEL FUNC + * + ****************************************************************************/ +NINT GetAuthModelID(utf8_t *name) +{ + NINT index; + NINT authModelID = zFTYPE_ZAS_AUTH_MODEL; +// utf8_t name[MAX_AUTH_MODEL_NAME_SIZE]; + +// strcpy(name, tagContent[AUTHORIZATION_MODEL].content); + index = COMN_FindAuthModelByName(name); + if (index != -1) + { + authModelID = BST_ArrayIndex2ClassID(&AuthModelIDMap, + AuthModels[index]->modelIndex); + if (authModelID == zFTYPE_INVALID) + { + authModelID = zFTYPE_ZAS_AUTH_MODEL; + } + } + return (authModelID); +} + + +/**************************************************************************** + * + * This function... + * KERNEL FUNC + * + ****************************************************************************/ + +STATUS CreateVolumeInPool(unicode_t *uniPoolName, + unicode_t *uniVolName, + NINT authModelID, + GUID_t volumeGUID, + unicode_t *uniPassword, + BOOL *isClustered, + NINT *errIndex) +{ + STATUS status = zFAILURE; + GeneralMsg_s genMsg; + Pool_s *pool = NULL; + VCO_VolumeCommonOps_s *parms = NULL; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + pool = COMN_PoolNameLookup(&genMsg, uniPoolName, TRUE, NULL); + if (pool == NULL) + { + status = GetErrno(&genMsg); + *errIndex = MANAGE_VOLUME_ERROR_FINDING_POOL; /*MSGNot("Error finding pool in NSS");*/ + goto exit; + } + + /* If the volume has a password, save it in the volume structure first */ + if ((uniPassword != NULL) && (unilen(uniPassword) != 0)) + { + (void)COMN_SVPW(uniVolName, uniPassword); /* register the volume password */ + } + + parms = zalloc(sizeof(*parms)); + if (parms == NULL) + { + status = zERR_NO_MEMORY; + *errIndex = MANAGE_VOLUME_ERROR_OUT_OF_MEMORY; + goto exit; + } + parms->u.create.quota = zLV_NO_QUOTA_SIZE; + parms->u.create.virtualFileFlag = FALSE; + parms->u.create.authModelID = authModelID; + parms->u.create.guid = volumeGUID; + unicpy(parms->u.create.poolName, uniPoolName); + unicpy(parms->u.create.volumeName, uniVolName); + + *isClustered = pool->POOLenabledFeatures & zPOOL_FEATURE_SHARED_CLUSTER; + + /* + * Note -- We are getting a use count because the command function will + * decrement the use count and we still need to use the pool object later + * on. + */ + COMN_USE_BEAST(&pool->POOLroot); + if ((status = pool->VOLcomnVolOps.VOL_commandFunction(&genMsg, pool, + VCO_VOLUME_CREATE_NUMBER, parms, 0, NULL, 0, NULL, 0, 0, NULL, NULL)) + != zOK) + { + status = GetErrno(&genMsg); + *errIndex = MANAGE_VOLUME_ERROR_CREATING_VOLUME; /*MSGNot("Error creating volume");*/ + goto exit; + } + +exit: + if (parms != NULL) + { + free(parms); + } + if (pool != NULL) + { + COMN_Release(&pool); + } + return(status); +} + + +/**************************************************************************** + * + * This function... + * KERNEL FUNC + * + ****************************************************************************/ + +STATUS SetNDSInfoOnVolume(unicode_t *uniVolName, zVolumeInfo_s *info, + BOOL lock, BOOL onlineOnly) +{ + STATUS status = zFAILURE; + GeneralMsg_s genMsg; + Volume_s *volume = NULL; + ModifyInfoMsg_s modInfoMsg; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + volume = COMN_VolumeNameLookup(&genMsg, uniVolName, onlineOnly, NULL); + if (volume == NULL) + { + goto exit; + } + + if (lock) + { + if (COMN_LockVolumeActive(&genMsg, volume, FALSE) != zOK) + { + goto releaseExit; + } + } + + COMN_STRUCT_INIT(modInfoMsg); + COMN_SETUP_MODIFY_TYPE_INFO_MSG(&modInfoMsg, 0, NULL, + zMOD_VOL_NDS_OBJECT_ID, info); + + modInfoMsg.parentZid = volume->VOLfirstParentZid; + + X_LATCH(&volume->VOLbeastLatch); + status = volume->VOLcomnBeastOps.BST_modifyInfo(&genMsg, &volume->VOLroot, + &modInfoMsg, NULL); + UNX_LATCH(&volume->VOLbeastLatch); + if (lock) + { + COMN_UnlockVolumeActive(volume, FALSE); + } + if (status != zOK) + { + status = GetErrno(&genMsg); + } + +releaseExit: + COMN_Release(&volume); +exit: + return(status); +} + + +/**************************************************************************** + * + * ModifyVolumeAttributes + * KERNEL FUNC + * + ****************************************************************************/ + +STATUS ModifyVolumeAttributes(unicode_t *uniVolName, + NINT modifyInfoMask, + zVolumeInfo_s *info, + NINT readAhead, + NINT *errIndex) +{ + STATUS status; + NINT readAheadBlocks; + GeneralMsg_s genMsg; + ModifyInfoMsg_s modInfoMsg; + Volume_s *volume; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + volume = COMN_VolumeNameLookup(&genMsg, uniVolName, TRUE, NULL); + if (volume == NULL) + { + status = GetErrno(&genMsg); + *errIndex = MANAGE_VOLUME_ERROR_FINDING_VOLUME; /*MSGNot("Error finding volume in NSS");*/ + goto exit; + } + + if (COMN_LockVolumeActive(&genMsg, volume, FALSE) != zOK) + { + status = GetErrno(&genMsg); + COMN_Release(&volume); + *errIndex = MANAGE_VOLUME_ERROR_LOCK_VOLUME; /*MSGNot("Unable to lock the volume active");*/ + goto exit; + } + + if (modifyInfoMask & zMOD_READ_AHEAD_BLOCKS) + { + readAheadBlocks = readAhead >> volume->VOLblockShift; + if (readAheadBlocks > zMAX_READ_AHEAD_COUNT) + { + readAheadBlocks = zMAX_READ_AHEAD_COUNT; + } + volume->readAheadBlocks = readAheadBlocks; + } + + COMN_STRUCT_INIT(modInfoMsg); + COMN_SETUP_MODIFY_TYPE_INFO_MSG(&modInfoMsg, 0, NULL, modifyInfoMask, + info); + + modInfoMsg.parentZid = volume->VOLfirstParentZid; + + X_LATCH(&volume->VOLbeastLatch); + status = volume->VOLcomnBeastOps.BST_modifyInfo(&genMsg, &volume->VOLroot, + &modInfoMsg, NULL); + if (status != zOK) + { + status = GetErrno(&genMsg); + *errIndex = MANAGE_VOLUME_ERROR_SETTING_VOLUME_ATTRS; /*MSGNot("Error setting volume attributes");*/ + } + UNX_LATCH(&volume->VOLbeastLatch); + COMN_UnlockVolumeActive(volume, FALSE); + COMN_Release(&volume); + +exit: + return (status); +} + + +/****************************************************************************** +* GetNSSVolumeHostPool +* Given a volume name, find the name of the pool that it resides in. +* KERNEL FUNC +******************************************************************************/ + +STATUS GetNSSVolumeHostPool( + utf8_t *volumeName, + utf8_t *poolName) +{ + GeneralMsg_s genMsg; + Volume_s *volume = NULL; + unicode_t uni_volName[zMAX_COMPONENT_NAME]; + STATUS status; + + status = zOK; + *poolName = 0; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + /* Change volume name to unicode. */ + if (utf2uni(volumeName, uni_volName, sizeof(uni_volName)) == -1) + { + status = zERR_UNICODE_CONVERSION_ERROR; + goto exit; + } + + /* Check if volume is an NSS volume. */ + if((volume = COMN_VolumeNameLookup(&genMsg,uni_volName,FALSE,NULL)) == NULL) + { + status = zFAILURE; + goto exit; + } + + + /* Pool name in which this volume resides */ + if (volume->v_statusFlag & VOL_SF_LOGICAL_VOLUME) + { + Pool_s *pool = volume->v_pool; + unicode_t pname[zMAX_COMPONENT_NAME]; + + S_LATCH(&pool->POOLbeastLatch); + + /* this routine always returns a valid name */ + status = COMN_GetNameFromBeast(&genMsg, pool, + /* cnt pool->POOLavfile.AVFILEfirstParentNameUniquifier,*/ zNSPACE_LONG, + zMAX_COMPONENT_NAME, pname, NULL); + + UNS_LATCH(&pool->POOLbeastLatch); + + if (status == zOK) + { + status = uni2utf(pname, poolName, zMAX_COMPONENT_NAME); + status = (status == -1) ? zERR_UNICODE_CONVERSION_ERROR : zOK; + } + } +exit: + if (volume != NULL) + { + COMN_Release(&volume); + } + + return status; +} + + +/**************************************************************************** + * Get the LSS VolumeInfo for this deleted volume + * KERNEL FUNC + *****************************************************************************/ + +STATUS GetDeletedVolumeLSSInfo( + utf8_t *volumeName, + unicode_t *uni_volName, + utf8_t *buf, + NINT bufLen, + NINT *retLen) +{ + STATUS status; + GeneralMsg_s genMsg; + Volume_s *volume; + VCO_VolumeCommonOps_s *parms; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + COMN_INCLUDE_INTERNAL_VOLUMES( &genMsg ); + + if((volume = COMN_VolumeNameLookup(&genMsg,uni_volName,FALSE,NULL)) == NULL) + { + status = GetErrno(&genMsg); + return(status); + } + + parms = zalloc(sizeof(*parms)); + if (parms == NULL) + { + status = zERR_NO_MEMORY; + goto exit; + } + + /*** FixFixFix Can we just use uni_volName here? ***/ + if (COMN_GetVolumeName( &genMsg, volume, + parms->u.VCO_getInfo.VGI_volumeName, + NELEMS( parms->u.VCO_getInfo.VGI_volumeName ) ) != zOK) + { + status = GetErrno(&genMsg); + goto freeExit; + } + + COMN_USE_BEAST( &volume->VOLroot ); /* VOL_commandFunction inherits count */ + /* Ensure volume state does not change so that all + * objects report items from the same state. + * + * NOTE - the COMN Ops use to do this BUT it is illegal for + * a thread to get TWO shared latches(even if there are no yields). + * This comes about as the first shared latch may yield. If thread + * A has a Xlatch. Thread B must wait to get a Slatch. Thread C + * must wait to get a Xlatch. Thread A unlatches, Thread B gets + * a Slatch, but waits(deadlocks) for the 2nd Slatch, because + * Thread C requested a Xlatch. + */ + S_LATCH( &volume->stateLatch ); + parms->u.VCO_getInfo.VGI_action = 0; + *retLen = 0; + status = volume->VOLcomnVolOps.VOL_commandFunction( + &genMsg, volume, VCO_VOLUME_GET_INFO_NUMBER, parms, + sizeof(volumeName), volumeName, 0, NULL, 0, + bufLen, buf, retLen); + UNS_LATCH( &volume->stateLatch ); + + if ( status != zOK ) + { + status = GetErrno(&genMsg); + goto freeExit; + } +freeExit: + free(parms); +exit: + COMN_Release(&volume); + return status; +} + + +/**************************************************************************** + * + * This function... + * KERNEL FUNC + * + ****************************************************************************/ + + +STATUS NSSVolumeFound(unicode_t *uni_volName, + BOOL include_internal, + BOOL *isDeleted, + NINT *readAhead, + NINT *volumeState, + utf8_t *authModelName, + UserID_t *volNameGUID) +{ + STATUS status; + Volume_s *volume = NULL; + GeneralMsg_s genMsg; + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + /* Check if volume is an NSS volume. */ + if (include_internal) + { + COMN_INCLUDE_INTERNAL_VOLUMES( &genMsg ); + } + if ((volume = COMN_VolumeNameLookup(&genMsg,uni_volName,FALSE,NULL)) == NULL) + { + status = GetErrno(&genMsg); + return(status); + } + + if (isDeleted != NULL) + { + *isDeleted = (volume->VOLpState == zVOL_PSTATE_DELETION); + } + if (readAhead != NULL) + { + *readAhead = volume->readAheadBlocks << volume->VOLblockShift; + } + if (volumeState != NULL) + { + *volumeState = volume->state; + } + if (authModelName != NULL) + { + strcpy(authModelName, volume->authModel->name); + } + if (volNameGUID != NULL) + { + *volNameGUID = volume->VOLndsObjectID; + } + COMN_Release(&volume); + + return(zOK); +} + +/**************************************************************************** + * + * This function... + * KERNEL FUNC + * + ****************************************************************************/ + +STATUS GetZInfo(BYTE *path, QUAD getInfoMask, zInfo_s *info, NINT *errIndex) +{ + STATUS status = zOK; + Key_t rootKey; + Key_t fileKey = 0; + + /* Get the root key */ + ZOS_zRootKey(status, 0, &rootKey); + if (status != zOK) + { + *errIndex = MANAGE_VOLUME_ERROR_GET_ROOT_KEY; /*MSGNot("Error getting rootKey for zAPI");*/ + goto exit; + } + + /* Get the file key. This is the key to the volume object in the + * NSS admin volumes directory. + */ + MPKNSS_UNLOCK(); + if ((status = zOpen(rootKey, zNSS_TASK, zNSPACE_LONG|zMODE_UTF8, path, + zRR_READ_ACCESS, &fileKey)) != zOK) + { + *errIndex = MANAGE_VOLUME_ERROR_OPEN_ADMIN; /*MSGNot("Error opening _ADMIN file for the specified volume");*/ + goto closeExit; + } + if ((status = zGetInfo(fileKey, getInfoMask, sizeof(*info), + zINFO_VERSION_A, info)) != zOK) + { + *errIndex = MANAGE_VOLUME_ERROR_GETTING_VOLUME_INFO; /*MSGNot("Error getting volume info");*/ + goto closeExit; + } +closeExit: + (void) zClose(rootKey); + if (fileKey) + { + (void) zClose(fileKey); + } + MPKNSS_LOCK(); +exit: + return(status); +} + + +/**************************************************************************** + * + * This function... + * KERNEL FUNC + * + ****************************************************************************/ + +STATUS RemoveNSSVolume(unicode_t *uniVolName) +{ + STATUS status = zOK; + Volume_s *vol = NULL; + GeneralMsg_s genMsg; + VCO_VolumeCommonOps_s *parms = NULL; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + vol = COMN_VolumeNameLookup(&genMsg, uniVolName, FALSE, NULL); + if (vol != NULL) + { + parms = zalloc(sizeof(*parms)); + if (parms == NULL) + { + status = zERR_NO_MEMORY; + COMN_Release(&vol); + goto exit; + } + unicpy(parms->u.delete.volumeName, uniVolName); + status = vol->VOLcomnVolOps.VOL_commandFunction(&genMsg, vol, + VCO_VOLUME_DELETE_NUMBER, parms, 0, NULL, 0, NULL, 0, 0, + NULL, NULL); + } + + /* NB: COMN_Release(&vol) happened in VOL_commandFunction() */ +exit: + if (parms != NULL) + { + free(parms); + } + return(status); +} + + +/****************************************************************************** +* +* RenameNSSVolume +* KERNEL FUNC +* +*******************************************************************************/ + +STATUS RenameNSSVolume(unicode_t *uniVolName, unicode_t *uniNewName) +{ + STATUS status = zOK; + Volume_s *vol = NULL; + GeneralMsg_s genMsg; + VCO_VolumeCommonOps_s *parms = NULL; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + vol = COMN_VolumeNameLookup(&genMsg, uniVolName, FALSE, NULL); + if (vol != NULL) + { + parms = zalloc(sizeof(*parms)); + if (parms == NULL) + { + status = zERR_NO_MEMORY; + COMN_Release(&vol); + goto exit; + } + unicpy(parms->u.rename.volumeName, uniVolName); + unicpy(parms->u.rename.volumeNameNew, uniNewName); + + status = vol->VOLcomnVolOps.VOL_commandFunction(&genMsg, vol, + VCO_VOLUME_RENAME_NUMBER, parms, 0, NULL, 0, NULL, 0, 0, + NULL, NULL); + } + + /* NB: COMN_Release(&vol) happened in VOL_commandFunction() */ +exit: + if (parms != NULL) + { + free(parms); + } + return(status); +} + + +/**************************************************************************** + * + * This function... + * KERNEL FUNC + * + ****************************************************************************/ + +STATUS ChangeVolumeState(unicode_t *uniVolName, BOOL activateVolume, + utf8_t *volumePassword, NINT *errIndex) +{ + STATUS status = zFAILURE; + GeneralMsg_s genMsg; + Volume_s *vol; + + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + vol = COMN_VolumeNameLookup(&genMsg,uniVolName,FALSE,NULL); + if (vol == NULL) + { + return GetErrno(&genMsg); + } + + if ((vol != NULL) && (activateVolume) && (vol->state != zVOLSTATE_ACTIVE)) + { + /* check for encrypted volume support */ + if ((vol->VOLenabledAttributes & zATTR_ENCRYPTED) && + (volumePassword != NULL) && (strlen(volumePassword) != 0)) + { + unicode_t password[ENCRYPTED_VOLUME_PASSWORD_LENGTH+1]; + + /* password to unicode */ + if (utf2uni(volumePassword, password, sizeof(password)) == -1) + { + status = zERR_INVALID_UTF8_CHAR; + *errIndex = MANAGE_VOLUME_ERROR_CONVERT_VOL_PASSWORD; /*MSGNot("Error converting volume password to unicode");*/ + bzero(password, sizeof(password)); + goto exitRelease; + } + else + { + (void)COMN_SVPW(uniVolName, password); /* register the volume password */ + bzero(password, sizeof(password)); + } + } + /* NSS Volume needs to be activated */ + if ((status = COMN_ChangeVolumeStateByName(&genMsg, uniVolName, + zVOLSTATE_ACTIVE, VOLMODE_VERBOSE)) != zOK) + { + status = GetErrno(&genMsg); + *errIndex = MANAGE_VOLUME_ERROR_ACTIVATING_VOLUME; /*MSGNot("Unsuccessful in activating the volume");*/ + goto exitRelease; + } + if (vol->state != zVOLSTATE_ACTIVE) + { + status = zFAILURE; + *errIndex = MANAGE_VOLUME_ERROR_ACTIVATING_VOLUME; /*MSGNot("Unsuccessful in activating the volume");*/ + goto exitRelease; + } + } + else if ((vol != NULL) && (!activateVolume) && (vol->state == zVOLSTATE_ACTIVE)) + { + /* NSS Volume needs to be deactivated */ + if ((status = COMN_ChangeVolumeStateByName(&genMsg, uniVolName, + zVOLSTATE_DEACTIVE, VOLMODE_VERBOSE)) != zOK) + { + status = GetErrno(&genMsg); + *errIndex = MANAGE_VOLUME_ERROR_DEACTIVATING_VOLUME; /*MSGNot("Unsuccessful in deactivating the volume");*/ + goto exitRelease; + } + if (vol->state != zVOLSTATE_DEACTIVE) + { + status = zFAILURE; + *errIndex = MANAGE_VOLUME_ERROR_DEACTIVATING_VOLUME; /*MSGNot("Unsuccessful in deactivating the volume");*/ + goto exitRelease; + } + } + else + { + status = zOK; + } + +exitRelease: + if (vol != NULL) + { + COMN_Release(&vol); + } + return(status); +} + + +/**************************************************************************** + * + * This function... + * KERNEL FUNC + * + ****************************************************************************/ + +STATUS PerformDeletedVolumeAction(unicode_t *uniVolName, + deletedVolumeAction_t action) +{ + STATUS status = zOK; + Volume_s *vol = NULL; + GeneralMsg_s genMsg; + VCO_VolumeCommonOps_s *parms = NULL; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + COMN_INCLUDE_INTERNAL_VOLUMES( &genMsg ); + + vol = COMN_VolumeNameLookup(&genMsg, uniVolName, FALSE, NULL); + if (vol != NULL) + { + parms = zalloc(sizeof(*parms)); + if (parms == NULL) + { + status = zERR_NO_MEMORY; + COMN_Release(&vol); + goto exit; + } + + switch(action) + { + case DELETE_ACTION_SALVAGE: + parms->u.deleteAction.action = zVOL_LV_DELETE_ACTION_SALVAGE; + break; + case DELETE_ACTION_PAUSE: + parms->u.deleteAction.action = zVOL_LV_DELETE_ACTION_PAUSE; + break; + case DELETE_ACTION_CONTINUE: + parms->u.deleteAction.action = zVOL_LV_DELETE_ACTION_CONTINUE; + break; + case DELETE_ACTION_PURGE: + parms->u.deleteAction.action = zVOL_LV_DELETE_ACTION_PURGE; + break; + default: + status = zERR_BAD_PARAMETER_VALUE; + COMN_Release(&vol); + goto exit; + } + unicpy(parms->u.delete.volumeName, uniVolName); + status = vol->VOLcomnVolOps.VOL_commandFunction(&genMsg, vol, + VCO_VOLUME_DELETE_ACTION_NUMBER, parms, 0, NULL, 0, NULL, 0, 0, + NULL, NULL); + } + + /* NB: COMN_Release(&vol) happened in VOL_commandFunction() */ +exit: + if (parms != NULL) + { + free(parms); + } + + return(status); +} + + +/**************************************************************************** + * + * This function... + * KERNEL FUNC + * + ****************************************************************************/ + +STATUS RenameSalvagedVolume(unicode_t *uniVolName, unicode_t *uniNewName, + NINT *state) +{ + STATUS status; + GeneralMsg_s genMsg; + Volume_s *volume = NULL; + VCO_VolumeCommonOps_s *parms = NULL; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + volume = COMN_VolumeNameLookup(&genMsg, uniVolName, FALSE, NULL); + if (volume == NULL) + { + status = GetErrno(&genMsg); + goto exit; + } + + /* Allocate buffer for LSS command functions */ + parms = zalloc(sizeof(*parms)); + if (parms == NULL) + { + status = zERR_NO_MEMORY; + COMN_Release(&volume); + goto exit; + } + + unicpy(parms->u.rename.volumeName, uniVolName); + unicpy(parms->u.rename.volumeNameNew, uniNewName); + + COMN_USE_BEAST( &volume->VOLroot ); /* VOL_commandFunction releases this extra count */ + status = volume->VOLcomnVolOps.VOL_commandFunction(&genMsg, volume, + VCO_VOLUME_RENAME_NUMBER, parms, 0, NULL, 0, NULL, 0, 0, NULL, NULL); + if ((status == zOK) && (state != NULL)) + { + *state = volume->state; + } + COMN_Release(&volume); +exit: + if (parms != NULL) + { + free(parms); + } + return(status); +} + + +/**************************************************************************** + * + * This function... + * KERNEL FUNC + * + ****************************************************************************/ + +STATUS RemoveUserFromIDStore(unicode_t *volumeName, UserID_t *userID, + NINT *errIndex) +{ + STATUS status; + GeneralMsg_s genMsg; + Volume_s *vol; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + vol = COMN_VolumeNameLookup(&genMsg, volumeName, FALSE, NULL); + if (vol == NULL) + { + status = GetErrno(&genMsg); + *errIndex = MANAGE_VOLUME_ERROR_FINDING_VOLUME; /*MSGNot("Error finding volume in NSS");*/ + goto exit; + } + + if (COMN_LockVolumeActive(&genMsg, vol, FALSE) != zOK) + { + status = GetErrno(&genMsg); + *errIndex = MANAGE_VOLUME_ERROR_VOLUME_NOT_ACTIVE; /*MSGNot("Volume not active");*/ + goto exitRelease; + } + + status = vol->VOLcomnVolOps.VOL_removeUser(&genMsg, vol, userID); + if (status != zOK) + { + status = GetErrno(&genMsg); + *errIndex = MANAGE_VOLUME_ERROR_REMOVING_USER; /*MSGNot("Error removing user from volume");*/ + goto exitUnlock; + } + +exitUnlock: + COMN_UnlockVolumeActive(vol, FALSE); + +exitRelease: + COMN_Release(&vol); +exit: + return(status); +} + + +/* Get the setNum value for a Set item */ +/* This belongs in que.h */ +#define SET_GETSETNUM(item, linkField) \ + item->linkField.setNum + +/* Find the entry following the specified _setNum */ +/* This belongs in que.h */ +#define SET_FINDENTRY(head, item, type, linkField, _setNum) \ + { \ + type *_item; \ + SETlink_t _dummySet; \ + \ + _dummySet.setNum = _setNum; \ + item = NULL; \ + SET_FOREACH(head, _item, type, linkField) \ + { \ + if (SET_GT(&(_item)->linkField, &_dummySet)) \ + { \ + item = _item; \ + break; \ + } \ + } \ + } + +/**************************************************************************** + * + * This function... + * KERNEL FUNC + * + ****************************************************************************/ + +STATUS GetNextVolumeName(BOOL firstTime, SQUAD *cookie, unicode_t *uniName, + NINT uniNameLen, BOOL *isLogical) +{ + STATUS status = zFAILURE; + GeneralMsg_s genMsg; + Volume_s *volume; + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + if (firstTime) + { + SET_PEEK(&NSSMasterVolumeList, volume, Volume_s, masterVolLink); + } + else + { + SET_FINDENTRY(&NSSMasterVolumeList, volume, Volume_s, masterVolLink, + *cookie); + } + while (volume != NULL) + { + if ( !VOL_ACCESSIBLE1(volume) ) + { + goto NextVolume; + } + + COMN_USE_BEAST( &volume->VOLroot ); + X_LATCH( &volume->cvsLatch ); + + if ((status = COMN_GetVolumeName(&genMsg, volume, uniName, + uniNameLen)) != zOK) + { + status = GetErrno(&genMsg); +// MNSS_ReturnResult(virtInfo, TAG_VOLUMEINFO, status, +// MSGNot("Error unable to get the name of a volume")); + UNX_LATCH( &volume->cvsLatch ); + COMN_Release( &volume ); + break; + } + + *isLogical = volume->v_statusFlag & VOL_SF_LOGICAL_VOLUME; + *cookie = SET_GETSETNUM(volume, masterVolLink); + UNX_LATCH( &volume->cvsLatch ); + COMN_Release( &volume ); + break; + +NextVolume: + volume = SET_NEXT(&NSSMasterVolumeList, volume, Volume_s, + masterVolLink); + } + + return(status); +} +#endif /* Kernel functions */ + + +/**************************************************************************** + * + * User Space Functions + * On Linux, these run in user space + * On NetWare, everything runs in the kernel... + * + ****************************************************************************/ + +#if !defined(__KERNEL__) + +/**************************************************************************** + * + * This function... + * + ****************************************************************************/ + +STATUS GetNDSNameFromGUID(unicode_t *uniVolName, utf8_t *objectName) +{ + STATUS status = zFAILURE; + UserID_t ndsObjectID; + void *vol = NULL; + + if (NSSVolumeFound(uniVolName, FALSE, NULL, NULL, NULL, NULL, &ndsObjectID) == zOK) + { + status = MNSS_GetNDSNameFromGUID(vol, &ndsObjectID, objectName); + } + return(status); +} + + +#define NORENAME_OPTION "norename" +#define NAMESPACE_OPTION "ns" +#define NAME_OPTION "name" + +/**************************************************************************** + * + * This function creates the directories in the passed in path if they do not + * exist. It assumes that the path has only directories in it. + * + ****************************************************************************/ +void MNSS_CreateDirs( + utf8_t *path) +{ + char *cur = path; + int lenPath = strlen(path); + char *endPath = path + lenPath; + char *end; + char holdChar; + int ccode; + + cur = strchr(cur, '/') + 1; + if (!cur) + { + return; + } + while(cur < endPath) + { + end = strchr(cur, '/'); + if (!end) + { + end = endPath; + } + + holdChar = *end; + *end = '\0'; +//printf("Creating path %s\n", path); + ccode = mkdir(path, CREATE_DIR_MODE); + *end = holdChar; + if(ccode != 0) + { + if(errno != EEXIST) + { + syslog(LOG_ALERT, + "Failed to create the directory %s for mounting a volume.\n", path); + return; + } + } + cur = end + 1; + } +} + + +/* + * Given an option string find the option passed in and return any value + * return True if option is found. + */ +BOOL MNSS_GetOption( + struct mntent *mountEntry, + const char *option, + char *value) +{ + char *startOfOption; + char *endOfOption; + char *startOfValue; + char *endOfValue; + +//printf("Entering get option: %s\n", option); +//printf("options from entry: %s\n", mountEntry->mnt_opts); + startOfOption = hasmntopt(mountEntry, option); + if (startOfOption == NULL) + { +//printf("Exiting get option: could not find %s\n", option); + return FALSE; + } + + /* Get any value that might be associated with the option */ + if (value != NULL) + { + startOfValue = strstr(startOfOption, "="); + endOfOption = strstr(startOfOption, ","); + if (startOfValue && (!endOfOption || (endOfOption > startOfValue))) + { + startOfValue++; + endOfValue = strstr(startOfValue, ","); + if (endOfValue) + { + int len = endOfValue - startOfValue; + memcpy(value, startOfValue, len); + value[len] = '\0'; + } + else + { + strcpy(value, startOfValue); + } + } + else + { + value[0] = '\0'; + } + } +//printf("Exiting get option: found %s with value %s\n", option, value); + return TRUE; +} + +/* + * Get the stored mount point of a mounted volume. The volume may or may not + * be mounted. Result comes from parsing the fstab or mtab. + * Return: less than 0 = error + * equal to 0 = not found + * greater than 0 = found + */ +int MNSS_GetMountPoint( + utf8_t *name, + BOOL mountTab, + char *retMountPoint, + char *retDevice, + char *retName, + BOOL *retRename, + char *retNameSpace) +{ + FILE *file=NULL; + BOOL foundMountPoint = FALSE; + char *mountTable; + struct mntent *mountEntry; + + mountTable = mountTab ? "/etc/mtab" : "/etc/fstab"; + if(retMountPoint) + { + retMountPoint[0] = '\0'; + } + if (retDevice) + { + retDevice[0] = '\0'; + } + if (retName) + { + retName[0] = '\0'; + } + if(retRename != NULL) + { + *retRename = FALSE; + } + if (retNameSpace != NULL) + { + retNameSpace[0] = '\0'; + } + + /* check either mtab or fstab for the mount point */ + if ((file = setmntent(mountTable, "r")) == NULL) + { + syslog(LOG_NOTICE, "Error opening %s. Error=%m\n", mountTable); + return -ENOENT; + } + + + for (;;) + { + mountEntry = getmntent(file); + if (mountEntry == NULL) + { + break; + } +//printf("Get mount point. dev=%s mnt=%s ty=%s opt=%s pass=%d freq=%d\n", +// mountEntry->mnt_fsname, +// mountEntry->mnt_dir, +// mountEntry->mnt_type, +// mountEntry->mnt_opts, +// mountEntry->mnt_passno, +// mountEntry->mnt_freq); + + if (strcmp(mountEntry->mnt_type, "nssvol") == 0) + { + char value[256]; + + if (MNSS_GetOption(mountEntry, NAME_OPTION, value)) + { +//printf("Get mount point: option value=%s\n", value); + if (strcmp(value, name) == 0) + { + foundMountPoint = TRUE; + if (retMountPoint) + { + strcpy(retMountPoint, mountEntry->mnt_dir); + } + if (retDevice) + { + strcpy(retDevice, mountEntry->mnt_fsname); + } + if (retName) + { + strcpy(retName, value); + } + if (retRename) + { + if (MNSS_GetOption(mountEntry, NORENAME_OPTION, NULL) == FALSE) + { + *retRename = TRUE; + } + } + if (retNameSpace) + { + MNSS_GetOption(mountEntry, NAMESPACE_OPTION, + retNameSpace); + } + break; + } + } + else + { + // Old form: the name was the only option + if (strcmp(mountEntry->mnt_opts, name) == 0) + { + foundMountPoint = TRUE; + if (retMountPoint) + { + strcpy(retMountPoint, mountEntry->mnt_dir); + } + break; + } + } + } + } + + endmntent(file); + return foundMountPoint; +} + +/* + * This function updates the value of an option + * for fstab. If remove is true then the entry + * is removed. If value is NULL then the option + * is inserted without a value. + */ +void MNSS_UpdateOption( + char *optionString, + BOOL removeFlag, + char *option, + char *value) +{ + char *startLoc = optionString; + char *endLoc; + char *optionLoc; + char *endOption; + +//printf("Updating fstab. string=%s opt=%s val=%s\n", optionString, option, value); + for(;;) + { + optionLoc = strstr(startLoc, option); + if (!optionLoc) + { + break; + } + endLoc = optionLoc + strlen(option); + startLoc = endLoc; + if ((*endLoc == '\0') || + (value && *endLoc == '=') || + (!value && *endLoc == ',')) + { + break; + } + } + + /* Remove the old option */ + if (optionLoc) + { + endOption = strstr(optionLoc, ","); + if (optionLoc > optionString) + { + if (*(optionLoc-1) == ',') + { + optionLoc--; + } + } + if (endOption) + { + if (optionLoc == optionString) + { + endOption++; /* skip the leading comma */ + } + strcpy(optionLoc, endOption); + } + else + { + *optionLoc = '\0'; + } + } + + /* Put in the new option */ + if (!removeFlag) + { + if (strlen(optionString) > 0) + { + strcat(optionString, ","); + } + strcat(optionString, option); + if (value) + { + strcat(optionString, "="); + strcat(optionString, value); + } + } +} + +/* + * This function scans the fstab looking for an entry for the given volume. It + * calls the specified function to determine what to do with the entry. + */ +STATUS MNSS_UpdateFstab( + char *volName, + char *newMountPoint, + BOOL *newRenameOption, + char *newVolName, + char *newNameSpace, + BOOL *found) +{ + int fd; + FILE *file; + FILE *tempFile; + char tempFileName[32]; + char options[1024]; + STATUS status = zOK; + BOOL removeFlag = FALSE; + struct mntent *mountEntry; + +//printf("UpdateFstab. Attempting to update volume %s\n", volName); + /* Add, modify, or delete the entry in /etc/fstab */ + *found = FALSE; + if ((file = setmntent("/etc/fstab", "r+")) == NULL) + { + syslog(LOG_NOTICE, "Error opening /etc/fstab.\n"); + return zERR_BAD_FILE_HANDLE; + } + + /* create a temp file in case we need to modify /etc/fstab */ + strcpy(tempFileName, "/etc/fstabXXXXXX"); + if (((fd = mkstemp(tempFileName)) == -1) || + (close(fd), + ((tempFile = setmntent(tempFileName, "w+")) == NULL))) + { + syslog(LOG_NOTICE, "Error opening the temp file for modifying mount point.\n"); + endmntent(file); + return zERR_BAD_FILE_HANDLE; + } + + for (;;) + { + mountEntry = getmntent(file); + if (mountEntry == NULL) + { + break; + } + // if (fscanf(file, "%s%s%s%s%s%s", device, mountPoint, fsType, options, &dump, &boot) != 6) +// { +// break; +// } + strcpy(options, mountEntry->mnt_opts); + if (!(*found) && strcmp(mountEntry->mnt_type, "nssvol") == 0) + { + utf8_t value[256]; + + if (MNSS_GetOption(mountEntry, NAME_OPTION, value) && + (strcmp(value, volName) == 0)) + { +//printf("UpdateFstab. Found volume %s\n", volName); + *found = TRUE; + if (newMountPoint || newRenameOption || newVolName || newNameSpace) + { + if (newMountPoint) + { + mountEntry->mnt_dir = newMountPoint; + } + if (newVolName) + { + mountEntry->mnt_fsname = newVolName; +//printf("UpdateFstab. new volume %s\n", newVolName); + MNSS_UpdateOption(options, FALSE, NAME_OPTION, + newVolName); + } + if (newRenameOption) + { + if (*newRenameOption) + { + MNSS_UpdateOption(options, TRUE, NORENAME_OPTION, + NULL); + } + else + { + MNSS_UpdateOption(options, FALSE, NORENAME_OPTION, + NULL); + } + } + if (newNameSpace) + { + MNSS_UpdateOption(options, FALSE, NAMESPACE_OPTION, + newNameSpace); + } + } + else + { + removeFlag = TRUE; + } + } + } + if (!removeFlag) + { +//printf("fstab update. Keep entry. Vol=%s mount=%s\n", mountEntry->mnt_fsname, mountEntry->mnt_dir); + mountEntry->mnt_opts = options; + addmntent(tempFile, mountEntry); + } + else + { +//printf("fstab update. Remove entry. Vol=%s mount=%s\n", mountEntry->mnt_fsname, mountEntry->mnt_dir); + removeFlag = FALSE; + } + } + +exit: + /* Now we have all the content of fstab plus the modified mount point */ + /* in the temp file, delete fstab, and rename the temp file to fstab */ + endmntent(file); + endmntent(tempFile); + if (status == zOK) + { + if((status = remove("/etc/fstab")) != 0) + { + syslog(LOG_NOTICE, "Error removing /etc/fstab.\n"); + goto exit; + } + if((status = rename(tempFileName, "/etc/fstab")) != 0) + { + syslog(LOG_NOTICE, "Error renaming the temp file to fstab.\n"); + goto exit; + } + } + remove(tempFileName); +//printf("UpdateFstab. Exit code=%d\n", status); + return status; +} + +/* + * This function adds an entry to the end of the fstab + */ +static STATUS AppendToFstab( + char *volName, + char *mountPoint, + BOOL renameFlag, + char *newNameSpace) +{ + FILE *file; + char options[1024]; +// char *renameOption; + struct mntent mountEntry; + char defaultMountPoint[MOUNT_POINT_MAX_SIZE]; + char name[zMAX_COMPONENT_NAME]; + + if (mountPoint == NULL) + { + sprintf(defaultMountPoint, MSGNot("%s%s"), + VOLUME_MOUNT_POINT, volName); + mountPoint = defaultMountPoint; + } + +//printf("Appending vol %s to fstab as mount point %s\n", volName, mountPoint); + /* Add, modify, or delete the entry in /etc/fstab */ + if ((file = setmntent("/etc/fstab", "a")) == NULL) + { + syslog(LOG_NOTICE, "Error opening /etc/fstab.\n"); + return zERR_BAD_FILE_HANDLE; + } + + strcpy(options, MNTOPT_NOAUTO","MNTOPT_RW","NAME_OPTION"="); + strcat(options, volName); + if (!renameFlag) + { + strcat(options, ","NORENAME_OPTION); + } + + if (newNameSpace != NULL) + { + strcat(options, ","NAMESPACE_OPTION"="); + strcat(options, newNameSpace); + } + + if (volName[0] == '#') + { + strcpy(name, "_"); + } + else + { + name[0] = '\0'; + } + strcat(name, volName); + mountEntry.mnt_fsname = name; + mountEntry.mnt_dir = mountPoint; + mountEntry.mnt_type = "nssvol"; + mountEntry.mnt_opts = options; + mountEntry.mnt_freq = 0; + mountEntry.mnt_passno = 0; +//printf("fstab append. Vol=%s mount=%s\n", mountEntry.mnt_fsname, mountEntry.mnt_dir); + addmntent(file, &mountEntry); + + endmntent(file); + return zOK; +} + +/* + * Add the mount point to fstab for a volume + */ +STATUS MNSS_AddMountPoint( + utf8_t *poolName, + utf8_t *volName, + utf8_t *mountPoint, + BOOL renameFlag, + char *newNameSpace) +{ + BOOL isShared; + POOLSNAP_TYPE poolType ; + // Don't put fstab entries in on shared volumes because the + // pool comes up deactive. + if(poolName && poolName[0] != '\0') + { + if(LINUX_GetPoolSharedState(TRUE, poolName, &isShared) == zOK) + { + if (isShared) + { + syslog(LOG_INFO, "Mounted volume on shared device. Mount table (fstab) not updated.\n"); + return zOK; + } + } + /* + * Don't put fstab entries in on snapshot volumes because the + * snap pool comes up deactive by default. + */ + if(LINUX_GetPoolSnapshotType(TRUE, poolName, &poolType) == zOK) + { + if(poolType == POOL_SNAPSHOT) + { + syslog (LOG_INFO, "Volume mounted. Mount table (fstab) not updated") ; + return zOK ; + } + } + } + + syslog(LOG_INFO, "Mount table (fstab) updating on volume mount.\n"); + if(MNSS_GetMountPoint(volName, FALSE, NULL, NULL, NULL, NULL, NULL) > 0) + { + return zERR_FILE_ALREADY_EXISTS; + } + + return AppendToFstab(volName, mountPoint, renameFlag, newNameSpace); +} + +/* + * Find and remove the mount point from fstab for a volume + * and remove the mount point folder from the file system as well. + * + * The incoming parameter 'mountPoint' is optional. If it is not + * NULL and does not contain an empty string, this is used. Else + * the mount point is looked up at the fstab. + */ + +STATUS MNSS_RemoveMountPoint( + utf8_t *volName, + char *mountPoint) +{ + char mountPointTemp[MOUNT_POINT_MAX_SIZE]; + char *mountPointToRemove = NULL; + BOOL found; + STATUS status; + + if(mountPoint != NULL && mountPoint[0] != '\0') + { + mountPointToRemove = mountPoint; + } + else + { + MNSS_GetMountPoint(volName, FALSE, mountPointTemp, NULL, NULL, NULL, NULL); + mountPointToRemove = mountPointTemp; + } +//printf("Remove Mount point: %s\n", mountPointToRemove); + (void)RemoveMountPoint(mountPointToRemove); + status = MNSS_UpdateFstab(volName, NULL, NULL, NULL, NULL, &found); + return status; +} + +/* + * Modify a mount point in the fstab + */ +STATUS MNSS_ModifyMountPoint( + utf8_t *volName, + char *newMountPoint, + BOOL *newRenameOption, + char *newNameSpace) +{ + BOOL found; + STATUS status; + BOOL renameFlag; + char mountPoint[MOUNT_POINT_MAX_SIZE]; + char nameSpace[NAME_SPACE_MAX_SIZE]; + STATUS dismountStatus; + BOOL oldRenameOption; + utf8_t poolName[zMAX_FULL_NAME]; + + /* + * Check fstab then mtab + */ + if ((MNSS_GetMountPoint(volName, FALSE, mountPoint, NULL, NULL, &oldRenameOption, nameSpace) <= 0) && + (MNSS_GetMountPoint(volName, TRUE, mountPoint, NULL, NULL, &oldRenameOption, nameSpace) <= 0)) + { + return zERR_NO_FSTAB_ENTRY; + } + + if (((newMountPoint == NULL) || (strcmp(newMountPoint, mountPoint) == 0)) && + (!newRenameOption || (*newRenameOption == oldRenameOption)) && + ((newNameSpace == NULL) || (strcmp(newNameSpace, nameSpace) == 0))) + { + return zOK; + } + + dismountStatus = DismountVolume(volName, TRUE); + if (dismountStatus != zOK && dismountStatus != zERR_VOLUME_NOT_MOUNTED) + { + return zERR_CANNOT_UNMOUNT_VOLUME; + } + + status = MNSS_UpdateFstab(volName, newMountPoint, newRenameOption, + NULL, newNameSpace, &found); + if (status != zOK) + { + return status; + } + + if (!found) + { + char defaultMountPoint[MOUNT_POINT_MAX_SIZE]; + if (newMountPoint == NULL) + { + sprintf(defaultMountPoint, MSGNot("%s%s"), + VOLUME_MOUNT_POINT, volName); + } + renameFlag = newRenameOption ? *newRenameOption : TRUE; + /* pool name */ + if(GetNSSVolumeHostPool(volName,poolName) != zOK) + { + poolName[0] = '\0'; + } + + status = MNSS_AddMountPoint(poolName, volName, + newMountPoint == NULL ? defaultMountPoint : newMountPoint, + renameFlag, + newNameSpace); + if (status != zOK) + { + return status; + } + } + + if (newMountPoint) + { + MNSS_CreateDirs(newMountPoint); + status = RenameMountPoint(volName, volName, mountPoint, newMountPoint, + FALSE); + } + + if (dismountStatus != zERR_VOLUME_NOT_MOUNTED) + { + status = MountVolume(volName, TRUE, NULL); + if (status != zOK) + { + return zERR_CANNOT_MOUNT_VOLUME; + } + } + + return status; +} + +/* + * Rename a mount point in the fstab if it is the default path and the + * option is not set to inhibit renaming of mount points. + */ +STATUS MNSS_RenameMountPoint( + utf8_t *volName, + char *newVolName) +{ + char mountPoint[MOUNT_POINT_MAX_SIZE]; + char newMountPoint[MOUNT_POINT_MAX_SIZE]; + char defaultMountPoint[MOUNT_POINT_MAX_SIZE]; + BOOL found = FALSE; + STATUS status; + BOOL renameFlag; + STATUS dismountStatus; + utf8_t poolName[zMAX_FULL_NAME]; + + +//printf("Rename Mount point from %s to %s\n", volName, newVolName); + mountPoint[0] = '\0'; + if ((MNSS_GetMountPoint(volName, FALSE, mountPoint, NULL, NULL, &renameFlag, NULL) > 0) || + (MNSS_GetMountPoint(volName, TRUE, mountPoint, NULL, NULL, &renameFlag, NULL) > 0)) + { + found = TRUE; + } +//printf("MNSS_RenameMountPoint -- mount point=!%s!\n", mountPoint); + + // If it can't be dismounted then don't continue because we will end up + // with it double mounted. + dismountStatus = DismountVolume(volName, TRUE); + if (dismountStatus != zOK && dismountStatus != zERR_VOLUME_NOT_MOUNTED) + { + return zERR_CANNOT_UNMOUNT_VOLUME; + } + + sprintf(defaultMountPoint, MSGNot("%s%s"), VOLUME_MOUNT_POINT, volName); + if (renameFlag && strcmp(defaultMountPoint, mountPoint) == 0) + { + sprintf(newMountPoint, MSGNot("%s%s"), VOLUME_MOUNT_POINT, newVolName); + status = RenameMountPoint(volName, newVolName, mountPoint, + newMountPoint, FALSE); + if (status != zOK) + { + return status; + } + status = MNSS_UpdateFstab(volName, newMountPoint, NULL, + newVolName, NULL, &found); + } + else + { + status = MNSS_UpdateFstab(volName, NULL, NULL, newVolName, NULL, + &found); + if (!found) + { + strcpy(newMountPoint, mountPoint); + } + } + if (status != zOK) + { + return status; + } + + if (!found && mountPoint[0] != '\0') + { + /* pool name */ + if(GetNSSVolumeHostPool(newVolName,poolName) != zOK) + { + poolName[0] = '\0'; + } + + status = MNSS_AddMountPoint(poolName, newVolName, newMountPoint, TRUE, NULL); + if (status != zOK) + { + return status; + } + } + + if (dismountStatus != zERR_VOLUME_NOT_MOUNTED) + { + status = MountVolume(newVolName, TRUE, NULL); + if (status != zOK) + { + return zERR_CANNOT_MOUNT_VOLUME; + } + } + + return status; +} + + +/**************************************************************************** + * Return TRUE if the specified volume is mounted + *****************************************************************************/ +BOOL IsVolumeMounted( + char *volumeNameString) +{ + return MNSS_GetMountPoint(volumeNameString, TRUE, NULL, NULL, NULL, NULL, NULL) > 0 ? + TRUE : FALSE; +} + + +/**************************************************************************** + * + *****************************************************************************/ +void SetVolumeState(XML_ElementInfo_s *element, + BOOL defaultVolumeMounted, + BOOL defaultVolumeActive, + utf8_t *volName, + unicode_t *uniVolName, + NINT *errIndex) +{ + enum + { + MNSS_NO_VOL_STATE_CHANGE, + MNSS_VOL_STATE_ACTIVE, + MNSS_VOL_STATE_DEACTIVE, + MNSS_VOL_STATE_MOUNTED + } action; + + action = MNSS_NO_VOL_STATE_CHANGE; + if (XML_GetTagAttribute(ATR_STATE, element) == zOK) + { + *(element->attributeValueEnd + 1) = 0; + if (strcmp(element->attributeValueStart, + MSGNot("active")) == 0) + { + action = MNSS_VOL_STATE_ACTIVE; + } + else if (strcmp(element->attributeValueStart, + MSGNot("deactive")) == 0) + { + action = MNSS_VOL_STATE_DEACTIVE; + } + else if (strcmp(element->attributeValueStart, + MSGNot("mounted")) == 0) + { + action = MNSS_VOL_STATE_MOUNTED; + } + } + + /* Change the volume state if requested */ + switch (action) + { + case MNSS_NO_VOL_STATE_CHANGE: + if (!defaultVolumeMounted) + { + DismountVolume(volName, FALSE); + } + break; + + case MNSS_VOL_STATE_MOUNTED: + /* Already Mounted and Active */ + break; + + case MNSS_VOL_STATE_ACTIVE: + /* Already Mounted and Active */ + DismountVolume(volName, FALSE); + break; + + case MNSS_VOL_STATE_DEACTIVE: + DismountVolume(volName, FALSE); + (void) ChangeVolumeState(uniVolName, FALSE, NULL, errIndex); + break; + } +} + + +/**************************************************************************** + * Set the DFS GUID for a volume (ignoring errors), and add it to the VLDB + * unless told otherwise + *****************************************************************************/ +STATUS SetVolumesDFSGUID(utf8_t *volumeName, unicode_t *uniVolName, + utf8_t *poolName, GUID_t *dfsGUID, BOOL updateVLDB, + char **errText) +{ + STATUS status = zOK; + unicode_t *serverName = NULL; + unicode_t serverNameBuf[zMAX_FULL_NAME] ; + void *ncsHandle; + NCS_HANDLE handle; + NCS_POOL_INFO poolInfo; + NCSRFPTR reg = NULL; + NCSDFPTR dereg = NULL; + NCSFFPTR find = NULL; + + + /* Set the DFS GUID and ignore any error. We have to do this because + * we might be running in install where we can't set the DFS GUID. + * Fortunately, we expect Volume Manager to automatically correct + * any error automatically in any case. */ + + (void)VOLMNSetDFSGuid(uniVolName, dfsGUID); + +//Initialise tree name + InitLocalServerName(); + if (updateVLDB) + { + ncsHandle = dlopen(NCS_LIB_NAME, RTLD_LAZY); + if (ncsHandle != NULL) + { + /* Import NCS symbols */ + reg = (NCSRFPTR) dlsym(ncsHandle, NCS_REGISTER_FUNCTION_NAME); + dereg = (NCSDFPTR) dlsym(ncsHandle, NCS_DEREGISTER_FUNCTION_NAME); + find = (NCSFFPTR) dlsym(ncsHandle, NCS_FIND_FUNCTION_NAME); + } + + if ((reg != NULL) && (dereg != NULL) && (find != NULL)) + { + syslog(LOG_INFO, "Registering with cluster services\n"); + status = (*reg)(NULL, "ManageNSS", NULL, NULL, NULL, &handle); + if (status == NCS_SUCCESS) + { + status = (*find)(handle, volumeName, &poolInfo); + (void) (*dereg)(handle); + if (status == NCS_SUCCESS) + { + serverNameBuf[0] = DELIM_DF_RDN; + utf2uni((utf8_t *) poolInfo.VirtServFDN, &serverNameBuf[1], + zMAX_FULL_NAME - sizeof(unicode_t)); + ConvertToDottedName(serverNameBuf); + RemoveTypes(serverNameBuf); + if(LocalTreeName) + unicat(serverNameBuf, LocalTreeName); + serverName = serverNameBuf; + } + } + } + + + /* Add this volume to the VLDB */ + if ((status = AddVolumeToVLDB(dfsGUID, serverName, uniVolName, errText)) != zOK) + { + if ((status == VLDB_ERR_ENTRY_NOT_FOUND) || + (status == VLDB_ERR_NO_MANAGEMENT_CONTEXT)) + { + /* This server does not have a DFS Management Context */ + status = zOK; + } + } + + if (ncsHandle != NULL) + { + (void) dlclose(ncsHandle); + } + } + return(status); +} + + +/**************************************************************************** + * + * This function adds a volume to a pool. Additionally, it adds the volume + * object to NDS. + * + ****************************************************************************/ + +STATUS MNSS_ProcessAddVolume( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + BOOL defaultVolumeActive; + BOOL defaultVolumeMounted; + BOOL isClustered; + GUID_t volumeGUID; + GUID_t dfsGUID; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + unicode_t uniPoolName[zMAX_COMPONENT_NAME]; + unicode_t password[ENCRYPTED_VOLUME_PASSWORD_LENGTH+1]; + NINT i; + NINT authModelID = zFTYPE_ZAS_AUTH_MODEL; + NINT volState; + NINT errIndex; + zVolumeInfo_s info; + char *errorString = NULL; + int errorVal = zOK; + char *errText = NULL; + char mountPoint[zMAX_FULL_NAME]; + + const TagRequest_s tags[] = + { + {TAG_NDSNAME, TR_OPTIONAL}, + {TAG_CONTEXT, TR_OPTIONAL}, + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_AUTHORIZATIONMODEL, TR_OPTIONAL | TR_CONTENT_REQUIRED}, + {TAG_VOLUMEGUID, TR_OPTIONAL}, + {TAG_DFSGUID, TR_OPTIONAL}, + {TAG_NODFSGUID, TR_OPTIONAL}, + {TAG_NDSPOOLNAME, TR_OPTIONAL}, + {TAG_NONDSOBJECT, TR_OPTIONAL}, + {TAG_UPDATEVLDB, TR_OPTIONAL}, + {TAG_VOLUMEPASSWORD, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + NDS_NAME = 0, + CONTEXT = 1, + VOLUME_NAME = 2, + POOL_NAME = 3, + AUTHORIZATION_MODEL = 4, + VOLUME_GUID = 5, + DFS_GUID = 6, + NO_DFS_GUID = 7, + NDS_POOL_NAME = 8, + NO_NDS_OBJECT = 9, + UPDATE_VLDB = 10, + VOLUME_PASSWORD = 11 + }; + + ASSERT_MPKNSS_LOCK(); + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* volume name */ + /* + * Upper case the name. It is done before the unicode conversion because + * we use both the unicode and utf8 versions. + */ + for (i = 0; tagContent[VOLUME_NAME].content[i] != '\0'; i++) + { + tagContent[VOLUME_NAME].content[i] = + toupper(tagContent[VOLUME_NAME].content[i]); + } + + if (utf2uni(tagContent[VOLUME_NAME].content, uniVolName, + sizeof(uniVolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + + if ((status = LB_VolumeNameAcceptable(uniVolName)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid volume name")); + goto exit; + } + /* volume password, if any */ + if(tagContent[VOLUME_PASSWORD].content) + { + if (utf2uni(tagContent[VOLUME_PASSWORD].content, password, sizeof(password)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume password to unicode")); + bzero(password, sizeof(password)); + goto exit; + } + } + else + { + /* No password, ... so zero the unicode buffer for password */ + bzero(password, sizeof(password)); + } + + /* pool name */ + for (i = 0; tagContent[POOL_NAME].content[i] != '\0'; i++) + { + tagContent[POOL_NAME].content[i] = + toupper(tagContent[POOL_NAME].content[i]); + } + + tagContent[POOL_NAME].content[i] = '\0'; + + if (utf2uni(tagContent[POOL_NAME].content, uniPoolName, + sizeof(uniPoolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error converting pool name to unicode")); + goto exit; + } + + /* + * The pool is being validated against the volume rules for now. + */ + if ((status = LB_VolumeNameValid(uniPoolName)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid pool name")); + goto exit; + } + + /* Authorization model */ + if (tagContent[AUTHORIZATION_MODEL].flags & TR_TAG_FOUND) + { + authModelID = GetAuthModelID(tagContent[AUTHORIZATION_MODEL].content); + } + + /* optional GUID */ + if (tagContent[VOLUME_GUID].content) + { + if ((status = LB_GUIDFromUTF8(tagContent[VOLUME_GUID].content, + &volumeGUID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error converting volume GUID")); + goto exit; + } + + if (!LB_GUIDValidate(&volumeGUID)) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid volume GUID")); + goto exit; + } + } + else + { + volumeGUID = zINVALID_GUID; + } + + /* optional DFS GUID */ + if (tagContent[DFS_GUID].content) + { + if (tagContent[NO_DFS_GUID].flags & TR_TAG_FOUND) + { + status = zERR_XML_IS_BAD; + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Can't have dfs GUID and noDFSGUID")); + goto exit; + } + if ((status = LB_GUIDFromUTF8(tagContent[DFS_GUID].content, + &dfsGUID)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error converting dfs GUID")); + goto exit; + } + + if (!LB_GUIDValidate(&dfsGUID)) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid dfs GUID")); + goto exit; + } + } + else + { + dfsGUID = zINVALID_GUID; + } + + if (!(tagContent[NO_DFS_GUID].flags & TR_TAG_FOUND)) + { + /* Generate the DFS GUID */ + if (LB_GUIDCompare(&dfsGUID,&zINVALID_GUID) == 0) + { + LB_GUIDGenerate(&dfsGUID); + } + } + + if ((status = CreateVolumeInPool(uniPoolName, uniVolName, authModelID, + volumeGUID, password, &isClustered, &errIndex)) != zOK) + { + bzero(password, sizeof(password)); + MNSS_ReturnResult(virtInfo, tagName, status, + ManageVolumeErrorMessages[errIndex]); + goto exit; + } + bzero(password, sizeof(password)); + + /* + * Before we store the DFS GUID in the volume manager, we + * require that the volume be Active and Mounted. However, if the caller + * requests no state change, then when we are done we need to put the + * volume back into the state it is right now. We need to get the current + * state of the volume so we can restore it if we need to. + */ + if ((status = NSSVolumeFound(uniVolName, FALSE, NULL, NULL, &volState, NULL, NULL)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error finding volume in NSS")); + goto exit; + } + /* Figure out whether the volume is currently active and/or mounted */ + defaultVolumeActive = (volState == zVOLSTATE_ACTIVE) ? TRUE : FALSE; + + defaultVolumeMounted = FALSE; + + sprintf(mountPoint, MSGNot("%s%s"), VOLUME_MOUNT_POINT, + tagContent[VOLUME_NAME].content); +//printf("The mount point is %s\n", mountPoint); + status = MNSS_AddMountPoint(tagContent[POOL_NAME].content, + tagContent[VOLUME_NAME].content, mountPoint,TRUE,NULL); + if (status != zOK) + { + if (status == zERR_FILE_ALREADY_EXISTS) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Volume already exists in mount table")); + + } + else + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error setting the mount point")); + } + goto exit; + } + + MountVolume(tagContent[VOLUME_NAME].content, TRUE, NULL); + + /* + * Add the NDS object if it should be there + */ + + if (!(tagContent[NO_NDS_OBJECT].flags & TR_TAG_FOUND)) + { + if (!(tagContent[NDS_NAME].flags & TR_TAG_FOUND) || + !(tagContent[CONTEXT].flags & TR_TAG_FOUND) || + !(tagContent[NDS_POOL_NAME].flags & TR_TAG_FOUND)) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Missing NDS name or context")); + goto exit; + } + + if ((status = MNDS_AddVolumeToNDS(virtInfo, TRUE, + tagContent[CONTEXT].content, + tagContent[NDS_NAME].content, tagContent[POOL_NAME].content, + tagContent[VOLUME_NAME].content, tagContent[NDS_POOL_NAME].content, + mountPoint, &dfsGUID, &info.ndsObjectID, isClustered)) != zOK) + { + errorString = "Error adding volume to NDS"; + errorVal = status; + } + else + { + if ((status = SetNDSInfoOnVolume(uniVolName, &info, TRUE, TRUE)) != zOK) + { + errorString = "Error setting NDS object ID for NSS volume"; + errorVal = status; + } + } + } + + if (!(tagContent[NO_DFS_GUID].flags & TR_TAG_FOUND)) + { +// syslog(LOG_INFO, "MNSS_ProcessAddVolume: Setting DFS GUID on volume\n"); + status = SetVolumesDFSGUID(tagContent[VOLUME_NAME].content, + uniVolName, + tagContent[POOL_NAME].content, + &dfsGUID, + tagContent[UPDATE_VLDB].flags & TR_TAG_FOUND, + &errText); + } + else + { + syslog(LOG_INFO, "MNSS_ProcessAddVolume: NO_DFS_GUID flag set\n"); + if (tagContent[UPDATE_VLDB].flags & TR_TAG_FOUND) + { + status = zERR_XML_IS_BAD; + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Can't add volume to VLDB if noDFSGUID")); + goto exit; + } + } + + /* + * Check to see if the volume should be left deactive, active or mounted. + */ + SetVolumeState(element, defaultVolumeMounted, defaultVolumeActive, + tagContent[VOLUME_NAME].content, uniVolName, &errIndex); + + if (errorVal == zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, errorVal, errorString); + } + +exit: + /* Zero the password on the stack */ + bzero(password, sizeof(password)); + return zOK; +} + + +/**************************************************************************** + * + * This function modifies the attributes of a volume + * + ****************************************************************************/ + +STATUS MNSS_ProcessModifyVolumeInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status; + zVolumeInfo_s info; + XML_ElementInfo_s parmElement; + utf8_t *attrTagName; + NINT tagLen; + NINT i; + QUAD bit; + NINT count; + NINT modifyInfoMask = 0; + NINT readAhead = 0; + NINT errIndex; + utf8_t *searchStart; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + BOOL renameOption = TRUE; + BOOL *renameOptionPtr = NULL; + char *nameSpacePtr = NULL; + char newMountPoint[MOUNT_POINT_MAX_SIZE]; + char *newMountPointPtr = NULL; + utf8_t objectName[MAX_DN_CHARS+1]; + utf8_t container[MAX_DN_CHARS+1]; + utf8_t object[MAX_DN_CHARS+1]; + STATUS holdStatus = zOK; + char *holdErrorMsg = NULL; + + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_VOLUMEQUOTA, TR_OPTIONAL}, + {TAG_ENABLEDATTRIBUTES, TR_OPTIONAL}, + {TAG_VOLUMEREADAHEAD, TR_OPTIONAL}, + {TAG_MOUNTPOINT, TR_OPTIONAL}, + {TAG_MOUNTPOINTRENAME, TR_OPTIONAL}, + {TAG_NAMESPACE, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + VOLUME_NAME = 0, + VOLUME_QUOTA = 1, + ENABLED_ATTRIBUTES = 2, + VOLUME_READAHEAD = 3, + MOUNT_POINT = 4, + MOUNT_POINT_RENAME = 5, + NAMESPACE = 6 + }; + + + enum + { + VOLA_YES_NO = 0, + VOLA_NO_YES = 1, + VOLA_SHRED = 2, + }; + + struct + { + utf8_t *tagName; + NINT tagLen; + QUAD modBit; + NINT type; + } + const attrTable [] = + { + {TAG_SALVAGE, 7, zATTR_SALVAGE, VOLA_YES_NO}, + {TAG_COMPRESSION, 11, zATTR_COMPRESSION, VOLA_YES_NO}, + {TAG_DIRECTORYQUOTA, 14, zATTR_DIR_QUOTAS, VOLA_YES_NO}, + {TAG_USERQUOTA, 9, zATTR_USER_SPACE_RESTRICTIONS, VOLA_YES_NO}, + {TAG_FLUSHFILES, 10, zATTR_HIGH_INTEGRITY, VOLA_YES_NO}, + {TAG_CFSMASTER, 9, zATTR_CFS_MASTER, VOLA_YES_NO}, + {TAG_SHREDDING, 9, zATTR_SHRED_DATA, VOLA_SHRED}, + {TAG_MFL, 3, zATTR_MFL, VOLA_YES_NO}, + {TAG_SNAPSHOT, 8, zATTR_COW, VOLA_YES_NO}, + {TAG_BACKUP, 6, zATTR_DONT_BACKUP, VOLA_NO_YES}, + {TAG_MIGRATION, 9, zATTR_MIGRATION, VOLA_YES_NO}, + {TAG_USERTRANSACTION, 15, zATTR_USER_TRANSACTION, VOLA_YES_NO}, + {TAG_VOLUMEHARDLINKS, 15, zATTR_HARD_LINKS, VOLA_YES_NO}, + {TAG_NOACCESSTIME, 12, zATTR_NO_ATIME, VOLA_YES_NO}, + {0}, + }; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* volume name */ + /* Upper case the name. */ + for (i = 0; tagContent[VOLUME_NAME].content[i] != '\0'; i++) + { + tagContent[VOLUME_NAME].content[i] = + toupper(tagContent[VOLUME_NAME].content[i]); + } + + if (utf2uni(tagContent[VOLUME_NAME].content, uniVolName, + sizeof(uniVolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + + info.features.enabled = 0; + info.features.enableModMask = 0; + + /* + * Match the next tag with possible volume attributes. + */ + if ((tagContent[ENABLED_ATTRIBUTES].flags & TR_TAG_FOUND) && + (tagContent[ENABLED_ATTRIBUTES].flags & TR_CONTENT_FOUND)) + { + searchStart = tagContent[ENABLED_ATTRIBUTES].element.dataStart; + while (XML_GetNextTag(searchStart, + tagContent[ENABLED_ATTRIBUTES].element.dataEnd, &parmElement, + &attrTagName, &tagLen) == zOK) + { + searchStart = parmElement.elementEnd + 1; + for(i = 0; attrTable[i].tagName != NULL; i++) + { + if ((tagLen == attrTable[i].tagLen) && + (memcmp(attrTagName, attrTable[i].tagName, tagLen) == 0)) + { /* we have a match */ + if (attrTable[i].type == VOLA_YES_NO || + attrTable[i].type == VOLA_NO_YES) + { /* needs an enabled attribute */ + if (XML_GetTagAttribute(ATR_ENABLED, &parmElement) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, + zERR_XML_IS_BAD, + MSGNot("A tag is missing attribute \""ATR_ENABLED"\"")); + status = zERR_XML_IS_BAD; + goto exit; + } + else + { + modifyInfoMask |= zMOD_VOL_ATTRIBUTES; + bit = attrTable[i].modBit; + if (parmElement.attributeValueLen == 3 && + memcmp(parmElement.attributeValueStart, MSGNot("yes"), 3) == 0) + { + info.features.enableModMask |= bit; + if (attrTable[i].type == VOLA_YES_NO) + { + info.features.enabled |= bit; + } + else + { + info.features.enabled &= ~bit; + } + } + else if (parmElement.attributeValueLen == 2 && + memcmp(parmElement.attributeValueStart, MSGNot("no"), 2) == 0) + { + info.features.enableModMask |= bit; + if (attrTable[i].type == VOLA_YES_NO) + { + info.features.enabled &= ~bit; + } + else + { + info.features.enabled |= bit; + } + } + else + { + MNSS_ReturnResult(virtInfo, tagName, + zERR_XML_IS_BAD, + MSGNot("attribute \""ATR_ENABLED"\" needs a yes/no value")); + status = zERR_XML_IS_BAD; + goto exit; + } + } + } + else if (attrTable[i].type == VOLA_SHRED) + { + if (XML_GetTagAttribute(ATR_COUNT, &parmElement) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, + zERR_XML_IS_BAD, + MSGNot("A tag is missing attribute \""ATR_COUNT"\"")); + status = zERR_XML_IS_BAD; + goto exit; + } + else + { + /* convert the input value to a number */ + modifyInfoMask |= zMOD_VOL_ATTRIBUTES; + *(parmElement.attributeValueEnd + 1) = 0; + count = atol(parmElement.attributeValueStart); + info.features.enableModMask |= zATTR_SHRED_DATA; + if (count > 0) + { + info.features.enabled |= zATTR_SHRED_DATA; + info.dataShreddingCount = count; + modifyInfoMask |= zMOD_VOL_DATA_SHREDDING_COUNT; + } + else + { + info.features.enabled &= ~zATTR_SHRED_DATA; + } + } + } + } + } + } + } + + if (tagContent[VOLUME_QUOTA].flags & TR_TAG_FOUND) + { + if (XML_GetTagAttribute(ATR_QUOTA, &tagContent[VOLUME_QUOTA].element) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("A tag is missing attribute \""ATR_QUOTA"\"")); + status = zERR_XML_IS_BAD; + goto exit; + } + else + { + *(tagContent[VOLUME_QUOTA].element.attributeValueEnd + 1) = 0; + if (stricmp(tagContent[VOLUME_QUOTA].element.attributeValueStart, + MSGNot("none")) == 0) + { + info.totalSpaceQuota = zLV_NO_QUOTA_SIZE; + } + else + { + /* convert the input value to a number */ + info.totalSpaceQuota = + atoq(tagContent[VOLUME_QUOTA].element.attributeValueStart); + } + modifyInfoMask |= zMOD_VOL_QUOTA; + } + } + + + if (tagContent[VOLUME_READAHEAD].flags & TR_TAG_FOUND) + { + if (XML_GetTagAttribute(ATR_READAHEAD, &tagContent[VOLUME_READAHEAD].element) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("A tag is missing attribute \""ATR_READAHEAD"\"")); + status = zERR_XML_IS_BAD; + goto exit; + } + else + { + *(tagContent[VOLUME_READAHEAD].element.attributeValueEnd + 1) = 0; + readAhead = + atoi(tagContent[VOLUME_READAHEAD].element.attributeValueStart); + modifyInfoMask |= zMOD_READ_AHEAD_BLOCKS; + } + } + + if (tagContent[MOUNT_POINT_RENAME].flags & TR_TAG_FOUND) + { + if (XML_GetTagAttribute(ATR_ENABLED, &tagContent[MOUNT_POINT_RENAME].element) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("A tag is missing attribute \""ATR_ENABLED"\"")); + status = zERR_XML_IS_BAD; + goto exit; + } + else + { + renameOptionPtr = &renameOption; + if (tagContent[MOUNT_POINT_RENAME].element.attributeValueLen == 3 && + memcmp(tagContent[MOUNT_POINT_RENAME].element.attributeValueStart, MSGNot("yes"), 3) == 0) + { + renameOption = TRUE; + } + else if (tagContent[MOUNT_POINT_RENAME].element.attributeValueLen == 2 && + memcmp(tagContent[MOUNT_POINT_RENAME].element.attributeValueStart, MSGNot("no"), 2) == 0) + { + renameOption = FALSE; + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("attribute \""ATR_ENABLED"\" needs a yes/no value")); + status = zERR_XML_IS_BAD; + goto exit; + } + } + } + + if (tagContent[NAMESPACE].flags & TR_TAG_FOUND) + { + nameSpacePtr = tagContent[NAMESPACE].content; + } + + if (tagContent[MOUNT_POINT].flags & TR_TAG_FOUND) + { + newMountPointPtr = newMountPoint; + if (tagContent[MOUNT_POINT].content == NULL || + strlen(tagContent[MOUNT_POINT].content) == 0) + { + sprintf(newMountPoint, MSGNot("%s%s"), VOLUME_MOUNT_POINT, + tagContent[VOLUME_NAME].content); + } + else + { + strcpy(newMountPoint, tagContent[MOUNT_POINT].content); + } + } + + if (newMountPointPtr || renameOptionPtr || nameSpacePtr) + { + status = MNSS_ModifyMountPoint(tagContent[VOLUME_NAME].content, + newMountPointPtr, renameOptionPtr, nameSpacePtr); + if(status != zOK) + { + if (status == zERR_CANNOT_UNMOUNT_VOLUME) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error cannot unmount volume to change mount point")); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error setting the mount point or rename option")); + } + goto exit; + } + } + if (newMountPointPtr) + { + + // Fix up the mount point in the directory volume object + status = GetNDSNameFromGUID(uniVolName, objectName); + // If the GUID is not there then build the default name + if (status != zOK) + { + if ((status = MNDS_GetServerNameFromNDS(object, container)) != zOK) + { + holdStatus = status; + holdErrorMsg = "Error Getting Server Name from NDS"; + goto exitMountPoint; + } + strcat(object,"_"); + strcat(object,tagContent[VOLUME_NAME].content); + } + else + { + LB_ParseDSObjectName(objectName, container, object); + } + + status = MNDS_ChangeVolumeMountPointInNDS(container, object, + newMountPointPtr); + if (status != zOK) + { + holdStatus = status; + holdErrorMsg = "Error setting mount point in NDS"; + goto exitMountPoint; + } + } +exitMountPoint: + + /* + * Modify the attributes in the volume + */ + status = ModifyVolumeAttributes(uniVolName, modifyInfoMask, &info, + readAhead, &errIndex); + if (status == zOK) + { + if (holdErrorMsg == NULL) + { + MNSS_ReturnResult(virtInfo, tagName, zOK, XML_SUCCESS); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, holdStatus, holdErrorMsg); + } + } + else + { + MNSS_ReturnResult(virtInfo, tagName, status, + ManageVolumeErrorMessages[errIndex]); + } + +exit: + return zOK; +} + + +/**************************************************************************** + * Add the volume tag and all of its contents. + *****************************************************************************/ + +STATUS AddVolBasicInfo( + VirtInfo_s *virtInfo, + utf8_t *volName, + NINT readAhead, + utf8_t *authModelName, + zInfo_s *info) +{ + STATUS status; + utf8_t tmpStr[zMAX_FULL_NAME]; + utf8_t device[zMAX_FULL_NAME]; + char nameSpace[NAME_SPACE_MAX_SIZE]; + int ccode; + BOOL renameFlag; + char *stateString; + GUID_t *ptrGUID; + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_BASICINFO, FALSE, TRUE)) != zOK) + { + return status; + } + + /* volume name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMENAME, + volName, FALSE)) != zOK) + { + return status; + } + + /* mount point */ + ccode = MNSS_GetMountPoint(volName, TRUE, tmpStr, device, NULL, + &renameFlag, nameSpace); + if (ccode <= 0) + { + MNSS_GetMountPoint(volName, FALSE, tmpStr, device, NULL, + &renameFlag, nameSpace); + } +// sprintf(tmpStr, MSGNot("%s%s"), VOLUME_MOUNT_POINT, volName); + if ((status = VIRT_AddResultElement(virtInfo, TAG_MOUNTPOINT, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* mount point rename */ + if (renameFlag) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_MOUNTPOINTRENAME, + NULL, FALSE)) != zOK) + { + return status; + } + } + + if ((status = VIRT_AddResultElement(virtInfo, TAG_DEVICE, + device, FALSE)) != zOK) + { + return status; + } + + /* pool name */ + GetNSSVolumeHostPool(volName, tmpStr); + if ((status = VIRT_AddResultElement(virtInfo, TAG_POOLNAME, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* NDS volume name */ + if ((status = MNSS_GetNDSNameFromGUID(NULL, &info->vol.ndsObjectID, + tmpStr)) != zOK) + { + tmpStr[0] = 0; + } + if ((status = VIRT_AddResultElement(virtInfo, TAG_NDSVOLUMENAME, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* NDS GUID */ + ptrGUID = (GUID_t *)&info->vol.ndsObjectID; + bzero(tmpStr, sizeof(tmpStr)); + LB_GUIDToString(ptrGUID, sizeof(tmpStr), tmpStr); + if ((status = VIRT_AddResultElement(virtInfo, TAG_NDSVOLUMEGUID, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* NSS GUID */ + ptrGUID = (GUID_t *)&info->vol.volumeID; + bzero(tmpStr, sizeof(tmpStr)); + LB_GUIDToString(ptrGUID, sizeof(tmpStr), tmpStr); + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMEGUID, + tmpStr, FALSE)) != zOK) + { + return status; + } + +//#ifndef __linux__ + /* Owner name */ + if ((status = MNSS_GetNDSNameFromGUID(NULL, &info->id.owner, + tmpStr)) != zOK) + { + tmpStr[0] = 0; + } + if ((status = VIRT_AddResultElement(virtInfo, TAG_OWNER, + tmpStr, FALSE)) != zOK) + { + return status; + } +//#endif + + /* State */ + switch (info->vol.volumeState) + { + case zVOLSTATE_UNKNOWN: + default: + stateString = MSGNot("unknown"); + break; + + case zVOLSTATE_DEACTIVE: + stateString = MSGNot("deactive"); + break; + + case zVOLSTATE_MAINTENANCE: + stateString = MSGNot("maintenance"); + break; + + case zVOLSTATE_ACTIVE: + stateString = MSGNot("active"); + if (IsVolumeMounted(volName)) + { + stateString = MSGNot("mounted"); + } + break; + } + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMESTATE, + stateString, FALSE)) != zOK) + { + return status; + } + + /* Name spaces */ + if ((status = VIRT_AddResultTagForAttribute(virtInfo, TAG_NAMESPACES)) + != zOK) + { + return status; + } + + if (nameSpace[0] != '\0') + { + if ((status = VIRT_AddAttribute(virtInfo, ATR_LOOKUP, nameSpace, FALSE, + FALSE, FALSE)) != zOK) + { + return status; + } + } + + sprintf(tmpStr, MSGNot("%u"), info->vol.nameSpaceMask); + if ((status = VIRT_AddAttribute(virtInfo, ATR_VALUE, tmpStr, TRUE, + FALSE, FALSE)) != zOK) + { + return status; + } + + tmpStr[0] = 0; + if (info->vol.nameSpaceMask & (1 << zNSPACE_DOS)) + { + strcat(tmpStr, MSGNot("DOS ")); + } + if (info->vol.nameSpaceMask & (1 << zNSPACE_LONG)) + { + strcat(tmpStr, MSGNot("Long ")); + } + if (info->vol.nameSpaceMask & (1 << zNSPACE_MAC)) + { + strcat(tmpStr, MSGNot("Macintosh ")); + } + if (info->vol.nameSpaceMask & (1 << zNSPACE_UNIX)) + { + strcat(tmpStr, MSGNot("Unix ")); + } + if (info->vol.nameSpaceMask & (1 << zNSPACE_EXTENDED_ATTRIBUTE)) + { + strcat(tmpStr, MSGNot("ExtendedAttribute ")); + } + if (info->vol.nameSpaceMask & (1 << zNSPACE_DATA_STREAM)) + { + strcat(tmpStr, MSGNot("DataStream ")); + } + if ((status = VIRT_AddResultData(virtInfo, tmpStr)) != zOK) + { + return(status); + } + if ((status = VIRT_AddResultTag(virtInfo, TAG_NAMESPACES, TRUE, TRUE)) != zOK) + { + return(status); + } + + /* FixFixFix - Need to get from get info when this is not the default size. + * Block Size */ +// sprintf(tmpStr, MSGNot("%u"), info->blockSize.size); + sprintf(tmpStr, MSGNot("%u"), DEFAULT_BLOCK_SIZE); + if ((status = VIRT_AddResultElement(virtInfo, TAG_BLOCKSIZE, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Total Quota */ + if (info->vol.totalSpaceQuota == zLV_NO_QUOTA_SIZE) + { + sprintf(tmpStr, MSGNot("none")); + } + else + { + sprintf(tmpStr, MSGNot("%Lu"), info->vol.totalSpaceQuota); + } + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMEQUOTA, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Used space */ + sprintf(tmpStr, MSGNot("%Lu"), info->vol.numUsedBytes); + if ((status = VIRT_AddResultElement(virtInfo, TAG_USEDSIZE, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Number Of Objects */ + sprintf(tmpStr, MSGNot("%Lu"), info->vol.numObjects); + if ((status = VIRT_AddResultElement(virtInfo, TAG_TOTALOBJECTS, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Number Of Files */ + sprintf(tmpStr, MSGNot("%Lu"), info->vol.numFiles); + if ((status = VIRT_AddResultElement(virtInfo, TAG_TOTALFILES, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Created Time */ + if ((status = AddUTCTimeTag(virtInfo, TAG_CREATEDTIME, + (Time_t)(info->time.created))) != zOK) + { + return status; + } + + /* Modified Time */ + if ((status = AddUTCTimeTag(virtInfo, TAG_MODIFIEDTIME, + (Time_t)(info->time.modified))) != zOK) + { + return status; + } + + /* Archived Time */ + if ((status = AddUTCTimeTag(virtInfo, TAG_ARCHIVEDTIME, + (Time_t)(info->time.archived))) != zOK) + { + return status; + } + + /* Read Ahead Blocks */ + sprintf(tmpStr, MSGNot("%u"), readAhead); + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMEREADAHEAD, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* authorization model */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_AUTHORIZATIONMODEL, + authModelName, FALSE)) != zOK) + { + return status; + } + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_BASICINFO, TRUE, TRUE)) != zOK) + { + return status; + } + return(zOK); +} + + +/**************************************************************************** + * Add the tag and all of its contents. + *****************************************************************************/ + +STATUS FillVolAttributeInfo( + VirtInfo_s *virtInfo, + char *tagName, + BOOL supported, + QUAD attributes, + LONG shredCount) +{ + STATUS status; + utf8_t tmpStr[zMAX_COMPONENT_NAME]; + + if ((status = VIRT_AddResultTagForAttribute(virtInfo, tagName)) != zOK) + { + return status; + } + sprintf(tmpStr, MSGNot("%Lu"), attributes); + if ((status = VIRT_AddAttribute(virtInfo, ATR_VALUE, tmpStr, TRUE, + FALSE, FALSE)) != zOK) + { + return status; + } + + if (attributes & zATTR_READONLY) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_READONLY, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zATTR_ENCRYPTED) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMEENCRYPTED, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zATTR_HARD_LINKS) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMEHARDLINKS, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zATTR_SALVAGE) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_SALVAGE, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zATTR_COMPRESSION) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_COMPRESSION, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zATTR_DIR_QUOTAS) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_DIRECTORYQUOTA, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zATTR_USER_SPACE_RESTRICTIONS) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_USERQUOTA, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zATTR_HIGH_INTEGRITY) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_FLUSHFILES, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zATTR_CFS_MASTER) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_CFSMASTER, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zATTR_CFS_SLAVE) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_CFSSLAVE, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zATTR_MFL) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_MFL, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zATTR_COW) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_SNAPSHOT, + NULL, FALSE)) != zOK) + { + return status; + } + } + if ((attributes & zATTR_DONT_BACKUP) == 0) + { + // for default features, if this bit is not set, then backup should + // be enabled + if(strcmp(tagName, TAG_VOLDEFAULTFEATURES) == 0 + || strcmp(tagName, TAG_ENABLEDATTRIBUTES) == 0) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_BACKUP, + NULL, FALSE)) != zOK) + { + return status; + } + } + } + else + { + // for supported features or changeable, if this bit is set, + // then backup should be supported + if(strcmp(tagName, TAG_VOLSUPPORTEDFEATURES) == 0 + || strcmp(tagName, TAG_VOLCHANGEABLEFEATURES) == 0) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_BACKUP, + NULL, FALSE)) != zOK) + { + return status; + } + } + } + if (attributes & zATTR_SHRED_DATA) + { + if (supported) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_SHREDDING, + NULL, FALSE)) != zOK) + { + return status; + } + } + else + { + sprintf(tmpStr, MSGNot("%u"), shredCount); + if ((status = VIRT_AddResultElement(virtInfo, TAG_SHREDDING, + tmpStr, FALSE)) != zOK) + { + return status; + } + } + } + if (attributes & zATTR_USER_TRANSACTION) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_USERTRANSACTION, + NULL, FALSE)) != zOK) + { + return status; + } + } + if (attributes & zATTR_MIGRATION) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_MIGRATION, + NULL, FALSE)) != zOK) + { + return status; + } + } + + { + BOOL noAtime; + noAtime = ((attributes & zATTR_NO_ATIME) != 0)? TRUE : FALSE; + + if (noAtime) + { + if ((status = VIRT_AddResultElement(virtInfo, TAG_NOACCESSTIME, + NULL, FALSE)) != zOK) + { + return status; + } + } + } + + if ((status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE)) != zOK) + { + return(status); + } + return(zOK); +} + + +/**************************************************************************** + * Add the volume tag and all of its contents. + *****************************************************************************/ + +STATUS AddVolAttrInfo( + VirtInfo_s *virtInfo, + zInfo_s *info) +{ + STATUS status; + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_ATTRIBUTEINFO, + FALSE, TRUE)) != zOK) + { + return status; + } + + /* SupportedAttributes */ + if ((status = FillVolAttributeInfo(virtInfo, TAG_SUPPORTEDATTRIBUTES, + TRUE, info->vol.features.supported, 0)) != zOK) + { + return status; + } + + /* EnabledAttributes */ + if ((status = FillVolAttributeInfo(virtInfo, TAG_ENABLEDATTRIBUTES, + FALSE, info->vol.features.enabled, + info->vol.dataShreddingCount)) != zOK) + { + return status; + } + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_ATTRIBUTEINFO, TRUE, TRUE)) != zOK) + { + return status; + } + return(zOK); +} + + +/**************************************************************************** + * Add the volume tag and all of its contents. + *****************************************************************************/ + +STATUS AddVolSalvageInfo( + VirtInfo_s *virtInfo, + zInfo_s *info) +{ + STATUS status; + utf8_t tmpStr[zMAX_COMPONENT_NAME]; + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_SALVAGEINFO, FALSE, TRUE)) != zOK) + { + return status; + } + + /* Purgeable bytes */ + sprintf(tmpStr, MSGNot("%Lu"), info->vol.salvage.purgeableBytes); + if ((status = VIRT_AddResultElement(virtInfo, TAG_FREEABLESIZE, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Non-purgeable bytes */ + sprintf(tmpStr, MSGNot("%Lu"), info->vol.salvage.nonPurgeableBytes); + if ((status = VIRT_AddResultElement(virtInfo, TAG_NONFREEABLESIZE, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Deleted files */ + sprintf(tmpStr, MSGNot("%Lu"), info->vol.salvage.numDeletedFiles); + if ((status = VIRT_AddResultElement(virtInfo, TAG_DELETEDFILES, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Oldest deleted time */ + if ((status = AddUTCTimeTag(virtInfo, TAG_OLDESTDELETEDTIME, + (Time_t)(info->vol.salvage.oldestDeletedTime))) != zOK) + { + return status; + } + + /* Minimum keep seconds */ + sprintf(tmpStr, MSGNot("%u"), info->vol.salvage.minKeepSeconds); + if ((status = VIRT_AddResultElement(virtInfo, TAG_MINKEEPTIME, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Maximum keep seconds */ + sprintf(tmpStr, MSGNot("%u"), info->vol.salvage.maxKeepSeconds); + if ((status = VIRT_AddResultElement(virtInfo, TAG_MAXKEEPTIME, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Low water mark */ + sprintf(tmpStr, MSGNot("%u"), info->vol.salvage.lowWaterMark); + if ((status = VIRT_AddResultElement(virtInfo, TAG_LOWWATERMARK, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* High water mark */ + sprintf(tmpStr, MSGNot("%u"), info->vol.salvage.highWaterMark); + if ((status = VIRT_AddResultElement(virtInfo, TAG_HIGHWATERMARK, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_SALVAGEINFO, TRUE, TRUE)) != zOK) + { + return status; + } + return(zOK); +} + + +/**************************************************************************** + * Add the volume tag and all of its contents. + *****************************************************************************/ + +STATUS AddVolCompressionInfo( + VirtInfo_s *virtInfo, + zInfo_s *info) +{ + STATUS status; + utf8_t tmpStr[zMAX_COMPONENT_NAME]; + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_COMPRESSIONINFO, FALSE, TRUE)) != zOK) + { + return status; + } + + /* Compressed files (Not Deleted) */ + sprintf(tmpStr, MSGNot("%Lu"), info->vol.comp.numCompressedFiles); + if ((status = VIRT_AddResultElement(virtInfo, TAG_COMPRESSEDFILES, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Compressed files (Deleted) */ + sprintf(tmpStr, MSGNot("%Lu"), info->vol.comp.numCompDelFiles); + if ((status = VIRT_AddResultElement(virtInfo, TAG_COMPRESSEDDELETEDFILES, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Uncompressible files */ + sprintf(tmpStr, MSGNot("%Lu"), info->vol.comp.numUncompressibleFiles); + if ((status = VIRT_AddResultElement(virtInfo, TAG_UNCOMPRESSIBLEFILES, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Pre-compressed bytes */ + sprintf(tmpStr, MSGNot("%Lu"), info->vol.comp.numPreCompressedBytes); + if ((status = VIRT_AddResultElement(virtInfo, TAG_PRECOMPRESSIONBYTES, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Compressed bytes */ + sprintf(tmpStr, MSGNot("%Lu"), info->vol.comp.numCompressedBytes); + if ((status = VIRT_AddResultElement(virtInfo, TAG_COMPRESSEDBYTES, + tmpStr, FALSE)) != zOK) + { + return status; + } + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_COMPRESSIONINFO, TRUE, TRUE)) != zOK) + { + return status; + } + return(zOK); +} + + +/**************************************************************************** + * Add the volume tag and all of its contents. + *****************************************************************************/ + +STATUS AddVolDeletedVolumeInfo( + VirtInfo_s *virtInfo, + utf8_t *volumeName, + unicode_t *uni_volName) +{ + STATUS status; + #define BUFSIZE (6*1024) + utf8_t *buf; + NINT retLen; + utf8_t *startTag; + utf8_t *endTag; + + buf = calloc(1, BUFSIZE); + if (buf == NULL) + { + return(zERR_NO_MEMORY); + } + + /* Get an LSS XML Buffer with more data than we care to deal with. + * Then extract out the section. + */ + retLen = 0; /* This is required to be pre-inited by VOL_VOL_CommandFunction */ + if ((status = GetDeletedVolumeLSSInfo(volumeName, uni_volName, + buf, BUFSIZE, &retLen)) != zOK) + { + goto statusExit; + } + + /* Find the start of the tag */ + if ((status = XML_ForwardFindTag(TAG_DELETEDVOLUME, 13, + buf, buf+retLen, &startTag)) != zOK) + { + goto statusExit; + } + ++startTag; /* increment so it points to first char after ending ">" */ + XML_skipWhiteSpace(&startTag, buf+retLen); + + if ((status = XML_BackwardFindEndTag(TAG_DELETEDVOLUME, + buf+retLen+1, startTag, &endTag)) != zOK) + { + goto statusExit; + } + /* endTag points to open "<" of end tag */ + *endTag = 0; + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_DELETEDVOLUMEINFO, FALSE, TRUE)) != zOK) + { + goto statusExit; + } + + status = VIRT_AddResultData(virtInfo, startTag); + if (status != zOK) + { + goto statusExit; + } + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, TAG_DELETEDVOLUMEINFO, TRUE, TRUE)) != zOK) + { + goto statusExit; + } + + free(buf); + return(zOK); + +/*===========================================================================*/ +statusExit: + free(buf); + return(status); +} + + +/**************************************************************************** + * + * This function returns the attributes of a volume + * + ****************************************************************************/ + +STATUS MNSS_ProcessGetVolumeInfo( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_BASICINFO, TR_OPTIONAL}, + {TAG_SALVAGE, TR_OPTIONAL}, + {TAG_COMPRESSION, TR_OPTIONAL}, + {TAG_ATTRIBUTES, TR_OPTIONAL}, + {TAG_DELETEDVOLUME, TR_OPTIONAL}, + {ATR_TYPE, TR_ATTRIBUTE | TR_OPTIONAL}, + {0} + }; + + enum + { + VOLUME_NAME = 0, + BASIC = 1, + SALVAGE = 2, + COMPRESSION = 3, + ATTRIBUTES = 4, + DELETEDVOLUME = 5, + TYPE = 6, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + NINT infoBits = 0; + enum + { + BASIC_INFO = 0x01, + ATTRIBUTES_INFO = 0x02, + COMPRESSION_INFO = 0x04, + SALVAGE_INFO = 0x08, + DELETEDVOLUMES_INFO = 0x10, + }; + + STATUS status; + BOOL isDeleted = FALSE; + NINT readAhead; + NINT errIndex; + zInfo_s info; + utf8_t authModelName[MAX_AUTH_MODEL_NAME_SIZE]; + unicode_t uni_volName[zMAX_COMPONENT_NAME]; + BYTE path[zMAX_FULL_NAME]; + QUAD getInfoMask; + NINT i; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Upper case the name.*/ + for (i = 0; tagContent[VOLUME_NAME].content[i] != '\0'; i++) + { + tagContent[VOLUME_NAME].content[i] = + toupper(tagContent[VOLUME_NAME].content[i]); + } + + /* Change volume name to unicode. */ + if (utf2uni(tagContent[VOLUME_NAME].content, uni_volName, + sizeof(uni_volName)) == -1) + { + goto exit; + } + + if ((status = NSSVolumeFound(uni_volName, TRUE, &isDeleted, &readAhead, NULL, &authModelName[0], NULL)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error finding volume in NSS")); + goto exit; + } + + /* The old method of selecting what to return was a single tag that + * allowed one option to be selected (with all being one option). + * This has been augmented with a tag per option to allow other + * combinations than one or all - see the cases below this tag. */ + if (tagContent[TYPE].flags & TR_TAG_FOUND) + { + if (stricmp(tagContent[TYPE].content, MSGNot("all")) == 0) + { + infoBits = -1; + } + else if (stricmp(tagContent[TYPE].content, MSGNot("basic")) == 0) + { + infoBits |= BASIC_INFO; + } + else if (stricmp(tagContent[TYPE].content, MSGNot("salvage")) == 0) + { + infoBits |= SALVAGE_INFO; + } + else if (stricmp(tagContent[TYPE].content, MSGNot("compression")) == 0) + { + infoBits |= COMPRESSION_INFO; + } + else if (stricmp(tagContent[TYPE].content, MSGNot("attributes")) == 0) + { + infoBits |= ATTRIBUTES_INFO; + } + else if (stricmp(tagContent[TYPE].content, MSGNot("deletedVolume")) == 0) + { + infoBits |= DELETEDVOLUMES_INFO; + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Invalid info type specified")); + goto exit; + } + } + + /* Allow individual options to be selected one at a time to create + * combinations. + * NB: Due to the need to support the previous functionality this + * actually results in obtaining the sum of both sets, based + * and individual item based */ + if (tagContent[BASIC].flags & TR_TAG_FOUND) + { + infoBits |= BASIC_INFO; + } + if (tagContent[SALVAGE].flags & TR_TAG_FOUND) + { + infoBits |= SALVAGE_INFO; + } + if (tagContent[COMPRESSION].flags & TR_TAG_FOUND) + { + infoBits |= COMPRESSION_INFO; + } + if (tagContent[ATTRIBUTES].flags & TR_TAG_FOUND) + { + infoBits |= ATTRIBUTES_INFO; + } + if (tagContent[DELETEDVOLUME].flags & TR_TAG_FOUND) + { + infoBits |= DELETEDVOLUMES_INFO; + } + + /* If nothing was selected assume everything */ + if (!infoBits) + { + infoBits = -1; + } + + sprintf((char *)path, "%s%s", ADMIN_VOL_PATH, + tagContent[VOLUME_NAME].content); + getInfoMask = zGET_TIMES_IN_SECS | zGET_IDS | zGET_VOLUME_INFO | + zGET_POOL_INFO | zGET_VOL_SALVAGE_INFO; + + if ((status = GetZInfo(path, getInfoMask, &info, &errIndex)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + ManageVolumeErrorMessages[errIndex]); + goto exit; + } + + /* Basic Volume Information */ + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto statusExit; + } + + /* Add the basic information */ + if (infoBits & BASIC_INFO) + { + if ((status = AddVolBasicInfo(virtInfo, + tagContent[VOLUME_NAME].content, readAhead, + authModelName, &info)) != zOK) + { + goto statusExit; + } + } + + /* Add the attribute information */ + if (infoBits & ATTRIBUTES_INFO) + { + if ((status = AddVolAttrInfo(virtInfo, &info)) != zOK) + { + goto statusExit; + } + } + + /* Add the salvage information */ + if (infoBits & SALVAGE_INFO) + { + if ((status = AddVolSalvageInfo(virtInfo, &info)) != zOK) + { + goto statusExit; + } + } + + /* Add the compression information */ + if (infoBits & COMPRESSION_INFO) + { + if ((status = AddVolCompressionInfo(virtInfo, &info)) != zOK) + { + goto statusExit; + } + } + + /* Add the deletedVolume information */ + if (infoBits & DELETEDVOLUMES_INFO) + { + /* Only return this info if the volume is deleted. */ + if (isDeleted) + { + if ((status = AddVolDeletedVolumeInfo(virtInfo, + tagContent[VOLUME_NAME].content, uni_volName)) != zOK) + { + goto statusExit; + } + } + } + + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE)) != zOK) + { + goto statusExit; + } + +exit: + return zOK; + +/*===========================================================================*/ +statusExit: + return(status); +} + + +/**************************************************************************** + * + * This function removes a volume. + * + ****************************************************************************/ +STATUS MNSS_RemoveVolume( + utf8_t *volumeName, + BOOL removeNDSObject, + BOOL updateVLDB, + utf8_t **returnMsg, + BOOL lazyUmount) +{ + NINT i; + BOOL volumeIsNSS; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + utf8_t objectName[256]; + utf8_t container[256]; + utf8_t object[256]; + STATUS status = zFAILURE; + STATUS vldbStatus = zOK; + char *errText=NULL; + GUID_t dfsGUID; + + *returnMsg = NULL; + + /* Upper case the name */ + for (i = 0; volumeName[i] != '\0'; i++) + { + volumeName[i] = toupper(volumeName[i]); + } + + /* volume name to unicode */ + if (utf2uni(volumeName, uniVolName, sizeof(uniVolName)) == -1) + { + status = zERR_INVALID_UTF8_CHAR; + *returnMsg = MSGNot("Error converting volume name to unicode"); + goto exit; + } + + if ((status = NSSVolumeFound(uniVolName, FALSE, NULL, NULL, NULL, NULL, NULL)) == zOK) + { + volumeIsNSS = TRUE; + } + else + { + volumeIsNSS = FALSE; + } + + /* + * Remove the NDS object if requested + */ + if (removeNDSObject) + { + if (volumeIsNSS) + { + status = GetNDSNameFromGUID(uniVolName, objectName); + } + else + { + /* We don't have a GUID, so force us to use a default name */ + status = zFAILURE; + } + + if (status != zOK) + { + if ((status = MNDS_GetServerNameFromNDS(object, container)) != zOK) + { + *returnMsg = MSGNot("Error Getting Server Name from NDS"); + goto justRemoveVolume; + } + strcat(object,"_"); + strcat(object,volumeName); + } + else + { + LB_ParseDSObjectName(objectName, container, object); + } + status = MNDS_RemoveObjectFromNDS(container, object, "Volume"); + + if (status != zOK) + { + *returnMsg = MSGNot("Error removing volume from NDS"); + goto justRemoveVolume; + } + } + +justRemoveVolume: + if (updateVLDB) + { + /* Remove this volume from the VLDB */ + if ((vldbStatus = VOLMNGetDFSGuid(uniVolName, &dfsGUID)) == zOK) + { + if ((vldbStatus = RemoveVolumeFromVLDB(&dfsGUID, &errText)) != zOK) + { + if (vldbStatus == VLDB_ERR_ENTRY_NOT_FOUND) + { + /* This server does not have a DFS Management Context */ + vldbStatus = zOK; + } + } + } + else + { + /* DEFECT000337144: Highly likely the DFS GUID was never set. */ + /* Just ignore the error. Worst case is that user will have to */ + /* run a VLDB REPAIR */ + vldbStatus = zOK; + } + } + /* + * Remove the actual volume + */ + if (volumeIsNSS) + { + /* If you don't dismount the volume first, the mount point can't be + read, written or deleted after the volume is deleted */ + char mountPoint[MOUNT_POINT_MAX_SIZE]; + int ccode; + + mountPoint[0] = '\0'; + ccode = MNSS_GetMountPoint(volumeName, TRUE, + mountPoint, NULL, NULL, NULL, NULL); + if(ccode > 0) + { + status = DismountVolume(volumeName, lazyUmount); + if (status != zOK) + { + *returnMsg = MSGNot("Error dismounting volume"); + goto exit; + } + } + + status = RemoveNSSVolume(uniVolName); + if (status != zOK) + { + *returnMsg = MSGNot("Error deleting volume"); + goto exit; + } + + /* + * If the mount point was found from mtab, it will be sent. + * Else, an empty string will be sent. + */ + status = MNSS_RemoveMountPoint(volumeName, mountPoint); + if (status != zOK) + { + *returnMsg = MSGNot("Error deleting mount point"); + goto exit; + } + + } + else + { +#ifndef __linux__ + ZMM_ObjectControl(status, + LEGACYAPPid, + MM_VOLUME_DELETE, + 0, + 0, + 0, + LB_strlen(volumeName), + volumeName); + if (status != zOK) + { + *returnMsg = MSGNot("Error deleting volume"); + goto exit; + } +#endif + } + + if (vldbStatus != zOK) + { + status = vldbStatus; + *returnMsg = errText; + goto exit; + } + status = zOK; + +exit: + return status; +} + +/**************************************************************************** + * + * This function removes a volume. + * + ****************************************************************************/ + +STATUS MNSS_ProcessRemoveVolume( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_DONTREMOVENDSOBJECT, TR_OPTIONAL}, + {TAG_UPDATEVLDB, TR_OPTIONAL}, + {0} + }; + + enum + { + VOLUME_NAME = 0, + DONT_REMOVE_NDS_OBJECT = 1, + UPDATE_VLDB = 2 + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + utf8_t *returnMsg; + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + return zOK; + } + return status; + } + +#ifndef __linux__ + MNSS_LoadAppIDs(); +#endif + + if ((status = MNSS_RemoveVolume(tagContent[VOLUME_NAME].content, + !(tagContent[DONT_REMOVE_NDS_OBJECT].flags & TR_TAG_FOUND), + tagContent[UPDATE_VLDB].flags & TR_TAG_FOUND, + &returnMsg, FALSE)) != zOK) + { + if (returnMsg != NULL) + { + MNSS_ReturnResult(virtInfo, tagName, status, returnMsg); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error removing a volume")); + } + } + else + { + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + } + return zOK; +} + + +/**************************************************************************** + * + * This function renames a volume. + * + ****************************************************************************/ + +STATUS MNSS_ProcessRenameVolume( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_NEWVOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_NEWNDSNAME, TR_OPTIONAL}, + {TAG_DONTRENAMENDSOBJECT, TR_OPTIONAL}, + {TAG_UPDATEVLDB, TR_OPTIONAL}, + {0} + }; + + enum + { + VOLUME_NAME = 0, + NEW_VOLUME_NAME = 1, + NEW_NDS_NAME = 2, + DONT_RENAME_NDS_OBJECT = 3, + UPDATE_VLDB = 4 + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + NINT i; + STATUS status; + STATUS vldbStatus = zOK; + char *errText=NULL; + BOOL volumeIsNSS; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + unicode_t uniNewName[zMAX_COMPONENT_NAME]; + GUID_t dfsGUID; + utf8_t objectName[256]; + utf8_t container[256]; + utf8_t object[256]; + + ASSERT_MPKNSS_LOCK(); + + syslog(LOG_INFO,"Volume rename request via XML\n"); + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + +#ifndef __linux__ + MNSS_LoadAppIDs(); +#endif + + /* Upper case the names */ + for (i = 0; tagContent[VOLUME_NAME].content[i] != '\0'; i++) + { + tagContent[VOLUME_NAME].content[i] = + toupper(tagContent[VOLUME_NAME].content[i]); + } + for (i = 0; tagContent[NEW_VOLUME_NAME].content[i] != '\0'; i++) + { + tagContent[NEW_VOLUME_NAME].content[i] = + toupper(tagContent[NEW_VOLUME_NAME].content[i]); + } + + /* volume names to unicode */ + if (utf2uni(tagContent[VOLUME_NAME].content, uniVolName, + sizeof(uniVolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting source volume name to unicode")); + goto exit; + } + if (utf2uni(tagContent[NEW_VOLUME_NAME].content, + uniNewName, sizeof(uniNewName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting destination volume name to unicode")); + goto exit; + } + + if ((status = LB_VolumeNameAcceptable(uniNewName)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid target volume name")); + goto exit; + } + + if ((status = NSSVolumeFound(uniVolName, FALSE, NULL, NULL, NULL, NULL, NULL)) == zOK) + { + volumeIsNSS = TRUE; + } + else + { + volumeIsNSS = FALSE; + } + + /* + * Rename the actual volume + */ + if (volumeIsNSS) + { + status = RenameNSSVolume(uniVolName, uniNewName); + } + else + { + } + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error renaming volume")); + goto exit; + } + + status = MNSS_RenameMountPoint(tagContent[VOLUME_NAME].content, + tagContent[NEW_VOLUME_NAME].content); + + if (status != zOK) + { + (void)RenameNSSVolume(uniNewName, uniVolName); + if (status == zERR_CANNOT_UNMOUNT_VOLUME) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error cannot unmount volume to rename it")); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error renaming volume mount point")); + } + goto exit; + } + + /* + * Rename the NDS object if requested + */ + if (!(tagContent[DONT_RENAME_NDS_OBJECT].flags & TR_TAG_FOUND)) + { + if (!(tagContent[NEW_NDS_NAME].flags & TR_TAG_FOUND)) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Missing new NDS name")); + goto exit; + } + + if (volumeIsNSS) + { /* May 2007 - Bugzilla 270736 + We must use the new name of volume because the + volume has already been renamed to it by now. + */ + status = GetNDSNameFromGUID(uniNewName, objectName); + } + else + { + /* We don't have a GUID, so force us to use a default name */ + status = zFAILURE; + } + + if (status != zOK) + { + if ((status = MNDS_GetServerNameFromNDS(object, container)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error Getting Server Name from NDS")); + goto exit; + } + strcat(object,"_"); + strcat(object,tagContent[VOLUME_NAME].content); + syslog(LOG_NOTICE, " Volume rename (current eDIR Name) - %s\n", object); + } + else + { + LB_ParseDSObjectName(objectName, container, object); + syslog(LOG_NOTICE, " Volume rename (current eDIR Name from eDIR GUID) - %s\n", object); + } + status = MNDS_RenameVolumeInNDS(virtInfo, container, object, + tagContent[VOLUME_NAME].content, + tagContent[NEW_NDS_NAME].content, + tagContent[NEW_VOLUME_NAME].content); + + if (status != zOK) + { + syslog(LOG_NOTICE, " Volume rename (eDIR rename failed) - %s\n", container); + syslog(LOG_NOTICE, " Volume rename (eDIR rename failed) - %s\n", object); + syslog(LOG_NOTICE, " Volume rename (eDIR rename failed) - %s\n", tagContent[VOLUME_NAME].content); + syslog(LOG_NOTICE, " Volume rename (eDIR rename failed) - %s\n", tagContent[NEW_NDS_NAME].content); + syslog(LOG_NOTICE, " Volume rename (eDIR rename failed) - %s\n", tagContent[NEW_VOLUME_NAME].content); + syslog(LOG_NOTICE, " Volume rename (eDIR rename failed) - %d\n", status); + + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error renaming volume in NDS")); + goto exit; + } + } + + /* Conditional commented out because ConsoleOne does not update the VLDB */ + /* so we fix that bug by always updating. */ + /* Note that the flag was added to provide backward compatibility + with ConsoleOne */ +// if (tagContext[UPDATE_VLDB].flags & TR_TAG_FOUND) + { + /* Update this volume's VLDB entry */ + /* We have to remove the old entry first because of the restriction */ + /* that there cannot be more than one instance of a volume on a */ + /* single server - should look into whether that restriction is */ + /* really necessary */ + /* May 2007 - Bugzilla 270736 + We must use the new name of volume because the + volume has already been renamed to it by now. + */ + if ((vldbStatus = VOLMNGetDFSGuid(uniNewName, &dfsGUID)) == zOK) + { + syslog(LOG_INFO," Volume rename - VLDB being updated.\n"); + /* RemoveVolumeServer (old volume name) */ + if ((vldbStatus = RemoveVolumeServerFromVLDB(&dfsGUID, NULL, uniVolName, &errText)) != zOK) + { + if (vldbStatus == VLDB_ERR_ENTRY_NOT_FOUND) + { + /* This server does not have a DFS Management Context */ + vldbStatus = zOK; + } + else + { + syslog(LOG_ERR, " Volume rename - VLDB updation failed. You might need to run VLDB repair. "); + + } + } + /* AddVolumeServer (new volume name) */ + if ((vldbStatus = AddVolumeServerToVLDB(&dfsGUID, NULL, uniNewName, &errText)) != zOK) + { + if (vldbStatus == VLDB_ERR_ENTRY_NOT_FOUND) + { + /* This server does not have a DFS Management Context */ + vldbStatus = zOK; + } + else + { + syslog(LOG_ERR, " Volume rename - VLDB updation failed. You might need to run VLDB repair. "); + + } + } + } + else + { + syslog(LOG_WARNING," Volume rename - Unable to obtain DFS GUID (%d).", vldbStatus ); + syslog(LOG_WARNING," VLDB not updated to reflect new volume name."); + /* DEFECT000337144: Highly likely the DFS GUID was never set. */ + /* Just ignore the error. Worst case is that user will have to */ + /* run a VLDB REPAIR */ + vldbStatus = zOK; + } + } + + if (vldbStatus == zOK) + { + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, vldbStatus, errText); + } + goto exit; + +exit: + return zOK; +} + + +/**************************************************************************** + * + * This function returns the state of a volume. + * + ****************************************************************************/ + +STATUS MNSS_ProcessGetVolumeState( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + TagContent_s tagContent[2]; + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + VOLUME_NAME = 0, + }; + + STATUS status; + BOOL volumeIsNSS; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + char lpVolName[zMAX_COMPONENT_NAME]; + NINT volumeState; + BOOL volumeMounted; + char *stateString; + NINT idx; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Upper case the name */ + for (idx = 0; tagContent[VOLUME_NAME].content[idx] != '\0'; idx++) + { + tagContent[VOLUME_NAME].content[idx] = + toupper(tagContent[VOLUME_NAME].content[idx]); + } + + /* volume name to Length Preceeded ASCII */ + lpVolName[0] = strlen(tagContent[VOLUME_NAME].content); + strcpy(&lpVolName[1],tagContent[VOLUME_NAME].content); + + /* volume name to unicode */ + if (utf2uni(tagContent[VOLUME_NAME].content, uniVolName, + sizeof(uniVolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + + + if (NSSVolumeFound(uniVolName, FALSE, NULL, NULL, &volumeState, NULL, NULL) == zOK) + { + volumeIsNSS = TRUE; + } + else + { + volumeIsNSS = FALSE; + volumeState = 0; + } + + volumeMounted = IsVolumeMounted(tagContent[VOLUME_NAME].content); + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + return status; + } + + /* volume name */ + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMENAME, + tagContent[VOLUME_NAME].content, FALSE)) != zOK) + { + return status; + } + + /* volume state */ + if (volumeMounted) + { + stateString = MSGNot("mounted"); + } + else if (!volumeIsNSS) + { + stateString = MSGNot("dismounted"); + } + else /* is NSS and not mounted */ + { + switch (volumeState) + { + case zVOLSTATE_UNKNOWN: + default: + stateString = MSGNot("unknown"); + break; + + case zVOLSTATE_DEACTIVE: + stateString = MSGNot("deactive"); + break; + + case zVOLSTATE_MAINTENANCE: + stateString = MSGNot("maintenance"); + break; + + case zVOLSTATE_ACTIVE: + stateString = MSGNot("active"); + break; + } + } + if ((status = VIRT_AddResultElement(virtInfo, TAG_VOLUMESTATE, + stateString, FALSE)) != zOK) + { + return status; + } + + /* Add a result tag */ + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + + /* Add the closing tag */ + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + return zOK; +} + + +/**************************************************************************** + * + * This function gets the NDS name for a volume. + * + ****************************************************************************/ + +STATUS MNSS_GetVolumeNDSName( + utf8_t *volName, + utf8_t *ndsVolName, + utf8_t *ndsContainer, + UserID_t *volNameGUID, + utf8_t **errorString) +{ + STATUS status; + unicode_t uni_volName[zMAX_COMPONENT_NAME]; + utf8_t objectName[MAX_DN_CHARS]; + NINT i; + + *ndsVolName = '\0'; + *ndsContainer = '\0'; + + /* Upper case the name */ + for (i = 0; volName[i] != '\0'; i++) + { + volName[i] = toupper(volName[i]); + } + + /* vol name to unicode */ + if (utf2uni(volName, uni_volName, sizeof(uni_volName)) == -1) + { + *errorString = MSGNot("Error converting volume name to unicode"); + return zERR_INVALID_UTF8_CHAR; + } + + if ((status = NSSVolumeFound(uni_volName, FALSE, NULL, NULL, NULL, NULL, volNameGUID)) != zOK) + { + *errorString = MSGNot("Error finding volume in NSS"); + return (status); + } + + if ((status = GetNDSNameFromGUID(uni_volName, objectName)) + != zOK) + { + *errorString = MSGNot("Error converting GUID to name"); + return status; + } + + LB_ParseDSObjectName(objectName, ndsContainer, ndsVolName); + return zOK; +} + + +/**************************************************************************** + * + * This function process a request to get the NDS name for a volume. + * + ****************************************************************************/ + +STATUS MNSS_ProcessGetVolumeNDSName( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + TagContent_s tagContent[1]; + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + VOL_NAME = 0, + }; + + STATUS status; + utf8_t container[MAX_DN_CHARS]; + utf8_t object[MAX_DN_CHARS]; + utf8_t *errorString; + UserID_t guid; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + if ((status = MNSS_GetVolumeNDSName(tagContent[VOL_NAME].content, + object, container, &guid, &errorString)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, errorString); + goto exit; + } + + VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE); + + if ((status = VIRT_AddResultElement(virtInfo, TAG_NDSNAME, object, + FALSE)) != zOK) + { + return status; + } + + if ((status = VIRT_AddResultElement(virtInfo, TAG_CONTEXT, container, + FALSE)) != zOK) + { + return status; + } + + MNSS_BuildResult(virtInfo, 0, XML_SUCCESS); + VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + return zOK; +} + + +/**************************************************************************** + * + * This function modifies the state of a volume. + * + ****************************************************************************/ + +STATUS MNSS_ProcessModifyVolumeState( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ +#define MAX_MOUNT_OPTIONS 512 + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_VOLUMESTATE, TR_CONTENT_REQUIRED}, + {TAG_VOLUMEPASSWORD, TR_OPTIONAL}, + {TAG_MOUNTOPTIONS, TR_OPTIONAL}, + {TAG_FROMNCP, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + VOLUME_NAME = 0, + VOLUME_STATE = 1, + VOLUME_PASSWORD = 2, + MOUNT_OPTIONS = 3, + FROM_NCP = 4, + }; + + STATUS status; + BOOL volumeIsNSS; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + char lpVolName[zMAX_COMPONENT_NAME]; + BOOL mountVolume; + BOOL volumeIsMounted; + BOOL activateVolume; + BOOL fromNCP = FALSE; + NINT idx; + NINT errIndex; + utf8_t poolName[zMAX_FULL_NAME]; + utf8_t mountOptions[MAX_MOUNT_OPTIONS]; + char mountPoint[MOUNT_POINT_MAX_SIZE]; + POOLSNAP_TYPE poolType; + BOOL removeMountPoint = FALSE; + + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Upper case the name */ + for (idx = 0; tagContent[VOLUME_NAME].content[idx] != '\0'; idx++) + { + tagContent[VOLUME_NAME].content[idx] = + toupper(tagContent[VOLUME_NAME].content[idx]); + } + + /* volume name to Length Preceeded ASCII */ + lpVolName[0] = strlen(tagContent[VOLUME_NAME].content); + strcpy(&lpVolName[1],tagContent[VOLUME_NAME].content); + + /* volume name to unicode */ + if (utf2uni(tagContent[VOLUME_NAME].content, uniVolName, + sizeof(uniVolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + + /* Get current Activated state */ + if (NSSVolumeFound(uniVolName, FALSE, NULL, NULL, NULL, NULL, NULL) == zOK) + { + volumeIsNSS = TRUE; + } + else + { + volumeIsNSS = FALSE; + } + + /* Get current Mounted state */ + volumeIsMounted = FALSE; + volumeIsMounted = IsVolumeMounted(tagContent[VOLUME_NAME].content); + + /* Process requested state */ + if (strcmp(tagContent[VOLUME_STATE].content, MSGNot("mounted")) == 0) + { + activateVolume = TRUE; + mountVolume = TRUE; + } + else if (strcmp(tagContent[VOLUME_STATE].content, MSGNot("dismounted")) == 0) + { + activateVolume = TRUE; + mountVolume = FALSE; + } + else if ((strcmp(tagContent[VOLUME_STATE].content, MSGNot("active")) == 0) && + (volumeIsNSS)) + { + activateVolume = TRUE; + mountVolume = FALSE; + } + else if ((strcmp(tagContent[VOLUME_STATE].content, MSGNot("deactive")) == 0) && + (volumeIsNSS)) + { + activateVolume = FALSE; + mountVolume = FALSE; + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Unsupported volume state value")); + goto exit; + } + + if (mountVolume && (tagContent[MOUNT_OPTIONS].flags & TR_TAG_FOUND)) + { + if (strlen(tagContent[MOUNT_OPTIONS].content) >= MAX_MOUNT_OPTIONS) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Options too long")); + goto exit; + } + strcpy(mountOptions, tagContent[MOUNT_OPTIONS].content); + } + else + { + mountOptions[0] = '\0'; + } + + fromNCP = (tagContent[FROM_NCP].flags & TR_TAG_FOUND) ? TRUE : FALSE; + if (fromNCP) + { + syslog(LOG_INFO, "Volume state change request for %s from NCP\n", + tagContent[VOLUME_NAME].content); + } + else + { + syslog(LOG_INFO, "Volume state change request for %s not from NCP\n", + tagContent[VOLUME_NAME].content); + } + + /* Change the volume activation state */ + status = ChangeVolumeState(uniVolName, + activateVolume, + tagContent[VOLUME_PASSWORD].content, + &errIndex); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + ManageVolumeErrorMessages[errIndex]); + goto exit; + } + + if(mountVolume) + { + if(!volumeIsMounted) + { + if((status = MountVolume(tagContent[VOLUME_NAME].content, + !fromNCP, mountOptions)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unsuccessful in mounting the volume")); + goto exit; + } + + /* pool name */ + if(GetNSSVolumeHostPool(tagContent[VOLUME_NAME].content, + poolName) != zOK) + { + poolName[0] = '\0'; + } + + MNSS_AddMountPoint(poolName, tagContent[VOLUME_NAME].content, + NULL, TRUE, NULL); + } + } + else + { + if(volumeIsMounted) + { + /* + * If the volume belongs to snapshot pool, mount point should + * also be cleared from the file system. + * Also, ignoring the errors to proceed with dismount. + */ + status = GetNSSVolumeHostPool(tagContent[VOLUME_NAME].content, + poolName); + + if(status == zOK) + { + if((status = LINUX_GetPoolSnapshotType(TRUE, poolName, + &poolType)) == zOK) + { + if(poolType == POOL_SNAPSHOT) + { + if(MNSS_GetMountPoint( + tagContent[VOLUME_NAME].content, TRUE, + mountPoint, NULL, NULL, + NULL, NULL) > 0) + { + removeMountPoint = TRUE ; + } + } + } + } + + if((status = DismountVolume(tagContent[VOLUME_NAME].content, + !activateVolume)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Unsuccessful in dismounting the volume")); + goto exit; + } + + if(removeMountPoint == TRUE) + { + (void)RemoveMountPoint(mountPoint); + } + } + } + + /* Change the volume mount state */ + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + +exit: + return zOK; +} + + +/**************************************************************************** + * + * This function executes a Linux command + * + ****************************************************************************/ +int executeCommand( + char *path, + char *argv[]) +{ + pid_t pid; + int status; + int rc; + + /* Fork and execute the command */ + switch (pid = fork()) + { + case -1: + { + return -1; + } + case 0: + { + execv(path, argv); + /* only gets to here if there is an error */ + _exit(-1); + } + } + rc = wait(&status); + if (rc < 0) + { + return rc; + } + else + { + if (WIFEXITED(status)) + { + return WEXITSTATUS(status); + } + else + { + return -1; + } + } +} + +#if 0 +//this has never been debugged +/**************************************************************************** + * + * This function takes a path and returns the last component and the rest of + * the path. + * + ****************************************************************************/ +void GetNameAndPath( + utf8_t *fullPath, + utf8_t *name, + utf8_t *newPath) +{ + char *seperatorPtr; + int len = strlen(fullPath); + char holdChar = '\0'; + int newPathLen; + +//printf("Full path=%s\n", fullPath); + if (fullPath[len-1] == '/') + { + holdChar = fullPath[len-1]; + fullPath[len-1] = 0; + } + + seperatorPtr = strrchr(fullPath, '/'); + if (seperatorPtr) + { + if (newPath) + { + newPathLen = seperatorPtr - newPath; + memcpy(newPath, fullPath, newPathLen); + newPath[newPathLen] = '\0'; + } + if (name) + { + strcpy(name, seperatorPtr+1); + } + } + else + { + if (newPath) + { + newPath[0] = '\0'; + } + if (name) + { + strcpy(name, fullPath); + } + } + + if (holdChar != '\0') + { + fullPath[len-1] = holdChar; + } + +//if (name)printf(NAME_OPTION"=%s\n", name); +//if (newPath)printf("New path=%s\n", newPath); + return; +} +#endif + +/**************************************************************************** + * + * This function mounts a volume + * + ****************************************************************************/ +int MountVolume( + utf8_t *volName, + BOOL notifyNCP, + utf8_t *options) +{ + STATUS status; + int ccode; + BOOL renameMP; + char *parms[8]; + char sMountPoint[MOUNT_POINT_MAX_SIZE]; + char sNameSpace[NAME_SPACE_MAX_SIZE]; + char sDevice[1024]; + char sName[1024]; + char sOptions[1024]; + + syslog(LOG_INFO, "mounting volume %s with extra options %s\n", + volName, options); +//printf("MountVolume %s.\n", volName); + sNameSpace[0] = '\0'; + strcpy(sOptions, "-o"); + strcat(sOptions, NAME_OPTION"="); + ccode = MNSS_GetMountPoint(volName, FALSE, sMountPoint, sDevice, sName, + &renameMP, sNameSpace); + if (ccode <= 0) + { +//printf("MountVolume. Mount point not found in fstab\n"); + sprintf(sMountPoint, MSGNot("%s%s"), VOLUME_MOUNT_POINT, volName); + strcpy(sDevice, volName); + strcat(sOptions, volName); + } + else + { + strcat(sOptions, sName); + } + if (!renameMP) + { + strcat(sOptions, ","NORENAME_OPTION); + } + if (sNameSpace[0] != '\0') + { + strcat(sOptions, ","NAMESPACE_OPTION"="); + strcat(sOptions, sNameSpace); + } + if (options != NULL && options[0] != '\0') + { + strcat(sOptions, ","); + strcat(sOptions, options); + } + + MNSS_CreateDirs(sMountPoint); + errno = 0; + parms[0] = "mount"; + parms[1] = "-t"; + parms[2] = "nssvol"; + parms[3] = sDevice; + parms[4] = sMountPoint; + //parms[5] = "-o "; + parms[5] = sOptions; + parms[6] = NULL; + if ((status = executeCommand("/bin/mount", parms)) != 0) + { +/* syslog(LOG_INFO, "Failed to mount %s.\n", mountPoint); */ +//printf("MountVolume. err %m returned from mount\n"); + return status; + } + + // Let the NCP server know that the volume needs to be mounted + // so it can be added to its tables. + if (notifyNCP) + { + IPCAddNSSVolume(volName); + } + + return 0; +} + +/**************************************************************************** + * + * This function unmounts a volume by volume name + * + ****************************************************************************/ +int DismountVolume( + utf8_t *volName, + BOOL lazyUmount) +{ + int status; + int index; + char *parms[4]; + char mountPoint[MOUNT_POINT_MAX_SIZE]; + + syslog(LOG_INFO, "umounting volume %s lazy=%d\n", volName, lazyUmount); + // Let the NCP server know that the volume needs to be dismounted + // so it can be removed from its tables. If it is not removed then the + // volume will have a use count on it. + IPCRemoveNSSVolume(volName); + + status = MNSS_GetMountPoint(volName, TRUE, mountPoint, NULL, NULL, NULL, + NULL); + if (status <= 0) + { + return zERR_VOLUME_NOT_MOUNTED; + } + + errno = 0; + index = 0; + parms[index++] = "umount"; + if (lazyUmount) + { + parms[index++] = "-l"; + } + parms[index++] = mountPoint; + parms[index] = NULL; + if ((status = executeCommand("/bin/umount", parms)) != 0) + { + //syslog(LOG_INFO, "Failed to dismount %s. Lazy=%d Status=%d\n", mountPoint, lazyUmount, status); + + // Tell NCP server to remount the volume because we could not + // dismount it + IPCAddNSSVolume(volName); + return status; + } + return 0; +} + +/**************************************************************************** + * + * Remove the mount point for a volume + * + ****************************************************************************/ +STATUS RemoveMountPoint(utf8_t *mountPoint) +{ + STATUS status; + + errno = 0; + if((status = rmdir(mountPoint)) != 0) + { + if (errno != ENOENT) + { + syslog(LOG_INFO, "Failed to delete the directory %s. Error=%d(%m)\n", mountPoint, errno); + return errno; + } + } + return 0; +} + +/**************************************************************************** + * + * Rename the mount point. + * + ****************************************************************************/ +STATUS RenameMountPoint( + utf8_t *volName, + utf8_t *newVolName, + utf8_t *oldMountPoint, + utf8_t *newMountPoint, + BOOL mounted) +{ + STATUS dismountStatus = 0; + STATUS status; + +//printf("Entering RenameMountPoint. vol:%s newvol:%s old:%s new:%s\n", volName, newVolName, oldMountPoint, newMountPoint); + if (mounted) + { + dismountStatus = DismountVolume(volName, TRUE); + } + /* rename */ + if ((status = rename(oldMountPoint, newMountPoint)) != 0) + { +//printf("RenameMountPoint. Error renaming mount point = %d\n", errno); + return errno; + } + + /* mount the renamed volume */ + if(mounted && dismountStatus == 0) + { + status = MountVolume(newVolName, TRUE, NULL); + } + return status; +} + +/**************************************************************************** + * + * This function processes a deletedVolumeAction request + * + ****************************************************************************/ + +STATUS ProcessDeletedVolumeAction( + utf8_t *tagName, + VirtInfo_s *virtInfo, + utf8_t *volName, + deletedVolumeAction_t action) +{ + NINT idx; + STATUS status; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + + ASSERT_MPKNSS_LOCK(); + + /* Upper case the name */ + for (idx = 0; volName[idx] != '\0'; idx++) + { + volName[idx] = toupper(volName[idx]); + } + + /* volume name to unicode */ + if (utf2uni(volName, uniVolName, sizeof(uniVolName)) == -1) + { + status = zERR_INVALID_UTF8_CHAR; + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + + if ((status = NSSVolumeFound(uniVolName, TRUE, NULL, NULL, NULL, NULL, NULL)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Unable to locate the deleted volume")); + goto exit; + } + + /* + * Perform the deleted volume action + */ + status = PerformDeletedVolumeAction(uniVolName, action); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error performing deleted volume action")); + goto exit; + } + status = zOK; + + /* The release was done by VOL_commandFunction */ +exit: + return(status); +} + + +/**************************************************************************** + * + * This function salvages a deleted logical volume + * + ****************************************************************************/ + +STATUS MNSS_ProcessSalvageVolume( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + enum + { + MNSS_NO_VOL_STATE_CHANGE, + MNSS_VOL_STATE_ACTIVE, + MNSS_VOL_STATE_DEACTIVE, + MNSS_VOL_STATE_MOUNTED + } action; + + const TagRequest_s tags[] = + { + {ATR_STATE, TR_OPTIONAL | TR_ATTRIBUTE}, + {TAG_DELETEDVOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_NDSNAME, TR_OPTIONAL}, + {TAG_CONTEXT, TR_OPTIONAL}, + {TAG_POOLNAME, TR_CONTENT_REQUIRED}, + {TAG_NDSPOOLNAME, TR_OPTIONAL}, + {TAG_NONDSOBJECT, TR_OPTIONAL}, + {TAG_UPDATEVLDB, TR_OPTIONAL}, + {TAG_MOUNTPOINT, TR_OPTIONAL}, + {0} + }; + enum + { + STATE = 0, + DELETED_VOLUME_NAME = 1, + VOLUME_NAME = 2, + NDS_NAME = 3, + CONTEXT = 4, + POOL_NAME = 5, + NDS_POOL_NAME = 6, + NO_NDS_OBJECT = 7, + UPDATE_VLDB = 8, + MOUNT_POINT = 9 + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + STATUS status; + NINT state; + NINT idx; + NINT errIndex; + char *errText=NULL; + BOOL defaultVolumeActive; + BOOL defaultVolumeMounted; + BOOL isDeleted; + char volName[zMAX_COMPONENT_NAME]; + unicode_t uniVolName[zMAX_COMPONENT_NAME]; + unicode_t uniNewName[zMAX_COMPONENT_NAME]; + GUID_t dfsGUID; + zVolumeInfo_s info; + + ASSERT_MPKNSS_LOCK(); + + /* Process the XML tags */ + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Upper case the names */ + for (idx = 0; tagContent[DELETED_VOLUME_NAME].content[idx] != '\0'; idx++) + { + tagContent[DELETED_VOLUME_NAME].content[idx] = + toupper(tagContent[DELETED_VOLUME_NAME].content[idx]); + } + for (idx = 0; tagContent[VOLUME_NAME].content[idx] != '\0'; idx++) + { + tagContent[VOLUME_NAME].content[idx] = + toupper(tagContent[VOLUME_NAME].content[idx]); + } + + /* Convert the names to unicode */ + if (utf2uni(tagContent[DELETED_VOLUME_NAME].content, + uniVolName, sizeof(uniVolName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + if (utf2uni(tagContent[VOLUME_NAME].content, + uniNewName, sizeof(uniNewName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Error converting new volume name to unicode")); + goto exit; + } + if ((status = LB_VolumeNameAcceptable(uniNewName)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Invalid new volume name")); + goto exit; + } + + /* Check if the new volume name already exists. */ + /*** Check this - should include_internal arg be TRUE??? ***/ + if (NSSVolumeFound(uniVolName, FALSE, NULL, NULL, NULL, NULL, NULL) == zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_DUPLICATE_VOLUME_NAME, + MSGNot("Volume name already exists")); + status = zERR_DUPLICATE_VOLUME_NAME; + goto exit; + } + + /* Locate the deleted volume (as an internal volume) */ + if ((status = NSSVolumeFound(uniVolName, TRUE, NULL, NULL, NULL, NULL, NULL)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, zFAILURE, + MSGNot("Unable to locate the deleted volume")); + goto exit; + } + + /* Salvage the deleted volume with its deleted name */ + if ((status = ProcessDeletedVolumeAction(tagName, virtInfo, + tagContent[DELETED_VOLUME_NAME].content, + DELETE_ACTION_SALVAGE)) != zOK) + { + /* Result already filled in if we get an error */ + goto exit; + } + + /* Wait up to 60 seconds for the volume to be salvaged */ + idx = 0; + while ((NSSVolumeFound(uniVolName, TRUE, &isDeleted, NULL, NULL, NULL, NULL) == zOK) && isDeleted) + { + sleep(1); + if (++idx > 60) + { + break; + } + } + + /* + * Rename the salvaged logical volume to the "new name" + */ + status = RenameSalvagedVolume(uniVolName, uniNewName, &state); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error renaming the salvaged volume")); + goto exit; + } + + char mountPoint[zMAX_FULL_NAME]; + if (tagContent[MOUNT_POINT].flags & TR_TAG_FOUND) + { + if (tagContent[MOUNT_POINT].content == NULL || + strlen(tagContent[MOUNT_POINT].content) == 0) + { + sprintf(mountPoint, MSGNot("%s%s"), + VOLUME_MOUNT_POINT, tagContent[VOLUME_NAME].content); + } + else + { + strcpy(mountPoint, tagContent[MOUNT_POINT].content); + } + } + else + { + sprintf(mountPoint, MSGNot("%s%s"), + VOLUME_MOUNT_POINT, tagContent[VOLUME_NAME].content); + } + status = MNSS_AddMountPoint(tagContent[POOL_NAME].content, + tagContent[VOLUME_NAME].content, mountPoint, TRUE, NULL); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error setting the mount point")); + goto exit; + } + status = MountVolume(tagContent[VOLUME_NAME].content, TRUE, NULL); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error mounting the volume")); + goto exit; + } + + /* Figure out whether the volume is currently active and/or mounted */ + defaultVolumeActive = (state == zVOLSTATE_ACTIVE) ? TRUE : FALSE; + defaultVolumeMounted = FALSE; + volName[0] = strlen(tagContent[VOLUME_NAME].content); + strcpy(&volName[1],tagContent[VOLUME_NAME].content); + + /* Now, locate the DFS GUID. If one is not set, generate one */ + if ((VOLMNGetDFSGuid(uniNewName, &dfsGUID)) != zOK) + { + LB_GUIDGenerate(&dfsGUID); + VOLMNSetDFSGuid(uniNewName, &dfsGUID); + } + + /* + * Add the NDS object if it should be there + */ + if (!(tagContent[NO_NDS_OBJECT].flags & TR_TAG_FOUND)) + { + if (!(tagContent[NDS_NAME].flags & TR_TAG_FOUND) || + !(tagContent[CONTEXT].flags & TR_TAG_FOUND) || + !(tagContent[NDS_POOL_NAME].flags & TR_TAG_FOUND)) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Missing NDS name or context")); + goto exit; + } + + if ((status = MNDS_AddVolumeToNDS(virtInfo, TRUE, + tagContent[CONTEXT].content, + tagContent[NDS_NAME].content, tagContent[POOL_NAME].content, + tagContent[VOLUME_NAME].content, tagContent[NDS_POOL_NAME].content, + mountPoint, + &dfsGUID, &info.ndsObjectID, FALSE)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error adding volume to NDS")); + goto exit; + } + + status = SetNDSInfoOnVolume(uniNewName, &info, FALSE, TRUE); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error setting NDS object ID for NSS volume")); + goto exit; + } + } + + if (tagContent[UPDATE_VLDB].flags & TR_TAG_FOUND) + { + /* Add this volume to the VLDB */ + if ((status = AddVolumeToVLDB(&dfsGUID, NULL, uniNewName, &errText)) != zOK) + { + if (status == VLDB_ERR_ENTRY_NOT_FOUND) + { + /* This server does not have a DFS Management Context */ + status = zOK; + } + } + } + + /* + * Check to see if the volume should be left deactive, active or mounted. + */ + action = MNSS_NO_VOL_STATE_CHANGE; + if (tagContent[STATE].flags & TR_TAG_FOUND) + { + if (stricmp(tagContent[STATE].content,MSGNot("active")) == 0) + { + action = MNSS_VOL_STATE_ACTIVE; + } + else if (stricmp(tagContent[STATE].content,MSGNot("deactive")) == 0) + { + action = MNSS_VOL_STATE_DEACTIVE; + } + else if (stricmp(tagContent[STATE].content,MSGNot("mounted")) == 0) + { + action = MNSS_VOL_STATE_MOUNTED; + } + } + switch (action) + { + case MNSS_NO_VOL_STATE_CHANGE: + if (!defaultVolumeActive) + { + (void) ChangeVolumeState(uniVolName, FALSE, NULL, &errIndex); + } + break; + + case MNSS_VOL_STATE_MOUNTED: + /* Already Mounted and Active */ + break; + + case MNSS_VOL_STATE_ACTIVE: + /* Already Mounted and Active */ + break; + + case MNSS_VOL_STATE_DEACTIVE: + (void) ChangeVolumeState(uniVolName, FALSE, NULL, &errIndex); + break; + } + + if (status == zOK) + { + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + } + else + { + MNSS_ReturnResult(virtInfo, tagName, status, errText); + } + +exit: + return zOK; +} + + +/**************************************************************************** + * + * This function purges a deleted logical volume + * + ****************************************************************************/ + +STATUS MNSS_ProcessPurgeVolume( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_DELETEDVOLUMENAME, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + DELETED_VOLUME_NAME = 0, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + if ((status = ProcessDeletedVolumeAction(tagName, virtInfo, + tagContent[DELETED_VOLUME_NAME].content, + DELETE_ACTION_PURGE)) != zOK) + { + /* Result already filled in if we get an error */ + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + +exit: + return zOK; +} + + +/**************************************************************************** + * + * This function prevents auto purges on a salvageable deleted logical volume, + * else it pauses a purging process on a deleted logical volume. + * + ****************************************************************************/ + +STATUS MNSS_ProcessPauseDeletedVolumeState( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_DELETEDVOLUMENAME, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + DELETED_VOLUME_NAME = 0, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + if ((status = ProcessDeletedVolumeAction(tagName, virtInfo, + tagContent[DELETED_VOLUME_NAME].content, + DELETE_ACTION_PAUSE)) != zOK) + { + /* Result already filled in if we get an error */ + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + +exit: + return zOK; +} + + +/**************************************************************************** + * + * This function allows auto purges on salvageable deleted logical volume, + * else it continues a purging process on a deleted logical volume. + * + ****************************************************************************/ + +STATUS MNSS_ProcessContinueDeletedVolumeState( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_DELETEDVOLUMENAME, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + DELETED_VOLUME_NAME = 0, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + if ((status = ProcessDeletedVolumeAction(tagName, virtInfo, + tagContent[DELETED_VOLUME_NAME].content, + DELETE_ACTION_CONTINUE)) != zOK) + { + /* Result already filled in if we get an error */ + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + +exit: + return zOK; +} + + +/**************************************************************************** + * + * This function removes a user from a volumes object ID store. + * + ****************************************************************************/ + +STATUS MNSS_ProcessRemoveUser( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_ID, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + VOLUME_NAME = 0, + ID = 1, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + STATUS status; + unicode_t volumeName[zMAX_COMPONENT_NAME]; + UserID_t userID; + NINT i; + NINT errIndex; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + /* Upper case the name */ + for (i = 0; tagContent[VOLUME_NAME].content[i] != '\0'; i++) + { + tagContent[VOLUME_NAME].content[i] = + toupper(tagContent[VOLUME_NAME].content[i]); + } + + /* volume name to unicode */ + if (utf2uni(tagContent[VOLUME_NAME].content, volumeName, + sizeof(volumeName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error converting volume name to unicode")); + goto exit; + } + + status = LB_GUIDFromUTF8(tagContent[ID].content, &userID); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error converting ID to GUID format")); + goto exit; + } + + status = RemoveUserFromIDStore(volumeName,&userID, &errIndex); + if (status != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + ManageVolumeErrorMessages[errIndex]); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function lists all volumes on the server (including traditional volume) + * + ****************************************************************************/ +#undef VOLUME_DELETE +#undef VOLUME_RENAME + +STATUS MNSS_ProcessListVolumes( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + STATUS status = zFAILURE; + utf8_t volName[zMAX_COMPONENT_NAME]; + unicode_t uniName[zMAX_COMPONENT_NAME]; + BOOL listNSS = TRUE; + BOOL listTrad = TRUE; + BOOL firstTime; + BOOL isLogical; + SQUAD cookie; +#ifndef __linux__ + LONG volID; + struct volinfodef volType; + LONG ccode; +#endif + const TagRequest_s tags[] = + { + {ATR_TYPE, TR_ATTRIBUTE | TR_OPTIONAL}, + {0} + }; + + enum + { + TYPE = 0, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + goto exit; + } + return status; + } + + + if (tagContent[TYPE].flags & TR_TAG_FOUND) + { + if (stricmp(tagContent[TYPE].content, MSGNot("all")) == 0) + { + /* Default is true on everything */ + } + else if (stricmp(tagContent[TYPE].content, MSGNot("nss")) == 0) + { + listTrad = FALSE; + } + else if (stricmp(tagContent[TYPE].content, MSGNot("traditional")) == 0) + { + listNSS = FALSE; + } + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto exit; + } + + /* get NSS volume list */ + if (listNSS) + { + firstTime = TRUE; + cookie = -1; + while ((status = GetNextVolumeName(firstTime, &cookie, uniName, NELEMS(uniName), &isLogical)) == zOK) + { + firstTime = FALSE; + if (uni2utf(uniName, volName, sizeof(volName)) == -1) + { + status = zFAILURE; + goto exit; + } + + /* Only want volumes that have a pool. Don't want _Admin, + Dosfat, cd's... + */ + if (isLogical) + { + if ((status = VIRT_AddResultTagForAttribute(virtInfo, TAG_VOLUMENAME)) != zOK) + { + goto exit; + } + if ((status = VIRT_AddAttribute(virtInfo, ATR_TYPE, + MSGNot("nss"), TRUE, FALSE, FALSE)) != zOK) + { + goto exit; + } + + if ((status = VIRT_AddResultData(virtInfo, volName)) != zOK) + { + goto exit; + } + if ((status = VIRT_AddResultTag(virtInfo, TAG_VOLUMENAME, TRUE, TRUE)) != zOK) + { + goto exit; + } + } + } + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + + status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE); + +exit: + return status; +} + + +/**************************************************************************** + * + * This function returns the a scoop of zids from a volume + * + ****************************************************************************/ + +STATUS MNSS_ProcessBrowseBeasts( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {TAG_ONLINEONLY, TR_OPTIONAL}, + {TAG_SELECTBEASTSCRITERIA, TR_CONTENT_REQUIRED}, + {TAG_NUMBEASTSREQUESTED, TR_CONTENT_REQUIRED}, + {TAG_SCANSEQUENCE, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + VOLUME_NAME = 0, + ONLINE_ONLY = 1, + SELECT_BEASTS_CRITERIA = 2, + NUM_BEASTS_REQUESTED = 3, + SCAN_SEQUENCE = 4, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + BOOL onlineOnly = TRUE; + NINT selectCriteria = SELECT_BEASTS_ALL; + Zid_t scanSequence; + NINT numBeastsRequested; + NINT numBeastsReturned; + Zid_t *zids = NULL; + unicode_t uni_volName[zMAX_COMPONENT_NAME]; + utf8_t buf[256]; + NINT i; + STATUS status; + + ASSERT_MPKNSS_LOCK(); + +// syslog(LOG_INFO, "***********browse beasts"); + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Bad XML")); + goto exit; + } + return status; + } + + /* Upper case the name.*/ + for (i = 0; tagContent[VOLUME_NAME].content[i] != '\0'; i++) + { + tagContent[VOLUME_NAME].content[i] = + toupper(tagContent[VOLUME_NAME].content[i]); + } + + /* Change volume name to unicode. */ + if (utf2uni(tagContent[VOLUME_NAME].content, uni_volName, + sizeof(uni_volName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Failed to convert volume name from utf8 format to unicode format")); + goto exit; + } + + if (tagContent[ONLINE_ONLY].flags & TR_TAG_FOUND) + { + onlineOnly = TRUE; + } + else + { + onlineOnly = FALSE; + } + + selectCriteria = -1; + { + utf8_t *start; + XML_ElementInfo_s subElement; + utf8_t *nextTagName; + NINT tagLen; + + start = tagContent[SELECT_BEASTS_CRITERIA].element.dataStart; + for(;;) + { + /* + * Get the next tag which should be a type of info to fill in. + */ + if (XML_GetNextTag(start, + tagContent[SELECT_BEASTS_CRITERIA].element.dataEnd, + &subElement, &nextTagName, &tagLen) != zOK) + { + break; /* we have all of the elements */ + } + start = subElement.elementEnd + 1; + + if (memcmp(nextTagName, TAG_SELECTBEASTSALL, tagLen) == 0) + { + selectCriteria = SELECT_BEASTS_ALL; + break; + } + else if (memcmp(nextTagName, TAG_SELECTBEASTSFORCOMPRESSION, tagLen) == 0) + { + selectCriteria |= SELECT_BEASTS_FOR_COMPRESSION; + } + else if (memcmp(nextTagName, TAG_SELECTBEASTSSALVAGEABLE, tagLen) == 0) + { + selectCriteria |= SELECT_BEASTS_SALVAGEABLE; + } + else if (memcmp(nextTagName, TAG_SELECTBEASTSPURGEABLE, tagLen) == 0) + { + selectCriteria |= SELECT_BEASTS_PURGEABLE; + } + else if (memcmp(nextTagName, TAG_SELECTBEASTSFORBACKUP, tagLen) == 0) + { + selectCriteria |= SELECT_BEASTS_FOR_BACKUP; + } + else if (memcmp(nextTagName, TAG_SELECTBEASTSFORMIGRATION, tagLen) == 0) + { + selectCriteria |= SELECT_BEASTS_FOR_MIGRATION; + } + else + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Invalid selectBeastsCriteria specified")); + goto exit; + } + } + } + + if (selectCriteria == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Invalid selectBeastsCriteria specified")); + goto exit; + + } + + scanSequence = (Zid_t)strtouq(tagContent[SCAN_SEQUENCE].content, NULL, 10); + numBeastsRequested = strtouq(tagContent[NUM_BEASTS_REQUESTED].content, + NULL, 10); + + zids = malloc(sizeof(Zid_t) * numBeastsRequested); + if (zids == NULL) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_NO_MEMORY, + MSGNot("Failed to allocate memory")); + goto exit; + } + +// syslog(LOG_INFO, "selectCriteria = %d, numBeasts = %d, scanSequence = %d", +// selectCriteria, numBeastsRequested, scanSequence); + if ((status = BrowseBeastsInVolume(uni_volName, onlineOnly, + selectCriteria, numBeastsRequested, + &scanSequence, zids, + &numBeastsReturned)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error browsing Beasts in volume")); + goto exit; + } + + /* Add the opening tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, FALSE, TRUE)) != zOK) + { + goto exit; + } + + sprintf(buf, "<"TAG_LASTZIDRETURNED">%Lu" + "<"TAG_NUMBEASTSRETURNED">%u", + scanSequence, numBeastsReturned); + + if ((status = VIRT_AddResultData(virtInfo, buf)) != zOK) + { + goto exit; + } + + // fill in returned zids + if ((status = VIRT_AddResultTag(virtInfo, TAG_BEASTZIDS, FALSE, TRUE)) != zOK) + { + goto exit; + } + + for (i = 0; i < numBeastsReturned; i++) + { + sprintf(buf, "<"TAG_ZID">%Lu", zids[i]); + if ((status = VIRT_AddResultData(virtInfo, buf)) != zOK) + { + goto exit; + } + } + + if ((status = VIRT_AddResultTag(virtInfo, TAG_BEASTZIDS, TRUE, TRUE)) != zOK) + { + goto exit; + } + + MNSS_BuildResult(virtInfo, zOK, XML_SUCCESS); + + /* Add the closing tag */ + if ((status = VIRT_AddResultTag(virtInfo, tagName, TRUE, TRUE)) != zOK) + { + goto exit; + } + +exit: + if (zids) + { + free(zids); + } + return zOK; + +} + +/**************************************************************************** + * + * This function returns the attributes of a volume + * + ****************************************************************************/ + +STATUS MNSS_ProcessFixCompStats( + utf8_t *tagName, + VirtInfo_s *virtInfo, + XML_ElementInfo_s *element) +{ + const TagRequest_s tags[] = + { + {TAG_VOLUMENAME, TR_CONTENT_REQUIRED}, + {0} + }; + + enum + { + VOLUME_NAME = 0, + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + unicode_t uni_volName[zMAX_COMPONENT_NAME]; + NINT i; + STATUS status; + + ASSERT_MPKNSS_LOCK(); + + if ((status = MNSS_GetTagContents(virtInfo, tagName, element, tags, + tagContent)) != zOK) + { + if (status == zERR_XML_IS_BAD) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_XML_IS_BAD, + MSGNot("Bad XML")); + goto exit; + } + return status; + } + + /* Upper case the name.*/ + for (i = 0; tagContent[VOLUME_NAME].content[i] != '\0'; i++) + { + tagContent[VOLUME_NAME].content[i] = + toupper(tagContent[VOLUME_NAME].content[i]); + } + +// syslog(LOG_INFO, "volume name: %s", tagContent[VOLUME_NAME].content); + /* Change volume name to unicode. */ + if (utf2uni(tagContent[VOLUME_NAME].content, uni_volName, + sizeof(uni_volName)) == -1) + { + MNSS_ReturnResult(virtInfo, tagName, zERR_INVALID_UTF8_CHAR, + MSGNot("Failed to convert volume name from utf8 format to unicode format")); + goto exit; + } + + if ((status = fixVolumeCompStats(uni_volName)) != zOK) + { + MNSS_ReturnResult(virtInfo, tagName, status, + MSGNot("Error fixing volume comp stats")); + goto exit; + } + + MNSS_ReturnResult(virtInfo, tagName, 0, XML_SUCCESS); + +exit: + return zOK; +} + +/**************************************************************************** + * + * This function does the following for the given volume + * a) unmount + * b) remove the mount point dir entries from file system + * + ****************************************************************************/ + +STATUS DismountAndRemoveVolumeEntries( + utf8_t *volumeName, + utf8_t **returnMsg, + BOOL lazyUmount, + BOOL removeMountPointFolder) +{ + STATUS status = zFAILURE; + int ccode; + char mountPoint[MOUNT_POINT_MAX_SIZE]; + + *returnMsg = NULL; + + ccode = MNSS_GetMountPoint(volumeName, TRUE, + mountPoint, NULL, NULL, NULL, NULL); + + if(ccode > 0) + { + status = DismountVolume(volumeName, lazyUmount); + if (status != zOK) + { + *returnMsg = MSGNot("Error dismounting volume"); + goto exit; + } + + if(removeMountPointFolder) + { + /* + * Calling this directly as MNSS_RemoveMountPoint() takes a volume name + * and gets the mount point from fstab, and we don't add it for snap volumes. + */ + status = RemoveMountPoint(mountPoint); + + /* There is no need to update fstab as snap volumes are not updated in it */ + if (status != zOK) + { + *returnMsg = MSGNot("Error removing mount point"); + goto exit; + } + } + } + else if(ccode < 0) + { + *returnMsg = MSGNot("Error getting mount point"); + goto exit; + } + else + { + status = zOK; + } + +exit: + return status; +} + +#endif /* User Space code */ + diff --git a/src/nwnss/sharedsrc/mgmt.c.h b/src/nwnss/sharedsrc/mgmt.c.h index cb16842..e478438 100644 --- a/src/nwnss/sharedsrc/mgmt.c.h +++ b/src/nwnss/sharedsrc/mgmt.c.h @@ -24,10 +24,10 @@ | |--------------------------------------------------------------------------- | - | $Author: blarsen $ + | $Author: blarsen $ | $Date: 2006-11-15 04:57:17 +0530 (Wed, 15 Nov 2006) $ | - | $RCSfile$ + | $RCSfile$ | $Revision: 1644 $ | |--------------------------------------------------------------------------- @@ -72,14 +72,11 @@ #include "nwdserr.h" #include "sysimp.h" #include "comnAuthorize.h" -#if zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE)) +#if zLINUX && defined(__KERNEL__) #include #endif #if zLINUX && !defined(__KERNEL__) -#undef MPKNSS_LOCK -#undef MPKNSS_UNLOCK -#undef ASSERT_MPKNSS_LOCK #define MPKNSS_LOCK() ((void) 0) #define MPKNSS_UNLOCK() ((void) 0) #define ASSERT_MPKNSS_LOCK() ((void) 0) @@ -124,10 +121,10 @@ LONG OSSetParamAddEventID = 0; /* event for adding a new settable parameter */ LONG OSSetParamRemoveEventID = 0; /* event for removing a settable parameter */ #endif -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) /**************************************************************************** * This function creates an entire transformation template for the - * control functions that use a file for commands (i.e. consoleOne). It + * control functions that use a file for commands (i.e. consoleOne). It * assumes the spinlock is set. ****************************************************************************/ STATUS MGMTS_MakeCommandVirtualFileWithHelp( @@ -145,13 +142,13 @@ STATUS MGMTS_MakeCommandVirtualFileWithHelp( goto errorExit; } - if ((status = VIRT_MakeDataTypeDataStream(key, NULL, help, &filePos)) + if ((status = VIRT_MakeDataTypeDataStream(key, NULL, help, &filePos)) != zOK) { goto errorExit; } - if ((status = VIRT_MakeReadWriteFuncDataStream(key, MSGNot("command"), + if ((status = VIRT_MakeReadWriteFuncDataStream(key, MSGNot("command"), NULL, NULL, commandRoutine, commandParm, FALSE, &filePos)) != zOK) { goto errorExit; @@ -176,7 +173,7 @@ STATUS MGMT_MakeCommandVirtualFileWithHelp( STATUS status; MPKNSS_LOCK(); - status = MGMTS_MakeCommandVirtualFileWithHelp(key, help, commandRoutine, + status = MGMTS_MakeCommandVirtualFileWithHelp(key, help, commandRoutine, commandParm); MPKNSS_UNLOCK(); return status; @@ -184,7 +181,7 @@ STATUS MGMT_MakeCommandVirtualFileWithHelp( /**************************************************************************** * This function creates an entire transformation template for the - * control functions that use a file for commands (i.e. consoleOne). It + * control functions that use a file for commands (i.e. consoleOne). It * assumes the spinlock is set. ****************************************************************************/ STATUS MGMTS_MakeUserCommandVirtualFileWithHelp( @@ -203,14 +200,14 @@ STATUS MGMTS_MakeUserCommandVirtualFileWithHelp( goto errorExit; } - if ((status = VIRT_MakeDataTypeDataStream(key, NULL, help, &filePos)) + if ((status = VIRT_MakeDataTypeDataStream(key, NULL, help, &filePos)) != zOK) { goto errorExit; } - if ((status = VIRT_MakeUserReadWriteFuncDataStream(key, MSGNot("command"), - NULL, NULL, NULL, commandLibrary, commandRoutine, commandParm, FALSE, + if ((status = VIRT_MakeUserReadWriteFuncDataStream(key, MSGNot("command"), + NULL, NULL, NULL, commandLibrary, commandRoutine, commandParm, FALSE, &filePos)) != zOK) { goto errorExit; @@ -236,7 +233,7 @@ STATUS MGMT_MakeUserCommandVirtualFileWithHelp( STATUS status; MPKNSS_LOCK(); - status = MGMTS_MakeUserCommandVirtualFileWithHelp(key, help, + status = MGMTS_MakeUserCommandVirtualFileWithHelp(key, help, commandLibrary, commandRoutine, commandParm); MPKNSS_UNLOCK(); return status; @@ -262,7 +259,7 @@ STATUS MGMTS_MakeCommandVirtualFile( goto errorExit; } - if ((status = VIRT_MakeReadWriteFuncDataStream(key, NULL, NULL, + if ((status = VIRT_MakeReadWriteFuncDataStream(key, NULL, NULL, NULL, commandRoutine, commandParm, FALSE, &filePos)) != zOK) { goto errorExit; @@ -317,7 +314,7 @@ STATUS MGMTS_MakeFunctionVirtualFile( goto errorExit; } - if ((status = VIRT_MakeReadWriteFuncDataStream(key, NULL, readRoutine, + if ((status = VIRT_MakeReadWriteFuncDataStream(key, NULL, readRoutine, readParm, writeRoutine, writeParm, withCookie, &filePos)) != zOK) { goto errorExit; @@ -346,7 +343,7 @@ STATUS MGMT_MakeFunctionVirtualFile( STATUS status; MPKNSS_LOCK(); - status = MGMTS_MakeFunctionVirtualFile(key, readRoutine, readParm, + status = MGMTS_MakeFunctionVirtualFile(key, readRoutine, readParm, writeRoutine, writeParm, withCookie); MPKNSS_UNLOCK(); return status; @@ -378,14 +375,14 @@ STATUS MGMTS_MakeFunctionVirtualFileWithHelp( goto errorExit; } - if ((status = VIRT_MakeDataTypeDataStream(key, NULL, help, &filePos)) + if ((status = VIRT_MakeDataTypeDataStream(key, NULL, help, &filePos)) != zOK) { goto errorExit; } - if ((status = VIRT_MakeReadWriteFuncDataStream(key, MSGNot("command"), - readRoutine, readParm, writeRoutine, writeParm, withCookie, + if ((status = VIRT_MakeReadWriteFuncDataStream(key, MSGNot("command"), + readRoutine, readParm, writeRoutine, writeParm, withCookie, &filePos)) != zOK) { goto errorExit; @@ -415,7 +412,7 @@ STATUS MGMT_MakeFunctionVirtualFileWithHelp( STATUS status; MPKNSS_LOCK(); - status = MGMTS_MakeFunctionVirtualFileWithHelp(key, help, readRoutine, + status = MGMTS_MakeFunctionVirtualFileWithHelp(key, help, readRoutine, readParm, writeRoutine, writeParm, withCookie); MPKNSS_UNLOCK(); return status; @@ -445,7 +442,7 @@ STATUS MGMT_CopyToWorkingBuffer( */ if (virtInfo->memUsedSize > virtInfo->memAllocatedSize) { - if ((virtInfo->memUsedSize - virtInfo->memAllocatedSize) + if ((virtInfo->memUsedSize - virtInfo->memAllocatedSize) > MGMT_BUFFER_REALLOC_AMOUNT) { virtInfo->memAllocatedSize = virtInfo->memUsedSize; @@ -456,12 +453,12 @@ STATUS MGMT_CopyToWorkingBuffer( } if (virtInfo->memPtr) { - virtInfo->memPtr = + virtInfo->memPtr = realloc(virtInfo->memPtr, virtInfo->memAllocatedSize); } else { - virtInfo->memPtr = + virtInfo->memPtr = malloc(virtInfo->memAllocatedSize); } if (virtInfo->memPtr == NULL) @@ -474,7 +471,7 @@ STATUS MGMT_CopyToWorkingBuffer( memcpy (&((BYTE *)virtInfo->memPtr)[offset], buffer, bufLen); return zOK; -} +} /**************************************************************************** * This function takes the input and appends it to any previous input. It @@ -497,7 +494,7 @@ STATUS MGMT_FindFirstElement( * Take the input and copy to a holding buffer. The holding buffer * is used to hold the incoming XML until we have the entire command. */ - if ((status = MGMT_CopyToWorkingBuffer(bufferLength, buffer, offset, + if ((status = MGMT_CopyToWorkingBuffer(bufferLength, buffer, offset, virtInfo)) != zOK) { goto exit; @@ -507,7 +504,7 @@ STATUS MGMT_FindFirstElement( * Check to see if the XML is all here. If not then return and wait * for more to come. */ - if ((status = XML_BackwardFindEndTag(tagName, + if ((status = XML_BackwardFindEndTag(tagName, (utf8_t *)((BYTE *)virtInfo->memPtr + virtInfo->memUsedSize - 1), virtInfo->memPtr, &endTag)) != zOK) { @@ -519,7 +516,7 @@ STATUS MGMT_FindFirstElement( VIRT_ResetResult(virtInfo); if (XML_GetTagElement(tagName, virtInfo->memPtr, - (utf8_t *)((BYTE *)virtInfo->memPtr + virtInfo->memUsedSize - 1), element) + (utf8_t *)((BYTE *)virtInfo->memPtr + virtInfo->memUsedSize - 1), element) != zOK) { status = zERR_XML_IS_BAD; @@ -561,12 +558,12 @@ void MGMT_BuildResultNSS( utf8_t *buffer) { sprintf(buffer, MSGNot("<"TAG_RESULT" "ATR_VALUE"=\"%d\"><"TAG_DESCRIPTION - ">%s\n"), result, + ">%s\n"), result, GetErrorFromNumber(result)); } /**************************************************************************** - * This function takes the input error and description and adds the XML for + * This function takes the input error and description and adds the XML for * error messages. ****************************************************************************/ void MGMT_BuildResultElement( @@ -575,7 +572,7 @@ void MGMT_BuildResultElement( utf8_t *buffer) { sprintf(buffer, MSGNot("<"TAG_RESULT" "ATR_VALUE"=\"%d\"><"TAG_DESCRIPTION - ">%s\n"), result, + ">%s\n"), result, description); } @@ -666,11 +663,11 @@ STATUS MON_createMonitorFile() { goto error; } - + strcpy((char *)pathStr, (char *)AVFileMgmtDir); strcpy(&pathStr[AVFileMgmtDirLen], MSGNot("monitor.txt")); - ZOS_zCreate(status, rootKey, zNO_TASK, 0, + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, pathStr, zFILE_REGULAR, AVFILEFILEATTR, zCREATE_OPEN_IF_THERE, 0, &retKey); if (status != zOK) @@ -679,23 +676,23 @@ STATUS MON_createMonitorFile() } /* write the transformation template to the file */ - status = MGMTS_MakeFunctionVirtualFile(retKey, "MON_ReadFunc", 0, + status = MGMTS_MakeFunctionVirtualFile(retKey, "MON_ReadFunc", 0, NULL, NULL, FALSE); - + ZOS_zClose(status, retKey); #endif ZOS_ModuleRegister(MON_ReadFunc); status = zOK; -#if NSS_DEBUG IS_ENABLED +#if NSS_DEBUG IS_ENABLED errorCloseRoot: ZOS_zClose(status, rootKey); error: free(pathStr); -#endif +#endif return status; -} +} #endif #ifndef __linux__ // LINUX_SetParms @@ -712,27 +709,27 @@ void formatTickString(LONG ticks, BYTE *buffer) ASSERT_MPKNSS_LOCK(); ConvertTicksToSeconds(ticks, &seconds, &tenthsOfSeconds); /* format days */ - if ((numOfUnits = seconds / (24 * 60 * 60)) >= 1) + if ((numOfUnits = seconds / (24 * 60 * 60)) >= 1) { - sprintf(&buffer[strLen], MSGNot("%u %s "), numOfUnits, + sprintf(&buffer[strLen], MSGNot("%u %s "), numOfUnits, (numOfUnits == 1) ? MSGNot("day") : MSGNot("days")); strLen = strlen(buffer); seconds %= (24 * 60 * 60); hasUnit = TRUE; } /* format hours */ - if ((numOfUnits = seconds / (60 * 60)) >= 1) + if ((numOfUnits = seconds / (60 * 60)) >= 1) { - sprintf(&buffer[strLen], MSGNot("%u %s "), numOfUnits, + sprintf(&buffer[strLen], MSGNot("%u %s "), numOfUnits, (numOfUnits == 1) ? MSGNot("hour") : MSGNot("hours")); strLen = strlen(buffer); seconds %= (60 * 60); hasUnit = TRUE; } /* format minutes */ - if ((numOfUnits = seconds / 60) >= 1) + if ((numOfUnits = seconds / 60) >= 1) { - sprintf(&buffer[strLen], MSGNot("%u %s "), numOfUnits, + sprintf(&buffer[strLen], MSGNot("%u %s "), numOfUnits, (numOfUnits == 1) ? MSGNot("minute") : MSGNot("minutes")); strLen = strlen(buffer); seconds %= 60; @@ -748,7 +745,7 @@ void formatTickString(LONG ticks, BYTE *buffer) } else { - sprintf(&buffer[strLen], MSGNot("%u %s "), seconds, + sprintf(&buffer[strLen], MSGNot("%u %s "), seconds, (seconds == 1) ? MSGNot("second") : MSGNot("seconds")); } @@ -786,7 +783,7 @@ STATUS OS_setParmRead( } /* * Put an element in the file each parameter in this set catagory - */ + */ for (;;) { ZOS_ScanSetableParameters(result, catIndex, ¶mIndex, paramName, @@ -799,8 +796,8 @@ STATUS OS_setParmRead( /* now get the current value */ switch(rType) { - case SP_TYPE_STRING: - ZOS_GetSetableParameterValue(result,0, ¶mName, + case SP_TYPE_STRING: + ZOS_GetSetableParameterValue(result,0, ¶mName, curValueStr); if (result != 0) { @@ -810,15 +807,15 @@ STATUS OS_setParmRead( } else { - sprintf(data, MSGNot("%s"), curValueStr); + sprintf(data, MSGNot("%s"), curValueStr); } break; case SP_TYPE_TRIGGER: - ZOS_GetSetableParameterValue(result,0, ¶mName, + ZOS_GetSetableParameterValue(result,0, ¶mName, &curValueLong); if (result != 0) { - zASSERT(MSGNot("Error getting value of Set Parameter.") == NULL); + zASSERT(MSGNot("Error getting value of Set Parameter.") == NULL); status = zERR_UNABLE_TO_GET_SET_PARAM_VALUE; goto exit; } @@ -843,18 +840,18 @@ STATUS OS_setParmRead( break; } } - break; + break; case SP_TYPE_BOOLEAN: - ZOS_GetSetableParameterValue(result, 0, ¶mName, - &curValueLong); - if (result != 0) + ZOS_GetSetableParameterValue(result, 0, ¶mName, + &curValueLong); + if (result != 0) { - zASSERT(MSGNot("Error getting value of Set Parameter.") == NULL); + zASSERT(MSGNot("Error getting value of Set Parameter.") == NULL); status = zERR_UNABLE_TO_GET_SET_PARAM_VALUE; goto exit; } else - { + { if ((BYTE)curValueLong == 1) { strcpy(data, MSGNot("ON")); @@ -866,11 +863,11 @@ STATUS OS_setParmRead( } break; case SP_TYPE_TIME_OFFSET: - ZOS_GetSetableParameterValue(result,0, ¶mName, + ZOS_GetSetableParameterValue(result,0, ¶mName, &curValueLong); if (result != 0) { - zASSERT(MSGNot("Error getting value of Set Parameter.") == NULL); + zASSERT(MSGNot("Error getting value of Set Parameter.") == NULL); status = zERR_UNABLE_TO_GET_SET_PARAM_VALUE; goto exit; } @@ -888,16 +885,16 @@ STATUS OS_setParmRead( minute = (curValueLong % (60 * 60)) / 60; second = curValueLong % 60; - sprintf(data, MSGNot("%c%u:%02u:%02u"), + sprintf(data, MSGNot("%c%u:%02u:%02u"), sign, hour, minute, second); } break; case SP_TYPE_TICKS: - ZOS_GetSetableParameterValue(result,0, ¶mName, - &curValueLong); - if (result != 0) + ZOS_GetSetableParameterValue(result,0, ¶mName, + &curValueLong); + if (result != 0) { - zASSERT(MSGNot("Error getting value of Set Parameter.") == NULL); + zASSERT(MSGNot("Error getting value of Set Parameter.") == NULL); status = zERR_UNABLE_TO_GET_SET_PARAM_VALUE; goto exit; } @@ -907,26 +904,26 @@ STATUS OS_setParmRead( } break; case SP_TYPE_BLOCK_SHIFT: - ZOS_GetSetableParameterValue(result, 0, ¶mName, - &curValueLong); - if (result != 0) + ZOS_GetSetableParameterValue(result, 0, ¶mName, + &curValueLong); + if (result != 0) { - zASSERT(MSGNot("Error getting value of Set Parameter.") == NULL); + zASSERT(MSGNot("Error getting value of Set Parameter.") == NULL); status = zERR_UNABLE_TO_GET_SET_PARAM_VALUE; goto exit; } else { - /* 512 is for the OS block shift */ + /* 512 is for the OS block shift */ sprintf(data, MSGNot("%u"), 512 << curValueLong); } break; default: - ZOS_GetSetableParameterValue(result,0, ¶mName, - &curValueLong); - if (result != 0) + ZOS_GetSetableParameterValue(result,0, ¶mName, + &curValueLong); + if (result != 0) { - zASSERT(MSGNot("Error getting value of Set Parameter.") == NULL); + zASSERT(MSGNot("Error getting value of Set Parameter.") == NULL); status = zERR_UNABLE_TO_GET_SET_PARAM_VALUE; goto exit; } @@ -934,14 +931,14 @@ STATUS OS_setParmRead( { sprintf(data, MSGNot("%u"), (LONG)curValueLong); } - } - + } + if ((status = VIRT_AddResultTag(virtInfo, TAG_PARMINFO, FALSE, FALSE)) != zOK) { goto exit; } - if ((status = VIRT_AddResultElement(virtInfo, TAG_NAME, paramName, + if ((status = VIRT_AddResultElement(virtInfo, TAG_NAME, paramName, FALSE)) != zOK) { goto exit; @@ -1010,7 +1007,7 @@ STATUS OS_setParmCommand( MPKNSS_LOCK(); /* Check to see if we have the entire XML command */ - if ((status = MGMT_FindFirstElement(virtInfo, TAG_OSMODIFY, bufferLength, + if ((status = MGMT_FindFirstElement(virtInfo, TAG_OSMODIFY, bufferLength, buffer, offset, &osElement)) != zOK) { goto exit; @@ -1019,7 +1016,7 @@ STATUS OS_setParmCommand( /* * Get the next tag which should be a command to change some OS parameter */ - if (XML_GetNextTag(osElement.dataStart, osElement.dataEnd, + if (XML_GetNextTag(osElement.dataStart, osElement.dataEnd, &parmElement, &tagName, &tagLen) != zOK) { status = zERR_XML_IS_BAD; @@ -1067,7 +1064,7 @@ STATUS OS_setParmCommand( /* * Scan all categories for the parameter name */ - ZOS_ScanSetableParameters(result, -2, NULL, paramName, &rType, + ZOS_ScanSetableParameters(result, -2, NULL, paramName, &rType, &rFlag, NULL, NULL, NULL, NULL, NULL); if (result != zOK) { @@ -1103,7 +1100,7 @@ STATUS OS_setParmCommand( errorFlag = TRUE; break; } - ZOS_SetSetableParameterValue(result, 0, paramName, + ZOS_SetSetableParameterValue(result, 0, paramName, &newValueLong); if (result != 0) { @@ -1172,7 +1169,7 @@ STATUS OS_setParmCommand( } seconds += atol(pr); - ConvertSecondsToTicks(seconds, tenthsOfSeconds, &newValueLong); + ConvertSecondsToTicks(seconds, tenthsOfSeconds, &newValueLong); ZOS_SetSetableParameterValue(result, 0, paramName, &newValueLong); if (result != zOK) { @@ -1181,7 +1178,7 @@ STATUS OS_setParmCommand( } break; case SP_TYPE_BLOCK_SHIFT: - /* 512 is for the OS block shift */ + /* 512 is for the OS block shift */ newValueLong = atol(newValueStr) >> 512; newValueLong >>= 512; ZOS_SetSetableParameterValue(result, 0, paramName, &newValueLong); @@ -1191,7 +1188,7 @@ STATUS OS_setParmCommand( break; } break; - default: + default: newValueLong = atol(newValueStr); ZOS_SetSetableParameterValue(result, 0, paramName, &newValueLong); if (result != 0 && result != -1) @@ -1215,12 +1212,12 @@ STATUS OS_setParmCommand( { goto exit; } - if ((status = VIRT_AddResultElement(virtInfo, TAG_ID, paramName, + if ((status = VIRT_AddResultElement(virtInfo, TAG_ID, paramName, FALSE)) != zOK) { goto exit; } - if ((status = VIRT_AddResultElement(virtInfo, TAG_STATUS, resultStr, + if ((status = VIRT_AddResultElement(virtInfo, TAG_STATUS, resultStr, FALSE)) != zOK) { goto exit; @@ -1231,7 +1228,7 @@ STATUS OS_setParmCommand( goto exit; } /* get the next element (better be another parmInfo) */ - if (XML_GetNextTag(parmElement.elementEnd, osElement.dataEnd, + if (XML_GetNextTag(parmElement.elementEnd, osElement.dataEnd, &parmElement, &tagName, &tagLen) != zOK) { break; /* no more tags -- done */ @@ -1271,7 +1268,7 @@ STATUS OS_createCategory( BYTE *catName, NINT catNum) { - BYTE path[zMAX_FULL_NAME]; + BYTE path[zMAX_FULL_NAME]; BYTE valName[128]; BYTE parm[132]; STATUS status; @@ -1280,9 +1277,9 @@ STATUS OS_createCategory( strcpy(path, AVFileOSMgmtDir); strcpy(valName, catName); validateName(valName); - sprintf(&path[AVFileOSMgmtDirLen], MSGNot("%s.xml"), + sprintf(&path[AVFileOSMgmtDirLen], MSGNot("%s.xml"), (char *)valName); - ZOS_zCreate(status, rootKey, zNO_TASK, 0, + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, path, zFILE_REGULAR, AVFILEFILEATTR, zCREATE_OPEN_IF_THERE, 0, &retKey); if (status != zOK) @@ -1295,7 +1292,7 @@ STATUS OS_createCategory( sprintf(parm, "%d", catNum); /* write the transformation template to the file */ - if ((status = MGMTS_MakeFunctionVirtualFile(retKey, "OS_setParmRead", parm, + if ((status = MGMTS_MakeFunctionVirtualFile(retKey, "OS_setParmRead", parm, NULL, NULL, FALSE)) != zOK) { SetErrno(genMsg, status); @@ -1307,7 +1304,7 @@ STATUS OS_createCategory( /* we keep the path in the link file */ if (AVFileAddLink(&RegOSSetParmMgmtFiles, path) != zOK) { - ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, + ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, path, zMATCH_ALL, zDELETE_FORCE_DELETE); zASSERT(status == 0); SetErrno(genMsg, zERR_BAD_PARAMETER_VALUE); @@ -1322,7 +1319,7 @@ errorClose: error: return zFAILURE; -} +} /**************************************************************************** * This function is called whenever a new OS set param category is added @@ -1370,7 +1367,7 @@ void OSSetParamCategoryRemoveEventFunc( } strcpy(path, AVFileOSMgmtDir); - + strcpy(valName, catEvent->setParameterCategoryName); validateName(valName); sprintf(&path[AVFileOSMgmtDirLen], MSGNot("%s.xml"), valName); @@ -1379,7 +1376,7 @@ void OSSetParamCategoryRemoveEventFunc( validateName(path); - ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, path, + ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, path, zMATCH_ALL, zDELETE_FORCE_DELETE); // zASSERT(status == 0); @@ -1398,7 +1395,7 @@ exit: //void OSSetParamAddEventFunc( // struct EventSetParameter *spEvent) //{ -// LONG catIndex; +// LONG catIndex; // BYTE paramName[128]; // BYTE oriPath[zMAX_FULL_NAME]; // BYTE valPath[zMAX_FULL_NAME]; @@ -1420,9 +1417,9 @@ exit: // } // // strcpy(oriPath, AdminVolAsciiName); -// +// // catIndex = spEvent->setParameterCategoryNumber; -// +// // ZOS_ReturnSetParameterCategoryInfo(result, 2, NULL, catIndex, paramName); // if (result != 0) // { @@ -1430,7 +1427,7 @@ exit: // goto exit; // } // -// ZOS_ScanSetableParameters(result,-2, NULL, spEvent->setParameterName, NULL, +// ZOS_ScanSetableParameters(result,-2, NULL, spEvent->setParameterName, NULL, // &rFlag, NULL, NULL, NULL, NULL, NULL);/* get the flag of new created parameter, if it marks hide, we don't create it*/ // if (result != 0) // { @@ -1443,13 +1440,13 @@ exit: // goto exit; // } // -// sprintf(&oriPath[AdminVolNameLen], MSGNot(":Manage_OS\\%s\\%s.xml"), +// sprintf(&oriPath[AdminVolNameLen], MSGNot(":Manage_OS\\%s\\%s.xml"), // paramName, spEvent->setParameterName); // strcpy(valPath, oriPath); // validatePath(valPath); // -// ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, -// valPath, zFILE_REGULAR, AVFILEFILEATTR, zCREATE_OPEN_IF_THERE, +// ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, +// valPath, zFILE_REGULAR, AVFILEFILEATTR, zCREATE_OPEN_IF_THERE, // zRR_WRITE_ACCESS, &retKey); // if (status != zOK) // { @@ -1472,7 +1469,7 @@ exit: // if (AVFileAddLink(&RegOSSetParmMgmtFiles, oriPath) != zOK) // { // zASSERT(MSGNot("Failed to link the newly Added Set Parm management file") == NULL); -// ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, +// ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, // valPath, zMATCH_ALL, zDELETE_FORCE_DELETE); // zASSERT(status == 0); // } @@ -1493,7 +1490,7 @@ exit: //void OSSetParamRemoveEventFunc( // struct EventSetParameter *spEvent) //{ -// LONG catIndex; +// LONG catIndex; // BYTE paramName[128]; // BYTE path[zMAX_FULL_NAME]; // LONG result; @@ -1509,7 +1506,7 @@ exit: // } // // strcpy(path, AdminVolAsciiName); -// +// // catIndex = spEvent->setParameterCategoryNumber; // ZOS_ReturnSetParameterCategoryInfo(result, 2, NULL, catIndex, paramName); // if (result != 0) @@ -1518,13 +1515,13 @@ exit: // goto exit; // } // -// sprintf(&path[AdminVolNameLen], MSGNot(":Manage_OS\\%s\\%s.xml"), +// sprintf(&path[AdminVolNameLen], MSGNot(":Manage_OS\\%s\\%s.xml"), // paramName, spEvent->setParameterName); // AVFileRemoveLink(&RegOSSetParmMgmtFiles, path); // // validatePath(path); // -// ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, path, +// ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, path, // zMATCH_ALL, zDELETE_FORCE_DELETE); //// zASSERT(status == 0); // @@ -1545,8 +1542,8 @@ exit: STATUS OS_StartupSetParam( GeneralMsg_s *genMsg) { - - BYTE path[zMAX_FULL_NAME]; + + BYTE path[zMAX_FULL_NAME]; LONG regSetParamCatNum; LONG index; LONG catIndex; @@ -1566,10 +1563,10 @@ STATUS OS_StartupSetParam( } /* Create OS management directory */ - sprintf(path, MSGNot("%s:%s"), AdminVolAsciiName, + sprintf(path, MSGNot("%s:%s"), AdminVolAsciiName, AVOL_OS_MANAGEMENT_DIRECTORY); - ZOS_zCreate(status, rootKey, zNO_TASK, 0, + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, path, zFILE_REGULAR, AVFILEDIRATTR, zCREATE_OPEN_IF_THERE, 0, &retKey); if (status != zOK) @@ -1582,7 +1579,7 @@ STATUS OS_StartupSetParam( /* create the set parm control file (for changing parameters) */ strcat(path, MSGNot("\\SetParmControl.cmd")); - ZOS_zCreate(status, rootKey, zNO_TASK, 0, + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, path, zFILE_REGULAR, AVFILEFILEATTR, zCREATE_OPEN_IF_THERE, 0, &retKey); if (status != zOK) @@ -1591,7 +1588,7 @@ STATUS OS_StartupSetParam( goto errorClose; } - status = MGMTS_MakeCommandVirtualFileWithHelp(retKey, + status = MGMTS_MakeCommandVirtualFileWithHelp(retKey, MSG("This file allows changing of the operating system set parameters\n", 43), MSGNot("OS_setParmCommand"), NULL); ZOS_zClose(tmpStatus, retKey); @@ -1604,7 +1601,7 @@ STATUS OS_StartupSetParam( if (AVFileAddLink(&RegOSSetParmMgmtFiles, path) != zOK) { - ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, + ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, path, zMATCH_ALL, zDELETE_FORCE_DELETE); zASSERT(status == 0); SetErrno(genMsg, zERR_BAD_PARAMETER_VALUE); @@ -1613,7 +1610,7 @@ STATUS OS_StartupSetParam( /* first, get the number of already registered categories */ catIndex = 0; - ZOS_ScanSetableParameters(result, -3, &catIndex, paramName, NULL, NULL, + ZOS_ScanSetableParameters(result, -3, &catIndex, paramName, NULL, NULL, NULL, NULL, NULL, NULL, ®SetParamCatNum); if (result != zOK) { @@ -1626,7 +1623,7 @@ STATUS OS_StartupSetParam( /* note: catIndex is set to next sequence number, need to adjust it back when it's used to as index to get params under it*/ index = catIndex; - ZOS_ScanSetableParameters(result, -3, &index, paramName, NULL, NULL, + ZOS_ScanSetableParameters(result, -3, &index, paramName, NULL, NULL, NULL, NULL, NULL, NULL, NULL); if (result != zOK) { @@ -1639,7 +1636,7 @@ STATUS OS_StartupSetParam( } } ZOS_zClose(status, rootKey); - + /* Register to get notified whenever any set parameter value is changed */ ZOS_EventNotificationReg(OSSetParamCategoryAddEventID, EVENT_SET_PARM_CATEGORY_ADD, @@ -1683,7 +1680,7 @@ void OS_ShutdownSetParam() ASSERT_MPKNSS_LOCK(); - /* Unregister the event routine */ + /* Unregister the event routine */ if (OSSetParamCategoryAddEventID) ZOS_EventNotificationUnReg(OSSetParamCategoryAddEventID); @@ -1702,29 +1699,29 @@ void OS_ShutdownSetParam() return; } - while (DQ_NOT_EMPTY(&RegOSSetParmMgmtFiles)) + while (DQ_NOT_EMPTY(&RegOSSetParmMgmtFiles)) { DQ_TAKE(&RegOSSetParmMgmtFiles, mgmtFile, AVFileLink_s, link); if (mgmtFile->path != NULL) { strcpy(path, mgmtFile->path); validateName(path); - ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, + ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, path, zMATCH_ALL, zDELETE_FORCE_DELETE); zASSERT(status == 0); free(mgmtFile->path); } free(mgmtFile); } - + /* Remove the base dir */ - sprintf(path, MSGNot("%s:%s"), (char *)AdminVolAsciiName, + sprintf(path, MSGNot("%s:%s"), (char *)AdminVolAsciiName, AVOL_OS_MANAGEMENT_DIRECTORY); - ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, + ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, path, zMATCH_ALL, zDELETE_FORCE_DELETE); zASSERT(status == 0); ZOS_zClose(status, rootKey); - return; + return; } #endif @@ -1790,7 +1787,7 @@ STATUS MGMT_LVDelete( strcat(aStack->path, MGMT_ControlFileInfo[i].MLVCF_Path); strcat(aStack->path, MGMT_ControlFileInfo[i].MLVCF_Filename); - ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, aStack->path, + ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, aStack->path, zMATCH_ALL, zDELETE_FORCE_DELETE); zASSERT(status == zOK); if ( status != zOK ) @@ -1823,7 +1820,7 @@ STATUS MGMT_LVCreate( strcat(aStack->path, MGMT_ControlFileInfo[i].MLVCF_Path); strcat(aStack->path, MGMT_ControlFileInfo[i].MLVCF_Filename); - ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, aStack->path, + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, aStack->path, zFILE_REGULAR, zFA_SYSTEM | zFA_HIDDEN | zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT | zFA_VOLATILE, @@ -1876,7 +1873,7 @@ STATUS MGMT_StartupControlPath() strcpy(aStack->path, AdminVolAsciiName); strcat(aStack->path, MSGNot(":\\CONTROL")); - ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, aStack->path, + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, aStack->path, zFILE_REGULAR, zFA_SYSTEM | zFA_HIDDEN | zFA_SUBDIRECTORY | zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT, zCREATE_OPEN_IF_THERE, 0, &retKey); @@ -1921,20 +1918,20 @@ void MGMT_ShutdownControlPath() /* * Remove the directory for management files */ - + ZOS_zRootKey(status, 0, &rootKey); if (status != zOK) { goto errorExit; } - + /* Clean up :CONTROL\Volume... files */ (void)MGMT_LVDelete(rootKey); /* Clean up :CONTROL subdirectory */ strcpy(aStack->path, AdminVolAsciiName); strcat(aStack->path, MSGNot(":\\CONTROL")); - ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, aStack->path, + ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, aStack->path, zMATCH_ALL, zDELETE_FORCE_DELETE); zASSERT(status == zOK); @@ -1970,7 +1967,7 @@ STATUS AVFileAddLink( mgmtFile->path = (char *)zalloc(strlen(pathStr) + 1); if (mgmtFile->path == NULL) { - free(mgmtFile); + free(mgmtFile); status = zERR_NO_MEMORY; goto Exit; } @@ -2015,7 +2012,7 @@ STATUS AVFileRemoveLink( } if (!stricmp(mgmtFile->path, pathStr)) - { + { DQ_RMV(mgmtFile,link); free(mgmtFile->path); free(mgmtFile); @@ -2038,7 +2035,7 @@ LONG NSSTestValueOne = 1; LONG NSSTestValueTwo = 2; -#define test_catagory MSGNot("Testing 123") +#define test_catagory MSGNot("Testing 123") #define test_value_one MSGNot("Test value one") #define test_value_two MSGNot("Test value two") @@ -2048,7 +2045,7 @@ void TEST_RegisterOSparms(void) LONG ccode; ZOS_RegisterSetParameterCategory( ccode, - (LONG)COMN_Resource.moduleHandle, + (LONG)COMN_Resource.moduleHandle, COMN_Resource.setCmdCategoryRTag, test_catagory, &NSSTestCategory); @@ -2069,7 +2066,7 @@ void TEST_RegisterOSparms(void) aprintf(LRED, "Error %d registering test value one\n", ccode); zASSERT(0); } - + ZOS_RegisterSetParameter(ccode, (LONG)COMN_Resource.moduleHandle, COMN_Resource.setCmdRTag, @@ -2091,7 +2088,7 @@ void TEST_RegisterOSparms(void) aprintf(LRED, "Error %d registering test catagory\n", ccode); zASSERT(0); } -} +} void TEST_UnregisterOSparms(void) @@ -2132,7 +2129,7 @@ void TEST_UnregisterOSparms(void) #endif /******************************************************************************** - * Initialize the Management Files. * + * Initialize the Management Files. * ********************************************************************************/ STATUS MGMTFILES_Startup( GeneralMsg_s *genMsg) @@ -2158,8 +2155,8 @@ STATUS MGMTFILES_Startup( SetErrno(genMsg, status); goto errorExit; } - - ZOS_zCreate(status, rootKey, zNO_TASK, 0, + + ZOS_zCreate(status, rootKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, AVFileMgmtDir, zFILE_REGULAR, AVFILEDIRATTR, zCREATE_OPEN_IF_THERE, 0, &retKey); if (status != zOK) @@ -2169,7 +2166,7 @@ STATUS MGMTFILES_Startup( goto errorExit; } - ZOS_zCreate(status, retKey, zNO_TASK, 0, + ZOS_zCreate(status, retKey, zNO_TASK, 0, zNSPACE_LONG | zMODE_UTF8, "LSS", zFILE_REGULAR, AVFILEDIRATTR, zCREATE_OPEN_IF_THERE, 0, &lssKey); if (status != zOK) @@ -2263,7 +2260,7 @@ void MGMTFILES_Shutdown() ASSERT_MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); - + #ifndef __linux__ // LINUX_SetParms #if TEST_OS_SETPARMS IS_ENABLED TEST_UnregisterOSparms(); @@ -2288,14 +2285,14 @@ void MGMTFILES_Shutdown() * not actually remove the directory because there are still files to * be removed, but I have left the code anyway. */ - + ZOS_zRootKey(status, 0, &rootKey); if (status != zOK) { goto errorExit; } - - ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, AVFileMgmtDir, + + ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, AVFileMgmtDir, zMATCH_ALL, zDELETE_FORCE_DELETE); ZOS_zClose(status, rootKey); @@ -2505,7 +2502,7 @@ void MGMT_BuildResultNSSWithSetter( ">" "<"TAG_DESCRIPTION">%s" "\n"), - result, + result, resultSetter, GetErrorFromNumber(result) ); } @@ -2533,20 +2530,20 @@ STATUS MGMT_ReturnResultNSSWithSetter( * Three Sample Outputs * * - * Error creating pool - * managePool.c[5706] - * MM_ADAPTER_ERROR + * Error creating pool + * managePool.c[5706] + * MM_ADAPTER_ERROR * * * - * Fake Pool Error - * managePool.c[5707] - * zERR_NO_MEMORY - * managePool.c[5705] + * Fake Pool Error + * managePool.c[5707] + * zERR_NO_MEMORY + * managePool.c[5705] * * * - * Fake No Error + * Fake No Error * * */ @@ -2562,7 +2559,7 @@ void MNSS_BuildResult2( */ { utf8_t tempBuf[256]; - + ASSERT_MPKNSS_LOCK(); sprintf(tempBuf, MSGNot("<"TAG_RESULT" "ATR_VALUE @@ -2601,24 +2598,24 @@ void MNSS_BuildResult2( * * * - * Error creating pool - * managePool.c[5706] - * MM_ADAPTER_ERROR + * Error creating pool + * managePool.c[5706] + * MM_ADAPTER_ERROR * * * * * - * Fake Pool Error - * managePool.c[5707] - * zERR_NO_MEMORY - * managePool.c[5705] + * Fake Pool Error + * managePool.c[5707] + * zERR_NO_MEMORY + * managePool.c[5705] * * * * * - * Fake No Error + * Fake No Error * * */ @@ -2673,9 +2670,9 @@ STATUS MNSS_GetTagContents( { if (virtInfo) { - sprintf(tempBuf, "%s%s", + sprintf(tempBuf, "%s%s", MSGNot("Missing required attribute: "), tagName); - MNSS_ReturnResult(virtInfo, parentTag, zERR_XML_IS_BAD, + MNSS_ReturnResult(virtInfo, parentTag, zERR_XML_IS_BAD, tempBuf); } status = zERR_XML_IS_BAD; @@ -2691,16 +2688,16 @@ STATUS MNSS_GetTagContents( } else { - if (XML_GetTagElement(tagName, element->dataStart, + if (XML_GetTagElement(tagName, element->dataStart, element->dataEnd, &parmElement) != zOK) { if (!(requestedTags[i].flags & TR_OPTIONAL)) { if (virtInfo) { - sprintf(tempBuf, MSGNot("Missing required tag: %s"), + sprintf(tempBuf, MSGNot("Missing required tag: %s"), tagName); - MNSS_ReturnResult(virtInfo, parentTag, zERR_XML_IS_BAD, + MNSS_ReturnResult(virtInfo, parentTag, zERR_XML_IS_BAD, tempBuf); } status = zERR_XML_IS_BAD; @@ -2718,9 +2715,9 @@ STATUS MNSS_GetTagContents( { if (virtInfo) { - sprintf(tempBuf, + sprintf(tempBuf, MSGNot("Missing required tag content: %s"), tagName); - MNSS_ReturnResult(virtInfo, parentTag, zERR_XML_IS_BAD, + MNSS_ReturnResult(virtInfo, parentTag, zERR_XML_IS_BAD, tempBuf); } status = zERR_XML_IS_BAD; @@ -2837,7 +2834,7 @@ STATUS MNSS_GetSpecificTemplate( for (;; ) { - status = MNSS_GetNextTagString( currentTags, ¤tTags, + status = MNSS_GetNextTagString( currentTags, ¤tTags, sizeof(tagName), tagName ); // if ( resultInfo->dataLen != 0 ) @@ -2854,7 +2851,7 @@ STATUS MNSS_GetSpecificTemplate( status = XML_GetTagElementAtCurrentLevel( tagName, resultInfo->dataStart, resultInfo->dataEnd, resultInfo ); - + if ( status != zOK ) { return( status ); @@ -2995,7 +2992,7 @@ STATUS MNSS_ConvertBitsToTags( { QUAD bit; NINT index; - + value &= bitsToCheck; *dataLen = 0; @@ -3018,7 +3015,7 @@ STATUS MNSS_ConvertBitsToTags( return zERR_BUFFER_TOO_SMALL; } } - + } return zOK; @@ -3042,10 +3039,10 @@ QUAD MNSS_ConvertTagsToBits( NINT tagLen; XML_ElementInfo_s element; QUAD value; - + start = buf; end = buf + bufLen - 1; - + value = 0; for (;;) @@ -3098,7 +3095,7 @@ SNINT MNSS_ConvertNameSpaceTagsToValue( { return zNSPACE_DATA_STREAM; } - else + else { return -1; } @@ -3129,7 +3126,7 @@ SNINT MNSS_ConvertNameTypeTagsToValue( } } -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) /**************************************************************************** * * Generate the XML for the UTC time @@ -3140,7 +3137,7 @@ STATUS MNSS_FillUTCTime( Time_t time, NINT bufLen, utf8_t *buf, - NINT *dataLen) + NINT *dataLen) { typedef struct Stack_s { utf8_t buffer[256]; @@ -3150,7 +3147,7 @@ STATUS MNSS_FillUTCTime( STACK_ALLOC(); sprintf(aStack->buffer, "<%s><"TAG_UTC">%u" "<"TAG_STRING">%s", - tag, time, + tag, time, UTCTime2UniversalStr(time, aStack->timeString), tag); @@ -3158,11 +3155,11 @@ STATUS MNSS_FillUTCTime( if (*dataLen > bufLen - 1) { STACK_FREE(); - return zERR_BUFFER_TOO_SMALL; + return zERR_BUFFER_TOO_SMALL; } strcpy(buf, aStack->buffer); - + STACK_FREE(); return zOK; } @@ -3172,7 +3169,7 @@ STATUS MNSS_FillInAnID( UserID_t *id, NINT bufLen, utf8_t *buf, - NINT *dataLen) + NINT *dataLen) { typedef struct Stack_s { char idString[MAX_DN_CHARS]; @@ -3181,14 +3178,14 @@ STATUS MNSS_FillInAnID( } Stack_s; STACK_ALLOC(); - + /* Get the name from the ID */ if (MNSS_GetNDSNameFromGUID(NULL, id, aStack->idString) != zOK) { strcpy(aStack->idString,"Unknown User"); } (void)LB_GUIDToString(id, GUID_FORMAT_SIZE, aStack->guid); - + sprintf(aStack->buffer, "<%s><"TAG_NAME">" "<"TAG_ID">%s", tag, aStack->idString, aStack->guid, tag); @@ -3197,7 +3194,7 @@ STATUS MNSS_FillInAnID( if (*dataLen > bufLen - 1) { STACK_FREE(); - return zERR_BUFFER_TOO_SMALL; + return zERR_BUFFER_TOO_SMALL; } strcpy(buf, aStack->buffer); @@ -3214,7 +3211,7 @@ STATUS MNSS_FillInAnID( ****************************************************************************/ STATUS MNSS_FindUserIDByDN( unsigned char *context, - unsigned char *dn, + unsigned char *dn, UserID_t *userID) { STATUS status; @@ -3268,7 +3265,7 @@ STATUS MNSS_FindUserIDByDN( #endif #endif -#if zNETWARE || (zLINUX && !defined(__KERNEL__) && !defined(NSS_USERSPACE)) +#if zNETWARE || (zLINUX && !defined(__KERNEL__)) /**************************************************************************** * * This function takes the passed in distinguished name for an object and @@ -3445,7 +3442,7 @@ STATUS MNSS_GetObjectIDFromName( /* Create a DClient Context */ err = (*DDCCreateContextPtr)((SAL_ModHandle)(long)COMN_ModuleHandle, &dsContext); - if (err != 0) + if (err != 0) { goto exit; } @@ -3512,9 +3509,9 @@ exit: } #endif -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) STATUS MNSS_GetGUIDFromName( - utf8_t *name, + utf8_t *name, UserID_t *ndsGUID) { #if !zLINUX @@ -3566,7 +3563,7 @@ STATUS MNSS_GetNDSNameFromGUID( { STATUS status; -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ typedef struct Stack_s { unicode_t uniName[MAX_DN_CHARS]; utf8_t tempName[MAX_DN_CHARS]; @@ -3588,7 +3585,7 @@ STATUS MNSS_GetNDSNameFromGUID( utf8_t tempName[MAX_DN_CHARS]; int dsContext; int agentIdentityHandle; - + //syslog(LOG_DEBUG, "MNSS_GetNDSNameFromGUID: guid=0x%x\n", guid->timeLow); if (guid->timeHighAndVersion == 0) { /* special guid */ @@ -3621,7 +3618,7 @@ STATUS MNSS_GetNDSNameFromGUID( } zASSERT("Bad special GUID" == 0); } - + if (!NdsPublicsLoaded) { if (LB_ImportNDSPublics((LONG)COMN_ModuleHandle) != zOK) @@ -3637,7 +3634,7 @@ STATUS MNSS_GetNDSNameFromGUID( /* Create a DClient Context */ status = (*DDCCreateContextPtr)((SAL_ModHandle)(long)COMN_ModuleHandle, &dsContext); - if (status != 0) + if (status != 0) { goto exit; } @@ -3670,41 +3667,41 @@ exit: // DBG_DebugPrintf(LMAGENTA,"MNSS_GetNDSNameFromGUID: error from MapObjectIDToLongName=%d\n", status); return status; } - + // DBG_DebugPrintf(LMAGENTA,"MNSS_GetNDSNameFromGUID: objectName=%s\n", objectName); return zOK; -} +} -#if zNETWARE || (zLINUX && (defined(__KERNEL__) || defined(NSS_USERSPACE))) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) STATUS getModifyValue( - GeneralMsg_s *genMsg, - XML_ElementInfo_s *element, + GeneralMsg_s *genMsg, + XML_ElementInfo_s *element, utf8_t **oldValueStr, - utf8_t **newValueStr) -{ - STATUS status; - - const TagRequest_s tags[] = - { - {TAG_OLDVALUE, TR_OPTIONAL}, - {TAG_NEWVALUE, TR_OPTIONAL}, - {0} - }; - TagContent_s tagContent[NELEMS(tags)-1]; - - enum - { - OLD_VALUE = 0, - NEW_VALUE = 1 - }; - - status = MNSS_GetTagContents(NULL, NULL, element, tags, tagContent); - if (status != zOK) - { - SetErrno(genMsg, status); - return zFAILURE; - } + utf8_t **newValueStr) +{ + STATUS status; + + const TagRequest_s tags[] = + { + {TAG_OLDVALUE, TR_OPTIONAL}, + {TAG_NEWVALUE, TR_OPTIONAL}, + {0} + }; + TagContent_s tagContent[NELEMS(tags)-1]; + + enum + { + OLD_VALUE = 0, + NEW_VALUE = 1 + }; + + status = MNSS_GetTagContents(NULL, NULL, element, tags, tagContent); + if (status != zOK) + { + SetErrno(genMsg, status); + return zFAILURE; + } *oldValueStr = NULL; *newValueStr = NULL; @@ -3724,34 +3721,34 @@ STATUS getModifyValue( STATUS modifyInfoTimeStr( GeneralMsg_s *genMsg, void *beast, - ADDR address, - XML_ElementInfo_s *element, + ADDR address, + XML_ElementInfo_s *element, Xaction_s *xaction, - BOOL doChange) -{ - STATUS status = zOK; - Time_t oldValue; - Time_t newValue; + BOOL doChange) +{ + STATUS status = zOK; + Time_t oldValue; + Time_t newValue; utf8_t *oldValueStr; utf8_t *newValueStr; - + status = getModifyValue(genMsg, element, &oldValueStr, &newValueStr); - if (status != zOK) - { - return status; - } + if (status != zOK) + { + return status; + } - if (!newValueStr || !oldValueStr) - { - SetErrno(genMsg, zERR_XML_IS_BAD); - status = zFAILURE; + if (!newValueStr || !oldValueStr) + { + SetErrno(genMsg, zERR_XML_IS_BAD); + status = zFAILURE; goto Exit; - } + } - oldValue = UniversalStr2utcTime(oldValueStr); - newValue = UniversalStr2utcTime(newValueStr); + oldValue = UniversalStr2utcTime(oldValueStr); + newValue = UniversalStr2utcTime(newValueStr); - setNumberValueXML(genMsg, beast, Time_t, address, NULL); + setNumberValueXML(genMsg, beast, Time_t, address, NULL); Exit: return status; @@ -3767,8 +3764,8 @@ STATUS modifyTimeXML( BOOL doChange) { STATUS status; - - const TagRequest_s tags[] = + + const TagRequest_s tags[] = { {TAG_UTC, TR_OPTIONAL}, {TAG_STRING, TR_OPTIONAL}, @@ -3795,7 +3792,7 @@ STATUS modifyTimeXML( } else if (tagContent[STRING].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - status = modifyInfoTimeStr(genMsg, beast, address, &tagContent[STRING].element, xaction, doChange); + status = modifyInfoTimeStr(genMsg, beast, address, &tagContent[STRING].element, xaction, doChange); } Exit: @@ -3804,30 +3801,30 @@ Exit: STATUS modifyInfoIDName( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, void *beast, - ADDR address, - XML_ElementInfo_s *element, + ADDR address, + XML_ElementInfo_s *element, Xaction_s *xaction, - BOOL doChange) -{ - STATUS status = zOK; - UserID_t oldValue; - UserID_t newValue; + BOOL doChange) +{ + STATUS status = zOK; + UserID_t oldValue; + UserID_t newValue; utf8_t *oldValueStr; utf8_t *newValueStr; - + status = getModifyValue(genMsg, element, &oldValueStr, &newValueStr); - if (status != zOK) - { - return status; - } - - if (!newValueStr || !oldValueStr) - { - SetErrno(genMsg, zERR_XML_IS_BAD); - return zFAILURE; - } + if (status != zOK) + { + return status; + } + + if (!newValueStr || !oldValueStr) + { + SetErrno(genMsg, zERR_XML_IS_BAD); + return zFAILURE; + } if ((status = MNSS_GetGUIDFromName(oldValueStr, &oldValue)) != zOK) { @@ -3841,36 +3838,36 @@ STATUS modifyInfoIDName( return zFAILURE; } - setNumberValueXML(genMsg, beast, UserID_t, address, NULL); + setNumberValueXML(genMsg, beast, UserID_t, address, NULL); return status; } STATUS modifyInfoIDStr( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, void *beast, - ADDR address, - XML_ElementInfo_s *element, + ADDR address, + XML_ElementInfo_s *element, Xaction_s *xaction, - BOOL doChange) -{ - STATUS status = zOK; - UserID_t oldValue; - UserID_t newValue; + BOOL doChange) +{ + STATUS status = zOK; + UserID_t oldValue; + UserID_t newValue; utf8_t *oldValueStr; utf8_t *newValueStr; - + status = getModifyValue(genMsg, element, &oldValueStr, &newValueStr); - if (status != zOK) - { - return status; - } + if (status != zOK) + { + return status; + } - if (!newValueStr || !oldValueStr) - { - SetErrno(genMsg, zERR_XML_IS_BAD); - return zFAILURE; - } + if (!newValueStr || !oldValueStr) + { + SetErrno(genMsg, zERR_XML_IS_BAD); + return zFAILURE; + } if ((status = LB_GUIDFromUTF8(oldValueStr, &oldValue)) != zOK) { @@ -3884,7 +3881,7 @@ STATUS modifyInfoIDStr( return zFAILURE; } - setNumberValueXML(genMsg, beast, UserID_t, address, NULL); + setNumberValueXML(genMsg, beast, UserID_t, address, NULL); return status; } @@ -3898,8 +3895,8 @@ STATUS modifyIDXML( BOOL doChange) { STATUS status; - - const TagRequest_s tags[] = + + const TagRequest_s tags[] = { {TAG_NAME, TR_OPTIONAL}, {TAG_ID, TR_OPTIONAL}, @@ -3922,13 +3919,13 @@ STATUS modifyIDXML( status = zOK; if (tagContent[NAME].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - status = modifyInfoIDName(genMsg, beast, address, &tagContent[NAME].element, xaction, doChange); - + status = modifyInfoIDName(genMsg, beast, address, &tagContent[NAME].element, xaction, doChange); + } else if (tagContent[ID].flags == (TR_TAG_FOUND | TR_CONTENT_FOUND)) { - - status = modifyInfoIDStr(genMsg, beast, address, &tagContent[ID].element, xaction, doChange); + + status = modifyInfoIDStr(genMsg, beast, address, &tagContent[ID].element, xaction, doChange); } return status; @@ -3936,30 +3933,30 @@ STATUS modifyIDXML( STATUS modifyInfoBOOL( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, void *beast, - ADDR address, - XML_ElementInfo_s *element, + ADDR address, + XML_ElementInfo_s *element, Xaction_s *xaction, - BOOL doChange) -{ - STATUS status = zOK; - BOOL oldValue = FALSE; + BOOL doChange) +{ + STATUS status = zOK; + BOOL oldValue = FALSE; BOOL newValue = FALSE; utf8_t *oldValueStr; utf8_t *newValueStr; - + status = getModifyValue(genMsg, element, &oldValueStr, &newValueStr); - if (status != zOK) - { + if (status != zOK) + { return status; - } + } - if (!newValueStr || !oldValueStr) - { - SetErrno(genMsg, zERR_XML_IS_BAD); - return zFAILURE; - } + if (!newValueStr || !oldValueStr) + { + SetErrno(genMsg, zERR_XML_IS_BAD); + return zFAILURE; + } if (!stricmp(oldValueStr, MSGNot("true"))) { @@ -3971,7 +3968,7 @@ STATUS modifyInfoBOOL( newValue = TRUE; } - setNumberValueXML(genMsg, beast, BOOL, address, NULL); + setNumberValueXML(genMsg, beast, BOOL, address, NULL); return status; } diff --git a/src/nwnss/sharedsrc/ndp_comn.c.h b/src/nwnss/sharedsrc/ndp_comn.c.h index 27036a0..f4f8a3f 100644 --- a/src/nwnss/sharedsrc/ndp_comn.c.h +++ b/src/nwnss/sharedsrc/ndp_comn.c.h @@ -1601,3 +1601,4 @@ void ndp_deregisterGuid( return; } /* ndp_deregisterGuid() */ EXPORT_SYMBOL(ndp_deregisterGuid); + diff --git a/src/nwnss/sharedsrc/ndp_guids.c.h b/src/nwnss/sharedsrc/ndp_guids.c.h index be0e08e..4ea201c 100644 --- a/src/nwnss/sharedsrc/ndp_guids.c.h +++ b/src/nwnss/sharedsrc/ndp_guids.c.h @@ -48,3 +48,4 @@ GUID_t ndpAppGuid = { 0xdd698a15, 0x9e44, 0x4317, 0x91, 0x95, { 0x5b, 0x04, 0x99 /* 4B1F2770-DE5E-4482-8E52-70D86EFE990C */ GUID_t ndpModGuid = { 0x4b1f2770, 0xde5e, 0x4482, 0x8e, 0x52, { 0x70, 0xd8, 0x6e, 0xfe, 0x99, 0x0c } }; + diff --git a/src/nwnss/sharedsrc/ndp_idbroker.c.h b/src/nwnss/sharedsrc/ndp_idbroker.c.h index 299eab5..b86a66b 100644 --- a/src/nwnss/sharedsrc/ndp_idbroker.c.h +++ b/src/nwnss/sharedsrc/ndp_idbroker.c.h @@ -56,10 +56,8 @@ # include # include # include -# ifndef NSS_USERSPACE -# include /* dlerror(), dlopen(), dlsym(), dlclose() */ -# include -# endif +# include /* dlerror(), dlopen(), dlsym(), dlclose() */ +# include #endif /* Timeout(s) specified in seconds */ @@ -301,7 +299,7 @@ static ndpIdBrokerInfo_t ndpIdBrokerInfo[] = * The NDP ID Broker Message Handling Routine * These routines run in their own threads... ******************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ void *ndp_idBroker_messagehandler( THREAD thread, void *_threadContext) @@ -556,7 +554,7 @@ void *ndp_idBroker_messagehandler( * Dynamically linked libraries & functions we need *****************************************************************************/ -#if !defined(__KERNEL__) && !defined(NSS_USERSPACE) +#ifndef __KERNEL__ /* The following is a deriviation of info from Alexander Danoyan */ #ifdef __x86_64__ @@ -599,14 +597,14 @@ static int (*NCPMapGUIDToUID) static int (*NCPMapUIDToGUID) (const LONG uid, GUID_t *guid) = NULL; -#endif /* ! __KERNEL__ && ! NSS_USERSPACE */ +#endif /* ! __KERNEL__ */ /***************************************************************************** * Bind dynamically linked libraries & functions we need *****************************************************************************/ void ndp_bind_idbroker_functions() { -#if !defined(__KERNEL__) && !defined(NSS_USERSPACE) +#ifndef __KERNEL__ char *error; ndpDbgPrintf(2, "ndp_bind_idbroker_functions(Enter)\n"); @@ -726,7 +724,7 @@ void ndp_bind_idbroker_functions() } ndpDbgPrintf(2, "ndp_bind_idbroker_functions(Leave)\n"); -#endif /* ! __KERNEL__ && ! NSS_USERSPACE */ +#endif /* ! __KERNEL__ */ return; } /* ndp_bind_idbroker_functions() */ @@ -735,7 +733,7 @@ void ndp_bind_idbroker_functions() *****************************************************************************/ void ndp_unbind_idbroker_functions() { -#if !defined(__KERNEL__) && !defined(NSS_USERSPACE) +#ifndef __KERNEL__ ndpDbgPrintf(2, "ndp_unbind_idbroker_functions(Enter)\n"); /* * Unbind the PAM/NAM library and the functions we use @@ -765,7 +763,7 @@ void ndp_unbind_idbroker_functions() dlclose(idbroker_handle); } ndpDbgPrintf(2, "ndp_unbind_idbroker_functions(Leave)\n"); -#endif /* ! __KERNEL__ && ! NSS_USERSPACE */ +#endif /* ! __KERNEL__ */ return; } /* ndp_unbind_idbroker_functions() */ @@ -842,7 +840,7 @@ int ndp_init_idBroker(void) sts = pthread_create( &ndpIdBrokerInfo[g].thread, NULL, - (void *(*)(void *))ndp_idBroker_messagehandler, + ndp_idBroker_messagehandler, &ndpIdBrokerInfo[g].threadContext); // if (sts) { // /* Thread Creation Error */ @@ -910,7 +908,7 @@ int ndp_cleanup_idBroker(void) * K2U nnn * U2K nnnnnnccc *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_namGetUserFDNfromUID( int uid, unicode_t **userFDN) @@ -1076,7 +1074,7 @@ int ndp_namGetUserFDNfromUID_handler( if (*ldapPtr == ',') { ++ldapPtr; /* skip leading comma */ } - + /* Copy the LDAP string to the eDir string, one character at a time. * Converting any special char escape sequences to eDir syntax. */ @@ -1119,14 +1117,14 @@ int ndp_namGetUserFDNfromUID_handler( break; } break; - + case '.': case '+': /* These characters, if not escaped in LDAP, DO need to * be escaped in eDir. Add a leading '\' to them. */ *eDirPtr++ = '\\'; - *eDirPtr++ = *ldapPtr++; + *eDirPtr++ = *ldapPtr++; break; case '=': @@ -1141,10 +1139,10 @@ int ndp_namGetUserFDNfromUID_handler( if (skippedEquals) { /* Already skipped first '='. Put '\' in front of this*/ *eDirPtr++ = '\\'; - *eDirPtr++ = *ldapPtr++; + *eDirPtr++ = *ldapPtr++; } else { /* This is the first '='. Don't add '\' in front */ - *eDirPtr++ = *ldapPtr++; + *eDirPtr++ = *ldapPtr++; skippedEquals = TRUE; } break; @@ -1225,7 +1223,7 @@ int ndp_namGetUserFDNfromUID_handler( * K2U nnnccc * U2K nnnccchex *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPMapDNToGUID( int create, unicode_t *dn, @@ -1244,7 +1242,7 @@ int ndp_NCPMapDNToGUID( utf8_t *dnUtf8 = NULL; NDP_NCPMapDNToGUID_count++; - + ndpDbgPrintf(1, "ndp_NCPMapDNToGUID(Enter)\n"); /* Generate a new random Guid (for this session) & register it */ @@ -1402,7 +1400,7 @@ SendResponse: * K2U nnn * U2K nnnccc *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPLocalTreeName( size_t treeNameSize, /* This is buffer size in bytes */ unicode_t *treeName) @@ -1418,7 +1416,7 @@ int ndp_NCPLocalTreeName( LONG sts = 0; NDP_NCPLocalTreeName_count++; - + ndpDbgPrintf(1, "ndp_NCPLocalTreeName(Enter)\n"); /* Generate a new random Guid (for this session) & register it */ @@ -1581,7 +1579,7 @@ SendResponse: * U2K nnncccnnn * hex,... *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPMapDNToSEV( unicode_t *dn, size_t *_guidSEVCount, @@ -1604,7 +1602,7 @@ int ndp_NCPMapDNToSEV( int utf8Len; NDP_NCPMapDNToSEV_count++; - + ndpDbgPrintf(1, "ndp_NCPMapDNToSEV(Enter)\n"); /* Generate a new random Guid (for this session) & register it */ @@ -1850,7 +1848,7 @@ SendResult: * U2K nnnhex * nnn *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPMapGUIDToMgtLevel( size_t numAuthenticatedIDs, GUID_t *authenticatedIDs, @@ -1870,7 +1868,7 @@ int ndp_NCPMapGUIDToMgtLevel( unsigned char objhexguid[HEXGUIDSIZE]; NDP_NCPMapGUIDToMgtLevel_count++; - + ndpDbgPrintf(1, "ndp_NCPMapGUIDToMgtLevel(Enter, numAuthenticatedIDs=%d, objectID=%08lx-%04x-%04x-%02x-%02x-%02x%02x%02x%02x%02x%02x\n", numAuthenticatedIDs, objectID->timeLow, objectID->timeMid, @@ -1969,7 +1967,7 @@ int ndp_NCPMapGUIDToMgtLevel_handler( status = ndp_getXmlTagValueLong("authidcount", (utf8_t *)data, length, &numAuthenticatedIDs); ndpDbgPrintf(2, "ndp_NCPMapGUIDToMgtLevel_handler(numAuthIds=%d)\n",numAuthenticatedIDs); - if (numAuthenticatedIDs > 0) { + if (numAuthenticatedIDs > 0) { authenticatedIDs = (GUID_t *)ndpMalloc (numAuthenticatedIDs * sizeof(GUID_t), GFP_KERNEL); if (authenticatedIDs) { @@ -1979,7 +1977,7 @@ int ndp_NCPMapGUIDToMgtLevel_handler( * but merely expecting things to be "right". */ status = ndp_getXmlTagValueString("authid", (utf8_t *)data, length, &hexguids); - + for ( i = 0; i < numAuthenticatedIDs; i++) { ndp_hex2guid(&hexguids[i * HEXGUIDSIZE], &authenticatedIDs[i]); ndpDbgPrintf(2, "ndp_NCPMapGUIDToMgtLevel_handler(authID(%d): %08lx-%04x-%04x-%02x-%02x-%02x%02x%02x%02x%02x%02x)\n", @@ -2083,7 +2081,7 @@ SendResult: * K2U hexnnn * U2K nnnhexccc *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPMapGUIDToDN( GUID_t *guid, size_t dnSize, @@ -2202,7 +2200,7 @@ int ndp_NCPMapGUIDToDN_handler( /* Parent Process */ if (dn) { ndpFree(dn); - } + } if (hexguid) { ndpFree(hexguid); } @@ -2253,7 +2251,7 @@ SendResult: /* Free the allocated memory */ if (dn) { ndpFree(dn); - } + } if (utf8Dn) { ndpFree(utf8Dn); } @@ -2276,7 +2274,7 @@ SendResult: * K2U hex * U2K nnnhexnnn *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPMapGUIDToUID( GUID_t *guid, LONG *uid) @@ -2292,7 +2290,7 @@ int ndp_NCPMapGUIDToUID( unsigned char hexguid[HEXGUIDSIZE]; NDP_NCPMapGUIDToUID_count++; - + ndpDbgPrintf(1, "ndp_NCPMapGUIDToUID(Enter)\n"); /* Generate a new random Guid (for this session) & register it */ @@ -2419,7 +2417,7 @@ int ndp_NCPMapGUIDToUID_handler( * K2U nnn * U2K nnnnnnhex *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPMapUIDToGUID( LONG uid, GUID_t *guid) @@ -2435,7 +2433,7 @@ int ndp_NCPMapUIDToGUID( unsigned char *hexguid; NDP_NCPMapUIDToGUID_count++; - + ndpDbgPrintf(1, "ndp_NCPMapUIDToGUID(Enter)\n"); /* Generate a new random Guid (for this session) & register it */ @@ -2553,7 +2551,7 @@ int ndp_NCPMapUIDToGUID_handler( * K2U ccc * U2K nnncccnnn *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_GetUIDFromName( unsigned char *name, LONG *uid) @@ -2790,7 +2788,7 @@ utf8_t *ndp_UnManglePassword( * U2K nnnccchex

hex

*
*****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_GenerateVolumeKeyInfo( unicode_t *volumePassword, BYTE *retKey, /* ptr to 16 byte buffer to receive the new key */ @@ -2809,7 +2807,7 @@ int ndp_GenerateVolumeKeyInfo( int utf8Len; NDP_GenerateData_count++; - + ndpDbgPrintf(1, "ndp_GenerateData(Enter)\n"); /* Generate a new random Guid (for this session) & register it */ @@ -2830,7 +2828,7 @@ int ndp_GenerateVolumeKeyInfo( retval = -ENOMEM; goto functionExit; } - + ndp_printfToGuid(3, /* Don't log this message because it contains a password */ &sidGuidPrime, &ndpIdBrokerInfo[IDBG_GenerateVolumeKeyInfo].guid, @@ -2997,7 +2995,7 @@ SendResult: * K2U ccc

hex

* U2K nnnccchex *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_ExtractVolumeKeyInfo( unicode_t *volumePassword, BYTE *volP, /* ptr to 128 byte persistent portion of VolumeKey_s */ @@ -3017,7 +3015,7 @@ int ndp_ExtractVolumeKeyInfo( unsigned char *hexP = NULL; NDP_ExtractData_count++; - + ndpDbgPrintf(1, "ndp_ExtractData(Enter)\n"); /* Generate a new random Guid (for this session) & register it */ @@ -3089,10 +3087,10 @@ functionExit: if (utf8Pw) { memset(utf8Pw, 0, strlen(utf8Pw)); ndpFree(utf8Pw); - } + } if (hexP) { ndpFree(hexP); - } + } /* DeRegister our random Guid (for this session) */ ndp_deregisterGuid(&sidGuidPrime); @@ -3217,7 +3215,7 @@ SendResult: * if already registered (-2) * if invalid function pointer (-1) *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ void (*ndp_NCPNotifyDNChange)(unicode_t *oldDN, unicode_t *newDN) = NULL; int ndp_register_NCPNotifyDNChange( @@ -3248,7 +3246,7 @@ EXPORT_SYMBOL(ndp_register_NCPNotifyDNChange); * K2U ... N/A (no return value) ... * U2K cccccc *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPNotifyDNChange_handler( GUID_t *srcGuid, LONG length, @@ -3315,7 +3313,7 @@ int ndp_NCPNotifyDNChange_handler( * if already registered (-2) * if invalid function pointer (-1) *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ void (*ndp_NCPNotifySEVChange)(GUID_t *changedGUID) = NULL; int ndp_register_NCPNotifySEVChange( @@ -3345,7 +3343,7 @@ EXPORT_SYMBOL(ndp_register_NCPNotifySEVChange); * K2U ... N/A (no return value) ... * U2K hex *****************************************************************************/ -#if defined(__KERNEL__) || defined(NSS_USERSPACE) +#ifdef __KERNEL__ int ndp_NCPNotifySEVChange_handler( GUID_t *srcGuid, LONG length, @@ -3379,3 +3377,4 @@ int ndp_NCPNotifySEVChange_handler( #endif #endif /* BUILD_NDP_IDBROKER */ + diff --git a/src/nwnss/sharedsrc/ndp_messagehandler.c.h b/src/nwnss/sharedsrc/ndp_messagehandler.c.h index 27abd6b..5bfc460 100644 --- a/src/nwnss/sharedsrc/ndp_messagehandler.c.h +++ b/src/nwnss/sharedsrc/ndp_messagehandler.c.h @@ -294,7 +294,7 @@ void ndp_messagehandler( data); } } else if (ndpContext) { - sts = ndp_readFromGuid(13, &THISGUIDPRIME, srcGuid, &length, &data); + sts = ndp_readFromGuid(13, &THISGUIDPRIME, srcGuid, &length, &data); if (sts == 0) { /* Skip past any white space */ data = ndp_SkipWhitespace(data, &length); @@ -354,3 +354,4 @@ void ndp_messagehandler( ndpDbgPrintf(13, "ndp_messagehandler(Leave)\n"); return; } /* ndp_messagehandler() */ + diff --git a/src/nwnss/sharedsrc/otherErrorTables.c.h b/src/nwnss/sharedsrc/otherErrorTables.c.h index e1337ba..efb43c6 100644 --- a/src/nwnss/sharedsrc/otherErrorTables.c.h +++ b/src/nwnss/sharedsrc/otherErrorTables.c.h @@ -38,7 +38,7 @@ #include "nssErrorTable.h" #if zNETWARE -ErrorTable_s MM_ErrorTable[] = +ErrorTable_s MM_ErrorTable[] = { /* Numbers MUST be in order (except for last entry which has a 0) */ {0x00000001, "MM_INVALID_OBJECT"}, @@ -145,7 +145,7 @@ ErrorTable_s MM_ErrorTable[] = }; #endif -ErrorTableSigned_s NDS_ErrorTable[] = +ErrorTableSigned_s NDS_ErrorTable[] = { /* Numbers MUST be in order (except for last entry which has a 0) */ {-6043, "ERR_OP_IN_PROGRESS" }, @@ -589,3 +589,4 @@ ErrorTableSigned_s NDS_ErrorTable[] = {0, "End of table"} }; + diff --git a/src/nwnss/sharedsrc/parseDSObjectName.c.h b/src/nwnss/sharedsrc/parseDSObjectName.c.h index 375ac53..6a073e7 100644 --- a/src/nwnss/sharedsrc/parseDSObjectName.c.h +++ b/src/nwnss/sharedsrc/parseDSObjectName.c.h @@ -72,7 +72,7 @@ void LB_ParseDSObjectName( if (rootLeft) { /* divide the server name into the container part and the object name */ - for (objectIndex = strlen(fullName) - 1; objectIndex >= 0; + for (objectIndex = strlen(fullName) - 1; objectIndex >= 0; objectIndex--) { if (((char *)fullName)[objectIndex] == '=' || @@ -83,7 +83,7 @@ void LB_ParseDSObjectName( /* * Find to the container where the server object is found. */ - for (endContainer = objectIndex; endContainer >= 0; + for (endContainer = objectIndex; endContainer >= 0; endContainer--) { if (((char *)fullName)[endContainer] == '\\') @@ -130,7 +130,7 @@ void LB_ParseDSObjectName( { if (objectName) { - memcpy(objectName, &fullName[startIndex], + memcpy(objectName, &fullName[startIndex], objectIndex - startIndex); objectName[objectIndex - startIndex] = '\0'; } @@ -190,4 +190,5 @@ void LB_ParseDSObjectName( } } } -} +} + diff --git a/src/nwnss/sharedsrc/que.c.h b/src/nwnss/sharedsrc/que.c.h index fcf8704..9c946cd 100644 --- a/src/nwnss/sharedsrc/que.c.h +++ b/src/nwnss/sharedsrc/que.c.h @@ -40,13 +40,13 @@ #endif #if zNETWARE || (zLINUX && defined(__KERNEL__)) -#include /* NetWare Includes */ -#include /* NSS Library Includes */ +#include "procdefs.h" /* NetWare Includes */ +#include /* NSS Library Includes */ #else #include #endif -#include +#include BOOL DoDQAudit = FALSE; @@ -61,8 +61,7 @@ int LBQ_QAssertError (char *msg, Link_t item) { static char assertmsg[] = MSGNot("\tQASSERT ERROR: %s item=0x%x next=0x%x\n"); - if (NSS_QAssertErrorCallback && - ((BOOL (*)(char *, Link_t))NSS_QAssertErrorCallback)(msg, item)) + if (NSS_QAssertErrorCallback && NSS_QAssertErrorCallback(msg, item)) { return FALSE; } @@ -750,7 +749,7 @@ void LBQ_DQdrop (DQhead_t *head) void LBQ_DQrmv (DQlink_t *item) { - if ((item->prev->next != item) || (item->next->prev != item)) + if ((item->prev->next != item) || (item->next->prev != item)) { QueueAbend("DQ_RMV would cause memory corruption"); } @@ -996,7 +995,7 @@ STATUS LBQ_SETapply (SEThead_t *head, statusfunc_t userFunction, void *userArgs) if (SET_LT(item, &dummy)) { dummy.setNum = item->setNum; - status = ((STATUS (*)(SETlink_t *, void *))userFunction)(item, userArgs); + status = userFunction(item, userArgs); if (status != zOK) { return status; diff --git a/src/nwnss/sharedsrc/sysimp.c.h b/src/nwnss/sharedsrc/sysimp.c.h index 0b20333..501266a 100644 --- a/src/nwnss/sharedsrc/sysimp.c.h +++ b/src/nwnss/sharedsrc/sysimp.c.h @@ -39,14 +39,11 @@ #include #include #endif -#if zLINUX && !defined(__KERNEL__) && !defined(NSS_USERSPACE) +#if zLINUX && !defined(__KERNEL__) #include #include #include #endif -#if zLINUX && !defined(__KERNEL__) && defined(NSS_USERSPACE) -#include -#endif #if zNETWARE # include @@ -57,20 +54,6 @@ #include #include #include -#if defined(NSS_USERSPACE) -#ifndef DDSAPI -#define DDSAPI -#endif -typedef UINT32 uint32; -typedef UINT32 s_uint32; -typedef unicode_t unicode; -typedef void *DDSEventHandler; -typedef void DDCString; -typedef void DDCVALUE; -typedef void DDCReadFilter; -typedef void DDCListFilter; -typedef void (*DDCReadCB)(void); -#endif #if zLINUX #include extern void syslog(int __pri, __const char *__fmt, ...) @@ -79,15 +62,15 @@ extern void syslog(int __pri, __const char *__fmt, ...) #if zNETWARE || (zLINUX && defined(__KERNEL__)) THREAD (*kStartThreadWithModuleHandlePtr)( - BYTE *pThreadName, + BYTE *pThreadName, void *(*StartAddress)(THREAD, void *), - void *StackAddressHigh, - LONG StackSize, - void *Argument, + void *StackAddressHigh, + LONG StackSize, + void *Argument, LONG ModuleHandle) = NULL; #endif -#ifndef __linux__ +#ifndef __linux__ LONG *NW_NumberOfVolumes = NULL; struct LocaleTableStruct *NW_LocaleTable = NULL; @@ -98,7 +81,7 @@ void (*(*NW_SwitchVector)[256])() = NULL; struct ResourceTagStructure *NW_OSGeneralWorkAllocTag = NULL; struct LoadDefinitionStructure **NW_OSHandle = NULL; -NetWareAlertStructure *NW_StationAttemptedToUseBadPacket = NULL; +NetWareAlertStructure *NW_StationAttemptedToUseBadPacket = NULL; NetWareAlertStructure *NW_StationUsedBadPacket = NULL; NetWareAlertStructure *NW_NCPHasBadSubFunctionLength = NULL; NetWareAlertStructure *NW_NCPUsedBadSubFunctionLength = NULL; @@ -325,7 +308,7 @@ void UnimportNSSPublics(void) *(p->address) = 0; /* mark as not imported */ } } -} +} #if zLINUX && defined(__KERNEL__) EXPORT_SYMBOL(UnimportNSSPublics); #endif @@ -381,7 +364,7 @@ STATIC void UnimportNetWarePublics( pubs->address = 0; /* mark no import */ // } } -} +} /************************************************************************** * This is a local routine that will import the given list of publics. @@ -429,7 +412,7 @@ STATIC STATUS ImportNetWarePublics( } } return zOK; -} +} @@ -505,7 +488,7 @@ void LB_UnimportOptionalUnixlibStuff(void) /* If unixlib is being unloaded, but the use count is non-zero, * don't unimport the symbol. This causes the unixlib unload to * fail. They will have to try to unload it later when the API - * is no longer in use + * is no longer in use */ if ((UNIXLIB_isUnloading) && (UNIXLIB_useCount != 0)) @@ -520,7 +503,7 @@ void LB_UnimportOptionalUnixlibStuff(void) (BYTE *)UNIXLIB_MapDOSToNFSNew_APINAME); UNIXLIB_MapDOSToNFSforNewNSSFilePtr = NULL; - } + } } /*------------------------------------------------------------------------- @@ -627,7 +610,7 @@ STATUS LB_ImportNDSPublics(LONG handle) */ if (DDSGetLocalAgentInfoPtr == NULL) { - ZOS_ImportPublicSymbol(DDSGetLocalAgentInfoPtr, handle, + ZOS_ImportPublicSymbol(DDSGetLocalAgentInfoPtr, handle, (BYTE *)DDSGetLocalAgentInfoAPI); if (DDSGetLocalAgentInfoPtr == NULL) { @@ -1091,7 +1074,7 @@ STATUS LB_ImportNDSPublics(LONG handle) */ if (DDCConnectToReferralPtr == NULL) { - ZOS_ImportPublicSymbol(DDCConnectToReferralPtr, handle, + ZOS_ImportPublicSymbol(DDCConnectToReferralPtr, handle, (BYTE *)DDCConnectToReferralAPI); if (DDCConnectToReferralPtr == NULL) { @@ -1107,7 +1090,7 @@ STATUS LB_ImportNDSPublics(LONG handle) */ if (DDCContextEntryIDPtr == NULL) { - ZOS_ImportPublicSymbol(DDCContextEntryIDPtr, handle, + ZOS_ImportPublicSymbol(DDCContextEntryIDPtr, handle, (BYTE *)DDCContextEntryIDAPI); if (DDCContextEntryIDPtr == NULL) { @@ -1137,7 +1120,7 @@ STATUS LB_ImportNDSPublics(LONG handle) { NDSEventRegistered = TRUE; MPKNSS_UNLOCK(); - err = (DDSRegisterForEventPtr)(NDSEventHandlerHandle, DSEP_JOURNAL, + err = (DDSRegisterForEventPtr)(NDSEventHandlerHandle, DSEP_JOURNAL, DSE_RENAME_ENTRY, 2, NDSRenameEventFunc); MPKNSS_LOCK(); if (err) @@ -1150,7 +1133,7 @@ STATUS LB_ImportNDSPublics(LONG handle) DBG_DebugPrintf(YELLOW, "Event Handler registered for rename\n"); #endif MPKNSS_UNLOCK(); - err = (DDSRegisterForEventPtr)(NDSEventHandlerHandle, DSEP_JOURNAL, + err = (DDSRegisterForEventPtr)(NDSEventHandlerHandle, DSEP_JOURNAL, DSE_MOVE_SOURCE_ENTRY, 2, NDSRenameEventFunc); MPKNSS_LOCK(); if (err) @@ -1163,7 +1146,7 @@ STATUS LB_ImportNDSPublics(LONG handle) DBG_DebugPrintf(YELLOW, "Event Handler registered for move\n"); #endif MPKNSS_UNLOCK(); - err = (DDSRegisterForEventPtr)(NDSEventHandlerHandle, DSEP_JOURNAL, + err = (DDSRegisterForEventPtr)(NDSEventHandlerHandle, DSEP_JOURNAL, DSE_DELETE_ENTRY, 2, NDSDeleteEventFunc); MPKNSS_LOCK(); if (err) @@ -1177,15 +1160,11 @@ STATUS LB_ImportNDSPublics(LONG handle) #endif } #else -#if defined(NSS_USERSPACE) - NdsPublicsLoaded = FALSE; - return zFAILURE; -#else #if !defined(__KERNEL__) DDSInit((SAL_ModHandle)(long) getpid()); #else DDSInit((uint32) getpid()); -#endif +#endif #ifndef __linux__ DDSGetLocalAgentInfoPtr = DDSGetLocalAgentInfo; DDSGetLocalEntryNamePtr = DDSGetLocalEntryName; @@ -1224,7 +1203,6 @@ STATUS LB_ImportNDSPublics(LONG handle) #endif DDCContextEntryIDPtr = DDCContextEntryID; DDCPingPtr = DDCPing; -#endif #endif NdsPublicsLoaded = TRUE; @@ -1249,12 +1227,12 @@ void LB_UnimportNDSPublics(LONG handle) { (DDSUnRegisterForEventPtr)(DSEP_JOURNAL, DSE_RENAME_ENTRY, NDSRenameEventFunc); - (DDSUnRegisterForEventPtr)(DSEP_JOURNAL, DSE_MOVE_SOURCE_ENTRY, + (DDSUnRegisterForEventPtr)(DSEP_JOURNAL, DSE_MOVE_SOURCE_ENTRY, NDSRenameEventFunc); } if (NDSDeleteEventFunc) { - (DDSUnRegisterForEventPtr)(DSEP_JOURNAL, DSE_DELETE_ENTRY, + (DDSUnRegisterForEventPtr)(DSEP_JOURNAL, DSE_DELETE_ENTRY, NDSDeleteEventFunc); } MPKNSS_LOCK(); @@ -1598,11 +1576,11 @@ void LB_UnimportNDSPublics(LONG handle) * of NCPIPX.NLM. When it loads it re-imports all Packet burst fields we * need access to. ***************************************************************************/ -STATIC LONG CheckForModuleLoadEventID = 0; +STATIC LONG CheckForModuleLoadEventID = 0; void CheckForModuleLoad(LONG moduleHandle) { - struct LoadDefinitionStructure *LoadRecord = + struct LoadDefinitionStructure *LoadRecord = ValidateModuleHandle(moduleHandle); if (LoadRecord == NULL) @@ -1642,14 +1620,14 @@ void CheckForModuleLoad(LONG moduleHandle) * of NCPIPX.NLM. When it loads it re-imports all Packet burst fields we * need access to. ***************************************************************************/ -STATIC LONG CheckForModuleUnloadEventID = 0; +STATIC LONG CheckForModuleUnloadEventID = 0; STATIC BOOL UnixlibUnimportedByCheckRoutine = FALSE; LONG WarnForModuleUnload( void (*OutputRoutine)(void *controlString,...), LONG moduleHandle) { - struct LoadDefinitionStructure *LoadRecord = + struct LoadDefinitionStructure *LoadRecord = ValidateModuleHandle(moduleHandle); if (LoadRecord == NULL) @@ -1673,7 +1651,7 @@ LONG WarnForModuleUnload( void CheckForModuleUnload( LONG moduleHandle) { - struct LoadDefinitionStructure *LoadRecord = + struct LoadDefinitionStructure *LoadRecord = ValidateModuleHandle(moduleHandle); if (LoadRecord == NULL) @@ -1698,7 +1676,7 @@ void CheckForModuleUnload( * of NCPIPX.NLM. When it loads it re-imports all Packet burst fields we * need access to. ***************************************************************************/ -STATIC LONG CheckForModuleUnloadFailedEventID = 0; +STATIC LONG CheckForModuleUnloadFailedEventID = 0; void CheckForModuleUnloadFailed( LONG moduleHandle) @@ -1714,7 +1692,7 @@ void CheckForModuleUnloadFailed( MPKNSS_LOCK(); - + if (strnicmp(LoadRecord->LDFileName, MSGNot("\xB" "UNIXLIB.NLM"), 0xB + 1) == 0) { if (UnixlibUnimportedByCheckRoutine) @@ -1790,17 +1768,17 @@ STATUS LB_InitializeSystemImports(void) /* Packet Burst stuff */ ImportOptionalPacketBurstStuff(); - /* Unixlib stuff */ + /* Unixlib stuff */ LB_ImportOptionalUnixlibStuff(); ZOS_EventNotificationReg(CheckForModuleLoadEventID, - EVENT_MODULE_LOAD, + EVENT_MODULE_LOAD, NULL, CheckForModuleLoad); ZOS_EventNotificationReg(CheckForModuleUnloadEventID, - EVENT_MODULE_UNLOAD, + EVENT_MODULE_UNLOAD, WarnForModuleUnload, CheckForModuleUnload); ZOS_EventNotificationReg(CheckForModuleUnloadFailedEventID, - EVENT_MODULE_UNLOAD_FAIL, + EVENT_MODULE_UNLOAD_FAIL, NULL, CheckForModuleUnloadFailed); if ((CheckForModuleLoadEventID == NULL) || (CheckForModuleUnloadEventID == NULL) || @@ -1811,12 +1789,12 @@ STATUS LB_InitializeSystemImports(void) "An internal error has occurred. Contact your Novell Technical Support Provider.", 122)); goto MBerrorCleanup_unimport; } - + /** MPK stuff */ MPKNSS_UNLOCK(); kStartThreadWithModuleHandlePtr = (THREAD (*)())ImportPublicSymbol( - (LONG)COMN_Resource.moduleHandle, (BYTE *)kStartThreadWithModuleHandleAPI); - MPKNSS_LOCK(); + (LONG)COMN_Resource.moduleHandle, (BYTE *)kStartThreadWithModuleHandleAPI); + MPKNSS_LOCK(); #endif return zOK; @@ -1829,7 +1807,7 @@ MBerrorCleanup_unimport: UnimportNetWarePublics(OptionalNCPPubs); UnimportNetWarePublics(OptionalMoabPubs); UnimportNetWarePublics(MoabPubs); - + return zFAILURE; #endif } @@ -1843,13 +1821,13 @@ void LB_UninitializeSystemImports(void) { #ifndef __linux__ // LINUX_NetWarePublics ASSERT_MPKNSS_LOCK(); - + if (kStartThreadWithModuleHandlePtr != NULL) { - ZOS_UnImportPublicSymbol((LONG)COMN_Resource.moduleHandle, - (BYTE *)kStartThreadWithModuleHandleAPI); + ZOS_UnImportPublicSymbol((LONG)COMN_Resource.moduleHandle, + (BYTE *)kStartThreadWithModuleHandleAPI); } - + UnimportNetWarePublics(MoabPubs); UnimportNetWarePublics(OptionalMoabPubs); UnimportNetWarePublics(OptionalNCPPubs); @@ -1878,3 +1856,4 @@ void LB_UninitializeSystemImports(void) #endif } #endif + diff --git a/src/nwnss/sharedsrc/uni2utf.c.h b/src/nwnss/sharedsrc/uni2utf.c.h index b3da529..c3fabb1 100644 --- a/src/nwnss/sharedsrc/uni2utf.c.h +++ b/src/nwnss/sharedsrc/uni2utf.c.h @@ -32,7 +32,7 @@ | |--------------------------------------------------------------------------- | This module is used to: - | + | +-------------------------------------------------------------------------*/ /* @@ -62,7 +62,7 @@ * Unicode string. */ -#include +#include #if zLINUX && !defined(__KERNEL__) diff --git a/src/nwnss/sharedsrc/unicat.c.h b/src/nwnss/sharedsrc/unicat.c.h index aa2f0ed..7d1e171 100644 --- a/src/nwnss/sharedsrc/unicat.c.h +++ b/src/nwnss/sharedsrc/unicat.c.h @@ -34,7 +34,7 @@ | This module is used to: | NSS Library Routine code taken from LibC in August 2003 +-------------------------------------------------------------------------*/ -#include +#include unicode_t *LB_unicat ( diff --git a/src/nwnss/sharedsrc/unicmp.c.h b/src/nwnss/sharedsrc/unicmp.c.h index 044673f..7fd4d09 100644 --- a/src/nwnss/sharedsrc/unicmp.c.h +++ b/src/nwnss/sharedsrc/unicmp.c.h @@ -34,7 +34,7 @@ | This module is used to: | NSS Library Routine code taken from LibC in August 2003 +-------------------------------------------------------------------------*/ -#include +#include int LB_unicmp ( @@ -73,3 +73,4 @@ int LB_unincmp return ((n == 0) ? 0 : (*s1 - *s2)); } + diff --git a/src/nwnss/sharedsrc/unicpy.c.h b/src/nwnss/sharedsrc/unicpy.c.h index ba24f0d..7d29b42 100644 --- a/src/nwnss/sharedsrc/unicpy.c.h +++ b/src/nwnss/sharedsrc/unicpy.c.h @@ -34,7 +34,7 @@ | This module is used to: | NSS Library Routine +-------------------------------------------------------------------------*/ -#include +#include /************************************************************************** * Copy string s2 to s1. s1 must be large enough. @@ -62,7 +62,7 @@ unicode_t *LB_unincpy { register unicode_t *base = t; - n++; + n++; while (--n > 0 && (*t++ = *s++)) ; diff --git a/src/nwnss/sharedsrc/unilen.c.h b/src/nwnss/sharedsrc/unilen.c.h index 276e8a7..2b5756e 100644 --- a/src/nwnss/sharedsrc/unilen.c.h +++ b/src/nwnss/sharedsrc/unilen.c.h @@ -35,9 +35,9 @@ | This is a temporary routine to emulate what the real unicode_t | routines will do. +-------------------------------------------------------------------------*/ -#include +#include #if defined(_WATCOMC_) -#include +#include #endif /************************************************************************** diff --git a/src/nwnss/sharedsrc/unimcpy.c.h b/src/nwnss/sharedsrc/unimcpy.c.h index c2f6195..da8fc65 100644 --- a/src/nwnss/sharedsrc/unimcpy.c.h +++ b/src/nwnss/sharedsrc/unimcpy.c.h @@ -35,7 +35,7 @@ | This is a temporary routine to emulate what the real unicode_t | routines will do. +-------------------------------------------------------------------------*/ -#include +#include /************************************************************************** * This will copy the source string to the destination string and will @@ -61,5 +61,6 @@ unicode_t *LB_unimcpy( if ((*ldest++ = (unicode_t)*src++) == 0) break; } - return dest; + return dest; } + diff --git a/src/nwnss/sharedsrc/utf2uni.c.h b/src/nwnss/sharedsrc/utf2uni.c.h index e713389..a122853 100644 --- a/src/nwnss/sharedsrc/utf2uni.c.h +++ b/src/nwnss/sharedsrc/utf2uni.c.h @@ -62,7 +62,7 @@ * Unicode string. */ -#include +#include #if zLINUX && !defined(__KERNEL__) NINT LB_utf2uni ( /* Return: -1 = err, else # uni chars in dest. */ diff --git a/src/nwnss/sharedsrc/virtualIO.c.h b/src/nwnss/sharedsrc/virtualIO.c.h index 5e09ac4..9d67043 100644 --- a/src/nwnss/sharedsrc/virtualIO.c.h +++ b/src/nwnss/sharedsrc/virtualIO.c.h @@ -42,15 +42,12 @@ #endif #include -#include -#if zNETWARE || (zLINUX && defined(__KERNEL__)) || defined(NSS_VIRTUAL_IO) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) #include #include #include -#if !defined(NSS_USERSPACE) #include -#endif #include #endif @@ -66,23 +63,22 @@ #include #include #include -#if zNETWARE || (zLINUX && defined(__KERNEL__)) || defined(NSS_VIRTUAL_IO) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) #include #endif #include "comnPublics.h" -#if zNETWARE || (zLINUX && defined(__KERNEL__)) || defined(NSS_VIRTUAL_IO) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) #include "comnTask.h" #include "nCache.h" #endif #include "virtualIO.h" -#if zNETWARE || (zLINUX && defined(__KERNEL__)) || defined(NSS_VIRTUAL_IO) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) #include "msgGen.h" #include "comnParams.h" #include "msgIO.h" #include "fileHandle.h" #include "comnBeasts.h" -#include "inst.h" #include "pssStartup.h" #include "xmlNSS.h" #include "zPublics.h" @@ -92,13 +88,12 @@ #include "mgmt.h" #include "msgName.h" #include "eventSys.h" -#include #endif #if zLINUX && !defined(__KERNEL__) #include #endif -#if zNETWARE || (zLINUX && defined(__KERNEL__)) || defined(NSS_VIRTUAL_IO) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) //#define VIRT_JAVA_DEBUG 1 BOOL VIRT_PrintDebug = FALSE; @@ -106,25 +101,6 @@ BOOL VIRT_PrintDebug = FALSE; #define VIRT_TEMP_BUFFER_LEN 20 -/* - * The original NSS virtual I/O template stores imported read/write callbacks - * in old K&R-style STATUS (*)() slots. Modern GCC treats those as functions - * with no prototype at the indirect call site, so userspace builds need the - * call signature restored explicitly where the callbacks are invoked. - */ -typedef STATUS (*VIRT_ReadFunction_t)(NINT parmLen, utf8_t *parm, - VirtInfo_s *virtInfo); -typedef STATUS (*VIRT_WriteFunction_t)(NINT parmLen, utf8_t *parm, - NINT dataLen, BYTE *data, NINT offset, VirtInfo_s *virtInfo); - -#define VIRT_CALL_READ_FUNCTION(_fn, _parmLen, _parm, _virtInfo) \ - ((VIRT_ReadFunction_t)(_fn))((_parmLen), (_parm), (_virtInfo)) - -#define VIRT_CALL_WRITE_FUNCTION(_fn, _parmLen, _parm, _dataLen, _data, \ - _offset, _virtInfo) \ - ((VIRT_WriteFunction_t)(_fn))((_parmLen), (_parm), (NINT)(_dataLen), \ - (_data), (NINT)(_offset), (_virtInfo)) - #if NSS_DEBUG IS_ENABLED #define VIRT_DBGPRINT if (VIRT_PrintDebug) DBG_DebugPrintf #else @@ -134,18 +110,8 @@ typedef STATUS (*VIRT_WriteFunction_t)(NINT parmLen, utf8_t *parm, QUAD AdminVolWrites = 0; QUAD AdminVolReads = 0; -#if defined(NSS_USERSPACE) -#undef ClearStatus -#define ClearStatus(_msg) \ - do { SetStatus((_msg), zOK); (_msg)->sys.where = (QUAD)(uintptr_t)(WHERE); } while (0) -#define VIRT_ZOS_MODULE_HANDLE 0 -#else -#define VIRT_ZOS_MODULE_HANDLE ((LONG)CMN_ModuleHandle) -#endif - //#define RPC_SERVICE_NAME "/tmp/_admin" -#if zNETWARE || (zLINUX && defined(__KERNEL__)) || defined(NSS_VIRTUAL_IO) void VIRT_BlockSignalHandler (Agent_s *agent) { Buffer_s *buf = STRUCT(agent,Buffer_s,agent); @@ -154,7 +120,6 @@ void VIRT_BlockSignalHandler (Agent_s *agent) defaultSignal(agent); CACHE_SIGNAL_RELEASE_TOSS(buf); } -#endif /**************************************************************************** * Returns the size of the packed virtual IO meta data for this beast @@ -219,7 +184,7 @@ void VIRT_UnimportSymbols( case VIRT_TYPE_LOCATION: if (compInfo->u.location.locSymPtr != NULL) { - ZOS_UnImportPublicSymbol(VIRT_ZOS_MODULE_HANDLE, + ZOS_UnImportPublicSymbol((LONG)CMN_ModuleHandle, &virtTemplate->names[compInfo->u.location.locSymIdx]); compInfo->u.location.locSymPtr = NULL; } @@ -229,13 +194,13 @@ void VIRT_UnimportSymbols( case VIRT_TYPE_FUNCTION: if (compInfo->u.function.readFunctionPtr != NULL) { - ZOS_UnImportPublicSymbol(VIRT_ZOS_MODULE_HANDLE, + ZOS_UnImportPublicSymbol((LONG)CMN_ModuleHandle, &virtTemplate->names[compInfo->u.function.readSymIdx]); compInfo->u.function.readFunctionPtr = NULL; } if (compInfo->u.function.writeFunctionPtr != NULL) { - ZOS_UnImportPublicSymbol(VIRT_ZOS_MODULE_HANDLE, + ZOS_UnImportPublicSymbol((LONG)CMN_ModuleHandle, &virtTemplate->names[compInfo->u.function.writeSymIdx]); compInfo->u.function.writeFunctionPtr = NULL; } @@ -391,7 +356,6 @@ STATIC BYTE *VIRT_FreeRootVariableData( #ifndef __linux__ // LINUX_VirtualFile // Parameter is the callback function passed to atexit -#if !defined(NSS_USERSPACE) void JavaShutdownCallback(LONG parameter, int exitStatus) { VirtInfo_s *virtInfo = (VirtInfo_s *)parameter; @@ -443,7 +407,6 @@ DBG_DebugPrintf(LGREEN, "yyy - handler finished\n"); MPKNSS_UNLOCK(); } -#endif #endif /**************************************************************************** @@ -579,7 +542,7 @@ STATUS VIRT_ImportSymbol( { zASSERT(virtTemplate->names[nameIdx]+2 < sizeof(name)); memcpy(name, &virtTemplate->names[nameIdx], virtTemplate->names[nameIdx]+2); - ZOS_ImportPublicSymbol(*funcPtr, VIRT_ZOS_MODULE_HANDLE, name); + ZOS_ImportPublicSymbol(*funcPtr, (LONG)CMN_ModuleHandle, name); if (*funcPtr == NULL) { VIRT_DBGPRINT(LRED, "VFS: Error importing symbol\n"); @@ -590,7 +553,7 @@ STATUS VIRT_ImportSymbol( return zOK; } -#if zLINUX && defined(__KERNEL__) +#if zLINUX /**************************************************************************** * * Get the size of the buffer needed to hold the marshalled user space data. @@ -971,20 +934,18 @@ void VIRT_CallKernelSpaceThread( MPKNSS_UNLOCK(); if (kernelInfo->readFlag) { - kernelInfo->status = VIRT_CALL_READ_FUNCTION( - compInfo->u.function.readFunctionPtr, + kernelInfo->status = compInfo->u.function.readFunctionPtr( compInfo->u.function.readParmLen, &virtTemplate->names[compInfo->u.function.readParmIdx], virtInfo); } else { - kernelInfo->status = VIRT_CALL_WRITE_FUNCTION( - compInfo->u.function.writeFunctionPtr, + kernelInfo->status = compInfo->u.function.writeFunctionPtr( compInfo->u.function.writeParmLen, &virtTemplate->names[compInfo->u.function.writeParmIdx], msg->sys.data[RW_DATA].length, - (BYTE *)(uintptr_t)msg->sys.data[RW_DATA].start, + (BYTE *)msg->sys.data[RW_DATA].start, offset, virtInfo); } @@ -1215,7 +1176,6 @@ void VIRT_WaitForRequester( * Call a Java method * ****************************************************************************/ -#if !defined(NSS_USERSPACE) void VIRT_CallJavaThread( THREAD threadID, FileHandle_s *fileHandle) @@ -1224,7 +1184,7 @@ void VIRT_CallJavaThread( VirtInfo_s *virtInfo; CompiledTemplate_s *compInfo; BOOL readFlag; - jint (*JNI_CreateJavaVMPtr)() = NULL; + jint (*JNI_CreateJavaVMPtr)() = NULL; #ifndef __linux__ // LINUX_VirtualFile int (*RegisterJavaClassExitCallbackPtr)() = NULL; int (*GetJavaClassIDPtr)() = NULL; @@ -1243,7 +1203,7 @@ void VIRT_CallJavaThread( jstring data; jstring connection; JavaVMOption options[1]; - utf8_t *parmString = NULL; + utf8_t *parmString = NULL; utf8_t *dataString = NULL; char *connectionString = NULL; NINT readClassPathLen; @@ -1276,7 +1236,7 @@ void VIRT_CallJavaThread( DBG_DebugPrintf(LCYAN, "xxx - continuing java thread. FH:0x%x\n", fileHandle); #endif #ifndef __linux__ // LINUX_VirtualFile - JNI_CreateJavaVMPtr = (void *)ImportPublicSymbol(VIRT_ZOS_MODULE_HANDLE, + JNI_CreateJavaVMPtr = (void *)ImportPublicSymbol((LONG)CMN_ModuleHandle, "\x10JNI_CreateJavaVM"); #endif if (JNI_CreateJavaVMPtr == NULL) @@ -1371,10 +1331,10 @@ void VIRT_CallJavaThread( jecs.callBackData = (LONG)virtInfo; jecs.callBackFlag = CLASS_EXIT_WARNING; - RegisterJavaClassExitCallbackPtr = (void *)ImportPublicSymbol(VIRT_ZOS_MODULE_HANDLE, + RegisterJavaClassExitCallbackPtr = (void *)ImportPublicSymbol((LONG)CMN_ModuleHandle, "\x1DRegisterJavaClassExitCallback"); - GetJavaClassIDPtr = (void *)ImportPublicSymbol(VIRT_ZOS_MODULE_HANDLE, + GetJavaClassIDPtr = (void *)ImportPublicSymbol((LONG)CMN_ModuleHandle, "\x0EGetJavaClassID"); if (RegisterJavaClassExitCallbackPtr == NULL || @@ -1657,17 +1617,17 @@ exitThread: #ifndef __linux__ // LINUX_VirtualFile if (JNI_CreateJavaVMPtr != NULL) { - UnImportPublicSymbol(VIRT_ZOS_MODULE_HANDLE, "\x10JNI_CreateJavaVM"); + UnImportPublicSymbol((LONG)CMN_ModuleHandle, "\x10JNI_CreateJavaVM"); } if (RegisterJavaClassExitCallbackPtr != NULL) { - UnImportPublicSymbol(VIRT_ZOS_MODULE_HANDLE, "\x1DRegisterJavaClassExitCallback"); + UnImportPublicSymbol((LONG)CMN_ModuleHandle, "\x1DRegisterJavaClassExitCallback"); } if (GetJavaClassIDPtr != NULL) { - UnImportPublicSymbol(VIRT_ZOS_MODULE_HANDLE, "\x0EGetJavaClassID"); + UnImportPublicSymbol((LONG)CMN_ModuleHandle, "\x0EGetJavaClassID"); } #endif @@ -1788,7 +1748,7 @@ aprintf(LRED, "VirtualIO for Java - unexpected state found: %d Expected: %d\n", ZOS_StartThreadWithModuleHandle(javaInfo->threadID, "VirtIO JNI", (void *(*)(THREAD, void *))VIRT_CallJavaThread, - 0, 128*1024, fileHandle, VIRT_ZOS_MODULE_HANDLE); + 0, 128*1024, fileHandle, (LONG)CMN_ModuleHandle); #else ZOS_StartThread(javaInfo->threadID, "VirtIO JNI", @@ -1876,8 +1836,6 @@ else * Put an error message in the result buffer * ****************************************************************************/ -#endif /* !NSS_USERSPACE Java runtime */ - void VIRT_WriteError( VirtInfo_s *virtInfo, STATUS status) @@ -1931,32 +1889,20 @@ STATUS VIRT_WriteFunction( } #if zNETWARE MPKNSS_UNLOCK(); - status = VIRT_CALL_WRITE_FUNCTION( - compInfo->u.function.writeFunctionPtr, + status = compInfo->u.function.writeFunctionPtr( compInfo->u.function.writeParmLen, &virtTemplate->names[compInfo->u.function.writeParmIdx], msg->sys.data[RW_DATA].length, - (BYTE *)(uintptr_t)msg->sys.data[RW_DATA].start, + (BYTE *)msg->sys.data[RW_DATA].start, offset, virtInfo); MPKNSS_LOCK(); #endif -#if defined(NSS_USERSPACE) - MPKNSS_UNLOCK(); - status = VIRT_CALL_WRITE_FUNCTION( - compInfo->u.function.writeFunctionPtr, - compInfo->u.function.writeParmLen, - &virtTemplate->names[compInfo->u.function.writeParmIdx], - msg->sys.data[RW_DATA].length, - (BYTE *)(uintptr_t)msg->sys.data[RW_DATA].start, - offset, - virtInfo); - MPKNSS_LOCK(); -#elif zLINUX +#if zLINUX status = VIRT_CallKernelSpace(msg, fileHandle, virtInfo, compInfo, FALSE); #endif } -#if zLINUX && defined(__KERNEL__) +#if zLINUX else if (compInfo->u.function.writeSymType == VIRT_TYPE_USER) { status = VIRT_CallUserSpace(msg, fileHandle, virtInfo, compInfo, FALSE); @@ -1964,11 +1910,7 @@ STATUS VIRT_WriteFunction( #endif else if (compInfo->u.function.writeSymType == VIRT_TYPE_JAVA) { -#if defined(NSS_USERSPACE) - status = zERR_NOT_SUPPORTED; -#else status = VIRT_CallJava(msg, fileHandle, virtInfo, compInfo, FALSE); -#endif } else { @@ -2230,7 +2172,7 @@ STATUS VIRT_GetSymNamePtr( if (type == VIRT_TYPE_KERNEL) { - ZOS_ImportPublicSymbol(symPtr, VIRT_ZOS_MODULE_HANDLE, symName); + ZOS_ImportPublicSymbol(symPtr, (LONG)CMN_ModuleHandle, symName); if (symPtr == NULL) { VIRT_DBGPRINT(LRED, "VFS: Unable to import symbol %s\n", &symName[1]); @@ -3045,20 +2987,16 @@ STATUS VIRT_Write( goto cleanupNoFree; } outputAddressToPassToFree = output; - outbuf = (utf8_t *)(uintptr_t)msg->sys.data[RW_DATA].start; + outbuf = (utf8_t *)msg->sys.data[RW_DATA].start; MPKNSS_UNLOCK(); - #if zLINUX && defined(__KERNEL__) if (copy_from_user(output, outbuf, numBytesToWrite) != 0) { printk("<1> VIRT_Write error from copy_from_user \n"); } -#else - memcpy(output, outbuf, numBytesToWrite); -#endif MPKNSS_LOCK(); // memcpy(output, outbuf, numBytesToWrite); output[numBytesToWrite] = '\0'; - msg->sys.data[RW_DATA].start = (QUAD)(uintptr_t)output; + msg->sys.data[RW_DATA].start = output; if ((virtTemplate = VIRT_TEMPLATE(&beast->FILEroot)) == NULL) { @@ -3087,7 +3025,7 @@ STATUS VIRT_Write( if (VIRT_PrintDebug) { -#if zLINUX && defined(__KERNEL__) +#if zLINUX printk(KERN_ALERT"VFS: Write - num bytes=%d offset=%d pid=%d\n", numBytesToWrite, offset, current->pid); printk(KERN_ALERT"WRITE DATA (pid=%d)=%s\n", current->pid, output); @@ -3364,7 +3302,7 @@ STATUS VIRT_Write( } exit: - msg->sys.data[RW_DATA].start = (QUAD)(uintptr_t)outbuf; + msg->sys.data[RW_DATA].start = outbuf; free(outputAddressToPassToFree); //printk(KERN_ALERT"-----write: unlatch template pid=%d\n", current->pid); UN_LATCH(&virtTemplate->templateLatch); @@ -3377,7 +3315,7 @@ cleanup: //printk(KERN_ALERT"-----write: unlatch template pid=%d\n", current->pid); UN_LATCH(&virtTemplate->templateLatch); cleanupNoLatch: - msg->sys.data[RW_DATA].start = (QUAD)(uintptr_t)outbuf; + msg->sys.data[RW_DATA].start = outbuf; free(outputAddressToPassToFree); cleanupNoFree: virtInfo = fileHandle->virtInfo; @@ -3464,15 +3402,7 @@ STATUS VIRT_ReadFunction( if (compInfo->u.function.readSymType == VIRT_TYPE_KERNEL) { -#if defined(NSS_USERSPACE) - MPKNSS_UNLOCK(); - status = VIRT_CALL_READ_FUNCTION( - compInfo->u.function.readFunctionPtr, - compInfo->u.function.readParmLen, - &virtTemplate->names[compInfo->u.function.readParmIdx], - fileHandle->virtInfo); - MPKNSS_LOCK(); -#elif zLINUX +#if zLINUX status = VIRT_CallKernelSpace(msg, fileHandle, fileHandle->virtInfo, compInfo, TRUE); #else @@ -3484,15 +3414,14 @@ STATUS VIRT_ReadFunction( * than VIRT_RESULT_BUFFER_SIZE. The current size is kept in * resultBufferSize in virtInfo. */ - status = VIRT_CALL_READ_FUNCTION( - compInfo->u.function.readFunctionPtr, + status = compInfo->u.function.readFunctionPtr( compInfo->u.function.readParmLen, &virtTemplate->names[compInfo->u.function.readParmIdx], fileHandle->virtInfo); MPKNSS_LOCK(); #endif } -#if zLINUX && defined(__KERNEL__) +#if zLINUX else if (compInfo->u.function.readSymType == VIRT_TYPE_USER) { status = VIRT_CallUserSpace(msg, fileHandle, fileHandle->virtInfo, @@ -3501,12 +3430,8 @@ STATUS VIRT_ReadFunction( #endif else if (compInfo->u.function.readSymType == VIRT_TYPE_JAVA) { -#if defined(NSS_USERSPACE) - status = zERR_NOT_SUPPORTED; -#else status = VIRT_CallJava(msg, fileHandle, fileHandle->virtInfo, compInfo, TRUE); -#endif } else { @@ -4138,13 +4063,13 @@ STATUS VIRT_Read( if (VIRT_PrintDebug) { -#if zLINUX && defined(__KERNEL__) +#ifdef __linux__ printk(KERN_ALERT"VFS: Read - num bytes=%d offset=%d pid=%d\n", msg->body.read.numBytes, offset, current->pid); #endif - VIRT_DBGPRINT(LBLUE, "VFS: Read - num bytes=%d offset=%d\n", - msg->body.read.numBytes, offset); + VIRT_DBGPRINT(LBLUE, "VFS: Read - num bytes=%d offset=%d pid=%d\n", + msg->body.read.numBytes, offset, current->pid); } /* @@ -4303,7 +4228,7 @@ STATUS VIRT_ChunkyRead (zNSSMsg_s *msg) NINT totalBytes = 0; NINT numChunks = 0; NINT numBytes = msg->body.read.numBytes; - NSSChunk_s *chunk = (NSSChunk_s *)(uintptr_t)msg->sys.data[RW_DATA].start; + NSSChunk_s *chunk = msg->sys.data[RW_DATA].start; #ifndef __linux__ // LINUX_ConnMgr LONG connectionNum; struct ConnectionStructure *conn; @@ -4394,7 +4319,7 @@ STATUS VIRT_ChunkyRead (zNSSMsg_s *msg) { holdByte = virtInfo->resultBuffer[offset + numBytes]; virtInfo->resultBuffer[offset + numBytes] = '\0'; -#if zLINUX && defined(__KERNEL__) +#ifdef __linux__ printk(KERN_ALERT "READ DATA (pid=%d)=%s\n", current->pid, virtInfo->resultBuffer + offset); #endif VIRT_DBGPRINT(YELLOW, "READ DATA=%s\n", virtInfo->resultBuffer + offset); @@ -4427,7 +4352,7 @@ STATUS VIRT_ChunkyRead (zNSSMsg_s *msg) DOWN_LATCH( &buffer->agent.latch); } chunk->nc_length = bytesInBlk; - chunk->nc_release = (voidfunc_t)cacheRelease; + chunk->nc_release = cacheRelease; chunk->nc_offset = blkoffset; chunk->nc_handle = (ADDR)buffer; ++chunk; @@ -4443,7 +4368,7 @@ STATUS VIRT_ChunkyRead (zNSSMsg_s *msg) blkoffset = 0; PERIODIC_YIELD(); } - zASSERT(numChunks == (chunk - (NSSChunk_s *)(uintptr_t)msg->sys.data[RW_DATA].start)); + zASSERT(numChunks == (chunk - (NSSChunk_s *)msg->sys.data[RW_DATA].start)); msg->body.read.numChunks = numChunks; RELEASE_RSRC(msg->body.read.maxChunks << 1); @@ -4462,7 +4387,7 @@ exit: fileHandle->virtInfo->useCount--; if (VIRT_PrintDebug) { -#if zLINUX && defined(__KERNEL__) +#ifdef __linux__ printk(KERN_ALERT "VFS: Read completed. len=%d pid=%d\n", totalBytes, current->pid); #endif VIRT_DBGPRINT(YELLOW, "VFS: Read completed. len=%d\n", totalBytes); @@ -4998,7 +4923,7 @@ STATUS VIRT_AddResultCDataElement ( return zOK; } -#if zNETWARE || (zLINUX && defined(__KERNEL__)) || defined(NSS_VIRTUAL_IO) +#if zNETWARE || (zLINUX && defined(__KERNEL__)) BYTE VIRT_test[VIRT_TEST_BUF_LEN] = "The quick brown fox jumped over the lazy dog"; /**************************************************************************** @@ -5798,3 +5723,4 @@ STATUS VFS_AddUnicode( NINT bLen, BYTE **bAdd, NINT *rLen, const unicode_t *uniN *rLen += bytesAdded; return zOK; } + diff --git a/src/nwnss/sharedsrc/xmlNSS.c.h b/src/nwnss/sharedsrc/xmlNSS.c.h index 16cc69a..c8aa71a 100644 --- a/src/nwnss/sharedsrc/xmlNSS.c.h +++ b/src/nwnss/sharedsrc/xmlNSS.c.h @@ -244,7 +244,7 @@ STATUS XML_GetTagAttribute( break; } - if (*cursor == '"') + if (*cursor == '"') { /* found the attribute, let's get the value */ cursor++; elementInfo->attributeValueStart = cursor; @@ -255,7 +255,7 @@ STATUS XML_GetTagAttribute( if (*cursor == '"') { elementInfo->attributeValueEnd = cursor - 1; - elementInfo->attributeValueLen = + elementInfo->attributeValueLen = elementInfo->attributeValueEnd - elementInfo->attributeValueStart + 1; return zOK; @@ -280,7 +280,7 @@ STATUS XML_FindEndOfElement( NINT tagLen, utf8_t *cursor, utf8_t *bufferEnd, - XML_ElementInfo_s *elementInfo) + XML_ElementInfo_s *elementInfo) { int nested = 0; int depth = 0; @@ -310,7 +310,7 @@ STATUS XML_FindEndOfElement( elementInfo->elementEnd = cursor; return zOK; } - + cursor++; elementInfo->dataStart = cursor; insertCursor = cursor; @@ -328,12 +328,12 @@ STATUS XML_FindEndOfElement( else { *insertCursor = *cursor; - insertCursor++; + insertCursor++; } } else { - if ((depth == 0) && + if ((depth == 0) && (startCursor = XML_findStartCDATA(cursor, bufferEnd))) { cursor = startCursor; @@ -354,7 +354,7 @@ STATUS XML_FindEndOfElement( { /* it is our end tag */ if ( nested == 0 ) { - elementInfo->dataLen = elementInfo->dataEnd - + elementInfo->dataLen = elementInfo->dataEnd - elementInfo->dataStart + 1; elementInfo->elementEnd = cursor; return zOK; @@ -389,7 +389,7 @@ STATUS XML_FindEndOfElement( depth++; } tagLen2 = cursor2 - (cursor + 1); - if ( (tagLen2 == tagLen) && (memcmp(tag, cursor+1, + if ( (tagLen2 == tagLen) && (memcmp(tag, cursor+1, tagLen) == 0) ) { /* Is our tag */ cursor += (1 + tagLen); @@ -425,7 +425,7 @@ STATUS XML_ForwardFindTag( { XML_skipCDATA(&cursor, bufferEnd); if ((*cursor == '<') && - (memcmp(tag, cursor+1, tagLen) == 0) && + (memcmp(tag, cursor+1, tagLen) == 0) && (*(cursor + tagLen + 1) == '>')) { *endOfTag = cursor + tagLen + 1; @@ -460,7 +460,7 @@ STATUS XML_BackwardFindEndTag( while (cursor > bufferStart) { if ((*cursor == '>') && - (memcmp(tag, cursor-tagLen, tagLen) == 0) && + (memcmp(tag, cursor-tagLen, tagLen) == 0) && (*(cursor - tagLen - 1) == '/') && (*(cursor - tagLen - 2) == '<')) { @@ -481,7 +481,7 @@ STATUS XML_GetTagElement( utf8_t *tag, utf8_t *bufferStart, utf8_t *bufferEnd, - XML_ElementInfo_s *elementInfo) + XML_ElementInfo_s *elementInfo) { utf8_t *cursor = bufferStart; NINT tagLen = strlen(tag); @@ -517,7 +517,7 @@ STATUS XML_GetTagElement( STATUS XML_GetNextTag( utf8_t *bufferStart, utf8_t *bufferEnd, - XML_ElementInfo_s *elementInfo, + XML_ElementInfo_s *elementInfo, utf8_t **tagName, NINT *tagLen) { @@ -551,3 +551,4 @@ STATUS XML_GetNextTag( } return zFAILURE; } + diff --git a/src/nwnss/zlss/Makefile b/src/nwnss/zlss/Makefile new file mode 100644 index 0000000..b1569e4 --- /dev/null +++ b/src/nwnss/zlss/Makefile @@ -0,0 +1,32 @@ +### +### ../nss/private_core/zlss Makefile +### + +############################################################################## +# +# (C) Copyright 2004 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +BASEDIR=../.. + +SUBDIRS= \ + +include ${BASEDIR}/buildtools/Makefile.default + diff --git a/src/nwnss/zlss/Module.supported b/src/nwnss/zlss/Module.supported new file mode 100644 index 0000000..c65fc8e --- /dev/null +++ b/src/nwnss/zlss/Module.supported @@ -0,0 +1,2 @@ +nsszlss.ko + diff --git a/src/nwnss/zlss/beastTree.c b/src/nwnss/zlss/beastTree.c index a8f56c0..75d58eb 100644 --- a/src/nwnss/zlss/beastTree.c +++ b/src/nwnss/zlss/beastTree.c @@ -36,7 +36,6 @@ +-------------------------------------------------------------------------*/ #include #include -#include #include #include #include @@ -308,9 +307,9 @@ void bbtValidateNode (BeastTreeNode_s *node) ASSERT_MPKNSS_LOCK(); if (BBT_IS_LEAF(node)) { - zASSERT( (node->magic == LEAF_MAGIC) || + zASSERT( (node->magic == LEAF_MAGIC) || node->magic == (LEAF_MAGIC | 0x20) ); - if ( (node->magic != LEAF_MAGIC) && + if ( (node->magic != LEAF_MAGIC) && (node->magic != (LEAF_MAGIC | 0x20) ) ) { return; @@ -367,7 +366,7 @@ void bbtValidateNode (BeastTreeNode_s *node) { /*- set the current record -*/ b_curr = &node->n.branch[cnt]; - + /*- check if ZIDs ascend -*/ zASSERT(b_prev->zid < b_curr->zid); @@ -505,7 +504,7 @@ Buffer_s *BBT_ReadPoolBlk ( ++count; if ( (count > gGregCount) && (iomsg->mode == CACHE_READ) ) { - magic = 5; + magic = 5; } } #endif @@ -540,12 +539,12 @@ Blknum_t findChildBlock( ENTER(TZTREE, findChildBlock); - while (low <= high) + while (low <= high) { mid = (low + high) / 2; zidFromMid = node->n.branch[mid].zid; if (zid == zidFromMid) - { + { break; } else if (zid > zidFromMid) @@ -667,9 +666,9 @@ void insertZeroNode (BeastTreeNode_s *node) VALIDATE_NODE(node); /* - * We always want a zero in the first location to establish a lower bound - * so we do not need a lot of special case code. - */ + * We always want a zero in the first location to establish a lower bound + * so we do not need a lot of special case code. + */ node->numRecs = 1; node->LEAF.znodePtr[MAX_LEAF_PTRS] = node->n.leaf.startOfFreeSpace; node->n.leaf.startOfFreeSpace += MIN_ZNODE_SIZE; @@ -692,8 +691,8 @@ void garbageCollectNode (BeastTreeNode_s *node) ASSERT_MPKNSS_LOCK(); /* - * This routine garbage collects the internal area of a leaf node - */ + * This routine garbage collects the internal area of a leaf node + */ currentPosition = 0; newStart = node->n.leaf.startOfFreeSpace; while (currentPosition < node->n.leaf.startOfFreeSpace) @@ -841,8 +840,8 @@ ZPRINT_NODE(join1, parms->sibling); /* update the leaf link */ child->n.leaf.nextLeaf = sibling->n.leaf.nextLeaf; /* Change magic in Deleted Leaf Node to indicate it is deleted. This - * is being done for scan mode of rebuild. - */ + * is being done for scan mode of rebuild. + */ sibling->magic |= 0x20; /* Lower case low byte letter */ } else @@ -862,15 +861,15 @@ ZPRINT_NODE(join1, parms->sibling); parentIndex = parms->index + 1; zidInParent = parent->n.branch[parentIndex].zid; memmove( &parent->n.branch[parentIndex], /* Destination */ - &parent->n.branch[parentIndex + 1], /* Source */ - (parent->numRecs - parentIndex) * sizeof(BTBranch_s)); + &parent->n.branch[parentIndex + 1], /* Source */ + (parent->numRecs - parentIndex) * sizeof(BTBranch_s)); localXaction = BeginXLocal(parms->beast->vol.volume,BXL_DEFAULT); /* - * Check to see if we need to do an overflow log record (it won't all - * fit in one). - */ + * Check to see if we need to do an overflow log record (it won't all + * fit in one). + */ totalLen = ZLOG_BLOCK_INFO_SIZE(3) + sizeof(Split_s) - 1 + lenMoved; if (totalLen > ZLOG_MAXIMUM_RECORD_SIZE) { /* it won't fit in one log record */ @@ -930,14 +929,14 @@ ZPRINT_NODE(join1, parms->sibling); ZLOG_BIND(localXaction, parms->parent); if (BBT_IS_LEAF(child) ) { /* This is the deleted LEAF block we must write so that rebuild - * can scan whole disk and not find OLD beast tree leafs. - */ + * can scan whole disk and not find OLD beast tree leafs. + */ parms->sibling->state |= CACHE_DIRTY; ZLOG_BIND(localXaction, parms->sibling); #if 0 /* This code allows for testing of the recovery code of setting - * the magic word on deletes. - */ + * the magic word on deletes. + */ #if NSS_ASSERT IS_ENABLED { extern LONG gZlogAssertBlock; @@ -953,8 +952,8 @@ ZPRINT_NODE(join1, parms->sibling); } /* - * Process an overflow log record for the join if needed - */ + * Process an overflow log record for the join if needed + */ if (numOverflow != 0) { /* need to generate an overflow log record */ @@ -986,7 +985,7 @@ ZPRINT_NODE(join1, parms->sibling); insertLocation += znode->header.length; #if NSS_DEBUG IS_ENABLED tempLen += znode->header.length; -#endif +#endif } zASSERT(tempLen == lenOverflow); } @@ -1131,11 +1130,11 @@ ZPRINT_NODE(balance1, parms->sibling); LEAF.znodePtr[MAX_LEAF_PTRS - i]])->header.length + sizeof(NodeLen_t); /* Defect:260351 - * The obvious way to do this test: - * sibling->freeSpace - space < child->freeSapce + space - * Can wrap with large records. For unsigned numbers, this - * will cause more records to be copied than we have room for. - */ + * The obvious way to do this test: + * sibling->freeSpace - space < child->freeSapce + space + * Can wrap with large records. For unsigned numbers, this + * will cause more records to be copied than we have room for. + */ if (sibling->n.leaf.freeSpace < (child->n.leaf.freeSpace + 2*space)) { /* if the sibling free space will be less than the child */ @@ -1183,7 +1182,7 @@ ZPRINT_NODE(balance1, parms->sibling); avg = (child->numRecs + sibling->numRecs) / 2; #if 0 /* FixFixFix6: uncomment this code as soon as appropriate. - * Dont do balancing if no records can be moved */ + * Dont do balancing if no records can be moved */ if (child->numRecs == avg) { --Inst.ztree.balance.total; @@ -1201,8 +1200,8 @@ ZPRINT_NODE(balance1, parms->sibling); /* move the entries from sibling to child */ memcpy(startLocation, /* Destination */ - &sibling->n.branch[0], /* Source */ - lenMoved); + &sibling->n.branch[0], /* Source */ + lenMoved); /* move sibling entries back to the front of the record */ memmove(&sibling->n.branch[0], /* Destination */ @@ -1230,8 +1229,8 @@ ZPRINT_NODE(balance1, parms->sibling); /* move the entries from the child to the sibling */ memcpy(startLocation, - &child->n.branch[child->numRecs - numToMove], - lenMoved); + &child->n.branch[child->numRecs - numToMove], + lenMoved); child->numRecs -= numToMove; sibling->numRecs += numToMove; @@ -1356,7 +1355,7 @@ STATUS underflow ( if (parms->sibling == NULL) { //zASSERT(0); - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } VALIDATE_NODE((BeastTreeNode_s *)parms->sibling->pBuf.data); } @@ -1367,9 +1366,9 @@ STATUS underflow ( READBLK_IO_MSG(iomsg, ztree, parms->readBlkNum, CACHE_UPDATE); SET_DEBUG_ID(iomsg, 2); /* - * Release the latch so we do not latch out of order -- This is - * OK because the parent latch is held. - */ + * Release the latch so we do not latch out of order -- This is + * OK because the parent latch is held. + */ CACHE_PIN(parms->sibling); CACHE_UNXLATCH(parms->sibling); parms->child = BBT_ReadPoolBlk(genMsg, &iomsg); @@ -1379,7 +1378,7 @@ STATUS underflow ( { //zASSERT(0); CACHE_RELEASE(parms->sibling); - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } VALIDATE_NODE((BeastTreeNode_s *)parms->child->pBuf.data); } @@ -1431,8 +1430,8 @@ STATUS shrink ( /* force the beast out */ localXaction = BeginXLocal(parms->beast->vol.volume,BXL_DEFAULT); COMN_MARK_BEAST_XLOCAL(&ztree->ZFSBEASTTREEroot, &localXaction->xaction); - if (COMN_ForceBeastWrite(genMsg, &ztree->ZFSBEASTTREEroot, - &localXaction->xaction) != zOK) + if (COMN_ForceBeastWrite(genMsg, &ztree->ZFSBEASTTREEroot, + &localXaction->xaction) != zOK) { goto errorEndXaction; } @@ -1481,10 +1480,10 @@ ZPRINT_NODE(shrink, parms->child); ZLOG_ReleaseRecordAndLogEnd(localXaction); /* Use the special ASYNC version of EndXlocal() so that the - * use of the purgeLog is disconnected from the beast B-Tree - * code. This prevents deadlocks that where occurring when - * the purgeLog is flushed. - */ + * use of the purgeLog is disconnected from the beast B-Tree + * code. This prevents deadlocks that where occurring when + * the purgeLog is flushed. + */ // EndXlocalAsync(localXaction); EndXlocal(localXaction); @@ -1639,9 +1638,9 @@ STATUS split ( beastZid = parms->beast->zid; /* - * Sibling is the node to be split. It is the left node in the split. - * Child is the new node. - */ + * Sibling is the node to be split. It is the left node in the split. + * Child is the new node. + */ child = (BeastTreeNode_s *)parms->child->pBuf.data; holdState = sibling->state & BBT_LEAF; @@ -1725,8 +1724,8 @@ ZPRINT_NODE(split1, parms->sibling); sibling->numRecs = MIN_BRANCHES; } /* - * Make room in the Parent to place the node - */ + * Make room in the Parent to place the node + */ i = parms->index + 1; memmove(&parent->n.branch[i + 1], /* Destination */ &parent->n.branch[i], /* Source */ @@ -1735,10 +1734,10 @@ ZPRINT_NODE(split1, parms->sibling); if (BBT_IS_LEAF(sibling)) { /* - * Update the parent with the first entry in the child unless - * the new beast is going to be inserted as the first entry in the - * child node. If this is the case then use the new beast zid. - */ + * Update the parent with the first entry in the child unless + * the new beast is going to be inserted as the first entry in the + * child node. If this is the case then use the new beast zid. + */ if (insertInSibling || ((child->numRecs > 0) && (((Znode_s *)&child->LEAF.znode[child->LEAF. @@ -1870,8 +1869,8 @@ STATUS grow ( /* force the beast out */ COMN_MARK_BEAST_XLOCAL(&ztree->ZFSBEASTTREEroot, &localXaction->xaction); - if (COMN_ForceBeastWrite(genMsg, &ztree->ZFSBEASTTREEroot, - &localXaction->xaction) != zOK) + if (COMN_ForceBeastWrite(genMsg, &ztree->ZFSBEASTTREEroot, + &localXaction->xaction) != zOK) { goto errorUnlatch; } @@ -1993,13 +1992,13 @@ errorRelease: } /* This routine gets the list of the blocks that are in the same area - * as the block that we are going to read. We will use this list to + * as the block that we are going to read. We will use this list to * do readahead on these blocks. */ -NINT BT_getBlockList( +NINT BT_getBlockList( void *voidNode, SNINT index, - Blknum_t *blockList) + Blknum_t *blockList) { BeastTreeNode_s *node = voidNode; SNINT i; @@ -2115,7 +2114,7 @@ STATUS findLeaf ( parms->parent = parms->child; parms->readBlkNum = findChildBlock((BeastTreeNode_s *)parms->parent->pBuf.data, parms->beast->zid, &parms->index); - if ((currentLevel+1) == ztree->zfsBtree.levelsInTree) + if ((currentLevel+1) == ztree->zfsBtree.levelsInTree) { BTREE_ReadAheadMetadata(&ztree->zfsBtree.ZFSBTREEroot, parms->parent->pBuf.data, @@ -2166,15 +2165,15 @@ STATUS insertZnode ( ASSERT_MPKNSS_LOCK(); /* - * This routine assumes a check has ready been done to make sure there - * there is enough free space in the buffer to hold the new znode. - */ + * This routine assumes a check has ready been done to make sure there + * there is enough free space in the buffer to hold the new znode. + */ ENTER(TZTREE, insertZnode); /* - * Add the znode to the leaf node - */ + * Add the znode to the leaf node + */ if (findZnodeByZid(child, zid, &i)) { zASSERT("Same ZID added twice to metadata b-tree" == NULL); @@ -2192,8 +2191,8 @@ STATUS insertZnode ( zASSERT(zlen + sizeof(NodeLen_t) <= SIZEOFFREESPACE(child)); /* - * The znode will fit in the remaining free space . - */ + * The znode will fit in the remaining free space . + */ znode = (Znode_s *)&child->LEAF.znode[child->n.leaf.startOfFreeSpace]; znode->header.zid = zid; znode->header.length = zlen; @@ -2262,7 +2261,7 @@ void logInsertRecord ( /**************************************************************************** * Put an insert znode log record into the log for logical undo * - * This routine is the same as the non-logical case, except it is a + * This routine is the same as the non-logical case, except it is a * different function number and it also stored the volume GUID after the * the variable data section of the znode. * @@ -2292,7 +2291,7 @@ void logInsertRecordLogical ( ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[0], parms->child->volBlk, child->lsn, parms->child, parms->xaction, 0, bbtCompare); memcpy(&logRecord->u.znode, parms->packArea, parms->beastLen); /* log the beast contents*/ - memcpy(((BYTE *)(&logRecord->u.znode)) + parms->beastLen, + memcpy(((BYTE *)(&logRecord->u.znode)) + parms->beastLen, &parms->ztree->ZFSBEASTTREEroot.ROOTinternalID, sizeof(GUID_t)); child->lsn = logBuffer->ZXR_Lsn; @@ -2308,7 +2307,7 @@ void logInsertRecordLogical ( * * Input: Child and parent are latched. Child is buffer to inserted into. * - * Output: Parent and child are unlatched. + * Output: Parent and child are unlatched. ****************************************************************************/ STATUS doInsertZnode ( GeneralMsg_s *genMsg, @@ -2362,7 +2361,7 @@ ZPRINT_NODE(doInsertZnode, parms->child); ****************************************************************************/ /**************************************************************************** ** - ** The system beasts have been moved out of the beast tree, into a special + ** The system beasts have been moved out of the beast tree, into a special ** block that is pointed to by the super blk. When the beast tree beast is ** unpacked, a non-persistent field in the beast structure points to this ** special block. The nextLeaf pointer of this special block points to the @@ -2372,7 +2371,7 @@ ZPRINT_NODE(doInsertZnode, parms->child); ** ** The system beasts have been moved out of the beast tree to avoid using ** EndXLocalAsync. This is necessary to be able to do logical undo's. - ** It also allows the FreeTree to do a force beast write, without the + ** It also allows the FreeTree to do a force beast write, without the ** deadlock situation of the beast tree then calling the free tree to ** alloc a block for splits etc. ** @@ -2424,19 +2423,19 @@ ZPRINT_ZID(ZFSVOL_InsertBeastIntoVolume, beast->zid); parms.ztree = ztree; /* This field specifies whether to log inserts and deletes physically or - * logically. For system beasts and the root dir zid we always do the - * logging to physically undo for all others we do the logging to - * logically undo. We can do this because the location of the system - * beasts does not change from the special system beasts block. The root - * dir zid is always in the left most leaf of the beast tree and splits - * grows etc does not change its location. It is necessary to do the - * root dir physically because logical volume creation is one big - * xaction and root dir is inserted as part of the same transaction that - * allocates and initializes the left block. After physical undo is - * complete the system beasts have to be in a stable state since logical - * undo can modify them. Thus the system beasts inserts and deletes need - * to be done physically too. - */ + * logically. For system beasts and the root dir zid we always do the + * logging to physically undo for all others we do the logging to + * logically undo. We can do this because the location of the system + * beasts does not change from the special system beasts block. The root + * dir zid is always in the left most leaf of the beast tree and splits + * grows etc does not change its location. It is necessary to do the + * root dir physically because logical volume creation is one big + * xaction and root dir is inserted as part of the same transaction that + * allocates and initializes the left block. After physical undo is + * complete the system beasts have to be in a stable state since logical + * undo can modify them. Thus the system beasts inserts and deletes need + * to be done physically too. + */ parms.physicalLogging = FALSE; if (IS_SYSTEM_BEAST_ZID(beast->zid)) @@ -2466,8 +2465,8 @@ ZPRINT_ZID(ZFSVOL_InsertBeastIntoVolume, beast->zid); parms.physicalLogging = TRUE; } /* - * Get an exclusive latch on ztree - */ + * Get an exclusive latch on ztree + */ BBT_X_LATCH_BEASTTREE(&parms); if (ztree->zfsBtree.p.btRoot == INVALID_BLK) @@ -2489,25 +2488,25 @@ ZPRINT_ZID(ZFSVOL_InsertBeastIntoVolume, beast->zid); ztree->zfsBtree.p.btRoot = parms.child->volBlk; ztree->zfsBtree.levelsInTree++; - - COMN_MARK_BEAST_XLOCAL(&ztree->ZFSBEASTTREEroot, - &localXaction->xaction); + + COMN_MARK_BEAST_XLOCAL(&ztree->ZFSBEASTTREEroot, + &localXaction->xaction); // /* We do not need to do this write because we are actually inserting // * the beastTree beast right now. During volume creation we will // * write this beast again after the insert to make sure it is up to // * date. */ - /* Now that the system beasts are not in the beast tree we - * can do a ForceBeastWrite here. - */ + /* Now that the system beasts are not in the beast tree we + * can do a ForceBeastWrite here. + */ if (COMN_ForceBeastWrite(genMsg, &ztree->ZFSBEASTTREEroot, - &localXaction->xaction) != zOK) - { + &localXaction->xaction) != zOK) + { goto errorEndXaction; - } - + } + READBLK_IO_MSG(iomsg, ztree, ztree->specialSystemBstsBlk, - /* beast->vol.zfsVol->p.PZV_systemBeastBlkNum, */ CACHE_UPDATE); + /* beast->vol.zfsVol->p.PZV_systemBeastBlkNum, */ CACHE_UPDATE); buffer = BBT_ReadPoolBlk(genMsg, &iomsg); if (buffer == NULL) { @@ -2521,28 +2520,28 @@ ZPRINT_ZID(ZFSVOL_InsertBeastIntoVolume, beast->zid); /* log the init record */ ZLOG_ObtainRecord(localXaction, - ZLOG_BLOCK_INFO_SIZE(2) + sizeof(BeastTreeInit_s) ); - + ZLOG_BLOCK_INFO_SIZE(2) + sizeof(BeastTreeInit_s) ); + ZLOG_INIT_LOG_RECORD(XFUNC_BTREE_INIT, localXaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[0], parms.child->volBlk, - ((BeastTreeNode_s *)parms.child->pBuf.data)->lsn, parms.child, + ((BeastTreeNode_s *)parms.child->pBuf.data)->lsn, parms.child, localXaction, 0, bbtCompare); ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[1], buffer->volBlk, - node->lsn, buffer, + node->lsn, buffer, localXaction, 1, bbtCompare); - ZLOG_ALLOC_BLOCK(poolBlks[0]); - ((BeastTreeNode_s *)parms.child->pBuf.data)->lsn = + ZLOG_ALLOC_BLOCK(poolBlks[0]); + ((BeastTreeNode_s *)parms.child->pBuf.data)->lsn = logBuffer->ZXR_Lsn; node->lsn = logBuffer->ZXR_Lsn; - logRecord->u.bl_init.bti_internalID = + logRecord->u.bl_init.bti_internalID = ztree->ZFSBEASTTREEroot.ROOTinternalID; - + ZLOG_BIND(localXaction, parms.child); ZLOG_BIND(localXaction, buffer); ZLOG_ReleaseRecordAndLogEnd(localXaction); EndXlocal(localXaction); - + CACHE_DIRTY_RELEASE(buffer); if (doInsertZnode(genMsg, &parms) != zOK) @@ -2565,22 +2564,22 @@ ZPRINT_ZID(ZFSVOL_InsertBeastIntoVolume, beast->zid); } /* If this routine was called during logical undo, we do not want to change - * the counts on the volume as physical undo has already fixed them to - * the correct values - */ + * the counts on the volume as physical undo has already fixed them to + * the correct values + */ if (IS_LOGICAL_UNDO_XACTION(parms.xaction)) { RTN_STATUS(zOK); } /* the insert of the new beast was successful, update the volume count */ -// done in ZFSVOL_VOL_WriteVolumeLoggedData -// beast->ROOTvolume->VOLnumObjects++; +// done in ZFSVOL_VOL_WriteVolumeLoggedData +// beast->ROOTvolume->VOLnumObjects++; volLog.delta = 1; volLog.action = VOLINFO_CHANGE_NUM_OBJECTS; if (COMN_IsDerivedFrom(beast,zFTYPE_FILE)) { -// done in ZFSVOL_VOL_WriteVolumeLoggedData +// done in ZFSVOL_VOL_WriteVolumeLoggedData // beast->ROOTvolume->VOLnumFiles++; volLog.action = VOLINFO_CHANGE_NUM_FILES; } @@ -2634,7 +2633,7 @@ void deleteZnodeFromChild( * * Output: Child record is Latched ****************************************************************************/ -void logDeleteRecord( +void logDeleteRecord( BeastTreeParms_s *parms, NINT recNum) { @@ -2681,7 +2680,7 @@ void logDeleteRecord( * Put an delete znode log record into the log. This is the contents before * the znode is deleted. This is for logical undo. * - * This routine is the same as the non-logical case, except it is a + * This routine is the same as the non-logical case, except it is a * different function number and it also stored the volume GUID after the * the variable data section of the znode. * @@ -2693,7 +2692,7 @@ void logDeleteRecord( * * Output: Child record is Latched ****************************************************************************/ -void logDeleteRecordLogical( +void logDeleteRecordLogical( BeastTreeParms_s *parms, NINT recNum) { @@ -2719,7 +2718,7 @@ void logDeleteRecordLogical( ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[0], parms->child->volBlk, node->lsn, parms->child, parms->xaction, 0, bbtCompare); memcpy(&logRecord->u.znode, znode, znode->header.length); /* log the beast old contents*/ - memcpy(((BYTE *)(&logRecord->u.znode)) + znode->header.length, + memcpy(((BYTE *)(&logRecord->u.znode)) + znode->header.length, &parms->ztree->ZFSBEASTTREEroot.ROOTinternalID, sizeof(GUID_t)); #if LOG_TEST IS_ENABLED holdLsn = logBuffer->ZXR_Lsn; /* this is done so the lsn will be ok for testing */ @@ -2794,7 +2793,7 @@ ZPRINT_NODE(doDeleteZnode, parms->child); errorExit: //zASSERT(0); CACHE_DIRTY_RELEASE(parms->child); - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } @@ -2828,15 +2827,15 @@ ZPRINT_ZID(ZFSVOL_RemoveBeastFromVolume, beast->zid); if (beast->bstState & BST_STATE_NEW) { /* If the beast is new it has never been added to the Beast Tree, - * so we don't need to do anything - */ + * so we don't need to do anything + */ RTN_STATUS(zOK); } /* - * Don't allow the system beasts (or the orginal zero entry) to be - * deleted. - */ + * Don't allow the system beasts (or the orginal zero entry) to be + * deleted. + */ if (beast->zid == 0) { zASSERT("Attempting to remove the zero ZID from the beastTree" == NULL); @@ -2845,8 +2844,8 @@ ZPRINT_ZID(ZFSVOL_RemoveBeastFromVolume, beast->zid); } /* - * Get an exclusive latch on ztree - */ + * Get an exclusive latch on ztree + */ /* LogLogLog -- remove the next 2 line */ // pool = (ZfsPool_s *)beast->vol.zfsVol->beastTree; @@ -2856,19 +2855,19 @@ ZPRINT_ZID(ZFSVOL_RemoveBeastFromVolume, beast->zid); parms.ztree = ztree; /* This field specifies whether to log inserts and deletes physically or - * logically. For system beasts and the root dir zid we always do the - * logging to physically undo for all others we do the logging to - * logically undo. We can do this because the location of the system - * beasts does not change from the special system beasts block. The root - * dir zid is always in the left most leaf of the beast tree and splits - * grows etc does not change its location. It is necessary to do the - * root dir physically because logical volume creation is one big - * xaction and root dir is inserted as part of the same transaction that - * allocates and initializes the left block. After physical undo is - * complete the system beasts have to be in a stable state since logical - * undo can modify them. Thus the system beasts inserts and deletes need - * to be done physically too. - */ + * logically. For system beasts and the root dir zid we always do the + * logging to physically undo for all others we do the logging to + * logically undo. We can do this because the location of the system + * beasts does not change from the special system beasts block. The root + * dir zid is always in the left most leaf of the beast tree and splits + * grows etc does not change its location. It is necessary to do the + * root dir physically because logical volume creation is one big + * xaction and root dir is inserted as part of the same transaction that + * allocates and initializes the left block. After physical undo is + * complete the system beasts have to be in a stable state since logical + * undo can modify them. Thus the system beasts inserts and deletes need + * to be done physically too. + */ parms.physicalLogging = FALSE; if (IS_SYSTEM_BEAST_ZID(beast->zid)) @@ -2876,8 +2875,8 @@ ZPRINT_ZID(ZFSVOL_RemoveBeastFromVolume, beast->zid); parms.physicalLogging = TRUE; zASSERT((beast->zid == ZFSPOOL_VOLUSERTREE_ZID) || - (beast->zid == ZFSVOL_DIRTREE_ZID) || - (beast->zid == ZFSVOL_MFL_ZID) || + (beast->zid == ZFSVOL_DIRTREE_ZID) || + (beast->zid == ZFSVOL_MFL_ZID) || (beast->zid == ZFSVOL_EFL_ZID) ); if ((beast->zid != ZFSPOOL_VOLUSERTREE_ZID) && (beast->zid != ZFSVOL_DIRTREE_ZID) && @@ -2927,21 +2926,21 @@ ZPRINT_ZID(ZFSVOL_RemoveBeastFromVolume, beast->zid); } /* If this routine was called during logical undo, we do not want to change - * the counts on the volume as physical undo has already fixed them to - * the correct values - */ + * the counts on the volume as physical undo has already fixed them to + * the correct values + */ if (IS_LOGICAL_UNDO_XACTION(parms.xaction)) { RTN_STATUS(zOK); } /* the remove of the beast was successful, udpate the volume count */ -// done in ZFSVOL_VOL_WriteVolumeLoggedData +// done in ZFSVOL_VOL_WriteVolumeLoggedData // beast->ROOTvolume->VOLnumObjects--; volLog.delta = -1; volLog.action = VOLINFO_CHANGE_NUM_OBJECTS; if (COMN_IsDerivedFrom(beast, zFTYPE_FILE)) { -// done in ZFSVOL_VOL_WriteVolumeLoggedData +// done in ZFSVOL_VOL_WriteVolumeLoggedData // beast->ROOTvolume->VOLnumFiles--; volLog.action = VOLINFO_CHANGE_NUM_FILES; } @@ -2958,7 +2957,7 @@ ZPRINT_ZID(ZFSVOL_RemoveBeastFromVolume, beast->zid); /**************************************************************************** - * Modify the actual znode (if it will fit). This routine assumes the + * Modify the actual znode (if it will fit). This routine assumes the * log record has already been released that has the old information. ****************************************************************************/ STATUS modifyZnode ( @@ -2969,7 +2968,7 @@ STATUS modifyZnode ( BeastTreeNode_s *child = (BeastTreeNode_s *)parms->child->pBuf.data; SNINT lenDif; Znode_s *znode = (Znode_s *)&child->LEAF.znode - [child->LEAF.znodePtr[MAX_LEAF_PTRS - recNum]]; + [child->LEAF.znodePtr[MAX_LEAF_PTRS - recNum]]; Znode_s *tempZnode; Znode_s *freeZnode; @@ -2977,13 +2976,13 @@ STATUS modifyZnode ( ENTER(TZTREE, modifyZnode); VALIDATE_NODE((BeastTreeNode_s *)parms->child->pBuf.data); /* - * Change the znode contents in the node. If the node size is the same - * just copy it. If is smaller copy it and make free space. If it is - * larger then check for space in the node. If there is no space then - * things get fun... - * - * NOTE: the parent is still latched when we come into this routine. - */ + * Change the znode contents in the node. If the node size is the same + * just copy it. If is smaller copy it and make free space. If it is + * larger then check for space in the node. If there is no space then + * things get fun... + * + * NOTE: the parent is still latched when we come into this routine. + */ lenDif = parms->beastLen - znode->header.length; if (lenDif == 0) { /* they are the same length */ @@ -3026,7 +3025,7 @@ STATUS modifyZnode ( if ((ADDR)tempZnode == (ADDR)&child->LEAF.znode[child->n.leaf.startOfFreeSpace]) - { /* if the next area is the start of free space */ + { /* if the next area is the start of free space */ if (SIZEOFFREESPACE(child) >= lenDif) { /* if there is enough room at the end of the node */ child->n.leaf.startOfFreeSpace += lenDif; @@ -3072,15 +3071,15 @@ STATUS modifyZnode ( } zASSERT("Corrupt free space count in a meta-data storage node" == NULL); /* We already released parent so we can not just do an INSERT - * here. Instead we return an error. The user will have to - * run /REBUILD. I am not sure if REBUILD is capable of fixing - * this type of error. FixFixFix6 - REBUILD should fix this - * type of error. - * No real attempt to restore the beast information because - * we may have done garbage collection plus the NODE is corrupt - * so just exit. Note that the volume may be deactivated - * by higher level routines. - */ + * here. Instead we return an error. The user will have to + * run /REBUILD. I am not sure if REBUILD is capable of fixing + * this type of error. FixFixFix6 - REBUILD should fix this + * type of error. + * No real attempt to restore the beast information because + * we may have done garbage collection plus the NODE is corrupt + * so just exit. Note that the volume may be deactivated + * by higher level routines. + */ if ((BBT_IS_ROOT(child)) && (!BBT_IS_SYSTEM_BSTS_BLK(child))) { BBT_UNX_LATCH_BEASTTREE(parms); @@ -3237,26 +3236,26 @@ ZPRINT_ZID(ZFSVOL_UpdateBeastToVolume, beast->zid); parms.ztree = ztree; /* This field specifies whether to log inserts and deletes physically or - * logically. For system beasts and the root dir zid we always do the - * logging to physically undo for all others we do the logging to - * logically undo. We can do this because the location of the system - * beasts does not change from the special system beasts block. The root - * dir zid is always in the left most leaf of the beast tree and splits - * grows etc does not change its location. It is necessary to do the - * root dir physically because logical volume creation is one big - * xaction and root dir is inserted as part of the same transaction that - * allocates and initializes the left block. After physical undo is - * complete the system beasts have to be in a stable state since logical - * undo can modify them. Thus the system beasts inserts and deletes need - * to be done physically too. - */ + * logically. For system beasts and the root dir zid we always do the + * logging to physically undo for all others we do the logging to + * logically undo. We can do this because the location of the system + * beasts does not change from the special system beasts block. The root + * dir zid is always in the left most leaf of the beast tree and splits + * grows etc does not change its location. It is necessary to do the + * root dir physically because logical volume creation is one big + * xaction and root dir is inserted as part of the same transaction that + * allocates and initializes the left block. After physical undo is + * complete the system beasts have to be in a stable state since logical + * undo can modify them. Thus the system beasts inserts and deletes need + * to be done physically too. + */ parms.physicalLogging = FALSE; if (IS_SYSTEM_BEAST_ZID(beast->zid)) { - /* Before we modify a system beast the upgrade to media version - * 40 01 should be completed. - */ + /* Before we modify a system beast the upgrade to media version + * 40 01 should be completed. + */ parms.physicalLogging = TRUE; // parms.readBlkNum = beast->vol.zfsVol->p.PZV_systemBeastBlkNum; parms.readBlkNum = ztree->specialSystemBstsBlk; @@ -3279,8 +3278,8 @@ ZPRINT_ZID(ZFSVOL_UpdateBeastToVolume, beast->zid); parms.physicalLogging = TRUE; } /* - * Get an exclusive latch on ztree - */ + * Get an exclusive latch on ztree + */ BBT_X_LATCH_BEASTTREE(&parms); if (ztree->zfsBtree.p.btRoot == INVALID_BLK) @@ -3311,7 +3310,7 @@ ZPRINT_ZID(ZFSVOL_UpdateBeastToVolume, beast->zid); ****************************************************************************/ /**************************************************************************** - * + * * Check to make sure the left-most leaf has the "zero" zid in it. If it * doesn't then fix it. * @@ -3330,24 +3329,24 @@ void ZFSVOL_CheckZeroZid( COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); /* - * Get an exclusive latch on ztree - */ + * Get an exclusive latch on ztree + */ X_LATCH(&ztree->ZFSBEASTTREEbeastLatch); /* Latch the tree */ /* - * Start from the root and find all the branch entries to see if they - * need to be fixed up - */ + * Start from the root and find all the branch entries to see if they + * need to be fixed up + */ nextBlock = ztree->zfsBtree.p.btRoot; for(;;) { if (nextBlock == INVALID_BLK) - { /* No root block yet OR the BT has been partially - * deleted by a volume being purged. - */ - goto exit; + { /* No root block yet OR the BT has been partially + * deleted by a volume being purged. + */ + goto exit; } READBLK_IO_MSG(iomsg, ztree, nextBlock, CACHE_UPDATE); buffer = BBT_ReadPoolBlk(&genMsg, &iomsg); @@ -3362,12 +3361,12 @@ void ZFSVOL_CheckZeroZid( { break; } - + if (node->n.branch[0].zid != 0) { /* This node is in error. Set the first entry to zero */ zASSERT(node->n.branch[0].zid == 1); - node->n.branch[0].zid = 0; + node->n.branch[0].zid = 0; buffer->state |= CACHE_DIRTY; } @@ -3382,8 +3381,8 @@ void ZFSVOL_CheckZeroZid( } /* - * Put the "zero" zid in the buffer at the first slot. - */ + * Put the "zero" zid in the buffer at the first slot. + */ if (node->n.leaf.freeSpace < (MIN_ZNODE_SIZE + sizeof(NodeLen_t))) { goto exitRelease; /* not enough room to put the entry in the buffer */ @@ -3392,16 +3391,16 @@ void ZFSVOL_CheckZeroZid( garbageCollectNode(node); /* Make room for the "zero" zid entry and fix it up */ - memmove(&node->LEAF.znode[MIN_ZNODE_SIZE], znode, + memmove(&node->LEAF.znode[MIN_ZNODE_SIZE], znode, node->n.leaf.startOfFreeSpace); - /* - * Fix up the indices by making a new slot and adjusting for the shifting - * of the znodes. - */ + /* + * Fix up the indices by making a new slot and adjusting for the shifting + * of the znodes. + */ for (i = node->numRecs; i > 0; i--) { - node->LEAF.znodePtr[MAX_LEAF_PTRS - i] = + node->LEAF.znodePtr[MAX_LEAF_PTRS - i] = node->LEAF.znodePtr[MAX_LEAF_PTRS - i + 1] + MIN_ZNODE_SIZE; } @@ -3490,7 +3489,7 @@ STATUS getLeaf( parms->parent = parms->child; poolBlk = findChildBlock((BeastTreeNode_s *)parms->parent->pBuf.data, zid, &parms->index); - if ((currentLevel+1) == parms->ztree->zfsBtree.levelsInTree) + if ((currentLevel+1) == parms->ztree->zfsBtree.levelsInTree) { BTREE_ReadAheadMetadata(&parms->ztree->zfsBtree.ZFSBTREEroot, parms->parent->pBuf.data, @@ -3542,7 +3541,7 @@ void *ZFSVOL_VOL_GetBeastFromVolume( if (IS_SYSTEM_BEAST_ZID(zid)) { READBLK_IO_MSG(iomsg, ztree, ztree->specialSystemBstsBlk, - /* ((ZfsVolume_s *)volume)->p.PZV_systemBeastBlkNum,*/ CACHE_READ); + /* ((ZfsVolume_s *)volume)->p.PZV_systemBeastBlkNum,*/ CACHE_READ); parms.child = BBT_ReadPoolBlk(genMsg, &iomsg); if (parms.child == NULL) { @@ -3559,7 +3558,7 @@ void *ZFSVOL_VOL_GetBeastFromVolume( SetErrno(genMsg, zERR_ZID_NOT_FOUND); RTN_PTR(NULL); } - + /* read the root node */ READBLK_IO_MSG(iomsg, ztree, ztree->zfsBtree.p.btRoot, CACHE_READ); SET_DEBUG_ID(iomsg, 8); @@ -3572,14 +3571,14 @@ void *ZFSVOL_VOL_GetBeastFromVolume( RTN_PTR(NULL); } VALIDATE_NODE((BeastTreeNode_s *)parms.child->pBuf.data); - + /* descend the tree to the leaf */ if (getLeaf(genMsg, zid, (ZfsVolume_s *)volume, &parms) != zOK) { RTN_PTR(NULL); } } - ZPRINT_NODE(ZFSVOL_GetBeastFromVolume, parms.child); + ZPRINT_NODE(ZFSVOL_GetBeastFromVolume, parms.child); zASSERT(BBT_IS_LEAF((BeastTreeNode_s *)parms.child->pBuf.data)); beast = ZFSVOL_GetBeastFromBuffer(genMsg, zid, volume, parms.child); @@ -3595,9 +3594,9 @@ void *ZFSVOL_VOL_GetBeastFromVolume( * the system beasts will need to be read from the special system beasts * block. * - * NOTE: This will not return snapshot beasts ie beasts that have the + * NOTE: This will not return snapshot beasts ie beasts that have the * high bit set. The beasts that have the high bit set are not - * on any of the linked lists and are only pointed to by the + * on any of the linked lists and are only pointed to by the * parent beasts. Callers of this routine do a COMN_LookupByZid * and that will result in the snapshot beast being in memory * twice. @@ -3637,11 +3636,11 @@ STATUS ZFSVOL_VOL_BrowseBeastsInVolume( UNS_LATCH(&ztree->ZFSBEASTTREEbeastLatch); goto done; } - + /* - * Find the next beast after *lastZidReturned to return. - * For this, we start at the root. - */ + * Find the next beast after *lastZidReturned to return. + * For this, we start at the root. + */ /* read the root node */ READBLK_IO_MSG(iomsg, ztree, ztree->zfsBtree.p.btRoot, CACHE_READ); parms.child = BBT_ReadPoolBlk(genMsg, &iomsg); @@ -3656,7 +3655,7 @@ STATUS ZFSVOL_VOL_BrowseBeastsInVolume( VALIDATE_NODE(node); /* descend the tree to the leaf */ - if ((rc = getLeaf(genMsg, *lastZidReturned, (ZfsVolume_s *)volume, + if ((rc = getLeaf(genMsg, *lastZidReturned, (ZfsVolume_s *)volume, &parms)) != zOK) { goto done; @@ -3670,22 +3669,22 @@ STATUS ZFSVOL_VOL_BrowseBeastsInVolume( } nextIndex++; /* Skip the last matched entry */ - /* - * Return the ZIDs of next numBeastsRequested beasts after (*lastZidReturned) - * by sequentially scanning the beast tree's leaf nodes - * - * Sequentially scan the linked list of leaf nodes for beasts to return - * (starting at the beast at (parms.child, nextind)). - */ + /* + * Return the ZIDs of next numBeastsRequested beasts after (*lastZidReturned) + * by sequentially scanning the beast tree's leaf nodes + * + * Sequentially scan the linked list of leaf nodes for beasts to return + * (starting at the beast at (parms.child, nextind)). + */ for (; beastIndex < numBeastsRequested; ) { /* Skip to a leaf node with entries to process */ - if (nextIndex >= node->numRecs) + if (nextIndex >= node->numRecs) { /* Jump to the next leaf node */ Buffer_s *nextbuf; if (node->n.leaf.nextLeaf == INVALID_BLK || - node->n.leaf.nextLeaf == 0) + node->n.leaf.nextLeaf == 0) { break; } @@ -3704,17 +3703,17 @@ STATUS ZFSVOL_VOL_BrowseBeastsInVolume( } /* Add the beast's ZID to the beastZids list */ - beastZids[beastIndex] = + beastZids[beastIndex] = ((Znode_s *)&node->LEAF.znode[node->LEAF.znodePtr [MAX_LEAF_PTRS - nextIndex]])->header.zid; - + /* Don't return LSS-specific system beasts */ /* Don't return SNAPSHOT beast */ if (IS_SYSTEM_BEAST_ZID(beastZids[beastIndex])) { /* The system beasts have been moved out of the beast tree. - * This should not happen. - */ + * This should not happen. + */ zASSERT("System beast found in the left leaf" == NULL); } else if (!(beastZids[beastIndex] & SNAPSHOT_ZID_FLAG)) @@ -3855,10 +3854,10 @@ ZPRINT_NODE(restoreShrink, buffer); if (ZLOG_VALID_BLOCK(poolBlks[1])) { /* update the system beast blk to point to new root which is left most - * leaf of the beast b-tree. */ + * leaf of the beast b-tree. */ if (logBuffer->ZXR_FunctionIndex == XFUNC_LV_BT_INIT ) { /* This version requires us to INIT the - * special block */ + * special block */ READBLK_IO_MSG(iomsg, pool, poolBlks[1].blkNum, CACHE_WRITE) buffer = BBT_ReadPoolBlk(genMsg, &iomsg); zASSERT( buffer != NULL ); /* Can't get error on CACHE_WRITE */ @@ -4173,13 +4172,13 @@ STATUS recoveryBalance( ZPRINT_NODE(restoreBalanceParent1, buffer); if (action == X_REDO) { - node->n.branch[logRecord->u.balance.indexForParent].zid = + node->n.branch[logRecord->u.balance.indexForParent].zid = logRecord->u.balance.zidForParent; } else { - node->n.branch[logRecord->u.balance.indexForParent].zid = - logRecord->u.balance.oldZid; + node->n.branch[logRecord->u.balance.indexForParent].zid = + logRecord->u.balance.oldZid; } ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); ZPRINT_NODE(restoreBalanceParent2, buffer); @@ -4235,7 +4234,7 @@ ZPRINT_NINT(restoreBalanceChild_NumRecs, logRecord->u.balance.numToMove); else { /* branch */ numToMove = logRecord->u.balance.numToMove; - if ((numToMove > 0) && + if ((numToMove > 0) && (((BTBranch_s *)&logRecord->u.balance.data[0])->zid == node->n.branch[0].zid)) { /* if we are removing from the start of the branch record ... */ @@ -4389,8 +4388,8 @@ ZPRINT_NODE(restoreJoinParent1, buffer); --(node->numRecs); i = logRecord->u.split.indexForParent; memmove( &node->n.branch[i], /* Destination */ - &node->n.branch[i + 1], /* Source */ - (node->numRecs - i) * sizeof(BTBranch_s)); + &node->n.branch[i + 1], /* Source */ + (node->numRecs - i) * sizeof(BTBranch_s)); ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); ZPRINT_NODE(restoreJoinParent2, buffer); VALIDATE_NODE(node); @@ -4439,7 +4438,7 @@ ZPRINT_NINT(restoreJoinChild_NumRecs, logRecord->u.split.numToMove); { memcpy(packArea, currentZnode, znodeLength); } - + } node->n.leaf.nextLeaf = logRecord->u.split.leafLink; } @@ -4648,7 +4647,7 @@ ZPRINT_NINT(restoreSplitNewChild_NumRecs, logRecord->u.split.numToMove); else { memcpy(packArea, currentZnode, znodeLength); - } + } } node->n.leaf.nextLeaf = logRecord->u.split.leafLink; } @@ -4731,7 +4730,7 @@ ZPRINT_NINT(restoreJoinOverflow_NumRecs, logRecord->u.overflow.numToMove); { memcpy(packArea, currentZnode, znodeLength); } - + } } else @@ -4879,7 +4878,7 @@ ZPRINT_NINT(restoreOverflowChild_NumRecs, logRecord->u.overflow.numToMove); else { memcpy(packArea, currentZnode, znodeLength); - } + } } } else @@ -4990,7 +4989,7 @@ STATUS recoveryInsertZnodeLogical( znode = &logRecord->u.znode; - memcpy(&internalID, ((BYTE *)(&logRecord->u.znode)) + + memcpy(&internalID, ((BYTE *)(&logRecord->u.znode)) + znode->header.length, sizeof(GUID_t)); zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, &internalID, pool); @@ -5017,8 +5016,8 @@ STATUS recoveryInsertZnodeLogical( packedSize = BST_getPackedSize(beast); xaction = BeginXLocal(&zfsVol->vol, BXL_LOGICAL_UNDO); - status = ZFSVOL_VOL_InsertBeastIntoVolume(genMsg, beast, - packedSize, &xaction->xaction); + status = ZFSVOL_VOL_InsertBeastIntoVolume(genMsg, beast, + packedSize, &xaction->xaction); SET_LUNDO_LSN(xaction, logBuffer, status); EndXlocal(xaction); @@ -5117,7 +5116,7 @@ STATUS recoveryDeleteZnodeLogical( znode = &logRecord->u.znode; - memcpy(&internalID, ((BYTE *)(&logRecord->u.znode)) + + memcpy(&internalID, ((BYTE *)(&logRecord->u.znode)) + znode->header.length, sizeof(GUID_t)); zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, &internalID, pool); diff --git a/src/nwnss/zlss/beastTree.h b/src/nwnss/zlss/beastTree.h index 203ae96..fec1a82 100644 --- a/src/nwnss/zlss/beastTree.h +++ b/src/nwnss/zlss/beastTree.h @@ -32,7 +32,7 @@ | |--------------------------------------------------------------------------- | This module is used to: - | Define stuctures and + | Define stuctures and +-------------------------------------------------------------------------*/ #ifndef _BEASTTREE_H_ @@ -41,7 +41,7 @@ #ifndef _ZFS_H_ #include "zfs.h" #endif - + /* * Debug stuff */ @@ -111,12 +111,12 @@ void zprintNint(char *location, NINT value); #define MAX_LEAF_PTRS (MAX_LEAF_FREE/sizeof(NodeLen_t) - 1) /* is used as an array index -- must be zero based */ #define IS_SYSTEM_BEAST_ZID(_zid) \ - ((_zid < ZFSPOOL_MAX_RESERVED_SUPERBLK_ZID) && \ - (_zid > zINVALID_ZID)) + ((_zid < ZFSPOOL_MAX_RESERVED_SUPERBLK_ZID) && \ + (_zid > zINVALID_ZID)) #define SIZEOFFREESPACE(_node) \ - (MAX_LEAF_FREE - ((_node)->n.leaf.startOfFreeSpace + \ - (_node)->numRecs * sizeof(NodeLen_t))) + (MAX_LEAF_FREE - ((_node)->n.leaf.startOfFreeSpace + \ + (_node)->numRecs * sizeof(NodeLen_t))) #define LEAF n.leaf.space #define MIN_BRANCHES (MAX_BRANCHES / 2) @@ -126,38 +126,38 @@ void zprintNint(char *location, NINT value); #define BBT_IS_SYSTEM_BSTS_BLK(_n) ((_n)->state & BBT_SYSTEM_BSTS_BLK) #define BBT_HAS_PARENT(_n) \ - ((!BBT_IS_ROOT(_n)) && (!BBT_IS_SYSTEM_BSTS_BLK(_n))) + ((!BBT_IS_ROOT(_n)) && (!BBT_IS_SYSTEM_BSTS_BLK(_n))) #define BBT_IS_MAX_ENTRIES(_node, _parms) \ - (BBT_IS_LEAF(_node) \ - ? (_node->n.leaf.freeSpace < (parms->beastLen + \ - sizeof(NodeLen_t))) \ - : ((_node)->numRecs >= MAX_BRANCHES)) + (BBT_IS_LEAF(_node) \ + ? (_node->n.leaf.freeSpace < (parms->beastLen + \ + sizeof(NodeLen_t))) \ + : ((_node)->numRecs >= MAX_BRANCHES)) #define BBT_IS_MIN_ENTRIES(_node) \ - (BBT_IS_LEAF(_node) \ - ? (_node->n.leaf.freeSpace > MAX_LEAF_FREE / 2) \ - : ((_node)->numRecs <= MIN_BRANCHES)) + (BBT_IS_LEAF(_node) \ + ? (_node->n.leaf.freeSpace > MAX_LEAF_FREE / 2) \ + : ((_node)->numRecs <= MIN_BRANCHES)) #define BBT_IS_LESSTHAN_MAX(_node, _sibling) \ - (BBT_IS_LEAF(_node) \ - ? (((_node)->n.leaf.freeSpace + (_sibling)->n.leaf.freeSpace) > MAX_LEAF_FREE) \ - : (((_node)->numRecs + (_sibling)->numRecs) < MAX_BRANCHES)) + (BBT_IS_LEAF(_node) \ + ? (((_node)->n.leaf.freeSpace + (_sibling)->n.leaf.freeSpace) > MAX_LEAF_FREE) \ + : (((_node)->numRecs + (_sibling)->numRecs) < MAX_BRANCHES)) /* Macros used for latching and unlatching the beastTree beast and checking * to see if the beast we are inserting or updating is the beastTree beast */ #define BBT_X_LATCH_BEASTTREE(_parms) \ - if ((_parms)->beast != &(_parms)->ztree->ZFSBEASTTREEroot) \ - { \ - X_LATCH(&(_parms)->ztree->ZFSBEASTTREEbeastLatch); \ - } + if ((_parms)->beast != &(_parms)->ztree->ZFSBEASTTREEroot) \ + { \ + X_LATCH(&(_parms)->ztree->ZFSBEASTTREEbeastLatch); \ + } #define BBT_UNX_LATCH_BEASTTREE(_parms) \ - if ((_parms)->beast != &(_parms)->ztree->ZFSBEASTTREEroot) \ - { \ - UNX_LATCH(&(_parms)->ztree->ZFSBEASTTREEbeastLatch); \ - } + if ((_parms)->beast != &(_parms)->ztree->ZFSBEASTTREEroot) \ + { \ + UNX_LATCH(&(_parms)->ztree->ZFSBEASTTREEbeastLatch); \ + } #define GET_LEFTMOST_LEAF(_ztree) \ ((_ztree)->ZFSBEASTTREEroot.vol.zfsVol->pool->ZP_super-> \ @@ -171,21 +171,21 @@ typedef WORD NodeLen_t; */ typedef struct BeastTreeParms_s { - RootBeast_s *beast; /* the beast to be used */ - NINT beastLen; /* the length of the beast */ - Blknum_t readBlkNum; /* Next block to be read */ - NINT index; /* Where last record was found in parent*/ - Buffer_s *parent; /* Parent buffer */ - Buffer_s *child; /* Child buffer */ - Buffer_s *sibling; /* Sibling buffer */ - Znode_s *packArea; /* pointer to the area to put the packed record */ - struct ZfsXaction_s *xaction; /* Transaction being used */ - struct ZfsBeastTreeBeast_s *ztree; /* The pointer to the b-tree beast */ - BOOL physicalLogging; + RootBeast_s *beast; /* the beast to be used */ + NINT beastLen; /* the length of the beast */ + Blknum_t readBlkNum; /* Next block to be read */ + NINT index; /* Where last record was found in parent*/ + Buffer_s *parent; /* Parent buffer */ + Buffer_s *child; /* Child buffer */ + Buffer_s *sibling; /* Sibling buffer */ + Znode_s *packArea; /* pointer to the area to put the packed record */ + struct ZfsXaction_s *xaction; /* Transaction being used */ + struct ZfsBeastTreeBeast_s *ztree; /* The pointer to the b-tree beast */ + BOOL physicalLogging; } BeastTreeParms_s; - /* The physicalLogging parameter specifies whether to log inserts and - * deletes physically or + /* The physicalLogging parameter specifies whether to log inserts and + * deletes physically or * logically. For system beasts and the root dir zid we always do the * logging to physically undo, for all others we do the logging to * logically undo. We can do this because the location of the system @@ -197,8 +197,8 @@ typedef struct BeastTreeParms_s * allocates and initializes the left block. After physical undo is * complete the system beasts have to be in a stable state since logical * undo can modify them. Thus the system beasts inserts and deletes need - * to be done physically too. - */ + * to be done physically too. + */ /* @@ -206,23 +206,23 @@ typedef struct BeastTreeParms_s */ typedef struct BTBranch_s { - Zid_t zid; - Blknum_t child; + Zid_t zid; + Blknum_t child; } NSS_MEDIA_STRUCTURE(BTBranch_s,child) BTBranch_s; typedef struct BTLeaf_s { - /* - * If the size of the header portion changes then change MAX_LEAF_FREE. - */ - Blknum_t nextLeaf; /* link to the next leaf in the tree */ - WORD freeSpace; /* amount of free space left in leaf node */ - WORD startOfFreeSpace; /* pointer to the start of the free space */ - union - { - BYTE znode[MAX_LEAF_FREE]; /* space to store vnodes */ - NodeLen_t znodePtr[MAX_LEAF_FREE/sizeof(NodeLen_t)]; /* pointers to start of znodes */ - } NSS_MEDIA_UNION(NamelessUnion,znodePtr[MAX_LEAF_FREE/sizeof(NodeLen_t)]) space; + /* + * If the size of the header portion changes then change MAX_LEAF_FREE. + */ + Blknum_t nextLeaf; /* link to the next leaf in the tree */ + WORD freeSpace; /* amount of free space left in leaf node */ + WORD startOfFreeSpace; /* pointer to the start of the free space */ + union + { + BYTE znode[MAX_LEAF_FREE]; /* space to store vnodes */ + NodeLen_t znodePtr[MAX_LEAF_FREE/sizeof(NodeLen_t)]; /* pointers to start of znodes */ + } NSS_MEDIA_UNION(NamelessUnion,znodePtr[MAX_LEAF_FREE/sizeof(NodeLen_t)]) space; } NSS_MEDIA_STRUCTURE(BTLeaf_s,space.znodePtr[MAX_LEAF_FREE/sizeof(NodeLen_t)]) BTLeaf_s; @@ -232,37 +232,37 @@ typedef struct BTLeaf_s */ typedef struct GUIDWithBlock_t /* holds GUIDs*/ { - LONG timeLow; - WORD timeMid; - WORD timeHighAndVersion; - BYTE clockSeqHighAndReserved; - BYTE clockSeqLow; - Blknum_t GWB_Block; - BYTE GWB_Node[2]; + LONG timeLow; + WORD timeMid; + WORD timeHighAndVersion; + BYTE clockSeqHighAndReserved; + BYTE clockSeqLow; + Blknum_t GWB_Block; + BYTE GWB_Node[2]; } NSS_MEDIA_STRUCTURE(GUIDWithBlock_t, GWB_Node[2]) GUIDWithBlock_t; typedef struct BeastTreeNode_s { - /* - * If the size of the header portion changes then change MAX_FREEBLKS, - * MAX_BRANCHES and MAX_LEAF_FREE. - */ - LONG magic; - WORD state; - WORD numRecs; - Lsn_t lsn; - GUIDWithBlock_t btn_internalIDWithBlock; /* Must be at OFFSET 16 - unique volume ID with possible - * block number (used by relink). Also used in debug - * write code to validate block. Also used in LV delete - * to ensure no BT jumping occurs. - */ - union - { - BTBranch_s branch[MAX_BRANCHES]; - BTLeaf_s leaf; + /* + * If the size of the header portion changes then change MAX_FREEBLKS, + * MAX_BRANCHES and MAX_LEAF_FREE. + */ + LONG magic; + WORD state; + WORD numRecs; + Lsn_t lsn; + GUIDWithBlock_t btn_internalIDWithBlock; /* Must be at OFFSET 16 - unique volume ID with possible + * block number (used by relink). Also used in debug + * write code to validate block. Also used in LV delete + * to ensure no BT jumping occurs. + */ + union + { + BTBranch_s branch[MAX_BRANCHES]; + BTLeaf_s leaf; // Blknum_t freeBlks[MAX_FREEBLKS]; - } NSS_MEDIA_UNION(NamelessUnion,branch[MAX_BRANCHES]) n; + } NSS_MEDIA_UNION(NamelessUnion,branch[MAX_BRANCHES]) n; } NSS_MEDIA_STRUCTURE(BeastTreeNode_s,n.branch[MAX_BRANCHES]) BeastTreeNode_s; /* @@ -271,44 +271,44 @@ typedef struct BeastTreeNode_s typedef struct Split_s { - GUID_t s_internalID; - Zid_t zidForParent; /* zid to insert in the parent */ - Blknum_t leafLink; /* link to the next leaf in the tree */ - Blknum_t blockForParent; /* block number to insert in the parent */ - LONG indexForParent; /* index where zid is inserted in the parent */ - LONG totalLength; /* length of tree information being moved */ - WORD numToMove; /* number of entries logged */ - WORD nodeType; /* whether the new node is a branch or a leaf */ - BYTE data[1]; /* data to move */ + GUID_t s_internalID; + Zid_t zidForParent; /* zid to insert in the parent */ + Blknum_t leafLink; /* link to the next leaf in the tree */ + Blknum_t blockForParent; /* block number to insert in the parent */ + LONG indexForParent; /* index where zid is inserted in the parent */ + LONG totalLength; /* length of tree information being moved */ + WORD numToMove; /* number of entries logged */ + WORD nodeType; /* whether the new node is a branch or a leaf */ + BYTE data[1]; /* data to move */ } NSS_MEDIA_STRUCTURE(Split_s,data[1]) Split_s; typedef struct Overflow_s { - LONG totalLength; /* length of tree information being moved */ - WORD numToMove; /* number of entries logged */ - WORD nodeType; /* whether the new node is a branch or a leaf */ - BYTE data[1]; /* data to move */ + LONG totalLength; /* length of tree information being moved */ + WORD numToMove; /* number of entries logged */ + WORD nodeType; /* whether the new node is a branch or a leaf */ + BYTE data[1]; /* data to move */ } NSS_MEDIA_STRUCTURE(Overflow_s,data[1]) Overflow_s; typedef struct Grow_s { - GUID_t g_internalID; - Blknum_t blockForParent; /* block number to insert in the parent */ + GUID_t g_internalID; + Blknum_t blockForParent; /* block number to insert in the parent */ } NSS_MEDIA_STRUCTURE(Grow_s,blockForParent) Grow_s; typedef struct Balance_s { - Zid_t zidForParent; /* zid to insert in the parent */ - Zid_t oldZid; /* previous zid in the parent */ - LONG indexForParent; /* index where zid is changed in the parent */ - LONG totalLength; /* length of tree information being moved */ - WORD numToMove; /* number of entries moved */ - BYTE data[1]; /* data to move */ + Zid_t zidForParent; /* zid to insert in the parent */ + Zid_t oldZid; /* previous zid in the parent */ + LONG indexForParent; /* index where zid is changed in the parent */ + LONG totalLength; /* length of tree information being moved */ + WORD numToMove; /* number of entries moved */ + BYTE data[1]; /* data to move */ } NSS_MEDIA_STRUCTURE(Balance_s,data[1]) Balance_s; typedef struct BeastTreeInit_s { - GUID_t bti_internalID; + GUID_t bti_internalID; } NSS_MEDIA_STRUCTURE(BeastTreeInit_s,bti_internalID) BeastTreeInit_s; /* defines for direction */ @@ -317,19 +317,19 @@ typedef struct BeastTreeInit_s typedef struct BeastLog_s { - union - { - Znode_s znode; /* Volume ID for logical UNDO is packed in - * the log record after the variable len - * of the znode which is of size znode-> - * header.length - */ - Split_s split; - Overflow_s overflow; - Grow_s grow; - Balance_s balance; - BeastTreeInit_s bl_init; - } NSS_MEDIA_UNION(NamelessUnion,u) u; + union + { + Znode_s znode; /* Volume ID for logical UNDO is packed in + * the log record after the variable len + * of the znode which is of size znode-> + * header.length + */ + Split_s split; + Overflow_s overflow; + Grow_s grow; + Balance_s balance; + BeastTreeInit_s bl_init; + } NSS_MEDIA_UNION(NamelessUnion,u) u; } NSS_MEDIA_STRUCTURE(BeastLog_s,u.bl_init) BeastLog_s; /**************************************************************************** @@ -339,97 +339,97 @@ typedef struct BeastLog_s ****************************************************************************/ BOOL findZnodeByZid( - BeastTreeNode_s *node, - Zid_t zid, - NINT *i); + BeastTreeNode_s *node, + Zid_t zid, + NINT *i); void deleteZnodeFromChild( - BeastTreeNode_s *child, - NINT recNum); + BeastTreeNode_s *child, + NINT recNum); STATUS insertZnode ( - GeneralMsg_s *genMsg, - BeastTreeNode_s *child, - Zid_t zid, - NINT zlen, - Znode_s **packArea); + GeneralMsg_s *genMsg, + BeastTreeNode_s *child, + Zid_t zid, + NINT zlen, + Znode_s **packArea); STATUS getLeaf( - GeneralMsg_s *genMsg, - Zid_t zid, - ZfsVolume_s *volume, - BeastTreeParms_s *parms); + GeneralMsg_s *genMsg, + Zid_t zid, + ZfsVolume_s *volume, + BeastTreeParms_s *parms); STATUS ZFSVOL_VOL_InsertBeastIntoVolume( - struct GeneralMsg_s *genMsg, - struct RootBeast_s *beast, - NINT beastLen, - Xaction_s *xaction); + struct GeneralMsg_s *genMsg, + struct RootBeast_s *beast, + NINT beastLen, + Xaction_s *xaction); STATUS ZFSVOL_VOL_RemoveBeastFromVolume( - struct GeneralMsg_s *genMsg, - struct RootBeast_s *beast, - Xaction_s *xaction); + struct GeneralMsg_s *genMsg, + struct RootBeast_s *beast, + Xaction_s *xaction); STATUS ZFSVOL_VOL_UpdateBeastToVolume( - struct GeneralMsg_s *genMsg, - struct RootBeast_s *beast, - NINT beastLen, - Xaction_s *xaction); + struct GeneralMsg_s *genMsg, + struct RootBeast_s *beast, + NINT beastLen, + Xaction_s *xaction); void *ZFSVOL_VOL_GetBeastFromVolume( - struct GeneralMsg_s *genMsg, - Zid_t zid, - struct Volume_s *volume); + struct GeneralMsg_s *genMsg, + Zid_t zid, + struct Volume_s *volume); void ZFSVOL_CheckZeroZid( - struct Volume_s *volume); + struct Volume_s *volume); void *ZFSVOL_GetBeastFromBuffer( - struct GeneralMsg_s *genMsg, - Zid_t zid, - struct Volume_s *volume, - struct Buffer_s *buffer); + struct GeneralMsg_s *genMsg, + Zid_t zid, + struct Volume_s *volume, + struct Buffer_s *buffer); STATUS ZFSVOL_VOL_BrowseBeastsInVolume( struct GeneralMsg_s *genMsg, struct Volume_s *volume, - NINT selectionCriteria, - NINT numBeastsRequested, - Zid_t *lastZidReturned, /* inout */ - Zid_t *beastZids, /* out */ - NINT *numBeastsReturned); /* out */ + NINT selectionCriteria, + NINT numBeastsRequested, + Zid_t *lastZidReturned, /* inout */ + Zid_t *beastZids, /* out */ + NINT *numBeastsReturned); /* out */ Blknum_t findChildBlock( - BeastTreeNode_s *node, - Zid_t zid, - NINT *index); + BeastTreeNode_s *node, + Zid_t zid, + NINT *index); void initNode( - Buffer_s *buffer, - NINT state, - GUID_t *internalID); + Buffer_s *buffer, + NINT state, + GUID_t *internalID); void insertZeroNode( - BeastTreeNode_s *node); + BeastTreeNode_s *node); STATUS copyZnode( - GeneralMsg_s *genMsg, - BeastTreeNode_s *src, - BeastTreeNode_s *dst, - Zid_t zid); + GeneralMsg_s *genMsg, + BeastTreeNode_s *src, + BeastTreeNode_s *dst, + Zid_t zid); STATUS cleanZnode( - GeneralMsg_s *genMsg, - BeastTreeNode_s *src, - Zid_t zid); + GeneralMsg_s *genMsg, + BeastTreeNode_s *src, + Zid_t zid); STATUS moveZnode( - GeneralMsg_s *genMsg, - BeastTreeNode_s *src, - BeastTreeNode_s *dst, - Zid_t zid); + GeneralMsg_s *genMsg, + BeastTreeNode_s *src, + BeastTreeNode_s *dst, + Zid_t zid); void garbageCollectNode(BeastTreeNode_s *node); diff --git a/src/nwnss/zlss/btree.c b/src/nwnss/zlss/btree.c index f1a1d9a..69d7d9c 100644 --- a/src/nwnss/zlss/btree.c +++ b/src/nwnss/zlss/btree.c @@ -41,7 +41,7 @@ #include "zParams.h" /**************************************************************************** - * ZFS B-Tree beast constructor + * ZFS B-Tree beast constructor *****************************************************************************/ STATUS ZFSBTREE_Construct( GeneralMsg_s *genMsg, @@ -134,7 +134,7 @@ STATIC BYTE *ZFSBTREE_Pack( *****************************************************************************/ STATIC BYTE *ZFSBTREE_Unpack( GeneralMsg_s *genMsg, - void *beast_LX, + void *beast_LX, BYTE *storeBuffer) { ZfsBtreeBeast_s *beast = (ZfsBtreeBeast_s *)beast_LX; diff --git a/src/nwnss/zlss/dfsIO.c b/src/nwnss/zlss/dfsIO.c index 87aa86a..3f44217 100644 --- a/src/nwnss/zlss/dfsIO.c +++ b/src/nwnss/zlss/dfsIO.c @@ -40,25 +40,25 @@ ** ** These calls request that given the beast, offset, and number of units to ** be read/written (as part of the DirectFileIOMsg_s structure, the - ** information be read to/written from the buffer directly. - ** + ** information be read to/written from the buffer directly. + ** ** DIO_UNIT_SIZE is 512 BYTES ** DIO_UNIT_SHIFT is 9 - ** + ** ** typedef struct DirectFileIOMsg_s ** { ** QUAD unitOffset; * unit offset in file to read/write at ** NINT numUnits; * number units to read/write ** void *buffer; * buffer to read/write - ** NINT unitsXfered; * number units actually read/writen + ** NINT unitsXfered; * number units actually read/writen ** void (*callbackroutine)(); * callbackroutine for NoWait option ** NINT callbackparameter; * parameter for the callback routine ** } DirectFileIOMsg_s; - ** - ** + ** + ** ** If callbackroutine is NULL then it is a "NoWait" call. ** Otherwise, the callback routine is called after the data transfer. - ** + ** ****************************************************************************/ #include @@ -209,10 +209,10 @@ void zfsPoolDFSReadCallBack( STATUS GetFileMapExtent( zNSSMsg_s *msg, - RootBeast_s *beast, - QUAD fileUnitOffset, - NINT totalUnits, - QUAD *poolUnitOffset, + RootBeast_s *beast, + QUAD fileUnitOffset, + NINT totalUnits, + QUAD *poolUnitOffset, NINT *numUnits) { Blknum_t fileBlk, poolBlk /*, nextPoolBlk */; @@ -227,7 +227,7 @@ STATUS GetFileMapExtent( zASSERT(totalUnits != 0); /** Computing number of blocks needed **/ - len = (( fileUnitOffset + totalUnits - 1) >> unitsPerBlockShift) - + len = (( fileUnitOffset + totalUnits - 1) >> unitsPerBlockShift) - ( fileUnitOffset >> unitsPerBlockShift) + 1; fileBlk = fileUnitOffset >> unitsPerBlockShift; @@ -240,7 +240,7 @@ STATUS GetFileMapExtent( SetStatus(msg, zERR_HOLE_IN_DIO_FILE); return zFAILURE; } - unitOffsetIntoBlock = fileUnitOffset - (fileBlk << unitsPerBlockShift); + unitOffsetIntoBlock = fileUnitOffset - (fileBlk << unitsPerBlockShift); *poolUnitOffset = (poolBlk << unitsPerBlockShift) + unitOffsetIntoBlock; *numUnits = unitsPerBlock - unitOffsetIntoBlock; len--; @@ -255,7 +255,7 @@ STATUS GetFileMapExtent( /**************************************************************************** - * + * *****************************************************************************/ STATUS ZFSVOL_VOL_dioReadUnits( zNSSMsg_s *msg, @@ -264,8 +264,8 @@ STATUS ZFSVOL_VOL_dioReadUnits( #if 1 /* malDev.c did not support unitsize of anything but 4096 * Nobody is using direct IO calls. When we decide to support - * we will use bio which can support unitsize of 512, and - * look at what is being passed by the VFS layer and maybe + * we will use bio which can support unitsize of 512, and + * look at what is being passed by the VFS layer and maybe * able to use that */ SetStatus(msg, zERR_NOT_SUPPORTED); @@ -341,7 +341,7 @@ STATUS ZFSVOL_VOL_dioReadUnits( zASSERT( totalUnits != 0 ); while(totalUnits) { - if ((status = GetFileMapExtent(msg, beast, fileUnitOffset, + if ((status = GetFileMapExtent(msg, beast, fileUnitOffset, totalUnits, &poolUnitOffset, &numUnits)) != zOK) { break; @@ -365,14 +365,14 @@ STATUS ZFSVOL_VOL_dioReadUnits( } } - req = zMALFillIOMsg(NULL, + req = zMALFillIOMsg(NULL, phypool->ZCP_dev, - poolUnitOffset, - numUnits, + poolUnitOffset, + numUnits, DIO_UNIT_SIZE, - (numUnits << DIO_UNIT_SHIFT), + (numUnits << DIO_UNIT_SHIFT), buffer, - zfsPoolDFSReadCallBack, + zfsPoolDFSReadCallBack, (ADDR)cbContext, NULL); @@ -392,10 +392,10 @@ STATUS ZFSVOL_VOL_dioReadUnits( zMALFreeReqMsg(req); req = NULL; #if NSS_DEBUG IS_ENABLED - (beast->beastClass->classID <= zFTYPE_FILE) ? + (beast->beastClass->classID <= zFTYPE_FILE) ? beast->vol.volume->v_stats.IO_user_read_failure++ : beast->vol.volume->v_stats.IO_system_read_failure++; -#endif +#endif break; } @@ -404,8 +404,8 @@ STATUS ZFSVOL_VOL_dioReadUnits( buffer = (void *)((ADDR)buffer + (DIO_UNIT_SIZE * numUnits)); /* get IO counts */ if (beast->beastClass->classID <= zFTYPE_FILE) - { - beast->vol.volume->v_stats.IO_user_read_success++; + { + beast->vol.volume->v_stats.IO_user_read_success++; } #if NSS_DEBUG IS_ENABLED else @@ -452,9 +452,9 @@ STATUS ZFSVOL_VOL_dioReadUnits( ZIO_GatherDetailedSummaryInformationDIO( beast, ZPIOLH_STATE_DIO_READ_START, msg->sys.data[DIO_DATA].length >> DIO_UNIT_SHIFT ); } /* get IO size */ - if (beast->beastClass->classID <= zFTYPE_FILE) + if (beast->beastClass->classID <= zFTYPE_FILE) { - beast->vol.volume->v_stats.IO_user_readSize += msg->sys.data[DIO_DATA].length; + beast->vol.volume->v_stats.IO_user_readSize += msg->sys.data[DIO_DATA].length; } #if NSS_DEBUG IS_ENABLED else @@ -472,7 +472,7 @@ errorReturn: } /**************************************************************************** - * + * *****************************************************************************/ STATUS ZFSVOL_VOL_dioWriteUnits ( zNSSMsg_s *msg, @@ -481,15 +481,15 @@ STATUS ZFSVOL_VOL_dioWriteUnits ( #if 1 /* malDev.c did not support unitsize of anything but 4096 * Nobody is using direct IO calls. When we decide to support - * we will use bio which can support unitsize of 512, and - * look at what is being passed by the VFS layer and maybe + * we will use bio which can support unitsize of 512, and + * look at what is being passed by the VFS layer and maybe * able to use that */ SetStatus(msg, zERR_NOT_SUPPORTED); return zFAILURE; #else File_s *beast = (File_s *)beast_LX; - QUAD poolUnitOffset; + QUAD poolUnitOffset; NINT numUnits; NINT waitState; STATUS status = zOK; @@ -531,7 +531,7 @@ STATUS ZFSVOL_VOL_dioWriteUnits ( /*- get the storage deposit to access for this volume -*/ if((phypool = pool->storagepool->phypool) == NULL) { - zASSERT("Pool is no longer valid" != NULL); + zASSERT("Pool is no longer valid" != NULL); SetStatus(msg, zERR_POOL_NOT_ACCESSIBLE ); goto errorReturnCleanup; } @@ -539,7 +539,7 @@ STATUS ZFSVOL_VOL_dioWriteUnits ( zASSERT( totalUnits != 0 ); while(totalUnits) { - if ((status = GetFileMapExtent(msg, (RootBeast_s *)beast, + if ((status = GetFileMapExtent(msg, (RootBeast_s *)beast, fileUnitOffset, totalUnits, &poolUnitOffset, &numUnits)) != zOK) { break; @@ -562,14 +562,14 @@ STATUS ZFSVOL_VOL_dioWriteUnits ( cbContext->lastCount = 0; } } - req = zMALFillIOMsg(NULL, + req = zMALFillIOMsg(NULL, phypool->ZCP_dev, - poolUnitOffset, - numUnits, + poolUnitOffset, + numUnits, DIO_UNIT_SIZE, - (numUnits << DIO_UNIT_SHIFT), + (numUnits << DIO_UNIT_SHIFT), buffer, - zfsPoolDFSWriteCallBack, + zfsPoolDFSWriteCallBack, (ADDR)cbContext, NULL); @@ -599,10 +599,10 @@ STATUS ZFSVOL_VOL_dioWriteUnits ( zMALFreeReqMsg(req); req = NULL; #if NSS_DEBUG IS_ENABLED - (((RootBeast_s *)beast)->beastClass->classID <= zFTYPE_FILE) ? + (((RootBeast_s *)beast)->beastClass->classID <= zFTYPE_FILE) ? ((RootBeast_s *)beast)->vol.volume->v_stats.IO_user_write_failure++ : ((RootBeast_s *)beast)->vol.volume->v_stats.IO_system_write_failure++; -#endif +#endif break; } @@ -612,7 +612,7 @@ STATUS ZFSVOL_VOL_dioWriteUnits ( /* get IO counts */ if (((RootBeast_s *)beast)->beastClass->classID <= zFTYPE_FILE) { - ((RootBeast_s *)beast)->vol.volume->v_stats.IO_user_write_success++; + ((RootBeast_s *)beast)->vol.volume->v_stats.IO_user_write_success++; } #if NSS_DEBUG IS_ENABLED else @@ -661,7 +661,7 @@ STATUS ZFSVOL_VOL_dioWriteUnits ( } if (((RootBeast_s *)beast)->beastClass->classID <= zFTYPE_FILE) { - ((RootBeast_s *)beast)->vol.volume->v_stats.IO_user_writeSize + ((RootBeast_s *)beast)->vol.volume->v_stats.IO_user_writeSize += msg->sys.data[DIO_DATA].length; } #if NSS_DEBUG IS_ENABLED @@ -690,7 +690,7 @@ errorReturn: STATUS DIO_Startup(void) { - return (objCacheCreate( &DIOcbContext, "DIOcbContext", + return (objCacheCreate( &DIOcbContext, "DIOcbContext", sizeof(zfsPoolDFSControl_s), NULL)); } diff --git a/src/nwnss/zlss/dir.h b/src/nwnss/zlss/dir.h index ce1f6e5..e4d029b 100644 --- a/src/nwnss/zlss/dir.h +++ b/src/nwnss/zlss/dir.h @@ -40,7 +40,7 @@ #define ADD_DELFILE_ZID_IN_NTREE_KEY 1 /* A null char is appended to all file names */ -typedef struct dir_key_s +typedef struct dir_key_s { Zid_t pzid; /* Parent directory's ZID */ #if ADD_DELFILE_ZID_IN_NTREE_KEY @@ -51,7 +51,7 @@ typedef struct dir_key_s fname_char_t name[1]; /* File name; inline */ } NSS_MEDIA_STRUCTURE(dir_key_s,name[1]) dir_key_s; -typedef struct dir_key_ool_s +typedef struct dir_key_ool_s { Zid_t pzid; /* Parent directory's ZID */ #if ADD_DELFILE_ZID_IN_NTREE_KEY @@ -74,9 +74,9 @@ typedef struct dir_key_ool_s extern void keycopy(dir_key_s *_dstkey, dir_key_s *_srckey); extern SNINT keycomp(dir_key_s *k1, dir_key_s *k2); -typedef SNINT (*fname_cmpfn_t)(CONST fname_char_t *n1, CONST fname_char_t *n2, +typedef SNINT (*fname_cmpfn_t)(CONST fname_char_t *n1, CONST fname_char_t *n2, NINT flags); -typedef BOOL (*fpat_cmpfn_t)(fname_char_t *pattern, fname_char_t *name, +typedef BOOL (*fpat_cmpfn_t)(fname_char_t *pattern, fname_char_t *name, NINT flags); #define DIR_OP_LOOKUP 0 @@ -103,7 +103,7 @@ typedef BOOL (*fpat_cmpfn_t)(fname_char_t *pattern, fname_char_t *name, extern STATUS dir_op_common( NameTreeParms_s *parms, - dir_key_s *key, + dir_key_s *key, nsmask_t ns_mask, SNINT op, Zid_t *zid, @@ -115,10 +115,10 @@ dir_op_common( extern STATUS dir_pat_lookup( NameTreeParms_s *parms, - Zid_t pzid, + Zid_t pzid, NINT nameType, nsmask_t ns_mask, - fname_char_t *pattern, + fname_char_t *pattern, SearchMap_s *smap, Zid_t *zid, // cnt NINT *nameUniquifier, diff --git a/src/nwnss/zlss/dirTree.c b/src/nwnss/zlss/dirTree.c index c969efa..4c5a6e1 100644 --- a/src/nwnss/zlss/dirTree.c +++ b/src/nwnss/zlss/dirTree.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include "dirTree.h" @@ -208,7 +207,7 @@ void DBT_DoDisplayDirTree( buffer = ZFS_ReadPoolBlk( &genMsg, &iomsg); zASSERT(buffer != NULL); DBT_DisplaySubtree(ztree, buffer); - DBG_DebugPrintf(LMAGENTA, MSGNot("\nTotal branches = %d\n"), + DBG_DebugPrintf(LMAGENTA, MSGNot("\nTotal branches = %d\n"), DBT_TotalBranches); DBG_DebugPrintf(LMAGENTA, MSGNot("Total leafs = %d\n"), DBT_TotalLeafs); @@ -265,10 +264,10 @@ void DBT_validateNode( DirLeafEntry_s *curr; DirLeafEntry_s *prev; - zASSERT(node->magic == DBT_LEAF_MAGIC || node->magic == + zASSERT(node->magic == DBT_LEAF_MAGIC || node->magic == (DBT_LEAF_MAGIC | 0x20)); - if ((node->magic != DBT_LEAF_MAGIC) && + if ((node->magic != DBT_LEAF_MAGIC) && (node->magic != (DBT_LEAF_MAGIC | 0x20))) { return; @@ -282,7 +281,7 @@ void DBT_validateNode( curr = &node->DLEAF(count); // zASSERT(curr->usedAmount <= curr->restrictionAmount); - + /* check if ascending */ zASSERT(prev->dirZid < curr->dirZid); @@ -307,7 +306,7 @@ void DBT_validateNode( for(count = 1; count < node->numRecs; count++) { curr = &node->DBRANCH(count); - + /* check if ascending */ zASSERT(prev->dirZid < curr->dirZid); @@ -392,12 +391,12 @@ Blknum_t DBT_findChildBlock( ENTER(TZTREE, DBT_findChildBlock); - while (low <= high) + while (low <= high) { mid = (low + high) / 2; dirZidFromMid = node->DBRANCH(mid).dirZid; if (dirZid == dirZidFromMid) - { + { break; } else if (dirZid > dirZidFromMid) @@ -442,7 +441,7 @@ BOOL DBT_findLeafEntry( ENTER(TZTREE, DBT_findLeafEntry); DBT_VALIDATE_NODE(node); - while (low <= high) + while (low <= high) { mid = (low + high) / 2; dirZidFromMid = node->DLEAF(mid).dirZid; @@ -512,9 +511,9 @@ void DBT_insertZeroNode (DirTreeNode_s *node) DBT_VALIDATE_NODE(node); /* - * We always want a zero in the first location to establish a lower bound - * so we do not need a lot of special case code. - */ + * We always want a zero in the first location to establish a lower bound + * so we do not need a lot of special case code. + */ node->numRecs = 1; node->DLEAF(0).dirZid = 0; node->DLEAF(0).quota = 0; @@ -590,8 +589,8 @@ STATUS DBT_join ( /* update the leaf link */ child->n.leaf.nextLeaf = sibling->n.leaf.nextLeaf; /* Change magic in Deleted Leaf Node to indicate it is deleted. This - * is being done for scan mode of rebuild. - */ + * is being done for scan mode of rebuild. + */ sibling->magic |= 0x20; /* Lower case low byte letter */ } else @@ -611,8 +610,8 @@ STATUS DBT_join ( parentIndex = parms->index + 1; entryInParent = parent->DBRANCH(parentIndex).dirZid; memmove( &parent->DBRANCH(parentIndex), /* Destination */ - &parent->DBRANCH(parentIndex + 1), /* Source */ - (parent->numRecs - parentIndex) * sizeof(DirBranchEntry_s)); + &parent->DBRANCH(parentIndex + 1), /* Source */ + (parent->numRecs - parentIndex) * sizeof(DirBranchEntry_s)); localXaction = BeginXLocal(parms->volume, BXL_DEFAULT); @@ -655,14 +654,14 @@ STATUS DBT_join ( ZLOG_BIND(localXaction, parms->parent); if (DBT_IS_LEAF(child) ) { /* This is the deleted LEAF block we must write so that rebuild - * can scan whole disk and not find OLD beast tree leafs. - */ + * can scan whole disk and not find OLD beast tree leafs. + */ parms->sibling->state |= CACHE_DIRTY; ZLOG_BIND(localXaction, parms->sibling); #if 0 /* This code allows for testing of the recovery code of setting - * the magic word on deletes. - */ + * the magic word on deletes. + */ #if NSS_ASSERT IS_ENABLED { extern LONG gZlogAssertBlock; @@ -719,14 +718,14 @@ STATUS DBT_balance ( avg = (child->numRecs + sibling->numRecs) / 2; - /* Don't do balancing if no records can be moved */ + /* Don't do balancing if no records can be moved */ if (child->numRecs == avg || (sibling->numRecs == avg)) { /* - * The entry we were looking for when we started the balance my be - * in either the child or the sibling entry. Make sure that it - * ends up in the child. - */ + * The entry we were looking for when we started the balance my be + * in either the child or the sibling entry. Make sure that it + * ends up in the child. + */ if (parms->dirZid >= parent->DBRANCH(parms->index + 1).dirZid) { CACHE_RELEASE(parms->child); @@ -734,7 +733,7 @@ STATUS DBT_balance ( } else { - CACHE_RELEASE(parms->sibling); + CACHE_RELEASE(parms->sibling); } RTN_STATUS(zOK); } @@ -754,8 +753,8 @@ STATUS DBT_balance ( /* move the entries from sibling to child */ memcpy(startLocation, /* Destination */ - &sibling->DLEAF(0), /* Source */ - lenMoved); + &sibling->DLEAF(0), /* Source */ + lenMoved); /* move sibling entries back to the front of the record */ memmove(&sibling->DLEAF(0), /* Destination */ @@ -781,8 +780,8 @@ STATUS DBT_balance ( /* move the entries from the child to the sibling */ memcpy(startLocation, - &child->DLEAF(child->numRecs - numToMove), - lenMoved); + &child->DLEAF(child->numRecs - numToMove), + lenMoved); child->numRecs -= numToMove; sibling->numRecs += numToMove; @@ -799,8 +798,8 @@ STATUS DBT_balance ( /* move the entries from sibling to child */ memcpy(startLocation, /* Destination */ - &sibling->DBRANCH(0), /* Source */ - lenMoved); + &sibling->DBRANCH(0), /* Source */ + lenMoved); /* move sibling entries back to the front of the record */ memmove(&sibling->DBRANCH(0), /* Destination */ @@ -826,8 +825,8 @@ STATUS DBT_balance ( /* move the entries from the child to the sibling */ memcpy(startLocation, - &child->DBRANCH(child->numRecs - numToMove), - lenMoved); + &child->DBRANCH(child->numRecs - numToMove), + lenMoved); child->numRecs -= numToMove; sibling->numRecs += numToMove; @@ -944,7 +943,7 @@ STATUS DBT_underflow ( parms->sibling = DBT_ReadPoolBlk(genMsg, &iomsg); if (parms->sibling == NULL) { - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } DBT_VALIDATE_NODE((DirTreeNode_s *)parms->sibling->pBuf.data); } @@ -955,9 +954,9 @@ STATUS DBT_underflow ( READBLK_IO_MSG(iomsg, dirTreeBeast, parms->readBlkNum, CACHE_UPDATE); SET_DEBUG_ID(iomsg, 2); /* - * Release the latch so we do not latch out of order -- This is - * OK because the parent latch is held. - */ + * Release the latch so we do not latch out of order -- This is + * OK because the parent latch is held. + */ CACHE_PIN(parms->sibling); CACHE_UNXLATCH(parms->sibling); parms->child = DBT_ReadPoolBlk(genMsg, &iomsg); @@ -966,7 +965,7 @@ STATUS DBT_underflow ( if (parms->child == NULL) { CACHE_RELEASE(parms->sibling); - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } DBT_VALIDATE_NODE((DirTreeNode_s *)parms->child->pBuf.data); } @@ -1205,9 +1204,9 @@ STATUS DBT_split ( parms->readBlkNum = parms->child->volBlk; /* - * Sibling is the node to be split. It is the left node in the split. - * Child is the new node. - */ + * Sibling is the node to be split. It is the left node in the split. + * Child is the new node. + */ child = (DirTreeNode_s *)parms->child->pBuf.data; holdState = sibling->state & DBT_LEAF; @@ -1248,8 +1247,8 @@ STATUS DBT_split ( } /* - * Make room in the parent to place the node - */ + * Make room in the parent to place the node + */ i = parms->index + 1; memmove(&parent->DBRANCH(i + 1), /* Destination */ &parent->DBRANCH(i), /* Source */ @@ -1505,7 +1504,7 @@ void DBT_logInsertRecord ( ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[0], parms->child->volBlk, child->lsn, parms->child, parms->xaction, 0, DBT_compare); - logRecord->u.entry.internalID = + logRecord->u.entry.internalID = parms->dirTreeBeast->ZFSDIRTREEroot.ROOTinternalID; logRecord->u.entry.dirZid = parms->dirZid; logRecord->u.entry.quota = quota; @@ -1534,17 +1533,17 @@ STATUS DBT_insertEntry ( DirLeafEntry_s *entry; /* - * This routine assumes a check has ready been done to make sure there - * there is enough free space in the buffer to hold the new znode. - */ + * This routine assumes a check has ready been done to make sure there + * there is enough free space in the buffer to hold the new znode. + */ ENTER(TZTREE, insertZnode); child = (DirTreeNode_s *)parms->child->pBuf.data; /* - * Add the entry to the leaf node - */ + * Add the entry to the leaf node + */ if (DBT_findLeafEntry(child, parms->dirZid, &i)) { zASSERT("Same dir added twice to dir b-tree" == NULL); @@ -1572,7 +1571,7 @@ STATUS DBT_insertEntry ( * * Input: Child and parent are latched. Child is buffer to inserted into. * - * Output: Parent and child are unlatched. + * Output: Parent and child are unlatched. ****************************************************************************/ STATUS DBT_doInsertEntry ( GeneralMsg_s *genMsg, @@ -1586,17 +1585,17 @@ STATUS DBT_doInsertEntry ( if (parms->type == DBT_TYPE_USED_AMOUNT) { /* - * If we get an insert that is adjusting the used amount it means - * that the quotas have been enabled, but the initial setting of - * the quota has not happened yet. We can ignore these requests - * because the amount will be recomputed. - */ + * If we get an insert that is adjusting the used amount it means + * that the quotas have been enabled, but the initial setting of + * the quota has not happened yet. We can ignore these requests + * because the amount will be recomputed. + */ #if NSS_DEBUG IS_ENABLED aprintf(YELLOW, "Inserting a new Dir Quota while modifying used amount\n"); #endif if (DBT_IS_ROOT((DirTreeNode_s *)parms->child->pBuf.data)) { - UNX_LATCH(&parms->dirTreeBeast->ZFSDIRTREEbeastLatch); + UNX_LATCH(&parms->dirTreeBeast->ZFSDIRTREEbeastLatch); } else { @@ -1659,7 +1658,7 @@ void DBT_logModifyRecord ( ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[0], parms->child->volBlk, child->lsn, parms->child, parms->xaction, 0, DBT_compare); - logRecord->u.modify.internalID = + logRecord->u.modify.internalID = parms->dirTreeBeast->ZFSDIRTREEroot.ROOTinternalID; logRecord->u.modify.dirZid = parms->dirZid; logRecord->u.modify.oldValue = oldValue; @@ -1787,7 +1786,7 @@ STATUS DBT_findLeaf ( { if (DBT_IS_ROOT(node)) { - UNX_LATCH(&parms->dirTreeBeast->ZFSDIRTREEbeastLatch); + UNX_LATCH(&parms->dirTreeBeast->ZFSDIRTREEbeastLatch); } } if (!DBT_IS_ROOT(node)) @@ -1835,8 +1834,8 @@ STATUS DBT_modifyDirValue ( ENTER(TZTREE, DBT_modifyDirValue); /* - * Get an exclusive latch on the Dir Tree Beast - */ + * Get an exclusive latch on the Dir Tree Beast + */ X_LATCH(&dirTreeBeast->ZFSDIRTREEbeastLatch); if (dirTreeBeast->zfsBtree.p.btRoot == INVALID_BLK) @@ -1869,7 +1868,7 @@ STATUS DBT_modifyDirValue ( /* log the init record */ ZLOG_ObtainRecord(localXaction, - ZLOG_BLOCK_INFO_SIZE(1) + sizeof(DBTTreeInit_s) ); + ZLOG_BLOCK_INFO_SIZE(1) + sizeof(DBTTreeInit_s) ); ZLOG_INIT_LOG_RECORD(XFUNC_DIRTREE_INIT, localXaction, logBuffer, 1, poolBlks, logRecord); @@ -1894,8 +1893,8 @@ STATUS DBT_modifyDirValue ( } /* - * If the entry already exists then update it, otherwise insert it - */ + * If the entry already exists then update it, otherwise insert it + */ if (DBT_findLeafEntry((DirTreeNode_s *)parms->child->pBuf.data, parms->dirZid, &index)) { @@ -2058,7 +2057,7 @@ STATUS ZFSVOL_VOL_GetDirQuotaInfo( /* init return values */ *quota = zDIR_NO_QUOTA; - *usedAmount = 0; + *usedAmount = 0; if ((volume->VOLenabledAttributes & zATTR_DIR_QUOTAS) == 0 || dirTreeBeast == NULL) @@ -2072,8 +2071,8 @@ STATUS ZFSVOL_VOL_GetDirQuotaInfo( parms.dirZid = dirZid; /* - * Get an exclusive latch on the Dir Tree Beast - */ + * Get an exclusive latch on the Dir Tree Beast + */ S_LATCH(&dirTreeBeast->ZFSDIRTREEbeastLatch); if (dirTreeBeast->zfsBtree.p.btRoot == INVALID_BLK) { @@ -2081,7 +2080,7 @@ STATUS ZFSVOL_VOL_GetDirQuotaInfo( SetErrno(genMsg, zERR_NO_SUCH_DIR); RTN_STATUS(zFAILURE); } - + /* read the root node */ READBLK_IO_MSG(iomsg, dirTreeBeast, dirTreeBeast->zfsBtree.p.btRoot, CACHE_READ); @@ -2095,7 +2094,7 @@ STATUS ZFSVOL_VOL_GetDirQuotaInfo( RTN_STATUS(zFAILURE); } DBT_VALIDATE_NODE((DirTreeNode_s *)parms.child->pBuf.data); - + /* decend the tree to the leaf */ if (DBT_getLeaf(genMsg, (ZfsVolume_s *)volume, &parms) != zOK) { @@ -2112,7 +2111,7 @@ STATUS ZFSVOL_VOL_GetDirQuotaInfo( CACHE_RELEASE(parms.child); RTN_STATUS(zFAILURE); } - else + else { *quota = node->DLEAF(index).quota; *usedAmount = node->DLEAF(index).usedAmount; @@ -2164,10 +2163,10 @@ STATUS ZFSVOL_VOL_BrowseDirsInVolume( UNS_LATCH(&dirTreeBeast->ZFSDIRTREEbeastLatch); goto done; } - + /* - * Find the next dir after *lastDirReturned. - */ + * Find the next dir after *lastDirReturned. + */ /* read the root node */ READBLK_IO_MSG(iomsg, dirTreeBeast, dirTreeBeast->zfsBtree.p.btRoot, @@ -2184,7 +2183,7 @@ STATUS ZFSVOL_VOL_BrowseDirsInVolume( DBT_VALIDATE_NODE(node); /* descend the tree to the leaf */ - if ((status = DBT_getLeaf(genMsg, (ZfsVolume_s *)volume, + if ((status = DBT_getLeaf(genMsg, (ZfsVolume_s *)volume, &parms)) != zOK) { goto done; @@ -2198,17 +2197,17 @@ STATUS ZFSVOL_VOL_BrowseDirsInVolume( } ++ index; /* Skip the last matched entry */ - /* - * Return the directory entries of next numEntriesRequested entries - * by sequentially scanning the dir tree's leaf nodes - * - * Sequentially scan the linked list of leaf nodes for beasts to return - * (starting at the beast at (parms.child, index)). - */ + /* + * Return the directory entries of next numEntriesRequested entries + * by sequentially scanning the dir tree's leaf nodes + * + * Sequentially scan the linked list of leaf nodes for beasts to return + * (starting at the beast at (parms.child, index)). + */ for (; entryIndex < numEntriesRequested; entryIndex++, index++) { /* Skip to a leaf node with entries to process */ - if (index >= node->numRecs) + if (index >= node->numRecs) { /* Jump to the next leaf node */ if (node->n.leaf.nextLeaf == INVALID_BLK) @@ -2274,7 +2273,7 @@ void DBT_logDeleteRecord ( ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[0], parms->child->volBlk, child->lsn, parms->child, parms->xaction, 0, DBT_compare); - logRecord->u.entry.internalID = + logRecord->u.entry.internalID = parms->dirTreeBeast->ZFSDIRTREEroot.ROOTinternalID; logRecord->u.entry.dirZid = child->DLEAF(index).dirZid; logRecord->u.entry.quota = child->DLEAF(index).quota; @@ -2351,7 +2350,7 @@ STATUS DBT_doDeleteDir ( errorExit: //zASSERT(0); CACHE_DIRTY_RELEASE(parms->child); - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } @@ -2379,8 +2378,8 @@ STATUS ZFSVOL_VOL_RemoveDirectory( } /* - * Don't allow zero entry to be deleted. - */ + * Don't allow zero entry to be deleted. + */ if (dirZid == 0) { SetErrno(genMsg, zERR_NO_SUCH_DIR); @@ -2449,8 +2448,8 @@ STATUS ZFSVOL_VOL_ResetAllDirEntries( zASSERT(!(volume->VOLenabledAttributes & zATTR_READONLY)); /* - * If there is no tree then don't bother. - */ + * If there is no tree then don't bother. + */ if (dirTreeBeast == NULL) { STACK_FREE(); @@ -2458,8 +2457,8 @@ STATUS ZFSVOL_VOL_ResetAllDirEntries( } /* - * Get an exclusive latch on the Directory Tree Beast - */ + * Get an exclusive latch on the Directory Tree Beast + */ X_LATCH(&dirTreeBeast->ZFSDIRTREEbeastLatch); if (dirTreeBeast->zfsBtree.p.btRoot == INVALID_BLK) @@ -2494,9 +2493,9 @@ STATUS ZFSVOL_VOL_ResetAllDirEntries( node = (DirTreeNode_s *)buffer->pBuf.data; if (DBT_IS_LEAF(node)) { /* - * If it is a leaf then set up so on the next loop it will be - * deleted. - */ + * If it is a leaf then set up so on the next loop it will be + * deleted. + */ zASSERT(node->magic == DBT_LEAF_MAGIC); cacheReleaseToss(buffer); readALeaf = TRUE; @@ -2512,9 +2511,9 @@ STATUS ZFSVOL_VOL_ResetAllDirEntries( } else { /* - * it's a branch -- push on the stack and move on to its first - * child - */ + * it's a branch -- push on the stack and move on to its first + * child + */ readALeaf = FALSE; zASSERT(node->magic == DBT_BRANCH_MAGIC); @@ -2546,12 +2545,12 @@ STATUS ZFSVOL_VOL_ResetAllDirEntries( node = (DirTreeNode_s *)buffer->pBuf.data; /* - * If we have read all of the child records we can now delete - * them. - * - * If one of the children was a leaf they all will be so there - * is no reason to read them all. Just delete them. - */ + * If we have read all of the child records we can now delete + * them. + * + * If one of the children was a leaf they all will be so there + * is no reason to read them all. Just delete them. + */ aStack->parentStack[stkPtr].entry++; if ((aStack->parentStack[stkPtr].entry >= node->numRecs) || readALeaf) { @@ -2562,15 +2561,15 @@ STATUS ZFSVOL_VOL_ResetAllDirEntries( { ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2)); - ZLOG_INIT_LOG_RECORD(XFUNC_DIRTREE_REMOVE, xaction, + ZLOG_INIT_LOG_RECORD(XFUNC_DIRTREE_REMOVE, xaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, node->lsn, buffer, xaction, 0); node->lsn = logBuffer->ZXR_Lsn; node->numRecs--; - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], - node->DBRANCH(node->numRecs).child, 0, NULL, + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], + node->DBRANCH(node->numRecs).child, 0, NULL, xaction, 1); ZLOG_DELETE_BLOCK(xaction, poolBlks[1]); @@ -2604,20 +2603,20 @@ STATUS ZFSVOL_VOL_ResetAllDirEntries( ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2)); - ZLOG_INIT_LOG_RECORD(XFUNC_DIRTREE_REMOVE, xaction, logBuffer, 2, + ZLOG_INIT_LOG_RECORD(XFUNC_DIRTREE_REMOVE, xaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], 0, 0, NULL, xaction, 0); - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], dirTreeBeast->zfsBtree.p.btRoot, 0, + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], dirTreeBeast->zfsBtree.p.btRoot, 0, NULL, xaction, 0); ZLOG_DELETE_BLOCK(xaction, poolBlks[1]); ZLOG_ReleaseRecord(xaction); /* - * Fix up the dir tree beast to show no tree - */ + * Fix up the dir tree beast to show no tree + */ dirTreeBeast->zfsBtree.p.btRoot = INVALID_BLK; COMN_MARK_BEAST_XLOCAL(&dirTreeBeast->ZFSDIRTREEroot, &xaction->xaction); @@ -2677,9 +2676,9 @@ STATUS DBT_CreateDirTreeBeast( volume->ZLSSVOLdirTree = (ZfsDirTreeBeast_s *)beast; BEASTHASH_Insert(beast); /* - * We do not want these special system beasts to be in the POOL - * linked list. - */ + * We do not want these special system beasts to be in the POOL + * linked list. + */ DQ_RMV(beast, volLink); return zOK; } @@ -2944,13 +2943,13 @@ STATUS DBT_recoveryBalance( { /* fix up the parent */ if (action == X_REDO) { - node->DBRANCH(logRecord->u.balance.indexForParent).dirZid = + node->DBRANCH(logRecord->u.balance.indexForParent).dirZid = logRecord->u.balance.dirZidForParent; } else { - node->DBRANCH(logRecord->u.balance.indexForParent).dirZid = - logRecord->u.balance.oldDirID; + node->DBRANCH(logRecord->u.balance.indexForParent).dirZid = + logRecord->u.balance.oldDirID; } ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); DBT_VALIDATE_NODE(node); @@ -2982,7 +2981,7 @@ STATUS DBT_recoveryBalance( if (DBT_IS_LEAF(node)) { /* leaf */ numToMove = logRecord->u.balance.numToMove; - if ((numToMove > 0) && + if ((numToMove > 0) && (((DirLeafEntry_s *)&logRecord->u.balance.data[0])->dirZid == node->DLEAF(0).dirZid)) { /* if we are removing from the start of the leaf record ... */ @@ -2994,7 +2993,7 @@ STATUS DBT_recoveryBalance( else { /* branch */ numToMove = logRecord->u.balance.numToMove; - if ((numToMove > 0) && + if ((numToMove > 0) && (((DirBranchEntry_s *)&logRecord->u.balance.data[0])->dirZid == node->DBRANCH(0).dirZid)) { /* if we are removing from the start of the branch record ... */ @@ -3143,8 +3142,8 @@ STATUS DBT_recoveryJoin( --(node->numRecs); i = logRecord->u.split.indexForParent; memmove( &node->DBRANCH(i), /* Destination */ - &node->DBRANCH(i + 1), /* Source */ - (node->numRecs - i) * sizeof(DirBranchEntry_s)); + &node->DBRANCH(i + 1), /* Source */ + (node->numRecs - i) * sizeof(DirBranchEntry_s)); ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); DBT_VALIDATE_NODE(node); CACHE_DIRTY_RELEASE(buffer); @@ -3571,8 +3570,8 @@ STATUS DBT_recoveryInsertEntryLogical( logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); COMN_INCLUDE_INTERNAL_VOLUMES(genMsg); - zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, - &logRecord->u.entry.internalID, pool); + zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, + &logRecord->u.entry.internalID, pool); COMN_EXCLUDE_INTERNAL_VOLUMES(genMsg); if (zfsVol == NULL) @@ -3619,8 +3618,8 @@ STATUS DBT_recoveryDeleteEntryLogical( } logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, - &logRecord->u.entry.internalID, pool); + zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, + &logRecord->u.entry.internalID, pool); if (zfsVol == NULL) { return zFAILURE; @@ -3628,7 +3627,7 @@ STATUS DBT_recoveryDeleteEntryLogical( xaction = BeginXLocal(&zfsVol->vol, BXL_LOGICAL_UNDO); - status = ZFSVOL_VOL_RemoveDirectory(genMsg, &zfsVol->vol, + status = ZFSVOL_VOL_RemoveDirectory(genMsg, &zfsVol->vol, &xaction->xaction, logRecord->u.entry.dirZid); SET_LUNDO_LSN(xaction, logBuffer, status); @@ -3661,7 +3660,7 @@ STATUS DBT_recoveryModifyEntryLogical( } logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, + zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, &logRecord->u.modify.internalID, pool); if (zfsVol == NULL) { diff --git a/src/nwnss/zlss/dirTree.h b/src/nwnss/zlss/dirTree.h index 21e26b5..52ffec9 100644 --- a/src/nwnss/zlss/dirTree.h +++ b/src/nwnss/zlss/dirTree.h @@ -46,7 +46,7 @@ #ifndef _ZFS_H_ #include "zfs.h" #endif - + #if NSS_DEBUG IS_ENABLED #define DBT_VALIDATE_NODE(_node) (DBT_validateNode(_node)) #else @@ -62,12 +62,12 @@ /* state of a node */ #define DBT_LEAF 0x1 /* Leaf node of a B-tree */ #define DBT_ROOT 0x2 /* Root node of a B-tree */ -#define DBT_REZID_DONE 0x4 /* This node was ReZid - * This bit is only used while we are - * in the process of rezidding. - * When rezid is complete we clear this - * bit. - */ +#define DBT_REZID_DONE 0x4 /* This node was ReZid + * This bit is only used while we are + * in the process of rezidding. + * When rezid is complete we clear this + * bit. + */ #define DBT_SMALL DISABLE //#define DBT_SMALL ENABLE @@ -88,19 +88,19 @@ #define DBT_MIN_LEAF_ENTRIES (DBT_MAX_LEAF_ENTRIES / 2) #define DBT_IS_MAX_ENTRIES(_node, _parms) \ - (DBT_IS_LEAF(_node) \ - ? ((_node)->numRecs >= DBT_MAX_LEAF_ENTRIES) \ - : ((_node)->numRecs >= DBT_MAX_BRANCH_ENTRIES)) + (DBT_IS_LEAF(_node) \ + ? ((_node)->numRecs >= DBT_MAX_LEAF_ENTRIES) \ + : ((_node)->numRecs >= DBT_MAX_BRANCH_ENTRIES)) #define DBT_IS_MIN_ENTRIES(_node) \ - (DBT_IS_LEAF(_node) \ - ? ((_node)->numRecs <= DBT_MIN_LEAF_ENTRIES) \ - : ((_node)->numRecs <= DBT_MIN_BRANCH_ENTRIES)) + (DBT_IS_LEAF(_node) \ + ? ((_node)->numRecs <= DBT_MIN_LEAF_ENTRIES) \ + : ((_node)->numRecs <= DBT_MIN_BRANCH_ENTRIES)) #define DBT_IS_LESSTHAN_MAX(_node, _sibling) \ - (DBT_IS_LEAF(_node) \ - ? (((_node)->numRecs + (_sibling)->numRecs) < DBT_MAX_LEAF_ENTRIES) \ - : (((_node)->numRecs + (_sibling)->numRecs) < DBT_MAX_BRANCH_ENTRIES)) + (DBT_IS_LEAF(_node) \ + ? (((_node)->numRecs + (_sibling)->numRecs) < DBT_MAX_LEAF_ENTRIES) \ + : (((_node)->numRecs + (_sibling)->numRecs) < DBT_MAX_BRANCH_ENTRIES)) #define DBRANCH(_entry) n.branch.entry[(_entry)] #define DLEAF(_entry) n.leaf.entry[(_entry)] @@ -112,17 +112,17 @@ */ typedef struct DirTreeParms_s { - Zid_t dirZid; /* the directory ID to be used */ - Volume_s *volume; - Blknum_t readBlkNum; /* Next block to be read */ - NINT index; /* Where last record was found in parent*/ - SQUAD value; /* The value being set or adjusted */ - NINT type; /* The type of data contained in the value -- see defines below */ - Buffer_s *parent; /* Parent buffer */ - Buffer_s *child; /* Child buffer */ - Buffer_s *sibling; /* Sibling buffer */ - struct ZfsXaction_s *xaction; /* Transaction being used */ - struct ZfsDirTreeBeast_s *dirTreeBeast; /* The pointer to the b-tree beast */ + Zid_t dirZid; /* the directory ID to be used */ + Volume_s *volume; + Blknum_t readBlkNum; /* Next block to be read */ + NINT index; /* Where last record was found in parent*/ + SQUAD value; /* The value being set or adjusted */ + NINT type; /* The type of data contained in the value -- see defines below */ + Buffer_s *parent; /* Parent buffer */ + Buffer_s *child; /* Child buffer */ + Buffer_s *sibling; /* Sibling buffer */ + struct ZfsXaction_s *xaction; /* Transaction being used */ + struct ZfsDirTreeBeast_s *dirTreeBeast; /* The pointer to the b-tree beast */ } DirTreeParms_s; /* @@ -138,52 +138,52 @@ typedef struct DirTreeParms_s typedef struct DirBranchEntry_s { - Zid_t dirZid; - Blknum_t child; + Zid_t dirZid; + Blknum_t child; } NSS_MEDIA_STRUCTURE(DirBranchEntry_s,child) DirBranchEntry_s; typedef struct DirBranch_s { - DirBranchEntry_s entry[DBT_MAX_BRANCH_ENTRIES]; + DirBranchEntry_s entry[DBT_MAX_BRANCH_ENTRIES]; } NSS_MEDIA_STRUCTURE(DirBranch_s,entry[DBT_MAX_BRANCH_ENTRIES]) DirBranch_s; typedef struct DirLeafEntry_s { - Zid_t dirZid; - SQUAD usedAmount; - SQUAD quota; + Zid_t dirZid; + SQUAD usedAmount; + SQUAD quota; } NSS_MEDIA_STRUCTURE(DirLeafEntry_s,quota) DirLeafEntry_s; typedef struct DirLeaf_s { - /* - * If the size of the header portion changes then change - * DBT_MAX_LEAF_ENTRIES. - */ - Blknum_t nextLeaf; /* link to the next leaf in the tree */ - DirLeafEntry_s entry[DBT_MAX_LEAF_ENTRIES]; + /* + * If the size of the header portion changes then change + * DBT_MAX_LEAF_ENTRIES. + */ + Blknum_t nextLeaf; /* link to the next leaf in the tree */ + DirLeafEntry_s entry[DBT_MAX_LEAF_ENTRIES]; } NSS_MEDIA_STRUCTURE(DirLeaf_s,entry[DBT_MAX_LEAF_ENTRIES]) DirLeaf_s; typedef struct DirTreeNode_s { - /* - * If the size of the header portion changes then change - * DBT_MAX_BRANCH_ENTRIES and DBT_MAX_LEAF_ENTRIES. - */ - LONG magic; - WORD state; - WORD numRecs; - Lsn_t lsn; - GUID_t dtn_internalID; /* Must be at OFFSET 16 - unique volume ID (used - * by scanning repair). dtn -> directory Tree Node. - */ - union - { - DirBranch_s branch; - DirLeaf_s leaf; - } NSS_MEDIA_UNION(NamelessUnion,leaf) n; + /* + * If the size of the header portion changes then change + * DBT_MAX_BRANCH_ENTRIES and DBT_MAX_LEAF_ENTRIES. + */ + LONG magic; + WORD state; + WORD numRecs; + Lsn_t lsn; + GUID_t dtn_internalID; /* Must be at OFFSET 16 - unique volume ID (used + * by scanning repair). dtn -> directory Tree Node. + */ + union + { + DirBranch_s branch; + DirLeaf_s leaf; + } NSS_MEDIA_UNION(NamelessUnion,leaf) n; } NSS_MEDIA_STRUCTURE(DirTreeNode_s,n.leaf) DirTreeNode_s; /* @@ -192,60 +192,60 @@ typedef struct DirTreeNode_s typedef struct DBTEntry_s { - Zid_t dirZid; /* directory to be modified */ - SQUAD quota; /* Value for restriction amount */ - GUID_t internalID; + Zid_t dirZid; /* directory to be modified */ + SQUAD quota; /* Value for restriction amount */ + GUID_t internalID; } NSS_MEDIA_STRUCTURE(DBTEntry_s,internalID) DBTEntry_s; typedef struct DBTModify_s { - Zid_t dirZid; /* directory to be modified */ - SQUAD oldValue; /* Value before change */ - SQUAD value; /* Value for change */ - LONG type; /* type of value ("used amount" or "restriction") */ - GUID_t internalID; + Zid_t dirZid; /* directory to be modified */ + SQUAD oldValue; /* Value before change */ + SQUAD value; /* Value for change */ + LONG type; /* type of value ("used amount" or "restriction") */ + GUID_t internalID; } NSS_MEDIA_STRUCTURE(DBTModify_s,internalID) DBTModify_s; typedef struct DBTSplit_s { - GUID_t internalID; - Zid_t dirZidForParent; /* zid to insert in the parent */ - Blknum_t leafLink; /* link to the next leaf in the tree */ - Blknum_t blockForParent; /* block number to insert in the parent */ - LONG indexForParent; /* index where zid is inserted in the parent */ - WORD numToMove; /* number of entries logged */ - LONG totalLength; /* length of tree information being moved */ - WORD nodeType; /* whether the new node is a branch or a leaf */ - BYTE data[1]; /* data to move */ + GUID_t internalID; + Zid_t dirZidForParent; /* zid to insert in the parent */ + Blknum_t leafLink; /* link to the next leaf in the tree */ + Blknum_t blockForParent; /* block number to insert in the parent */ + LONG indexForParent; /* index where zid is inserted in the parent */ + WORD numToMove; /* number of entries logged */ + LONG totalLength; /* length of tree information being moved */ + WORD nodeType; /* whether the new node is a branch or a leaf */ + BYTE data[1]; /* data to move */ } NSS_MEDIA_STRUCTURE(DBTSplit_s,data) DBTSplit_s; typedef struct DBTOverflow_s { - LONG totalLength; /* length of tree information being moved */ - WORD numToMove; /* number of entries logged */ - WORD nodeType; /* whether the new node is a branch or a leaf */ - BYTE data[1]; /* data to move */ + LONG totalLength; /* length of tree information being moved */ + WORD numToMove; /* number of entries logged */ + WORD nodeType; /* whether the new node is a branch or a leaf */ + BYTE data[1]; /* data to move */ } NSS_MEDIA_STRUCTURE(DBTOverflow_s,data) DBTOverflow_s; typedef struct DBTGrow_s { - GUID_t internalID; - Blknum_t blockForParent; /* block number to insert in the parent */ + GUID_t internalID; + Blknum_t blockForParent; /* block number to insert in the parent */ } NSS_MEDIA_STRUCTURE(DBTGrow_s,blockForParent) DBTGrow_s; typedef struct DBTBalance_s { - Zid_t dirZidForParent; /* zid to insert in the parent */ - Zid_t oldDirID; /* previous dir zid in the parent */ - LONG indexForParent; /* index where entry is changed in the parent */ - LONG totalLength; /* length of tree information being moved */ - WORD numToMove; /* number of entries moved */ - BYTE data[1]; /* data to move */ + Zid_t dirZidForParent; /* zid to insert in the parent */ + Zid_t oldDirID; /* previous dir zid in the parent */ + LONG indexForParent; /* index where entry is changed in the parent */ + LONG totalLength; /* length of tree information being moved */ + WORD numToMove; /* number of entries moved */ + BYTE data[1]; /* data to move */ } NSS_MEDIA_STRUCTURE(DBTBalance_s,data) DBTBalance_s; typedef struct DBTTreeInit_s { - GUID_t internalID; + GUID_t internalID; } NSS_MEDIA_STRUCTURE(DBTTreeInit_s,internalID) DBTTreeInit_s; /* defines for direction */ @@ -255,22 +255,22 @@ typedef struct DBTTreeInit_s typedef struct DirLog_s { - union - { - DBTEntry_s entry; - DBTModify_s modify; - DBTSplit_s split; - DBTOverflow_s overflow; - DBTGrow_s grow; - DBTBalance_s balance; - DBTTreeInit_s initTree; - } NSS_MEDIA_UNION(NamelessUnion,initTree) u; + union + { + DBTEntry_s entry; + DBTModify_s modify; + DBTSplit_s split; + DBTOverflow_s overflow; + DBTGrow_s grow; + DBTBalance_s balance; + DBTTreeInit_s initTree; + } NSS_MEDIA_UNION(NamelessUnion,initTree) u; } NSS_MEDIA_STRUCTURE(DirLog_s,u.initTree) DirLog_s; typedef struct NTShrinkLogRecord_s { - LONG offsetOfPoke; - Blknum_t valueOfPoke; - /* The UNDO poke value is poolBlks[1] */ + LONG offsetOfPoke; + Blknum_t valueOfPoke; + /* The UNDO poke value is poolBlks[1] */ } NSS_MEDIA_STRUCTURE(NTShrinkLogRecord_s,valueOfPoke) NTShrinkLogRecord_s; /**************************************************************************** @@ -280,45 +280,45 @@ typedef struct NTShrinkLogRecord_s { ****************************************************************************/ STATUS ZFSVOL_VOL_GetDirQuotaInfo( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - Zid_t dirZid, - SQUAD *restrictionAmount, - SQUAD *usedAmount); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + Zid_t dirZid, + SQUAD *restrictionAmount, + SQUAD *usedAmount); STATUS ZFSVOL_VOL_SetDirQuota( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - struct Xaction_s *xAction, - Zid_t dirZid, - SQUAD restrictionAmount); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + struct Xaction_s *xAction, + Zid_t dirZid, + SQUAD restrictionAmount); void ZFSVOL_VOL_AdjustUsedDirSpace( - struct Xaction_s *xAction, - struct Volume_s *volume, - Zid_t dirZid, - SQUAD amountToAdjust); - + struct Xaction_s *xAction, + struct Volume_s *volume, + Zid_t dirZid, + SQUAD amountToAdjust); + STATUS ZFSVOL_VOL_RemoveDirectory( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - struct Xaction_s *xAction, - Zid_t dirZid); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + struct Xaction_s *xAction, + Zid_t dirZid); STATUS ZFSVOL_VOL_ResetAllDirEntries( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume); STATUS ZFSVOL_VOL_BrowseDirsInVolume( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - NINT numEntriesRequested, - Zid_t *lastDirReturned, /* inout */ - struct COMNDirQuota_s *dirEntries, /* out */ - NINT *numEntriesReturned); /* out */ + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT numEntriesRequested, + Zid_t *lastDirReturned, /* inout */ + struct COMNDirQuota_s *dirEntries, /* out */ + NINT *numEntriesReturned); /* out */ STATUS DBT_CreateDirTreeBeast( - struct GeneralMsg_s *genMsg, - struct ZfsVolume_s *volume); + struct GeneralMsg_s *genMsg, + struct ZfsVolume_s *volume); #endif diff --git a/src/nwnss/zlss/dir_ops.c b/src/nwnss/zlss/dir_ops.c index 18e2574..977c753 100644 --- a/src/nwnss/zlss/dir_ops.c +++ b/src/nwnss/zlss/dir_ops.c @@ -43,7 +43,7 @@ STATIC SNINT namecmp_nocase(fname_char_t *storename, fname_char_t *lookupname) { - while (TOLOWER(*storename) == TOLOWER(*lookupname)) + while (TOLOWER(*storename) == TOLOWER(*lookupname)) { if (*storename++ == 0) return 0; @@ -56,16 +56,16 @@ SNINT keycomp(dir_key_s *k1, dir_key_s *k2) { fname_char_t *n1, *n2; SNINT diff; - + if (k1->pzid != k2->pzid) { return (k1->pzid < k2->pzid) ? -1 : 1; } - if ((diff = (SNINT) (k1->nameType - k2->nameType)) != 0) + if ((diff = (SNINT) (k1->nameType - k2->nameType)) != 0) return diff; n1 = (k1->namelen & NAMEool) ? ((dir_key_ool_s *)k1)->name : k1->name; n2 = (k2->namelen & NAMEool) ? ((dir_key_ool_s *)k2)->name : k2->name; - if ((diff = namecmp_nocase(n1, n2)) != 0) + if ((diff = namecmp_nocase(n1, n2)) != 0) return diff; #if ADD_DELFILE_ZID_IN_NTREE_KEY if (k1->nameType == zNTYPE_DELETED_FILE) @@ -84,11 +84,11 @@ SNINT keycomp(dir_key_s *k1, dir_key_s *k2) void keycopy(dir_key_s *dstkey, dir_key_s *srckey) { - if (srckey->namelen & NAMEool) + if (srckey->namelen & NAMEool) { WORD nlen = srckey->namelen & NAMEnameLenMask; memmove(dstkey, srckey, FIELD_OFFSET(dir_key_s, name)); - memmove(dstkey->name, ((dir_key_ool_s *)srckey)->name, + memmove(dstkey->name, ((dir_key_ool_s *)srckey)->name, nlen * sizeof(fname_char_t)); dstkey->name[nlen] = 0; dstkey->namelen &= ~NAMEool; @@ -118,15 +118,15 @@ namecopy(SearchMap_s *smap, FullDirectoryInfo_s *dirinfo, Leaf_s *e) sizeof(fname_char_t); oldlen = kc->buflen; - - if (namelen > oldlen) + + if (namelen > oldlen) { BYTE *newmem; - NINT newlen = (namelen > DEFAULT_CURSOR_MEM) ? + NINT newlen = (namelen > DEFAULT_CURSOR_MEM) ? namelen : DEFAULT_CURSOR_MEM; if (oldlen == 0) kc->name = 0; - if (! (newmem = (BYTE *)realloc(kc->name, newlen))) + if (! (newmem = (BYTE *)realloc(kc->name, newlen))) { return zERR_NO_MEMORY; } @@ -141,7 +141,7 @@ namecopy(SearchMap_s *smap, FullDirectoryInfo_s *dirinfo, Leaf_s *e) kc->namelen = e->k.namelen & ~(NAMEovflow|NAMEdup); // cnt kc->nameUniquifier = e->nameUniquifier; kc->zid = e->zid; - if (dirinfo != 0) + if (dirinfo != 0) { NINT nlen = (e->k.namelen & NAMEnameLenMask) + 1; dirinfo->zid = kc->zid; @@ -158,12 +158,12 @@ namecopy(SearchMap_s *smap, FullDirectoryInfo_s *dirinfo, Leaf_s *e) STATIC inline BOOL leaf_keycomp( - dir_key_s *k1, - Zid_t zid, -// cnt NINT nameUniquifier, - nsmask_t ns_mask, - Leaf_s *e, - BOOL exact, + dir_key_s *k1, + Zid_t zid, +// cnt NINT nameUniquifier, + nsmask_t ns_mask, + Leaf_s *e, + BOOL exact, fname_cmpfn_t ncmpfn) { fname_char_t *n1, *n2; @@ -178,15 +178,15 @@ BOOL leaf_keycomp( zASSERT((k1->nameType != zNTYPE_DELETED_FILE) || (k1->zid == zid)); #endif /* ADD_DELFILE_ZID_IN_NTREE_KEY */ - return - (exact + return + (exact ? (e->ns_mask == ns_mask) && (NAMECMP_EXACT(n1, n2) == 0) - : (e->ns_mask & ns_mask) && - (ncmpfn(n2, n1, k2->namelen & + : (e->ns_mask & ns_mask) && + (ncmpfn(n2, n1, k2->namelen & (~(NAMEnameLenMask|NAMEool))) == 0)) - && ((k1->nameType == zNTYPE_DELETED_FILE) + && ((k1->nameType == zNTYPE_DELETED_FILE) ? ( - /* cnt ((nameUniquifier == zFNU_UNDEFINED) || + /* cnt ((nameUniquifier == zFNU_UNDEFINED) || (nameUniquifier == e->nameUniquifier)) && */ ((zid == zINVALID_ZID) || (zid == e->zid))) : TRUE); @@ -208,7 +208,7 @@ STATIC valid_smap_tab_s ValidSmapTable = /* control head for the hash */ STATUS valid_smap_tab_init(void) { LOCK_VALID_SMAP_TAB(); - if (ValidSmapTable.vst_hash == NULL) + if (ValidSmapTable.vst_hash == NULL) { NINT i; CONST NINT hashSize = ValidSmapTable.size; @@ -237,7 +237,7 @@ void valid_smap_tab_uninit(void) DQhead_t *hp; NINT i; SearchMap_s *smap; - + LOCK_VALID_SMAP_TAB(); if (ValidSmapTable.vst_hash != NULL) { @@ -246,7 +246,7 @@ void valid_smap_tab_uninit(void) for (;;) { DQ_DEQ(hp, smap, SearchMap_s, SMAPvalidLink); - if (smap != NULL) + if (smap != NULL) { SMAP_CURSOR(smap)->leafhint = INVALID_BLK; SMAP_CURSOR(smap)->ovflow_hint = INVALID_BLK; @@ -279,13 +279,13 @@ revalidate_smap(SearchMap_s *smap, Blknum_t leafhint, Blknum_t ovflow_hint) ZFSNameSearchCtrl_s *kc = SMAP_CURSOR(smap); LOCK_VALID_SMAP_TAB(); - if (kc->leafhint != leafhint) + if (kc->leafhint != leafhint) { - if (kc->leafhint != INVALID_BLK) + if (kc->leafhint != INVALID_BLK) { DQ_RMV(smap, SMAPvalidLink); } - if (leafhint != INVALID_BLK) + if (leafhint != INVALID_BLK) { NINT hash_ind = ntree_blknum_hash(leafhint) % ValidSmapTable.size; zASSERT(!QMEMBER(&smap->SMAPvalidLink)); @@ -309,13 +309,13 @@ invalidate_smaps(Blknum_t leafhint, Blknum_t ovflow_hint) hash_ind = ntree_blknum_hash(leafhint) % ValidSmapTable.size; LOCK_VALID_SMAP_TAB(); - if (ValidSmapTable.vst_hash != NULL) + if (ValidSmapTable.vst_hash != NULL) { hashPtr = &ValidSmapTable.vst_hash[hash_ind]; - DQ_FOREACH(hashPtr, smap, SearchMap_s, SMAPvalidLink) + DQ_FOREACH(hashPtr, smap, SearchMap_s, SMAPvalidLink) { - if ((SMAP_CURSOR(smap)->leafhint == leafhint) && - (remove_all || (SMAP_CURSOR(smap)->ovflow_hint == ovflow_hint))) + if ((SMAP_CURSOR(smap)->leafhint == leafhint) && + (remove_all || (SMAP_CURSOR(smap)->ovflow_hint == ovflow_hint))) { /* If this a matching entry, invalidate the smap */ SMAP_CURSOR(smap)->leafhint = INVALID_BLK; @@ -338,7 +338,7 @@ invalidate_smaps(Blknum_t leafhint, Blknum_t ovflow_hint) * */ void node_findkeyWithOverflow( - NameTreeParms_s *parms, + NameTreeParms_s *parms, Node_s *node, dir_key_s *key, Node_s *ovflow_node, @@ -431,7 +431,7 @@ NINT NT_getBlockList( return blockCount; } - startBlock = (index == NODE_LEFTMOST(node)) ? node->child_blk : + startBlock = (index == NODE_LEFTMOST(node)) ? node->child_blk : BRANCH_ENTRY(node, index)->child_blk; /* The block at index (startBlock) will be the first block in the array returned */ @@ -459,14 +459,14 @@ NINT NT_getBlockList( STATUS dir_op_common( - NameTreeParms_s *parms, - dir_key_s *key, - nsmask_t ns_mask, - SNINT op, - Zid_t *zid, + NameTreeParms_s *parms, + dir_key_s *key, + nsmask_t ns_mask, + SNINT op, + Zid_t *zid, // cnt NINT *nameUniquifier, FullDirectoryInfo_s *dirinfo, - nsmask_t newmask, + nsmask_t newmask, fname_cmpfn_t ncmpfn) { ZfsNameTree_s *ntree = parms->ntree; @@ -493,13 +493,13 @@ dir_op_common( goto error_ret; } - for (;;) + for (;;) { buf = 0; - if (nextchild == INVALID_BLK) + if (nextchild == INVALID_BLK) { - if (op == DIR_OP_INSERT) + if (op == DIR_OP_INSERT) { dlog_s lhdr = {{0,0},0,0}; dlog_s *dlog_rec, *dlhdr; @@ -519,7 +519,7 @@ dir_op_common( &ntree->ZFSNAMETREEinternalID ); if ((rc = ntree_ch_root_node(parms, xaction, (Buffer_s *)0, buf)) - != zOK) + != zOK) { /* * FixFixFix6: Should not deallocate if we have abort_xaction @@ -529,9 +529,9 @@ dir_op_common( END_XACTION(xaction); goto error_ret; } - ntree->zfsBtree.levelsInTree++; + ntree->zfsBtree.levelsInTree++; lhdr.nOps = 1; - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(1, DLOG_DATA_SIZE(&lhdr, 0))); DLOG_INIT_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -556,7 +556,7 @@ dir_op_common( ZLOG_ReleaseRecordAndLogEnd(xaction); END_XACTION(xaction); } - else + else { rc = zERR_NAME_NOT_FOUND_IN_DIRECTORY; goto error_ret; @@ -565,8 +565,8 @@ dir_op_common( else if ((rc = FETCH_NTREE_BLK_EXCL(parms, nextchild, &buf, 40)) != zOK) { goto error_ret; - } - else + } + else { currentLevel++; } @@ -577,11 +577,11 @@ dir_op_common( node_ind_t ind = NODE_LEFTMOST(node); /* Perform overflow/underflow handling only if NameTree is writable */ - if (! NTREE_IS_READONLY(parms)) + if (! NTREE_IS_READONLY(parms)) { - if (NODE_OVFLOW(node)) + if (NODE_OVFLOW(node)) { - if ((rc = BRANCH_OVFLOW(parms, &buf, &parbuf, + if ((rc = BRANCH_OVFLOW(parms, &buf, &parbuf, &parind, key, &curmatch)) != zOK) goto error_ret; } else if (parbuf && (node->nfreebytes > NODE_UNDERFLOW)) @@ -597,17 +597,17 @@ dir_op_common( if ((currentLevel+1) == ntree->zfsBtree.levelsInTree) { - BTREE_ReadAheadMetadata(&ntree->zfsBtree.ZFSBTREEroot, + BTREE_ReadAheadMetadata(&ntree->zfsBtree.ZFSBTREEroot, node, ind, NT_getBlockList, nextchild); } - if (NTREE_IS_READONLY(parms) && NODE_OVFLOW(node)) + if (NTREE_IS_READONLY(parms) && NODE_OVFLOW(node)) { Buffer_s *ovflow_buf; Node_s *ovflow_node; curmatch = prevmatch = 0; // Just force a node_findkey all the time. What was a match may not still be // a match after processing the overflow block, etc. - if ((rc = FETCH_NTREE_BLK_SHARED(parms, node->u.ovflow_blk, &ovflow_buf, 52)) != zOK) + if ((rc = FETCH_NTREE_BLK_SHARED(parms, node->u.ovflow_blk, &ovflow_buf, 52)) != zOK) { goto error_ret; } @@ -624,9 +624,9 @@ dir_op_common( } else break; - if (parbuf) + if (parbuf) { - if (ntree_latched && (parbuf->BUFblknum == NTREE_GET_ROOT_BLK(ntree))) + if (ntree_latched && (parbuf->BUFblknum == NTREE_GET_ROOT_BLK(ntree))) { UNLATCH_NTREE(ntree); ntree_latched = 0; @@ -638,7 +638,7 @@ dir_op_common( ntree->zfsBtree.levelsInTree = currentLevel; zASSERT(IS_LEAF(node)); - + { node_ind_t ind, dupind = -1, nextind; Buffer_s *firstbuf = 0, *tmpbuf = 0; @@ -649,7 +649,7 @@ dir_op_common( isdup = found = node_findkey(node, key, &ind); /* For all operations except Insert, the key must be present in the tree */ - if ((!found) && (op != DIR_OP_INSERT)) + if ((!found) && (op != DIR_OP_INSERT)) { rc = zERR_NAME_NOT_FOUND_IN_DIRECTORY; goto error_ret; @@ -660,26 +660,26 @@ dir_op_common( if (op != DIR_OP_INSERT) { #endif /* CHECK_DUPKEY_INSERT */ - if (found) + if (found) { head = e = LEAF_ENTRY(node, ind); found = leaf_keycomp(key, *zid, /* cnt *nameUniquifier,*/ ns_mask, e, exact, ncmpfn); - if (found) + if (found) goto do_leaf_operation; - if (e->k.namelen & NAMEdup) + if (e->k.namelen & NAMEdup) { SNINT esize = ENTRYSIZE_FROM_KEY(&e->k, LEAF_DATASIZE); Dupinfo_s *di = (Dupinfo_s *)((char *)e + esize); - if (e->k.namelen & NAMEovflow) + if (e->k.namelen & NAMEovflow) { Blknum_t ovflow_blk = di->ovflow_blk; - while (ovflow_blk != INVALID_BLK) + while (ovflow_blk != INVALID_BLK) { Node_s *tmpnode; SNINT i; if ((rc = FETCH_NTREE_BLK_EXCL(parms, ovflow_blk, - &tmpbuf, 41)) != zOK) + &tmpbuf, 41)) != zOK) { if (firstbuf) RELEASE_NTREE_BLK(parms, firstbuf); goto error_ret; @@ -687,7 +687,7 @@ dir_op_common( if (! firstbuf) firstbuf = tmpbuf; tmpnode = (Node_s *) tmpbuf->pBuf.data; e = (Leaf_s *)tmpnode->padbytes; - for (i=0; i < tmpnode->numRecs; ++ i) + for (i=0; i < tmpnode->numRecs; ++ i) { dupind = i; if ((found = leaf_keycomp(key, *zid, /* cnt *nameUniquifier, */ @@ -696,7 +696,7 @@ dir_op_common( e = (Leaf_s *)((char *)e + LEAF_ENTRY_SIZE(e)); } ovflow_blk = tmpnode->u.nextleaf; - if (! ((op == DIR_OP_DELETE) && (tmpbuf == firstbuf))) + if (! ((op == DIR_OP_DELETE) && (tmpbuf == firstbuf))) { RELEASE_NTREE_BLK(parms, tmpbuf); if (tmpbuf == firstbuf) @@ -705,11 +705,11 @@ dir_op_common( } } } - else + else { SNINT i, ndups = di->nduplicates; e = (Leaf_s *)((char *)e + sizeof(Dupinfo_s)); - for (i=0; i < ndups; ++ i) + for (i=0; i < ndups; ++ i) { e = (Leaf_s *)((char *)e + esize); dupind = i; @@ -728,11 +728,11 @@ dir_op_common( do_leaf_operation: ; #ifdef CHECK_DUPKEY_INSERT - if ((op == DIR_OP_INSERT) && found) + if ((op == DIR_OP_INSERT) && found) { - if (firstbuf) + if (firstbuf) RELEASE_NTREE_BLK(parms, firstbuf); - if (tmpbuf && (tmpbuf != firstbuf)) + if (tmpbuf && (tmpbuf != firstbuf)) RELEASE_NTREE_BLK(parms, tmpbuf); zASSERT("Inserting a duplicate name"==NULL); rc = zERR_FILE_ALREADY_EXISTS; @@ -741,23 +741,23 @@ do_leaf_operation: ; else #endif /* CHECK_DUPKEY_INSERT */ - if ((op != DIR_OP_INSERT) && ! found) + if ((op != DIR_OP_INSERT) && ! found) { /* Couldn't find an exact match (in case of Lookup, modify, delete) */ - if (firstbuf) + if (firstbuf) RELEASE_NTREE_BLK(parms, firstbuf); - if (tmpbuf && (tmpbuf != firstbuf)) + if (tmpbuf && (tmpbuf != firstbuf)) RELEASE_NTREE_BLK(parms, tmpbuf); rc = zERR_NAME_NOT_FOUND_IN_DIRECTORY; goto error_ret; } rc = zOK; - switch (op) + switch (op) { case DIR_OP_LOOKUP: /* Lookup */ *zid = e->zid; // cnt *nameUniquifier = e->nameUniquifier; - if (dirinfo != 0) + if (dirinfo != 0) { WORD nlen = (e->k.namelen & NAMEnameLenMask) + 1; dirinfo->zid = *zid; @@ -785,7 +785,7 @@ do_leaf_operation: ; if (tmpbuf) RELEASE_NTREE_BLK(parms, tmpbuf); if (isdup) ind = - (ind + 3); /* Inserting a duplicate key */ - rc = node_ovflow_insert(parms, &buf, ind, &parbuf, &parind, key, + rc = node_ovflow_insert(parms, &buf, ind, &parbuf, &parind, key, (BYTE *)&d, LEAF_DATASIZE, 0); break; } @@ -802,7 +802,7 @@ do_leaf_operation: ; lhdr.nOps = 1; dlog_size = LEAF_ENTRY_SIZE(e); - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks, DLOG_DATA_SIZE(&lhdr, dlog_size))); DLOG_INIT_LOGICAL_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -811,8 +811,8 @@ do_leaf_operation: ; *DLOG_HDR(dlog_rec) = lhdr; dlog_ops = DLOG_OPS(dlog_rec); dlog_entries = DLOG_ENTRIES(dlog_rec); - - DLOG_SET_BLKINFO(dlog_blkinfo, 0, modbuf, + + DLOG_SET_BLKINFO(dlog_blkinfo, 0, modbuf, ((Node_s *)modbuf->pBuf.data)->vers, xaction); ((Node_s *)modbuf->pBuf.data)->vers = dlbuf->ZXR_Lsn; if (tmpbuf) ind = -1; @@ -846,7 +846,7 @@ do_leaf_operation: ; { lhdr.nOps = 1; dlog_size = LEAF_ENTRY_SIZE(e); - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks, DLOG_DATA_SIZE(&lhdr, dlog_size))); DLOG_INIT_LOGICAL_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -855,14 +855,14 @@ do_leaf_operation: ; *DLOG_HDR(dlog_rec) = lhdr; dlog_ops = DLOG_OPS(dlog_rec); dlog_entries = DLOG_ENTRIES(dlog_rec); - - DLOG_SET_BLKINFO(dlog_blkinfo, 0, modbuf, + + DLOG_SET_BLKINFO(dlog_blkinfo, 0, modbuf, ((Node_s *)modbuf->pBuf.data)->vers, xaction); ((Node_s *)modbuf->pBuf.data)->vers = dlbuf->ZXR_Lsn; if (tmpbuf) ind = -1; dlentry_off = 0; DLOG_ADD_OP_CH_MATCHATTR(dlog_ops, 0, ind, dupind, - e->matchAttributes, newmask); + e->matchAttributes, newmask); DLOG_ADD_ENTRY(dlog_entries, dlentry_off, e, 1); /* * Since this is the only operation for this log record, we need not @@ -871,7 +871,7 @@ do_leaf_operation: ; } /* When this is called by in-place-on-the-fly upgrade this does - * not need to be part of a transaction. In this one case this + * not need to be part of a transaction. In this one case this * is a "MESSY DATA" update where it doesn't matter if the data * makes it to disk before a crash. If for some reason the * system crashes and this does not get flushed, that is OK. We @@ -884,7 +884,7 @@ do_leaf_operation: ; if (xaction) { - ZLOG_BIND(xaction, modbuf); + ZLOG_BIND(xaction, modbuf); ZLOG_ReleaseRecord(xaction); } @@ -907,7 +907,7 @@ do_leaf_operation: ; { lhdr.nOps = 1; dlog_size = LEAF_ENTRY_SIZE(e); - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks, DLOG_DATA_SIZE(&lhdr, dlog_size))); DLOG_INIT_LOGICAL_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -916,14 +916,14 @@ do_leaf_operation: ; *DLOG_HDR(dlog_rec) = lhdr; dlog_ops = DLOG_OPS(dlog_rec); dlog_entries = DLOG_ENTRIES(dlog_rec); - - DLOG_SET_BLKINFO(dlog_blkinfo, 0, modbuf, + + DLOG_SET_BLKINFO(dlog_blkinfo, 0, modbuf, ((Node_s *)modbuf->pBuf.data)->vers, xaction); ((Node_s *)modbuf->pBuf.data)->vers = dlbuf->ZXR_Lsn; if (tmpbuf) ind = -1; dlentry_off = 0; DLOG_ADD_OP_CH_HLFLAGS(dlog_ops, 0, ind, dupind, - e->miscFlags, newmask); + e->miscFlags, newmask); DLOG_ADD_ENTRY(dlog_entries, dlentry_off, e, 1); /* * Since this is the only operation for this log record, we need not @@ -932,7 +932,7 @@ do_leaf_operation: ; } /* When this is called by in-place-on-the-fly upgrade this does - * not need to be part of a transaction. In this one case this + * not need to be part of a transaction. In this one case this * is a "MESSY DATA" update where it doesn't matter if the data * makes it to disk before a crash. If for some reason the * system crashes and this does not get flushed, that is OK. We @@ -942,12 +942,12 @@ do_leaf_operation: ; * with flushing out the beast so a transaction is necessary. */ /* Modify only the bits associated with HL FLAGS */ - e->miscFlags = (e->miscFlags & ~HL_FLAG_IS_VALID_MASK) | + e->miscFlags = (e->miscFlags & ~HL_FLAG_IS_VALID_MASK) | (newmask & HL_FLAG_IS_VALID_MASK); if (xaction) { - ZLOG_BIND(xaction, modbuf); + ZLOG_BIND(xaction, modbuf); ZLOG_ReleaseRecord(xaction); } @@ -958,11 +958,11 @@ do_leaf_operation: ; case DIR_OP_DELETE: /* Delete */ *zid = e->zid; // cnt *nameUniquifier = e->nameUniquifier; - if (head->k.namelen & NAMEdup) + if (head->k.namelen & NAMEdup) { if (head->k.namelen & NAMEovflow) { - rc = leaf_ovflow_delete(parms, buf, ind, dupind, firstbuf, + rc = leaf_ovflow_delete(parms, buf, ind, dupind, firstbuf, tmpbuf); /* firstbuf and tmpbuf have been released */ firstbuf = tmpbuf = 0; @@ -987,7 +987,7 @@ do_leaf_operation: ; dlog_size = esize; dlog_nblks = 1; - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks, DLOG_DATA_SIZE(&lhdr, dlog_size))); DLOG_INIT_LOGICAL_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -998,16 +998,16 @@ do_leaf_operation: ; dlog_ops = DLOG_OPS(dlog_rec); dlog_entries = DLOG_ENTRIES(dlog_rec); dlentry_off = 0; - + DLOG_SET_BLKINFO(dlog_blkinfo, 0, buf, node->vers, xaction); node->vers = dlbuf->ZXR_Lsn; ZLOG_BIND(xaction, buf); - + { node_offset_t tmp = e->size; e->size = NWORDS(esize); DLOG_ADD_ENTRY(dlog_entries, dlentry_off, e, 1); - if (e == head) + if (e == head) e->size = tmp; } DLOG_ADD_OP_DELETE_DUP(dlog_ops, 0, ind, dupind, 0); @@ -1022,7 +1022,7 @@ do_leaf_operation: ; zASSERT(rc == zOK); } break; - default: + default: zASSERT(0); } } @@ -1032,7 +1032,7 @@ error_ret: ; UNLATCH_NTREE(ntree); if (parbuf) RELEASE_NTREE_BLK_EXCL(parms, parbuf); - if (buf) + if (buf) RELEASE_NTREE_BLK_EXCL(parms, buf); return rc; } @@ -1051,7 +1051,7 @@ error_ret: ; STATUS dir_pat_lookup( NameTreeParms_s *parms, - Zid_t pzid, + Zid_t pzid, NINT nameType, nsmask_t ns_mask, fname_char_t *pattern, @@ -1065,7 +1065,7 @@ dir_pat_lookup( STATUS rc = zOK; ZfsNameTree_s *ntree = parms->ntree; Blknum_t nextchild, leafhint, ovflow_hint; - SNINT hint_changed = 0; + SNINT hint_changed = 0; Buffer_s *parbuf = 0, *buf = 0; node_ind_t parind, nextind; ZFSNameSearchCtrl_s *kc = SMAP_CURSOR(smap); @@ -1084,13 +1084,13 @@ dir_pat_lookup( *zid = kc->zid; UNLOCK_VALID_SMAP_TAB(); - if (leafhint != INVALID_BLK) + if (leafhint != INVALID_BLK) { #if ZFSNAMETREE_DEBUG NINT old_validate = parms->validate_ntree_nodes; parms->validate_ntree_nodes = 0; #endif - if ((rc = FETCH_NTREE_BLK_SHARED_NO_MAGIC_CHECK(parms, leafhint, &buf, 43)) == zOK) + if ((rc = FETCH_NTREE_BLK_SHARED_NO_MAGIC_CHECK(parms, leafhint, &buf, 43)) == zOK) { Blknum_t hint; LOCK_VALID_SMAP_TAB(); @@ -1099,9 +1099,9 @@ dir_pat_lookup( // cnt *nameUniquifier = kc->nameUniquifier; *zid = kc->zid; UNLOCK_VALID_SMAP_TAB(); - if ((leafhint == hint) && + if ((leafhint == hint) && (((LONG)((Node_s *)buf->pBuf.data)->vers) == kc->vers)) - + { if ((rc = node_verify_magic(parms, buf)) != zOK) { @@ -1118,7 +1118,7 @@ dir_pat_lookup( #endif goto serial_lookup; } - else + else { RELEASE_NTREE_BLK_SHARED(parms, buf); buf = 0; @@ -1131,13 +1131,13 @@ dir_pat_lookup( zASSERT(rc == zOK); found_lastkey = 0; } - if (kc->name == 0) + if (kc->name == 0) { nullstr[0] = 0; key.name = nullstr; key.namelen = 0; } - else + else { key.name = kc->name; found_lastkey = 0; @@ -1157,12 +1157,12 @@ dir_pat_lookup( LATCH_NTREE(ntree); nextchild = NTREE_GET_ROOT_BLK(ntree); parbuf = 0; - for (;;) + for (;;) { Node_s *node; buf = 0; - if (nextchild == INVALID_BLK) + if (nextchild == INVALID_BLK) { rc = zERR_NAME_NOT_FOUND_IN_DIRECTORY; goto error_ret; @@ -1170,8 +1170,8 @@ dir_pat_lookup( else if ((rc = FETCH_NTREE_BLK_EXCL(parms, nextchild, &buf, 44)) !=zOK) { goto error_ret; - } - else + } + else { currentLevel++; } @@ -1186,7 +1186,7 @@ dir_pat_lookup( nextind = NODE_NEXT(node, nextind); found_lastkey = 1; } - if (parbuf) + if (parbuf) { RELEASE_NTREE_BLK_EXCL(parms, parbuf); parbuf = 0; @@ -1200,12 +1200,12 @@ dir_pat_lookup( zASSERT(IS_BRANCH(node)); /* Perform overflow/underflow handling only if NameTree is writable */ - if (! NTREE_IS_READONLY(parms)) + if (! NTREE_IS_READONLY(parms)) { - if (NODE_OVFLOW(node)) + if (NODE_OVFLOW(node)) { - if ((rc = BRANCH_OVFLOW(parms, &buf, &parbuf, - &parind, (dir_key_s *)&key, &curmatch)) != zOK) + if ((rc = BRANCH_OVFLOW(parms, &buf, &parbuf, + &parind, (dir_key_s *)&key, &curmatch)) != zOK) goto error_ret; } else if (parbuf && (node->nfreebytes > NODE_UNDERFLOW)) @@ -1219,10 +1219,10 @@ dir_pat_lookup( if ((currentLevel+1) == ntree->zfsBtree.levelsInTree) { - BTREE_ReadAheadMetadata(&ntree->zfsBtree.ZFSBTREEroot, + BTREE_ReadAheadMetadata(&ntree->zfsBtree.ZFSBTREEroot, node, ind, NT_getBlockList, nextchild); } - if (NTREE_IS_READONLY(parms) && NODE_OVFLOW(node)) + if (NTREE_IS_READONLY(parms) && NODE_OVFLOW(node)) { /* * Branch node has overflowed. But can't clear the overflow @@ -1231,10 +1231,10 @@ dir_pat_lookup( */ Buffer_s *ovflow_buf; Node_s *ovflow_node; - + prevmatch = curmatch = 0; - if ((rc = FETCH_NTREE_BLK_SHARED(parms, node->u.ovflow_blk, - &ovflow_buf, 52)) != zOK) + if ((rc = FETCH_NTREE_BLK_SHARED(parms, node->u.ovflow_blk, + &ovflow_buf, 52)) != zOK) { goto error_ret; } @@ -1245,9 +1245,9 @@ dir_pat_lookup( parind = ind; } - if (parbuf) + if (parbuf) { - if (ntree_latched && (parbuf->BUFblknum == NTREE_GET_ROOT_BLK(ntree))) + if (ntree_latched && (parbuf->BUFblknum == NTREE_GET_ROOT_BLK(ntree))) { UNLATCH_NTREE(ntree); ntree_latched = 0; @@ -1260,7 +1260,7 @@ dir_pat_lookup( error_ret: ; if (ntree_latched) UNLATCH_NTREE(ntree); - if (rc != zOK) + if (rc != zOK) { leafhint = ovflow_hint = INVALID_BLK; hint_changed = 1; @@ -1276,7 +1276,7 @@ error_ret: ; serial_lookup: ; zASSERT(parbuf == 0); - for (;;) + for (;;) { /* * Search sequentially thru the linked list of leaf nodes (including @@ -1288,25 +1288,25 @@ serial_lookup: ; Leaf_s *e; node = (Node_s *)buf->pBuf.data; - while (nextind <= NODE_LAST(node)) + while (nextind <= NODE_LAST(node)) { e = LEAF_ENTRY(node, nextind); - if (! found_lastkey) + if (! found_lastkey) { - if ((found_lastkey = leaf_keycomp((dir_key_s *)&key, + if ((found_lastkey = leaf_keycomp((dir_key_s *)&key, *zid, /* cnt *nameUniquifier,*/ ns_mask, e, 0, ncmpfn))) kc->dupind = ret_prevmatch ? 0 : 1; } - else if (! ((e->k.pzid == pzid) && (e->k.nameType == nameType))) + else if (! ((e->k.pzid == pzid) && (e->k.nameType == nameType))) { zASSERT((e->k.pzid > pzid) || (e->k.nameType > nameType)); rc = zERR_NAME_NOT_FOUND_IN_DIRECTORY; goto error_ret; } - if (found_lastkey && (kc->dupind==0) - && PATCMP(smap, ns_mask, pattern, e, patcmpfn)) + if (found_lastkey && (kc->dupind==0) + && PATCMP(smap, ns_mask, pattern, e, patcmpfn)) { - if ((rc = namecopy(smap, dirinfo, e)) == zOK) + if ((rc = namecopy(smap, dirinfo, e)) == zOK) { kc->vers = node->vers; kc->ind = nextind; @@ -1315,21 +1315,21 @@ serial_lookup: ; } goto error_ret; } - if (e->k.namelen & NAMEdup) + if (e->k.namelen & NAMEdup) { SNINT esize = ENTRYSIZE_FROM_KEY(&e->k, LEAF_DATASIZE); Dupinfo_s *di = (Dupinfo_s *)((char *)e + esize); node_ind_t starti = kc->dupind ? kc->dupind-1 : 0; - if (e->k.namelen & NAMEovflow) + if (e->k.namelen & NAMEovflow) { Leaf_s *e1; - if (ovflow_hint == INVALID_BLK) + if (ovflow_hint == INVALID_BLK) { ovflow_hint = di->ovflow_blk; hint_changed = 1; } - while (ovflow_hint != INVALID_BLK) + while (ovflow_hint != INVALID_BLK) { Node_s *tmpnode; Buffer_s *tmpbuf; @@ -1337,37 +1337,37 @@ serial_lookup: ; &tmpbuf, 45)) != zOK) goto error_ret; tmpnode = (Node_s *) tmpbuf->pBuf.data; e1 = (Leaf_s *)tmpnode->padbytes; - if (! found_lastkey) + if (! found_lastkey) { - for (starti=0; starti numRecs; ++starti) + for (starti=0; starti numRecs; ++starti) { found_lastkey = leaf_keycomp((dir_key_s *)&key, *zid, /* cnt *nameUniquifier,*/ ns_mask, e1, FALSE, ncmpfn); if (found_lastkey) { - if (! ret_prevmatch) + if (! ret_prevmatch) ++ starti; break; } e1= (Leaf_s *)((BYTE *)e1 + esize); } } - if (found_lastkey) + if (found_lastkey) { - if (starti < tmpnode->numRecs) + if (starti < tmpnode->numRecs) { - e1 = (Leaf_s *)(tmpnode->padbytes + + e1 = (Leaf_s *)(tmpnode->padbytes + starti * esize); - for (; starti < tmpnode->numRecs; ++ starti) + for (; starti < tmpnode->numRecs; ++ starti) { - if ((found = PATCMP(smap, ns_mask, pattern, + if ((found = PATCMP(smap, ns_mask, pattern, e1, patcmpfn)) != 0) { kc->ind = nextind; kc->dupind = starti+1; if ((rc = namecopy(smap, dirinfo, e1)) - == zOK) + == zOK) { kc->vers = node->vers; *zid = e1->zid; @@ -1389,34 +1389,34 @@ serial_lookup: ; else { /* All duplicate keys fit in the same leaf node */ SNINT ndups = di->nduplicates; ovflow_hint = INVALID_BLK; - if (! found_lastkey) + if (! found_lastkey) { e = (Leaf_s *)((char *)di + sizeof(Dupinfo_s)); - for (starti=0; starti < ndups; ++ starti) + for (starti=0; starti < ndups; ++ starti) { - found_lastkey = leaf_keycomp((dir_key_s *)&key, + found_lastkey = leaf_keycomp((dir_key_s *)&key, *zid, /* cnt *nameUniquifier,*/ ns_mask, e, 0, ncmpfn); if (found_lastkey) { - if (! ret_prevmatch) + if (! ret_prevmatch) ++ starti; break; } e = (Leaf_s *)((char *)e + esize); } } - if (found_lastkey) + if (found_lastkey) { - e = (Leaf_s *)((char *)di + sizeof(Dupinfo_s) + + e = (Leaf_s *)((char *)di + sizeof(Dupinfo_s) + starti * esize); - for (; starti < ndups; ++ starti) + for (; starti < ndups; ++ starti) { - if ((found = PATCMP(smap, ns_mask, pattern, + if ((found = PATCMP(smap, ns_mask, pattern, e, patcmpfn)) != 0) { kc->ind = nextind; kc->dupind = starti+1; - if ((rc = namecopy(smap, dirinfo, e))==zOK) + if ((rc = namecopy(smap, dirinfo, e))==zOK) { kc->vers = node->vers; *zid = e->zid; @@ -1445,12 +1445,12 @@ serial_lookup: ; leafhint = node->u.nextleaf; { Buffer_s *nextbuf; - if (leafhint == INVALID_BLK) + if (leafhint == INVALID_BLK) { rc = zERR_NAME_NOT_FOUND_IN_DIRECTORY; goto error_ret; } - if ((rc = FETCH_NTREE_BLK_SHARED(parms, leafhint, &nextbuf, 46)) + if ((rc = FETCH_NTREE_BLK_SHARED(parms, leafhint, &nextbuf, 46)) != zOK) goto error_ret; RELEASE_NTREE_BLK_SHARED(parms, buf); @@ -1493,31 +1493,31 @@ PRINT_LENTRY(NameTreeParms_s *parms, Leaf_s *e, SNINT idx) SNINT esize; Dupinfo_s *di; PRINT_SINGLE_LENTRY(e); - if (! (e->k.namelen & NAMEdup)) + if (! (e->k.namelen & NAMEdup)) return; esize = ENTRYSIZE_FROM_KEY(&e->k, LEAF_DATASIZE); di = (Dupinfo_s *)((char *)e + esize); idx += INDENT_STEP; - if (e->k.namelen & NAMEovflow) + if (e->k.namelen & NAMEovflow) { Blknum_t ovflow_blk = di->ovflow_blk; - while (ovflow_blk != INVALID_BLK) + while (ovflow_blk != INVALID_BLK) { Buffer_s *buf; Node_s *node; SNINT i; if (! parms) return; - if (FETCH_NTREE_BLK_DEBUG(parms, ovflow_blk, &buf, 48) != zOK) + if (FETCH_NTREE_BLK_DEBUG(parms, ovflow_blk, &buf, 48) != zOK) return; node = (Node_s *) buf->pBuf.data; do_indent(idx); - DB_PRINTF((CYAN, + DB_PRINTF((CYAN, MSGNot("[ Leaf ovflow blk# %d: %d recs, %d freebytes, next blk# %d\n"), buf->BUFblknum, node->numRecs, node->nfreebytes, node->u.nextleaf)); e = (Leaf_s *)node->padbytes; idx += INDENT_STEP; - for (i=0; i < node->numRecs; ++ i) + for (i=0; i < node->numRecs; ++ i) { do_indent(idx); PRINT_SINGLE_LENTRY(e); @@ -1528,12 +1528,12 @@ PRINT_LENTRY(NameTreeParms_s *parms, Leaf_s *e, SNINT idx) RELEASE_NTREE_BLK_DEBUG(parms, buf); } } - else + else { SNINT i, ndups = di->nduplicates; DB_PRINTF((CYAN, MSGNot("%d duplicates:\n"), ndups)); e = (Leaf_s *)((char *)di + sizeof(Dupinfo_s)); - for (i=0; i < ndups; ++ i) + for (i=0; i < ndups; ++ i) { do_indent(idx); PRINT_SINGLE_LENTRY(e); @@ -1560,21 +1560,21 @@ dir_dumpnode(NameTreeParms_s *parms, Buffer_s *buf) Leaf_s *e; iam_overflow = IS_LEAF_OVFLOW(node); - DB_PRINTF((CYAN, + DB_PRINTF((CYAN, MSGNot("Leaf %s blk# %d: %d recs, %d freebytes, next leaf blk# %d\n"), iam_overflow ? "overflow" : "", buf->BUFblknum, node->numRecs, node->nfreebytes, node->u.nextleaf)); if (iam_overflow) { e = (Leaf_s *)node->padbytes; - for (i=0; i < node->numRecs; ++ i) + for (i=0; i < node->numRecs; ++ i) { PRINT_SINGLE_LENTRY(e); e = (Leaf_s *)((char *)e + LEAF_ENTRY_SIZE(e)); } } else - for (i = 0; i < node->numRecs; ++i) + for (i = 0; i < node->numRecs; ++i) { e = LEAF_ENTRY(node, i); DB_PRINTF((CYAN, MSGNot("%d: size %d, "), i, LEAF_ENTRY_SIZE(e))); @@ -1589,12 +1589,12 @@ dir_dumpnode(NameTreeParms_s *parms, Buffer_s *buf) buf->BUFblknum, node->numRecs, node->nfreebytes, node->child_blk)); - if (NODE_OVFLOW(node)) + if (NODE_OVFLOW(node)) { DB_PRINTF((CYAN, MSGNot("ovflow blk# %d\n"), node->u.ovflow_blk)); } - for (i = 0; i < node->numRecs; ++i) + for (i = 0; i < node->numRecs; ++i) { Branch_s *e = BRANCH_ENTRY(node, i); DB_PRINTF((CYAN, MSGNot("%d: size %d, "), i, BRANCH_ENTRY_SIZE(e))); @@ -1608,7 +1608,7 @@ dir_dumpnode(NameTreeParms_s *parms, Buffer_s *buf) */ STATUS dir_dump( - NameTreeParms_s *parms, + NameTreeParms_s *parms, Blknum_t nextchild, SNINT idx) /* Indent index */ { @@ -1632,7 +1632,7 @@ dir_dump( buf->BUFblknum, node->numRecs, node->nfreebytes, node->u.nextleaf)); idx += INDENT_STEP; - for (i = 0; i < node->numRecs; ++i) + for (i = 0; i < node->numRecs; ++i) { Leaf_s *e = LEAF_ENTRY(node, i); @@ -1651,7 +1651,7 @@ dir_dump( DB_PRINTF((CYAN, MSGNot("( Branch blk# %d: %d recs, %d freebytes, lchild# %d"), buf->BUFblknum, node->numRecs, node->nfreebytes, node->child_blk)); - if (NODE_OVFLOW(node)) + if (NODE_OVFLOW(node)) { DB_PRINTF((CYAN, MSGNot(", ovflow blk# %d"), node->u.ovflow_blk)); } @@ -1660,18 +1660,18 @@ dir_dump( idx += INDENT_STEP; if (! iam_overflow) dir_dump(parms, node->child_blk, idx); - for (i = 0; i < node->numRecs; ++i) + for (i = 0; i < node->numRecs; ++i) { Branch_s *e = BRANCH_ENTRY(node, i); do_indent(idx); DB_PRINTF((CYAN, MSGNot("%d: size %d, "), i, BRANCH_ENTRY_SIZE(e))); - if (iam_overflow) + if (iam_overflow) { node_ind_t j; SNINT e_repl; OVFLOW_ENTRY(node, i, &j, &e_repl, &e); - if (e_repl) + if (e_repl) { DB_PRINTF((CYAN, MSGNot("Replace #%d with: "), j)); } @@ -1682,7 +1682,7 @@ dir_dump( dir_dump(parms, e->child_blk, idx); } idx -= INDENT_STEP; - if (NODE_OVFLOW(node)) + if (NODE_OVFLOW(node)) { do_indent(idx); DB_PRINTF((CYAN, MSGNot("ovflow "))); @@ -1702,25 +1702,25 @@ dir_dump( */ STATUS dir_ls( - NameTreeParms_s *parms, + NameTreeParms_s *parms, Blknum_t nextchild) { Buffer_s *buf; Node_s *node; WORD i; - while (nextchild != INVALID_BLK) + while (nextchild != INVALID_BLK) { if (FETCH_NTREE_BLK_DEBUG(parms, nextchild, &buf, 49) != zOK) return zOUT_OF_BUFFERS; node = (Node_s *)buf->pBuf.data; - if (IS_BRANCH(node)) + if (IS_BRANCH(node)) { nextchild = node->child_blk; goto next_node; } - for (i = 0; i < node->numRecs; ++i) + for (i = 0; i < node->numRecs; ++i) { Leaf_s *e = LEAF_ENTRY(node, i); PRINT_LENTRY(parms, e, 0); diff --git a/src/nwnss/zlss/dlog.c b/src/nwnss/zlss/dlog.c index ffab52a..e20842d 100644 --- a/src/nwnss/zlss/dlog.c +++ b/src/nwnss/zlss/dlog.c @@ -55,8 +55,8 @@ STATUS dlog_recovery_common( NameTreeParms_s parms; parms.genMsg = gm; parms.ntree = ntree; - - for (i = 0; i < DLOG_NBLKS(dlbuf); ++ i) + + for (i = 0; i < DLOG_NBLKS(dlbuf); ++ i) { Buffer_s *buf; Node_s *node; @@ -71,7 +71,7 @@ STATUS dlog_recovery_common( parms.validate_ntree_nodes = 0; #endif if ((rc = FETCH_NTREE_BLK_EXCL_NO_MAGIC_CHECK(&parms, blkinfo[i].blkNum, - &buf, 0)) != zOK) + &buf, 0)) != zOK) return rc; node = (Node_s *)buf->pBuf.data; @@ -97,7 +97,7 @@ STATUS dlog_recovery_common( INIT_LEAF_NODE(node, isovflow, volumeInternalID); else INIT_BRANCH_NODE(node, isovflow, volumeInternalID); } - else if (ZLOG_ALREADY_DONE(pool, dlbuf, node->vers, action)) + else if (ZLOG_ALREADY_DONE(pool, dlbuf, node->vers, action)) { RELEASE_NTREE_BLK(&parms, buf); continue; @@ -112,12 +112,12 @@ STATUS dlog_recovery_common( PRE_VALIDATE_NTREE_NODE(&parms, node); #endif - if (undo) + if (undo) { endi = 0, jincr = -1; zASSERT(blk_alloc || (node->vers == dlbuf->ZXR_Lsn)); } - else + else { endi = (dlhdr->nOps-1), jincr = 1; zASSERT(blk_alloc || (node->vers == blkinfo[i].previousLsn)); @@ -128,12 +128,12 @@ STATUS dlog_recovery_common( dlog_entries = DLOG_ENTRIES(dlog_rec); dlog_op = &DLOG_OPS(dlog_rec)[j]; modified = 0; - for (; j != endi; j += jincr) + for (; j != endi; j += jincr) { dlog_op_t op = dlog_op->op; - switch (DLOG_BASE_OP(op)) + switch (DLOG_BASE_OP(op)) { - case DLOG_OP_MOVE: + case DLOG_OP_MOVE: { dlog_move_s *mv_op = &dlog_op->move; BYTE *mv_entries = dlog_entries + mv_op->log; @@ -142,13 +142,13 @@ STATUS dlog_recovery_common( if (! (issrc || isdst)) break; /* node has to be either a src or a dst */ - if (! (op & DLOG_OP_DUP)) + if (! (op & DLOG_OP_DUP)) { - if (undo == issrc) + if (undo == issrc) { /* Data to be moved in to node */ node_ind_t ind = undo ? mv_op->srci-1 : mv_op->dsti; - node_blk_copy(node, ind, mv_op->nrecs, + node_blk_copy(node, ind, mv_op->nrecs, (node_offset_t *)mv_entries, 0, 0); } else { @@ -157,15 +157,15 @@ STATUS dlog_recovery_common( node_ndelete(node, ind, mv_op->nrecs); } } - else + else { SNINT esize = LEAF_ENTRY_SIZE(mv_entries); NINT mvsize = esize * mv_op->nrecs; - if (issrc) + if (issrc) { Leaf_s *e = LEAF_ENTRY(node, mv_op->srci); Dupinfo_s *di = (Dupinfo_s *)((BYTE *)e + esize); - if (undo) + if (undo) { node_expand_entry(node, mv_op->srci, (dir_key_s *)0, mv_entries, mvsize); @@ -173,9 +173,9 @@ STATUS dlog_recovery_common( e->k.namelen &= ~NAMEovflow; di->nduplicates = mv_op->nrecs; } - else + else { - node_shrink_entry(node, (node_offset_t *)e, + node_shrink_entry(node, (node_offset_t *)e, esize+sizeof(Dupinfo_s)); e = LEAF_ENTRY(node, mv_op->srci); e->k.namelen |= NAMEovflow; @@ -183,15 +183,15 @@ STATUS dlog_recovery_common( } } - else + else { SNINT incr = 1; - if (undo) + if (undo) { incr = -1; mvsize = - mvsize; } - else memmove(&node->padbytes[node->nextfree], + else memmove(&node->padbytes[node->nextfree], mv_entries, mvsize); node->numRecs += incr * mv_op->nrecs; node->nextfree += mvsize; @@ -201,7 +201,7 @@ STATUS dlog_recovery_common( modified = 1; break; } - case DLOG_OP_REPL: + case DLOG_OP_REPL: { dlog_repl_s *repl_op = &dlog_op->repl; SNINT do_repl, do_ins; @@ -214,7 +214,7 @@ STATUS dlog_recovery_common( zASSERT(! (do_ins && (op & DLOG_OP_DELETE))); ind = repl_op->i; dupi = repl_op->dupi; - if (op & DLOG_OP_DUP) + if (op & DLOG_OP_DUP) { SNINT isovflow = IS_LEAF_OVFLOW(node); BYTE *e, *last; @@ -223,13 +223,13 @@ STATUS dlog_recovery_common( SNINT esize = LEAF_ENTRY_SIZE(dlog_entries + ((do_repl || do_ins) ? repl_op->newlog : repl_op->oldlog)); modified = 1; - if (isovflow) + if (isovflow) { head = 0; e = node->padbytes + esize * dupi; last = node->padbytes + esize * NODE_LAST(node); } - else + else { head = LEAF_ENTRY(node, ind); di = (Dupinfo_s *)((BYTE *)head + esize); @@ -239,64 +239,64 @@ STATUS dlog_recovery_common( e = (dupi < 0) ? (BYTE *)head : (e + esize * dupi); } - if (do_repl) + if (do_repl) { - BYTE *repl_e = dlog_entries + + BYTE *repl_e = dlog_entries + (undo ? repl_op->oldlog : repl_op->newlog); SNINT esize = LEAF_ENTRY_SIZE(repl_e); SNINT savesize = 0; if (head) savesize = head->size; memmove(e, repl_e, esize); - if (e == (BYTE *)head) + if (e == (BYTE *)head) { head->size = savesize; head->k.namelen |= (NAMEdup | NAMEovflow); } } else { /* Insert/Delete */ - BYTE *loge = dlog_entries + + BYTE *loge = dlog_entries + (do_ins ? repl_op->newlog : repl_op->oldlog); - if (undo == do_ins) + if (undo == do_ins) { /* undo an insert, or redo a delete */ - if ((! do_ins) && (e != last)) + if ((! do_ins) && (e != last)) { SNINT dupflags = 0; SNINT savesize = 0; - if (head) + if (head) { savesize = head->size; - dupflags = head->k.namelen & + dupflags = head->k.namelen & (NAMEdup | NAMEovflow); } memmove(e, last, esize); - if (e == (BYTE *)head) + if (e == (BYTE *)head) { head->size = savesize; head->k.namelen |= dupflags; } } - if (isovflow) + if (isovflow) { -- node->numRecs; node->nfreebytes += esize; node->nextfree -= esize; } - else + else { - if (-- di->nduplicates <= 0) + if (-- di->nduplicates <= 0) { head->k.namelen &= ~NAMEdup; - node_shrink_entry(node, + node_shrink_entry(node, (node_offset_t *)head, esize); } - else node_shrink_entry(node, - (node_offset_t *)head, + else node_shrink_entry(node, + (node_offset_t *)head, LEAF_ENTRY_SIZE(head) - esize); } } else { /* undo a delete, or redo an insert */ - if (isovflow) + if (isovflow) { /* Both e and last must be in ovflow node */ last += esize; @@ -319,21 +319,21 @@ STATUS dlog_recovery_common( ld.miscFlags = l->miscFlags; node_expand_entry(node, repl_op->i, &l->k, (BYTE *)&ld, LEAF_DATASIZE); - if (undo && (e != last)) + if (undo && (e != last)) { SNINT dupflags, savesize; Leaf_s *head = LEAF_ENTRY(node, ind); di = (Dupinfo_s *)((BYTE *)head + esize); e = (BYTE *)di + sizeof(*di); last = e + esize * (di->nduplicates-1); - e = (dupi < 0) ? (BYTE *)head + e = (dupi < 0) ? (BYTE *)head : (e + esize * dupi); memmove(last, e, esize); dupflags = head->k.namelen & (NAMEdup|NAMEovflow); savesize = head->size; memmove(e, loge, esize); - if (e == (BYTE *)head) + if (e == (BYTE *)head) { head->size = savesize; head->k.namelen |= dupflags; @@ -343,16 +343,16 @@ STATUS dlog_recovery_common( } } } - else if (do_repl || (undo == (! do_ins))) + else if (do_repl || (undo == (! do_ins))) { - node_offset_t *e = (node_offset_t *)(dlog_entries + + node_offset_t *e = (node_offset_t *)(dlog_entries + (undo ? repl_op->oldlog : repl_op->newlog)); if (! do_ins) -- ind; - node_blk_copy(node, ind, 1, e, do_repl, + node_blk_copy(node, ind, 1, e, do_repl, (op & DLOG_OP_OVFLOW)); modified = 1; } - else if (! (op & DLOG_OP_OVFLOW)) + else if (! (op & DLOG_OP_OVFLOW)) { /* Undo an insert, or redo a delete */ if (do_ins) ++ ind; @@ -361,49 +361,49 @@ STATUS dlog_recovery_common( } break; } - case DLOG_OP_REPLKEY: + case DLOG_OP_REPLKEY: { dlog_replkey_s *replk_op = &dlog_op->replkey; - if (replk_op->blki == i) + if (replk_op->blki == i) { SNINT do_repl = ((op & (DLOG_OP_INSERT|DLOG_OP_DELETE)) == 0); - SNINT do_ins = ((op & DLOG_OP_INSERT) != 0); + SNINT do_ins = ((op & DLOG_OP_INSERT) != 0); /* 1=INSERT, 0=DELETE */ node_ind_t ind = replk_op->i; - if (do_repl || (undo == (! do_ins))) + if (do_repl || (undo == (! do_ins))) { /* redo an insert, undo a delete, redo/undo a replace */ Blknum_t blk; - BYTE *e = (dlog_entries + + BYTE *e = (dlog_entries + (undo ? replk_op->oldlog : replk_op->newlog)); Branch_s *olde = NULL; - dir_key_s *k = (ISFREE(e)) ? &((Leaf_s *)e)->k + dir_key_s *k = (ISFREE(e)) ? &((Leaf_s *)e)->k : &((Branch_s *)e)->k; - if (do_repl) + if (do_repl) { olde = BRANCH_ENTRY(node, ind); blk = undo ? olde->child_blk : replk_op->blk; } - else + else { blk = replk_op->blk; if (! do_ins) -- ind; } node_insert_common(node, ind, k, (BYTE *)&blk, - sizeof(blk) + + sizeof(blk) + ((op & DLOG_OP_OVFLOW) ? OVFLOW_OP_DATA_SZ : 0), do_repl); - if (op & DLOG_OP_OVFLOW) + if (op & DLOG_OP_OVFLOW) { node_ind_t insi; SNINT e_repl; - if (do_repl && undo) + if (do_repl && undo) { Ovflow_op_data_t *op_data =OVFLOW_OP_DATA(olde); insi = op_data->ind; e_repl = op_data->replace; } - else + else { insi = replk_op->ovflow_data; if ((e_repl = (insi < -1)) != 0) @@ -421,24 +421,24 @@ STATUS dlog_recovery_common( } break; } - case DLOG_OP_EXPAND: + case DLOG_OP_EXPAND: { dlog_expand_s *expand_op = &dlog_op->expand; - if (expand_op->blki == i) + if (expand_op->blki == i) { node_ind_t ind = expand_op->i; Leaf_s *e = LEAF_ENTRY(node, ind); - if (undo) + if (undo) { SNINT esize = ENTRYSIZE_FROM_KEY(&e->k, LEAF_DATASIZE); Dupinfo_s *di = (Dupinfo_s *)((BYTE *)e + esize); - node_delete_dup(node, e, di->nduplicates-1); + node_delete_dup(node, e, di->nduplicates-1); } - else + else { Leaf_s *l = (Leaf_s *)(dlog_entries + expand_op->log); SNINT esize = expand_op->size; - if (esize >= 0) + if (esize >= 0) { Ldata_s d; d.zid = l->zid; @@ -446,31 +446,31 @@ STATUS dlog_recovery_common( // cnt d.nameUniquifier = l->nameUniquifier; d.matchAttributes = l->matchAttributes; d.miscFlags = l->miscFlags; - node_expand_entry(node, ind, &l->k, (BYTE *)&d, + node_expand_entry(node, ind, &l->k, (BYTE *)&d, LEAF_DATASIZE); } - else node_expand_entry(node, ind, (dir_key_s *)0, + else node_expand_entry(node, ind, (dir_key_s *)0, (BYTE *)l, - esize); } - modified = 1; + modified = 1; } break; } - case DLOG_OP_CH_MASK: + case DLOG_OP_CH_MASK: { dlog_chmask_s *ch_mask = &dlog_op->chmask; - if (ch_mask->blki == i) + if (ch_mask->blki == i) { Leaf_s *e; SNINT esize; - if (ch_mask->i >= 0) + if (ch_mask->i >= 0) { e = LEAF_ENTRY(node, ch_mask->i); esize = ENTRYSIZE_FROM_KEY(&e->k, LEAF_DATASIZE); if (ch_mask->dupi >= 0) e = (Leaf_s *)((BYTE *)e + esize + sizeof(Dupinfo_s)); } - else + else { e = (Leaf_s *)node->padbytes; esize = ENTRYSIZE_FROM_KEY(&e->k, LEAF_DATASIZE); @@ -482,21 +482,21 @@ STATUS dlog_recovery_common( } break; } - case DLOG_OP_CH_MATCHATTR: + case DLOG_OP_CH_MATCHATTR: { dlog_chmatchAttr_s *ch_matchAttr = &dlog_op->chmatchAttr; - if (ch_matchAttr->blki == i) + if (ch_matchAttr->blki == i) { Leaf_s *e; SNINT esize; - if (ch_matchAttr->i >= 0) + if (ch_matchAttr->i >= 0) { e = LEAF_ENTRY(node, ch_matchAttr->i); esize = ENTRYSIZE_FROM_KEY(&e->k, LEAF_DATASIZE); if (ch_matchAttr->dupi >= 0) e = (Leaf_s *)((BYTE *)e + esize + sizeof(Dupinfo_s)); } - else + else { e = (Leaf_s *)node->padbytes; esize = ENTRYSIZE_FROM_KEY(&e->k, LEAF_DATASIZE); @@ -504,26 +504,26 @@ STATUS dlog_recovery_common( if (ch_matchAttr->dupi >= 0) e = (Leaf_s *)((BYTE *)e + ch_matchAttr->dupi * esize); e->matchAttributes = undo ? - ch_matchAttr->oldmatchAttr : ch_matchAttr->newmatchAttr; + ch_matchAttr->oldmatchAttr : ch_matchAttr->newmatchAttr; modified = 1; } break; } - case DLOG_OP_CH_HLFLAGS: + case DLOG_OP_CH_HLFLAGS: { dlog_chHlFlags_s *ch_hlFlags = &dlog_op->chHlFlags; - if (ch_hlFlags->blki == i) + if (ch_hlFlags->blki == i) { Leaf_s *e; SNINT esize; - if (ch_hlFlags->i >= 0) + if (ch_hlFlags->i >= 0) { e = LEAF_ENTRY(node, ch_hlFlags->i); esize = ENTRYSIZE_FROM_KEY(&e->k, LEAF_DATASIZE); if (ch_hlFlags->dupi >= 0) e = (Leaf_s *)((BYTE *)e + esize + sizeof(Dupinfo_s)); } - else + else { e = (Leaf_s *)node->padbytes; esize = ENTRYSIZE_FROM_KEY(&e->k, LEAF_DATASIZE); @@ -535,14 +535,14 @@ STATUS dlog_recovery_common( e->miscFlags &= ~HL_FLAG_IS_VALID_MASK; /* Now, or in the new HL FLAGS */ - e->miscFlags |= HL_FLAG_IS_VALID_MASK & - (undo ? ch_hlFlags->oldHlFlags : ch_hlFlags->newHlFlags); + e->miscFlags |= HL_FLAG_IS_VALID_MASK & + (undo ? ch_hlFlags->oldHlFlags : ch_hlFlags->newHlFlags); modified = 1; } break; } - case DLOG_OP_CH_ROOT: + case DLOG_OP_CH_ROOT: { dlog_chroot_s *ch_root = &dlog_op->chroot; SNINT isnew = (ch_root->newblki == i); @@ -559,10 +559,10 @@ STATUS dlog_recovery_common( modified = 1; break; } - case DLOG_OP_CH_LCHILD: + case DLOG_OP_CH_LCHILD: { dlog_ch_lchild_s *ch_lchild = &dlog_op->ch_lchild; - if (ch_lchild->blki == i) + if (ch_lchild->blki == i) { node->child_blk = undo ? ch_lchild->oldblk : ch_lchild->newblk; @@ -570,48 +570,48 @@ STATUS dlog_recovery_common( } break; } - case DLOG_OP_SET_OVFLOW: + case DLOG_OP_SET_OVFLOW: { dlog_set_ovflow_s *set_ovflow = &dlog_op->set_ovflow; - if (set_ovflow->blki == i) + if (set_ovflow->blki == i) { SNINT reset = ((op & DLOG_OP_RESET_OVFLOW) != 0); - node->u.ovflow_blk = + node->u.ovflow_blk = (undo == reset) ? set_ovflow->ovflow_blk : INVALID_BLK; modified = 1; } break; } - case DLOG_OP_LEAFLIST: + case DLOG_OP_LEAFLIST: { dlog_leaflist_s *leaflist = &dlog_op->leaflist; SNINT do_ins = ((op & DLOG_OP_INSERT) != 0); SNINT isovflow = ((op & DLOG_OP_OVFLOW) != 0); - if (i == leaflist->curblki) + if (i == leaflist->curblki) { - node->u.nextleaf = (undo == do_ins) + node->u.nextleaf = (undo == do_ins) ? INVALID_BLK : leaflist->nextblk; modified = 1; } - else if (i == leaflist->prevblki) + else if (i == leaflist->prevblki) { - Blknum_t blk = (undo == do_ins) + Blknum_t blk = (undo == do_ins) ? leaflist->nextblk : blkinfo[leaflist->curblki].blkNum; - if (isovflow) + if (isovflow) { Leaf_s *e = LEAF_ENTRY(node, leaflist->ind); SNINT esize = ENTRYSIZE_FROM_KEY(&e->k, LEAF_DATASIZE); Dupinfo_s *di = (Dupinfo_s *)((BYTE *)e + esize); - if (leaflist->nextblk == INVALID_BLK) + if (leaflist->nextblk == INVALID_BLK) { - if (undo == do_ins) + if (undo == do_ins) { e->k.namelen &= ~(NAMEdup|NAMEovflow); node_shrink_entry(node, (node_offset_t *)e, esize); } - else + else { Dupinfo_s dinfo; dinfo.ovflow_blk = blk; @@ -638,7 +638,7 @@ STATUS dlog_recovery_common( } dlog_op += jincr; } - if (modified) + if (modified) { ZLOG_SET_LSN(dlbuf, node->vers, blkinfo[i], action); SET_NTREE_BLK_DIRTY(buf); @@ -709,13 +709,13 @@ STATUS dlog_logical_recovery_common( parms.validate_ntree_nodes = 1; #endif rc = zOK; - switch (DLOG_BASE_OP(op)) + switch (DLOG_BASE_OP(op)) { case DLOG_OP_REPL: /* Insert and Delete operations come thru this */ { dlog_repl_s *repl_op = &dlog_op->repl; SNINT do_repl, do_ins; - Leaf_s *e = (Leaf_s *)(dlog_entries + + Leaf_s *e = (Leaf_s *)(dlog_entries + (undo ? repl_op->oldlog : repl_op->newlog)); Zid_t zid; @@ -732,15 +732,15 @@ STATUS dlog_logical_recovery_common( do_ins = ((op & DLOG_OP_INSERT) != 0); /* 1=INSERT, 0=DELETE */ zASSERT(! (do_ins && (op & DLOG_OP_DELETE))); - zASSERT(! (op & DLOG_OP_OVFLOW)); + zASSERT(! (op & DLOG_OP_OVFLOW)); if (undo == (! do_ins)) { /* Undo a delete, redo an insert */ // cnt nameUniquifier = e->nameUniquifier; - rc = DIR_INSERT(&parms, &e->k, e->ns_mask, e->zid, + rc = DIR_INSERT(&parms, &e->k, e->ns_mask, e->zid, /* cnt nameUniquifier,*/ e->matchAttributes); } - else + else { /* Undo an insert, or redo a delete */ // cnt nameUniquifier = e->nameUniquifier; @@ -754,7 +754,7 @@ STATUS dlog_logical_recovery_common( } break; } - case DLOG_OP_EXPAND: + case DLOG_OP_EXPAND: { /* At the logical level, expand is treated like insert */ dlog_expand_s *expand_op = &dlog_op->expand; @@ -763,7 +763,7 @@ STATUS dlog_logical_recovery_common( /* If logged entry is a leaf entry, the FREE_ENTRY_MASK will be set */ zASSERT(ISFREE(e)); - if (undo) + if (undo) { // cnt nameUniquifier = e->nameUniquifier; zid = e->zid; @@ -774,12 +774,12 @@ STATUS dlog_logical_recovery_common( rc = zFAILURE; } } - else + else { if (expand_op->size > 0) { // cnt nameUniquifier = e->nameUniquifier; - rc = DIR_INSERT(&parms, &e->k, e->ns_mask, e->zid, + rc = DIR_INSERT(&parms, &e->k, e->ns_mask, e->zid, /* cnt nameUniquifier,*/ e->matchAttributes); if (rc != zOK) { @@ -787,7 +787,7 @@ STATUS dlog_logical_recovery_common( rc = zFAILURE; } } - else + else { zASSERT("Not supposed to happen in a nametree interface operation!" == 0); SetErrno(genMsg, zERR_BAD_PARAMETER_VALUE); @@ -796,7 +796,7 @@ STATUS dlog_logical_recovery_common( } break; } - case DLOG_OP_CH_MASK: + case DLOG_OP_CH_MASK: { dlog_chmask_s *ch_mask = &dlog_op->chmask; Leaf_s *e = (Leaf_s *)dlog_entries; @@ -813,7 +813,7 @@ STATUS dlog_logical_recovery_common( else { // cnt nameUniquifier = e->nameUniquifier; - rc = DIR_MODIFY_NSMASK(&parms, &e->k, &zid, /* cnt &nameUniquifier,*/ + rc = DIR_MODIFY_NSMASK(&parms, &e->k, &zid, /* cnt &nameUniquifier,*/ ch_mask->oldmask, ch_mask->newmask); } if (rc != zOK) @@ -823,7 +823,7 @@ STATUS dlog_logical_recovery_common( } break; } - case DLOG_OP_CH_MATCHATTR: + case DLOG_OP_CH_MATCHATTR: { dlog_chmatchAttr_s *ch_matchAttr = &dlog_op->chmatchAttr; Leaf_s *e = (Leaf_s *)dlog_entries; @@ -850,7 +850,7 @@ STATUS dlog_logical_recovery_common( } break; } - case DLOG_OP_CH_HLFLAGS: + case DLOG_OP_CH_HLFLAGS: { dlog_chHlFlags_s *ch_hlFlags = &dlog_op->chHlFlags; Leaf_s *e = (Leaf_s *)dlog_entries; @@ -937,16 +937,16 @@ void dlog_dumprec(ZfsXasRecovery_s *dlbuf, SNINT size) dlog_op_s *dlog_op; BYTE *dlentries; SNINT dlentry_off; - - if (dlbuf->ZXR_TransactionState & XAS_XR_TS_START) + + if (dlbuf->ZXR_TransactionState & XAS_XR_TS_START) { DB_PRINTF((CYAN, MSGNot("StartX { "))); } - if (dlbuf->ZXR_TransactionState & XAS_XR_TS_MIDDLE) + if (dlbuf->ZXR_TransactionState & XAS_XR_TS_MIDDLE) { DB_PRINTF((CYAN, MSGNot("----X "))); } - if (dlbuf->ZXR_TransactionState & XAS_XR_TS_END) + if (dlbuf->ZXR_TransactionState & XAS_XR_TS_END) { DB_PRINTF((CYAN, MSGNot("} EndX "))); } @@ -966,24 +966,24 @@ void dlog_dumprec(ZfsXasRecovery_s *dlbuf, SNINT size) DB_PRINTF((CYAN, MSGNot("%qd, log# %qd, func %d: %d blks\n"), dlbuf->ZXR_LocalXid, dlbuf->ZXR_Lsn, dlbuf->ZXR_FunctionIndex, dlbuf->ZXR_PoolBlockCount)); - for (i = 0; i < DLOG_NBLKS(dlbuf); ++ i) + for (i = 0; i < DLOG_NBLKS(dlbuf); ++ i) { DB_PRINTF((CYAN, MSGNot("\t%d: blk_alloc.is_leaf & (1 << i)) + DB_PRINTF((CYAN, MSGNot(" %s"), (dlhdr->blk_alloc.is_leaf & (1 << i)) ? MSGNot("leaf") : MSGNot("branch"))); if (dlhdr->blk_alloc.is_ovflow & (i << i)) DB_PRINTF((CYAN, MSGNot(" ovflow"))); @@ -992,7 +992,7 @@ void dlog_dumprec(ZfsXasRecovery_s *dlbuf, SNINT size) DB_PRINTF((CYAN, MSGNot(">\n"))); } - if (! dlhdr) + if (! dlhdr) { DB_PRINTF((CYAN, MSGNot("0 ops\n"))); return; @@ -1004,18 +1004,18 @@ void dlog_dumprec(ZfsXasRecovery_s *dlbuf, SNINT size) dlog_op = DLOG_OPS(dlog_rec); dlentries = DLOG_ENTRIES(dlog_rec); dlentry_off = 0; - for (j = 0; j != endi; j += 1) + for (j = 0; j != endi; j += 1) { dlog_op_t op = dlog_op->op; DB_PRINTF((CYAN, MSGNot("<"))); - switch (DLOG_BASE_OP(op)) + switch (DLOG_BASE_OP(op)) { - case DLOG_OP_MOVE: + case DLOG_OP_MOVE: { dlog_move_s *mv_op = &dlog_op->move; DB_PRINTF((CYAN, MSGNot("%s"), (op & DLOG_OP_COPY) ? MSGNot("copy") : MSGNot("move"))); - if (op & DLOG_OP_DUP) + if (op & DLOG_OP_DUP) { DB_PRINTF((CYAN, MSGNot(" dup"))); } @@ -1025,7 +1025,7 @@ void dlog_dumprec(ZfsXasRecovery_s *dlbuf, SNINT size) DLOG_DUMPENTRY(dlentries, dlentry_off, mv_op->log, 0,mv_op->nrecs); break; } - case DLOG_OP_REPL: + case DLOG_OP_REPL: { dlog_repl_s *repl_op = &dlog_op->repl; SNINT do_repl, do_ins; @@ -1035,53 +1035,53 @@ void dlog_dumprec(ZfsXasRecovery_s *dlbuf, SNINT size) zASSERT(! (do_ins && (op & DLOG_OP_DELETE))); DB_PRINTF((CYAN, MSGNot("At <%d, %d"), repl_op->blki, repl_op->i)); - if (op & DLOG_OP_DUP) + if (op & DLOG_OP_DUP) { DB_PRINTF((CYAN, MSGNot(", %d> dup"), repl_op->dupi)); } else DB_PRINTF((CYAN, MSGNot(">"))); if (op & DLOG_OP_OVFLOW) DB_PRINTF((CYAN, MSGNot(" ovflow"))); - if (do_repl) + if (do_repl) { DB_PRINTF((CYAN, MSGNot(" repl oldlog %d with newlog %d"), repl_op->oldlog, repl_op->newlog)); DLOG_DUMPENTRY(dlentries, dlentry_off, repl_op->oldlog, 0, 1); DLOG_DUMPENTRY(dlentries, dlentry_off, repl_op->newlog, 0, 1); } - else if (do_ins) + else if (do_ins) { DB_PRINTF((CYAN, MSGNot(" insert newlog %d"), repl_op->newlog)); DLOG_DUMPENTRY(dlentries, dlentry_off, repl_op->newlog, 0, 1); } - else + else { DB_PRINTF((CYAN, MSGNot(" delete oldlog %d"), repl_op->oldlog)); DLOG_DUMPENTRY(dlentries, dlentry_off, repl_op->oldlog, 0, 1); } break; } - case DLOG_OP_REPLKEY: + case DLOG_OP_REPLKEY: { dlog_replkey_s *replk_op = &dlog_op->replkey; SNINT do_repl = ((op & (DLOG_OP_INSERT|DLOG_OP_DELETE)) == 0); - SNINT do_ins = ((op & DLOG_OP_INSERT) != 0); + SNINT do_ins = ((op & DLOG_OP_INSERT) != 0); DB_PRINTF((CYAN, MSGNot("At <%d, %d> "), replk_op->blki, replk_op->i)); - if (do_repl) + if (do_repl) { DB_PRINTF((CYAN, MSGNot("replkey oldlog %d with newlog %d"), replk_op->oldlog, replk_op->newlog)); DLOG_DUMPENTRY(dlentries, dlentry_off, replk_op->oldlog, 0, 1); DLOG_DUMPENTRY(dlentries, dlentry_off, replk_op->newlog, 0, 1); } - else + else { SNINT log = do_ins ? replk_op->newlog : replk_op->oldlog; - DB_PRINTF((CYAN, MSGNot("%s newlog %d, blk %d"), + DB_PRINTF((CYAN, MSGNot("%s newlog %d, blk %d"), do_ins ? MSGNot("inskey" : "delkey"), log, replk_op->blk)); DLOG_DUMPENTRY(dlentries, dlentry_off, log, 0, 1); } - if (op & DLOG_OP_OVFLOW) + if (op & DLOG_OP_OVFLOW) { SNINT e_repl; SNINT insi = replk_op->ovflow_data; @@ -1092,7 +1092,7 @@ void dlog_dumprec(ZfsXasRecovery_s *dlbuf, SNINT size) } break; } - case DLOG_OP_EXPAND: + case DLOG_OP_EXPAND: { dlog_expand_s *expand_op = &dlog_op->expand; SNINT esize = expand_op->size; @@ -1101,7 +1101,7 @@ void dlog_dumprec(ZfsXasRecovery_s *dlbuf, SNINT size) DLOG_DUMPENTRY(dlentries, dlentry_off, expand_op->log, 0, 1); break; } - case DLOG_OP_CH_MASK: + case DLOG_OP_CH_MASK: { dlog_chmask_s *ch_mask = &dlog_op->chmask; DB_PRINTF((CYAN, MSGNot("ch_mask <%d, %d, %d> from 0x%x to 0x%x"), @@ -1109,7 +1109,7 @@ void dlog_dumprec(ZfsXasRecovery_s *dlbuf, SNINT size) ch_mask->oldmask, ch_mask->newmask)); break; } - case DLOG_OP_CH_MATCHATTR: + case DLOG_OP_CH_MATCHATTR: { dlog_chmatchAttr_s *ch_matchAttr = &dlog_op->chmatchAttr; DB_PRINTF((CYAN, MSGNot("ch_matchAttr <%d, %d, %d> from 0x%x to 0x%x"), @@ -1117,49 +1117,49 @@ void dlog_dumprec(ZfsXasRecovery_s *dlbuf, SNINT size) ch_matchAttr->oldmatchAttr, ch_matchAttr->newmatchAttr)); break; } - case DLOG_OP_CH_HLFLAGS: + case DLOG_OP_CH_HLFLAGS: { - dlog_chHlFlags_s *ch_hlFlags = &dlog_op->chHlFlags; + dlog_chHlFlags_s *ch_hlFlags = &dlog_op->chHlFlags; DB_PRINTF((CYAN, MSGNot("ch_hlFlags <%d, %d, %d> from 0x%x to 0x%x"), ch_hlFlags->blki, ch_hlFlags->i, ch_hlFlags->dupi, ch_hlFlags->oldHlFlags, ch_hlFlags->newHlFlags)); break; } - case DLOG_OP_CH_ROOT: + case DLOG_OP_CH_ROOT: { dlog_chroot_s *ch_root = &dlog_op->chroot; DB_PRINTF((CYAN, MSGNot("ch_root from %d to %d"), ch_root->oldblki, ch_root->newblki)); break; } - case DLOG_OP_CH_LCHILD: + case DLOG_OP_CH_LCHILD: { dlog_ch_lchild_s *ch_lchild = &dlog_op->ch_lchild; DB_PRINTF((CYAN, MSGNot("ch_lchild of <%d> from %d to %d"), ch_lchild->blki, ch_lchild->oldblk, ch_lchild->newblk)); break; } - case DLOG_OP_SET_OVFLOW: + case DLOG_OP_SET_OVFLOW: { dlog_set_ovflow_s *set_ovflow = &dlog_op->set_ovflow; SNINT reset = ((op & DLOG_OP_RESET_OVFLOW) != 0); - if (reset) + if (reset) { DB_PRINTF((CYAN, MSGNot("reset_ovflow of <%d> from %d to INVALID"), set_ovflow->blki, set_ovflow->ovflow_blk)); } - else + else DB_PRINTF((CYAN, MSGNot("set_ovflow of <%d> from INVALID to %d"), set_ovflow->blki, set_ovflow->ovflow_blk)); break; } - case DLOG_OP_LEAFLIST: + case DLOG_OP_LEAFLIST: { dlog_leaflist_s *leaflist = &dlog_op->leaflist; SNINT do_ins = op & DLOG_OP_INSERT; SNINT isovflow = op & DLOG_OP_OVFLOW; - if (isovflow) + if (isovflow) { DB_PRINTF((CYAN, MSGNot("ovflow "))); } @@ -1187,7 +1187,7 @@ zlog_dumpblk(BYTE *zlog_buf) blkhdr->ZLBH_NumberOfRecords, blkhdr->ZLBH_NumberOfUnusedLongs, ZLOG_MAX_BLK_SIZE)); rechdr = (ZLOGRecordHeader_s *)(zlog_buf + sizeof(ZLOGBlockHeader_s)); - for (i = 0; i < blkhdr->ZLBH_NumberOfRecords; ++ i) + for (i = 0; i < blkhdr->ZLBH_NumberOfRecords; ++ i) { DB_PRINTF((CYAN, MSGNot("----> size %d bytes "), rechdr->ZLRH_LongLength)); dlog_dumprec(&rechdr->ZLRH_Zxr, rechdr->ZLRH_LongLength - diff --git a/src/nwnss/zlss/dlog.h b/src/nwnss/zlss/dlog.h index 9d3b325..c72cec8 100644 --- a/src/nwnss/zlss/dlog.h +++ b/src/nwnss/zlss/dlog.h @@ -44,7 +44,7 @@ typedef SWORD dlog_offset_t; #define DLOG_NBLKS(_dlbuf_) ((_dlbuf_)->ZXR_PoolBlockCount) -typedef struct dlog_move +typedef struct dlog_move { dlog_op_t op; dlog_ind_t srcblki; @@ -84,7 +84,7 @@ typedef struct dlog_move DLOG_ADD_OP_MOVE_COMMON(_dl_ops_, _srcbi_, _si_, _dstbi_, \ _di_, _log_, _nrecs_, DLOG_OP_DUP) -typedef struct dlog_replkey +typedef struct dlog_replkey { dlog_op_t op; dlog_ind_t blki; @@ -130,7 +130,7 @@ typedef struct dlog_replkey DLOG_ADD_OP_REPLKEY_COMMON(_dl_ops_, _blki_, _i_, _log_, _b_, \ DLOG_OP_INSERT|DLOG_OP_OVFLOW, 0, _od_) -typedef struct dlog_repl +typedef struct dlog_repl { dlog_op_t op; dlog_ind_t blki; @@ -182,7 +182,7 @@ typedef struct dlog_repl DLOG_OP_DUP, _oldl_) -typedef struct dlog_expand +typedef struct dlog_expand { dlog_op_t op; dlog_ind_t blki; @@ -202,7 +202,7 @@ typedef struct dlog_expand ++ (_dl_ops_); \ } while (0) -typedef struct dlog_set_ovflow +typedef struct dlog_set_ovflow { dlog_op_t op; dlog_ind_t blki; @@ -225,7 +225,7 @@ typedef struct dlog_set_ovflow #define DLOG_ADD_OP_RESET_OVFLOW(_dl_ops_, _blki_, _ovblk_) \ DLOG_ADD_OP_SET_OVFLOW_COMMON(_dl_ops_, _blki_,_ovblk_,DLOG_OP_RESET_OVFLOW) -typedef struct dlog_chmask +typedef struct dlog_chmask { dlog_op_t op; dlog_ind_t blki; @@ -258,7 +258,7 @@ typedef struct dlog_chmatchAttr } NSS_MEDIA_STRUCTURE(dlog_chmatchAttr_s,newmatchAttr) dlog_chmatchAttr_s; #define DLOG_ADD_OP_CH_MATCHATTR(_dl_ops_, _blki_, _i_, _dupi_, _oldmatch, \ - _newmatch) \ + _newmatch) \ do { \ dlog_chmatchAttr_s *ch_matchAttr = &(_dl_ops_)->chmatchAttr; \ (_dl_ops_)->op = DLOG_OP_CH_MATCHATTR; \ @@ -281,7 +281,7 @@ typedef struct dlog_chHlFlags } dlog_chHlFlags_s; #define DLOG_ADD_OP_CH_HLFLAGS(_dl_ops_, _blki_, _i_, _dupi_, _oldHlFlags, \ - _newHlFlags) \ + _newHlFlags) \ do { \ dlog_chHlFlags_s *ch_HlFlags = &(_dl_ops_)->chHlFlags; \ (_dl_ops_)->op = DLOG_OP_CH_HLFLAGS; \ @@ -293,7 +293,7 @@ typedef struct dlog_chHlFlags ++ (_dl_ops_); \ } while (0) -typedef struct dlog_chroot +typedef struct dlog_chroot { dlog_op_t op; dlog_ind_t oldblki; @@ -309,7 +309,7 @@ typedef struct dlog_chroot ++ (_dl_ops_); \ } while (0) -typedef struct dlog_ch_lchild +typedef struct dlog_ch_lchild { dlog_op_t op; dlog_ind_t blki; @@ -327,7 +327,7 @@ typedef struct dlog_ch_lchild ++ (_dl_ops_); \ } while (0) -typedef struct dlog_leaflist +typedef struct dlog_leaflist { dlog_op_t op; dlog_ind_t prevblki; @@ -387,7 +387,7 @@ typedef struct dlog_leaflist #define DLOG_OP_CH_MATCHATTR 0x000A #define DLOG_OP_CH_HLFLAGS 0x000B -typedef union +typedef union { dlog_move_s move; dlog_replkey_s replkey; @@ -396,14 +396,14 @@ typedef union dlog_set_ovflow_s set_ovflow; dlog_chmask_s chmask; dlog_chmatchAttr_s chmatchAttr; - dlog_chHlFlags_s chHlFlags; + dlog_chHlFlags_s chHlFlags; dlog_chroot_s chroot; dlog_ch_lchild_s ch_lchild; dlog_leaflist_s leaflist; dlog_op_t op; } NSS_MEDIA_UNION(NamelessUnion,op) dlog_op_s; -typedef struct dlog +typedef struct dlog { struct blk_alloc_s { /* Info about alloc'ed/dealloc'ed blocks */ WORD is_leaf; /* type of block (leaf/branch): bitmap (0-15) */ @@ -449,9 +449,9 @@ typedef struct dlog_newhdr_s #define DLOG_DELETE_LEAF(_xaction_, _hdr_, _binfo_, _bi_, _isovfl_) \ DLOG_DELETE_BLK(_xaction_, _hdr_, _binfo_, _bi_, 1, _isovfl_) -/* In the new log record format, - * we prepend the volume's internal ID before the old record - * All macros below are relative to the old record. +/* In the new log record format, + * we prepend the volume's internal ID before the old record + * All macros below are relative to the old record. * During recovery, we distinguish the record from the function index used */ #define DLOG_NEWHDR_SIZE sizeof(dlog_newhdr_s) #define DLOG_NEWHDR(_dlrec_) ((dlog_newhdr_s *)(_dlrec_)) @@ -492,7 +492,7 @@ do { \ (_ntree)->ZFSNAMETREEinternalID; \ (_logrecord) = DLOG_OLD_RECORD(_logrecord); \ } while (0) - + #define DLOG_SET_BLKINFO(_bi_, _blki_, _buf_, _lsn_, _xact_) \ ZLOG_ASSIGN_BLOCK_INFO2((_bi_)[_blki_], (_buf_)->BUFblknum, _lsn_, \ _buf_, _xact_, _blki_, (LogTestCompareFunc_t)node_compare) diff --git a/src/nwnss/zlss/eflLog.c b/src/nwnss/zlss/eflLog.c index 6c9b0ec..209a3c2 100644 --- a/src/nwnss/zlss/eflLog.c +++ b/src/nwnss/zlss/eflLog.c @@ -81,7 +81,7 @@ void EFL_DisplayLogEntry ( EFL_Printf(LCYAN, " Name:%U\n", entry->names); if (entry->oldNameIndex != (WORD)-1) { - EFL_Printf(LCYAN, " Old name:%U\n", + EFL_Printf(LCYAN, " Old name:%U\n", &entry->names[entry->oldNameIndex]); } } @@ -290,7 +290,7 @@ Buffer_s *ELOG_ReadPoolBlk ( * ****************************************************************************/ void ELOG_InitNode( - Buffer_s *buffer, + Buffer_s *buffer, GUID_t *internalID, NINT type) { @@ -348,10 +348,10 @@ STATUS ELOG_RemoveNode( xaction = BeginXLocal(&((ZfsVolume_s *)volume)->vol, BXL_DEFAULT); - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2) + + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2) + sizeof(ELogRemoveNode_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_EFLLOG_REMOVE_NODE, xaction, + ZLOG_INIT_LOG_RECORD(XFUNC_EFLLOG_REMOVE_NODE, xaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, node->lsn, buffer, xaction, 0); @@ -378,7 +378,7 @@ STATUS ELOG_RemoveNode( /**************************************************************************** * * Allocate a single block to serve as the header to the log file. We cannot - * use a dymnamic first node because the EFL beast must be locked to + * use a dymnamic first node because the EFL beast must be locked to * ****************************************************************************/ Buffer_s *ELOG_AllocateHeaderNode( @@ -389,19 +389,19 @@ Buffer_s *ELOG_AllocateHeaderNode( ZfsEFLTreeBeast_s *eTree = ((ZfsVolume_s *)volume)->eflTree; Buffer_s *buffer; IoMsg_s iomsg; - + /* get the new node */ XALLOCBLK_IO_MSG(iomsg, eTree, localXaction, CACHE_UPDATE); buffer = ZFS_AllocPoolBlk(genMsg, &iomsg); if (buffer != NULL) { - ELOG_InitNode(buffer, &eTree->ZFSEFLTREEroot.ROOTinternalID, + ELOG_InitNode(buffer, &eTree->ZFSEFLTREEroot.ROOTinternalID, ELOG_HEADER_RECORD); } return buffer; } - + /**************************************************************************** * * Allocate a new block for the EFL log and link it to the previous end @@ -451,10 +451,10 @@ Buffer_s *ELOG_AllocNewNode( newBlockNum = buffer->volBlk; /* Fill in the recovery log information */ - ELOG_InitNode(buffer, &eTree->ZFSEFLTREEroot.ROOTinternalID, + ELOG_InitNode(buffer, &eTree->ZFSEFLTREEroot.ROOTinternalID, ELOG_LOG_RECORD); - ZLOG_ObtainRecord(localXaction, ZLOG_BLOCK_INFO_SIZE(3) + + ZLOG_ObtainRecord(localXaction, ZLOG_BLOCK_INFO_SIZE(3) + sizeof(ELogAddNode_s)); ZLOG_INIT_LOG_RECORD(XFUNC_EFLLOG_ADD_NODE, localXaction, logBuffer, 3, poolBlks, logRecord); @@ -470,7 +470,7 @@ Buffer_s *ELOG_AllocNewNode( logRecord->u.addNode.newBlock = newBlockNum; logRecord->u.addNode.oldNextLink = previous->nextBlock; logRecord->u.addNode.oldLastLink = header->u.header.lastBlock; - + icurrent->lsn = logBuffer->ZXR_Lsn; header->lsn = logBuffer->ZXR_Lsn; previous->lsn = logBuffer->ZXR_Lsn; @@ -496,10 +496,10 @@ exit: return buffer; } - + /**************************************************************************** * - * Add a new entry to the EFL log + * Add a new entry to the EFL log * ****************************************************************************/ STATUS ELOG_AddLogEntry( @@ -534,7 +534,7 @@ STATUS ELOG_AddLogEntry( IoMsg_s iomsg; NINT offset; NINT objectType; - + currentName = malloc(zMAX_FULL_NAME * sizeof(unicode_t)); if (!currentName) { @@ -567,16 +567,16 @@ STATUS ELOG_AddLogEntry( } /* - * If the entry is too big then truncate the name. This is a kludge - * but it should keep us from crashing. - */ + * If the entry is too big then truncate the name. This is a kludge + * but it should keep us from crashing. + */ if (entryLen > PAGE_SIZE) { zASSERT("Name overflow in EFL log"); oldNameLen -= (entryLen - PAGE_SIZE) + 2; oldNameLenBytes = oldNameLen * sizeof(unicode_t); } - + /* Get the header node */ READBLK_IO_MSG(iomsg, eTree, eTree->p.logHeaderBlock, CACHE_UPDATE); headerBuf = ELOG_ReadPoolBlk(genMsg, &iomsg); @@ -593,7 +593,7 @@ STATUS ELOG_AddLogEntry( /* Get the last node we were working on */ if (header->u.header.lastBlock != INVALID_BLK_ZERO) { - READBLK_IO_MSG(iomsg, eTree, header->u.header.lastBlock, + READBLK_IO_MSG(iomsg, eTree, header->u.header.lastBlock, CACHE_UPDATE); buffer = ELOG_ReadPoolBlk(genMsg, &iomsg); if (buffer == NULL) @@ -617,7 +617,7 @@ STATUS ELOG_AddLogEntry( if ((entryLen > (ELOG_MAX_FREE - node->u.log.insertOffset)) || (buffer == headerBuf)) { - if ((buffer = ELOG_AllocNewNode(genMsg, volume, headerBuf, + if ((buffer = ELOG_AllocNewNode(genMsg, volume, headerBuf, buffer)) == NULL) { status = zFAILURE; @@ -632,9 +632,9 @@ STATUS ELOG_AddLogEntry( } /* - * If there are other entries for this zid then get the block where the - * last entry was done. It will be updated to point at the the new entry. - */ + * If there are other entries for this zid then get the block where the + * last entry was done. It will be updated to point at the the new entry. + */ if (leafEntry->lastLogEntry.blockNum != INVALID_BLK_ZERO) { if (leafEntry->lastLogEntry.blockNum == buffer->volBlk) @@ -643,7 +643,7 @@ STATUS ELOG_AddLogEntry( } else { - READBLK_IO_MSG(iomsg, eTree, leafEntry->lastLogEntry.blockNum, + READBLK_IO_MSG(iomsg, eTree, leafEntry->lastLogEntry.blockNum, CACHE_UPDATE); lastBuffer = ELOG_ReadPoolBlk(genMsg, &iomsg); if (lastBuffer == NULL) @@ -668,7 +668,7 @@ STATUS ELOG_AddLogEntry( ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2) + sizeof(ELogAddEntry_s)); ZLOG_INIT_LOG_RECORD(XFUNC_EFLLOG_ADD_ENTRY, xaction, logBuffer, 2, poolBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, node->lsn, buffer, + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, node->lsn, buffer, xaction, 0); if (lastBuffer) { @@ -681,8 +681,8 @@ STATUS ELOG_AddLogEntry( } /* - * Fill in the new entry - */ + * Fill in the new entry + */ zASSERT(((node->u.log.insertOffset >> 2) << 2) == node->u.log.insertOffset); offset = node->u.log.insertOffset; entry = (ELogEntry_s *)&node->u.log.data[offset]; @@ -759,7 +759,7 @@ STATUS ELOG_AddLogEntry( logRecord->u.addEntry.firstLogEntry = leafEntry->firstLogEntry; logRecord->u.addEntry.numGoodLogEntries = leafEntry->numGoodLogEntries; logRecord->u.addEntry.internalID = eTree->ZFSEFLTREEroot.ROOTinternalID; - memcpy(&logRecord->u.addEntry.entry, entry, sizeof(ELogEntry_s) - + memcpy(&logRecord->u.addEntry.entry, entry, sizeof(ELogEntry_s) - sizeof(unicode_t)); node->lsn = logBuffer->ZXR_Lsn; @@ -772,15 +772,15 @@ STATUS ELOG_AddLogEntry( ZLOG_BIND(xaction, buffer); ZLOG_ReleaseRecord(xaction); - /* - * Log the names in seperate log records because they can overflow a - * single log record. - */ - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + /* + * Log the names in seperate log records because they can overflow a + * single log record. + */ + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + sizeof(ELogAddEntryName_s) + currentNameLen * sizeof(unicode_t)); ZLOG_INIT_LOG_RECORD(XFUNC_EFLLOG_ADD_ENTRY_NAME, xaction, logBuffer, 1, poolBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, node->lsn, buffer, + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, node->lsn, buffer, xaction, 0); logRecord->u.addEntryName.nameIndex = 0; logRecord->u.addEntryName.entryLen = entryLen; @@ -791,14 +791,14 @@ STATUS ELOG_AddLogEntry( if (oldName) { - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + sizeof(ELogAddEntryName_s) + oldNameLenBytes); ZLOG_INIT_LOG_RECORD(XFUNC_EFLLOG_ADD_ENTRY_NAME, xaction, logBuffer, 1, poolBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, node->lsn, buffer, + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, node->lsn, buffer, xaction, 0); - logRecord->u.addEntryName.nameIndex = currentNameLen + 1; - logRecord->u.addEntryName.entryLen = entryLen; + logRecord->u.addEntryName.nameIndex = currentNameLen + 1; + logRecord->u.addEntryName.entryLen = entryLen; memcpy(logRecord->u.addEntryName.name, oldName, oldNameLenBytes); logRecord->u.addEntryName.name[oldNameLen] = L'\0'; node->lsn = logBuffer->ZXR_Lsn; @@ -870,11 +870,11 @@ STATUS ELOG_FixupDeletedEntry( { /* - * If we are in a buffer other than the first one then - * we need to get the first one also. We are able to latch - * back up the chain of blocks because we never hold latches - * on two blocks during other operations. - */ + * If we are in a buffer other than the first one then + * we need to get the first one also. We are able to latch + * back up the chain of blocks because we never hold latches + * on two blocks during other operations. + */ if (currentBlock != leafEntry->firstLogEntry.blockNum) { READBLK_IO_MSG(iomsg, eTree, leafEntry->firstLogEntry.blockNum, @@ -905,9 +905,9 @@ STATUS ELOG_FixupDeletedEntry( if (changedEpochs || changed) { - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2) + + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2) + sizeof(ELogModifyEpochs_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_EFLLOG_MODIFY_EPOCH, xaction, logBuffer, + ZLOG_INIT_LOG_RECORD(XFUNC_EFLLOG_MODIFY_EPOCH, xaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, node->lsn, buffer, xaction, 0); @@ -916,9 +916,9 @@ STATUS ELOG_FixupDeletedEntry( logRecord->u.modifyEpochs.offset = offset; logRecord->u.modifyEpochs.epochsToChange = changedEpochs; - logRecord->u.modifyEpochs.firstEntryAdjustment = + logRecord->u.modifyEpochs.firstEntryAdjustment = firstEntryAdjustment; - + node->lsn = logBuffer->ZXR_Lsn; firstNode->lsn = logBuffer->ZXR_Lsn; @@ -983,7 +983,7 @@ STATUS ELOG_ClearALogEntry( /**************************************************************************** * - * Clear all the indicated epochs for all of the entries on this ZID. + * Clear all the indicated epochs for all of the entries on this ZID. * ****************************************************************************/ STATUS ELOG_ClearLogEntries( @@ -1023,14 +1023,14 @@ STATUS ELOG_ClearLogEntries( nextLink = entry->nextLogEntry; if ((typesToClear == ELOG_CLEAR_ALL) || - ((entry->action == ELOG_CREATE) && + ((entry->action == ELOG_CREATE) && (typesToClear & ELOG_CLEAR_CREATE)) || - ((entry->action == ELOG_MODIFY || - entry->action == ELOG_MODIFY_META_DATA) && + ((entry->action == ELOG_MODIFY || + entry->action == ELOG_MODIFY_META_DATA) && (typesToClear & ELOG_CLEAR_MODIFY)) || - ((entry->action == ELOG_RENAME) && + ((entry->action == ELOG_RENAME) && (typesToClear & ELOG_CLEAR_RENAME)) || - ((entry->action == ELOG_DELETE) && + ((entry->action == ELOG_DELETE) && (typesToClear & ELOG_CLEAR_DELETE))) { if (ELOG_FixupDeletedEntry(genMsg, volume, leafEntry, buffer, @@ -1115,7 +1115,7 @@ STATUS ELOG_ClearSameNameCreate( /**************************************************************************** * * Find all epochs for this ZID that already have a modify record. Return - * the epochs that do not have it set. + * the epochs that do not have it set. * ****************************************************************************/ STATUS ELOG_FindModifyForEpochs( @@ -1173,8 +1173,8 @@ STATUS ELOG_FindModifyForEpochs( ****************************************************************************/ Buffer_s *ELOG_GetFirstGoodEntry( GeneralMsg_s *genMsg, - ZfsEFLTreeBeast_s *eTree, - Blknum_t block, + ZfsEFLTreeBeast_s *eTree, + Blknum_t block, NINT offset, Blknum_t *retBlock, NINT *retOffset) @@ -1229,8 +1229,8 @@ Buffer_s *ELOG_GetFirstGoodEntry( ****************************************************************************/ Buffer_s *ELOG_GetNextGoodEntry( GeneralMsg_s *genMsg, - ZfsEFLTreeBeast_s *eTree, - Buffer_s *buffer, + ZfsEFLTreeBeast_s *eTree, + Buffer_s *buffer, NINT offset, Blknum_t *retBlock, NINT *retOffset) @@ -1264,7 +1264,7 @@ Buffer_s *ELOG_GetNextGoodEntry( { zASSERT("Error getting block in EFL enumerate(2)" == NULL); return NULL; - } + } } /* Find a good entry */ @@ -1312,7 +1312,7 @@ Buffer_s *ELOG_GetNextGoodEntry( * Returns TRUE if something was changed. ****************************************************************************/ BOOL ELOG_FixupEntries( - ZfsEFLTreeBeast_s *eTree, + ZfsEFLTreeBeast_s *eTree, ELogNode_s *node) { ELogEntry_s *entry; @@ -1330,7 +1330,7 @@ BOOL ELOG_FixupEntries( entry = (ELogEntry_s *)&node->u.log.data[offset]; zASSERT(i == entry->entryNum); zASSERT(entry->magic == ELOG_ENTRY_MAGIC); - + originalEpochs = entry->epochs; entry->epochs &= eTree->p.usedEpochs; if (entry->epochs != originalEpochs) @@ -1387,10 +1387,10 @@ STATUS ELOG_CleanupBlocks( header = (ELogNode_s *)headerBuf->pBuf.data; /* - * Keep getting and deleting blocks until we come to the end of the list - * or we hit the first block with used entries (if we are only cleaning up - * unused entries). - */ + * Keep getting and deleting blocks until we come to the end of the list + * or we hit the first block with used entries (if we are only cleaning up + * unused entries). + */ while (header->nextBlock != INVALID_BLK_ZERO) { READBLK_IO_MSG(iomsg, eTree, header->nextBlock, CACHE_UPDATE); @@ -1520,7 +1520,7 @@ STATUS ELOG_recoveryAddNode( node = (ELogNode_s *)buffer->pBuf.data; - if (!sameBlock && + if (!sameBlock && ZLOG_ALREADY_DONE(pool, logBuffer, node->lsn, action)) { CACHE_RELEASE(buffer); @@ -1615,7 +1615,7 @@ STATUS ELOG_recoveryAddNodeUndo( node = (ELogNode_s *)buffer->pBuf.data; - if (!sameBlock && + if (!sameBlock && ZLOG_ALREADY_DONE(pool, logBuffer, node->lsn, action)) { CACHE_RELEASE(buffer); @@ -1678,7 +1678,7 @@ STATUS ELOG_recoveryAddEntry( else { /* add the entry */ - memcpy(&node->u.log.data[node->u.log.insertOffset], + memcpy(&node->u.log.data[node->u.log.insertOffset], &logRecord->u.addEntry.entry, sizeof(ELogEntry_s) - sizeof(unicode_t)); node->u.log.insertOffset += logRecord->u.addEntry.entry.len; node->numEntries++; @@ -1710,7 +1710,7 @@ STATUS ELOG_recoveryAddEntry( node = (ELogNode_s *)buffer->pBuf.data; - if (!sameBlock && + if (!sameBlock && ZLOG_ALREADY_DONE(pool, logBuffer, node->lsn, action)) { CACHE_RELEASE(buffer); @@ -1745,7 +1745,7 @@ STATUS ELOG_recoveryRemoveEntryLogical( NINT action) { EFLRecoveryLog_s *logRecord; - BlockInfo_s *poolBlks; + BlockInfo_s *poolBlks; ZfsVolume_s *zfsVol; ZfsXaction_s *xaction; GUID_t internalID; @@ -1777,8 +1777,8 @@ STATUS ELOG_recoveryRemoveEntryLogical( currentEntry.firstLogEntry = logRecord->u.addEntry.firstLogEntry; xaction = BeginXLocal(&zfsVol->vol, BXL_LOGICAL_UNDO); - status = ELOG_ClearALogEntry(genMsg, &zfsVol->vol, ¤tEntry, - poolBlks[0].blkNum, logRecord->u.addEntry.offset, + status = ELOG_ClearALogEntry(genMsg, &zfsVol->vol, ¤tEntry, + poolBlks[0].blkNum, logRecord->u.addEntry.offset, logRecord->u.addEntry.entry.epochs, xaction, &operation); zASSERT(operation == logRecord->u.addEntry.entry.action); SET_LUNDO_LSN(xaction, logBuffer, status); @@ -1830,10 +1830,10 @@ STATUS ELOG_recoveryAddEntryName( /* add the entry */ ELogEntry_s *entry; - entry = (ELogEntry_s *)&node->u.log.data[node->u.log.insertOffset - + entry = (ELogEntry_s *)&node->u.log.data[node->u.log.insertOffset - logRecord->u.addEntryName.entryLen]; - unicpy(&entry->names[logRecord->u.addEntryName.nameIndex], + unicpy(&entry->names[logRecord->u.addEntryName.nameIndex], logRecord->u.addEntryName.name); ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); CACHE_DIRTY_RELEASE(buffer); @@ -1844,7 +1844,7 @@ STATUS ELOG_recoveryAddEntryName( } /**************************************************************************** - * Recovery routine for adding a name into an entry in a node (logical undo + * Recovery routine for adding a name into an entry in a node (logical undo * of add) ****************************************************************************/ STATUS ELOG_recoveryRemoveEntryNameLogical( @@ -1860,10 +1860,10 @@ STATUS ELOG_recoveryRemoveEntryNameLogical( return zX_LOGICAL; } - /* - * There is no action because it will be taken care of in the logical - * undo of the entry - */ + /* + * There is no action because it will be taken care of in the logical + * undo of the entry + */ return zOK; } @@ -1990,7 +1990,7 @@ STATUS ELOG_recoveryRemoveNodeUndo( node = (ELogNode_s *)buffer->pBuf.data; - if (!sameBlock && + if (!sameBlock && ZLOG_ALREADY_DONE(pool, logBuffer, node->lsn, action)) { CACHE_RELEASE(buffer); @@ -2010,7 +2010,7 @@ STATUS ELOG_recoveryRemoveNodeUndo( } /**************************************************************************** - * Recovery routine for changing the epoch in an EFL log entry + * Recovery routine for changing the epoch in an EFL log entry ****************************************************************************/ STATUS ELOG_recoveryModifyEpoch( GeneralMsg_s *genMsg, @@ -2029,11 +2029,11 @@ STATUS ELOG_recoveryModifyEpoch( BOOL sameBlock; /* - * This is doing a physical undo even though the block is not being - * held locked through the entire transaction. This can be done because - * the information does not change position and we cannot get conflicting - * writes to this position in the block. - */ + * This is doing a physical undo even though the block is not being + * held locked through the entire transaction. This can be done because + * the information does not change position and we cannot get conflicting + * writes to this position in the block. + */ poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); @@ -2082,7 +2082,7 @@ STATUS ELOG_recoveryModifyEpoch( node->u.log.numGoodEntries++; } entry->state &= ~ELOG_ENTRY_STATE_DELETED; - + } entry->epochs ^= logRecord->u.modifyEpochs.epochsToChange; } @@ -2109,7 +2109,7 @@ STATUS ELOG_recoveryModifyEpoch( node = (ELogNode_s *)buffer->pBuf.data; - if (!sameBlock && + if (!sameBlock && ZLOG_ALREADY_DONE(pool, logBuffer, node->lsn, action)) { CACHE_RELEASE(buffer); @@ -2118,13 +2118,13 @@ STATUS ELOG_recoveryModifyEpoch( { if (action == X_REDO) { - node->u.log.numFirstEntries -= + node->u.log.numFirstEntries -= logRecord->u.modifyEpochs.firstEntryAdjustment; } else { - node->u.log.numFirstEntries += - logRecord->u.modifyEpochs.firstEntryAdjustment; + node->u.log.numFirstEntries += + logRecord->u.modifyEpochs.firstEntryAdjustment; } if (!sameBlock || !setLSN) diff --git a/src/nwnss/zlss/eflLog.h b/src/nwnss/zlss/eflLog.h index 2e8f8f4..0fb81f6 100644 --- a/src/nwnss/zlss/eflLog.h +++ b/src/nwnss/zlss/eflLog.h @@ -56,23 +56,23 @@ struct EFLLeafEntry_s; typedef struct ELogLink_s { - Blknum_t blockNum; /* block number of the entry */ - LONG resBlk; /* reserved for 64 bit block */ - LONG offset; /* offset into the block of the start of the entry */ + Blknum_t blockNum; /* block number of the entry */ + LONG resBlk; /* reserved for 64 bit block */ + LONG offset; /* offset into the block of the start of the entry */ } NSS_MEDIA_STRUCTURE(ELogLink_s,offset) ELogLink_s; typedef struct ELogEntry_s { - WORD magic; - WORD len; - WORD entryNum; /* zero based */ - WORD action; - Zid_t zid; - EFLEpochMask_t epochs; - ELogLink_s nextLogEntry; - WORD state; - WORD oldNameIndex; - unicode_t names[1]; /* variable length section with old and new names */ + WORD magic; + WORD len; + WORD entryNum; /* zero based */ + WORD action; + Zid_t zid; + EFLEpochMask_t epochs; + ELogLink_s nextLogEntry; + WORD state; + WORD oldNameIndex; + unicode_t names[1]; /* variable length section with old and new names */ } NSS_MEDIA_STRUCTURE(ELogEntry_s,names[1]) ELogEntry_s; /* Values for action */ @@ -90,197 +90,197 @@ typedef struct ELogEntry_s typedef struct ELogHeader_s { - Blknum_t lastBlock; /* The last block in the list */ - LONG resBlk; /* reserved for 64 bit block */ + Blknum_t lastBlock; /* The last block in the list */ + LONG resBlk; /* reserved for 64 bit block */ } NSS_MEDIA_STRUCTURE(ELogHeader_s,resBlk) ELogHeader_s; typedef struct ELogLog_s { - WORD numGoodEntries; /* The number of entries still in use */ - WORD numFirstEntries; /* The number of entries pointed to by the EFL tree */ - LONG insertOffset; /* The point in the block to start inserting */ - BYTE data[1]; + WORD numGoodEntries; /* The number of entries still in use */ + WORD numFirstEntries; /* The number of entries pointed to by the EFL tree */ + LONG insertOffset; /* The point in the block to start inserting */ + BYTE data[1]; } NSS_MEDIA_STRUCTURE(ELogLog_s,data[1]) ELogLog_s; typedef struct ELogNode_s { - /* - * If the size of the header portion changes then change EFL_MAX_FREEBLKS, - * EFL_MAX_BRANCHES and EFL_MAX_LEAF_FREE. - */ - LONG magic; - WORD numEntries; - WORD state; - Lsn_t lsn; - GUID_t elog_internalID; /* Must be at OFFSET 16 - unique volume ID (used - * by scanning repair). - */ - Blknum_t nextBlock; - LONG resBlk; /* reserved for 64 bit blocks */ - union - { - ELogHeader_s header; - ELogLog_s log; - } NSS_MEDIA_UNION(NamelessUnion,log) u; + /* + * If the size of the header portion changes then change EFL_MAX_FREEBLKS, + * EFL_MAX_BRANCHES and EFL_MAX_LEAF_FREE. + */ + LONG magic; + WORD numEntries; + WORD state; + Lsn_t lsn; + GUID_t elog_internalID; /* Must be at OFFSET 16 - unique volume ID (used + * by scanning repair). + */ + Blknum_t nextBlock; + LONG resBlk; /* reserved for 64 bit blocks */ + union + { + ELogHeader_s header; + ELogLog_s log; + } NSS_MEDIA_UNION(NamelessUnion,log) u; } NSS_MEDIA_STRUCTURE(ELogNode_s,u.log) ELogNode_s; #define ELOG_STATE_HEADER 0x0001 /* set if this is the header block */ -#define ELOG_STATE_REZID_DONE 0x0002 /* This node was ReZid - * This bit is only used while we are - * in the process of rezidding. - * When rezid is complete we clear this - * bit. - */ +#define ELOG_STATE_REZID_DONE 0x0002 /* This node was ReZid + * This bit is only used while we are + * in the process of rezidding. + * When rezid is complete we clear this + * bit. + */ typedef struct ELogParms_s { - NINT originalNameLen; - unicode_t *originalName; - NINT newNameLen; - unicode_t *newName; + NINT originalNameLen; + unicode_t *originalName; + NINT newNameLen; + unicode_t *newName; } ELogParms_s; typedef struct ELogAddNode_s { - GUID_t internalID; - Blknum_t newBlock; - Blknum_t oldNextLink; - Blknum_t oldLastLink; + GUID_t internalID; + Blknum_t newBlock; + Blknum_t oldNextLink; + Blknum_t oldLastLink; } NSS_MEDIA_STRUCTURE(ELogAddNode_s,oldLastLink) ELogAddNode_s; typedef struct ELogAddEntry_s { - GUID_t internalID; - ELogEntry_s entry; - LONG lastEntryOffset; - LONG offset; - LONG firstEntry; - ELogLink_s firstLogEntry; - LONG numGoodLogEntries; + GUID_t internalID; + ELogEntry_s entry; + LONG lastEntryOffset; + LONG offset; + LONG firstEntry; + ELogLink_s firstLogEntry; + LONG numGoodLogEntries; } NSS_MEDIA_STRUCTURE(ELogAddEntry_s,numGoodLogEntries) ELogAddEntry_s; typedef struct ELogAddEntryName_s { - LONG entryLen; - LONG nameIndex; - unicode_t name[1]; + LONG entryLen; + LONG nameIndex; + unicode_t name[1]; } NSS_MEDIA_STRUCTURE(ELogAddEntryName_s,name[1]) ELogAddEntryName_s; typedef struct ELogRemoveNode_s { - Blknum_t currentBlock; - Blknum_t nextBlock; + Blknum_t currentBlock; + Blknum_t nextBlock; } NSS_MEDIA_STRUCTURE(ELogRemoveNode_s,nextBlock) ELogRemoveNode_s; typedef struct ELogModifyEpochs_s { - LONG offset; - EFLEpochMask_t epochsToChange; - LONG firstEntryAdjustment; + LONG offset; + EFLEpochMask_t epochsToChange; + LONG firstEntryAdjustment; } NSS_MEDIA_STRUCTURE(ELogModifyEpochs_s,firstEntryAdjustment) ELogModifyEpochs_s; typedef struct EFLRecoveryLog_s { - union - { - ELogAddNode_s addNode; - ELogAddEntry_s addEntry; - ELogAddEntryName_s addEntryName; - ELogRemoveNode_s removeNode; - ELogModifyEpochs_s modifyEpochs; - } NSS_MEDIA_UNION(NamelessUnion,modifyEpochs) u; + union + { + ELogAddNode_s addNode; + ELogAddEntry_s addEntry; + ELogAddEntryName_s addEntryName; + ELogRemoveNode_s removeNode; + ELogModifyEpochs_s modifyEpochs; + } NSS_MEDIA_UNION(NamelessUnion,modifyEpochs) u; } NSS_MEDIA_STRUCTURE(EFLRecoveryLog_s,u.modifyEpochs[1]) EFLRecoveryLog_s; /* Prototypes */ void EFL_DisplayLogEntry ( - ELogEntry_s *entry, - NINT offset); + ELogEntry_s *entry, + NINT offset); Buffer_s *ELOG_ReadPoolBlk ( - struct GeneralMsg_s *genMsg, - struct IoMsg_s *iomsg); + struct GeneralMsg_s *genMsg, + struct IoMsg_s *iomsg); void ELOG_InitNode( - Buffer_s *buffer, - GUID_t *internalID, - NINT type); + Buffer_s *buffer, + GUID_t *internalID, + NINT type); Buffer_s *ELOG_AllocateHeaderNode( - struct GeneralMsg_s *genMsg, - Volume_s *volume, - struct ZfsXaction_s *localXaction); + struct GeneralMsg_s *genMsg, + Volume_s *volume, + struct ZfsXaction_s *localXaction); STATUS ELOG_AddLogEntry( - struct GeneralMsg_s *genMsg, - struct ZfsXaction_s *xaction, - struct EFLLeafEntry_s *leafEntry, - NINT action, - EFLEpochMask_t epochs, - struct Volume_s *volume, - Zid_t zid, - unicode_t *oldName); + struct GeneralMsg_s *genMsg, + struct ZfsXaction_s *xaction, + struct EFLLeafEntry_s *leafEntry, + NINT action, + EFLEpochMask_t epochs, + struct Volume_s *volume, + Zid_t zid, + unicode_t *oldName); STATUS ELOG_RemoveNode( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - struct Buffer_s *prevBuffer, - struct Buffer_s *buffer); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + struct Buffer_s *prevBuffer, + struct Buffer_s *buffer); STATUS ELOG_FindModifyForEpochs( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - struct EFLLeafEntry_s *leafEntry, - EFLEpochMask_t activeEpochs, - EFLEpochMask_t *notFoundEpochs, - BOOL includeMetaData); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + struct EFLLeafEntry_s *leafEntry, + EFLEpochMask_t activeEpochs, + EFLEpochMask_t *notFoundEpochs, + BOOL includeMetaData); STATUS ELOG_ClearALogEntry( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - struct EFLLeafEntry_s *leafEntry, - Blknum_t block, - NINT offset, - EFLEpochMask_t epoch, - struct ZfsXaction_s *xaction, - NINT *operation); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + struct EFLLeafEntry_s *leafEntry, + Blknum_t block, + NINT offset, + EFLEpochMask_t epoch, + struct ZfsXaction_s *xaction, + NINT *operation); STATUS ELOG_ClearLogEntries( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - struct EFLLeafEntry_s *leafEntry, - EFLEpochMask_t activeEpochs, - struct ZfsXaction_s *xaction, - BOOL justModifies); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + struct EFLLeafEntry_s *leafEntry, + EFLEpochMask_t activeEpochs, + struct ZfsXaction_s *xaction, + BOOL justModifies); STATUS ELOG_ClearSameNameCreate( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - struct EFLLeafEntry_s *leafEntry, - EFLEpochMask_t epochs, - struct ZfsXaction_s *xaction, - unicode_t *name, - EFLEpochMask_t *changedEpochs); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + struct EFLLeafEntry_s *leafEntry, + EFLEpochMask_t epochs, + struct ZfsXaction_s *xaction, + unicode_t *name, + EFLEpochMask_t *changedEpochs); Buffer_s *ELOG_GetFirstGoodEntry( - struct GeneralMsg_s *genMsg, - struct ZfsEFLTreeBeast_s *eTree, - Blknum_t block, - NINT offset, - Blknum_t *retBlock, - NINT *retOffset); + struct GeneralMsg_s *genMsg, + struct ZfsEFLTreeBeast_s *eTree, + Blknum_t block, + NINT offset, + Blknum_t *retBlock, + NINT *retOffset); Buffer_s *ELOG_GetNextGoodEntry( - struct GeneralMsg_s *genMsg, - struct ZfsEFLTreeBeast_s *eTree, - struct Buffer_s *buffer, - NINT offset, - Blknum_t *retBlock, - NINT *retOffset); + struct GeneralMsg_s *genMsg, + struct ZfsEFLTreeBeast_s *eTree, + struct Buffer_s *buffer, + NINT offset, + Blknum_t *retBlock, + NINT *retOffset); STATUS ELOG_CleanupBlocks( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - BOOL unusedOnly); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + BOOL unusedOnly); #endif diff --git a/src/nwnss/zlss/eflTree.c b/src/nwnss/zlss/eflTree.c index 9fa7d29..9422aa1 100644 --- a/src/nwnss/zlss/eflTree.c +++ b/src/nwnss/zlss/eflTree.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -88,8 +87,8 @@ STATUS EFL_writeTheBeast( ****************************************************************************/ void EFL_DisplayNode ( ZfsEFLTreeBeast_s *treeBeast, - char *location, - char *nameOfBuffer, + char *location, + char *nameOfBuffer, EFLTreeNode_s *node, Blknum_t block) @@ -219,12 +218,12 @@ void EFL_DisplaySubtree( COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); if (EFL_IS_LEAF(node)) { - EFL_DisplayNode(treeBeast, MSGNot("Full Tree"), MSGNot("LEAF"), node, + EFL_DisplayNode(treeBeast, MSGNot("Full Tree"), MSGNot("LEAF"), node, buffer->volBlk); } else { - EFL_DisplayNode(treeBeast, MSGNot("Full Tree"), MSGNot("BRANCH"), node, + EFL_DisplayNode(treeBeast, MSGNot("Full Tree"), MSGNot("BRANCH"), node, buffer->volBlk); if ( node->magic == EFL_BRANCH_MAGIC ) { @@ -277,7 +276,7 @@ void EFL_DoDisplayEFLTree( buffer = ZFS_ReadPoolBlk( &genMsg, &iomsg); zASSERT(buffer != NULL); EFL_DisplaySubtree(eTree, buffer); - EFL_Printf(LMAGENTA, MSGNot("\nTotal branches = %d\n"), + EFL_Printf(LMAGENTA, MSGNot("\nTotal branches = %d\n"), EFL_TotalBranches); EFL_Printf(LMAGENTA, MSGNot("Total leafs = %d\n"), EFL_TotalLeafs); @@ -333,10 +332,10 @@ BOOL EFL_ValidateNode (EFLTreeNode_s *node) EFLLeafEntry_s *curr; EFLLeafEntry_s *prev; - zASSERT(node->magic == EFL_LEAF_MAGIC || node->magic == + zASSERT(node->magic == EFL_LEAF_MAGIC || node->magic == (EFL_LEAF_MAGIC | 0x20)); - if ((node->magic != EFL_LEAF_MAGIC) && + if ((node->magic != EFL_LEAF_MAGIC) && (node->magic != (EFL_LEAF_MAGIC))) { return FALSE; @@ -355,7 +354,7 @@ BOOL EFL_ValidateNode (EFLTreeNode_s *node) curr = &node->ELEAF(count); // zASSERT(curr->usedAmount <= curr->restrictionAmount); - + /* check if ascending */ zASSERT(prev->zid < curr->zid); if(prev->zid >= curr->zid) @@ -389,7 +388,7 @@ BOOL EFL_ValidateNode (EFLTreeNode_s *node) for(count = 1; count < node->numRecs; count++) { curr = &node->EBRANCH(count); - + /* check if ascending */ zASSERT(prev->zid < curr->zid); if(prev->zid >= curr->zid) @@ -432,7 +431,7 @@ void EFL_noCompare ( #endif /**************************************************************************** - * EFL beast constructor + * EFL beast constructor *****************************************************************************/ STATUS EFL_construct( GeneralMsg_s *genMsg, @@ -457,27 +456,27 @@ STATUS createEFLEpoch( ZfsEFLTreeBeast_s *eTree = ((ZfsVolume_s *)volume)->eflTree; NINT bit, index; STATUS status; - - for (bit = 1, index = 0; bit != 0; bit <<= 1, index++) + + for (bit = 1, index = 0; bit != 0; bit <<= 1, index++) { - if (!(bit & eTree->p.usedEpochs)) + if (!(bit & eTree->p.usedEpochs)) { LB_GUIDGenerate((GUID_t *)epoch); - + eTree->p.usedEpochs |= bit; eTree->p.activeEpochs |= bit; eTree->p.epochs[index].epoch = *epoch; eTree->p.epochs[index].lastAlive = GetUTCTime(); - + status = EFL_writeTheBeast(genMsg, volume, eTree); zASSERT(status == zOK); - + return status; } } - + SetErrno(genMsg, zERR_EFL_NO_EPOCH_AVAILABLE); - return zFAILURE; + return zFAILURE; } @@ -488,15 +487,15 @@ BOOL findEpochIndex( ZfsEFLTreeBeast_s *eTree, GUID_t *epoch, NINT *index) -{ +{ NINT i; - + if (!LB_GUIDValidate(epoch)) { return FALSE; } - - for (i = 0; i < MAX_ZFS_EFL_EPOCHS; i++) + + for (i = 0; i < MAX_ZFS_EFL_EPOCHS; i++) { if (!LB_GUIDCompare(epoch, &eTree->p.epochs[i].epoch)) { @@ -504,8 +503,8 @@ BOOL findEpochIndex( *index = i; return TRUE; } - } - + } + return FALSE; } @@ -515,15 +514,15 @@ BOOL findEpochIndex( EFLEpochMask_t getEFLEpochMask( ZfsEFLTreeBeast_s *eTree, GUID_t *epoch) -{ +{ NINT index; - - if (findEpochIndex(eTree, epoch, &index)) + + if (findEpochIndex(eTree, epoch, &index)) { return 1 << index; - } + } return 0; -} +} /**************************************************************************** * @@ -535,7 +534,7 @@ STATUS pingEpoch( { ZfsEFLTreeBeast_s *eTree = ((ZfsVolume_s *)volume)->eflTree; NINT index; - + if (findEpochIndex(eTree, epoch, &index)) { eTree->p.epochs[index].lastAlive = GetUTCTime(); @@ -563,7 +562,7 @@ ZfsEFLTreeBeast_s *EFL_createEFL( zASSERT(zfsVol->ZLSSVOLEFL == NULL); ASSERT_XLATCH(&zfsVol->ZFSVOLbeastLatch); - + /* Make sure the EFL isn't already there */ eTree = ZFSVOL_VOL_GetBeastFromVolume( genMsg, ZFSVOL_EFL_ZID, &zfsVol->ZFSVOLvol); @@ -576,20 +575,20 @@ ZfsEFLTreeBeast_s *EFL_createEFL( errPrintf(WHERE, Module, 1460, MSG("Error creating EFL (ZID %d), status=%d", 581), ZFSVOL_EFL_ZID, GetErrno(genMsg)); - return NULL; + return NULL; } X_LATCH(&eTree->ZFSEFLTREEbeastLatch); eTree->ZFSEFLTREEzid = ZFSVOL_EFL_ZID; eTree->ZFSEFLTREEfirstParentZID = zINVALID_ZID; - eTree->ZFSEFLTREEbstState |= BST_STATE_NEW; - + eTree->ZFSEFLTREEbstState |= BST_STATE_NEW; + eTree->p.nameSpace = EFL_DEFAULT_NAMESPACE; /* set default epoch inactive interval to 2 weeks, in terms of seconds */ - eTree->p.inactiveInterval = EFL_defaultEpochInterval; - - + eTree->p.inactiveInterval = EFL_defaultEpochInterval; + + xaction = BeginXLocal(&zfsVol->ZFSVOLvol, BXL_DEFAULT); COMN_MARK_BEAST_XLOCAL(&eTree->ZFSEFLTREEroot, &xaction->xaction); COMN_ForceBeastWrite(genMsg, eTree, &xaction->xaction); @@ -602,16 +601,16 @@ ZfsEFLTreeBeast_s *EFL_createEFL( zASSERT(eTree->ZFSEFLTREEroot.useCount != 0); } DQ_RMV(&eTree->ZFSEFLTREEroot, volLink); - zfsVol->ZLSSVOLEFL = eTree; + zfsVol->ZLSSVOLEFL = eTree; UNX_LATCH(&eTree->ZFSEFLTREEbeastLatch); //#ifndef __linux__ // LINUX_Upgrade /* upgrade the pool */ if (ZFSPOOL_AIPU4085_4086_4087_4088To4300(genMsg, ZLSS_VOLUME_TO_ZLSS_POOL(zfsVol)) != zOK) - { + { zfsVol->ZLSSVOLEFL = NULL; - eTree->ZFSEFLTREEbstState |= BST_STATE_PURGING; + eTree->ZFSEFLTREEbstState |= BST_STATE_PURGING; BST_releaseAndFree(eTree); return NULL; @@ -628,21 +627,21 @@ ZfsEFLTreeBeast_s *EFL_createEFL( * ****************************************************************************/ ZfsEFLTreeBeast_s *EFL_getEFL( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, ZfsVolume_s *zfsVol) { ZfsEFLTreeBeast_s *eTree; - + X_LATCH(&zfsVol->ZFSVOLbeastLatch); - + eTree = zfsVol->eflTree; if (!eTree) { eTree = EFL_createEFL(genMsg, zfsVol); } - + UNX_LATCH(&zfsVol->ZFSVOLbeastLatch); - + return eTree; } @@ -694,12 +693,12 @@ Blknum_t EFL_findChildBlock( SNINT high = node->numRecs-1; Zid_t zidFromMid = 0; - while (low <= high) + while (low <= high) { mid = (low + high) / 2; zidFromMid = node->EBRANCH(mid).zid; if (zid == zidFromMid) - { + { break; } else if (zid > zidFromMid) @@ -741,7 +740,7 @@ BOOL EFL_findLeafEntry( Zid_t zidFromMid = (Zid_t)-1; BOOL foundFlag = FALSE; - while (low <= high) + while (low <= high) { mid = (low + high) / 2; zidFromMid = node->ELEAF(mid).zid; @@ -773,8 +772,8 @@ BOOL EFL_findLeafEntry( * ****************************************************************************/ void EFL_initNode( - Buffer_s *buffer, - NINT state, + Buffer_s *buffer, + NINT state, GUID_t *internalID) { EFLTreeNode_s *node = (EFLTreeNode_s *)buffer->pBuf.data; @@ -813,9 +812,9 @@ void EFL_insertZeroNode( EFL_VALIDATE_NODE(node); /* - * We always want a zero in the first location to establish a lower bound - * so we do not need a lot of special case code. - */ + * We always want a zero in the first location to establish a lower bound + * so we do not need a lot of special case code. + */ node->numRecs = 1; memset(&node->ELEAF(0), 0, sizeof(EFLLeafEntry_s)); node->ELEAF(0).firstLogEntry.blockNum = INVALID_BLK_ZERO; @@ -896,8 +895,8 @@ STATUS EFL_join( /* update the leaf link */ child->n.leaf.nextLeaf = sibling->n.leaf.nextLeaf; /* Change magic in Deleted Leaf Node to indicate it is deleted. This - * is being done for scan mode of rebuild. - */ + * is being done for scan mode of rebuild. + */ sibling->magic |= 0x20; /* Lower case low byte letter */ } else @@ -917,8 +916,8 @@ STATUS EFL_join( parentIndex = parms->index + 1; entryInParent = parent->EBRANCH(parentIndex).zid; memmove( &parent->EBRANCH(parentIndex), /* Destination */ - &parent->EBRANCH(parentIndex + 1), /* Source */ - (parent->numRecs - parentIndex) * sizeof(EFLBranchEntry_s)); + &parent->EBRANCH(parentIndex + 1), /* Source */ + (parent->numRecs - parentIndex) * sizeof(EFLBranchEntry_s)); localXaction = BeginXLocal(parms->volume, BXL_DEFAULT); @@ -961,14 +960,14 @@ STATUS EFL_join( ZLOG_BIND(localXaction, parms->parent); if (EFL_IS_LEAF(child) ) { /* This is the deleted LEAF block we must write so that rebuild - * can scan whole disk and not find OLD beast tree leafs. - */ + * can scan whole disk and not find OLD beast tree leafs. + */ parms->sibling->state |= CACHE_DIRTY; ZLOG_BIND(localXaction, parms->sibling); #if 0 /* This code allows for testing of the recovery code of setting - * the magic word on deletes. - */ + * the magic word on deletes. + */ #if NSS_ASSERT IS_ENABLED { extern LONG gZlogAssertBlock; @@ -1025,14 +1024,14 @@ STATUS EFL_balance ( avg = (child->numRecs + sibling->numRecs) / 2; - /* Don't do balancing if no records can be moved */ + /* Don't do balancing if no records can be moved */ if (child->numRecs == avg || (sibling->numRecs == avg)) { /* - * The entry we were looking for when we started the balance my be - * in either the child or the sibling entry. Make sure that it - * ends up in the child. - */ + * The entry we were looking for when we started the balance my be + * in either the child or the sibling entry. Make sure that it + * ends up in the child. + */ if (parms->zid >= parent->EBRANCH(parms->index + 1).zid) { CACHE_RELEASE(parms->child); @@ -1040,7 +1039,7 @@ STATUS EFL_balance ( } else { - CACHE_RELEASE(parms->sibling); + CACHE_RELEASE(parms->sibling); } return zOK; } @@ -1063,8 +1062,8 @@ STATUS EFL_balance ( /* move the entries from sibling to child */ memcpy(startLocation, /* Destination */ - &sibling->ELEAF(0), /* Source */ - lenMoved); + &sibling->ELEAF(0), /* Source */ + lenMoved); /* move sibling entries back to the front of the record */ memmove(&sibling->ELEAF(0), /* Destination */ @@ -1090,8 +1089,8 @@ STATUS EFL_balance ( /* move the entries from the child to the sibling */ memcpy(startLocation, - &child->ELEAF(child->numRecs - numToMove), - lenMoved); + &child->ELEAF(child->numRecs - numToMove), + lenMoved); child->numRecs -= numToMove; sibling->numRecs += numToMove; @@ -1108,8 +1107,8 @@ STATUS EFL_balance ( /* move the entries from sibling to child */ memcpy(startLocation, /* Destination */ - &sibling->EBRANCH(0), /* Source */ - lenMoved); + &sibling->EBRANCH(0), /* Source */ + lenMoved); /* move sibling entries back to the front of the record */ memmove(&sibling->EBRANCH(0), /* Destination */ @@ -1135,8 +1134,8 @@ STATUS EFL_balance ( /* move the entries from the child to the sibling */ memcpy(startLocation, - &child->EBRANCH(child->numRecs - numToMove), - lenMoved); + &child->EBRANCH(child->numRecs - numToMove), + lenMoved); child->numRecs -= numToMove; sibling->numRecs += numToMove; @@ -1254,7 +1253,7 @@ STATUS EFL_underflow ( parms->sibling = EFL_ReadPoolBlk(genMsg, &iomsg); if (parms->sibling == NULL) { - return zFAILURE; + return zFAILURE; } EFL_VALIDATE_NODE((EFLTreeNode_s *)parms->sibling->pBuf.data); } @@ -1265,9 +1264,9 @@ STATUS EFL_underflow ( READBLK_IO_MSG(iomsg, eflTreeBeast, parms->readBlkNum, CACHE_UPDATE); SET_DEBUG_ID(iomsg, 2); /* - * Release the latch so we do not latch out of order -- This is - * OK because the parent latch is held. - */ + * Release the latch so we do not latch out of order -- This is + * OK because the parent latch is held. + */ CACHE_PIN(parms->sibling); CACHE_UNXLATCH(parms->sibling); parms->child = EFL_ReadPoolBlk(genMsg, &iomsg); @@ -1513,9 +1512,9 @@ STATUS EFL_split ( parms->readBlkNum = parms->child->volBlk; /* - * Sibling is the node to be split. It is the left node in the split. - * Child is the new node. - */ + * Sibling is the node to be split. It is the left node in the split. + * Child is the new node. + */ child = (EFLTreeNode_s *)parms->child->pBuf.data; holdState = sibling->state & EFL_LEAF; @@ -1556,8 +1555,8 @@ STATUS EFL_split ( } /* - * Make room in the parent to place the node - */ + * Make room in the parent to place the node + */ i = parms->index + 1; memmove(&parent->EBRANCH(i + 1), /* Destination */ &parent->EBRANCH(i), /* Source */ @@ -1860,7 +1859,7 @@ STATUS EFL_findLeaf( } /* go down another level */ parms->parent = parms->child; - parms->readBlkNum = + parms->readBlkNum = EFL_findChildBlock((EFLTreeNode_s *)parms->parent->pBuf.data, parms->zid, &parms->index); READBLK_IO_MSG(iomsg, eTree, parms->readBlkNum, CACHE_UPDATE); @@ -1885,14 +1884,14 @@ STATUS EFL_findLeaf( * ****************************************************************************/ /**************************************************************************** - * Put a modify leaf entry log record into the log. This is the contents + * Put a modify leaf entry log record into the log. This is the contents * before the entry is deleted. * * Input: Child record is Latched * * Output: Child record is Latched ****************************************************************************/ -void EFL_logModifyRecord( +void EFL_logModifyRecord( EFLTreeParms_s *parms, EFLLeafEntry_s *leafEntry, EFLLeafEntry_s *oldEntry) @@ -1905,7 +1904,7 @@ void EFL_logModifyRecord( ASSERT_MPKNSS_LOCK(); EFL_VALIDATE_NODE((EFLTreeNode_s *)parms->child->pBuf.data); - ZLOG_ObtainRecord(parms->xaction, ZLOG_BLOCK_INFO_SIZE(1) + + ZLOG_ObtainRecord(parms->xaction, ZLOG_BLOCK_INFO_SIZE(1) + sizeof(EFLModify_s)); ZLOG_INIT_LOG_RECORD(XFUNC_EFLTREE_L_MODIFY, parms->xaction, logBuffer, 1, @@ -1933,7 +1932,7 @@ void EFL_logModifyRecord( * * Input: Child and parent are latched. Child is buffer to modified. * - * Output: Parent and child are unlatched. + * Output: Parent and child are unlatched. ****************************************************************************/ STATUS EFL_doModifyEntry( GeneralMsg_s *genMsg, @@ -1947,10 +1946,10 @@ STATUS EFL_doModifyEntry( ASSERT_MPKNSS_LOCK(); EFL_VALIDATE_NODE((EFLTreeNode_s *)parms->child->pBuf.data); /* - * Change the leaf entry contents in the node. - * - * NOTE: the parent is still latched when we come into this routine. - */ + * Change the leaf entry contents in the node. + * + * NOTE: the parent is still latched when we come into this routine. + */ if (EFL_IS_ROOT(child)) { EFL_UNX_LATCH_TREE(parms); @@ -1997,11 +1996,11 @@ STATUS EFL_insertEntry( ASSERT_MPKNSS_LOCK(); /* - * This routine assumes a check has ready been done to make sure there - * there is enough free space in the buffer to hold the new eNode. - */ + * This routine assumes a check has ready been done to make sure there + * there is enough free space in the buffer to hold the new eNode. + */ - /* Add the eNode to the leaf node */ + /* Add the eNode to the leaf node */ if (EFL_findLeafEntry(child, newEntry->zid, &i)) { zASSERT("Same ZID added twice to EFL b-tree" == NULL); @@ -2040,14 +2039,14 @@ void EFL_logInsertRecord( ASSERT_MPKNSS_LOCK(); EFL_VALIDATE_NODE((EFLTreeNode_s *)parms->child->pBuf.data); - ZLOG_ObtainRecord(parms->xaction, ZLOG_BLOCK_INFO_SIZE(1) + + ZLOG_ObtainRecord(parms->xaction, ZLOG_BLOCK_INFO_SIZE(1) + sizeof(EFLInsert_s)); ZLOG_INIT_LOG_RECORD(XFUNC_EFLTREE_L_INSERT, parms->xaction, logBuffer, 1, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[0], parms->child->volBlk, child->lsn, parms->child, parms->xaction, 0, EFL_compare); - + logRecord->u.insert.internalID = parms->eTree->ZFSEFLTREEroot.ROOTinternalID; logRecord->u.insert.newEntry = *newEntry; @@ -2065,11 +2064,11 @@ void EFL_logInsertRecord( * * Input: Child and parent are latched. Child is buffer to inserted into. * - * Output: Parent and child are unlatched. + * Output: Parent and child are unlatched. ****************************************************************************/ STATUS EFL_doInsertEntry( GeneralMsg_s *genMsg, - EFLTreeParms_s *parms, + EFLTreeParms_s *parms, EFLLeafEntry_s *newEntry) { EFLTreeNode_s *child; @@ -2078,8 +2077,8 @@ STATUS EFL_doInsertEntry( EFL_VALIDATE_NODE((EFLTreeNode_s *)parms->child->pBuf.data); /* - * Insert the new entry into the tree - */ + * Insert the new entry into the tree + */ if (EFL_checkForSplit(genMsg, parms) != zOK) { return(zFAILURE); @@ -2109,7 +2108,7 @@ STATUS EFL_doInsertEntry( //rks * //rks * Check to see if we need to add a log record for this action. If we are //rks * modifying data that has already been modified or created in this epoch -//rks * we do not need to send the log record. +//rks * we do not need to send the log record. //rks * //rks ****************************************************************************/ //rksSTATUS EFL_ProcessLogEntry( @@ -2129,19 +2128,19 @@ STATUS EFL_doInsertEntry( //rks { //rks case ELOG_OP_CLEAR: //rks { -//rks status = ELOG_ClearLogEntries(genMsg, volume, leafEntry, +//rks status = ELOG_ClearLogEntries(genMsg, volume, leafEntry, //rks activeEpochs, parms->xaction, FALSE); //rks break; //rks } //rks case ELOG_OP_CREATE: //rks { -//rks status = ELOG_AddLogEntry(genMsg, parms->xaction, leafEntry, +//rks status = ELOG_AddLogEntry(genMsg, parms->xaction, leafEntry, //rks ELOG_CREATE, activeEpochs, volume, zid, name); //rks break; //rks } //rks case ELOG_OP_DELETE: //rks { -//rks status = ELOG_AddLogEntry(genMsg, parms->xaction, leafEntry, +//rks status = ELOG_AddLogEntry(genMsg, parms->xaction, leafEntry, //rks ELOG_DELETE, parms->epochMask, volume, zid, name); //rks break; //rks } @@ -2155,7 +2154,7 @@ STATUS EFL_doInsertEntry( //rks //rks if (notFoundEpochs) //rks { -//rks status = ELOG_AddLogEntry(genMsg, parms->xaction, leafEntry, +//rks status = ELOG_AddLogEntry(genMsg, parms->xaction, leafEntry, //rks ELOG_MODIFY, notFoundEpochs, volume, zid, name); //rks } //rks break; @@ -2169,20 +2168,20 @@ STATUS EFL_doInsertEntry( //rks //rks if (notFoundEpochs) //rks { -//rks status = ELOG_AddLogEntry(genMsg, parms->xaction, leafEntry, +//rks status = ELOG_AddLogEntry(genMsg, parms->xaction, leafEntry, //rks ELOG_MODIFY_META_DATA, notFoundEpochs, volume, zid, name); //rks } //rks break; //rks //rks case ELOG_OP_RENAME: //rks { -//rks status = ELOG_AddLogEntry(genMsg, parms->xaction, leafEntry, +//rks status = ELOG_AddLogEntry(genMsg, parms->xaction, leafEntry, //rks ELOG_RENAME, activeEpochs, volume, zid, name); //rks } //rks case ELOG_OP_UNDELETE: //rks case ELOG_OP_CLEAR_MODIFIES: //rks { -//rks status = ELOG_ClearLogEntries(genMsg, volume, leafEntry, +//rks status = ELOG_ClearLogEntries(genMsg, volume, leafEntry, //rks activeEpochs, parms->xaction, TRUE); //rks break; //rks } @@ -2195,7 +2194,7 @@ STATUS EFL_doInsertEntry( //rksexit: //rks return status; //rks} - + /**************************************************************************** * This function is called during error recovery to get things release and * unlatched as is needed. @@ -2210,8 +2209,8 @@ void EFL_releaseStuff( EFLTreeNode_s *child = (EFLTreeNode_s *)parms->child->pBuf.data; /* - * NOTE: the parent is still latched when we come into this routine. - */ + * NOTE: the parent is still latched when we come into this routine. + */ if (EFL_IS_ROOT(child)) { EFL_UNX_LATCH_TREE(parms); @@ -2240,7 +2239,7 @@ STATUS ZFSVOL_VOL_insertEFLEntry( GeneralMsg_s *genMsg, File_s *beast, NINT action, - unicode_t *name, + unicode_t *name, Xaction_s *xaction) { Volume_s *volume = beast->FILEvolume; @@ -2278,7 +2277,7 @@ STATUS ZFSVOL_VOL_insertEFLEntry( } memset(&aStack->leafEntry, 0, sizeof(EFLLeafEntry_s)); - + activeEpochs = eTree->p.activeEpochs; aStack->parms.xaction = (ZfsXaction_s *)xaction; aStack->parms.zid = zid; @@ -2313,8 +2312,8 @@ STATUS ZFSVOL_VOL_insertEFLEntry( } /* - * Get an exclusive latch on eTree - */ + * Get an exclusive latch on eTree + */ EFL_X_LATCH_TREE(&aStack->parms); if (eTree->zfsBtree.p.btRoot == INVALID_BLK_ZERO) @@ -2334,31 +2333,31 @@ STATUS ZFSVOL_VOL_insertEFLEntry( EFL_initNode(aStack->parms.child, EFL_ROOT|EFL_LEAF, &eTree->ZFSEFLTREEroot.ROOTinternalID); EFL_insertZeroNode((EFLTreeNode_s *)aStack->parms.child->pBuf.data); - logHeaderBuffer = ELOG_AllocateHeaderNode(genMsg, volume, + logHeaderBuffer = ELOG_AllocateHeaderNode(genMsg, volume, localXaction); if (logHeaderBuffer == NULL) { // FixFixFix should release parms.child to avoid losing a block goto errorEndXaction; } - - headerNode = (ELogNode_s *)logHeaderBuffer->pBuf.data; + + headerNode = (ELogNode_s *)logHeaderBuffer->pBuf.data; eTree->p.logHeaderBlock = logHeaderBuffer->volBlk; eTree->zfsBtree.p.btRoot = aStack->parms.child->volBlk; - COMN_MARK_BEAST_XLOCAL(&eTree->ZFSEFLTREEroot, - &localXaction->xaction); + COMN_MARK_BEAST_XLOCAL(&eTree->ZFSEFLTREEroot, + &localXaction->xaction); if (COMN_ForceBeastWrite(genMsg, &eTree->ZFSEFLTREEroot, - &localXaction->xaction) != zOK) - { + &localXaction->xaction) != zOK) + { CACHE_DIRTY_RELEASE(logHeaderBuffer); goto errorEndXaction; - } + } /* log the init record */ ZLOG_ObtainRecord(localXaction, - ZLOG_BLOCK_INFO_SIZE(2) + sizeof(EFLTreeInit_s) ); + ZLOG_BLOCK_INFO_SIZE(2) + sizeof(EFLTreeInit_s) ); ZLOG_INIT_LOG_RECORD(XFUNC_EFLTREE_INIT, localXaction, logBuffer, 2, poolBlks, logRecord); @@ -2366,8 +2365,8 @@ STATUS ZFSVOL_VOL_insertEFLEntry( node->lsn, aStack->parms.child, localXaction, 0); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], logHeaderBuffer->volBlk, headerNode->lsn, logHeaderBuffer, localXaction, 1); - ZLOG_ALLOC_BLOCK(poolBlks[0]); - ZLOG_ALLOC_BLOCK(poolBlks[1]); + ZLOG_ALLOC_BLOCK(poolBlks[0]); + ZLOG_ALLOC_BLOCK(poolBlks[1]); node->lsn = logBuffer->ZXR_Lsn; headerNode->lsn = logBuffer->ZXR_Lsn; logRecord->u.init.internalID = eTree->ZFSEFLTREEroot.ROOTinternalID; @@ -2375,7 +2374,7 @@ STATUS ZFSVOL_VOL_insertEFLEntry( ZLOG_BIND(localXaction, aStack->parms.child); ZLOG_ReleaseRecordAndLogEnd(localXaction); EndXlocal(localXaction); - + CACHE_DIRTY_RELEASE(logHeaderBuffer); } else @@ -2407,10 +2406,10 @@ STATUS ZFSVOL_VOL_insertEFLEntry( case EFL_FILE_STATE_DELETE_FILE: { /* - * If there are epochs where the delete and the create are - * both in the same epoch then remove the create. Always - * remove all of the modify records for the active epochs. - */ + * If there are epochs where the delete and the create are + * both in the same epoch then remove the create. Always + * remove all of the modify records for the active epochs. + */ EFLLeafEntry_s localEntry = *currentEntry; EFLEpochMask_t createActive; EFLEpochMask_t deleteActive; @@ -2428,7 +2427,7 @@ STATUS ZFSVOL_VOL_insertEFLEntry( localEntry.deleteEpochs |= ~createActive & activeEpochs; /* Figure out which epochs need delete log records created */ - deleteEpochs = deleteActive ^ + deleteEpochs = deleteActive ^ (localEntry.deleteEpochs & activeEpochs); /* clear all other masks */ @@ -2444,7 +2443,7 @@ STATUS ZFSVOL_VOL_insertEFLEntry( /* Add in log records for deletes that need to be done */ if (deleteEpochs) { - if (ELOG_AddLogEntry(genMsg, aStack->parms.xaction, &localEntry, + if (ELOG_AddLogEntry(genMsg, aStack->parms.xaction, &localEntry, ELOG_DELETE, deleteEpochs, volume, zid, name) != zOK) { status = zFAILURE; @@ -2454,10 +2453,10 @@ STATUS ZFSVOL_VOL_insertEFLEntry( *currentEntry = localEntry; /* - * Remove log entries that are no longer needed. If the - * deleted and creation are in the same epoch then we should - * get rid of renames. - */ + * Remove log entries that are no longer needed. If the + * deleted and creation are in the same epoch then we should + * get rid of renames. + */ if (deleteCreateEpochs == activeEpochs) { typesToClear |= ELOG_CLEAR_RENAME; @@ -2466,13 +2465,13 @@ STATUS ZFSVOL_VOL_insertEFLEntry( { if (deleteCreateEpochs) { - ELOG_ClearLogEntries(genMsg, volume, currentEntry, + ELOG_ClearLogEntries(genMsg, volume, currentEntry, deleteCreateEpochs, aStack->parms.xaction, ELOG_CLEAR_RENAME); - } + } } - ELOG_ClearLogEntries(genMsg, volume, currentEntry, - activeEpochs, aStack->parms.xaction, typesToClear); + ELOG_ClearLogEntries(genMsg, volume, currentEntry, + activeEpochs, aStack->parms.xaction, typesToClear); break; } @@ -2485,7 +2484,7 @@ STATUS ZFSVOL_VOL_insertEFLEntry( EFLEpochMask_t notFoundEpochsComputed; #endif - modifyActive = ((currentEntry->modifyEpochs | + modifyActive = ((currentEntry->modifyEpochs | currentEntry->createEpochs)) & activeEpochs; notFoundEpochs = modifyActive ^ activeEpochs; #if NSS_DEBUG IS_ENABLED @@ -2497,7 +2496,7 @@ STATUS ZFSVOL_VOL_insertEFLEntry( { localEntry = *currentEntry; localEntry.modifyEpochs |= notFoundEpochs; - if (ELOG_AddLogEntry(genMsg, aStack->parms.xaction, &localEntry, + if (ELOG_AddLogEntry(genMsg, aStack->parms.xaction, &localEntry, ELOG_MODIFY, notFoundEpochs, volume, zid, name) != zOK) { status = zFAILURE; @@ -2515,7 +2514,7 @@ STATUS ZFSVOL_VOL_insertEFLEntry( #if NSS_DEBUG IS_ENABLED EFLEpochMask_t notFoundEpochsComputed; #endif - metadataActive = ((currentEntry->modifyEpochs | + metadataActive = ((currentEntry->modifyEpochs | currentEntry->metaDataEpochs | currentEntry->createEpochs)) & activeEpochs; notFoundEpochs = metadataActive ^ activeEpochs; @@ -2528,8 +2527,8 @@ STATUS ZFSVOL_VOL_insertEFLEntry( { localEntry = *currentEntry; localEntry.metaDataEpochs |= notFoundEpochs; - if (ELOG_AddLogEntry(genMsg, aStack->parms.xaction, &localEntry, - ELOG_MODIFY_META_DATA, notFoundEpochs, volume, zid, + if (ELOG_AddLogEntry(genMsg, aStack->parms.xaction, &localEntry, + ELOG_MODIFY_META_DATA, notFoundEpochs, volume, zid, name) != zOK) { status = zFAILURE; @@ -2553,7 +2552,7 @@ STATUS ZFSVOL_VOL_insertEFLEntry( { if (changedEpochs) { - ELOG_AddLogEntry(genMsg, aStack->parms.xaction, currentEntry, + ELOG_AddLogEntry(genMsg, aStack->parms.xaction, currentEntry, ELOG_CREATE, changedEpochs, volume, zid, NULL); renameEpochs = activeEpochs ^ changedEpochs; } @@ -2561,34 +2560,34 @@ STATUS ZFSVOL_VOL_insertEFLEntry( } if (renameEpochs) { - ELOG_AddLogEntry(genMsg, aStack->parms.xaction, currentEntry, + ELOG_AddLogEntry(genMsg, aStack->parms.xaction, currentEntry, ELOG_RENAME, renameEpochs, volume, zid, name); } break; } case EFL_FILE_STATE_UNDELETE: - { + { EFLLeafEntry_s localEntry = *currentEntry; EFLEpochMask_t changedEpochs; zASSERT(!(localEntry.createEpochs & activeEpochs)); - changedEpochs = (localEntry.deleteEpochs ^ activeEpochs) & + changedEpochs = (localEntry.deleteEpochs ^ activeEpochs) & activeEpochs; localEntry.createEpochs |= changedEpochs; localEntry.deleteEpochs &= ~changedEpochs; - if (ELOG_AddLogEntry(genMsg, aStack->parms.xaction, &localEntry, + if (ELOG_AddLogEntry(genMsg, aStack->parms.xaction, &localEntry, ELOG_CREATE, changedEpochs, volume, zid, name) != zOK) { status = zFAILURE; break; } *currentEntry = localEntry; - ELOG_ClearLogEntries(genMsg, volume, currentEntry, - changedEpochs, aStack->parms.xaction, ELOG_CLEAR_DELETE); + ELOG_ClearLogEntries(genMsg, volume, currentEntry, + changedEpochs, aStack->parms.xaction, ELOG_CLEAR_DELETE); break; } } - + if (status == zOK) { if (EFL_doModifyEntry(genMsg, &aStack->parms, index, &aStack->leafEntry) != zOK) @@ -2600,7 +2599,7 @@ STATUS ZFSVOL_VOL_insertEFLEntry( { if (EFLDisplay) { - aprintf(LRED, "(EFL) Insert. Error %d during leaf modify\n", + aprintf(LRED, "(EFL) Insert. Error %d during leaf modify\n", GetErrno(genMsg)); } @@ -2622,7 +2621,7 @@ STATUS ZFSVOL_VOL_insertEFLEntry( if (directory) { aStack->leafEntry.objectType = ELF_TYPE_DIRECTORY; - } + } else if (dataStream) { aStack->leafEntry.objectType = ELF_TYPE_DATASTREAM; @@ -2633,7 +2632,7 @@ STATUS ZFSVOL_VOL_insertEFLEntry( } else { - aStack->leafEntry.objectType = ELF_TYPE_FILE; + aStack->leafEntry.objectType = ELF_TYPE_FILE; } switch (aStack->parms.action) @@ -2688,12 +2687,12 @@ STATUS ZFSVOL_VOL_insertEFLEntry( aStack->leafEntry.lastLogEntry.resBlk = INVALID_BLK_ZERO; aStack->leafEntry.lastLogEntry.offset = 0; - if (ELOG_AddLogEntry(genMsg, aStack->parms.xaction, &aStack->leafEntry, logOp, + if (ELOG_AddLogEntry(genMsg, aStack->parms.xaction, &aStack->leafEntry, logOp, activeEpochs, volume, zid, name) != zOK) { if (EFLDisplay) { - aprintf(LRED, "(EFL) Insert. Error %d adding log entry during leaf create\n", + aprintf(LRED, "(EFL) Insert. Error %d adding log entry during leaf create\n", GetErrno(genMsg)); } @@ -2717,7 +2716,7 @@ errorEndXaction: EFL_UNX_LATCH_TREE(&aStack->parms); STACK_FREE(); return(zFAILURE); - + error: STACK_FREE(); return(zFAILURE); @@ -2737,7 +2736,7 @@ void EFL_deleteEntry( { ASSERT_MPKNSS_LOCK(); EFL_VALIDATE_NODE(child); - + child->numRecs--; if (index < child->numRecs) { @@ -2756,7 +2755,7 @@ void EFL_deleteEntry( * * Output: Child record is Latched ****************************************************************************/ -void EFL_logDeleteRecord( +void EFL_logDeleteRecord( EFLTreeParms_s *parms, EFLLeafEntry_s *entry) { @@ -2837,7 +2836,7 @@ zASSERT(parms->index != -1); errorExit: //zASSERT(0); CACHE_DIRTY_RELEASE(parms->child); - return(zFAILURE); + return(zFAILURE); } /**************************************************************************** @@ -2875,8 +2874,8 @@ STATUS ZFSVOL_VOL_deleteEFLEntry( } /* - * Return with an error if we have a bad ZID - */ + * Return with an error if we have a bad ZID + */ if (zid == 0) { zASSERT("Attempting to remove the zero ZID from the eflTree" == NULL); @@ -2891,8 +2890,8 @@ STATUS ZFSVOL_VOL_deleteEFLEntry( } /* - * Get an exclusive latch on eTree - */ + * Get an exclusive latch on eTree + */ parms.xaction = (ZfsXaction_s *)xaction; parms.volume = volume; @@ -2922,15 +2921,15 @@ STATUS ZFSVOL_VOL_deleteEFLEntry( oldEntry = *currentEntry; epochMask = EFL_GET_EPOCH_MASK(eTree, epoch); - + /* Get the log entry */ if (block == INVALID_BLK_ZERO) { - if (ELOG_ClearLogEntries(genMsg, volume, currentEntry, + if (ELOG_ClearLogEntries(genMsg, volume, currentEntry, epochMask, parms.xaction, ELOG_CLEAR_ALL) != zOK) { - EFL_releaseStuff(&parms); + EFL_releaseStuff(&parms); return zFAILURE; } @@ -2956,10 +2955,10 @@ STATUS ZFSVOL_VOL_deleteEFLEntry( } else { - if (ELOG_ClearALogEntry(genMsg, volume, currentEntry, block, offset, + if (ELOG_ClearALogEntry(genMsg, volume, currentEntry, block, offset, epochMask, parms.xaction, &operation) != zOK) { - EFL_releaseStuff(&parms); + EFL_releaseStuff(&parms); return zFAILURE; } @@ -2994,7 +2993,7 @@ STATUS ZFSVOL_VOL_deleteEFLEntry( } else { - EFL_releaseStuff(&parms); + EFL_releaseStuff(&parms); return zFAILURE; } @@ -3088,7 +3087,7 @@ STATUS ZFSVOL_VOL_enumerateEFL( *numEntriesReturned = 0; if (!eTree) - { + { nextEntry->done = TRUE; return zOK; } @@ -3100,7 +3099,7 @@ STATUS ZFSVOL_VOL_enumerateEFL( nextEntry->done = TRUE; return zOK; } - + targetEpochMask = EFL_GET_EPOCH_MASK(eTree, targetEpoch); if (nextEntry->firstTime) { @@ -3116,7 +3115,7 @@ STATUS ZFSVOL_VOL_enumerateEFL( return zFAILURE; } node = (ELogNode_s *)headerBuffer->pBuf.data; - buffer = ELOG_GetFirstGoodEntry(genMsg, eTree, node->nextBlock, 0, + buffer = ELOG_GetFirstGoodEntry(genMsg, eTree, node->nextBlock, 0, &block, &offset); CACHE_RELEASE(headerBuffer); } @@ -3146,20 +3145,20 @@ STATUS ZFSVOL_VOL_enumerateEFL( } else if (entry->state & ELOG_ENTRY_STATE_EXTENDED_ATTRIBUTE) { - retEntries[*numEntriesReturned].objectType = + retEntries[*numEntriesReturned].objectType = EFL_EXTENDED_ATTRIBUTE; } else { - retEntries[*numEntriesReturned].objectType = EFL_FILE; + retEntries[*numEntriesReturned].objectType = EFL_FILE; } retEntries[*numEntriesReturned].action = entry->action; - /* - * Get the current name as well as the operation time name - * because it may have changed the requester needs to know - * where to go to get current content. - */ + /* + * Get the current name as well as the operation time name + * because it may have changed the requester needs to know + * where to go to get current content. + */ if (entry->action == ELOG_DELETE) { zASSERT(entry->oldNameIndex == (WORD)(-1)); @@ -3167,14 +3166,14 @@ STATUS ZFSVOL_VOL_enumerateEFL( retEntries[*numEntriesReturned].newName[0] = L'\0'; retEntries[*numEntriesReturned].realName[0] = L'\0'; } - else + else { if (entry->action == ELOG_RENAME) { zASSERT(entry->oldNameIndex != (WORD)(-1) ); unicpy(retEntries[*numEntriesReturned].name, &entry->names[entry->oldNameIndex]); - unicpy(retEntries[*numEntriesReturned].newName, + unicpy(retEntries[*numEntriesReturned].newName, entry->names); } else @@ -3184,8 +3183,8 @@ STATUS ZFSVOL_VOL_enumerateEFL( retEntries[*numEntriesReturned].newName[0] = L'\0'; } - if (EFL_GetNameFromZid(genMsg, volume, entry->zid, - EFL_GET_NAME_SPACE_ID(volume), + if (EFL_GetNameFromZid(genMsg, volume, entry->zid, + EFL_GET_NAME_SPACE_ID(volume), retEntries[*numEntriesReturned].realName, &objectType) != zOK) { retEntries[*numEntriesReturned].realName[0] = L'\0'; @@ -3193,7 +3192,7 @@ STATUS ZFSVOL_VOL_enumerateEFL( } (*numEntriesReturned)++; } - buffer = ELOG_GetNextGoodEntry(genMsg, eTree, buffer, offset, + buffer = ELOG_GetNextGoodEntry(genMsg, eTree, buffer, offset, &block, &offset); } if (buffer != NULL) @@ -3238,7 +3237,7 @@ STATUS EFL_GetEFLEntry( SetErrno(genMsg, zERR_ZID_NOT_FOUND); return zFAILURE; } - + /* read the root node */ READBLK_IO_MSG(iomsg, eTree, eTree->zfsBtree.p.btRoot, CACHE_READ); SET_DEBUG_ID(iomsg, 8); @@ -3300,7 +3299,7 @@ STATUS EFL_enumerateTree( EFLEpochMask_t targetEpochMask; if (!eTree) - { + { *numEntriesReturned = 0; return zOK; } @@ -3319,11 +3318,11 @@ STATUS EFL_enumerateTree( UNS_LATCH(&eTree->ZFSEFLTREEbeastLatch); goto done; } - + /* - * Find the next beast after *lastZidReturned to return. - * For this, we start at the root. - */ + * Find the next beast after *lastZidReturned to return. + * For this, we start at the root. + */ /* read the root node */ READBLK_IO_MSG(iomsg, eTree, eTree->zfsBtree.p.btRoot, CACHE_READ); parms.child = EFL_ReadPoolBlk(genMsg, &iomsg); @@ -3338,7 +3337,7 @@ STATUS EFL_enumerateTree( EFL_VALIDATE_NODE(node); /* descend the tree to the leaf */ - if ((status = EFL_getLeaf(genMsg, *lastZidReturned, (ZfsVolume_s *)volume, + if ((status = EFL_getLeaf(genMsg, *lastZidReturned, (ZfsVolume_s *)volume, &parms)) != zOK) { goto done; @@ -3352,23 +3351,23 @@ STATUS EFL_enumerateTree( } nextIndex++; /* Skip the last matched entry */ - /* - * Return the ZIDs of next numEntriesRequested after (*lastZidReturned) - * by sequentially scanning the EFL tree's leaf nodes - * - * Sequentially scan the linked list of leaf nodes for entries to return - * (starting at the entry at (parms.child, nextind)). - */ + /* + * Return the ZIDs of next numEntriesRequested after (*lastZidReturned) + * by sequentially scanning the EFL tree's leaf nodes + * + * Sequentially scan the linked list of leaf nodes for entries to return + * (starting at the entry at (parms.child, nextind)). + */ targetEpochMask = EFL_GET_EPOCH_MASK(eTree, targetEpoch); for (; entryIndex < numEntriesRequested; ) { /* Skip to a leaf node with entries to process */ - if (nextIndex >= node->numRecs) + if (nextIndex >= node->numRecs) { /* Jump to the next leaf node */ Buffer_s *nextbuf; if (node->n.leaf.nextLeaf == INVALID_BLK_ZERO || - node->n.leaf.nextLeaf == 0) + node->n.leaf.nextLeaf == 0) { break; } @@ -3389,12 +3388,12 @@ STATUS EFL_enumerateTree( currentEntry = &node->ELEAF(nextIndex); /* Add the beast's ZID to the beastZids list */ zids[entryIndex] = currentEntry->zid; - + /* only return if the epoch matches */ epochMask = currentEntry->createEpochs | currentEntry->modifyEpochs | currentEntry->metaDataEpochs | currentEntry->deleteEpochs; - if ((epochMask & eTree->p.usedEpochs) == 0 || + if ((epochMask & eTree->p.usedEpochs) == 0 || epochMask & targetEpochMask) { ++entryIndex; @@ -3431,9 +3430,9 @@ STATUS EFL_writeTheBeast( /* force the beast out */ X_LATCH(&eTree->ZFSEFLTREEbeastLatch); localXaction = BeginXLocal(volume, BXL_DEFAULT); - COMN_MARK_BEAST_XLOCAL(&eTree->ZFSEFLTREEroot, + COMN_MARK_BEAST_XLOCAL(&eTree->ZFSEFLTREEroot, &localXaction->xaction); - status = COMN_ForceBeastWrite(genMsg, + status = COMN_ForceBeastWrite(genMsg, &eTree->ZFSEFLTREEroot, &localXaction->xaction); EndXlocal(localXaction); UNX_LATCH(&eTree->ZFSEFLTREEbeastLatch); @@ -3447,16 +3446,16 @@ STATUS eflRemoveEpoch( GeneralMsg_s *genMsg, Volume_s *volume, EFLEpoch_t *epoch) -{ +{ #define MAX_EFL_ENTRIES_PER_SCOOP 50 - ZfsEFLTreeBeast_s *eTree = ((ZfsVolume_s *)volume)->eflTree; + ZfsEFLTreeBeast_s *eTree = ((ZfsVolume_s *)volume)->eflTree; EFLEpochMask_t epochMask; NINT numEntriesObtained; - Zid_t lastZidReturned; + Zid_t lastZidReturned; Zid_t *zids = NULL; ZfsXaction_s *xaction; - NINT i; - Volume_s *tmpVolume; + NINT i; + Volume_s *tmpVolume; STATUS status = zFAILURE; struct purgeLogInfo_s @@ -3465,8 +3464,8 @@ STATUS eflRemoveEpoch( LONG purgeLogLoc[MAX_PLOG_LOCATION_SIZE]; }; struct purgeLogInfo_s *purgeLogInfo = NULL; - - + + COMN_USE_BEAST(&volume->VOLroot); if (COMN_LockVolumeActive(genMsg, volume, FALSE) != zOK) { @@ -3475,7 +3474,7 @@ STATUS eflRemoveEpoch( if (!findEpochIndex(eTree, epoch, &i)) { - errPrintf(WHERE, Module, 0, + errPrintf(WHERE, Module, 0, MSG("Epoch to be removed was not found", 608)); SetErrno(genMsg, zERR_EFL_EPOCH_NOT_FOUND); goto exitUnlock; @@ -3483,14 +3482,14 @@ STATUS eflRemoveEpoch( epochMask = 1 << i; eTree->p.activeEpochs &= ~epochMask; (void)EFL_writeTheBeast(genMsg, volume, eTree); - + /* allocate memory for return data */ zids = malloc(MAX_EFL_ENTRIES_PER_SCOOP * sizeof(Zid_t)); if (!zids) { errPrintf(WHERE, Module, 0, - MSG("Error allocating memory for remove epoch operation\n", 609)); - SetErrno(genMsg, zERR_NO_MEMORY); + MSG("Error allocating memory for remove epoch operation\n", 609)); + SetErrno(genMsg, zERR_NO_MEMORY); goto exitUnlock; } @@ -3500,22 +3499,22 @@ STATUS eflRemoveEpoch( { errPrintf(WHERE, Module, 0, MSG("Error allocating memory for remove epoch operation\n", 610)); - SetErrno(genMsg, zERR_NO_MEMORY); + SetErrno(genMsg, zERR_NO_MEMORY); goto exitFree; } - SETUP_REMOVE_EFL_EPOCH_LOG(&purgeLogInfo->purgeLogMsg, - (void *)&purgeLogInfo->purgeLogLoc, volume, epoch); + SETUP_REMOVE_EFL_EPOCH_LOG(&purgeLogInfo->purgeLogMsg, + (void *)&purgeLogInfo->purgeLogLoc, volume, epoch); xaction = BeginXLocal(volume, BXL_DEFAULT); - status = volume->VOLcomnVolOps.VOL_addPurgeLogEntry( - genMsg, volume, PLOG_EFL_REMOVE_EPOCH, + status = volume->VOLcomnVolOps.VOL_addPurgeLogEntry( + genMsg, volume, PLOG_EFL_REMOVE_EPOCH, &purgeLogInfo->purgeLogMsg, (Xaction_s *)xaction); EndXlocal(xaction); if (status != zOK) { goto exitFree; } - + lastZidReturned = zINVALID_ZID; for(;;) { @@ -3523,7 +3522,7 @@ STATUS eflRemoveEpoch( { goto exitFree; /* do not remove the purge log entry */ } - if (EFL_enumerateTree(genMsg, volume, + if (EFL_enumerateTree(genMsg, volume, epoch, MAX_EFL_ENTRIES_PER_SCOOP, &lastZidReturned, zids, &numEntriesObtained) != zOK) { @@ -3538,7 +3537,7 @@ STATUS eflRemoveEpoch( for (i = 0; i < numEntriesObtained; ++i) { xaction = BeginXLocal(volume, BXL_DEFAULT | X_CF_OK_TO_THROTTLE); - status = ZFSVOL_VOL_deleteEFLEntry(genMsg, volume, zids[i], + status = ZFSVOL_VOL_deleteEFLEntry(genMsg, volume, zids[i], INVALID_BLK_ZERO, 0, epoch, &xaction->xaction); EndXlocal(xaction); @@ -3559,11 +3558,11 @@ STATUS eflRemoveEpoch( (void)ELOG_CleanupBlocks(genMsg, volume, TRUE); status = zOK; - + exitRemovePurgeLog: xaction = BeginXLocal(volume, BXL_DEFAULT); - volume->VOLcomnVolOps.VOL_removePurgeLogEntry( - genMsg, volume, PLOG_EFL_REMOVE_EPOCH, + volume->VOLcomnVolOps.VOL_removePurgeLogEntry( + genMsg, volume, PLOG_EFL_REMOVE_EPOCH, &purgeLogInfo->purgeLogMsg, (Xaction_s *)xaction); EndXlocal(xaction); exitFree: @@ -3579,8 +3578,8 @@ exitUnlock: COMN_UnlockVolumeActive(volume, FALSE); exitRelease: tmpVolume = volume; - COMN_Release(&tmpVolume); - + COMN_Release(&tmpVolume); + return status; } @@ -3630,8 +3629,8 @@ STATUS ZFSVOL_VOL_administerEFL( if (!eTree) { /* somebody wants to start a EFL epoch, or set EFL default - * name space, it's a good time to create EFL tree if it doesn't exist - */ + * name space, it's a good time to create EFL tree if it doesn't exist + */ if (((opcode == VOL_EFL_ADMIN_CHANGE_EPOCH) && (retData != NULL)) || (opcode == VOL_EFL_ADMIN_SET_NAME_SPACE_ID) || (opcode == VOL_EFL_ADMIN_SET_INACTIVE_EPOCH_INTERVAL)) @@ -3665,11 +3664,11 @@ STATUS ZFSVOL_VOL_administerEFL( return zOK; } else if (((opcode == VOL_EFL_ADMIN_CHANGE_EPOCH) && (data != NULL)) || - (opcode == VOL_EFL_ADMIN_REMOVE_EPOCH) || - (opcode == VOL_EFL_ADMIN_RESET_EFL) || - (opcode == VOL_EFL_ADMIN_GET_INACTIVE_EPOCH_INTERVAL) || - (opcode == VOL_EFL_ADMIN_PING_EPOCH) || - (opcode == VOL_EFL_ADMIN_CHECK_EPOCH)) + (opcode == VOL_EFL_ADMIN_REMOVE_EPOCH) || + (opcode == VOL_EFL_ADMIN_RESET_EFL) || + (opcode == VOL_EFL_ADMIN_GET_INACTIVE_EPOCH_INTERVAL) || + (opcode == VOL_EFL_ADMIN_PING_EPOCH) || + (opcode == VOL_EFL_ADMIN_CHECK_EPOCH)) { return zOK; } @@ -3678,7 +3677,7 @@ STATUS ZFSVOL_VOL_administerEFL( return zFAILURE; } } - } + } switch(opcode) { @@ -3687,7 +3686,7 @@ STATUS ZFSVOL_VOL_administerEFL( /* stop the current active epoch and start a epoch */ if (data != NULL) { /* stop the specified epoch */ - epochMask = EFL_GET_EPOCH_MASK(eTree, &data->u.changeEpoch.epoch); + epochMask = EFL_GET_EPOCH_MASK(eTree, &data->u.changeEpoch.epoch); if (!epochMask) { SetErrno(genMsg, zERR_EFL_EPOCH_NOT_FOUND); @@ -3697,11 +3696,11 @@ STATUS ZFSVOL_VOL_administerEFL( status = EFL_writeTheBeast(genMsg, volume, eTree); } if (retData != NULL) - { + { /* start a new epoch */ if (status == zOK) - { - status = createEFLEpoch(genMsg, volume, + { + status = createEFLEpoch(genMsg, volume, &retData->u.changeEpoch.epoch); } } @@ -3724,20 +3723,20 @@ STATUS ZFSVOL_VOL_administerEFL( FSMLITE_INIT(&fsm->fsm, "FSM for removing EFL epochs", ++fsmInstance); - WORK_Schedule((FsmLite_s *)fsm, (voidfunc_t)EFL_RemoveEpochThread, NULL); + WORK_Schedule((FsmLite_s *)fsm, EFL_RemoveEpochThread, NULL); zASSERT((eTree->p.usedEpochs | eTree->p.activeEpochs) == eTree->p.usedEpochs); return zOK; } case VOL_EFL_ADMIN_RESET_EFL: { - /* This is done on COMMON layer instead */ + /* This is done on COMMON layer instead */ zASSERT("We shouldn't be here" == NULL); break; } case VOL_EFL_ADMIN_LIST_EPOCHS: - { + { NINT index; - + /* Do the active epochs */ epochList = malloc(sizeof(EFLEpoch_t) * 32); if (!epochList) @@ -3774,11 +3773,11 @@ STATUS ZFSVOL_VOL_administerEFL( retData->u.listEpochs.usedEpochs = epochList; retData->u.listEpochs.numUsedEpochs = numEntries; return zOK; - } + } case VOL_EFL_ADMIN_GET_NAME_SPACE_ID: { retData->u.nameSpaceID = EFL_GET_NAME_SPACE_ID(volume); - return zOK; + return zOK; } case VOL_EFL_ADMIN_SET_NAME_SPACE_ID: { @@ -3787,7 +3786,7 @@ STATUS ZFSVOL_VOL_administerEFL( } case VOL_EFL_ADMIN_GET_INACTIVE_EPOCH_INTERVAL: { - retData->u.inactiveEpochInterval = + retData->u.inactiveEpochInterval = EFL_GET_INACTIVE_EPOCH_INTERVAL(volume); return zOK; } @@ -3805,7 +3804,7 @@ STATUS ZFSVOL_VOL_administerEFL( EFLRemoveEpochData_s *fsm; NINT i; - for (i = 0; i < MAX_ZFS_EFL_EPOCHS; i++) + for (i = 0; i < MAX_ZFS_EFL_EPOCHS; i++) { if (((GetUTCTime() - eTree->p.epochs[i].lastAlive) > eTree->p.inactiveInterval) && ((1 << i) & eTree->p.usedEpochs)) @@ -3825,7 +3824,7 @@ STATUS ZFSVOL_VOL_administerEFL( FSMLITE_INIT(&fsm->fsm, "FSM for removing EFL epochs", ++fsmInstance); - WORK_Schedule((FsmLite_s *)fsm, (voidfunc_t)EFL_RemoveEpochThread, NULL); + WORK_Schedule((FsmLite_s *)fsm, EFL_RemoveEpochThread, NULL); } } return zOK; @@ -3833,8 +3832,8 @@ STATUS ZFSVOL_VOL_administerEFL( case VOL_EFL_GET_STATUS: { retData->u.active = eTree->p.activeEpochs ? TRUE : FALSE; - return zOK; - } + return zOK; + } } return zFAILURE; } @@ -3875,8 +3874,8 @@ STATUS ZFSVOL_VOL_resetEFL( STACK_ALLOC(); /* - * If there is no tree then don't bother. - */ + * If there is no tree then don't bother. + */ if (eTree == NULL) { STACK_FREE(); @@ -3884,8 +3883,8 @@ STATUS ZFSVOL_VOL_resetEFL( } /* - * Get an exclusive latch on the EFL Tree Beast - */ + * Get an exclusive latch on the EFL Tree Beast + */ X_LATCH(&eTree->ZFSEFLTREEbeastLatch); if (eTree->zfsBtree.p.btRoot == INVALID_BLK_ZERO) @@ -3900,7 +3899,7 @@ STATUS ZFSVOL_VOL_resetEFL( status = zFAILURE; goto exit; } - + READBLK_IO_MSG(aStack->iomsg, eTree, eTree->p.logHeaderBlock, CACHE_UPDATE); buffer = ELOG_ReadPoolBlk(genMsg, &aStack->iomsg); if (buffer == NULL) @@ -3916,7 +3915,7 @@ STATUS ZFSVOL_VOL_resetEFL( ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + sizeof(EFLRemoveLog_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_EFLTREE_REMOVE_LOG, xaction, + ZLOG_INIT_LOG_RECORD(XFUNC_EFLTREE_REMOVE_LOG, xaction, logBuffer, 1, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, elogNode->lsn, buffer, xaction, 0); @@ -3963,9 +3962,9 @@ STATUS ZFSVOL_VOL_resetEFL( node = (EFLTreeNode_s *)buffer->pBuf.data; if (EFL_IS_LEAF(node)) { /* - * If it is a leaf then set up so on the next loop it will be - * deleted. - */ + * If it is a leaf then set up so on the next loop it will be + * deleted. + */ zASSERT(node->magic == EFL_LEAF_MAGIC); cacheReleaseToss(buffer); readALeaf = TRUE; @@ -3981,9 +3980,9 @@ STATUS ZFSVOL_VOL_resetEFL( } else { /* - * it's a branch -- push on the stack and move on to its first - * child - */ + * it's a branch -- push on the stack and move on to its first + * child + */ readALeaf = FALSE; zASSERT(node->magic == EFL_BRANCH_MAGIC); @@ -4015,12 +4014,12 @@ STATUS ZFSVOL_VOL_resetEFL( node = (EFLTreeNode_s *)buffer->pBuf.data; /* - * If we have read all of the child records we can now delete - * them. - * - * If this is a leaf we need to check each name record for the - * leaf and see if it should be deleted. - */ + * If we have read all of the child records we can now delete + * them. + * + * If this is a leaf we need to check each name record for the + * leaf and see if it should be deleted. + */ aStack->parentStack[stkPtr].entry++; if ((aStack->parentStack[stkPtr].entry >= node->numRecs) || readALeaf) { @@ -4031,15 +4030,15 @@ STATUS ZFSVOL_VOL_resetEFL( { ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2)); - ZLOG_INIT_LOG_RECORD(XFUNC_EFLTREE_REMOVE, xaction, + ZLOG_INIT_LOG_RECORD(XFUNC_EFLTREE_REMOVE, xaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, node->lsn, buffer, xaction, 0); node->lsn = logBuffer->ZXR_Lsn; node->numRecs--; - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], - node->EBRANCH(node->numRecs).child, 0, NULL, + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], + node->EBRANCH(node->numRecs).child, 0, NULL, xaction, 1); ZLOG_DELETE_BLOCK(xaction, poolBlks[1]); @@ -4073,12 +4072,12 @@ STATUS ZFSVOL_VOL_resetEFL( ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2)); - ZLOG_INIT_LOG_RECORD(XFUNC_EFLTREE_REMOVE, xaction, logBuffer, 2, + ZLOG_INIT_LOG_RECORD(XFUNC_EFLTREE_REMOVE, xaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], 0, 0, NULL, xaction, 0); - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], eTree->zfsBtree.p.btRoot, 0, + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], eTree->zfsBtree.p.btRoot, 0, NULL, xaction, 0); ZLOG_DELETE_BLOCK(xaction, poolBlks[1]); @@ -4086,8 +4085,8 @@ STATUS ZFSVOL_VOL_resetEFL( ZLOG_ReleaseRecord(xaction); /* - * Fix up the efl tree beast to show no tree - */ + * Fix up the efl tree beast to show no tree + */ eTree->zfsBtree.p.btRoot = INVALID_BLK_ZERO; /* resets efl tree beast's persistent areas */ @@ -4095,7 +4094,7 @@ STATUS ZFSVOL_VOL_resetEFL( eTree->p.logHeaderBlock = INVALID_BLK_ZERO; eTree->p.nameSpace = EFL_DEFAULT_NAMESPACE; eTree->p.inactiveInterval = EFL_defaultEpochInterval; - + COMN_MARK_BEAST_XLOCAL(&eTree->ZFSEFLTREEroot, &xaction->xaction); COMN_ForceBeastWrite(genMsg, &eTree->ZFSEFLTREEroot, &xaction->xaction); @@ -4171,7 +4170,7 @@ STATUS EFL_recoveryInit( /* init the log header */ node = (EFLTreeNode_s *)buffer->pBuf.data; - ELOG_InitNode(buffer, &logRecord->u.init.internalID, + ELOG_InitNode(buffer, &logRecord->u.init.internalID, ELOG_HEADER_RECORD); ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[1], action); CACHE_DIRTY_RELEASE(buffer); @@ -4398,13 +4397,13 @@ STATUS EFL_recoveryBalance( { /* fix up the parent */ if (action == X_REDO) { - node->EBRANCH(logRecord->u.balance.indexForParent).zid = + node->EBRANCH(logRecord->u.balance.indexForParent).zid = logRecord->u.balance.zidForParent; } else { - node->EBRANCH(logRecord->u.balance.indexForParent).zid = - logRecord->u.balance.oldZid; + node->EBRANCH(logRecord->u.balance.indexForParent).zid = + logRecord->u.balance.oldZid; } ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); EFL_VALIDATE_NODE(node); @@ -4436,7 +4435,7 @@ STATUS EFL_recoveryBalance( if (EFL_IS_LEAF(node)) { /* leaf */ numToMove = logRecord->u.balance.numToMove; - if ((numToMove > 0) && + if ((numToMove > 0) && (((EFLLeafEntry_s *)&logRecord->u.balance.data[0])->zid == node->ELEAF(0).zid)) { /* if we are removing from the start of the leaf record ... */ @@ -4448,7 +4447,7 @@ STATUS EFL_recoveryBalance( else { /* branch */ numToMove = logRecord->u.balance.numToMove; - if ((numToMove > 0) && + if ((numToMove > 0) && (((EFLBranchEntry_s *)&logRecord->u.balance.data[0])->zid == node->EBRANCH(0).zid)) { /* if we are removing from the start of the branch record ... */ @@ -4598,8 +4597,8 @@ STATUS EFL_recoveryJoin( --(node->numRecs); i = logRecord->u.split.indexForParent; memmove( &node->EBRANCH(i), /* Destination */ - &node->EBRANCH(i + 1), /* Source */ - (node->numRecs - i) * sizeof(EFLBranchEntry_s)); + &node->EBRANCH(i + 1), /* Source */ + (node->numRecs - i) * sizeof(EFLBranchEntry_s)); ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); EFL_VALIDATE_NODE(node); CACHE_DIRTY_RELEASE(buffer); @@ -4812,7 +4811,7 @@ STATUS EFL_recoveryInsertEntry( Buffer_s *buffer; EFLTreeNode_s *node; IoMsg_s iomsg; - BlockInfo_s *poolBlks; + BlockInfo_s *poolBlks; ASSERT_MPKNSS_LOCK(); poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); @@ -4862,7 +4861,7 @@ STATUS EFL_recoveryDeleteEntryLogical( ZfsXasRecovery_s *logBuffer, NINT action) { - BlockInfo_s *poolBlks; + BlockInfo_s *poolBlks; EFLLog_s *logRecord; EFLTreeParms_s parms; EFLTreeNode_s *node; @@ -4894,7 +4893,7 @@ STATUS EFL_recoveryDeleteEntryLogical( xaction = BeginXLocal(&zfsVol->vol, BXL_LOGICAL_UNDO); eTree = zfsVol->eflTree; - + parms.xaction = xaction; parms.volume = (Volume_s *)zfsVol; parms.zid = logRecord->u.insert.newEntry.zid; @@ -4906,7 +4905,7 @@ STATUS EFL_recoveryDeleteEntryLogical( { UNX_LATCH(&eTree->ZFSEFLTREEbeastLatch); SetErrno(genMsg, zERR_ZID_NOT_FOUND); - goto exit; + goto exit; } if (EFL_findLeaf(genMsg, &parms, EFL_CHECK_FOR_JOIN) != zOK) @@ -4917,10 +4916,10 @@ STATUS EFL_recoveryDeleteEntryLogical( node = (EFLTreeNode_s *)parms.child->pBuf.data; if (EFL_findLeafEntry(node, parms.zid, &index)) { - status = EFL_doDeleteEntry(genMsg, &parms, + status = EFL_doDeleteEntry(genMsg, &parms, &logRecord->u.insert.newEntry); } - + exit: SET_LUNDO_LSN(xaction, logBuffer, status); EndXlocal(xaction); @@ -4971,7 +4970,7 @@ STATUS EFL_recoveryDeleteEntry( } logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - + if (EFL_findLeafEntry(node, logRecord->u.delete.entry.zid, &i)) { EFL_deleteEntry(node, i); @@ -5011,8 +5010,8 @@ STATUS EFL_recoveryInsertEntryLogical( if (action == X_UNDO) { return zX_LOGICAL; - } - + } + logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); internalID = logRecord->u.delete.internalID; @@ -5031,7 +5030,7 @@ STATUS EFL_recoveryInsertEntryLogical( { UNX_LATCH(&eTree->ZFSEFLTREEbeastLatch); SetErrno(genMsg, zERR_ZID_NOT_FOUND); - goto exitRelease; + goto exitRelease; } xaction = BeginXLocal(&zfsVol->vol, BXL_LOGICAL_UNDO); @@ -5046,19 +5045,19 @@ STATUS EFL_recoveryInsertEntryLogical( goto exitXaction; } -#if NSS_DEBUG IS_ENABLED +#if NSS_DEBUG IS_ENABLED { EFLTreeNode_s *node; NINT index; - + node = (EFLTreeNode_s *)parms.child->pBuf.data; if (EFL_findLeafEntry(node, parms.zid, &index)) { zASSERT("Node is not deleted" == NULL); goto exitXaction; - } + } } -#endif +#endif status = EFL_doInsertEntry(genMsg, &parms, &logRecord->u.delete.entry); @@ -5108,7 +5107,7 @@ STATUS EFL_recoveryModifyEntry( } newEntry = &logRecord->u.modify.newEntry; - + node = (EFLTreeNode_s *)buffer->pBuf.data; EFL_VALIDATE_NODE(node); zASSERT(node->magic == EFL_LEAF_MAGIC); @@ -5118,7 +5117,7 @@ STATUS EFL_recoveryModifyEntry( CACHE_RELEASE(buffer); return zOK; } - + if (!EFL_findLeafEntry(node, newEntry->zid, &i)) { /* zid not found in the buffer */ zASSERT("Leaf entry is not found" == NULL); @@ -5155,7 +5154,7 @@ STATUS EFL_recoveryModifyEntryLogical( EFLLeafEntry_s *leafEntry; EFLLeafEntry_s prevEntry; ZfsXaction_s *xaction; - GUID_t internalID; + GUID_t internalID; ZfsVolume_s *zfsVol; STATUS status = zFAILURE; ASSERT_MPKNSS_LOCK(); @@ -5163,7 +5162,7 @@ STATUS EFL_recoveryModifyEntryLogical( if (action == X_UNDO) { return zX_LOGICAL; - } + } logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); internalID = logRecord->u.modify.internalID; @@ -5184,14 +5183,14 @@ STATUS EFL_recoveryModifyEntryLogical( { UNX_LATCH(&eTree->ZFSEFLTREEbeastLatch); SetErrno(genMsg, zERR_ZID_NOT_FOUND); - goto exit; + goto exit; } parms.xaction = (ZfsXaction_s *)xaction; parms.volume = (Volume_s *)zfsVol; parms.eTree = eTree; parms.zid = oldEntry->zid; - + if (EFL_findLeaf(genMsg, &parms, EFL_CHECK_FOR_JOIN) != zOK) { if (EFL_TREE_X_LATCHED(&parms)) @@ -5199,24 +5198,24 @@ STATUS EFL_recoveryModifyEntryLogical( EFL_UNX_LATCH_TREE(&parms); } goto exit; - } + } - node = (EFLTreeNode_s *)parms.child->pBuf.data; + node = (EFLTreeNode_s *)parms.child->pBuf.data; if (!EFL_findLeafEntry(node, parms.zid, &i)) { /* zid not found in the buffer */ SetErrno(genMsg, zERR_ZID_NOT_FOUND); goto exit; } - + leafEntry = &node->ELEAF(i); prevEntry = *leafEntry; *leafEntry = *oldEntry; status = EFL_doModifyEntry(genMsg, &parms, i, &prevEntry); - + zASSERT(!EFL_TREE_X_LATCHED(&parms)); - + exit: SET_LUNDO_LSN(xaction, logBuffer, status); EndXlocal(xaction); @@ -5288,7 +5287,7 @@ STATUS EFL_recoveryRemove( } /**************************************************************************** - * Recovery routine for removing the link to the EFL log + * Recovery routine for removing the link to the EFL log ****************************************************************************/ STATUS EFL_recoveryRemoveLog( GeneralMsg_s *genMsg, @@ -5327,7 +5326,7 @@ STATUS EFL_recoveryRemoveLog( } else { - ELOG_InitNode(buffer, &logRecord->u.removeLog.internalID, + ELOG_InitNode(buffer, &logRecord->u.removeLog.internalID, ELOG_HEADER_RECORD); } diff --git a/src/nwnss/zlss/eflTree.h b/src/nwnss/zlss/eflTree.h index 96a660f..5b00ccc 100644 --- a/src/nwnss/zlss/eflTree.h +++ b/src/nwnss/zlss/eflTree.h @@ -45,7 +45,7 @@ #ifndef _EFLLOG_H_ #include "eflLog.h" #endif - + /* * Debug stuff */ @@ -64,12 +64,12 @@ /* state of a node */ #define EFL_LEAF 0x1 /* Leaf node of a B-tree */ #define EFL_ROOT 0x2 /* Root node of a B-tree */ -#define EFL_REZID_DONE 0x4 /* This node was ReZid - * This bit is only used while we are - * in the process of rezidding. - * When rezid is complete we clear this - * bit. - */ +#define EFL_REZID_DONE 0x4 /* This node was ReZid + * This bit is only used while we are + * in the process of rezidding. + * When rezid is complete we clear this + * bit. + */ #define EFL_SMALL DISABLE //#define EFL_SMALL ENABLE @@ -89,24 +89,24 @@ #define EFL_IS_ROOT(_n) ((_n)->state & EFL_ROOT) #define EFL_IS_MAX_ENTRIES(_node, _parms) \ - (EFL_IS_LEAF(_node) \ - ? ((_node)->numRecs >= EFL_MAX_LEAF_ENTRIES) \ - : ((_node)->numRecs >= EFL_MAX_BRANCH_ENTRIES)) + (EFL_IS_LEAF(_node) \ + ? ((_node)->numRecs >= EFL_MAX_LEAF_ENTRIES) \ + : ((_node)->numRecs >= EFL_MAX_BRANCH_ENTRIES)) #define EFL_IS_MIN_ENTRIES(_node) \ - (EFL_IS_LEAF(_node) \ - ? ((_node)->numRecs <= EFL_MIN_LEAF_ENTRIES) \ - : ((_node)->numRecs <= EFL_MIN_BRANCH_ENTRIES)) + (EFL_IS_LEAF(_node) \ + ? ((_node)->numRecs <= EFL_MIN_LEAF_ENTRIES) \ + : ((_node)->numRecs <= EFL_MIN_BRANCH_ENTRIES)) #define EFL_IS_LESSTHAN_MAX(_node, _sibling) \ - (EFL_IS_LEAF(_node) \ - ? (((_node)->numRecs + (_sibling)->numRecs) < EFL_MAX_LEAF_ENTRIES) \ - : (((_node)->numRecs + (_sibling)->numRecs) < EFL_MAX_BRANCH_ENTRIES)) + (EFL_IS_LEAF(_node) \ + ? (((_node)->numRecs + (_sibling)->numRecs) < EFL_MAX_LEAF_ENTRIES) \ + : (((_node)->numRecs + (_sibling)->numRecs) < EFL_MAX_BRANCH_ENTRIES)) -#define EFL_GET_NAME_SPACE_ID(_volume) ((ZfsVolume_s *)(_volume))->eflTree->p.nameSpace +#define EFL_GET_NAME_SPACE_ID(_volume) ((ZfsVolume_s *)(_volume))->eflTree->p.nameSpace #define EFL_GET_INACTIVE_EPOCH_INTERVAL(_volume) \ - ((ZfsVolume_s *)(_volume))->eflTree->p.inactiveInterval + ((ZfsVolume_s *)(_volume))->eflTree->p.inactiveInterval #define EBRANCH(_entry) n.branch.entry[(_entry)] #define ELEAF(_entry) n.leaf.entry[(_entry)] @@ -114,17 +114,17 @@ /* Macros used for latching and unlatching the eflTree beast and checking * to see if the beast we are inserting or updating is the eflTree beast */ #define EFL_X_LATCH_TREE(_parms) \ - X_LATCH(&(_parms)->eTree->ZFSEFLTREEbeastLatch); + X_LATCH(&(_parms)->eTree->ZFSEFLTREEbeastLatch); #define EFL_UNX_LATCH_TREE(_parms) \ - UNX_LATCH(&(_parms)->eTree->ZFSEFLTREEbeastLatch); + UNX_LATCH(&(_parms)->eTree->ZFSEFLTREEbeastLatch); #define EFL_TREE_X_LATCHED(_parms) \ - IS_XLATCHED(&(_parms)->eTree->ZFSEFLTREEbeastLatch) + IS_XLATCHED(&(_parms)->eTree->ZFSEFLTREEbeastLatch) #define EFL_ANY_EPOCH_ACTIONS(_entry) \ - ((_entry).createEpochs || (_entry).modifyEpochs || \ - (_entry).metaDataEpochs || (_entry).deleteEpochs) + ((_entry).createEpochs || (_entry).modifyEpochs || \ + (_entry).metaDataEpochs || (_entry).deleteEpochs) #define EFL_GET_EPOCH_MASK(_eTree, _epoch) getEFLEpochMask(_eTree, _epoch) @@ -134,28 +134,28 @@ */ typedef struct EFLBranchEntry_s { - Zid_t zid; - Blknum_t child; - LONG resBlk; /* reserved for 64 bit blocks */ + Zid_t zid; + Blknum_t child; + LONG resBlk; /* reserved for 64 bit blocks */ } NSS_MEDIA_STRUCTURE(EFLBranchEntry_s,resBlk) EFLBranchEntry_s; typedef struct EFLBranch_s { - EFLBranchEntry_s entry[EFL_MAX_BRANCH_ENTRIES]; + EFLBranchEntry_s entry[EFL_MAX_BRANCH_ENTRIES]; } NSS_MEDIA_STRUCTURE(EFLBranch_s,entry[EFL_MAX_BRANCH_ENTRIES]) EFLBranch_s; typedef struct EFLLeafEntry_s { - Zid_t zid; - EFLEpochMask_t createEpochs; - EFLEpochMask_t modifyEpochs; /* data modified */ - EFLEpochMask_t metaDataEpochs; /* metadata modified */ - EFLEpochMask_t deleteEpochs; - LONG objectType; - ELogLink_s firstLogEntry; - ELogLink_s lastLogEntry; - LONG numGoodLogEntries; - LONG extra[4]; /* extra space for future use */ + Zid_t zid; + EFLEpochMask_t createEpochs; + EFLEpochMask_t modifyEpochs; /* data modified */ + EFLEpochMask_t metaDataEpochs; /* metadata modified */ + EFLEpochMask_t deleteEpochs; + LONG objectType; + ELogLink_s firstLogEntry; + ELogLink_s lastLogEntry; + LONG numGoodLogEntries; + LONG extra[4]; /* extra space for future use */ } NSS_MEDIA_STRUCTURE(EFLLeafEntry_s,extra[4]) EFLLeafEntry_s; /* Values for objectType */ @@ -166,33 +166,33 @@ typedef struct EFLLeafEntry_s typedef struct EFLLeaf_s { - /* - * If the size of the header portion changes then change - * EFL_MAX_LEAF_ENTRIES. - */ - Blknum_t nextLeaf; /* link to the next leaf in the tree */ - LONG resBlk; /* reserved for 64 bit blocks */ - EFLLeafEntry_s entry[EFL_MAX_LEAF_ENTRIES]; + /* + * If the size of the header portion changes then change + * EFL_MAX_LEAF_ENTRIES. + */ + Blknum_t nextLeaf; /* link to the next leaf in the tree */ + LONG resBlk; /* reserved for 64 bit blocks */ + EFLLeafEntry_s entry[EFL_MAX_LEAF_ENTRIES]; } NSS_MEDIA_STRUCTURE(EFLLeaf_s,entry[EFL_MAX_LEAF_ENTRIES]) EFLLeaf_s; typedef struct EFLTreeNode_s { - /* - * If the size of the header portion changes then change EFL_MAX_FREEBLKS, - * EFL_MAX_BRANCHES and EFL_MAX_LEAF_FREE. - */ - LONG magic; - WORD state; - WORD numRecs; - Lsn_t lsn; - GUID_t efl_internalID; /* Must be at OFFSET 16 - unique volume ID (used - * by scanning repair). btn -> Beast Tree Node. - */ - union - { - EFLBranch_s branch; - EFLLeaf_s leaf; - } NSS_MEDIA_UNION(NamelessUnion,leaf) n; + /* + * If the size of the header portion changes then change EFL_MAX_FREEBLKS, + * EFL_MAX_BRANCHES and EFL_MAX_LEAF_FREE. + */ + LONG magic; + WORD state; + WORD numRecs; + Lsn_t lsn; + GUID_t efl_internalID; /* Must be at OFFSET 16 - unique volume ID (used + * by scanning repair). btn -> Beast Tree Node. + */ + union + { + EFLBranch_s branch; + EFLLeaf_s leaf; + } NSS_MEDIA_UNION(NamelessUnion,leaf) n; } NSS_MEDIA_STRUCTURE(EFLTreeNode_s,n.leaf) EFLTreeNode_s; /* @@ -200,17 +200,17 @@ typedef struct EFLTreeNode_s */ typedef struct EFLTreeParms_s { - Volume_s *volume; /* the volume we are working on */ - Zid_t zid; - NINT action; - Blknum_t readBlkNum; /* Next block to be read */ - NINT index; /* Where last record was found in parent*/ - Buffer_s *parent; /* Parent buffer */ - Buffer_s *child; /* Child buffer */ - Buffer_s *sibling; /* Sibling buffer */ - EFLEpochMask_t epochMask; - struct ZfsXaction_s *xaction; /* Transaction being used */ - struct ZfsEFLTreeBeast_s *eTree; /* The pointer to the b-tree beast */ + Volume_s *volume; /* the volume we are working on */ + Zid_t zid; + NINT action; + Blknum_t readBlkNum; /* Next block to be read */ + NINT index; /* Where last record was found in parent*/ + Buffer_s *parent; /* Parent buffer */ + Buffer_s *child; /* Child buffer */ + Buffer_s *sibling; /* Sibling buffer */ + EFLEpochMask_t epochMask; + struct ZfsXaction_s *xaction; /* Transaction being used */ + struct ZfsEFLTreeBeast_s *eTree; /* The pointer to the b-tree beast */ } EFLTreeParms_s; /* @@ -219,60 +219,60 @@ typedef struct EFLTreeParms_s typedef struct EFLSplit_s { - GUID_t internalID; - Zid_t zidForParent; /* zid to insert in the parent */ - Blknum_t leafLink; /* link to the next leaf in the tree */ - Blknum_t blockForParent; /* block number to insert in the parent */ - LONG indexForParent; /* index where zid is inserted in the parent */ - LONG totalLength; /* length of tree information being moved */ - WORD numToMove; /* number of entries logged */ - WORD nodeType; /* whether the new node is a branch or a leaf */ - BYTE data[1]; /* data to move */ + GUID_t internalID; + Zid_t zidForParent; /* zid to insert in the parent */ + Blknum_t leafLink; /* link to the next leaf in the tree */ + Blknum_t blockForParent; /* block number to insert in the parent */ + LONG indexForParent; /* index where zid is inserted in the parent */ + LONG totalLength; /* length of tree information being moved */ + WORD numToMove; /* number of entries logged */ + WORD nodeType; /* whether the new node is a branch or a leaf */ + BYTE data[1]; /* data to move */ } NSS_MEDIA_STRUCTURE(EFLSplit_s,data[1]) EFLSplit_s; typedef struct EFLGrow_s { - GUID_t internalID; - Blknum_t blockForParent; /* block number to insert in the parent */ + GUID_t internalID; + Blknum_t blockForParent; /* block number to insert in the parent */ } NSS_MEDIA_STRUCTURE(EFLGrow_s,blockForParent) EFLGrow_s; typedef struct EFLBalance_s { - Zid_t zidForParent; /* zid to insert in the parent */ - Zid_t oldZid; /* previous zid in the parent */ - LONG indexForParent; /* index where zid is changed in the parent */ - LONG totalLength; /* length of tree information being moved */ - WORD numToMove; /* number of entries moved */ - BYTE data[1]; /* data to move */ + Zid_t zidForParent; /* zid to insert in the parent */ + Zid_t oldZid; /* previous zid in the parent */ + LONG indexForParent; /* index where zid is changed in the parent */ + LONG totalLength; /* length of tree information being moved */ + WORD numToMove; /* number of entries moved */ + BYTE data[1]; /* data to move */ } NSS_MEDIA_STRUCTURE(EFLBalance_s,data[1]) EFLBalance_s; typedef struct EFLTreeInit_s { - GUID_t internalID; + GUID_t internalID; } NSS_MEDIA_STRUCTURE(EFLTreeInit_s,internalID) EFLTreeInit_s; typedef struct EFLModify_s { - GUID_t internalID; - EFLLeafEntry_s oldEntry; - EFLLeafEntry_s newEntry; + GUID_t internalID; + EFLLeafEntry_s oldEntry; + EFLLeafEntry_s newEntry; } NSS_MEDIA_STRUCTURE(EFLModify_s,newEntry) EFLModify_s; typedef struct EFLInsert_s { - GUID_t internalID; - EFLLeafEntry_s newEntry; + GUID_t internalID; + EFLLeafEntry_s newEntry; } NSS_MEDIA_STRUCTURE(EFLInsert_s,newEntry) EFLInsert_s; typedef struct EFLDelete_s { - GUID_t internalID; - EFLLeafEntry_s entry; + GUID_t internalID; + EFLLeafEntry_s entry; } NSS_MEDIA_STRUCTURE(EFLDelete_s,entry) EFLDelete_s; typedef struct EFLRemoveLog_s { - GUID_t internalID; + GUID_t internalID; } NSS_MEDIA_STRUCTURE(EFLRemoveLog_s,internalID) EFLRemoveLog_s; /* defines for direction */ @@ -281,17 +281,17 @@ typedef struct EFLRemoveLog_s typedef struct EFLLog_s { - union - { - EFLSplit_s split; - EFLGrow_s grow; - EFLBalance_s balance; - EFLTreeInit_s init; - EFLModify_s modify; - EFLInsert_s insert; - EFLDelete_s delete; - EFLRemoveLog_s removeLog; - } NSS_MEDIA_UNION(NamelessUnion,removeLog) u; + union + { + EFLSplit_s split; + EFLGrow_s grow; + EFLBalance_s balance; + EFLTreeInit_s init; + EFLModify_s modify; + EFLInsert_s insert; + EFLDelete_s delete; + EFLRemoveLog_s removeLog; + } NSS_MEDIA_UNION(NamelessUnion,removeLog) u; } NSS_MEDIA_STRUCTURE(EFLLog_s,u.removeLog) EFLLog_s; @@ -303,67 +303,67 @@ typedef struct EFLLog_s ****************************************************************************/ STATUS ZFSVOL_VOL_insertEFLEntry( - struct GeneralMsg_s *genMsg, - struct File_s *file, - NINT action, - unicode_t *name, - struct Xaction_s *xaction); - + struct GeneralMsg_s *genMsg, + struct File_s *file, + NINT action, + unicode_t *name, + struct Xaction_s *xaction); + STATUS ZFSVOL_VOL_deleteEFLEntry( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - Zid_t zid, - QUAD id1, - QUAD id2, - EFLEpoch_t *epoch, - struct Xaction_s *xaction); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + Zid_t zid, + QUAD id1, + QUAD id2, + EFLEpoch_t *epoch, + struct Xaction_s *xaction); STATUS ZFSVOL_VOL_lookupEFLEntry( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - Zid_t zid, - EFLEpoch_t *epoch, - EFLEntry_s *entry); - + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + Zid_t zid, + EFLEpoch_t *epoch, + EFLEntry_s *entry); + STATUS ZFSVOL_VOL_enumerateEFL( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - EFLEpoch_t *targetEpoch, - NINT maxEntries, - struct EFLEntryIndex_s *nextEntry, /* inout */ - struct EFLEntry_s *retEntries, /* out */ - NINT *numEntriesReturned); /* out */ + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + EFLEpoch_t *targetEpoch, + NINT maxEntries, + struct EFLEntryIndex_s *nextEntry, /* inout */ + struct EFLEntry_s *retEntries, /* out */ + NINT *numEntriesReturned); /* out */ STATUS ZFSVOL_VOL_administerEFL( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - NINT opCode, - EFLAdminIn_s *data, - EFLAdminOut_s *retData); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT opCode, + EFLAdminIn_s *data, + EFLAdminOut_s *retData); STATUS ZFSVOL_VOL_resetEFL( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume); void EFL_RemoveEpochThread( - EFLRemoveEpochData_s *fsm, + EFLRemoveEpochData_s *fsm, void *unused); void EFL_checkerStart(OneShot_s *alarm); STATUS eflRemoveEpoch( - GeneralMsg_s *genMsg, - Volume_s *volume, - EFLEpoch_t *epoch); + GeneralMsg_s *genMsg, + Volume_s *volume, + EFLEpoch_t *epoch); BOOL EFL_ValidateNode( - EFLTreeNode_s *node); + EFLTreeNode_s *node); Buffer_s *EFL_ReadPoolBlk ( - GeneralMsg_s *genMsg, - IoMsg_s *iomsg); + GeneralMsg_s *genMsg, + IoMsg_s *iomsg); /* efl startup/shutdown routine */ void eflInit(); diff --git a/src/nwnss/zlss/mflBTree.h b/src/nwnss/zlss/mflBTree.h index 34d50c4..af0b02f 100644 --- a/src/nwnss/zlss/mflBTree.h +++ b/src/nwnss/zlss/mflBTree.h @@ -65,9 +65,9 @@ extern MYBTreeInstanceInfo_s MFLTreeInfo; #if NSS_DEBUG IS_ENABLED void ZfsDisplayMFL( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); #define zfsDisplayMFLNode(_location, _nameOfBuffer, _buffer) \ MYBT_displayNode(&MFLTreeInfo, _location, _nameOfBuffer, _buffer) diff --git a/src/nwnss/zlss/mfl_if.c b/src/nwnss/zlss/mfl_if.c index 6a3b980..2719a3c 100644 --- a/src/nwnss/zlss/mfl_if.c +++ b/src/nwnss/zlss/mfl_if.c @@ -135,7 +135,7 @@ MYBTreeInstanceInfo_s MFLTreeInfo = #define MFL_INCOMPLETE(_volume) \ (((ZfsVolume_s *)(_volume))->mfl->incomplete) -STATIC void +STATIC void MFL_setStatus( Volume_s *volume, BOOL incomplete, /* Should be marked incomplete? */ @@ -146,7 +146,7 @@ MFL_setStatus( ZfsMFLBeast_s *mflBeast = ((ZfsVolume_s *)volume)->mfl; zASSERT(mflBeast != NULL); - + X_LATCH(&mflBeast->ZFSMFLbeastLatch); if (mflBeast->incomplete == incomplete) { @@ -188,7 +188,7 @@ STATUS ZFSVOL_VOL_createMFL( beast->ROOTzid = ZFSVOL_MFL_ZID; ((ZfsMFLBeast_s *)beast)->ZFSMFLfirstParentZID = zINVALID_ZID; - /* Just created MFL; yet to add modified files to it. + /* Just created MFL; yet to add modified files to it. * Mark it incomplete */ ((ZfsMFLBeast_s *)beast)->incomplete = TRUE; beast->bstState |= BST_STATE_NEW; @@ -219,7 +219,7 @@ STATUS ZFSVOL_VOL_destroyMFL( /* Empty the MFL tree and mark it incomplete */ mflIncompleteFlag = zfsVol->mfl->incomplete; zfsVol->mfl->incomplete = TRUE; - rc = MYBT_resetTree(genMsg, &MFLTreeInfo, &zfsVol->mfl->myBTree, + rc = MYBT_resetTree(genMsg, &MFLTreeInfo, &zfsVol->mfl->myBTree, &zfsVol->ZFSVOLvol); if (rc != zOK) { @@ -241,7 +241,7 @@ STATUS ZFSVOL_VOL_destroyMFL( xaction = BeginXLocal(&zfsVol->ZFSVOLvol, BXL_DEFAULT); X_LATCH(&zfsVol->mfl->ZFSMFLbeastLatch); - rc = zfsVol->ZFSVOLvol.VOLcomnVolOps.VOL_removeBeastFromVolume(genMsg, &zfsVol->mfl->ZFSMFLroot, + rc = zfsVol->ZFSVOLvol.VOLcomnVolOps.VOL_removeBeastFromVolume(genMsg, &zfsVol->mfl->ZFSMFLroot, &xaction->xaction); UNX_LATCH(&zfsVol->mfl->ZFSMFLbeastLatch); if (rc != zOK) @@ -298,7 +298,7 @@ STATUS ZFSVOL_VOL_insertMFLEntry( STATUS ZFSVOL_VOL_deleteMFLEntry( GeneralMsg_s *genMsg, Volume_s *volume, - Zid_t zid, + Zid_t zid, Epoch_t *epoch, /* out */ Xaction_s *xAction) { @@ -327,7 +327,7 @@ STATUS ZFSVOL_VOL_deleteMFLEntry( STATUS ZFSVOL_VOL_lookupMFLEntry( GeneralMsg_s *genMsg, Volume_s *volume, - Zid_t zid, + Zid_t zid, Epoch_t *epoch) { MYBTreeParms_s parms; @@ -403,16 +403,16 @@ STATUS ZFSVOL_VOL_enumerateMFL( NINT numEntriesObtained; NINT destind, i; - rc = MYBT_browseEntries(genMsg, &parms, numEntriesRequested, + rc = MYBT_browseEntries(genMsg, &parms, numEntriesRequested, (BYTE *)&mflEntries[nextind], &numEntriesObtained); destind = nextind; for (i = nextind; i < nextind + numEntriesObtained; ++ i) { - /* + /* * Examine the entry to see if its epoch is what we are looking for */ - if (KEY_COMP(mflEntries[i].value.epoch, targetEpoch) < 0) + if (KEY_COMP(mflEntries[i].value.epoch, targetEpoch) < 0) { if (destind != i) mflEntries[destind] = mflEntries[i]; @@ -472,7 +472,7 @@ STATUS MFL_internalRecoveryCommon( struct ZfsXasRecovery_s *logBuffer, NINT action) { - return MYBT_CALL_INTERNAL_RECOVERY_FUNC(genMsg, &MFLTreeInfo, pool, + return MYBT_CALL_INTERNAL_RECOVERY_FUNC(genMsg, &MFLTreeInfo, pool, logBuffer, action); } @@ -493,8 +493,8 @@ STATUS MFL_logicalRecoveryCommon( if (action == X_L_UNDO) { /* Logical Undo; need tree beast; get it from volume */ - zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, - &logRecord->internalVolumeID, pool); + zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, + &logRecord->internalVolumeID, pool); if (zfsVol == NULL) { return zFAILURE; @@ -506,7 +506,7 @@ STATUS MFL_logicalRecoveryCommon( SetErrno(genMsg, zERR_ZID_NOT_FOUND); return zFAILURE; } - rc = MYBT_CALL_LOGICAL_RECOVERY_FUNC(genMsg, &MFLTreeInfo, + rc = MYBT_CALL_LOGICAL_RECOVERY_FUNC(genMsg, &MFLTreeInfo, pool, &zfsVol->mfl->myBTree, logBuffer, action); COMN_Release(&zfsVol); } @@ -514,7 +514,7 @@ STATUS MFL_logicalRecoveryCommon( { zASSERT(action == X_REDO); /* Redo case; don't need tree beast */ - rc = MYBT_CALL_LOGICAL_RECOVERY_FUNC(genMsg, &MFLTreeInfo, + rc = MYBT_CALL_LOGICAL_RECOVERY_FUNC(genMsg, &MFLTreeInfo, pool, NULL, logBuffer, action); } return rc; @@ -525,7 +525,7 @@ STATIC BOOL FixingMFL = FALSE; #define MAX_ZIDS_PER_SCOOP 100 STATIC void MFL_verify( - Volume_s *volume, + Volume_s *volume, MFLVerifyStats_s *verifyStats, /* out */ BOOL doFix) { @@ -539,7 +539,7 @@ MFL_verify( Epoch_t epoch; ZfsXaction_s *localXaction; typedef struct Stack_s { - Zid_t beastZids[MAX_ZIDS_PER_SCOOP]; + Zid_t beastZids[MAX_ZIDS_PER_SCOOP]; } Stack_s; STACK_ALLOC(); @@ -553,7 +553,7 @@ MFL_verify( STACK_FREE(); return; } - /* turn off MFL's incomplete flag in memory to detect + /* turn off MFL's incomplete flag in memory to detect * errors encountered during other MFL adds happening behind our back * while we are fixing the MFL */ if ((! ((ZfsVolume_s *)volume)->mfl) && @@ -563,7 +563,7 @@ MFL_verify( FixingMFL = TRUE; } - do + do { /* Make sure the volume is in active state */ if ((volume->state != zVOLSTATE_ACTIVE) || @@ -577,8 +577,8 @@ MFL_verify( numBeastsReturned = MAX_ZIDS_PER_SCOOP; /* Obtain a scoop of ZIDs to examine */ - rc = volume->VOLcomnVolOps.VOL_browseBeastsInVolume(&genMsg, volume, - SELECT_BEASTS_ALL, MAX_ZIDS_PER_SCOOP, + rc = volume->VOLcomnVolOps.VOL_browseBeastsInVolume(&genMsg, volume, + SELECT_BEASTS_ALL, MAX_ZIDS_PER_SCOOP, &lastZidReturned, aStack->beastZids, &numBeastsReturned); if (rc != zOK) { @@ -590,7 +590,7 @@ MFL_verify( for (i = 0; i < numBeastsReturned; ++ i) { /* Obtain the file */ - file = (File_s *)COMN_LookupByZid(&genMsg, volume, + file = (File_s *)COMN_LookupByZid(&genMsg, volume, aStack->beastZids[i], SLATCHED, TRUE); /* Ignore all errors */ @@ -619,12 +619,12 @@ MFL_verify( localXaction = BeginXLocal(volume, BXL_DEFAULT); rc = ZFSVOL_VOL_insertMFLEntry( &genMsg, file->FILEvolume, file->FILEzid, - file->FILEvolume->VOLepoch, + file->FILEvolume->VOLepoch, &localXaction->xaction); if (rc != zOK) { - /* If entry already exists, keep the entry. - * Don't modify it. + /* If entry already exists, keep the entry. + * Don't modify it. * Otherwise mark the MFL incomplete */ if (GetErrno(&genMsg) != zERR_FILE_ALREADY_EXISTS) { @@ -648,7 +648,7 @@ MFL_verify( localXaction = BeginXLocal(volume, BXL_DEFAULT); rc = ZFSVOL_VOL_deleteMFLEntry( &genMsg, file->FILEvolume, file->FILEzid, - &epoch, + &epoch, &localXaction->xaction); if (rc != zOK) { @@ -702,7 +702,7 @@ ZFSVOL_VOL_administerMFL( switch(opCode) { case VOL_MFL_ADMIN_GET_STATUS_OP: - parms->status.incomplete = + parms->status.incomplete = (! ((ZfsVolume_s *)volume)->mfl) || MFL_INCOMPLETE(volume); return zOK; case VOL_MFL_ADMIN_VERIFY_OP: @@ -719,7 +719,7 @@ ZFSVOL_VOL_administerMFL( } -STATIC STATUS +STATIC STATUS ZFSMFL_Construct( GeneralMsg_s *genMsg, void *beast_LX) diff --git a/src/nwnss/zlss/mfl_if.h b/src/nwnss/zlss/mfl_if.h index e89d453..b1ffae7 100644 --- a/src/nwnss/zlss/mfl_if.h +++ b/src/nwnss/zlss/mfl_if.h @@ -47,17 +47,17 @@ * ****************************************************************************/ -extern STATUS +extern STATUS ZFSVOL_VOL_createMFL( GeneralMsg_s *genMsg, ZfsVolume_s *zfsVol); -extern STATUS +extern STATUS ZFSVOL_VOL_destroyMFL( GeneralMsg_s *genMsg, ZfsVolume_s *zfsVol); -extern STATUS +extern STATUS ZFSVOL_VOL_insertMFLEntry( GeneralMsg_s *genMsg, Volume_s *volume, @@ -65,7 +65,7 @@ ZFSVOL_VOL_insertMFLEntry( Epoch_t epoch, Xaction_s *xaction); -extern STATUS +extern STATUS ZFSVOL_VOL_deleteMFLEntry( GeneralMsg_s *genMsg, Volume_s *volume, @@ -73,22 +73,22 @@ ZFSVOL_VOL_deleteMFLEntry( Epoch_t *epoch, /* out */ Xaction_s *xaction); -extern STATUS +extern STATUS ZFSVOL_VOL_lookupMFLEntry( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, Volume_s *volume, Zid_t zid, Epoch_t *epoch); /* out */ STATUS ZFSVOL_VOL_enumerateMFL( - GeneralMsg_s *genMsg, - Volume_s *volume, - Epoch_t targetEpoch, - NINT numEntriesRequested, - Zid_t *lastZidReturned, /* inout */ - MFLEntry_s *mflEntries, /* out */ - NINT *numEntriesReturned, /* out */ - BOOL *isMFLincomplete); /* out */ + GeneralMsg_s *genMsg, + Volume_s *volume, + Epoch_t targetEpoch, + NINT numEntriesRequested, + Zid_t *lastZidReturned, /* inout */ + MFLEntry_s *mflEntries, /* out */ + NINT *numEntriesReturned, /* out */ + BOOL *isMFLincomplete); /* out */ extern STATUS ZFSVOL_VOL_administerMFL( @@ -99,7 +99,7 @@ ZFSVOL_VOL_administerMFL( extern void MFL_verify( - Volume_s *volume, + Volume_s *volume, MFLVerifyStats_s *verifyStats, /* out */ BOOL doFix); diff --git a/src/nwnss/zlss/myBTree.c b/src/nwnss/zlss/myBTree.c index 8e57617..e2e426a 100644 --- a/src/nwnss/zlss/myBTree.c +++ b/src/nwnss/zlss/myBTree.c @@ -32,7 +32,7 @@ | |--------------------------------------------------------------------------- | This module is used to: - | Generic fixed-key, fixed-value B-tree for use in various ZLSS + | Generic fixed-key, fixed-value B-tree for use in various ZLSS | data structures. +-------------------------------------------------------------------------*/ #include @@ -41,7 +41,6 @@ #include #include #include -#include #include "myBTree.h" #include "pssDebug.h" @@ -93,7 +92,7 @@ Buffer_s *MYBT_ReadPoolBlk( { if (treeInfo->upgradeNode) { - if (treeInfo->upgradeNode(genMsg, buffer, iomsg->mode, &modified) + if (treeInfo->upgradeNode(genMsg, buffer, iomsg->mode, &modified) != zOK) { CACHE_RELEASE(buffer); @@ -105,9 +104,9 @@ Buffer_s *MYBT_ReadPoolBlk( } } node = (MYBTreeNode_s *)buffer->pBuf.data; - if ((MYBT_IS_LEAF(node) && + if ((MYBT_IS_LEAF(node) && (node->magic != MYBT_LEAF_MAGIC(treeInfo))) || - (node->magic != MYBT_BRANCH_MAGIC(treeInfo))) + (node->magic != MYBT_BRANCH_MAGIC(treeInfo))) { SetErrno(genMsg, zERR_MEDIA_CORRUPTED); ZLSSPOOL_MediaIsCorrupt(genMsg, buffer, iomsg); @@ -155,7 +154,7 @@ BOOL MYBT_validateNode( curr = MYBT_LEAFENTRY(treeInfo, node, count); /* check if ascending */ - VERIFY_CONDITION((treeInfo->keyComp(MYBT_LEAFENTRY_KEY(treeInfo, prev), + VERIFY_CONDITION((treeInfo->keyComp(MYBT_LEAFENTRY_KEY(treeInfo, prev), MYBT_LEAFENTRY_KEY(treeInfo, curr)) < 0), dontAssert); /* set previous record and try again */ @@ -171,14 +170,14 @@ BOOL MYBT_validateNode( prev = MYBT_BRANCHENTRY(treeInfo, node, 0); - VERIFY_CONDITION((MYBT_MAX_BRANCH_ENTRIES(treeInfo) >= node->numRecs), + VERIFY_CONDITION((MYBT_MAX_BRANCH_ENTRIES(treeInfo) >= node->numRecs), dontAssert); for(count = 1; count < node->numRecs; count++) { curr = MYBT_BRANCHENTRY(treeInfo, node, count); - + /* check if ascending */ - VERIFY_CONDITION((treeInfo->keyComp(&prev->key, &curr->key) < 0), + VERIFY_CONDITION((treeInfo->keyComp(&prev->key, &curr->key) < 0), dontAssert); /* set previous record and try again */ @@ -227,7 +226,7 @@ void MYBT_displayNode( DBG_DebugPrintf(YELLOW, MSGNot("<")); treeInfo->displayKey(YELLOW, MYBT_LEAF_IND_KEY(treeInfo, node, i)); DBG_DebugPrintf(YELLOW, MSGNot(", ")); - treeInfo->displayValue(YELLOW, + treeInfo->displayValue(YELLOW, MYBT_LEAF_IND_VALUE(treeInfo, node, i)); DBG_DebugPrintf(YELLOW, MSGNot(">\n")); } @@ -386,12 +385,12 @@ STATIC Blknum_t MYBT_findChildBlock( ENTER(TZTREE, MYBT_findChildBlock); - while (low <= high) + while (low <= high) { mid = (low + high) / 2; cmpResult = treeInfo->keyComp(key, MYBT_BRANCHENTRY(treeInfo, node, mid)->key); if (cmpResult == 0) /* key == mid entry's key */ - { + { break; } else if (cmpResult > 0) /* key > mid entry's key */ @@ -437,7 +436,7 @@ STATIC BOOL MYBT_findLeafEntry( ENTER(TZTREE, MYBT_findLeafEntry); MYBT_VALIDATE_NODE(treeInfo, node); - while (low <= high) + while (low <= high) { mid = (low + high) / 2; cmpResult = treeInfo->keyComp(key, MYBT_LEAF_IND_KEY(treeInfo, node, mid)); @@ -510,9 +509,9 @@ STATIC void MYBT_insertZeroNode ( MYBT_VALIDATE_NODE(treeInfo, node); /* - * We always want a zero in the first location to establish a lower bound - * so we do not need a lot of special case code. - */ + * We always want a zero in the first location to establish a lower bound + * so we do not need a lot of special case code. + */ node->numRecs = 1; bzero(MYBT_LEAFENTRY(treeInfo, node, 0), MYBT_LEAFENTRY_SIZE(treeInfo)); MYBT_VALIDATE_NODE(treeInfo, node); @@ -587,8 +586,8 @@ STATIC STATUS MYBT_join ( /* update the leaf link */ child->n.leaf.nextLeaf = sibling->n.leaf.nextLeaf; /* Change magic in Deleted Leaf Node to indicate it is deleted. This - * is being done for scan mode of rebuild. - */ + * is being done for scan mode of rebuild. + */ sibling->magic |= 0x20; /* Lower case low byte letter */ } else @@ -613,7 +612,7 @@ STATIC STATUS MYBT_join ( - 1 + lenMoved + MYBT_KEY_SIZE(treeInfo)); ZLOG_INIT_LOG_RECORD( - (treeInfo->internalRecoveryStartOpCode + MYBT_RECOVERY_OP_JOIN), + (treeInfo->internalRecoveryStartOpCode + MYBT_RECOVERY_OP_JOIN), localXaction, logBuffer, 3, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[0], parms->parent->volBlk, parent->lsn, parms->parent, localXaction, 0, MYBT_compare); @@ -628,8 +627,8 @@ STATIC STATUS MYBT_join ( keyForParent = &logRecord->u.split.data[lenMoved]; MYBT_keyCopy(treeInfo, keyForParent, MYBT_BRANCHENTRY(treeInfo, parent, parentIndex)->key); memmove( MYBT_BRANCHENTRY(treeInfo, parent, parentIndex), /* Destination */ - MYBT_BRANCHENTRY(treeInfo, parent, parentIndex + 1), /* Source */ - (parent->numRecs - parentIndex) * MYBT_BRANCHENTRY_SIZE(treeInfo)); + MYBT_BRANCHENTRY(treeInfo, parent, parentIndex + 1), /* Source */ + (parent->numRecs - parentIndex) * MYBT_BRANCHENTRY_SIZE(treeInfo)); logRecord->u.split.leafLink = child->n.leaf.nextLeaf; logRecord->u.split.blockForParent = poolBlks[2].blkNum; zASSERT( parms->btreeBeast != NULL ); @@ -652,14 +651,14 @@ STATIC STATUS MYBT_join ( ZLOG_BIND(localXaction, parms->parent); if (MYBT_IS_LEAF(child) ) { /* This is the deleted LEAF block we must write so that rebuild - * can scan whole disk and not find OLD beast tree leafs. - */ + * can scan whole disk and not find OLD beast tree leafs. + */ parms->sibling->state |= CACHE_DIRTY; ZLOG_BIND(localXaction, parms->sibling); #if 0 /* This code allows for testing of the recovery code of setting - * the magic word on deletes. - */ + * the magic word on deletes. + */ #if NSS_ASSERT IS_ENABLED { extern LONG gZlogAssertBlock; @@ -717,15 +716,15 @@ STATIC STATUS MYBT_balance ( avg = (child->numRecs + sibling->numRecs) / 2; - /* Dont do balancing if no records can be moved */ + /* Dont do balancing if no records can be moved */ if ((child->numRecs == avg) || (sibling->numRecs == avg)) { /* - * The entry we were looking for when we started the balance may be - * in either the child or the sibling entry. Make sure that it - * ends up in the child. - */ - if (treeInfo->keyComp(parms->key, + * The entry we were looking for when we started the balance may be + * in either the child or the sibling entry. Make sure that it + * ends up in the child. + */ + if (treeInfo->keyComp(parms->key, MYBT_BRANCHENTRY(treeInfo, parent, parms->index + 1)->key) >= 0) { CACHE_RELEASE(parms->child); @@ -733,7 +732,7 @@ STATIC STATUS MYBT_balance ( } else { - CACHE_RELEASE(parms->sibling); + CACHE_RELEASE(parms->sibling); } RTN_STATUS(zOK); } @@ -753,8 +752,8 @@ STATIC STATUS MYBT_balance ( /* move the entries from sibling to child */ memcpy(startLocation, /* Destination */ - MYBT_LEAFENTRY(treeInfo, sibling, 0), /* Source */ - lenMoved); + MYBT_LEAFENTRY(treeInfo, sibling, 0), /* Source */ + lenMoved); /* move sibling entries back to the front of the record */ memmove(MYBT_LEAFENTRY(treeInfo, sibling, 0), /* Destination */ @@ -780,8 +779,8 @@ STATIC STATUS MYBT_balance ( /* move the entries from the child to the sibling */ memcpy(startLocation, - MYBT_LEAFENTRY(treeInfo, child, child->numRecs - numToMove), - lenMoved); + MYBT_LEAFENTRY(treeInfo, child, child->numRecs - numToMove), + lenMoved); child->numRecs -= numToMove; sibling->numRecs += numToMove; @@ -798,8 +797,8 @@ STATIC STATUS MYBT_balance ( /* move the entries from sibling to child */ memcpy(startLocation, /* Destination */ - MYBT_BRANCHENTRY(treeInfo, sibling, 0), /* Source */ - lenMoved); + MYBT_BRANCHENTRY(treeInfo, sibling, 0), /* Source */ + lenMoved); /* move sibling entries back to the front of the record */ memmove(MYBT_BRANCHENTRY(treeInfo, sibling, 0), /* Destination */ @@ -825,8 +824,8 @@ STATIC STATUS MYBT_balance ( /* move the entries from the child to the sibling */ memcpy(startLocation, - MYBT_BRANCHENTRY(treeInfo, child, child->numRecs - numToMove), - lenMoved); + MYBT_BRANCHENTRY(treeInfo, child, child->numRecs - numToMove), + lenMoved); child->numRecs -= numToMove; sibling->numRecs += numToMove; @@ -894,7 +893,7 @@ STATIC STATUS MYBT_balance ( ZLOG_ReleaseRecordAndLogEnd(localXaction); EndXlocal(localXaction); - if (treeInfo->keyComp(parms->key, + if (treeInfo->keyComp(parms->key, MYBT_BRANCHENTRY(treeInfo, parent, parms->index + 1)->key) >= 0) { MYBT_VALIDATE_NODE(treeInfo, (MYBTreeNode_s *)parms->child->pBuf.data); @@ -946,7 +945,7 @@ STATIC STATUS MYBT_underflow ( parms->sibling = MYBT_ReadPoolBlk(treeInfo, genMsg, &iomsg); if (parms->sibling == NULL) { - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } MYBT_VALIDATE_NODE(treeInfo, (MYBTreeNode_s *)parms->sibling->pBuf.data); } @@ -958,9 +957,9 @@ STATIC STATUS MYBT_underflow ( READBLK_IO_MSG(iomsg, btreeBeast, parms->readBlkNum, CACHE_UPDATE); SET_DEBUG_ID(iomsg, 2); /* - * Release the latch so we do not latch out of order -- This is - * OK because the parent latch is held. - */ + * Release the latch so we do not latch out of order -- This is + * OK because the parent latch is held. + */ CACHE_PIN(parms->sibling); CACHE_UNXLATCH(parms->sibling); parms->child = MYBT_ReadPoolBlk(treeInfo, genMsg, &iomsg); @@ -969,7 +968,7 @@ STATIC STATUS MYBT_underflow ( if (parms->child == NULL) { CACHE_RELEASE(parms->sibling); - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } MYBT_VALIDATE_NODE(treeInfo, (MYBTreeNode_s *)parms->child->pBuf.data); } @@ -1048,7 +1047,7 @@ STATIC STATUS MYBT_shrink ( ZLOG_ObtainRecord(localXaction, ZLOG_BLOCK_INFO_SIZE(2) + sizeof(MYBTGrow_s)); ZLOG_INIT_LOG_RECORD( - (treeInfo->internalRecoveryStartOpCode + MYBT_RECOVERY_OP_SHRINK), + (treeInfo->internalRecoveryStartOpCode + MYBT_RECOVERY_OP_SHRINK), localXaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[0], rootBlkNum, @@ -1212,9 +1211,9 @@ STATIC STATUS MYBT_split ( parms->readBlkNum = parms->child->volBlk; /* - * Sibling is the node to be split. It is the left node in the split. - * Child is the new node. - */ + * Sibling is the node to be split. It is the left node in the split. + * Child is the new node. + */ child = (MYBTreeNode_s *)parms->child->pBuf.data; holdState = sibling->state & MYBT_LEAF; @@ -1255,8 +1254,8 @@ STATIC STATUS MYBT_split ( } /* - * Make room in the Parent to place the node - */ + * Make room in the Parent to place the node + */ i = parms->index + 1; memmove(MYBT_BRANCHENTRY(treeInfo, parent, i + 1), /* Destination */ MYBT_BRANCHENTRY(treeInfo, parent, i), /* Source */ @@ -1514,12 +1513,12 @@ STATIC void MYBT_logInsertRecord ( MYBT_VALIDATE_NODE(treeInfo, child); ZLOG_ObtainRecord(parms->xaction, - ZLOG_BLOCK_INFO_SIZE(1) + sizeof(MybtLogicalLog_s) - 1 + + ZLOG_BLOCK_INFO_SIZE(1) + sizeof(MybtLogicalLog_s) - 1 + MYBT_ENTRY_SIZE(treeInfo)); ZLOG_INIT_LOG_RECORD( - (treeInfo->logicalRecoveryStartOpCode + - MYBT_RECOVERY_L_OP_INSERT_ENTRY), + (treeInfo->logicalRecoveryStartOpCode + + MYBT_RECOVERY_L_OP_INSERT_ENTRY), parms->xaction, logBuffer, 1, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[0], parms->child->volBlk, child->lsn, parms->child, parms->xaction, 0, MYBT_compare); @@ -1554,17 +1553,17 @@ STATIC STATUS MYBT_insertEntryIntoNode ( MYBTreeInstanceInfo_s *treeInfo = parms->treeInfo; /* - * This routine assumes a check has ready been done to make sure there - * there is enough free space in the buffer to hold the new znode. - */ + * This routine assumes a check has ready been done to make sure there + * there is enough free space in the buffer to hold the new znode. + */ ENTER(TZTREE, MYBT_insertEntryIntoNode); child = (MYBTreeNode_s *)parms->child->pBuf.data; /* - * Add the entry to the leaf node - */ + * Add the entry to the leaf node + */ if (MYBT_findLeafEntry(treeInfo, child, parms->key, &i)) { if (parms->updateCallback == NULL) @@ -1574,14 +1573,14 @@ STATIC STATUS MYBT_insertEntryIntoNode ( RTN_STATUS(zFAILURE); } /* We found an entry in the tree. updateCallBack is non-NULL, - * so call the callback routine. The callback routine will - * return the modified value to be inserted, in the newValue - * field, which is value, which is a pointer to the parms->value. - * Next we do a delete of the entry and the insert code will - * insert it, resulting in an update. - */ - if (parms->updateCallback( genMsg, - MYBT_LEAF_IND_VALUE(treeInfo, child, i), + * so call the callback routine. The callback routine will + * return the modified value to be inserted, in the newValue + * field, which is value, which is a pointer to the parms->value. + * Next we do a delete of the entry and the insert code will + * insert it, resulting in an update. + */ + if (parms->updateCallback( genMsg, + MYBT_LEAF_IND_VALUE(treeInfo, child, i), value) != zOK) { RTN_STATUS(zFAILURE); @@ -1610,7 +1609,7 @@ STATIC STATUS MYBT_insertEntryIntoNode ( * * Input: Child and parent are latched. Child is buffer to inserted into. * - * Output: Parent and child are unlatched. + * Output: Parent and child are unlatched. ****************************************************************************/ STATIC STATUS MYBT_doInsertEntry ( GeneralMsg_s *genMsg, @@ -1712,7 +1711,7 @@ STATIC STATUS MYBT_findLeaf ( { if (MYBT_IS_ROOT(node)) { - UNX_LATCH(&parms->btreeBeast->ZFSMYBTREEbeastLatch); + UNX_LATCH(&parms->btreeBeast->ZFSMYBTREEbeastLatch); } } if (!MYBT_IS_ROOT(node)) @@ -1760,8 +1759,8 @@ STATUS MYBT_insertEntry ( ENTER(TZTREE, MYBT_insertEntry); /* - * Get an exclusive latch on the Tree Beast - */ + * Get an exclusive latch on the Tree Beast + */ X_LATCH(&btreeBeast->ZFSMYBTREEbeastLatch); if (btreeBeast->zfsBtree.p.btRoot == INVALID_BLK) @@ -1796,7 +1795,7 @@ STATUS MYBT_insertEntry ( /* log the init record */ ZLOG_ObtainRecord(localXaction, - ZLOG_BLOCK_INFO_SIZE(1) + sizeof(MYBTTreeInit_s) ); + ZLOG_BLOCK_INFO_SIZE(1) + sizeof(MYBTTreeInit_s) ); ZLOG_INIT_LOG_RECORD( (treeInfo->internalRecoveryStartOpCode + MYBT_RECOVERY_OP_INIT), @@ -1888,8 +1887,8 @@ STATUS MYBT_lookupEntry( MYBTreeInstanceInfo_s *treeInfo = parms->treeInfo; /* - * Get an exclusive latch on the B-Tree Beast - */ + * Get an exclusive latch on the B-Tree Beast + */ S_LATCH(&btreeBeast->ZFSMYBTREEbeastLatch); if (btreeBeast->zfsBtree.p.btRoot == INVALID_BLK) { @@ -1897,7 +1896,7 @@ STATUS MYBT_lookupEntry( SetErrno(genMsg, zERR_ZID_NOT_FOUND); RTN_STATUS(zFAILURE); } - + /* read the root node */ READBLK_IO_MSG(iomsg, btreeBeast, btreeBeast->zfsBtree.p.btRoot, CACHE_READ); @@ -1911,7 +1910,7 @@ STATUS MYBT_lookupEntry( RTN_STATUS(zFAILURE); } MYBT_VALIDATE_NODE(treeInfo, (MYBTreeNode_s *)parms->child->pBuf.data); - + /* decend the tree to the leaf */ if (MYBT_getLeaf(genMsg, parms) != zOK) { @@ -1928,7 +1927,7 @@ STATUS MYBT_lookupEntry( CACHE_RELEASE(parms->child); RTN_STATUS(zFAILURE); } - else + else { MYBT_valueCopy(treeInfo, parms->value, MYBT_LEAF_IND_VALUE(treeInfo, node, index)); } @@ -1962,21 +1961,21 @@ STATIC void MYBT_logDeleteRecord ( MYBT_VALIDATE_NODE(treeInfo, child); ZLOG_ObtainRecord(parms->xaction, - ZLOG_BLOCK_INFO_SIZE(1) + sizeof(MybtLogicalLog_s) - 1 + + ZLOG_BLOCK_INFO_SIZE(1) + sizeof(MybtLogicalLog_s) - 1 + MYBT_ENTRY_SIZE(treeInfo)); ZLOG_INIT_LOG_RECORD( - (treeInfo->logicalRecoveryStartOpCode + - MYBT_RECOVERY_L_OP_DELETE_ENTRY), + (treeInfo->logicalRecoveryStartOpCode + + MYBT_RECOVERY_L_OP_DELETE_ENTRY), parms->xaction, logBuffer, 1, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[0], parms->child->volBlk, child->lsn, parms->child, parms->xaction, 0, MYBT_compare); logRecord->internalVolumeID = parms->btreeBeast->ZFSMYBTREEroot.ROOTinternalID; logRecord->btreeBeastZid = parms->btreeBeast->ZFSMYBTREEzid; - MYBT_keyCopy(treeInfo, MYBT_LEAFENTRY_KEY(treeInfo, logRecord->u.entry), + MYBT_keyCopy(treeInfo, MYBT_LEAFENTRY_KEY(treeInfo, logRecord->u.entry), MYBT_LEAF_IND_KEY(treeInfo, child, index)); - MYBT_valueCopy(treeInfo, MYBT_LEAFENTRY_VALUE(treeInfo, logRecord->u.entry), + MYBT_valueCopy(treeInfo, MYBT_LEAFENTRY_VALUE(treeInfo, logRecord->u.entry), MYBT_LEAF_IND_VALUE(treeInfo, child, index)); #if LOG_TEST IS_ENABLED holdLsn = logBuffer->ZXR_Lsn; /* this is done so the lsn will be ok for testing */ @@ -2009,7 +2008,7 @@ STATIC void MYBT_deleteLeafEntry( { memmove(MYBT_LEAFENTRY(treeInfo, node, index), /* destination */ MYBT_LEAFENTRY(treeInfo, node, index+1), /* source */ - (node->numRecs - (index + 1)) * MYBT_LEAFENTRY_SIZE(treeInfo)); + (node->numRecs - (index + 1)) * MYBT_LEAFENTRY_SIZE(treeInfo)); } node->numRecs--; MYBT_VALIDATE_NODE(treeInfo, node); @@ -2077,7 +2076,7 @@ STATUS MYBT_deleteEntry ( errorExit: //zASSERT(0); CACHE_DIRTY_RELEASE(parms->child); - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } @@ -2114,10 +2113,10 @@ STATUS MYBT_browseEntries( UNS_LATCH(&btreeBeast->ZFSMYBTREEbeastLatch); goto done; } - + /* - * Find the next key after *parms->key. - */ + * Find the next key after *parms->key. + */ /* read the root node */ READBLK_IO_MSG(iomsg, btreeBeast, btreeBeast->zfsBtree.p.btRoot, @@ -2147,17 +2146,17 @@ STATUS MYBT_browseEntries( } ++ index; /* Skip the last matched entry */ - /* - * Return the next numEntriesReturned entries - * by sequentially scanning the tree's leaf nodes - * - * Sequentially scan the linked list of leaf nodes for beasts to return - * (starting at the beast at (parms->child, index)). - */ + /* + * Return the next numEntriesReturned entries + * by sequentially scanning the tree's leaf nodes + * + * Sequentially scan the linked list of leaf nodes for beasts to return + * (starting at the beast at (parms->child, index)). + */ for (; entryIndex < numEntriesRequested; entryIndex++, index++) { /* Skip to a leaf node with entries to process */ - if (index >= node->numRecs) + if (index >= node->numRecs) { /* Jump to the next leaf node */ if (node->n.leaf.nextLeaf == INVALID_BLK) @@ -2180,7 +2179,7 @@ STATUS MYBT_browseEntries( } /* Add the entry to the list of entries returned */ - memmove(entries, MYBT_LEAFENTRY(treeInfo, node, index), + memmove(entries, MYBT_LEAFENTRY(treeInfo, node, index), MYBT_LEAFENTRY_SIZE(treeInfo)); lastKey = MYBT_LEAFENTRY_KEY(treeInfo, entries); entries += MYBT_LEAFENTRY_SIZE(treeInfo); @@ -2233,8 +2232,8 @@ STATUS MYBT_resetTree( zASSERT(!(volume->VOLenabledAttributes & zATTR_READONLY)); /* - * Get an exclusive latch on the B-Tree Beast - */ + * Get an exclusive latch on the B-Tree Beast + */ X_LATCH(&btreeBeast->ZFSMYBTREEbeastLatch); if (btreeBeast->zfsBtree.p.btRoot == INVALID_BLK) @@ -2268,9 +2267,9 @@ STATUS MYBT_resetTree( node = (MYBTreeNode_s *)buffer->pBuf.data; if (MYBT_IS_LEAF(node)) { /* - * If it is a leaf then set up so on the next loop it will be - * deleted. - */ + * If it is a leaf then set up so on the next loop it will be + * deleted. + */ zASSERT(node->magic == MYBT_LEAF_MAGIC(treeInfo)); cacheReleaseToss(buffer); readALeaf = TRUE; @@ -2286,9 +2285,9 @@ STATUS MYBT_resetTree( } else { /* - * it's a branch -- push on the stack and move on to its first - * child - */ + * it's a branch -- push on the stack and move on to its first + * child + */ readALeaf = FALSE; zASSERT(node->magic == MYBT_BRANCH_MAGIC(treeInfo)); @@ -2320,12 +2319,12 @@ STATUS MYBT_resetTree( node = (MYBTreeNode_s *)buffer->pBuf.data; /* - * If we have read all of the child records we can now delete - * them. - * - * If one of the children was a leaf they all will be so there - * is no reason to read them all. Just delete them. - */ + * If we have read all of the child records we can now delete + * them. + * + * If one of the children was a leaf they all will be so there + * is no reason to read them all. Just delete them. + */ aStack->parentStack[stkPtr].entry++; if ((aStack->parentStack[stkPtr].entry >= node->numRecs) || readALeaf) { @@ -2337,15 +2336,15 @@ STATUS MYBT_resetTree( ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2)); ZLOG_INIT_LOG_RECORD( - (treeInfo->internalRecoveryStartOpCode - + MYBT_RECOVERY_OP_REMOVE_NODE), + (treeInfo->internalRecoveryStartOpCode + + MYBT_RECOVERY_OP_REMOVE_NODE), xaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, node->lsn, buffer, xaction, 0); node->lsn = logBuffer->ZXR_Lsn; node->numRecs--; - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], MYBT_BRANCHENTRY(treeInfo, node, node->numRecs)->child, 0, NULL, xaction, 1); ZLOG_DELETE_BLOCK(xaction, poolBlks[1]); @@ -2380,21 +2379,21 @@ STATUS MYBT_resetTree( ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2)); - ZLOG_INIT_LOG_RECORD((treeInfo->internalRecoveryStartOpCode + - MYBT_RECOVERY_OP_REMOVE_NODE), + ZLOG_INIT_LOG_RECORD((treeInfo->internalRecoveryStartOpCode + + MYBT_RECOVERY_OP_REMOVE_NODE), xaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], 0, 0, NULL, xaction, 0); - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], btreeBeast->zfsBtree.p.btRoot, 0, + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], btreeBeast->zfsBtree.p.btRoot, 0, NULL, xaction, 0); ZLOG_DELETE_BLOCK(xaction, poolBlks[1]); ZLOG_ReleaseRecord(xaction); /* - * Fix up the btree beast to show no tree - */ + * Fix up the btree beast to show no tree + */ btreeBeast->zfsBtree.p.btRoot = INVALID_BLK; COMN_MARK_BEAST_XLOCAL(&btreeBeast->ZFSMYBTREEroot, &xaction->xaction); @@ -2596,7 +2595,7 @@ STATIC STATUS MYBT_recoveryGrow( node->numRecs = 1; treeInfo->setZeroKey(MYBT_BRANCH_IND_KEY(treeInfo, node, 0)); MYBT_BRANCHENTRY(treeInfo, node, 0)->child = logRecord->u.grow.blockForParent; - MYBT_BRANCHENTRY(treeInfo, node, 0)->reserved = 0; + MYBT_BRANCHENTRY(treeInfo, node, 0)->reserved = 0; ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); CACHE_DIRTY_RELEASE(buffer); } @@ -2682,8 +2681,8 @@ STATIC STATUS MYBT_recoveryBalance( } else { - MYBT_keyCopy(treeInfo, MYBT_BRANCHENTRY(treeInfo, node, logRecord->u.balance.indexForParent)->key, - oldKey); + MYBT_keyCopy(treeInfo, MYBT_BRANCHENTRY(treeInfo, node, logRecord->u.balance.indexForParent)->key, + oldKey); } ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); MYBT_VALIDATE_NODE(treeInfo, node); @@ -2715,7 +2714,7 @@ STATIC STATUS MYBT_recoveryBalance( if (MYBT_IS_LEAF(node)) { /* leaf */ numToMove = logRecord->u.balance.numToMove; - if ((numToMove > 0) && + if ((numToMove > 0) && treeInfo->keyComp( MYBT_LEAFENTRY_KEY(treeInfo, &logRecord->u.balance.data[0]), MYBT_LEAF_IND_KEY(treeInfo, node, 0)) == 0) @@ -2728,7 +2727,7 @@ STATIC STATUS MYBT_recoveryBalance( else { /* branch */ numToMove = logRecord->u.balance.numToMove; - if ((numToMove > 0) && + if ((numToMove > 0) && treeInfo->keyComp( &((MYBTBranchEntry_s *)&logRecord->u.balance.data[0])->key, MYBT_BRANCHENTRY(treeInfo, node, 0)->key) == 0) @@ -2881,8 +2880,8 @@ STATIC STATUS MYBT_recoveryJoin( --(node->numRecs); i = logRecord->u.split.indexForParent; memmove( MYBT_BRANCHENTRY(treeInfo, node, i), /* Destination */ - MYBT_BRANCHENTRY(treeInfo, node, i + 1), /* Source */ - (node->numRecs - i) * MYBT_BRANCHENTRY_SIZE(treeInfo)); + MYBT_BRANCHENTRY(treeInfo, node, i + 1), /* Source */ + (node->numRecs - i) * MYBT_BRANCHENTRY_SIZE(treeInfo)); ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); MYBT_VALIDATE_NODE(treeInfo, node); CACHE_DIRTY_RELEASE(buffer); @@ -3014,7 +3013,7 @@ STATIC STATUS MYBT_recoverySplit( MYBT_BRANCHENTRY(treeInfo, node, i), /* Source */ (node->numRecs - i) * MYBT_BRANCHENTRY_SIZE(treeInfo)); ++(node->numRecs); - keyForParent = + keyForParent = &logRecord->u.split.data[logRecord->u.split.dataLength]; MYBT_keyCopy(treeInfo, MYBT_BRANCHENTRY(treeInfo, node, i)->key, keyForParent); MYBT_BRANCHENTRY(treeInfo, node, i)->child = logRecord->u.split.blockForParent; @@ -3208,7 +3207,7 @@ STATIC STATUS MYBT_recoveryInsertEntry( parms.key = MYBT_LEAFENTRY_KEY(&parms, &logRecord->u.entry[0]); parms.updateCallback = NULL; - if (MYBT_insertEntryIntoNode(genMsg, &parms, + if (MYBT_insertEntryIntoNode(genMsg, &parms, MYBT_LEAFENTRY_VALUE(treeInfo, logRecord->u.entry)) != zOK) { CACHE_RELEASE(buffer); diff --git a/src/nwnss/zlss/myBTree.h b/src/nwnss/zlss/myBTree.h index 1bcf28d..6946fdc 100644 --- a/src/nwnss/zlss/myBTree.h +++ b/src/nwnss/zlss/myBTree.h @@ -53,7 +53,7 @@ /* Pre-declare the following structure(s) */ struct ZfsXasRecovery_s; - + #define MYBT_getOwnerID(_beast) ((_beast)->ROOTownerID) #define MYBT_LEAF_MAGIC(_treeInfo) (_treeInfo)->leafMagic @@ -122,28 +122,28 @@ typedef struct MYBTreeParms_s { MYBTreeInstanceInfo_s *treeInfo; /* B-Tree instance-specific information */ MYBTKey_t key; /* the key to be used */ - Volume_s *volume; - Blknum_t readBlkNum; /* Next block to be read */ - NINT index; /* Where last record was found in parent*/ + Volume_s *volume; + Blknum_t readBlkNum; /* Next block to be read */ + NINT index; /* Where last record was found in parent*/ MYBTValue_t value; /* The value being set */ - Buffer_s *parent; /* Parent buffer */ - Buffer_s *child; /* Child buffer */ - Buffer_s *sibling; /* Sibling buffer */ - struct ZfsXaction_s *xaction; /* Transaction being used */ - struct ZfsMYBTreeBeast_s *btreeBeast; /* The pointer to the b-tree beast */ - STATUS (*updateCallback)( - GeneralMsg_s *genMsg, - MYBTValue_t oldValue, - MYBTValue_t newValue); - /* Set to NULL for insert * and no update. - * Otherwise to update the value - * define the callback routine. This - * routine will be called with the existing - * value and the value asked to be inserted - * The newValue will be changed to reflect - * the updated value to be inserted back - * in the tree - */ + Buffer_s *parent; /* Parent buffer */ + Buffer_s *child; /* Child buffer */ + Buffer_s *sibling; /* Sibling buffer */ + struct ZfsXaction_s *xaction; /* Transaction being used */ + struct ZfsMYBTreeBeast_s *btreeBeast; /* The pointer to the b-tree beast */ + STATUS (*updateCallback)( + GeneralMsg_s *genMsg, + MYBTValue_t oldValue, + MYBTValue_t newValue); + /* Set to NULL for insert * and no update. + * Otherwise to update the value + * define the callback routine. This + * routine will be called with the existing + * value and the value asked to be inserted + * The newValue will be changed to reflect + * the updated value to be inserted back + * in the tree + */ } MYBTreeParms_s; /* @@ -151,7 +151,7 @@ typedef struct MYBTreeParms_s */ typedef struct MYBTBranchEntry_s { - Blknum_t child; + Blknum_t child; LONG reserved; /* to align key to 64-bit boundary */ BYTE key[1]; } NSS_MEDIA_STRUCTURE(MYBTBranchEntry_s,key[1]) MYBTBranchEntry_s; @@ -182,28 +182,28 @@ typedef struct MYBTBranchEntry_s typedef struct MYBTreeNode_s { - /* - * If the size of the header portion changes then change - * MYBT_MAX_BRANCH_ENTRIES and MYBT_MAX_LEAF_ENTRIES. - */ - LONG magic; - WORD state; - WORD numRecs; - Lsn_t lsn; + /* + * If the size of the header portion changes then change + * MYBT_MAX_BRANCH_ENTRIES and MYBT_MAX_LEAF_ENTRIES. + */ + LONG magic; + WORD state; + WORD numRecs; + Lsn_t lsn; GUID_t utn_internalID; /* Must be at OFFSET 16 - unique volume ID (used - * by scanning repair). utn -> User Tree Node. - */ - union - { + * by scanning repair). utn -> User Tree Node. + */ + union + { struct NSSFakeNameRJ4 { LONG v_entry; } NSS_MEDIA_STRUCTURE(NSSFakeNameRJ4,entry) branch; struct NSSFakeNameHU8{ - Blknum_t nextLeaf; /* link to the next leaf in the tree */ + Blknum_t nextLeaf; /* link to the next leaf in the tree */ LONG reserved; /* To align entries to 64-bit boundary */ LONG vv_entry; } NSS_MEDIA_STRUCTURE(NSSFakeNameHU8,entry) leaf; - } NSS_MEDIA_UNION(NamelessUnion,leaf.entry) n; + } NSS_MEDIA_UNION(NamelessUnion,leaf.entry) n; } NSS_MEDIA_STRUCTURE(MYBTreeNode_s,n.leaf.entry) MYBTreeNode_s; #define MYBT_MAX_BRANCH_ENTRIES(_treeInfo) \ @@ -218,19 +218,19 @@ typedef struct MYBTreeNode_s #define MYBT_MIN_LEAF_ENTRIES(_treeInfo) (MYBT_MAX_LEAF_ENTRIES(_treeInfo) / 2) #define MYBT_IS_MAX_ENTRIES(_treeInfo, _node) \ - (MYBT_IS_LEAF(_node) \ - ? ((_node)->numRecs >= MYBT_MAX_LEAF_ENTRIES(_treeInfo)) \ - : ((_node)->numRecs >= MYBT_MAX_BRANCH_ENTRIES(_treeInfo))) + (MYBT_IS_LEAF(_node) \ + ? ((_node)->numRecs >= MYBT_MAX_LEAF_ENTRIES(_treeInfo)) \ + : ((_node)->numRecs >= MYBT_MAX_BRANCH_ENTRIES(_treeInfo))) #define MYBT_IS_MIN_ENTRIES(_treeInfo, _node) \ - (MYBT_IS_LEAF(_node) \ - ? ((_node)->numRecs <= MYBT_MIN_LEAF_ENTRIES(_treeInfo)) \ - : ((_node)->numRecs <= MYBT_MIN_BRANCH_ENTRIES(_treeInfo))) + (MYBT_IS_LEAF(_node) \ + ? ((_node)->numRecs <= MYBT_MIN_LEAF_ENTRIES(_treeInfo)) \ + : ((_node)->numRecs <= MYBT_MIN_BRANCH_ENTRIES(_treeInfo))) #define MYBT_IS_LESSTHAN_MAX(_treeInfo, _node, _sibling) \ - (MYBT_IS_LEAF(_node) \ - ? (((_node)->numRecs + (_sibling)->numRecs) < MYBT_MAX_LEAF_ENTRIES(_treeInfo)) \ - : (((_node)->numRecs + (_sibling)->numRecs) < MYBT_MAX_BRANCH_ENTRIES(_treeInfo))) + (MYBT_IS_LEAF(_node) \ + ? (((_node)->numRecs + (_sibling)->numRecs) < MYBT_MAX_LEAF_ENTRIES(_treeInfo)) \ + : (((_node)->numRecs + (_sibling)->numRecs) < MYBT_MAX_BRANCH_ENTRIES(_treeInfo))) /* * Structures and defines for log records for the user b-tree. @@ -244,14 +244,14 @@ typedef struct MYBTEntry_s typedef struct MYBTSplit_s { GUID_t internalID; - Blknum_t leafLink; /* link to the next leaf in the tree */ - Blknum_t blockForParent; /* block number to insert in the parent */ - LONG indexForParent; /* index where zid is inserted in the parent */ - LONG dataLength; /* length of tree information being moved */ - WORD numToMove; /* number of entries logged */ - WORD nodeType; /* whether the new node is a branch or a leaf */ + Blknum_t leafLink; /* link to the next leaf in the tree */ + Blknum_t blockForParent; /* block number to insert in the parent */ + LONG indexForParent; /* index where zid is inserted in the parent */ + LONG dataLength; /* length of tree information being moved */ + WORD numToMove; /* number of entries logged */ + WORD nodeType; /* whether the new node is a branch or a leaf */ LONG reserved; /* to align data to 64-bit boundary */ - BYTE data[1]; /* data to move */ + BYTE data[1]; /* data to move */ #if 0 MYBTKey_s keyForParent; /* Key to insert in the parent */ #endif /* 0 */ @@ -260,17 +260,17 @@ typedef struct MYBTSplit_s typedef struct MYBTGrow_s { GUID_t internalID; - Blknum_t blockForParent; /* block number to insert in the parent */ + Blknum_t blockForParent; /* block number to insert in the parent */ } NSS_MEDIA_STRUCTURE(MYBTGrow_s,blockForParent) MYBTGrow_s; typedef struct MYBTBalance_s { - LONG indexForParent; /* index where entry is changed in the parent */ - LONG dataLength; /* length of tree information being moved */ - WORD numToMove; /* number of entries moved */ + LONG indexForParent; /* index where entry is changed in the parent */ + LONG dataLength; /* length of tree information being moved */ + WORD numToMove; /* number of entries moved */ WORD reserved1; /* to align data to 64-bit boundary */ LONG reserved2; /* to align data to 64-bit boundary */ - BYTE data[1]; /* data to move */ + BYTE data[1]; /* data to move */ #if 0 MYBTKey_s oldKey; /* previous key in the parent */ MYBTKey_s keyForParent; /* key to insert in the parent */ @@ -291,13 +291,13 @@ typedef struct MYBTTreeInit_s */ typedef struct MybtInternalLog_s { - union - { - MYBTSplit_s split; - MYBTGrow_s grow; - MYBTBalance_s balance; - MYBTTreeInit_s initTree; - } NSS_MEDIA_UNION(NamelessUnion,balance.data[1]) u; + union + { + MYBTSplit_s split; + MYBTGrow_s grow; + MYBTBalance_s balance; + MYBTTreeInit_s initTree; + } NSS_MEDIA_UNION(NamelessUnion,balance.data[1]) u; } NSS_MEDIA_STRUCTURE(MybtInternalLog_s,u.balance.data[1]) MybtInternalLog_s; /* Tree-internal operations */ @@ -311,11 +311,11 @@ typedef struct MybtInternalLog_s #define MYBT_RECOVERY_MAX_INTERNAL_OPS 7 typedef STATUS (* MYBTInternalRecovery_f)( - struct GeneralMsg_s *genMsg, + struct GeneralMsg_s *genMsg, MYBTreeInstanceInfo_s *treeInfo, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); /* redo routine stored at even index, undo routine at odd index */ extern MYBTInternalRecovery_f MYBTreeInternalRecoveryFuncTable[ @@ -328,7 +328,7 @@ extern MYBTInternalRecovery_f MYBTreeInternalRecoveryFuncTable[ (((_action) == X_REDO) ? 0 : 1)] \ (_genMsg, _treeInfo, _pool, _logBuf, _action) -/* +/* * Structure of log records for BTree-interface operations. * Tree instances can use this structure to obtain the volume ID and * btree beast ZID during recovery. @@ -337,7 +337,7 @@ typedef struct MybtLogicalLog_s { GUID_t internalVolumeID; Zid_t btreeBeastZid; - union + union { BYTE entry[1]; } NSS_MEDIA_UNION(NamelessUnion,entry[1]) u; @@ -350,12 +350,12 @@ typedef struct MybtLogicalLog_s #define MYBT_RECOVERY_MAX_LOGICAL_OPS 3 typedef STATUS (* MYBTLogicalRecovery_f)( - struct GeneralMsg_s *genMsg, + struct GeneralMsg_s *genMsg, MYBTreeInstanceInfo_s *treeInfo, - struct ZfsPool_s *pool, - struct ZfsMYBTreeBeast_s *btreeBeast, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct ZfsPool_s *pool, + struct ZfsMYBTreeBeast_s *btreeBeast, + struct ZfsXasRecovery_s *logBuffer, + NINT action); /* redo routine stored at even index, undo routine at odd index */ extern MYBTLogicalRecovery_f MYBTreeLogicalRecoveryFuncTable[ @@ -372,23 +372,23 @@ extern MYBTLogicalRecovery_f MYBTreeLogicalRecoveryFuncTable[ * MYBTree Interface operations. */ STATUS MYBT_insertEntry( - GeneralMsg_s *genMsg, - MYBTreeParms_s *parms); + GeneralMsg_s *genMsg, + MYBTreeParms_s *parms); STATUS MYBT_deleteEntry ( - GeneralMsg_s *genMsg, - MYBTreeParms_s *parms); + GeneralMsg_s *genMsg, + MYBTreeParms_s *parms); STATUS MYBT_lookupEntry( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, MYBTreeParms_s *parms); STATUS MYBT_browseEntries( - GeneralMsg_s *genMsg, - MYBTreeParms_s *parms, - NINT numEntriesRequested, - BYTE *userEntries, /* out */ - NINT *numEntriesReturned); /* out */ + GeneralMsg_s *genMsg, + MYBTreeParms_s *parms, + NINT numEntriesRequested, + BYTE *userEntries, /* out */ + NINT *numEntriesReturned); /* out */ STATUS MYBT_resetTree( GeneralMsg_s *genMsg, @@ -398,18 +398,18 @@ STATUS MYBT_resetTree( BOOL MYBT_validateNode( MYBTreeInstanceInfo_s *treeInfo, - MYBTreeNode_s *node, + MYBTreeNode_s *node, BOOL dontAssert); #if NSS_DEBUG IS_ENABLED void MYBT_displayTree( MYBTreeInstanceInfo_s *treeInfo, - ZfsMYBTreeBeast_s *ztree); + ZfsMYBTreeBeast_s *ztree); void MYBT_displayNode( MYBTreeInstanceInfo_s *treeInfo, - char *location, - char *nameOfBuffer, + char *location, + char *nameOfBuffer, Buffer_s *buffer); #endif /* NSS_DEBUG */ diff --git a/src/nwnss/zlss/nameTree.c b/src/nwnss/zlss/nameTree.c index b1c5472..2261db9 100644 --- a/src/nwnss/zlss/nameTree.c +++ b/src/nwnss/zlss/nameTree.c @@ -59,19 +59,19 @@ STATUS node_verify_magic( */ #if NSS_DEBUG IS_ENABLED STATUS fetch_ntree_blk( - NameTreeParms_s *_parms, - Blknum_t _blk, - Buffer_s **_buf, - Latch_mode_t _mode, + NameTreeParms_s *_parms, + Blknum_t _blk, + Buffer_s **_buf, + Latch_mode_t _mode, BOOL _verify_magic, - NINT _debug_id) + NINT _debug_id) #else STATUS fetch_ntree_blk( - NameTreeParms_s *_parms, - Blknum_t _blk, - Buffer_s **_buf, + NameTreeParms_s *_parms, + Blknum_t _blk, + Buffer_s **_buf, Latch_mode_t _mode, - BOOL _verify_magic) + BOOL _verify_magic) #endif { STATUS status; @@ -81,8 +81,8 @@ STATUS fetch_ntree_blk( #if NSS_DEBUG IS_ENABLED SET_DEBUG_ID((_parms)->iomsg, _debug_id); #endif - status = (((*(_buf) = ZFS_ReadPoolBlk((_parms)->genMsg, - &(_parms)->iomsg)) == NULL) + status = (((*(_buf) = ZFS_ReadPoolBlk((_parms)->genMsg, + &(_parms)->iomsg)) == NULL) ? GetErrno((_parms)->genMsg) : zOK); if ((status == zOK) && (_verify_magic)) { @@ -111,8 +111,8 @@ NT_Allocate_Statistics_s NT_Allocs; STATUS alloc_ntree_blks( - NameTreeParms_s *parms, - ZfsXaction_s *xaction, + NameTreeParms_s *parms, + ZfsXaction_s *xaction, NINT nblks, Buffer_s **buf) { @@ -131,7 +131,7 @@ STATUS alloc_ntree_blks( if (status != zOK) break; } - if (i < nblks) + if (i < nblks) { zASSERT("Name Tree alloc failed (This is bad because we will not free the block)"==NULL); DEALLOC_NTREE_BLKS(parms, i, buf); @@ -146,8 +146,8 @@ STATUS alloc_ntree_blks( I/O performance. */ STATUS alloc_ntree_blks2( - NameTreeParms_s *parms, - ZfsXaction_s *xaction, + NameTreeParms_s *parms, + ZfsXaction_s *xaction, NINT nblks, Blknum_t *nearBlocks, /* The near block request type */ Buffer_s **buf) @@ -176,7 +176,7 @@ STATUS alloc_ntree_blks2( if (status != zOK) break; } - if (i < nblks) + if (i < nblks) { zASSERT("Name Tree alloc failed (This is bad because we will not free the block)"==NULL); DEALLOC_NTREE_BLKS(parms, i, buf); @@ -193,13 +193,13 @@ ntree_ch_root_node(NameTreeParms_s *parms, ZfsXaction_s *xaction, ZfsNameTree_s *ntree = parms->ntree; Blknum_t oldroot; - if (oldbuf) + if (oldbuf) { ((Node_s *)oldbuf->pBuf.data)->state &= ~NT_ROOT; oldroot = oldbuf->BUFblknum; } else oldroot = INVALID_BLK; - if (newbuf) + if (newbuf) { ((Node_s *)newbuf->pBuf.data)->state |= NT_ROOT; NTREE_SET_ROOT_BLK(ntree, newbuf->BUFblknum); @@ -207,7 +207,7 @@ ntree_ch_root_node(NameTreeParms_s *parms, ZfsXaction_s *xaction, else NTREE_SET_ROOT_BLK(ntree, INVALID_BLK); COMN_MARK_BEAST_XLOCAL(&ntree->ZFSNAMETREEroot, &xaction->xaction); if ((status = COMN_ForceBeastWrite(parms->genMsg, &ntree->ZFSNAMETREEroot, - &xaction->xaction)) != zOK) + &xaction->xaction)) != zOK) { NTREE_SET_ROOT_BLK(ntree, oldroot); } @@ -236,8 +236,8 @@ Zid_t ZFSVOL_VOL_LookupByNameInDirectory( ASSERT_LATCH(&directory->NAMEDbeastLatch); zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); parms.genMsg = genMsg; parms.ntree = directory->NAMEDroot.vol.zfsVol->nameTree; parms.xaction = (ZfsXaction_s *)0; @@ -251,14 +251,14 @@ Zid_t ZFSVOL_VOL_LookupByNameInDirectory( k.name = name; // cnt *retNameUniquifier = nameUniquifier; - fileZid = zINVALID_ZID; /* Return first matching nametree entry + fileZid = zINVALID_ZID; /* Return first matching nametree entry * when looking for a deleted file */ if (retInfo && (nameType == zNTYPE_DELETED_FILE)) fileZid = retInfo->zid; #if ADD_DELFILE_ZID_IN_NTREE_KEY k.zid = fileZid; #endif /* ADD_DELFILE_ZID_IN_NTREE_KEY */ - if ((status = DIR_LOOKUP(&parms, (dir_key_s *)&k, + if ((status = DIR_LOOKUP(&parms, (dir_key_s *)&k, (1<nSpaceID), &fileZid, /* cnt retNameUniquifier,*/ retInfo, nameSpace->nSpaceOps->unicodeCompareFileNames)) != zOK) { @@ -273,7 +273,7 @@ Zid_t ZFSVOL_VOL_LookupByNameInDirectory( // * This routine is not used; it's here just for compatibility // *****************************************************************************/ //STATUS ZFSVOL_InitDirectory( -// GeneralMsg_s *genMsg, +// GeneralMsg_s *genMsg, // NamedBeast_s *directory) //{ // ASSERT_XLATCH(&directory->NAMEDbeastLatch); @@ -286,7 +286,7 @@ Zid_t ZFSVOL_VOL_LookupByNameInDirectory( * that there is only one free entry in each block of the correct size. ***************************************************************************/ NINT ZFSVOL_VOL_IsDirectoryEmpty( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, NamedBeast_s *directory, NINT nameType) { @@ -296,14 +296,14 @@ NINT ZFSVOL_VOL_IsDirectoryEmpty( NINT NameSpacesLoadedMask = ((int)(1 << (MaxRegisteredNameSpaceID+1)))-1; typedef struct Stack_s { NameTreeParms_s parms; - SearchMap_s smap; + SearchMap_s smap; } Stack_s; STACK_ALLOC(); ASSERT_LATCH(&directory->NAMEDbeastLatch); zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); bzero(&aStack->smap, sizeof(aStack->smap)); aStack->smap.options = 0 | SMAPOPT_matchAllEntries; @@ -361,8 +361,8 @@ STATUS ZFSVOL_VOL_AddNameToDirectory( STATUS status; zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); ASSERT_XLATCH(&directory->NAMEDbeastLatch); zASSERT(!(directory->NAMEDvolume->VOLenabledAttributes & zATTR_READONLY)); @@ -377,12 +377,12 @@ STATUS ZFSVOL_VOL_AddNameToDirectory( * If the name being inserted is that of a deleted beast, add it to the * purge queue also. * The following assertion should always be TRUE: - * "If a name of a deleted file is in the name tree (i.e., + * "If a name of a deleted file is in the name tree (i.e., * nameType == DELETED), it should also be in the purge queue". */ - if ((nameType == zNTYPE_DELETED_FILE) && (addNameFlags & NF_LAST_NAME)) + if ((nameType == zNTYPE_DELETED_FILE) && (addNameFlags & NF_LAST_NAME)) { - status = purgeq_insert_name(genMsg, + status = purgeq_insert_name(genMsg, directory->NAMEDroot.vol.zfsVol->ZFSVOLpurgeTree, nameTypeInfo->u.deleted.time, &directory->NAMEDroot.ROOTinternalID, @@ -403,7 +403,7 @@ STATUS ZFSVOL_VOL_AddNameToDirectory( if ((status = DIR_INSERT(&parms, (dir_key_s *)&k,nameSpaceMask, - beast->NAMEDzid, /* cnt nameUniquifier,*/ matchAttributes)) != zOK) + beast->NAMEDzid, /* cnt nameUniquifier,*/ matchAttributes)) != zOK) { if ((nameType == zNTYPE_DELETED_FILE) && (addNameFlags & NF_LAST_NAME)) { @@ -414,14 +414,14 @@ STATUS ZFSVOL_VOL_AddNameToDirectory( directory->NAMEDroot.vol.zfsVol->ZFSVOLpurgeTree, nameTypeInfo->u.deleted.time, &directory->NAMEDroot.ROOTinternalID, - beast->NAMEDzid, /* cnt nameUniquifier,*/ k.pzid, xact); + beast->NAMEDzid, /* cnt nameUniquifier,*/ k.pzid, xact); zASSERT(rc == zOK); } - SetErrno(genMsg,status); - return zFAILURE; - } - else - { + SetErrno(genMsg,status); + return zFAILURE; + } + else + { return status; } } @@ -459,22 +459,22 @@ STATUS ZFSVOL_VOL_RemoveNameFromDirectory( if (removeNameFlags & NF_DIR_MISSING) { /* This code corresponds to a kludge in the COMN Layer in - * NAME_RemoveStrandedParentEntry. The COMN layer has a case where - * the directory is missing, but the names are still in the name tree - * and need to be removed. If this bit is set, the "directory" pointer - * is really a pointer to the child beast. and the beastZid is really - * the ZID of the parent directory. - */ - k.pzid = beastZid; /* This is really the parent directory's ZID */ + * NAME_RemoveStrandedParentEntry. The COMN layer has a case where + * the directory is missing, but the names are still in the name tree + * and need to be removed. If this bit is set, the "directory" pointer + * is really a pointer to the child beast. and the beastZid is really + * the ZID of the parent directory. + */ + k.pzid = beastZid; /* This is really the parent directory's ZID */ beastZid = directory->NAMEDzid; /* This is really the beast's ZID */ } else { - zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); - k.pzid = directory->NAMEDzid; + k.pzid = directory->NAMEDzid; } parms.genMsg = genMsg; @@ -503,7 +503,7 @@ STATUS ZFSVOL_VOL_RemoveNameFromDirectory( if ((nameType == zNTYPE_DELETED_FILE) && (removeNameFlags & NF_LAST_NAME)) { STATUS rc; - rc = purgeq_delete_name(&dummy_genmsg, + rc = purgeq_delete_name(&dummy_genmsg, directory->NAMEDroot.vol.zfsVol->ZFSVOLpurgeTree, nameTypeInfo->u.deleted.time, &directory->NAMEDroot.ROOTinternalID, @@ -516,7 +516,7 @@ STATUS ZFSVOL_VOL_RemoveNameFromDirectory( /**************************************************************************** * This locates the curName and curNameSpaceMask in the directory, via * an exact binary match. Then it replaces the nameSpacemask with - * the newNameSpacemask. NOTE--This function does not validate the + * the newNameSpacemask. NOTE--This function does not validate the * new nameSpacemask, it blindly obeys. All validity checking must * be done by the caller previous to calling this function. ALSO, * this function may not be used to set the nameSpaceMask to 0. @@ -540,8 +540,8 @@ STATUS ZFSVOL_VOL_ModifyNameSpaceMaskInDirectory( ASSERT_XLATCH(&directory->NAMEDbeastLatch); zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); zASSERT(!(directory->NAMEDvolume->VOLenabledAttributes & zATTR_READONLY)); parms.genMsg = genMsg; @@ -592,8 +592,8 @@ STATUS ZFSVOL_VOL_SetMatchAttributesInDirectory( ASSERT_XLATCH(&directory->NAMEDbeastLatch); zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); parms.genMsg = genMsg; parms.ntree = directory->NAMEDroot.vol.zfsVol->nameTree; @@ -642,14 +642,14 @@ STATUS ZFSVOL_VOL_SetHardLinkFlagsInDirectory( ASSERT_XLATCH(&directory->NAMEDbeastLatch); zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); if(beast->NAMEDbeastVersion <= BEAST_VERSION_2) { /* For version 2 and earlier beasts, just pretend we did something, - * but do not set the hard link flags on these beast types. - */ + * but do not set the hard link flags on these beast types. + */ return(zOK); } @@ -694,7 +694,7 @@ STATUS ZFSVOL_VOL_FCNTL( { case VOL_FCNTL_SET_HARDLINK_NAMETREE_FLAGS: return ZFSVOL_VOL_SetHardLinkFlagsInDirectory( - genMsg, + genMsg, data->u.setHLFlags.beast, data->u.setHLFlags.directory, data->u.setHLFlags.nameSpaceMask, @@ -708,7 +708,7 @@ STATUS ZFSVOL_VOL_FCNTL( } SetErrno(genMsg, zERR_COMN_OP_NOT_SUPPORTED); return(zFAILURE); -} +} /**************************************************************************** * Picking up where it left off last time. This will find the next file @@ -734,8 +734,8 @@ Zid_t ZFSVOL_VOL_WildcardLookup( ASSERT_LATCH(&directory->NAMEDbeastLatch); zASSERT((directory->NAMEDattributes & zFA_SUBDIRECTORY) || - (nameType == zNTYPE_DATA_STREAM) || - (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); + (nameType == zNTYPE_DATA_STREAM) || + (nameType == zNTYPE_EXTENDED_ATTRIBUTE)); parms.genMsg = genMsg; parms.ntree = directory->NAMEDroot.vol.zfsVol->nameTree; parms.xaction = NULL; @@ -758,7 +758,7 @@ Zid_t ZFSVOL_VOL_WildcardLookup( } /**************************************************************************** - * ZFS B-Tree beast constructor + * ZFS B-Tree beast constructor *****************************************************************************/ STATUS ZFSNAMETREE_Construct( GeneralMsg_s *genMsg, @@ -842,7 +842,7 @@ STATIC BYTE *ZFSNAMETREE_Pack( *****************************************************************************/ STATIC BYTE *ZFSNAMETREE_Unpack( GeneralMsg_s *genMsg, - void *beast_LX, + void *beast_LX, BYTE *storeBuffer) { /*memcpy(&beast->p,storeBuffer,sizeof(PersistentZfsNameTree_s));*/ diff --git a/src/nwnss/zlss/nameTree.h b/src/nwnss/zlss/nameTree.h index e02abbc..4f9fa82 100644 --- a/src/nwnss/zlss/nameTree.h +++ b/src/nwnss/zlss/nameTree.h @@ -74,19 +74,19 @@ ovflow_insert_common(_b_, _i_, _k, 0, _ob, 1, _dlops, _blki, \ _oblki, _oldl, _newl) extern STATUS -ovflow_insert_common(Buffer_s *buf, node_ind_t ind, dir_key_s *newkey, - Blknum_t blk, Buffer_s *ovflow_buf, SNINT replace, +ovflow_insert_common(Buffer_s *buf, node_ind_t ind, dir_key_s *newkey, + Blknum_t blk, Buffer_s *ovflow_buf, SNINT replace, dlog_op_s **dlops, dlog_ind_t blki, dlog_ind_t ovflow_blki, SNINT oldoff, SNINT newoff); extern STATUS -node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, - node_ind_t ind, Buffer_s **parbuf, node_ind_t *parind, dir_key_s *inskey, +node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, + node_ind_t ind, Buffer_s **parbuf, node_ind_t *parind, dir_key_s *inskey, BYTE *data, SNINT datasz, SNINT *key_in_par); extern STATUS node_underflow( - NameTreeParms_s *parms, + NameTreeParms_s *parms, Buffer_s **buf, /* inout */ Buffer_s **parbuf, /* inout */ node_ind_t *pind, /* inout */ @@ -94,8 +94,8 @@ node_underflow( STATUS leaf_ovflow_delete( - NameTreeParms_s *parms, - Buffer_s *buf, + NameTreeParms_s *parms, + Buffer_s *buf, node_ind_t ind, node_ind_t dupind, Buffer_s *firstbuf, @@ -103,9 +103,9 @@ leaf_ovflow_delete( extern STATUS node_delete_entry( - NameTreeParms_s *parms, - Buffer_s *buf, - dir_key_s *delkey, + NameTreeParms_s *parms, + Buffer_s *buf, + dir_key_s *delkey, Zid_t *zid); /* out */ extern STATUS @@ -115,15 +115,15 @@ extern STATUS alloc_ntree_blks(NameTreeParms_s *parms, ZfsXaction_s *xaction, NINT nblks, Buffer_s **buf); /* Special nearBlock values that take advantage that the - first ZLSS superblock uses blocks 0 to 15. */ + first ZLSS superblock uses blocks 0 to 15. */ #define NT_ALLOC_GLOBAL_SEED 0 #define NT_ALLOC_NEW_AREA 1 extern STATUS alloc_ntree_blks2( - NameTreeParms_s *_parms, - ZfsXaction_s *_xact, + NameTreeParms_s *_parms, + ZfsXaction_s *_xact, NINT nblks, Blknum_t *nearBlocks, - Buffer_s **_buf); + Buffer_s **_buf); extern STATUS ntree_ch_root_node(NameTreeParms_s *parms, ZfsXaction_s *xaction, Buffer_s *oldbuf, Buffer_s *newbuf); @@ -172,16 +172,16 @@ extern STATUS ntree_ch_root_node(NameTreeParms_s *parms, #define MYABS(_i) (((_i) < 0) ? -(_i) : (_i)) /* - * Declarations for the Global Hash table data structure + * Declarations for the Global Hash table data structure * used to invalidate searchmap entries in response to Name tree operations. */ #define SMAP_TABLE_SIZE 31 /* The number of entries in the SMAP table */ -typedef struct valid_smap_tab_s +typedef struct valid_smap_tab_s { NINT size; /* # of hash table buckets in hash array */ - DQhead_t *vst_hash; /* hash array */ + DQhead_t *vst_hash; /* hash array */ #ifdef USE_LATCH_FOR_HASH_TABLE - Latch_s latch; /* latch to control changes in this structure */ + Latch_s latch; /* latch to control changes in this structure */ #endif } valid_smap_tab_s; @@ -190,9 +190,9 @@ extern valid_smap_tab_s valid_smap_tab; /* control head for valid SMAP hash */ #ifdef USE_LATCH_FOR_HASH_TABLE #define LOCK_VALID_SMAP_TAB() X_LATCH(&valid_smap_tab.latch) #define UNLOCK_VALID_SMAP_TAB() UNX_LATCH(&valid_smap_tab.latch) -#else -#define LOCK_VALID_SMAP_TAB() -#define UNLOCK_VALID_SMAP_TAB() +#else +#define LOCK_VALID_SMAP_TAB() +#define UNLOCK_VALID_SMAP_TAB() #endif #define ISVALID_SMAP(_smap) (SMAP_CURSOR(_smap)->leafhint != INVALID_BLK) @@ -200,7 +200,7 @@ extern valid_smap_tab_s valid_smap_tab; /* control head for valid SMAP hash */ extern STATUS valid_smap_tab_init(void); extern void valid_smap_tab_uninit(void); -extern void revalidate_smap(SearchMap_s *smap, Blknum_t leafhint, +extern void revalidate_smap(SearchMap_s *smap, Blknum_t leafhint, Blknum_t ovflow_hint); extern void invalidate_smaps(Blknum_t leafhint, Blknum_t ovflow_hint); @@ -228,7 +228,7 @@ extern STATUS dir_ls(NameTreeParms_s *parms, Blknum_t nextchild); DB_PRINTF((CYAN, MSGNot("%hd, \""), (_l)->k.nameType)); \ PRINT_FNAME((_l)->k.name); \ DB_PRINTF((CYAN, MSGNot("\", 0x%x, ], 0x%Lx>\n"), (_l)->ns_mask, \ - (_l)->zid)); \ + (_l)->zid)); \ zASSERT(((_l)->k.namelen & NAMEnameLenMask) == unilen((_l)->k.name)); \ } while (0) diff --git a/src/nwnss/zlss/node.c b/src/nwnss/zlss/node.c index 900256a..b45b845 100644 --- a/src/nwnss/zlss/node.c +++ b/src/nwnss/zlss/node.c @@ -100,7 +100,7 @@ STATIC inline NINT leafentry_validate(Leaf_s *e) zASSERT(ISVALID_BLKNUM(di->ovflow_blk)); return 1; } - + ndups = di->nduplicates; zASSERT(ndups > 0); zASSERT(size == ((ndups+1) * esize + sizeof(Dupinfo_s))); @@ -128,7 +128,7 @@ NINT ZV_NTleafentry_validate(Leaf_s *e) if (! (e->k.namelen & NAMEdup)) { if(size != esize) - return 0; + return 0; return 1; } @@ -140,17 +140,17 @@ NINT ZV_NTleafentry_validate(Leaf_s *e) if (e->k.namelen & NAMEovflow) { if(size != ((ndups+1) * esize + sizeof(Dupinfo_s))) - return 0; + return 0; if(!(ISVALID_BLKNUM(di->ovflow_blk))) - return 0; + return 0; return 1; } - + ndups = di->nduplicates; if(ndups <= 0) - return 0; + return 0; if(size != ((ndups+1) * esize + sizeof(Dupinfo_s))) - return 0; + return 0; e = (Leaf_s *)((BYTE *)e + esize + sizeof(Dupinfo_s)); for (i = 0; i < di->nduplicates; ++ i) { @@ -181,7 +181,7 @@ STATUS node_validate(Node_s *node) zASSERT(isvalid = (node->magic == NAMETREE_MAGIC)); if (! isvalid) return zFAILURE; - zASSERT(isvalid = + zASSERT(isvalid = ((node->state & ~(NT_LEAF|NT_BRANCH|NT_ROOT|NT_OVERFLOW)) == 0)); /* Skip checking leaf overflow nodes for the moment */ @@ -193,7 +193,7 @@ STATUS node_validate(Node_s *node) zASSERT(isvalid = (isleaf != (IS_BRANCH(node) != 0))); if (! isvalid) return zFAILURE; zASSERT(isvalid = ((node->numRecs >= 0) && - (node->numRecs <= (NODE_MAX_FREEBYTES / + (node->numRecs <= (NODE_MAX_FREEBYTES / (MIN_ENTRY_SIZE(isleaf ? LEAF_DATASIZE : sizeof(Blknum_t)) + OFFSETSZ))))); if (! isvalid) return zFAILURE; indarr = NODE_INDARR(node); @@ -205,7 +205,7 @@ STATUS node_validate(Node_s *node) NODE_MAX_FREEBYTES))); if (! isvalid) return zFAILURE; - zASSERT(isvalid = ((node->nextfree >= 0) && + zASSERT(isvalid = ((node->nextfree >= 0) && (node->nextfree <= ((BYTE *)indarr - &node->padbytes[0])))); if (! isvalid) return zFAILURE; @@ -218,7 +218,7 @@ STATUS node_validate(Node_s *node) node_offset_t *e = (node_offset_t *)&node->padbytes[0]; zASSERT(! ISFREE_PREVENTRY(e)); - while (e < indarr) + while (e < indarr) { size = ENTRYSIZE(e); zASSERT(isvalid = (size > 0)); @@ -226,14 +226,14 @@ STATUS node_validate(Node_s *node) zASSERT(isvalid = ((e + size) <= indarr)); if (! isvalid) return zFAILURE; zASSERT((ISFREE_PREVENTRY(e) != 0) == isfree_prev_entry); - if (ISFREE(e)) + if (ISFREE(e)) { zASSERT(! isfree_prev_entry); zASSERT(e[0] == e[size-1]); isfree_prev_entry = 1; nfreebytes += size; } - else + else { isfree_prev_entry = 0; ++ numRecs; @@ -250,7 +250,7 @@ STATUS node_validate(Node_s *node) { Leaf_s *prev_e = LEAF_ENTRY(node, 0); zASSERT(ISVALID_LEAF_ENTRY(prev_e)); - for (i = 1; i < node->numRecs; ++i) + for (i = 1; i < node->numRecs; ++i) { Leaf_s *e = LEAF_ENTRY(node, i); @@ -262,12 +262,12 @@ STATUS node_validate(Node_s *node) else /* Branch node */ { Branch_s *prev_e = BRANCH_ENTRY(node, 0); - if (NODE_OVFLOW(node)) + if (NODE_OVFLOW(node)) { } zASSERT(ISVALID_BRANCH_ENTRY(prev_e)); - for (i = 1; i < node->numRecs; ++i) + for (i = 1; i < node->numRecs; ++i) { Branch_s *e = BRANCH_ENTRY(node, i); @@ -402,7 +402,7 @@ STATUS ZV_nameNode_validate(Node_s *node, Blknum_t blknum, VerifyStats_s *vStats goto INVALID_NODE; } - if (ISFREE(e)) + if (ISFREE(e)) { isvalid = (! isfree_prev_entry); if (! isvalid) { @@ -417,7 +417,7 @@ STATUS ZV_nameNode_validate(Node_s *node, Blknum_t blknum, VerifyStats_s *vStats isfree_prev_entry = 1; nfreebytes += size; } - else + else { isfree_prev_entry = 0; ++ numRecs; @@ -452,7 +452,7 @@ STATUS ZV_nameNode_validate(Node_s *node, Blknum_t blknum, VerifyStats_s *vStats } // FixFixFix6 - We need some validation of entries with duplicate names in them // see what Sai does to validate - prev_e = LEAF_ENTRY(node, 0); + prev_e = LEAF_ENTRY(node, 0); e = LEAF_ENTRY(node, 0); /* init entry in case only one entry */ isvalid = (ZV_ISVALID_LEAF_ENTRY(prev_e)); @@ -473,21 +473,21 @@ STATUS ZV_nameNode_validate(Node_s *node, Blknum_t blknum, VerifyStats_s *vStats goto INVALID_NODE; } } - for (i = 1; i < node->numRecs; ++i) - { - e = LEAF_ENTRY(node, i); + for (i = 1; i < node->numRecs; ++i) + { + e = LEAF_ENTRY(node, i); isvalid = (ZV_ISVALID_LEAF_ENTRY(e)); if (! isvalid) { where = WHERE; goto INVALID_NODE; } - isvalid = (keycomp(&prev_e->k, &e->k) < 0); + isvalid = (keycomp(&prev_e->k, &e->k) < 0); if (! isvalid) { where = WHERE; goto INVALID_NODE; } - prev_e = e; - } + prev_e = e; + } if(node->u.nextleaf != 0 && node->u.nextleaf != INVALID_BLK) { ntData->prevNTLeafNodeNextLeaf = node->u.nextleaf; @@ -497,28 +497,28 @@ STATUS ZV_nameNode_validate(Node_s *node, Blknum_t blknum, VerifyStats_s *vStats else /* Branch node */ { Branch_s *prev_e = BRANCH_ENTRY(node, 0); - + if (node->numRecs == 0) { return zOK; } - if (NODE_OVFLOW(node)) + if (NODE_OVFLOW(node)) { // FixFixFix6 - need to do something with overflow branch nodes here???? See Sai } isvalid = (ZV_ISVALID_DELETED_BRANCH_ENTRY(prev_e)); /* FixFixFix(LV,ACI,9) - Should _DELETED_ be here? I believe - * it is O.K. There are still locations in verify that - * need to say bad NT or good NT based on if volume is - * being purged. This check could be done here also - * to determine if _DELETED_ version should be called. - */ + * it is O.K. There are still locations in verify that + * need to say bad NT or good NT based on if volume is + * being purged. This check could be done here also + * to determine if _DELETED_ version should be called. + */ if (! isvalid) { where = WHERE; goto INVALID_NODE; } - for (i = 1; i < node->numRecs; ++i) + for (i = 1; i < node->numRecs; ++i) { Branch_s *e = BRANCH_ENTRY(node, i); @@ -574,11 +574,11 @@ node_compact(Node_s *node) node_offset_t *indarr = NODE_INDARR(node); node_offset_t *dest = (node_offset_t *)&node->padbytes[0]; node_offset_t *src = dest; - - while (src < indarr) + + while (src < indarr) { SNINT size; - if (ISFREE(src)) + if (ISFREE(src)) { src += ENTRYSIZE(src); continue; @@ -586,9 +586,9 @@ node_compact(Node_s *node) size = ENTRYSIZE(src); if (dest == src) dest = src = src + size; - else + else { - SNINT old_off = (BYTE *)src - &node->padbytes[0]; + SNINT old_off = (BYTE *)src - &node->padbytes[0]; SNINT new_off = (BYTE *)dest - &node->padbytes[0], i; *src &= ~FREE_PREVENTRY_MASK; zASSERT(dest < src); @@ -635,7 +635,7 @@ alloc_ind_entries(Node_s *node, SNINT nentries) /* * Search for position of key k in the node in sorted order. * Returns 1 if exact match found, 0 otherwise. - * In anycase, ind contains index of entry such that + * In anycase, ind contains index of entry such that * node[ind] <= k < node[ind+1]. * ind ranges from [-1, node->numRecs-1]. */ @@ -646,7 +646,7 @@ node_findkey(Node_s *node, dir_key_s *k, node_ind_t *ind) SNINT i = 0, low = 0, high = node->numRecs-1; SNINT res = -1; - while (low <= high) + while (low <= high) { BYTE *e; dir_key_s *storkey; @@ -655,9 +655,9 @@ node_findkey(Node_s *node, dir_key_s *k, node_ind_t *ind) e = &node->padbytes[indarr[i]]; storkey = IS_LEAF(node) ? &((Leaf_s *)e)->k : &((Branch_s *)e)->k; res = keycomp(k, storkey); - if (res == 0) + if (res == 0) { - if (low == high) + if (low == high) { *ind = i; return 1; @@ -690,22 +690,22 @@ retry_find_space: zASSERT(free < indarr); /* Find a free chunk of atleast entrysize */ - for (;;) + for (;;) { size = ENTRYSIZE(free); if (ISFREE(free) && (size >= entrywords)) break; free += size; - if (free >= indarr) + if (free >= indarr) { free = (node_offset_t *)(&node->padbytes); wrap = 1; } - if (wrap && (free >= start)) + if (wrap && (free >= start)) { zASSERT(! compacted); - /* - * Couldn't fit new entry SNINTo any available slot; + /* + * Couldn't fit new entry SNINTo any available slot; * Compact the node */ node_compact(node); @@ -719,19 +719,19 @@ retry_find_space: free += entrywords; size -= entrywords; node_freebytes = node->nfreebytes - entrywords * OFFSETSZ; - if ((free == indarr) && (node_freebytes > 0)) + if ((free == indarr) && (node_freebytes > 0)) { zASSERT(! compacted); node_compact(node); compacted = 1; goto retry_find_space; } - else + else { node->nfreebytes = node_freebytes; if (size > 0) free[0] = free[size-1] = FREE_ENTRY_SIZE(size); - else if (free < indarr) + else if (free < indarr) free[0] &= ~FREE_PREVENTRY_MASK; if (node->nextfree >= ((BYTE *)retval - node->padbytes)) node->nextfree = (BYTE *)free - node->padbytes; @@ -751,7 +751,7 @@ node_dealloc_space(Node_s *node, node_offset_t *entry) node->nfreebytes += size * OFFSETSZ; if ((next < indarr) && ISFREE(next)) size += ENTRYSIZE(next); - if (ISFREE_PREVENTRY(entry)) + if (ISFREE_PREVENTRY(entry)) { free = entry - ENTRYSIZE(entry-1); size += ENTRYSIZE(free); @@ -777,7 +777,7 @@ node_ndelete(Node_s *node, node_ind_t ind, SNINT nentries) SNINT node_was_full = (node->nfreebytes == 0); if (nentries <= 0) return; - + zASSERT((ind >= 0) && (ind <= node->numRecs)); for (i = ind; i < ind + nentries; ++i) { freed_lastentry = NODE_DEALLOC_ENTRY(node, i) || freed_lastentry; @@ -805,7 +805,7 @@ node_ndelete(Node_s *node, node_ind_t ind, SNINT nentries) } void -node_ncopy(Node_s *destnode, node_ind_t destind, Node_s *srcnode, +node_ncopy(Node_s *destnode, node_ind_t destind, Node_s *srcnode, node_ind_t srcind, SNINT nentries, SNINT move) { node_offset_t *indarr, *srcindarr; @@ -821,9 +821,9 @@ node_ncopy(Node_s *destnode, node_ind_t destind, Node_s *srcnode, indarr[i] = indarr[i+nentries]; for (j = i; j < i + nentries; ++ j) indarr[j] = NODE_MAX_FREEBYTES; - + srcindarr = NODE_INDARR(srcnode); - for (j = srcind; j < srcind + nentries; ++ j) + for (j = srcind; j < srcind + nentries; ++ j) { node_offset_t *entry = (node_offset_t *) &srcnode->padbytes[srcindarr[j]]; @@ -840,16 +840,16 @@ node_ncopy(Node_s *destnode, node_ind_t destind, Node_s *srcnode, } void -node_insert_common(Node_s *node, node_ind_t ind, dir_key_s *inskey, +node_insert_common(Node_s *node, node_ind_t ind, dir_key_s *inskey, BYTE *data, SNINT datasize, SNINT replace) { node_offset_t *indarr; SNINT i, entrywords = NWORDS(ENTRYSIZE_FROM_KEY(inskey, datasize)); node_offset_t *free; dir_key_s *k; + - - if (replace) + if (replace) { SNINT need_compact = (node->nfreebytes == 0); i = ind; @@ -858,7 +858,7 @@ node_insert_common(Node_s *node, node_ind_t ind, dir_key_s *inskey, node_compact(node); indarr = NODE_INDARR(node); } - else + else { alloc_ind_entries(node, 1); ++ node->numRecs; @@ -870,7 +870,7 @@ node_insert_common(Node_s *node, node_ind_t ind, dir_key_s *inskey, } free = node_alloc_space(node, entrywords); - if (IS_LEAF(node)) + if (IS_LEAF(node)) { Ldata_s *l = (Ldata_s *)data; bzero((BYTE *)free, FIELD_OFFSET(Leaf_s, k)); @@ -880,7 +880,7 @@ node_insert_common(Node_s *node, node_ind_t ind, dir_key_s *inskey, ((Leaf_s *)free)->miscFlags = l->miscFlags; k = &((Leaf_s *)free)->k; } - else + else { ((Branch_s *)free)->child_blk = *(Blknum_t *)data; k = &((Branch_s *)free)->k; @@ -898,7 +898,7 @@ node_expand_entry(Node_s *node, node_ind_t ind, dir_key_s *inskey, BYTE *data, node_offset_t *free, *indarr, *e = NODE_ENTRY(node, ind); SNINT oldsize, incrsize, availsize, incrbytes, i; oldsize = ENTRYSIZE(e); - if (inskey) + if (inskey) { incrbytes = ENTRYSIZE_FROM_KEY(inskey, datasize); if (! (((Leaf_s *)e)->k.namelen & NAMEdup)) @@ -918,11 +918,11 @@ node_expand_entry(Node_s *node, node_ind_t ind, dir_key_s *inskey, BYTE *data, && ((free + incrsize) < indarr)) goto found_space; - if (ISFREE_PREVENTRY(e)) + if (ISFREE_PREVENTRY(e)) { free = e - ENTRYSIZE(e-1); if (((availsize += ENTRYSIZE(free)) >= incrsize) - && ((free + oldsize + availsize) < indarr)) + && ((free + oldsize + availsize) < indarr)) { memmove(free, e, oldsize * OFFSETSZ); e = free; @@ -938,10 +938,10 @@ node_expand_entry(Node_s *node, node_ind_t ind, dir_key_s *inskey, BYTE *data, indarr = NODE_INDARR(node); e = NODE_ENTRY(node, ind); free = e + oldsize; - memmove(free + incrsize, (BYTE *)free, &node->padbytes[node->nextfree] - + memmove(free + incrsize, (BYTE *)free, &node->padbytes[node->nextfree] - (BYTE *)free); node->nextfree += incrbytes; - + { SNINT newfree = NWORDS(node->nfreebytes - incrbytes); node_offset_t e_offset = (BYTE *)e - node->padbytes; @@ -954,11 +954,11 @@ node_expand_entry(Node_s *node, node_ind_t ind, dir_key_s *inskey, BYTE *data, free[0] = FREE_ENTRY_SIZE(incrsize); found_space: ; - + { SNINT size = ENTRYSIZE(free); SNINT ressize = size - incrsize; /* residual free space */ - if (ressize > 0) + if (ressize > 0) { free[incrsize] = free[size-1] = FREE_ENTRY_SIZE(ressize); if (&free[size] < indarr) @@ -970,16 +970,16 @@ found_space: ; node->nextfree = (BYTE *)&free[size] - node->padbytes; node->nfreebytes -= incrbytes; - e[0] = (e[0] & FREE_PREVENTRY_MASK) | + e[0] = (e[0] & FREE_PREVENTRY_MASK) | ((oldsize + incrsize) & ENTRYSIZE_MASK); - if (inskey) + if (inskey) { Ldata_s *l = (Ldata_s *)data; - SNINT esize = NWORDS(ENTRYSIZE_FROM_KEY(&((Leaf_s *)e)->k, + SNINT esize = NWORDS(ENTRYSIZE_FROM_KEY(&((Leaf_s *)e)->k, LEAF_DATASIZE)); Dupinfo_s *di = (Dupinfo_s *)(e + esize); - if (! (((Leaf_s *)e)->k.namelen & NAMEdup)) + if (! (((Leaf_s *)e)->k.namelen & NAMEdup)) { di->nduplicates = 0; ((Leaf_s *)e)->k.namelen |= NAMEdup; @@ -989,8 +989,8 @@ found_space: ; bzero((BYTE *)free, FIELD_OFFSET(Leaf_s, k)); ((Leaf_s *)free)->zid = l->zid; ((Leaf_s *)free)->ns_mask = l->ns_mask; - ((Leaf_s *)free)->matchAttributes = l->matchAttributes; - ((Leaf_s *)free)->miscFlags = l->miscFlags; + ((Leaf_s *)free)->matchAttributes = l->matchAttributes; + ((Leaf_s *)free)->miscFlags = l->miscFlags; keycopy(&((Leaf_s *)free)->k, inskey); free[0] = esize; } @@ -1032,17 +1032,17 @@ node_delete_dup(Node_s *node, Leaf_s *head, SNINT dupind) zASSERT(di->nduplicates > 0); last = e + esize * (di->nduplicates-1); e = (dupind < 0) ? ((BYTE *)head) : (e + esize * dupind); - if (e != last) + if (e != last) { node_offset_t size = ((node_offset_t *)e)[0]; memmove(e, last, esize); - if (((Leaf_s *)e) == head) + if (((Leaf_s *)e) == head) { head->size = size; head->k.namelen |= NAMEdup; } } - if (-- di->nduplicates <= 0) + if (-- di->nduplicates <= 0) { head->k.namelen &= ~NAMEdup; node_shrink_entry(node, (node_offset_t *)head, esize); @@ -1052,7 +1052,7 @@ node_delete_dup(Node_s *node, Leaf_s *head, SNINT dupind) } void -node_blk_copy(Node_s *node, node_ind_t ind, SNINT nentries, +node_blk_copy(Node_s *node, node_ind_t ind, SNINT nentries, node_offset_t *entries, SNINT replace, SNINT isovflow) { node_offset_t *indarr; @@ -1060,7 +1060,7 @@ node_blk_copy(Node_s *node, node_ind_t ind, SNINT nentries, if (nentries <= 0) return; - if (replace) + if (replace) { SNINT need_compact = (node->nfreebytes == 0); i = ind; @@ -1068,21 +1068,21 @@ node_blk_copy(Node_s *node, node_ind_t ind, SNINT nentries, need_compact = (! NODE_DEALLOC_ENTRY(node, i)) && need_compact; if (need_compact) node_compact(node); - indarr = NODE_INDARR(node); + indarr = NODE_INDARR(node); } - else + else { alloc_ind_entries(node, nentries); node->numRecs += nentries; indarr = NODE_INDARR(node); - + for (i = 0; i <= ind; ++ i) indarr[i] = indarr[i+nentries]; for (j = i; j < i + nentries; ++ j) indarr[j] = NODE_MAX_FREEBYTES; } - for (j = 0; j < nentries; ++ j) + for (j = 0; j < nentries; ++ j) { SNINT size = ENTRYSIZE(entries); node_offset_t *free; @@ -1116,26 +1116,26 @@ STATUS node_compare(Node_s *n1, Node_s *n2, SNINT length) zASSERT(n1->numRecs == n2->numRecs); zASSERT(n1->nfreebytes == n2->nfreebytes); - if (IS_LEAF(n1)) + if (IS_LEAF(n1)) { zASSERT(n1->u.nextleaf == n2->u.nextleaf); } - else + else { zASSERT(n1->u.ovflow_blk == n2->u.ovflow_blk); zASSERT(n1->child_blk == n2->child_blk); } - + { node_offset_t *e1=NULL, *e2=NULL; SNINT leaf_ovflow = IS_LEAF_OVFLOW(n1), size=0; - if (leaf_ovflow) + if (leaf_ovflow) { e1 = (node_offset_t *)n1->padbytes; e2 = (node_offset_t *)n2->padbytes; size = 0; } - for (i = 0; i < n1->numRecs; ++ i) + for (i = 0; i < n1->numRecs; ++ i) { if (! leaf_ovflow) e1 = NODE_ENTRY(n1, i), e2 = NODE_ENTRY(n2, i); @@ -1153,13 +1153,13 @@ node_display(Node_s *node) SNINT i; node_offset_t *indarr = NODE_INDARR(node); node_offset_t *src = (node_offset_t *)node->padbytes; - + DB_PRINTF((CYAN, MSGNot("Hdr: {%d recs, %d bytes free, nextfree %d}\n"), node->numRecs, node->nfreebytes, node->nextfree)); - while (src < indarr) + while (src < indarr) { - DB_PRINTF((CYAN, MSGNot("%s %d %d\n"), ISFREE(src) ? MSGNot("free") : MSGNot(""), + DB_PRINTF((CYAN, MSGNot("%s %d %d\n"), ISFREE(src) ? MSGNot("free") : MSGNot(""), (ISFREE_PREVENTRY(src) != 0), ENTRYBYTES(src))); src += ENTRYSIZE(src); } @@ -1225,8 +1225,8 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkBranchChild( ZfsNameTree_s *nameTree, Buffer_s *parentBuffer, Blknum_t *childBlockPtr, /* This is an address within the - * parent node buffer. - */ + * parent node buffer. + */ NINT *level, NINT leafLevel ) /* 'leaf' level */ @@ -1246,14 +1246,14 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkBranchChild( zASSERT( leafLevel > 0 ); zASSERT( *level <= leafLevel ); /* The equal is needed as we are called - * to process OVERFLOW nodes on the - * leaf level. - */ + * to process OVERFLOW nodes on the + * leaf level. + */ childBlock = *childBlockPtr; if((childBlock == 0) || (childBlock == INVALID_BLK)) { /* We return zOK, because we place INVALID_BLK all over the place - * when shrinking the name tree. - */ + * when shrinking the name tree. + */ return zOK; } READBLK_IO_MSG(iomsg, nameTree, childBlock, CACHE_UPDATE); @@ -1272,43 +1272,43 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkBranchChild( } /*** - *** We are at the level of the B-Tree that we are deleting - *** all the blocks on. We refer to the block we our deleting - *** as the child block. - *** If the child is a BRANCH then this routine will also - *** delete its OVERFLOW BRANCH if present. - *** If the child is a LEAF then we first let - *** ZLSSVOL_LVD_NTShrinkVisit delete any OVERFLOW LEAFs that - *** the LEAF may have. This is done is small xactions as - *** there may be a great number of OVERFLOW LEAFs. - ***/ + *** We are at the level of the B-Tree that we are deleting + *** all the blocks on. We refer to the block we our deleting + *** as the child block. + *** If the child is a BRANCH then this routine will also + *** delete its OVERFLOW BRANCH if present. + *** If the child is a LEAF then we first let + *** ZLSSVOL_LVD_NTShrinkVisit delete any OVERFLOW LEAFs that + *** the LEAF may have. This is done is small xactions as + *** there may be a great number of OVERFLOW LEAFs. + ***/ childNode = (Node_s *)childBuffer->pBuf.data; ccode = ZLSSVOL_LVD_NTNodeValidate(genMsg, nameTree, childNode, *level); if ( ccode != zOK) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, - MSGNot("Error %ld(%s) Name Tree node 0x%lx(%ld) in level %d\n"), + MSGNot("Error %ld(%s) Name Tree node 0x%lx(%ld) in level %d\n"), GetErrno( genMsg ), GetErrnoSetter( genMsg ), - (unsigned long)childBlock, - (unsigned long)childBlock, + (unsigned long)childBlock, + (unsigned long)childBlock, *level )); CACHE_RELEASE(childBuffer); return( zFAILURE ); } if ( IS_LEAF( childNode ) ) { /* Visit each entry in the leaf node so that - * we can delete any LEAF OVERFLOW blocks. - */ + * we can delete any LEAF OVERFLOW blocks. + */ NINT i; - for (i = 0; i < childNode->numRecs; ++i) + for (i = 0; i < childNode->numRecs; ++i) { WORD dupNameFlags; - Leaf_s *e; - - e = LEAF_ENTRY(childNode, i); + Leaf_s *e; + + e = LEAF_ENTRY(childNode, i); dupNameFlags = e->k.namelen & 0xf000; if ( (dupNameFlags & NAMEdup) && (dupNameFlags & NAMEovflow) ) { @@ -1322,10 +1322,10 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkBranchChild( { ASSERT_XLATCH( &childBuffer->agent.latch ); /* The next function will release the latch many times - * and when it returns the buffer is S_LATCHed. It - * pins the Buffer_s so our 'node' pointer will - * still be valid. - */ + * and when it returns the buffer is S_LATCHed. It + * pins the Buffer_s so our 'node' pointer will + * still be valid. + */ ccode = ZLSSVOL_LVD_NTShrinkLeafOverflow(genMsg, nameTree, i, childBuffer, ovFlowLeafBlk ); ASSERT_XLATCH( &childBuffer->agent.latch ); if ( ccode != zOK ) @@ -1341,12 +1341,12 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkBranchChild( { if ( NODE_OVFLOW(childNode) ) { /* Overflow exists - we MUST free the BRANCH OVERFLOW block - * and the BRANCH in one xaction. This relates to the - * replace operation that may be contained in the OVERFLOW - * BRANCH. It is the only indication that a specific - * entry in the BRANCH is really not an entry. I.E. if - * we look at it we will free a child block twice!!! - */ + * and the BRANCH in one xaction. This relates to the + * replace operation that may be contained in the OVERFLOW + * BRANCH. It is the only indication that a specific + * entry in the BRANCH is really not an entry. I.E. if + * we look at it we will free a child block twice!!! + */ ovFlowBlk = childNode->u.ovflow_blk; operation = XFUNC_LV_NT_SHRINK_BRANCH_OVERFLOW; } @@ -1357,11 +1357,11 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkBranchChild( ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(3) + sizeof(*logRecord)); /** There is no difference between a XFUNC_LV_NT_SHRINK_BRANCH_OVERFLOW - * and XFUNC_LV_NT_SHRINK_LEAF_OVERFLOW and XFUNC_LV_NT_SHRINK. - * We use different operation IDs so that ZLOG histogram will count - * the overflow operations from the non-overflow operations. This - * will give us some idea as to if OVERFLOW code is being tested. - */ + * and XFUNC_LV_NT_SHRINK_LEAF_OVERFLOW and XFUNC_LV_NT_SHRINK. + * We use different operation IDs so that ZLOG histogram will count + * the overflow operations from the non-overflow operations. This + * will give us some idea as to if OVERFLOW code is being tested. + */ ZLOG_INIT_LOG_RECORD(operation, xaction, logBuffer, 3, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], parentBuffer->volBlk, @@ -1429,8 +1429,8 @@ STATIC STATUS ZLSSVOL_LVD_NTDepthRightBranchChild( zASSERT( *depth > 0 ); if((childBlock == 0) || (childBlock == INVALID_BLK)) { /* We return zOK, because we place INVALID_BLK all over the place - * when shrinking the name tree. - */ + * when shrinking the name tree. + */ return zOK; } @@ -1487,7 +1487,7 @@ STATIC STATUS ZLSSVOL_LVD_NTShrink( { return zFAILURE; } - status = ZLSSVOL_LVD_NTShrinkVisit(genMsg, nameTree, + status = ZLSSVOL_LVD_NTShrinkVisit(genMsg, nameTree, bufferRoot, ¤tLevel, leafLevel ); CACHE_RELEASE(bufferRoot); return( status ); @@ -1617,50 +1617,50 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkBranchNode( } /* If overflow exists, process all entries up to the - overflow entry from the regular node, - then process the overflow entry */ + overflow entry from the regular node, + then process the overflow entry */ br_ind = 0; if ( ovBuffer != NULL ) { ovflow_node = (Node_s*)ovBuffer->pBuf.data; - for (ovflow_ind = 0; ovflow_ind < ovflow_node->numRecs; ++ ovflow_ind) - { - node_ind_t insi, endi; - SNINT replace; - Branch_s *inse; + for (ovflow_ind = 0; ovflow_ind < ovflow_node->numRecs; ++ ovflow_ind) + { + node_ind_t insi, endi; + SNINT replace; + Branch_s *inse; - /* Get the next overflow node entry */ - OVFLOW_ENTRY(ovflow_node, ovflow_ind, &insi, &replace, &inse); - endi = insi; - if (replace) + /* Get the next overflow node entry */ + OVFLOW_ENTRY(ovflow_node, ovflow_ind, &insi, &replace, &inse); + endi = insi; + if (replace) { - -- endi; /* replace ops do not increase # of branch entries */ + -- endi; /* replace ops do not increase # of branch entries */ } - /* - * For each entry in the overflow node, process all branch node entries - * upto but not including the overflow node entry's index. - */ - for ( ; br_ind <= endi; ++ br_ind) - { - Branch_s *e = BRANCH_ENTRY(brnode, br_ind); + /* + * For each entry in the overflow node, process all branch node entries + * upto but not including the overflow node entry's index. + */ + for ( ; br_ind <= endi; ++ br_ind) + { + Branch_s *e = BRANCH_ENTRY(brnode, br_ind); // childBlock = e->child_blk; ccode = ZLSSVOL_LVD_NTShrinkBranchChild(genMsg, nameTree, brBuffer, &e->child_blk, level, leafLevel); if(ccode != zOK) { return( ccode ); } - } + } - /* Then process the overflow entry itself */ + /* Then process the overflow entry itself */ // childBlock = inse->child_blk; ccode = ZLSSVOL_LVD_NTShrinkBranchChild(genMsg, nameTree, ovBuffer, &inse->child_blk, level, leafLevel); if(ccode != zOK) { return( ccode ); } - br_ind = insi + 1; - } + br_ind = insi + 1; + } } /* Process all remaining branch node entries not covered above */ @@ -1668,7 +1668,7 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkBranchNode( { Branch_s *e = BRANCH_ENTRY(brnode, br_ind); // childBlock = e->child_blk; - ccode = ZLSSVOL_LVD_NTShrinkBranchChild(genMsg, nameTree, brBuffer, &e->child_blk, level, leafLevel); + ccode = ZLSSVOL_LVD_NTShrinkBranchChild(genMsg, nameTree, brBuffer, &e->child_blk, level, leafLevel); if(ccode != zOK) { return( ccode ); @@ -1701,7 +1701,7 @@ STATIC STATUS ZLSSVOL_LVD_NTDepthRightBranchNode( Branch_s *e; brnode = (Node_s *)brBuffer->pBuf.data; - if ( ovBuffer == NULL ) + if ( ovBuffer == NULL ) { /* Overflow does not exists */ if ( brnode->numRecs == 0 ) { @@ -1709,11 +1709,11 @@ STATIC STATUS ZLSSVOL_LVD_NTDepthRightBranchNode( nameTree, brBuffer, brnode->child_blk, depth); } else - { - e = BRANCH_ENTRY(brnode, brnode->numRecs-1); - ccode = ZLSSVOL_LVD_NTDepthRightBranchChild(genMsg, - nameTree, brBuffer, e->child_blk, depth); - } + { + e = BRANCH_ENTRY(brnode, brnode->numRecs-1); + ccode = ZLSSVOL_LVD_NTDepthRightBranchChild(genMsg, + nameTree, brBuffer, e->child_blk, depth); + } return( ccode ); } /* Overflow exists */ @@ -1737,8 +1737,8 @@ STATIC STATUS ZLSSVOL_LVD_NTDepthRightBranchNode( return( zFAILURE ); } e = BRANCH_ENTRY(brnode, brnode->numRecs-1); - ccode = ZLSSVOL_LVD_NTDepthRightBranchChild(genMsg, nameTree, - brBuffer, e->child_blk, depth); + ccode = ZLSSVOL_LVD_NTDepthRightBranchChild(genMsg, nameTree, + brBuffer, e->child_blk, depth); } else { /* The overflow node contains the right most entry */ @@ -1780,11 +1780,11 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkVisit( if ( ccode != zOK) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, - MSGNot("Error %ld(%s) Name Tree node 0x%lx(%ld) in level %d\n"), + MSGNot("Error %ld(%s) Name Tree node 0x%lx(%ld) in level %d\n"), GetErrno( genMsg ), GetErrnoSetter( genMsg ), - (unsigned long)parentBuffer->volBlk, - (unsigned long)parentBuffer->volBlk, + (unsigned long)parentBuffer->volBlk, + (unsigned long)parentBuffer->volBlk, *level )); return( zFAILURE ); } @@ -1801,8 +1801,8 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkVisit( /*-------------------------------*/ /* BRANCH NODE */ /*-------------------------------*/ - if (parentNode->state & NT_BRANCH) - { + if (parentNode->state & NT_BRANCH) + { (*level)++; if (NODE_OVFLOW(parentNode)) /* overflow exists, process it with it's branch */ { /* A BRANCH with an OVERFLOW BRANCH */ @@ -1827,11 +1827,11 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkVisit( if ( ccode != zOK ) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, - MSGNot("Error %ld(%s) Name Tree overflow node 0x%lx(%ld) in level %d\n"), + MSGNot("Error %ld(%s) Name Tree overflow node 0x%lx(%ld) in level %d\n"), GetErrno( genMsg ), GetErrnoSetter( genMsg ), - (unsigned long)overFlowBlock, - (unsigned long)overFlowBlock, + (unsigned long)overFlowBlock, + (unsigned long)overFlowBlock, *level )); CACHE_RELEASE(ovBuffer); return zFAILURE; @@ -1884,11 +1884,11 @@ STATIC STATUS ZLSSVOL_LVD_NTDepthRightVisit( if ( ccode != zOK) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, - MSGNot("Error %ld(%s) Name Tree node 0x%lx(%ld) in level %d\n"), + MSGNot("Error %ld(%s) Name Tree node 0x%lx(%ld) in level %d\n"), GetErrno( genMsg ), GetErrnoSetter( genMsg ), - (unsigned long)parentBuffer->volBlk, - (unsigned long)parentBuffer->volBlk, + (unsigned long)parentBuffer->volBlk, + (unsigned long)parentBuffer->volBlk, (*depth) )); return( zFAILURE ); } @@ -1929,11 +1929,11 @@ STATIC STATUS ZLSSVOL_LVD_NTDepthRightVisit( if ( ccode != zOK ) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, - MSGNot("Error %ld(%s) Name Tree overflow node 0x%lx(%ld) in level %d\n"), + MSGNot("Error %ld(%s) Name Tree overflow node 0x%lx(%ld) in level %d\n"), GetErrno( genMsg ), GetErrnoSetter( genMsg ), - (unsigned long)overFlowBlock, - (unsigned long)overFlowBlock, + (unsigned long)overFlowBlock, + (unsigned long)overFlowBlock, (*depth) )); CACHE_RELEASE(ovBuffer); return zFAILURE; @@ -1945,7 +1945,7 @@ STATIC STATUS ZLSSVOL_LVD_NTDepthRightVisit( } /* A BRANCH without an OVERFLOW BRANCH */ ccode = ZLSSVOL_LVD_NTDepthRightBranchNode(genMsg, - nameTree, parentBuffer, NULL, depth); + nameTree, parentBuffer, NULL, depth); return ccode; } /*-------------------------------*/ @@ -1956,7 +1956,7 @@ STATIC STATUS ZLSSVOL_LVD_NTDepthRightVisit( } /* End of ZLSSVOL_LVD_NTDepthRightVisit() */ - + /* * ZLSSVOL_LVD_NTShrinkLeafOverflow() - * Truncates all the LEAF OVERFLOW blocks that are hanginf off of @@ -1978,7 +1978,7 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkLeafOverflow( Blknum_t ovFlowBlk ) /* 1st LEAF OVERFLOW block */ { LONG status; - QUAD *ovFlowBlkPtr; + QUAD *ovFlowBlkPtr; Buffer_s *childBuffer; Node_s *childNode; Node_s *eNode; @@ -1994,23 +1994,23 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkLeafOverflow( zASSERT( ovFlowBlk != 0 ); ASSERT_XLATCH( &eBuffer->agent.latch ); /* Keep the Buffer_s in same location and release latch. In - * this routine wish wish to normally NOT own latch on the - * leaf buffer so that it can be written if the overflow - * chain contains 1000's of blocks. This is required because - * ZLOG needs HOME to move. I.E. even though we have SMALL - * xactions, it does not help unless we let them home. - */ + * this routine wish wish to normally NOT own latch on the + * leaf buffer so that it can be written if the overflow + * chain contains 1000's of blocks. This is required because + * ZLOG needs HOME to move. I.E. even though we have SMALL + * xactions, it does not help unless we let them home. + */ CACHE_PIN(eBuffer); UNX_LATCH( &eBuffer->agent.latch ); eNode = (Node_s*)eBuffer->pBuf.data; eLeaf = LEAF_ENTRY(eNode, eIndex); /* FixFixFix6 - Verify must handle recursive branches and - * leaf overflows. E.G. if a leaf overflow block points - * back into the overflow chain then we will loop forever. - * If a branch points back up into the tree then we will ABEND - * with a stack fault??? I assume that none of the B-Tree - * verify code checks for these types of problems. - */ + * leaf overflows. E.G. if a leaf overflow block points + * back into the overflow chain then we will loop forever. + * If a branch points back up into the tree then we will ABEND + * with a stack fault??? I assume that none of the B-Tree + * verify code checks for these types of problems. + */ do { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, @@ -2027,8 +2027,8 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkLeafOverflow( childNode = (Node_s*)childBuffer->pBuf.data; if ( !(childNode->state & NT_OVERFLOW) ) { /* All blocks in a NT leaf overflow - * chain must be overflow blocks. - */ + * chain must be overflow blocks. + */ DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, MSGNot("Error(BMP_TST_EXTENT) following NT leaf overflows\n") )); CACHE_RELEASE(childBuffer); @@ -2041,20 +2041,20 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkLeafOverflow( if ( status != zOK) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, - MSGNot("Error %ld(%s) Name Tree node leaf overflow 0x%lx(%ld)\n"), + MSGNot("Error %ld(%s) Name Tree node leaf overflow 0x%lx(%ld)\n"), GetErrno( genMsg ), GetErrnoSetter( genMsg ), - (unsigned long)ovFlowBlk, (unsigned long)ovFlowBlk )); + (unsigned long)ovFlowBlk, (unsigned long)ovFlowBlk )); X_LATCH( &eBuffer->agent.latch ); CACHE_UNPIN( eBuffer ); return( zFAILURE ); } /* This is not the normal ORDER of latching NT overflow blocks, - * but no one is using the volume so we are safe. Could do - * latch before read, but I feel better if our window for not - * owning the eBuffer latch is big. Could twinde a bit in - * magic of over flow and dirty release. This way validate - * would complain at some point. - */ + * but no one is using the volume so we are safe. Could do + * latch before read, but I feel better if our window for not + * owning the eBuffer latch is big. Could twinde a bit in + * magic of over flow and dirty release. This way validate + * would complain at some point. + */ X_LATCH( &eBuffer->agent.latch ); xaction = BeginXLocal( nameTree->ZFSNAMETREEfile.FILEvolume, BXL_DEFAULT); @@ -2114,7 +2114,7 @@ STATIC STATUS ZLSSVOL_LVD_NTShrinkLeafOverflow( * * Notes - * We do not use a GOTO here because SetErrno will also store - * the line we are on. I.E. we can easily determine the exact + * the line we are on. I.E. we can easily determine the exact * cause of error by having multiple SetErrno() calls because the * errNoSetter will be unique for each validation check. * @@ -2137,14 +2137,14 @@ STATUS ZLSSVOL_LVD_NTNodeValidate( if ( zVolume->ZV_stopPurge ) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(MAGENTA, - MSGNot("ZV_stopPurge request - stopping LV delete (in NT)\n"))); + MSGNot("ZV_stopPurge request - stopping LV delete (in NT)\n"))); SetErrno( genMsg, zERR_VOLUME_STOP_REQUESTED ); return( zFAILURE ); } if ( zVolume->ZLSSVOLvol.v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP ) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, - MSGNot("Deactivate request - stopping LV delete (in NT)\n"))); + MSGNot("Deactivate request - stopping LV delete (in NT)\n"))); SetErrno( genMsg, zERR_VOLUME_STATE_CHANGE_REQUESTED ); return( zFAILURE ); } @@ -2189,7 +2189,7 @@ STATUS ZLSSVOL_LVD_NTNodeValidate( return zFAILURE; } - if (IS_FREE(node)) + if (IS_FREE(node)) { zASSERT("Nametree should not have FREE Nodes"==NULL); SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); @@ -2310,7 +2310,7 @@ STATUS ZLSSVOL_LVD_NTNodeValidate( return zFAILURE; } - if (ISFREE(e)) + if (ISFREE(e)) { isvalid = (! isfree_prev_entry); if ( !isvalid ) @@ -2327,7 +2327,7 @@ STATUS ZLSSVOL_LVD_NTNodeValidate( isfree_prev_entry = 1; nfreebytes += size; } - else + else { isfree_prev_entry = 0; ++ numRecs; @@ -2354,7 +2354,7 @@ STATUS ZLSSVOL_LVD_NTNodeValidate( { // FixFixFix6 - We need some validation of entries with duplicate names in them // see what Sai does to validate - prev_e = LEAF_ENTRY(node, 0); + prev_e = LEAF_ENTRY(node, 0); e = LEAF_ENTRY(node, 0); /* init entry in case only one entry */ if(node->u.nextleaf != 0 && node->u.nextleaf != INVALID_BLK) { @@ -2376,23 +2376,23 @@ STATUS ZLSSVOL_LVD_NTNodeValidate( // } // } } - for (i = 1; i < node->numRecs; ++i) - { - e = LEAF_ENTRY(node, i); + for (i = 1; i < node->numRecs; ++i) + { + e = LEAF_ENTRY(node, i); isvalid = (ZV_ISVALID_LEAF_ENTRY(e)); if ( !isvalid ) { SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); return zFAILURE; } - isvalid = (keycomp(&prev_e->k, &e->k) < 0); + isvalid = (keycomp(&prev_e->k, &e->k) < 0); if ( !isvalid ) { SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); return zFAILURE; } - prev_e = e; - } + prev_e = e; + } // if(node->u.nextleaf != 0 && node->u.nextleaf != INVALID_BLK) // { // NTStats->prevNTLeafNodeNextLeaf = node->u.nextleaf; @@ -2402,7 +2402,7 @@ STATUS ZLSSVOL_LVD_NTNodeValidate( else /* Branch node */ { Branch_s *prev_e = BRANCH_ENTRY(node, 0); - if (NODE_OVFLOW(node)) + if (NODE_OVFLOW(node)) { // FixFixFix6 - need to do something with overflow branch nodes here???? See Sai } @@ -2412,7 +2412,7 @@ STATUS ZLSSVOL_LVD_NTNodeValidate( SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); return zFAILURE; } - for (i = 1; i < node->numRecs; ++i) + for (i = 1; i < node->numRecs; ++i) { Branch_s *e = BRANCH_ENTRY(node, i); @@ -2455,8 +2455,8 @@ STATUS ZLSSVOL_LVD_RecoveryNTShrink( if (ZLOG_VALID_BLOCK(poolBlks[0])) { /* Update the parent entry that pointed to the - * block we deleted. - */ + * block we deleted. + */ READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_UPDATE) if ((buffer = ZFS_ReadPoolBlk(genMsg, &iomsg)) == NULL) { @@ -2498,15 +2498,16 @@ STATUS ZLSSVOL_LVD_RecoveryNTShrink( } /* Since poolBlks[1] is the block we deleted and - * because we did nothing to it on delete we do the - * same here. - */ + * because we did nothing to it on delete we do the + * same here. + */ /* Since poolBlks[2] is the optional overflow branch block we - * deleted and because we did nothing to it on delete we do the - * same here. - */ + * deleted and because we did nothing to it on delete we do the + * same here. + */ RTN_STATUS(zOK); } /* End of ZLSSVOL_LVD_RecoveryNTShrink() */ + diff --git a/src/nwnss/zlss/node.h b/src/nwnss/zlss/node.h index 8cb33d2..c040281 100644 --- a/src/nwnss/zlss/node.h +++ b/src/nwnss/zlss/node.h @@ -32,7 +32,7 @@ | |--------------------------------------------------------------------------- | This module is used to: - | Declares structures, macros and functions for manipulating + | Declares structures, macros and functions for manipulating | Naming B-Tree nodes. +-------------------------------------------------------------------------*/ #ifndef _NSS_NODE_H_ @@ -91,33 +91,33 @@ typedef struct Branch_s dir_key_s k; } NSS_MEDIA_STRUCTURE(Branch_s,k) Branch_s; - -typedef struct Ldata_s + +typedef struct Ldata_s { Zid_t zid; nsmask_t ns_mask; - BYTE matchAttributes; - BYTE miscFlags; + BYTE matchAttributes; + BYTE miscFlags; } Ldata_s; //} NSS_MEDIA_STRUCTURE(Ldata_s,matchAttributes) Ldata_s; /* This must match the data fields in Leaf_s (see above comment dated 2005April) */ #define LEAF_DATASIZE (sizeof(nsmask_t) + sizeof(Zid_t) + sizeof(WORD) + \ - sizeof(BYTE) + sizeof(BYTE) + sizeof(LONG)) + sizeof(BYTE) + sizeof(BYTE) + sizeof(LONG)) -typedef struct Leaf_s +typedef struct Leaf_s { node_offset_t size; nsmask_t ns_mask; Zid_t zid; - WORD oldNameUniquifier; - BYTE matchAttributes; - BYTE miscFlags; - LONG reserved2; + WORD oldNameUniquifier; + BYTE matchAttributes; + BYTE miscFlags; + LONG reserved2; dir_key_s k; } NSS_MEDIA_STRUCTURE(Leaf_s,k) Leaf_s; -typedef union +typedef union { QUAD data; Blknum_t ovflow_blk; @@ -133,8 +133,8 @@ typedef struct Node_s WORD state; /* Type of node */ SWORD numRecs; /* Number of directory entries in this node */ blk_version_t vers; /* Must be at OFFSET 8 - Generation # of this blk */ - GUID_t n_internalID; /* Must be at OFFSET 16 */ - union + GUID_t n_internalID; /* Must be at OFFSET 16 */ + union { Blknum_t ovflow_blk; /* location of overflow block */ Blknum_t nextleaf; /* Singly linked list of Leaf nodes */ @@ -189,14 +189,14 @@ typedef struct Node_s extern void init_node(Node_s *node, GUID_t *internalID); extern BOOL node_findkey(Node_s *node, dir_key_s *k, node_ind_t *ind); extern void node_ndelete(Node_s *node, node_ind_t ind, SNINT nentries); -extern void node_ncopy(Node_s *destnode, node_ind_t destind, Node_s *srcnode, +extern void node_ncopy(Node_s *destnode, node_ind_t destind, Node_s *srcnode, node_ind_t srcind, SNINT nentries, SNINT move); -extern void node_insert_common(Node_s *node, node_ind_t ind, dir_key_s *inskey, +extern void node_insert_common(Node_s *node, node_ind_t ind, dir_key_s *inskey, BYTE *data, SNINT datasize, SNINT replace); extern void node_shrink_entry(Node_s *node, node_offset_t *entry, SNINT newsize); extern void node_delete_dup(Node_s *node, Leaf_s *head, SNINT dupind); -extern void node_expand_entry(Node_s *node, node_ind_t ind, dir_key_s *inskey, +extern void node_expand_entry(Node_s *node, node_ind_t ind, dir_key_s *inskey, BYTE *data, SNINT datasize); @@ -212,7 +212,7 @@ extern STATUS node_validate(Node_s *node); #define POST_VALIDATE_NTREE_NODE(_parms, _node) ((void)0) #endif /* ZFSNAMETREE_DEBUG */ -extern void node_blk_copy(Node_s *node, node_ind_t ind, SNINT nentries, +extern void node_blk_copy(Node_s *node, node_ind_t ind, SNINT nentries, node_offset_t *entries, SNINT replace, SNINT isovflow); #define INIT_LEAF_NODE(_n_, _is_ovflow_, _internalID_) \ @@ -329,9 +329,9 @@ extern STATUS ZV_nameNode_validate(Node_s *node, Blknum_t blknum, VerifyStats_s ((_b)->child_blk != INVALID_BLK) && \ ZV_NTkey_validate(&(_b)->k)) - /* A Branch that may have had the LV delete code run on - * it can have the child_blk set to INVALID_BLK. - */ + /* A Branch that may have had the LV delete code run on + * it can have the child_blk set to INVALID_BLK. + */ #define ZV_ISVALID_DELETED_BRANCH_ENTRY(_b) \ (ISVALID_ENTRY(_b) && \ ISVALID_BLKNUM((_b)->child_blk) && \ diff --git a/src/nwnss/zlss/nssZLSSSym.c b/src/nwnss/zlss/nssZLSSSym.c new file mode 100644 index 0000000..55915ed --- /dev/null +++ b/src/nwnss/zlss/nssZLSSSym.c @@ -0,0 +1,129 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $ + | + | $RCSfile$ + | $Revision: 1325 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Export zlss symbles to Linux system + +-------------------------------------------------------------------------*/ +#define EXPORT_SYMTAB + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "zlssManage.h" + + +EXPORT_SYMBOL(COMPFIX_VerifyAndLoadLVSystemBeasts); +EXPORT_SYMBOL(COMPFIX_verify_FlushVolVolumeBuffers); +EXPORT_SYMBOL(COMPFIX_UnloadlvSystemBeasts); +EXPORT_SYMBOL(GetZedStuff); +EXPORT_SYMBOL(ZLOG_RecoveryInfoGet); +EXPORT_SYMBOL(ZLSS_MSAPItemsXML); +EXPORT_SYMBOL(ZLSS_PhysicalIOXMLGlobal); +EXPORT_SYMBOL(ZLSS_PhysicalIOXML); +EXPORT_SYMBOL(ZLSS_VCF_InternalCmd); +EXPORT_SYMBOL(ZLSS_ZLogReadMetadataXML); +EXPORT_SYMBOL(ZLSS_ZLogReadMetadata); + + +EXPORT_SYMBOL(ZLSS_RebuildFileLog); +EXPORT_SYMBOL(ZLSS_RebuildFileDebug); +EXPORT_SYMBOL(ZLSS_RebuildFileDetails); +EXPORT_SYMBOL(ZLSS_RebuildFileStatus); +EXPORT_SYMBOL(ZLSS_VerifyFileLog); +EXPORT_SYMBOL(ZLSS_VerifyFileDebug); +EXPORT_SYMBOL(ZLSS_VerifyFileDetails); +EXPORT_SYMBOL(ZLSS_VerifyFileStatus); +EXPORT_SYMBOL(ZLSS_VerifyFileStatistics); + + +void ZLSS_AdminFunctionsStartup() +{ + ZOS_ModuleRegister(COMPFIX_VerifyAndLoadLVSystemBeasts); + ZOS_ModuleRegister(COMPFIX_verify_FlushVolVolumeBuffers); + ZOS_ModuleRegister(COMPFIX_UnloadlvSystemBeasts); + ZOS_ModuleRegister(GetZedStuff); + ZOS_ModuleRegister(ZLOG_RecoveryInfoGet); + ZOS_ModuleRegister(ZLSS_MSAPItemsXML); + ZOS_ModuleRegister(ZLSS_PhysicalIOXML); + ZOS_ModuleRegister(ZLSS_PhysicalIOXMLGlobal); + ZOS_ModuleRegister(ZLSS_VCF_InternalCmd); + ZOS_ModuleRegister(ZLSS_ZLogReadMetadataXML); + ZOS_ModuleRegister(ZLSS_ZLogReadMetadata); + + ZOS_ModuleRegister(ZLSS_RebuildFileLog); + ZOS_ModuleRegister(ZLSS_RebuildFileDebug); + ZOS_ModuleRegister(ZLSS_RebuildFileDetails); + ZOS_ModuleRegister(ZLSS_RebuildFileStatus); + ZOS_ModuleRegister(ZLSS_VerifyFileLog); + ZOS_ModuleRegister(ZLSS_VerifyFileDebug); + ZOS_ModuleRegister(ZLSS_VerifyFileDetails); + ZOS_ModuleRegister(ZLSS_VerifyFileStatus); + ZOS_ModuleRegister(ZLSS_VerifyFileStatistics); +} + + +void ZLSS_AdminFunctionsShutdown() +{ + ZOS_ModuleUnregister(COMPFIX_VerifyAndLoadLVSystemBeasts); + ZOS_ModuleUnregister(COMPFIX_verify_FlushVolVolumeBuffers); + ZOS_ModuleUnregister(COMPFIX_UnloadlvSystemBeasts); + ZOS_ModuleUnregister(GetZedStuff); + ZOS_ModuleUnregister(ZLOG_RecoveryInfoGet); + ZOS_ModuleUnregister(ZLSS_MSAPItemsXML); + ZOS_ModuleUnregister(ZLSS_PhysicalIOXML); + ZOS_ModuleUnregister(ZLSS_PhysicalIOXMLGlobal); + ZOS_ModuleUnregister(ZLSS_VCF_InternalCmd); + ZOS_ModuleUnregister(ZLSS_ZLogReadMetadataXML); + ZOS_ModuleUnregister(ZLSS_ZLogReadMetadata); + + ZOS_ModuleUnregister(ZLSS_RebuildFileLog); + ZOS_ModuleUnregister(ZLSS_RebuildFileDebug); + ZOS_ModuleUnregister(ZLSS_RebuildFileDetails); + ZOS_ModuleUnregister(ZLSS_RebuildFileStatus); + ZOS_ModuleUnregister(ZLSS_VerifyFileLog); + ZOS_ModuleUnregister(ZLSS_VerifyFileDebug); + ZOS_ModuleUnregister(ZLSS_VerifyFileDetails); + ZOS_ModuleUnregister(ZLSS_VerifyFileStatus); + ZOS_ModuleUnregister(ZLSS_VerifyFileStatistics); +} + + + diff --git a/src/nwnss/zlss/overflow.c b/src/nwnss/zlss/overflow.c index 735f35f..a498dd1 100644 --- a/src/nwnss/zlss/overflow.c +++ b/src/nwnss/zlss/overflow.c @@ -50,7 +50,7 @@ get_sibnode(NameTreeParms_s *parms, Buffer_s *parbuf, Buffer_s *buf, Node_s *parnode = (Node_s *)parbuf->pBuf.data; Node_s *sibnode; STATUS rc = zOK; - SNINT blk = (ind == NODE_LEFTMOST(parnode)) + SNINT blk = (ind == NODE_LEFTMOST(parnode)) ? parnode->child_blk : BRANCH_ENTRY(parnode, ind)->child_blk; /* @@ -66,7 +66,7 @@ get_sibnode(NameTreeParms_s *parms, Buffer_s *parbuf, Buffer_s *buf, goto error_ret; sibnode = (Node_s *)(*sib_buf)->pBuf.data; - if (IS_BRANCH(sibnode) && NODE_OVFLOW(sibnode)) + if (IS_BRANCH(sibnode) && NODE_OVFLOW(sibnode)) { RELEASE_NTREE_BLK_EXCL(parms, *sib_buf); return zERR_NAME_NOT_FOUND_IN_DIRECTORY; @@ -87,11 +87,11 @@ error_ret: ; STATUS ovflow_insert_common(Buffer_s *buf, node_ind_t ind, - dir_key_s *newkey, + dir_key_s *newkey, Blknum_t blk, - Buffer_s *ovflow_buf, SNINT replace, - dlog_op_s **dlops, - dlog_ind_t blki, + Buffer_s *ovflow_buf, SNINT replace, + dlog_op_s **dlops, + dlog_ind_t blki, dlog_ind_t ovflow_blki, SNINT oldoff, SNINT newoff) { @@ -105,17 +105,17 @@ ovflow_insert_common(Buffer_s *buf, node = (Node_s *)buf->pBuf.data; freebytes = node->nfreebytes - newentrysize; - if (replace) + if (replace) { Branch_s *e = BRANCH_ENTRY(node, ind); freebytes += SPACE_NEEDED_BRANCH(e); blk = e->child_blk; } - /* + /* * Check if the node needs to be split to accommodate new entry. */ - if ((! NODE_OVFLOW(node)) && (freebytes >= 0)) + if ((! NODE_OVFLOW(node)) && (freebytes >= 0)) { if (dlops) DLOG_ADD_OP_REPLKEY_COMMON(*dlops, blki, ind, newoff, blk, @@ -130,21 +130,21 @@ ovflow_insert_common(Buffer_s *buf, zASSERT(ovflow_node->numRecs <= 1); zASSERT((ovflow_node->numRecs == 0) || replace); - for (insi=0; insi < ovflow_node->numRecs; ++ insi) + for (insi=0; insi < ovflow_node->numRecs; ++ insi) { node_ind_t i; SNINT e_repl; OVFLOW_ENTRY(ovflow_node, insi, &i, &e_repl, &inse); - if ((diff = (ind - (i + ind_off + (! e_repl)))) <= 0) + if ((diff = (ind - (i + ind_off + (! e_repl)))) <= 0) { - if (diff == 0) + if (diff == 0) { blk = inse->child_blk; if (dlops) - DLOG_ADD_OP_REPLKEY_OVFLOW(*dlops, ovflow_blki, insi, + DLOG_ADD_OP_REPLKEY_OVFLOW(*dlops, ovflow_blki, insi, newoff, blk, oldoff, (e_repl ? - (i+3) : i)); - NODE_REPLACE(ovflow_node, insi, newkey, (BYTE *)&blk, + NODE_REPLACE(ovflow_node, insi, newkey, (BYTE *)&blk, sizeof(blk) + OVFLOW_OP_DATA_SZ); OVFLOW_SET_ENTRY(ovflow_node, insi, i, e_repl); } @@ -152,19 +152,19 @@ ovflow_insert_common(Buffer_s *buf, } else if (! e_repl) ++ ind_off; } - if (diff) + if (diff) { SNINT i = ind - ind_off; -- insi; if (dlops) - DLOG_ADD_OP_INSKEY_OVFLOW(*dlops, ovflow_blki, insi, + DLOG_ADD_OP_INSKEY_OVFLOW(*dlops, ovflow_blki, insi, newoff, blk, (replace ? - (i+3) : i)); NODE_INSERT(ovflow_node, insi, newkey, (BYTE *)&blk, sizeof(blk) + OVFLOW_OP_DATA_SZ); ++ insi; OVFLOW_SET_ENTRY(ovflow_node, insi, i, replace); } - if (! NODE_OVFLOW(node)) + if (! NODE_OVFLOW(node)) { if (dlops) DLOG_ADD_OP_SET_OVFLOW(*dlops, blki, ovflow_buf->BUFblknum); @@ -183,8 +183,8 @@ ovflow_insert_common(Buffer_s *buf, * one. */ STATIC STATUS -leaf_ovflow_insert(NameTreeParms_s *parms, Buffer_s *buf, - node_ind_t ind, Buffer_s **parbuf, node_ind_t parind, +leaf_ovflow_insert(NameTreeParms_s *parms, Buffer_s *buf, + node_ind_t ind, Buffer_s **parbuf, node_ind_t parind, dir_key_s *inskey, BYTE *data, SNINT datasize) { Buffer_s *ovflow_buf; @@ -214,7 +214,7 @@ leaf_ovflow_insert(NameTreeParms_s *parms, Buffer_s *buf, e = LEAF_ENTRY(node, ind); esize = ENTRYSIZE_FROM_KEY(&e->k, LEAF_DATASIZE); di = (Dupinfo_s *)((char *)e + esize); - if (! (e->k.namelen & NAMEovflow)) + if (! (e->k.namelen & NAMEovflow)) { /* * Duplicate keys currently reside in same node. @@ -232,7 +232,7 @@ leaf_ovflow_insert(NameTreeParms_s *parms, Buffer_s *buf, SET_NTREE_BLK_DIRTY(ovflow_buf); alloc = 1; was_inline = 1; - if (e->k.namelen & NAMEdup) + if (e->k.namelen & NAMEdup) { esize += sizeof(Dupinfo_s); @@ -263,9 +263,9 @@ leaf_ovflow_insert(NameTreeParms_s *parms, Buffer_s *buf, e->k.namelen |= NAMEdup|NAMEovflow; new_di.ovflow_blk = ovflow_buf->BUFblknum; - rc = NODE_OVFLOW_EXPAND(parms, &buf, ind, parbuf, + rc = NODE_OVFLOW_EXPAND(parms, &buf, ind, parbuf, &parind, (BYTE *)&new_di, sizeof(new_di)); - if (rc != zOK) + if (rc != zOK) { e->k.namelen &= ~(NAMEdup|NAMEovflow); DEALLOC_NTREE_BLKS(parms, 1, &ovflow_buf); @@ -282,7 +282,7 @@ leaf_ovflow_insert(NameTreeParms_s *parms, Buffer_s *buf, } } else if ((rc = FETCH_NTREE_BLK_EXCL(parms, di->ovflow_blk, &ovflow_buf, 51)) - != zOK) + != zOK) { if (xaction) END_XACTION(xaction); @@ -290,14 +290,14 @@ leaf_ovflow_insert(NameTreeParms_s *parms, Buffer_s *buf, } ovflow_node = (Node_s *)ovflow_buf->pBuf.data; - if (ovflow_node->nfreebytes < esize) + if (ovflow_node->nfreebytes < esize) { Blknum_t nextleaf = ovflow_buf->BUFblknum; RELEASE_NTREE_BLK(parms, ovflow_buf); zASSERT(! xaction); xaction = BEGIN_XACTION(parms); - if ((rc = alloc_ntree_blks(parms, xaction, 1, &ovflow_buf)) != zOK) + if ((rc = alloc_ntree_blks(parms, xaction, 1, &ovflow_buf)) != zOK) return rc; alloc = 1; bzero(&lhdr, sizeof(lhdr)); @@ -319,7 +319,7 @@ leaf_ovflow_insert(NameTreeParms_s *parms, Buffer_s *buf, */ if (xaction != NULL) { - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks, DLOG_DATA_SIZE(&lhdr, dlog_size))); DLOG_INIT_LOG_RECORD(parms->ntree, xaction, dlbuf, dlog_nblks, @@ -330,9 +330,9 @@ leaf_ovflow_insert(NameTreeParms_s *parms, Buffer_s *buf, dlog_ops = DLOG_OPS(dlog_rec); dlog_entries = DLOG_ENTRIES(dlog_rec); dlentry_off = 0; - + blki = 0; - if (dlog_nblks > 1) + if (dlog_nblks > 1) { nodeblki = blki++; DLOG_SET_BLKINFO(dlog_blkinfo, nodeblki, buf,node->vers,xaction); @@ -340,23 +340,23 @@ leaf_ovflow_insert(NameTreeParms_s *parms, Buffer_s *buf, ZLOG_BIND(xaction, buf); } ovflow_blki = blki++; - DLOG_SET_BLKINFO(dlog_blkinfo, ovflow_blki, ovflow_buf, + DLOG_SET_BLKINFO(dlog_blkinfo, ovflow_blki, ovflow_buf, ovflow_node->vers, xaction); if (alloc) DLOG_ALLOC_LEAF(dlhdr, dlog_blkinfo, ovflow_blki, 1); ovflow_node->vers = dlbuf->ZXR_Lsn; ZLOG_BIND(xaction, ovflow_buf); - if (mvsize > 0) + if (mvsize > 0) { DLOG_ADD_OP_MOVE_DUP(dlog_ops, nodeblki, ind, ovflow_blki, NODE_LEFTMOST(ovflow_node), dlentry_off, ovflow_node->numRecs); memmove(dlog_entries, ovflow_node->padbytes, mvsize); - + { SNINT i; node_offset_t *e = (node_offset_t *)dlog_entries; - for (i = 0; i < ovflow_node->numRecs; ++ i) + for (i = 0; i < ovflow_node->numRecs; ++ i) { SNINT nwords = ENTRYSIZE(e); e[0] = FREE_ENTRY_SIZE(nwords); /* to indicate to log that @@ -367,7 +367,7 @@ leaf_ovflow_insert(NameTreeParms_s *parms, Buffer_s *buf, dlentry_off += mvsize; dlog_entries += mvsize; } - if (alloc && ! was_inline) + if (alloc && ! was_inline) { zASSERT(ovflow_node->u.nextleaf != INVALID_BLK); DLOG_ADD_OP_LEAFLIST_INSERT_OVFLOW(dlog_ops, nodeblki, ind, @@ -390,7 +390,7 @@ leaf_ovflow_insert(NameTreeParms_s *parms, Buffer_s *buf, lhdr.nOps = 1; /* insert new dupkey into ovflow node */ dlog_size = esize; dlog_nblks = 1; - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks, DLOG_DATA_SIZE(&lhdr, dlog_size))); DLOG_INIT_LOGICAL_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -399,8 +399,8 @@ leaf_ovflow_insert(NameTreeParms_s *parms, Buffer_s *buf, *DLOG_HDR(dlog_rec) = lhdr; dlog_ops = DLOG_OPS(dlog_rec); dlog_entries = DLOG_ENTRIES(dlog_rec); - - DLOG_SET_BLKINFO(dlog_blkinfo, 0, ovflow_buf, ovflow_node->vers, + + DLOG_SET_BLKINFO(dlog_blkinfo, 0, ovflow_buf, ovflow_node->vers, xaction); ovflow_node->vers = dlbuf->ZXR_Lsn; ZLOG_BIND(xaction, ovflow_buf); @@ -433,8 +433,8 @@ NINT gNameEntryOverflow[3]; * Modifies the tree only if the operation succeeds. */ STATUS -node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, - node_ind_t ind, Buffer_s **parbuf, node_ind_t *pind, +node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, + node_ind_t ind, Buffer_s **parbuf, node_ind_t *pind, dir_key_s *inskey, BYTE *data, SNINT datasize, SNINT *key_in_par) { STATUS rc; @@ -449,24 +449,24 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, node_ind_t parind = *pind; SNINT ovflow_right, do_split, isdup = 0, newentrysize = 0; - if (isleaf) + if (isleaf) { isdup = (ind < -1); - if (isdup) + if (isdup) { Leaf_s *e; ind = - (ind + 3); e = LEAF_ENTRY(node, ind); - if (inskey) + if (inskey) { SNINT ovflow = e->k.namelen & NAMEovflow; newentrysize = ENTRYSIZE_FROM_KEY(inskey, datasize); - if (!(e->k.namelen & NAMEdup)) + if (!(e->k.namelen & NAMEdup)) newentrysize += sizeof(Dupinfo_s); - if (ovflow || ((LEAF_ENTRY_SIZE(e) + newentrysize) - > LEAF_MAX_DUPENTRY_INLINE_SIZE)) + if (ovflow || ((LEAF_ENTRY_SIZE(e) + newentrysize) + > LEAF_MAX_DUPENTRY_INLINE_SIZE)) { - rc = leaf_ovflow_insert(parms, *buf, ind, + rc = leaf_ovflow_insert(parms, *buf, ind, parbuf, parind, inskey, data, datasize); goto error_ret; } @@ -475,12 +475,12 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, node_freebytes -= newentrysize; newentrysize += SPACE_NEEDED_LEAF(e); } - else + else { newentrysize = SPACE_NEEDED_LEAF_FROM_KEY(inskey, datasize); node_freebytes -= newentrysize; } - if (node_freebytes >= 0) + if (node_freebytes >= 0) { rc = zOK; goto do_leaf_insert; @@ -488,31 +488,31 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, } else { - if (NODE_OVFLOW(node)) + if (NODE_OVFLOW(node)) { SNINT i, nrecs; - if ((rc = FETCH_NTREE_BLK_EXCL(parms, node->u.ovflow_blk, - &ovflow_buf, 52)) != zOK) + if ((rc = FETCH_NTREE_BLK_EXCL(parms, node->u.ovflow_blk, + &ovflow_buf, 52)) != zOK) { goto error_ret; } ovflow_node = (Node_s *)(ovflow_buf->pBuf.data); ovflow_blk = ovflow_buf->BUFblknum; nrecs = OVFLOW_NRECS(ovflow_node); - for (i = 0; i < nrecs; ++i) + for (i = 0; i < nrecs; ++i) { node_ind_t nextind; SNINT replace; Branch_s *e; OVFLOW_ENTRY(ovflow_node, i, &nextind, &replace, &e); - if (replace) + if (replace) { - if (BRANCH_ENTRY_SIZE(NODE_ENTRY(node, nextind)) < + if (BRANCH_ENTRY_SIZE(NODE_ENTRY(node, nextind)) < BRANCH_ENTRY_SIZE(e)) { - node_freebytes += - BRANCH_ENTRY_SIZE(NODE_ENTRY(node, nextind)); - node_freebytes -= BRANCH_ENTRY_SIZE(e); + node_freebytes += + BRANCH_ENTRY_SIZE(NODE_ENTRY(node, nextind)); + node_freebytes -= BRANCH_ENTRY_SIZE(e); gNameEntryOverflow[0]++; } else @@ -522,12 +522,12 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, } else { - node_freebytes -= BRANCH_ENTRY_SIZE(e); + node_freebytes -= BRANCH_ENTRY_SIZE(e); gNameEntryOverflow[2]++; } } } - else + else { rc = zOK; goto error_ret; @@ -539,7 +539,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, /* * Handle branch/leaf node overflow. * Leaf overflow is always handled in the context of an insert operation. - * + * * First try merging/rearranging with the right brother node (if * any) and, if failed, with the left brother node. */ @@ -547,7 +547,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, ovflow_right = 1; if (*parbuf) parnode = (Node_s *)(*parbuf)->pBuf.data; - for (;;) + for (;;) { SNINT threshold; Buffer_s *sib_buf, *new_buf; @@ -570,13 +570,13 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, dlog_ind_t srcblki = 0, dstblki, parblki, par_ovflow_blki = WALL_PUNT, ovflow_blki = WALL_PUNT; dlog_offset_t new_dlentry_off; - for (dlog_nrecs = 0; dlog_nrecs < 3; ++ dlog_nrecs) + for (dlog_nrecs = 0; dlog_nrecs < 3; ++ dlog_nrecs) { bzero(&lhdr[dlog_nrecs], sizeof(lhdr[dlog_nrecs])); dlog_size[dlog_nrecs] = 0; dlog_nblks[dlog_nrecs] = 0; } - if (do_split) + if (do_split) { sib_freebytes = NODE_MAX_FREEBYTES; ovflow_right = 1; @@ -584,7 +584,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, par_freebytes = *parbuf ? parnode->nfreebytes : NODE_MAX_FREEBYTES; if (isleaf) ++ lhdr[0].nOps; /* Insert new blk in nextleaf list */ } - else + else { SNINT sib_ind; @@ -592,10 +592,10 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, || ((! ovflow_right) && (parind == NODE_LEFTMOST(parnode)))) goto try_other_side; - sib_ind = ovflow_right ? NODE_NEXT(parnode, parind) : + sib_ind = ovflow_right ? NODE_NEXT(parnode, parind) : NODE_PREV(parnode, parind); if ((rc = get_sibnode(parms, *parbuf, *buf, - ovflow_right, sib_ind, &sib_buf)) != zOK) + ovflow_right, sib_ind, &sib_buf)) != zOK) { goto try_other_side; } @@ -640,7 +640,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, * respective tree nodes. Each such operation should involve * modifying only one node and must be independent of the others. * Each of these three pieces is logged logically in separate - * log records as part of a new Xaction. However a leaf insert is + * log records as part of a new Xaction. However a leaf insert is * done separately as part of incoming Xaction. */ nrecs_moved = 0; @@ -648,9 +648,9 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, dest_freebytes = sib_freebytes; srci = ovflow_right ? NODE_LAST(srcnode) : NODE_FIRST(srcnode); diff = dest_freebytes - threshold; - if (! isleaf) + if (! isleaf) { - if (! do_split) + if (! do_split) { dest_freebytes -= SPACE_NEEDED_BRANCH(midentry); ++ lhdr[0].nOps; /* Insert midentry into destnode */ @@ -666,7 +666,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, OVFLOW_ENTRY(ovflow_node, ovflow_ind, &ind, &replace, &inse); } endi = (ovflow_right || isdup || replace) ? ind : ind + src_incr; - if ((! ovflow_right) && (endi < srci)) + if ((! ovflow_right) && (endi < srci)) srci = endi; for (;;) { @@ -679,11 +679,11 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, */ par_repl_ovflow_ind = -1; /* Get next entry to move */ - if (srci == endi) - { + if (srci == endi) + { if (isdup || replace) logsize = ENTRYBYTES(NODE_ENTRY(srcnode, endi)); - else + else { srci -= src_incr; logsize = 0; @@ -699,28 +699,28 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, size = SPACE_NEEDED_BRANCH_FROM_KEY(key); par_repl_blk = inse->child_blk; par_repl_ovflow_ind = ovflow_ind; - if (ovflow_ind != ovflow_endi) + if (ovflow_ind != ovflow_endi) { node_ind_t i; ovflow_ind += src_incr; - OVFLOW_ENTRY(ovflow_node, ovflow_ind, + OVFLOW_ENTRY(ovflow_node, ovflow_ind, &i, &replace, &inse); endi = (ovflow_right || replace) ? i : i + src_incr; } else endi = srci; } } - else + else { - if (isleaf) + if (isleaf) { Leaf_s *entry = LEAF_ENTRY(srcnode, srci); key = &entry->k; size = SPACE_NEEDED_LEAF(entry); logsize = size - OFFSETSZ; } - else + else { Branch_s *entry = BRANCH_ENTRY(srcnode, srci); key = &entry->k; @@ -733,17 +733,17 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, dest_freebytes -= size; newdiff = dest_freebytes - threshold; if (stop || (dest_freebytes < 0) || - ((MYABS(newdiff) > diff) && (src_freebytes >= 0))) + ((MYABS(newdiff) > diff) && (src_freebytes >= 0))) { SNINT brsize; - /* - * We moved as many entries as we could - * from srcnode to destnode + /* + * We moved as many entries as we could + * from srcnode to destnode */ if (! data_moved) goto abort_this_side; - /* + /* * nrecs_moved now holds # of entries that can be * actually moved; prevkey indicates the last entry * moved; key indicates the first entry NOT moved. @@ -756,9 +756,9 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, dlog_size[0] += BRANCH_ENTRY_SIZE(midentry); dlog_size[0] += brsize - OFFSETSZ; /* log new par entry */ ++ lhdr[0].nOps;/* Insert/repl parent node's midentry */ - if (isleaf) + if (isleaf) { - if (ovflow_right) + if (ovflow_right) { /* Adjust par_repl_ind to point to last moved entry */ @@ -773,7 +773,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, zASSERT(size == brsize); /* size gives size of entry to move to parent node */ src_freebytes += size; - /* + /* * 1. Delete moved entry from srcnode (unless it is * from ovflow_node) * 2. Change the Leftmost child blk# of right node. @@ -785,12 +785,12 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, } /* Couldn't make enough space in srcnode? abort */ - if (src_freebytes < 0) + if (src_freebytes < 0) goto abort_this_side; par_freebytes -= brsize; break; } - else + else { stop = (newdiff <= 0); src_freebytes += size; @@ -801,7 +801,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, } prevkey = key; data_moved = 1; - par_repl_ovflow_ind = -1; /* the ovflow entry (if any) is + par_repl_ovflow_ind = -1; /* the ovflow entry (if any) is * not going to the parent node.*/ diff = MYABS(newdiff); } @@ -816,15 +816,15 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, { SNINT i, nrecs; nrecs = OVFLOW_NRECS(ovflow_node); - for (i = 0; i < nrecs; ++i) + for (i = 0; i < nrecs; ++i) { node_ind_t nextind; SNINT replace; Branch_s *e; OVFLOW_ENTRY(ovflow_node, i, &nextind, &replace, &e); - if (replace) - dlog_size[2] += + if (replace) + dlog_size[2] += BRANCH_ENTRY_SIZE(NODE_ENTRY(node, nextind)); dlog_size[2] += BRANCH_ENTRY_SIZE(e); if ((par_repl_ovflow_ind != i) || replace) @@ -837,7 +837,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, ++ lhdr[2].nOps; /* Clear the branch ovflow condition */ } } - + { Blknum_t nearBlocks[3]; int near_index = 0; @@ -847,15 +847,15 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, SNINT other_ops; xaction = BEGIN_XACTION(parms); - if (nblks > 0) + if (nblks > 0) { /* We use the small array 'nearBlocks' to pass information - as to where a block should be allocated near. 'nblks' - holds the number of blocks that need to be allocated. - The three 'near_index++' below depend on the order of - the allocated blocks being used. Usage of '--nblks' was - used to determine block placement. It appears that - only 2 blocks can be allocated at a time (see 'tmp_buf' - defined to hold only TWO Buffer_s pointers). + as to where a block should be allocated near. 'nblks' + holds the number of blocks that need to be allocated. + The three 'near_index++' below depend on the order of + the allocated blocks being used. Usage of '--nblks' was + used to determine block placement. It appears that + only 2 blocks can be allocated at a time (see 'tmp_buf' + defined to hold only TWO Buffer_s pointers). */ if ( isroot ) { nearBlocks[near_index++] = NT_ALLOC_NEW_AREA; @@ -864,21 +864,21 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, nearBlocks[near_index++] = near; } if ( par_freebytes < 0 ) { - /* This block is an oveflow block so it gets freed in + /* This block is an oveflow block so it gets freed in just a little while. We place near parent because parent also needs to be written. */ nearBlocks[near_index] = nearParent; } - if (((rc = alloc_ntree_blks2(parms, xaction, nblks, nearBlocks, tmp_buf )) - == zOK) && do_split && isroot) + if (((rc = alloc_ntree_blks2(parms, xaction, nblks, nearBlocks, tmp_buf )) + == zOK) && do_split && isroot) { zASSERT( parms->ntree != NULL ); INIT_BRANCH_NODE((Node_s *)tmp_buf[0]->pBuf.data, 0, &parms->ntree->ZFSNAMETREEinternalID ); if ((rc = ntree_ch_root_node(parms, xaction, *buf, - tmp_buf[0])) != zOK) + tmp_buf[0])) != zOK) { - /* + /* * FixFixFix6: Should not explicitly free the blk when * we can actually abort a transaction. Till then ... */ @@ -887,7 +887,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, } parms->ntree->zfsBtree.levelsInTree++; } - if (rc != zOK) + if (rc != zOK) { END_XACTION(xaction); if (sib_buf) RELEASE_NTREE_BLK(parms, sib_buf); @@ -912,9 +912,9 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, DLOG_DATA_SIZE(&lhdr[0], dlog_size[0]) + DLOG_DATA_SIZE(&lhdr[1], dlog_size[1]) + DLOG_DATA_SIZE(&lhdr[2], dlog_size[2])) - <= ZLOG_MAXIMUM_RECORD_SIZE) + <= ZLOG_MAXIMUM_RECORD_SIZE) { - if (other_ops > 0) + if (other_ops > 0) { lhdr[0].nOps += other_ops; srcblki = 0; @@ -922,13 +922,13 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, lhdr[1].nOps = lhdr[2].nOps = 0; dlog_size[0] += dlog_size[1] + dlog_size[2]; } - else + else { /* Log the work of record 1 separately */ zASSERT(other_ops > 0); dlog_nblks[0] = (par_freebytes < 0) + 2 + (srcblki >= 0); - zASSERT(DLOG_SIZE(dlog_nblks[0], - DLOG_DATA_SIZE(&lhdr[0], dlog_size[0])) + zASSERT(DLOG_SIZE(dlog_nblks[0], + DLOG_DATA_SIZE(&lhdr[0], dlog_size[0])) <= ZLOG_MAXIMUM_RECORD_SIZE); ++ dlog_nrecs; @@ -939,13 +939,13 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, (DLOG_SIZE(dlog_nblks[1], DLOG_DATA_SIZE(&lhdr[1], dlog_size[1]) + DLOG_DATA_SIZE(&lhdr[2], dlog_size[2])) - <= ZLOG_MAXIMUM_RECORD_SIZE)) + <= ZLOG_MAXIMUM_RECORD_SIZE)) { dlog_size[1] += dlog_size[2]; lhdr[1].nOps += lhdr[2].nOps; lhdr[2].nOps = 0; } - else if (lhdr[2].nOps > 0) + else if (lhdr[2].nOps > 0) { /* Log the work of record 2 separately */ dlog_nblks[1] = 2; /* src and destnodes */ @@ -959,7 +959,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, /* * Now allocate the log record of appropriate length */ - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks[0], DLOG_DATA_SIZE(&lhdr[0], dlog_size[0]))); DLOG_INIT_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -975,19 +975,19 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, blki = 0; parblki = blki++; dstblki = blki++; - if (srcblki >= 0) + if (srcblki >= 0) { srcblki = blki++; DLOG_SET_BLKINFO(dlog_blkinfo, srcblki, (*buf), srcnode->vers, xaction); ZLOG_BIND(xaction, *buf); } - if (par_freebytes < 0) + if (par_freebytes < 0) { par_ovflow_buf = tmp_buf[--nblks]; par_ovflow_blki = blki++; DLOG_SET_BLKINFO(dlog_blkinfo, par_ovflow_blki, - par_ovflow_buf, + par_ovflow_buf, ((Node_s *)par_ovflow_buf->pBuf.data)->vers, xaction); zASSERT( parms->ntree != NULL ); INIT_BRANCH_NODE((Node_s *)par_ovflow_buf->pBuf.data, 1, @@ -998,20 +998,20 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, if ((! isleaf) && ((dlog_nrecs <= 1) || (par_repl_ovflow_ind >= 0))) { ovflow_blki = blki++; - DLOG_SET_BLKINFO(dlog_blkinfo, ovflow_blki, + DLOG_SET_BLKINFO(dlog_blkinfo, ovflow_blki, ovflow_buf, ovflow_node->vers, xaction); } - if (do_split) + if (do_split) { sib_alloc = 1; sib_buf = tmp_buf[--nblks]; destnode = (Node_s *)(sib_buf->pBuf.data); ovflow_blk = sib_buf->BUFblknum; zASSERT( parms->ntree != NULL ); - if (isleaf) + if (isleaf) { - INIT_LEAF_NODE(destnode, 0, - &parms->ntree->ZFSNAMETREEinternalID ); + INIT_LEAF_NODE(destnode, 0, + &parms->ntree->ZFSNAMETREEinternalID ); DLOG_ADD_OP_LEAFLIST_INSERT(dlog_ops, srcblki, dstblki, node->u.nextleaf); destnode->u.nextleaf = node->u.nextleaf; @@ -1019,16 +1019,16 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, srcnode->vers = dlbuf->ZXR_Lsn; } else INIT_BRANCH_NODE(destnode, 0, - &parms->ntree->ZFSNAMETREEinternalID ); + &parms->ntree->ZFSNAMETREEinternalID ); DLOG_SET_BLKINFO(dlog_blkinfo, dstblki, sib_buf, destnode->vers, xaction); DLOG_ALLOC_BLK(dlhdr, dlog_blkinfo, dstblki, isleaf, 0); - if (isroot) + if (isroot) { zASSERT(nblks > 0); *parbuf = tmp_buf[--nblks]; parnode = (Node_s *)((*parbuf)->pBuf.data); - DLOG_SET_BLKINFO(dlog_blkinfo, parblki, + DLOG_SET_BLKINFO(dlog_blkinfo, parblki, *parbuf, parnode->vers, xaction); DLOG_ALLOC_BRANCH(dlhdr, dlog_blkinfo, parblki, 0); parnode->child_blk = (*buf)->BUFblknum; @@ -1041,7 +1041,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, else DLOG_SET_BLKINFO(dlog_blkinfo, parblki, (*parbuf), parnode->vers, xaction); } - else + else { DLOG_SET_BLKINFO(dlog_blkinfo, parblki, (*parbuf), parnode->vers, xaction); @@ -1058,7 +1058,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, * ovflow/insertion. Now we actually perform it, splitting/rearranging * as necessary. */ - + { SNINT i, compresult; dlog_offset_t old_dlentry_off = 0; @@ -1069,37 +1069,37 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, rightnode = destnode, rightblki = dstblki; else rightnode = srcnode, rightblki = srcblki; - if (! isleaf) + if (! isleaf) { - if (! do_split) + if (! do_split) { Blknum_t blk; node_ind_t destind; - if (ovflow_right) + if (ovflow_right) { destind = NODE_LEFTMOST(destnode); blk = destnode->child_blk; } - else + else { destind = NODE_LAST(destnode); blk = srcnode->child_blk; } - NODE_INSERT(destnode, destind, &midentry->k, (BYTE *)&blk, + NODE_INSERT(destnode, destind, &midentry->k, (BYTE *)&blk, sizeof(blk)); old_dlentry_off = dlentry_off; - DLOG_ADD_OP_INSKEY(dlog_ops, dstblki, destind, + DLOG_ADD_OP_INSKEY(dlog_ops, dstblki, destind, dlentry_off, blk); DLOG_ADD_ENTRY(dlog_entries, dlentry_off, midentry, 0); destnode->vers = dlbuf->ZXR_Lsn; } new_dlentry_off = dlentry_off; - if (par_repl_ovflow_ind >= 0) + if (par_repl_ovflow_ind >= 0) { SNINT size; Branch_s *logb = (Branch_s *)dlog_entries; - Branch_s *b = BRANCH_ENTRY(ovflow_node, + Branch_s *b = BRANCH_ENTRY(ovflow_node, par_repl_ovflow_ind); keycopy(&logb->k, &b->k); logb->child_blk = b->child_blk; @@ -1109,17 +1109,17 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, dlentry_off += size; dlog_entries += size; } - else + else { DLOG_ADD_OP_DELETE(dlog_ops, srcblki, par_repl_ind, dlentry_off); - DLOG_ADD_ENTRY(dlog_entries, dlentry_off, - (BYTE *)BRANCH_ENTRY(srcnode, par_repl_ind), + DLOG_ADD_ENTRY(dlog_entries, dlentry_off, + (BYTE *)BRANCH_ENTRY(srcnode, par_repl_ind), isleaf); srcnode->vers = dlbuf->ZXR_Lsn; } } - else + else { if (! do_split) /* old par entry */ { @@ -1143,13 +1143,13 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, * current tree level. */ /* parnode's middle entry index */ - i = (ovflow_right && ! do_split) + i = (ovflow_right && ! do_split) ? NODE_NEXT(parnode, parind) : parind; /* - * If rearranging, replace midentry in parent node with + * If rearranging, replace midentry in parent node with * . */ - rc = ovflow_insert_common(*parbuf, i, par_repl_key, ovflow_blk, + rc = ovflow_insert_common(*parbuf, i, par_repl_key, ovflow_blk, par_ovflow_buf, ! do_split, &dlog_ops, parblki, par_ovflow_blki, old_dlentry_off, new_dlentry_off); zASSERT(rc == zOK); @@ -1159,7 +1159,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, * accordingly. */ compresult = keycomp(inskey, par_repl_key); - if (ovflow_right == (compresult >= 0)) + if (ovflow_right == (compresult >= 0)) { new_buf = sib_buf; *pind = parind = ovflow_right ? NODE_NEXT(parnode, parind) @@ -1168,7 +1168,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, else new_buf = *buf; if (key_in_par) *key_in_par = (compresult == 0); - if (! isleaf) + if (! isleaf) { DLOG_ADD_OP_CH_LCHILD(dlog_ops, rightblki, rightnode->child_blk, par_repl_blk); @@ -1183,18 +1183,18 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, } SET_NTREE_BLK_DIRTY(*parbuf); parnode->vers = dlbuf->ZXR_Lsn; - if (par_ovflow_buf) + if (par_ovflow_buf) { ((Node_s *)par_ovflow_buf->pBuf.data)->vers = dlbuf->ZXR_Lsn; } } - if (lhdr[1].nOps > 0) + if (lhdr[1].nOps > 0) { dlog_ind_t blki; ZLOG_ReleaseRecord(xaction); - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks[1], DLOG_DATA_SIZE(&lhdr[1], dlog_size[1]))); DLOG_INIT_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -1217,8 +1217,8 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, destnode->vers, xaction); ZLOG_BIND(xaction, sib_buf); } - - if (nrecs_moved > 0) + + if (nrecs_moved > 0) { SNINT i; node_ind_t srci, dsti; @@ -1237,24 +1237,24 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, dsti = NODE_LAST(destnode); } - DLOG_ADD_OP_MOVE(dlog_ops, srcblki, srci, dstblki, dsti, + DLOG_ADD_OP_MOVE(dlog_ops, srcblki, srci, dstblki, dsti, dlentry_off, nrecs_moved); - for (i = srci; i < srci + nrecs_moved; ++ i) + for (i = srci; i < srci + nrecs_moved; ++ i) { - DLOG_ADD_ENTRY(dlog_entries, dlentry_off, + DLOG_ADD_ENTRY(dlog_entries, dlentry_off, NODE_ENTRY(srcnode, i), isleaf); } node_ncopy(destnode, dsti, srcnode, srci, nrecs_moved, 1); } - if (lhdr[2].nOps > 0) + if (lhdr[2].nOps > 0) { dlog_ind_t blki; ZLOG_ReleaseRecord(xaction); zASSERT(! isleaf); - ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks[2], + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks[2], DLOG_DATA_SIZE(&lhdr[2], dlog_size[2]))); DLOG_INIT_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -1271,7 +1271,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, srcblki = blki++; dstblki = blki++; ovflow_blki = blki++; - DLOG_SET_BLKINFO(dlog_blkinfo, ovflow_blki, + DLOG_SET_BLKINFO(dlog_blkinfo, ovflow_blki, ovflow_buf, ovflow_node->vers, xaction); DLOG_SET_BLKINFO(dlog_blkinfo, srcblki, (*buf), @@ -1286,7 +1286,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, SNINT destnode_recs = destnode->numRecs; /* We SHOULD process ovflow entries in reverse order */ - for (i = OVFLOW_NRECS(ovflow_node) - 1; i >= 0; --i) + for (i = OVFLOW_NRECS(ovflow_node) - 1; i >= 0; --i) { node_ind_t targetind; SNINT replace, oldentry_off = 0; @@ -1296,9 +1296,9 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, OVFLOW_ENTRY(ovflow_node, i, &targetind, &replace, &e); - /* + /* * Re-find the entry to operate on, as some entries moved due to - * rebalancing + * rebalancing */ if (ovflow_right) { @@ -1307,14 +1307,14 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, targetnode = srcnode; targetblki = srcblki; } - else + else { targetnode = destnode; targetblki = dstblki; targetind -= srcnode_recs + (par_repl_ovflow_ind < 0); } } - else + else { if (targetind >= nrecs_moved) { @@ -1337,17 +1337,17 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, { /* Log the old targetnode entry */ oldentry_off = dlentry_off; - DLOG_ADD_ENTRY(dlog_entries, dlentry_off, + DLOG_ADD_ENTRY(dlog_entries, dlentry_off, NODE_ENTRY(targetnode, targetind), 0); } if (par_repl_ovflow_ind != i) { /* Perform the insert/replace in targetnode */ - DLOG_ADD_OP_REPLKEY_COMMON(dlog_ops, targetblki, targetind, - dlentry_off, e->child_blk, + DLOG_ADD_OP_REPLKEY_COMMON(dlog_ops, targetblki, targetind, + dlentry_off, e->child_blk, (replace ? 0 : DLOG_OP_INSERT), oldentry_off, 0); - node_insert_common(targetnode, targetind, &e->k, - (BYTE *)&e->child_blk, sizeof(e->child_blk), + node_insert_common(targetnode, targetind, &e->k, + (BYTE *)&e->child_blk, sizeof(e->child_blk), replace); } else if (replace) @@ -1356,7 +1356,7 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, * This ovflow entry moved to parent entry. * So just delete its old entry from targetnode. */ - DLOG_ADD_OP_DELETE(dlog_ops, targetblki, targetind, + DLOG_ADD_OP_DELETE(dlog_ops, targetblki, targetind, oldentry_off); NODE_DELETE(targetnode, targetind); } @@ -1380,26 +1380,26 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, DEALLOC_NTREE_BLKS(parms, 1, &ovflow_buf); ovflow_buf = 0; } - else + else { ZLOG_ReleaseRecordAndLogEnd(xaction); END_XACTION(xaction); } /* Reset the current node buffer pointer */ - if (new_buf != *buf) + if (new_buf != *buf) { sib_buf = *buf; *buf = new_buf; } SET_NTREE_BLK_DIRTY(*buf); - if (par_ovflow_buf) + if (par_ovflow_buf) { RELEASE_NTREE_BLK_DIRTY(parms, par_ovflow_buf); par_ovflow_buf = 0; } - if (sib_buf) + if (sib_buf) { RELEASE_NTREE_BLK_DIRTY(parms, sib_buf); sib_buf = 0; @@ -1412,13 +1412,13 @@ node_ovflow_insert(NameTreeParms_s *parms, Buffer_s **buf, abort_this_side: ; if (sib_buf) RELEASE_NTREE_BLK_EXCL(parms, sib_buf); try_other_side: - if (do_split) + if (do_split) { zASSERT(isleaf && isdup); return leaf_ovflow_insert(parms, *buf, ind, parbuf, parind, inskey, data, datasize); } - else + else { if (ovflow_right) { /* If right node didn't work, try left */ ovflow_right = 0; @@ -1446,12 +1446,12 @@ do_leaf_insert: ; */ node = (Node_s *)((*buf)->pBuf.data); node_findkey(node, inskey, &ind); - newentrysize = inskey + newentrysize = inskey ? ENTRYSIZE_FROM_KEY(inskey, datasize) : datasize; dlog_size = newentrysize; /* - * Perform the entry insertion in the context of incoming + * Perform the entry insertion in the context of incoming * transaction. * Perform entry expansion in the context of incoming xaction * only if we are inserting a new entry into the entry as part of @@ -1462,7 +1462,7 @@ do_leaf_insert: ; if (isdup && ! inskey) { xaction = BEGIN_XACTION(parms); - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(1, DLOG_DATA_SIZE(&lhdr, dlog_size))); DLOG_INIT_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -1471,7 +1471,7 @@ do_leaf_insert: ; else { xaction = parms->xaction; - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(1, DLOG_DATA_SIZE(&lhdr, dlog_size))); DLOG_INIT_LOGICAL_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -1482,27 +1482,27 @@ do_leaf_insert: ; dlog_ops = DLOG_OPS(dlog_rec); dlog_entries = DLOG_ENTRIES(dlog_rec); dlentry_off = 0; - + DLOG_SET_BLKINFO(dlog_blkinfo, 0, *buf, node->vers, xaction); node->vers = dlbuf->ZXR_Lsn; ZLOG_BIND(xaction, *buf); - if (isdup) + if (isdup) { BYTE *e; SNINT size; node_expand_entry(node, ind, inskey, data, datasize); - DLOG_ADD_OP_EXPAND(dlog_ops, 0, ind, + DLOG_ADD_OP_EXPAND(dlog_ops, 0, ind, inskey, newentrysize, dlentry_off); e = (BYTE *)LEAF_ENTRY(node, ind); size = LEAF_ENTRY_SIZE(e); - DLOG_ADD_ENTRY(dlog_entries, dlentry_off, + DLOG_ADD_ENTRY(dlog_entries, dlentry_off, e + (size - newentrysize), 1); } - else + else { NODE_INSERT(node, ind, inskey, data, datasize); DLOG_ADD_OP_INSERT(dlog_ops, 0, ind, dlentry_off); - DLOG_ADD_ENTRY(dlog_entries, dlentry_off, + DLOG_ADD_ENTRY(dlog_entries, dlentry_off, NODE_ENTRY(node, NODE_NEXT(node, ind)), 1); } if (xaction != parms->xaction) @@ -1515,7 +1515,7 @@ do_leaf_insert: ; SET_NTREE_BLK_DIRTY(*buf); } error_ret: ; - if (ovflow_buf) + if (ovflow_buf) RELEASE_NTREE_BLK(parms, ovflow_buf); return rc; } diff --git a/src/nwnss/zlss/purgeLog.c b/src/nwnss/zlss/purgeLog.c index 4e5b319..3c0288c 100644 --- a/src/nwnss/zlss/purgeLog.c +++ b/src/nwnss/zlss/purgeLog.c @@ -59,16 +59,16 @@ #include "comnAuthorize.h" #include "volume.h" #include "dirQuotas.h" -#include "objectIDStore.h" +#include "objectIDStore.h" #include "eflTree.h" - +#include "mpkmisc.h" #if NSS_DEBUG IS_ENABLED typedef struct PurgeRec_s { - Blknum_t block; - NINT slot; + Blknum_t block; + NINT slot; } PurgeRec_s; #define MAX_PURGE_RECS (1<<12) @@ -76,300 +76,300 @@ PurgeRec_s PurgeRec[MAX_PURGE_RECS]; NINT PurgeRecIndex = 0; #define BUG_PURGE_REC(_blk, _slot) \ { \ - PurgeRec[PurgeRecIndex & (MAX_PURGE_RECS - 1)].block = (_blk); \ - PurgeRec[PurgeRecIndex++ & (MAX_PURGE_RECS - 1)].slot = (_slot); \ + PurgeRec[PurgeRecIndex & (MAX_PURGE_RECS - 1)].block = (_blk); \ + PurgeRec[PurgeRecIndex++ & (MAX_PURGE_RECS - 1)].slot = (_slot); \ } #define MAX_PURGE_BLOCKS (1<<7) Blknum_t PurgeBlocks[MAX_PURGE_BLOCKS] = { 0 }; NINT PurgeBlockIndex = 0; #define BUG_PURGE_BLOCK(_blk) \ - (PurgeBlocks[PurgeBlockIndex++ & (MAX_PURGE_BLOCKS - 1)] = _blk) + (PurgeBlocks[PurgeBlockIndex++ & (MAX_PURGE_BLOCKS - 1)] = _blk) void DisplayPurgeLogInfo2 ( - GeneralMsg_s *genMsg, - ZfsVolume_s *volume, - ZfsPurgeLogBeast_s *purgeLog ) + GeneralMsg_s *genMsg, + ZfsVolume_s *volume, + ZfsPurgeLogBeast_s *purgeLog ) { - IoMsg_s iomsg; - Buffer_s *buffer; - Blknum_t block; - Blknum_t newBlock; - NINT slot; - NINT blockCount = 0; - NINT availCount = 0; - NINT beastDeleteCount = 0; - NINT beastCompCount = 0; - NINT truncCount = 0; - NINT blockFreeCount = 0; - NINT fixVisibCount = 0; - NINT userScanCount = 0; - NINT userFreeCount = 0; - NINT userClearCount = 0; - NINT dirFreeCount = 0; - NINT dirUsedCount = 0; - NINT epochRemoveCount = 0; - NINT resetEFLCount = 0; - PurgeLogBlock_s *pLogBlock; - PurgeBeastEntry_s *beastEntry; - TruncateEntry_s *truncEntry; - PurgeBlockEntry_s *blockEntry; - FreeEntry_s *freeEntry; - FixVisEntry_s *visibEntry; - UserClearEntry_s *userClearEntry; - UserScanEntry_s *userScanEntry; - UserEntry_s *userEntry; - DirEntry_s *dirEntry; - DirUsed_s *dirUsed; - EFLEpochRemove_s *epochRemove; - EFLTreeReset_s *resetEFL; + IoMsg_s iomsg; + Buffer_s *buffer; + Blknum_t block; + Blknum_t newBlock; + NINT slot; + NINT blockCount = 0; + NINT availCount = 0; + NINT beastDeleteCount = 0; + NINT beastCompCount = 0; + NINT truncCount = 0; + NINT blockFreeCount = 0; + NINT fixVisibCount = 0; + NINT userScanCount = 0; + NINT userFreeCount = 0; + NINT userClearCount = 0; + NINT dirFreeCount = 0; + NINT dirUsedCount = 0; + NINT epochRemoveCount = 0; + NINT resetEFLCount = 0; + PurgeLogBlock_s *pLogBlock; + PurgeBeastEntry_s *beastEntry; + TruncateEntry_s *truncEntry; + PurgeBlockEntry_s *blockEntry; + FreeEntry_s *freeEntry; + FixVisEntry_s *visibEntry; + UserClearEntry_s *userClearEntry; + UserScanEntry_s *userScanEntry; + UserEntry_s *userEntry; + DirEntry_s *dirEntry; + DirUsed_s *dirUsed; + EFLEpochRemove_s *epochRemove; + EFLTreeReset_s *resetEFL; - if (purgeLog == NULL) + if (purgeLog == NULL) { - printf(MSGNot("Error getting the purge log beast")); - return; + printf(MSGNot("Error getting the purge log beast")); + return; } - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* Latch the log */ - DBG_DebugPrintf(LBLUE, MSGNot("First Record = %d\n"), purgeLog->p.firstBlock); - DBG_DebugPrintf(LBLUE, MSGNot("Next Block = %d\n"), purgeLog->nextUnused.block); - DBG_DebugPrintf(LBLUE, MSGNot("Next Slot = %d\n"), purgeLog->nextUnused.slot); + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* Latch the log */ + DBG_DebugPrintf(LBLUE, MSGNot("First Record = %d\n"), purgeLog->p.firstBlock); + DBG_DebugPrintf(LBLUE, MSGNot("Next Block = %d\n"), purgeLog->nextUnused.block); + DBG_DebugPrintf(LBLUE, MSGNot("Next Slot = %d\n"), purgeLog->nextUnused.slot); - /* count the number of blocks in the purge log */ - block = purgeLog->p.firstBlock; - while(block != 0) - { - READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); - SET_DEBUG_ID(iomsg, 0); - buffer = ZFS_ReadPoolBlk(genMsg, &iomsg); - if (buffer == NULL) - { - printf(MSGNot("Error reading block %d\n"),block); - goto errorExit; - } + /* count the number of blocks in the purge log */ + block = purgeLog->p.firstBlock; + while(block != 0) + { + READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); + SET_DEBUG_ID(iomsg, 0); + buffer = ZFS_ReadPoolBlk(genMsg, &iomsg); + if (buffer == NULL) + { + printf(MSGNot("Error reading block %d\n"),block); + goto errorExit; + } - blockCount++; - newBlock = ((PurgeLogBlock_s *)buffer->pBuf.data)->nextBlock; - CACHE_RELEASE(buffer); - if (block == purgeLog->nextUnused.block) + blockCount++; + newBlock = ((PurgeLogBlock_s *)buffer->pBuf.data)->nextBlock; + CACHE_RELEASE(buffer); + if (block == purgeLog->nextUnused.block) { - break; + break; } - else - { - block = newBlock; - } - } - DBG_DebugPrintf(LBLUE, MSGNot("Number of blocks in log = %d\n"), blockCount); - DBG_DebugPrintf(LBLUE, MSGNot("Number of entries in log = %d\n"), - (blockCount-1) * MAX_PURGE_LOG_ENTRIES + purgeLog->nextUnused.slot); + else + { + block = newBlock; + } + } + DBG_DebugPrintf(LBLUE, MSGNot("Number of blocks in log = %d\n"), blockCount); + DBG_DebugPrintf(LBLUE, MSGNot("Number of entries in log = %d\n"), + (blockCount-1) * MAX_PURGE_LOG_ENTRIES + purgeLog->nextUnused.slot); - /* follow avail list */ - block = purgeLog->freeList.block; - slot = purgeLog->freeList.slot; - while(block != 0) - { - READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); - SET_DEBUG_ID(iomsg, 0); - buffer = ZFS_ReadPoolBlk(genMsg, &iomsg); - if (buffer == NULL) + /* follow avail list */ + block = purgeLog->freeList.block; + slot = purgeLog->freeList.slot; + while(block != 0) + { + READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); + SET_DEBUG_ID(iomsg, 0); + buffer = ZFS_ReadPoolBlk(genMsg, &iomsg); + if (buffer == NULL) + { + printf(MSGNot("Error reading block %d\n"),block); + goto errorExit; + } + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + availCount++; + block = ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->block; + slot = ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->slot; + if (pLogBlock->logEntry[slot].type != PLOG_UNUSED) { - printf(MSGNot("Error reading block %d\n"),block); - goto errorExit; + DBG_DebugPrintf(RED,MSGNot("Free list has an entry not marked free\n")); } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - availCount++; - block = ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->block; - slot = ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->slot; - if (pLogBlock->logEntry[slot].type != PLOG_UNUSED) + CACHE_RELEASE(buffer); + } + DBG_DebugPrintf(LBLUE, MSGNot("Number of avail entries in log = %d\n"), availCount); + + /* + * Scan all entries in the log and report usage + */ + DBG_DebugPrintf(LBLUE, MSGNot("******* Purge Log Entries *******\n")); + availCount = 0; + block = purgeLog->p.firstBlock; + + /* process each entry in the log */ + while (block != 0) + { /* process each block until we are past the last block */ + READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); + SET_DEBUG_ID(iomsg, 0); + buffer = ZFS_ReadPoolBlk(genMsg, &iomsg); + if (buffer == NULL) + { + printf(MSGNot("Error reading block %d\n"),block); + goto errorExit; + } + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + + for (slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) + { /* process each entry in the block */ + if ((block == purgeLog->nextUnused.block) && + (slot >= purgeLog->nextUnused.slot)) + { /* if past the last purge log entry - end*/ + CACHE_RELEASE(buffer); + goto done; /* done */ + } + + switch (pLogBlock->logEntry[slot].type) + { + case PLOG_UNUSED: + { + availCount++; + freeEntry = &pLogBlock->logEntry[slot].info.free; + DBG_DebugPrintf(LRED, + MSGNot("FREE Block=%d Slot=%d nextBlock=%d nextSlot=%d\n"), + block, slot, freeEntry->link.block, + freeEntry->link.slot); + break; + } + case PLOG_BEAST_DELETE: + { + beastDeleteCount++; + beastEntry = &pLogBlock->logEntry[slot].info.beast; + DBG_DebugPrintf(LBLUE, + MSGNot("BEAST Block=%d Slot=%d volumeID=%d zid=%d\n"), + block, slot, (LONG)beastEntry->volumeID.timeLow, (LONG)beastEntry->zid); + break; + } + case PLOG_TRUNCATE: + { + truncCount++; + truncEntry = &pLogBlock->logEntry[slot].info.trunc; + DBG_DebugPrintf(BLUE, + MSGNot("TRUNCATE Block=%d Slot=%d volumeID=%d zid=%d startBlock=%d len=%d\n"), + block, slot, (LONG)truncEntry->volumeID.timeLow, (LONG)truncEntry->zid, + truncEntry->startBlock, truncEntry->len); + break; + } + case PLOG_BLOCK_FREE: + { + blockFreeCount++; + blockEntry = &pLogBlock->logEntry[slot].info.block; + DBG_DebugPrintf(MAGENTA, + MSGNot("BLOCK Block=%d Slot=%d Freed block=%d\n"), + block, slot, blockEntry->blockNumber); + break; + } + case PLOG_BEAST_COMP_CLEANUP: + { + beastCompCount++; + beastEntry = &pLogBlock->logEntry[slot].info.beast; + DBG_DebugPrintf(LBLUE, + MSGNot("BEAST COMP CLEANUP Block=%d Slot=%d volumeID=%d zid=%d\n"), + block, slot, (LONG)beastEntry->volumeID.timeLow, (LONG)beastEntry->zid); + break; + } + case PLOG_FIX_VISIBILITY: + { + fixVisibCount++; + visibEntry = &pLogBlock->logEntry[slot].info.visib; + DBG_DebugPrintf(GREEN, + MSGNot("BEAST FIX VISIBILITY Block=%d Slot=%d parent zid=%d trusteeID=%d Action=%d\n"), block, slot, (LONG)visibEntry->parentZID, (LONG)visibEntry->trusteeID.timeLow, visibEntry->action); + break; + } + case PLOG_SCAN_USER_NAMES: + { + userScanCount++; + userScanEntry = &pLogBlock->logEntry[slot].info.userScan; + DBG_DebugPrintf(MAGENTA, + MSGNot("USER Block=%d Slot=%d volumeID=%Lx\n"), + block, slot, userScanEntry->volumeID); + break; + } + case PLOG_REMOVE_USER_TREE: + { + userFreeCount++; + userEntry = &pLogBlock->logEntry[slot].info.user; + DBG_DebugPrintf(MAGENTA, + MSGNot("USER Block=%d Slot=%d volumeID=%Lx\n"), + block, slot, userEntry->volumeID); + break; + } + case PLOG_CLEAR_USED_AMOUNT: + { + userClearCount++; + userClearEntry = &pLogBlock->logEntry[slot].info.userClear; + DBG_DebugPrintf(MAGENTA, + MSGNot("USER Clear Block=%d Slot=%d volumeID=%Lx\n"), + block, slot, userClearEntry->volumeID); + break; + } + case PLOG_REMOVE_DIR_TREE: + { + dirFreeCount++; + dirEntry = &pLogBlock->logEntry[slot].info.directory; + DBG_DebugPrintf(MAGENTA, + MSGNot("DIR Block=%d Slot=%d volumeID=%Lx\n"), + block, slot, dirEntry->volumeID); + break; + } + case PLOG_DIR_QUOTA_USED: + { + dirUsedCount++; + dirUsed = &pLogBlock->logEntry[slot].info.dirUsed; + DBG_DebugPrintf(MAGENTA, + MSGNot("DIR Used Block=%d Slot=%d volumeID=%Lx dirZid=%d\n"), + block, slot, dirUsed->volumeID, dirUsed->dirZid); + break; + } + case PLOG_EFL_REMOVE_EPOCH: + { + epochRemoveCount++; + epochRemove = &pLogBlock->logEntry[slot].info.epochRemove; + DBG_DebugPrintf(MAGENTA, + MSGNot("DIR Used Block=%d Slot=%d epoch=%d volumeID=%Lx\n"), + block, slot, epochRemove->epoch.clockSeqHighAndReserved & 0x1F, + epochRemove->volumeID); + break; + } + case PLOG_EFL_RESET_TREE: + { + resetEFLCount++; + resetEFL = &pLogBlock->logEntry[slot].info.resetEFL; + DBG_DebugPrintf(MAGENTA, + MSGNot("USER Block=%d Slot=%d volumeID=%Lx\n"), + block, slot, resetEFL->volumeID); + break; + } + default: + { + DBG_DebugPrintf(RED, MSGNot("Unknown record type Block=%d Slot=%d\n"), + block, slot); + } + } + } + /* catch the case where nextUnused.slot is one greater than MAX_PURGE_LOG_ENTRIES */ + if (block == purgeLog->nextUnused.block) { - DBG_DebugPrintf(RED,MSGNot("Free list has an entry not marked free\n")); + CACHE_RELEASE(buffer); + goto done; /* done */ } - CACHE_RELEASE(buffer); - } - DBG_DebugPrintf(LBLUE, MSGNot("Number of avail entries in log = %d\n"), availCount); - - /* - * Scan all entries in the log and report usage - */ - DBG_DebugPrintf(LBLUE, MSGNot("******* Purge Log Entries *******\n")); - availCount = 0; - block = purgeLog->p.firstBlock; - - /* process each entry in the log */ - while (block != 0) - { /* process each block until we are past the last block */ - READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); - SET_DEBUG_ID(iomsg, 0); - buffer = ZFS_ReadPoolBlk(genMsg, &iomsg); - if (buffer == NULL) - { - printf(MSGNot("Error reading block %d\n"),block); - goto errorExit; - } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - - for (slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) - { /* process each entry in the block */ - if ((block == purgeLog->nextUnused.block) && - (slot >= purgeLog->nextUnused.slot)) - { /* if past the last purge log entry - end*/ - CACHE_RELEASE(buffer); - goto done; /* done */ - } - - switch (pLogBlock->logEntry[slot].type) - { - case PLOG_UNUSED: - { - availCount++; - freeEntry = &pLogBlock->logEntry[slot].info.free; - DBG_DebugPrintf(LRED, - MSGNot("FREE Block=%d Slot=%d nextBlock=%d nextSlot=%d\n"), - block, slot, freeEntry->link.block, - freeEntry->link.slot); - break; - } - case PLOG_BEAST_DELETE: - { - beastDeleteCount++; - beastEntry = &pLogBlock->logEntry[slot].info.beast; - DBG_DebugPrintf(LBLUE, - MSGNot("BEAST Block=%d Slot=%d volumeID=%d zid=%d\n"), - block, slot, (LONG)beastEntry->volumeID.timeLow, (LONG)beastEntry->zid); - break; - } - case PLOG_TRUNCATE: - { - truncCount++; - truncEntry = &pLogBlock->logEntry[slot].info.trunc; - DBG_DebugPrintf(BLUE, - MSGNot("TRUNCATE Block=%d Slot=%d volumeID=%d zid=%d startBlock=%d len=%d\n"), - block, slot, (LONG)truncEntry->volumeID.timeLow, (LONG)truncEntry->zid, - truncEntry->startBlock, truncEntry->len); - break; - } - case PLOG_BLOCK_FREE: - { - blockFreeCount++; - blockEntry = &pLogBlock->logEntry[slot].info.block; - DBG_DebugPrintf(MAGENTA, - MSGNot("BLOCK Block=%d Slot=%d Freed block=%d\n"), - block, slot, blockEntry->blockNumber); - break; - } - case PLOG_BEAST_COMP_CLEANUP: - { - beastCompCount++; - beastEntry = &pLogBlock->logEntry[slot].info.beast; - DBG_DebugPrintf(LBLUE, - MSGNot("BEAST COMP CLEANUP Block=%d Slot=%d volumeID=%d zid=%d\n"), - block, slot, (LONG)beastEntry->volumeID.timeLow, (LONG)beastEntry->zid); - break; - } - case PLOG_FIX_VISIBILITY: - { - fixVisibCount++; - visibEntry = &pLogBlock->logEntry[slot].info.visib; - DBG_DebugPrintf(GREEN, - MSGNot("BEAST FIX VISIBILITY Block=%d Slot=%d parent zid=%d trusteeID=%d Action=%d\n"), block, slot, (LONG)visibEntry->parentZID, (LONG)visibEntry->trusteeID.timeLow, visibEntry->action); - break; - } - case PLOG_SCAN_USER_NAMES: - { - userScanCount++; - userScanEntry = &pLogBlock->logEntry[slot].info.userScan; - DBG_DebugPrintf(MAGENTA, - MSGNot("USER Block=%d Slot=%d volumeID=%Lx\n"), - block, slot, userScanEntry->volumeID); - break; - } - case PLOG_REMOVE_USER_TREE: - { - userFreeCount++; - userEntry = &pLogBlock->logEntry[slot].info.user; - DBG_DebugPrintf(MAGENTA, - MSGNot("USER Block=%d Slot=%d volumeID=%Lx\n"), - block, slot, userEntry->volumeID); - break; - } - case PLOG_CLEAR_USED_AMOUNT: - { - userClearCount++; - userClearEntry = &pLogBlock->logEntry[slot].info.userClear; - DBG_DebugPrintf(MAGENTA, - MSGNot("USER Clear Block=%d Slot=%d volumeID=%Lx\n"), - block, slot, userClearEntry->volumeID); - break; - } - case PLOG_REMOVE_DIR_TREE: - { - dirFreeCount++; - dirEntry = &pLogBlock->logEntry[slot].info.directory; - DBG_DebugPrintf(MAGENTA, - MSGNot("DIR Block=%d Slot=%d volumeID=%Lx\n"), - block, slot, dirEntry->volumeID); - break; - } - case PLOG_DIR_QUOTA_USED: - { - dirUsedCount++; - dirUsed = &pLogBlock->logEntry[slot].info.dirUsed; - DBG_DebugPrintf(MAGENTA, - MSGNot("DIR Used Block=%d Slot=%d volumeID=%Lx dirZid=%d\n"), - block, slot, dirUsed->volumeID, dirUsed->dirZid); - break; - } - case PLOG_EFL_REMOVE_EPOCH: - { - epochRemoveCount++; - epochRemove = &pLogBlock->logEntry[slot].info.epochRemove; - DBG_DebugPrintf(MAGENTA, - MSGNot("DIR Used Block=%d Slot=%d epoch=%d volumeID=%Lx\n"), - block, slot, epochRemove->epoch.clockSeqHighAndReserved & 0x1F, - epochRemove->volumeID); - break; - } - case PLOG_EFL_RESET_TREE: - { - resetEFLCount++; - resetEFL = &pLogBlock->logEntry[slot].info.resetEFL; - DBG_DebugPrintf(MAGENTA, - MSGNot("USER Block=%d Slot=%d volumeID=%Lx\n"), - block, slot, resetEFL->volumeID); - break; - } - default: - { - DBG_DebugPrintf(RED, MSGNot("Unknown record type Block=%d Slot=%d\n"), - block, slot); - } - } - } - /* catch the case where nextUnused.slot is one greater than MAX_PURGE_LOG_ENTRIES */ - if (block == purgeLog->nextUnused.block) - { - CACHE_RELEASE(buffer); - goto done; /* done */ - } - block = pLogBlock->nextBlock; - CACHE_RELEASE(buffer); - } + block = pLogBlock->nextBlock; + CACHE_RELEASE(buffer); + } done: - DBG_DebugPrintf(LBLUE, MSGNot("Total free=%d Bstdels=%d Trun=%d BlkFree=%d Comp=%d TotVis=%d UsrScan=%d UsrFree=%d UsrClr=%d removeEpoch=%d resetEFL=%d Total=%d\n"), - availCount, beastDeleteCount, truncCount, blockFreeCount, - beastCompCount, fixVisibCount, userScanCount, userFreeCount, userClearCount, - epochRemoveCount, resetEFLCount, - availCount+beastDeleteCount+truncCount+blockFreeCount+beastCompCount+ - fixVisibCount+userScanCount+userFreeCount+userClearCount+epochRemoveCount+resetEFLCount); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ - return; + DBG_DebugPrintf(LBLUE, MSGNot("Total free=%d Bstdels=%d Trun=%d BlkFree=%d Comp=%d TotVis=%d UsrScan=%d UsrFree=%d UsrClr=%d removeEpoch=%d resetEFL=%d Total=%d\n"), + availCount, beastDeleteCount, truncCount, blockFreeCount, + beastCompCount, fixVisibCount, userScanCount, userFreeCount, userClearCount, + epochRemoveCount, resetEFLCount, + availCount+beastDeleteCount+truncCount+blockFreeCount+beastCompCount+ + fixVisibCount+userScanCount+userFreeCount+userClearCount+epochRemoveCount+resetEFLCount); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ + return; errorExit: - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ - return; + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ + return; } @@ -378,40 +378,40 @@ errorExit: * ****************************************************************************/ void DisplayPurgeLogInfo ( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm) + struct PCLSwitchDef_s *switchDef, + NINT index, + void *userParm) { - GeneralMsg_s genMsg; - ZfsVolume_s *volume; - ZfsPurgeLogBeast_s *purgeLog; + GeneralMsg_s genMsg; + ZfsVolume_s *volume; + ZfsPurgeLogBeast_s *purgeLog; - MPKNSS_LOCK(); - DBG_DebugPrintf(LBLUE, MSGNot("***** Purge Log Display Volume %U *****\n"), - (unicode_t *)switchDef->ret_value ); - COMN_SETUP_GENERAL_MSG_NOSA( &genMsg ); - COMN_INCLUDE_INTERNAL_VOLUMES( &genMsg ); - volume = (ZfsVolume_s *)COMN_VolumeNameLookup(&genMsg, - (unicode_t *)switchDef->ret_value,TRUE,NULL); - if (volume == NULL) - { - printf(MSGNot("Volume not found.\n")); - MPKNSS_UNLOCK(); - return; - } + MPKNSS_LOCK(); + DBG_DebugPrintf(LBLUE, MSGNot("***** Purge Log Display Volume %U *****\n"), + (unicode_t *)switchDef->ret_value ); + COMN_SETUP_GENERAL_MSG_NOSA( &genMsg ); + COMN_INCLUDE_INTERNAL_VOLUMES( &genMsg ); + volume = (ZfsVolume_s *)COMN_VolumeNameLookup(&genMsg, + (unicode_t *)switchDef->ret_value,TRUE,NULL); + if (volume == NULL) + { + printf(MSGNot("Volume not found.\n")); + MPKNSS_UNLOCK(); + return; + } - purgeLog = volume->ZFSVOLvolumePurgeLog; - DisplayPurgeLogInfo2( &genMsg, volume, purgeLog ); + purgeLog = volume->ZFSVOLvolumePurgeLog; + DisplayPurgeLogInfo2( &genMsg, volume, purgeLog ); - purgeLog = volume->pool->purgeLogBeast; - DBG_DebugPrintf(LBLUE, MSGNot("***** Volume's Pool Purge Log Display *****\n") ); + purgeLog = volume->pool->purgeLogBeast; + DBG_DebugPrintf(LBLUE, MSGNot("***** Volume's Pool Purge Log Display *****\n") ); - DisplayPurgeLogInfo2( &genMsg, volume, purgeLog ); + DisplayPurgeLogInfo2( &genMsg, volume, purgeLog ); - COMN_Release( &volume ); - MPKNSS_UNLOCK(); - return; + COMN_Release( &volume ); + MPKNSS_UNLOCK(); + return; } @@ -420,207 +420,207 @@ void DisplayPurgeLogInfo ( * ****************************************************************************/ void plogValidate ( - ZfsPurgeLogBeast_s *purgeLog, - BOOL shouldBeEmpty ) /* TRUE when PLOG should be empty */ + ZfsPurgeLogBeast_s *purgeLog, + BOOL shouldBeEmpty ) /* TRUE when PLOG should be empty */ { - GeneralMsg_s genMsg; - IoMsg_s iomsg; - Buffer_s *buffer; - Blknum_t block; - Blknum_t newBlock; - Blknum_t prvBlock; /* Debug only */ - NINT slot; - NINT prvSlot; /* Debug only */ - NINT blockCount = 0; - NINT availCount = 0; - NINT freeCount = 0; - NINT usedCount = 0; - BOOL end = FALSE; - BOOL freeCountError = FALSE; - PurgeLogBlock_s *pLogBlock; + GeneralMsg_s genMsg; + IoMsg_s iomsg; + Buffer_s *buffer; + Blknum_t block; + Blknum_t newBlock; + Blknum_t prvBlock; /* Debug only */ + NINT slot; + NINT prvSlot; /* Debug only */ + NINT blockCount = 0; + NINT availCount = 0; + NINT freeCount = 0; + NINT usedCount = 0; + BOOL end = FALSE; + BOOL freeCountError = FALSE; + PurgeLogBlock_s *pLogBlock; - COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); - /* count the number of blocks in the purge log */ - block = purgeLog->p.firstBlock; - while(block != 0) - { - READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); - SET_DEBUG_ID(iomsg, 0); - buffer = ZFS_ReadPoolBlk(&genMsg, &iomsg); - if (buffer == NULL) + /* count the number of blocks in the purge log */ + block = purgeLog->p.firstBlock; + while(block != 0) + { + READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); + SET_DEBUG_ID(iomsg, 0); + buffer = ZFS_ReadPoolBlk(&genMsg, &iomsg); + if (buffer == NULL) + { + goto errorExit; + } + + blockCount++; + newBlock = ((PurgeLogBlock_s *)buffer->pBuf.data)->nextBlock; + CACHE_RELEASE(buffer); + if (block == purgeLog->nextUnused.block) { - goto errorExit; + break; } + else + { + block = newBlock; + } + } - blockCount++; - newBlock = ((PurgeLogBlock_s *)buffer->pBuf.data)->nextBlock; - CACHE_RELEASE(buffer); - if (block == purgeLog->nextUnused.block) - { - break; - } - else - { - block = newBlock; - } - } - - /* follow avail list */ - block = ((ZfsPurgeLogLoc_s *)&purgeLog->freeList)->block; - slot = ((ZfsPurgeLogLoc_s *)&purgeLog->freeList)->slot; - zASSERT(slot < MAX_PURGE_LOG_ENTRIES); + /* follow avail list */ + block = ((ZfsPurgeLogLoc_s *)&purgeLog->freeList)->block; + slot = ((ZfsPurgeLogLoc_s *)&purgeLog->freeList)->slot; + zASSERT(slot < MAX_PURGE_LOG_ENTRIES); // zASSERT(slot <= MAX_PURGE_LOG_ENTRIES); - while(block != 0) - { - READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); - SET_DEBUG_ID(iomsg, 0); - buffer = ZFS_ReadPoolBlk(&genMsg, &iomsg); - if (buffer == NULL) - { - goto errorExit; - } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); - if ( pLogBlock->magic != PURGE_LOG_MAGIC ) - { - freeCountError = TRUE; - CACHE_RELEASE(buffer); - break; - } - zASSERT(pLogBlock->logEntry[slot].type == PLOG_UNUSED); - if ( pLogBlock->logEntry[slot].type != PLOG_UNUSED ) - { /* If not a free block then we MUST not follow - * block list. - */ - freeCountError = TRUE; - CACHE_RELEASE(buffer); - break; - } - freeCount++; - prvBlock = block; - prvSlot = slot; - block = ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->block; - slot = ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->slot; - CACHE_RELEASE(buffer); - } + while(block != 0) + { + READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); + SET_DEBUG_ID(iomsg, 0); + buffer = ZFS_ReadPoolBlk(&genMsg, &iomsg); + if (buffer == NULL) + { + goto errorExit; + } + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); + if ( pLogBlock->magic != PURGE_LOG_MAGIC ) + { + freeCountError = TRUE; + CACHE_RELEASE(buffer); + break; + } + zASSERT(pLogBlock->logEntry[slot].type == PLOG_UNUSED); + if ( pLogBlock->logEntry[slot].type != PLOG_UNUSED ) + { /* If not a free block then we MUST not follow + * block list. + */ + freeCountError = TRUE; + CACHE_RELEASE(buffer); + break; + } + freeCount++; + prvBlock = block; + prvSlot = slot; + block = ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->block; + slot = ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->slot; + CACHE_RELEASE(buffer); + } - /* - * Scan all entries in the log and report usage - */ - availCount = 0; - usedCount = 0; - block = purgeLog->p.firstBlock; + /* + * Scan all entries in the log and report usage + */ + availCount = 0; + usedCount = 0; + block = purgeLog->p.firstBlock; - /* process each entry in the log */ - while (block != 0) - { /* process each block until we are past the last block */ - READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); - SET_DEBUG_ID(iomsg, 0); - buffer = ZFS_ReadPoolBlk(&genMsg, &iomsg); - if (buffer == NULL) - { - goto errorExit; - } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + /* process each entry in the log */ + while (block != 0) + { /* process each block until we are past the last block */ + READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); + SET_DEBUG_ID(iomsg, 0); + buffer = ZFS_ReadPoolBlk(&genMsg, &iomsg); + if (buffer == NULL) + { + goto errorExit; + } + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - for (slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) - { /* process each entry in the block */ - if ((block == purgeLog->nextUnused.block) && - (slot >= purgeLog->nextUnused.slot)) - { /* if past the last purge log entry - end*/ - end = TRUE; - } - if (end) + for (slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) + { /* process each entry in the block */ + if ((block == purgeLog->nextUnused.block) && + (slot >= purgeLog->nextUnused.slot)) + { /* if past the last purge log entry - end*/ + end = TRUE; + } + if (end) { - zASSERT(pLogBlock->logEntry[slot].type == PLOG_UNUSED); - break; + zASSERT(pLogBlock->logEntry[slot].type == PLOG_UNUSED); + break; } - if (pLogBlock->logEntry[slot].type != PLOG_UNUSED) - { /* if it is not an open entry */ - usedCount++; - if ( shouldBeEmpty ) - { - zASSERT("Found an non-empty PL entry"==NULL); - } - } - else - { - availCount++; - } - } - /* catch the case where nextUnused.slot is one greater than MAX_PURGE_LOG_ENTRIES */ - if (block == purgeLog->nextUnused.block) + if (pLogBlock->logEntry[slot].type != PLOG_UNUSED) + { /* if it is not an open entry */ + usedCount++; + if ( shouldBeEmpty ) + { + zASSERT("Found an non-empty PL entry"==NULL); + } + } + else + { + availCount++; + } + } + /* catch the case where nextUnused.slot is one greater than MAX_PURGE_LOG_ENTRIES */ + if (block == purgeLog->nextUnused.block) { - end = TRUE; + end = TRUE; } - block = pLogBlock->nextBlock; - CACHE_RELEASE(buffer); - } - if (blockCount != 0) + block = pLogBlock->nextBlock; + CACHE_RELEASE(buffer); + } + if (blockCount != 0) { - zASSERT((availCount + usedCount) == ((blockCount - 1) * - MAX_PURGE_LOG_ENTRIES + purgeLog->nextUnused.slot)); - if ( !freeCountError ) - { - zASSERT(freeCount <= availCount); - } + zASSERT((availCount + usedCount) == ((blockCount - 1) * + MAX_PURGE_LOG_ENTRIES + purgeLog->nextUnused.slot)); + if ( !freeCountError ) + { + zASSERT(freeCount <= availCount); + } } - return; + return; errorExit: - zASSERT(0); - return; + zASSERT(0); + return; } - /* - * Validate that a particular block is in the purge log. - */ + /* + * Validate that a particular block is in the purge log. + */ #define PLOG_VALIDATE_BLOCK(_pLog, _blk) plogValidateBlock((_pLog), (_blk)) void plogValidateBlock ( - ZfsPurgeLogBeast_s *purgeLog, - Blknum_t blockToFind) + ZfsPurgeLogBeast_s *purgeLog, + Blknum_t blockToFind) { - GeneralMsg_s genMsg; - IoMsg_s iomsg; - Buffer_s *buffer; - Blknum_t block; - Blknum_t newBlock; - NINT blockCount = 0; + GeneralMsg_s genMsg; + IoMsg_s iomsg; + Buffer_s *buffer; + Blknum_t block; + Blknum_t newBlock; + NINT blockCount = 0; - COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); - block = purgeLog->p.firstBlock; - while (block != 0) - { - if (block == blockToFind) - { - return; - } - READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); - SET_DEBUG_ID(iomsg, 0); - buffer = ZFS_ReadPoolBlk(&genMsg, &iomsg); - if (buffer == NULL) - { - zASSERT(0); - break; - } + block = purgeLog->p.firstBlock; + while (block != 0) + { + if (block == blockToFind) + { + return; + } + READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_READ); + SET_DEBUG_ID(iomsg, 0); + buffer = ZFS_ReadPoolBlk(&genMsg, &iomsg); + if (buffer == NULL) + { + zASSERT(0); + break; + } - blockCount++; - newBlock = ((PurgeLogBlock_s *)buffer->pBuf.data)->nextBlock; - CACHE_RELEASE(buffer); - if (block == purgeLog->nextUnused.block) + blockCount++; + newBlock = ((PurgeLogBlock_s *)buffer->pBuf.data)->nextBlock; + CACHE_RELEASE(buffer); + if (block == purgeLog->nextUnused.block) { - break; + break; } - else - { - block = newBlock; - } - } - zASSERT(!blockToFind); + else + { + block = newBlock; + } + } + zASSERT(!blockToFind); } #else @@ -638,25 +638,25 @@ void plogValidateBlock ( * ****************************************************************************/ Buffer_s *PLOG_ReadPoolBlk ( - GeneralMsg_s *genMsg, - IoMsg_s *iomsg) + GeneralMsg_s *genMsg, + IoMsg_s *iomsg) { - Buffer_s *buffer; - NINT magic; + Buffer_s *buffer; + NINT magic; - buffer = ZFS_ReadPoolBlk(genMsg, iomsg); - if ((buffer != NULL) && (iomsg->mode != CACHE_WRITE)) - { - magic = ((PurgeLogBlock_s *)buffer->pBuf.data)->magic; - if (magic != PURGE_LOG_MAGIC) - { - SetErrno(genMsg, zERR_MEDIA_CORRUPTED); - ZLSSPOOL_MediaIsCorrupt(genMsg, buffer, iomsg ); - CACHE_RELEASE(buffer); - return NULL; - } - } - return buffer; + buffer = ZFS_ReadPoolBlk(genMsg, iomsg); + if ((buffer != NULL) && (iomsg->mode != CACHE_WRITE)) + { + magic = ((PurgeLogBlock_s *)buffer->pBuf.data)->magic; + if (magic != PURGE_LOG_MAGIC) + { + SetErrno(genMsg, zERR_MEDIA_CORRUPTED); + ZLSSPOOL_MediaIsCorrupt(genMsg, buffer, iomsg ); + CACHE_RELEASE(buffer); + return NULL; + } + } + return buffer; } @@ -665,122 +665,122 @@ Buffer_s *PLOG_ReadPoolBlk ( * done early so that additions can be made to the log before it is played. ****************************************************************************/ STATUS ZFSPURGELOG_Setup ( - GeneralMsg_s *genMsg, - ZfsPurgeLogBeast_s *purgeLog) + GeneralMsg_s *genMsg, + ZfsPurgeLogBeast_s *purgeLog) { - IoMsg_s iomsg; - Buffer_s *buffer; - PurgeLogBlock_s *pLogBlock; - NINT slot; - Blknum_t block = 0; + IoMsg_s iomsg; + Buffer_s *buffer; + PurgeLogBlock_s *pLogBlock; + NINT slot; + Blknum_t block = 0; - if (purgeLog->p.firstBlock == 0) + if (purgeLog->p.firstBlock == 0) { /* if the log has never been created */ - zASSERT("Purge log not found" == 0); - return zOK; + zASSERT("Purge log not found" == 0); + return zOK; } - /* setup the purgeLog beast */ - purgeLog->freeList.block = 0; - purgeLog->freeList.slot = 0; + /* setup the purgeLog beast */ + purgeLog->freeList.block = 0; + purgeLog->freeList.slot = 0; - /* initialize the avail list */ - purgeLog->nextUnused.block = purgeLog->p.firstBlock; - zASSERT( purgeLog->nextUnused.block != 0 ); - while (purgeLog->nextUnused.block != 0) - { /* process each entry until we are past the last block */ - READBLK_IO_MSG(iomsg, purgeLog, purgeLog->nextUnused.block, - CACHE_UPDATE); - SET_DEBUG_ID(iomsg, 9); - buffer = PLOG_ReadPoolBlk(genMsg, &iomsg); - if (buffer == NULL) - { - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ - return zFAILURE; - } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); - if ( pLogBlock->magic != PURGE_LOG_MAGIC ) - { - CACHE_RELEASE(buffer); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ - SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); - return zFAILURE; - } - for (slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) - { /* process each entry in the block */ - if (pLogBlock->logEntry[slot].type == PLOG_UNUSED) - { - pLogBlock->logEntry[slot].info.free.link.block - = purgeLog->freeList.block; - pLogBlock->logEntry[slot].info.free.link.slot - = purgeLog->freeList.slot; - purgeLog->freeList.block = purgeLog->nextUnused.block; - purgeLog->freeList.slot = slot; - } - } - block = purgeLog->nextUnused.block; /* save the old block number */ - purgeLog->nextUnused.block = pLogBlock->nextBlock; - CACHE_DIRTY_RELEASE(buffer); - } + /* initialize the avail list */ + purgeLog->nextUnused.block = purgeLog->p.firstBlock; + zASSERT( purgeLog->nextUnused.block != 0 ); + while (purgeLog->nextUnused.block != 0) + { /* process each entry until we are past the last block */ + READBLK_IO_MSG(iomsg, purgeLog, purgeLog->nextUnused.block, + CACHE_UPDATE); + SET_DEBUG_ID(iomsg, 9); + buffer = PLOG_ReadPoolBlk(genMsg, &iomsg); + if (buffer == NULL) + { + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ + return zFAILURE; + } + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); + if ( pLogBlock->magic != PURGE_LOG_MAGIC ) + { + CACHE_RELEASE(buffer); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ + SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); + return zFAILURE; + } + for (slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) + { /* process each entry in the block */ + if (pLogBlock->logEntry[slot].type == PLOG_UNUSED) + { + pLogBlock->logEntry[slot].info.free.link.block + = purgeLog->freeList.block; + pLogBlock->logEntry[slot].info.free.link.slot + = purgeLog->freeList.slot; + purgeLog->freeList.block = purgeLog->nextUnused.block; + purgeLog->freeList.slot = slot; + } + } + block = purgeLog->nextUnused.block; /* save the old block number */ + purgeLog->nextUnused.block = pLogBlock->nextBlock; + CACHE_DIRTY_RELEASE(buffer); + } - zASSERT(block != 0); - purgeLog->nextUnused.block = block; - purgeLog->nextUnused.slot = MAX_PURGE_LOG_ENTRIES; - return zOK; + zASSERT(block != 0); + purgeLog->nextUnused.block = block; + purgeLog->nextUnused.slot = MAX_PURGE_LOG_ENTRIES; + return zOK; } /**************************************************************************** * Play the purge log. Called during system recovery. It assumes the - * system structures have been restored. + * system structures have been restored. ****************************************************************************/ STATUS ZFSVOL_PlayPurgeLog ( - GeneralMsg_s *genMsg, - ZfsVolume_s *zfsVol, - ZfsPurgeLogBeast_s *purgeLog, - NINT mode ) + GeneralMsg_s *genMsg, + ZfsVolume_s *zfsVol, + ZfsPurgeLogBeast_s *purgeLog, + NINT mode ) { - STATUS status; - ZfsPool_s *zfsPool; - ZlssPool_s *zlssPool; + STATUS status; + ZfsPool_s *zfsPool; + ZlssPool_s *zlssPool; - DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN,MSGNot("CVS@ZFSVOL_PlayPurgeLog\n"))); - zlssPool = (ZlssPool_s *)(zfsVol->ZFSVOLvol.v_pool); - zASSERT( zlssPool != NULL ); - zASSERT( zlssPool->ZLSSPOOLzfsPool != NULL ); - zfsPool = zlssPool->ZLSSPOOLzfsPool; - /** - * Now for more gross LV AIPU code. In the first few steps - * of upgrading to LVs the volume purge log does not exist. - * Therefore it is wise to check for this condition and skip - * playing the log. Note that STEP 2A of LV ZIPU creates - * the volume purge log for the pool. - */ - if ( purgeLog == NULL ) - { - LONG version; + DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN,MSGNot("CVS@ZFSVOL_PlayPurgeLog\n"))); + zlssPool = (ZlssPool_s *)(zfsVol->ZFSVOLvol.v_pool); + zASSERT( zlssPool != NULL ); + zASSERT( zlssPool->ZLSSPOOLzfsPool != NULL ); + zfsPool = zlssPool->ZLSSPOOLzfsPool; + /** + * Now for more gross LV AIPU code. In the first few steps + * of upgrading to LVs the volume purge log does not exist. + * Therefore it is wise to check for this condition and skip + * playing the log. Note that STEP 2A of LV ZIPU creates + * the volume purge log for the pool. + */ + if ( purgeLog == NULL ) + { + LONG version; - version = zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor * 0x100L + - zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor; + version = zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor * 0x100L + + zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor; - if ( version < (AIPU_LV_MEDIA_MAJOR*0x100L+AIPU_LV_STEP_PVPL_DONE) ) - { /* Media still may not have Volume Purge Log */ - return( zOK ); - } - else - { + if ( version < (AIPU_LV_MEDIA_MAJOR*0x100L+AIPU_LV_STEP_PVPL_DONE) ) + { /* Media still may not have Volume Purge Log */ + return( zOK ); + } + else + { // return( zOK ); - SetErrno(genMsg, zERR_MEDIA_CORRUPTED ); - return( zFAILURE ); - } - } - /** - * Back to normal code. Just call the standard play back code - * suppling the Volume Purge Log as the log to play. We also must - * supply the Volume that the purge log is on. - */ - status = ZFSPOOL_PlayPurgeLog( genMsg, zfsPool, zfsVol, purgeLog, mode ); - return( status ); + SetErrno(genMsg, zERR_MEDIA_CORRUPTED ); + return( zFAILURE ); + } + } + /** + * Back to normal code. Just call the standard play back code + * suppling the Volume Purge Log as the log to play. We also must + * supply the Volume that the purge log is on. + */ + status = ZFSPOOL_PlayPurgeLog( genMsg, zfsPool, zfsVol, purgeLog, mode ); + return( status ); } /**************************************************************************** @@ -788,208 +788,208 @@ STATUS ZFSVOL_PlayPurgeLog ( * system structures have been restored. ****************************************************************************/ STATUS ZFSPOOL_PlayPurgeLog ( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - ZfsVolume_s *zfsVol, /* LV */ - ZfsPurgeLogBeast_s *purgeLog, /* Can be Pool purge log OR Volume - * purge log. The ZID is used to - * indicate which purge we are playing. - */ - NINT mode ) + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + ZfsVolume_s *zfsVol, /* LV */ + ZfsPurgeLogBeast_s *purgeLog, /* Can be Pool purge log OR Volume + * purge log. The ZID is used to + * indicate which purge we are playing. + */ + NINT mode ) { - Volume_s *volume = &zfsVol->ZFSVOLvol; - Buffer_s *buffer; - PurgeLogBlock_s *pLogBlock; - PurgeBeastEntry_s *beastEntry; - TruncateEntry_s *truncEntry; - FixVisEntry_s *visibEntry; - NINT slot; - Blknum_t block; - Blknum_t nextBlock; - RootBeast_s *beast = NULL; - ZfsXaction_s *xaction; - ZfsXasRecovery_s *logBuffer; - BlockInfo_s *poolBlks; - LogPurgeLog_s *logRecord; - Extent_s extent; - BOOL beastIsLatched; - NINT savedRestartCount; - typedef struct PLStats_s { - NINT PLS_numBeastDeletes; - NINT PLS_numBeastCompCleanups; - NINT PLS_numBlockDeletes; - NINT PLS_numTruncates; - NINT PLS_numFixVisib; - NINT PLS_numScanUser; - NINT PLS_numRemoveUser; - NINT PLS_numClearUser; - NINT PLS_numRemoveDirTree; - NINT PLS_numDirQuotaUsed; - NINT PLS_numEpochRemove; - NINT PLS_numResetEFL; - } PLStats_s; - SQUAD usedAmount; - SQUAD amountUsed; - SQUAD quota; - ZfsPurgeLogLoc_s location; - STATUS status; - BOOL allowedInactive; /* State of genMsg ALLOW_INACTIVE_VOLUME - * bit used to be able to reset bit - * back to orginal state. - */ + Volume_s *volume = &zfsVol->ZFSVOLvol; + Buffer_s *buffer; + PurgeLogBlock_s *pLogBlock; + PurgeBeastEntry_s *beastEntry; + TruncateEntry_s *truncEntry; + FixVisEntry_s *visibEntry; + NINT slot; + Blknum_t block; + Blknum_t nextBlock; + RootBeast_s *beast = NULL; + ZfsXaction_s *xaction; + ZfsXasRecovery_s *logBuffer; + BlockInfo_s *poolBlks; + LogPurgeLog_s *logRecord; + Extent_s extent; + BOOL beastIsLatched; + NINT savedRestartCount; + typedef struct PLStats_s { + NINT PLS_numBeastDeletes; + NINT PLS_numBeastCompCleanups; + NINT PLS_numBlockDeletes; + NINT PLS_numTruncates; + NINT PLS_numFixVisib; + NINT PLS_numScanUser; + NINT PLS_numRemoveUser; + NINT PLS_numClearUser; + NINT PLS_numRemoveDirTree; + NINT PLS_numDirQuotaUsed; + NINT PLS_numEpochRemove; + NINT PLS_numResetEFL; + } PLStats_s; + SQUAD usedAmount; + SQUAD amountUsed; + SQUAD quota; + ZfsPurgeLogLoc_s location; + STATUS status; + BOOL allowedInactive; /* State of genMsg ALLOW_INACTIVE_VOLUME + * bit used to be able to reset bit + * back to orginal state. + */ #if LOG_TEST IS_ENABLED - Lsn_t holdLsn; + Lsn_t holdLsn; #endif - typedef struct Stack_s { - IoMsg_s iomsg; - PLStats_s stats; - } Stack_s; - STACK_ALLOC(); - bzero( &aStack->stats, sizeof(aStack->stats) ); + typedef struct Stack_s { + IoMsg_s iomsg; + PLStats_s stats; + } Stack_s; + STACK_ALLOC(); + bzero( &aStack->stats, sizeof(aStack->stats) ); - ENTER(TPLOG, ZFSPOOL_PlayPurgeLog); - DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN,MSGNot("CVS@ZFSPOOL_PlayPurgeLog\n") )); - allowedInactive = genMsg->flags & ALLOW_INACTIVE_VOLUME; - genMsg->flags |= ALLOW_INACTIVE_VOLUME; - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* Latch the log */ - /* We now use the Volume's activation count instead of the global - * RestartCount. We do this because we stopped doing restart - * count setting when in MAINTENANCE mode. - */ + ENTER(TPLOG, ZFSPOOL_PlayPurgeLog); + DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN,MSGNot("CVS@ZFSPOOL_PlayPurgeLog\n") )); + allowedInactive = genMsg->flags & ALLOW_INACTIVE_VOLUME; + genMsg->flags |= ALLOW_INACTIVE_VOLUME; + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* Latch the log */ + /* We now use the Volume's activation count instead of the global + * RestartCount. We do this because we stopped doing restart + * count setting when in MAINTENANCE mode. + */ // savedRestartCount = pool->zfsLogBeast->ZLB_P.ZLBP_RecoveryActivationCount; - savedRestartCount = zfsVol->ZFSVOLactivationCount; + savedRestartCount = zfsVol->ZFSVOLactivationCount; - block = purgeLog->p.firstBlock; - if ( mode & VOLMODE_VERBOSE ) - { - aprintf(NSS_POOL_COLOR, MSGNot(" ** ")); - } - /* process each entry in the log */ - while (block != 0) - { /* process each entry until we are past the last block */ - if ( mode & VOLMODE_VERBOSE ) - { - aprintf(NSS_POOL_COLOR, MSGNot(".")); - } - for (slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) - { /* process each entry in the block */ - /* - * This read must be done inside the loop because the buffer cannot - * be kept locked. It causes the purge log transactions to not - * home. This causes the truncate log entries to build up and - * fill the log. - */ - beastIsLatched = FALSE; - READBLK_IO_MSG(aStack->iomsg, purgeLog, block, CACHE_READ); - SET_DEBUG_ID(aStack->iomsg, 10); - buffer = PLOG_ReadPoolBlk(genMsg, &aStack->iomsg); - if (buffer == NULL) - { - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ - if ( mode & VOLMODE_VERBOSE ) - { - aprintf(NSS_POOL_COLOR, MSGNot("\n")); - } - if ( !allowedInactive ) - { - genMsg->flags &= ~ALLOW_INACTIVE_VOLUME; - } - STACK_FREE(); - RTN_STATUS(zFAILURE); - } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - nextBlock = pLogBlock->nextBlock; - zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); - if ( pLogBlock->magic != PURGE_LOG_MAGIC ) - { - CACHE_RELEASE(buffer); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ - SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); - if ( mode & VOLMODE_VERBOSE ) - { - aprintf(NSS_POOL_COLOR, MSGNot("\n")); - } - if ( !allowedInactive ) - { - genMsg->flags &= ~ALLOW_INACTIVE_VOLUME; - } - STACK_FREE(); - RTN_STATUS(zFAILURE); - } - if (pLogBlock->logEntry[slot].generation >= savedRestartCount) - { /* the log record was inserted during the playing of the log -- ignore it*/ + block = purgeLog->p.firstBlock; + if ( mode & VOLMODE_VERBOSE ) + { + aprintf(NSS_POOL_COLOR, MSGNot(" ** ")); + } + /* process each entry in the log */ + while (block != 0) + { /* process each entry until we are past the last block */ + if ( mode & VOLMODE_VERBOSE ) + { + aprintf(NSS_POOL_COLOR, MSGNot(".")); + } + for (slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) + { /* process each entry in the block */ + /* + * This read must be done inside the loop because the buffer cannot + * be kept locked. It causes the purge log transactions to not + * home. This causes the truncate log entries to build up and + * fill the log. + */ + beastIsLatched = FALSE; + READBLK_IO_MSG(aStack->iomsg, purgeLog, block, CACHE_READ); + SET_DEBUG_ID(aStack->iomsg, 10); + buffer = PLOG_ReadPoolBlk(genMsg, &aStack->iomsg); + if (buffer == NULL) + { + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ + if ( mode & VOLMODE_VERBOSE ) + { + aprintf(NSS_POOL_COLOR, MSGNot("\n")); + } + if ( !allowedInactive ) + { + genMsg->flags &= ~ALLOW_INACTIVE_VOLUME; + } + STACK_FREE(); + RTN_STATUS(zFAILURE); + } + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + nextBlock = pLogBlock->nextBlock; + zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); + if ( pLogBlock->magic != PURGE_LOG_MAGIC ) + { + CACHE_RELEASE(buffer); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ + SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); + if ( mode & VOLMODE_VERBOSE ) + { + aprintf(NSS_POOL_COLOR, MSGNot("\n")); + } + if ( !allowedInactive ) + { + genMsg->flags &= ~ALLOW_INACTIVE_VOLUME; + } + STACK_FREE(); + RTN_STATUS(zFAILURE); + } + if (pLogBlock->logEntry[slot].generation >= savedRestartCount) + { /* the log record was inserted during the playing of the log -- ignore it*/ #if NSS_DEBUG IS_ENABLED - if (pLogBlock->logEntry[slot].type != PLOG_UNUSED) - { /* We do not display UNUSED info as it is bogus anyway */ - DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, - MSGNot("PL generation %d while volume is %d so skipping Purge Log Blk:%d Slot:%d type:%d\n"), - pLogBlock->logEntry[slot].generation, - savedRestartCount, - block, slot, pLogBlock->logEntry[slot].type)); - } + if (pLogBlock->logEntry[slot].type != PLOG_UNUSED) + { /* We do not display UNUSED info as it is bogus anyway */ + DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, + MSGNot("PL generation %d while volume is %d so skipping Purge Log Blk:%d Slot:%d type:%d\n"), + pLogBlock->logEntry[slot].generation, + savedRestartCount, + block, slot, pLogBlock->logEntry[slot].type)); + } #endif - CACHE_RELEASE(buffer); - goto next; - } - + CACHE_RELEASE(buffer); + goto next; + } + #if NSS_DEBUG IS_ENABLED - if (pLogBlock->logEntry[slot].type != PLOG_UNUSED) - { - DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, - MSGNot("Processing Purge Log Blk:%d Slot:%d type:%d\n"), - block, slot, pLogBlock->logEntry[slot].type)); - } + if (pLogBlock->logEntry[slot].type != PLOG_UNUSED) + { + DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, + MSGNot("Processing Purge Log Blk:%d Slot:%d type:%d\n"), + block, slot, pLogBlock->logEntry[slot].type)); + } #endif - /* release the lock, but keep the buffer around */ - CACHE_PIN(buffer); - CACHE_RELEASE(buffer); + /* release the lock, but keep the buffer around */ + CACHE_PIN(buffer); + CACHE_RELEASE(buffer); - /* Check the record type and take the appropriate action */ - switch (pLogBlock->logEntry[slot].type) - { - case PLOG_UNUSED: - { /* entry is unused -- skip it */ - buffer = PLOG_ReadPoolBlk(genMsg, &aStack->iomsg); /* latch the buffer again */ - if(buffer == NULL) - { - Abend("PLOG_ReadPoolBlk returned null pointer to a previously pinned buffer.\n"); - } - CACHE_UNPIN(buffer); - CACHE_RELEASE(buffer); - goto next; - break; - } + /* Check the record type and take the appropriate action */ + switch (pLogBlock->logEntry[slot].type) + { + case PLOG_UNUSED: + { /* entry is unused -- skip it */ + buffer = PLOG_ReadPoolBlk(genMsg, &aStack->iomsg); /* latch the buffer again */ + if(buffer == NULL) + { + Abend("PLOG_ReadPoolBlk returned null pointer to a previously pinned buffer.\n"); + } + CACHE_UNPIN(buffer); + CACHE_RELEASE(buffer); + goto next; + break; + } - case PLOG_BEAST_DELETE: - { /* a beast is being deleted */ - aStack->stats.PLS_numBeastDeletes++; - beastEntry = &pLogBlock->logEntry[slot].info.beast; - DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (CYAN, - MSGNot("BEAST DELETE - Zid=%d\n"), - (LONG)beastEntry->zid)); + case PLOG_BEAST_DELETE: + { /* a beast is being deleted */ + aStack->stats.PLS_numBeastDeletes++; + beastEntry = &pLogBlock->logEntry[slot].info.beast; + DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (CYAN, + MSGNot("BEAST DELETE - Zid=%d\n"), + (LONG)beastEntry->zid)); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ - /* get the beast to remove */ - beast = BEASTHASH_LookupByZid(genMsg, volume, beastEntry->zid, - NOTLATCHED); - if (beast != NULL) - { - /* beast has not been deleted -- delete it */ - /* remove data streams and extended attributes, - * and do any necessary salvage system maintenance */ - if (COMN_IsDerivedFrom(beast,zFTYPE_FILE)) - { - genMsg->flags |= ALLOW_INACTIVE_VOLUME; - if (BST_cleanupDeletedFile(genMsg,beast,TRUE,FALSE) != zOK) - { - /* Ignore errors, but do an assert if debug */ - zASSERT(0); - ClearErrno(genMsg); - } - } + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ + /* get the beast to remove */ + beast = BEASTHASH_LookupByZid(genMsg, volume, beastEntry->zid, + NOTLATCHED); + if (beast != NULL) + { + /* beast has not been deleted -- delete it */ + /* remove data streams and extended attributes, + * and do any necessary salvage system maintenance */ + if (COMN_IsDerivedFrom(beast,zFTYPE_FILE)) + { + genMsg->flags |= ALLOW_INACTIVE_VOLUME; + if (BST_cleanupDeletedFile(genMsg,beast,TRUE,FALSE) != zOK) + { + /* Ignore errors, but do an assert if debug */ + zASSERT(0); + ClearErrno(genMsg); + } + } - X_LATCH(&beast->ROOTbeastLatch); - beastIsLatched = TRUE; + X_LATCH(&beast->ROOTbeastLatch); + beastIsLatched = TRUE; if (CM_COMPRESSION_ENABLED(beast->ROOTvolume)) { @@ -1000,21 +1000,21 @@ STATUS ZFSPOOL_PlayPurgeLog ( } } - /* - * The state is set to purging so that the directory - * quota routine will know not to adjust for these - * blocks. They have already been done during - * the original beast delete. - */ - beast->bstState |= BST_STATE_PURGING; + /* + * The state is set to purging so that the directory + * quota routine will know not to adjust for these + * blocks. They have already been done during + * the original beast delete. + */ + beast->bstState |= BST_STATE_PURGING; - /* remove all blocks from the beast*/ - if (beast->ROOTcomnOps.BST_truncateFile(genMsg, beast, 0, -1) - != zOK) - { - zASSERT(0); - ClearErrno(genMsg); - } + /* remove all blocks from the beast*/ + if (beast->ROOTcomnOps.BST_truncateFile(genMsg, beast, 0, -1) + != zOK) + { + zASSERT(0); + ClearErrno(genMsg); + } /*------------------------------------------------------------------------- * Ensure that any mycache items are written and then TOSS the mycache. @@ -1023,86 +1023,86 @@ STATUS ZFSPOOL_PlayPurgeLog ( * 'dirty read' problem as it relates to REDO/UNDO and letting home * move to soon. *-------------------------------------------------------------------------*/ - beast->bstState |= BST_STATE_FLUSHING; - cacheFlushMyCacheBufs(&beast->ROOTmycache); - UNX_LATCH(&beast->ROOTbeastLatch); - defaultFlushWait(&beast->ROOTmycache.agent); - cacheTossAll(&beast->ROOTmycache); - X_LATCH(&beast->ROOTbeastLatch); - zASSERT(beast->useCount == 1); + beast->bstState |= BST_STATE_FLUSHING; + cacheFlushMyCacheBufs(&beast->ROOTmycache); + UNX_LATCH(&beast->ROOTbeastLatch); + defaultFlushWait(&beast->ROOTmycache.agent); + cacheTossAll(&beast->ROOTmycache); + X_LATCH(&beast->ROOTbeastLatch); + zASSERT(beast->useCount == 1); - xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - if (beast->ROOTcomnVolOps.VOL_removeBeastFromVolume(genMsg, - beast, &xaction->xaction) != zOK) - { - zASSERT(0); - ClearErrno(genMsg); - } + if (beast->ROOTcomnVolOps.VOL_removeBeastFromVolume(genMsg, + beast, &xaction->xaction) != zOK) + { + zASSERT(0); + ClearErrno(genMsg); + } - status = VOL_insertEFLEntry (genMsg, beast, - EFL_FILE_STATE_DELETE_FILE, NULL, - &xaction->xaction); + status = VOL_insertEFLEntry (genMsg, beast, + EFL_FILE_STATE_DELETE_FILE, NULL, + &xaction->xaction); - zASSERT(status == zOK); - ClearErrno(genMsg); + zASSERT(status == zOK); + ClearErrno(genMsg); - /* Remove any directory quota entries */ - status = beast->ROOTcomnVolOps.VOL_removeDirectory( - genMsg, beast->ROOTvolume, &xaction->xaction, - beast->zid); - if (status != zOK) - { - status = GetErrno(genMsg); - if (status != zERR_DIR_QUOTAS_NOT_ENABLED && - status != zERR_NO_SUCH_DIR) - { - zASSERT("Problem removing directory quota in purge log" == 0); - } - ClearErrno(genMsg); - } - } - else - { - ClearErrno(genMsg); - beastIsLatched = FALSE; - xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - } - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ - break; - } - case PLOG_TRUNCATE: - { - aStack->stats.PLS_numTruncates++; - truncEntry = &pLogBlock->logEntry[slot].info.trunc; + /* Remove any directory quota entries */ + status = beast->ROOTcomnVolOps.VOL_removeDirectory( + genMsg, beast->ROOTvolume, &xaction->xaction, + beast->zid); + if (status != zOK) + { + status = GetErrno(genMsg); + if (status != zERR_DIR_QUOTAS_NOT_ENABLED && + status != zERR_NO_SUCH_DIR) + { + zASSERT("Problem removing directory quota in purge log" == 0); + } + ClearErrno(genMsg); + } + } + else + { + ClearErrno(genMsg); + beastIsLatched = FALSE; + xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + } + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ + break; + } + case PLOG_TRUNCATE: + { + aStack->stats.PLS_numTruncates++; + truncEntry = &pLogBlock->logEntry[slot].info.trunc; DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (CYAN, MSGNot("Zid=%d startBlock=%d len=%d/n"), - (LONG)truncEntry->zid, truncEntry->startBlock, truncEntry->len)); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ - /* get the beast to remove */ - beast = BEASTHASH_LookupByZid(genMsg, volume, - truncEntry->zid, XLATCHED); - if (beast != NULL) - { - beastIsLatched = TRUE; + (LONG)truncEntry->zid, truncEntry->startBlock, truncEntry->len)); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ + /* get the beast to remove */ + beast = BEASTHASH_LookupByZid(genMsg, volume, + truncEntry->zid, XLATCHED); + if (beast != NULL) + { + beastIsLatched = TRUE; if ((truncEntry->startBlock == 0) && (truncEntry->len == -1) && CM_COMPRESSION_ENABLED(beast->ROOTvolume)) { - if (CM_prepareToTruncateFile(genMsg, beast, TRUE) + if (CM_prepareToTruncateFile(genMsg, beast, TRUE) != zOK) { zASSERT(0); ClearErrno(genMsg); } } - if (beast->ROOTcomnOps.BST_truncateFile(genMsg, beast, - truncEntry->startBlock, truncEntry->len) != zOK) - { - zASSERT(0); - ClearErrno(genMsg); - } + if (beast->ROOTcomnOps.BST_truncateFile(genMsg, beast, + truncEntry->startBlock, truncEntry->len) != zOK) + { + zASSERT(0); + ClearErrno(genMsg); + } /*------------------------------------------------------------------------- * Ensure that any mycache items are written and then TOSS the mycache. @@ -1111,341 +1111,341 @@ DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (CYAN, MSGNot("Zid=%d startBlock=%d len=%d * 'dirty read' problem as it relates to REDO/UNDO and letting home * move to soon. *-------------------------------------------------------------------------*/ - beast->bstState |= BST_STATE_FLUSHING; - cacheFlushMyCacheBufs(&beast->ROOTmycache); - UNX_LATCH(&beast->ROOTbeastLatch); - defaultFlushWait(&beast->ROOTmycache.agent); - cacheTossAll(&beast->ROOTmycache); - X_LATCH(&beast->ROOTbeastLatch); - zASSERT(beast->useCount == 1); + beast->bstState |= BST_STATE_FLUSHING; + cacheFlushMyCacheBufs(&beast->ROOTmycache); + UNX_LATCH(&beast->ROOTbeastLatch); + defaultFlushWait(&beast->ROOTmycache.agent); + cacheTossAll(&beast->ROOTmycache); + X_LATCH(&beast->ROOTbeastLatch); + zASSERT(beast->useCount == 1); - xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - } - else - { - ClearErrno(genMsg); - beastIsLatched = FALSE; - xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - } - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ - break; - } - case PLOG_BLOCK_FREE: - { - DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, - MSGNot(" PLOG_BLOCK_FREE block %ld(0x%lx)\n"), - pLogBlock->logEntry[slot].info.block.blockNumber, - pLogBlock->logEntry[slot].info.block.blockNumber)); - aStack->stats.PLS_numBlockDeletes++; - beastIsLatched = FALSE; - xaction = BeginXLocal(/*ZLSS_POOL_TO_VOLUME(pool)*/&zfsVol->ZFSVOLvol, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - extent.lengthOfExtent = 1; - extent.poolBlkNum = - pLogBlock->logEntry[slot].info.block.blockNumber; - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ - zfsFreeExtent(genMsg, /*&pool->ZFSPOOLzfsVol*/zfsVol, &extent, xaction); - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ - break; - } - case PLOG_BEAST_COMP_CLEANUP: - { /* a beast's compression state is being cleaned up */ + xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + } + else + { + ClearErrno(genMsg); + beastIsLatched = FALSE; + xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + } + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ + break; + } + case PLOG_BLOCK_FREE: + { + DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, + MSGNot(" PLOG_BLOCK_FREE block %ld(0x%lx)\n"), + pLogBlock->logEntry[slot].info.block.blockNumber, + pLogBlock->logEntry[slot].info.block.blockNumber)); + aStack->stats.PLS_numBlockDeletes++; + beastIsLatched = FALSE; + xaction = BeginXLocal(/*ZLSS_POOL_TO_VOLUME(pool)*/&zfsVol->ZFSVOLvol, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + extent.lengthOfExtent = 1; + extent.poolBlkNum = + pLogBlock->logEntry[slot].info.block.blockNumber; + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ + zfsFreeExtent(genMsg, /*&pool->ZFSPOOLzfsVol*/zfsVol, &extent, xaction); + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ + break; + } + case PLOG_BEAST_COMP_CLEANUP: + { /* a beast's compression state is being cleaned up */ ++aStack->stats.PLS_numBeastCompCleanups; - beastEntry = &pLogBlock->logEntry[slot].info.beast; + beastEntry = &pLogBlock->logEntry[slot].info.beast; DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (CYAN, MSGNot("BEAST COMP CLEANUP - Zid=%d\n"), (LONG)beastEntry->zid)); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ - /* get the beast to remove */ - beast = BEASTHASH_LookupByZid(genMsg, volume, beastEntry->zid, - NOTLATCHED); - if (beast != NULL) - { - zASSERT(beast->useCount == 1); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ + /* get the beast to remove */ + beast = BEASTHASH_LookupByZid(genMsg, volume, beastEntry->zid, + NOTLATCHED); + if (beast != NULL) + { + zASSERT(beast->useCount == 1); - X_LATCH(&beast->ROOTbeastLatch); + X_LATCH(&beast->ROOTbeastLatch); if (CM_cleanupBeast(genMsg, beast, 0) != zOK) - { - zASSERT(0); - ClearErrno(genMsg); - } + { + zASSERT(0); + ClearErrno(genMsg); + } + + beast->bstState |= BST_STATE_FLUSHING; + cacheFlushMyCacheBufs(&beast->ROOTmycache); + UNX_LATCH(&beast->ROOTbeastLatch); + defaultFlushWait(&beast->ROOTmycache.agent); + cacheTossAll(&beast->ROOTmycache); + X_LATCH(&beast->ROOTbeastLatch); - beast->bstState |= BST_STATE_FLUSHING; - cacheFlushMyCacheBufs(&beast->ROOTmycache); - UNX_LATCH(&beast->ROOTbeastLatch); - defaultFlushWait(&beast->ROOTmycache.agent); - cacheTossAll(&beast->ROOTmycache); - X_LATCH(&beast->ROOTbeastLatch); - - beastIsLatched = TRUE; - } - else - { - ClearErrno(genMsg); - beastIsLatched = FALSE; - } + beastIsLatched = TRUE; + } + else + { + ClearErrno(genMsg); + beastIsLatched = FALSE; + } xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ - break; - } - case PLOG_FIX_VISIBILITY: - { - aStack->stats.PLS_numFixVisib++; - beastIsLatched = FALSE; - zASSERT( volume == &zfsVol->ZFSVOLvol ); + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ + break; + } + case PLOG_FIX_VISIBILITY: + { + aStack->stats.PLS_numFixVisib++; + beastIsLatched = FALSE; + zASSERT( volume == &zfsVol->ZFSVOLvol ); - visibEntry = &pLogBlock->logEntry[slot].info.visib; + visibEntry = &pLogBlock->logEntry[slot].info.visib; DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (CYAN, MSGNot("BEAST FIX VISIB - Parent Zid=%d Trustee ID=%d Action=%d\n"),(LONG)visibEntry->parentZID, (LONG)visibEntry->trusteeID.timeLow, visibEntry->action)); - /* unlatch the log so new records can be logged */ - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); + /* unlatch the log so new records can be logged */ + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); - location.block = block; - location.slot = slot; - if (ZAS_FixVisibility( genMsg, visibEntry->action, - volume, visibEntry->parentZID, - &visibEntry->trusteeID, - &location) != zOK ) - { + location.block = block; + location.slot = slot; + if (ZAS_FixVisibility( genMsg, visibEntry->action, + volume, visibEntry->parentZID, + &visibEntry->trusteeID, + &location) != zOK ) + { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("%s Error setter is %s and error code is %ld\n"), WHERE, GetErrnoSetter(genMsg), GetErrno(genMsg) ); + DBG_DebugPrintf(LRED,MSGNot("%s Error setter is %s and error code is %ld\n"), WHERE, GetErrnoSetter(genMsg), GetErrno(genMsg) ); #endif - aprintf(LRED, MSG("Error fixing visibility of trustees that were being added or removed when the system crashed\n", 883)); - if (GetErrno(genMsg) == zERR_UNABLE_TO_OPEN_BEAST) - { - ClearErrno(genMsg); - goto needToRemoveEntry; - } - ClearErrno(genMsg); - } - /* This entry in the purgelog was removed by - * Fix_visibility, so do not start a transaction - */ - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch log*/ - buffer = PLOG_ReadPoolBlk(genMsg, &aStack->iomsg); - if(buffer == NULL) - { - Abend("PLOG_ReadPoolBlk returned null pointer to a previously pinned buffer.\n"); - } - CACHE_UNPIN(buffer); - CACHE_RELEASE(buffer); - goto next; + aprintf(LRED, MSG("Error fixing visibility of trustees that were being added or removed when the system crashed\n", 883)); + if (GetErrno(genMsg) == zERR_UNABLE_TO_OPEN_BEAST) + { + ClearErrno(genMsg); + goto needToRemoveEntry; + } + ClearErrno(genMsg); + } + /* This entry in the purgelog was removed by + * Fix_visibility, so do not start a transaction + */ + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch log*/ + buffer = PLOG_ReadPoolBlk(genMsg, &aStack->iomsg); + if(buffer == NULL) + { + Abend("PLOG_ReadPoolBlk returned null pointer to a previously pinned buffer.\n"); + } + CACHE_UNPIN(buffer); + CACHE_RELEASE(buffer); + goto next; needToRemoveEntry: - xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ - break; - } - case PLOG_SCAN_USER_NAMES: - { - aStack->stats.PLS_numScanUser++; + xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ + break; + } + case PLOG_SCAN_USER_NAMES: + { + aStack->stats.PLS_numScanUser++; DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (CYAN, MSGNot("SCAN USER NAMES - VolID=%Lx\n"), - pLogBlock->logEntry[slot].info.userScan.volumeID)); - zASSERT(volume == (Volume_s *)zfsVol); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ - OID_InitObjectInfo(genMsg, volume); - xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ - break; - } - case PLOG_REMOVE_USER_TREE: - { - aStack->stats.PLS_numRemoveUser++; + pLogBlock->logEntry[slot].info.userScan.volumeID)); + zASSERT(volume == (Volume_s *)zfsVol); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ + OID_InitObjectInfo(genMsg, volume); + xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ + break; + } + case PLOG_REMOVE_USER_TREE: + { + aStack->stats.PLS_numRemoveUser++; DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (CYAN, MSGNot("REMOVE USER TREE - VolID=%Lx\n"), - pLogBlock->logEntry[slot].info.user.volumeID)); - zASSERT(volume == (Volume_s *)zfsVol); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ - VOL_ChangeUserSpaceAttribute(genMsg, volume, FALSE); - volume->VOLcomnVolOps.VOL_resetAllObjects(genMsg, volume); - OID_InvalidateObjectIDCache(volume); - xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ - break; - } - case PLOG_CLEAR_USED_AMOUNT: - { - aStack->stats.PLS_numClearUser++; + pLogBlock->logEntry[slot].info.user.volumeID)); + zASSERT(volume == (Volume_s *)zfsVol); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ + VOL_ChangeUserSpaceAttribute(genMsg, volume, FALSE); + volume->VOLcomnVolOps.VOL_resetAllObjects(genMsg, volume); + OID_InvalidateObjectIDCache(volume); + xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ + break; + } + case PLOG_CLEAR_USED_AMOUNT: + { + aStack->stats.PLS_numClearUser++; DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (CYAN, MSGNot("CLEAR USER TREE USED AMOUNT- VolID=%Lx\n"), - pLogBlock->logEntry[slot].info.userClear.volumeID)); - zASSERT(volume == (Volume_s *)zfsVol); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ - VOL_ChangeUserSpaceAttribute(genMsg, volume, FALSE); - xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ - break; - } - case PLOG_REMOVE_DIR_TREE: - { + pLogBlock->logEntry[slot].info.userClear.volumeID)); + zASSERT(volume == (Volume_s *)zfsVol); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ + VOL_ChangeUserSpaceAttribute(genMsg, volume, FALSE); + xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ + break; + } + case PLOG_REMOVE_DIR_TREE: + { DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (CYAN, MSGNot("REMOVE DIR TREE - VolID=%Lx\n"), - pLogBlock->logEntry[slot].info.directory.volumeID)); - aStack->stats.PLS_numRemoveDirTree++; - zASSERT(volume == (Volume_s *)zfsVol); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ - DIRQ_ChangeDirQuotaAttribute(genMsg, volume, FALSE); - xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ - break; - } - case PLOG_DIR_QUOTA_USED: - { + pLogBlock->logEntry[slot].info.directory.volumeID)); + aStack->stats.PLS_numRemoveDirTree++; + zASSERT(volume == (Volume_s *)zfsVol); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ + DIRQ_ChangeDirQuotaAttribute(genMsg, volume, FALSE); + xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ + break; + } + case PLOG_DIR_QUOTA_USED: + { DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (CYAN, MSGNot("DIR USED AMOUNT - VolID=%Lx zid=%Ld\n"), - pLogBlock->logEntry[slot].info.dirUsed.volumeID, - pLogBlock->logEntry[slot].info.dirUsed.dirZid)); - aStack->stats.PLS_numDirQuotaUsed++; - zASSERT(volume == (Volume_s *)zfsVol); + pLogBlock->logEntry[slot].info.dirUsed.volumeID, + pLogBlock->logEntry[slot].info.dirUsed.dirZid)); + aStack->stats.PLS_numDirQuotaUsed++; + zASSERT(volume == (Volume_s *)zfsVol); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ - DIRQ_ComputeUsedAmount(volume, - pLogBlock->logEntry[slot].info.dirUsed.dirZid, - &amountUsed, FALSE); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ + DIRQ_ComputeUsedAmount(volume, + pLogBlock->logEntry[slot].info.dirUsed.dirZid, + &amountUsed, FALSE); - if (amountUsed >= 0) - { - /* If the amount is good then make any needed adjustment */ + if (amountUsed >= 0) + { + /* If the amount is good then make any needed adjustment */ - if (volume->VOLcomnVolOps.VOL_getDirQuotaInfo(genMsg, - volume, - pLogBlock->logEntry[slot].info.dirUsed.dirZid, - "a, &usedAmount) != zOK) - { - zASSERT("Problem getting dir quota used amount" == 0); - errPrintf(WHERE, Module, 1469, - MSG("Unable to get used amount in dir quota, status=%d.\n", - 113), GetErrno(genMsg)); - usedAmount = 0; - } + if (volume->VOLcomnVolOps.VOL_getDirQuotaInfo(genMsg, + volume, + pLogBlock->logEntry[slot].info.dirUsed.dirZid, + "a, &usedAmount) != zOK) + { + zASSERT("Problem getting dir quota used amount" == 0); + errPrintf(WHERE, Module, 1469, + MSG("Unable to get used amount in dir quota, status=%d.\n", + 113), GetErrno(genMsg)); + usedAmount = 0; + } - amountUsed -= usedAmount; + amountUsed -= usedAmount; - xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - volume->VOLcomnVolOps.VOL_adjustUsedDirSpace( - &xaction->xaction, volume, - pLogBlock->logEntry[slot].info.dirUsed.dirZid, - amountUsed); - } - else - { - xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - } - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); - break; - } - case PLOG_EFL_REMOVE_EPOCH: - { - aStack->stats.PLS_numEpochRemove++; + xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + volume->VOLcomnVolOps.VOL_adjustUsedDirSpace( + &xaction->xaction, volume, + pLogBlock->logEntry[slot].info.dirUsed.dirZid, + amountUsed); + } + else + { + xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + } + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); + break; + } + case PLOG_EFL_REMOVE_EPOCH: + { + aStack->stats.PLS_numEpochRemove++; DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (CYAN, MSGNot("REMOVE EFL EPOCH- VolID=%Lx epoch = %d\n"), - pLogBlock->logEntry[slot].info.epochRemove.volumeID, pLogBlock->logEntry[slot].info.epochRemove.epoch)); - zASSERT(volume == (Volume_s *)zfsVol); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ - - if (eflRemoveEpoch(genMsg, volume, - &pLogBlock->logEntry[slot].info.epochRemove.epoch) != zOK) - { + pLogBlock->logEntry[slot].info.epochRemove.volumeID, pLogBlock->logEntry[slot].info.epochRemove.epoch)); + zASSERT(volume == (Volume_s *)zfsVol); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ + + if (eflRemoveEpoch(genMsg, volume, + &pLogBlock->logEntry[slot].info.epochRemove.epoch) != zOK) + { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("%s Error setter is %s and error code is %ld\n"), WHERE, GetErrnoSetter(genMsg), GetErrno(genMsg) ); + DBG_DebugPrintf(LRED,MSGNot("%s Error setter is %s and error code is %ld\n"), WHERE, GetErrnoSetter(genMsg), GetErrno(genMsg) ); #endif - aprintf(LRED, MSG("Error removing epoch that is being processed when the system crashed\n", 582)); - ClearErrno(genMsg); - } + aprintf(LRED, MSG("Error removing epoch that is being processed when the system crashed\n", 582)); + ClearErrno(genMsg); + } + + xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* latch the log so new records can be logged */ - xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* latch the log so new records can be logged */ - - break; - } - case PLOG_EFL_RESET_TREE: - { - aStack->stats.PLS_numResetEFL++; + break; + } + case PLOG_EFL_RESET_TREE: + { + aStack->stats.PLS_numResetEFL++; DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (CYAN, MSGNot("REMOVE EFL TREE - VolID=%Lx\n"), - pLogBlock->logEntry[slot].info.resetEFL.volumeID)); - zASSERT(volume == (Volume_s *)zfsVol); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ - volume->VOLcomnVolOps.VOL_resetEFL(genMsg, volume); - xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ - break; - } - default: - { - zASSERT("Unknown purge log record type" == 0); - buffer = PLOG_ReadPoolBlk(genMsg, &aStack->iomsg); /* latch the buffer again */ - if(buffer == NULL) - { - Abend("PLOG_ReadPoolBlk returned null pointer to a previously pinned buffer.\n"); - } - CACHE_UNPIN(buffer); - CACHE_RELEASE(buffer); - goto next; - break; - } - } + pLogBlock->logEntry[slot].info.resetEFL.volumeID)); + zASSERT(volume == (Volume_s *)zfsVol); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log so new records can be logged */ + volume->VOLcomnVolOps.VOL_resetEFL(genMsg, volume); + xaction = BeginXLocal(volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* relatch the log */ + break; + } + default: + { + zASSERT("Unknown purge log record type" == 0); + buffer = PLOG_ReadPoolBlk(genMsg, &aStack->iomsg); /* latch the buffer again */ + if(buffer == NULL) + { + Abend("PLOG_ReadPoolBlk returned null pointer to a previously pinned buffer.\n"); + } + CACHE_UNPIN(buffer); + CACHE_RELEASE(buffer); + goto next; + break; + } + } - aStack->iomsg.mode = CACHE_UPDATE; - buffer = PLOG_ReadPoolBlk(genMsg, &aStack->iomsg); /* latch the buffer again - exclusive*/ - if(buffer == NULL) - { - Abend("PLOG_ReadPoolBlk returned null pointer to a previously pinned buffer.\n"); - } - CACHE_UNPIN(buffer); + aStack->iomsg.mode = CACHE_UPDATE; + buffer = PLOG_ReadPoolBlk(genMsg, &aStack->iomsg); /* latch the buffer again - exclusive*/ + if(buffer == NULL) + { + Abend("PLOG_ReadPoolBlk returned null pointer to a previously pinned buffer.\n"); + } + CACHE_UNPIN(buffer); - /* log the deletion */ - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(LogPurgeLog_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_PLOG_DELETE, xaction, logBuffer, 1, - poolBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], block, pLogBlock->lsn, buffer, - xaction, 0); /* old block number */ + /* log the deletion */ + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(LogPurgeLog_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_PLOG_DELETE, xaction, logBuffer, 1, + poolBlks, logRecord); + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], block, pLogBlock->lsn, buffer, + xaction, 0); /* old block number */ #if LOG_TEST IS_ENABLED - holdLsn = logBuffer->ZXR_Lsn; + holdLsn = logBuffer->ZXR_Lsn; #else - pLogBlock->lsn = logBuffer->ZXR_Lsn; + pLogBlock->lsn = logBuffer->ZXR_Lsn; #endif - logRecord->slot = slot; - logRecord->entry = pLogBlock->logEntry[slot]; + logRecord->slot = slot; + logRecord->entry = pLogBlock->logEntry[slot]; - ZLOG_BIND(xaction, buffer); - ZLOG_TEST_REDO(xaction); - ZLOG_ReleaseRecordAndLogEnd(xaction); + ZLOG_BIND(xaction, buffer); + ZLOG_TEST_REDO(xaction); + ZLOG_ReleaseRecordAndLogEnd(xaction); #if LOG_TEST IS_ENABLED - pLogBlock->lsn = holdLsn; + pLogBlock->lsn = holdLsn; #endif - EndXlocal(xaction); + EndXlocal(xaction); - /* fill in the purged record and put it on the avail list*/ - pLogBlock->logEntry[slot].type = PLOG_UNUSED; - ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->block - = purgeLog->freeList.block; - ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->slot - = purgeLog->freeList.slot; - purgeLog->freeList.block = block; - purgeLog->freeList.slot = slot; + /* fill in the purged record and put it on the avail list*/ + pLogBlock->logEntry[slot].type = PLOG_UNUSED; + ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->block + = purgeLog->freeList.block; + ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->slot + = purgeLog->freeList.slot; + purgeLog->freeList.block = block; + purgeLog->freeList.slot = slot; // /* // * uplatch the buffer to make changes -- it is shared while // * doing the truncates so the transactions can be homed. // */ // UP_LATCH(&buffer->agent.latch); - pLogBlock->logEntry[slot].type = PLOG_UNUSED; + pLogBlock->logEntry[slot].type = PLOG_UNUSED; - /* release the beast beasts */ - if (beastIsLatched) + /* release the beast beasts */ + if (beastIsLatched) { - UNX_LATCH(&beast->ROOTbeastLatch); - BST_releaseAndFree(beast); + UNX_LATCH(&beast->ROOTbeastLatch); + BST_releaseAndFree(beast); } - /* - * Release the cache block from the purge log. It cannot be kept - * locked because it causes the purge log transactions not to - * home. This causes the trucate transactions to pile up. - */ - CACHE_DIRTY_RELEASE(buffer); + /* + * Release the cache block from the purge log. It cannot be kept + * locked because it causes the purge log transactions not to + * home. This causes the trucate transactions to pile up. + */ + CACHE_DIRTY_RELEASE(buffer); next: - continue; - } - block = nextBlock; - } - if ( mode & VOLMODE_VERBOSE ) - { - aprintf(NSS_POOL_COLOR, MSGNot("\n")); - } + continue; + } + block = nextBlock; + } + if ( mode & VOLMODE_VERBOSE ) + { + aprintf(NSS_POOL_COLOR, MSGNot("\n")); + } // This code does not modify Purgelog, so it is not necessary to mark // it dirty. Flushing it on a timer can cause a situation that we have @@ -1453,74 +1453,74 @@ next: // is waiting for a thread. // COMN_MARK_BEAST_DIRTY(&purgeLog->ZFSPURGELOGroot); #if NSS_DEBUG IS_ENABLED - /* March 29, 2000 - The purge log needs to be empty for - * Logical Volume(LV) Auto-in-place-upgrade(AIPU) to be - * able run successfully. LV AIPU counts blocks and move - * system beast so it can not have these beasts being used. - * We will properly be forced to ensure this BEFORE six-pack - * zlss runs. Either with a media 34 NSS or ZLSS. - * - * WARNING - currently we do not ensure this. For example, - * if a beast delete causes a b-tree join or shrink then there - * will be a purge log entry for the system block free. - */ + /* March 29, 2000 - The purge log needs to be empty for + * Logical Volume(LV) Auto-in-place-upgrade(AIPU) to be + * able run successfully. LV AIPU counts blocks and move + * system beast so it can not have these beasts being used. + * We will properly be forced to ensure this BEFORE six-pack + * zlss runs. Either with a media 34 NSS or ZLSS. + * + * WARNING - currently we do not ensure this. For example, + * if a beast delete causes a b-tree join or shrink then there + * will be a purge log entry for the system block free. + */ // plogValidate( purgeLog, TRUE ); /* Validate that PL is EMPTY */ - VALIDATE_PLOG(purgeLog); + VALIDATE_PLOG(purgeLog); #endif - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ #if NSS_DEBUG IS_ENABLED - if ( mode & VOLMODE_VERBOSE ) - { - aprintf(CYAN, - MSGNot(" Beast deletes: %d Beast truncates: %d Block frees: %d\n" - " Compress clean: %d Visiblity fix: %d Remove user tree: %d\n" - " Clear user tree: %d Remove dir tree: %d Compute used amount: %d\n" - " Scan user tree: %d Epoch Remove: %d Reset EFL tree: %d\n"), - aStack->stats.PLS_numBeastDeletes, - aStack->stats.PLS_numTruncates, - aStack->stats.PLS_numBlockDeletes, + if ( mode & VOLMODE_VERBOSE ) + { + aprintf(CYAN, + MSGNot(" Beast deletes: %d Beast truncates: %d Block frees: %d\n" + " Compress clean: %d Visiblity fix: %d Remove user tree: %d\n" + " Clear user tree: %d Remove dir tree: %d Compute used amount: %d\n" + " Scan user tree: %d Epoch Remove: %d Reset EFL tree: %d\n"), + aStack->stats.PLS_numBeastDeletes, + aStack->stats.PLS_numTruncates, + aStack->stats.PLS_numBlockDeletes, aStack->stats.PLS_numBeastCompCleanups, - aStack->stats.PLS_numFixVisib, - aStack->stats.PLS_numRemoveUser, - aStack->stats.PLS_numClearUser, - aStack->stats.PLS_numRemoveDirTree, - aStack->stats.PLS_numDirQuotaUsed, - aStack->stats.PLS_numScanUser, - aStack->stats.PLS_numEpochRemove, - aStack->stats.PLS_numResetEFL); - } + aStack->stats.PLS_numFixVisib, + aStack->stats.PLS_numRemoveUser, + aStack->stats.PLS_numClearUser, + aStack->stats.PLS_numRemoveDirTree, + aStack->stats.PLS_numDirQuotaUsed, + aStack->stats.PLS_numScanUser, + aStack->stats.PLS_numEpochRemove, + aStack->stats.PLS_numResetEFL); + } #endif - if ( !allowedInactive ) - { - genMsg->flags &= ~ALLOW_INACTIVE_VOLUME; - } - STACK_FREE(); - RTN_STATUS(zOK); + if ( !allowedInactive ) + { + genMsg->flags &= ~ALLOW_INACTIVE_VOLUME; + } + STACK_FREE(); + RTN_STATUS(zOK); } - + /**************************************************************************** * Init a new purge log block * ****************************************************************************/ void ZFSVOL_InitPurgeLogBlock ( - Buffer_s *buffer, - GUID_t *internalID) + Buffer_s *buffer, + GUID_t *internalID) { - PurgeLogBlock_s *pLogBlock; - NINT slot; + PurgeLogBlock_s *pLogBlock; + NINT slot; - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - pLogBlock->magic = PURGE_LOG_MAGIC; - pLogBlock->nextBlock = 0; - pLogBlock->lsn = 0; - zASSERT( LB_GUIDValidate( internalID ) ); - pLogBlock->plb_internalID = *internalID; - for(slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) - { - pLogBlock->logEntry[slot].type = PLOG_UNUSED; - } + pLogBlock->magic = PURGE_LOG_MAGIC; + pLogBlock->nextBlock = 0; + pLogBlock->lsn = 0; + zASSERT( LB_GUIDValidate( internalID ) ); + pLogBlock->plb_internalID = *internalID; + for(slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) + { + pLogBlock->logEntry[slot].type = PLOG_UNUSED; + } } @@ -1530,545 +1530,545 @@ void ZFSVOL_InitPurgeLogBlock ( * ****************************************************************************/ STATUS ZFSVOL_VOL_AddPurgeLogEntry ( - GeneralMsg_s *genMsg, - Volume_s *volume, - NINT type, /* input: the type of entry being added */ - PurgeLogMsg_s *purgeMsg, /* input: the actual information to be logged */ - Xaction_s *xAction) + GeneralMsg_s *genMsg, + Volume_s *volume, + NINT type, /* input: the type of entry being added */ + PurgeLogMsg_s *purgeMsg, /* input: the actual information to be logged */ + Xaction_s *xAction) { - NINT slot; - Buffer_s *buffer; - Blknum_t newBlock; - IoMsg_s iomsg; - ZfsXasRecovery_s *logBuffer; - BlockInfo_s *poolBlks; - LogPurgeLog_s *logRecord; - PurgeLogBlock_s *pLogBlock; - ZfsPurgeLogBeast_s *purgeLog; - ZfsXaction_s *xaction; - ZfsPurgeLogLoc_s *location = NULL; - NINT retryCount; + NINT slot; + Buffer_s *buffer; + Blknum_t newBlock; + IoMsg_s iomsg; + ZfsXasRecovery_s *logBuffer; + BlockInfo_s *poolBlks; + LogPurgeLog_s *logRecord; + PurgeLogBlock_s *pLogBlock; + ZfsPurgeLogBeast_s *purgeLog; + ZfsXaction_s *xaction; + ZfsPurgeLogLoc_s *location = NULL; + NINT retryCount; - ENTER(TPLOG, ZFSVOL_AddPurgeLogEntry); + ENTER(TPLOG, ZFSVOL_AddPurgeLogEntry); - zASSERT(!(volume->VOLenabledAttributes & zATTR_READONLY)); + zASSERT(!(volume->VOLenabledAttributes & zATTR_READONLY)); - retryCount = 0; - xaction = (ZfsXaction_s *)xAction; + retryCount = 0; + xaction = (ZfsXaction_s *)xAction; - switch (type) - { - /* These are the purge log records that are handled by - * the VOLUME Purge Log. - */ - case PLOG_BLOCK_FREE: - case PLOG_BEAST_COMP_CLEANUP: - case PLOG_BEAST_DELETE: - case PLOG_TRUNCATE: - case PLOG_FIX_VISIBILITY: - case PLOG_SCAN_USER_NAMES: - case PLOG_REMOVE_USER_TREE: - case PLOG_CLEAR_USED_AMOUNT: - case PLOG_REMOVE_DIR_TREE: - case PLOG_DIR_QUOTA_USED: - case PLOG_EFL_REMOVE_EPOCH: - case PLOG_EFL_RESET_TREE: - { - purgeLog = ((ZfsVolume_s *)volume)->ZFSVOLvolumePurgeLog; - DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, - MSGNot("*** *** Add Purge Log (VOLUME) operation %d ***\n"), - type)); + switch (type) + { + /* These are the purge log records that are handled by + * the VOLUME Purge Log. + */ + case PLOG_BLOCK_FREE: + case PLOG_BEAST_COMP_CLEANUP: + case PLOG_BEAST_DELETE: + case PLOG_TRUNCATE: + case PLOG_FIX_VISIBILITY: + case PLOG_SCAN_USER_NAMES: + case PLOG_REMOVE_USER_TREE: + case PLOG_CLEAR_USED_AMOUNT: + case PLOG_REMOVE_DIR_TREE: + case PLOG_DIR_QUOTA_USED: + case PLOG_EFL_REMOVE_EPOCH: + case PLOG_EFL_RESET_TREE: + { + purgeLog = ((ZfsVolume_s *)volume)->ZFSVOLvolumePurgeLog; + DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, + MSGNot("*** *** Add Purge Log (VOLUME) operation %d ***\n"), + type)); // zASSERT( purgeLog != NULL ); - if ( purgeLog == NULL ) - { /** - * This code is here just in case someone calls this - * routine during LV AIPU before the volume purge logs - * are created. - */ - purgeLog = ((ZfsVolume_s *)volume)->pool->ZFSPOOLpurgeLogBeast; - zASSERT( purgeLog != NULL ); - if ( purgeLog == NULL ) - { - SetErrno( genMsg, zERR_MISSING_BEAST ); - return( zFAILURE ); - } - } - break; - } + if ( purgeLog == NULL ) + { /** + * This code is here just in case someone calls this + * routine during LV AIPU before the volume purge logs + * are created. + */ + purgeLog = ((ZfsVolume_s *)volume)->pool->ZFSPOOLpurgeLogBeast; + zASSERT( purgeLog != NULL ); + if ( purgeLog == NULL ) + { + SetErrno( genMsg, zERR_MISSING_BEAST ); + return( zFAILURE ); + } + } + break; + } #if 0 - /* These are the purge log records that are handled by - * the POOL Purge Log. - */ - case PLOG_BLOCK_FREE: - { - purgeLog = ((ZfsVolume_s *)volume)->pool->ZFSPOOLpurgeLogBeast; - DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, - MSGNot("*** *** Add Purge Log (POOL) operation %d *****\n") - ,type)); - zASSERT( purgeLog != NULL ); - break; - } + /* These are the purge log records that are handled by + * the POOL Purge Log. + */ + case PLOG_BLOCK_FREE: + { + purgeLog = ((ZfsVolume_s *)volume)->pool->ZFSPOOLpurgeLogBeast; + DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, + MSGNot("*** *** Add Purge Log (POOL) operation %d *****\n") + ,type)); + zASSERT( purgeLog != NULL ); + break; + } #endif - default: - { - zASSERT("Bad purge log record type" == 0); - SetErrno( genMsg, zERR_NOT_SUPPORTED ); - return( zFAILURE ); - } - } + default: + { + zASSERT("Bad purge log record type" == 0); + SetErrno( genMsg, zERR_NOT_SUPPORTED ); + return( zFAILURE ); + } + } tryAgain: - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* Latch the log */ + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* Latch the log */ - if (purgeLog->p.firstBlock == 0) + if (purgeLog->p.firstBlock == 0) { /* if the log has never been created */ - zASSERT("Purge log not found" == 0); - goto errorExit; + zASSERT("Purge log not found" == 0); + goto errorExit; } - /* log is already there */ - VALIDATE_PLOG(purgeLog); - if (purgeLog->freeList.block == 0) - { /* if the free list is empty */ - READBLK_IO_MSG(iomsg, purgeLog, purgeLog->nextUnused.block, CACHE_UPDATE); - SET_DEBUG_ID(iomsg, 11); - buffer = PLOG_ReadPoolBlk(genMsg, &iomsg); - if (buffer == NULL) - { - goto errorExit; - } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); - if ( pLogBlock->magic != PURGE_LOG_MAGIC ) - { - CACHE_RELEASE(buffer); - SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); - goto errorExit; - } - slot = purgeLog->nextUnused.slot++; + /* log is already there */ + VALIDATE_PLOG(purgeLog); + if (purgeLog->freeList.block == 0) + { /* if the free list is empty */ + READBLK_IO_MSG(iomsg, purgeLog, purgeLog->nextUnused.block, CACHE_UPDATE); + SET_DEBUG_ID(iomsg, 11); + buffer = PLOG_ReadPoolBlk(genMsg, &iomsg); + if (buffer == NULL) + { + goto errorExit; + } + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); + if ( pLogBlock->magic != PURGE_LOG_MAGIC ) + { + CACHE_RELEASE(buffer); + SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); + goto errorExit; + } + slot = purgeLog->nextUnused.slot++; - if (slot >= MAX_PURGE_LOG_ENTRIES) - { /* if the block is full then get a new block */ - if (pLogBlock->nextBlock != 0) - { /* if there is another block allocated read it */ - newBlock = pLogBlock->nextBlock; - CACHE_RELEASE(buffer); - READBLK_IO_MSG(iomsg, purgeLog, newBlock, CACHE_UPDATE); - SET_DEBUG_ID(iomsg, 12); - buffer = PLOG_ReadPoolBlk(genMsg, &iomsg); - if (buffer == NULL) - { - goto errorExit; - } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); - if ( pLogBlock->magic != PURGE_LOG_MAGIC ) - { - CACHE_RELEASE(buffer); - SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); - goto errorExit; - } - purgeLog->nextUnused.block = buffer->volBlk; /* point to new block */ - purgeLog->nextUnused.slot = 1; /* init pointer to next free slot */ - slot = 0; - } - else - { /* need to add a block to the file */ - /* Start a new transaction */ - LogPurgeLogGrow_s *growLogRecord; - PurgeLogBlock_s *newLogBlock; - Buffer_s *newBuffer; - ZfsXaction_s *localXaction; - Buffer_s *spBuf; + if (slot >= MAX_PURGE_LOG_ENTRIES) + { /* if the block is full then get a new block */ + if (pLogBlock->nextBlock != 0) + { /* if there is another block allocated read it */ + newBlock = pLogBlock->nextBlock; + CACHE_RELEASE(buffer); + READBLK_IO_MSG(iomsg, purgeLog, newBlock, CACHE_UPDATE); + SET_DEBUG_ID(iomsg, 12); + buffer = PLOG_ReadPoolBlk(genMsg, &iomsg); + if (buffer == NULL) + { + goto errorExit; + } + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); + if ( pLogBlock->magic != PURGE_LOG_MAGIC ) + { + CACHE_RELEASE(buffer); + SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); + goto errorExit; + } + purgeLog->nextUnused.block = buffer->volBlk; /* point to new block */ + purgeLog->nextUnused.slot = 1; /* init pointer to next free slot */ + slot = 0; + } + else + { /* need to add a block to the file */ + /* Start a new transaction */ + LogPurgeLogGrow_s *growLogRecord; + PurgeLogBlock_s *newLogBlock; + Buffer_s *newBuffer; + ZfsXaction_s *localXaction; + Buffer_s *spBuf; - localXaction = BeginXLocal(volume, BXL_DEFAULT); - XALLOCBLK_IO_MSG( iomsg, purgeLog, localXaction, CACHE_UPDATE); - newBuffer = ZFS_AllocPoolBlkSpecial(genMsg, &iomsg, &spBuf); - if (newBuffer == NULL) - { - EndXlocal(localXaction); - if (++retryCount >= 10) - { - goto errorBufferRelease; - } - ClearErrno(genMsg); - purgeLog->nextUnused.slot--; - CACHE_RELEASE(buffer); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ - LB_delay(100); - goto tryAgain; - } + localXaction = BeginXLocal(volume, BXL_DEFAULT); + XALLOCBLK_IO_MSG( iomsg, purgeLog, localXaction, CACHE_UPDATE); + newBuffer = ZFS_AllocPoolBlkSpecial(genMsg, &iomsg, &spBuf); + if (newBuffer == NULL) + { + EndXlocal(localXaction); + if (++retryCount >= 10) + { + goto errorBufferRelease; + } + ClearErrno(genMsg); + purgeLog->nextUnused.slot--; + CACHE_RELEASE(buffer); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ + LB_delay(100); + goto tryAgain; + } - newBlock = newBuffer->volBlk; /* block number for the new block */ - pLogBlock->nextBlock = newBlock; /* link the new block to the old one */ - BUG_PURGE_BLOCK(newBlock); + newBlock = newBuffer->volBlk; /* block number for the new block */ + pLogBlock->nextBlock = newBlock; /* link the new block to the old one */ + BUG_PURGE_BLOCK(newBlock); - newLogBlock = (PurgeLogBlock_s *)newBuffer->pBuf.data; - zASSERT( LB_GUIDValidate( &purgeLog->ZFSPURGELOGroot.ROOTvolumeID ) ); - ZFSVOL_InitPurgeLogBlock(newBuffer, - &purgeLog->ZFSPURGELOGroot.ROOTinternalID); - purgeLog->nextUnused.block = newBlock; /* point to new block */ - purgeLog->nextUnused.slot = 1; /* init pointer to next free slot */ + newLogBlock = (PurgeLogBlock_s *)newBuffer->pBuf.data; + zASSERT( LB_GUIDValidate( &purgeLog->ZFSPURGELOGroot.ROOTvolumeID ) ); + ZFSVOL_InitPurgeLogBlock(newBuffer, + &purgeLog->ZFSPURGELOGroot.ROOTinternalID); + purgeLog->nextUnused.block = newBlock; /* point to new block */ + purgeLog->nextUnused.slot = 1; /* init pointer to next free slot */ - /* log the grow record */ - ZLOG_ObtainRecord(localXaction, - ZLOG_BLOCK_INFO_SIZE(2) + sizeof(LogPurgeLogGrow_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_PLOG_GROW, localXaction, logBuffer, 2, - poolBlks, growLogRecord); - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, - pLogBlock->lsn, buffer, localXaction, 0); /* old block number */ - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], newBlock, - newLogBlock->lsn, newBuffer, localXaction, 1); - pLogBlock->lsn = logBuffer->ZXR_Lsn; - newLogBlock->lsn = logBuffer->ZXR_Lsn; - growLogRecord->lplg_internalID = - purgeLog->ZFSPURGELOGroot.ROOTinternalID; + /* log the grow record */ + ZLOG_ObtainRecord(localXaction, + ZLOG_BLOCK_INFO_SIZE(2) + sizeof(LogPurgeLogGrow_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_PLOG_GROW, localXaction, logBuffer, 2, + poolBlks, growLogRecord); + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, + pLogBlock->lsn, buffer, localXaction, 0); /* old block number */ + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], newBlock, + newLogBlock->lsn, newBuffer, localXaction, 1); + pLogBlock->lsn = logBuffer->ZXR_Lsn; + newLogBlock->lsn = logBuffer->ZXR_Lsn; + growLogRecord->lplg_internalID = + purgeLog->ZFSPURGELOGroot.ROOTinternalID; - ZLOG_BIND(localXaction, buffer); - ZLOG_BIND(localXaction, newBuffer); + ZLOG_BIND(localXaction, buffer); + ZLOG_BIND(localXaction, newBuffer); - ZLOG_ReleaseRecord(localXaction); - EndXlocal(localXaction); - CACHE_DIRTY_RELEASE(spBuf); - CACHE_DIRTY_RELEASE(buffer); - /* Switch over to new block */ - buffer = newBuffer; - pLogBlock = newLogBlock; - slot = 0; + ZLOG_ReleaseRecord(localXaction); + EndXlocal(localXaction); + CACHE_DIRTY_RELEASE(spBuf); + CACHE_DIRTY_RELEASE(buffer); + /* Switch over to new block */ + buffer = newBuffer; + pLogBlock = newLogBlock; + slot = 0; DEBUG_PRINTF(TPLOG, DBG_NOINDENT, (GREEN, MSGNot("PLOG -- added a new block (%d) to the log\n"), buffer->volBlk)); - } - } - } - else - { /* get the entry from the free list */ - READBLK_IO_MSG(iomsg, purgeLog, purgeLog->freeList.block, CACHE_UPDATE); - SET_DEBUG_ID(iomsg, 13); - buffer = PLOG_ReadPoolBlk(genMsg, &iomsg); - if (buffer == NULL) - { - goto errorExit; - } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); - if ( pLogBlock->magic != PURGE_LOG_MAGIC ) - { - CACHE_RELEASE(buffer); - SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); - goto errorExit; - } - slot = purgeLog->freeList.slot; - purgeLog->freeList.block = - pLogBlock->logEntry[slot].info.free.link.block; - purgeLog->freeList.slot = - pLogBlock->logEntry[slot].info.free.link.slot; - } + } + } + } + else + { /* get the entry from the free list */ + READBLK_IO_MSG(iomsg, purgeLog, purgeLog->freeList.block, CACHE_UPDATE); + SET_DEBUG_ID(iomsg, 13); + buffer = PLOG_ReadPoolBlk(genMsg, &iomsg); + if (buffer == NULL) + { + goto errorExit; + } + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); + if ( pLogBlock->magic != PURGE_LOG_MAGIC ) + { + CACHE_RELEASE(buffer); + SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); + goto errorExit; + } + slot = purgeLog->freeList.slot; + purgeLog->freeList.block = + pLogBlock->logEntry[slot].info.free.link.block; + purgeLog->freeList.slot = + pLogBlock->logEntry[slot].info.free.link.slot; + } - /* add the entry to the log */ - pLogBlock->logEntry[slot].type = type; + /* add the entry to the log */ + pLogBlock->logEntry[slot].type = type; // pLogBlock->logEntry[slot].generation = RestartCount; // pLogBlock->logEntry[slot].generation = // xaction->ZX_zlogBeast->ZLB_P.ZLBP_RecoveryActivationCount; - pLogBlock->logEntry[slot].generation = ((ZfsVolume_s *)volume)->ZFSVOLactivationCount; - DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, - MSGNot(" Activation count is %d\n"), - ((ZfsVolume_s *)volume)->ZFSVOLactivationCount)); - switch (type) - { - case PLOG_BEAST_DELETE: - { - pLogBlock->logEntry[slot].info.beast.volumeID = - purgeMsg->beast.beast->vol.volume->VOLvolumeID; - zASSERT(purgeMsg->beast.beast->zid != 0); - pLogBlock->logEntry[slot].info.beast.zid = - purgeMsg->beast.beast->zid; - if (purgeMsg->beast.dirBeast != NULL) - { - zASSERT(purgeMsg->beast.dirBeast->zid != 0); - pLogBlock->logEntry[slot].info.beast.dirZid = - purgeMsg->beast.dirBeast->zid; - } - else - { - pLogBlock->logEntry[slot].info.beast.dirZid = zINVALID_ZID; - } - location = &purgeMsg->beast.beast->storage.zfsInfo->deletePurgeLogLoc; - break; - } - case PLOG_BEAST_COMP_CLEANUP: - { - pLogBlock->logEntry[slot].info.beast.volumeID = - purgeMsg->beast.beast->vol.volume->VOLvolumeID; - zASSERT(purgeMsg->beast.beast->zid != 0); - zASSERT(purgeMsg->beast.dirBeast == NULL); - pLogBlock->logEntry[slot].info.beast.zid = - purgeMsg->beast.beast->zid; + pLogBlock->logEntry[slot].generation = ((ZfsVolume_s *)volume)->ZFSVOLactivationCount; + DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, + MSGNot(" Activation count is %d\n"), + ((ZfsVolume_s *)volume)->ZFSVOLactivationCount)); + switch (type) + { + case PLOG_BEAST_DELETE: + { + pLogBlock->logEntry[slot].info.beast.volumeID = + purgeMsg->beast.beast->vol.volume->VOLvolumeID; + zASSERT(purgeMsg->beast.beast->zid != 0); + pLogBlock->logEntry[slot].info.beast.zid = + purgeMsg->beast.beast->zid; + if (purgeMsg->beast.dirBeast != NULL) + { + zASSERT(purgeMsg->beast.dirBeast->zid != 0); + pLogBlock->logEntry[slot].info.beast.dirZid = + purgeMsg->beast.dirBeast->zid; + } + else + { + pLogBlock->logEntry[slot].info.beast.dirZid = zINVALID_ZID; + } + location = &purgeMsg->beast.beast->storage.zfsInfo->deletePurgeLogLoc; + break; + } + case PLOG_BEAST_COMP_CLEANUP: + { + pLogBlock->logEntry[slot].info.beast.volumeID = + purgeMsg->beast.beast->vol.volume->VOLvolumeID; + zASSERT(purgeMsg->beast.beast->zid != 0); + zASSERT(purgeMsg->beast.dirBeast == NULL); + pLogBlock->logEntry[slot].info.beast.zid = + purgeMsg->beast.beast->zid; pLogBlock->logEntry[slot].info.beast.dirZid = zINVALID_ZID; - location = &purgeMsg->beast.beast->storage.zfsInfo->compCleanupPurgeLogLoc; - break; - } - case PLOG_TRUNCATE: - { - pLogBlock->logEntry[slot].info.trunc.volumeID = - purgeMsg->trunc.beast->vol.volume->VOLvolumeID; - pLogBlock->logEntry[slot].info.trunc.zid = - purgeMsg->trunc.beast->zid; - pLogBlock->logEntry[slot].info.trunc.startBlock = - purgeMsg->trunc.startBlock; - pLogBlock->logEntry[slot].info.trunc.len = purgeMsg->trunc.len; - location = &purgeMsg->trunc.beast->storage.zfsInfo->purgeLogLoc; - break; - } - case PLOG_BLOCK_FREE: - { - pLogBlock->logEntry[slot].info.block.blockNumber = - purgeMsg->block.blockNumber; - location = purgeMsg->block.purgeLogLoc; - break; - } - case PLOG_FIX_VISIBILITY: - { - pLogBlock->logEntry[slot].info.visib.action = - purgeMsg->visib.action; - pLogBlock->logEntry[slot].info.visib.trusteeID = - *(purgeMsg->visib.trusteeID); - pLogBlock->logEntry[slot].info.visib.parentZID = - purgeMsg->visib.parentZID; - location = purgeMsg->visib.purgeLogLoc; - break; - } - case PLOG_SCAN_USER_NAMES: - { - pLogBlock->logEntry[slot].info.userScan.volumeID = - purgeMsg->userScan.volume->VOLvolumeID; - location = purgeMsg->userScan.purgeLogLoc; - break; - } - case PLOG_REMOVE_USER_TREE: - { - pLogBlock->logEntry[slot].info.user.volumeID = - purgeMsg->user.volume->VOLvolumeID; - location = purgeMsg->user.purgeLogLoc; - break; - } - case PLOG_CLEAR_USED_AMOUNT: - { - pLogBlock->logEntry[slot].info.userClear.volumeID = - purgeMsg->userClear.volume->VOLvolumeID; - location = purgeMsg->userClear.purgeLogLoc; - break; - } - case PLOG_REMOVE_DIR_TREE: - { - pLogBlock->logEntry[slot].info.directory.volumeID = - purgeMsg->directory.volume->VOLvolumeID; - location = purgeMsg->directory.purgeLogLoc; - break; - } - case PLOG_DIR_QUOTA_USED: - { - pLogBlock->logEntry[slot].info.dirUsed.volumeID = - purgeMsg->dirUsed.volume->VOLvolumeID; - pLogBlock->logEntry[slot].info.dirUsed.dirZid = - purgeMsg->dirUsed.dirZid; - location = purgeMsg->dirUsed.purgeLogLoc; - break; - } - case PLOG_EFL_REMOVE_EPOCH: - { - pLogBlock->logEntry[slot].info.epochRemove.volumeID = - purgeMsg->epochRemove.volume->VOLvolumeID; - pLogBlock->logEntry[slot].info.epochRemove.epoch = - *(purgeMsg->epochRemove.epoch); - location = purgeMsg->epochRemove.purgeLogLoc; - break; - } - case PLOG_EFL_RESET_TREE: - { - pLogBlock->logEntry[slot].info.resetEFL.volumeID = - purgeMsg->resetEFL.volume->VOLvolumeID; - location = purgeMsg->resetEFL.purgeLogLoc; - break; - } - } - /* log the insertion */ - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + sizeof(LogPurgeLog_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_PLOG_INSERT, xaction, logBuffer, 1, - poolBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, pLogBlock->lsn, buffer, - xaction, 0); /* block number */ - pLogBlock->lsn = logBuffer->ZXR_Lsn; + location = &purgeMsg->beast.beast->storage.zfsInfo->compCleanupPurgeLogLoc; + break; + } + case PLOG_TRUNCATE: + { + pLogBlock->logEntry[slot].info.trunc.volumeID = + purgeMsg->trunc.beast->vol.volume->VOLvolumeID; + pLogBlock->logEntry[slot].info.trunc.zid = + purgeMsg->trunc.beast->zid; + pLogBlock->logEntry[slot].info.trunc.startBlock = + purgeMsg->trunc.startBlock; + pLogBlock->logEntry[slot].info.trunc.len = purgeMsg->trunc.len; + location = &purgeMsg->trunc.beast->storage.zfsInfo->purgeLogLoc; + break; + } + case PLOG_BLOCK_FREE: + { + pLogBlock->logEntry[slot].info.block.blockNumber = + purgeMsg->block.blockNumber; + location = purgeMsg->block.purgeLogLoc; + break; + } + case PLOG_FIX_VISIBILITY: + { + pLogBlock->logEntry[slot].info.visib.action = + purgeMsg->visib.action; + pLogBlock->logEntry[slot].info.visib.trusteeID = + *(purgeMsg->visib.trusteeID); + pLogBlock->logEntry[slot].info.visib.parentZID = + purgeMsg->visib.parentZID; + location = purgeMsg->visib.purgeLogLoc; + break; + } + case PLOG_SCAN_USER_NAMES: + { + pLogBlock->logEntry[slot].info.userScan.volumeID = + purgeMsg->userScan.volume->VOLvolumeID; + location = purgeMsg->userScan.purgeLogLoc; + break; + } + case PLOG_REMOVE_USER_TREE: + { + pLogBlock->logEntry[slot].info.user.volumeID = + purgeMsg->user.volume->VOLvolumeID; + location = purgeMsg->user.purgeLogLoc; + break; + } + case PLOG_CLEAR_USED_AMOUNT: + { + pLogBlock->logEntry[slot].info.userClear.volumeID = + purgeMsg->userClear.volume->VOLvolumeID; + location = purgeMsg->userClear.purgeLogLoc; + break; + } + case PLOG_REMOVE_DIR_TREE: + { + pLogBlock->logEntry[slot].info.directory.volumeID = + purgeMsg->directory.volume->VOLvolumeID; + location = purgeMsg->directory.purgeLogLoc; + break; + } + case PLOG_DIR_QUOTA_USED: + { + pLogBlock->logEntry[slot].info.dirUsed.volumeID = + purgeMsg->dirUsed.volume->VOLvolumeID; + pLogBlock->logEntry[slot].info.dirUsed.dirZid = + purgeMsg->dirUsed.dirZid; + location = purgeMsg->dirUsed.purgeLogLoc; + break; + } + case PLOG_EFL_REMOVE_EPOCH: + { + pLogBlock->logEntry[slot].info.epochRemove.volumeID = + purgeMsg->epochRemove.volume->VOLvolumeID; + pLogBlock->logEntry[slot].info.epochRemove.epoch = + *(purgeMsg->epochRemove.epoch); + location = purgeMsg->epochRemove.purgeLogLoc; + break; + } + case PLOG_EFL_RESET_TREE: + { + pLogBlock->logEntry[slot].info.resetEFL.volumeID = + purgeMsg->resetEFL.volume->VOLvolumeID; + location = purgeMsg->resetEFL.purgeLogLoc; + break; + } + } + /* log the insertion */ + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + sizeof(LogPurgeLog_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_PLOG_INSERT, xaction, logBuffer, 1, + poolBlks, logRecord); + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, pLogBlock->lsn, buffer, + xaction, 0); /* block number */ + pLogBlock->lsn = logBuffer->ZXR_Lsn; - logRecord->slot = slot; - logRecord->entry = pLogBlock->logEntry[slot]; + logRecord->slot = slot; + logRecord->entry = pLogBlock->logEntry[slot]; - ZLOG_BIND(xaction, buffer); - ZLOG_ReleaseRecord(xaction); + ZLOG_BIND(xaction, buffer); + ZLOG_ReleaseRecord(xaction); - BUG_PURGE_REC(buffer->volBlk, slot); + BUG_PURGE_REC(buffer->volBlk, slot); - /* make sure it's empty */ - zASSERT( (location->block == 0) || (location->block == INVALID_BLK) ); - location->block = buffer->volBlk; - location->slot = slot; + /* make sure it's empty */ + zASSERT( (location->block == 0) || (location->block == INVALID_BLK) ); + location->block = buffer->volBlk; + location->slot = slot; #if NSS_DEBUG IS_ENABLED - switch (type) - { - case PLOG_BEAST_DELETE: - { - DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Beast Delete) -- inserted zid %d in %d:%d\n"), - (LONG)purgeMsg->beast.beast->zid, location->block, location->slot)); - break; - } - case PLOG_TRUNCATE: - { - DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Beast Truncate) -- inserted zid %d in %d:%d\n"), - (LONG)purgeMsg->trunc.beast->zid, location->block, location->slot)); - break; - } - case PLOG_BLOCK_FREE: - { - DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Block Free) -- inserted block %d in %d:%d\n"), - (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); - break; - } - case PLOG_BEAST_COMP_CLEANUP: - { - DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Beast Comp Cleanup) -- inserted zid %d in %d:%d\n"), - (LONG)purgeMsg->beast.beast->zid, location->block, location->slot)); - break; - } - case PLOG_FIX_VISIBILITY: - { - DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Fix Visibility) -- inserted parent zid %d in %d:%d\n"), - (LONG)purgeMsg->visib.parentZID, location->block, location->slot)); - break; - } - case PLOG_SCAN_USER_NAMES: - { - DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Scan User Names) -- inserted block %d in %d:%d\n"), - (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); - break; - } - case PLOG_REMOVE_USER_TREE: - { - DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Remove User Tree) -- inserted block %d in %d:%d\n"), - (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); - break; - } - case PLOG_CLEAR_USED_AMOUNT: - { - DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Clear User Tree) -- inserted block %d in %d:%d\n"), - (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); - break; - } - case PLOG_REMOVE_DIR_TREE: - { - DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Remove Directory Tree) -- inserted block %d in %d:%d\n"), - (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); - break; - } - case PLOG_DIR_QUOTA_USED: - { - DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Directory Tree Used Amount) -- inserted block %d in %d:%d\n"), - (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); - break; - } - case PLOG_EFL_REMOVE_EPOCH: - { - DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Remove EFL epoch) -- inserted block %d in %d:%d\n"), - (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); - break; - } - case PLOG_EFL_RESET_TREE: - { - DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Reset EFL Tree) -- inserted block %d in %d:%d\n"), - (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); - break; - } - } + switch (type) + { + case PLOG_BEAST_DELETE: + { + DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Beast Delete) -- inserted zid %d in %d:%d\n"), + (LONG)purgeMsg->beast.beast->zid, location->block, location->slot)); + break; + } + case PLOG_TRUNCATE: + { + DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Beast Truncate) -- inserted zid %d in %d:%d\n"), + (LONG)purgeMsg->trunc.beast->zid, location->block, location->slot)); + break; + } + case PLOG_BLOCK_FREE: + { + DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Block Free) -- inserted block %d in %d:%d\n"), + (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); + break; + } + case PLOG_BEAST_COMP_CLEANUP: + { + DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Beast Comp Cleanup) -- inserted zid %d in %d:%d\n"), + (LONG)purgeMsg->beast.beast->zid, location->block, location->slot)); + break; + } + case PLOG_FIX_VISIBILITY: + { + DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Fix Visibility) -- inserted parent zid %d in %d:%d\n"), + (LONG)purgeMsg->visib.parentZID, location->block, location->slot)); + break; + } + case PLOG_SCAN_USER_NAMES: + { + DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Scan User Names) -- inserted block %d in %d:%d\n"), + (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); + break; + } + case PLOG_REMOVE_USER_TREE: + { + DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Remove User Tree) -- inserted block %d in %d:%d\n"), + (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); + break; + } + case PLOG_CLEAR_USED_AMOUNT: + { + DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Clear User Tree) -- inserted block %d in %d:%d\n"), + (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); + break; + } + case PLOG_REMOVE_DIR_TREE: + { + DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Remove Directory Tree) -- inserted block %d in %d:%d\n"), + (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); + break; + } + case PLOG_DIR_QUOTA_USED: + { + DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Directory Tree Used Amount) -- inserted block %d in %d:%d\n"), + (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); + break; + } + case PLOG_EFL_REMOVE_EPOCH: + { + DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Remove EFL epoch) -- inserted block %d in %d:%d\n"), + (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); + break; + } + case PLOG_EFL_RESET_TREE: + { + DEBUG_PRINTF(TPLOG, DBG_INDENT, (LGREEN, MSGNot("PLOG (Reset EFL Tree) -- inserted block %d in %d:%d\n"), + (LONG)purgeMsg->block.blockNumber, location->block, location->slot)); + break; + } + } #endif - CACHE_DIRTY_RELEASE(buffer); - VALIDATE_PLOG(purgeLog); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ + CACHE_DIRTY_RELEASE(buffer); + VALIDATE_PLOG(purgeLog); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ //DEBUG_PRINTF(TPLOG, DBG_INDENT,(GREEN, MSGNot(" next unused = %d:%d\n"), // purgeLog->nextUnused.block, purgeLog->nextUnused.slot)); - RTN_STATUS(zOK); + RTN_STATUS(zOK); errorBufferRelease: - CACHE_RELEASE(buffer); + CACHE_RELEASE(buffer); errorExit: // zASSERT(0); - switch (type) - { - case PLOG_BEAST_DELETE: - { - location = - &purgeMsg->beast.beast->storage.zfsInfo->deletePurgeLogLoc; - break; - } - case PLOG_BEAST_COMP_CLEANUP: - { - location = - &purgeMsg->beast.beast->storage.zfsInfo->compCleanupPurgeLogLoc; - break; - } - case PLOG_TRUNCATE: - { - location = &purgeMsg->trunc.beast->storage.zfsInfo->purgeLogLoc; - break; - } - case PLOG_BLOCK_FREE: - { - location = purgeMsg->block.purgeLogLoc; - break; - } - case PLOG_FIX_VISIBILITY: - { - location = purgeMsg->visib.purgeLogLoc; - break; - } - case PLOG_SCAN_USER_NAMES: - { - location = purgeMsg->userScan.purgeLogLoc; - break; - } - case PLOG_REMOVE_USER_TREE: - { - location = purgeMsg->user.purgeLogLoc; - break; - } - case PLOG_CLEAR_USED_AMOUNT: - { - location = purgeMsg->userClear.purgeLogLoc; - break; - } - case PLOG_REMOVE_DIR_TREE: - { - location = purgeMsg->directory.purgeLogLoc; - break; - } - case PLOG_DIR_QUOTA_USED: - { - location = purgeMsg->dirUsed.purgeLogLoc; - break; - } - case PLOG_EFL_REMOVE_EPOCH: - { - location = purgeMsg->epochRemove.purgeLogLoc; - break; - } - case PLOG_EFL_RESET_TREE: - { - location = purgeMsg->resetEFL.purgeLogLoc; - break; - } - } - location->block = 0; - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ - RTN_STATUS(zFAILURE); + switch (type) + { + case PLOG_BEAST_DELETE: + { + location = + &purgeMsg->beast.beast->storage.zfsInfo->deletePurgeLogLoc; + break; + } + case PLOG_BEAST_COMP_CLEANUP: + { + location = + &purgeMsg->beast.beast->storage.zfsInfo->compCleanupPurgeLogLoc; + break; + } + case PLOG_TRUNCATE: + { + location = &purgeMsg->trunc.beast->storage.zfsInfo->purgeLogLoc; + break; + } + case PLOG_BLOCK_FREE: + { + location = purgeMsg->block.purgeLogLoc; + break; + } + case PLOG_FIX_VISIBILITY: + { + location = purgeMsg->visib.purgeLogLoc; + break; + } + case PLOG_SCAN_USER_NAMES: + { + location = purgeMsg->userScan.purgeLogLoc; + break; + } + case PLOG_REMOVE_USER_TREE: + { + location = purgeMsg->user.purgeLogLoc; + break; + } + case PLOG_CLEAR_USED_AMOUNT: + { + location = purgeMsg->userClear.purgeLogLoc; + break; + } + case PLOG_REMOVE_DIR_TREE: + { + location = purgeMsg->directory.purgeLogLoc; + break; + } + case PLOG_DIR_QUOTA_USED: + { + location = purgeMsg->dirUsed.purgeLogLoc; + break; + } + case PLOG_EFL_REMOVE_EPOCH: + { + location = purgeMsg->epochRemove.purgeLogLoc; + break; + } + case PLOG_EFL_RESET_TREE: + { + location = purgeMsg->resetEFL.purgeLogLoc; + break; + } + } + location->block = 0; + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ + RTN_STATUS(zFAILURE); } /**************************************************************************** @@ -2077,362 +2077,362 @@ errorExit: * ****************************************************************************/ STATUS ZFSVOL_VOL_RemovePurgeLogEntry ( - GeneralMsg_s *genMsg, - Volume_s *volume, - NINT type, /* input: the type of entry being removed */ - PurgeLogMsg_s *purgeMsg, /* input: the information to find the log entry */ - Xaction_s *xAction) + GeneralMsg_s *genMsg, + Volume_s *volume, + NINT type, /* input: the type of entry being removed */ + PurgeLogMsg_s *purgeMsg, /* input: the information to find the log entry */ + Xaction_s *xAction) { - NINT slot; - Buffer_s *buffer; - IoMsg_s iomsg; - ZfsXasRecovery_s *logBuffer; - BlockInfo_s *poolBlks; - LogPurgeLog_s *logRecord; - PurgeLogBlock_s *pLogBlock; - ZfsPurgeLogBeast_s *purgeLog; - ZfsXaction_s *xaction; - ZfsPurgeLogLoc_s *location; + NINT slot; + Buffer_s *buffer; + IoMsg_s iomsg; + ZfsXasRecovery_s *logBuffer; + BlockInfo_s *poolBlks; + LogPurgeLog_s *logRecord; + PurgeLogBlock_s *pLogBlock; + ZfsPurgeLogBeast_s *purgeLog; + ZfsXaction_s *xaction; + ZfsPurgeLogLoc_s *location; #if LOG_TEST IS_ENABLED - Lsn_t holdLsn; + Lsn_t holdLsn; #endif - FreePurgeLogEntries_s *pLogEntry; + FreePurgeLogEntries_s *pLogEntry; - ENTER(TPLOG, ZFSVOL_RemovePurgeLogEntry); - zASSERT(!(volume->VOLenabledAttributes & zATTR_READONLY)); + ENTER(TPLOG, ZFSVOL_RemovePurgeLogEntry); + zASSERT(!(volume->VOLenabledAttributes & zATTR_READONLY)); - switch (type) - { - /* These are the purge log records that are handled by - * the VOLUME Purge Log. - */ - case PLOG_BEAST_COMP_CLEANUP: - case PLOG_BEAST_DELETE: - case PLOG_TRUNCATE: - case PLOG_BLOCK_FREE: - case PLOG_FIX_VISIBILITY: - case PLOG_SCAN_USER_NAMES: - case PLOG_REMOVE_USER_TREE: - case PLOG_CLEAR_USED_AMOUNT: - case PLOG_REMOVE_DIR_TREE: - case PLOG_DIR_QUOTA_USED: - case PLOG_EFL_REMOVE_EPOCH: - case PLOG_EFL_RESET_TREE: - { - purgeLog = ((ZfsVolume_s *)volume)->ZFSVOLvolumePurgeLog; - DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, - MSGNot("*** *** Remove Purge Log (VOLUME) operation %d ***\n"), - type)); - zASSERT( purgeLog != NULL ); - if ( purgeLog == NULL ) - { /** - * This code is here just in case someone calls this - * routine during LV AIPU before the volume purge logs - * are created. - */ - purgeLog = ((ZfsVolume_s *)volume)->pool->ZFSPOOLpurgeLogBeast; - zASSERT( purgeLog != NULL ); - if ( purgeLog == NULL ) - { - SetErrno( genMsg, zERR_MISSING_BEAST ); - return( zFAILURE ); - } - } - break; - } - /* These are the purge log records that are handled by - * the POOL Purge Log. - */ + switch (type) + { + /* These are the purge log records that are handled by + * the VOLUME Purge Log. + */ + case PLOG_BEAST_COMP_CLEANUP: + case PLOG_BEAST_DELETE: + case PLOG_TRUNCATE: + case PLOG_BLOCK_FREE: + case PLOG_FIX_VISIBILITY: + case PLOG_SCAN_USER_NAMES: + case PLOG_REMOVE_USER_TREE: + case PLOG_CLEAR_USED_AMOUNT: + case PLOG_REMOVE_DIR_TREE: + case PLOG_DIR_QUOTA_USED: + case PLOG_EFL_REMOVE_EPOCH: + case PLOG_EFL_RESET_TREE: + { + purgeLog = ((ZfsVolume_s *)volume)->ZFSVOLvolumePurgeLog; + DEBUG_PRINTF(TPLOG,DBG_NOINDENT,(CYAN, + MSGNot("*** *** Remove Purge Log (VOLUME) operation %d ***\n"), + type)); + zASSERT( purgeLog != NULL ); + if ( purgeLog == NULL ) + { /** + * This code is here just in case someone calls this + * routine during LV AIPU before the volume purge logs + * are created. + */ + purgeLog = ((ZfsVolume_s *)volume)->pool->ZFSPOOLpurgeLogBeast; + zASSERT( purgeLog != NULL ); + if ( purgeLog == NULL ) + { + SetErrno( genMsg, zERR_MISSING_BEAST ); + return( zFAILURE ); + } + } + break; + } + /* These are the purge log records that are handled by + * the POOL Purge Log. + */ #if 0 - case PLOG_BLOCK_FREE: - { - purgeLog = ((ZfsVolume_s *)volume)->pool->ZFSPOOLpurgeLogBeast; + case PLOG_BLOCK_FREE: + { + purgeLog = ((ZfsVolume_s *)volume)->pool->ZFSPOOLpurgeLogBeast; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( CYAN, "*** *** Remove Purge Log (POOL) operation %d *****\n",type); + DBG_DebugPrintf( CYAN, "*** *** Remove Purge Log (POOL) operation %d *****\n",type); #endif - zASSERT( purgeLog != NULL ); - break; - } + zASSERT( purgeLog != NULL ); + break; + } #endif - default: - { - zASSERT("Bad purge log record type" == 0); - SetErrno( genMsg, zERR_NOT_SUPPORTED ); - return( zFAILURE ); - } + default: + { + zASSERT("Bad purge log record type" == 0); + SetErrno( genMsg, zERR_NOT_SUPPORTED ); + return( zFAILURE ); + } + } + + xaction = (ZfsXaction_s *)xAction; + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* Latch the log */ + VALIDATE_PLOG(purgeLog); + + /* get the location of the purge log record to be deleted */ + switch (type) + { + case PLOG_BEAST_DELETE: + { + location = &purgeMsg->beast.beast->storage.zfsInfo->deletePurgeLogLoc; + PLOG_VALIDATE_BLOCK(purgeLog, location->block); + break; + } + case PLOG_BEAST_COMP_CLEANUP: + { + location = &purgeMsg->beast.beast->storage.zfsInfo->compCleanupPurgeLogLoc; + PLOG_VALIDATE_BLOCK(purgeLog, location->block); + break; + } + case PLOG_FIX_VISIBILITY: + { + location = purgeMsg->visib.purgeLogLoc; + PLOG_VALIDATE_BLOCK(purgeLog, location->block); + break; + } + case PLOG_TRUNCATE: + { + location = &purgeMsg->trunc.beast->storage.zfsInfo->purgeLogLoc; + break; + } + case PLOG_BLOCK_FREE: + { + location = purgeMsg->block.purgeLogLoc; + break; + } + case PLOG_SCAN_USER_NAMES: + { + location = purgeMsg->userScan.purgeLogLoc; + PLOG_VALIDATE_BLOCK(purgeLog, location->block); + break; + } + case PLOG_REMOVE_USER_TREE: + { + location = purgeMsg->user.purgeLogLoc; + PLOG_VALIDATE_BLOCK(purgeLog, location->block); + break; + } + case PLOG_CLEAR_USED_AMOUNT: + { + location = purgeMsg->userClear.purgeLogLoc; + PLOG_VALIDATE_BLOCK(purgeLog, location->block); + break; + } + case PLOG_REMOVE_DIR_TREE: + { + location = purgeMsg->directory.purgeLogLoc; + PLOG_VALIDATE_BLOCK(purgeLog, location->block); + break; + } + case PLOG_DIR_QUOTA_USED: + { + location = purgeMsg->dirUsed.purgeLogLoc; + PLOG_VALIDATE_BLOCK(purgeLog, location->block); + break; + } + case PLOG_EFL_REMOVE_EPOCH: + { + location = purgeMsg->epochRemove.purgeLogLoc; + PLOG_VALIDATE_BLOCK(purgeLog, location->block); + break; + } + case PLOG_EFL_RESET_TREE: + { + location = purgeMsg->resetEFL.purgeLogLoc; + PLOG_VALIDATE_BLOCK(purgeLog, location->block); + break; + } + default: + { + zASSERT("Bad purge log record type in delete" == 0); + SetErrno( genMsg, zERR_BAD_PARAMETER_VALUE ); + goto errorExitNoLocation; + } + } + + if (location->block == 0) + { + SetErrno( genMsg, zERR_INVALID_STATE ); + goto errorExit; } - xaction = (ZfsXaction_s *)xAction; - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* Latch the log */ - VALIDATE_PLOG(purgeLog); - - /* get the location of the purge log record to be deleted */ - switch (type) + READBLK_IO_MSG(iomsg, purgeLog, location->block, CACHE_UPDATE); + SET_DEBUG_ID(iomsg, 14); + buffer = PLOG_ReadPoolBlk(genMsg, &iomsg); + if (buffer == NULL) { - case PLOG_BEAST_DELETE: - { - location = &purgeMsg->beast.beast->storage.zfsInfo->deletePurgeLogLoc; - PLOG_VALIDATE_BLOCK(purgeLog, location->block); - break; - } - case PLOG_BEAST_COMP_CLEANUP: - { - location = &purgeMsg->beast.beast->storage.zfsInfo->compCleanupPurgeLogLoc; - PLOG_VALIDATE_BLOCK(purgeLog, location->block); - break; - } - case PLOG_FIX_VISIBILITY: - { - location = purgeMsg->visib.purgeLogLoc; - PLOG_VALIDATE_BLOCK(purgeLog, location->block); - break; - } - case PLOG_TRUNCATE: - { - location = &purgeMsg->trunc.beast->storage.zfsInfo->purgeLogLoc; - break; - } - case PLOG_BLOCK_FREE: - { - location = purgeMsg->block.purgeLogLoc; - break; - } - case PLOG_SCAN_USER_NAMES: - { - location = purgeMsg->userScan.purgeLogLoc; - PLOG_VALIDATE_BLOCK(purgeLog, location->block); - break; - } - case PLOG_REMOVE_USER_TREE: - { - location = purgeMsg->user.purgeLogLoc; - PLOG_VALIDATE_BLOCK(purgeLog, location->block); - break; - } - case PLOG_CLEAR_USED_AMOUNT: - { - location = purgeMsg->userClear.purgeLogLoc; - PLOG_VALIDATE_BLOCK(purgeLog, location->block); - break; - } - case PLOG_REMOVE_DIR_TREE: - { - location = purgeMsg->directory.purgeLogLoc; - PLOG_VALIDATE_BLOCK(purgeLog, location->block); - break; - } - case PLOG_DIR_QUOTA_USED: - { - location = purgeMsg->dirUsed.purgeLogLoc; - PLOG_VALIDATE_BLOCK(purgeLog, location->block); - break; - } - case PLOG_EFL_REMOVE_EPOCH: - { - location = purgeMsg->epochRemove.purgeLogLoc; - PLOG_VALIDATE_BLOCK(purgeLog, location->block); - break; - } - case PLOG_EFL_RESET_TREE: - { - location = purgeMsg->resetEFL.purgeLogLoc; - PLOG_VALIDATE_BLOCK(purgeLog, location->block); - break; - } - default: - { - zASSERT("Bad purge log record type in delete" == 0); - SetErrno( genMsg, zERR_BAD_PARAMETER_VALUE ); - goto errorExitNoLocation; - } + goto errorExit; } - - if (location->block == 0) - { - SetErrno( genMsg, zERR_INVALID_STATE ); - goto errorExit; - } - - READBLK_IO_MSG(iomsg, purgeLog, location->block, CACHE_UPDATE); - SET_DEBUG_ID(iomsg, 14); - buffer = PLOG_ReadPoolBlk(genMsg, &iomsg); - if (buffer == NULL) - { - goto errorExit; - } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); - if ( pLogBlock->magic != PURGE_LOG_MAGIC ) - { - CACHE_RELEASE(buffer); - SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); - goto errorExit; - } - slot = location->slot; + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); + if ( pLogBlock->magic != PURGE_LOG_MAGIC ) + { + CACHE_RELEASE(buffer); + SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); + goto errorExit; + } + slot = location->slot; #if NSS_DEBUG IS_ENABLED - switch (type) - { - case PLOG_BEAST_DELETE: - { - zASSERT(purgeMsg->beast.beast->zid == pLogBlock->logEntry[slot].info.beast.zid); - break; - } - case PLOG_BEAST_COMP_CLEANUP: - { - zASSERT(purgeMsg->beast.beast->zid == pLogBlock->logEntry[slot].info.beast.zid); - break; - } - case PLOG_TRUNCATE: - { - zASSERT(purgeMsg->trunc.beast->zid == pLogBlock->logEntry[slot].info.trunc.zid); - break; - } - case PLOG_FIX_VISIBILITY: - { - zASSERT(purgeMsg->visib.parentZID == pLogBlock->logEntry[slot].info.visib.parentZID); - break; - } - case PLOG_BLOCK_FREE: - { - break; - } - case PLOG_SCAN_USER_NAMES: - { - break; - } - case PLOG_REMOVE_USER_TREE: - { - break; - } - case PLOG_CLEAR_USED_AMOUNT: - { - break; - } - case PLOG_REMOVE_DIR_TREE: - { - break; - } - case PLOG_DIR_QUOTA_USED: - { - break; - } - case PLOG_EFL_REMOVE_EPOCH: - { - break; - } - case PLOG_EFL_RESET_TREE: - { - break; - } - default: - { - zASSERT("Bad purge log record type in delete check" == 0); - } - } + switch (type) + { + case PLOG_BEAST_DELETE: + { + zASSERT(purgeMsg->beast.beast->zid == pLogBlock->logEntry[slot].info.beast.zid); + break; + } + case PLOG_BEAST_COMP_CLEANUP: + { + zASSERT(purgeMsg->beast.beast->zid == pLogBlock->logEntry[slot].info.beast.zid); + break; + } + case PLOG_TRUNCATE: + { + zASSERT(purgeMsg->trunc.beast->zid == pLogBlock->logEntry[slot].info.trunc.zid); + break; + } + case PLOG_FIX_VISIBILITY: + { + zASSERT(purgeMsg->visib.parentZID == pLogBlock->logEntry[slot].info.visib.parentZID); + break; + } + case PLOG_BLOCK_FREE: + { + break; + } + case PLOG_SCAN_USER_NAMES: + { + break; + } + case PLOG_REMOVE_USER_TREE: + { + break; + } + case PLOG_CLEAR_USED_AMOUNT: + { + break; + } + case PLOG_REMOVE_DIR_TREE: + { + break; + } + case PLOG_DIR_QUOTA_USED: + { + break; + } + case PLOG_EFL_REMOVE_EPOCH: + { + break; + } + case PLOG_EFL_RESET_TREE: + { + break; + } + default: + { + zASSERT("Bad purge log record type in delete check" == 0); + } + } // zASSERT(beast->zid == pLogBlock->logEntry[slot].u.entry.zid); #endif - /* log the deletion */ - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + sizeof(LogPurgeLog_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_PLOG_DELETE, xaction, logBuffer, 1, - poolBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, pLogBlock->lsn, buffer, - xaction, 0); /* old block number */ + /* log the deletion */ + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + sizeof(LogPurgeLog_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_PLOG_DELETE, xaction, logBuffer, 1, + poolBlks, logRecord); + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, pLogBlock->lsn, buffer, + xaction, 0); /* old block number */ #if LOG_TEST IS_ENABLED - holdLsn = logBuffer->ZXR_Lsn; /* this is done so the lsn is ok for testing */ + holdLsn = logBuffer->ZXR_Lsn; /* this is done so the lsn is ok for testing */ #else - pLogBlock->lsn = logBuffer->ZXR_Lsn; + pLogBlock->lsn = logBuffer->ZXR_Lsn; #endif - logRecord->slot = slot; - logRecord->entry = pLogBlock->logEntry[slot]; + logRecord->slot = slot; + logRecord->entry = pLogBlock->logEntry[slot]; - ZLOG_BIND(xaction, buffer); - ZLOG_TEST_REDO(xaction); - ZLOG_ReleaseRecord(xaction); + ZLOG_BIND(xaction, buffer); + ZLOG_TEST_REDO(xaction); + ZLOG_ReleaseRecord(xaction); #if LOG_TEST IS_ENABLED - pLogBlock->lsn = holdLsn; + pLogBlock->lsn = holdLsn; #endif + + /* fill in the purged record and put it on the avail list*/ + pLogBlock->logEntry[slot].type = PLOG_UNUSED; - /* fill in the purged record and put it on the avail list*/ - pLogBlock->logEntry[slot].type = PLOG_UNUSED; + pLogEntry = objCacheAlloc(&PLogFreeEntry); - pLogEntry = objCacheAlloc(&PLogFreeEntry); - - COMN_USE_BEAST(&purgeLog->ZFSPURGELOGroot); - pLogEntry->purgeLog = purgeLog; - pLogEntry->location.block = location->block; - pLogEntry->location.slot = location->slot; - DQ_ENQ(&xaction->freePurgeLogEntries, pLogEntry, xactionLink); + COMN_USE_BEAST(&purgeLog->ZFSPURGELOGroot); + pLogEntry->purgeLog = purgeLog; + pLogEntry->location.block = location->block; + pLogEntry->location.slot = location->slot; + DQ_ENQ(&xaction->freePurgeLogEntries, pLogEntry, xactionLink); DEBUG_PRINTF(TPLOG, DBG_INDENT, (GREEN, MSGNot("PLOG -- removed entry from %d:%d\n"), - location->block, location->slot)); - location->block = 0; /* indicate this field is no longer in use */ + location->block, location->slot)); + location->block = 0; /* indicate this field is no longer in use */ - CACHE_DIRTY_RELEASE(buffer); - VALIDATE_PLOG(purgeLog); - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ - RTN_STATUS(zOK); + CACHE_DIRTY_RELEASE(buffer); + VALIDATE_PLOG(purgeLog); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ + RTN_STATUS(zOK); errorExit: #if NSS_DEBUG IS_ENABLED - location->block = INVALID_BLK; + location->block = INVALID_BLK; #endif errorExitNoLocation: - UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ - RTN_STATUS(zFAILURE); + UNX_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* unlatch the log */ + RTN_STATUS(zFAILURE); } void PLOG_PutEntryOnFreeList( - FreePurgeLogEntries_s *pLogEntry) + FreePurgeLogEntries_s *pLogEntry) { - ZfsPurgeLogBeast_s *purgeLog = pLogEntry->purgeLog; - NINT slot = pLogEntry->location.slot; - Blknum_t block = pLogEntry->location.block; - Buffer_s *buffer; - IoMsg_s iomsg; - PurgeLogBlock_s *pLogBlock; - GeneralMsg_s genMsg; + ZfsPurgeLogBeast_s *purgeLog = pLogEntry->purgeLog; + NINT slot = pLogEntry->location.slot; + Blknum_t block = pLogEntry->location.block; + Buffer_s *buffer; + IoMsg_s iomsg; + PurgeLogBlock_s *pLogBlock; + GeneralMsg_s genMsg; - COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); - X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* latch the log */ + X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* latch the log */ - READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_UPDATE); - SET_DEBUG_ID(iomsg, 14); - buffer = PLOG_ReadPoolBlk(&genMsg, &iomsg); - if (buffer == NULL) + READBLK_IO_MSG(iomsg, purgeLog, block, CACHE_UPDATE); + SET_DEBUG_ID(iomsg, 14); + buffer = PLOG_ReadPoolBlk(&genMsg, &iomsg); + if (buffer == NULL) { - goto cleanupAndReturn; - } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); - if ( pLogBlock->magic != PURGE_LOG_MAGIC ) - { - CACHE_RELEASE(buffer); - goto cleanupAndReturn; + goto cleanupAndReturn; } + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + zASSERT( pLogBlock->magic == PURGE_LOG_MAGIC ); + if ( pLogBlock->magic != PURGE_LOG_MAGIC ) + { + CACHE_RELEASE(buffer); + goto cleanupAndReturn; + } - ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->block = - purgeLog->freeList.block; - ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->slot = - purgeLog->freeList.slot; - purgeLog->freeList.block = block; - purgeLog->freeList.slot = slot; + ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->block = + purgeLog->freeList.block; + ((ZfsPurgeLogLoc_s *)&pLogBlock->logEntry[slot].info.free.link)->slot = + purgeLog->freeList.slot; + purgeLog->freeList.block = block; + purgeLog->freeList.slot = slot; - CACHE_DIRTY_RELEASE(buffer); + CACHE_DIRTY_RELEASE(buffer); cleanupAndReturn: - /* An extra use count was put on the purgelog beast when this entry was - * linked on the xaction. - */ - objCacheFree(pLogEntry); - COMN_UnlatchAndRelease(&purgeLog, XLATCHED); - return; + /* An extra use count was put on the purgelog beast when this entry was + * linked on the xaction. + */ + objCacheFree(pLogEntry); + COMN_UnlatchAndRelease(&purgeLog, XLATCHED); + return; } @@ -2509,272 +2509,272 @@ cleanupAndReturn: * Recovery routine for growing the purge log ****************************************************************************/ STATUS recoveryPurgeLogGrow( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - ZfsXasRecovery_s *logBuffer, - NINT action) + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + ZfsXasRecovery_s *logBuffer, + NINT action) { - Buffer_s *buffer; - PurgeLogBlock_s *pLogBlock; - IoMsg_s iomsg; - BlockInfo_s *poolBlks; - LogPurgeLogGrow_s *logRecord; + Buffer_s *buffer; + PurgeLogBlock_s *pLogBlock; + IoMsg_s iomsg; + BlockInfo_s *poolBlks; + LogPurgeLogGrow_s *logRecord; - poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); - logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); + poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); + logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - /* restore the previous end record of the log */ - if (ZLOG_VALID_BLOCK(poolBlks[0])) - { - READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_UPDATE) - SET_DEBUG_ID(iomsg, 0); - if ((buffer = PLOG_ReadPoolBlk(genMsg, &iomsg)) == NULL) - { - zASSERT(0); - return zFAILURE; - } + /* restore the previous end record of the log */ + if (ZLOG_VALID_BLOCK(poolBlks[0])) + { + READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_UPDATE) + SET_DEBUG_ID(iomsg, 0); + if ((buffer = PLOG_ReadPoolBlk(genMsg, &iomsg)) == NULL) + { + zASSERT(0); + return zFAILURE; + } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - if (ZLOG_ALREADY_DONE(pool, logBuffer, pLogBlock->lsn, action)) - { - CACHE_RELEASE(buffer); - } - else - { - pLogBlock->nextBlock = poolBlks[1].blkNum; /* link the new block to the old one */ - BUG_PURGE_BLOCK(poolBlks[1].blkNum); - ZLOG_SET_LSN(logBuffer, pLogBlock->lsn, poolBlks[0], action); - CACHE_DIRTY_RELEASE(buffer); - } - } + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + if (ZLOG_ALREADY_DONE(pool, logBuffer, pLogBlock->lsn, action)) + { + CACHE_RELEASE(buffer); + } + else + { + pLogBlock->nextBlock = poolBlks[1].blkNum; /* link the new block to the old one */ + BUG_PURGE_BLOCK(poolBlks[1].blkNum); + ZLOG_SET_LSN(logBuffer, pLogBlock->lsn, poolBlks[0], action); + CACHE_DIRTY_RELEASE(buffer); + } + } - /* restore the new end record of the log */ - if (ZLOG_VALID_BLOCK(poolBlks[1])) - { - READBLK_IO_MSG(iomsg, pool, poolBlks[1].blkNum, CACHE_WRITE) - SET_DEBUG_ID(iomsg, 0); - if ((buffer = PLOG_ReadPoolBlk(genMsg, &iomsg)) == NULL) - { - zASSERT(0); - return zFAILURE; - } + /* restore the new end record of the log */ + if (ZLOG_VALID_BLOCK(poolBlks[1])) + { + READBLK_IO_MSG(iomsg, pool, poolBlks[1].blkNum, CACHE_WRITE) + SET_DEBUG_ID(iomsg, 0); + if ((buffer = PLOG_ReadPoolBlk(genMsg, &iomsg)) == NULL) + { + zASSERT(0); + return zFAILURE; + } - zASSERT( LB_GUIDValidate( &logRecord->lplg_internalID ) ); - ZFSVOL_InitPurgeLogBlock(buffer, &logRecord->lplg_internalID); - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + zASSERT( LB_GUIDValidate( &logRecord->lplg_internalID ) ); + ZFSVOL_InitPurgeLogBlock(buffer, &logRecord->lplg_internalID); + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - ZLOG_SET_LSN(logBuffer, pLogBlock->lsn, poolBlks[1], action); - CACHE_DIRTY_RELEASE(buffer); - } - return zOK; + ZLOG_SET_LSN(logBuffer, pLogBlock->lsn, poolBlks[1], action); + CACHE_DIRTY_RELEASE(buffer); + } + return zOK; } /**************************************************************************** * Recovery routine for shrinking the purge log (undo for grow) ****************************************************************************/ STATUS recoveryPurgeLogShrink( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - ZfsXasRecovery_s *logBuffer, - NINT action) + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + ZfsXasRecovery_s *logBuffer, + NINT action) { - Buffer_s *buffer; - PurgeLogBlock_s *pLogBlock; - IoMsg_s iomsg; - BlockInfo_s *poolBlks; + Buffer_s *buffer; + PurgeLogBlock_s *pLogBlock; + IoMsg_s iomsg; + BlockInfo_s *poolBlks; - poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); + poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); - /* restore the previous end record of the log */ - if (ZLOG_VALID_BLOCK(poolBlks[0])) - { - READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_UPDATE) - SET_DEBUG_ID(iomsg, 0); - if ((buffer = PLOG_ReadPoolBlk(genMsg, &iomsg)) == NULL) - { - zASSERT(0); - return zFAILURE; - } + /* restore the previous end record of the log */ + if (ZLOG_VALID_BLOCK(poolBlks[0])) + { + READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_UPDATE) + SET_DEBUG_ID(iomsg, 0); + if ((buffer = PLOG_ReadPoolBlk(genMsg, &iomsg)) == NULL) + { + zASSERT(0); + return zFAILURE; + } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - if (ZLOG_ALREADY_DONE(pool, logBuffer, pLogBlock->lsn, action)) - { - CACHE_RELEASE(buffer); - } - else - { - pLogBlock->nextBlock = 0; /* mark as the end of the list */ - ZLOG_SET_LSN(logBuffer, pLogBlock->lsn, poolBlks[0], action); - CACHE_DIRTY_RELEASE(buffer); - } - } + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + if (ZLOG_ALREADY_DONE(pool, logBuffer, pLogBlock->lsn, action)) + { + CACHE_RELEASE(buffer); + } + else + { + pLogBlock->nextBlock = 0; /* mark as the end of the list */ + ZLOG_SET_LSN(logBuffer, pLogBlock->lsn, poolBlks[0], action); + CACHE_DIRTY_RELEASE(buffer); + } + } - if (ZLOG_VALID_BLOCK(poolBlks[1])) - { - /* make sure the cache block for the deleted block is gone */ - READBLK_IO_MSG(iomsg, pool, poolBlks[1].blkNum, CACHE_WRITE) - SET_DEBUG_ID(iomsg, 0); - if ((buffer = PLOG_ReadPoolBlk(genMsg, &iomsg)) != NULL) - { - cacheReleaseToss(buffer); - } - } - return zOK; + if (ZLOG_VALID_BLOCK(poolBlks[1])) + { + /* make sure the cache block for the deleted block is gone */ + READBLK_IO_MSG(iomsg, pool, poolBlks[1].blkNum, CACHE_WRITE) + SET_DEBUG_ID(iomsg, 0); + if ((buffer = PLOG_ReadPoolBlk(genMsg, &iomsg)) != NULL) + { + cacheReleaseToss(buffer); + } + } + return zOK; } /**************************************************************************** * Recovery routine for inserting into the purge log (undo for remove) ****************************************************************************/ STATUS recoveryPurgeLogInsert( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - ZfsXasRecovery_s *logBuffer, - NINT action) + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + ZfsXasRecovery_s *logBuffer, + NINT action) { - Buffer_s *buffer; - PurgeLogBlock_s *pLogBlock; - IoMsg_s iomsg; - BlockInfo_s *poolBlks; - LogPurgeLog_s *logRecord; + Buffer_s *buffer; + PurgeLogBlock_s *pLogBlock; + IoMsg_s iomsg; + BlockInfo_s *poolBlks; + LogPurgeLog_s *logRecord; // NINT slot; - poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); + poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); - if (ZLOG_VALID_BLOCK(poolBlks[0])) - { - READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_UPDATE) - SET_DEBUG_ID(iomsg, 0); - if ((buffer = PLOG_ReadPoolBlk(genMsg, &iomsg)) == NULL) - { - zASSERT(0); - return zFAILURE; - } + if (ZLOG_VALID_BLOCK(poolBlks[0])) + { + READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_UPDATE) + SET_DEBUG_ID(iomsg, 0); + if ((buffer = PLOG_ReadPoolBlk(genMsg, &iomsg)) == NULL) + { + zASSERT(0); + return zFAILURE; + } //DBG_DebugPrintf(RED, MSGNot("REDO - Purge Log Insert. block:%d\n"),poolBlks[0].blkNum); - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - if (ZLOG_ALREADY_DONE(pool, logBuffer, pLogBlock->lsn, action)) - { + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + if (ZLOG_ALREADY_DONE(pool, logBuffer, pLogBlock->lsn, action)) + { //DBG_DebugPrintf(LRED, MSGNot(" Already done.\n")); - CACHE_RELEASE(buffer); - } - else - { - logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - if (pLogBlock->logEntry[logRecord->slot].type == PLOG_UNUSED) - { /* if the original entry is open then use it */ + CACHE_RELEASE(buffer); + } + else + { + logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); + if (pLogBlock->logEntry[logRecord->slot].type == PLOG_UNUSED) + { /* if the original entry is open then use it */ //DBG_DebugPrintf(LRED, MSGNot(" Inserting in the same slot:%d type=%d\n"), // logRecord->slot, logRecord->entry.type); - pLogBlock->logEntry[logRecord->slot] = logRecord->entry; - } - else - { /* find an open entry */ - zASSERT("PurgeLog Recovery - Bad slot" == NULL); /* This should no longer happen */ + pLogBlock->logEntry[logRecord->slot] = logRecord->entry; + } + else + { /* find an open entry */ + zASSERT("PurgeLog Recovery - Bad slot" == NULL); /* This should no longer happen */ #if 1 - /* Dec 2002 - Vandana wanted to return an error - * verses just using the slot. Greg wanted to - * just use the slot, but he owned Vandana a - * favor. This code can be tested with the ZSB - * files from incident 2835342 (you must also - * apply the new.zsb so that all of the journal is - * played. Greg has all related information on a CD. - */ - CACHE_RELEASE(buffer); - SetErrno( genMsg, zERR_RECOVERY_SLOT_IN_USE ); - return( zFAILURE ); + /* Dec 2002 - Vandana wanted to return an error + * verses just using the slot. Greg wanted to + * just use the slot, but he owned Vandana a + * favor. This code can be tested with the ZSB + * files from incident 2835342 (you must also + * apply the new.zsb so that all of the journal is + * played. Greg has all related information on a CD. + */ + CACHE_RELEASE(buffer); + SetErrno( genMsg, zERR_RECOVERY_SLOT_IN_USE ); + return( zFAILURE ); // pLogBlock->logEntry[logRecord->slot] = logRecord->entry; #else - for (slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) - { /* process each entry in the block */ - if (pLogBlock->logEntry[slot].type == PLOG_UNUSED) - { /* if it is an open entry */ + for (slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) + { /* process each entry in the block */ + if (pLogBlock->logEntry[slot].type == PLOG_UNUSED) + { /* if it is an open entry */ //DBG_DebugPrintf(LRED, MSGNot(" Inserting in a new slot:%d type=%d\n"), slot, // logRecord->entry.type); - pLogBlock->logEntry[slot] = - logRecord->entry; - break; - } - } - zASSERT(slot < MAX_PURGE_LOG_ENTRIES); /* we better find an entry */ + pLogBlock->logEntry[slot] = + logRecord->entry; + break; + } + } + zASSERT(slot < MAX_PURGE_LOG_ENTRIES); /* we better find an entry */ #endif - } - ZLOG_SET_LSN(logBuffer, pLogBlock->lsn, poolBlks[0], action); - CACHE_DIRTY_RELEASE(buffer); - } - } + } + ZLOG_SET_LSN(logBuffer, pLogBlock->lsn, poolBlks[0], action); + CACHE_DIRTY_RELEASE(buffer); + } + } //DBG_DebugPrintf(RED, MSGNot("End purge log insert redo\n")); - return zOK; + return zOK; } /**************************************************************************** * Recovery routine for deleting from the purge log (undo for insert) ****************************************************************************/ STATUS recoveryPurgeLogRemove( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - ZfsXasRecovery_s *logBuffer, - NINT action) + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + ZfsXasRecovery_s *logBuffer, + NINT action) { - Buffer_s *buffer; - PurgeLogBlock_s *pLogBlock; - IoMsg_s iomsg; - BlockInfo_s *poolBlks; - LogPurgeLog_s *logRecord; + Buffer_s *buffer; + PurgeLogBlock_s *pLogBlock; + IoMsg_s iomsg; + BlockInfo_s *poolBlks; + LogPurgeLog_s *logRecord; // NINT slot; - poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); + poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); - if (ZLOG_VALID_BLOCK(poolBlks[0])) - { - READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_UPDATE) - SET_DEBUG_ID(iomsg, 0); - if ((buffer = PLOG_ReadPoolBlk(genMsg, &iomsg)) == NULL) - { - zASSERT(0); - return zFAILURE; - } + if (ZLOG_VALID_BLOCK(poolBlks[0])) + { + READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_UPDATE) + SET_DEBUG_ID(iomsg, 0); + if ((buffer = PLOG_ReadPoolBlk(genMsg, &iomsg)) == NULL) + { + zASSERT(0); + return zFAILURE; + } - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - if (ZLOG_ALREADY_DONE(pool, logBuffer, pLogBlock->lsn, action)) - { + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + if (ZLOG_ALREADY_DONE(pool, logBuffer, pLogBlock->lsn, action)) + { //DBG_DebugPrintf(RED, MSGNot(" Already done.\n")); - CACHE_RELEASE(buffer); - } - else - { - logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - if (memcmp(&logRecord->entry, &pLogBlock->logEntry[logRecord->slot], - sizeof(PurgeLogEntry_s)) == 0) - { /* if the slot is still the correct record then delete it */ + CACHE_RELEASE(buffer); + } + else + { + logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); + if (memcmp(&logRecord->entry, &pLogBlock->logEntry[logRecord->slot], + sizeof(PurgeLogEntry_s)) == 0) + { /* if the slot is still the correct record then delete it */ //DBG_DebugPrintf(RED, MSGNot(" Removing from the same slot:%d\n"),logRecord->slot); - pLogBlock->logEntry[logRecord->slot].type = PLOG_UNUSED; - } - else - { /* find the entry to be deleted */ - zASSERT("PurgeLog Recovery - Bad slot" == NULL); /* This should no longer happen */ + pLogBlock->logEntry[logRecord->slot].type = PLOG_UNUSED; + } + else + { /* find the entry to be deleted */ + zASSERT("PurgeLog Recovery - Bad slot" == NULL); /* This should no longer happen */ #if 1 - CACHE_RELEASE(buffer); - SetErrno( genMsg, zERR_RECOVERY_SLOT_MISMATCH ); - return( zFAILURE ); + CACHE_RELEASE(buffer); + SetErrno( genMsg, zERR_RECOVERY_SLOT_MISMATCH ); + return( zFAILURE ); // pLogBlock->logEntry[logRecord->slot].type = PLOG_UNUSED; #else - for (slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) - { /* process each entry in the block */ - if (memcmp(&logRecord->entry, &pLogBlock->logEntry[slot], - sizeof(PurgeLogInfo_s)) == 0) - { /* if the slot is the correct record then delete it */ + for (slot = 0; slot < MAX_PURGE_LOG_ENTRIES; slot++) + { /* process each entry in the block */ + if (memcmp(&logRecord->entry, &pLogBlock->logEntry[slot], + sizeof(PurgeLogInfo_s)) == 0) + { /* if the slot is the correct record then delete it */ //DBG_DebugPrintf(RED, MSGNot(" Removing from a new slot:%d\n"),slot); - pLogBlock->logEntry[slot].type = PLOG_UNUSED; - break; - } - } - zASSERT(slot < MAX_PURGE_LOG_ENTRIES); /* we better find an entry */ + pLogBlock->logEntry[slot].type = PLOG_UNUSED; + break; + } + } + zASSERT(slot < MAX_PURGE_LOG_ENTRIES); /* we better find an entry */ #endif - } - ZLOG_SET_LSN(logBuffer, pLogBlock->lsn, poolBlks[0], action); - CACHE_DIRTY_RELEASE(buffer); - } - } - return zOK; + } + ZLOG_SET_LSN(logBuffer, pLogBlock->lsn, poolBlks[0], action); + CACHE_DIRTY_RELEASE(buffer); + } + } + return zOK; } @@ -2797,34 +2797,34 @@ STATUS recoveryPurgeLogRemove( *---------------------------------------------------------------------------*/ CommonBeastOps_s ZFSPURGELOG_ComnBeastOps = { - NULL, /* construct */ - NULL, /* destruct */ + NULL, /* construct */ + NULL, /* destruct */ // cnt NULL, /* BST_getNameUniquifier */ - NULL, /* BST_setupNameTypeSpecificInfo */ - NULL, /* BST_lookupByNameInDirectory*/ - NULL, /* BST_isDirectoryEmpty*/ - NULL, /* BST_addNameToDirectory*/ - NULL, /* BST_removeNameFromDirectory*/ - NULL, /* BST_modifyNameSpaceMaskInDirectory*/ - NULL, /* BST_setMatchAttributesInDirectory*/ - NULL, /* BST_wildcardLookup*/ + NULL, /* BST_setupNameTypeSpecificInfo */ + NULL, /* BST_lookupByNameInDirectory*/ + NULL, /* BST_isDirectoryEmpty*/ + NULL, /* BST_addNameToDirectory*/ + NULL, /* BST_removeNameFromDirectory*/ + NULL, /* BST_modifyNameSpaceMaskInDirectory*/ + NULL, /* BST_setMatchAttributesInDirectory*/ + NULL, /* BST_wildcardLookup*/ - NULL, /* BST_truncateFile*/ - NULL, /* BST_getStorageInfo*/ - NULL, /* BST_getExtentList*/ - NULL, /* BST_getPhysicalExtent*/ - NULL, /* BST_isBlockInBeast*/ + NULL, /* BST_truncateFile*/ + NULL, /* BST_getStorageInfo*/ + NULL, /* BST_getExtentList*/ + NULL, /* BST_getPhysicalExtent*/ + NULL, /* BST_isBlockInBeast*/ - NULL, /* BST_asyncReadFileBlk*/ - NULL, /* BST_getFileBlk*/ - NULL, /* BST_dfsReadUnits*/ - NULL, /* BST_dfsWriteUnits*/ + NULL, /* BST_asyncReadFileBlk*/ + NULL, /* BST_getFileBlk*/ + NULL, /* BST_dfsReadUnits*/ + NULL, /* BST_dfsWriteUnits*/ - NULL, /* BST_getZID*/ - NULL, /* BST_beastNotify*/ - NULL, /* BST_getInfo*/ - NULL /* BST_modifyInfo*/ + NULL, /* BST_getZID*/ + NULL, /* BST_beastNotify*/ + NULL, /* BST_getInfo*/ + NULL /* BST_modifyInfo*/ }; @@ -2832,36 +2832,36 @@ CommonBeastOps_s ZFSPURGELOG_ComnBeastOps = * EXTENT BASED storage pack routine *****************************************************************************/ STATIC NINT ZFSPURGELOG_PackedSize( - void *beast_LX) + void *beast_LX) { - return sizeof(PersistentZfsPurgeLog_s); + return sizeof(PersistentZfsPurgeLog_s); } /**************************************************************************** * EXTENT BASED storage pack routine *****************************************************************************/ STATIC BYTE *ZFSPURGELOG_Pack( - void *beast_LX, - BYTE *storeBuffer) + void *beast_LX, + BYTE *storeBuffer) { - ZfsPurgeLogBeast_s *beast = (ZfsPurgeLogBeast_s *)beast_LX; + ZfsPurgeLogBeast_s *beast = (ZfsPurgeLogBeast_s *)beast_LX; - memcpy(storeBuffer,&beast->p,sizeof(PersistentZfsPurgeLog_s)); - return (storeBuffer + sizeof(PersistentZfsPurgeLog_s)); + memcpy(storeBuffer,&beast->p,sizeof(PersistentZfsPurgeLog_s)); + return (storeBuffer + sizeof(PersistentZfsPurgeLog_s)); } /**************************************************************************** * EXTENT BASED storage pack routines *****************************************************************************/ STATIC BYTE *ZFSPURGELOG_Unpack( - GeneralMsg_s *genMsg, - void *beast_LX, - BYTE *storeBuffer) + GeneralMsg_s *genMsg, + void *beast_LX, + BYTE *storeBuffer) { - ZfsPurgeLogBeast_s *beast = (ZfsPurgeLogBeast_s *)beast_LX; + ZfsPurgeLogBeast_s *beast = (ZfsPurgeLogBeast_s *)beast_LX; - memcpy(&beast->p,storeBuffer,sizeof(PersistentZfsPurgeLog_s)); - return (storeBuffer + sizeof(PersistentZfsPurgeLog_s)); + memcpy(&beast->p,storeBuffer,sizeof(PersistentZfsPurgeLog_s)); + return (storeBuffer + sizeof(PersistentZfsPurgeLog_s)); } /*--------------------------------------------------------------------------- @@ -2869,8 +2869,8 @@ STATIC BYTE *ZFSPURGELOG_Unpack( *---------------------------------------------------------------------------*/ LSSSpecificPackUnpackOps_s ZFSPURGELOG_lssOps[] = { - {zLSS_ID_ZLSS,ZFSPURGELOG_PackedSize,ZFSPURGELOG_Pack,NULL,ZFSPURGELOG_Unpack}, - {zLSS_ID_INVALID} + {zLSS_ID_ZLSS,ZFSPURGELOG_PackedSize,ZFSPURGELOG_Pack,NULL,ZFSPURGELOG_Unpack}, + {zLSS_ID_INVALID} }; @@ -2878,64 +2878,64 @@ LSSSpecificPackUnpackOps_s ZFSPURGELOG_lssOps[] = * Recovery routine for initing the purge log first block ****************************************************************************/ STATUS recoveryPurgeLogInit( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - ZfsXasRecovery_s *logBuffer, - NINT action) + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + ZfsXasRecovery_s *logBuffer, + NINT action) { - Buffer_s *buffer; - PurgeLogBlock_s *pLogBlock; - IoMsg_s iomsg; - BlockInfo_s *poolBlks; - LogPurgeLogGrow_s *logRecord; + Buffer_s *buffer; + PurgeLogBlock_s *pLogBlock; + IoMsg_s iomsg; + BlockInfo_s *poolBlks; + LogPurgeLogGrow_s *logRecord; - zASSERT( logBuffer->ZXR_FunctionIndex == XFUNC_LV_PL_INIT ); + zASSERT( logBuffer->ZXR_FunctionIndex == XFUNC_LV_PL_INIT ); + + poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); - poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); + if (ZLOG_VALID_BLOCK(poolBlks[0])) + { + READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_WRITE) + buffer = ZFS_ReadPoolBlk(genMsg, &iomsg); + zASSERT( buffer != NULL ); - if (ZLOG_VALID_BLOCK(poolBlks[0])) - { - READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_WRITE) - buffer = ZFS_ReadPoolBlk(genMsg, &iomsg); - zASSERT( buffer != NULL ); + logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); + zASSERT( LB_GUIDValidate( &logRecord->lplg_internalID ) ); + ZFSVOL_InitPurgeLogBlock(buffer, &logRecord->lplg_internalID); + pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; - logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - zASSERT( LB_GUIDValidate( &logRecord->lplg_internalID ) ); - ZFSVOL_InitPurgeLogBlock(buffer, &logRecord->lplg_internalID); - pLogBlock = (PurgeLogBlock_s *)buffer->pBuf.data; + ZLOG_SET_LSN(logBuffer, pLogBlock->lsn, poolBlks[0], action); + CACHE_DIRTY_RELEASE(buffer); - ZLOG_SET_LSN(logBuffer, pLogBlock->lsn, poolBlks[0], action); - CACHE_DIRTY_RELEASE(buffer); - - } - return zOK; + } + return zOK; } /**************************************************************************** * Recovery routine for uniniting the purge log first block (undo for init) ****************************************************************************/ STATUS recoveryPurgeLogUninit( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - ZfsXasRecovery_s *logBuffer, - NINT action) + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + ZfsXasRecovery_s *logBuffer, + NINT action) { - Buffer_s *buffer; - IoMsg_s iomsg; - BlockInfo_s *poolBlks; + Buffer_s *buffer; + IoMsg_s iomsg; + BlockInfo_s *poolBlks; - zASSERT( logBuffer->ZXR_FunctionIndex == XFUNC_LV_PL_INIT ); + zASSERT( logBuffer->ZXR_FunctionIndex == XFUNC_LV_PL_INIT ); - poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); + poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); - if (ZLOG_VALID_BLOCK(poolBlks[0])) - { - /* make sure the cache block for the deleted block is gone */ - READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_WRITE) - if ((buffer = ZFS_ReadPoolBlk(genMsg, &iomsg)) != NULL) - { - cacheReleaseToss(buffer); - } - } - return zOK; + if (ZLOG_VALID_BLOCK(poolBlks[0])) + { + /* make sure the cache block for the deleted block is gone */ + READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_WRITE) + if ((buffer = ZFS_ReadPoolBlk(genMsg, &iomsg)) != NULL) + { + cacheReleaseToss(buffer); + } + } + return zOK; } diff --git a/src/nwnss/zlss/purgeLog.h b/src/nwnss/zlss/purgeLog.h index d2119f6..f517353 100644 --- a/src/nwnss/zlss/purgeLog.h +++ b/src/nwnss/zlss/purgeLog.h @@ -58,15 +58,15 @@ #define MAX_PURGE_LOG_ENTRIES 5 #else #define MAX_PURGE_LOG_ENTRIES \ - ( (PAGE_SIZE - \ - (sizeof(LONG) + sizeof (Lsn_t) + sizeof(Blknum_t) + sizeof(VolumeID_t) \ - ) \ - ) \ - / sizeof(PurgeLogEntry_s) \ - ) + ( (PAGE_SIZE - \ + (sizeof(LONG) + sizeof (Lsn_t) + sizeof(Blknum_t) + sizeof(VolumeID_t) \ + ) \ + ) \ + / sizeof(PurgeLogEntry_s) \ + ) #endif -#define PURGE_LOG_MAGIC 0x474f4c50 +#define PURGE_LOG_MAGIC 0x474f4c50 #if NSS_DEBUG IS_ENABLED //#define VALIDATE_PLOG(_plog) ((void)0) @@ -78,7 +78,7 @@ /************************************************************************** * * Structures for the purge log - * + * **************************************************************************/ /* @@ -87,95 +87,95 @@ typedef struct FreeEntry_s { - ZfsPurgeLogLoc_s link; /* link to the next entry on the free list */ + ZfsPurgeLogLoc_s link; /* link to the next entry on the free list */ } NSS_MEDIA_STRUCTURE(FreeEntry_s,link) FreeEntry_s; - + typedef struct PurgeBlockEntry_s { - Blknum_t blockNumber; + Blknum_t blockNumber; } NSS_MEDIA_STRUCTURE(PurgeBlockEntry_s,blockNumber) PurgeBlockEntry_s; typedef struct PurgeBeastEntry_s { - VolumeID_t volumeID; /* guid of the volume the beast is on */ - Zid_t zid; /* zid of the beast */ - Zid_t dirZid; /* zid of the beast's parent container */ + VolumeID_t volumeID; /* guid of the volume the beast is on */ + Zid_t zid; /* zid of the beast */ + Zid_t dirZid; /* zid of the beast's parent container */ } NSS_MEDIA_STRUCTURE(PurgeBeastEntry_s,dirZid) PurgeBeastEntry_s; typedef struct TruncateEntry_s { - VolumeID_t volumeID; /* guid of the volume the beast is on */ - Zid_t zid; /* zid of the beast */ - Blknum_t startBlock; /* block num to start the truncate */ - Blkcnt_t len; /* length of the extent to be truncated */ + VolumeID_t volumeID; /* guid of the volume the beast is on */ + Zid_t zid; /* zid of the beast */ + Blknum_t startBlock; /* block num to start the truncate */ + Blkcnt_t len; /* length of the extent to be truncated */ } NSS_MEDIA_STRUCTURE(TruncateEntry_s,len) TruncateEntry_s; typedef struct FixVisEntry_s { - UserID_t trusteeID; - Zid_t parentZID; - LONG action; + UserID_t trusteeID; + Zid_t parentZID; + LONG action; } NSS_MEDIA_STRUCTURE(FixVisEntry_s,action) FixVisEntry_s; typedef struct UserEntry_s { - VolumeID_t volumeID; + VolumeID_t volumeID; } NSS_MEDIA_STRUCTURE(UserEntry_s,volumeID) UserEntry_s; typedef struct UserScanEntry_s { - VolumeID_t volumeID; + VolumeID_t volumeID; } NSS_MEDIA_STRUCTURE(UserScanEntry_s,volumeID) UserScanEntry_s; typedef struct UserClearEntry_s { - VolumeID_t volumeID; + VolumeID_t volumeID; } NSS_MEDIA_STRUCTURE(UserClearEntry_s,volumeID) UserClearEntry_s; typedef struct DirEntry_s { - VolumeID_t volumeID; + VolumeID_t volumeID; } NSS_MEDIA_STRUCTURE(DirEntry_s,volumeID) DirEntry_s; typedef struct DirUsed_s { - VolumeID_t volumeID; - Zid_t dirZid; /* zid of directory where we are computing used amount */ + VolumeID_t volumeID; + Zid_t dirZid; /* zid of directory where we are computing used amount */ } NSS_MEDIA_STRUCTURE(DirUsed_s,dirZid) DirUsed_s; typedef struct EFLEpochRemove_s { - VolumeID_t volumeID; - EFLEpoch_t epoch; + VolumeID_t volumeID; + EFLEpoch_t epoch; } NSS_MEDIA_STRUCTURE(EFLEpochRemove_s,epoch) EFLEpochRemove_s; typedef struct EFLTreeReset_s { - VolumeID_t volumeID; + VolumeID_t volumeID; } NSS_MEDIA_STRUCTURE(EFLTreeReset_s,volumeID) EFLTreeReset_s; typedef union PurgeLogInfo_s { - FreeEntry_s free; /* link to the next entry on the free list */ - PurgeBeastEntry_s beast; /* normal purge log entry */ - TruncateEntry_s trunc; /* trucate and entry */ - PurgeBlockEntry_s block; /* remove a block (add it to the free tree) */ - FixVisEntry_s visib; /* add/remove visibility going up the tree */ - UserEntry_s user; /* remove the user tree for a volume */ - UserScanEntry_s userScan; /* scan the user names for a volume */ - UserClearEntry_s userClear; /* clear all used space for users */ - DirEntry_s directory; /* remove the directory tree for a volume */ - DirUsed_s dirUsed; /* compute used amount for dir quota */ - EFLEpochRemove_s epochRemove; /* remove a certain epoch in volume's EFL tree */ - EFLTreeReset_s resetEFL; /* reset volume's EFL tree */ + FreeEntry_s free; /* link to the next entry on the free list */ + PurgeBeastEntry_s beast; /* normal purge log entry */ + TruncateEntry_s trunc; /* trucate and entry */ + PurgeBlockEntry_s block; /* remove a block (add it to the free tree) */ + FixVisEntry_s visib; /* add/remove visibility going up the tree */ + UserEntry_s user; /* remove the user tree for a volume */ + UserScanEntry_s userScan; /* scan the user names for a volume */ + UserClearEntry_s userClear; /* clear all used space for users */ + DirEntry_s directory; /* remove the directory tree for a volume */ + DirUsed_s dirUsed; /* compute used amount for dir quota */ + EFLEpochRemove_s epochRemove; /* remove a certain epoch in volume's EFL tree */ + EFLTreeReset_s resetEFL; /* reset volume's EFL tree */ } NSS_MEDIA_UNION(PurgeLogInfo_s,trunc.len) PurgeLogInfo_s; typedef struct PurgeLogEntry_s { - LONG type; /* the type of entry */ - LONG generation; /* this is the system restart count */ - PurgeLogInfo_s info; /* the information to be logged */ + LONG type; /* the type of entry */ + LONG generation; /* this is the system restart count */ + PurgeLogInfo_s info; /* the information to be logged */ } NSS_MEDIA_STRUCTURE(PurgeLogEntry_s,info.trunc.len) PurgeLogEntry_s; /* @@ -183,17 +183,17 @@ typedef struct PurgeLogEntry_s */ typedef struct PurgeLogBlock_s { - /* - * If fields are added or deleted from this structure make sure to - * update MAX_PURGE_LOG_ENTRIES. - */ - LONG magic; - Blknum_t nextBlock; /* link to the next block with purge log entries */ - Lsn_t lsn; /* Must be at offset 8 - the log sequence number */ - GUID_t plb_internalID; /* Must be at OFFSET 16 - unique volume ID (used - * by scanning repair). xnh is x Node Header. - */ - PurgeLogEntry_s logEntry[MAX_PURGE_LOG_ENTRIES]; /* maximum entries in a block */ + /* + * If fields are added or deleted from this structure make sure to + * update MAX_PURGE_LOG_ENTRIES. + */ + LONG magic; + Blknum_t nextBlock; /* link to the next block with purge log entries */ + Lsn_t lsn; /* Must be at offset 8 - the log sequence number */ + GUID_t plb_internalID; /* Must be at OFFSET 16 - unique volume ID (used + * by scanning repair). xnh is x Node Header. + */ + PurgeLogEntry_s logEntry[MAX_PURGE_LOG_ENTRIES]; /* maximum entries in a block */ } NSS_MEDIA_STRUCTURE(PurgeLogBlock_s,logEntry[MAX_PURGE_LOG_ENTRIES]) PurgeLogBlock_s; /************************************************************************** @@ -204,14 +204,14 @@ typedef struct PurgeLogBlock_s typedef struct LogPurgeLog_s { - LONG slot; - PurgeLogEntry_s entry; + LONG slot; + PurgeLogEntry_s entry; } NSS_MEDIA_STRUCTURE(LogPurgeLog_s,entry.info.trunc.len) LogPurgeLog_s; - // For GROW and INIT + // For GROW and INIT typedef struct LogPurgeLogGrow_s { - VolumeID_t lplg_internalID; + VolumeID_t lplg_internalID; } NSS_MEDIA_STRUCTURE(LogPurgeLogGrow_s,lplg_internalID) LogPurgeLogGrow_s; /************************************************************************* @@ -219,13 +219,13 @@ typedef struct LogPurgeLogGrow_s ************************************************************************/ typedef struct FreePurgeLogEntries_s { - DQlink_t xactionLink; - ZfsPurgeLogLoc_s location; - ZfsPurgeLogBeast_s *purgeLog; + DQlink_t xactionLink; + ZfsPurgeLogLoc_s location; + ZfsPurgeLogBeast_s *purgeLog; } FreePurgeLogEntries_s; -extern void PLOG_PutEntryOnFreeList( - FreePurgeLogEntries_s *pLogEntry); +extern void PLOG_PutEntryOnFreeList( + FreePurgeLogEntries_s *pLogEntry); extern ObjCache_s PLogFreeEntry; @@ -236,42 +236,42 @@ extern ObjCache_s PLogFreeEntry; * ****************************************************************************/ void plogValidate ( - ZfsPurgeLogBeast_s *purgeLog, - BOOL shouldBeEmpty); + ZfsPurgeLogBeast_s *purgeLog, + BOOL shouldBeEmpty); STATUS ZFSPURGELOG_Setup ( - struct GeneralMsg_s *genMsg, - struct ZfsPurgeLogBeast_s *purgeLog); + struct GeneralMsg_s *genMsg, + struct ZfsPurgeLogBeast_s *purgeLog); STATUS ZFSPOOL_PlayPurgeLog ( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - ZfsVolume_s *zfsVol, - struct ZfsPurgeLogBeast_s *purgeLog, - NINT mode ); + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + ZfsVolume_s *zfsVol, + struct ZfsPurgeLogBeast_s *purgeLog, + NINT mode ); STATUS ZFSVOL_PlayPurgeLog ( - GeneralMsg_s *genMsg, - ZfsVolume_s *zfsVol, - struct ZfsPurgeLogBeast_s *purgeLog, - NINT mode ); + GeneralMsg_s *genMsg, + ZfsVolume_s *zfsVol, + struct ZfsPurgeLogBeast_s *purgeLog, + NINT mode ); STATUS ZFSVOL_VOL_AddPurgeLogEntry ( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - NINT type, - PurgeLogMsg_s *purgeMsg, - struct Xaction_s *xAction); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT type, + PurgeLogMsg_s *purgeMsg, + struct Xaction_s *xAction); STATUS ZFSVOL_VOL_RemovePurgeLogEntry ( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - NINT type, - PurgeLogMsg_s *purgeMsg, - struct Xaction_s *xAction); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT type, + PurgeLogMsg_s *purgeMsg, + struct Xaction_s *xAction); void ZFSVOL_InitPurgeLogBlock ( - struct Buffer_s *buffer, - VolumeID_t *volumeID); + struct Buffer_s *buffer, + VolumeID_t *volumeID); #endif /* _PURGELOG_H_ */ diff --git a/src/nwnss/zlss/purgeTree.c b/src/nwnss/zlss/purgeTree.c index fc94154..4b9b7d4 100644 --- a/src/nwnss/zlss/purgeTree.c +++ b/src/nwnss/zlss/purgeTree.c @@ -83,7 +83,7 @@ while (! _cond) \ SNINT purgekey_comp(PurgeKey_s *k1, PurgeKey_s *k2) { SNINT diff; - + diff = KEY_COMP(k1->deltime, k2->deltime); if (diff != 0) return diff; diff = LB_GUIDCompare(&k1->internalID, &k2->internalID); @@ -115,7 +115,7 @@ BOOL pbtValidateNode(PurgeTreeNode_s *node, BOOL dontAssert) zid = pinfo->key.zid; VERIFY_CONDITION((*(LONG *)&zid != -1), dontAssert); VERIFY_CONDITION(((zid != zOPEN_ENTRY_ZID) && ((zid != zINVALID_ZID) || (i == 0))), dontAssert); - VERIFY_CONDITION(((i == 0) || + VERIFY_CONDITION(((i == 0) || (purgekey_comp(&prev_pinfo->key, &pinfo->key) < 0)), dontAssert); prev_pinfo = pinfo; } @@ -154,7 +154,7 @@ BOOL pbtValidateNode(PurgeTreeNode_s *node, BOOL dontAssert) { /*- set the current record -*/ b_curr = &node->n.branch[cnt]; - + /*- check if keys ascend -*/ VERIFY_CONDITION((purgekey_comp(&b_prev->key, &b_curr->key) < 0), dontAssert); @@ -178,7 +178,7 @@ invalidNode: ; /**************************************************************************** * ****************************************************************************/ -void zfsDisplayPurgeTreeNode (char *location, char *nameOfBuffer, +void zfsDisplayPurgeTreeNode (char *location, char *nameOfBuffer, Buffer_s *buffer) { PurgeTreeNode_s *node = (PurgeTreeNode_s *)buffer->pBuf.data; @@ -190,7 +190,7 @@ void zfsDisplayPurgeTreeNode (char *location, char *nameOfBuffer, PurgeInfo_s *pinfo; DBG_DebugPrintf( LBLUE, "\n%s=%s<%lx(%ld.)>", location, nameOfBuffer, - (unsigned long)buffer->volBlk, (unsigned long)buffer->volBlk ); + (unsigned long)buffer->volBlk, (unsigned long)buffer->volBlk ); if (PBT_IS_ROOT(node)) { @@ -200,11 +200,11 @@ void zfsDisplayPurgeTreeNode (char *location, char *nameOfBuffer, { DBG_DebugPrintf( LBLUE, "LEAF"); if (node->magic != PURGETREE_MAGIC) - { - DBG_DebugPrintf( LRED, "\n:ERROR(Node does not have correct MAGIC (value is %lx))\n",node->magic); - zASSERT(node->magic == PURGETREE_MAGIC); - return; - } + { + DBG_DebugPrintf( LRED, "\n:ERROR(Node does not have correct MAGIC (value is %lx))\n",node->magic); + zASSERT(node->magic == PURGETREE_MAGIC); + return; + } DBG_DebugPrintf( LBLUE, "(free=%d, start=%d, numRecs=%d)", node->n.leaf.freeSpace, node->n.leaf.startOfFreeSpace, node->numRecs); for (i = 0; i < node->numRecs; ++i) @@ -214,10 +214,10 @@ void zfsDisplayPurgeTreeNode (char *location, char *nameOfBuffer, zASSERT(*(LONG *)&zid != -1); zASSERT((zid != zOPEN_ENTRY_ZID) && ((zid != zINVALID_ZID) || (i == 0))); zASSERT((i == 0) || (zid > PT_LEAF_ENTRY(node, i-1)->key.zid)); - if ( i != 0 && (zid <= PT_LEAF_ENTRY(node, i-1)->key.zid) ) - { /* Out Of ORDER */ - DBG_DebugPrintf( LRED, ":ERROR(out-of-order)"); - } + if ( i != 0 && (zid <= PT_LEAF_ENTRY(node, i-1)->key.zid) ) + { /* Out Of ORDER */ + DBG_DebugPrintf( LRED, ":ERROR(out-of-order)"); + } DBG_DebugPrintf( LBLUE, ":%lx", (LONG)zid); } DBG_DebugPrintf( LBLUE, "\n"); @@ -248,15 +248,15 @@ void zfsDisplayPurgeTreeNode (char *location, char *nameOfBuffer, { DBG_DebugPrintf( LGREEN, "BRANCH"); if (node->magic != PURGETREE_MAGIC) - { - DBG_DebugPrintf( LRED, "\n:ERROR(Node does not have correct MAGIC (value is %lx))\n",node->magic); - zASSERT(node->magic == PURGETREE_MAGIC); - return; - } + { + DBG_DebugPrintf( LRED, "\n:ERROR(Node does not have correct MAGIC (value is %lx))\n",node->magic); + zASSERT(node->magic == PURGETREE_MAGIC); + return; + } DBG_DebugPrintf( LBLUE, "(numRecs=%d)", node->numRecs); for (i = 0; i < node->numRecs; ++i) { - DBG_DebugPrintf( LBLUE, "<%d, %d>", + DBG_DebugPrintf( LBLUE, "<%d, %d>", (LONG)node->n.branch[i].key.zid, // cnt (LONG)node->n.branch[i].key.nameUniquifier, (LONG)node->n.branch[i].child); @@ -286,17 +286,17 @@ void zfsDisplayPurgeSubtree( else { zfsDisplayPurgeTreeNode("Full Tree", "BRANCH", buffer); - if ( node->magic == PURGETREE_MAGIC ) - { - for (i = 0; i < node->numRecs; i++) - { - READBLK_IO_MSG(iomsg, treeBeast, - node->n.branch[i].child, CACHE_READ); - newBuf = ZFS_ReadPoolBlk( &genMsg, &iomsg); - zfsDisplayPurgeSubtree(treeBeast, newBuf); - CACHE_RELEASE(newBuf); - } - } + if ( node->magic == PURGETREE_MAGIC ) + { + for (i = 0; i < node->numRecs; i++) + { + READBLK_IO_MSG(iomsg, treeBeast, + node->n.branch[i].child, CACHE_READ); + newBuf = ZFS_ReadPoolBlk( &genMsg, &iomsg); + zfsDisplayPurgeSubtree(treeBeast, newBuf); + CACHE_RELEASE(newBuf); + } + } } } @@ -362,7 +362,7 @@ void ZfsDisplayPurgeTree( printf(MSG("Volume not found.\n", 462)); } COMN_Release(&volume); - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); } /**************************************************************************** @@ -430,25 +430,25 @@ void zprintPurgeTreeNode (char *location, char *nameOfBuffer, Buffer_s *buffer) * ****************************************************************************/ Buffer_s *PBT_ReadPoolBlk ( - GeneralMsg_s *genMsg, - IoMsg_s *iomsg) + GeneralMsg_s *genMsg, + IoMsg_s *iomsg) { - Buffer_s *buffer; - NINT magic; + Buffer_s *buffer; + NINT magic; - buffer = ZFS_ReadPoolBlk(genMsg, iomsg); - if ((buffer != NULL) && (iomsg->mode != CACHE_WRITE)) - { - magic = ((PurgeTreeNode_s *)buffer->pBuf.data)->magic; - if (magic != PURGETREE_MAGIC) - { - SetErrno(genMsg, zERR_MEDIA_CORRUPTED); - ZLSSPOOL_MediaIsCorrupt(genMsg, buffer, iomsg); - CACHE_RELEASE(buffer); - return NULL; - } - } - return buffer; + buffer = ZFS_ReadPoolBlk(genMsg, iomsg); + if ((buffer != NULL) && (iomsg->mode != CACHE_WRITE)) + { + magic = ((PurgeTreeNode_s *)buffer->pBuf.data)->magic; + if (magic != PURGETREE_MAGIC) + { + SetErrno(genMsg, zERR_MEDIA_CORRUPTED); + ZLSSPOOL_MediaIsCorrupt(genMsg, buffer, iomsg); + CACHE_RELEASE(buffer); + return NULL; + } + } + return buffer; } /***************************************************************** @@ -471,14 +471,14 @@ BOOL pbt_findLentryByKey( ENTER(TZTREE, pbt_findLentryByKey); PBT_VALIDATE_NODE(node); - while (low <= high) + while (low <= high) { i = (low + high)/2; pinfo = PT_LEAF_ENTRY(node, i); res = purgekey_comp(key, &pinfo->key); - if (res == 0) + if (res == 0) { - if (low == high) + if (low == high) { *ind = i; RTN_BOOL(TRUE); @@ -490,7 +490,7 @@ BOOL pbt_findLentryByKey( else high = i-1; } - if (res < 0) + if (res < 0) --i; *ind = i+1; RTN_BOOL(FALSE); @@ -568,7 +568,7 @@ void pbt_garbageCollectNode (PurgeTreeNode_s *node) while (currentPosition < node->n.leaf.startOfFreeSpace) { /* garbage collect the free space */ curLentry = (PurgeInfo_s *)&node->PBTLEAFSPACE.pinfo[currentPosition]; - zASSERT((node->n.leaf.startOfFreeSpace - currentPosition) + zASSERT((node->n.leaf.startOfFreeSpace - currentPosition) >= MIN_PT_LEAF_ENTRY_SIZE); len = curLentry->length; zASSERT(len >= MIN_PT_LEAF_ENTRY_SIZE); @@ -884,7 +884,7 @@ STATUS pbt_recoveryGrow( node->numRecs = 1; node->n.branch[0].key.deltime = 0; node->n.branch[0].key.zid = 0; - node->n.branch[0].key.reserved = 0; + node->n.branch[0].key.reserved = 0; node->n.branch[0].child = logRecord->u.grow.blockForParent; ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); ZPRINT_PTREE_NODE(restoreGrowRoot, buffer); @@ -968,13 +968,13 @@ STATUS pbt_recoveryBalance( ZPRINT_PTREE_NODE(restoreBalanceParent1, buffer); if (action == X_REDO) { - node->n.branch[logRecord->u.balance.indexForParent].key = + node->n.branch[logRecord->u.balance.indexForParent].key = logRecord->u.balance.keyForParent; } else { - node->n.branch[logRecord->u.balance.indexForParent].key = - logRecord->u.balance.oldKey; + node->n.branch[logRecord->u.balance.indexForParent].key = + logRecord->u.balance.oldKey; } ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); ZPRINT_PTREE_NODE(restoreBalanceParent2, buffer); @@ -1029,8 +1029,8 @@ STATUS pbt_recoveryBalance( else { /* branch */ numToMove = logRecord->u.balance.numToMove; - if ((numToMove > 0) && - (purgekey_comp(&((PbtBranch_s *)&logRecord->u.balance.data[0])->key, + if ((numToMove > 0) && + (purgekey_comp(&((PbtBranch_s *)&logRecord->u.balance.data[0])->key, &node->n.branch[0].key) == 0)) { /* if we are removing from the start of the branch record.. */ memmove(&node->n.branch[0], /* Destination */ @@ -1079,7 +1079,7 @@ STATUS pbt_recoveryBalance( currentLentry = (PurgeInfo_s *)(((ADDR)currentLentry) + lentryLength)) { lentryLength = currentLentry->length; - if (pbt_insertEntry(genMsg, node, currentLentry, lentryLength) + if (pbt_insertEntry(genMsg, node, currentLentry, lentryLength) != zOK) { CACHE_RELEASE(buffer); @@ -1092,32 +1092,32 @@ STATUS pbt_recoveryBalance( numToMove = logRecord->u.balance.numToMove; lenMoved = logRecord->u.balance.totalLength; if ( numToMove > 0 ) - { - if ( purgekey_comp(&((PbtBranch_s *)&logRecord->u.balance.data[0])->key, - &node->n.branch[0].key) < 0) - { /* if we are inserting at the start of the branch record ... */ + { + if ( purgekey_comp(&((PbtBranch_s *)&logRecord->u.balance.data[0])->key, + &node->n.branch[0].key) < 0) + { /* if we are inserting at the start of the branch record ... */ - /* make room for the insert */ - memmove(&node->n.branch[numToMove], /* Destination */ - &node->n.branch[0], /* Source */ - node->numRecs * sizeof(PbtBranch_s) ); - // lenMoved); + /* make room for the insert */ + memmove(&node->n.branch[numToMove], /* Destination */ + &node->n.branch[0], /* Source */ + node->numRecs * sizeof(PbtBranch_s) ); + // lenMoved); - /* insert the info from the log record */ - memcpy(&node->n.branch[0], - &logRecord->u.balance.data[0], - lenMoved); - } - else - { - /* insert the info from the log record */ - // memcpy(&node->n.branch[numToMove], - memcpy(&node->n.branch[node->numRecs], - &logRecord->u.balance.data[0], - lenMoved); - } - node->numRecs += numToMove; - } + /* insert the info from the log record */ + memcpy(&node->n.branch[0], + &logRecord->u.balance.data[0], + lenMoved); + } + else + { + /* insert the info from the log record */ + // memcpy(&node->n.branch[numToMove], + memcpy(&node->n.branch[node->numRecs], + &logRecord->u.balance.data[0], + lenMoved); + } + node->numRecs += numToMove; + } } ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[block], action); @@ -1214,7 +1214,7 @@ STATUS pbt_recoveryJoin( currentLentry = (PurgeInfo_s *)(((ADDR)currentLentry) + lentryLength)) { lentryLength = currentLentry->length; - if (pbt_insertEntry(genMsg, node, currentLentry, lentryLength) + if (pbt_insertEntry(genMsg, node, currentLentry, lentryLength) != zOK) { CACHE_RELEASE(buffer); @@ -1381,7 +1381,7 @@ STATUS pbt_recoverySplit( /* fix up the child */ ZPRINT_PTREE_NODE(restoreSplitNewChild1, buffer); ZPRINT_NINT(restoreSplitNewChild_NumRecs, logRecord->u.split.numToMove); - pbt_initNode(buffer, logRecord->u.split.nodeType, + pbt_initNode(buffer, logRecord->u.split.nodeType, &pool->ZFSPOOLinternalID); if (PBT_IS_LEAF(node)) { /* leaf */ @@ -1392,7 +1392,7 @@ STATUS pbt_recoverySplit( currentLentry = (PurgeInfo_s *)(((ADDR)currentLentry) + lentryLength)) { lentryLength = currentLentry->length; - if (pbt_insertEntry(genMsg, node, currentLentry, lentryLength) + if (pbt_insertEntry(genMsg, node, currentLentry, lentryLength) != zOK) { CACHE_RELEASE(buffer); @@ -1467,7 +1467,7 @@ STATUS pbt_recoveryInsertOverflow( currentLentry = (PurgeInfo_s *)(((ADDR)currentLentry) + lentryLength)) { lentryLength = currentLentry->length; - if (pbt_insertEntry(genMsg, node, currentLentry, lentryLength) + if (pbt_insertEntry(genMsg, node, currentLentry, lentryLength) != zOK) { CACHE_RELEASE(buffer); @@ -1606,7 +1606,7 @@ STATUS pbt_recoveryRemoveOverflow( currentLentry = (PurgeInfo_s *)(((ADDR)currentLentry) + lentryLength)) { lentryLength = currentLentry->length; - if (pbt_insertEntry(genMsg, node, currentLentry, lentryLength) + if (pbt_insertEntry(genMsg, node, currentLentry, lentryLength) != zOK) { CACHE_RELEASE(buffer); @@ -1752,32 +1752,32 @@ STATUS pbt_recoveryInsertEntryLogical( ZfsXasRecovery_s *logBuffer, NINT action) { - STATUS status; + STATUS status; PbtLog_s *logRecord; - ZfsXaction_s *xaction; - PurgeInfo_s *pInfo; + ZfsXaction_s *xaction; + PurgeInfo_s *pInfo; - ASSERT_MPKNSS_LOCK(); + ASSERT_MPKNSS_LOCK(); - if (action == X_UNDO) - { - return zX_LOGICAL; - } + if (action == X_UNDO) + { + return zX_LOGICAL; + } logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - pInfo = &logRecord->u.pinfo; + pInfo = &logRecord->u.pinfo; - xaction = BeginXLocal(&pool->ZFSPOOLvol, BXL_LOGICAL_UNDO); + xaction = BeginXLocal(&pool->ZFSPOOLvol, BXL_LOGICAL_UNDO); - status = purgeq_insert_name(genMsg, - pool->purgeTree, - pInfo->key.deltime, &pInfo->key.internalID, - pInfo->key.zid, /* cnt pInfo->key.nameUniquifier, */ - pInfo->pzid, &xaction->xaction); + status = purgeq_insert_name(genMsg, + pool->purgeTree, + pInfo->key.deltime, &pInfo->key.internalID, + pInfo->key.zid, /* cnt pInfo->key.nameUniquifier, */ + pInfo->pzid, &xaction->xaction); - SET_LUNDO_LSN(xaction, logBuffer, status); - EndXlocal(xaction); - return status; + SET_LUNDO_LSN(xaction, logBuffer, status); + EndXlocal(xaction); + return status; } /**************************************************************************** @@ -1789,32 +1789,32 @@ STATUS pbt_recoveryDeleteEntryLogical( ZfsXasRecovery_s *logBuffer, NINT action) { - STATUS status; + STATUS status; PbtLog_s *logRecord; - ZfsXaction_s *xaction; - PurgeInfo_s *pInfo; + ZfsXaction_s *xaction; + PurgeInfo_s *pInfo; - ASSERT_MPKNSS_LOCK(); + ASSERT_MPKNSS_LOCK(); - if (action == X_UNDO) - { - return zX_LOGICAL; - } + if (action == X_UNDO) + { + return zX_LOGICAL; + } logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - pInfo = &logRecord->u.pinfo; + pInfo = &logRecord->u.pinfo; - xaction = BeginXLocal(&pool->ZFSPOOLvol, BXL_LOGICAL_UNDO); + xaction = BeginXLocal(&pool->ZFSPOOLvol, BXL_LOGICAL_UNDO); - status = purgeq_delete_name(genMsg, - pool->purgeTree, - pInfo->key.deltime, &pInfo->key.internalID, - pInfo->key.zid, /* cnt pInfo->key.nameUniquifier, */ - pInfo->pzid, &xaction->xaction); + status = purgeq_delete_name(genMsg, + pool->purgeTree, + pInfo->key.deltime, &pInfo->key.internalID, + pInfo->key.zid, /* cnt pInfo->key.nameUniquifier, */ + pInfo->pzid, &xaction->xaction); - SET_LUNDO_LSN(xaction, logBuffer, status); - EndXlocal(xaction); - return status; + SET_LUNDO_LSN(xaction, logBuffer, status); + EndXlocal(xaction); + return status; } @@ -1832,36 +1832,36 @@ STATUS pbt_recoveryDeleteEntryLogical( *---------------------------------------------------------------------------*/ CommonBeastOps_s ZFSPURGETREE_ComnBeastOps = { - NULL, /* construct */ - NULL, /* destruct */ + NULL, /* construct */ + NULL, /* destruct */ // cnt NULL, /* BST_getNameUniquifier */ - NULL, /* BST_setupNameTypeSpecificInfo */ - NULL, /* BST_lookupByNameInDirectory*/ - NULL, /* BST_isDirectoryEmpty*/ - NULL, /* BST_addNameToDirectory*/ - NULL, /* BST_removeNameFromDirectory*/ - NULL, /* BST_modifyNameSpaceMaskInDirectory*/ - NULL, /* BST_setMatchAttributesInDirectory*/ - NULL, /* BST_wildcardLookup*/ + NULL, /* BST_setupNameTypeSpecificInfo */ + NULL, /* BST_lookupByNameInDirectory*/ + NULL, /* BST_isDirectoryEmpty*/ + NULL, /* BST_addNameToDirectory*/ + NULL, /* BST_removeNameFromDirectory*/ + NULL, /* BST_modifyNameSpaceMaskInDirectory*/ + NULL, /* BST_setMatchAttributesInDirectory*/ + NULL, /* BST_wildcardLookup*/ - NULL, /* BST_truncateFile*/ - NULL, /* BST_getStorageInfo*/ - NULL, /* BST_getExtentList*/ - NULL, /* BST_getPhysicalExtent*/ - NULL, /* BST_isBlockInBeast*/ + NULL, /* BST_truncateFile*/ + NULL, /* BST_getStorageInfo*/ + NULL, /* BST_getExtentList*/ + NULL, /* BST_getPhysicalExtent*/ + NULL, /* BST_isBlockInBeast*/ - NULL, /* BST_asyncReadFileBlk*/ - NULL, /* BST_getFileBlk*/ - NULL, /* BST_dfsReadUnits*/ - NULL, /* BST_dfsWriteUnits*/ + NULL, /* BST_asyncReadFileBlk*/ + NULL, /* BST_getFileBlk*/ + NULL, /* BST_dfsReadUnits*/ + NULL, /* BST_dfsWriteUnits*/ - NULL, /* BST_getZID*/ - NULL, /* BST_beastNotify*/ - NULL, /* BST_getInfo*/ - NULL, /* BST_modifyInfo*/ - NULL, /* BST_getInfoXML */ - NULL /* BST_modifyInfoXML*/ + NULL, /* BST_getZID*/ + NULL, /* BST_beastNotify*/ + NULL, /* BST_getInfo*/ + NULL, /* BST_modifyInfo*/ + NULL, /* BST_getInfoXML */ + NULL /* BST_modifyInfoXML*/ }; /**************************************************************************** diff --git a/src/nwnss/zlss/purgeTree.h b/src/nwnss/zlss/purgeTree.h index 3e0fe36..474d24c 100644 --- a/src/nwnss/zlss/purgeTree.h +++ b/src/nwnss/zlss/purgeTree.h @@ -157,14 +157,14 @@ typedef WORD pbtNodeLen_t; * The following operations need to be supported on the purge-queue. * STATUS purgeq_insert_name(deltime, volume, zid, nameUniquifier, pzid); * STATUS purgeq_delete_name(deltime, volume, zid, nameUniquifier, pzid); - * STATUS purgeq_serial_lookup(curtime, out deltime, out volumeID, out zid, + * STATUS purgeq_serial_lookup(curtime, out deltime, out volumeID, out zid, * out nameUniquifier, out pzid); * Optionally, - * STATUS purgeq_delete_next_name(curtime, out deltime, out zid, + * STATUS purgeq_delete_next_name(curtime, out deltime, out zid, * out nameUniquifier, out pzid); * (This operation can be implemented using the above operations). */ -typedef struct PurgeKey_s +typedef struct PurgeKey_s { GUID_t internalID; /* Beast's volume ID */ Zid_t zid; /* ZID of the purgeable file. */ @@ -233,9 +233,9 @@ typedef struct PurgeTreeNode_s WORD state; WORD numRecs; Lsn_t lsn; - GUID_t ptn_internalID; /* Must be at OFFSET 16 - unique internal ID (used - * by scanning repair). ptn -> Purge Tree Node. - */ + GUID_t ptn_internalID; /* Must be at OFFSET 16 - unique internal ID (used + * by scanning repair). ptn -> Purge Tree Node. + */ union { PbtBranch_s branch[1]; @@ -304,7 +304,7 @@ typedef struct PbtLog_s PbtBalance_s balance; } NSS_MEDIA_UNION(NamelessUnion,balance.data[1]) u; } NSS_MEDIA_STRUCTURE(PbtLog_s,u.balance.data[1]) PbtLog_s; - + BOOL pbtValidateNode(PurgeTreeNode_s *node, BOOL dontAssert); #define PBT_IS_NODE_VALID(_node) \ pbtValidateNode((PurgeTreeNode_s *)(_node), TRUE) @@ -315,12 +315,12 @@ BOOL pbtValidateNode(PurgeTreeNode_s *node, BOOL dontAssert); #if NSS_DEBUG IS_ENABLED #define PBT_VALIDATE_NODE(_node) \ ((void)pbtValidateNode((PurgeTreeNode_s *)(_node), FALSE)) -void zfsDisplayPurgeTreeNode (char *location, char *nameOfBuffer, +void zfsDisplayPurgeTreeNode (char *location, char *nameOfBuffer, Buffer_s *buffer); void ZfsDisplayPurgeTree( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); #else #define PBT_VALIDATE_NODE(_node) ((void)0) #endif diff --git a/src/nwnss/zlss/purgeTree_if.h b/src/nwnss/zlss/purgeTree_if.h index ecef6a9..d32017a 100644 --- a/src/nwnss/zlss/purgeTree_if.h +++ b/src/nwnss/zlss/purgeTree_if.h @@ -32,7 +32,7 @@ | |--------------------------------------------------------------------------- | This module is used to: - | Define stuctures and + | Define stuctures and +-------------------------------------------------------------------------*/ #ifndef _PURGETREE_IF_H_ @@ -44,60 +44,61 @@ * ****************************************************************************/ -extern STATUS +extern STATUS purgeq_insert_name( GeneralMsg_s *genMsg, ZfsPurgeTreeBeast_s *ptree, - Time_t deltime, + Time_t deltime, GUID_t *internalID, - Zid_t zid, -// cnt NINT nameUniquifier, + Zid_t zid, +// cnt NINT nameUniquifier, Zid_t pzid, Xaction_s *xaction); -extern STATUS +extern STATUS purgeq_delete_name( GeneralMsg_s *genMsg, ZfsPurgeTreeBeast_s *ptree, - Time_t deltime, + Time_t deltime, GUID_t *internalID, - Zid_t zid, -// cnt NINT nameUniquifier, + Zid_t zid, +// cnt NINT nameUniquifier, Zid_t pzid, Xaction_s *xaction); STATUS purgeq_lookup_name( - GeneralMsg_s *genMsg, - ZfsPurgeTreeBeast_s *ztree, - Time_t deltime, - VolumeID_t *volumeID, - Zid_t zid, -// cnt NINT nameUniquifier, - Zid_t pzid); + GeneralMsg_s *genMsg, + ZfsPurgeTreeBeast_s *ztree, + Time_t deltime, + VolumeID_t *volumeID, + Zid_t zid, +// cnt NINT nameUniquifier, + Zid_t pzid); -typedef QUAD storage_size_t; +typedef QUAD storage_size_t; /* Should match the type of ZlssPool_s.ZP_BlksToSalvage */ #define PBT_FREESPACE_LOW_WATERMARK(_zlssPool_) \ ((((_zlssPool_)->ZLSSPOOLtotalBlocks * (_zlssPool_)->ZLSSPOOLlowWaterMark))/100) - + #define PBT_FREESPACE_HIGH_WATERMARK(_zlssPool_) \ ((((_zlssPool_)->ZLSSPOOLtotalBlocks * (_zlssPool_)->ZLSSPOOLhighWaterMark))/100) #define PBT_NUM_FREEBLKS(_zlssPool_) \ - (((_zlssPool_)->ZLSSPOOLtotalBlocks > (_zlssPool_)->ZLSSPOOLinUseBlocks) ? \ + (((_zlssPool_)->ZLSSPOOLtotalBlocks > (_zlssPool_)->ZLSSPOOLinUseBlocks) ? \ ((_zlssPool_)->ZLSSPOOLtotalBlocks - (_zlssPool_)->ZLSSPOOLinUseBlocks) : 0) extern STATUS ZLSSPOOL_VOL_MakeVolumeFreeSpace( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, void *zlssPool_LX, - BOOL purgeAllDeletedFiles, - BOOL asyncPurge, + BOOL purgeAllDeletedFiles, + BOOL asyncPurge, storage_size_t nblocks_needed); extern Time_t getOldestDeletedTime( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, ZfsVolume_s *zfsVol); #endif /* _PURGETREE_IF_H_ */ + diff --git a/src/nwnss/zlss/purgeTree_new.c b/src/nwnss/zlss/purgeTree_new.c index 333354c..04c9643 100644 --- a/src/nwnss/zlss/purgeTree_new.c +++ b/src/nwnss/zlss/purgeTree_new.c @@ -148,13 +148,13 @@ STATUS pbtUpgradeNode( STATIC SNINT pbtNewKeyComp( - void *k1_LX, - void *k2_LX) + void *k1_LX, + void *k2_LX) { - PurgeQNewKey_s *k1 = (PurgeQNewKey_s *)k1_LX; - PurgeQNewKey_s *k2 = (PurgeQNewKey_s *)k2_LX; + PurgeQNewKey_s *k1 = (PurgeQNewKey_s *)k1_LX; + PurgeQNewKey_s *k2 = (PurgeQNewKey_s *)k2_LX; SNINT diff; - + diff = KEY_COMP(k1->deltime, k2->deltime); if (diff != 0) return diff; diff = LB_GUIDCompare(&k1->internalID, &k2->internalID); @@ -168,30 +168,30 @@ STATIC SNINT pbtNewKeyComp( #if NSS_DEBUG IS_ENABLED STATIC void pbtDisplayKey( - NINT color, - void *key_LX ) + NINT color, + void *key_LX ) { - PurgeQNewKey_s *key = (PurgeQNewKey_s *)key_LX; + PurgeQNewKey_s *key = (PurgeQNewKey_s *)key_LX; DBG_DebugPrintf(color, MSGNot("0x%8x, 0x%Lx"), - key->deltime, - key->zid/* cnt, + key->deltime, + key->zid/* cnt, key->nameUniquifier*/); } STATIC void pbtDisplayValue( - NINT color, - void *value_LX) + NINT color, + void *value_LX) { - PurgeQNewValue_s *value = (PurgeQNewValue_s *)value_LX; + PurgeQNewValue_s *value = (PurgeQNewValue_s *)value_LX; DBG_DebugPrintf(color, MSGNot("0x%Lx"), value->pzid); } #endif void pbtSetZeroKey( - void *key_LX) + void *key_LX) { - PurgeQNewKey_s *key = (PurgeQNewKey_s *)key_LX; + PurgeQNewKey_s *key = (PurgeQNewKey_s *)key_LX; bzero((BYTE *)key, sizeof(PurgeQNewKey_s)); key->internalID = zINVALID_GUID; @@ -224,10 +224,10 @@ MYBTreeInstanceInfo_s PurgeTreeInfo = STATUS purgeq_insert_name( GeneralMsg_s *genMsg, ZfsPurgeTreeBeast_s *ztree, - Time_t deltime, + Time_t deltime, GUID_t *internalID, - Zid_t zid, -// cnt NINT nameUniquifier, + Zid_t zid, +// cnt NINT nameUniquifier, Zid_t pzid, Xaction_s *xAction) { @@ -240,27 +240,27 @@ STATUS purgeq_insert_name( key.deltime = deltime; key.internalID = *internalID; key.zid = zid; - key.reserved = 0; + key.reserved = 0; value.pzid = pzid; parms.treeInfo = &PurgeTreeInfo; - parms.xaction = (ZfsXaction_s *)xAction; - parms.volume = ztree->ZFSPURGETREEvolume; + parms.xaction = (ZfsXaction_s *)xAction; + parms.volume = ztree->ZFSPURGETREEvolume; parms.btreeBeast = ztree; parms.key = (MYBTKey_t)&key; parms.value = (MYBTValue_t)&value; - parms.updateCallback = NULL; + parms.updateCallback = NULL; - return MYBT_insertEntry(genMsg, &parms); + return MYBT_insertEntry(genMsg, &parms); } STATUS purgeq_delete_name( GeneralMsg_s *genMsg, ZfsPurgeTreeBeast_s *ztree, - Time_t deltime, + Time_t deltime, GUID_t *internalID, - Zid_t zid, -// cnt NINT nameUniquifier, + Zid_t zid, +// cnt NINT nameUniquifier, Zid_t pzid, Xaction_s *xAction) { @@ -275,23 +275,23 @@ STATUS purgeq_delete_name( value.pzid = pzid; parms.treeInfo = &PurgeTreeInfo; - parms.xaction = (ZfsXaction_s *)xAction; - parms.volume = ztree->ZFSPURGETREEvolume; + parms.xaction = (ZfsXaction_s *)xAction; + parms.volume = ztree->ZFSPURGETREEvolume; parms.btreeBeast = ztree; parms.key = (MYBTKey_t)&key; parms.value = (MYBTValue_t)&value; - parms.updateCallback = NULL; + parms.updateCallback = NULL; - return MYBT_deleteEntry(genMsg, &parms); + return MYBT_deleteEntry(genMsg, &parms); } STATUS purgeq_lookup_name( GeneralMsg_s *genMsg, ZfsPurgeTreeBeast_s *ztree, - Time_t deltime, + Time_t deltime, GUID_t *internalID, - Zid_t zid, -// cnt NINT nameUniquifier, + Zid_t zid, +// cnt NINT nameUniquifier, Zid_t pzid) { MYBTreeParms_s parms; @@ -305,14 +305,14 @@ STATUS purgeq_lookup_name( value.pzid = pzid; parms.treeInfo = &PurgeTreeInfo; - parms.xaction = 0; - parms.volume = ztree->ZFSPURGETREEvolume; + parms.xaction = 0; + parms.volume = ztree->ZFSPURGETREEvolume; parms.btreeBeast = ztree; parms.key = (MYBTKey_t)&key; parms.value = (MYBTValue_t)&value; - parms.updateCallback = NULL; + parms.updateCallback = NULL; - return MYBT_lookupEntry(genMsg, &parms); + return MYBT_lookupEntry(genMsg, &parms); } /* @@ -321,52 +321,52 @@ STATUS purgeq_lookup_name( */ STATIC STATUS doPurgeBeast( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, ZlssPool_s *zlssPool, PurgeNewInfo_s *pinfo) { STATUS rc; - ZfsVolume_s *zfsVol; - BOOL weSet = FALSE; + ZfsVolume_s *zfsVol; + BOOL weSet = FALSE; - /* Since we allow zAPI into internal volumes they - * can have purgeable space. We therefore must - * include in our search. - */ - if ( !(genMsg->flags & GM_FLAGS_INTERNAL_VOLUME) ) - { - COMN_INCLUDE_INTERNAL_VOLUMES( genMsg ); - weSet = TRUE; - } - zfsVol = ZLSS_VolumeIDLookup(genMsg, &pinfo->key.internalID, - TRUE, zlssPool->ZLSSPOOLzfsPool); - if ( weSet ) - { /* Reset only if we did the set */ - COMN_EXCLUDE_INTERNAL_VOLUMES( genMsg ); - } - if (zfsVol == NULL) - { - return zFAILURE; - } + /* Since we allow zAPI into internal volumes they + * can have purgeable space. We therefore must + * include in our search. + */ + if ( !(genMsg->flags & GM_FLAGS_INTERNAL_VOLUME) ) + { + COMN_INCLUDE_INTERNAL_VOLUMES( genMsg ); + weSet = TRUE; + } + zfsVol = ZLSS_VolumeIDLookup(genMsg, &pinfo->key.internalID, + TRUE, zlssPool->ZLSSPOOLzfsPool); + if ( weSet ) + { /* Reset only if we did the set */ + COMN_EXCLUDE_INTERNAL_VOLUMES( genMsg ); + } + if (zfsVol == NULL) + { + return zFAILURE; + } /* * Invoke common layer to purge the beast name identified by * tuple. */ - rc = BST_PurgeFileName(genMsg, &zfsVol->vol, pinfo->value.pzid, + rc = BST_PurgeFileName(genMsg, &zfsVol->vol, pinfo->value.pzid, pinfo->key.zid/* cnt, pinfo->key.nameUniquifier*/); COMN_Release(&zfsVol); if ((rc != zOK) && (GetErrno(genMsg) == zERR_ZID_NOT_FOUND)) { ZfsXaction_s *localXaction = - BeginXLocal(zlssPool->ZLSSPOOLpurgeTree->ZFSPURGETREEvolume, + BeginXLocal(zlssPool->ZLSSPOOLpurgeTree->ZFSPURGETREEvolume, BXL_DEFAULT); - /* No Beast found so deleting PT entry */ + /* No Beast found so deleting PT entry */ ClearErrno(genMsg); - rc = purgeq_delete_name(genMsg, zlssPool->ZLSSPOOLpurgeTree, + rc = purgeq_delete_name(genMsg, zlssPool->ZLSSPOOLpurgeTree, pinfo->key.deltime, &pinfo->key.internalID, pinfo->key.zid, - /* cnt pinfo->key.nameUniquifier,*/ pinfo->value.pzid, + /* cnt pinfo->key.nameUniquifier,*/ pinfo->value.pzid, (Xaction_s *)localXaction); /* Ignore the result of delete_name */ if (rc != zOK) @@ -382,7 +382,7 @@ doPurgeBeast( /**************************************************************************** * Find the next file to purge, whose deletion time has elapsed. * - * return: If found, + * return: If found, * returns the file's deletion time, zid, nameUniquifier, * pzid and zOK. * Note: We use the ZfsPurgeTreeBeast_s.zfsBtree.p.btFree field to hold the @@ -394,8 +394,8 @@ doPurgeBeast( STATIC STATUS make_freeSpace_common( - GeneralMsg_s *genMsg, - ZlssPool_s *zlssPool, + GeneralMsg_s *genMsg, + ZlssPool_s *zlssPool, // ZfsPool_s *pool, BOOL delete_by_time, /* Based on this flag, either */ Time_t delete_keep_time, /* Purge all files deleted at least @@ -404,18 +404,18 @@ make_freeSpace_common( { STATUS rc; ZfsPurgeTreeBeast_s *ztree = zlssPool->ZLSSPOOLpurgeTree; - MYBTreeParms_s parms; + MYBTreeParms_s parms; PurgeNewInfo_s purgeInfo; BOOL success = FALSE; ENTER(TZTREE, make_freeSpace_common); if (ztree == NULL) - { + { goto done; - } + } - if (! delete_by_time) + if (! delete_by_time) { #if 0 if (target_freeblks < PBT_FREESPACE_HIGH_WATERMARK(zlssPool)) @@ -441,7 +441,7 @@ make_freeSpace_common( purgeInfo.key.reserved = 0; parms.btreeBeast = ztree; parms.key = (MYBTKey_t)&purgeInfo.key; - parms.updateCallback = NULL; + parms.updateCallback = NULL; /* * Sequentially scan the linked list of leaf nodes for beasts to purge @@ -452,28 +452,28 @@ make_freeSpace_common( Time_t curtime; NINT numEntriesReturned; - /* Quit the loop if leaving active state or not in active state. */ - if ((zlssPool->ZLSSPOOLstate != zVOLSTATE_ACTIVE) || - (zlssPool->ZLSSPOOLstatusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP)) - { - /* success == FALSE, so this will return an error */ - goto done; - } + /* Quit the loop if leaving active state or not in active state. */ + if ((zlssPool->ZLSSPOOLstate != zVOLSTATE_ACTIVE) || + (zlssPool->ZLSSPOOLstatusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP)) + { + /* success == FALSE, so this will return an error */ + goto done; + } - curtime = GetUTCTime() - + curtime = GetUTCTime() - (delete_by_time ? delete_keep_time : zlssPool->ZLSSPOOLminKeepSeconds); - if (! delete_by_time) + if (! delete_by_time) { /* Check if we met our freeSpace target */ - if (PBT_NUM_FREEBLKS(zlssPool) >= target_freeblks) + if (PBT_NUM_FREEBLKS(zlssPool) >= target_freeblks) { success = TRUE; goto done; } } - rc = MYBT_browseEntries(genMsg, &parms, 1, (BYTE *)&purgeInfo, + rc = MYBT_browseEntries(genMsg, &parms, 1, (BYTE *)&purgeInfo, &numEntriesReturned); switch (rc) { @@ -482,7 +482,7 @@ make_freeSpace_common( case zERR_ZID_NOT_FOUND: success = delete_by_time; goto done; - default: + default: goto error_ret; } if (numEntriesReturned < 1) @@ -529,25 +529,25 @@ make_freeSpace_worker_thread( // ZfsPool_s *pool = STRUCT(fsm, ZfsPool_s, ZP_makeFreeSpaceFsm); ZlssPool_s *zlssPool = STRUCT(fsm, ZlssPool_s, ZP_MakeFreeSpaceFsm); storage_size_t target_freeblks; - storage_size_t min_freeblks = zlssPool->ZP_BlocksToSalvage + + storage_size_t min_freeblks = zlssPool->ZP_BlocksToSalvage + ZFS_RESERVED_BLOCKS_FOR_INTERNAL_ALLOCATION; COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); /* Convert into target freeSpace */ - target_freeblks = zlssPool->ZP_BlocksToSalvage + PBT_NUM_FREEBLKS(zlssPool); + target_freeblks = zlssPool->ZP_BlocksToSalvage + PBT_NUM_FREEBLKS(zlssPool); if (target_freeblks < min_freeblks) - { + { target_freeblks = min_freeblks; - } - DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, - MSGNot("make_freeSpace_worker_thread freeing %Ld blocks\n"), - target_freeblks)); + } + DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, + MSGNot("make_freeSpace_worker_thread freeing %Ld blocks\n"), + target_freeblks)); rc = make_freeSpace_common(&genMsg, zlssPool, FALSE, 0, target_freeblks); - DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, - MSGNot("make_freeSpace_worker_thread DONE\n"))); + DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, + MSGNot("make_freeSpace_worker_thread DONE\n"))); zlssPool->ZP_BlocksToSalvage = 0; - --(zlssPool->ZLSSPOOLkeepActiveUseCount); + --(zlssPool->ZLSSPOOLkeepActiveUseCount); } /* @@ -564,48 +564,48 @@ make_freeSpace_worker_thread( */ STATIC BOOL make_freeSpace_async( - ZlssPool_s *zlssPool, + ZlssPool_s *zlssPool, storage_size_t nblks_needed) { storage_size_t freespace_high, freespace_low, new_freeSpace; if (zlssPool->ZP_BlocksToSalvage > 0) - { /* Thread is already running */ - DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, - MSGNot("make_freespace_async thread already running\n"))); + { /* Thread is already running */ + DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, + MSGNot("make_freespace_async thread already running\n"))); return FALSE; - } + } freespace_low = PBT_FREESPACE_LOW_WATERMARK(zlssPool); new_freeSpace = PBT_NUM_FREEBLKS(zlssPool) - nblks_needed; if (new_freeSpace >= freespace_low) - { /* Request does not cause us to meet our 'minimum - * number of blocks that must be free at any given - * moment' requirement. I.E. we do not need to - * start our purge thread to free purgable blocks - * because we are ABOVE our low water mark of free blocks. - */ + { /* Request does not cause us to meet our 'minimum + * number of blocks that must be free at any given + * moment' requirement. I.E. we do not need to + * start our purge thread to free purgable blocks + * because we are ABOVE our low water mark of free blocks. + */ // DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, // MSGNot("HAPPY space = %Ld lowmark = %Ld\n"), // new_freeSpace,freespace_low)); return FALSE; - } + } - /* Calculate the number of blocks needed to be - * freed to enable us to be at our high water mark. - */ + /* Calculate the number of blocks needed to be + * freed to enable us to be at our high water mark. + */ freespace_high = PBT_FREESPACE_HIGH_WATERMARK(zlssPool); zlssPool->ZP_BlocksToSalvage = freespace_high - new_freeSpace; if (nblks_needed > zlssPool->ZP_BlocksToSalvage) - { + { zlssPool->ZP_BlocksToSalvage = nblks_needed; - } - DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, - MSGNot("make_freespace_async thread starting\n"))); + } + DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, + MSGNot("make_freespace_async thread starting\n"))); ++(zlssPool->ZLSSPOOLkeepActiveUseCount); - WORK_Schedule(&zlssPool->ZP_MakeFreeSpaceFsm, - (voidfunc_t)make_freeSpace_worker_thread, 0); + WORK_Schedule(&zlssPool->ZP_MakeFreeSpaceFsm, + make_freeSpace_worker_thread, 0); return TRUE; } @@ -632,13 +632,13 @@ make_freeSpace_async( STATUS ZLSSPOOL_VOL_MakeVolumeFreeSpace( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, void *zlssPool_LX, - BOOL purgeAllDeletedFiles, - BOOL asyncPurge, + BOOL purgeAllDeletedFiles, + BOOL asyncPurge, storage_size_t nblks_needed) { - ZlssPool_s *zlssPool = (ZlssPool_s *)zlssPool_LX; + ZlssPool_s *zlssPool = (ZlssPool_s *)zlssPool_LX; storage_size_t target_freeblks; storage_size_t min_freeblks; @@ -647,99 +647,99 @@ ZLSSPOOL_VOL_MakeVolumeFreeSpace( if (asyncPurge) { - if ( zlssPool->ZP_Version >= - (AIPU_LV_MEDIA_MAJOR*0x100L+AIPU_LV_STEP_4_DONE) ) - { /* Caller wanted ASYNC and we are NOT doing AIPU */ - (void) make_freeSpace_async(zlssPool, nblks_needed); - return zOK; - } - else - { /* LV AIPU does not like purge thread to go ASYNC as - * LV AIPU may be counting blocks in some of the system trees. - * If these trees are changing then some of our counts - * will be off. - * July 25, 2001. Changed so to skip purging if we have - * enough free blocks. This is different than check in - * make_freeSpace_async as it will purge if we are below - * salvage low water mark. - */ - storage_size_t freeBlocks; + if ( zlssPool->ZP_Version >= + (AIPU_LV_MEDIA_MAJOR*0x100L+AIPU_LV_STEP_4_DONE) ) + { /* Caller wanted ASYNC and we are NOT doing AIPU */ + (void) make_freeSpace_async(zlssPool, nblks_needed); + return zOK; + } + else + { /* LV AIPU does not like purge thread to go ASYNC as + * LV AIPU may be counting blocks in some of the system trees. + * If these trees are changing then some of our counts + * will be off. + * July 25, 2001. Changed so to skip purging if we have + * enough free blocks. This is different than check in + * make_freeSpace_async as it will purge if we are below + * salvage low water mark. + */ + storage_size_t freeBlocks; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( MAGENTA, - MSGNot("ZLSSPOOL_VOL_MakeVolumeFreeSpace called ASYNC during LV AIPU converting to SYNC call\n")); + DBG_DebugPrintf( MAGENTA, + MSGNot("ZLSSPOOL_VOL_MakeVolumeFreeSpace called ASYNC during LV AIPU converting to SYNC call\n")); #endif - freeBlocks = PBT_NUM_FREEBLKS(zlssPool); - if ( freeBlocks >= (nblks_needed + 1024) ) - { /* Have enough free blocks so no purge. During LV AIPU - * we try to avoid purge because we can deadlock. E.G. - * if LV AIPU is creating a file which causes a split - * in the BT which ask purge to purge a file in the - * same BT Leaf that the split has lock we deadlock. - * I saw this on a volume with 12 files of which 8 are - * deleted. - * - * The 1024 is so that we reduce the chance that we - * MUST have the purge succeed for a block to be allocated. - * If we get to this point then we could deadlock as - * above. - */ + freeBlocks = PBT_NUM_FREEBLKS(zlssPool); + if ( freeBlocks >= (nblks_needed + 1024) ) + { /* Have enough free blocks so no purge. During LV AIPU + * we try to avoid purge because we can deadlock. E.G. + * if LV AIPU is creating a file which causes a split + * in the BT which ask purge to purge a file in the + * same BT Leaf that the split has lock we deadlock. + * I saw this on a volume with 12 files of which 8 are + * deleted. + * + * The 1024 is so that we reduce the chance that we + * MUST have the purge succeed for a block to be allocated. + * If we get to this point then we could deadlock as + * above. + */ #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( MAGENTA, - MSGNot("ZLSSPOOL_VOL_MakeVolumeFreeSpace LV AIPU ASYNC not needed as have enough free blocks\n")); + DBG_DebugPrintf( MAGENTA, + MSGNot("ZLSSPOOL_VOL_MakeVolumeFreeSpace LV AIPU ASYNC not needed as have enough free blocks\n")); #endif - return zOK; - } - /* July 25, 2001. We must go ASYNC or we may deadlock - * see above. Since we NEED blocks we must purge. - */ + return zOK; + } + /* July 25, 2001. We must go ASYNC or we may deadlock + * see above. Since we NEED blocks we must purge. + */ #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf( MAGENTA, - MSGNot("ZLSSPOOL_VOL_MakeVolumeFreeSpace LV AIPU going ASYNC.\n")); + DBG_DebugPrintf( MAGENTA, + MSGNot("ZLSSPOOL_VOL_MakeVolumeFreeSpace LV AIPU going ASYNC.\n")); #endif - (void) make_freeSpace_async(zlssPool, nblks_needed); - LB_delay( 2000 ); /* Give purge some time to run. This will - * make call look sync to LV AIPU if sleeping - * thread does not own resources that purge - * needs. - */ - return zOK; - } - } + (void) make_freeSpace_async(zlssPool, nblks_needed); + LB_delay( 2000 ); /* Give purge some time to run. This will + * make call look sync to LV AIPU if sleeping + * thread does not own resources that purge + * needs. + */ + return zOK; + } + } /* Convert into target freeSpace */ min_freeblks = nblks_needed + ZFS_RESERVED_BLOCKS_FOR_INTERNAL_ALLOCATION; target_freeblks = nblks_needed + PBT_NUM_FREEBLKS(zlssPool); if (target_freeblks < min_freeblks) - { + { target_freeblks = min_freeblks; - } + } return make_freeSpace_common(genMsg, zlssPool, purgeAllDeletedFiles, (Time_t)0, target_freeblks); } /* End of ZLSSPOOL_VOL_MakeVolumeFreeSpace */ -/* +/* * This function returns the oldest delete time in the pool. It was decided * that this would be O.K. for Logical Volumes. Brenda and Oly said that no one - * really looks at this value. + * really looks at this value. */ Time_t getOldestDeletedTime( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, ZfsVolume_s *zfsVol) { STATUS rc; ZfsPurgeTreeBeast_s *ztree = zfsVol->ZFSVOLpurgeTree; - MYBTreeParms_s parms; + MYBTreeParms_s parms; PurgeNewInfo_s purgeInfo; NINT numEntriesReturned; ENTER(TZTREE, getOldestDeletedTime); if (ztree == NULL) - { + { rc = zERR_ZID_NOT_FOUND; goto error_ret; - } + } /* Get the leftmost leaf's first entry */ parms.treeInfo = &PurgeTreeInfo; @@ -750,12 +750,12 @@ getOldestDeletedTime( purgeInfo.key.reserved = 0; parms.btreeBeast = ztree; parms.key = (MYBTKey_t)&purgeInfo.key; - parms.updateCallback = NULL; + parms.updateCallback = NULL; - rc = MYBT_browseEntries(genMsg, &parms, 1, (BYTE *)&purgeInfo, + rc = MYBT_browseEntries(genMsg, &parms, 1, (BYTE *)&purgeInfo, &numEntriesReturned); error_ret: ; - if (rc != zOK || (numEntriesReturned < 1)) + if (rc != zOK || (numEntriesReturned < 1)) { ClearErrno(genMsg); RTN_NINT(INVALID_UTC_TIME); @@ -789,40 +789,40 @@ void ZfsDisplayPurgeTreeNew( printf(MSG("Volume not found.\n", 427)); } COMN_Release(&volume); - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); } #endif /* NSS_DEBUG */ STATUS pbt_internalRecoveryCommon( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action) + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action) { - return MYBT_CALL_INTERNAL_RECOVERY_FUNC(genMsg, &PurgeTreeInfo, pool, + return MYBT_CALL_INTERNAL_RECOVERY_FUNC(genMsg, &PurgeTreeInfo, pool, logBuffer, action); } STATUS pbt_logicalRecoveryCommon( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action) + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action) { - if (action == X_UNDO) - { - return zX_LOGICAL; - } - else if (action == X_L_UNDO) - { - return MYBT_CALL_LOGICAL_RECOVERY_FUNC(genMsg, &PurgeTreeInfo, + if (action == X_UNDO) + { + return zX_LOGICAL; + } + else if (action == X_L_UNDO) + { + return MYBT_CALL_LOGICAL_RECOVERY_FUNC(genMsg, &PurgeTreeInfo, pool, pool->purgeTree, logBuffer, action); - } - else - { - /* During REDO we do not have a purgeTree in memory yet */ - zASSERT(action == X_REDO); - return MYBT_CALL_LOGICAL_RECOVERY_FUNC(genMsg, &PurgeTreeInfo, - pool, NULL, logBuffer, action); - } + } + else + { + /* During REDO we do not have a purgeTree in memory yet */ + zASSERT(action == X_REDO); + return MYBT_CALL_LOGICAL_RECOVERY_FUNC(genMsg, &PurgeTreeInfo, + pool, NULL, logBuffer, action); + } } diff --git a/src/nwnss/zlss/purgeTree_new.h b/src/nwnss/zlss/purgeTree_new.h index c6bccc4..1b3e345 100644 --- a/src/nwnss/zlss/purgeTree_new.h +++ b/src/nwnss/zlss/purgeTree_new.h @@ -90,9 +90,9 @@ extern MYBTreeInstanceInfo_s PurgeTreeInfo; #if NSS_DEBUG IS_ENABLED void ZfsDisplayPurgeTreeNew( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); #define zfsDisplayPurgeTreeNewNode(_location, _nameOfBuffer, _buffer) \ MYBT_displayNode(&PurgeTreeInfo, _location, _nameOfBuffer, _buffer) diff --git a/src/nwnss/zlss/qdiv.c b/src/nwnss/zlss/qdiv.c new file mode 100644 index 0000000..dad1a90 --- /dev/null +++ b/src/nwnss/zlss/qdiv.c @@ -0,0 +1,412 @@ +/**************************************************************************** + | + |*************************************************************************** + | + | Novell Storage Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $ + | + | $RCSfile$ + | $Revision: 1325 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Implement the quad division functions + +-------------------------------------------------------------------------*/ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Multiprecision divide. This algorithm is from Knuth vol. 2 (2nd ed), + * section 4.3.1, pp. 257--259. + */ + +#include +//#include +//#include +//#include +//#include + +/* + * Depending on the desired operation, we view a `long long' (aka SQUAD) in + * one or more of the following formats. + */ +union uu { + SQUAD q; /* as a (signed) quad */ + SQUAD uq; /* as an unsigned quad */ + SLONG sl[2]; /* as two signed longs */ + LONG ul[2]; /* as two unsigned longs */ +}; + +/* + * Define high and low longwords. + */ + +#define H 1 +#define L 0 + +/* + * Total number of bits in a SQUAD and in the pieces that make it up. + * These are used for shifting, and also below for halfword extraction + * and assembly. + */ +#define CHAR_BIT 8 +#define QUAD_BITS (sizeof(SQUAD) * CHAR_BIT) +#define LONG_BITS (sizeof(SLONG) * CHAR_BIT) +#define HALF_BITS (sizeof(SLONG) * CHAR_BIT / 2) + +/* + * Extract high and low shortwords from longword, and move low shortword of + * longword to upper half of long, i.e., produce the upper longword of + * ((SQUAD)(x) << (number_of_bits_in_long/2)). (`x' must actually be LONG.) + * + * These are used in the multiply code, to split a longword into upper + * and lower halves, and to reassemble a product as a SQUAD, shifted left + * (sizeof(long)*CHAR_BIT/2). + */ +#define HHALF(x) ((x) >> HALF_BITS) +#define LHALF(x) ((x) & ((1 << HALF_BITS) - 1)) +#define LHUP(x) ((x) << HALF_BITS) + + typedef unsigned int qshift_t; + + + +#define B (1 << HALF_BITS) /* digit base */ + +/* Combine two `digits' to make a single two-digit number. */ +#define COMBINE(_a, _b) (((LONG)(_a) << HALF_BITS) | (_b)) + +/* select a type for digits in base B: use unsigned short if they fit */ +//Brenda +//#if ULONG_MAX == 0xffffffff && USHRT_MAX >= 0xffff +//typedef unsigned short digit; +//#else +typedef LONG digit; +//#endif + +/* + * Shift p[0]..p[len] left `sh' bits, ignoring any bits that + * `fall out' the left (there never will be any such anyway). + * We may assume len >= 0. NOTE THAT THIS WRITES len+1 DIGITS. + */ +static void shl( + register digit *p, + register int len, + register int sh) +{ + register int i; + + for (i = 0; i < len; i++) + p[i] = LHALF(p[i] << sh) | (p[i + 1] >> (HALF_BITS - sh)); + p[i] = LHALF(p[i] << sh); +} + +/* + * __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v. + * + * We do this in base 2-sup-HALF_BITS, so that all intermediate products + * fit within LONG. As a consequence, the maximum length dividend and + * divisor are 4 `digits' in this base (they are shorter if they have + * leading zeros). + */ +QUAD __qdivrem( + QUAD uq, + QUAD vq, + QUAD *arq) +{ + union uu tmp; + digit *u, *v, *q; + register digit v1, v2; + LONG qhat, rhat, t; + int m, n, d, j, i; + digit uspace[5], vspace[5], qspace[5]; + +/* + * Take care of special cases: divide by zero, and u < v. + */ + if (vq == 0) { + /* divide by zero. */ + static volatile const unsigned int zero = 0; + + tmp.ul[H] = tmp.ul[L] = 1 / zero; + if (arq) + *arq = uq; + return (tmp.q); + } + if (uq < vq) { + if (arq) + *arq = uq; + return (0); + } + u = &uspace[0]; + v = &vspace[0]; + q = &qspace[0]; + +/* + * Break dividend and divisor into digits in base B, then + * count leading zeros to determine m and n. When done, we + * will have: + * u = (u[1]u[2]...u[m+n]) sub B + * v = (v[1]v[2]...v[n]) sub B + * v[1] != 0 + * 1 < n <= 4 (if n = 1, we use a different division algorithm) + * m >= 0 (otherwise u < v, which we already checked) + * m + n = 4 + * and thus + * m = 4 - n <= 2 + */ + tmp.uq = uq; + u[0] = 0; + u[1] = HHALF(tmp.ul[H]); + u[2] = LHALF(tmp.ul[H]); + u[3] = HHALF(tmp.ul[L]); + u[4] = LHALF(tmp.ul[L]); + tmp.uq = vq; + v[1] = HHALF(tmp.ul[H]); + v[2] = LHALF(tmp.ul[H]); + v[3] = HHALF(tmp.ul[L]); + v[4] = LHALF(tmp.ul[L]); + for (n = 4; v[1] == 0; v++) { + if (--n == 1) { + LONG rbj; /* r*B+u[j] (not root boy jim) */ + digit q1, q2, q3, q4; + +/* + * Change of plan, per exercise 16. + * r = 0; + * for j = 1..4: + * q[j] = floor((r*B + u[j]) / v), + * r = (r*B + u[j]) % v; + * We unroll this completely here. + */ + t = v[2]; /* nonzero, by definition */ + q1 = u[1] / t; + rbj = COMBINE(u[1] % t, u[2]); + q2 = rbj / t; + rbj = COMBINE(rbj % t, u[3]); + q3 = rbj / t; + rbj = COMBINE(rbj % t, u[4]); + q4 = rbj / t; + if (arq) + *arq = rbj % t; + tmp.ul[H] = COMBINE(q1, q2); + tmp.ul[L] = COMBINE(q3, q4); + return (tmp.q); + } + } + +/* + * By adjusting q once we determine m, we can guarantee that + * there is a complete four-digit quotient at &qspace[1] when + * we finally stop. + */ + for (m = 4 - n; u[1] == 0; u++) + m--; + for (i = 4 - m; --i >= 0;) + q[i] = 0; + q += 4 - m; + +/* + * Here we run Program D, translated from MIX to C and acquiring + * a few minor changes. + * + * * D1: choose multiplier 1 << d to ensure v[1] >= B/2. + */ + d = 0; + for (t = v[1]; t < B / 2; t <<= 1) + d++; + if (d > 0) { + shl(&u[0], m + n, d); /* u <<= d */ + shl(&v[1], n - 1, d); /* v <<= d */ + } +/* + * D2: j = 0. + */ + j = 0; + v1 = v[1]; /* for D3 -- note that v[1..n] are constant */ + v2 = v[2]; /* for D3 */ + do { + register digit uj0, uj1, uj2; + +/* + * D3: Calculate qhat (\^q, in TeX notation). + * Let qhat = min((u[j]*B + u[j+1])/v[1], B-1), and + * let rhat = (u[j]*B + u[j+1]) mod v[1]. + * While rhat < B and v[2]*qhat > rhat*B+u[j+2], + * decrement qhat and increase rhat correspondingly. + * Note that if rhat >= B, v[2]*qhat < rhat*B. + */ + uj0 = u[j + 0]; /* for D3 only -- note that u[j+...] change */ + uj1 = u[j + 1]; /* for D3 only */ + uj2 = u[j + 2]; /* for D3 only */ + if (uj0 == v1) { + qhat = B; + rhat = uj1; + goto qhat_too_big; + } else { + LONG nn = COMBINE(uj0, uj1); + qhat = nn / v1; + rhat = nn % v1; + } + while (v2 * qhat > COMBINE(rhat, uj2)) { +qhat_too_big: + qhat--; + if ((rhat += v1) >= B) + break; + } +/* + * D4: Multiply and subtract. + * The variable `t' holds any borrows across the loop. + * We split this up so that we do not require v[0] = 0, + * and to eliminate a final special case. + */ + for (t = 0, i = n; i > 0; i--) { + t = u[i + j] - v[i] * qhat - t; + u[i + j] = LHALF(t); + t = (B - HHALF(t)) & (B - 1); + } + t = u[j] - t; + u[j] = LHALF(t); +/* + * D5: test remainder. + * There is a borrow if and only if HHALF(t) is nonzero; + * in that (rare) case, qhat was too large (by exactly 1). + * Fix it by adding v[1..n] to u[j..j+n]. + */ + if (HHALF(t)) { + qhat--; + for (t = 0, i = n; i > 0; i--) { /* D6: add back. */ + t += u[i + j] + v[i]; + u[i + j] = LHALF(t); + t = HHALF(t); + } + u[j] = LHALF(u[j] + t); + } + q[j] = qhat; + } while (++j <= m); /* D7: loop on j. */ + +/* + * If caller wants the remainder, we have to calculate it as + * u[m..m+n] >> d (this is at most n digits and thus fits in + * u[m+1..m+n], but we may need more source digits). + */ + if (arq) { + if (d) { + for (i = m + n; i > m; --i) + u[i] = (u[i] >> d) | LHALF(u[i - 1] << (HALF_BITS - d)); + u[i] = 0; + } + tmp.ul[H] = COMBINE(uspace[1], uspace[2]); + tmp.ul[L] = COMBINE(uspace[3], uspace[4]); + *arq = tmp.q; + } + + tmp.ul[H] = COMBINE(qspace[1], qspace[2]); + tmp.ul[L] = COMBINE(qspace[3], qspace[4]); + return (tmp.q); +} + +/* + * Return remainder after dividing two unsigned quads. + */ +QUAD __umoddi3( + QUAD a, + QUAD b) +{ + QUAD r; + + (void)__qdivrem(a, b, &r); + return (r); +} + +/* + * Divide two unsigned quads. + */ +QUAD __udivdi3( + QUAD a, + QUAD b) +{ + return (__qdivrem(a, b, (QUAD *)0)); +} + +/* + * Return remainder after dividing two signed quads. + * + * If -1/2 should produce -1 on this machine, this code is wrong. + */ +SQUAD __moddi3( + QUAD a, + QUAD b) +{ + QUAD ua, ub, ur; + int neg; + + if (a < 0) + ua = -(QUAD)a, neg = 1; + else + ua = a, neg = 0; + if (b < 0) + ub = -(QUAD)b; + else + ub = b; + (void)__qdivrem(ua, ub, &ur); + return (neg ? -ur : ur); +} + +/* + * Divide two signed quads./* + * if -1/2 should produce -1 on this machine, this code is wrong/* + */ +SQUAD __divdi3( + QUAD a, + QUAD b) +{ + QUAD ua, ub, uq; + int neg; + + if (a < 0) + ua = -(QUAD)a, neg = 1; + else + ua = a, neg = 0; + if (b < 0) + ub = -(QUAD)b, neg ^= 1; + else + ub = b; + uq = __qdivrem(ua, ub, (QUAD *)0); + return (neg ? -uq : uq); +} diff --git a/src/nwnss/zlss/repairBtree.c b/src/nwnss/zlss/repairBtree.c index b77de10..fce88e0 100644 --- a/src/nwnss/zlss/repairBtree.c +++ b/src/nwnss/zlss/repairBtree.c @@ -38,7 +38,7 @@ #include #include #include - + #include #include #include @@ -215,7 +215,7 @@ STATIC void ZVP_BT_missingBeastParentEntsRecord( BTStats_s *btStats, Zid_t zid, dVar[rGS->RGS_NumberOfElements].BMBPE_Zid = zid; dVar[rGS->RGS_NumberOfElements].BMBPE_PZid = pZid; dVar[rGS->RGS_NumberOfElements].BMBPE_Status = error; - RAV_CopyRightSideOfWhere( dVar[rGS->RGS_NumberOfElements].BMBPE_Setter, where, + RAV_CopyRightSideOfWhere( dVar[rGS->RGS_NumberOfElements].BMBPE_Setter, where, sizeof(dVar[rGS->RGS_NumberOfElements].BMBPE_Setter) ); ++rGS->RGS_NumberOfElements; } @@ -405,7 +405,7 @@ LONG lookUpZidInNameTree(GeneralMsg_s *genMsg, RootBeast_s *file, Zid_t zid, NIN if ( !COMN_IsDerivedFrom(file, zFTYPE_NAMED_DATA_STREAM) ) { /* No 'report' code here as only time we report this error is when caller expects it */ #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(GREEN,MSGNot("ZID not derived from zFTYPE_NAMED_DATA_STREAM (ZID 0x%Lx(%Ld))\n"),zid,zid); + DBG_DebugPrintf(GREEN,MSGNot("ZID not derived from zFTYPE_NAMED_DATA_STREAM (ZID 0x%Lx(%Ld))\n"),zid,zid); #endif //g COMN_UnlatchAndRelease(&file, SLATCHED); SetErrno( genMsg, zERR_RAV_NOT_NAMED_DATA_STREAM ); @@ -420,7 +420,7 @@ LONG lookUpZidInNameTree(GeneralMsg_s *genMsg, RootBeast_s *file, Zid_t zid, NIN { BTStats->numSalvagableObjects_OptValid++; - if (COMN_GetPurgeableBlksCnt(genMsg, file, &purgeableBlks) != zOK) + if (COMN_GetPurgeableBlksCnt(genMsg, file, &purgeableBlks) != zOK) { ClearErrno(genMsg); zASSERT("We don't expect to see this either" == NULL); @@ -475,7 +475,7 @@ LONG lookUpZidInNameTree(GeneralMsg_s *genMsg, RootBeast_s *file, Zid_t zid, NIN is is in the mask and avoide problems with the unix case sensitive stuff */ } - nSpaceCount++; + nSpaceCount++; } } if(nSpaceCount !=0) @@ -572,7 +572,7 @@ LONG lookUpZidInNameTree(GeneralMsg_s *genMsg, RootBeast_s *file, Zid_t zid, NIN if(nentry->p.nameSpaceMask & nSpaceFlag) { nSpaceID = i; - nSpaceCount++; + nSpaceCount++; } } if(nSpaceCount !=0) @@ -588,7 +588,7 @@ LONG lookUpZidInNameTree(GeneralMsg_s *genMsg, RootBeast_s *file, Zid_t zid, NIN // cnt zFNU_UNDEFINED, &nameUniquifier, &aStack->retInfo); - if (nzid == zid) + if (nzid == zid) { if (aStack->retInfo.nameSpaceMask == nentry->p.nameSpaceMask) { @@ -646,8 +646,8 @@ LONG lookUpZidInNameTree(GeneralMsg_s *genMsg, RootBeast_s *file, Zid_t zid, NIN { BTStats->numBeastOrphanedEnts_OptValid++; if (orphanedCount == parentCount) - { - BTStats->numBeastTotallyOrphaned_OptValid++; + { + BTStats->numBeastTotallyOrphaned_OptValid++; } } if(*numEnts != *foundEnts) @@ -659,7 +659,7 @@ LONG lookUpZidInNameTree(GeneralMsg_s *genMsg, RootBeast_s *file, Zid_t zid, NIN #if NSS_DEBUG IS_ENABLED if ( *numEnts == 0) { - DBG_DebugPrintf(LRED,MSGNot("ZID 0x%Lx(%Ld) is derived from zFTYPE_NAMED_DATA_STREAM, but has no names\n"),zid,zid); + DBG_DebugPrintf(LRED,MSGNot("ZID 0x%Lx(%Ld) is derived from zFTYPE_NAMED_DATA_STREAM, but has no names\n"),zid,zid); // ZOS_EnterDebugger(); } #endif @@ -1154,7 +1154,7 @@ BOOL ZVP_LVNeedsVerification( ZlssVolumeLocator_s *lvBeast ) { // FixFixFix(ZVP,12,.25) - why these checks??? return FALSE; } - if( (lvBeast->ZVL_p.PZVL_state == PZVL_S_CREATION_DELETE) || + if( (lvBeast->ZVL_p.PZVL_state == PZVL_S_CREATION_DELETE) || (lvBeast->ZVL_p.PZVL_state == PZVL_S_CREATION) ) { // Logical Volume Not Totally Created, Verify will skip it return( FALSE ); @@ -1265,18 +1265,18 @@ STATUS ZVP_verifyLogicalVolume(GeneralMsg_s *genMsg, VerifyStats_s *vStats, Zlss } if (zVolume->mfl != NULL) { - rootBlocks.mflRootBlock = zVolume->mfl->ZFSMFLbtRoot; + rootBlocks.mflRootBlock = zVolume->mfl->ZFSMFLbtRoot; } if (zVolume->eflTree != NULL) { - rootBlocks.eflRootBlock = zVolume->eflTree->ZFSEFLTREEbtRoot; + rootBlocks.eflRootBlock = zVolume->eflTree->ZFSEFLTREEbtRoot; } if ( zVolume->ZV_volumePurgeLog != NULL ) { - rootBlocks.vplRootBlock = zVolume->ZV_volumePurgeLog->p.firstBlock; + rootBlocks.vplRootBlock = zVolume->ZV_volumePurgeLog->p.firstBlock; } - rootBlocks.vlbplRootBlock = lvBeast->ZVL_p.PZVL_purgeLogBlocks; + rootBlocks.vlbplRootBlock = lvBeast->ZVL_p.PZVL_purgeLogBlocks; savedZid = vStats->VS_zid; CBS_Save( vStats, &saveCBS ); @@ -1316,13 +1316,13 @@ ZVP_ERROR ZVP_visitLeaf( BeastTreeNode_s *node, Blknum_t blknum, VerifyStats_s * //g BTStats->numBeastTreeLevels = BTStats->BTLevelCount; savedZid = vStats->VS_zid; //l numNon3030Recs = node->numRecs; - + /* Visit each beast record in the leaf node */ for (i = 0; i < node->numRecs; i++) { // validate has ensured that znode is within the block. znode = (Znode_s *)&node->LEAF.znode[node->LEAF.znodePtr[MAX_LEAF_PTRS - i]]; if ( znode->header.magic == 0x3030 ) - { // We must not process the NULL entry + { // We must not process the NULL entry //l --numNon3030Recs; if ( vStats->action == BMP_TST_EXTENT ) { @@ -1382,7 +1382,7 @@ ZVP_ERROR ZVP_visitLeaf( BeastTreeNode_s *node, Blknum_t blknum, VerifyStats_s * // BTStats->numUnreadableZids++; #endif #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("Unreadable Beast ==> ID = 0x%x, Zid = 0x%Lx\n"), + DBG_DebugPrintf(LRED,MSGNot("Unreadable Beast ==> ID = 0x%x, Zid = 0x%Lx\n"), znode->header.type, znode->header.zid); #endif if ( vStats->action == BMP_TST_EXTENT ) @@ -1434,7 +1434,7 @@ ZVP_ERROR ZVP_visitLeaf( BeastTreeNode_s *node, Blknum_t blknum, VerifyStats_s * BTStats->numDirCount++; else BTStats->numFileCount++; - + //mfl This did not do anything in original code so removed. //mfl if (MFL_ENABLED(volume)) //mfl { @@ -1476,7 +1476,7 @@ ZVP_ERROR ZVP_visitLeaf( BeastTreeNode_s *node, Blknum_t blknum, VerifyStats_s * else /* should NOT be in name tree */ { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("NonNameTree Beast ==> ID = 0x%x, Zid = 0x%Lx\n"), + DBG_DebugPrintf(LRED,MSGNot("NonNameTree Beast ==> ID = 0x%x, Zid = 0x%Lx\n"), znode->header.type, znode->header.zid); #endif BTStats->numNonNameTreeZids++; @@ -1522,7 +1522,7 @@ ZVP_ERROR ZVP_visitLeaf( BeastTreeNode_s *node, Blknum_t blknum, VerifyStats_s * else { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERROR: Logical volume locator beast found on a logical volume!\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERROR: Logical volume locator beast found on a logical volume!\n")); #endif } } @@ -1546,7 +1546,7 @@ ZVP_ERROR ZVP_visitLeaf( BeastTreeNode_s *node, Blknum_t blknum, VerifyStats_s * // BTStats->numUnreadableZids++; #endif #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("Unreadable Beast ==> Error = %d, ID = 0x%x, Zid = 0x%Lx\n"), + DBG_DebugPrintf(LRED,MSGNot("Unreadable Beast ==> Error = %d, ID = 0x%x, Zid = 0x%Lx\n"), (signed int)vStats->VS_Common.RAVS_GenMsg.errStatus, znode->header.type, znode->header.zid); #endif @@ -1579,7 +1579,7 @@ ZVP_ERROR ZVP_visitLeaf( BeastTreeNode_s *node, Blknum_t blknum, VerifyStats_s * else { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERROR: Logical volume locator beast found on a logical volume!\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERROR: Logical volume locator beast found on a logical volume!\n")); #endif } } @@ -1634,9 +1634,9 @@ ZVP_ERROR ZVP_visitNode(BeastTreeNode_s *node, Blknum_t blknum, VerifyStats_s *v if ( !BeastNode_valid(node, blknum, vStats, BTStats) ) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot(">>>>Invalid Beast tree node %d\n"),blknum); - DBG_DebugPrintf(LRED,MSGNot(" >>Current BT level %d\n"),vStats->VS_cBS->CBS_LevelCurrent); - DBG_DebugPrintf(LRED,MSGNot(" >>MAX BT level %d\n"),vStats->VS_cBS->CBS_LevelMaximum); + DBG_DebugPrintf(LRED,MSGNot(">>>>Invalid Beast tree node %d\n"),blknum); + DBG_DebugPrintf(LRED,MSGNot(" >>Current BT level %d\n"),vStats->VS_cBS->CBS_LevelCurrent); + DBG_DebugPrintf(LRED,MSGNot(" >>MAX BT level %d\n"),vStats->VS_cBS->CBS_LevelMaximum); #endif ccode = zOK; goto VISIT_DONE; @@ -1676,7 +1676,7 @@ ZVP_ERROR ZVP_visitNode(BeastTreeNode_s *node, Blknum_t blknum, VerifyStats_s *v break; case FIND_BLOCK: break; - } + } for (i = 0; i < node->numRecs; i++) { @@ -1728,7 +1728,7 @@ ZVP_ERROR ZVP_visitNode(BeastTreeNode_s *node, Blknum_t blknum, VerifyStats_s *v } } ccode = zOK; - + VISIT_DONE: CBS_LevelUp( vStats->VS_cBS ); // BTStats->BTLevelCount--; @@ -1753,8 +1753,8 @@ ZVP_ERROR ZVP_FlushVolVolumeBuffers(ZfsVolume_s *zfsVol) { GeneralMsg_s dummyGenMsg; NINT i; - - COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); + + COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); /* Warning - Compfix.nlm calls uses this function. @@ -1789,7 +1789,7 @@ ZVP_ERROR ZVP_FlushVolVolumeBuffers(ZfsVolume_s *zfsVol) } /* End of ZVP_FlushVolVolumeBuffers() */ -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- COMPFIX_verify_FlushVolVolumeBuffers This is the function exported and used by \testing\nlms\compfix to adjust volume's compression statistics while volume is in the @@ -1816,8 +1816,8 @@ void ZVP_FlushPoolVolumeBuffers(ZfsPool_s *pool) { GeneralMsg_s dummyGenMsg; NINT i; - - COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); + + COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); for ( i=0; i < 600; i++ ) { @@ -1859,7 +1859,7 @@ void ZVP_LVStatsVolumeLoaded( ZVP_LVData_s *lvData, ZfsVolume_s *zVolume ) ZVP_playLogicalVolumePurgeLog() - Ready logical volume for playing purge log and play it. - Notes - + Notes - It is VERY important that we are able to load the volume so that we can verify the LV. Therefore, all errors in this routine will result in termination of verify. This enables the user to address @@ -2063,7 +2063,7 @@ ZVP_ERROR ZVP_playAllPurgeLogsVisitNode(BeastTreeNode_s *node, Blknum_t blknum, // ccode = zERR_RAV_CORRUPT_LOCATOR_BEAST; // FixFixFix(ZVPFixed,2) - DO we really want this fail a verify??? Note that play all purge logs errors outs on all errors so by not doing here we are inconsistent. Maybe UI should just be looking for SKIPPED LVs and it could abort verify if user cares... I.E. change play all PLs. // goto visit_done; continue; - } + } //g COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); file = (RootBeast_s *)COMN_LookupByZid(&vStats->VS_Common.RAVS_GenMsg, vStats->VS_zVolume, znode->header.zid, SLATCHED, TRUE); if(file == NULL) @@ -2114,7 +2114,7 @@ ZVP_ERROR ZVP_playAllPurgeLogsVisitNode(BeastTreeNode_s *node, Blknum_t blknum, ccode = zOK; } else - { // BT Branch + { // BT Branch for ( i = 0; i < node->numRecs; i++ ) { if ( ZVP_UnloadRequested( vStats ) ) @@ -2374,7 +2374,7 @@ nextBlock: } } else - { + { switch(vStats->action) { case BMP_TST_EXTENT: @@ -2415,7 +2415,7 @@ nextBlock: * * The assumption is that beast fits in this node (no split required) * - * If we are not upgrading the media format the size of the previous + * If we are not upgrading the media format the size of the previous * size and new size will be same. If we are upgrading the new size * will be bigger, so we need to rearrange the contents of this node * before we pack it in. @@ -2489,7 +2489,7 @@ STATUS ZRB_PackBeastInBlock( return zFAILURE; } znode->header.zid = zOPEN_ENTRY_ZID; - node->LEAF.znodePtr[MAX_LEAF_PTRS - recNum] = + node->LEAF.znodePtr[MAX_LEAF_PTRS - recNum] = node->n.leaf.startOfFreeSpace; znode = (Znode_s *)&node->LEAF.znode[ node->n.leaf.startOfFreeSpace]; @@ -2517,9 +2517,9 @@ STATUS ZRB_PackBeastInBlock( * * If we are rebuilding a Media format 34,35,36 or 39: * Before calling this routine the special block has been created and - * the system beasts moved to this special block. + * the system beasts moved to this special block. * - * If we are not upgrading the media format the size of the previous + * If we are not upgrading the media format the size of the previous * size and new size will be same. If we are upgrading the new size * will be bigger, so we need to rearrange the contents of this node * before we pack it in. diff --git a/src/nwnss/zlss/repairDisplay.c b/src/nwnss/zlss/repairDisplay.c index 9bb3689..0cd7ddf 100644 --- a/src/nwnss/zlss/repairDisplay.c +++ b/src/nwnss/zlss/repairDisplay.c @@ -67,8 +67,7 @@ BYTE lineChar[50] = {'€','€','€','€','€','€','€','€','€','€','€','€','€','€', '€','€','€','€','€','€','€','€','€','€','€','€','€','€', - '€','€','€','€','€','€','€','€','€','€','€','€',' -','', + '€','€','€','€','€','€','€','€','€','€','€','€','','', '','','€','€','€','€'}; @@ -129,7 +128,7 @@ void DeleteBadLogFileBox(ZLSSCheckIOProcess_s *ZCProcessPtr) #endif -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- WriteVerifyLine() IN: line - pointer to string to write (may be NULL) @@ -152,7 +151,7 @@ STATUS WriteVerifyLine(VerifyStats_s *vStats, BYTE *line, BYTE crlfs) #endif -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- WriteRebuildLine() IN: line - pointer to string to write (may be NULL) @@ -253,16 +252,16 @@ void DisplayLine(VerifyStats_s *vStats, BYTE *desc, BYTE *value, NINT row, NINT #endif } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DisplayResultsForInternalVolume() -------------------------------------------------------------------------- */ -void DisplayResultsForInternalVolume(VerifyStats_s *vStats, - ZVP_LVData_s *volDataPtr, - NINT blockTotal, - LONG unaccountedBlocks, - LONG usedBlocks, - NINT logFlag, - LONG errFlag, +void DisplayResultsForInternalVolume(VerifyStats_s *vStats, + ZVP_LVData_s *volDataPtr, + NINT blockTotal, + LONG unaccountedBlocks, + LONG usedBlocks, + NINT logFlag, + LONG errFlag, LONG warnFlag) { LONG key = F4; @@ -352,7 +351,7 @@ void DisplayResultsForInternalVolume(VerifyStats_s *vStats, } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DisplayInternalVolumePage() -------------------------------------------------------------------------- */ void DisplayInternalVolumePage(VerifyStats_s *vStats, NINT blockTotal, LONG unaccountedBlocks, LONG usedBlocks, NINT logFlag, LONG errFlag, LONG warnFlag) @@ -385,7 +384,7 @@ void DisplayInternalVolumePage(VerifyStats_s *vStats, NINT blockTotal, LONG unac return; } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DisplayResultsForPoolPage1() -------------------------------------------------------------------------- */ void DisplayResultsForPoolPage1(VerifyStats_s *vStats, NINT blockTotal, LONG unaccountedBlocks, LONG usedBlocks, NINT logFlag) @@ -631,7 +630,7 @@ void DisplayResultsForPoolPage1(VerifyStats_s *vStats, NINT blockTotal, LONG una } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DisplayResultsForPool() sets vStats->zfsPoolStats->RollUpStats.MainStatsPage -------------------------------------------------------------------------- */ @@ -652,14 +651,14 @@ void DisplayResultsForPool(VerifyStats_s *vStats, NINT blockTotal, LONG unaccoun break; default: - break; + break; } return; #endif } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DisplayResultsForLogicalVolumeHeaderPage() -------------------------------------------------------------------------- */ void DisplayResultsForLogicalVolumeHeaderPage(ZVP_LVData_s *lvDataPtr, BOOL IVflag) @@ -672,7 +671,7 @@ void DisplayResultsForLogicalVolumeHeaderPage(ZVP_LVData_s *lvDataPtr, BOOL IVfl /* Determine if quota is set or not, * if not, display "no quota" string */ - if(lvDataPtr->lvZVolume->ZFSVOLvol.VOLtotalBlocks == + if(lvDataPtr->lvZVolume->ZFSVOLvol.VOLtotalBlocks == zLV_NO_QUOTA_SIZE >> lvDataPtr->lvZVolume->ZFSVOLblockShift) { sprintf(DisplayBuffer, MSG(" IV: %U Quota Size: No Quota",503), @@ -691,7 +690,7 @@ void DisplayResultsForLogicalVolumeHeaderPage(ZVP_LVData_s *lvDataPtr, BOOL IVfl /* Determine if quota is set or not, * if not, display "no quota" string */ - if(lvDataPtr->lvZVolume->ZFSVOLvol.VOLtotalBlocks == + if(lvDataPtr->lvZVolume->ZFSVOLvol.VOLtotalBlocks == zLV_NO_QUOTA_SIZE >> lvDataPtr->lvZVolume->ZFSVOLblockShift) { sprintf(DisplayBuffer, MSG(" LV: %U Quota Size: No Quota",505), @@ -709,7 +708,7 @@ void DisplayResultsForLogicalVolumeHeaderPage(ZVP_LVData_s *lvDataPtr, BOOL IVfl } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DisplayResultsForLogicalVolumePage1() -------------------------------------------------------------------------- */ void DisplayResultsForLogicalVolumePage1(VerifyStats_s *vStats, ZVP_LVData_s *lvDataPtr, NINT logFlag, BOOL IVflag) @@ -748,7 +747,7 @@ void DisplayResultsForLogicalVolumePage1(VerifyStats_s *vStats, ZVP_LVData_s *lv //g zWinPrintf(ccode,vStats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_mainWinHandle, DisplayBuffer); } /* Display delete/purge status (if applicable) on seperater line */ - /* we will display only the display time since that is what the + /* we will display only the display time since that is what the * user will recognize */ if(lvStatsPtr->lvStateDeleted) @@ -880,7 +879,7 @@ void DisplayResultsForLogicalVolumePage1(VerifyStats_s *vStats, ZVP_LVData_s *lv /* Determine if quota is set or not, * if not, display "no quota" string */ - if(lvDataPtr->lvZVolume->ZFSVOLvol.VOLtotalBlocks == + if(lvDataPtr->lvZVolume->ZFSVOLvol.VOLtotalBlocks == zLV_NO_QUOTA_SIZE >> lvDataPtr->lvZVolume->ZFSVOLblockShift) { sprintf(numStr, MSG("No Quota",1054)); @@ -960,7 +959,7 @@ void DisplayResultsForLogicalVolumePage1(VerifyStats_s *vStats, ZVP_LVData_s *lv } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DisplayResultsForLogicalVolumePage2() -------------------------------------------------------------------------- */ void DisplayResultsForLogicalVolumePage2(VerifyStats_s *vStats, ZVP_LVData_s *lvDataPtr, NINT logFlag, BOOL IVflag) @@ -998,7 +997,7 @@ void DisplayResultsForLogicalVolumePage2(VerifyStats_s *vStats, ZVP_LVData_s *lv //g zWinPrintf(ccode,vStats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_mainWinHandle, DisplayBuffer); } /* Display delete/purge status (if applicable) on seperater line */ - /* we will display only the display time since that is what the + /* we will display only the display time since that is what the * user will recognize */ if(lvStatsPtr->lvStateDeleted) @@ -1136,15 +1135,15 @@ void DisplayResultsForLogicalVolumePage2(VerifyStats_s *vStats, ZVP_LVData_s *lv } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DisplayResultsForLogicalVolume() -------------------------------------------------------------------------- */ -void DisplayResultsForLogicalVolume(VerifyStats_s *vStats, - NINT blockTotal, - LONG unaccountedBlocks, - LONG usedBlocks, - NINT logFlag, - LONG errFlag, +void DisplayResultsForLogicalVolume(VerifyStats_s *vStats, + NINT blockTotal, + LONG unaccountedBlocks, + LONG usedBlocks, + NINT logFlag, + LONG errFlag, LONG warnFlag) { ZVP_LVData_s *LVDataPtr; @@ -1274,7 +1273,7 @@ void DisplayResultsForLogicalVolume(VerifyStats_s *vStats, //g//g zGetCharSem(ccode,vStats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_screenHandle, &key, (LONG *)&vStats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_flag); }/* end of while(key != ESC_K) loop */ }while(LVDataPtr == NULL);/* end do loop */ - + DisplayResultsForPoolPage1(vStats, blockTotal, unaccountedBlocks, usedBlocks, logFlag); //g vStats->zfsPoolStats->RollUpStats.MainStatsPage = MAIN_STATS_PAGE_POOL1; @@ -1282,12 +1281,12 @@ void DisplayResultsForLogicalVolume(VerifyStats_s *vStats, } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DisplayErrorsWarnings() -------------------------------------------------------------------------- */ -void DisplayErrorsWarnings(VerifyStats_s *vStats, - LONG warnFlag, - LONG errFlag, +void DisplayErrorsWarnings(VerifyStats_s *vStats, + LONG warnFlag, + LONG errFlag, NINT logFlag) { #if 0 @@ -1393,13 +1392,13 @@ void DisplayErrorsWarnings(VerifyStats_s *vStats, } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DisplayWarnings() -------------------------------------------------------------------------- */ -void DisplayWarnings(VerifyStats_s *vStats, - LONG warnFlag, - NINT logFlag, - HWINDOW localWinHandle2, +void DisplayWarnings(VerifyStats_s *vStats, + LONG warnFlag, + NINT logFlag, + HWINDOW localWinHandle2, NINT overlapFlag) { #if 0 @@ -1420,11 +1419,11 @@ void DisplayWarnings(VerifyStats_s *vStats, StructMSG(" Object Tree Node(s) Contain Corruption.", 1085), // 0x0010 StructMSG(" Salvage Tree Node(s) Contain Corruption.", 1086), // 0x0020 StructMSG(" Filename(s) could not be found in the NT.", 1087), // 0x0040 - StructMSG(" Pool System Report 'Number of Objects' in Error.", 1088), // 0x0080 - StructMSG(" Pool System Report 'Blocks in Use' in Error.", 1089), // 0x0100 - StructMSG(" Salvage Tree Inconsistent With Object/Name Trees.", 1090), // 0x0200 - StructMSG(" A 'Volume Problem Report' Shows Problems.", 1091), // 0x0400 - StructMSG(" Sum of 'Salvagable Objects' != Salvage Tree Entries.", 1092),// 0x0800 + StructMSG(" Pool System Report 'Number of Objects' in Error.", 1088), // 0x0080 + StructMSG(" Pool System Report 'Blocks in Use' in Error.", 1089), // 0x0100 + StructMSG(" Salvage Tree Inconsistent With Object/Name Trees.", 1090), // 0x0200 + StructMSG(" A 'Volume Problem Report' Shows Problems.", 1091), // 0x0400 + StructMSG(" Sum of 'Salvagable Objects' != Salvage Tree Entries.", 1092),// 0x0800 StructMSG(" Pool System Report 'Number of Salvagable blocks' in Error", 0), // 0x00001000 StructMSG(" Volume System Report 'Number of Salvagable blocks' in Error", 0), // 0x00002000 @@ -1544,13 +1543,13 @@ void DisplayWarnings(VerifyStats_s *vStats, } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DisplayErrors() -------------------------------------------------------------------------- */ -void DisplayErrors(VerifyStats_s *vStats, - LONG errFlag, - NINT logFlag, - HWINDOW localWinHandle, +void DisplayErrors(VerifyStats_s *vStats, + LONG errFlag, + NINT logFlag, + HWINDOW localWinHandle, NINT overlapFlag) { #if 0 @@ -1572,15 +1571,15 @@ void DisplayErrors(VerifyStats_s *vStats, StructMSG(" Salvage Tree Leaf Linked List is Broken.", 1104), // 0x0020 StructMSG(" Could Not Verify Logical Volume(s) ", 1105), // 0x0040 - StructMSG(" junk error 8 ", 1106), // 0x0080 - StructMSG(" junk error 9 ", 1107), // 0x0100 - StructMSG(" junk error 10 ", 1108), // 0x0200 - StructMSG(" junk error 11 ", 1109), // 0x0400 - StructMSG(" junk error 12 ", 1110), // 0x0800 - StructMSG(" junk error 13 ", 1111), // 0x1000 - StructMSG(" junk error 14 ", 1112), // 0x2000 - StructMSG(" junk error 15 ", 1113), // 0x4000 - StructMSG(" junk error 16 ", 1114), // 0x8000 + StructMSG(" junk error 8 ", 1106), // 0x0080 + StructMSG(" junk error 9 ", 1107), // 0x0100 + StructMSG(" junk error 10 ", 1108), // 0x0200 + StructMSG(" junk error 11 ", 1109), // 0x0400 + StructMSG(" junk error 12 ", 1110), // 0x0800 + StructMSG(" junk error 13 ", 1111), // 0x1000 + StructMSG(" junk error 14 ", 1112), // 0x2000 + StructMSG(" junk error 15 ", 1113), // 0x4000 + StructMSG(" junk error 16 ", 1114), // 0x8000 }; /* double line */ @@ -1697,17 +1696,17 @@ void DisplayErrors(VerifyStats_s *vStats, } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayHistogram() -------------------------------------------------------------------------- */ #if 0 -void DebugDisplayHistogram(VerifyStats_s *vStats, - BTStats_s *lvBTStats, - NTStats_s *lvNTStats, - UBTStats_s *lvUBTStats, - DBTStats_s *lvDBTStats, - unicode_t *name, - NINT logFlag, +void DebugDisplayHistogram(VerifyStats_s *vStats, + BTStats_s *lvBTStats, + NTStats_s *lvNTStats, + UBTStats_s *lvUBTStats, + DBTStats_s *lvDBTStats, + unicode_t *name, + NINT logFlag, NINT lvFlag) { LONG key = PGDN_K; @@ -1775,7 +1774,7 @@ void DebugDisplayHistogram(VerifyStats_s *vStats, page = 0; break; } - break; + break; } switch(key) { @@ -1799,7 +1798,7 @@ void DebugDisplayHistogram(VerifyStats_s *vStats, #endif -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayOTHistogram() -------------------------------------------------------------------------- */ #if 0 @@ -1812,7 +1811,7 @@ void DebugDisplayOTHistogram(VerifyStats_s *vStats, BTStats_s * lvBTStats, unico zASSERT(lvBTStats != 0); - + /* double line */ if(logFlag == LOGGING) { @@ -2285,7 +2284,7 @@ void DebugDisplayOTHistogram(VerifyStats_s *vStats, BTStats_s * lvBTStats, unico if(logFlag == LOGGING) { status = WriteVerifyLine(vStats, NULL, 2); - + } else { @@ -2299,7 +2298,7 @@ void DebugDisplayOTHistogram(VerifyStats_s *vStats, BTStats_s * lvBTStats, unico } #endif -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayNTHistogram() -------------------------------------------------------------------------- */ #if 0 @@ -2353,7 +2352,7 @@ void DebugDisplayNTHistogram(VerifyStats_s *vStats, NTStats_s *lvNTStats, unicod zPutWinCursor(ccode,localWinHandle,16, 61); zWinPrintf(ccode,localWinHandle, DisplayBuffer); } - + sprintf(DisplayBuffer, MSG(" Branches ", 1155)); if(logFlag == LOGGING) { @@ -2370,7 +2369,7 @@ void DebugDisplayNTHistogram(VerifyStats_s *vStats, NTStats_s *lvNTStats, unicod zDisplayWindow(ccode,localWinHandle1); zClearWindow(ccode,localWinHandle1); } - + sprintf(DisplayBuffer, MSG(" No. Recs Branch", 1156)); if(logFlag == LOGGING) { @@ -2485,13 +2484,13 @@ void DebugDisplayNTHistogram(VerifyStats_s *vStats, NTStats_s *lvNTStats, unicod zPutWinCursor(ccode,localWinHandle1, 10, 0); zWinPrintf(ccode,localWinHandle1, DisplayBuffer); } - + /* double space down */ if(logFlag == LOGGING) { status = WriteVerifyLine(vStats, NULL, 2); } - + sprintf(DisplayBuffer, MSG(" Leafs ", 1166)); if(logFlag == LOGGING) { @@ -2508,7 +2507,7 @@ void DebugDisplayNTHistogram(VerifyStats_s *vStats, NTStats_s *lvNTStats, unicod zDisplayWindow(ccode,localWinHandle2); zClearWindow(ccode,localWinHandle2); } - + sprintf(DisplayBuffer, MSG(" No. Recs Leaf", 1167)); if(logFlag == LOGGING) { @@ -2653,13 +2652,13 @@ void DebugDisplayNTHistogram(VerifyStats_s *vStats, NTStats_s *lvNTStats, unicod zPutWinCursor(ccode,localWinHandle2,13 , 0); zWinPrintf(ccode,localWinHandle2, DisplayBuffer); } - + /* double space down */ if(logFlag == LOGGING) { status = WriteVerifyLine(vStats, NULL, 2); } - + sprintf(DisplayBuffer, MSG(" Entries ", 1180)); if(logFlag == LOGGING) { @@ -2676,7 +2675,7 @@ void DebugDisplayNTHistogram(VerifyStats_s *vStats, NTStats_s *lvNTStats, unicod zDisplayWindow(ccode,localWinHandle3); zClearWindow(ccode,localWinHandle3); } - + sprintf(DisplayBuffer, MSG(" NT No.", 1181)); if(logFlag == LOGGING) { @@ -2802,7 +2801,7 @@ void DebugDisplayNTHistogram(VerifyStats_s *vStats, NTStats_s *lvNTStats, unicod } #endif -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplaySTHistogram() -------------------------------------------------------------------------- */ #if 0 @@ -3297,7 +3296,7 @@ void DebugDisplaySTHistogram(VerifyStats_s *vStats, NINT logFlag, LONG *key) } #endif -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayUTHistogram() -------------------------------------------------------------------------- */ #if 0 @@ -3351,7 +3350,7 @@ void DebugDisplayUTHistogram(VerifyStats_s *vStats, UBTStats_s * lvUBTStats, uni zPutWinCursor(ccode,localWinHandle,16, 61); zWinPrintf(ccode,localWinHandle, DisplayBuffer); } - + sprintf(DisplayBuffer, MSG(" Branches ", 1228)); if(logFlag == LOGGING) { @@ -3368,7 +3367,7 @@ void DebugDisplayUTHistogram(VerifyStats_s *vStats, UBTStats_s * lvUBTStats, uni zDisplayWindow(ccode,localWinHandle1); zClearWindow(ccode,localWinHandle1); } - + sprintf(DisplayBuffer, MSG(" No. Recs Branch", 1229)); if(logFlag == LOGGING) { @@ -3483,13 +3482,13 @@ void DebugDisplayUTHistogram(VerifyStats_s *vStats, UBTStats_s * lvUBTStats, uni zPutWinCursor(ccode,localWinHandle1, 10, 0); zWinPrintf(ccode,localWinHandle1, DisplayBuffer); } - + /* double space down */ if(logFlag == LOGGING) { status = WriteVerifyLine(vStats, NULL, 2); } - + sprintf(DisplayBuffer, MSG(" Leafs ", 1239)); if(logFlag == LOGGING) { @@ -3506,7 +3505,7 @@ void DebugDisplayUTHistogram(VerifyStats_s *vStats, UBTStats_s * lvUBTStats, uni zDisplayWindow(ccode,localWinHandle2); zClearWindow(ccode,localWinHandle2); } - + sprintf(DisplayBuffer, MSG(" No. Recs Leaf", 1240)); if(logFlag == LOGGING) { @@ -3651,13 +3650,13 @@ void DebugDisplayUTHistogram(VerifyStats_s *vStats, UBTStats_s * lvUBTStats, uni zPutWinCursor(ccode,localWinHandle2,13 , 0); zWinPrintf(ccode,localWinHandle2, DisplayBuffer); } - + /* double space down */ if(logFlag == LOGGING) { status = WriteVerifyLine(vStats, NULL, 2); } - + sprintf(DisplayBuffer, MSG(" Entries ", 1253)); if(logFlag == LOGGING) { @@ -3674,7 +3673,7 @@ void DebugDisplayUTHistogram(VerifyStats_s *vStats, UBTStats_s * lvUBTStats, uni zDisplayWindow(ccode,localWinHandle3); zClearWindow(ccode,localWinHandle3); } - + sprintf(DisplayBuffer, MSG(" UT No.", 510)); if(logFlag == LOGGING) { @@ -3801,7 +3800,7 @@ void DebugDisplayUTHistogram(VerifyStats_s *vStats, UBTStats_s * lvUBTStats, uni #endif -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayDTHistogram() -------------------------------------------------------------------------- */ #if 0 @@ -3855,7 +3854,7 @@ void DebugDisplayDTHistogram(VerifyStats_s *vStats, DBTStats_s * lvDBTStats, uni zPutWinCursor(ccode,localWinHandle,16, 61); zWinPrintf(ccode,localWinHandle, DisplayBuffer); } - + sprintf(DisplayBuffer, MSG(" Branches ", 1263)); if(logFlag == LOGGING) { @@ -3872,7 +3871,7 @@ void DebugDisplayDTHistogram(VerifyStats_s *vStats, DBTStats_s * lvDBTStats, uni zDisplayWindow(ccode,localWinHandle1); zClearWindow(ccode,localWinHandle1); } - + sprintf(DisplayBuffer, MSG(" No. Recs Branch", 1264)); if(logFlag == LOGGING) { @@ -3987,13 +3986,13 @@ void DebugDisplayDTHistogram(VerifyStats_s *vStats, DBTStats_s * lvDBTStats, uni zPutWinCursor(ccode,localWinHandle1, 10, 0); zWinPrintf(ccode,localWinHandle1, DisplayBuffer); } - + /* double space down */ if(logFlag == LOGGING) { status = WriteVerifyLine(vStats, NULL, 2); } - + sprintf(DisplayBuffer, MSG(" Leafs ", 1274)); if(logFlag == LOGGING) { @@ -4010,7 +4009,7 @@ void DebugDisplayDTHistogram(VerifyStats_s *vStats, DBTStats_s * lvDBTStats, uni zDisplayWindow(ccode,localWinHandle2); zClearWindow(ccode,localWinHandle2); } - + sprintf(DisplayBuffer, MSG(" No. Recs Leaf", 1275)); if(logFlag == LOGGING) { @@ -4155,13 +4154,13 @@ void DebugDisplayDTHistogram(VerifyStats_s *vStats, DBTStats_s * lvDBTStats, uni zPutWinCursor(ccode,localWinHandle2,13 , 0); zWinPrintf(ccode,localWinHandle2, DisplayBuffer); } - + /* double space down */ if(logFlag == LOGGING) { status = WriteVerifyLine(vStats, NULL, 2); } - + sprintf(DisplayBuffer, MSG(" Entries ", 1288)); if(logFlag == LOGGING) { @@ -4178,7 +4177,7 @@ void DebugDisplayDTHistogram(VerifyStats_s *vStats, DBTStats_s * lvDBTStats, uni zDisplayWindow(ccode,localWinHandle3); zClearWindow(ccode,localWinHandle3); } - + sprintf(DisplayBuffer, MSG(" DT No.", 512)); if(logFlag == LOGGING) { @@ -4305,7 +4304,7 @@ void DebugDisplayDTHistogram(VerifyStats_s *vStats, DBTStats_s * lvDBTStats, uni #endif -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayMissingNSpace() -------------------------------------------------------------------------- */ void DebugDisplayMissingNSpace(VerifyStats_s *vStats, BTStats_s *lvBTStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -4426,7 +4425,7 @@ void DebugDisplayMissingNSpace(VerifyStats_s *vStats, BTStats_s *lvBTStats, LONG } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayInvalidTreeBlocks() -------------------------------------------------------------------------- */ void DebugDisplayInvalidTreeBlocks(VerifyStats_s *vStats, NTStats_s *NTStats, BTStats_s *BTStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -4509,7 +4508,7 @@ void DebugDisplayInvalidTreeBlocks(VerifyStats_s *vStats, NTStats_s *NTStats, BT return; } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayBadBTNextNodeErrs() -------------------------------------------------------------------------- */ void DebugDisplayBadBTNextNodeErrs(VerifyStats_s *vStats, BTStats_s *lvBTStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -4582,7 +4581,7 @@ void DebugDisplayBadBTNextNodeErrs(VerifyStats_s *vStats, BTStats_s *lvBTStats, } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayBadSTNextNodeErrs() -------------------------------------------------------------------------- */ void DebugDisplayBadSTNextNodeErrs(VerifyStats_s *vStats, STStats_s *lvSTStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -4656,7 +4655,7 @@ void DebugDisplayBadSTNextNodeErrs(VerifyStats_s *vStats, STStats_s *lvSTStats, -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayMissingZids() -------------------------------------------------------------------------- */ void DebugDisplayMissingZids(VerifyStats_s *vStats, BTStats_s *lvBTStats, NTStats_s *lvNTStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -4755,7 +4754,7 @@ void DebugDisplayMissingZids(VerifyStats_s *vStats, BTStats_s *lvBTStats, NTStat return; } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayMissingZids1() -------------------------------------------------------------------------- */ void DebugDisplayMissingZids1(VerifyStats_s *vStats, BTStats_s *lvBTStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -4826,7 +4825,7 @@ void DebugDisplayMissingZids1(VerifyStats_s *vStats, BTStats_s *lvBTStats, LONG } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayMissingZids2() -------------------------------------------------------------------------- */ void DebugDisplayMissingZids2(VerifyStats_s *vStats, STStats_s *STStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -4926,7 +4925,7 @@ void DebugDisplayMissingZids2(VerifyStats_s *vStats, STStats_s *STStats, LONG *k } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayMissingZids3() -------------------------------------------------------------------------- */ void DebugDisplayMissingZids3(VerifyStats_s *vStats, STStats_s *STStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -5027,7 +5026,7 @@ void DebugDisplayMissingZids3(VerifyStats_s *vStats, STStats_s *STStats, LONG *k -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayUnaccountedBlocks() -------------------------------------------------------------------------- */ void DebugDisplayUnaccountedBlocks(VerifyStats_s *vStats, LONG unaccountedBlocks, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -5098,7 +5097,7 @@ void DebugDisplayUnaccountedBlocks(VerifyStats_s *vStats, LONG unaccountedBlocks return; } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayXLinkedBlocks() -------------------------------------------------------------------------- */ void DebugDisplayXLinkedBlocks(VerifyStats_s *vStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -5265,7 +5264,7 @@ NextPage: return; } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayUnreadableZids() -------------------------------------------------------------------------- */ void DebugDisplayUnreadableZids(VerifyStats_s *vStats, BTStats_s *lvBTStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -5337,7 +5336,7 @@ void DebugDisplayUnreadableZids(VerifyStats_s *vStats, BTStats_s *lvBTStats, LON return; } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayDuplicateZids() -------------------------------------------------------------------------- */ void DebugDisplayDuplicateZids(VerifyStats_s *vStats, BTStats_s *lvBTStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -5433,7 +5432,7 @@ void DebugDisplayDuplicateZids(VerifyStats_s *vStats, BTStats_s *lvBTStats, LONG return; } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayRangeErrZids() -------------------------------------------------------------------------- */ void DebugDisplayRangeErrZids(VerifyStats_s *vStats, BTStats_s *lvBTStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -5530,7 +5529,7 @@ void DebugDisplayRangeErrZids(VerifyStats_s *vStats, BTStats_s *lvBTStats, LONG return; } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayMissingParents() -------------------------------------------------------------------------- */ void DebugDisplayMissingParents(VerifyStats_s *vStats, BTStats_s *lvBTStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -5603,7 +5602,7 @@ void DebugDisplayMissingParents(VerifyStats_s *vStats, BTStats_s *lvBTStats, LON return; } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayUnVerifiableLVs() -------------------------------------------------------------------------- */ void DebugDisplayUnVerifiableLVs(VerifyStats_s *vStats, LONG *key, HWINDOW localWinHandle, NINT logFlag) @@ -5673,7 +5672,7 @@ void DebugDisplayUnVerifiableLVs(VerifyStats_s *vStats, LONG *key, HWINDOW local -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugDisplayConflicts() -------------------------------------------------------------------------- */ void DebugDisplayConflicts(VerifyStats_s *vStats, NTStats_s *NTStats, BTStats_s *BTStats, STStats_s *STStats, LONG numUnAccountedBlocks, NINT logFlag) @@ -5715,15 +5714,15 @@ void DebugDisplayConflicts(VerifyStats_s *vStats, NTStats_s *NTStats, BTStats_s case 2: DebugDisplayInvalidTreeBlocks(vStats, NTStats, BTStats, &key, localWinHandle, logFlag); break; - + case 3: DebugDisplayBadBTNextNodeErrs(vStats, BTStats, &key, localWinHandle, logFlag); break; - + case 4: DebugDisplayBadSTNextNodeErrs(vStats, STStats, &key, localWinHandle, logFlag); break; - + case 5: DebugDisplayMissingZids(vStats, BTStats, NTStats, &key, localWinHandle, logFlag); break; @@ -5731,31 +5730,31 @@ void DebugDisplayConflicts(VerifyStats_s *vStats, NTStats_s *NTStats, BTStats_s case 6: DebugDisplayMissingZids1(vStats, BTStats, &key, localWinHandle, logFlag); break; - + case 7: DebugDisplayMissingZids2(vStats, STStats, &key, localWinHandle, logFlag); break; - + case 8: DebugDisplayMissingZids3(vStats, STStats, &key, localWinHandle, logFlag); break; - + case 9: DebugDisplayMissingNSpace(vStats, BTStats, &key, localWinHandle, logFlag); break; - + case 10: DebugDisplayUnreadableZids(vStats, BTStats, &key, localWinHandle, logFlag); break; - + case 11: DebugDisplayDuplicateZids(vStats, BTStats, &key, localWinHandle, logFlag); break; - + case 12: DebugDisplayRangeErrZids(vStats, BTStats, &key, localWinHandle, logFlag); break; - + case 13: DebugDisplayMissingParents(vStats, BTStats, &key, localWinHandle, logFlag); break; @@ -5764,9 +5763,9 @@ void DebugDisplayConflicts(VerifyStats_s *vStats, NTStats_s *NTStats, BTStats_s DebugDisplayUnVerifiableLVs(vStats, &key, localWinHandle, logFlag); break; - default: + default: vStats->zfsPoolStats->RollUpStats.ConflictsPage = 0; - break; + break; } #endif @@ -5787,7 +5786,7 @@ void DebugDisplayConflicts(VerifyStats_s *vStats, NTStats_s *NTStats, BTStats_s //g vStats->zfsPoolStats->RollUpStats.ConflictsPage = 0; break; - default: + default: break; } } @@ -5796,14 +5795,14 @@ void DebugDisplayConflicts(VerifyStats_s *vStats, NTStats_s *NTStats, BTStats_s #endif } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- DebugWriteLogFileStats() -------------------------------------------------------------------------- */ #if 0 void DebugWriteLogFileStats(VerifyStats_s *vStats, NINT blockTotal, LONG numUnAccountedBlocks, LONG usedBlocks, GeneralMsg_s *genMsg, char *sysVolName, LONG warnFlag, LONG errFlag) { LONG key = 0; - HWINDOW localWinHandle = vStats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_mainWinHandle; + HWINDOW localWinHandle = vStats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_mainWinHandle; ZVP_LVData_s *LVDataPtr; NINT logFlag = LOGGING; NINT lvFlag = NOT_LV_LOOPING; @@ -5907,3 +5906,4 @@ void DebugWriteLogFileStats(VerifyStats_s *vStats, NINT blockTotal, LONG numUnAc #endif + diff --git a/src/nwnss/zlss/repairFMtree.c b/src/nwnss/zlss/repairFMtree.c index d9f9f2b..83ca908 100644 --- a/src/nwnss/zlss/repairFMtree.c +++ b/src/nwnss/zlss/repairFMtree.c @@ -79,7 +79,7 @@ BOOL ZVP_FMAPValid( VerifyStats_s *vStats, FmapNode_s *node, Blknum_t block ) { if ( (node->head.magic != FMAP_BT_ROOT) && (node->head.magic != FMAP_BT_LEAF) ) - { + { ZVP_CBS_BadMiscReport( vStats, block, zERR_RAV_MISMATCH_STATE, WHERE ); return FALSE; } @@ -101,7 +101,7 @@ BOOL ZVP_FMAPValid( VerifyStats_s *vStats, FmapNode_s *node, Blknum_t block ) { if ( (node->head.magic != FMAP_BT_ROOT) && (node->head.magic != FMAP_BT_BRANCH) ) - { + { ZVP_CBS_BadMiscReport( vStats, block, zERR_RAV_MISMATCH_STATE, WHERE ); return FALSE; } @@ -122,7 +122,7 @@ BOOL ZVP_FMAPValid( VerifyStats_s *vStats, FmapNode_s *node, Blknum_t block ) if ( node->head.state & BT_ROOT ) { if ( node->head.magic != FMAP_BT_ROOT ) - { + { ZVP_CBS_BadMiscReport( vStats, block, zERR_RAV_MISMATCH_STATE, WHERE ); return FALSE; } @@ -362,13 +362,13 @@ ZVP_ERROR ZVP_FMTreeWalk(VerifyStats_s *vStats, BTStats_s *BTStats, Blknum_t roo /* Recursively verify each file map node in the btree for repair. */ /* -------------------------------------------------------------------------*/ STATUS verifyMapNode(GeneralMsg_s *genMsg, - FmapNode_s *node, - RepairStats_s *stats, - RBTStats_s *RBTStats, - Blknum_t *cntFmapDataBlks, - Blknum_t *cntFmapTreeBlks, - Blknum_t *cntNextBlk, - Zid_t fileZid, + FmapNode_s *node, + RepairStats_s *stats, + RBTStats_s *RBTStats, + Blknum_t *cntFmapDataBlks, + Blknum_t *cntFmapTreeBlks, + Blknum_t *cntNextBlk, + Zid_t fileZid, BOOL thisFileIsSparse) { NINT i,k; @@ -379,11 +379,11 @@ STATUS verifyMapNode(GeneralMsg_s *genMsg, Buffer_s *buffer; //g IoMsg_s iomsg; - if (((node->head.magic == FMAP_BT_ROOT) && - (node->head.state & BT_LEAF) && - (node->head.state & BT_ROOT)) || - ((node->head.magic == FMAP_BT_LEAF) && - (node->head.state & BT_LEAF) && + if (((node->head.magic == FMAP_BT_ROOT) && + (node->head.state & BT_LEAF) && + (node->head.state & BT_ROOT)) || + ((node->head.magic == FMAP_BT_LEAF) && + (node->head.state & BT_LEAF) && (!(node->head.state & BT_ROOT)))) { /* Visit each entry in the leaf node */ @@ -432,11 +432,11 @@ STATUS verifyMapNode(GeneralMsg_s *genMsg, } } } - else if (((node->head.magic == FMAP_BT_ROOT) && - (!(node->head.state & BT_LEAF)) && - (node->head.state & BT_ROOT)) || - ((node->head.magic == FMAP_BT_BRANCH) && - (!(node->head.state & BT_LEAF)) && + else if (((node->head.magic == FMAP_BT_ROOT) && + (!(node->head.state & BT_LEAF)) && + (node->head.state & BT_ROOT)) || + ((node->head.magic == FMAP_BT_BRANCH) && + (!(node->head.state & BT_LEAF)) && (!(node->head.state & BT_ROOT)))) { /* Visit each child in this branch node */ @@ -488,7 +488,7 @@ STATUS verifyMapNode(GeneralMsg_s *genMsg, if (verifyMapNode(genMsg, childNode, stats, RBTStats, cntFmapDataBlks, cntFmapTreeBlks, cntNextBlk, fileZid, thisFileIsSparse) != zOK) { - if(genMsg->errStatus == zERR_NO_NODE) + if(genMsg->errStatus == zERR_NO_NODE) { if(i == 1) { @@ -638,7 +638,7 @@ STATUS VerifyFMTreeWalk(GeneralMsg_s *genMsg, RepairStats_s *stats, RBTStats_s * Returns - zFAILURE if the file is cross-linked. - + */ STATIC STATUS testForConflictMapNode(FmapNode_s *node, RepairStats_s *stats) { @@ -651,11 +651,11 @@ STATIC STATUS testForConflictMapNode(FmapNode_s *node, RepairStats_s *stats) GeneralMsg_s genMsg; //g IoMsg_s iomsg; - if (((node->head.magic == FMAP_BT_ROOT) && - (node->head.state & BT_LEAF) && - (node->head.state & BT_ROOT)) || - ((node->head.magic == FMAP_BT_LEAF) && - (node->head.state & BT_LEAF) && + if (((node->head.magic == FMAP_BT_ROOT) && + (node->head.state & BT_LEAF) && + (node->head.state & BT_ROOT)) || + ((node->head.magic == FMAP_BT_LEAF) && + (node->head.state & BT_LEAF) && (!(node->head.state & BT_ROOT)))) { /* Visit each entry in the leaf node */ @@ -676,11 +676,11 @@ STATIC STATUS testForConflictMapNode(FmapNode_s *node, RepairStats_s *stats) } } } - else if (((node->head.magic == FMAP_BT_ROOT) && - (!(node->head.state & BT_LEAF)) && - (node->head.state & BT_ROOT)) || - ((node->head.magic == FMAP_BT_BRANCH) && - (!(node->head.state & BT_LEAF)) && + else if (((node->head.magic == FMAP_BT_ROOT) && + (!(node->head.state & BT_LEAF)) && + (node->head.state & BT_ROOT)) || + ((node->head.magic == FMAP_BT_BRANCH) && + (!(node->head.state & BT_LEAF)) && (!(node->head.state & BT_ROOT)))) { /* Visit each child in this branch node */ @@ -726,7 +726,7 @@ STATIC STATUS testForConflictMapNode(FmapNode_s *node, RepairStats_s *stats) Returns - zFAILURE if the file is cross-linked. - + */ STATUS testForConflictFMTreeWalk(RepairStats_s *stats, Fmap_s *fMap) { @@ -830,11 +830,11 @@ STATUS freeConflictMapNode(GeneralMsg_s *genMsg, FmapNode_s *node, RepairStats_s STATUS returnCode = zOK; STATUS ccode = zOK; - if (((node->head.magic == FMAP_BT_ROOT) && - (node->head.state & BT_LEAF) && - (node->head.state & BT_ROOT)) || - ((node->head.magic == FMAP_BT_LEAF) && - (node->head.state & BT_LEAF) && + if (((node->head.magic == FMAP_BT_ROOT) && + (node->head.state & BT_LEAF) && + (node->head.state & BT_ROOT)) || + ((node->head.magic == FMAP_BT_LEAF) && + (node->head.state & BT_LEAF) && (!(node->head.state & BT_ROOT)))) { /* Visit each entry in the leaf node */ @@ -851,11 +851,11 @@ STATUS freeConflictMapNode(GeneralMsg_s *genMsg, FmapNode_s *node, RepairStats_s } } } - else if (((node->head.magic == FMAP_BT_ROOT) && - (!(node->head.state & BT_LEAF)) && - (node->head.state & BT_ROOT)) || - ((node->head.magic == FMAP_BT_BRANCH) && - (!(node->head.state & BT_LEAF)) && + else if (((node->head.magic == FMAP_BT_ROOT) && + (!(node->head.state & BT_LEAF)) && + (node->head.state & BT_ROOT)) || + ((node->head.magic == FMAP_BT_BRANCH) && + (!(node->head.state & BT_LEAF)) && (!(node->head.state & BT_ROOT)))) { /* Visit each child in this branch node */ diff --git a/src/nwnss/zlss/repairFtree.c b/src/nwnss/zlss/repairFtree.c index 52123c2..12d6f07 100644 --- a/src/nwnss/zlss/repairFtree.c +++ b/src/nwnss/zlss/repairFtree.c @@ -114,7 +114,7 @@ BOOL ZVP_FTValid( VerifyStats_s *vStats, xNode_s *node, Blknum_t block ) ZVP_CBS_BadMiscReport( vStats, block, zERR_RAV_BAD_ZERO_ENTRY, WHERE ); return( FALSE ); } - + for (cnt = 1; cnt < node->header.numRecs; cnt++ ) { e_curr = &node->EXT[cnt]; @@ -290,7 +290,7 @@ ZVP_ERROR ZVP_visitFreeNode(xNode_s *node, Blknum_t blknum, VerifyStats_s *vStat if (buffer == NULL) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: ZVP_VisitFreeNode, readbuffer alloc error\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: ZVP_VisitFreeNode, readbuffer alloc error\n")); #endif CBS_LevelUp( vStats->VS_cBS ); return ZVP_CBS_BadReadReport( vStats, vStats->VS_iomsg.volBlk, &genMsg ); @@ -358,7 +358,7 @@ LONG ZVP_FreeTreeWalk(VerifyStats_s *vStats, FTStats_s *FTStats) if (buffer == NULL) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: ZVP_FreeTreeWalk, read buffer alloc error\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: ZVP_FreeTreeWalk, read buffer alloc error\n")); #endif return ZVP_CBS_BadReadReport( vStats, vStats->VS_iomsg.volBlk, &genMsg ); } @@ -395,7 +395,7 @@ LONG ZVP_FreeTreeWalk(VerifyStats_s *vStats, FTStats_s *FTStats) if (buffer == NULL) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: ZVP_FreeTreeWalk, read buffer alloc error\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: ZVP_FreeTreeWalk, read buffer alloc error\n")); #endif return ZVP_CBS_BadReadReport( vStats, vStats->VS_iomsg.volBlk, &genMsg ); } @@ -495,7 +495,7 @@ STATUS DsrNode_validateNode(DirTreeNode_s *node) // Rebuild Only in NSS 4.x for(count = 1; count < node->numRecs; count++) { curr = &node->DBRANCH(count); - + /* check if ascending */ if(prev->dirZid >= curr->dirZid) { @@ -590,7 +590,7 @@ BOOL ZVP_DsrNode_valid(VerifyStats_s *vStats,DirTreeNode_s *node, Blknum_t blknu for(count = 1; count < node->numRecs; count++) { curr = &node->DBRANCH(count); - + /* check if ascending */ if(prev->dirZid >= curr->dirZid) { @@ -644,7 +644,7 @@ STATUS ZVP_visitDBTNode(DirTreeNode_s *node, Blknum_t blknum, VerifyStats_s *vSt //g DBTStats->DBTNextNode = INVALID_BLK; //g vStats->VS_cBS->CBS_NextLeafExpected = INVALID_BLK; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot(">>>>Invalid DSR tree node %d\n"),blknum); + DBG_DebugPrintf(LRED,MSGNot(">>>>Invalid DSR tree node %d\n"),blknum); #endif CBS_LevelUp( vStats->VS_cBS ); return zOK; @@ -722,7 +722,7 @@ STATUS ZVP_visitDBTNode(DirTreeNode_s *node, Blknum_t blknum, VerifyStats_s *vSt if (buffer == NULL) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: VisitDsrNode, readbuffer alloc error\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: VisitDsrNode, readbuffer alloc error\n")); #endif CBS_LevelUp( vStats->VS_cBS ); return ZVP_CBS_BadReadReport( vStats, vStats->VS_iomsg.volBlk, &genMsg ); @@ -810,7 +810,7 @@ STATUS ZVP_DBTTreeWalk(VerifyStats_s *vStats, DBTStats_s *DBTStats, Blknum_t roo if (buffer == NULL) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: DSRTreeWalk, read error\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: DSRTreeWalk, read error\n")); #endif ccode = ZVP_CBS_BadReadReport( vStats, vStats->VS_iomsg.volBlk, &genMsg ); return ccode; @@ -1082,7 +1082,7 @@ STATUS OldUsrNode_validateNode(OldUserTreeNode_s *node) for(count = 1; count < node->numRecs; count++) { curr = &node->UBRANCH(count); - + /* check if ascending */ if(prev->userID >= curr->userID) { @@ -1168,7 +1168,7 @@ STATUS UsrNode_validateNode(UserTreeNode_s *node) for(count = 1; count < node->numRecs; count++) { curr = &node->UBRANCH(count); - + /* check if ascending */ if(LB_GUIDCompare(&prev->userID, &curr->userID) >= 0) // if(prev->userID >= curr->userID) @@ -1265,7 +1265,7 @@ BOOL ZVP_UsrNode_valid(VerifyStats_s *vStats, UserTreeNode_s *node, Blknum_t blk for(count = 1; count < node->numRecs; count++) { curr = &node->UBRANCH(count); - + /* check if ascending */ if(LB_GUIDCompare(&prev->userID, &curr->userID) >= 0) // if(prev->userID >= curr->userID) @@ -1308,7 +1308,7 @@ BOOL ZVP_UsrNode_valid(VerifyStats_s *vStats, UserTreeNode_s *node, Blknum_t blk // curr = &node->ULEAF(count); // ////// zASSERT(curr->usedAmount <= curr->restrictionAmount); -// +// // /* check if ascending */ //// zASSERT(LB_GUIDCompare(&prev->userID, &curr->userID) < 0); // if(LB_GUIDCompare(&prev->userID, &curr->userID) >= 0) @@ -1337,7 +1337,7 @@ BOOL ZVP_UsrNode_valid(VerifyStats_s *vStats, UserTreeNode_s *node, Blknum_t blk // for(count = 1; count < node->numRecs; count++) // { // curr = &node->UBRANCH(count); -// +// // /* check if ascending */ //// zASSERT(LB_GUIDCompare(&prev->userID, &curr->userID) < 0); // if(LB_GUIDCompare(&prev->userID, &curr->userID) >= 0) @@ -1376,7 +1376,7 @@ void ZVP_accountForUBT_UNAMBlocks(VerifyStats_s *vStats, UBTStats_s *UBTStats, B if (buffer == NULL) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: accountForUBT_UNAMBlocks, read buffer alloc error\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: accountForUBT_UNAMBlocks, read buffer alloc error\n")); #endif return; } @@ -1398,7 +1398,7 @@ void ZVP_accountForUBT_UNAMBlocks(VerifyStats_s *vStats, UBTStats_s *UBTStats, B else { unamNode->verifyCount++; //inc the count UNAM blocks - } + } break; case FIND_BLOCK: @@ -1452,7 +1452,7 @@ STATUS ZVP_visitUBTNode(UserTreeNode_s *node, Blknum_t blknum, VerifyStats_s *vS //g UBTStats->UBTNextNode = INVALID_BLK; //g vStats->VS_cBS->CBS_NextLeafExpected = INVALID_BLK; reporting bad block does this #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot(">>>>Invalid USR tree node %d\n"),blknum); + DBG_DebugPrintf(LRED,MSGNot(">>>>Invalid USR tree node %d\n"),blknum); #endif CBS_LevelUp( vStats->VS_cBS ); return zOK; @@ -1542,7 +1542,7 @@ STATUS ZVP_visitUBTNode(UserTreeNode_s *node, Blknum_t blknum, VerifyStats_s *vS if (buffer == NULL) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: VisitUsrNode, readbuffer alloc error\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: VisitUsrNode, readbuffer alloc error\n")); #endif CBS_LevelUp( vStats->VS_cBS ); return ZVP_CBS_BadReadReport( vStats, vStats->VS_iomsg.volBlk, &genMsg ); @@ -1553,7 +1553,7 @@ STATUS ZVP_visitUBTNode(UserTreeNode_s *node, Blknum_t blknum, VerifyStats_s *vS { //FixFixFix - what to do on error #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: UsrNode_validateNode\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: UsrNode_validateNode\n")); #endif } switch(vStats->action) @@ -1589,7 +1589,7 @@ STATUS ZVP_visitUBTNode(UserTreeNode_s *node, Blknum_t blknum, VerifyStats_s *vS // #endif // return zERR_RAV_UT_INVALID_NODE; // } - + CBS_LevelUp( vStats->VS_cBS ); return zOK; @@ -1664,7 +1664,7 @@ STATUS ZVP_UBTTreeWalk(VerifyStats_s *vStats, UBTStats_s *UBTStats, Blknum_t roo if (buffer == NULL) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: USRTreeWalk, read buffer alloc error\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: USRTreeWalk, read buffer alloc error\n")); #endif return ZVP_CBS_BadReadReport( vStats, vStats->VS_iomsg.volBlk, &genMsg ); } @@ -1673,7 +1673,7 @@ STATUS ZVP_UBTTreeWalk(VerifyStats_s *vStats, UBTStats_s *UBTStats, Blknum_t roo { //FixFixFix - what to do on error #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: UsrNode_validateNode\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: UsrNode_validateNode\n")); #endif } @@ -1691,7 +1691,7 @@ STATUS ZVP_UBTTreeWalk(VerifyStats_s *vStats, UBTStats_s *UBTStats, Blknum_t roo ZVP_checkBlockForConflicts(vStats, rootBlock, volZid); break; } - + //g UBTStats->UBTLevelCount = 0; //g vStats->VS_cBS->CBS_NextLeafExpected = 0; //g UBTStats->UBTNextNode = 0; diff --git a/src/nwnss/zlss/repairMFL.c b/src/nwnss/zlss/repairMFL.c index 925ef81..29219cd 100644 --- a/src/nwnss/zlss/repairMFL.c +++ b/src/nwnss/zlss/repairMFL.c @@ -138,7 +138,7 @@ LONG visitMFLNode(MFLTreeNode_s *node, Blknum_t blknum, VerifyStats_s *vStats, M if ( !MFLNode_valid(node, blknum, vStats, mflStats) ) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot(">>>>Invalid MFL node %d\n"),blknum); + DBG_DebugPrintf(LRED,MSGNot(">>>>Invalid MFL node %d\n"),blknum); #endif ccode = zOK; goto VISIT_DONE; @@ -147,7 +147,7 @@ LONG visitMFLNode(MFLTreeNode_s *node, Blknum_t blknum, VerifyStats_s *vStats, M if (MFL_IS_LEAF(node)) /* LEAF NODE */ { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("MFL Leaf Verified, %d records\n"), node->numRecs); + DBG_DebugPrintf(LRED,MSGNot("MFL Leaf Verified, %d records\n"), node->numRecs); #endif switch(vStats->action) { @@ -234,7 +234,7 @@ LONG visitMFLNode(MFLTreeNode_s *node, Blknum_t blknum, VerifyStats_s *vStats, M break; } #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("MFL Branch Verified, %d records\n"), node->numRecs); + DBG_DebugPrintf(LRED,MSGNot("MFL Branch Verified, %d records\n"), node->numRecs); #endif for (i = 0; i < node->numRecs; i++) { @@ -284,11 +284,11 @@ LONG visitMFLNode(MFLTreeNode_s *node, Blknum_t blknum, VerifyStats_s *vStats, M } } ccode = zOK; - + VISIT_DONE: CBS_LevelUp( vStats->VS_cBS ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("MFL Tree Verified, %d return code\n"), ccode); + DBG_DebugPrintf(LRED,MSGNot("MFL Tree Verified, %d return code\n"), ccode); #endif return ccode; } @@ -478,7 +478,7 @@ STATIC BOOL EFLNode_valid(EFLTreeNode_s *node, Blknum_t blknum, VerifyStats_s *v // } // EFLStats->EFLNextNode = node->n.leaf.nextLeaf; } - return TRUE; + return TRUE; } @@ -508,7 +508,7 @@ ZVP_ERROR ZVP_visitEFLNode(EFLTreeNode_s *node, Blknum_t blknum, VerifyStats_s * if ( !EFLNode_valid(node, blknum, vStats, eflStats) ) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot(">>>>Invalid EFL node %d\n"),blknum); + DBG_DebugPrintf(LRED,MSGNot(">>>>Invalid EFL node %d\n"),blknum); #endif ccode = zOK; goto VISIT_DONE; @@ -517,7 +517,7 @@ ZVP_ERROR ZVP_visitEFLNode(EFLTreeNode_s *node, Blknum_t blknum, VerifyStats_s * if (EFL_IS_LEAF(node)) /* LEAF NODE */ { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("EFL Leaf Verified, %d records\n"), node->numRecs); + DBG_DebugPrintf(LRED,MSGNot("EFL Leaf Verified, %d records\n"), node->numRecs); #endif switch(vStats->action) { @@ -555,7 +555,7 @@ ZVP_ERROR ZVP_visitEFLNode(EFLTreeNode_s *node, Blknum_t blknum, VerifyStats_s * break; } #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("EFL Branch Verified, %d records\n"), node->numRecs); + DBG_DebugPrintf(LRED,MSGNot("EFL Branch Verified, %d records\n"), node->numRecs); #endif for (i = 0; i < node->numRecs; i++) { @@ -569,7 +569,7 @@ ZVP_ERROR ZVP_visitEFLNode(EFLTreeNode_s *node, Blknum_t blknum, VerifyStats_s * // childBlock = EFL_BRANCH_ENTRY(node, i)->child; childBlock = node->n.branch.entry[i].child; /* This is in case the lv is being deleted and the tree blocks are being free'd (I think, - * is that right Randy? It is based on ZVL_p.PZVL_state == PZVL_S_DELETION and the + * is that right Randy? It is based on ZVL_p.PZVL_state == PZVL_S_DELETION and the * ZVL_p.PZVL_subState != PZVL_SS_DELETE_SALVAGEABLE */ //p if (eflStats->lvStatePurging) if (ZVP_LV_StatePurging( vStats )) @@ -608,11 +608,11 @@ ZVP_ERROR ZVP_visitEFLNode(EFLTreeNode_s *node, Blknum_t blknum, VerifyStats_s * } } ccode = zOK; - + VISIT_DONE: CBS_LevelUp( vStats->VS_cBS ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("EFL Tree Verified, %d return code\n"), ccode); + DBG_DebugPrintf(LRED,MSGNot("EFL Tree Verified, %d return code\n"), ccode); #endif return ccode; @@ -708,3 +708,4 @@ ZVP_ERROR ZVP_EFLTreeAndLogWalk(VerifyStats_s *vStats, EFLStats_s *eflStats, Blk return rError; } /* End of ZVP_EFLTreeAndLogWalk() */ + diff --git a/src/nwnss/zlss/repairMain.c b/src/nwnss/zlss/repairMain.c index 9fa7cb9..2ea6b05 100644 --- a/src/nwnss/zlss/repairMain.c +++ b/src/nwnss/zlss/repairMain.c @@ -292,7 +292,7 @@ void verifylog_WriteDeletedFilenameToLog ( #endif -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- ZRB_UnloadSystemBeasts() -------------------------------------------------------------------------- */ STATUS ZRB_UnloadSystemBeasts(GeneralMsg_s *genMsg, ZfsPool_s *pool, ZLSSCheckIOProcess_s *ZCProcessPtr) @@ -330,14 +330,14 @@ STATUS ZRB_UnloadSystemBeasts(GeneralMsg_s *genMsg, ZfsPool_s *pool, ZLSSCheckIO * to stop doing work. */ X_NOWAIT( &zlssPool->ZLSSPOOLpool.cvsLatch, waitFlag ); -// while ( (waitFlag == WAITED) && +// while ( (waitFlag == WAITED) && // (ZCProcessPtr->ZCIOP_flag != 0 /*CP_FLAG_CLEANUP*/)) // See VPS_Terminate for some details while ( (waitFlag == WAITED) && !COMN_RAV_Terminate(ZCProcessPtr->ZCIOP_pInfo) ) { LB_delay(100); X_NOWAIT( &zlssPool->ZLSSPOOLpool.cvsLatch, waitFlag ); - } + } #if NSS_DEBUG IS_ENABLED DBG_ScreenAPrintf( "ZLSS.Greg.Repair.Pool.Volume", WHERE, CYAN, "%s Going to unload all of the pool's LVs.\n",WHERE ); @@ -362,7 +362,7 @@ STATUS ZRB_UnloadSystemBeasts(GeneralMsg_s *genMsg, ZfsPool_s *pool, ZLSSCheckIO } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- VerifyAndLoadLVSystemBeasts() -------------------------------------------------------------------------- */ /* @@ -386,14 +386,14 @@ STATUS VerifyAndLoadLVSystemBeasts(GeneralMsg_s *genMsg, ZfsVolume_s *vol) if ( status == zOK ) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("LV Purge Log played successfully\n")); + DBG_DebugPrintf(LRED,MSGNot("LV Purge Log played successfully\n")); #endif return( zOK ); } else { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("LV Purge Log NOT played successfully\n")); + DBG_DebugPrintf(LRED,MSGNot("LV Purge Log NOT played successfully\n")); #endif (void)VOL_Deactivate( genMsg, &vol->ZFSVOLvol, 0 ); (void)ZFSVOL_Deactivate( genMsg, vol, 0 ); @@ -421,7 +421,7 @@ STATUS VerifyAndLoadLVSystemBeasts(GeneralMsg_s *genMsg, ZfsVolume_s *vol) } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- UnloadlvSystemBeasts() -------------------------------------------------------------------------- */ STATUS UnloadlvSystemBeasts(GeneralMsg_s *genMsg, ZfsVolume_s *vol) @@ -446,47 +446,47 @@ STATUS UnloadlvSystemBeasts(GeneralMsg_s *genMsg, ZfsVolume_s *vol) return( zOK ); } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- COMPFIX_VerifyAndLoadLVSystemBeasts This is the function exported and used by \testing\nlms\compfix to adjust volume's compression statistics while volume is in the maintenance mode -------------------------------------------------------------------------- */ STATUS COMPFIX_VerifyAndLoadLVSystemBeasts( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, Volume_s *vol) { return VerifyAndLoadLVSystemBeasts(genMsg, (ZfsVolume_s *)vol); -} +} -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- COMPFIX_UnloadlvSystemBeasts This is the function exported and used by \testing\nlms\compfix to adjust volume's compression statistics while volume is in the maintenance mode -------------------------------------------------------------------------- */ STATUS COMPFIX_UnloadlvSystemBeasts( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, Volume_s *vol) { - return UnloadlvSystemBeasts(genMsg, (ZfsVolume_s *)vol); -} + return UnloadlvSystemBeasts(genMsg, (ZfsVolume_s *)vol); +} -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- zRepairValidateNode - + Routine which, given a node pointer, determines what, if anything is wrong with the node. - + Parameters: - + node - beast node pointer - + Returns: - + zOK zFAILURE - if a problem is detected in the beast node @@ -505,7 +505,7 @@ STATUS zRepairValidateNode (BeastTreeNode_s *node) if(node->magic != LEAF_MAGIC) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("CORRUPTED NODE ==> MAGIC = 0x%x\n"),node->magic); + DBG_DebugPrintf(LRED,MSGNot("CORRUPTED NODE ==> MAGIC = 0x%x\n"),node->magic); #endif return zFAILURE; } @@ -514,7 +514,7 @@ STATUS zRepairValidateNode (BeastTreeNode_s *node) if(node->LEAF.znodePtr[MAX_LEAF_PTRS - i] > MAX_LEAF_FREE) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("CORRUPTED ZNODE ==> znode.Ptr > MAX_LEAF_FREE\n")); + DBG_DebugPrintf(LRED,MSGNot("CORRUPTED ZNODE ==> znode.Ptr > MAX_LEAF_FREE\n")); #endif return zFAILURE; } @@ -524,7 +524,7 @@ STATUS zRepairValidateNode (BeastTreeNode_s *node) ((i != 0) || (znode->header.magic != 0x3030))) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("CORRUPTED ZNODE ==> MAGIC = 0x%x\n"),znode->header.magic); + DBG_DebugPrintf(LRED,MSGNot("CORRUPTED ZNODE ==> MAGIC = 0x%x\n"),znode->header.magic); #endif return zFAILURE; } @@ -533,7 +533,7 @@ STATUS zRepairValidateNode (BeastTreeNode_s *node) if(*(LONG *)&zid == -1) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("CORRUPTED ZNODE ==> Zid = 0x%Lx\n"), zid); + DBG_DebugPrintf(LRED,MSGNot("CORRUPTED ZNODE ==> Zid = 0x%Lx\n"), zid); #endif return zFAILURE; } @@ -541,7 +541,7 @@ STATUS zRepairValidateNode (BeastTreeNode_s *node) if((zid == zOPEN_ENTRY_ZID) || ((zid == zINVALID_ZID) && (i != 0))) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("CORRUPTED ZNODE ==> Zid = 0x%Lx\n"), zid); + DBG_DebugPrintf(LRED,MSGNot("CORRUPTED ZNODE ==> Zid = 0x%Lx\n"), zid); #endif return zFAILURE; } @@ -550,7 +550,7 @@ STATUS zRepairValidateNode (BeastTreeNode_s *node) znodePtr[MAX_LEAF_PTRS - (i-1)]])->header.zid)) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("CORRUPTED ZNODE, duplicate or out or order zid ==> Zid = 0x%Lx\n"), zid); + DBG_DebugPrintf(LRED,MSGNot("CORRUPTED ZNODE, duplicate or out or order zid ==> Zid = 0x%Lx\n"), zid); #endif return zFAILURE; } @@ -573,7 +573,7 @@ STATUS zRepairValidateNode (BeastTreeNode_s *node) if(total != MAX_LEAF_FREE) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("CORRUPTED NODE ==> total space is wrong\n")); + DBG_DebugPrintf(LRED,MSGNot("CORRUPTED NODE ==> total space is wrong\n")); #endif return zFAILURE; } @@ -581,7 +581,7 @@ STATUS zRepairValidateNode (BeastTreeNode_s *node) if(totalFree != node->n.leaf.freeSpace) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("CORRUPTED NODE ==> free space is wrong\n")); + DBG_DebugPrintf(LRED,MSGNot("CORRUPTED NODE ==> free space is wrong\n")); #endif return zFAILURE; } @@ -607,7 +607,7 @@ STATUS zRepairValidateNode (BeastTreeNode_s *node) { /*- set the current record -*/ b_curr = &node->n.branch[cnt]; - + /*- check if ZIDs ascend -*/ if(b_prev->zid >= b_curr->zid) return zFAILURE; @@ -621,7 +621,7 @@ STATUS zRepairValidateNode (BeastTreeNode_s *node) return zOK; } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- FindLastLeafBlock Returns block number of the last leaf in the tree INVALID_BLK, means could not run the tree correctly @@ -630,7 +630,7 @@ Blknum_t FindLastLeafBlock(GeneralMsg_s *genMsg, RepairStats_s *rStats, ZfsPool_ { #define MAX_TREE_SEARCH_DEPTH 8 - struct + struct { Blknum_t curBlock; Blknum_t nextBlock; NINT index; @@ -654,19 +654,19 @@ Blknum_t FindLastLeafBlock(GeneralMsg_s *genMsg, RepairStats_s *rStats, ZfsPool_ } node = (BeastTreeNode_s *)buffer->pBuf.data; - if(zRepairValidateNode (node) != zOK) + if(zRepairValidateNode (node) != zOK) { CACHE_RELEASE(buffer); return INVALID_BLK; } - if (!BBT_IS_LEAF(node)) + if (!BBT_IS_LEAF(node)) { - level[depth].nextBlock = findChildBlock(node, zINVALID_ZID-1, &level[depth].index); + level[depth].nextBlock = findChildBlock(node, zINVALID_ZID-1, &level[depth].index); CACHE_RELEASE(buffer); if(depth < MAX_TREE_SEARCH_DEPTH-1) level[depth+1].curBlock = level[depth].nextBlock; - } + } else { CACHE_RELEASE(buffer); @@ -691,7 +691,7 @@ Blknum_t FindLastLeafBlock(GeneralMsg_s *genMsg, RepairStats_s *rStats, ZfsPool_ } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- FindNextLeafBlock Given a zid in a leaf, find and return the leaf block number which @@ -699,19 +699,19 @@ Blknum_t FindLastLeafBlock(GeneralMsg_s *genMsg, RepairStats_s *rStats, ZfsPool_ Parameters: genMsg GeneralMsg_s * pool ZfsPool_s * - pointer to the pool management structure - beastRootBlockNum Blknum_t - block number of the root of the beast tree + beastRootBlockNum Blknum_t - block number of the root of the beast tree *zid Zid_t - zid that should be contained in the reference leaf block *nextLeaf - block num of the leaf that is in question Returns: - + zOK returns *nextLeaf = blocknum of the next leaf, zid = rightmost zid in nextLeaf = 0, no next leaf, end of tree zFAILURE - Unable to successfully rebuild the tree. Notes - - June 2004. + June 2004. '*zid' is generally the lowest zid in the leaf left of '*nextblock'. The '*zid' is used to find the branches that point to the 'leaf left of *nextblock'. The code then ups the index so that the first leaf we look at is right of the leaf that has '*zid'. The @@ -722,16 +722,16 @@ Blknum_t FindLastLeafBlock(GeneralMsg_s *genMsg, RepairStats_s *rStats, ZfsPool_ tree. I.E. the zids in the branches are ignored! This appears to be a very good design as using the previous zid is MORE likily to be valid than the ZID in the leaf that has a possible bad nextleaf pointer. - + Warnings - This code does not attempt to handle TWO BTs that are linked together!!!! -------------------------------------------------------------------------- */ -STATUS FindNextLeafBlock(GeneralMsg_s *genMsg, - ZfsPool_s *pool, - RBTStats_s *RBTStats, +STATUS FindNextLeafBlock(GeneralMsg_s *genMsg, + ZfsPool_s *pool, + RBTStats_s *RBTStats, RepairStats_s *stats, - Blknum_t beastRootBlockNum, - Zid_t *zid, + Blknum_t beastRootBlockNum, + Zid_t *zid, Blknum_t *nextBlock) { #define MAX_TREE_SEARCH_DEPTH 8 @@ -769,9 +769,9 @@ STATUS FindNextLeafBlock(GeneralMsg_s *genMsg, //g stats->ExcessiveBtreePrune = TRUE; RBTStats->BtreePruned = TRUE; break; - } + } node = (BeastTreeNode_s *)buffer->pBuf.data; - if(zRepairValidateNode (node) != zOK) + if(zRepairValidateNode (node) != zOK) { RBTStats->beastTreeRightMostLeaf = INVALID_BLK; //g stats->ExcessiveBtreePrune = TRUE; @@ -780,7 +780,7 @@ STATUS FindNextLeafBlock(GeneralMsg_s *genMsg, break; } - if (!BBT_IS_LEAF(node)) + if (!BBT_IS_LEAF(node)) { branchBlk = node->n.branch[node->numRecs-1].child; } @@ -821,7 +821,7 @@ STATUS FindNextLeafBlock(GeneralMsg_s *genMsg, break; } node = (BeastTreeNode_s *)buffer->pBuf.data; - if(zRepairValidateNode (node) != zOK) + if(zRepairValidateNode (node) != zOK) { //g stats->ExcessiveBtreePrune = TRUE; RBTStats->BtreePruned = TRUE; @@ -829,13 +829,13 @@ STATUS FindNextLeafBlock(GeneralMsg_s *genMsg, break; } - if (!BBT_IS_LEAF(node)) + if (!BBT_IS_LEAF(node)) { - aStack->level[depth].nextBlock = findChildBlock(node, *zid, &aStack->level[depth].index); + aStack->level[depth].nextBlock = findChildBlock(node, *zid, &aStack->level[depth].index); CACHE_RELEASE(buffer); if(depth < MAX_TREE_SEARCH_DEPTH-1) aStack->level[depth+1].curBlock = aStack->level[depth].nextBlock; - } + } else { CACHE_RELEASE(buffer); @@ -864,7 +864,7 @@ STATUS FindNextLeafBlock(GeneralMsg_s *genMsg, Starting from a successful parse to the leaf level, back up the tree until we find a node that we can increase the child index and still have a valid downlink. Once we find that point, decend the tree again - always using the leftmost child until we get to a leaf. + always using the leftmost child until we get to a leaf. */ startOver: @@ -906,23 +906,23 @@ startOver: node = (BeastTreeNode_s *)buffer->pBuf.data; - if(zRepairValidateNode (node) != zOK) + if(zRepairValidateNode (node) != zOK) { //g stats->ExcessiveBtreePrune = TRUE; RBTStats->BtreePruned = TRUE; CACHE_RELEASE(buffer); goto startOver; } - - if (!BBT_IS_LEAF(node)) + + if (!BBT_IS_LEAF(node)) { - aStack->level[depth].nextBlock = node->n.branch[0].child; + aStack->level[depth].nextBlock = node->n.branch[0].child; aStack->level[depth].index = 0; CACHE_RELEASE(buffer); if(depth < MAX_TREE_SEARCH_DEPTH-1) aStack->level[depth+1].curBlock = aStack->level[depth].nextBlock; continue; - } + } else { znode = (Znode_s *)&node->LEAF.znode[node->LEAF.znodePtr[MAX_LEAF_PTRS - (node->numRecs - 1)]]; /* point at the rightmost beast in the buffer */ @@ -936,7 +936,7 @@ startOver: STACK_FREE(); return zOK; } - } + } } } STACK_FREE(); @@ -950,9 +950,9 @@ startOver: void SaveLeafInfoEnd(RBTStats_s *RBTStats) { - if(RBTStats->leafInfoStoredToDisk && RBTStats->onDiskList.tailBuffer) + if(RBTStats->leafInfoStoredToDisk && RBTStats->onDiskList.tailBuffer) { - + CACHE_DIRTY_RELEASE((RBTStats->onDiskList.tailBuffer)); RBTStats->onDiskList.tailBuffer = NULL; RBTStats->onDiskList.tailBufferInsert = NULL; @@ -964,7 +964,7 @@ void SaveLeafInfoEnd(RBTStats_s *RBTStats) SaveLeafInfoToDisk Given the current block and current Zid, store this info away - in a queue on the disk. + in a queue on the disk. FixFixFix6 need to check for errors _________________________________________________________________________ */ @@ -987,11 +987,11 @@ STATUS SaveLeafInfoToDisk(Blknum_t blockNum, Zid_t zid, RepairStats_s *stats, RB //g RBTStats->onDiskList.tailBuffer = zFS_ReadPoolBlk(genMsg,&iomsg); zASSERT(RBTStats->onDiskList.tailBuffer != NULL); - + if(RBTStats->onDiskList.tailBuffer == NULL) - return zOK; /* this SHOULDN'T ever happen. If it does, we loose a block fixfixfix6 for cnt */ - - RBTStats->onDiskList.tailBufferStart = + return zOK; /* this SHOULDN'T ever happen. If it does, we loose a block fixfixfix6 for cnt */ + + RBTStats->onDiskList.tailBufferStart = RBTStats->onDiskList.tailBufferInsert = RBTStats->onDiskList.tailBufferEnd = (LeafInfo_s *)RBTStats->onDiskList.tailBuffer->pBuf.data; @@ -1053,10 +1053,10 @@ STATUS SaveLeafInfo( Blknum_t blockNum, Zid_t lowestZid, RepairStats_s *stats, R break; } } - RBTStats->leafInfoStoredToDisk = TRUE; + RBTStats->leafInfoStoredToDisk = TRUE; } #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("***Saving leaf info to disk\n")); + DBG_DebugPrintf(LRED,MSGNot("***Saving leaf info to disk\n")); #endif if(status != zOK) { @@ -1074,9 +1074,9 @@ STATUS SaveLeafInfo( Blknum_t blockNum, Zid_t lowestZid, RepairStats_s *stats, R NULLIFY(&branchInfo->nextBlock); SQ_ENQ(&RBTStats->RS_branchHead, branchInfo, nextBlock); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("++++Saving leaf info in memory for Volume %p\n"),(RBTStats->zVolume)); - DBG_DebugPrintf(LRED,MSGNot("++++Branch Info: blockNum = %d, LowZid = %d, count = %d\n"), - branchInfo->blockNum, (LONG)branchInfo->lowestZid, RBTStats->leafInfoCount); + DBG_DebugPrintf(LRED,MSGNot("++++Saving leaf info in memory for Volume %p\n"),(RBTStats->zVolume)); + DBG_DebugPrintf(LRED,MSGNot("++++Branch Info: blockNum = %d, LowZid = %d, count = %d\n"), + branchInfo->blockNum, (LONG)branchInfo->lowestZid, RBTStats->leafInfoCount); #endif } return zOK; @@ -1088,9 +1088,9 @@ STATUS SaveLeafInfo( Blknum_t blockNum, Zid_t lowestZid, RepairStats_s *stats, R void GetLeafInfoEnd(RepairStats_s *stats, RBTStats_s *RBTStats) { - if(RBTStats->leafInfoStoredToDisk && RBTStats->onDiskList.headBuffer) + if(RBTStats->leafInfoStoredToDisk && RBTStats->onDiskList.headBuffer) { - + CACHE_RELEASE((RBTStats->onDiskList.headBuffer)); RBTStats->onDiskList.headBuffer = NULL; RBTStats->onDiskList.headBufferRemove = NULL; @@ -1126,7 +1126,7 @@ BranchList_s *GetLeafInfoFromDisk(RepairStats_s *stats, RBTStats_s *RBTStats, Ge return NULL; } - RBTStats->onDiskList.headBufferStart = + RBTStats->onDiskList.headBufferStart = RBTStats->onDiskList.headBufferRemove = RBTStats->onDiskList.headBufferEnd = (LeafInfo_s *) RBTStats->onDiskList.headBuffer->pBuf.data; @@ -1136,7 +1136,7 @@ BranchList_s *GetLeafInfoFromDisk(RepairStats_s *stats, RBTStats_s *RBTStats, Ge } branchInfo = malloc(sizeof(BranchList_s)); zASSERT(branchInfo != NULL); - + if(branchInfo == NULL) return NULL; @@ -1183,13 +1183,13 @@ BranchList_s *leafInfo; /* pointer to current leaf node info struct */ { SQ_DEQ(&RBTStats->RS_branchHead, leafInfo, BranchList_s, nextBlock); } - + if(leafInfo) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("----Getting leaf info from memory for Volume %p\n"),(RBTStats->zVolume)); - DBG_DebugPrintf(LRED,MSGNot("----Getting Info: blockNum = %d, LowZid = %d, count = %d\n"), - leafInfo->blockNum, leafInfo->lowestZid, RBTStats->leafInfoCount); + DBG_DebugPrintf(LRED,MSGNot("----Getting leaf info from memory for Volume %p\n"),(RBTStats->zVolume)); + DBG_DebugPrintf(LRED,MSGNot("----Getting Info: blockNum = %d, LowZid = %d, count = %d\n"), + leafInfo->blockNum, leafInfo->lowestZid, RBTStats->leafInfoCount); #endif RBTStats->leafInfoCount--; } @@ -1199,11 +1199,11 @@ BranchList_s *leafInfo; /* pointer to current leaf node info struct */ } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- BuildNewBeastTreeLevel - - Given a pointer to a list head for a linked list of leaf descriptions, + + Given a pointer to a list head for a linked list of leaf descriptions, and a count of how many nodes there are on the list, build a layer of the beast tree. This routine is called recursively until only one node is created. @@ -1211,13 +1211,13 @@ BranchList_s *leafInfo; /* pointer to current leaf node info struct */ During each recursive call, the old list of node descriptors is freed and a new one (describing the newly created nodes) is created. When the newly created node descriptor list contains only one descriptor, we are done. - + Parameters: pool - ZfsPool_s * - pointer to the pool management structure leafCount - LONG - count of how many leaves are being sent in GeneralMsg_s *genMsg volumeBitMap - NINT* - pointer to bitmap used to allocated vol free space - + Returns: zOK zFAILURE - Unable to successfully rebuild the tree. @@ -1245,7 +1245,7 @@ STATUS BuildNewBeastTreeLevel( Extent_s extent; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LGREEN,MSGNot("***Building Beast tree level in pass 1( leafCount = %d)\n"),leafCount); + DBG_DebugPrintf(LGREEN,MSGNot("***Building Beast tree level in pass 1( leafCount = %d)\n"),leafCount); #endif if(leafCount == 1) /* handle the root node case up front */ { @@ -1258,14 +1258,14 @@ STATUS BuildNewBeastTreeLevel( for(branchCount=0; RBTStats->leafInfoCount != 0; branchCount++) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot(" Building...leafInfoCount = %d)\n"),RBTStats->leafInfoCount); + DBG_DebugPrintf(LRED,MSGNot(" Building...leafInfoCount = %d)\n"),RBTStats->leafInfoCount); #endif - for(branchBuffer = NULL; branchBuffer == NULL;) + for(branchBuffer = NULL; branchBuffer == NULL;) { if(RBTStats->beastTreeBuiltFlag == ZRB_BUILD_BBTREE_PASS1) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("***Building Beast tree level in pass 1(block from bitmap\n")); + DBG_DebugPrintf(LRED,MSGNot("***Building Beast tree level in pass 1(block from bitmap\n")); #endif // zASSERT(volumeBitMap != NULL); if(ZRP_AllocFromBitMap(stats, RBTStats, /*volumeBitMap,*/ &branchBlkNum) != zOK) @@ -1276,12 +1276,12 @@ STATUS BuildNewBeastTreeLevel( else { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("***Building Beast tree level in pass 2(block from x-tree\n")); + DBG_DebugPrintf(LRED,MSGNot("***Building Beast tree level in pass 2(block from x-tree\n")); #endif // zASSERT(volumeBitMap == NULL); extent.lengthOfExtent = 1; extent.poolBlkNum = 0; - if ( zfsAllocExtent(genMsg, RBTStats->zVolume, &extent, + if ( zfsAllocExtent(genMsg, RBTStats->zVolume, &extent, XTREE_SYSTEM_REQUEST, NULL) != zOK ) { goto errorReturn; @@ -1311,7 +1311,7 @@ STATUS BuildNewBeastTreeLevel( }; NULLIFY(&branchInfo->nextBlock); branchInfo->blockNum = branchBlkNum; - for(i=0; in.branch[i]; branch->zid = leafInfo->lowestZid; - branch->child = leafInfo->blockNum; + branch->child = leafInfo->blockNum; free(leafInfo); } branchNode->numRecs = i; @@ -1341,7 +1341,7 @@ STATUS BuildNewBeastTreeLevel( RBTStats->leafInfoCount = branchCount; RBTStats->leafInfoStoredToDisk = FALSE; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LGREEN,MSGNot("---Building Beast tree( leafCount = %d)\n"),branchCount); + DBG_DebugPrintf(LGREEN,MSGNot("---Building Beast tree( leafCount = %d)\n"),branchCount); #endif BuildNewBeastTreeLevel(pool, branchCount, genMsg, /*volumeBitMap,*/ beastTreeRootBlock, stats, RBTStats); return zOK; @@ -1356,14 +1356,14 @@ errorReturn: { /* return the nodes that were passed in */ free(leafInfo); } - return zFAILURE; + return zFAILURE; } /* End of BuildNewBeastTreeLevel() */ -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- getNextExtentFromBitmap - + Returns: zOK zFAILURE @@ -1372,14 +1372,14 @@ errorReturn: STATUS getNextExtentFromBitmap(RepairStats_s *stats, BlockMap_s *bMap, - Blknum_t block, - Blknum_t totalBlocks, + Blknum_t block, + Blknum_t totalBlocks, Extent_s *request) { NINT state; Blknum_t i; - state = 0; /* flag that we are looking for the beginning of the next extent */ + state = 0; /* flag that we are looking for the beginning of the next extent */ request->lengthOfExtent = 0; request->poolBlkNum = 0; @@ -1419,8 +1419,8 @@ STATUS getNextExtentFromBitmap(RepairStats_s *stats, { return (zFAILURE); /* no more extents */ } -//g WinIncrementProgressBar(stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar, -//g stats->markedBlockCount+stats->bitmapAllocedBlockCount+stats->bitmapFreedBlockCount, +//g WinIncrementProgressBar(stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar, +//g stats->markedBlockCount+stats->bitmapAllocedBlockCount+stats->bitmapFreedBlockCount, //g stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar->decimalPlaces); //g DisplayRepairProgressPass(stats, REPAIR_PHASE_FILES); @@ -1494,10 +1494,10 @@ STATUS testConflictSystemBit(RepairStats_s *stats, Blknum_t blockNum) } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- ZRB_FreeNonSystemXLinkedBlocks - + Returns: zOK zFAILURE @@ -1533,12 +1533,12 @@ STATUS ZRB_FreeNonSystemXLinkedBlocks(GeneralMsg_s *genMsg, RepairStats_s *stats return (zOK); } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- BuildNewFreeTree build the free tree from the allocation bit map - + Returns: zOK zFAILURE @@ -1621,8 +1621,8 @@ STATUS BuildNewFreeTree(GeneralMsg_s *genMsg,ZfsPool_s *pool,Blknum_t specialLea } if(request.lengthOfExtent >= specialBlocksLeft) { - request.lengthOfExtent = specialBlocksLeft; - ccode = zFAILURE; /* not really and error, just a flag that we are done */ + request.lengthOfExtent = specialBlocksLeft; + ccode = zFAILURE; /* not really and error, just a flag that we are done */ } else { @@ -1665,8 +1665,8 @@ STATUS BuildNewFreeTree(GeneralMsg_s *genMsg,ZfsPool_s *pool,Blknum_t specialLea } /* And now pack the beast back into the leaf buffer */ - if (ZRB_PackSystemBeastInSpecialBlock(genMsg, - &stats->RepairZfsPoolStats->RBTStats, + if (ZRB_PackSystemBeastInSpecialBlock(genMsg, + &stats->RepairZfsPoolStats->RBTStats, &freeTreeBeast->ZFSFXroot, ZFSPOOL_FREETREE_ZID, leafNode) != zOK) { zASSERT("Error packing beast in to the beast tree leaf" == NULL); @@ -1676,14 +1676,14 @@ STATUS BuildNewFreeTree(GeneralMsg_s *genMsg,ZfsPool_s *pool,Blknum_t specialLea return zOK; } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- updateFreeTree - + update the free tree with the x-linked blocks (the files have been or will be deleted) that are not system blocks. We do not free system blocks because they have been validated as legal so we leave them in their tree. - + Returns: zOK zFAILURE @@ -1722,8 +1722,8 @@ STATUS updateFreeTree(GeneralMsg_s *genMsg,ZfsPool_s *pool,Blknum_t specialLeaf, /* setup pool to point to free tree beast */ zASSERT(pool->freeExtent == freeTreeBeast); /* And now pack the beast back into the leaf buffer */ - if ( ZRB_PackSystemBeastInSpecialBlock(genMsg, - &stats->RepairZfsPoolStats->RBTStats, + if ( ZRB_PackSystemBeastInSpecialBlock(genMsg, + &stats->RepairZfsPoolStats->RBTStats, &freeTreeBeast->ZFSFXroot, ZFSPOOL_FREETREE_ZID, leafNode) != zOK) { zASSERT("Error packing beast in to the beast tree leaf" == NULL); @@ -1734,22 +1734,22 @@ STATUS updateFreeTree(GeneralMsg_s *genMsg,ZfsPool_s *pool,Blknum_t specialLeaf, } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- RebuildBeastTree - + Given a pointer to a linked list and some pool information, build the branches of a new Beast Tree - + Parameters: - + pool - ZfsPool_s * - pointer to the pool management structure leftLeaf - BlkNum_t - points to left most leaf in the Beast Tree specialLeaf - BlkNum_t - points to special leaf GeneralMsg_s *genMsg - + Returns: - + zOK zFAILURE - Unable to successfully rebuild the tree. @@ -1767,8 +1767,8 @@ STATUS BuildNewBeastTree(ZfsPool_s *pool, ZfsBeastTreeBeast_s *beastTreeBeast; Blknum_t beastRoot; //g IoMsg_s iomsg; /* used for zFS_ReadPoolBlk */ - Buffer_s *leafBuffer; - Buffer_s *buffer; + Buffer_s *leafBuffer; + Buffer_s *buffer; BeastTreeNode_s *leafNode; /* pointer into the special leaf node */ BeastTreeNode_s *node; /* pointer into the leftmost leaf node in a beast leaf */ @@ -1820,14 +1820,14 @@ STATUS BuildNewBeastTree(ZfsPool_s *pool, // BEASTHASH_Insert((File_s*)beastTreeBeast); // DQ_RMV((File_s*)beastTreeBeast,FILEvolLink); - + /* Update the root block number in the beast tree beast */ beastTreeBeast = RBTStats->zVolume->beastTree; beastTreeBeast->zfsBtree.p.btRoot = beastRoot; /* And now pack the beast back into the leaf buffer */ if (ZRB_PackSystemBeastInSpecialBlock(genMsg, RBTStats, - &beastTreeBeast->ZFSBEASTTREEroot, + &beastTreeBeast->ZFSBEASTTREEroot, ZFSPOOL_VOLBSTTREE_ZID, leafNode) != zOK) { zASSERT("Error packing beast in to the beast tree leaf" == NULL); @@ -2035,7 +2035,7 @@ void *getFosterParent(GeneralMsg_s *genMsg, void *voidVol, Zid_t zid, NINT latch /************************************************************************** * ZRB_undoParentEntryNames() ***************************************************************************/ -void ZRB_undoParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *beast, ParentEntry_s *parent, LinkedNameEntry_s *endNode, ZfsVolume_s *zVol) +void ZRB_undoParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *beast, ParentEntry_s *parent, LinkedNameEntry_s *endNode, ZfsVolume_s *zVol) { LinkedNameEntry_s *nnode; NamedBeast_s *directory; @@ -2065,8 +2065,8 @@ void ZRB_undoParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *beast, Parent deleteNameFlags |= NF_LAST_NAME; directory->NAMEDcomnOps.BST_removeNameFromDirectory( genMsg, beast->NAMEDzid, directory, nnode->p.nameSpaceMask, - parent->p.nameType, nnode->p.name, - /* cnt parent->p.nameUniquifier,*/ deleteNameFlags, (Xaction_s*)xaction, parent->t); + parent->p.nameType, nnode->p.name, + /* cnt parent->p.nameUniquifier,*/ deleteNameFlags, (Xaction_s*)xaction, parent->t); // UNX_LATCH(&beast->NAMEDbeastLatch); COMN_UnlatchAndRelease(&directory, XLATCHED); deleteNameFlags &= ~NF_FIRST_NAME; @@ -2086,12 +2086,12 @@ void ZRB_undoParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *beast, Parent * Comments: * This routine adds all the names for a beast for the given parent (either first parent or * other parents). if the parent does not exist, we create a foster parent for it, fix up - * the beast to use the new foster parent, and add the name and return zOK. + * the beast to use the new foster parent, and add the name and return zOK. ***************************************************************************/ STATUS ZRB_doParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *beast, ParentEntry_s *parent, ZfsVolume_s *zVol, RepairStats_s *stats,RBTStats_s *RBTStats ) { ZfsXaction_s *xaction; - LinkedNameEntry_s *nnode; + LinkedNameEntry_s *nnode; NamedBeast_s *directory; NINT addNameFlags = NF_FIRST_NAME; BOOL allDone; @@ -2101,7 +2101,7 @@ STATUS ZRB_doParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *beast, Parent /* Need to check to see if this is a foster parent that is already * in name tree (from when it was created) and skip if it is. - * If this is the ".FPD" directory or if its parent is the ".FPD" + * If this is the ".FPD" directory or if its parent is the ".FPD" * directory, the name is already in the name tree */ @@ -2110,7 +2110,7 @@ STATUS ZRB_doParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *beast, Parent if(beast->NAMEDfirstParentZid == RBTStats->rebuildDirNameZid || beast->root.zid == RBTStats->rebuildDirNameZid) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("SKIPPED BEAST ZID = 0x%Lx\n"), beast->root.zid); + DBG_DebugPrintf(LRED,MSGNot("SKIPPED BEAST ZID = 0x%Lx\n"), beast->root.zid); #endif return zOK; } @@ -2119,7 +2119,7 @@ STATUS ZRB_doParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *beast, Parent * did not get completed (for whatever reason, multiple transactions???) and the beast * was not removed */ - if( /* cnt (parent->p.nameUniquifier == zFNU_INVALID_NAME_UNIQUIFIER) + if( /* cnt (parent->p.nameUniquifier == zFNU_INVALID_NAME_UNIQUIFIER) && */(parent->p.primaryNameSpaceID == (BYTE)zNSPACE_INVALID) && (parent->p.zid == zINVALID_ZID) && ((beast->NAMEDroot.storage.zfsInfo->fmap.numRecs == 0) || (beast->NAMEDroot.storage.zfsInfo->fmap.numRecs == 1)) @@ -2134,7 +2134,7 @@ STATUS ZRB_doParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *beast, Parent */ if ( (parent->p.zid == zINVALID_ZID) && (DQ_EMPTY(&parent->names)) ) { - // need to set errno? + // need to set errno? ForceSetErrno(genMsg,zERR_UNSUPPORTED_OBJECT_LAYOUT); return zFAILURE; } @@ -2148,7 +2148,7 @@ STATUS ZRB_doParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *beast, Parent /* we now have a directory for the insert that is XLATCHED or a NULL*/ if(directory == NULL) - { + { EndXlocal(xaction); if ( stats->RS_NumOrphanDirCreateErrors == 0 ) { @@ -2206,7 +2206,7 @@ STATUS ZRB_doParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *beast, Parent if( COMN_IsDerivedFrom(beast, zFTYPE_AUTH_BEAST) ) { if(((AuthBeast_s *)beast)->AUTHauthModelOps->addAuthInfo(genMsg, - (AuthBeast_s *)beast, directory->NAMEDzid, + (AuthBeast_s *)beast, directory->NAMEDzid, &directory->NAMEDbeastLatch) != zOK) { /* FixFixFix6 -- What should we do if this function fails? */ @@ -2252,23 +2252,23 @@ Zid_t LeafNodesReadAhead(GeneralMsg_s *genMsg, RootBeast_s *readBeast, Blknum_t if(buffer == NULL) return zINVALID_ZID; /* if we fail, guess where next leaf block might be */ node = (BeastTreeNode_s *)buffer->pBuf.data; - if(zRepairValidateNode (node) != zOK) + if(zRepairValidateNode (node) != zOK) { CACHE_RELEASE(buffer); return zINVALID_ZID; } - if (!BBT_IS_LEAF(node)) + if (!BBT_IS_LEAF(node)) { - blocks[i+1] = findChildBlock(node, zid, &temp); + blocks[i+1] = findChildBlock(node, zid, &temp); CACHE_RELEASE(buffer); - } + } else { CACHE_RELEASE(buffer); - break; + break; } - + } /* We went as far as we could go, see if any errors occured */ @@ -2292,14 +2292,14 @@ Zid_t LeafNodesReadAhead(GeneralMsg_s *genMsg, RootBeast_s *readBeast, Blknum_t if(buffer == NULL) return zINVALID_ZID; /* if we fail, guess where next leaf block might be */ node = (BeastTreeNode_s *)buffer->pBuf.data; - if(zRepairValidateNode (node) != zOK) + if(zRepairValidateNode (node) != zOK) { CACHE_DIRTY_RELEASE(buffer); return zINVALID_ZID; } - readAheadCount = (Config.cache.numPagesAllocated>>2 > node->numRecs) ? - node->numRecs : + readAheadCount = (Config.cache.numPagesAllocated>>2 > node->numRecs) ? + node->numRecs : Config.cache.numPagesAllocated>>2; /* Do the readahead of all the children buffers */ @@ -2367,7 +2367,7 @@ Buffer_s *GetBeastTreeLeafBuffer2( { block = node->n.branch[i].child; newBuffer = GetBeastTreeLeafBuffer2(genMsg, rStats, zid, block, zVolume, - level, index, readAheadZid, lowBranchLevel, + level, index, readAheadZid, lowBranchLevel, cacheMode); if ( level == *lowBranchLevel ) { @@ -2465,7 +2465,7 @@ Buffer_s *GetBeastTreeLeafBuffer( Buffer_s *buffer; buffer = GetBeastTreeLeafBuffer2( genMsg, stats, zid, blocknum, zVolume, - 0, index, readAheadZid, &lowBranchLevel, + 0, index, readAheadZid, &lowBranchLevel, cacheMode ); return( buffer ); } /* End of GetBeastTreeLeafBuffer() */ @@ -2474,9 +2474,9 @@ Buffer_s *GetBeastTreeLeafBuffer( //QUAD ZRP_VS_TODRecordKey; /************************************************************************** - * + * ***************************************************************************/ -void ReBuildLogDeletionOrMessage( GeneralMsg_s *genMsg, RepairStats_s *stats, RBTStats_s *RBTStats, +void ReBuildLogDeletionOrMessage( GeneralMsg_s *genMsg, RepairStats_s *stats, RBTStats_s *RBTStats, PersistentNameEntry_s *pName, PersistentParentEntry_s *pEntry, NINT reasonMask, Zid_t beastZid, BOOL isNamed, NINT action ) { @@ -2532,9 +2532,9 @@ void ReBuildLogDeletionOrMessage( GeneralMsg_s *genMsg, RepairStats_s *stats, RB /************************************************************************** - * + * ***************************************************************************/ -STATIC void ReBuildLogTruncate( GeneralMsg_s *genMsg, RepairStats_s *stats, RBTStats_s *RBTStats, +STATIC void ReBuildLogTruncate( GeneralMsg_s *genMsg, RepairStats_s *stats, RBTStats_s *RBTStats, PersistentNameEntry_s *pName, PersistentParentEntry_s *pEntry, NINT reasonMask, Zid_t beastZid, BOOL isNamed, QUAD dataEOF ) { @@ -2611,7 +2611,7 @@ void ReBuildLogDeletionOrMessageBeast( GeneralMsg_s *genMsg, RepairStats_s *stat pEntry = &namedBeast->NAMEDfirstParent.p; DQ_PEEK(&namedBeast->NAMEDfirstParent.names, nnode, LinkedNameEntry_s, nlink); if (nnode != NULL) - { + { pName = &nnode->p; } } @@ -2675,7 +2675,7 @@ void ReBuildLogTruncateBeast( GeneralMsg_s *genMsg, RepairStats_s *stats, RBTSta * The zids of these beasts may not have been accounted for by GreatestA- * llocatedZid, so we need to look beyond the greatest allocated zid for * these beasts and delete them. The RDEL beasts zids have been accounted - * for. + * for. ***************************************************************************/ STATUS ZRB_CleanupBeastsBeyondLastZid( GeneralMsg_s *genMsg, @@ -2760,13 +2760,13 @@ STATUS ZRB_CleanupBeastsBeyondLastZid( if ( (rebuildMagic == REBUILD_DELETE_UNREADABLE_BEAST_MAGIC) || ( rebuildMagic == REBUILD_FILE_IS_SNAPSHOT) ) - { + { aStack->zidsToDelete[zidsToDeleteIndex] = currentZid; zidsToDeleteIndex++; continue; } } /* End of Leaf processing */ - if ((leafNode->n.leaf.nextLeaf == INVALID_BLK) || + if ((leafNode->n.leaf.nextLeaf == INVALID_BLK) || (leafNode->n.leaf.nextLeaf == 0)) { moreZids = FALSE; @@ -2837,11 +2837,11 @@ void ZRB_FixVolumeCompInfo(RootBeast_s *beast, RBTStats_s *RBTStats, BOOL delete RBTStats->numCompDelFiles++; } } - - RBTStats->numPreCompressedFileBlocks += + + RBTStats->numPreCompressedFileBlocks += (CEILING(beast->eof, beast->ROOTvolume->VOLblockSize) >> beast->ROOTvolume->VOLblockShift); } - else + else { if (COMN_IsDerivedFrom(beast,zFTYPE_NAMED_DATA_STREAM)) { @@ -2853,10 +2853,10 @@ void ZRB_FixVolumeCompInfo(RootBeast_s *beast, RBTStats_s *RBTStats, BOOL delete } else if ( ((beast->beastClass->classID == zFTYPE_COMPRESSION)) || (!(beast->ROOTvolume->VOLcompAttributes.compFlags & VOL_COMP_FLAGS_UPGRADE_FINISHED) && - (beast->beastClass->classID == zFTYPE_ROOT_BEAST) && (beast->eof != 0)) ) + (beast->beastClass->classID == zFTYPE_ROOT_BEAST) && (beast->eof != 0)) ) { // This is a compressed beast // compile counts for numCompressedFileBlocks - RBTStats->numCompressedFileBlocks += + RBTStats->numCompressedFileBlocks += (CEILING(beast->eof, beast->ROOTvolume->VOLblockSize) >> beast->ROOTvolume->VOLblockShift); } } @@ -2880,7 +2880,7 @@ void ZRB_AddZidToDelete(ZidsToDelete_s *zidsToDelete, Zid_t zid) if(zidsToDelete->count < zidsToDelete->max) { - zidsToDelete->zid[zidsToDelete->count] = zid; + zidsToDelete->zid[zidsToDelete->count] = zid; zidsToDelete->count++; } return; @@ -2891,8 +2891,8 @@ void ZRB_AddZidToDelete(ZidsToDelete_s *zidsToDelete, Zid_t zid) * * Checks a znode that is to be deleted for other zids that must also * be deleted. Checks the following zids in a single beast: - * The beast is left in packed format. - * AUTH_BEAST: ACL and VIS overFlowZid + * The beast is left in packed format. + * AUTH_BEAST: ACL and VIS overFlowZid * ACL_BEAST: nextOverflowZid * VIS_BEAST: nextOverflowZid * COMPRESS_BEAST: compZid @@ -2934,7 +2934,7 @@ void ZRB_CheckZnodeForZidPointer(ZfsVolume_s *zfsVol,Znode_s *znodeBeast, ZidsTo znode_V1 = (V1_ZFSPackedRoot_s *)znode; rebuildMagic = znode_V1->rebuildMagic; curVar = (BYTE *)(((BYTE *)znode_V1) + sizeof(V1_ZFSPackedRoot_s)); - fmap = (Fmap_s *)(((BYTE *)znode_V1) + + fmap = (Fmap_s *)(((BYTE *)znode_V1) + sizeof(V1_ZFSPackedRoot_s) + znode_V1->variableSize); fmapSize = znode_V1->sizeFmap; deletedParentEntrySize = sizeof(V1_DeletedPersistentParentEntry_s); @@ -2946,7 +2946,7 @@ void ZRB_CheckZnodeForZidPointer(ZfsVolume_s *zfsVol,Znode_s *znodeBeast, ZidsTo znode_V1 = NULL; rebuildMagic = znode->rebuildMagic; curVar = (BYTE *)(((BYTE *)znode) + sizeof(ZFSPackedRoot_s)); - fmap = (Fmap_s *)(((BYTE *)znode) + + fmap = (Fmap_s *)(((BYTE *)znode) + sizeof(ZFSPackedRoot_s) + znode->variableSize); fmapSize = znode->sizeFmap; deletedParentEntrySize = sizeof(DeletedPersistentParentEntry_s); @@ -3001,17 +3001,17 @@ void ZRB_CheckZnodeForZidPointer(ZfsVolume_s *zfsVol,Znode_s *znodeBeast, ZidsTo if (numParents > 0) { - /* dummy points to first of all parents - * (PersistentParentEntry_s) + /* dummy points to first of all parents + * (PersistentParentEntry_s) */ for ( i = 0; i < numParents; i++) { /* add the size of each parent entry for this beast */ numNames = ((PersistentParentEntry_s *)dummy)->numNames; - if (((PersistentParentEntry_s *)dummy)->nameType == + if (((PersistentParentEntry_s *)dummy)->nameType == zNTYPE_DELETED_FILE) { - dummy += sizeof(PersistentParentEntry_s) + + dummy += sizeof(PersistentParentEntry_s) + deletedParentEntrySize; } else @@ -3019,12 +3019,12 @@ void ZRB_CheckZnodeForZidPointer(ZfsVolume_s *zfsVol,Znode_s *znodeBeast, ZidsTo dummy += sizeof(PersistentParentEntry_s); } /* dummy points past this parent entry potentially - * at the list of names (if any, PersistentNameEntry_s) + * at the list of names (if any, PersistentNameEntry_s) */ for (k = 0; k < numNames; k++) { /* add the size of each name entry for this parent */ - dummy += REALSIZE_PersistentNameEntry_s + + dummy += REALSIZE_PersistentNameEntry_s + NAMED_GET_NSIZE((PersistentNameEntry_s *)dummy); } } @@ -3086,7 +3086,7 @@ void ZRB_CheckZnodeForZidPointer(ZfsVolume_s *zfsVol,Znode_s *znodeBeast, ZidsTo } else { - used = sizeof(PackedUnixInfo_s) + + used = sizeof(PackedUnixInfo_s) + ((PackedUnixInfo_s *)curVar)->unixInfo.variableSize; } break; @@ -3270,7 +3270,7 @@ void ZRB_RebuildOverflowBeastChain( if ( overflowChainArray != NULL ) { NINT i; - + for ( i=0; i < overflowChainCount; i++ ) { if(overflowChainArray[i] == overflowZid) @@ -3477,7 +3477,7 @@ STATUS ZRB_ReBuildNameTree( * "REBUILD_DELETE_UNREADABLE_BEAST_MAGIC" * or "REBUILD_FILE_IS_SNAPSHOT", because the * fmap blocks were not set in the bitmap. Only - * free the fmap blocks for the beasts that are marked + * free the fmap blocks for the beasts that are marked * "REBUILD_DELETE_BEAST_MAGIC" because their fmap blocks * were set in the bitmap */ @@ -3583,8 +3583,8 @@ STATUS ZRB_ReBuildNameTree( #if NSS_DEBUG IS_ENABLED else { - DBG_DebugPrintf(LRED, - MSGNot("CORRUPTED BEAST(0x%lx) ==> Zid = 0x%Lx, ID = 0x%x\n"), + DBG_DebugPrintf(LRED, + MSGNot("CORRUPTED BEAST(0x%lx) ==> Zid = 0x%Lx, ID = 0x%x\n"), rebuildMagic, currentZid,znode->header.type ); } #endif @@ -3610,7 +3610,7 @@ STATUS ZRB_ReBuildNameTree( if ( beast == NULL ) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("%s Unreadable Zid Error = %d(%s), Zid = 0x%Lx\n"), + DBG_DebugPrintf(LRED,MSGNot("%s Unreadable Zid Error = %d(%s), Zid = 0x%Lx\n"), WHERE, GetErrno(genMsg), GetErrnoSetter(genMsg), currentZid ); #endif @@ -3629,7 +3629,7 @@ STATUS ZRB_ReBuildNameTree( * verify will report missing names (if a named beast). * * Before July 30, 2001 we would delete this beast. - * + * */ (void)ZRP_printf_Log( stats, ZRP_LOG_WARNING_TAG("Zid 0x%Lx not processed. Status %ld(%s)."), @@ -3663,7 +3663,7 @@ STATUS ZRB_ReBuildNameTree( // if( stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_rebuildPurge ) if( pInfo->VPRS_Purge ) - { + { if( ZRB_FileIsDeleted(namedBeast) ) { freeConflictFmap(genMsg, stats, &beast->storage.zfsInfo->fmap, RBTStats); @@ -3680,9 +3680,9 @@ STATUS ZRB_ReBuildNameTree( { if( ((AuthBeast_s *)beast)->authInfo.zas->p.trusteeOverflow != zINVALID_ZID) { - Xaction_s *overflowXaction; + Xaction_s *overflowXaction; - overflowXaction = COMN_BeginXLocal(beast); + overflowXaction = COMN_BeginXLocal(beast); ZRB_RebuildOverflowBeastChain(genMsg, beast, stats, RBTStats, overflowXaction); COMN_EndXLocal(beast, &overflowXaction); } @@ -3698,7 +3698,7 @@ STATUS ZRB_ReBuildNameTree( // if( GetErrno( genMsg ) != zERR_BEAST_BEING_PURGED_IN_REBUILD ) // { ClearErrno( genMsg ); - freeConflictFmap(genMsg, stats, &beast->storage.zfsInfo->fmap, RBTStats ); + freeConflictFmap(genMsg, stats, &beast->storage.zfsInfo->fmap, RBTStats ); ReBuildLogDeletionOrMessageBeast( genMsg, stats, RBTStats, beast, RAV_TLF_UNFINISHED_DELETE, RAV_TLF_ACTION_DELETE /* MSGNot("%U DELETED (BAD PARENT DIRECTORY)")*/ ); // } @@ -3714,7 +3714,7 @@ STATUS ZRB_ReBuildNameTree( case BEAST_VERSION_2: DQ_FOREACH(&namedBeast->reserved,pnode,LinkedParentEntry_s,plink) - { + { if ( pnode->pentry.p.nameType != zNTYPE_DELETED_FILE ) { allNamesAreDeleted = FALSE; @@ -3725,7 +3725,7 @@ STATUS ZRB_ReBuildNameTree( { status = GetErrno( genMsg ); ClearErrno( genMsg ); - ZRB_undoParentEntryNames( genMsg, namedBeast, + ZRB_undoParentEntryNames( genMsg, namedBeast, &namedBeast->NAMEDfirstParent, NULL, RBTStats->zVolume ); // if( status != zERR_BEAST_BEING_PURGED_IN_REBUILD ) @@ -3754,7 +3754,7 @@ STATUS ZRB_ReBuildNameTree( { /* These two stats need to be kept as globals and * then flushed out when the name tree rebuild is done. */ - if (COMN_GetPurgeableBlksCnt(genMsg, namedBeast, &purgeableBlks) != zOK) + if (COMN_GetPurgeableBlksCnt(genMsg, namedBeast, &purgeableBlks) != zOK) { ClearErrno(genMsg); zASSERT("We don't expect to see this" == NULL); @@ -3767,19 +3767,19 @@ STATUS ZRB_ReBuildNameTree( } else if (MFL_ENABLED(namedBeast->NAMEDvolume) && COMN_IsDerivedFrom(namedBeast, zFTYPE_FILE) && - (((File_s *)namedBeast)->FILEattributes & + (((File_s *)namedBeast)->FILEattributes & (zFA_ARCHIVE|zFA_ATTR_ARCHIVE))) { - ZfsXaction_s *localXaction; + ZfsXaction_s *localXaction; - localXaction = BeginXLocal(namedBeast->NAMEDvolume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - if (ZFSVOL_VOL_insertMFLEntry(genMsg, - namedBeast->NAMEDvolume, namedBeast->NAMEDzid, - namedBeast->NAMEDvolume->VOLepoch, - &localXaction->xaction) != zOK) - { - /* Ignore all errors; they've been handled - * by above routine itself properly */ + localXaction = BeginXLocal(namedBeast->NAMEDvolume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); + if (ZFSVOL_VOL_insertMFLEntry(genMsg, + namedBeast->NAMEDvolume, namedBeast->NAMEDzid, + namedBeast->NAMEDvolume->VOLepoch, + &localXaction->xaction) != zOK) + { + /* Ignore all errors; they've been handled + * by above routine itself properly */ ClearErrno(genMsg); } EndXlocal(localXaction); @@ -3834,7 +3834,7 @@ nextGoodZid:; //g WinIncrementProgressBar(stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar, stats->countedObjects, stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar->decimalPlaces); //g lastCount += stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar->incThreshold; //g DisplayRepairProgressPass(stats, REPAIR_PHASE_NAMES); -//g } +//g } // stats->blocksWritten++; } // processDeletedBeastZids(genMsg, stats, RBTStats); @@ -4072,7 +4072,7 @@ Blknum_t GetBeastRootBlockNum(GeneralMsg_s *genMsg, RepairStats_s *rStats, ZfsPo BEASTHASH_Insert((RootBeast_s *)beastTreeBeast); DQ_RMV((File_s*)beastTreeBeast,FILEvolLink); - + /* Update the root block number in the beast tree beast */ beastRootBlockNum = beastTreeBeast->zfsBtree.p.btRoot; RBTStats->zVolume->beastTree = beastTreeBeast; @@ -4091,9 +4091,9 @@ Blknum_t GetBeastRootBlockNum(GeneralMsg_s *genMsg, RepairStats_s *rStats, ZfsPo defaultFlushWait( &pool->ZFSPOOLmycache.agent ); cacheTossAll( &pool->ZFSPOOLmycache ); /* we make sure we toss the mycache here because we read it in on the pool - * and routines before here ZRB_LoadUserAndDsrBeasts and + * and routines before here ZRB_LoadUserAndDsrBeasts and * ZRB_MapSpecialLeaf may have dirtied the block (special leaf). - * From now on we will read it it on the beasttree beast so we + * From now on we will read it it on the beasttree beast so we * must make sure it is flushed to disk before then */ return beastRootBlockNum; @@ -4102,11 +4102,11 @@ Blknum_t GetBeastRootBlockNum(GeneralMsg_s *genMsg, RepairStats_s *rStats, ZfsPo /************************************************************************** - * + * ***************************************************************************/ -STATUS beastTreeBranchPass(GeneralMsg_s *genMsg, - ZfsPool_s *pool, - RepairStats_s *stats, +STATUS beastTreeBranchPass(GeneralMsg_s *genMsg, + ZfsPool_s *pool, + RepairStats_s *stats, RBTStats_s *RBTStats) { Blknum_t beastRootBlockNum=0; @@ -4160,8 +4160,8 @@ STATUS beastTreeBranchPass(GeneralMsg_s *genMsg, beastRootBlockNum = RBTStats->zVolume->beastTree->zfsBtree.p.btRoot; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("***Starting Leaf Walk a second time\n")); - DBG_DebugPrintf(LRED,MSGNot("*** to build beast tree\n")); + DBG_DebugPrintf(LRED,MSGNot("***Starting Leaf Walk a second time\n")); + DBG_DebugPrintf(LRED,MSGNot("*** to build beast tree\n")); #endif for(;( (leftLeaf != 0) && (leftLeaf != INVALID_BLK) ) ;leafCount++) { @@ -4184,7 +4184,7 @@ STATUS beastTreeBranchPass(GeneralMsg_s *genMsg, if(buffer == NULL) { /* - * if we can't read the leaf at this point, we can't do a + * if we can't read the leaf at this point, we can't do a * 'FindNextLeafBlock' because we have been allocating blocks * and the old beast tree branches could have been overwritten. * This really should never happen because we have fixed up the @@ -4202,9 +4202,9 @@ STATUS beastTreeBranchPass(GeneralMsg_s *genMsg, zASSERT( node->lsn == 0 ); zASSERT(node->magic == LEAF_MAGIC); - zASSERT(BBT_IS_LEAF(node)); + zASSERT(BBT_IS_LEAF(node)); - nextLeaf = node->n.leaf.nextLeaf; + nextLeaf = node->n.leaf.nextLeaf; znode = (Znode_s *)&node->LEAF.znode[node->LEAF.znodePtr[MAX_LEAF_PTRS]]; /* point at the leftmost beast in the buffer */ @@ -4217,8 +4217,8 @@ STATUS beastTreeBranchPass(GeneralMsg_s *genMsg, if (((V1_ZFSPackedRoot_s *)znode)->rebuildReZidState == REBUILD_REZID_STATE_REZID_DONE) { - currentZid = ((V1_ZFSPackedRoot_s *)znode)->rebuildReZid; - if (((V1_ZFSPackedRoot_s *)znode)->rebuildMagic == + currentZid = ((V1_ZFSPackedRoot_s *)znode)->rebuildReZid; + if (((V1_ZFSPackedRoot_s *)znode)->rebuildMagic == REBUILD_FILE_IS_SNAPSHOT) { currentZid |= SNAPSHOT_ZID_FLAG; @@ -4233,7 +4233,7 @@ STATUS beastTreeBranchPass(GeneralMsg_s *genMsg, REBUILD_REZID_STATE_REZID_DONE) { currentZid = ((ZFSPackedRoot_s *)znode)->rebuildReZid; - if (((ZFSPackedRoot_s *)znode)->rebuildMagic == + if (((ZFSPackedRoot_s *)znode)->rebuildMagic == REBUILD_FILE_IS_SNAPSHOT) { currentZid |= SNAPSHOT_ZID_FLAG; @@ -4267,7 +4267,7 @@ STATUS beastTreeBranchPass(GeneralMsg_s *genMsg, leftLeaf = saveLeftLeaf; zASSERT( leftLeaf != 0 ); zASSERT( leftLeaf != INVALID_BLK ); - if((ccode = BuildNewBeastTree(pool, leftLeaf, specialLeaf, genMsg, /*NULL, */leafCount, stats, RBTStats)) != zOK) + if((ccode = BuildNewBeastTree(pool, leftLeaf, specialLeaf, genMsg, /*NULL, */leafCount, stats, RBTStats)) != zOK) { ccode = ZRP_Error_Return( stats, GetErrno(genMsg), GetErrnoSetter(genMsg), WHERE ); return ccode; @@ -4276,11 +4276,11 @@ STATUS beastTreeBranchPass(GeneralMsg_s *genMsg, } /************************************************************************** - * + * * (repair) ***************************************************************************/ -void ZRB_ReserveLogicalVolDataBlocks(RepairStats_s *stats, - RBTStats_s *RBTStats, +void ZRB_ReserveLogicalVolDataBlocks(RepairStats_s *stats, + RBTStats_s *RBTStats, ZfsVolume_s *zVolume) { /*-----------------------------------------------------------*/ @@ -4469,7 +4469,7 @@ void ZRB_InitPoolData(RepairStats_s *stats) /************************************************************************** - * + * ***************************************************************************/ STATUS ZRB_RemoveNodeFromLinkedList(GeneralMsg_s *genMsg, RepairStats_s *rStats, RBTStats_s *RBTStats, Blknum_t previousLeaf, Blknum_t nextLeaf) { @@ -4488,7 +4488,7 @@ STATUS ZRB_RemoveNodeFromLinkedList(GeneralMsg_s *genMsg, RepairStats_s *rStats, return zFAILURE; } node = (BeastTreeNode_s *)previousBuffer->pBuf.data; - node->n.leaf.nextLeaf = nextLeaf; + node->n.leaf.nextLeaf = nextLeaf; CACHE_DIRTY_RELEASE(previousBuffer); } return zOK; @@ -4497,14 +4497,14 @@ STATUS ZRB_RemoveNodeFromLinkedList(GeneralMsg_s *genMsg, RepairStats_s *rStats, /************************************************************************** * The passed in buffer gets released in this routine ***************************************************************************/ -STATUS ZRB_ProcessNodeInLinkedList(GeneralMsg_s *genMsg, - RepairStats_s *stats, - RBTStats_s *RBTStats, - BeastTreeNode_s *node, - Buffer_s *buffer, - Blknum_t leftLeaf, - Blknum_t *previousLeaf, - Zid_t *previousZid, +STATUS ZRB_ProcessNodeInLinkedList(GeneralMsg_s *genMsg, + RepairStats_s *stats, + RBTStats_s *RBTStats, + BeastTreeNode_s *node, + Buffer_s *buffer, + Blknum_t leftLeaf, + Blknum_t *previousLeaf, + Zid_t *previousZid, Zid_t *readAheadZid) { Zid_t currentZid; @@ -4557,8 +4557,8 @@ DBG_DebugPrintf(LRED, MSGNot("(LV_REBUILD)calling VerifyFileMap \n")); if (((V1_ZFSPackedRoot_s *)znode)->rebuildReZidState == REBUILD_REZID_STATE_REZID_DONE) { - currentZid = ((V1_ZFSPackedRoot_s *)znode)->rebuildReZid; - if (((V1_ZFSPackedRoot_s *)znode)->rebuildMagic == + currentZid = ((V1_ZFSPackedRoot_s *)znode)->rebuildReZid; + if (((V1_ZFSPackedRoot_s *)znode)->rebuildMagic == REBUILD_FILE_IS_SNAPSHOT) { currentZid |= SNAPSHOT_ZID_FLAG; @@ -4572,8 +4572,8 @@ DBG_DebugPrintf(LRED, MSGNot("(LV_REBUILD)calling VerifyFileMap \n")); if (((ZFSPackedRoot_s *)znode)->rebuildReZidState == REBUILD_REZID_STATE_REZID_DONE) { - currentZid = ((ZFSPackedRoot_s *)znode)->rebuildReZid; - if (((ZFSPackedRoot_s *)znode)->rebuildMagic == + currentZid = ((ZFSPackedRoot_s *)znode)->rebuildReZid; + if (((ZFSPackedRoot_s *)znode)->rebuildMagic == REBUILD_FILE_IS_SNAPSHOT) { currentZid |= SNAPSHOT_ZID_FLAG; @@ -4583,7 +4583,7 @@ DBG_DebugPrintf(LRED, MSGNot("(LV_REBUILD)calling VerifyFileMap \n")); } } - *previousZid = currentZid; + *previousZid = currentZid; if(SaveLeafInfo(leftLeaf, currentZid, stats, RBTStats, genMsg) != zOK) { @@ -4612,11 +4612,11 @@ DBG_DebugPrintf(LRED, MSGNot("(LV_REBUILD)calling VerifyFileMap \n")); if (!REZID_IN_PROCESS(RBTStats->zVolume)) { - ((V1_ZFSPackedRoot_s *)znode)->rebuildReZidState = + ((V1_ZFSPackedRoot_s *)znode)->rebuildReZidState = REBUILD_REZID_STATE_CLEAR; if (znode->header.zid >= zROOTDIR_ZID) { - ((V1_ZFSPackedRoot_s *)znode)->rebuildReZid = + ((V1_ZFSPackedRoot_s *)znode)->rebuildReZid = RBTStats->reZidCurrentZid++; } } @@ -4629,17 +4629,17 @@ DBG_DebugPrintf(LRED, MSGNot("(LV_REBUILD)calling VerifyFileMap \n")); if (!REZID_IN_PROCESS(RBTStats->zVolume)) { - ((ZFSPackedRoot_s *)znode)->rebuildReZidState = + ((ZFSPackedRoot_s *)znode)->rebuildReZidState = REBUILD_REZID_STATE_CLEAR; if (znode->header.zid >= zROOTDIR_ZID) { - ((ZFSPackedRoot_s *)znode)->rebuildReZid = + ((ZFSPackedRoot_s *)znode)->rebuildReZid = RBTStats->reZidCurrentZid++; } } break; } - if( (rebuildMagic == REBUILD_DELETE_BEAST_MAGIC) || + if( (rebuildMagic == REBUILD_DELETE_BEAST_MAGIC) || (rebuildMagic == REBUILD_DELETE_UNREADABLE_BEAST_MAGIC) || (rebuildMagic == REBUILD_FILE_IS_SNAPSHOT) ) { @@ -4726,7 +4726,7 @@ void ZRB_FixOverlappingLeafZids(RepairStats_s *stats, RBTStats_s *RBTStats, Beas Zid_t nextLeafLowZid = zOPEN_ENTRY_ZID; // 0xFFFFFFFFFFFFFFFF GeneralMsg_s genMsg; - if( !((node->n.leaf.nextLeaf == 0) || + if( !((node->n.leaf.nextLeaf == 0) || (node->n.leaf.nextLeaf == INVALID_BLK) || (node->n.leaf.nextLeaf > stats->pool->ZP_super->SB_Header.hdr.totalblocks)) ) { @@ -4750,7 +4750,7 @@ void ZRB_FixOverlappingLeafZids(RepairStats_s *stats, RBTStats_s *RBTStats, Beas { nextLeafLowZid = znode->header.zid; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(RED,MSGNot("<<<<<>>>>>> RANGE CHECKING prev ZID=0x%Lx, next ZID=0x%Lx\n"), + DBG_DebugPrintf(RED,MSGNot("<<<<<>>>>>> RANGE CHECKING prev ZID=0x%Lx, next ZID=0x%Lx\n"), RBTStats->prevLeafHighZid, nextLeafLowZid); #endif for (k = 0; k < node->numRecs; k++) @@ -4761,7 +4761,7 @@ void ZRB_FixOverlappingLeafZids(RepairStats_s *stats, RBTStats_s *RBTStats, Beas if(znode->header.zid != 0) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(RED,MSGNot("<<<<<>>>>>> ZID RANGE ERROR w-both: DELETED ZID 0x%Lx\n"), + DBG_DebugPrintf(RED,MSGNot("<<<<<>>>>>> ZID RANGE ERROR w-both: DELETED ZID 0x%Lx\n"), znode->header.zid ); #endif deleteZnodeFromChild(node,k); @@ -4801,7 +4801,7 @@ void ZRB_FixOverlappingLeafZids(RepairStats_s *stats, RBTStats_s *RBTStats, Beas if (znode->header.zid > RBTStats->prevLeafHighZid) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(RED,MSGNot("<<<<<<<<<<< prev ZID=0x%Lx\n"), RBTStats->prevLeafHighZid); + DBG_DebugPrintf(RED,MSGNot("<<<<<<<<<<< prev ZID=0x%Lx\n"), RBTStats->prevLeafHighZid); #endif for (k = 0; k < i; k++) { @@ -4811,7 +4811,7 @@ void ZRB_FixOverlappingLeafZids(RepairStats_s *stats, RBTStats_s *RBTStats, Beas if(znode->header.zid != 0) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(RED,MSGNot("<<<<<<<<<<< ZID RANGE ERROR w-prev: DELETED ZID 0x%Lx\n"), + DBG_DebugPrintf(RED,MSGNot("<<<<<<<<<<< ZID RANGE ERROR w-prev: DELETED ZID 0x%Lx\n"), znode->header.zid ); #endif deleteZnodeFromChild(node,k); @@ -4847,7 +4847,7 @@ Blknum_t ZRB_FindValidNextLeaf(GeneralMsg_s *genMsg, - if( (lastLeafBlock != INVALID_BLK) && + if( (lastLeafBlock != INVALID_BLK) && ((previousLeaf == lastLeafBlock) || (currentLeaf == lastLeafBlock)) ) { return INVALID_BLK; /* there is no next leaf, we're on the last leaf */ @@ -4871,7 +4871,7 @@ Blknum_t ZRB_FindValidNextLeaf(GeneralMsg_s *genMsg, (dummyZid < zid) ); // we circled back into our/some tree, can't use the block /* we found a good nextLeaf */ - return dummyLeaf; + return dummyLeaf; } @@ -4967,7 +4967,7 @@ Blknum_t ZRB_MapSpecialLeaf(GeneralMsg_s *genMsg, RepairStats_s *stats, RBTStats * First pass of rebuild. Go throught all leafs of Beast Tree. We * fill in a bitmap of used blocks. This includes file maps found * in the beast tree. Also gathers BT info so we can build the branches - * of the BT. + * of the BT. * ZFSVOLinUseBlocks ZLOG_ZLB_S_SIGNATURE ***************************************************************************/ STATUS ZRB_lvAllocationMapPass(GeneralMsg_s *genMsg, RepairStats_s *stats, ZlssVolumeLocator_s *lvBeast) @@ -4997,13 +4997,13 @@ STATUS ZRB_lvAllocationMapPass(GeneralMsg_s *genMsg, RepairStats_s *stats, ZlssV S_LATCH(&lvBeast->ZVLfile.FILEbeastLatch); lvBeast->ZVL_file.FILEuseCount++; /* get use count for Greg */ X_NOWAIT( &stats->zlssPool->ZLSSPOOLpool.cvsLatch, waitFlag ); -//g while ( (waitFlag == WAITED) && +//g while ( (waitFlag == WAITED) && //g (stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_flag != 0 /*CP_FLAG_CLEANUP*/)) while ( (waitFlag == WAITED) && !COMN_RAV_Terminate(stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_pInfo) ) { LB_delay(100); X_NOWAIT( &stats->zlssPool->ZLSSPOOLpool.cvsLatch, waitFlag ); - } + } zVolume = ZLSSVOL_LV_Load(genMsg, lvBeast, &stats->pool->ZFSPOOLvol, FALSE, TRUE ); BST_UNUSE_BEAST(&((File_s *)lvBeast)->FILEroot); /* remove useCount */ if (waitFlag == NOWAIT) @@ -5153,7 +5153,7 @@ STATUS ZRB_lvAllocationMapPass(GeneralMsg_s *genMsg, RepairStats_s *stats, ZlssV * First pass of rebuild. Go throught all leafs of Beast Tree. We * fill in a bitmap of used blocks. This includes file maps found * in the beast tree. Also gathers BT info so we can build the branches - * of the BT. + * of the BT. * * LOGIC as follows: * FOR EACH leaf in linked list @@ -5175,11 +5175,11 @@ STATUS ZRB_lvAllocationMapPass(GeneralMsg_s *genMsg, RepairStats_s *stats, ZlssV * | Remove leaf from linked list * | Update user entertainment * |___set up loop control variable with pointer to next leaf - * + * ***************************************************************************/ -STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, - RepairStats_s *rStats, - RBTStats_s *RBTStats, +STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, + RepairStats_s *rStats, + RBTStats_s *RBTStats, LONG *leafCount, BOOL specialBlockExists) { @@ -5200,7 +5200,7 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, NINT numValidNodes = 0; // NINT numInvalidNodes = 0; #endif -// testing code for killZid stuff, leave in but commented out +// testing code for killZid stuff, leave in but commented out //#if NSS_DEBUG IS_ENABLED // Zid_t killZid = 128; // Zid_t killZid2 = 129; @@ -5217,8 +5217,8 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, /*---------------------------------------------------------------*/ /* Map beast tree leaf blocks and their filemaps into the bitmap * * - * Process the special block (specialLeaf) separately and then run - * through the beast tree leafs getting a pointer to the left leaf + * Process the special block (specialLeaf) separately and then run + * through the beast tree leafs getting a pointer to the left leaf * from this special block *---------------------------------------------------------------*/ leftLeaf = ZRB_MapSpecialLeaf(genMsg, rStats, RBTStats); @@ -5233,11 +5233,11 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, } else { - /* This is the case where we are upgrading media format, and + /* This is the case where we are upgrading media format, and * the special system beasts blk does not exist yet. So we - * have to treat this block like any other leaf + * have to treat this block like any other leaf */ - leftLeaf = RBTStats->systemBeastBlkNum; + leftLeaf = RBTStats->systemBeastBlkNum; zASSERT( (leftLeaf != 0) && (leftLeaf != INVALID_BLK) ); if ( RAV_BlockIsEndBlock( leftLeaf ) ) { @@ -5248,10 +5248,10 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, } } /* load the Vol's BeastTree beast, UserSpaceRestrictions beast, - * DirSpaceRestrictions beast into memory. The other beast are Bst_New'd + * DirSpaceRestrictions beast into memory. The other beast are Bst_New'd * later in ZRB_CreatenewPoolSystemBeasts and ZRB_CreatenewVolSystemBeasts * - * The internal volume does not have a user tree and dir tree. + * The internal volume does not have a user tree and dir tree. * 6 pack formats may contain these trees. This routine can dirty the * leafBuffer. */ @@ -5266,8 +5266,8 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, ClearErrno( genMsg ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("Starting Leaf Walk\n")); - DBG_DebugPrintf(YELLOW,MSGNot(" *** LEAF INFO ***\n")); + DBG_DebugPrintf(LRED,MSGNot("Starting Leaf Walk\n")); + DBG_DebugPrintf(YELLOW,MSGNot(" *** LEAF INFO ***\n")); #endif // testing code for killZid stuff, leave in but commented out //#if NSS_DEBUG IS_ENABLED @@ -5328,10 +5328,10 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, { #if NSS_DEBUG IS_ENABLED numValidNodes++; - DBG_DebugPrintf(LRED,MSGNot("VALIDATED LEAF NODE #%d, numRec = %d (block = %d \n"),numValidNodes,node->numRecs,leftLeaf); + DBG_DebugPrintf(LRED,MSGNot("VALIDATED LEAF NODE #%d, numRec = %d (block = %d \n"),numValidNodes,node->numRecs,leftLeaf); #endif /* remember this block in case nextLeaf block is invalid */ - nextLeaf = node->n.leaf.nextLeaf; + nextLeaf = node->n.leaf.nextLeaf; if((testConflictSystemBit(rStats,nextLeaf)==zFAILURE)||(nextLeaf==leftLeaf) ) { /*********************************************************** * We know nextLeaf is circularly linked, so we must call @@ -5373,7 +5373,7 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, * Remove leaf if it has 0 records. *******************************************************************/ if(node->numRecs == 0) - { + { /*********************************************************** * Remove this leaf. ************************************************************/ @@ -5392,7 +5392,7 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, { // FixFixFix(UT,12,6) - need test case for this code. See concerns below /************************************************************** * Since we know we set the bit in the bitmap (because leaf is NOT - * x-linked) we must clear the bit in the bitmap because we + * x-linked) we must clear the bit in the bitmap because we * removed the leaf from the tree so no one owns it. **************************************************************/ /* FixFixFix(ZRP,12,6) - I do not see that repairTestSetBit is called in this code path - So is @@ -5405,7 +5405,7 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, rStats->RepairZfsPoolStats->RZPS_uiStatus.ZRPS_BlocksProcessedPass1--; } #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("zero records, removed block #%d\n"),leftLeaf); + DBG_DebugPrintf(LRED,MSGNot("zero records, removed block #%d\n"),leftLeaf); #endif } else @@ -5429,7 +5429,7 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, (void)ZRP_printf_Log( rStats, ZRP_LOG_WARNING_TAG("Leaf Pruned, Files Lost (0x%Lx)."), (QUAD)leftLeaf ); ClearErrno( genMsg ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("x-linked, removed block #%d\n"),leftLeaf); + DBG_DebugPrintf(LRED,MSGNot("x-linked, removed block #%d\n"),leftLeaf); #endif } else @@ -5440,7 +5440,7 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, **********************************************************************/ /*********************************************************** * set up previousZid to be the greatest zid in this leaf for - * later use when and if we have an invalid node and need to + * later use when and if we have an invalid node and need to * find the nextLeaf. ***********************************************************/ znode = (Znode_s *)&node->LEAF.znode[node->LEAF.znodePtr[MAX_LEAF_PTRS - (node->numRecs - 1)]]; /* point at the rightmost beast in the buffer */ @@ -5455,7 +5455,7 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, //#endif setSysBlockBit(rStats, leftLeaf); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("======processing block %d\n"),leftLeaf); + DBG_DebugPrintf(LRED,MSGNot("======processing block %d\n"),leftLeaf); #endif /* this call releases the buffer and sets up the previousleaf pointer */ if(ZRB_ProcessNodeInLinkedList(genMsg, rStats, RBTStats, node, buffer, leftLeaf, &previousLeaf, @@ -5463,7 +5463,7 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, { //g ccode = ZRP_Error_Return( stats, GetErrno(genMsg), GetErrnoSetter(genMsg), WHERE ); return zFAILURE; // A LOGICAL VOLUME WAS FOUND IN THIS NODE AND COULD NOT BE LOADED - } + } rStats->countedObjects += node->numRecs; /* inc the counted blocks on every other leaf, cuz we parse the leaf level twice */ rStats->filesProcessed += node->numRecs; //g stats->RepairZfsPoolStats->RZPS_uiStatus.ZRPS_ObjectsProcessedPass2 += node->numRecs; @@ -5472,7 +5472,7 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, } } } - else + else { /*********************************************************** * The leaf node is NOT VALID, we need to remove it from the * list. We must make sure we have a good nextLeaf before we @@ -5502,7 +5502,7 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, return zFAILURE; /* fouled up list, return error */ } #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("@@@@ PRUNED LEAF NODE #%d\n"),leftLeaf); + DBG_DebugPrintf(LRED,MSGNot("@@@@ PRUNED LEAF NODE #%d\n"),leftLeaf); #endif (void)ZRP_printf_Log( rStats, ZRP_LOG_WARNING_TAG("Leaf Pruned, Files Lost (0x%Lx)."), (QUAD)leftLeaf ); ClearErrno( genMsg ); @@ -5510,7 +5510,7 @@ STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, else { /* no previous leaf, this is the first leaf (system beasts), its INVALID, we're hosed */ ccode = ZRP_Error_Return( rStats, zERR_INVALID_BLOCK, WHERE, WHERE ); - return zFAILURE; + return zFAILURE; } } @@ -5746,7 +5746,7 @@ STATUS ZRB_CreateNewPoolSystemBeasts(GeneralMsg_s *genMsg, /* And now pack all the beast back into the leaf buffer */ if (ZRB_PackSystemBeastInSpecialBlock(genMsg, rbtStats, - &freeTreeBeast->FILEroot, + &freeTreeBeast->FILEroot, ZFSPOOL_FREETREE_ZID, leafNode) != zOK) { zASSERT("Error packing beast in to the beast tree leaf" == NULL); @@ -5754,7 +5754,7 @@ STATUS ZRB_CreateNewPoolSystemBeasts(GeneralMsg_s *genMsg, } if (ZRB_PackSystemBeastInSpecialBlock(genMsg, rbtStats, - &poolPurgeLog->ZFSPURGELOGroot, + &poolPurgeLog->ZFSPURGELOGroot, ZFSPOOL_PURGELOG_ZID, leafNode) != zOK) { zASSERT("Error packing beast in to the beast tree leaf" == NULL); @@ -5762,7 +5762,7 @@ STATUS ZRB_CreateNewPoolSystemBeasts(GeneralMsg_s *genMsg, } if (ZRB_PackSystemBeastInSpecialBlock(genMsg, rbtStats, - &volPurgeLog->ZFSPURGELOGroot, + &volPurgeLog->ZFSPURGELOGroot, ZFSVOL_PURGELOG_ZID, leafNode) != zOK) { zASSERT("Error packing beast in to the beast tree leaf" == NULL); @@ -5770,7 +5770,7 @@ STATUS ZRB_CreateNewPoolSystemBeasts(GeneralMsg_s *genMsg, } if (ZRB_PackSystemBeastInSpecialBlock(genMsg, rbtStats, - &nameTreeBeast->ZFSNAMETREEroot, + &nameTreeBeast->ZFSNAMETREEroot, ZFSPOOL_VOLNAMETREE_ZID, leafNode) != zOK) { zASSERT("Error packing beast in to the beast tree leaf" == NULL); @@ -5778,7 +5778,7 @@ STATUS ZRB_CreateNewPoolSystemBeasts(GeneralMsg_s *genMsg, } if (ZRB_PackSystemBeastInSpecialBlock(genMsg, rbtStats, - &salvageBeast->ZFSPURGETREEroot, + &salvageBeast->ZFSPURGETREEroot, ZFSPOOL_PURGETREE_ZID, leafNode) != zOK) { zASSERT("Error packing beast in to the beast tree leaf" == NULL); @@ -5806,7 +5806,7 @@ STATUS ZRB_CreateNewPoolSystemBeasts(GeneralMsg_s *genMsg, else { if (ZRB_PackSystemBeastInSpecialBlock(genMsg, rbtStats, - &userTree->ZFSUSERTREEroot, + &userTree->ZFSUSERTREEroot, ZFSPOOL_VOLUSERTREE_ZID, leafNode) != zOK) { zASSERT( @@ -5833,7 +5833,7 @@ STATUS ZRB_CreateNewPoolSystemBeasts(GeneralMsg_s *genMsg, else { if (ZRB_PackSystemBeastInSpecialBlock(genMsg, rbtStats, - &userTree->ZFSUSERTREEroot, + &userTree->ZFSUSERTREEroot, ZFSVOL_USERTREE_ZID, leafNode) != zOK) { zASSERT( @@ -5862,7 +5862,7 @@ STATUS ZRB_CreateNewPoolSystemBeasts(GeneralMsg_s *genMsg, else { if (ZRB_PackSystemBeastInSpecialBlock(genMsg, rbtStats, - &dirTree->ZFSDIRTREEroot, + &dirTree->ZFSDIRTREEroot, ZFSVOL_DIRTREE_ZID, leafNode) != zOK) { zASSERT( @@ -6030,18 +6030,18 @@ STATUS ZRB_CreateNewVolSystemBeasts(GeneralMsg_s *genMsg, leafNode = (BeastTreeNode_s *)buffer->pBuf.data; /* And now pack the beasts back into the leaf buffer */ - if (ZRB_PackSystemBeastInSpecialBlock(genMsg, + if (ZRB_PackSystemBeastInSpecialBlock(genMsg, &RLVStatsPtr->lvRBTStats, - &volPurgeLog->ZFSPURGELOGroot, + &volPurgeLog->ZFSPURGELOGroot, ZFSVOL_PURGELOG_ZID, leafNode) != zOK) { zASSERT("Error packing beast in to the beast tree leaf" == NULL); ClearErrno(genMsg); } - if (ZRB_PackSystemBeastInSpecialBlock(genMsg, + if (ZRB_PackSystemBeastInSpecialBlock(genMsg, &RLVStatsPtr->lvRBTStats, - &nameTreeBeast->ZFSNAMETREEroot, + &nameTreeBeast->ZFSNAMETREEroot, ZFSPOOL_VOLNAMETREE_ZID, leafNode) != zOK) { zASSERT("Error packing beast in to the beast tree leaf" == NULL); @@ -6068,9 +6068,9 @@ STATUS ZRB_CreateNewVolSystemBeasts(GeneralMsg_s *genMsg, } else { - if (ZRB_PackSystemBeastInSpecialBlock(genMsg, + if (ZRB_PackSystemBeastInSpecialBlock(genMsg, &RLVStatsPtr->lvRBTStats, - &userTree->ZFSUSERTREEroot, + &userTree->ZFSUSERTREEroot, ZFSPOOL_VOLUSERTREE_ZID, leafNode) != zOK) { zASSERT( @@ -6096,9 +6096,9 @@ STATUS ZRB_CreateNewVolSystemBeasts(GeneralMsg_s *genMsg, } else { - if (ZRB_PackSystemBeastInSpecialBlock(genMsg, + if (ZRB_PackSystemBeastInSpecialBlock(genMsg, &RLVStatsPtr->lvRBTStats, - &userTree->ZFSUSERTREEroot, + &userTree->ZFSUSERTREEroot, ZFSVOL_USERTREE_ZID, leafNode) != zOK) { zASSERT( @@ -6129,9 +6129,9 @@ STATUS ZRB_CreateNewVolSystemBeasts(GeneralMsg_s *genMsg, } else { - if (ZRB_PackSystemBeastInSpecialBlock(genMsg, + if (ZRB_PackSystemBeastInSpecialBlock(genMsg, &RLVStatsPtr->lvRBTStats, - &dirTree->ZFSDIRTREEroot, + &dirTree->ZFSDIRTREEroot, ZFSVOL_DIRTREE_ZID, leafNode) != zOK) { zASSERT("Error packing beast in to the beast tree leaf" == NULL); @@ -6166,9 +6166,9 @@ STATUS ZRB_CreateNewVolSystemBeasts(GeneralMsg_s *genMsg, // /* And now pack the MFLBeast back into the leaf buffer and get it written */ // if(mflTreeBeast != NULL) // { -// if (ZRB_PackSystemBeastInSpecialBlock(genMsg, +// if (ZRB_PackSystemBeastInSpecialBlock(genMsg, // &RLVStatsPtr->lvRBTStats, -// &mflTreeBeast->ZFSMFLroot, +// &mflTreeBeast->ZFSMFLroot, // ZFSVOL_MFL_ZID, leafNode) != zOK) // { // zASSERT("Error packing beast in to the beast tree leaf" == NULL); @@ -6220,9 +6220,9 @@ STATUS ZRB_BuildPoolDataBlocks(GeneralMsg_s *genMsg, RepairStats_s *stats, RBTSt // stats->pool->ZFSPOOLvol.VOLnumFiles = RBTStats->dataNumFiles; // stats->pool->ZFSPOOLvol.VOLnumObjects = RBTStats->dataNumObjects; } - + /*-----------------------------------------------------------*/ - /* build new non-logged volume data block if needed */ + /* build new non-logged volume data block if needed */ /*-----------------------------------------------------------*/ if(stats->pool->ZP_RepairFlags & ZP_REPAIRFLAGS_REBUILD_POOL_DATA_BLOCKS ) { @@ -6258,9 +6258,9 @@ STATUS ZRB_BuildPoolDataBlocks(GeneralMsg_s *genMsg, RepairStats_s *stats, RBTSt /************************************************************************** * build new logged vol data block and non logged vol data block if needed ***************************************************************************/ -STATUS ZRB_BuildVolDataBlocks(GeneralMsg_s *genMsg, - RepairStats_s *stats, - RBTStats_s *RBTStats, +STATUS ZRB_BuildVolDataBlocks(GeneralMsg_s *genMsg, + RepairStats_s *stats, + RBTStats_s *RBTStats, NINT zv_repairFlags) { BOOL sbhChanged = FALSE; @@ -6302,9 +6302,9 @@ STATUS ZRB_BuildVolDataBlocks(GeneralMsg_s *genMsg, RBTStats->writeZVLBeast = TRUE; } } - + /*-----------------------------------------------------------*/ - /* build new non-logged volume data block if needed */ + /* build new non-logged volume data block if needed */ /*-----------------------------------------------------------*/ if(zv_repairFlags & ZV_REPAIRFLAGS_REBUILD_VOL_DATA_BLOCKS ) { @@ -6366,7 +6366,7 @@ STATUS ZRB_BuildVolDataBlocks(GeneralMsg_s *genMsg, } /************************************************************************** - * + * ***************************************************************************/ STATUS ZRB_WriteNameTreeBeastToDisk(GeneralMsg_s *genMsg, RepairStats_s *rStats, RBTStats_s *RBTStats, RVDBStats_s *RVDBStats, ZfsNameTree_s *nameTreeBeast) { @@ -6392,7 +6392,7 @@ STATUS ZRB_WriteNameTreeBeastToDisk(GeneralMsg_s *genMsg, RepairStats_s *rStats, /* And now pack the nameTreeBeast back into the leaf buffer */ if (ZRB_PackSystemBeastInSpecialBlock(genMsg, RBTStats, - &nameTreeBeast->ZFSNAMETREEroot, + &nameTreeBeast->ZFSNAMETREEroot, ZFSPOOL_VOLNAMETREE_ZID, leafNode) != zOK) { zASSERT("Error packing beast in to the beast tree leaf" == NULL); @@ -6404,7 +6404,7 @@ STATUS ZRB_WriteNameTreeBeastToDisk(GeneralMsg_s *genMsg, RepairStats_s *rStats, /************************************************************************** - * + * ***************************************************************************/ STATUS ZRB_WriteSalvageTreeBeastToDisk(GeneralMsg_s *genMsg, RepairStats_s *rStats, RBTStats_s *RBTStats, RVDBStats_s *RVDBStats, ZfsPurgeTreeBeast_s *salvageBeast) { @@ -6430,7 +6430,7 @@ STATUS ZRB_WriteSalvageTreeBeastToDisk(GeneralMsg_s *genMsg, RepairStats_s *rSta /* And now pack the SalvageTreeBeast back into the leaf buffer */ if (ZRB_PackSystemBeastInSpecialBlock(genMsg, RBTStats, - &salvageBeast->ZFSPURGETREEroot, + &salvageBeast->ZFSPURGETREEroot, ZFSPOOL_PURGETREE_ZID, leafNode) != zOK) { zASSERT("Error packing beast in to the beast tree leaf" == NULL); @@ -6483,7 +6483,7 @@ void ZRB_ModifyVolDataBlock(GeneralMsg_s *genMsg, RBTStats_s *RBTStats) } /************************************************************************** - * + * ***************************************************************************/ #if 0 STATUS ZRB_CreateOrphanageDir(GeneralMsg_s *genMsg, @@ -6520,7 +6520,7 @@ STATUS ZRB_CreateOrphanageDir(GeneralMsg_s *genMsg, return zFAILURE; } X_LATCH(&rootDir->FILEbeastLatch); - if (ZFSPOOL_InitNewRootDir(genMsg, rootDir, + if (ZFSPOOL_InitNewRootDir(genMsg, rootDir, ((ZfsVolume_s *)volume)) != zOK) { UNX_LATCH(&rootDir->FILEbeastLatch); @@ -6574,11 +6574,11 @@ STATUS ZRB_CreateOrphanageDir(GeneralMsg_s *genMsg, zFA_SUBDIRECTORY, zSUPERVISOR_ID, 0, 0, NULL); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("LV_REBUILD)creating orphanage directory\n")); + DBG_DebugPrintf(LRED,MSGNot("LV_REBUILD)creating orphanage directory\n")); #endif cStatus = COMN_Create(genMsg, &aStack->nameMsg, &aStack->createMsg, NULL); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("LV_REBUILD)returned from creating orphanage directory\n")); + DBG_DebugPrintf(LRED,MSGNot("LV_REBUILD)returned from creating orphanage directory\n")); #endif if (cStatus == zOK) { @@ -6638,14 +6638,14 @@ void AddManyVirtualXLinkedBlocks( blockNum = VirtualXLinked[i]; if ( blockNum >= stats->pool->ZFSPOOLtotalBlocks ) { - (void)ZRP_printf_Log( stats, ZRP_LOG_WARNING_TAG("------- Virtual block OUT OF RANGE OF POOL(this should not happen!!!) %lx"), blockNum ); + (void)ZRP_printf_Log( stats, ZRP_LOG_WARNING_TAG("------- Virtual block OUT OF RANGE OF POOL(this should not happen!!!) %lx"), blockNum ); zASSERT( blockNum < stats->pool->ZFSPOOLtotalBlocks ); } else { if ( BM_TST_BIT( stats->RS_InUseBlockBM, blockNum) ) { /* set the bit in the conflicts bitmap */ - (void)ZRP_printf_Log( stats, ZRP_LOG_WARNING_TAG("Virtual X-LINKED BLOCK(this should not happen!!!) -- %lx"), blockNum ); + (void)ZRP_printf_Log( stats, ZRP_LOG_WARNING_TAG("Virtual X-LINKED BLOCK(this should not happen!!!) -- %lx"), blockNum ); zASSERT("X-LINKED BLOCK FOUND (should not happen here as only doing have superblocks)" == NULL); } else @@ -6689,7 +6689,7 @@ STATUS ZRB_ReadInPoolDataBlock( /* Set up the flags in the Pool and Internal Volume. * They will be cleared at each step in ZFSPOOL_LoadPersistentPool * as they are read in and validated. - */ + */ pool->zfsVol.ZV_RepairFlags |= ZV_REPAIRFLAGS_REBUILD_VOL_DATA_BLOCKS; pool->zfsVol.ZV_RepairFlags |= ZV_REPAIRFLAGS_REBUILD_VOL_LDATA_BLOCKS; pool->zfsVol.ZV_RepairFlags |= ZV_REPAIRFLAGS_MANUAL_VOL_LOAD; @@ -6697,7 +6697,7 @@ STATUS ZRB_ReadInPoolDataBlock( pool->ZP_RepairFlags |= ZP_REPAIRFLAGS_REBUILD_POOL_LDATA_BLOCKS; pool->ZP_RepairFlags |= ZP_REPAIRFLAGS_REBUILD_POOL_SUPER_BLOCKS; pool->ZP_RepairFlags |= ZP_REPAIRFLAGS_MANUAL_POOL_LOAD; - + /* The below call will fail on incorrect media version. This * is a good thing, but most other failures should be handled. */ @@ -6725,7 +6725,7 @@ STATUS ZRB_ReadInPoolDataBlock( /*- (FUNCTION) ----- ZFSREPAIR_CheckRepair() --------------------------- | - | + | +-------------------------------------------------------------------------*/ STATUS ZFSREPAIR_VOL_CheckRepair( GeneralMsg_s *genMsg, @@ -6817,3 +6817,6 @@ STATUS ZLSSPOOL_VOL_VolumeMaintenance( } return status; } + + + diff --git a/src/nwnss/zlss/repairMain.h b/src/nwnss/zlss/repairMain.h index 413a28c..a54b023 100644 --- a/src/nwnss/zlss/repairMain.h +++ b/src/nwnss/zlss/repairMain.h @@ -178,11 +178,11 @@ STATUS REZID_DoRezid( void SaveLeafInfoEnd( RBTStats_s *RBTStats); -STATUS SaveLeafInfo( - Blknum_t blockNum, - Zid_t lowestZid, - RepairStats_s *stats, - RBTStats_s *RBTStats, +STATUS SaveLeafInfo( + Blknum_t blockNum, + Zid_t lowestZid, + RepairStats_s *stats, + RBTStats_s *RBTStats, GeneralMsg_s *genMsg); STATUS BuildNewBeastTree( @@ -195,9 +195,9 @@ STATUS BuildNewBeastTree( RepairStats_s *stats, RBTStats_s *RBTStats); -STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, - RepairStats_s *stats, - RBTStats_s *RBTStats, +STATUS ZRB_AllocationMapPass(GeneralMsg_s *genMsg, + RepairStats_s *stats, + RBTStats_s *RBTStats, LONG *leafCount, BOOL specialBlockExists); @@ -216,11 +216,11 @@ STATUS ZRB_CreateDot1Dir(GeneralMsg_s *genMsg, STATUS COMPFIX_VerifyAndLoadLVSystemBeasts( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, Volume_s *vol); STATUS COMPFIX_UnloadlvSystemBeasts( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, Volume_s *vol); void COMPFIX_verify_FlushVolVolumeBuffers( @@ -234,9 +234,9 @@ STATUS ZRB_ReadInPoolDataBlock( ZlssPool_s *zlssPool, ZLSSCheckIOProcess_s *ZCProcessPtr ); -STATUS ZRB_BuildVolDataBlocks(GeneralMsg_s *genMsg, - RepairStats_s *stats, - RBTStats_s *RBTStats, +STATUS ZRB_BuildVolDataBlocks(GeneralMsg_s *genMsg, + RepairStats_s *stats, + RBTStats_s *RBTStats, NINT zv_repairFlags); STATUS ZRB_CreateNewVolSystemBeasts(GeneralMsg_s *genMsg, RepairStats_s *stats, ZRP_LVData_s *RLVStatsPtr); void ZRB_InitVolumeData(ZfsVolume_s *zfsVol,NINT repairFlags,BOOL virtualFileFlag,RBTStats_s *RBTStats); diff --git a/src/nwnss/zlss/repairMap.c b/src/nwnss/zlss/repairMap.c index e0bd3e7..837ab15 100644 --- a/src/nwnss/zlss/repairMap.c +++ b/src/nwnss/zlss/repairMap.c @@ -168,7 +168,7 @@ void DestroyBitMap(NINT *bitMap) // BYTE *bytePtr; // NINT i; // -// // read left most block +// // read left most block // READBLK_IO_MSG(iomsg, pool, leafBlk, CACHE_READ); // buffer = zFS_ReadPoolBlk( genMsg, &iomsg ); // if (buffer == NULL) @@ -577,7 +577,7 @@ STATUS ZRB_PrepareForPass1(GeneralMsg_s *genMsg, RepairStats_s *stats) } /* Extract the rebuild file beast */ stats->RepairZfsPoolStats->rebuildBeast = (File_s *) - ZFSVOL_GetBeastFromBuffer(genMsg, ZFSPOOL_REBUILDFILE_ZID, + ZFSVOL_GetBeastFromBuffer(genMsg, ZFSPOOL_REBUILDFILE_ZID, (Volume_s *)&stats->pool->zfsVol, buffer); if(stats->RepairZfsPoolStats->rebuildBeast != NULL) { @@ -599,7 +599,7 @@ STATUS ZRB_PrepareForPass1(GeneralMsg_s *genMsg, RepairStats_s *stats) } /************************************************************************** - * + * * (repair) ***************************************************************************/ void ZRB_ReservePoolDataBlocks(RepairStats_s *stats) @@ -608,8 +608,8 @@ void ZRB_ReservePoolDataBlocks(RepairStats_s *stats) /*-----------------------------------------------------------*/ /* reserve the pool's Internal volume data blocks if used */ /*-----------------------------------------------------------*/ - ZRB_ReserveLogicalVolDataBlocks(stats, - &stats->RepairZfsPoolStats->RBTStats, + ZRB_ReserveLogicalVolDataBlocks(stats, + &stats->RepairZfsPoolStats->RBTStats, &stats->pool->zfsVol); /*-----------------------------------------------------------*/ @@ -912,8 +912,8 @@ DBG_DebugPrintf(LRED, MSGNot("(LV_REBUILD)calling ZRB_PrepareForPass1 \n")); /************************************************************************/ ZRP_ADRecord( stats ); ZRP_ADSet( stats, "Superblocks", stats->RS_CurrentLVData ); - stats->xLinkedFlag = 0; - for(i = 0; i < SUPERBLOCK_NUMBER; i++) + stats->xLinkedFlag = 0; + for(i = 0; i < SUPERBLOCK_NUMBER; i++) { for(k = 0; k < 16; k++) { @@ -921,7 +921,7 @@ DBG_DebugPrintf(LRED, MSGNot("(LV_REBUILD)calling ZRB_PrepareForPass1 \n")); if(repairTestSetBit(stats, stats->pool->ZP_super->SB_Header.hdr.superlocation[i]+k /*si[i].SBHV_MathematicalBlock+k*/) != zOK) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("Super Block not in range of pool's blocks (%lx) \n"),stats->pool->ZP_super->SB_Header.hdr.superlocation[i]+k); + DBG_DebugPrintf(LRED,MSGNot("Super Block not in range of pool's blocks (%lx) \n"),stats->pool->ZP_super->SB_Header.hdr.superlocation[i]+k); #endif zASSERT("Super Block not in range of pool's blocks" == NULL); stats->xLinkedFlag = 0; @@ -944,7 +944,7 @@ DBG_DebugPrintf(LRED, MSGNot("(LV_REBUILD)calling ZRB_PrepareForPass1 \n")); } } } - stats->xLinkedFlag = 0; + stats->xLinkedFlag = 0; status = zOK; /************************************************/ @@ -1066,9 +1066,9 @@ FreeMemory: | (repair) | Verify visibility +-------------------------------------------------------------------------*/ -void ZRB_FixVisibility(BeastTreeNode_s *node, - Znode_s *znode, - ZASPersistentAuthInfo_s *ZASPersistentAuthInfo, +void ZRB_FixVisibility(BeastTreeNode_s *node, + Znode_s *znode, + ZASPersistentAuthInfo_s *ZASPersistentAuthInfo, V1_ZASPersistentAuthInfo_s *V1_ZASPersistentAuthInfo) { NINT visLen; @@ -1083,7 +1083,7 @@ void ZRB_FixVisibility(BeastTreeNode_s *node, * the beast size. We need to ZERO the stuf in the znode in this * pass because we write the node back out later anyway. * this requires removing the VisEntry_s stuff out of the middle - * of the znode and moving the rest of the stuff up in the znode, + * of the znode and moving the rest of the stuff up in the znode, * changing the length of the znode, and fixing the free space. */ @@ -1220,7 +1220,7 @@ STATUS VerifyFileMap(GeneralMsg_s *genMsg, ZfsPool_s *pool, BeastTreeNode_s *nod //g unicode_t tempBuffer[zMAX_COMPONENT_NAME]; //g } Stack_s; //g STACK_ALLOC(); - + for (j = 0; j < node->numRecs; j++) { @@ -1229,7 +1229,7 @@ STATUS VerifyFileMap(GeneralMsg_s *genMsg, ZfsPool_s *pool, BeastTreeNode_s *nod continue; /* count as an abject and/or file always, because if we mark it to be - * deleted, it will be deleted in the nametree pass (pass 2) and is + * deleted, it will be deleted in the nametree pass (pass 2) and is * transactioned, so the volume data object count is decremented. */ RBTStats->dataNumObjects++; /* count as an object */ @@ -1303,7 +1303,7 @@ STATUS VerifyFileMap(GeneralMsg_s *genMsg, ZfsPool_s *pool, BeastTreeNode_s *nod } } break; - + case BEAST_VERSION_2: fMap = (Fmap_s *)(((BYTE *)znode) + sizeof(ZFSPackedRoot_s) + ((ZFSPackedRoot_s *)znode)->variableSize); @@ -1376,26 +1376,26 @@ STATUS VerifyFileMap(GeneralMsg_s *genMsg, ZfsPool_s *pool, BeastTreeNode_s *nod } } - if(RBTStats->zVolume->ZFSVOLvol.VOLauthModelID == zFTYPE_ZAS_AUTH_MODEL) - { - if (COMN_IsIDDerivedFrom(znode->header.type, zFTYPE_AUTH_BEAST)) - { - /* skip the names for the first parent if parent exists*/ - dummy = (BYTE *)pEntry; /* point past PersistentNamed_s */ + if(RBTStats->zVolume->ZFSVOLvol.VOLauthModelID == zFTYPE_ZAS_AUTH_MODEL) + { + if (COMN_IsIDDerivedFrom(znode->header.type, zFTYPE_AUTH_BEAST)) + { + /* skip the names for the first parent if parent exists*/ + dummy = (BYTE *)pEntry; /* point past PersistentNamed_s */ if(numParents > 0) - { - /* dummy points to first of all parents (PersistentParentEntry_s) - */ + { + /* dummy points to first of all parents (PersistentParentEntry_s) + */ for ( i = 0; i < numParents; i++) - { /* add the size of each parent entry for this beast */ - numNames = ((PersistentParentEntry_s *)dummy)->numNames; - if(((PersistentParentEntry_s *)dummy)->nameType == zNTYPE_DELETED_FILE) - { + { /* add the size of each parent entry for this beast */ + numNames = ((PersistentParentEntry_s *)dummy)->numNames; + if(((PersistentParentEntry_s *)dummy)->nameType == zNTYPE_DELETED_FILE) + { switch(((ZFSPackedRoot_s *)znode)->beastLayout) { case BEAST_VERSION_1: - dummy += sizeof(PersistentParentEntry_s) + sizeof(V1_DeletedPersistentParentEntry_s); + dummy += sizeof(PersistentParentEntry_s) + sizeof(V1_DeletedPersistentParentEntry_s); break; case BEAST_VERSION_2: @@ -1404,10 +1404,10 @@ STATUS VerifyFileMap(GeneralMsg_s *genMsg, ZfsPool_s *pool, BeastTreeNode_s *nod dummy += sizeof(PersistentParentEntry_s) + sizeof(DeletedPersistentParentEntry_s); break; } - } - else - { - dummy += sizeof(PersistentParentEntry_s); + } + else + { + dummy += sizeof(PersistentParentEntry_s); } /* dummy points past this parent entry potentially * at the list of names (if any, PersistentNameEntry_s) @@ -1495,7 +1495,7 @@ STATUS VerifyFileMap(GeneralMsg_s *genMsg, ZfsPool_s *pool, BeastTreeNode_s *nod /******************************************************************************************************/ CompressInfo_s *compInfo = BEAST_CM_INFO((RootBeast_s *)file); //FixFixFix(UT,4,2) - UT this code by creating a proper bad pool - if(compInfo && (compInfo->p.compZid == zINVALID_ZID) && + if(compInfo && (compInfo->p.compZid == zINVALID_ZID) && (compInfo->p.UCprecious == 0) && (compInfo->p.Cprecious == 1)) { // fixfixfix(ZRPDone,4,3) - Everytime we delete a file we need to LOG it. See all setters of rebuildMagic I think that REBUILD_DELETE_BEAST_MAGIC get deleted in 2nd passes do get logged, but with a generic corrupt message. @@ -1553,7 +1553,7 @@ STATUS VerifyFileMap(GeneralMsg_s *genMsg, ZfsPool_s *pool, BeastTreeNode_s *nod /* Fix up rights visibility here, first * if the beast has visibility, ZERO it out, * second, if the beast has an overflow beast, - * set its zid to zINVALID_ZID, third, if this + * set its zid to zINVALID_ZID, third, if this * is an overflow beast, mark it to be deleted. */ if(COMN_IsDerivedFrom(file, zFTYPE_AUTH_BEAST)) @@ -1580,7 +1580,7 @@ STATUS VerifyFileMap(GeneralMsg_s *genMsg, ZfsPool_s *pool, BeastTreeNode_s *nod if( COMN_IsDerivedFrom(file, zFTYPE_ZLSS_VOLUME_LOCATOR) ) { ZlssVolumeLocator_s *zvlBeast; - + zvlBeast = (ZlssVolumeLocator_s *)file; if ( (zvlBeast->ZVL_p.PZVL_state == PZVL_S_CREATION) || (zvlBeast->ZVL_p.PZVL_state == PZVL_S_DELETION) || @@ -1588,7 +1588,7 @@ STATUS VerifyFileMap(GeneralMsg_s *genMsg, ZfsPool_s *pool, BeastTreeNode_s *nod { /* NON-created volume(I.E. deleted or partial created), * remove from node by marking the beast to be deleted - * during pass 2 + * during pass 2 */ (void)ZRP_printf_Log( stats, ZRP_LOG_INFO_TAG("Non-created volume cleanup (0x%Lx)."), znode->header.zid ); /* FixFixFix(ZRP,12,5) - Should we really silently purge deleted volumes??? */ @@ -1616,7 +1616,7 @@ STATUS VerifyFileMap(GeneralMsg_s *genMsg, ZfsPool_s *pool, BeastTreeNode_s *nod else { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERROR: Logical volume locator beast found on a logical volume!\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERROR: Logical volume locator beast found on a logical volume!\n")); #endif (void)ZRP_printf_Log( stats, ZRP_LOG_INFO_TAG("Unneeded volume locator (0x%Lx)."), znode->header.zid ); *rebuildMagic = REBUILD_DELETE_BEAST_MAGIC; @@ -1638,7 +1638,7 @@ STATUS VerifyFileMap(GeneralMsg_s *genMsg, ZfsPool_s *pool, BeastTreeNode_s *nod (void)ZRP_Error_Return( stats, GetErrno(genMsg), GetErrnoSetter(genMsg), WHERE ); return (zFAILURE); } - + #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(YELLOW,MSGNot("Unreadable zid (initial pass) zid = 0x%Lx\n"), znode->header.zid ); #endif @@ -1669,10 +1669,10 @@ DBG_DebugPrintf(LRED, MSGNot("(LV_REBUILD)VerifyFileMap OK -- \"%U\" \n"),RBTSta +-------------------------------------------------------------------------*/ STATUS repairTestSetBit(RepairStats_s *stats, Blknum_t blockNum) { -//g if ((stats->markedBlockCount+stats->bitmapAllocedBlockCount+stats->bitmapFreedBlockCount) % stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar->incThreshold == 0) +//g if ((stats->markedBlockCount+stats->bitmapAllocedBlockCount+stats->bitmapFreedBlockCount) % stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar->incThreshold == 0) //g { -//g WinIncrementProgressBar(stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar, -//g stats->markedBlockCount+stats->bitmapAllocedBlockCount+stats->bitmapFreedBlockCount, +//g WinIncrementProgressBar(stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar, +//g stats->markedBlockCount+stats->bitmapAllocedBlockCount+stats->bitmapFreedBlockCount, //g stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar->decimalPlaces); //g DisplayRepairProgressPass(stats, REPAIR_PHASE_FILES); //g } @@ -1681,7 +1681,7 @@ STATUS repairTestSetBit(RepairStats_s *stats, Blknum_t blockNum) if(blockNum >= stats->pool->ZFSPOOLtotalBlocks) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(RED,MSGNot("------- BIT 0UT OF RANGE OF POOL (%lx\n"),blockNum); + DBG_DebugPrintf(RED,MSGNot("------- BIT 0UT OF RANGE OF POOL (%lx\n"),blockNum); #endif zASSERT(blockNum < stats->pool->ZFSPOOLtotalBlocks); return zFAILURE; @@ -1707,7 +1707,7 @@ STATUS repairTestSetBit(RepairStats_s *stats, Blknum_t blockNum) } PERIODIC_YIELD(); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(RED,MSGNot("X-LINKED BLOCK -- %lx\n"),blockNum); + DBG_DebugPrintf(RED,MSGNot("X-LINKED BLOCK -- %lx\n"),blockNum); #endif // zASSERT("X-LINKED BLOCK FOUND" == NULL); return zOK; @@ -2029,10 +2029,10 @@ STATUS ZRB_FMAPFreeConflictBlocks(GeneralMsg_s *genMsg, RepairStats_s *stats) } -/* -------------------------------------------------------------------------- +/* -------------------------------------------------------------------------- getNextExtentFromXLinkedMap - + Returns: zOK zFAILURE @@ -2043,7 +2043,7 @@ STATUS getNextExtentFromXLinkedMap(NINT *volumeBitMap, Blknum_t block, Blknum_t NINT state; Blknum_t i; - state = 0; /* flag that we are looking for the beginning of the next extent */ + state = 0; /* flag that we are looking for the beginning of the next extent */ request->lengthOfExtent = 0; request->poolBlkNum = 0; @@ -2147,10 +2147,10 @@ STATUS allocFromBitMap(RepairStats_s *stats, RBTStats_s *RBTStats, NINT *bitMap, return zFAILURE; } -//g if ((stats->markedBlockCount+stats->bitmapAllocedBlockCount+stats->bitmapFreedBlockCount) % stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar->incThreshold == 0) +//g if ((stats->markedBlockCount+stats->bitmapAllocedBlockCount+stats->bitmapFreedBlockCount) % stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar->incThreshold == 0) //g { -//g WinIncrementProgressBar(stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar, -//g stats->markedBlockCount+stats->bitmapAllocedBlockCount+stats->bitmapFreedBlockCount, +//g WinIncrementProgressBar(stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar, +//g stats->markedBlockCount+stats->bitmapAllocedBlockCount+stats->bitmapFreedBlockCount, //g stats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar->decimalPlaces); //g DisplayRepairProgressPass(stats, REPAIR_PHASE_FILES); //g } diff --git a/src/nwnss/zlss/repairNames.c b/src/nwnss/zlss/repairNames.c index e0070df..09a29c7 100644 --- a/src/nwnss/zlss/repairNames.c +++ b/src/nwnss/zlss/repairNames.c @@ -52,10 +52,6 @@ #include "xaction.h" #include "zfsdefs.h" #include "repairMap.h" -#include -#ifndef ASSERT -#define ASSERT(_expr) zASSERT(_expr) -#endif #include "repairMain.h" @@ -138,8 +134,8 @@ void ZDupExtSet(ZDupExt_s *ZDupExt, GeneralMsg_s *genMsg) /************************************************************************** * ZRB_RemoveParentEntryNames() ***************************************************************************/ -static STATUS ZRB_RemoveParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *beast, NamedBeast_s *directory, - ParentEntry_s *parent, LinkedNameEntry_s *endNode, ZfsVolume_s *zVol) +static STATUS ZRB_RemoveParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *beast, NamedBeast_s *directory, + ParentEntry_s *parent, LinkedNameEntry_s *endNode, ZfsVolume_s *zVol) { LinkedNameEntry_s *nnode; NINT deleteNameFlags = NF_FIRST_NAME; @@ -166,7 +162,7 @@ static STATUS ZRB_RemoveParentEntryNames (GeneralMsg_s *genMsg, NamedBeast_s *be ccode = directory->NAMEDcomnOps.BST_removeNameFromDirectory( genMsg, beast->NAMEDzid, directory, nnode->p.nameSpaceMask, - parent->p.nameType, nnode->p.name, + parent->p.nameType, nnode->p.name, /* cnt parent->p.nameUniquifier, */ deleteNameFlags, (Xaction_s*)xaction, parent->t); @@ -303,13 +299,13 @@ Zid_t ZRB_DirCreate(GeneralMsg_s *genMsg, * off of the root dir. * NOTE: the object is always returned latched now. ***************************************************************************/ -static NamedBeast_s *ZRB_GetDot3Name(GeneralMsg_s *genMsg, - Volume_s *vol, - Zid_t zid, - NINT latchType, +static NamedBeast_s *ZRB_GetDot3Name(GeneralMsg_s *genMsg, + Volume_s *vol, + Zid_t zid, + NINT latchType, RepairStats_s *stats, - RBTStats_s *RBTStats, - Zid_t dot2Zid, + RBTStats_s *RBTStats, + Zid_t dot2Zid, NINT id, NINT fileAttr) { @@ -377,7 +373,7 @@ static NamedBeast_s *ZRB_GetDot3Name(GeneralMsg_s *genMsg, /************************************************************************** - * + * ***************************************************************************/ STATUS ZRB_CreateDot1Dir(GeneralMsg_s *genMsg, RepairStats_s *stats, @@ -403,7 +399,7 @@ STATUS ZRB_CreateDot1Dir(GeneralMsg_s *genMsg, return zFAILURE; } X_LATCH(&rootDir->FILEbeastLatch); - if (ZFSPOOL_InitNewRootDir(genMsg, rootDir, + if (ZFSPOOL_InitNewRootDir(genMsg, rootDir, ((ZfsVolume_s *)volume)) != zOK) { UNX_LATCH(&rootDir->FILEbeastLatch); @@ -440,7 +436,7 @@ STATUS ZRB_CreateDot1Dir(GeneralMsg_s *genMsg, * * ***************************************************************************/ -static BOOL ZRB_FileNameAlreadyExistsInDirectory (GeneralMsg_s *genMsg, +static BOOL ZRB_FileNameAlreadyExistsInDirectory (GeneralMsg_s *genMsg, NamedBeast_s *directory, NINT nameType, NameSpace_s *nameSpace, @@ -590,7 +586,7 @@ static NamedBeast_s *ZRB_GetDuplicateDir(GeneralMsg_s *genMsg, NamedBeast_s *bea Zid_t dot2Zid; NINT fileAttr = zFA_SUBDIRECTORY; NamedBeast_s *directory = NULL; - + dot2Zid = ZRB_GetDot2Zid(beast, parent, RBTStats, FALSE); if(dot2Zid == zINVALID_ZID) { @@ -617,7 +613,7 @@ static NamedBeast_s *ZRB_GetDuplicateDir(GeneralMsg_s *genMsg, NamedBeast_s *bea * not strictly limited to a directory. * * Returns - * TRUE if at least one name is already in 'directory' in which case + * TRUE if at least one name is already in 'directory' in which case * 'retNameSpaceID' indicates which namespace we conflicted in. 'orgZid' * and 'retNameUniquifier' indicates which exactly who we conflicted * with. @@ -652,9 +648,9 @@ static BOOL ZRB_IsDuplicateName(GeneralMsg_s *genMsg, nameSpace = COMN_NameSpaceIDLookup(genMsg, parent->p.primaryNameSpaceID); if(nameSpace != NULL) { - if ( ZRB_FileNameAlreadyExistsInDirectory(genMsg, - directory, - parent->p.nameType, + if ( ZRB_FileNameAlreadyExistsInDirectory(genMsg, + directory, + parent->p.nameType, nameSpace, primaryNnode->p.name, orgZid /* cnt , retNameUniquifier */ ) ) @@ -685,9 +681,9 @@ static BOOL ZRB_IsDuplicateName(GeneralMsg_s *genMsg, nameSpace = COMN_NameSpaceIDLookup(genMsg, nSpaceID); if(nameSpace != NULL) { - if ( ZRB_FileNameAlreadyExistsInDirectory(genMsg, - directory, - parent->p.nameType, + if ( ZRB_FileNameAlreadyExistsInDirectory(genMsg, + directory, + parent->p.nameType, nameSpace, nnode->p.name, orgZid /* cnt , retNameUniquifier */ ) ) @@ -714,12 +710,12 @@ static BOOL ZRB_IsDuplicateName(GeneralMsg_s *genMsg, * ZRB_GetDestinationDirectory2() * ***************************************************************************/ -static NamedBeast_s *ZRB_GetDestinationDirectory2(GeneralMsg_s *genMsg, - NamedBeast_s *directory, - NamedBeast_s *beast, +static NamedBeast_s *ZRB_GetDestinationDirectory2(GeneralMsg_s *genMsg, + NamedBeast_s *directory, + NamedBeast_s *beast, ParentEntry_s *parent, - RepairStats_s *stats, - RBTStats_s *RBTStats, + RepairStats_s *stats, + RBTStats_s *RBTStats, BOOL *orgDir ) { NINT id = 1; @@ -759,12 +755,12 @@ static NamedBeast_s *ZRB_GetDestinationDirectory2(GeneralMsg_s *genMsg, * returns an orphanage directory beast who's name is in the form "xxxxxxxxxxxxxxxx.DIR" * where "xxxxxxxxxxxxxxxx" is the missing parent zid in ascii ***************************************************************************/ -static NamedBeast_s *ZRB_GetFirstChoiceOrphanage(GeneralMsg_s *genMsg, - NamedBeast_s *beast, +static NamedBeast_s *ZRB_GetFirstChoiceOrphanage(GeneralMsg_s *genMsg, + NamedBeast_s *beast, ParentEntry_s *parent, - Zid_t zid, - NINT latchType, - RepairStats_s *stats, + Zid_t zid, + NINT latchType, + RepairStats_s *stats, RBTStats_s *RBTStats) { NamedBeast_s *directory = NULL; @@ -901,8 +897,8 @@ static NamedBeast_s *ZRB_MangleNewDupName(GeneralMsg_s *genMsg, NamedBeast_s *beast, ParentEntry_s *parentEntry, NamedBeast_s *directory, - BYTE nameSpaceID, - ZfsXaction_s *xaction, + BYTE nameSpaceID, + ZfsXaction_s *xaction, BOOL *allDone, BOOL persistent) { @@ -945,7 +941,7 @@ static NamedBeast_s *ZRB_MangleNewDupName(GeneralMsg_s *genMsg, nsFlags = nnode->p.flagsAndLen & ~NAMEnameLenMask; /*--------------------------------------------------------------------------- - * get the primary name space for the directory + * get the primary name space for the directory *---------------------------------------------------------------------------*/ if ((primaryNameSpace = COMN_NameSpaceIDLookup(genMsg, parentEntry->p.primaryNameSpaceID)) == NULL) { @@ -953,7 +949,7 @@ static NamedBeast_s *ZRB_MangleNewDupName(GeneralMsg_s *genMsg, goto CleanUpAndReturn; } /*--------------------------------------------------------------------------- - * get the conflicting name space for the directory + * get the conflicting name space for the directory *---------------------------------------------------------------------------*/ if ((nameSpace = COMN_NameSpaceIDLookup(genMsg, nameSpaceID)) == NULL) { @@ -962,7 +958,7 @@ static NamedBeast_s *ZRB_MangleNewDupName(GeneralMsg_s *genMsg, } /*--------------------------------------------------------------------------- - * Generate a unique name for this name, nameSpace, and dir + * Generate a unique name for this name, nameSpace, and dir *---------------------------------------------------------------------------*/ nameShareMode = nameSpace->nSpaceOps->generateUniqueName( genMsg, directory, @@ -1086,9 +1082,9 @@ CleanUpAndReturn: * if allDone == FALSE, directory MUST be NULL * == TRUE, if directorty is null, name not added to name tree ***************************************************************************/ -static NamedBeast_s *ZRB_HandleDuplicateNames(GeneralMsg_s *genMsg, - NamedBeast_s *beast, - ParentEntry_s *parent, +static NamedBeast_s *ZRB_HandleDuplicateNames(GeneralMsg_s *genMsg, + NamedBeast_s *beast, + ParentEntry_s *parent, NamedBeast_s *directory, RepairStats_s *stats, RBTStats_s *RBTStats, @@ -1107,7 +1103,7 @@ static NamedBeast_s *ZRB_HandleDuplicateNames(GeneralMsg_s *genMsg, /**************************************************************************/ if(ZRB_MustMove(genMsg, beast, dupBeast)) { /* move the dupBeast file to a dup directory */ - destDirectory = ZRB_GetDestinationDirectory2(genMsg, directory, dupBeast, + destDirectory = ZRB_GetDestinationDirectory2(genMsg, directory, dupBeast, dupBeastParentEntry, stats, RBTStats, &orgDir); if(!orgDir) { @@ -1182,12 +1178,12 @@ static NamedBeast_s *ZRB_HandleDuplicateNames(GeneralMsg_s *genMsg, * our parent. * * When this routine changes a beast it will ensure that the beast is written. - * + * ***************************************************************************/ -NamedBeast_s *ZRB_GetDestinationDirectory(GeneralMsg_s *genMsg, - NamedBeast_s *beast, - ParentEntry_s *parentE, - RepairStats_s *stats, +NamedBeast_s *ZRB_GetDestinationDirectory(GeneralMsg_s *genMsg, + NamedBeast_s *beast, + ParentEntry_s *parentE, + RepairStats_s *stats, RBTStats_s *RBTStats, ZfsXaction_s *xaction, BOOL *allDone) /* Output */ @@ -1208,7 +1204,7 @@ NamedBeast_s *ZRB_GetDestinationDirectory(GeneralMsg_s *genMsg, /* During Rezid, if we could not rezid the parent Zid then we mark * the beast with this magic so that we don't attempt to read in * the beast with the old zid. We still want to use the old zid - * to create the foster parent directory. This ensures all the + * to create the foster parent directory. This ensures all the * foster children for the same zid are together. */ directory = NULL; @@ -1277,7 +1273,7 @@ NamedBeast_s *ZRB_GetDestinationDirectory(GeneralMsg_s *genMsg, if(nameSpaceID == parentE->p.primaryNameSpaceID) { /* Our primary name conflicts with another beast's name */ - originalBeast = (NamedBeast_s *)BEASTHASH_LookupByZid( genMsg, beast->NAMEDvolume, + originalBeast = (NamedBeast_s *)BEASTHASH_LookupByZid( genMsg, beast->NAMEDvolume, dupedZid, XLATCHED ); if(originalBeast == NULL) { /* Dup names will be inserted into name tree! */ @@ -1303,10 +1299,10 @@ NamedBeast_s *ZRB_GetDestinationDirectory(GeneralMsg_s *genMsg, if(originalBeastParentEntry->p.primaryNameSpaceID == nameSpaceID) { /* We conflicted with another beast's primary name */ zDup.PP++; - directory = ZRB_HandleDuplicateNames( genMsg, beast, parentE, directory, - stats, RBTStats, xaction, + directory = ZRB_HandleDuplicateNames( genMsg, beast, parentE, directory, + stats, RBTStats, xaction, allDone, nameSpaceID, - originalBeast, + originalBeast, originalBeastParentEntry); COMN_UnlatchAndRelease(&originalBeast, XLATCHED); @@ -1327,3 +1323,5 @@ NamedBeast_s *ZRB_GetDestinationDirectory(GeneralMsg_s *genMsg, return directory; } } + + diff --git a/src/nwnss/zlss/repairNtree.c b/src/nwnss/zlss/repairNtree.c index b16b614..61396c7 100644 --- a/src/nwnss/zlss/repairNtree.c +++ b/src/nwnss/zlss/repairNtree.c @@ -373,7 +373,7 @@ STATIC STATUS ProcessLeafNodeEnt_BMP_TST_EXTENT(GeneralMsg_s *genMsg, Leaf_s *e, while ( (childBlock != INVALID_BLK && childBlock != 0) && (status == zOK) ) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("++name node leaf overflow %d\n"),childBlock); + DBG_DebugPrintf(LRED,MSGNot("++name node leaf overflow %d\n"),childBlock); #endif NTStats->numNTLeafOverflowNodes++; //g NTStats->numNTreeBlocks++; @@ -566,7 +566,7 @@ STATIC STATUS ProcessLeafOverflowNode(GeneralMsg_s *genMsg, Node_s *node, Verify STATUS errcode = zOK; ccode = zOK; - switch(vStats->action) + switch(vStats->action) { case BMP_TST_EXTENT: /* All the records in a leaf overflow are duplicate @@ -674,8 +674,8 @@ STATIC ZVP_ERROR ZVP_ProcessBranchChildBlock(GeneralMsg_s *genMsg, Blknum_t bloc #if NSS_DEBUG IS_ENABLED if(ntData->ovblkFlag) { - DBG_DebugPrintf(LRED,MSGNot(" --Child = 0x%x, state = 0x%x, NextLeaf = 0x%x\n"),block,node->state,node->u.nextleaf); - DBG_DebugPrintf(LRED,MSGNot(" operation = %d\n"),ntData->ovReplaceOp); + DBG_DebugPrintf(LRED,MSGNot(" --Child = 0x%x, state = 0x%x, NextLeaf = 0x%x\n"),block,node->state,node->u.nextleaf); + DBG_DebugPrintf(LRED,MSGNot(" operation = %d\n"),ntData->ovReplaceOp); } #endif (void)ZVP_visitNameNode(genMsg, node, block, vStats, NTStats, volZid, ntData); @@ -725,7 +725,7 @@ STATIC STATUS ZVP_visitNameNode(GeneralMsg_s *genMsg, Node_s *node, Blknum_t blk if ( ccode != zOK ) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("<<<numRecs; ++i) + for (i = 0; i < node->numRecs; ++i) { - Leaf_s *e = LEAF_ENTRY(node, i); + Leaf_s *e = LEAF_ENTRY(node, i); if ( ZVP_UnloadRequested( vStats ) ) { ForceSetErrno(genMsg, zERR_RAV_UNLOAD_REQUESTED); /* unload requested */ @@ -820,7 +820,7 @@ STATIC STATUS ZVP_visitNameNode(GeneralMsg_s *genMsg, Node_s *node, Blknum_t blk /*-------------------------------*/ /* BRANCH NODE */ /*-------------------------------*/ - switch(vStats->action) + switch(vStats->action) { case BMP_TST_EXTENT: CBS_LevelReport( vStats->VS_cBS, CBS_LR_BRANCH, node->numRecs+1 ); @@ -846,7 +846,7 @@ STATIC STATUS ZVP_visitNameNode(GeneralMsg_s *genMsg, Node_s *node, Blknum_t blk (void)ZVP_printf_Debug( vStats, WHERE, ZRP_DEBUG_LOG_GENERAL_INFO, RAV_DEBUG_TAG("Name tree branch overflow block -- 0x%lx."), overFlowBlock ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("--name node branch overflow %d\n"),overFlowBlock); + DBG_DebugPrintf(LRED,MSGNot("--name node branch overflow %d\n"),overFlowBlock); #endif switch(vStats->action) { @@ -912,7 +912,7 @@ ZVP_ERROR ZVP_NameTreeWalkPool(VerifyStats_s *vStats) rootBlock = vStats->pool->ZFSPOOLnameTree->zfsBtree.p.btRoot; return(ZVP_NameTreeWalk(vStats, &vStats->zfsPoolStats->NTStats, rootBlock, vStats->VS_ivVolZid, &vStats->VS_NTData)); -} +} /* ZVP_NameTreeWalk() - @@ -970,3 +970,4 @@ LONG ZVP_NameTreeWalk(VerifyStats_s *vStats, NTStats_s *NTStats, Blknum_t rootBl return zOK; } /* End of ZVP_NameTreeWalk() */ + diff --git a/src/nwnss/zlss/repairPtree.c b/src/nwnss/zlss/repairPtree.c index 6d11ec9..b963ba4 100644 --- a/src/nwnss/zlss/repairPtree.c +++ b/src/nwnss/zlss/repairPtree.c @@ -425,7 +425,7 @@ LONG visitPurgeNode(PurgeTreeNewNode_s *node, Blknum_t blknum, VerifyStats_s *vS if ( !PurgeNode_valid(node, blknum, vStats, STStats) ) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot(">>>>Invalid purge node %d\n"),blknum); + DBG_DebugPrintf(LRED,MSGNot(">>>>Invalid purge node %d\n"),blknum); #endif ccode = zOK; goto VISIT_DONE; @@ -434,7 +434,7 @@ LONG visitPurgeNode(PurgeTreeNewNode_s *node, Blknum_t blknum, VerifyStats_s *vS if (PBT_NEW_IS_LEAF(node)) /* LEAF NODE */ { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("Purge Leaf Verified, %d records\n"), node->numRecs); + DBG_DebugPrintf(LRED,MSGNot("Purge Leaf Verified, %d records\n"), node->numRecs); #endif switch(vStats->action) { @@ -499,7 +499,7 @@ LONG visitPurgeNode(PurgeTreeNewNode_s *node, Blknum_t blknum, VerifyStats_s *vS { zVolume = lvDataPtr->lvZVolume; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot(">>>>Found LV for Salvage Object\n")); + DBG_DebugPrintf(LRED,MSGNot(">>>>Found LV for Salvage Object\n")); #endif break; } @@ -512,7 +512,7 @@ LONG visitPurgeNode(PurgeTreeNewNode_s *node, Blknum_t blknum, VerifyStats_s *vS * tree. */ #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot(">>>>LV for Salvage Object == NULL\n")); + DBG_DebugPrintf(LRED,MSGNot(">>>>LV for Salvage Object == NULL\n")); #endif continue; } @@ -520,7 +520,7 @@ LONG visitPurgeNode(PurgeTreeNewNode_s *node, Blknum_t blknum, VerifyStats_s *vS if ( !lvDataPtr->lvQuasiActivated ) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot(">>>>LV for Salvage Object not lvQuasiActivated == NULL\n")); + DBG_DebugPrintf(LRED,MSGNot(">>>>LV for Salvage Object not lvQuasiActivated == NULL\n")); #endif zASSERT("Why is the LV not lvQuasiActivated?"==NULL); continue; @@ -534,7 +534,7 @@ LONG visitPurgeNode(PurgeTreeNewNode_s *node, Blknum_t blknum, VerifyStats_s *vS } /* check to make sure parent entry in in the beast tree & name tree */ #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot(">>>>loaded LV system beasts\n")); + DBG_DebugPrintf(LRED,MSGNot(">>>>loaded LV system beasts\n")); #endif beast = ZFSVOL_VOL_GetBeastFromVolume(&genMsg, pinfo->value.pzid, &zVolume->vol); if(beast == NULL) @@ -615,7 +615,7 @@ LONG visitPurgeNode(PurgeTreeNewNode_s *node, Blknum_t blknum, VerifyStats_s *vS break; } #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("Purge Branch Verified, %d records\n"), node->numRecs); + DBG_DebugPrintf(LRED,MSGNot("Purge Branch Verified, %d records\n"), node->numRecs); #endif for (i = 0; i < node->numRecs; i++) { @@ -626,7 +626,7 @@ LONG visitPurgeNode(PurgeTreeNewNode_s *node, Blknum_t blknum, VerifyStats_s *vS } childBlock = PBT_NEW_BRANCH_ENTRY(node, i)->child; - + READBLK_IO_MSG(iomsg, vStats->pool->purgeTree, childBlock, CACHE_READ); buffer = ZVP_ReadPoolBlk( &genMsg, &iomsg, vStats, WHERE ); if (buffer == NULL) @@ -661,12 +661,12 @@ LONG visitPurgeNode(PurgeTreeNewNode_s *node, Blknum_t blknum, VerifyStats_s *vS } } ccode = zOK; - + VISIT_DONE: CBS_LevelUp( vStats->VS_cBS ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("Purge Tree Verified, %d return code\n"), ccode); + DBG_DebugPrintf(LRED,MSGNot("Purge Tree Verified, %d return code\n"), ccode); #endif return ccode; } @@ -719,7 +719,7 @@ ZVP_ERROR ZVP_SalvageTreeWalk(VerifyStats_s *vStats, STStats_s *STStats, Zid_t v return GetErrno(&genMsg); } rootNode = (PurgeTreeNewNode_s*)buffer->pBuf.data; - + switch(vStats->action) { case BMP_TST_EXTENT: @@ -748,9 +748,11 @@ ZVP_ERROR ZVP_SalvageTreeWalk(VerifyStats_s *vStats, STStats_s *STStats, Zid_t v else { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("INVALID PURGE TREE ROOT\n")); + DBG_DebugPrintf(LRED,MSGNot("INVALID PURGE TREE ROOT\n")); #endif } } return zOK; } + + diff --git a/src/nwnss/zlss/repairRAV.c b/src/nwnss/zlss/repairRAV.c index 73e428e..51f184e 100644 --- a/src/nwnss/zlss/repairRAV.c +++ b/src/nwnss/zlss/repairRAV.c @@ -19,7 +19,7 @@ | |*************************************************************************** | - | NetWare Advance File Service + | NetWare Advance File Service | |--------------------------------------------------------------------------- | @@ -51,7 +51,6 @@ #include #include #include -#include #include #include @@ -213,7 +212,7 @@ STATUS RAV_TestAndSetBlock( if ( (bitMap == NULL) || (bitMap->BM_Map == NULL) ) { - zASSERT("Fix the caller of RAV_TestAndSetBlock()"==NULL); + zASSERT("Fix the caller of RAV_TestAndSetBlock()"==NULL); return zERR_BAD_PARAMETER_VALUE; } if ( blockNum >= bitMap->BM_NumberOfBits ) @@ -247,7 +246,7 @@ STATUS RAV_BM_SetBlock( if ( (bitMap == NULL) || (bitMap->BM_Map == NULL) ) { - zASSERT("Fix the caller of RAV_TestAndSetBlock()"==NULL); + zASSERT("Fix the caller of RAV_TestAndSetBlock()"==NULL); return zERR_BAD_PARAMETER_VALUE; } if ( blockNum >= bitMap->BM_NumberOfBits ) @@ -302,7 +301,7 @@ STATUS RAV_TestBlock( if ( (bitMap == NULL) || (bitMap->BM_Map == NULL) ) { - zASSERT("Fix the caller of RAV_TestAndSetBlock()"==NULL); + zASSERT("Fix the caller of RAV_TestAndSetBlock()"==NULL); return zERR_BAD_PARAMETER_VALUE; } if ( blockNum >= bitMap->BM_NumberOfBits ) @@ -581,7 +580,7 @@ STATUS RAV_DisplayXML( { ForceSetErrno( genMsg, status ); } - return( status ); + return( status ); } /* End of RAV_DisplayXML() */ @@ -615,7 +614,7 @@ STATUS RAV_ResourceFree( GeneralMsg_s *genMsg, QUAD userKey ) * "Pool\\%s\\ZLSS\\VerifyStatistics.vbf" * RAV_VerifyStatisticsDisplayBin() - * This dumps verify statistics into a buffer in BIN format. - * + * * Notes - * This routine requires that we can fit ALL of the data to be passed to * the user into one buffer. This routine will determine the size of the @@ -667,7 +666,7 @@ STATUS RAV_VerifyStatisticsDisplayBin( { ForceSetErrno( genMsg, status ); } - return( status ); + return( status ); } /* End of RAV_VerifyStatisticsDisplayBin() */ @@ -707,7 +706,7 @@ STATIC void RAV_VS_ActionItemDisplay( NINT *rLen ) { Time_t now; - char aBuffer[80]; + char aBuffer[80]; VFS_ssprintf(bLen, bAdd, rLen, "\n" ); VFS_ssprintf(bLen, bAdd, rLen, "\n", dVar->RA_Key ); @@ -881,7 +880,7 @@ Buffer_s *RAV_ReadPoolBlk(GeneralMsg_s *genMsg, IoMsg_s *ioMsg, BOOL *cacheHit ) Grows a RAV_GrowingStats_s object by specified amount. If specified amount is 0 then the default amount associated with the RAV_GrowingStats_s is used. The new memory will be zeroed. - + Warnings - The caller must not keep local copies of the RGS_Data pointer. The caller must own a lock on the RAV_GrowingStats_s (as indicated by the required 'lockKey'). @@ -1227,7 +1226,7 @@ STATUS RAV_ResourceFreePartial( } UNX_LATCH( &RAV_FinalStatListLatch ); SetErrno( genMsg, zERR_RAV_NO_STATUS_FOUND ); - return( zERR_RAV_NO_STATUS_FOUND ); + return( zERR_RAV_NO_STATUS_FOUND ); } /* End of RAV_ResourceFreePartial() */ @@ -1596,3 +1595,6 @@ void RAV_CopyRightSideOfWhere( char *dest, const char *where, size_t destSize ) strcpy( dest, whereRight ); return; } + + + diff --git a/src/nwnss/zlss/repairRAVDebug.c b/src/nwnss/zlss/repairRAVDebug.c index a3a433c..4bcd5b3 100644 --- a/src/nwnss/zlss/repairRAVDebug.c +++ b/src/nwnss/zlss/repairRAVDebug.c @@ -19,7 +19,7 @@ | |*************************************************************************** | - | NetWare Advance File Service + | NetWare Advance File Service | |--------------------------------------------------------------------------- | @@ -108,7 +108,7 @@ void ZVP_AnalysisReport( VerifyStats_s *vStats ) { ZVP_LVData_s *lvData; - + aprintf( CYAN, " Pool \"%U\" analysis pass report (%lu)\n", vStats->zfsPoolStats->ZPS_uiStatus.ZVPS_PoolName, GetUTCTime() ); aprintf( LGREEN, " Blocks -------------- %Lu\n", vStats->zfsPoolStats->PDBStats.dataTotalBlocks ); @@ -123,7 +123,7 @@ void ZVP_AnalysisReport( VerifyStats_s *vStats ) aprintf( LGREEN, " Objects ------------- %Lu\n", vStats->zfsPoolStats->VDBStats.dataNumObjects ); aprintf( LGREEN, " Files --------------- %Lu\n", vStats->zfsPoolStats->VDBStats.dataNumFiles ); aprintf( LGREEN, " Next ZID ------------ %Lu\n", vStats->zfsPoolStats->VDBStats.dataNextZid ); - + DQ_FOREACH( &vStats->VS_LVData, lvData, ZVP_LVData_s, link ) { diff --git a/src/nwnss/zlss/repairRAVDebug.h b/src/nwnss/zlss/repairRAVDebug.h index a6b97ac..3e7cb02 100644 --- a/src/nwnss/zlss/repairRAVDebug.h +++ b/src/nwnss/zlss/repairRAVDebug.h @@ -19,7 +19,7 @@ | |*************************************************************************** | - | NetWare Advance File Service + | NetWare Advance File Service | |--------------------------------------------------------------------------- | diff --git a/src/nwnss/zlss/repairReZid.c b/src/nwnss/zlss/repairReZid.c index 4a4fb74..1664ae6 100644 --- a/src/nwnss/zlss/repairReZid.c +++ b/src/nwnss/zlss/repairReZid.c @@ -61,7 +61,7 @@ #include #include #include -#include "repairMain.h" +#include "repairMain.h" #include #undef WHERE @@ -70,14 +70,14 @@ /***************************************************************** * findZnodeByConvertedZid * I: buffer - the buffer to be searched - * I: zid - ZID to find + * I: zid - ZID to find * O: index into the ptr array (0 to numrecs) * R: True if the ZID is found * * NOTE: This routine searches based on the zid in the rebuild - * reserved section for re-zid. This code is similar to + * reserved section for re-zid. This code is similar to * the findZnodeByZid routine in beasttree.c - * + * *****************************************************************/ BOOL findZnodeByConvertedZid( BeastTreeNode_s *node, @@ -155,7 +155,7 @@ Zid_t REZID_ConvertZid( RepairStats_s *rStats, ZfsVolume_s *zfsVol, Zid_t zidToConvert, - BOOL isConverted) + BOOL isConverted) { ZfsBeastTreeBeast_s *ztree = zfsVol->beastTree; BeastTreeParms_s parms; @@ -209,7 +209,7 @@ Zid_t REZID_ConvertZid( { retZid = zINVALID_ZID; } - + } else { @@ -262,10 +262,10 @@ STATUS REZID_DirTreeLeafCleaup( //g IoMsg_s iomsg; ZfsDirTreeBeast_s *ztree = zfsVol->dirTree; DirTreeNode_s *node = (DirTreeNode_s *)buffer->pBuf.data; - DirTreeNode_s *parentNode; + DirTreeNode_s *parentNode; Blknum_t parent; Extent_s deleteExtent; - + /* The left leaf entry will always have an entry for Zid zero * so we can assume, that the left leaf will never have 0 * numRecs. This is true for all the left branches at every level. @@ -349,15 +349,15 @@ STATUS REZID_DirTreeNodeReZid( BOOL *fixupLeafLinkList) { //g IoMsg_s iomsg; - Buffer_s *newBuf; + Buffer_s *newBuf; NINT i; DirTreeNode_s *node = (DirTreeNode_s *)buffer->pBuf.data; - DirTreeNode_s *childNode; + DirTreeNode_s *childNode; BOOL reZidBranchNode = TRUE; ZfsDirTreeBeast_s *ztree = zfsVol->dirTree; Extent_s deleteExtent = {0}; - if (DBT_IS_LEAF(node)) + if (DBT_IS_LEAF(node)) { if (clearReZidState) { @@ -380,8 +380,8 @@ STATUS REZID_DirTreeNodeReZid( if (node->DLEAF(i).dirZid == zINVALID_ZID) { memmove(&node->DLEAF(i), &node->DLEAF(i + 1), - (node->numRecs - (i + 1)) * sizeof(DirLeafEntry_s)); - i--; + (node->numRecs - (i + 1)) * sizeof(DirLeafEntry_s)); + i--; node->numRecs--; } } @@ -415,7 +415,7 @@ STATUS REZID_DirTreeNodeReZid( } childNode = (DirTreeNode_s *)newBuf->pBuf.data; - if (REZID_DirTreeNodeReZid(genMsg, rStats, zfsVol, newBuf, clearReZidState, + if (REZID_DirTreeNodeReZid(genMsg, rStats, zfsVol, newBuf, clearReZidState, fixupLeafLinkList) != zOK) { CACHE_RELEASE(newBuf); @@ -429,15 +429,15 @@ STATUS REZID_DirTreeNodeReZid( * as the key in the branch */ node->DBRANCH(i).dirZid = (DBT_IS_LEAF(childNode)) ? - childNode->DLEAF(0).dirZid : + childNode->DLEAF(0).dirZid : childNode->DBRANCH(0).dirZid; } else { - /* child is empty, can't key the entry in parent, so + /* child is empty, can't key the entry in parent, so * delete the parent entry. If the child is a branch, * it can be deleted here since it is empty. If the child - * is a leaf, the leaf link list has to be fixed up, so + * is a leaf, the leaf link list has to be fixed up, so * we will delete it later. */ if (DBT_IS_LEAF(childNode)) @@ -450,7 +450,7 @@ STATUS REZID_DirTreeNodeReZid( } memmove(&node->DBRANCH(i), &node->DBRANCH(i + 1), (node->numRecs - (i + 1)) * sizeof(DirBranchEntry_s)); - i--; + i--; node->numRecs--; } } @@ -514,7 +514,7 @@ STATUS REZID_DirTreeReZid( { return zFAILURE; } - if (REZID_DirTreeNodeReZid(genMsg, rStats, zfsVol, buffer, clearReZidState, + if (REZID_DirTreeNodeReZid(genMsg, rStats, zfsVol, buffer, clearReZidState, &fixupLeafLinkedList) != zOK) { CACHE_RELEASE(buffer); @@ -558,10 +558,10 @@ STATUS REZID_EFLTreeLeafCleaup( //g IoMsg_s iomsg; ZfsEFLTreeBeast_s *etree = zfsVol->eflTree; EFLTreeNode_s *node = (EFLTreeNode_s *)buffer->pBuf.data; - EFLTreeNode_s *parentNode; + EFLTreeNode_s *parentNode; Blknum_t parent; Extent_s deleteExtent; - + /* The left leaf entry will always have an entry for Zid zero * so we can assume, that the left leaf will never have 0 * numRecs. This is true for all the left branches at every level. @@ -646,15 +646,15 @@ STATUS REZID_EFLTreeNodeReZid( BOOL *fixupLeafLinkList) { //g IoMsg_s iomsg; - Buffer_s *newBuf; + Buffer_s *newBuf; NINT i; EFLTreeNode_s *node = (EFLTreeNode_s *)buffer->pBuf.data; - EFLTreeNode_s *childNode; + EFLTreeNode_s *childNode; BOOL reZidBranchNode = TRUE; ZfsEFLTreeBeast_s *etree = zfsVol->eflTree; Extent_s deleteExtent = {0}; - if (EFL_IS_LEAF(node)) + if (EFL_IS_LEAF(node)) { if (clearReZidState) { @@ -678,7 +678,7 @@ STATUS REZID_EFLTreeNodeReZid( { memmove(&node->ELEAF(i), &node->ELEAF(i + 1), (node->numRecs - (i + 1)) * sizeof(EFLLeafEntry_s)); - i--; + i--; node->numRecs--; } } @@ -713,7 +713,7 @@ STATUS REZID_EFLTreeNodeReZid( } childNode = (EFLTreeNode_s *)newBuf->pBuf.data; - if (REZID_EFLTreeNodeReZid(genMsg, rStats, zfsVol, newBuf, clearReZidState, + if (REZID_EFLTreeNodeReZid(genMsg, rStats, zfsVol, newBuf, clearReZidState, fixupLeafLinkList) != zOK) { CACHE_RELEASE(newBuf); @@ -727,15 +727,15 @@ STATUS REZID_EFLTreeNodeReZid( * as the key in the branch */ node->EBRANCH(i).zid = (EFL_IS_LEAF(childNode)) ? - childNode->ELEAF(0).zid : + childNode->ELEAF(0).zid : childNode->EBRANCH(0).zid; } else { - /* child is empty, can't key the entry in parent, so + /* child is empty, can't key the entry in parent, so * delete the parent entry. If the child is a branch, * it can be deleted here since it is empty. If the child - * is a leaf, the leaf link list has to be fixed up, so + * is a leaf, the leaf link list has to be fixed up, so * we will delete it later. */ if (EFL_IS_LEAF(childNode)) @@ -748,7 +748,7 @@ STATUS REZID_EFLTreeNodeReZid( } memmove(&node->EBRANCH(i), &node->EBRANCH(i + 1), (node->numRecs - (i + 1)) * sizeof(EFLBranchEntry_s)); - i--; + i--; node->numRecs--; } } @@ -791,7 +791,7 @@ STATUS REZID_EFLLogNodeReZid( Buffer_s *buffer; NINT i; ELogNode_s *header = (ELogNode_s *)headBuf->pBuf.data; - ELogNode_s *node; + ELogNode_s *node; ZfsEFLTreeBeast_s *etree = zfsVol->eflTree; Blknum_t nextBlk, volBlk; ELogEntry_s *entry; @@ -802,7 +802,7 @@ STATUS REZID_EFLLogNodeReZid( return zOK; } - nextBlk = header->nextBlock; + nextBlk = header->nextBlock; do { /* find the next log node in the link */ @@ -814,11 +814,11 @@ STATUS REZID_EFLLogNodeReZid( { return zFAILURE; } - + node = (ELogNode_s *)buffer->pBuf.data; nextBlk = node->nextBlock; volBlk = buffer->volBlk; - + if (clearReZidState) { node->state &= ~ELOG_STATE_REZID_DONE; @@ -830,7 +830,7 @@ STATUS REZID_EFLLogNodeReZid( for (i = 0; i < node->numEntries; i++) { entry = (ELogEntry_s *)&node->u.log.data[offset]; - + if (!(entry->state & ELOG_ENTRY_STATE_DELETED)) { zASSERT(entry->zid > zROOTDIR_ZID); @@ -839,18 +839,18 @@ STATUS REZID_EFLLogNodeReZid( entry->zid, FALSE); zASSERT(entry->zid != zINVALID_ZID); - - offset += entry->len; + + offset += entry->len; } } node->state |= ELOG_STATE_REZID_DONE; buffer->state |= CACHE_DIRTY; } - + CACHE_RELEASE(buffer); - + }while (volBlk != header->u.header.lastBlock); - + return zOK; } @@ -871,7 +871,7 @@ STATUS REZID_EFLTreeReZid( ZfsEFLTreeBeast_s *etree = zfsVol->eflTree; BOOL fixupLeafLinkedList = FALSE; Blknum_t child; - + if (etree == NULL) { @@ -894,8 +894,8 @@ STATUS REZID_EFLTreeReZid( { return zFAILURE; } - - if (REZID_EFLTreeNodeReZid(genMsg, rStats, zfsVol, buffer, clearReZidState, + + if (REZID_EFLTreeNodeReZid(genMsg, rStats, zfsVol, buffer, clearReZidState, &fixupLeafLinkedList) != zOK) { CACHE_RELEASE(buffer); @@ -921,7 +921,7 @@ STATUS REZID_EFLTreeReZid( { return zOK; } - + buffer = ZRP_ReadPoolBlk( genMsg, rStats, &etree->ZFSEFLTREEroot, child, CACHE_UPDATE, WHERE ); //g READBLK_IO_MSG(iomsg, etree, child, CACHE_UPDATE); @@ -930,22 +930,22 @@ STATUS REZID_EFLTreeReZid( { return zFAILURE; } - + if (REZID_EFLLogNodeReZid(genMsg, rStats, zfsVol, buffer, clearReZidState) != zOK) { CACHE_RELEASE(buffer); return zFAILURE; } - + CACHE_RELEASE(buffer); - + return zOK; } /***************************************************************** * * REZID_BeastFileMapNodeReZid() - - * Recurses through the file map and fixes the zid in each of the + * Recurses through the file map and fixes the zid in each of the * file map nodes to be the new Zid. * *****************************************************************/ @@ -999,7 +999,7 @@ void REZID_BeastFileMapNodeReZid( /***************************************************************** * * REZID_BeastFileMapReZid() - - * Fixes the zid in each of the file map nodes to be the + * Fixes the zid in each of the file map nodes to be the * new Zid. * * There are no error returns, because the fnh_zid in the fmap @@ -1051,9 +1051,9 @@ void REZID_BeastFileMapReZid( * * REZID_BeastTreeEntryReZid() - * Rezids the following zids in a single beast: - * The beast is left in packed format. + * The beast is left in packed format. * NAMED_BEAST: parentZID - * AUTH_BEAST: ACL and VIS overFlowZid + * AUTH_BEAST: ACL and VIS overFlowZid * ACL_BEAST: nextOverflowZid * VIS_BEAST: nextOverflowZid * COMPRESSED BEAST: compZid @@ -1098,7 +1098,7 @@ void REZID_BeastTreeEntryReZid( case BEAST_VERSION_1: znode_V1 = (V1_ZFSPackedRoot_s *)znode; curVar = (BYTE *)(((BYTE *)znode_V1) + sizeof(V1_ZFSPackedRoot_s)); - fmap = (Fmap_s *)(((BYTE *)znode_V1) + + fmap = (Fmap_s *)(((BYTE *)znode_V1) + sizeof(V1_ZFSPackedRoot_s) + znode_V1->variableSize); fmapSize = znode_V1->sizeFmap; deletedParentEntrySize = sizeof(V1_DeletedPersistentParentEntry_s); @@ -1109,7 +1109,7 @@ void REZID_BeastTreeEntryReZid( default: znode_V1 = NULL; curVar = (BYTE *)(((BYTE *)znode) + sizeof(ZFSPackedRoot_s)); - fmap = (Fmap_s *)(((BYTE *)znode) + + fmap = (Fmap_s *)(((BYTE *)znode) + sizeof(ZFSPackedRoot_s) + znode->variableSize); fmapSize = znode->sizeFmap; deletedParentEntrySize = sizeof(DeletedPersistentParentEntry_s); @@ -1165,17 +1165,17 @@ void REZID_BeastTreeEntryReZid( if (numParents > 0) { - /* dummy points to first of all parents - * (PersistentParentEntry_s) + /* dummy points to first of all parents + * (PersistentParentEntry_s) */ for ( i = 0; i < numParents; i++) { /* add the size of each parent entry for this beast */ numNames = ((PersistentParentEntry_s *)dummy)->numNames; - if (((PersistentParentEntry_s *)dummy)->nameType == + if (((PersistentParentEntry_s *)dummy)->nameType == zNTYPE_DELETED_FILE) { - dummy += sizeof(PersistentParentEntry_s) + + dummy += sizeof(PersistentParentEntry_s) + deletedParentEntrySize; } else @@ -1183,12 +1183,12 @@ void REZID_BeastTreeEntryReZid( dummy += sizeof(PersistentParentEntry_s); } /* dummy points past this parent entry potentially - * at the list of names (if any, PersistentNameEntry_s) + * at the list of names (if any, PersistentNameEntry_s) */ for (k = 0; k < numNames; k++) { /* add the size of each name entry for this parent */ - dummy += REALSIZE_PersistentNameEntry_s + + dummy += REALSIZE_PersistentNameEntry_s + NAMED_GET_NSIZE((PersistentNameEntry_s *)dummy); } } @@ -1198,16 +1198,16 @@ void REZID_BeastTreeEntryReZid( /* dummy now points to the first part of the auth stuff */ zasAuthInfo = (ZASPersistentAuthInfo_s *)dummy; - isConverted = (zasAuthInfo->trusteeOverflow > oldZid) ? + isConverted = (zasAuthInfo->trusteeOverflow > oldZid) ? FALSE : TRUE; - zasAuthInfo->trusteeOverflow = REZID_ConvertZid( - genMsg, rStats, zfsVol, + zasAuthInfo->trusteeOverflow = REZID_ConvertZid( + genMsg, rStats, zfsVol, zasAuthInfo->trusteeOverflow, isConverted); - isConverted = (zasAuthInfo->visibilityOverflow > oldZid) ? + isConverted = (zasAuthInfo->visibilityOverflow > oldZid) ? FALSE : TRUE; - zasAuthInfo->visibilityOverflow = REZID_ConvertZid( - genMsg, rStats, zfsVol, + zasAuthInfo->visibilityOverflow = REZID_ConvertZid( + genMsg, rStats, zfsVol, zasAuthInfo->visibilityOverflow, isConverted); } else @@ -1215,16 +1215,16 @@ void REZID_BeastTreeEntryReZid( /* dummy now points to the first part of the auth stuff */ zasAuthInfo_V1 = (V1_ZASPersistentAuthInfo_s *)dummy; - isConverted = (zasAuthInfo_V1->trusteeOverflow > oldZid) ? + isConverted = (zasAuthInfo_V1->trusteeOverflow > oldZid) ? FALSE : TRUE; - zasAuthInfo_V1->trusteeOverflow = REZID_ConvertZid( - genMsg, rStats, zfsVol, + zasAuthInfo_V1->trusteeOverflow = REZID_ConvertZid( + genMsg, rStats, zfsVol, zasAuthInfo_V1->trusteeOverflow, isConverted); - isConverted = (zasAuthInfo_V1->visibilityOverflow > oldZid) ? + isConverted = (zasAuthInfo_V1->visibilityOverflow > oldZid) ? FALSE : TRUE; - zasAuthInfo_V1->visibilityOverflow = REZID_ConvertZid( - genMsg, rStats, zfsVol, + zasAuthInfo_V1->visibilityOverflow = REZID_ConvertZid( + genMsg, rStats, zfsVol, zasAuthInfo_V1->visibilityOverflow, isConverted); } } @@ -1236,7 +1236,7 @@ void REZID_BeastTreeEntryReZid( isConverted = (aclOverflow->nextOverflowZid > oldZid) ? FALSE : TRUE; - aclOverflow->nextOverflowZid = REZID_ConvertZid(genMsg, rStats, zfsVol, + aclOverflow->nextOverflowZid = REZID_ConvertZid(genMsg, rStats, zfsVol, aclOverflow->nextOverflowZid, isConverted); } if (COMN_IsIDDerivedFrom(znode->header.type, zFTYPE_ZAS_VIS_OVERFLOW)) @@ -1246,7 +1246,7 @@ void REZID_BeastTreeEntryReZid( isConverted = (visOverflow->nextOverflowZid > oldZid) ? FALSE : TRUE; - visOverflow->nextOverflowZid = REZID_ConvertZid(genMsg, rStats, zfsVol, + visOverflow->nextOverflowZid = REZID_ConvertZid(genMsg, rStats, zfsVol, visOverflow->nextOverflowZid, isConverted); } if (COMN_IsIDDerivedFrom(znode->header.type, zFTYPE_COMPRESSION)) @@ -1255,12 +1255,12 @@ void REZID_BeastTreeEntryReZid( isConverted = (pComp->uncompZid > oldZid) ? FALSE : TRUE; - pComp->uncompZid = REZID_ConvertZid(genMsg, rStats, zfsVol, + pComp->uncompZid = REZID_ConvertZid(genMsg, rStats, zfsVol, pComp->uncompZid, isConverted); } if (fmap->root != 0) { - REZID_BeastFileMapReZid(genMsg, rStats, zfsVol->pool, fmap->root, znode->header.zid); + REZID_BeastFileMapReZid(genMsg, rStats, zfsVol->pool, fmap->root, znode->header.zid); } if ((znode_V1 == NULL) && (znode->variableSize != 0)) { @@ -1281,7 +1281,7 @@ void REZID_BeastTreeEntryReZid( } else { - used = sizeof(PackedUnixInfo_s) + + used = sizeof(PackedUnixInfo_s) + ((PackedUnixInfo_s *)curVar)->unixInfo.variableSize; } break; @@ -1295,7 +1295,7 @@ void REZID_BeastTreeEntryReZid( isConverted = (compInfo->cmInfo.compZid > oldZid) ? FALSE : TRUE; - compInfo->cmInfo.compZid = REZID_ConvertZid(genMsg, rStats, zfsVol, + compInfo->cmInfo.compZid = REZID_ConvertZid(genMsg, rStats, zfsVol, compInfo->cmInfo.compZid, isConverted); used = sizeof(PackedCompInfo_s); @@ -1358,7 +1358,7 @@ void REZID_BeastTreeNodeReZid( switch(((ZFSPackedRoot_s *)znode)->beastLayout) { case BEAST_VERSION_1: - rebuildMagic = &((V1_ZFSPackedRoot_s *)znode)->rebuildMagic; + rebuildMagic = &((V1_ZFSPackedRoot_s *)znode)->rebuildMagic; rebReZidState = &((V1_ZFSPackedRoot_s *)znode)->rebuildReZidState; rebReZid = &((V1_ZFSPackedRoot_s *)znode)->rebuildReZid; break; @@ -1366,7 +1366,7 @@ void REZID_BeastTreeNodeReZid( case BEAST_VERSION_2: case BEAST_VERSION_3: default: - rebuildMagic = &((ZFSPackedRoot_s *)znode)->rebuildMagic; + rebuildMagic = &((ZFSPackedRoot_s *)znode)->rebuildMagic; rebReZidState = &((ZFSPackedRoot_s *)znode)->rebuildReZidState; rebReZid = &((ZFSPackedRoot_s *)znode)->rebuildReZid; break; @@ -1376,11 +1376,11 @@ void REZID_BeastTreeNodeReZid( { continue; } - + newZid = *rebReZid; oldZid = znode->header.zid; *rebReZid = (LONG)oldZid; - znode->header.zid = newZid; + znode->header.zid = newZid; *rebReZidState = REBUILD_REZID_STATE_REZID_DONE; buffer->state |= CACHE_DIRTY; @@ -1390,16 +1390,16 @@ void REZID_BeastTreeNodeReZid( continue; } - REZID_BeastTreeEntryReZid(genMsg, rStats, zfsVol, (ZFSPackedRoot_s *)znode, + REZID_BeastTreeEntryReZid(genMsg, rStats, zfsVol, (ZFSPackedRoot_s *)znode, oldZid, rebuildMagic); } return; -} +} /***************************************************************** * - * This routine goes through the beast tree leaves and calls a + * This routine goes through the beast tree leaves and calls a * routine to rezid all the beasts in each node. It collects information * about the rezid leaves so that this information can be used later * to build a new set of beast tree branches based on the new zids. @@ -1420,7 +1420,7 @@ STATUS REZID_BeastTreeReZid( //g PBAR bar; Znode_s *znode; -//g bar = WinCreateProgressBar(rStats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_screenHandle, 7, 14, 52, +//g bar = WinCreateProgressBar(rStats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_screenHandle, 7, 14, 52, //g MSGNot(" ReZid Progress ")); if (rbtStats->leafCount == 0) { @@ -1455,7 +1455,7 @@ STATUS REZID_BeastTreeReZid( } #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("Starting Re-Zid Leaf Walk\n")); + DBG_DebugPrintf(LRED,MSGNot("Starting Re-Zid Leaf Walk\n")); #endif for (;;) { @@ -1510,18 +1510,18 @@ STATUS REZID_BeastTreeReZid( return( zFAILURE ); } - nextLeaf = node->n.leaf.nextLeaf; + nextLeaf = node->n.leaf.nextLeaf; if ( (nextLeaf == 0) || (nextLeaf == INVALID_BLK) ) { znode = (Znode_s *)&node->LEAF.znode[node->LEAF.znodePtr[ MAX_LEAF_PTRS - (node->numRecs -1)]]; rbtStats->RS_GreatestAllocatedZid = znode->header.zid; - + CACHE_RELEASE( buffer ); break; } CACHE_RELEASE( buffer ); - } + } rbtStats->leafCount = leafCount; SaveLeafInfoEnd(rbtStats); @@ -1538,18 +1538,18 @@ STATUS REZID_BeastTreeReZid( //g WinDestroyProgressBar( bar ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("Done Re-Zid Leaf Walk\n")); + DBG_DebugPrintf(LRED,MSGNot("Done Re-Zid Leaf Walk\n")); #endif return zOK; } /***************************************************************** * - * This routine will recurse through the old beast tree branches and free the - * blocks that are branches of the old beast tree. + * This routine will recurse through the old beast tree branches and free the + * blocks that are branches of the old beast tree. * * This routine must never be called with a beast tree leaf. - * It can only be called when buffer is a beast tree branch that we + * It can only be called when buffer is a beast tree branch that we * want to throw away. * *****************************************************************/ @@ -1573,7 +1573,7 @@ void REZID_BeastTreeBranchesCleanup( return; } - for (i = 0; i < node->numRecs; i++) + for (i = 0; i < node->numRecs; i++) { newBuf = ZRP_ReadPoolBlk( genMsg, rStats, &zfsVol->beastTree->ZFSBEASTTREEroot, @@ -1612,7 +1612,7 @@ void REZID_BeastTreeBranchesCleanup( /***************************************************************** * * This routine will throw the old beast tree branches (free the block - * and return to the free tree), and build a new set of beast tree + * and return to the free tree), and build a new set of beast tree * branches based on the new zids. * *****************************************************************/ @@ -1709,7 +1709,7 @@ STATUS REZID_DoRezid( /** FixFixFix * When Jeff stops blowing away EFL tree during rebuild, uncomment this block. - * + * * if (REZID_EFLTreeReZid(genMsg, rStats, zfsVol, FALSE) != zOK) * { * return zFAILURE; @@ -1730,7 +1730,7 @@ STATUS REZID_DoRezid( } /* This writes persistent data first and then the logged persistent data. - * I want the logged stuff to be written first as it fixes up the + * I want the logged stuff to be written first as it fixes up the * nextZid. So I call ZFSVOL_WritePersistentVolumeData twice. */ zfsVol->ZFSVOLvol.VOLnextZid = rbtStats->RS_GreatestAllocatedZid + 1; @@ -1740,25 +1740,25 @@ STATUS REZID_DoRezid( ZFSVOL_WritePersistentVolumeData(zfsVol); /* The following REZID_EFLTreeReZid and REZID_DirTreeReZid only - * clears every leaf node's rezid state. Even if + * clears every leaf node's rezid state. Even if * system crashes here, it is OK because repair code will * clear rezid state in other places. */ - + /** FixFixFix * When Jeff stops blowing away EFL tree during rebuild, uncomment this block. * Add extra code in Jeff's EFL rebuild code so that EFL_REZID_DONE flag - * can be cleaned up there if system crashed at this point. (Similar code as + * can be cleaned up there if system crashed at this point. (Similar code as * the block that cleans up DBT_REZID_DONE flag in RepairSRTree.c. ) * * This part of code needs to be tested. - * + * * if (REZID_EFLTreeReZid(genMsg, rStats, zfsVol, TRUE) != zOK) * { * return zFAILURE; * } */ - + if (REZID_DirTreeReZid(genMsg, rStats, zfsVol, TRUE) != zOK) { return zFAILURE; @@ -1770,3 +1770,4 @@ STATUS REZID_DoRezid( } return zOK; } + diff --git a/src/nwnss/zlss/repairSRTree.c b/src/nwnss/zlss/repairSRTree.c index 6e446c5..58c79b4 100644 --- a/src/nwnss/zlss/repairSRTree.c +++ b/src/nwnss/zlss/repairSRTree.c @@ -92,7 +92,7 @@ STATUS ZRB_ValidateUNAMblk(RepairStats_s *rStats, ZfsVolume_s *zVolume, Blknum_t if (buffer == NULL) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: ZRB_ValidateSRNode (unamBlk) read buffer alloc error\n")); + DBG_DebugPrintf(LRED,MSGNot("VERIFY ERR: ZRB_ValidateSRNode (unamBlk) read buffer alloc error\n")); #endif return zFAILURE; } @@ -258,7 +258,7 @@ STATUS ZRB_ValidateSRNode(RepairStats_s *rStats, void *node, ZfsVolume_s *zVolum ***************************************************************************/ STATUS ZRB_ValidateSRTree(RepairStats_s *rStats, ZfsVolume_s *zVolume, NINT treeType) { - void *rootNode; + void *rootNode; Blknum_t rootBlock = 0; Blknum_t btFree; STATUS ccode; @@ -328,10 +328,10 @@ STATUS ZRB_ValidateSRTree(RepairStats_s *rStats, ZfsVolume_s *zVolume, NINT tree * ZRB_MapSRBlock() * Test and set the bits in the allocation and systemblocks bitmaps ***************************************************************************/ -STATUS ZRB_MapSRBlock(RepairStats_s *rStats, - RBTStats_s *RBTStats, - RUBTStats_s *RUBTStats, - RDBTStats_s *RDBTStats, +STATUS ZRB_MapSRBlock(RepairStats_s *rStats, + RBTStats_s *RBTStats, + RUBTStats_s *RUBTStats, + RDBTStats_s *RDBTStats, Blknum_t block, NINT treeType) { @@ -370,18 +370,18 @@ STATUS ZRB_MapSRBlock(RepairStats_s *rStats, * Recursively walk the USR/DSR tree(s) and map the tree blocks into * the allocation and systemblocks bitmaps. * This is the second part of rebuild for the USR/DSR trees. - * If the entire tree does not map without conflicts, we unmap the + * If the entire tree does not map without conflicts, we unmap the * blocks already mapped from the tree thus far (see ZRB_FreeSRTree) and * return an error causing the system/user to rebuild the tree(s). * If the entire tree is mapped without conflicts, then we go ahead and use * the current USR/DSR trees. ***************************************************************************/ -STATUS ZRB_MapSRNode(void *parentNode, - Blknum_t parentBlock, - RepairStats_s *rStats, - RBTStats_s *RBTStats, - RUBTStats_s *RUBTStats, - RDBTStats_s *RDBTStats, +STATUS ZRB_MapSRNode(void *parentNode, + Blknum_t parentBlock, + RepairStats_s *rStats, + RBTStats_s *RBTStats, + RUBTStats_s *RUBTStats, + RDBTStats_s *RDBTStats, NINT treeType) { NINT i; @@ -424,7 +424,7 @@ STATUS ZRB_MapSRNode(void *parentNode, /* Leaf Node */ if( ((treeType == ZRB_DSR_FLAG) && (((DirTreeNode_s *)parentNode)->magic == DBT_LEAF_MAGIC)) || - ((treeType == ZRB_USR_OLD_FLAG) && (((OldUserTreeNode_s *)parentNode)->magic == UBT_LEAF_MAGIC)) ) + ((treeType == ZRB_USR_OLD_FLAG) && (((OldUserTreeNode_s *)parentNode)->magic == UBT_LEAF_MAGIC)) ) { /* what ever goes here.. */ return zOK; @@ -471,7 +471,7 @@ STATUS ZRB_MapSRNode(void *parentNode, else { /* Already seen so do not map it */ unamNode->verifyCount++; //inc the count UNAM blocks - } + } CACHE_DIRTY_RELEASE(buffer); } else @@ -575,18 +575,18 @@ STATUS ZRB_MapSRNode(void *parentNode, * Start walking the USR/DSR tree(s) and map the tree blocks into * the allocation and systemblocks bitmaps. * This is the second part of rebuild for the USR/DSR trees. - * If the entire tree does not map without conflicts, we unmap the + * If the entire tree does not map without conflicts, we unmap the * blocks already mapped from the tree thus far (see ZRB_FreeSRTree) and * return an error causing the system/user to rebuild the tree(s). * If the entire tree is mapped without conflicts, then we go ahead and use * the current USR/DSR trees. - * A count of mapped blocks is kept for use in ZRB_FreeSRTree to know + * A count of mapped blocks is kept for use in ZRB_FreeSRTree to know * how much of the tree was mapped before we found problems. ***************************************************************************/ -STATUS ZRB_MapSRTree(RepairStats_s *rStats, - RBTStats_s *RBTStats, - RUBTStats_s *RUBTStats, - RDBTStats_s *RDBTStats, +STATUS ZRB_MapSRTree(RepairStats_s *rStats, + RBTStats_s *RBTStats, + RUBTStats_s *RUBTStats, + RDBTStats_s *RDBTStats, NINT treeType) { void *rootNode; @@ -642,7 +642,7 @@ STATUS ZRB_MapSRTree(RepairStats_s *rStats, else { unamNode->verifyCount++; //inc the count UNAM type blocks - } + } CACHE_DIRTY_RELEASE(buffer); } } @@ -683,9 +683,9 @@ STATUS ZRB_MapSRTree(RepairStats_s *rStats, * ZRB_FreeSRBlock() * Test and clear the bits in the allocation and systemblocks bitmaps ***************************************************************************/ -STATUS ZRB_FreeSRBlock(RepairStats_s *rStats, - RUBTStats_s *RUBTStats, - RDBTStats_s *RDBTStats, +STATUS ZRB_FreeSRBlock(RepairStats_s *rStats, + RUBTStats_s *RUBTStats, + RDBTStats_s *RDBTStats, Blknum_t block, NINT treeType) { @@ -697,12 +697,12 @@ STATUS ZRB_FreeSRBlock(RepairStats_s *rStats, * 4) Unmap the block. */ - if (((treeType == ZRB_USR_FLAG) || (treeType == ZRB_USR_OLD_FLAG)) && + if (((treeType == ZRB_USR_FLAG) || (treeType == ZRB_USR_OLD_FLAG)) && (RUBTStats->firstUSRTreeConflictBlkCnt == 0)) { return zFAILURE; } - else if ((treeType == ZRB_DSR_FLAG) && + else if ((treeType == ZRB_DSR_FLAG) && (RDBTStats->firstDSRTreeConflictBlkCnt == 0)) { return zFAILURE; @@ -721,12 +721,12 @@ STATUS ZRB_FreeSRBlock(RepairStats_s *rStats, BM_CLR_BIT(rStats->RS_InUseBlockBM, block); rStats->markedBlockCount--; rStats->RepairZfsPoolStats->RZPS_uiStatus.ZRPS_BlocksProcessedPass1--; - if (((treeType == ZRB_USR_FLAG) || (treeType == ZRB_USR_OLD_FLAG)) && + if (((treeType == ZRB_USR_FLAG) || (treeType == ZRB_USR_OLD_FLAG)) && (RUBTStats->firstUSRTreeConflictBlkCnt > 0)) { RUBTStats->firstUSRTreeConflictBlkCnt--; } - else if ((treeType == ZRB_DSR_FLAG) && + else if ((treeType == ZRB_DSR_FLAG) && (RDBTStats->firstDSRTreeConflictBlkCnt > 0)) { RDBTStats->firstDSRTreeConflictBlkCnt--; @@ -747,12 +747,12 @@ STATUS ZRB_FreeSRBlock(RepairStats_s *rStats, * found. A count kept in ZRB_MapSRTree is used to know how many blocks * to unmap. ***************************************************************************/ -STATUS ZRB_FreeSRNode(void *parentNode, - Blknum_t parentBlock, - RepairStats_s *rStats, - RBTStats_s *RBTStats, - RUBTStats_s *RUBTStats, - RDBTStats_s *RDBTStats, +STATUS ZRB_FreeSRNode(void *parentNode, + Blknum_t parentBlock, + RepairStats_s *rStats, + RBTStats_s *RBTStats, + RUBTStats_s *RUBTStats, + RDBTStats_s *RDBTStats, NINT treeType) { NINT i; @@ -775,7 +775,7 @@ STATUS ZRB_FreeSRNode(void *parentNode, /* Process parent node to traverse the tree */ /* Leaf Node */ if( ((treeType == ZRB_DSR_FLAG) && (((DirTreeNode_s *)parentNode)->magic == DBT_LEAF_MAGIC)) || - ((treeType == ZRB_USR_OLD_FLAG) && (((OldUserTreeNode_s *)parentNode)->magic == UBT_LEAF_MAGIC)) ) + ((treeType == ZRB_USR_OLD_FLAG) && (((OldUserTreeNode_s *)parentNode)->magic == UBT_LEAF_MAGIC)) ) { return zOK; } @@ -819,7 +819,7 @@ STATUS ZRB_FreeSRNode(void *parentNode, { // Is this an error return condition?? The block // should have been marked ours. - } + } CACHE_DIRTY_RELEASE(buffer); } else @@ -861,7 +861,7 @@ STATUS ZRB_FreeSRNode(void *parentNode, childBlock = ((DirTreeNode_s *)parentNode)->n.branch.entry[i].child; ioObject = &RBTStats->zVolume->dirTree->ZFSDIRTREEroot; //g READBLK_IO_MSG(iomsg, RBTStats->zVolume->dirTree, childBlock, CACHE_READ); - } + } else /*if(treeType == ZRB_USR_OLD_FLAG)*/ { childBlock = ((OldUserTreeNode_s *)parentNode)->n.branch.entry[i].child; @@ -919,9 +919,9 @@ STATUS ZRB_FreeSRNode(void *parentNode, * free list is NOT pointed to by any B-TREE Leaf entries. ***************************************************************************/ void ZRB_FreeSRTree(RepairStats_s *rStats, - RBTStats_s *RBTStats, - RUBTStats_s *RUBTStats, - RDBTStats_s *RDBTStats, + RBTStats_s *RBTStats, + RUBTStats_s *RUBTStats, + RDBTStats_s *RDBTStats, NINT treeType) { void *rootNode; @@ -986,8 +986,8 @@ void ZRB_FreeSRTree(RepairStats_s *rStats, * Loads the LV's Usrbeasttree beast & DsrBeastTree into memory ***************************************************************************/ void ZRB_LoadUserAndDsrBeasts( - GeneralMsg_s *genMsg, - RepairStats_s *rStats, + GeneralMsg_s *genMsg, + RepairStats_s *rStats, RBTStats_s *RBTStats) { ZfsUserTreeBeast_s *userTreeBeast; @@ -1017,7 +1017,7 @@ void ZRB_LoadUserAndDsrBeasts( /* Extract the beast for the USER and DIR trees */ /* If we have not upgraded to 40.06 media format yet, then a old format - * user tree may exist. Depending on how far we are in the upgrade + * user tree may exist. Depending on how far we are in the upgrade * the user tree (old or new format) and directory tree may exist on * the internal volume or the logical volume. * @@ -1027,15 +1027,15 @@ void ZRB_LoadUserAndDsrBeasts( * see if the new tree exists. * * FixFixFix: Right now we are punting on which of the two trees - * is correct to use. For this to be correct the upgradeUserTree + * is correct to use. For this to be correct the upgradeUserTree * needs to mark the states in the old and new user trees */ oldUserTreeBeast = (ZfsUserTreeBeast_s *)ZFSVOL_GetBeastFromBuffer( - genMsg, ZFSPOOL_VOLUSERTREE_ZID, + genMsg, ZFSPOOL_VOLUSERTREE_ZID, &RBTStats->zVolume->vol, leafBuffer); userTreeBeast = (ZfsUserTreeBeast_s *)ZFSVOL_GetBeastFromBuffer( - genMsg, ZFSVOL_USERTREE_ZID, + genMsg, ZFSVOL_USERTREE_ZID, &RBTStats->zVolume->vol, leafBuffer); if (oldUserTreeBeast) @@ -1059,7 +1059,7 @@ void ZRB_LoadUserAndDsrBeasts( leafBuffer->state |= CACHE_DIRTY; } } - if (userTreeBeast) + if (userTreeBeast) { if (!oldUserTreeBeast) { @@ -1090,7 +1090,7 @@ void ZRB_LoadUserAndDsrBeasts( CACHE_RELEASE(leafBuffer); /* beast tree node reads will be * done on the beast tree beast after - * GetBeastRootBlockNum which is + * GetBeastRootBlockNum which is * where the beast tree will get * read in */ return; @@ -1099,10 +1099,10 @@ void ZRB_LoadUserAndDsrBeasts( /************************************************************************** * ZRB_ValidateAndMapSRTrees() - * Verify integrity of SPACE RESTRICTION trees, if tree is OK, flip his - * bits in bitmap in preperation for using the existing tree in the - * rebuild system. If the bits don't conflict, then OK to use the the - * beast and the tree. If the bits are x-linked, we must throw away the + * Verify integrity of SPACE RESTRICTION trees, if tree is OK, flip his + * bits in bitmap in preperation for using the existing tree in the + * rebuild system. If the bits don't conflict, then OK to use the the + * beast and the tree. If the bits are x-linked, we must throw away the * tree and new the beast. ***************************************************************************/ void ZRB_ValidateAndMapSRTrees( @@ -1120,13 +1120,13 @@ void ZRB_ValidateAndMapSRTrees( ZRP_ADSetDescription( rStats, "Validation" ); ZRP_ADSet( rStats, "User Tree", rStats->RS_CurrentLVData ); /*----------------------------------------------------------------------*/ - /* Verify integrity of USR tree, if tree is OK, flip his bits in bitmap - * in preperation for using the existing tree in the rebuild system. - * If the bits don't conflict, then OK to use the the beast and the tree. + /* Verify integrity of USR tree, if tree is OK, flip his bits in bitmap + * in preperation for using the existing tree in the rebuild system. + * If the bits don't conflict, then OK to use the the beast and the tree. * If the bits are x-linked, we throw away the tree and new the beast. */ /*----------------------------------------------------------------------*/ /* Default - OK to use beast and tree */ - RUBTStats->usrTreeFlag = ZRB_SR_OLD; + RUBTStats->usrTreeFlag = ZRB_SR_OLD; if (zVolume->userTree != NULL) { // get a unique GUID for marking "myfield" in UBTTreeWalk (store in RUBTStats buffer) @@ -1134,12 +1134,12 @@ void ZRB_ValidateAndMapSRTrees( if ((cStatus = ZRB_ValidateSRTree(rStats, zVolume, ZRB_USR_FLAG)) == zOK) { - if ((cStatus = ZRB_MapSRTree(rStats, RBTStats, + if ((cStatus = ZRB_MapSRTree(rStats, RBTStats, RUBTStats, RDBTStats, ZRB_USR_FLAG)) != zOK) - { - /* clear tree bits in bitmap that were not conflicts + { + /* clear tree bits in bitmap that were not conflicts * (ie already set) */ - ZRB_FreeSRTree(rStats, RBTStats, RUBTStats, + ZRB_FreeSRTree(rStats, RBTStats, RUBTStats, RDBTStats, ZRB_USR_FLAG); } } @@ -1150,7 +1150,7 @@ void ZRB_ValidateAndMapSRTrees( zVolume->userTree->zfsBtree.p.btRoot = INVALID_BLK; /* turn off usr on the volume because we destroyed the tree */ - zVolume->ZFSVOLenabledAttributes &= + zVolume->ZFSVOLenabledAttributes &= ~zATTR_USER_SPACE_RESTRICTIONS; //g aprintf(LRED,MSG("User space restrictions for volume %U\n" //g "have been lost.\n" @@ -1180,26 +1180,26 @@ void ZRB_ValidateAndMapSRTrees( zVolume->ZFSVOLenabledAttributes &= ~zATTR_USER_SPACE_RESTRICTIONS; } /*----------------------------------------------------------------------*/ - /* Verify integrity of DSR tree, if tree is OK, flip his bits in bitmap - * in preperation for using the existing tree in the rebuild system. - * If the bits don't conflict, then OK to use the the beast and the tree. + /* Verify integrity of DSR tree, if tree is OK, flip his bits in bitmap + * in preperation for using the existing tree in the rebuild system. + * If the bits don't conflict, then OK to use the the beast and the tree. * If the bits are x-linked, we throw away the tree and new the beast. */ /*----------------------------------------------------------------------*/ - + /* Default - OK to use beast and tree */ - RDBTStats->dsrTreeFlag = ZRB_SR_OLD; + RDBTStats->dsrTreeFlag = ZRB_SR_OLD; ZRP_ADRecord( rStats ); ZRP_ADSet( rStats, "Directory Tree", rStats->RS_CurrentLVData ); if (zVolume->dirTree != NULL) { if ((cStatus = ZRB_ValidateSRTree(rStats, zVolume, ZRB_DSR_FLAG)) == zOK) { - if ((cStatus = ZRB_MapSRTree(rStats, RBTStats, RUBTStats, + if ((cStatus = ZRB_MapSRTree(rStats, RBTStats, RUBTStats, RDBTStats, ZRB_DSR_FLAG)) != zOK) - { - /* clear tree bits in bitmap that were not conflicts + { + /* clear tree bits in bitmap that were not conflicts * (ie already set) */ - ZRB_FreeSRTree(rStats, RBTStats, RUBTStats, + ZRB_FreeSRTree(rStats, RBTStats, RUBTStats, RDBTStats, ZRB_DSR_FLAG); } } diff --git a/src/nwnss/zlss/repairUpgrade.c b/src/nwnss/zlss/repairUpgrade.c index 080acce..2e3d003 100644 --- a/src/nwnss/zlss/repairUpgrade.c +++ b/src/nwnss/zlss/repairUpgrade.c @@ -75,9 +75,9 @@ * ***************************************************************************/ STATUS ZUP_CheckForLeftBlockCleanup( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, RepairStats_s *stats, - BOOL *specialBeastsBlkExists) + BOOL *specialBeastsBlkExists) { //g IoMsg_s iomsg; Blknum_t specialBlk; @@ -114,7 +114,7 @@ STATUS ZUP_CheckForLeftBlockCleanup( znodePtr[MAX_LEAF_PTRS - i]]; zid = znode->header.zid; - + if ((zid >= ZFSPOOL_MAX_RESERVED_SUPERBLK_ZID) && (zid < zROOTDIR_ZID) ) { @@ -131,8 +131,8 @@ STATUS ZUP_CheckForLeftBlockCleanup( return zOK; } } - /* The rootdir ZID (0x7f) or zids greater than rootdir zid was not found - * in this buffer. It must be the special system beasts block. + /* The rootdir ZID (0x7f) or zids greater than rootdir zid was not found + * in this buffer. It must be the special system beasts block. */ /* Still Need to check the leftbuffer to make sure it is clean */ @@ -151,17 +151,17 @@ STATUS ZUP_CheckForLeftBlockCleanup( /* I don't write the volume data block here because it will * get written later on */ - pool->ZFSPOOLzfsvol.p.PZV_systemBeastBlkNum = + pool->ZFSPOOLzfsvol.p.PZV_systemBeastBlkNum = pool->ZP_super->SB_Header.hdr.SBH_SystemBeastBlkNum; ZFSVOL_WritePersistentVolumeData(&pool->ZFSPOOLzfsvol); } leftNode = (BeastTreeNode_s *)leftBuffer->pBuf.data; - for (zid = zINVALID_ZID+1; + for (zid = zINVALID_ZID+1; zid < ZFSPOOL_MAX_RESERVED_SUPERBLK_ZID; zid++) { if (zid == ZFSPOOL_LOGFILE_ZID) - { + { /* The ZLOG is in the checkpoint block so skip */ continue; } @@ -169,10 +169,10 @@ STATUS ZUP_CheckForLeftBlockCleanup( * paranoid and make sure it exists in the specialBlk. * I'm checking both nodes because some system beasts are optional. */ - if ((findZnodeByZid(specialNode, zid, &i) != TRUE) && + if ((findZnodeByZid(specialNode, zid, &i) != TRUE) && (findZnodeByZid(leftNode, zid, &i) == TRUE)) { - zASSERT( "Cleaning LeftNode did not find zid in SpecialNode" + zASSERT( "Cleaning LeftNode did not find zid in SpecialNode" == NULL); moveZnode(genMsg, leftNode, specialNode, zid); needToWriteSplBlk = TRUE; @@ -193,7 +193,7 @@ STATUS ZUP_CheckForLeftBlockCleanup( { cacheReleaseToss(leftBuffer); cacheReleaseToss(specialBuffer); - return zFAILURE; + return zFAILURE; } } if (needToWriteLeftBlk) @@ -214,8 +214,8 @@ STATUS ZUP_CheckForLeftBlockCleanup( * ****************************************************************************/ STATUS ZUP_CreateSpecialBeastsBlock( - GeneralMsg_s *genMsg, - RepairStats_s *stats) + GeneralMsg_s *genMsg, + RepairStats_s *stats) { STATUS status; //g IoMsg_s iomsg; @@ -263,7 +263,7 @@ STATUS ZUP_CreateSpecialBeastsBlock( for (zid = zINVALID_ZID+1; zid < ZFSPOOL_MAX_RESERVED_SUPERBLK_ZID; zid++) { if (zid == ZFSPOOL_LOGFILE_ZID) - { + { /* The ZLOG is in the checkpoint block so skip */ continue; } @@ -282,10 +282,10 @@ STATUS ZUP_CreateSpecialBeastsBlock( CACHE_RELEASE(leftBuffer); return zFAILURE; } - if (pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor < + if (pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor < AIPU_LV_MEDIA_MAJOR) { - pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor = + pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor = AIPU_LV_MEDIA_MAJOR; pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor = 0; } @@ -322,8 +322,8 @@ STATUS ZUP_CreateSpecialBeastsBlock( */ STATUS ZUP_CheckToMapSRTrees( - GeneralMsg_s *genMsg, - RepairStats_s *stats) + GeneralMsg_s *genMsg, + RepairStats_s *stats) { // ZfsPool_s *pool = stats->pool; @@ -332,7 +332,7 @@ STATUS ZUP_CheckToMapSRTrees( * information since NDS does not. */ // if ( ((pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor * 0x100L) + -// pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor) >= +// pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor) >= // ((AIPU_LV_MEDIA_MAJOR * 0x100L) + AIPU_LV_STEP_4_DONE) ) // { // zASSERT(pool->ZFSPOOLuserTree == NULL); @@ -364,7 +364,7 @@ STATUS ZUP_CheckToMapSRTrees( STATUS ZUP_CheckAndCreateLV ( GeneralMsg_s *genMsg, RepairStats_s *stats ) -// BOOL *restartRebuild) +// BOOL *restartRebuild) { STATUS status; //g IoMsg_s iomsg; @@ -385,9 +385,9 @@ STATUS ZUP_CheckAndCreateLV ( // *restartRebuild = FALSE; - if ( ( pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor > + if ( ( pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor > AIPU_LV_MEDIA_MAJOR ) || - ( ( pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor == + ( ( pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor == AIPU_LV_MEDIA_MAJOR ) && ( pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor >= AIPU_LV_STEP_2B_DONE ) ) ) @@ -440,9 +440,9 @@ STATUS ZUP_CheckAndCreateLV ( beastTreeBeast->FILEfirstParentZid = zINVALID_ZID; // DQ_RMV(beastTreeBeast, FILEvolLink); - status = ZRB_PackSystemBeastInSpecialBlock( genMsg, - &stats->RepairZfsPoolStats->RBTStats, - (RootBeast_s *)beastTreeBeast, + status = ZRB_PackSystemBeastInSpecialBlock( genMsg, + &stats->RepairZfsPoolStats->RBTStats, + (RootBeast_s *)beastTreeBeast, ZFSPOOL_VOLBSTTREE_ZID, specialNode); BST_free(beastTreeBeast); if (status != zOK) @@ -455,9 +455,9 @@ STATUS ZUP_CheckAndCreateLV ( */ if (stats->RepairZfsPoolStats->rebuildBeast != NULL) { - if (ZRB_PackSystemBeastInSpecialBlock(genMsg, + if (ZRB_PackSystemBeastInSpecialBlock(genMsg, &stats->RepairZfsPoolStats->RBTStats, - (RootBeast_s *)stats->RepairZfsPoolStats->rebuildBeast, + (RootBeast_s *)stats->RepairZfsPoolStats->rebuildBeast, ZFSPOOL_REBUILDFILE_ZID, specialNode) != zOK) { goto releaseBuffersAndErrorReturn; @@ -479,7 +479,7 @@ STATUS ZUP_CheckAndCreateLV ( BST_free(rootDir); goto releaseBuffersAndErrorReturn; } - status = ZRB_PackBeastInBlock(genMsg, &stats->RepairZfsPoolStats->RBTStats, + status = ZRB_PackBeastInBlock(genMsg, &stats->RepairZfsPoolStats->RBTStats, &rootDir->FILEroot, leftNode); /* These are Internal Volume VDB items */ @@ -507,8 +507,8 @@ STATUS ZUP_CheckAndCreateLV ( X_LATCH(&lvDir->FILEbeastLatch); // DQ_RMV(lvDir, FILEvolLink); status = ZFSPOOL_InitNewBeast(genMsg, lvDir, zROOTDIR_ZID + 1, - zROOTDIR_ZID, (zFA_SUBDIRECTORY | zFA_RENAME_INHIBIT | - zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT), + zROOTDIR_ZID, (zFA_SUBDIRECTORY | zFA_RENAME_INHIBIT | + zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT), ZLSSVOL_DIRECTORY_UNICODE); UNX_LATCH(&lvDir->FILEbeastLatch); if (status != zOK) @@ -516,7 +516,7 @@ STATUS ZUP_CheckAndCreateLV ( BST_free(lvDir); goto releaseBuffersAndErrorReturn; } - status = ZRB_PackBeastInBlock(genMsg, &stats->RepairZfsPoolStats->RBTStats, + status = ZRB_PackBeastInBlock(genMsg, &stats->RepairZfsPoolStats->RBTStats, &lvDir->FILEroot, leftNode); BST_free(lvDir); if (status != zOK) @@ -533,7 +533,7 @@ STATUS ZUP_CheckAndCreateLV ( X_LATCH(&locatorBeast->FILEbeastLatch); // DQ_RMV(locatorBeast, FILEvolLink); status = ZFSPOOL_InitNewBeast(genMsg, locatorBeast, zROOTDIR_ZID + 2, - zROOTDIR_ZID + 1, (zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT | + zROOTDIR_ZID + 1, (zFA_RENAME_INHIBIT | zFA_DELETE_INHIBIT | zFA_COPY_INHIBIT), pool->storagepool->poolname); if (status != zOK) { @@ -545,18 +545,18 @@ STATUS ZUP_CheckAndCreateLV ( zvlBeast->ZVL_p.PZVL_state = PZVL_S_CREATED; zvlBeast->ZVLfile.FILEeof = PZVL_S_CREATED; - zvlBeast->ZVL_p.PZVL_volumeID = + zvlBeast->ZVL_p.PZVL_volumeID = pool->ZP_super->SB_Header.hdr.SBH_VolumeID; - zvlBeast->ZVL_p.PZVL_internalID = + zvlBeast->ZVL_p.PZVL_internalID = pool->ZP_super->SB_Header.hdr.SBH_VolumeID; unicpy(zvlBeast->ZVL_p.PZVL_volumeName, pool->storagepool->poolname ); - zvlBeast->ZVL_p.PZVL_loggedVolumeDataBlk = + zvlBeast->ZVL_p.PZVL_loggedVolumeDataBlk = pool->ZP_super->SB_Header.hdr.SBH_LoggedVolumeDataBlk; - zvlBeast->ZVL_p.PZVL_volumeDataBlk = + zvlBeast->ZVL_p.PZVL_volumeDataBlk = pool->ZP_super->SB_Header.hdr.SBH_VolumeDataBlk; - zvlBeast->ZVL_p.PZVL_systemBeastBlkNum = + zvlBeast->ZVL_p.PZVL_systemBeastBlkNum = pool->ZP_super->SB_Header.hdr.SBH_SystemBeastBlkNum; UNX_LATCH(&locatorBeast->FILEbeastLatch); @@ -565,7 +565,7 @@ STATUS ZUP_CheckAndCreateLV ( BST_free(locatorBeast); goto releaseBuffersAndErrorReturn; } - status = ZRB_PackBeastInBlock(genMsg, &stats->RepairZfsPoolStats->RBTStats, + status = ZRB_PackBeastInBlock(genMsg, &stats->RepairZfsPoolStats->RBTStats, &locatorBeast->FILEroot, leftNode); BST_free(locatorBeast); if (status != zOK) @@ -593,7 +593,7 @@ STATUS ZUP_CheckAndCreateLV ( /* SB items */ if ( pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajorCreate == 0 ) { - pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajorCreate = + pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajorCreate = pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor; pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinorCreate = pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor; @@ -616,9 +616,9 @@ STATUS ZUP_CheckAndCreateLV ( * helps DEBUG ASSERT code that checks if a written blocks * internal ID (at offset 16) is correct. */ - pool->ZFSPOOLoldInternalID = + pool->ZFSPOOLoldInternalID = pool->ZP_super->SB_Header.hdr.SBH_OldInternalID; - pool->ZFSPOOLinternalID = + pool->ZFSPOOLinternalID = pool->ZP_super->SB_Header.hdr.SBH_InternalID; /* ZAP the PDB, LPDB, VDB, LVDB. When we restart rebuild it @@ -679,7 +679,7 @@ STATUS ZUP_LogicalVolumeUpgradeCleanup ( BeastTreeNode_s *specialNode; if ( ((pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor * 0x100L) + - pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor) >= + pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor) >= ((AIPU_LV_MEDIA_MAJOR * 0x100L) + AIPU_LV_STEP_4_DONE) ) { /* We are already at 40.06 or greater */ @@ -687,10 +687,10 @@ STATUS ZUP_LogicalVolumeUpgradeCleanup ( } if ( ((pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor * 0x100L) + - pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor) < + pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor) < ((AIPU_LV_MEDIA_MAJOR * 0x100L) + AIPU_LV_STEP_2B_DONE) ) { - /* We are not upgraded to 40.04 yet */ + /* We are not upgraded to 40.04 yet */ /* This code is only valid if we are up to at least 40.04 */ return zFAILURE; } diff --git a/src/nwnss/zlss/repairWidgets.c b/src/nwnss/zlss/repairWidgets.c index 1b90cc1..8f1b73e 100644 --- a/src/nwnss/zlss/repairWidgets.c +++ b/src/nwnss/zlss/repairWidgets.c @@ -170,8 +170,8 @@ void WinIncrementProgressBar(PBAR bar, QUAD count, NINT decimalPlaces) sprintf(strPercent, MSGNot("%s%%"),&strNum); else sprintf(strPercent, MSGNot("%s.%s%s%%"), - &strNum, - strPad+(LB_strlen(strPad)-(decimalPlaces-LB_strlen(strDec))), + &strNum, + strPad+(LB_strlen(strPad)-(decimalPlaces-LB_strlen(strDec))), strDec); // zPutWinCursor(status,bar->bWinHandle, 0, (bar->width - (decimalPlaces+3)) / 2); zPutWinCursor(status,bar->bWinHandle, 0, ((bar->width / 2) - (LB_strlen(strPercent)))); @@ -253,13 +253,13 @@ void WinCreateWarning(HWINDOW WinHandle, NINT row, NINT col, NINT width, BYTE *t zGetCharSem(status,WinHandle, &key, (LONG *)sem); switch(key) { - case ESC_K: + case ESC_K: { - zDeleteWindow(status,localWinHandle); + zDeleteWindow(status,localWinHandle); return; } default: - break; + break; } } zDeleteWindow(status,localWinHandle); @@ -358,22 +358,22 @@ void WinTerminateWarning(HWINDOW WinHandle, NINT row, NINT col, NINT width, NINT zClearWindow(status,localWinHandle); /* NOTE TO TRANSLATORS: Keep messages shorter thatn 70 chars */ zPutWinCursor(status,localWinHandle, 0, 1); - sprintf(DisplayBuffer, MSGNew("Pool objects (volumes) are missing or corrupt, Rebuild will not continue!",0)); + sprintf(DisplayBuffer, MSGNew("Pool objects (volumes) are missing or corrupt, Rebuild will not continue!",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); zPutWinCursor(status,localWinHandle, 1, 1); - sprintf(DisplayBuffer, MSGNew("Please check that all partition segments are visible, disks or SAN are",0)); + sprintf(DisplayBuffer, MSGNew("Please check that all partition segments are visible, disks or SAN are",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); zPutWinCursor(status,localWinHandle, 2, 1); - sprintf(DisplayBuffer, MSGNew("properly functioning and visible to the server and then try rebuild again.",0)); + sprintf(DisplayBuffer, MSGNew("properly functioning and visible to the server and then try rebuild again.",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); zPutWinCursor(status,localWinHandle, 3, 1); - sprintf(DisplayBuffer, MSGNew("If Rebuild continues to generate this warning, data recovery by third",0)); + sprintf(DisplayBuffer, MSGNew("If Rebuild continues to generate this warning, data recovery by third",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); zPutWinCursor(status,localWinHandle, 4, 1); - sprintf(DisplayBuffer, MSGNew("party tools/procedures or by recreating pools and volumes",0)); + sprintf(DisplayBuffer, MSGNew("party tools/procedures or by recreating pools and volumes",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); zPutWinCursor(status,localWinHandle, 5, 1); - sprintf(DisplayBuffer, MSGNew("and then restoring from backup archives will be necessary.",0)); + sprintf(DisplayBuffer, MSGNew("and then restoring from backup archives will be necessary.",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); zPutWinCursor(status,localWinHandle, 6, 5); @@ -386,13 +386,13 @@ void WinTerminateWarning(HWINDOW WinHandle, NINT row, NINT col, NINT width, NINT zGetCharSem(status,WinHandle, &key, (LONG *)sem); switch(key) { - case ESC_K: + case ESC_K: { - zDeleteWindow(status,localWinHandle); + zDeleteWindow(status,localWinHandle); return; } default: - break; + break; } } zDeleteWindow(status,localWinHandle); @@ -423,14 +423,14 @@ BOOL WinTerminateRebuild(HWINDOW WinHandle, NINT row, NINT col, NINT width, unic zPutWinCursor(status,localWinHandle, 0, 1); /* NOTE TO TRANSLATORS: Keep messages shorter thatn 70 chars */ - sprintf(DisplayBuffer, MSGNew("Rebuild has encountered a problem in the volume data structures!",0)); + sprintf(DisplayBuffer, MSGNew("Rebuild has encountered a problem in the volume data structures!",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); if( repairFlags & ZV_REPAIRFLAGS_REBUILD_VOL_LDATA_BLOCKS ) { zPutWinCursor(status,localWinHandle, 1, 1); /* NOTE TO TRANSLATORS: Keep messages shorter thatn 70 chars */ - sprintf(DisplayBuffer, MSGNew("If you continue, an unknown amount of data will be lost",0)); + sprintf(DisplayBuffer, MSGNew("If you continue, an unknown amount of data will be lost",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); } else @@ -443,39 +443,39 @@ BOOL WinTerminateRebuild(HWINDOW WinHandle, NINT row, NINT col, NINT width, unic zPutWinCursor(status,localWinHandle, 1, 1); /* NOTE TO TRANSLATORS: Keep messages shorter than 70 chars */ - sprintf(DisplayBuffer, MSGNew("If you continue, %ld.%ld Megabytes in %ld file(s) will be lost",0), - lostSize, lostSizeDecimalPart, (NINT)lostFiles); + sprintf(DisplayBuffer, MSGNew("If you continue, %ld.%ld Megabytes in %ld file(s) will be lost",0), + lostSize, lostSizeDecimalPart, (NINT)lostFiles); zWinPrintf(status,localWinHandle, DisplayBuffer); } else { zPutWinCursor(status,localWinHandle, 1, 1); /* NOTE TO TRANSLATORS: Keep messages shorter than 70 chars */ - sprintf(DisplayBuffer, MSGNew("If you continue, %ld block(s) in %ld file(s) will be lost",0), - (NINT)lostBlocks, (NINT)lostFiles); + sprintf(DisplayBuffer, MSGNew("If you continue, %ld block(s) in %ld file(s) will be lost",0), + (NINT)lostBlocks, (NINT)lostFiles); zWinPrintf(status,localWinHandle, DisplayBuffer); } } zPutWinCursor(status,localWinHandle, 2, 1); /* NOTE TO TRANSLATORS: Keep messages shorter thatn 70 chars */ - sprintf(DisplayBuffer, MSGNew("on volume %U!",0),lvName); + sprintf(DisplayBuffer, MSGNew("on volume %U!",0),lvName); zWinPrintf(status,localWinHandle, DisplayBuffer); zPutWinCursor(status,localWinHandle, 3, 1); - sprintf(DisplayBuffer, MSGNew("Please check that all partition segments are visible, disks or SAN are",0)); + sprintf(DisplayBuffer, MSGNew("Please check that all partition segments are visible, disks or SAN are",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); zPutWinCursor(status,localWinHandle, 4, 1); - sprintf(DisplayBuffer, MSGNew("properly functioning and visible to the server and then try rebuild again.",0)); + sprintf(DisplayBuffer, MSGNew("properly functioning and visible to the server and then try rebuild again.",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); zPutWinCursor(status,localWinHandle, 5, 1); - sprintf(DisplayBuffer, MSGNew("If Rebuild continues to generate this warning, data recovery by third",0)); + sprintf(DisplayBuffer, MSGNew("If Rebuild continues to generate this warning, data recovery by third",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); zPutWinCursor(status,localWinHandle, 6, 1); - sprintf(DisplayBuffer, MSGNew("party tools/procedures or by recreating pools and volumes",0)); + sprintf(DisplayBuffer, MSGNew("party tools/procedures or by recreating pools and volumes",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); zPutWinCursor(status,localWinHandle, 7, 1); - sprintf(DisplayBuffer, MSGNew("and then restoring from backup archives will be necessary.",0)); + sprintf(DisplayBuffer, MSGNew("and then restoring from backup archives will be necessary.",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); @@ -497,18 +497,18 @@ BOOL WinTerminateRebuild(HWINDOW WinHandle, NINT row, NINT col, NINT width, unic break; } - case 'n': /* continue with rebuild, ask to confirm */ + case 'n': /* continue with rebuild, ask to confirm */ case 'N': { zClearWindow(status,localWinHandle); zPutWinCursor(status,localWinHandle, 0, 2); /* NOTE TO TRANSLATORS: Keep messages shorter thatn 70 chars */ - sprintf(DisplayBuffer, MSGNew("Continuing will result in Data loss on volume %U.",0), - lvName); + sprintf(DisplayBuffer, MSGNew("Continuing will result in Data loss on volume %U.",0), + lvName); zWinPrintf(status,localWinHandle, DisplayBuffer); zPutWinCursor(status,localWinHandle, 1, 2); /* NOTE TO TRANSLATORS: Keep messages shorter thatn 70 chars */ - sprintf(DisplayBuffer, MSGNew("Press 'n' if you are sure you wish to continue.",0)); + sprintf(DisplayBuffer, MSGNew("Press 'n' if you are sure you wish to continue.",0)); zWinPrintf(status,localWinHandle, DisplayBuffer); zPutWinCursor(status,localWinHandle, 8, 3); @@ -528,7 +528,7 @@ BOOL WinTerminateRebuild(HWINDOW WinHandle, NINT row, NINT col, NINT width, unic break; } - case 'n': /* continue with rebuild, (idiots) */ + case 'n': /* continue with rebuild, (idiots) */ case 'N': { conclusion = FALSE; @@ -536,7 +536,7 @@ BOOL WinTerminateRebuild(HWINDOW WinHandle, NINT row, NINT col, NINT width, unic } default: - break; + break; } } @@ -544,7 +544,7 @@ BOOL WinTerminateRebuild(HWINDOW WinHandle, NINT row, NINT col, NINT width, unic } default: - break; + break; } } zDeleteWindow(status,localWinHandle); @@ -553,3 +553,4 @@ BOOL WinTerminateRebuild(HWINDOW WinHandle, NINT row, NINT col, NINT width, unic #endif + diff --git a/src/nwnss/zlss/repairZRP.c b/src/nwnss/zlss/repairZRP.c index dad1c42..2ba50c3 100644 --- a/src/nwnss/zlss/repairZRP.c +++ b/src/nwnss/zlss/repairZRP.c @@ -19,7 +19,7 @@ | |*************************************************************************** | - | NetWare Advance File Service + | NetWare Advance File Service | |--------------------------------------------------------------------------- | @@ -330,7 +330,7 @@ STATUS ZRP_StatusReportXML( VFS_ssprintf(bLen, bAdd, rLen, "\n", uiStatus->ZRPS_UIRemoveRequested ); VFS_ssprintf(bLen, bAdd, rLen, "\n", uiStatus->ZRPS_UIRemoveID ); - VFS_ssprintf(bLen, bAdd, rLen, "/// %s\n", + VFS_ssprintf(bLen, bAdd, rLen, "/// %s\n", "Initial values only - use action zPOOL_RAV_SET_WITH_KEY in zPoolVerify to obtain 'current' values(start)" ); VFS_ssprintf(bLen, bAdd, rLen, "\n", uiStatus->ZPRS_UIPruneWait ); VFS_ssprintf(bLen, bAdd, rLen, "\n", uiStatus->ZRPS_UIPruneSet ); @@ -376,7 +376,7 @@ STATUS ZRP_StatusReportXML( } /* End of ZRP_StatusReportXML() */ -void ZRP_DataDestroy( +void ZRP_DataDestroy( RepairStats_s *rStats, RepairZfsPoolStats_s *zStats ) { @@ -455,7 +455,7 @@ STATUS ZRP_PoolStartup(GeneralMsg_s *genMsg, ZlssPool_s *zlssPool, ZLSSCheckIOPr * is when rebuild creates a new name tree. */ zfsPool->ZFSPOOLrebuildCount += 1; - ZLSSPOOL_WritePersistentPoolData( zlssPool ); // FixFixFix(ZRP,1,.2) - why both + ZLSSPOOL_WritePersistentPoolData( zlssPool ); // FixFixFix(ZRP,1,.2) - why both ZFSVOL_WritePersistentVolumeData( &zfsPool->ZFSPOOLzfsvol ); return zOK; @@ -606,7 +606,7 @@ STATUS ZRP_StatsNew( /* - ZRP_StatusInitial() - + ZRP_StatusInitial() - Warning - We assume that ZRP_PoolStartup has been called successfully. I.E. @@ -750,7 +750,7 @@ ZVP_ERROR ZRP_Error_Return( RepairStats_s *rStats, STATUS status, const char *se //g ForceSetErrnoWithWhere( &rStats->VS_Common.RAVS_GenMsg, status, (char *)setter); ForceSetErrnoWithWhere( &rStats->VS_Common.RAVS_FinalErrno, status, (char *)setter); rStats->VS_Common.RAVS_Caller = caller; - (void)ZRP_printf_Log( rStats, ZRP_LOG_FATAL_TAG("Fatal rebuild error.", caller, status, setter) ); + (void)ZRP_printf_Log( rStats, ZRP_LOG_FATAL_TAG("Fatal rebuild error.", caller, status, setter) ); return status; } /* End of ZRP_Error_Return() */ @@ -758,7 +758,7 @@ ZVP_ERROR ZRP_Error_Return( RepairStats_s *rStats, STATUS status, const char *se /* ZRP_RebuildPool() - Rebuilds a ZLSS pool... - + Returns - Status of the rebuild operation( NOT a status of the pool ). zOK - indicates that rebuild completed successfully. @@ -989,13 +989,13 @@ STATUS ZRB_TerminatePruneRebuildTest( /* - ZRB_TerminatePrunedRebuild() - This routine determines if rebuild should continue based on user input and - if rebuild has 'pruned' any beast trees. - - Warning - - This routine CAN wait for UI input via XML!!!! - + ZRB_TerminatePrunedRebuild() + This routine determines if rebuild should continue based on user input and + if rebuild has 'pruned' any beast trees. + + Warning - + This routine CAN wait for UI input via XML!!!! + */ STATUS ZRB_TerminatePrunedRebuild( GeneralMsg_s *genMsg, RepairStats_s *rStats) { @@ -1188,7 +1188,7 @@ STATUS ZRP_RepairPool( { rStats->RS_CurrentLVData = lvStatsPtr; ZRB_ValidateAndMapSRTrees( genMsg, lvStatsPtr->lvRBTStats.zVolume, rStats, - &lvStatsPtr->lvRBTStats, &lvStatsPtr->lvRUBTStats, + &lvStatsPtr->lvRBTStats, &lvStatsPtr->lvRUBTStats, &lvStatsPtr->lvRDBTStats, lvStatsPtr->ZLD_Name.ZLNI_lvName ); ClearErrno( genMsg ); } /* end DQ_FOREACH */ @@ -1206,7 +1206,7 @@ STATUS ZRP_RepairPool( /************************************************************************ * THIS is the point at which you can start allocating blocks from the - * bitmap (using allocFromBitmap). + * bitmap (using allocFromBitmap). ***********************************************************************/ rStats->okToAllocFromBitMap = TRUE; ZRP_ADRecord( rStats ); @@ -1230,7 +1230,7 @@ STATUS ZRP_RepairPool( } DQ_FOREACH(&rStats->RepairZfsPoolStats->RZPS_RLVStats,lvStatsPtr,ZRP_LVData_s,link) { - if (ZUP_LogicalVolumeUpgradeCleanup(genMsg, rStats, pool, + if (ZUP_LogicalVolumeUpgradeCleanup(genMsg, rStats, pool, &lvStatsPtr->lvRBTStats, lvStatsPtr->zVolume) != zOK) { ccode = ZRP_Error_Return( rStats, GetErrno(genMsg), GetErrnoSetter(genMsg), WHERE ); @@ -1265,7 +1265,7 @@ STATUS ZRP_RepairPool( zASSERT( leftLeaf != INVALID_BLK ); if(rStats->RepairZfsPoolStats->RBTStats.beastTreeBuiltFlag == ZRB_BUILD_BBTREE_PASS1) { - if((ccode = BuildNewBeastTree(pool, leftLeaf, specialLeaf, genMsg, /*rStats->RS_DualBitMap,*/ leafCount, rStats, &rStats->RepairZfsPoolStats->RBTStats)) != zOK) + if((ccode = BuildNewBeastTree(pool, leftLeaf, specialLeaf, genMsg, /*rStats->RS_DualBitMap,*/ leafCount, rStats, &rStats->RepairZfsPoolStats->RBTStats)) != zOK) { //g aprintf(LRED,MSG("Build of new Beast Tree failed. \n",845)); // FixFixFix(ZRPDone,3,2) - Remove all aprintf's ccode = ZRP_Error_Return( rStats, GetErrno(genMsg), GetErrnoSetter(genMsg), WHERE ); @@ -1308,14 +1308,14 @@ DBG_DebugPrintf(LRED, MSGNot("(LV_REBUILD)building new LV beast trees \n")); zASSERT( lvLeftLeaf != INVALID_BLK ); if(lvStatsPtr->lvRBTStats.beastTreeBuiltFlag == ZRB_BUILD_BBTREE_PASS1) { - if((ccode = BuildNewBeastTree(pool, lvLeftLeaf, lvSpecialLeaf, genMsg, /*rStats->RS_DualBitMap,*/ lvStatsPtr->lvRBTStats.leafCount, rStats, &lvStatsPtr->lvRBTStats)) != zOK) + if((ccode = BuildNewBeastTree(pool, lvLeftLeaf, lvSpecialLeaf, genMsg, /*rStats->RS_DualBitMap,*/ lvStatsPtr->lvRBTStats.leafCount, rStats, &lvStatsPtr->lvRBTStats)) != zOK) { //g aprintf(LRED,MSG("Build of new Beast Tree failed (LV). \n",970)); ccode = ZRP_Error_Return( rStats, GetErrno(genMsg), GetErrnoSetter(genMsg), WHERE ); goto BCleanup; } #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("***Built beast tree in pass 1 (LV)\n")); + DBG_DebugPrintf(LRED,MSGNot("***Built beast tree in pass 1 (LV)\n")); #endif } rStats->filesProcessed -= 2; /* we adjust this here to account for the null beasts in the leftmost leaf */ @@ -1374,7 +1374,7 @@ DBG_DebugPrintf(LRED,MSGNot("***************************************\n")); } ZRP_ADRecord( rStats ); ZRP_ADSet( rStats, "Volume Blocks", rStats->RS_CurrentLVData ); - if ( ZRB_BuildVolDataBlocks(genMsg, rStats, &rStats->RepairZfsPoolStats->RBTStats, + if ( ZRB_BuildVolDataBlocks(genMsg, rStats, &rStats->RepairZfsPoolStats->RBTStats, rStats->pool->zfsVol.ZV_RepairFlags ) != zOK ) { ccode = ZRP_Error_Return( rStats, GetErrno(genMsg), GetErrnoSetter(genMsg), WHERE ); @@ -1388,7 +1388,7 @@ DBG_DebugPrintf(LRED,MSGNot("***************************************\n")); rStats->RS_CurrentLVData = lvStatsPtr; ZRP_ADRecord( rStats ); ZRP_ADSet( rStats, "Volume Blocks", rStats->RS_CurrentLVData ); - if ( ZRB_BuildVolDataBlocks(genMsg, rStats, &lvStatsPtr->lvRBTStats, + if ( ZRB_BuildVolDataBlocks(genMsg, rStats, &lvStatsPtr->lvRBTStats, lvStatsPtr->zVolume->ZV_RepairFlags ) != zOK ) { ccode = ZRP_Error_Return( rStats, GetErrno(genMsg), GetErrnoSetter(genMsg), WHERE ); @@ -1448,10 +1448,10 @@ DBG_DebugPrintf(LRED,MSGNot("***************************************\n")); goto BCleanup; } #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("LV_REBUILD)returned from updateFreeTree\n")); + DBG_DebugPrintf(LRED,MSGNot("LV_REBUILD)returned from updateFreeTree\n")); #endif /************************************************************************ - * At this time we have built the free tree, so we should no longer + * At this time we have built the free tree, so we should no longer * call allocFromBitMap to get blocks. Blocks should be allocated * from the free tree ***********************************************************************/ @@ -1503,7 +1503,7 @@ DBG_DebugPrintf(LRED,MSGNot("***************************************\n")); if(rStats->RepairZfsPoolStats->RBTStats.beastTreeBuiltFlag == ZRB_BUILD_BBTREE_PASS2) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("***Building beast tree in SECONDARY pass\n")); + DBG_DebugPrintf(LRED,MSGNot("***Building beast tree in SECONDARY pass\n")); #endif ccode = beastTreeBranchPass(genMsg, pool, rStats, &rStats->RepairZfsPoolStats->RBTStats); if ( ccode != zOK) @@ -1521,7 +1521,7 @@ DBG_DebugPrintf(LRED,MSGNot("***************************************\n")); if(lvStatsPtr->lvRBTStats.beastTreeBuiltFlag == ZRB_BUILD_BBTREE_PASS2) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("***Building beast tree in SECONDARY pass (lv)\n")); + DBG_DebugPrintf(LRED,MSGNot("***Building beast tree in SECONDARY pass (lv)\n")); #endif ccode = beastTreeBranchPass(genMsg, pool, rStats, &lvStatsPtr->lvRBTStats); if ( ccode != zOK ) @@ -1604,14 +1604,14 @@ DBG_DebugPrintf(LRED,MSGNot("***************************************\n")); ZRP_ADRecord( rStats ); ZRP_ADSetDescription( rStats, "Upgrade" ); ZRP_ADSet( rStats, "User Tree", rStats->RS_CurrentLVData ); - if ((pool->ZFSPOOLuserTree != NULL) && + if ((pool->ZFSPOOLuserTree != NULL) && (pool->ZFSPOOLuserTree->ZFSUSERTREEzid == ZFSPOOL_VOLUSERTREE_ZID)) { /* A user tree will exist on the pool's internal volume only if the * the media format is pre 6 pack. We need to upgrade this tree * to 6 pack format. We check if the tree has not been upgraded */ - if (ZFSPOOL_upgradeUserTree(genMsg, &pool->ZFSPOOLzfsvol, + if (ZFSPOOL_upgradeUserTree(genMsg, &pool->ZFSPOOLzfsvol, pool->ZFSPOOLuserTree) != zOK) { zASSERT("Error Upgrading User Tree to 6 pack format" == NULL); @@ -1624,13 +1624,13 @@ DBG_DebugPrintf(LRED,MSGNot("***************************************\n")); ZRP_ADRecord( rStats ); ZRP_ADSet( rStats, "User Tree", rStats->RS_CurrentLVData ); if ((lvStatsPtr->zVolume->userTree != NULL) && - (lvStatsPtr->zVolume->userTree->ZFSUSERTREEzid == + (lvStatsPtr->zVolume->userTree->ZFSUSERTREEzid == ZFSPOOL_VOLUSERTREE_ZID)) { /* A user tree in the old format may exist on the logical volume * if we are upgrading */ - if (ZFSPOOL_upgradeUserTree(genMsg, lvStatsPtr->zVolume, + if (ZFSPOOL_upgradeUserTree(genMsg, lvStatsPtr->zVolume, lvStatsPtr->zVolume->userTree) != zOK) { zASSERT("Error Upgrading User Tree to 6 pack format" == NULL); @@ -1736,7 +1736,7 @@ DBG_DebugPrintf(LRED,MSGNot(" IV_REBUILD)returned OK from ReBuildNameTree\n")) ZRP_ADRecord( rStats ); ZRP_ADSet( rStats, "Name Tree", rStats->RS_CurrentLVData ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("***Building LV name tree\n")); + DBG_DebugPrintf(LRED,MSGNot("***Building LV name tree\n")); #endif beastRootBlockNum = lvStatsPtr->zVolume->beastTree->zfsBtree.p.btRoot; ccode = ZRB_ReBuildNameTree(genMsg, rStats, &lvStatsPtr->lvRBTStats, lvStatsPtr->zVolume->beastTree); @@ -1746,12 +1746,12 @@ DBG_DebugPrintf(LRED,MSGNot(" IV_REBUILD)returned OK from ReBuildNameTree\n")) goto BCleanup; } #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("*** Built LV name tree OK\n")); + DBG_DebugPrintf(LRED,MSGNot("*** Built LV name tree OK\n")); #endif /* write the leaf containing the name tree beast out to disk */ ccode = ZRB_WriteNameTreeBeastToDisk(genMsg, rStats, &lvStatsPtr->lvRBTStats, &lvStatsPtr->lvRVDBStats, lvStatsPtr->zVolume->nameTree); if ( ccode != zOK) - { + { ccode = ZRP_Error_Return( rStats, GetErrno(genMsg), GetErrnoSetter(genMsg), WHERE ); goto BCleanup; } @@ -1827,7 +1827,7 @@ DBG_DebugPrintf(LRED,MSGNot(" IV_REBUILD)returned OK from ReBuildNameTree\n")) * the location of the ZVL Beast in the beast tree. Hence we will * do it now. */ - zvlBeast = BEASTHASH_LookupByZid(genMsg, &pool->ZFSPOOLvol, + zvlBeast = BEASTHASH_LookupByZid(genMsg, &pool->ZFSPOOLvol, lvStatsPtr->lvVolZid, XLATCHED); if (zvlBeast == NULL) { @@ -1835,9 +1835,9 @@ DBG_DebugPrintf(LRED,MSGNot(" IV_REBUILD)returned OK from ReBuildNameTree\n")) goto BCleanup; } - zvlBeast->ZVL_p.PZVL_loggedVolumeDataBlk = + zvlBeast->ZVL_p.PZVL_loggedVolumeDataBlk = lvStatsPtr->lvRBTStats.loggedVolumeDataBlk; - zvlBeast->ZVL_p.PZVL_volumeDataBlk = + zvlBeast->ZVL_p.PZVL_volumeDataBlk = lvStatsPtr->lvRBTStats.volumeDataBlk; COMN_MARK_BEAST_DIRTY(&zvlBeast->ZVL_file.FILEroot); @@ -1938,7 +1938,7 @@ STATUS ZRP_AllocFromBitMap( RepairStats_s *stats, RBTStats_s *RBTStats, Blknum_t /* -------------------------------------------------------------------------- * ZRP_CopyXlinkedBitMapToMemoryBitMap * - * copy xlinked bit map (zlog area) to the memory bit map prior to + * copy xlinked bit map (zlog area) to the memory bit map prior to * building the name tree. This is so loging can use the log file and * not clobber the xlinked bitmap. * -------------------------------------------------------------------------- */ @@ -2285,7 +2285,7 @@ BOOL ZRP_UnloadRequested( RepairStats_s *rStats ) We will use the XLATCH code that will not block if we can not get an X Latch. If someone owns the cvsLatch and our callback event is waiting for us to cleanup, we can proceed because repair/verify traps the POOL change state event. We do not grab - the latch all the time beacuse we can be called when our Pool state event code tells + the latch all the time beacuse we can be called when our Pool state event code tells rebuild/verify to stop doing work. */ void ZRP_UnloadLVs( @@ -2306,7 +2306,7 @@ void ZRP_UnloadLVs( { RAV_delay(100); X_NOWAIT( &zlssPool->ZLSSPOOLpool.cvsLatch, waitFlag ); - } + } DQ_DEQ(&zlssPool->ZP_Pool.P_VolumeList,volume,Volume_s,v_poolVolLink); if (volume == NULL) { @@ -2487,8 +2487,8 @@ STATIC void ZRP_MessageRecordRecord( RepairStats_s *rStats, const char *legalXML Notes - This is the replacement for the pre Linux routine repairlog_WriteRealRepairLogFileToVolume. - Places text into the RebuildLog.XML file. The 'legalXML' must be legal XML. E.G. - This can be multiple, single tags or a comment ("///"). + Places text into the RebuildLog.XML file. The 'legalXML' must be legal XML. E.G. + This can be multiple, single tags or a comment ("///"). */ // --- ZSS_TYPE_MESSAGE_RECORD_R STATIC void ZRP_MessageRecordReport( RepairStats_s *rStats, const char *legalXML ) @@ -3027,7 +3027,7 @@ STATUS ZRP_printf_Debug( // --- ZSS_TYPE_DEBUG_RECORD_R -STATIC void ZRP_DebugRecordRecord( +STATIC void ZRP_DebugRecordRecord( RepairStats_s *rStats, const char *where, QUAD debugLevel, @@ -3082,3 +3082,4 @@ void ZRP_DebugRecordReport( return; } /* End of ZRP_DebugRecordReport() */ + diff --git a/src/nwnss/zlss/repairZRP.h b/src/nwnss/zlss/repairZRP.h index 09b79a5..263af05 100644 --- a/src/nwnss/zlss/repairZRP.h +++ b/src/nwnss/zlss/repairZRP.h @@ -126,18 +126,18 @@ typedef struct LeafInfo_s typedef struct LeafInfoOnDisk_s { - Blknum_t headBlockNum; + Blknum_t headBlockNum; LeafInfo_s *headBufferStart; LeafInfo_s *headBufferRemove; LeafInfo_s *headBufferEnd; Buffer_s *headBuffer; - Blknum_t tailBlockNum; + Blknum_t tailBlockNum; LeafInfo_s *tailBufferStart; LeafInfo_s *tailBufferInsert; LeafInfo_s *tailBufferEnd; Buffer_s *tailBuffer; - + } LeafInfoOnDisk_s; @@ -199,7 +199,7 @@ typedef struct RBTStats_s /* Volume BT stats */ NINT queSlotsTaken; LeafInfoOnDisk_s onDiskList; NINT leafInfoCount; - NINT leafInfoStoredToDisk; // if true, we're out of memory and have to go to disk for leaf link info + NINT leafInfoStoredToDisk; // if true, we're out of memory and have to go to disk for leaf link info Zid_t reZidCurrentZid; // Used by rezid to keep track of the next consecutive zid Zid_t rebuildDirNameZid; // zid of the parent directory for orphans "UTCTimeString.FPD" @@ -397,7 +397,7 @@ typedef struct ZRP_DynamicStats_s * for a given pool that are not stats. I.E. this is the place to put things * that any UI would have no need to see!!!! This structure hangs off the * thread while it runs and then off the saved data once the thread goes away. - * + * * All pool stats are stored in the ZVP_PoolStats_s that we point to. All LV stats * are stored in the ZVP_LVStats_s which we point to via the VS_LVData DQ head. */ @@ -415,7 +415,7 @@ typedef struct RepairStats_s LONG rebuildCount; // rebuild count from zlog blocks NINT phase; // files, names, or done -// NINT *RS_bitMap; +// NINT *RS_bitMap; BlockMap_s RS_FMAPBitMap; // Bitmap of ALL FMAP blocks on given volume - Legal to be a NULL ptr. BlockMap_s RS_DualBitMap; // DO NOT USE DIRECTLY - use via RS_InUseBlockBM or RS_CrossLinkedBlockBM @@ -542,12 +542,13 @@ STATUS ZRB_CreateDot1Dir( RBTStats_s *RBTStats, Volume_s *volume); NamedBeast_s *ZRB_GetDestinationDirectory( - GeneralMsg_s *genMsg, - NamedBeast_s *beast, - ParentEntry_s *parentE, - RepairStats_s *stats, + GeneralMsg_s *genMsg, + NamedBeast_s *beast, + ParentEntry_s *parentE, + RepairStats_s *stats, RBTStats_s *RBTStats, struct ZfsXaction_s *xaction, BOOL *allDone); #endif // #ifndef _REPAIRZRP_H_ + diff --git a/src/nwnss/zlss/repairZVP.c b/src/nwnss/zlss/repairZVP.c index 39300d7..ca805b0 100644 --- a/src/nwnss/zlss/repairZVP.c +++ b/src/nwnss/zlss/repairZVP.c @@ -19,7 +19,7 @@ | |*************************************************************************** | - | NetWare Advance File Service + | NetWare Advance File Service | |--------------------------------------------------------------------------- | @@ -225,7 +225,7 @@ ZVP_ERROR ZVP_MapTestExtent(VerifyStats_s *vStats, Extent_s *extent, NINT flag) /* for each block in the extent entry, test for conflicts, then set bit */ for(blkcnt = 0; blkcnt < extent->lengthOfExtent; blkcnt++) { - switch(vStats->action) + switch(vStats->action) { case BMP_TST_EXTENT: ZVP_mapTestSetBit(vStats, extent->poolBlkNum+blkcnt, vStats->VS_ivVolZid); @@ -388,7 +388,7 @@ void ZVP_VolumeShutdownAll( Cleans up the resources allocated by ZVP_StatsNew */ -void ZVP_DataDestroy( +void ZVP_DataDestroy( // ZLSSCheckIOProcess_s *pData, VerifyStats_s *vStats, ZVP_PoolStats_s *zStats ) @@ -564,7 +564,7 @@ void ZVP_DeterminePoolCondition( + zStats->ZLOGStats.ZLOGS_cBS.CBS_BlockCountPass1 // Journal + zStats->RFStats.RFS_cBS.CBS_BlockCountPass1 // Rebuild file + zStats->SBStats.SBS_cBS.CBS_BlockCountPass1 // Super blocks - + zStats->VDBStats.VDBS_cBS.CBS_BlockCountPass1 // LVDB and VDB + + zStats->VDBStats.VDBS_cBS.CBS_BlockCountPass1 // LVDB and VDB + zStats->PDBStats.PDBS_cBS.CBS_BlockCountPass1 // LPDB and PDB + zStats->STStats.STS_cBS.CBS_BlockCountPass1; // PT tree blockTotal = usedBlocksIV + zStats->FTStats.FTS_cBSFree.CBS_BlockCountPass1; @@ -581,13 +581,13 @@ void ZVP_DeterminePoolCondition( lv = &lvData->ZLD_stats; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot - ("LVObjects = %ld, LVFiles = %ld, BTDirs = %ld, BTFiles = %ld, BeastFileCount = %d\n"), - lv->lvVDBStats.dataNumObjects, - lv->lvVDBStats.dataNumFiles, - lv->lvBTStats.numDirCount, - lv->lvBTStats.numFileCount, - lv->lvBTStats.numBeastFileCount); + DBG_DebugPrintf(LRED,MSGNot + ("LVObjects = %ld, LVFiles = %ld, BTDirs = %ld, BTFiles = %ld, BeastFileCount = %d\n"), + lv->lvVDBStats.dataNumObjects, + lv->lvVDBStats.dataNumFiles, + lv->lvBTStats.numDirCount, + lv->lvBTStats.numFileCount, + lv->lvBTStats.numBeastFileCount); #endif lvSalvagableBlocks_OptValid = lv->lvBTStats.numSalvagableBlocks_OptValid; lvSalvagableObjects_OptValid = lv->lvBTStats.numSalvagableObjects_OptValid; @@ -607,7 +607,7 @@ void ZVP_DeterminePoolCondition( if ( zStats->ZPS_Option_CrossValidateNT && zStats->ZPS_Option_CrossValidateBT ) { if ( (lv->lvBTStats.numNTEntsFromBT_OptValid != lv->lvNTStats.NTS_cBS.CBS_LevelLeaf.LI_ObjectCount + lv->lvNTStats.numNTObjectDups) || - (lv->lvBTStats.numNTEntsFromBT_OptValid != lv->lvNTStats.numNameFileCount_OptValid + lv->lvNTStats.numNameDirCount_OptValid) ) + (lv->lvBTStats.numNTEntsFromBT_OptValid != lv->lvNTStats.numNameFileCount_OptValid + lv->lvNTStats.numNameDirCount_OptValid) ) { errFlag |= ZVP_ERROR_00000002; /* Name Tree Entries != Named Objects */ lv->LVErrFlag |= ZVP_ERROR_00000002; @@ -731,7 +731,7 @@ void ZVP_DeterminePoolCondition( if (vStats->zfsPoolStats->ZPS_uiStatus.ZVPS_BlocksUnaccounted != 0) { warnFlag |= ZVP_WARNING_00000002; /* Unaccounted Blocks Exist */ - } + } if (zStats->STStats.STS_cBS.CBS_InvalidBlock != 0) // Was STStats.numSTBadNodes { warnFlag |= ZVP_WARNING_00000020; /* Salvage Tree Node(s) Contain Corruption */ @@ -786,7 +786,7 @@ void ZVP_DeterminePoolCondition( /* - ZVP_StatusInitial() - + ZVP_StatusInitial() - Warning - We assume that ZVP_PoolStartup has been called successfully. I.E. @@ -859,7 +859,7 @@ void ZVP_StatusFinal( RAV_CopyRightSideOfWhere( uiStatus->ZVPS_VerifySetter, WHERE, sizeof(uiStatus->ZVPS_VerifySetter) ); if ( pc->ZPC_poolConditionValid ) { - if ( pc->ZPC_errFlag != 0 ) + if ( pc->ZPC_errFlag != 0 ) { ZVP_ADSetDescription( vStats, "Error report" ); uiStatus->ZVPS_PoolCondition = ZVP_STATUS_ERRORS; @@ -916,7 +916,7 @@ void ZVP_checkBlockForConflicts(VerifyStats_s *vStats, Blknum_t blockNum, Zid_t { NINT i; -//g if ((vStats->countedBlocks) % vStats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar->incThreshold == 0) +//g if ((vStats->countedBlocks) % vStats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar->incThreshold == 0) //g WinIncrementProgressBar(vStats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar, vStats->countedBlocks, vStats->VS_Common.RAVS_ZCProcessPtr->ZCIOP_bar->decimalPlaces); zASSERT( vStats->action == FIND_BLOCK ); zASSERT( vStats->VS_cBS != NULL ); @@ -1016,7 +1016,7 @@ void ZVP_mapTestSetBit( zASSERT( vStats->action == BMP_TST_EXTENT ); zASSERT( vStats->VS_cBS != NULL ); -//g if ((vStats->countedBlocks) % vStats->VS_Common.RAVS_ZCProcessPtr->bar->incThreshold == 0) +//g if ((vStats->countedBlocks) % vStats->VS_Common.RAVS_ZCProcessPtr->bar->incThreshold == 0) //g WinIncrementProgressBar(vStats->VS_Common.RAVS_ZCProcessPtr->bar, vStats->countedBlocks, vStats->VS_Common.RAVS_ZCProcessPtr->bar->decimalPlaces); PERIODIC_YIELD(); @@ -1152,7 +1152,7 @@ FreeMemory: } for(k = 0; k < 16; k++) { /* flip the bits in the bitmap for the superblock blocks */ - switch(vStats->action) + switch(vStats->action) { case BMP_TST_EXTENT: ZVP_mapTestSetBit(vStats, MSBHeader->hdr.superlocation[i]+k, vStats->VS_ivVolZid); @@ -1168,7 +1168,7 @@ FreeMemory2: /**********/ free(MSBHeader); free(destMediaCheckpoint); - return (status); + return (status); } /* End of ZVP_MapTestSuperBlk() */ @@ -1181,12 +1181,10 @@ FreeMemory2: * XLink pass. It is set to BMP_TST_EXTENT to indicate the 1st pass. * * For Volumes the routine ZVP_LVVerify has which routines to call hard coded. In addition, - * ZVP_verifyLogicalVolume has the first routine to call hard coded. The Beast Tree's visitNode + * ZVP_verifyLogicalVolume has the first routine to call hard coded. The Beast Tree's visitNode * code will verify a volume when ever it finds a zFTYPE_ZLSS_VOLUME_LOCATOR beast. * */ -typedef ZVP_ERROR (*ZVP_VerifyRoutine_t)(VerifyStats_s *vStats); - typedef struct ZVP_VerifyRoutines_s { ADDR ZVR_Routine; @@ -1244,7 +1242,7 @@ ZVP_ERROR ZVP_Error_Return( VerifyStats_s *vStats, STATUS status, const char *se // ForceSetErrnoWithWhere( &vStats->VS_Common.RAVS_GenMsg, status, (char *)setter); ForceSetErrnoWithWhere( &vStats->VS_Common.RAVS_FinalErrno, status, (char *)setter); vStats->VS_Common.RAVS_Caller = caller; - (void)ZVP_printf_Log( vStats, ZRP_LOG_FATAL_TAG("Fatal rebuild error.", caller, status, setter) ); // fixfixfix(zvpDone,2,1) - need ZVP version + (void)ZVP_printf_Log( vStats, ZRP_LOG_FATAL_TAG("Fatal rebuild error.", caller, status, setter) ); // fixfixfix(zvpDone,2,1) - need ZVP version return status; } @@ -1317,7 +1315,7 @@ ZVP_ERROR ZVP_MapTestPoolDataBlk( VerifyStats_s *vStats, Zid_t volZid ) { /* FixFixFix6 - Verify GUID */ vStats->zfsPoolStats->PDBStats.dataTotalBlocks = loggedPoolNode->ZLPB_pool.LPP_totalBlocks; - vStats->zfsPoolStats->PDBStats.dataInUseBlocks = loggedPoolNode->ZLPB_pool.LPP_inUseBlocks; + vStats->zfsPoolStats->PDBStats.dataInUseBlocks = loggedPoolNode->ZLPB_pool.LPP_inUseBlocks; vStats->zfsPoolStats->PDBStats.dataNumPurgeableBlocks = loggedPoolNode->ZLPB_pool.LPP_purgeableBlocks; vStats->zfsPoolStats->PDBStats.dataNumNonPurgeableBlocks = loggedPoolNode->ZLPB_pool.LPP_nonPurgeableBlocks; CACHE_RELEASE(buffer); @@ -1482,7 +1480,7 @@ ZVP_ERROR ZVP_MapTestVolumeBlk(VerifyStats_s *vStats, VDBStats_s *VDBStats, Zid_ DBG_DebugPrintf(LRED,MSGNot(" --Purgable blocks %ld\n"),vStats->VS_zVolume->ZFSVOLpurgeableBlocks); #endif VDBStats->dataInUseBlocks = loggedDataNode->ZLVD_volume.inUseBlocks; - VDBStats->dataNumFiles = loggedDataNode->ZLVD_volume.numFiles; + VDBStats->dataNumFiles = loggedDataNode->ZLVD_volume.numFiles; VDBStats->dataNumObjects = loggedDataNode->ZLVD_volume.numObjects; VDBStats->dataNumPurgeableBlocks = loggedDataNode->ZLVD_volume.purgeableBlocks; VDBStats->dataNumNonPurgeableBlocks = loggedDataNode->ZLVD_volume.nonPurgeableBlocks; @@ -1533,10 +1531,10 @@ ZVP_ERROR ZVP_MapTestVolumeBlk(VerifyStats_s *vStats, VDBStats_s *VDBStats, Zid_ | | (verify) +-------------------------------------------------------------------------*/ -ZVP_ERROR ZVP_MapTestFileMap(VerifyStats_s *vStats, - BTStats_s *BTStats, - Fmap_s *fMap, - Blknum_t numNextBlk, +ZVP_ERROR ZVP_MapTestFileMap(VerifyStats_s *vStats, + BTStats_s *BTStats, + Fmap_s *fMap, + Blknum_t numNextBlk, Zid_t volZid) { NINT i,k; @@ -1559,7 +1557,7 @@ ZVP_ERROR ZVP_MapTestFileMap(VerifyStats_s *vStats, { cntNextBlk = fMap->dirExt[i-1].count; } - eFlag = 1; + eFlag = 1; break; } count = fMap->dirExt[i].count - fMap->dirExt[i-1].count; @@ -1596,19 +1594,19 @@ ZVP_ERROR ZVP_MapTestFileMap(VerifyStats_s *vStats, { // (void)ZVP_printf_Debug( vStats, WHERE, ZRP_DEBUG_LOG_GENERAL_INFO, RAV_DEBUG_TAG("Object 0x%Lx should have 0x%lx blocks, but there are only 0x%lx blocks"), vStats->VS_zid, numNextBlk, cntNextBlk ); (void)ZVP_printf_Log( vStats, ZRP_LOG_INFO_TAG("Object 0x%Lx should have 0x%lx blocks, but there are only 0x%lx blocks"), vStats->VS_zid, numNextBlk, cntNextBlk ); - BTStats->truncatedFmapBlocks += (numNextBlk - cntNextBlk); + BTStats->truncatedFmapBlocks += (numNextBlk - cntNextBlk); BTStats->truncatedFileCount++; CBS_LevelUp( vStats->VS_cBS ); return (zOK); } if(fMap->root != 0) { - ccode = ZVP_FMTreeWalk(vStats, BTStats, fMap->root, &cntNextBlk, volZid); + ccode = ZVP_FMTreeWalk(vStats, BTStats, fMap->root, &cntNextBlk, volZid); if(numNextBlk != cntNextBlk) { // (void)ZVP_printf_Debug( vStats, WHERE, ZRP_DEBUG_LOG_GENERAL_INFO, RAV_DEBUG_TAG("Object 0x%Lx should have 0x%lx blocks, but there are only 0x%lx blocks"), vStats->VS_zid, numNextBlk, cntNextBlk ); (void)ZVP_printf_Log( vStats, ZRP_LOG_INFO_TAG("Object 0x%Lx should have 0x%lx blocks, but there are only 0x%lx blocks"), vStats->VS_zid, numNextBlk, cntNextBlk ); - BTStats->truncatedFmapBlocks += (numNextBlk - cntNextBlk); + BTStats->truncatedFmapBlocks += (numNextBlk - cntNextBlk); BTStats->truncatedFileCount++; } CBS_LevelUp( vStats->VS_cBS ); @@ -1787,7 +1785,7 @@ TODO - inline as vStats now allocated vStats->VS_cBS = NULL; // Help catch if we forget to set. ZVP_ADSet( vStats, ZVP_VerifyRoutines[i].ZVR_ActionDescription, NULL ); - ccode = ((ZVP_VerifyRoutine_t)ZVP_VerifyRoutines[i].ZVR_Routine)(vStats); + ccode = ((LONG (*)())ZVP_VerifyRoutines[i].ZVR_Routine)(vStats); ZVP_ADRecord( vStats ); if (ccode != zOK) { @@ -1820,7 +1818,7 @@ TODO - inline as vStats now allocated { vStats->VS_cBS = NULL; // Help catch if we forget to set. ZVP_ADSet( vStats, ZVP_VerifyRoutines[i].ZVR_ActionDescription, NULL ); - ccode = ((ZVP_VerifyRoutine_t)ZVP_VerifyRoutines[i].ZVR_Routine)(vStats); + ccode = ((LONG (*)())ZVP_VerifyRoutines[i].ZVR_Routine)(vStats); ZVP_ADRecord( vStats ); if (ccode != zOK) { @@ -1850,7 +1848,7 @@ MapExit: /* ZVP_VerifyPool() - Determines if a pool is corrupt... - + Returns - Status of the verify operation( NOT a status of the pool ). zOK - indicates that verify completed successfully (Stats indicate if pool is corrupt or not). @@ -1942,7 +1940,7 @@ Cleanup: link list of volumes. We need to unload them so that they LV memory objects can be freed when their usecounts gets to 0. - Warnings - + Warnings - This code requires that our NEB handler is preventing pool state changes. */ @@ -1966,11 +1964,11 @@ void ZVP_PoolUnloadLVs( ZlssPool_s *zlssPool, ZLSSCheckIOProcess_s *ZCProcessPtr { LB_delay(100); X_NOWAIT( &zlssPool->ZLSSPOOLpool.cvsLatch, waitFlag ); - } + } status = ZLSSVOL_LV_UnloadAll( &dummyGenMsg, zlssPool ); if ( status != zOK ) { - (void)printfOS( KERN_ALERT "%s Unable to unload all LVs (%d@%s)", + (void)printfOS( KERN_ALERT "%s Unable to unload all LVs (%d@%s)", WHERE, GetErrno( &dummyGenMsg ), GetErrnoSetter( &dummyGenMsg ) ); ClearErrno( &dummyGenMsg ); } @@ -2028,7 +2026,7 @@ void ZVP_PoolShutdown( ZlssPool_s *zlssPool, ZLSSCheckIOProcess_s *ZCProcessPtr else STATUS code and any pool is placed back into the normal MAINTENANCE state. I.E. system beasts not loaded and etc. A call to ZVP_PoolShutdown must NOT be done. - + Notes - Performs all the steps needed to activate the ZlssPool_s without actually marking the pool as active. Specifically, the following @@ -2055,7 +2053,7 @@ void ZVP_PoolShutdown( ZlssPool_s *zlssPool, ZLSSCheckIOProcess_s *ZCProcessPtr us problems. For example, ABENDING the server. Also we a bug prone in the since that we must keep in sync with any changes as to how Change Volume state works. - + */ STATUS ZVP_PoolStartup(GeneralMsg_s *genMsg, ZlssPool_s *zlssPool, ZLSSCheckIOProcess_s *ZCProcessPtr) { @@ -2066,7 +2064,7 @@ STATUS ZVP_PoolStartup(GeneralMsg_s *genMsg, ZlssPool_s *zlssPool, ZLSSCheckIOPr /* COMN only set status for Pool_s we must do our ZfsPool_s */ VP_MarkAsChecking( &zfsPool->ZFSPOOLvol ); /* The core change state code must be serialized */ - X_LATCH( &zfsPool->ZFSPOOLvol.stateLatch ); + X_LATCH( &zfsPool->ZFSPOOLvol.stateLatch ); status = ZFSPOOL_LoadPersistentPool( genMsg, zfsPool, 0, 0, FALSE, 0 ); if ( status != zOK ) { /* ZFSPOOL_LoadPersistentPool cleans up after itself so no @@ -2097,7 +2095,7 @@ STATUS ZVP_PoolStartup(GeneralMsg_s *genMsg, ZlssPool_s *zlssPool, ZLSSCheckIOPr zfsPool->ZFSPOOLzfsvol.ZFSVOLvolumePurgeLog, 0); if ( status == zOK ) { - UNX_LATCH( &zfsPool->ZFSPOOLvol.stateLatch ); + UNX_LATCH( &zfsPool->ZFSPOOLvol.stateLatch ); /* Mark that we are doing a verify */ zfsPool->ZFSPOOLvol.p.stateAttributes |= VOLSTATEATTR_CHECKING; ZFSVOL_WritePersistentVolumeData( &zfsPool->ZFSPOOLzfsvol ); @@ -2130,7 +2128,7 @@ STATUS ZVP_PoolStartup(GeneralMsg_s *genMsg, ZlssPool_s *zlssPool, ZLSSCheckIOPr haveLoadedPool: (void)ZFSPOOL_UnloadPersistentPool( zfsPool, 0 ); haveLatch: - UNX_LATCH( &zfsPool->ZFSPOOLvol.stateLatch ); + UNX_LATCH( &zfsPool->ZFSPOOLvol.stateLatch ); VP_ClearChecking( &zfsPool->ZFSPOOLvol ); // Error exit - must clean up as ZVP_PoolShutdown will not be called return zFAILURE; @@ -2179,7 +2177,7 @@ void ZVP_StatsSaveAndDestroy( void CBS_Destruct( CommonBlockStats_s *cBS ) { - + if ( cBS->CBS_Variable != NULL ) { free( cBS->CBS_Variable ); @@ -2363,7 +2361,7 @@ void CBS_LevelTop( CommonBlockStats_s *cBS ) } /* - + */ void CBS_LevelUp( CommonBlockStats_s *cBS ) { @@ -2961,7 +2959,7 @@ STATUS VIRT_CheckResultSize2( NINT *bLen, BYTE **bAdd, NINT *rLen ) /* This indicates how much of buffer is already filled in. - * We must update as we fill things in. */ + * We must update as we fill things in. */ { NINT newSize; BYTE *temp; @@ -3773,8 +3771,8 @@ STATIC void ZVP_MessageRecordRecord( VerifyStats_s *vStats, const char *legalXML Notes - This is the replacement for the pre Linux routine repairlog_WriteRealRepairLogFileToVolume. - Places text into the RebuildLog.XML file. The 'legalXML' must be legal XML. E.G. - This can be multiple, single tags or a comment ("///"). + Places text into the RebuildLog.XML file. The 'legalXML' must be legal XML. E.G. + This can be multiple, single tags or a comment ("///"). */ // --- ZSS_TYPE_MESSAGE_RECORD STATIC void ZVP_MessageRecordReport( VerifyStats_s *vStats, const char *legalXML ) @@ -3961,7 +3959,7 @@ STATUS ZVP_printf_Debug( // --- ZSS_TYPE_DEBUG_RECORD -STATIC void ZVP_DebugRecordRecord( +STATIC void ZVP_DebugRecordRecord( VerifyStats_s *vStats, const char *where, QUAD debugLevel, @@ -4016,3 +4014,5 @@ void ZVP_DebugRecordReport( return; } /* End of ZVP_DebugRecordReport() */ + + diff --git a/src/nwnss/zlss/repairZVP.h b/src/nwnss/zlss/repairZVP.h index 5d6a3b1..14ae0d1 100644 --- a/src/nwnss/zlss/repairZVP.h +++ b/src/nwnss/zlss/repairZVP.h @@ -138,8 +138,8 @@ typedef struct ZVP_LVData_s ZVP_LVStats_s ZLD_stats; DQhead_t ZLD_Head; // Head of ALL dynamic stats within this LV object. // Used so certain routines can operate on all of - // the RAV_GrowingStats_s without knowing all of their - // names. + // the RAV_GrowingStats_s without knowing all of their + // names. DQlink_t link; // pointer to next logical volume BOOL lvQuasiActivated; // Purge Tree is the only setter. ZfsVolume_s *lvZVolume; // Purge Tree uses to have a quick @@ -225,7 +225,7 @@ typedef struct NTDynamicStats_s /* This is the verify structure used to orginize all global data * for a given pool that are not stats. I.E. this is the place to put things * that any UI would have no need to see!!!! - * + * * All pool stats are stored in the ZVP_PoolStats_s that we point to. All LV stats * are stored in the ZVP_LVStats_s which we point to via the VS_LVData DQ head. */ @@ -287,7 +287,7 @@ typedef struct VerifyStats_s /* Global stats buffer */ ZVP_ERROR ZVP_MapTestPurgeLogVolume(VerifyStats_s *vStats, PLStats_s *plStats, Blknum_t purgeFirstBlk, Zid_t volZid); ZVP_ERROR ZVP_MapTestExtent(VerifyStats_s *vStats, struct Extent_s *extent, NINT flag); -ZVP_ERROR ZVP_LVVerify(VerifyStats_s *vStats, ZVP_LVData_s *lvData, LVRootBlocks_s *rootBlocks); +ZVP_ERROR ZVP_LVVerify(VerifyStats_s *vStats, ZVP_LVData_s *lvData, LVRootBlocks_s *rootBlocks); struct MaintenanceRetInfo_s; STATUS ZVP_Main(struct GeneralMsg_s *genMsg,struct ZlssPool_s *zlssPool, NINT vmFlag, struct MaintenanceRetInfo_s *retInfo ); void ZVP_Startup(); @@ -373,7 +373,7 @@ STATUS ZVP_StatusReportXML( NINT bLen, BYTE **bAdd, NINT *rLen ); -void ZVP_DataDestroy( +void ZVP_DataDestroy( VerifyStats_s *vStats, ZVP_PoolStats_s *zStats ); STATUS ZVP_StatisticsReportBin( @@ -386,3 +386,4 @@ STATUS ZVP_printf_Debug( VerifyStats_s *vStats, const char *where, QUAD debugLev STATUS ZVP_printf_Log( VerifyStats_s *vStats, const char *format, ...); #endif // #ifndef _REPAIRZVP_H_ + diff --git a/src/nwnss/zlss/salvageLog.c b/src/nwnss/zlss/salvageLog.c index 1731afb..a2f04dc 100644 --- a/src/nwnss/zlss/salvageLog.c +++ b/src/nwnss/zlss/salvageLog.c @@ -34,16 +34,13 @@ | This module is used to: | The SalvageLog file +-------------------------------------------------------------------------*/ -#ifdef NSS_USERSPACE -#else #include -#endif #include "msgGen.h" #include "zfs.h" #include "zParams.h" ///**************************************************************************** -// * ZFS B-Tree beast constructor +// * ZFS B-Tree beast constructor // *****************************************************************************/ //STATUS ZSALVAGELOG_Construct( // GeneralMsg_s *genMsg, @@ -132,7 +129,7 @@ // *****************************************************************************/ //STATIC BYTE *ZSALVAGELOG_Unpack( // GeneralMsg_s *genMsg, -// ZSalvageLog_s *beast, +// ZSalvageLog_s *beast, // BYTE *storeBuffer) //{ // /*memcpy(&beast->p,storeBuffer,sizeof(PersistentZSalvageLog_s));*/ diff --git a/src/nwnss/zlss/sbi.c b/src/nwnss/zlss/sbi.c new file mode 100644 index 0000000..eb63279 --- /dev/null +++ b/src/nwnss/zlss/sbi.c @@ -0,0 +1,1940 @@ +/**************************************************************************** + | + | (C) Copyright 2001-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | SBI - Generic NSS code that understands how to convert NSS 3.00 + / ZLSS Metadata blocks into XML. + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Display ZLSS 3.00 metadata blocks in XML form. + | + | Warning - This file is used by NT Utilities like zedRemote, ZlogGet and + | etc. DO NOT ADD NSS specific code. The define NTLIB is only defined + | when source file is compiled with NT Utilities. + +-------------------------------------------------------------------------*/ + +#include +#include + +#include "dfi.h" +#include "sbi.h" +#include "sdZLSS.h" +#include "sdNSS.h" +#include "snp.h" + +#include "zfsFileMap.h" + +/* + * This table is used to Display the vurtual structure ZLSSBlock_s. + * + * As of 2001Nov28 Still have 16 blocks with SBI_DisplayBlockDefault. + * 2003May06 Added EFL support for its 3 block types. + * Added SNAP items, but routine is SBI_DisplayBlockDefault (now have 12 using it). + * Added MSAP support for its 1 block type. + * 2003May07 Added SNAP items routines (Only 8 SBI_DisplayBlockDefault left) + */ + +ZED_SystemBlockInfo_s SBI_SystemBlockTable[] = +{ + {1, "BT Branch", BRANCH_MAGIC, 0, 0, SBI_DisplayBlockBTBranch}, + {1, "BT Leaf", LEAF_MAGIC, 0, 0, SBI_DisplayBlockBTLeaf}, + + {1, "Checkpoint", CHECKPOINT_CP_S_SIGNATURE, 0, 0, SBI_DisplayBlockCheckpoint}, + + {1, "DBT Branch", DBT_LEAF_MAGIC, 0, 0, SBI_DisplayBlockDefault}, + {1, "DBT Leaf", DBT_BRANCH_MAGIC, 0, 0, SBI_DisplayBlockDefault}, + + {1, "EFL Leaf", EFL_LEAF_MAGIC, 0, 0, SBI_DisplayBlockEFLLeaf}, + {1, "EFL Branch", EFL_BRANCH_MAGIC, 0, 0, SBI_DisplayBlockEFLBranch}, + {1, "EFL Log", EFL_LOG_MAGIC, 0, 0, SBI_DisplayBlockEFLLog}, + + {1, "FMAP Branch", FMAP_BT_BRANCH, 0, 0, SBI_DisplayBlockFMAPBranch}, + {1, "FMAP Leaf", FMAP_BT_LEAF, 0, 0, SBI_DisplayBlockFMAPLeaf}, + {1, "FMAP Root", FMAP_BT_ROOT, 0, 0, SBI_DisplayBlockFMAPRoot}, + + {1, "FT Branch", FXBRANCH_MAGIC, 0, 0, SBI_DisplayBlockFTBranch}, + {1, "FT Leaf", FXLEAF_MAGIC, 0, 0, SBI_DisplayBlockFTLeaf}, + + {1, "MFL Node", MFL_MAGIC, 0, 0, SBI_DisplayBlockDefault}, + + {1, "MSAP", MSAP_SIGNATURE, 0, 0, SBI_DisplayBlockMSAP}, + + {1, "NT Node", NAMETREE_MAGIC, 0, 0, SBI_DisplayBlockNameTree}, + + {1, "PT Node(old)", PURGETREE_MAGIC, 0, 0, SBI_DisplayBlockDefault}, + {1, "PT Node", PURGETREE_NEW_MAGIC, 0, 0, SBI_DisplayBlockPT}, + + {1, "PL Node", PURGE_LOG_MAGIC, 0, 0, SBI_DisplayBlockPurgeLog}, + + {1, "Snap admin", SNAP_ADMIN_STAMP, 0, 0, SBI_DisplayBlockSNAPAdmin}, + {1, "Snap header", SNAP_HEADER_STAMP, 0, 0, SBI_DisplayBlockSNAPHeader}, + {1, "Snap map", SNAP_MAP_STAMP, 0, 0, SBI_DisplayBlockSNAPMap}, + {1, "Snap leaf", SNAP_LEAF_STAMP, 0, 0, SBI_DisplayBlockSNAPLeaf}, + + {1, "Super Block Header", SUPERBLOCK_SB_S_SIGNATURE, 0, 0, SBI_DisplayBlockSuperBlockHeader}, + {1, "Super Block Header(deleted)", SUPERBLOCK_SB_S_SIGNATURE_OLD, 0, 0, SBI_DisplayBlockSuperBlockHeader}, + + {1, "UBT Branch", UBT_BRANCH_MAGIC, 0, 0, SBI_DisplayBlockDefault}, + {1, "UBT Leaf", UBT_LEAF_MAGIC, 0, 0, SBI_DisplayBlockDefault}, +#ifndef AT_HOME + {1, "UBT Name", UBT_NAME_MAGIC, 0, 0, SBI_DisplayBlockDefault}, +#endif + {1, "PDB", ZLSSPOOLINFO_MAGIC, 0, 0, SBI_DisplayBlockPoolDataBlock}, + {1, "PLDB", ZLSSLOGGEDPOOLINFO_MAGIC, 0, 0, SBI_DisplayBlockPoolLoggedDataBlock}, + + {1, "VDB", ZFSVOLUMEINFO_MAGIC, 0, 0, SBI_DisplayBlockVolumeDataBlock}, + {1, "VLDB", ZFSLOGGEDVOLUMEINFO_MAGIC, 0, 0, SBI_DisplayBlockVolumeLoggedDataBlock}, + + {1, "Zlog Block Header", ZLBH_S_SIGNATURE, 0, 0, SBI_DisplayBlockDefault}, + +}; + +STATIC int ZED_NumZlssSystemBlkMagicNumbers = sizeof(SBI_SystemBlockTable)/(sizeof(SBI_SystemBlockTable[0])); + + + + +/* The SNAP structure are defined in MMSnap.h which NSS does not have access to. + * Since the structures describe PERSISTENT items I have copied the structures + * from the offical H files. I have changed SPINLOCK to be a LONG. I also + * changed the byte [16] for guid to be GUID_t. In addition, I removed one + * structure that had a union that comes out to be a QUAD on the media to be + * just a QUAD. + */ +typedef struct SnapAdminBlockDef { + LONG stamp; + LONG version; + LONG index; + LONG totalsnaps; + GUID_t snapguid; + QUAD nextadminblock; + LONG/*SPINLOCK*/ adminlock; + LONG reserved[13]; + QUAD snaps[500]; +} SnapAdminBlockDef; + +typedef struct FileExtentList { + LONG length; + LONG virtualblock; + QUAD physicalblock; +} FileExtentList; + +#define SNAP_FILE_EXTENT_SIZE 200 + +typedef struct SnapHeaderDef { + LONG stamp; + LONG version; + QUAD block; + GUID_t guid; + LONG index; + LONG timestamp; + LONG prevstamp; + LONG nextstamp; + QUAD mapheader; + QUAD totalblocks; + GUID_t poolguid; + GUID_t snapguid; + BYTE snappoolname[64]; + BYTE snapname[64]; + LONG initialized; + LONG dirty; + LONG flushing; + LONG lowersectors; + LONG uppersectors; + LONG reserved[31]; + /* These must be together through the freelist. */ + LONG/*SPINLOCK*/ listlock; + LONG startlist; + LONG nextfreeblock; + LONG blocksallocated; + FileExtentList freelist[SNAP_FILE_EXTENT_SIZE]; + BYTE privatesector[512]; +} SnapHeaderDef; + + +typedef struct MapBlock { + LONG stamp; + WORD version; + WORD adminindex; + LONG index; + LONG virtualblock; + QUAD block; + QUAD parentblock; + LONG bits[16]; + /* NOTE: in the SNAP Map root, bits[0] = transfer count and bits[1] - data count. + * The SNAP Map root is pointed to by SNAP Header's 'mapheader' field. + * If bits[0] is 2 then the 1st 2 items in elements[] are transfer map trees. If bits[1] + * is 2 then elements[2] and [3] are block map trees. Transfer map trees leafs are bitmaps + * of which blocks have been transfer via Copy On Write(COW). + */ + QUAD element[500]; // MapElement element[500]; +} MapBlock; +/* The SNAP structure are defined in MMSnap.h which NSS does not have access to. + * Since the structures describe PERSISTENT items I have copied the structures + * from the offical H files. I have changed SPINLOCK to be a LONG. I also + * changed the byte [16] for guid to be GUID_t. In addition, I removed one + * structure that had a union that comes out to be a QUAD on the media to be + * just a QUAD. + */ + + + + /*** + *** The following are structures used to genericially define the fields + *** in numerous ZLSS metadata blocks. There are routines that use these + *** structure to convert a 4K block into XML. + ***/ + + +DFI_DataFormatInformation_s ZED_PurgeLogBlock[] = { + { DFI_TYPE_LONG , NULL, offsetof( PurgeLogBlock_s, magic ), "magic", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( PurgeLogBlock_s, nextBlock ), "nextBlock", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( PurgeLogBlock_s, lsn ), "lsn", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( PurgeLogBlock_s, plb_internalID ), "plb_internalID", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_PurgeLogEntry[] = { + { DFI_TYPE_LONG , NULL, offsetof( PurgeLogEntry_s, type ), "type", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PurgeLogEntry_s, generation ), "generation", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_PurgeBlockEntry[] = { + { DFI_TYPE_Blknum_t , NULL, offsetof( PurgeLogInfo_s, block.blockNumber ), "blockNumber", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_PurgeBeastEntry[] = { + { DFI_TYPE_VolumeID_t , NULL, offsetof( PurgeLogInfo_s, beast.volumeID ), "volumeID", 0, "" }, + { DFI_TYPE_Zid_t , NULL, offsetof( PurgeLogInfo_s, beast.zid ), "zid", 0, "" }, + { DFI_TYPE_Zid_t , NULL, offsetof( PurgeLogInfo_s, beast.dirZid ), "dirZid", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_UserScanEntry[] = { + { DFI_TYPE_VolumeID_t , NULL, offsetof( PurgeLogInfo_s, userScan.volumeID ), "volumeID", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_UserEntry[] = { + { DFI_TYPE_VolumeID_t , NULL, offsetof( PurgeLogInfo_s, user.volumeID ), "volumeID", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_UserClearEntry[] = { + { DFI_TYPE_VolumeID_t , NULL, offsetof( PurgeLogInfo_s, userClear.volumeID ), "volumeID", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_DirEntry[] = { + { DFI_TYPE_VolumeID_t , NULL, offsetof( PurgeLogInfo_s, directory.volumeID ), "volumeID", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_DirUsedEntry[] = { + { DFI_TYPE_VolumeID_t , NULL, offsetof( PurgeLogInfo_s, dirUsed.volumeID ), "volumeID", 0, "" }, + { DFI_TYPE_Zid_t , NULL, offsetof( PurgeLogInfo_s, dirUsed.dirZid ), "dirZid", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_FixVisEntry[] = { + { DFI_TYPE_UserID_t , NULL, offsetof( PurgeLogInfo_s, visib.trusteeID ), "trusteeID", 0, "" }, + { DFI_TYPE_Zid_t , NULL, offsetof( PurgeLogInfo_s, visib.parentZID ), "parentZID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PurgeLogInfo_s, visib.action ), "action", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_TruncateEntry[] = { + { DFI_TYPE_VolumeID_t , NULL, offsetof( PurgeLogInfo_s, trunc.volumeID ), "volumeID", 0, "" }, + { DFI_TYPE_Zid_t , NULL, offsetof( PurgeLogInfo_s, trunc.zid ), "zid", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( PurgeLogInfo_s, trunc.startBlock ), "startBlock", 0, "" }, + { DFI_TYPE_Blkcnt_t , NULL, offsetof( PurgeLogInfo_s, trunc.len ), "len", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_FreeEntry[] = { + { DFI_TYPE_Blknum_t , NULL, offsetof( PurgeLogInfo_s, free.link.block ), "block", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PurgeLogInfo_s, free.link.slot ), "slot", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_MyBTreeBranch[] = { + { DFI_TYPE_LONG , NULL, offsetof( MYBTreeNode_s, magic ), "magic", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( MYBTreeNode_s, state ), "state", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( MYBTreeNode_s, numRecs ), "numRecs", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( MYBTreeNode_s, lsn ), "lsn", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( MYBTreeNode_s, utn_internalID ), "utn_internalID", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_MyBTreeLeaf[] = { + { DFI_TYPE_LONG , NULL, offsetof( MYBTreeNode_s, magic ), "magic", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( MYBTreeNode_s, state ), "state", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( MYBTreeNode_s, numRecs ), "numRecs", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( MYBTreeNode_s, lsn ), "lsn", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( MYBTreeNode_s, utn_internalID ), "utn_internalID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( MYBTreeNode_s, n.leaf.nextLeaf ), "nextLeaf", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( MYBTreeNode_s, n.leaf.reserved ), "reserved", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_LoggedPoolDataBlock[] = { + { DFI_TYPE_LONG , NULL, offsetof( ZlssLoggedPoolBlock_s, ZLPB_zlssPool.LPZP_magic ), "LPZP_magic", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssLoggedPoolBlock_s, ZLPB_zlssPool.LPZP_version ), "LPZP_version", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( ZlssLoggedPoolBlock_s, ZLPB_zlssPool.LPZP_lsn ), "LPZP_lsn", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( ZlssLoggedPoolBlock_s, ZLPB_zlssPool.LPZP_internalID ), "LPZP_internalID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssLoggedPoolBlock_s, ZLPB_zlssPool.LPZP_reserved ), "LPZP_reserved", 64-8, "" }, + + { DFI_TYPE_QUAD , NULL, offsetof( ZlssLoggedPoolBlock_s, ZLPB_pool.LPP_totalBlocks ), "LPP_totalBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlssLoggedPoolBlock_s, ZLPB_pool.LPP_inUseBlocks ), "LPP_inUseBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlssLoggedPoolBlock_s, ZLPB_pool.LPP_purgeableBlocks ), "LPP_purgeableBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlssLoggedPoolBlock_s, ZLPB_pool.LPP_nonPurgeableBlocks ), "LPP_nonPurgeableBlocks", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssLoggedPoolBlock_s, ZLPB_pool.LPP_reserved ), "LPP_reserved", 64-8, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +extern DFI_DataFormatInformation_s ZED_NameTreeHeader[]; + +DFI_DataFormatInformation_s ZED_PoolDataBlock[] = { + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_zlssPool.PZP_magic ), "PZP_magic", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_zlssPool.PZP_version ), "PZP_version", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_zlssPool.PZP_checksum ), "PZP_checksum", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_zlssPool.PZP_reserved1 ), "PZP_reserved1", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( ZlssPoolBlock_s, ZPB_zlssPool.PZP_internalID ), "PZP_internalID", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( ZlssPoolBlock_s, ZPB_zlssPool.PZP_loggedPoolDataBlk ), "PZP_loggedPoolDataBlk", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( ZlssPoolBlock_s, ZPB_zlssPool.PZP_poolDataBlk ), "PZP_poolDataBlk", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_zlssPool.PZP_initUTCTime ), "PZP_initUTCTime", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_zlssPool.PZP_rebuildUTCTime ), "PZP_rebuildUTCTime", 0, "" }, + { DFI_TYPE_VolumeID_t , NULL, offsetof( ZlssPoolBlock_s, ZPB_zlssPool.PZP_volumeID ), "PZP_volumeID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_zlssPool.PZP_reserved ), "PZP_reserved", 64-16-4, "" }, + + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_blockSize ), "PP_blockSize", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_blockShift ), "PP_blockShift", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_rebuildCount ), "PP_rebuildCount", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_reserved0 ), "PP_reserved0", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_mac ), "PP_mac", 32, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_minKeepSeconds ), "PP_minKeepSeconds", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_maxKeepSeconds ), "PP_maxKeepSeconds", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_lowWaterMark ), "PP_lowWaterMark", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_highWaterMark ), "PP_highWaterMark", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_reserved2 ), "PP_reserved2", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_stateAttributes ), "PP_stateAttributes", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_freeToUse ), "PP_freeToUse", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_enabledFeatures ), "PP_enabledFeatures", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_mediaFormatMajor ), "PP_mediaFormatMajor", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_mediaFormatMinor ), "PP_mediaFormatMinor", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_ndsObjectID ), "PP_ndsObjectID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPoolBlock_s, ZPB_pool.PP_reserved ), "PP_reserved", 64-22-4, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s ZED_LoggedVolumeDataBlock[] = { + { DFI_TYPE_LONG , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_zfsVol.LPZV_magic ), "LPZV_magic", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_zfsVol.LPZV_version ), "LPZV_version", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_zfsVol.LPZV_lsn ), "LPZV_lsn", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_zfsVol.LPZV_internalID ), "LPZV_internalID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_zfsVol.LPZV_reserved ), "LPZV_reserved", 32-8, "" }, + + { DFI_TYPE_Zid_t , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.nextZid ), "nextZid", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.numFiles ), "numFiles", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.numObjects ), "numObjects", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.totalBlocks ), "totalBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.inUseBlocks ), "inUseBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.purgeableBlocks ), "purgeableBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.nonPurgeableBlocks ), "nonPurgeableBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.numDeletedFiles ), "numDeletedFiles", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.renameSeqNum ), "renameSeqNum", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.reserved1 ), "reserved1", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.numCompressedFiles ), "numCompressedFiles", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.numCompDelFiles ), "numCompDelFiles", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.numUncompressibleFiles ), "numUncompressibleFiles", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.numCompressedFileBlocks ), "numCompressedFileBlocks", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.numPreCompressedFileBlocks ), "numPreCompressedFileBlocks", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.epoch ), "epoch", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.reservedEpoch ), "reservedEpoch", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsLoggedVolumeBlock_s, ZLVD_volume.LPV_reserved ), "LPV_reserved", 32-30, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_VolumeDataBlock[] = { + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_zfsVol.PZV_magic ), "PZV_magic", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_zfsVol.PZV_version ), "PZV_version", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_zfsVol.PZV_checksum ), "PZV_checksum", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ZfsVolumeBlock_s, ZVD_zfsVol.PZV_rezidCount ), "PZV_rezidCount", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ZfsVolumeBlock_s, ZVD_zfsVol.PZV_readAheadBlocks ), "PZV_readAheadBlocks", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( ZfsVolumeBlock_s, ZVD_zfsVol.PZV_internalID ), "PZV_internalID", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( ZfsVolumeBlock_s, ZVD_zfsVol.PZV_loggedVolumeDataBlk ), "PZV_loggedVolumeDataBlk", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( ZfsVolumeBlock_s, ZVD_zfsVol.PZV_volumeDataBlk ), "PZV_volumeDataBlk", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( ZfsVolumeBlock_s, ZVD_zfsVol.PZV_systemBeastBlkNum ), "PZV_systemBeastBlkNum", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_zfsVol.PZV_ActivationCount ), "PZV_ActivationCount", 0, "" }, + { DFI_TYPE_VolumeID_t , NULL, offsetof( ZfsVolumeBlock_s, ZVD_zfsVol.PZV_volumeID ), "PZV_volumeID", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( ZfsVolumeBlock_s, ZVD_zfsVol.PZV_lsn ), "PZV_lsn", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_zfsVol.PZV_reserved ), "PZV_reserved", 32-8-6-1-4-2, "" }, + { DFI_TYPE_VolumeID_t , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.NUvolumeID ), "NUvolumeID", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.beastVersionMask ), "beastVersionMask", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.blockSize ), "blockSize", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.blockShift ), "blockShift", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.oldVolAttributes ), "oldVolAttributes", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.nameSpaceMask ), "nameSpaceMask", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.mac ), "mac", 32, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.authModelID ), "authModelID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.minKeepSeconds ), "minKeepSeconds", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.maxKeepSeconds ), "maxKeepSeconds", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.lowWaterMark ), "lowWaterMark", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.highWaterMark ), "highWaterMark", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.beastVersion ), "beastVersion", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.stateAttributes ), "stateAttributes", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.rebuildCount ), "rebuildCount", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.ndsObjectID ), "ndsObjectID", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.enabledAttributes ), "enabledAttributes", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.compAttributes.ImplMajorVersion ), "ImplMajorVersion", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.compAttributes.ImplMinorVersion ), "ImplMinorVersion", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.compAttributes.algoID ), "algoID", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.compAttributes.algoVersion ), "algoVersion", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.compAttributes.compFlags ), "compFlags", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.compAttributes.chunkSize ), "chunkSize", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.compAttributes.algorithms_used ), "algorithms_used", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.PV_mediaFormatMajor ), "PV_mediaFormatMajor", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.PV_mediaFormatMinor ), "PV_mediaFormatMinor", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.PV_mediaFormatMajorCreate ), "PV_mediaFormatMajorCreate", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.PV_mediaFormatMinorCreate ), "PV_mediaFormatMinorCreate", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.PV_createTimeUTC ), "PV_createTimeUTC", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.PV_verifyTimeUTC ), "PV_verifyTimeUTC", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.PV_rebuildTimeUTC ), "PV_rebuildTimeUTC", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.PV_activationTimeUTC ), "PV_activationTimeUTC", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.PV_shredCount ), "PV_shredCount", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.PV_reserved2 ), "PV_reserved2", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolumeBlock_s, ZVD_volume.PV_reserved3 ), "PV_reserved3", 64 - (offsetof(struct PersistentVolume_s, PV_reserved2)/sizeof(LONG) + 1), "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s ZED_SuperBlockHeader[] = { + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, SBH_Signature ), "SBH_Signature", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( SuperBlockHeader_s, SBH_VersionMajor ), "SBH_VersionMajor", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( SuperBlockHeader_s, SBH_VersionMinor ), "SBH_VersionMinor", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( SuperBlockHeader_s, SBH_VersionMediaMajor ), "SBH_VersionMediaMajor", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( SuperBlockHeader_s, SBH_VersionMediaMinor ), "SBH_VersionMediaMinor", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, SBH_ItemsMoved ), "SBH_ItemsMoved", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( SuperBlockHeader_s, SBH_InternalID ), "SBH_InternalID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, SBH_PackedSize ), "SBH_PackedSize", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, SBH_Checksum ), "SBH_Checksum", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, supersyncid ), "supersyncid", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( SuperBlockHeader_s, superlocation ), "superlocation", 4, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, physSizeUsed ), "physSizeUsed", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, sizeUsed ), "sizeUsed", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( SuperBlockHeader_s, superTimeStamp ), "superTimeStamp", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, reserved0 ), "reserved0", 1, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( SuperBlockHeader_s, SBH_LoggedPoolDataBlk ), "SBH_LoggedPoolDataBlk", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( SuperBlockHeader_s, SBH_PoolDataBlk ), "SBH_PoolDataBlk", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( SuperBlockHeader_s, SBH_OldInternalID ), "SBH_OldInternalID", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( SuperBlockHeader_s, SBH_PoolToLVStartUTC ), "SBH_PoolToLVStartUTC", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( SuperBlockHeader_s, SBH_PoolToLVEndUTC ), "SBH_PoolToLVEndUTC", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( SuperBlockHeader_s, SBH_VersionMediaMajorCreate ), "SBH_VersionMediaMajorCreate", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( SuperBlockHeader_s, SBH_VersionMediaMinorCreate ), "SBH_VersionMediaMinorCreate", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, SBH_BlocksMoved ), "SBH_BlocksMoved", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, SBH_TempBTSpBlk ), "SBH_TempBTSpBlk", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, SBH_TempFTSpBlk ), "SBH_TempFTSpBlk", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, SBH_TempFTSpBlk1 ), "SBH_TempFTSpBlk1", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, SBH_TempFTSpBlk2 ), "SBH_TempFTSpBlk2", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, nssMagicNumber ), "nssMagicNumber", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, poolClassID ), "poolClassID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, poolID ), "poolID", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( SuperBlockHeader_s, createTime ), "createTime", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( SuperBlockHeader_s, SBH_LoggedVolumeDataBlk ), "SBH_LoggedVolumeDataBlk", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( SuperBlockHeader_s, SBH_VolumeDataBlk ), "SBH_VolumeDataBlk", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( SuperBlockHeader_s, SBH_SystemBeastBlkNum ), "SBH_SystemBeastBlkNum", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( SuperBlockHeader_s, totalblocks ), "totalblocks", 0, "" }, + { DFI_TYPE_unicode_t_STR, NULL, offsetof( SuperBlockHeader_s, SBH_Name ), "SBH_Name", 64, "" }, + { DFI_TYPE_VolumeID_t , NULL, offsetof( SuperBlockHeader_s, SBH_VolumeID ), "SBH_VolumeID", 0, "" }, + { DFI_TYPE_VolumeID_t , NULL, offsetof( SuperBlockHeader_s, SBH_PoolID ), "SBH_PoolID", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( SuperBlockHeader_s, SBH_PoolInternalID ), "SBH_PoolInternalID", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( SuperBlockHeader_s, SBH_Lsn ), "SBH_Lsn", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, SBH_SS_Enabled ), "SBH_SS_Enabled", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( SuperBlockHeader_s, SBH_SS_CreateTime ), "SBH_SS_CreateTime", 0, "" }, + { DFI_TYPE_VolumeID_t , NULL, offsetof( SuperBlockHeader_s, SBH_SS_OriginalPoolID ), "SBH_SS_OriginalPoolID", 0, "" }, + { DFI_TYPE_VolumeID_t , NULL, offsetof( SuperBlockHeader_s, SBH_SS_OriginalVolumeID ), "SBH_SS_OriginalVolumeID", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( SuperBlockHeader_s, SBH_SS_Guid ), "SBH_SS_Guid", 0, "" }, + { DFI_TYPE_unicode_t_STR, NULL, offsetof( SuperBlockHeader_s, SBH_SS_OriginalName ), "SBH_SS_OriginalName", 64, "" }, + { DFI_TYPE_LONG , NULL, offsetof( SuperBlockHeader_s, reserved2 ), "reserved2", 16, "" }, + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s ZED_Checkpoint[] = { + { DFI_TYPE_LONG , NULL, offsetof( Checkpoint_s, CP_Signature ), "CP_Signature", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( Checkpoint_s, CP_VersionMajor ), "CP_VersionMajor", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( Checkpoint_s, CP_VersionMinor ), "CP_VersionMinor", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Checkpoint_s, CP_PackedSize ), "CP_PackedSize", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Checkpoint_s, CP_Checksum ), "CP_Checksum", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( Checkpoint_s, CP_SyncId ), "CP_SyncId", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( Checkpoint_s, CP_ModifiedTime ), "CP_ModifiedTime", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Checkpoint_s, CP_NumPackedBeasts ), "CP_NumPackedBeasts", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Checkpoint_s, CP_ZasRestartId ), "CP_ZasRestartId", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Checkpoint_s, CP_State ), "CP_State", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Checkpoint_s, CP_Reserved ), "CP_Reserved", 20, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( Checkpoint_s, CP_PackedData ), "CP_PackedData", 8, "" }, + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +/* + * ZED_SystemBlockInfo_s() + * Determines if a block is a SYSTEM BLOCK. + * + * Returns - + * !NULL if the block match our critria else NULL. + */ + +ZED_SystemBlockInfo_s *SBI_SystemBlock( BYTE *buffer ) + +{ + + int i; + LONG nodeMagic; + + nodeMagic = *(LONG *)buffer; + for (i = 0; i < ZED_NumZlssSystemBlkMagicNumbers; ++ i) + { + if (nodeMagic == SBI_SystemBlockTable[i].magic) + { +// ++SBI_SystemBlockTable[i].SSBI_count; + if ( SBI_SystemBlockTable[i].selected ) + { + return( &SBI_SystemBlockTable[i] ); + } + else + { + return( NULL ); + } + } + } + return( NULL ); + +} + +STATUS SBI_DisplayBlockBTLeaf( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS rc; + int index; + BeastTreeNode_s *btLeaf = (BeastTreeNode_s *)block; + Znode_s *znode; + + DFI_Display_Header_Structure( co, "TheBlock", "BeastTreeNode_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + ZSD_Display_Type_LONG( co, "magic", &btLeaf->magic ); + ZSD_Display_Type_WORD( co, "state", &btLeaf->state ); //bitmask + ZSD_Display_Type_WORD( co, "numRecs", &btLeaf->numRecs ); + ZSD_Display_Struct_Lsn_t( co, "lsn", &btLeaf->lsn ); + ZSD_Display_Struct_GUID_t( co, "btn_internalID", (GUID_t *)&btLeaf->btn_internalIDWithBlock ); + + ZSD_Display_Type_Blknum_t( co, "nextLeaf", &btLeaf->n.leaf.nextLeaf ); + if ( co->DCO_Zid == 0 ) + { + *nextBlockHint = btLeaf->n.leaf.nextLeaf; + } + ZSD_Display_Type_WORD( co, "freeSpace", &btLeaf->n.leaf.freeSpace ); + ZSD_Display_Type_WORD( co, "startOfFreeSpace", &btLeaf->n.leaf.startOfFreeSpace ); + + ZSD_Display_Type_NodeLen_t_ARRAY( co, "znodePtr", btLeaf->numRecs, &btLeaf->LEAF.znodePtr[MAX_LEAF_PTRS - btLeaf->numRecs + 1] ); + +#if 1 + for ( index = 0; index < btLeaf->numRecs; index++ ) + { + znode = (Znode_s *)&btLeaf->LEAF.znode[btLeaf->LEAF.znodePtr[MAX_LEAF_PTRS - index]]; + (void)ZSD_Display_Struct_Znode_s( znode, co, "data" ); + } +#else + /* Display only 1st and last entry (makes zedremote fast when using /next to dump a BIG BT) */ + if ( btLeaf->numRecs > 0 ) + { + index = 0; + znode = (Znode_s *)&btLeaf->LEAF.znode[btLeaf->LEAF.znodePtr[MAX_LEAF_PTRS - index]]; + (void)ZSD_Display_Struct_Znode_s( znode, co, "data" ); + if ( btLeaf->numRecs > 1 ) + { + index = btLeaf->numRecs-1; + znode = (Znode_s *)&btLeaf->LEAF.znode[btLeaf->LEAF.znodePtr[MAX_LEAF_PTRS - index]]; + (void)ZSD_Display_Struct_Znode_s( znode, co, "data" ); + } + } +#endif + rc = DFI_Display_Tail_Structure( co, "BeastTreeNode_s", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( zOK ); + +} /* End of SBI_DisplayBlockBTLeaf */ + + +int ZSD_Display_Struct_FileExtentList( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + FileExtentList *data ) +{ + char *structureName = "FileExtentList"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *data ), data ); + ZSD_Display_Type_LONG( co, "length", &data->length ); + ZSD_Display_Type_LONG( co, "virtualblock", &data->virtualblock ); + ZSD_Display_Type_QUAD( co, "physicalblock", &data->physicalblock ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + + return( rc ); + +} + + +int ZSD_Display_Struct_FileExtentList_ARRAY( + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + FileExtentList *data ) /* Array of .. */ +{ + int rc; + unsigned int index; + + DFI_Display_Header_ARRAY( co, tag, "FileExtentList", arrayElements, arrayElements * sizeof( *data ), &data[0] ); + for ( index = 0; index < arrayElements; index++ ) + { + rc = ZSD_Display_Struct_FileExtentList( co, tag, index, arrayElements, &data[index] ); + } + rc = DFI_Display_Tail_ARRAY( co, tag, "FileExtentList" ); + return( rc ); +} /* End of ZSD_Display_Struct_FileExtentList_ARRAY() */ + + +STATUS SBI_DisplayBlockSNAPMap( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + STATUS status; + MapBlock *snap = (void *)block; + + DFI_Display_Header_Structure( co, "TheBlock", "MapBlock", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + + ZSD_Display_Type_LONG( co, "stamp", &snap->stamp ); + ZSD_Display_Type_WORD( co, "version", &snap->version ); + ZSD_Display_Type_WORD( co, "adminindex", &snap->adminindex ); + ZSD_Display_Type_LONG( co, "index", &snap->index ); + ZSD_Display_Type_LONG( co, "virtualblock", &snap->virtualblock ); + ZSD_Display_Type_QUAD( co, "block", &snap->block ); + ZSD_Display_Type_QUAD( co, "parentblock", &snap->parentblock ); + ZSD_Display_Type_LONG_ARRAY( co, "bits", NELEMS( snap->bits ), (LONG *)&snap->bits ); + ZSD_Display_Type_QUAD_ARRAY( co, "element", NELEMS( snap->element ), &snap->element[0] ); + + status = DFI_Display_Tail_Structure( co, "MapBlock", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( status ); + +} /* End of SBI_DisplayBlockMSAPap() */ + + +STATUS SBI_DisplayBlockSNAPLeaf( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + STATUS status; + MapBlock *snap = (void *)block; + + DFI_Display_Header_Structure( co, "TheBlock", "MapBlock", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + + ZSD_Display_Type_LONG( co, "stamp", &snap->stamp ); + ZSD_Display_Type_WORD( co, "version", &snap->version ); + ZSD_Display_Type_WORD( co, "adminindex", &snap->adminindex ); + ZSD_Display_Type_LONG( co, "index", &snap->index ); + ZSD_Display_Type_LONG( co, "virtualblock", &snap->virtualblock ); + ZSD_Display_Type_QUAD( co, "block", &snap->block ); + ZSD_Display_Type_QUAD( co, "parentblock", &snap->parentblock ); + ZSD_Display_Type_LONG_ARRAY( co, "bits", NELEMS( snap->bits ), &snap->bits[0] ); + ZSD_Display_Type_QUAD_ARRAY( co, "element", NELEMS( snap->element ), &snap->element[0] ); + + status = DFI_Display_Tail_Structure( co, "MapBlock", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( status ); + +} /* End of SBI_DisplayBlockMSAPLeaf() */ + + +STATUS SBI_DisplayBlockSNAPHeader( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + STATUS status; + SnapHeaderDef *snap = (void *)block; + + DFI_Display_Header_Structure( co, "TheBlock", "SnapHeaderDef", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + + ZSD_Display_Type_LONG( co, "stamp", &snap->stamp ); + ZSD_Display_Type_LONG( co, "version", &snap->version ); + ZSD_Display_Type_QUAD( co, "block", &snap->block ); + ZSD_Display_Struct_GUID_t( co, "guid", &snap->guid ); + ZSD_Display_Type_LONG( co, "index", &snap->index ); + ZSD_Display_Type_Time_t( co, "timestamp", &snap->timestamp ); + ZSD_Display_Type_Time_t( co, "prevstamp", &snap->prevstamp ); + ZSD_Display_Type_Time_t( co, "nextstamp", &snap->nextstamp ); + ZSD_Display_Type_QUAD( co, "mapheader", &snap->mapheader ); + ZSD_Display_Type_QUAD( co, "totalblocks", &snap->totalblocks ); + ZSD_Display_Struct_GUID_t( co, "poolguid", &snap->poolguid ); + ZSD_Display_Struct_GUID_t( co, "snapguid", &snap->snapguid ); + ZSD_Display_Type_char_STR( co, "snappoolname", NELEMS( snap->snappoolname ), (char *)&snap->snappoolname[0] ); + ZSD_Display_Type_char_STR( co, "snapname", NELEMS( snap->snapname ), (char *)&snap->snapname[0] ); + ZSD_Display_Type_LONG( co, "initialized", &snap->initialized ); + ZSD_Display_Type_LONG( co, "dirty", &snap->dirty ); + ZSD_Display_Type_LONG( co, "flushing", &snap->flushing ); + ZSD_Display_Type_LONG( co, "lowersectors", &snap->lowersectors ); + ZSD_Display_Type_LONG( co, "uppersectors", &snap->uppersectors ); + ZSD_Display_Type_LONG_ARRAY( co, "reserved", NELEMS( snap->reserved ), &snap->reserved[0] ); + ZSD_Display_Type_LONG( co, "listlock", &snap->listlock ); + ZSD_Display_Type_LONG( co, "startlist", &snap->startlist ); + ZSD_Display_Type_LONG( co, "nextfreeblock", &snap->nextfreeblock ); + ZSD_Display_Type_LONG( co, "blocksallocated", &snap->blocksallocated ); + ZSD_Display_Struct_FileExtentList_ARRAY( co, "freelist", NELEMS( snap->freelist ), &snap->freelist[0] ); + ZSD_Display_Type_BYTE_ARRAY( co, "privatesector", NELEMS( snap->privatesector ), &snap->privatesector[0] ); + + status = DFI_Display_Tail_Structure( co, "SnapHeaderDef", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( status ); + +} /* End of SBI_DisplayBlockMSAP() */ + + +STATUS SBI_DisplayBlockSNAPAdmin( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS status; + SnapAdminBlockDef *snap = (void *)block; + + DFI_Display_Header_Structure( co, "TheBlock", "SnapAdminBlockDef", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + + ZSD_Display_Type_LONG( co, "stamp", &snap->stamp ); + ZSD_Display_Type_LONG( co, "version", &snap->version ); + ZSD_Display_Type_LONG( co, "index", &snap->index ); + ZSD_Display_Type_LONG( co, "totalsnaps", &snap->totalsnaps ); + ZSD_Display_Struct_GUID_t( co, "snapguid", &snap->snapguid ); + ZSD_Display_Type_QUAD( co, "nextadminblock", &snap->nextadminblock ); + ZSD_Display_Type_LONG( co, "adminlock", &snap->adminlock ); + ZSD_Display_Type_LONG_ARRAY( co, "reserved", NELEMS( snap->reserved ), &snap->reserved[0] ); + ZSD_Display_Type_QUAD_ARRAY( co, "snaps", NELEMS( snap->snaps ), &snap->snaps[0] ); + + status = DFI_Display_Tail_Structure( co, "SnapAdminBlockDef", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( status ); + +} /* End of SBI_DisplayBlockMSAP() */ + + +STATUS SBI_DisplayBlockMSAP( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS status; + MSAP_Block_s *msap = (void *)block; + + DFI_Display_Header_Structure( co, "TheBlock", "MSAP_Block_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + + ZSD_Display_Type_LONG( co, "MSAP_SignatureMinor", &msap->MSAP_SignatureMinor ); + ZSD_Display_Type_LONG( co, "MSAP_SignatureMajor", &msap->MSAP_SignatureMajor ); + ZSD_Display_Struct_Lsn_t( co, "MSAP_LsnNotUsed", &msap->MSAP_LsnNotUsed ); + ZSD_Display_Struct_GUID_t( co, "MSAP_InternalID", &msap->MSAP_InternalID ); + ZSD_Display_Struct_GUID_t( co, "MSAP_ServerID", &msap->MSAP_ServerID ); + ZSD_Display_Struct_GUID_t( co, "MSAP_ClusterID", &msap->MSAP_ClusterID ); + ZSD_Display_Struct_GUID_t( co, "MSAP_ProbeRequestID", &msap->MSAP_ProbeRequestID ); + ZSD_Display_Struct_GUID_t( co, "MSAP_ProbeResponseID", &msap->MSAP_ProbeResponseID ); + ZSD_Display_Type_Time_t( co, "MSAP_InitialUTC", &msap->MSAP_InitialUTC ); + ZSD_Display_Type_Time_t( co, "MSAP_WroteUTC", &msap->MSAP_WroteUTC ); + ZSD_Display_Type_WORD( co, "MSAP_VersionMajor", &msap->MSAP_VersionMajor ); + ZSD_Display_Type_WORD( co, "MSAP_VersionMinor", &msap->MSAP_VersionMinor ); + ZSD_Display_Type_WORD( co, "MSAP_ProbeRequestIDListSlot", &msap->MSAP_ProbeRequestIDListSlot ); + ZSD_Display_Type_WORD( co, "MSAP_ProbeResponseIDListSlot", &msap->MSAP_ProbeResponseIDListSlot ); + ZSD_Display_Type_WORD( co, "MSAP_ServerIDListSlot", &msap->MSAP_ServerIDListSlot ); + ZSD_Display_Type_WORD( co, "MSAP_ProbeSeconds", &msap->MSAP_ProbeSeconds ); + ZSD_Display_Type_WORD( co, "MSAP_ProbeSecondsMinimum", &msap->MSAP_ProbeSecondsMinimum ); + ZSD_Display_Type_WORD( co, "MSAP_ProbeSecondsMaximum", &msap->MSAP_ProbeSecondsMaximum ); + ZSD_Display_Type_QUAD( co, "MSAP_ServerIDCount", &msap->MSAP_ServerIDCount ); + ZSD_Display_Type_QUAD( co, "MSAP_ProbeRequestCount", &msap->MSAP_ProbeRequestCount ); + ZSD_Display_Type_QUAD( co, "MSAP_ProbeResponseCount", &msap->MSAP_ProbeResponseCount ); + ZSD_Display_Struct_GUID_t_ARRAY( co, "MSAP_ProbeRequestIDList", NELEMS( msap->MSAP_ProbeRequestIDList ), &msap->MSAP_ProbeRequestIDList[0] ); + ZSD_Display_Struct_GUID_t_ARRAY( co, "MSAP_ProbeRequestIDClusterList", NELEMS( msap->MSAP_ProbeRequestIDClusterList ), &msap->MSAP_ProbeRequestIDClusterList[0] ); + ZSD_Display_Type_Time_t_ARRAY( co, "MSAP_ProbeRequestIDListUTC", NELEMS( msap->MSAP_ProbeRequestIDListUTC ), &msap->MSAP_ProbeRequestIDListUTC[0] ); + ZSD_Display_Struct_GUID_t_ARRAY( co, "MSAP_ProbeResponseIDList", NELEMS( msap->MSAP_ProbeResponseIDList ), &msap->MSAP_ProbeRequestIDList[0] ); + ZSD_Display_Struct_GUID_t_ARRAY( co, "MSAP_ProbeResponseIDTargetList", NELEMS( msap->MSAP_ProbeResponseIDTargetList ), &msap->MSAP_ProbeResponseIDTargetList[0] ); + ZSD_Display_Type_Time_t_ARRAY( co, "MSAP_ProbeResponseIDListUTC", NELEMS( msap->MSAP_ProbeResponseIDListUTC ), &msap->MSAP_ProbeResponseIDListUTC[0] ); + ZSD_Display_Struct_GUID_t_ARRAY( co, "MSAP_ServerIDList", NELEMS( msap->MSAP_ServerIDList ), &msap->MSAP_ServerIDList[0] ); + ZSD_Display_Struct_GUID_t_ARRAY( co, "MSAP_ClusterIDList", NELEMS( msap->MSAP_ClusterIDList ), &msap->MSAP_ClusterIDList[0] ); + ZSD_Display_Type_Time_t_ARRAY( co, "MSAP_ServerIDListUTC", NELEMS( msap->MSAP_ServerIDListUTC ), &msap->MSAP_ServerIDListUTC[0] ); + ZSD_Display_Type_BYTE_ARRAY( co, "MSAP_ServerIDListFlags", NELEMS( msap->MSAP_ServerIDListFlags ), &msap->MSAP_ServerIDListFlags[0] ); + ZSD_Display_Type_BYTE( co, "MSAP_ServerIDFlags", &msap->MSAP_ServerIDFlags ); + ZSD_Display_Type_BYTE_ARRAY( co, "MSAP_Reserver4", NELEMS( msap->MSAP_Reserver4 ), &msap->MSAP_Reserver4[0] ); + ZSD_Display_Type_WORD( co, "MSAP_ProbeReponseSeconds", &msap->MSAP_ProbeReponseSeconds ); + ZSD_Display_Type_LONG_ARRAY( co, "MSAP_Reserved3", NELEMS( msap->MSAP_Reserved3 ), &msap->MSAP_Reserved3[0] ); + ZSD_Display_Type_LONG( co, "MSAP_SignatureMinor2", &msap->MSAP_SignatureMinor2 ); + + status = DFI_Display_Tail_Structure( co, "MSAP_Block_s", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( status ); + +} /* End of SBI_DisplayBlockMSAP() */ + + +STATUS SBI_DisplayBlockEFLLogHeader( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS rc; + ELogNode_s *eLog = (void *)block; + + DFI_Display_Header_Structure( co, "TheBlock", "ELogNode_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + ZSD_Display_Type_LONG( co, "magic", &eLog->magic ); + ZSD_Display_Type_WORD( co, "numEntries", &eLog->numEntries ); + ZSD_Display_Type_WORD( co, "state", &eLog->state ); //bitmask + ZSD_Display_Struct_Lsn_t( co, "lsn", &eLog->lsn ); + ZSD_Display_Struct_GUID_t( co, "elog_internalID", &eLog->elog_internalID ); + ZSD_Display_Type_Blknum_t( co, "nextBlock", &eLog->nextBlock ); + *nextBlockHint = eLog->nextBlock; + ZSD_Display_Type_LONG( co, "resBlk", &eLog->resBlk ); + ZSD_Display_Struct_ELogHeader_s_ARRAY( co, "header", (unsigned int)eLog->numEntries, &eLog->u.header ); + rc = DFI_Display_Tail_Structure( co, "ELogNode_s", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( rc ); + +} /* End of SBI_DisplayBlockEFLLogHeader */ + + +STATUS SBI_DisplayBlockEFLLogLog( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS rc; + ELogNode_s *eLog = (void *)block; + + DFI_Display_Header_Structure( co, "TheBlock", "ELogNode_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + ZSD_Display_Type_LONG( co, "magic", &eLog->magic ); + ZSD_Display_Type_WORD( co, "numEntries", &eLog->numEntries ); + ZSD_Display_Type_WORD( co, "state", &eLog->state ); //bitmask + ZSD_Display_Struct_Lsn_t( co, "lsn", &eLog->lsn ); + ZSD_Display_Struct_GUID_t( co, "elog_internalID", &eLog->elog_internalID ); + ZSD_Display_Type_Blknum_t( co, "nextBlock", &eLog->nextBlock ); + *nextBlockHint = eLog->nextBlock; + ZSD_Display_Type_LONG( co, "resBlk", &eLog->resBlk ); + + { + char *structureName = "ELogLog_s"; + ELogEntry_s *eLogEntry; + int i; + int offset; + + DFI_Display_Header_Structure( co, "data", structureName, 0, 0, DFI_VARIABLE_SIZE_INKNOWN, &eLog->u.log ); + ZSD_Display_Type_WORD( co, "numGoodEntries", &eLog->u.log.numGoodEntries ); + ZSD_Display_Type_WORD( co, "numFirstEntries", &eLog->u.log.numFirstEntries ); + ZSD_Display_Type_LONG( co, "insertOffset", &eLog->u.log.insertOffset ); + + for(i = 0, offset = 0; i < eLog->numEntries; i++, offset += eLogEntry->len) + { +// zASSERT(offset < node->u.log.insertOffset); + eLogEntry = (ELogEntry_s *)&eLog->u.log.data[offset]; +// zASSERT(entry->magic == ELOG_ENTRY_MAGIC); + DFI_Display_Struct_ELogEntry_s( co, "data"/*tag*/, i/*index*/, eLog->numEntries/*array elements*/, eLogEntry ); + } + + DFI_Display_Tail_Structure( co, structureName, DFI_VARIABLE_SIZE_INKNOWN, &eLog->u.log ); + } + + + rc = DFI_Display_Tail_Structure( co, "ELogNode_s", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( rc ); + +} /* End of SBI_DisplayBlockEFLLogHeader */ + + +STATUS SBI_DisplayBlockEFLLog( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS status; + ELogNode_s *eLog = (void *)block; + + if ( eLog->state & ELOG_STATE_HEADER ) + { + status = SBI_DisplayBlockEFLLogHeader( sbi, block, co, nextBlockHint ); + } + else + { + status = SBI_DisplayBlockEFLLogLog( sbi, block, co, nextBlockHint ); + } + return( status ); + +} /* End of SBI_DisplayBlockEFLLog() */ + + +STATUS SBI_DisplayBlockEFLLeaf( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS rc; + EFLTreeNode_s *eflLeaf = (void *)block; + + + DFI_Display_Header_Structure( co, "TheBlock", "EFLTreeNode_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + ZSD_Display_Type_LONG( co, "magic", &eflLeaf->magic ); + ZSD_Display_Type_WORD( co, "state", &eflLeaf->state ); //bitmask + ZSD_Display_Type_WORD( co, "numRecs", &eflLeaf->numRecs ); + ZSD_Display_Struct_Lsn_t( co, "lsn", &eflLeaf->lsn ); + ZSD_Display_Struct_GUID_t( co, "efl_internalID", &eflLeaf->efl_internalID ); + + ZSD_Display_Type_Blknum_t( co, "nextLeaf", &eflLeaf->n.leaf.nextLeaf ); + *nextBlockHint = eflLeaf->n.leaf.nextLeaf; + ZSD_Display_Type_LONG( co, "resBlk", &eflLeaf->n.leaf.resBlk ); + ZSD_Display_Struct_EFLLeafEntry_s_ARRAY( co, "leaf", + (unsigned int)eflLeaf->numRecs, &eflLeaf->n.leaf.entry[0] ); + rc = DFI_Display_Tail_Structure( co, "EFLTreeNode_s", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( rc ); + +} /* End of SBI_DisplayBlockEFLLeaf */ + + +STATUS SBI_DisplayBlockEFLBranch( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS rc; + EFLTreeNode_s *eflBranch = (void *)block; + + DFI_Display_Header_Structure( co, "TheBlock", "EFLTreeNode_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + ZSD_Display_Type_LONG( co, "magic", &eflBranch->magic ); + ZSD_Display_Type_WORD( co, "state", &eflBranch->state ); //bitmask + ZSD_Display_Type_WORD( co, "numRecs", &eflBranch->numRecs ); + ZSD_Display_Struct_Lsn_t( co, "lsn", &eflBranch->lsn ); + ZSD_Display_Struct_GUID_t( co, "efl_internalID", &eflBranch->efl_internalID ); + if ( eflBranch->numRecs > 0 ) + { /* For BRANCHes we follow down the left most branches which + * gets us to the left most leaf which then gets us all the + * leaves. + */ + *nextBlockHint = eflBranch->n.branch.entry[0].child; + } + ZSD_Display_Struct_EFLBranch_s_ARRAY( co, "branch", + (unsigned int)eflBranch->numRecs, &eflBranch->n.branch.entry[0] ); + rc = DFI_Display_Tail_Structure( co, "EFLTreeNode_s", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( rc ); + +} /* End of SBI_DisplayBlockEFLBranch */ + + +STATUS SBI_DisplayBlockFMAPRoot( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS status; + FmapNode_s *fmap = (void *)block; + + if ( fmap->head.state & BT_LEAF ) + { + status = SBI_DisplayBlockFMAPLeaf( sbi, block, co, nextBlockHint ); + } + else + { + status = SBI_DisplayBlockFMAPBranch( sbi, block, co, nextBlockHint ); + } + return( status ); + +} + +STATUS SBI_DisplayBlockFMAPBranch( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS rc; + FmapNode_s *fmapBranch = (void *)block; + + DFI_Display_Header_Structure( co, "TheBlock", "FmapNode_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + ZSD_Display_Type_LONG( co, "magic", &fmapBranch->head.magic ); + ZSD_Display_Type_WORD( co, "state", &fmapBranch->head.state ); //bitmask + ZSD_Display_Type_WORD( co, "numRecs", &fmapBranch->head.numRecs ); + ZSD_Display_Struct_Lsn_t( co, "lsn", &fmapBranch->head.lsn ); + ZSD_Display_Struct_GUID_t( co, "fnh_internalID", &fmapBranch->head.fnh_internalID ); + ZSD_Display_Type_Zid_t( co, "fnh_zid", &fmapBranch->head.fnh_zid ); + ZSD_Display_Type_Blknum_t( co, "leafLink", &fmapBranch->head.leafLink ); + ZSD_Display_Struct_FmapExt_s_ARRAY( co, "branch", + (unsigned int)fmapBranch->head.numRecs, &fmapBranch->extent[0] ); + rc = DFI_Display_Tail_Structure( co, "FmapNode_s", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( rc ); + +} /* End of SBI_DisplayBlockFMAPBranch */ + + +STATUS SBI_DisplayBlockFMAPLeaf( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS rc; + FmapNode_s *fmapLeaf = (void *)block; + + DFI_Display_Header_Structure( co, "TheBlock", "FmapNode_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + ZSD_Display_Type_LONG( co, "magic", &fmapLeaf->head.magic ); + ZSD_Display_Type_WORD( co, "state", &fmapLeaf->head.state ); //bitmask + ZSD_Display_Type_WORD( co, "numRecs", &fmapLeaf->head.numRecs ); + ZSD_Display_Struct_Lsn_t( co, "lsn", &fmapLeaf->head.lsn ); + ZSD_Display_Struct_GUID_t( co, "fnh_internalID", &fmapLeaf->head.fnh_internalID ); + ZSD_Display_Type_Zid_t( co, "fnh_zid", &fmapLeaf->head.fnh_zid ); + ZSD_Display_Type_Blknum_t( co, "leafLink", &fmapLeaf->head.leafLink ); + ZSD_Display_Struct_FmapExt_s_ARRAY( co, "leaf", + (unsigned int)fmapLeaf->head.numRecs, &fmapLeaf->extent[0] ); + rc = DFI_Display_Tail_Structure( co, "FmapNode_s", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( rc ); + +} /* End of SBI_DisplayBlockFMAPLeaf */ + + +STATUS SBI_DisplayBlockFTBranch( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS rc; + xNode_s *ftBranch = (xNode_s *)block; + + DFI_Display_Header_Structure( co, "TheBlock", "xNode_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + ZSD_Display_Type_LONG( co, "magic", &ftBranch->header.magic ); + ZSD_Display_Type_WORD( co, "state", &ftBranch->header.state ); //bitmask + ZSD_Display_Type_WORD( co, "numRecs", &ftBranch->header.numRecs ); + ZSD_Display_Struct_Lsn_t( co, "lsn", &ftBranch->header.lsn ); + ZSD_Display_Struct_GUID_t( co, "xnh_internalID", &ftBranch->header.xnh_internalID ); + ZSD_Display_Type_WORD( co, "nextrec", &ftBranch->header.nextrec ); + ZSD_Display_Struct_xBranch_s_ARRAY( co, "branch", + (unsigned int)ftBranch->header.numRecs, (xBranch_s *)&ftBranch->n.extents[0] ); + rc = DFI_Display_Tail_Structure( co, "xNode_s", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( rc ); + +} /* End of SBI_DisplayBlockFTBranch */ + + +STATUS SBI_DisplayBlockFTLeaf( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS rc; + xNode_s *ftLeaf = (xNode_s *)block; + + DFI_Display_Header_Structure( co, "TheBlock", "xNode_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + ZSD_Display_Type_LONG( co, "magic", &ftLeaf->header.magic ); + ZSD_Display_Type_WORD( co, "state", &ftLeaf->header.state ); //bitmask + ZSD_Display_Type_WORD( co, "numRecs", &ftLeaf->header.numRecs ); + ZSD_Display_Struct_Lsn_t( co, "lsn", &ftLeaf->header.lsn ); + ZSD_Display_Struct_GUID_t( co, "xnh_internalID", &ftLeaf->header.xnh_internalID ); + ZSD_Display_Type_WORD( co, "nextrec", &ftLeaf->header.nextrec ); +// SNP_snprintf( WHERE, pb, "\n", (unsigned int)ftLeaf->header.numRecs ); + ZSD_Display_Struct_Extent_s_ARRAY( co, "extents", ftLeaf->header.numRecs, &ftLeaf->n.extents[0] ); +// SNP_snprintf( WHERE, pb, "\n" ); + rc = DFI_Display_Tail_Structure( co, "xNode_s", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( rc ); + +} /* End of SBI_DisplayBlockBTLeaf */ + +/**************************************************************************** + * SBI_findChildBlock + * In: buffer - the buffer to be searched + * zid - ZID to find + * Out: index into the ptr array (0 to numrecs) + * Return: Blknum of the child block holding the zid + ****************************************************************************/ +Blknum_t SBI_findChildBlock( + BeastTreeNode_s *node, + Zid_t zid, + NINT *index) +{ + SNINT mid = 0; + SNINT low = 0; + SNINT high = node->numRecs-1; + Zid_t zidFromMid = 0; + + while (low <= high) + { + mid = (low + high) / 2; + zidFromMid = node->n.branch[mid].zid; + if (zid == zidFromMid) + { + break; + } + else if (zid > zidFromMid) + { + low = mid + 1; + } + else + { + high = mid - 1; + } + } + + if (zid < zidFromMid) + { + if (mid > 0) + { + --mid; + } + else + { + zASSERT("zid too small in findChildBlock" == 0); + mid = 0; + } + } + *index = mid; + return(node->n.branch[mid].child); +} + + +void SBI_BTBracnhBlockHint( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + NINT dummy; + + if ( !BBT_IS_LEAF((BeastTreeNode_s *)block) ) + { + *nextBlockHint = SBI_findChildBlock((BeastTreeNode_s *)block, co->DCO_Zid, &dummy); + } + +} + + +STATUS SBI_DisplayBlockBTBranch( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS rc; + BeastTreeNode_s *btBranch = (BeastTreeNode_s *)block; + + DFI_Display_Header_Structure( co, "TheBlock", "BeastTreeNode_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + ZSD_Display_Type_LONG( co, "magic", &btBranch->magic ); + ZSD_Display_Type_WORD( co, "state", &btBranch->state ); //bitmask + ZSD_Display_Type_WORD( co, "numRecs", &btBranch->numRecs ); + ZSD_Display_Struct_Lsn_t( co, "lsn", &btBranch->lsn ); + ZSD_Display_Struct_GUID_t( co, "btn_internalID", (GUID_t *)&btBranch->btn_internalIDWithBlock ); + ZSD_Display_Struct_BTBranch_s_ARRAY( co, "branch", (unsigned int)btBranch->numRecs, &btBranch->n.branch[0] ); + rc = DFI_Display_Tail_Structure( co, "BeastTreeNode_s", DFI_VARIABLE_SIZE_INKNOWN, block ); + if ( co->DCO_Zid != 0 ) + { + SBI_BTBracnhBlockHint( sbi, block, co, nextBlockHint ); + } + + return( rc ); + +} /* End of SBI_DisplayBlockBTBranch */ + + +STATUS SBI_DisplayBlockCheckpoint( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + LONG checksum; + NINT i; + MediaCheckpoint_s *mcp = (void *)block; + Checkpoint_s *checkpoint; + ZnodeHeader_s *packedHeader; + + checkpoint = (Checkpoint_s *)mcp; + packedHeader = (ZnodeHeader_s *)&checkpoint->CP_PackedData[0]; + /* Is the length larger than our buffer? */ + if ( checkpoint->CP_PackedSize > (sizeof(*mcp)) ) + { /* Yes - then data must be corrupted */ + return( zERR_CHECKPOINT_BAD_BLOCK_SIZE ); + } + checksum = ZED_CheckpointCalculateChecksum( (LONG *)mcp, + checkpoint->CP_PackedSize/4 ); + if ( checksum != 0 ) + { /* Checksum error on checkpoint */ + printf(" Checksum is not correct\n" ); + } + else + { + printf(" Checksum is valid\n" ); + } + if ( checkpoint->CP_Signature != CHECKPOINT_CP_S_SIGNATURE ) + { + printf( " Signature BAD\n"); + } + if ( checkpoint->CP_VersionMajor != CHECKPOINT_CP_VM_MAJOR ) + { + printf( " Unsupported Version (rest of results may be bad)\n"); + } + + for ( i = 0; ZED_Checkpoint[i].DFI_Type != DFI_TYPE_END; i++ ) + { + DFI_Display( co, &ZED_Checkpoint[i], block, ZED_Checkpoint[i].DFI_Offset ); + } + + if ( packedHeader->magic != NODE_MAGIC ) + { + printf( " Packed Magic BAD\n"); + } + if ( packedHeader->zid != ZFSPOOL_LOGFILE_ZID ) + { + printf( " Packed ZID is BAD (it must be ZLOGs)\n"); + } + + (void)ZSD_Display_Struct_Znode_s((Znode_s *)&checkpoint->CP_PackedData[0], co, "ZLOG" ); +// BST_doUnpack(genMsg,&beast->ZFSLOGroot,&checkpoint->CP_PackedData[0], packedHeader->length) != zOK) + + return( zOK ); + +} /* End of SBI_DisplayBlockCheckpoint */ + + + +/* + * SBI_DisplayBlockVolumeLoggedDataBlock() - + * + * Return - + * We don't set nextBlockHint because really nothing to set it to. + */ +STATUS SBI_DisplayBlockVolumeLoggedDataBlock( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + NINT i; + + for ( i = 0; ZED_LoggedVolumeDataBlock[i].DFI_Type != DFI_TYPE_END; i++ ) + { + DFI_Display( co, &ZED_LoggedVolumeDataBlock[i], block, ZED_LoggedVolumeDataBlock[i].DFI_Offset ); + } +// *nextBlockHint = superblockHeader->hdr.SBH_SystemBeastBlkNum; + + return( zOK ); + +} /* End of SBI_DisplayBlockVolumeLoggedDataBlock() */ + + + +/* + * SBI_DisplayBlockVolumeDataBlock() - + * + * Return - + * We set nextBlockHint to LVDB. That way the VDB and LVDB + * can be displayed with one command (i.e. display the VDB). + */ +STATUS SBI_DisplayBlockVolumeDataBlock( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + LONG checksum; + NINT i; + ZfsVolumeBlock_s *vdb = (void *)block; + + checksum = ZED_SuperBlockHeaderCalculateChecksum( (LONG *)vdb, sizeof(*vdb)/4 ); + if ( checksum != 0 ) + { + LONG checksumOriginal; + checksumOriginal = vdb->ZVD_zfsVol.PZV_checksum; + printf(" Checksum is not correct - Value is 0x%lx\n", checksumOriginal ); + vdb->ZVD_zfsVol.PZV_checksum = 0; + checksum = ZED_SuperBlockHeaderCalculateChecksum( (LONG *)vdb, sizeof(*vdb)/4 ); + printf(" Checksum should have been 0x%lx\n", 0-checksum ); + /* Replace original checksum so that we display VDB as it really is */ + vdb->ZVD_zfsVol.PZV_checksum = checksumOriginal; + } + else + { + printf(" Checksum is valid\n" ); + } + + for ( i = 0; ZED_VolumeDataBlock[i].DFI_Type != DFI_TYPE_END; i++ ) + { + DFI_Display( co, &ZED_VolumeDataBlock[i], block, ZED_VolumeDataBlock[i].DFI_Offset ); + } + *nextBlockHint = vdb->ZVD_zfsVol.PZV_loggedVolumeDataBlk; + + return( zOK ); + +} /* End of SBI_DisplayBlockVolumeDataBlock() */ + + +/* + * SBI_DisplayBlockPurgeLog() - + * + * Return - + * We set nextBlockHint to the next block. + */ +STATUS SBI_DisplayBlockPurgeLog( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) + +{ + STATUS status = zOK; + unsigned int type; + unsigned int entry; + BYTE *buffer; + PurgeLogEntry_s *logEntry; + PurgeLogBlock_s *plb = (void *)block; + char *tag = "data"; + +// SNP_snprintf( WHERE, pb, "
\n" ); + DFI_DisplayStructure( co, ZED_PurgeLogBlock, (BYTE *)plb ); + *nextBlockHint = plb->nextBlock; +// SNP_snprintf( WHERE, pb, "
\n" ); +// SNP_snprintf( WHERE, pb, "\n" ); + DFI_Display_Header_ARRAY( co, tag, "PurgeLogEntry_s", MAX_PURGE_LOG_ENTRIES, + MAX_PURGE_LOG_ENTRIES * sizeof( *logEntry ), &plb->logEntry[0] ); + for ( entry = 0; entry < MAX_PURGE_LOG_ENTRIES; ++entry ) + { + logEntry = &plb->logEntry[entry]; + buffer = (BYTE *)(&logEntry->info); + type = logEntry->type; +// SNP_snprintf( WHERE, pb, "\n", entry ); + + DFI_Display_Header_Structure( co, tag, "PurgeLogEntry_s", entry, MAX_PURGE_LOG_ENTRIES, sizeof( *logEntry ), logEntry ); + DFI_DisplayStructure( co, ZED_PurgeLogEntry, (BYTE *)logEntry ); + /* This is a little wierd because PurgeLogInfo_s is a UNION, but + * we display the correct item because we know about 'type'. + */ + DFI_Display_Header_Structure( co, "info", "PurgeLogInfo_s", 0, 0, sizeof( PurgeLogInfo_s ), buffer ); + switch( type ) + { + case PLOG_UNUSED: + DFI_Display_Header_Structure( co, "free", "FreeEntry_s", 0, 0, sizeof( FreeEntry_s ), buffer ); + DFI_DisplayStructure( co, ZED_FreeEntry, buffer ); + DFI_Display_Tail_Structure( co, "FreeEntry_s", sizeof( FreeEntry_s ), buffer ); + break; + case PLOG_BEAST_DELETE: + DFI_Display_Header_Structure( co, "beast", "PurgeBeastEntry_s", 0, 0, sizeof( PurgeBeastEntry_s ), buffer ); + DFI_DisplayStructure( co, ZED_PurgeBeastEntry, buffer ); + DFI_Display_Tail_Structure( co, "PurgeBeastEntry_s", sizeof( PurgeBeastEntry_s ), buffer ); + break; + case PLOG_TRUNCATE: + DFI_Display_Header_Structure( co, "trunc", "TruncateEntry_s", 0, 0, sizeof( TruncateEntry_s ), buffer ); + DFI_DisplayStructure( co, ZED_TruncateEntry, buffer ); + DFI_Display_Tail_Structure( co, "TruncateEntry_s", sizeof( TruncateEntry_s ), buffer ); + break; + case PLOG_BLOCK_FREE: + DFI_Display_Header_Structure( co, "block", "PurgeBlockEntry_s", 0, 0, sizeof( PurgeBlockEntry_s ), buffer ); + DFI_DisplayStructure( co, ZED_PurgeBlockEntry, buffer ); + DFI_Display_Tail_Structure( co, "PurgeBlockEntry_s", sizeof( PurgeBlockEntry_s ), buffer ); + break; + case PLOG_BEAST_COMP_CLEANUP: /* Note - comp uses same record as PLOG_BEAST_DELETE */ + DFI_Display_Header_Structure( co, "beast", "PurgeBeastEntry_s", 0, 0, sizeof( PurgeBeastEntry_s ), buffer ); + DFI_DisplayStructure( co, ZED_PurgeBeastEntry, buffer ); + DFI_Display_Tail_Structure( co, "PurgeBeastEntry_s", sizeof( PurgeBeastEntry_s ), buffer ); + break; + case PLOG_FIX_VISIBILITY: + DFI_Display_Header_Structure( co, "visib", "FixVisEntry_s", 0, 0, sizeof( FixVisEntry_s ), buffer ); + DFI_DisplayStructure( co, ZED_FixVisEntry, buffer ); + DFI_Display_Tail_Structure( co, "FixVisEntry_s", sizeof( FixVisEntry_s ), buffer ); + break; + case PLOG_SCAN_USER_NAMES: + DFI_Display_Header_Structure( co, "userScan", "UserScanEntry_s", 0, 0, sizeof( UserScanEntry_s ), buffer ); + DFI_DisplayStructure( co, ZED_UserScanEntry, buffer ); + DFI_Display_Tail_Structure( co, "UserScanEntry_s", sizeof( UserScanEntry_s ), buffer ); + break; + case PLOG_REMOVE_USER_TREE: + DFI_Display_Header_Structure( co, "user", "UserEntry_s", 0, 0, sizeof( UserEntry_s ), buffer ); + DFI_DisplayStructure( co, ZED_UserEntry, buffer ); + DFI_Display_Tail_Structure( co, "UserEntry_s", sizeof( UserEntry_s ), buffer ); + break; + case PLOG_CLEAR_USED_AMOUNT: + DFI_Display_Header_Structure( co, "userClear", "UserClearEntry_s", 0, 0, sizeof( UserClearEntry_s ), buffer ); + DFI_DisplayStructure( co, ZED_UserClearEntry, buffer ); + DFI_Display_Tail_Structure( co, "UserClearEntry_s", sizeof( UserClearEntry_s ), buffer ); + break; + case PLOG_REMOVE_DIR_TREE: + DFI_Display_Header_Structure( co, "directory", "DirEntry_s", 0, 0, sizeof( DirEntry_s ), buffer ); + DFI_DisplayStructure( co, ZED_DirEntry, buffer ); + DFI_Display_Tail_Structure( co, "DirEntry_s", sizeof( DirEntry_s ), buffer ); + break; + case PLOG_DIR_QUOTA_USED: + DFI_Display_Header_Structure( co, "dirUsed", "DirUsed_s", 0, 0, sizeof( DirUsed_s ), buffer ); + DFI_DisplayStructure( co, ZED_DirUsedEntry, buffer ); + DFI_Display_Tail_Structure( co, "DirUsed_s", sizeof( DirUsed_s ), buffer ); + break; + default: + status = zFAILURE; + printf("Unknown Purge Log Entry type %d.\n", type ); + break; + } + DFI_Display_Tail_Structure( co, "PurgeLogInfo_s", sizeof( PurgeLogInfo_s ), buffer ); + DFI_Display_Tail_Structure( co, "PurgeLogEntry_s", sizeof( *logEntry ), logEntry ); +// SNP_snprintf( WHERE, pb, "\n" ); + } +// SNP_snprintf( WHERE, pb, "\n" ); + DFI_Display_Tail_ARRAY( co, tag, "PurgeLogEntry_s" ); + return( status ); + +} /* End of SBI_DisplayBlockPurgeLog() */ + + + +/* + * SBI_DisplayBlockMyBTreeLeaf() - + * + * Return - + * nextBlockHint + */ +STATUS SBI_DisplayBlockMyBTreeLeaf( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + int rc; + MYBTreeNode_s *myBTree = (void *)block; + PurgeNewInfo_s *entry; + NINT i; + + DFI_Display_Header_Structure( co, "TheBlock", "MYBTreeNode_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + for ( i = 0; ZED_MyBTreeLeaf[i].DFI_Type != DFI_TYPE_END; i++ ) + { + DFI_Display( co, &ZED_MyBTreeLeaf[i], block, ZED_MyBTreeLeaf[i].DFI_Offset ); + } + *nextBlockHint = myBTree->n.leaf.nextLeaf; + entry = (PurgeNewInfo_s *)&myBTree->n.leaf.vv_entry; + ZSD_Display_Struct_PurgeNewInfo_s_ARRAY( co, "entry", myBTree->numRecs, entry ); + rc = DFI_Display_Tail_Structure( co, "MYBTreeNode_s", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( zOK ); + +} /* End of SBI_DisplayBlockMyBTreeLeaf() */ + + +/* + * SBI_DisplayBlockMyBTreeBranch() - + * + * Return - + * We don't set nextBlockHint because really nothing to set it to. + */ +STATUS SBI_DisplayBlockMyBTreeBranch( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + int rc; + MYBTreeNode_s *myBTree = (void *)block; + NINT i; + MYBTBranchEntry_s *entry; +// PurgeQNewKey_s *key; + + DFI_Display_Header_Structure( co, "TheBlock", "MYBTreeNode_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, block ); + for ( i = 0; ZED_MyBTreeBranch[i].DFI_Type != DFI_TYPE_END; i++ ) + { + DFI_Display( co, &ZED_MyBTreeBranch[i], block, ZED_MyBTreeBranch[i].DFI_Offset ); + } + entry = (MYBTBranchEntry_s *)&myBTree->n.branch.v_entry; + ZSD_Display_Struct_MYBTBranchEntry_s_ARRAY( co, "entry", myBTree->numRecs, entry ); + rc = DFI_Display_Tail_Structure( co, "MYBTreeNode_s", DFI_VARIABLE_SIZE_INKNOWN, block ); + return( rc ); + +} /* End of SBI_DisplayBlockMyBTreeBranch() */ + +/* + * SBI_DisplayBlockPT() - + * Displays purge tree blocks that are based on the + * MYBTree code. These are the new PT Format Sai added + * in NW6.0 so that he could use the MYBTREE code. + * + * Return - + * nextBlockHint (Leaf only) + */ +STATUS SBI_DisplayBlockPT( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + STATUS status; + MYBTreeNode_s *myBTree = (void *)block; + + if ( MYBT_IS_LEAF( myBTree ) ) + { + status = SBI_DisplayBlockMyBTreeLeaf( sbi, block, co, nextBlockHint ); + } + else + { + status = SBI_DisplayBlockMyBTreeBranch( sbi, block, co, nextBlockHint ); + } + return( status ); + +} /* End of SBI_DisplayBlockPT() */ + + +/* + * SBI_DisplayBlockPoolLoggedDataBlock() - + * + * Return - + * We don't set nextBlockHint because really nothing to set it to. + */ +STATUS SBI_DisplayBlockPoolLoggedDataBlock( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + NINT i; + + for ( i = 0; ZED_LoggedPoolDataBlock[i].DFI_Type != DFI_TYPE_END; i++ ) + { + DFI_Display( co, &ZED_LoggedPoolDataBlock[i], block, ZED_LoggedPoolDataBlock[i].DFI_Offset ); + } +// *nextBlockHint = superblockHeader->hdr.SBH_SystemBeastBlkNum; + + return( zOK ); + +} /* End of SBI_DisplayBlockPoolLoggedDataBlock() */ + + +/* + * SBI_DisplayBlockPoolDataBlock() - + * + * Return - + * We set nextBlockHint to LPDB. That way the VDB and LVDB + * can be displayed with one command (i.e. display the VDB). + */ +STATUS SBI_DisplayBlockPoolDataBlock( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + LONG checksum; + NINT i; + ZlssPoolBlock_s *pdb = (void *)block; + + checksum = ZED_SuperBlockHeaderCalculateChecksum( (LONG *)pdb, sizeof(*pdb)/4 ); + if ( checksum != 0 ) + { + printf(" Checksum is not correct\n" ); + } + else + { + printf(" Checksum is valid\n" ); + } + + for ( i = 0; ZED_PoolDataBlock[i].DFI_Type != DFI_TYPE_END; i++ ) + { + DFI_Display( co, &ZED_PoolDataBlock[i], block, ZED_PoolDataBlock[i].DFI_Offset ); + } + *nextBlockHint = pdb->ZPB_zlssPool.PZP_loggedPoolDataBlk; + + return( zOK ); + +} /* End of SBI_DisplayBlockPoolDataBlock() */ + + +STATUS SBI_DisplayBlockSuperBlockHeader( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + LONG checksum; + NINT i; + MediaSuperBlockHeader_s *superblockHeader = (void *)block; + + /* Calculate the checksum. Checksum will equal zero if correct. + * Note that we use size on disk so we can verify checksum in older + * or newer superblocks. If we do not understand the older/newer + * format our version check will catch. This gives the user a better + * error than a checksum error because of a size change. + */ + checksum = ZED_SuperBlockHeaderCalculateChecksum( + (LONG *)superblockHeader, + superblockHeader->hdr.SBH_PackedSize/4 ); + if ( checksum != 0 ) + { /* Checksum error on checkpoint */ + printf(" Checksum is not correct\n" ); + } + else + { + printf(" Checksum is valid\n" ); + } + + for ( i = 0; ZED_SuperBlockHeader[i].DFI_Type != DFI_TYPE_END; i++ ) + { + DFI_Display( co, &ZED_SuperBlockHeader[i], block, ZED_SuperBlockHeader[i].DFI_Offset ); + } + *nextBlockHint = superblockHeader->hdr.SBH_SystemBeastBlkNum; + + return( zOK ); +} + + +/************************************************************************** + * ZED_CheckpointCalculateChecksum() - Calculate a checksum on a + * buffer of LONGs. + ***************************************************************************/ +LONG ZED_CheckpointCalculateChecksum( + LONG *buffer, + NINT numberOfLONGs ) +{ + + LONG checksum; + + checksum = 0; + for ( ; numberOfLONGs != 0 ; --numberOfLONGs ) + { + checksum += *buffer; + ++buffer; + } + /* We do not want a checksum of a zeroed block to be 0 */ + return( checksum + 1 ); +} + +/* + * ZED_SuperBlockHeaderCalculateChecksum() - + * Calculate a checksum on a buffer of LONGs. + */ +LONG ZED_SuperBlockHeaderCalculateChecksum( + LONG *buffer, + NINT numberOfLONGs ) +{ + LONG checksum; + + checksum = 0; + for ( ; numberOfLONGs != 0 ; --numberOfLONGs ) + { + checksum += *buffer; ++buffer; + } + /* We do not want a checksum of a zeroed block to be 0 */ + return( checksum + 1 ); +} + + +STATUS SBI_DisplayBlockDefault( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + SNP_PrintBuffer_s *pb = co->DCO_SNPOutput; + + SNP_snprintf( WHERE, pb, "\n" ); + printf( "No block handler for %s(magic=%lx) Hex dump to follow\n\n", sbi->SSBI_name, sbi->magic ); + ZED_HexDump( block, 4096, 4 ); + return( zOK ); + +} /* End of SBI_DisplayBlockDefault() */ + + +void SBI_DisplayBlockHex( + SNP_PrintBuffer_s *pb, + BYTE *block ) + +{ /* FixFixFix - Should use pb and dump in LEGAL XML format + * MAYBE we should just return to caller the BINARY data and + * they can do what they want for a HEX dump I.E. + * it does not need to be XML + */ + +// SNP_snprintf( WHERE, pb, "" ); + printf( "User data(Hex dump to follow)\n\n" ); + ZED_HexDump( block, 4096, 4 ); + return; + +} /* End of SBI_DisplayBlockHex() */ + +/* + * ZED_HexDump + * userArea Pointer to memory to dump. + * len Number of BYTEs to dump. If <= 0 nothing is printed. + * size 1, 2, or 4 for BYTE, WORD or LONG + * + * Dumps a range of memory to the debug device. Currently only supports + * a BYTE dump with the ASCII equivalent displayed on the right. + * + * + * 00000000 45 45 45 45 45 45 45 45 | 45 45 45 45 45 41 41 41 EEEEEEEEEEEEEAAA + * 00000010 45 45 45 45 45 45 45 45 | 45 45 45 45 45 00 01 02 EEEEEEEEEEEEE... + * 00000020 45 45 45 45 45 45 45 45 | 45 45 45 45 45 45 45 45 EEEEEEEEEEEEEEEE + * ^ ^ ^ + * | | Column 60 (DHD_COLUMN_ASCII) + * | Column 10 (DHD_COLUMN_HEX) + * Column 0 (DHD_COLUMN_OFFSET) + */ + + +/* FixFixFix this needs to dump LEGAL xml into a 'SNP' object */ + +#define DHD_COLUMN_OFFSET 0 +#define DHD_COLUMN_HEX 10 +#define DHD_COLUMN_ASCII 60 + +void ZED_HexDump( + void *userArea, + int length, + int size ) + +{ + int column; + char viewLine[81]; + int len; + int digit; + + if ( length <= 0 ) + { + return; + } + memset( &viewLine[0], ' ', 79 ); + viewLine[79] = 0; + column = 0; + for ( len = 0; len < length; ++column, len += size ) + { + if ( column == (16/size) ) + { + printf( "%s\n", &viewLine[0] ); + memset( &viewLine[0], ' ', 79 ); + column = 0; + } + if ( column == 0 ) + { /* We have chossen to display the OFFSET verses the address */ + sprintf( &viewLine[DHD_COLUMN_OFFSET], "%08lx", len ); + viewLine[DHD_COLUMN_OFFSET + 8] = ' '; + } + if ( column == (8/size) ) + { + viewLine[column*3*size + DHD_COLUMN_HEX + 0] = '|'; + viewLine[column*3*size + DHD_COLUMN_HEX + 1] = ' '; + } + + switch ( size ) + { + case 4: + sprintf( &viewLine[(column/(8/size))*2 + (column*3*size) + DHD_COLUMN_HEX], + "%08x", *(LONG *)userArea ); + break; + case 2: + sprintf( &viewLine[(column/(8/size))*2 + (column*3*size) + DHD_COLUMN_HEX], + "%04x", *(WORD *)userArea ); + break; + default: + sprintf( &viewLine[(column/(8/size))*2 + (column*3*size) + DHD_COLUMN_HEX], + "%02x", *(BYTE *)userArea ); + } + + viewLine[(column/(8/size))*2 + (column*3*size+2*size) + DHD_COLUMN_HEX] = ' '; + for ( digit = 0; digit < size; ++digit ) + { + /* Fill in ASCII portion. This is the range that ZED does. */ + if( ( *(unsigned char *)userArea > 0x19) && ( *(unsigned char *)userArea < 0x80) ) + { + viewLine[column*size+digit+DHD_COLUMN_ASCII] = *(char *)userArea; + } + else + { + viewLine[column*size+digit+DHD_COLUMN_ASCII] = '.'; + } + userArea = ((char *)userArea) + 1; + } + } + + printf( "%s\n", &viewLine[0] ); + return; + +} /* End of ZED_HexDump() */ + + +/* + * SSBI_displayBlock() - + * Common routine to display a block. This enables us to put 'headers' + * and 'tails' so that all blocks have the same high level format. + */ +STATUS SSBI_displayBlock( + struct ZED_SystemBlockInfo_s *sbi, + BYTE *buffer, + struct SNP_PrintBuffer_s *pb, + Blknum_t currentBlock, + Blknum_t *nextBlockHint, + void *localAddress, + void *sourceAddress, + Zid_t zid ) +{ + DFI_CallerOptions_s *co; + STATUS rc; + + co = DFI_Open( pb, pb, DCO_OUTPUT_TYPE_XML, DCO_DETAILS_FULL, 0, 0, localAddress, sourceAddress ); +// co = DFI_Open( pb, pb, DCO_OUTPUT_TYPE_XML, DCO_DETAILS_BRIEF, 0, 0, localAddress, sourceAddress ); + if ( co == NULL ) + { + return( 19999 ); + } + co->DCO_Zid = zid; + +// SNP_snprintf( WHERE, pb, "\n" ); + SNP_snprintf( WHERE, pb, + "\n", + "ZLSS", currentBlock, "System", sbi->SSBI_name ); +// SNP_snprintf( WHERE, pb, "\n" ); +// ZSD_Display_Type_Blknum_t( co, "BlockNumber", ¤tBlock ); +// SNP_snprintf( WHERE, pb, "\n", currentBlock ); +// SNP_snprintf( WHERE, pb, "
\n", +// currentBlock, "System", sbi->SSBI_name ); +// SNP_snprintf( WHERE, pb, "\n", "System" ); +// SNP_snprintf( WHERE, pb, "\n", sbi->SSBI_name ); +// SNP_snprintf( WHERE, pb, "\n" ); +// SNP_snprintf( WHERE, pb, "\n" ); +// SNP_HexDump( WHERE, pb, buffer, 4096, 4 ); +// SNP_snprintf( WHERE, pb, "\n" ); +// SNP_snprintf( WHERE, pb, "\n" ); + rc = sbi->SSBI_displayBlock( sbi, buffer, co, nextBlockHint ); +// SNP_snprintf( WHERE, pb, "\n" ); + rc = SNP_snprintf( WHERE, pb, "\n" ); + (void)DFI_Close( co ); + return rc; + +} /* End of SSBI_displayBlock() */ + + +/* + * SBI_DisplayBlockZlss() - + * Main routine to display a ZLSS System Block from within + * NetWare's assembly debugger. Routine does NOT actually display + * the block. The output all goes into the 'co' object. The + * caller can then display, parse or etc. + * + * Warning - + * The display code does NOT validate the ZLSS System Block. + * This will cause an ABEND if the block is invalid. The code + * was designed this way because it was originally run from + * a NT Client so preventing crashes was not worth the time + * to hack up validate routines. + * + * FixFixFix - + * We should call validate routines so not to pass invalid + * blocks to the display routines. Se WARNING above. + * Note that the beast tree validate routines do NOT validate + * the packed beasts. The display routines can still ABEND. + * Oneeasy to implement solution may be to add a flag to 'co' + * and then add LOTS of address validation. 'co' could also hold + * the end of the valid 4K buffer. Beware of code that assumes + * that a string has a '\0'. A corrupt block may not!!! Maybe DFI_Display + * or lower could check address, string and etc. + * + */ +STATUS SBI_DisplayBlockZlss( + DFI_CallerOptions_s *co, + BYTE *buffer ) /* A 4K block */ +{ + STATUS rc; + struct ZED_SystemBlockInfo_s *sbi; + Blknum_t nextBlockHintDummy; + + /* See if this is a system block (we look at MAGIC at offset 0 of block) */ + sbi = SBI_SystemBlock( buffer ); + if ( sbi == NULL ) + { /* Not a system block - do a hex dump */ +// printf("Block %ld is not a system block\n", blockNumber); + SNP_snprintf( WHERE, co->DCO_SNPOutput, + "\n", + "ZLSS", 0, "User" ); + SBI_DisplayBlockHex( co->DCO_SNPOutput, buffer ); + rc = SNP_snprintf( WHERE, co->DCO_SNPOutput, "\n" ); + return( rc ); + } + /* + * This is a system block so place XML information into th 'co'. + */ + SNP_snprintf( WHERE, co->DCO_SNPOutput, + "\n", + "ZLSS", 0, "System", sbi->SSBI_name ); + rc = sbi->SSBI_displayBlock( sbi, buffer, co, &nextBlockHintDummy ); + rc = SNP_snprintf( WHERE, co->DCO_SNPOutput, "\n" ); + return rc; + +} /* End of SBI_DisplayBlockZlss() */ + diff --git a/src/nwnss/zlss/sbiNT.c b/src/nwnss/zlss/sbiNT.c new file mode 100644 index 0000000..5efed97 --- /dev/null +++ b/src/nwnss/zlss/sbiNT.c @@ -0,0 +1,555 @@ +/**************************************************************************** + | + | (C) Copyright 2001 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | ZlogGet - Utility to read the ZLOG file from the _ADMIN volume. + | + |--------------------------------------------------------------------------- + | + | $Author: blarsen $ + | $Date: 2006-01-21 04:09:53 +0530 (Sat, 21 Jan 2006) $ + | + | $RCSfile$ + | $Revision: 1315 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Reads the ZLOG Beasts via the _ADMIN volume + / + / Warning - This file is used by NT Utilities like zedRemote, ZlogGet and + / etc. DO NOT ADD NSS specific code. The define NTLIB is only defined + / when source file is compiled with NT Utilities. + +-------------------------------------------------------------------------*/ +#include +#include +#include +#include +//#include +//#include +//#include + /* + * By defining this we will match the .LOG file produced by + * UNSS.NLM. This is because we store the complete memory copy + * of the ZLOG Beast as the header to the .LOG file in addition + * to having a copy of all checkpoints (the memory copy of the + * ZLOG Beast again) when the checkpoints are taken. + */ +//#define UNOPT + /* This next define helps asyncio.h */ +#ifdef NTLIB +#define _NWGREENRIVER_ +#endif + +#undef errno +#include "zParams.h" +#include "zError.h" + +#include "comnPublics.h" +#include "guid.h" + +#include "zfs.h" +#include "nameTree.h" + + + +#include "dfi.h" +#include "sbi.h" +#include "snp.h" +//#define SAI_NT /* NT has SAME typedef names as BT */ +#include "sdZLSS.h" +//#include "ntXML.h" + +#include "register.h" +#ifdef NTLIB +#include "mscIDE.h" +#endif + + +void SBI_PRINT_LENTRY( + DFI_CallerOptions_s *co, + NameTreeParms_s *parms, Leaf_s *e, SNINT idx); +extern void SBI_dir_dumpnode( DFI_CallerOptions_s *co, NameTreeParms_s *parms, void *buf ); +#if 0 +extern STATUS SBI_dir_dump(NameTreeParms_s *parms, Blknum_t nextchild, + SNINT idx); /* Indent index */ +extern STATUS dir_ls(NameTreeParms_s *parms, Blknum_t nextchild); +#endif + +//#define PRINT_FNAME(_name) printf( "%S", _name) /* Watcom is %S NetWare is %U */ + + +DFI_DataFormatInformation_s ZED_NameTreeHeader[] = { + { DFI_TYPE_LONG , NULL, offsetof( Node_s, magic ), "magic", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( Node_s, state ), "state", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( Node_s, numRecs ), "numRecs", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( Node_s, vers ), "vers", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( Node_s, n_internalID ), "n_internalID", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( Node_s, u.ovflow_blk ), "ovflow_blkORnextleaf", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( Node_s, child_blk ), "child_blk", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Node_s, nfreebytes ), "nfreebytes", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( Node_s, nextfree ), "nextfree", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( Node_s, padbytes ), "padbytes", 1, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +#if 0 +#define NT_LEAF 0x1 /* Leaf node of a B-tree */ +#define NT_BRANCH 0x2 /* Branch node of a B-tree */ +#define NT_ROOT 0x4 /* Root node of a B-tree */ +#define NT_OVERFLOW 0x8 /* Overflow node (could be branch or leaf) */ +#define NT_FREE 0x10 /* Node is free */ + +#define NT_LEAF_OVFLOW (NT_LEAF|NT_OVERFLOW) /* to hold duplicate keys */ +#define NT_BRANCH_OVFLOW (NT_BRANCH|NT_OVERFLOW) + +#define IS_LEAF(_n) ((_n)->state & NT_LEAF) +#define IS_BRANCH(_n) ((_n)->state & NT_BRANCH) +#define IS_LEAF_OVFLOW(_n) \ + (((_n)->state & NT_LEAF_OVFLOW) == NT_LEAF_OVFLOW) +#define IS_BRANCH_OVFLOW(_n) \ + (((_n)->state & NT_BRANCH_OVFLOW) == NT_BRANCH_OVFLOW) +#define IS_FREE(_n) ((_n)->state & NT_FREE) +#define NT_IS_ROOT(_n) ((_n)->state & NT_ROOT) +#endif + + + + +#define INDENT_STEP 4 +#define OVERFLOW_BIAS 10000 + + +int ZSD_Display_Struct_dir_key_s( + DFI_CallerOptions_s *co, + dir_key_s *key ) + +{ + SNP_PrintBuffer_s *pb = co->DCO_SNPOutput; + int rc; + + SNP_snprintf( WHERE, pb, "\n" ); + ZSD_Display_Type_Zid_t( co, "pzid", &key->pzid ); + ZSD_Display_Type_Zid_t( co, "zid", &key->zid ); + ZSD_Display_Type_WORD( co, "nameType", &key->nameType ); +#if 0 +#define zNTYPE_FILE 0 +#define zNTYPE_DATA_STREAM 1 +#define zNTYPE_EXTENDED_ATTRIBUTE 2 +#define zNTYPE_DELETED_FILE 3 +#endif + { + WORD save; + + save = key->namelen; + ZSD_Display_Type_WORD( co, "namelen", &key->namelen ); + key->namelen = save & NAMEnameLenMask; + ZSD_Display_Type_WORD( co, "namelenLENGTH", &key->namelen ); + key->namelen = save & ~NAMEnameLenMask; + ZSD_Display_Type_WORD( co, "namelenFLAGS", &key->namelen ); + key->namelen = save; + } +#if 0 +#define NAMEforcedUpper 0x8000 /* The name was created by a name space that + * forced it to upper case. */ +#define NAMEovflow 0x4000 /* duplicate names stored in fflow + * blocks (ZFS naming B-tree-specific) */ +#define NAMEdup 0x2000 /* Duplicate names exist + * (ZFS naming B-tree-specific) */ +#define NAMEool 0x1000 /* name field points to an out-of-line + * array (ZFS naming B-tree-specific) */ +#define NAMEnameLenMask 0x0fff /* mask used to remove flags from nameLen + * when it is brought in from disk (the + * upper 4 bits are available) */ +#endif + /* Saw a case in NSS 2.7x Name Tree where array Elements 0, + * but no string. Can not tell STRing routine that a string + * has no elements (it attempts to display a non-array + * unicode char which in above case came out to 0 which + * then cause use to thing the SNP buffer has ended + * because of the NULL terminator. + */ + if ( ((unsigned int)key->namelen & NAMEnameLenMask) != 0 ) + { + ZSD_Display_Type_unicode_t_STR( co, "name", (unsigned int)key->namelen & NAMEnameLenMask, &key->name[0] ); + } + rc = SNP_snprintf( WHERE, pb, "\n" ); + return( rc ); + +} /* End of ZSD_Display_Struct_dir_key_s() */ + + +void print_single_lentry( + DFI_CallerOptions_s *co, + Leaf_s *_l ) + +{ + SNP_PrintBuffer_s *pb = co->DCO_SNPOutput; + + SNP_snprintf( WHERE, pb, "\n" ); + ZSD_Display_Type_SLONG( co, "size", &_l->size ); + ZSD_Display_Type_LONG( co, "ns_mask", &_l->ns_mask ); + ZSD_Display_Type_Zid_t( co, "zid", &_l->zid ); + ZSD_Display_Type_WORD( co, "oldNameUniquifier", &_l->oldNameUniquifier ); + ZSD_Display_Type_BYTE( co, "matchAttributes", &_l->matchAttributes ); + ZSD_Display_Type_BYTE( co, "miscFlags", &_l->miscFlags ); + ZSD_Display_Type_LONG( co, "reserved2", &_l->reserved2 ); + ZSD_Display_Struct_dir_key_s( co, &_l->k ); + SNP_snprintf( WHERE, pb, "\n" ); + +} + +void print_single_bentry( + DFI_CallerOptions_s *co, + Branch_s *_b ) +{ + SNP_PrintBuffer_s *pb = co->DCO_SNPOutput; + + SNP_snprintf( WHERE, pb, "\n" ); + ZSD_Display_Struct_dir_key_s( co, &_b->k ); + ZSD_Display_Type_SLONG( co, "size", &_b->size ); + ZSD_Display_Type_Blknum_t( co, "child_blk", &_b->child_blk ); + SNP_snprintf( WHERE, pb, "\n" ); + +} /* End of print_single_bentry() */ + + +void print_single_bentryoverflow( + DFI_CallerOptions_s *co, + Ovflow_op_data_t *of, + Branch_s *b ) +{ + SNP_PrintBuffer_s *pb = co->DCO_SNPOutput; + + SNP_snprintf( WHERE, pb, "\n" ); + ZSD_Display_Type_SLONG( co, "index", (SLONG *)&of->ind ); + ZSD_Display_Type_SLONG( co, "replace", (SLONG *)&of->replace ); + print_single_bentry( co, b ); + SNP_snprintf( WHERE, pb, "\n" ); + +} /* End of print_single_bentryoverflow() */ + + +/* + * Dump contents of a node of B-tree directory. + * dirznode must be locked atleast SHARED. + */ +void SBI_dir_dumpnode( + DFI_CallerOptions_s *co, + NameTreeParms_s *parms, void *block) +{ + Node_s *node; + BOOL iam_overflow; + WORD i; + +// node = (Node_s *)buf->pBuf.data; + node = block; + + if (IS_LEAF(node)) /* Leaf Node */ + { + Leaf_s *e; + + iam_overflow = IS_LEAF_OVFLOW(node); + printf( "Leaf %s blk# %d: %d recs, %d freebytes, next leaf blk# %d\n", + iam_overflow ? "overflow" : "", 0x12345678/*buf->BUFblknum*/, node->numRecs, + node->nfreebytes, node->u.nextleaf); + + if (iam_overflow) { + e = (Leaf_s *)node->padbytes; + for (i=0; i < node->numRecs; ++ i) + { + print_single_lentry(co,e); + e = (Leaf_s *)((char *)e + LEAF_ENTRY_SIZE(e)); + } + } + else + for (i = 0; i < node->numRecs; ++i) + { + e = LEAF_ENTRY(node, i); + printf( "%d: size %d, ", i, LEAF_ENTRY_SIZE(e) ); + SBI_PRINT_LENTRY( co, parms, e, 0 ); + } + } + else /* Branch node */ + { + zASSERT(IS_BRANCH(node)); + iam_overflow = IS_BRANCH_OVFLOW(node); + printf( "Branch blk# %d: %d recs, %d freebytes, lchild# %d\n", + 0x12345678/*buf->BUFblknum*/, node->numRecs, node->nfreebytes, + node->child_blk); + + if (NODE_OVFLOW(node)) + { + printf( "ovflow blk# %d\n", node->u.ovflow_blk); + } + + if (iam_overflow) + { + for (i=0; i < node->numRecs; ++ i) + { + Branch_s *e = BRANCH_ENTRY(node, i); + Ovflow_op_data_t *of = OVFLOW_OP_DATA(e); + + printf( "%d: size %d, ", i, BRANCH_ENTRY_SIZE(e) ); + print_single_bentryoverflow( co, of, e ); + } + } + else + { + for (i = 0; i < node->numRecs; ++i) + { + Branch_s *e = BRANCH_ENTRY(node, i); + printf( "%d: size %d, ", i, BRANCH_ENTRY_SIZE(e) ); + print_single_bentry( co, e ); + } + } + } +} + + +void SBI_PRINT_LENTRY( + DFI_CallerOptions_s *co, + NameTreeParms_s *parms, Leaf_s *e, SNINT idx) +{ + SNINT esize; + Dupinfo_s *di; + print_single_lentry(co,e); + if (! (e->k.namelen & NAMEdup)) + return; + esize = ENTRYSIZE_FROM_KEY(&e->k, LEAF_DATASIZE); + di = (Dupinfo_s *)((char *)e + esize); + idx += INDENT_STEP; + if (e->k.namelen & NAMEovflow) + { +#if 0 +// +// At this time we do not parse overflow Leaf as it would force +// us to READ in another leaf. +// + Blknum_t ovflow_blk = di->ovflow_blk; + while (ovflow_blk != INVALID_BLK) + { + Buffer_s *buf; + Node_s *node; + SNINT i; + if (! parms) return; + if (FETCH_NTREE_BLK_DEBUG(parms, ovflow_blk, &buf, 48) != zOK) + return; + node = (Node_s *) buf->pBuf.data; +// do_indent(idx); + printf( "[ Leaf ovflow blk# %d: %d recs, %d freebytes, next blk# %d\n", + buf->BUFblknum, node->numRecs, node->nfreebytes, node->u.nextleaf); + e = (Leaf_s *)node->padbytes; + idx += INDENT_STEP; + for (i=0; i < node->numRecs; ++ i) + { +// do_indent(idx); + print_single_lentry(e); + e = (Leaf_s *)((char *)e + LEAF_ENTRY_SIZE(e)); + } + idx -= INDENT_STEP; + ovflow_blk = node->u.nextleaf; + RELEASE_NTREE_BLK_DEBUG(parms, buf); + } +#endif + } + else + { + SNINT i, ndups = di->nduplicates; + printf( "%d duplicates:\n", ndups ); + e = (Leaf_s *)((char *)di + sizeof(Dupinfo_s)); + for (i=0; i < ndups; ++ i) + { +// do_indent(idx); + print_single_lentry(co,e); + e = (Leaf_s *)((char *)e + LEAF_ENTRY_SIZE(e)); + } + } +} + +#if 0 +/* + * Print the subtree rooted at given B-Tree node + */ +STATUS SBI_dir_dump( + NameTreeParms_s *parms, + Blknum_t nextchild, + SNINT idx) /* Indent index */ +{ + Buffer_s *buf; + Node_s *node; + WORD i; + SNINT iam_overflow = (idx < 0); + if (idx < 0) idx += OVERFLOW_BIAS; + + + if (nextchild == INVALID_BLK) + return zERR_NAME_NOT_FOUND_IN_DIRECTORY; + else if (FETCH_NTREE_BLK_DEBUG(parms, nextchild, &buf, 47) != zOK) + return zOUT_OF_BUFFERS; + + node = (Node_s *)buf->pBuf.data; + + if (IS_LEAF(node)) { /* Leaf Node */ + do_indent(idx); + printf( "[ Leaf blk# %d: %d recs, %d freebytes, nextleaf blk# %d\n", + buf->BUFblknum, node->numRecs, node->nfreebytes, + node->u.nextleaf); + idx += INDENT_STEP; + for (i = 0; i < node->numRecs; ++i) + { + Leaf_s *e = LEAF_ENTRY(node, i); + + do_indent(idx); + printf( "%d: size %d, ", i, LEAF_ENTRY_SIZE(e)); + SBI_PRINT_LENTRY(parms, e, idx); + } + idx -= INDENT_STEP; + do_indent(idx); + printf( "]\n" ); + } + else { /* Branch node */ + + zASSERT(IS_BRANCH(node)); + do_indent(idx); + printf( "( Branch blk# %d: %d recs, %d freebytes, lchild# %d", + buf->BUFblknum, node->numRecs, node->nfreebytes, node->child_blk); + + if (NODE_OVFLOW(node)) + { + printf( ", ovflow blk# %d", node->u.ovflow_blk); + } + printf( "\n" ); + + idx += INDENT_STEP; + if (! iam_overflow) + { + SBI_dir_dump(parms, node->child_blk, idx); + } + for (i = 0; i < node->numRecs; ++i) + { + Branch_s *e = BRANCH_ENTRY(node, i); + + do_indent(idx); + printf( "%d: size %d, ", i, BRANCH_ENTRY_SIZE(e)); + if (iam_overflow) + { + node_ind_t j; + SNINT e_repl; + OVFLOW_ENTRY(node, i, &j, &e_repl, &e); + if (e_repl) + { + printf( "Replace #%d with: ", j ); + } + else printf( "Insert at #%d: ", j); + } + PRINT_BENTRY(e); + + SBI_dir_dump(parms, e->child_blk, idx); + } + idx -= INDENT_STEP; + if (NODE_OVFLOW(node)) + { + do_indent(idx); + printf( "ovflow " ); + SBI_dir_dump(parms, node->u.ovflow_blk, idx - OVERFLOW_BIAS); + } + do_indent(idx); + printf( ")\n" ); + } + + RELEASE_NTREE_BLK_DEBUG(parms, buf); + return zOK; +} + +/* + Lookup an entry in a B-tree directory. + dirznode must be locked atleast SHARED. + */ +STATUS SBI_dir_ls( + NameTreeParms_s *parms, + Blknum_t nextchild) +{ + Buffer_s *buf; + Node_s *node; + WORD i; + + while (nextchild != INVALID_BLK) + { + if (FETCH_NTREE_BLK_DEBUG(parms, nextchild, &buf, 49) != zOK) + return zOUT_OF_BUFFERS; + node = (Node_s *)buf->pBuf.data; + if (IS_BRANCH(node)) + { + nextchild = node->child_blk; + goto next_node; + } + + for (i = 0; i < node->numRecs; ++i) + { + Leaf_s *e = LEAF_ENTRY(node, i); + SBI_PRINT_LENTRY(parms, e, 0); + } + nextchild = node->u.nextleaf; +next_node: ; + RELEASE_NTREE_BLK_DEBUG(parms, buf); + } + + return zOK; +} +#endif + + +/* + * SBI_DisplayBlockNameTree() - + * + * Return - + */ +STATUS SBI_DisplayBlockNameTree( + ZED_SystemBlockInfo_s *sbi, + BYTE *block, + DFI_CallerOptions_s *co, + Blknum_t *nextBlockHint ) +{ + SNP_PrintBuffer_s *pb = co->DCO_SNPOutput; + NINT i; + Node_s *nt = (void *)block; + + /** Display the header of the Name Tree Node **/ + SNP_snprintf( WHERE, pb, "\n" ); + SNP_snprintf( WHERE, pb, "\n" ); + SNP_snprintf( WHERE, pb, "\n" ); + for ( i = 0; ZED_NameTreeHeader[i].DFI_Type != DFI_TYPE_END; i++ ) + { + DFI_Display( co, &ZED_NameTreeHeader[i], block, ZED_NameTreeHeader[i].DFI_Offset ); + } + SNP_snprintf( WHERE, pb, "\n" ); + SBI_dir_dumpnode( co, NULL, block ); +//printf("%s next leaf is 0x%lx\n", WHERE,nt->u.nextleaf ); + *nextBlockHint = nt->u.nextleaf; /* Should do leaf check here */ + + SNP_snprintf( WHERE, pb, "\n" ); + SNP_snprintf( WHERE, pb, "\n" ); + return( zOK ); + +} /* End of SBI_DisplayBlockNameTree() */ + diff --git a/src/nwnss/zlss/sdZLSS.c b/src/nwnss/zlss/sdZLSS.c new file mode 100644 index 0000000..310709f --- /dev/null +++ b/src/nwnss/zlss/sdZLSS.c @@ -0,0 +1,3189 @@ +/**************************************************************************** + | + | (C) Copyright 2002-2003 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | sdZLSS - Structure Display ZLSS items. + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2007-04-18 23:26:20 +0530 (Wed, 18 Apr 2007) $ + | + | $RCSfile$ + | $Revision: 1954 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Display ZLSS 3.00 items in XML form. + / + / Warning - This file is used by NT Utilities like zedRemote, ZlogGet and + / etc. DO NOT ADD NSS specific code. The define NTLIB is only defined + / when source file is compiled with NT Utilities. + +-------------------------------------------------------------------------*/ + +#include + +#include +#include +#include +#include +#include +//#include + + +#define DFI_INTERNAL +#include "dfi.h" +#include "sbi.h" +#include "sdZLSS.h" + +#define TRACE5 +//#define TRACE5 printf("%s\n",WHERE) /* Used to debug UNPACKing bugs */ + +SDM_Table_s SDM_TableZLSS[] = { + /****************************************************************/ + /*** Entries MUST be in alpha order or '=va' does not work!!! ***/ + /****************************************************************/ + { "LocalXid_t", sizeof( LocalXid_t ), SDM_Structure, DFI_LocalXid_t }, + { "LoggedPersistentZfsVolume_s", sizeof( LoggedPersistentZfsVolume_s ), SDM_Structure, DFI_LoggedPersistentZfsVolume_s }, + { "LoggedPersistentZlssPool_s", sizeof( LoggedPersistentZlssPool_s ), SDM_Structure, DFI_LoggedPersistentZlssPool_s }, + { "PersistentZfsVolume_s", sizeof( PersistentZfsVolume_s ), SDM_Structure, DFI_PersistentZfsVolume_s }, + { "PersistentZlssPool_s", sizeof( PersistentZlssPool_s ), SDM_Structure, DFI_PersistentZlssPool_s }, + { "ZfsPool_s", sizeof( ZfsPool_s ), SDM_Structure, DFI_ZfsPool_s }, + { "ZfsVolume_s", sizeof( ZfsVolume_s ), SDM_Structure, DFI_ZfsVolume_s }, + { "ZfsXasRecovery_s", sizeof( ZfsXasRecovery_s ), SDM_Structure, DFI_ZfsXasRecovery_s }, + { "ZlogBeast_s", sizeof( ZlogBeast_s ), SDM_Structure, DFI_ZlogBeast_s }, + { "ZlogBeastPersistent_s", sizeof( ZlogBeastPersistent_s ), SDM_Structure, DFI_ZlogBeastPersistent_s }, + { "ZlogHighWatermarkSlot_s", sizeof( ZlogHighWatermarkSlot_s ), SDM_Structure, DFI_ZlogHighWatermarkSlot_s }, + { "ZlogHistogramPersistent_s", sizeof( ZlogHistogramPersistent_s ), SDM_Structure, DFI_ZlogHistogramPersistent_s }, + { "ZlssBarrier_s", sizeof( ZlssBarrier_s ), SDM_Structure, DFI_ZlssBarrier_s }, + { "ZlssBlock_s", 4096, SDM_ZlssBlock_s, NULL }, /* Entry to dump a metadata block */ + { "ZlssPool_s", sizeof( ZlssPool_s ), SDM_Structure, DFI_ZlssPool_s }, + /****************************************************************/ + /*** Entries MUST be in alpha order or '=va' does not work!!! ***/ + /****************************************************************/ + { NULL, 0, NULL } /* End of table entry */ +}; + +#define DFI_ZFSStorageInfo_s DFI_NotUsed_s +#define DFI_ResourceTagStructure DFI_NotUsed_s +#define DFI_ZfsBeastTreeBeast_s DFI_NotUsed_s +#define DFI_ZfsNameTree_s DFI_NotUsed_s +#define DFI_ZfsMFLBeast_s DFI_NotUsed_s +#define DFI_ZfsEFLTreeBeast_s DFI_NotUsed_s +#define DFI_ZfsUserTreeBeast_s DFI_NotUsed_s +#define DFI_ZfsDirTreeBeast_s DFI_NotUsed_s +#define DFI_ZfsPurgeLogBeast_s DFI_NotUsed_s +#define DFI_ZLSSVOL_LVD_DeleteQueueInfo_t DFI_NotUsed_s +#define DFI_StorPool_s DFI_NotUsed_s +#define DFI_ZFSMemorySuperBlk_s DFI_NotUsed_s +#define DFI_ZfsPurgeLogBeast_s DFI_NotUsed_s +#define DFI_ZfsMYBTreeBeast_s DFI_NotUsed_s +#define DFI_ZfsFreeExtent_s DFI_NotUsed_s +#define DFI_MSAP_PoolStateInfo_s DFI_NotUsed_s + + + +DFI_DataFormatInformation_s DFI_ZlogHistory_s[] = { + { DFI_TYPE_LONG , NULL, offsetof( ZlogHistory_s, ZH_WatermarkCount ), "ZH_WatermarkCount", 0, "" }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZlogHistory_s, ZH_Slots ), "ZH_Slots", 0, "ZlogHighWatermarkSlot_s", 0, DFI_ZlogHighWatermarkSlot_s }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_ZlogHistogram_s[] = { + { DFI_TYPE_LONG , NULL, offsetof( ZlogHistogram_s, ZH_BucketCount ), "ZH_BucketCount", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogHistogram_s, ZH_BucketSize ), "ZH_BucketSize", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogHistogram_s, ZH_Flags ), "ZH_Flags", 0, "" }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZlogHistogram_s, ZH_P ), "ZH_P", 0, "ZlogHistogramPersistent_s", 0, DFI_ZlogHistogramPersistent_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZlogHistogram_s, ZH_Bucket ), "ZH_Bucket", 0, "void", 0, DFI_NotUsed_s }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_LocalXid_t[] = { + { DFI_TYPE_LONG , NULL, offsetof( LocalXid_t, unique ), "unique", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( LocalXid_t, restartCount ), "restartCount", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_ZfsXasRecovery_s[] = { + { DFI_TYPE_Lsn_t , NULL, offsetof( ZfsXasRecovery_s, ZXR_Lsn ), "ZXR_Lsn", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZfsXasRecovery_s, ZXR_LocalXid ), "ZXR_LocalXid", 0, "LocalXid_t", sizeof(LocalXid_t), DFI_LocalXid_t }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsXasRecovery_s, ZXR_FunctionIndex ), "ZXR_FunctionIndex", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ZfsXasRecovery_s, ZXR_TransactionState ), "ZXR_TransactionState", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ZfsXasRecovery_s, ZXR_PoolBlockCount ), "ZXR_PoolBlockCount", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_ZlogHistogramPersistent_s[] = { + { DFI_TYPE_QUAD , NULL, offsetof( ZlogHistogramPersistent_s, ZHP_CurrentEvent ), "ZHP_CurrentEvent", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogHistogramPersistent_s, ZHP_EventCount ), "ZHP_EventCount", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_ZlogHighWatermarkSlot_s[] = { + { DFI_TYPE_Time_t , NULL, offsetof( ZlogHighWatermarkSlot_s, ZHWB_Time ), "ZHWB_Time", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogHighWatermarkSlot_s, ZHWB_Event ), "ZHWB_Event", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_ZlssBarrier_s[] = { + { DFI_TYPE_NINT , NULL, offsetof( ZlssBarrier_s, ZB_Signature ), "ZB_Signature", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlssBarrier_s, ZB_BarrierLink), "ZB_BarrierLink", 0, "SQlink_t", sizeof(SQlink_t), DFI_SQlink_s}, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZlssBarrier_s, ZB_Zlog ), "ZB_Zlog", 0, "ZlogBeast_s", sizeof(ZlogBeast_s), DFI_ZlogBeast_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlssBarrier_s, ZB_Agent ), "ZB_Agent", 0, "Agent_s", sizeof(Agent_s), DFI_Agent_s }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_ZlogBeast_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, file ), "file", 0, "File_s", sizeof(File_s), DFI_File_s }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeast_s, ZLB_LogRecordFilledInCount ), "ZLB_LogRecordFilledInCount", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeast_s, ZLB_LogBlockFilledInCount ), "ZLB_LogBlockFilledInCount", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeast_s, ZLB_TransactionsHomedSinceCheckpointCount ), "ZLB_TransactionsHomedSinceCheckpointCount", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeast_s, ZLB_TransactionsHomedCount ), "ZLB_TransactionsHomedCount", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeast_s, ZLB_LogBlockFilledInSinceCheckpointCount ), "ZLB_LogBlockFilledInSinceCheckpointCount", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeast_s, ZLB_LogBlockFilledInMaximum ), "ZLB_LogBlockFilledInMaximum", 0, "" }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZlogBeast_s, ZLB_Buffer ), "ZLB_Buffer", 0, "Buffer_s", 0 /*sizeof(struct Buffer_s)*/, DFI_Buffer_s }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeast_s, ZLB_NumberOfLogBlocks ), "ZLB_NumberOfLogBlocks", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_SeniorityListHead ), "ZLB_SeniorityListHead", 0, "ZLB_SeniorityListHead", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_CachedBufferListHead ), "ZLB_CachedBufferListHead", 0, "ZLB_CachedBufferListHead", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZlogBeast_s, ZLB_ZfsXasRecovery ), "ZLB_ZfsXasRecovery", 0, "ZfsXasRecovery_s", 0 /*sizeof(struct ZfsXasRecovery_s)*/, DFI_ZfsXasRecovery_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_FileFullLatch ), "ZLB_FileFullLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_RecoveryLatch ), "ZLB_RecoveryLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_CheckpointTakeLatch ), "ZLB_CheckpointTakeLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeast_s, ZLB_RecoveryAreaFirstBlockNumber ), "ZLB_RecoveryAreaFirstBlockNumber", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeast_s, ZLB_RecoveryActivePointerBlockNumber ), "ZLB_RecoveryActivePointerBlockNumber", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( ZlogBeast_s, ZLB_RecoveryActivePointerLsn ), "ZLB_RecoveryActivePointerLsn", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeast_s, ZLB_RecoveryInitialActivePointerBlockNumber ), "ZLB_RecoveryInitialActivePointerBlockNumber", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( ZlogBeast_s, ZLB_RecoveryInitialActivePointerLsn ), "ZLB_RecoveryInitialActivePointerLsn", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( ZlogBeast_s, ZLB_RecoveryCompensationPointerLsn ), "ZLB_RecoveryCompensationPointerLsn", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( ZlogBeast_s, ZLB_Signature ), "ZLB_Signature", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeast_s, ZLB_State ), "ZLB_State", 0, "" }, +#if ZLOG_USE_SYSTEMS_WORK_TO_DO + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_CheckpointTakeWorkToDoStructure ), "ZLB_CheckpointTakeWorkToDoStructure", 0, "zWorkProc_s", sizeof(zWorkProc_s), DFI_zWorkProc_s }, +#else + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_CheckpointTakeWorkToDoFsm ), "ZLB_CheckpointTakeWorkToDoFsm", 0, "FsmLite_s", sizeof(FsmLite_s), DFI_FsmLite_s }, +#endif +#if NSS_DEBUG IS_ENABLED + { DFI_TYPE_Time_t , NULL, offsetof( ZlogBeast_s, ZLB_CheckpointTakeWorkToDoTiming ), "ZLB_CheckpointTakeWorkToDoTiming", 0, "" }, +#endif + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_CheckpointTakeWorkToDoTimer ), "ZLB_CheckpointTakeWorkToDoTimer", 0, "OneShot_s", sizeof(OneShot_s), DFI_OneShot_s }, + { DFI_TYPE_BYTE , NULL, offsetof( ZlogBeast_s, ZLB_CheckpointTakeWorkToDoScheduled ), "ZLB_CheckpointTakeWorkToDoScheduled", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZlogBeast_s, ZLB_DebugState ), "ZLB_DebugState", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZlogBeast_s, ZLB_ActiveHasBeenRead ), "ZLB_ActiveHasBeenRead", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZlogBeast_s, ZLB_FileFullWaiters ), "ZLB_FileFullWaiters", 0, "" }, +#if LOG_TEST IS_ENABLED +#if 0 /* Not worth putting in */ + LogTest_s ZLB_LT[LOG_TEST_MAX]; +#endif +#endif + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeast_s, ZLB_WorkToDoParameter1 ), "ZLB_WorkToDoParameter1", 0, "" }, +#if NSS_DEBUG IS_ENABLED + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeast_s, ZLB_CheckpointThreadId ), "ZLB_CheckpointThreadId", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeast_s, ZLB_CheckpointThreadIdLast ), "ZLB_CheckpointThreadIdLast", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZlogBeast_s, ZLB_CheckpointTime ), "ZLB_CheckpointTime", CHECKPOINT_NUMBER, "" }, +#endif +#if 0 /* Not worth putting in */ + ZlogXactionStats_s ZLB_Ftest; +#endif + { DFI_TYPE_STATUS , NULL, offsetof( ZlogBeast_s, ZLB_RedoUndoStatus ), "ZLB_RedoUndoStatus", 0, "" }, + { DFI_TYPE_char_PTR , NULL, offsetof( ZlogBeast_s, ZLB_RedoUndoStatusSetter ), "ZLB_RedoUndoStatusSetter", 0, "char", sizeof(char) }, + + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZlogBeast_s, ZLB_Barrier ), "ZLB_Barrier", 0, "ZlssBarrier_s", sizeof(struct ZlssBarrier_s), DFI_ZlssBarrier_s }, + { DFI_TYPE_BYTE , NULL, offsetof( ZlogBeast_s, ZLB_BarrierWorkToDoScheduled ), "ZLB_BarrierWorkToDoScheduled", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZlogBeast_s, ZLB_Reserved2007 ), "ZLB_Reserved2007", 3, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_BarrierListHead ), "ZLB_BarrierListHead", 0, "SQhead_t", sizeof(SQhead_t), DFI_SQhead_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_BarrierWorkToDoFsm ), "ZLB_BarrierWorkToDoFsm", 0, "FsmLite_s", sizeof(FsmLite_s), DFI_FsmLite_s }, + + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_FunctionHistogram ), "ZLB_FunctionHistogram", 0, "ZlogHistogram_s", sizeof(ZlogHistogram_s), DFI_ZlogHistogram_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_SizeHistogram ), "ZLB_SizeHistogram", 0, "ZlogHistogram_s", sizeof(ZlogHistogram_s), DFI_ZlogHistogram_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_History ), "ZLB_History", 4, "ZlogHistory_s", sizeof(ZlogHistory_s), DFI_ZlogHistory_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_ReferenceBlockCountHistogram ), "ZLB_ReferenceBlockCountHistogram", 0, "ZlogHistogram_s", sizeof(ZlogHistogram_s), DFI_ZlogHistogram_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_ReferenceBlockCountHistory ), "ZLB_ReferenceBlockCountHistory", 0, "ZlogHistory_s", sizeof(ZlogHistory_s), DFI_ZlogHistory_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_BlockInuseCountHistogram ), "ZLB_BlockInuseCountHistogram", 0, "ZlogHistogram_s", sizeof(ZlogHistogram_s), DFI_ZlogHistogram_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_BlockInuseCountHistory ), "ZLB_BlockInuseCountHistory", 0, "ZlogHistory_s", sizeof(ZlogHistory_s), DFI_ZlogHistory_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_RecoveryTimeHistogram ), "ZLB_RecoveryTimeHistogram", 0, "ZlogHistogram_s", sizeof(ZlogHistogram_s), DFI_ZlogHistogram_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_RecoveryTimeHistory ), "ZLB_RecoveryTimeHistory", 0, "ZlogHistory_s", sizeof(ZlogHistory_s), DFI_ZlogHistory_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_DeferredWritesHistogram ), "ZLB_DeferredWritesHistogram", 0, "ZlogHistogram_s", sizeof(ZlogHistogram_s), DFI_ZlogHistogram_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_DeferredWritesHistory ), "ZLB_DeferredWritesHistory", 0, "ZlogHistory_s", sizeof(ZlogHistory_s), DFI_ZlogHistory_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeast_s, ZLB_P ), "ZLB_P", 0, "ZlogBeastPersistent_s", sizeof(ZlogBeastPersistent_s), DFI_ZlogBeastPersistent_s }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_ZfsEFLEpoch_s[] = { + { DFI_TYPE_EFLEpochMask_t , NULL, offsetof( ZfsEFLEpoch_s, epoch ), "epoch", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZfsEFLEpoch_s, lastAlive ), "lastAlive", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_PersistentZfsEFLTree_s[] = { + { DFI_TYPE_EFLEpochMask_t , NULL, offsetof( PersistentZfsEFLTree_s, activeEpochs ), "activeEpochs", 0, "" }, + { DFI_TYPE_EFLEpochMask_t , NULL, offsetof( PersistentZfsEFLTree_s, usedEpochs ), "usedEpochs", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentZfsEFLTree_s, nameSpace ), "nameSpace", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentZfsEFLTree_s, inactiveInterval ), "inactiveInterval", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( PersistentZfsEFLTree_s, logHeaderBlock ), "logHeaderBlock", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentZfsEFLTree_s, extra ), "extra", 3, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( PersistentZfsEFLTree_s, epochs ), "epochs", MAX_ZFS_EFL_EPOCHS, "ZfsEFLEpoch_s", sizeof(ZfsEFLEpoch_s), DFI_ZfsEFLEpoch_s }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_ZlogBeastPersistent_s[] = { + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_Signature2 ), "ZLBP_Signature2", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_VersionMajor ), "ZLBP_VersionMajor", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_VersionMinor ), "ZLBP_VersionMinor", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_ZSTOREMajorVersion ), "ZLBP_ZSTOREMajorVersion", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_ZSTOREMinorVersion ), "ZLBP_ZSTOREMinorVersion", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_ZSTORESubVersion ), "ZLBP_ZSTORESubVersion", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_ZSTOREBuildNumber ), "ZLBP_ZSTOREBuildNumber", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_ActivePointerLsn ), "ZLBP_ActivePointerLsn", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_HomePointerLsn ), "ZLBP_HomePointerLsn", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_OldHomePointerLsn ), "ZLBP_OldHomePointerLsn", CHECKPOINT_NUMBER, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleFull ), "ZLBP_FileThrottleFull", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleBack ), "ZLBP_FileThrottleBack", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleWaitCount ), "ZLBP_FileThrottleWaitCount", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleWait1Count ), "ZLBP_FileThrottleWait1Count", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleWait2Count ), "ZLBP_FileThrottleWait2Count", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleWait3Count ), "ZLBP_FileThrottleWait3Count", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleWait4Count ), "ZLBP_FileThrottleWait4Count", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleWait5Count ), "ZLBP_FileThrottleWait5Count", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleFullCount ), "ZLBP_FileThrottleFullCount", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleCheckpointCount ), "ZLBP_FileThrottleCheckpointCount", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleSkipCount ), "ZLBP_FileThrottleSkipCount", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleBackCount ), "ZLBP_FileThrottleBackCount", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleTimeStart ), "ZLBP_FileThrottleTimeStart", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleTimeEnd ), "ZLBP_FileThrottleTimeEnd", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_OldHomePointerBlockNumber ), "ZLBP_OldHomePointerBlockNumber", CHECKPOINT_NUMBER, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_ActivePointerBlockNumber ), "ZLBP_ActivePointerBlockNumber", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_HomePointerBlockNumber ), "ZLBP_HomePointerBlockNumber", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_PreOldestHomePointerBlockNumber ), "ZLBP_PreOldestHomePointerBlockNumber", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_TimeActivation ), "ZLBP_TimeActivation", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_TimeDeactivation ), "ZLBP_TimeDeactivation", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_TimePoolCreate ), "ZLBP_TimePoolCreate", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_RecoveryRecoverCount ), "ZLBP_RecoveryRecoverCount", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_RecoveryActivationCount ), "ZLBP_RecoveryActivationCount", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_LastRecoveryTimeStart ), "ZLBP_LastRecoveryTimeStart", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_LastRecoveryTimeEnd ), "ZLBP_LastRecoveryTimeEnd", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_LastRecoveryActivationCount ), "ZLBP_LastRecoveryActivationCount", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_Mode ), "ZLBP_Mode", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileVersion ), "ZLBP_FileVersion", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleFullPercent ), "ZLBP_FileThrottleFullPercent", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FileThrottleBackPercent ), "ZLBP_FileThrottleBackPercent", 0, "" }, + { DFI_TYPE_BYTE , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_Padding ), "ZLBP_Padding", 6, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_PreHomePointerReferenceBlockCount ), "ZLBP_PreHomePointerReferenceBlockCount", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_HomePointerReferenceBlockCount ), "ZLBP_HomePointerReferenceBlockCount", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_ActivePointerReferenceBlockCount ), "ZLBP_ActivePointerReferenceBlockCount", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeastPersistent_s, ZLBP_ReferenceBlockCountHistorySlots ), "ZLBP_ReferenceBlockCountHistorySlots", 10, "ZlogHighWatermarkSlot_s", sizeof(ZlogHighWatermarkSlot_s), DFI_ZlogHighWatermarkSlot_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeastPersistent_s, ZLBP_ReferenceBlockCountHistogramPersistent ), "ZLBP_ReferenceBlockCountHistogramPersistent", 0, "ZlogHistogramPersistent_s", sizeof(ZlogHistogramPersistent_s), DFI_ZlogHistogramPersistent_s }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_ReferenceBlockCountBucket ), "ZLBP_ReferenceBlockCountBucket", 10, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeastPersistent_s, ZLBP_FunctionHistogramPersistent ), "ZLBP_FunctionHistogramPersistent", 0, "ZlogHistogramPersistent_s", sizeof(ZlogHistogramPersistent_s), DFI_ZlogHistogramPersistent_s }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_FunctionBucket ), "ZLBP_FunctionBucket", 50+85, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeastPersistent_s, ZLBP_SizeHistogramPersistent ), "ZLBP_SizeHistogramPersistent", 0, "ZlogHistogramPersistent_s", sizeof(ZlogHistogramPersistent_s), DFI_ZlogHistogramPersistent_s }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_SizeBucket ), "ZLBP_SizeBucket", 8, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeastPersistent_s, ZLBP_BlockInuseCountHistorySlots ), "ZLBP_BlockInuseCountHistorySlots", 10, "ZlogHighWatermarkSlot_s", sizeof(ZlogHighWatermarkSlot_s), DFI_ZlogHighWatermarkSlot_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeastPersistent_s, ZLBP_BlockInuseCountHistogramPersistent ), "ZLBP_BlockInuseCountHistogramPersistent", 0, "ZlogHistogramPersistent_s", sizeof(ZlogHistogramPersistent_s), DFI_ZlogHistogramPersistent_s }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_BlockInuseCountBucket ), "ZLBP_BlockInuseCountBucket", 12, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeastPersistent_s, ZLBP_RecoveryTimeHistorySlots ), "ZLBP_RecoveryTimeHistorySlots", 10, "ZlogHighWatermarkSlot_s", sizeof(ZlogHighWatermarkSlot_s), DFI_ZlogHighWatermarkSlot_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeastPersistent_s, ZLBP_RecoveryTimeHistogramPersistent ), "ZLBP_RecoveryTimeHistogramPersistent", 0, "ZlogHistogramPersistent_s", sizeof(ZlogHistogramPersistent_s), DFI_ZlogHistogramPersistent_s }, + { DFI_TYPE_Time_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_RecoveryTimeBucket ), "ZLBP_RecoveryTimeBucket", 4, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeastPersistent_s, ZLBP_DeferredWritesHistorySlots ), "ZLBP_DeferredWritesHistorySlots", 10, "ZlogHighWatermarkSlot_s", sizeof(ZlogHighWatermarkSlot_s), DFI_ZlogHighWatermarkSlot_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeastPersistent_s, ZLBP_DeferredWritesHistogramPersistent ), "ZLBP_DeferredWritesHistogramPersistent", 0, "ZlogHistogramPersistent_s", sizeof(ZlogHistogramPersistent_s), DFI_ZlogHistogramPersistent_s }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_DeferredWritesBucket ), "ZLBP_DeferredWritesBucket", 5, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeastPersistent_s, ZLBP_HistorySlots ), "ZLBP_HistorySlots", 4*ZLOG_HISTORY_SLOTS, "ZlogHighWatermarkSlot_s", sizeof(ZlogHighWatermarkSlot_s), DFI_ZlogHighWatermarkSlot_s }, + { DFI_TYPE_Lsn_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_CompensationPtrLsn ), "ZLBP_CompensationPtrLsn", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_LogicalUndoPtrLsn ), "ZLBP_LogicalUndoPtrLsn", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_CompensationPtrBlkNum ), "ZLBP_CompensationPtrBlkNum", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_LogicalUndoPtrBlkNum ), "ZLBP_LogicalUndoPtrBlkNum", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeastPersistent_s, ZLBP_StatisticsRead ), "ZLBP_StatisticsRead", 0, "PoolReadStatistics_s", sizeof(PoolReadStatistics_s), DFI_PoolReadStatistics_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlogBeastPersistent_s, ZLBP_StatisticsWrite ), "ZLBP_StatisticsWrite", 0, "PoolWriteStatistics_s", sizeof(PoolWriteStatistics_s), DFI_PoolWriteStatistics_s }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_Reserved ), "ZLBP_Reserved", 12, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_Signature ), "ZLBP_Signature", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlogBeastPersistent_s, ZLBP_StatisticsResetUTCTime ), "ZLBP_StatisticsResetUTCTime", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_SD_Fake_s[] = { + { DFI_TYPE_NINT , NULL, offsetof( SD_Fake_s, redo ), "redo", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( SD_Fake_s, undo ), "undo", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_RecoveryStats_s[] = { + { DFI_TYPE_NINT , NULL, offsetof( RecoveryStats_s, pass1 ), "pass1", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( RecoveryStats_s, pass2 ), "pass2", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( RecoveryStats_s, pass3 ), "pass3", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( RecoveryStats_s, pass4 ), "pass4", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( RecoveryStats_s, pass5 ), "pass5", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( RecoveryStats_s, alloc ), "alloc", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( RecoveryStats_s, realloc ), "realloc", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( RecoveryStats_s, func ), "func", XFUNC_MAX, "SD_Fake_s", sizeof(SD_Fake_s), DFI_SD_Fake_s }, + { DFI_TYPE_NINT , NULL, offsetof( RecoveryStats_s, redid ), "redid", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_PoolReadStatistics_s[] = { + { DFI_TYPE_QUAD , NULL, offsetof( PoolReadStatistics_s, PRS_SystemBeast ), "PRS_SystemBeast", ZLSS_PRS_SB_COUNT, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PoolReadStatistics_s, PRS_SuperBlock ), "PRS_SuperBlock", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PoolReadStatistics_s, PRS_UserBlock ), "PRS_UserBlock", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PoolReadStatistics_s, PRS_DirectIOBlock ), "PRS_DirectIOBlock", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PoolReadStatistics_s, PRS_Reserved ), "PRS_Reserved", 5, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_PoolWriteStatistics_s[] = { + { DFI_TYPE_QUAD , NULL, offsetof( PoolWriteStatistics_s, PWS_SystemBeast ), "PWS_SystemBeast", ZLSS_PRS_SB_COUNT, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PoolWriteStatistics_s, PWS_SuperBlock ), "PWS_SuperBlock", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PoolWriteStatistics_s, PWS_UserBlock ), "PWS_UserBlock", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PoolWriteStatistics_s, PWS_DirectIOBlock ), "PWS_DirectIOBlock", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PoolWriteStatistics_s, PWS_Reserved ), "PWS_Reserved", 4, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( PoolWriteStatistics_s, PWS_BarrierIO ), "PWS_BarrierIO", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_ZfsPool_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZfsPool_s, zfsVol ), "zfsVol", 0, "ZfsVolume_s", sizeof(ZfsVolume_s), DFI_ZfsVolume_s }, + { DFI_TYPE_NINT , NULL, offsetof( ZfsPool_s, ZP_NextCheckpoint ), "ZP_NextCheckpoint", 0, "" }, + { DFI_TYPE_NINT , NULL, offsetof( ZfsPool_s, ZP_BadCheckpoints ), "ZP_BadCheckpoints", 0, "" }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsPool_s, storagepool ), "storagepool", 0, "StorPool_s", sizeof(StorPool_s), DFI_StorPool_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsPool_s, ZP_super ), "ZP_super", 0, "ZFSMemorySuperBlk_s", sizeof(ZFSMemorySuperBlk_s), DFI_ZFSMemorySuperBlk_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsPool_s, zfsLogBeast ), "zfsLogBeast", 0, "ZlogBeast_s", sizeof(ZlogBeast_s), DFI_ZlogBeast_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsPool_s, purgeLogBeast ), "purgeLogBeast", 0, "ZfsPurgeLogBeast_s", sizeof(ZfsPurgeLogBeast_s), DFI_ZfsPurgeLogBeast_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsPool_s, purgeTree ), "purgeTree", 0, "ZfsMYBTreeBeast_s", sizeof(ZfsMYBTreeBeast_s), DFI_ZfsMYBTreeBeast_s }, + { DFI_TYPE_SQUAD , NULL, offsetof( ZfsPool_s, nblks_to_salvage ), "nblks_to_salvage", 0, "" }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsPool_s, freeExtent ), "freeExtent", 0, "ZfsFreeExtent_s", sizeof(ZfsFreeExtent_s), DFI_ZfsFreeExtent_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZfsPool_s, freeDataBlksList ), "freeDataBlksList", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZfsPool_s, ZP_deleteBlkQ ), "ZP_deleteBlkQ", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZfsPool_s, zp_stats ), "zp_stats", 0, "RecoveryStats_s", sizeof(RecoveryStats_s), DFI_RecoveryStats_s }, + { DFI_TYPE_NINT , NULL, offsetof( ZfsPool_s, ZP_RepairFlags ), "ZP_RepairFlags", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( ZfsPool_s, ZP_OldInternalID ), "ZP_OldInternalID", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZfsPool_s, ZP_SuperblockHeaderLatch ), "ZP_SuperblockHeaderLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_ZfsVolume_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZfsVolume_s, vol ), "vol", 0, "Volume_s", sizeof(Volume_s), DFI_Volume_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZfsVolume_s, p ), "p", 0, "PersistentZfsVolume_s", sizeof(PersistentZfsVolume_s), DFI_PersistentZfsVolume_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZfsVolume_s, logged ), "logged", 0, "LoggedPersistentZfsVolume_s", sizeof(LoggedPersistentZfsVolume_s), DFI_LoggedPersistentZfsVolume_s }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZfsVolume_s, ZV_loggedVolumeDataBlk ), "ZV_loggedVolumeDataBlk", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZfsVolume_s, ZV_volumeDataBlk ), "ZV_volumeDataBlk", 0, "" }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZfsVolume_s, ZV_systemBeastBlkNum ), "ZV_systemBeastBlkNum", 0, "" }, + { DFI_TYPE_QUAD , NULL, offsetof( ZfsVolume_s, zv_bookedInUseBlocks ), "zv_bookedInUseBlocks", 0, "" }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsVolume_s, pool ), "pool", 0, "ZfsPool_s", sizeof(ZfsPool_s), DFI_ZfsPool_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsVolume_s, beastTree ), "beastTree", 0, "ZfsBeastTreeBeast_s", sizeof(ZfsBeastTreeBeast_s), DFI_ZfsBeastTreeBeast_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsVolume_s, nameTree ), "nameTree", 0, "ZfsNameTree_s", sizeof(ZfsNameTree_s), DFI_ZfsNameTree_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsVolume_s, mfl ), "mfl", 0, "ZfsMFLBeast_s", sizeof(ZfsMFLBeast_s), DFI_ZfsMFLBeast_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsVolume_s, eflTree ), "eflTree", 0, "ZfsEFLTreeBeast_s", sizeof(ZfsEFLTreeBeast_s), DFI_ZfsEFLTreeBeast_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsVolume_s, userTree ), "userTree", 0, "ZfsUserTreeBeast_s", sizeof(ZfsUserTreeBeast_s), DFI_ZfsUserTreeBeast_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsVolume_s, dirTree ), "dirTree", 0, "ZfsDirTreeBeast_s", sizeof(ZfsDirTreeBeast_s), DFI_ZfsDirTreeBeast_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsVolume_s, ZV_volumePurgeLog ), "ZV_volumePurgeLog", 0, "ZfsPurgeLogBeast_s", sizeof(ZfsPurgeLogBeast_s), DFI_ZfsPurgeLogBeast_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsVolume_s, zv_zfsLogBeast ), "zv_zfsLogBeast", 0, "ZlogBeast_s", sizeof(ZlogBeast_s), DFI_ZlogBeast_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZfsVolume_s, ZV_deleteBlkQ ), "ZV_deleteBlkQ", 0, "DQhead_t", sizeof(DQhead_t), DFI_DQhead_t }, + { DFI_TYPE_SNINT , NULL, offsetof( ZfsVolume_s, unusableFreeBlkCnt ), "unusableFreeBlkCnt", 0, "" }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZfsVolume_s, ZV_dqi ), "ZV_dqi", 0, "ZLSSVOL_LVD_DeleteQueueInfo_t", sizeof(ZLSSVOL_LVD_DeleteQueueInfo_t), DFI_ZLSSVOL_LVD_DeleteQueueInfo_t }, + { DFI_TYPE_BOOL , NULL, offsetof( ZfsVolume_s, ZV_stopPurge ), "ZV_stopPurge", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( ZfsVolume_s, ZV_internalID ), "ZV_internalID", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZfsVolume_s, ZV_vdbLatch ), "ZV_vdbLatch", 0, "Latch_s", sizeof(Latch_s), DFI_Latch_s }, + { DFI_TYPE_LONG , NULL, offsetof( ZfsVolume_s, ZV_RepairFlags ), "ZV_RepairFlags", 0, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_PersistentZfsVolume_s[] = { + { DFI_TYPE_LONG , NULL, offsetof( PersistentZfsVolume_s, PZV_magic ), "PZV_magic", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentZfsVolume_s, PZV_version ), "PZV_version", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentZfsVolume_s, PZV_checksum ), "PZV_checksum", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( PersistentZfsVolume_s, PZV_rezidCount ), "PZV_rezidCount", 0, "" }, + { DFI_TYPE_WORD , NULL, offsetof( PersistentZfsVolume_s, PZV_readAheadBlocks ), "PZV_readAheadBlocks", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( PersistentZfsVolume_s, PZV_internalID ), "PZV_internalID", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( PersistentZfsVolume_s, PZV_loggedVolumeDataBlk ), "PZV_loggedVolumeDataBlk", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( PersistentZfsVolume_s, PZV_volumeDataBlk ), "PZV_volumeDataBlk", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( PersistentZfsVolume_s, PZV_systemBeastBlkNum ), "PZV_systemBeastBlkNum", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentZfsVolume_s, PZV_ActivationCount ), "PZV_ActivationCount", 0, "" }, + { DFI_TYPE_VolumeID_t , NULL, offsetof( PersistentZfsVolume_s, PZV_volumeID ), "PZV_volumeID", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( PersistentZfsVolume_s, PZV_lsn ), "PZV_lsn", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentZfsVolume_s, PZV_reserved ), "PZV_reserved", 32-8-6-1-4-2, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_LoggedPersistentZfsVolume_s[] = { + { DFI_TYPE_LONG , NULL, offsetof( LoggedPersistentZfsVolume_s, LPZV_magic ), "LPZV_magic", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( LoggedPersistentZfsVolume_s, LPZV_version ), "LPZV_version", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( LoggedPersistentZfsVolume_s, LPZV_lsn ), "LPZV_lsn", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( LoggedPersistentZfsVolume_s, LPZV_internalID ), "LPZV_internalID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( LoggedPersistentZfsVolume_s, LPZV_reserved ), "LPZV_reserved", 32-8, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +#include "zfsFileMap.h" +DFI_DataFormatInformation_s DFI_ZlssPool_s[] = { + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlssPool_s, ZP_Pool ), "ZP_Pool", 0, "Pool_s", sizeof(Pool_s), DFI_Pool_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlssPool_s, ZP_p ), "ZP_p", 0, "PersistentZlssPool_s", sizeof(PersistentZlssPool_s), DFI_PersistentZlssPool_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlssPool_s, ZP_logged ), "ZP_logged", 0, "LoggedPersistentZlssPool_s", sizeof(LoggedPersistentZlssPool_s), DFI_LoggedPersistentZlssPool_s }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZlssPool_s, ZP_ZfsPool ), "ZP_ZfsPool", 0, "ZfsPool_s", sizeof(ZfsPool_s), DFI_ZfsPool_s }, + { DFI_TYPE_QUAD , NULL, offsetof( ZlssPool_s, ZP_bookedInUseBlocks ), "ZP_bookedInUseBlocks", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlssPool_s, ZP_MakeFreeSpaceFsm ), "ZP_MakeFreeSpaceFsm", 0, "FsmLite_s", sizeof(FsmLite_s), DFI_FsmLite_s }, + { DFI_TYPE_SQUAD , NULL, offsetof( ZlssPool_s, ZP_BlocksToSalvage ), "ZP_BlocksToSalvage", 0, "" }, + { DFI_TYPE_SNINT , NULL, offsetof( ZlssPool_s, ZP_UnusableFreeBlkCnt ), "ZP_UnusableFreeBlkCnt", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( ZlssPool_s, ZP_InternalID ), "ZP_InternalID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( ZlssPool_s, ZP_Version ), "ZP_Version", 0, "" }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlssPool_s, ZP_PWS ), "ZP_PWS", 0, "PoolWriteStatistics_s", sizeof(PoolWriteStatistics_s), DFI_PoolWriteStatistics_s }, + { DFI_TYPE_STRUCT , SDM_Structure, offsetof( ZlssPool_s, ZP_PRS ), "ZP_PRS", 0, "PoolReadStatistics_s", sizeof(PoolReadStatistics_s), DFI_PoolReadStatistics_s }, + { DFI_TYPE_Time_t , NULL, offsetof( ZlssPool_s, ZP_StatisticsResetCommandUTCTime ), "ZP_StatisticsResetCommandUTCTime", 0, "" }, + { DFI_TYPE_Time_t , NULL, offsetof( ZlssPool_s, ZP_StatisticsResetUTCTime ), "ZP_StatisticsResetUTCTime", 0, "" }, + { DFI_TYPE_BOOL , NULL, offsetof( ZlssPool_s, ZP_PoolTrackIO ), "ZP_PoolTrackIO", 0, "" }, + { DFI_TYPE_BOOL , NULL, offsetof( ZlssPool_s, ZP_Loading ), "ZP_Loading", 0, "" }, + { DFI_TYPE_BOOL , NULL, offsetof( ZlssPool_s, ZP_Snapshot ), "ZP_Snapshot", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( ZlssPool_s, ZP_SnapshotID ), "ZP_SnapshotID", 0, "" }, + { DFI_TYPE_STRUCT_PTR , SDM_Structure, offsetof( ZlssPool_s, ZP_MSAPInfo ), "ZP_MSAPInfo", 0, "MSAP_PoolStateInfo_s", sizeof(MSAP_PoolStateInfo_s), DFI_MSAP_PoolStateInfo_s }, + { DFI_TYPE_Blknum_t , NULL, offsetof( ZlssPool_s, ZP_MSAPBlock ), "ZP_MSAPBlock", 0, "" }, + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + +DFI_DataFormatInformation_s DFI_PersistentZlssPool_s[] = { + { DFI_TYPE_LONG , NULL, offsetof( PersistentZlssPool_s, PZP_magic ), "PZP_magic", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentZlssPool_s, PZP_version ), "PZP_version", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentZlssPool_s, PZP_checksum ), "PZP_checksum", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentZlssPool_s, PZP_reserved1 ), "PZP_reserved1", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( PersistentZlssPool_s, PZP_internalID ), "PZP_internalID", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( PersistentZlssPool_s, PZP_loggedPoolDataBlk ), "PZP_loggedPoolDataBlk", 0, "" }, + { DFI_TYPE_QBlknum_t , NULL, offsetof( PersistentZlssPool_s, PZP_poolDataBlk ), "PZP_poolDataBlk", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentZlssPool_s, PZP_initUTCTime ), "PZP_initUTCTime", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentZlssPool_s, PZP_rebuildUTCTime ), "PZP_rebuildUTCTime", 0, "" }, + { DFI_TYPE_VolumeID_t , NULL, offsetof( PersistentZlssPool_s, PZP_volumeID ), "PZP_volumeID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( PersistentZlssPool_s, PZP_reserved ), "PZP_reserved", 64-16-4, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +DFI_DataFormatInformation_s DFI_LoggedPersistentZlssPool_s[] = { + { DFI_TYPE_LONG , NULL, offsetof( LoggedPersistentZlssPool_s, LPZP_magic ), "LPZP_magic", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( LoggedPersistentZlssPool_s, LPZP_version ), "LPZP_version", 0, "" }, + { DFI_TYPE_Lsn_t , NULL, offsetof( LoggedPersistentZlssPool_s, LPZP_lsn ), "LPZP_lsn", 0, "" }, + { DFI_TYPE_GUID_t , NULL, offsetof( LoggedPersistentZlssPool_s, LPZP_internalID ), "LPZP_internalID", 0, "" }, + { DFI_TYPE_LONG , NULL, offsetof( LoggedPersistentZlssPool_s, LPZP_reserved ), "LPZP_reserved", 64-8, "" }, + + { DFI_TYPE_END , NULL, 0, "", 0, "" }, +}; + + +/* FixFixFix - Currently hard code to a PurgeQNewKey_s as the key */ +int ZSD_Display_Struct_MYBTBranchEntry_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + MYBTBranchEntry_s *data ) +{ + char *structureName = "MYBTBranchEntry_s"; + int rc; + int size; + + size = offsetof(MYBTBranchEntry_s, key) + sizeof(PurgeQNewKey_s); + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, size, data ); + ZSD_Display_Type_Blknum_t( co, "child", &data->child ); + ZSD_Display_Type_LONG( co, "reserved", &data->reserved ); + ZSD_Display_Struct_PurgeQNewKey_s( co, "key", 0, 0, (PurgeQNewKey_s *)&data->key ); + rc = DFI_Display_Tail_Structure( co, structureName, size, data ); + + return( rc ); + +} + + +/* Currently hard code to a PurgeQNewKey_s as the key */ +int ZSD_Display_Struct_MYBTBranchEntry_s_ARRAY( + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + MYBTBranchEntry_s *data ) /* Array of .. */ +{ + int rc; + unsigned int index; + MYBTBranchEntry_s *entry; + int size; + + size = arrayElements * (offsetof(MYBTBranchEntry_s, key) + sizeof(PurgeQNewKey_s)); + DFI_Display_Header_ARRAY( co, tag, "MYBTBranchEntry_s", arrayElements, size, &data[0] ); + entry = (MYBTBranchEntry_s *)data; + for ( index = 0; index < arrayElements; index++ ) + { + rc = ZSD_Display_Struct_MYBTBranchEntry_s( co, tag, index, arrayElements, entry ); + entry = (MYBTBranchEntry_s *)(((BYTE *)entry) + offsetof(MYBTBranchEntry_s, key) + sizeof(PurgeQNewKey_s)); + } + rc = DFI_Display_Tail_ARRAY( co, tag, "MYBTBranchEntry_s" ); + return( rc ); +} /* End of ZSD_Display_Struct_MYBTBranchEntry_s_ARRAY() */ + + +int ZSD_Display_Type_QBlknum_t( + DFI_CallerOptions_s *co, + char *tag, + SQUAD *data ) +{ + int rc; + + DFI_DataFormatInformation_s dfi = { DFI_TYPE_QBlknum_t, NULL, 0, "", 0, "" }; + dfi.DFI_Name = tag; +// dfi.DFI_ArrayElements = arrayElements; + rc = DFI_Display( co, &dfi, (BYTE *)data, 0 ); + return( rc ); +} /* End of ZSD_Display_Type_QBlknum_t() */ + + + +int ZSD_Display_Type_BYTE_ARRAY( + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + BYTE *data ) +{ + int rc; + DFI_DataFormatInformation_s dfi = { DFI_TYPE_BYTE, NULL, 0, "", 0, "" }; + +// SNP_snprintf( WHERE, pb, "<%s type=\"Array_t\" value=\"0x%x\">\n", "BYTE", arrayElements ); + dfi.DFI_Name = tag; + dfi.DFI_ArrayElements = arrayElements; + rc = DFI_Display( co, &dfi, data, 0 ); +// rc = SNP_snprintf( WHERE, pb, "\n", "BYTE" ); + return( rc ); + +} /* End of ZSD_Display_Type_BYTE_ARRAY() */ + + +int ZSD_Display_Type_LONG_ARRAY( + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + LONG *data ) +{ + int rc; + DFI_DataFormatInformation_s dfi = { DFI_TYPE_LONG, NULL, 0, "", 0, "" }; + +// SNP_snprintf( WHERE, pb, "<%s type=\"Array_t\" value=\"0x%x\">\n", "BYTE", arrayElements ); + dfi.DFI_Name = tag; + dfi.DFI_ArrayElements = arrayElements; + rc = DFI_Display( co, &dfi, (BYTE *)data, 0 ); +// rc = SNP_snprintf( WHERE, pb, "\n", "BYTE" ); + return( rc ); + +} /* End of ZSD_Display_Type_LONG_ARRAY() */ + + +/* + * DFI_Display_Struct_xBranch_s() - + * Display a single FmapExt_s object. + * + * Notes - + * If arrayElements > 0 then the object is assume to be part of + * an array. Which means the 'index' will be displayed. + */ +int DFI_Display_Struct_xBranch_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + xBranch_s *data ) +{ + char *structureName = "xBranch_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *data ), data ); + ZSD_Display_Type_Blknum_t( co, "start", &data->start ); + ZSD_Display_Type_Blknum_t( co, "child", &data->child ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return( rc ); + +} /* End of DFI_Display_Struct_xBranch_s() */ + + +int ZSD_Display_Struct_xBranch_s_ARRAY( + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + xBranch_s *data ) /* Array of xBranch_s */ +{ + int rc; + unsigned int index; + + DFI_Display_Header_ARRAY( co, tag, "xBranch_s", arrayElements, arrayElements * sizeof( *data ), &data[0] ); + for ( index = 0; index < arrayElements; index++ ) + { +// rc = ZSD_Display_Type_Blknum_t_ARRAY_With_Key_Blkcnt_t( co, tag, index, &branch[index].child, &branch[index].start ); + DFI_Display_Struct_xBranch_s( co, tag, index, arrayElements, &data[index] ); + } + rc = DFI_Display_Tail_ARRAY( co, tag, "xBranch_s" ); + return( rc ); + +} /* End of ZSD_Display_Struct_xBranch_s_ARRAY() */ + + +/* + * DFI_Display_Struct_FmapExt_s() - + * Display a single FmapExt_s object. + * + * Notes - + * If arrayElements > 0 then the object is assume to be part of + * an array. Which means the 'index' will be displayed. + */ +int DFI_Display_Struct_FmapExt_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + FmapExt_s *data ) +{ + char *structureName = "FmapExt_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *data ), data ); + ZSD_Display_Type_Blkcnt_t( co, "count", (Blkcnt_t *)(&data->count) ); + ZSD_Display_Type_Blknum_t( co, "poolBlk", &data->poolBlk ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return( rc ); + +} /* End of DFI_Display_Struct_FmapExt_s() */ + + +/* + * ZSD_Display_Struct_FmapExt_s_ARRAY - + * Display an ARRAY of FmapExt_s objects. + */ +int ZSD_Display_Struct_FmapExt_s_ARRAY( + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the element */ + unsigned int arrayElements, /* Number of array elements */ + FmapExt_s *data ) /* Array of branches */ +{ + int rc; + int index; + + DFI_Display_Header_ARRAY( co, tag, "FmapExt_s", arrayElements, arrayElements * sizeof( *data ), &data[0] ); + for ( index = 0; index < arrayElements; index++ ) + { + DFI_Display_Struct_FmapExt_s( co, tag, index, arrayElements, &data[index] ); + } + rc = DFI_Display_Tail_ARRAY( co, tag, "FmapExt_s" ); + return( rc ); + +} /* End of ZSD_Display_Struct_FmapExt_s_ARRAY() */ + + +int ZSD_Display_Struct_Extent_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, /* If 0 then we assume NOT an array */ + Extent_s *data ) +{ + char *structureName = "Extent_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *data ), data ); + ZSD_Display_Type_Blkcnt_t( co, "lengthOfExtent", (Blkcnt_t *)(&data->lengthOfExtent) ); + ZSD_Display_Type_Blknum_t( co, "poolBlkNum", &data->poolBlkNum ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return( rc ); + +} /* End of ZSD_Display_Struct_Extent_s() */ + + +int ZSD_Display_Struct_Extent_s_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, + Extent_s *data ) +{ + int rc; + int index; + + DFI_Display_Header_ARRAY( co, tag, "Extent_s", arrayElements, arrayElements * sizeof( *data ), &data[0] ); + for ( index = 0; index < arrayElements; index++ ) + { + ZSD_Display_Struct_Extent_s( co, tag, index, arrayElements, &data[index] ); + } + rc = DFI_Display_Tail_ARRAY( co, tag, "Extent_s" ); + return( rc ); + +} /* End of ZSD_Display_Struct_Extent_s_ARRAY() */ + + +/* + * DFI_Display_Struct_FmapExt_s() - + * Display a single FmapExt_s object. + * + * Notes - + * If arrayElements > 0 then the object is assume to be part of + * an array. Which means the 'index' will be displayed. + */ +int DFI_Display_Struct_EFLBranchEntry_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + EFLBranchEntry_s *data ) +{ + char *structureName = "EFLBranchEntry_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *data ), data ); + ZSD_Display_Type_Zid_t( co, "zid", &data->zid ); + ZSD_Display_Type_Blknum_t( co, "child", &data->child ); + ZSD_Display_Type_LONG( co, "resBlk", &data->resBlk ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return( rc ); + +} /* End of DFI_Display_Struct_EFLBranchEntry_s() */ + + +/* + * DFI_Display_Struct_ELogHeader_s() - + * Display a single ELogHeader_s object. + * + * Notes - + * If arrayElements > 0 then the object is assume to be part of + * an array. Which means the 'index' will be displayed. + */ +int DFI_Display_Struct_ELogHeader_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + ELogHeader_s *data ) +{ + char *structureName = "ELogHeader_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *data ), data ); + ZSD_Display_Type_Blknum_t( co, "lastBlock", &data->lastBlock ); + ZSD_Display_Type_LONG( co, "resBlk", &data->resBlk ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return( rc ); + +} /* End of DFI_Display_Struct_ELogHeader_s() */ + + +/* + * ZSD_Display_Struct_ELogHeader_s_ARRAY - + * Display an ARRAY of ELogHeader_s_s objects. + */ +int ZSD_Display_Struct_ELogHeader_s_ARRAY( + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the element */ + unsigned int arrayElements, /* Number of array elements */ + ELogHeader_s *data ) /* Array of headers */ +{ + int rc; + int index; + + DFI_Display_Header_ARRAY( co, tag, "ELogHeader_s", arrayElements, arrayElements * sizeof( *data ), &data[0] ); + for ( index = 0; index < arrayElements; index++ ) + { + DFI_Display_Struct_ELogHeader_s( co, tag, index, arrayElements, &data[index] ); + } + rc = DFI_Display_Tail_ARRAY( co, tag, "ELogHeader_s" ); + return( rc ); + +} /* End of ZSD_Display_Struct_ELogHeader_s_ARRAY() */ + + +/* + * DFI_Display_Struct_ELogEntry_s() - + * Display a single ELogEntry_s object. + * + * Notes - + * If arrayElements > 0 then the object is assume to be part of + * an array. Which means the 'index' will be displayed. + */ +int DFI_Display_Struct_ELogEntry_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + ELogEntry_s *data ) +{ + char *structureName = "ELogEntry_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *data ), data ); + ZSD_Display_Type_WORD( co, "magic", &data->magic ); + ZSD_Display_Type_WORD( co, "len", &data->len ); + ZSD_Display_Type_WORD( co, "entryNum", &data->entryNum ); + ZSD_Display_Type_WORD( co, "action", &data->action ); + ZSD_Display_Type_Zid_t( co, "zid", &data->zid ); + ZSD_Display_Type_EFLEpochMask_t( co, "epochs", &data->epochs ); + ZSD_Display_Type_ELogLink_s( co, "nextLogEntry", &data->nextLogEntry ); + ZSD_Display_Type_WORD( co, "state", &data->state ); + ZSD_Display_Type_WORD( co, "oldNameIndex", &data->oldNameIndex ); + + ZSD_Display_Type_unicode_t_STR( co, "name", 4096/2 /*Max unicode in 4k buffer*/, &data->names[0] ); + if ( data->oldNameIndex != (WORD)(-1) ) + { + ZSD_Display_Type_unicode_t_STR( co, "Old name", 4096/2, &data->names[data->oldNameIndex] ); + } + + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return( rc ); + +} /* End of DFI_Display_Struct_ELogEntry_s() */ + + +int ZSD_Display_Type_ELogLink_s( + DFI_CallerOptions_s *co, + char *tag, + ELogLink_s *data ) +{ + char *structureName = "ELogLink_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, 0, 0, sizeof( *data ), data ); + ZSD_Display_Type_Blknum_t( co, "blockNum", &data->blockNum ); + ZSD_Display_Type_LONG( co, "resBlk", &data->resBlk ); + ZSD_Display_Type_LONG( co, "offset", &data->offset ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return( rc ); + +} /* End of ZSD_Display_Type_Zid_t() */ + + +/* + * DFI_Display_Struct_EFLLeafEntry_s() - + * Display a single + * + * Notes - + * If arrayElements > 0 then the object is assume to be part of + * an array. Which means the 'index' will be displayed. + */ +int DFI_Display_Struct_EFLLeafEntry_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + EFLLeafEntry_s *data ) +{ + char *structureName = "EFLLeafEntry_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *data ), data ); + ZSD_Display_Type_Zid_t( co, "zid", &data->zid ); + ZSD_Display_Type_EFLEpochMask_t( co, "createEpochs", &data->createEpochs ); + ZSD_Display_Type_EFLEpochMask_t( co, "modifyEpochs", &data->modifyEpochs ); + ZSD_Display_Type_EFLEpochMask_t( co, "metaDataEpochs", &data->metaDataEpochs ); + ZSD_Display_Type_EFLEpochMask_t( co, "deleteEpochs", &data->deleteEpochs ); + ZSD_Display_Type_LONG( co, "objectType", &data->objectType ); + ZSD_Display_Type_ELogLink_s( co, "firstLogEntry", &data->firstLogEntry ); + ZSD_Display_Type_ELogLink_s( co, "lastLogEntry", &data->lastLogEntry ); + ZSD_Display_Type_LONG( co, "numGoodLogEntries", &data->numGoodLogEntries ); + ZSD_Display_Type_LONG_ARRAY( co, "extra", NELEMS( data->extra ), &data->extra[0] ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return( rc ); + +} /* End of DFI_Display_Struct_EFLLeafEntry_s() */ + +int ZSD_Display_Struct_EFLLeafEntry_s_ARRAY( + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the element */ + unsigned int arrayElements, /* Number of array elements */ + EFLLeafEntry_s *data ) /* Array of branches */ +{ + int rc; + int index; + + DFI_Display_Header_ARRAY( co, tag, "EFLLeafEntry_s", arrayElements, arrayElements * sizeof( *data ), &data[0] ); + for ( index = 0; index < arrayElements; index++ ) + { + DFI_Display_Struct_EFLLeafEntry_s( co, tag, index, arrayElements, &data[index] ); + } + rc = DFI_Display_Tail_ARRAY( co, tag, "EFLLeafEntry_s" ); + return( rc ); + +} /* End of ZSD_Display_Struct_EFLLeafEntry_s_ARRAY() */ + + +int ZSD_Display_Struct_EFLBranch_s_ARRAY( + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the element */ + unsigned int arrayElements, /* Number of array elements */ + EFLBranchEntry_s *data ) /* Array of branches */ +{ + int rc; + int index; + + DFI_Display_Header_ARRAY( co, tag, "EFLBranch_s", arrayElements, arrayElements * sizeof( *data ), &data[0] ); + for ( index = 0; index < arrayElements; index++ ) + { + DFI_Display_Struct_EFLBranchEntry_s( co, tag, index, arrayElements, &data[index] ); + } + rc = DFI_Display_Tail_ARRAY( co, tag, "EFLBranch_s" ); + return( rc ); + +} /* End of ZSD_Display_Struct_EFLBranch_s_ARRAY() */ + + +int ZSD_Display_Struct_BTBranch_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, /* If 0 then we assume NOT an array */ + BTBranch_s *data ) +{ + char *structureName = "BTBranch_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *data ), data ); + ZSD_Display_Type_Zid_t( co, "zid", &data->zid ); + ZSD_Display_Type_Blknum_t( co, "child", &data->child ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return( rc ); + +} /* End of ZSD_Display_Struct_BTBranch_s() */ + + +int ZSD_Display_Struct_BTBranch_s_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + int arrayElements, + BTBranch_s *data ) +{ + int rc; + int index; + + DFI_Display_Header_ARRAY( co, tag, "BTBranch_s", arrayElements, arrayElements * sizeof( *data ), &data[0] ); + for ( index = 0; index < arrayElements; index++ ) + { + ZSD_Display_Struct_BTBranch_s( co, tag, index, arrayElements, &data[index] ); + } + rc = DFI_Display_Tail_ARRAY( co, tag, "BTBranch_s" ); + return( rc ); +} /* End of ZSD_Display_Struct_BTBranch_s_ARRAY() */ + + +int ZSD_Display_Type_NodeLen_t( + DFI_CallerOptions_s *co, + char *tag, + int index, // Ignored + int arrayElements, + NodeLen_t *data ) +{ + int rc; + + DFI_DataFormatInformation_s dfi = { DFI_TYPE_WORD, NULL, 0, "", 0, "" }; + + dfi.DFI_Name = tag; + dfi.DFI_ArrayElements = arrayElements; + rc = DFI_Display( co, &dfi, (BYTE *)data, 0 ); + return( rc ); + +} /* End of ZSD_Display_Type_NodeLen_t() */ + + +/* + * ZSD_Display_Type_NodeLen_t_ARRAY - + * + * Notes - + * Basic type items do not need the _ARRAY version because + * we do arrays via the DFI_ArrayElements element in native types. + * For consistentency we have the function. + */ +int ZSD_Display_Type_NodeLen_t_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + int arrayElements, + NodeLen_t *data ) +{ + int rc; + + rc = ZSD_Display_Type_NodeLen_t( co, tag, 0, arrayElements, &data[0] ); + return( rc ); +} /* End of ZSD_Display_Type_NodeLen_t_ARRAY() */ + + +int ZSD_Display_Type_Blknum_t( + DFI_CallerOptions_s *co, + char *tag, + Blknum_t *block ) +{ + int rc; + + DFI_DataFormatInformation_s dfi = { DFI_TYPE_Blknum_t, NULL, 0, "", 0, "" }; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)block, 0 ); + return( rc ); + +} /* End of ZSD_Display_Type_Blknum_t() */ + +int ZSD_Display_Type_EFLEpochMask_t( + DFI_CallerOptions_s *co, + char *tag, + EFLEpochMask_t *epoch ) +{ + int rc; + + DFI_DataFormatInformation_s dfi = { DFI_TYPE_EFLEpochMask_t, NULL, 0, "", 0, "" }; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)epoch, 0 ); + return( rc ); +} /* End of ZSD_Display_Type_EFLEpochMask_t() */ + +int ZSD_Display_Type_Blkcnt_t( + DFI_CallerOptions_s *co, + char *tag, + Blkcnt_t *block ) +{ + int rc; + + DFI_DataFormatInformation_s dfi = { DFI_TYPE_Blkcnt_t, NULL, 0, "", 0, "" }; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)block, 0 ); + return( rc ); +} /* End of ZSD_Display_Type_Blkcnt_t() */ + + +int ZSD_Display_Type_Blknum_t_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + int arrayElements, + Blknum_t *block ) +{ + int rc; + + DFI_DataFormatInformation_s dfi = { DFI_TYPE_Blknum_t, NULL, 0, "", 0, "" }; + dfi.DFI_Name = tag; + dfi.DFI_ArrayElements = arrayElements; + rc = DFI_Display( co, &dfi, (BYTE *)block, 0 ); + return( rc ); +} /* End of ZSD_Display_Type_Blknum_t_ARRAY() */ + + + + +int ZSD_Display_Struct_Lsn_t( + DFI_CallerOptions_s *co, + char *tag, + Lsn_t *lsn ) + +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_Lsn_t, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)lsn, 0 ); + return( rc ); +} /* End of ZSD_Display_Struct_Lsn_t() */ + + +int ZSD_Display_Struct_GUID_t( + DFI_CallerOptions_s *co, + char *tag, + GUID_t *guid ) + +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_GUID_t, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)guid, 0 ); + return( rc ); +} /* End of ZSD_Display_Struct_GUID_t() */ + + +int ZSD_Display_Struct_GUID_t_ARRAY( + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + GUID_t *data ) +{ + int rc; + DFI_DataFormatInformation_s dfi = { DFI_TYPE_GUID_t, NULL, 0, "", 0, "" }; + + dfi.DFI_Name = tag; + dfi.DFI_ArrayElements = arrayElements; + rc = DFI_Display( co, &dfi, (BYTE *)data, 0 ); + return( rc ); + +} /* End of ZSD_Display_Type_LONG_ARRAY() */ + + +int ZSD_Display_Struct_UserID_t( + DFI_CallerOptions_s *co, + char *tag, + UserID_t *userID ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_UserID_t, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)userID, 0 ); + return( rc ); + +} /* End of ZSD_Display_Struct_UserID_t() */ + + +int ZSD_Display_Struct_VolumeID_t( + DFI_CallerOptions_s *co, + char *tag, + VolumeID_t *volumeID ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_VolumeID_t, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + rc = DFI_Display( co, &dfi, (BYTE *)volumeID, 0 ); + return( rc ); +} /* End of ZSD_Display_Struct_VolumeID_t() */ + + +int ZSD_Display_Type_unicode_t_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, + unicode_t *name ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_unicode_t_ARRAY, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + dfi.DFI_ArrayElements = arrayElements; + rc = DFI_Display( co, &dfi, (BYTE *)name, 0 ); + return( rc ); +} /* End of ZSD_Display_Type_unicode_t_ARRAY() */ + + +int ZSD_Display_Type_unicode_t_STR( + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, /* Number of array elements */ + unicode_t *name ) +{ + DFI_DataFormatInformation_s dfi = { DFI_TYPE_unicode_t_STR, NULL, 0, "", 0, "" }; + int rc; + + dfi.DFI_Name = tag; + dfi.DFI_ArrayElements = arrayElements; + if ( arrayElements == 0 ) + { /* STRINGs MUST be null terminated (how can a zero length array have a '\0'??? */ + printf("%s array elements is 0 on a unicode string. This is not supported as we may put a NULL into the SNP buffer.\n", WHERE ); + return( zOK ); + } + rc = DFI_Display( co, &dfi, (BYTE *)name, 0 ); + return( rc ); + +} /* End of ZSD_Display_Type_unicode_t_STR() */ + + +int ZSD_Display_Type_char_STR( + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, /* Number of array elements */ + char *name ) +{ + int rc; + DFI_DataFormatInformation_s dfi = { DFI_TYPE_char_STR, NULL, 0, "", 0, "" }; + + dfi.DFI_Name = tag; + dfi.DFI_ArrayElements = arrayElements; + rc = DFI_Display( co, &dfi, (BYTE *)name, 0 ); + return( rc ); +} /* End of ZSD_Display_Type_char_t_STR() */ + + +int ZSD_Display_Struct_PersistentCompIntermediate_s( + DFI_CallerOptions_s *co, + void *compIntermediate, + char *name ) + +{ + int rc; + + DFI_Display_Header_Structure( co, name, "PersistentCompIntermediate_s", 0, 0, 0, compIntermediate ); + rc = DFI_Display_Tail_Structure( co, "PersistentCompIntermediate_s", 0, compIntermediate ); + return( rc ); +} /* End of ZSD_Display_Struct_PersistentCompIntermediate_s() */ + + +int ZSD_Display_Struct_PersistentZasAclOverflowBeast_s( + DFI_CallerOptions_s *co, + PersistentZasAclOverflowBeast_s *acl, + char *name ) +{ + int rc; + ACLEntry_s *aclEntry; + + DFI_Display_Header_Structure( co, name, "PersistentZasAclOverflowBeast_s", 0, 0, sizeof( *acl ), acl ); + ZSD_Display_Type_Zid_t( co, "nextOverflowZid", &acl->nextOverflowZid ); + ZSD_Display_Type_LONG( co, "numEntries", &acl->numEntries ); + if ( acl->numEntries != 0 ) + { + aclEntry = (ACLEntry_s *)(acl + 1); + ZSD_Display_Struct_ACLEntry_s_ARRAY( co, "ACLEntry_s", acl->numEntries, aclEntry ); + } + rc = DFI_Display_Tail_Structure( co, "PersistentZasAclOverflowBeast_s", sizeof( *acl ), acl ); + return( rc ); +} /* End of ZSD_Display_Struct_PersistentZasAclOverflowBeast_s() */ + + +int ZSD_Display_Struct_V1_PersistentZasVisOverflowBeast_s( + DFI_CallerOptions_s *co, + PersistentZasVisOverflowBeast_s *vis, // No V1, but V1_VisEntry_s is different + char *name ) +{ + int rc; + V1_VisEntry_s *visEntry; + + DFI_Display_Header_Structure( co, name, "V1_PersistentZasVisOverflowBeast_s", 0, 0, sizeof( *vis ), vis ); + ZSD_Display_Type_Zid_t( co, "nextOverflowZid", &vis->nextOverflowZid ); + ZSD_Display_Type_LONG( co, "numEntries", &vis->numEntries ); + if ( vis->numEntries != 0 ) + { + visEntry = (V1_VisEntry_s *)(vis + 1); + ZSD_Display_Struct_V1_VisEntry_s_ARRAY( co, "V1_VisEntry_s", vis->numEntries, visEntry ); + } + rc = DFI_Display_Tail_Structure( co, "PersistentZasVisOverflowBeast_s", sizeof( *vis ), vis ); + return( rc ); +} /* End of ZSD_Display_Struct_V1_PersistentZasVisOverflowBeast_s() */ + + +int ZSD_Display_Struct_PersistentZasVisOverflowBeast_s( + DFI_CallerOptions_s *co, + PersistentZasVisOverflowBeast_s *vis, + char *name ) +{ + int rc; + VisEntry_s *visEntry; + + DFI_Display_Header_Structure( co, name, "PersistentZasVisOverflowBeast_s", 0, 0, sizeof( *vis ), vis ); + ZSD_Display_Type_Zid_t( co, "nextOverflowZid", &vis->nextOverflowZid ); + ZSD_Display_Type_LONG( co, "numEntries", &vis->numEntries ); + if ( vis->numEntries != 0 ) + { + visEntry = (VisEntry_s *)(vis + 1); + ZSD_Display_Struct_VisEntry_s_ARRAY( co, "VisEntry_s", vis->numEntries, visEntry ); + } + rc = DFI_Display_Tail_Structure( co, "PersistentZasVisOverflowBeast_s", sizeof( *vis ), vis ); + return( rc ); +} /* End of ZSD_Display_Struct_PersistentZasVisOverflowBeast_s() */ + + +int ZSD_Display_Struct_V1_PersistentZasAclOverflowBeast_s( + DFI_CallerOptions_s *co, + PersistentZasAclOverflowBeast_s *acl, // No V1, but ACLEntry_s is different + char *name ) +{ + int rc; + V1_ACLEntry_s *aclEntry; + + DFI_Display_Header_Structure( co, name, "V1_PersistentZasAclOverflowBeast_s", 0, 0, sizeof( *acl ), acl ); + ZSD_Display_Type_Zid_t( co, "nextOverflowZid", &acl->nextOverflowZid ); + ZSD_Display_Type_LONG( co, "numEntries", &acl->numEntries ); + if ( acl->numEntries != 0 ) + { + aclEntry = (V1_ACLEntry_s *)(acl + 1); + ZSD_Display_Struct_V1_ACLEntry_s_ARRAY( co, "V1_ACLEntry_s", acl->numEntries, aclEntry ); + } + rc = DFI_Display_Tail_Structure( co, "V1_PersistentZasAclOverflowBeast_s", sizeof( *acl ), acl ); + return( rc ); +} /* End of ZSD_Display_Struct_V1_PersistentZasAclOverflowBeast_s() */ + + +int ZSD_Display_Struct_PersistentComp_s( + DFI_CallerOptions_s *co, + PersistentComp_s *comp, + char *name ) + +{ + int rc; + + DFI_Display_Header_Structure( co, name, "PersistentComp_s", 0, 0, sizeof( *comp ), comp ); + ZSD_Display_Type_Zid_t( co, "uncompZid", &comp->uncompZid ); + ZSD_Display_Type_LONG_ARRAY( co, "unused", NELEMS( comp->unused ), comp->unused ); + rc = DFI_Display_Tail_Structure( co, "PersistentComp_s", sizeof( *comp ), comp ); + return( rc ); +} /* End of ZSD_Display_Struct_PersistentComp_s() */ + + +int ZSD_Display_Struct_PersistentNamed2_s( + DFI_CallerOptions_s *co, + PersistentNamed2_s *named, + char *name ) +{ + int rc; + + DFI_Display_Header_Structure( co, name, "PersistentNamed_s", 0, 0, sizeof( *named ), named ); + ZSD_Display_Type_Zid_t( co, "nextChildZID", &named->nextChildZID ); + ZSD_Display_Type_LONG( co, "attributes", &named->attributes ); + ZSD_Display_Type_WORD( co, "numChildZIDs", &named->numChildZIDs ); + ZSD_Display_Type_WORD( co, "numParents", &named->numParents ); + ZSD_Display_Type_WORD( co, "nameFlags", &named->nameFlags ); + ZSD_Display_Type_WORD( co, "reserved", &named->reserved ); + rc = DFI_Display_Tail_Structure( co, "PersistentNamed_s", sizeof( *named ), named ); + return( rc ); +} /* End of ZSD_Display_Struct_PersistentNamed2_s() */ + + +int ZSD_Display_Struct_PersistentNamed3_s( + DFI_CallerOptions_s *co, + PersistentNamed3_s *named, + char *name ) +{ + int rc; + + // Elected to keep same name PersistentNamed_s in v2 and v3 so that anyone parsing MAY be happy + // They can look for hardlink filed or beastversion to find if 2 or 3 + DFI_Display_Header_Structure( co, name, "PersistentNamed_s", 0, 0, sizeof( *named ), named ); + ZSD_Display_Type_Zid_t( co, "nextChildZID", &named->nextChildZID ); + ZSD_Display_Type_LONG( co, "attributes", &named->attributes ); + ZSD_Display_Type_WORD( co, "numChildZIDs", &named->numChildZIDs ); + ZSD_Display_Type_WORD( co, "numParents", &named->numParents ); + ZSD_Display_Type_WORD( co, "nameFlags", &named->nameFlags ); + ZSD_Display_Type_WORD( co, "reserved", &named->reserved ); + ZSD_Display_Type_Zid_t( co, "hardLinkZid", &named->hardLinkZid ); + rc = DFI_Display_Tail_Structure( co, "PersistentNamed_s", sizeof( *named ), named ); + return( rc ); +} /* End of ZSD_Display_Struct_PersistentNamed2_s() */ + + +int ZSD_Display_Struct_PersistentParentEntry2_s( + DFI_CallerOptions_s *co, + PersistentParentEntry_s *namedParent, + char *name ) +{ + int rc; + + DFI_Display_Header_Structure( co, name, "PersistentParentEntry_s", 0, 0, sizeof( *namedParent ), namedParent ); + ZSD_Display_Type_WORD( co, "nameUniquifier", &namedParent->reserved1 ); + ZSD_Display_Type_WORD( co, "nameType", &namedParent->nameType ); + ZSD_Display_Type_BYTE( co, "primaryNameSpaceID", &namedParent->primaryNameSpaceID ); + ZSD_Display_Type_BYTE( co, "numNames", &namedParent->numNames ); + ZSD_Display_Type_WORD( co, "reserved", &namedParent->reserved ); + ZSD_Display_Type_LONG( co, "renameSeqNum", &namedParent->renameSeqNum ); + ZSD_Display_Type_Zid_t( co, "zid", &namedParent->zid ); + rc = DFI_Display_Tail_Structure( co, "PersistentParentEntry_s", sizeof( *namedParent ), namedParent ); + return( rc ); +} /* End of ZSD_Display_Struct_PersistentParentEntry2_s() */ + + +int ZSD_Display_Struct_PersistentParentEntry3_s( + DFI_CallerOptions_s *co, + PersistentParentEntry_s *namedParent, + char *name ) +{ + int rc; + + DFI_Display_Header_Structure( co, name, "PersistentParentEntry_s", 0, 0, sizeof( *namedParent ), namedParent ); + ZSD_Display_Type_WORD( co, "nameUniquifier", &namedParent->reserved1 ); + ZSD_Display_Type_WORD( co, "nameType", &namedParent->nameType ); + ZSD_Display_Type_BYTE( co, "primaryNameSpaceID", &namedParent->primaryNameSpaceID ); + ZSD_Display_Type_BYTE( co, "numNames", &namedParent->numNames ); + ZSD_Display_Type_WORD( co, "reserved", &namedParent->reserved ); + ZSD_Display_Type_LONG( co, "renameSeqNum", &namedParent->renameSeqNum ); + ZSD_Display_Type_Zid_t( co, "zid", &namedParent->zid ); + rc = DFI_Display_Tail_Structure( co, "PersistentParentEntry_s", sizeof( *namedParent ), namedParent ); + return( rc ); +} /* End of ZSD_Display_Struct_PersistentParentEntry3_s() */ + + +int ZSD_Display_Struct_PersistentNameEntry_s( + DFI_CallerOptions_s *co, + PersistentNameEntry_s *namedParentEntry, + char *name ) +{ + int rc; + + DFI_Display_Header_Structure( co, name, "PersistentNameEntry_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, namedParentEntry ); + + ZSD_Display_Type_LONG( co, "nameSpaceMask", &namedParentEntry->nameSpaceMask ); + ZSD_Display_Type_WORD( co, "flagsAndLen", &namedParentEntry->flagsAndLen ); +#if 0 + // zedEdit does not handle the same address mulitple times in a XML file + { + WORD save; + + ZSD_Display_Type_WORD( co, "flagsAndLen", &namedParentEntry->flagsAndLen ); +// SNP_snprintf( WHERE, pb, "\n"); + save = namedParentEntry->flagsAndLen; + namedParentEntry->flagsAndLen = save & ~NAMEnameLenMask; + ZSD_Display_Type_WORD( co, "flagsAndLenFLAGS", &namedParentEntry->flagsAndLen ); +//#define NAMEforcedUpper 0x8000 /* The name was created by a name space that +// * forced it to upper case. */ +//#define NAMEovflow 0x4000 /* duplicate names stored in fflow +// * blocks (ZFS naming B-tree-specific) */ +//#define NAMEdup 0x2000 /* Duplicate names exist +// * (ZFS naming B-tree-specific) */ +//#define NAMEool 0x1000 /* name field points to an out-of-line +// * array (ZFS naming B-tree-specific) */ + namedParentEntry->flagsAndLen = save & NAMEnameLenMask; + ZSD_Display_Type_WORD( co, "flagsAndLenLEN", &namedParentEntry->flagsAndLen ); + namedParentEntry->flagsAndLen = save; +// SNP_snprintf( WHERE, pb, "\n"); + } +#endif + ZSD_Display_Type_unicode_t_ARRAY( co, "name", + (unsigned int)namedParentEntry->flagsAndLen & NAMEnameLenMask, + &namedParentEntry->name[0] ); + + rc = DFI_Display_Tail_Structure( co, "PersistentNameEntry_s", DFI_VARIABLE_SIZE_INKNOWN, namedParentEntry ); + return ( rc ); +} /* End of ZSD_Display_Struct_PersistentNameEntry_s() */ + + +int ZSD_Display_Struct_V1_PersistentFile_s( + DFI_CallerOptions_s *co, + V1_PersistentFile_s *file, + char *name ) + +{ + int rc; + + DFI_Display_Header_Structure( co, name, "V1_PersistentFile_s", 0, 0, sizeof( *file ), file ); + + ZSD_Display_Type_Time_t( co, "accessedTime", &file->accessedTime ); + ZSD_Display_Type_Time_t( co, "createdTime", &file->createdTime ); + ZSD_Display_Type_Time_t( co, "modifiedTime", &file->modifiedTime ); + ZSD_Display_Type_Time_t( co, "metaDataModifiedTime", &file->metaDataModifiedTime ); + ZSD_Display_Type_Time_t( co, "archivedTime", &file->archivedTime ); + + ZSD_Display_Type_LONG( co, "modifierID", &file->modifierID ); + ZSD_Display_Type_LONG( co, "metaDataModifierID", &file->metaDataModifierID ); + ZSD_Display_Type_LONG( co, "archiverID", &file->archiverID ); + + rc = DFI_Display_Tail_Structure( co, "V1_PersistentFile_s", sizeof( *file ), file ); + return ( rc ); + +} /* End of ZSD_Display_Struct_V1_PersistentFile_s() */ + + +int ZSD_Display_Struct_PersistentFile_s( + DFI_CallerOptions_s *co, + PersistentFile_s *file, + char *name ) + +{ + int rc; + + DFI_Display_Header_Structure( co, name, "PersistentFile_s", 0, 0, sizeof( *file ), file ); + ZSD_Display_Type_Time_t( co, "accessedTime", &file->accessedTime ); + ZSD_Display_Type_Time_t( co, "createdTime", &file->createdTime ); + ZSD_Display_Type_Time_t( co, "modifiedTime", &file->modifiedTime ); + ZSD_Display_Type_Time_t( co, "metaDataModifiedTime", &file->metaDataModifiedTime ); + ZSD_Display_Type_Time_t( co, "archivedTime", &file->archivedTime ); + + ZSD_Display_Struct_UserID_t( co, "modifierID", &file->modifierID ); + ZSD_Display_Struct_UserID_t( co, "metaDataModifierID", &file->metaDataModifierID ); + ZSD_Display_Struct_UserID_t( co, "archiverID", &file->archiverID ); + + rc = DFI_Display_Tail_Structure( co, "V1_PersistentFile_s", sizeof( *file ), file ); + return ( rc ); + +} /* End of ZSD_Display_Struct_PersistentFile_s() */ + + +int ZSD_Display_Struct_PersistentExtAttrBeast_s( + DFI_CallerOptions_s *co, + PersistentExtAttrBeast_s *data, + char *name ) + +{ + char *structureName = "PersistentExtAttrBeast_s"; + int rc; + + DFI_Display_Header_Structure( co, name, structureName, 0, 0, sizeof( *data ), data ); + ZSD_Display_Type_LONG( co, "extAttrUserFlags", &data->extAttrUserFlags ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return ( rc ); + +} /* End of ZSD_Display_Struct_PersistentExtAttrBeast_s() */ + + +int ZSD_Display_Struct_PersistentAuthBeast_1Dot0_s( + DFI_CallerOptions_s *co, + PersistentAuthBeast_1Dot0_s *data, + char *name ) + +{ + char *structureName = "PersistentAuthBeast_1Dot0_s"; + int rc; + + DFI_Display_Header_Structure( co, name, structureName, 0, 0, sizeof( *data ), data ); + ZSD_Display_Type_LONG( co, "ownerID", &data->ownerID ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return ( rc ); + +} /* End of ZSD_Display_Struct_PersistentAuthBeast_1Dot0_s() */ + + +#if 0 +int ZSD_Display_Struct_Fmap_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + Fmap_s *data ) +{ + char *structureName = "Fmap_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *data ), data ); + ZSD_Display_Type_LONG( co, "numRecs", &data->numRecs ); + ZSD_Display_Type_Blknum_t( co, "root", &data->root ); + ZSD_Display_Struct_Extent_s_ARRAY( co, "dirExt", (unsigned int)data->numRecs, &data->dirExt[0] ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return( rc ); + +} /* End of ZSD_Display_Struct_FmapExt_s() */ +#endif + + +int ZSD_Display_Struct_Fmap_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + Fmap_s *data, + unsigned int size ) +{ + char *structureName = "Fmap_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, size, data ); + ZSD_Display_Type_LONG( co, "numRecs", &data->numRecs ); + ZSD_Display_Type_Blknum_t( co, "root", &data->root ); + ZSD_Display_Struct_FmapExt_s_ARRAY( co, "dirExt", (unsigned int)data->numRecs, &data->dirExt[0] ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return( rc ); + +} /* End of ZSD_Display_Struct_Fmap_s() */ + + + +int ZSD_Display_Struct_ZFSPackedRoot_s( + DFI_CallerOptions_s *co, + ZFSPackedRoot_s *packedHeader2, + char *name, + BOOL doZnodeHeader ) + +{ + int rc; + Fmap_s *packedFMap; + + DFI_Display_Header_Structure( co, name, "ZFSPackedRoot_s", 0, 0, sizeof( *packedHeader2 ), packedHeader2 ); + if ( doZnodeHeader ) + { + ZSD_Display_Struct_ZnodeHeader_s( co, &packedHeader2->header, "header" ); + } + ZSD_Display_Type_BYTE( co, "beastLayout", &packedHeader2->beastLayout ); + ZSD_Display_Type_BYTE( co, "blkSizeShift", &packedHeader2->blkSizeShift ); + ZSD_Display_Type_WORD( co, "sizeFmap", &packedHeader2->sizeFmap ); + ZSD_Display_Type_LONG( co, "metaDataSeqNum", &packedHeader2->metaDataSeqNum ); + ZSD_Display_Type_QUAD( co, "eof", &packedHeader2->eof ); + ZSD_Display_Struct_UserID_t( co, "ownerID", &packedHeader2->ownerID ); + ZSD_Display_Type_Blknum_t( co, "nextBlk", &packedHeader2->nextBlk ); + ZSD_Display_Type_Blknum_t( co, "fmapDataBlks", &packedHeader2->fmapDataBlks ); + ZSD_Display_Type_Blknum_t( co, "fmapTreeBlks", &packedHeader2->fmapTreeBlks ); + ZSD_Display_Type_LONG( co, "rebuildMagic", &packedHeader2->rebuildMagic ); +//#define REBUILD_FILE_IS_GOOD 0x4F4F4752 /* "RGOO" */ +//#define REBUILD_FILE_IS_SNAPSHOT 0x574F4352 /* "RCOW" */ +//#define REBUILD_DELETE_UNREADABLE_BEAST_MAGIC 0X44414252 /* "RBAD" */ +//#define REBUILD_DELETE_BEAST_MAGIC 0X4c454452 /* "RDEL" */ +// BYTE rebuildReserved[6]; + +//zzzzz +// SNP_snprintf( WHERE, pb, "\n", packedHeader2->variableSize ); + ZSD_Display_Type_WORD( co, "variableSize", &packedHeader2->variableSize ); + + ZSD_Display_Struct_RootVariable_s( co, ((BYTE *)packedHeader2) + sizeof(*packedHeader2), packedHeader2->variableSize, name ); + packedFMap = (Fmap_s *)(((BYTE *)packedHeader2) + sizeof(*packedHeader2) + packedHeader2->variableSize); + ZSD_Display_Struct_Fmap_s( co, "fmap", 0, 0, packedFMap, packedHeader2->sizeFmap ); + rc = DFI_Display_Tail_Structure( co, "ZFSPackedRoot_s", sizeof( *packedHeader2 ), packedHeader2 ); + return( rc ); + +} /* End of ZSD_Display_Struct_ZFSPackedRoot_s() */ + + +int ZSD_Display_Struct_V1_ZFSPackedRoot_s( + DFI_CallerOptions_s *co, + V1_ZFSPackedRoot_s *packedHeader1, + char *name, + BOOL doZnodeHeader ) + +{ + int rc; + Fmap_s *packedFMap; + + TRACE5; + DFI_Display_Header_Structure( co, name, "ZFSPackedRoot_s", 0, 0, sizeof( *packedHeader1 ), packedHeader1 ); + TRACE5; + if ( doZnodeHeader ) + { + TRACE5; + ZSD_Display_Struct_ZnodeHeader_s( co, &packedHeader1->header, "header" ); + TRACE5; + } + TRACE5; + ZSD_Display_Type_BYTE( co, "beastLayout", &packedHeader1->beastLayout ); + ZSD_Display_Type_BYTE( co, "blkSizeShift", &packedHeader1->blkSizeShift ); + ZSD_Display_Type_WORD( co, "sizeFmap", &packedHeader1->sizeFmap ); + ZSD_Display_Type_LONG( co, "metaDataSeqNum", &packedHeader1->metaDataSeqNum ); + ZSD_Display_Type_QUAD( co, "eof", &packedHeader1->eof ); +// ZSD_Display_Struct_UserID_t( pb, "ownerID", &packedHeader1->ownerID ); + ZSD_Display_Type_Blknum_t( co, "nextBlk", &packedHeader1->nextBlk ); + ZSD_Display_Type_Blknum_t( co, "fmapDataBlks", &packedHeader1->fmapDataBlks ); + ZSD_Display_Type_Blknum_t( co, "fmapTreeBlks", &packedHeader1->fmapTreeBlks ); + ZSD_Display_Type_LONG( co, "rebuildMagic", &packedHeader1->rebuildMagic ); +//#define REBUILD_FILE_IS_GOOD 0x4F4F4752 /* "RGOO" */ +//#define REBUILD_FILE_IS_SNAPSHOT 0x574F4352 /* "RCOW" */ +//#define REBUILD_DELETE_UNREADABLE_BEAST_MAGIC 0X44414252 /* "RBAD" */ +//#define REBUILD_DELETE_BEAST_MAGIC 0X4c454452 /* "RDEL" */ +// BYTE rebuildReserved[6]; +// SNP_snprintf( WHERE, pb, "\n", packedHeader1->variableSize ); + TRACE5; + ZSD_Display_Type_WORD( co, "variableSize", &packedHeader1->variableSize ); + TRACE5; + ZSD_Display_Struct_RootVariable_s( co, ((BYTE *)packedHeader1) + sizeof(*packedHeader1), packedHeader1->variableSize, name ); + TRACE5; + packedFMap = (Fmap_s *)(((BYTE *)packedHeader1) + sizeof(*packedHeader1) + packedHeader1->variableSize); + ZSD_Display_Struct_Fmap_s( co, "fmap", 0, 0, packedFMap, packedHeader1->sizeFmap ); + TRACE5; + rc = DFI_Display_Tail_Structure( co, "ZFSPackedRoot_s", sizeof( *packedHeader1 ), packedHeader1 ); + TRACE5; + return( rc ); + +} /* End of ZSD_Display_Struct_V1_ZFSPackedRoot_s() */ + + +int ZSD_Display_Struct_ZnodeHeader_s( + DFI_CallerOptions_s *co, + ZnodeHeader_s *znodeHeader, + char *name ) +{ + int rc; + + DFI_Display_Header_Structure( co, name, "ZnodeHeader_s", 0, 0, sizeof( *znodeHeader ), znodeHeader ); + ZSD_Display_Type_WORD( co, "length", &znodeHeader->length ); + ZSD_Display_Type_WORD( co, "magic", &znodeHeader->magic ); + ZSD_Display_Type_LONG( co, "type", &znodeHeader->type ); + ZSD_Display_Type_Zid_t( co, "zid", &znodeHeader->zid ); + rc = DFI_Display_Tail_Structure( co, "ZnodeHeader_s", sizeof( *znodeHeader ), znodeHeader ); + return( rc ); +} /* End of ZSD_Display_Struct_ZnodeHeader_s() */ + + +int ZSD_Display_Struct_PersistentZlssVolumeLocator_s( + DFI_CallerOptions_s *co, + PersistentZlssVolumeLocator_s *pzvl, + char *name ) +{ + char *structureName = "PersistentZlssVolumeLocator_s"; + int rc; + + + DFI_Display_Header_Structure( co, name, structureName, 0, 0, sizeof( *pzvl ), pzvl ); + ZSD_Display_Type_LONG( co , "PZVL_signature", &pzvl->PZVL_signature ); + ZSD_Display_Type_WORD( co , "PZVL_versionMajor", &pzvl->PZVL_versionMajor ); + ZSD_Display_Type_WORD( co , "PZVL_versionMinor", &pzvl->PZVL_versionMinor ); + ZSD_Display_Type_QBlknum_t( co, "PZVL_loggedVolumeDataBlk", &pzvl->PZVL_loggedVolumeDataBlk ); + ZSD_Display_Type_QBlknum_t( co, "PZVL_volumeDataBlk", &pzvl->PZVL_volumeDataBlk ); + ZSD_Display_Type_QBlknum_t( co, "PZVL_systemBeastBlkNum", &pzvl->PZVL_systemBeastBlkNum ); + ZSD_Display_Struct_VolumeID_t( co, "PZVL_volumeID", &pzvl->PZVL_volumeID ); + ZSD_Display_Type_LONG( co , "PZVL_signature", &pzvl->PZVL_state ); +//#define PZVL_S_CREATION_DELETE 0 /* Volume is being created, but if at load +//#define PZVL_S_CREATION 1 /* Volume is being created. +//#define PZVL_S_CREATED 2 /* Volume is created (this is the normal +//#define PZVL_S_DELETION 3 /* Volume is being deleted */ + ZSD_Display_Type_LONG( co , "PZVL_subState", &pzvl->PZVL_subState ); +//#define PZVL_SS_DELETE_SALVAGEABLE 0 +//#define PZVL_SS_DELETE_TRUNCATE_UST_DST_MFL 1 +//#define PZVL_SS_DELETE_TRUNCATE_ALL_OBJECTS 2 +//#define PZVL_SS_DELETE_TRUNCATE_NT 3 +//#define PZVL_SS_DELETE_TRUNCATE_BT 4 +//#define PZVL_SS_DELETE_STEP_PLOG_MOVE 5 +//#define PZVL_SS_DELETE_STEP_PLOG_TRUNCATE 6 +//#define PZVL_SS_DELETE_STEP_FREE_LAST_BLOCKS 7 +//#define PZVL_SS_DELETE_STEP_DELETE_ZVLB 8 + + ZSD_Display_Struct_VolumeID_t( co, "PZVL_volumeIDOriginal", &pzvl->PZVL_volumeIDOriginal ); + ZSD_Display_Struct_GUID_t( co, "PZVL_internalID", &pzvl->PZVL_internalID ); + ZSD_Display_Type_unicode_t_STR( co, "PZVL_volumeName", NELEMS( pzvl->PZVL_volumeName ), &pzvl->PZVL_volumeName[0] ); + { +// SNP_snprintf( WHERE, pb, "\n" ); + ZSD_Display_Type_Time_t( co, "PZVL_deleteTimeStart", &pzvl->PZVL_deleteTimeStart ); + ZSD_Display_Type_LONG( co , "PZVL_deleteState", &pzvl->PZVL_deleteState ); +//#define ZVL_DS_SALVAGEABLE 0 /* Waiting for purge time */ +//#define ZVL_DS_PURGEING 1 /* LV is being purged. May not mean being +//#define ZVL_DS_PURGEING_PAUSED 2 /* Paused by user AFTER purge started */ +//#define ZVL_DS_SALVAGEABLE_PAUSED 3 /* Paused by user BEFORE purge started */ +//#define ZVL_DS_PURGE_ERROR 4 /* Last purge did not complete */ +//#define ZVL_DS_UNDELETE 5 /* Thread actively undeleting LV. */ +//#define ZVL_DS_UNDELETE_ERROR 6 /* Last undelete did not complete */ +//#define ZVL_DS_SALVAGED 7 /* LV has been salvaged. This state is +//#define ZVL_DS_UNKNOWN 8 /* Unknown state (should not happen + ZSD_Display_Type_unicode_t_STR( co, "PZVL_volumeNameOriginal", NELEMS( pzvl->PZVL_volumeNameOriginal ), &pzvl->PZVL_volumeNameOriginal[0] ); + ZSD_Display_Type_LONG( co , "PZVL_errno", &pzvl->PZVL_errno ); + ZSD_Display_Type_char_STR( co, "PZVL_errnoSetter", NELEMS( pzvl->PZVL_errnoSetter ), &pzvl->PZVL_errnoSetter[0] ); + { +// SNP_snprintf( WHERE, pb, "\n" ); + ZSD_Display_Type_Time_t( co, "PZVL_purgeTimeStart", &pzvl->PZVL_purgeTimeStart ); + ZSD_Display_Type_Time_t( co, "PZVL_purgeTimeLastStart", &pzvl->PZVL_purgeTimeLastStart ); + ZSD_Display_Type_Time_t( co, "PZVL_purgeTimeLastEnd", &pzvl->PZVL_purgeTimeLastEnd ); + ZSD_Display_Type_QBlknum_t( co, "PZVL_purgeLogBlocks", &pzvl->PZVL_purgeLogBlocks ); + ZSD_Display_Type_Zid_t( co, "PZVL_lastZidTruncated", &pzvl->PZVL_lastZidTruncated ); +// SNP_snprintf( WHERE, pb, "\n" ); + } +// SNP_snprintf( WHERE, pb, "\n" ); + } + { +// SNP_snprintf( WHERE, pb, "\n" ); + ZSD_Display_Struct_GUID_t( co, "PZVL_snapshotID", &pzvl->PZVL_snapshotID ); + ZSD_Display_Struct_VolumeID_t( co, "PZVL_volumeIDSnapshot", &pzvl->PZVL_volumeIDSnapshot ); + ZSD_Display_Struct_VolumeID_t( co, "PZVL_volumeIDOriginalSnapshot", &pzvl->PZVL_volumeIDOriginalSnapshot ); + ZSD_Display_Type_unicode_t_STR( co, "PZVL_volumeNameSnapshot", NELEMS( pzvl->PZVL_volumeNameSnapshot ), &pzvl->PZVL_volumeNameSnapshot[0] ); + ZSD_Display_Type_LONG( co, "PZVL_stateSnapshot", &pzvl->PZVL_stateSnapshot ); + ZSD_Display_Type_unicode_t_STR( co, "PZVL_volumeNameOriginalSnapshot", NELEMS( pzvl->PZVL_volumeNameOriginalSnapshot ), &pzvl->PZVL_volumeNameOriginalSnapshot[0] ); +// SNP_snprintf( WHERE, pb, "\n" ); + } + ZSD_Display_Type_LONG( co , "PZVL_authModelID", &pzvl->PZVL_authModelID ); +// LONG PZVL_reserved[200]; + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *pzvl ), pzvl ); + return ( rc ); + +} /* End of ZSD_Display_Struct_PersistentZlssVolumeLocator_s() */ + + +int ZSD_Display_Struct_PersistentPersistentHardLink_s( + DFI_CallerOptions_s *co, + PersistentHardLink_s *hLink, + char *name ) +{ + char *structureName = "PersistentHardLink_s"; + int rc; + + DFI_Display_Header_Structure( co, name, structureName, 0, 0, sizeof( *hLink ), hLink ); + + ZSD_Display_Type_BYTE( co , "version", &hLink->version ); + ZSD_Display_Type_BYTE( co , "hlFlags", &hLink->hlFlags ); + ZSD_Display_Type_WORD( co , "reserved1", &hLink->reserved1 ); + ZSD_Display_Type_Zid_t( co, "primaryZid", &hLink->primaryZid ); + ZSD_Display_Type_LONG_ARRAY( co, "reserved2", NELEMS(hLink->reserved2), hLink->reserved2 ); + + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *hLink ), hLink ); + return ( rc ); + +} /* End of ZSD_Display_Struct_PersistentPersistentHardLink_s() */ + + + +int ZSD_Display_Struct_PersistentZfsPurgeLog_s( + DFI_CallerOptions_s *co, + PersistentZfsPurgeLog_s *purgeLog, + char *name ) + +{ + char *structureName = "PersistentZfsPurgeLog_s"; + int rc; + + DFI_Display_Header_Structure( co, name, structureName, 0, 0, sizeof( *purgeLog ), purgeLog ); + ZSD_Display_Type_Blknum_t( co, "firstBlock", &purgeLog->firstBlock ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *purgeLog ), purgeLog ); + return ( rc ); + +} /* End of ZSD_Display_Struct_PersistentZfsPurgeLog_s() */ + + +// +// The Beast B-Tree actually has some beast specific persistent informaiton!!! +// It is not used. +// +int ZSD_Display_Struct_PersistentZfsBeastTree_s( + DFI_CallerOptions_s *co, + PersistentZfsBeastTree_s *data, + char *name ) +{ + char *structureName = "PersistentZfsBeastTree_s"; + int rc; + + DFI_Display_Header_Structure( co, name, structureName, 0, 0, sizeof( *data ), data ); + ZSD_Display_Type_Blknum_t( co, "deletevolumeDataBlk", &data->deletevolumeDataBlk ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return ( rc ); + +} /* End of ZSD_Display_Struct_PersistentZfsBeastTree_s() */ + + +int ZSD_Display_Struct_PersistentZfsBtree_s( + DFI_CallerOptions_s *co, + PersistentZfsBtree_s *btree, + char *name ) + +{ + char *structureName = "PersistentZfsBtree_s"; + int rc; + + DFI_Display_Header_Structure( co, name, structureName, 0, 0, sizeof( *btree ), btree ); + ZSD_Display_Type_Blknum_t( co, "btRoot", &btree->btRoot ); + ZSD_Display_Type_Blknum_t( co, "btFree", &btree->btFree ); + ZSD_Display_Type_Blknum_t( co, "btLeftMostLeaf", &btree->btLeftMostLeaf ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *btree ), btree ); + return ( rc ); + +} /* End of ZSD_Display_Struct_PersistentZfsBtree_s() */ + + +int ZSD_Display_Struct_PersistentZfsEFLTree_s( + DFI_CallerOptions_s *co, + PersistentZfsEFLTree_s *efl, + char *name ) + +{ + SIZEOF size; + DFI_DataFormatInformation_s dfi = { DFI_TYPE_STRUCT , SDM_Structure, 0, "", 0, "PersistentZfsEFLTree_s", sizeof(PersistentZfsEFLTree_s), DFI_PersistentZfsEFLTree_s }; + + (void)ZSD_Display_Struct_PersistentZfsBtree_s( co, (PersistentZfsBtree_s *)efl, name ); + dfi.DFI_Name = name; + size = SDM_Structure( co, &dfi, (BYTE *)efl, 0, 0 ); + return ( zOK ); + +} /* End of ZSD_Display_Struct_ZlogBeastPersistent_s() */ + + +int ZSD_Display_Struct_ZlogBeastPersistent_s( + DFI_CallerOptions_s *co, + ZlogBeastPersistent_s *zlog, + char *name ) + +{ + SIZEOF size; + DFI_DataFormatInformation_s dfi = { DFI_TYPE_STRUCT , SDM_Structure, 0, "", 0, "ZlogBeastPersistent_s", sizeof(ZlogBeastPersistent_s), DFI_ZlogBeastPersistent_s }; + + dfi.DFI_Name = name; + size = SDM_Structure( co, &dfi, (BYTE *)zlog, 0, 0 ); + return ( zOK ); + +} /* End of ZSD_Display_Struct_ZlogBeastPersistent_s() */ + + +int ZSD_Display_Struct_V1_ZASPersistentAuthInfo_s( + DFI_CallerOptions_s *co, + V1_ZASPersistentAuthInfo_s *zasAuth, + char *name ) + +{ + V1_ACLEntry_s *aclEntry; + V1_VisEntry_s *visEntry; + char *structureName = "V1_ZASPersistentAuthInfo_s"; + int rc; + + TRACE5; + DFI_Display_Header_Structure( co, name, structureName, 0, 0, sizeof( *zasAuth ), zasAuth ); + TRACE5; + ZSD_Display_Type_LONG( co, "cacheIndex", &zasAuth->cacheIndex ); + ZSD_Display_Type_LONG( co, "restartCount", &zasAuth->restartCount ); + ZSD_Display_Type_LONG( co, "signature", &zasAuth->signature ); + ZSD_Display_Type_LONG( co, "inheritedRightsMask", &zasAuth->inheritedRightsMask ); + ZSD_Display_Type_Zid_t( co, "trusteeOverflow", &zasAuth->trusteeOverflow ); + ZSD_Display_Type_Zid_t( co, "visibilityOverflow", &zasAuth->visibilityOverflow ); + ZSD_Display_Type_LONG( co, "extra", &zasAuth->extra ); + ZSD_Display_Type_WORD( co, "numTrusteesAssigned", &zasAuth->numTrusteesAssigned ); + ZSD_Display_Type_WORD( co, "numVisibilityTrusteesAssigned", &zasAuth->numVisibilityTrusteesAssigned ); + TRACE5; + aclEntry = (V1_ACLEntry_s *)(zasAuth+1); + if ( zasAuth->numTrusteesAssigned != 0 ) + { + TRACE5; + ZSD_Display_Struct_V1_ACLEntry_s_ARRAY( co, "V1_ACLEntry_s", zasAuth->numTrusteesAssigned, aclEntry ); + TRACE5; + } + visEntry = (V1_VisEntry_s *)(aclEntry + zasAuth->numTrusteesAssigned); + if ( zasAuth->numVisibilityTrusteesAssigned != 0 ) + { + TRACE5; + ZSD_Display_Struct_V1_VisEntry_s_ARRAY( co, "V1_VisEntry_s", zasAuth->numVisibilityTrusteesAssigned, visEntry ); + TRACE5; + } + TRACE5; + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *zasAuth ), zasAuth ); + TRACE5; + return( rc ); +} /* End of ZSD_Display_Struct_V1_ZASPersistentAuthInfo_s() */ + + +int ZSD_Display_Struct_ZASPersistentAuthInfo_s( + DFI_CallerOptions_s *co, + ZASPersistentAuthInfo_s *zasAuth, + char *name ) + +{ + ACLEntry_s *aclEntry; + VisEntry_s *visEntry; + int rc; + int size; + + size = offsetof( ZASPersistentAuthInfo_s, ACL ) + + ( sizeof(ACLEntry_s) * zasAuth->numTrusteesAssigned ) + + ( sizeof(VisEntry_s) * zasAuth->numVisibilityTrusteesAssigned ); + + DFI_Display_Header_Structure( co, name, "ZASPersistentAuthInfo_s", 0, 0, size, zasAuth ); + ZSD_Display_Type_WORD( co, "version", &zasAuth->version ); + ZSD_Display_Type_WORD( co, "extra1", &zasAuth->extra1 ); + ZSD_Display_Type_LONG( co, "extra2", &zasAuth->extra2 ); + ZSD_Display_Type_LONG( co, "cacheIndex", &zasAuth->cacheIndex ); + ZSD_Display_Type_LONG( co, "restartCount", &zasAuth->restartCount ); + ZSD_Display_Type_LONG( co, "signature", &zasAuth->signature ); + ZSD_Display_Type_LONG( co, "inheritedRightsMask", &zasAuth->inheritedRightsMask ); + ZSD_Display_Type_Zid_t( co, "trusteeOverflow", &zasAuth->trusteeOverflow ); + ZSD_Display_Type_Zid_t( co, "visibilityOverflow", &zasAuth->visibilityOverflow ); + ZSD_Display_Type_WORD( co, "numTrusteesAssigned", &zasAuth->numTrusteesAssigned ); + ZSD_Display_Type_WORD( co, "numVisibilityTrusteesAssigned", &zasAuth->numVisibilityTrusteesAssigned ); + aclEntry = &zasAuth->ACL[0]; + if ( zasAuth->numTrusteesAssigned != 0 ) + { + ZSD_Display_Struct_ACLEntry_s_ARRAY( co, "ACLEntry_s", zasAuth->numTrusteesAssigned, aclEntry ); + } + visEntry = (VisEntry_s *)(aclEntry + zasAuth->numTrusteesAssigned); + if ( zasAuth->numVisibilityTrusteesAssigned != 0 ) + { + ZSD_Display_Struct_VisEntry_s_ARRAY( co, "VisEntry_s", zasAuth->numVisibilityTrusteesAssigned, visEntry ); + } + rc = DFI_Display_Tail_Structure( co, "ZASPersistentAuthInfo_s", size, zasAuth ); + return( rc ); +} /* End of ZSD_Display_Struct_ZASPersistentAuthInfo_s() */ + +int ZSD_Display_Struct_UNIXPersistentAuthInfo_s( + DFI_CallerOptions_s *co, + UXASPersistentAuthInfo_s *uxAuth, + char *name ) + +{ + int rc; + int size; + + size = sizeof(UXASPersistentAuthInfo_s); + + DFI_Display_Header_Structure( co, name, "UXASPersistentAuthInfo_s", 0, 0, size, uxAuth ); + ZSD_Display_Type_WORD( co, "version", &uxAuth->version ); + ZSD_Display_Type_WORD( co, "extra1", &uxAuth->extra1 ); + ZSD_Display_Type_LONG( co, "mode", &uxAuth->mode ); + ZSD_Display_Struct_UserID_t( co, "groupID", &uxAuth->groupID ); + ZSD_Display_Type_LONG_ARRAY( co, "unused", 8, uxAuth->unused ); + rc = DFI_Display_Tail_Structure( co, "UXASPersistentAuthInfo_s", size, uxAuth ); + return( rc ); +} /* End of ZSD_Display_Struct_UNIXPersistentAuthInfo_s() */ + + +int ZSD_Display_Struct_V1_ACLEntry_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, /* Number of array elements */ + V1_ACLEntry_s *entry ) +{ + char *structureName = "V1_ACLEntry_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *entry ), entry ); + ZSD_Display_Type_LONG( co, "trusteeID", &entry->trusteeID ); + ZSD_Display_Type_WORD( co, "rights", &entry->rights ); + ZSD_Display_Type_WORD( co, "attributes", &entry->attributes ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *entry ), entry ); + return( rc ); + +} /* End of ZSD_Display_Struct_V1_ACLEntry_s() */ + + +int ZSD_Display_Struct_V1_ACLEntry_s_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, /* Number of array elements */ + V1_ACLEntry_s *data ) /* Array of .. */ +{ + int rc; + unsigned int index; + +// printf("arrayElements = %u\n",arrayElements); + TRACE5; + DFI_Display_Header_ARRAY( co, tag, "V1_ACLEntry_s", arrayElements, arrayElements * sizeof( *data ), &data[0] ); + TRACE5; + for ( index = 0; index < arrayElements; index++ ) + { + TRACE5; + rc = ZSD_Display_Struct_V1_ACLEntry_s( co, tag, index, arrayElements, &data[index] ); + TRACE5; + } + TRACE5; + rc = DFI_Display_Tail_ARRAY( co, tag, "V1_ACLEntry_s" ); + TRACE5; + return( rc ); +} /* End of ZSD_Display_Struct_V1_ACLEntry_s_ARRAY() */ + + +int ZSD_Display_Struct_V1_VisEntry_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + V1_VisEntry_s *entry ) +{ + char *structureName = "V1_VisEntry_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *entry ), entry ); + ZSD_Display_Type_LONG( co, "trusteeID", &entry->trusteeID ); + ZSD_Display_Type_LONG( co, "count", &entry->count ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *entry ), entry ); + return( rc ); + +} /* End of ZSD_Display_Struct_V1_VisEntry_s() */ + + +int ZSD_Display_Struct_V1_VisEntry_s_ARRAY( + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + V1_VisEntry_s *data ) /* Array of .. */ +{ + int rc; + unsigned int index; + + DFI_Display_Header_ARRAY( co, tag, "V1_VisEntry_s", arrayElements, arrayElements * sizeof( *data ), &data[0] ); + for ( index = 0; index < arrayElements; index++ ) + { + rc = ZSD_Display_Struct_V1_VisEntry_s( co, tag, index, arrayElements, &data[index] ); + } + rc = DFI_Display_Tail_ARRAY( co, tag, "V1_VisEntry_s" ); + return( rc ); +} /* End of ZSD_Display_Struct_V1_VisEntry_s_ARRAY() */ + + +int ZSD_Display_Struct_ACLEntry_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, /* Number of array elements */ + ACLEntry_s *entry ) +{ + char *structureName = "ACLEntry_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *entry ), entry ); + ZSD_Display_Struct_UserID_t( co, "trusteeID", &entry->trusteeID ); + ZSD_Display_Type_WORD( co, "rights", &entry->rights ); + rc = ZSD_Display_Type_WORD( co, "attributes", &entry->attributes ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *entry ), entry ); + return( rc ); + +} + + +int ZSD_Display_Struct_ACLEntry_s_ARRAY( + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, /* Number of array elements */ + ACLEntry_s *data ) /* Array of .. */ +{ + int rc; + unsigned int index; + + DFI_Display_Header_ARRAY( co, tag, "ACLEntry_s", arrayElements, arrayElements * sizeof( *data ), &data[0] ); + for ( index = 0; index < arrayElements; index++ ) + { + rc = ZSD_Display_Struct_ACLEntry_s( co, tag, index, arrayElements, &data[index] ); + } + rc = DFI_Display_Tail_ARRAY( co, tag, "ACLEntry_s" ); + return( rc ); +} /* End of ZSD_Display_Struct_ACLEntry_s_ARRAY() */ + + +int ZSD_Display_Struct_PurgeQNewKey_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + PurgeQNewKey_s *data ) +{ + int rc; + char *structureName = "PurgeQNewKey_s"; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *data ), data ); + ZSD_Display_Struct_GUID_t( co, "internalID", &data->internalID ); + ZSD_Display_Type_Zid_t( co, "zid", &data->zid ); + ZSD_Display_Type_Time_t( co, "deltime", &data->deltime ); +// cnt ZSD_Display_Type_WORD( co, "nameUniquifier", &data->nameUniquifier ); + ZSD_Display_Type_LONG( co, "reserved", &data->reserved ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return( rc ); + +} + + +int ZSD_Display_Struct_PurgeQNewValue_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + PurgeQNewValue_s *data ) +{ + int rc; + char *structureName = "PurgeQNewValue_s"; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *data ), data ); + ZSD_Display_Type_Zid_t( co, "pzid", &data->pzid ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + return( rc ); + +} + + +int ZSD_Display_Struct_PurgeNewInfo_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + PurgeNewInfo_s *data ) +{ + char *structureName = "PurgeNewInfo_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *data ), data ); + ZSD_Display_Struct_PurgeQNewKey_s( co, "key", 0, 0, &data->key ); + ZSD_Display_Struct_PurgeQNewValue_s( co, "value", 0, 0, &data->value ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *data ), data ); + + return( rc ); + +} + + +int ZSD_Display_Struct_PurgeNewInfo_s_ARRAY( + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + PurgeNewInfo_s *data ) /* Array of .. */ +{ + int rc; + unsigned int index; + + DFI_Display_Header_ARRAY( co, tag, "PurgeNewInfo_s", arrayElements, arrayElements * sizeof( *data ), &data[0] ); + for ( index = 0; index < arrayElements; index++ ) + { + rc = ZSD_Display_Struct_PurgeNewInfo_s( co, tag, index, arrayElements, &data[index] ); + } + rc = DFI_Display_Tail_ARRAY( co, tag, "PurgeNewInfo_s" ); + return( rc ); +} /* End of ZSD_Display_Struct_PurgeNewInfo_s_ARRAY() */ + + +int ZSD_Display_Struct_VisEntry_s( + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, /* Number of array elements */ + VisEntry_s *entry ) +{ + char *structureName = "VisEntry_s"; + int rc; + + DFI_Display_Header_Structure( co, tag, structureName, index, arrayElements, sizeof( *entry ), entry ); + ZSD_Display_Struct_UserID_t( co, "trusteeID", &entry->trusteeID ); + ZSD_Display_Type_LONG( co, "count", &entry->count ); + rc = DFI_Display_Tail_Structure( co, structureName, sizeof( *entry ), entry ); + return( rc ); + +} + + +int ZSD_Display_Struct_VisEntry_s_ARRAY( + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + VisEntry_s *data ) /* Array of .. */ +{ + int rc; + unsigned int index; + + DFI_Display_Header_ARRAY( co, tag, "VisEntry_s", arrayElements, arrayElements * sizeof( *data ), &data[0] ); + for ( index = 0; index < arrayElements; index++ ) + { + rc = ZSD_Display_Struct_VisEntry_s( co, tag, index, arrayElements, &data[index] ); + } + rc = DFI_Display_Tail_ARRAY( co, tag, "VisEntry_s" ); + return( rc ); +} /* End of ZSD_Display_Struct_VisEntry_s_ARRAY() */ + + +/* + * If we get this routine simple relating to inputs then + * we may be able to use in ZAD to unpack Beast B-Tree + * LOG records. ZAD unpacks some beast stuff now, but + * not the full beast. + */ +int ZSD_Display_Struct_Znode_s( + Znode_s *znode, + DFI_CallerOptions_s *co, + char *name ) +{ + int rc; + void *systemBeastSpecific; + + DFI_Display_Header_Structure( co, name, "Znode_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, znode ); + rc = ZSD_Display_Struct_ZnodeHeader_s( co, &znode->header, "header" ); + /*** + *** DANGER DANGER DANGER DANGER DANGER DANGER DANGER DANGER + *** + *** You can only cast a Znode_t into a ZFSPackedRoot_s if not the ZERO_MAGIC entry. + *** + *** DANGER DANGER DANGER DANGER DANGER DANGER DANGER DANGER + ***/ + if ( znode->header.magic == ZERO_MAGIC ) + { /* Specical ZERO_MAGIC (Only ZnodeHeader_s valid) */ + goto exit; + } + TRACE5; + rc = BeastUnpack( (ZFSPackedRoot_s *)znode, co, &systemBeastSpecific, "data" ); + TRACE5; + if ( rc != 0 ) + { + printf("%s RC is %d\n",WHERE,rc); + } + else + { + switch ( znode->header.type ) + { + case zFTYPE_EXTENDED_ATTRIBUTE: // Unpacked as part of BeastUnpack (since Dec 2003) + case zFTYPE_ROOT_BEAST: + case zFTYPE_NAMED_DATA_STREAM: + case zFTYPE_AUTH_BEAST: + case zFTYPE_FILE: + break; + case zFTYPE_ZAS_ACL_OVERFLOW: // Unpacked as part of BeastUnpack + case zFTYPE_ZAS_VIS_OVERFLOW: // Unpacked as part of BeastUnpack + break; + case zFTYPE_ZLSS_FREE_EXTENT: + rc = ZSD_Display_Struct_PersistentZfsBtree_s( co, systemBeastSpecific, name ); + BN_Notify( znode->header.type, co, &znode->header, systemBeastSpecific ); + break; + case zFTYPE_ZLSS_SALVAGE: + rc = ZSD_Display_Struct_PersistentZfsBtree_s( co, systemBeastSpecific, name ); + BN_Notify( znode->header.type, co, &znode->header, systemBeastSpecific ); + break; + case zFTYPE_ZLSS_NAME_TREE: + rc = ZSD_Display_Struct_PersistentZfsBtree_s( co, systemBeastSpecific, name ); + BN_Notify( znode->header.type, co, &znode->header, systemBeastSpecific ); + break; + case zFTYPE_ZLSS_USER_TREE: + rc = ZSD_Display_Struct_PersistentZfsBtree_s( co, systemBeastSpecific, name ); + BN_Notify( znode->header.type, co, &znode->header, systemBeastSpecific ); + break; + case zFTYPE_ZLSS_DIR_TREE: + rc = ZSD_Display_Struct_PersistentZfsBtree_s( co, systemBeastSpecific, name ); + BN_Notify( znode->header.type, co, &znode->header, systemBeastSpecific ); + break; + case zFTYPE_ZLSS_PURGE_LOG: + rc = ZSD_Display_Struct_PersistentZfsPurgeLog_s( co, systemBeastSpecific, name ); + BN_Notify( znode->header.type, co, &znode->header, systemBeastSpecific ); + break; + case zFTYPE_ZLSS_BEAST_TREE: + rc = ZSD_Display_Struct_PersistentZfsBtree_s( co, systemBeastSpecific, name ); + // July 9, 2003 - The Beast B-Tree has some specific presistent information!!! + rc = ZSD_Display_Struct_PersistentZfsBeastTree_s( co, + (void *)(((BYTE *)systemBeastSpecific) + sizeof( PersistentZfsBtree_s ) ), name ); + /* Note that notify is called with systemBeastSpecific set to PersistentZfsBtree_s so that + * notify can look at both PersistentZfsBtree_s and PersistentZfsEFLTree_s. + */ + BN_Notify( znode->header.type, co, &znode->header, systemBeastSpecific ); + break; + case zFTYPE_ZLSS_VOLUME_LOCATOR: + rc = ZSD_Display_Struct_PersistentZlssVolumeLocator_s( co, systemBeastSpecific, name ); + BN_Notify( znode->header.type, co, &znode->header, systemBeastSpecific ); + break; + case zFTYPE_ZLSS_LOG: + rc = ZSD_Display_Struct_ZlogBeastPersistent_s( co, systemBeastSpecific, name ); + BN_Notify( znode->header.type, co, &znode->header, systemBeastSpecific ); + break; + case zFTYPE_ZLSS_EFL: + rc = ZSD_Display_Struct_PersistentZfsBtree_s( co, systemBeastSpecific, name ); + rc = ZSD_Display_Struct_PersistentZfsEFLTree_s( co, + (void *)(((BYTE *)systemBeastSpecific) + sizeof( PersistentZfsBtree_s ) ), name ); + /* Note that notify is called with systemBeastSpecific set to PersistentZfsBtree_s so that + * notify can look at both PersistentZfsBtree_s and PersistentZfsEFLTree_s. + */ + BN_Notify( znode->header.type, co, &znode->header, systemBeastSpecific ); + break; + case zFTYPE_COMPRESSION: // Part of BeastUnpack (since ~2004) + case zFTYPE_COMPRESSION_INTERMEDIATE: // Part of BeastUnpack (since ~2004) + break; + case zFTYPE_HARDLINK_BEAST: + rc = ZSD_Display_Struct_PersistentPersistentHardLink_s( co, (PersistentHardLink_s *)systemBeastSpecific, name ); + BN_Notify( znode->header.type, co, &znode->header, systemBeastSpecific ); + break; + default: + printf("*** %s Code does NOT have an complete unpack for %d type beast\n", WHERE, znode->header.type); + } +// if ( znode->header.type < NELEMS( BN_NotifyTable ) ) +// { +// BN_PersistentZlssVolumeLocator( znode->header.type, pb, znode, systemBeastSpecific ); +// } + } +exit: + rc = DFI_Display_Tail_Structure( co, "Znode_s", DFI_VARIABLE_SIZE_INKNOWN, znode ); + return( rc ); + +} + + +/* + * Returns - + * Amount used or 0 for error. + */ +int ZSD_Display_Struct_PackedCompInfo_s( + DFI_CallerOptions_s *co, + BYTE *variable, + int variableSize, /* Amount Left */ + char *name ) + +{ + PackedCompInfo_s *curVar = (PackedCompInfo_s *)variable; + + DFI_Display_Header_Structure( co, name, "PackedCompInfo_s", 0, 0, sizeof( *curVar), curVar ); + ZSD_Display_Type_WORD( co, "rvdID", &curVar->rvdID ); + ZSD_Display_Type_WORD( co, "rvdLayout", &curVar->rvdLayout ); + ZSD_Display_Type_Zid_t( co, "compZid", &curVar->cmInfo.compZid ); + ZSD_Display_Type_LONG( co, "chunkSize", &curVar->cmInfo.chunkSize ); + ZSD_Display_Type_LONG( co, "UCprecious", &curVar->cmInfo.UCprecious ); + ZSD_Display_Type_LONG( co, "Cprecious", &curVar->cmInfo.Cprecious ); + ZSD_Display_Type_Blkcnt_t( co, "purgeableBlks", &curVar->cmInfo.purgeableBlks ); + ZSD_Display_Type_BYTE( co, "algoID", &curVar->cmInfo.algoID ); + ZSD_Display_Type_BYTE( co, "algoVersion", &curVar->cmInfo.algoVersion ); + ZSD_Display_Type_BYTE( co, "status", &curVar->cmInfo.status ); + ZSD_Display_Type_BYTE( co, "action", &curVar->cmInfo.action ); + DFI_Display_Tail_Structure( co, "PackedCompInfo_s", sizeof( *curVar), curVar ); + return( sizeof( *curVar ) ); + +} /* End of ZSD_Display_Struct_PackedCompInfo_s() */ + + +/* + * Returns - + * Amount used or 0 for error. + */ +int ZSD_Display_Struct_PackedUnixInfo_Layout1_s( + DFI_CallerOptions_s *co, + BYTE *variable, + int variableSize, /* Amount Left */ + char *name ) + +{ + PackedUnixInfo_Layout1_s *curVar = (PackedUnixInfo_Layout1_s *)variable; + + DFI_Display_Header_Structure( co, name, "PackedUnixInfo_Layout1_s", 0, 0, sizeof( *curVar), curVar ); + ZSD_Display_Type_WORD( co, "rvdID", &curVar->rvdID ); + ZSD_Display_Type_WORD( co, "rvdLayout", &curVar->rvdLayout ); + ZSD_Display_Type_LONG( co, "groupID", &curVar->unixInfo.groupID ); + ZSD_Display_Type_LONG( co, "userID", &curVar->unixInfo.userID ); + ZSD_Display_Type_LONG( co, "fMode", &curVar->unixInfo.fMode ); + ZSD_Display_Type_LONG( co, "rDev", &curVar->unixInfo.rDev ); + ZSD_Display_Type_LONG( co, "myFlags", &curVar->unixInfo.myFlags ); + ZSD_Display_Type_BYTE( co, "acsFlags", &curVar->unixInfo.acsFlags ); + ZSD_Display_Type_BYTE( co, "firstCreated", &curVar->unixInfo.firstCreated ); + ZSD_Display_Type_BYTE_ARRAY( co, "filler", NELEMS( curVar->unixInfo.filler ), curVar->unixInfo.filler ); + ZSD_Display_Type_LONG( co, "reserved", &curVar->reserved ); + DFI_Display_Tail_Structure( co, "PackedUnixInfo_Layout1_s", sizeof( *curVar), curVar ); + return( sizeof( *curVar ) ); + +} /* End of ZSD_Display_Struct_PackedUnixInfo_Layout1_s() */ + + +/* + * Returns - + * Amount used or 0 for error. + */ +int ZSD_Display_Struct_PackedUnixInfo_s( + DFI_CallerOptions_s *co, + BYTE *variable, + int variableSize, /* Amount Left */ + char *name ) + +{ + PackedUnixInfo_s *curVar = (PackedUnixInfo_s *)variable; + unsigned int size; + + if ( curVar->rvdLayout == 1 ) + { + return( ZSD_Display_Struct_PackedUnixInfo_Layout1_s( co, variable, variableSize, name ) ); + } + size = sizeof( *curVar ) + curVar->unixInfo.variableSize; + DFI_Display_Header_Structure( co, name, "PackedUnixInfo_s", 0, 0, size, curVar ); + ZSD_Display_Type_WORD( co, "rvdID", &curVar->rvdID ); + ZSD_Display_Type_WORD( co, "rvdLayout", &curVar->rvdLayout ); + ZSD_Display_Type_LONG( co, "fMode", &curVar->unixInfo.fMode ); + ZSD_Display_Type_LONG( co, "rDev", &curVar->unixInfo.rDev ); + ZSD_Display_Type_LONG( co, "myFlags", &curVar->unixInfo.myFlags ); + ZSD_Display_Type_LONG( co, "nfsUID", &curVar->unixInfo.nfsUID ); + ZSD_Display_Type_LONG( co, "nfsGID", &curVar->unixInfo.nfsGID ); + ZSD_Display_Type_LONG( co, "nwUID", &curVar->unixInfo.nwUID ); + ZSD_Display_Type_LONG( co, "nwGID", &curVar->unixInfo.nwGID ); + ZSD_Display_Type_LONG( co, "nwEveryone", &curVar->unixInfo.nwEveryone ); + ZSD_Display_Type_LONG( co, "nwUIDRights", &curVar->unixInfo.nwUIDRights ); + ZSD_Display_Type_LONG( co, "nwGIDRights", &curVar->unixInfo.nwGIDRights ); + ZSD_Display_Type_LONG( co, "nwEveryoneRights", &curVar->unixInfo.nwEveryoneRights ); + ZSD_Display_Type_BYTE( co, "acsFlags", &curVar->unixInfo.acsFlags ); + ZSD_Display_Type_BYTE( co, "firstCreated", &curVar->unixInfo.firstCreated ); + ZSD_Display_Type_SWORD( co, "variableSize", &curVar->unixInfo.variableSize ); + if ( curVar->unixInfo.variableSize > 0 ) + { + ZSD_Display_Type_BYTE_ARRAY( co, "variableSizeData", (WORD)curVar->unixInfo.variableSize, + ((BYTE *)&curVar->unixInfo.variableSize) + sizeof( curVar->unixInfo.variableSize ) ); + } + DFI_Display_Tail_Structure( co, "PackedUnixInfo_s", size, curVar ); + return( sizeof( *curVar ) + curVar->unixInfo.variableSize ); + +} /* End of ZSD_Display_Struct_PackedUnixInfo_s() */ + + +/* + * Returns - + * Amount used or 0 for error. + */ +int ZSD_Display_Struct_PackedMacInfo_s( + DFI_CallerOptions_s *co, + BYTE *variable, + int variableSize, /* Amount Left */ + char *name ) + +{ + PackedMacInfo_s *curVar = (PackedMacInfo_s *)variable; + + DFI_Display_Header_Structure( co, name, "PackedMacInfo_s", 0, 0, sizeof( *curVar), curVar ); + ZSD_Display_Type_WORD( co, "rvdID", &curVar->rvdID ); + ZSD_Display_Type_WORD( co, "rvdLayout", &curVar->rvdLayout ); + ZSD_Display_Type_BYTE_ARRAY( co, "finderInfo", NELEMS( curVar->macInfo.finderInfo ), curVar->macInfo.finderInfo ); + ZSD_Display_Type_BYTE_ARRAY( co, "proDOSInfo", NELEMS( curVar->macInfo.proDOSInfo ), curVar->macInfo.proDOSInfo ); + ZSD_Display_Type_BYTE_ARRAY( co, "filler", NELEMS( curVar->macInfo.filler ), curVar->macInfo.filler ); + ZSD_Display_Type_LONG( co, "dirRightsMask", &curVar->macInfo.dirRightsMask ); + DFI_Display_Tail_Structure( co, "PackedMacInfo_s", sizeof(*curVar), curVar ); + return( sizeof( *curVar ) ); + +} + + +int ZSD_Display_Struct_RootVariable_s( + DFI_CallerOptions_s *co, + BYTE *variable, + int variableSize, + char *name ) +{ + int rc = 0; + int used; + int sizeLeft = variableSize; + BYTE *curVar = variable; + WORD rvdID; + + if ( variableSize > 0 ) + { + DFI_Display_Header_Structure( co, name, "VariableData_s", 0, 0, variableSize, curVar ); + } + while ( sizeLeft > 0 ) + { + rvdID = *(WORD *)curVar; + switch ( rvdID ) + { + case RVD_MAC_META_DATA: + used = ZSD_Display_Struct_PackedMacInfo_s( co, curVar, sizeLeft, name ); + break; + case RVD_UNIX_META_DATA: + used = ZSD_Display_Struct_PackedUnixInfo_s( co, curVar, sizeLeft, name ); + break; + case RVD_VIRTUAL_DATA: /* This is used by the _ADMIN volume so is not persistent */ + printf("Error: Found variable data type RVD_VIRTUAL_DATA\n"); + return( __LINE__ ); + case RVD_COMP_META_DATA: + used = ZSD_Display_Struct_PackedCompInfo_s( co, curVar, sizeLeft, name ); + break; + default: + printf("Error: Found variable data type %d\n", rvdID); + return( __LINE__ ); + } + if ( used == 0 ) + { /* If none used then we will loop forever if we don't error out */ + return( __LINE__ ); + } + sizeLeft -= used; + curVar += used; + } + if ( variableSize > 0 ) + { + rc = DFI_Display_Tail_Structure( co, "VariableData_s",variableSize, curVar ); + } + return rc; +} /* End of ZSD_Display_Struct_RootVariable_s() */ + + + +STATUS BeastUnpackBV3( + ZFSPackedRoot_s *packedHeader2, + DFI_CallerOptions_s *co, + void **systemBeastSpecific, /* Output - Pointer to information past File_s */ + char *name ) +{ + int rc; + NINT packedFMapSize; + NINT len; + Fmap_s *packedFMap; + ZASPersistentAuthInfo_s *auth2; + PersistentFile_s *file; + PersistentNamed3_s *named; + + TRACE5; + *systemBeastSpecific = 0; + rc = ZSD_Display_Struct_ZFSPackedRoot_s( co, packedHeader2, name, FALSE ); + packedFMap = (Fmap_s *)(((BYTE *)packedHeader2) + sizeof(*packedHeader2) + packedHeader2->variableSize); + packedFMapSize = packedHeader2->sizeFmap; + TRACE5; + + BN_Notify( zFTYPE_ROOT_BEAST, co, &packedHeader2->header, packedHeader2 ); + if ( packedHeader2->header.type == zFTYPE_ROOT_BEAST ) + { + TRACE5; + return( rc ); + } + TRACE5; + if ( packedHeader2->header.type == zFTYPE_COMPRESSION_INTERMEDIATE ) + { + void *compIntermediate; /* There is no 'intermediate' specific data. */ + + compIntermediate = (PersistentComp_s *)(((BYTE *)packedFMap) + packedFMapSize); + rc = ZSD_Display_Struct_PersistentCompIntermediate_s( co, compIntermediate, name ); + BN_Notify( zFTYPE_COMPRESSION_INTERMEDIATE, co, &packedHeader2->header, compIntermediate ); + return( rc ); + } + if ( packedHeader2->header.type == zFTYPE_COMPRESSION ) + { + PersistentComp_s *comp; + + comp = (PersistentComp_s *)(((BYTE *)packedFMap) + packedFMapSize); + rc = ZSD_Display_Struct_PersistentComp_s( co, comp, name ); + BN_Notify( zFTYPE_COMPRESSION, co, &packedHeader2->header, comp ); + return( rc ); + } + if ( packedHeader2->header.type == zFTYPE_ZAS_ACL_OVERFLOW ) + { + PersistentZasAclOverflowBeast_s *acl; + + acl = (PersistentZasAclOverflowBeast_s *)(((BYTE *)packedFMap) + packedFMapSize); + rc = ZSD_Display_Struct_PersistentZasAclOverflowBeast_s( co, acl, name ); + BN_Notify( zFTYPE_ZAS_ACL_OVERFLOW, co, &packedHeader2->header, acl ); + return( rc ); + } + if ( packedHeader2->header.type == zFTYPE_ZAS_VIS_OVERFLOW ) + { + PersistentZasVisOverflowBeast_s *vis; + + vis = (PersistentZasVisOverflowBeast_s *)(((BYTE *)packedFMap) + packedFMapSize); + rc = ZSD_Display_Struct_PersistentZasVisOverflowBeast_s( co, vis, name ); + BN_Notify( zFTYPE_ZAS_VIS_OVERFLOW, co, &packedHeader2->header, vis ); + return( rc ); + } + + named = (PersistentNamed3_s *)(((BYTE *)packedFMap) + packedFMapSize); +// DFI_Display_Header_Structure( co, name, "PersistentNamed_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, named ); + ZSD_Display_Struct_PersistentNamed3_s( co, named, name ); + TRACE5; + if ( named->numParents > 0 ) + { + PersistentParentEntry_s *namedParent; + PersistentNameEntry_s *namedParentEntry; + DeletedPersistentParentEntry_s *deletedInfo; + int nameIndex; + + namedParent = (PersistentParentEntry_s *)(named+1); +// cnt for ( parentIndex = 0; parentIndex < named->numParents; ++parentIndex ) + { + ZSD_Display_Struct_PersistentParentEntry3_s( co, namedParent, name ); + TRACE5; + if ( namedParent->nameType == zNTYPE_DELETED_FILE ) + { + deletedInfo = (DeletedPersistentParentEntry_s *)(namedParent + 1); + TRACE5; + ZSD_Display_Struct_DeletedPersistentParentEntry_s( co, deletedInfo, name ); + TRACE5; + namedParentEntry = (PersistentNameEntry_s *)(deletedInfo+1); + } + else + { + deletedInfo = NULL; + namedParentEntry = (PersistentNameEntry_s *)(namedParent+1); + } + TRACE5; + for ( nameIndex = 0; nameIndex < namedParent->numNames; nameIndex++) + { + ZSD_Display_Struct_PersistentNameEntry_s( co, namedParentEntry, name ); + namedParentEntry = (PersistentNameEntry_s *)(((BYTE *)namedParentEntry) + REALSIZE_PersistentNameEntry_s + NAMED_GET_NSIZE((PersistentNameEntry_s *)namedParentEntry)); + } + TRACE5; + namedParent = (PersistentParentEntry_s *)namedParentEntry; + } + auth2 = (ZASPersistentAuthInfo_s *)(namedParent); + } + else + { + auth2 = (ZASPersistentAuthInfo_s *)(named+1); + } + TRACE5; +// rc = DFI_Display_Tail_Structure( co, "PersistentNamed_s", DFI_VARIABLE_SIZE_INKNOWN, named ); + BN_Notify( zFTYPE_NAMED_DATA_STREAM, co, &packedHeader2->header, named ); + TRACE5; + if ( packedHeader2->header.type == zFTYPE_NAMED_DATA_STREAM ) + { + TRACE5; + return( zOK ); + } + if ( packedHeader2->header.type == zFTYPE_EXTENDED_ATTRIBUTE ) + { // Added Dec 2003 + PersistentExtAttrBeast_s *extended = (PersistentExtAttrBeast_s *)auth2; + rc = ZSD_Display_Struct_PersistentExtAttrBeast_s( co, extended, name ); + BN_Notify( zFTYPE_EXTENDED_ATTRIBUTE, co, &packedHeader2->header, extended ); + return( rc ); + } + TRACE5; + + if (co->DCO_AuthType == DCO_AUTHTYPE_ZAS) + { + ZSD_Display_Struct_ZASPersistentAuthInfo_s( co, auth2, name ); + TRACE5; + len = offsetof( ZASPersistentAuthInfo_s, ACL ) + + ( sizeof(ACLEntry_s) * auth2->numTrusteesAssigned ) + + ( sizeof(VisEntry_s) * auth2->numVisibilityTrusteesAssigned ); + } + else if (co->DCO_AuthType == DCO_AUTHTYPE_UNIX) + { + ZSD_Display_Struct_UNIXPersistentAuthInfo_s( co, + (UXASPersistentAuthInfo_s *)auth2, name ); + TRACE5; + len = sizeof(UXASPersistentAuthInfo_s); + } + else + { + return zERR_NOT_SUPPORTED; + } + BN_Notify( zFTYPE_AUTH_BEAST, co, &packedHeader2->header, auth2 ); + TRACE5; + if ( packedHeader2->header.type == zFTYPE_AUTH_BEAST ) + { + TRACE5; + return( zOK ); + } + file = (PersistentFile_s *)( ((BYTE *)(auth2))+len ); + ZSD_Display_Struct_PersistentFile_s( co, file, name ); + BN_Notify( zFTYPE_FILE, co, &packedHeader2->header, file ); + + *systemBeastSpecific = file+1; + TRACE5; + return( zOK ); + +} /* End of BeastUnpackBV3() */ + + + +STATUS BeastUnpackBV2( + ZFSPackedRoot_s *packedHeader2, + DFI_CallerOptions_s *co, + void **systemBeastSpecific, /* Output - Pointer to information past File_s */ + char *name ) +{ + int rc; + NINT packedFMapSize; + NINT len; + Fmap_s *packedFMap; + ZASPersistentAuthInfo_s *auth2; + PersistentFile_s *file; + PersistentNamed2_s *named; + + TRACE5; + *systemBeastSpecific = 0; + rc = ZSD_Display_Struct_ZFSPackedRoot_s( co, packedHeader2, name, FALSE ); + packedFMap = (Fmap_s *)(((BYTE *)packedHeader2) + sizeof(*packedHeader2) + packedHeader2->variableSize); + packedFMapSize = packedHeader2->sizeFmap; + TRACE5; + + BN_Notify( zFTYPE_ROOT_BEAST, co, &packedHeader2->header, packedHeader2 ); + if ( packedHeader2->header.type == zFTYPE_ROOT_BEAST ) + { + TRACE5; + return( rc ); + } + TRACE5; + if ( packedHeader2->header.type == zFTYPE_COMPRESSION_INTERMEDIATE ) + { + void *compIntermediate; /* There is no 'intermediate' specific data. */ + + compIntermediate = (PersistentComp_s *)(((BYTE *)packedFMap) + packedFMapSize); + rc = ZSD_Display_Struct_PersistentCompIntermediate_s( co, compIntermediate, name ); + BN_Notify( zFTYPE_COMPRESSION_INTERMEDIATE, co, &packedHeader2->header, compIntermediate ); + return( rc ); + } + if ( packedHeader2->header.type == zFTYPE_COMPRESSION ) + { + PersistentComp_s *comp; + + comp = (PersistentComp_s *)(((BYTE *)packedFMap) + packedFMapSize); + rc = ZSD_Display_Struct_PersistentComp_s( co, comp, name ); + BN_Notify( zFTYPE_COMPRESSION, co, &packedHeader2->header, comp ); + return( rc ); + } + if ( packedHeader2->header.type == zFTYPE_ZAS_ACL_OVERFLOW ) + { + PersistentZasAclOverflowBeast_s *acl; + + acl = (PersistentZasAclOverflowBeast_s *)(((BYTE *)packedFMap) + packedFMapSize); + rc = ZSD_Display_Struct_PersistentZasAclOverflowBeast_s( co, acl, name ); + BN_Notify( zFTYPE_ZAS_ACL_OVERFLOW, co, &packedHeader2->header, acl ); + return( rc ); + } + if ( packedHeader2->header.type == zFTYPE_ZAS_VIS_OVERFLOW ) + { + PersistentZasVisOverflowBeast_s *vis; + + vis = (PersistentZasVisOverflowBeast_s *)(((BYTE *)packedFMap) + packedFMapSize); + rc = ZSD_Display_Struct_PersistentZasVisOverflowBeast_s( co, vis, name ); + BN_Notify( zFTYPE_ZAS_VIS_OVERFLOW, co, &packedHeader2->header, vis ); + return( rc ); + } + + named = (PersistentNamed2_s *)(((BYTE *)packedFMap) + packedFMapSize); +// DFI_Display_Header_Structure( co, name, "PersistentNamed_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, named ); + ZSD_Display_Struct_PersistentNamed2_s( co, named, name ); + TRACE5; + if ( named->numParents > 0 ) + { + PersistentParentEntry_s *namedParent; + PersistentNameEntry_s *namedParentEntry; + DeletedPersistentParentEntry_s *deletedInfo; + int parentIndex; + int nameIndex; + + namedParent = (PersistentParentEntry_s *)(named+1); + for ( parentIndex = 0; parentIndex < named->numParents; ++parentIndex ) + { + ZSD_Display_Struct_PersistentParentEntry2_s( co, namedParent, name ); + TRACE5; + if ( namedParent->nameType == zNTYPE_DELETED_FILE ) + { + deletedInfo = (DeletedPersistentParentEntry_s *)(namedParent + 1); + TRACE5; + ZSD_Display_Struct_DeletedPersistentParentEntry_s( co, deletedInfo, name ); + TRACE5; + namedParentEntry = (PersistentNameEntry_s *)(deletedInfo+1); + } + else + { + deletedInfo = NULL; + namedParentEntry = (PersistentNameEntry_s *)(namedParent+1); + } + TRACE5; + for ( nameIndex = 0; nameIndex < namedParent->numNames; nameIndex++) + { + ZSD_Display_Struct_PersistentNameEntry_s( co, namedParentEntry, name ); + namedParentEntry = (PersistentNameEntry_s *)(((BYTE *)namedParentEntry) + REALSIZE_PersistentNameEntry_s + NAMED_GET_NSIZE((PersistentNameEntry_s *)namedParentEntry)); + } + TRACE5; + namedParent = (PersistentParentEntry_s *)namedParentEntry; + } + auth2 = (ZASPersistentAuthInfo_s *)(namedParent); + } + else + { + auth2 = (ZASPersistentAuthInfo_s *)(named+1); + } + TRACE5; +// rc = DFI_Display_Tail_Structure( co, "PersistentNamed_s", DFI_VARIABLE_SIZE_INKNOWN, named ); + BN_Notify( zFTYPE_NAMED_DATA_STREAM, co, &packedHeader2->header, named ); + TRACE5; + if ( packedHeader2->header.type == zFTYPE_NAMED_DATA_STREAM ) + { + TRACE5; + return( zOK ); + } + if ( packedHeader2->header.type == zFTYPE_EXTENDED_ATTRIBUTE ) + { // Added Dec 2003 + PersistentExtAttrBeast_s *extended = (PersistentExtAttrBeast_s *)auth2; + rc = ZSD_Display_Struct_PersistentExtAttrBeast_s( co, extended, name ); + BN_Notify( zFTYPE_EXTENDED_ATTRIBUTE, co, &packedHeader2->header, extended ); + return( rc ); + } + TRACE5; + + if (co->DCO_AuthType == DCO_AUTHTYPE_ZAS) + { + ZSD_Display_Struct_ZASPersistentAuthInfo_s( co, auth2, name ); + TRACE5; + len = offsetof( ZASPersistentAuthInfo_s, ACL ) + + ( sizeof(ACLEntry_s) * auth2->numTrusteesAssigned ) + + ( sizeof(VisEntry_s) * auth2->numVisibilityTrusteesAssigned ); + } + else if (co->DCO_AuthType == DCO_AUTHTYPE_UNIX) + { + ZSD_Display_Struct_UNIXPersistentAuthInfo_s( co, + (UXASPersistentAuthInfo_s *)auth2, name ); + TRACE5; + len = sizeof(UXASPersistentAuthInfo_s); + } + else + { + return zERR_NOT_SUPPORTED; + } + BN_Notify( zFTYPE_AUTH_BEAST, co, &packedHeader2->header, auth2 ); + TRACE5; + if ( packedHeader2->header.type == zFTYPE_AUTH_BEAST ) + { + TRACE5; + return( zOK ); + } + file = (PersistentFile_s *)( ((BYTE *)(auth2))+len ); + ZSD_Display_Struct_PersistentFile_s( co, file, name ); + BN_Notify( zFTYPE_FILE, co, &packedHeader2->header, file ); + + *systemBeastSpecific = file+1; + TRACE5; + return( zOK ); + +} /* End of BeastUnpackBV2() */ + + +int ZSD_Display_Struct_V1_DeletedPersistentParentEntry_s( + DFI_CallerOptions_s *co, + V1_DeletedPersistentParentEntry_s *deletedInfo, + char *name ) +{ + int rc; + + DFI_Display_Header_Structure( co, name, "V1_DeletedPersistentParentEntry_s", 0, 0, sizeof(V1_DeletedPersistentParentEntry_s), deletedInfo ); + ZSD_Display_Type_Time_t( co, "time", &deletedInfo->time ); + ZSD_Display_Type_LONG( co, "ID", &deletedInfo->ID ); + rc = DFI_Display_Tail_Structure( co, "V1_DeletedPersistentParentEntry_s", sizeof(V1_DeletedPersistentParentEntry_s), deletedInfo ); + return ( rc ); +} /* End of ZSD_Display_Struct_V1_DeletedPersistentParentEntry_s() */ + + +int ZSD_Display_Struct_DeletedPersistentParentEntry_s( + DFI_CallerOptions_s *co, + DeletedPersistentParentEntry_s *deletedInfo, + char *name ) +{ + int rc; + + DFI_Display_Header_Structure( co, name, "DeletedPersistentParentEntry_s", 0, 0, sizeof(DeletedPersistentParentEntry_s), deletedInfo ); + ZSD_Display_Type_Time_t( co, "time", &deletedInfo->time ); + ZSD_Display_Struct_UserID_t( co, "ID", &deletedInfo->ID ); + rc = DFI_Display_Tail_Structure( co, "DeletedPersistentParentEntry_s", sizeof(DeletedPersistentParentEntry_s), deletedInfo ); + return ( rc ); +} /* End of ZSD_Display_Struct_DeletedPersistentParentEntry_s() */ + + +int BeastUnpackBV1( + V1_ZFSPackedRoot_s *packedHeader, + DFI_CallerOptions_s *co, + void **systemBeastSpecific, /* Output - Pointer to information past File_s */ + char *name ) +{ + int rc; + NINT packedFMapSize; + NINT len; + Fmap_s *packedFMap; + PersistentAuthBeast_1Dot0_s *zlssAuth; + V1_ZASPersistentAuthInfo_s *auth1; + V1_PersistentFile_s *file; + PersistentNamed2_s *named; + + TRACE5; + *systemBeastSpecific = 0; + rc = ZSD_Display_Struct_V1_ZFSPackedRoot_s( co, packedHeader, name, FALSE ); + TRACE5; + packedFMap = (Fmap_s *)(((BYTE *)packedHeader) + sizeof(*packedHeader) + packedHeader->variableSize); + packedFMapSize = packedHeader->sizeFmap; + + TRACE5; + BN_Notify( zFTYPE_ROOT_BEAST, co, &packedHeader->header, packedHeader ); + TRACE5; + if ( packedHeader->header.type == zFTYPE_ROOT_BEAST ) + { + TRACE5; + return( rc ); + } + if ( packedHeader->header.type == zFTYPE_ZAS_ACL_OVERFLOW ) + { + PersistentZasAclOverflowBeast_s *acl; + + acl = (PersistentZasAclOverflowBeast_s *)(((BYTE *)packedFMap) + packedFMapSize); + rc = ZSD_Display_Struct_V1_PersistentZasAclOverflowBeast_s( co, acl, name ); + BN_Notify( zFTYPE_ZAS_ACL_OVERFLOW, co, &packedHeader->header, acl ); + return( rc ); + } + if ( packedHeader->header.type == zFTYPE_ZAS_VIS_OVERFLOW ) + { + PersistentZasVisOverflowBeast_s *vis; + + vis = (PersistentZasVisOverflowBeast_s *)(((BYTE *)packedFMap) + packedFMapSize); + rc = ZSD_Display_Struct_V1_PersistentZasVisOverflowBeast_s( co, vis, name ); + BN_Notify( zFTYPE_ZAS_VIS_OVERFLOW, co, &packedHeader->header, vis ); + return( rc ); + } + named = (PersistentNamed2_s *)(((BYTE *)packedFMap) + packedFMapSize); +// DFI_Display_Header_Structure( co, name, "PersistentNamed_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, named ); + ZSD_Display_Struct_PersistentNamed2_s( co, named, name ); + TRACE5; + if ( named->numParents > 0 ) + { + PersistentParentEntry_s *namedParent; + PersistentNameEntry_s *namedParentEntry; + V1_DeletedPersistentParentEntry_s *deletedInfo; + int parentIndex; + int nameIndex; + + namedParent = (PersistentParentEntry_s *)(named+1); + for ( parentIndex = 0; parentIndex < named->numParents; ++parentIndex ) + { + TRACE5; + ZSD_Display_Struct_PersistentParentEntry2_s( co, namedParent, name ); + TRACE5; + if ( namedParent->nameType == zNTYPE_DELETED_FILE ) + { + deletedInfo = (V1_DeletedPersistentParentEntry_s *)(namedParent + 1); + TRACE5; + ZSD_Display_Struct_V1_DeletedPersistentParentEntry_s( co, deletedInfo, name ); + TRACE5; + namedParentEntry = (PersistentNameEntry_s *)(deletedInfo+1); + } + else + { + deletedInfo = NULL; + namedParentEntry = (PersistentNameEntry_s *)(namedParent+1); + } + for ( nameIndex = 0; nameIndex < namedParent->numNames; nameIndex++) + { + TRACE5; + ZSD_Display_Struct_PersistentNameEntry_s( co, namedParentEntry, name ); + TRACE5; + namedParentEntry = (PersistentNameEntry_s *)(((BYTE *)namedParentEntry) + REALSIZE_PersistentNameEntry_s + NAMED_GET_NSIZE((PersistentNameEntry_s *)namedParentEntry)); + } + namedParent = (PersistentParentEntry_s *)namedParentEntry; + } + zlssAuth = (PersistentAuthBeast_1Dot0_s *)(namedParent); + } + else + { + zlssAuth = (PersistentAuthBeast_1Dot0_s *)(named+1); + } +// rc = DFI_Display_Tail_Structure( co, "PersistentNamed_s", DFI_VARIABLE_SIZE_INKNOWN, named ); + TRACE5; + BN_Notify( zFTYPE_NAMED_DATA_STREAM, co, &packedHeader->header, named ); + TRACE5; + if ( packedHeader->header.type == zFTYPE_NAMED_DATA_STREAM ) + { + TRACE5; + return( rc ); + } + if ( packedHeader->header.type == zFTYPE_EXTENDED_ATTRIBUTE ) + { // Added Dec 2003 + PersistentExtAttrBeast_s *extended = (PersistentExtAttrBeast_s *)(zlssAuth); + rc = ZSD_Display_Struct_PersistentExtAttrBeast_s( co, extended, name ); + BN_Notify( zFTYPE_EXTENDED_ATTRIBUTE, co, &packedHeader->header, extended ); + return( rc ); + } +// DFI_Display_Header_Structure( co, name, "AuthBeast_s", 0, 0, DFI_VARIABLE_SIZE_INKNOWN, zlssAuth ); +// if (zfsVol->ZFSVOLvol.p.authModelID == zFTYPE_ZAS_AUTH_MODEL) + TRACE5; + ZSD_Display_Struct_PersistentAuthBeast_1Dot0_s( co, zlssAuth, name ); + auth1 = (V1_ZASPersistentAuthInfo_s *)(zlssAuth+1); + TRACE5; + ZSD_Display_Struct_V1_ZASPersistentAuthInfo_s( co, auth1, name ); + len = sizeof(*auth1) + + ( sizeof(V1_ACLEntry_s) * auth1->numTrusteesAssigned ) + + ( sizeof(V1_VisEntry_s) * auth1->numVisibilityTrusteesAssigned ); + + TRACE5; + BN_Notify( zFTYPE_AUTH_BEAST, co, &packedHeader->header, zlssAuth ); + TRACE5; + if ( packedHeader->header.type == zFTYPE_AUTH_BEAST ) + { + TRACE5; + return( rc ); + } + file = (V1_PersistentFile_s *)( ((BYTE *)(auth1))+len ); + TRACE5; + ZSD_Display_Struct_V1_PersistentFile_s( co, file, name ); + TRACE5; + BN_Notify( zFTYPE_FILE, co, &packedHeader->header, file ); + TRACE5; + *systemBeastSpecific = file+1; + return( 0 ); + +} /* End of BeastUnpackBV1() */ + + +int BeastUnpack( + ZFSPackedRoot_s *packedHeader, + DFI_CallerOptions_s *co, + void **systemBeastSpecific, /* Output - Pointer to information past File_s */ + char *name ) + +{ + int rc; + + /*** + *** DANGER DANGER DANGER DANGER DANGER DANGER DANGER DANGER + *** + *** Only a few fields in ZFSPackedRoot_s match in version + *** 1 and 2. You must only use the beastLayout field + *** until the beast version in known. All fields in the + *** ZnodeHeader_s are also valid for both versions. + *** + *** DANGER DANGER DANGER DANGER DANGER DANGER DANGER DANGER + ***/ + TRACE5; + switch ( packedHeader->beastLayout ) + { + case 3: + TRACE5; + rc = BeastUnpackBV3( packedHeader, co, systemBeastSpecific, name ); + TRACE5; + break; + case 2: + TRACE5; + rc = BeastUnpackBV2( packedHeader, co, systemBeastSpecific, name ); + TRACE5; + break; + case 1: + TRACE5; + rc = BeastUnpackBV1( (V1_ZFSPackedRoot_s *)packedHeader, co, systemBeastSpecific, name ); + TRACE5; + break; + default: + TRACE5; + printf("\nBeast Version is not 1 or 2 or 3.\n\n"); + rc = zERR_NOT_SUPPORTED; + break; + } + TRACE5; + return( rc ); + +} /* End of BeastUnpack() */ + + + +BN_Function_f BN_NotifyTable[ 128 ]; + +void BN_NotifyRegister( + LONG type, + BN_Function_f notifyRoutine ) + +{ + if ( type >= NELEMS( BN_NotifyTable ) ) + { + printf("BN_NotifyRegister supports types up to %d (passed in type is %d)\n", NELEMS( BN_NotifyTable ), type ); + return; + } + BN_NotifyTable[type] = notifyRoutine; + return; + +} + + +void BN_NotifyUnRegister( + LONG type, + BN_Function_f notifyRoutine ) + +{ + if ( type >= NELEMS( BN_NotifyTable ) ) + { + printf("BN_NotifyUnRegister supports types up to %d (passed in type is %d)\n", NELEMS( BN_NotifyTable ), type ); + return; + } + BN_NotifyTable[type] = NULL; + return; + +} + + +void BN_Notify( + LONG type, + DFI_CallerOptions_s *co, + ZnodeHeader_s *znode, + void *specificBeast ) +{ + + if ( type >= NELEMS( BN_NotifyTable ) ) + { + return; + } + if ( BN_NotifyTable[type] == NULL ) + { + return; + } + BN_NotifyTable[type](co, znode, specificBeast); + +} + + +/* + * Returns the amount of data actaully displayed. We return + * this verses using dfi->DFI_SizeOf because some structures + * are variable size. The routines that display variable size + * items can then return the proper amount. + */ +SIZEOF SDM_ZlssBlock_s( + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ) +{ + BYTE *data = (BYTE *)(buffer + offset); + STATUS status; + + DFI_Display_Header_Structure( co, dfi->DFI_Name, dfi->DFI_Name2, index, dfi->DFI_ArrayElements, dfi->DFI_SizeOf, buffer+offset ); + status = SBI_DisplayBlockZlss( co, data ); + DFI_Display_Tail_Structure( co, dfi->DFI_Name2, sizeof( *data ), data ); + return( dfi->DFI_SizeOf ); + +} diff --git a/src/nwnss/zlss/sdZLSS.h b/src/nwnss/zlss/sdZLSS.h index 4f978af..d3d349e 100644 --- a/src/nwnss/zlss/sdZLSS.h +++ b/src/nwnss/zlss/sdZLSS.h @@ -105,15 +105,15 @@ struct PersistentAuthBeast_1Dot0_s; extern SDM_Table_s SDM_TableZLSS[]; typedef void (*BN_Function_f)( - DFI_CallerOptions_s *co, - ZnodeHeader_s *znode, - void *specificBeast ); + DFI_CallerOptions_s *co, + ZnodeHeader_s *znode, + void *specificBeast ); /* This is for the inline structure in RecoveryStats_s */ typedef struct SD_Fake_s { - NINT redo; - NINT undo; + NINT redo; + NINT undo; } SD_Fake_s; @@ -140,517 +140,517 @@ extern DFI_DataFormatInformation_s DFI_LoggedPersistentZlssPool_s[]; SIZEOF SDM_LoggedPersistentZfsVolume_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_LoggedPersistentZlssPool_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_PersistentZfsVolume_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_PersistentZlssPool_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_PoolReadStatistics_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_PoolWriteStatistics_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_RecoveryStats_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_ZfsPool_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_ZfsVolume_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_ZlogBeast_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_ZlogBeastPersistent_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_ZlogHighWatermarkSlot_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_ZlogHistogram_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_ZlogHistory_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_ZlogHistogramPersistent_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_ZlssBlock_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_ZlssPool_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); SIZEOF SDM_ZfsXasRecovery_s( - DFI_CallerOptions_s *co, - DFI_DataFormatInformation_s *dfi, - BYTE *buffer, - NINT offset, - NINT index ); + DFI_CallerOptions_s *co, + DFI_DataFormatInformation_s *dfi, + BYTE *buffer, + NINT offset, + NINT index ); int ZSD_Display_Type_QBlknum_t( - DFI_CallerOptions_s *co, - char *tag, - SQUAD *block ); + DFI_CallerOptions_s *co, + char *tag, + SQUAD *block ); int ZSD_Display_Struct_FmapExt_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, /* Generally the name of the branch element */ - unsigned int arrayElements, /* Number of array elements */ - FmapExt_s *branch ); /* Array of branches */ + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + FmapExt_s *branch ); /* Array of branches */ int ZSD_Display_Struct_xBranch_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, /* Generally the name of the branch element */ - unsigned int arrayElements, /* Number of array elements */ - xBranch_s *branch ); /* Array of branches */ + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + xBranch_s *branch ); /* Array of branches */ int ZSD_Display_Struct_BTBranch_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, - int arrayElements, - BTBranch_s *branch ); + DFI_CallerOptions_s *co, + char *tag, + int arrayElements, + BTBranch_s *branch ); int ZSD_Display_Struct_Extent_s( - DFI_CallerOptions_s *co, - char *tag, - unsigned int index, - unsigned int arrayElements, - Extent_s *extent ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + Extent_s *extent ); int ZSD_Display_Struct_Extent_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, - unsigned int numberOfElements, - Extent_s *extent ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int numberOfElements, + Extent_s *extent ); int ZSD_Display_Type_char_STR( - DFI_CallerOptions_s *co, - char *tag, - unsigned int arrayElements, /* Number of array elements */ - char *name ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, /* Number of array elements */ + char *name ); int ZSD_Display_Struct_ZASPersistentAuthInfo_s( - DFI_CallerOptions_s *co, - ZASPersistentAuthInfo_s *zasAuth, - char *name ); + DFI_CallerOptions_s *co, + ZASPersistentAuthInfo_s *zasAuth, + char *name ); int ZSD_Display_Struct_PersistentAuthBeast_1Dot0_s( - DFI_CallerOptions_s *co, - struct PersistentAuthBeast_1Dot0_s *auth, - char *name ); + DFI_CallerOptions_s *co, + struct PersistentAuthBeast_1Dot0_s *auth, + char *name ); -int ZSD_Display_Struct_V1_PersistentFile_s( - DFI_CallerOptions_s *co, - V1_PersistentFile_s *file, - char *name ); +int ZSD_Display_Struct_V1_PersistentFile_s( + DFI_CallerOptions_s *co, + V1_PersistentFile_s *file, + char *name ); -int ZSD_Display_Struct_PersistentFile_s( - DFI_CallerOptions_s *co, - PersistentFile_s *file, - char *name ); +int ZSD_Display_Struct_PersistentFile_s( + DFI_CallerOptions_s *co, + PersistentFile_s *file, + char *name ); -int ZSD_Display_Struct_PersistentNameEntry_s( - DFI_CallerOptions_s *co, - PersistentNameEntry_s *namedParentEntry, - char *name ); +int ZSD_Display_Struct_PersistentNameEntry_s( + DFI_CallerOptions_s *co, + PersistentNameEntry_s *namedParentEntry, + char *name ); -int ZSD_Display_Struct_PersistentNamed_s( - DFI_CallerOptions_s *co, - PersistentNamed3_s *named, - char *name ); +int ZSD_Display_Struct_PersistentNamed_s( + DFI_CallerOptions_s *co, + PersistentNamed3_s *named, + char *name ); -int ZSD_Display_Struct_PersistentParentEntry_s( - struct DFI_CallerOptions_s *co, - PersistentParentEntry_s *namedParent, - char *name ); +int ZSD_Display_Struct_PersistentParentEntry_s( + struct DFI_CallerOptions_s *co, + PersistentParentEntry_s *namedParent, + char *name ); int ZSD_Display_Struct_Fmap_s( - DFI_CallerOptions_s *co, - char *tag, - unsigned int index, - unsigned int arrayElements, - Fmap_s *data, - unsigned int size ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + Fmap_s *data, + unsigned int size ); int ZSD_Display_Struct_ZFSPackedRoot_s( - struct DFI_CallerOptions_s *co, - ZFSPackedRoot_s *packedHeader2, - char *name, - BOOL doZnodeHeader ); + struct DFI_CallerOptions_s *co, + ZFSPackedRoot_s *packedHeader2, + char *name, + BOOL doZnodeHeader ); int ZSD_Display_Struct_V1_ZFSPackedRoot_s( - struct DFI_CallerOptions_s *co, - V1_ZFSPackedRoot_s *packedHeader1, - char *name, - BOOL doZnodeHeader ); + struct DFI_CallerOptions_s *co, + V1_ZFSPackedRoot_s *packedHeader1, + char *name, + BOOL doZnodeHeader ); int ZSD_Display_Struct_ZnodeHeader_s( - struct DFI_CallerOptions_s *co, - ZnodeHeader_s *znodeHeader, - char *name ); + struct DFI_CallerOptions_s *co, + ZnodeHeader_s *znodeHeader, + char *name ); -int ZSD_Display_Struct_PersistentZlssVolumeLocator_s( - struct DFI_CallerOptions_s *co, - PersistentZlssVolumeLocator_s *pzvl, - char *name ); +int ZSD_Display_Struct_PersistentZlssVolumeLocator_s( + struct DFI_CallerOptions_s *co, + PersistentZlssVolumeLocator_s *pzvl, + char *name ); -int ZSD_Display_Struct_PersistentZfsPurgeLog_s( - DFI_CallerOptions_s *co, - PersistentZfsPurgeLog_s *purgeLog, - char *name ); +int ZSD_Display_Struct_PersistentZfsPurgeLog_s( + DFI_CallerOptions_s *co, + PersistentZfsPurgeLog_s *purgeLog, + char *name ); -int ZSD_Display_Struct_PersistentZfsBtree_s( - DFI_CallerOptions_s *co, - PersistentZfsBtree_s *btree, - char *name ); +int ZSD_Display_Struct_PersistentZfsBtree_s( + DFI_CallerOptions_s *co, + PersistentZfsBtree_s *btree, + char *name ); -int ZSD_Display_Struct_ZlogBeastPersistent_s( - DFI_CallerOptions_s *co, - ZlogBeastPersistent_s *zlog, - char *name ); +int ZSD_Display_Struct_ZlogBeastPersistent_s( + DFI_CallerOptions_s *co, + ZlogBeastPersistent_s *zlog, + char *name ); int ZSD_Display_Struct_BTBranch_s( - DFI_CallerOptions_s *co, - char *tag, - unsigned int index, - unsigned int arrayElements, /* If 0 then we assume NOT an array */ - BTBranch_s *data ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, /* If 0 then we assume NOT an array */ + BTBranch_s *data ); int ZSD_Display_Type_unicode_t_STR( - DFI_CallerOptions_s *co, - char *tag, - unsigned int numberOfElements, // Must be a NULL before end of ARRAY - unicode_t *name ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int numberOfElements, // Must be a NULL before end of ARRAY + unicode_t *name ); int ZSD_Display_Type_unicode_t_ARRAY( - DFI_CallerOptions_s *co, - char *tag, - unsigned int numberOfElements, - unicode_t *name ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int numberOfElements, + unicode_t *name ); int ZSD_Display_Struct_Znode_s( - Znode_s *znode, - DFI_CallerOptions_s *co, - char *name ); + Znode_s *znode, + DFI_CallerOptions_s *co, + char *name ); STATUS BeastUnpackBV2( - ZFSPackedRoot_s *packedHeader2, - DFI_CallerOptions_s *co, - void **systemBeastSpecific, - char *name ); + ZFSPackedRoot_s *packedHeader2, + DFI_CallerOptions_s *co, + void **systemBeastSpecific, + char *name ); int BeastUnpackBV1( - V1_ZFSPackedRoot_s *packedHeader, - DFI_CallerOptions_s *co, - void **systemBeastSpecific, - char *name ); + V1_ZFSPackedRoot_s *packedHeader, + DFI_CallerOptions_s *co, + void **systemBeastSpecific, + char *name ); int BeastUnpack( - ZFSPackedRoot_s *packedHeader, - DFI_CallerOptions_s *co, - void **systemBeastSpecific, - char *name ); + ZFSPackedRoot_s *packedHeader, + DFI_CallerOptions_s *co, + void **systemBeastSpecific, + char *name ); + +void BN_NotifyRegister( + LONG type, + BN_Function_f notifyRoutine ); -void BN_NotifyRegister( - LONG type, - BN_Function_f notifyRoutine ); - -void BN_NotifyUnRegister( - LONG type, - BN_Function_f notifyRoutine ); +void BN_NotifyUnRegister( + LONG type, + BN_Function_f notifyRoutine ); void BN_Notify( - LONG type, - DFI_CallerOptions_s *co, - ZnodeHeader_s *znode, - void *specificBeast ); + LONG type, + DFI_CallerOptions_s *co, + ZnodeHeader_s *znode, + void *specificBeast ); int ZSD_Display_Struct_V1_ZASPersistentAuthInfo_s( - DFI_CallerOptions_s *co, - V1_ZASPersistentAuthInfo_s *zasAuth, - char *name ); + DFI_CallerOptions_s *co, + V1_ZASPersistentAuthInfo_s *zasAuth, + char *name ); int ZSD_Display_Struct_V1_ACLEntry_s_Element( - DFI_CallerOptions_s *co, - char *tag, - unsigned int index, - V1_ACLEntry_s *entry ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + V1_ACLEntry_s *entry ); int ZSD_Display_Struct_V1_ACLEntry_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, - unsigned int arrayElements, - V1_ACLEntry_s *entry ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, + V1_ACLEntry_s *entry ); int ZSD_Display_Struct_V1_VisEntry_s_Element( - DFI_CallerOptions_s *co, - char *tag, - unsigned int index, - V1_VisEntry_s *entry ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + V1_VisEntry_s *entry ); int ZSD_Display_Struct_V1_VisEntry_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, - unsigned int arrayElements, - V1_VisEntry_s *entry ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, + V1_VisEntry_s *entry ); int ZSD_Display_Struct_RootVariable_s( - struct DFI_CallerOptions_s *co, - BYTE *variable, - int variableSize, - char *name ); + struct DFI_CallerOptions_s *co, + BYTE *variable, + int variableSize, + char *name ); int ZSD_Display_Struct_PackedMacInfo_s( - struct DFI_CallerOptions_s *co, - BYTE *variable, - int variableSize, - char *name ); + struct DFI_CallerOptions_s *co, + BYTE *variable, + int variableSize, + char *name ); int ZSD_Display_Type_BYTE_ARRAY( - struct DFI_CallerOptions_s *co, - char *tag, /* Generally the name of the branch element */ - unsigned int arrayElements, /* Number of array elements */ - BYTE *data ); + struct DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + BYTE *data ); int ZSD_Display_Type_LONG_ARRAY( - struct DFI_CallerOptions_s *co, - char *tag, /* Generally the name of the branch element */ - unsigned int arrayElements, /* Number of array elements */ - LONG *data ); + struct DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + LONG *data ); int ZSD_Display_Struct_V1_ACLEntry_s( - DFI_CallerOptions_s *co, - char *tag, - unsigned int index, - unsigned int arrayElements, /* Number of array elements */ - V1_ACLEntry_s *entry ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, /* Number of array elements */ + V1_ACLEntry_s *entry ); int ZSD_Display_Struct_V1_ACLEntry_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, - unsigned int arrayElements, /* Number of array elements */ - V1_ACLEntry_s *entry ); /* Array of .. */ + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, /* Number of array elements */ + V1_ACLEntry_s *entry ); /* Array of .. */ int ZSD_Display_Struct_V1_VisEntry_s( - DFI_CallerOptions_s *co, - char *tag, - unsigned int index, - unsigned int arrayElements, /* Number of array elements */ - V1_VisEntry_s *entry ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, /* Number of array elements */ + V1_VisEntry_s *entry ); int ZSD_Display_Struct_V1_VisEntry_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, /* Generally the name of the branch element */ - unsigned int arrayElements, /* Number of array elements */ - V1_VisEntry_s *data ); + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + V1_VisEntry_s *data ); int ZSD_Display_Struct_ACLEntry_s( - DFI_CallerOptions_s *co, - char *tag, - unsigned int index, - unsigned int arrayElements, /* Number of array elements */ - ACLEntry_s *entry ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, /* Number of array elements */ + ACLEntry_s *entry ); int ZSD_Display_Struct_ACLEntry_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, - unsigned int arrayElements, /* Number of array elements */ - ACLEntry_s *data ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int arrayElements, /* Number of array elements */ + ACLEntry_s *data ); int ZSD_Display_Struct_VisEntry_s( - DFI_CallerOptions_s *co, - char *tag, - unsigned int index, - unsigned int arrayElements, /* Number of array elements */ - VisEntry_s *entry ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, /* Number of array elements */ + VisEntry_s *entry ); int ZSD_Display_Struct_VisEntry_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, /* Generally the name of the branch element */ - unsigned int arrayElements, /* Number of array elements */ - VisEntry_s *data ); /* Array of .. */ + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + VisEntry_s *data ); /* Array of .. */ int ZSD_Display_Struct_MYBTBranchEntry_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, /* Generally the name of the branch element */ - unsigned int arrayElements, /* Number of array elements */ - MYBTBranchEntry_s *data ); /* Array of .. */ + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + MYBTBranchEntry_s *data ); /* Array of .. */ //#ifndef SAI_NT int ZSD_Display_Type_NodeLen_t_ARRAY( - DFI_CallerOptions_s *co, - char *tag, - int arrayElements, - NodeLen_t *branch ); + DFI_CallerOptions_s *co, + char *tag, + int arrayElements, + NodeLen_t *branch ); int ZSD_Display_Type_NodeLen_t( - DFI_CallerOptions_s *co, - char *tag, - int index, - int arrayElements, - NodeLen_t *nodeOffset ); + DFI_CallerOptions_s *co, + char *tag, + int index, + int arrayElements, + NodeLen_t *nodeOffset ); int ZSD_Display_Struct_PurgeQNewKey_s( - DFI_CallerOptions_s *co, - char *tag, - unsigned int index, - unsigned int arrayElements, - PurgeQNewKey_s *data ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + PurgeQNewKey_s *data ); int ZSD_Display_Struct_PurgeQNewValue_s( - DFI_CallerOptions_s *co, - char *tag, - unsigned int index, - unsigned int arrayElements, - PurgeQNewValue_s *data ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + PurgeQNewValue_s *data ); int ZSD_Display_Struct_PurgeNewInfo_s( - DFI_CallerOptions_s *co, - char *tag, - unsigned int index, - unsigned int arrayElements, - PurgeNewInfo_s *data ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + PurgeNewInfo_s *data ); int ZSD_Display_Struct_PurgeNewInfo_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, /* Generally the name of the branch element */ - unsigned int arrayElements, /* Number of array elements */ - PurgeNewInfo_s *data ); /* Array of .. */ + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + PurgeNewInfo_s *data ); /* Array of .. */ //#endif // #ifndef SAI_NT int ZSD_Display_Struct_EFLBranch_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, /* Generally the name of the element */ - unsigned int arrayElements, /* Number of array elements */ - EFLBranchEntry_s *data ); /* Array of branches */ + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the element */ + unsigned int arrayElements, /* Number of array elements */ + EFLBranchEntry_s *data ); /* Array of branches */ int ZSD_Display_Struct_EFLLeafEntry_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, /* Generally the name of the element */ - unsigned int arrayElements, /* Number of array elements */ - EFLLeafEntry_s *data ); /* Array of branches */ + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the element */ + unsigned int arrayElements, /* Number of array elements */ + EFLLeafEntry_s *data ); /* Array of branches */ int ZSD_Display_Struct_ELogHeader_s_ARRAY( - DFI_CallerOptions_s *co, - char *tag, /* Generally the name of the element */ - unsigned int arrayElements, /* Number of array elements */ - ELogHeader_s *data ); /* Array of headers */ + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the element */ + unsigned int arrayElements, /* Number of array elements */ + ELogHeader_s *data ); /* Array of headers */ int DFI_Display_Struct_ELogEntry_s( - DFI_CallerOptions_s *co, - char *tag, - unsigned int index, - unsigned int arrayElements, - ELogEntry_s *data ); + DFI_CallerOptions_s *co, + char *tag, + unsigned int index, + unsigned int arrayElements, + ELogEntry_s *data ); int ZSD_Display_Struct_GUID_t_ARRAY( - DFI_CallerOptions_s *co, - char *tag, /* Generally the name of the branch element */ - unsigned int arrayElements, /* Number of array elements */ - GUID_t *data ); + DFI_CallerOptions_s *co, + char *tag, /* Generally the name of the branch element */ + unsigned int arrayElements, /* Number of array elements */ + GUID_t *data ); -int ZSD_Display_Struct_PersistentZfsBeastTree_s( - DFI_CallerOptions_s *co, - PersistentZfsBeastTree_s *data, - char *name ); +int ZSD_Display_Struct_PersistentZfsBeastTree_s( + DFI_CallerOptions_s *co, + PersistentZfsBeastTree_s *data, + char *name ); int ZSD_Display_Type_EFLEpochMask_t( - DFI_CallerOptions_s *co, - char *tag, - EFLEpochMask_t *epoch ); + DFI_CallerOptions_s *co, + char *tag, + EFLEpochMask_t *epoch ); int ZSD_Display_Type_ELogLink_s( - DFI_CallerOptions_s *co, - char *tag, - ELogLink_s *data ); + DFI_CallerOptions_s *co, + char *tag, + ELogLink_s *data ); -int ZSD_Display_Struct_DeletedPersistentParentEntry_s( - DFI_CallerOptions_s *co, - struct DeletedPersistentParentEntry_s *deletedInfo, - char *name ); +int ZSD_Display_Struct_DeletedPersistentParentEntry_s( + DFI_CallerOptions_s *co, + struct DeletedPersistentParentEntry_s *deletedInfo, + char *name ); #endif // #ifndef _SDPERSISTENT_H_ diff --git a/src/nwnss/zlss/underflow.c b/src/nwnss/zlss/underflow.c index 7cf11e2..b48d4a9 100644 --- a/src/nwnss/zlss/underflow.c +++ b/src/nwnss/zlss/underflow.c @@ -51,9 +51,9 @@ */ STATUS node_underflow( - NameTreeParms_s *parms, - Buffer_s **buf, - Buffer_s **pbuf, + NameTreeParms_s *parms, + Buffer_s **buf, + Buffer_s **pbuf, node_ind_t *pind, SNINT *key_in_par) { @@ -66,10 +66,10 @@ node_underflow( node_ind_t parind = *pind; SNINT node_freebytes = node->nfreebytes; SNINT uflow_right; - Node_s *parnode; + Node_s *parnode; BOOL parnode_was_root; - if (parbuf) + if (parbuf) { parnode = (Node_s *)parbuf->pBuf.data; parnode_was_root = NT_IS_ROOT(parnode); @@ -85,7 +85,7 @@ node_underflow( /* * Handle branch/leaf node underflow. */ - if ((node_freebytes > NODE_UNDERFLOW) && parbuf) + if ((node_freebytes > NODE_UNDERFLOW) && parbuf) { /* * First try merging/rearranging with the right sibling node (if @@ -99,7 +99,7 @@ node_underflow( goto error_ret; } - for (;;) + for (;;) { SNINT merge, threshold; Buffer_s *sib_buf, *srcbuf, *dstbuf; @@ -133,13 +133,13 @@ node_underflow( sib_ind = uflow_right ? NODE_NEXT(parnode, parind) : NODE_PREV(parnode, parind); if ((rc = get_sibnode(parms, parbuf, *buf, - uflow_right, sib_ind, &sib_buf)) != zOK) + uflow_right, sib_ind, &sib_buf)) != zOK) { goto try_other_side; } sibnode = (Node_s *)(sib_buf->pBuf.data); - midentry = uflow_right + midentry = uflow_right ? BRANCH_ENTRY(parnode, NODE_NEXT(parnode, parind)) : BRANCH_ENTRY(parnode, parind); midentrysize = SPACE_NEEDED_BRANCH(midentry); @@ -161,7 +161,7 @@ node_underflow( destnode = (Node_s *)dstbuf->pBuf.data; /* See if we can balance the free space equally among the two nodes */ - if (! merge) + if (! merge) { SNINT srci = move_right ? NODE_LAST(srcnode) : NODE_FIRST(srcnode); SNINT data_moved = 0, src_incr = move_right ? -1 : 1; @@ -172,7 +172,7 @@ node_underflow( if ((dest_freebytes <= threshold) || (srcnode->nfreebytes >= NODE_UNDERFLOW)) goto abort_this_side; - if (! isleaf) + if (! isleaf) { size = 0; dest_freebytes -= midentrysize; @@ -182,9 +182,9 @@ node_underflow( ++ lhdr[0].nOps; /* Insert midentry into destnode */ } newdiff = diff = dest_freebytes - threshold; - while (nrecs > 0) + while (nrecs > 0) { - size = isleaf + size = isleaf ? SPACE_NEEDED_LEAF(LEAF_ENTRY(srcnode, srci)) : SPACE_NEEDED_BRANCH(BRANCH_ENTRY(srcnode, srci)); @@ -205,7 +205,7 @@ node_underflow( nrecs = srcnode->numRecs - nrecs; /* nrecs now holds # of entries that can be actually moved */ - if (! isleaf) + if (! isleaf) { Branch_s *e = BRANCH_ENTRY(srcnode, srci); par_repl_key = &e->k; @@ -214,7 +214,7 @@ node_underflow( lhdr[0].nOps += 2; /* 1. delete newpar_entry from srcnode * 2. set leftmost blk# of right node */ } - else + else { Leaf_s *e; if (move_right) { /* rearranging with left? */ @@ -226,7 +226,7 @@ node_underflow( par_repl_key = &e->k; size = SPACE_NEEDED_BRANCH_FROM_KEY(par_repl_key); dlog_size[0] += size - OFFSETSZ; /* newpar_entry */ - if (move_right) + if (move_right) { dlog_size[1] -= LEAF_ENTRY_SIZE(e); dlog_size[0] += LEAF_ENTRY_SIZE(e); @@ -241,7 +241,7 @@ node_underflow( SNINT srci; for (srci = 0; srci < nrecs; ++ srci) dlog_size[1] += ENTRYBYTES(NODE_ENTRY(srcnode, srci)); - if (! isleaf) + if (! isleaf) lhdr[0].nOps += 2; /* 1. Insert midentry into destnode * 2. Reset leftmost blk# of srcnode */ else ++ lhdr[1].nOps; /* Delete leaf from leaflist */ @@ -251,52 +251,52 @@ node_underflow( par_ovflow = -1; dlog_nblks[0] = 3; /* par, src, and dest nodes */ - if (parbuf) + if (parbuf) { /* oldpar_entry */ dlog_size[0] += BRANCH_ENTRY_SIZE(midentry); - ++ lhdr[0].nOps; /* delete/replace oldpar_entry in + ++ lhdr[0].nOps; /* delete/replace oldpar_entry in * par/par_ovflow */ if (merge && (parnode->numRecs <= 1) && parnode_was_root) { lhdr[0].nOps += 2; /* 1. set new root node * 2. Reset leftmost blk# of old parnode */ } - if ((par_freebytes + parnode->nfreebytes) < 0) + if ((par_freebytes + parnode->nfreebytes) < 0) { par_ovflow = nblks++; ++ lhdr[0].nOps; /* set parent's ovflow_blk */ } } - if (nrecs > 0) + if (nrecs > 0) ++ lhdr[1].nOps; /* Move nrecs from srcnode to destnode */ xaction = BEGIN_XACTION(parms); /* Allocate the overflow directory blocks (if needed) */ zASSERT(nblks <= 1); - if (nblks && ((rc = alloc_ntree_blks(parms, xaction, nblks, - &par_ovflow_buf)) != zOK)) + if (nblks && ((rc = alloc_ntree_blks(parms, xaction, nblks, + &par_ovflow_buf)) != zOK)) { END_XACTION(xaction); if (nblks) par_ovflow_buf = 0; goto abort_this_side; } - if (merge) + if (merge) { rc = zOK; zASSERT(parbuf != 0); if ((parnode->numRecs <= 1) && parnode_was_root) - { + { rc = ntree_ch_root_node(parms, xaction, parbuf, dstbuf); - if (rc != zOK) + if (rc != zOK) { /* * FixFixFix6: should not deallocate below when we have the * abort_xaction functionality. */ - if (nblks) { + if (nblks) { zASSERT(0); /* error setting root node */ DEALLOC_NTREE_BLKS(parms, nblks, &par_ovflow_buf); if (nblks) @@ -314,13 +314,13 @@ node_underflow( if (DLOG_SIZE(dlog_nblks[0], DLOG_DATA_SIZE(&lhdr[0], dlog_size[0]) + DLOG_DATA_SIZE(&lhdr[1], dlog_size[1])) - <= ZLOG_MAXIMUM_RECORD_SIZE) + <= ZLOG_MAXIMUM_RECORD_SIZE) { dlog_size[0] += dlog_size[1]; lhdr[0].nOps += lhdr[1].nOps; lhdr[1].nOps = 0; } - else + else { ++ dlog_nrecs; if (isleaf && uflow_right) @@ -331,7 +331,7 @@ node_underflow( /* * Now allocate the log record of appropriate length */ - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks[0], DLOG_DATA_SIZE(&lhdr[0], dlog_size[0]))); DLOG_INIT_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -346,12 +346,12 @@ node_underflow( blki = 0; dstblki = blki++; DLOG_SET_BLKINFO(dlog_blkinfo, dstblki, dstbuf, destnode->vers,xaction); - if (parbuf) + if (parbuf) { parblki = blki++; DLOG_SET_BLKINFO(dlog_blkinfo, parblki, *pbuf, parnode->vers, xaction); - if ((dlog_nrecs <= 1) || ! (isleaf && ! uflow_right)) + if ((dlog_nrecs <= 1) || ! (isleaf && ! uflow_right)) { srcblki = blki++; DLOG_SET_BLKINFO(dlog_blkinfo, srcblki, srcbuf, @@ -365,7 +365,7 @@ node_underflow( * deletion/underflow. Now we actually perform the deletion, * merging/rearranging as necessary. */ - + { dlog_offset_t oldpar_log, newpar_log; if (! isleaf) /* Branch underflow case */ @@ -374,17 +374,17 @@ node_underflow( /* Frees up destnode/srcnode->childblk for reassignment */ Blknum_t blk; node_ind_t destind; - if (move_right) + if (move_right) { destind = NODE_LEFTMOST(destnode); blk = destnode->child_blk; } - else + else { destind = NODE_LAST(destnode); blk = srcnode->child_blk; } - NODE_INSERT(destnode, destind, &midentry->k, (BYTE *)&blk, + NODE_INSERT(destnode, destind, &midentry->k, (BYTE *)&blk, sizeof(blk)); DLOG_ADD_OP_INSKEY(dlog_ops, dstblki, destind, dlentry_off, blk); if (! uflow_right) @@ -401,13 +401,13 @@ node_underflow( DLOG_ADD_ENTRY(dlog_entries, dlentry_off, midentry, 0); /* Initialize parent overflow node (if any) */ - if (par_ovflow >= 0) + if (par_ovflow >= 0) { INIT_BRANCH_NODE((Node_s *)par_ovflow_buf->pBuf.data, 1, &ntree->ZFSNAMETREEinternalID ); par_ovflow_blki = blki++; DLOG_SET_BLKINFO(dlog_blkinfo, par_ovflow_blki, - par_ovflow_buf, + par_ovflow_buf, ((Node_s *)par_ovflow_buf->pBuf.data)->vers, xaction); DLOG_ALLOC_BLK(dlhdr, dlog_blkinfo, par_ovflow_blki, 0, 1); ZLOG_BIND(xaction, par_ovflow_buf); @@ -418,14 +418,14 @@ node_underflow( * Replace parnode's middle entry with appropriate entry from * current tree level. */ - if (merge) + if (merge) { DLOG_ADD_OP_DELKEY(dlog_ops, parblki, i, oldpar_log, srcbuf->BUFblknum); NODE_DELETE(parnode, i); /* delete parnode's midentry */ if (! uflow_right) *pind = NODE_PREV(parnode, parind); - if (! isleaf) + if (! isleaf) { DLOG_ADD_OP_CH_LCHILD(dlog_ops, srcblki, srcnode->child_blk, INVALID_BLK); @@ -433,25 +433,25 @@ node_underflow( } /* zASSERT(parnode->numRecs > 0); XXX only for debugging!! */ } - else + else { /* - * If rearranging, replace midentry in parent node with + * If rearranging, replace midentry in parent node with * . */ BYTE *e; /* log the new parent entry */ newpar_log = dlentry_off; - if (isleaf) + if (isleaf) { - if (move_right) + if (move_right) { e = (BYTE *)LEAF_ENTRY(srcnode, par_repl_ind); - DLOG_ADD_OP_MOVE(dlog_ops, srcblki, par_repl_ind, + DLOG_ADD_OP_MOVE(dlog_ops, srcblki, par_repl_ind, dstblki, NODE_LEFTMOST(destnode), newpar_log, 1); } - else + else { SNINT size; Branch_s *b = (Branch_s *)dlog_entries; @@ -472,15 +472,15 @@ node_underflow( oldpar_log, newpar_log); zASSERT(rc == zOK); - if (par_ovflow >= 0) + if (par_ovflow >= 0) { zASSERT(par_ovflow_buf != 0); SET_NTREE_BLK_DIRTY(par_ovflow_buf); } - if (! isleaf) + if (! isleaf) { dlog_ind_t rightblki; - Node_s *rightnode; + Node_s *rightnode; DLOG_ADD_OP_DELETE(dlog_ops, srcblki, par_repl_ind, newpar_log); NODE_DELETE(srcnode, par_repl_ind); @@ -515,13 +515,13 @@ node_underflow( DLOG_DELETE_BRANCH(xaction, dlhdr, dlog_blkinfo, parblki, 0); dealloc_pbuf = 1; } - else + else { parnode->vers = dlbuf->ZXR_Lsn; ZLOG_BIND(xaction, parbuf); } } - if (isleaf && move_right) /* rearranging leaf with left sibling */ + if (isleaf && move_right) /* rearranging leaf with left sibling */ { zASSERT(! merge); /* move new par entry to its final position */ @@ -529,16 +529,16 @@ node_underflow( srcnode, par_repl_ind, 1, 1); } } - if (dlog_nrecs > 1) + if (dlog_nrecs > 1) { - if (! (isleaf && uflow_right)) + if (! (isleaf && uflow_right)) { srcnode->vers = dlbuf->ZXR_Lsn; ZLOG_BIND(xaction, srcbuf); } ZLOG_ReleaseRecord(xaction); - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks[1], DLOG_DATA_SIZE(&lhdr[1], dlog_size[1]))); DLOG_INIT_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -561,13 +561,13 @@ node_underflow( { /* Merge/rearrange nodes */ - SNINT srci = move_right ? NODE_LAST(srcnode) - nrecs + 1 + SNINT srci = move_right ? NODE_LAST(srcnode) - nrecs + 1 : NODE_FIRST(srcnode); SNINT desti = move_right ? NODE_LEFTMOST(destnode) : NODE_LAST(destnode); /* Do a move instead of copy. */ if (isleaf && move_right) ++ desti; - if (nrecs > 0) + if (nrecs > 0) { SNINT i; DLOG_ADD_OP_MOVE(dlog_ops, srcblki, srci, dstblki, desti, @@ -578,17 +578,17 @@ node_underflow( node_ncopy(destnode, desti, srcnode, srci, nrecs, 1); } destnode->vers = dlbuf->ZXR_Lsn; - if (merge) + if (merge) { zASSERT(srcnode->numRecs == 0); - if (isleaf) + if (isleaf) { DLOG_ADD_OP_LEAFLIST_DELETE(dlog_ops, dstblki, srcblki, srcnode->u.nextleaf); destnode->u.nextleaf = srcnode->u.nextleaf; srcnode->u.nextleaf = INVALID_BLK; } - if (srcbuf == *buf) + if (srcbuf == *buf) { *buf = sib_buf; } @@ -599,12 +599,12 @@ node_underflow( /* mark srcnode dealloc'ed */ DLOG_DELETE_BLK(xaction, dlhdr, dlog_blkinfo, srcblki,isleaf,0); } - else + else { srcnode->vers = dlbuf->ZXR_Lsn; ZLOG_BIND(xaction, srcbuf); /* create dependency for srcnode */ } - if (*buf) + if (*buf) { ZLOG_BIND(xaction, *buf); /* create dependency for dstnode */ SET_NTREE_BLK_DIRTY(*buf); @@ -615,12 +615,12 @@ node_underflow( zASSERT(merge || (! NO_SIGNALS(&(srcbuf)->agent))); ZLOG_ReleaseRecordAndLogEnd(xaction); END_XACTION(xaction); - if (dealloc_pbuf) + if (dealloc_pbuf) { DEALLOC_NTREE_BLKS(parms, 1, pbuf); *pbuf = 0; } - if (merge) + if (merge) { if (isleaf) invalidate_smaps(srcbuf->BUFblknum, INVALID_BLK); DEALLOC_NTREE_BLKS(parms, 1, &srcbuf); @@ -648,7 +648,7 @@ error_ret: ; /* * Remove given entry from a overflowed duplicate leaf entry list. * firstbuf and keybuf will be released by this routine (success or failure). - * + * * The entry to be deleted could be either * - at the head of the duplicate entry list (i.e., in leaf node (buf)) * - somewhere in the first overflow node (firstbuf) @@ -662,8 +662,8 @@ error_ret: ; */ STATUS leaf_ovflow_delete( - NameTreeParms_s *parms, - Buffer_s *buf, + NameTreeParms_s *parms, + Buffer_s *buf, node_ind_t ind, node_ind_t dupind, Buffer_s *firstbuf, @@ -704,14 +704,14 @@ leaf_ovflow_delete( else if (keybuf && (keybuf != firstbuf)) { zASSERT(dupind < ((Node_s *)keybuf->pBuf.data)->numRecs); - e = (Leaf_s *)(((Node_s *)keybuf->pBuf.data)->padbytes + + e = (Leaf_s *)(((Node_s *)keybuf->pBuf.data)->padbytes + (dupind * esize)); } - else + else { zASSERT(firstbuf != NULL); zASSERT(dupind < ((Node_s *)firstbuf->pBuf.data)->numRecs); - e = (Leaf_s *)(((Node_s *)firstbuf->pBuf.data)->padbytes + + e = (Leaf_s *)(((Node_s *)firstbuf->pBuf.data)->padbytes + (dupind * esize)); } @@ -720,14 +720,14 @@ leaf_ovflow_delete( dlog_nblks = 0; /* Fetch the first node in the entry's overflow block list */ - if ((! firstbuf) && + if ((! firstbuf) && (rc = FETCH_NTREE_BLK_EXCL(parms, di->ovflow_blk,&firstbuf, 42) != zOK)) goto done; firstnode = (Node_s *)firstbuf->pBuf.data; old_firstblki = keyblki = -1; firstblki = dlog_nblks++; /* Is it empty? If so, we need to remove it from the list */ - if (firstnode->numRecs == 0) + if (firstnode->numRecs == 0) { nodeblki = dlog_nblks++; ++ lhdr.nOps; /* Remove firstbuf from ovflow leaf list */ @@ -739,7 +739,7 @@ leaf_ovflow_delete( if (keybuf && (firstnode->u.nextleaf == keybuf->BUFblknum)) firstbuf = keybuf; else if ((rc = FETCH_NTREE_BLK_EXCL(parms, firstnode->u.nextleaf, - &firstbuf, 42) != zOK)) + &firstbuf, 42) != zOK)) { RELEASE_NTREE_BLK(parms, old_firstbuf); goto done; @@ -775,7 +775,7 @@ leaf_ovflow_delete( if (lhdr.nOps > 0) { xaction = BEGIN_XACTION(parms); - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks, DLOG_DATA_SIZE(&lhdr, dlog_size))); DLOG_INIT_LOG_RECORD(parms->ntree, xaction, dlbuf, dlog_nblks, dlog_blkinfo, dlog_rec); @@ -787,7 +787,7 @@ leaf_ovflow_delete( dlentry_off = 0; if (nodeblki >= 0) { - DLOG_SET_BLKINFO(dlog_blkinfo, nodeblki, buf, + DLOG_SET_BLKINFO(dlog_blkinfo, nodeblki, buf, node->vers, xaction); node->vers = dlbuf->ZXR_Lsn; ZLOG_BIND(xaction, buf); @@ -798,7 +798,7 @@ leaf_ovflow_delete( if (old_firstblki >= 0) { Node_s *old_firstnode = (Node_s *)old_firstbuf->pBuf.data; - DLOG_SET_BLKINFO(dlog_blkinfo, old_firstblki, + DLOG_SET_BLKINFO(dlog_blkinfo, old_firstblki, old_firstbuf, old_firstnode->vers, xaction); DLOG_DELETE_LEAF(xaction, dlhdr, dlog_blkinfo, old_firstblki, 1); @@ -853,7 +853,7 @@ leaf_ovflow_delete( } /* Move delentry to last entry position of firstnode and log it */ memmove(last, DLOG_ENTRIES(dlog_rec) + delentry_log, esize); - DLOG_ADD_OP_REPL_DUP(dlog_ops, firstblki, -1, + DLOG_ADD_OP_REPL_DUP(dlog_ops, firstblki, -1, firstnode->numRecs-1, delentry_log, lastentry_log); e = last; @@ -869,7 +869,7 @@ leaf_ovflow_delete( dupind, lastentry_log, delentry_log); ((Node_s *)keybuf->pBuf.data)->vers = dlbuf->ZXR_Lsn; } - else DLOG_ADD_OP_REPL_DUP(dlog_ops, nodeblki, ind, + else DLOG_ADD_OP_REPL_DUP(dlog_ops, nodeblki, ind, -1, lastentry_log, delentry_log); } ZLOG_ReleaseRecordAndLogEnd(xaction); @@ -897,7 +897,7 @@ leaf_ovflow_delete( dlog_nblks = 1; lhdr.nOps = 1; dlog_size = esize; - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks, DLOG_DATA_SIZE(&lhdr, dlog_size))); DLOG_INIT_LOGICAL_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -907,7 +907,7 @@ leaf_ovflow_delete( dlog_ops = DLOG_OPS(dlog_rec); dlog_entries = DLOG_ENTRIES(dlog_rec); dlentry_off = 0; - + if (firstbuf) { DLOG_SET_BLKINFO(dlog_blkinfo, 0, firstbuf, firstnode->vers, xaction); @@ -936,11 +936,11 @@ leaf_ovflow_delete( firstnode->nextfree -= esize; -- firstnode->numRecs; } - else + else { DLOG_ADD_OP_DELETE(dlog_ops, 0, ind, delentry_log); /* Delete delkey from leaf */ - NODE_DELETE(node, ind); + NODE_DELETE(node, ind); } ZLOG_ReleaseRecord(xaction); done: ; @@ -959,9 +959,9 @@ done: ; STATUS node_delete_entry( - NameTreeParms_s *parms, + NameTreeParms_s *parms, Buffer_s *buf, - dir_key_s *delkey, + dir_key_s *delkey, Zid_t *zid) { ZfsXaction_s *xaction = parms->xaction; @@ -983,7 +983,7 @@ node_delete_entry( dlog_nblks = 1; lhdr.nOps = 1; dlog_size = LEAF_ENTRY_SIZE(LEAF_ENTRY(node, ind)); - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, DLOG_SIZE(dlog_nblks, DLOG_DATA_SIZE(&lhdr, dlog_size))); DLOG_INIT_LOGICAL_LOG_RECORD(parms->ntree, xaction, dlbuf, @@ -992,7 +992,7 @@ node_delete_entry( *DLOG_HDR(dlog_rec) = lhdr; dlog_ops = DLOG_OPS(dlog_rec); dlog_entries = DLOG_ENTRIES(dlog_rec); - + DLOG_SET_BLKINFO(dlog_blkinfo, 0, buf, node->vers, xaction); node->vers = dlbuf->ZXR_Lsn; @@ -1002,7 +1002,7 @@ node_delete_entry( DLOG_ADD_ENTRY(dlog_entries, dlentry_off, NODE_ENTRY(node,ind), 1); /* Delete delkey from leaf */ - NODE_DELETE(node, ind); + NODE_DELETE(node, ind); ZLOG_BIND(xaction, buf); ZLOG_ReleaseRecord(xaction); diff --git a/src/nwnss/zlss/userTree.c b/src/nwnss/zlss/userTree.c index 115fbb2..82c95d6 100644 --- a/src/nwnss/zlss/userTree.c +++ b/src/nwnss/zlss/userTree.c @@ -42,7 +42,6 @@ #include #include #include -#include #include "userTree.h" #include "pssDebug.h" @@ -113,7 +112,7 @@ void UBT_DisplayNode ( node->ULEAF(i).usedAmount); if (node->ULEAF(i).infoBlock) { - READBLK_IO_MSG(iomsg, treeBeast, node->ULEAF(i).infoBlock, + READBLK_IO_MSG(iomsg, treeBeast, node->ULEAF(i).infoBlock, CACHE_READ); SET_DEBUG_ID(iomsg, 0); nameBuffer = ZFS_ReadPoolBlk( &genMsg, &iomsg); @@ -121,10 +120,10 @@ void UBT_DisplayNode ( nameNode = (ObjectNameNode_s *)nameBuffer->pBuf.data; if (nameNode->magic == UBT_NAME_MAGIC) { - DBG_DebugPrintf(LCYAN, MSGNot(" blk=%d idx=%d Name:%U\n"), + DBG_DebugPrintf(LCYAN, MSGNot(" blk=%d idx=%d Name:%U\n"), node->ULEAF(i).infoBlock, node->ULEAF(i).infoIndex, nameNode->entry[node->ULEAF(i).infoIndex].name); - DBG_DebugPrintf(LCYAN, MSGNot(" timeNotFound=%d numTimesNotFound=%d\n"), + DBG_DebugPrintf(LCYAN, MSGNot(" timeNotFound=%d numTimesNotFound=%d\n"), nameNode->entry[node->ULEAF(i).infoIndex].timeNotFound, nameNode->entry[node->ULEAF(i).infoIndex].numberOfTimesNotFound); } @@ -302,7 +301,7 @@ void UBT_validateNode( curr = &node->ULEAF(count); // zASSERT(curr->usedAmount <= curr->restrictionAmount); - + /* check if ascending */ zASSERT(LB_GUIDCompare(&prev->userID, &curr->userID) < 0); @@ -327,7 +326,7 @@ void UBT_validateNode( for(count = 1; count < node->numRecs; count++) { curr = &node->UBRANCH(count); - + /* check if ascending */ zASSERT(LB_GUIDCompare(&prev->userID, &curr->userID) < 0); @@ -413,12 +412,12 @@ Blknum_t UBT_findChildBlock( ENTER(TZTREE, UBT_findChildBlock); - while (low <= high) + while (low <= high) { mid = (low + high) / 2; cmpResult = LB_GUIDCompare(userID, &node->UBRANCH(mid).userID); if (cmpResult == 0) /* userID == userIDFromMid */ - { + { break; } else if (cmpResult > 0) /* userID > userIDFromMid */ @@ -463,7 +462,7 @@ BOOL UBT_findLeafEntry( ENTER(TZTREE, UBT_findLeafEntry); UBT_VALIDATE_NODE(node); - while (low <= high) + while (low <= high) { mid = (low + high) / 2; cmpResult = LB_GUIDCompare(userID, &node->ULEAF(mid).userID); @@ -533,9 +532,9 @@ void UBT_insertZeroNode (UserTreeNode_s *node) UBT_VALIDATE_NODE(node); /* - * We always want a zero in the first location to establish a lower bound - * so we do not need a lot of special case code. - */ + * We always want a zero in the first location to establish a lower bound + * so we do not need a lot of special case code. + */ node->numRecs = 1; bzero(&node->ULEAF(0), sizeof(UserLeaf_s)); node->ULEAF(0).userID = UBT_ZERO_USERID; @@ -610,8 +609,8 @@ STATUS UBT_join ( /* update the leaf link */ child->n.leaf.nextLeaf = sibling->n.leaf.nextLeaf; /* Change magic in Deleted Leaf Node to indicate it is deleted. This - * is being done for scan mode of rebuild. - */ + * is being done for scan mode of rebuild. + */ sibling->magic |= 0x20; /* Lower case low byte letter */ } else @@ -631,8 +630,8 @@ STATUS UBT_join ( parentIndex = parms->index + 1; entryInParent = parent->UBRANCH(parentIndex).userID; memmove( &parent->UBRANCH(parentIndex), /* Destination */ - &parent->UBRANCH(parentIndex + 1), /* Source */ - (parent->numRecs - parentIndex) * sizeof(UserBranchEntry_s)); + &parent->UBRANCH(parentIndex + 1), /* Source */ + (parent->numRecs - parentIndex) * sizeof(UserBranchEntry_s)); localXaction = BeginXLocal(parms->volume, BXL_DEFAULT); @@ -675,14 +674,14 @@ STATUS UBT_join ( ZLOG_BIND(localXaction, parms->parent); if (UBT_IS_LEAF(child) ) { /* This is the deleted LEAF block we must write so that rebuild - * can scan whole disk and not find OLD beast tree leafs. - */ + * can scan whole disk and not find OLD beast tree leafs. + */ parms->sibling->state |= CACHE_DIRTY; ZLOG_BIND(localXaction, parms->sibling); #if 0 /* This code allows for testing of the recovery code of setting - * the magic word on deletes. - */ + * the magic word on deletes. + */ #if NSS_ASSERT IS_ENABLED { extern LONG gZlogAssertBlock; @@ -739,15 +738,15 @@ STATUS UBT_balance ( avg = (child->numRecs + sibling->numRecs) / 2; - /* Don't do balancing if no records can be moved */ + /* Don't do balancing if no records can be moved */ if (child->numRecs == avg || (sibling->numRecs == avg)) { /* - * The entry we were looking for when we started the balance my be - * in either the child or the sibling entry. Make sure that it - * ends up in the child. - */ - if (LB_GUIDCompare(&parms->userID, + * The entry we were looking for when we started the balance my be + * in either the child or the sibling entry. Make sure that it + * ends up in the child. + */ + if (LB_GUIDCompare(&parms->userID, &parent->UBRANCH(parms->index + 1).userID) >= 0) { CACHE_RELEASE(parms->child); @@ -755,7 +754,7 @@ STATUS UBT_balance ( } else { - CACHE_RELEASE(parms->sibling); + CACHE_RELEASE(parms->sibling); } RTN_STATUS(zOK); } @@ -775,8 +774,8 @@ STATUS UBT_balance ( /* move the entries from sibling to child */ memcpy(startLocation, /* Destination */ - &sibling->ULEAF(0), /* Source */ - lenMoved); + &sibling->ULEAF(0), /* Source */ + lenMoved); /* move sibling entries back to the front of the record */ memmove(&sibling->ULEAF(0), /* Destination */ @@ -802,8 +801,8 @@ STATUS UBT_balance ( /* move the entries from the child to the sibling */ memcpy(startLocation, - &child->ULEAF(child->numRecs - numToMove), - lenMoved); + &child->ULEAF(child->numRecs - numToMove), + lenMoved); child->numRecs -= numToMove; sibling->numRecs += numToMove; @@ -820,8 +819,8 @@ STATUS UBT_balance ( /* move the entries from sibling to child */ memcpy(startLocation, /* Destination */ - &sibling->UBRANCH(0), /* Source */ - lenMoved); + &sibling->UBRANCH(0), /* Source */ + lenMoved); /* move sibling entries back to the front of the record */ memmove(&sibling->UBRANCH(0), /* Destination */ @@ -847,8 +846,8 @@ STATUS UBT_balance ( /* move the entries from the child to the sibling */ memcpy(startLocation, - &child->UBRANCH(child->numRecs - numToMove), - lenMoved); + &child->UBRANCH(child->numRecs - numToMove), + lenMoved); child->numRecs -= numToMove; sibling->numRecs += numToMove; @@ -966,7 +965,7 @@ STATUS UBT_underflow ( parms->sibling = UBT_ReadPoolBlk(genMsg, &iomsg); if (parms->sibling == NULL) { - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } UBT_VALIDATE_NODE((UserTreeNode_s *)parms->sibling->pBuf.data); } @@ -977,9 +976,9 @@ STATUS UBT_underflow ( READBLK_IO_MSG(iomsg, userTreeBeast, parms->readBlkNum, CACHE_UPDATE); SET_DEBUG_ID(iomsg, 2); /* - * Release the latch so we do not latch out of order -- This is - * OK because the parent latch is held. - */ + * Release the latch so we do not latch out of order -- This is + * OK because the parent latch is held. + */ CACHE_PIN(parms->sibling); CACHE_UNXLATCH(parms->sibling); parms->child = UBT_ReadPoolBlk(genMsg, &iomsg); @@ -988,7 +987,7 @@ STATUS UBT_underflow ( if (parms->child == NULL) { CACHE_RELEASE(parms->sibling); - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } UBT_VALIDATE_NODE((UserTreeNode_s *)parms->child->pBuf.data); } @@ -1227,9 +1226,9 @@ STATUS UBT_split ( parms->readBlkNum = parms->child->volBlk; /* - * Sibling is the node to be split. It is the left node in the split. - * Child is the new node. - */ + * Sibling is the node to be split. It is the left node in the split. + * Child is the new node. + */ child = (UserTreeNode_s *)parms->child->pBuf.data; holdState = sibling->state & UBT_LEAF; @@ -1270,8 +1269,8 @@ STATUS UBT_split ( } /* - * Make room in the Parent to place the node - */ + * Make room in the Parent to place the node + */ i = parms->index + 1; memmove(&parent->UBRANCH(i + 1), /* Destination */ &parent->UBRANCH(i), /* Source */ @@ -1390,7 +1389,7 @@ STATUS UBT_grow ( userTreeBeast->zfsBtree.p.btRoot = parms->readBlkNum; /* force the beast out */ - COMN_MARK_BEAST_XLOCAL(&userTreeBeast->ZFSUSERTREEroot, + COMN_MARK_BEAST_XLOCAL(&userTreeBeast->ZFSUSERTREEroot, &localXaction->xaction); if (COMN_ForceBeastWrite(genMsg, &userTreeBeast->ZFSUSERTREEroot, &localXaction->xaction)) @@ -1529,7 +1528,7 @@ void UBT_logInsertRecord ( ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[0], parms->child->volBlk, child->lsn, parms->child, parms->xaction, 0, UBT_compare); - logRecord->u.entry.internalID = + logRecord->u.entry.internalID = parms->userTreeBeast->ZFSUSERTREEroot.ROOTinternalID; logRecord->u.entry.userID = parms->userID; logRecord->u.entry.usedAmount = usedAmount; @@ -1560,17 +1559,17 @@ STATUS UBT_insertEntry ( UserLeafEntry_s *entry; /* - * This routine assumes a check has ready been done to make sure there - * there is enough free space in the buffer to hold the new znode. - */ + * This routine assumes a check has ready been done to make sure there + * there is enough free space in the buffer to hold the new znode. + */ ENTER(TZTREE, insertZnode); child = (UserTreeNode_s *)parms->child->pBuf.data; /* - * Add the entry to the leaf node - */ + * Add the entry to the leaf node + */ if (UBT_findLeafEntry(child, &parms->userID, &i)) { zASSERT("Same user added twice to user b-tree" == NULL); @@ -1602,7 +1601,7 @@ STATUS UBT_insertEntry ( * * Input: Child and parent are latched. Child is buffer to inserted into. * - * Output: Parent and child are unlatched. + * Output: Parent and child are unlatched. ****************************************************************************/ STATUS UBT_doInsertEntry ( GeneralMsg_s *genMsg, @@ -1678,7 +1677,7 @@ void UBT_logModifyRecord ( ZLOG_ASSIGN_BLOCK_INFO2(poolBlks[0], parms->child->volBlk, child->lsn, parms->child, parms->xaction, 0, UBT_compare); - logRecord->u.modify.internalID = + logRecord->u.modify.internalID = parms->userTreeBeast->ZFSUSERTREEroot.ROOTinternalID; logRecord->u.modify.userID = parms->userID; logRecord->u.modify.oldValue = oldValue; @@ -1805,7 +1804,7 @@ STATUS UBT_findLeaf ( { if (UBT_IS_ROOT(node)) { - UNX_LATCH(&parms->userTreeBeast->ZFSUSERTREEbeastLatch); + UNX_LATCH(&parms->userTreeBeast->ZFSUSERTREEbeastLatch); } } if (!UBT_IS_ROOT(node)) @@ -1853,8 +1852,8 @@ STATUS UBT_modifyUserValue ( ENTER(TZTREE, UBT_modifyUserValue); /* - * Get an exclusive latch on the User Tree Beast - */ + * Get an exclusive latch on the User Tree Beast + */ X_LATCH(&userTreeBeast->ZFSUSERTREEbeastLatch); if (userTreeBeast->zfsBtree.p.btRoot == INVALID_BLK) @@ -1887,7 +1886,7 @@ STATUS UBT_modifyUserValue ( /* log the init record */ ZLOG_ObtainRecord(localXaction, - ZLOG_BLOCK_INFO_SIZE(1) + sizeof(UBTTreeInit_s) ); + ZLOG_BLOCK_INFO_SIZE(1) + sizeof(UBTTreeInit_s) ); ZLOG_INIT_LOG_RECORD(XFUNC_USERTREE_INIT, localXaction, logBuffer, 1, poolBlks, logRecord); @@ -1911,8 +1910,8 @@ STATUS UBT_modifyUserValue ( } /* - * If the entry already exists then update it, otherwise insert it - */ + * If the entry already exists then update it, otherwise insert it + */ if (UBT_findLeafEntry((UserTreeNode_s *)parms->child->pBuf.data, &parms->userID, &index)) { @@ -2076,8 +2075,8 @@ STATUS ZFSVOL_VOL_GetUserSpaceInfo( parms.userID = *userID; /* - * Get an exclusive latch on the User Tree Beast - */ + * Get an exclusive latch on the User Tree Beast + */ S_LATCH(&userTreeBeast->ZFSUSERTREEbeastLatch); if (userTreeBeast->zfsBtree.p.btRoot == INVALID_BLK) { @@ -2085,7 +2084,7 @@ STATUS ZFSVOL_VOL_GetUserSpaceInfo( SetErrno(genMsg, zERR_NO_SUCH_USER); RTN_STATUS(zFAILURE); } - + /* read the root node */ READBLK_IO_MSG(iomsg, userTreeBeast, userTreeBeast->zfsBtree.p.btRoot, CACHE_READ); @@ -2099,7 +2098,7 @@ STATUS ZFSVOL_VOL_GetUserSpaceInfo( RTN_STATUS(zFAILURE); } UBT_VALIDATE_NODE((UserTreeNode_s *)parms.child->pBuf.data); - + /* decend the tree to the leaf */ if (UBT_getLeaf(genMsg, (ZfsVolume_s *)volume, &parms, CACHE_READ) != zOK) { @@ -2116,7 +2115,7 @@ STATUS ZFSVOL_VOL_GetUserSpaceInfo( CACHE_RELEASE(parms.child); RTN_STATUS(zFAILURE); } - else + else { *restrictionAmount = node->ULEAF(index).restrictionAmount; *usedAmount = node->ULEAF(index).usedAmount; @@ -2133,7 +2132,7 @@ STATUS zfsvol_vol_CountUsersInVolume( GeneralMsg_s *genMsg, Volume_s *volume, NINT *userCount, - LONG allUsersFlag) + LONG allUsersFlag) { STATUS status = zOK; ZfsUserTreeBeast_s *userTreeBeast = ((ZfsVolume_s *)volume)->userTree; @@ -2162,7 +2161,7 @@ STATUS zfsvol_vol_CountUsersInVolume( UNS_LATCH(&userTreeBeast->ZFSUSERTREEbeastLatch); goto done; } - + /* read the root node */ READBLK_IO_MSG(iomsg, userTreeBeast, userTreeBeast->zfsBtree.p.btRoot, CACHE_READ); @@ -2178,7 +2177,7 @@ STATUS zfsvol_vol_CountUsersInVolume( UBT_VALIDATE_NODE(node); /* descend the tree to the leaf */ - if ((status = UBT_getLeaf(genMsg, (ZfsVolume_s *)volume, + if ((status = UBT_getLeaf(genMsg, (ZfsVolume_s *)volume, &parms, CACHE_READ)) != zOK) { goto done; @@ -2191,7 +2190,7 @@ STATUS zfsvol_vol_CountUsersInVolume( while (1) { /* Skip to a leaf node with entries to process */ - if (index >= node->numRecs) + if (index >= node->numRecs) { /* Jump to the next leaf node */ if (node->n.leaf.nextLeaf == INVALID_BLK) @@ -2215,7 +2214,7 @@ STATUS zfsvol_vol_CountUsersInVolume( if ((allUsersFlag & BROWSE_USERS_GET_ALL) || (!(allUsersFlag & BROWSE_USERS_GET_ONLY_RESTRICTED) && - (node->ULEAF(index).usedAmount != 0 )) || + (node->ULEAF(index).usedAmount != 0 )) || (node->ULEAF(index).restrictionAmount != zUSER_NO_RESTRICTIONS)) { count++; @@ -2241,8 +2240,8 @@ STATUS zfsvol_vol_BrowseUsersInVolumeAtCount( COMNUserRest_s *userEntries, /* out */ NINT *numEntriesReturned, /* in : start count out: numEntriesRet */ - LONG allUsersFlag) /* if 0 then only those with - space information (used space or if they + LONG allUsersFlag) /* if 0 then only those with + space information (used space or if they have a restriction are returned ) */ { STATUS status = zOK; @@ -2274,7 +2273,7 @@ STATUS zfsvol_vol_BrowseUsersInVolumeAtCount( UNS_LATCH(&userTreeBeast->ZFSUSERTREEbeastLatch); goto done; } - + /* read the root node */ READBLK_IO_MSG(iomsg, userTreeBeast, userTreeBeast->zfsBtree.p.btRoot, CACHE_READ); @@ -2290,7 +2289,7 @@ STATUS zfsvol_vol_BrowseUsersInVolumeAtCount( UBT_VALIDATE_NODE(node); /* descend the tree to the leaf */ - if ((status = UBT_getLeaf(genMsg, (ZfsVolume_s *)volume, + if ((status = UBT_getLeaf(genMsg, (ZfsVolume_s *)volume, &parms, CACHE_READ)) != zOK) { goto done; @@ -2299,18 +2298,18 @@ STATUS zfsvol_vol_BrowseUsersInVolumeAtCount( node = (UserTreeNode_s *)parms.child->pBuf.data; zASSERT(UBT_IS_LEAF(node)); - /* - * Return the user entries of next numEntriesRequested users - * by sequentially scanning the user tree's leaf nodes - * - * Sequentially scan the linked list of leaf nodes for users to return - * (starting at (and including) the startcount'th user). - */ + /* + * Return the user entries of next numEntriesRequested users + * by sequentially scanning the user tree's leaf nodes + * + * Sequentially scan the linked list of leaf nodes for users to return + * (starting at (and including) the startcount'th user). + */ index++; // Skip the first entry which is zINVALID_USER for (entryIndex = 0; entryIndex < numEntriesRequested; index++) { /* Skip to a leaf node with entries to process */ - if (index >= node->numRecs) + if (index >= node->numRecs) { /* Jump to the next leaf node */ if (node->n.leaf.nextLeaf == INVALID_BLK) @@ -2335,7 +2334,7 @@ STATUS zfsvol_vol_BrowseUsersInVolumeAtCount( /* Add the beast's ZID to the beastZids list */ if ((allUsersFlag & BROWSE_USERS_GET_ALL) || (!(allUsersFlag & BROWSE_USERS_GET_ONLY_RESTRICTED) && - (node->ULEAF(index).usedAmount != 0 )) || + (node->ULEAF(index).usedAmount != 0 )) || (node->ULEAF(index).restrictionAmount != zUSER_NO_RESTRICTIONS)) { //printk("<1> HEre skipcount = %d, startCount = %d\n", skipCount, startCount); @@ -2346,7 +2345,7 @@ STATUS zfsvol_vol_BrowseUsersInVolumeAtCount( else { userEntries[entryIndex].userID = node->ULEAF(index).userID; - userEntries[entryIndex].usedAmount = + userEntries[entryIndex].usedAmount = node->ULEAF(index).usedAmount; userEntries[entryIndex].restrictionAmount = node->ULEAF(index).restrictionAmount; @@ -2373,8 +2372,8 @@ STATUS ZFSVOL_VOL_BrowseUsersInVolume( UserID_t *lastUserReturned, /* inout */ COMNUserRest_s *userEntries, /* out */ NINT *numEntriesReturned, - LONG allUsersFlag) /* if 0 then only those with - space information (used space or if they + LONG allUsersFlag) /* if 0 then only those with + space information (used space or if they have a restriction are returned ) */ { STATUS status; @@ -2391,7 +2390,7 @@ STATUS ZFSVOL_VOL_BrowseUsersInVolume( { /* numEntriesRequested, lastUserReturned, userEntries ignored */ /* numEntriesReturned is filled with the total count */ - status = zfsvol_vol_CountUsersInVolume(genMsg, volume, + status = zfsvol_vol_CountUsersInVolume(genMsg, volume, numEntriesReturned, allUsersFlag); RTN_STATUS(status); } @@ -2399,10 +2398,10 @@ STATUS ZFSVOL_VOL_BrowseUsersInVolume( { /* lastUserReturned ignored */ /* numEntriesReturned used as the count to start at, - * Return value of numEntriesReturned is the number of users returned. - */ - status = zfsvol_vol_BrowseUsersInVolumeAtCount(genMsg, volume, - numEntriesRequested, userEntries, + * Return value of numEntriesReturned is the number of users returned. + */ + status = zfsvol_vol_BrowseUsersInVolumeAtCount(genMsg, volume, + numEntriesRequested, userEntries, numEntriesReturned, allUsersFlag); RTN_STATUS(status); } @@ -2425,10 +2424,10 @@ STATUS ZFSVOL_VOL_BrowseUsersInVolume( UNS_LATCH(&userTreeBeast->ZFSUSERTREEbeastLatch); goto done; } - + /* - * Find the next user after *lastUserReturned. - */ + * Find the next user after *lastUserReturned. + */ /* read the root node */ READBLK_IO_MSG(iomsg, userTreeBeast, userTreeBeast->zfsBtree.p.btRoot, @@ -2445,7 +2444,7 @@ STATUS ZFSVOL_VOL_BrowseUsersInVolume( UBT_VALIDATE_NODE(node); /* descend the tree to the leaf */ - if ((status = UBT_getLeaf(genMsg, (ZfsVolume_s *)volume, + if ((status = UBT_getLeaf(genMsg, (ZfsVolume_s *)volume, &parms, CACHE_READ)) != zOK) { goto done; @@ -2459,17 +2458,17 @@ STATUS ZFSVOL_VOL_BrowseUsersInVolume( } ++ index; /* Skip the last matched entry */ - /* - * Return the user entries of next numEntriesRequested users - * by sequentially scanning the user tree's leaf nodes - * - * Sequentially scan the linked list of leaf nodes for users to return - * (starting at the user at (parms.child, index)). - */ + /* + * Return the user entries of next numEntriesRequested users + * by sequentially scanning the user tree's leaf nodes + * + * Sequentially scan the linked list of leaf nodes for users to return + * (starting at the user at (parms.child, index)). + */ for (entryIndex = 0; entryIndex < numEntriesRequested; index++) { /* Skip to a leaf node with entries to process */ - if (index >= node->numRecs) + if (index >= node->numRecs) { /* Jump to the next leaf node */ if (node->n.leaf.nextLeaf == INVALID_BLK) @@ -2494,7 +2493,7 @@ STATUS ZFSVOL_VOL_BrowseUsersInVolume( /* Add the beast's ZID to the beastZids list */ if ((allUsersFlag & BROWSE_USERS_GET_ALL) || (!(allUsersFlag & BROWSE_USERS_GET_ONLY_RESTRICTED) && - (node->ULEAF(index).usedAmount != 0 )) || + (node->ULEAF(index).usedAmount != 0 )) || (node->ULEAF(index).restrictionAmount != zUSER_NO_RESTRICTIONS)) { userEntries[entryIndex].userID = node->ULEAF(index).userID; @@ -2575,7 +2574,7 @@ void UBT_deleteRecord ( parms->child, localXaction, 0, UBT_compare); entry = &node->ULEAF(index); - logRecord->u.entry.internalID = + logRecord->u.entry.internalID = parms->userTreeBeast->ZFSUSERTREEroot.ROOTinternalID; logRecord->u.entry.userID = entry->userID; logRecord->u.entry.usedAmount = entry->usedAmount; @@ -2596,14 +2595,14 @@ void UBT_deleteRecord ( nameBuffer, localXaction, 1); logRecord->u.remove.nameIndex = entry->infoIndex; - unicpy( logRecord->u.remove.name, + unicpy( logRecord->u.remove.name, nameNode->entry[entry->infoIndex].name); nameNode->lsn = logBuffer->ZXR_Lsn; - /* - * Determine if we are going to delete the block because this is the - * last name in it. - */ + /* + * Determine if we are going to delete the block because this is the + * last name in it. + */ count = 0; for (i = 0; i < UBT_MAX_NAME_ENTRIES; i++) { @@ -2615,12 +2614,12 @@ void UBT_deleteRecord ( zASSERT(count > 0); zASSERT(nameNode->entry[entry->infoIndex].state & UBT_NAME_ENTRY_USED); - if (count > 1 || + if (count > 1 || (nameBuffer->volBlk == userTreeBeast->zfsBtree.p.btFree)) { ZLOG_BIND(localXaction, nameBuffer); #if NSS_DEBUG IS_ENABLED -//DBG_DebugPrintf(LMAGENTA, "Deleting name entry in block %d. Count=%d\n", +//DBG_DebugPrintf(LMAGENTA, "Deleting name entry in block %d. Count=%d\n", //poolBlks[1], count); #endif } @@ -2665,7 +2664,7 @@ void UBT_deleteRecord ( //{ // if (nameNode) // { -// nameNode->entry[node->ULEAF(index).infoIndex].state &= +// nameNode->entry[node->ULEAF(index).infoIndex].state &= // ~UBT_NAME_ENTRY_USED; // } // @@ -2730,8 +2729,8 @@ STATUS UBT_doDeleteUser ( } /* - * Get the buffer with the associated name if there is one. - */ + * Get the buffer with the associated name if there is one. + */ nameBlkNum = child->ULEAF(i).infoBlock; if (nameBlkNum != 0 && nameBlkNum != INVALID_BLK) { @@ -2747,8 +2746,8 @@ STATUS UBT_doDeleteUser ( } /* - * Delete the user entry and any name entry that is associated with it. - */ + * Delete the user entry and any name entry that is associated with it. + */ UBT_deleteRecord(genMsg, parms, nameBuffer, i); UBT_VALIDATE_NODE((UserTreeNode_s *)parms->child->pBuf.data); @@ -2763,7 +2762,7 @@ STATUS UBT_doDeleteUser ( errorExit: //zASSERT(0); CACHE_DIRTY_RELEASE(parms->child); - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } @@ -2847,7 +2846,7 @@ void UBT_logDeleteNameEntry ( parms->child, localXaction, 0, UBT_compare); entry = &node->ULEAF(index); - logRecord->u.removeName.internalID = + logRecord->u.removeName.internalID = parms->userTreeBeast->ZFSUSERTREEroot.ROOTinternalID; logRecord->u.removeName.userID = entry->userID; @@ -2861,14 +2860,14 @@ void UBT_logDeleteNameEntry ( nameBuffer, localXaction, 1); logRecord->u.removeName.nameIndex = entry->infoIndex; - unicpy(logRecord->u.removeName.name, + unicpy(logRecord->u.removeName.name, nameNode->entry[entry->infoIndex].name); nameNode->lsn = logBuffer->ZXR_Lsn; - /* - * Determine if we are going to delete the block because this is the - * last name in it. - */ + /* + * Determine if we are going to delete the block because this is the + * last name in it. + */ count = 0; for (i = 0; i < UBT_MAX_NAME_ENTRIES; i++) { @@ -2880,7 +2879,7 @@ void UBT_logDeleteNameEntry ( zASSERT(count > 0); zASSERT(nameNode->entry[entry->infoIndex].state & UBT_NAME_ENTRY_USED); - if (count > 1 || + if (count > 1 || (nameBuffer->volBlk == userTreeBeast->zfsBtree.p.btFree)) { ZLOG_BIND(localXaction, nameBuffer); @@ -2926,7 +2925,7 @@ STATUS UBT_doDeleteUserName ( child = (UserTreeNode_s *)parms->child->pBuf.data; if (UBT_IS_ROOT(child)) { - UNX_LATCH(&parms->userTreeBeast->ZFSUSERTREEbeastLatch); + UNX_LATCH(&parms->userTreeBeast->ZFSUSERTREEbeastLatch); } else { @@ -2941,8 +2940,8 @@ STATUS UBT_doDeleteUserName ( } /* - * Get the buffer with the associated name if there is one. - */ + * Get the buffer with the associated name if there is one. + */ nameBlkNum = child->ULEAF(i).infoBlock; if (nameBlkNum == 0 || nameBlkNum == INVALID_BLK) { @@ -2960,8 +2959,8 @@ STATUS UBT_doDeleteUserName ( zASSERT(nameNode->magic == UBT_NAME_MAGIC); /* - * Delete the name entry that is associated with a user. - */ + * Delete the name entry that is associated with a user. + */ UBT_logDeleteNameEntry(genMsg, parms, nameBuffer, i); nameNode->entry[child->ULEAF(i).infoIndex].state &= ~UBT_NAME_ENTRY_USED; child->ULEAF(i).infoIndex = 0; @@ -2977,7 +2976,7 @@ exit: errorExit: //zASSERT(0); CACHE_DIRTY_RELEASE(parms->child); - RTN_STATUS(zFAILURE); + RTN_STATUS(zFAILURE); } @@ -3023,7 +3022,7 @@ STATUS UBT_DeleteObjectName( /**************************************************************************** * - * This function will reset the restriction info for all entries in the user + * This function will reset the restriction info for all entries in the user * tree * ****************************************************************************/ @@ -3044,16 +3043,16 @@ STATUS ZFSVOL_VOL_ResetAllUsers( zASSERT(!(volume->VOLenabledAttributes & zATTR_READONLY)); /* - * If there is no tree then don't bother. - */ + * If there is no tree then don't bother. + */ if (userTreeBeast == NULL) { return zOK; } /* - * Get an exclusive latch on the User Tree Beast - */ + * Get an exclusive latch on the User Tree Beast + */ X_LATCH(&userTreeBeast->ZFSUSERTREEbeastLatch); if (userTreeBeast->zfsBtree.p.btRoot == INVALID_BLK) @@ -3081,7 +3080,7 @@ STATUS ZFSVOL_VOL_ResetAllUsers( UBT_VALIDATE_NODE(node); /* descend the tree to the leaf */ - if ((status = UBT_getLeaf(genMsg, (ZfsVolume_s *)volume, + if ((status = UBT_getLeaf(genMsg, (ZfsVolume_s *)volume, &parms, CACHE_UPDATE)) != zOK) { goto done; @@ -3091,13 +3090,13 @@ STATUS ZFSVOL_VOL_ResetAllUsers( zASSERT(UBT_IS_LEAF(node)); /* - * Sequentially scan the linked list of leaf nodes for users and remove - * the used information for each user. - */ + * Sequentially scan the linked list of leaf nodes for users and remove + * the used information for each user. + */ for (index = 0; ; index++) { /* Skip to a leaf node with entries to process */ - if (index >= node->numRecs) + if (index >= node->numRecs) { /* Jump to the next leaf node */ if (node->n.leaf.nextLeaf == INVALID_BLK) @@ -3210,7 +3209,7 @@ STATUS UBT_initRemoveObjectName( ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + sizeof(UBTAddNameRecord_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_UTREE_DELETE_NAME_RECORD, xaction, + ZLOG_INIT_LOG_RECORD(XFUNC_UTREE_DELETE_NAME_RECORD, xaction, logBuffer, 1, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], delBlkNum, nameNode->lsn, nameBuffer, xaction, 0); @@ -3227,14 +3226,14 @@ STATUS UBT_initRemoveObjectName( if (delBlkNum == userTreeBeast->zfsBtree.p.btFree) { /* - * Fix up the user tree beast to show no avail - */ + * Fix up the user tree beast to show no avail + */ #if NSS_DEBUG IS_ENABLED // DBG_DebugPrintf(YELLOW, "resetting avail list for user tree -- ZFSVOL_VOL_ResetAllObjects\n"); #endif userTreeBeast->zfsBtree.p.btFree = INVALID_BLK; - COMN_MARK_BEAST_XLOCAL(&userTreeBeast->ZFSUSERTREEroot, + COMN_MARK_BEAST_XLOCAL(&userTreeBeast->ZFSUSERTREEroot, &xaction->xaction); COMN_ForceBeastWrite(genMsg, &userTreeBeast->ZFSUSERTREEroot, &xaction->xaction); @@ -3264,7 +3263,7 @@ STATUS ZFSVOL_VOL_ResetAllObjects( Buffer_s *buffer; NINT entry; } ParentStack_s; - + UserTreeNode_s *node; ZfsUserTreeBeast_s *userTreeBeast = ((ZfsVolume_s *)volume)->userTree; Buffer_s *buffer; @@ -3284,8 +3283,8 @@ STATUS ZFSVOL_VOL_ResetAllObjects( zASSERT(!(volume->VOLenabledAttributes & zATTR_READONLY)); /* - * If there is no tree then don't bother. - */ + * If there is no tree then don't bother. + */ if (userTreeBeast == NULL) { STACK_FREE(); @@ -3299,8 +3298,8 @@ STATUS ZFSVOL_VOL_ResetAllObjects( } /* - * Get an exclusive latch on the User Tree Beast - */ + * Get an exclusive latch on the User Tree Beast + */ X_LATCH(&userTreeBeast->ZFSUSERTREEbeastLatch); if (userTreeBeast->zfsBtree.p.btRoot == INVALID_BLK) @@ -3335,9 +3334,9 @@ STATUS ZFSVOL_VOL_ResetAllObjects( node = (UserTreeNode_s *)buffer->pBuf.data; /* - * Push the buffer on the stack and move on to its first - * child - */ + * Push the buffer on the stack and move on to its first + * child + */ stkPtr++; zASSERT(stkPtr < MAX_USER_TREE_DEPTH); @@ -3366,12 +3365,12 @@ STATUS ZFSVOL_VOL_ResetAllObjects( node = (UserTreeNode_s *)buffer->pBuf.data; /* - * If we have read all of the child records we can now delete - * them. - * - * If this is a leaf we need to check each name record for the - * leaf and see it it should be deleted. - */ + * If we have read all of the child records we can now delete + * them. + * + * If this is a leaf we need to check each name record for the + * leaf and see it it should be deleted. + */ aStack->parentStack[stkPtr].entry++; if (UBT_IS_LEAF(node) || aStack->parentStack[stkPtr].entry >= node->numRecs) @@ -3383,17 +3382,17 @@ STATUS ZFSVOL_VOL_ResetAllObjects( node->numRecs--; if (UBT_IS_LEAF(node)) { - if (node->ULEAF(node->numRecs).infoBlock && + if (node->ULEAF(node->numRecs).infoBlock && (LB_GUIDCompare(&node->ULEAF(node->numRecs).userID, &UBT_ZERO_USERID) != 0)) { /* if there is a name then remove it */ - if (UBT_initRemoveObjectName(genMsg, volume, + if (UBT_initRemoveObjectName(genMsg, volume, buffer) != zOK) { CACHE_DIRTY_RELEASE(buffer); status = zFAILURE; goto exit; - } + } } } else @@ -3401,14 +3400,14 @@ STATUS ZFSVOL_VOL_ResetAllObjects( xaction = BeginXLocal(&((ZfsVolume_s *)volume)->vol, BXL_DEFAULT); ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2)); - ZLOG_INIT_LOG_RECORD(XFUNC_USERTREE_REMOVE, xaction, + ZLOG_INIT_LOG_RECORD(XFUNC_USERTREE_REMOVE, xaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, node->lsn, buffer, xaction, 0); node->lsn = logBuffer->ZXR_Lsn; - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], - node->UBRANCH(node->numRecs).child, 0, NULL, + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], + node->UBRANCH(node->numRecs).child, 0, NULL, xaction, 1); #if NSS_DEBUG IS_ENABLED // DBG_DebugPrintf(YELLOW, "Delete block %d -- ZFSVOL_VOL_ResetAllObjects\n", poolBlks[1].blkNum); @@ -3445,12 +3444,12 @@ STATUS ZFSVOL_VOL_ResetAllObjects( ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2)); - ZLOG_INIT_LOG_RECORD(XFUNC_USERTREE_REMOVE, xaction, logBuffer, 2, + ZLOG_INIT_LOG_RECORD(XFUNC_USERTREE_REMOVE, xaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], 0, 0, NULL, xaction, 0); - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], userTreeBeast->zfsBtree.p.btRoot, 0, + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], userTreeBeast->zfsBtree.p.btRoot, 0, NULL, xaction, 0); #if NSS_DEBUG IS_ENABLED @@ -3466,12 +3465,12 @@ STATUS ZFSVOL_VOL_ResetAllObjects( { ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2)); - ZLOG_INIT_LOG_RECORD(XFUNC_USERTREE_REMOVE, xaction, logBuffer, 2, + ZLOG_INIT_LOG_RECORD(XFUNC_USERTREE_REMOVE, xaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], 0, 0, NULL, xaction, 0); - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], userTreeBeast->zfsBtree.p.btFree, 0, + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], userTreeBeast->zfsBtree.p.btFree, 0, NULL, xaction, 0); #if NSS_DEBUG IS_ENABLED @@ -3483,8 +3482,8 @@ STATUS ZFSVOL_VOL_ResetAllObjects( } /* - * Fix up the user tree beast to show no tree - */ + * Fix up the user tree beast to show no tree + */ userTreeBeast->zfsBtree.p.btRoot = INVALID_BLK; X_LATCH(&UserTreeInsertNameLatch); userTreeBeast->zfsBtree.p.btFree = INVALID_BLK; @@ -3542,8 +3541,8 @@ STATUS UBT_CreateUserTreeBeast( volume->ZLSSVOLuserTree = (ZfsUserTreeBeast_s *)beast; BEASTHASH_Insert(beast); /* - * We do not want these special system beasts to be in the linked list. - */ + * We do not want these special system beasts to be in the linked list. + */ DQ_RMV(beast, volLink); return zOK; } @@ -3582,9 +3581,9 @@ STATUS ZFSVOL_VOL_GetObjectName( userTreeBeast = ((ZfsVolume_s *)volume)->userTree; } - /* - * Find the object to add the name. - */ + /* + * Find the object to add the name. + */ parms.xaction = NULL; parms.volume = volume; parms.userTreeBeast = userTreeBeast; @@ -3598,7 +3597,7 @@ STATUS ZFSVOL_VOL_GetObjectName( ForceSetErrno(genMsg, zERR_FULL_NAME_NOT_FOUND); return zFAILURE; } - + /* read the root node */ READBLK_IO_MSG(iomsg, userTreeBeast, userTreeBeast->zfsBtree.p.btRoot, CACHE_READ); @@ -3611,7 +3610,7 @@ STATUS ZFSVOL_VOL_GetObjectName( return zFAILURE; } UBT_VALIDATE_NODE((UserTreeNode_s *)parms.child->pBuf.data); - + /* decend the tree to the leaf */ if (UBT_getLeaf(genMsg, (ZfsVolume_s *)volume, &parms, CACHE_UPDATE) != zOK) { @@ -3631,8 +3630,8 @@ STATUS ZFSVOL_VOL_GetObjectName( } /* - * If there is a name then change it. If there is no name then add one. - */ + * If there is a name then change it. If there is no name then add one. + */ entry = &node->ULEAF(index); @@ -3654,7 +3653,7 @@ STATUS ZFSVOL_VOL_GetObjectName( } if (numberOfTimesNotFound) { - *numberOfTimesNotFound = + *numberOfTimesNotFound = nameNode->entry[entry->infoIndex].numberOfTimesNotFound; } CACHE_RELEASE(nameBuffer); @@ -3667,7 +3666,7 @@ STATUS ZFSVOL_VOL_GetObjectName( } CACHE_RELEASE(parms.child); return zOK; -} +} /**************************************************************************** * @@ -3687,7 +3686,7 @@ void UBT_logNewNameRecord ( ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + sizeof(UBTAddNameRecord_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_UTREE_ADD_NAME_RECORD, xaction, logBuffer, 1, + ZLOG_INIT_LOG_RECORD(XFUNC_UTREE_ADD_NAME_RECORD, xaction, logBuffer, 1, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, record->lsn, buffer, xaction, 0); @@ -3859,7 +3858,7 @@ STATUS UBT_checkAvailList ( ObjectNameNode_s *nameNode; ZfsXaction_s *localXaction; IoMsg_s iomsg; - + if (userTreeBeast->zfsBtree.p.btFree != INVALID_BLK && userTreeBeast->zfsBtree.p.btFree != 0) { @@ -3887,7 +3886,7 @@ STATUS UBT_checkAvailList ( localXaction = BeginXLocal(volume, BXL_DEFAULT); userTreeBeast->zfsBtree.p.btFree = 0; /* force the beast out */ - COMN_MARK_BEAST_XLOCAL(&userTreeBeast->ZFSUSERTREEroot, + COMN_MARK_BEAST_XLOCAL(&userTreeBeast->ZFSUSERTREEroot, &localXaction->xaction); if (COMN_ForceBeastWrite(genMsg, &userTreeBeast->ZFSUSERTREEroot, &localXaction->xaction)) @@ -3904,7 +3903,7 @@ STATUS UBT_checkAvailList ( userTreeBeast->zfsBtree.p.btFree == 0) { /* We need to get a new name record to insert into */ localXaction = BeginXLocal(volume, BXL_DEFAULT); - + /* get a new name block */ XALLOCBLK_IO_MSG(iomsg, userTreeBeast, localXaction, CACHE_UPDATE); nameBuffer = ZFS_AllocPoolBlk(genMsg, &iomsg); @@ -3915,14 +3914,14 @@ STATUS UBT_checkAvailList ( goto error; } userTreeBeast->zfsBtree.p.btFree = nameBuffer->volBlk; - UBT_initNameRecord((ObjectNameNode_s *)nameBuffer->pBuf.data, + UBT_initNameRecord((ObjectNameNode_s *)nameBuffer->pBuf.data, &userTreeBeast->ZFSUSERTREEroot.ROOTinternalID); - - UBT_logNewNameRecord(localXaction, nameBuffer, + + UBT_logNewNameRecord(localXaction, nameBuffer, &userTreeBeast->ZFSUSERTREEroot.ROOTinternalID); /* force the beast out */ - COMN_MARK_BEAST_XLOCAL(&userTreeBeast->ZFSUSERTREEroot, + COMN_MARK_BEAST_XLOCAL(&userTreeBeast->ZFSUSERTREEroot, &localXaction->xaction); if (COMN_ForceBeastWrite(genMsg, &userTreeBeast->ZFSUSERTREEroot, &localXaction->xaction)) @@ -3979,9 +3978,9 @@ STATUS ZFSVOL_VOL_InsertObjectName( return zFAILURE; } - /* - * Find the object to add the name. - */ + /* + * Find the object to add the name. + */ parms.xaction = NULL; parms.volume = volume; parms.userTreeBeast = userTreeBeast; @@ -4003,7 +4002,7 @@ STATUS ZFSVOL_VOL_InsertObjectName( SetErrno(genMsg, zERR_NO_SUCH_USER); goto error; } - + /* read the root node */ READBLK_IO_MSG(iomsg, userTreeBeast, userTreeBeast->zfsBtree.p.btRoot, CACHE_UPDATE); @@ -4016,7 +4015,7 @@ STATUS ZFSVOL_VOL_InsertObjectName( goto error; } UBT_VALIDATE_NODE((UserTreeNode_s *)parms.child->pBuf.data); - + /* decend the tree to the leaf */ if (UBT_getLeaf(genMsg, (ZfsVolume_s *)volume, &parms, CACHE_UPDATE) != zOK) { @@ -4037,8 +4036,8 @@ STATUS ZFSVOL_VOL_InsertObjectName( } /* - * If there is a name then change it. If there is no name then add one. - */ + * If there is a name then change it. If there is no name then add one. + */ entry = &node->ULEAF(index); @@ -4068,7 +4067,7 @@ STATUS ZFSVOL_VOL_InsertObjectName( userTreeBeast->zfsBtree.p.btFree != 0); /* Read the name record from the avail list */ - READBLK_IO_MSG(iomsg, userTreeBeast, userTreeBeast->zfsBtree.p.btFree, + READBLK_IO_MSG(iomsg, userTreeBeast, userTreeBeast->zfsBtree.p.btFree, CACHE_UPDATE); nameBuffer = UBT_ReadPoolBlk(genMsg, &iomsg); if (nameBuffer == NULL) @@ -4100,7 +4099,7 @@ STATUS ZFSVOL_VOL_InsertObjectName( nameNode->entry[i].timeNotFound = 0; nameNode->entry[i].numberOfTimesNotFound = 0; nameNode->entry[i].state |= UBT_NAME_ENTRY_USED; - UBT_logAddName((ZfsXaction_s *)xaction, parms.child, nameBuffer, + UBT_logAddName((ZfsXaction_s *)xaction, parms.child, nameBuffer, entry->infoBlock, entry->infoIndex, index, name, &userTreeBeast->ZFSUSERTREEroot.ROOTinternalID); CACHE_DIRTY_RELEASE(nameBuffer); @@ -4142,9 +4141,9 @@ STATUS ZFSVOL_VOL_ModifyObjectName( } Stack_s; STACK_ALLOC(); - /* - * Find the object - */ + /* + * Find the object + */ parms.xaction = NULL; parms.volume = volume; parms.userTreeBeast = userTreeBeast; @@ -4159,7 +4158,7 @@ STATUS ZFSVOL_VOL_ModifyObjectName( STACK_FREE(); return zFAILURE; } - + /* read the root node */ READBLK_IO_MSG(aStack->iomsg, userTreeBeast, userTreeBeast->zfsBtree.p.btRoot, CACHE_UPDATE); @@ -4173,7 +4172,7 @@ STATUS ZFSVOL_VOL_ModifyObjectName( return zFAILURE; } UBT_VALIDATE_NODE((UserTreeNode_s *)parms.child->pBuf.data); - + /* decend the tree to the leaf */ if (UBT_getLeaf(genMsg, (ZfsVolume_s *)volume, &parms, CACHE_UPDATE) != zOK) { @@ -4195,8 +4194,8 @@ STATUS ZFSVOL_VOL_ModifyObjectName( } /* - * Update the name entry - */ + * Update the name entry + */ entry = &node->ULEAF(index); @@ -4235,7 +4234,7 @@ STATUS ZFSVOL_VOL_ModifyObjectName( STACK_FREE(); return zOK; -} +} /*---------------------------------------------------------------------------*/ /**************************************************************************** @@ -4495,13 +4494,13 @@ STATUS UBT_recoveryBalance( { /* fix up the parent */ if (action == X_REDO) { - node->UBRANCH(logRecord->u.balance.indexForParent).userID = + node->UBRANCH(logRecord->u.balance.indexForParent).userID = logRecord->u.balance.userIDForParent; } else { - node->UBRANCH(logRecord->u.balance.indexForParent).userID = - logRecord->u.balance.oldUserID; + node->UBRANCH(logRecord->u.balance.indexForParent).userID = + logRecord->u.balance.oldUserID; } ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); UBT_VALIDATE_NODE(node); @@ -4533,7 +4532,7 @@ STATUS UBT_recoveryBalance( if (UBT_IS_LEAF(node)) { /* leaf */ numToMove = logRecord->u.balance.numToMove; - if ((numToMove > 0) && + if ((numToMove > 0) && LB_GUIDCompare( &((UserLeafEntry_s *)&logRecord->u.balance.data[0])->userID, &node->ULEAF(0).userID) == 0) @@ -4546,7 +4545,7 @@ STATUS UBT_recoveryBalance( else { /* branch */ numToMove = logRecord->u.balance.numToMove; - if ((numToMove > 0) && + if ((numToMove > 0) && LB_GUIDCompare( &((UserBranchEntry_s *)&logRecord->u.balance.data[0])->userID, &node->UBRANCH(0).userID) == 0) @@ -4698,8 +4697,8 @@ STATUS UBT_recoveryJoin( --(node->numRecs); i = logRecord->u.split.indexForParent; memmove( &node->UBRANCH(i), /* Destination */ - &node->UBRANCH(i + 1), /* Source */ - (node->numRecs - i) * sizeof(UserBranchEntry_s)); + &node->UBRANCH(i + 1), /* Source */ + (node->numRecs - i) * sizeof(UserBranchEntry_s)); ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); UBT_VALIDATE_NODE(node); CACHE_DIRTY_RELEASE(buffer); @@ -5176,7 +5175,7 @@ STATUS UBT_recoveryAddName( logRecord->u.addName.name); nameNode->entry[logRecord->u.addName.nameIndex].timeNotFound = 0; nameNode->entry[logRecord->u.addName.nameIndex].numberOfTimesNotFound = 0; - nameNode->entry[logRecord->u.addName.nameIndex].state |= + nameNode->entry[logRecord->u.addName.nameIndex].state |= UBT_NAME_ENTRY_USED; ZLOG_SET_LSN(logBuffer, nameNode->lsn, poolBlks[1], action); @@ -5227,7 +5226,7 @@ STATUS UBT_recoveryModifyName( zASSERT(logRecord->u.modifyName.index <= UBT_MAX_NAME_ENTRIES); node = (ObjectNameNode_s *)buffer->pBuf.data; - unicpy(node->entry[logRecord->u.modifyName.index].name, + unicpy(node->entry[logRecord->u.modifyName.index].name, logRecord->u.modifyName.newName); ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); @@ -5277,7 +5276,7 @@ STATUS UBT_recoveryModifyNameEntry( zASSERT(logRecord->u.modifyNameEntry.index <= UBT_MAX_NAME_ENTRIES); node = (ObjectNameNode_s *)buffer->pBuf.data; - node->entry[logRecord->u.modifyNameEntry.index] = + node->entry[logRecord->u.modifyNameEntry.index] = logRecord->u.modifyNameEntry.newEntry; ZLOG_SET_LSN(logBuffer, node->lsn, poolBlks[0], action); @@ -5308,8 +5307,8 @@ STATUS UBT_recoveryInsertEntryLogical( } logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, - &logRecord->u.entry.internalID, pool); + zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, + &logRecord->u.entry.internalID, pool); if (zfsVol == NULL) { return zFAILURE; @@ -5371,14 +5370,14 @@ STATUS UBT_recoveryDeleteEntryLogical( } logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, &logRecord->u.entry.internalID, + zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, &logRecord->u.entry.internalID, pool); if (zfsVol == NULL) { return zFAILURE; } - status = ZFSVOL_VOL_RemoveUser(genMsg, &zfsVol->vol, + status = ZFSVOL_VOL_RemoveUser(genMsg, &zfsVol->vol, &logRecord->u.entry.userID); COMN_Release(&zfsVol); @@ -5409,8 +5408,8 @@ STATUS UBT_recoveryModifyEntryLogical( } logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, - &logRecord->u.modify.internalID, pool); + zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, + &logRecord->u.modify.internalID, pool); if (zfsVol == NULL) { return zFAILURE; @@ -5462,7 +5461,7 @@ STATUS UBT_recoveryDeleteNameLogical( } logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, + zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, &logRecord->u.addName.internalID, pool); if (zfsVol == NULL) { @@ -5471,7 +5470,7 @@ STATUS UBT_recoveryDeleteNameLogical( xaction = BeginXLocal(&zfsVol->vol, BXL_LOGICAL_UNDO); - status = UBT_DeleteObjectName(genMsg, &zfsVol->vol, + status = UBT_DeleteObjectName(genMsg, &zfsVol->vol, &xaction->xaction, &logRecord->u.addName.objectID); SET_LUNDO_LSN(xaction, logBuffer, status); @@ -5502,8 +5501,8 @@ STATUS UBT_recoveryModifyNameLogical( } logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, - &logRecord->u.modify.internalID, pool); + zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, + &logRecord->u.modify.internalID, pool); if (zfsVol == NULL) { return zFAILURE; @@ -5511,7 +5510,7 @@ STATUS UBT_recoveryModifyNameLogical( xaction = BeginXLocal(&zfsVol->vol, BXL_LOGICAL_UNDO); - status = ZFSVOL_VOL_InsertObjectName(genMsg, &zfsVol->vol, + status = ZFSVOL_VOL_InsertObjectName(genMsg, &zfsVol->vol, &xaction->xaction, &logRecord->u.modifyName.objectID, logRecord->u.modifyName.oldName); @@ -5543,8 +5542,8 @@ STATUS UBT_recoveryModifyNameEntryLogical( } logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, - &logRecord->u.modifyNameEntry.internalID, pool); + zfsVol = ZLSS_VolumeIDLookupRecovery(genMsg, + &logRecord->u.modifyNameEntry.internalID, pool); if (zfsVol == NULL) { return zFAILURE; @@ -5552,7 +5551,7 @@ STATUS UBT_recoveryModifyNameEntryLogical( xaction = BeginXLocal(&zfsVol->vol, BXL_LOGICAL_UNDO); - status = ZFSVOL_VOL_ModifyObjectName(genMsg, &zfsVol->vol, + status = ZFSVOL_VOL_ModifyObjectName(genMsg, &zfsVol->vol, &xaction->xaction, &logRecord->u.modifyNameEntry.objectID, logRecord->u.modifyNameEntry.oldEntry.name, logRecord->u.modifyNameEntry.oldEntry.timeNotFound, @@ -5749,9 +5748,9 @@ STATUS UBT_recoveryRemoveNameRecord( if (ZLOG_VALID_BLOCK(poolBlks[1])) { - /* - * Reset the used state in the indicated entry. - */ + /* + * Reset the used state in the indicated entry. + */ READBLK_IO_MSG(iomsg, pool, poolBlks[1].blkNum, CACHE_UPDATE) if ((nameBuffer = UBT_ReadPoolBlk(genMsg, &iomsg)) == NULL) { @@ -5765,7 +5764,7 @@ STATUS UBT_recoveryRemoveNameRecord( return zOK; } - nameNode->entry[logRecord->u.removeNameRecord.nameIndex].state &= + nameNode->entry[logRecord->u.removeNameRecord.nameIndex].state &= ~UBT_NAME_ENTRY_USED; ZLOG_SET_LSN(logBuffer, nameNode->lsn, poolBlks[1], action); @@ -5823,9 +5822,9 @@ STATUS UBT_recoveryInsertNameRecord( if (ZLOG_VALID_BLOCK(poolBlks[1])) { - /* - * Set the used state in the indicated entry. - */ + /* + * Set the used state in the indicated entry. + */ READBLK_IO_MSG(iomsg, pool, poolBlks[1].blkNum, CACHE_UPDATE) if ((nameBuffer = UBT_ReadPoolBlk(genMsg, &iomsg)) == NULL) { @@ -5842,7 +5841,7 @@ STATUS UBT_recoveryInsertNameRecord( logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); nameNode->entry[logRecord->u.removeNameRecord.nameIndex].timeNotFound = 0; nameNode->entry[logRecord->u.removeNameRecord.nameIndex].numberOfTimesNotFound = 0; - nameNode->entry[logRecord->u.removeNameRecord.nameIndex].state |= + nameNode->entry[logRecord->u.removeNameRecord.nameIndex].state |= UBT_NAME_ENTRY_USED; ZLOG_SET_LSN(logBuffer, nameNode->lsn, poolBlks[1], action); CACHE_DIRTY_RELEASE(nameBuffer); @@ -5922,9 +5921,9 @@ STATUS UBT_recoveryDeleteAll( } else { - /* - * Reset the used state in the indicated entry. - */ + /* + * Reset the used state in the indicated entry. + */ READBLK_IO_MSG(iomsg, pool, poolBlks[1].blkNum, CACHE_UPDATE) if ((nameBuffer = UBT_ReadPoolBlk(genMsg, &iomsg)) == NULL) { @@ -5940,7 +5939,7 @@ STATUS UBT_recoveryDeleteAll( logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); - nameNode->entry[logRecord->u.remove.nameIndex].state &= + nameNode->entry[logRecord->u.remove.nameIndex].state &= ~UBT_NAME_ENTRY_USED; ZLOG_SET_LSN(logBuffer, nameNode->lsn, poolBlks[1], action); @@ -6007,11 +6006,11 @@ STATUS UBT_recoveryAddAll( node->ULEAF(i).infoBlock = poolBlks[1].blkNum; if (logRecord->u.remove.nameIndex == -1) { - node->ULEAF(i).infoIndex = 0; + node->ULEAF(i).infoIndex = 0; } else { - node->ULEAF(i).infoIndex = logRecord->u.remove.nameIndex; + node->ULEAF(i).infoIndex = logRecord->u.remove.nameIndex; } } else @@ -6060,7 +6059,7 @@ STATUS UBT_recoveryAddAll( index = logRecord->u.remove.nameIndex; } - nameNode->entry[index].state |= + nameNode->entry[index].state |= UBT_NAME_ENTRY_USED; nameNode->entry[index].timeNotFound = 0; nameNode->entry[index].numberOfTimesNotFound = 0; @@ -6143,9 +6142,9 @@ STATUS UBT_recoveryDeleteName( } else { - /* - * Reset the used state in the indicated entry. - */ + /* + * Reset the used state in the indicated entry. + */ READBLK_IO_MSG(iomsg, pool, poolBlks[1].blkNum, CACHE_UPDATE) if ((nameBuffer = UBT_ReadPoolBlk(genMsg, &iomsg)) == NULL) { @@ -6159,7 +6158,7 @@ STATUS UBT_recoveryDeleteName( return zOK; } - nameNode->entry[logRecord->u.removeName.nameIndex].state &= + nameNode->entry[logRecord->u.removeName.nameIndex].state &= ~UBT_NAME_ENTRY_USED; ZLOG_SET_LSN(logBuffer, nameNode->lsn, poolBlks[1], action); @@ -6218,11 +6217,11 @@ STATUS UBT_recoveryAddOnlyName( node->ULEAF(i).infoBlock = poolBlks[1].blkNum; if (logRecord->u.removeName.nameIndex == -1) { - node->ULEAF(i).infoIndex = 0; + node->ULEAF(i).infoIndex = 0; } else { - node->ULEAF(i).infoIndex = logRecord->u.removeName.nameIndex; + node->ULEAF(i).infoIndex = logRecord->u.removeName.nameIndex; } } else @@ -6272,7 +6271,7 @@ STATUS UBT_recoveryAddOnlyName( index = logRecord->u.removeName.nameIndex; } - nameNode->entry[index].state |= + nameNode->entry[index].state |= UBT_NAME_ENTRY_USED; nameNode->entry[index].timeNotFound = 0; nameNode->entry[index].numberOfTimesNotFound = 0; @@ -6424,8 +6423,8 @@ STATUS UBT_OLD_ResetAllUsers( zASSERT(!(volume->VOLenabledAttributes & zATTR_READONLY)); /* - * Get an exclusive latch on the User Tree Beast - */ + * Get an exclusive latch on the User Tree Beast + */ X_LATCH(&userTreeBeast->ZFSUSERTREEbeastLatch); if (userTreeBeast->zfsBtree.p.btRoot == INVALID_BLK) @@ -6451,9 +6450,9 @@ STATUS UBT_OLD_ResetAllUsers( node = (OldUserTreeNode_s *)buffer->pBuf.data; if (UBT_IS_LEAF(node)) { /* - * If it is a leaf then set up so on the next loop it will be - * deleted. - */ + * If it is a leaf then set up so on the next loop it will be + * deleted. + */ zASSERT(node->magic == UBT_LEAF_MAGIC); cacheReleaseToss(buffer); readALeaf = TRUE; @@ -6469,9 +6468,9 @@ STATUS UBT_OLD_ResetAllUsers( } else { /* - * it's a branch -- push on the stack and move on to its first - * child - */ + * it's a branch -- push on the stack and move on to its first + * child + */ readALeaf = FALSE; zASSERT(node->magic == UBT_BRANCH_MAGIC); @@ -6503,12 +6502,12 @@ STATUS UBT_OLD_ResetAllUsers( node = (OldUserTreeNode_s *)buffer->pBuf.data; /* - * If we have read all of the child records we can now delete - * them. - * - * If one of the children was a leaf they all will be so there - * is no reason to read them all. Just delete them. - */ + * If we have read all of the child records we can now delete + * them. + * + * If one of the children was a leaf they all will be so there + * is no reason to read them all. Just delete them. + */ aStack->parentStack[stkPtr].entry++; if ((aStack->parentStack[stkPtr].entry >= node->numRecs) || readALeaf) { @@ -6519,15 +6518,15 @@ STATUS UBT_OLD_ResetAllUsers( { ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2)); - ZLOG_INIT_LOG_RECORD(XFUNC_USERTREE_REMOVE, xaction, + ZLOG_INIT_LOG_RECORD(XFUNC_USERTREE_REMOVE, xaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], buffer->volBlk, node->lsn, buffer, xaction, 0); node->lsn = logBuffer->ZXR_Lsn; node->numRecs--; - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], - node->UBRANCH(node->numRecs).child, 0, NULL, + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], + node->UBRANCH(node->numRecs).child, 0, NULL, xaction, 0); ZLOG_DELETE_BLOCK(xaction, poolBlks[1]); @@ -6561,20 +6560,20 @@ STATUS UBT_OLD_ResetAllUsers( ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2)); - ZLOG_INIT_LOG_RECORD(XFUNC_USERTREE_REMOVE, xaction, logBuffer, 2, + ZLOG_INIT_LOG_RECORD(XFUNC_USERTREE_REMOVE, xaction, logBuffer, 2, poolBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(poolBlks[0], 0, 0, NULL, xaction, 0); - ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], userTreeBeast->zfsBtree.p.btRoot, 0, + ZLOG_ASSIGN_BLOCK_INFO(poolBlks[1], userTreeBeast->zfsBtree.p.btRoot, 0, NULL, xaction, 0); ZLOG_DELETE_BLOCK(xaction, poolBlks[1]); ZLOG_ReleaseRecord(xaction); /* - * Fix up the user tree beast to show no tree - */ + * Fix up the user tree beast to show no tree + */ userTreeBeast->zfsBtree.p.btRoot = INVALID_BLK; COMN_MARK_BEAST_XLOCAL(&userTreeBeast->ZFSUSERTREEroot, &xaction->xaction); @@ -6592,3 +6591,4 @@ exit: STACK_FREE(); return status; } + diff --git a/src/nwnss/zlss/userTree.h b/src/nwnss/zlss/userTree.h index 16e392b..d994929 100644 --- a/src/nwnss/zlss/userTree.h +++ b/src/nwnss/zlss/userTree.h @@ -46,7 +46,7 @@ #ifndef _ZFS_H_ #include "zfs.h" #endif - + #ifndef DCONST_H #include "dconst.h" #endif @@ -87,19 +87,19 @@ #define UBT_MIN_LEAF_ENTRIES (UBT_MAX_LEAF_ENTRIES / 2) #define UBT_IS_MAX_ENTRIES(_node, _parms) \ - (UBT_IS_LEAF(_node) \ - ? ((_node)->numRecs >= UBT_MAX_LEAF_ENTRIES) \ - : ((_node)->numRecs >= UBT_MAX_BRANCH_ENTRIES)) + (UBT_IS_LEAF(_node) \ + ? ((_node)->numRecs >= UBT_MAX_LEAF_ENTRIES) \ + : ((_node)->numRecs >= UBT_MAX_BRANCH_ENTRIES)) #define UBT_IS_MIN_ENTRIES(_node) \ - (UBT_IS_LEAF(_node) \ - ? ((_node)->numRecs <= UBT_MIN_LEAF_ENTRIES) \ - : ((_node)->numRecs <= UBT_MIN_BRANCH_ENTRIES)) + (UBT_IS_LEAF(_node) \ + ? ((_node)->numRecs <= UBT_MIN_LEAF_ENTRIES) \ + : ((_node)->numRecs <= UBT_MIN_BRANCH_ENTRIES)) #define UBT_IS_LESSTHAN_MAX(_node, _sibling) \ - (UBT_IS_LEAF(_node) \ - ? (((_node)->numRecs + (_sibling)->numRecs) < UBT_MAX_LEAF_ENTRIES) \ - : (((_node)->numRecs + (_sibling)->numRecs) < UBT_MAX_BRANCH_ENTRIES)) + (UBT_IS_LEAF(_node) \ + ? (((_node)->numRecs + (_sibling)->numRecs) < UBT_MAX_LEAF_ENTRIES) \ + : (((_node)->numRecs + (_sibling)->numRecs) < UBT_MAX_BRANCH_ENTRIES)) #define UBRANCH(_entry) n.branch.entry[(_entry)] #define ULEAF(_entry) n.leaf.entry[(_entry)] @@ -111,17 +111,17 @@ */ typedef struct UserTreeParms_s { - UserID_t userID; /* the user to be used */ - Volume_s *volume; - Blknum_t readBlkNum; /* Next block to be read */ - NINT index; /* Where last record was found in parent*/ - SQUAD value; /* The value being set or adjusted */ - NINT type; /* The type of data contained in the value -- see defines below */ - Buffer_s *parent; /* Parent buffer */ - Buffer_s *child; /* Child buffer */ - Buffer_s *sibling; /* Sibling buffer */ - struct ZfsXaction_s *xaction; /* Transaction being used */ - struct ZfsUserTreeBeast_s *userTreeBeast; /* The pointer to the b-tree beast */ + UserID_t userID; /* the user to be used */ + Volume_s *volume; + Blknum_t readBlkNum; /* Next block to be read */ + NINT index; /* Where last record was found in parent*/ + SQUAD value; /* The value being set or adjusted */ + NINT type; /* The type of data contained in the value -- see defines below */ + Buffer_s *parent; /* Parent buffer */ + Buffer_s *child; /* Child buffer */ + Buffer_s *sibling; /* Sibling buffer */ + struct ZfsXaction_s *xaction; /* Transaction being used */ + struct ZfsUserTreeBeast_s *userTreeBeast; /* The pointer to the b-tree beast */ } UserTreeParms_s; /* @@ -140,52 +140,52 @@ typedef struct UserTreeParms_s typedef struct OldUserBranchEntry_s { - LONG userID; - Blknum_t child; + LONG userID; + Blknum_t child; } NSS_MEDIA_STRUCTURE(OldUserBranchEntry_s,child) OldUserBranchEntry_s; typedef struct OldUserBranch_s { - OldUserBranchEntry_s entry[OLD_UBT_MAX_BRANCH_ENTRIES]; + OldUserBranchEntry_s entry[OLD_UBT_MAX_BRANCH_ENTRIES]; } NSS_MEDIA_STRUCTURE(OldUserBranch_s,entry[OLD_UBT_MAX_BRANCH_ENTRIES]) OldUserBranch_s; typedef struct OldUserLeafEntry_s { - LONG userID; - SQUAD usedAmount; - SQUAD restrictionAmount; + LONG userID; + SQUAD usedAmount; + SQUAD restrictionAmount; } NSS_MEDIA_STRUCTURE(OldUserLeafEntry_s,restrictionAmount) OldUserLeafEntry_s; typedef struct OldUserLeaf_s { - /* - * If the size of the header portion changes then change - * OLD_UBT_MAX_LEAF_ENTRIES. - */ - Blknum_t nextLeaf; /* link to the next leaf in the tree */ - OldUserLeafEntry_s entry[OLD_UBT_MAX_LEAF_ENTRIES]; + /* + * If the size of the header portion changes then change + * OLD_UBT_MAX_LEAF_ENTRIES. + */ + Blknum_t nextLeaf; /* link to the next leaf in the tree */ + OldUserLeafEntry_s entry[OLD_UBT_MAX_LEAF_ENTRIES]; } NSS_MEDIA_STRUCTURE(OldUserLeaf_s,entry[OLD_UBT_MAX_LEAF_ENTRIES]) OldUserLeaf_s; typedef struct OldUserTreeNode_s { - /* - * If the size of the header portion changes then change - * OLD_UBT_MAX_BRANCH_ENTRIES and OLD_UBT_MAX_LEAF_ENTRIES. - */ - LONG magic; - WORD state; - WORD numRecs; - Lsn_t lsn; - GUID_t utn_internalID; /* Must be at OFFSET 16 - unique internal ID (used - * by scanning repair). utn -> User Tree Node. - */ - union - { - OldUserBranch_s branch; - OldUserLeaf_s leaf; - } NSS_MEDIA_UNION(NamelessUnion,leaf.entry[OLD_UBT_MAX_LEAF_ENTRIES]) n; + /* + * If the size of the header portion changes then change + * OLD_UBT_MAX_BRANCH_ENTRIES and OLD_UBT_MAX_LEAF_ENTRIES. + */ + LONG magic; + WORD state; + WORD numRecs; + Lsn_t lsn; + GUID_t utn_internalID; /* Must be at OFFSET 16 - unique internal ID (used + * by scanning repair). utn -> User Tree Node. + */ + union + { + OldUserBranch_s branch; + OldUserLeaf_s leaf; + } NSS_MEDIA_UNION(NamelessUnion,leaf.entry[OLD_UBT_MAX_LEAF_ENTRIES]) n; } NSS_MEDIA_STRUCTURE(OldUserTreeNode_s,n.leaf.entry[OLD_UBT_MAX_LEAF_ENTRIES]) OldUserTreeNode_s; /* @@ -194,91 +194,91 @@ typedef struct OldUserTreeNode_s typedef struct UserBranchEntry_s { - UserID_t userID; - Blknum_t child; + UserID_t userID; + Blknum_t child; } NSS_MEDIA_STRUCTURE(UserBranchEntry_s,child) UserBranchEntry_s; typedef struct UserBranch_s { - UserBranchEntry_s entry[UBT_MAX_BRANCH_ENTRIES]; + UserBranchEntry_s entry[UBT_MAX_BRANCH_ENTRIES]; } NSS_MEDIA_STRUCTURE(UserBranch_s,entry[UBT_MAX_BRANCH_ENTRIES]) UserBranch_s; typedef struct UserLeafEntry_s { - UserID_t userID; - SQUAD usedAmount; - SQUAD restrictionAmount; - Blknum_t infoBlock; - WORD infoIndex; - WORD reserved; + UserID_t userID; + SQUAD usedAmount; + SQUAD restrictionAmount; + Blknum_t infoBlock; + WORD infoIndex; + WORD reserved; } NSS_MEDIA_STRUCTURE(UserLeafEntry_s,reserved) UserLeafEntry_s; typedef struct UserLeaf_s { - /* - * If the size of the header portion changes then change - * UBT_MAX_LEAF_ENTRIES. - */ - Blknum_t nextLeaf; /* link to the next leaf in the tree */ - UserLeafEntry_s entry[UBT_MAX_LEAF_ENTRIES]; + /* + * If the size of the header portion changes then change + * UBT_MAX_LEAF_ENTRIES. + */ + Blknum_t nextLeaf; /* link to the next leaf in the tree */ + UserLeafEntry_s entry[UBT_MAX_LEAF_ENTRIES]; } NSS_MEDIA_STRUCTURE(UserLeaf_s,entry[UBT_MAX_LEAF_ENTRIES]) UserLeaf_s; typedef struct UserTreeNode_s { - /* - * If the size of the header portion changes then change - * UBT_MAX_BRANCH_ENTRIES and UBT_MAX_LEAF_ENTRIES. - */ - LONG magic; - WORD state; - WORD numRecs; - Lsn_t lsn; - GUID_t utn_internalID; /* Must be at OFFSET 16 - unique internal ID (used - * by scanning repair). utn -> User Tree Node. - */ - union - { - UserBranch_s branch; - UserLeaf_s leaf; - } NSS_MEDIA_UNION(NamelessUnion,leaf.entry[UBT_MAX_LEAF_ENTRIES]) n; + /* + * If the size of the header portion changes then change + * UBT_MAX_BRANCH_ENTRIES and UBT_MAX_LEAF_ENTRIES. + */ + LONG magic; + WORD state; + WORD numRecs; + Lsn_t lsn; + GUID_t utn_internalID; /* Must be at OFFSET 16 - unique internal ID (used + * by scanning repair). utn -> User Tree Node. + */ + union + { + UserBranch_s branch; + UserLeaf_s leaf; + } NSS_MEDIA_UNION(NamelessUnion,leaf.entry[UBT_MAX_LEAF_ENTRIES]) n; } NSS_MEDIA_STRUCTURE(UserTreeNode_s,n.leaf.entry[UBT_MAX_LEAF_ENTRIES]) UserTreeNode_s; typedef struct ObjectNameEntry_s { - /* - * The size of one entry is 676 bytes - */ - LONG state; - unicode_t name[MAX_DN_CHARS]; - Time_t timeNotFound; /* Used by checker */ - LONG numberOfTimesNotFound; /* Used by checker */ - BYTE reserved[152]; + /* + * The size of one entry is 676 bytes + */ + LONG state; + unicode_t name[MAX_DN_CHARS]; + Time_t timeNotFound; /* Used by checker */ + LONG numberOfTimesNotFound; /* Used by checker */ + BYTE reserved[152]; } NSS_MEDIA_STRUCTURE(ObjectNameEntry_s,reserved[152]) ObjectNameEntry_s; #define UBT_NAME_ENTRY_USED 0x00000001 typedef struct ObjectNameNode_s { - /* - * If the size of the header portion changes then change - * UBT_MAX_NAME_ENTRIES - */ - LONG magic; - LONG reserved1; - Lsn_t lsn; - GUID_t utn_internalID; /* Must be at OFFSET 16 - unique internal ID (used - * by scanning repair). utn -> User Tree Node. - */ - LONG reserved2; /* This is an unused field */ - GUID_t verifyGuid; /* Space for verify to mark this block as already - * in the bitmap. - */ - LONG verifyCount; /* Space for verify to count use of the block - */ - LONG extraSpace[2]; /* bring the total to 64 bytes */ - ObjectNameEntry_s entry[UBT_MAX_NAME_ENTRIES]; + /* + * If the size of the header portion changes then change + * UBT_MAX_NAME_ENTRIES + */ + LONG magic; + LONG reserved1; + Lsn_t lsn; + GUID_t utn_internalID; /* Must be at OFFSET 16 - unique internal ID (used + * by scanning repair). utn -> User Tree Node. + */ + LONG reserved2; /* This is an unused field */ + GUID_t verifyGuid; /* Space for verify to mark this block as already + * in the bitmap. + */ + LONG verifyCount; /* Space for verify to count use of the block + */ + LONG extraSpace[2]; /* bring the total to 64 bytes */ + ObjectNameEntry_s entry[UBT_MAX_NAME_ENTRIES]; } NSS_MEDIA_STRUCTURE(ObjectNameNode_s,entry[UBT_MAX_NAME_ENTRIES]) ObjectNameNode_s; @@ -288,117 +288,117 @@ typedef struct ObjectNameNode_s typedef struct UBTEntry_s { - UserID_t userID; /* User to be modified */ - SQUAD usedAmount; /* Value for used amount */ - SQUAD restrictionAmount; /* Value for restriction amount */ - GUID_t internalID; + UserID_t userID; /* User to be modified */ + SQUAD usedAmount; /* Value for used amount */ + SQUAD restrictionAmount; /* Value for restriction amount */ + GUID_t internalID; } NSS_MEDIA_STRUCTURE(UBTEntry_s,internalID) UBTEntry_s; typedef struct UBTModify_s { - UserID_t userID; /* User to be modified */ - SQUAD oldValue; /* Value before change */ - SQUAD value; /* Value for change */ - LONG type; /* type of value ("used amount" or "restriction") */ - GUID_t internalID; + UserID_t userID; /* User to be modified */ + SQUAD oldValue; /* Value before change */ + SQUAD value; /* Value for change */ + LONG type; /* type of value ("used amount" or "restriction") */ + GUID_t internalID; } NSS_MEDIA_STRUCTURE(UBTModify_s,internalID) UBTModify_s; typedef struct UBTSplit_s { - GUID_t internalID; - UserID_t userIDForParent; /* zid to insert in the parent */ - Blknum_t leafLink; /* link to the next leaf in the tree */ - Blknum_t blockForParent; /* block number to insert in the parent */ - LONG indexForParent; /* index where zid is inserted in the parent */ - WORD numToMove; /* number of entries logged */ - LONG totalLength; /* length of tree information being moved */ - WORD nodeType; /* whether the new node is a branch or a leaf */ - BYTE data[1]; /* data to move */ + GUID_t internalID; + UserID_t userIDForParent; /* zid to insert in the parent */ + Blknum_t leafLink; /* link to the next leaf in the tree */ + Blknum_t blockForParent; /* block number to insert in the parent */ + LONG indexForParent; /* index where zid is inserted in the parent */ + WORD numToMove; /* number of entries logged */ + LONG totalLength; /* length of tree information being moved */ + WORD nodeType; /* whether the new node is a branch or a leaf */ + BYTE data[1]; /* data to move */ } NSS_MEDIA_STRUCTURE(UBTSplit_s,data[1]) UBTSplit_s; typedef struct UBTOverflow_s { - LONG totalLength; /* length of tree information being moved */ - WORD numToMove; /* number of entries logged */ - WORD nodeType; /* whether the new node is a branch or a leaf */ - BYTE data[1]; /* data to move */ + LONG totalLength; /* length of tree information being moved */ + WORD numToMove; /* number of entries logged */ + WORD nodeType; /* whether the new node is a branch or a leaf */ + BYTE data[1]; /* data to move */ } NSS_MEDIA_STRUCTURE(UBTOverflow_s,data[1]) UBTOverflow_s; typedef struct UBTGrow_s { - GUID_t internalID; - Blknum_t blockForParent; /* block number to insert in the parent */ + GUID_t internalID; + Blknum_t blockForParent; /* block number to insert in the parent */ } NSS_MEDIA_STRUCTURE(UBTGrow_s,blockForParent) UBTGrow_s; typedef struct UBTBalance_s { - UserID_t userIDForParent; /* user to insert in the parent */ - UserID_t oldUserID; /* previous user in the parent */ - LONG indexForParent; /* index where entry is changed in the parent */ - LONG totalLength; /* length of tree information being moved */ - WORD numToMove; /* number of entries moved */ - BYTE data[1]; /* data to move */ + UserID_t userIDForParent; /* user to insert in the parent */ + UserID_t oldUserID; /* previous user in the parent */ + LONG indexForParent; /* index where entry is changed in the parent */ + LONG totalLength; /* length of tree information being moved */ + WORD numToMove; /* number of entries moved */ + BYTE data[1]; /* data to move */ } NSS_MEDIA_STRUCTURE(UBTBalance_s,data[1]) UBTBalance_s; typedef struct UBTTreeInit_s { - GUID_t internalID; + GUID_t internalID; } NSS_MEDIA_STRUCTURE(UBTTreeInit_s,internalID) UBTTreeInit_s; typedef struct UBTModifyName_s { - UserID_t objectID; - unicode_t oldName[MAX_DN_CHARS]; - unicode_t newName[MAX_DN_CHARS]; - LONG index; - GUID_t internalID; + UserID_t objectID; + unicode_t oldName[MAX_DN_CHARS]; + unicode_t newName[MAX_DN_CHARS]; + LONG index; + GUID_t internalID; } NSS_MEDIA_STRUCTURE(UBTModifyName_s,internalID) UBTModifyName_s; typedef struct UBTModifyNameEntry_s { - UserID_t objectID; - ObjectNameEntry_s oldEntry; - ObjectNameEntry_s newEntry; - LONG index; - GUID_t internalID; + UserID_t objectID; + ObjectNameEntry_s oldEntry; + ObjectNameEntry_s newEntry; + LONG index; + GUID_t internalID; } NSS_MEDIA_STRUCTURE(UBTModifyNameEntry_s,internalID) UBTModifyNameEntry_s; typedef struct UBTAddNameRecord_s { - GUID_t internalID; + GUID_t internalID; } NSS_MEDIA_STRUCTURE(UBTAddNameRecord_s,internalID) UBTAddNameRecord_s; typedef struct UBTAddName_s { - LONG blockNum; - LONG nameIndex; - LONG leafIndex; - unicode_t name[MAX_DN_CHARS]; - UserID_t objectID; - GUID_t internalID; + LONG blockNum; + LONG nameIndex; + LONG leafIndex; + unicode_t name[MAX_DN_CHARS]; + UserID_t objectID; + GUID_t internalID; } NSS_MEDIA_STRUCTURE(UBTAddName_s,internalID) UBTAddName_s; typedef struct UBTRemoveNameRecord_s { - LONG nameIndex; + LONG nameIndex; } NSS_MEDIA_STRUCTURE(UBTRemoveNameRecord_s,nameIndex) UBTRemoveNameRecord_s; typedef struct UBTRemove_s { - UserID_t userID; /* User to be modified */ - SQUAD usedAmount; /* Value for used amount */ - SQUAD restrictionAmount; /* Value for restriction amount */ - GUID_t internalID; - LONG nameIndex; - unicode_t name[MAX_DN_CHARS]; + UserID_t userID; /* User to be modified */ + SQUAD usedAmount; /* Value for used amount */ + SQUAD restrictionAmount; /* Value for restriction amount */ + GUID_t internalID; + LONG nameIndex; + unicode_t name[MAX_DN_CHARS]; } NSS_MEDIA_STRUCTURE(UBTRemove_s,name[MAX_DN_CHARS]) UBTRemove_s; typedef struct UBTRemoveName_s { - GUID_t internalID; - UserID_t userID; - LONG nameIndex; - unicode_t name[MAX_DN_CHARS]; + GUID_t internalID; + UserID_t userID; + LONG nameIndex; + unicode_t name[MAX_DN_CHARS]; } NSS_MEDIA_STRUCTURE(UBTRemoveName_s,name[MAX_DN_CHARS]) UBTRemoveName_s; /* defines for direction */ @@ -408,23 +408,23 @@ typedef struct UBTRemoveName_s typedef struct UserLog_s { - union - { - UBTEntry_s entry; - UBTModify_s modify; - UBTSplit_s split; - UBTOverflow_s overflow; - UBTGrow_s grow; - UBTBalance_s balance; - UBTTreeInit_s initTree; - UBTModifyName_s modifyName; - UBTModifyNameEntry_s modifyNameEntry; - UBTAddNameRecord_s addNameRecord; - UBTAddName_s addName; - UBTRemoveNameRecord_s removeNameRecord; - UBTRemove_s remove; - UBTRemoveName_s removeName; - } NSS_MEDIA_UNION(NamelessUnion,remove.name[MAX_DN_CHARS]) u; + union + { + UBTEntry_s entry; + UBTModify_s modify; + UBTSplit_s split; + UBTOverflow_s overflow; + UBTGrow_s grow; + UBTBalance_s balance; + UBTTreeInit_s initTree; + UBTModifyName_s modifyName; + UBTModifyNameEntry_s modifyNameEntry; + UBTAddNameRecord_s addNameRecord; + UBTAddName_s addName; + UBTRemoveNameRecord_s removeNameRecord; + UBTRemove_s remove; + UBTRemoveName_s removeName; + } NSS_MEDIA_UNION(NamelessUnion,remove.name[MAX_DN_CHARS]) u; } NSS_MEDIA_STRUCTURE(UserLog_s,u.remove.name[MAX_DN_CHARS]) UserLog_s; /**************************************************************************** @@ -434,78 +434,78 @@ typedef struct UserLog_s ****************************************************************************/ STATUS ZFSVOL_VOL_GetUserSpaceInfo( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - const UserID_t *userID, - SQUAD *restrictionAmount, - SQUAD *usedAmount); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + const UserID_t *userID, + SQUAD *restrictionAmount, + SQUAD *usedAmount); STATUS ZFSVOL_VOL_SetUserSpaceRestriction( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - struct Xaction_s *xAction, - const UserID_t *userID, - SQUAD restrictionAmount); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + struct Xaction_s *xAction, + const UserID_t *userID, + SQUAD restrictionAmount); void ZFSVOL_VOL_AdjustUsedUserSpace( - struct Xaction_s *xAction, - struct RootBeast_s *beast, - SQUAD usedAdjustment); - + struct Xaction_s *xAction, + struct RootBeast_s *beast, + SQUAD usedAdjustment); + STATUS ZFSVOL_VOL_RemoveUser( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - const UserID_t *userID); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + const UserID_t *userID); STATUS ZFSVOL_VOL_ResetAllUsers( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume); STATUS ZFSVOL_VOL_BrowseUsersInVolume( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - NINT numEntriesRequested, - UserID_t *lastUserReturned, /* inout */ - struct COMNUserRest_s *userEntries, /* out */ - NINT *numEntriesReturned, /* out */ - LONG allUsersFlags); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT numEntriesRequested, + UserID_t *lastUserReturned, /* inout */ + struct COMNUserRest_s *userEntries, /* out */ + NINT *numEntriesReturned, /* out */ + LONG allUsersFlags); STATUS ZFSVOL_VOL_ResetAllObjects( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume); STATUS ZFSVOL_VOL_GetObjectName( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - UserID_t *objectID, - unicode_t *name, - Time_t *timeNotFound, - NINT *numberOfTimesNotFound); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + UserID_t *objectID, + unicode_t *name, + Time_t *timeNotFound, + NINT *numberOfTimesNotFound); STATUS ZFSVOL_VOL_InsertObjectName( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - struct Xaction_s *xAction, - UserID_t *objectID, - unicode_t *name); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + struct Xaction_s *xAction, + UserID_t *objectID, + unicode_t *name); STATUS ZFSVOL_VOL_ModifyObjectName( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - struct Xaction_s *xAction, - UserID_t *objectID, - unicode_t *name, - Time_t timeNotFound, - NINT numberOfTimesNotFound); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + struct Xaction_s *xAction, + UserID_t *objectID, + unicode_t *name, + Time_t timeNotFound, + NINT numberOfTimesNotFound); STATUS UBT_CreateUserTreeBeast( - struct GeneralMsg_s *genMsg, - struct ZfsVolume_s *volume); + struct GeneralMsg_s *genMsg, + struct ZfsVolume_s *volume); STATUS UBT_OLD_ResetAllUsers( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - struct ZfsUserTreeBeast_s *userTreeBeast); + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + struct ZfsUserTreeBeast_s *userTreeBeast); /**************************************************************************** * @@ -513,15 +513,15 @@ STATUS UBT_OLD_ResetAllUsers( * ****************************************************************************/ STATUS UBT_modifyUserValue ( - struct GeneralMsg_s *genMsg, - struct UserTreeParms_s *parms); + struct GeneralMsg_s *genMsg, + struct UserTreeParms_s *parms); #ifdef NW5X_UPGRADE STATUS ZFSPOOL_upgradeUserTree( - struct GeneralMsg_s *genMsg, - struct ZfsVolume_s *volume, - struct ZfsUserTreeBeast_s *oldTree); + struct GeneralMsg_s *genMsg, + struct ZfsVolume_s *volume, + struct ZfsUserTreeBeast_s *oldTree); #endif diff --git a/src/nwnss/zlss/xaction.c b/src/nwnss/zlss/xaction.c index 163bd80..604a917 100644 --- a/src/nwnss/zlss/xaction.c +++ b/src/nwnss/zlss/xaction.c @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include "comnPublics.h" #include "zParams.h" @@ -57,9 +57,9 @@ #include "zlssLogicalVolume.h" /* - * Initialization for the Transaction Recovery Table. Each developer - * needs to place their functions they need for recovery in this table. - */ + * Initialization for the Transaction Recovery Table. Each developer + * needs to place their functions they need for recovery in this table. + */ STATUS XRedoDummy ( struct GeneralMsg_s *genMsg, struct ZfsPool_s *pool, @@ -121,14 +121,14 @@ RedoUndo_s XRecoveryTable[XFUNC_MAX] = { { XRedoDummy, XUndoDummy }, /* - * If we just want to ignore it. (End Transaction). In debug - * mode (unss.nlm) the checkpoint code also uses to log - * chcekpoints into the ZLOG file. - */ + * If we just want to ignore it. (End Transaction). In debug + * mode (unss.nlm) the checkpoint code also uses to log + * chcekpoints into the ZLOG file. + */ { XRedoIgnore, XUndoIgnore }, /* 1 */ /* - * Beast B-tree recovery functions - */ + * Beast B-tree recovery functions + */ { recoveryInsertZnode, recoveryDeleteZnode }, /* 2 */ { recoveryDeleteZnode, recoveryInsertZnode }, /* 3 */ { recoverySplit, recoveryJoin }, /* 4 */ @@ -139,15 +139,15 @@ RedoUndo_s XRecoveryTable[XFUNC_MAX] = { recoveryShrink, recoveryGrow }, /* 9 */ { recoveryInit, recoveryUninit }, /* 10 */ /* - * Purge Log - */ + * Purge Log + */ { XRedoDummy, XUndoDummy }, /* Not being used */ /* 11 */ { recoveryPurgeLogGrow, recoveryPurgeLogShrink }, /* 12 */ { recoveryPurgeLogInsert, recoveryPurgeLogRemove }, /* 13 */ - { recoveryPurgeLogRemove, recoveryPurgeLogInsert }, /* 14 */ + { recoveryPurgeLogRemove, recoveryPurgeLogInsert }, /* 14 */ /* - * File Map recovery functions - */ + * File Map recovery functions + */ { redoInitRoot, undoInitRoot }, /* 15 */ { redoFmapInsert, undoFmapInsert }, /* 16 */ { redoFmapInsertSparse, undoFmapInsertSparse }, /* 17 */ @@ -156,7 +156,7 @@ RedoUndo_s XRecoveryTable[XFUNC_MAX] = { redoFmapRemove, undoFmapRemove }, /* 20 */ { redoFmapJoin, undoFmapJoin }, /* 21 */ { redoFmapToss, undoFmapToss }, /* 22 */ - /* + /* * Name log */ #ifndef NSSOLD_NAMING @@ -171,8 +171,8 @@ RedoUndo_s XRecoveryTable[XFUNC_MAX] = { redoModifyNSMask, undoModifyNSMask }, /* 26 */ #endif /* - * Free tree - */ + * Free tree + */ { redoFXshrink, undoFXshrink }, /* 27 */ { redoFXdelete, undoFXdelete }, /* 28 */ { redoFXbalance, undoFXbalance }, /* 29 */ @@ -181,8 +181,8 @@ RedoUndo_s XRecoveryTable[XFUNC_MAX] = { redoFXsplit, undoFXsplit }, /* 32 */ { redoFXinsert, undoFXinsert }, /* 33 */ /* - * Volume info - */ + * Volume info + */ { recoveryVolumeInfo, recoveryVolumeInfo }, /* 34 */ #ifndef NSSOLD_NAMING { dlog_recovery_common, dlog_recovery_common }, /* 35 */ @@ -190,8 +190,8 @@ RedoUndo_s XRecoveryTable[XFUNC_MAX] = { XRedoDummy, XUndoDummy }, #endif /* - * Old Purge B-tree recovery functions - */ + * Old Purge B-tree recovery functions + */ { pbt_recoveryInsertEntry, pbt_recoveryDeleteEntry }, /* 36 */ { pbt_recoveryDeleteEntry, pbt_recoveryInsertEntry }, /* 37 */ { pbt_recoverySplit, pbt_recoveryJoin }, /* 38 */ @@ -202,8 +202,8 @@ RedoUndo_s XRecoveryTable[XFUNC_MAX] = { pbt_recoveryShrink, pbt_recoveryGrow }, /* 43 */ { pbt_recoveryInit, pbt_recoveryUninit }, /* 44 */ /* - * user B-tree recovery functions - */ + * user B-tree recovery functions + */ { UBT_recoveryModifyEntry, UBT_recoveryModifyEntry }, /* 45 */ { UBT_recoveryInsertEntry, UBT_recoveryDeleteEntry }, /* 46 */ { UBT_recoveryDeleteEntry, UBT_recoveryInsertEntry }, /* 47 */ @@ -215,27 +215,27 @@ RedoUndo_s XRecoveryTable[XFUNC_MAX] = { UBT_recoveryInit, UBT_recoveryUninit }, /* 53 */ { UBT_recoveryRemove, UBT_recoveryRemove }, /* 54 */ /* - * LV delete info - */ + * LV delete info + */ { ZLSSVOL_LVD_RecoveryBTShrinkRoot, ZLSSVOL_LVD_RecoveryBTShrinkRoot }, /* 55 */ { ZLSSVOL_LVD_RecoveryBTShrink, ZLSSVOL_LVD_RecoveryBTShrink }, /* 56 */ { ZLSSVOL_LVD_RecoveryNTShrink, ZLSSVOL_LVD_RecoveryNTShrink }, /* 57 */ { ZLSSVOL_LVD_RecoveryNTShrink, ZLSSVOL_LVD_RecoveryNTShrink }, /* 58 */ { ZLSSVOL_LVD_RecoveryNTShrink, ZLSSVOL_LVD_RecoveryNTShrink }, /* 59 */ /* - * LV Create info - */ + * LV Create info + */ { recoveryInit, recoveryUninit }, /* 60 */ { recoveryPurgeLogInit, recoveryPurgeLogUninit }, /* 61 */ { recoveryVDBInit, recoveryVDBUninit }, /* 62 */ { recoveryLVDBInit, recoveryLVDBUninit }, /* 63 */ /* - * Pool info - */ + * Pool info + */ { ZLSSPOOL_RecoveryPoolInfo, ZLSSPOOL_RecoveryPoolInfo }, /* 64 */ /* - * Logical Undo routines - */ + * Logical Undo routines + */ { recoveryInsertZnode, recoveryDeleteZnodeLogical }, /* 65 */ { recoveryDeleteZnode, recoveryInsertZnodeLogical }, /* 66 */ { redoFXinsert, undoFXinsertLogical }, /* 67 */ @@ -246,23 +246,23 @@ RedoUndo_s XRecoveryTable[XFUNC_MAX] = { UBT_recoveryInsertEntry, UBT_recoveryDeleteEntryLogical }, /* 72 */ { UBT_recoveryDeleteEntry, UBT_recoveryInsertEntryLogical }, /* 73 */ /* - * Name tree physical redo/undo routines - */ + * Name tree physical redo/undo routines + */ { dlog_recovery_common, dlog_recovery_common }, /* 74 */ /* - * Superblock Header - */ + * Superblock Header + */ { ZLSSPOOL_RecoverySuperblockHeader, ZLSSPOOL_RecoverySuperblockHeader }, /* 75 */ /* - * - */ + * + */ { recoveryPDBInit, recoveryPDBUninit }, /* 76 */ { recoveryLPDBInit, recoveryLPDBUninit }, /* 77 */ { recoveryVDBUpdate, recoveryVDBUpdate }, /* 78 */ /* - * directory quota B-tree recovery functions - */ + * directory quota B-tree recovery functions + */ { DBT_recoveryModifyEntry, DBT_recoveryModifyEntry }, /* 79 */ { DBT_recoveryInsertEntry, DBT_recoveryDeleteEntry }, /* 80 */ { DBT_recoveryDeleteEntry, DBT_recoveryInsertEntry }, /* 81 */ @@ -360,16 +360,16 @@ Histogram_s XcommitHistogram = { 0 }; Histogram_s XendHistogram = { 0 }; NINT XdeleteCnt = 0; /* July 30, 1998(Greg) Made 20 verses 10 because we hit - * to often because of slow Name Tree when many duplicate - * deleted file names. - */ + * to often because of slow Name Tree when many duplicate + * deleted file names. + */ NINT MaxXactionTicks = SEC2TICK(100); #endif #if FREE_DATA_STATS IS_ENABLED FreeUserDataBlksStats_s UserFreeStats = {0}; #endif - + void XqueueDeferredPoolBlks ( ZfsXaction_s *xaction); @@ -384,12 +384,12 @@ STATUS XACT_Startup (void) { ENTER(TXACTION, XACT_Startup); - if (CONTROL_Startup(&XactionControl, ZstoreConfig.zfs.numXactions, - sizeof(ZfsXaction_s), (voidfunc_t)XACT_Init) != zOK) + if (CONTROL_Startup(&XactionControl, ZstoreConfig.zfs.numXactions, + sizeof(ZfsXaction_s), XACT_Init) != zOK) { RTN_STATUS(zFAILURE); } - + if (CONTROL_Startup(&FreeUserDataBlksControl, 256, sizeof(FreeUserDataBlks_s), NULL) != zOK) { @@ -397,8 +397,8 @@ STATUS XACT_Startup (void) RTN_STATUS(zFAILURE); } - if (objCacheCreate(&PLogFreeEntry, "Plog", - sizeof(FreePurgeLogEntries_s), NULL) != zOK) + if (objCacheCreate(&PLogFreeEntry, "Plog", + sizeof(FreePurgeLogEntries_s), NULL) != zOK) { CONTROL_Shutdown( &XactionControl); CONTROL_Shutdown( &FreeUserDataBlksControl); @@ -442,7 +442,7 @@ void freeXaction (ZfsXaction_s *xaction) } /************************************************************************** - * + * ***************************************************************************/ void writeCommitRecord (ZfsXaction_s *xaction) { @@ -457,23 +457,23 @@ void writeCommitRecord (ZfsXaction_s *xaction) RTN_VOID(); } - if (xaction->xflags & XFLAG_LOGICAL_UNDO) + if (xaction->xflags & XFLAG_LOGICAL_UNDO) { /* These are the EndXLocal that are called during Pass 7 - * on transactions that were started by the logical undo - * routines. We want to save the LSN of the logical undo - * record that initiated this xaction. - */ + * on transactions that were started by the logical undo + * routines. We want to save the LSN of the logical undo + * record that initiated this xaction. + */ ZLOG_ObtainRecord( xaction, sizeof(Lsn_t) ); log = xaction->ZX_zlogBeast->ZLB_ZfsXasRecovery; if (xaction->xstate & X_DONT_COMMIT) { /* This is the condition that an error occurred while - * in Pass 7 of recovery. We do not want to mark the - * this xaction with an XAS_XR_TS_END state, as we want - * to undo it if the user tries to bring the system back up. - */ + * in Pass 7 of recovery. We do not want to mark the + * this xaction with an XAS_XR_TS_END state, as we want + * to undo it if the user tries to bring the system back up. + */ log->ZXR_TransactionState = 0; } else @@ -566,11 +566,11 @@ ZfsXaction_s *BeginXLocal (Volume_s *volume, NINT flags) if (time - xact->timeStamp >= MaxXactionTicks) { #ifdef __linux__ - printk("<1>" "Xaction slow status = 0x%08x; id = 0x%08x, currentid=0x%08x\n", xact->xstate, (LONG)xact->localXid.unique, (LONG)XidUnique); - aprintf(CYAN,"stat = 0x%08x; id = 0x%08x, currentid=0x%08x\n", xact->xstate, (LONG)xact->localXid.unique, (LONG)XidUnique); + printk("<1>" "Xaction slow status = 0x%08x; id = 0x%08x, currentid=0x%08x\n", xact->xstate, (LONG)xact->localXid.unique, (LONG)XidUnique); + aprintf(CYAN,"stat = 0x%08x; id = 0x%08x, currentid=0x%08x\n", xact->xstate, (LONG)xact->localXid.unique, (LONG)XidUnique); #else aprintf(CYAN, MSGNot("Caller = 0x%08x; CallerCaller = 0x%08x\n"), xact->caller, xact->callerCaller); - zASSERT("Transaction too slow" == NULL); + zASSERT("Transaction too slow" == NULL); #endif } } @@ -610,9 +610,9 @@ void XisHomedSignalHandler (Agent_s *agent) if (xaction->xstate & X_COMMITTED) { /* - * The Xaction is committed and everything is in its - * home location so we can finish up. - */ + * The Xaction is committed and everything is in its + * home location so we can finish up. + */ ZLOG_TransactionHomed(xaction); } RTN_VOID(); @@ -632,11 +632,11 @@ void EndXlocal (ZfsXaction_s *xaction) #if NSS_DEBUG IS_ENABLED xaction->commitStamp = Ticks; #endif - + /* queue any deferred pool blocks onto the pool queue */ if (DQ_NOT_EMPTY(&xaction->ZX_deleteBlkQ)) { - XqueueDeferredPoolBlks(xaction); + XqueueDeferredPoolBlks(xaction); } #if NSS_ASSERT IS_ENABLED @@ -644,7 +644,7 @@ void EndXlocal (ZfsXaction_s *xaction) { zASSERT(xaction->ZX_logicalUndoLSN != 0); } - else + else { zASSERT(xaction->ZX_logicalUndoLSN == 0); } @@ -657,8 +657,8 @@ void EndXlocal (ZfsXaction_s *xaction) } while (DQ_NOT_EMPTY(&xaction->freePurgeLogEntries)) { - DQ_DEQ(&xaction->freePurgeLogEntries, pLogEntry, - FreePurgeLogEntries_s, xactionLink); + DQ_DEQ(&xaction->freePurgeLogEntries, pLogEntry, + FreePurgeLogEntries_s, xactionLink); PLOG_PutEntryOnFreeList(pLogEntry); } @@ -666,13 +666,13 @@ void EndXlocal (ZfsXaction_s *xaction) zASSERT(xaction->numFreeNonusableBlks == 0); #endif - /* The X_COMMITTED state on the xaction is what causes the xaction to - * eventually be freed from memory and for ZLOG_TransactionHomed - * to be called. - * We do not want to set this bit until this point, because this is - * where we are done using the xaction and one of the 2 paths below - * will cause the signal handler for the xaction to be called. - */ + /* The X_COMMITTED state on the xaction is what causes the xaction to + * eventually be freed from memory and for ZLOG_TransactionHomed + * to be called. + * We do not want to set this bit until this point, because this is + * where we are done using the xaction and one of the 2 paths below + * will cause the signal handler for the xaction to be called. + */ xaction->xstate |= X_COMMITTED; lazyFlush( &xaction->xaction.agent); @@ -710,11 +710,11 @@ void EndXlocalAsync (ZfsXaction_s *xaction) // UTCTime2Str(GetUTCTime(),&buffer[0]) ); // } //#endif - /* - * This only works because the FSM and the ZfsXaction_s - * are at offset 0. - */ - WORK_Schedule_HIGH( &xaction->xaction.agent.fsm, (voidfunc_t)EndXlocal, 0); + /* + * This only works because the FSM and the ZfsXaction_s + * are at offset 0. + */ + WORK_Schedule_HIGH( &xaction->xaction.agent.fsm, EndXlocal, 0); RTN_VOID(); } @@ -747,7 +747,7 @@ NINT PageIndex = 0; #define SET_PAGE(_binfo, _alloc) ((void)0) #endif #endif - + /************************************************************************* * @@ -760,10 +760,10 @@ STATUS initXfreeTable ( STATUS status; /* - * The free table keeps track of which block were freed and allocated - * in the log so we can ignore operations on the freed - * blocks. - */ + * The free table keeps track of which block were freed and allocated + * in the log so we can ignore operations on the freed + * blocks. + */ ENTER(TXACTION, initXfreeTable); freeTable->size = INITIAL_XTABLE_SIZE; @@ -771,7 +771,7 @@ STATUS initXfreeTable ( freeTable->free = 0; status = ((freeTable->blks == NULL) ? zFAILURE : zOK); - + RTN_STATUS(status); } @@ -794,10 +794,10 @@ void freeXfreeTable ( /************************************************************************* * * Find an entry in the undo transaction table - * return - an index into the table (-1 = not found) + * return - an index into the table (-1 = not found) * *************************************************************************/ -NINT findUndoEntry ( +NINT findUndoEntry ( UndoTable_s *undoTable, LocalXid_t xid) /* input - block number we are looking for */ { @@ -864,7 +864,7 @@ STATUS insertFreedBlk ( RTN_STATUS( zFAILURE ); } freeTable->blks = blks; - } + } #if NSS_DEBUG IS_ENABLED { NINT i; @@ -966,9 +966,9 @@ STATUS initXactTable ( STATUS status; /* - * Xaction table keeps track of which transactions have not been - * been committed. - */ + * Xaction table keeps track of which transactions have not been + * been committed. + */ ENTER(TXACTION, initXactTable); xactTable->size = INITIAL_XTABLE_SIZE; @@ -977,7 +977,7 @@ STATUS initXactTable ( xactTable->numUncommittedEntries = 0; status = ((xactTable->xEntry == NULL) ? zFAILURE : zOK); - + RTN_STATUS(status); } @@ -1026,9 +1026,9 @@ STATUS addXactEntry ( xactTable->xEntry = xEntry; } /* - * Pass 1 - Every call does ++ - * Pass 2 - No call does ++ - */ + * Pass 1 - Every call does ++ + * Pass 2 - No call does ++ + */ if (!(state & XTE_COMMITTED)) { /* uncommitted */ xactTable->numUncommittedEntries++; @@ -1059,9 +1059,9 @@ void removeXactEntry ( ENTER(TXACTION, removeXactEntry); /* - * Pass 1 - Every call does -- - * Pass 2 - May or may not do -- - */ + * Pass 1 - Every call does -- + * Pass 2 - May or may not do -- + */ if (!(xactionTable->xEntry[index].state & XTE_COMMITTED)) { /* completed and uncommitted */ xactionTable->numUncommittedEntries--; @@ -1081,7 +1081,7 @@ void removeXactEntry ( } } while (entry != NULL); - xactionTable->xEntry[index] = + xactionTable->xEntry[index] = xactionTable->xEntry[--xactionTable->numEntries]; RTN_VOID(); } @@ -1089,10 +1089,10 @@ void removeXactEntry ( /************************************************************************* * * Find an entry from the transaction table - * return - an index into the transaction table (-1 = not found) + * return - an index into the transaction table (-1 = not found) * *************************************************************************/ -NINT findXactEntry ( +NINT findXactEntry ( XactTable_s *xactTable, LocalXid_t xid) /* input - transaction id */ { @@ -1239,7 +1239,7 @@ STATUS initUncommittedTable ( uncommittedTable->numEntries = 0; status = ((uncommittedTable->xids == NULL) ? zFAILURE : zOK); - + RTN_STATUS(status); } @@ -1319,7 +1319,7 @@ STATUS initUndoTable ( undoTable->numEntries = 0; status = ((undoTable->xids == NULL) ? zFAILURE : zOK); - + RTN_STATUS(status); } @@ -1365,8 +1365,8 @@ STATUS addUndoEntry ( } undoTable->xids[undoTable->numEntries] = xid; undoTable->numEntries++; - DEBUG_PRINTF(TXACTION, DBG_NOINDENT, - (LBLUE, MSGNot("Added undo. xid=%d\n"), xid)); + DEBUG_PRINTF(TXACTION, DBG_NOINDENT, + (LBLUE, MSGNot("Added undo. xid=%d\n"), xid)); RTN_STATUS(zOK); } @@ -1425,7 +1425,7 @@ STATUS undoAnalysis( if (xactionTable->numEntries > 0) { DBG_DebugPrintf( LRED, - MSGNot("** Uncommitted Transactions (Type 3 transactions) **\n")); + MSGNot("** Uncommitted Transactions (Type 3 transactions) **\n")); for (i = 0; i < xactionTable->numEntries; i++) { char buffer[40]; @@ -1443,8 +1443,8 @@ STATUS undoAnalysis( #endif /* - * Init the various table we are going to need - */ + * Init the various table we are going to need + */ if (initBlockTable(&blockTable) != zOK) { zASSERT("Unable to init the block table"==0); @@ -1494,36 +1494,36 @@ STATUS undoAnalysis( } } /* - * This next code ignores blocks that are part of the Purge - * Log because many transactions use the same blocks. If - * we did not ignore them we would greatly increase the number - * of committed transactions that would have to be uncommited. - * We can ignore Purge Log Blocks because the Purge Log's undo - * and redo routines operate logically on a block! - * - * The Purge Log can be logical at the block level because - * a block change does NOT effect other blocks - unlike changes - * to B-Trees. - * - * FixFixFix6(Randy) - If the original operation is a DELETE that - * does not commit and the purge log block becomes full 20 - * transactions later before we crash. On the UNDO pass would - * we not do an insert and not have enough space??? - * - * Note that we CANNOT ignore some XFUNC_VOLINFO_MODIFY blocks - * because on a crash during the UNDO pass the LSN would be left - * LOW. Then on the next activate we would REDO some - * items that had already been done and thus end up with - * incorrect values. - */ + * This next code ignores blocks that are part of the Purge + * Log because many transactions use the same blocks. If + * we did not ignore them we would greatly increase the number + * of committed transactions that would have to be uncommited. + * We can ignore Purge Log Blocks because the Purge Log's undo + * and redo routines operate logically on a block! + * + * The Purge Log can be logical at the block level because + * a block change does NOT effect other blocks - unlike changes + * to B-Trees. + * + * FixFixFix6(Randy) - If the original operation is a DELETE that + * does not commit and the purge log block becomes full 20 + * transactions later before we crash. On the UNDO pass would + * we not do an insert and not have enough space??? + * + * Note that we CANNOT ignore some XFUNC_VOLINFO_MODIFY blocks + * because on a crash during the UNDO pass the LSN would be left + * LOW. Then on the next activate we would REDO some + * items that had already been done and thus end up with + * incorrect values. + */ -// if ((logRec->ZXR_FunctionIndex != XFUNC_PLOG_INSERT) && +// if ((logRec->ZXR_FunctionIndex != XFUNC_PLOG_INSERT) && // (logRec->ZXR_FunctionIndex != XFUNC_PLOG_DELETE)) - /* FixFixFix6 - This (above) fixes above fix item by not skipping - * purge loge entries. Could allow skipping of INSERT??? - * Note this fix causes more uncommits of committed - * transactions. - */ + /* FixFixFix6 - This (above) fixes above fix item by not skipping + * purge loge entries. Could allow skipping of INSERT??? + * Note this fix causes more uncommits of committed + * transactions. + */ { /* if not a purgelog function then look at all of the blocks */ for (i = 0; i < logRec->ZXR_PoolBlockCount; ++i) { /* for each block in the log record */ @@ -1551,8 +1551,8 @@ STATUS undoAnalysis( } /* - * Figure out what transactions need to be undone - */ + * Figure out what transactions need to be undone + */ while (uncommittedTable.numEntries > 0) { /* while there are entries on the uncommitted stack */ xactionLoc = findXactEntry(xactionTable, @@ -1577,13 +1577,13 @@ STATUS undoAnalysis( // &unCommittedEntry, unCommittedEntry->block); if ((unCommittedEntry->block == committedEntry->block) && // ((unCommittedEntry->generation == committedEntry->generation) || -// ((unCommittedEntry->state & LOG_FREE_NODE) && +// ((unCommittedEntry->state & LOG_FREE_NODE) && // (unCommittedEntry->generation > committedEntry->generation))) && (unCommittedEntry->sequence > committedEntry->sequence)) { /* we have common blocks in the required order - - * force the committed transaction into the - * uncommitted state. - */ + * force the committed transaction into the + * uncommitted state. + */ xactionTable->xEntry[i].state &= ~XTE_COMMITTED; xactionTable->numUncommittedEntries++; #if NSS_DEBUG IS_ENABLED @@ -1603,11 +1603,11 @@ STATUS undoAnalysis( xactionTable->xEntry[i].xid.unique) ); { char buffer[40]; - + DEBUG_PRINTF(TXACTION, DBG_NOINDENT, (CYAN,MSGNot("%s\n"),UTCTime2Str(xactionTable->xactionTime,&buffer[0])) ); } - DEBUG_PRINTF(TXACTION, DBG_NOINDENT, + DEBUG_PRINTF(TXACTION, DBG_NOINDENT, (LBLUE,MSGNot("**** COMMON BLOCK NUMBER FOUND **** xid=%d comparing to xid=%d blk=%d\n"), xactionTable->xEntry[xactionLoc].xid.unique, xactionTable->xEntry[i].xid.unique, committedEntry->block) ); @@ -1710,7 +1710,7 @@ STATUS XactionRecover ( NINT i; #if NSS_DEBUG IS_ENABLED Time_t firstLRTime=0; /* The time of the first LR in - * the NORMAL area of the ZLOG file */ + * the NORMAL area of the ZLOG file */ Time_t lastLRTime=0; /* The time of the last LR in ZLOG file */ Time_t currentLRTime; /* The time of the current LR */ BOOL haveAsserted = FALSE; @@ -1722,14 +1722,14 @@ STATUS XactionRecover ( * happens we will do PASS 3 and PASS 4, but * not PASS 5. We then return an error * so ZREPAIR will be run. - */ + */ ENTER(TXACTION, XactionRecover); /* Normally, it is EVIL to clear errNo. We do here to save - * stack space for a genMSg and because no one should be calling - * this as cleanup code. - */ + * stack space for a genMSg and because no one should be calling + * this as cleanup code. + */ zASSERT( GetErrno( genMsg ) == zOK ); ClearErrno( genMsg ); if (initXactTable(&xactTable) != zOK) @@ -1749,25 +1749,25 @@ STATUS XactionRecover ( } /* - * PASS 1 of Recovery: ANALYSIS: Figure out the transactions - * that didn't commit. - * - * There are three types of transactions in the ZLOG file. - * - * Type 1 have a Start record. - * Type 2 have a End record. - * Type 3 have a Start record and a End record. - * - * Type 1 - Uncommitted before crash - * Type 2 - Committed across a checkpoint - * Type 3 - Committed - * - * PASS 1 finds all the transactions of type 1. These are - * the ONLY transactions left in the xactTable[] when the pass - * is done. Note that Type 1 transactions never get placed into - * the xactTable[] in PASS 1. - * - */ + * PASS 1 of Recovery: ANALYSIS: Figure out the transactions + * that didn't commit. + * + * There are three types of transactions in the ZLOG file. + * + * Type 1 have a Start record. + * Type 2 have a End record. + * Type 3 have a Start record and a End record. + * + * Type 1 - Uncommitted before crash + * Type 2 - Committed across a checkpoint + * Type 3 - Committed + * + * PASS 1 finds all the transactions of type 1. These are + * the ONLY transactions left in the xactTable[] when the pass + * is done. Note that Type 1 transactions never get placed into + * the xactTable[] in PASS 1. + * + */ #if NSS_DEBUG IS_ENABLED // aprintf(LGREEN, MSGNot(" (DEBUG) PASS 1\n") ); DBG_DebugPrintf(LGREEN, MSGNot("*** PASS 1***\n")); @@ -1847,9 +1847,9 @@ STATUS XactionRecover ( #endif /* - * PASS 2 of Recovery: ANALYSIS: Figure out which transactions need - * to be undone. - */ + * PASS 2 of Recovery: ANALYSIS: Figure out which transactions need + * to be undone. + */ #if NSS_DEBUG IS_ENABLED // aprintf(LGREEN, MSGNot(" (DEBUG) PASS 2\n") ); DBG_DebugPrintf(LGREEN, MSGNot("*** PASS 2***\n")); @@ -1865,19 +1865,19 @@ STATUS XactionRecover ( } /* - * PASS 3 of Recovery: collect the blocks that will be freed - * - * This pass is needed because if we TOSS a buffer because - * it gets deleted then home may be signaled even thought - * other transactions had marked the buffer dirty. These - * other transactions may not be happy if we tell them to - * REDO because the LSN may not match because we did not - * write the buffer before moving home. - * - * Currently I do not believe that any early tosses are occuring - * because the TOSS (and delete) are being delayed until the - * 4th checkpoint occurs. See XfreePoolBlks(). - */ + * PASS 3 of Recovery: collect the blocks that will be freed + * + * This pass is needed because if we TOSS a buffer because + * it gets deleted then home may be signaled even thought + * other transactions had marked the buffer dirty. These + * other transactions may not be happy if we tell them to + * REDO because the LSN may not match because we did not + * write the buffer before moving home. + * + * Currently I do not believe that any early tosses are occuring + * because the TOSS (and delete) are being delayed until the + * 4th checkpoint occurs. See XfreePoolBlks(). + */ #if NSS_DEBUG IS_ENABLED // aprintf(LGREEN, MSGNot(" (DEBUG) PASS 3\n") ); DBG_DebugPrintf(LGREEN, MSGNot("*** PASS 3 ***\n")); @@ -1888,7 +1888,7 @@ STATUS XactionRecover ( pool->zp_stats.pass3++; if (key.ZRK_ZfsXasRecovery->ZXR_PoolBlockCount != 0) { - status = recoverFreedBlocks( genMsg, &freeTable, + status = recoverFreedBlocks( genMsg, &freeTable, key.ZRK_ZfsXasRecovery); if ( status != zOK ) { @@ -1904,10 +1904,10 @@ STATUS XactionRecover ( ClearErrno(genMsg); /* - * Pass 4 of Recovery: REDO : Call redo function for each log - * record. Mark the blocks that should not be redone by filling - * them with zero. - */ + * Pass 4 of Recovery: REDO : Call redo function for each log + * record. Mark the blocks that should not be redone by filling + * them with zero. + */ #if NSS_DEBUG IS_ENABLED // aprintf(LGREEN, MSGNot(" (DEBUG) PASS 4\n") ); DBG_DebugPrintf(LGREEN, MSGNot("*** PASS 4 ***\n")); @@ -2033,8 +2033,8 @@ STATUS XactionRecover ( #endif /* NSS_DEBUG (PASS 4a and 4b) */ /* - * Pass 5 of Recovery: UNDO : Call undo functions. - */ + * Pass 5 of Recovery: UNDO : Call undo functions. + */ #if NSS_DEBUG IS_ENABLED // aprintf(LGREEN, MSGNot(" (DEBUG) PASS 5\n") ); DBG_DebugPrintf(LGREEN, MSGNot("*** PASS 5 ***\n")); @@ -2045,9 +2045,9 @@ STATUS XactionRecover ( goto error; } /* FixFixFix6 - We could track numEntries as we hit the START - * record of the transactions being UNDOne. Then when we hit - * zero within the loop below we can stop Pass 5. - */ + * record of the transactions being UNDOne. Then when we hit + * zero within the loop below we can stop Pass 5. + */ if ( undoTable.numEntries > 0 ) { ZLOG_RecoveryOpen(ZLOG_RECOVERY_END | ZLOG_RECOVERY_EXPANDED, pool, &key); @@ -2131,15 +2131,15 @@ STATUS XactionRecover ( aprintf(CYAN, MSGNot(" ** (DEBUG) %d Redo(s), %d Undo(s)\n"), numRedos, numUndos ); #endif - if ( mode & VOLMODE_VERBOSE ) + if ( mode & VOLMODE_VERBOSE ) { aprintf(NSS_POOL_COLOR, MSG(" ** %d Redo(s), %d Undo(s)\n", 861), numRealRedos, numRealUndos ); } /* - * This code is here just to let FTEST report 'useful' information - * when at demos. - */ + * This code is here just to let FTEST report 'useful' information + * when at demos. + */ { ZlogBeast_s *zlog; @@ -2164,7 +2164,7 @@ error: UNX_LATCH( &pool->ZFSPOOLbeastLatch); defaultFlushWait( &pool->ZFSPOOLmycache.agent); cacheTossAll( &pool->ZFSPOOLmycache); - + freeUndoTable(&undoTable); freeXfree: freeXfreeTable(&freeTable); @@ -2203,7 +2203,7 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( NINT i; #if NSS_DEBUG IS_ENABLED Time_t firstLRTime=0; /* The time of the first LR in - * the NORMAL area of the ZLOG file */ + * the NORMAL area of the ZLOG file */ Time_t lastLRTime=0; /* The time of the last LR in ZLOG file */ Time_t currentLRTime; /* The time of the current LR */ #endif @@ -2211,9 +2211,9 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( ENTER(TXACTION, XactionRecover); /* Normally, it is EVIL to clear errNo. We do here to save - * stack space for a genMSg and because no one should be calling - * this as cleanup code. - */ + * stack space for a genMSg and because no one should be calling + * this as cleanup code. + */ zASSERT( GetErrno( genMsg ) == zOK ); ClearErrno( genMsg ); @@ -2228,55 +2228,55 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( } /* - * PASS 1 of Recovery: ANALYSIS: Figure out the transactions - * that didn't commit. - * - * There are three types of transactions in the ZLOG file. - * - * Type 1 have a Start record. - * Type 2 have a End record. - * Type 3 have a Start record and a End record. - * - * Type 1 - Uncommitted before crash - * Type 2 - Committed across a checkpoint - * Type 3 - Committed - * - * PASS 1 finds all the transactions of type 1. These are - * the ONLY transactions left in the undoTable[] when the pass - * is done. Note that Type 2 transactions never get placed into - * the undoTable[] in PASS 1. - * - * If we are doing Compensation Records, then all Type 1 and - * Type 3 records will be left in the undoTable when the Pass is - * is done. If we are processing normal (non-compensation Records) - * only Type 1 records will be left in the undoTable when done. - * Note - When doing Comp Records we UNDO all of them (even - * committed ones). We do this because we will replay the - * logical UNDOs that created the comps. - * - */ + * PASS 1 of Recovery: ANALYSIS: Figure out the transactions + * that didn't commit. + * + * There are three types of transactions in the ZLOG file. + * + * Type 1 have a Start record. + * Type 2 have a End record. + * Type 3 have a Start record and a End record. + * + * Type 1 - Uncommitted before crash + * Type 2 - Committed across a checkpoint + * Type 3 - Committed + * + * PASS 1 finds all the transactions of type 1. These are + * the ONLY transactions left in the undoTable[] when the pass + * is done. Note that Type 2 transactions never get placed into + * the undoTable[] in PASS 1. + * + * If we are doing Compensation Records, then all Type 1 and + * Type 3 records will be left in the undoTable when the Pass is + * is done. If we are processing normal (non-compensation Records) + * only Type 1 records will be left in the undoTable when done. + * Note - When doing Comp Records we UNDO all of them (even + * committed ones). We do this because we will replay the + * logical UNDOs that created the comps. + * + */ /* - * PASS 2 of Recovery: ANALYSIS: Figure out which transactions need - * to be undone. With Logical undo's this pass no longer needs to - * be done. All the transactions left in the undoTable by Pass 1 - * will be undone. - */ + * PASS 2 of Recovery: ANALYSIS: Figure out which transactions need + * to be undone. With Logical undo's this pass no longer needs to + * be done. All the transactions left in the undoTable by Pass 1 + * will be undone. + */ /* - * PASS 3 of Recovery: collect the blocks that will be freed - * - * This pass is needed because if we TOSS a buffer because - * it gets deleted then home may be signaled even thought - * other transactions had marked the buffer dirty. These - * other transactions may not be happy if we tell them to - * REDO because the LSN may not match because we did not - * write the buffer before moving home. - * - * Currently I do not believe that any early tosses are occuring - * because the TOSS (and delete) are being delayed until the - * 4th checkpoint occurs. See XfreePoolBlks(). - * - * This pass is now being done with Pass 1. - */ + * PASS 3 of Recovery: collect the blocks that will be freed + * + * This pass is needed because if we TOSS a buffer because + * it gets deleted then home may be signaled even thought + * other transactions had marked the buffer dirty. These + * other transactions may not be happy if we tell them to + * REDO because the LSN may not match because we did not + * write the buffer before moving home. + * + * Currently I do not believe that any early tosses are occuring + * because the TOSS (and delete) are being delayed until the + * 4th checkpoint occurs. See XfreePoolBlks(). + * + * This pass is now being done with Pass 1. + */ #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LGREEN, MSGNot("*** PASS 1 2 3***\n")); #endif @@ -2294,19 +2294,19 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( if (key.ZRK_ZfsXasRecovery->ZXR_TransactionState & XAS_XR_TS_START) { /* found a starting log record - insert in the transaction table */ if ( addUndoEntry(&undoTable, - key.ZRK_ZfsXasRecovery->ZXR_LocalXid) != zOK ) + key.ZRK_ZfsXasRecovery->ZXR_LocalXid) != zOK ) { /* error */ SetErrno(genMsg, zERR_NO_MEMORY); goto errClose; } } if (key.ZRK_ZfsXasRecovery->ZXR_TransactionState & XAS_XR_TS_END) - { - /* found a end xaction log record, remove from the transaction - * table. We NEVER undo committed transactions. */ + { + /* found a end xaction log record, remove from the transaction + * table. We NEVER undo committed transactions. */ location = findUndoEntry(&undoTable, - key.ZRK_ZfsXasRecovery->ZXR_LocalXid); + key.ZRK_ZfsXasRecovery->ZXR_LocalXid); if (location != -1) { /* found an entry */ removeUndoEntry(&undoTable, location); @@ -2356,12 +2356,12 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( { char buffer[40]; - aprintf(CYAN, + aprintf(CYAN, MSGNot(" (DEBUG) First transaction start time is %s\n"), UTCTime2Str(firstLRTime,&buffer[0]) ); DBG_DebugPrintf(CYAN, MSGNot("First transaction start time is %s\n"), UTCTime2Str(firstLRTime,&buffer[0]) ); - aprintf(CYAN, + aprintf(CYAN, MSGNot(" (DEBUG) Last transaction start time is %s\n"), UTCTime2Str(lastLRTime,&buffer[0]) ); DBG_DebugPrintf(CYAN, MSGNot("Last transaction start time is %s\n"), @@ -2370,10 +2370,10 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( #endif /* - * Pass 4 of Recovery: REDO : Call redo function for each log - * record. Mark the blocks that should not be redone by filling - * them with zero. - */ + * Pass 4 of Recovery: REDO : Call redo function for each log + * record. Mark the blocks that should not be redone by filling + * them with zero. + */ #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LGREEN, MSGNot("*** PASS 4 ***\n")); #endif @@ -2386,7 +2386,7 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( pool->zp_stats.pass4++; ++numRedos; /* used to be called markFreedBlocks */ - setReplayState(&freeTable, key.ZRK_ZfsXasRecovery); + setReplayState(&freeTable, key.ZRK_ZfsXasRecovery); #if NSS_DEBUG IS_ENABLED blkInfo = ZLOG_START_OF_POOL_BLOCKS(key.ZRK_ZfsXasRecovery); DBG_DebugPrintf(LGREEN, MSGNot("R: %d xid:%x"), @@ -2402,9 +2402,9 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( func = XRecoveryTable[key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex].redo; status = func(genMsg, pool, key.ZRK_ZfsXasRecovery, X_REDO); #if NSS_DEBUG IS_ENABLED - /* Redo/undo routines print P(rocessed) or S(kip) from - * _ALREADY done macro */ - DBG_DebugPrintf(LGREEN, MSGNot("\n")); + /* Redo/undo routines print P(rocessed) or S(kip) from + * _ALREADY done macro */ + DBG_DebugPrintf(LGREEN, MSGNot("\n")); #endif if (status != zOK) { @@ -2423,25 +2423,25 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( ClearErrno(genMsg); /* - * Pass 5 of Recovery: UNDO : Call undo functions. - */ + * Pass 5 of Recovery: UNDO : Call undo functions. + */ #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LGREEN, MSGNot("*** PASS 5 ***\n")); #endif /* FixFixFix6 - We could track numEntries as we hit the START - * record of the transactions being UNDOne. Then when we hit - * zero within the loop below we can stop Pass 5. - */ + * record of the transactions being UNDOne. Then when we hit + * zero within the loop below we can stop Pass 5. + */ if ( undoTable.numEntries > 0 ) { - ZLOG_RecoveryOpen(ZLOG_RECOVERY_END | ZLOG_RECOVERY_NORMAL, - pool, &key); + ZLOG_RecoveryOpen(ZLOG_RECOVERY_END | ZLOG_RECOVERY_NORMAL, + pool, &key); while (ZLOG_RecoveryGet(genMsg, &key, ZLOG_RG_PREVIOUS) == zOK) { zASSERT(key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex < XFUNC_MAX); - if (findUndoEntry(&undoTable, - key.ZRK_ZfsXasRecovery->ZXR_LocalXid) != -1) + if (findUndoEntry(&undoTable, + key.ZRK_ZfsXasRecovery->ZXR_LocalXid) != -1) { /* if this transaction is being undone ...*/ pool->zp_stats.func[key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex].undo++; pool->zp_stats.pass5++; @@ -2461,8 +2461,8 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( (unsigned int)key.ZRK_ZfsXasRecovery->ZXR_LocalXid.unique); for (i = 0; i < key.ZRK_ZfsXasRecovery->ZXR_PoolBlockCount; ++i) { /* for each block in the log record */ - DBG_DebugPrintf(CYAN, MSGNot(" b%d=%x(%x,%x)"), i+1, - blkInfo[i].blkNum, blkInfo[i].logState, + DBG_DebugPrintf(CYAN, MSGNot(" b%d=%x(%x,%x)"), i+1, + blkInfo[i].blkNum, blkInfo[i].logState, blkInfo[i].replayState); } #endif @@ -2476,12 +2476,12 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( { #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LRED, MSGNot( - "UNDO copied: f:%d xid:%x\n"), - key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex, + "UNDO copied: f:%d xid:%x\n"), + key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex, (unsigned int)key.ZRK_ZfsXasRecovery->ZXR_LocalXid.unique); #endif ZLOG_CopyLogicalUndoRecord(zlogBeast, - key.ZRK_ZfsXasRecovery); + key.ZRK_ZfsXasRecovery); numLogicalUndos++; status = zOK; } @@ -2490,12 +2490,12 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( goto errClose; } /* If we are doing a UNDO insert of the free tree, then we - * need to put the blocks on the special list, so that we - * don't reallocate them during other logical undo operations - * and the logical undo of this insert is the one that - * deletes them from the free tree. - */ - if (key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex == + * need to put the blocks on the special list, so that we + * don't reallocate them during other logical undo operations + * and the logical undo of this insert is the one that + * deletes them from the free tree. + */ + if (key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex == XFUNC_FXLOG_L_INSERT) { undoFXinsertLogicalHoldBlks(pool, key.ZRK_ZfsXasRecovery); @@ -2516,15 +2516,15 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( #if NSS_DEBUG IS_ENABLED else { - DBG_DebugPrintf(LGREEN, + DBG_DebugPrintf(LGREEN, MSGNot("*** PASS 5 (skipped no UNDO entries) ***\n")); } #endif /* - * Pass 6 of Recovery: Copy Previous Pass 7 records. - * Greg likes to say Pre-crash Pass 5 records. - */ + * Pass 6 of Recovery: Copy Previous Pass 7 records. + * Greg likes to say Pre-crash Pass 5 records. + */ if (zlogBeast->ZLB_P.ZLBP_CompensationPtrLsn != 0) { #if NSS_DEBUG IS_ENABLED @@ -2534,22 +2534,22 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( // zASSERT(zlogBeast->ZLB_P.ZLBP_LogicalUndoPtrBlkNum != 0); zASSERT(zlogBeast->ZLB_P.ZLBP_CompensationPtrLsn != 0); // zASSERT(zlogBeast->ZLB_P.ZLBP_CompensationPtrBlkNum != 0); - zASSERT(zlogBeast->ZLB_P.ZLBP_LogicalUndoPtrLsn != + zASSERT(zlogBeast->ZLB_P.ZLBP_LogicalUndoPtrLsn != zlogBeast->ZLB_P.ZLBP_CompensationPtrLsn); /* We were in compensation records part of the log when we crashed. - * These records were created while doing logical undo(Pass 7). - * We have just undone in Pass 5 all these comp records. - * Now we need to recopy the logical undo records from the normal - * redo/undo log processing to the recovery active pointer location, so - * the logical undo operation can be redone. - */ + * These records were created while doing logical undo(Pass 7). + * We have just undone in Pass 5 all these comp records. + * Now we need to recopy the logical undo records from the normal + * redo/undo log processing to the recovery active pointer location, so + * the logical undo operation can be redone. + */ ZLOG_RecoveryOpen(ZLOG_RECOVERY_BEGIN | ZLOG_RECOVERY_LOGICAL, - pool, &key); + pool, &key); /* This only gets the logical undo records between - * LUP and COMP pointers. (ASSERT that are only tagged logical - * records between the 2 pointers) - */ + * LUP and COMP pointers. (ASSERT that are only tagged logical + * records between the 2 pointers) + */ while (ZLOG_RecoveryGetLogicalOnly(genMsg, &key, ZLOG_RG_NEXT) == zOK) { zASSERT(key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex < XFUNC_MAX); @@ -2557,32 +2557,32 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( if (key.ZRK_ZfsXasRecovery->ZXR_Lsn <= zlogBeast->ZLB_RecoveryCompensationPointerLsn) { /* This logical undo operation was completed. The transaction - * started by this record was committed. Redo pass above - * ensured that the operation is complete. Since the xaction - * was committed it cannot be undone. So this record will - * not be copied. - */ + * started by this record was committed. Redo pass above + * ensured that the operation is complete. Since the xaction + * was committed it cannot be undone. So this record will + * not be copied. + */ #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LRED, MSGNot( - "LOGICAL UNDO copy skipped: f:%d xid:%x\n"), - key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex, + "LOGICAL UNDO copy skipped: f:%d xid:%x\n"), + key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex, (unsigned int)key.ZRK_ZfsXasRecovery->ZXR_LocalXid.unique); #endif continue; } #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LRED, MSGNot( - "LOGICAL UNDO copied: f:%d xid:%x\n"), - key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex, + "LOGICAL UNDO copied: f:%d xid:%x\n"), + key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex, (unsigned int)key.ZRK_ZfsXasRecovery->ZXR_LocalXid.unique); #endif ZLOG_CopyLogicalUndoRecord(zlogBeast, key.ZRK_ZfsXasRecovery); numLogicalUndos++; /* If we are doing a UNDO insert of the free tree, then we - * need to put the blocks on the special list - */ - if (key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex == + * need to put the blocks on the special list + */ + if (key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex == XFUNC_FXLOG_L_INSERT) { undoFXinsertLogicalHoldBlks(pool, key.ZRK_ZfsXasRecovery); @@ -2609,10 +2609,10 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( defaultFlushWait( &pool->ZFSPOOLmycache.agent); cacheTossAll( &pool->ZFSPOOLmycache); - /* - * CHECKPOINT 1 (physical checkpoint is taken in ZLOG) - */ - if (zlogBeast->ZLB_RecoveryInitialActivePointerLsn != + /* + * CHECKPOINT 1 (physical checkpoint is taken in ZLOG) + */ + if (zlogBeast->ZLB_RecoveryInitialActivePointerLsn != zlogBeast->ZLB_P.ZLBP_ActivePointerLsn) { #if NSS_DEBUG IS_ENABLED @@ -2632,23 +2632,23 @@ STATUS XactionRecoverLogicalUndoPass1To6 ( freeXfreeTable(&freeTable); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LGREEN, + DBG_DebugPrintf(LGREEN, MSGNot(" ** %d(%d) Redo(s), %d(%d) Undo(s), %d Logical Undo(s)\n"), numRedos, numRealRedos, numUndos, numRealUndos, numLogicalUndos ); - aprintf(CYAN, + aprintf(CYAN, MSGNot(" ** (DEBUG) %d Redo(s), %d Undo(s), %d Logical Undo(s)\n"), numRedos, numUndos, numLogicalUndos ); #endif - if ( mode & VOLMODE_VERBOSE ) + if ( mode & VOLMODE_VERBOSE ) { aprintf(NSS_POOL_COLOR, MSG(" ** %d Redo(s), %d Undo(s), %d Logical Undo(s)\n", 431), numRealRedos, numRealUndos, numLogicalUndos ); } /* - * This code is here just to let FTEST report 'useful' information - * when at demos. - */ + * This code is here just to let FTEST report 'useful' information + * when at demos. + */ { ZlogBeast_s *zlog; @@ -2673,7 +2673,7 @@ error: UNX_LATCH( &pool->ZFSPOOLbeastLatch); defaultFlushWait( &pool->ZFSPOOLmycache.agent); cacheTossAll( &pool->ZFSPOOLmycache); - + freeUndoTable(&undoTable); freeXfree: freeXfreeTable(&freeTable); @@ -2697,25 +2697,25 @@ STATUS XactionRecoverLogicalUndoPass7( XRecovery_f func; /* - * Pass 7 of Recovery: Logical Undo. - */ + * Pass 7 of Recovery: Logical Undo. + */ /* This pass will start reading records from the Home pointer/LUP ptr - * and play the logical undo records, creating new redo/undo records - * in the log starting at the Compensation pointer. - */ + * and play the logical undo records, creating new redo/undo records + * in the log starting at the Compensation pointer. + */ /* At this time the log is available to add redo/undo routines - * to it, even while we are reading parts of it. - */ - + * to it, even while we are reading parts of it. + */ + /* Before we can proceed the super beasts have to loaded and the volume - * data has to be read in. - */ + * data has to be read in. + */ - /* This pass is only needed if there are logical undo records to - * process - */ + /* This pass is only needed if there are logical undo records to + * process + */ if (!(zlogBeast->ZLB_State & ZLOG_ZB_S_NEEDTODO_COMPENSATION)) { #if NSS_DEBUG IS_ENABLED @@ -2739,26 +2739,26 @@ STATUS XactionRecoverLogicalUndoPass7( // zASSERT(zlogBeast->ZLB_P.ZLBP_LogicalUndoPtrBlkNum != 0); // zASSERT(zlogBeast->ZLB_P.ZLBP_CompensationPtrBlkNum != 0); zASSERT(zlogBeast->ZLB_P.ZLBP_CompensationPtrLsn != 0); - zASSERT(zlogBeast->ZLB_P.ZLBP_LogicalUndoPtrLsn != + zASSERT(zlogBeast->ZLB_P.ZLBP_LogicalUndoPtrLsn != zlogBeast->ZLB_P.ZLBP_CompensationPtrLsn); #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LGREEN, MSGNot("*** PASS 7 ***\n")); #endif X_LATCH( &zlogBeast->ZFSLOGbeastLatch); - ZLOG_RecoveryOpen(ZLOG_RECOVERY_BEGIN | ZLOG_RECOVERY_LOGICAL, - pool, &key); + ZLOG_RecoveryOpen(ZLOG_RECOVERY_BEGIN | ZLOG_RECOVERY_LOGICAL, + pool, &key); /* This gets only the logical undo records between - * LUP and COMP pointers. (ASSERT that are only tagged logical - * records between the 2 pointers) - */ + * LUP and COMP pointers. (ASSERT that are only tagged logical + * records between the 2 pointers) + */ while (ZLOG_RecoveryGetLogicalOnly(genMsg, &key, ZLOG_RG_NEXT) == zOK) { zASSERT(key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex < XFUNC_MAX); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED, MSGNot("LOGICAL UNDO: f:%d xid:%x\n"), - key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex, + DBG_DebugPrintf(LRED, MSGNot("LOGICAL UNDO: f:%d xid:%x\n"), + key.ZRK_ZfsXasRecovery->ZXR_FunctionIndex, (unsigned int)key.ZRK_ZfsXasRecovery->ZXR_LocalXid.unique); #endif UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch); @@ -2783,13 +2783,13 @@ STATUS XactionRecoverLogicalUndoPass7( ClearErrno(genMsg); status = zOK; - /* - * CHECKPOINT 2 - * - * Wait until compensation records are written to - * disk (ZFSPOOL_CheckpointTake does this (I.E. CHECKPOINT_CT_S_CLEAN - * forces a flush (and wait) of the ZLOG beast)) - */ + /* + * CHECKPOINT 2 + * + * Wait until compensation records are written to + * disk (ZFSPOOL_CheckpointTake does this (I.E. CHECKPOINT_CT_S_CLEAN + * forces a flush (and wait) of the ZLOG beast)) + */ zlogBeast->ZLB_P.ZLBP_LogicalUndoPtrLsn = 0; zlogBeast->ZLB_P.ZLBP_LogicalUndoPtrBlkNum = 0; zlogBeast->ZLB_P.ZLBP_CompensationPtrLsn = 0; @@ -2856,11 +2856,11 @@ typedef struct FreedPoolBlk_s Blknum_t fpb_poolBlk; ZfsVolume_s *fpb_zfsVol; /* MyCache_s fpb_myCache; * The MyCache that the block was - * on at XdeferPoolBlk() time. - */ + * on at XdeferPoolBlk() time. + */ Lsn_t fpb_lsn; /* The LSN for the log record that - * caused the block to be freed. - */ + * caused the block to be freed. + */ ZfsPurgeLogLoc_s fpb_purgeLogLoc; /* The location in the purge log */ } FreedPoolBlk_s; @@ -2879,7 +2879,7 @@ STATUS XDEL_Startup (void) status = CONTROL_Startup( &DeleteControl, ZstoreConfig.zfs.numXdeletes, sizeof(FreedPoolBlk_s), NULL); - + RTN_STATUS(status); } @@ -2973,7 +2973,7 @@ void XqueueDeferredPoolBlks ( * have an lsn that is smaller than the current one. * *************************************************************************/ -void XfreePoolBlks ( +void XfreePoolBlks ( ZfsPool_s *pool, Lsn_t maxLsn) { @@ -3016,18 +3016,18 @@ void XfreePoolBlks ( zASSERT(status == zOK); /* FixFixFix6(Future,Performance) - The TOSS of the buffer - * can occur after COMMIT. This was not done becuase we - * do not track when a transaction COMMITs. Doing the - * TOSS at commit will save us a write if the buffer had - * been dirtyed before it was deleted. - */ - - /* We do not have to TOSS here because the buffer has - * already been written. I.E. for home to move far - * enough for the delete to occur the buffer must of - * been written (if dirty). - */ + * can occur after COMMIT. This was not done becuase we + * do not track when a transaction COMMITs. Doing the + * TOSS at commit will save us a write if the buffer had + * been dirtyed before it was deleted. + */ + /* We do not have to TOSS here because the buffer has + * already been written. I.E. for home to move far + * enough for the delete to occur the buffer must of + * been written (if dirty). + */ + SETUP_BLOCK_FREE_PURGE_LOG(&purgeLogMsg, &xdelete->fpb_purgeLogLoc, 0); //DBG_DebugPrintf(LRED, MSGNot("Removing log entry for block %d.\n"), xdelete->poolBlk); ZFSVOL_VOL_RemovePurgeLogEntry(&genMsg, &xdelete->fpb_zfsVol->ZFSVOLvol, @@ -3049,7 +3049,7 @@ void XfreePoolBlks ( *** value, and user specified length. *** *** This routine is called during Alloc Extent after finding a specific seed - *** value or during find length match to ensure that the blocks being + *** value or during find length match to ensure that the blocks being *** returned as available are not on the list of blocks that cannot yet *** be reassigned. *** @@ -3061,7 +3061,7 @@ void XfreePoolBlks ( ****************************************************************************/ BOOL XACT_blksNotOnFreeList( ZfsPool_s *pool, - Extent_s *nodeExtent, + Extent_s *nodeExtent, Extent_s *requestedExtent) { Blknum_t reqBlk, nodeBlk; @@ -3087,9 +3087,9 @@ BOOL XACT_blksNotOnFreeList( if ((reqBlk != 0) && (reqBlk > nodeBlk) && (reqBlk < (nodeBlk + nodeLen))) { - /** A seed value was specified and the seed value is within the - ** extent that is being processed - **/ + /** A seed value was specified and the seed value is within the + ** extent that is being processed + **/ nodeBlk = reqBlk; nodeLen -= (reqBlk - nodeBlk); } @@ -3098,14 +3098,14 @@ BOOL XACT_blksNotOnFreeList( nodeLen = reqLen; } - DQ_FOREACH(&pool->freeDataBlksList, freeChunk, - FreeUserDataBlks_s, globalListLink) + DQ_FOREACH(&pool->freeDataBlksList, freeChunk, + FreeUserDataBlks_s, globalListLink) { #if FREE_DATA_STATS IS_ENABLED UserFreeStats.freeExtentsProcessed++; #endif - if (((freeChunk->freeExt.poolBlkNum + - freeChunk->freeExt.lengthOfExtent) <= nodeBlk) || + if (((freeChunk->freeExt.poolBlkNum + + freeChunk->freeExt.lengthOfExtent) <= nodeBlk) || (freeChunk->freeExt.poolBlkNum >= (nodeBlk + nodeLen))) { continue; @@ -3135,7 +3135,7 @@ BOOL XACT_blksNotOnFreeList( *** to be able to do logical undos. ****************************************************************************/ STATUS XACT_holdFreeUserDataBlks( - Extent_s *extent, + Extent_s *extent, ZfsXaction_s *xaction) { FreeUserDataBlks_s *free; @@ -3167,7 +3167,7 @@ STATUS XACT_holdFreeUserDataBlks( xaction->numFreeNonusableBlks += free->freeExt.lengthOfExtent; #endif return zOK; - + } @@ -3175,7 +3175,7 @@ STATUS XACT_holdFreeUserDataBlks( *** This routine is called when the xaction ends. At this we remove all *** the user data blks that were freed during this xaction from the global *** list of blks that were freed, but cannot be used until the xaction that - *** freed them has ended. + *** freed them has ended. ****************************************************************************/ STATUS XACT_releaseFreeUserDataBlks( ZfsXaction_s *xaction) @@ -3191,8 +3191,8 @@ STATUS XACT_releaseFreeUserDataBlks( while (DQ_NOT_EMPTY(&xaction->freeUserDataBlks)) { - DQ_DEQ(&xaction->freeUserDataBlks, free, - FreeUserDataBlks_s, xactionLink); + DQ_DEQ(&xaction->freeUserDataBlks, free, + FreeUserDataBlks_s, xactionLink); #if NSS_DEBUG IS_ENABLED zASSERT(FT_ExtentIsStillFree(zfsPool, &free->freeExt) == TRUE); @@ -3282,12 +3282,13 @@ void XDEL_DeactivateVolume(ZfsVolume_s *zfsVol) #if NSS_DEBUG IS_ENABLED #ifdef USER_GPACHNER DBG_DebugPrintf( CYAN, "Dequeue FreedPoolBlk_s %p which contains info on pool block %0xlx(%ld)", - xdelete,xdelete->fpb_poolBlk,xdelete->fpb_poolBlk); + xdelete,xdelete->fpb_poolBlk,xdelete->fpb_poolBlk); aprintf( CYAN, "Dequeue FreedPoolBlk_s %p which contains info on pool block %0xlx(%ld)", - xdelete,xdelete->fpb_poolBlk,xdelete->fpb_poolBlk); + xdelete,xdelete->fpb_poolBlk,xdelete->fpb_poolBlk); #endif #endif CONTROL_FREE(xdelete); } } + diff --git a/src/nwnss/zlss/xaction.h b/src/nwnss/zlss/xaction.h index 12952f8..73fb071 100644 --- a/src/nwnss/zlss/xaction.h +++ b/src/nwnss/zlss/xaction.h @@ -42,7 +42,7 @@ #endif #ifndef _XCACHE_H_ -#include +#include #endif #ifndef _VOLUME_H_ @@ -67,20 +67,20 @@ struct ZfsXasRecovery_s; * becuase ??? */ - /* States for an active transaction. */ + /* States for an active transaction. */ #define X_COMMITTED 0x0001 /* Xaction has been committed */ #define X_PREPARED 0x0002 /* Prepared to commit */ #define X_DONT_COMMIT 0x0004 /* Do not commit */ - /* These are the ZXR_TransactionState defines */ + /* These are the ZXR_TransactionState defines */ #define XAS_XR_TS_START 0x0010 #define XAS_XR_TS_MIDDLE 0x0020 #define XAS_XR_TS_END 0x0040 #define X_REDO_THEN_UNDO 0x0080 /* Debug. Do redo then undo verses - * undo then redo. - */ + * undo then redo. + */ #define XAS_XR_TS_UNDO_LOGICAL_COPY 0x0100 - /* xflags */ + /* xflags */ #define XFLAG_LOGICAL_UNDO 0x0001 #define XFLAG_LOGICAL_UNDO_FREE_TREE_INSERT 0x0002 @@ -88,116 +88,116 @@ struct ZfsXasRecovery_s; #define zX_LOGICAL 0x584c4f47 /*XLOG*/ typedef STATUS (*LogTestCompareFunc_t)( - void *src1, - void *src2, - NINT length); + void *src1, + void *src2, + NINT length); typedef struct LocalXid_t { - LONG unique; /* Unique number -- starts at 1 */ - LONG restartCount; /* Set to RestartCount */ + LONG unique; /* Unique number -- starts at 1 */ + LONG restartCount; /* Set to RestartCount */ } NSS_MEDIA_STRUCTURE(LocalXid_t,restartCount) LocalXid_t; typedef struct ZfsXaction_s { - Xaction_s xaction; /* ZfsXaction_s is derived from Xaction_s */ - Lsn_t ZX_lsn; - /* LSN associated with the first log record - * of this transaction. Protected by ZLOG's - * beastLatch. - */ - LocalXid_t localXid; /* Transaction's ID - unique for all transactions */ + Xaction_s xaction; /* ZfsXaction_s is derived from Xaction_s */ + Lsn_t ZX_lsn; + /* LSN associated with the first log record + * of this transaction. Protected by ZLOG's + * beastLatch. + */ + LocalXid_t localXid; /* Transaction's ID - unique for all transactions */ // void (*signalHomed)(struct Xaction_s *); - /* Who to tell when transaction homed. This routine - * must run as a FSM. The routine can use home.fsm - * to to a FSM LATCH. - */ - struct ZlogBeast_s *ZX_zlogBeast; - /* Filled in at BeginXLocal(). This is for a - * quick/cheap way of accessing ZLOG. Placed in generic - * part of Xaction_s just to get transaction stuff - * working. - */ + /* Who to tell when transaction homed. This routine + * must run as a FSM. The routine can use home.fsm + * to to a FSM LATCH. + */ + struct ZlogBeast_s *ZX_zlogBeast; + /* Filled in at BeginXLocal(). This is for a + * quick/cheap way of accessing ZLOG. Placed in generic + * part of Xaction_s just to get transaction stuff + * working. + */ // struct ZfsPool_s *ZX_zfsPool; /* Pool for transaction */ - struct ZfsVolume_s *ZX_zfsVol; /* Volume for transaction */ - DQlink_t ZX_seniorityList; - /* ZFS transactions are linked by oldest to - * youngest by ZLOG so ZLOG can determine when - * home can be moved. The oldest transaction has - * the lowest LSN, while the youngest transaction - * has the highest LSN. The head of this list is - * stored in the ZlogBeast_s. Concurrent access - * is protected by ZlogBeast_s data latch. - */ - Blknum_t ZX_logBlockNumber; - /* Log block number of first log record of this - * transaction. Protected by ZLOG Beast's - * dataLatch. - */ - DQhead_t ZX_deleteBlkQ; /* Queue of pool blocks to be deleted */ - WORD xstate; /* Current transaction state */ - WORD xflags; /* Current transaction flags */ - DQhead_t freeUserDataBlks; /* Linked list of all the user data blks - * that were freed during this xaction - */ - DQhead_t freePurgeLogEntries; /* Linked list of all purgeLog entries - * that were removed during this xaction - */ - Lsn_t ZX_logicalUndoLSN; - /* LSN associated with the logical undo record - * that initiated this transaction - */ + struct ZfsVolume_s *ZX_zfsVol; /* Volume for transaction */ + DQlink_t ZX_seniorityList; + /* ZFS transactions are linked by oldest to + * youngest by ZLOG so ZLOG can determine when + * home can be moved. The oldest transaction has + * the lowest LSN, while the youngest transaction + * has the highest LSN. The head of this list is + * stored in the ZlogBeast_s. Concurrent access + * is protected by ZlogBeast_s data latch. + */ + Blknum_t ZX_logBlockNumber; + /* Log block number of first log record of this + * transaction. Protected by ZLOG Beast's + * dataLatch. + */ + DQhead_t ZX_deleteBlkQ; /* Queue of pool blocks to be deleted */ + WORD xstate; /* Current transaction state */ + WORD xflags; /* Current transaction flags */ + DQhead_t freeUserDataBlks; /* Linked list of all the user data blks + * that were freed during this xaction + */ + DQhead_t freePurgeLogEntries; /* Linked list of all purgeLog entries + * that were removed during this xaction + */ + Lsn_t ZX_logicalUndoLSN; + /* LSN associated with the logical undo record + * that initiated this transaction + */ #if NSS_DEBUG IS_ENABLED - DQlink_t inuse; /* List of Xactions being used */ - Seq_t timeStamp; /* Time stamp of when this tranaction - * was started. - */ - Seq_t commitStamp; /* Time stamp on commit */ - LONG caller; - LONG callerCaller; - LONG numFreeNonusableBlks; /* This is the count of user data blkd - * that were freed by this transaction, - * but will be available for reuse only - * when the xaction ends - */ + DQlink_t inuse; /* List of Xactions being used */ + Seq_t timeStamp; /* Time stamp of when this tranaction + * was started. + */ + Seq_t commitStamp; /* Time stamp on commit */ + LONG caller; + LONG callerCaller; + LONG numFreeNonusableBlks; /* This is the count of user data blkd + * that were freed by this transaction, + * but will be available for reuse only + * when the xaction ends + */ #endif #if LOG_TEST IS_ENABLED - /* - * Used by test code that makes the code do and immediate - * redo/undo after releasing a log record. - */ - struct Buffer_s *ZX_Buffers[LOG_TEST_MAX]; - LogTestCompareFunc_t ZX_Compare[LOG_TEST_MAX]; + /* + * Used by test code that makes the code do and immediate + * redo/undo after releasing a log record. + */ + struct Buffer_s *ZX_Buffers[LOG_TEST_MAX]; + LogTestCompareFunc_t ZX_Compare[LOG_TEST_MAX]; #endif } ZfsXaction_s; #define BXL_DEFAULT 0 /* Default for storage specific callers - * of BeginXLocal(). Note that this - * define is passed to BeginXLocal() which - * currently is used as the BeginXLocal - * common op function. Therefore, this - * define must adhere to the definition - * of the common op flags. See X_CF... - * defines in comnBeasts.h before changing - * this value. - */ -#define BXL_LOGICAL_UNDO 0x80000000 /* Transaction was started during - * logical undo pass. - */ -#define BXL_LOGICAL_UNDO_FREE_TREE_INSERT 0x40000000 /* Transaction was - * started during - * logical undo of - * free tree insert - */ + * of BeginXLocal(). Note that this + * define is passed to BeginXLocal() which + * currently is used as the BeginXLocal + * common op function. Therefore, this + * define must adhere to the definition + * of the common op flags. See X_CF... + * defines in comnBeasts.h before changing + * this value. + */ +#define BXL_LOGICAL_UNDO 0x80000000 /* Transaction was started during + * logical undo pass. + */ +#define BXL_LOGICAL_UNDO_FREE_TREE_INSERT 0x40000000 /* Transaction was + * started during + * logical undo of + * free tree insert + */ #define SET_LUNDO_LSN(_xaction, _log, _status) \ { \ - (_xaction)->ZX_logicalUndoLSN = (_log)->ZXR_Lsn; \ - if ((_status) != zOK) \ - { \ - (_xaction)->xstate |= X_DONT_COMMIT; \ - } \ + (_xaction)->ZX_logicalUndoLSN = (_log)->ZXR_Lsn; \ + if ((_status) != zOK) \ + { \ + (_xaction)->xstate |= X_DONT_COMMIT; \ + } \ } Xaction_s *ZFSVOL_VOL_beginXLocal(Volume_s *volume, NINT flags); @@ -210,22 +210,22 @@ extern void XdeferPoolBlk(ZfsXaction_s *xaction, Blknum_t poolBlk); extern void freeXaction(ZfsXaction_s *xaction); extern STATUS XactionRecover( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - NINT mode); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + NINT mode); extern STATUS XactionRecoverLogicalUndoPass1To6( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - NINT mode); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + NINT mode); extern STATUS XactionRecoverLogicalUndoPass7( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool); extern void XfreePoolBlks( - struct ZfsPool_s *pool, - Lsn_t maxlsn); + struct ZfsPool_s *pool, + Lsn_t maxlsn); extern STATUS XACT_Startup(void); @@ -236,38 +236,38 @@ void XDEL_DeactivateVolume(struct ZfsVolume_s *zfsVol); extern ControlStore_s FreeUserDataBlksControl; extern STATUS XACT_holdFreeUserDataBlks( - Extent_s *extent, - ZfsXaction_s *xaction); + Extent_s *extent, + ZfsXaction_s *xaction); extern STATUS XACT_releaseFreeUserDataBlks( - ZfsXaction_s *xaction); + ZfsXaction_s *xaction); extern BOOL XACT_blksNotOnFreeList( - ZfsPool_s *pool, - Extent_s *nodeExtent, - Extent_s *reqExtent); + ZfsPool_s *pool, + Extent_s *nodeExtent, + Extent_s *reqExtent); typedef struct FreeUserDataBlks_s { - DQlink_t xactionLink; - DQlink_t globalListLink; - Extent_s freeExt; + DQlink_t xactionLink; + DQlink_t globalListLink; + Extent_s freeExt; } FreeUserDataBlks_s; #if FREE_DATA_STATS IS_ENABLED typedef struct FreeUserDataBlksStats_s { - QUAD listEmpty; /* freeDataBlksList was empty during - * block alloc */ - QUAD listNotEmpty; /* Not empty */ - QUAD retBlockUnAvail; /* The block F-Tree wanted was on - * freeDataBlksList */ - QUAD retBlockAvail; /* Not on list */ - QUAD totalFreeExtents; /* Number of extents placed onto - * freeDataBlksList */ - QUAD freeExtentsProcessed;/* Number of extents searched on - * freeDataBlksList during block alloc */ - QUAD currentFreeExtents; /* Number of extents on freeDataBlksList - * at this moment. */ - QUAD processedNodeTwice; + QUAD listEmpty; /* freeDataBlksList was empty during + * block alloc */ + QUAD listNotEmpty; /* Not empty */ + QUAD retBlockUnAvail; /* The block F-Tree wanted was on + * freeDataBlksList */ + QUAD retBlockAvail; /* Not on list */ + QUAD totalFreeExtents; /* Number of extents placed onto + * freeDataBlksList */ + QUAD freeExtentsProcessed;/* Number of extents searched on + * freeDataBlksList during block alloc */ + QUAD currentFreeExtents; /* Number of extents on freeDataBlksList + * at this moment. */ + QUAD processedNodeTwice; /* All these stats are for 'higher block' logic */ QUAD FUDBS_ListEmpty; /* No blocks on freeDataBlksList */ QUAD FUDBS_Free; /* Able to alloc some of node extent */ @@ -281,48 +281,48 @@ extern FreeUserDataBlksStats_s UserFreeStats; #if FREE_DATA_STATS IS_ENABLED #define BLKS_CAN_BE_ALLOCATED(_pool, _nodeExt, _reqExt) \ - (DQ_EMPTY(&(_pool)->freeDataBlksList) ? (UserFreeStats.listEmpty++,TRUE): \ - XACT_blksNotOnFreeList(_pool, _nodeExt,_reqExt)) + (DQ_EMPTY(&(_pool)->freeDataBlksList) ? (UserFreeStats.listEmpty++,TRUE): \ + XACT_blksNotOnFreeList(_pool, _nodeExt,_reqExt)) #else #define BLKS_CAN_BE_ALLOCATED(_pool, _nodeExt, _reqExt) \ - (DQ_EMPTY(&(_pool)->freeDataBlksList) ? TRUE : \ - XACT_blksNotOnFreeList(_pool, _nodeExt,_reqExt)) + (DQ_EMPTY(&(_pool)->freeDataBlksList) ? TRUE : \ + XACT_blksNotOnFreeList(_pool, _nodeExt,_reqExt)) #endif #define RELEASE_FREE_DATA_BLKS(_xaction) \ - XACT_releaseFreeUserDataBlks(_xaction) + XACT_releaseFreeUserDataBlks(_xaction) #define IS_LOGICAL_UNDO_XACTION(_xaction) \ - ((_xaction != NULL) && (_xaction->xflags & XFLAG_LOGICAL_UNDO)) + ((_xaction != NULL) && (_xaction->xflags & XFLAG_LOGICAL_UNDO)) #define IS_LOGICAL_UNDO_FREE_TREE_INSERT_XACTION(_xaction) \ - ((_xaction != NULL) && \ - (_xaction->xflags & XFLAG_LOGICAL_UNDO) && \ - (_xaction->xflags & XFLAG_LOGICAL_UNDO_FREE_TREE_INSERT)) + ((_xaction != NULL) && \ + (_xaction->xflags & XFLAG_LOGICAL_UNDO) && \ + (_xaction->xflags & XFLAG_LOGICAL_UNDO_FREE_TREE_INSERT)) /* * Macros and functions for manipulating transaction strucutures. */ - /* - * The Transaction Recovery Table is used to find the functions that - * need to called to undoing/redoing transactions. - */ + /* + * The Transaction Recovery Table is used to find the functions that + * need to called to undoing/redoing transactions. + */ #define X_REDO 1 #define X_UNDO 2 #define X_L_UNDO 3 - /* - * Developers will need to make #define's for their respecitive - * recovery functions. These are indexes into an array of - * pointers to functions and MUST be unique. Each #define will - * index 2 functions. One to be called during the Redo pass and - * the other to be called during the Undo pass. - */ + /* + * Developers will need to make #define's for their respecitive + * recovery functions. These are indexes into an array of + * pointers to functions and MUST be unique. Each #define will + * index 2 functions. One to be called during the Redo pass and + * the other to be called during the Undo pass. + */ #define XFUNC_DUMMY 0 /* administrative and Debug */ #define XFUNC_IGNORE 1 /*** If this value changes you need - to re-build the dumpzlog utility ***/ + to re-build the dumpzlog utility ***/ /* beast b-tree */ #define XFUNC_BTREE_INSERT_ZNODE 2 /*used for special systems block only*/ @@ -448,8 +448,8 @@ extern FreeUserDataBlksStats_s UserFreeStats; #define XFUNC_DIRTREE_L_INSERT 90 #define XFUNC_DIRTREE_L_DELETE 91 -/* - * New Purge B-tree is an instance of generic MYBTree +/* + * New Purge B-tree is an instance of generic MYBTree * 3 for interface operations * 6 for internal operations * All numbers from 92 to 101 are in use! @@ -460,7 +460,7 @@ extern FreeUserDataBlksStats_s UserFreeStats; #define XFUNC_PTREE_INTERNAL_OP_END 101 /* 95 + 7 - 1 */ /*************************************************************************** - * "XFUNC_PTREE_LOGICAL_OP_START + MYBT_RECOVERY_L_OP_INSERT_ENTRY" 92 + * "XFUNC_PTREE_LOGICAL_OP_START + MYBT_RECOVERY_L_OP_INSERT_ENTRY" 92 * "XFUNC_PTREE_LOGICAL_OP_START + MYBT_RECOVERY_L_OP_DELETE_ENTRY" 93 * "XFUNC_PTREE_LOGICAL_OP_START + MYBT_RECOVERY_L_OP_MODIFY_ENTRY" 94 * "XFUNC_PTREE_INTERNAL_OP_START + MYBT_RECOVERY_OP_SPLIT" 95 @@ -472,8 +472,8 @@ extern FreeUserDataBlksStats_s UserFreeStats; * "XFUNC_PTREE_INTERNAL_OP_START + MYBT_RECOVERY_OP_REMOVE_NODE" 101 ****************************************************************************/ -/* - * MFL B-tree: an instance of generic MYBTree +/* + * MFL B-tree: an instance of generic MYBTree * 3 for interface operations * 6 for internal operations * All numbers from 102 to 111 are in use! @@ -512,7 +512,7 @@ extern FreeUserDataBlksStats_s UserFreeStats; #define XFUNC_UTREE_DELETE_NAME 121 /* Event File List operations */ -#define XFUNC_EFLTREE_SPLIT 122 +#define XFUNC_EFLTREE_SPLIT 122 #define XFUNC_EFLTREE_JOIN 123 #define XFUNC_EFLTREE_BALANCE 124 #define XFUNC_EFLTREE_GROW 125 @@ -535,7 +535,7 @@ extern FreeUserDataBlksStats_s UserFreeStats; * logging operations. Logical undo functionality and rules need to * be considered. Redo routines have to be physical, undo routines * physical and/or logical. Then change #if on #error below to match new max - */ + */ /* @@ -550,20 +550,20 @@ extern FreeUserDataBlksStats_s UserFreeStats; * logging operations. Logical undo functionality and rules need to * be considered. Redo routines have to be physical, undo routines * physical and/or logical. Then change above #if to match new max - */ + */ #error You did not read (or follow) the above comment!!! #endif typedef STATUS (*XRecovery_f)( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logRecord, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logRecord, + NINT pass); typedef struct RedoUndo_s { - XRecovery_f redo; - XRecovery_f undo; + XRecovery_f redo; + XRecovery_f undo; } RedoUndo_s; #define BLOCK_TABLE_ALLOC_SIZE 4//256 /* number of block entries in each allocation. */ @@ -572,30 +572,30 @@ typedef struct RedoUndo_s #define INITIAL_UTABLE_SIZE 4//64 /* Initial number of uncommitted entries. */ #define INITIAL_UNDO_TABLE_SIZE 4//128 /* Initial number of uncommitted entries. */ #define XTABLE_GROWTH_FACTOR 4 /* Factor we grow by when we have - * to grow the table. - */ + * to grow the table. + */ extern RedoUndo_s XRecoveryTable[XFUNC_MAX]; - /* - * The undo table holds entries we know need to be undone later. - */ + /* + * The undo table holds entries we know need to be undone later. + */ typedef struct UndoTable_s { - NINT size; /* current size of the table */ - NINT numEntries; /* number of entries in the table */ - LocalXid_t *xids; /* pointer to the first entry */ + NINT size; /* current size of the table */ + NINT numEntries; /* number of entries in the table */ + LocalXid_t *xids; /* pointer to the first entry */ } UndoTable_s; - /* - * The uncommitted table holds entries we know are uncommitted until we - * can process them against the transaction table. - */ + /* + * The uncommitted table holds entries we know are uncommitted until we + * can process them against the transaction table. + */ typedef struct UncommittedTable_s { - NINT size; /* current size of the table */ - NINT numEntries; /* number of entries in the table */ - LocalXid_t *xids; /* pointer to the first entry */ + NINT size; /* current size of the table */ + NINT numEntries; /* number of entries in the table */ + LocalXid_t *xids; /* pointer to the first entry */ } UncommittedTable_s; // /* @@ -615,81 +615,81 @@ typedef struct UncommittedTable_s // DeletedBlockEntry_s *entry; /* pointer to the first entry */ //} DeletedBlockTable_s; - /* - * The block table holds an entry for blocks associated with a transaction. - * The blocks are linked off from a transaction. - */ + /* + * The block table holds an entry for blocks associated with a transaction. + * The blocks are linked off from a transaction. + */ typedef struct BlockNumberEntry_s { - STKlink_t link; /* link to next block number entry for this xaction */ - Blknum_t block; + STKlink_t link; /* link to next block number entry for this xaction */ + Blknum_t block; // NINT generation; - WORD sequence; + WORD sequence; // WORD state; /* log state */ } BlockNumberEntry_s; typedef struct BlockTableMem_s { - STKlink_t nextMem; /* link to the next memory block */ - BlockNumberEntry_s entry[BLOCK_TABLE_ALLOC_SIZE]; /* space for block info */ + STKlink_t nextMem; /* link to the next memory block */ + BlockNumberEntry_s entry[BLOCK_TABLE_ALLOC_SIZE]; /* space for block info */ } BlockTableMem_s; typedef struct BlockTable_s { - STKtop_t availList; /* start of the linked list of available entries*/ - STKtop_t memList; /* a linked list of the memory use to hold blocks */ + STKtop_t availList; /* start of the linked list of available entries*/ + STKtop_t memList; /* a linked list of the memory use to hold blocks */ } BlockTable_s; - /* - * Transaction table used during recovery. It is designed to be - * dynamically grown during recovery. It keeps track of which - * transactions have not been committed. - */ + /* + * Transaction table used during recovery. It is designed to be + * dynamically grown during recovery. It keeps track of which + * transactions have not been committed. + */ typedef struct XactionTableEntry_s { - NINT state; - LocalXid_t xid; - STKtop_t blockList; /* head of linked list in block table */ + NINT state; + LocalXid_t xid; + STKtop_t blockList; /* head of linked list in block table */ } XactionTableEntry_s; - /* State values of XactionTableEntry */ + /* State values of XactionTableEntry */ #define XTE_COMMITTED 0x01 #define XTE_COMPLETED 0x02 typedef struct XactTable_s { - NINT size; /* Current size of the transaction table */ - NINT numEntries; /* number of entries in the table */ - NINT numUncommittedEntries; - /* After PASS 1 numUncommittedEntries is the number - * of transactions that are not committed. - * During PASS 2 the count is decremented as the - * uncommitted transaction is removed from this - * table. This occurs when PASS 2 hits the - * transaction start log record (PASS 2 is a - * backwards search). This count is incremented - * during PASS 2 when a committed xaction is - * convertted to an uncommitted xaction because - * of matching block numbers. When the count - * reaches 0 we are done with PASS 2. If it - * does not reach 0 before reaching the end of - * the expanded ZLOG search it means we can not - * recovery successfully. - */ + NINT size; /* Current size of the transaction table */ + NINT numEntries; /* number of entries in the table */ + NINT numUncommittedEntries; + /* After PASS 1 numUncommittedEntries is the number + * of transactions that are not committed. + * During PASS 2 the count is decremented as the + * uncommitted transaction is removed from this + * table. This occurs when PASS 2 hits the + * transaction start log record (PASS 2 is a + * backwards search). This count is incremented + * during PASS 2 when a committed xaction is + * convertted to an uncommitted xaction because + * of matching block numbers. When the count + * reaches 0 we are done with PASS 2. If it + * does not reach 0 before reaching the end of + * the expanded ZLOG search it means we can not + * recovery successfully. + */ #if NSS_DEBUG IS_ENABLED - Time_t xactionTime; /* UTC when transaction recorded */ + Time_t xactionTime; /* UTC when transaction recorded */ #endif - XactionTableEntry_s *xEntry; /* Space for allocation */ + XactionTableEntry_s *xEntry; /* Space for allocation */ } XactTable_s; - /* - * Table of blocks freed in log. It keeps track - * of the blocks we can't apply transactions because - * the block was later freed and may have been reallocated. - */ + /* + * Table of blocks freed in log. It keeps track + * of the blocks we can't apply transactions because + * the block was later freed and may have been reallocated. + */ typedef struct XfreedBlk_s { - Blknum_t poolBlk; /* Pool block deleted */ + Blknum_t poolBlk; /* Pool block deleted */ // The LSN is commented out because: // we should not need to check for allocated blocks because a deleted block // should not be reallocated until it is no longer affected by the log. @@ -697,12 +697,12 @@ typedef struct XfreedBlk_s // * using this log. // */ } XfreedBlk_s; - + typedef struct XfreeTable_s { - NINT size; /* Current size of the freed block table */ - NINT free; /* Where free space starts */ - XfreedBlk_s *blks; /* Space for allocation */ + NINT size; /* Current size of the freed block table */ + NINT free; /* Where free space starts */ + XfreedBlk_s *blks; /* Space for allocation */ } XfreeTable_s; /************************************************************************ @@ -710,344 +710,344 @@ typedef struct XfreeTable_s ************************************************************************/ extern STATUS recoveryInsertZnode( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryDeleteZnode( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryInsertZnodeLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryDeleteZnodeLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoverySplit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryJoin( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryBalance( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryInsertOverflow( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryRemoveOverflow( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryGrow( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryShrink( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryVDBInit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryVDBUninit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryLVDBInit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryLVDBUninit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryInit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryUninit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS redoInitRoot( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoInitRoot( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFmapInsert( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFmapInsert( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFmapInsertSparse( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFmapInsertSparse( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFmapGrow( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFmapGrow( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFmapSplit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFmapSplit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFmapRemove( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFmapRemove( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFmapJoin( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFmapJoin( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFmapToss( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFmapToss( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS recoveryPurgeLogInit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS recoveryPurgeLogUninit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS recoveryPurgeLogGrow( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS recoveryPurgeLogShrink( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS recoveryPurgeLogInsert( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS recoveryPurgeLogRemove( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFXshrink( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFXshrink( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFXdelete( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFXdelete( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFXdeleteLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFXbalance( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFXbalance( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFXjoin( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFXjoin( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFXgrow( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFXgrow( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFXsplit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFXsplit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoFXinsert( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFXinsert( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoFXinsertLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern void undoFXinsertLogicalHoldBlks( - struct ZfsPool_s *zfspool, - struct ZfsXasRecovery_s *logBuffer); + struct ZfsPool_s *zfspool, + struct ZfsXasRecovery_s *logBuffer); extern STATUS recoveryVolumeInfo( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); /* Name B-Tree recovery routines */ extern STATUS dlog_recovery_common( @@ -1064,605 +1064,605 @@ extern STATUS dlog_logical_recovery_common( #ifdef NSSOLD_NAMING extern STATUS redoNameInit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoNameInit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS addNameToDir( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS removeNameFromDir( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS redoModifyNSMask( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); extern STATUS undoModifyNSMask( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT pass); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT pass); #endif /* Old Purge B-Tree recovery routines */ extern STATUS pbt_recoveryInsertEntry( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS pbt_recoveryDeleteEntry( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); /* Not yet being used */ extern STATUS pbt_recoveryInsertEntryLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); /* Not yet being used */ extern STATUS pbt_recoveryDeleteEntryLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS pbt_recoverySplit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS pbt_recoveryJoin( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS pbt_recoveryBalance( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS pbt_recoveryInsertOverflow( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS pbt_recoveryRemoveOverflow( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS pbt_recoveryGrow( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS pbt_recoveryShrink( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS pbt_recoveryInit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS pbt_recoveryUninit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); /* New Purge B-Tree recovery routines */ extern STATUS pbt_internalRecoveryCommon( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS pbt_logicalRecoveryCommon( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); /* User B-Tree recovery routines */ extern STATUS UBT_recoveryInit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryUninit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryShrink( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryGrow( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryBalance( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryJoin( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoverySplit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryInsertEntry( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryDeleteEntry( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryModifyEntry( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryRemove( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryModifyName( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryAddNameRecord( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryDeleteNameRecord( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryInsertNameRecord( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryRemoveNameRecord( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryAddName( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryInsertEntryLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryDeleteEntryLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryModifyEntryLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryModifyNameLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryDeleteNameLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryModifyNameEntry( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryModifyNameEntryLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryDeleteAll( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryAddAll( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryDeleteName( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS UBT_recoveryAddOnlyName( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); STATUS ZLSSPOOL_RecoverySuperblockHeader( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); STATUS ZLSSPOOL_RecoveryPoolInfo( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); STATUS ZLSSVOL_LVD_RecoveryBTShrink( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); STATUS ZLSSVOL_LVD_RecoveryBTShrinkRoot( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); STATUS ZLSSVOL_LVD_RecoveryNTShrink( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryPDBInit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryPDBUninit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryLPDBInit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS recoveryLPDBUninit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); STATUS recoveryVDBUpdate( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); /* MFL recovery routine */ extern STATUS MFL_internalRecoveryCommon( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS MFL_logicalRecoveryCommon( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); /* EFL recovery routines */ extern STATUS EFL_recoverySplit ( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryJoin ( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryBalance ( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryGrow ( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryShrink ( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryInit ( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryUninit ( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryInsertEntry ( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryDeleteEntryLogical ( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryDeleteEntry ( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryInsertEntryLogical ( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryModifyEntry ( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryModifyEntryLogical ( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryRemove( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS EFL_recoveryRemoveLog( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS ELOG_recoveryAddNode( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS ELOG_recoveryAddNodeUndo( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS ELOG_recoveryAddEntry( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS ELOG_recoveryRemoveEntryLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS ELOG_recoveryAddEntryName( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS ELOG_recoveryRemoveEntryNameLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS ELOG_recoveryRemoveNode( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS ELOG_recoveryRemoveNodeUndo( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS ELOG_recoveryModifyEpoch( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); /* Directory Tree routines */ extern STATUS DBT_recoveryInit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS DBT_recoveryUninit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS DBT_recoveryShrink( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS DBT_recoveryGrow( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS DBT_recoveryBalance( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS DBT_recoveryJoin( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS DBT_recoverySplit( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS DBT_recoveryInsertEntry( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS DBT_recoveryDeleteEntry( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS DBT_recoveryModifyEntry( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS DBT_recoveryInsertEntryLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS DBT_recoveryDeleteEntryLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS DBT_recoveryModifyEntryLogical( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); extern STATUS DBT_recoveryRemove( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); #endif diff --git a/src/nwnss/zlss/z_aes.h b/src/nwnss/zlss/z_aes.h index f8e39c7..908c859 100644 --- a/src/nwnss/zlss/z_aes.h +++ b/src/nwnss/zlss/z_aes.h @@ -7,7 +7,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -64,12 +64,6 @@ #define AES_MAXNR 14 #define AES_BLOCK_SIZE 16 -#if defined(NSS_USERSPACE) && !defined(NSS_ZLSS_U32_DEFINED) -#include -typedef uint32_t u32; -#define NSS_ZLSS_U32_DEFINED 1 -#endif - #ifdef __cplusplus extern "C" { #endif @@ -77,7 +71,7 @@ extern "C" { /* This should be a hidden type, but EVP requires that the size be known */ struct aes_key_st { // unsigned long rd_key[4 *(AES_MAXNR + 1)]; - u32 rd_key[4 *(AES_MAXNR + 1)]; + u32 rd_key[4 *(AES_MAXNR + 1)]; int rounds; }; typedef struct aes_key_st AES_KEY; @@ -85,31 +79,31 @@ typedef struct aes_key_st AES_KEY; const char *AES_options(void); int AES_set_encrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key); + AES_KEY *key); int AES_set_decrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key); + AES_KEY *key); void AES_encrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key); + const AES_KEY *key); void AES_decrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key); + const AES_KEY *key); void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key, const int enc); + const AES_KEY *key, const int enc); void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, - const unsigned long length, const AES_KEY *key, - unsigned char *ivec, const int enc); + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, const int enc); void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, - const unsigned long length, const AES_KEY *key, - unsigned char *ivec, int *num, const int enc); + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, - const unsigned long length, const AES_KEY *key, - unsigned char *ivec, int *num); + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num); void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, - const unsigned long length, const AES_KEY *key, - unsigned char ivec[AES_BLOCK_SIZE], - unsigned char ecount_buf[AES_BLOCK_SIZE], - unsigned int *num); + const unsigned long length, const AES_KEY *key, + unsigned char ivec[AES_BLOCK_SIZE], + unsigned char ecount_buf[AES_BLOCK_SIZE], + unsigned int *num); #ifdef __cplusplus diff --git a/src/nwnss/zlss/z_aes_cbc.c b/src/nwnss/zlss/z_aes_cbc.c new file mode 100644 index 0000000..7477adf --- /dev/null +++ b/src/nwnss/zlss/z_aes_cbc.c @@ -0,0 +1,113 @@ +/* crypto/aes/aes_cbc.c -*- mode:C; c-file-style: "eay" -*- */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + */ + +#ifndef AES_DEBUG +# ifndef NDEBUG +# define NDEBUG +# endif +#endif +//#include /* Removed by Brenda */ + +//#include /* Removed by Brenda */ +#include +#include "z_aes.h" /* Added by Brenda */ +#include "z_aes_locl.h" + +void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, const int enc) { + + unsigned long n; + unsigned long len = length; + unsigned char tmp[AES_BLOCK_SIZE]; + +// assert(in && out && key && ivec); /* Removed by Brenda */ +// assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc)); /* Removed by Brenda */ + + if (AES_ENCRYPT == enc) { + while (len >= AES_BLOCK_SIZE) { + for(n=0; n < AES_BLOCK_SIZE; ++n) + tmp[n] = in[n] ^ ivec[n]; + AES_encrypt(tmp, out, key); + memcpy(ivec, out, AES_BLOCK_SIZE); + len -= AES_BLOCK_SIZE; + in += AES_BLOCK_SIZE; + out += AES_BLOCK_SIZE; + } + if (len) { + for(n=0; n < len; ++n) + tmp[n] = in[n] ^ ivec[n]; + for(n=len; n < AES_BLOCK_SIZE; ++n) + tmp[n] = ivec[n]; + AES_encrypt(tmp, tmp, key); + memcpy(out, tmp, AES_BLOCK_SIZE); + memcpy(ivec, tmp, AES_BLOCK_SIZE); + } + } else { + while (len >= AES_BLOCK_SIZE) { + memcpy(tmp, in, AES_BLOCK_SIZE); + AES_decrypt(in, out, key); + for(n=0; n < AES_BLOCK_SIZE; ++n) + out[n] ^= ivec[n]; + memcpy(ivec, tmp, AES_BLOCK_SIZE); + len -= AES_BLOCK_SIZE; + in += AES_BLOCK_SIZE; + out += AES_BLOCK_SIZE; + } + if (len) { + memcpy(tmp, in, AES_BLOCK_SIZE); + AES_decrypt(tmp, tmp, key); + for(n=0; n < len; ++n) + out[n] = tmp[n] ^ ivec[n]; + memcpy(ivec, tmp, AES_BLOCK_SIZE); + } + } +} diff --git a/src/nwnss/zlss/z_aes_core.c b/src/nwnss/zlss/z_aes_core.c new file mode 100644 index 0000000..1d7ec37 --- /dev/null +++ b/src/nwnss/zlss/z_aes_core.c @@ -0,0 +1,1260 @@ +/* crypto/aes/aes_core.c -*- mode:C; c-file-style: "eay" -*- */ +/** + * rijndael-alg-fst.c + * + * @version 3.0 (December 2000) + * + * Optimised ANSI C code for the Rijndael cipher (now AES) + * + * @author Vincent Rijmen + * @author Antoon Bosselaers + * @author Paulo Barreto + * + * This code is hereby placed in the public domain. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Note: rewritten a little bit to provide error control and an OpenSSL- + compatible API */ + +#ifndef AES_DEBUG +# ifndef NDEBUG +# define NDEBUG +# endif +#endif +//#include /* Removed by Brenda */ + +#include +#include +#include +//#include /* Removed by Brenda */ +#include "z_aes.h" /* Added by Brenda */ +#include "z_aes_locl.h" + +/* +Te0[x] = S [x].[02, 01, 01, 03]; +Te1[x] = S [x].[03, 02, 01, 01]; +Te2[x] = S [x].[01, 03, 02, 01]; +Te3[x] = S [x].[01, 01, 03, 02]; +Te4[x] = S [x].[01, 01, 01, 01]; + +Td0[x] = Si[x].[0e, 09, 0d, 0b]; +Td1[x] = Si[x].[0b, 0e, 09, 0d]; +Td2[x] = Si[x].[0d, 0b, 0e, 09]; +Td3[x] = Si[x].[09, 0d, 0b, 0e]; +Td4[x] = Si[x].[01, 01, 01, 01]; +*/ + +static const u32 Te0[256] = { + 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, + 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, + 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, + 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU, + 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U, + 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU, + 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU, + 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU, + 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU, + 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU, + 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U, + 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU, + 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU, + 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U, + 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU, + 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU, + 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU, + 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU, + 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU, + 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U, + 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU, + 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU, + 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU, + 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU, + 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U, + 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U, + 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U, + 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U, + 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU, + 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U, + 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U, + 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU, + 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU, + 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U, + 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U, + 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U, + 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU, + 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U, + 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU, + 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U, + 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU, + 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U, + 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U, + 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU, + 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U, + 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U, + 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U, + 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U, + 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U, + 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U, + 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U, + 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U, + 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU, + 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U, + 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U, + 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U, + 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U, + 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U, + 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U, + 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU, + 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U, + 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U, + 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, + 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, +}; +static const u32 Te1[256] = { + 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU, + 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U, + 0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU, + 0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U, + 0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU, + 0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U, + 0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU, + 0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U, + 0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U, + 0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU, + 0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U, + 0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U, + 0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U, + 0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU, + 0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U, + 0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U, + 0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU, + 0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U, + 0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U, + 0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U, + 0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU, + 0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU, + 0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U, + 0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU, + 0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU, + 0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U, + 0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU, + 0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U, + 0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU, + 0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U, + 0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U, + 0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U, + 0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU, + 0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U, + 0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU, + 0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U, + 0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU, + 0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U, + 0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U, + 0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU, + 0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU, + 0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU, + 0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U, + 0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U, + 0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU, + 0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U, + 0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU, + 0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U, + 0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU, + 0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U, + 0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU, + 0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU, + 0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U, + 0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU, + 0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U, + 0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU, + 0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U, + 0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U, + 0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U, + 0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU, + 0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU, + 0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U, + 0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU, + 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U, +}; +static const u32 Te2[256] = { + 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU, + 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U, + 0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU, + 0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U, + 0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU, + 0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U, + 0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU, + 0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U, + 0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U, + 0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU, + 0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U, + 0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U, + 0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U, + 0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU, + 0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U, + 0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U, + 0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU, + 0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U, + 0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U, + 0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U, + 0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU, + 0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU, + 0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U, + 0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU, + 0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU, + 0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U, + 0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU, + 0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U, + 0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU, + 0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U, + 0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U, + 0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U, + 0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU, + 0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U, + 0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU, + 0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U, + 0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU, + 0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U, + 0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U, + 0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU, + 0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU, + 0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU, + 0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U, + 0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U, + 0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU, + 0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U, + 0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU, + 0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U, + 0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU, + 0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U, + 0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU, + 0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU, + 0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U, + 0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU, + 0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U, + 0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU, + 0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U, + 0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U, + 0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U, + 0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU, + 0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU, + 0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U, + 0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU, + 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U, +}; +static const u32 Te3[256] = { + + 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U, + 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U, + 0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U, + 0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU, + 0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU, + 0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU, + 0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U, + 0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU, + 0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU, + 0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U, + 0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U, + 0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU, + 0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU, + 0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU, + 0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU, + 0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU, + 0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U, + 0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU, + 0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU, + 0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U, + 0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U, + 0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U, + 0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U, + 0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U, + 0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU, + 0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U, + 0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU, + 0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU, + 0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U, + 0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U, + 0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U, + 0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU, + 0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U, + 0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU, + 0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU, + 0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U, + 0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U, + 0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU, + 0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U, + 0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU, + 0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U, + 0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U, + 0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U, + 0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U, + 0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU, + 0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U, + 0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU, + 0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U, + 0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU, + 0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U, + 0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU, + 0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU, + 0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU, + 0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU, + 0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U, + 0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U, + 0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U, + 0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U, + 0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U, + 0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U, + 0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU, + 0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U, + 0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU, + 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU, +}; +static const u32 Te4[256] = { + 0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU, + 0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U, + 0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU, + 0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U, + 0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU, + 0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U, + 0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU, + 0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U, + 0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U, + 0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU, + 0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U, + 0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U, + 0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U, + 0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU, + 0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U, + 0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U, + 0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU, + 0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U, + 0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U, + 0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U, + 0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU, + 0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU, + 0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U, + 0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU, + 0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU, + 0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U, + 0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU, + 0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U, + 0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU, + 0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U, + 0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U, + 0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U, + 0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU, + 0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U, + 0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU, + 0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U, + 0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU, + 0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U, + 0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U, + 0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU, + 0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU, + 0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU, + 0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U, + 0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U, + 0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU, + 0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U, + 0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU, + 0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U, + 0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU, + 0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U, + 0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU, + 0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU, + 0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U, + 0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU, + 0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U, + 0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU, + 0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U, + 0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U, + 0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U, + 0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU, + 0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU, + 0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U, + 0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU, + 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U, +}; +static const u32 Td0[256] = { + 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, + 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, + 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, + 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU, + 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U, + 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U, + 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU, + 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U, + 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU, + 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U, + 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U, + 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U, + 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U, + 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU, + 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U, + 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU, + 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U, + 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU, + 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U, + 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U, + 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U, + 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU, + 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U, + 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU, + 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U, + 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU, + 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U, + 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU, + 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU, + 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U, + 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU, + 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U, + 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU, + 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U, + 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U, + 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U, + 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU, + 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U, + 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U, + 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU, + 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U, + 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U, + 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U, + 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U, + 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U, + 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU, + 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U, + 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U, + 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U, + 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U, + 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U, + 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU, + 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU, + 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU, + 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU, + 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U, + 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U, + 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU, + 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU, + 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U, + 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU, + 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U, + 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, + 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, +}; +static const u32 Td1[256] = { + 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU, + 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U, + 0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU, + 0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U, + 0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U, + 0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U, + 0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U, + 0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U, + 0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U, + 0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU, + 0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU, + 0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU, + 0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U, + 0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU, + 0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U, + 0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U, + 0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U, + 0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU, + 0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU, + 0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U, + 0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU, + 0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U, + 0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU, + 0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU, + 0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U, + 0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U, + 0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U, + 0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU, + 0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U, + 0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU, + 0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U, + 0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U, + 0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U, + 0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU, + 0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U, + 0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U, + 0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U, + 0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U, + 0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U, + 0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U, + 0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU, + 0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU, + 0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U, + 0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU, + 0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U, + 0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU, + 0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU, + 0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U, + 0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU, + 0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U, + 0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U, + 0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U, + 0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U, + 0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U, + 0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U, + 0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U, + 0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU, + 0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U, + 0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U, + 0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU, + 0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U, + 0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U, + 0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U, + 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U, +}; +static const u32 Td2[256] = { + 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U, + 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U, + 0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U, + 0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U, + 0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU, + 0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U, + 0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U, + 0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U, + 0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U, + 0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU, + 0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U, + 0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U, + 0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU, + 0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U, + 0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U, + 0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U, + 0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U, + 0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U, + 0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U, + 0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU, + + 0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U, + 0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U, + 0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U, + 0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U, + 0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U, + 0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU, + 0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU, + 0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U, + 0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU, + 0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U, + 0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU, + 0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU, + 0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU, + 0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU, + 0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U, + 0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U, + 0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U, + 0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U, + 0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U, + 0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U, + 0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U, + 0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU, + 0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU, + 0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U, + 0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U, + 0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU, + 0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU, + 0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U, + 0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U, + 0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U, + 0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U, + 0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U, + 0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U, + 0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U, + 0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU, + 0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U, + 0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U, + 0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U, + 0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U, + 0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U, + 0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U, + 0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU, + 0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U, + 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U, +}; +static const u32 Td3[256] = { + 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU, + 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU, + 0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U, + 0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U, + 0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU, + 0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU, + 0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U, + 0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU, + 0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U, + 0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU, + 0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U, + 0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U, + 0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U, + 0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U, + 0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U, + 0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU, + 0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU, + 0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U, + 0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U, + 0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU, + 0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU, + 0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U, + 0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U, + 0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U, + 0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U, + 0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU, + 0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U, + 0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U, + 0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU, + 0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU, + 0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U, + 0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U, + 0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U, + 0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU, + 0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U, + 0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U, + 0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U, + 0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U, + 0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U, + 0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U, + 0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U, + 0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU, + 0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U, + 0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U, + 0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU, + 0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU, + 0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U, + 0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU, + 0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U, + 0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U, + 0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U, + 0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U, + 0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U, + 0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U, + 0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU, + 0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU, + 0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU, + 0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU, + 0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U, + 0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U, + 0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U, + 0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU, + 0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U, + 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U, +}; +static const u32 Td4[256] = { + 0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U, + 0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U, + 0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU, + 0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU, + 0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U, + 0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U, + 0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U, + 0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU, + 0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U, + 0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU, + 0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU, + 0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU, + 0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U, + 0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U, + 0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U, + 0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U, + 0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U, + 0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U, + 0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU, + 0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U, + 0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U, + 0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU, + 0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U, + 0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U, + 0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U, + 0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU, + 0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U, + 0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U, + 0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU, + 0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U, + 0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U, + 0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU, + 0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U, + 0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU, + 0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU, + 0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U, + 0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U, + 0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U, + 0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U, + 0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU, + 0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U, + 0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U, + 0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU, + 0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU, + 0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU, + 0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U, + 0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU, + 0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U, + 0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U, + 0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U, + 0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U, + 0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU, + 0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U, + 0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU, + 0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU, + 0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU, + 0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU, + 0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U, + 0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU, + 0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U, + 0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU, + 0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U, + 0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U, + 0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU, +}; +static const u32 rcon[] = { + 0x01000000, 0x02000000, 0x04000000, 0x08000000, + 0x10000000, 0x20000000, 0x40000000, 0x80000000, + 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ +}; + +/** + * Expand the cipher key into the encryption key schedule. + */ +int AES_set_encrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key) { + + u32 *rk; + int i = 0; + u32 temp; + + if (!userKey || !key) + return -1; + if (bits != 128 && bits != 192 && bits != 256) + return -2; + + rk = key->rd_key; + + if (bits==128) + key->rounds = 10; + else if (bits==192) + key->rounds = 12; + else + key->rounds = 14; + + rk[0] = GETU32(userKey ); + rk[1] = GETU32(userKey + 4); + rk[2] = GETU32(userKey + 8); + rk[3] = GETU32(userKey + 12); + if (bits == 128) { + while (1) { + temp = rk[3]; + rk[4] = rk[0] ^ + (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ + (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ + (Te4[(temp ) & 0xff] & 0x0000ff00) ^ + (Te4[(temp >> 24) ] & 0x000000ff) ^ + rcon[i]; + rk[5] = rk[1] ^ rk[4]; + rk[6] = rk[2] ^ rk[5]; + rk[7] = rk[3] ^ rk[6]; + if (++i == 10) { + return 0; + } + rk += 4; + } + } + rk[4] = GETU32(userKey + 16); + rk[5] = GETU32(userKey + 20); + if (bits == 192) { + while (1) { + temp = rk[ 5]; + rk[ 6] = rk[ 0] ^ + (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ + (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ + (Te4[(temp ) & 0xff] & 0x0000ff00) ^ + (Te4[(temp >> 24) ] & 0x000000ff) ^ + rcon[i]; + rk[ 7] = rk[ 1] ^ rk[ 6]; + rk[ 8] = rk[ 2] ^ rk[ 7]; + rk[ 9] = rk[ 3] ^ rk[ 8]; + if (++i == 8) { + return 0; + } + rk[10] = rk[ 4] ^ rk[ 9]; + rk[11] = rk[ 5] ^ rk[10]; + rk += 6; + } + } + rk[6] = GETU32(userKey + 24); + rk[7] = GETU32(userKey + 28); + if (bits == 256) { + while (1) { + temp = rk[ 7]; + rk[ 8] = rk[ 0] ^ + (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ + (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ + (Te4[(temp ) & 0xff] & 0x0000ff00) ^ + (Te4[(temp >> 24) ] & 0x000000ff) ^ + rcon[i]; + rk[ 9] = rk[ 1] ^ rk[ 8]; + rk[10] = rk[ 2] ^ rk[ 9]; + rk[11] = rk[ 3] ^ rk[10]; + if (++i == 7) { + return 0; + } + temp = rk[11]; + rk[12] = rk[ 4] ^ + (Te4[(temp >> 24) ] & 0xff000000) ^ + (Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(temp >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(temp ) & 0xff] & 0x000000ff); + rk[13] = rk[ 5] ^ rk[12]; + rk[14] = rk[ 6] ^ rk[13]; + rk[15] = rk[ 7] ^ rk[14]; + + rk += 8; + } + } + return 0; +} + +/** + * Expand the cipher key into the decryption key schedule. + */ +int AES_set_decrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key) { + + u32 *rk; + int i, j, status; + u32 temp; + + /* first, start with an encryption schedule */ + status = AES_set_encrypt_key(userKey, bits, key); + if (status < 0) + return status; + + rk = key->rd_key; + + /* invert the order of the round keys: */ + for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) { + temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp; + temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp; + temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp; + temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp; + } + /* apply the inverse MixColumn transform to all round keys but the first and the last: */ + for (i = 1; i < (key->rounds); i++) { + rk += 4; + rk[0] = + Td0[Te4[(rk[0] >> 24) ] & 0xff] ^ + Td1[Te4[(rk[0] >> 16) & 0xff] & 0xff] ^ + Td2[Te4[(rk[0] >> 8) & 0xff] & 0xff] ^ + Td3[Te4[(rk[0] ) & 0xff] & 0xff]; + rk[1] = + Td0[Te4[(rk[1] >> 24) ] & 0xff] ^ + Td1[Te4[(rk[1] >> 16) & 0xff] & 0xff] ^ + Td2[Te4[(rk[1] >> 8) & 0xff] & 0xff] ^ + Td3[Te4[(rk[1] ) & 0xff] & 0xff]; + rk[2] = + Td0[Te4[(rk[2] >> 24) ] & 0xff] ^ + Td1[Te4[(rk[2] >> 16) & 0xff] & 0xff] ^ + Td2[Te4[(rk[2] >> 8) & 0xff] & 0xff] ^ + Td3[Te4[(rk[2] ) & 0xff] & 0xff]; + rk[3] = + Td0[Te4[(rk[3] >> 24) ] & 0xff] ^ + Td1[Te4[(rk[3] >> 16) & 0xff] & 0xff] ^ + Td2[Te4[(rk[3] >> 8) & 0xff] & 0xff] ^ + Td3[Te4[(rk[3] ) & 0xff] & 0xff]; + } + return 0; +} + +/* + * Encrypt a single block + * in and out can overlap + */ +void AES_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key) { + + const u32 *rk; + u32 s0, s1, s2, s3, t0, t1, t2, t3; +#ifndef FULL_UNROLL + int r; +#endif /* ?FULL_UNROLL */ + +// assert(in && out && key); /* Removed by Brenda */ + rk = key->rd_key; + + /* + * map byte array block to cipher state + * and add initial round key: + */ + s0 = GETU32(in ) ^ rk[0]; + s1 = GETU32(in + 4) ^ rk[1]; + s2 = GETU32(in + 8) ^ rk[2]; + s3 = GETU32(in + 12) ^ rk[3]; +#ifdef FULL_UNROLL + /* round 1: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7]; + /* round 2: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11]; + /* round 3: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15]; + /* round 4: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19]; + /* round 5: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23]; + /* round 6: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27]; + /* round 7: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31]; + /* round 8: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35]; + /* round 9: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39]; + if (key->rounds > 10) { + /* round 10: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43]; + /* round 11: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47]; + if (key->rounds > 12) { + /* round 12: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51]; + /* round 13: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55]; + } + } + rk += key->rounds << 2; +#else /* !FULL_UNROLL */ + /* + * Nr - 1 full rounds: + */ + r = key->rounds >> 1; + for (;;) { + t0 = + Te0[(s0 >> 24) ] ^ + Te1[(s1 >> 16) & 0xff] ^ + Te2[(s2 >> 8) & 0xff] ^ + Te3[(s3 ) & 0xff] ^ + rk[4]; + t1 = + Te0[(s1 >> 24) ] ^ + Te1[(s2 >> 16) & 0xff] ^ + Te2[(s3 >> 8) & 0xff] ^ + Te3[(s0 ) & 0xff] ^ + rk[5]; + t2 = + Te0[(s2 >> 24) ] ^ + Te1[(s3 >> 16) & 0xff] ^ + Te2[(s0 >> 8) & 0xff] ^ + Te3[(s1 ) & 0xff] ^ + rk[6]; + t3 = + Te0[(s3 >> 24) ] ^ + Te1[(s0 >> 16) & 0xff] ^ + Te2[(s1 >> 8) & 0xff] ^ + Te3[(s2 ) & 0xff] ^ + rk[7]; + + rk += 8; + if (--r == 0) { + break; + } + + s0 = + Te0[(t0 >> 24) ] ^ + Te1[(t1 >> 16) & 0xff] ^ + Te2[(t2 >> 8) & 0xff] ^ + Te3[(t3 ) & 0xff] ^ + rk[0]; + s1 = + Te0[(t1 >> 24) ] ^ + Te1[(t2 >> 16) & 0xff] ^ + Te2[(t3 >> 8) & 0xff] ^ + Te3[(t0 ) & 0xff] ^ + rk[1]; + s2 = + Te0[(t2 >> 24) ] ^ + Te1[(t3 >> 16) & 0xff] ^ + Te2[(t0 >> 8) & 0xff] ^ + Te3[(t1 ) & 0xff] ^ + rk[2]; + s3 = + Te0[(t3 >> 24) ] ^ + Te1[(t0 >> 16) & 0xff] ^ + Te2[(t1 >> 8) & 0xff] ^ + Te3[(t2 ) & 0xff] ^ + rk[3]; + } +#endif /* ?FULL_UNROLL */ + /* + * apply last round and + * map cipher state to byte array block: + */ + s0 = + (Te4[(t0 >> 24) ] & 0xff000000) ^ + (Te4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(t3 ) & 0xff] & 0x000000ff) ^ + rk[0]; + PUTU32(out , s0); + s1 = + (Te4[(t1 >> 24) ] & 0xff000000) ^ + (Te4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(t0 ) & 0xff] & 0x000000ff) ^ + rk[1]; + PUTU32(out + 4, s1); + s2 = + (Te4[(t2 >> 24) ] & 0xff000000) ^ + (Te4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(t1 ) & 0xff] & 0x000000ff) ^ + rk[2]; + PUTU32(out + 8, s2); + s3 = + (Te4[(t3 >> 24) ] & 0xff000000) ^ + (Te4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(t2 ) & 0xff] & 0x000000ff) ^ + rk[3]; + PUTU32(out + 12, s3); +} + +/* + * Decrypt a single block + * in and out can overlap + */ +void AES_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key) { + + const u32 *rk; + u32 s0, s1, s2, s3, t0, t1, t2, t3; +#ifndef FULL_UNROLL + int r; +#endif /* ?FULL_UNROLL */ + +// assert(in && out && key); /* Removed by Brenda */ + rk = key->rd_key; + + /* + * map byte array block to cipher state + * and add initial round key: + */ + s0 = GETU32(in ) ^ rk[0]; + s1 = GETU32(in + 4) ^ rk[1]; + s2 = GETU32(in + 8) ^ rk[2]; + s3 = GETU32(in + 12) ^ rk[3]; +#ifdef FULL_UNROLL + /* round 1: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[ 4]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[ 5]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[ 6]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[ 7]; + /* round 2: */ + s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[ 8]; + s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[ 9]; + s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[10]; + s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[11]; + /* round 3: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[12]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[13]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[14]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[15]; + /* round 4: */ + s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[16]; + s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[17]; + s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[18]; + s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[19]; + /* round 5: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[20]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[21]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[22]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[23]; + /* round 6: */ + s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[24]; + s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[25]; + s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[26]; + s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[27]; + /* round 7: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[28]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[29]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[30]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[31]; + /* round 8: */ + s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[32]; + s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[33]; + s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[34]; + s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[35]; + /* round 9: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[36]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[37]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[38]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[39]; + if (key->rounds > 10) { + /* round 10: */ + s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[40]; + s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[41]; + s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[42]; + s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[43]; + /* round 11: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[44]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[45]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[46]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[47]; + if (key->rounds > 12) { + /* round 12: */ + s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[48]; + s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[49]; + s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[50]; + s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[51]; + /* round 13: */ + t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[52]; + t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[53]; + t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[54]; + t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[55]; + } + } + rk += key->rounds << 2; +#else /* !FULL_UNROLL */ + /* + * Nr - 1 full rounds: + */ + r = key->rounds >> 1; + for (;;) { + t0 = + Td0[(s0 >> 24) ] ^ + Td1[(s3 >> 16) & 0xff] ^ + Td2[(s2 >> 8) & 0xff] ^ + Td3[(s1 ) & 0xff] ^ + rk[4]; + t1 = + Td0[(s1 >> 24) ] ^ + Td1[(s0 >> 16) & 0xff] ^ + Td2[(s3 >> 8) & 0xff] ^ + Td3[(s2 ) & 0xff] ^ + rk[5]; + t2 = + Td0[(s2 >> 24) ] ^ + Td1[(s1 >> 16) & 0xff] ^ + Td2[(s0 >> 8) & 0xff] ^ + Td3[(s3 ) & 0xff] ^ + rk[6]; + t3 = + Td0[(s3 >> 24) ] ^ + Td1[(s2 >> 16) & 0xff] ^ + Td2[(s1 >> 8) & 0xff] ^ + Td3[(s0 ) & 0xff] ^ + rk[7]; + + rk += 8; + if (--r == 0) { + break; + } + + s0 = + Td0[(t0 >> 24) ] ^ + Td1[(t3 >> 16) & 0xff] ^ + Td2[(t2 >> 8) & 0xff] ^ + Td3[(t1 ) & 0xff] ^ + rk[0]; + s1 = + Td0[(t1 >> 24) ] ^ + Td1[(t0 >> 16) & 0xff] ^ + Td2[(t3 >> 8) & 0xff] ^ + Td3[(t2 ) & 0xff] ^ + rk[1]; + s2 = + Td0[(t2 >> 24) ] ^ + Td1[(t1 >> 16) & 0xff] ^ + Td2[(t0 >> 8) & 0xff] ^ + Td3[(t3 ) & 0xff] ^ + rk[2]; + s3 = + Td0[(t3 >> 24) ] ^ + Td1[(t2 >> 16) & 0xff] ^ + Td2[(t1 >> 8) & 0xff] ^ + Td3[(t0 ) & 0xff] ^ + rk[3]; + } +#endif /* ?FULL_UNROLL */ + /* + * apply last round and + * map cipher state to byte array block: + */ + s0 = + (Td4[(t0 >> 24) ] & 0xff000000) ^ + (Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ + (Td4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ + (Td4[(t1 ) & 0xff] & 0x000000ff) ^ + rk[0]; + PUTU32(out , s0); + s1 = + (Td4[(t1 >> 24) ] & 0xff000000) ^ + (Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ + (Td4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ + (Td4[(t2 ) & 0xff] & 0x000000ff) ^ + rk[1]; + PUTU32(out + 4, s1); + s2 = + (Td4[(t2 >> 24) ] & 0xff000000) ^ + (Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ + (Td4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ + (Td4[(t3 ) & 0xff] & 0x000000ff) ^ + rk[2]; + PUTU32(out + 8, s2); + s3 = + (Td4[(t3 >> 24) ] & 0xff000000) ^ + (Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ + (Td4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ + (Td4[(t0 ) & 0xff] & 0x000000ff) ^ + rk[3]; + PUTU32(out + 12, s3); +} + diff --git a/src/nwnss/zlss/z_aes_locl.h b/src/nwnss/zlss/z_aes_locl.h index 91630d1..c6347f0 100644 --- a/src/nwnss/zlss/z_aes_locl.h +++ b/src/nwnss/zlss/z_aes_locl.h @@ -7,7 +7,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in diff --git a/src/nwnss/zlss/zedExport.c b/src/nwnss/zlss/zedExport.c new file mode 100644 index 0000000..f6aebf1 --- /dev/null +++ b/src/nwnss/zlss/zedExport.c @@ -0,0 +1,174 @@ +/**************************************************************************** + | + | (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2006-12-30 03:27:16 +0530 (Sat, 30 Dec 2006) $ + | + | $RCSfile$ + | $Revision: 1799 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Initialize all ZED export stuff + | PSSMasterPoolList + | zpoolBlockReadWait() + | zpoolBlockWriteWait() + | + +-------------------------------------------------------------------------*/ + +#if zLINUX +#include +#endif + +#include +#include "zedExport.h" +#include "zfsSuperBlk.h" +#include "zlssConsumer.h" +#include "zlssStartup.h" + +ADDR ZedStuff[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + +LONG NSSConsumerID = 0x5A4C5353; /*- ZLSS -*/ + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*------------------ START OF ROUTINES ------------------------------------*/ + +/*- (FUNCTION) ----- GetZedStuff() ----------------------------------------- + | + | return pointer to list of pointers to zed stuff + | + | + +-------------------------------------------------------------------------*/ +STATUS GetZedStuff(ADDR **zedList) +{ +// ASSERT_MPKNSS_LOCK(); No reason to require SPIN Lock for this backdoor + if (ZedStuff[0] == 0) + return(zFAILURE); + *zedList = ZedStuff; + return (zOK); +} + +/*- Could not find any ref to this zed stuff and I wanted to remove internal + | ref to storage pool information. + | Mike - 8/11/00 + | + +-------------------------------------------------------------------------*/ + +///*- (FUNCTION) ----- GetZedPoolInfo() -------------------------------------- +// | +// | return info for pool +// | +// | +// +-------------------------------------------------------------------------*/ +//STATUS GetZedPoolInfo(LONG poolID, struct zedPoolStruc *poolPtr) +//{ +// ZfsPool_s *pool; +// zConPool_s *scanphypool; +// +// +//// ASSERT_MPKNSS_LOCK(); +// /*- scan the master pool list for this id-*/ +// if(DQ_NOT_EMPTY(&ZLSSPhyPoolList)) +// { +// DQ_FOREACH(&ZLSSPhyPoolList, scanphypool, zConPool_s, pollink) +// { +// if(poolID == scanphypool->pol.poolid) +// { +// pool = scanphypool->pol.zfspool; +// if( (pool != NULL) && (pool->ZP_super != NULL) ) +// { +// poolPtr->poolAddr = pool; +// poolPtr->blockSize = 4096; +// poolPtr->totalBlocks = pool->ZP_super->SB_Header.hdr.totalblocks; +// +// return (zOK); +// } +// } +// } +// } +// return (zFAILURE); +// +//} + +/*- (FUNCTION) ----- ZedStuffInitn() ---------------------------------------- + | + | Uninitialize all storage services + | + | + v1.02 [11] and [12] added. This was done to allow a scan of all blocks + to be done on a deactive pool from an external NLM. + v2.00 [8], [9] and [10] removed. This was done to patch the base with + code that did not need the I/O statistic code while still being + able to run scan.nlm. Version 2.01 will add this fields back in. + Also added [13] (debug flag). + v2.01 Added back in [8], [9], and [10]. I/O Statistics. + +-------------------------------------------------------------------------*/ +void ZedStuffInit() +{ +// ASSERT_MPKNSS_LOCK(); + /*- init ZedStuff[] -*/ + ZedStuff[0] = (ADDR)&ZLSSPhyPoolList; +// ZedStuff[1] = NULL; + ZedStuff[1] = (ADDR)ZFS_ReadPoolBlk; +// ZedStuff[1] = (ADDR)zpoolBlockReadWait; + ZedStuff[2] = NULL; +// ZedStuff[2] = (ADDR)zpoolBlockWriteWait; + ZedStuff[3] = NULL; +// ZedStuff[3] = (ADDR)GetZedPoolInfo; + ZedStuff[4] = (ADDR)NSSConsumerID; + /* Major number must change if you make a change that will break + * users if zedExport. Minor should change otherwise. Adding a + * NEW function should cause minor version to change. Removing + * a function should cause major version to change. + */ + ZedStuff[5] = 2; /* Using address 5 as a Major version number */ + ZedStuff[6] = 1; /* Using address 6 as a Minor version number */ + ZedStuff[7] = (ADDR)(&ZSTORE_VersionInfo); + /* + * [8], [9] and [10] added back in 2.01 + */ + ZedStuff[8] = (ADDR)(&gZLSSPRS); + ZedStuff[9] = (ADDR)(&gZLSSPWS); + ZedStuff[10] = (ADDR)(&gZLSSIOStartUpTime); + /* + * [11] and [12] added in version 1.2. This was done to allow + * a scan of all blocks to be done on a deactive pool from + * an external NLM. + */ + ZedStuff[11] = (ADDR)ZFS_BlockSignalHandler; + ZedStuff[12] = (ADDR)ZFSMAL_asyncReadBlk; + /* + * [13] added in 2.00 + */ +#if NSS_DEBUG IS_ENABLED + ZedStuff[13] = TRUE; +#else + ZedStuff[13] = FALSE; +#endif + return; +} diff --git a/src/nwnss/zlss/zedExport.h b/src/nwnss/zlss/zedExport.h index b3cb335..32e3e67 100644 --- a/src/nwnss/zlss/zedExport.h +++ b/src/nwnss/zlss/zedExport.h @@ -47,9 +47,9 @@ struct zedPoolStruc { - ZfsPool_s *poolAddr; - LONG blockSize; - LONG totalBlocks; + ZfsPool_s *poolAddr; + LONG blockSize; + LONG totalBlocks; }; STATUS GetZedStuff(ADDR **zedList); diff --git a/src/nwnss/zlss/zfs.c b/src/nwnss/zlss/zfs.c index 197919b..5cdb72c 100644 --- a/src/nwnss/zlss/zfs.c +++ b/src/nwnss/zlss/zfs.c @@ -294,7 +294,7 @@ REGISTERCLASSES_Failed: } /**************************************************************************** - * + * *****************************************************************************/ void ZSTORE_Shutdown (void) { @@ -333,7 +333,7 @@ void ZSTORE_Shutdown (void) * run. I.E. just increases odds that a corrupt/bug will not prevent * REBUILD of running. * - * Note - + * Note - * NEB only checks return code if CONSUMABLE_CONSUMER_BIT is set * at registeration. NSS does NOT support any CONSUMABLE_CONSUMER_BIT * consumers!!! @@ -360,8 +360,8 @@ LONG ZLSSPOOL_ChangePoolStateExitCallBack( data = (EventChangePoolStateExit_s *)evBlk->EBEventData; if ( data->opRetCode != zOK ) { /* We ignore all pool state changes that failed because - * it means that a state change did not occur. - */ + * it means that a state change did not occur. + */ #if NSS_DEBUG IS_ENABLED DBG_ScreenAPrintf( "ZLSS.Greg.Pool", WHERE, YELLOW,"Warning %d during change pool state\n",data->opRetCode); @@ -371,8 +371,8 @@ LONG ZLSSPOOL_ChangePoolStateExitCallBack( } if ( data->newState == data->oldState ) { /* We ignore all pool state changes that really - * did not CHANGE state. - */ + * did not CHANGE state. + */ #if NSS_DEBUG IS_ENABLED DBG_ScreenAPrintf( "ZLSS.Greg.Pool", WHERE, YELLOW,"Warning pool state did not change\n"); @@ -493,7 +493,7 @@ LONG ZLSSPOOL_ChangePoolStateExitCallBack( * We do not own the NSS spin lock so we must obtain if we make * any NSS calls. * - * Note - + * Note - * NEB only checks return code if CONSUMABLE_CONSUMER_BIT is set * at registeration. NSS does NOT support any CONSUMABLE_CONSUMER_BIT * consumers!!! @@ -557,24 +557,24 @@ LONG ZLSSPOOL_SUT_SnapshotEnterCallBack( /** We do not care about the Volume ID so we do not change it **/ /** Delete Volumes can have their OLD volume ID and old - ** name updated. We skip because the OLD values are - ** only used a a possible suggestion as to the name - ** to give a volume when it is salvaged. Normally, - ** it would not be worth asking the 'user' for a new - ** name that would only be used as a suggestion. Also, - ** we let NSS choice the deleted volumes new name - ** as deleted names are funky anyway and user interfaces - ** do not see them. - **/ + ** name updated. We skip because the OLD values are + ** only used a a possible suggestion as to the name + ** to give a volume when it is salvaged. Normally, + ** it would not be worth asking the 'user' for a new + ** name that would only be used as a suggestion. Also, + ** we let NSS choice the deleted volumes new name + ** as deleted names are funky anyway and user interfaces + ** do not see them. + **/ /** Get a new name for non-deleted volumes. Real code could - ** ask the user OR have saved up the answers already - ** by getting the original pools LV names from the - ** _admin volume before doing the snapshot. The 2nd - ** method is preferred as the cvsLatch is held which - ** will prevent many NSS commands to block until - ** ALL volume names have been replaced. - **/ + ** ask the user OR have saved up the answers already + ** by getting the original pools LV names from the + ** _admin volume before doing the snapshot. The 2nd + ** method is preferred as the cvsLatch is held which + ** will prevent many NSS commands to block until + ** ALL volume names have been replaced. + **/ if ( snapData->volPersistentState != 3 ) { int volumeCount; @@ -614,7 +614,7 @@ Again: * If PRODUCER is registered already then this gets call immediately * when the consumer registers. * - * Note - + * Note - * NEB does not check the return code. We always use 0 just * to be consistent. */ @@ -646,7 +646,7 @@ LONG ZLSSPOOL_SUT_SnapshotEnterConsumerESR(struct EventBlock *evBlk) * run. I.E. just increases odds that a corrupt/bug will not prevent * REBUILD of running. * - * Note - + * Note - * NEB only checks return code if CONSUMABLE_CONSUMER_BIT is set * at registeration. NSS does NOT support any CONSUMABLE_CONSUMER_BIT * consumers!!! @@ -719,7 +719,7 @@ LONG ZLSSPOOL_SUT_SnapshotExitCallBack( * If PRODUCER is registered already then this gets call immediately * when the consumer registers. * - * Note - + * Note - * NEB does not check the return code. We always use 0 just * to be consistent. */ @@ -740,7 +740,7 @@ LONG ZLSSPOOL_SUT_SnapshotExitConsumerESR(struct EventBlock *evBlk) * If PRODUCER is registered already then this gets call immediately * when the consumer registers. * - * Note - + * Note - * NEB does not check the return code. We always use 0 just * to be consistent. */ diff --git a/src/nwnss/zlss/zfs.h b/src/nwnss/zlss/zfs.h index 02a2a26..3023a81 100644 --- a/src/nwnss/zlss/zfs.h +++ b/src/nwnss/zlss/zfs.h @@ -44,11 +44,11 @@ #define _ZFS_H_ #ifndef _XCACHE_H_ -#include +#include #endif #ifndef _XSTDLIB_H_ -#include +#include #endif #ifndef _COMNBEASTS_H_ @@ -72,7 +72,6 @@ struct ZfsXasRecovery_s; struct PCLSwitchDef_s; struct XML_ElementInfo_s; struct MediaSuperBlockHeader_s; -struct block_device; #define ZFS_RESERVED_BLOCKS_FOR_INTERNAL_ALLOCATION 128 #define ZFS_RESERVED_BLOCKS_FOR_RECOVERY 48 @@ -82,7 +81,7 @@ struct block_device; #define LV_POOL_BLOCKS 2 /* Number of pool data blocks (one logged; one non-logged) */ -/* The read ahead used to be 2 -- don't know why. I have increased the +/* The read ahead used to be 2 -- don't know why. I have increased the * default read ahead to 16, as we see better read performance for large * files. */ @@ -110,35 +109,35 @@ struct block_device; typedef struct PersistentAuthBeast_1Dot0_s { - LONG ownerID; /* PERSISTENT - owner of this beast */ + LONG ownerID; /* PERSISTENT - owner of this beast */ } NSS_MEDIA_STRUCTURE(PersistentAuthBeast_1Dot0_s,ownerID) PersistentAuthBeast_1Dot0_s; /* Set ZLSS_IO_GATHER to ENABLE when you want to gather ZLSS - * detailed I/O log. This log can be saved with the ZLSSDebugIOStatsSave - * command. This is a hidden command. The program ZIOA (ZLSS IO - * Analysis) will convert this file into a text analysis file. ZIOA - * is in the nss\dev\util\zioa directory. NT, OS/2 and DOS versions exist. - * - * The log is stored into memory. - * - * The follow commands are active when ZLSS_IO_GATHER is enabled. - * - * ZLSSDebugIOLogSave - - * Hidden command only valid if ZLSS_IO_GATHER is enabled in the - * compile. This is not a DEBUG only command. Causes the ZLSS - * I/O log to be written as SYS:\ZLSS.ZSF. This file can then - * be processed by the ZIOA (ZLSS I/O Analysis utility). This - * utility is at nss\dev\util\zioa. This log file is used - * to analysis I/O. - * - * ZLSSDebugIOLogSize - - * Hidden command only valid if ZLSS_IO_GATHER is enabled in the - * compile. This is not a DEBUG only command. Sets the ZLSS I/O - * log size in bytes. Must be specified at startup only. - * - */ + * detailed I/O log. This log can be saved with the ZLSSDebugIOStatsSave + * command. This is a hidden command. The program ZIOA (ZLSS IO + * Analysis) will convert this file into a text analysis file. ZIOA + * is in the nss\dev\util\zioa directory. NT, OS/2 and DOS versions exist. + * + * The log is stored into memory. + * + * The follow commands are active when ZLSS_IO_GATHER is enabled. + * + * ZLSSDebugIOLogSave - + * Hidden command only valid if ZLSS_IO_GATHER is enabled in the + * compile. This is not a DEBUG only command. Causes the ZLSS + * I/O log to be written as SYS:\ZLSS.ZSF. This file can then + * be processed by the ZIOA (ZLSS I/O Analysis utility). This + * utility is at nss\dev\util\zioa. This log file is used + * to analysis I/O. + * + * ZLSSDebugIOLogSize - + * Hidden command only valid if ZLSS_IO_GATHER is enabled in the + * compile. This is not a DEBUG only command. Sets the ZLSS I/O + * log size in bytes. Must be specified at startup only. + * + */ //#define ZLSS_IO_GATHER ENABLE #define ZLSS_IO_GATHER DISABLE @@ -157,31 +156,31 @@ typedef struct PersistentAuthBeast_1Dot0_s #define ZLSS_PRS_SB_COUNT 16 typedef struct { - QUAD PRS_SystemBeast[ZLSS_PRS_SB_COUNT]; - /* - * For the first 16 Zids we just store into our buffer. - * Zid 0 is used by all LVDB and VDB reads since the - * volume beast uses Zids from the Admin. - * Zid 15 is used for all other system beasts. - */ - QUAD PRS_SuperBlock; - QUAD PRS_UserBlock; - QUAD PRS_DirectIOBlock; /* Number of DIO UNITS(512) byte reads */ - QUAD PRS_Reserved[5]; + QUAD PRS_SystemBeast[ZLSS_PRS_SB_COUNT]; + /* + * For the first 16 Zids we just store into our buffer. + * Zid 0 is used by all LVDB and VDB reads since the + * volume beast uses Zids from the Admin. + * Zid 15 is used for all other system beasts. + */ + QUAD PRS_SuperBlock; + QUAD PRS_UserBlock; + QUAD PRS_DirectIOBlock; /* Number of DIO UNITS(512) byte reads */ + QUAD PRS_Reserved[5]; } NSS_MEDIA_STRUCTURE(PoolReadStatistics_s,PRS_Reserved[5]) PoolReadStatistics_s; typedef struct { - QUAD PWS_SystemBeast[ZLSS_PRS_SB_COUNT]; - /* - * For the first 16 Zids we just store into our buffer. - * Zid 0 is used by all LVDB and VDB reads since the - * volume beast uses Zids from the Admin. - * Zid 15 is used for all other system beasts. - */ - QUAD PWS_SuperBlock; - QUAD PWS_UserBlock; - QUAD PWS_DirectIOBlock; /* Number of DIO UNITS(512) byte writes */ - QUAD PWS_Reserved[4]; + QUAD PWS_SystemBeast[ZLSS_PRS_SB_COUNT]; + /* + * For the first 16 Zids we just store into our buffer. + * Zid 0 is used by all LVDB and VDB reads since the + * volume beast uses Zids from the Admin. + * Zid 15 is used for all other system beasts. + */ + QUAD PWS_SuperBlock; + QUAD PWS_UserBlock; + QUAD PWS_DirectIOBlock; /* Number of DIO UNITS(512) byte writes */ + QUAD PWS_Reserved[4]; QUAD PWS_BarrierIO; /* Number of times we have done a barrier flush */ } NSS_MEDIA_STRUCTURE(PoolWriteStatistics_s,PWS_Reserved[4]) PoolWriteStatistics_s; @@ -197,38 +196,38 @@ extern BOOL gCLPoolTrackMaintenance; * ZFS Supported Attributes *****************************************************************************/ #define ZLSS_SUPPORTED_ATTRIBUTES (zATTR_SALVAGE | \ - zATTR_USER_SPACE_RESTRICTIONS /*| zATTR_READONLY*/ | zATTR_COMPRESSION | \ - zATTR_EXTENDED_ATTRIBUTES | zATTR_DATA_STREAMS | zATTR_DOS_METADATA | \ - zATTR_NETWARE_METADATA | zATTR_MAC_METADATA | zATTR_UNIX_METADATA | \ - zATTR_HARD_LINKS | zATTR_TRANSACTION | zATTR_SPARSE_FILES | \ - zATTR_PHYSICAL_EOF | zATTR_DIRECT_IO | zATTR_PERSISTENT_ATTRIBUTES | \ - zATTR_VERIFY | zATTR_REBUILD | zATTR_COW | zATTR_VIRTUAL_FILES | \ - zATTR_USER_TRANSACTION | zATTR_USER_TRANSACTION_ACTIVE | \ - zATTR_DONT_BACKUP | zATTR_MFL | zATTR_DIR_QUOTAS | zATTR_SHRED_DATA |\ - zATTR_HIGH_INTEGRITY | zATTR_MIGRATION | zATTR_CFS_MASTER | zATTR_ENCRYPTED |\ + zATTR_USER_SPACE_RESTRICTIONS /*| zATTR_READONLY*/ | zATTR_COMPRESSION | \ + zATTR_EXTENDED_ATTRIBUTES | zATTR_DATA_STREAMS | zATTR_DOS_METADATA | \ + zATTR_NETWARE_METADATA | zATTR_MAC_METADATA | zATTR_UNIX_METADATA | \ + zATTR_HARD_LINKS | zATTR_TRANSACTION | zATTR_SPARSE_FILES | \ + zATTR_PHYSICAL_EOF | zATTR_DIRECT_IO | zATTR_PERSISTENT_ATTRIBUTES | \ + zATTR_VERIFY | zATTR_REBUILD | zATTR_COW | zATTR_VIRTUAL_FILES | \ + zATTR_USER_TRANSACTION | zATTR_USER_TRANSACTION_ACTIVE | \ + zATTR_DONT_BACKUP | zATTR_MFL | zATTR_DIR_QUOTAS | zATTR_SHRED_DATA |\ + zATTR_HIGH_INTEGRITY | zATTR_MIGRATION | zATTR_CFS_MASTER | zATTR_ENCRYPTED |\ zATTR_EXTENDED_MAC_NAMESPACE | zATTR_NO_ATIME) - /* If you add bits to ZLSS_DEFAULT_ENABLED_ATTRIBUTES, you need to - * look at code in ZFSPOOL_LoadPersistentPool that uses this define - * to upgrade volumes and do what is being done for zATTR_SALVAGE - */ + /* If you add bits to ZLSS_DEFAULT_ENABLED_ATTRIBUTES, you need to + * look at code in ZFSPOOL_LoadPersistentPool that uses this define + * to upgrade volumes and do what is being done for zATTR_SALVAGE + */ #define ZLSS_DEFAULT_ENABLED_ATTRIBUTES (zATTR_SALVAGE | \ - zATTR_EXTENDED_ATTRIBUTES | zATTR_DATA_STREAMS | zATTR_DOS_METADATA | \ - zATTR_NETWARE_METADATA | zATTR_MAC_METADATA | zATTR_UNIX_METADATA | \ - zATTR_TRANSACTION | zATTR_SPARSE_FILES | \ - zATTR_PHYSICAL_EOF | zATTR_DIRECT_IO | zATTR_PERSISTENT_ATTRIBUTES | \ - zATTR_VERIFY | zATTR_REBUILD | zATTR_EXTENDED_MAC_NAMESPACE) + zATTR_EXTENDED_ATTRIBUTES | zATTR_DATA_STREAMS | zATTR_DOS_METADATA | \ + zATTR_NETWARE_METADATA | zATTR_MAC_METADATA | zATTR_UNIX_METADATA | \ + zATTR_TRANSACTION | zATTR_SPARSE_FILES | \ + zATTR_PHYSICAL_EOF | zATTR_DIRECT_IO | zATTR_PERSISTENT_ATTRIBUTES | \ + zATTR_VERIFY | zATTR_REBUILD | zATTR_EXTENDED_MAC_NAMESPACE) - /* If attribute bit is set in the next define then ZLSS modify info - * function will not allow the user to DISABLE the feature. - */ + /* If attribute bit is set in the next define then ZLSS modify info + * function will not allow the user to DISABLE the feature. + */ /* fixfixfix@nextMediaFormatChange - zATTR_EXTENDED_MAC_NAMESPACE should be non-changeable at nextMediaFormatChange */ #define ZLSS_NON_CHANGABLE_ATTRIBUTES ( zATTR_EXTENDED_ATTRIBUTES | \ - zATTR_DATA_STREAMS | zATTR_DOS_METADATA | zATTR_NETWARE_METADATA | \ - zATTR_MAC_METADATA | zATTR_UNIX_METADATA | \ - zATTR_TRANSACTION | zATTR_SPARSE_FILES | zATTR_PHYSICAL_EOF | \ - zATTR_DIRECT_IO | zATTR_PERSISTENT_ATTRIBUTES | zATTR_VERIFY | \ - zATTR_REBUILD | zATTR_VIRTUAL_FILES | zATTR_ENCRYPTED) + zATTR_DATA_STREAMS | zATTR_DOS_METADATA | zATTR_NETWARE_METADATA | \ + zATTR_MAC_METADATA | zATTR_UNIX_METADATA | \ + zATTR_TRANSACTION | zATTR_SPARSE_FILES | zATTR_PHYSICAL_EOF | \ + zATTR_DIRECT_IO | zATTR_PERSISTENT_ATTRIBUTES | zATTR_VERIFY | \ + zATTR_REBUILD | zATTR_VIRTUAL_FILES | zATTR_ENCRYPTED) @@ -236,39 +235,39 @@ extern BOOL gCLPoolTrackMaintenance; * ZLSS POOL Supported features *****************************************************************************/ #define ZLSSPOOL_SUPPORTED_FEATURES \ - (zPOOL_FEATURE_PERSISTENT_FEATURES | \ - zPOOL_FEATURE_SHARED_CLUSTER | \ - /* zPOOL_FEATURE_READ_ONLY | */ \ - zPOOL_FEATURE_VERIFY | \ - zPOOL_FEATURE_REBUILD | \ - zPOOL_FEATURE_MULTIPLE_VOLUMES | \ - zPOOL_FEATURE_SNAPSHOT | \ - zPOOL_FEATURE_MSAP) + (zPOOL_FEATURE_PERSISTENT_FEATURES | \ + zPOOL_FEATURE_SHARED_CLUSTER | \ + /* zPOOL_FEATURE_READ_ONLY | */ \ + zPOOL_FEATURE_VERIFY | \ + zPOOL_FEATURE_REBUILD | \ + zPOOL_FEATURE_MULTIPLE_VOLUMES | \ + zPOOL_FEATURE_SNAPSHOT | \ + zPOOL_FEATURE_MSAP) #define ZLSSPOOL_DEFAULT_ENABLED_FEATURES \ - (zPOOL_FEATURE_PERSISTENT_FEATURES | \ - zPOOL_FEATURE_VERIFY | \ - zPOOL_FEATURE_REBUILD | \ - zPOOL_FEATURE_MULTIPLE_VOLUMES | \ - zPOOL_FEATURE_MSAP) + (zPOOL_FEATURE_PERSISTENT_FEATURES | \ + zPOOL_FEATURE_VERIFY | \ + zPOOL_FEATURE_REBUILD | \ + zPOOL_FEATURE_MULTIPLE_VOLUMES | \ + zPOOL_FEATURE_MSAP) #define ZLSSPOOL_NON_CHANGEABLE_FEATURES \ - (zPOOL_FEATURE_PERSISTENT_FEATURES | \ - zPOOL_FEATURE_SHARED_CLUSTER | \ - zPOOL_FEATURE_VERIFY | \ - zPOOL_FEATURE_REBUILD | \ - zPOOL_FEATURE_MULTIPLE_VOLUMES | \ - zPOOL_FEATURE_SNAPSHOT) + (zPOOL_FEATURE_PERSISTENT_FEATURES | \ + zPOOL_FEATURE_SHARED_CLUSTER | \ + zPOOL_FEATURE_VERIFY | \ + zPOOL_FEATURE_REBUILD | \ + zPOOL_FEATURE_MULTIPLE_VOLUMES | \ + zPOOL_FEATURE_SNAPSHOT) - /* zPOOL_FEATURE items that are NOT persistent stored with - * the other bits in the Pool Data Block - */ + /* zPOOL_FEATURE items that are NOT persistent stored with + * the other bits in the Pool Data Block + */ #define ZLSSPOOL_PERSISTENT_ELSEWHERE \ - (zPOOL_FEATURE_SHARED_CLUSTER | \ - zPOOL_FEATURE_SNAPSHOT) + (zPOOL_FEATURE_SHARED_CLUSTER | \ + zPOOL_FEATURE_SNAPSHOT) #if zPOOL_FEATURE_LIST != 0xff - #error Please check if the new FEATURE needs to be added to the above defines. + #error Please check if the new FEATURE needs to be added to the above defines. #endif /*========================================================================= @@ -285,7 +284,7 @@ extern BOOL gCLPoolTrackMaintenance; #define POOLBLK_TO_INDIRECT(_blk) ((Blknum_t)(-(ADDR)(_blk))) #define DATA_SHREDDING_ENABLED(_zfsvol) \ - ((_zfsvol)->ZFSVOLenabledAttributes & zATTR_SHRED_DATA) + ((_zfsvol)->ZFSVOLenabledAttributes & zATTR_SHRED_DATA) //#define DATA_SHREDDING_CHUNK 32 // We have changed this to 8 to work with XEN. It should be fixed @@ -301,8 +300,8 @@ extern void DataShredCleanup(void); ************************************************************************/ typedef struct ZfsPurgeLogLoc_s /* zfs specific purge log location */ { - Blknum_t block; /* pool block where the entry is */ - LONG slot; /* slot in the array of entries in a block */ + Blknum_t block; /* pool block where the entry is */ + LONG slot; /* slot in the array of entries in a block */ } NSS_MEDIA_STRUCTURE(ZfsPurgeLogLoc_s,slot) ZfsPurgeLogLoc_s; typedef struct Extent_s @@ -311,7 +310,7 @@ typedef struct Extent_s Blknum_t poolBlkNum; /*- pool block offset for this extent -*/ } NSS_MEDIA_STRUCTURE(Extent_s,poolBlkNum) Extent_s; - + typedef struct FmapExt_s { Blknum_t count; @@ -320,91 +319,91 @@ typedef struct FmapExt_s typedef struct Fmap_s { - /* packing code assumes fields are contiguous */ - LONG numRecs; - Blknum_t root; - FmapExt_s dirExt[MAX_DIRECT]; + /* packing code assumes fields are contiguous */ + LONG numRecs; + Blknum_t root; + FmapExt_s dirExt[MAX_DIRECT]; } NSS_MEDIA_STRUCTURE(Fmap_s,dirExt[MAX_DIRECT]) Fmap_s; #define ZSTORE_BEAST_LAYOUT 1 /* Layout version of the beasts that are - * on the media. Used so if ZSTORE changes - * how beasts are stored - ZSTORE can detect - * how a beast is stored. ZSTORE may - * change how beasts are stored because - * NSS changes the items that need to be - * persistent. - * A change to this define should also - * require a change to the media version - * number -> SUPERBLOCK_SB_VM_MEDIA_MAJOR. - */ + * on the media. Used so if ZSTORE changes + * how beasts are stored - ZSTORE can detect + * how a beast is stored. ZSTORE may + * change how beasts are stored because + * NSS changes the items that need to be + * persistent. + * A change to this define should also + * require a change to the media version + * number -> SUPERBLOCK_SB_VM_MEDIA_MAJOR. + */ /** If persistent data fields are changed in this structure, verify to make ** sure that the packing code for the root beast has the same change **/ typedef struct ZFSStorageInfo_s { - StorageInfo_s comnInfo; /* NSS requires this to be first? */ + StorageInfo_s comnInfo; /* NSS requires this to be first? */ #if ZSTORE_BEAST_LAYOUT != 1 - /* This stuff not in layout 1 because code assumes the only - * beast layouts that exist are 1. The ZSTORE compilied with - * the layout at 1 will not load future versions of ZSTORE - * pools because the SUPERBLOCK_SB_VM_MEDIA_MAJOR will not - * match. - */ - BYTE beastLayout;/* PERSISTENT: Layout number of this beast */ - BYTE reserved1; /* Must be 0 */ - WORD reserved2; /* Must be 0 */ + /* This stuff not in layout 1 because code assumes the only + * beast layouts that exist are 1. The ZSTORE compilied with + * the layout at 1 will not load future versions of ZSTORE + * pools because the SUPERBLOCK_SB_VM_MEDIA_MAJOR will not + * match. + */ + BYTE beastLayout;/* PERSISTENT: Layout number of this beast */ + BYTE reserved1; /* Must be 0 */ + WORD reserved2; /* Must be 0 */ #endif - Blknum_t nextBlk; /* PERSISTENT: Block after the last block in the - * the file after the EOF. */ - Blknum_t fmapDataBlks;/* PERSISTENT: Num of data blocks alloc'd */ - Blknum_t fmapTreeBlks;/* PERSISTENT: Num of blks used by fmap tree*/ - Fmap_s fmap; /* PERSISTENT: File map */ - LONG rebuildMagic; /* PERSISTENT: Rebuild file state */ - ZfsPurgeLogLoc_s deletePurgeLogLoc; /* The location of the purge log entry */ - /* for delete. Can be in use at the */ - /* same time as the regular entry. */ - /* Beasts can be marked as deleted */ - /* long before they are actually */ - /* removed. */ + Blknum_t nextBlk; /* PERSISTENT: Block after the last block in the + * the file after the EOF. */ + Blknum_t fmapDataBlks;/* PERSISTENT: Num of data blocks alloc'd */ + Blknum_t fmapTreeBlks;/* PERSISTENT: Num of blks used by fmap tree*/ + Fmap_s fmap; /* PERSISTENT: File map */ + LONG rebuildMagic; /* PERSISTENT: Rebuild file state */ + ZfsPurgeLogLoc_s deletePurgeLogLoc; /* The location of the purge log entry */ + /* for delete. Can be in use at the */ + /* same time as the regular entry. */ + /* Beasts can be marked as deleted */ + /* long before they are actually */ + /* removed. */ ZfsPurgeLogLoc_s compCleanupPurgeLogLoc;/* the location of the compCleanup purge log entry */ - ZfsPurgeLogLoc_s purgeLogLoc;/* the location of the purge log entry */ + ZfsPurgeLogLoc_s purgeLogLoc;/* the location of the purge log entry */ } ZFSStorageInfo_s; #if NSS_DEBUG IS_ENABLED - /* WRite debug globals */ + /* WRite debug globals */ extern NINT WRTestCnt; /* Number of writes that we have done while - * WRErrTestSeed is non-zero. - */ -extern NINT WRErrTestSeed; /* The write number to start failing on. - * The value zero idicates we will not - * simulate write failures. - */ + * WRErrTestSeed is non-zero. + */ +extern NINT WRErrTestSeed; /* The write number to start failing on. + * The value zero idicates we will not + * simulate write failures. + */ extern NINT WRErrTestInterval; /* Frequency of which write calls will - * fail. Note that ZLSS attempts to - * never do another REAL write attempt - * after detecting a failure. - */ + * fail. Note that ZLSS attempts to + * never do another REAL write attempt + * after detecting a failure. + */ #endif - /* Information about bitmaps used to ensure that the Purge Log - * is not hooked into itself. Used to prevent hangs. - */ + /* Information about bitmaps used to ensure that the Purge Log + * is not hooked into itself. Used to prevent hangs. + */ #ifndef HAVE_BLOCK_MAP_s #define HAVE_BLOCK_MAP_s typedef struct BlockMap_s { - char *BM_Startup; /* Who allocated (I.E. WHERE macro) */ - char *BM_Shutdown; /* Who allocated (I.E. WHERE macro) */ - Blkcnt_t BM_NumberOfBits; /* Number of bits in map */ - NINT *BM_Map; /* Actual bitmap */ + char *BM_Startup; /* Who allocated (I.E. WHERE macro) */ + char *BM_Shutdown; /* Who allocated (I.E. WHERE macro) */ + Blkcnt_t BM_NumberOfBits; /* Number of bits in map */ + NINT *BM_Map; /* Actual bitmap */ } BlockMap_s; - // - // Caller must ensure that bitmap is legal and block is within - // range before using this MACROS. - // + // + // Caller must ensure that bitmap is legal and block is within + // range before using this MACROS. + // #define BM_TST_BIT( _bitMap, _blockNum ) (TST_BIT( (_bitMap)->BM_Map, _blockNum )) #define BM_SET_BIT( _bitMap, _blockNum ) (SET_BIT( (_bitMap)->BM_Map, _blockNum )) #define BM_CLR_BIT( _bitMap, _blockNum ) (CLR_BIT( (_bitMap)->BM_Map, _blockNum )) @@ -416,48 +415,48 @@ typedef struct BlockMap_s { *---------------------------------------------------------------------------*/ void ZFSVOL_VOL_asyncReadFileBlk( - struct Asyncio_s *asyncio); + struct Asyncio_s *asyncio); struct Buffer_s *ZFSVOL_VOL_getFileBlk( - struct GeneralMsg_s *genMsg, - struct IoMsg_s *ioMsg); + struct GeneralMsg_s *genMsg, + struct IoMsg_s *ioMsg); STATUS ZFSVOL_VOL_truncateFile( - struct GeneralMsg_s *genMsg, - struct RootBeast_s *beast, - Blknum_t fileBlk, - Blkcnt_t count); + struct GeneralMsg_s *genMsg, + struct RootBeast_s *beast, + Blknum_t fileBlk, + Blkcnt_t count); STATUS ZFSVOL_VOL_getExtentList( - struct GeneralMsg_s *genMsg, - struct RootBeast_s *beast, - Blknum_t startingBlock, - NINT extentListSize, - Blknum_t (*extentList)[], - NINT *retNumExtents, - Blknum_t *retNextBlock); + struct GeneralMsg_s *genMsg, + struct RootBeast_s *beast, + Blknum_t startingBlock, + NINT extentListSize, + Blknum_t (*extentList)[], + NINT *retNumExtents, + Blknum_t *retNextBlock); STATUS ZFSVOL_VOL_getPhysicalExtent( - struct zNSSMsg_s *msg, - RootBeast_s *beast); + struct zNSSMsg_s *msg, + RootBeast_s *beast); BOOL ZFSVOL_VOL_isBlockInBeast( - RootBeast_s *beast, - Blknum_t blockNum); + RootBeast_s *beast, + Blknum_t blockNum); Blknum_t ZFS_fileBlk2volBlk( - RootBeast_s *beast, - Blknum_t fileBlk, - NINT *length); + RootBeast_s *beast, + Blknum_t fileBlk, + NINT *length); STATUS ZLSSPOOL_RebuildFileExtend( - GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - Blknum_t totalBlocks ); + GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + Blknum_t totalBlocks ); File_s *ZLSSPOOL_RebuildFileCreate( - GeneralMsg_s *genMsg, - struct ZfsPool_s *pool ); + GeneralMsg_s *genMsg, + struct ZfsPool_s *pool ); /*========================================================================= *========================================================================= @@ -480,28 +479,28 @@ extern LSSSpecificPackUnpackOps_s ZFSVOL_lssOps[]; #define ZFSVOLUMEINFO_MAGIC (0x6c6f565AuL) /* "ZVol" on Little-Endian */ #define ZFSVOLUMEINFO_VERSION_5 5uL /* Greg changed to 5 from 1 when - * he added Volume name to after - * the checksum area. Re-link can - * use to see that volume name is - * present. Skipped numbers just - * in case Cobra needs some. - */ -#define ZFSVOLUMEINFO_VERSION_6 6uL /* Vandana changed to 6 from 5 - * Version 6 has: - * 1) the reserved area zeroed out. - * 2) rezid count added - * 3) rezid time added - */ + * he added Volume name to after + * the checksum area. Re-link can + * use to see that volume name is + * present. Skipped numbers just + * in case Cobra needs some. + */ +#define ZFSVOLUMEINFO_VERSION_6 6uL /* Vandana changed to 6 from 5 + * Version 6 has: + * 1) the reserved area zeroed out. + * 2) rezid count added + * 3) rezid time added + */ -#define ZFSVOLUMEINFO_VERSION_7 7uL /* Vandana changed to 7 from 6 - * Version 7 has: - * 1) readAheadBlocks added. - */ +#define ZFSVOLUMEINFO_VERSION_7 7uL /* Vandana changed to 7 from 6 + * Version 7 has: + * 1) readAheadBlocks added. + */ #define ZFSVOLUMEINFO_VERSION 8uL /* Craig/Greg changed to 8 from 7 - * Version 8 has: - * 1) Encryption information in it - */ + * Version 8 has: + * 1) Encryption information in it + */ #define ZFSLOGGEDVOLUMEINFO_MAGIC (0x6f4c565AuL) /* "ZVLo" on Little-Endian */ #define ZFSLOGGEDVOLUMEINFO_VERSION 1uL /* */ @@ -510,173 +509,173 @@ extern LSSSpecificPackUnpackOps_s ZFSVOL_lssOps[]; typedef struct PersistentZfsVolume_s { - LONG PZV_magic; /* volinfo magic number */ - LONG PZV_version; - LONG PZV_checksum; - /* Calculated before each NON-LOGGED write of the block. - * Checksum is for all NON LOGGED data. Checksum is - * valid if the NON-LOGGED contents (including this field) - * add up to zero. Use ZFSVOL_CalculateChecksum() to - * perform checksumming. We do not include the LOGGED - * data in the checksum for the following reasons. - * 1) We update the block too often for LOGGING - * 2) All the LOGGED data can be reproduced by Rebuild. - * 3) This LSS stores the LOGGED data in a different - * volume block. - */ - WORD PZV_rezidCount; /* Number of times volume has been rezid */ - WORD PZV_readAheadBlocks;/* Number of blocks to read ahead */ - GUID_t PZV_internalID; /* Internal ID of volume - needs to be at ofsset 16 */ - SQUAD PZV_loggedVolumeDataBlk; /* Block number where the persistent - * LOGGED volume information is stored. - */ - SQUAD PZV_volumeDataBlk; /* Block number where the persistent - * NON-LOGGED volume information is stored. - */ - SQUAD PZV_systemBeastBlkNum; /* Block number where the super beasts - * are located. Its nextleaf link - * points to the left most leaf of - * the beast b-tree. - */ - LONG PZV_ActivationCount; /* Number of times that this volume - * has had an attempt to activate it. - * Used by purge log code to detect - * if a purge log entry should be played - * or if it has been added during purge - * log play. - */ - VolumeID_t PZV_volumeID; /* Volume ID of volume. Note this is - * just a redundent copy of the actual - * volume ID that is placed into the - * beast with VOL_BstNew(). The value - * in bst new is either from the superblock - * (for the _IV_ volume) or from the ZVL - * beasts for Logical Volumes. - */ - Lsn_t PZV_lsn; - Time_t PZV_lastRezidTime; /* UTC time the last time a rezid was done - */ - LONG PZV_reserved[32-8-6-1-4-2-1]; - /* Space for modifications that do not require media format change. - * The size of the ZFSVOL persistent area is 128 bytes. - */ + LONG PZV_magic; /* volinfo magic number */ + LONG PZV_version; + LONG PZV_checksum; + /* Calculated before each NON-LOGGED write of the block. + * Checksum is for all NON LOGGED data. Checksum is + * valid if the NON-LOGGED contents (including this field) + * add up to zero. Use ZFSVOL_CalculateChecksum() to + * perform checksumming. We do not include the LOGGED + * data in the checksum for the following reasons. + * 1) We update the block too often for LOGGING + * 2) All the LOGGED data can be reproduced by Rebuild. + * 3) This LSS stores the LOGGED data in a different + * volume block. + */ + WORD PZV_rezidCount; /* Number of times volume has been rezid */ + WORD PZV_readAheadBlocks;/* Number of blocks to read ahead */ + GUID_t PZV_internalID; /* Internal ID of volume - needs to be at ofsset 16 */ + SQUAD PZV_loggedVolumeDataBlk; /* Block number where the persistent + * LOGGED volume information is stored. + */ + SQUAD PZV_volumeDataBlk; /* Block number where the persistent + * NON-LOGGED volume information is stored. + */ + SQUAD PZV_systemBeastBlkNum; /* Block number where the super beasts + * are located. Its nextleaf link + * points to the left most leaf of + * the beast b-tree. + */ + LONG PZV_ActivationCount; /* Number of times that this volume + * has had an attempt to activate it. + * Used by purge log code to detect + * if a purge log entry should be played + * or if it has been added during purge + * log play. + */ + VolumeID_t PZV_volumeID; /* Volume ID of volume. Note this is + * just a redundent copy of the actual + * volume ID that is placed into the + * beast with VOL_BstNew(). The value + * in bst new is either from the superblock + * (for the _IV_ volume) or from the ZVL + * beasts for Logical Volumes. + */ + Lsn_t PZV_lsn; + Time_t PZV_lastRezidTime; /* UTC time the last time a rezid was done + */ + LONG PZV_reserved[32-8-6-1-4-2-1]; + /* Space for modifications that do not require media format change. + * The size of the ZFSVOL persistent area is 128 bytes. + */ } NSS_MEDIA_STRUCTURE(PersistentZfsVolume_s,PZV_reserved[32-8-6-1-4-2-1]) PersistentZfsVolume_s; typedef struct LoggedPersistentZfsVolume_s { - LONG LPZV_magic; /* volinfo magic number */ - LONG LPZV_version; - Lsn_t LPZV_lsn; /* log sequence number -- needs to be - * at the eighth byte offset. This is not - * part of the checksum because it is - * updated when LOGGED data is changed! - */ - GUID_t LPZV_internalID; /* Internal ID of volume - needs to be at ofsset 16 */ - LONG LPZV_reserved[32-8]; - /* Space for modifications that do not require media format change. - * The size of the logged ZFSVOL persistent area is 128 bytes. - */ + LONG LPZV_magic; /* volinfo magic number */ + LONG LPZV_version; + Lsn_t LPZV_lsn; /* log sequence number -- needs to be + * at the eighth byte offset. This is not + * part of the checksum because it is + * updated when LOGGED data is changed! + */ + GUID_t LPZV_internalID; /* Internal ID of volume - needs to be at ofsset 16 */ + LONG LPZV_reserved[32-8]; + /* Space for modifications that do not require media format change. + * The size of the logged ZFSVOL persistent area is 128 bytes. + */ } NSS_MEDIA_STRUCTURE(LoggedPersistentZfsVolume_s,LPZV_reserved[32-8]) LoggedPersistentZfsVolume_s; typedef struct ZfsVolume_s { - Volume_s vol; - PersistentZfsVolume_s p; /* holds persistent volume information*/ - LoggedPersistentZfsVolume_s logged; /* contains persistent information that is logged*/ - /* The next three block number are where we stored the - * values obtained from the ZVL Beast at LV load time. - * These values MUST only be used to init the same - * block numbers in the persistent area at ACTIVATION - * time. This is done so we can clear the persistent - * area when the volume is not ACTIVE. This is done - * to help find bugs (someone accessing area when LV - * is not ACTIVE). - */ - Blknum_t ZV_loggedVolumeDataBlk; /* Block number where the persistent - * LOGGED volume information is stored. - */ - Blknum_t ZV_volumeDataBlk; /* Block number where the persistent - * NON-LOGGED volume information is stored. - */ - Blknum_t ZV_systemBeastBlkNum; /* Block number where the super beasts - * are located. Its nextleaf link - * points to the left most leaf of - * the beast b-tree. - */ - QUAD zv_bookedInUseBlocks; /* Blocks that have been 'booked' as in - * use. Free B-Tree code uses to track - * 'in use blocks' relative to threads - * that are actively allocating blocks. - * The 'in use blocks' in Volume_s is - * not used because it is a logged - * item (much more overhead to change). - * The 'in use blocks' is only changed - * after we have allocated the blocks. - */ - struct ZfsPool_s *pool; /* Pointer to the internal volume - * that the volume is on. Note that - * the Volume_s has a pointer to the - * pool that the volume is on. Which - * also has a pointer to the internal - * volume. The internal volume is - * the volume that the pool uses to - * store the pool's system objects. The - * pool can not store directly because - * we do not have pool common ops (we - * have volume common ops). - */ - struct ZfsBeastTreeBeast_s *beastTree; /* Beast ZFS B-tree file*/ - struct ZfsNameTree_s *nameTree; /* Name ZFS B-tree file*/ + Volume_s vol; + PersistentZfsVolume_s p; /* holds persistent volume information*/ + LoggedPersistentZfsVolume_s logged; /* contains persistent information that is logged*/ + /* The next three block number are where we stored the + * values obtained from the ZVL Beast at LV load time. + * These values MUST only be used to init the same + * block numbers in the persistent area at ACTIVATION + * time. This is done so we can clear the persistent + * area when the volume is not ACTIVE. This is done + * to help find bugs (someone accessing area when LV + * is not ACTIVE). + */ + Blknum_t ZV_loggedVolumeDataBlk; /* Block number where the persistent + * LOGGED volume information is stored. + */ + Blknum_t ZV_volumeDataBlk; /* Block number where the persistent + * NON-LOGGED volume information is stored. + */ + Blknum_t ZV_systemBeastBlkNum; /* Block number where the super beasts + * are located. Its nextleaf link + * points to the left most leaf of + * the beast b-tree. + */ + QUAD zv_bookedInUseBlocks; /* Blocks that have been 'booked' as in + * use. Free B-Tree code uses to track + * 'in use blocks' relative to threads + * that are actively allocating blocks. + * The 'in use blocks' in Volume_s is + * not used because it is a logged + * item (much more overhead to change). + * The 'in use blocks' is only changed + * after we have allocated the blocks. + */ + struct ZfsPool_s *pool; /* Pointer to the internal volume + * that the volume is on. Note that + * the Volume_s has a pointer to the + * pool that the volume is on. Which + * also has a pointer to the internal + * volume. The internal volume is + * the volume that the pool uses to + * store the pool's system objects. The + * pool can not store directly because + * we do not have pool common ops (we + * have volume common ops). + */ + struct ZfsBeastTreeBeast_s *beastTree; /* Beast ZFS B-tree file*/ + struct ZfsNameTree_s *nameTree; /* Name ZFS B-tree file*/ struct ZfsMFLBeast_s *mfl; /* Modified Files List */ struct ZfsEFLTreeBeast_s *eflTree; /* Event File List */ - struct ZfsUserTreeBeast_s *userTree; /* User ZFS B-tree file */ - struct ZfsDirTreeBeast_s *dirTree; /* Directory ZFS B-tree file */ - struct ZfsPurgeLogBeast_s *ZV_volumePurgeLog; /* This is the Volume's purge log. Do not - * confuse with the Pool's purge log. This - * is the one added for LV support that contains - * volume specific log items. For example, delete - * beast and truncate beast. This was done so - * that LVs would not have to be activated - * to play the POOL's purge log. - */ - struct ZlogBeast_s *zv_zfsLogBeast; /* Quick pointer to ZLOG Beast. We - * include it here just so we do not - * have to go to the ZFS Pool to get*/ - DQhead_t ZV_deleteBlkQ; /* Queue of pool blocks to be deleted. - * This QUEUE is protected by NetWare - * being non-pre-emptive!!! - */ - SNINT unusableFreeBlkCnt; /* Number of blks that are - * currently on the free - * data blks list */ - struct ZLSSVOL_LVD_DeleteQueueInfo_t *ZV_dqi; - /* DQI pointer. Only - * valid while the LV is on the ZLSS master - * delete list. In addition, you must own - * the ZLSSLVDeleteList.ZDL_listLatch to - * ensure that the LV stays on the list. - */ - BOOL ZV_stopPurge; /* When TRUE the Delete LV thread will - * stop its purging. Used by stop API - * to tell thread to actually stop. - */ - GUID_t ZV_internalID; /* Internal GUID used to mark all - * volume blocks. Stopped using the - * volume ID has no one would commit - * to NEVER changing it. For example, - * when a mirror is split apart we - * may re-volumeID one set of volumes - * so that the user can use both - * set of volumes. - */ - Latch_s ZV_vdbLatch; - LONG ZV_RepairFlags; /* Flags describing how the vol loaded for - * rebuild. Bits are defined for conditions - * that failed in loading the vol prior to - * rebuild so rebuild will know what parts - * need to be re-initialized during rebuild. - */ + struct ZfsUserTreeBeast_s *userTree; /* User ZFS B-tree file */ + struct ZfsDirTreeBeast_s *dirTree; /* Directory ZFS B-tree file */ + struct ZfsPurgeLogBeast_s *ZV_volumePurgeLog; /* This is the Volume's purge log. Do not + * confuse with the Pool's purge log. This + * is the one added for LV support that contains + * volume specific log items. For example, delete + * beast and truncate beast. This was done so + * that LVs would not have to be activated + * to play the POOL's purge log. + */ + struct ZlogBeast_s *zv_zfsLogBeast; /* Quick pointer to ZLOG Beast. We + * include it here just so we do not + * have to go to the ZFS Pool to get*/ + DQhead_t ZV_deleteBlkQ; /* Queue of pool blocks to be deleted. + * This QUEUE is protected by NetWare + * being non-pre-emptive!!! + */ + SNINT unusableFreeBlkCnt; /* Number of blks that are + * currently on the free + * data blks list */ + struct ZLSSVOL_LVD_DeleteQueueInfo_t *ZV_dqi; + /* DQI pointer. Only + * valid while the LV is on the ZLSS master + * delete list. In addition, you must own + * the ZLSSLVDeleteList.ZDL_listLatch to + * ensure that the LV stays on the list. + */ + BOOL ZV_stopPurge; /* When TRUE the Delete LV thread will + * stop its purging. Used by stop API + * to tell thread to actually stop. + */ + GUID_t ZV_internalID; /* Internal GUID used to mark all + * volume blocks. Stopped using the + * volume ID has no one would commit + * to NEVER changing it. For example, + * when a mirror is split apart we + * may re-volumeID one set of volumes + * so that the user can use both + * set of volumes. + */ + Latch_s ZV_vdbLatch; + LONG ZV_RepairFlags; /* Flags describing how the vol loaded for + * rebuild. Bits are defined for conditions + * that failed in loading the vol prior to + * rebuild so rebuild will know what parts + * need to be re-initialized during rebuild. + */ #define ZV_REPAIRFLAGS_REBUILD_VOL_DATA_BLOCKS 0x0001 /* could not read in volume data block */ #define ZV_REPAIRFLAGS_REBUILD_VOL_LDATA_BLOCKS 0x0002 /* could not read in volume logged data block */ #define ZV_REPAIRFLAGS_MANUAL_VOL_LOAD 0x2000 /* Rebuild is doing the LoadPersistentPool */ @@ -751,45 +750,45 @@ typedef struct ZfsVolume_s // typedef struct ZfsVolumeBlock_s { - PersistentZfsVolume_s ZVD_zfsVol; - PersistentVolume_s ZVD_volume; - /* IN ADDITION, the volume name in UNICODE is appended here by - * the low level VDB write routines. This is done so that - * re-link can have TWO places to pick up the name of the - * volume (offical place is the Volume Locator Beast). The - * name is not part of this structure for two reasons. - * 1) Saves a little memory (name is already in NamedBeast_s) - * 2) Makes In place upgrade easier as not part of checksum. - * - * Also note that the version of VDBs with the volume name is 5. - */ + PersistentZfsVolume_s ZVD_zfsVol; + PersistentVolume_s ZVD_volume; + /* IN ADDITION, the volume name in UNICODE is appended here by + * the low level VDB write routines. This is done so that + * re-link can have TWO places to pick up the name of the + * volume (offical place is the Volume Locator Beast). The + * name is not part of this structure for two reasons. + * 1) Saves a little memory (name is already in NamedBeast_s) + * 2) Makes In place upgrade easier as not part of checksum. + * + * Also note that the version of VDBs with the volume name is 5. + */ } NSS_MEDIA_STRUCTURE(ZfsVolumeBlock_s,ZVD_volume) ZfsVolumeBlock_s; typedef struct Zfs4KVolumeBlock_s { - ZfsVolumeBlock_s ZVD4K_Persistents; /* all the persistent volume data, only this area is currently checksummed */ - unicode_t ZVD4K_VolName[0x100]; /* backup copy of the volume name, not checksummed */ - PersistentVolumeCrypt_s ZVD4K_zfsCrypt; /* starts at ADDR 0x380-0x3ff */ - /*the crypto data is packed and umpacked in ZFSVOL_WritePersistentVolumeData */ - /* ZFSVOL_WriteInitialVDB, and ZFSVOL_ReadPersistentVolumeData in zfsvolumedata.c */ - BYTE reserved[0x1000 - sizeof(ZfsVolumeBlock_s) - (0x100*sizeof(unicode_t)) - sizeof(PersistentVolumeCrypt_s)]; - /* the reserved area is checkek in compile time calculaton in zfsVolumeData.c */ + ZfsVolumeBlock_s ZVD4K_Persistents; /* all the persistent volume data, only this area is currently checksummed */ + unicode_t ZVD4K_VolName[0x100]; /* backup copy of the volume name, not checksummed */ + PersistentVolumeCrypt_s ZVD4K_zfsCrypt; /* starts at ADDR 0x380-0x3ff */ + /*the crypto data is packed and umpacked in ZFSVOL_WritePersistentVolumeData */ + /* ZFSVOL_WriteInitialVDB, and ZFSVOL_ReadPersistentVolumeData in zfsvolumedata.c */ + BYTE reserved[0x1000 - sizeof(ZfsVolumeBlock_s) - (0x100*sizeof(unicode_t)) - sizeof(PersistentVolumeCrypt_s)]; + /* the reserved area is checkek in compile time calculaton in zfsVolumeData.c */ } NSS_MEDIA_STRUCTURE(Zfs4KVolumeBlock_s,reserved[0x1000 - sizeof(ZfsVolumeBlock_s) - (0x100*sizeof(unicode_t)) - sizeof(PersistentVolumeCrypt_s)]) Zfs4KVolumeBlock_s; typedef struct ZfsLoggedVolumeBlock_s { - LoggedPersistentZfsVolume_s ZLVD_zfsVol; - LoggedPersistentVolume_s ZLVD_volume; + LoggedPersistentZfsVolume_s ZLVD_zfsVol; + LoggedPersistentVolume_s ZLVD_volume; } NSS_MEDIA_STRUCTURE(ZfsLoggedVolumeBlock_s,ZLVD_volume) ZfsLoggedVolumeBlock_s; - /* Log record for VDB updates */ + /* Log record for VDB updates */ typedef struct { - ZfsVolumeBlock_s ZVULR_ValuesOld; - ZfsVolumeBlock_s ZVULR_ValuesNew; + ZfsVolumeBlock_s ZVULR_ValuesOld; + ZfsVolumeBlock_s ZVULR_ValuesNew; } NSS_MEDIA_STRUCTURE(ZfsVDBUpdateLogRecord_s,ZVULR_ValuesNew) ZfsVDBUpdateLogRecord_s; - /* Log record for VDB inits */ + /* Log record for VDB inits */ typedef struct { - ZfsVolumeBlock_s ZVILR_ValuesNew; + ZfsVolumeBlock_s ZVILR_ValuesNew; } NSS_MEDIA_STRUCTURE(ZfsVDBInitLogRecord_s,ZVILR_ValuesNew) ZfsVDBInitLogRecord_s; /* @@ -801,74 +800,74 @@ typedef struct { #define ZLSSPOOL_ACTIVATE 3 /* Loads pool system beasts. FixFixFix6 - * this includes the Beast and Name Tree - * which are volume beasts. Don't need - * to fix until Logical Volumes. - */ + * this includes the Beast and Name Tree + * which are volume beasts. Don't need + * to fix until Logical Volumes. + */ #define ZLSSVOL_ACTIVATE 4 /* Loads rootdir which is in Beast Tree - * so must be after beast tree load. - */ + * so must be after beast tree load. + */ #define ZLSSVOL_ACTIVATE_TIME 9 /* Sets the PV_activationTimeUTC field - * and writes the VDB. - */ + * and writes the VDB. + */ #define ZLSSVOL_DEACTIVATE 4 /* Unloads rootdir which is in Beast Tree - * so must be while beast tree still loaded. - */ + * so must be while beast tree still loaded. + */ #define ZLSSPOOL_DEACTIVATE 5 /* Unloads pool system beasts. */ #define ZLSSPOOL_DEACTIVATE_CLEANUP_LV_DELETES 2 - /* Removes all the pools information - * from the ZLSSLVDeleteList. This - * must be done before the Volume_s - * tosses and flushes because we have - * InUseCounts on the zvlBeasts. - */ + /* Removes all the pools information + * from the ZLSSLVDeleteList. This + * must be done before the Volume_s + * tosses and flushes because we have + * InUseCounts on the zvlBeasts. + */ #define ZLSSVOL_ACTIVE_TO_MAINTENANCE ZLSSVOL_DEACTIVATE #define ZLSSPOOL_ACTIVE_TO_MAINTENANCE ZLSSPOOL_DEACTIVATE #define ZLSSPOOL_LAST 10 /* This is the pass that we play the purge - * log. The purge log likes everything to - * be up and running before doing anything. - * - * Also auto in-place-upgrade also takes place in this pass. - * - * Media 32 -> 33 (add PurgeTree Beast) - * This auto upgrade occurs AFTER the purge log is played. - * This way beasts that were deleted in the last run are not - * placed into the salvage area. Not a big issue because - * salvage is off anyway. - */ + * log. The purge log likes everything to + * be up and running before doing anything. + * + * Also auto in-place-upgrade also takes place in this pass. + * + * Media 32 -> 33 (add PurgeTree Beast) + * This auto upgrade occurs AFTER the purge log is played. + * This way beasts that were deleted in the last run are not + * placed into the salvage area. Not a big issue because + * salvage is off anyway. + */ #define ZLSSVOL_LAST 10 /* Pass that we play the volume purge log */ #define XFUNC_MAX (137+1) /* This is the last XFUNC_ plus 1. It - * is the size that arrays need to - * be to hold the last XFUNC_ item. The - * plus one is needed because 0 is a - * legal item. - */ + * is the size that arrays need to + * be to hold the last XFUNC_ item. The + * plus one is needed because 0 is a + * legal item. + */ typedef struct RecoveryStats_s { - NINT pass1; - NINT pass2; - NINT pass3; - NINT pass4; - NINT pass5; - NINT alloc; - NINT realloc; - struct - { - NINT redo; - NINT undo; - } func[XFUNC_MAX]; - NINT redid; /* How many blocks actually where UNDOne or - * REDOne by REDO/UNDO routine. - */ + NINT pass1; + NINT pass2; + NINT pass3; + NINT pass4; + NINT pass5; + NINT alloc; + NINT realloc; + struct + { + NINT redo; + NINT undo; + } func[XFUNC_MAX]; + NINT redid; /* How many blocks actually where UNDOne or + * REDOne by REDO/UNDO routine. + */ } RecoveryStats_s; @@ -887,44 +886,44 @@ extern CommonVolumeOps_s ZFSPOOL_ComnVolOps; typedef struct ZfsPool_s { - ZfsVolume_s zfsVol; /* Derived from ZFS Vol Beast*/ - NINT ZP_NextCheckpoint; /* Next checkpoint number to - * write to */ - NINT ZP_BadCheckpoints; /* Number of bad checkpoints - * found during activation of - * the pool. */ + ZfsVolume_s zfsVol; /* Derived from ZFS Vol Beast*/ + NINT ZP_NextCheckpoint; /* Next checkpoint number to + * write to */ + NINT ZP_BadCheckpoints; /* Number of bad checkpoints + * found during activation of + * the pool. */ // DQlink_t poolLink; /* link all pools */ -// struct zfsSegment_s *mstsegment; /* master pool/group/segment +// struct zfsSegment_s *mstsegment; /* master pool/group/segment // * (storage) */ - struct StorPool_s *storagepool; /* zlss owned storage pool */ - struct ZFSMemorySuperBlk_s *ZP_super; /* Super block in-memory copy. - * This is only a few of the total blocks. This area - * is just an easy location for the owner of each super - * block block to store their block while the volume is - * active. The activate code allocates this memory and - * the deactivate code frees it. The owner of each block - * in this memory must read and write their own block. - */ - struct ZlogBeast_s *zfsLogBeast; /* Log for pool*/ - struct ZfsPurgeLogBeast_s *purgeLogBeast; /* Log of files being purged - * and extents being freed */ - struct ZfsMYBTreeBeast_s *purgeTree; /* ZfsSalvage system purgeq */ + struct StorPool_s *storagepool; /* zlss owned storage pool */ + struct ZFSMemorySuperBlk_s *ZP_super; /* Super block in-memory copy. + * This is only a few of the total blocks. This area + * is just an easy location for the owner of each super + * block block to store their block while the volume is + * active. The activate code allocates this memory and + * the deactivate code frees it. The owner of each block + * in this memory must read and write their own block. + */ + struct ZlogBeast_s *zfsLogBeast; /* Log for pool*/ + struct ZfsPurgeLogBeast_s *purgeLogBeast; /* Log of files being purged + * and extents being freed */ + struct ZfsMYBTreeBeast_s *purgeTree; /* ZfsSalvage system purgeq */ SQUAD nblks_to_salvage; /* Pending work for purgeThrd */ - struct ZfsFreeExtent_s *freeExtent; /* Free extents in pool*/ - DQhead_t freeDataBlksList; /* List of user data blks that - * have been freed, are kept on - * this list until the - * transaction ends */ + struct ZfsFreeExtent_s *freeExtent; /* Free extents in pool*/ + DQhead_t freeDataBlksList; /* List of user data blks that + * have been freed, are kept on + * this list until the + * transaction ends */ // SQUAD nblks_to_salvage;/* Pending work for purgeThread */ - DQhead_t ZP_deleteBlkQ; /* Queue of pool blocks to be deleted. - * This QUEUE is protected by NetWare - * being non-pre-emptive!!! This list - * contains ALL the blocks for the ALL - * the pool's volumes. The list is in - * in LSN order. - */ - struct RecoveryStats_s zp_stats; - NINT ZP_RepairFlags; /* flags for repair/verify */ + DQhead_t ZP_deleteBlkQ; /* Queue of pool blocks to be deleted. + * This QUEUE is protected by NetWare + * being non-pre-emptive!!! This list + * contains ALL the blocks for the ALL + * the pool's volumes. The list is in + * in LSN order. + */ + struct RecoveryStats_s zp_stats; + NINT ZP_RepairFlags; /* flags for repair/verify */ #define ZP_REPAIRFLAGS_REBUILD_POOL_DATA_BLOCKS 0x0001 /* could not read in pool data block */ #define ZP_REPAIRFLAGS_REBUILD_POOL_LDATA_BLOCKS 0x0002 /* could not read in pool logged data block */ #define ZP_REPAIRFLAGS_REBUILD_POOL_SUPER_BLOCKS 0x0010 /* could not read in super blocks */ @@ -932,31 +931,31 @@ typedef struct ZfsPool_s #define ZP_REPAIRFLAGS_MANUAL_POOL_LOAD 0x2000 /* Rebuild is doing the LoadPersistentPool */ #if 0 - DQhead_t ZP_VolumeList; /* List of all memory resident - * volumes on this pool */ - /** - * We keep the Pool's name tree and beast tree in the pool - * so that we are less dependent on the ZLSS Volume load - * order. This solves the problem that the beast tree - * contains pool beasts that should be loaded before the - * nametree and root directory. - */ - struct ZfsBeastTreeBeast_s *ZP_BeastTree; /* Beast ZFS B-tree file*/ - struct ZfsNameTree_s *ZP_NameTree; /* Name ZFS B-tree file*/ + DQhead_t ZP_VolumeList; /* List of all memory resident + * volumes on this pool */ + /** + * We keep the Pool's name tree and beast tree in the pool + * so that we are less dependent on the ZLSS Volume load + * order. This solves the problem that the beast tree + * contains pool beasts that should be loaded before the + * nametree and root directory. + */ + struct ZfsBeastTreeBeast_s *ZP_BeastTree; /* Beast ZFS B-tree file*/ + struct ZfsNameTree_s *ZP_NameTree; /* Name ZFS B-tree file*/ #endif - GUID_t ZP_OldInternalID; /* Old INTERNAL ID of pool. This is the ID - * the pool had before it was converted - * into a Logical Volume. The LV ended - * up with this ID, but I did not - * feel it was important enough to - * go through all POOL specific system - * beasts to re-ID them. A scan program - * will have to look for one of two - * IDs when looking for POOL specific - * system blocks. - */ + GUID_t ZP_OldInternalID; /* Old INTERNAL ID of pool. This is the ID + * the pool had before it was converted + * into a Logical Volume. The LV ended + * up with this ID, but I did not + * feel it was important enough to + * go through all POOL specific system + * beasts to re-ID them. A scan program + * will have to look for one of two + * IDs when looking for POOL specific + * system blocks. + */ // FsmLite_s ZP_makeFreeSpaceFsm; - Latch_s ZP_SuperblockHeaderLatch; + Latch_s ZP_SuperblockHeaderLatch; } ZfsPool_s; @@ -1058,11 +1057,11 @@ typedef struct ZfsPool_s #define ZLSS_VOLUME_IO_DISABLED( _zlssVolume ) \ - ( ( (_zlssVolume)->ZFSVOLvol.v_ioFlag & VOL_IOF_DISABLE ) || \ - ( ZLSS_POOL_IO_DISABLED(ZLSS_VOLUME_TO_ZLSS_POOL(_zlssVolume)) ) ) + ( ( (_zlssVolume)->ZFSVOLvol.v_ioFlag & VOL_IOF_DISABLE ) || \ + ( ZLSS_POOL_IO_DISABLED(ZLSS_VOLUME_TO_ZLSS_POOL(_zlssVolume)) ) ) #define ZLSS_POOL_IO_DISABLED( _zlssPool ) \ - ( _zlssPool->ZLSSPOOLpool.v_ioFlag & VOL_IOF_DISABLE ) + ( _zlssPool->ZLSSPOOLpool.v_ioFlag & VOL_IOF_DISABLE ) /* * ZLSS_INTERNAL_VOLUME_GET( RootBeast_s *_rootBeast, ZfsPool_s *_poolVolume ); @@ -1074,30 +1073,30 @@ typedef struct ZfsPool_s * the internal volume that the volume/pool beasts are actually stored in. */ #define ZLSS_INTERNAL_VOLUME_GET( _rootBeast, _poolVolume ) \ - if ( _rootBeast->bstState & BST_STATE_IS_VOLUME_OR_POOL ) \ - { /* Volumes and Pools are SPECIAL because of _ADMIN volume */ \ - switch ( _rootBeast->beastClass->classID ) \ - { \ - case zFTYPE_ZLSS_VOL: /* A ZfsVolume_s */ \ - _poolVolume = ((ZfsVolume_s *)_rootBeast)->pool; \ - break; \ - case zFTYPE_ZLSS_ZFSPOOL: /* A ZfsPool_s */ \ - _poolVolume = (ZfsPool_s *)_rootBeast; \ - break; \ - case zFTYPE_ZLSS_LOGICAL_POOL: /* A ZlssPool_s */ \ - _poolVolume = ((ZlssPool_s *)_rootBeast)->ZP_ZfsPool; \ - break; \ - default: \ - zASSERT( "Not a legal class ID"==NULL ); \ - _poolVolume = NULL; \ - break; \ - } \ - } \ - else \ - { \ - _poolVolume = _rootBeast->vol.zfsVol->pool; \ - } \ - zASSERT( _poolVolume != NULL ); + if ( _rootBeast->bstState & BST_STATE_IS_VOLUME_OR_POOL ) \ + { /* Volumes and Pools are SPECIAL because of _ADMIN volume */ \ + switch ( _rootBeast->beastClass->classID ) \ + { \ + case zFTYPE_ZLSS_VOL: /* A ZfsVolume_s */ \ + _poolVolume = ((ZfsVolume_s *)_rootBeast)->pool; \ + break; \ + case zFTYPE_ZLSS_ZFSPOOL: /* A ZfsPool_s */ \ + _poolVolume = (ZfsPool_s *)_rootBeast; \ + break; \ + case zFTYPE_ZLSS_LOGICAL_POOL: /* A ZlssPool_s */ \ + _poolVolume = ((ZlssPool_s *)_rootBeast)->ZP_ZfsPool; \ + break; \ + default: \ + zASSERT( "Not a legal class ID"==NULL ); \ + _poolVolume = NULL; \ + break; \ + } \ + } \ + else \ + { \ + _poolVolume = _rootBeast->vol.zfsVol->pool; \ + } \ + zASSERT( _poolVolume != NULL ); /* * ZLSS_VOLUME_GET( RootBeast_s *_rootBeast, Volume_s *_volume ); @@ -1112,31 +1111,31 @@ typedef struct ZfsPool_s * internal volume (i.e. ZfsPool_s). */ #define ZLSS_VOLUME_GET( _rootBeast, _volume ) \ - if ( _rootBeast->bstState & BST_STATE_IS_VOLUME_OR_POOL ) \ - { /* Volumes and Pools are SPECIAL because of _ADMIN volume */ \ - switch ( _rootBeast->beastClass->classID ) \ - { \ - case zFTYPE_ZLSS_VOL: /* A ZfsVolume_s */ \ - _volume = (Volume_s *)_rootBeast; \ - break; \ - case zFTYPE_ZLSS_ZFSPOOL: /* A ZfsPool_s */ \ - _volume = (Volume_s *)_rootBeast; \ - break; \ - case zFTYPE_ZLSS_LOGICAL_POOL: /* A ZlssPool_s */ \ - _volume = (Volume_s *)(((ZlssPool_s *)_rootBeast)->ZP_ZfsPool);\ - break; \ - default: \ - zASSERT( "Not a legal class ID"==NULL ); \ - _volume = NULL; \ - break; \ - } \ - } \ - else \ - { \ - _volume = _rootBeast->vol.volume; \ - } \ - zASSERT( _volume != NULL ); \ - zASSERT( COMN_IsDerivedFrom(_volume, zFTYPE_ZLSS_VOL) ); + if ( _rootBeast->bstState & BST_STATE_IS_VOLUME_OR_POOL ) \ + { /* Volumes and Pools are SPECIAL because of _ADMIN volume */ \ + switch ( _rootBeast->beastClass->classID ) \ + { \ + case zFTYPE_ZLSS_VOL: /* A ZfsVolume_s */ \ + _volume = (Volume_s *)_rootBeast; \ + break; \ + case zFTYPE_ZLSS_ZFSPOOL: /* A ZfsPool_s */ \ + _volume = (Volume_s *)_rootBeast; \ + break; \ + case zFTYPE_ZLSS_LOGICAL_POOL: /* A ZlssPool_s */ \ + _volume = (Volume_s *)(((ZlssPool_s *)_rootBeast)->ZP_ZfsPool);\ + break; \ + default: \ + zASSERT( "Not a legal class ID"==NULL ); \ + _volume = NULL; \ + break; \ + } \ + } \ + else \ + { \ + _volume = _rootBeast->vol.volume; \ + } \ + zASSERT( _volume != NULL ); \ + zASSERT( COMN_IsDerivedFrom(_volume, zFTYPE_ZLSS_VOL) ); /*========================================================================= @@ -1153,15 +1152,15 @@ extern LSSSpecificPackUnpackOps_s ZFSPURGELOG_lssOps[]; typedef struct PersistentZfsPurgeLog_s { - Blknum_t firstBlock; + Blknum_t firstBlock; } NSS_MEDIA_STRUCTURE(PersistentZfsPurgeLog_s,firstBlock) PersistentZfsPurgeLog_s; typedef struct ZfsPurgeLogBeast_s { - File_s file; /* Derived from File_s */ - PersistentZfsPurgeLog_s p; - ZfsPurgeLogLoc_s freeList; /* head of the free list */ - ZfsPurgeLogLoc_s nextUnused; /* next entry that has never been used */ + File_s file; /* Derived from File_s */ + PersistentZfsPurgeLog_s p; + ZfsPurgeLogLoc_s freeList; /* head of the free list */ + ZfsPurgeLogLoc_s nextUnused; /* next entry that has never been used */ } ZfsPurgeLogBeast_s; #define ZFSPURGELOGroot file.auth.named.root @@ -1188,23 +1187,23 @@ extern LSSSpecificPackUnpackOps_s ZFSBTREE_lssOps[]; typedef struct PersistentZfsBtree_s { - Blknum_t btRoot; /* Btree Root */ - Blknum_t btFree; /* Free B-Tree uses for special block - * that tracks free blocks to be - * used only by the free tree to - * do grows and shrinks. Other - * B-Trees can use for their own purpose. - */ - Blknum_t btLeftMostLeaf; /* left most leaf of the b-tree*/ + Blknum_t btRoot; /* Btree Root */ + Blknum_t btFree; /* Free B-Tree uses for special block + * that tracks free blocks to be + * used only by the free tree to + * do grows and shrinks. Other + * B-Trees can use for their own purpose. + */ + Blknum_t btLeftMostLeaf; /* left most leaf of the b-tree*/ } NSS_MEDIA_STRUCTURE(PersistentZfsBtree_s,btLeftMostLeaf) PersistentZfsBtree_s; typedef struct ZfsBtreeBeast_s { - File_s file; /* A ZFS B-tree "is a" file */ - PersistentZfsBtree_s p; /* Persistent portion*/ - NINT levelsInTree; /* Levels in the tree, if the root it is - * a leaf then it has 1 level - */ + File_s file; /* A ZFS B-tree "is a" file */ + PersistentZfsBtree_s p; /* Persistent portion*/ + NINT levelsInTree; /* Levels in the tree, if the root it is + * a leaf then it has 1 level + */ } ZfsBtreeBeast_s; #define ZFSBTREEroot file.auth.named.root @@ -1229,20 +1228,20 @@ extern LSSSpecificPackUnpackOps_s ZFSFREEEXT_lssOps[]; typedef struct ZfsFreeExtent_s { - ZfsBtreeBeast_s zfsBtree; /* Derived from ZfsBtreeBeast_s - */ + ZfsBtreeBeast_s zfsBtree; /* Derived from ZfsBtreeBeast_s + */ // FsmLite_s wtdFsm; /* Fsm used to schedule a thread // * to replenish btFree block // */ - zWorkProc_s xtreeWtd; /* Work to do to start a thread - * to replenish btFree block - */ - LONG xtreeFlags; /* Non-persistent flag to keep track - * of whether the thread to replenish - * btFree has been scheduled of not - * and if the scheduling needs to - * be stopped. - */ + zWorkProc_s xtreeWtd; /* Work to do to start a thread + * to replenish btFree block + */ + LONG xtreeFlags; /* Non-persistent flag to keep track + * of whether the thread to replenish + * btFree has been scheduled of not + * and if the scheduling needs to + * be stopped. + */ #define XTREE_THREAD_SCHEDULED 0x00000001 #define XTREE_STOP_THREADS 0x00000002 /* The free tree can be called without a transaction. During upgrade to add @@ -1257,39 +1256,39 @@ typedef struct ZfsFreeExtent_s */ #define XTREE_OK_TODO_LOCAL_XACTION 0x00000004 - Blknum_t freeTreeSeed; /* If a freeTree block is requested with - * a seed of zero, use a global seed to move - * across the disk - */ + Blknum_t freeTreeSeed; /* If a freeTree block is requested with + * a seed of zero, use a global seed to move + * across the disk + */ //TODO(Perf,doc): Doc relationship between freeTreeSeed and ZFE_AreaSeed - Latch_s ZFE_AreaLatch; /* Watch out for FT calling (i.e. don't have - FT allocate blocks with this routine) */ - NINT ZFE_AreaSizeDefault; - /* The perferred area size to use for the pool.*/ - NINT ZFE_AreaSizeSmallest; - /* Smallest area size to use before reverting to - old global seed logic. */ + Latch_s ZFE_AreaLatch; /* Watch out for FT calling (i.e. don't have + FT allocate blocks with this routine) */ + NINT ZFE_AreaSizeDefault; + /* The perferred area size to use for the pool.*/ + NINT ZFE_AreaSizeSmallest; + /* Smallest area size to use before reverting to + old global seed logic. */ NINT ZFE_AreaSizeCurrent; - /* Current area size. This is normally the same - as ZFE_AreaSizeDefault. In low space conditions - ZFE_AreaSizeCurrent will be reduced so to still - benefit from the area logic. I.E. related blocks - will be near each other. - */ - uBlknum_t ZFE_AreaSeed; /* Seed to used when XTREE_AF_CONTIGUOUS_TREE + /* Current area size. This is normally the same + as ZFE_AreaSizeDefault. In low space conditions + ZFE_AreaSizeCurrent will be reduced so to still + benefit from the area logic. I.E. related blocks + will be near each other. + */ + uBlknum_t ZFE_AreaSeed; /* Seed to used when XTREE_AF_CONTIGUOUS_TREE is passed to zfsAllocExtent and fail in getting the passed in block. */ - SQUAD ZFE_GrowAreaSize; - /* Number of free blocks needed to up the - ZFE_AreaSizeCurrent size. */ + SQUAD ZFE_GrowAreaSize; + /* Number of free blocks needed to up the + ZFE_AreaSizeCurrent size. */ #if 0 - Blkcnt_t ZFE_AreaSizeCounts[FT_AREA_SIZE_MAX+1]; - /* A 'close' count of the number areas that are - free for a given size. Can be negative because + Blkcnt_t ZFE_AreaSizeCounts[FT_AREA_SIZE_MAX+1]; + /* A 'close' count of the number areas that are + free for a given size. Can be negative because we do not track totally correctly. */ BOOL ZFE_AreaSizeCountsTrack[FT_AREA_SIZE_MAX+1]; - /* Set to TRUE when we are tracking the equivilant - area size count. */ + /* Set to TRUE when we are tracking the equivilant + area size count. */ #endif } ZfsFreeExtent_s; @@ -1330,7 +1329,7 @@ extern LSSSpecificPackUnpackOps_s ZFSNAMETREE_lssOps[]; typedef struct ZfsNameTree_s { - ZfsBtreeBeast_s zfsBtree; + ZfsBtreeBeast_s zfsBtree; } ZfsNameTree_s; #define ZFSNAMETREEroot zfsBtree.file.auth.named.root @@ -1345,7 +1344,7 @@ typedef struct ZfsNameTree_s #define ZFSNAMETREEbeastLatch ZFSNAMETREEroot.mycache.agent.latch #define ZFSNAMETREEfirstParentZID ZFSNAMETREEnamed.firstParent.p.zid -#define ZFSNAMETREEinternalID ZFSNAMETREEroot.ROOTinternalID +#define ZFSNAMETREEinternalID ZFSNAMETREEroot.ROOTinternalID /*========================================================================= @@ -1362,14 +1361,14 @@ extern LSSSpecificPackUnpackOps_s ZFSBEASTTREE_lssOps[]; typedef struct PersistentZfsBeastTree_s { - Blknum_t deletevolumeDataBlk; /* FixFixFix6 remove from Beast B-Tree */ + Blknum_t deletevolumeDataBlk; /* FixFixFix6 remove from Beast B-Tree */ } NSS_MEDIA_STRUCTURE(PersistentZfsBeastTree_s,deletevolumeDataBlk) PersistentZfsBeastTree_s; typedef struct ZfsBeastTreeBeast_s { - ZfsBtreeBeast_s zfsBtree; /* Derived from ZfsBtreeBeast_s */ - PersistentZfsBeastTree_s p; - Blknum_t specialSystemBstsBlk; + ZfsBtreeBeast_s zfsBtree; /* Derived from ZfsBtreeBeast_s */ + PersistentZfsBeastTree_s p; + Blknum_t specialSystemBstsBlk; } ZfsBeastTreeBeast_s; #define ZFSBEASTTREEroot zfsBtree.file.auth.named.root @@ -1404,7 +1403,7 @@ typedef struct ZfsBeastTreeBeast_s */ typedef struct ZfsMYBTreeBeast_s { - ZfsBtreeBeast_s zfsBtree; /* Derived from ZfsBtreeBeast_s */ + ZfsBtreeBeast_s zfsBtree; /* Derived from ZfsBtreeBeast_s */ // PersistentZfsPurgeTree_s p; } ZfsMYBTreeBeast_s; @@ -1448,16 +1447,16 @@ extern LSSSpecificPackUnpackOps_s ZFSMYBTREE_lssOps[]; typedef ZfsMYBTreeBeast_s ZfsPurgeTreeBeast_s; #define ZFSPURGETREEroot ZFSMYBTREEroot -#define ZFSPURGETREEzid ZFSMYBTREEzid -#define ZFSPURGETREEstate ZFSMYBTREEstate -#define ZFSPURGETREEvolLink ZFSMYBTREEvolLink -#define ZFSPURGETREEstorage ZFSMYBTREEstorage -#define ZFSPURGETREEbeastLatch ZFSMYBTREEbeastLatch +#define ZFSPURGETREEzid ZFSMYBTREEzid +#define ZFSPURGETREEstate ZFSMYBTREEstate +#define ZFSPURGETREEvolLink ZFSMYBTREEvolLink +#define ZFSPURGETREEstorage ZFSMYBTREEstorage +#define ZFSPURGETREEbeastLatch ZFSMYBTREEbeastLatch #define ZFSPURGETREEvolume ZFSMYBTREEvolume #define ZFSPURGETREEzbtree ZFSMYBTREEzbtree -#define ZFSPURGETREEfirstParentZID ZFSMYBTREEfirstParentZID -#define ZFSPURGETREEbtRoot ZFSMYBTREEbtRoot +#define ZFSPURGETREEfirstParentZID ZFSMYBTREEfirstParentZID +#define ZFSPURGETREEbtRoot ZFSMYBTREEbtRoot /*========================================================================= *========================================================================= @@ -1479,15 +1478,15 @@ typedef struct ZfsMFLBeast_s #define ZFSMFLBTREE myBTree #define ZFSMFLincomplete incomplete #define ZFSMFLroot ZFSMFLBTREE.ZFSMYBTREEroot -#define ZFSMFLzid ZFSMFLBTREE.ZFSMYBTREEzid -#define ZFSMFLstate ZFSMFLBTREE.ZFSMYBTREEstate -#define ZFSMFLvolLink ZFSMFLBTREE.ZFSMYBTREEvolLink -#define ZFSMFLstorage ZFSMFLBTREE.ZFSMYBTREEstorage -#define ZFSMFLbeastLatch ZFSMFLBTREE.ZFSMYBTREEbeastLatch +#define ZFSMFLzid ZFSMFLBTREE.ZFSMYBTREEzid +#define ZFSMFLstate ZFSMFLBTREE.ZFSMYBTREEstate +#define ZFSMFLvolLink ZFSMFLBTREE.ZFSMYBTREEvolLink +#define ZFSMFLstorage ZFSMFLBTREE.ZFSMYBTREEstorage +#define ZFSMFLbeastLatch ZFSMFLBTREE.ZFSMYBTREEbeastLatch #define ZFSMFLvolume ZFSMFLBTREE.ZFSMYBTREEvolume -#define ZFSMFLfirstParentZID ZFSMFLBTREE.ZFSMYBTREEfirstParentZID -#define ZFSMFLbtRoot ZFSMFLBTREE.ZFSMYBTREEbtRoot +#define ZFSMFLfirstParentZID ZFSMFLBTREE.ZFSMYBTREEfirstParentZID +#define ZFSMFLbtRoot ZFSMFLBTREE.ZFSMYBTREEbtRoot /*========================================================================= *========================================================================= @@ -1503,7 +1502,7 @@ extern LSSSpecificPackUnpackOps_s ZFSUSERTREE_lssOps[]; typedef struct ZfsUserTreeBeast_s { - ZfsBtreeBeast_s zfsBtree; /* Derived from ZfsBtreeBeast_s */ + ZfsBtreeBeast_s zfsBtree; /* Derived from ZfsBtreeBeast_s */ } ZfsUserTreeBeast_s; #define ZFSUSERTREEroot zfsBtree.file.auth.named.root @@ -1537,7 +1536,7 @@ extern LSSSpecificPackUnpackOps_s ZFSDIRTREE_lssOps[]; typedef struct ZfsDirTreeBeast_s { - ZfsBtreeBeast_s zfsBtree; /* Derived from ZfsBtreeBeast_s */ + ZfsBtreeBeast_s zfsBtree; /* Derived from ZfsBtreeBeast_s */ } ZfsDirTreeBeast_s; #define ZFSDIRTREEroot zfsBtree.file.auth.named.root @@ -1576,25 +1575,25 @@ extern BOOL EFLDisplay; typedef struct ZfsEFLEpoch_s { - EFLEpoch_t epoch; - Time_t lastAlive; + EFLEpoch_t epoch; + Time_t lastAlive; } NSS_MEDIA_STRUCTURE(ZfsEFLEpoch_s,lastAlive) ZfsEFLEpoch_s; typedef struct PersistentZfsEFLTree_s { - EFLEpochMask_t activeEpochs; - EFLEpochMask_t usedEpochs; - LONG nameSpace; - LONG inactiveInterval; /* epoch inactive interval, in seconds */ - Blknum_t logHeaderBlock; /* the header block for the EFL log */ - LONG extra[3]; - ZfsEFLEpoch_s epochs[MAX_ZFS_EFL_EPOCHS]; + EFLEpochMask_t activeEpochs; + EFLEpochMask_t usedEpochs; + LONG nameSpace; + LONG inactiveInterval; /* epoch inactive interval, in seconds */ + Blknum_t logHeaderBlock; /* the header block for the EFL log */ + LONG extra[3]; + ZfsEFLEpoch_s epochs[MAX_ZFS_EFL_EPOCHS]; } NSS_MEDIA_STRUCTURE(PersistentZfsEFLTree_s,epochs[MAX_ZFS_EFL_EPOCHS]) PersistentZfsEFLTree_s; typedef struct ZfsEFLTreeBeast_s { - ZfsBtreeBeast_s zfsBtree; /* Derived from ZfsBtreeBeast_s */ - PersistentZfsEFLTree_s p; + ZfsBtreeBeast_s zfsBtree; /* Derived from ZfsBtreeBeast_s */ + PersistentZfsEFLTree_s p; } ZfsEFLTreeBeast_s; #define ZFSEFLTREEroot zfsBtree.file.auth.named.root @@ -1627,15 +1626,15 @@ typedef struct ZfsEFLTreeBeast_s *=========================================================================*/ typedef struct ZnodeHeader_s { - WORD length; /* PERSISTENT - length of the znode */ - WORD magic; /* PERSISTENT - Znode magic number */ - LONG type; /* PERSISTENT - Type - beast class ID */ - Zid_t zid; /* PERSISTENT - Id for znode */ - /* - * DO NOT ADD TO THIS STRUCTURE - unless you place the beast layout - * at offset 16. It is currently located there via the structure - * ZFSPackedRoot_s. - */ + WORD length; /* PERSISTENT - length of the znode */ + WORD magic; /* PERSISTENT - Znode magic number */ + LONG type; /* PERSISTENT - Type - beast class ID */ + Zid_t zid; /* PERSISTENT - Id for znode */ + /* + * DO NOT ADD TO THIS STRUCTURE - unless you place the beast layout + * at offset 16. It is currently located there via the structure + * ZFSPackedRoot_s. + */ } NSS_MEDIA_STRUCTURE(ZnodeHeader_s,zid) ZnodeHeader_s; /* @@ -1683,15 +1682,15 @@ typedef struct ZnodeHeader_s typedef struct Znode_s { - ZnodeHeader_s header; - BYTE data[1]; /* Variable length data from the beast */ + ZnodeHeader_s header; + BYTE data[1]; /* Variable length data from the beast */ } NSS_MEDIA_STRUCTURE(Znode_s,data[1]) Znode_s; #define MAX_BLK_NUM 0x80000000 /* All logical block numbers must be less - * than this value. (signed values are - * reserved for file map blocks.) - */ + * than this value. (signed values are + * reserved for file map blocks.) + */ #define INVALID_BLK MAX_BLK_NUM /* Used to designate an invalid block number */ #define INVALID_BLK_ZERO 0 /* Used to designate an invalid block number in new structures*/ @@ -1704,56 +1703,56 @@ typedef struct Znode_s #endif typedef struct V1_ZFSPackedRoot_s { - ZnodeHeader_s header; - BYTE beastLayout; /* OFFSET 16. Beast layout version number. - * Indicates the format of the rest of the - * persistent information. - */ - BYTE blkSizeShift; - WORD sizeFmap; - LONG metaDataSeqNum; - QUAD eof; - Blknum_t nextBlk; - Blknum_t fmapDataBlks; - Blknum_t fmapTreeBlks; - LONG rebuildMagic; - LONG rebuildReZid; /* Save the low part of the zid here while - * while reZidding - */ - BYTE rebuildReZidState; /* Use this field to determine is this - * beast has been rezid. - */ - BYTE rebuildReserved;/* If rebuildMagic == REBUILD_DELETE_BEAST_MAGIC then reason (valid during rebuild only) */ - WORD variableSize; /* Size of variable packed root data */ + ZnodeHeader_s header; + BYTE beastLayout; /* OFFSET 16. Beast layout version number. + * Indicates the format of the rest of the + * persistent information. + */ + BYTE blkSizeShift; + WORD sizeFmap; + LONG metaDataSeqNum; + QUAD eof; + Blknum_t nextBlk; + Blknum_t fmapDataBlks; + Blknum_t fmapTreeBlks; + LONG rebuildMagic; + LONG rebuildReZid; /* Save the low part of the zid here while + * while reZidding + */ + BYTE rebuildReZidState; /* Use this field to determine is this + * beast has been rezid. + */ + BYTE rebuildReserved;/* If rebuildMagic == REBUILD_DELETE_BEAST_MAGIC then reason (valid during rebuild only) */ + WORD variableSize; /* Size of variable packed root data */ /* Extent_s fmap[];*/ /*the extent map starts at this location*/ } NSS_MEDIA_STRUCTURE(V1_ZFSPackedRoot_s,variableSize) V1_ZFSPackedRoot_s; typedef struct ZFSPackedRoot_s { - ZnodeHeader_s header; - BYTE beastLayout; /* OFFSET 16. Beast layout version number. - * Indicates the format of the rest of the - * persistent information. - */ - BYTE blkSizeShift; - WORD sizeFmap; - LONG metaDataSeqNum; - QUAD eof; - UserID_t ownerID; - Blknum_t nextBlk; - Blknum_t fmapDataBlks; - Blknum_t fmapTreeBlks; - LONG rebuildMagic; /* We only pack a good value in this field - * for rebuild. It is not unpacked */ - LONG rebuildReZid; /* Save the low part of the zid here while - * while reZidding - */ - BYTE rebuildReZidState; /* Use this field to determine is this - * beast has been rezid. - */ - BYTE rebuildReserved;/* If rebuildMagic == REBUILD_DELETE_BEAST_MAGIC then reason (valid during rebuild only) */ - WORD variableSize; /* Size of variable packed root data */ + ZnodeHeader_s header; + BYTE beastLayout; /* OFFSET 16. Beast layout version number. + * Indicates the format of the rest of the + * persistent information. + */ + BYTE blkSizeShift; + WORD sizeFmap; + LONG metaDataSeqNum; + QUAD eof; + UserID_t ownerID; + Blknum_t nextBlk; + Blknum_t fmapDataBlks; + Blknum_t fmapTreeBlks; + LONG rebuildMagic; /* We only pack a good value in this field + * for rebuild. It is not unpacked */ + LONG rebuildReZid; /* Save the low part of the zid here while + * while reZidding + */ + BYTE rebuildReZidState; /* Use this field to determine is this + * beast has been rezid. + */ + BYTE rebuildReserved;/* If rebuildMagic == REBUILD_DELETE_BEAST_MAGIC then reason (valid during rebuild only) */ + WORD variableSize; /* Size of variable packed root data */ /* Extent_s fmap[];*/ /*the extent map starts at this location*/ } NSS_MEDIA_STRUCTURE(ZFSPackedRoot_s,variableSize) ZFSPackedRoot_s; @@ -1771,71 +1770,71 @@ typedef struct ZFSPackedRoot_s typedef struct { - LONG ZPIOH_SignatureMajor; /* ZLSS Pool Signature */ - LONG ZPIOH_SignatureMinor; /* I/O Log information */ - WORD ZPIOH_VersionMajor; - WORD ZPIOH_VersionMinor; - LONG ZPIOH_Pws; /* Index */ + LONG ZPIOH_SignatureMajor; /* ZLSS Pool Signature */ + LONG ZPIOH_SignatureMinor; /* I/O Log information */ + WORD ZPIOH_VersionMajor; + WORD ZPIOH_VersionMinor; + LONG ZPIOH_Pws; /* Index */ - LONG ZPIOH_Prs; - LONG ZPIOH_DataOffset; /* Index of where data starts in - * the dump file (0 relative). - */ - LONG pad0; - LONG pad1; + LONG ZPIOH_Prs; + LONG ZPIOH_DataOffset; /* Index of where data starts in + * the dump file (0 relative). + */ + LONG pad0; + LONG pad1; - char ZPIOH_Servername[16]; + char ZPIOH_Servername[16]; - LONG ZPIOH_ZSTOREMajorVersion; - LONG ZPIOH_ZSTOREMinorVersion; - LONG ZPIOH_ZSTORESubVersion; - LONG ZPIOH_ZSTOREBuildNumber; + LONG ZPIOH_ZSTOREMajorVersion; + LONG ZPIOH_ZSTOREMinorVersion; + LONG ZPIOH_ZSTORESubVersion; + LONG ZPIOH_ZSTOREBuildNumber; - LONG ZPIOH_UTCTime; /* Time that data was obtained */ - LONG ZPIOH_Start; /* Index of start of circular buffer */ - LONG ZPIOH_Next; /* Next free slot (IE end of buffer) */ - LONG ZPIOH_Size; + LONG ZPIOH_UTCTime; /* Time that data was obtained */ + LONG ZPIOH_Start; /* Index of start of circular buffer */ + LONG ZPIOH_Next; /* Next free slot (IE end of buffer) */ + LONG ZPIOH_Size; } ZLSSPoolIOHeader_s; typedef struct { - BYTE ZPIOLH_Size; /* Number of bytes in record. Used - * so some readers can just skip - * records they do not know format - * of. - */ - BYTE ZPIOLH_Format; /* */ - #define ZPIOLH_FORMAT_STANDARD 0x0001 - WORD ZPIOLH_State; /* */ - #define ZPIOLH_STATE_WRITE_START 0x0001 - #define ZPIOLH_STATE_WRITE_COMPLETE 0x0002 - #define ZPIOLH_STATE_READ_START 0x0003 - #define ZPIOLH_STATE_READ_ASYNC_START 0x0004 - #define ZPIOLH_STATE_READ_COMPLETE 0x0005 - #define ZPIOLH_STATE_DIO_WRITE_START 0x0006 /* Only used for summary information */ - #define ZPIOLH_STATE_DIO_READ_START 0x0007 /* No details are logged for DIO items */ + BYTE ZPIOLH_Size; /* Number of bytes in record. Used + * so some readers can just skip + * records they do not know format + * of. + */ + BYTE ZPIOLH_Format; /* */ + #define ZPIOLH_FORMAT_STANDARD 0x0001 + WORD ZPIOLH_State; /* */ + #define ZPIOLH_STATE_WRITE_START 0x0001 + #define ZPIOLH_STATE_WRITE_COMPLETE 0x0002 + #define ZPIOLH_STATE_READ_START 0x0003 + #define ZPIOLH_STATE_READ_ASYNC_START 0x0004 + #define ZPIOLH_STATE_READ_COMPLETE 0x0005 + #define ZPIOLH_STATE_DIO_WRITE_START 0x0006 /* Only used for summary information */ + #define ZPIOLH_STATE_DIO_READ_START 0x0007 /* No details are logged for DIO items */ - LONG ZPIOLH_Time; /* High Res timer time */ - LONG ZPIOLH_ZidVolume; /* Zid of volume write occuring on */ + LONG ZPIOLH_Time; /* High Res timer time */ + LONG ZPIOLH_ZidVolume; /* Zid of volume write occuring on */ } ZLSSPoolIOLogHeader_s; typedef struct { - ZLSSPoolIOLogHeader_s ZPIOL_Header; - Blknum_t ZPIOL_C_BlockPool; /* Physical block number */ - LONG ZPIOL_C_Data; /* First 4 bytes of DATA wrote. We - * store on write complete so that - * record matches the read complete - * record. Read does not know what - * was read until after the read - * completes. - */ + ZLSSPoolIOLogHeader_s ZPIOL_Header; + Blknum_t ZPIOL_C_BlockPool; /* Physical block number */ + LONG ZPIOL_C_Data; /* First 4 bytes of DATA wrote. We + * store on write complete so that + * record matches the read complete + * record. Read does not know what + * was read until after the read + * completes. + */ } ZLSSPoolIOLog_Complete_s; typedef struct { - ZLSSPoolIOLogHeader_s ZPIOL_Header; - LONG ZPIOL_S_ZidBeast; /* Zid of beast doing write */ - Blknum_t ZPIOL_S_BlockFile; /* File's logical block number */ - Blknum_t ZPIOL_S_BlockPool; /* Physical block number */ + ZLSSPoolIOLogHeader_s ZPIOL_Header; + LONG ZPIOL_S_ZidBeast; /* Zid of beast doing write */ + Blknum_t ZPIOL_S_BlockFile; /* File's logical block number */ + Blknum_t ZPIOL_S_BlockPool; /* Physical block number */ } ZLSSPoolIOLog_Start_s; @@ -1847,40 +1846,40 @@ typedef struct { typedef struct IOErrorLog_s { - Time_t IOEL_UTCTime; - BOOL IOEL_System; /* TRUE - System else User */ - BOOL IOEL_Read; /* TRUE - Read else Write */ - Blknum_t IOEL_VolumeBlock; - Blknum_t IOEL_FileBlock; - LONG IOEL_ErrorMediaManager; - STATUS IOEL_Status; - Zid_t IOEL_Zid; - unicode_t IOEL_PoolName[64]; + Time_t IOEL_UTCTime; + BOOL IOEL_System; /* TRUE - System else User */ + BOOL IOEL_Read; /* TRUE - Read else Write */ + Blknum_t IOEL_VolumeBlock; + Blknum_t IOEL_FileBlock; + LONG IOEL_ErrorMediaManager; + STATUS IOEL_Status; + Zid_t IOEL_Zid; + unicode_t IOEL_PoolName[64]; } IOErrorLog_s; /* - * this struct is used to produce information about the IOs being + * this struct is used to produce information about the IOs being * processed by the zlss module. */ typedef struct { - LONG writeIn; - LONG writeOut; - LONG writeInXdata; /* Other objects dependent on this being written */ - LONG writeOutXdata; - LONG readIn; - LONG readOut; - LONG readWIn; - LONG readWOut; + LONG writeIn; + LONG writeOut; + LONG writeInXdata; /* Other objects dependent on this being written */ + LONG writeOutXdata; + LONG readIn; + LONG readOut; + LONG readWIn; + LONG readWOut; } ZLSSIOsInst_s; #define ZLSS_POOL_IO_LOG_SPACE 256 /* Amount of spare at end of buffer. This - * spare space is used so that wrap is - * easier. Note that space must be greater - * than largest record placed into the - * circular buffer. - */ + * spare space is used so that wrap is + * easier. Note that space must be greater + * than largest record placed into the + * circular buffer. + */ extern ZLSSIOsInst_s IOsInst; extern PoolWriteStatistics_s gZLSSPWS; @@ -1894,229 +1893,229 @@ extern NINT gZLSSGatherDetailedIOInformation; void ZIO_GatherDetailedSummaryInformationDIO( - RootBeast_s *beast, - int state, - LONG dioUnits ); /* Each unit is DIO_UNIT_SIZE bytes */ + RootBeast_s *beast, + int state, + LONG dioUnits ); /* Each unit is DIO_UNIT_SIZE bytes */ STATUS ZLSSPOOL_MediaIsCorrupt( - GeneralMsg_s *genMsg, - Buffer_s *corruptedBuffer, - struct IoMsg_s *iomsg ); + GeneralMsg_s *genMsg, + Buffer_s *corruptedBuffer, + struct IoMsg_s *iomsg ); STATUS ZFSPOOL_Activate( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - NINT mode, - NINT zmode ); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + NINT mode, + NINT zmode ); STATUS ZFSPOOL_ActivateAllLVsQuasi( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool); void ZFSPOOL_DeactivateAllQuasiActiveLVs( - struct ZfsPool_s *pool); + struct ZfsPool_s *pool); STATUS ZPSPOOL_AIPU32To33( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - NINT mode ); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + NINT mode ); STATUS ZLVAIPU_AIPU4001To4006( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - NINT mode ); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + NINT mode ); STATUS ZFSPOOL_Deactivate( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - NINT mode ); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + NINT mode ); STATUS ZFSVOL_Activate( - struct GeneralMsg_s *genMsg, - struct ZfsVolume_s *zfsVol, - NINT mode ); + struct GeneralMsg_s *genMsg, + struct ZfsVolume_s *zfsVol, + NINT mode ); STATUS ZFSVOL_Deactivate( - struct GeneralMsg_s *genMsg, - struct ZfsVolume_s *zfsVol, - NINT mode ); + struct GeneralMsg_s *genMsg, + struct ZfsVolume_s *zfsVol, + NINT mode ); void ZFSVOL_UnLoadSystemBeasts( - struct ZfsVolume_s *vol); + struct ZfsVolume_s *vol); STATUS ZFSVOL_DoFlushSystemBeasts( - struct GeneralMsg_s *genMsg, - struct ZfsVolume_s *vol, - BOOL deactivating); /* if TRUE we are deactivating the volume, else flushing */ + struct GeneralMsg_s *genMsg, + struct ZfsVolume_s *vol, + BOOL deactivating); /* if TRUE we are deactivating the volume, else flushing */ -STATUS ZFSPOOL_LoadPersistentPool( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - NINT volmode, /* Must be a VOLMODE_ define */ - NINT flags, /* Must be a LPP_FLAGS_ define */ - BOOL ioStateTransition, - NINT requestedState ); /* Required only if ioStateTransition is TRUE */ +STATUS ZFSPOOL_LoadPersistentPool( + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + NINT volmode, /* Must be a VOLMODE_ define */ + NINT flags, /* Must be a LPP_FLAGS_ define */ + BOOL ioStateTransition, + NINT requestedState ); /* Required only if ioStateTransition is TRUE */ #define LPP_FLAGS_NO_VERSION_MESSAGES 0x0001 /* Don't display version - * info or errors. - */ + * info or errors. + */ STATUS ZFSVOL_WriteInitialLVDB( - GeneralMsg_s *genMsg, - ZfsVolume_s *zlssVol, - struct ZfsXaction_s *zfsXaction ); + GeneralMsg_s *genMsg, + ZfsVolume_s *zlssVol, + struct ZfsXaction_s *zfsXaction ); STATUS ZFSVOL_WriteInitialVDB( - GeneralMsg_s *genMsg, - ZfsVolume_s *zlssVol, - struct ZfsXaction_s *zfsXaction ); + GeneralMsg_s *genMsg, + ZfsVolume_s *zlssVol, + struct ZfsXaction_s *zfsXaction ); void ZLSSPOOL_PoolDataInitialize( - struct ZlssPool_s *zlssPool, - Blknum_t totalBlocks, - LONG blockShift, - QUAD persistentElsewhere ); + struct ZlssPool_s *zlssPool, + Blknum_t totalBlocks, + LONG blockShift, + QUAD persistentElsewhere ); -void ZFSPOOL_UnloadPersistentPool( - ZfsPool_s *pool, - NINT mode ); +void ZFSPOOL_UnloadPersistentPool( + ZfsPool_s *pool, + NINT mode ); STATUS ZFSPOOL_SuperBlockMove( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - struct StorPool_s *storagepool, - struct ZfsXaction_s *zfsXaction ); + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + struct StorPool_s *storagepool, + struct ZfsXaction_s *zfsXaction ); STATUS ZFSPOOL_SuperBlockPoolInitialize( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool); STATUS ZFSPOOL_SuperBlock12Initialize( - struct GeneralMsg_s *genMsg, - struct StorPool_s *storagepool, - struct MediaSuperBlockHeader_s *super ); + struct GeneralMsg_s *genMsg, + struct StorPool_s *storagepool, + struct MediaSuperBlockHeader_s *super ); STATUS ZFSPOOL_SuperBlockWriteByBlock( - struct GeneralMsg_s *genMsg, - struct StorPool_s *storagepool, - struct MediaSuperBlockHeader_s *super, - NINT superblockNumber, /* 0, 1, 2 or 3 */ - NINT section, /* 0, 1, ... 14 or 15 */ - void *data ); + struct GeneralMsg_s *genMsg, + struct StorPool_s *storagepool, + struct MediaSuperBlockHeader_s *super, + NINT superblockNumber, /* 0, 1, 2 or 3 */ + NINT section, /* 0, 1, ... 14 or 15 */ + void *data ); STATUS ZFSPOOL_SuperBlockReadByBlock( - struct GeneralMsg_s *genMsg, - struct StorPool_s *storagepool, - struct MediaSuperBlockHeader_s *super, - NINT superblockNumber, /* 0, 1, 2 or 3 */ - NINT section, /* 0, 1, ... 14 or 15 */ - void *data ); + struct GeneralMsg_s *genMsg, + struct StorPool_s *storagepool, + struct MediaSuperBlockHeader_s *super, + NINT superblockNumber, /* 0, 1, 2 or 3 */ + NINT section, /* 0, 1, ... 14 or 15 */ + void *data ); STATUS ZFSMAL_PhysicalExtent( - ZfsVolume_s *zfsVol, - QUAD poolOffset, - QUAD poolLength, - ADDR *deviceID, - QUAD *deviceOffset, - QUAD *deviceLength ); + ZfsVolume_s *zfsVol, + QUAD poolOffset, + QUAD poolLength, + ADDR *deviceID, + QUAD *deviceOffset, + QUAD *deviceLength ); void ZFSMAL_asyncReadBlk(struct Asyncio_s *zio); STATUS ZFSMAL_ReadBlk(struct GeneralMsg_s *genMsg, struct Buffer_s *buffer); void ZFS_BlockSignalHandler( - struct Agent_s *agent); + struct Agent_s *agent); void ZFS_DoBlockWriteFromSignal( - struct Agent_s *agent, - AgentSignalFunc_t writeDoneHandler); + struct Agent_s *agent, + AgentSignalFunc_t writeDoneHandler); struct zConPool_s; STATUS ZFS_WritePoolBlk( struct GeneralMsg_s *genMsg, - struct zConPool_s *phypool, - struct Buffer_s *buffer ); + struct zConPool_s *phypool, + struct Buffer_s *buffer ); struct Buffer_s *ZFS_ReadPoolBlk( - struct GeneralMsg_s *genMsg, - struct IoMsg_s *iomsg); + struct GeneralMsg_s *genMsg, + struct IoMsg_s *iomsg); Buffer_s *ZFS_AllocPoolBlkSpecialWithFlags( - struct GeneralMsg_s *genMsg, - struct IoMsg_s *iomsg, - struct Buffer_s **specialBuffer, - NINT allocFlags); + struct GeneralMsg_s *genMsg, + struct IoMsg_s *iomsg, + struct Buffer_s **specialBuffer, + NINT allocFlags); #define XTREE_SYSTEM_REQUEST 0x01 #define XTREE_CONTIGUOUS_BLKS 0x02 #define XTREE_AF_NEAR_TREE 0x04 /* If we can not allocate 'near' the - seed block then we allocate from a new free - area. Used to indicate you want the blocks - of a tree contiguous with each other. */ + seed block then we allocate from a new free + area. Used to indicate you want the blocks + of a tree contiguous with each other. */ #define XTREE_AF_NEW_AREA 0x08 /* Allocate in a 'new area' */ static inline Buffer_s *ZFS_AllocPoolBlkSpecial( - struct GeneralMsg_s *genMsg, - struct IoMsg_s *iomsg, - struct Buffer_s **specialBuffer) + struct GeneralMsg_s *genMsg, + struct IoMsg_s *iomsg, + struct Buffer_s **specialBuffer) { - return ZFS_AllocPoolBlkSpecialWithFlags(genMsg,iomsg,specialBuffer,XTREE_SYSTEM_REQUEST); + return ZFS_AllocPoolBlkSpecialWithFlags(genMsg,iomsg,specialBuffer,XTREE_SYSTEM_REQUEST); } static inline Buffer_s *ZFS_AllocPoolBlk( - struct GeneralMsg_s *genMsg, - struct IoMsg_s *iomsg ) + struct GeneralMsg_s *genMsg, + struct IoMsg_s *iomsg ) { - return ZFS_AllocPoolBlkSpecialWithFlags(genMsg,iomsg,NULL,XTREE_SYSTEM_REQUEST); + return ZFS_AllocPoolBlkSpecialWithFlags(genMsg,iomsg,NULL,XTREE_SYSTEM_REQUEST); } void ZFS_ReadAheadPoolBlk( - struct IoMsg_s *iomsg); - + struct IoMsg_s *iomsg); + STATUS ZFSVOL_ReadPersistentVolumeData( - struct GeneralMsg_s *genMsg, - struct ZfsVolume_s *zlssVol); + struct GeneralMsg_s *genMsg, + struct ZfsVolume_s *zlssVol); void ZFSVOL_WritePersistentVolumeData( - struct ZfsVolume_s *vol); + struct ZfsVolume_s *vol); void ZFSVOL_VOL_WriteVolumeLoggedData( - struct Volume_s *vol, - struct Xaction_s *xaction, - struct VolInfoLog_s *volLog); + struct Volume_s *vol, + struct Xaction_s *xaction, + struct VolInfoLog_s *volLog); void ZFSVOL_WritePersistentVolumeDataXactioned( - struct ZfsVolume_s *zlssVol, - struct ZfsXaction_s *xaction); + struct ZfsVolume_s *zlssVol, + struct ZfsXaction_s *xaction); STATUS ZLSSPOOL_WriteVolumeLoggedData( - struct GeneralMsg_s *genMsg, - struct ZlssPool_s *zlssPool, - struct Xaction_s *xaction, /* Can not be NULL */ - struct VolInfoLog_s *volLog); + struct GeneralMsg_s *genMsg, + struct ZlssPool_s *zlssPool, + struct Xaction_s *xaction, /* Can not be NULL */ + struct VolInfoLog_s *volLog); STATUS ZFSVOL_VOL_FlushSystemBeasts( - struct GeneralMsg_s *genMsg, - void *vol); + struct GeneralMsg_s *genMsg, + void *vol); /*------------------------------------------------------------------------- * ZLSS General macros *-------------------------------------------------------------------------*/ - /* Both tests needed because - System beast with file maps don't use negative fileblock - numbers(ZLOG, REbuild file, ...). While File Map Blocks use - the beast's ZID the file map represents. - */ + /* Both tests needed because + System beast with file maps don't use negative fileblock + numbers(ZLOG, REbuild file, ...). While File Map Blocks use + the beast's ZID the file map represents. + */ #define ZLSS_IS_SYSTEM_BLOCK(_rootBeast, _buf ) \ - ((_buf->pBuf.fileBlk < 0) || (_buf->volBlk == 0) || (_rootBeast->zid < zFIRST_ALLOCATABLE_ZID)) + ((_buf->pBuf.fileBlk < 0) || (_buf->volBlk == 0) || (_rootBeast->zid < zFIRST_ALLOCATABLE_ZID)) - /* Is the volume (or its pool) doing MAINTENANCE IO? */ + /* Is the volume (or its pool) doing MAINTENANCE IO? */ #define ZLSS_IS_MAINTENANCE_IO( _volume ) \ - ( (_volume->maintenanceStatus & \ - (VOLMAINTSTATUS_CHECKING|VOLMAINTSTATUS_REPAIRING) ) || \ - ( (ZLSS_VOLUME_TO_POOL(VOLUME_TO_ZLSS_VOLUME(_volume)))-> \ - maintenanceStatus & \ - (VOLMAINTSTATUS_CHECKING|VOLMAINTSTATUS_REPAIRING) ) ) + ( (_volume->maintenanceStatus & \ + (VOLMAINTSTATUS_CHECKING|VOLMAINTSTATUS_REPAIRING) ) || \ + ( (ZLSS_VOLUME_TO_POOL(VOLUME_TO_ZLSS_VOLUME(_volume)))-> \ + maintenanceStatus & \ + (VOLMAINTSTATUS_CHECKING|VOLMAINTSTATUS_REPAIRING) ) ) /*------------------------------------------------------------------------- @@ -2124,62 +2123,62 @@ STATUS ZFSVOL_VOL_FlushSystemBeasts( *-------------------------------------------------------------------------*/ #define READBLK_IO_MSG(_io, _beast, _volBlk, _mode) \ { \ - SETUP_IO_MSG(_io, _beast, _mode); \ - (_io).fileBlk = -(_volBlk); \ - (_io).volBlk = (_volBlk); \ - (_io).allocNumBlks = 1; \ + SETUP_IO_MSG(_io, _beast, _mode); \ + (_io).fileBlk = -(_volBlk); \ + (_io).volBlk = (_volBlk); \ + (_io).allocNumBlks = 1; \ } #define ALLOCBLK_IO_MSG(_io, _beast, _mode) \ { \ - SETUP_IO_MSG(_io, _beast, _mode); \ - (_io).fileBlk = INVALID_BLK; \ - (_io).volBlk = 0; \ - (_io).allocNumBlks = 1; \ + SETUP_IO_MSG(_io, _beast, _mode); \ + (_io).fileBlk = INVALID_BLK; \ + (_io).volBlk = 0; \ + (_io).allocNumBlks = 1; \ } #define XALLOCBLK_IO_MSG(_io, _beast, _xaction, _mode) \ { \ - XSETUP_IO_MSG(_io, _beast, _xaction, _mode); \ - (_io).fileBlk = INVALID_BLK; \ - (_io).volBlk = 0; \ - (_io).allocNumBlks = 1; \ + XSETUP_IO_MSG(_io, _beast, _xaction, _mode); \ + (_io).fileBlk = INVALID_BLK; \ + (_io).volBlk = 0; \ + (_io).allocNumBlks = 1; \ } #define ALLOC_SEED_IO_MSG(_io, _beast, _seed, _mode) \ { \ - SETUP_IO_MSG(_io, _beast, _mode); \ - (_io).fileBlk = INVALID_BLK; \ - (_io).volBlk = (_seed); \ - (_io).allocNumBlks = 1; \ + SETUP_IO_MSG(_io, _beast, _mode); \ + (_io).fileBlk = INVALID_BLK; \ + (_io).volBlk = (_seed); \ + (_io).allocNumBlks = 1; \ } #define XALLOC_SEED_IO_MSG(_io, _beast, _xaction, _seed, _mode) \ { \ - XSETUP_IO_MSG(_io, _beast, _xaction, _mode); \ - (_io).fileBlk = INVALID_BLK; \ - (_io).volBlk = (_seed); \ - (_io).allocNumBlks = 1; \ + XSETUP_IO_MSG(_io, _beast, _xaction, _mode); \ + (_io).fileBlk = INVALID_BLK; \ + (_io).volBlk = (_seed); \ + (_io).allocNumBlks = 1; \ } #define DELETEBLK_IO_MSG(_io, _beast, _volBlk) \ { \ - SETUP_IO_MSG(_io, _beast, 0); \ - (_io).fileBlk = 0; \ - (_io).volBlk = (_volBlk); \ - (_io).allocNumBlks = 1; \ + SETUP_IO_MSG(_io, _beast, 0); \ + (_io).fileBlk = 0; \ + (_io).volBlk = (_volBlk); \ + (_io).allocNumBlks = 1; \ } #define XDELETEBLK_IO_MSG(_io, _beast, _xaction, _volBlk) \ - \ - XSETUP_IO_MSG(_io, _beast, _xaction, 0); \ - (_io).fileBlk = 0; \ - (_io).volBlk = (_volBlk); \ - (_io).allocNumBlks = 1; \ + \ + XSETUP_IO_MSG(_io, _beast, _xaction, 0); \ + (_io).fileBlk = 0; \ + (_io).volBlk = (_volBlk); \ + (_io).allocNumBlks = 1; \ } #if NSS_DEBUG IS_ENABLED -#define SET_DEBUG_ID(_io, _id) (_io).debugID = (_id) +#define SET_DEBUG_ID(_io, _id) (_io).debugID = (_id) #else #define SET_DEBUG_ID(_io, _id) ((void) 0) #endif @@ -2210,162 +2209,162 @@ extern BOOL ZLSS_UpgradeMediaFormat; typedef struct PersistentZlssPool_s { - LONG PZP_magic; /* pool info magic number */ - LONG PZP_version; - LONG PZP_checksum; - /* Calculated before each NON-LOGGED write of the block. - * Checksum is for all NON LOGGED data. Checksum is - * valid if the NON-LOGGED contents (including this field) - * add up to zero. Use ZFSVOL_CalculateChecksum() to - * perform checksumming. We do not include the LOGGED - * data in the checksum for the following reasons. - * 1) We update the block too often for LOGGING - * 2) All the LOGGED data can be reproduced by Rebuild. - * 3) This LSS stores the LOGGED data in a different - * volume block. - */ - LONG PZP_reserved1; /* For alignment of next item */ - GUID_t PZP_internalID; /* GUID of pool - needs to be at ofsset 16 */ - SQUAD PZP_loggedPoolDataBlk; /* Block number where the persistent - * LOGGED pool information is stored. - */ - SQUAD PZP_poolDataBlk; /* Block number where the persistent - * NON-LOGGED pool information is stored. - */ - QUAD PZP_initUTCTime; /* UTC time of when pool block initialized - * last. Stored as a QUAD so when UTC - * time changes we might still hold a - * time_t. time_t is not used as not - * a fixed size. - */ - QUAD PZP_rebuildUTCTime; /* UTC time of when pool last rebuilt. Set - * to zero when pool is created. - */ - VolumeID_t PZP_volumeID; /* Volume ID of pool */ - LONG PZP_reserved[64-16-4]; - /* Space for modifications that do not require media format change. - * The size of the ZFSVOL persistent area is 256 bytes. - */ + LONG PZP_magic; /* pool info magic number */ + LONG PZP_version; + LONG PZP_checksum; + /* Calculated before each NON-LOGGED write of the block. + * Checksum is for all NON LOGGED data. Checksum is + * valid if the NON-LOGGED contents (including this field) + * add up to zero. Use ZFSVOL_CalculateChecksum() to + * perform checksumming. We do not include the LOGGED + * data in the checksum for the following reasons. + * 1) We update the block too often for LOGGING + * 2) All the LOGGED data can be reproduced by Rebuild. + * 3) This LSS stores the LOGGED data in a different + * volume block. + */ + LONG PZP_reserved1; /* For alignment of next item */ + GUID_t PZP_internalID; /* GUID of pool - needs to be at ofsset 16 */ + SQUAD PZP_loggedPoolDataBlk; /* Block number where the persistent + * LOGGED pool information is stored. + */ + SQUAD PZP_poolDataBlk; /* Block number where the persistent + * NON-LOGGED pool information is stored. + */ + QUAD PZP_initUTCTime; /* UTC time of when pool block initialized + * last. Stored as a QUAD so when UTC + * time changes we might still hold a + * time_t. time_t is not used as not + * a fixed size. + */ + QUAD PZP_rebuildUTCTime; /* UTC time of when pool last rebuilt. Set + * to zero when pool is created. + */ + VolumeID_t PZP_volumeID; /* Volume ID of pool */ + LONG PZP_reserved[64-16-4]; + /* Space for modifications that do not require media format change. + * The size of the ZFSVOL persistent area is 256 bytes. + */ } NSS_MEDIA_STRUCTURE(PersistentZlssPool_s,PZP_reserved[64-16-4]) PersistentZlssPool_s; typedef struct LoggedPersistentZlssPool_s { - LONG LPZP_magic; /* poolinfo magic number */ - LONG LPZP_version; - Lsn_t LPZP_lsn; /* log sequence number -- needs to be - * at the eighth byte offset. This is not - * part of the checksum because it is - * updated when LOGGED data is changed! - */ - VolumeID_t LPZP_internalID; /* Internal GUID of pool - needs to be at ofsset 16 */ - LONG LPZP_reserved[64-8]; - /* Space for modifications that do not require media format change. - * The size of the logged ZLSS Pool logged area is 256 bytes. - */ + LONG LPZP_magic; /* poolinfo magic number */ + LONG LPZP_version; + Lsn_t LPZP_lsn; /* log sequence number -- needs to be + * at the eighth byte offset. This is not + * part of the checksum because it is + * updated when LOGGED data is changed! + */ + VolumeID_t LPZP_internalID; /* Internal GUID of pool - needs to be at ofsset 16 */ + LONG LPZP_reserved[64-8]; + /* Space for modifications that do not require media format change. + * The size of the logged ZLSS Pool logged area is 256 bytes. + */ } NSS_MEDIA_STRUCTURE(LoggedPersistentZlssPool_s,LPZP_reserved[64-8]) LoggedPersistentZlssPool_s; typedef struct ZlssLoggedPoolBlock_s { - LoggedPersistentZlssPool_s ZLPB_zlssPool; - LoggedPersistentPool_s ZLPB_pool; + LoggedPersistentZlssPool_s ZLPB_zlssPool; + LoggedPersistentPool_s ZLPB_pool; } NSS_MEDIA_STRUCTURE(ZlssLoggedPoolBlock_s,ZLPB_pool) ZlssLoggedPoolBlock_s; typedef struct ZlssPoolBlock_s { - PersistentZlssPool_s ZPB_zlssPool; - PersistentPool_s ZPB_pool; + PersistentZlssPool_s ZPB_zlssPool; + PersistentPool_s ZPB_pool; } NSS_MEDIA_STRUCTURE(ZlssPoolBlock_s,ZPB_pool) ZlssPoolBlock_s; - /** - * ZLSS Pool is the logical pool structure create to enable - * easier addition of Logical Volumes. I decided to use the - * ZfsPool_s as the ZLSS Pool's physical volume. This way - * most of the current code could be left as is. - * - * Overview - - * ZlssPool_s - The pool that NSS knowns about. - * ZfsPool_s - The Physical Volume used to implement - * many of the ZlssPool features. The - * ZfsPool_s is not seen by the common - * layer. - * ZfsVolume_s - The volume that NSS knows about. - * - */ + /** + * ZLSS Pool is the logical pool structure create to enable + * easier addition of Logical Volumes. I decided to use the + * ZfsPool_s as the ZLSS Pool's physical volume. This way + * most of the current code could be left as is. + * + * Overview - + * ZlssPool_s - The pool that NSS knowns about. + * ZfsPool_s - The Physical Volume used to implement + * many of the ZlssPool features. The + * ZfsPool_s is not seen by the common + * layer. + * ZfsVolume_s - The volume that NSS knows about. + * + */ typedef struct ZlssPool_s { - Pool_s ZP_Pool; /* ZLSS pool 'is a' pool */ - PersistentZlssPool_s ZP_p; - LoggedPersistentZlssPool_s ZP_logged; - ZfsPool_s *ZP_ZfsPool; /* Has a ZfsPool Beast */ - QUAD ZP_bookedInUseBlocks; - /* */ - FsmLite_s ZP_MakeFreeSpaceFsm; - SQUAD ZP_BlocksToSalvage; - SNINT ZP_UnusableFreeBlkCnt; /* Number of blks that are - * currently on the free - * data blks list */ - GUID_t ZP_InternalID; - LONG ZP_Version; /* Version of pool in Major * 0x100L + - * minor format. Used to quickly - * determine where LV AIPU is at. - * Valid only after the pool has - * been persistently loaded. I.E. - * after ZFSPOOL_LoadPersistentPool() - * has been called. Because LV AIPU - * re-loads the pool after each minor - * upgrade you will not find ZP_Version - * being updated as the media major - * and minor version fields are. - */ + Pool_s ZP_Pool; /* ZLSS pool 'is a' pool */ + PersistentZlssPool_s ZP_p; + LoggedPersistentZlssPool_s ZP_logged; + ZfsPool_s *ZP_ZfsPool; /* Has a ZfsPool Beast */ + QUAD ZP_bookedInUseBlocks; + /* */ + FsmLite_s ZP_MakeFreeSpaceFsm; + SQUAD ZP_BlocksToSalvage; + SNINT ZP_UnusableFreeBlkCnt; /* Number of blks that are + * currently on the free + * data blks list */ + GUID_t ZP_InternalID; + LONG ZP_Version; /* Version of pool in Major * 0x100L + + * minor format. Used to quickly + * determine where LV AIPU is at. + * Valid only after the pool has + * been persistently loaded. I.E. + * after ZFSPOOL_LoadPersistentPool() + * has been called. Because LV AIPU + * re-loads the pool after each minor + * upgrade you will not find ZP_Version + * being updated as the media major + * and minor version fields are. + */ #define ZLSS_MEDIA_VERSION_4007 0x2807 #define ZLSS_MEDIA_VERSION_4008 0x2808 - PoolWriteStatistics_s ZP_PWS; - PoolReadStatistics_s ZP_PRS; - Time_t ZP_StatisticsResetCommandUTCTime; - Time_t ZP_StatisticsResetUTCTime; - BOOL ZP_PoolTrackIO; /* TRUE when we are tracking I/O - * to the pool. Normally, set - * when pool is ACTIVE. - */ - BOOL ZP_Loading; /* The pool is in the process of - * being loaded. It is used - * to prevent NON upgraded pools - * from being used (ACTIVATED). - */ - BOOL ZP_Snapshot; /* The pool is a snapshot of another - * pool. General this means another - * pool on the same server. This - * flag is retrieved from the super - * block at POOL LOAD time only. - * Snapshot pools do magic to their - * LVs at load time to ensure their - * LVs have unique names and volume - * IDs. This magic is done ONCE - * on the first LOAD after the - * superblock is updated. The super - * block should be updated when the - * pool is not loaded. - */ - GUID_t ZP_SnapshotID; /* If ZP_Snapshot then the unique - * ID of the snapshot. Used to - * tell if LVs have been snapshoted - * and if the information about - * the LVs snapshot is valid. See - * PersistentZlssVolumeLocator_s - * for more information. - */ - struct MSAP_PoolStateInfo_s *ZP_MSAPInfo; - /* Used by new MSAP code to store MSAP specific - * information. See the specification - * "ZLSS's Multiple Activation Inhibitor" and - * zlssMSAP.c for details. - */ - Blknum_t ZP_MSAPBlock; /* Block number that MSAP is stored. This - * is block 11 (0 rel) of superblock 1 (0 rel). - */ + PoolWriteStatistics_s ZP_PWS; + PoolReadStatistics_s ZP_PRS; + Time_t ZP_StatisticsResetCommandUTCTime; + Time_t ZP_StatisticsResetUTCTime; + BOOL ZP_PoolTrackIO; /* TRUE when we are tracking I/O + * to the pool. Normally, set + * when pool is ACTIVE. + */ + BOOL ZP_Loading; /* The pool is in the process of + * being loaded. It is used + * to prevent NON upgraded pools + * from being used (ACTIVATED). + */ + BOOL ZP_Snapshot; /* The pool is a snapshot of another + * pool. General this means another + * pool on the same server. This + * flag is retrieved from the super + * block at POOL LOAD time only. + * Snapshot pools do magic to their + * LVs at load time to ensure their + * LVs have unique names and volume + * IDs. This magic is done ONCE + * on the first LOAD after the + * superblock is updated. The super + * block should be updated when the + * pool is not loaded. + */ + GUID_t ZP_SnapshotID; /* If ZP_Snapshot then the unique + * ID of the snapshot. Used to + * tell if LVs have been snapshoted + * and if the information about + * the LVs snapshot is valid. See + * PersistentZlssVolumeLocator_s + * for more information. + */ + struct MSAP_PoolStateInfo_s *ZP_MSAPInfo; + /* Used by new MSAP code to store MSAP specific + * information. See the specification + * "ZLSS's Multiple Activation Inhibitor" and + * zlssMSAP.c for details. + */ + Blknum_t ZP_MSAPBlock; /* Block number that MSAP is stored. This + * is block 11 (0 rel) of superblock 1 (0 rel). + */ } ZlssPool_s; @@ -2376,43 +2375,43 @@ typedef struct ZlssPool_s #define ZLSSPOOLavfile ZP_Pool.avfile #define ZLSSPOOLpool ZP_Pool - /* ZLSS Pool items */ -#define ZLSSPOOLzfsPool ZP_ZfsPool + /* ZLSS Pool items */ +#define ZLSSPOOLzfsPool ZP_ZfsPool - /* Derived from items */ -#define ZLSSPOOLmVolumeID ZLSSPOOLpool.POOLvolumeID + /* Derived from items */ +#define ZLSSPOOLmVolumeID ZLSSPOOLpool.POOLvolumeID #define ZLSSPOOLmInternalID ZP_InternalID -#define ZLSSPOOLbeastLatch ZLSSPOOLpool.POOLbeastLatch -#define ZLSSPOOLstateAttributes ZLSSPOOLpool.POOLstateAttributes +#define ZLSSPOOLbeastLatch ZLSSPOOLpool.POOLbeastLatch +#define ZLSSPOOLstateAttributes ZLSSPOOLpool.POOLstateAttributes #define ZLSSPOOLbeastClass ZLSSPOOLroot.beastClass #define ZLSSPOOLmycache ZLSSPOOLroot.mycache -#define ZLSSPOOLblockSize ZLSSPOOLpool.POOLblockSize -#define ZLSSPOOLblockShift ZLSSPOOLpool.POOLblockShift -#define ZLSSPOOLrebuildCount ZLSSPOOLpool.POOLrebuildCount -#define ZLSSPOOLminKeepSeconds ZLSSPOOLpool.POOLminKeepSeconds -#define ZLSSPOOLmaxKeepSeconds ZLSSPOOLpool.POOLmaxKeepSeconds -#define ZLSSPOOLlowWaterMark ZLSSPOOLpool.POOLlowWaterMark -#define ZLSSPOOLhighWaterMark ZLSSPOOLpool.POOLhighWaterMark -#define ZLSSPOOLreserved2 ZLSSPOOLpool.POOLreserved2 -#define ZLSSPOOLstate ZLSSPOOLpool.POOLstate -#define ZLSSPOOLstateAttributes ZLSSPOOLpool.POOLstateAttributes -#define ZLSSPOOLndsObjectID ZLSSPOOLpool.POOLndsObjectID +#define ZLSSPOOLblockSize ZLSSPOOLpool.POOLblockSize +#define ZLSSPOOLblockShift ZLSSPOOLpool.POOLblockShift +#define ZLSSPOOLrebuildCount ZLSSPOOLpool.POOLrebuildCount +#define ZLSSPOOLminKeepSeconds ZLSSPOOLpool.POOLminKeepSeconds +#define ZLSSPOOLmaxKeepSeconds ZLSSPOOLpool.POOLmaxKeepSeconds +#define ZLSSPOOLlowWaterMark ZLSSPOOLpool.POOLlowWaterMark +#define ZLSSPOOLhighWaterMark ZLSSPOOLpool.POOLhighWaterMark +#define ZLSSPOOLreserved2 ZLSSPOOLpool.POOLreserved2 +#define ZLSSPOOLstate ZLSSPOOLpool.POOLstate +#define ZLSSPOOLstateAttributes ZLSSPOOLpool.POOLstateAttributes +#define ZLSSPOOLndsObjectID ZLSSPOOLpool.POOLndsObjectID #define ZLSSPOOLenabledFeatures ZLSSPOOLpool.POOLenabledFeatures #define ZLSSPOOLmediaFormatMajor ZLSSPOOLpool.POOLmediaFormatMajor #define ZLSSPOOLmediaFormatMinor ZLSSPOOLpool.POOLmediaFormatMinor #define ZLSSPOOLfreeBlockAdjustment ZLSSPOOLpool.POOLfreeBlockAdjustment -#define ZLSSPOOLblockSize ZLSSPOOLpool.POOLblockSize -#define ZLSSPOOLnumFiles ZLSSPOOLpool.POOLnumFiles -#define ZLSSPOOLnumObjects ZLSSPOOLpool.POOLnumObjects -#define ZLSSPOOLtotalBlocks ZLSSPOOLpool.POOLtotalBlocks -#define ZLSSPOOLinUseBlocks ZLSSPOOLpool.POOLinUseBlocks -#define ZLSSPOOLpurgeableBlocks ZLSSPOOLpool.POOLpurgeableBlocks -#define ZLSSPOOLnonPurgeableBlocks ZLSSPOOLpool.POOLnonPurgeableBlocks -#define ZLSSPOOLnumDeletedFiles ZLSSPOOLpool.POOLnumDeletedFiles -#define ZLSSPOOLnumLogicalVolumes ZLSSPOOLpool.POOLnumLogicalVolumes +#define ZLSSPOOLblockSize ZLSSPOOLpool.POOLblockSize +#define ZLSSPOOLnumFiles ZLSSPOOLpool.POOLnumFiles +#define ZLSSPOOLnumObjects ZLSSPOOLpool.POOLnumObjects +#define ZLSSPOOLtotalBlocks ZLSSPOOLpool.POOLtotalBlocks +#define ZLSSPOOLinUseBlocks ZLSSPOOLpool.POOLinUseBlocks +#define ZLSSPOOLpurgeableBlocks ZLSSPOOLpool.POOLpurgeableBlocks +#define ZLSSPOOLnonPurgeableBlocks ZLSSPOOLpool.POOLnonPurgeableBlocks +#define ZLSSPOOLnumDeletedFiles ZLSSPOOLpool.POOLnumDeletedFiles +#define ZLSSPOOLnumLogicalVolumes ZLSSPOOLpool.POOLnumLogicalVolumes #define ZLSSPOOLpMagic ZP_p.PZP_magic @@ -2437,39 +2436,39 @@ typedef struct ZlssPool_s #define ZLSSPOOLstatusFlag ZLSSPOOLpool.POOLstatusFlag typedef struct BTShrinkLogRecord_s { - Blknum_t block; /* Previous 'child' block number */ - WORD slot; /* Index of previous 'child' block number */ + Blknum_t block; /* Previous 'child' block number */ + WORD slot; /* Index of previous 'child' block number */ } NSS_MEDIA_STRUCTURE(BTShrinkLogRecord_s,slot) BTShrinkLogRecord_s; ZfsVolume_s *ZLSS_VolumeIDLookup( - GeneralMsg_s *genMsg, - GUID_t *internalID, - BOOL onlineOnly, - ZfsPool_s *poolVolume ); + GeneralMsg_s *genMsg, + GUID_t *internalID, + BOOL onlineOnly, + ZfsPool_s *poolVolume ); ZfsVolume_s *ZLSS_VolumeIDLookupRecovery( - GeneralMsg_s *genMsg, - GUID_t *internalID, - ZfsPool_s *poolVolume ); + GeneralMsg_s *genMsg, + GUID_t *internalID, + ZfsPool_s *poolVolume ); STATUS ZLSS_VolumeIDLookupID( - GeneralMsg_s *genMsg, - GUID_t *internalID, - ZfsPool_s *poolVolume, - VolumeID_t *retVolumeID); + GeneralMsg_s *genMsg, + GUID_t *internalID, + ZfsPool_s *poolVolume, + VolumeID_t *retVolumeID); void ZLSSPOOL_WritePersistentPoolData( - ZlssPool_s *zlssPool); + ZlssPool_s *zlssPool); STATUS ZLSSPOOL_ReadPersistentPoolData( - GeneralMsg_s *genMsg, - ZlssPool_s *zlssPool); + GeneralMsg_s *genMsg, + ZlssPool_s *zlssPool); STATUS ZLSSPOOL_RecoveryPoolInfo( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - struct ZfsXasRecovery_s *logBuffer, - NINT action); + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + struct ZfsXasRecovery_s *logBuffer, + NINT action); STATUS ZFSREPAIR_VOL_CheckRepair( GeneralMsg_s *genMsg, @@ -2486,74 +2485,74 @@ STATUS ZLSSPOOL_VOL_VolumeMaintenance( void *userInfo); STATUS doZLSSPoolIOErrors( - struct PCLSwitchDef_s *switchDef, - NINT parseOptions, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT parseOptions, + void *userParm); STATUS doZLSSPoolIOState( - struct PCLSwitchDef_s *switchDef, - NINT parseOptions, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT parseOptions, + void *userParm); STATUS doZLSSPoolIOStatistics( - struct PCLSwitchDef_s *switchDef, - NINT parseOptions, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT parseOptions, + void *userParm); STATUS doZLSSPoolIOReset( - struct PCLSwitchDef_s *switchDef, - NINT parseOptions, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT parseOptions, + void *userParm); STATUS doZLSSVolumeUpgrade( - struct PCLSwitchDef_s *switchDef, - NINT parseOptions, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT parseOptions, + void *userParm); STATUS doZLSSPoolSnapshot( - struct PCLSwitchDef_s *switchDef, - NINT parseOptions, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT parseOptions, + void *userParm); STATUS doDisplayESMCachePerf( - struct PCLSwitchDef_s *switchDef, - NINT parseOptions, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT parseOptions, + void *userParm); extern BOOL TrackESMPerfStats; extern BOOL HL_ClusterApprovesUpgrade(); #ifdef NW5X_UPGRADE -STATUS ZLSSCON_Upgrade( - GeneralMsg_s *genMsg, - ZfsPool_s *zfsPool ); +STATUS ZLSSCON_Upgrade( + GeneralMsg_s *genMsg, + ZfsPool_s *zfsPool ); #endif ZfsPool_s *ZFSPOOL_LoadPool( - struct GeneralMsg_s *genMsg, - struct StorPool_s *storagepool, - BOOL verbose, - NINT loadFlag, - BOOL snapshot, - unicode_t *snapshotInfo, - BOOL newGuids ); + struct GeneralMsg_s *genMsg, + struct StorPool_s *storagepool, + BOOL verbose, + NINT loadFlag, + BOOL snapshot, + unicode_t *snapshotInfo, + BOOL newGuids ); - /* Pool Load flag is one of the following */ + /* Pool Load flag is one of the following */ #define ZLSS_PLF_NORMAL 0x0000 /* Normal value. */ #define ZLSS_PLF_NO_UPGRADE 0x0001 /* Use to force us NOT to try upgrade. - * Works on Pools with a version less than - * 40.06. Causes load pool to leave the - * pool in deactive state with no upgrade - * attempted. - */ + * Works on Pools with a version less than + * 40.06. Causes load pool to leave the + * pool in deactive state with no upgrade + * attempted. + */ #define ZLSS_PLF_UPGRADE 0x0002 /* Used to force us to upgrade a pool to - * version 40.06. We will force an - * activation if the policies did - * not set the pool to ACTIVE. Again, - * this only applies to pools if they - * are not already 40.06. - */ + * version 40.06. We will force an + * activation if the policies did + * not set the pool to ACTIVE. Again, + * this only applies to pools if they + * are not already 40.06. + */ STATUS ZLSS_VFCDelete( GeneralMsg_s *genMsg ); STATUS ZLSS_VFCCreate( GeneralMsg_s *genMsg ); @@ -2561,38 +2560,38 @@ void ZLSS_removePoolMgmtFile( unicode_t *poolName ); STATUS ZLSS_addPoolMgmtFile(GeneralMsg_s *genMsg, unicode_t *poolName); STATUS MSAP_MSAPActivate( - ZlssPool_s *zlssPool, - GeneralMsg_s *genMsg ); + ZlssPool_s *zlssPool, + GeneralMsg_s *genMsg ); STATUS MSAP_MSAPBlockInitializePhysical( - ZlssPool_s *zlssPool, - GeneralMsg_s *genMsg ); + ZlssPool_s *zlssPool, + GeneralMsg_s *genMsg ); void MSAP_MSAPDeactivate( - ZlssPool_s *zlssPool ); + ZlssPool_s *zlssPool ); STATUS MSAP_MSAPRebuild( - ZlssPool_s *zlssPool, - GeneralMsg_s *genMsg ); + ZlssPool_s *zlssPool, + GeneralMsg_s *genMsg ); #define ZLSS_SIGNATURE 0x7a4c5373 /* "zLSs" This should be in the 2nd long of - * all new block types so that SCAN will - * automatically detect new block types. - */ + * all new block types so that SCAN will + * automatically detect new block types. + */ STATUS RAV_Startup(); void RAV_Shutdown(); void MSAP_MSAPShutdown( ); void MSAP_MSAPStartup( ); STATUS MSAP_AIPU4007To4008( - ZlssPool_s *zlssPool, - GeneralMsg_s *genMsg ); + ZlssPool_s *zlssPool, + GeneralMsg_s *genMsg ); STATUS ZFSVOL_VDBNDSObjectClear( - GeneralMsg_s *genMsg, - struct StorPool_s *storagepool, - Blknum_t blkVDB ); + GeneralMsg_s *genMsg, + struct StorPool_s *storagepool, + Blknum_t blkVDB ); STATUS ZFSVOL_PDBNDSObjectClear( - GeneralMsg_s *genMsg, - struct StorPool_s *storagepool, - Blknum_t blkPDB ); + GeneralMsg_s *genMsg, + struct StorPool_s *storagepool, + Blknum_t blkPDB ); BOOL ZFSPOOL_PoolVerifySupported( struct MediaSuperBlockHeader_s *superHeader ); BOOL ZFSPOOL_PoolLoadSupported( struct MediaSuperBlockHeader_s *superHeader ); @@ -2602,8 +2601,8 @@ BOOL ZFSPOOL_IsInstallTime( ); //#endif STATIC STATUS ZFSVOL_LoadSystemBeasts( - GeneralMsg_s *genMsg, - ZfsVolume_s *vol); + GeneralMsg_s *genMsg, + ZfsVolume_s *vol); void ZSTORE_NEBEventRegister(); @@ -2611,15 +2610,15 @@ void ZSTORE_NEBEventUnregister(); STATUS RAV_DisplayXML( GeneralMsg_s *genMsg, NINT type, LONG flags, struct ZlssPool_s *zlssPool, - NINT bufferLength, BYTE **bufferAddress, NINT *retLen ); + NINT bufferLength, BYTE **bufferAddress, NINT *retLen ); STATUS RAV_VerifyStatisticsDisplayBin( GeneralMsg_s *genMsg, NINT type, struct ZlssPool_s *zlssPool, - NINT *bufferLength, BYTE **bufferAddress, NINT *retLen ); + NINT *bufferLength, BYTE **bufferAddress, NINT *retLen ); #define INIT_BIO_REQ(_bioReq, _callback) \ { \ - (_bioReq)->br_status = zOK; \ - (_bioReq)->br_callback = _callback; \ - NULLIFY(&(_bioReq)->br_link); \ + (_bioReq)->br_status = zOK; \ + (_bioReq)->br_callback = _callback; \ + NULLIFY(&(_bioReq)->br_link); \ } STATUS zlssBioIOData( @@ -2645,7 +2644,7 @@ void zlssBioIOBufferAsync ( int rw, struct block_device *blockDevice, Buffer_s *buf, - BioReq_s *bioReq); + BioReq_s *bioReq); /* This is called without the NSSMPK spinlock */ STATUS zlssBioIOSync( @@ -2730,42 +2729,43 @@ static inline NINT BTREE_CheckAndAddRABlock( } static inline void BTREE_ReadAheadMetadata( - RootBeast_s *root, - void *node, - NINT indexInNode, - NINT (*getBlockList)(void *node, - SNINT indexInNode, - Blknum_t *blockList), - Blknum_t readBlock) + RootBeast_s *root, + void *node, + NINT indexInNode, + NINT (*getBlockList)(void *node, + SNINT indexInNode, + Blknum_t *blockList), + Blknum_t readBlock) { - struct inode *inode = NULL; - NINT numBlocks; - typedef struct Stack_s { - Blknum_t blockList[FT_AREA_SIZE_MAX]; + struct inode *inode = NULL; + NINT numBlocks; + typedef struct Stack_s { + Blknum_t blockList[FT_AREA_SIZE_MAX]; } Stack_s; - if (root->ROOTvolume->v_pool) - { - inode = root->ROOTvolume->v_pool->P_Inode; - } - /* If the readBlock is in cache, we will not do a readAhead, - * because no need to do a disk I/O if we are not reading the - * metadata block. We only want to do read aheads if we can - * do "free" reads. */ - if ((!cacheFind(&root->mycache, -readBlock)) && - (!HMC_MarkNewestIfCached(inode, readBlock))) - { - STACK_ALLOC(); - numBlocks = getBlockList(node, indexInNode, aStack->blockList); + if (root->ROOTvolume->v_pool) + { + inode = root->ROOTvolume->v_pool->P_Inode; + } + /* If the readBlock is in cache, we will not do a readAhead, + * because no need to do a disk I/O if we are not reading the + * metadata block. We only want to do read aheads if we can + * do "free" reads. */ + if ((!cacheFind(&root->mycache, -readBlock)) && + (!HMC_MarkNewestIfCached(inode, readBlock))) + { + STACK_ALLOC(); + numBlocks = getBlockList(node, indexInNode, aStack->blockList); - if (numBlocks > 1) - { - ZLSS_AsyncMetadataReadAhead(&root->mycache, aStack->blockList, - numBlocks); - } - STACK_FREE(); - } - return; + if (numBlocks > 1) + { + ZLSS_AsyncMetadataReadAhead(&root->mycache, aStack->blockList, + numBlocks); + } + STACK_FREE(); + } + return; } #endif /* _ZFS_H_ */ + diff --git a/src/nwnss/zlss/zfsAsyncio.h b/src/nwnss/zlss/zfsAsyncio.h index 2ac334c..baea25d 100644 --- a/src/nwnss/zlss/zfsAsyncio.h +++ b/src/nwnss/zlss/zfsAsyncio.h @@ -44,7 +44,7 @@ #define _ZFSASYNCIO_H_ #ifndef _XCACHE_H_ -#include +#include #endif #ifndef _ZFS_H_ @@ -58,13 +58,13 @@ typedef struct FmapOps_s { Blknum_t saveFileBlk; - Extent_s extent; /* location to send/receive extents */ + Extent_s extent; /* location to send/receive extents */ } FmapOps_s; typedef struct ZioFmap_s { - Asyncio_s io; - FmapOps_s fmap; + Asyncio_s io; + FmapOps_s fmap; } ZioFmap_s; diff --git a/src/nwnss/zlss/zfsFileMap.c b/src/nwnss/zlss/zfsFileMap.c index aa0b800..a813277 100644 --- a/src/nwnss/zlss/zfsFileMap.c +++ b/src/nwnss/zlss/zfsFileMap.c @@ -34,21 +34,14 @@ | This module is used to: | This defines all of the primitive BEASTS inside of PSS +-------------------------------------------------------------------------*/ -#if defined(NSS_USERSPACE) -#include -struct block_device; -#else #include #include -#endif #include #include #include #include -#include -#include -#include +#include #include "msgIO.h" #include "zfs.h" @@ -69,35 +62,6 @@ struct block_device; #include "userTree.h" #include "dirQuotas.h" -#if defined(NSS_USERSPACE) -#ifndef GFP_USER -#define GFP_USER 0 -#endif -#ifndef READ -#define READ 0 -#endif -#ifndef WRITE -#define WRITE 1 -#endif -#undef ClearStatus -#define ClearStatus(_msg) \ - do { (_msg)->sys.status = zOK; (_msg)->sys.where = (QUAD)(uintptr_t)WHERE; } while (0) -#undef SetStatusFromErrno -#define SetStatusFromErrno(_msg, _genMsg) \ - do { (_msg)->sys.status = GetErrno((_genMsg)); \ - (_msg)->sys.where = (QUAD)(uintptr_t)((_genMsg)->errStatusSetter); } while (0) -#undef FSM_RUN -#define FSM_RUN(_f) \ -{ \ - Fsm_s *Fsm = (_f); \ - void (*Func)(Fsm_s *); \ - --(Fsm->sp); \ - zASSERT(*(Fsm->sp) != FSM_STACK_BOUNDARY); \ - Func = (void (*)(Fsm_s *))(*(Fsm->sp)); \ - Func(Fsm); \ -} -#endif - /************************************************************************** * read a block that belongs to the btree **************************************************************************/ @@ -113,7 +77,7 @@ void readVolBlkBuffer(Asyncio_s *aio) DOWN_LATCH( &aio->buffer->agent.latch); if (aio->status != zOK) { - aio->buffer->agent.status = aio->status; + aio->buffer->agent.status = aio->status; CACHE_RELEASE(aio->buffer); aio->buffer = NULL; } @@ -136,12 +100,12 @@ void asyncReadVolBlk(Asyncio_s *aio, voidfunc_t action) beast = STRUCT(aio->mycache, RootBeast_s, ROOTmycache); if ((aio->fileBlk < 0) || (aio->volBlk == 0) || (beast->ROOTzid < zFIRST_ALLOCATABLE_ZID)) { - asyncCacheAllocBuffer(aio, (voidfunc_t)ZFSMAL_asyncReadBlk, + asyncCacheAllocBuffer(aio, ZFSMAL_asyncReadBlk, ZFS_BlockSignalHandler); } else { - asyncCacheAllocBufferForUserData(aio, (voidfunc_t)ZFSMAL_asyncReadBlk, + asyncCacheAllocBufferForUserData(aio, ZFSMAL_asyncReadBlk, ZFS_BlockSignalHandler); } } @@ -149,11 +113,11 @@ void asyncReadVolBlk(Asyncio_s *aio, voidfunc_t action) /**************************************************************************** - * Search the Direct File Map + * Search the Direct File Map *****************************************************************************/ Blknum_t searchDirectMap( - Fmap_s *fmap, - Blknum_t fileBlk, + Fmap_s *fmap, + Blknum_t fileBlk, Blknum_t *seed, Blknum_t *length, NINT *index) @@ -170,24 +134,24 @@ Blknum_t searchDirectMap( { *index = i; *length = fmap->dirExt[i].count - fileBlk; - return (fmap->dirExt[i].poolBlk + + return (fmap->dirExt[i].poolBlk + (fileBlk - fmap->dirExt[i-1].count)); } } - *seed = fmap->dirExt[i-1].poolBlk + fmap->dirExt[i-1].count - - fmap->dirExt[i-2].count; + *seed = fmap->dirExt[i-1].poolBlk + fmap->dirExt[i-1].count + - fmap->dirExt[i-2].count; return 0; } /**************************************************************************** * searchLeaf and searchBranch: - * Search the leaf and branch nodes of a btree + * Search the leaf and branch nodes of a btree *****************************************************************************/ Blknum_t searchLeaf( - FmapNode_s *node, - Blknum_t fileBlk, - Blknum_t *length, + FmapNode_s *node, + Blknum_t fileBlk, + Blknum_t *length, NINT *index) { Blknum_t numRecs; @@ -201,8 +165,8 @@ Blknum_t searchLeaf( numRecs = node->head.numRecs; /** Added an extra check to make sure we don't get stuck here forever in - ** case there is a corrupted node - **/ + ** case there is a corrupted node + **/ if (fileBlk >= node->extent[numRecs - 1].count) { *index = numRecs; @@ -247,8 +211,8 @@ Blknum_t searchLeaf( if (node->extent[i].poolBlk == 0) return 0; else - return (node->extent[i].poolBlk + - (fileBlk - node->extent[i-1].count)); + return (node->extent[i].poolBlk + + (fileBlk - node->extent[i-1].count)); } @@ -264,8 +228,8 @@ Blknum_t searchBranch(FmapNode_s *node, Blknum_t fileBlk, NINT *index) numRecs = node->head.numRecs; /** Added an extra check to make sure we don't get stuck here forever in - ** case there is a corrupted node - **/ + ** case there is a corrupted node + **/ if (fileBlk >= node->extent[numRecs - 1].count) { zASSERT(0); @@ -302,7 +266,7 @@ Blknum_t searchBranch(FmapNode_s *node, Blknum_t fileBlk, NINT *index) } } #if NSS_DEBUG IS_ENABLED - zASSERT(testCounter < 100); + zASSERT(testCounter < 100); #endif } } @@ -336,12 +300,12 @@ void asyncFindBlkInFmap(ZioFmap_s *zio) if (node->head.state & BT_LEAF) { - zASSERT((node->head.state & BT_ROOT) ? - (node->head.magic == FMAP_BT_ROOT) : - (node->head.magic == FMAP_BT_LEAF)); - if ((node->head.state & BT_ROOT) ? - (node->head.magic != FMAP_BT_ROOT) : - (node->head.magic != FMAP_BT_LEAF)) + zASSERT((node->head.state & BT_ROOT) ? + (node->head.magic == FMAP_BT_ROOT) : + (node->head.magic == FMAP_BT_LEAF)); + if ((node->head.state & BT_ROOT) ? + (node->head.magic != FMAP_BT_ROOT) : + (node->head.magic != FMAP_BT_LEAF)) { zio->io.status = zERR_MEDIA_CORRUPTED; CACHE_RELEASE(zio->io.buffer); @@ -368,18 +332,18 @@ void asyncFindBlkInFmap(ZioFmap_s *zio) } else { - asyncReadVolBlk(&zio->io, (voidfunc_t)ZFS_Return); + asyncReadVolBlk(&zio->io, ZFS_Return); return; } } else { - zASSERT((node->head.state & BT_ROOT) ? - (node->head.magic == FMAP_BT_ROOT) : - (node->head.magic == FMAP_BT_BRANCH)); - if ((node->head.state & BT_ROOT) ? - (node->head.magic != FMAP_BT_ROOT) : - (node->head.magic != FMAP_BT_BRANCH)) + zASSERT((node->head.state & BT_ROOT) ? + (node->head.magic == FMAP_BT_ROOT) : + (node->head.magic == FMAP_BT_BRANCH)); + if ((node->head.state & BT_ROOT) ? + (node->head.magic != FMAP_BT_ROOT) : + (node->head.magic != FMAP_BT_BRANCH)) { zio->io.status = zERR_MEDIA_CORRUPTED; CACHE_RELEASE(zio->io.buffer); @@ -396,7 +360,7 @@ void asyncFindBlkInFmap(ZioFmap_s *zio) CACHE_RELEASE(zio->io.buffer); zio->io.buffer = NULL; zio->io.fileBlk = POOLBLK_TO_INDIRECT(zio->io.volBlk); - asyncReadVolBlk(&zio->io, (voidfunc_t)asyncFindBlkInFmap); + asyncReadVolBlk(&zio->io, asyncFindBlkInFmap); return; } } @@ -422,7 +386,7 @@ void ZFSVOL_VOL_asyncReadFileBlk(Asyncio_s *asyncio) fmap = &stInfo->fmap; zASSERT(zio->io.mode == CACHE_READ); - ASSERT_LATCH(&beast->ROOTbeastLatch); + ASSERT_LATCH(&beast->ROOTbeastLatch); zio->io.buffer = NULL; @@ -442,12 +406,12 @@ void ZFSVOL_VOL_asyncReadFileBlk(Asyncio_s *asyncio) if (zio->io.fileBlk < fmap->dirExt[fmap->numRecs - 1].count) { /** The fileBlk is in the direct portion of the filemap **/ - zio->io.volBlk = searchDirectMap(fmap, zio->io.fileBlk, &seed, - &len, &index); + zio->io.volBlk = searchDirectMap(fmap, zio->io.fileBlk, &seed, + &len, &index); zASSERT(zio->io.volBlk > 0); // zASSERT(zio->io.volBlk < DEBUG_MAX_FILE_BLK); - asyncReadVolBlk(&zio->io, (voidfunc_t)ZFS_Return); + asyncReadVolBlk(&zio->io, ZFS_Return); return; } else @@ -458,7 +422,7 @@ void ZFSVOL_VOL_asyncReadFileBlk(Asyncio_s *asyncio) zio->io.volBlk = fmap->root; zio->io.fileBlk = POOLBLK_TO_INDIRECT(zio->io.volBlk); - asyncReadVolBlk(&zio->io, (voidfunc_t)asyncFindBlkInFmap); + asyncReadVolBlk(&zio->io, asyncFindBlkInFmap); return; } } @@ -486,7 +450,7 @@ STATUS findBlkInFileMap( ASSERT_MPKNSS_LOCK(); if (fmap->dirExt[fmap->numRecs - 1].count > fileBlk) { - *poolBlk = searchDirectMap(fmap, fileBlk, &seed, &len, &index); + *poolBlk = searchDirectMap(fmap, fileBlk, &seed, &len, &index); zASSERT(*poolBlk > 0); } else @@ -520,8 +484,8 @@ STATUS findBlkInFileMap( } node = (FmapNode_s *)buf->pBuf.data; zASSERT((node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_BRANCH)); - if ((node->head.magic != FMAP_BT_LEAF) && + (node->head.magic == FMAP_BT_BRANCH)); + if ((node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_BRANCH)) { SetErrno(genMsg, zERR_MEDIA_CORRUPTED); @@ -541,7 +505,7 @@ STATUS findBlkInFileMap( void syncGrowBtree( ZfsXaction_s *xaction, - Buffer_s *bufChild, + Buffer_s *bufChild, Buffer_s *bufParent, NINT *indexParent, RootBeast_s *beast) @@ -590,17 +554,17 @@ void syncGrowBtree( } ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2) + sizeof(FmapGrow_s) ); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_GROW, xaction, logBuffer, - 2, logBlks, logRecord); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_GROW, xaction, logBuffer, + 2, logBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], bufChild->volBlk, - child->head.lsn, bufChild, xaction, 0); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], bufParent->volBlk, - parent->head.lsn, bufParent, xaction, 1); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], bufChild->volBlk, + child->head.lsn, bufChild, xaction, 0); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], bufParent->volBlk, + parent->head.lsn, bufParent, xaction, 1); ZLOG_ALLOC_BLOCK(logBlks[1]); - memcpy(&logRecord->u.grow.extent[0], &parent->extent[0], - sizeof(logRecord->u.grow.extent)); + memcpy(&logRecord->u.grow.extent[0], &parent->extent[0], + sizeof(logRecord->u.grow.extent)); // Either Child or Parent is ok for next 2 lines as ID, ZID are the same logRecord->u.grow.fg_internalID = child->head.fnh_internalID; logRecord->u.grow.fg_zid = child->head.fnh_zid; @@ -618,9 +582,9 @@ void syncGrowBtree( void syncSplitBtree( ZfsXaction_s *xaction, - Buffer_s *bufChild, - Buffer_s *bufSibling, - Buffer_s *bufParent, + Buffer_s *bufChild, + Buffer_s *bufSibling, + Buffer_s *bufParent, Extent_s *extent) { FmapNode_s *parent; @@ -647,8 +611,8 @@ void syncSplitBtree( { child->head.leafLink = bufSibling->volBlk; - parent->extent[parent->head.numRecs - 1].count = - child->extent[child->head.numRecs - 1].count; + parent->extent[parent->head.numRecs - 1].count = + child->extent[child->head.numRecs - 1].count; parent->extent[parent->head.numRecs].count = MAX_FILE_BLK; parent->extent[parent->head.numRecs].poolBlk = bufSibling->volBlk; parent->head.numRecs++; @@ -656,19 +620,19 @@ void syncSplitBtree( sibling->extent[0].count = child->extent[child->head.numRecs - 1].count; sibling->extent[0].poolBlk = - child->extent[child->head.numRecs - 1].poolBlk; + child->extent[child->head.numRecs - 1].poolBlk; sibling->head.numRecs = 1; sibling->extent[sibling->head.numRecs].count = - sibling->extent[sibling->head.numRecs - 1].count + + sibling->extent[sibling->head.numRecs - 1].count + extent->lengthOfExtent; sibling->extent[sibling->head.numRecs].poolBlk = extent->poolBlkNum; sibling->head.numRecs++; } else { - parent->extent[parent->head.numRecs - 1].count = - child->extent[child->head.numRecs - 2].count; + parent->extent[parent->head.numRecs - 1].count = + child->extent[child->head.numRecs - 2].count; parent->extent[parent->head.numRecs].count = MAX_FILE_BLK; parent->extent[parent->head.numRecs].poolBlk = bufSibling->volBlk; parent->head.numRecs++; @@ -676,13 +640,13 @@ void syncSplitBtree( sibling->extent[0].count = child->extent[child->head.numRecs - 2].count; sibling->extent[0].poolBlk = - child->extent[child->head.numRecs - 2].poolBlk; + child->extent[child->head.numRecs - 2].poolBlk; sibling->head.numRecs = 1; sibling->extent[sibling->head.numRecs].count = - child->extent[child->head.numRecs - 1].count; - sibling->extent[sibling->head.numRecs].poolBlk = - child->extent[child->head.numRecs - 1].poolBlk; + child->extent[child->head.numRecs - 1].count; + sibling->extent[sibling->head.numRecs].poolBlk = + child->extent[child->head.numRecs - 1].poolBlk; sibling->head.numRecs++; child->extent[child->head.numRecs - 1].count = 0; @@ -695,24 +659,24 @@ void syncSplitBtree( return; } - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(3) + - sizeof(FmapSplit_s) - 1 + - (sibling->head.numRecs * sizeof(FmapExt_s)) ); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_SPLIT, xaction, logBuffer, - 3, logBlks, logRecord); + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(3) + + sizeof(FmapSplit_s) - 1 + + (sibling->head.numRecs * sizeof(FmapExt_s)) ); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_SPLIT, xaction, logBuffer, + 3, logBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], bufChild->volBlk, - child->head.lsn, bufChild, xaction, 0); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], bufParent->volBlk, - parent->head.lsn, bufParent, xaction, 1); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[2], bufSibling->volBlk, - sibling->head.lsn, bufSibling, xaction, 2); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], bufChild->volBlk, + child->head.lsn, bufChild, xaction, 0); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], bufParent->volBlk, + parent->head.lsn, bufParent, xaction, 1); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[2], bufSibling->volBlk, + sibling->head.lsn, bufSibling, xaction, 2); ZLOG_ALLOC_BLOCK(logBlks[2]); - memcpy(&logRecord->u.split.data[0], &sibling->extent[0], - sibling->head.numRecs * sizeof(FmapExt_s)); - memcpy(&logRecord->u.split.parentExt[0], - &parent->extent[parent->head.numRecs - 2], 2 * sizeof(FmapExt_s)); + memcpy(&logRecord->u.split.data[0], &sibling->extent[0], + sibling->head.numRecs * sizeof(FmapExt_s)); + memcpy(&logRecord->u.split.parentExt[0], + &parent->extent[parent->head.numRecs - 2], 2 * sizeof(FmapExt_s)); logRecord->u.split.pIndex = parent->head.numRecs - 2; logRecord->u.split.childLink = bufSibling->volBlk; @@ -739,9 +703,9 @@ void syncSplitBtree( Buffer_s *splitBtreeBranchSparse( ZfsXaction_s *xaction, - Buffer_s *bufChild, - Buffer_s *bufSibling, - Buffer_s *bufParent, + Buffer_s *bufChild, + Buffer_s *bufSibling, + Buffer_s *bufParent, NINT index, NINT *parentIndex) { @@ -765,15 +729,15 @@ Buffer_s *splitBtreeBranchSparse( sibling->head.fnh_zid = child->head.fnh_zid; sibling->head.state = child->head.state; sibling->head.leafLink = INVALID_BLK_ZERO; - zASSERT(bufSibling->volBlk != 0); + zASSERT(bufSibling->volBlk != 0); if (child->extent[index].count == MAX_FILE_BLK) { zASSERT(index == child->head.numRecs -1); zASSERT(parent->extent[pIndex].count == MAX_FILE_BLK); zASSERT(pIndex == parent->head.numRecs -1); - parent->extent[pIndex].count = - child->extent[index - 1].count; + parent->extent[pIndex].count = + child->extent[index - 1].count; parent->extent[pIndex + 1].count = MAX_FILE_BLK; parent->extent[pIndex + 1].poolBlk = bufSibling->volBlk; parent->head.numRecs++; @@ -781,13 +745,13 @@ Buffer_s *splitBtreeBranchSparse( sibling->extent[0].count = child->extent[index - 1].count; sibling->extent[0].poolBlk = - child->extent[index -1].poolBlk; + child->extent[index -1].poolBlk; sibling->head.numRecs = 1; sibling->extent[sibling->head.numRecs].count = - child->extent[index].count; - sibling->extent[sibling->head.numRecs].poolBlk = - child->extent[index].poolBlk; + child->extent[index].count; + sibling->extent[sibling->head.numRecs].poolBlk = + child->extent[index].poolBlk; sibling->head.numRecs++; child->extent[index].count = 0; @@ -801,21 +765,21 @@ Buffer_s *splitBtreeBranchSparse( { tmpIndex = child->head.numRecs >> 1; /** Copy half the records to the new node **/ - memcpy(&sibling->extent[0], &child->extent[tmpIndex], - (sizeof(FmapExt_s) * (child->head.numRecs - tmpIndex))); + memcpy(&sibling->extent[0], &child->extent[tmpIndex], + (sizeof(FmapExt_s) * (child->head.numRecs - tmpIndex))); sibling->head.numRecs = child->head.numRecs - tmpIndex; child->head.numRecs = tmpIndex + 1; - bzero(&child->extent[child->head.numRecs], - (sizeof(FmapExt_s) * (FMAP_MAX - child->head.numRecs))); - + bzero(&child->extent[child->head.numRecs], + (sizeof(FmapExt_s) * (FMAP_MAX - child->head.numRecs))); + memmove(&parent->extent[pIndex + 2], &parent->extent[pIndex + 1], sizeof(FmapExt_s) * (parent->head.numRecs - (pIndex + 1))); parent->extent[pIndex + 1].count = parent->extent[pIndex].count; parent->extent[pIndex + 1].poolBlk = bufSibling->volBlk; parent->extent[pIndex].count = sibling->extent[0].count; parent->head.numRecs++; - + if (index < child->head.numRecs) { *parentIndex = index; @@ -828,24 +792,24 @@ Buffer_s *splitBtreeBranchSparse( } } - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(3) + - sizeof(FmapSplit_s) - 1 + - (sibling->head.numRecs * sizeof(FmapExt_s))); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_SPLIT, xaction, logBuffer, - 3, logBlks, logRecord); + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(3) + + sizeof(FmapSplit_s) - 1 + + (sibling->head.numRecs * sizeof(FmapExt_s))); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_SPLIT, xaction, logBuffer, + 3, logBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], bufChild->volBlk, - child->head.lsn, bufChild, xaction, 0); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], bufParent->volBlk, - parent->head.lsn, bufParent, xaction, 1); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[2], bufSibling->volBlk, - sibling->head.lsn, bufSibling, xaction, 2); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], bufChild->volBlk, + child->head.lsn, bufChild, xaction, 0); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], bufParent->volBlk, + parent->head.lsn, bufParent, xaction, 1); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[2], bufSibling->volBlk, + sibling->head.lsn, bufSibling, xaction, 2); ZLOG_ALLOC_BLOCK(logBlks[2]); - memcpy(&logRecord->u.split.data[0], &sibling->extent[0], - sibling->head.numRecs * sizeof(FmapExt_s)); - memcpy(&logRecord->u.split.parentExt[0], - &parent->extent[pIndex], 2 * sizeof(FmapExt_s)); + memcpy(&logRecord->u.split.data[0], &sibling->extent[0], + sibling->head.numRecs * sizeof(FmapExt_s)); + memcpy(&logRecord->u.split.parentExt[0], + &parent->extent[pIndex], 2 * sizeof(FmapExt_s)); logRecord->u.split.pIndex = pIndex; logRecord->u.split.childLink = INVALID_BLK_ZERO; @@ -888,7 +852,7 @@ void updateNodeEntry( if (fileBlk == node->extent[index -1].count) { - memmove(&node->extent[index + 1], &node->extent[index], + memmove(&node->extent[index + 1], &node->extent[index], sizeof(FmapExt_s) * (node->head.numRecs - index)); node->head.numRecs++; node->extent[index].count = fileBlk + extent->lengthOfExtent; @@ -896,7 +860,7 @@ void updateNodeEntry( } else if ((fileBlk + extent->lengthOfExtent) == node->extent[index].count) { - memmove(&node->extent[index + 2], &node->extent[index + 1], + memmove(&node->extent[index + 2], &node->extent[index + 1], sizeof(FmapExt_s) * (node->head.numRecs - (index + 1))); node->head.numRecs++; node->extent[index + 1].count = node->extent[index].count; @@ -906,7 +870,7 @@ void updateNodeEntry( else { memmove(&node->extent[index + 3], &node->extent[index + 1], - sizeof(FmapExt_s) * (node->head.numRecs - (index + 1))); + sizeof(FmapExt_s) * (node->head.numRecs - (index + 1))); node->head.numRecs+=2; @@ -919,17 +883,17 @@ void updateNodeEntry( node->extent[index].count = fileBlk; node->extent[index].poolBlk = 0; } - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(FmapInsertSparse_s) ); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INSERT_SPARSE, xaction, logBuffer, 1, - logBlks, logRecord); + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(FmapInsertSparse_s) ); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INSERT_SPARSE, xaction, logBuffer, 1, + logBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, - node->head.lsn, buf, xaction, 0); - + node->head.lsn, buf, xaction, 0); + memcpy(&logRecord->u.insertSparse.origExt[0], &origExt[0], - 3 * sizeof(FmapExt_s)); + 3 * sizeof(FmapExt_s)); memcpy(&logRecord->u.insertSparse.finalExt[0], &node->extent[index], - 3 * sizeof(FmapExt_s)); + 3 * sizeof(FmapExt_s)); logRecord->u.insertSparse.origNumRecs = origNumRecs; logRecord->u.insertSparse.finalNumRecs = node->head.numRecs; logRecord->u.insertSparse.index = index + 1; @@ -941,9 +905,9 @@ void updateNodeEntry( void splitBtreeLeafSparse( ZfsXaction_s *xaction, - Buffer_s *bufChild, - Buffer_s *bufSibling, - Buffer_s *bufParent, + Buffer_s *bufChild, + Buffer_s *bufSibling, + Buffer_s *bufParent, NINT index, NINT pIndex, Extent_s *extent, @@ -974,8 +938,8 @@ void splitBtreeLeafSparse( sibling->head.leafLink = INVALID_BLK_ZERO; pIndex = parent->head.numRecs - 1; - parent->extent[pIndex].count = - child->extent[child->head.numRecs - 1].count; + parent->extent[pIndex].count = + child->extent[child->head.numRecs - 1].count; parent->extent[pIndex + 1].count = MAX_FILE_BLK; parent->extent[pIndex + 1].poolBlk = bufSibling->volBlk; parent->head.numRecs++; @@ -983,7 +947,7 @@ void splitBtreeLeafSparse( sibling->extent[0].count = child->extent[child->head.numRecs - 1].count; sibling->extent[0].poolBlk = - child->extent[child->head.numRecs - 1].poolBlk; + child->extent[child->head.numRecs - 1].poolBlk; sibling->head.numRecs = 1; sibling->extent[sibling->head.numRecs].count = @@ -992,7 +956,7 @@ void splitBtreeLeafSparse( sibling->head.numRecs++; sibling->extent[sibling->head.numRecs].count = - sibling->extent[sibling->head.numRecs - 1].count + + sibling->extent[sibling->head.numRecs - 1].count + extent->lengthOfExtent; sibling->extent[sibling->head.numRecs].poolBlk = extent->poolBlkNum; sibling->head.numRecs++; @@ -1006,14 +970,14 @@ void splitBtreeLeafSparse( if (index == tmpIndex) tmpIndex = tmpIndex + 1; /** Copy half the records to the new node **/ - memcpy(&sibling->extent[0], &child->extent[tmpIndex], - (sizeof(FmapExt_s) * (child->head.numRecs - tmpIndex))); + memcpy(&sibling->extent[0], &child->extent[tmpIndex], + (sizeof(FmapExt_s) * (child->head.numRecs - tmpIndex))); sibling->head.numRecs = child->head.numRecs - tmpIndex; child->head.numRecs = tmpIndex + 1; - bzero(&child->extent[child->head.numRecs], - (sizeof(FmapExt_s) * (FMAP_MAX - child->head.numRecs))); - + bzero(&child->extent[child->head.numRecs], + (sizeof(FmapExt_s) * (FMAP_MAX - child->head.numRecs))); + memmove(&parent->extent[pIndex + 2], &parent->extent[pIndex + 1], sizeof(FmapExt_s) * (parent->head.numRecs - (pIndex + 1))); parent->head.numRecs++; @@ -1028,24 +992,24 @@ void splitBtreeLeafSparse( return; } - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(3) + - sizeof(FmapSplit_s) - 1 + - (sibling->head.numRecs * sizeof(FmapExt_s)) ); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_SPLIT, xaction, logBuffer, - 3, logBlks, logRecord); + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(3) + + sizeof(FmapSplit_s) - 1 + + (sibling->head.numRecs * sizeof(FmapExt_s)) ); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_SPLIT, xaction, logBuffer, + 3, logBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], bufChild->volBlk, - child->head.lsn, bufChild, xaction, 0); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], bufParent->volBlk, - parent->head.lsn, bufParent, xaction, 1); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[2], bufSibling->volBlk, - sibling->head.lsn, bufSibling, xaction, 2); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], bufChild->volBlk, + child->head.lsn, bufChild, xaction, 0); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], bufParent->volBlk, + parent->head.lsn, bufParent, xaction, 1); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[2], bufSibling->volBlk, + sibling->head.lsn, bufSibling, xaction, 2); ZLOG_ALLOC_BLOCK(logBlks[2]); - memcpy(&logRecord->u.split.data[0], &sibling->extent[0], - sibling->head.numRecs * sizeof(FmapExt_s)); - memcpy(&logRecord->u.split.parentExt[0], - &parent->extent[pIndex], 2 * sizeof(FmapExt_s)); + memcpy(&logRecord->u.split.data[0], &sibling->extent[0], + sibling->head.numRecs * sizeof(FmapExt_s)); + memcpy(&logRecord->u.split.parentExt[0], + &parent->extent[pIndex], 2 * sizeof(FmapExt_s)); logRecord->u.split.pIndex = pIndex; logRecord->u.split.childLink = child->head.leafLink; @@ -1109,7 +1073,7 @@ STATUS updateSparseLeaf( #if FMAP_TEST IS_ENABLED NINT fmapMax; #endif - + ASSERT_MPKNSS_LOCK(); if (allocAhead) { @@ -1128,33 +1092,33 @@ STATUS updateSparseLeaf( node->extent[node->head.numRecs].poolBlk = 0; node->head.numRecs++; - node->extent[node->head.numRecs].count = - fileBlk + extent.lengthOfExtent; + node->extent[node->head.numRecs].count = + fileBlk + extent.lengthOfExtent; node->extent[node->head.numRecs].poolBlk = extent.poolBlkNum; node->head.numRecs++; - if (bufParent) + if (bufParent) { CACHE_RELEASE(bufParent); } - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(FmapInsert_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INSERT, xaction, logBuffer, 1, - logBlks, logRecord); + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(FmapInsert_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INSERT, xaction, logBuffer, 1, + logBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, - node->head.lsn, buf, xaction, 0); + node->head.lsn, buf, xaction, 0); - node->head.lsn = logBuffer->ZXR_Lsn; + node->head.lsn = logBuffer->ZXR_Lsn; logRecord->u.insert.numRecs = 2; - logRecord->u.insert.extent.poolBlk = extent.poolBlkNum; - logRecord->u.insert.extent.count = extent.lengthOfExtent; - logRecord->u.insert.fileBlk = fileBlk; + logRecord->u.insert.extent.poolBlk = extent.poolBlkNum; + logRecord->u.insert.extent.count = extent.lengthOfExtent; + logRecord->u.insert.fileBlk = fileBlk; - ZLOG_BIND(xaction, buf); - ZLOG_ReleaseRecord(xaction); + ZLOG_BIND(xaction, buf); + ZLOG_ReleaseRecord(xaction); CACHE_DIRTY_RELEASE(buf); } @@ -1177,8 +1141,8 @@ STATUS updateSparseLeaf( localExt.poolBlkNum = bufSibling->volBlk; localExt.lengthOfExtent = 1; - zfsFreeExtent(genMsg, beast->vol.zfsVol, - &localExt, xaction); + zfsFreeExtent(genMsg, beast->vol.zfsVol, + &localExt, xaction); cacheReleaseToss(bufSibling); return zFAILURE; @@ -1189,8 +1153,8 @@ STATUS updateSparseLeaf( } zASSERT(bufParent != NULL); stInfo->fmapTreeBlks++; - splitBtreeLeafSparse(xaction, buf, bufSibling, bufParent, - index, pIndex, &extent, allocAhead, fileBlk); + splitBtreeLeafSparse(xaction, buf, bufSibling, bufParent, + index, pIndex, &extent, allocAhead, fileBlk); CACHE_DIRTY_RELEASE(buf); buf = NULL; CACHE_DIRTY_RELEASE(bufParent); @@ -1206,23 +1170,23 @@ STATUS updateSparseLeaf( memcpy(&origExt[0], &node->extent[index -1], 3 * sizeof(FmapExt_s)); origNumRecs = node->head.numRecs; - if ((index > 1) && + if ((index > 1) && (fileBlk == node->extent[index - 1].count) && ((node->extent[index - 1].poolBlk + (node->extent[index -1].count - - node->extent[index - 2].count)) == extent.poolBlkNum)) + node->extent[index - 2].count)) == extent.poolBlkNum)) { node->extent[index - 1].count += extent.lengthOfExtent; if (node->extent[index - 1].count == node->extent[index].count) { - if (node->extent[index + 1].poolBlk == - (node->extent[index - 1].poolBlk + - (node->extent[index -1].count - - node->extent[index - 2].count)) ) + if (node->extent[index + 1].poolBlk == + (node->extent[index - 1].poolBlk + + (node->extent[index -1].count - + node->extent[index - 2].count)) ) { node->extent[index-1].count = node->extent[index+1].count; - memmove(&node->extent[index], &node->extent[index + 2], - sizeof(FmapExt_s) * (node->head.numRecs - (index + 2))); + memmove(&node->extent[index], &node->extent[index + 2], + sizeof(FmapExt_s) * (node->head.numRecs - (index + 2))); node->head.numRecs-=2; node->extent[node->head.numRecs].count = 0; node->extent[node->head.numRecs].poolBlk = 0; @@ -1231,36 +1195,36 @@ STATUS updateSparseLeaf( } else { - memmove(&node->extent[index], &node->extent[index + 1], - sizeof(FmapExt_s) * (node->head.numRecs - (index + 1))); + memmove(&node->extent[index], &node->extent[index + 1], + sizeof(FmapExt_s) * (node->head.numRecs - (index + 1))); node->head.numRecs--; node->extent[node->head.numRecs].count = 0; node->extent[node->head.numRecs].poolBlk = 0; } } - if (bufParent) + if (bufParent) { CACHE_RELEASE(bufParent); } } - else if (((fileBlk + extent.lengthOfExtent) == - node->extent[index].count) && - ((extent.poolBlkNum + extent.lengthOfExtent) == - node->extent[index + 1].poolBlk)) + else if (((fileBlk + extent.lengthOfExtent) == + node->extent[index].count) && + ((extent.poolBlkNum + extent.lengthOfExtent) == + node->extent[index + 1].poolBlk)) { node->extent[index].count = fileBlk; node->extent[index + 1].poolBlk = extent.poolBlkNum; - + if (node->extent[index - 1].count == node->extent[index].count) { - if ((index > 1) && (node->extent[index + 1].poolBlk == - (node->extent[index - 1].poolBlk + - (node->extent[index -1].count - - node->extent[index - 2].count)) )) + if ((index > 1) && (node->extent[index + 1].poolBlk == + (node->extent[index - 1].poolBlk + + (node->extent[index -1].count - + node->extent[index - 2].count)) )) { node->extent[index-1].count = node->extent[index+1].count; - memmove(&node->extent[index], &node->extent[index + 2], - sizeof(FmapExt_s) * (node->head.numRecs - (index + 2))); + memmove(&node->extent[index], &node->extent[index + 2], + sizeof(FmapExt_s) * (node->head.numRecs - (index + 2))); node->head.numRecs-=2; node->extent[node->head.numRecs].count = 0; node->extent[node->head.numRecs].poolBlk = 0; @@ -1269,29 +1233,29 @@ STATUS updateSparseLeaf( } else { - memmove(&node->extent[index], &node->extent[index + 1], - sizeof(FmapExt_s) * (node->head.numRecs - (index + 1))); + memmove(&node->extent[index], &node->extent[index + 1], + sizeof(FmapExt_s) * (node->head.numRecs - (index + 1))); node->head.numRecs--; node->extent[node->head.numRecs].count = 0; node->extent[node->head.numRecs].poolBlk = 0; } } - if (bufParent) + if (bufParent) { CACHE_RELEASE(bufParent); } } - else if ((fileBlk == node->extent[index - 1].count) && - (extent.lengthOfExtent == (node->extent[index].count - - node->extent[index - 1].count)) ) + else if ((fileBlk == node->extent[index - 1].count) && + (extent.lengthOfExtent == (node->extent[index].count - + node->extent[index - 1].count)) ) { node->extent[index].poolBlk = extent.poolBlkNum; - if (bufParent) + if (bufParent) { CACHE_RELEASE(bufParent); } } - else + else { tmpFlag = 1; #if FMAP_TEST IS_ENABLED @@ -1306,7 +1270,7 @@ STATUS updateSparseLeaf( #endif { updateNodeEntry(xaction, buf, index, &extent, fileBlk); - if (bufParent) + if (bufParent) { CACHE_RELEASE(bufParent); } @@ -1332,8 +1296,8 @@ STATUS updateSparseLeaf( localExt.poolBlkNum = bufSibling->volBlk; localExt.lengthOfExtent = 1; - zfsFreeExtent(genMsg, beast->vol.zfsVol, - &localExt, xaction); + zfsFreeExtent(genMsg, beast->vol.zfsVol, + &localExt, xaction); cacheReleaseToss(bufSibling); return zFAILURE; @@ -1346,7 +1310,7 @@ STATUS updateSparseLeaf( stInfo->fmapTreeBlks++; COMN_MARK_BEAST_XLOCAL(beast, &xaction->xaction); splitBtreeLeafSparse(xaction, buf, bufSibling, bufParent, - index, pIndex, &extent, allocAhead, fileBlk); + index, pIndex, &extent, allocAhead, fileBlk); CACHE_DIRTY_RELEASE(buf); buf = NULL; CACHE_DIRTY_RELEASE(bufParent); @@ -1357,18 +1321,18 @@ STATUS updateSparseLeaf( } if (tmpFlag == 0) { - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(FmapInsertSparse_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INSERT_SPARSE, xaction, logBuffer, + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(FmapInsertSparse_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INSERT_SPARSE, xaction, logBuffer, 1, logBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, - node->head.lsn, buf, xaction, 0); - + node->head.lsn, buf, xaction, 0); + memcpy(&logRecord->u.insertSparse.origExt[0], &origExt[0], - 3 * sizeof(FmapExt_s)); - memcpy(&logRecord->u.insertSparse.finalExt[0], - &node->extent[index -1], - 3 * sizeof(FmapExt_s)); + 3 * sizeof(FmapExt_s)); + memcpy(&logRecord->u.insertSparse.finalExt[0], + &node->extent[index -1], + 3 * sizeof(FmapExt_s)); logRecord->u.insertSparse.origNumRecs = origNumRecs; logRecord->u.insertSparse.finalNumRecs = node->head.numRecs; logRecord->u.insertSparse.index = index; @@ -1400,7 +1364,7 @@ STATUS updateSparse( Buffer_s *bufSibling = NULL; Buffer_s *tmpBuf; FmapNode_s *node; - NINT i, index, indexParent; + NINT i, index, indexParent; Extent_s extent; Blknum_t seed; Blknum_t len; @@ -1418,23 +1382,23 @@ STATUS updateSparse( if (fmap->root == INVALID_BLK_ZERO) { /* Making file sparse the first time, filemap is still direct, - * continuing entries will be in the btree */ + * continuing entries will be in the btree */ zASSERT(allocAhead != 0); extent.poolBlkNum = 0; extent.lengthOfExtent = length; index = 0; - /* Check to make sure we have enough user and directory space available */ + /* Check to make sure we have enough user and directory space available */ if (VOL_CheckUserSpace(genMsg, beast, numBytes) != zOK || DIRQ_CheckDirQuotas(genMsg, beast, numBytes) != zOK) { return zFAILURE; } - if (zfsAllocExtent(genMsg, beast->vol.zfsVol, &extent, - (flags & ALLOC_BLOCKS_CONTIGUOUS) ? XTREE_CONTIGUOUS_BLKS : 0, - xaction) != zOK) + if (zfsAllocExtent(genMsg, beast->vol.zfsVol, &extent, + (flags & ALLOC_BLOCKS_CONTIGUOUS) ? XTREE_CONTIGUOUS_BLKS : 0, + xaction) != zOK) { return zFAILURE; } @@ -1464,12 +1428,12 @@ STATUS updateSparse( node->extent[0].poolBlk = fmap->dirExt[fmap->numRecs -1].poolBlk; node->head.numRecs = 1; - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(FmapRoot_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INIT_ROOT, xaction, logBuffer, 1, - logBlks, logRecord); + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(FmapRoot_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INIT_ROOT, xaction, logBuffer, 1, + logBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, - node->head.lsn, buf, xaction, 0); + node->head.lsn, buf, xaction, 0); ZLOG_ALLOC_BLOCK(logBlks[0]); node->head.lsn = logBuffer->ZXR_Lsn; @@ -1477,8 +1441,8 @@ STATUS updateSparse( logRecord->u.root.numRecs = 1; logRecord->u.root.fr_internalID = node->head.fnh_internalID; logRecord->u.root.fr_zid = node->head.fnh_zid; - memcpy(&logRecord->u.root.extent[0], &node->extent[0], - 1 * sizeof(FmapExt_s)); + memcpy(&logRecord->u.root.extent[0], &node->extent[0], + 1 * sizeof(FmapExt_s)); ZLOG_BIND(xaction, buf); @@ -1506,7 +1470,7 @@ STATUS updateSparse( } while (!(node->head.state & BT_LEAF)) { - if (allocAhead) + if (allocAhead) { *poolBlk = node->extent[node->head.numRecs -1].poolBlk; index = node->head.numRecs - 1; @@ -1552,8 +1516,8 @@ STATUS updateSparse( CACHE_RELEASE(buf); localExt.poolBlkNum = bufSibling->volBlk; localExt.lengthOfExtent = 1; - zfsFreeExtent(genMsg, beast->vol.zfsVol, - &localExt, xaction); + zfsFreeExtent(genMsg, beast->vol.zfsVol, + &localExt, xaction); cacheReleaseToss(bufSibling); return zFAILURE; } @@ -1565,10 +1529,10 @@ STATUS updateSparse( stInfo->fmapTreeBlks++; COMN_MARK_BEAST_XLOCAL(beast, &xaction->xaction); - tmpBuf = splitBtreeBranchSparse(xaction, buf, bufSibling, + tmpBuf = splitBtreeBranchSparse(xaction, buf, bufSibling, bufParent, index, &indexParent); - (tmpBuf == buf) ? CACHE_DIRTY_RELEASE(bufSibling): - CACHE_DIRTY_RELEASE(buf); + (tmpBuf == buf) ? CACHE_DIRTY_RELEASE(bufSibling): + CACHE_DIRTY_RELEASE(buf); CACHE_DIRTY_RELEASE(bufParent); bufParent = tmpBuf; bufSibling = NULL; @@ -1579,7 +1543,7 @@ STATUS updateSparse( SET_DEBUG_ID(iomsg, 18); if ((buf = ZFS_ReadPoolBlk(genMsg, &iomsg)) == NULL) { - if (bufParent) + if (bufParent) { CACHE_RELEASE(bufParent); } @@ -1587,15 +1551,15 @@ STATUS updateSparse( } node = (FmapNode_s *)buf->pBuf.data; zASSERT((node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_BRANCH)); + (node->head.magic == FMAP_BT_BRANCH)); if ((node->head.magic != FMAP_BT_LEAF) && - (node->head.magic != FMAP_BT_BRANCH)) + (node->head.magic != FMAP_BT_BRANCH)) { SetErrno(genMsg, zERR_MEDIA_CORRUPTED); ZLSSPOOL_MediaIsCorrupt(genMsg, buf, &iomsg); CACHE_RELEASE(buf); buf = NULL; - if (bufParent) + if (bufParent) { CACHE_RELEASE(bufParent); } @@ -1605,8 +1569,8 @@ STATUS updateSparse( if (allocAhead) { if (node->head.numRecs > 1) - seed = node->extent[node->head.numRecs -1].poolBlk + - (fileBlk - node->extent[node->head.numRecs -2].count); + seed = node->extent[node->head.numRecs -1].poolBlk + + (fileBlk - node->extent[node->head.numRecs -2].count); else seed = 0; index = node->head.numRecs - 1; @@ -1616,10 +1580,10 @@ STATUS updateSparse( *poolBlk = searchLeaf(node, fileBlk, &len, &index); zASSERT(*poolBlk == 0); if (index > 2) - seed = node->extent[index - 1].poolBlk + - (fileBlk - node->extent[index -2].count); + seed = node->extent[index - 1].poolBlk + + (fileBlk - node->extent[index -2].count); else - seed = node->extent[index + 1].poolBlk - + seed = node->extent[index + 1].poolBlk - (node->extent[index].count - fileBlk); } #if FMAP_TEST IS_ENABLED @@ -1632,24 +1596,24 @@ STATUS updateSparse( #endif extent.lengthOfExtent = length; - /* Check to make sure we have enough user/directory space available */ + /* Check to make sure we have enough user/directory space available */ if (VOL_CheckUserSpace(genMsg, beast, numBytes) != zOK || DIRQ_CheckDirQuotas(genMsg, beast, numBytes) != zOK) { CACHE_DIRTY_RELEASE(buf); - if (bufParent) + if (bufParent) { CACHE_DIRTY_RELEASE(bufParent); } return zFAILURE; } - if (zfsAllocExtent( genMsg, beast->vol.zfsVol, &extent, - (flags & ALLOC_BLOCKS_CONTIGUOUS) ? XTREE_CONTIGUOUS_BLKS : 0, + if (zfsAllocExtent( genMsg, beast->vol.zfsVol, &extent, + (flags & ALLOC_BLOCKS_CONTIGUOUS) ? XTREE_CONTIGUOUS_BLKS : 0, xaction) != zOK) { CACHE_DIRTY_RELEASE(buf); - if (bufParent) + if (bufParent) { CACHE_DIRTY_RELEASE(bufParent); } @@ -1660,8 +1624,8 @@ ContinueAfterCreatingANewRoot: *poolBlk = extent.poolBlkNum; length = extent.lengthOfExtent; - if (updateSparseLeaf(genMsg, xaction, stInfo, buf, bufParent, index, - indexParent, fileBlk, extent, allocAhead) != zOK) + if (updateSparseLeaf(genMsg, xaction, stInfo, buf, bufParent, index, + indexParent, fileBlk, extent, allocAhead) != zOK) { zfsFreeExtent(genMsg, beast->vol.zfsVol, &extent, xaction); return zFAILURE; @@ -1680,9 +1644,9 @@ ContinueAfterCreatingANewRoot: { for(i = 1; i < length; i++) { - buf = cacheAllocBufferForUserData(&beast->ROOTmycache, - fileBlk+i, (*poolBlk)+i, - ZFS_BlockSignalHandler, STAT_CACHE_ALLOCATE); + buf = cacheAllocBufferForUserData(&beast->ROOTmycache, + fileBlk+i, (*poolBlk)+i, + ZFS_BlockSignalHandler, STAT_CACHE_ALLOCATE); if (buf->pBuf.data == NULL) { buf->pBuf.data = kmap_atomic(buf->b_page, KM_USER0); @@ -1704,7 +1668,7 @@ ContinueAfterCreatingANewRoot: STATUS updateBtreeFileMap( GeneralMsg_s *genMsg, ZfsXaction_s *xaction, - ZFSStorageInfo_s *stInfo, + ZFSStorageInfo_s *stInfo, Blknum_t fileBlk, Extent_s *extent, BYTE flags) @@ -1726,7 +1690,7 @@ STATUS updateBtreeFileMap( #if FMAP_TEST IS_ENABLED NINT fmapMax; #endif - + ASSERT_MPKNSS_LOCK(); beast = stInfo->comnInfo.beast; fmap = &stInfo->fmap; @@ -1737,11 +1701,11 @@ ContinueScanningTheBtree: SET_DEBUG_ID(iomsg, 19); if ((bufChild = ZFS_ReadPoolBlk(genMsg, &iomsg)) == NULL) { - if (bufParent) + if (bufParent) { CACHE_RELEASE(bufParent); } - if (bufSibling) + if (bufSibling) { CACHE_RELEASE(bufSibling); } @@ -1760,11 +1724,11 @@ ContinueScanningTheBtree: ZLSSPOOL_MediaIsCorrupt(genMsg, bufChild, &iomsg); CACHE_RELEASE(bufChild); bufChild = NULL; - if (bufParent) + if (bufParent) { CACHE_RELEASE(bufParent); } - if (bufSibling) + if (bufSibling) { CACHE_RELEASE(bufSibling); } @@ -1773,8 +1737,8 @@ ContinueScanningTheBtree: if (child->head.state & BT_LEAF) { seed = child->extent[child->head.numRecs-1].poolBlk - - child->extent[child->head.numRecs-2].count + - child->extent[child->head.numRecs-1].count; + child->extent[child->head.numRecs-2].count + + child->extent[child->head.numRecs-1].count; #if FMAP_TEST IS_ENABLED if (FmapTest || OneBlockExtents) extent->poolBlkNum = 0; @@ -1783,45 +1747,45 @@ ContinueScanningTheBtree: #else extent->poolBlkNum = seed; #endif - /* Check to make sure we have enough user/directory space available */ + /* Check to make sure we have enough user/directory space available */ numBytes = extent->lengthOfExtent << beast->ROOTblkSizeShift; if (VOL_CheckUserSpace(genMsg, beast, numBytes) != zOK || DIRQ_CheckDirQuotas(genMsg, beast, numBytes) != zOK) { - if (bufChild) - { + if (bufChild) + { CACHE_DIRTY_RELEASE(bufChild); } - if (bufParent) - { + if (bufParent) + { CACHE_DIRTY_RELEASE(bufParent); } - if (bufSibling) - { + if (bufSibling) + { CACHE_DIRTY_RELEASE(bufSibling); } return zFAILURE; } - if (zfsAllocExtent( genMsg, beast->vol.zfsVol, extent, - (flags & ALLOC_BLOCKS_CONTIGUOUS) ? XTREE_CONTIGUOUS_BLKS : 0, + if (zfsAllocExtent( genMsg, beast->vol.zfsVol, extent, + (flags & ALLOC_BLOCKS_CONTIGUOUS) ? XTREE_CONTIGUOUS_BLKS : 0, xaction) != zOK) { - if (bufChild) - { + if (bufChild) + { CACHE_DIRTY_RELEASE(bufChild); } - if (bufParent) - { + if (bufParent) + { CACHE_DIRTY_RELEASE(bufParent); } - if (bufSibling) - { + if (bufSibling) + { CACHE_DIRTY_RELEASE(bufSibling); } return zFAILURE; } - + #if FMAP_TEST IS_ENABLED if (FmapTest) fmapMax = FMAP_MAX_SMALL; @@ -1829,26 +1793,26 @@ ContinueScanningTheBtree: fmapMax = FMAP_MAX - 5; #endif if ((child->extent[child->head.numRecs -1].poolBlk + - child->extent[child->head.numRecs -1].count - - child->extent[child->head.numRecs -2].count) == extent->poolBlkNum) + child->extent[child->head.numRecs -1].count - + child->extent[child->head.numRecs -2].count) == extent->poolBlkNum) { child->extent[child->head.numRecs -1].count+=extent->lengthOfExtent; - - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(FmapInsert_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INSERT, xaction, logBuffer, 1, - logBlks, logRecord); + + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(FmapInsert_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INSERT, xaction, logBuffer, 1, + logBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], bufChild->volBlk, - child->head.lsn, bufChild, xaction, 0); + child->head.lsn, bufChild, xaction, 0); - child->head.lsn = logBuffer->ZXR_Lsn; + child->head.lsn = logBuffer->ZXR_Lsn; logRecord->u.insert.numRecs = 0; - logRecord->u.insert.extent.poolBlk = 0; - logRecord->u.insert.extent.count = extent->lengthOfExtent; + logRecord->u.insert.extent.poolBlk = 0; + logRecord->u.insert.extent.count = extent->lengthOfExtent; - ZLOG_BIND(xaction, bufChild); - ZLOG_ReleaseRecord(xaction); + ZLOG_BIND(xaction, bufChild); + ZLOG_ReleaseRecord(xaction); } #if FMAP_TEST IS_ENABLED else if (child->head.numRecs < (fmapMax - 1)) @@ -1861,32 +1825,32 @@ ContinueScanningTheBtree: child->extent[child->head.numRecs -1].count+extent->lengthOfExtent; child->head.numRecs++; - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(FmapInsert_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INSERT, xaction, logBuffer, 1, - logBlks, logRecord); + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(FmapInsert_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INSERT, xaction, logBuffer, 1, + logBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], bufChild->volBlk, - child->head.lsn, bufChild, xaction, 0); + child->head.lsn, bufChild, xaction, 0); - child->head.lsn = logBuffer->ZXR_Lsn; + child->head.lsn = logBuffer->ZXR_Lsn; logRecord->u.insert.numRecs = 1; - logRecord->u.insert.extent.poolBlk = - child->extent[child->head.numRecs -1].poolBlk; - logRecord->u.insert.extent.count = - child->extent[child->head.numRecs -1].count; + logRecord->u.insert.extent.poolBlk = + child->extent[child->head.numRecs -1].poolBlk; + logRecord->u.insert.extent.count = + child->extent[child->head.numRecs -1].count; - ZLOG_BIND(xaction, bufChild); - ZLOG_ReleaseRecord(xaction); + ZLOG_BIND(xaction, bufChild); + ZLOG_ReleaseRecord(xaction); } else { XALLOC_SEED_IO_MSG(iomsg, beast, xaction, 0, CACHE_UPDATE); if ((bufSibling = ZFS_AllocPoolBlk(genMsg, &iomsg)) == NULL) { - zfsFreeExtent(genMsg, beast->vol.zfsVol, - extent, xaction); + zfsFreeExtent(genMsg, beast->vol.zfsVol, + extent, xaction); CACHE_RELEASE(bufChild); return zFAILURE; } @@ -1897,20 +1861,20 @@ ContinueScanningTheBtree: { Extent_s localExt; - zfsFreeExtent(genMsg, beast->vol.zfsVol, - extent, xaction); + zfsFreeExtent(genMsg, beast->vol.zfsVol, + extent, xaction); CACHE_RELEASE(bufChild); localExt.poolBlkNum = bufSibling->volBlk; localExt.lengthOfExtent = 1; zfsFreeExtent(genMsg, beast->vol.zfsVol, - &localExt, xaction); + &localExt, xaction); cacheReleaseToss(bufSibling); return zFAILURE; - } + } stInfo->fmapTreeBlks++; syncGrowBtree(xaction, bufChild, bufParent, &tmp, beast); fmap->root = bufParent->volBlk; @@ -1942,7 +1906,7 @@ ContinueScanningTheBtree: if (child->head.numRecs < (FMAP_MAX - 6)) #endif { - if (bufParent) + if (bufParent) { CACHE_DIRTY_RELEASE(bufParent); bufParent = NULL; @@ -1969,12 +1933,12 @@ ContinueScanningTheBtree: localExt.poolBlkNum = bufSibling->volBlk; localExt.lengthOfExtent = 1; zfsFreeExtent(genMsg, beast->vol.zfsVol, - &localExt, xaction); + &localExt, xaction); cacheReleaseToss(bufSibling); return zFAILURE; - } + } stInfo->fmapTreeBlks++; - syncGrowBtree(xaction, bufChild, bufParent, &tmp, beast); + syncGrowBtree(xaction, bufChild, bufParent, &tmp, beast); fmap->root = bufParent->volBlk; } zASSERT(bufParent != NULL); @@ -1983,7 +1947,7 @@ ContinueScanningTheBtree: COMN_MARK_BEAST_XLOCAL(beast, &xaction->xaction); syncSplitBtree(xaction, bufChild, bufSibling, bufParent, extent); - CACHE_DIRTY_RELEASE(bufChild); + CACHE_DIRTY_RELEASE(bufChild); bufChild = NULL; CACHE_DIRTY_RELEASE(bufParent); bufParent = NULL; @@ -1994,7 +1958,7 @@ ContinueScanningTheBtree: goto ContinueScanningTheBtree; } CACHE_DIRTY_RELEASE(bufChild); - if (bufParent) + if (bufParent) { CACHE_DIRTY_RELEASE(bufParent); } @@ -2009,7 +1973,7 @@ ContinueScanningTheBtree: STATUS updateDirectFileMap( GeneralMsg_s *genMsg, ZfsXaction_s *xaction, - ZFSStorageInfo_s *stInfo, + ZFSStorageInfo_s *stInfo, Blknum_t fileBlk, Extent_s *extent) { @@ -2023,7 +1987,7 @@ STATUS updateDirectFileMap( ZfsXasRecovery_s *logBuffer; BlockInfo_s *logBlks; FmapLog_s *logRecord; - + ASSERT_MPKNSS_LOCK(); beast = stInfo->comnInfo.beast; fmap = &stInfo->fmap; @@ -2035,8 +1999,8 @@ STATUS updateDirectFileMap( fmap->numRecs++; } else if ( ( fmap->dirExt[fmap->numRecs -1].poolBlk - - fmap->dirExt[fmap->numRecs -2].count + - fmap->dirExt[fmap->numRecs -1].count ) == poolBlk) + fmap->dirExt[fmap->numRecs -2].count + + fmap->dirExt[fmap->numRecs -1].count ) == poolBlk) { fmap->dirExt[fmap->numRecs - 1].count += length; } @@ -2044,8 +2008,8 @@ STATUS updateDirectFileMap( { fmap->dirExt[fmap->numRecs].poolBlk = poolBlk; fmap->dirExt[fmap->numRecs].count = - fmap->dirExt[fmap->numRecs -1].count + length; - fmap->numRecs++; + fmap->dirExt[fmap->numRecs -1].count + length; + fmap->numRecs++; } else { @@ -2068,23 +2032,23 @@ STATUS updateDirectFileMap( node->head.leafLink = 0; node->head.lsn = 0; - node->extent[node->head.numRecs].count = - fmap->dirExt[fmap->numRecs - 1].count; - node->extent[node->head.numRecs].poolBlk = - fmap->dirExt[fmap->numRecs -1].poolBlk; + node->extent[node->head.numRecs].count = + fmap->dirExt[fmap->numRecs - 1].count; + node->extent[node->head.numRecs].poolBlk = + fmap->dirExt[fmap->numRecs -1].poolBlk; node->head.numRecs++; - node->extent[node->head.numRecs].count = - fmap->dirExt[fmap->numRecs - 1].count + length; + node->extent[node->head.numRecs].count = + fmap->dirExt[fmap->numRecs - 1].count + length; node->extent[node->head.numRecs].poolBlk = poolBlk; node->head.numRecs++; - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(FmapRoot_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INIT_ROOT, xaction, logBuffer, 1, - logBlks, logRecord); + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(FmapRoot_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_INIT_ROOT, xaction, logBuffer, 1, + logBlks, logRecord); ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buffer->volBlk, - node->head.lsn, buffer, xaction, 0); + node->head.lsn, buffer, xaction, 0); ZLOG_ALLOC_BLOCK(logBlks[0]); node->head.lsn = logBuffer->ZXR_Lsn; @@ -2092,13 +2056,13 @@ STATUS updateDirectFileMap( logRecord->u.root.numRecs = 2; logRecord->u.root.fr_internalID = node->head.fnh_internalID; logRecord->u.root.fr_zid = node->head.fnh_zid; - memcpy(&logRecord->u.root.extent[0], &node->extent[0], - 2 * sizeof(FmapExt_s)); + memcpy(&logRecord->u.root.extent[0], &node->extent[0], + 2 * sizeof(FmapExt_s)); ZLOG_BIND(xaction, buffer); ZLOG_ReleaseRecord(xaction); - + CACHE_DIRTY_RELEASE(buffer); } return zOK; @@ -2188,12 +2152,12 @@ static void PS_UpdateItem( Zid_t parentZid, Blknum_t seed ) STATUS extendFileMap( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, ZfsXaction_s *xaction, - ZFSStorageInfo_s *stInfo, + ZFSStorageInfo_s *stInfo, Blknum_t *poolBlk, NINT allocLength, - BYTE flags) + BYTE flags) { Fmap_s *fmap = &stInfo->fmap; RootBeast_s *beast = stInfo->comnInfo.beast; @@ -2207,7 +2171,7 @@ STATUS extendFileMap( Zid_t parentZid = 0; NINT lFlags = 0; - + ASSERT_MPKNSS_LOCK(); extent.lengthOfExtent = allocLength; if ((fileBlk == 0) && (fmap->numRecs == 0)) @@ -2222,7 +2186,7 @@ STATUS extendFileMap( seed = 0; #ifdef ZLSS_PARENT_BIAS if ( ZLSS_ParentBias && (allocLength <= ZLSS_ParentBiasSmall) && - COMN_IsDerivedFrom( beast, zFTYPE_NAMED_DATA_STREAM ) ) + COMN_IsDerivedFrom( beast, zFTYPE_NAMED_DATA_STREAM ) ) { NamedBeast_s *nbeast = (NamedBeast_s *)beast; @@ -2230,7 +2194,7 @@ STATUS extendFileMap( parentZid = nbeast->firstParent.p.zid; if ( parentZid ) { seed = PS_FindSeed( parentZid ); - /* ZLSS_PARENT_BIAS - If we keep this then need new + /* ZLSS_PARENT_BIAS - If we keep this then need new flags so that we do not mix metadata area with user blocks. Some of the user files may be more than one block so they may want to smash into our @@ -2253,10 +2217,10 @@ STATUS extendFileMap( else { seed = fmap->dirExt[fmap->numRecs - 1].poolBlk + - (fmap->dirExt[fmap->numRecs - 1].count - + (fmap->dirExt[fmap->numRecs - 1].count - fmap->dirExt[fmap->numRecs - 2].count); } - + #if FMAP_TEST IS_ENABLED if (FmapTest || OneBlockExtents) extent.poolBlkNum = 0; @@ -2265,7 +2229,7 @@ STATUS extendFileMap( #else extent.poolBlkNum = seed; #endif - /* Check to make sure we have enough user/directory space available */ + /* Check to make sure we have enough user/directory space available */ numBytes = allocLength << beast->ROOTblkSizeShift; if (VOL_CheckUserSpace(genMsg, beast, numBytes) != zOK || DIRQ_CheckDirQuotas(genMsg, beast, numBytes) != zOK) @@ -2273,13 +2237,13 @@ STATUS extendFileMap( return zFAILURE; } - if (zfsAllocExtent( genMsg, beast->vol.zfsVol, &extent, + if (zfsAllocExtent( genMsg, beast->vol.zfsVol, &extent, (flags & ALLOC_BLOCKS_CONTIGUOUS) ? XTREE_CONTIGUOUS_BLKS : lFlags, xaction) != zOK) { return zFAILURE; } - if (updateDirectFileMap(genMsg, xaction, + if (updateDirectFileMap(genMsg, xaction, stInfo, fileBlk, &extent) != zOK) { zfsFreeExtent(genMsg, beast->vol.zfsVol, &extent, xaction); @@ -2298,8 +2262,8 @@ STATUS extendFileMap( } else { - if (updateBtreeFileMap(genMsg, xaction, - stInfo, fileBlk, &extent, flags) != zOK) + if (updateBtreeFileMap(genMsg, xaction, + stInfo, fileBlk, &extent, flags) != zOK) { return zFAILURE; } @@ -2313,9 +2277,9 @@ STATUS extendFileMap( { for(i = 1; i < allocatedLength; i++) { - buf = cacheAllocBufferForUserData(&beast->ROOTmycache, - fileBlk+i, (*poolBlk)+i, - ZFS_BlockSignalHandler, STAT_CACHE_ALLOCATE); + buf = cacheAllocBufferForUserData(&beast->ROOTmycache, + fileBlk+i, (*poolBlk)+i, + ZFS_BlockSignalHandler, STAT_CACHE_ALLOCATE); if (buf->pBuf.data == NULL) { buf->pBuf.data = kmap_atomic(buf->b_page, KM_USER0); @@ -2340,10 +2304,10 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( { RootBeast_s *beast = io->beast; ZFSStorageInfo_s *stInfo = beast->storage.zfsInfo; - Blknum_t poolBlk; - Blknum_t tmpBlk; + Blknum_t poolBlk; + Blknum_t tmpBlk; Blknum_t fileBlk = io->fileBlk; - Blknum_t allocAhead; + Blknum_t allocAhead; Blknum_t allocRemain; Buffer_s *buf; ZfsXaction_s *xaction; @@ -2358,8 +2322,8 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( if (fileBlk >= stInfo->nextBlk) { ASSERT_SLATCH( &CACHE_SparseBuffer.agent.latch); - ADD_LATCH( &CACHE_SparseBuffer.agent.latch); - return &CACHE_SparseBuffer; + ADD_LATCH( &CACHE_SparseBuffer.agent.latch); + return &CACHE_SparseBuffer; } if (findBlkInFileMap(genMsg, stInfo, fileBlk, &poolBlk) != zOK) { @@ -2368,12 +2332,12 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( if (poolBlk == 0) { ASSERT_SLATCH( &CACHE_SparseBuffer.agent.latch); - ADD_LATCH( &CACHE_SparseBuffer.agent.latch); - return &CACHE_SparseBuffer; + ADD_LATCH( &CACHE_SparseBuffer.agent.latch); + return &CACHE_SparseBuffer; } io->volBlk = poolBlk; SET_DEBUG_ID(*io, 20); - return ZFS_ReadPoolBlk(genMsg, io); + return ZFS_ReadPoolBlk(genMsg, io); } else if (fileBlk >= stInfo->nextBlk) { @@ -2384,7 +2348,7 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( if ((io->allocNumBlks > 1) && (io->flags & ALLOC_NUM_BLOCKS_IS_OPTIONAL)) { - beast->bstState |= BST_STATE_TRUNCATE_CLOSE; + beast->bstState |= BST_STATE_TRUNCATE_CLOSE; } xaction = BeginXLocal(beast->vol.volume, BXL_DEFAULT|X_CF_OK_TO_THROTTLE); @@ -2394,8 +2358,8 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( { allocRemain = io->allocNumBlks; tmpBlk = fileBlk; - if (updateSparse(genMsg, xaction, stInfo, fileBlk, &poolBlk, - allocAhead, allocRemain, io->flags) != zOK) + if (updateSparse(genMsg, xaction, stInfo, fileBlk, &poolBlk, + allocAhead, allocRemain, io->flags) != zOK) { COMN_ForceBeastWrite(genMsg, beast, &xaction->xaction); EndXlocal(xaction); @@ -2406,15 +2370,15 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( allocRemain -= (stInfo->nextBlk - tmpBlk); while (allocRemain) { - if ((stInfo->nextBlk > fileBlk) && - (io->flags & (ALLOC_NUM_BLOCKS_IS_OPTIONAL | - ALLOC_BLOCKS_CONTIGUOUS))) + if ((stInfo->nextBlk > fileBlk) && + (io->flags & (ALLOC_NUM_BLOCKS_IS_OPTIONAL | + ALLOC_BLOCKS_CONTIGUOUS))) { break; } tmpBlk = stInfo->nextBlk; - if (extendFileMap(genMsg, xaction, stInfo, &poolBlk, - allocRemain, io->flags) != zOK) + if (extendFileMap(genMsg, xaction, stInfo, &poolBlk, + allocRemain, io->flags) != zOK) { COMN_ForceBeastWrite(genMsg, beast, &xaction->xaction); EndXlocal(xaction); @@ -2425,8 +2389,8 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( if ((io->flags & ALLOC_NO_ZERO_FILL) == 0) { buf = cacheAllocBufferForUserData(&beast->ROOTmycache, - tmpBlk, poolBlk, - ZFS_BlockSignalHandler, STAT_CACHE_ALLOCATE); + tmpBlk, poolBlk, + ZFS_BlockSignalHandler, STAT_CACHE_ALLOCATE); if (buf->pBuf.data == NULL) { buf->pBuf.data = kmap_atomic(buf->b_page, KM_USER0); @@ -2442,13 +2406,13 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( } } } - else + else { while (allocAhead) { tmpBlk = stInfo->nextBlk; - if (extendFileMap(genMsg, xaction, stInfo, &poolBlk, - allocAhead, io->flags) != zOK) + if (extendFileMap(genMsg, xaction, stInfo, &poolBlk, + allocAhead, io->flags) != zOK) { COMN_ForceBeastWrite(genMsg, beast, &xaction->xaction); EndXlocal(xaction); @@ -2459,8 +2423,8 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( if ((io->flags & ALLOC_NO_ZERO_FILL) == 0) { buf = cacheAllocBufferForUserData(&beast->ROOTmycache, - tmpBlk, poolBlk, - ZFS_BlockSignalHandler, STAT_CACHE_ALLOCATE); + tmpBlk, poolBlk, + ZFS_BlockSignalHandler, STAT_CACHE_ALLOCATE); if (buf->pBuf.data == NULL) { buf->pBuf.data = kmap_atomic(buf->b_page, KM_USER0); @@ -2479,8 +2443,8 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( zASSERT(fileBlk == stInfo->nextBlk); tmpBlk = stInfo->nextBlk; allocRemain = io->allocNumBlks; - if (extendFileMap(genMsg, xaction, stInfo, &poolBlk, - allocRemain, io->flags) != zOK) + if (extendFileMap(genMsg, xaction, stInfo, &poolBlk, + allocRemain, io->flags) != zOK) { COMN_ForceBeastWrite(genMsg, beast, &xaction->xaction); EndXlocal(xaction); @@ -2491,15 +2455,15 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( allocRemain -= (stInfo->nextBlk - tmpBlk); while (allocRemain) { - if ((stInfo->nextBlk > fileBlk) && - (io->flags & (ALLOC_NUM_BLOCKS_IS_OPTIONAL | - ALLOC_BLOCKS_CONTIGUOUS))) + if ((stInfo->nextBlk > fileBlk) && + (io->flags & (ALLOC_NUM_BLOCKS_IS_OPTIONAL | + ALLOC_BLOCKS_CONTIGUOUS))) { break; } tmpBlk = stInfo->nextBlk; - if (extendFileMap(genMsg, xaction, stInfo, &poolBlk, - allocRemain, io->flags) != zOK) + if (extendFileMap(genMsg, xaction, stInfo, &poolBlk, + allocRemain, io->flags) != zOK) { COMN_ForceBeastWrite(genMsg, beast, &xaction->xaction); EndXlocal(xaction); @@ -2510,8 +2474,8 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( if ((io->flags & ALLOC_NO_ZERO_FILL) == 0) { buf = cacheAllocBufferForUserData(&beast->ROOTmycache, - tmpBlk, poolBlk, - ZFS_BlockSignalHandler, STAT_CACHE_ALLOCATE); + tmpBlk, poolBlk, + ZFS_BlockSignalHandler, STAT_CACHE_ALLOCATE); if (buf->pBuf.data == NULL) { buf->pBuf.data = kmap_atomic(buf->b_page, KM_USER0); @@ -2537,11 +2501,11 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( if ((io->fileBlk + io->allocNumBlks) != stInfo->nextBlk) { /* This is the case where we have only partially allocated - * the requested contiguous blocks - */ + * the requested contiguous blocks + */ if ((io->flags & ALLOC_NO_ZERO_FILL) == 0) { - buf = cacheAllocBufferForUserData(&beast->ROOTmycache, + buf = cacheAllocBufferForUserData(&beast->ROOTmycache, io->fileBlk, io->volBlk, ZFS_BlockSignalHandler, STAT_CACHE_ALLOCATE); if (buf->pBuf.data == NULL) @@ -2562,10 +2526,10 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( return NULL; } } - buf = cacheAllocBufferForUserData(&beast->ROOTmycache, + buf = cacheAllocBufferForUserData(&beast->ROOTmycache, io->fileBlk, io->volBlk, ZFS_BlockSignalHandler, STAT_CACHE_ALLOCATE); - if ((io->mode != CACHE_WRITE) && + if ((io->mode != CACHE_WRITE) && ((io->flags & ALLOC_NO_ZERO_FILL) == 0)) { if (buf->pBuf.data == NULL) @@ -2595,24 +2559,24 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( { io->volBlk = poolBlk; SET_DEBUG_ID(*io, 21); - return ZFS_ReadPoolBlk(genMsg, io); + return ZFS_ReadPoolBlk(genMsg, io); } else { xaction = BeginXLocal(beast->vol.volume,BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - if (updateSparse(genMsg, xaction, stInfo, fileBlk, &poolBlk, - 0, 1, io->flags) != zOK) - { + if (updateSparse(genMsg, xaction, stInfo, fileBlk, &poolBlk, + 0, 1, io->flags) != zOK) + { COMN_ForceBeastWrite(genMsg, beast, &xaction->xaction); EndXlocal(xaction); return NULL; } io->volBlk = poolBlk; - buf = cacheAllocBufferForUserData(&beast->ROOTmycache, + buf = cacheAllocBufferForUserData(&beast->ROOTmycache, io->fileBlk, io->volBlk, ZFS_BlockSignalHandler, STAT_CACHE_ALLOCATE); - if ((io->mode != CACHE_WRITE) && + if ((io->mode != CACHE_WRITE) && ((io->flags & ALLOC_NO_ZERO_FILL) == 0)) { if (buf->pBuf.data == NULL) @@ -2642,7 +2606,7 @@ Buffer_s *ZFSVOL_VOL_getFileBlk( /************************************************************************* - * Recovery routines + * Recovery routines *************************************************************************/ STATUS redoInitRoot( @@ -2680,8 +2644,8 @@ STATUS redoInitRoot( node->head.leafLink = 0; memcpy(&node->extent[0], &logRecord->u.root.extent[0], - node->head.numRecs * sizeof(FmapExt_s)); - + node->head.numRecs * sizeof(FmapExt_s)); + ZLOG_SET_LSN(logBuffer, node->head.lsn, logBlks[0], pass); CACHE_DIRTY_RELEASE(buffer); } @@ -2740,8 +2704,8 @@ STATUS redoFmapInsert( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && @@ -2768,19 +2732,19 @@ STATUS redoFmapInsert( { node->head.numRecs++; node->extent[index + 1].poolBlk = - logRecord->u.insert.extent.poolBlk; - node->extent[index + 1].count = - logRecord->u.insert.extent.count; + logRecord->u.insert.extent.poolBlk; + node->extent[index + 1].count = + logRecord->u.insert.extent.count; } else if (logRecord->u.insert.numRecs == 2) { node->head.numRecs+=2; node->extent[index + 1].poolBlk = 0; node->extent[index + 1].count = logRecord->u.insert.fileBlk; - node->extent[index + 2].poolBlk = - logRecord->u.insert.extent.poolBlk; + node->extent[index + 2].poolBlk = + logRecord->u.insert.extent.poolBlk; node->extent[index + 2].count = logRecord->u.insert.fileBlk + - logRecord->u.insert.extent.count; + logRecord->u.insert.extent.count; } else @@ -2821,8 +2785,8 @@ STATUS undoFmapInsert( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -2895,8 +2859,8 @@ STATUS redoFmapInsertSparse( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -2913,7 +2877,7 @@ STATUS redoFmapInsertSparse( } else { - origNumRecs = logRecord->u.insertSparse.origNumRecs; + origNumRecs = logRecord->u.insertSparse.origNumRecs; finalNumRecs = logRecord->u.insertSparse.finalNumRecs; index = logRecord->u.insertSparse.index - 1; @@ -2933,10 +2897,10 @@ STATUS redoFmapInsertSparse( { diff = finalNumRecs - origNumRecs; memmove(&node->extent[index + diff], &node->extent[index], - sizeof(FmapExt_s) * (node->head.numRecs - index)); + sizeof(FmapExt_s) * (node->head.numRecs - index)); } memcpy(&node->extent[index], &logRecord->u.insertSparse.finalExt[0], - 3 * sizeof(FmapExt_s)); + 3 * sizeof(FmapExt_s)); node->head.numRecs = finalNumRecs; ZLOG_SET_LSN(logBuffer, node->head.lsn, logBlks[0], pass); CACHE_DIRTY_RELEASE(buffer); @@ -2976,8 +2940,8 @@ STATUS undoFmapInsertSparse( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -2995,21 +2959,21 @@ STATUS undoFmapInsertSparse( } else { - origNumRecs = logRecord->u.insertSparse.origNumRecs; + origNumRecs = logRecord->u.insertSparse.origNumRecs; finalNumRecs = logRecord->u.insertSparse.finalNumRecs; index = logRecord->u.insertSparse.index - 1; - + if (origNumRecs > finalNumRecs) { diff = origNumRecs - finalNumRecs; memmove(&node->extent[index + diff], &node->extent[index], - sizeof(FmapExt_s) * (node->head.numRecs - index)); + sizeof(FmapExt_s) * (node->head.numRecs - index)); } else if (finalNumRecs > origNumRecs) { diff = finalNumRecs - origNumRecs; memmove(&node->extent[index], &node->extent[index + diff], - sizeof(FmapExt_s) * (node->head.numRecs - (index + diff))); + sizeof(FmapExt_s) * (node->head.numRecs - (index + diff))); while(diff) { node->extent[node->head.numRecs - diff].count = 0; @@ -3018,9 +2982,9 @@ STATUS undoFmapInsertSparse( } } memcpy(&node->extent[index], &logRecord->u.insertSparse.origExt[0], - 3 * sizeof(FmapExt_s)); + 3 * sizeof(FmapExt_s)); node->head.numRecs = origNumRecs; - + ZLOG_SET_LSN(logBuffer, node->head.lsn, logBlks[0], pass); CACHE_DIRTY_RELEASE(buffer); } @@ -3056,8 +3020,8 @@ STATUS redoFmapGrow( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -3082,7 +3046,7 @@ STATUS redoFmapGrow( node->head.fnh_internalID = logRecord->u.grow.fg_internalID; node->head.fnh_zid = logRecord->u.grow.fg_zid; ZLOG_SET_LSN(logBuffer, node->head.lsn, logBlks[0], pass); - + CACHE_DIRTY_RELEASE(buffer); } } @@ -3106,7 +3070,7 @@ STATUS redoFmapGrow( node->head.leafLink = INVALID_BLK_ZERO; memcpy(&node->extent[0], &logRecord->u.grow.extent[0], - sizeof(FmapGrow_s)); + sizeof(FmapGrow_s)); ZLOG_SET_LSN(logBuffer, node->head.lsn, logBlks[1], pass); CACHE_DIRTY_RELEASE(buffer); @@ -3140,8 +3104,8 @@ STATUS undoFmapGrow( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -3205,8 +3169,8 @@ STATUS redoFmapSplit( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -3250,10 +3214,10 @@ STATUS redoFmapSplit( } else { - node->head.numRecs = node->head.numRecs - - logRecord->u.split.numRecs + 1; - bzero(&node->extent[node->head.numRecs], - (sizeof(FmapExt_s) * (FMAP_MAX - node->head.numRecs))); + node->head.numRecs = node->head.numRecs - + logRecord->u.split.numRecs + 1; + bzero(&node->extent[node->head.numRecs], + (sizeof(FmapExt_s) * (FMAP_MAX - node->head.numRecs))); } ZLOG_SET_LSN(logBuffer, node->head.lsn, logBlks[0], pass); CACHE_DIRTY_RELEASE(buffer); @@ -3270,8 +3234,8 @@ STATUS redoFmapSplit( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -3290,10 +3254,10 @@ STATUS redoFmapSplit( { memmove(&node->extent[logRecord->u.split.pIndex + 2], &node->extent[logRecord->u.split.pIndex + 1], - sizeof(FmapExt_s) * (node->head.numRecs - + sizeof(FmapExt_s) * (node->head.numRecs - (logRecord->u.split.pIndex + 1))); - memcpy(&node->extent[logRecord->u.split.pIndex], - &logRecord->u.split.parentExt[0], 2 * sizeof(FmapExt_s)); + memcpy(&node->extent[logRecord->u.split.pIndex], + &logRecord->u.split.parentExt[0], 2 * sizeof(FmapExt_s)); node->head.numRecs++; ZLOG_SET_LSN(logBuffer, node->head.lsn, logBlks[1], pass); CACHE_DIRTY_RELEASE(buffer); @@ -3318,7 +3282,7 @@ STATUS redoFmapSplit( node->head.leafLink = logRecord->u.split.sibLink; memcpy(&node->extent[0], &logRecord->u.split.data[0], - logRecord->u.split.numRecs * sizeof(FmapExt_s)); + logRecord->u.split.numRecs * sizeof(FmapExt_s)); node->head.numRecs = logRecord->u.split.numRecs; ZLOG_SET_LSN(logBuffer, node->head.lsn, logBlks[2], pass); @@ -3354,8 +3318,8 @@ STATUS undoFmapSplit( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -3397,11 +3361,11 @@ STATUS undoFmapSplit( else { - memcpy(&node->extent[node->head.numRecs - 1], - &logRecord->u.split.data[0], - sizeof(FmapExt_s) * logRecord->u.split.numRecs); - node->head.numRecs = node->head.numRecs + - logRecord->u.split.numRecs - 1; + memcpy(&node->extent[node->head.numRecs - 1], + &logRecord->u.split.data[0], + sizeof(FmapExt_s) * logRecord->u.split.numRecs); + node->head.numRecs = node->head.numRecs + + logRecord->u.split.numRecs - 1; } ZLOG_SET_LSN(logBuffer, node->head.lsn, logBlks[0], pass); CACHE_DIRTY_RELEASE(buffer); @@ -3419,8 +3383,8 @@ STATUS undoFmapSplit( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -3437,12 +3401,12 @@ STATUS undoFmapSplit( } else { - node->extent[logRecord->u.split.pIndex].count = - node->extent[logRecord->u.split.pIndex + 1].count; + node->extent[logRecord->u.split.pIndex].count = + node->extent[logRecord->u.split.pIndex + 1].count; memmove(&node->extent[logRecord->u.split.pIndex + 1], &node->extent[logRecord->u.split.pIndex + 2], - sizeof(FmapExt_s) * (node->head.numRecs - - (logRecord->u.split.pIndex + 2))); + sizeof(FmapExt_s) * (node->head.numRecs - + (logRecord->u.split.pIndex + 2))); node->head.numRecs--; node->extent[node->head.numRecs].count = 0; node->extent[node->head.numRecs].poolBlk = 0; @@ -3490,8 +3454,8 @@ STATUS redoFmapRemove( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -3508,10 +3472,10 @@ STATUS redoFmapRemove( } else { - node->extent[node->head.numRecs - 1].poolBlk = - logRecord->u.remove.finalExt.poolBlk; - node->extent[node->head.numRecs - 1].count = - logRecord->u.remove.finalExt.count; + node->extent[node->head.numRecs - 1].poolBlk = + logRecord->u.remove.finalExt.poolBlk; + node->extent[node->head.numRecs - 1].count = + logRecord->u.remove.finalExt.count; node->head.numRecs -= logRecord->u.remove.numRecs; ZLOG_SET_LSN(logBuffer, node->head.lsn, logBlks[0], pass); @@ -3547,8 +3511,8 @@ STATUS undoFmapRemove( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -3566,10 +3530,10 @@ STATUS undoFmapRemove( else { node->head.numRecs += logRecord->u.remove.numRecs; - node->extent[node->head.numRecs - 1].poolBlk = - logRecord->u.remove.origExt.poolBlk; - node->extent[node->head.numRecs - 1].count = - logRecord->u.remove.origExt.count; + node->extent[node->head.numRecs - 1].poolBlk = + logRecord->u.remove.origExt.poolBlk; + node->extent[node->head.numRecs - 1].count = + logRecord->u.remove.origExt.count; ZLOG_SET_LSN(logBuffer, node->head.lsn, logBlks[0], pass); CACHE_DIRTY_RELEASE(buffer); @@ -3616,8 +3580,8 @@ STATUS redoFmapJoin( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -3696,8 +3660,8 @@ STATUS undoFmapJoin( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -3714,8 +3678,8 @@ STATUS undoFmapJoin( } else { - memmove(&node->extent[node->head.numRecs - 1], - &logRecord->u.join.parentExt[0], + memmove(&node->extent[node->head.numRecs - 1], + &logRecord->u.join.parentExt[0], 2 * sizeof(FmapExt_s)); node->head.numRecs++; @@ -3754,8 +3718,8 @@ STATUS redoFmapToss( } node = (FmapNode_s *)buffer->pBuf.data; zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -3838,7 +3802,7 @@ STATUS undoFmapToss( } else { /* numrec of non-zero indicates this originally was - * a block delete. */ + * a block delete. */ bzero(buffer->pBuf.data, (1 << buffer->bufSizeShift)); node->head.magic = logRecord->u.toss.magic; @@ -3848,7 +3812,7 @@ STATUS undoFmapToss( node->head.leafLink = INVALID_BLK_ZERO; memcpy(&node->extent[0], &logRecord->u.toss.extent[0], - logRecord->u.toss.numRecs * sizeof(FmapExt_s)); + logRecord->u.toss.numRecs * sizeof(FmapExt_s)); node->head.numRecs = logRecord->u.toss.numRecs; ZLOG_SET_LSN(logBuffer, node->head.lsn, logBlks[0], pass); CACHE_DIRTY_RELEASE(buffer); @@ -3859,7 +3823,7 @@ STATUS undoFmapToss( /************************************************************************* - * Shred Data + * Shred Data *************************************************************************/ BYTE DataShredPatterns[MAX_DATA_SHRED_PATTERNS] = @@ -3882,7 +3846,7 @@ STATUS DataShredInit( { NINT i; BYTE *data; - + if ( patCount > MAX_DATA_SHRED_PATTERNS) { return zFAILURE; @@ -3892,7 +3856,7 @@ STATUS DataShredInit( if (DataShredPatPage[i] == NULL) { MPKNSS_UNLOCK(); - DataShredPatPage[i] = alloc_page(GFP_USER); + DataShredPatPage[i] = alloc_page(GFP_USER); MPKNSS_LOCK(); if (DataShredPatPage[i] == NULL) { @@ -3922,7 +3886,7 @@ void DataShredCleanup() void DataShred( - ZfsVolume_s *zfsVol, + ZfsVolume_s *zfsVol, Extent_s *extent) { zConPool_s *phypool = zfsVol->pool->storagepool->phypool; @@ -4007,8 +3971,8 @@ NINT truncLeafNode( ASSERT_MPKNSS_LOCK(); node = (FmapNode_s *)(buf->pBuf.data); zASSERT((node->head.magic == FMAP_BT_BRANCH) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_ROOT)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_ROOT)); ContinueProcessingLeaf: if (node->head.numRecs <= 1) @@ -4018,15 +3982,15 @@ ContinueProcessingLeaf: { xaction = BeginXLocal(beast->vol.volume,BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(FmapToss_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_TOSS, xaction, logBuffer, 1, - logBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, - node->head.lsn, buf, xaction, 0); + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(FmapToss_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_TOSS, xaction, logBuffer, 1, + logBlks, logRecord); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, + node->head.lsn, buf, xaction, 0); lsn = logBuffer->ZXR_Lsn; - + logRecord->u.toss.extent[0].poolBlk = node->extent[0].poolBlk; logRecord->u.toss.extent[0].count = node->extent[0].count; logRecord->u.toss.numRecs = 1; @@ -4036,7 +4000,7 @@ ContinueProcessingLeaf: logRecord->u.toss.ft_internalID = node->head.fnh_internalID; logRecord->u.toss.ft_zid = node->head.fnh_zid; - ZLOG_DELETE_BLOCK(xaction, logBlks[0]); + ZLOG_DELETE_BLOCK(xaction, logBlks[0]); ZLOG_TEST_REDO(xaction); ZLOG_ReleaseRecord(xaction); @@ -4061,21 +4025,21 @@ ContinueProcessingLeaf: parent = (FmapNode_s *)(parentBuf->pBuf.data); xaction = BeginXLocal(beast->vol.volume,BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2) + - sizeof(FmapJoin_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_JOIN, xaction, logBuffer, 2, - logBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, - node->head.lsn, buf, xaction, 0); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], parentBuf->volBlk, - parent->head.lsn, parentBuf, xaction, 1); - + + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2) + + sizeof(FmapJoin_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_JOIN, xaction, logBuffer, 2, + logBlks, logRecord); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, + node->head.lsn, buf, xaction, 0); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], parentBuf->volBlk, + parent->head.lsn, parentBuf, xaction, 1); + lsn = logBuffer->ZXR_Lsn; - - memcpy(&logRecord->u.join.parentExt[0], - &parent->extent[parent->head.numRecs -2], - 2 * sizeof(FmapExt_s)); + + memcpy(&logRecord->u.join.parentExt[0], + &parent->extent[parent->head.numRecs -2], + 2 * sizeof(FmapExt_s)); logRecord->u.join.childExt.poolBlk = node->extent[0].poolBlk; logRecord->u.join.childExt.count = node->extent[0].count; @@ -4085,8 +4049,8 @@ ContinueProcessingLeaf: zASSERT( node->head.fnh_zid != 0 ); logRecord->u.join.fj_internalID = node->head.fnh_internalID; logRecord->u.join.fj_zid = node->head.fnh_zid; - - ZLOG_DELETE_BLOCK(xaction, logBlks[0]); + + ZLOG_DELETE_BLOCK(xaction, logBlks[0]); ZLOG_BIND(xaction, parentBuf); ZLOG_TEST_REDO(xaction); @@ -4095,15 +4059,15 @@ ContinueProcessingLeaf: node->head.lsn = lsn; parent->head.lsn = lsn; - parent->extent[parent->head.numRecs -1].count = 0; - parent->extent[parent->head.numRecs -1].poolBlk = 0; + parent->extent[parent->head.numRecs -1].count = 0; + parent->extent[parent->head.numRecs -1].poolBlk = 0; parent->head.numRecs--; if (parent->head.numRecs > 1) { poolBlk = parent->extent[parent->head.numRecs -1].poolBlk; parent->extent[parent->head.numRecs -1].count = MAX_FILE_BLK; - parentBuf->state |= CACHE_DIRTY; + parentBuf->state |= CACHE_DIRTY; CACHE_RELEASE(buf); zASSERT(stInfo->fmapTreeBlks > 0); @@ -4121,8 +4085,8 @@ ContinueProcessingLeaf: } node = (FmapNode_s *)(buf->pBuf.data); zASSERT((node->head.magic == FMAP_BT_ROOT) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_BRANCH)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_BRANCH)); if ((node->head.magic != FMAP_BT_BRANCH) && (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_ROOT)) @@ -4158,7 +4122,7 @@ ContinueProcessingLeaf: if (node->extent[node->head.numRecs -1].poolBlk == 0) { /** The last entry is a sparse entry -- remove it and - ** further truncate the file **/ + ** further truncate the file **/ fileBlk = node->extent[node->head.numRecs -2].count; node->extent[node->head.numRecs -1].count = 0; node->head.numRecs--; @@ -4188,27 +4152,27 @@ ContinueProcessingLeaf: if (DATA_SHREDDING_ENABLED(beast->vol.zfsVol) && (poolBlk != 0)) { extent.poolBlkNum = poolBlk; - extent.lengthOfExtent = node->extent[node->head.numRecs -1].count - - node->extent[node->head.numRecs -2].count; + extent.lengthOfExtent = node->extent[node->head.numRecs -1].count - + node->extent[node->head.numRecs -2].count; DataShred(beast->vol.zfsVol, &extent); } xaction = BeginXLocal(beast->vol.volume,BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(FmapRemove_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_REMOVE, xaction, logBuffer, 1, - logBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, - node->head.lsn, buf, xaction, 0); + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(FmapRemove_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_REMOVE, xaction, logBuffer, 1, + logBlks, logRecord); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, + node->head.lsn, buf, xaction, 0); lsn = logBuffer->ZXR_Lsn; - logRecord->u.remove.origExt.poolBlk = - node->extent[node->head.numRecs -1].poolBlk; - logRecord->u.remove.origExt.count = - node->extent[node->head.numRecs -1].count; + logRecord->u.remove.origExt.poolBlk = + node->extent[node->head.numRecs -1].poolBlk; + logRecord->u.remove.origExt.count = + node->extent[node->head.numRecs -1].count; logRecord->u.remove.finalExt.poolBlk = 0; logRecord->u.remove.finalExt.count = 0; logRecord->u.remove.numRecs = 1; @@ -4228,27 +4192,27 @@ ContinueProcessingLeaf: else { extent.poolBlkNum = poolBlk; - extent.lengthOfExtent = node->extent[node->head.numRecs -1].count - - node->extent[node->head.numRecs -2].count; + extent.lengthOfExtent = node->extent[node->head.numRecs -1].count - + node->extent[node->head.numRecs -2].count; node->extent[node->head.numRecs -1].count = 0; node->extent[node->head.numRecs -1].poolBlk = 0; node->head.numRecs--; - zASSERT(stInfo->fmapDataBlks >= extent.lengthOfExtent); + zASSERT(stInfo->fmapDataBlks >= extent.lengthOfExtent); VOL_AdjustUsedUserSpace(&xaction->xaction, beast, -((SQUAD)extent.lengthOfExtent << beast->ROOTblkSizeShift)); - DIRQ_AdjustUsedDirSpace(&xaction->xaction, + DIRQ_AdjustUsedDirSpace(&xaction->xaction, beast->ROOTvolume, beast, -((SQUAD)extent.lengthOfExtent << beast->ROOTblkSizeShift)); stInfo->fmapDataBlks-=extent.lengthOfExtent; stInfo->nextBlk = node->extent[node->head.numRecs -1].count; COMN_MARK_BEAST_XLOCAL(beast, &xaction->xaction); /** FixFixFix6 Free should be done before logging or changing - ** metadata - **/ - if (zfsFreeExtent(genMsg, beast->vol.zfsVol, - &extent, xaction) != zOK) + ** metadata + **/ + if (zfsFreeExtent(genMsg, beast->vol.zfsVol, + &extent, xaction) != zOK) { if (parentBuf) CACHE_RELEASE(parentBuf); node->head.leafLink = INVALID_BLK_ZERO; @@ -4259,7 +4223,7 @@ ContinueProcessingLeaf: return zFAILURE; } } - buf->state |= CACHE_DIRTY; + buf->state |= CACHE_DIRTY; EndXlocal(xaction); if (--periodicReleaseCount <= 0) { @@ -4281,8 +4245,8 @@ ContinueProcessingLeaf: return zFAILURE; } /* I am just releasing and re reading it back it, so not - * checking the magic numbers - */ + * checking the magic numbers + */ } Yield(); READBLK_IO_MSG(iomsg, beast, bufBlk, CACHE_UPDATE); @@ -4309,33 +4273,33 @@ ContinueProcessingLeaf: else { poolBlk = node->extent[node->head.numRecs -1].poolBlk + - (fileBlk - node->extent[node->head.numRecs -2].count); + (fileBlk - node->extent[node->head.numRecs -2].count); } if (DATA_SHREDDING_ENABLED(beast->vol.zfsVol) && (poolBlk != 0)) { extent.poolBlkNum = poolBlk; - extent.lengthOfExtent = - node->extent[node->head.numRecs -1].count - fileBlk; + extent.lengthOfExtent = + node->extent[node->head.numRecs -1].count - fileBlk; DataShred(beast->vol.zfsVol, &extent); } xaction = BeginXLocal(beast->vol.volume,BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(FmapRemove_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_REMOVE, xaction, logBuffer, 1, - logBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, - node->head.lsn, buf, xaction, 0); + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(FmapRemove_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_REMOVE, xaction, logBuffer, 1, + logBlks, logRecord); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, + node->head.lsn, buf, xaction, 0); lsn = logBuffer->ZXR_Lsn; - logRecord->u.remove.origExt.poolBlk = - node->extent[node->head.numRecs -1].poolBlk; - logRecord->u.remove.origExt.count = - node->extent[node->head.numRecs -1].count; + logRecord->u.remove.origExt.poolBlk = + node->extent[node->head.numRecs -1].poolBlk; + logRecord->u.remove.origExt.count = + node->extent[node->head.numRecs -1].count; if (poolBlk == 0) { logRecord->u.remove.finalExt.poolBlk = 0; @@ -4344,8 +4308,8 @@ ContinueProcessingLeaf: } else { - logRecord->u.remove.finalExt.poolBlk = - node->extent[node->head.numRecs -1].poolBlk; + logRecord->u.remove.finalExt.poolBlk = + node->extent[node->head.numRecs -1].poolBlk; logRecord->u.remove.finalExt.count = fileBlk; logRecord->u.remove.numRecs = 0; } @@ -4365,24 +4329,24 @@ ContinueProcessingLeaf: else { extent.poolBlkNum = poolBlk; - extent.lengthOfExtent = - node->extent[node->head.numRecs -1].count - fileBlk; + extent.lengthOfExtent = + node->extent[node->head.numRecs -1].count - fileBlk; node->extent[node->head.numRecs -1].count = fileBlk; - zASSERT(stInfo->fmapDataBlks >= extent.lengthOfExtent); + zASSERT(stInfo->fmapDataBlks >= extent.lengthOfExtent); VOL_AdjustUsedUserSpace(&xaction->xaction, beast, -((SQUAD)extent.lengthOfExtent << beast->ROOTblkSizeShift)); - DIRQ_AdjustUsedDirSpace(&xaction->xaction, + DIRQ_AdjustUsedDirSpace(&xaction->xaction, beast->ROOTvolume, beast, -((SQUAD)extent.lengthOfExtent << beast->ROOTblkSizeShift)); stInfo->fmapDataBlks-=extent.lengthOfExtent; stInfo->nextBlk = node->extent[node->head.numRecs -1].count; COMN_MARK_BEAST_XLOCAL(beast, &xaction->xaction); /** FixFixFix6 Free should be done before logging or changing - ** metadata - **/ - if (zfsFreeExtent(genMsg, beast->vol.zfsVol, - &extent, xaction) != zOK) + ** metadata + **/ + if (zfsFreeExtent(genMsg, beast->vol.zfsVol, + &extent, xaction) != zOK) { if (parentBuf) CACHE_RELEASE(parentBuf); node->head.leafLink = INVALID_BLK_ZERO; @@ -4393,7 +4357,7 @@ ContinueProcessingLeaf: return TRUNC_ERROR; } } - buf->state |= CACHE_DIRTY; + buf->state |= CACHE_DIRTY; EndXlocal(xaction); goto ContinueProcessingLeaf; } @@ -4425,12 +4389,12 @@ NINT truncBranchNodeChild( ContinueDownTheTree: node = (FmapNode_s *)(buf->pBuf.data); zASSERT((node->head.magic == FMAP_BT_ROOT) || - (node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_BRANCH)); + (node->head.magic == FMAP_BT_LEAF) || + (node->head.magic == FMAP_BT_BRANCH)); parent = (FmapNode_s *)(parentBuf->pBuf.data); zASSERT((parent->head.magic == FMAP_BT_ROOT) || - (parent->head.magic == FMAP_BT_LEAF) || - (parent->head.magic == FMAP_BT_BRANCH)); + (parent->head.magic == FMAP_BT_LEAF) || + (parent->head.magic == FMAP_BT_BRANCH)); if (node->head.state & BT_LEAF) { @@ -4467,21 +4431,21 @@ ContinueDownTheTree: else { xaction = BeginXLocal(beast->vol.volume,BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2) + - sizeof(FmapJoin_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_JOIN, xaction, logBuffer, 2, - logBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, - node->head.lsn, buf, xaction, 0); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], parentBuf->volBlk, - parent->head.lsn, parentBuf, xaction, 1); - + + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(2) + + sizeof(FmapJoin_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_JOIN, xaction, logBuffer, 2, + logBlks, logRecord); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, + node->head.lsn, buf, xaction, 0); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], parentBuf->volBlk, + parent->head.lsn, parentBuf, xaction, 1); + lsn = logBuffer->ZXR_Lsn; - memcpy(&logRecord->u.join.parentExt[0], - &parent->extent[parent->head.numRecs -2], - 2 * sizeof(FmapExt_s)); + memcpy(&logRecord->u.join.parentExt[0], + &parent->extent[parent->head.numRecs -2], + 2 * sizeof(FmapExt_s)); logRecord->u.join.childExt.poolBlk = node->extent[0].poolBlk; logRecord->u.join.childExt.count = node->extent[0].count; @@ -4491,7 +4455,7 @@ ContinueDownTheTree: zASSERT( node->head.fnh_zid != 0 ); logRecord->u.join.fj_internalID = node->head.fnh_internalID; logRecord->u.join.fj_zid = node->head.fnh_zid; - + ZLOG_DELETE_BLOCK(xaction, logBlks[0]); ZLOG_BIND(xaction, parentBuf); @@ -4501,15 +4465,15 @@ ContinueDownTheTree: node->head.lsn = lsn; parent->head.lsn = lsn; - parent->extent[parent->head.numRecs -1].count = 0; - parent->extent[parent->head.numRecs -1].poolBlk = 0; + parent->extent[parent->head.numRecs -1].count = 0; + parent->extent[parent->head.numRecs -1].poolBlk = 0; parent->head.numRecs--; if (parent->head.numRecs > 1) - { + { poolBlk = parent->extent[parent->head.numRecs -1].poolBlk; parent->extent[parent->head.numRecs -1].count = MAX_FILE_BLK; - parentBuf->state |= CACHE_DIRTY; + parentBuf->state |= CACHE_DIRTY; CACHE_RELEASE(buf); zASSERT(stInfo->fmapTreeBlks > 0); @@ -4581,7 +4545,7 @@ STATUS btreeFileMapTrunc( Lsn_t lsn; ASSERT_MPKNSS_LOCK(); - + ContinueTraversingTheTree: zASSERT(node->head.magic == FMAP_BT_ROOT); zASSERT(node->head.state & BT_ROOT); @@ -4626,15 +4590,15 @@ ContinueTraversingTheTree: /** this is the end .. All my leaves are gone **/ xaction = BeginXLocal(beast->vol.volume,BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(FmapToss_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_TOSS, xaction, logBuffer, 1, - logBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, - node->head.lsn, buf, xaction, 0); - + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(FmapToss_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_TOSS, xaction, logBuffer, 1, + logBlks, logRecord); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, + node->head.lsn, buf, xaction, 0); + lsn = logBuffer->ZXR_Lsn; - + logRecord->u.toss.extent[0].poolBlk = node->extent[0].poolBlk; logRecord->u.toss.extent[0].count = node->extent[0].count; logRecord->u.toss.numRecs = 1; @@ -4643,7 +4607,7 @@ ContinueTraversingTheTree: zASSERT( node->head.fnh_zid != 0 ); logRecord->u.toss.ft_internalID = node->head.fnh_internalID; logRecord->u.toss.ft_zid = node->head.fnh_zid; - + ZLOG_DELETE_BLOCK(xaction, logBlks[0]); ZLOG_TEST_REDO(xaction); ZLOG_ReleaseRecord(xaction); @@ -4658,7 +4622,7 @@ ContinueTraversingTheTree: COMN_MARK_BEAST_XLOCAL(beast, &xaction->xaction); if (COMN_ForceBeastWrite(genMsg, beast, &xaction->xaction) != zOK) { - if (parentBuf) + if (parentBuf) { CACHE_RELEASE(parentBuf); } @@ -4667,21 +4631,21 @@ ContinueTraversingTheTree: } EndXlocal(xaction); } - else if (node->head.numRecs == 2) + else if (node->head.numRecs == 2) { /** Root Blk has only 1 entry (other one is std first entry), so we - ** can shrink the B-tree **/ + ** can shrink the B-tree **/ xaction = BeginXLocal(beast->vol.volume,BXL_DEFAULT|X_CF_OK_TO_THROTTLE); - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(FmapToss_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_TOSS, xaction, logBuffer, 1, - logBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, - node->head.lsn, buf, xaction, 0); - + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(FmapToss_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_TOSS, xaction, logBuffer, 1, + logBlks, logRecord); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, + node->head.lsn, buf, xaction, 0); + lsn = logBuffer->ZXR_Lsn; - + logRecord->u.toss.extent[0].poolBlk = node->extent[0].poolBlk; logRecord->u.toss.extent[0].count = node->extent[0].count; logRecord->u.toss.extent[1].poolBlk = node->extent[1].poolBlk; @@ -4692,7 +4656,7 @@ ContinueTraversingTheTree: zASSERT( node->head.fnh_zid != 0 ); logRecord->u.toss.ft_internalID = node->head.fnh_internalID; logRecord->u.toss.ft_zid = node->head.fnh_zid; - + ZLOG_DELETE_BLOCK(xaction, logBlks[0]); ZLOG_TEST_REDO(xaction); ZLOG_ReleaseRecord(xaction); @@ -4730,25 +4694,25 @@ ContinueTraversingTheTree: return zFAILURE; } - ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + - sizeof(FmapToss_s)); - ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_TOSS, xaction, logBuffer, 1, - logBlks, logRecord); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, - node->head.lsn, buf, xaction, 0); - + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(1) + + sizeof(FmapToss_s)); + ZLOG_INIT_LOG_RECORD(XFUNC_FMAP_TOSS, xaction, logBuffer, 1, + logBlks, logRecord); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], buf->volBlk, + node->head.lsn, buf, xaction, 0); + lsn = logBuffer->ZXR_Lsn; - + logRecord->u.toss.numRecs = 0; logRecord->u.toss.magic = node->head.magic; logRecord->u.toss.state = node->head.state; zASSERT( node->head.fnh_zid != 0 ); logRecord->u.toss.ft_internalID = node->head.fnh_internalID; logRecord->u.toss.ft_zid = node->head.fnh_zid; - + ZLOG_TEST_REDO(xaction); ZLOG_BIND(xaction, buf); - + ZLOG_ReleaseRecord(xaction); node->head.lsn = lsn; @@ -4757,7 +4721,7 @@ ContinueTraversingTheTree: // hold the old MAGIC/type of // this node. - buf->state |= CACHE_DIRTY; + buf->state |= CACHE_DIRTY; EndXlocal(xaction); goto ContinueTraversingTheTree; } @@ -4775,7 +4739,7 @@ ContinueTraversingTheTree: } node = (FmapNode_s *)buf->pBuf.data; if ((node->head.magic != FMAP_BT_ROOT) && - (node->head.magic != FMAP_BT_LEAF) && + (node->head.magic != FMAP_BT_LEAF) && (node->head.magic != FMAP_BT_BRANCH)) { CACHE_RELEASE(parentBuf); @@ -4851,7 +4815,7 @@ STATUS directFileMapTrunc( { extent.poolBlkNum = fmap->dirExt[numRecs - 1].poolBlk; extent.lengthOfExtent = fmap->dirExt[numRecs -1].count - - fmap->dirExt[numRecs -2].count; + fmap->dirExt[numRecs -2].count; } else { @@ -4874,12 +4838,12 @@ STATUS directFileMapTrunc( { extent.poolBlkNum = fmap->dirExt[fmap->numRecs - 1].poolBlk; extent.lengthOfExtent = fmap->dirExt[fmap->numRecs -1].count - - fmap->dirExt[fmap->numRecs -2].count; - + fmap->dirExt[fmap->numRecs -2].count; + zASSERT(stInfo->fmapDataBlks >= extent.lengthOfExtent); length = extent.lengthOfExtent; - if (zfsFreeExtent(genMsg, beast->vol.zfsVol, - &extent, xaction) != zOK) + if (zfsFreeExtent(genMsg, beast->vol.zfsVol, + &extent, xaction) != zOK) { status = zFAILURE; break; @@ -4895,11 +4859,11 @@ STATUS directFileMapTrunc( (fileBlk - fmap->dirExt[fmap->numRecs -2].count); extent.lengthOfExtent = fmap->dirExt[fmap->numRecs -1].count - fileBlk; - + zASSERT(stInfo->fmapDataBlks >= extent.lengthOfExtent); length = extent.lengthOfExtent; - if (zfsFreeExtent(genMsg, beast->vol.zfsVol, - &extent, xaction) != zOK) + if (zfsFreeExtent(genMsg, beast->vol.zfsVol, + &extent, xaction) != zOK) { status = zFAILURE; break; @@ -5003,19 +4967,19 @@ STATUS ZFSVOL_VOL_truncateFile ( (beast->ROOTvolume->VOLenabledAttributes & zATTR_COW)) { /* If snapshotting is enabled on the volume and the file is being - * truncated, we just copy the filemap to the snapshot beast if - * the file is being truncated to zero. Else, the high level routine - * will copy individual blocks to the snapshot beast, before truncating - * the original file - */ + * truncated, we just copy the filemap to the snapshot beast if + * the file is being truncated to zero. Else, the high level routine + * will copy individual blocks to the snapshot beast, before truncating + * the original file + */ if (fileBlk == 0) { /* - * Adjust used space now because the truncated blocks are being - * moved over to the snapshot beast, not actually being released. - * To keep the users/directory used block counts correct they - * should be decremented now. - */ + * Adjust used space now because the truncated blocks are being + * moved over to the snapshot beast, not actually being released. + * To keep the users/directory used block counts correct they + * should be decremented now. + */ xaction = BeginXLocal(beast->vol.volume,BXL_DEFAULT|X_CF_OK_TO_THROTTLE); VOL_AdjustUsedUserSpace(&xaction->xaction, beast, -((SQUAD)stInfo->fmapDataBlks << beast->ROOTblkSizeShift)); @@ -5037,7 +5001,7 @@ STATUS ZFSVOL_VOL_truncateFile ( /** the fileBlk to be truncated is beyond EOF **/ /** Should this be an error? -- I don't think so -- Vandana **/ return zOK; - } + } if ((fmap->numRecs <= 1) && (fmap->root == INVALID_BLK_ZERO)) { @@ -5089,7 +5053,7 @@ STATUS ZFSVOL_VOL_truncateFile ( * for every hole in the file. For allocated extents, the entries are * positive numbers indicating how many blocks are in the extent. For * holes, the entries are negative numbers, the complement of which - * indicates how many blocks make up the hole. + * indicates how many blocks make up the hole. ***************************************************************************/ STATUS ZFSVOL_VOL_getExtentList( GeneralMsg_s *genMsg, @@ -5135,7 +5099,7 @@ STATUS ZFSVOL_VOL_getExtentList( *retNumExtents = 1; fileBlkInDirectMap = TRUE; } - if (fmap->root != 0) + if (fmap->root != 0) { READBLK_IO_MSG(iomsg, beast, fmap->root, CACHE_READ); SET_DEBUG_ID(iomsg, 32); @@ -5153,7 +5117,7 @@ STATUS ZFSVOL_VOL_getExtentList( buf = NULL; return zFAILURE; } - while (!(node->head.state & BT_LEAF)) + while (!(node->head.state & BT_LEAF)) { poolBlk = searchBranch(node, fileBlk, &index); CACHE_RELEASE(buf); @@ -5177,17 +5141,17 @@ STATUS ZFSVOL_VOL_getExtentList( } } poolBlk = searchLeaf(node, fileBlk, &retLen, &index); - /** If the first extent is in the filemap and is a hole, - ** the direct map will not have added an entry and we need to - ** do this extra check here, before we go into the for loop. - **/ + /** If the first extent is in the filemap and is a hole, + ** the direct map will not have added an entry and we need to + ** do this extra check here, before we go into the for loop. + **/ if (!fileBlkInDirectMap) - { + { /* Need to handle starting in the middle of an extent that - * has not been handle in direct map code. - */ + * has not been handle in direct map code. + */ if (poolBlk == 0) - { + { /* Hole code */ (*extentList)[i] = -(node->extent[index].count - fileBlk); if (++i == extentListSize) @@ -5199,7 +5163,7 @@ STATUS ZFSVOL_VOL_getExtentList( (*extentList)[i] = 0; } else - { + { /* Non-hole code */ (*extentList)[i] += (node->extent[index].count - fileBlk); } @@ -5211,19 +5175,19 @@ STATUS ZFSVOL_VOL_getExtentList( { if (node->extent[index].poolBlk != 0) { - (*extentList)[i] += (node->extent[index].count - - node->extent[index-1].count); + (*extentList)[i] += (node->extent[index].count - + node->extent[index-1].count); } else { - if (++i == extentListSize) + if (++i == extentListSize) { *retNextBlock = node->extent[index-1].count; *retNumExtents = i; goto returnValues; } - (*extentList)[i] = -(node->extent[index].count - - node->extent[index-1].count); + (*extentList)[i] = -(node->extent[index].count - + node->extent[index-1].count); if (++i == extentListSize) { *retNextBlock = node->extent[index].count; @@ -5235,7 +5199,7 @@ STATUS ZFSVOL_VOL_getExtentList( } LB_delay(0); poolBlk = node->head.leafLink; - if ((poolBlk == INVALID_BLK_ZERO) || + if ((poolBlk == INVALID_BLK_ZERO) || (node->extent[node->head.numRecs -1].count >= stInfo->nextBlk)) { *retNextBlock = stInfo->nextBlk; @@ -5270,14 +5234,14 @@ returnValues: } /* - * Convert a pool extent to a device number and physical extent. - */ + * Convert a pool extent to a device number and physical extent. + */ STATUS pool2physicalExtent ( zNSSMsg_s *msg, RootBeast_s *beast, Extent_s *extent) { - zPhysicalExtent_s *physical = (zPhysicalExtent_s *)(uintptr_t)msg->sys.data[MAP_DATA].start; + zPhysicalExtent_s *physical = msg->sys.data[MAP_DATA].start; NINT maxExtents; NINT numExtents; STATUS status; @@ -5300,9 +5264,9 @@ STATUS pool2physicalExtent ( poolByteLength = ((QUAD)(LONG)extent->lengthOfExtent) << beast->blkSizeShift; if (poolByteOffset == 0) { /* - * Hole in file, we just skip passed it and don't change the number - * of extents we are returning. - */ + * Hole in file, we just skip passed it and don't change the number + * of extents we are returning. + */ msg->body.map.retEndingOffset = poolByteLength + fileByteOffset; return zOK; } @@ -5345,8 +5309,8 @@ STATUS pool2physicalExtent ( } /* - * ZFSVOL_doDirectPhysicalExtents - handles the direct physical extents - */ + * ZFSVOL_doDirectPhysicalExtents - handles the direct physical extents + */ STATUS ZFSVOL_doDirectPhysicalExtents ( zNSSMsg_s *msg, RootBeast_s *beast) @@ -5363,18 +5327,18 @@ STATUS ZFSVOL_doDirectPhysicalExtents ( ASSERT_SLATCH( &beast->ROOTbeastLatch); /* - * retEndingOffset was initialized to the passed in offset. - */ + * retEndingOffset was initialized to the passed in offset. + */ fileBlk = msg->body.map.retEndingOffset >> beast->blkSizeShift; for (i = 1; i < fmap->numRecs; ++i) { /* - * This if lets us skip forward to the correct offset - * in file map. - */ + * This if lets us skip forward to the correct offset + * in file map. + */ if (fileBlk < fmap->dirExt[i].count) { extent.poolBlkNum = fmap->dirExt[i].poolBlk; - extent.lengthOfExtent = fmap->dirExt[i].count - + extent.lengthOfExtent = fmap->dirExt[i].count - fmap->dirExt[i-1].count; if (fileBlk > fmap->dirExt[i-1].count) { @@ -5393,9 +5357,9 @@ STATUS ZFSVOL_doDirectPhysicalExtents ( } /* - * Given a file block number in the beast, descend the - * file map tree and find the extent mapping information. - */ + * Given a file block number in the beast, descend the + * file map tree and find the extent mapping information. + */ Buffer_s *descendFileMapTree (RootBeast_s *beast, Blknum_t fileBlk) { ZFSStorageInfo_s *stInfo = beast->storage.zfsInfo; @@ -5408,7 +5372,7 @@ Buffer_s *descendFileMapTree (RootBeast_s *beast, Blknum_t fileBlk) NINT index; COMN_SETUP_GENERAL_MSG_NO_CONNECTION_RESOLVE( &genMsg); - for (poolBlk = fmap->root; poolBlk != 0;) + for (poolBlk = fmap->root; poolBlk != 0;) { READBLK_IO_MSG(iomsg, beast, poolBlk, CACHE_READ); SET_DEBUG_ID(iomsg, 36); @@ -5429,8 +5393,8 @@ Buffer_s *descendFileMapTree (RootBeast_s *beast, Blknum_t fileBlk) } STATUS scanFileMapLeaf ( - zNSSMsg_s *msg, - RootBeast_s *beast, + zNSSMsg_s *msg, + RootBeast_s *beast, FmapNode_s *node) { Blknum_t fileBlk; @@ -5445,16 +5409,16 @@ STATUS scanFileMapLeaf ( fileBlk = msg->body.map.retEndingOffset >> beast->blkSizeShift; /* - * Find the first extent that contains the file block. - */ - extent.poolBlkNum = searchLeaf(node, fileBlk, &extent.lengthOfExtent, - &index); + * Find the first extent that contains the file block. + */ + extent.poolBlkNum = searchLeaf(node, fileBlk, &extent.lengthOfExtent, + &index); for (i = index; i < numRecs; ++i) { if (i != index) { extent.poolBlkNum = node->extent[i].poolBlk; - extent.lengthOfExtent = node->extent[i].count - + extent.lengthOfExtent = node->extent[i].count - node->extent[i-1].count; } status = pool2physicalExtent(msg, beast, &extent); @@ -5467,9 +5431,9 @@ STATUS scanFileMapLeaf ( } /* - * ZFSVOL_doTreePhysicalExtents - handles physical extents in the - * file map tree. - */ + * ZFSVOL_doTreePhysicalExtents - handles physical extents in the + * file map tree. + */ STATUS ZFSVOL_doTreePhysicalExtents ( zNSSMsg_s *msg, RootBeast_s *beast) @@ -5538,8 +5502,8 @@ STATUS ZFSVOL_VOL_getPhysicalExtent ( ASSERT_SLATCH( &beast->ROOTbeastLatch); /* - * Initialize the return values. They are updated in pool2physicalExtent - */ + * Initialize the return values. They are updated in pool2physicalExtent + */ msg->body.map.retEndingOffset = msg->body.map.offset; msg->body.map.retExtentListCount = 0; @@ -5583,8 +5547,8 @@ finish: *****************************************************************************/ Blknum_t ZFS_fileBlk2volBlk ( - RootBeast_s *beast, - Blknum_t fileBlk, + RootBeast_s *beast, + Blknum_t fileBlk, NINT *length) { GeneralMsg_s genMsg; @@ -5594,7 +5558,7 @@ Blknum_t ZFS_fileBlk2volBlk ( Blknum_t poolBlk; Blknum_t retLen = 0; Blknum_t seed = 0; - NINT index = 0; + NINT index = 0; FmapNode_s *node; IoMsg_s iomsg; @@ -5615,9 +5579,9 @@ Blknum_t ZFS_fileBlk2volBlk ( } else if (fmap->root) { - READBLK_IO_MSG(iomsg, beast, fmap->root, CACHE_READ); + READBLK_IO_MSG(iomsg, beast, fmap->root, CACHE_READ); SET_DEBUG_ID(iomsg, 0); - buf = ZFS_ReadPoolBlk(&genMsg, &iomsg); + buf = ZFS_ReadPoolBlk(&genMsg, &iomsg); if (buf == NULL) { poolBlk = 0; @@ -5634,14 +5598,14 @@ Blknum_t ZFS_fileBlk2volBlk ( goto returnStatus; } - while (!(node->head.state & BT_LEAF)) + while (!(node->head.state & BT_LEAF)) { poolBlk = searchBranch(node, fileBlk, &index); CACHE_RELEASE(buf); buf = NULL; - READBLK_IO_MSG(iomsg, beast, poolBlk, CACHE_READ); + READBLK_IO_MSG(iomsg, beast, poolBlk, CACHE_READ); SET_DEBUG_ID(iomsg, 0); - buf = ZFS_ReadPoolBlk(&genMsg, &iomsg); + buf = ZFS_ReadPoolBlk(&genMsg, &iomsg); if (buf == NULL) { poolBlk = 0; @@ -5685,7 +5649,7 @@ BOOL ZFSVOL_VOL_isBlockInBeast( { NINT len = 1; ASSERT_MPKNSS_LOCK(); - + if ((fileBlk << beast->ROOTmycache.bufSizeShift) < beast->ROOTeof) { return (ZFS_fileBlk2volBlk(beast, fileBlk, &len) != 0); @@ -5694,7 +5658,7 @@ BOOL ZFSVOL_VOL_isBlockInBeast( { return FALSE; } -} +} /*************************************************************************** * Read Ahead Pool Blocks. @@ -5712,7 +5676,7 @@ void asyncReadAheadPoolBlkDone(Fsm_s *fsm) ASSERT_MPKNSS_LOCK(); if (asyncio->buffer) - CACHE_RELEASE(asyncio->buffer); + CACHE_RELEASE(asyncio->buffer); COMN_UnlatchAndRelease(&beast, SLATCHED); @@ -5725,8 +5689,8 @@ void asyncContinueReadAheadPoolBlk(FsmLite_s *fsmLite) Asyncio_s *aio = STRUCT(fsmLite,Asyncio_s,fsm.lite); ASSERT_MPKNSS_LOCK(); - asyncReadVolBlk(aio, (voidfunc_t)asyncReadAheadPoolBlkDone); - + asyncReadVolBlk(aio, asyncReadAheadPoolBlkDone); + } /** Initialize IoMsg_s using READBLK_IO_MSG before calling this routine **/ @@ -5748,8 +5712,8 @@ void ZFS_ReadAheadPoolBlk( /*- (FUNCTION) ----- ZFS_appendFileMap() --------------------------------------- | - | do not allow this api to be exposed to the public. this api is used - | internal to zlss only and does not have logging, transactions, latching, + | do not allow this api to be exposed to the public. this api is used + | internal to zlss only and does not have logging, transactions, latching, | etc. | IPU uses this to fill in the file map before the NSS volume is real | and before any external access. @@ -5758,7 +5722,7 @@ void ZFS_ReadAheadPoolBlk( STATUS ipuUpdateSparseLeaf( GeneralMsg_s *genMsg, - RootBeast_s *beast, + RootBeast_s *beast, Extent_s *extent, Blknum_t fileBlk, Blknum_t holeBlkCnt, @@ -5782,12 +5746,12 @@ STATUS ipuUpdateSparseLeaf( node->extent[node->head.numRecs].poolBlk = 0; node->head.numRecs++; - node->extent[node->head.numRecs].count = - fileBlk + extent->lengthOfExtent; + node->extent[node->head.numRecs].count = + fileBlk + extent->lengthOfExtent; node->extent[node->head.numRecs].poolBlk = extent->poolBlkNum; node->head.numRecs++; - if (bufParent) + if (bufParent) { CACHE_RELEASE(bufParent); } @@ -5813,8 +5777,8 @@ STATUS ipuUpdateSparseLeaf( CACHE_RELEASE(buf); localExt.poolBlkNum = bufSibling->volBlk; localExt.lengthOfExtent = 1; - zfsFreeExtent(genMsg, beast->vol.zfsVol, - &localExt, NULL); + zfsFreeExtent(genMsg, beast->vol.zfsVol, + &localExt, NULL); cacheReleaseToss(bufSibling); return zFAILURE; @@ -5826,8 +5790,8 @@ STATUS ipuUpdateSparseLeaf( zASSERT(bufParent != NULL); stInfo->fmapTreeBlks++; - splitBtreeLeafSparse(NULL, buf, bufSibling, bufParent, index, - pIndex, extent, (NINT)holeBlkCnt, fileBlk); + splitBtreeLeafSparse(NULL, buf, bufSibling, bufParent, index, + pIndex, extent, (NINT)holeBlkCnt, fileBlk); CACHE_DIRTY_RELEASE(buf); buf = NULL; @@ -5849,8 +5813,8 @@ STATUS ipuUpdateSparse( { ZFSStorageInfo_s *stInfo; Fmap_s *fmap; - Buffer_s *buf = NULL; - Buffer_s *bufParent = NULL; + Buffer_s *buf = NULL; + Buffer_s *bufParent = NULL; Buffer_s *bufSibling = NULL; FmapNode_s *node; IoMsg_s iomsg; @@ -5863,7 +5827,7 @@ STATUS ipuUpdateSparse( if (fmap->root == INVALID_BLK_ZERO) { /* Making file sparse the first time, filemap is still direct, - * continuing entries will be in the btree */ + * continuing entries will be in the btree */ XALLOCBLK_IO_MSG(iomsg, beast, NULL, CACHE_UPDATE); if ((buf = ZFS_AllocPoolBlk(genMsg, &iomsg)) == NULL) @@ -5924,8 +5888,8 @@ STATUS ipuUpdateSparse( CACHE_RELEASE(buf); localExt.poolBlkNum = bufSibling->volBlk; localExt.lengthOfExtent = 1; - zfsFreeExtent(genMsg, beast->vol.zfsVol, - &localExt, NULL); + zfsFreeExtent(genMsg, beast->vol.zfsVol, + &localExt, NULL); cacheReleaseToss(bufSibling); return zFAILURE; } @@ -5936,9 +5900,9 @@ STATUS ipuUpdateSparse( zASSERT(bufParent != NULL); stInfo->fmapTreeBlks++; - syncSplitBtree(NULL, buf, bufSibling, bufParent, extent); + syncSplitBtree(NULL, buf, bufSibling, bufParent, extent); - CACHE_DIRTY_RELEASE(buf); + CACHE_DIRTY_RELEASE(buf); CACHE_DIRTY_RELEASE(bufParent); bufParent = NULL; @@ -5949,7 +5913,7 @@ STATUS ipuUpdateSparse( READBLK_IO_MSG(iomsg, beast, poolBlk, CACHE_UPDATE); if ((buf = ZFS_ReadPoolBlk(genMsg, &iomsg)) == NULL) { - if (bufParent) + if (bufParent) { CACHE_RELEASE(bufParent); } @@ -5957,10 +5921,10 @@ STATUS ipuUpdateSparse( } node = (FmapNode_s *)buf->pBuf.data; zASSERT((node->head.magic == FMAP_BT_LEAF) || - (node->head.magic == FMAP_BT_BRANCH)); + (node->head.magic == FMAP_BT_BRANCH)); } - if (ipuUpdateSparseLeaf(genMsg, beast, extent, fileBlk, + if (ipuUpdateSparseLeaf(genMsg, beast, extent, fileBlk, holeBlkCnt, buf, bufParent) != zOK) { return zFAILURE; @@ -5992,11 +5956,11 @@ ContinueScanningTheBtree: READBLK_IO_MSG(iomsg, beast, poolBlk, CACHE_UPDATE); if ((bufChild = ZFS_ReadPoolBlk(genMsg, &iomsg)) == NULL) { - if (bufParent) + if (bufParent) { CACHE_RELEASE(bufParent); } - if (bufSibling) + if (bufSibling) { CACHE_RELEASE(bufSibling); } @@ -6010,8 +5974,8 @@ ContinueScanningTheBtree: if (child->head.state & BT_LEAF) { if ((child->extent[child->head.numRecs -1].poolBlk + - child->extent[child->head.numRecs -1].count - - child->extent[child->head.numRecs -2].count) == extent->poolBlkNum) + child->extent[child->head.numRecs -1].count - + child->extent[child->head.numRecs -2].count) == extent->poolBlkNum) { child->extent[child->head.numRecs -1].count+=extent->lengthOfExtent; } @@ -6041,12 +6005,12 @@ ContinueScanningTheBtree: localExt.poolBlkNum = bufSibling->volBlk; localExt.lengthOfExtent = 1; zfsFreeExtent(genMsg, beast->vol.zfsVol, - &localExt, NULL); + &localExt, NULL); cacheReleaseToss(bufSibling); return zFAILURE; - } + } stInfo->fmapTreeBlks++; syncGrowBtree(NULL, bufChild, bufParent, &tmp, beast); fmap->root = bufParent->volBlk; @@ -6061,7 +6025,7 @@ ContinueScanningTheBtree: poolBlk = child->extent[child->head.numRecs-1].poolBlk; if (child->head.numRecs < (FMAP_MAX - 6)) { - if (bufParent) + if (bufParent) { CACHE_DIRTY_RELEASE(bufParent); bufParent = NULL; @@ -6089,12 +6053,12 @@ ContinueScanningTheBtree: localExt.poolBlkNum = bufSibling->volBlk; localExt.lengthOfExtent = 1; zfsFreeExtent(genMsg, beast->vol.zfsVol, - &localExt, NULL); + &localExt, NULL); cacheReleaseToss(bufSibling); return zFAILURE; - } + } stInfo->fmapTreeBlks++; - syncGrowBtree(NULL, bufChild, bufParent, &tmp, beast); + syncGrowBtree(NULL, bufChild, bufParent, &tmp, beast); fmap->root = bufParent->volBlk; } zASSERT(bufParent != NULL); @@ -6102,7 +6066,7 @@ ContinueScanningTheBtree: stInfo->fmapTreeBlks++; syncSplitBtree(NULL, bufChild, bufSibling, bufParent, extent); - CACHE_DIRTY_RELEASE(bufChild); + CACHE_DIRTY_RELEASE(bufChild); bufChild = NULL; CACHE_DIRTY_RELEASE(bufParent); bufParent = NULL; @@ -6113,7 +6077,7 @@ ContinueScanningTheBtree: goto ContinueScanningTheBtree; } CACHE_DIRTY_RELEASE(bufChild); - if (bufParent) + if (bufParent) { CACHE_DIRTY_RELEASE(bufParent); } @@ -6149,9 +6113,9 @@ STATUS ipuUpdateDirectFileMap ( fmap->dirExt[fmap->numRecs].poolBlk = poolBlk; fmap->numRecs++; } - else if ((fmap->dirExt[fmap->numRecs -1].poolBlk - - fmap->dirExt[fmap->numRecs -2].count + - fmap->dirExt[fmap->numRecs -1].count) == poolBlk) + else if ((fmap->dirExt[fmap->numRecs -1].poolBlk - + fmap->dirExt[fmap->numRecs -2].count + + fmap->dirExt[fmap->numRecs -1].count) == poolBlk) { fmap->dirExt[fmap->numRecs - 1].count += length; } @@ -6175,20 +6139,20 @@ STATUS ipuUpdateDirectFileMap ( node = (FmapNode_s *)(buffer->pBuf.data); - node->head.magic = FMAP_BT_ROOT; - node->head.fnh_internalID = beast->ROOTinternalID; - node->head.fnh_zid = beast->zid; - node->head.state = BT_ROOT | BT_LEAF; - node->head.numRecs = 0; - node->head.leafLink = 0; - node->head.lsn = 0; + node->head.magic = FMAP_BT_ROOT; + node->head.fnh_internalID = beast->ROOTinternalID; + node->head.fnh_zid = beast->zid; + node->head.state = BT_ROOT | BT_LEAF; + node->head.numRecs = 0; + node->head.leafLink = 0; + node->head.lsn = 0; - node->extent[node->head.numRecs].count = + node->extent[node->head.numRecs].count = fmap->dirExt[fmap->numRecs - 1].count; - node->extent[node->head.numRecs].poolBlk = + node->extent[node->head.numRecs].poolBlk = fmap->dirExt[fmap->numRecs -1].poolBlk; - node->head.numRecs++; - + node->head.numRecs++; + node->extent[node->head.numRecs].count = fmap->dirExt[fmap->numRecs - 1].count + length; node->extent[node->head.numRecs].poolBlk = poolBlk; @@ -6197,7 +6161,7 @@ STATUS ipuUpdateDirectFileMap ( CACHE_DIRTY_RELEASE(buffer); } return zOK; -} +} /***************************************************************************** @@ -6207,9 +6171,9 @@ STATUS ipuUpdateDirectFileMap ( ** This routine does NOT: 1) check for latching ** 2) do transactions ** 3) do logging - ** + ** ** The beast is marked dirty when we are done. It does not change the - ** logical eof. + ** logical eof. ** ** The only error cases that exist in this routine is if there is an error ** allocating and getting a buffer for a meta block to extend the filemap, @@ -6226,12 +6190,12 @@ STATUS ipuUpdateDirectFileMap ( STATUS ZFS_appendFileMap( GeneralMsg_s *genMsg, - RootBeast_s *beast, + RootBeast_s *beast, Blknum_t holeBlkCnt, Extent_s *extent) { ZFSStorageInfo_s *stInfo; - Fmap_s *fmap; + Fmap_s *fmap; Blknum_t fileBlk; stInfo = beast->storage.zfsInfo; @@ -6271,3 +6235,5 @@ STATUS ZFS_appendFileMap( BST_MarkDirty(beast); return(zOK); } + + diff --git a/src/nwnss/zlss/zfsFileMap.h b/src/nwnss/zlss/zfsFileMap.h index ae7784f..f8e8993 100644 --- a/src/nwnss/zlss/zfsFileMap.h +++ b/src/nwnss/zlss/zfsFileMap.h @@ -59,15 +59,15 @@ typedef struct FmapNodeHead_s { - LONG magic; - WORD state; - WORD numRecs; - Lsn_t lsn; - GUID_t fnh_internalID; /* Must be at OFFSET 16 - unique internal ID (used - * by scanning repair). fnh stands for Fmap Node Head. - */ - Zid_t fnh_zid; /* ZID of beast that this FMAP is part of */ - Blknum_t leafLink; + LONG magic; + WORD state; + WORD numRecs; + Lsn_t lsn; + GUID_t fnh_internalID; /* Must be at OFFSET 16 - unique internal ID (used + * by scanning repair). fnh stands for Fmap Node Head. + */ + Zid_t fnh_zid; /* ZID of beast that this FMAP is part of */ + Blknum_t leafLink; } NSS_MEDIA_STRUCTURE(FmapNodeHead_s,leafLink) FmapNodeHead_s; #define FMAP_MAX (PAGE_SIZE - sizeof(FmapNodeHead_s)) / sizeof(FmapExt_s) @@ -78,8 +78,8 @@ typedef struct FmapNodeHead_s typedef struct FmapNode_s { - FmapNodeHead_s head; - FmapExt_s extent[FMAP_MAX]; + FmapNodeHead_s head; + FmapExt_s extent[FMAP_MAX]; } NSS_MEDIA_STRUCTURE(FmapNode_s,extent[FMAP_MAX]) FmapNode_s; #define TRUNC_DONE 0 @@ -88,97 +88,98 @@ typedef struct FmapNode_s typedef struct FmapRoot_s { - GUID_t fr_internalID; - Zid_t fr_zid; - WORD numRecs; - FmapExt_s extent[2]; + GUID_t fr_internalID; + Zid_t fr_zid; + WORD numRecs; + FmapExt_s extent[2]; } NSS_MEDIA_STRUCTURE(FmapRoot_s,extent[2]) FmapRoot_s; -typedef struct FmapInsert_s +typedef struct FmapInsert_s { - Blknum_t fileBlk; - WORD numRecs; - FmapExt_s extent; + Blknum_t fileBlk; + WORD numRecs; + FmapExt_s extent; } NSS_MEDIA_STRUCTURE(FmapInsert_s,extent.poolBlk) FmapInsert_s; -typedef struct FmapInsertSparse_s +typedef struct FmapInsertSparse_s { - FmapExt_s origExt[3]; - FmapExt_s finalExt[3]; - WORD origNumRecs; - WORD finalNumRecs; - LONG index; + FmapExt_s origExt[3]; + FmapExt_s finalExt[3]; + WORD origNumRecs; + WORD finalNumRecs; + LONG index; } NSS_MEDIA_STRUCTURE(FmapInsertSparse_s,index) FmapInsertSparse_s; typedef struct FmapGrow_s { - GUID_t fg_internalID; - Zid_t fg_zid; - FmapExt_s extent[2]; + GUID_t fg_internalID; + Zid_t fg_zid; + FmapExt_s extent[2]; } NSS_MEDIA_STRUCTURE(FmapGrow_s,extent[2].count) FmapGrow_s; typedef struct FmapSplit_s { - GUID_t fs_internalID; - Zid_t fs_zid; - FmapExt_s parentExt[2]; - LONG pIndex; - Blknum_t childLink; - Blknum_t sibLink; - LONG childMagic; - WORD childState; - WORD numRecs; - BYTE data[1]; + GUID_t fs_internalID; + Zid_t fs_zid; + FmapExt_s parentExt[2]; + LONG pIndex; + Blknum_t childLink; + Blknum_t sibLink; + LONG childMagic; + WORD childState; + WORD numRecs; + BYTE data[1]; } NSS_MEDIA_STRUCTURE(FmapSplit_s,data[1]) FmapSplit_s; -typedef struct FmapRemove_s +typedef struct FmapRemove_s { - FmapExt_s origExt; - FmapExt_s finalExt; - WORD numRecs; + FmapExt_s origExt; + FmapExt_s finalExt; + WORD numRecs; } NSS_MEDIA_STRUCTURE(FmapRemove_s,numRecs) FmapRemove_s; -typedef struct FmapJoin_s +typedef struct FmapJoin_s { - GUID_t fj_internalID; - Zid_t fj_zid; - FmapExt_s parentExt[2]; - FmapExt_s childExt; - LONG childMagic; - WORD childState; - WORD childNumRecs; + GUID_t fj_internalID; + Zid_t fj_zid; + FmapExt_s parentExt[2]; + FmapExt_s childExt; + LONG childMagic; + WORD childState; + WORD childNumRecs; } NSS_MEDIA_STRUCTURE(FmapJoin_s,childNumRecs) FmapJoin_s; -typedef struct FmapToss_s +typedef struct FmapToss_s { - GUID_t ft_internalID; - Zid_t ft_zid; - FmapExt_s extent[2]; - LONG magic; - WORD state; - WORD numRecs; + GUID_t ft_internalID; + Zid_t ft_zid; + FmapExt_s extent[2]; + LONG magic; + WORD state; + WORD numRecs; } NSS_MEDIA_STRUCTURE(FmapToss_s,numRecs) FmapToss_s; -typedef struct FmapLog_s +typedef struct FmapLog_s { - union - { - FmapRoot_s root; - FmapInsert_s insert; - FmapInsertSparse_s insertSparse; - FmapGrow_s grow; - FmapSplit_s split; - FmapRemove_s remove; - FmapJoin_s join; - FmapToss_s toss; - } NSS_MEDIA_UNION(NamelessUnion,join.childNumRecs) u; + union + { + FmapRoot_s root; + FmapInsert_s insert; + FmapInsertSparse_s insertSparse; + FmapGrow_s grow; + FmapSplit_s split; + FmapRemove_s remove; + FmapJoin_s join; + FmapToss_s toss; + } NSS_MEDIA_UNION(NamelessUnion,join.childNumRecs) u; } NSS_MEDIA_STRUCTURE(FmapLog_s,u.join.childNumRecs) FmapLog_s; /*- this is for IPU only and was not exposed in zfs.h -*/ extern STATUS ZFS_appendFileMap( - GeneralMsg_s *genMsg, - RootBeast_s *beast, - Blknum_t holeBlkCnt, - Extent_s *extent); + GeneralMsg_s *genMsg, + RootBeast_s *beast, + Blknum_t holeBlkCnt, + Extent_s *extent); #endif /* _ZFSFILEMAP_H_ */ + diff --git a/src/nwnss/zlss/zfsPool.c b/src/nwnss/zlss/zfsPool.c index 8ad40ee..7225dde 100644 --- a/src/nwnss/zlss/zfsPool.c +++ b/src/nwnss/zlss/zfsPool.c @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** | | (C) Copyright 1995 - 2001 Novell, Inc. | All Rights Reserved. @@ -82,71 +82,38 @@ #include "hardLinkBeast.h" #include "dir.h" /* For ZFSNAMETREE_smap_cursor_cleanup used in DIR_SCTRL_CLEANUP */ -/* Legacy NSS callback tables use statusfunc_t/voidfunc_t with old-style - * prototypes. Keep the imported ZLSS signatures intact and cast only at - * the COMN callback boundary. - */ -typedef STATUS (*zfspool_change_volume_state_func_t)( - GeneralMsg_s *genMsg, - void *volume, - NINT sourceState, - NINT requestedState, - NINT mode, - NINT pass); -typedef STATUS (*zfspool_modify_info_func_t)( - GeneralMsg_s *genMsg, - void *beast, - ModifyInfoMsg_s *modifyMsg, - Xaction_s *xaction); -typedef STATUS (*zfspool_flush_system_beasts_func_t)( - GeneralMsg_s *genMsg, - void *volume); -typedef STATUS (*zfspool_command_func_t)( - GeneralMsg_s *genMsg, - void *beast, - NINT functionNumber, - VCO_VolumeCommonOps_s *pCD, - NINT parmLen, - utf8_t *parm, - NINT dataLen, - BYTE *commandData, - NINT offset, - NINT retBufLen, - BYTE *retBuf, - NINT *retLen); - /* Generally, we only track ACTIVE state I/O because in MAINTENANCE - * state we use the pool beast for most I/O. This will make us - * think we did a lot of PDB I/Os. In addition, we do not track - * in DEACTIVE because the tracking will not be persistent because - * we do not take checkpoints. By having multiple flags we can check - * if we are doing I/O when we have told the clustering software - * we will not. - */ -BOOL gCLPoolTrackActive = TRUE; + * state we use the pool beast for most I/O. This will make us + * think we did a lot of PDB I/Os. In addition, we do not track + * in DEACTIVE because the tracking will not be persistent because + * we do not take checkpoints. By having multiple flags we can check + * if we are doing I/O when we have told the clustering software + * we will not. + */ +BOOL gCLPoolTrackActive = TRUE; BOOL gCLPoolTrackMaintenance = FALSE; BOOL gCLPoolTrackDeactive = FALSE; /** The link list of all LVs that are being deleted or purged. Must - ** be empty when all pools are deactive. I.E. if the pool an - ** LV is on is not ACTIVE then we do NOT have any information - ** about the LV in this list. - **/ + ** be empty when all pools are deactive. I.E. if the pool an + ** LV is on is not ACTIVE then we do NOT have any information + ** about the LV in this list. + **/ ZLSSLVDeleteList_s ZLSSLVDeleteList; -Time_t ZLSSStartUpTime; /* UpTime when ZLSS started. */ +Time_t ZLSSStartUpTime; /* UpTime when ZLSS started. */ /*** Set to TRUE when detailed ZLSS I/O information is needed */ PoolWriteStatistics_s gZLSSPWS; /* Holds Global ZLSS Write Statisitics */ PoolReadStatistics_s gZLSSPRS; /* Holds Global ZLSS Read Statisitics */ -LONG gZLSSIOStartUpTime; /* UpTime when global stats set to - * zero. Currently this is when ZLSS - * starts up. In the future, we may - * allow the counters to be reset so - * this time would reflect that time. - */ +LONG gZLSSIOStartUpTime; /* UpTime when global stats set to + * zero. Currently this is when ZLSS + * starts up. In the future, we may + * allow the counters to be reset so + * this time would reflect that time. + */ #if ZLSS_IO_GATHER IS_ENABLED @@ -171,10 +138,10 @@ extern unicode_t gZCL_OnlyPoolName[]; /* Name of POOL to load */ FsmLite_s gZLSSUserBlocksWorkToDoFsm; #endif -extern NINT EnterExitEventID; +NINT EnterExitEventID = 0; /************************************************************************** - * + * ***************************************************************************/ STATUS ZFSPOOL_Startup( GeneralMsg_s *genMsg) @@ -208,8 +175,8 @@ STATUS ZFSPOOL_Startup( free(gZLSSPoolIOLog); gZLSSPoolIOLog = NULL; } else { - LB_bzero( gZLSSPoolIOHeader, sizeof(*gZLSSPoolIOHeader) ); - LB_bzero( gZLSSPoolIOLog, gZLSSPoolIOLogSize ); + LB_bzero( gZLSSPoolIOHeader, sizeof(*gZLSSPoolIOHeader) ); + LB_bzero( gZLSSPoolIOLog, gZLSSPoolIOLogSize ); } #endif #if 0 @@ -266,9 +233,9 @@ void ZFSPOOL_ShutdownPool( ZfsPool_s *poolVolume ) return; } /* Set unload bit so we can catch multiple unloads AND - * the so the common layer will prevent change volume - * states to higher states. - */ + * the so the common layer will prevent change volume + * states to higher states. + */ zlssPool->ZLSSPOOLpool.v_statusFlag |= VOL_SF_UNLOADING; COMN_GetPoolName(&dummyGenMsg, &zlssPool->ZLSSPOOLpool, aStack->pName,NELEMS(aStack->pName)); @@ -276,14 +243,14 @@ void ZFSPOOL_ShutdownPool( ZfsPool_s *poolVolume ) (poolVolume->ZFSPOOLvol.state != zVOLSTATE_UNKNOWN)) { #ifdef USER_GPACHNER - aprintf(YELLOW, WHERE ); + aprintf(YELLOW, WHERE ); #endif aprintf(YELLOW,MSG("Deactivating pool \"%U\"...\n",884),aStack->pName); } /* - * Go through the link list of LVs that this pool - * owns and shut them down first. - */ + * Go through the link list of LVs that this pool + * owns and shut them down first. + */ // printk("<1>start shutdownpool %s\n",WHERE); for (;;) { @@ -307,7 +274,7 @@ void ZFSPOOL_ShutdownPool( ZfsPool_s *poolVolume ) //// * that we are deactivating it. //// */ //// COMN_GetVolumeName(&dummyGenMsg, volume, vName, NELEMS(vName)); -// status = COMN_ChangeVolumeState(&dummyGenMsg, volume, +// status = COMN_ChangeVolumeState(&dummyGenMsg, volume, // zVOLSTATE_UNKNOWN, VOLMODE_VERBOSE ); // zASSERT(status == zOK); // WORK_WaitForPending(); /* before freeing the poolVolume structure, wait @@ -317,8 +284,8 @@ void ZFSPOOL_ShutdownPool( ZfsPool_s *poolVolume ) // BST_releaseAndFree(volume); } /* This will deactivate the ZLSS Pool and its physical volume */ - status = COMN_ChangePoolState(&dummyGenMsg, &zlssPool->ZLSSPOOLpool, - zVOLSTATE_UNKNOWN, 0 /*VOLMODE_VERBOSE*/); + status = COMN_ChangePoolState(&dummyGenMsg, &zlssPool->ZLSSPOOLpool, + zVOLSTATE_UNKNOWN, 0 /*VOLMODE_VERBOSE*/); if ( status != zOK ) { // printk("<1>start shutdownpool %s\n",WHERE); @@ -331,10 +298,10 @@ void ZFSPOOL_ShutdownPool( ZfsPool_s *poolVolume ) // printk("<1>start shutdownpool %s\n",WHERE); /* By removing from the master volume link list we prevent - * this volume from being found. This prevents any new - * operations from starting which is a requirement since - * we will be freeing the volume. - */ + * this volume from being found. This prevents any new + * operations from starting which is a requirement since + * we will be freeing the volume. + */ COMN_RemoveVolumeFromAllLists( &poolVolume->ZFSPOOLvol ); /* Defect 270987 - Remove the ZlssPool_s from the master pool list. We do not want the pool found just because a use @@ -343,31 +310,31 @@ void ZFSPOOL_ShutdownPool( ZfsPool_s *poolVolume ) // printk("<1>start shutdownpool %s\n",WHERE); WORK_WaitForPending(); /* before freeing the poolVolume structure, wait - * for all pending WORK to complete. This - * gives a chance for all outstanding - * operations and transactions to complete.*/ + * for all pending WORK to complete. This + * gives a chance for all outstanding + * operations and transactions to complete.*/ // printk("<1>start shutdownpool %s\n",WHERE); zASSERT( poolVolume->storagepool != NULL ); /* This can happen if loadpool - * fails really early on */ + * fails really early on */ if ( poolVolume->storagepool != NULL ) { /* Added this to clean up. Mike's stuff has a pointer - * to us (no use count though). During LV AIPU I re-load - * amd unload the zfsPool_s several times and would get - * confussed when looking at freed memory. E.G. in low level - * I/O disable code we have storagepool and if points to - * a zfsPool we use to see if I/O has been disabled. - */ + * to us (no use count though). During LV AIPU I re-load + * amd unload the zfsPool_s several times and would get + * confussed when looking at freed memory. E.G. in low level + * I/O disable code we have storagepool and if points to + * a zfsPool we use to see if I/O has been disabled. + */ if ( poolVolume->storagepool->zfspool == poolVolume ) { /* Only poke if it still points to us. */ poolVolume->storagepool->zfspool = NULL; } } /* These are releasing the use counts obtained at 'load' time. - * We have these useCounts so that we control when the - * pool is freed. The beasts will be freed when their - * useCounts get to 0. - */ + * We have these useCounts so that we control when the + * pool is freed. The beasts will be freed when their + * useCounts get to 0. + */ // printk("<1>start shutdownpool %s\n",WHERE); COMN_Release(&poolVolume); // printk("<1>start shutdownpool %s\n",WHERE); @@ -401,8 +368,8 @@ void ZFSPOOL_Shutdown(void) COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); ZLSS_UpgradeShutdownNakoma(); /* Do Manage_NSS cleanup up front because _Admin may be a - * persistent ZLSS volume. - */ + * persistent ZLSS volume. + */ status = ZLSS_VFCDelete( &genMsg ); if ( status != zOK ) { @@ -430,7 +397,7 @@ void ZFSPOOL_Shutdown(void) UNX_LATCH( &ZLSSLVDeleteList.ZDL_beastLatch ); LB_delay( ZLOG_WORK_CHECKPOINT_WAIT_DELAY ); /* 20 millisecs */ X_LATCH( &ZLSSLVDeleteList.ZDL_beastLatch ); - + #if NSS_ASSERT IS_ENABLED ++count; /* Not in ASSERT macro just in case of side-effects */ #endif @@ -464,7 +431,7 @@ void ZFSPOOL_Shutdown(void) *=========================================================================*/ /************************************************************************** - * ZFS pool beast constructor + * ZFS pool beast constructor ***************************************************************************/ STATUS ZFSPOOL_BST_Construct( GeneralMsg_s *genMsg, @@ -476,27 +443,27 @@ STATUS ZFSPOOL_BST_Construct( ASSERT_MPKNSS_LOCK(); /* Assert that packed beast portion of checkpoint is on QUAD boundary */ - zASSERT( offsetof(Checkpoint_s,CP_PackedData) == - ALIGN( offsetof( Checkpoint_s, CP_PackedData ), 8 ) ); + zASSERT( offsetof(Checkpoint_s,CP_PackedData) == + ALIGN( offsetof( Checkpoint_s, CP_PackedData ), 8 ) ); /* Assert that superblock header is on LONG boundary. Checksum code requires this. */ - zASSERT( sizeof( SuperBlockHeader_s ) == + zASSERT( sizeof( SuperBlockHeader_s ) == ALIGN( sizeof( SuperBlockHeader_s ) , 4 ) ); /*--------------------------------------------------------------------------- | Start initing the pool *-------------------------------------------------------------------------*/ /* Technically, this is incorrect as it is initialing the ZLSS Volume - * and therefore should be done in the ZLSS Volume constructor. This - * can not be done there because that constructor does not know the pool. - * In LV code the ZLSS Pool's volume is not NEWed until after the pool. - */ + * and therefore should be done in the ZLSS Volume constructor. This + * can not be done there because that constructor does not know the pool. + * In LV code the ZLSS Pool's volume is not NEWed until after the pool. + */ pool->ZFSPOOLpool = pool; /* Mark this as a special internal volume. This hides it from the user. - * At the same time, unmark it as a logical volume. We also mark - * hidden and system in NSS_Admin volume so a normal dir does not - * reveal the volume. - */ + * At the same time, unmark it as a logical volume. We also mark + * hidden and system in NSS_Admin volume so a normal dir does not + * reveal the volume. + */ pool->ZFSPOOLvol.VOLv_statusFlag |= VOL_SF_INTERNAL_VOLUME; pool->ZFSPOOLvol.VOLv_statusFlag &= ~VOL_SF_LOGICAL_VOLUME; pool->ZFSPOOLfile.FILEattributes = zFA_SYSTEM|zFA_HIDDEN; @@ -513,14 +480,14 @@ void ZFSPOOL_BST_Destruct( void *pool_LX ) { ZfsPool_s *pool = (ZfsPool_s *)pool_LX; - + ENTER(TZPOOL, ZFSPOOL_Destruct); ASSERT_MPKNSS_LOCK(); /* Note that normally deactivate will have taken care of the - * 4 releaseAndFree() and the free call. This code is here - * just in case we could not deactivate. - */ + * 4 releaseAndFree() and the free call. This code is here + * just in case we could not deactivate. + */ BST_releaseAndFree(pool->freeExtent); BST_releaseAndFree(pool->purgeLogBeast); BST_releaseAndFree(pool->purgeTree); @@ -529,7 +496,7 @@ void ZFSPOOL_BST_Destruct( free(pool->ZP_super); pool->ZP_super = NULL; RTN_VOID(); -} +} /**************************************************************************** * This function modifies metadata information for a POOL beast object @@ -543,7 +510,7 @@ STATUS ZFSPOOL_BST_ModifyInfo( { ZfsPool_s *pool = (ZfsPool_s *)pool_LX; zVolumeInfo_s *volInfo; - zfspool_modify_info_func_t derivedFromModifyInfo; + statusfunc_t derivedFromModifyInfo; NINT modified = FALSE; @@ -551,12 +518,11 @@ STATUS ZFSPOOL_BST_ModifyInfo( zASSERT(!(pool->ZFSPOOLenabledAttributes & zATTR_READONLY)); /*--------------------------------------------------------------------------- - * First, call the generic file information routine and modify any + * First, call the generic file information routine and modify any * requested generic information. If it fails, do not continue... *---------------------------------------------------------------------------*/ - derivedFromModifyInfo = (zfspool_modify_info_func_t)COMN_GetNextParentBeastComnOp(pool->ZFSPOOLbeastClass, - COMNOPS_INDEX(BST_modifyInfo), - (statusfunc_t)ZFSPOOL_BST_ModifyInfo); + derivedFromModifyInfo = COMN_GetNextParentBeastComnOp(pool->ZFSPOOLbeastClass, + COMNOPS_INDEX(BST_modifyInfo),ZFSPOOL_BST_ModifyInfo); if (derivedFromModifyInfo(genMsg,pool,modifyMsg,xaction) != zOK) { return(zFAILURE); @@ -608,7 +574,7 @@ STATUS ZFSPOOL_BST_ModifyInfo( else { /* Even if not changing high water mark, force it to be at least - * 2% greater than low water mark */ + * 2% greater than low water mark */ if (pool->ZFSPOOLhighWaterMark < pool->ZFSPOOLlowWaterMark+2) { pool->ZFSPOOLhighWaterMark = pool->ZFSPOOLlowWaterMark+2; @@ -618,8 +584,8 @@ STATUS ZFSPOOL_BST_ModifyInfo( } if ( modified ) { /* This is an async call that does not do transactions - * so no warrenty that persistent information is updated. - */ + * so no warrenty that persistent information is updated. + */ ZFSVOL_WritePersistentVolumeData(&pool->ZFSPOOLzfsvol); } } @@ -725,8 +691,8 @@ STATUS ZFSPOOL_LoadSystemBeasts( { errPrintf(WHERE, Module, 1418, MSG("Error reading beast tree block %d, status=%d.\n" - "Check the status, you may need to run Rebuild.", 119), - blk, GetErrno(genMsg)); + "Check the status, you may need to run Rebuild.", 119), + blk, GetErrno(genMsg)); } // cacheReleaseToss(buffer); RTN_STATUS(zFAILURE); @@ -803,10 +769,10 @@ STATUS ZFSPOOL_LoadSystemBeasts( version = pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor * 0x100L + pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor; /* FixFixFix(LV,ACI,11) - should the pool's volume - * purge log be created here? then could remove - * for LV AIPU and not have to worry if someone - * needs the purge log before it is created. - */ + * purge log be created here? then could remove + * for LV AIPU and not have to worry if someone + * needs the purge log before it is created. + */ if ( version >= (AIPU_LV_MEDIA_MAJOR*0x100L+AIPU_LV_STEP_PVPL_DONE) ) { /* Media still may not have Volume Purge Log */ errPrintf(WHERE, Module, 1422, @@ -835,9 +801,9 @@ STATUS ZFSPOOL_LoadSystemBeasts( if (SuperBeasts[i].zid == ZFSVOL_DIRTREE_ZID) { NINT version; - version = pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor + version = pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor * 0x100L + pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor; - zASSERT(version < + zASSERT(version < (AIPU_LV_MEDIA_MAJOR*0x100L+AIPU_LV_STEP_4_DONE)); } } @@ -851,10 +817,10 @@ STATUS ZFSPOOL_LoadSystemBeasts( /* we do not want these special system beasts to be in the POOL linked list */ DQ_RMV(beast,volLink); /* - * If we have just loaded up the purge log then go through its setup - * so that entries can be added in later phases of activation, - * before it has a chance to be played. - */ + * If we have just loaded up the purge log then go through its setup + * so that entries can be added in later phases of activation, + * before it has a chance to be played. + */ if ((SuperBeasts[i].zid == ZFSVOL_PURGELOG_ZID) || (SuperBeasts[i].zid == ZFSPOOL_PURGELOG_ZID)) { @@ -867,12 +833,12 @@ STATUS ZFSPOOL_LoadSystemBeasts( /* Set up quick pointer to ZLOG Beast (needed to do XACTIONS) */ pool->ZFSPOOLzfsvolzlog = pool->zfsLogBeast; - /* All upgrades that do transactioning should be done after the - * XactionRecoverLogicalUndo call in ZFSPOOL_Activate - */ + /* All upgrades that do transactioning should be done after the + * XactionRecoverLogicalUndo call in ZFSPOOL_Activate + */ RTN_STATUS(zOK); -} +} /**************************************************************************** * This is called to dirty all of the Beasts from the SuperBlock. This @@ -906,7 +872,7 @@ void ZFSPOOL_DirtySystemBeasts( } } return; -} +} /************************************************************************ @@ -946,7 +912,7 @@ STATUS ZFSPOOL_ActivateAllLVsQuasi( ClearErrno(genMsg); bzero( &aStack->smap, sizeof( SearchMap_s ) ); - directory = (NamedBeast_s *)ZFSVOL_VOL_GetBeastFromVolume(genMsg, + directory = (NamedBeast_s *)ZFSVOL_VOL_GetBeastFromVolume(genMsg, zROOTDIR_ZID, ZFS_POOL_TO_VOLUME(pool)); if (directory == NULL) { @@ -961,8 +927,8 @@ STATUS ZFSPOOL_ActivateAllLVsQuasi( S_LATCH(&directory->NAMEDbeastLatch); - dirZid = ZFSVOL_VOL_LookupByNameInDirectory(genMsg, directory, - nameSpace, zNTYPE_FILE, ZLSSVOL_DIRECTORY_UNICODE, + dirZid = ZFSVOL_VOL_LookupByNameInDirectory(genMsg, directory, + nameSpace, zNTYPE_FILE, ZLSSVOL_DIRECTORY_UNICODE, /* zFNU_FIRST_PARENT, &nameUniquifier,*/ NULL); UNS_LATCH(&directory->NAMEDbeastLatch); @@ -973,7 +939,7 @@ STATUS ZFSPOOL_ActivateAllLVsQuasi( } BST_free(directory); - directory = (NamedBeast_s *)ZFSVOL_VOL_GetBeastFromVolume(genMsg, + directory = (NamedBeast_s *)ZFSVOL_VOL_GetBeastFromVolume(genMsg, dirZid, ZFS_POOL_TO_VOLUME(pool)); if (directory == NULL) { @@ -984,16 +950,16 @@ STATUS ZFSPOOL_ActivateAllLVsQuasi( /* If we stop calling ZFSVOL_VOL_WildcardLookup() before getting an error WE must clean up the smap! This means we need to call - DIR_SCTRL_CLEANUP(smap); + DIR_SCTRL_CLEANUP(smap); so that the SMAP is removed from any lists that it is on. */ - while (1) + while (1) { S_LATCH(&directory->NAMEDbeastLatch); cleanupSMAP = TRUE; - zvlZid = ZFSVOL_VOL_WildcardLookup(genMsg, directory, nameSpace, - zNTYPE_FILE, NULL, &aStack->smap, /* cnt &nameUniquifier,*/ NULL); + zvlZid = ZFSVOL_VOL_WildcardLookup(genMsg, directory, nameSpace, + zNTYPE_FILE, NULL, &aStack->smap, /* cnt &nameUniquifier,*/ NULL); UNS_LATCH(&directory->NAMEDbeastLatch); @@ -1011,14 +977,14 @@ STATUS ZFSPOOL_ActivateAllLVsQuasi( } } - zvlBeast = (ZlssVolumeLocator_s *)ZFSVOL_VOL_GetBeastFromVolume(genMsg, + zvlBeast = (ZlssVolumeLocator_s *)ZFSVOL_VOL_GetBeastFromVolume(genMsg, zvlZid, ZFS_POOL_TO_VOLUME(pool)); - if (zvlBeast == NULL) + if (zvlBeast == NULL) { if (GetErrno(genMsg) == zERR_ZID_NOT_FOUND) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(RED, MSGNot("Error finding logicalVolumeBeast in the beast Tree. Error = %ld (%s) \n"), GetErrno(genMsg), GetErrnoSetter(genMsg)); + DBG_DebugPrintf(RED, MSGNot("Error finding logicalVolumeBeast in the beast Tree. Error = %ld (%s) \n"), GetErrno(genMsg), GetErrnoSetter(genMsg)); zASSERT("Logical Volume not found during Quasi Activation." == NULL); #endif ClearErrno(genMsg); @@ -1031,11 +997,11 @@ STATUS ZFSPOOL_ActivateAllLVsQuasi( } #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(CYAN, - MSGNot("LV %U with state %d and substate %d found\n"), + DBG_DebugPrintf(CYAN, + MSGNot("LV %U with state %d and substate %d found\n"), zvlBeast->ZVL_p.PZVL_volumeName, - zvlBeast->ZVL_p.PZVL_state, - zvlBeast->ZVL_p.PZVL_subState); + zvlBeast->ZVL_p.PZVL_state, + zvlBeast->ZVL_p.PZVL_subState); #endif switch (zvlBeast->ZVL_p.PZVL_state) { @@ -1045,20 +1011,20 @@ STATUS ZFSPOOL_ActivateAllLVsQuasi( break; } /* If the subState is less than or equal to the above substate - * we want to fall into the code below - */ + * we want to fall into the code below + */ case PZVL_S_CREATED: - + zASSERT((zvlBeast->ZVL_p.PZVL_state == PZVL_S_CREATED) || - (zvlBeast->ZVL_p.PZVL_state == PZVL_S_DELETION)); - + (zvlBeast->ZVL_p.PZVL_state == PZVL_S_DELETION)); + #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(CYAN, - MSGNot("Quasi activation of LV %U. \n"), + DBG_DebugPrintf(CYAN, + MSGNot("Quasi activation of LV %U. \n"), zvlBeast->ZVL_p.PZVL_volumeName); #endif zVolume = ZLSSVOL_NewFakeLVBeast(genMsg, zvlBeast, pool, - zvlBeast->ZVL_p.PZVL_volumeName); + zvlBeast->ZVL_p.PZVL_volumeName); if (zVolume == NULL) { goto cleanup_error; @@ -1080,8 +1046,8 @@ STATUS ZFSPOOL_ActivateAllLVsQuasi( goto cleanup_error; } - /* System Beasts have a pointer to the volume and put a - * use Count on the volume */ + /* System Beasts have a pointer to the volume and put a + * use Count on the volume */ zASSERT( zVolume->ZFSVOLfile.FILEuseCount >= 2 ); --(zVolume->ZFSVOLfile.FILEuseCount); zVolume = NULL; @@ -1091,9 +1057,9 @@ STATUS ZFSPOOL_ActivateAllLVsQuasi( case PZVL_S_CREATION: case PZVL_S_CREATION_DELETE: /* This volume has not been created yet, so there should not be - * any logical undo records for this volume, we will ignore it - * and go on - */ + * any logical undo records for this volume, we will ignore it + * and go on + */ break; default: zASSERT("Unrecognized Volume Locator Beast state" == NULL); @@ -1120,8 +1086,8 @@ cleanup_error: if (zVolume) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(CYAN, - MSGNot("Quasi activation of LV %U failed. \n"), + DBG_DebugPrintf(CYAN, + MSGNot("Quasi activation of LV %U failed. \n"), zvlBeast->ZVL_p.PZVL_volumeName); #endif zASSERT(QMEMBER(&zVolume->ZLSSVOLvol.masterVolLink)); @@ -1150,7 +1116,7 @@ cleanup_error: BST_UNUSE_BEAST(&nameSpace->NSPACEroot); } #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(RED, MSGNot("Quasi activation of LVs failed. Error = %ld (%s) \n"), GetErrno(genMsg), GetErrnoSetter(genMsg)); + DBG_DebugPrintf(RED, MSGNot("Quasi activation of LVs failed. Error = %ld (%s) \n"), GetErrno(genMsg), GetErrnoSetter(genMsg)); zASSERT("Error during Quasi Activation." == NULL); #endif @@ -1194,7 +1160,7 @@ void ZFSPOOL_DeactivateAllQuasiActiveLVs( zVolume = VOLUME_TO_ZLSS_VOLUME(volume); ZFSVOL_Deactivate(&genMsg, zVolume, 0); ZLSSVOL_UnloadPersistentPool(zVolume, 0); - + zASSERT(QMEMBER(&zVolume->ZFSVOLvol.masterVolLink)); SET_RMV(zVolume,ZFSVOLvol.masterVolLink); @@ -1236,7 +1202,7 @@ STATUS ZFSPOOL_Activate( COMN_GetVolumeName(&aStack->dummyGenMsg,(Volume_s *)pool,aStack->poolName,NELEMS(aStack->poolName)); status = ZFSPOOL_CheckpointFindNewest( genMsg, pool, - &pool->ZP_super->SB_Checkpoint, aStack->poolName ); + &pool->ZP_super->SB_Checkpoint, aStack->poolName ); if ( status != zOK ) { /* All errors mean we can not come up */ goto cleanup_error; @@ -1277,8 +1243,8 @@ STATUS ZFSPOOL_Activate( //#ifndef __linux__ // LINUX_Upgrade /* Do not do any in place upgrades that do transactioning in this - * routine. - */ + * routine. + */ #ifdef NW5X_UPGRADE if (ZFSPOOL_AutoInPlaceUpgradeNoXactions(genMsg, pool) != zOK) { @@ -1311,7 +1277,7 @@ cleanup_error: STACK_FREE(); RTN_STATUS(zFAILURE); } - + /************************************************************************** * This is called when we are bringing the POOL down * @@ -1332,21 +1298,21 @@ STATUS ZFSPOOL_Deactivate( GeneralMsg_s dummyGenMsg; ENTER(TZPOOL, ZFSPOOL_Deactivate); - - ASSERT_MPKNSS_LOCK(); + + ASSERT_MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); DEBUG_PRINTF(TPOOL,DBG_NOINDENT,(CYAN,MSGNot("CVS@ZFSPOOL_Deactivate\n"))); CANCEL_ALARM(pool->ZFSPOOLmycache.agent.timer); /* Removed CANCEL_ALARM(pool->timer) because - * ZFSPOOL_CheckpointTake() below handles the alarm cancel. Make - * sure that the routine is called with the 'LAST' bit set if you - * change this routine. - */ + * ZFSPOOL_CheckpointTake() below handles the alarm cancel. Make + * sure that the routine is called with the 'LAST' bit set if you + * change this routine. + */ zASSERT(DQ_EMPTY(&pool->ZFSPOOLbeastList)); /* The *10 is to ENSURE we take enough checkpoints to clear - * the defered delete queue. - */ + * the defered delete queue. + */ for ( i=0; i < (CHECKPOINT_NUMBER*30); i++ ) { /*------------------------------------------------------------------------- @@ -1365,19 +1331,19 @@ STATUS ZFSPOOL_Deactivate( /* continue with the deactivation */ } /* - * This code prevents us from taking extra checkpoints when - * trying to clear the defered delete queue. Here we check - * that there are no more items on the defered delete queue. - * - * We must clear the defered delete queue so that we can take - * one last checkpoint that will be clean. If we do not clear - * defered delete queue 1st then after we take the last - * checkpoint more log records may be generated by blocks - * that are now deletable. - * - * The QUEUE is protected by NetWare being non-pre-emptive. - * - */ + * This code prevents us from taking extra checkpoints when + * trying to clear the defered delete queue. Here we check + * that there are no more items on the defered delete queue. + * + * We must clear the defered delete queue so that we can take + * one last checkpoint that will be clean. If we do not clear + * defered delete queue 1st then after we take the last + * checkpoint more log records may be generated by blocks + * that are now deletable. + * + * The QUEUE is protected by NetWare being non-pre-emptive. + * + */ if (DQ_EMPTY(&pool->ZP_deleteBlkQ)) { /* Nothing on queue */ break; @@ -1399,14 +1365,14 @@ STATUS ZFSPOOL_Deactivate( LB_delay(200); } /* Worst case is that the Free B-Tree will cause MANY delete - * block deletes of its own blocks. Note a delete could cause - * the Free B-Tree to delete one of its nodes. Depending on state - * this delete could then cause another delete of a block in the - * Free B-Tree. 40 seems like more than ressonable number of - * checkpoints to take. If this is WRONG then we will have - * a purge log entry and be forced to do REDO/UNDO and/or replay - * purge log. - */ + * block deletes of its own blocks. Note a delete could cause + * the Free B-Tree to delete one of its nodes. Depending on state + * this delete could then cause another delete of a block in the + * Free B-Tree. 40 seems like more than ressonable number of + * checkpoints to take. If this is WRONG then we will have + * a purge log entry and be forced to do REDO/UNDO and/or replay + * purge log. + */ #if NSS_DEBUG IS_ENABLED /* We skip ASSERTS if in DISABLE mode because they will occur */ if ( !(ZLSS_VOLUME_IO_DISABLED( &pool->ZFSPOOLzfsVol ) ) ) @@ -1416,17 +1382,17 @@ STATUS ZFSPOOL_Deactivate( } #endif /* TOSS any left over blocks. We must do because if we can not write - * checkpoints then we have been unable to properly delete the - * blocks on the delete block queue. - */ + * checkpoints then we have been unable to properly delete the + * blocks on the delete block queue. + */ XDEL_DeactivateVolume(&pool->ZFSPOOLzfsVol); - + /* This code waits for all transactions to home. The system flush - * in the above loop returns when the metadata is flushed. It - * does not wait for home to move. By waiting for all transactions - * to complete we also allow the ASYNC EndXLocal threads to - * clear out of the system. - */ + * in the above loop returns when the metadata is flushed. It + * does not wait for home to move. By waiting for all transactions + * to complete we also allow the ASYNC EndXLocal threads to + * clear out of the system. + */ zlogBeast = pool->zfsLogBeast; if ( zlogBeast != NULL ) { @@ -1438,13 +1404,13 @@ STATUS ZFSPOOL_Deactivate( UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); LB_delay( ZLOG_WORK_CHECKPOINT_WAIT_DELAY ); /* 20 millisecs */ /* Bug 308300 - * Now that we do group writes of metadata we must ensure - * defaultFlush is done to all the metadata blocks. Since - * we have only used TRUE (3rd paramter) we may have some - * metadata blocks that got dirty via updating other system - * beasts. We do not want to have to wait up to 45 seconds - * for the metadata group write timer to perform defaultFlush. - */ + * Now that we do group writes of metadata we must ensure + * defaultFlush is done to all the metadata blocks. Since + * we have only used TRUE (3rd paramter) we may have some + * metadata blocks that got dirty via updating other system + * beasts. We do not want to have to wait up to 45 seconds + * for the metadata group write timer to perform defaultFlush. + */ (void)ZFSPOOL_DoFlushSystemBeasts(&dummyGenMsg,pool,FALSE); /* Bug 308300 */ X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); ++count; @@ -1453,20 +1419,20 @@ STATUS ZFSPOOL_Deactivate( /* If we did the above for 30 secs then ASSERT */ zASSERT( count < ((30 * 1000)/ZLOG_WORK_CHECKPOINT_WAIT_DELAY) ); /* We drop out after 15 seconds so we do not hang. This means - * that some items have not homed. This will mean we do a - * REDO/UNDO sequenece on the next activate even though the - * user believes they did a clean deactivate. - */ + * that some items have not homed. This will mean we do a + * REDO/UNDO sequenece on the next activate even though the + * user believes they did a clean deactivate. + */ UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); /*----------------------------------------------------------------------- - * Write a clean checkpoint - *-----------------------------------------------------------------------*/ + * Write a clean checkpoint + *-----------------------------------------------------------------------*/ /* Don't do tosses until after we are done with all the activity on - * the system beasts, because cacheToss has a problem where it - * removes the blocks from the cache HASH even if they still need - * to be flushed. - */ + * the system beasts, because cacheToss has a problem where it + * removes the blocks from the cache HASH even if they still need + * to be flushed. + */ ZFSPOOL_DoFlushSystemBeasts(&dummyGenMsg,pool,TRUE); // if ( mode & iVOLMODE_UNDO ) // { @@ -1476,7 +1442,7 @@ STATUS ZFSPOOL_Deactivate( // else { DEBUG_PRINTF(TPOOL,DBG_NOINDENT,(CYAN,MSGNot("CVS@ZFSPOOL_CheckpointTake(fake)\n"))); - if (ZFSPOOL_CheckpointTake(&dummyGenMsg,pool,CHECKPOINT_CT_S_DEACTIVATION| + if (ZFSPOOL_CheckpointTake(&dummyGenMsg,pool,CHECKPOINT_CT_S_DEACTIVATION| CHECKPOINT_CT_S_CLEAN|CHECKPOINT_CT_S_LAST) != zOK) { errPrintf(WHERE, Module, 1425, @@ -1508,10 +1474,10 @@ STATUS ZFSPOOL_Deactivate( } } /* The return says the function succeeded in cleaning up - * all resources. If errno is set then we got some sort - * of error while deactivating. - */ - + * all resources. If errno is set then we got some sort + * of error while deactivating. + */ + RTN_STATUS( zOK ); } @@ -1559,9 +1525,9 @@ STATUS ZFSPOOL_upgradeUserTree( if (oldTree->zfsBtree.p.btRoot == INVALID_BLK) { status = zOK; - goto deleteOldTree; + goto deleteOldTree; } - + newTree = (ZfsUserTreeBeast_s *)ZFSVOL_VOL_GetBeastFromVolume(genMsg, ZFSVOL_USERTREE_ZID, &volume->ZFSVOLvol); @@ -1618,9 +1584,9 @@ STATUS ZFSPOOL_upgradeUserTree( } /* - * Parse the old tree by following the leaf links. Convert the user IDs - * to GUIDs and add the entries to the new tree. - */ + * Parse the old tree by following the leaf links. Convert the user IDs + * to GUIDs and add the entries to the new tree. + */ while(nextLeaf != INVALID_BLK) { READBLK_IO_MSG(iomsg, oldTree, nextLeaf, CACHE_READ); @@ -1636,12 +1602,12 @@ STATUS ZFSPOOL_upgradeUserTree( /* Convert the user IDs and add them to the new user tree */ for (index = 0; index < oldNode->numRecs; index++) { - if (COMN_MapNDSIDToGUID(&retStatus, oldNode->ULEAF(index).userID, + if (COMN_MapNDSIDToGUID(&retStatus, oldNode->ULEAF(index).userID, &newUserID) != zOK) { errPrintf(WHERE, Module, 1474, MSG("Unable to convert ID to GUID. Status=%d\n" - "The entry for a user has been lost.", 877), + "The entry for a user has been lost.", 877), retStatus); zASSERT("Error converting to GUID -- Ignoring entry"==0); continue; @@ -1659,12 +1625,12 @@ STATUS ZFSPOOL_upgradeUserTree( EndXlocal(parms.xaction); errPrintf(WHERE, Module, 1475, MSG("Error modifying used amount during convert. Status=%d\n" - "User restrictions may be inaccurate", 929), + "User restrictions may be inaccurate", 929), GetErrno(genMsg)); zASSERT("Error modifying used amount"==0); continue; } - if (oldNode->ULEAF(index).restrictionAmount != + if (oldNode->ULEAF(index).restrictionAmount != zUSER_NO_RESTRICTIONS) { parms.value = oldNode->ULEAF(index).restrictionAmount; @@ -1674,7 +1640,7 @@ STATUS ZFSPOOL_upgradeUserTree( EndXlocal(parms.xaction); errPrintf(WHERE, Module, 1476, MSG("Error modifying restriction amount during convert. Error=%d\n" - "User restrictions may be innaccurate", 938), + "User restrictions may be innaccurate", 938), GetErrno(genMsg)); zASSERT("Error modifying restriction amount"==0); continue; @@ -1692,21 +1658,21 @@ STATUS ZFSPOOL_upgradeUserTree( deleteOldTree: /* - * Get rid of the old tree - */ + * Get rid of the old tree + */ UBT_OLD_ResetAllUsers(genMsg, &volume->ZFSVOLvol, oldTree); BST_flush(oldTree); cacheTossAll(&oldTree->ZFSUSERTREEmycache); X_LATCH(&oldTree->ZFSUSERTREEbeastLatch); xaction = BeginXLocal(&volume->ZFSVOLvol, BXL_DEFAULT); - ZFSVOL_VOL_RemoveBeastFromVolume(genMsg, &oldTree->ZFSUSERTREEroot, + ZFSVOL_VOL_RemoveBeastFromVolume(genMsg, &oldTree->ZFSUSERTREEroot, &xaction->xaction); EndXlocal(xaction); UNX_LATCH(&oldTree->ZFSUSERTREEbeastLatch); cleanupOldTreeFromMemory: BST_UNUSE_BEAST(&oldTree->ZFSUSERTREEroot); - BST_free(&oldTree->ZFSUSERTREEroot); + BST_free(&oldTree->ZFSUSERTREEroot); if (status == zOK) { /* Make sure all object IDs in the file system are in the tree */ @@ -1714,7 +1680,7 @@ cleanupOldTreeFromMemory: } return status; -} +} #endif //#endif @@ -1814,7 +1780,7 @@ STATIC STATUS ZFSPOOL_VOL_ChangeVolumeState( { ZfsPool_s *pool = (ZfsPool_s *)pool_LX; STATUS status; - zfspool_change_volume_state_func_t parentFunc; + statusfunc_t parentFunc; RootBeast_s *beast; ZlssPool_s *zlssPool; @@ -1830,15 +1796,14 @@ STATIC STATUS ZFSPOOL_VOL_ChangeVolumeState( * Since we know we need to call the ZfsVolume_s code, get the address of * that routine. *-------------------------------------------------------------------------*/ - parentFunc = (zfspool_change_volume_state_func_t)COMN_GetNextParentVolumeComnOp(pool->ZFSPOOLbeastClass, - COMNVOLOPS_INDEX(VOL_changeVolumeState), - (statusfunc_t)ZFSPOOL_VOL_ChangeVolumeState); + parentFunc = COMN_GetNextParentVolumeComnOp(pool->ZFSPOOLbeastClass, + COMNVOLOPS_INDEX(VOL_changeVolumeState),ZFSPOOL_VOL_ChangeVolumeState); zASSERT(parentFunc != NULL); status = parentFunc( genMsg, &pool->zfsVol, sourceState, requestedState, mode, pass ); if ( status != zOK ) { - return( status ); + return( status ); } switch (requestedState) @@ -1859,11 +1824,11 @@ STATIC STATUS ZFSPOOL_VOL_ChangeVolumeState( if ( zlssPool->ZP_Version < (AIPU_LV_MEDIA_MAJOR*0x100L+AIPU_LV_STEP_4_DONE) ) { /* We are NOT done with with UPGRADE so the ONLY - * time we allow us to go into ACTIVE state is - * if we are LOADING/UPGRADEING the pool. This - * is required because the LV AIPU part of - * upgrade loads and unloads the pool. - */ + * time we allow us to go into ACTIVE state is + * if we are LOADING/UPGRADEING the pool. This + * is required because the LV AIPU part of + * upgrade loads and unloads the pool. + */ if ( !zlssPool->ZP_Loading ) { SetErrno( genMsg, zERR_ZLSSPOOL_UPGRADE_POOL_FIRST ); @@ -1875,26 +1840,26 @@ STATIC STATUS ZFSPOOL_VOL_ChangeVolumeState( if ( pass == ZLSSPOOL_ACTIVATE ) { /* When we go from DEACTIVE to ACTIVE we need - * to do our extra SHARED pool checks. Note - * the check is not needed when going from - * MAINTENANCE to ACTIVE because the check was - * done when we went from DEACTIVE to MAINTENANCE. - */ + * to do our extra SHARED pool checks. Note + * the check is not needed when going from + * MAINTENANCE to ACTIVE because the check was + * done when we went from DEACTIVE to MAINTENANCE. + */ status = ZFSPOOL_LoadPersistentPool( genMsg, pool, mode, 0, sourceState == zVOLSTATE_DEACTIVE, requestedState ); if ( status != zOK ) { RTN_STATUS(zFAILURE); } /* If we are not in override mode then we need - * to fail going to ACTIVE state if the volume - * is corrupt or was being repaired/checked. We - * have to wait until now to check because the - * corrupt and repairing bits are stored in the - * persistent volume. Maybe Volume_s should do - * the check. - */ + * to fail going to ACTIVE state if the volume + * is corrupt or was being repaired/checked. We + * have to wait until now to check because the + * corrupt and repairing bits are stored in the + * persistent volume. Maybe Volume_s should do + * the check. + */ if ( !(mode & VOLMODE_OVERRIDE) -// && (sourceState == zVOLSTATE_DEACTIVE) +// && (sourceState == zVOLSTATE_DEACTIVE) ) { if ( (pool->ZFSPOOLvol.p.stateAttributes & VOLSTATEATTR_CORRUPT) || @@ -1921,9 +1886,9 @@ STATIC STATUS ZFSPOOL_VOL_ChangeVolumeState( } else { /* Since we are corrupt or were repairing and - * we have not been told to OVERRIDE then we - * will not do this activation request. - */ + * we have not been told to OVERRIDE then we + * will not do this activation request. + */ SetErrno(genMsg,zERR_VOLUME_SHOULD_NOT_ACTIVATE); } return( zFAILURE ); @@ -1931,36 +1896,36 @@ STATIC STATUS ZFSPOOL_VOL_ChangeVolumeState( } status = ZFSPOOL_Activate(genMsg,pool,mode,0); } - + if ( pass == ZLSSVOL_ACTIVATE_TIME ) { ZfsPurgeLogBeast_s *holdPurgeLog; /* - * The following can be done here and does not need to - * be added to Verify or Repair because we will not - * allow the a volume to be repaired or verified that - * has not been already upgraded. - */ + * The following can be done here and does not need to + * be added to Verify or Repair because we will not + * allow the a volume to be repaired or verified that + * has not been already upgraded. + */ /** Replenish the special blk in the free tree to have - ** enough free blocks for the free tree to use when - ** in needs to grow or split. - ** If the special blk does not exist, it is created - ** at this time. (on existing volumes) - **/ + ** enough free blocks for the free tree to use when + ** in needs to grow or split. + ** If the special blk does not exist, it is created + ** at this time. (on existing volumes) + **/ CheckSpecialBlkAndAdd(pool, NULL, XTREE_SPBLK_XACTION | XTREE_SPBLK_THREAD_SCH); /* - * If there is an old version of the user tree then - * upgrade it to the new version. This must be done - * before the purge log is played, as playing the - * purge log may cause modifications to the user tree. - */ + * If there is an old version of the user tree then + * upgrade it to the new version. This must be done + * before the purge log is played, as playing the + * purge log may cause modifications to the user tree. + */ - holdPurgeLog = + holdPurgeLog = ((ZfsVolume_s *)pool)->ZFSVOLvolumePurgeLog; if (holdPurgeLog == NULL) @@ -1976,8 +1941,8 @@ STATIC STATUS ZFSPOOL_VOL_ChangeVolumeState( DQ_RMV(beast, volLink); //#ifndef __linux__ // LINUX_Upgrade #ifdef NW5X_UPGRADE - ZFSPOOL_upgradeUserTree(genMsg, - &pool->ZFSPOOLzfsVol, + ZFSPOOL_upgradeUserTree(genMsg, + &pool->ZFSPOOLzfsVol, (ZfsUserTreeBeast_s *)beast); #endif //#endif @@ -1986,7 +1951,7 @@ STATIC STATUS ZFSPOOL_VOL_ChangeVolumeState( { ClearErrno( genMsg ); } - ((ZfsVolume_s *)pool)->ZFSVOLvolumePurgeLog = + ((ZfsVolume_s *)pool)->ZFSVOLvolumePurgeLog = holdPurgeLog; } @@ -2033,30 +1998,30 @@ STATIC STATUS ZFSPOOL_VOL_ChangeVolumeState( #endif //#ifndef __linux__ // LINUX_Upgrade /* Start up the background upgrade thread that - * ensures that the pool gets upgraded into - * Nakoma version sooner or later. - */ + * ensures that the pool gets upgraded into + * Nakoma version sooner or later. + */ if ( ZLSS_AIPUNakomaPool_Ready( zlssPool ) ) { ZLSS_UpgradeStartupNakoma(); } //#endif /* Increase the POOL size if a segment has - * been added since last activation OR we - * crashed while adding space. - */ + * been added since last activation OR we + * crashed while adding space. + */ status = ZFSPOOL_SetNewPoolSizeDuringActivation( genMsg, pool ); if ( status != zOK ) { RTN_STATUS( status ); } /* - * Dirty the system beasts if needed. - * This must be done just before we - * set the volume state to active so the - * timer does not pop before the volume - * is active - */ + * Dirty the system beasts if needed. + * This must be done just before we + * set the volume state to active so the + * timer does not pop before the volume + * is active + */ ZFSPOOL_DirtySystemBeasts(genMsg, pool); } break; @@ -2086,9 +2051,9 @@ STATIC STATUS ZFSPOOL_VOL_ChangeVolumeState( { GeneralMsg_s dummyGenMsg; /* We do not care about errors from - * deactivate so pass it a dummy genMsg - * so it does not mess with our errno. - */ + * deactivate so pass it a dummy genMsg + * so it does not mess with our errno. + */ COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); ASSERT_MPKNSS_LOCK(); ZFSPOOL_Deactivate( &dummyGenMsg, pool, mode ); @@ -2227,7 +2192,7 @@ PoolBeastCtrl_s SuperBeasts[] = * beast which is stored in CheckPoint. This is called when we are both * deactivating as well as simply flushing the pool. We pass a flag to * say what mode we are in. Make sure that the volume persistent data - * is being written. Some code depends on this (i.e. + * is being written. Some code depends on this (i.e. * VOL_UpgradeBeastsOnVolume). ***************************************************************************/ STATUS ZFSPOOL_DoFlushSystemBeasts( @@ -2238,7 +2203,7 @@ STATUS ZFSPOOL_DoFlushSystemBeasts( RootBeast_s *beast; NINT i; NINT retryCount; - + ENTER(TZPOOL,ZFSPOOL_DoFlushSystemBeasts); ASSERT_MPKNSS_LOCK(); DEBUG_PRINTF(TPOOL,DBG_NOINDENT,(CYAN,MSGNot("CVS@ZFSPOOL_DoFlushSystemBeasts\n"))); @@ -2345,15 +2310,15 @@ STATUS ZFSPOOL_DoFlushSystemBeasts( * */ void ZLSSPOOL_PoolVolDataInitialize( - ZfsPool_s *zfsPool, + ZfsPool_s *zfsPool, StorPool_s *storagepool) { zASSERT( offsetof( PersistentVolume_s, PV_reserved3 ) == 184 ); zASSERT( offsetof( PersistentZfsVolume_s, PZV_reserved ) == 88 ); /* If you hit ANY of the above ASSERTs be sure to add the item - * that changed the size to the initialization code below. - * Then update the ASSERT - */ + * that changed the size to the initialization code below. + * Then update the ASSERT + */ ZLSSVOL_InitVDB( ZFS_POOL_TO_ZLSS_VOLUME( zfsPool ), /* IV allocates and inits LVDB, VDB, and BT fields later */ INVALID_BLK_ZERO, INVALID_BLK_ZERO, INVALID_BLK_ZERO, @@ -2364,9 +2329,9 @@ void ZLSSPOOL_PoolVolDataInitialize( zASSERT( offsetof( LoggedPersistentVolume_s, LPV_reserved ) == 120 ); zASSERT( offsetof( LoggedPersistentZfsVolume_s, LPZV_reserved ) == 32 ); /* If you hit ANY of the above ASSERTs be sure to add the item - * that changed the size to the initialization code below. - * Then update the ASSERT - */ + * that changed the size to the initialization code below. + * Then update the ASSERT + */ ZLSSVOL_InitLVDB( ZFS_POOL_TO_ZLSS_VOLUME( zfsPool ), storagepool->pooltotalblocks, 0, /* All blocks initially in use during pool create */ @@ -2394,14 +2359,14 @@ STATUS ZFSPOOL_InitNewBeast( file->FILEzid = zid; file->FILEfirstParentZid = parentZid; file->FILEattributes = fileAttributes; - file->FILEaccessedTime = - file->FILEcreatedTime = - file->FILEmodifiedTime = + file->FILEaccessedTime = + file->FILEcreatedTime = + file->FILEmodifiedTime = file->FILEmetaDataModifiedTime = GetUTCTime(); file->FILEarchivedTime = INVALID_UTC_TIME; - file->FILEownerID = + file->FILEownerID = file->FILEmodifierID = file->FILEmetaDataModifierID = zSUPERVISOR_ID; @@ -2413,8 +2378,8 @@ STATUS ZFSPOOL_InitNewBeast( return zOK; } - if (NAME_doAddName(genMsg, &file->FILEnamed, &file->FILEfirstParent, - 1 << zNSPACE_LONG, name, 0) != zOK) + if (NAME_doAddName(genMsg, &file->FILEnamed, &file->FILEfirstParent, + 1 << zNSPACE_LONG, name, 0) != zOK) { return zFAILURE; } @@ -2439,10 +2404,10 @@ STATUS ZFSPOOL_InitNewRootDir( File_s *rootdir, ZfsVolume_s *zfsVol) { - + ASSERT_XLATCH(&rootdir->FILEbeastLatch); if (ZFSPOOL_InitNewBeast(genMsg, rootdir, zROOTDIR_ZID, zINVALID_ZID, - zFA_SUBDIRECTORY, NULL) != zOK) + zFA_SUBDIRECTORY, NULL) != zOK) { return zFAILURE; } @@ -2510,7 +2475,7 @@ STATUS ZFSPOOL_InitNewPool( SetErrno( genMsg, zERR_POOL_TOO_LARGE ); return( zFAILURE ); } - + LB_GUIDGenerate( &volumeID ); zlssPool = POOL_BstNew( genMsg, zFTYPE_ZLSS_LOGICAL_POOL, COMN_GetAdminVolume(), @@ -2551,11 +2516,11 @@ STATUS ZFSPOOL_InitNewPool( } if(zlssPool->ZLSSPOOLroot.beastVersion == BEAST_VERSION_3) { - sbMinor = SUPERBLOCK_SB_VM_MEDIA_MINOR; + sbMinor = SUPERBLOCK_SB_VM_MEDIA_MINOR; } else { - sbMinor = 2; + sbMinor = 2; } /*- get the storage deposit -*/ @@ -2572,8 +2537,8 @@ STATUS ZFSPOOL_InitNewPool( /* Must match because we use _IV_ to write the POOL's LPDB and PDB */ zlssPool->ZLSSPOOLmInternalID = pool->ZFSPOOLinternalID; /* ZP_Version must be filled in before ZLSSPOOL_PoolVolDataInitialize call. - * We init to the values that will be in superblock in a few lines - */ + * We init to the values that will be in superblock in a few lines + */ if ( ZLSS_UpgradeMediaFormat ) { zlssPool->ZP_Version = (SUPERBLOCK_SB_VM_MEDIA_MAJOR * 0x100L) + sbMinor; @@ -2583,15 +2548,15 @@ STATUS ZFSPOOL_InitNewPool( zlssPool->ZP_Version = (40 * 0x100L) + 8; } /* Init MOST of the POOL's persistent fields to default values. - * We do nothing */ + * We do nothing */ ZLSSPOOL_PoolDataInitialize( zlssPool, storagepool->pooltotalblocks, storagepool->poolblkshift, storagepool->sharedStatus ? zPOOL_FEATURE_SHARED_CLUSTER : 0); /* Init MOST of the POOL's internal volume persistent fields - * to their default values. - */ + * to their default values. + */ ZLSSPOOL_PoolVolDataInitialize(pool, storagepool); /*--------------------------------------------------------------------------- @@ -2711,8 +2676,8 @@ STATUS ZFSPOOL_InitNewPool( InitRootNode(genMsg,(ZfsFreeExtent_s *)beast, super->SB_Header.hdr.totalblocks / 2 ); /** Initialize the special block where some free blocks are kept - ** exclusively for use by the free tree for its splits and grows - **/ + ** exclusively for use by the free tree for its splits and grows + **/ InitSpecialNode(genMsg,(ZfsFreeExtent_s *)beast, (super->SB_Header.hdr.totalblocks / 2) + 1); @@ -2725,16 +2690,16 @@ STATUS ZFSPOOL_InitNewPool( /* Remove the space just allocated to the FREE tree */ seedext.poolBlkNum = super->SB_Header.hdr.totalblocks / 2; seedext.lengthOfExtent = 2; - zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, + zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, XTREE_SYSTEM_REQUEST, NULL); - zASSERT(((super->SB_Header.hdr.totalblocks / 2) == - seedext.poolBlkNum) && (seedext.lengthOfExtent == 2)); - + zASSERT(((super->SB_Header.hdr.totalblocks / 2) == + seedext.poolBlkNum) && (seedext.lengthOfExtent == 2)); + // pool->ZP_super->SB_Header.hdr.SBH_FreeTreeBlk = seedext.poolBlkNum; } BEASTHASH_Insert(&beast->FILEroot); /* Do not put any of the SYSTEM beasts into the POOL linked list because - * we need to control when the files are flushed */ + * we need to control when the files are flushed */ DQ_RMV(beast,FILEvolLink); } @@ -2744,7 +2709,7 @@ STATUS ZFSPOOL_InitNewPool( /* Super block 1 */ seedext.poolBlkNum = super->SB_Header.hdr.superlocation[0]; seedext.lengthOfExtent = SUPERBLOCK_BLKCOUNT; - zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, + zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, XTREE_SYSTEM_REQUEST, NULL); zASSERT((super->SB_Header.hdr.superlocation[0] == seedext.poolBlkNum) && (seedext.lengthOfExtent == SUPERBLOCK_BLKCOUNT)); @@ -2752,7 +2717,7 @@ STATUS ZFSPOOL_InitNewPool( /* Super block 2 */ seedext.poolBlkNum = super->SB_Header.hdr.superlocation[1]; seedext.lengthOfExtent = SUPERBLOCK_BLKCOUNT; - zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, + zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, XTREE_SYSTEM_REQUEST, NULL); zASSERT((super->SB_Header.hdr.superlocation[1] == seedext.poolBlkNum) && (seedext.lengthOfExtent == SUPERBLOCK_BLKCOUNT)); @@ -2760,7 +2725,7 @@ STATUS ZFSPOOL_InitNewPool( /* Super block 3 */ seedext.poolBlkNum = super->SB_Header.hdr.superlocation[2]; seedext.lengthOfExtent = SUPERBLOCK_BLKCOUNT; - zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, + zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, XTREE_SYSTEM_REQUEST, NULL); zASSERT((super->SB_Header.hdr.superlocation[2] == seedext.poolBlkNum) && (seedext.lengthOfExtent == SUPERBLOCK_BLKCOUNT)); @@ -2768,7 +2733,7 @@ STATUS ZFSPOOL_InitNewPool( /* Super block 4 */ seedext.poolBlkNum = super->SB_Header.hdr.superlocation[3]; seedext.lengthOfExtent = SUPERBLOCK_BLKCOUNT; - zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, + zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, XTREE_SYSTEM_REQUEST, NULL); zASSERT((super->SB_Header.hdr.superlocation[3] == seedext.poolBlkNum) && (seedext.lengthOfExtent == SUPERBLOCK_BLKCOUNT)); @@ -2790,7 +2755,7 @@ STATUS ZFSPOOL_InitNewPool( *-------------------------------------------------------------------------*/ seedext.poolBlkNum = (super->SB_Header.hdr.totalblocks / 2) + 2; seedext.lengthOfExtent = 3+LV_POOL_BLOCKS; - zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, + zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, XTREE_SYSTEM_REQUEST, NULL); if (seedext.lengthOfExtent != (3+LV_POOL_BLOCKS)) { @@ -2810,7 +2775,7 @@ STATUS ZFSPOOL_InitNewPool( pool->ZP_super->SB_Header.hdr.SBH_PoolDataBlk = seedext.poolBlkNum+4; zlssPool->ZP_p.PZP_poolDataBlk = seedext.poolBlkNum+4; - READBLK_IO_MSG(iomsg, ztree, ztree->specialSystemBstsBlk, CACHE_WRITE); + READBLK_IO_MSG(iomsg, ztree, ztree->specialSystemBstsBlk, CACHE_WRITE); buffer = ZFS_ReadPoolBlk(genMsg, &iomsg); if (buffer == NULL) { @@ -2830,19 +2795,19 @@ STATUS ZFSPOOL_InitNewPool( #if 0 { /* - * We like to have completly zeroed volume data blocks - * when we start. Some of this is required because our - * logging code does not ever update the reserved area - * so to save a little time on writing the logged data - * which is done ALL the time. - * - * As of May 21, 1998 the above is no longer true. We - * now no longer pre-read the volume data blocks mainly - * so we do not have to handle read errors. We still - * zero the reserved areas (via the in-memory structure), - * but we no longer have zeros at the end of the 4k block - * in the area I call UNUSED. - */ + * We like to have completly zeroed volume data blocks + * when we start. Some of this is required because our + * logging code does not ever update the reserved area + * so to save a little time on writing the logged data + * which is done ALL the time. + * + * As of May 21, 1998 the above is no longer true. We + * now no longer pre-read the volume data blocks mainly + * so we do not have to handle read errors. We still + * zero the reserved areas (via the in-memory structure), + * but we no longer have zeros at the end of the 4k block + * in the area I call UNUSED. + */ IoMsg_s iomsg; Blknum_t blk; @@ -2862,8 +2827,8 @@ STATUS ZFSPOOL_InitNewPool( } bzero( buffer->pBuf.data, (1<bufSizeShift) ); /* Note that the zero's will be replaced at the end of this - * routine when ZFSPOOL_Deactive is called. - */ + * routine when ZFSPOOL_Deactive is called. + */ CACHE_DIRTY_RELEASE(buffer); blk = pool->ZFSPOOLzfsvol.p.PZV_loggedVolumeDataBlk; @@ -2880,10 +2845,10 @@ STATUS ZFSPOOL_InitNewPool( } bzero( buffer->pBuf.data, (1<bufSizeShift) ); /* Note that the zero's will be replaced at the end of this - * routine when ZFSPOOL_Deactive is called. - */ + * routine when ZFSPOOL_Deactive is called. + */ CACHE_DIRTY_RELEASE(buffer); - + } #endif @@ -2904,7 +2869,7 @@ STATUS ZFSPOOL_InitNewPool( *-------------------------------------------------------------------------*/ extent.lengthOfExtent = 2; extent.poolBlkNum = (super->SB_Header.hdr.totalblocks / 2) + 1 + 2; - if (zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &extent, + if (zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &extent, XTREE_SYSTEM_REQUEST, NULL) != zOK) { goto error_cleanupRelease; @@ -2965,7 +2930,7 @@ STATUS ZFSPOOL_InitNewPool( if (status != zOK) { -/** Insert beast now does the cleanup on error conditions. We have no way +/** Insert beast now does the cleanup on error conditions. We have no way ** to tell if the error was before or after the pack was called. ** ** BST_noPackCleanup(&beast->FILEroot); @@ -2976,7 +2941,7 @@ STATUS ZFSPOOL_InitNewPool( // if (beast->FILEzid == ZFSPOOL_VOLBSTTREE_ZID) // { // ZfsBeastTreeBeast_s *btree = (ZfsBeastTreeBeast_s *)beast; -// +// // /* Store BEAST B-Tree block number into the ZFS volume */ // zASSERT( btree->ZFSBEASTTREEbtRoot != 0 ); // pool->ZFSPOOLzfsvolp.PZV_beastTreeBlkNum = btree->ZFSBEASTTREEbtRoot; @@ -2997,8 +2962,8 @@ STATUS ZFSPOOL_InitNewPool( X_LATCH(&rootdir->FILEbeastLatch); /* Do not put any of the SYSTEM beasts into the Volume's list because - * we need to control when the files are flushed. - */ + * we need to control when the files are flushed. + */ if (ZFSPOOL_InitNewRootDir(genMsg, rootdir, &pool->ZFSPOOLzfsvol) != zOK) { @@ -3007,7 +2972,7 @@ STATUS ZFSPOOL_InitNewPool( goto error_freeRootdir; } - BEASTHASH_Insert(&rootdir->FILEroot); + BEASTHASH_Insert(&rootdir->FILEroot); DQ_RMV(rootdir,FILEvolLink); COMN_MARK_BEAST_DIRTY( &rootdir->FILEroot); @@ -3075,17 +3040,17 @@ STATUS ZFSPOOL_InitNewPool( /*--------------------------------------------------------------------------- | Flush and Toss all ZFSPOOL system beasts. - | The deactivate also flushes the Volume Data Blocks and Logged + | The deactivate also flushes the Volume Data Blocks and Logged | Volume Data Blocks. *-------------------------------------------------------------------------*/ ZFSPOOL_Deactivate( genMsg, pool, 0 ); ZFSPOOL_UnloadPersistentPool( pool, 0 ); /* By removing from the master volume link list we prevent - * this volume from being found. This prevents any new - * operations from starting which is a requirement since - * we will be freeing the volume. - */ + * this volume from being found. This prevents any new + * operations from starting which is a requirement since + * we will be freeing the volume. + */ if (QMEMBER(&pool->ZFSPOOLvol.masterVolLink)) { SET_RMV(pool,ZFSPOOLvol.masterVolLink); @@ -3142,7 +3107,7 @@ error_exit: MSGNot("ZFSPOOL_InitNewPool(error exit) %ld %s\n"), GetErrno(genMsg),GetErrnoSetter(genMsg))); RTN_STATUS(zFAILURE); -} +} @@ -3197,7 +3162,7 @@ void ReBoot(void); /* Reboots a PC - taken from crashNMIShell.386 */ * library/default.asp?URL=/library/wcedoc/wcesdkr/regapi_7.htm ) * * Registry Functions - * Function Description + * Function Description * RegCloseKey - SUPPORTED * RegConnectRegistry * RegCreateKeyEx - SUPPORTED @@ -3309,20 +3274,20 @@ ZfsPool_s *ZFSPOOL_LoadPool( BOOL verbose, NINT loadFlag, BOOL snapshot, /* TRUE when we need to create a snapshot - * of current pool being loaded. I.E. - * convert the current pool into a snapshot - * of some other pool. - */ + * of current pool being loaded. I.E. + * convert the current pool into a snapshot + * of some other pool. + */ unicode_t *snapshotInfo, /* Only used if 'snapshot' is TRUE. Caller - * must ensure that this is less than 64 - * unicode (including the required NULL). - */ + * must ensure that this is less than 64 + * unicode (including the required NULL). + */ BOOL newGuids ) /* TRUE when we need to generate new GUIDs - * of the pool (and internal volume) being loaded. - * This is done as part of AUTO Pool rename - * which is done if our caller detects a duplicate - * pool name. - */ + * of the pool (and internal volume) being loaded. + * This is done as part of AUTO Pool rename + * which is done if our caller detects a duplicate + * pool name. + */ { Pool_s *dupPool; @@ -3332,10 +3297,10 @@ ZfsPool_s *ZFSPOOL_LoadPool( STATUS status; BOOL forceState; BOOL isInstallTime = FALSE; /* OS is being installed. We have - * decided not to upgrade any volumes - * during this time unless specifically - * requested via the 'loadFlag' - */ + * decided not to upgrade any volumes + * during this time unless specifically + * requested via the 'loadFlag' + */ NINT state = 0; #if NSS_DEBUG IS_ENABLED NINT resetAlready = FALSE; @@ -3385,7 +3350,7 @@ ZfsPool_s *ZFSPOOL_LoadPool( if ( uniicmp( poolName, &gZCL_OnlyPoolName[0] ) != 0 ) { aprintf(LRED,MSGNot(" Not loading pool \"%U\" because /OnlyPoolName=%U switch\n"),poolName,&gZCL_OnlyPoolName[0]); - SetErrno(genMsg,zERR_NO_MEMORY); + SetErrno(genMsg,zERR_NO_MEMORY); RTN_PTR(NULL); } } @@ -3409,15 +3374,15 @@ ResetStart: | BEWARE how them changing on you during REDO/UNDO!!! For example, | BEWARE the beast tree special block may change. We handle this | BEWARE today by NOT using the block until AFTER REDO/UNDO. - | BEWARE + | BEWARE | BEWARE We are doing I/O (writes) to the pool even though it is not | BEWARE ACTIVE this is technically ILLEGAL in a cluster environment. - | BEWARE + | BEWARE *-------------------------------------------------------------------------*/ { MediaSuperBlockHeader_s *super; - + /* The super block memory is freed in the ZfsPool destructor */ super = (MediaSuperBlockHeader_s *)zalloc(sizeof(*super)); if ( super == NULL ) @@ -3426,18 +3391,18 @@ ResetStart: RTN_PTR(NULL); } /* FixFixFix(LV,ACI,10) - Validate and other code here in - * load will WRITE to the VOLUME. This is wrong in a CLUSTER. - * Also reading is wrong if we do not re-read at activate - * time I.E. another server could have changed original data on - * us. Do we need an unload of the pool or should load do less??? - * What happens if someone changes the name of the pool on another - * server in the cluster? - * - * We currently throw out the SB Header after load. We may want - * to unload and reload the pool before ACTIVATION? Or maybe just - * in Allen's cluster scan code he could do unload/load on all - * pools that are NOT ACTIVE or MAINTENANCE. This sounds GOOD! - */ + * load will WRITE to the VOLUME. This is wrong in a CLUSTER. + * Also reading is wrong if we do not re-read at activate + * time I.E. another server could have changed original data on + * us. Do we need an unload of the pool or should load do less??? + * What happens if someone changes the name of the pool on another + * server in the cluster? + * + * We currently throw out the SB Header after load. We may want + * to unload and reload the pool before ACTIVATION? Or maybe just + * in Allen's cluster scan code he could do unload/load on all + * pools that are NOT ACTIVE or MAINTENANCE. This sounds GOOD! + */ status = ZFSPOOL_SuperBlockHeaderValidate(genMsg, storagepool, super); if (status != zOK) { /* User will have to re-configure group */ @@ -3451,25 +3416,25 @@ ResetStart: } /** - * This is cheap upgrade code. We fill in the NEW volume ID - * location(SBH_VolumeID) with the old value(SBH_InternalID). - * We do this AIPU here because SBH_VolumeID needs to be correct - * from the get go (e.g. the POOL_BstNew needs (see below)). - * We also fill in the POOL's internal and volume ID. We - * also make reserved2 bigger so we zero out the area. - * - * June 26, 2001 Added check for zero GUID because during - * NW6 install we do not upgrade the pools. This meant - * that on reboot I would give the pool a NEW pool ID. - * The cluster boys did not like this. - */ + * This is cheap upgrade code. We fill in the NEW volume ID + * location(SBH_VolumeID) with the old value(SBH_InternalID). + * We do this AIPU here because SBH_VolumeID needs to be correct + * from the get go (e.g. the POOL_BstNew needs (see below)). + * We also fill in the POOL's internal and volume ID. We + * also make reserved2 bigger so we zero out the area. + * + * June 26, 2001 Added check for zero GUID because during + * NW6 install we do not upgrade the pools. This meant + * that on reboot I would give the pool a NEW pool ID. + * The cluster boys did not like this. + */ if ( (super->hdr.SBH_VersionMediaMajor < AIPU_1ST_6PACK_MEDIA_VERSION) && (LB_GUIDCompare( &super->hdr.SBH_PoolID, &zZERO_GUID) == 0) ) { /* Copy the internal ID (at offset 16) to the - * new location for the volume ID. - */ + * new location for the volume ID. + */ zASSERT( LB_GUIDValidate( &super->hdr.SBH_InternalID ) ); #ifdef USER_GPACHNER // zASSERT("Doing internal ID to Volume ID copy in load pool"==NULL); @@ -3477,17 +3442,17 @@ ResetStart: super->hdr.SBH_VolumeID = super->hdr.SBH_InternalID; zASSERT( LB_GUIDValidate( &super->hdr.SBH_VolumeID ) ); /* The Pool's and Internal Volume's internal IDs must - * match because we write the LPDB and PDB with the - * _IV_ because writes require a volume and not a - * pool. - */ + * match because we write the LPDB and PDB with the + * _IV_ because writes require a volume and not a + * pool. + */ super->hdr.SBH_PoolInternalID = super->hdr.SBH_InternalID; LB_GUIDGenerate( &super->hdr.SBH_PoolID ); zASSERT( LB_GUIDValidate( &super->hdr.SBH_PoolID ) ); /* Fill block 12 of superblocks 0 and 1. These blocks - * can be used for persistent debug information. As - * of 05Jan20001 these two blocks are NOT being used. - */ + * can be used for persistent debug information. As + * of 05Jan20001 these two blocks are NOT being used. + */ if (ZFSPOOL_SuperBlock12Initialize( genMsg, storagepool, super ) != zOK) { ClearErrno( genMsg ); @@ -3498,8 +3463,8 @@ ResetStart: LB_bzero( &super->hdr.reserved2, sizeof( super->hdr.reserved2 ) ); zASSERT( LB_GUIDValidate( &super->hdr.SBH_PoolID ) ); /* Write out the changes we have made to the superblock - * header. - */ + * header. + */ status = ZFSPOOL_SuperBlockUpdate2( genMsg, storagepool, super ); if (status != zOK) { /* Error message already printed. */ @@ -3508,11 +3473,11 @@ ResetStart: } } /* If snapshot request AND the the old name is not - * too long then 'take a snapshot.' - */ + * too long then 'take a snapshot.' + */ if ( snapshot && ( NELEMS( super->hdr.SBH_SS_OriginalName ) > - unilen( snapshotInfo ) ) ) + unilen( snapshotInfo ) ) ) { /* Take a snapshot */ bzero( super->hdr.SBH_SS_OriginalName, sizeof( super->hdr.SBH_SS_OriginalName ) ); @@ -3529,9 +3494,9 @@ ResetStart: LB_GUIDGenerate( &super->hdr.SBH_VolumeID ); zASSERT( LB_GUIDValidate( &super->hdr.SBH_VolumeID ) ); /* In NetWare 6.x, we will clear the SNAPSHOT's NDS Object Ids. Here we do - * the Pool's NDS Object ID and the Internal Volume's NDS Object ID. - * The Pool's LVs are done in ZLSSVOL_LV_Snapshot(). - */ + * the Pool's NDS Object ID and the Internal Volume's NDS Object ID. + * The Pool's LVs are done in ZLSSVOL_LV_Snapshot(). + */ status = ZFSVOL_PDBNDSObjectClear( genMsg, storagepool, (Blknum_t)super->hdr.SBH_PoolDataBlk ); zASSERT( status == zOK ); if (status != zOK) @@ -3560,8 +3525,8 @@ ResetStart: dupPool = COMN_PoolIDLookup( genMsg, &super->hdr.SBH_PoolID, FALSE); if ( dupPool != NULL ) { /* A pool with the same GUID is already loaded we - * better change this pool's GUIDs. - */ + * better change this pool's GUIDs. + */ #ifdef USER_GPACHNER zASSERT("Duplicate Pool ID found auto pool id rename will be done"==NULL); #endif @@ -3574,7 +3539,7 @@ ResetStart: } if ( newGuids ) { /* Generate new GUIDs for pool and internal volume */ - LB_GUIDGenerate( &super->hdr.SBH_PoolID ); + LB_GUIDGenerate( &super->hdr.SBH_PoolID ); zASSERT( LB_GUIDValidate( &super->hdr.SBH_PoolID ) ); LB_GUIDGenerate( &super->hdr.SBH_VolumeID ); zASSERT( LB_GUIDValidate( &super->hdr.SBH_VolumeID ) ); @@ -3625,8 +3590,8 @@ ResetStart: super->hdr.SBH_Name, &super->hdr.SBH_PoolID, zLSS_ID_ZLSS ); /* ZLSS also creates a physical volume which goes back to the - * days when a ZfsPool_s 'is a' ZfsVolume_s. - */ + * days when a ZfsPool_s 'is a' ZfsVolume_s. + */ #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LRED,"%s zlssPool address is %lx inUse is at offset %x\n",WHERE,zlssPool, offsetof( RootBeast_s, useCount) ); #endif @@ -3754,8 +3719,8 @@ ResetStart: } /*--------------------------------------------------------------------------- - | Start initing the pool - *-------------------------------------------------------------------------*/ + | Start initing the pool + *-------------------------------------------------------------------------*/ pool->storagepool = storagepool; storagepool->zfspool = pool; // FixFixFix6 - where should this be done? /* Set up our cross reference pointer between ZLSS Pool and its physical Volume */ @@ -3773,16 +3738,16 @@ ResetStart: zlssPool->ZP_Pool.P_Inode = storagepool->phypool->cp_inode; /*** Here we load in the POOL's persistent infomarion so - *** that the POOL's features are always available. This - *** is very important for the SHARED cluster bit as many - *** pool commands use when the pool is not ACTIVE. - *** - *** As of Dec 2000, the above is no longer TRUE. The - *** shared bit is given to as by the MAL/MM. Although - *** we still load the persistent information to fix - *** SPD 256378. Clustering needs access to the pool's - *** GUID and feature bits when a pool is not ACTIVE. - ***/ + *** that the POOL's features are always available. This + *** is very important for the SHARED cluster bit as many + *** pool commands use when the pool is not ACTIVE. + *** + *** As of Dec 2000, the above is no longer TRUE. The + *** shared bit is given to as by the MAL/MM. Although + *** we still load the persistent information to fix + *** SPD 256378. Clustering needs access to the pool's + *** GUID and feature bits when a pool is not ACTIVE. + ***/ zlssPool->ZP_Version = (super->hdr.SBH_VersionMediaMajor * 0x100L) + super->hdr.SBH_VersionMediaMinor; if ( zlssPool->ZP_Version >= (AIPU_LV_MEDIA_MAJOR*0x100L+AIPU_LV_STEP_PDB_DONE) ) @@ -3794,11 +3759,11 @@ ResetStart: status = ZLSSPOOL_ReadPersistentPoolData( genMsg, zlssPool ); if ( status != zOK ) { /* FixFixFix(LV,ACI,11) - We may wish to set a bit that - * the FEATUREs are not REALLY correct? - */ - /* Or in bits here so we do not WRITE over the - * ZLSSPOOL_PERSISTENT_ELSEWHERE bits. - */ + * the FEATUREs are not REALLY correct? + */ + /* Or in bits here so we do not WRITE over the + * ZLSSPOOL_PERSISTENT_ELSEWHERE bits. + */ zlssPool->ZLSSPOOLenabledFeatures |= ZLSSPOOL_DEFAULT_ENABLED_FEATURES; } #if NSS_DEBUG IS_ENABLED @@ -3808,9 +3773,9 @@ ResetStart: } else { /* We display pool version only if the pool is not - * up to 40.06. This is done to help in any problems - * we have in the field. - */ + * up to 40.06. This is done to help in any problems + * we have in the field. + */ aprintf(NSS_POOL_COLOR,MSG(" Pool layout v%u.%02u\n", 918), (unsigned int)super->hdr.SBH_VersionMediaMajor, (unsigned int)super->hdr.SBH_VersionMediaMinor ); @@ -3818,9 +3783,9 @@ ResetStart: DBG_ScreenAPrintf( "ZLSS.Greg.Pool", WHERE, CYAN,"%s POOL features set to DEFAULT 0x%Lx\n",WHERE,zlssPool->ZLSSPOOLenabledFeatures); #endif /** Not a POOL yet, so use default feature set. - ** Or in bits here so we do not WRITE over the - ** ZLSSPOOL_PERSISTENT_ELSEWHERE bit. - **/ + ** Or in bits here so we do not WRITE over the + ** ZLSSPOOL_PERSISTENT_ELSEWHERE bit. + **/ zlssPool->ZLSSPOOLenabledFeatures |= ZLSSPOOL_DEFAULT_ENABLED_FEATURES; // zlssPool->ZLSSPOOLtotalBlocks = superHeader->hdr.totalblocks; } @@ -3850,13 +3815,13 @@ ResetStart: RTN_PTR(NULL); } /* In the debug system were we allow /reset we must give the - * pool a new GUID because ZLOG does not initialize its file. - * ZLOG detects unwritten blocks when the internalID of the block - * does not match the internalID of the volume. Because the volume's - * volume ID is assigned in VOL_BstNew(), we do another - * VOL_BstNew() so that we get the correct volumeID into - * the pool beast. The internal ID is set to the volume ID below. - */ + * pool a new GUID because ZLOG does not initialize its file. + * ZLOG detects unwritten blocks when the internalID of the block + * does not match the internalID of the volume. Because the volume's + * volume ID is assigned in VOL_BstNew(), we do another + * VOL_BstNew() so that we get the correct volumeID into + * the pool beast. The internal ID is set to the volume ID below. + */ resetAlready = TRUE; goto ResetStart; @@ -3902,8 +3867,8 @@ ResetStart: } else if ( TRUE /*isInstallTime*/ ) /* FixFixFix() - Remove before ship when the GUID/NDS issues are resolved. By Having TRUE we force USER to UPGRADE VOLUMES */ { /* Loader has no specical requests, but it is INSTALL - * time so we will not activate (let upgrade run). - */ + * time so we will not activate (let upgrade run). + */ forceState = TRUE; state = zVOLSTATE_DEACTIVE; if ( verbose ) @@ -3918,25 +3883,25 @@ ResetStart: (void)COMN_PoolEvent( genMsg, &zlssPool->ZLSSPOOLpool, poolName, VOLEVENT_LOAD, verbose, forceState, state ); - X_LATCH( &pool->ZFSPOOLvol.stateLatch ); + X_LATCH( &pool->ZFSPOOLvol.stateLatch ); state = pool->ZFSPOOLstate; /* The STATE that the pool got to */ - UNX_LATCH( &pool->ZFSPOOLvol.stateLatch ); + UNX_LATCH( &pool->ZFSPOOLvol.stateLatch ); if ( state == zVOLSTATE_ACTIVE ) { /* We only work if the pool is ACTIVE. */ - if ( zlssPool->ZP_Version < + if ( zlssPool->ZP_Version < (AIPU_LV_MEDIA_MAJOR*0x100L+AIPU_LV_STEP_4_DONE) ) { /* Media needs to be upgraded */ status = ZLVAIPU_AIPU4001To4006( genMsg, pool, verbose ? VOLMODE_VERBOSE : 0 ); /* The AIPU has unloaded the pool (errors or no errors) - * At most ZLVAIPU_AIPU4001To4006 has done one minor LV upgrade. - * The call to ZFSPOOL_LoadPool() below will recursively put - * us back to above routine to do another minor LV upgrade. - * This recursion is limited to Steps 2A, 2B, 3 and 4. Step - * 1 is done with Step 2A since it is a very simple step. - * In otherwords, ZLVAIPU_AIPU4001To4006() gets called FOUR - * times in the normal process of doing a Logical Volume Auto - * In Place Upgrade (LV AIPU). - */ + * At most ZLVAIPU_AIPU4001To4006 has done one minor LV upgrade. + * The call to ZFSPOOL_LoadPool() below will recursively put + * us back to above routine to do another minor LV upgrade. + * This recursion is limited to Steps 2A, 2B, 3 and 4. Step + * 1 is done with Step 2A since it is a very simple step. + * In otherwords, ZLVAIPU_AIPU4001To4006() gets called FOUR + * times in the normal process of doing a Logical Volume Auto + * In Place Upgrade (LV AIPU). + */ if ( status != zOK ) { errPrintf(WHERE, Module, 1466, @@ -3948,15 +3913,15 @@ ResetStart: RTN_PTR(NULL); } /** - * A successful upgrade requires us to re-load the - * pool. This is because the upgrade has changed - * persistent block numbers and unloaded the 'old' pool. - * The upgade does not re-load the pool because of complexity - * of returning the new pool pointer. It is cleaner - * for us to re-load the pool here. We pass in VERBOSE - * of FALSE so that we do not get multiple messages that - * says we are upgrading the volume. - */ + * A successful upgrade requires us to re-load the + * pool. This is because the upgrade has changed + * persistent block numbers and unloaded the 'old' pool. + * The upgade does not re-load the pool because of complexity + * of returning the new pool pointer. It is cleaner + * for us to re-load the pool here. We pass in VERBOSE + * of FALSE so that we do not get multiple messages that + * says we are upgrading the volume. + */ pool = ZFSPOOL_LoadPool( genMsg, storagepool, FALSE, loadFlag, FALSE, NULL, FALSE ); RTN_PTR(pool); } @@ -3968,38 +3933,38 @@ ResetStart: if ( ResetPools ) { /* We only work if the pool is ACTIVE. */ aprintf(LRED,MSGNot(" ** Re-creating a single LV\n")); - X_LATCH( &pool->ZFSPOOLvol.v_pool->cvsLatch ); + X_LATCH( &pool->ZFSPOOLvol.v_pool->cvsLatch ); (void)ZLSSVOL_LV_Create( genMsg, (Volume_s *)pool, poolName, (QUAD)pool->ZFSPOOLtotalBlocks << pool->ZFSPOOLblockShift, zFTYPE_ZAS_AUTH_MODEL, &zINVALID_GUID, FALSE, NULL, FALSE ); - UNX_LATCH( &pool->ZFSPOOLvol.v_pool->cvsLatch ); + UNX_LATCH( &pool->ZFSPOOLvol.v_pool->cvsLatch ); (void)ZLSSVOL_LV_LoadAll( genMsg, pool, TRUE, FALSE, FALSE ); } #endif } else { /** We did not activate - which is a problem ONLY if - ** we are trying to upgrade the volume. - **/ + ** we are trying to upgrade the volume. + **/ /* Do not give big error messages IF - * 1) We are purposely not upgading OR - * 2) It is install time OR - * 3) The media has already been upgraded - */ + * 1) We are purposely not upgading OR + * 2) It is install time OR + * 3) The media has already been upgraded + */ if ( (loadFlag != ZLSS_PLF_NO_UPGRADE) && (!isInstallTime) && - (zlssPool->ZP_Version < + (zlssPool->ZP_Version < (AIPU_LV_MEDIA_MAJOR*0x100L+AIPU_LV_STEP_4_DONE) ) ) { /*** LV AIPU is designed to work only at load pool time. - *** The main issue here is that block numbers in the - *** superblock are changed during the upgrade. Therefore - *** if we can not upgrade we must fail the load so that - *** the upgrade can be attempted on the 'next' load. A - *** command will be added to let the user attempt a load. - *** This command is called "NSS /ZLSSPoolScan". - *** Generally, is a server is brought up with /autoact=none - *** then no LV AIPU will take place. - ***/ + *** The main issue here is that block numbers in the + *** superblock are changed during the upgrade. Therefore + *** if we can not upgrade we must fail the load so that + *** the upgrade can be attempted on the 'next' load. A + *** command will be added to let the user attempt a load. + *** This command is called "NSS /ZLSSPoolScan". + *** Generally, is a server is brought up with /autoact=none + *** then no LV AIPU will take place. + ***/ switch ( state ) { case zVOLSTATE_UNKNOWN: @@ -4072,11 +4037,11 @@ STATUS ZFSPOOL_SetNewPoolSize( ASSERT_MPKNSS_LOCK(); - zASSERT( pool != NULL ); - zASSERT( storagepool != NULL ); + zASSERT( pool != NULL ); + zASSERT( storagepool != NULL ); zASSERT( pool->ZP_super != NULL ); super = pool->ZP_super; - + DEBUG_PRINTF(TPOOL,DBG_NOINDENT,(LRED,MSGNot("ZFSPOOL_SetNewPoolSize\n"))); /*- find what's missing -*/ if ( storagepool->pooltotalblocks < pool->ZFSPOOLtotalBlocks ) @@ -4096,11 +4061,11 @@ STATUS ZFSPOOL_SetNewPoolSize( if ( templen > 0 ) { /* ZLSS pool has not accounted for segment addition so do it now */ SQUAD blocksInNewPool; /* Number of blocks that are in the - * pool. - */ + * pool. + */ Blknum_t block3n; /* Block number of the first block - * of super block 3n. - */ + * of super block 3n. + */ Blknum_t block4n; /* Block number of super block 4n */ DEBUG_PRINTF(TPOOL,DBG_NOINDENT,(CYAN, @@ -4149,8 +4114,8 @@ STATUS ZFSPOOL_SetNewPoolSize( zASSERT( block4n > block3n ); if ( block3n <= tempstart ) { /* The add is too small, instead of giving an error and - * preventing activation we just do not grow the pool. - */ + * preventing activation we just do not grow the pool. + */ DEBUG_PRINTF(TPOOL,DBG_NOINDENT,(LRED, MSGNot("ZFSPOOL_SetNewPoolSize pool size did NOT increased enough to move superblocks\n"))); return( zOK ); @@ -4161,8 +4126,8 @@ STATUS ZFSPOOL_SetNewPoolSize( /*- Set up a transaction for this operation -*/ xaction = BeginXLocal((void *)pool, BXL_DEFAULT); /*- update the zfspool super block info -*/ - - /*- update the zfspool info -*/ + + /*- update the zfspool info -*/ volLog.delta = templen; pool->ZFSPOOLtotalBlocks = storagepool->pooltotalblocks; volLog.action = VOLINFO_CHANGE_TOT_BLOCKS; @@ -4174,11 +4139,11 @@ STATUS ZFSPOOL_SetNewPoolSize( ZFSVOL_VOL_WriteVolumeLoggedData(&pool->ZFSPOOLvol, &xaction->xaction, &volLog); /* Now we add the number of blocks that the pool is increasing - * by to the 'inUseBlocks'. This is needed because we are - * adding the new space to the pool by freeing the new space. - * When we free the space the Free B-Tree will change the - * 'inUseSpace' back to the correct value. - */ + * by to the 'inUseBlocks'. This is needed because we are + * adding the new space to the pool by freeing the new space. + * When we free the space the Free B-Tree will change the + * 'inUseSpace' back to the correct value. + */ // pool->ZFSPOOLinUseBlocks += templen; zlssPool = (ZlssPool_s *)pool->ZFSPOOLvol.v_pool; zlssPool->ZLSSPOOLbookedInUseBlocks += volLog.delta; @@ -4190,9 +4155,9 @@ STATUS ZFSPOOL_SetNewPoolSize( &xaction->xaction, &volLog); /* Now we can give the new space to the Free B-Tree by - * simply freeing the blocks that are new. We exclude - * the two super blocks from this area. - */ + * simply freeing the blocks that are new. We exclude + * the two super blocks from this area. + */ /*- update the zfspool free extent size -*/ #if NSS_DEBUG IS_ENABLED ClearErrno( genMsg ); /* To many people do not clear error no @@ -4202,13 +4167,13 @@ STATUS ZFSPOOL_SetNewPoolSize( seedext.lengthOfExtent = templen - (blocksInNewPool-block3n); zfsFreeExtent(genMsg, &pool->ZFSPOOLzfsVol, &seedext, xaction); /* FixFixFix5( SPD 189303 ) - Need to handle errors. Mike says you - * can not get an error on frees (he will steal a - * block that is being freed if a split occurs). I saw - * error returns when the Free B-Tree gets an - * error from ZFS_ReadPoolBlk. Need to re-adjust some - * of the Volume counts we just updated. Maybe we - * should call COMN_AbortXLocal (really undo transaction) - */ + * can not get an error on frees (he will steal a + * block that is being freed if a split occurs). I saw + * error returns when the Free B-Tree gets an + * error from ZFS_ReadPoolBlk. Need to re-adjust some + * of the Volume counts we just updated. Maybe we + * should call COMN_AbortXLocal (really undo transaction) + */ zASSERT(seedext.lengthOfExtent == 0); zASSERT(GetErrno(genMsg) == zOK); ClearErrno( genMsg ); @@ -4232,14 +4197,14 @@ STATUS ZFSPOOL_SetNewPoolSize( if ( status != zOK ) { /* FixFixFix5( SPD 189303 ) - what to do on errors!!!! See previous - * fix fix fix item above. - */ - zASSERT( "FixFixFix5( SPD 189303 ) - not handling error condition" + * fix fix fix item above. + */ + zASSERT( "FixFixFix5( SPD 189303 ) - not handling error condition" == NULL ); /* Be very carefull on errors because the super blocks have - * been changed and they will use the new blocks in the - * added area. - */ + * been changed and they will use the new blocks in the + * added area. + */ } @@ -4259,7 +4224,7 @@ STATUS ZFSPOOL_SetNewPoolSize( neededBlocks = storagepool->pooltotalblocks; neededBlocks = ((neededBlocks * ZLOG_REBUILD_BYTES_PER_BLOCK) + (1 << zlogBeast->ZFSLOGblkSizeShift)-1) - >> zlogBeast->ZFSLOGblkSizeShift; + >> zlogBeast->ZFSLOGblkSizeShift; neededBlocks += ZLOG_REBUILD_FUDGE_BLOCKS; #if NSS_DEBUG IS_ENABLED #ifdef USER_GPACHNER @@ -4276,9 +4241,9 @@ neededBlocks *= 4; /* Just to create a rebuild file on 1 gig volume */ neededBlocks = neededBlocks - zlogBeast->ZLB_NumberOfLogBlocks; /* Put extra needed blocks in special rebuild file - * This is done because it is much easier to - * extend than the ZLOG file. - */ + * This is done because it is much easier to + * extend than the ZLOG file. + */ status = ZLSSPOOL_RebuildFileExtend( genMsg, pool, neededBlocks ); } @@ -4291,15 +4256,15 @@ neededBlocks *= 4; /* Just to create a rebuild file on 1 gig volume */ #endif } if ( (zlogBeast == NULL) || (status != zOK) ) - { /* FixFixFix5( SPD 189303 ) - what to do on errors!!!! - * Unless we move - * everthing that has been allocated by other then we - * should just tell user that re-build may get - * mad at them and that they should run re-build to - * make the file bigger. In which case we should continue - * with the segment add. The re-build could be a simple - * switch that enlarges the rebuild file. - */ + { /* FixFixFix5( SPD 189303 ) - what to do on errors!!!! + * Unless we move + * everthing that has been allocated by other then we + * should just tell user that re-build may get + * mad at them and that they should run re-build to + * make the file bigger. In which case we should continue + * with the segment add. The re-build could be a simple + * switch that enlarges the rebuild file. + */ zASSERT( "FixFixFix5( SPD 189303 ) - not handling error condition(OK to do go)" == NULL ); ClearErrno( genMsg ); status = zOK; @@ -4317,7 +4282,7 @@ neededBlocks *= 4; /* Just to create a rebuild file on 1 gig volume */ * ZFSPOOL_SetNewPoolSizeDuringActivation - * Increase the size of the pool if storage size idicates that we * should. This check is done during activation. The purpose is - * to allow the MAL to add segments when we are not active and + * to allow the MAL to add segments when we are not active and * for us to detect this so that we can use the space. * * Caller must - @@ -4327,7 +4292,7 @@ neededBlocks *= 4; /* Just to create a rebuild file on 1 gig volume */ * */ -STATUS ZFSPOOL_SetNewPoolSizeDuringActivation( +STATUS ZFSPOOL_SetNewPoolSizeDuringActivation( struct GeneralMsg_s *genMsg, struct ZfsPool_s *pool ) @@ -4340,7 +4305,7 @@ STATUS ZFSPOOL_SetNewPoolSizeDuringActivation( MSGNot("ZFSPOOL_SetNewPoolSizeDuringActivation\n"))); ASSERT_MPKNSS_LOCK(); storagepool = pool->storagepool; - zASSERT( storagepool != NULL ); + zASSERT( storagepool != NULL ); status = ZFSPOOL_SetNewPoolSize( genMsg, pool, storagepool ); DEBUG_PRINTF(TPOOL,DBG_NOINDENT,(LRED, MSGNot("ZFSPOOL_SetNewPoolSizeDuringActivation(exit)\n"))); @@ -4353,7 +4318,7 @@ STATUS ZFSPOOL_SetNewPoolSizeDuringActivation( * ZFSPOOL_SetNewPoolSizeWhileActive - * Increase the size of the pool if storage size idicates that we * should. This fucntion will only work if ACTIVE. The purpose is - * to allow the MAL to add segments when we are ACTIVE + * to allow the MAL to add segments when we are ACTIVE * so that we can use the space right away. * * Caller must - @@ -4369,7 +4334,7 @@ STATUS ZFSPOOL_SetNewPoolSizeWhileActive( ZfsPool_s *pool; STATUS status; - + DEBUG_PRINTF(TPOOL,DBG_NOINDENT,(LRED, MSGNot("ZFSPOOL_SetNewPoolSizeWhileActive\n"))); ASSERT_MPKNSS_LOCK(); @@ -4384,7 +4349,7 @@ STATUS ZFSPOOL_SetNewPoolSizeWhileActive( return( status ); } - X_LATCH( &pool->ZFSPOOLvol.stateLatch ); + X_LATCH( &pool->ZFSPOOLvol.stateLatch ); if ( pool->ZFSPOOLstate == zVOLSTATE_ACTIVE ) { /* We only work if the pool is active ACTIVE state. */ @@ -4396,7 +4361,7 @@ STATUS ZFSPOOL_SetNewPoolSizeWhileActive( status = zFAILURE; } - UNX_LATCH( &pool->ZFSPOOLvol.stateLatch ); + UNX_LATCH( &pool->ZFSPOOLvol.stateLatch ); DEBUG_PRINTF(TPOOL,DBG_NOINDENT,(LRED, MSGNot("ZFSPOOL_SetNewPoolSizeWhileActive(exit)\n"))); return( status ); @@ -4406,15 +4371,15 @@ STATUS ZFSPOOL_SetNewPoolSizeWhileActive( #if 0 /** - * This is code that attempts to GROUP user buffer writes - * so that we get some better elevator performance. On initial - * testings this actually slowed down Roger's 5000 4K file - * restore. When I have time I will re-address so to find out - * why. My guess is that 'IMPORTANT' I/Os got queued up after - * the users blocks so we actually slowed down. After the - * COPY ON XLATCH code is complete I will try again. Reads will - * still be delayed though. - */ + * This is code that attempts to GROUP user buffer writes + * so that we get some better elevator performance. On initial + * testings this actually slowed down Roger's 5000 4K file + * restore. When I have time I will re-address so to find out + * why. My guess is that 'IMPORTANT' I/Os got queued up after + * the users blocks so we actually slowed down. After the + * COPY ON XLATCH code is complete I will try again. Reads will + * still be delayed though. + */ #define ZLOG_COMBINE 100 Agent_s *gJunk[ZLOG_COMBINE]; int gJunkIndex = 0; @@ -4561,12 +4526,11 @@ STATUS ZFSPOOL_VOL_FlushSystemBeasts( ZfsPool_s *pool = (ZfsPool_s *)pool_LX; STATUS status; STATUS status2; - zfspool_flush_system_beasts_func_t parentFunc; + statusfunc_t parentFunc; ASSERT_MPKNSS_LOCK(); DEBUG_PRINTF(TPOOL,DBG_NOINDENT,(CYAN,MSGNot("CVS@ZFSPOOL_FlushSystemBeasts\n"))); - parentFunc = (zfspool_flush_system_beasts_func_t)COMN_GetNextParentVolumeComnOp(pool->ZFSPOOLbeastClass, - COMNVOLOPS_INDEX(VOL_flushSystemBeasts), - (statusfunc_t)ZFSPOOL_VOL_FlushSystemBeasts); + parentFunc = COMN_GetNextParentVolumeComnOp(pool->ZFSPOOLbeastClass, + COMNVOLOPS_INDEX(VOL_flushSystemBeasts),ZFSPOOL_VOL_FlushSystemBeasts); zASSERT(parentFunc != NULL); @@ -4580,16 +4544,16 @@ STATUS ZFSPOOL_VOL_FlushSystemBeasts( status2 = ZFSPOOL_DoFlushSystemBeasts(genMsg,pool,FALSE); /* If our flush did not get and error, but the parent call - * did then return the parent error. - */ + * did then return the parent error. + */ if ( (status2 == zOK) && (status != zOK) ) { SetErrno( genMsg, status ); return( zFAILURE ); } /* Return our error or zOK if use and parents both returned - * zOK. - */ + * zOK. + */ return( status ); } @@ -4623,20 +4587,20 @@ BOOL ZFSPOOL_PoolLoadSupported( MediaSuperBlockHeader_s *superHeader ) { if ( (superHeader->hdr.SBH_VersionMediaMajor == 34) || - (superHeader->hdr.SBH_VersionMediaMajor == 35) || - (superHeader->hdr.SBH_VersionMediaMajor == 36) || - (superHeader->hdr.SBH_VersionMediaMajor == 39) || - (superHeader->hdr.SBH_VersionMediaMajor == AIPU_NAKOMA_MEDIA_MAJOR) || - ( (superHeader->hdr.SBH_VersionMediaMajor == AIPU_LV_MEDIA_MAJOR) && - ( (superHeader->hdr.SBH_VersionMediaMinor < 50) || - (superHeader->hdr.SBH_VersionMediaMinor == 84) || - (superHeader->hdr.SBH_VersionMediaMinor == 85) || - (superHeader->hdr.SBH_VersionMediaMinor == 86) || - (superHeader->hdr.SBH_VersionMediaMinor == 87) || - (superHeader->hdr.SBH_VersionMediaMinor == 88) + (superHeader->hdr.SBH_VersionMediaMajor == 35) || + (superHeader->hdr.SBH_VersionMediaMajor == 36) || + (superHeader->hdr.SBH_VersionMediaMajor == 39) || + (superHeader->hdr.SBH_VersionMediaMajor == AIPU_NAKOMA_MEDIA_MAJOR) || + ( (superHeader->hdr.SBH_VersionMediaMajor == AIPU_LV_MEDIA_MAJOR) && + ( (superHeader->hdr.SBH_VersionMediaMinor < 50) || + (superHeader->hdr.SBH_VersionMediaMinor == 84) || + (superHeader->hdr.SBH_VersionMediaMinor == 85) || + (superHeader->hdr.SBH_VersionMediaMinor == 86) || + (superHeader->hdr.SBH_VersionMediaMinor == 87) || + (superHeader->hdr.SBH_VersionMediaMinor == 88) ) - ) - ) + ) + ) { return( TRUE ); } @@ -4657,10 +4621,10 @@ BOOL ZFSPOOL_PoolVerifySupported( MediaSuperBlockHeader_s *superHeader ) { if ( (superHeader->hdr.SBH_VersionMediaMajor == AIPU_NAKOMA_MEDIA_MAJOR) || - ( (superHeader->hdr.SBH_VersionMediaMajor == AIPU_LV_MEDIA_MAJOR) && - (superHeader->hdr.SBH_VersionMediaMinor >= AIPU_LV_STEP_4_DONE) - ) - ) + ( (superHeader->hdr.SBH_VersionMediaMajor == AIPU_LV_MEDIA_MAJOR) && + (superHeader->hdr.SBH_VersionMediaMinor >= AIPU_LV_STEP_4_DONE) + ) + ) { return( TRUE ); } @@ -4683,7 +4647,7 @@ BOOL ZFSPOOL_PoolVerifySupported( MediaSuperBlockHeader_s *superHeader ) * it would have rejected the Change Pool State if this pool is being * used by another server in the cluster. ***************************************************************************/ -STATUS ZFSPOOL_LoadPersistentPool( +STATUS ZFSPOOL_LoadPersistentPool( GeneralMsg_s *genMsg, ZfsPool_s *pool, NINT mode, /* Must be VOLMODE_xxx define */ @@ -4712,9 +4676,9 @@ STATUS ZFSPOOL_LoadPersistentPool( zASSERT( zlssPool != NULL ); /* If either of this ASSERTs occur someone added/removed an - * item to the structure(s) without adjusting the reserved area - * to ensure that this structures are 256 bytes long. - */ + * item to the structure(s) without adjusting the reserved area + * to ensure that this structures are 256 bytes long. + */ zASSERT( sizeof( PersistentPool_s ) == 256 ); zASSERT( sizeof( LoggedPersistentPool_s ) == 256 ); zASSERT( sizeof( PersistentZlssPool_s ) == 256 ); @@ -4758,14 +4722,14 @@ STATUS ZFSPOOL_LoadPersistentPool( RTN_STATUS( zFAILURE ); } /** - * This is an attempt to catch SNAPSHOT being turned - * on/off from another cluster. In the end, it would be much - * better for the POOL to be shutdown and reloaded so - * that the snapshot and the shared bit are correct without - * having special cluster code in ZLSS. I.E. if someone - * in the cluster modifies the snapshot or shared features - * then the other servers should shutdown and reload the pool. - */ + * This is an attempt to catch SNAPSHOT being turned + * on/off from another cluster. In the end, it would be much + * better for the POOL to be shutdown and reloaded so + * that the snapshot and the shared bit are correct without + * having special cluster code in ZLSS. I.E. if someone + * in the cluster modifies the snapshot or shared features + * then the other servers should shutdown and reload the pool. + */ if ( superHeader->hdr.SBH_SS_Enabled == ZLSS_SBH_SNAPSHOT_ENABLED ) { zlssPool->ZP_Snapshot = TRUE; @@ -4820,7 +4784,7 @@ STATUS ZFSPOOL_LoadPersistentPool( if ( !(flags & LPP_FLAGS_NO_VERSION_MESSAGES) ) { COMN_GetVolumeName(&aStack->dummyGenMsg,(Volume_s *)pool,aStack->poolName,NELEMS(aStack->poolName)); - + aprintf(LRED,MSG(" ** Volume \"%U\" not activated.\n", 867), aStack->poolName); errPrintf(WHERE, Module, 1445, MSG("ZLSS supports volume layout v%u.%02u, \"%U\" is v%u.%02u.\n" @@ -4850,8 +4814,8 @@ STATUS ZFSPOOL_LoadPersistentPool( #endif /* The super blocks checked out OK, so clear the repair's - * flag. - */ + * flag. + */ pool->ZP_RepairFlags &= ~ZP_REPAIRFLAGS_REBUILD_POOL_SUPER_BLOCKS; zASSERT( superHeader->hdr.SBH_LoggedVolumeDataBlk != 0 ); @@ -4863,20 +4827,20 @@ STATUS ZFSPOOL_LoadPersistentPool( zASSERT( superHeader->hdr.SBH_SystemBeastBlkNum != 0 ); pool->ZFSPOOLzfsvolp.PZV_systemBeastBlkNum = superHeader->hdr.SBH_SystemBeastBlkNum; pool->ZFSPOOLzfsvol.ZV_systemBeastBlkNum = superHeader->hdr.SBH_SystemBeastBlkNum; - + /* Set up OLD volume ID because it is only stored in the - * superblock. This is helpful in that rebuild never - * blows away the superblock unlike the Pool's Pool Data - * Blocks (LPDB and PDB) and Volume Data Blocks (LVDB and VDB). */ + * superblock. This is helpful in that rebuild never + * blows away the superblock unlike the Pool's Pool Data + * Blocks (LPDB and PDB) and Volume Data Blocks (LVDB and VDB). */ pool->ZFSPOOLoldInternalID = superHeader->hdr.SBH_OldInternalID; /** - * Pool data blocks do not exist until media 40.03 so skip - * reading pool blocks until then. To get around a low space - * ALERT when upgrading the media to 40.01 the total block - * item is initialized to the value stored in the super block. - */ + * Pool data blocks do not exist until media 40.03 so skip + * reading pool blocks until then. To get around a low space + * ALERT when upgrading the media to 40.01 the total block + * item is initialized to the value stored in the super block. + */ zlssPool->ZP_Version = (superHeader->hdr.SBH_VersionMediaMajor * 0x100L) + superHeader->hdr.SBH_VersionMediaMinor; @@ -4924,20 +4888,20 @@ STATUS ZFSPOOL_LoadPersistentPool( pool->zfsVol.ZLSSVOLmediaFormatMajorCreate, pool->zfsVol.ZLSSVOLmediaFormatMinorCreate ); DBG_DebugPrintf(CYAN, MSGNot("%s activation count %ld of volume 0x%lx\n"), - WHERE, pool->zfsVol.ZFSVOLactivationCount, &pool->zfsVol); + WHERE, pool->zfsVol.ZFSVOLactivationCount, &pool->zfsVol); #endif zASSERT( LB_GUIDValidate( &pool->zfsVol.ZLSSVOLvolumeID ) ); // zASSERT( LB_GUIDCompare( &pool->zfsVol.p.PZV_volumeID, &pool->zfsVol.ZLSSVOLvolumeID ) == 0 ); /* Ensure that the duplicate copy of the GUID is in the VDB. - * Specifically this helps the LV delete code because the delete - * code does not update the GUID in the VDB. Note that the GUID - * in the VDB is really a backup that re-link could use. Really - * not an issue with Internal Volumes as they do not get deleted - * in the same since. Have here to be consistent. - */ + * Specifically this helps the LV delete code because the delete + * code does not update the GUID in the VDB. Note that the GUID + * in the VDB is really a backup that re-link could use. Really + * not an issue with Internal Volumes as they do not get deleted + * in the same since. Have here to be consistent. + */ pool->zfsVol.p.PZV_volumeID = pool->zfsVol.ZLSSVOLvolumeID; - + #if SUPERBLOCK_SB_VM_MEDIA_MAJOR != 43 #error "Check to see if we still need to do this conversion" #endif @@ -4955,44 +4919,44 @@ STATUS ZFSPOOL_LoadPersistentPool( { /* Supply defaults for all but SALVAGE, ... */ pool->ZFSPOOLenabledAttributes = (ZLSS_DEFAULT_ENABLED_ATTRIBUTES & - ~zATTR_SALVAGE ); + ~zATTR_SALVAGE ); /* Get SALVAGE from old attributes. No other attribute bits were - * valid in the old volAttributes, and in fact there was a bug where - * the other bits could have been total GARBAGE. That is why we - * mask out the salvage bit and ignore the rest of the old bits. */ + * valid in the old volAttributes, and in fact there was a bug where + * the other bits could have been total GARBAGE. That is why we + * mask out the salvage bit and ignore the rest of the old bits. */ /* in SP4 we fixed the volume to not have garbage bits and set - * the state attributes bit VOLSTATEATTR_FIXEDATTR after fixing - * the volume. Copy all bits from oldVolAttributes if the volume - * has been fixed, otherwise copy only the salvage bit - */ + * the state attributes bit VOLSTATEATTR_FIXEDATTR after fixing + * the volume. Copy all bits from oldVolAttributes if the volume + * has been fixed, otherwise copy only the salvage bit + */ if (pool->ZFSPOOLvol.p.stateAttributes & VOLSTATEATTR_FIXEDATTR) { - pool->ZFSPOOLenabledAttributes |= + pool->ZFSPOOLenabledAttributes |= pool->ZFSPOOLoldVolAttributes; } else { - pool->ZFSPOOLenabledAttributes |= + pool->ZFSPOOLenabledAttributes |= (pool->ZFSPOOLoldVolAttributes & zATTR_SALVAGE); } /* Zero the old LONG so in the future we can reuse it for something - * else. */ + * else. */ pool->ZFSPOOLoldVolAttributes = 0; } } /** - * This is cheap upgrade code. We fill in the VDB copy - * of the volume ID from the superblock. The superblock - * volume ID was made correct in ZFSPOOL_LoadPool. - */ + * This is cheap upgrade code. We fill in the VDB copy + * of the volume ID from the superblock. The superblock + * volume ID was made correct in ZFSPOOL_LoadPool. + */ if ( !LB_GUIDValidate( &pool->ZFSPOOLzfsvolp.PZV_volumeID ) ) { /* As long as the VDB GUID is invalid place the - * super block one into it. We do this as we don't - * go out of are way to write the PZV so if we - * crash the PZV may not have been made persistent. - */ + * super block one into it. We do this as we don't + * go out of are way to write the PZV so if we + * crash the PZV may not have been made persistent. + */ pool->ZFSPOOLzfsvolp.PZV_volumeID = superHeader->hdr.SBH_PoolID; } pool->ZFSPOOLsupportedAttributes = ZLSS_SUPPORTED_ATTRIBUTES; @@ -5029,13 +4993,13 @@ STATUS ZFSPOOL_LoadPersistentPool( * information about how it uses the activation count. */ /* In rebuild, we are loading the pool manually and dont play the purge log, - * we can't write the data blocks out yet because we have not yet mapped the - * blocks in the system, but we will write it later after we map the blocks - * and know which blocks we can use for the pool's data blocks - */ + * we can't write the data blocks out yet because we have not yet mapped the + * blocks in the system, but we will write it later after we map the blocks + * and know which blocks we can use for the pool's data blocks + */ if( !(pool->ZP_RepairFlags & ZP_REPAIRFLAGS_MANUAL_POOL_LOAD) ) { - ZFSVOL_WritePersistentVolumeData(&pool->zfsVol); + ZFSVOL_WritePersistentVolumeData(&pool->zfsVol); } /* Point POOL to super block's memory space */ @@ -5051,7 +5015,7 @@ STATUS ZFSPOOL_LoadPersistentPool( * of ERROR but needs to clean up anyway (free all resources). */ -void ZFSPOOL_UnloadPersistentPool( +void ZFSPOOL_UnloadPersistentPool( ZfsPool_s *pool, NINT mode ) @@ -5074,8 +5038,8 @@ void ZFSPOOL_UnloadPersistentPool( cacheTossAll(&pool->ZFSPOOLmycache ); /* The ZLSS Pool is used to do I/O on the logged and non-logged - * pool data blocks. - */ + * pool data blocks. + */ X_LATCH(&zlssPool->ZLSSPOOLbeastLatch); zlssPool->ZLSSPOOLroot.bstState |= BST_STATE_FULL_FLUSH; cacheFlushMyCacheBufs(&zlssPool->ZLSSPOOLmycache ); @@ -5088,20 +5052,20 @@ void ZFSPOOL_UnloadPersistentPool( pool->ZP_super = NULL; // Required because of ZfsPool destructor /* - * pool->zfsVol.p.PZV_loggedVolumeDataBlk = 0; - * pool->zfsVol.p.PZV_volumeDataBlk = 0; - * zlssPool->ZP_p.PZP_loggedPoolDataBlk = 0; - * zlssPool->ZP_p.PZP_poolDataBlk = 0; - * - * Zero all the persistent data - required for four commented - * out lines above, but a very good idea for all other fields. - * Note that we will not write either volume data block if - * their block number is 0. - * - * As of September 22, 2000 we always have the POOL's feature - * available no matter the STATE of the pool. Therefore, save - * off and restore around the bzeros below. - */ + * pool->zfsVol.p.PZV_loggedVolumeDataBlk = 0; + * pool->zfsVol.p.PZV_volumeDataBlk = 0; + * zlssPool->ZP_p.PZP_loggedPoolDataBlk = 0; + * zlssPool->ZP_p.PZP_poolDataBlk = 0; + * + * Zero all the persistent data - required for four commented + * out lines above, but a very good idea for all other fields. + * Note that we will not write either volume data block if + * their block number is 0. + * + * As of September 22, 2000 we always have the POOL's feature + * available no matter the STATE of the pool. Therefore, save + * off and restore around the bzeros below. + */ features = zlssPool->ZLSSPOOLenabledFeatures; @@ -5151,7 +5115,7 @@ STATUS ZFSPOOL_VOL_CommandFunction( { ZfsPool_s *beast = (ZfsPool_s *)beast_LX; - zfspool_command_func_t parentFunc; + statusfunc_t parentFunc; STATUS status; zASSERT( COMN_IsDerivedFrom(beast, zFTYPE_ZLSS_ZFSPOOL) ); @@ -5180,9 +5144,9 @@ STATUS ZFSPOOL_VOL_CommandFunction( /* Even though we have no data to return our derived from objects may */ ASSERT_LATCH( &beast->ZFSPOOLvol.stateLatch ); COMN_USE_BEAST( &beast->ZFSPOOLroot ); /* Get a use count for parent */ - parentFunc = (zfspool_command_func_t)COMN_GetNextParentVolumeComnOp( beast->ZFSPOOLbeastClass, + parentFunc = COMN_GetNextParentVolumeComnOp( beast->ZFSPOOLbeastClass, COMNVOLOPS_INDEX(VOL_commandFunction), - (statusfunc_t)ZFSPOOL_VOL_CommandFunction ); + ZFSPOOL_VOL_CommandFunction ); status = parentFunc( genMsg, beast, functionNumber, pCD, parmLen, parm, dataLen, commandData, offset, retBufLen, retBuf, retLen ); @@ -5298,7 +5262,7 @@ CommonVolumeOps_s ZFSPOOL_ComnVolOps = NULL, /* VOL_lookupMFLEntry */ NULL, /* VOL_enumerateMFL */ NULL, /* VOL_administerMFL */ - ZFSPOOL_VOL_CommandFunction, /* VOL_commandFunction */ + ZFSPOOL_VOL_CommandFunction, /* VOL_commandFunction */ NULL, /* VOL_getDirQuotaInfo */ NULL, /* VOL_setDirQuota */ @@ -5352,14 +5316,14 @@ File_s *ZLSSPOOL_RebuildFileCreate( rebuildBeast->FILEzid = ZFSPOOL_REBUILDFILE_ZID; rebuildBeast->FILEfirstParentZid = zINVALID_ZID; - rebuildBeast->FILEaccessedTime = - rebuildBeast->FILEcreatedTime = - rebuildBeast->FILEmodifiedTime = + rebuildBeast->FILEaccessedTime = + rebuildBeast->FILEcreatedTime = + rebuildBeast->FILEmodifiedTime = rebuildBeast->FILEmetaDataModifiedTime = GetUTCTime(); rebuildBeast->FILEarchivedTime = INVALID_UTC_TIME; - rebuildBeast->FILEownerID = + rebuildBeast->FILEownerID = rebuildBeast->FILEmodifierID = rebuildBeast->FILEmetaDataModifierID = zSUPERVISOR_ID; @@ -5371,8 +5335,8 @@ File_s *ZLSSPOOL_RebuildFileCreate( BEASTHASH_Insert(&rebuildBeast->FILEroot); DQ_RMV(&rebuildBeast->FILEroot, volLink); /* Now write into the beastTree so that the space for them - * will be allocated. - */ + * will be allocated. + */ X_LATCH(&rebuildBeast->FILEbeastLatch); packedSize = BST_getPackedSize(&rebuildBeast->FILEroot); xaction = BeginXLocal(rebuildBeast->FILEvolume,BXL_DEFAULT); @@ -5388,10 +5352,10 @@ File_s *ZLSSPOOL_RebuildFileCreate( /** Insert beast now does the cleanup on error conditions. ** We have no way to tell if the error was before or after the pack was ** called. - ** + ** ** BST_noPackCleanup(&rebuildBeast->FILEroot); **/ - COMN_UnlatchAndRelease(&rebuildBeast, XLATCHED); + COMN_UnlatchAndRelease(&rebuildBeast, XLATCHED); return( NULL ); } return( rebuildBeast ); @@ -5430,7 +5394,7 @@ STATUS ZLSSPOOL_RebuildFileExtend( DEBUG_PRINTF(TPOOL,DBG_NOINDENT,(CYAN, MSGNot("Looking for rebuild file\n"))); rebuildBeast = COMN_LookupByZid(genMsg, &pool->ZFSPOOLvol, - ZFSPOOL_REBUILDFILE_ZID, XLATCHED, TRUE); + ZFSPOOL_REBUILDFILE_ZID, XLATCHED, TRUE); /* On success the rebuildBeast is XLATCHED */ if ( rebuildBeast == NULL ) { @@ -5465,10 +5429,10 @@ STATUS ZLSSPOOL_RebuildFileExtend( COMN_MARK_BEAST_DIRTY( &rebuildBeast->FILEroot); if (buffer == NULL) { /* Note - the file has been partially extended - * in some error cases. This is the reason we - * require the caller to pass in how big should - * we be VERSES how big a segement was added. - */ + * in some error cases. This is the reason we + * require the caller to pass in how big should + * we be VERSES how big a segement was added. + */ zASSERT( "Unit Test Assert - Extend rebuild file failed (ok to do go)" == NULL ); status = zFAILURE; goto error_closeFile; @@ -5556,12 +5520,12 @@ void ZFSPOOL_CopyLogFileToVolume( startOffset = 0; /* Turn off IO logging. We can not have the circular pointers - * or data change on us when we are writing. - */ + * or data change on us when we are writing. + */ saveLogState = gZLSSPoolIOLogDo; gZLSSPoolIOLogDo = FALSE; - + gZLSSPoolIOHeader->ZPIOH_SignatureMajor = 0x58595451; gZLSSPoolIOHeader->ZPIOH_SignatureMinor = 0x58303030; gZLSSPoolIOHeader->ZPIOH_VersionMajor = 1; @@ -5570,9 +5534,9 @@ void ZFSPOOL_CopyLogFileToVolume( gZLSSPoolIOHeader->ZPIOH_Pws = gZLSSPoolIOHeader->ZPIOH_Prs + sizeof( gZLSSPRS ); gZLSSPoolIOHeader->ZPIOH_DataOffset = gZLSSPoolIOHeader->ZPIOH_Pws + sizeof( gZLSSPWS ); // gZLSSPoolIOHeader->ZPIOH_Servername; -// gZLSSPoolIOHeader->ZPIOH_UTCTime= ; - gZLSSPoolIOHeader->ZPIOH_Start= gZLSSPoolIOLogStart; - gZLSSPoolIOHeader->ZPIOH_Next = gZLSSPoolIOLogNext; +// gZLSSPoolIOHeader->ZPIOH_UTCTime= ; + gZLSSPoolIOHeader->ZPIOH_Start= gZLSSPoolIOLogStart; + gZLSSPoolIOHeader->ZPIOH_Next = gZLSSPoolIOLogNext; gZLSSPoolIOHeader->ZPIOH_Size = gZLSSPoolIOLogSize; gZLSSPoolIOHeader->ZPIOH_ZSTOREMajorVersion = ZSTORE_VersionInfo.majorVersion; gZLSSPoolIOHeader->ZPIOH_ZSTOREMinorVersion = ZSTORE_VersionInfo.minorVersion; @@ -5627,7 +5591,7 @@ STATUS doZLSSIOStatsSave( UNUSED_PARAM(userParm); ZFSPOOL_CopyLogFileToVolume( "SYS", 0 ); - + MPKNSS_UNLOCK(); return zOK; } @@ -5656,7 +5620,7 @@ LangEnabledStruct_s ZFSPOOL_ZidToNameLong[ZLSS_PRS_SB_COUNT] = { /* * ZLSSPOOL_DisplayIOStatistics() - * This function displays ZLSS Physical I/O statistics to the screen. - * + * * Notes - * A QUAD is 19 digits at most in decimal. */ @@ -5693,7 +5657,7 @@ void ZLSSPOOL_DisplayIOStatistics( totalReads += read->PRS_SystemBeast[i]; totalWrites += write->PWS_SystemBeast[i]; } - } + } if ( (read->PRS_SuperBlock != 0) || ( write->PWS_SuperBlock != 0 ) ) { aprintf(LGREEN, MSGNot("%25.25s %19Lu %19Lu\n"), @@ -5770,7 +5734,7 @@ void ZLSSPOOL_DisplayIOStatisticsPool( unicode_t *poolName, ZlssPool_s *zlssPool /* * ZLSSPOOL_ResetIOStatistics() - * This function resets the ZLSS Physical I/O statistics. - * + * */ void ZLSSPOOL_ResetIOStatistics( @@ -5821,7 +5785,7 @@ void ZLSSPOOL_ResetIOStatisticsPool( unicode_t *poolName, ZlssPool_s *zlssPool ) * This function supports the hidden command to display ZLSS Physical * I/O statistics. This command is used internally to gather I/O * information to help in making performance changes to ZLSS. - * + * * These statistics are for ALL pools that the ZLSS owns. */ @@ -5843,7 +5807,7 @@ STATUS doZLSSPoolIOStatistics( if ( uniicmp( (unicode_t *)switchDef->ret_value, MSGNot(L"_Summary") ) == 0 ) { ZLSSPOOL_DisplayIOStatisticsGlobal( ); - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return( zOK ); } pool = COMN_PoolNameLookup( &dummyGenMsg, (unicode_t *)switchDef->ret_value, @@ -5884,7 +5848,7 @@ STATUS doZLSSPoolIOStatistics( printf(MSGNot("Pool \"%U\" not found.\n"), (unicode_t *)switchDef->ret_value ); } - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return zOK; } /* End of doZLSSPoolIOStatistics() */ @@ -5894,7 +5858,7 @@ STATUS doZLSSPoolIOStatistics( * This function supports the hidden command to display ZLSS Physical * I/O statistics. This command is used internally to gather I/O * information to help in making performance changes to ZLSS. - * + * * These statistics are for ALL pools that the ZLSS owns. */ @@ -5915,7 +5879,7 @@ STATUS doZLSSPoolIOReset( if ( uniicmp( (unicode_t *)switchDef->ret_value, MSGNot(L"_Summary") ) == 0 ) { ZLSSPOOL_ResetIOStatisticsGlobal( ); - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return( zOK ); } pool = COMN_PoolNameLookup( &dummyGenMsg, (unicode_t *)switchDef->ret_value, @@ -5935,9 +5899,9 @@ STATUS doZLSSPoolIOReset( // X_LATCH( &zlssPool->ZLSSPOOLpool.stateLatch ); ZLSSPOOL_ResetIOStatisticsPool( (unicode_t *)switchDef->ret_value, zlssPool ); /* Indicate when the reset command was done. This - * is used to see if should UNPACK the statistics information - * at pool activate time(in zlog_CommonCreateAndOpen). - */ + * is used to see if should UNPACK the statistics information + * at pool activate time(in zlog_CommonCreateAndOpen). + */ zlssPool->ZP_StatisticsResetCommandUTCTime = zlssPool->ZP_StatisticsResetUTCTime; // UN_XLATCH( &zlssPool->ZLSSPOOLpool.stateLatch ); @@ -5948,7 +5912,7 @@ STATUS doZLSSPoolIOReset( printf(MSGNot("Pool \"%U\" not found.\n"), (unicode_t *)switchDef->ret_value ); } - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return zOK; } /* End of doZLSSPoolIOReset() */ @@ -5956,7 +5920,7 @@ STATUS doZLSSPoolIOReset( /* * ZLSSPOOL_VolumeUpgrade() - - * This function upgrades a specific ZLSS Volume from NSS 2.x to + * This function upgrades a specific ZLSS Volume from NSS 2.x to * NSS 3.00. * * Note: This function releases the pool object. @@ -6005,23 +5969,23 @@ void ZLSSPOOL_VolumeUpgrade( free( as ); return; } - X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); state = zlssPool->ZLSSPOOLstate; - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); if ( state != zVOLSTATE_DEACTIVE ) { printf( MSG("Volume %U must be in the DEACTIVE state to upgrade. Use the\n" - "command \"NSS /poolDeactivate=pool name\" to deactivate the volume.\n",518), - as->name); + "command \"NSS /poolDeactivate=pool name\" to deactivate the volume.\n",518), + as->name); COMN_Release( &pool ); free( as ); return; } /* This is a kludge so that the Cluster Team does not have to - * change their scripts (to call a non prompting upgrade). - * We look for their thread name and if them we do not prompt. - */ + * change their scripts (to call a non prompting upgrade). + * We look for their thread name and if them we do not prompt. + */ cluster = FALSE; if ( kGetThreadName(kCurrentThread(), as->threadName, sizeof(as->threadName) ) == kSUCCESS ) { @@ -6033,15 +5997,15 @@ void ZLSSPOOL_VolumeUpgrade( if ( cluster ) { /* If CLUSTER software is asking us to do the upgrade then - * we do as we are not allowed to ask questions as they - * are running in a script. - */ + * we do as we are not allowed to ask questions as they + * are running in a script. + */ upgrade = TRUE; } else { -// ZOS_UnformattedOutputWithAttribute(COMN_Resource.consoleScreenID, YELLOW, - aprintf( YELLOW, +// ZOS_UnformattedOutputWithAttribute(COMN_Resource.consoleScreenID, YELLOW, + aprintf( YELLOW, MSG("Before proceeding, make sure that all processes relating to the\n" "NetWare 65 upgrade have completed. For more information see the\n" "Novell Storage Services Administration Guide at\n" @@ -6062,8 +6026,8 @@ void ZLSSPOOL_VolumeUpgrade( (void)ZLSSCON_Upgrade( genMsg, zfsPool ); } zfsPool = NULL; /* Pool has been unloaded and reloaded so - * can not use our old pointer. - */ + * can not use our old pointer. + */ free( as ); return; } /* End of ZLSSPOOL_VolumeUpgrade() */ @@ -6071,7 +6035,7 @@ void ZLSSPOOL_VolumeUpgrade( /* * doZLSSVolumeUpgrade() - - * This function supports the command to upgrade a specific ZLSS Volume + * This function supports the command to upgrade a specific ZLSS Volume * (or all volumes) from NSS 2.x to NSS 3.00. This is needed if LV AIPU fails. * * Notes - @@ -6101,23 +6065,23 @@ STATUS doZLSSVolumeUpgrade( { SET_FOREACHBLOCKING(&NSSMasterPoolList, pool, Pool_s, masterPoolLink) { /*** You MUST NOT use continue in this loop because the macro - *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called - *** every time through the loop. Technically, you - *** can use a continue BEFORE any blocking calls. - ***/ + *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called + *** every time through the loop. Technically, you + *** can use a continue BEFORE any blocking calls. + ***/ COMN_USE_BEAST(&pool->POOLroot); ZLSSPOOL_VolumeUpgrade(&genMsg, pool); ClearErrno(&genMsg); - SET_FOREACHBLOCKINGEND(&NSSMasterPoolList, pool, Pool_s, + SET_FOREACHBLOCKINGEND(&NSSMasterPoolList, pool, Pool_s, masterPoolLink); } } else { - pool = COMN_PoolNameLookup(&genMsg, (unicode_t *)switchDef->ret_value, + pool = COMN_PoolNameLookup(&genMsg, (unicode_t *)switchDef->ret_value, FALSE /* NOT only active */, NULL); - if (pool != NULL) - { + if (pool != NULL) + { ZLSSPOOL_VolumeUpgrade(&genMsg, pool); } else @@ -6126,9 +6090,9 @@ STATUS doZLSSVolumeUpgrade( "/ZLSSPoolScan\" to load the volume.\n",984), (unicode_t *)switchDef->ret_value ); } - + } - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return zOK; } #endif @@ -6148,7 +6112,7 @@ STATUS doZLSSVolumeUpgrade( * volume name SYS appears to be used a lot. */ -STATUS ZFSPOOL_Snapshot( +STATUS ZFSPOOL_Snapshot( GeneralMsg_s *genMsg, ZfsPool_s *zfsPool ) @@ -6164,7 +6128,7 @@ STATUS ZFSPOOL_Snapshot( ZFSPOOL_ShutdownPool( zfsPool ); storagePool->zfspool = NULL; - + storagePool->zfspool = ZFSPOOL_LoadPool(genMsg, storagePool, TRUE, ZLSS_PLF_NORMAL, TRUE, L"ZSBPOOL", FALSE ); if ( storagePool->zfspool == NULL ) @@ -6216,14 +6180,14 @@ STATUS doZLSSPoolSnapshot( return zOK; } zlssPool = (ZlssPool_s *)pool; - X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); state = zlssPool->ZLSSPOOLstate; - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); if ( state != zVOLSTATE_DEACTIVE ) { printf( MSGNot("Pool must be in the DEACTIVE state to snap. Use the\n" - "command \"NSS /poolDeactivate=%U\" to deactivate the pool.\n"), - (unicode_t *)switchDef->ret_value ); + "command \"NSS /poolDeactivate=%U\" to deactivate the pool.\n"), + (unicode_t *)switchDef->ret_value ); COMN_Release( &pool ); MPKNSS_UNLOCK(); return zOK; @@ -6233,8 +6197,8 @@ STATUS doZLSSPoolSnapshot( /* Attempt to upgrade the POOL */ (void)ZFSPOOL_Snapshot( &dummyGenMsg, zfsPool ); zfsPool = NULL; /* Pool has been unloaded and reloaded so - * can not use our old pointer. - */ + * can not use our old pointer. + */ } else { @@ -6242,7 +6206,7 @@ STATUS doZLSSPoolSnapshot( "/ZLSSPoolScan\" to load the pool.\n"), (unicode_t *)switchDef->ret_value ); } - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return zOK; } /* End of doZLSSPoolSnapshot() */ @@ -6254,7 +6218,7 @@ STATUS doZLSSPoolSnapshot( * that I/O statistics are tracked in. The globals have already * been updated by the command line processor. We just need to * go through ALL the ZLSS pools to update their tracking state. - * + * * These statistics are for ALL pools that the ZLSS owns. */ @@ -6272,10 +6236,10 @@ STATUS doZLSSPoolIOState( /* Uses a hidden key to find the 'next' pool */ SET_FOREACHBLOCKING(&NSSMasterPoolList, pool, Pool_s, masterPoolLink) { /*** You MUST NOT USE continue in this loop because the macro - *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called - *** every time through the loop. Technically, you - *** can use a continue BEFORE any blocking calls. - ***/ + *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called + *** every time through the loop. Technically, you + *** can use a continue BEFORE any blocking calls. + ***/ if ( !COMN_IsDerivedFrom(pool, zFTYPE_ZLSS_LOGICAL_POOL) ) { /* Not a ZLSS pool so exit */ zASSERT("Wow we have non ZLSS pools(ok to do a 'go')"==NULL); @@ -6283,7 +6247,7 @@ STATUS doZLSSPoolIOState( } COMN_USE_BEAST( &pool->POOLroot ); zlssPool = (ZlssPool_s *)pool; - X_LATCH( &zlssPool->ZLSSPOOLpool.stateLatch ); + X_LATCH( &zlssPool->ZLSSPOOLpool.stateLatch ); switch (pool->state) { case zVOLSTATE_UNKNOWN: @@ -6299,13 +6263,13 @@ STATUS doZLSSPoolIOState( default: break; } - UNX_LATCH( &zlssPool->ZLSSPOOLpool.stateLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.stateLatch ); COMN_Release( &pool ); cantUseContinue: /* Resets us to the beginning of the list */ SET_FOREACHBLOCKINGEND(&NSSMasterPoolList, pool, Pool_s, masterPoolLink) } - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return zOK; } /* End of doZLSSPoolIOState() */ @@ -6321,13 +6285,13 @@ STATUS ZLSSPOOL_BST_Construct( ZlssPool_s *zlssPool = (ZlssPool_s *)zlssPool_LX; ENTER(TZPOOL, ZLSSPOOL_BST_Construct); - FSMLITE_INIT(&zlssPool->ZP_MakeFreeSpaceFsm, + FSMLITE_INIT(&zlssPool->ZP_MakeFreeSpaceFsm, MSGNot("ZLSS POOL Make Free Space"), 0); zlssPool->ZP_UnusableFreeBlkCnt = 0; #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(RED,MSGNot("A ZlssPool_s is at %lx with inuse set to %d\n"),zlssPool,zlssPool->ZLSSPOOLroot.useCount); DBG_DebugPrintf(RED,MSGNot("The inUse is at %lx\n"),&zlssPool->ZLSSPOOLroot.useCount); - + #endif zlssPool->ZLSSPOOLsupportedFeatures = ZLSSPOOL_SUPPORTED_FEATURES; zlssPool->ZP_StatisticsResetUTCTime = GetUTCTime(); @@ -6357,7 +6321,7 @@ void ZLSSPOOL_BST_Destruct( /************************************************************************** * This will do a flush of the POOL's system beasts. We simply have the * internal volume do the work. - * + * * Notes - * As of 12/18/2000 no one ever calls this volume op for a pool. ***************************************************************************/ @@ -6376,9 +6340,9 @@ STATUS ZLSSPOOL_VOL_FlushSystemBeasts( /************************************************************************** - * + * * This changes the state of a ZLSS Pool. - * + * * It is called 10 times for each common layer change state request. See * COMN_ChangeVolumeState for details on the states. The Pool states * are the same as the Volume states. @@ -6391,7 +6355,7 @@ STATUS ZLSSPOOL_VOL_FlushSystemBeasts( * This was done as it is called after we know the pool STATE change * worked and after the stateLatch is released. See * ZLSSPOOL_ChangePoolStateExitCallBack() for details. - * + * ***************************************************************************/ STATIC STATUS ZLSSPOOL_VOL_ChangeVolumeState( GeneralMsg_s *genMsg, @@ -6403,16 +6367,15 @@ STATIC STATUS ZLSSPOOL_VOL_ChangeVolumeState( { ZlssPool_s *zlssPool = (ZlssPool_s *)zlssPool_LX; STATUS status = zOK; - zfspool_change_volume_state_func_t parentFunc; + statusfunc_t parentFunc; ENTER(TZPOOL, ZLSSPOOL_VOL_ChangeVolumeState); /*------------------------------------------------------------------------- * Since we know we need to call the Pool_s code, get the address of * that routine. *-------------------------------------------------------------------------*/ - parentFunc = (zfspool_change_volume_state_func_t)COMN_GetNextParentVolumeComnOp(zlssPool->ZLSSPOOLbeastClass, - COMNVOLOPS_INDEX(VOL_changeVolumeState), - (statusfunc_t)ZLSSPOOL_VOL_ChangeVolumeState); + parentFunc = COMN_GetNextParentVolumeComnOp(zlssPool->ZLSSPOOLbeastClass, + COMNVOLOPS_INDEX(VOL_changeVolumeState),ZLSSPOOL_VOL_ChangeVolumeState); zASSERT(parentFunc != NULL); status = parentFunc( genMsg, &zlssPool->ZLSSPOOLpool, sourceState, requestedState, mode, pass ); @@ -6422,47 +6385,47 @@ STATIC STATUS ZLSSPOOL_VOL_ChangeVolumeState( } /** At this time we do all the real work in a ZlssPool_s - ** state change by telling our internal volume that it - ** needs to do a STATE change. We do this in our first - ** pass. This in turns forces our LVs to the correct - ** STATE. I.E. if we are going to a lower number STATE - ** then the LVs will be placed in that STATE(if they - ** where in a higher STATE). - **/ + ** state change by telling our internal volume that it + ** needs to do a STATE change. We do this in our first + ** pass. This in turns forces our LVs to the correct + ** STATE. I.E. if we are going to a lower number STATE + ** then the LVs will be placed in that STATE(if they + ** where in a higher STATE). + **/ if ( pass == 1 ) { if (zlssPool->ZLSSPOOLzfsPool->storagepool != NULL) { /* ???Code for if clustering changeing things on us??? */ if ( zlssPool->ZLSSPOOLzfsPool->storagepool->sharedStatus ) { /* Allen says we are shared */ - zlssPool->ZLSSPOOLenabledFeatures |= + zlssPool->ZLSSPOOLenabledFeatures |= zPOOL_FEATURE_SHARED_CLUSTER; } else { - zlssPool->ZLSSPOOLenabledFeatures &= + zlssPool->ZLSSPOOLenabledFeatures &= ~zPOOL_FEATURE_SHARED_CLUSTER; } } - + status = COMN_ChangeVolumeState( genMsg, zlssPool->ZLSSPOOLzfsPool, requestedState, mode & VOLMODE_LEGAL_BITS); if ( status != zOK ) { RTN_STATUS( status ); } /** This check handles the case where the internal volume - ** destination state got changed from ACTIVE to MAINTENANCE - ** because of the zERR_VOLUME_STATE_CHANGE_A_TO_M error. - ** When this error occurs the change volume code changes - ** the destination state to MAINTENANCE and if that - ** state is reached NO ERROR is returned. - **/ + ** destination state got changed from ACTIVE to MAINTENANCE + ** because of the zERR_VOLUME_STATE_CHANGE_A_TO_M error. + ** When this error occurs the change volume code changes + ** the destination state to MAINTENANCE and if that + ** state is reached NO ERROR is returned. + **/ if ( (requestedState == zVOLSTATE_ACTIVE) && (zlssPool->ZLSSPOOLzfsPool->ZFSPOOLstate == zVOLSTATE_MAINTENANCE ) ) { /* Since internal volume destination state got changed - * we need to change the pools. We simply return the - * special error code and let change pool state handle. - */ + * we need to change the pools. We simply return the + * special error code and let change pool state handle. + */ DEBUG_PRINTF(TPOOL,DBG_NOINDENT,(GREEN, MSGNot("ZLSS POOL - Change state converted to a request from %d to %d\n"), requestedState, zVOLSTATE_MAINTENANCE )); @@ -6518,9 +6481,9 @@ STATUS ZLSSPOOL_VOL_CommandFunction( break; /*** Note that the rest of the VCO_VOLUME_... commands - *** are handle by ZFSVOL_VOL_CommandFunction() because - *** the commands have volumes that exist. - ***/ + *** are handle by ZFSVOL_VOL_CommandFunction() because + *** the commands have volumes that exist. + ***/ case VCO_VOLUME_RENAME_NUMBER: status = zFAILURE; SetErrno( genMsg, zERR_NOT_SUPPORTED ); @@ -6559,21 +6522,21 @@ STATUS ZLSSPOOL_BST_ModifyInfo( ZlssPool_s *zlssPool = (ZlssPool_s *)zlssPool_LX; zPoolInfo_s *poolInfo; zVolumeInfo_s *volInfo; - zfspool_modify_info_func_t derivedFromModifyInfo; + statusfunc_t derivedFromModifyInfo; BOOL modified = FALSE; BOOL someAttrsChanged = FALSE; - BOOL someAttrsNotChanged = FALSE; + BOOL someAttrsNotChanged = FALSE; ASSERT_MPKNSS_LOCK(); ASSERT_XLATCH( &zlssPool->ZLSSPOOLfile.FILEbeastLatch ); /*--------------------------------------------------------------------------- - * First, call the generic file information routine and modify any + * First, call the generic file information routine and modify any * requested generic information. If it fails, do not continue... *---------------------------------------------------------------------------*/ - derivedFromModifyInfo = (zfspool_modify_info_func_t)COMN_GetNextParentBeastComnOp( + derivedFromModifyInfo = COMN_GetNextParentBeastComnOp( zlssPool->ZLSSPOOLbeastClass, COMNOPS_INDEX( BST_modifyInfo ), - (statusfunc_t)ZLSSPOOL_BST_ModifyInfo); + ZLSSPOOL_BST_ModifyInfo); if (derivedFromModifyInfo(genMsg,zlssPool,modifyMsg,xaction) != zOK) { @@ -6588,12 +6551,12 @@ STATUS ZLSSPOOL_BST_ModifyInfo( poolInfo = &modifyMsg->modifyInfo->pool; volInfo = &modifyMsg->modifyInfo->vol; - if (modifyMsg->modifyInfoMask & + if (modifyMsg->modifyInfoMask & (zMOD_POOL_ATTRIBUTES | zMOD_POOL_NDS_OBJECT_ID)) { zASSERT(!(zlssPool->ZLSSPOOLenabledFeatures & zPOOL_FEATURE_READ_ONLY)); - if (zlssPool->ZLSSPOOLauth.mayIDoThis(genMsg, zlssPool, + if (zlssPool->ZLSSPOOLauth.mayIDoThis(genMsg, zlssPool, #ifdef NSS_NW60 modifyMsg->parentZid, MAY_I_DO_EVERYTHING) != zOK) #else @@ -6608,26 +6571,26 @@ STATUS ZLSSPOOL_BST_ModifyInfo( if (modifyMsg->modifyInfoMask & zMOD_POOL_ATTRIBUTES) { - if ((poolInfo->features.enableModMask & - ZLSSPOOL_NON_CHANGEABLE_FEATURES) != + if ((poolInfo->features.enableModMask & + ZLSSPOOL_NON_CHANGEABLE_FEATURES) != (((poolInfo->features.enabled & poolInfo->features.enableModMask) & - ZLSSPOOL_NON_CHANGEABLE_FEATURES))) + ZLSSPOOL_NON_CHANGEABLE_FEATURES))) { - /* One of the bits requested to be changed is a - * non-changeable feature */ + /* One of the bits requested to be changed is a + * non-changeable feature */ someAttrsNotChanged = TRUE; } /* - * LOCAL - */ + * LOCAL + */ if ((poolInfo->features.enableModMask & zPOOL_FEATURE_MSAP) && ((poolInfo->features.enabled & zPOOL_FEATURE_MSAP) != (zlssPool->ZLSSPOOLenabledFeatures & zPOOL_FEATURE_MSAP))) { /* Local is being changed */ zlssPool->ZLSSPOOLenabledFeatures &= ~zPOOL_FEATURE_MSAP; - zlssPool->ZLSSPOOLenabledFeatures |= + zlssPool->ZLSSPOOLenabledFeatures |= (poolInfo->features.enabled & zPOOL_FEATURE_MSAP); someAttrsChanged = TRUE; } @@ -6655,31 +6618,31 @@ STATUS ZLSSPOOL_BST_ModifyInfo( // * is the keeper of this bit!!! // */ // -// if ((poolInfo->features.enableModMask & +// if ((poolInfo->features.enableModMask & // zPOOL_FEATURE_SHARED_CLUSTER) && -// ((poolInfo->features.enabled & +// ((poolInfo->features.enabled & // zPOOL_FEATURE_SHARED_CLUSTER) != -// (zlssPool->ZLSSPOOLenabledFeatures & +// (zlssPool->ZLSSPOOLenabledFeatures & // zPOOL_FEATURE_SHARED_CLUSTER))) // { -// /* shared cluster feature is being changed -// * this bit is persistently stored by the partition segment +// /* shared cluster feature is being changed +// * this bit is persistently stored by the partition segment // * so we will call NSSIDK/MM to save this information // */ -// -// if (ChangeSharedClusterFeatureOfPool(genMsg, zlssPool, +// +// if (ChangeSharedClusterFeatureOfPool(genMsg, zlssPool, // poolInfo) != zOK) // { // ClearErrno( genMsg ); // someAttrsNotChanged = TRUE; -// } +// } // } #endif } if (modifyMsg->modifyInfoMask & zMOD_POOL_NDS_OBJECT_ID) { zlssPool->ZLSSPOOLndsObjectID = poolInfo->ndsObjectID; - OID_SaveObjectID((Volume_s *)zlssPool->ZP_ZfsPool, + OID_SaveObjectID((Volume_s *)zlssPool->ZP_ZfsPool, &zlssPool->ZLSSPOOLndsObjectID); modified = TRUE; } @@ -6825,7 +6788,7 @@ CommonVolumeOps_s ZLSSPOOL_ComnVolOps = NULL, /* VOL_lookupMFLEntry */ NULL, /* VOL_enumerateMFL */ NULL, /* VOL_administerMFL */ - ZLSSPOOL_VOL_CommandFunction, /* VOL_commandFunction */ + ZLSSPOOL_VOL_CommandFunction, /* VOL_commandFunction */ NULL, /* VOL_getDirQuotaInfo */ NULL, /* VOL_setDirQuota */ @@ -6873,22 +6836,22 @@ STATUS ZLSSPOOL_MediaIsCorrupt( { RootBeast_s *beast; /* The beast the corruption was found in */ Volume_s *volume; /* The volume that the buffer is on. Note - * that this is not the 'owning' volume if - * the beast is a volume because the ADMIN - * volume owns all volumes. - */ + * that this is not the 'owning' volume if + * the beast is a volume because the ADMIN + * volume owns all volumes. + */ beast = STRUCT(corruptedBuffer->pBuf.mycache, RootBeast_s, ROOTmycache); ZLSS_VOLUME_GET( beast, volume ); zASSERT( volume != NULL ); /* If not /VERIFY or /REBUILD then DISABLE the - * volume. The repair code handles errors so we - * do not wish to DISABLE the volume. Note that - * we do not simply check the volume's state because - * we would be required to obtain the stateLatch and - * if we did that we could easily deadlock. - */ + * volume. The repair code handles errors so we + * do not wish to DISABLE the volume. Note that + * we do not simply check the volume's state because + * we would be required to obtain the stateLatch and + * if we did that we could easily deadlock. + */ if ( !ZLSS_IS_MAINTENANCE_IO( volume ) ) { GeneralMsg_s dummyGenMsg; @@ -6898,23 +6861,23 @@ STATUS ZLSSPOOL_MediaIsCorrupt( zASSERT("We have found corruption on a NSS volume (if possible contact NSS)."==NULL); /* Now tell the common layer that we wish to disable this - * pool. This is an ASYNC call. We require because we - * can not block. CVA_NON_IO is set because we did not - * get an I/O read we just have a bad MAGIC. - */ + * pool. This is an ASYNC call. We require because we + * can not block. CVA_NON_IO is set because we did not + * get an I/O read we just have a bad MAGIC. + */ flags = CVA_SYSTEM_DATA | CVA_POOL_DISABLE | CVA_POOL_ALERT | CVA_NON_IO; if ( !COMN_IsDerivedFrom(volume, zFTYPE_ZLSS_ZFSPOOL) ) { /* Set Volume alert for Logical Volumes only. I.E. do - * NOT say that the internal volume is a volume. - * This prevents the internal volume name from being - * seen. - */ + * NOT say that the internal volume is a volume. + * This prevents the internal volume name from being + * seen. + */ flags |= CVA_VOLUME_DISABLE | CVA_VOLUME_ALERT; } if ( iomsg->mode == CACHE_READ ) { /* No sense doing DISABLE on CACHE_READ as error - * is easily handled by caller. - */ + * is easily handled by caller. + */ flags &= ~(CVA_POOL_DISABLE | CVA_VOLUME_DISABLE); } (void)COMN_VolumeAlert( &dummyGenMsg, beast, volume, @@ -6956,10 +6919,10 @@ STATUS ZFSPOOL_SuperBlockUpdate( GeneralMsg_s *genMsg, ZfsPool_s *pool ) int superblock; /* Note that the checksum will be updated by the SuperBlock write - * header code below. Having the checksum correct in the - * ZP_Super (memory version of Super Block) is not REQUIRED because - * we always calculate it when writing the header. - */ + * header code below. Having the checksum correct in the + * ZP_Super (memory version of Super Block) is not REQUIRED because + * we always calculate it when writing the header. + */ for ( superblock=0; superblock < SUPERBLOCK_NUMBER; superblock++ ) { zASSERT( pool->storagepool != NULL ); @@ -7001,10 +6964,10 @@ STATUS ZFSPOOL_SuperBlockUpdate2( int superblock; /* Note that the checksum will be updated by the SuperBlock write - * header code below. Having the checksum correct in the - * ZP_Super (memory version of Super Block) is not REQUIRED because - * we always calculate it when writing the header. - */ + * header code below. Having the checksum correct in the + * ZP_Super (memory version of Super Block) is not REQUIRED because + * we always calculate it when writing the header. + */ for ( superblock=0; superblock < SUPERBLOCK_NUMBER; superblock++ ) { status = ZFSPOOL_SuperBlockHeaderWrite(storagepool, @@ -7066,8 +7029,8 @@ STATUS ZFSPOOL_SuperBlockUpdateXaction( superblockHeader = &zfsPool->ZP_super->SB_Header.hdr; /* Grab the buffers before ZLOG_ObtainRecord because - * ZFS_ReadPoolBlk can block. - */ + * ZFS_ReadPoolBlk can block. + */ for ( superblock=0; superblock < SUPERBLOCK_NUMBER; superblock++ ) { zASSERT( zfsPool->storagepool != NULL ); @@ -7104,16 +7067,16 @@ STATUS ZFSPOOL_SuperBlockUpdateXaction( memcpy( logRecord->SLR_ValuesOld, sbhBuf[0]->pBuf.data, sizeof(logRecord->SLR_ValuesOld)); /* We must update checksum as we are placing superblock header - * into a cache buffer (I.E. ZFSPOOL_SuperBlockHeaderWrite will - * not be used to write it so ZFSPOOL_SuperBlockHeaderWrite can not - * update checksum for us). - */ + * into a cache buffer (I.E. ZFSPOOL_SuperBlockHeaderWrite will + * not be used to write it so ZFSPOOL_SuperBlockHeaderWrite can not + * update checksum for us). + */ superblockHeader->SBH_Lsn = logBuffer->ZXR_Lsn; superblockHeader->SBH_VersionMajor = SUPERBLOCK_SB_VM_MAJOR; superblockHeader->SBH_VersionMinor = SUPERBLOCK_SB_VM_MINOR; superblockHeader->SBH_PackedSize = sizeof(SuperBlockHeader_s); superblockHeader->SBH_Checksum = 0; - superblockHeader->SBH_Checksum = 0 - + superblockHeader->SBH_Checksum = 0 - ZFSPOOL_SuperBlockHeaderCalculateChecksum( (LONG *)superblockHeader, sizeof( SuperBlockHeader_s ) / 4 ); @@ -7175,17 +7138,17 @@ STATUS ZLSSPOOL_RecoverySuperblockHeader( zlssPool = ZLSS_VOLUME_TO_ZLSS_POOL( &pool->ZFSPOOLzfsvol ); zASSERT( zlssPool != NULL ); poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); - + for ( superblock=0; superblock < SUPERBLOCK_NUMBER; superblock++ ) { if (ZLOG_VALID_BLOCK(poolBlks[superblock])) { /* Must use be a CACHE_UPDATE because ZLOG_ALREADY_DONE - * references LSN in block. - */ + * references LSN in block. + */ READBLK_IO_MSG(iomsg, pool, poolBlks[superblock].blkNum, CACHE_UPDATE) buffer[superblock] = ZFS_ReadPoolBlk( genMsg, &iomsg ); if (buffer[superblock] == NULL) - { + { return( zFAILURE ); } block = (MediaSuperBlockHeader_s *)buffer[superblock]->pBuf.data; @@ -7198,7 +7161,7 @@ STATUS ZLSSPOOL_RecoverySuperblockHeader( { logRecord = ZLOG_START_OF_LOG_RECORD(logBuffer); if (action == X_REDO) - { + { #ifdef USER_GPACHNER zASSERT("REDO of superblock header"==NULL); #endif @@ -7218,7 +7181,7 @@ STATUS ZLSSPOOL_RecoverySuperblockHeader( #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LRED,"2) Zlss pool version is now %ld (long value)\n", zlssPool->ZP_Version ); #endif - } + } else { #ifdef USER_GPACHNER @@ -7242,8 +7205,8 @@ STATUS ZLSSPOOL_RecoverySuperblockHeader( #endif } /* Not needed because the memcpy above sets the LSN - * to the correct value - */ + * to the correct value + */ /* ZLOG_SET_LSN(logBuffer, block->ZLPB_zlssPool.LPZP_lsn, poolBlks[superblock], action); */ CACHE_DIRTY_RELEASE(buffer[superblock]); } @@ -7252,3 +7215,5 @@ STATUS ZLSSPOOL_RecoverySuperblockHeader( RTN_STATUS(zOK); } /* End of ZLSSPOOL_RecoverySuperblockHeader() */ + + diff --git a/src/nwnss/zlss/zfsSuperBlk.c b/src/nwnss/zlss/zfsSuperBlk.c index ef14308..f29e6a4 100644 --- a/src/nwnss/zlss/zfsSuperBlk.c +++ b/src/nwnss/zlss/zfsSuperBlk.c @@ -36,9 +36,7 @@ | | +-------------------------------------------------------------------------*/ -#ifndef NSS_USERSPACE #include -#endif #include #include #include @@ -58,18 +56,6 @@ #include "zlog.h" #include "zlssLogicalVolume.h" -#ifdef NSS_USERSPACE -#ifndef READ -#define READ 0 -#endif -#ifndef WRITE -#define WRITE 1 -#endif -#ifndef dump_stack -#define dump_stack() do { } while (0) -#endif -#endif - /* * General Concepts * @@ -82,7 +68,7 @@ /*- (FUNCTION) ----- ZFSPOOL_SuperBlockMathematicalBlock() ------------------ | | ZFSPOOL_SuperBlockMathematicalBlock - | Calculates and returns one of the mathematical locations of + | Calculates and returns one of the mathematical locations of | the requested super block. Note this is the block number of | section 0 of the super block. | @@ -103,9 +89,9 @@ Blknum_t ZFSPOOL_SuperBlockMathematicalBlock( /* Verify paramenter */ zASSERT( superBlockNumber < SUPERBLOCK_NUMBER ); /* - * Ensure that we change the number of super blocks that the case - * statement below gets updated. - */ + * Ensure that we change the number of super blocks that the case + * statement below gets updated. + */ zASSERT( (3 + 1) == SUPERBLOCK_NUMBER ); switch (superBlockNumber) { @@ -117,21 +103,21 @@ Blknum_t ZFSPOOL_SuperBlockMathematicalBlock( return( ((1024ul*1024ul)/MAL_BUFSZ4K) ); case 2 : /* - * 2 Meg from end of pool. This leaves space to grow the - * super block and still have the possibility of staying - * backwards compatible with the previous media format. Most - * likily we will not be compatible, but this at least - * increases our odds with no cost. - */ + * 2 Meg from end of pool. This leaves space to grow the + * super block and still have the possibility of staying + * backwards compatible with the previous media format. Most + * likily we will not be compatible, but this at least + * increases our odds with no cost. + */ return( totalBlocksInPool - ((2*1024ul*1024ul)/MAL_BUFSZ4K) ); case 3 : /* - * 1 Meg from end of pool. This leaves space to grow - * super block and still have the possibility of staying - * backwards compatible with the previous media format. Most - * likily we will not be compatible, but this at least - * increases our odds with no cost. - */ + * 1 Meg from end of pool. This leaves space to grow + * super block and still have the possibility of staying + * backwards compatible with the previous media format. Most + * likily we will not be compatible, but this at least + * increases our odds with no cost. + */ return( totalBlocksInPool - ((1024ul * 1024ul)/MAL_BUFSZ4K) ); } return( 0 ); /* Make compiler happy */ @@ -403,7 +389,7 @@ STATUS ZFSPOOL_SuperBlockRead( zConPool_s *phypool; ZfsPool_s *zfspool; ZlssPool_s *zlssPool = NULL; - + ASSERT_MPKNSS_LOCK(); ENTER(TZPOOL, ZFSPOOL_SuperBlockRead); @@ -412,7 +398,7 @@ STATUS ZFSPOOL_SuperBlockRead( /*- get the storage deposit to access for this volume -*/ if((phypool = storagepool->phypool) == NULL) { - zASSERT("Pool is no longer valid" == NULL); + zASSERT("Pool is no longer valid" == NULL); RTN_STATUS(zERR_POOL_NOT_ACCESSIBLE); } @@ -505,7 +491,7 @@ STATUS ZFSPOOL_SuperBlockWrite( /*- get the storage deposit to access for this volume -*/ if((phypool = storagepool->phypool) == NULL) { - zASSERT("Pool is no longer valid" == NULL); + zASSERT("Pool is no longer valid" == NULL); RTN_STATUS(zERR_POOL_NOT_ACCESSIBLE); } zfsPool = storagepool->zfspool; @@ -521,13 +507,13 @@ STATUS ZFSPOOL_SuperBlockWrite( if ( zlssPool->ZLSSPOOLpool.v_ioFlag & VOL_IOF_DISABLE ) { /* Not allowed to write if pool is 'Disabled' */ RTN_STATUS(zOK); /* We clean up much better by saying the - * the write work, but not actually doing it. - * For example, home will appear to move - * and the ZV_DeleteBlkQ will clear - * out and let the volume deactivate. - * For example, the user will not see - * thousands of checkpoint write errors. - */ + * the write work, but not actually doing it. + * For example, home will appear to move + * and the ZV_DeleteBlkQ will clear + * out and let the volume deactivate. + * For example, the user will not see + * thousands of checkpoint write errors. + */ // RTN_STATUS(zERR_POOL_DISABLING); } } @@ -595,7 +581,7 @@ STATUS ZFSPOOL_SuperBlockWrite( if (zfsPool != NULL) { ((Volume_s *)zfsPool)->v_stats.IO_system_write_success++; - ((Volume_s *)zfsPool)->v_stats.IO_system_writeSize += + ((Volume_s *)zfsPool)->v_stats.IO_system_writeSize += blockCnt*phypool->pol.poolblocksize; } #endif @@ -661,36 +647,36 @@ STATUS ZFSPOOL_SuperBlockHeaderChecker( ENTER(TZPOOL, ZFSPOOL_SuperBlockHeaderChecker); ASSERT_MPKNSS_LOCK(); /* - * There is a aprintf() below that casts a Blknum_t to a unsigned - * long for displaying. FixFixFix6 change cast to QUAD when aprintf - * supports! Then we can remove this ASSERT. Also change - * code in ZFSPOOL_SuperBlockHeaderRepair() which does not have - * an ASSERT because it does not get called often. - */ + * There is a aprintf() below that casts a Blknum_t to a unsigned + * long for displaying. FixFixFix6 change cast to QUAD when aprintf + * supports! Then we can remove this ASSERT. Also change + * code in ZFSPOOL_SuperBlockHeaderRepair() which does not have + * an ASSERT because it does not get called often. + */ zASSERT( sizeof(unsigned long) == sizeof(Blknum_t) ); /* - * Now read in and verify the four super block headers. We - * read them in based on the mathematical addresses. We do - * this because we have the mathematical addresses and if the - * mathematical do not agree with the logical address we - * return failure. - */ + * Now read in and verify the four super block headers. We + * read them in based on the mathematical addresses. We do + * this because we have the mathematical addresses and if the + * mathematical do not agree with the logical address we + * return failure. + */ for ( superBlock = 0; superBlock < SUPERBLOCK_NUMBER; ++superBlock ) { /* Read the 4 using blocks using mathematical addresses */ status = ZFSPOOL_SuperBlockHeaderReadByBlock( storagepool, - si[superBlock].SBHV_MediaCopy, - si[superBlock].SBHV_MathematicalBlock); + si[superBlock].SBHV_MediaCopy, + si[superBlock].SBHV_MathematicalBlock); if ( status == zOK ) { /* Read succeeded - verify checksum, signature, ... */ status = ZFSPOOL_SuperBlockHeaderVerify( storagepool, - si[superBlock].SBHV_MediaCopy ); + si[superBlock].SBHV_MediaCopy ); if ( status != zOK ) { #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LRED, - MSGNot("SB (warn) Super block header %u validation error %lu.\n"), + MSGNot("SB (warn) Super block header %u validation error %lu.\n"), superBlock+1, status ); #endif RTN_STATUS( zFAILURE ); @@ -729,18 +715,18 @@ STATUS ZFSPOOL_SuperBlockHeaderChecker( RTN_STATUS( zFAILURE ); } } - + /* Copy the first good super block header into the return area */ *superblockHeaderMedia = *(si[0].SBHV_MediaCopy); #if 0 /** January 31, 2001 - * The name of the pool is stored by MAL. We have - * a local copy so that ZLSS can access without - * having to pull out of the NAMED beast. If this - * gets updated persistently fine. If not fine. - * The memory copy needs to be correct because - * numerous places in ZLSS use as the name of the pool. - */ + * The name of the pool is stored by MAL. We have + * a local copy so that ZLSS can access without + * having to pull out of the NAMED beast. If this + * gets updated persistently fine. If not fine. + * The memory copy needs to be correct because + * numerous places in ZLSS use as the name of the pool. + */ unicpy(superblockHeaderMedia->hdr.SBH_Name, storagepool->poolname); #endif @@ -753,7 +739,7 @@ STATUS ZFSPOOL_SuperBlockHeaderChecker( /************************************************************************** - * + * ***************************************************************************/ STATUS ZFSPOOL_SuperBlockHeaderReadByBlock( StorPool_s *storagepool, @@ -794,10 +780,10 @@ STATUS ZFSPOOL_SuperBlockHeaderRepair( MediaSuperBlockHeader_s *superblockHeaderMedia, SuperBlockHeaderValidate_s si[], int verbose ) /* If TRUE prints error - * messages. Repair passes in - * FALSE since repair uses the - * windowing system. - */ + * messages. Repair passes in + * FALSE since repair uses the + * windowing system. + */ { @@ -806,30 +792,30 @@ STATUS ZFSPOOL_SuperBlockHeaderRepair( NINT superBlock; NINT numberGood; NINT firstGood; /* First super block number that has a - * valid checksum. - */ + * valid checksum. + */ ENTER(TZPOOL, ZFSPOOL_SuperBlockHeaderRepair); ASSERT_MPKNSS_LOCK(); /* FixFixFix6 this message not total correct because if - * the super blocks are in GOOD non-math locations we - * will be happy not not rebuild. Greg April 10, 1998 - */ + * the super blocks are in GOOD non-math locations we + * will be happy not not rebuild. Greg April 10, 1998 + */ // aprintf(LGREEN,MSG("** Rebuild of super block header\n", 299)); /* - * Read in the 1st super block header using its calculated block - * number. If we read in and verify the 1st super block header - * then the other three super block headers will be read in using - * the block locations stored in the 1st super block header. If - * we can not read or the checksum fails then we will read in the - * last three super block headers using the mathematical block - * numbers. - */ + * Read in the 1st super block header using its calculated block + * number. If we read in and verify the 1st super block header + * then the other three super block headers will be read in using + * the block locations stored in the 1st super block header. If + * we can not read or the checksum fails then we will read in the + * last three super block headers using the mathematical block + * numbers. + */ firstGood = -1; numberGood = 0; status = ZFSPOOL_SuperBlockHeaderReadByBlock( storagepool, - si[0].SBHV_MediaCopy, - si[0].SBHV_MathematicalBlock); + si[0].SBHV_MediaCopy, + si[0].SBHV_MathematicalBlock); if ( status == zOK ) { /* Read succeeded */ status = ZFSPOOL_SuperBlockHeaderVerify( storagepool, @@ -866,9 +852,9 @@ STATUS ZFSPOOL_SuperBlockHeaderRepair( #endif } /* - * Now read in and verify the last three super block headers. We - * read them in based on if the 1st super block header is valid. - */ + * Now read in and verify the last three super block headers. We + * read them in based on if the 1st super block header is valid. + */ for ( superBlock = 1; superBlock < SUPERBLOCK_NUMBER; ++superBlock ) { if ( si[0].SBHV_Flag & SUPERBLOCK_SBHV_F_CHECKSUM_GOOD ) @@ -884,7 +870,7 @@ STATUS ZFSPOOL_SuperBlockHeaderRepair( if ( status == zOK ) { /* Read succeeded - verify checksum, signature, ... */ status = ZFSPOOL_SuperBlockHeaderVerify( storagepool, - si[superBlock].SBHV_MediaCopy ); + si[superBlock].SBHV_MediaCopy ); if ( status == zOK ) { /* Super block header verified - mark as good */ si[superBlock].SBHV_Flag |= SUPERBLOCK_SBHV_F_CHECKSUM_GOOD; @@ -921,33 +907,33 @@ STATUS ZFSPOOL_SuperBlockHeaderRepair( /* Did we find any good super block headers? */ if ( numberGood == 0 ) { /* - * No super block header could be read and verified. - */ + * No super block header could be read and verified. + */ SetErrno(genMsg, zERR_SUPERBLOCK_NOT_ENOUGH); goto SBHV_ErrorExit; } /* Do some validation of the good super block headers */ if ( !(si[0].SBHV_Flag & SUPERBLOCK_SBHV_F_CHECKSUM_GOOD) ) { /* - * We have these requirements if super block 1 is bad. Or - * in other words, these are the requirements if we had to read - * the headers in with our mathematical block locations. - * - * 1). At least two of the super blocks headers are good. - * Which means 2 of the last 3 are good since the 1st - * one being bad is how we got here. - * 2). All the good super block headers are identical. - * 3). The logical block locations of the super blocks must - * match the mathematical block locations. - * - * We will fix the following problems by writing a good super block - * headers data over the 'bad' super block header. - * - * 1). Validation error (bad checksum, signature, or version). - * - * Note that we take the attitude that we can not trust - * the headers that we read via the mathematical locations. - */ + * We have these requirements if super block 1 is bad. Or + * in other words, these are the requirements if we had to read + * the headers in with our mathematical block locations. + * + * 1). At least two of the super blocks headers are good. + * Which means 2 of the last 3 are good since the 1st + * one being bad is how we got here. + * 2). All the good super block headers are identical. + * 3). The logical block locations of the super blocks must + * match the mathematical block locations. + * + * We will fix the following problems by writing a good super block + * headers data over the 'bad' super block header. + * + * 1). Validation error (bad checksum, signature, or version). + * + * Note that we take the attitude that we can not trust + * the headers that we read via the mathematical locations. + */ /*** Test 1 ***/ if ( numberGood < 2 ) @@ -983,44 +969,44 @@ STATUS ZFSPOOL_SuperBlockHeaderRepair( } else { /* - * We have these requirements if the 1st super block is good. - * - * 1). At least one of the super blocks headers are good. This - * is always true when executing this code path. - * 2). Both the logical and mathematical location of super - * block 1 are the same. This rule may be changed when - * we start adding segments to a pool. - * - * We do not require any super block headers to match the 1st - * super block because we can not find OLD super block headers - * at location 0 of a valid pool. - * - * We will fix the following problems by writing super block - * header 1's data over the 'bad' super block header. - * - * 1). Validation error (bad checksum, signature, or version). - * 2). Super block not identical to super block 1. - * - * FixFixFix5( SPD 189303 ) - * - * Above statement assumes that before a pool is created by MAL - * that the MAL will clear section 1 (super block header) of - * the pool. - */ + * We have these requirements if the 1st super block is good. + * + * 1). At least one of the super blocks headers are good. This + * is always true when executing this code path. + * 2). Both the logical and mathematical location of super + * block 1 are the same. This rule may be changed when + * we start adding segments to a pool. + * + * We do not require any super block headers to match the 1st + * super block because we can not find OLD super block headers + * at location 0 of a valid pool. + * + * We will fix the following problems by writing super block + * header 1's data over the 'bad' super block header. + * + * 1). Validation error (bad checksum, signature, or version). + * 2). Super block not identical to super block 1. + * + * FixFixFix5( SPD 189303 ) + * + * Above statement assumes that before a pool is created by MAL + * that the MAL will clear section 1 (super block header) of + * the pool. + */ /*** Test 1 ***/ /* Already done by returning error if numberGood is equal to zero */ /*** Test 2 ***/ if (si[0].SBHV_MediaCopy->hdr.superlocation[0] != - si[0].SBHV_MathematicalBlock) + si[0].SBHV_MathematicalBlock) { /* Logical 1st does not equal physical 1st */ SetErrno(genMsg, zERR_SUPERBLOCK_CORRUPTED ); goto SBHV_ErrorExit; } /* - * Mike this is where we would try to move super blocks that - * are not in the correct locations. Easier said than done - * since we do not have the free beast yet. - */ + * Mike this is where we would try to move super blocks that + * are not in the correct locations. Easier said than done + * since we do not have the free beast yet. + */ for ( superBlock = 0; superBlock < SUPERBLOCK_NUMBER; ++superBlock ) { if ( si[0].SBHV_MediaCopy->hdr.superlocation[superBlock] != @@ -1028,10 +1014,10 @@ STATUS ZFSPOOL_SuperBlockHeaderRepair( { /* Some one does not match */ /* FixFixFix5( SPD 189303 ) - Add code here - normally this would be caused by a crash when a segment was being added to a pool.*/ - /* - * This is a FYI print out for now, because we are - * using the stored locations for the super blocks. - */ + /* + * This is a FYI print out for now, because we are + * using the stored locations for the super blocks. + */ #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LGREEN,MSGNot("SB (warn) Different mathematical(%lu) " "and stored block(%lu) for header %u (SBHrepair)\n"), @@ -1050,7 +1036,7 @@ STATUS ZFSPOOL_SuperBlockHeaderRepair( si[superBlock].SBHV_Flag |= SUPERBLOCK_SBHV_F_DIFFERENT; #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(LGREEN,MSGNot("SB (error) Super block header %u (%lu) is" - " not identical to super block 1 (%lu).\n"), + " not identical to super block 1 (%lu).\n"), superBlock+1, (unsigned long) si[0].SBHV_MediaCopy->hdr.superlocation[superBlock] + SUPERBLOCKHEADER_SECTION,(unsigned long) @@ -1062,26 +1048,26 @@ STATUS ZFSPOOL_SuperBlockHeaderRepair( } } /* - * We are very happy with the 'firstGood' super block header. We - * now write over all the super block headers that we did not - * like. The owners of the other blocks in the super block must - * verify their own blocks! If these owners are not happy then they - * can fail activation. - * - * Note that if this routine returns zOK then other blocks in the super - * block may be written. E.G. the checkpoint code normally will write - * numerous checkpoints in a running system. The checkpoint code uses - * the logical block numbers to determine were to write! - */ + * We are very happy with the 'firstGood' super block header. We + * now write over all the super block headers that we did not + * like. The owners of the other blocks in the super block must + * verify their own blocks! If these owners are not happy then they + * can fail activation. + * + * Note that if this routine returns zOK then other blocks in the super + * block may be written. E.G. the checkpoint code normally will write + * numerous checkpoints in a running system. The checkpoint code uses + * the logical block numbers to determine were to write! + */ for ( superBlock = 0; superBlock < SUPERBLOCK_NUMBER; ++superBlock ) { if ( !(si[superBlock].SBHV_Flag & (SUPERBLOCK_SBHV_F_CHECKSUM_GOOD | SUPERBLOCK_SBHV_F_DIFFERENT)) ) { /* Checksum bad or read error or different than firstGood */ /* Make a copy of the BAD header. Note that we do not - * update the checksum (we call general write routine). This - * allows us to see the old value. - */ + * update the checksum (we call general write routine). This + * allows us to see the old value. + */ status = ZFSPOOL_SuperBlockWrite(storagepool, si[superBlock].SBHV_MediaCopy, /* BAD header */ si[firstGood].SBHV_MediaCopy->hdr.superlocation[superBlock]+ @@ -1116,11 +1102,11 @@ STATUS ZFSPOOL_SuperBlockHeaderRepair( SUPERBLOCKHEADER_SECTION, status ); } /* - * If the write error is only in the header area then - * we can still come up and run. The other users of - * the super block sections will have to fail pool - * activation if they can not write to required sections. - */ + * If the write error is only in the header area then + * we can still come up and run. The other users of + * the super block sections will have to fail pool + * activation if they can not write to required sections. + */ ClearErrno( genMsg ); } else @@ -1152,8 +1138,8 @@ STATUS ZFSPOOL_SuperBlockHeaderRepair( SBHV_ErrorExit: /* FixFixFix5( SPD 190424 ) This is bad because we will not be able to get - * MAINTENANCE state to run rebuild or verify. - */ + * MAINTENANCE state to run rebuild or verify. + */ RTN_STATUS(zFAILURE); } /* End of ZFSPOOL_SuperBlockHeaderRepair() */ @@ -1172,7 +1158,7 @@ STATUS ZFSPOOL_SuperBlockHeaderValidate( StorPool_s *storagepool, MediaSuperBlockHeader_s *superblockHeaderMedia ) -{ +{ STATUS status; NINT superBlock; @@ -1203,20 +1189,20 @@ STATUS ZFSPOOL_SuperBlockHeaderValidate( #endif } /* - * Verify that all four super block headers are correct. Note - * that if zOK is returned then super block header media is filled in. - * Routine only returns zOK when all four super blocks are identical - * and located at the proper mathematical locations. - */ + * Verify that all four super block headers are correct. Note + * that if zOK is returned then super block header media is filled in. + * Routine only returns zOK when all four super blocks are identical + * and located at the proper mathematical locations. + */ status = ZFSPOOL_SuperBlockHeaderChecker( genMsg, storagepool, superblockHeaderMedia, si ); if ( status != zOK ) { /* - * Repair the super block headers. Note that if zOK is returned - * then the super block header media is filled in and the headers - * have been repaired. - */ + * Repair the super block headers. Note that if zOK is returned + * then the super block header media is filled in and the headers + * have been repaired. + */ ClearErrno( genMsg ); status = ZFSPOOL_SuperBlockHeaderRepair( genMsg, storagepool, superblockHeaderMedia, si, TRUE ); @@ -1242,14 +1228,14 @@ SBHV_Exit: } /* End of ZFSPOOL_SuperBlockHeaderValidate() */ /************************************************************************** - * + * ***************************************************************************/ STATUS ZFSPOOL_SuperBlockHeaderVerify( StorPool_s *storagepool, MediaSuperBlockHeader_s *superblockHeaderMedia ) { - - STATUS status; + + STATUS status; LONG checksum; SuperBlockHeader_s *superblockHeader; @@ -1264,11 +1250,11 @@ STATUS ZFSPOOL_SuperBlockHeaderVerify( RTN_STATUS(status); } /* Calculate the checksum. Checksum will equal zero if correct. - * Note that we use size on disk so we can verify checksum in older - * or newer superblocks. If we do not understand the older/newer - * format our version check will catch. This gives the user a better - * error than a checksum error because of a size change. - */ + * Note that we use size on disk so we can verify checksum in older + * or newer superblocks. If we do not understand the older/newer + * format our version check will catch. This gives the user a better + * error than a checksum error because of a size change. + */ checksum = ZFSPOOL_SuperBlockHeaderCalculateChecksum( (LONG *)superblockHeader, superblockHeader->SBH_PackedSize/4 ); @@ -1279,13 +1265,13 @@ STATUS ZFSPOOL_SuperBlockHeaderVerify( } /** January 31, 2001 - * The name of the pool is stored by MAL. We have - * a local copy so that ZLSS can access without - * having to pull out of the NAMED beast. If this - * gets updated persistently fine. If not fine. - * The memory copy needs to be correct because - * numerous places in ZLSS use as the name of the pool. - */ + * The name of the pool is stored by MAL. We have + * a local copy so that ZLSS can access without + * having to pull out of the NAMED beast. If this + * gets updated persistently fine. If not fine. + * The memory copy needs to be correct because + * numerous places in ZLSS use as the name of the pool. + */ unicpy(superblockHeader->SBH_Name, storagepool->poolname); if ( superblockHeader->SBH_Signature != SUPERBLOCK_SB_S_SIGNATURE ) @@ -1315,24 +1301,24 @@ STATUS ZFSPOOL_SuperBlockHeaderWrite( ASSERT_MPKNSS_LOCK(); /* Note that since LV AIPU did/does not update several fields - * in the Superblock Header we do them here. They are the - * fields SBH_VersionMajor, SBH_VersionMinor and - * SBH_PackedSize. - * Since we are checksumming the SuperBlockHeader_s size we better - * indicate that this is the size of the superblock header. - * This means that the first time we write a 5.x superblock - * header its size goes from 0x18c to 0x27c. The fact that - * the SBH_PackedSize is wrong on upgrade 5.x media is not - * a issue UNTIL a snapshot is done on them! This comes about as - * the only things in the superblock after size 0x18c is related - * to snapshot data. I.E. unless a snapshot is done all items - * are zero and do not effect checksum. - */ + * in the Superblock Header we do them here. They are the + * fields SBH_VersionMajor, SBH_VersionMinor and + * SBH_PackedSize. + * Since we are checksumming the SuperBlockHeader_s size we better + * indicate that this is the size of the superblock header. + * This means that the first time we write a 5.x superblock + * header its size goes from 0x18c to 0x27c. The fact that + * the SBH_PackedSize is wrong on upgrade 5.x media is not + * a issue UNTIL a snapshot is done on them! This comes about as + * the only things in the superblock after size 0x18c is related + * to snapshot data. I.E. unless a snapshot is done all items + * are zero and do not effect checksum. + */ superblockHeader->SBH_VersionMajor = SUPERBLOCK_SB_VM_MAJOR; superblockHeader->SBH_VersionMinor = SUPERBLOCK_SB_VM_MINOR; superblockHeader->SBH_PackedSize = sizeof(SuperBlockHeader_s); superblockHeader->SBH_Checksum = 0; - superblockHeader->SBH_Checksum = 0 - + superblockHeader->SBH_Checksum = 0 - ZFSPOOL_SuperBlockHeaderCalculateChecksum( (LONG *)superblockHeader, sizeof( SuperBlockHeader_s ) / 4 ); @@ -1376,9 +1362,9 @@ STATUS ZFSPOOL_SuperBlockHeaderWriteInitial( { SetErrno( genMsg, status ); /* FixFixFix6 - This message says volume when it is really - * a pool. Fix when we no longer have a one to one - * relationship. - */ + * a pool. Fix when we no longer have a one to one + * relationship. + */ errPrintf(WHERE, Module, 1446, MSG("Unable to write the initial superblock header " "for the volume \"%U\", status=%d.", 337), poolName, status); @@ -1484,11 +1470,11 @@ STATUS ZFSPOOL_SuperBlockMove( { QUAD blocksInNewPool; /* Number of blocks that are in the - * pool. - */ + * pool. + */ Blknum_t block3n; /* Block number of the first block - * of super block 3n. - */ + * of super block 3n. + */ Blknum_t block4n; /* Block number of super block 4n */ Blknum_t block3; /* Block number of super block 3 */ Blknum_t block4; /* Block number of super block 4 */ @@ -1501,7 +1487,7 @@ STATUS ZFSPOOL_SuperBlockMove( /*** Initialize - ***/ + ***/ #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf( CYAN, MSGNot("Moving super blocks 3 & 4\n") ); #endif @@ -1525,9 +1511,9 @@ STATUS ZFSPOOL_SuperBlockMove( #if 0 /*** 1) Obtain Volume State Latch so volume state does not change. - *** and verify that we are ACTIVE. - ***/ - X_LATCH( &pool->ZFSPOOLvol.stateLatch ); + *** and verify that we are ACTIVE. + ***/ + X_LATCH( &pool->ZFSPOOLvol.stateLatch ); if ( pool->ZFSPOOLstate != zVOLSTATE_ACTIVE ) { /* We only work if in ACTIVE state. */ SetErrno( genMsg, zERR_VOLUME_STATE_NOT_SUPPORTED ); @@ -1537,7 +1523,7 @@ STATUS ZFSPOOL_SuperBlockMove( #endif /*** 2) Allocate space for the new super blocks from the Free B-Tree. - ***/ + ***/ #if 0 seedext3n.poolBlkNum = block3n; seedext3n.lengthOfExtent = SUPERBLOCK_BLKCOUNT; @@ -1566,7 +1552,7 @@ STATUS ZFSPOOL_SuperBlockMove( #endif /*** 3) Copy super block 3 into 3n AND 4 into 4n (skip header). - ***/ + ***/ for ( section=0; section < SUPERBLOCK_BLKCOUNT; section++ ) { if ( section == SUPERBLOCKHEADER_SECTION ) @@ -1574,12 +1560,12 @@ STATUS ZFSPOOL_SuperBlockMove( continue; } /* FixFixFix6 - think about not erroring out on super block - * section that really do not have anything useful in them. - */ + * section that really do not have anything useful in them. + */ status = ZFSPOOL_SuperBlockRead(storagepool, buffer, block3+section, 1); /* FixFixFix6 - the error is always zFAILURE so not to usefull - * for user. Same for write call. - */ + * for user. Same for write call. + */ if ( status != zOK ) { SetErrno( genMsg, status ); @@ -1606,15 +1592,15 @@ STATUS ZFSPOOL_SuperBlockMove( } /*** 4) Write Super Block Header into 3n and 4n. This is a copy - *** of the current ZP_super, but has the updated block - *** locations for super blocks 3n and 4n and the new total - *** blocks in the pool. - ***/ + *** of the current ZP_super, but has the updated block + *** locations for super blocks 3n and 4n and the new total + *** blocks in the pool. + ***/ memcpy( buffer, &pool->ZP_super->SB_Header, SUPERBLOCK_SECTION_SIZE ); /* WARNING - 'buffer' is used for writing in many places - * below. Do not add code that reads something else into it - */ + * below. Do not add code that reads something else into it + */ ((MediaSuperBlockHeader_s *)buffer)->hdr.superlocation[3-1] = block3n; ((MediaSuperBlockHeader_s *)buffer)->hdr.superlocation[4-1] = block4n; ((MediaSuperBlockHeader_s *)buffer)->hdr.totalblocks = @@ -1635,8 +1621,8 @@ STATUS ZFSPOOL_SuperBlockMove( } /*** 5) Write Super Block 1 & 2 (header only). This updates the - *** location fields of the super block header. - ***/ + *** location fields of the super block header. + ***/ status = ZFSPOOL_SuperBlockHeaderWrite(storagepool, buffer, pool->ZP_super->SB_Header.hdr.superlocation[2-1]+SUPERBLOCKHEADER_SECTION,1); @@ -1646,12 +1632,12 @@ STATUS ZFSPOOL_SuperBlockMove( goto error_haveLatch; } /* Note that this is a point of no return! Once this write succeeds - * (Super block 1) then the ZLSS pool will use super blocks 1, 2, 3n - * and 4n if we were to crash. This is TRUE even if we UNDO the - * transaction part of the segment add!!! We assume if we do UNDO - * then the segment add will be re-attempted as the last item in - * activation. - */ + * (Super block 1) then the ZLSS pool will use super blocks 1, 2, 3n + * and 4n if we were to crash. This is TRUE even if we UNDO the + * transaction part of the segment add!!! We assume if we do UNDO + * then the segment add will be re-attempted as the last item in + * activation. + */ status = ZFSPOOL_SuperBlockHeaderWrite(storagepool, buffer, pool->ZP_super->SB_Header.hdr.superlocation[1-1]+SUPERBLOCKHEADER_SECTION,1); if ( status != zOK ) @@ -1665,24 +1651,24 @@ STATUS ZFSPOOL_SuperBlockMove( } /*** 6) Update the locations of Super Blocks 3n & 4n in the header - *** of the ZP_super. This causes all current users - *** to start writing to new locations. For example, - *** checkpoints will now be going to blocks 1, 2, 3n, and 4n. - *** Also update the total block count. - ***/ + *** of the ZP_super. This causes all current users + *** to start writing to new locations. For example, + *** checkpoints will now be going to blocks 1, 2, 3n, and 4n. + *** Also update the total block count. + ***/ pool->ZP_super->SB_Header.hdr.superlocation[4-1] = block4n; pool->ZP_super->SB_Header.hdr.superlocation[3-1] = block3n; pool->ZP_super->SB_Header.hdr.totalblocks = storagepool->pooltotalblocks; /*** 7) Modify super block header then free the space used by - *** super blocks 3 and 4. - ***/ + *** super blocks 3 and 4. + ***/ ((MediaSuperBlockHeader_s *)buffer)->hdr.SBH_Signature = - SUPERBLOCK_SB_S_SIGNATURE_OLD; + SUPERBLOCK_SB_S_SIGNATURE_OLD; /* WARNING - 'buffer' is no longer a 'good' super block header - */ + */ if ( block3 != block3n ) { (void)ZFSPOOL_SuperBlockHeaderWrite(storagepool,buffer, @@ -1691,12 +1677,12 @@ STATUS ZFSPOOL_SuperBlockMove( seedext.poolBlkNum = block3; seedext.lengthOfExtent = SUPERBLOCK_BLKCOUNT; /* FixFixFix6 - Should we use the famous ZLOG_DELETE_BLOCK so - * that the blocks are still around for a little while so that - * if anyone (e.g. checkpoints had already loaded old block 3 or 4 - * block number) that they have time to write before giving to a new - * user? Note that ZLOG_D... will not work because it assumes - * a log record block we would have to just call delayed delete? - */ + * that the blocks are still around for a little while so that + * if anyone (e.g. checkpoints had already loaded old block 3 or 4 + * block number) that they have time to write before giving to a new + * user? Note that ZLOG_D... will not work because it assumes + * a log record block we would have to just call delayed delete? + */ zfsFreeExtent(genMsg, &pool->ZFSPOOLzfsVol, &seedext, zfsXaction ); zASSERT(seedext.lengthOfExtent == 0); } @@ -1714,8 +1700,8 @@ STATUS ZFSPOOL_SuperBlockMove( #if 0 /*** 8) Release Volume State Latch. - ***/ - UNX_LATCH( &pool->ZFSPOOLvol.stateLatch ); + ***/ + UNX_LATCH( &pool->ZFSPOOLvol.stateLatch ); #endif free( buffer ); @@ -1725,7 +1711,7 @@ STATUS ZFSPOOL_SuperBlockMove( return( zOK ); /**** Error Exits - ****/ + ****/ error_haveLatch: #if 0 @@ -1739,7 +1725,7 @@ error_haveLatch: zfsFreeExtent(genMsg, pool, &seedext4n, zfsXaction ); zASSERT(seedext4n.lengthOfExtent == 0); } - UNX_LATCH( &pool->ZFSPOOLvol.stateLatch ); + UNX_LATCH( &pool->ZFSPOOLvol.stateLatch ); #endif free( buffer ); @@ -1783,9 +1769,9 @@ void ZFSPOOL_SuperBlockReservedValidate( data = zalloc( sizeof(MediaReservedHeader_s) ); if ( data == NULL ) - { + { DBG_DebugPrintf( CYAN, MSGNot("** Not enough memory to validate super blocks" - " reserved sections.\n") ); + " reserved sections.\n") ); RTN_VOID(); } for ( i=0; i < SUPERBLOCK_NUMBER; i++ ) @@ -1802,7 +1788,7 @@ void ZFSPOOL_SuperBlockReservedValidate( if (status != zOK) { DBG_DebugPrintf( CYAN, MSGNot("** Unable to read super block %d section" - " %d (%lu) for validation.\n" ), + " %d (%lu) for validation.\n" ), i+1, section,(unsigned long) pool->ZP_super->SB_Header.hdr.superlocation[i] + section); } @@ -1814,7 +1800,7 @@ void ZFSPOOL_SuperBlockReservedValidate( if ( mask != data->reserved[index] ) { DBG_DebugPrintf( LRED, MSGNot("** Super block %d section %d (%lu)" - " has been corrupted.\n" ), + " has been corrupted.\n" ), i+1, section,(unsigned long) pool->ZP_super->SB_Header.hdr.superlocation[i] + section ); @@ -1854,7 +1840,7 @@ LONG ZFSPOOL_CheckpointCalculateChecksum( } /************************************************************************** - * + * ***************************************************************************/ void ZFSPOOL_CheckpointCheckAndMakeBest( Checkpoint_s *currentBest, @@ -1873,7 +1859,7 @@ void ZFSPOOL_CheckpointCheckAndMakeBest( } /************************************************************************** - * + * ***************************************************************************/ STATUS ZFSPOOL_CheckpointFindNewest( GeneralMsg_s *genMsg, @@ -1906,9 +1892,9 @@ STATUS ZFSPOOL_CheckpointFindNewest( if ( status != zOK ) { /* No checkpoint could be read */ /* FixFixFix6 - This message says volume when it is really - * a pool. Fix when we no longer have a one to one - * relationship. - */ + * a pool. Fix when we no longer have a one to one + * relationship. + */ errPrintf(WHERE, Module, 1447, MSG("Unable to locate a valid checkpoint for " "the volume \"%U\", status=%d.\n" @@ -1927,7 +1913,7 @@ STATUS ZFSPOOL_CheckpointFindNewest( { /* We do not report an error because we did read in one valid checkpoint. */ /* We will assume all other checkpoints are bad */ - pool->ZP_BadCheckpoints = CHECKPOINT_NUMBER - 1; + pool->ZP_BadCheckpoints = CHECKPOINT_NUMBER - 1; RTN_STATUS( zOK ); } @@ -1942,7 +1928,7 @@ STATUS ZFSPOOL_CheckpointFindNewest( if ( status == zOK ) { ZFSPOOL_CheckpointCheckAndMakeBest(&destMediaCheckpoint->chkPnt, - &mediaCheckpoint->chkPnt ); + &mediaCheckpoint->chkPnt ); } } if ( status != zOK ) @@ -1975,7 +1961,7 @@ void ZFSPOOL_CheckpointFillin( NINT packedSize; ZnodeHeader_s *packedHeader; MediaCheckpoint_s *mcp = &pool->ZP_super->SB_Checkpoint; - ZlogBeast_s *logBeast; + ZlogBeast_s *logBeast; ENTER(TZPOOL, ZFSPOOL_CheckpointFillin); ASSERT_MPKNSS_LOCK(); @@ -2013,10 +1999,10 @@ void ZFSPOOL_CheckpointFillin( #if NSS_DEBUG IS_ENABLED //aprintf(LRED,"Checkpoint is %ld in size\n",packedSize + offsetof(Checkpoint_s,CP_PackedData) ); #endif - zASSERT((packedSize + offsetof(Checkpoint_s,CP_PackedData)) <= + zASSERT((packedSize + offsetof(Checkpoint_s,CP_PackedData)) <= sizeof(MediaCheckpoint_s) ); RTN_VOID(); -} +} /************************************************************************** * Make sure any files that is in the check point if written out. @@ -2025,7 +2011,7 @@ void ZFSPOOL_CheckpointFlushFiles( ZfsPool_s *pool, NINT state) /* If CHECKPOINT_CT_S_LAST is set, toss the cache buffers */ { - ZlogBeast_s *zlogBeast; + ZlogBeast_s *zlogBeast; ENTER(TZPOOL, ZFSPOOL_CheckpointFlushFiles); ASSERT_MPKNSS_LOCK(); @@ -2033,7 +2019,7 @@ void ZFSPOOL_CheckpointFlushFiles( zASSERT( state & CHECKPOINT_CT_S_MODE ); zlogBeast = pool->zfsLogBeast; - + //Zlog_FlushBeast(zlogBeast); cacheFlushMyCache(&zlogBeast->ZFSLOGmycache); X_BARRIER(&zlogBeast->ZFSLOGmycache.agent.latch); @@ -2057,11 +2043,11 @@ STATUS ZFSPOOL_CheckpointPoolInitialize( GeneralMsg_s *genMsg, ZfsPool_s *pool ) { - + STATUS status; NINT i; Checkpoint_s *checkpoint; - + ENTER(TZPOOL, ZFSPOOL_CheckpointPoolInitialize); ASSERT_MPKNSS_LOCK(); @@ -2107,7 +2093,7 @@ STATUS ZFSPOOL_CheckpointReadNext( #endif /************************************************************************** - * + * ***************************************************************************/ STATUS ZFSPOOL_CheckpointReadSpecific( ZfsPool_s *pool, @@ -2133,7 +2119,7 @@ STATUS ZFSPOOL_CheckpointReadSpecific( /************************************************************************** * ZFSPOOL_CheckpointSetRestartID - - * This updates the activation count of the volume. The trustee cache + * This updates the activation count of the volume. The trustee cache * of the ZAS authorization system uses to ensure that the cache is * correct for a given AUTH beast on the volume. The AUTH system stores * cacheing information persistently on the volume. @@ -2158,31 +2144,31 @@ STATUS ZFSPOOL_CheckpointSetRestartID( ASSERT_XLATCH( &pool->ZFSPOOLvol.stateLatch ); zASSERT( pool->ZP_super != NULL ); /* This is a activation count for the volume. Not persistent in - * Volume_s because too big of a change for Gold Release of MOAB. - * ZLSS stores in the checkpoint because that is were Neal put - * it long ago. At least this way we have 4 copies of it. - * - * Also note that /Rebuild does not rebuild checkpoints unlike - * the Volume Data Blocks. If in Volume Data Block then Rebuild - * would have to scan whole volume for AUTH beast with highest - * activation/restart count in it. - */ + * Volume_s because too big of a change for Gold Release of MOAB. + * ZLSS stores in the checkpoint because that is were Neal put + * it long ago. At least this way we have 4 copies of it. + * + * Also note that /Rebuild does not rebuild checkpoints unlike + * the Volume Data Blocks. If in Volume Data Block then Rebuild + * would have to scan whole volume for AUTH beast with highest + * activation/restart count in it. + */ ++pool->ZP_super->SB_Checkpoint.chkPnt.CP_ZasRestartId; /* Take all 4 checkpoints just in case a read error occurs - * after a crash. I.E. if we wrote one and then created - * Auth beasts with a activation count that will be lost - * because of a crash then we open the possibility of - * confussing the AUTH cache code. - */ + * after a crash. I.E. if we wrote one and then created + * Auth beasts with a activation count that will be lost + * because of a crash then we open the possibility of + * confussing the AUTH cache code. + */ for ( i=0; i < CHECKPOINT_NUMBER; i++ ) { status = ZFSPOOL_CheckpointTake(genMsg,pool, CHECKPOINT_CT_S_SET_RESTART_ID|CHECKPOINT_CT_S_NORMAL); if (status != zOK) { /* Error out because we really like to be able to - * write our checkpoints in a running system. - */ + * write our checkpoints in a running system. + */ RTN_STATUS(zFAILURE); } } @@ -2197,7 +2183,7 @@ STATUS ZFSPOOL_CheckpointSetRestartID( /************************************************************************** - * STATUS ZFSPOOL_CheckpointFindNewest( + * STATUS ZFSPOOL_CheckpointFindNewest( * GeneralMsg *genMsg, * ZfsPool_s *pool * MediaCheckpoint_s *destMediaCheckpoint ) @@ -2235,7 +2221,7 @@ STATUS ZFSPOOL_CheckpointSetRestartID( * de-activated. A Non-clean checkpoint MUST have an correct home pointer * for recovery to work. This simply means that all metadata 'left' of * the home pointer has been homed. This is ALWAYS true. - * + * * A clean checkpoint ensures that all log buffers have been flushed. It * currently does not ensure that all transactions have been homed. This * is done by ????(FixFixFix6 - just update the comment). @@ -2267,8 +2253,8 @@ STATUS ZFSPOOL_CheckpointTake( if (zlogBeast->ZLB_State & ZLOG_ZB_S_DOING_COMPENSATION) { /* We should not be taking checkpoints while writing compensation - * records - */ + * records + */ return zOK; } @@ -2280,32 +2266,32 @@ STATUS ZFSPOOL_CheckpointTake( } #endif /** - * THIS IS NO LONGER TRUE - Read 2nd Paragraph for current actions - * Here we look at the return code of REDO/UNDO to make an - * educated guess about skipping taking checkpoints. Current - * design is to not take a checkpoint only if we get an - * zERR_NO_MEMORY. If we take a checkpoint when REDO/UNDO - * fails it means that the next time the pool is activated - * we will NOT REDO/UNDO. This is good when we have some - * REDO/UNDO problem that will occur over and over. For example, - * a REDO routine that is unhappy. - * - * AS of May 26, 2000 (MI2 day) the following is TRUE. - * We always refuse to take checkpoints if REDO/UNDO fails. If - * some sort of permament error is occuring then the customer - * will have to contact us or run rebuild. They can not run - * verify as it will do REDO/UNDO also. Vandana and I agreed - * to this new logical so that we can find REDO/UNDO bugs. - * In addition, this fixes SPD 65463 (debug system also takes - * checkpoints on REDO/UNDO errors). What we are trying to prevent - * is taking a checkpoint that has moved home. I.E. it is technically - * legal to take a checkpoint as long as HOME still indicates - * that we need to do UNDO/REDO. We still use the below check - * so that if home moves for some reason (like someone logged - * something) we do not mess up REDO/UNDO on the next activate. - * NOTE that the debug system would log checkpoints before this - * check was added. - */ + * THIS IS NO LONGER TRUE - Read 2nd Paragraph for current actions + * Here we look at the return code of REDO/UNDO to make an + * educated guess about skipping taking checkpoints. Current + * design is to not take a checkpoint only if we get an + * zERR_NO_MEMORY. If we take a checkpoint when REDO/UNDO + * fails it means that the next time the pool is activated + * we will NOT REDO/UNDO. This is good when we have some + * REDO/UNDO problem that will occur over and over. For example, + * a REDO routine that is unhappy. + * + * AS of May 26, 2000 (MI2 day) the following is TRUE. + * We always refuse to take checkpoints if REDO/UNDO fails. If + * some sort of permament error is occuring then the customer + * will have to contact us or run rebuild. They can not run + * verify as it will do REDO/UNDO also. Vandana and I agreed + * to this new logical so that we can find REDO/UNDO bugs. + * In addition, this fixes SPD 65463 (debug system also takes + * checkpoints on REDO/UNDO errors). What we are trying to prevent + * is taking a checkpoint that has moved home. I.E. it is technically + * legal to take a checkpoint as long as HOME still indicates + * that we need to do UNDO/REDO. We still use the below check + * so that if home moves for some reason (like someone logged + * something) we do not mess up REDO/UNDO on the next activate. + * NOTE that the debug system would log checkpoints before this + * check was added. + */ if ( zlogBeast->ZLB_RedoUndoStatus != zOK ) { DEBUG_PRINTF(TZPOOL, DBG_INDENT,(LRED, @@ -2330,15 +2316,15 @@ STATUS ZFSPOOL_CheckpointTake( #endif #if NSS_ASSERT IS_ENABLED - { + { void *link1; // Link prior to CANCEL void *link2; // Link after CANCEL link1 = zlogBeast->ZLB_CheckpointTakeWorkToDoTimer.link.next; #endif - /* Cancel checkpoint timer (this works even if not the timer - * is not currently scheduled). - */ + /* Cancel checkpoint timer (this works even if not the timer + * is not currently scheduled). + */ CANCEL_ALARM( zlogBeast->ZLB_CheckpointTakeWorkToDoTimer ); #if NSS_ASSERT IS_ENABLED link2 = zlogBeast->ZLB_CheckpointTakeWorkToDoTimer.link.next; @@ -2349,7 +2335,7 @@ STATUS ZFSPOOL_CheckpointTake( } #endif /* The ZLB_State element needsMPKNSS_LOCK() protection */ - + #if NSS_ASSERT IS_ENABLED if ( zlogBeast->ZLB_State & ZLOG_ZB_S_TAKING_CHECKPOINT ) { @@ -2361,10 +2347,10 @@ STATUS ZFSPOOL_CheckpointTake( { WARN( "Someone asked for a checkpoint after deactivation" == NULL ); /* The above can happen if timer has past point of cancel, - * but has not yet executed this function. If this is - * the cause then NOT AN ERROR! - */ - + * but has not yet executed this function. If this is + * the cause then NOT AN ERROR! + */ + goto CT_exit; } /* Will this be the last checkpoint? */ @@ -2374,7 +2360,7 @@ STATUS ZFSPOOL_CheckpointTake( /* Record deactivation time in ZLOG beast */ zlogBeast->ZLB_P.ZLBP_TimeDeactivation = GetUTCTime(); } - + /* Are we doing special debug code? */ #if NSS_DEBUG IS_ENABLED @@ -2386,15 +2372,15 @@ STATUS ZFSPOOL_CheckpointTake( if ( state & CHECKPOINT_CT_S_TIMER ) { /* - * This code prevents us from taking checkpoints if the home - * has not moved. We only perform this if it is the timer - * because the timer always runs. This prevents us from - * taking checkpoints (writing to the media) when nothing - * is really occurring. - */ + * This code prevents us from taking checkpoints if the home + * has not moved. We only perform this if it is the timer + * because the timer always runs. This prevents us from + * taking checkpoints (writing to the media) when nothing + * is really occurring. + */ NINT oldest; - + S_LATCH( &zlogBeast->ZFSLOGbeastLatch ); oldest = zlog_GetOldestCheckpointIndex( zlogBeast ); /* Do we have four checkpoints that all have the same Home Pointer? */ @@ -2409,24 +2395,24 @@ STATUS ZFSPOOL_CheckpointTake( #if NSS_DEBUG IS_ENABLED #if 1 /* - * Because of deadlock problems we do not log when near full. - * We deadlock because if we must take a checkpoint to clear - * the full condition and this thread may block waiting for - * the ZLOG file to become unfull. No real reason to pick - * within 20 blocks as to close to full. - */ + * Because of deadlock problems we do not log when near full. + * We deadlock because if we must take a checkpoint to clear + * the full condition and this thread may block waiting for + * the ZLOG file to become unfull. No real reason to pick + * within 20 blocks as to close to full. + */ { NINT blocksInUse; Volume_s *volTmp; - + ++zlogBeast->ZLB_P.ZLBP_FileThrottleCheckpointCount; - if ( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber <= + if ( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber <= zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber ) { /* Do wrap math calculation */ blocksInUse = (NINT)zlogBeast->ZLB_NumberOfLogBlocks - (NINT)zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber + - (NINT)zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; - zASSERT( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber != + (NINT)zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; + zASSERT( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber != zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber ); } else @@ -2439,26 +2425,26 @@ STATUS ZFSPOOL_CheckpointTake( { okToLog = FALSE; } - + volTmp = &pool->ZFSPOOLvol; - + if ( ZLSS_IS_MAINTENANCE_IO( volTmp ) ) { okToLog = FALSE; } } - + okToLog = FALSE; if ( okToLog ) - + { /* - * This debug code puts a copy of the ZLOG Beast into a log record - * as a normal transaction. It has a side effect in that we will - * always take checkpoints (every 30 secs) because the home pointer - * will always be moving. - */ + * This debug code puts a copy of the ZLOG Beast into a log record + * as a normal transaction. It has a side effect in that we will + * always take checkpoints (every 30 secs) because the home pointer + * will always be moving. + */ ZfsXaction_s *localXaction; ZfsXasRecovery_s *logBuffer; @@ -2466,34 +2452,34 @@ STATUS ZFSPOOL_CheckpointTake( BYTE *logRecord; zASSERT( zlogBeast->ZFSLOGroot.vol.volume != NULL ); - + localXaction = BeginXLocal(zlogBeast->ZFSLOGroot.vol.volume ,BXL_DEFAULT); - + /* - * Because we take some checkpoints real early we need to - * poke the Xaction. - */ - + * Because we take some checkpoints real early we need to + * poke the Xaction. + */ + localXaction->ZX_zlogBeast = zlogBeast; - + ZLOG_ObtainRecord( localXaction, sizeof(*zlogBeast) ); - + ZLOG_INIT_LOG_RECORD(XFUNC_IGNORE, localXaction, logBuffer, 0, - poolBlks, logRecord); + poolBlks, logRecord); memcpy( logRecord/*Dest*/, zlogBeast, sizeof(*zlogBeast)); - + /* - * By not doing this bind, ZLOG will get to update the home pointer - * right away (during EndXlocal()). Therefore we will not - * think we need to redo this log record during recovery. Note - * this only works because we really do not care if the log buffer - * gets written, because we have no metadata. - */ + * By not doing this bind, ZLOG will get to update the home pointer + * right away (during EndXlocal()). Therefore we will not + * think we need to redo this log record during recovery. Note + * this only works because we really do not care if the log buffer + * gets written, because we have no metadata. + */ // bind( &localXaction->agent, &zlogBeast->ZLB_Buffer->agent); - + ZLOG_ReleaseRecordAndLogEnd(localXaction); - + EndXlocal(localXaction); } #endif @@ -2503,11 +2489,11 @@ STATUS ZFSPOOL_CheckpointTake( #if 1 if ( okToLog ) /* - * This debug code puts a copy of the Checkpoint_s into a log record - * as a normal transaction. It has a side effect in that we will - * always take checkpoints (every 30 secs) because the home pointer - * will always be moving. - */ + * This debug code puts a copy of the Checkpoint_s into a log record + * as a normal transaction. It has a side effect in that we will + * always take checkpoints (every 30 secs) because the home pointer + * will always be moving. + */ { ZfsXaction_s *localXaction; ZfsXasRecovery_s *logBuffer; @@ -2520,31 +2506,31 @@ STATUS ZFSPOOL_CheckpointTake( zASSERT( zlogBeast->ZFSLOGroot.vol.volume != NULL ); localXaction = BeginXLocal(zlogBeast->ZFSLOGroot.vol.volume ,BXL_DEFAULT); /* - * Because we take some checkpoints real early we need to - * poke the Xaction. - */ + * Because we take some checkpoints real early we need to + * poke the Xaction. + */ localXaction->ZX_zlogBeast = zlogBeast; ZLOG_ObtainRecord( localXaction, sizeof(*checkpoint) ); ZLOG_INIT_LOG_RECORD(XFUNC_IGNORE, localXaction, logBuffer, 0, - poolBlks, logRecord); + poolBlks, logRecord); memcpy( logRecord/*Dest*/, checkpoint, sizeof(*checkpoint)); /* - * By not doing this bind ZLOG will get to update the home pointer - * right away (during EndXlocal()) and therefore we will not - * think we need to redo this log record during recovery. Note - * this only works because we really do not care if the log buffer - * gets written, because we have no metadata. - */ + * By not doing this bind ZLOG will get to update the home pointer + * right away (during EndXlocal()) and therefore we will not + * think we need to redo this log record during recovery. Note + * this only works because we really do not care if the log buffer + * gets written, because we have no metadata. + */ // bind( &localXaction->agent, &zlogBeast->ZLB_Buffer->agent); ZLOG_ReleaseRecordAndLogEnd(localXaction); EndXlocal(localXaction); fakeState = state & ~CHECKPOINT_CT_S_REASON; /* Turn off reason */ fakeState |= CHECKPOINT_CT_S_DEBUG; /* Set new reason */ /* - * Redo this call so we get the updated home pointer that - * allows recovery detect if we did a clean checkpoint even - * when we are logging the checkpoint for debug. - */ + * Redo this call so we get the updated home pointer that + * allows recovery detect if we did a clean checkpoint even + * when we are logging the checkpoint for debug. + */ ZFSPOOL_CheckpointFillin(pool, fakeState); } #endif @@ -2559,8 +2545,8 @@ STATUS ZFSPOOL_CheckpointTake( status = ZFSPOOL_CheckpointWriteNext( pool ); if ( status != zOK ) { /* Note that serious I/O errors will cause volume to be disabled. - * This is done by the low level ZLSS I/O routines. - */ + * This is done by the low level ZLSS I/O routines. + */ GeneralMsg_s dummyGenMsg; Blknum_t blk; ZFSMemorySuperBlk_s *super; @@ -2569,19 +2555,19 @@ STATUS ZFSPOOL_CheckpointTake( if ( (super == NULL) || (pool->ZP_NextCheckpoint >= CHECKPOINT_NUMBER) ) { /* Really should not be needed, but but safe than sorry */ blk = 0; - } + } else { blk = super->SB_Header.hdr.superlocation[pool->ZP_NextCheckpoint] + CHECKPOINT_SECTION; } /* Now tell the common layer that we wish to disable this volume. - * This is an ASYNC call. - */ + * This is an ASYNC call. + */ COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); (void)COMN_VolumeAlert( &dummyGenMsg, NULL, &pool->ZFSPOOLvol, NULL, - blk, blk, status, WHERE, - CVA_SYSTEM_DATA | CVA_POOL_DISABLE | CVA_POOL_ALERT ); + blk, blk, status, WHERE, + CVA_SYSTEM_DATA | CVA_POOL_DISABLE | CVA_POOL_ALERT ); SetErrno(genMsg, status); goto CT_exit; } @@ -2591,11 +2577,11 @@ STATUS ZFSPOOL_CheckpointTake( (unsigned long)(zlogBeast->ZLB_P.ZLBP_HomePointerLsn >> 32), (unsigned long)(zlogBeast->ZLB_P.ZLBP_HomePointerLsn) ) ); /* - * To know when the ZLOG file is full we must track the home pointer - * stored in the four checkpoints. Because taking a checkpoint creates - * a new oldest checkpoint (by writing over the previous oldest - * checkpoint) we track here. - */ + * To know when the ZLOG file is full we must track the home pointer + * stored in the four checkpoints. Because taking a checkpoint creates + * a new oldest checkpoint (by writing over the previous oldest + * checkpoint) we track here. + */ oldest = zlog_GetOldestCheckpointIndex( zlogBeast ); zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber = zlogBeast->ZLB_P.ZLBP_OldHomePointerBlockNumber[ oldest ]; @@ -2606,36 +2592,36 @@ STATUS ZFSPOOL_CheckpointTake( /* If there are file full waiters then we need to wake them up. */ if ( zlogBeast->ZLB_FileFullWaiters != 0 ) { /* - * If the file is still full then the sleepers will go right back - * to sleep. We do not check before waking up so we only - * take code hit on file FULL - * verses all the time (if we checked here). - */ + * If the file is still full then the sleepers will go right back + * to sleep. We do not check before waking up so we only + * take code hit on file FULL + * verses all the time (if we checked here). + */ UNX_LATCH( &zlogBeast->ZLB_FileFullLatch ); zlogBeast->ZLB_FileFullWaiters = 0; } - + /* - * Reset the counter that ensures checkpoints are taken every so many - * log blocks. - */ + * Reset the counter that ensures checkpoints are taken every so many + * log blocks. + */ zlogBeast->ZLB_LogBlockFilledInSinceCheckpointCount = 0; /* - * If there are file 'too' full waiters then we may need - * to wake them up. - */ - /* Are we in throttle back mode? */ + * If there are file 'too' full waiters then we may need + * to wake them up. + */ + /* Are we in throttle back mode? */ if ( zlogBeast->ZLB_P.ZLBP_Mode & ZLOG_THROTTLE_BACK ) { /* YES - see if we can go full throttle again. */ NINT blocksInUse; ++zlogBeast->ZLB_P.ZLBP_FileThrottleCheckpointCount; - if ( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber <= + if ( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber <= zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber ) { /* Do wrap math calculation */ blocksInUse = (NINT)zlogBeast->ZLB_NumberOfLogBlocks - (NINT)zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber + - (NINT)zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; - zASSERT( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber != + (NINT)zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; + zASSERT( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber != zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber ); } else @@ -2664,23 +2650,23 @@ STATUS ZFSPOOL_CheckpointTake( } /* - * Reset the counter that ensures checkpoints are taken every so many - * log blocks. - */ + * Reset the counter that ensures checkpoints are taken every so many + * log blocks. + */ // zlogBeast->ZLB_LogBlockFilledInSinceCheckpointCount = 0; // UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); { /* - * We now must signal the purge block code so that it can - * release purged blocks into the Free B-Tree. It does this - * by freeing all blocks that were purged before the LSN - * we pass to the purge block code. This LSN is the home - * pointer's LSN of the oldest checkpoint. This is referred - * to as the undo pointer's LSN. In otherwords, the log - * records that have lower LSNs will never be included in - * the recovery area (i.e. then will never be undone). - */ + * We now must signal the purge block code so that it can + * release purged blocks into the Free B-Tree. It does this + * by freeing all blocks that were purged before the LSN + * we pass to the purge block code. This LSN is the home + * pointer's LSN of the oldest checkpoint. This is referred + * to as the undo pointer's LSN. In otherwords, the log + * records that have lower LSNs will never be included in + * the recovery area (i.e. then will never be undone). + */ NINT index; Lsn_t undoPointerLsn; @@ -2698,9 +2684,9 @@ STATUS ZFSPOOL_CheckpointTake( CT_exit: /******/ /* Re-schedule timer (most of the time) */ - + if ( !(zlogBeast->ZLB_State & ZLOG_ZB_S_NO_MORE_CHECKPOINTS) && - !(zlogBeast->ZLB_State & ZLOG_ZB_S_NEEDTODO_COMPENSATION) ) + !(zlogBeast->ZLB_State & ZLOG_ZB_S_NEEDTODO_COMPENSATION) ) { /* Set a new timer because checkpoints are still allowed. */ #if NSS_DEBUG IS_ENABLED if ( QMEMBER(&zlogBeast->ZLB_CheckpointTakeWorkToDoTimer.link) ) @@ -2713,7 +2699,7 @@ CT_exit: } /* Indicate that no one is taking a checkpoint */ zlogBeast->ZLB_State &= ~ZLOG_ZB_S_TAKING_CHECKPOINT; - + #if NSS_DEBUG IS_ENABLED zlogBeast->ZLB_CheckpointThreadIdLast = zlogBeast->ZLB_CheckpointThreadId; zlogBeast->ZLB_CheckpointThreadId = 0; @@ -2731,7 +2717,7 @@ CT_exit: void ZFSPOOL_CheckpointTimerPop( OneShot_s *alarm) { - ZlogBeast_s *zlogBeast; + ZlogBeast_s *zlogBeast; ENTER(TZPOOL, ZFSPOOL_CheckpointTimerPop); ASSERT_MPKNSS_LOCK(); @@ -2748,20 +2734,20 @@ void ZFSPOOL_CheckpointTimerPop( } /************************************************************************** - * + * ***************************************************************************/ STATUS ZFSPOOL_CheckpointVerify( MediaCheckpoint_s *mediaCheckpoint ) { - + STATUS status; LONG checksum; Checkpoint_s *checkpoint; ENTER(TZPOOL, ZFSPOOL_CheckpointVerify); ASSERT_MPKNSS_LOCK(); - + checkpoint = (Checkpoint_s *)mediaCheckpoint; /* Is the length larger than our buffer? */ if ( checkpoint->CP_PackedSize > (sizeof(*mediaCheckpoint)) ) @@ -2795,7 +2781,7 @@ STATUS ZFSPOOL_CheckpointVerify( #if ZLOG_TEST IS_ENABLED /* I print this so I can update diagrams. Not real correct to be based on ZLOG, but close enough. */ - if ( ZlogUnitTest ) + if ( ZlogUnitTest ) { aprintf(LGREEN,MSGNot("Checkpoint - Packed size %ld\n"), checkpoint->CP_PackedSize ); @@ -2844,7 +2830,7 @@ STATUS ZFSPOOL_CheckpointWriteNext( } /************************************************************************** - * + * ***************************************************************************/ STATUS ZFSPOOL_CheckpointWriteSpecific( ZfsPool_s *pool, @@ -2869,3 +2855,4 @@ STATUS ZFSPOOL_CheckpointWriteSpecific( /* FixFixFix6(A Greg ?) some code does re-tries on errors WHAT is ZLSS rule? */ + diff --git a/src/nwnss/zlss/zfsSuperBlk.h b/src/nwnss/zlss/zfsSuperBlk.h index e023112..8d2c822 100644 --- a/src/nwnss/zlss/zfsSuperBlk.h +++ b/src/nwnss/zlss/zfsSuperBlk.h @@ -63,7 +63,7 @@ struct ZfsXaction_s; #define SUPERBLOCK_PHYSICAL_SIZE (MAL_BUFSZ64K) /* 64 K */ #define SUPERBLOCK_SECTION_SIZE (MAL_BUFSZ4K) #define SUPERBLOCK_BLKCOUNT \ - (sizeof(ZFSMediaSuperBlk_s) / SUPERBLOCK_SECTION_SIZE) + (sizeof(ZFSMediaSuperBlk_s) / SUPERBLOCK_SECTION_SIZE) /*--------------------------------------------------------------------------- * This is where all of the beasts that are part of the super block are @@ -74,9 +74,9 @@ struct ZfsXaction_s; #define CHECKPOINT_NUMBER (4) /* Number of checkpoints */ #define CHECKPOINT_BLKCOUNT \ - (sizeof(MediaCheckpoint_s)/SUPERBLOCK_SECTION_SIZE) + (sizeof(MediaCheckpoint_s)/SUPERBLOCK_SECTION_SIZE) #define CHECKPOINT_SECTION \ - (offsetof(ZFSMediaSuperBlk_s,SB_Checkpoint)/SUPERBLOCK_SECTION_SIZE) + (offsetof(ZFSMediaSuperBlk_s,SB_Checkpoint)/SUPERBLOCK_SECTION_SIZE) /* * Be sure to update Template Checkpoint_s in magic.ztm if you change @@ -86,40 +86,40 @@ struct ZfsXaction_s; typedef struct Checkpoint_s { - LONG CP_Signature; /* Signature of block, must always be first*/ - WORD CP_VersionMajor; - /* The major version of the checkpoint. Changes when - * checkpoint is no longer compatible with an older version - * of the checkpoint. The first release will have this - * set to 1. To display use "%u.%02u" as the format string. - */ - WORD CP_VersionMinor; - /* The minor version of the checkpoint. Changes when old - checkpoints are still compatible. This will be 0 in the - first release. */ - LONG CP_PackedSize; - /* Total packed size of checkpoint. This includes - * the packed beast area as well as all the CP_xxx - * elements of the checkpoint. This is the number of bytes - * to checksum.*/ - LONG CP_Checksum; - /* Checksum of active bytes (includes bytes in - * CP_PackedData[]). */ - QUAD CP_SyncId; - /* increasing number to verify current instance */ - Time_t CP_ModifiedTime; /* when checkpoint was last modified(written) */ - LONG CP_NumPackedBeasts; /* how many beasts are in the SUPERBLK */ - LONG CP_ZasRestartId; /* used for ZAS effective rights cache */ - LONG CP_State; /* State that indicates what caused checkpoint. - * See CHECKPOINT_CT_S_ defines below for legal - * values. - */ - LONG CP_Reserved[20]; /* growth space plus align to QUAD boundry*/ + LONG CP_Signature; /* Signature of block, must always be first*/ + WORD CP_VersionMajor; + /* The major version of the checkpoint. Changes when + * checkpoint is no longer compatible with an older version + * of the checkpoint. The first release will have this + * set to 1. To display use "%u.%02u" as the format string. + */ + WORD CP_VersionMinor; + /* The minor version of the checkpoint. Changes when old + checkpoints are still compatible. This will be 0 in the + first release. */ + LONG CP_PackedSize; + /* Total packed size of checkpoint. This includes + * the packed beast area as well as all the CP_xxx + * elements of the checkpoint. This is the number of bytes + * to checksum.*/ + LONG CP_Checksum; + /* Checksum of active bytes (includes bytes in + * CP_PackedData[]). */ + QUAD CP_SyncId; + /* increasing number to verify current instance */ + Time_t CP_ModifiedTime; /* when checkpoint was last modified(written) */ + LONG CP_NumPackedBeasts; /* how many beasts are in the SUPERBLK */ + LONG CP_ZasRestartId; /* used for ZAS effective rights cache */ + LONG CP_State; /* State that indicates what caused checkpoint. + * See CHECKPOINT_CT_S_ defines below for legal + * values. + */ + LONG CP_Reserved[20]; /* growth space plus align to QUAD boundry*/ - /* CP_PackedData must be the last item in the checkpoint and - located on a QUAD boundary. Code will ASSERT if not located - on QUAD boundary */ - BYTE CP_PackedData[8]; /* space where packed data goes */ + /* CP_PackedData must be the last item in the checkpoint and + located on a QUAD boundary. Code will ASSERT if not located + on QUAD boundary */ + BYTE CP_PackedData[8]; /* space where packed data goes */ } NSS_MEDIA_STRUCTURE(Checkpoint_s,CP_PackedData[8]) Checkpoint_s; /* @@ -129,19 +129,19 @@ typedef struct Checkpoint_s #define CHECKPOINT_CP_VM_MAJOR 8 /* */ #define CHECKPOINT_CP_VM_MINOR 0 /* */ - + #define CHECKPOINT_CP_S_SIGNATURE (0x37504b43uL) /* 'CKP7' */ - /*** State values for ZFSPOOL_CheckpointTake ***/ + /*** State values for ZFSPOOL_CheckpointTake ***/ - /* These are the three 'modes' of the checkpoint */ + /* These are the three 'modes' of the checkpoint */ #define CHECKPOINT_CT_S_NORMAL 0x00000001u #define CHECKPOINT_CT_S_CLEAN 0x00000002u #define CHECKPOINT_CT_S_LAST 0x00000004u #define CHECKPOINT_CT_S_MODE (CHECKPOINT_CT_S_NORMAL| \ - CHECKPOINT_CT_S_CLEAN|CHECKPOINT_CT_S_LAST) - /* These are the 13 'reasons' a checkpoint is taken */ + CHECKPOINT_CT_S_CLEAN|CHECKPOINT_CT_S_LAST) + /* These are the 13 'reasons' a checkpoint is taken */ #define CHECKPOINT_CT_S_NO_UNDO_COMMITTED 0x00000010u #define CHECKPOINT_CT_S_DEFERED_DELETE 0x00000020u #define CHECKPOINT_CT_S_THROTTLE_BACK 0x00000040u @@ -156,12 +156,12 @@ typedef struct Checkpoint_s #define CHECKPOINT_CT_S_RECOVERY 0x00008000u #define CHECKPOINT_CT_S_L_UNDO 0x00010000u #define CHECKPOINT_CT_S_REASON (CHECKPOINT_CT_S_DEFERED_DELETE| \ - CHECKPOINT_CT_S_THROTTLE_BACK|CHECKPOINT_CT_S_NO_UNDO_COMMITTED|\ - CHECKPOINT_CT_S_DEBUG|CHECKPOINT_CT_S_POOL_INITIALIZE| \ - CHECKPOINT_CT_S_SET_RESTART_ID|CHECKPOINT_CT_S_HOME_MOVEMENT| \ - CHECKPOINT_CT_S_ACTIVE_MOVEMENT|CHECKPOINT_CT_S_TIMER| \ - CHECKPOINT_CT_S_MIRACLE|CHECKPOINT_CT_S_DEACTIVATION| \ - CHECKPOINT_CT_S_RECOVERY|CHECKPOINT_CT_S_L_UNDO) + CHECKPOINT_CT_S_THROTTLE_BACK|CHECKPOINT_CT_S_NO_UNDO_COMMITTED|\ + CHECKPOINT_CT_S_DEBUG|CHECKPOINT_CT_S_POOL_INITIALIZE| \ + CHECKPOINT_CT_S_SET_RESTART_ID|CHECKPOINT_CT_S_HOME_MOVEMENT| \ + CHECKPOINT_CT_S_ACTIVE_MOVEMENT|CHECKPOINT_CT_S_TIMER| \ + CHECKPOINT_CT_S_MIRACLE|CHECKPOINT_CT_S_DEACTIVATION| \ + CHECKPOINT_CT_S_RECOVERY|CHECKPOINT_CT_S_L_UNDO) /*--------------------------------------------------------------------------- @@ -169,8 +169,8 @@ typedef struct Checkpoint_s *---------------------------------------------------------------------------*/ typedef struct MediaCheckpoint_s { - Checkpoint_s chkPnt; - BYTE reserved[SUPERBLOCK_SECTION_SIZE - sizeof(Checkpoint_s)]; /* ZEROED */ + Checkpoint_s chkPnt; + BYTE reserved[SUPERBLOCK_SECTION_SIZE - sizeof(Checkpoint_s)]; /* ZEROED */ } NSS_MEDIA_STRUCTURE(MediaCheckpoint_s,reserved[SUPERBLOCK_SECTION_SIZE - sizeof(Checkpoint_s)]) MediaCheckpoint_s; /*--------------------------------------------------------------------------- @@ -178,34 +178,34 @@ typedef struct MediaCheckpoint_s * work on both signed and unsigned numbers. *---------------------------------------------------------------------------*/ #define CHECKPOINT_GET_NEXT( _checkpoint ) \ - *(_checkpoint) += 1; \ - if ( *(_checkpoint) >= CHECKPOINT_NUMBER ) \ - { \ - *(_checkpoint) = 0; \ - } + *(_checkpoint) += 1; \ + if ( *(_checkpoint) >= CHECKPOINT_NUMBER ) \ + { \ + *(_checkpoint) = 0; \ + } /*--------------------------------------------------------------------------- * Gets the previous checkpoint number i.e. handles wrap. This macro * must work on both signed and unsigned numbers. *---------------------------------------------------------------------------*/ #define CHECKPOINT_GET_PREVIOUS( _checkpoint ) \ - if ( *(_checkpoint) == 0 ) \ - { \ - *(_checkpoint) = CHECKPOINT_NUMBER - 1; \ - } \ - else \ - { \ - *(_checkpoint) -= 1; \ - } + if ( *(_checkpoint) == 0 ) \ + { \ + *(_checkpoint) = CHECKPOINT_NUMBER - 1; \ + } \ + else \ + { \ + *(_checkpoint) -= 1; \ + } /*--------------------------------------------------------------------------- | Super Block Header Specific Items +-------------------------------------------------------------------------*/ #define SUPERBLOCKHEADER_SECTION \ - (offsetof(ZFSMediaSuperBlk_s, SB_Header)/SUPERBLOCK_SECTION_SIZE) + (offsetof(ZFSMediaSuperBlk_s, SB_Header)/SUPERBLOCK_SECTION_SIZE) #define SUPERBLOCKHEADER_BLKCOUNT \ - (sizeof(MediaSuperBlockHeader_s) / SUPERBLOCK_SECTION_SIZE) + (sizeof(MediaSuperBlockHeader_s) / SUPERBLOCK_SECTION_SIZE) #define SUPERBLOCKHEADER_SYNCSTARTVALUE (0x0000000e) @@ -217,201 +217,201 @@ typedef struct MediaCheckpoint_s typedef struct SuperBlockHeader_s { - /* general information */ - LONG SBH_Signature; /* Signature of block, must always be first*/ - WORD SBH_VersionMajor; - /* The major version of the super block header. Changes - * when the super block is no longer compatible - * with an older version of the super block header. - * The first release will have this set to 1. The - * define SUPERBLOCK_SB_VM_MAJOR specifies the current - * major version number of the header. To display - * use "%u.%02u" as the format string. - */ - WORD SBH_VersionMinor; - /* The minor version of the super block header. - * Changes when old super block header are still - * compatible. This will be 0 in the first release. - * The define SUPERBLOCK_SB_VM_MINOR specifies the - * current minor version number of the header. - */ - WORD SBH_VersionMediaMajor; - /* Major version of media. This is used to limit - * older ZSTORE systems from running on newer media when - * no changes occur in the superblock or checkpoint. It - * can also be used to prevent newer systems from running - * on old media that the system does not support. The - * define SUPERBLOCK_SB_VM_MEDIA_MAJOR specifies the current - * major media version. - */ - WORD SBH_VersionMediaMinor; - /* The minor version of the media. Indicates a compatible - * change has occurred to the media. This will be 0 - * in the first release. The define - * SUPERBLOCK_SB_VM_MEDIA_MINOR specifies the - * current minor version number of the media. - */ - LONG SBH_ItemsMoved; - /* Items moved is used in a specific auto in-place - * upgrade when we added logical volumes. Once - * the upgrade is done then this field can be re-used. - * It will be zero. - */ - GUID_t SBH_InternalID; - /* Must be at OFFSET 16 - unique 128 bit GUID used - * for internal ZLSS identification. - */ - LONG SBH_PackedSize; - /* Number of packed bytes in the header. */ - LONG SBH_Checksum; - /* Checksum of active bytes (SuperBlockHeader_s). */ + /* general information */ + LONG SBH_Signature; /* Signature of block, must always be first*/ + WORD SBH_VersionMajor; + /* The major version of the super block header. Changes + * when the super block is no longer compatible + * with an older version of the super block header. + * The first release will have this set to 1. The + * define SUPERBLOCK_SB_VM_MAJOR specifies the current + * major version number of the header. To display + * use "%u.%02u" as the format string. + */ + WORD SBH_VersionMinor; + /* The minor version of the super block header. + * Changes when old super block header are still + * compatible. This will be 0 in the first release. + * The define SUPERBLOCK_SB_VM_MINOR specifies the + * current minor version number of the header. + */ + WORD SBH_VersionMediaMajor; + /* Major version of media. This is used to limit + * older ZSTORE systems from running on newer media when + * no changes occur in the superblock or checkpoint. It + * can also be used to prevent newer systems from running + * on old media that the system does not support. The + * define SUPERBLOCK_SB_VM_MEDIA_MAJOR specifies the current + * major media version. + */ + WORD SBH_VersionMediaMinor; + /* The minor version of the media. Indicates a compatible + * change has occurred to the media. This will be 0 + * in the first release. The define + * SUPERBLOCK_SB_VM_MEDIA_MINOR specifies the + * current minor version number of the media. + */ + LONG SBH_ItemsMoved; + /* Items moved is used in a specific auto in-place + * upgrade when we added logical volumes. Once + * the upgrade is done then this field can be re-used. + * It will be zero. + */ + GUID_t SBH_InternalID; + /* Must be at OFFSET 16 - unique 128 bit GUID used + * for internal ZLSS identification. + */ + LONG SBH_PackedSize; + /* Number of packed bytes in the header. */ + LONG SBH_Checksum; + /* Checksum of active bytes (SuperBlockHeader_s). */ - LONG supersyncid; /* increasing number to verify current */ - SQUAD superlocation[SUPERBLOCK_NUMBER]; - /* Pool block location of super block (4 each) */ - LONG physSizeUsed; /* bytes used by super block physical */ - LONG sizeUsed; /* size of the super block in bytes */ - Time_t superTimeStamp; /* last time of superblk write (UTC) */ - LONG reserved0[1]; - SQUAD SBH_LoggedPoolDataBlk; /* Block number of the ZLSS Pool's - * data block. - */ - SQUAD SBH_PoolDataBlk; /* Block number of the ZLSS Pool's - * logged data block. - */ - GUID_t SBH_OldInternalID; /* 'LV Support */ - /* Old unique 128 bit GUID used for identification. This - * field will be 0 for pools that were created AFTER - * Logical Volumes added. The LV conversion code stores - * the OLD GUID of the pool here so that scan utilities - * can detect POOL specific system beast blocks that - * existed before conversion. Both this GUID and - * the SBH_VolumeID are legal for pool specific system - * beast blocks. For example, in the purge log or - * free tree. While the Beast Tree and Name Tree - * blocks will not have SBH_OldVolumeIDs in them. The - * scanner MUST not use SBH_OldVolumeIDs when matching - * NON POOL system beasts because it may find some blocks - * that belong to the Logical Volume that was created - * when the pool was converted to a LV. - */ - Time_t SBH_PoolToLVStartUTC; /* 'LV Support */ - Time_t SBH_PoolToLVEndUTC; /* 'LV Support */ - /* The above two times are FYI as to when the pool - * started and endded conversion from the old - * pool/volume format into the new LV format. - */ - WORD SBH_VersionMediaMajorCreate; /* 'LV Support */ - WORD SBH_VersionMediaMinorCreate; /* 'LV Support */ - /* The Create media versions above is the media - * version at the time the pool was created. This - * allows us to detect what auto in place upgrades - * have been applied to a pool. This can be useful - * in detecting things. For example, if the media - * version is 36.05 then we know that the volume - * has no 32 bit trustee information on it. Note - * that this field was first supported by LV upgrade - * which took place at 36.01. The AIPU that took - * place at 36.01 would save the current media version - * at the time of AIPU. Therefore any version less - * than 36.01 only indicates the media version at - * conversion. The actual media version at creation - * is unknown if create media version is 36.01 or less! - */ - LONG SBH_BlocksMoved; - /* Blocks moved is used in a specific auto in-place - * upgrade when we added logical volumes. Once - * the upgrade is done then this field can be re-used. - * It will be zero. - */ - LONG SBH_TempBTSpBlk; - /* This is the block allocated for beasttree special - * block, to be used during upgrades. When upgrade is - * complete it is reset back to zero - */ - LONG SBH_TempFTSpBlk; - /* This is the block allocated for freetree special - * block, to be used during upgrades. When upgrade is - * complete it is reset back to zero - */ - LONG SBH_TempFTSpBlk1; - /* This is the block allocated to put in FT special - * block, to be used during upgrades. When upgrade is - * complete it is reset back to zero - */ - LONG SBH_TempFTSpBlk2; - /* This is another block allocated to put in FT special - * block, to be used during upgrades. When upgrade is - * complete it is reset back to zero - */ + LONG supersyncid; /* increasing number to verify current */ + SQUAD superlocation[SUPERBLOCK_NUMBER]; + /* Pool block location of super block (4 each) */ + LONG physSizeUsed; /* bytes used by super block physical */ + LONG sizeUsed; /* size of the super block in bytes */ + Time_t superTimeStamp; /* last time of superblk write (UTC) */ + LONG reserved0[1]; + SQUAD SBH_LoggedPoolDataBlk; /* Block number of the ZLSS Pool's + * data block. + */ + SQUAD SBH_PoolDataBlk; /* Block number of the ZLSS Pool's + * logged data block. + */ + GUID_t SBH_OldInternalID; /* 'LV Support */ + /* Old unique 128 bit GUID used for identification. This + * field will be 0 for pools that were created AFTER + * Logical Volumes added. The LV conversion code stores + * the OLD GUID of the pool here so that scan utilities + * can detect POOL specific system beast blocks that + * existed before conversion. Both this GUID and + * the SBH_VolumeID are legal for pool specific system + * beast blocks. For example, in the purge log or + * free tree. While the Beast Tree and Name Tree + * blocks will not have SBH_OldVolumeIDs in them. The + * scanner MUST not use SBH_OldVolumeIDs when matching + * NON POOL system beasts because it may find some blocks + * that belong to the Logical Volume that was created + * when the pool was converted to a LV. + */ + Time_t SBH_PoolToLVStartUTC; /* 'LV Support */ + Time_t SBH_PoolToLVEndUTC; /* 'LV Support */ + /* The above two times are FYI as to when the pool + * started and endded conversion from the old + * pool/volume format into the new LV format. + */ + WORD SBH_VersionMediaMajorCreate; /* 'LV Support */ + WORD SBH_VersionMediaMinorCreate; /* 'LV Support */ + /* The Create media versions above is the media + * version at the time the pool was created. This + * allows us to detect what auto in place upgrades + * have been applied to a pool. This can be useful + * in detecting things. For example, if the media + * version is 36.05 then we know that the volume + * has no 32 bit trustee information on it. Note + * that this field was first supported by LV upgrade + * which took place at 36.01. The AIPU that took + * place at 36.01 would save the current media version + * at the time of AIPU. Therefore any version less + * than 36.01 only indicates the media version at + * conversion. The actual media version at creation + * is unknown if create media version is 36.01 or less! + */ + LONG SBH_BlocksMoved; + /* Blocks moved is used in a specific auto in-place + * upgrade when we added logical volumes. Once + * the upgrade is done then this field can be re-used. + * It will be zero. + */ + LONG SBH_TempBTSpBlk; + /* This is the block allocated for beasttree special + * block, to be used during upgrades. When upgrade is + * complete it is reset back to zero + */ + LONG SBH_TempFTSpBlk; + /* This is the block allocated for freetree special + * block, to be used during upgrades. When upgrade is + * complete it is reset back to zero + */ + LONG SBH_TempFTSpBlk1; + /* This is the block allocated to put in FT special + * block, to be used during upgrades. When upgrade is + * complete it is reset back to zero + */ + LONG SBH_TempFTSpBlk2; + /* This is another block allocated to put in FT special + * block, to be used during upgrades. When upgrade is + * complete it is reset back to zero + */ /* LONG reserved1[4-4]; */ - /* Extra space and keep aligned to QUAD boundary - * (4 longs). This space contains zeros. - */ + /* Extra space and keep aligned to QUAD boundary + * (4 longs). This space contains zeros. + */ - /* pool information */ - LONG nssMagicNumber; /* NSS data layout on disk */ - LONG poolClassID; /* classID of this pool */ - LONG poolID; /* unique id for this pool */ - Time_t createTime; /* time pool was created */ - SQUAD SBH_LoggedVolumeDataBlk;/* blk number of ZfsPool's Volume_s logged into */ - SQUAD SBH_VolumeDataBlk; /* blk number of ZfsPool's Volume_s beast */ - SQUAD SBH_SystemBeastBlkNum;/* blk that has all the system beasts */ - QUAD totalblocks; /* total number of blocks in pool */ + /* pool information */ + LONG nssMagicNumber; /* NSS data layout on disk */ + LONG poolClassID; /* classID of this pool */ + LONG poolID; /* unique id for this pool */ + Time_t createTime; /* time pool was created */ + SQUAD SBH_LoggedVolumeDataBlk;/* blk number of ZfsPool's Volume_s logged into */ + SQUAD SBH_VolumeDataBlk; /* blk number of ZfsPool's Volume_s beast */ + SQUAD SBH_SystemBeastBlkNum;/* blk that has all the system beasts */ + QUAD totalblocks; /* total number of blocks in pool */ #if MAL_MAXNAME != 64 #error MAL_MAXNAME is assumed to be 64 by the next line. #endif - unicode_t SBH_Name[MAL_MAXNAME]; /* unicode_t string of pool name. - * As of Feb 5, 2001. - * After verifying a supber block header - * we ALWAYS fill in the name that MAL - * has for the pool. This was done so that - * we only have ONE offical keeper of the - * pool name. - */ - VolumeID_t SBH_VolumeID; /* Moved from offset 16 during AIPU 34 to - * 35. This is the ID of the Internal - * volume(i.e. the ZfsPool_s object). - */ - VolumeID_t SBH_PoolID; /* Created during AIPU 34 to 35. This is - * the Pool_s objects ID. - */ - GUID_t SBH_PoolInternalID; /* Created during AIPU 34 to 35. This is - * the Pool_s objects Internal ID. The - * one that NEVER changes. - */ + unicode_t SBH_Name[MAL_MAXNAME]; /* unicode_t string of pool name. + * As of Feb 5, 2001. + * After verifying a supber block header + * we ALWAYS fill in the name that MAL + * has for the pool. This was done so that + * we only have ONE offical keeper of the + * pool name. + */ + VolumeID_t SBH_VolumeID; /* Moved from offset 16 during AIPU 34 to + * 35. This is the ID of the Internal + * volume(i.e. the ZfsPool_s object). + */ + VolumeID_t SBH_PoolID; /* Created during AIPU 34 to 35. This is + * the Pool_s objects ID. + */ + GUID_t SBH_PoolInternalID; /* Created during AIPU 34 to 35. This is + * the Pool_s objects Internal ID. The + * one that NEVER changes. + */ - Lsn_t SBH_Lsn; /* LSN of last time block written as - * part of a xaction. - */ + Lsn_t SBH_Lsn; /* LSN of last time block written as + * part of a xaction. + */ - LONG SBH_SS_Enabled; /* When set to "SnAp" then this pool - * is a snapshot of another pool. - */ + LONG SBH_SS_Enabled; /* When set to "SnAp" then this pool + * is a snapshot of another pool. + */ #define ZLSS_SBH_SNAPSHOT_ENABLED 0x70416e53 // "SnAp" - Time_t SBH_SS_CreateTime; /* UTC of when snapshot created */ - VolumeID_t SBH_SS_OriginalPoolID; - /* Pool ID when snapshot taken. This should be - * the Pool ID of another pool that this pool - * is the snapshot of. - */ - VolumeID_t SBH_SS_OriginalVolumeID; - /* Volume ID when snapshot taken. This should be - * the Volume ID of another internal volume that - * this pool is the snapshot of. - */ - GUID_t SBH_SS_Guid; - /* Unique ID given to the 'snapshot' */ - unicode_t SBH_SS_OriginalName[MAL_MAXNAME]; - /* Pool name when snapshot taken. This should be - * the name of another pool that this pool - * is the snapshot of. - */ - LONG reserved2[64-(2+46)]; /* Extra space and keep aligned to QUAD - * boundary (16 longs). ZEROED. Extra - * zero space added in AIPU 34 to 35. - */ - // This structure must not be greater than 3*512 or logging code will be broken + Time_t SBH_SS_CreateTime; /* UTC of when snapshot created */ + VolumeID_t SBH_SS_OriginalPoolID; + /* Pool ID when snapshot taken. This should be + * the Pool ID of another pool that this pool + * is the snapshot of. + */ + VolumeID_t SBH_SS_OriginalVolumeID; + /* Volume ID when snapshot taken. This should be + * the Volume ID of another internal volume that + * this pool is the snapshot of. + */ + GUID_t SBH_SS_Guid; + /* Unique ID given to the 'snapshot' */ + unicode_t SBH_SS_OriginalName[MAL_MAXNAME]; + /* Pool name when snapshot taken. This should be + * the name of another pool that this pool + * is the snapshot of. + */ + LONG reserved2[64-(2+46)]; /* Extra space and keep aligned to QUAD + * boundary (16 longs). ZEROED. Extra + * zero space added in AIPU 34 to 35. + */ + // This structure must not be greater than 3*512 or logging code will be broken } NSS_MEDIA_STRUCTURE(SuperBlockHeader_s,reserved2[64-(2+46)]) SuperBlockHeader_s; /* @@ -421,96 +421,96 @@ typedef struct SuperBlockHeader_s #define SUPERBLOCK_SB_VM_MAJOR 3 /* */ #define SUPERBLOCK_SB_VM_MINOR 1 /* Greg updated to 1 to indicate - * that some fields where added - * of LV support. This fields - * are marked with 'LV Support' - */ + * that some fields where added + * of LV support. This fields + * are marked with 'LV Support' + */ -#if ZSTORE_BEAST_LAYOUT == 1 +#if ZSTORE_BEAST_LAYOUT == 1 #define SUPERBLOCK_SB_VM_MEDIA_MAJOR 43 // Greg did 32 to 33; Vandana to 34; Randy to 35; Greg/Randy(COBRA) to 36; Randy 39; Greg 40; Greg 43 - /* POOL verson of media. The system that creates or updates - * the media places this value into SB_VersionMediaMajor - * to indicate the media format. Currently NSS will only - * run on media that has the same major media version as - * this define. - * - * Media 32 - Offical layout of MOAB Beta III release - * - * Media 33 - Auto in-place-upgrade to add purge tree beast - * to media. This was done for Salvage support. This - * was done May 1, 1998 and will be in FCS of MOAB. - * - * Media 34 - The official layout for FCS. - * It will require the BETA III volumes to be recreated. - * - * Media 35 - User Space Restriction Tree. - * - * Media 36, 37 and 38 - Reserved for COBRA and/or MOAB - * service packs. Still requires change to Six-Pack. - * - * Media 39 - Change in layout caused by changing from - * 32 bit IDs to 128 GUIDs for all object IDs. Also, - * moved owner ID to the root. Cleared extra bits - * on in the persistent attribute field. - * - * Media 40 - System beasts into special beast tree block and - * Added Logical Volumes. - * - * Media 40.08 - Has a MSAP block used to prevent multiple - * servers from activating the same pool. - * - * Media 40.84 - Pool has been activated under Nakoma - * - * Media 40.85 - Clustering has given permission to upgrade pool. - * Non 'SHARED' pools do not need clustering permission to - * go to media format 40.85 - * - * Media 40.86 - Pool made it 7 days under Nakoma OR EFL would - * like to be enabled. - * - * Media 40.87 - Pool made it 14 days under Nakoma OR EFL would - * like to be enabled. - * - * Media 40.88 - Pool made it 21 days under Nakoma OR EFL would - * like to be enabled. - * - * Media 43.00 - Volumes on Pool can be upgraded to 36.00. - * - * Media 43.01 - All volumes are at 36.01 or higher. - * - * Media 43.02 - All volumes are at 36.03, 37.03, 40.03 or higher - * - * Media 43.03 - All volumes are at 38.05 or higher + /* POOL verson of media. The system that creates or updates + * the media places this value into SB_VersionMediaMajor + * to indicate the media format. Currently NSS will only + * run on media that has the same major media version as + * this define. + * + * Media 32 - Offical layout of MOAB Beta III release + * + * Media 33 - Auto in-place-upgrade to add purge tree beast + * to media. This was done for Salvage support. This + * was done May 1, 1998 and will be in FCS of MOAB. + * + * Media 34 - The official layout for FCS. + * It will require the BETA III volumes to be recreated. + * + * Media 35 - User Space Restriction Tree. + * + * Media 36, 37 and 38 - Reserved for COBRA and/or MOAB + * service packs. Still requires change to Six-Pack. + * + * Media 39 - Change in layout caused by changing from + * 32 bit IDs to 128 GUIDs for all object IDs. Also, + * moved owner ID to the root. Cleared extra bits + * on in the persistent attribute field. + * + * Media 40 - System beasts into special beast tree block and + * Added Logical Volumes. + * + * Media 40.08 - Has a MSAP block used to prevent multiple + * servers from activating the same pool. + * + * Media 40.84 - Pool has been activated under Nakoma + * + * Media 40.85 - Clustering has given permission to upgrade pool. + * Non 'SHARED' pools do not need clustering permission to + * go to media format 40.85 + * + * Media 40.86 - Pool made it 7 days under Nakoma OR EFL would + * like to be enabled. + * + * Media 40.87 - Pool made it 14 days under Nakoma OR EFL would + * like to be enabled. + * + * Media 40.88 - Pool made it 21 days under Nakoma OR EFL would + * like to be enabled. + * + * Media 43.00 - Volumes on Pool can be upgraded to 36.00. + * + * Media 43.01 - All volumes are at 36.01 or higher. + * + * Media 43.02 - All volumes are at 36.03, 37.03, 40.03 or higher + * + * Media 43.03 - All volumes are at 38.05 or higher * * Volume versions explanation is in zlssUpgrade.h * - */ + */ #define SUPERBLOCK_SB_VM_MEDIA_MINOR 3 // Craig did 43.02 to 43.03 for hardlink upgrade - /* Current minor version of the media that this code - * understands. This is the minor version number placed - * on the media if this code 'creates' a pool. - * Set to 0 at release and erase comment. - */ + /* Current minor version of the media that this code + * understands. This is the minor version number placed + * on the media if this code 'creates' a pool. + * Set to 0 at release and erase comment. + */ #else #error "Be sure to update the MEDIA version when changing the ZSTORE_BEAST_VERSION" #endif #define SUPERBLOCK_SB_S_SIGNATURE 0x35425053uL /* 'SPB5' on little endian */ #define SUPERBLOCK_SB_S_SIGNATURE_OLD 0x356f6273uL - /* 'sbo5' on little endian. This is placed in - * super blocks that are old. IE when we expand - * a pool and move the last 2 super blocks the - * old last two super block headers get updated. - * If the update fails we ignore the error. - */ + /* 'sbo5' on little endian. This is placed in + * super blocks that are old. IE when we expand + * a pool and move the last 2 super blocks the + * old last two super block headers get updated. + * If the update fails we ignore the error. + */ /*--------------------------------------------------------------------------- * This is the media representation of the Super Block Header *---------------------------------------------------------------------------*/ typedef struct MediaSuperBlockHeader_s { - SuperBlockHeader_s hdr; - BYTE reserved[SUPERBLOCK_SECTION_SIZE-sizeof(SuperBlockHeader_s)];/*ZEROED*/ + SuperBlockHeader_s hdr; + BYTE reserved[SUPERBLOCK_SECTION_SIZE-sizeof(SuperBlockHeader_s)];/*ZEROED*/ } NSS_MEDIA_STRUCTURE(MediaSuperBlockHeader_s,reserved[SUPERBLOCK_SECTION_SIZE-sizeof(SuperBlockHeader_s)]) MediaSuperBlockHeader_s; /* @@ -522,41 +522,41 @@ typedef struct MediaSuperBlockHeader_s typedef struct SuperBlockDebug_s { - /* general information */ - LONG SBD_Signature; /* Signature of block, must always be first*/ - WORD SBD_VersionMajor; - /* The major version of the super block header. Changes - * when the super block is no longer compatible - * with an older version of the super block header. - * The first release will have this set to 1. The - * define SUPERBLOCK_SB_VM_MAJOR specifies the current - * major version number of the header. To display - * use "%u.%02u" as the format string. - */ - WORD SBD_VersionMinor; - /* The minor version of the super block header. - * Changes when old super block header are still - * compatible. This will be 0 in the first release. - * The define SUPERBLOCK_SB_VM_MINOR specifies the - * current minor version number of the header. - */ - Lsn_t SBD_LsnReserved; - /* Reserved if we need to log this block. Should - * not need as should just use section 12 of 2nd - * superblock if need a logged block. - */ - GUID_t SBD_InternalID; - /* Must be at OFFSET 16 - unique 128 bit GUID used - * for internal ZLSS identification. - */ - QUAD SBD_WriteCrashFailureCount; - /* Count of writes that should be done before - * crashing the machine. Used in debug systems - * only when the /ZLSSWriteCrash switch is on. - * Note that the /ZLSSWriteCrashIncrement switch - * can be used to increase the value by one. - */ - BYTE reserved2[4096-32-8]; + /* general information */ + LONG SBD_Signature; /* Signature of block, must always be first*/ + WORD SBD_VersionMajor; + /* The major version of the super block header. Changes + * when the super block is no longer compatible + * with an older version of the super block header. + * The first release will have this set to 1. The + * define SUPERBLOCK_SB_VM_MAJOR specifies the current + * major version number of the header. To display + * use "%u.%02u" as the format string. + */ + WORD SBD_VersionMinor; + /* The minor version of the super block header. + * Changes when old super block header are still + * compatible. This will be 0 in the first release. + * The define SUPERBLOCK_SB_VM_MINOR specifies the + * current minor version number of the header. + */ + Lsn_t SBD_LsnReserved; + /* Reserved if we need to log this block. Should + * not need as should just use section 12 of 2nd + * superblock if need a logged block. + */ + GUID_t SBD_InternalID; + /* Must be at OFFSET 16 - unique 128 bit GUID used + * for internal ZLSS identification. + */ + QUAD SBD_WriteCrashFailureCount; + /* Count of writes that should be done before + * crashing the machine. Used in debug systems + * only when the /ZLSSWriteCrash switch is on. + * Note that the /ZLSSWriteCrashIncrement switch + * can be used to increase the value by one. + */ + BYTE reserved2[4096-32-8]; } NSS_MEDIA_STRUCTURE(SuperBlockDebug_s,reserved2[4096-32-8]) SuperBlockDebug_s; /* @@ -568,44 +568,44 @@ typedef struct SuperBlockDebug_s typedef struct SuperBlockDebugXaction_s { - /* general information */ - LONG SBDX_Signature; /* Signature of block, must always be first*/ - WORD SBDX_VersionMajor; - /* The major version of the super block header. Changes - * when the super block is no longer compatible - * with an older version of the super block header. - * The first release will have this set to 1. The - * define SUPERBLOCK_SB_VM_MAJOR specifies the current - * major version number of the header. To display - * use "%u.%02u" as the format string. - */ - WORD SBDX_VersionMinor; - /* The minor version of the super block header. - * Changes when old super block header are still - * compatible. This will be 0 in the first release. - * The define SUPERBLOCK_SB_VM_MINOR specifies the - * current minor version number of the header. - */ - Lsn_t SBDX_Lsn; - GUID_t SBDX_InternalID; - /* Must be at OFFSET 16 - unique 128 bit GUID used - * for internal ZLSS identification. - */ - BYTE reserved2[4096-32]; + /* general information */ + LONG SBDX_Signature; /* Signature of block, must always be first*/ + WORD SBDX_VersionMajor; + /* The major version of the super block header. Changes + * when the super block is no longer compatible + * with an older version of the super block header. + * The first release will have this set to 1. The + * define SUPERBLOCK_SB_VM_MAJOR specifies the current + * major version number of the header. To display + * use "%u.%02u" as the format string. + */ + WORD SBDX_VersionMinor; + /* The minor version of the super block header. + * Changes when old super block header are still + * compatible. This will be 0 in the first release. + * The define SUPERBLOCK_SB_VM_MINOR specifies the + * current minor version number of the header. + */ + Lsn_t SBDX_Lsn; + GUID_t SBDX_InternalID; + /* Must be at OFFSET 16 - unique 128 bit GUID used + * for internal ZLSS identification. + */ + BYTE reserved2[4096-32]; } NSS_MEDIA_STRUCTURE(SuperBlockDebugXaction_s,reserved2[4096-32]) SuperBlockDebugXaction_s; - /* - * This structure is used to store validation items about the super - * block headers - */ + /* + * This structure is used to store validation items about the super + * block headers + */ typedef struct SuperBlockHeaderValidate_s { - Blknum_t SBHV_MathematicalBlock; - MediaSuperBlockHeader_s *SBHV_MediaCopy; - NINT SBHV_Flag; + Blknum_t SBHV_MathematicalBlock; + MediaSuperBlockHeader_s *SBHV_MediaCopy; + NINT SBHV_Flag; #define SUPERBLOCK_SBHV_F_CHECKSUM_GOOD 1 /* Valid checksum, ver, sign... */ #define SUPERBLOCK_SBHV_F_DIFFERENT 2 /* Different from main header */ } SuperBlockHeaderValidate_s; @@ -615,7 +615,7 @@ typedef struct SuperBlockHeaderValidate_s +-------------------------------------------------------------------------*/ #define SUPERBLOCKHEADERCOPY_SECTION \ - (offsetof(ZFSMediaSuperBlk_s,SB_HeaderCopy)/SUPERBLOCK_SECTION_SIZE) + (offsetof(ZFSMediaSuperBlk_s,SB_HeaderCopy)/SUPERBLOCK_SECTION_SIZE) #define SUPERBLOCKHEADERCOPY_BLKCOUNT SUPERBLOCKHEADER_BLKCOUNT @@ -624,7 +624,7 @@ typedef struct SuperBlockHeaderValidate_s +-------------------------------------------------------------------------*/ #define SUPERBLOCKDEBUG_SECTION \ - (offsetof(ZFSMediaSuperBlk_s,SB_Debug)/SUPERBLOCK_SECTION_SIZE) + (offsetof(ZFSMediaSuperBlk_s,SB_Debug)/SUPERBLOCK_SECTION_SIZE) #define SUPERBLOCKDEBUG_BLKCOUNT SUPERBLOCKHEADER_BLKCOUNT /*--------------------------------------------------------------------------- @@ -633,14 +633,14 @@ typedef struct SuperBlockHeaderValidate_s typedef struct MediaReservedHeader_s { - LONG reserved[SUPERBLOCK_SECTION_SIZE/4]; + LONG reserved[SUPERBLOCK_SECTION_SIZE/4]; } NSS_MEDIA_STRUCTURE(MediaReservedHeader_s,reserved[SUPERBLOCK_SECTION_SIZE/4]) MediaReservedHeader_s; #define SUPER_BLOCK_RESERVED_SECTION_MASK( _superBlock, _section) \ - (0x42530000ul + (_section << 8) + _superBlock) - /* Number of blocks in each reserved section (I.E. 1) */ + (0x42530000ul + (_section << 8) + _superBlock) + /* Number of blocks in each reserved section (I.E. 1) */ #define SUPERBLOCKRESERVED_BLKCOUNT \ - (sizeof(MediaReservedHeader_s)/SUPERBLOCK_SECTION_SIZE) + (sizeof(MediaReservedHeader_s)/SUPERBLOCK_SECTION_SIZE) @@ -659,22 +659,22 @@ typedef struct MediaReservedHeader_s +-------------------------------------------------------------------------*/ typedef struct ZFSMediaSuperBlk_s { - MediaReservedHeader_s SB_Block0; /* Block 0 */ - MediaSuperBlockHeader_s SB_Header; /* Block 1 */ - MediaCheckpoint_s SB_Checkpoint; /* Block 2 */ - MediaReservedHeader_s SB_Block3; /* Block 3 */ - MediaReservedHeader_s SB_Block4; /* Block 4 */ - MediaReservedHeader_s SB_Block5; /* Block 5 */ - MediaReservedHeader_s SB_Block6; /* Block 6 */ - MediaReservedHeader_s SB_Block7; /* Block 7 */ - MediaReservedHeader_s SB_Block8; /* Block 8 */ - MediaReservedHeader_s SB_Block9; /* Block 9 */ - MediaReservedHeader_s SB_Block10; /* Block 10 */ - MediaReservedHeader_s SB_PoolSnapshot; /* Block 11 (Nakoma Pool snapshot and MSAP) */ - MediaReservedHeader_s SB_Debug; /* Block 12 */ - MediaReservedHeader_s SB_Repair1; /* Block 13 */ - MediaReservedHeader_s SB_Repair2; /* Block 14 */ - MediaSuperBlockHeader_s SB_HeaderCopy; /* Block 15 */ + MediaReservedHeader_s SB_Block0; /* Block 0 */ + MediaSuperBlockHeader_s SB_Header; /* Block 1 */ + MediaCheckpoint_s SB_Checkpoint; /* Block 2 */ + MediaReservedHeader_s SB_Block3; /* Block 3 */ + MediaReservedHeader_s SB_Block4; /* Block 4 */ + MediaReservedHeader_s SB_Block5; /* Block 5 */ + MediaReservedHeader_s SB_Block6; /* Block 6 */ + MediaReservedHeader_s SB_Block7; /* Block 7 */ + MediaReservedHeader_s SB_Block8; /* Block 8 */ + MediaReservedHeader_s SB_Block9; /* Block 9 */ + MediaReservedHeader_s SB_Block10; /* Block 10 */ + MediaReservedHeader_s SB_PoolSnapshot; /* Block 11 (Nakoma Pool snapshot and MSAP) */ + MediaReservedHeader_s SB_Debug; /* Block 12 */ + MediaReservedHeader_s SB_Repair1; /* Block 13 */ + MediaReservedHeader_s SB_Repair2; /* Block 14 */ + MediaSuperBlockHeader_s SB_HeaderCopy; /* Block 15 */ } NSS_MEDIA_STRUCTURE(ZFSMediaSuperBlk_s,SB_HeaderCopy.reserved[SUPERBLOCK_SECTION_SIZE-sizeof(SuperBlockHeader_s)]) ZFSMediaSuperBlk_s; #define MSAP_SUPERBLOCK_NUMBER 1 /* 0 relative number */ @@ -687,8 +687,8 @@ typedef struct ZFSMediaSuperBlk_s typedef struct ZFSMemorySuperBlk_s { // MediaReservedHeader_s block0; /* Block 0 */ - MediaSuperBlockHeader_s SB_Header; /* Block 1 */ - MediaCheckpoint_s SB_Checkpoint; /* Block 2 */ + MediaSuperBlockHeader_s SB_Header; /* Block 1 */ + MediaCheckpoint_s SB_Checkpoint; /* Block 2 */ } ZFSMemorySuperBlk_s; /*--------------------------------------------------------------------------- @@ -696,8 +696,8 @@ typedef struct ZFSMemorySuperBlk_s | of superblock header (like beast b-tree). +-------------------------------------------------------------------------*/ typedef struct { - BYTE SLR_ValuesOld[3*512]; - BYTE SLR_ValuesNew[3*512]; + BYTE SLR_ValuesOld[3*512]; + BYTE SLR_ValuesNew[3*512]; } NSS_MEDIA_STRUCTURE(SbhLogRecord_s,SLR_ValuesNew[3*512]) SbhLogRecord_s; /* Sbh stands for "Superblock Header" */ /*--------------------------------------------------------------------------- @@ -705,10 +705,10 @@ typedef struct { +-------------------------------------------------------------------------*/ typedef struct PoolBeastCtrl_s { - NINT beastClass; /* class ID*/ - Zid_t zid; /* desired zid of the beast */ - NINT poolOffset; /* offset into "ZfsPool_s" beast where this goes*/ - unicode_t *name; + NINT beastClass; /* class ID*/ + Zid_t zid; /* desired zid of the beast */ + NINT poolOffset; /* offset into "ZfsPool_s" beast where this goes*/ + unicode_t *name; } PoolBeastCtrl_s; extern PoolBeastCtrl_s SuperBeasts[]; @@ -717,82 +717,82 @@ extern PoolBeastCtrl_s SuperBeasts[]; | Function Prototypes needed +-------------------------------------------------------------------------*/ extern struct ZfsPool_s *ZFSPOOL_CreatePoolBeast( - struct GeneralMsg_s *genMsg); + struct GeneralMsg_s *genMsg); extern STATUS ZFSPOOL_InitNewRootDir( - struct GeneralMsg_s *genMsg, - File_s *rootdir, - ZfsVolume_s *zVolume); + struct GeneralMsg_s *genMsg, + File_s *rootdir, + ZfsVolume_s *zVolume); extern STATUS ZFSPOOL_InitNewBeast( - struct GeneralMsg_s *genMsg, - File_s *file, - Zid_t zid, - Zid_t parentZid, - NINT fileAttributes, - unicode_t *name); + struct GeneralMsg_s *genMsg, + File_s *file, + Zid_t zid, + Zid_t parentZid, + NINT fileAttributes, + unicode_t *name); extern STATUS ZFSPOOL_InitNewPool( - struct GeneralMsg_s *genMsg, - StorPool_s *storagepool); + struct GeneralMsg_s *genMsg, + StorPool_s *storagepool); STATUS ZFSPOOL_SuperBlockRead( - StorPool_s *storagepool, - void *ioBuffer, - Blknum_t blockNum, - NINT blockCnt); + StorPool_s *storagepool, + void *ioBuffer, + Blknum_t blockNum, + NINT blockCnt); STATUS ZFSPOOL_SuperBlockWrite( - StorPool_s *storagepool, - void *ioBuffer, - Blknum_t blockNum, - NINT blockCnt); + StorPool_s *storagepool, + void *ioBuffer, + Blknum_t blockNum, + NINT blockCnt); #if NSS_DEBUG IS_ENABLED -void ZFSPOOL_SuperBlockReservedValidate( - ZfsPool_s *pool ); +void ZFSPOOL_SuperBlockReservedValidate( + ZfsPool_s *pool ); #endif Blknum_t ZFSPOOL_SuperBlockMathematicalBlock( - NINT superBlockNumber, - QUAD totalNumberOfBlocks); + NINT superBlockNumber, + QUAD totalNumberOfBlocks); LONG ZFSPOOL_SuperBlockHeaderCalculateChecksum( - LONG *buffer, - NINT numberOfLONGs ); + LONG *buffer, + NINT numberOfLONGs ); STATUS ZFSPOOL_SuperBlockHeaderChecker( - GeneralMsg_s *genMsg, - StorPool_s *storagepool, - MediaSuperBlockHeader_s *superblockHeaderMedia, - struct SuperBlockHeaderValidate_s si[] ); + GeneralMsg_s *genMsg, + StorPool_s *storagepool, + MediaSuperBlockHeader_s *superblockHeaderMedia, + struct SuperBlockHeaderValidate_s si[] ); STATUS ZFSPOOL_SuperBlockHeaderRepair( - GeneralMsg_s *genMsg, - StorPool_s *storagepool, - MediaSuperBlockHeader_s *superblockHeaderMedia, - struct SuperBlockHeaderValidate_s si[], - int verbose ); + GeneralMsg_s *genMsg, + StorPool_s *storagepool, + MediaSuperBlockHeader_s *superblockHeaderMedia, + struct SuperBlockHeaderValidate_s si[], + int verbose ); STATUS ZFSPOOL_SuperBlockHeaderReadByBlock( - StorPool_s *storagepool, - MediaSuperBlockHeader_s *superblockHeaderMedia, - Blknum_t block); + StorPool_s *storagepool, + MediaSuperBlockHeader_s *superblockHeaderMedia, + Blknum_t block); STATUS ZFSPOOL_SuperBlockHeaderValidate( - GeneralMsg_s *genMsg, - StorPool_s *storagepool, - MediaSuperBlockHeader_s *superblockHeaderMedia ); + GeneralMsg_s *genMsg, + StorPool_s *storagepool, + MediaSuperBlockHeader_s *superblockHeaderMedia ); STATUS ZFSPOOL_SuperBlockHeaderVerify( - StorPool_s *storagepool, - MediaSuperBlockHeader_s *superblockHeaderMedia ); + StorPool_s *storagepool, + MediaSuperBlockHeader_s *superblockHeaderMedia ); STATUS ZFSPOOL_SuperBlockHeaderWriteInitial( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - unicode_t *poolName); + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + unicode_t *poolName); //extern STATUS ZFSPOOL_FlushSuperBlock( // struct GeneralMsg_s *genMsg, @@ -800,94 +800,94 @@ STATUS ZFSPOOL_SuperBlockHeaderWriteInitial( // LONG superblknum); STATUS ZFSPOOL_CheckpointSetRestartID( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool); STATUS ZFSPOOL_CheckpointTake( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - NINT state); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + NINT state); LONG ZFSPOOL_CheckpointCalculateChecksum( - LONG *buffer, - NINT numberOfLONGs ); + LONG *buffer, + NINT numberOfLONGs ); void ZFSPOOL_CheckpointTimerPop( - struct OneShot_s *alarm); + struct OneShot_s *alarm); STATIC void ZFSPOOL_CheckpointWorkToDo( - FsmLite_s *fsm); + FsmLite_s *fsm); STATUS ZFSPOOL_CheckpointWriteSpecific( - struct ZfsPool_s *pool, - NINT checkpointNumber); + struct ZfsPool_s *pool, + NINT checkpointNumber); STATUS ZFSPOOL_CheckpointWriteNext( - struct ZfsPool_s *pool); + struct ZfsPool_s *pool); STATUS ZFSPOOL_CheckpointVerify( - struct MediaCheckpoint_s *mediaCheckpoint ); + struct MediaCheckpoint_s *mediaCheckpoint ); STATUS ZFSPOOL_CheckpointFindNewest( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - struct MediaCheckpoint_s *mediaCheckpoint, - unicode_t *poolName); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + struct MediaCheckpoint_s *mediaCheckpoint, + unicode_t *poolName); void ZFSPOOL_CheckpointFlushFiles( - struct ZfsPool_s *pool, - BOOL deactivating); /* if TRUE, toss the cache buffers also */ + struct ZfsPool_s *pool, + BOOL deactivating); /* if TRUE, toss the cache buffers also */ STATUS ZFSPOOL_CheckpointPoolInitialize( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool ); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool ); STATUS ZFSPOOL_CheckpointReadSpecific( - struct ZfsPool_s *pool, - struct MediaCheckpoint_s *mediaCheckpoint, - NINT checkpointNumber); + struct ZfsPool_s *pool, + struct MediaCheckpoint_s *mediaCheckpoint, + NINT checkpointNumber); void ZFSPOOL_CheckpointCheckAndMakeBest( - struct Checkpoint_s *currentBest, - struct Checkpoint_s *challenger ); + struct Checkpoint_s *currentBest, + struct Checkpoint_s *challenger ); STATUS ZFSPOOL_DoFlushSystemBeasts( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *pool, - BOOL deactivating); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *pool, + BOOL deactivating); -STATUS ZFSPOOL_SetNewPoolSizeWhileActive( - struct GeneralMsg_s *gsnMsg, - struct StorPool_s *storagepool ); +STATUS ZFSPOOL_SetNewPoolSizeWhileActive( + struct GeneralMsg_s *gsnMsg, + struct StorPool_s *storagepool ); -STATUS ZFSPOOL_SetNewPoolSizeDuringActivation( - struct GeneralMsg_s *gsnMsg, - struct ZfsPool_s *zfsPool ); +STATUS ZFSPOOL_SetNewPoolSizeDuringActivation( + struct GeneralMsg_s *gsnMsg, + struct ZfsPool_s *zfsPool ); STATUS ZFSPOOL_SuperBlockHeaderWrite( - StorPool_s *storagepool, - void *ioBuffer, - Blknum_t blockNum, - NINT blockCnt); + StorPool_s *storagepool, + void *ioBuffer, + Blknum_t blockNum, + NINT blockCnt); STATUS ZFSPOOL_SuperBlockUpdate( - struct GeneralMsg_s *gsnMsg, - struct ZfsPool_s *zfsPool ); + struct GeneralMsg_s *gsnMsg, + struct ZfsPool_s *zfsPool ); STATUS ZFSPOOL_SuperBlockUpdate2( - struct GeneralMsg_s *genMsg, - struct StorPool_s *storagepool, - struct MediaSuperBlockHeader_s *super ); + struct GeneralMsg_s *genMsg, + struct StorPool_s *storagepool, + struct MediaSuperBlockHeader_s *super ); STATUS ZFSPOOL_SuperBlockUpdateXaction( - struct GeneralMsg_s *genMsg, - struct ZfsPool_s *zfsPool, - struct ZfsXaction_s *xaction ); + struct GeneralMsg_s *genMsg, + struct ZfsPool_s *zfsPool, + struct ZfsXaction_s *xaction ); STATUS ZFSPOOL_SetNewPoolName( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - unicode_t *poolname); + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + unicode_t *poolname); #endif /* _ZFSPOOLSUPERBLK_H_ */ diff --git a/src/nwnss/zlss/zfsVol.c b/src/nwnss/zlss/zfsVol.c index 78478b4..5df8a4a 100644 --- a/src/nwnss/zlss/zfsVol.c +++ b/src/nwnss/zlss/zfsVol.c @@ -68,46 +68,6 @@ #include "eflTree.h" #include "zlssUpgrade.h" -/* Legacy NSS callback tables use statusfunc_t/voidfunc_t with old-style - * prototypes. Keep the imported ZLSS signatures intact and cast only at - * the COMN/WORK callback boundary. - */ -typedef STATUS (*zfsvol_change_volume_state_func_t)( - GeneralMsg_s *genMsg, - void *vol, - NINT sourceState, - NINT requestedState, - NINT mode, - NINT pass); -typedef STATUS (*zfsvol_alloc_storage_info_func_t)( - GeneralMsg_s *genMsg, - RootBeast_s *beast); -typedef STATUS (*zfsvol_flush_system_beasts_func_t)( - GeneralMsg_s *genMsg, - Volume_s *vol); -typedef STATUS (*zfsvol_get_info_func_t)( - GeneralMsg_s *genMsg, - void *beast, - GetInfoMsg_s *infoMsg); -typedef STATUS (*zfsvol_modify_info_func_t)( - GeneralMsg_s *genMsg, - void *beast, - ModifyInfoMsg_s *modifyMsg, - Xaction_s *xaction); -typedef STATUS (*zfsvol_command_func_t)( - GeneralMsg_s *genMsg, - void *beast, - NINT functionNumber, - VCO_VolumeCommonOps_s *pCD, - NINT parmLen, - utf8_t *parm, - NINT dataLen, - BYTE *commandData, - NINT offset, - NINT retBufLen, - BYTE *retBuf, - NINT *retLen); - void ZFSVOL_UnLoadSystemBeasts(ZfsVolume_s *vol); /* After we make volume's read ahead number changable, we should @@ -115,7 +75,7 @@ void ZFSVOL_UnLoadSystemBeasts(ZfsVolume_s *vol); */ /**************************************************************************** - * ZFS volume beast constructor + * ZFS volume beast constructor *****************************************************************************/ STATIC STATUS ZFSVOL_BST_Construct( GeneralMsg_s *genMsg, @@ -130,9 +90,9 @@ STATIC STATUS ZFSVOL_BST_Construct( zASSERT( sizeof( PersistentZfsVolume_s ) == 128 ); zASSERT( sizeof( LoggedPersistentZfsVolume_s ) == 128 ); - /** - * We set up many of ZLSS volume's non-persistent items here. - */ + /** + * We set up many of ZLSS volume's non-persistent items here. + */ vol->ZFSVOLmaxBeastSize = MAX_BEAST_SIZE; vol->ZFSVOLfreeBlockAdjustment = ZFS_RESERVED_BLOCKS_FOR_INTERNAL_ALLOCATION; @@ -143,8 +103,8 @@ STATIC STATUS ZFSVOL_BST_Construct( vol->ZFSVOLroot.beastVersion = BEAST_VERSION_2; /* Mark as a Logical Volume - If this is the pool's internal - * volume then the ZfsPool_s constructor will turn this bit off - */ + * volume then the ZfsPool_s constructor will turn this bit off + */ vol->ZFSVOLvol.v_statusFlag |= VOL_SF_LOGICAL_VOLUME; DQ_INIT( &vol->ZV_deleteBlkQ ); INIT_LATCH( &vol->ZV_vdbLatch ); @@ -185,7 +145,7 @@ STATIC void ZFSVOL_BST_Destruct( } /************************************************************************** - * + * ***************************************************************************/ STATUS ZFSVOL_Activate( GeneralMsg_s *genMsg, @@ -195,9 +155,9 @@ STATUS ZFSVOL_Activate( ASSERT_MPKNSS_LOCK(); /* The next statement is located in the load of the Volume's - * persistent data blocks (VDB and LVDB). This was done because - * rebuild does not activate a volume. - */ + * persistent data blocks (VDB and LVDB). This was done because + * rebuild does not activate a volume. + */ // zfsVol->zv_bookedInUseBlocks = zfsVol->ZFSVOLinUseBlocks; DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN,MSGNot("CVS@ZFSVOL_Activate\n"))); @@ -221,10 +181,10 @@ STATUS ZFSVOL_Activate( WHERE, zfsVol, zfsVol->ZFSVOLactivationCount, zfsVol->ZFSVOLvol.v_restartCount )); /** - * Since Internal volume's restart count is changed each time - * the internal volume is activated we need to update the - * LV restart count when the LV is activated (verses loaded). - */ + * Since Internal volume's restart count is changed each time + * the internal volume is activated we need to update the + * LV restart count when the LV is activated (verses loaded). + */ zfsVol->ZLSSVOLvol.v_restartCount = zfsVol->ZFSVOLpool->ZFSPOOLvol.v_restartCount; DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN, MSGNot("%s 0x%lx Activation count is %d restart count id %d\n"), @@ -236,7 +196,7 @@ STATUS ZFSVOL_Activate( /************************************************************************** - * + * * In ZLSS Volume there is not difference between deactivate and going * from ACTIVATE to MAINTENANCE. Therefore this routine is called * in both cases. @@ -248,7 +208,7 @@ STATUS ZFSVOL_Deactivate( { GeneralMsg_s dummyGenMsg; NINT i; - + ASSERT_MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); @@ -256,15 +216,15 @@ STATUS ZFSVOL_Deactivate( DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, (CYAN,MSGNot("CVS@ZFSVOL_Deactivate\n"))); /* The *10 (i.e. 40) is to ENSURE we take enough checkpoints to clear - * the defered delete queue. - * LV - When added LVs I increased loop to write up to - * 120 checkpoints. This with the delay I added in the - * loop causes us to take checkpints for up to a minute before - * giving up. With LVs home my not be moving because of other LVs. - * We only flush our system beasts and not every ones. So - * we better wait a little while. Note if we have nothing on - * our delete queue then we do not do a delay. - */ + * the defered delete queue. + * LV - When added LVs I increased loop to write up to + * 120 checkpoints. This with the delay I added in the + * loop causes us to take checkpints for up to a minute before + * giving up. With LVs home my not be moving because of other LVs. + * We only flush our system beasts and not every ones. So + * we better wait a little while. Note if we have nothing on + * our delete queue then we do not do a delay. + */ for ( i=0; i < 120; i++ ) { /*------------------------------------------------------------------------- @@ -283,19 +243,19 @@ STATUS ZFSVOL_Deactivate( /* continue with the deactivation */ } /* - * This code prevents us from taking extra checkpoints when - * trying to clear the defered delete queue. Here we check - * that there are no more items on the defered delete queue. - * - * We must clear the defered delete queue so that we can take - * one last checkpoint that will be clean. If we do not clear - * defered delete queue 1st then after we take the last - * checkpoint more log records may be generated by blocks - * that are now deletable. - * - * The QUEUE is protected by NetWare being non-pre-emptive. - * - */ + * This code prevents us from taking extra checkpoints when + * trying to clear the defered delete queue. Here we check + * that there are no more items on the defered delete queue. + * + * We must clear the defered delete queue so that we can take + * one last checkpoint that will be clean. If we do not clear + * defered delete queue 1st then after we take the last + * checkpoint more log records may be generated by blocks + * that are now deletable. + * + * The QUEUE is protected by NetWare being non-pre-emptive. + * + */ if (DQ_EMPTY(&zfsVol->ZV_deleteBlkQ)) { /* Nothing on queue */ break; @@ -319,12 +279,12 @@ STATUS ZFSVOL_Deactivate( } } /* Volumes do not have the pool problem of worst case Free B-Tree - * casading because the Free B-Tree is owned by the Pool. See - * comments in ZFSPOOL_Deactivate. If this is WRONG then we will have - * a purge log entry and be forced to do REDO/UNDO and/or replay - * purge log WHICH in the case of LVs cause a system block to be - * freed to soon!!! - */ + * casading because the Free B-Tree is owned by the Pool. See + * comments in ZFSPOOL_Deactivate. If this is WRONG then we will have + * a purge log entry and be forced to do REDO/UNDO and/or replay + * purge log WHICH in the case of LVs cause a system block to be + * freed to soon!!! + */ #if NSS_DEBUG IS_ENABLED { ZfsPool_s *zfsPool; @@ -341,24 +301,24 @@ STATUS ZFSVOL_Deactivate( } #endif /** - * We need to clean up deleted system blocks that have - * not yet been physically freed. The XDEL_ call will - * toss the list of blocks, but the purge log is aware of them - * so they will be freed on our next activation when the LV's - * purge log is played. Tossing the list here leaves us open - * to freeing a block during a quick activation that should - * not be physically freed(yet). This is highly unlikily with - * checkpoint code above, but if we do manage to free and - * then allocate and then crash the result could be a coruption - * of the media. - */ + * We need to clean up deleted system blocks that have + * not yet been physically freed. The XDEL_ call will + * toss the list of blocks, but the purge log is aware of them + * so they will be freed on our next activation when the LV's + * purge log is played. Tossing the list here leaves us open + * to freeing a block during a quick activation that should + * not be physically freed(yet). This is highly unlikily with + * checkpoint code above, but if we do manage to free and + * then allocate and then crash the result could be a coruption + * of the media. + */ XDEL_DeactivateVolume(zfsVol); /* Don't do tosses until after we are done with all the activity on - * the system beasts, because cacheToss has a BUG where it - * removes the blocks from the cache HASH even if they still needs - * to be flushed. - */ + * the system beasts, because cacheToss has a BUG where it + * removes the blocks from the cache HASH even if they still needs + * to be flushed. + */ (void)ZFSVOL_DoFlushSystemBeasts( &dummyGenMsg, zfsVol, TRUE ); ZFSVOL_UnLoadSystemBeasts( zfsVol ); @@ -411,14 +371,14 @@ STATIC STATUS ZFSVOL_LoadSystemBeasts( *-------------------------------------------------------------------------*/ zASSERT( vol->ZFSVOLrootdir == NULL ); /* The zVOL_PSTATE_CRTEATED check was added when LV delete - * was implemented. During LV delete (and create) the - * rootdir may not exist. This is O.K. so we just - * never load in those cases. - */ + * was implemented. During LV delete (and create) the + * rootdir may not exist. This is O.K. so we just + * never load in those cases. + */ /* The if is just defensive code. The ROOTDIR should never - * be loaded when this routine is called. But less bad things - * will happen if we check and not re-load. - */ + * be loaded when this routine is called. But less bad things + * will happen if we check and not re-load. + */ if ( (vol->ZFSVOLvol.VOLpState == zVOL_PSTATE_CREATED) && (vol->ZFSVOLrootdir == NULL) ) { @@ -500,9 +460,9 @@ void ZFSVOL_UnLoadSystemBeasts( #if !VOL_DOES_ROOTDIR /* - * Even though our load inserted into the beast hash we do - * not need to remove from hash, because the root destructor does. - */ + * Even though our load inserted into the beast hash we do + * not need to remove from hash, because the root destructor does. + */ /*------------------------------------------------------------------------- * UnLoad the ROOT directory if it is loaded. *-------------------------------------------------------------------------*/ @@ -530,17 +490,17 @@ STATIC STATUS ZFSVOL_VOL_ChangeVolumeState( GeneralMsg_s *genMsg, void *vol_LX, NINT sourceState, /* This is normally vol->state, but when we - * are doing VOLMODE_UNDO then this is the - * state that we had previously tried to - * go to. - */ + * are doing VOLMODE_UNDO then this is the + * state that we had previously tried to + * go to. + */ NINT requestedState, NINT mode, NINT pass ) { ZfsVolume_s *vol = (ZfsVolume_s *)vol_LX; STATUS status; - zfsvol_change_volume_state_func_t parentFunc; + statusfunc_t parentFunc; ASSERT_MPKNSS_LOCK(); ENTER(TZVOL, ZFSVOL_ChangeVolumeState); @@ -549,9 +509,9 @@ STATIC STATUS ZFSVOL_VOL_ChangeVolumeState( * Since we know we need to call the Volume_s code, get the address of * that routine. *-------------------------------------------------------------------------*/ - parentFunc = (zfsvol_change_volume_state_func_t)COMN_GetNextParentVolumeComnOp( vol->ZFSVOLbeastClass, + parentFunc = COMN_GetNextParentVolumeComnOp( vol->ZFSVOLbeastClass, COMNVOLOPS_INDEX(VOL_changeVolumeState), - (statusfunc_t)ZFSVOL_VOL_ChangeVolumeState ); + ZFSVOL_VOL_ChangeVolumeState ); zASSERT(parentFunc != NULL); status = parentFunc( genMsg, &vol->vol, sourceState, requestedState, mode, pass ); @@ -569,13 +529,13 @@ STATIC STATUS ZFSVOL_VOL_ChangeVolumeState( { case zVOLSTATE_ACTIVE: /* Source State */ break; - /* - * The DEACTIVE amd MAINTENANCE code should - * normally be run as VOLMODE_PRE, but we still have - * the ZFSPOOL load the NAME and BEAST tree. If - * we change this then we can go back to being PRE - * fuctions. - */ + /* + * The DEACTIVE amd MAINTENANCE code should + * normally be run as VOLMODE_PRE, but we still have + * the ZFSPOOL load the NAME and BEAST tree. If + * we change this then we can go back to being PRE + * fuctions. + */ case zVOLSTATE_DEACTIVE: /* Source State */ case zVOLSTATE_MAINTENANCE: /* Source State */ // This is done by Volume_s now so that ALL volumes have @@ -596,13 +556,13 @@ STATIC STATUS ZFSVOL_VOL_ChangeVolumeState( } /** Same code is in POOL CVS make this a function **/ /* If we are not in override mode then we need - * to fail going to ACTIVE state if the volume - * is corrupt or was being repaired/checked. We - * have to wait until now to check because the - * corrupt and repairing bits are stored in the - * persistent volume. Maybe Volume_s should do - * the check. - */ + * to fail going to ACTIVE state if the volume + * is corrupt or was being repaired/checked. We + * have to wait until now to check because the + * corrupt and repairing bits are stored in the + * persistent volume. Maybe Volume_s should do + * the check. + */ if ( !(mode & VOLMODE_OVERRIDE) ) { if ( (vol->ZLSSVOLvol.p.stateAttributes & VOLSTATEATTR_CORRUPT) || @@ -628,9 +588,9 @@ STATIC STATUS ZFSVOL_VOL_ChangeVolumeState( } else { /* Since we are corrupt or were repairing and - * we have not been told to OVERRIDE then we - * will not do this activation request. - */ + * we have not been told to OVERRIDE then we + * will not do this activation request. + */ SetErrno(genMsg,zERR_VOLUME_SHOULD_NOT_ACTIVATE); } return( zFAILURE ); @@ -645,8 +605,8 @@ STATIC STATUS ZFSVOL_VOL_ChangeVolumeState( //#ifndef __linux__ // LINUX_Upgrade if ( ZLSS_AIPUNakomaVolume_Ready( vol ) ) { /* Volume is ready to be upgraded so ensure that - * the upgrade thread is running. - */ + * the upgrade thread is running. + */ ZLSS_UpgradeStartupNakoma( ); } //#endif @@ -744,7 +704,7 @@ STATIC STATUS ZFSVOL_VOL_AllocStorageInfo( { ZfsVolume_s *zvol = beast->vol.zfsVol; ZFSStorageInfo_s *stInfo; - zfsvol_alloc_storage_info_func_t parentFunc; + statusfunc_t parentFunc; STATUS status; ASSERT_MPKNSS_LOCK(); @@ -759,8 +719,8 @@ STATIC STATUS ZFSVOL_VOL_AllocStorageInfo( beast->storage.zfsInfo = stInfo; stInfo->rebuildMagic = REBUILD_FILE_IS_GOOD; - parentFunc = (zfsvol_alloc_storage_info_func_t)COMN_GetNextParentVolumeComnOp(zvol->ZFSVOLbeastClass, - COMNVOLOPS_INDEX(VOL_allocStorageInfo),(statusfunc_t)ZFSVOL_VOL_AllocStorageInfo); + parentFunc = COMN_GetNextParentVolumeComnOp(zvol->ZFSVOLbeastClass, + COMNVOLOPS_INDEX(VOL_allocStorageInfo),ZFSVOL_VOL_AllocStorageInfo); status = parentFunc(genMsg,beast); @@ -797,12 +757,12 @@ STATIC STATUS ZFSVOL_VOL_GetStorageInfo( *****************************************************************************/ STATIC NINT ZFSVOL_VOL_AllocateZIDs( GeneralMsg_s *genMsg, - Volume_s *vol_LX, + Volume_s *vol_LX, NINT howMany, Zid_t *retZID, Xaction_s *xaction) { - ZfsVolume_s *vol = (ZfsVolume_s *)vol_LX; + ZfsVolume_s *vol = (ZfsVolume_s *)vol_LX; VolInfoLog_s volLog; GeneralMsg_s dummyGenMsg; @@ -819,9 +779,9 @@ STATIC NINT ZFSVOL_VOL_AllocateZIDs( { SetErrno(genMsg, zERR_ZID_GREATER_THAN_32BITS); COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); - COMN_VolumeAlert(&dummyGenMsg, NULL, &vol->vol, NULL, 0, 0, - GetErrno(genMsg), GetErrnoSetter(genMsg), - CVA_VOLUME_ALERT | CVA_REZID_NEEDED); + COMN_VolumeAlert(&dummyGenMsg, NULL, &vol->vol, NULL, 0, 0, + GetErrno(genMsg), GetErrnoSetter(genMsg), + CVA_VOLUME_ALERT | CVA_REZID_NEEDED); RTN_NINT(0); } if ((*retZID+howMany) >= UI64_CONST(0xFFFFFFFF)) @@ -845,15 +805,15 @@ STATIC NINT ZFSVOL_VOL_AllocateZIDs( /* ZLSS_VolumeIDLookupRecovery() - * This function is used to locate a ZLSS volume by its internal GUID and - * lock the volume into memory(increases inUse count) at recovery time. - * If this function succeeds, the volume must be released from memory + * lock the volume into memory(increases inUse count) at recovery time. + * If this function succeeds, the volume must be released from memory * by calling COMN_Release. * * Internal volumes are included on the list of volumes to match. * Volumes not active will also be found. * Internal Volumes include the pool's volume and deleted * volumes (they are volumes that have been marked as internal so that the - * end user does not see them). + * end user does not see them). * * The caller owns the cvsLatch on the poolVolume. * This routine must only be called during recovery. @@ -873,9 +833,9 @@ ZfsVolume_s *ZLSS_VolumeIDLookupRecovery( pool = poolVolume->ZFSPOOLvol.v_pool; zASSERT( pool != NULL ); /* - * Go through the link list of LVs that this pool - * owns and find the correct volume. - */ + * Go through the link list of LVs that this pool + * owns and find the correct volume. + */ POOL_FOR_EACH_LOADED_VOLUME( pool, volume ) { zVolume = (ZfsVolume_s *)volume; @@ -945,9 +905,9 @@ ZfsVolume_s *ZLSS_VolumeIDLookup( pool = poolVolume->ZFSPOOLvol.v_pool; zASSERT( pool != NULL ); /* - * Go through the link list of LVs that this pool - * owns and find the correct volume. - */ + * Go through the link list of LVs that this pool + * owns and find the correct volume. + */ POOL_FOR_EACH_LOADED_VOLUME_NO_BLOCKING( pool, volume ) { @@ -958,7 +918,7 @@ ZfsVolume_s *ZLSS_VolumeIDLookup( { /* This is the correct volume */ if ( ( (!activeOnly) || ((volume->state == zVOLSTATE_ACTIVE) && (!(volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP)) - ) + ) ) && VOL_ACCESSIBLE2(volume, genMsg) /* Needed because deleted LVs are hidden */ ) { /* It matches all conditions */ @@ -978,7 +938,7 @@ ZfsVolume_s *ZLSS_VolumeIDLookup( zVolume = (ZfsVolume_s *)volume; if ( ( (!activeOnly) || ((volume->state == zVOLSTATE_ACTIVE) && (!(volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP)) - ) + ) ) && VOL_ACCESSIBLE2(volume, genMsg) /* Needed because the _IV_ is hidden */ ) { /* It matches all conditions */ @@ -994,7 +954,7 @@ ZfsVolume_s *ZLSS_VolumeIDLookup( /* ZLSS_VolumeIDLookupID - * Given a pool and a volume's internal ID this routine will find - * the volume's Volume ID. + * the volume's Volume ID. * * Notes - * ZLSS volumes on different pools can have the same internal ID. This @@ -1018,11 +978,11 @@ STATUS ZLSS_VolumeIDLookupID( pool = poolVolume->ZFSPOOLvol.v_pool; zASSERT( pool != NULL ); /* - * Go through the link list of LVs that this pool - * owns and find the correct volume. If not found - * then check to see if caller is looking for the - * pool's internal volume. If not then return an error. - */ + * Go through the link list of LVs that this pool + * owns and find the correct volume. If not found + * then check to see if caller is looking for the + * pool's internal volume. If not then return an error. + */ POOL_FOR_EACH_LOADED_VOLUME_NO_BLOCKING( pool, volume ) { zVolume = (ZfsVolume_s *)volume; @@ -1066,15 +1026,15 @@ STATUS ZFSVOL_DoFlushSystemBeasts( RootBeast_s *beast; ASSERT_MPKNSS_LOCK(); #if VOL_HAS_SYSTEM_BEASTS - zfsvol_flush_system_beasts_func_t parentFunc; + statusfunc_t parentFunc; #endif ENTER(TCOMMON, ZFSVOL_DoFlushSystemBeasts); DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN,MSGNot("CVS@ZFSVOL_DoFlushSystemBeasts\n"))); #if VOL_HAS_SYSTEM_BEASTS - parentFunc = (zfsvol_flush_system_beasts_func_t)BST_GetNextParentMethod(vol->ZFSVOLbeastClass, - COMNOPS_INDEX(flushSystemBeasts),(statusfunc_t)ZFSVOL_FlushSystemBeasts); + parentFunc = BST_GetNextParentMethod(vol->ZFSVOLbeastClass, + COMNOPS_INDEX(flushSystemBeasts),ZFSVOL_FlushSystemBeasts); zASSERT( parentFunc != NULL ); parentFunc( genMsg, (Volume_s *)vol ); @@ -1099,7 +1059,7 @@ STATUS ZFSVOL_DoFlushSystemBeasts( if ( !COMN_IsDerivedFrom(vol, zFTYPE_ZLSS_ZFSPOOL) ) { GeneralMsg_s dummyGenMsg; - + COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); (void)ZLSSVOL_DoFlushSystemBeasts( &dummyGenMsg, vol, deactivating ); } @@ -1133,14 +1093,14 @@ STATUS ZFSVOL_BST_GetInfo( { ZfsVolume_s *volume = (ZfsVolume_s *)volume_LX; zVolumeInfo_s *volInfo; - zfsvol_get_info_func_t derivedFromGetInfo; + statusfunc_t derivedFromGetInfo; ASSERT_MPKNSS_LOCK(); /*--------------------------------------------------------------------------- - * First, call the generic file information routine and get any + * First, call the generic file information routine and get any * requested generic information. If it fails, do not continue... *---------------------------------------------------------------------------*/ - derivedFromGetInfo = (zfsvol_get_info_func_t)COMN_GetNextParentBeastComnOp(volume->ZFSVOLbeastClass, - COMNOPS_INDEX(BST_getInfo),(statusfunc_t)ZFSVOL_BST_GetInfo); + derivedFromGetInfo = COMN_GetNextParentBeastComnOp(volume->ZFSVOLbeastClass, + COMNOPS_INDEX(BST_getInfo),ZFSVOL_BST_GetInfo); if (derivedFromGetInfo(genMsg,volume,infoMsg) != zOK) return(zFAILURE); /*--------------------------------------------------------------------------- @@ -1162,7 +1122,7 @@ STATUS ZFSVOL_BST_GetInfo( if (infoMsg->getTypeInfoMask & zGET_VOL_SALVAGE_INFO) { /* The default volume fills in the all salvage info except the - * oldestDeletedTime.*/ + * oldestDeletedTime.*/ volInfo->salvage.oldestDeletedTime = getOldestDeletedTime(genMsg, volume); } @@ -1183,23 +1143,23 @@ STATUS ZFSVOL_BST_ModifyInfo( { ZfsVolume_s *zlssVolume = (ZfsVolume_s *)zlssVolume_LX; zVolumeInfo_s *volInfo; - zfsvol_modify_info_func_t derivedFromModifyInfo; + statusfunc_t derivedFromModifyInfo; BOOL modified = FALSE; BOOL someAttrsChanged = FALSE; BOOL someAttrsNotChanged = FALSE; ASSERT_MPKNSS_LOCK(); zASSERT(!(zlssVolume->ZFSVOLenabledAttributes & zATTR_READONLY) || - (modifyMsg->modifyTypeInfoMask & zMOD_VOL_ATTRIBUTES)); + (modifyMsg->modifyTypeInfoMask & zMOD_VOL_ATTRIBUTES)); /*--------------------------------------------------------------------------- - * First, call the generic file information routine and modify any + * First, call the generic file information routine and modify any * requested generic information. If it fails, do not continue... *---------------------------------------------------------------------------*/ - derivedFromModifyInfo = (zfsvol_modify_info_func_t)COMN_GetNextParentBeastComnOp( + derivedFromModifyInfo = COMN_GetNextParentBeastComnOp( zlssVolume->ZFSVOLbeastClass, COMNOPS_INDEX(BST_modifyInfo), - (statusfunc_t)ZFSVOL_BST_ModifyInfo); + ZFSVOL_BST_ModifyInfo); if (derivedFromModifyInfo(genMsg,zlssVolume,modifyMsg,xaction) != zOK) return(zFAILURE); @@ -1215,8 +1175,8 @@ STATUS ZFSVOL_BST_ModifyInfo( { zASSERT(!(zlssVolume->ZFSVOLenabledAttributes & zATTR_READONLY) || ((modifyMsg->modifyTypeInfoMask & zMOD_VOL_ATTRIBUTES) && - (!(volInfo->features.enabled & zATTR_READONLY)))); - + (!(volInfo->features.enabled & zATTR_READONLY)))); + if (zlssVolume->ZFSVOLmayIDoThis(genMsg, zlssVolume, modifyMsg->parentZid, MAY_I_DO_EVERYTHING) != zOK) { @@ -1226,9 +1186,9 @@ STATUS ZFSVOL_BST_ModifyInfo( if (modifyMsg->modifyTypeInfoMask & zMOD_VOL_DATA_SHREDDING_COUNT) { zASSERT((volInfo->dataShreddingCount >= 1) && - (volInfo->dataShreddingCount <= MAX_DATA_SHRED_PATTERNS)); + (volInfo->dataShreddingCount <= MAX_DATA_SHRED_PATTERNS)); - if (volInfo->dataShreddingCount < 1) + if (volInfo->dataShreddingCount < 1) { volInfo->dataShreddingCount = 1; } @@ -1247,40 +1207,40 @@ STATUS ZFSVOL_BST_ModifyInfo( } } /* FixFixFix6(Later, Logical Volumes) - when logical volumes - * are added then this code must only set attributes - * that belong to the logical volume. Items setable - * by the pool only need to be moved to the Pool modify - * code (i.e. ZFSPOOL_BST_ModifyInfo). - */ + * are added then this code must only set attributes + * that belong to the logical volume. Items setable + * by the pool only need to be moved to the Pool modify + * code (i.e. ZFSPOOL_BST_ModifyInfo). + */ if (modifyMsg->modifyTypeInfoMask & zMOD_VOL_ATTRIBUTES) { - if ((volInfo->features.enableModMask & - ZLSS_NON_CHANGABLE_ATTRIBUTES) != + if ((volInfo->features.enableModMask & + ZLSS_NON_CHANGABLE_ATTRIBUTES) != ((volInfo->features.enabled & volInfo->features.enableModMask) & ZLSS_NON_CHANGABLE_ATTRIBUTES)) { /* One or more of these bits are specified to be changed. - * Today, we don't allow any of these bits to be modified. */ - someAttrsNotChanged = TRUE; + * Today, we don't allow any of these bits to be modified. */ + someAttrsNotChanged = TRUE; } /* - * Salvage - */ + * Salvage + */ if ((volInfo->features.enableModMask & zATTR_SALVAGE) && ((volInfo->features.enabled & zATTR_SALVAGE) != (zlssVolume->ZFSVOLenabledAttributes & zATTR_SALVAGE))) { /* Salvage is being changed */ zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_SALVAGE; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_SALVAGE); someAttrsChanged = TRUE; } /* - * Atime - */ + * Atime + */ // The compiler has trouble with 64 bit masking and bit compares. // This code variation seems to work. @@ -1290,7 +1250,7 @@ STATUS ZFSVOL_BST_ModifyInfo( // (zlssVolume->ZFSVOLenabledAttributes & zATTR_NO_ATIME))) // { // zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_NO_ATIME; -// zlssVolume->ZFSVOLenabledAttributes |= +// zlssVolume->ZFSVOLenabledAttributes |= // (volInfo->features.enabled & zATTR_NO_ATIME); // someAttrsChanged = TRUE; // } @@ -1318,8 +1278,8 @@ STATUS ZFSVOL_BST_ModifyInfo( } } /* - * Hardlinks - */ + * Hardlinks + */ if ((volInfo->features.enableModMask & zATTR_HARD_LINKS) && ((volInfo->features.enabled & zATTR_HARD_LINKS) != (zlssVolume->ZFSVOLenabledAttributes & zATTR_HARD_LINKS))) @@ -1334,37 +1294,37 @@ STATUS ZFSVOL_BST_ModifyInfo( { /* Hardlinks is being changed */ zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_HARD_LINKS; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_HARD_LINKS); someAttrsChanged = TRUE; } } /* - * Extended Mac Namespace i.e. up to 255 unicode chars - */ + * Extended Mac Namespace i.e. up to 255 unicode chars + */ if ((volInfo->features.enableModMask & zATTR_EXTENDED_MAC_NAMESPACE) && ((volInfo->features.enabled & zATTR_EXTENDED_MAC_NAMESPACE) != (zlssVolume->ZFSVOLenabledAttributes & zATTR_EXTENDED_MAC_NAMESPACE))) { /* Extended Mac Namespace attribute is being changed */ zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_EXTENDED_MAC_NAMESPACE; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_EXTENDED_MAC_NAMESPACE); someAttrsChanged = TRUE; } /* - * Migration - */ + * Migration + */ if ((volInfo->features.enableModMask & zATTR_MIGRATION) && ((volInfo->features.enabled & zATTR_MIGRATION) != (zlssVolume->ZFSVOLenabledAttributes & zATTR_MIGRATION))) { /* Migration is being changed */ zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_MIGRATION; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_MIGRATION); someAttrsChanged = TRUE; @@ -1375,7 +1335,7 @@ STATUS ZFSVOL_BST_ModifyInfo( (zlssVolume->ZFSVOLenabledAttributes & zATTR_USER_TRANSACTION))) { zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_USER_TRANSACTION; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_USER_TRANSACTION); someAttrsChanged = TRUE; @@ -1402,16 +1362,16 @@ STATUS ZFSVOL_BST_ModifyInfo( if (COMN_LockVolumeActive(genMsg, (Volume_s *)zlssVolume, FALSE) == zOK) { - WORK_Schedule(fsm, (voidfunc_t)UXactionActivateThread, (ADDR)zlssVolume); + WORK_Schedule(fsm, UXactionActivateThread, (ADDR)zlssVolume); } } } } /* - * User space restrictions - */ - if ((volInfo->features.enableModMask & + * User space restrictions + */ + if ((volInfo->features.enableModMask & zATTR_USER_SPACE_RESTRICTIONS) && ((volInfo->features.enabled & zATTR_USER_SPACE_RESTRICTIONS) != (zlssVolume->ZFSVOLenabledAttributes & @@ -1422,12 +1382,12 @@ STATUS ZFSVOL_BST_ModifyInfo( /* User Space Restriction status is being changed */ if (volInfo->features.enabled & zATTR_USER_SPACE_RESTRICTIONS) { /* - * If we are enabling restriction make sure the tree - * has been created - */ + * If we are enabling restriction make sure the tree + * has been created + */ if (zlssVolume->ZLSSVOLuserTree == NULL) { - if (UBT_CreateUserTreeBeast(genMsg, + if (UBT_CreateUserTreeBeast(genMsg, zlssVolume) != zOK) { errorFlag = TRUE; @@ -1435,7 +1395,7 @@ STATUS ZFSVOL_BST_ModifyInfo( } } /* Initialize the User Space database */ - if (VOL_InitUserSpaceRestrictionData(genMsg, + if (VOL_InitUserSpaceRestrictionData(genMsg, &zlssVolume->ZFSVOLvol) != zOK) { errorFlag = TRUE; @@ -1446,7 +1406,7 @@ STATUS ZFSVOL_BST_ModifyInfo( { zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_USER_SPACE_RESTRICTIONS; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_USER_SPACE_RESTRICTIONS); someAttrsChanged = TRUE; @@ -1454,23 +1414,23 @@ STATUS ZFSVOL_BST_ModifyInfo( } /* - * Directory quotas - */ + * Directory quotas + */ if ((volInfo->features.enableModMask & zATTR_DIR_QUOTAS) && ((volInfo->features.enabled & zATTR_DIR_QUOTAS) != - (zlssVolume->ZFSVOLenabledAttributes & zATTR_DIR_QUOTAS))) + (zlssVolume->ZFSVOLenabledAttributes & zATTR_DIR_QUOTAS))) { BOOL errorFlag = FALSE; /* Directory quota status is being changed */ if (volInfo->features.enabled & zATTR_DIR_QUOTAS) { /* - * If we are enabling restriction make sure the tree - * beast has been created - */ + * If we are enabling restriction make sure the tree + * beast has been created + */ if (zlssVolume->ZLSSVOLdirTree == NULL) { - if (DBT_CreateDirTreeBeast(genMsg, + if (DBT_CreateDirTreeBeast(genMsg, zlssVolume) != zOK) { errorFlag = TRUE; @@ -1482,7 +1442,7 @@ STATUS ZFSVOL_BST_ModifyInfo( { zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_DIR_QUOTAS; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_DIR_QUOTAS); someAttrsChanged = TRUE; @@ -1490,22 +1450,22 @@ STATUS ZFSVOL_BST_ModifyInfo( } /* - * Read-only - */ + * Read-only + */ if ((volInfo->features.enableModMask & zATTR_READONLY) && ((volInfo->features.enabled & zATTR_READONLY) != (zlssVolume->ZFSVOLenabledAttributes & zATTR_READONLY))) { /* Read-only status is being changed */ zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_READONLY; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_READONLY); someAttrsChanged = TRUE; } - /* - * Encryption - you can't modify it - */ + /* + * Encryption - you can't modify it + */ if ((volInfo->features.enableModMask & zATTR_ENCRYPTED) && ((volInfo->features.enabled & zATTR_ENCRYPTED) != (zlssVolume->ZFSVOLenabledAttributes & zATTR_ENCRYPTED))) @@ -1521,7 +1481,7 @@ STATUS ZFSVOL_BST_ModifyInfo( /* don't allow compression to be turned ON to OFF */ if (! (zlssVolume->ZFSVOLenabledAttributes & zATTR_COMPRESSION)) { - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_COMPRESSION); someAttrsChanged = TRUE; } @@ -1532,8 +1492,8 @@ STATUS ZFSVOL_BST_ModifyInfo( } /* - * Modified File List - */ + * Modified File List + */ if ((volInfo->features.enableModMask & zATTR_MFL) && ((volInfo->features.enabled & zATTR_MFL) != (zlssVolume->ZFSVOLenabledAttributes & zATTR_MFL))) @@ -1543,9 +1503,9 @@ STATUS ZFSVOL_BST_ModifyInfo( /* MFL feature is being changed */ if (volInfo->features.enabled & zATTR_MFL) { /* - * If we are enabling MFL make sure the tree - * has been created - */ + * If we are enabling MFL make sure the tree + * has been created + */ if (zlssVolume->ZLSSVOLMFL == NULL) { if (ZFSVOL_VOL_createMFL(genMsg, zlssVolume) != zOK) @@ -1567,15 +1527,15 @@ STATUS ZFSVOL_BST_ModifyInfo( if (!errorFlag) { zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_MFL; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_MFL); someAttrsChanged = TRUE; } } - /* - * Data Shredding - */ + /* + * Data Shredding + */ if ((volInfo->features.enableModMask & zATTR_SHRED_DATA) && ((volInfo->features.enabled & zATTR_SHRED_DATA) != @@ -1594,65 +1554,65 @@ STATUS ZFSVOL_BST_ModifyInfo( someAttrsNotChanged = TRUE; } } - if (!errorFlag) + if (!errorFlag) { zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_SHRED_DATA; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_SHRED_DATA); someAttrsChanged = TRUE; } } /* - * High Integrity - */ + * High Integrity + */ if ((volInfo->features.enableModMask & zATTR_HIGH_INTEGRITY) && ((volInfo->features.enabled & zATTR_HIGH_INTEGRITY) != (zlssVolume->ZFSVOLenabledAttributes & zATTR_HIGH_INTEGRITY))) { /* high integrity is being changed */ zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_HIGH_INTEGRITY; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_HIGH_INTEGRITY); someAttrsChanged = TRUE; } /* - * CFS_MASTER - */ + * CFS_MASTER + */ if ((volInfo->features.enableModMask & zATTR_CFS_MASTER) && ((volInfo->features.enabled & zATTR_CFS_MASTER) != (zlssVolume->ZFSVOLenabledAttributes & zATTR_CFS_MASTER))) { /* CFS_MASTER is being changed */ zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_CFS_MASTER; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_CFS_MASTER); someAttrsChanged = TRUE; } /* - * COW - */ + * COW + */ if ((volInfo->features.enableModMask & zATTR_COW) && ((volInfo->features.enabled & zATTR_COW) != (zlssVolume->ZFSVOLenabledAttributes & zATTR_COW))) { /* Cow is being changed */ zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_COW; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_COW); someAttrsChanged = TRUE; } /* - * DONT BACKUP - */ + * DONT BACKUP + */ if ((volInfo->features.enableModMask & zATTR_DONT_BACKUP) && ((volInfo->features.enabled & zATTR_DONT_BACKUP) != (zlssVolume->ZFSVOLenabledAttributes & zATTR_DONT_BACKUP))) { /* Don't backup is being changed */ zlssVolume->ZFSVOLenabledAttributes &= ~zATTR_DONT_BACKUP; - zlssVolume->ZFSVOLenabledAttributes |= + zlssVolume->ZFSVOLenabledAttributes |= (volInfo->features.enabled & zATTR_DONT_BACKUP); someAttrsChanged = TRUE; } @@ -1675,8 +1635,8 @@ STATUS ZFSVOL_BST_ModifyInfo( } } /* We set these items because each logical volume can - * have their own salvage min and max settings. - */ + * have their own salvage min and max settings. + */ if (modifyMsg->modifyTypeInfoMask & zMOD_VOL_MIN_KEEP_SECONDS) { zlssVolume->ZFSVOLminKeepSeconds = volInfo->salvage.minKeepSeconds; @@ -1698,7 +1658,7 @@ STATUS ZFSVOL_BST_ModifyInfo( if (modifyMsg->modifyTypeInfoMask & zMOD_VOL_QUOTA) { NINT shift = zlssVolume->ZLSSVOLblockShift; - zlssVolume->ZLSSVOLtotalBlocks = + zlssVolume->ZLSSVOLtotalBlocks = (volInfo->totalSpaceQuota + (1 << shift) - 1) >> shift; modified = TRUE; } @@ -1711,8 +1671,8 @@ STATUS ZFSVOL_BST_ModifyInfo( if ( modified ) { /* This is an async call that does not do transactions - * so no warrenty that persistent information is updated. - */ + * so no warrenty that persistent information is updated. + */ ZFSVOL_WritePersistentVolumeData(zlssVolume); } @@ -1721,10 +1681,10 @@ STATUS ZFSVOL_BST_ModifyInfo( if (someAttrsNotChanged) { /* The error code zERR_SOME_ATTRS_NOT_CHANGED indicates a partial - * success, but we still return an error indicating not all - * attributes were changed as requested. */ + * success, but we still return an error indicating not all + * attributes were changed as requested. */ return(zFAILURE); - + } return(zOK); } @@ -1754,7 +1714,7 @@ STATUS ZFSVOL_VOL_CommandFunction( { ZfsVolume_s *beast = (ZfsVolume_s *)beast_LX; - zfsvol_command_func_t parentFunc; + statusfunc_t parentFunc; STATUS status; zASSERT( COMN_IsDerivedFrom(beast, zFTYPE_ZLSS_VOL) ); @@ -1765,9 +1725,9 @@ STATUS ZFSVOL_VOL_CommandFunction( switch( functionNumber ) { /*** Note that the VCO_VOLUME_CREATE_NUMBER command - *** is handle by ZLSSPOL_VOL_CommandFunction() because - *** we only have a pool beast when a volume is created. - ***/ + *** is handle by ZLSSPOL_VOL_CommandFunction() because + *** we only have a pool beast when a volume is created. + ***/ case VCO_VOLUME_CREATE_NUMBER: COMN_Release( &beast ); status = zFAILURE; @@ -1787,19 +1747,19 @@ STATUS ZFSVOL_VOL_CommandFunction( break; case VCO_VOLUME_DELETE_ACTION_NUMBER: COMN_Release( &beast ); /* Delete API assumes calling thread - * does not own. - */ + * does not own. + */ status = ZLSSVOL_LVD_DeleteActionAPI( genMsg, pCD->u.deleteAction.volumeName, pCD->u.deleteAction.action ); break; case VCO_VOLUME_GET_INFO_NUMBER: // S_LATCH( &beast->ZLSSVOLvol.stateLatch ); - ASSERT_LATCH( &beast->ZLSSVOLvol.stateLatch ); + ASSERT_LATCH( &beast->ZLSSVOLvol.stateLatch ); COMN_USE_BEAST( &beast->ZFSVOLroot ); /* Get a use count for parent */ - parentFunc = (zfsvol_command_func_t)COMN_GetNextParentVolumeComnOp( beast->ZFSVOLbeastClass, + parentFunc = COMN_GetNextParentVolumeComnOp( beast->ZFSVOLbeastClass, COMNVOLOPS_INDEX(VOL_commandFunction), - (statusfunc_t)ZFSVOL_VOL_CommandFunction ); + ZFSVOL_VOL_CommandFunction ); zASSERT(parentFunc != NULL); status = parentFunc( genMsg, beast, functionNumber, pCD, parmLen, parm, dataLen, commandData, @@ -1941,7 +1901,7 @@ CommonVolumeOps_s ZFSVOL_ComnVolOps = ZFSVOL_VOL_lookupMFLEntry, /* VOL_lookupMFLEntry */ ZFSVOL_VOL_enumerateMFL, /* VOL_enumerateMFL */ ZFSVOL_VOL_administerMFL, /* VOL_administerMFL */ - ZFSVOL_VOL_CommandFunction, /* VOL_commandFunction */ + ZFSVOL_VOL_CommandFunction, /* VOL_commandFunction */ ZFSVOL_VOL_GetDirQuotaInfo, /* VOL_getDirQuotaInfo */ ZFSVOL_VOL_SetDirQuota, /* VOL_setDirQuota */ @@ -1998,7 +1958,7 @@ STATIC BYTE *ZFSVOL_Pack( *****************************************************************************/ STATIC BYTE *ZFSVOL_Unpack( GeneralMsg_s *genMsg, - void *beast_LX, + void *beast_LX, BYTE *storeBuffer) { ASSERT_MPKNSS_LOCK(); diff --git a/src/nwnss/zlss/zfsVolumeData.c b/src/nwnss/zlss/zfsVolumeData.c index c79833d..1f3f8c9 100644 --- a/src/nwnss/zlss/zfsVolumeData.c +++ b/src/nwnss/zlss/zfsVolumeData.c @@ -73,7 +73,7 @@ * latch should be owned because we are accessing the volume's data. This * refers to callers of the routine which are writing the VDB. */ - + STATIC STATUS ZFSVOL_GetVolumeName( GeneralMsg_s *genMsg, Volume_s *volume, @@ -97,7 +97,7 @@ STATIC STATUS ZFSVOL_GetVolumeName( { unimcpy(vname,nnode->p.name,vnameSize); - if ((nameSpace->flags & NSFLforceLowerIfForcedUpper) && + if ((nameSpace->flags & NSFLforceLowerIfForcedUpper) && (nnode->p.flagsAndLen & NAMEforcedUpper)) { unilwr(vname); @@ -157,13 +157,13 @@ LONG ZFSVOL_CalculateChecksum( LONG *buffer, NINT numberOfLONGs ) * When persistent volume data has changed, we must write it to the media * * 11/7/00 - We (Greg and Vandana) made this routine synchronous to close - * windows in other code. For example, rebuild marks the pool as being + * windows in other code. For example, rebuild marks the pool as being * rebuilt and increments rebuild count. This must become persistent before * the zlog file is initialized (zlog uses rebuild count to know that * the data in the zlog file is old.) Same applies to ModifyInfo where we - * modify and return to user saying the change is done but it was not + * modify and return to user saying the change is done but it was not * synchronous. - * + * ***************************************************************************/ void ZFSVOL_WritePersistentVolumeData( ZfsVolume_s *zlssVol) @@ -191,16 +191,16 @@ void ZFSVOL_WritePersistentVolumeData( /* writing and set persistent volume information */ blk = zlssVol->p.PZV_volumeDataBlk; /* If the block is zero then we must not write this information. - * Generally, this means that the persistent information has - * not been initialized (or read) in yet. - */ + * Generally, this means that the persistent information has + * not been initialized (or read) in yet. + */ if (blk != 0 && blk != INVALID_BLK) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN, MSGNot("CVS@ZFSVOL_WritePersistentVolumeData (doing a write)\n"))); /* This can be a CACHE_WRITE because we update all of the - * portion of the block we use. - */ + * portion of the block we use. + */ #ifdef __linux__ READBLK_IO_MSG(aStack->iomsg,zlssVol,blk,CACHE_UPDATE); @@ -221,7 +221,7 @@ void ZFSVOL_WritePersistentVolumeData( { LONG checksum; Zfs4KVolumeBlock_s *block; /* Non-logged blocked */ - + block = (Zfs4KVolumeBlock_s *)buffer->pBuf.data; zlssVol->ZLSSVOLversion = ZFSVOLUMEINFO_VERSION; @@ -258,21 +258,21 @@ void ZFSVOL_WritePersistentVolumeData( #endif } /* Calculate the checksum in the ZVD4K_Persistents because all - * of the non-logged data is next to each other. - */ + * of the non-logged data is next to each other. + */ block->ZVD4K_Persistents.ZVD_zfsVol.PZV_checksum = 0; - checksum = ZFSVOL_CalculateChecksum((LONG*)block,sizeof(block->ZVD4K_Persistents)/4 ); + checksum = ZFSVOL_CalculateChecksum((LONG*)block,sizeof(block->ZVD4K_Persistents)/4 ); block->ZVD4K_Persistents.ZVD_zfsVol.PZV_checksum = 0 - checksum; /* This is not really required because the logged - * write uses the VolumeData buffer and not in - * memory copy for its writes. I set the IN-MEMORY - * checksum just because it feels right! - */ + * write uses the VolumeData buffer and not in + * memory copy for its writes. I set the IN-MEMORY + * checksum just because it feels right! + */ zlssVol->p.PZV_checksum = 0 - checksum; /* Wait for this buffer to be synchronously written before we - * return from here. - */ + * return from here. + */ initAgent( &waitAgent, NULL, "Write Volume Data Agent" ); bind( &waitAgent, &buffer->agent ); CACHE_DIRTY_RELEASE( buffer ); @@ -334,10 +334,10 @@ void ZFSVOL_WritePersistentVolumeDataXactioned( /* writing and set persistent volume information */ blk = zlssVol->p.PZV_volumeDataBlk; /* If the block is zero then we must not write this information. - * Generally, this means that the persistent information has - * not been initialized (or read) in yet. This should not - * occur in the XACTIONed version! - */ + * Generally, this means that the persistent information has + * not been initialized (or read) in yet. This should not + * occur in the XACTIONed version! + */ zASSERT( (blk != 0) && (blk != INVALID_BLK) ); if ( (blk == 0) || (blk == INVALID_BLK) ) { @@ -348,11 +348,11 @@ void ZFSVOL_WritePersistentVolumeDataXactioned( DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN, MSGNot("CVS@ZFSVOL_WritePersistentVolumeDataXactioned (doing a write)\n"))); /* This can be a CACHE_WRITE because we update all of the - * portion of the block we use. - */ + * portion of the block we use. + */ READBLK_IO_MSG(iomsg,zlssVol,blk,CACHE_WRITE); buffer = ZFS_ReadPoolBlk(&genMsg,&iomsg); - + block = (Zfs4KVolumeBlock_s *)buffer->pBuf.data; /* log the init record */ @@ -385,7 +385,7 @@ void ZFSVOL_WritePersistentVolumeDataXactioned( } { STATUS status; - + status = ZFSVOL_GetVolumeName( &genMsg, &zlssVol->ZFSVOLvol, #ifdef __linux__ aStack->vName, sizeof(aStack->vName)); @@ -399,7 +399,7 @@ void ZFSVOL_WritePersistentVolumeDataXactioned( ClearErrno( &genMsg ); } unicpy(block->ZVD4K_VolName, -#ifdef __linux__ +#ifdef __linux__ aStack->vName); #else vName); @@ -408,10 +408,10 @@ void ZFSVOL_WritePersistentVolumeDataXactioned( } /* Calculate the checksum in the BLOCK because all - * of the non-logged data is next to each other. - */ + * of the non-logged data is next to each other. + */ block->ZVD4K_Persistents.ZVD_zfsVol.PZV_checksum = 0; - checksum = ZFSVOL_CalculateChecksum((LONG*)block,sizeof(block->ZVD4K_Persistents)/4 ); + checksum = ZFSVOL_CalculateChecksum((LONG*)block,sizeof(block->ZVD4K_Persistents)/4 ); block->ZVD4K_Persistents.ZVD_zfsVol.PZV_checksum = 0 - checksum; zlssVol->p.PZV_checksum = 0 - checksum; @@ -432,7 +432,7 @@ void ZFSVOL_WritePersistentVolumeDataXactioned( RTN_VOID(); } /* End of ZFSVOL_WritePersistentVolumeDataXactioned() */ - + /************************************************************************** * When persistent volume data has changed, we must write it to the media @@ -469,16 +469,16 @@ STATUS ZFSVOL_WriteInitialVDB( /* writing and set persistent volume information */ blk = zlssVol->p.PZV_volumeDataBlk; /* If the block is zero then we must not write this information. - * Generally, this means that the persistent information has - * not been initialized (or read) in yet. - */ + * Generally, this means that the persistent information has + * not been initialized (or read) in yet. + */ zASSERT( (blk != 0) && (blk != INVALID_BLK) ); DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN, MSGNot("CVS@ZFSVOL_WritePersistentVolumeDataInit (doing a write)\n"))); /* This can be a CACHE_WRITE because we update all of the - * portion of the block we use. - */ + * portion of the block we use. + */ #ifdef __linux__ READBLK_IO_MSG(aStack->iomsg,zlssVol,blk,CACHE_WRITE); buffer = ZFS_ReadPoolBlk( genMsg, &aStack->iomsg ); @@ -525,16 +525,16 @@ STATUS ZFSVOL_WriteInitialVDB( } /* Calculate the checksum in the BLOCK because all - * of the non-logged data is next to each other. - */ + * of the non-logged data is next to each other. + */ block->ZVD4K_Persistents.ZVD_zfsVol.PZV_checksum = 0; - checksum = ZFSVOL_CalculateChecksum((LONG*)block,sizeof(block->ZVD4K_Persistents)/4 ); + checksum = ZFSVOL_CalculateChecksum((LONG*)block,sizeof(block->ZVD4K_Persistents)/4 ); block->ZVD4K_Persistents.ZVD_zfsVol.PZV_checksum = 0 - checksum; /* This is not really required because the logged - * write uses the VolumeData buffer and not in - * memory copy for its writes. I set the IN-MEMORY - * checksum just because it feels right! - */ + * write uses the VolumeData buffer and not in + * memory copy for its writes. I set the IN-MEMORY + * checksum just because it feels right! + */ zlssVol->p.PZV_checksum = 0 - checksum; /* Removed transaction code to fix Bug#304139 and Bug#304187 */ @@ -560,8 +560,8 @@ STATUS ZFSVOL_WriteInitialVDB( ZLOG_ALLOC_BLOCK(poolBlks[0]); /* LSN is not used because this is an ALLOCed block (which is really - * good for the VDB as it does not have an LSN!!! - */ + * good for the VDB as it does not have an LSN!!! + */ /* node->lsn = logBuffer->ZXR_Lsn; */ /* This is the PACK code for a ZFS Volume (non-logged data) */ memcpy( &logRecord->ZVILR_ValuesNew.ZVD_zfsVol, &block->ZVD4K_Persistents.ZVD_zfsVol, @@ -656,7 +656,7 @@ STATUS ZFSVOL_WriteInitialVDB( // * of the non-logged data is next to each other. // */ // block->ZVD_zfsVol.PZV_checksum = 0; -// checksum = ZFSVOL_CalculateChecksum((LONG*)block,sizeof(*block)/4 ); +// checksum = ZFSVOL_CalculateChecksum((LONG*)block,sizeof(*block)/4 ); // block->ZVD_zfsVol.PZV_checksum = 0 - checksum; // /* This is not really required because the logged // * write uses the VolumeData buffer and not in @@ -697,7 +697,7 @@ STATUS ZFSVOL_WriteInitialVDB( // ZLOG_BIND(xaction, buffer); // ZLOG_ReleaseRecord(xaction); // } -// +// // CACHE_DIRTY_RELEASE(buffer); // // return( status ); @@ -725,11 +725,11 @@ STATUS ZFSVOL_WriteInitialLVDB( blk = zlssVol->p.PZV_loggedVolumeDataBlk; /* If the block is zero then we must not write this information. - * Generally, this means that the persistent information has - * not been initialized (or read) in yet. For example, - * during LV creation we allocate the BT specical block, the VDB - * and the LVDB before knowing the LVDB block number. - */ + * Generally, this means that the persistent information has + * not been initialized (or read) in yet. For example, + * during LV creation we allocate the BT specical block, the VDB + * and the LVDB before knowing the LVDB block number. + */ zASSERT( (blk != 0) && (blk != INVALID_BLK) ); READBLK_IO_MSG(iomsg,zlssVol,blk,CACHE_WRITE); @@ -738,9 +738,9 @@ STATUS ZFSVOL_WriteInitialLVDB( data = ((ZfsLoggedVolumeBlock_s *)buffer->pBuf.data); /* This takes the memory copy of active data that is logged - * in the Volume_s and places into the volume's data block. - * Note that we do not copy the reserved area (it is garbage). - */ + * in the Volume_s and places into the volume's data block. + * Note that we do not copy the reserved area (it is garbage). + */ /* This is the PACK code for a ZFS Volume (logged data) */ memcpy( &data->ZLVD_zfsVol, &zlssVol->logged, @@ -748,7 +748,7 @@ STATUS ZFSVOL_WriteInitialLVDB( sizeof(zlssVol->logged.LPZV_reserved) ); /* This is the PACK code for a Volume (logged data) */ memcpy(&data->ZLVD_volume, &zlssVol->ZFSVOLvol.logged, - sizeof(LoggedPersistentVolume_s) - + sizeof(LoggedPersistentVolume_s) - sizeof(zlssVol->ZFSVOLvol.logged.LPV_reserved) ); zASSERT( zfsPool->storagepool != NULL ); @@ -770,9 +770,9 @@ STATUS ZFSVOL_WriteInitialLVDB( /* LSN is not used because this is an ALLOCed block */ /* node->lsn = logBuffer->ZXR_Lsn; */ /* I use zlssVol and not data so that the reserved fields - * are zero. This makes the Log Record cleaner when viewing - * with ZLOG ZAD utility. - */ + * are zero. This makes the Log Record cleaner when viewing + * with ZLOG ZAD utility. + */ memcpy( &logRecord->ZLVD_zfsVol, &zlssVol->logged, sizeof(zlssVol->logged) ); @@ -783,13 +783,13 @@ STATUS ZFSVOL_WriteInitialLVDB( ZLOG_BIND(xaction, buffer); ZLOG_ReleaseRecord(xaction); } - + CACHE_DIRTY_RELEASE(buffer); #if 0 /*** Synchronously write VDB so that when the LV Create xaction - *** ends we can be ensured that the VDB is inited. - ***/ + *** ends we can be ensured that the VDB is inited. + ***/ status = ZFSPOOL_SuperBlockWrite( zfsPool->storagepool, data, blk, 1); if ( status != zOK ) { @@ -800,7 +800,7 @@ STATUS ZFSVOL_WriteInitialLVDB( #endif return status; -} /* End of ZFSVOL_WriteInitialLVDB() */ +} /* End of ZFSVOL_WriteInitialLVDB() */ /**************************************************************************** @@ -819,30 +819,30 @@ SNINT AdjustPurgeableBlocks( zASSERT("Going negative with volume purgeableBlocks count"==0); /* Change the Delta to something that will - * make the purgeableBlocks go to (or approach) - * zero. - * If the purgeableBlocks count is already - * negative, add the biggest number we can to - * make it go back towards zero. - * The delta field is only an SLONG, so we - * cannot log more than +2GB. - */ + * make the purgeableBlocks go to (or approach) + * zero. + * If the purgeableBlocks count is already + * negative, add the biggest number we can to + * make it go back towards zero. + * The delta field is only an SLONG, so we + * cannot log more than +2GB. + */ purgeableTemp = volPurgeableBlocks; if (purgeableTemp >= 0) { /* We currently have a positive count, but - * it is less than the current delta. - * Subtract as much as we have ... - * so we will go to zero but not below it. - */ + * it is less than the current delta. + * Subtract as much as we have ... + * so we will go to zero but not below it. + */ delta = -purgeableTemp; } else { /* Purgeable count is already negative. - * Add back what we can to make it approach - * zero (but the max we can add is 2GB-1 - */ + * Add back what we can to make it approach + * zero (but the max we can add is 2GB-1 + */ purgeableTemp = -purgeableTemp; if (purgeableTemp > 0x7FFFFFFF) { @@ -924,16 +924,16 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( /* writing and set persistent volume information */ blk = zfsVol->p.PZV_loggedVolumeDataBlk; /* If the block is zero then we must not write this information. - * Generally, this means that the persistent information has - * not been initialized (or read) in yet. For example, - * during LV creation we allocate the BT specical block, the VDB - * and the LVDB before knowing the LVDB block number. - */ + * Generally, this means that the persistent information has + * not been initialized (or read) in yet. For example, + * during LV creation we allocate the BT specical block, the VDB + * and the LVDB before knowing the LVDB block number. + */ if (blk != 0 && blk != INVALID_BLK) { /* This can be a CACHE_WRITE because we update all of the - * portion of the block we use. - */ + * portion of the block we use. + */ READBLK_IO_MSG(iomsg,vol,blk,CACHE_WRITE); SET_DEBUG_ID(iomsg, 54); buffer = ZFS_ReadPoolBlk(&genMsg,&iomsg); @@ -971,10 +971,10 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( vol->VOLnumDeletedFiles += delta; if (vol->VOLnumDeletedFiles == 0) { - /* We need to fix a bug, where our purgeableBlocks count is - * going negative. By doing this fix here, if the count is - * messed up, this will reset it back to zero. - */ + /* We need to fix a bug, where our purgeableBlocks count is + * going negative. By doing this fix here, if the count is + * messed up, this will reset it back to zero. + */ zASSERT(vol->VOLpurgeableBlocks == 0); if (vol->VOLpurgeableBlocks != 0) { @@ -982,11 +982,11 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( vol->VOLpurgeableBlocks = 0; /* Force to zero */ /* Our volume count was messed up. If it is negative, the - * pool is also negative by the same count. If it is still - * positive, the pool is also still positive by the - * same count. A simple fix for this is to subtract - * the erroneous volume count from the pool count. - */ + * pool is also negative by the same count. If it is still + * positive, the pool is also still positive by the + * same count. A simple fix for this is to subtract + * the erroneous volume count from the pool count. + */ zlssPool = (ZlssPool_s *)vol->v_pool; zASSERT( zlssPool != NULL ); zlssPool->ZLSSPOOLpurgeableBlocks -= delta; /* Adjust by error */ @@ -1010,7 +1010,7 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( break; } case VOLINFO_CHANGE_NUM_COMPRESSED_FILE_BLOCKS: - { + { vol->VOLnumCompressedFileBlocks += delta; break; } @@ -1027,12 +1027,12 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( zlssPool = (ZlssPool_s *)vol->v_pool; zASSERT( zlssPool != NULL ); if ( zlssPool->ZP_p.PZP_loggedPoolDataBlk != 0 && - zlssPool->ZP_p.PZP_loggedPoolDataBlk != INVALID_BLK ) + zlssPool->ZP_p.PZP_loggedPoolDataBlk != INVALID_BLK ) { /* The up front check for legal pool actions is done so that - * we do not need to get a XLATCH on the Pool's logged - * pool data block in cases that we do not need it. - */ + * we do not need to get a XLATCH on the Pool's logged + * pool data block in cases that we do not need it. + */ ZlssLoggedPoolBlock_s *poolBlock; Buffer_s *poolBuffer; @@ -1058,12 +1058,12 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( // MSGNot("VOLINFO_CHANGE_NUM_BLOCKS %ld Zid = %Ld\n"), // (unsigned long)vol->VOLinUseBlocks,vol->VOLzid )); /* We do not do the booked item because it - * has to be done by the caller. Generally, - * the caller updates the booked item 'way' - * before allocating a block so to discourge - * race conditions that could cause all blocks - * be be allocated. - */ + * has to be done by the caller. Generally, + * the caller updates the booked item 'way' + * before allocating a block so to discourge + * race conditions that could cause all blocks + * be be allocated. + */ // zlssPool->ZLSSPOOLbookedInUseBlocks += delta; break; } @@ -1071,11 +1071,11 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( { if ( vol->VOLv_statusFlag & VOL_SF_LOGICAL_VOLUME ) { /* In the case of a LV the total blocks - * is really a disk space quota so we - * MUST NOT update the Pool's size OR - * generate a pool log record that - * would do it if we crash. - */ + * is really a disk space quota so we + * MUST NOT update the Pool's size OR + * generate a pool log record that + * would do it if we crash. + */ logThis = FALSE; vol->VOLtotalBlocks += delta; } @@ -1091,9 +1091,9 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( ((-delta) > ((SQUAD)vol->VOLpurgeableBlocks))) { /* We would have gone negative here. - * Calculate a corrected delta, and save the same - * delta in the journal for recovery purposes. - */ + * Calculate a corrected delta, and save the same + * delta in the journal for recovery purposes. + */ delta = AdjustPurgeableBlocks(vol->VOLpurgeableBlocks); volLog->delta = delta; } @@ -1111,10 +1111,10 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( if ( (xaction != NULL) && (logThis) ) { /** The pool logs in a seperate log record from - * the volume. This was done because it is a clean - * design. Although, one could argue that performance - * is more important. - */ + * the volume. This was done because it is a clean + * design. Although, one could argue that performance + * is more important. + */ ZLOG_ObtainRecord((ZfsXaction_s *)xaction, ZLOG_BLOCK_INFO_SIZE(1) + sizeof(*volLog) ); @@ -1137,10 +1137,10 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( ZLOG_TEST_REDO((ZfsXaction_s *)xaction); ZLOG_ReleaseRecord((ZfsXaction_s *)xaction); /* Update block copy - watied until now because the - * when LOG_TEST is enabled the release above runs - * special debug code that requires the old copy - * of the LSN. - */ + * when LOG_TEST is enabled the release above runs + * special debug code that requires the old copy + * of the LSN. + */ #if LOG_TEST IS_ENABLED /* Waited because REDO/UNDO test pokes */ zlssPool->ZLSSPOOLlsn = savedLsn; @@ -1155,7 +1155,7 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( /* This is the PACK code for a Pool (logged data) */ memcpy( &poolBlock->ZLPB_pool, &zlssPool->ZLSSPOOLpool.logged, - sizeof(poolBlock->ZLPB_pool) - + sizeof(poolBlock->ZLPB_pool) - sizeof(zlssPool->ZLSSPOOLpool.logged.LPP_reserved) ); // DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, // MSGNot("At write with in use blocks set to %Ld\n"), @@ -1164,8 +1164,8 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( } else { /* Pool LPDB was zero or INVALID (this is normal during - * upgrade OR Pool Creation - */ + * upgrade OR Pool Creation + */ switch (volLog->action) { case VOLINFO_CHANGE_NUM_BLOCKS: @@ -1179,12 +1179,12 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( // MSGNot("VOLINFO_CHANGE_NUM_BLOCKS %ld Zid = %Ld\n"), // (unsigned long)vol->VOLinUseBlocks,vol->VOLzid )); /* We do not do the booked item because it - * has to be done by the caller. Generally, - * the caller updates the booked item 'way' - * before allocating a block so to discourge - * race conditions that could cause all blocks - * be be allocated. - */ + * has to be done by the caller. Generally, + * the caller updates the booked item 'way' + * before allocating a block so to discourge + * race conditions that could cause all blocks + * be be allocated. + */ // zlssPool->ZLSSPOOLbookedInUseBlocks += delta; break; } @@ -1192,11 +1192,11 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( { if ( vol->VOLv_statusFlag & VOL_SF_LOGICAL_VOLUME ) { /* In the case of a LV the total blocks - * is really a disk space quota so we - * MUST NOT update the Pool's size OR - * generate a pool log record that - * would do it if we crash. - */ + * is really a disk space quota so we + * MUST NOT update the Pool's size OR + * generate a pool log record that + * would do it if we crash. + */ logThis = FALSE; vol->VOLtotalBlocks += delta; } @@ -1212,9 +1212,9 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( ((-delta) > ((SQUAD)vol->VOLpurgeableBlocks))) { /* We would have gone negative here. - * Calculate a corrected delta, and save the same - * delta in the journal for recovery purposes. - */ + * Calculate a corrected delta, and save the same + * delta in the journal for recovery purposes. + */ delta = AdjustPurgeableBlocks(vol->VOLpurgeableBlocks); volLog->delta = delta; } @@ -1232,11 +1232,11 @@ void ZFSVOL_VOL_WriteVolumeLoggedData( } break; } - case VOLINFO_CHANGE_NEXT_ZID: + case VOLINFO_CHANGE_NEXT_ZID: { break; } - case VOLINFO_CHANGE_REN_SEQ_NUM: + case VOLINFO_CHANGE_REN_SEQ_NUM: { break; } @@ -1271,10 +1271,10 @@ copyDataAndReturn: ZLOG_TEST_REDO((ZfsXaction_s *)xaction); ZLOG_ReleaseRecord((ZfsXaction_s *)xaction); /* Update block copy - watied until now because the - * when LOG_TEST is enabled the release above runs - * special debug code that requires the old copy - * of the LSN. - */ + * when LOG_TEST is enabled the release above runs + * special debug code that requires the old copy + * of the LSN. + */ #if LOG_TEST IS_ENABLED // Waited because REDO/UNDO test pokes zfsVol->logged.LPZV_lsn = savedLsn; @@ -1282,9 +1282,9 @@ copyDataAndReturn: #endif } /* This takes the memory copy of active data that is logged - * in the Volume_s and places into the volume's data block. - * Note that we do not copy the reserved area (it is garbage). - */ + * in the Volume_s and places into the volume's data block. + * Note that we do not copy the reserved area (it is garbage). + */ /* This is the PACK code for a ZFS Volume (logged data) */ memcpy( &block->ZLVD_zfsVol, &zfsVol->logged, @@ -1292,12 +1292,12 @@ copyDataAndReturn: sizeof(zfsVol->logged.LPZV_reserved) ); /* This is the UNPACK code for a Volume (logged data) */ memcpy(&block->ZLVD_volume, &vol->logged, - sizeof(LoggedPersistentVolume_s) - + sizeof(LoggedPersistentVolume_s) - sizeof(vol->logged.LPV_reserved) ); CACHE_DIRTY_RELEASE(buffer); } RTN_VOID(); -} +} /* @@ -1386,10 +1386,10 @@ STATUS ZLSSPOOL_WriteVolumeLoggedData( ZLOG_TEST_REDO((ZfsXaction_s *)xaction); ZLOG_ReleaseRecord((ZfsXaction_s *)xaction); /* Update block copy - watied until now because the - * when LOG_TEST is enabled the release above runs - * special debug code that requires the old copy - * of the LSN. - */ + * when LOG_TEST is enabled the release above runs + * special debug code that requires the old copy + * of the LSN. + */ #if LOG_TEST IS_ENABLED zlssPool->ZLSSPOOLlsn = savedLsn; // Waited because REDO/UNDO test pokes poolBlock->ZLPB_zlssPool.LPZP_lsn = savedLsn; @@ -1402,7 +1402,7 @@ STATUS ZLSSPOOL_WriteVolumeLoggedData( /* This is the PACK code for a Pool (logged data) */ memcpy( &poolBlock->ZLPB_pool, &zlssPool->ZLSSPOOLpool.logged, - sizeof(poolBlock->ZLPB_pool) - + sizeof(poolBlock->ZLPB_pool) - sizeof(zlssPool->ZLSSPOOLpool.logged.LPP_reserved) ); // DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, // MSGNot("At write with in use blocks set to %Ld\n"), @@ -1441,8 +1441,8 @@ STATUS recoveryVolumeInfo( if (ZLOG_VALID_BLOCK(poolBlks[0])) { /* This MUST be a CACHE_UPDATE because we only update part of - * the block we use. - */ + * the block we use. + */ READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_UPDATE) SET_DEBUG_ID(iomsg, 0); if ((buffer = ZFS_ReadPoolBlk(genMsg, &iomsg)) == NULL) @@ -1488,17 +1488,17 @@ STATUS recoveryVolumeInfo( { block->ZLVD_volume.inUseBlocks += delta; /* Even though we have loaded the Volume's persistent - * VDB or LVDB we do not need to keep 'book' value - * in sync. This is because ZLOG will RE-LOAD - * the persistent information after a successful - * REDO/UNDO. This is already a requirement because - * all of our REDO/UNDO code in this routine only - * updates the physical block and not the information - * stored in the Pool's beast. Note that the Pool - * and ZLOG beasts are the only beasts 'loaded' when - * doing REDO/UNDO. This should work will when - * logical volumes are added. - */ + * VDB or LVDB we do not need to keep 'book' value + * in sync. This is because ZLOG will RE-LOAD + * the persistent information after a successful + * REDO/UNDO. This is already a requirement because + * all of our REDO/UNDO code in this routine only + * updates the physical block and not the information + * stored in the Pool's beast. Note that the Pool + * and ZLOG beasts are the only beasts 'loaded' when + * doing REDO/UNDO. This should work will when + * logical volumes are added. + */ // pool->ZFSPOOLbookedInUseBlocks += delta; break; } @@ -1513,9 +1513,9 @@ STATUS recoveryVolumeInfo( { /* never move the next zid backward */ block->ZLVD_volume.nextZid += delta; /* These should be the same, but we have a - * bug where ZIDs get re-used. This may help - * us find this bug - Greg (12/17/97). - */ + * bug where ZIDs get re-used. This may help + * us find this bug - Greg (12/17/97). + */ zASSERT( block->ZLVD_volume.nextZid == logRecord->VIL_value ); } break; @@ -1625,9 +1625,9 @@ STATUS ZFSVOL_ReadPersistentVolumeData( if(zlssVol->ZV_RepairFlags & ZV_REPAIRFLAGS_REBUILD_VOL_DATA_BLOCKS ) { /* init VDB here */ ZLSSVOL_InitVDB( zlssVol,INVALID_BLK ,INVALID_BLK ,INVALID_BLK , - GetUTCTime() , 1, GetUTCTime(), FALSE ); + GetUTCTime() , 1, GetUTCTime(), FALSE ); } - ClearErrno(genMsg); + ClearErrno(genMsg); goto ReadLoggedBlock; } else @@ -1645,17 +1645,17 @@ STATUS ZFSVOL_ReadPersistentVolumeData( /* This is the UNPACK code for a Volume */ memcpy( &zlssVol->vol.p, &block->ZVD4K_Persistents.ZVD_volume, sizeof(block->ZVD4K_Persistents.ZVD_volume) ); - /* unpack the area where the crypto data lives. It may or maynot be + /* unpack the area where the crypto data lives. It may or maynot be * here, but if this * is junk, we will detect it and ignore it later on */ - memcpy(&zlssVol->vol.v_key.p, &block->ZVD4K_zfsCrypt, sizeof(block->ZVD4K_zfsCrypt)); + memcpy(&zlssVol->vol.v_key.p, &block->ZVD4K_zfsCrypt, sizeof(block->ZVD4K_zfsCrypt)); /* restore the authorization model ID (in case persistent VDB does not have correct value) */ zlssVol->vol.p.authModelID = holdAuthModelID; zASSERT( sizeof(*block) == ALIGN( sizeof( *block ), 4 )); - zASSERT( sizeof(LoggedPersistentVolume_s) == + zASSERT( sizeof(LoggedPersistentVolume_s) == ALIGN( sizeof( LoggedPersistentVolume_s ), 4 )); checksum = ZFSVOL_CalculateChecksum( (LONG *)block, sizeof(block->ZVD4K_Persistents)/4 ); @@ -1664,10 +1664,10 @@ STATUS ZFSVOL_ReadPersistentVolumeData( /* Upgrade to version 6 */ zlssVol->p.PZV_version = ZFSVOLUMEINFO_VERSION_6; zlssVol->p.PZV_lastRezidTime = 0; - bzero(zlssVol->p.PZV_reserved, - sizeof(zlssVol->p.PZV_reserved)); + bzero(zlssVol->p.PZV_reserved, + sizeof(zlssVol->p.PZV_reserved)); bzero(zlssVol->ZFSVOLvol.p.PV_reserved3, - sizeof(zlssVol->ZFSVOLvol.p.PV_reserved3)); + sizeof(zlssVol->ZFSVOLvol.p.PV_reserved3)); } if (zlssVol->p.PZV_version == ZFSVOLUMEINFO_VERSION_6) { @@ -1681,7 +1681,7 @@ STATUS ZFSVOL_ReadPersistentVolumeData( } cacheReleaseToss(buffer); - zASSERT(checksum == 0); + zASSERT(checksum == 0); zASSERT( zlssVol->p.PZV_magic == ZFSVOLUMEINFO_MAGIC ); @@ -1699,7 +1699,7 @@ STATUS ZFSVOL_ReadPersistentVolumeData( if(zlssVol->ZV_RepairFlags & ZV_REPAIRFLAGS_REBUILD_VOL_DATA_BLOCKS ) { /* init VDB here */ ZLSSVOL_InitVDB( zlssVol,INVALID_BLK ,INVALID_BLK ,INVALID_BLK , - GetUTCTime() , 1, GetUTCTime(), FALSE ); + GetUTCTime() , 1, GetUTCTime(), FALSE ); } goto ReadLoggedBlock; } @@ -1714,8 +1714,8 @@ STATUS ZFSVOL_ReadPersistentVolumeData( } } /* The volume data block checked out OK, so clear repair's - * flag. - */ + * flag. + */ zlssVol->ZV_RepairFlags &= ~ZV_REPAIRFLAGS_REBUILD_VOL_DATA_BLOCKS; ReadLoggedBlock: @@ -1734,8 +1734,8 @@ ReadLoggedBlock: } /* - * Read in the 'logged' volume data from its block. - */ + * Read in the 'logged' volume data from its block. + */ zASSERT( blkLVDB != 0 ); READBLK_IO_MSG(iomsg,zlssVol,blkLVDB,CACHE_READ); @@ -1753,7 +1753,7 @@ ReadLoggedBlock: ZLSSVOL_InitLVDB( zlssVol, zlssVol->ZFSVOLpool->storagepool->pooltotalblocks, 0, 0, FALSE ); zlssVol->ZFSVOLvol.v_restartCount = zlssVol->pool->ZFSPOOLvol.v_restartCount; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("\n ****** inited restartCount = 0x%lx\n"), zlssVol->ZFSVOLvol.v_restartCount); + DBG_DebugPrintf(LRED,MSGNot("\n ****** inited restartCount = 0x%lx\n"), zlssVol->ZFSVOLvol.v_restartCount); #endif } ClearErrno(genMsg); @@ -1787,7 +1787,7 @@ ReadLoggedBlock: ZLSSVOL_InitLVDB( zlssVol, zlssVol->ZFSVOLpool->storagepool->pooltotalblocks, 0, 0, FALSE ); zlssVol->ZFSVOLvol.v_restartCount = zlssVol->pool->ZFSPOOLvol.v_restartCount; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(LRED,MSGNot("\n ****** inited restartCount = 0x%lx\n"), zlssVol->ZFSVOLvol.v_restartCount); + DBG_DebugPrintf(LRED,MSGNot("\n ****** inited restartCount = 0x%lx\n"), zlssVol->ZFSVOLvol.v_restartCount); #endif } goto CleanUpAndReturn; @@ -1800,15 +1800,15 @@ ReadLoggedBlock: RTN_STATUS(zFAILURE); } /* The logged volume data block checked out OK, so clear repair's - * flag. - */ + * flag. + */ zlssVol->ZV_RepairFlags &= ~ZV_REPAIRFLAGS_REBUILD_VOL_LDATA_BLOCKS; CleanUpAndReturn: - /* Update item that are directly based on persistent items. - * These updates are done here verses ACTIVATE calls because - * rebuild does not call ACTIVATE functions. - */ + /* Update item that are directly based on persistent items. + * These updates are done here verses ACTIVATE calls because + * rebuild does not call ACTIVATE functions. + */ zlssVol->zv_bookedInUseBlocks = zlssVol->ZFSVOLinUseBlocks; DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, MSGNot("Number of objects and files in read persistent volume data %Ld, %Ld\n"), @@ -1829,9 +1829,9 @@ CleanUpAndReturn: zlssVol->vol.readAheadBlocks = zlssVol->p.PZV_readAheadBlocks; /* The OFFICIAL keeper of the persistent BT, VDB and LVDB - * is the Locator Beast (or superblock for ZfsPool_s) therefore - * reset the values back to what came in. - */ + * is the Locator Beast (or superblock for ZfsPool_s) therefore + * reset the values back to what came in. + */ zlssVol->p.PZV_systemBeastBlkNum = blkBT; zlssVol->p.PZV_volumeDataBlk = blkVDB; zlssVol->p.PZV_loggedVolumeDataBlk = blkLVDB; @@ -1919,8 +1919,8 @@ STATUS recoveryVDBUpdate( if (ZLOG_VALID_BLOCK(poolBlks[0])) { /* This MUST be a CACHE_UPDATE because we will be looking at - * the LSN in the block. - */ + * the LSN in the block. + */ READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_UPDATE) SET_DEBUG_ID(iomsg, 0); if ((buffer = ZFS_ReadPoolBlk(genMsg, &iomsg)) == NULL) @@ -2262,3 +2262,5 @@ STATUS ZFSVOL_PDBNDSObjectClear( } /* End of ZFSVOL_PDBNDSObjectClear() */ int Zfs4KVolumeBlock_s_size[0x1000 == sizeof(Zfs4KVolumeBlock_s) ? 1 : 0]; /* check that Zfs4KVolumeBlock_s in zfs.h really is 4k */ + + diff --git a/src/nwnss/zlss/zfsXTree.c b/src/nwnss/zlss/zfsXTree.c index a92a005..262fb82 100644 --- a/src/nwnss/zlss/zfsXTree.c +++ b/src/nwnss/zlss/zfsXTree.c @@ -68,8 +68,6 @@ #include "zfsSuperBlk.h" #include "purgeTree_if.h" -extern int abs(int); - /*- entry/exit flag for verify -*/ #define FXVERIFYENTER 10 #define FXVERIFYEXIT 20 @@ -159,7 +157,7 @@ STATUS FT_MagicCheck(GeneralMsg_s *genMsg, Buffer_s *buffer, IoMsg_s *iomsg) * in size (the first one starting at the seed blk), or if not available * then the largest contiguous chunk that is available. * - * If there is no free space it will return zero, and the calling + * If there is no free space it will return zero, and the calling * routine will process it like a seed of zero. * * We do not keep the tree locked, so the extent we find may be used @@ -182,7 +180,7 @@ Blknum_t FT_FindContiguousBlocks( xNode_s *child; NINT index; Extent_s largestExtent = {0}; - Blknum_t currentSeed; + Blknum_t currentSeed; Blknum_t nextSeed = 0; ASSERT_MPKNSS_LOCK(); @@ -194,13 +192,13 @@ Blknum_t FT_FindContiguousBlocks( currentSeed = nextSeed; /*- get an exclusive latch on xtree -*/ - S_LATCH(&xtree->ZFSFXbeastLatch); + S_LATCH(&xtree->ZFSFXbeastLatch); childBlk = xtree->zfsBtree.p.btRoot; /*- check for root of btree -*/ if(childBlk == INVALID_BLK) { - UNS_LATCH(&xtree->ZFSFXbeastLatch); + UNS_LATCH(&xtree->ZFSFXbeastLatch); /* Let someone else deal with the error */ break; } @@ -208,11 +206,11 @@ Blknum_t FT_FindContiguousBlocks( READBLK_IO_MSG(iomsg, xtree, childBlk, CACHE_READ); if ((childBuffer = ZFS_ReadPoolBlk(&genMsg, &iomsg)) == NULL) { - UNS_LATCH(&xtree->ZFSFXbeastLatch); + UNS_LATCH(&xtree->ZFSFXbeastLatch); /* Let someone else deal with the error */ break; } - UNS_LATCH(&xtree->ZFSFXbeastLatch); + UNS_LATCH(&xtree->ZFSFXbeastLatch); child = (xNode_s *)childBuffer->pBuf.data; @@ -222,14 +220,14 @@ Blknum_t FT_FindContiguousBlocks( { childBlk = findIndexInXBranch(child, currentSeed, &index); /* If we are not the last entry in a node, keep track of the - * next seed as we traverse down the tree - * If it is the last entry in the node, use the seed from the - * parent as the next seed, ie don't change next seed. - * If we are the root, then we don't have a parent seed, so - * set it to zero. - * Setting the seed to zero, implies, that we have finished - * processing all the leaves in the free tree. - */ + * next seed as we traverse down the tree + * If it is the last entry in the node, use the seed from the + * parent as the next seed, ie don't change next seed. + * If we are the root, then we don't have a parent seed, so + * set it to zero. + * Setting the seed to zero, implies, that we have finished + * processing all the leaves in the free tree. + */ if (index < (child->header.numRecs - 1)) { nextSeed = child->BRA[index+1].start; @@ -289,13 +287,13 @@ exit: compared. By using this routine you do not have to worry that extent->poolBlkNum + extent->lengthOfExtent may be negative. */ -static inline Blknum_t FT_LastBlock( const Extent_s *extent ) +inline Blknum_t FT_LastBlock( const Extent_s *extent ) { return extent->poolBlkNum + extent->lengthOfExtent - 1; } -/* +/* FT_IsSubsetOf - Determines if one extent is completely within another. @@ -303,7 +301,7 @@ static inline Blknum_t FT_LastBlock( const Extent_s *extent ) TRUE if 'subsetExtent' is a subset of 'setExtent'. */ -static inline BOOL FT_IsSubsetOf( +inline BOOL FT_IsSubsetOf( const Extent_s *subsetExtent, /* poolBlkNum can be 0x80000000 */ const Extent_s *setExtent ) { @@ -317,14 +315,14 @@ static inline BOOL FT_IsSubsetOf( } -/* +/* FT_IsIntersect - Determines if two extents share any of the same blocks. Returns - TRUE if the two extents intersect each other. */ -static inline BOOL FT_IsIntersect( const Extent_s *e1, const Extent_s *e2 ) +inline BOOL FT_IsIntersect( const Extent_s *e1, const Extent_s *e2 ) { if ( (e1->poolBlkNum > e2->poolBlkNum) && (e1->poolBlkNum > FT_LastBlock( e2 )) ) { @@ -349,7 +347,7 @@ static inline BOOL FT_IsIntersect( const Extent_s *e1, const Extent_s *e2 ) Else the extent from the free tree did not have a large enough area that was considered free from a transaction system point of view. - Note - + Note - Based on XACT_blksNotOnFreeList code. We do not use XACT_blksNotOnFreeList because we need to make a educated guess as to the next blocks to check that are free. @@ -394,18 +392,18 @@ static BOOL XACT_FindFreeAreaWithinNodeExtent( if ( unlikely(FT_IsIntersect( ¬FreeChunk->freeExt, &tryExtent )) ) { intersect = TRUE; /* The next line is an optimization that allows us to - skip other 'tryExtent' that would intersect with this - same notFreeChunk. For example, a 'notFreeChunk' that - describes one million blocks will invalidate many - 'tryExtents'. So we just skip to the end of the - 'notFreeChunk'. */ + skip other 'tryExtent' that would intersect with this + same notFreeChunk. For example, a 'notFreeChunk' that + describes one million blocks will invalidate many + 'tryExtents'. So we just skip to the end of the + 'notFreeChunk'. */ nextGuess = FT_LastBlock( ¬FreeChunk->freeExt ); /* Note that there could be 2+ notFreeChunks that intersect - our current 'tryExtent'. We make no attempt to locate them - on this 'tryExtent', but instead will find them if they - effect our next 'tryExtent'. They may not effect the - next 'tryExtent' because the other 'notFreeChunk' may - describe blocks less than the current 'notFreeChunk'. */ + our current 'tryExtent'. We make no attempt to locate them + on this 'tryExtent', but instead will find them if they + effect our next 'tryExtent'. They may not effect the + next 'tryExtent' because the other 'notFreeChunk' may + describe blocks less than the current 'notFreeChunk'. */ #if FREE_DATA_STATS IS_ENABLED UserFreeStats.FUDBS_PartNotFree++; #endif @@ -440,7 +438,7 @@ static BOOL XACT_FindFreeAreaWithinNodeExtent( The free extent will be the same size as the request size. The free extent first block >= the request's first block. The extent will consist of the nearest free blocks to the request. - + Returns zOK - Found enough free contiguous blocks. The extent returned has NOT been allocated for the caller. @@ -529,7 +527,7 @@ NINT FT_AreaSizeDefault = (1 << 5); // TODO(Perf): Some code assumes a p // TODO(Perf,now): What should the real values of FT_TooClose and FT_TooCloseBuffer be? Blknum_t FT_TooClose = 100*1024; /* Metadata seed and user data seeds minimum - distance from each other. */ + distance from each other. */ Blknum_t FT_TooCloseBuffer = 20*1024; #if 0 @@ -588,7 +586,7 @@ Blknum_t FT_FindBlockInNewArea( GeneralMsg_s *genMsg, ZfsPool_s *zfsPool ) NINT index; Extent_s request; Extent_s extentToAllocate; - Blknum_t currentSeed; + Blknum_t currentSeed; Blknum_t nextSeed; BOOL wrapped; BOOL haveBranches; @@ -596,11 +594,11 @@ Blknum_t FT_FindBlockInNewArea( GeneralMsg_s *genMsg, ZfsPool_s *zfsPool ) NINT searchAll; /* I see no reason for numerous threads to be racing each other - * to find the next area. Let one of them find it and use it. - * That way the seed will be that much closer to the next area. - * In addition, we then do not need to worry about 2+ threads - * finding the 'same' area. - */ + * to find the next area. Let one of them find it and use it. + * That way the seed will be that much closer to the next area. + * In addition, we then do not need to worry about 2+ threads + * finding the 'same' area. + */ X_LATCH( &xtree->ZFE_AreaLatch ); ++xtree->ZFE_AreaSeed; if ( xtree->ZFE_AreaSeed >= zlssPool->ZLSSPOOLtotalBlocks ) { @@ -612,8 +610,8 @@ Blknum_t FT_FindBlockInNewArea( GeneralMsg_s *genMsg, ZfsPool_s *zfsPool ) if ( FT_AvailableBlocksInPool(zlssPool) >= xtree->ZFE_GrowAreaSize ) { /* Free blocks has increased enough to try default again. */ printk(KERN_INFO "NSS: Increasing area size from %d to %d\n", - xtree->ZFE_AreaSizeCurrent, - xtree->ZFE_AreaSizeDefault ); + xtree->ZFE_AreaSizeCurrent, + xtree->ZFE_AreaSizeDefault ); xtree->ZFE_AreaSizeCurrent = xtree->ZFE_AreaSizeDefault; } } @@ -625,58 +623,58 @@ Blknum_t FT_FindBlockInNewArea( GeneralMsg_s *genMsg, ZfsPool_s *zfsPool ) haveBranches = FALSE; nextSeed = 0; request.lengthOfExtent = xtree->ZFE_AreaSizeCurrent; - for(;;) { - S_LATCH(&xtree->ZFSFXbeastLatch); - childBlk = xtree->zfsBtree.p.btRoot; - if(childBlk == INVALID_BLK) { - UNS_LATCH(&xtree->ZFSFXbeastLatch); + for(;;) { + S_LATCH(&xtree->ZFSFXbeastLatch); + childBlk = xtree->zfsBtree.p.btRoot; + if(childBlk == INVALID_BLK) { + UNS_LATCH(&xtree->ZFSFXbeastLatch); SetErrno( genMsg, zERR_INVALID_BLOCK ); - goto errorExit; - } - READBLK_IO_MSG(iomsg, xtree, childBlk, CACHE_READ); - if ((childBuffer = ZFS_ReadPoolBlk(genMsg, &iomsg)) == NULL) { - UNS_LATCH(&xtree->ZFSFXbeastLatch); - goto errorExit; - } - UNS_LATCH(&xtree->ZFSFXbeastLatch); - child = (xNode_s *)childBuffer->pBuf.data; - zASSERT(child->header.state & FXBT_ROOT); - while (!(child->header.state & FXBT_LEAF)) { /* Descend branches */ - haveBranches = TRUE; - childBlk = findIndexInXBranch(child, currentSeed, &index); - if (index < (child->header.numRecs - 1)) { - nextSeed = child->BRA[index+1].start; - } else if (child->header.state & FXBT_ROOT) { - nextSeed = 0; - } - parentBuffer = childBuffer; - READBLK_IO_MSG(iomsg, xtree, childBlk, CACHE_READ); - if ((childBuffer = ZFS_ReadPoolBlk(genMsg, &iomsg)) == NULL) { - CACHE_RELEASE(parentBuffer); - goto errorExit; - } - CACHE_RELEASE(parentBuffer); - child = (xNode_s *)childBuffer->pBuf.data; - } - zASSERT(child->header.state & FXBT_LEAF); - request.poolBlkNum = currentSeed; + goto errorExit; + } + READBLK_IO_MSG(iomsg, xtree, childBlk, CACHE_READ); + if ((childBuffer = ZFS_ReadPoolBlk(genMsg, &iomsg)) == NULL) { + UNS_LATCH(&xtree->ZFSFXbeastLatch); + goto errorExit; + } + UNS_LATCH(&xtree->ZFSFXbeastLatch); + child = (xNode_s *)childBuffer->pBuf.data; + zASSERT(child->header.state & FXBT_ROOT); + while (!(child->header.state & FXBT_LEAF)) { /* Descend branches */ + haveBranches = TRUE; + childBlk = findIndexInXBranch(child, currentSeed, &index); + if (index < (child->header.numRecs - 1)) { + nextSeed = child->BRA[index+1].start; + } else if (child->header.state & FXBT_ROOT) { + nextSeed = 0; + } + parentBuffer = childBuffer; + READBLK_IO_MSG(iomsg, xtree, childBlk, CACHE_READ); + if ((childBuffer = ZFS_ReadPoolBlk(genMsg, &iomsg)) == NULL) { + CACHE_RELEASE(parentBuffer); + goto errorExit; + } + CACHE_RELEASE(parentBuffer); + child = (xNode_s *)childBuffer->pBuf.data; + } + zASSERT(child->header.state & FXBT_LEAF); + request.poolBlkNum = currentSeed; searchAll = 1; - status = FT_FindMatchHigher( zfsPool, child, &request, + status = FT_FindMatchHigher( zfsPool, child, &request, xtree->ZFE_AreaSizeCurrent, &extentToAllocate, &searchAll ); - if ( status == zOK ) { + if ( status == zOK ) { /*** Normal Exit Path ***/ - CACHE_RELEASE(childBuffer); - xtree->ZFE_AreaSeed = FT_LastBlock( &extentToAllocate ); + CACHE_RELEASE(childBuffer); + xtree->ZFE_AreaSeed = FT_LastBlock( &extentToAllocate ); // printk("<3>NewA %lx\n",xtree->ZFE_AreaSeed); - UNX_LATCH( &xtree->ZFE_AreaLatch ); - return extentToAllocate.poolBlkNum; - } - CACHE_RELEASE(childBuffer); - if ( !haveBranches ) { - break; /* No area big enough */ - } - if (nextSeed == 0) { + UNX_LATCH( &xtree->ZFE_AreaLatch ); + return extentToAllocate.poolBlkNum; + } + CACHE_RELEASE(childBuffer); + if ( !haveBranches ) { + break; /* No area big enough */ + } + if (nextSeed == 0) { /* Defect 283631 (June 2007) nextseed does not ever have to be > ZFS_AreaSeed so we must check for a previous wrap. Before this code @@ -685,23 +683,23 @@ Blknum_t FT_FindBlockInNewArea( GeneralMsg_s *genMsg, ZfsPool_s *zfsPool ) if ( wrapped ) { break; } - wrapped = TRUE; - } - if ( wrapped && (nextSeed > xtree->ZFE_AreaSeed) ) { - break; /* No area big enough */ - } - currentSeed = nextSeed; + wrapped = TRUE; + } + if ( wrapped && (nextSeed > xtree->ZFE_AreaSeed) ) { + break; /* No area big enough */ + } + currentSeed = nextSeed; } /* We will set grow point to 200MB bigger than current free blocks - * on the pool. This greatly over-simplfies when to increase the - * area size, but there is no time now for better logic. - */ + * on the pool. This greatly over-simplfies when to increase the + * area size, but there is no time now for better logic. + */ /* TODO(Perf,now) - Is this good enough for FCS? */ xtree->ZFE_GrowAreaSize = FT_AvailableBlocksInPool(zlssPool) + 65536; printk(KERN_INFO "NSS: Decreasing area size from %d to %d. Will increase when %lld blocks free.\n", - xtree->ZFE_AreaSizeCurrent, - xtree->ZFE_AreaSizeCurrent >> 1, - xtree->ZFE_GrowAreaSize ); + xtree->ZFE_AreaSizeCurrent, + xtree->ZFE_AreaSizeCurrent >> 1, + xtree->ZFE_GrowAreaSize ); #if 0 /* We can now ~correctly count this area size. Note that even though we init to 0 we may already have some of these area size @@ -742,9 +740,9 @@ STATUS zfsAllocExtent( GeneralMsg_s *genMsg, ZfsVolume_s *zfsVol, Extent_s *request, - NINT allocFlags, /* If XTREE_SYSTEM_REQUEST then - * allocate blocks from the reserve area - * during disk full condition */ + NINT allocFlags, /* If XTREE_SYSTEM_REQUEST then + * allocate blocks from the reserve area + * during disk full condition */ ZfsXaction_s *xaction) { ZioTh_s zio; @@ -782,7 +780,7 @@ STATUS zfsAllocExtent( //zASSERT("Generated out-of-space error"==0); aprintf(YELLOW,MSGNot("Generated out-of-space error %d\n"),++outOfSpaceCount); ForceSetErrno(genMsg,zERR_OUT_OF_SPACE); - if ((GenerateOutOfDiskSpaceErrorsBreakCount != 0) && + if ((GenerateOutOfDiskSpaceErrorsBreakCount != 0) && (GenerateOutOfDiskSpaceErrorsBreakCount == outOfSpaceCount)) { GenerateOutOfDiskSpaceErrorsBreakCount = 0; @@ -794,28 +792,28 @@ STATUS zfsAllocExtent( #endif /** - * We check if the pool has salvageable blocks. If so then we - * ask the pool to purge enough blocks to ensure that the - * allocation will work. This is done ASYNC from the current - * thread. - */ + * We check if the pool has salvageable blocks. If so then we + * ask the pool to purge enough blocks to ensure that the + * allocation will work. This is done ASYNC from the current + * thread. + */ /* Also checking numdeleted files because if all you have if 0 byte - * deleted files then purgeable blocks will be zero but we still need - * to purge. A test was creating 0 byte files and putting EAs on it - * and the EA data is not being accounted for by purgeableBlock count - */ + * deleted files then purgeable blocks will be zero but we still need + * to purge. A test was creating 0 byte files and putting EAs on it + * and the EA data is not being accounted for by purgeableBlock count + */ if ((zlssPool->ZLSSPOOLpurgeableBlocks > 0) || (zfsVol->ZFSVOLvol.VOLnumDeletedFiles > 0)) { /* Do a little performance check first */ - if (zlssPool->ZP_BlocksToSalvage <= 0) + if (zlssPool->ZP_BlocksToSalvage <= 0) { /* Thread is NOT already running */ - /* Start asynchronously purging files to make free space */ - if (ZLSSPOOL_VOL_MakeVolumeFreeSpace(genMsg, zlssPool, FALSE, TRUE, - request->lengthOfExtent) != zOK) - { - /* Ignore the result */ - ClearErrno(genMsg); - } + /* Start asynchronously purging files to make free space */ + if (ZLSSPOOL_VOL_MakeVolumeFreeSpace(genMsg, zlssPool, FALSE, TRUE, + request->lengthOfExtent) != zOK) + { + /* Ignore the result */ + ClearErrno(genMsg); + } } else { @@ -826,33 +824,33 @@ STATUS zfsAllocExtent( -// undeleteBlocksPOOL = zlssPool->ZLSSPOOLbookedInUseBlocks - -// (zlssPool->ZLSSPOOLpurgeableBlocks + +// undeleteBlocksPOOL = zlssPool->ZLSSPOOLbookedInUseBlocks - +// (zlssPool->ZLSSPOOLpurgeableBlocks + // zlssPool->ZLSSPOOLnonPurgeableBlocks); /* Pool available blocks are blocks that we know are allocateable - * from the free tree this very moment. - */ + * from the free tree this very moment. + */ availBlocksPOOL = FT_AvailableBlocksInPool(zlssPool); /* Pool potential blocks are blocks that could be made allocateable - * in a 'few' moments. I.E. purgeable blocks could be freed - * by purge thread we started above. And the ZP_UnusableFreeBlkCnt - * blocks will be made available when the transaction that - * holds them does a EndXLocal. - */ + * in a 'few' moments. I.E. purgeable blocks could be freed + * by purge thread we started above. And the ZP_UnusableFreeBlkCnt + * blocks will be made available when the transaction that + * holds them does a EndXLocal. + */ potentialBlocksPOOL = availBlocksPOOL + zlssPool->ZLSSPOOLpurgeableBlocks + zlssPool->ZP_UnusableFreeBlkCnt; /* Blocks that are in files that are not deleted (this - * includes system blocks). - */ + * includes system blocks). + */ inUseNoDeletedBlocksVOL = zfsVol->ZFSVOLbookedInUseBlocks - (zfsVol->ZFSVOLpurgeableBlocks + - zfsVol->ZFSVOLvol.VOLnonPurgeableBlocks ); + zfsVol->ZFSVOLvol.VOLnonPurgeableBlocks ); /* Volume available blocks is the volume quota that is left. The - * volume quota is NOT charged for blocks in purgeable or non- - * purgeable files. - */ + * volume quota is NOT charged for blocks in purgeable or non- + * purgeable files. + */ availBlocksVOL = zfsVol->ZFSVOLtotalBlocks - inUseNoDeletedBlocksVOL; /* Since availBlocksVOL is the total space 'free' potential */ potentialBlocksVOL = availBlocksVOL; @@ -875,16 +873,16 @@ STATUS zfsAllocExtent( //#endif /* - * FixFixFix9 - Should not let the fact that we are doing ALLOC - * ahead cause a OUT OF DISK alert to be sent to all users. - * - * This can show OUT OF SPACE alerts when there is enough to service - * the real request but not enough to service the real + alloc ahead. - * At this point nothing can be done to prevent this message. We can - * say that the ZFS_RESERVED_BLOCKS_FOR_INTERNAL_ALLOCATION just has a - * few more blocks than the define shows. If we are this close to being - * out of space then 'Just Do It'. - */ + * FixFixFix9 - Should not let the fact that we are doing ALLOC + * ahead cause a OUT OF DISK alert to be sent to all users. + * + * This can show OUT OF SPACE alerts when there is enough to service + * the real request but not enough to service the real + alloc ahead. + * At this point nothing can be done to prevent this message. We can + * say that the ZFS_RESERVED_BLOCKS_FOR_INTERNAL_ALLOCATION just has a + * few more blocks than the define shows. If we are this close to being + * out of space then 'Just Do It'. + */ if ( !(zfspool->ZFSPOOLrepairFlags & ZP_REPAIRFLAGS_NO_LOGGING_ALLOWED) ) { @@ -893,33 +891,33 @@ STATUS zfsAllocExtent( request->lengthOfExtent); } /* FixFixFix(LV,ACI,11) maybe a low space for VOL and POOL verses - * volume based on volume and pool. User will be confussed on - * pool low maybe a better message if pool causing volume problems? - */ + * volume based on volume and pool. User will be confussed on + * pool low maybe a better message if pool causing volume problems? + */ /* - * Make sure that we have enough space reserved for internal needs. We do - * not want to get an error allocating during recovery, or other file - * system needs. - */ - if ( availBlocksMIN < (ZFS_RESERVED_BLOCKS_FOR_INTERNAL_ALLOCATION + - request->lengthOfExtent) ) + * Make sure that we have enough space reserved for internal needs. We do + * not want to get an error allocating during recovery, or other file + * system needs. + */ + if ( availBlocksMIN < (ZFS_RESERVED_BLOCKS_FOR_INTERNAL_ALLOCATION + + request->lengthOfExtent) ) { /* - * If the pool/volume is still coming up then let it have the - * reserved space, otherwise check to see if it is a system - * request. - */ + * If the pool/volume is still coming up then let it have the + * reserved space, otherwise check to see if it is a system + * request. + */ if (zfsVol->ZFSVOLstate == zVOLSTATE_ACTIVE) - { + { if ( !(allocFlags & XTREE_SYSTEM_REQUEST)) { /* For user blocks we return an error simply based on - * the fact that we do not have available blocks at - * this moment. The caller will check for the - * specific error zERR_PURGED_SPACE_UNAVAILABLE and - * call back a little later. This is NOT done here - * because the caller may own too many important - * resources(i.e. Latches). - */ + * the fact that we do not have available blocks at + * this moment. The caller will check for the + * specific error zERR_PURGED_SPACE_UNAVAILABLE and + * call back a little later. This is NOT done here + * because the caller may own too many important + * resources(i.e. Latches). + */ if (potentialBlocksMIN < (request->lengthOfExtent + ZFS_RESERVED_BLOCKS_FOR_INTERNAL_ALLOCATION )) { @@ -933,7 +931,7 @@ STATUS zfsAllocExtent( } } } - + /*- Book the space taken now, this prevents overbooking while we look up -*/ zlssPool->ZLSSPOOLbookedInUseBlocks += request->lengthOfExtent; zfsVol->ZFSVOLbookedInUseBlocks += request->lengthOfExtent; @@ -941,7 +939,7 @@ STATUS zfsAllocExtent( if ( allocFlags & XTREE_CONTIGUOUS_BLKS) { - request->poolBlkNum = FT_FindContiguousBlocks( + request->poolBlkNum = FT_FindContiguousBlocks( zfspool, request->lengthOfExtent ); } @@ -959,7 +957,7 @@ STATUS zfsAllocExtent( zfspool->freeExtent->freeTreeSeed = 0; } request->poolBlkNum = zfspool->freeExtent->freeTreeSeed; - zfspool->freeExtent->freeTreeSeed = + zfspool->freeExtent->freeTreeSeed = request->poolBlkNum + request->lengthOfExtent; requestedSeedZero = TRUE; #if 0 @@ -1048,26 +1046,26 @@ newArea: genMsgError: if (zfspool->freeExtent->freeTreeSeed == zio.extent.poolBlkNum) { - zfspool->freeExtent->freeTreeSeed = + zfspool->freeExtent->freeTreeSeed = zio.extent.poolBlkNum + zio.extent.lengthOfExtent; if ( abs(zfspool->freeExtent->freeTreeSeed - zfspool->freeExtent->ZFE_AreaSeed) < FT_TooClose ) { - /* The FT_TooCloseBuffer is just an extra buffer to prevent - * rapid movement in ZFE_AreaSeed from consistently pushing - * freeTreeSeed. */ + /* The FT_TooCloseBuffer is just an extra buffer to prevent + * rapid movement in ZFE_AreaSeed from consistently pushing + * freeTreeSeed. */ zfspool->freeExtent->freeTreeSeed = zfspool->freeExtent->ZFE_AreaSeed + FT_TooClose + FT_TooCloseBuffer; // printk("<3> Global Seed was too close after seed match move %lx\n",zfspool->freeExtent->freeTreeSeed); } } else if (requestedSeedZero) { - if (zfspool->freeExtent->freeTreeSeed < + if (zfspool->freeExtent->freeTreeSeed < (zio.extent.poolBlkNum + zio.extent.lengthOfExtent)) { - zfspool->freeExtent->freeTreeSeed = + zfspool->freeExtent->freeTreeSeed = zio.extent.poolBlkNum + zio.extent.lengthOfExtent; // printk("<3> New Global Seed %lx\n",zfspool->freeExtent->freeTreeSeed); } if ( abs(zfspool->freeExtent->freeTreeSeed - zfspool->freeExtent->ZFE_AreaSeed) < FT_TooClose ) { - /* The FT_TooCloseBuffer is just an extra buffer to prevent - * rapid movement in ZFE_AreaSeed from consistently pushing - * freeTreeSeed. */ + /* The FT_TooCloseBuffer is just an extra buffer to prevent + * rapid movement in ZFE_AreaSeed from consistently pushing + * freeTreeSeed. */ zfspool->freeExtent->freeTreeSeed = zfspool->freeExtent->ZFE_AreaSeed + FT_TooClose + FT_TooCloseBuffer; // printk("<3> Global Seed was too close %lx\n",zfspool->freeExtent->freeTreeSeed); } @@ -1097,7 +1095,7 @@ genMsgError: request->lengthOfExtent = zio.extent.lengthOfExtent; // printk("<3> Allocated %lx for %lx\n", zio.extent.poolBlkNum, zio.extent.lengthOfExtent ); zASSERT((cCode != zOK) || (zio.extent.lengthOfExtent != 0)); - + DEBUG_PRINTF(TZFREETREE,DBG_BOTH,(YELLOW,MSGNot("Allocating Extent %u(%u) free space(%u)\n"), request->poolBlkNum,request->lengthOfExtent, (zfspool->ZFSPOOLtotalBlocks - zfspool->ZFSPOOLinUseBlocks))); @@ -1215,9 +1213,9 @@ STATUS zfsFreeExtent( delta += zio.extent.lengthOfExtent; - zio.extent.poolBlkNum = request->poolBlkNum + + zio.extent.poolBlkNum = request->poolBlkNum + zio.extent.lengthOfExtent; - zio.extent.lengthOfExtent = request->lengthOfExtent - + zio.extent.lengthOfExtent = request->lengthOfExtent - zio.extent.lengthOfExtent; request->lengthOfExtent = zio.extent.lengthOfExtent; request->poolBlkNum = zio.extent.poolBlkNum; @@ -1294,9 +1292,9 @@ STATUS zfsFreePoolExtent( } delta += zio.extent.lengthOfExtent; - zio.extent.poolBlkNum = request->poolBlkNum + + zio.extent.poolBlkNum = request->poolBlkNum + zio.extent.lengthOfExtent; - zio.extent.lengthOfExtent = request->lengthOfExtent - + zio.extent.lengthOfExtent = request->lengthOfExtent - zio.extent.lengthOfExtent; request->lengthOfExtent = zio.extent.lengthOfExtent; request->poolBlkNum = zio.extent.poolBlkNum; @@ -1363,7 +1361,7 @@ STATUS InitRootNode( /*- (FUNCTION) ----- InitSpecialNode() ----------------------------------------- | - | initialize the free extent special node + | initialize the free extent special node | +-------------------------------------------------------------------------*/ STATUS InitSpecialNode( @@ -1404,7 +1402,7 @@ STATUS InitSpecialNode( /*- (FUNCTION) ----- Add2BlksToSpecialNode() ------------------------------- | - | add 2 blks to the free extent special node + | add 2 blks to the free extent special node | +-------------------------------------------------------------------------*/ STATUS Add2BlksToSpecialNode( @@ -1543,11 +1541,11 @@ STATUS findIndexInXLeaf( { if(scanblk <= (rec->poolBlkNum + rec->lengthOfExtent)) break; - + if((start = mid + 1) >= max) break; } - else + else { if((mid == start) && (mid == end)) { @@ -1630,7 +1628,7 @@ STATUS findLengthMatch( return(zOK); } - if (node->EXT[icurrent].lengthOfExtent > + if (node->EXT[icurrent].lengthOfExtent > node->EXT[largest].lengthOfExtent) { largest = icurrent; @@ -1648,7 +1646,7 @@ STATUS findLengthMatch( return(zOK); } - if (node->EXT[icurrent].lengthOfExtent > + if (node->EXT[icurrent].lengthOfExtent > node->EXT[largest].lengthOfExtent) { largest = icurrent; @@ -1656,9 +1654,9 @@ STATUS findLengthMatch( } /* None of the free extents are big enough for request. We - * will return the largest extent. If the largest extent - * length is 0 then we return a failure. - */ + * will return the largest extent. If the largest extent + * length is 0 then we return a failure. + */ if (node->EXT[largest].lengthOfExtent == 0) { *ret_index = 1; @@ -1666,8 +1664,8 @@ STATUS findLengthMatch( } /** Make sure the blocks on the largest chunk available are not on the - ** hold blocks lists - **/ + ** hold blocks lists + **/ if (!(BLKS_CAN_BE_ALLOCATED(pool, &node->EXT[largest], &extent))) { #if FREE_DATA_STATS IS_ENABLED @@ -1677,7 +1675,7 @@ STATUS findLengthMatch( largest = 0; for (icurrent = 1; icurrent < max; icurrent++) { - if ((node->EXT[icurrent].lengthOfExtent > + if ((node->EXT[icurrent].lengthOfExtent > node->EXT[largest].lengthOfExtent) && (BLKS_CAN_BE_ALLOCATED(pool, &node->EXT[icurrent], &extent))) { @@ -1690,7 +1688,7 @@ STATUS findLengthMatch( ** be removed from the unusable list. **/ if (node->EXT[largest].lengthOfExtent == 0) - { + { *ret_index = 1; return(zFAILURE); } @@ -1704,7 +1702,7 @@ STATUS findLengthMatch( /********************************************************************* - * Find a block in the area that is available to be allocated. + * Find a block in the area that is available to be allocated. ********************************************************************/ STATUS findNearMatchInArea( ZfsPool_s *pool, @@ -1728,7 +1726,7 @@ STATUS findNearMatchInArea( while (inext < node->header.numRecs) { i = (seedBlock > node->EXT[inext].poolBlkNum) ? - (seedBlock - node->EXT[inext].poolBlkNum) : 0; + (seedBlock - node->EXT[inext].poolBlkNum) : 0; for (; i < node->EXT[inext].lengthOfExtent; i++) { @@ -1737,7 +1735,7 @@ STATUS findNearMatchInArea( { continue; } - if (FIRST_BLOCK_IN_AREA(nextBlock, areaSize) != + if (FIRST_BLOCK_IN_AREA(nextBlock, areaSize) != FIRST_BLOCK_IN_AREA(seedBlock, areaSize)) { nextBlock = INVALID_BLK; @@ -1757,7 +1755,7 @@ doneNextBlock: while (iprev >= 0) { i = (seedBlock < FT_LastBlock(&node->EXT[iprev])) ? - (FT_LastBlock(&node->EXT[iprev]) - seedBlock) : 0; + (FT_LastBlock(&node->EXT[iprev]) - seedBlock) : 0; for (; i < node->EXT[iprev].lengthOfExtent; i++) { @@ -1766,7 +1764,7 @@ doneNextBlock: { continue; } - if (FIRST_BLOCK_IN_AREA(prevBlock, areaSize) != + if (FIRST_BLOCK_IN_AREA(prevBlock, areaSize) != FIRST_BLOCK_IN_AREA(seedBlock, areaSize)) { prevBlock = INVALID_BLK; @@ -1861,7 +1859,7 @@ void insertZeroXNode(xNode_s *node) /*- this avoids a lot of special case code for record zero -*/ node->header.numRecs = 1; - + if(FXBT_IS_LEAF(node)) { node->EXT[0].lengthOfExtent = 0; @@ -1878,7 +1876,7 @@ void insertZeroXNode(xNode_s *node) //TODO(Perf): If we use simple area size increase logic then remove this if 0 code -/* +/* FT_GetAreasWithinExtent() - Calculate the number of full areas within the specified extent. @@ -1930,7 +1928,7 @@ static inline Blknum_t FT_GetAreasWithinExtent( #endif -/* +/* FT_AreaSizeUpdate() - Given an old extent from the free tree and the new one this routine will update the estimate of how many areas of specific @@ -1988,11 +1986,11 @@ void insertExtent(ZioTh_s *zio) #if NSS_DEBUG IS_ENABLED VerifyFXnode(node, FXVERIFYENTER); - + DEBUG_PRINTF(TZFREETREE,DBG_BOTH,(YELLOW,MSGNot("raw free extent free: %u(%u)\n"), EXTENTblk, EXTENTlen)); #endif - + /*- scan extents to find insert location -*/ if(findIndexInXLeaf(node, EXTENTblk, &scancnt) == zOK) { @@ -2028,7 +2026,7 @@ void insertExtent(ZioTh_s *zio) insertaction = FXBT_MERGELEFT; - /*- check to merge right after left merge -*/ + /*- check to merge right after left merge -*/ if((rightext->lengthOfExtent != NULL) && ((leftext->poolBlkNum + leftext->lengthOfExtent) == rightext->poolBlkNum)) { @@ -2037,8 +2035,8 @@ void insertExtent(ZioTh_s *zio) /*- shift all records to left and set last record to default -*/ memmove(&node->EXT[scancnt], /*- destination -*/ - &node->EXT[scancnt + 1], /*- source -*/ - (node->header.numRecs - (scancnt + 1)) * sizeof(Extent_s)); + &node->EXT[scancnt + 1], /*- source -*/ + (node->header.numRecs - (scancnt + 1)) * sizeof(Extent_s)); /*- remove last record -*/ node->EXT[node->header.numRecs - 1].poolBlkNum = 0; @@ -2069,14 +2067,14 @@ void insertExtent(ZioTh_s *zio) { /*- bump the scan count to point to the next record -*/ scancnt++; - + /*- check if over the max -*/ if(scancnt < FXBT_MAXEXTENTS) { /*- setup new node extent -*/ rightext = &node->EXT[scancnt]; leftext = &node->EXT[scancnt - 1]; - + /*- log the record index -*/ logdata.extindex = scancnt; @@ -2095,7 +2093,7 @@ void insertExtent(ZioTh_s *zio) insertaction = FXBT_MERGELEFT; - /*- check to merge right after left merge -*/ + /*- check to merge right after left merge -*/ if((rightext->lengthOfExtent != NULL) && ((leftext->poolBlkNum + leftext->lengthOfExtent) == rightext->poolBlkNum)) { @@ -2104,8 +2102,8 @@ void insertExtent(ZioTh_s *zio) /*- shift all records to left and set last record to default -*/ memmove(&node->EXT[scancnt], /*- destination -*/ - &node->EXT[scancnt + 1], /*- source -*/ - (node->header.numRecs - (scancnt + 1)) * sizeof(Extent_s)); + &node->EXT[scancnt + 1], /*- source -*/ + (node->header.numRecs - (scancnt + 1)) * sizeof(Extent_s)); /*- remove last record -*/ node->EXT[node->header.numRecs - 1].poolBlkNum = 0; @@ -2119,10 +2117,10 @@ void insertExtent(ZioTh_s *zio) } else { - + /*- no merge so insert between -*/ - + /*- check if current record is null -*/ if(rightext->lengthOfExtent != NULL) { @@ -2138,8 +2136,8 @@ void insertExtent(ZioTh_s *zio) /*- shift all records to right and insert new record -*/ memmove(&node->EXT[scancnt + 1], /*- destination -*/ - &node->EXT[scancnt], /*- source -*/ - (node->header.numRecs - scancnt) * sizeof(Extent_s)); + &node->EXT[scancnt], /*- source -*/ + (node->header.numRecs - scancnt) * sizeof(Extent_s)); /*- insert new extent -*/ node->EXT[scancnt].poolBlkNum = EXTENTblk; @@ -2154,7 +2152,7 @@ void insertExtent(ZioTh_s *zio) else { /*- record null, just use current -*/ - + /*- insert new extent -*/ rightext->poolBlkNum = EXTENTblk; rightext->lengthOfExtent = EXTENTlen; @@ -2182,7 +2180,7 @@ void insertExtent(ZioTh_s *zio) // FT_AreaSizeUpdate(); logdata.newnumRecs = node->header.numRecs; - + FT_ValidateNode( XTREEchild, scancnt ); /*- log the change -*/ @@ -2190,14 +2188,14 @@ void insertExtent(ZioTh_s *zio) { ZLOG_ObtainRecord(zio->xaction, ZLOG_BLOCK_INFO_SIZE(FXLOG_INSERT_COUNT) + - sizeof(FXinsert_s)); + sizeof(FXinsert_s)); ZLOG_INIT_LOG_RECORD(XFUNC_FXLOG_L_INSERT, - zio->xaction, - logBuffer, - FXLOG_INSERT_COUNT, - logBlks, - logRecord); + zio->xaction, + logBuffer, + FXLOG_INSERT_COUNT, + logBlks, + logRecord); /*- log the child update (leaf) -*/ ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], XTREEchild->volBlk, node->header.lsn, XTREEchild, zio->xaction, 0); @@ -2227,7 +2225,7 @@ void insertExtent(ZioTh_s *zio) return; } -/*********************************************************************** +/*********************************************************************** * SPLIT * * Input: XTREEparent and XTREEsibling - set and latched @@ -2235,7 +2233,7 @@ void insertExtent(ZioTh_s *zio) * Output: XTREEparent and XTREEchild - set and latched * XTREEchild is set dirty * XTREEparent is set dirty - * + * ***********************************************************************/ STATUS FT_splitFreeTree(ZioTh_s *zio) { @@ -2294,7 +2292,7 @@ STATUS FT_splitFreeTree(ZioTh_s *zio) VerifyFXnode(child, FXVERIFYEXIT); VerifyFXnode(sibling, FXVERIFYEXIT); #endif - + if(FXBT_IS_LEAF(sibling)) { child->header.numRecs = FXBT_MINEXTENTS + 1; @@ -2309,7 +2307,7 @@ STATUS FT_splitFreeTree(ZioTh_s *zio) memmove(&child->EXT[1], /* Destination */ &sibling->EXT[sibling->header.numRecs], /* Source */ bytesToMove); - + bzero(&sibling->EXT[sibling->header.numRecs], bytesToMove); if(child->EXT[child->header.numRecs - 1].poolBlkNum == 0) @@ -2332,9 +2330,9 @@ STATUS FT_splitFreeTree(ZioTh_s *zio) /*- move from sibling to child -*/ memmove(&child->BRA[1], /* Destination */ - &sibling->BRA[sibling->header.numRecs], /* Source */ - bytesToMove); - + &sibling->BRA[sibling->header.numRecs], /* Source */ + bytesToMove); + bzero(&sibling->BRA[sibling->header.numRecs], bytesToMove); if(child->BRA[child->header.numRecs - 1].start == 0) @@ -2349,8 +2347,8 @@ STATUS FT_splitFreeTree(ZioTh_s *zio) /*- put new node in the parent -*/ scancnt = XTREEindex + 1; memmove( &parent->BRA[scancnt + 1], /* Destination */ - &parent->BRA[scancnt], /* Source */ - (parent->header.numRecs - scancnt) * sizeof(xBranch_s)); + &parent->BRA[scancnt], /* Source */ + (parent->header.numRecs - scancnt) * sizeof(xBranch_s)); /*- log new child record count -*/ logdata.braindex = scancnt; @@ -2379,7 +2377,7 @@ STATUS FT_splitFreeTree(ZioTh_s *zio) VerifyFXnode(sibling, FXVERIFYEXIT); VerifyFXnode(parent, FXVERIFYEXIT); #endif - + /*- log new child record count -*/ logdata.newbra.start = parent->BRA[scancnt].start; logdata.newbra.child = parent->BRA[scancnt].child; @@ -2388,14 +2386,14 @@ STATUS FT_splitFreeTree(ZioTh_s *zio) { ZLOG_ObtainRecord(localXact, ZLOG_BLOCK_INFO_SIZE(FXLOG_SPLIT_COUNT) + - bytesToMove + sizeof(FXsplit_s) - 1); + bytesToMove + sizeof(FXsplit_s) - 1); ZLOG_INIT_LOG_RECORD(XFUNC_FXLOG_SPLIT, - localXact, - logBuffer, - FXLOG_SPLIT_COUNT, - logBlks, - logRecord); + localXact, + logBuffer, + FXLOG_SPLIT_COUNT, + logBlks, + logRecord); /*- log the parent update -*/ ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], XTREEparent->volBlk, parent->header.lsn, XTREEparent, localXact, 0); @@ -2421,7 +2419,7 @@ STATUS FT_splitFreeTree(ZioTh_s *zio) EndXlocal(localXact); } - + CACHE_DIRTY_RELEASE(specialBuf); /*- check which block takes the insert -*/ @@ -2458,7 +2456,7 @@ STATUS splitXNode(ZioTh_s *zio) CACHE_RELEASE(XTREEparent); if(EXTENTlen != NULL) - { + { if(FXBT_IS_LEAF(child)) { insertExtent(zio); @@ -2478,7 +2476,7 @@ STATUS splitXNode(ZioTh_s *zio) /*- (FUNCTION) ----- insertXNodeGetChild() ---------------------------------- | - | XTREEchild must be a branch. + | XTREEchild must be a branch. | +-------------------------------------------------------------------------*/ STATUS insertXNodeGetChild(ZioTh_s *zio) @@ -2495,15 +2493,15 @@ STATUS insertXNodeGetChild(ZioTh_s *zio) XTREEchildBlk = findIndexInXBranch(parent, EXTENTblk, &XTREEindex); - /* If the extent being freed has a part that should go to the next - * child, then break the extent and only free part of it that belongs - * to this child. - */ + /* If the extent being freed has a part that should go to the next + * child, then break the extent and only free part of it that belongs + * to this child. + */ if (XTREEindex < (parent->header.numRecs -1)) { if ((EXTENTblk + EXTENTlen) > parent->BRA[XTREEindex+1].start) { - diff = ((EXTENTblk + EXTENTlen) - parent->BRA[XTREEindex+1].start); + diff = ((EXTENTblk + EXTENTlen) - parent->BRA[XTREEindex+1].start); zASSERT(diff <= EXTENTlen); EXTENTlen -= diff; } @@ -2523,10 +2521,10 @@ STATUS insertXNodeGetChild(ZioTh_s *zio) #if NSS_DEBUG IS_ENABLED VerifyFXnode(child, FXVERIFYEXIT); #endif - + if(FXBT_IS_MAX_XBRANCHES(child)) { - XTREEsibling = XTREEchild; + XTREEsibling = XTREEchild; if(EXTENTlen != NULL) { @@ -2589,9 +2587,9 @@ STATUS FT_growFreeTree( ZioTh_s *zio, ZfsPool_s *zfsPool) zASSERT((zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor > AIPU_LV_MEDIA_MAJOR) || - ((zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor == + ((zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor == AIPU_LV_MEDIA_MAJOR) && - (zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor > 0))); + (zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor > 0))); if ((zio->xaction != NULL) || (XTREE->xtreeFlags & XTREE_OK_TODO_LOCAL_XACTION)) { @@ -2600,8 +2598,8 @@ STATUS FT_growFreeTree( ZioTh_s *zio, ZfsPool_s *zfsPool) /*- grow the tree -*/ XALLOCBLK_IO_MSG(iomsg, zio->xtree, localXact, CACHE_UPDATE); - XTREEparent = ZFS_AllocPoolBlkSpecial(zio->genMsg, - &iomsg, &specialBuf); + XTREEparent = ZFS_AllocPoolBlkSpecial(zio->genMsg, + &iomsg, &specialBuf); zASSERT(XTREEparent != NULL); if (XTREEparent == NULL) @@ -2618,8 +2616,8 @@ STATUS FT_growFreeTree( ZioTh_s *zio, ZfsPool_s *zfsPool) initXNode(XTREEparent, FXBT_ROOT, &xtree->ZFSFXroot.ROOTinternalID ); insertZeroXNode((xNode_s *)XTREEparent->pBuf.data); - /*- for the grow case the parent is a range check and should be - | set to zero for the parent left most node first record + /*- for the grow case the parent is a range check and should be + | set to zero for the parent left most node first record -*/ parent->header.numRecs = 2; parent->BRA[1].start = 0; @@ -2647,7 +2645,7 @@ VerifyFXnode(sibling, FXVERIFYEXIT); if (localXact != NULL) { COMN_MARK_BEAST_XLOCAL(&xtree->ZFSFXroot, (Xaction_s *)&localXact); - + if(COMN_ForceBeastWrite(zio->genMsg, &xtree->ZFSFXroot, (Xaction_s *)localXact) != zOK) { @@ -2662,14 +2660,14 @@ VerifyFXnode(sibling, FXVERIFYEXIT); ZLOG_ObtainRecord(localXact, ZLOG_BLOCK_INFO_SIZE(FXLOG_GROW_COUNT) + - sizeof(FXgrow_s)); + sizeof(FXgrow_s)); ZLOG_INIT_LOG_RECORD(XFUNC_FXLOG_GROW, - localXact, - logBuffer, - FXLOG_GROW_COUNT, - logBlks, - logRecord); + localXact, + logBuffer, + FXLOG_GROW_COUNT, + logBlks, + logRecord); /*- log the parent update -*/ ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], XTREEparent->volBlk, parent->header.lsn, XTREEparent, localXact, 0); @@ -2690,14 +2688,14 @@ VerifyFXnode(sibling, FXVERIFYEXIT); } else { /* No Xaction so we do not log. Normally, we just mark - * the beast dirty and when the beast timer pops ( 10 sec - * default) the beast will be written (in a new xaction). - * If REBUILD is running in pass 1 it is using the ZLOG - * file for storage so it sets a flag so that we do not - * mark our beast dirty. Rebuild will mark our beast - * dirty after rebuild is done with the ZLOG file. - */ - if(!(zfsPool->ZFSPOOLrepairFlags + * the beast dirty and when the beast timer pops ( 10 sec + * default) the beast will be written (in a new xaction). + * If REBUILD is running in pass 1 it is using the ZLOG + * file for storage so it sets a flag so that we do not + * mark our beast dirty. Rebuild will mark our beast + * dirty after rebuild is done with the ZLOG file. + */ + if(!(zfsPool->ZFSPOOLrepairFlags & ZP_REPAIRFLAGS_NO_LOGGING_ALLOWED)) { COMN_MARK_BEAST_DIRTY(&xtree->ZFSFXroot); @@ -2714,7 +2712,7 @@ VerifyFXnode(sibling, FXVERIFYEXIT); | | Parameters - | zfsVol - the volume that will get charged for the allocation. - | With the addition of LVs the number of blocks + | With the addition of LVs the number of blocks | The actual alloation is done from the POOL and the Pool's | will be also charged for the allocation. +-------------------------------------------------------------------------*/ @@ -2739,17 +2737,17 @@ STATUS ZFSPOOL_FreeExtent(ZioTh_s *zio, ZfsVolume_s *zfsVol) zASSERT( zlssPool != NULL ); zfsPool = zlssPool->ZLSSPOOLzfsPool; zASSERT( zfsPool != NULL ); - + /* The next ASSERT check against 0 because we did not always - * initialize btFree to INVALID_BLK. - */ - zASSERT( (xtree->ZFSFXbtFree != INVALID_BLK) && + * initialize btFree to INVALID_BLK. + */ + zASSERT( (xtree->ZFSFXbtFree != INVALID_BLK) && (xtree->ZFSFXbtFree != 0)); /*- get an exclusive latch on xtree -*/ - X_LATCH(&xtree->ZFSFXbeastLatch); + X_LATCH(&xtree->ZFSFXbeastLatch); - XTREEchildBlk = xtree->ZFSFXbtRoot; + XTREEchildBlk = xtree->ZFSFXbtRoot; READBLK_IO_MSG(iomsg, xtree, XTREEchildBlk, CACHE_UPDATE); SET_DEBUG_ID(iomsg, 60); if(((XTREEchild = ZFS_ReadPoolBlk(zio->genMsg, &iomsg)) == NULL) || @@ -2765,7 +2763,7 @@ STATUS ZFSPOOL_FreeExtent(ZioTh_s *zio, ZfsVolume_s *zfsVol) #if NSS_DEBUG IS_ENABLED VerifyFXnode(root, FXVERIFYEXIT); #endif - + if(FXBT_IS_MAX_XBRANCHES(root)) { /*- swap to make the parent point to the node that is growing -*/ @@ -2803,7 +2801,7 @@ STATUS ZFSPOOL_FreeExtent(ZioTh_s *zio, ZfsVolume_s *zfsVol) { /*- unlatch the tree -*/ UNX_LATCH(&xtree->ZFSFXbeastLatch); - + /*- check if root is a leaf -*/ if(FXBT_IS_LEAF(root)) { @@ -2863,11 +2861,11 @@ STATUS joinXNode(ZioTh_s *zio) VerifyFXnode(child, FXVERIFYEXIT); VerifyFXnode(sibling, FXVERIFYEXIT); #endif - + if(FXBT_IS_LEAF(child)) { startnum = child->header.numRecs - 1; - + numToMove = (sibling->header.numRecs - 1); bytesToMove = numToMove * sizeof(Extent_s); node = child; @@ -2903,8 +2901,8 @@ STATUS joinXNode(ZioTh_s *zio) /*- shift all records to left and set last record to default -*/ memmove(&child->EXT[startnum + 1], /*- destination -*/ - &child->EXT[startnum + 2], /*- source -*/ - (child->header.numRecs - (startnum + 2)) * sizeof(Extent_s)); + &child->EXT[startnum + 2], /*- source -*/ + (child->header.numRecs - (startnum + 2)) * sizeof(Extent_s)); /*- remove last record -*/ child->EXT[child->header.numRecs - 1].poolBlkNum = 0; @@ -2967,19 +2965,19 @@ STATUS joinXNode(ZioTh_s *zio) VerifyFXnode(child, FXVERIFYEXIT); VerifyFXnode(parent, FXVERIFYEXIT); #endif - + if (localXact != NULL) { ZLOG_ObtainRecord(localXact, ZLOG_BLOCK_INFO_SIZE(FXLOG_JOIN_COUNT) + - bytesToMove + sizeof(FXjoin_s) - 1); + bytesToMove + sizeof(FXjoin_s) - 1); ZLOG_INIT_LOG_RECORD(XFUNC_FXLOG_JOIN, - localXact, - logBuffer, - FXLOG_JOIN_COUNT, - logBlks, - logRecord); + localXact, + logBuffer, + FXLOG_JOIN_COUNT, + logBlks, + logRecord); /*- log the parent update -*/ ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], XTREEparent->volBlk, parent->header.lsn, XTREEparent, localXact, 0); @@ -3001,7 +2999,7 @@ STATUS joinXNode(ZioTh_s *zio) /*- set the merge flag -*/ logRecord->u.join.mergeflag = joinmerge; - + ZLOG_ReleaseRecordAndLogEnd(localXact); EndXlocal(localXact); @@ -3064,13 +3062,13 @@ STATUS balanceXNode(ZioTh_s *zio) VerifyFXnode(sibling, FXVERIFYEXIT); VerifyFXnode(child, FXVERIFYEXIT); #endif - + if(FXBT_IS_LEAF(child)) { /*- do a 50% balance on extent data -*/ avg = (child->header.numRecs + sibling->header.numRecs - 2) / 2; if((child->header.numRecs - 1) <= avg) - { + { numToMove = avg - (child->header.numRecs - 1); bytesToMove = numToMove * sizeof(Extent_s); node = child; @@ -3092,7 +3090,7 @@ STATUS balanceXNode(ZioTh_s *zio) (sibling->header.numRecs - (numToMove + 1)) * sizeof(Extent_s)); bzero(&sibling->EXT[sibling->header.numRecs - numToMove], - (FXBT_MAXEXTENTS - (sibling->header.numRecs - numToMove)) * sizeof(Extent_s)); + (FXBT_MAXEXTENTS - (sibling->header.numRecs - numToMove)) * sizeof(Extent_s)); /*- update both -*/ child->header.numRecs += numToMove; @@ -3107,7 +3105,7 @@ STATUS balanceXNode(ZioTh_s *zio) VerifyFXnode(child, FXVERIFYEXIT); VerifyFXnode(sibling, FXVERIFYEXIT); #endif - + } else { @@ -3134,7 +3132,7 @@ STATUS balanceXNode(ZioTh_s *zio) bytesToMove); bzero(&child->EXT[child->header.numRecs - numToMove], - (FXBT_MAXEXTENTS - (child->header.numRecs - numToMove)) * sizeof(Extent_s)); + (FXBT_MAXEXTENTS - (child->header.numRecs - numToMove)) * sizeof(Extent_s)); /*- update both -*/ child->header.numRecs -= numToMove; @@ -3149,7 +3147,7 @@ STATUS balanceXNode(ZioTh_s *zio) VerifyFXnode(child, FXVERIFYEXIT); VerifyFXnode(sibling, FXVERIFYEXIT); #endif - + } } else @@ -3157,7 +3155,7 @@ STATUS balanceXNode(ZioTh_s *zio) /* not a leaf */ avg = (child->header.numRecs + sibling->header.numRecs - 2) / 2; if((child->header.numRecs - 1) <= avg) - { + { numToMove = avg - (child->header.numRecs - 1); bytesToMove = numToMove * sizeof(xBranch_s); node = child; @@ -3179,7 +3177,7 @@ STATUS balanceXNode(ZioTh_s *zio) (sibling->header.numRecs - (numToMove + 1)) * sizeof(xBranch_s)); bzero(&sibling->EXT[sibling->header.numRecs - numToMove], - (FXBT_MAXBRANCHES - (sibling->header.numRecs - numToMove)) * sizeof(xBranch_s)); + (FXBT_MAXBRANCHES - (sibling->header.numRecs - numToMove)) * sizeof(xBranch_s)); child->header.numRecs += numToMove; sibling->header.numRecs -= numToMove; @@ -3193,7 +3191,7 @@ STATUS balanceXNode(ZioTh_s *zio) VerifyFXnode(child, FXVERIFYEXIT); VerifyFXnode(sibling, FXVERIFYEXIT); #endif - + } else { @@ -3220,7 +3218,7 @@ STATUS balanceXNode(ZioTh_s *zio) bytesToMove); bzero(&child->BRA[child->header.numRecs - numToMove], - (FXBT_MAXBRANCHES - (child->header.numRecs - numToMove)) * sizeof(xBranch_s)); + (FXBT_MAXBRANCHES - (child->header.numRecs - numToMove)) * sizeof(xBranch_s)); /*- update both -*/ child->header.numRecs -= numToMove; @@ -3235,10 +3233,10 @@ STATUS balanceXNode(ZioTh_s *zio) VerifyFXnode(child, FXVERIFYEXIT); VerifyFXnode(sibling, FXVERIFYEXIT); #endif - + } } - + /*- log the original extent -*/ logdata.braindex = XTREEindex + 1; logdata.oribra.start = parent->BRA[XTREEindex + 1].start; @@ -3261,20 +3259,20 @@ STATUS balanceXNode(ZioTh_s *zio) #if NSS_DEBUG IS_ENABLED VerifyFXnode(parent, FXVERIFYEXIT); #endif - + /*- log the change -*/ if (localXact != NULL) { ZLOG_ObtainRecord(localXact, ZLOG_BLOCK_INFO_SIZE(FXLOG_BALANCE_COUNT) + - bytesToMove + sizeof(FXbalance_s) - 1); + bytesToMove + sizeof(FXbalance_s) - 1); ZLOG_INIT_LOG_RECORD(XFUNC_FXLOG_BALANCE, - localXact, - logBuffer, - FXLOG_BALANCE_COUNT, - logBlks, - logRecord); + localXact, + logBuffer, + FXLOG_BALANCE_COUNT, + logBlks, + logRecord); /*- log the parent update -*/ ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], XTREEparent->volBlk, parent->header.lsn, XTREEparent, localXact, 0); @@ -3360,10 +3358,10 @@ STATUS deleteExtent(ZioTh_s *zio) bzero(&logdata, sizeof(FXdelete_s)); /* Look for the specified extent. Make sure it is not on the list - * of not available to be allocated yet .. but if we are doing logical - * undo's the block will be on the list and we want to specifically get - * that block so do not do the BLKS_CAN_BE_ALLOCATED check - */ + * of not available to be allocated yet .. but if we are doing logical + * undo's the block will be on the list and we want to specifically get + * that block so do not do the BLKS_CAN_BE_ALLOCATED check + */ if (EXTENTblk == 0) { goto findLengthMatch; @@ -3374,14 +3372,14 @@ STATUS deleteExtent(ZioTh_s *zio) localext = &node->EXT[scancnt]; - if ( (localext->lengthOfExtent != 0) && - (EXTENTblk >= localext->poolBlkNum) && - (EXTENTblk < (localext->poolBlkNum + localext->lengthOfExtent))) + if ( (localext->lengthOfExtent != 0) && + (EXTENTblk >= localext->poolBlkNum) && + (EXTENTblk < (localext->poolBlkNum + localext->lengthOfExtent))) { - /* seed found in the block */ + /* seed found in the block */ if ( (IS_LOGICAL_UNDO_FREE_TREE_INSERT_XACTION(zio->xaction)) || - (BLKS_CAN_BE_ALLOCATED(XTREE->ZFSFXpool, &node->EXT[scancnt], - &EXTENTptr))) + (BLKS_CAN_BE_ALLOCATED(XTREE->ZFSFXpool, &node->EXT[scancnt], + &EXTENTptr))) { /* We can use this seed, process it */ goto useFoundSeed; @@ -3389,30 +3387,30 @@ STATUS deleteExtent(ZioTh_s *zio) } if ( zio->zt_flags & ZT_FLAGS_NEAR_MATCH ) { - if ( findNearMatchInArea(XTREE->ZFSFXpool, node, XTREE->ZFE_AreaSizeCurrent, - &EXTENTblk, &scancnt) == zOK ) - { - /* findNearMatchInArea changed the seed - EXTENTblk to a value - * within the area, nearest the seed. It also set scancnt to the - * index of the entry that points to the new seed */ + if ( findNearMatchInArea(XTREE->ZFSFXpool, node, XTREE->ZFE_AreaSizeCurrent, + &EXTENTblk, &scancnt) == zOK ) + { + /* findNearMatchInArea changed the seed - EXTENTblk to a value + * within the area, nearest the seed. It also set scancnt to the + * index of the entry that points to the new seed */ FT_ValidateNode( XTREEchild, scancnt ); goto useFoundSeed; - } - else - { /* Caller will call back to allocate a new area */ - goto returnError; - } + } + else + { /* Caller will call back to allocate a new area */ + goto returnError; + } } else if (zio->zt_flags & ZT_FLAGS_GLOBAL_SEED) { -// if ( findMatchHigherOld(XTREE->ZFSFXpool, node, EXTENTlen, +// if ( findMatchHigherOld(XTREE->ZFSFXpool, node, EXTENTlen, // &EXTENTblk, &scancnt) == zOK ) if ( FT_FindMatchHigher(XTREE->ZFSFXpool, node, &EXTENTptr, - 1, &EXTENTptr, &scancnt) == zOK ) + 1, &EXTENTptr, &scancnt) == zOK ) { /* FT_FindMatchHigher changed the seed - EXTENTblk to a value - * higher than the GlobalSeed. It also set scancnt to the - * index of the entry that points to the new seed */ + * higher than the GlobalSeed. It also set scancnt to the + * index of the entry that points to the new seed */ FT_ValidateNode( XTREEchild, scancnt ); goto useFoundSeed; } @@ -3434,7 +3432,7 @@ useFoundSeed: /*- log the node record number -*/ logdata.recnuml = scancnt; - + /*- test for start match -*/ if((localext->lengthOfExtent != 0) && (EXTENTblk == localext->poolBlkNum)) { @@ -3472,8 +3470,8 @@ useFoundSeed: { /*- shift all records to left and set last record to default -*/ memmove(&node->EXT[scancnt], /*- destination -*/ - &node->EXT[scancnt + 1], /*- source -*/ - (node->header.numRecs - (scancnt + 1)) * sizeof(Extent_s)); + &node->EXT[scancnt + 1], /*- source -*/ + (node->header.numRecs - (scancnt + 1)) * sizeof(Extent_s)); node->EXT[node->header.numRecs - 1].poolBlkNum = 0; node->EXT[node->header.numRecs - 1].lengthOfExtent = 0; @@ -3489,14 +3487,14 @@ useFoundSeed: { ZLOG_ObtainRecord(zio->xaction, ZLOG_BLOCK_INFO_SIZE(FXLOG_DELETE_COUNT) + - sizeof(FXdelete_s)); + sizeof(FXdelete_s)); ZLOG_INIT_LOG_RECORD(XFUNC_FXLOG_L_DELETE, - zio->xaction, - logBuffer, - FXLOG_DELETE_COUNT, - logBlks, - logRecord); + zio->xaction, + logBuffer, + FXLOG_DELETE_COUNT, + logBlks, + logRecord); /*- mark the unused record -*/ ZLOG_ASSIGN_BLOCK_INFO(logBlks[0],0,0,0,zio->xaction,0); @@ -3520,11 +3518,11 @@ useFoundSeed: } /*- test if request is within record -*/ - if ((EXTENTblk > localext->poolBlkNum) && + if ((EXTENTblk > localext->poolBlkNum) && (EXTENTblk < (localext->poolBlkNum + localext->lengthOfExtent))) { - if (!(FXBT_IS_MAX_XBRANCHES(node)) || - (IS_LOGICAL_UNDO_FREE_TREE_INSERT_XACTION(zio->xaction))) + if (!(FXBT_IS_MAX_XBRANCHES(node)) || + (IS_LOGICAL_UNDO_FREE_TREE_INSERT_XACTION(zio->xaction))) { if(EXTENTlen > localext->lengthOfExtent - (EXTENTblk - localext->poolBlkNum)) { @@ -3559,18 +3557,18 @@ useFoundSeed: /*- update node if temp is valid -*/ if(templen > 0) { - if ((FXBT_IS_MAX_XBRANCHES(node)) && + if ((FXBT_IS_MAX_XBRANCHES(node)) && (IS_LOGICAL_UNDO_FREE_TREE_INSERT_XACTION(zio->xaction))) { - /* This has been put in for logical undo's. This - * is the case that we are undoing a free logically - * and require the exact blocks be allocated again. - * In the case that the record needs to be split - * and there is no space in the block to split the - * record, I will return more blocks than they - * asked for and the logical undo code will free - * them up. - */ + /* This has been put in for logical undo's. This + * is the case that we are undoing a free logically + * and require the exact blocks be allocated again. + * In the case that the record needs to be split + * and there is no space in the block to split the + * record, I will return more blocks than they + * asked for and the logical undo code will free + * them up. + */ EXTENTlen += templen; templen = 0; logdata.delExt.lengthOfExtent = EXTENTlen; @@ -3580,23 +3578,23 @@ useFoundSeed: /*- shift all records to right to insert temp -*/ memmove(&node->EXT[scancnt + 1], /*- dest -*/ &node->EXT[scancnt], /*- source -*/ - (node->header.numRecs - scancnt) * + (node->header.numRecs - scancnt) * sizeof(Extent_s)); - node->EXT[scancnt+1].poolBlkNum = + node->EXT[scancnt+1].poolBlkNum = EXTENTblk + EXTENTlen; node->EXT[scancnt+1].lengthOfExtent = templen; /*- log the new extent -*/ - logdata.splitext.poolBlkNum = + logdata.splitext.poolBlkNum = node->EXT[scancnt+1].poolBlkNum; - logdata.splitext.lengthOfExtent = + logdata.splitext.lengthOfExtent = node->EXT[scancnt+1].lengthOfExtent; node->header.numRecs++; } } - + /*- log the new number of records -*/ logdata.newnumRecs = node->header.numRecs; @@ -3605,16 +3603,16 @@ useFoundSeed: { ZLOG_ObtainRecord(zio->xaction, ZLOG_BLOCK_INFO_SIZE(FXLOG_DELETE_COUNT) + - sizeof(FXdelete_s)); + sizeof(FXdelete_s)); ZLOG_INIT_LOG_RECORD(XFUNC_FXLOG_L_DELETE, - zio->xaction, - logBuffer, - FXLOG_DELETE_COUNT, - logBlks, - logRecord); - + zio->xaction, + logBuffer, + FXLOG_DELETE_COUNT, + logBlks, + logRecord); + /*- mark the unused record -*/ ZLOG_ASSIGN_BLOCK_INFO(logBlks[0],0,0,0,zio->xaction,0); @@ -3641,7 +3639,7 @@ findLengthMatch: /*- seed location not found just find an extent to return -*/ /*- or the requested seed is on the cant be reused yet list -*/ if ( !(zio->zt_flags & ZT_FLAGS_NEAR_MATCH) && - (findLengthMatch(XTREE->ZFSFXpool, node, EXTENTlen, &scancnt) == zOK) ) + (findLengthMatch(XTREE->ZFSFXpool, node, EXTENTlen, &scancnt) == zOK) ) { FT_ValidateNode( XTREEchild, scancnt ); @@ -3715,8 +3713,8 @@ findLengthMatch: { /*- shift all records to left and set last record to default -*/ memmove(&node->EXT[scancnt], /*- destination -*/ - &node->EXT[scancnt + 1], /*- source -*/ - (node->header.numRecs - (scancnt + 1)) * sizeof(Extent_s)); + &node->EXT[scancnt + 1], /*- source -*/ + (node->header.numRecs - (scancnt + 1)) * sizeof(Extent_s)); node->EXT[node->header.numRecs - 1].poolBlkNum = 0; node->EXT[node->header.numRecs - 1].lengthOfExtent = 0; @@ -3732,14 +3730,14 @@ findLengthMatch: { ZLOG_ObtainRecord(zio->xaction, ZLOG_BLOCK_INFO_SIZE(FXLOG_DELETE_COUNT) + - sizeof(FXdelete_s)); + sizeof(FXdelete_s)); ZLOG_INIT_LOG_RECORD(XFUNC_FXLOG_L_DELETE, - zio->xaction, - logBuffer, - FXLOG_DELETE_COUNT, - logBlks, - logRecord); + zio->xaction, + logBuffer, + FXLOG_DELETE_COUNT, + logBlks, + logRecord); /*- mark the unused record -*/ ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], 0, 0, 0, zio->xaction, 0); @@ -3845,8 +3843,8 @@ STATUS deleteXNodeGetChild(ZioTh_s *zio) if(((XTREEchild = ZFS_ReadPoolBlk(zio->genMsg, &iomsg)) == NULL) || (FT_MagicCheck( zio->genMsg, XTREEchild, &iomsg) != zOK)) { - CACHE_RELEASE(XTREEsibling); - CACHE_RELEASE(XTREEparent); + CACHE_RELEASE(XTREEsibling); + CACHE_RELEASE(XTREEparent); return(zFAILURE); } @@ -3916,7 +3914,7 @@ STATUS ZFSPOOL_AllocExtent(ZioTh_s *zio, ZfsVolume_s *zfsVol) zASSERT( zfsPool != NULL ); /*- get an exclusive latch on xtree -*/ - X_LATCH(&xtree->ZFSFXbeastLatch); + X_LATCH(&xtree->ZFSFXbeastLatch); /*- check for root of btree -*/ if(xtree->zfsBtree.p.btRoot == INVALID_BLK) @@ -3939,7 +3937,7 @@ STATUS ZFSPOOL_AllocExtent(ZioTh_s *zio, ZfsVolume_s *zfsVol) UNX_LATCH(&xtree->ZFSFXbeastLatch); return(zFAILURE); } - + root = (xNode_s *)XTREEchild->pBuf.data; #if NSS_DEBUG IS_ENABLED VerifyFXnode(root, FXVERIFYEXIT); @@ -3947,30 +3945,30 @@ STATUS ZFSPOOL_AllocExtent(ZioTh_s *zio, ZfsVolume_s *zfsVol) #if 0 /* SPD 215937 - Free tree and beast tree deadlock. - * Paul, Vandana, Mike and me(Greg) have decided to - * remove the shrink code in the 60 day release. This - * code was not executed in original release. It is - * causeing the above deadlock and we felt that the lowest - * risk fix was to remove the code. I eneter SPD - * 215962 to address the bigger issue of the system beasts - * should not be stored in the beast tree. - * The COMN_ForceBeastWrite call is what causes the deadlock - * if the alloc call was made by the beast tree. - */ + * Paul, Vandana, Mike and me(Greg) have decided to + * remove the shrink code in the 60 day release. This + * code was not executed in original release. It is + * causeing the above deadlock and we felt that the lowest + * risk fix was to remove the code. I eneter SPD + * 215962 to address the bigger issue of the system beasts + * should not be stored in the beast tree. + * The COMN_ForceBeastWrite call is what causes the deadlock + * if the alloc call was made by the beast tree. + */ #endif - /* System beasts have been moved to special block so we can use this - * code - * But we cannot use it until the upgrade to media 40 01 is complete. - */ - if ( ( root->header.numRecs == 2 ) && - ( !FXBT_IS_LEAF(root) ) && - ( ( zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor > + /* System beasts have been moved to special block so we can use this + * code + * But we cannot use it until the upgrade to media 40 01 is complete. + */ + if ( ( root->header.numRecs == 2 ) && + ( !FXBT_IS_LEAF(root) ) && + ( ( zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor > AIPU_LV_MEDIA_MAJOR ) || - ( ( zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor == + ( ( zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor == AIPU_LV_MEDIA_MAJOR ) && - ( zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor > 0 ) - ) - ) ) + ( zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor > 0 ) + ) + ) ) { ZfsXaction_s *localXact; @@ -4011,7 +4009,7 @@ STATUS ZFSPOOL_AllocExtent(ZioTh_s *zio, ZfsVolume_s *zfsVol) if(localXact != NULL) { COMN_MARK_BEAST_XLOCAL(&xtree->ZFSFXroot, (Xaction_s *)&localXact); - + if(COMN_ForceBeastWrite(zio->genMsg, &xtree->ZFSFXroot, (Xaction_s *)localXact) != zOK) { @@ -4029,11 +4027,11 @@ STATUS ZFSPOOL_AllocExtent(ZioTh_s *zio, ZfsVolume_s *zfsVol) ZLOG_BLOCK_INFO_SIZE(FXLOG_SHRINK_COUNT)); ZLOG_INIT_LOG_RECORD(XFUNC_FXLOG_SHRINK, - localXact, - logBuffer, - FXLOG_SHRINK_COUNT, - logBlks, - logRecord); + localXact, + logBuffer, + FXLOG_SHRINK_COUNT, + logBlks, + logRecord); /*- log the buffer to delete -*/ ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], XTREEparent->volBlk, parent->header.lsn, XTREEparent, localXact, 0); @@ -4051,16 +4049,16 @@ STATUS ZFSPOOL_AllocExtent(ZioTh_s *zio, ZfsVolume_s *zfsVol) else { /* If we do a shrink without a xaction, that block is lost */ - if(!(zfsPool->ZFSPOOLrepairFlags & - ZP_REPAIRFLAGS_NO_LOGGING_ALLOWED)) + if(!(zfsPool->ZFSPOOLrepairFlags & + ZP_REPAIRFLAGS_NO_LOGGING_ALLOWED)) { /* No Xaction so we do not log. Normally, we just mark - * the beast dirty and when the beast timer pops ( 10 sec - * default) the beast will be written (in a new xaction). - * If REBUILD is running in pass 1 it is using the ZLOG - * file for storage so it sets a flag so that we do not - * mark our beast dirty. Rebuild will mark our beast - * dirty after rebuild is done with the ZLOG file. - */ + * the beast dirty and when the beast timer pops ( 10 sec + * default) the beast will be written (in a new xaction). + * If REBUILD is running in pass 1 it is using the ZLOG + * file for storage so it sets a flag so that we do not + * mark our beast dirty. Rebuild will mark our beast + * dirty after rebuild is done with the ZLOG file. + */ COMN_MARK_BEAST_DIRTY(&xtree->ZFSFXroot); } } @@ -4070,7 +4068,7 @@ STATUS ZFSPOOL_AllocExtent(ZioTh_s *zio, ZfsVolume_s *zfsVol) } if(FXBT_IS_MAX_XBRANCHES(root)) - { + { /*- swap to make the parent point to the node that is growing -*/ XTREEsibling = XTREEchild; @@ -4078,7 +4076,7 @@ STATUS ZFSPOOL_AllocExtent(ZioTh_s *zio, ZfsVolume_s *zfsVol) { printk("<1> Got an error from grow while allocation\n"); return zFAILURE; - } + } CACHE_RELEASE(XTREEsibling); XTREEchild = XTREEparent; root = (xNode_s *)XTREEchild->pBuf.data; @@ -4214,18 +4212,18 @@ Blknum_t getABlkFromSpecialBlk( if (xaction != NULL) { - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(FXLOG_DELETE_COUNT) + sizeof(FXdelete_s)); - + ZLOG_INIT_LOG_RECORD(XFUNC_FXLOG_DELETE, - xaction, - logBuffer, - FXLOG_DELETE_COUNT, - logBlks, - logRecord); + xaction, + logBuffer, + FXLOG_DELETE_COUNT, + logBlks, + logRecord); ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], 0, 0, 0, xaction, 0); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], specialBlk, node->header.lsn, - *specialBuf, xaction, 1); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[1], specialBlk, node->header.lsn, + *specialBuf, xaction, 1); node->header.lsn = logBuffer->ZXR_Lsn; ZLOG_BIND(xaction, *specialBuf); memcpy(&logRecord->u.delete, &logdata, sizeof(FXdelete_s)); @@ -4254,7 +4252,7 @@ Blknum_t getABlkFromSpecialBlk( /************************************************************************** ** This routine is called to add blks to the special blk. - ** + ** ***************************************************************************/ void CheckSpecialBlkAndAdd( ZfsPool_s *pool, @@ -4290,7 +4288,7 @@ void CheckSpecialBlkAndAdd( extent.poolBlkNum = 0; extent.lengthOfExtent = 1; - if (zfsAllocExtent( &genMsg, &pool->zfsVol, &extent, + if (zfsAllocExtent( &genMsg, &pool->zfsVol, &extent, XTREE_SYSTEM_REQUEST, NULL) != zOK) { zASSERT(0); @@ -4300,16 +4298,16 @@ void CheckSpecialBlkAndAdd( X_LATCH(&xtree->ZFSFXbeastLatch); InitSpecialNode(&genMsg, xtree, specialBlk); - if (!(pool->ZFSPOOLrepairFlags & - ZP_REPAIRFLAGS_NO_LOGGING_ALLOWED)) + if (!(pool->ZFSPOOLrepairFlags & + ZP_REPAIRFLAGS_NO_LOGGING_ALLOWED)) { /* No Xaction so we do not log. Normally, we just mark - * the beast dirty and when the beast timer pops ( 10 sec - * default) the beast will be written (in a new xaction). - * If REBUILD is running in pass 1 it is using the ZLOG - * file for storage so it sets a flag so that we do not - * mark our beast dirty. Rebuild will mark our beast - * dirty after rebuild is done with the ZLOG file. - */ + * the beast dirty and when the beast timer pops ( 10 sec + * default) the beast will be written (in a new xaction). + * If REBUILD is running in pass 1 it is using the ZLOG + * file for storage so it sets a flag so that we do not + * mark our beast dirty. Rebuild will mark our beast + * dirty after rebuild is done with the ZLOG file. + */ COMN_MARK_BEAST_DIRTY(&xtree->ZFSFXroot); } UNX_LATCH(&xtree->ZFSFXbeastLatch); @@ -4339,7 +4337,7 @@ void CheckSpecialBlkAndAdd( extent.poolBlkNum = 0; extent.lengthOfExtent = FXBT_MINBLKS_SPECIAL - numBlks; - if (zfsAllocExtent( &genMsg, &pool->zfsVol, &extent, + if (zfsAllocExtent( &genMsg, &pool->zfsVol, &extent, XTREE_SYSTEM_REQUEST, xaction) != zOK) { if (flags & XTREE_SPBLK_XACTION) @@ -4411,18 +4409,18 @@ void CheckSpecialBlkAndAdd( } if (xaction != NULL) { - ZLOG_ObtainRecord(xaction, + ZLOG_ObtainRecord(xaction, ZLOG_BLOCK_INFO_SIZE(FXLOG_INSERT_COUNT) + sizeof(FXinsert_s)); ZLOG_INIT_LOG_RECORD(XFUNC_FXLOG_INSERT, - xaction, - logBuffer, - FXLOG_INSERT_COUNT, - logBlks, - logRecord); + xaction, + logBuffer, + FXLOG_INSERT_COUNT, + logBlks, + logRecord); - ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], specialBlk, node->header.lsn, - specialBuf, xaction, 0); + ZLOG_ASSIGN_BLOCK_INFO(logBlks[0], specialBlk, node->header.lsn, + specialBuf, xaction, 0); node->header.lsn = logBuffer->ZXR_Lsn; ZLOG_BIND(xaction, specialBuf); memcpy(&logRecord->u.insert, &logdata, sizeof(FXinsert_s)); @@ -4442,10 +4440,10 @@ void CheckSpecialBlkAndAdd( } if (extent.lengthOfExtent == 0) { - break; + break; } } - + READBLK_IO_MSG(iomsg, xtree, specialBlk, CACHE_READ); if((specialBuf = ZFS_ReadPoolBlk(&genMsg, &iomsg)) == NULL) { @@ -4461,7 +4459,7 @@ void CheckSpecialBlkAndAdd( scheduleToRunLater: if ((flags & XTREE_SPBLK_THREAD_SCH) && !(xtree->xtreeFlags & XTREE_STOP_THREADS) && - (numBlks < FXBT_MINBLKS_SPECIAL)) + (numBlks < FXBT_MINBLKS_SPECIAL)) { xtree->xtreeFlags |= XTREE_THREAD_SCHEDULED; xtree->xtreeWtd.info = pool; @@ -4483,7 +4481,7 @@ void FT_PrintCorruptMessage( Volume_s *volume; Pool_s *pool; typedef struct Stack_s { - unicode_t poolName[zMAX_COMPONENT_NAME]; + unicode_t poolName[zMAX_COMPONENT_NAME]; } Stack_s; STACK_ALLOC(); @@ -4555,19 +4553,19 @@ void FT_ValidateNode( Buffer_s *buffer, SNINT index ) { e_curr = &node->EXT[cnt]; /* Check if leaf records assend && - * check for crossed linked blocks. - * - * Removed the check for ascending block numbers and - * just left the check for duplicate block - Aug 16, 2001 - */ + * check for crossed linked blocks. + * + * Removed the check for ascending block numbers and + * just left the check for duplicate block - Aug 16, 2001 + */ #if XTREE_CHECK_ORDER IS_ENABLED if ( (e_prev->poolBlkNum >= e_curr->poolBlkNum) || ((e_prev->poolBlkNum + e_prev->lengthOfExtent) > e_curr->poolBlkNum) ) #else if ( (e_prev->poolBlkNum <= e_curr->poolBlkNum) && - ((e_prev->poolBlkNum + e_prev->lengthOfExtent) > - e_curr->poolBlkNum) ) + ((e_prev->poolBlkNum + e_prev->lengthOfExtent) > + e_curr->poolBlkNum) ) #endif { @@ -4602,7 +4600,7 @@ void VerifyFXnode(xNode_s *node, NINT action) ASSERT_MPKNSS_LOCK(); /*- check the magic -*/ zASSERT((node->header.magic == FXLEAF_MAGIC) || (node->header.magic == FXBRANCH_MAGIC)); - + /*- check if status matches the magic -*/ if(node->header.state & FXBT_LEAF) zASSERT(node->header.magic == FXLEAF_MAGIC); @@ -4612,7 +4610,7 @@ void VerifyFXnode(xNode_s *node, NINT action) /*- check max number of nodes -*/ zASSERT(node->header.numRecs <= FXBT_MAXEXTENTS); - /*- select the node type -*/ + /*- select the node type -*/ if(node->header.state & FXBT_LEAF) { /*- this is for a leaf -*/ @@ -4624,12 +4622,12 @@ void VerifyFXnode(xNode_s *node, NINT action) /*- check special case first record -*/ zASSERT(e_curr->lengthOfExtent == 0); zASSERT(e_curr->poolBlkNum == 0); - + for(cnt = 1; cnt < node->header.numRecs; cnt++) { /*- set the current record -*/ e_curr = &node->EXT[cnt]; - + if(e_prev->poolBlkNum != 0) { /*- check if leaf records assend -*/ @@ -4640,7 +4638,7 @@ void VerifyFXnode(xNode_s *node, NINT action) balance does not merge. Mike will fix if we have time */ zASSERT((e_prev->poolBlkNum + e_prev->lengthOfExtent) <= e_curr->poolBlkNum); } - + /*- set previous record and try next -*/ e_prev = e_curr; } @@ -4648,7 +4646,7 @@ void VerifyFXnode(xNode_s *node, NINT action) else { /*- this is for a branch -*/ - + /*- set up extent pointers -*/ b_prev = &node->BRA[0]; b_curr = &node->BRA[0]; @@ -4656,12 +4654,12 @@ void VerifyFXnode(xNode_s *node, NINT action) /*- check special case first record -*/ zASSERT(b_curr->start == 0); zASSERT(b_curr->child == 0); - + for(cnt = 1; cnt < node->header.numRecs; cnt++) { /*- set the current record -*/ b_curr = &node->BRA[cnt]; - + if(b_prev->start != 0) { /*- check if leaf records assend -*/ @@ -4675,18 +4673,18 @@ void VerifyFXnode(xNode_s *node, NINT action) if(action == FXVERIFYENTER) EntryExitFlag = 0; - + if(EntryExitFlag == 0) { - + } else { - + } - - return; -} + + return; +} #endif @@ -4718,23 +4716,23 @@ BOOL FT_ExtentIsStillFree( CheckNextEntry: /*- get an exclusive latch on xtree -*/ - S_LATCH(&xtree->ZFSFXbeastLatch); + S_LATCH(&xtree->ZFSFXbeastLatch); childBlk = xtree->zfsBtree.p.btRoot; /*- check for root of btree -*/ if(childBlk == INVALID_BLK) { - UNS_LATCH(&xtree->ZFSFXbeastLatch); + UNS_LATCH(&xtree->ZFSFXbeastLatch); return FALSE; } READBLK_IO_MSG(iomsg, xtree, childBlk, CACHE_READ); if ((childBuffer = ZFS_ReadPoolBlk(&genMsg, &iomsg)) == NULL) { - UNS_LATCH(&xtree->ZFSFXbeastLatch); + UNS_LATCH(&xtree->ZFSFXbeastLatch); return FALSE; } - UNS_LATCH(&xtree->ZFSFXbeastLatch); + UNS_LATCH(&xtree->ZFSFXbeastLatch); child = (xNode_s *)childBuffer->pBuf.data; while (!(child->header.state & FXBT_LEAF)) @@ -4760,21 +4758,21 @@ CheckNextEntry: } extentInTree = &child->n.extents[index]; - if ((poolBlkNum < extentInTree->poolBlkNum) || - (poolBlkNum >= + if ((poolBlkNum < extentInTree->poolBlkNum) || + (poolBlkNum >= (extentInTree->poolBlkNum + extentInTree->lengthOfExtent))) { CACHE_RELEASE(childBuffer); return FALSE; } - if ((poolBlkNum + length) <= + if ((poolBlkNum + length) <= (extentInTree->poolBlkNum + extentInTree->lengthOfExtent)) { CACHE_RELEASE(childBuffer); return TRUE; } - validCnt = (extentInTree->poolBlkNum + extentInTree->lengthOfExtent) - + validCnt = (extentInTree->poolBlkNum + extentInTree->lengthOfExtent) - poolBlkNum; poolBlkNum += validCnt; @@ -4846,13 +4844,13 @@ STATUS undoFXshrink( // if (!(IS_XLATCHED(&zfspool->freeExtent->ZFSFXbeastLatch))) // { -// ilatchedit = 1; -// X_LATCH(&zfspool->freeExtent->ZFSFXbeastLatch); +// ilatchedit = 1; +// X_LATCH(&zfspool->freeExtent->ZFSFXbeastLatch); // } // // zfspool->freeExtent->zfsBtree.p.btRoot = logBlks[0].blkNum; // COMN_MARK_BEAST_DIRTY(&zfspool->freeExtent->ZFSFXroot); -// +// // if(ilatchedit) // UNX_LATCH(&zfspool->freeExtent->ZFSFXbeastLatch); @@ -4945,8 +4943,8 @@ STATUS redoFXshrink( // /*- set the new root -*/ // if (!(IS_XLATCHED(&zfspool->freeExtent->ZFSFXbeastLatch))) // { -// ilatchedit = 1; -// X_LATCH(&zfspool->freeExtent->ZFSFXbeastLatch); +// ilatchedit = 1; +// X_LATCH(&zfspool->freeExtent->ZFSFXbeastLatch); // } // // zfspool->freeExtent->zfsBtree.p.btRoot = logBlks[1].blkNum; @@ -4980,7 +4978,7 @@ STATUS undoFXdeleteLogical( { STATUS status = zOK; FXlog_s *logRecord; - ZfsXaction_s *xaction; + ZfsXaction_s *xaction; ZioTh_s zio; Extent_s delExt; @@ -4996,13 +4994,13 @@ STATUS undoFXdeleteLogical( xaction = BeginXLocal(&zfspool->ZFSPOOLvol, BXL_LOGICAL_UNDO); /* Free extent inserts this extent into the free tree. When redo - * completed it guaranteed that these blocks were deleted from - * the free tree. So free extent should be able to insert - * them. - * - * We still want to continue to hold them on a list until after the - * transaction that freed them has ended. - */ + * completed it guaranteed that these blocks were deleted from + * the free tree. So free extent should be able to insert + * them. + * + * We still want to continue to hold them on a list until after the + * transaction that freed them has ended. + */ delExt.poolBlkNum = logRecord->u.delete.delExt.poolBlkNum; delExt.lengthOfExtent = logRecord->u.delete.delExt.lengthOfExtent; @@ -5010,8 +5008,8 @@ STATUS undoFXdeleteLogical( zASSERT(delExt.lengthOfExtent != 0); XACT_holdFreeUserDataBlks(&delExt, xaction); - INIT_ZIO_TH(&zio, genMsg, zfspool->freeExtent, - delExt.poolBlkNum, + INIT_ZIO_TH(&zio, genMsg, zfspool->freeExtent, + delExt.poolBlkNum, delExt.lengthOfExtent, xaction); while (zio.extent.lengthOfExtent != 0) @@ -5024,9 +5022,9 @@ STATUS undoFXdeleteLogical( return(status); } - zio.extent.poolBlkNum = delExt.poolBlkNum + + zio.extent.poolBlkNum = delExt.poolBlkNum + zio.extent.lengthOfExtent; - zio.extent.lengthOfExtent = delExt.lengthOfExtent - + zio.extent.lengthOfExtent = delExt.lengthOfExtent - zio.extent.lengthOfExtent; delExt.lengthOfExtent = zio.extent.lengthOfExtent; delExt.poolBlkNum = zio.extent.poolBlkNum; @@ -5081,7 +5079,7 @@ STATUS undoFXdelete( { node->BRA[logRecord->u.delete.recnumb].start = logRecord->u.delete.oribra.start; node->BRA[logRecord->u.delete.recnumb].child = logRecord->u.delete.oribra.child; - + ZLOG_SET_LSN(logBuffer, node->header.lsn, logBlks[0], action); #if NSS_DEBUG IS_ENABLED @@ -5117,25 +5115,25 @@ STATUS undoFXdelete( //DebugPrintf(YELLOW, MSGNot("Undo Delete. scancnt=%d\n"), scancnt); if(logRecord->u.delete.orinumRecs != logRecord->u.delete.newnumRecs) - { + { /*- adjust node to hold new record -*/ if(logRecord->u.delete.orinumRecs > logRecord->u.delete.newnumRecs) - { + { /*- removed record, must expand -*/ /*- shift all records to right and insert new record -*/ memmove(&node->EXT[scancnt + 1], /*- destination -*/ - &node->EXT[scancnt], /*- source -*/ - (logRecord->u.delete.newnumRecs - scancnt) * sizeof(Extent_s)); + &node->EXT[scancnt], /*- source -*/ + (logRecord->u.delete.newnumRecs - scancnt) * sizeof(Extent_s)); } else - { + { /*- split record, must shrink -*/ /*- shift all records to left and set last record to default -*/ memmove(&node->EXT[scancnt], /*- destination -*/ - &node->EXT[scancnt + 1], /*- source -*/ - (logRecord->u.delete.newnumRecs - (scancnt + 1)) * sizeof(Extent_s)); + &node->EXT[scancnt + 1], /*- source -*/ + (logRecord->u.delete.newnumRecs - (scancnt + 1)) * sizeof(Extent_s)); node->EXT[logRecord->u.delete.newnumRecs - 1].poolBlkNum = 0; node->EXT[logRecord->u.delete.newnumRecs - 1].lengthOfExtent = 0; @@ -5241,28 +5239,28 @@ STATUS redoFXdelete( node->EXT[scancnt].lengthOfExtent = logRecord->u.delete.newext.lengthOfExtent; if(logRecord->u.delete.orinumRecs != logRecord->u.delete.newnumRecs) - { + { /*- adjust node to hold new record -*/ if(logRecord->u.delete.orinumRecs > logRecord->u.delete.newnumRecs) - { + { /*- removed record, must expand -*/ /*- shift all records to left and set last record to default -*/ memmove(&node->EXT[scancnt], /*- destination -*/ - &node->EXT[scancnt + 1], /*- source -*/ - (logRecord->u.delete.orinumRecs - (scancnt + 1)) * sizeof(Extent_s)); + &node->EXT[scancnt + 1], /*- source -*/ + (logRecord->u.delete.orinumRecs - (scancnt + 1)) * sizeof(Extent_s)); node->EXT[logRecord->u.delete.orinumRecs - 1].poolBlkNum = 0; node->EXT[logRecord->u.delete.orinumRecs - 1].lengthOfExtent = 0; } else - { + { /*- split record, must grow -*/ /*- shift all records to right and insert new record -*/ memmove(&node->EXT[scancnt + 1], /*- destination -*/ - &node->EXT[scancnt], /*- source -*/ - (logRecord->u.delete.orinumRecs - scancnt) * sizeof(Extent_s)); + &node->EXT[scancnt], /*- source -*/ + (logRecord->u.delete.orinumRecs - scancnt) * sizeof(Extent_s)); node->EXT[scancnt+1].poolBlkNum = logRecord->u.delete.splitext.poolBlkNum; node->EXT[scancnt+1].lengthOfExtent = logRecord->u.delete.splitext.lengthOfExtent; @@ -5359,16 +5357,16 @@ STATUS undoFXbalance( else { if (FXBT_IS_LEAF(node)) - { + { if (logRecord->u.balance.orichildnumRecs < logRecord->u.balance.newchildnumRecs) - { + { numToMove = logRecord->u.balance.newchildnumRecs - logRecord->u.balance.orichildnumRecs; bzero(&node->EXT[node->header.numRecs - numToMove], - (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(Extent_s)); + (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(Extent_s)); } else - { + { numToMove = logRecord->u.balance.orichildnumRecs - logRecord->u.balance.newchildnumRecs; /*- move from log to child -*/ @@ -5378,16 +5376,16 @@ STATUS undoFXbalance( } } else - { + { if (logRecord->u.balance.orichildnumRecs < logRecord->u.balance.newchildnumRecs) - { + { numToMove = logRecord->u.balance.newchildnumRecs - logRecord->u.balance.orichildnumRecs; bzero(&node->BRA[node->header.numRecs - numToMove], - (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(xBranch_s)); + (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(xBranch_s)); } else - { + { numToMove = logRecord->u.balance.orichildnumRecs - logRecord->u.balance.newchildnumRecs; /*- move from log to child -*/ @@ -5430,9 +5428,9 @@ STATUS undoFXbalance( else { if (FXBT_IS_LEAF(node)) - { + { if (logRecord->u.balance.orisiblingnumRecs > logRecord->u.balance.newsiblingnumRecs) - { + { numToMove = logRecord->u.balance.orisiblingnumRecs - logRecord->u.balance.newsiblingnumRecs; /*- make room in front of sibling first -*/ @@ -5446,7 +5444,7 @@ STATUS undoFXbalance( logRecord->u.balance.bytestomove); } else - { + { numToMove = logRecord->u.balance.newsiblingnumRecs - logRecord->u.balance.orisiblingnumRecs; /*- clean up sibling -*/ @@ -5455,13 +5453,13 @@ STATUS undoFXbalance( (node->header.numRecs - (numToMove + 1)) * sizeof(Extent_s)); bzero(&node->EXT[node->header.numRecs - numToMove], - (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(Extent_s)); + (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(Extent_s)); } } else - { + { if (logRecord->u.balance.orisiblingnumRecs > logRecord->u.balance.newsiblingnumRecs) - { + { numToMove = logRecord->u.balance.orisiblingnumRecs - logRecord->u.balance.newsiblingnumRecs; /*- make room in front of sibling first -*/ @@ -5475,7 +5473,7 @@ STATUS undoFXbalance( logRecord->u.balance.bytestomove); } else - { + { numToMove = logRecord->u.balance.newsiblingnumRecs - logRecord->u.balance.orisiblingnumRecs; /*- clean up sibling -*/ @@ -5484,7 +5482,7 @@ STATUS undoFXbalance( (node->header.numRecs - (numToMove + 1)) * sizeof(xBranch_s)); bzero(&node->EXT[node->header.numRecs - numToMove], - (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(xBranch_s)); + (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(xBranch_s)); } } @@ -5578,9 +5576,9 @@ STATUS redoFXbalance( else { if (FXBT_IS_LEAF(node)) - { + { if (logRecord->u.balance.orichildnumRecs < logRecord->u.balance.newchildnumRecs) - { + { numToMove = logRecord->u.balance.newchildnumRecs - logRecord->u.balance.orichildnumRecs; /*- move from log to child -*/ @@ -5589,18 +5587,18 @@ STATUS redoFXbalance( logRecord->u.balance.bytestomove); } else - { + { numToMove = logRecord->u.balance.orichildnumRecs - logRecord->u.balance.newchildnumRecs; /*- clean up child -*/ bzero(&node->EXT[node->header.numRecs - numToMove], - (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(Extent_s)); + (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(Extent_s)); } } else - { + { if (logRecord->u.balance.orichildnumRecs < logRecord->u.balance.newchildnumRecs) - { + { numToMove = logRecord->u.balance.newchildnumRecs - logRecord->u.balance.orichildnumRecs; /*- move from log to child -*/ @@ -5609,12 +5607,12 @@ STATUS redoFXbalance( logRecord->u.balance.bytestomove); } else - { + { numToMove = logRecord->u.balance.orichildnumRecs - logRecord->u.balance.newchildnumRecs; /*- clean up child -*/ bzero(&node->EXT[node->header.numRecs - numToMove], - (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(Extent_s)); + (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(Extent_s)); } } node->header.numRecs = logRecord->u.balance.newchildnumRecs; @@ -5651,9 +5649,9 @@ STATUS redoFXbalance( else { if (FXBT_IS_LEAF(node)) - { + { if (logRecord->u.balance.orisiblingnumRecs > logRecord->u.balance.newsiblingnumRecs) - { + { numToMove = logRecord->u.balance.orisiblingnumRecs - logRecord->u.balance.newsiblingnumRecs; /*- clean up sibling -*/ @@ -5662,10 +5660,10 @@ STATUS redoFXbalance( (node->header.numRecs - (numToMove + 1)) * sizeof(Extent_s)); bzero(&node->EXT[node->header.numRecs - numToMove], - (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(Extent_s)); + (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(Extent_s)); } else - { + { numToMove = logRecord->u.balance.newsiblingnumRecs - logRecord->u.balance.orisiblingnumRecs; /*- make room in front of sibling first -*/ @@ -5680,9 +5678,9 @@ STATUS redoFXbalance( } } else - { + { if (logRecord->u.balance.orisiblingnumRecs > logRecord->u.balance.newsiblingnumRecs) - { + { numToMove = logRecord->u.balance.orisiblingnumRecs - logRecord->u.balance.newsiblingnumRecs; /*- clean up sibling -*/ @@ -5691,10 +5689,10 @@ STATUS redoFXbalance( (node->header.numRecs - (numToMove + 1)) * sizeof(xBranch_s)); bzero(&node->EXT[node->header.numRecs - numToMove], - (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(xBranch_s)); + (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(xBranch_s)); } else - { + { numToMove = logRecord->u.balance.newsiblingnumRecs - logRecord->u.balance.orisiblingnumRecs; /*- make room in front of sibling first -*/ @@ -5770,7 +5768,7 @@ STATUS undoFXjoin( memmove(&node->BRA[braindex + 1], /* Destination */ &node->BRA[braindex], /* Source */ (node->header.numRecs - braindex) * sizeof(xBranch_s)); - + node->BRA[braindex].start = logRecord->u.join.oribra.start; node->BRA[braindex].child = logRecord->u.join.oribra.child; node->header.numRecs = logRecord->u.join.oriparentnumRecs; @@ -5808,7 +5806,7 @@ STATUS undoFXjoin( numToMove = logRecord->u.join.newchildnumRecs - logRecord->u.join.orichildnumRecs; bzero(&node->EXT[node->header.numRecs - numToMove], - (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(Extent_s)); + (FXBT_MAXEXTENTS - (node->header.numRecs - numToMove)) * sizeof(Extent_s)); node->header.numRecs = logRecord->u.join.orichildnumRecs; @@ -5816,9 +5814,9 @@ STATUS undoFXjoin( if(logRecord->u.join.mergeflag) { node->EXT[node->header.numRecs - 1].poolBlkNum = - logRecord->u.join.meroriextlt.poolBlkNum; + logRecord->u.join.meroriextlt.poolBlkNum; node->EXT[node->header.numRecs - 1].lengthOfExtent = - logRecord->u.join.meroriextlt.lengthOfExtent; + logRecord->u.join.meroriextlt.lengthOfExtent; } ZLOG_SET_LSN(logBuffer, node->header.lsn, logBlks[1], action); @@ -5865,7 +5863,7 @@ STATUS undoFXjoin( node->EXT[1].poolBlkNum = logRecord->u.join.meroriextrt.poolBlkNum; node->EXT[1].lengthOfExtent = logRecord->u.join.meroriextrt.lengthOfExtent; - + node->header.numRecs++; } @@ -5928,7 +5926,7 @@ STATUS redoFXjoin( memmove(&node->BRA[braindex], /* Destination */ &node->BRA[braindex + 1], /* Source */ (node->header.numRecs - (braindex + 1)) * sizeof(xBranch_s)); - + node->BRA[node->header.numRecs - 1].start = 0; node->BRA[node->header.numRecs - 1].child = 0; node->header.numRecs = logRecord->u.join.newparentnumRecs; @@ -5968,11 +5966,11 @@ STATUS redoFXjoin( if(logRecord->u.join.mergeflag) { node->EXT[node->header.numRecs - 1].poolBlkNum = - logRecord->u.join.mernewext.poolBlkNum; + logRecord->u.join.mernewext.poolBlkNum; node->EXT[node->header.numRecs - 1].lengthOfExtent = - logRecord->u.join.mernewext.lengthOfExtent; + logRecord->u.join.mernewext.lengthOfExtent; } - + numToMove = logRecord->u.join.newchildnumRecs - logRecord->u.join.orichildnumRecs; /*- move from log to child -*/ @@ -6043,13 +6041,13 @@ STATUS undoFXgrow( { // if (!(IS_XLATCHED(&zfspool->freeExtent->ZFSFXbeastLatch))) // { -// ilatchedit = 1; -// X_LATCH(&zfspool->freeExtent->ZFSFXbeastLatch); +// ilatchedit = 1; +// X_LATCH(&zfspool->freeExtent->ZFSFXbeastLatch); // } // // zfspool->freeExtent->zfsBtree.p.btRoot = logBlks[1].blkNum; // COMN_MARK_BEAST_DIRTY(&zfspool->freeExtent->ZFSFXroot); -// +// // if(ilatchedit) // UNX_LATCH(&zfspool->freeExtent->ZFSFXbeastLatch); @@ -6117,8 +6115,8 @@ STATUS redoFXgrow( // if (!(IS_XLATCHED(&zfspool->freeExtent->ZFSFXbeastLatch))) // { -// ilatchedit = 1; -// X_LATCH(&zfspool->freeExtent->ZFSFXbeastLatch); +// ilatchedit = 1; +// X_LATCH(&zfspool->freeExtent->ZFSFXbeastLatch); // } // // zfspool->freeExtent->zfsBtree.p.btRoot = logBlks[0].blkNum; @@ -6259,19 +6257,19 @@ STATUS undoFXsplit( bytesToMove = logRecord->u.split.bytestomove; if (FXBT_IS_LEAF(node)) - { + { /*- move from sibling to child -*/ memmove(&node->EXT[node->header.numRecs], /* Destination */ &logRecord->u.split.data[0], /* Source */ bytesToMove); } else - { + { /*- move from sibling to child -*/ memmove(&node->BRA[node->header.numRecs], /* Destination */ &logRecord->u.split.data[0], /* Source */ bytesToMove); - } + } node->header.state = logRecord->u.split.orisiblingstate; node->header.numRecs = logRecord->u.split.orisiblingnumRecs; @@ -6332,8 +6330,8 @@ STATUS redoFXsplit( braindex = logRecord->u.split.braindex; memmove(&node->BRA[braindex + 1], /* Destination */ - &node->BRA[braindex], /* Source */ - (node->header.numRecs - braindex) * sizeof(xBranch_s)); + &node->BRA[braindex], /* Source */ + (node->header.numRecs - braindex) * sizeof(xBranch_s)); node->BRA[braindex].start = logRecord->u.split.newbra.start; node->BRA[braindex].child = logRecord->u.split.newbra.child; @@ -6371,7 +6369,7 @@ STATUS redoFXsplit( memmove(&node->EXT[1], /* Destination */ &logRecord->u.split.data[0], /* Source */ bytesToMove); - + node->header.numRecs = logRecord->u.split.newchildnumRecs; ZLOG_SET_LSN(logBuffer, node->header.lsn, logBlks[1], action); @@ -6449,7 +6447,7 @@ STATUS undoFXinsertLogical( { STATUS status; FXlog_s *logRec; - ZfsXaction_s *xaction; + ZfsXaction_s *xaction; ZioTh_s zio, ziof; FreeUserDataBlks_s *free; @@ -6462,19 +6460,19 @@ STATUS undoFXinsertLogical( return zX_LOGICAL; } - xaction = BeginXLocal(&zfspool->ZFSPOOLvol, - BXL_LOGICAL_UNDO|BXL_LOGICAL_UNDO_FREE_TREE_INSERT); + xaction = BeginXLocal(&zfspool->ZFSPOOLvol, + BXL_LOGICAL_UNDO|BXL_LOGICAL_UNDO_FREE_TREE_INSERT); /* Alloc extent deletes this extent from the free tree. When redo - * completed it guaranteed that the blocks we are looking for were - * put in the free tree. So alloc extent should be able to delete - * them. - */ + * completed it guaranteed that the blocks we are looking for were + * put in the free tree. So alloc extent should be able to delete + * them. + */ zASSERT(logRec->u.insert.insExt.poolBlkNum != 0); zASSERT(logRec->u.insert.insExt.lengthOfExtent != 0); - INIT_ZIO_TH(&zio, genMsg, zfspool->freeExtent, - logRec->u.insert.insExt.poolBlkNum, + INIT_ZIO_TH(&zio, genMsg, zfspool->freeExtent, + logRec->u.insert.insExt.poolBlkNum, logRec->u.insert.insExt.lengthOfExtent, xaction); status = ZFSPOOL_AllocExtent(&zio, &zfspool->ZFSPOOLzfsVol); @@ -6488,11 +6486,11 @@ STATUS undoFXinsertLogical( return zFAILURE; } - DQ_FOREACH(&zfspool->freeDataBlksList, free, - FreeUserDataBlks_s, globalListLink) + DQ_FOREACH(&zfspool->freeDataBlksList, free, + FreeUserDataBlks_s, globalListLink) { if ((free->freeExt.poolBlkNum == logRec->u.insert.insExt.poolBlkNum) && - (free->freeExt.lengthOfExtent == + (free->freeExt.lengthOfExtent == logRec->u.insert.insExt.lengthOfExtent)) { DQ_RMV(free, globalListLink); @@ -6510,22 +6508,22 @@ STATUS undoFXinsertLogical( Extent_s delExt; - if (zio.extent.lengthOfExtent < + if (zio.extent.lengthOfExtent < logRec->u.insert.insExt.lengthOfExtent) { zASSERT(zio.extent.lengthOfExtent > logRec->u.insert.insExt.lengthOfExtent); return zFAILURE; } - delExt.poolBlkNum = zio.extent.poolBlkNum + + delExt.poolBlkNum = zio.extent.poolBlkNum + logRec->u.insert.insExt.lengthOfExtent; - delExt.lengthOfExtent = zio.extent.lengthOfExtent - + delExt.lengthOfExtent = zio.extent.lengthOfExtent - logRec->u.insert.insExt.lengthOfExtent; xaction = BeginXLocal(&zfspool->ZFSPOOLvol, BXL_LOGICAL_UNDO); XACT_holdFreeUserDataBlks(&delExt, xaction); - INIT_ZIO_TH(&ziof, genMsg, zfspool->freeExtent, + INIT_ZIO_TH(&ziof, genMsg, zfspool->freeExtent, delExt.poolBlkNum, delExt.lengthOfExtent, xaction); - + while (ziof.extent.lengthOfExtent != 0) { status = ZFSPOOL_FreeExtent(&ziof, &zfspool->ZFSPOOLzfsVol); @@ -6535,9 +6533,9 @@ STATUS undoFXinsertLogical( EndXlocal(xaction); return(status); } - ziof.extent.poolBlkNum = delExt.poolBlkNum + + ziof.extent.poolBlkNum = delExt.poolBlkNum + ziof.extent.lengthOfExtent; - ziof.extent.lengthOfExtent = delExt.lengthOfExtent - + ziof.extent.lengthOfExtent = delExt.lengthOfExtent - ziof.extent.lengthOfExtent; delExt.lengthOfExtent = ziof.extent.lengthOfExtent; delExt.poolBlkNum = ziof.extent.poolBlkNum; @@ -6582,7 +6580,7 @@ STATUS undoFXinsert( return(zFAILURE); } node = (xNode_s *)buffer->pBuf.data; - + #if NSS_DEBUG IS_ENABLED VerifyFXnode(node, FXVERIFYEXIT); #endif @@ -6597,14 +6595,14 @@ STATUS undoFXinsert( //DebugPrintf(YELLOW, MSGNot("Undo Insert. scancnt=%d insertaction=%x\n"), scancnt, // insertaction); if(insertaction == FXBT_MERGELEFT) - { + { node->EXT[scancnt - 1].poolBlkNum = logRecord->u.insert.oriextlt.poolBlkNum; node->EXT[scancnt - 1].lengthOfExtent = logRecord->u.insert.oriextlt.lengthOfExtent; } else - { + { if(insertaction == FXBT_MERGELEFTTHENRIGHT) - { + { /*- shift all records to right -*/ memmove(&node->EXT[scancnt + 1], /*- destination -*/ &node->EXT[scancnt], /*- source -*/ @@ -6617,34 +6615,34 @@ STATUS undoFXinsert( node->EXT[scancnt].lengthOfExtent = logRecord->u.insert.oriextrt.lengthOfExtent; } else - { + { if(insertaction == FXBT_MERGERIGHT) - { + { node->EXT[scancnt].poolBlkNum = logRecord->u.insert.oriextrt.poolBlkNum; node->EXT[scancnt].lengthOfExtent = logRecord->u.insert.oriextrt.lengthOfExtent; } else - { + { if(insertaction == FXBT_INSERTATRIGHT) - { + { /*- shift all records to left -*/ memmove(&node->EXT[scancnt], /*- destination -*/ - &node->EXT[scancnt + 1], /*- source -*/ - (node->header.numRecs - (scancnt + 1)) * sizeof(Extent_s)); + &node->EXT[scancnt + 1], /*- source -*/ + (node->header.numRecs - (scancnt + 1)) * sizeof(Extent_s)); node->EXT[node->header.numRecs - 1].poolBlkNum = 0; node->EXT[node->header.numRecs - 1].lengthOfExtent = 0; node->header.numRecs--; } else - { + { if(insertaction == FXBT_INSERTAPPEND) - { + { node->EXT[scancnt].poolBlkNum = logRecord->u.insert.oriextrt.poolBlkNum; node->EXT[scancnt].lengthOfExtent = logRecord->u.insert.oriextrt.lengthOfExtent; } else - { + { /*- undo never happend -*/ zASSERT(0); } @@ -6713,54 +6711,54 @@ STATUS redoFXinsert( //DebugPrintf(YELLOW, MSGNot("Redo Insert. scancnt=%d insertaction=%x\n"), scancnt, // insertaction); if(insertaction == FXBT_MERGELEFT) - { + { node->EXT[scancnt - 1].poolBlkNum = logRecord->u.insert.newextlt.poolBlkNum; node->EXT[scancnt - 1].lengthOfExtent = logRecord->u.insert.newextlt.lengthOfExtent; } else - { + { if(insertaction == FXBT_MERGELEFTTHENRIGHT) - { + { node->EXT[scancnt - 1].poolBlkNum = logRecord->u.insert.newextlt.poolBlkNum; node->EXT[scancnt - 1].lengthOfExtent = logRecord->u.insert.newextlt.lengthOfExtent; /*- shift all records to left and set last record to default -*/ memmove(&node->EXT[scancnt], /*- destination -*/ - &node->EXT[scancnt + 1], /*- source -*/ - (node->header.numRecs - (scancnt + 1)) * sizeof(Extent_s)); + &node->EXT[scancnt + 1], /*- source -*/ + (node->header.numRecs - (scancnt + 1)) * sizeof(Extent_s)); node->EXT[node->header.numRecs - 1].poolBlkNum = 0; node->EXT[node->header.numRecs - 1].lengthOfExtent = 0; node->header.numRecs--; } else - { + { if (insertaction == FXBT_MERGERIGHT) - { + { node->EXT[scancnt].poolBlkNum = logRecord->u.insert.newextrt.poolBlkNum; node->EXT[scancnt].lengthOfExtent = logRecord->u.insert.newextrt.lengthOfExtent; } else - { + { if (insertaction == FXBT_INSERTATRIGHT) - { + { /*- shift all records to right and insert new record -*/ memmove(&node->EXT[scancnt + 1], /*- destination -*/ - &node->EXT[scancnt], /*- source -*/ - (node->header.numRecs - scancnt) * sizeof(Extent_s)); + &node->EXT[scancnt], /*- source -*/ + (node->header.numRecs - scancnt) * sizeof(Extent_s)); node->EXT[scancnt].poolBlkNum = logRecord->u.insert.newext.poolBlkNum; node->EXT[scancnt].lengthOfExtent = logRecord->u.insert.newext.lengthOfExtent; } else - { + { if (insertaction == FXBT_INSERTAPPEND) - { + { node->EXT[scancnt].poolBlkNum = logRecord->u.insert.newextrt.poolBlkNum; node->EXT[scancnt].lengthOfExtent = logRecord->u.insert.newextrt.lengthOfExtent; } else - { + { /*- undo never happend -*/ zASSERT(0); } @@ -6812,7 +6810,7 @@ STATUS ZFSFREEEXT_Construct( // memset(xtree->ZFE_AreaSizeCounts, 0, sizeof(tree->ZFE_AreaSizeCounts) ); // memset(xtree->ZFE_AreaSizeCountsTrack, FALSE, sizeof(tree->ZFE_AreaSizeCountsTrack) ); // FSMLITE_INIT(&xtree->wtdFsm, MSGNot("SpecialFreeTreeBlkFSM"), 0); - fillInWork(&xtree->xtreeWtd, (voidfunc_t)CheckSpecialBlkWTD, 0); + fillInWork(&xtree->xtreeWtd, CheckSpecialBlkWTD, 0); return zOK; } @@ -6897,7 +6895,7 @@ STATIC BYTE *ZFSFREEEXT_Pack( +-------------------------------------------------------------------------*/ STATIC BYTE *ZFSFREEEXT_Unpack( GeneralMsg_s *genMsg, - void *beast_LX, + void *beast_LX, BYTE *storeBuffer) { ASSERT_MPKNSS_LOCK(); @@ -6919,3 +6917,5 @@ LSSSpecificPackUnpackOps_s ZFSFREEEXT_lssOps[] = {zLSS_ID_ZLSS,ZFSFREEEXT_PackedSize,ZFSFREEEXT_Pack,NULL,ZFSFREEEXT_Unpack}, {zLSS_ID_INVALID} }; + + diff --git a/src/nwnss/zlss/zfsXTree.h b/src/nwnss/zlss/zfsXTree.h index 0a384b3..885f77a 100644 --- a/src/nwnss/zlss/zfsXTree.h +++ b/src/nwnss/zlss/zfsXTree.h @@ -20,7 +20,7 @@ | |*************************************************************************** | - | NetWare Storage Services (NSS) + | NetWare Storage Services (NSS) | |--------------------------------------------------------------------------- | @@ -69,24 +69,24 @@ #define FXBT_MINEXTENTS 100 #define FXBT_MINBRANCHES 100 - /* August 10, 2001 - * Increased from 20 to 50 because rebuild caused as to run - * out of blocks doing a lot of splits. We worried that - * this could also happen in 'normal' code so we increased. - * Rebuild was fixed by checking if special blocks are - * needed and waiting for them. - * - * August 10, 2008 - * Increased from 50 to 256 because Linux Customer was running - * out on truncates of large fragmented files. Testing was - * also hitting when they ran the new fragment FS tool and then - * did truncates(delete). - */ + /* August 10, 2001 + * Increased from 20 to 50 because rebuild caused as to run + * out of blocks doing a lot of splits. We worried that + * this could also happen in 'normal' code so we increased. + * Rebuild was fixed by checking if special blocks are + * needed and waiting for them. + * + * August 10, 2008 + * Increased from 50 to 256 because Linux Customer was running + * out on truncates of large fragmented files. Testing was + * also hitting when they ran the new fragment FS tool and then + * did truncates(delete). + */ #define FXBT_MINBLKS_SPECIAL 256 // Do not increase to more than FXBT_MAXEXTENTS-1 - // without code changes because code assumes that - // all the blocks are in one FT leaf. The minus - // one is needed because of the (0,0) entry in all - // FT leafs. + // without code changes because code assumes that + // all the blocks are in one FT leaf. The minus + // one is needed because of the (0,0) entry in all + // FT leafs. /*- macros for xtree -*/ #define FXBT_IS_LEAF(_n) ((_n)->header.state & FXBT_LEAF) @@ -95,69 +95,69 @@ #define FXBT_IS_MAX_XBRANCHES(_node) \ - (FXBT_IS_LEAF(_node) \ - ? ((_node)->header.numRecs == FXBT_MAXEXTENTS) \ - : ((_node)->header.numRecs == FXBT_MAXBRANCHES)) + (FXBT_IS_LEAF(_node) \ + ? ((_node)->header.numRecs == FXBT_MAXEXTENTS) \ + : ((_node)->header.numRecs == FXBT_MAXBRANCHES)) #define FXBT_IS_MIN_XBRANCHES(_node) \ - (FXBT_IS_LEAF(_node) \ - ? ((_node)->header.numRecs <= FXBT_MINEXTENTS) \ - : ((_node)->header.numRecs <= FXBT_MINBRANCHES)) + (FXBT_IS_LEAF(_node) \ + ? ((_node)->header.numRecs <= FXBT_MINEXTENTS) \ + : ((_node)->header.numRecs <= FXBT_MINBRANCHES)) #define FXBT_IS_LESSTHAN_MAX(_node, _sibling) \ - (FXBT_IS_LEAF(_node) \ - ? (((_node)->header.numRecs + (_sibling)->header.numRecs) < FXBT_MAXEXTENTS) \ - : (((_node)->header.numRecs + (_sibling)->header.numRecs) < FXBT_MAXBRANCHES)) + (FXBT_IS_LEAF(_node) \ + ? (((_node)->header.numRecs + (_sibling)->header.numRecs) < FXBT_MAXEXTENTS) \ + : (((_node)->header.numRecs + (_sibling)->header.numRecs) < FXBT_MAXBRANCHES)) #define FXBT_IS_LESSTHAN_JOINMAX(_node, _sibling) \ - (FXBT_IS_LEAF(_node) \ - ? (((_node)->header.numRecs + (_sibling)->header.numRecs) < FXBT_MAXEXTENTS75) \ - : (((_node)->header.numRecs + (_sibling)->header.numRecs) < FXBT_MAXBRANCHES75)) + (FXBT_IS_LEAF(_node) \ + ? (((_node)->header.numRecs + (_sibling)->header.numRecs) < FXBT_MAXEXTENTS75) \ + : (((_node)->header.numRecs + (_sibling)->header.numRecs) < FXBT_MAXBRANCHES75)) -/************************************************************************* +/************************************************************************* ** This macro will count the total number of free blks available in the ** specified free tree leaf node. numRecs is the count of extents. *************************************************************************/ #define FXBT_NUM_BLKS(_node, _nBlks) \ { \ - NINT _i; \ - for (_nBlks = 0, _i = 1; _i < _node->header.numRecs; _i++) \ - _nBlks += node->n.extents[_i].lengthOfExtent; \ + NINT _i; \ + for (_nBlks = 0, _i = 1; _i < _node->header.numRecs; _i++) \ + _nBlks += node->n.extents[_i].lengthOfExtent; \ } /*- xtree structure defs -*/ typedef struct xNodeHeader_s { - LONG magic; - WORD state; - WORD numRecs; - Lsn_t lsn; /* Must be at OFFEST 8 - log sequence number */ - GUID_t xnh_internalID; /* Must be at OFFSET 16 - unique internal ID (used - * by scanning repair). xnh is x Node Header. - */ + LONG magic; + WORD state; + WORD numRecs; + Lsn_t lsn; /* Must be at OFFEST 8 - log sequence number */ + GUID_t xnh_internalID; /* Must be at OFFSET 16 - unique internal ID (used + * by scanning repair). xnh is x Node Header. + */ - WORD nextrec; - WORD pad; /* Put on LONG boundary */ - LONG pad2; /* Put on QUAD boundary */ + WORD nextrec; + WORD pad; /* Put on LONG boundary */ + LONG pad2; /* Put on QUAD boundary */ } NSS_MEDIA_STRUCTURE(xNodeHeader_s,pad2) xNodeHeader_s; /*- sizeof(xBranch_s) == sizeof(Extent_s), they can not be different -*/ typedef struct xBranch_s { - Blknum_t start; - Blknum_t child; + Blknum_t start; + Blknum_t child; } NSS_MEDIA_STRUCTURE(xBranch_s,child) xBranch_s; typedef struct xNode_s { - xNodeHeader_s header; - union - { - Extent_s extents[FXBT_MAXEXTENTS]; - xBranch_s branch[FXBT_MAXBRANCHES]; - } NSS_MEDIA_UNION(NamelessUnion,branch[FXBT_MAXBRANCHES]) n; + xNodeHeader_s header; + union + { + Extent_s extents[FXBT_MAXEXTENTS]; + xBranch_s branch[FXBT_MAXBRANCHES]; + } NSS_MEDIA_UNION(NamelessUnion,branch[FXBT_MAXBRANCHES]) n; } NSS_MEDIA_STRUCTURE(xNode_s,n.branch[FXBT_MAXBRANCHES]) xNode_s; @@ -183,28 +183,28 @@ enum { Validate_xBranch_s_Extent_s = 1/((sizeof(xBranch_s) == sizeof(Extent_s)) typedef struct ZioTh_s { - GeneralMsg_s *genMsg; - Blknum_t childBlk; - Buffer_s *child; - Buffer_s *sibling; - Buffer_s *parent; - NINT index; - Extent_s extent; - struct ZfsXaction_s *xaction; - struct ZfsFreeExtent_s *xtree; - NINT zt_flags; + GeneralMsg_s *genMsg; + Blknum_t childBlk; + Buffer_s *child; + Buffer_s *sibling; + Buffer_s *parent; + NINT index; + Extent_s extent; + struct ZfsXaction_s *xaction; + struct ZfsFreeExtent_s *xtree; + NINT zt_flags; #define ZT_FLAGS_NEAR_MATCH 0x00000001 /* On block allocate, - try to find a block in the area */ + try to find a block in the area */ #define ZT_FLAGS_GLOBAL_SEED 0x00000002 /* We are using GlobalSeed */ } ZioTh_s; #define INIT_ZIO_TH(_zio, _genMsg, _xtree, _blkNum, _extLen, _xact) \ { \ - (_zio)->genMsg = (_genMsg); \ - (_zio)->xtree = (_xtree); \ - (_zio)->extent.poolBlkNum = (_blkNum); \ - (_zio)->extent.lengthOfExtent = (_extLen); \ - (_zio)->xaction = (_xact); \ + (_zio)->genMsg = (_genMsg); \ + (_zio)->xtree = (_xtree); \ + (_zio)->extent.poolBlkNum = (_blkNum); \ + (_zio)->extent.lengthOfExtent = (_extLen); \ + (_zio)->xaction = (_xact); \ (_zio)->zt_flags = 0; \ } @@ -229,96 +229,96 @@ typedef struct ZioTh_s /*- log data structures -*/ - /*- shrink has no structure -*/ + /*- shrink has no structure -*/ -typedef struct FXdelete_s +typedef struct FXdelete_s { - Extent_s oriext; - Extent_s newext; - Extent_s splitext; - WORD orinumRecs; - WORD newnumRecs; - WORD recnuml; - WORD recnumb; - xBranch_s oribra; - xBranch_s newbra; - Extent_s delExt; + Extent_s oriext; + Extent_s newext; + Extent_s splitext; + WORD orinumRecs; + WORD newnumRecs; + WORD recnuml; + WORD recnumb; + xBranch_s oribra; + xBranch_s newbra; + Extent_s delExt; } NSS_MEDIA_STRUCTURE(FXdelete_s,delExt) FXdelete_s; -typedef struct FXbalance_s +typedef struct FXbalance_s { - WORD recnum; - WORD bytestomove; - WORD orichildnumRecs; - WORD newchildnumRecs; - WORD orisiblingnumRecs; - WORD newsiblingnumRecs; - WORD braindex; - xBranch_s oribra; - xBranch_s newbra; - BYTE data[1]; + WORD recnum; + WORD bytestomove; + WORD orichildnumRecs; + WORD newchildnumRecs; + WORD orisiblingnumRecs; + WORD newsiblingnumRecs; + WORD braindex; + xBranch_s oribra; + xBranch_s newbra; + BYTE data[1]; } NSS_MEDIA_STRUCTURE(FXbalance_s,data[1]) FXbalance_s; -typedef struct FXjoin_s +typedef struct FXjoin_s { - WORD orisiblingstate; - WORD orichildnumRecs; - WORD newchildnumRecs; - WORD oriparentnumRecs; - WORD newparentnumRecs; - WORD braindex; - xBranch_s oribra; - Extent_s meroriextlt; - Extent_s meroriextrt; - Extent_s mernewext; - LONG mergeflag; - BYTE data[1]; + WORD orisiblingstate; + WORD orichildnumRecs; + WORD newchildnumRecs; + WORD oriparentnumRecs; + WORD newparentnumRecs; + WORD braindex; + xBranch_s oribra; + Extent_s meroriextlt; + Extent_s meroriextrt; + Extent_s mernewext; + LONG mergeflag; + BYTE data[1]; } NSS_MEDIA_STRUCTURE(FXjoin_s,data[1]) FXjoin_s; -typedef struct FXgrow_s +typedef struct FXgrow_s { - WORD orichildstate; - WORD newparentstate; - WORD newparentnumRecs; - xBranch_s oribra; + WORD orichildstate; + WORD newparentstate; + WORD newparentnumRecs; + xBranch_s oribra; } NSS_MEDIA_STRUCTURE(FXgrow_s,oribra) FXgrow_s; -typedef struct FXsplit_s +typedef struct FXsplit_s { - WORD orisiblingstate; - WORD orisiblingnumRecs; - WORD bytestomove; - WORD newchildnumRecs; - WORD braindex; - xBranch_s newbra; - BYTE data[1]; + WORD orisiblingstate; + WORD orisiblingnumRecs; + WORD bytestomove; + WORD newchildnumRecs; + WORD braindex; + xBranch_s newbra; + BYTE data[1]; } NSS_MEDIA_STRUCTURE(FXsplit_s,data[1]) FXsplit_s; -typedef struct FXinsert_s +typedef struct FXinsert_s { - WORD extindex; - WORD orinumRecs; - WORD newnumRecs; - WORD action; - Extent_s oriextlt; - Extent_s oriextrt; - Extent_s newextlt; - Extent_s newextrt; - Extent_s newext; - Extent_s insExt; + WORD extindex; + WORD orinumRecs; + WORD newnumRecs; + WORD action; + Extent_s oriextlt; + Extent_s oriextrt; + Extent_s newextlt; + Extent_s newextrt; + Extent_s newext; + Extent_s insExt; } NSS_MEDIA_STRUCTURE(FXinsert_s,insExt) FXinsert_s; -typedef struct FXlog_s +typedef struct FXlog_s { - union - { - FXdelete_s delete; - FXbalance_s balance; - FXjoin_s join; - FXgrow_s grow; - FXsplit_s split; - FXinsert_s insert; - } NSS_MEDIA_STRUCTURE(u,insert) u; + union + { + FXdelete_s delete; + FXbalance_s balance; + FXjoin_s join; + FXgrow_s grow; + FXsplit_s split; + FXinsert_s insert; + } NSS_MEDIA_STRUCTURE(u,insert) u; } NSS_MEDIA_STRUCTURE(FXlog_s,u.insert) FXlog_s; @@ -333,69 +333,69 @@ typedef struct FXlog_s +-------------------------------------------------------------------------*/ extern STATUS zfsAllocExtent( - GeneralMsg_s *genMsg, - ZfsVolume_s *zfsVol, - Extent_s *request, - NINT allocFlags, - ZfsXaction_s *xaction); + GeneralMsg_s *genMsg, + ZfsVolume_s *zfsVol, + Extent_s *request, + NINT allocFlags, + ZfsXaction_s *xaction); extern STATUS zfsAllocExtentFromSpecialBlk( - GeneralMsg_s *genMsg, - ZfsVolume_s *zfsVol, - Extent_s *request, - ZfsXaction_s *xaction, - Buffer_s **specialBuffer); + GeneralMsg_s *genMsg, + ZfsVolume_s *zfsVol, + Extent_s *request, + ZfsXaction_s *xaction, + Buffer_s **specialBuffer); extern STATUS ZFSPOOL_AllocExtent(ZioTh_s *zio, ZfsVolume_s *zfsVol); extern STATUS zfsFreeExtent( - GeneralMsg_s *genMsg, - ZfsVolume_s *zfsVol, - Extent_s *request, - ZfsXaction_s *xaction); + GeneralMsg_s *genMsg, + ZfsVolume_s *zfsVol, + Extent_s *request, + ZfsXaction_s *xaction); STATUS zfsFreePoolExtent( - GeneralMsg_s *genMsg, - ZfsPool_s *poolVolume, - Extent_s *request, - ZfsXaction_s *xaction); + GeneralMsg_s *genMsg, + ZfsPool_s *poolVolume, + Extent_s *request, + ZfsXaction_s *xaction); extern STATUS ZFSPOOL_FreeExtent(ZioTh_s *zio, ZfsVolume_s *zfsVol); extern STATUS InitRootNode( - GeneralMsg_s *genMsg, - ZfsFreeExtent_s *beast, - Blknum_t poolblk); + GeneralMsg_s *genMsg, + ZfsFreeExtent_s *beast, + Blknum_t poolblk); extern STATUS InitSpecialNode( - GeneralMsg_s *genMsg, - ZfsFreeExtent_s *beast, - Blknum_t poolblk); + GeneralMsg_s *genMsg, + ZfsFreeExtent_s *beast, + Blknum_t poolblk); extern STATUS Add2BlksToSpecialNode( - GeneralMsg_s *genMsg, - ZfsFreeExtent_s *beast, - Blknum_t spBlk, - Blknum_t blk1, - Blknum_t blk2); + GeneralMsg_s *genMsg, + ZfsFreeExtent_s *beast, + Blknum_t spBlk, + Blknum_t blk1, + Blknum_t blk2); extern void CheckSpecialBlkAndAdd( - ZfsPool_s *pool, - Extent_s *allocExtent, - LONG flags); + ZfsPool_s *pool, + Extent_s *allocExtent, + LONG flags); #define XTREE_SPBLK_XACTION 0x00000001 #define XTREE_SPBLK_THREAD_SCH 0x00000002 extern Blknum_t getABlkFromSpecialBlk( - Blknum_t specialBlk, - ZfsFreeExtent_s *xtree, - ZfsXaction_s *xaction, - Buffer_s **specialBuf); + Blknum_t specialBlk, + ZfsFreeExtent_s *xtree, + ZfsXaction_s *xaction, + Buffer_s **specialBuf); extern BOOL FT_ExtentIsStillFree( - ZfsPool_s *pool, - Extent_s *extent); + ZfsPool_s *pool, + Extent_s *extent); #if NSS_DEBUG IS_ENABLED void VerifyFXnode(xNode_s *node, NINT action); diff --git a/src/nwnss/zlss/zfsdefs.h b/src/nwnss/zlss/zfsdefs.h index b3c4e57..1bc5fb8 100644 --- a/src/nwnss/zlss/zfsdefs.h +++ b/src/nwnss/zlss/zfsdefs.h @@ -77,7 +77,7 @@ typedef SNINT node_ind_t; #define NAMECMP_EXACT unicmp -typedef struct NameTreeParms_s +typedef struct NameTreeParms_s { GeneralMsg_s *genMsg; ZfsNameTree_s *ntree; @@ -125,7 +125,7 @@ typedef struct NameTreeParms_s (((_sm)->options & SMAPOPT_matchAllEntries) || \ (_pcmpfn)(_pat, (_e)->k.name, \ (_e)->k.namelen & ~(NAMEnameLenMask|NAMEool)))) - + #define MODE_NONE 0 #define MODE_READ CACHE_READ #define MODE_WRITE CACHE_WRITE @@ -170,18 +170,18 @@ typedef struct NameTreeParms_s #if NSS_DEBUG IS_ENABLED extern STATUS fetch_ntree_blk( - NameTreeParms_s *_parms, - Blknum_t _blk, - Buffer_s **_buf, - Latch_mode_t _mode, + NameTreeParms_s *_parms, + Blknum_t _blk, + Buffer_s **_buf, + Latch_mode_t _mode, BOOL verify_magic, - NINT _debug_id); + NINT _debug_id); #else extern STATUS fetch_ntree_blk( - NameTreeParms_s *_parms, - Blknum_t _blk, - Buffer_s **_buf, - Latch_mode_t _mode, + NameTreeParms_s *_parms, + Blknum_t _blk, + Buffer_s **_buf, + Latch_mode_t _mode, BOOL verify_magic); #endif @@ -190,95 +190,95 @@ extern STATUS node_verify_magic( Buffer_s *buf); extern STATUS alloc_ntree_blks( - NameTreeParms_s *_parms, - ZfsXaction_s *_xact, + NameTreeParms_s *_parms, + ZfsXaction_s *_xact, NINT nblks, - Buffer_s **_buf); + Buffer_s **_buf); /* Prototypes for naming btree SNINTerface functions to the rest of ZFS */ extern Zid_t ZFSVOL_VOL_LookupByNameInDirectory( - struct GeneralMsg_s *genMsg, - struct NamedBeast_s *directory, - struct NameSpace_s *nameSpace, - NINT nameType, - unicode_t *name, + struct GeneralMsg_s *genMsg, + struct NamedBeast_s *directory, + struct NameSpace_s *nameSpace, + NINT nameType, + unicode_t *name, // cnt NINT nameUniquifier, // cnt NINT *retNameUniquifier, - struct FullDirectoryInfo_s *retInfo); /* may be null */ + struct FullDirectoryInfo_s *retInfo); /* may be null */ //extern STATUS ZFSVOL_InitDirectory( -// struct GeneralMsg_s *genMsg, +// struct GeneralMsg_s *genMsg, // struct NamedBeast_s *directory); extern NINT ZFSVOL_VOL_IsDirectoryEmpty( - struct GeneralMsg_s *genMsg, - struct NamedBeast_s *directory, + struct GeneralMsg_s *genMsg, + struct NamedBeast_s *directory, NINT nameType); extern STATUS ZFSVOL_VOL_AddNameToDirectory( - struct GeneralMsg_s *genMsg, - struct NamedBeast_s *beast, - struct NamedBeast_s *directory, - NINT nameSpaceMask, - NINT nameType, - unicode_t *name, - NINT nsFlags, + struct GeneralMsg_s *genMsg, + struct NamedBeast_s *beast, + struct NamedBeast_s *directory, + NINT nameSpaceMask, + NINT nameType, + unicode_t *name, + NINT nsFlags, // cnt NINT nameUniquifier, - NINT addNameFlags, - NINT matchAttributes, - Xaction_s *xaction, - TypeSpecificPersistentParentEntry_s *nameTypeInfo); + NINT addNameFlags, + NINT matchAttributes, + Xaction_s *xaction, + TypeSpecificPersistentParentEntry_s *nameTypeInfo); extern STATUS ZFSVOL_VOL_RemoveNameFromDirectory( - struct GeneralMsg_s *genMsg, - Zid_t beastZid, - struct NamedBeast_s *directory, - NINT nameSpaceMask, - NINT nameType, - unicode_t *name, + struct GeneralMsg_s *genMsg, + Zid_t beastZid, + struct NamedBeast_s *directory, + NINT nameSpaceMask, + NINT nameType, + unicode_t *name, // cnt NINT nameUniquifier, - NINT removeNameFlags, - Xaction_s *xaction, - TypeSpecificPersistentParentEntry_s *nameTypeInfo); + NINT removeNameFlags, + Xaction_s *xaction, + TypeSpecificPersistentParentEntry_s *nameTypeInfo); extern STATUS ZFSVOL_VOL_ModifyNameSpaceMaskInDirectory( - struct GeneralMsg_s *genMsg, - struct NamedBeast_s *beast, - struct NamedBeast_s *directory, - NINT curNameSpaceMask, - NINT nameType, - unicode_t *curName, + struct GeneralMsg_s *genMsg, + struct NamedBeast_s *beast, + struct NamedBeast_s *directory, + NINT curNameSpaceMask, + NINT nameType, + unicode_t *curName, // cnt NINT nameUniquifier, - NINT newNameSpaceMask, - Xaction_s *xaction); + NINT newNameSpaceMask, + Xaction_s *xaction); extern STATUS ZFSVOL_VOL_SetMatchAttributesInDirectory( - struct GeneralMsg_s *genMsg, - struct NamedBeast_s *beast, - struct NamedBeast_s *directory, - NINT nameSpaceMask, - NINT nameType, - unicode_t *name, + struct GeneralMsg_s *genMsg, + struct NamedBeast_s *beast, + struct NamedBeast_s *directory, + NINT nameSpaceMask, + NINT nameType, + unicode_t *name, // cnt NINT nameUniquifier, - NINT newMatchAttributes, - Xaction_s *xaction); /* may be NULL */ + NINT newMatchAttributes, + Xaction_s *xaction); /* may be NULL */ extern Zid_t ZFSVOL_VOL_WildcardLookup( - struct GeneralMsg_s *genMsg, - struct NamedBeast_s *directory, - struct NameSpace_s *nameSpace, - NINT nameType, - unicode_t *pattern, - struct SearchMap_s *smap, + struct GeneralMsg_s *genMsg, + struct NamedBeast_s *directory, + struct NameSpace_s *nameSpace, + NINT nameType, + unicode_t *pattern, + struct SearchMap_s *smap, // cnt NINT *retNameUniquifier, - struct FullDirectoryInfo_s *retInfo); /* may be null */ + struct FullDirectoryInfo_s *retInfo); /* may be null */ extern STATUS ZFSVOL_VOL_FCNTL( - struct GeneralMsg_s *genMsg, - struct Volume_s *volume, - NINT opCode, - FCNTL_In_s *data, - FCNTL_Out_s *retData, /* may be NULL */ - Xaction_s *xaction); /* may be NULL */ + struct GeneralMsg_s *genMsg, + struct Volume_s *volume, + NINT opCode, + FCNTL_In_s *data, + FCNTL_Out_s *retData, /* may be NULL */ + Xaction_s *xaction); /* may be NULL */ #endif /* _ZFSDEFS_H_ */ diff --git a/src/nwnss/zlss/zio.c b/src/nwnss/zlss/zio.c index 0de1701..7bbc434 100644 --- a/src/nwnss/zlss/zio.c +++ b/src/nwnss/zlss/zio.c @@ -34,17 +34,12 @@ | This module is used to: | Defines routines to manage pool block io. +-------------------------------------------------------------------------*/ -#if !defined(NSS_USERSPACE) #include #include #include #include -#else -struct block_device; -#endif #include -#include #include #include #include @@ -72,16 +67,7 @@ struct block_device; #include "z_aes.h" -#if defined(NSS_USERSPACE) -#ifndef READ -#define READ 0 -#endif -#ifndef WRITE -#define WRITE 1 -#endif -#endif - -#if defined(__linux__) && !defined(NSS_USERSPACE) +#ifdef __linux__ #if zLINUX_2_6 #include #endif @@ -105,7 +91,7 @@ struct block_device; #ifdef USER_GPACHNER #if NSS_DEBUG IS_ENABLED -#ifndef __linux__ +#ifndef __linux__ void ReBoot(void); /* Reboots a PC - taken from crashNMIShell.386 */ #pragma aux ReBoot = \ @@ -157,17 +143,17 @@ NINT RWErrTestSeed = 0; NINT RWErrTestInterval = 1; /* WRite debug globals */ NINT WRTestCnt = 0; /* Number of writes that we have done while - * WRErrTestSeed is non-zero. - */ -NINT WRErrTestSeed = 0; /* The write number to start failing on. - * The value zero idicates we will not - * simulate write failures. - */ + * WRErrTestSeed is non-zero. + */ +NINT WRErrTestSeed = 0; /* The write number to start failing on. + * The value zero idicates we will not + * simulate write failures. + */ NINT WRErrTestInterval = 1; /* Frequency of which write calls will - * fail. Note that ZLSS attempts to - * never do another REAL write attempt - * after detecting a failure. - */ + * fail. Note that ZLSS attempts to + * never do another REAL write attempt + * after detecting a failure. + */ QUAD gSBD_WriteCrashFailureCount = 0; /* This is filled in at pool load time */ @@ -195,7 +181,7 @@ NINT CurrentWriteCount = 0; * key is also stored in memory to be used during later volume activations, while the password is discarded. When a volume * is enabled, if a key is already present, it is used for further volume operations. If no key is present, a password is * required. If no volume password is present, the activate fails and upper layer software will prompt for a password and - * try again. Once the password is present, it is used to unwrap the key stored in the VDB. When non-system data blocks + * try again. Once the password is present, it is used to unwrap the key stored in the VDB. When non-system data blocks * (as defined by the ZLSS_IS_SYSTEM_BLOCK macro)are read or written to an encrypted volume, the data are converted from * plain text to crypto just before the physical write, and decrypted on read before they go into the cache. A list of * dedicated buffers are used to hold the crypto data for the time it is being used. Because the list of volume/key pairs @@ -215,7 +201,7 @@ NINT CurrentWriteCount = 0; *****************************************************************************/ static STATUS ZFS_E_Buf( Volume_s *vol, - Buffer_s *buf) + Buffer_s *buf) { BYTE ivBuf[16]; STATUS status; @@ -284,7 +270,7 @@ static STATUS ZFS_D_Buf( unmapBufferPage(buf); return(zOK); -} +} /*********************************************************************** * ZLSS Routines to copy data to himem and copy data from himem @@ -327,7 +313,7 @@ ZLSS_Himem_s ZLSS_Himem; 0 is always the 1st block in the 1st ZLSS superblock. The 'volBlk == 0' is here because of a previous fix to ZFS_ReadPoolBlk - that detects if a block is a user block. The fix was needed because + that detects if a block is a user block. The fix was needed because verify/rebuild would read pool block zero on a file beast thinking it was a file map block. This would cause an abend because a meta-data block was in a Linux user page. I do not recall the exact location of the @@ -347,7 +333,7 @@ static inline BOOL ZLSS_IsUserBlock(const RootBeast_s *root, const Buffer_s *buf /* ZLSS_StoreBeastInHimem() - - Returns TRUE if this object should be stored in Linux Himem. + Returns TRUE if this object should be stored in Linux Himem. Notes - User data uses 'Linux Pages' which are not limited to low memory. I.E. we @@ -397,7 +383,7 @@ static void ZLSS_CopyDataToHimem( ++ZLSS_Himem.ZH_NoToPool; return; } - inode = root->vol.volume->v_pool->P_Inode; + inode = root->vol.volume->v_pool->P_Inode; if (!inode) { ++ZLSS_Himem.ZH_NoToInode; @@ -433,7 +419,7 @@ static BOOL ZLSS_CopyDataFromHimem( ++ZLSS_Himem.ZH_NoFromPool; return found; } - inode = root->vol.volume->v_pool->P_Inode; + inode = root->vol.volume->v_pool->P_Inode; if (!inode) { ++ZLSS_Himem.ZH_NoFromInode; @@ -455,10 +441,10 @@ static BOOL ZLSS_CopyDataFromHimem( | +-------------------------------------------------------------------------*/ Buffer_s *ZFS_AllocPoolBlkSpecialWithFlags( - GeneralMsg_s *genMsg, - IoMsg_s *iomsg, - Buffer_s **specialBuffer, - NINT allocFlags) + GeneralMsg_s *genMsg, + IoMsg_s *iomsg, + Buffer_s **specialBuffer, + NINT allocFlags) { RootBeast_s *beast = iomsg->beast; Extent_s extent; @@ -476,12 +462,12 @@ Buffer_s *ZFS_AllocPoolBlkSpecialWithFlags( extent.lengthOfExtent = iomsg->allocNumBlks; if (specialBuffer != NULL) { - status = zfsAllocExtentFromSpecialBlk(genMsg, beast->vol.zfsVol, - &extent, iomsg->xaction, specialBuffer); + status = zfsAllocExtentFromSpecialBlk(genMsg, beast->vol.zfsVol, + &extent, iomsg->xaction, specialBuffer); } else { - status = zfsAllocExtent(genMsg, beast->vol.zfsVol, + status = zfsAllocExtent(genMsg, beast->vol.zfsVol, &extent, allocFlags|XTREE_SYSTEM_REQUEST, iomsg->xaction); } @@ -491,9 +477,9 @@ Buffer_s *ZFS_AllocPoolBlkSpecialWithFlags( } if (iomsg->fileBlk == INVALID_BLK) { /* - * This must be an indirect block we are allocating - * Use negative of volBlk number. - */ + * This must be an indirect block we are allocating + * Use negative of volBlk number. + */ iomsg->fileBlk = -extent.poolBlkNum; } zASSERT(extent.poolBlkNum != 0); @@ -513,14 +499,14 @@ Buffer_s *ZFS_AllocPoolBlkSpecialWithFlags( /* ZFS_WritePoolBlk() - - Wrapper around unitwritewait to ensure that ZLSS_CopyDataToHimem is called - properly. + Wrapper around unitwritewait to ensure that ZLSS_CopyDataToHimem is called + properly. */ -STATUS ZFS_WritePoolBlk( - GeneralMsg_s *genMsg, - zConPool_s *phypool, +STATUS ZFS_WritePoolBlk( + GeneralMsg_s *genMsg, + zConPool_s *phypool, Buffer_s *buffer ) { STATUS status; @@ -555,7 +541,7 @@ Buffer_s *ZIO_DBG_LogTest( zASSERT( LogTest ); zASSERT( iomsg->beast != NULL ); if ( COMN_IsDerivedFrom( iomsg->beast, zFTYPE_ZLSS_ZFSPOOL) && - (((ZfsPool_s *)iomsg->beast)->zfsLogBeast != NULL) ) + (((ZfsPool_s *)iomsg->beast)->zfsLogBeast != NULL) ) { /* Is the pool - Pool only used for undo and redo!!!! */ zfsPool = (ZfsPool_s *)iomsg->beast; zlogBeast = zfsPool->zfsLogBeast; @@ -612,7 +598,7 @@ void ZIO_DBG_ErrorSimulateRead( /* * ZFS_ReadPoolBlk_ErrorHandler() - - * Handles the error code path for ZFS_ReadPoolBlk when + * Handles the error code path for ZFS_ReadPoolBlk when * ZFSMAL_ReadBlk() errors out. * */ @@ -629,36 +615,36 @@ void ZFS_ReadPoolBlk_ErrorHandler (GeneralMsg_s *genMsg, IoMsg_s *iomsg, Buffer_ DOWN_LATCH(&buf->agent.latch); } /* If this is a pre-read of a SYSTEM buffer that will - * be written then the error must DISABLE the volume. - * - * Feb 20, 2001 - * We came close to removing this disable code - * because some people do updates just in case they - * do a write. We left in, because numerous places - * do not do COMN abort Xaction when errors are - * returned during a XACTION. - */ - if ( (iomsg->mode == CACHE_UPDATE) && + * be written then the error must DISABLE the volume. + * + * Feb 20, 2001 + * We came close to removing this disable code + * because some people do updates just in case they + * do a write. We left in, because numerous places + * do not do COMN abort Xaction when errors are + * returned during a XACTION. + */ + if ( (iomsg->mode == CACHE_UPDATE) && ZLSS_IS_SYSTEM_BLOCK( beast, buf ) ) { /* This is a SYSTEM Block being pre-read for a write */ Volume_s *volume; /* The volume that the read was done - * on. Note that this is not the - * 'owning' volume if the beast is a - * volume becausethe ADMIN volume - * owns all volumes. - */ + * on. Note that this is not the + * 'owning' volume if the beast is a + * volume becausethe ADMIN volume + * owns all volumes. + */ - volume = ((beast->bstState & BST_STATE_IS_VOLUME_OR_POOL) ? - (Volume_s *)beast : + volume = ((beast->bstState & BST_STATE_IS_VOLUME_OR_POOL) ? + (Volume_s *)beast : beast->vol.volume ); zASSERT( volume != NULL ); /* If not /VERIFY or /REBUILD then DISABLE the - * volume. The repair code handles errors so we - * do not wish to DISABLE the volume. Note that - * we do not simply check the volume's state because - * we would be required to obtain the stateLatch and - * if we did that we could easily deadlock. - */ + * volume. The repair code handles errors so we + * do not wish to DISABLE the volume. Note that + * we do not simply check the volume's state because + * we would be required to obtain the stateLatch and + * if we did that we could easily deadlock. + */ if ( !ZLSS_IS_MAINTENANCE_IO( volume ) ) { GeneralMsg_s dummyGenMsg; @@ -672,9 +658,9 @@ void ZFS_ReadPoolBlk_ErrorHandler (GeneralMsg_s *genMsg, IoMsg_s *iomsg, Buffer_ flags |= CVA_VOLUME_DISABLE | CVA_VOLUME_ALERT; } /* Now tell the common layer that we wish to disable this - * volume. This is an ASYNC call. We require because we - * can not block. - */ + * volume. This is an ASYNC call. We require because we + * can not block. + */ (void)COMN_VolumeAlert( &dummyGenMsg, beast, volume, buf, buf->pBuf.fileBlk, buf->volBlk, buf->agent.status, WHERE, flags ); @@ -750,7 +736,7 @@ Buffer_s *ZFS_ReadPoolBlk (GeneralMsg_s *genMsg, IoMsg_s *iomsg) { buf = cacheAllocBuffer(mycache, iomsg->fileBlk, iomsg->volBlk, - ZFS_BlockSignalHandler, iomsg->mode); + ZFS_BlockSignalHandler, iomsg->mode); } else { @@ -760,8 +746,8 @@ Buffer_s *ZFS_ReadPoolBlk (GeneralMsg_s *genMsg, IoMsg_s *iomsg) } /* If after allocating a cache buffer, the page found in linux cache - * still has valid data, then no need to read the data from disk again. - */ + * still has valid data, then no need to read the data from disk again. + */ if (buf->state & CACHE_DATA_VALID) { buf->state &= ~CACHE_DATA_VALID; @@ -783,9 +769,9 @@ Buffer_s *ZFS_ReadPoolBlk (GeneralMsg_s *genMsg, IoMsg_s *iomsg) if (status != zOK) { /* - * 407920 - Moved the code to this routine to save stack space. - * Helps quiet a bit on 64-bit architecture. - */ + * 407920 - Moved the code to this routine to save stack space. + * Helps quiet a bit on 64-bit architecture. + */ ZFS_ReadPoolBlk_ErrorHandler(genMsg, iomsg, buf); return NULL; } @@ -818,7 +804,7 @@ STATUS ZFSMAL_PhysicalExtent( #if 1 if ( phyPool == NULL ) { - zASSERT("Pool is no longer valid" != NULL); + zASSERT("Pool is no longer valid" != NULL); return( zERR_POOL_NOT_ACCESSIBLE ); } @@ -827,9 +813,9 @@ STATUS ZFSMAL_PhysicalExtent( *deviceLength = poolLength; #else /* Paul says - I'm making the code look like many devices so I can - * test out logical extents being broken into multiple physical extents. - */ - *deviceID = (ADDR)phyPool->ZCP_dev + (volumeOffset >> 3); + * test out logical extents being broken into multiple physical extents. + */ + *deviceID = (ADDR)phyPool->ZCP_dev + (volumeOffset >> 3); *offset = volumeOffset & MASK(0, 3); *length = (1 << 3) - *offset; #endif @@ -867,7 +853,7 @@ IOErrorLog_s *ZIO_ErrorNewEntry( Volume_s *volume ) * This function supports the hidden command to display ZLSS Physical * I/O Errors. This command is used internally to gather I/O * information to help in making performance changes to ZLSS. - * + * * These statistics are for ALL pools that the ZLSS owns. */ @@ -890,11 +876,11 @@ STATUS doZLSSPoolIOErrors( wPause(stdout, -1); if ( ZIO_ErrorLogCount != 0 ) { - aprintf( CYAN, + aprintf( CYAN, "%-15.15s %-4.4s %-5.5s %-5.5s %-8.8s %-9.9s %-27.27s\n", "Pool Name", "Type", "Stat1", "Stat2", "Block", "Object", "Time" ); - aprintf( CYAN, + aprintf( CYAN, "%-15.15s %-4.4s %-5.5s %-5.5s %-8.8s %-9.9s %-27.27s\n", "-----------------------------------", "-----------------------------------", @@ -908,29 +894,29 @@ STATUS doZLSSPoolIOErrors( for ( i = 0; i < ZIO_ErrorLogCount; ++i ) { /* Because of limited room we do not print - * - * IOEL_FileBlock AND IOEL_Data - * - * and only 5 digits of - * - * IOEL_Status AND IOEL_ErrorMediaManager - * - * and only 9 hex digits of - * - * IOEL_Zid - */ + * + * IOEL_FileBlock AND IOEL_Data + * + * and only 5 digits of + * + * IOEL_Status AND IOEL_ErrorMediaManager + * + * and only 9 hex digits of + * + * IOEL_Zid + */ entry = &ZIO_ErrorLog[i]; ioString = entry->IOEL_Read ? "R" : "W"; sysString = entry->IOEL_System ? "S" : "U"; UTCTime2Str( entry->IOEL_UTCTime, &buffer[0] ); - aprintf( LGREEN, + aprintf( LGREEN, "%-15.15U %2.2s%-2.2s %5d %5d %8lx %9Lx %-27.27s\n", entry->IOEL_PoolName, ioString, sysString, entry->IOEL_Status, entry->IOEL_ErrorMediaManager, entry->IOEL_VolumeBlock, entry->IOEL_Zid, buffer ); } wPause(stdout, 0); - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return zOK; } /* End of doZLSSPoolIOErrors() */ @@ -962,10 +948,10 @@ void ZIO_ErrorRecord( zASSERT( status != zOK ); /*** - *** - *** This can be called on a FAST WORK TO DO (I.E. no blocking!) - *** - ***/ + *** + *** This can be called on a FAST WORK TO DO (I.E. no blocking!) + *** + ***/ switch ( state ) { case ZPIOLH_STATE_WRITE_COMPLETE: @@ -1023,7 +1009,7 @@ void ZIO_ErrorRecord( { volume->v_stats.IO_system_write_failure++; } -#endif +#endif } else { @@ -1037,7 +1023,7 @@ void ZIO_ErrorRecord( { volume->v_stats.IO_user_write_failure++; } -#endif +#endif } } /* End of ZIO_ErrorRecord() */ @@ -1078,10 +1064,10 @@ void ZIO_ErrorRecord( } if ( zfsPool->storagepool != NULL ) { /* Mike changed this from errPrintf in file r1.37 because - * errPrintf would cause an ABEND when we switched from - * P1 to P0. Was in a FAST WORK TO DO path and blocked!!! - * We will let the ALERT system report errors. - */ + * errPrintf would cause an ABEND when we switched from + * P1 to P0. Was in a FAST WORK TO DO path and blocked!!! + * We will let the ALERT system report errors. + */ DBG_DebugPrintf(LRED, " Consumer status=%d at block: 0x%x file block: 0x%x on pool: %U.\n", (consumerRetCode & 0x0000ffff), buf->volBlk, @@ -1110,10 +1096,10 @@ void ZIO_DBG_HistoryDisplay( Volume_s *volume; /*** - *** - *** This can be called on a FAST WORK TO DO (I.E. no blocking!) - *** - ***/ + *** + *** This can be called on a FAST WORK TO DO (I.E. no blocking!) + *** + ***/ switch ( state ) { case ZPIOLH_STATE_WRITE_COMPLETE: @@ -1146,29 +1132,29 @@ void ZIO_DBG_HistoryDisplay( memcpy( stuff, buf->pBuf.data, 4 ); stuff[4] = NULL; DEBUG_PRINTF(TZPOOLIO,DBG_INDENT, - ( GREEN, - MSGNot(" s%s: VZ=%ld Z=%ld%c FBlk=%ld VBlk=%ld D=%08lx *D=%s\n"), - modeString, - (unsigned long)volume->VOLzid, - (unsigned long)beast->zid,v, - buf->pBuf.fileBlk, - buf->volBlk, - buf->pBuf.data, - stuff + ( GREEN, + MSGNot(" s%s: VZ=%ld Z=%ld%c FBlk=%ld VBlk=%ld D=%08lx *D=%s\n"), + modeString, + (unsigned long)volume->VOLzid, + (unsigned long)beast->zid,v, + buf->pBuf.fileBlk, + buf->volBlk, + buf->pBuf.data, + stuff )); } else { DEBUG_PRINTF(TZPOOLIO,DBG_INDENT, - ( GREEN, - MSGNot(" u%s: VZ=%ld Z=%ld%c FBlk=%ld VBlk=%ld D=%08lx *D=%lx\n"), - modeString, - (unsigned long)volume->VOLzid, - (unsigned long)beast->zid,v, - buf->pBuf.fileBlk, - buf->volBlk, - buf->pBuf.data, - *((LONG *)buf->pBuf.data) + ( GREEN, + MSGNot(" u%s: VZ=%ld Z=%ld%c FBlk=%ld VBlk=%ld D=%08lx *D=%lx\n"), + modeString, + (unsigned long)volume->VOLzid, + (unsigned long)beast->zid,v, + buf->pBuf.fileBlk, + buf->volBlk, + buf->pBuf.data, + *((LONG *)buf->pBuf.data) )); } } /* End of ZIO_DBG_HistoryDisplay() */ @@ -1195,10 +1181,10 @@ void ZIO_DBG_GatherEventComplete( ZLSSPoolIOLog_Complete_s *log; /*** - *** - *** This can be called on a FAST WORK TO DO (I.E. no blocking!) - *** - ***/ + *** + *** This can be called on a FAST WORK TO DO (I.E. no blocking!) + *** + ***/ zASSERT( (gZLSSPoolIOLog != NULL) || !gZLSSPoolIOLogDo ); switch ( state ) { @@ -1224,7 +1210,7 @@ void ZIO_DBG_GatherEventComplete( if ( gZLSSPoolIOFull ) { while ( gZLSSPoolIOLogNext > gZLSSPoolIOLogStart ) - { + { gZLSSPoolIOLogStart += ((ZLSSPoolIOLogHeader_s *)(&gZLSSPoolIOLog[gZLSSPoolIOLogStart]))->ZPIOLH_Size; if ( gZLSSPoolIOLogStart > (gZLSSPoolIOLogSize - ZLSS_POOL_IO_LOG_SPACE) ) // FixFixFix { @@ -1235,10 +1221,10 @@ void ZIO_DBG_GatherEventComplete( } beast = STRUCT(buf->pBuf.mycache, RootBeast_s, ROOTmycache); ZLSS_VOLUME_GET( beast, volume ); -// volume = ((beast->bstState & BST_STATE_IS_VOLUME_OR_POOL) ? -// (Volume_s *)beast : +// volume = ((beast->bstState & BST_STATE_IS_VOLUME_OR_POOL) ? +// (Volume_s *)beast : // beast->vol.volume ); - gZLSSPoolIOHeader->ZPIOH_UTCTime = GetUTCTime(); + gZLSSPoolIOHeader->ZPIOH_UTCTime = GetUTCTime(); log->ZPIOL_C_Header.ZPIOLH_Size = sizeof( *log ); log->ZPIOL_C_Header.ZPIOLH_Format = ZPIOLH_FORMAT_STANDARD; log->ZPIOL_C_Header.ZPIOLH_State = state; @@ -1291,7 +1277,7 @@ void ZIO_DBG_GatherEventStart( if ( gZLSSPoolIOFull ) { while ( gZLSSPoolIOLogNext > gZLSSPoolIOLogStart ) - { + { gZLSSPoolIOLogStart += ((ZLSSPoolIOLogHeader_s *)(&gZLSSPoolIOLog[gZLSSPoolIOLogStart]))->ZPIOLH_Size; if ( gZLSSPoolIOLogStart > (gZLSSPoolIOLogSize - ZLSS_POOL_IO_LOG_SPACE) ) // FixFixFix { @@ -1302,8 +1288,8 @@ void ZIO_DBG_GatherEventStart( } beast = STRUCT(buf->pBuf.mycache, RootBeast_s, ROOTmycache); ZLSS_VOLUME_GET( beast, volume ); -// volume = ((beast->bstState & BST_STATE_IS_VOLUME_OR_POOL) ? -// (Volume_s *)beast : +// volume = ((beast->bstState & BST_STATE_IS_VOLUME_OR_POOL) ? +// (Volume_s *)beast : // beast->vol.volume ); zASSERT( volume != NULL ); gZLSSPoolIOHeader->ZPIOH_UTCTime = GetUTCTime(); @@ -1354,7 +1340,7 @@ void ZIO_DBG_GatherEvent( Buffer_s *buf, WORD state ) * ZIO_GatherDetailedSummaryInformation() - * This tracks the number of IOs done to ZLSS pools. It * tracks LVDB and all system beast writes as separate counts. In addition - * it counts all user writes. + * it counts all user writes. * * Notes - * The command "NSS /ZLSSPoolIOStatistics=PoolName" can be used to @@ -1377,10 +1363,10 @@ void ZIO_GatherDetailedSummaryInformation( BOOL read; /*** - *** - *** This can be called on a FAST WORK TO DO (I.E. no blocking!) - *** - ***/ + *** + *** This can be called on a FAST WORK TO DO (I.E. no blocking!) + *** + ***/ switch ( state ) { case ZPIOLH_STATE_WRITE_COMPLETE: @@ -1400,7 +1386,7 @@ void ZIO_GatherDetailedSummaryInformation( beast = STRUCT(buf->pBuf.mycache, RootBeast_s, ROOTmycache); ZLSS_VOLUME_GET( beast, volume ); // volume = ((beast->bstState & BST_STATE_IS_VOLUME_OR_POOL) ? -// (Volume_s *)beast : +// (Volume_s *)beast : // beast->vol.volume ); // zASSERT( volume != NULL ); // zASSERT( COMN_IsDerivedFrom(volume, zFTYPE_ZLSS_VOL) ); @@ -1540,10 +1526,10 @@ void ZFSMAL_ReadBlkDone(BioReq_s *bioReq) STATUS rc; /*** - *** - *** This can be called on a FAST WORK TO DO (I.E. no blocking!) - *** - ***/ + *** + *** This can be called on a FAST WORK TO DO (I.E. no blocking!) + *** + ***/ ENTER(TZPOOLIO, ZFSMAL_ReadBlkDone); ASSERT_MPKNSS_LOCK(); DEBUG_PRINTF(TZPOOLIO,DBG_INDENT,(LRED,MSGNot("Read IO Completed on %08x\n"),buf)); @@ -1563,16 +1549,16 @@ void ZFSMAL_ReadBlkDone(BioReq_s *bioReq) { ZIO_DBG_GatherEvent( buf, ZPIOLH_STATE_READ_COMPLETE ); } -#endif +#endif if (bioReq->br_status == zOK) { /* Do the decryption if necessary */ - if((volume->VOLenabledAttributes & zATTR_ENCRYPTED) && - (volume->v_statusFlag & VOL_SF_KEYPRESENT) && - (buf->eData != NULL)) + if((volume->VOLenabledAttributes & zATTR_ENCRYPTED) && + (volume->v_statusFlag & VOL_SF_KEYPRESENT) && + (buf->eData != NULL)) { - rc = ZFS_D_Buf(volume, buf); + rc = ZFS_D_Buf(volume, buf); zASSERT(rc == zOK); retEDataBuf(buf); if(rc != zOK) @@ -1583,7 +1569,7 @@ void ZFSMAL_ReadBlkDone(BioReq_s *bioReq) } /* get IO stats */ -// ioObj = ((beast->bstState & BST_STATE_IS_VOLUME_OR_POOL) ? +// ioObj = ((beast->bstState & BST_STATE_IS_VOLUME_OR_POOL) ? // (ZfsPool_s *)beast : beast->vol.zfsVol->pool); if (beast->beastClass->classID <= zFTYPE_FILE) { @@ -1605,9 +1591,9 @@ void ZFSMAL_ReadBlkDone(BioReq_s *bioReq) } else { - if((volume->VOLenabledAttributes & zATTR_ENCRYPTED) && - (volume->v_statusFlag & VOL_SF_KEYPRESENT) && - (buf->eData != NULL)) + if((volume->VOLenabledAttributes & zATTR_ENCRYPTED) && + (volume->v_statusFlag & VOL_SF_KEYPRESENT) && + (buf->eData != NULL)) { retEDataBuf(buf); } @@ -1651,16 +1637,16 @@ void ZFSMAL_asyncReadBlk(Asyncio_s *aio) BOOL cryptRead; ENTER(TZPOOLIO, ZFSMAL_asyncReadBlk); - + ASSERT_MPKNSS_LOCK(); zASSERT(buf->volBlk != 0); root = STRUCT(aio->mycache, RootBeast_s, ROOTmycache); { /* This is the special code to handle disabling a - * volume. The LSS is required to stop all physical reads - * if the volume's ioFlag indicates the volume is - * disabled. In addition, the Volume's pool is checked. - */ + * volume. The LSS is required to stop all physical reads + * if the volume's ioFlag indicates the volume is + * disabled. In addition, the Volume's pool is checked. + */ ZLSS_VOLUME_GET( root, vol ); if ( (ZLSS_VOLUME_IO_DISABLED( (ZfsVolume_s *)vol ) ) ) @@ -1683,12 +1669,12 @@ void ZFSMAL_asyncReadBlk(Asyncio_s *aio) /*- get the storage deposit to access for this volume -*/ if((phypool = ioObj->storagepool->phypool) == NULL) { - zASSERT("Pool is no longer valid" != NULL); + zASSERT("Pool is no longer valid" != NULL); aio->status = zERR_POOL_NOT_ACCESSIBLE; FSM_READY(&aio->fsm); RTN_VOID(); } - + #if NSS_DEBUG IS_ENABLED if (RWErrTestSeed) { @@ -1713,9 +1699,9 @@ void ZFSMAL_asyncReadBlk(Asyncio_s *aio) } /* Determine if this read is for a user data block on an encrypted volume, - * or just a regular read - */ - cryptRead = ((vol->VOLenabledAttributes & zATTR_ENCRYPTED) && + * or just a regular read + */ + cryptRead = ((vol->VOLenabledAttributes & zATTR_ENCRYPTED) && (vol->v_statusFlag & VOL_SF_KEYPRESENT) && (!ZLSS_IS_SYSTEM_BLOCK( root, buf ))); if (cryptRead) @@ -1724,7 +1710,7 @@ void ZFSMAL_asyncReadBlk(Asyncio_s *aio) STK_POP(COMN_Encrypted_Page_Head, buf->eData, EncryptedBufPage_s, link); if (buf->eData == NULL) { - aio->fsm.lite.action = (voidfunc_t)ZFSMAL_asyncReadBlk; + aio->fsm.lite.action = ZFSMAL_asyncReadBlk; CIR_ENQ(EncryptedBufWaitHead, aio, fsm.lite.link); #if NSS_DEBUG IS_ENABLED EncryptedBufWaitReadAsync++; @@ -1740,8 +1726,8 @@ void ZFSMAL_asyncReadBlk(Asyncio_s *aio) /*- total read io count of requests sent to storage objects -*/ ++IOsInst.readIn; /* - Here the lock is released in the lower level calls where the thread - leaves NSS domain + Here the lock is released in the lower level calls where the thread + leaves NSS domain */ #if NSS_DEBUG IS_ENABLED @@ -1757,11 +1743,11 @@ void ZFSMAL_asyncReadBlk(Asyncio_s *aio) INIT_BIO_REQ(&aio->bioReq, ZFSMAL_ReadBlkDone); zlssBioIOBufferAsync(READ, phypool->ZCP_dev, buf, &aio->bioReq); - RTN_VOID(); + RTN_VOID(); } /* End of ZFSMAL_asyncReadBlk() */ /**************************************************************************** - * + * *****************************************************************************/ typedef struct EBufWait_s { @@ -1770,7 +1756,7 @@ typedef struct EBufWait_s } eBufWait_s; /**************************************************************************** - * + * *****************************************************************************/ void encryptedAllocBufferContinue (FsmLite_s *fsm) { @@ -1791,7 +1777,7 @@ void waitForEncryptedBuffer (void) FSMLITE_INIT( &wait.fsm, MSGNot("waitForEncryptedBuffer"), 0); - wait.fsm.action = (voidfunc_t)encryptedAllocBufferContinue; + wait.fsm.action = encryptedAllocBufferContinue; wait.nextThread = ThreadId(); CIR_ENQ(EncryptedBufWaitHead, &wait, fsm.link); Wait(); @@ -1831,7 +1817,7 @@ STATUS ZFSMAL_ReadBlk( ZfsPool_s *ioObj; zConPool_s *phypool; - Volume_s *vol; + Volume_s *vol; BOOL cryptRead; ENTER(TZPOOLIO, ZFSMAL_ReadBlk); @@ -1842,10 +1828,10 @@ STATUS ZFSMAL_ReadBlk( { /* This is the special code to handle disabling a - * volume. The LSS is required to stop all physical reads - * if the volume's ioFlag indicates the volume is - * disabled. In addition, the Volume's pool is checked. - */ + * volume. The LSS is required to stop all physical reads + * if the volume's ioFlag indicates the volume is + * disabled. In addition, the Volume's pool is checked. + */ ZLSS_VOLUME_GET( root, vol ); if ( (ZLSS_VOLUME_IO_DISABLED( (ZfsVolume_s *)vol ) ) ) @@ -1866,7 +1852,7 @@ STATUS ZFSMAL_ReadBlk( /*- get the storage deposit to access for this volume -*/ if((phypool = ioObj->storagepool->phypool) == NULL) { - zASSERT("Pool is no longer valid" != NULL); + zASSERT("Pool is no longer valid" != NULL); SetErrno(genMsg, zERR_POOL_NOT_ACCESSIBLE); RTN_STATUS(zFAILURE); } @@ -1914,15 +1900,15 @@ STATUS ZFSMAL_ReadBlk( { ZIO_DBG_GatherEvent( buf, ZPIOLH_STATE_READ_START ); } -#endif +#endif ++IOsInst.readWIn; /* IO count of requests sent to storage objects */ status = zlssBioIOBuffer(READ, phypool->ZCP_dev, buf); /* If this was an encrypted read, decrypt it into the regular buffer, - * and free the encrypt buffer - */ + * and free the encrypt buffer + */ if (cryptRead) { if (status == 0) @@ -1931,19 +1917,19 @@ STATUS ZFSMAL_ReadBlk( status = ZFS_D_Buf(vol, buf); zASSERT(status == zOK); - if(status != zOK) + if(status != zOK) { - /* on error, we have to return the page to the list, - * on success this happens in ZFS_D_Buf */ + /* on error, we have to return the page to the list, + * on success this happens in ZFS_D_Buf */ SetErrno( genMsg, zERR_NICI_SUPPORT ); /* arrange for an early out */ - buf->ioRetryCount = MAX_IO_RETRY_COUNT; + buf->ioRetryCount = MAX_IO_RETRY_COUNT; } } retEDataBuf(buf); } - ++IOsInst.readWOut; /* IO count of requests finished */ + ++IOsInst.readWOut; /* IO count of requests finished */ if ( gZLSSGatherDetailedIOInformation ) { ZIO_GatherDetailedSummaryInformation( buf, ZPIOLH_STATE_READ_COMPLETE ); @@ -1959,7 +1945,7 @@ STATUS ZFSMAL_ReadBlk( #endif if ( status == zOK ) { /* Read was successful */ - if (root->beastClass->classID <= zFTYPE_FILE) + if (root->beastClass->classID <= zFTYPE_FILE) { ((Volume_s *)ioObj)->v_stats.IO_user_read_success++; ((Volume_s *)ioObj)->v_stats.IO_user_readSize += phypool->pol.poolblocksize; @@ -1981,10 +1967,10 @@ STATUS ZFSMAL_ReadBlk( SetErrno( genMsg, status ); ZIO_ErrorRecord( buf, status, GetErrno(genMsg), ZPIOLH_STATE_READ_COMPLETE ); #if NSS_DEBUG IS_ENABLED - (root->beastClass->classID <= zFTYPE_FILE) ? + (root->beastClass->classID <= zFTYPE_FILE) ? ((Volume_s *)ioObj)->v_stats.IO_user_read_failure++ : ((Volume_s *)ioObj)->v_stats.IO_system_read_failure++; -#endif +#endif RTN_STATUS(zFAILURE); } /* End of ZFSMAL_ReadBlk() */ @@ -2035,12 +2021,12 @@ void ZIO_DBG_WriteGuidVerify( ZLSS_VOLUME_GET( beast, volume ); zVolume = VOLUME_TO_ZLSS_VOLUME( volume ); /** - * Looking at the VOLstate is illegal without owning - * the state latch. We do here as - * 1) Debug code. - * 2) Only care if not in maintenance or REDO/UNDO. Which - * is TRUE when zVOLSTATE_ACTIVE is set. - */ + * Looking at the VOLstate is illegal without owning + * the state latch. We do here as + * 1) Debug code. + * 2) Only care if not in maintenance or REDO/UNDO. Which + * is TRUE when zVOLSTATE_ACTIVE is set. + */ if ( (volume->VOLstate != zVOLSTATE_ACTIVE) || ( buf->pBuf.fileBlk >= 0 ) ) { return; @@ -2051,9 +2037,9 @@ void ZIO_DBG_WriteGuidVerify( } if ( COMN_IsDerivedFrom(zVolume, zFTYPE_ZLSS_ZFSPOOL) ) { /** This pool may have been upgraded with - * a LV which means some of its OLD metadata - * blocks will have an old GUID. - */ + * a LV which means some of its OLD metadata + * blocks will have an old GUID. + */ zfsPool = (ZfsPool_s *)zVolume; if ( LB_GUIDCompareWithBlock( (GUIDWithBlock_t *)(buf->pBuf.data+16), &zfsPool->ZFSPOOLoldInternalID) == 0 ) @@ -2099,8 +2085,8 @@ void ZIO_DBG_ErrorSimulateWrite( Buffer_s *buf, LONG *consumerRetCode ) { *consumerRetCode = MAL_IO_UNDEFINED_ERROR; /* Set retry count so we FAIL this IO instead of - * causing a retry. - */ + * causing a retry. + */ buf->ioRetryCount = 1; DBG_DebugPrintf(LRED,"Generated Fake I/O Error at write count %d\n", WRTestCnt ); } @@ -2113,14 +2099,14 @@ void ZIO_DBG_ErrorSimulateWrite( Buffer_s *buf, LONG *consumerRetCode ) #ifdef USER_GPACHNER FsmLite_s gDelaySignalWorkToDoFsm; BOOL gEatSignal = FALSE; /* Set to TRUE to delay ONE FT write. - * Used to lock HOME into one place so - * that ZLOG file will get FULL. - */ + * Used to lock HOME into one place so + * that ZLOG file will get FULL. + */ BOOL gSignalDelay = TRUE; /* Set to FALSE to UN delay the FT - * write. Used so that the POOL - * DISABLE that a full ZLOG generates - * can complete. - */ + * write. Used so that the POOL + * DISABLE that a full ZLOG generates + * can complete. + */ NINT gEaten; Agent_s *gAgent; Buffer_s *gBuf; @@ -2156,16 +2142,16 @@ void ZFS_WriteBlkDone(BioReq_s *bioReq) Agent_s *agent = &buf->agent; STATUS status; RootBeast_s *beast; - + ENTER(TZPOOLIO, ZFS_WriteBlkDone); ASSERT_MPKNSS_LOCK(); zASSERT(buf->state & CACHE_DIRTY); /* now return the encrypted page to the avail pool if its present, even if - * the write completion fails, a new encrypt buf and processing will take - * place with the write is sent back to DoBlockWriteFromSignal. - */ + * the write completion fails, a new encrypt buf and processing will take + * place with the write is sent back to DoBlockWriteFromSignal. + */ retEDataBuf(buf); beast = STRUCT(buf->pBuf.mycache, RootBeast_s, ROOTmycache); @@ -2186,7 +2172,7 @@ void ZFS_WriteBlkDone(BioReq_s *bioReq) /*- total write io count of requests received from storage objects -*/ --CurrentWriteCount; - + /*- writeOut has no waiters, writeOutXdata has dependent waiters -*/ if (NO_SIGNALS( &(buf->agent))) { @@ -2205,14 +2191,14 @@ void ZFS_WriteBlkDone(BioReq_s *bioReq) CACHE_CLEAN(buf); /* if a writeDone routine is defined, call it instead of doing - * the default done processing - */ + * the default done processing + */ beast = STRUCT(buf->pBuf.mycache, RootBeast_s, ROOTmycache); ZLSS_VOLUME_GET( beast, volume ); -// ioObj = ((beast->bstState & BST_STATE_IS_VOLUME_OR_POOL) ? +// ioObj = ((beast->bstState & BST_STATE_IS_VOLUME_OR_POOL) ? // (ZfsPool_s *)beast : beast->vol.zfsVol->pool); /* get IO stats */ - if (beast->beastClass->classID <= zFTYPE_FILE) + if (beast->beastClass->classID <= zFTYPE_FILE) { volume->v_stats.IO_user_write_success++; volume->v_stats.IO_user_writeSize += 4096; @@ -2267,39 +2253,39 @@ void ZFS_WriteBlkDone(BioReq_s *bioReq) ZFS_FsmDoBlockWriteFromSignal(agent); RTN_VOID(); } - + agent->status = bioReq->br_status; -errorReturn: +errorReturn: /* Only writes that failed are passing through the following - * error handling code. - */ - + * error handling code. + */ + ZIO_ErrorRecord( buf, bioReq->br_status, - agent->status, ZPIOLH_STATE_WRITE_COMPLETE ); + agent->status, ZPIOLH_STATE_WRITE_COMPLETE ); status = agent->status; zASSERT( status != zOK ); /* We will disable the volume on all serious IO errors to - * SYSTEM blocks. - * - * This paragraph is no longer TRUE. See next paragraph. The - * exception is that we do not do this in MAINTENANCE state. - * The logic is that the /verify or /rebuild code needs to - * handle. For the MAINTENANCE code to catch errors - * they have to have their own signal handlers. The ZLOG code - * does this. It would be verify difficult for /Rebuild - * because the /Rebuild code uses normal ZLSS code to do - * much of the rebuild!!! - * - * Since /Rebuild does not use its own signal handlers we - * will not treat MAINTENANCE state special yet. A change - * volume state is sent to it that indicates we are disabling - * the volume. The ZLSS /rebuild code could use to detect - * that a serious error occurred. FixFixFix6. - * - * Serious IO error on USER blocks will cause an ALERT to - * be sent. - */ + * SYSTEM blocks. + * + * This paragraph is no longer TRUE. See next paragraph. The + * exception is that we do not do this in MAINTENANCE state. + * The logic is that the /verify or /rebuild code needs to + * handle. For the MAINTENANCE code to catch errors + * they have to have their own signal handlers. The ZLOG code + * does this. It would be verify difficult for /Rebuild + * because the /Rebuild code uses normal ZLSS code to do + * much of the rebuild!!! + * + * Since /Rebuild does not use its own signal handlers we + * will not treat MAINTENANCE state special yet. A change + * volume state is sent to it that indicates we are disabling + * the volume. The ZLSS /rebuild code could use to detect + * that a serious error occurred. FixFixFix6. + * + * Serious IO error on USER blocks will cause an ALERT to + * be sent. + */ if ( ZLSS_IS_SYSTEM_BLOCK(beast, buf ) ) { /* This is a SYSTEM Block */ @@ -2308,8 +2294,8 @@ errorReturn: NINT flags; /* Now tell the common layer that we wish to disable this pool. - * This is an ASYNC call. We require because we can not block. - */ + * This is an ASYNC call. We require because we can not block. + */ COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); ZLSS_VOLUME_GET( beast, volume ); flags = CVA_SYSTEM_DATA | CVA_POOL_DISABLE | CVA_POOL_ALERT; @@ -2328,8 +2314,8 @@ errorReturn: NINT flags; /* Now tell the common layer about this error. - * This is an ASYNC call. We require because we can not block. - */ + * This is an ASYNC call. We require because we can not block. + */ COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); ZLSS_VOLUME_GET( beast, volume ); if ( COMN_IsDerivedFrom(volume, zFTYPE_ZLSS_ZFSPOOL) ) @@ -2396,7 +2382,7 @@ void ZFS_WriteBlkDoneForError(FsmLite_s *fsm) buffer = STRUCT(agent, Buffer_s, agent); buffer->bioReq.br_status = agent->status; - + ZFS_WriteBlkDone(&buffer->bioReq); } @@ -2405,7 +2391,7 @@ void ZFS_WriteBlkDoneForError(FsmLite_s *fsm) /*- (FUNCTION) ----- ZFS_DoBlockWriteFromSignal() --------------------------- | | This is the actual routine that issues a write on a data block. The - | user can pass in the address of a routine that is called by the + | user can pass in the address of a routine that is called by the | "ZFS_WriteBlkDone" routine. | | Called as an FSM? (ZLOG does) @@ -2435,24 +2421,24 @@ void ZFS_FsmDoBlockWriteFromSignal (Agent_s *agent) if (!(buf->state & CACHE_DIRTY)) { /* - * Since this buffer is not dirty, we don't have - * to write the buffer but we still need to process - * the signals. - * - * We schedule an FSM to process the signals, because we - * can run into cases where the copy cache buffer code can - * end up creating a long chain of copied/not dirtied buffers and - * signaling back through the list could overflow the stack. - */ + * Since this buffer is not dirty, we don't have + * to write the buffer but we still need to process + * the signals. + * + * We schedule an FSM to process the signals, because we + * can run into cases where the copy cache buffer code can + * end up creating a long chain of copied/not dirtied buffers and + * signaling back through the list could overflow the stack. + */ FSM_ACTIVATE(&agent->fsm, ZFS_WriteBlkDoneNoWrite); RTN_VOID(); } if (buf->state & CACHE_TOSS) { /* - * Since this buffer is being tossed, we don't have - * to write the buffer but we still need to process - * the signals. - */ + * Since this buffer is being tossed, we don't have + * to write the buffer but we still need to process + * the signals. + */ CACHE_CLEAN(buf); if (writeDoneHandler != NULL) { @@ -2469,22 +2455,22 @@ void ZFS_FsmDoBlockWriteFromSignal (Agent_s *agent) #if NSS_DEBUG IS_ENABLED /* - * The 'CrashPools' gobal is used when we wish to fake a crash by - * not writing most blocks. This has been modified to skip - * all blocks except zlog buffers (during logging). Note that - * checkpoints are in the superblock which is also not effected - * by the CrashPools global. We also now use CrashPools with - * the /nodata switch to stop writes, but not exit right away. - * - * The gZCL_SkipWrites will prevent even log buffers from - * being written. This is usually used so we can run through - * the same recovery setup mulitple times. - */ + * The 'CrashPools' gobal is used when we wish to fake a crash by + * not writing most blocks. This has been modified to skip + * all blocks except zlog buffers (during logging). Note that + * checkpoints are in the superblock which is also not effected + * by the CrashPools global. We also now use CrashPools with + * the /nodata switch to stop writes, but not exit right away. + * + * The gZCL_SkipWrites will prevent even log buffers from + * being written. This is usually used so we can run through + * the same recovery setup mulitple times. + */ if ( (CrashPools && (writeDoneHandler == NULL)) || (gZCL_SkipWrites) ) { /* - * This is the code that ZFSPOOL_WritePoolBlkDone would - * do after a call back for the lower levels. - */ + * This is the code that ZFSPOOL_WritePoolBlkDone would + * do after a call back for the lower levels. + */ CACHE_CLEAN(buf); if (writeDoneHandler != NULL) { @@ -2507,10 +2493,10 @@ void ZFS_FsmDoBlockWriteFromSignal (Agent_s *agent) { /* This is the special code to handle disabling a - * volume. The LSS is required to stop all writes - * if the volume's ioFlag indicates the volume is - * disabled. In addition, the Volume's pool is checked. - */ + * volume. The LSS is required to stop all writes + * if the volume's ioFlag indicates the volume is + * disabled. In addition, the Volume's pool is checked. + */ ZLSS_VOLUME_GET( root, vol ); if ( (ZLSS_VOLUME_IO_DISABLED( (ZfsVolume_s *)vol ) ) ) @@ -2550,13 +2536,13 @@ void ZFS_FsmDoBlockWriteFromSignal (Agent_s *agent) buf->ioRetryCount = MAX_IO_RETRY_COUNT; } /* We should never be writing the sparse buffer because - * it does not contain correct block information. - */ + * it does not contain correct block information. + */ zASSERT( buf != &CACHE_SparseBuffer); - /* See if this is an encrypted buffer write, if so, - * we need to allocate a buffer and encrypt the user data */ - cryptWrite = ((vol->VOLenabledAttributes & zATTR_ENCRYPTED) && + /* See if this is an encrypted buffer write, if so, + * we need to allocate a buffer and encrypt the user data */ + cryptWrite = ((vol->VOLenabledAttributes & zATTR_ENCRYPTED) && (vol->v_statusFlag & VOL_SF_KEYPRESENT) && (!ZLSS_IS_SYSTEM_BLOCK( root, buf ))); @@ -2566,7 +2552,7 @@ void ZFS_FsmDoBlockWriteFromSignal (Agent_s *agent) STK_POP(COMN_Encrypted_Page_Head, buf->eData, EncryptedBufPage_s, link); if (buf->eData == NULL) { - agent->fsm.action = (voidfunc_t)ZFS_FsmDoBlockWriteFromSignal; + agent->fsm.action = ZFS_FsmDoBlockWriteFromSignal; CIR_ENQ(EncryptedBufWaitHead, agent, fsm.link); #if NSS_DEBUG IS_ENABLED EncryptedBufWaitWrite++; @@ -2574,7 +2560,7 @@ void ZFS_FsmDoBlockWriteFromSignal (Agent_s *agent) RTN_VOID(); } /* encrypt buf->pBuf.data into buf->eData in COMN's context */ - rc = ZFS_E_Buf(vol, buf); + rc = ZFS_E_Buf(vol, buf); if(rc != zOK) { agent->status = zERR_NICI_SUPPORT; @@ -2608,23 +2594,23 @@ void ZFS_FsmDoBlockWriteFromSignal (Agent_s *agent) cryptFail: FSM_ACTIVATE(&agent->fsm, ZFS_WriteBlkDoneForError); - + #if NSS_DEBUG IS_ENABLED (root->beastClass->classID <= zFTYPE_FILE) ? ((Volume_s *)ioObj)->v_stats.IO_user_write_failure++ : ((Volume_s *)ioObj)->v_stats.IO_system_write_failure++; -#endif +#endif RTN_VOID(); } - zASSERT("Pool is no longer valid" == NULL); + zASSERT("Pool is no longer valid" == NULL); errPrintf(WHERE, Module, 1443, MSG("Physical pool \"%U\" is unavailable - Write Request failed at " "pool block: 0x%x file block: 0x%x", 430), ioObj->storagepool->poolname, buf->volBlk, buf->pBuf.fileBlk); - + agent->status = zERR_POOL_NOT_ACCESSIBLE; /* See comments that are in ZFS_WriteBlkDone */ @@ -2635,8 +2621,8 @@ cryptFail: NINT flags; /* Now tell the common layer that we wish to disable this volume. - * This is an ASYNC call. We require because we can not block. - */ + * This is an ASYNC call. We require because we can not block. + */ COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); ZLSS_VOLUME_GET( root, volume ); flags = CVA_SYSTEM_DATA | CVA_POOL_DISABLE | CVA_POOL_ALERT; @@ -2654,8 +2640,8 @@ cryptFail: Volume_s *volume; /* Now tell the common layer about this error. - * This is an ASYNC call. We require because we can not block. - */ + * This is an ASYNC call. We require because we can not block. + */ COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); ZLSS_VOLUME_GET( root, volume ); (void)COMN_VolumeAlert( &dummyGenMsg, root, volume, buf, @@ -2760,3 +2746,5 @@ void ZLSS_AsyncMetadataReadAhead( // if (numRA > 0) // printk("<1> Actual RA Requested numBlocks = %d\n", numRA); } + + diff --git a/src/nwnss/zlss/zlog.c b/src/nwnss/zlss/zlog.c index 5d8b19d..157a6bb 100644 --- a/src/nwnss/zlss/zlog.c +++ b/src/nwnss/zlss/zlog.c @@ -36,22 +36,9 @@ | For detailed information about ZLOG see the ZLOG Specification. | +-------------------------------------------------------------------------*/ -#if zLINUX && !defined(NSS_USERSPACE) +#if zLINUX #include #endif -#if defined(NSS_USERSPACE) -#include -#ifndef EOPNOTSUPP -#define EOPNOTSUPP 95 -#endif -extern void abort(void); -static void nssZlssUserspaceAbend(const char *message) -{ - (void)message; - abort(); -} -#define Abend(_message) nssZlssUserspaceAbend(_message) -#endif #include #include /* NSS Library */ @@ -81,12 +68,12 @@ static void nssZlssUserspaceAbend(const char *message) #include "pssConfig.h" /* - * This is the value of the minimun number of extents that the Log File - * will use. This is to allow the IO's to be spread across the pool - * space. If the pool space constructed with multiple drives then this - * will allow spindle striping. Do not change this value without - * changing the seed[] code Zlog_PoolInitialize(). - */ + * This is the value of the minimun number of extents that the Log File + * will use. This is to allow the IO's to be spread across the pool + * space. If the pool space constructed with multiple drives then this + * will allow spindle striping. Do not change this value without + * changing the seed[] code Zlog_PoolInitialize(). + */ #define ZLOG_EXTENT_MIN 8 @@ -94,11 +81,11 @@ static void nssZlssUserspaceAbend(const char *message) #if LOG_TEST IS_ENABLED /* - * Set these in the debugger to specify a range of undo/redo functions - * that will be tested. By default we test all undo/redo functions - * when /logtest is supplied on the command line. Xaction.h has the - * defines for all of the undo/redo function numbers. - */ + * Set these in the debugger to specify a range of undo/redo functions + * that will be tested. By default we test all undo/redo functions + * when /logtest is supplied on the command line. Xaction.h has the + * defines for all of the undo/redo function numbers. + */ NINT xfirst = 0; NINT xlast = XFUNC_MAX; #endif @@ -126,7 +113,7 @@ do a load unss /copy=test /poolr=test then I get an assert because I say seems like deactivate or something else should handle for a long term solution. */ -/* +/* * * The following comments explain some important implementation facts * that will be helpful in understanding and modifying the ZLOG code. @@ -134,7 +121,7 @@ solution. */ * *** ZLOG Specification * * There is a design/implementation specification for ZLOG. It is - * stored on the inner WEB at + * stored on the inner WEB at * * http://137.65.73.185/docs/pssdev/secure/transactions/ * @@ -266,8 +253,8 @@ LONG gZlogAssertBlock = 0xffffffffuL; #endif /* We assume that ZLOG_HISTOGRAM_CONSTRUCT is called before - * ZLOG_HISTOGRAM_INIT. - */ + * ZLOG_HISTOGRAM_INIT. + */ void zlog_HistogramInitialize( ZlogHistogram_s *histogram ) { @@ -302,25 +289,25 @@ void zlog_HistogramConstruct( { histogram->ZH_BucketCount = count; - histogram->ZH_BucketSize = size; - histogram->ZH_Flags = flags; - histogram->ZH_P = persistent; - histogram->ZH_Bucket = bucket; + histogram->ZH_BucketSize = size; + histogram->ZH_Flags = flags; + histogram->ZH_P = persistent; + histogram->ZH_Bucket = bucket; } /* End of zlog_HistogramConstruct() */ /* We assume that zlog_HistoryConstruct is called before - * ZLOG_HISTORY_INIT. - */ -void zlog_HistoryInitialize( + * ZLOG_HISTORY_INIT. + */ +void zlog_HistoryInitialize( ZlogHistory_s *history ) -{ +{ - zASSERT( history->ZH_WatermarkCount > 0 ); - zASSERT( history->ZH_WatermarkCount < 50 ); - bzero( history->ZH_Slots, - sizeof( (*(history->ZH_Slots)) ) * history->ZH_WatermarkCount ); + zASSERT( history->ZH_WatermarkCount > 0 ); + zASSERT( history->ZH_WatermarkCount < 50 ); + bzero( history->ZH_Slots, + sizeof( (*(history->ZH_Slots)) ) * history->ZH_WatermarkCount ); } /* End of zlog_HistoryInitialize() */ @@ -428,30 +415,30 @@ void zlog_CheckpointTakeSchedule( DEBUG_PRINTF(TZLOG,DBG_INDENT,(CYAN,MSGNot("Scheduling a checkpoint take\n"))); - - /* - * Reset counter - we do here becase this checkpoint code - * is async and may take a while before it resets the count. In - * the mean time we do not wish to execute this code again. - */ + + /* + * Reset counter - we do here becase this checkpoint code + * is async and may take a while before it resets the count. In + * the mean time we do not wish to execute this code again. + */ zlogBeast->ZLB_LogBlockFilledInSinceCheckpointCount = 0; /* Tell Our checkpointing thread to do its thing */ /* See if a checkpoint is already scheduled */ if ( zlogBeast->ZLB_CheckpointTakeWorkToDoScheduled ) { /* Already scheduled so just return. ScheduleWork() does not handle multiple schedules of a work to do item. */ - - DEBUG_PRINTF(TZLOG,DBG_INDENT, (CYAN, + + DEBUG_PRINTF(TZLOG,DBG_INDENT, (CYAN, MSGNot("Asynchronous checkpoint already scheduled\n"))); RTN_VOID(); } /* - * Mark that we are scheduling our work to do. We use this flag - * to prevent mulitple schedules and to prevent unloading of the - * beast with a work-to-do scheduled (see Zlog_Destruct()). - */ + * Mark that we are scheduling our work to do. We use this flag + * to prevent mulitple schedules and to prevent unloading of the + * beast with a work-to-do scheduled (see Zlog_Destruct()). + */ zlogBeast->ZLB_CheckpointTakeWorkToDoScheduled = TRUE; - + zlogBeast->ZLB_WorkToDoParameter1 = state; #if NSS_DEBUG IS_ENABLED zlogBeast->ZLB_CheckpointTakeWorkToDoTiming = GetUTCTime(); @@ -518,15 +505,15 @@ void zlog_CheckpointTakeWorkToDoRoutine( if ( (zlogBeast->ZLB_CheckpointTakeWorkToDoTiming + 3) <= cTime ) { DBG_DebugPrintf( TZLOG_COLOR, - MSGNot("\"%U\" Checkpoint schedule delayed for %lu seconds(This is BAD).\n"), - zlogBeast->ZFSLOGroot.vol.zfsVol->pool->ZFSPOOLroot.name, + MSGNot("\"%U\" Checkpoint schedule delayed for %lu seconds(This is BAD).\n"), + zlogBeast->ZFSLOGroot.vol.zfsVol->pool->ZFSPOOLroot.name, (unsigned long)cTime - - (unsigned long)zlogBeast->ZLB_CheckpointTakeWorkToDoTiming ); - aprintf(CYAN, - MSGNot("\"%U\" Checkpoint schedule delayed for %lu seconds(This is BAD).\n"), - zlogBeast->ZFSLOGroot.vol.zfsVol->pool->ZFSPOOLroot.name, + (unsigned long)zlogBeast->ZLB_CheckpointTakeWorkToDoTiming ); + aprintf(CYAN, + MSGNot("\"%U\" Checkpoint schedule delayed for %lu seconds(This is BAD).\n"), + zlogBeast->ZFSLOGroot.vol.zfsVol->pool->ZFSPOOLroot.name, (unsigned long)cTime - - (unsigned long)zlogBeast->ZLB_CheckpointTakeWorkToDoTiming ); + (unsigned long)zlogBeast->ZLB_CheckpointTakeWorkToDoTiming ); } } #endif @@ -534,15 +521,15 @@ void zlog_CheckpointTakeWorkToDoRoutine( zlogBeast->ZFSLOGroot.vol.zfsVol->pool, zlogBeast->ZLB_WorkToDoParameter1 ); /* - * We ignore errors above based on read/write design within - * NSS. A low level routine has started de-activation or read - * only mode. - */ + * We ignore errors above based on read/write design within + * NSS. A low level routine has started de-activation or read + * only mode. + */ DEBUG_PRINTF(TZLOG,DBG_INDENT, (CYAN,MSGNot("... Done"))); - + /* Mark that we are 'almost' done running. */ zlogBeast->ZLB_CheckpointTakeWorkToDoScheduled = FALSE; - + /**********************************************************/ /*** No more using 'work', because we said we are done! ***/ @@ -559,7 +546,7 @@ void zlog_CheckpointTakeWorkToDoRoutine( */ -STATUS zlog_CommonCreateAndOpen( +STATUS zlog_CommonCreateAndOpen( GeneralMsg_s *genMsg, ZlogBeast_s *zlogBeast ) @@ -570,9 +557,9 @@ STATUS zlog_CommonCreateAndOpen( ASSERT_MPKNSS_LOCK(); ENTER(TZLOG, zlog_CommonCreateAndOpen); /* - * We assume at least 4096 byte blocks. I.E. we document that - * we can log ZLOG_MAXIMUM_RECORD_SIZE which is about 4096 bytes. - */ + * We assume at least 4096 byte blocks. I.E. we document that + * we can log ZLOG_MAXIMUM_RECORD_SIZE which is about 4096 bytes. + */ zASSERT( zlogBeast->ZFSLOGblkSizeShift >= 12 ); zfsPool = zlogBeast->ZFSLOGroot.vol.zfsVol->pool; @@ -585,18 +572,18 @@ STATUS zlog_CommonCreateAndOpen( zASSERT( COMN_IsDerivedFrom(zlssPool, zFTYPE_ZLSS_LOGICAL_POOL) ); /* - * Install is suppose to create with at least 1024 original blocks. - * This is a requirement of the ZLOG specification. - */ + * Install is suppose to create with at least 1024 original blocks. + * This is a requirement of the ZLOG specification. + */ WARN( zlogBeast->ZFSLOGroot.eof >= ZLOG_FILE_SIZE_MINIMUM ); /* */ if ( zlogBeast->ZFSLOGroot.eof >= ZLOG_FILE_SIZE_MINIMUM ) { /* - * Calculate number of log blocks (originals and duplicates) in - * the pool log file. - */ - zlogBeast->ZLB_NumberOfLogBlocks = zlogBeast->ZFSLOGroot.eof / - (1 << zlogBeast->ZFSLOGblkSizeShift); + * Calculate number of log blocks (originals and duplicates) in + * the pool log file. + */ + zlogBeast->ZLB_NumberOfLogBlocks = zlogBeast->ZFSLOGroot.eof / + (1 << zlogBeast->ZFSLOGblkSizeShift); } else { /* The file is just too small for logging to occur successfully */ @@ -605,19 +592,19 @@ STATUS zlog_CommonCreateAndOpen( RTN_STATUS(zERR_ZLOG_FILE_TOO_SMALL); } /* - * Calculate number of log blocks that must be in use before we - * throttle back and throttle full. This formula is - * specified by the ZLOG specification. - */ + * Calculate number of log blocks that must be in use before we + * throttle back and throttle full. This formula is + * specified by the ZLOG specification. + */ zlogBeast->ZLB_P.ZLBP_FileThrottleFull = zlogBeast->ZLB_NumberOfLogBlocks * - zlogBeast->ZLB_P.ZLBP_FileThrottleFullPercent / 100u; + zlogBeast->ZLB_P.ZLBP_FileThrottleFullPercent / 100u; zlogBeast->ZLB_P.ZLBP_FileThrottleBack = zlogBeast->ZLB_NumberOfLogBlocks * - zlogBeast->ZLB_P.ZLBP_FileThrottleBackPercent / 100u; + zlogBeast->ZLB_P.ZLBP_FileThrottleBackPercent / 100u; /* - * Calculate number of log blocks that will be filled in prior to - * taking a new checkpoint. This formula is specified by the ZLOG - * specification. - */ + * Calculate number of log blocks that will be filled in prior to + * taking a new checkpoint. This formula is specified by the ZLOG + * specification. + */ if ( zlogBeast->ZLB_NumberOfLogBlocks > (ZLOG_CHECKPOINT_BLOCK_FILLED_IN_MAXIMUM * ZLOG_CHECKPOINTS_BEFORE_WARP_MINIMUM( @@ -628,8 +615,8 @@ STATUS zlog_CommonCreateAndOpen( } else { /* We must take at least ZLOG_CHECKPOINTS_BEFORE_WARP_MINIMUM - * checkpoints before wrapping. - */ + * checkpoints before wrapping. + */ zlogBeast->ZLB_LogBlockFilledInMaximum = zlogBeast->ZLB_NumberOfLogBlocks / ZLOG_CHECKPOINTS_BEFORE_WARP_MINIMUM( @@ -637,11 +624,11 @@ STATUS zlog_CommonCreateAndOpen( } /* - * Blast in the saved persistent counts if the user has not - * done a statistics RESET since last load. This logic - * allows the user to reset the statistics when the pool in - * non-active. - */ + * Blast in the saved persistent counts if the user has not + * done a statistics RESET since last load. This logic + * allows the user to reset the statistics when the pool in + * non-active. + */ if ( zlssPool->ZP_StatisticsResetCommandUTCTime <= zlogBeast->ZLB_P.ZLBP_StatisticsResetUTCTime ) { memcpy( &zlssPool->ZP_PRS, &zlogBeast->ZLB_P.ZLBP_StatisticsRead, @@ -652,10 +639,10 @@ STATUS zlog_CommonCreateAndOpen( } /* - * Update NSS version numbers here so that ZLOG contains - * the version of the running system verses the version - * of the system running when the pool was initialized. - */ + * Update NSS version numbers here so that ZLOG contains + * the version of the running system verses the version + * of the system running when the pool was initialized. + */ zlogBeast->ZLB_P.ZLBP_ZSTOREMajorVersion = ZSTORE_VersionInfo.majorVersion; zlogBeast->ZLB_P.ZLBP_ZSTOREMinorVersion = ZSTORE_VersionInfo.minorVersion; zlogBeast->ZLB_P.ZLBP_ZSTORESubVersion = ZSTORE_VersionInfo.subVersion; @@ -665,7 +652,7 @@ STATUS zlog_CommonCreateAndOpen( } /* End of zlog_CommonCreateAndOpen */ /**************************************************************************** - * ZFS log beast constructor + * ZFS log beast constructor * * When a beast is 'created' only its constructor gets called. When * a beast is 'opened' the constructor is called then the unpack routine. @@ -692,10 +679,10 @@ STATUS Zlog_Construct( #endif /* - * Latch to help find bugs. None of our other code should be - * getting called before the beast is created, but better safe - * than sorry. - */ + * Latch to help find bugs. None of our other code should be + * getting called before the beast is created, but better safe + * than sorry. + */ // X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); /*** Assert some basic stuff the code assumes ***/ @@ -726,12 +713,12 @@ STATUS Zlog_Construct( zASSERT( sizeof( ZLOGBlockHeader_s ) == ALIGN( sizeof( ZLOGBlockHeader_s ), 8 )); /* - * Verify documented record size is still smaller than or equal - * to actual maximum record size. If this ASSERT appears then we - * need to change the documented record size and deal with the side - * effects of reducing the allowabe log record size on our other - * ZFS components. - */ + * Verify documented record size is still smaller than or equal + * to actual maximum record size. If this ASSERT appears then we + * need to change the documented record size and deal with the side + * effects of reducing the allowabe log record size on our other + * ZFS components. + */ zASSERT( ZLOG_MAXIMUM_RECORD_SIZE <= zlog_MAXIMUM_RECORD_SIZE ); #if ZLOG_TEST IS_ENABLED @@ -755,15 +742,15 @@ STATUS Zlog_Construct( /*** Initialize all non-persistent ZLOG beast items ***/ /* - * Flag that this beast can not be written to the beast Tree - */ + * Flag that this beast can not be written to the beast Tree + */ zlogBeast->ZFSLOGroot.bstState |= BST_STATE_DO_NOT_WRITE; /* - * Note that the beast is initialized to zero by the beast - * sub-system and therefore we just comment out items that need - * to be zeroed. - */ + * Note that the beast is initialized to zero by the beast + * sub-system and therefore we just comment out items that need + * to be zeroed. + */ zlogBeast->ZLB_Signature = ZLOG_ZLB_S_SIGNATURE; /* Start with no log blocks filled in since last checkpoint. */ @@ -771,35 +758,35 @@ STATUS Zlog_Construct( /* zlogBeast->ZLB_LogBlockFilledInCount = 0; */ /* zlogBeast->ZLB_LogRecordFilledInCount = 0; */ /* - * To simplify logic only ZLOG_ObtainRecord() ever reads a block. - * So we just need to NULL buffer to indicate no current block. - */ + * To simplify logic only ZLOG_ObtainRecord() ever reads a block. + * So we just need to NULL buffer to indicate no current block. + */ /* zlogBeast->ZLB_Buffer = NULL; */ zlogBeast->ZLB_RedoUndoStatus = zOK; zlogBeast->ZLB_RedoUndoStatusSetter = WHERE; zlogBeast->ZLB_ActiveHasBeenRead = FALSE; - /* - * Have DQ system initialize our ZfsXaction_s seniority DQ head. - * DQ of all active transactions order by oldest to youngest. Used to - * determine when the home pointer and home pointer LSN can be moved - * forward. Transactions get placed on list by ZLOG_ObtainRecord() and - * removed by ZLOG_TransactionHomed(). - */ + /* + * Have DQ system initialize our ZfsXaction_s seniority DQ head. + * DQ of all active transactions order by oldest to youngest. Used to + * determine when the home pointer and home pointer LSN can be moved + * forward. Transactions get placed on list by ZLOG_ObtainRecord() and + * removed by ZLOG_TransactionHomed(). + */ DQ_INIT( &zlogBeast->ZLB_SeniorityListHead ); - /* - * Have DQ system initialize our Buffer_s seniority DQ head. - * DQ of all not flushed buffers order by oldest to youngest. Used to - * determine when we can forward the signal to bound DATA buffers. - * Buffers get placed on list by ZLOG_ObtainRecord() and - * removed by Zlog_FlushBlockEndSignalHandler(). - */ + /* + * Have DQ system initialize our Buffer_s seniority DQ head. + * DQ of all not flushed buffers order by oldest to youngest. Used to + * determine when we can forward the signal to bound DATA buffers. + * Buffers get placed on list by ZLOG_ObtainRecord() and + * removed by Zlog_FlushBlockEndSignalHandler(). + */ DQ_INIT( &zlogBeast->ZLB_CachedBufferListHead ); /* - * Currently - initialing a latch zeros/nulls out some fields. It - * does not seem worth the possible trouble to comment out the - * init just in case it changes (I.E. Latching is not documented so - * who knows if it must be able to take a ZEROed latch). - */ + * Currently - initialing a latch zeros/nulls out some fields. It + * does not seem worth the possible trouble to comment out the + * init just in case it changes (I.E. Latching is not documented so + * who knows if it must be able to take a ZEROed latch). + */ INIT_LATCH( &zlogBeast->ZLB_RecoveryLatch ); INIT_LATCH( &zlogBeast->ZLB_FileFullLatch ); @@ -874,7 +861,7 @@ STATUS Zlog_Construct( #endif #if ZLOG_USE_SYSTEMS_WORK_TO_DO fillInWork( &zlogBeast->ZLB_CheckpointTakeWorkToDoStructure, - (voidfunc_t)zlog_CheckpointTakeWorkToDoRoutine, zlogBeast); + zlog_CheckpointTakeWorkToDoRoutine, zlogBeast); #else FSMLITE_INIT( &zlogBeast->ZLB_CheckpointTakeWorkToDoFsm /* Lite FSM */, MSGNot("ZLOG Checkpoint Work-To-Do"), 0 /* Instance */ ); @@ -896,8 +883,8 @@ STATUS Zlog_Construct( #if LOG_TEST IS_ENABLED for (i = 0; i < LOG_TEST_MAX; ++i) { - zlogBeast->ZLB_LT[i].LT_Copy = - zalloc(1 << zlogBeast->ZFSLOGblkSizeShift ); + zlogBeast->ZLB_LT[i].LT_Copy = + zalloc(1 << zlogBeast->ZFSLOGblkSizeShift ); zASSERT( zlogBeast->ZLB_LT[i].LT_Copy != NULL ); } #endif @@ -930,13 +917,13 @@ void Zlog_Destruct( zASSERT( zlogBeast->ZFSLOGroot.eof >= ZLOG_FILE_SIZE_MINIMUM ); /* I placed this code in because DESTRUCT was being called - * with items on the list. I have since made changes to - * pool deactivate which also does the same code. See - * pool deactivate for details. The bottom line is that - * this code should not be needed anymore, but it does - * no harm so I left it in. - */ - while ( (!(DQ_EMPTY( &zlogBeast->ZLB_SeniorityListHead )) ) && + * with items on the list. I have since made changes to + * pool deactivate which also does the same code. See + * pool deactivate for details. The bottom line is that + * this code should not be needed anymore, but it does + * no harm so I left it in. + */ + while ( (!(DQ_EMPTY( &zlogBeast->ZLB_SeniorityListHead )) ) && ( count < ((15 * 1000)/ZLOG_WORK_CHECKPOINT_WAIT_DELAY)) ) { #if NSS_ASSERT IS_ENABLED @@ -950,48 +937,48 @@ void Zlog_Destruct( /* If we have been doing this for 15 secs then ASSERT */ zASSERT( count < ((15 * 1000)/ZLOG_WORK_CHECKPOINT_WAIT_DELAY) ); - /* - * Can not have next ASSERT because if we get an error while - * creating a pool the signature is not filled in. The above - * ASSERT will have to be good enough. - */ + /* + * Can not have next ASSERT because if we get an error while + * creating a pool the signature is not filled in. The above + * ASSERT will have to be good enough. + */ // zASSERT( zlogBeast->ZLB_P.ZLBP_Signature == ZLOG_ZLBP_S_SIGNATURE ); /* Cancel checkpoint timer (this works even if not scheduled) */ CANCEL_ALARM( zlogBeast->ZLB_CheckpointTakeWorkToDoTimer ); /* We can still have a work-to-do scheduled. If so wait - * for it to complete before we allow the ZLOG beast to - * disappear on the work-to-do. - */ + * for it to complete before we allow the ZLOG beast to + * disappear on the work-to-do. + */ WARN( !zlogBeast->ZLB_CheckpointTakeWorkToDoScheduled ); WARN( !zlogBeast->ZLB_BarrierWorkToDoScheduled ); while ( zlogBeast->ZLB_CheckpointTakeWorkToDoScheduled || zlogBeast->ZLB_BarrierWorkToDoScheduled ) { /* - * Delay to give Work-to-do time to run. We do not do a yield - * because no documentation on work-to-do priority and no info - * on if yield lets 'lower' (less important) threads run. We - * could add cancel code, but this code will work and cancel - * could return a error anyway. We unlatch because the work-to-do - * will need to obtain to do a checkpoint. - */ - + * Delay to give Work-to-do time to run. We do not do a yield + * because no documentation on work-to-do priority and no info + * on if yield lets 'lower' (less important) threads run. We + * could add cancel code, but this code will work and cancel + * could return a error anyway. We unlatch because the work-to-do + * will need to obtain to do a checkpoint. + */ + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); LB_delay( ZLOG_WORK_CHECKPOINT_WAIT_DELAY ); /* 20 millisecs */ X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); - + #if NSS_ASSERT IS_ENABLED ++count; /* Not in ASSERT macro just in case of side-effects */ #endif /* If we have been doing this for 15 secs then ASSERT */ zASSERT( count < ((15 * 1000)/ZLOG_WORK_CHECKPOINT_WAIT_DELAY) ); } - + /* - * If we ever see this ASSERT then we can .. - * LB_delay() until the work to do runs and/or - * cancel the work to do. - */ + * If we ever see this ASSERT then we can .. + * LB_delay() until the work to do runs and/or + * cancel the work to do. + */ /* Should only be called if our constructor returned zOK */ zASSERT( zlogBeast->ZLB_DebugState >= ZLOG_ZB_DS_CONSTRUCT_END); @@ -1003,9 +990,9 @@ void Zlog_Destruct( #endif while ( zlogBeast->ZLB_Buffer != NULL ) { /* - * Delay to give buffer time to flush. We unlatch because the - * flush handler will need to obtain to complete the flush. - */ + * Delay to give buffer time to flush. We unlatch because the + * flush handler will need to obtain to complete the flush. + */ UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); LB_delay( ZLOG_WORK_FLUSH_WAIT_DELAY ); /* 100 millisecs */ X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); @@ -1016,12 +1003,12 @@ void Zlog_Destruct( zASSERT( count < ((20 * 1000)/ZLOG_WORK_FLUSH_WAIT_DELAY) ); } /* - * Verify that both DQ's are empty. - * If ZLB_SeniorityListHead asserts then some transactions - * never got homed? - * If ZLB_CachedBufferListHead asserts then some ZLOG buffers - * got tossed instead of flushed? - */ + * Verify that both DQ's are empty. + * If ZLB_SeniorityListHead asserts then some transactions + * never got homed? + * If ZLB_CachedBufferListHead asserts then some ZLOG buffers + * got tossed instead of flushed? + */ zASSERT( DQ_EMPTY( &zlogBeast->ZLB_SeniorityListHead ) ); zASSERT( DQ_EMPTY( &zlogBeast->ZLB_CachedBufferListHead ) ); #if LOG_TEST IS_ENABLED @@ -1067,13 +1054,13 @@ void Zlog_FlushBlockDoneSignalHandler( zASSERT( zlogBeast->ZLB_Signature == ZLOG_ZLB_S_SIGNATURE ); zASSERT( zlogBeast->ZFSLOGroot.eof >= ZLOG_FILE_SIZE_MINIMUM ); zASSERT( zlogBeast->ZLB_P.ZLBP_Signature == ZLOG_ZLBP_S_SIGNATURE ); - ASSERT_SLATCH( &flushedBuffer->agent.latch ); + ASSERT_SLATCH( &flushedBuffer->agent.latch ); /* Now remove the oldest buffer as long as it has been flushed. */ count = 0; for ( ;; ) { - + DQ_PEEK( &zlogBeast->ZLB_CachedBufferListHead, oldestBuffer, Buffer_s, signalLink ); if ( (oldestBuffer == NULL) || @@ -1083,7 +1070,7 @@ void Zlog_FlushBlockDoneSignalHandler( (QUAD)count ); ZLOG_HISTORY_EVENT( &zlogBeast->ZLB_DeferredWritesHistory, (QUAD)count ); - + RTN_VOID(); } ++count; @@ -1096,23 +1083,23 @@ void Zlog_FlushBlockDoneSignalHandler( logBlockHeader = (ZLOGBlockHeader_s *)oldestBuffer->pBuf.data; zASSERT( logBlockHeader->ZLBH_Signature == ZLBH_S_SIGNATURE ); /* Assert if this is the BLOCK someone wishes to be - * told when written. This can be used to crash - * the machine where a ZLOG record is written and the - * meta data block not written. - */ + * told when written. This can be used to crash + * the machine where a ZLOG record is written and the + * meta data block not written. + */ zASSERT( (logBlockHeader->ZLBH_FileBlockNumber != gZlogAssertBlock) || (gZlogAssertBlock == 0xfffffffful) ); } #endif ASSERT_SLATCH( &oldestBuffer->agent.latch ); - /* Pass the signal through */ + /* Pass the signal through */ defaultSignal( &oldestBuffer->agent ); /* The above routine unlatched our shared latch on the buffer */ /* - * We release with push because we will not need because we only - * do CACHE_WRITE which means we do not read the current data - * of the file. - */ + * We release with push because we will not need because we only + * do CACHE_WRITE which means we do not read the current data + * of the file. + */ CACHE_SIGNAL_RELEASE_PUSH( oldestBuffer ); } } /* End of Zlog_FlushBlockDoneSignalHandler() */ @@ -1143,25 +1130,25 @@ void Zlog_FlushBlockStartSignalHandler( zASSERT( zlogBeast->ZLB_P.ZLBP_Signature == ZLOG_ZLBP_S_SIGNATURE ); ASSERT_SLATCH( &buffer->agent.latch ); - + /* Are we flushing the current active ZLOG buffer? */ if ( buffer == zlogBeast->ZLB_Buffer ) { /* Yes - then we need to zap ZLOG's buffer pointer */ zlogBeast->ZLB_Buffer = NULL; } - + /*** Fill in last of Block Header and then write log block ***/ /* - * FixFixFix6(Future,If reading ZLOG file supported) - * Technically we need to have an exclusive latch on buffer - * when updating it. We do not do because we have no readers - * of the ZLOG file while ZLOG is running. If this changes then - * we will need to up the latch (with correct FSM coding). - * - * UP_LATCH( &agent->latch ); - */ + * FixFixFix6(Future,If reading ZLOG file supported) + * Technically we need to have an exclusive latch on buffer + * when updating it. We do not do because we have no readers + * of the ZLOG file while ZLOG is running. If this changes then + * we will need to up the latch (with correct FSM coding). + * + * UP_LATCH( &agent->latch ); + */ logBlockHeader = (ZLOGBlockHeader_s *)buffer->pBuf.data; zASSERT( logBlockHeader->ZLBH_Signature == ZLBH_S_SIGNATURE ); @@ -1172,9 +1159,9 @@ void Zlog_FlushBlockStartSignalHandler( /* Debug. Zero all of the unused longs */ if ( logBlockHeader->ZLBH_NumberOfUnusedLongs != 0 ) { /* - * My doc does not say what memset() does if length is zero - * so best not to find out. - */ + * My doc does not say what memset() does if length is zero + * so best not to find out. + */ unusedArea = ((LONG *)logBlockHeader) + (((1 << zlogBeast->ZFSLOGblkSizeShift)/4) - logBlockHeader->ZLBH_NumberOfUnusedLongs); @@ -1195,19 +1182,19 @@ void Zlog_FlushBlockStartSignalHandler( ((1 << zlogBeast->ZFSLOGblkSizeShift)/4) - logBlockHeader->ZLBH_NumberOfUnusedLongs ); /* - * FixFixFix6(Future,If reading ZLOG file supported) - * - * DOWN_LATCH( &agent->latch ); - */ + * FixFixFix6(Future,If reading ZLOG file supported) + * + * DOWN_LATCH( &agent->latch ); + */ if ( GCL_ZLSSJournal == 8615960 ) { /* This is for performance testing. Added for Ben so - * that we can test how much ZLOG writes slow down - * our performance. If the above global is set to - * the magic number then we will SKIP all - * the ZLOG buffer writes. This is not for the customer - * to use as if we crash we will have a corrupt volume. - */ + * that we can test how much ZLOG writes slow down + * our performance. If the above global is set to + * the magic number then we will SKIP all + * the ZLOG buffer writes. This is not for the customer + * to use as if we crash we will have a corrupt volume. + */ cachePrepareToFlush(buffer); CACHE_CLEAN(buffer); Zlog_FlushBlockDoneSignalHandler(agent); @@ -1216,7 +1203,7 @@ void Zlog_FlushBlockStartSignalHandler( ZFS_DoBlockWriteFromSignal( agent, &Zlog_FlushBlockDoneSignalHandler /*,0 */); RTN_VOID(); - + } /* End of Zlog_FlushBlockStartSignalHandler */ @@ -1252,7 +1239,7 @@ ObjCache_s ZlssBarrierObjCache; are the barrier agent primary object. */ BOOL ZlssBarrierObjCacheInited = FALSE; /*int ZLSSBarrierWaitSecs = 1;*/ - // TODO(Perf): allow less than a second + // TODO(Perf): allow less than a second /* Number of seconds before a group write should occur on journal blocks. We get better performance by grouping journal block writes, but increasing this global causes @@ -1289,7 +1276,6 @@ void ZLSSDoBarrierWriteIfRequired( struct zConPool_s *phyPool ) { ZIO_GatherDetailedSummaryInformationBarrierIOs( phyPool ); } -#if defined(NSS_BLOCK_IO) MPKNSS_UNLOCK(); flushRet = blkdev_issue_flush( phyPool->ZCP_dev, NULL); if (flushRet == -EOPNOTSUPP) @@ -1297,17 +1283,12 @@ void ZLSSDoBarrierWriteIfRequired( struct zConPool_s *phyPool ) phyPool->ZCP_BarrierWritesRequired = FALSE; } MPKNSS_LOCK(); -#else - flushRet = -EOPNOTSUPP; - phyPool->ZCP_BarrierWritesRequired = FALSE; - (void)flushRet; -#endif } return; } -/* +/* ZlssBarrier_s_InitOnce() - Iniitializes items in a ZlssBarrier_s that only need to be initialized once. @@ -1315,14 +1296,14 @@ void ZLSSDoBarrierWriteIfRequired( struct zConPool_s *phyPool ) void ZlssBarrier_s_InitOnce(ZlssBarrier_s *barrier) { initAgent(&barrier->ZB_Agent, - Zlog_BarrierFlushBlockStartSignalHandler, "ZLOG Barrier"); + Zlog_BarrierFlushBlockStartSignalHandler, "ZLOG Barrier"); barrier->ZB_Signature = ZLSS_BARRIER_SIGNATURE; NULLIFY(&barrier->ZB_BarrierLink); return; } -/* +/* ZLSS_BarrierStart() - Initialize resources used by ZLSS barrier write (device flush) system. Called via ZSTORE_GlobalStartup when ZLSS is loaded. @@ -1333,7 +1314,7 @@ STATUS ZLSS_BarrierStart( GeneralMsg_s *genMsg ) STATUS retCode; retCode = objCacheCreate(&ZlssBarrierObjCache, "ZLSS Barriers", - sizeof(ZlssBarrier_s), (voidfunc_t)ZlssBarrier_s_InitOnce); + sizeof(ZlssBarrier_s), ZlssBarrier_s_InitOnce); if ( retCode != zOK ) { SetErrno( genMsg, retCode ); @@ -1360,11 +1341,11 @@ void ZLSS_BarrierStop( ) /* - zlog_BarrierWorkToDoRoutine() - + zlog_BarrierWorkToDoRoutine() - Work-to-do that does a barrier write for all barrier agents that have been signaled (or are signaled before the thread completes). - - Synchronous and blocking + + Synchronous and blocking */ void zlog_BarrierWorkToDoRoutine( FsmLite_s *workToDoFsm ) @@ -1423,7 +1404,7 @@ MoreMayHaveBeenAddedDuringBarrierWrite: /* This is called when someone wishes to take an asynchronous barrier. - + Asynchronous and non-blocking, no notification of completion. */ static void zlog_BarrierSchedule( @@ -1447,7 +1428,7 @@ static void zlog_BarrierSchedule( zlogBeast->ZLB_BarrierWorkToDoScheduled = TRUE; /* Schedule a thread to do the work later (we must not block) */ WORK_Schedule_HIGH( &zlogBeast->ZLB_BarrierWorkToDoFsm, //TODO(Perf,now): Should it be WORK_Schedule of WORK_Schedule_HIGH? - (voidfunc_t)zlog_BarrierWorkToDoRoutine, 0 ); + zlog_BarrierWorkToDoRoutine, 0 ); return; } /* End of zlog_BarrierSchedule() */ @@ -1475,7 +1456,7 @@ static inline void ZLSSBarrierBind( ZlssBarrier_s *barrier, Buffer_s *buffer ) } -/* +/* ZlssBarrier_s_Construct() - Returns a new X_LATCHed instance of a ZlssBarrier_s object. */ @@ -1495,8 +1476,8 @@ ZlssBarrier_s *ZlssBarrier_s_Construct( ZlogBeast_s *zlogBeast ) } -/* - Can be called in timer pop so must not block. +/* + Can be called in timer pop so must not block. */ void ZlssBarrier_s_Destruct( ZlssBarrier_s *barrier ) { @@ -1508,20 +1489,20 @@ void ZlssBarrier_s_Destruct( ZlssBarrier_s *barrier ) /* This routine MUST only be called from Signal Handlers. */ -/* - Can be called in timer pop so must not block. +/* + Can be called in timer pop so must not block. */ void ZlssBarrierSignalRelease(ZlssBarrier_s *barrier) { if ( LATCH_FREE( &(barrier->ZB_Agent.latch)) ) { ZlssBarrier_s_Destruct( barrier ); - } + } return; } -/* +/* Zlog_BarrierFlushBlockStartSignalHandler() - Flush handler for barrier write. The barrier agent sits between the journal blocks and the metadata blocks. It gives us a nice place @@ -1618,7 +1599,7 @@ NINT zlog_GetOldestCheckpointIndex( ZlogBeast_s *zlogBeast ) } /* End of zlog_GetOldestCheckpointIndex() */ /* - * + * */ void zlog_HistogramEvent(ZlogHistogram_s *histogram, QUAD event) { @@ -1683,13 +1664,13 @@ void zlog_HistogramEvent(ZlogHistogram_s *histogram, QUAD event) // { // /* Lowest to higest ordered list sorted by event value */ // for ( index = 0; index < ZLOG_HWB_DEFAULT-1; index++ ) -// { +// { // if ( event < // histogram->ZH_Watermarks.ZHW_Bucket[index+1].ZHWB_Event ) // { // break; // } -// histogram->ZH_Watermarks.ZHW_Bucket[index] = +// histogram->ZH_Watermarks.ZHW_Bucket[index] = // histogram->ZH_Watermarks.ZHW_Bucket[index+1]; // } // histogram->ZH_Watermarks.ZHW_Bucket[index].ZHWB_Event = event; @@ -1712,7 +1693,7 @@ void zlog_HistoryEvent(ZlogHistory_s *history, QUAD event) { /* Lowest to higest ordered list sorted by event value */ for ( index = 0; index < history->ZH_WatermarkCount-1; index++ ) - { + { if ( event < slots[index+1].ZHWB_Event ) { break; @@ -1769,14 +1750,14 @@ void zlog_LogRecordDump( ZLOGRecordHeader_s *logRecordHeader, DEBUG_HEX_DUMP( TZLOG2, TZLOG2_COLOR, DHD_DM_BYTE | DHD_DM_ASCII, (void *)(blkInfo + logRec->ZXR_PoolBlockCount), (int)((logRecordHeader->ZLRH_LongLength * 4) - - sizeof( ZLOGRecordHeader_s ) - + sizeof( ZLOGRecordHeader_s ) - ZLOG_BLOCK_INFO_SIZE( logRec->ZXR_PoolBlockCount)) ); } return; } /* End of zlog_LogRecordDump() */ #endif - + #if LOG_TEST IS_ENABLED NINT ZLOGDoLogAsserts = 1; /* Maximum number of asserts per data buffer */ @@ -1807,7 +1788,7 @@ STATUS zlog_LogTestCompare( { zASSERT("Someone is not doing undo/redo correctly?" == NULL); } - } + } } if ( mismatches == 0 ) { @@ -1829,7 +1810,7 @@ LONG CacheFlushAtJournalPercent = 25; * * STATUS ZLOG_ObtainRecord(GeneralMsg_s *genMsg, NINT recordSize, * RootBeast_s *rootBeast, ZfsXaction_s *zlogXaction) - * + * * genMsg Contains thread specific error information. ZLOG will set the * errno field when zOK is not returned. * recordSize The number of bytes needed in the data portion of the pool @@ -1841,19 +1822,19 @@ LONG CacheFlushAtJournalPercent = 25; * connected with the current volume and the beast class * identifier so that it can be stored into the log record. * zlogXaction The transaction structure that this log record will be part of. - * + * * This function obtains a log record for the transaction associated with the * zlogXaction. The caller then fills in the log record. The caller then - * releases the log record with a call to ZLOG_ReleaseRecord(). - * + * releases the log record with a call to ZLOG_ReleaseRecord(). + * * The transaction's state must be correct when ZLOG_ObtainRecord() is called. - * + * * The error return value zOK indicates the call succeeded and that the other * return values can be used. All other returns indicate an error in obtaining * a log record. - * + * * ZLOG_ObtainRecord() returns the following information in the ZLOG beast. - * + * * ZLB_CommitAgent Type of Agent_s. ZLOG's Commit Agent used by callers to * bind with ZLOG. ZLOG will use to signal that the Log * Record has been flushed. This will be a define that @@ -1863,20 +1844,20 @@ LONG CacheFlushAtJournalPercent = 25; * description of the ZfsXasRecovery_s structure. The * caller€s beast specific information can be stored at * zlogBeast->ZLB_ZfsXasRecovery+1. - * + * * The ZLOG beast is pointed to by element zfsLogBeast within the ZfsPool_s * structure. In addition, it is pointed to by element zfsLogBeast within * the ZfsVolume_s structure. All beasts contain a pointer to the volume * the beast resides on. Also, ZfsXaction_s has a element called ZX_zlogBeast * that points to the ZLOG beast. This field is only valid after a successful * return from ZLOG_ObtainRecord(). - * + * * The caller must call ZLOG_ReleaseRecord() after each call to * ZLOG_ObtainRecord(). The caller must not block the FSM between these calls * because ZLOG is serialized per pool during this period. - * + * * Function Implementation Details - * + * * ZLOG will store homing information into the transaction structure whenever * the transaction's state is XAS_XR_TS_START. ZLOG will store the LSN and * Log Block number being used by the start log record of the transaction. @@ -1888,11 +1869,11 @@ LONG CacheFlushAtJournalPercent = 25; * See Pool Log File section on page 4 for more information on Home Pointer. * This design is required because we must keep the transaction system separate * from ZLOG. - * + * * ZLOG's beastLatch is exclusively owned on exit. - * + * */ - + void ZLOG_ObtainRecord( ZfsXaction_s *zlogXaction, NINT recordSize ) @@ -1922,10 +1903,10 @@ void ZLOG_ObtainRecord( /* Warn if record size greater than documented allowable size */ // WARN( recordSize <= ZLOG_MAXIMUM_RECORD_SIZE ); /* - * Number of LONGs needed. Note that both values being added - * below are evenly divisible by a QUAD(8). We do not keep in - * QUAD counts because not enough compilers support QUADs - */ + * Number of LONGs needed. Note that both values being added + * below are evenly divisible by a QUAD(8). We do not keep in + * QUAD counts because not enough compilers support QUADs + */ neededLongs = recordSize / 4 + ( sizeof( ZLOGRecordHeader_s )/4 ); zlogBeast = zlogXaction->ZX_zlogBeast; zASSERT(!(zlogBeast->ZLB_State & ZLOG_ZB_S_NEEDTODO_COMPENSATION)); @@ -1934,9 +1915,9 @@ void ZLOG_ObtainRecord( zASSERT( zlogBeast->ZLB_P.ZLBP_Signature == ZLOG_ZLBP_S_SIGNATURE ); ZLOG_HISTOGRAM_EVENT( &zlogBeast->ZLB_SizeHistogram, neededLongs*4u ); - zASSERT(!(zlogBeast->ZFSLOGroot.vol.zfsVol->pool->ZFSPOOLrepairFlags & + zASSERT(!(zlogBeast->ZFSLOGroot.vol.zfsVol->pool->ZFSPOOLrepairFlags & ZP_REPAIRFLAGS_NO_LOGGING_ALLOWED)); - if (zlogBeast->ZFSLOGroot.vol.zfsVol->pool->ZFSPOOLrepairFlags & + if (zlogBeast->ZFSLOGroot.vol.zfsVol->pool->ZFSPOOLrepairFlags & ZP_REPAIRFLAGS_NO_LOGGING_ALLOWED) { ZOS_Abend(MSGNot("During rebuild logging is not allowed.")); @@ -1947,11 +1928,11 @@ void ZLOG_ObtainRecord( zlog_ORTryAgain:; /***************/ /* - * Get exclusive latch. This latch is not released until the user - * calls ZLOG_ReleaseRecord(). The only exception is we will release - * on a full file before we loop back here. - */ - X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + * Get exclusive latch. This latch is not released until the user + * calls ZLOG_ReleaseRecord(). The only exception is we will release + * on a full file before we loop back here. + */ + X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); #if NSS_ASSERT IS_ENABLED /* The unit test is evil so skip this test if unit test is running. */ if ( !ZlogUnitTest ) @@ -1960,88 +1941,88 @@ zlog_ORTryAgain:; } #endif /* - * Check if someone forgot to call ZLOGReleaseRecord which sets - * to NULL. Only works if they also released beastLatch because - * otherwise we are hung in the X_LATCH above. - */ + * Check if someone forgot to call ZLOGReleaseRecord which sets + * to NULL. Only works if they also released beastLatch because + * otherwise we are hung in the X_LATCH above. + */ zASSERT( zlogBeast->ZLB_ZfsXasRecovery == NULL ); /* Make local copy */ if ( zlogBeast->ZLB_ActiveHasBeenRead == FALSE ) { /* - * This test is only TRUE the first time Obtain is called. At - * which time ZLB_Buffer is also NULL (which is required). - */ + * This test is only TRUE the first time Obtain is called. At + * which time ZLB_Buffer is also NULL (which is required). + */ zlogBeast->ZLB_ActiveHasBeenRead = TRUE; goto GetCurrentBlock; } /* - * Now check if defaultFlush (caused by timer pop or a DATA buffer - * wanting to go out or a beast flush) has been called on the - * buffer we are currently using. If any of the above have occurred - * our flush block start handler NULLs out our buffer pointer. We - * useMPKNSS_LOCK() for protection because our handler can not - * get a latch on the ZLOG beast to protect ZLB_Buffer. Because - * our signal handler has a shared latch on the buffers agent latch - * and aMPKNSS_LOCK() we can use either latch method to protect - * ZLB_Buffer. - */ - + * Now check if defaultFlush (caused by timer pop or a DATA buffer + * wanting to go out or a beast flush) has been called on the + * buffer we are currently using. If any of the above have occurred + * our flush block start handler NULLs out our buffer pointer. We + * useMPKNSS_LOCK() for protection because our handler can not + * get a latch on the ZLOG beast to protect ZLB_Buffer. Because + * our signal handler has a shared latch on the buffers agent latch + * and aMPKNSS_LOCK() we can use either latch method to protect + * ZLB_Buffer. + */ + #if NSS_DEBUG IS_ENABLED if ( zlogBeast->ZLB_P.ZLBP_Mode & ZLOG_THROTTLE_BACK ) { /* Track number of obtains we have while in throttle back mode. - * Only done in debug mode because not worth the cycles in - * the production system. - */ + * Only done in debug mode because not worth the cycles in + * the production system. + */ ++zlogBeast->ZLB_P.ZLBP_FileThrottleSkipCount; } #endif if ( zlogBeast->ZLB_Buffer == NULL ) { /* - * defaultFlush() has been called on our buffer. Just go get - * the next block. - */ - + * defaultFlush() has been called on our buffer. Just go get + * the next block. + */ + goto GetNextBlock; } else - { + { NINT waitFlag; buffer = zlogBeast->ZLB_Buffer; /* - * We will use the XLATCH code that will not block is we can - * not get an X Latch. - */ + * We will use the XLATCH code that will not block is we can + * not get an X Latch. + */ X_NOWAIT( &buffer->agent.latch, waitFlag ); /* Is the latch owned by someone else? */ if ( waitFlag == WAITED ) { /* - * Yes - then we will just go to the next buffer. Note that - * this works because we have marked the buffer dirty and - * filled in one record in it when we first grabbed it. The - * timer in it will defaultFlush it at some point and our - * signal handler will checksum it. - */ + * Yes - then we will just go to the next buffer. Note that + * this works because we have marked the buffer dirty and + * filled in one record in it when we first grabbed it. The + * timer in it will defaultFlush it at some point and our + * signal handler will checksum it. + */ zlogBeast->ZLB_Buffer = NULL; - + goto GetNextBlock; } - + zASSERT( zlogBeast->ZLB_Buffer != NULL ); } /* - * It is O.K. to use the current ZLOG buffer!!! - */ + * It is O.K. to use the current ZLOG buffer!!! + */ /* O.K. to give out log record */ logBlockHeader = (ZLOGBlockHeader_s *)buffer->pBuf.data; - if ( (NINT)logBlockHeader->ZLBH_NumberOfUnusedLongs >= neededLongs ) + if ( (NINT)logBlockHeader->ZLBH_NumberOfUnusedLongs >= neededLongs ) { /* Current log block has enough room for request */ if ( zlogBeast->ZLB_Barrier == NULL ) { /* defaultFlush() has been called on our barrier. Get a new one. */ zlogBeast->ZLB_Barrier = ZlssBarrier_s_Construct(zlogBeast); ZLSSBarrierBind( zlogBeast->ZLB_Barrier, zlogBeast->ZLB_Buffer ); - } else { + } else { NINT waitFlag; X_NOWAIT( &zlogBeast->ZLB_Barrier->ZB_Agent.latch, waitFlag ); @@ -2063,24 +2044,24 @@ zlog_ORTryAgain:; logBlockHeader->ZLBH_Status = ZLBH_S_TOOBIG | ZLBH_S_DEBUG | ZLBH_S_CHECKSUM; /* - * Indicate that we are done with the buffer, before we allow - * shared access which would allow our signal handler access to - * ZLB_Buffer. We do not needMPKNSS_LOCK() here because we have the - * ZLB_Buffer latched. - */ + * Indicate that we are done with the buffer, before we allow + * shared access which would allow our signal handler access to + * ZLB_Buffer. We do not needMPKNSS_LOCK() here because we have the + * ZLB_Buffer latched. + */ zlogBeast->ZLB_Buffer = NULL; /* - * We are now done with this buffer, unlatch and then flush it. - */ + * We are now done with this buffer, unlatch and then flush it. + */ CACHE_UNXLATCH( buffer ); /* - * To write we simply note that we would like to do a flush of - * our buffer. - */ + * To write we simply note that we would like to do a flush of + * our buffer. + */ // defaultFlush( &buffer->agent ); /* - * Write errors show up in our done signal handler. - */ + * Write errors show up in our done signal handler. + */ /*** Get the next log block in the file ***/ /************/ @@ -2089,14 +2070,14 @@ GetNextBlock:; if (zlogBeast->ZLB_State & ZLOG_ZB_S_DOING_COMPENSATION) { /* We are in compensation writing mode. At this time we do not - * want to take checkpoints. We are also making the assumption - * that there are only very few undo records and even fewer logical - * undo records, that the compensation records that are created - * are not enough to fill the log. Also when we start compensation - * records, we have moved home to the beginning of where the logical - * undo records were copied. Thus, at this time we have the whole - * log available for compensation records - */ + * want to take checkpoints. We are also making the assumption + * that there are only very few undo records and even fewer logical + * undo records, that the compensation records that are created + * are not enough to fill the log. Also when we start compensation + * records, we have moved home to the beginning of where the logical + * undo records were copied. Thus, at this time we have the whole + * log available for compensation records + */ /* Accounting */ zlogBeast->ZLB_LogBlockFilledInCount++; @@ -2106,19 +2087,19 @@ GetNextBlock:; goto SkipChkPtAndZlogFullTest; } /* - * We are back the buffer may or may not be flushed, but we - * don't care. - */ + * We are back the buffer may or may not be flushed, but we + * don't care. + */ /* - * The ZLOG code is very dependent that this is the ONLY place a log - * block is obtained for transaction logging. - * - * Verify that we are not about to give out a block that could be - * needed if we crash! - * - * Is the file 'almost' full (I.E. only one block free)? - */ + * The ZLOG code is very dependent that this is the ONLY place a log + * block is obtained for transaction logging. + * + * Verify that we are not about to give out a block that could be + * needed if we crash! + * + * Is the file 'almost' full (I.E. only one block free)? + */ if ( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber == zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber ) { /* Yes - The file is full */ @@ -2138,19 +2119,19 @@ GetNextBlock:; { X_LATCH( &zlogBeast->ZLB_FileFullLatch ); zlogBeast->ZLB_FileFullWaiters = 1; - UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); /* - * By taking a checkpoint here we are hoping to move the - * pre oldest home pointer. This will work until all four - * checkpoints have the same home pointer. At which point, - * file full can only be resolved by home moving. We will - * take four checkpoints here so to max our chances of - * pre home moving and thus getting us out of file full - * condition. More than likily we are full because home - * has not moved in a long time so this code will not move - * the pre oldest home. This code will only help if we have - * not been taking enough checkpoints. - */ + * By taking a checkpoint here we are hoping to move the + * pre oldest home pointer. This will work until all four + * checkpoints have the same home pointer. At which point, + * file full can only be resolved by home moving. We will + * take four checkpoints here so to max our chances of + * pre home moving and thus getting us out of file full + * condition. More than likily we are full because home + * has not moved in a long time so this code will not move + * the pre oldest home. This code will only help if we have + * not been taking enough checkpoints. + */ /* Reset counter */ zASSERT( zlogBeast->ZFSLOGroot.vol.zfsVol->pool != NULL ); DEBUG_PRINTF(TZLOG,DBG_INDENT,(CYAN,MSGNot("Attempting four checkpoint miracle\n"))); @@ -2161,7 +2142,7 @@ GetNextBlock:; for ( checkpoint = 0; checkpoint < CHECKPOINT_NUMBER; ++checkpoint ) { - ZFSPOOL_CheckpointTake( &genMsg, + ZFSPOOL_CheckpointTake( &genMsg, zlogBeast->ZFSLOGroot.vol.zfsVol->pool, CHECKPOINT_CT_S_NORMAL|CHECKPOINT_CT_S_MIRACLE ); } @@ -2174,30 +2155,30 @@ GetNextBlock:; } #endif /* - * Wait for room in the file - I.E. home or pre home moving. - * If our four checkpoints moved pre home then we will rip - * through the S_BARRIER. - */ + * Wait for room in the file - I.E. home or pre home moving. + * If our four checkpoints moved pre home then we will rip + * through the S_BARRIER. + */ S_BARRIER( &zlogBeast->ZLB_FileFullLatch ); goto zlog_ORTryAgain; } - UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); S_BARRIER( &zlogBeast->ZLB_FileFullLatch ); goto zlog_ORTryAgain; } - + if ( !(zlogBeast->ZLB_P.ZLBP_Mode & ZLOG_THROTTLE_BACK) ) { /* In throttle full mode */ NINT blocksInuse; - if ( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber <= + if ( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber <= zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber ) { /* Do wrap math calculation */ blocksInuse = (NINT)zlogBeast->ZLB_NumberOfLogBlocks - (NINT)zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber + - (NINT)zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; - zASSERT( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber != + (NINT)zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; + zASSERT( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber != zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber ); } else @@ -2205,7 +2186,7 @@ GetNextBlock:; blocksInuse = (NINT)zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber - (NINT)zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber; } - + for (i = CacheFlushAtJournalPercent; i < 50; i+=5) { journalCount = (zlogBeast->ZLB_P.ZLBP_FileThrottleBack * 2 * i)/100; @@ -2226,8 +2207,8 @@ GetNextBlock:; #if NSS_DEBUG IS_ENABLED { char buffer[40]; - - + + DBG_DebugPrintf( TZLOG_COLOR, MSGNot("\"%U\" Entering transaction throttle back mode at %s\n"), zlogBeast->ZFSLOGroot.vol.zfsVol->pool->ZFSPOOLroot.name, @@ -2241,18 +2222,18 @@ GetNextBlock:; UTCTime2Str( zlogBeast->ZLB_P.ZLBP_FileThrottleTimeStart, &buffer[0]) ); - + } #endif /* - * We schedule a checkpoint when we enter throttle back - * mode. If checkpoints have not been taken in a while - * then this can free up ZLOG space and thus allow us to - * quickly exit throttle back mode. With current 1/12 - * checkpoint rate the lack of taking checkpoints should - * not be causing the throttle back condition. We take a - * checkpoint here just because it can't hurt. - */ + * We schedule a checkpoint when we enter throttle back + * mode. If checkpoints have not been taken in a while + * then this can free up ZLOG space and thus allow us to + * quickly exit throttle back mode. With current 1/12 + * checkpoint rate the lack of taking checkpoints should + * not be causing the throttle back condition. We take a + * checkpoint here just because it can't hurt. + */ /* Async, non-blocking routine to schedule a checkpoint */ zlog_CheckpointTakeSchedule( zlogBeast, CHECKPOINT_CT_S_NORMAL|CHECKPOINT_CT_S_THROTTLE_BACK ); @@ -2266,13 +2247,13 @@ GetNextBlock:; SNINT delayAmount; /* In milliseconds */ ++zlogBeast->ZLB_P.ZLBP_FileThrottleWaitCount; - - if ( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber <= + + if ( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber <= zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber ) { /* Do wrap math calculation */ blocksInuse = (NINT)zlogBeast->ZLB_NumberOfLogBlocks - (NINT)zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber + - (NINT)zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; + (NINT)zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; zASSERT(zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber != zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber ); } @@ -2295,52 +2276,52 @@ GetNextBlock:; if ( percent < 60u ) { delayAmount = 1000u/2u; /* .5 sec */ - ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait2Count; + ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait2Count; } else { if ( percent < 70u ) { delayAmount = 1000u*1u; /* 1 sec */ - ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait3Count; + ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait3Count; } else { if ( percent < 80u ) { delayAmount = 1000u*10u; /* 10 sec */ - ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait4Count; + ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait4Count; } else { - if ( percent < 90u ) - { - delayAmount = 1000u*100u; /* 100 sec */ - ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait5Count; - } - else - { - delayAmount = 1000u*1000u; /* 1000 sec */ - } + if ( percent < 90u ) + { + delayAmount = 1000u*100u; /* 100 sec */ + ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait5Count; + } + else + { + delayAmount = 1000u*1000u; /* 1000 sec */ + } } } } } - UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); /* The specificaiton requires us not to sleep for - * a long time so that if the throttle mode changes - * our thread gets to run 'right' away. We therefore - * delay 0.1 seconds and then see if still in throttle - * back mode. We also let run when thread has waited - * required amount(remember this prevents deadlocks). - */ + * a long time so that if the throttle mode changes + * our thread gets to run 'right' away. We therefore + * delay 0.1 seconds and then see if still in throttle + * back mode. We also let run when thread has waited + * required amount(remember this prevents deadlocks). + */ do { - LB_delay( 1000u/10u ); + LB_delay( 1000u/10u ); delayAmount -= 1000u/10u; /* Note that we normally are in a MPKNSS_LOCK region - * when looking at the throttle bit. We ignore here - * because it will not cause any serious problems. - */ + * when looking at the throttle bit. We ignore here + * because it will not cause any serious problems. + */ } while ( (delayAmount > 0) && (zlogBeast->ZLB_P.ZLBP_Mode & ZLOG_THROTTLE_BACK) ); @@ -2358,12 +2339,12 @@ GetNextBlock:; zlogBeast->ZLB_LogBlockFilledInMaximum ) { /* Yes - then schedule a checkpoint */ /* - * It is interesting that taking checkpoints when home has not - * moved is just a waste of time! We have one exception to this - * which is the 'miracle four checkpoints' which attempt to move - * pre oldest and not home. Moving home reduces recovery time - * while moving pre oldest home frees space in the ZLOG file. - */ + * It is interesting that taking checkpoints when home has not + * moved is just a waste of time! We have one exception to this + * which is the 'miracle four checkpoints' which attempt to move + * pre oldest and not home. Moving home reduces recovery time + * while moving pre oldest home frees space in the ZLOG file. + */ /* Async, non-blocking routine to schedule a checkpoint */ zlog_CheckpointTakeSchedule( zlogBeast, CHECKPOINT_CT_S_NORMAL|CHECKPOINT_CT_S_ACTIVE_MOVEMENT ); @@ -2380,19 +2361,19 @@ SkipChkPtAndZlogFullTest:; GetCurrentBlock:; /***************/ /* - * Because we always write the full block we do not need to do - * a pre-read. So we are only getting a buffer from the cache system. - * We will have this buffer X latched so our signal handler will not be - * trying to poke ZLB_Buffer so we do not need MPKNSS_LOCK here. - */ + * Because we always write the full block we do not need to do + * a pre-read. So we are only getting a buffer from the cache system. + * We will have this buffer X latched so our signal handler will not be + * trying to poke ZLB_Buffer so we do not need MPKNSS_LOCK here. + */ /* - * Must look on mycache list because we do not toss ALL the time. - * 1). Recovery. - * 2). Other people reading file. - */ - buffer = cacheLookup(&zlogBeast->ZFSLOGmycache, - zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber, - CACHE_WRITE); + * Must look on mycache list because we do not toss ALL the time. + * 1). Recovery. + * 2). Other people reading file. + */ + buffer = cacheLookup(&zlogBeast->ZFSLOGmycache, + zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber, + CACHE_WRITE); if ( buffer == NULL ) { Blknum_t volBlk = 0; @@ -2400,36 +2381,36 @@ GetCurrentBlock:; Blknum_t fileBlk = zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; NINT i; // RootBeast_s - zASSERT(fmap->numRecs > 1); + zASSERT(fmap->numRecs > 1); for (i = 1; i < fmap->numRecs; i++) { if (fmap->dirExt[i].count > fileBlk) { - volBlk = fmap->dirExt[i].poolBlk + - (fileBlk - fmap->dirExt[i-1].count); + volBlk = fmap->dirExt[i].poolBlk + + (fileBlk - fmap->dirExt[i-1].count); break; } } zASSERT(volBlk != 0); /* - * We must know when the cache system flushes our buffer so we - * insert our own handler into the flush path verses the standard - * signal handler. - */ + * We must know when the cache system flushes our buffer so we + * insert our own handler into the flush path verses the standard + * signal handler. + */ buffer = cacheAllocBuffer( &zlogBeast->ZFSLOGmycache, - zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber, - volBlk, &Zlog_FlushBlockStartSignalHandler, - CACHE_WRITE); + zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber, + volBlk, &Zlog_FlushBlockStartSignalHandler, + CACHE_WRITE); zASSERT( buffer != NULL ); } else { /* - * The poke is needed just in case the buffer was originally - * obtained by our recovery code or some one reading the file. - * In these cases the signal handler is the default block handler. - */ + * The poke is needed just in case the buffer was originally + * obtained by our recovery code or some one reading the file. + * In these cases the signal handler is the default block handler. + */ Inst.cache.ioHitSystem++; POKE_SIGNAL_HANDLER( buffer, &Zlog_FlushBlockStartSignalHandler ); } @@ -2438,7 +2419,7 @@ GetCurrentBlock:; if ( zlogBeast->ZLB_Barrier == NULL ) { /* defaultFlush() has been called on our barrier. Get a new one. */ zlogBeast->ZLB_Barrier = ZlssBarrier_s_Construct(zlogBeast); - } else { + } else { NINT waitFlag; X_NOWAIT( &zlogBeast->ZLB_Barrier->ZB_Agent.latch, waitFlag ); @@ -2454,41 +2435,41 @@ GetCurrentBlock:; #endif /* - * Note that we have an exclusive latch on the buffer since we - * will be writing to it. - */ + * Note that we have an exclusive latch on the buffer since we + * will be writing to it. + */ zASSERT( zlogBeast->ZLB_Buffer == NULL ); zlogBeast->ZLB_Buffer = buffer; /* - * Mark buffer as dirty. This also starts a flush timer so that - * this buffer is not held too long. Our flush handler (set above) - * will be called when the timer goes off (or a bound DATA block - * indicates it needs to go out (or someone flushed the ZLOG beast)) - * via calls to defaultFlush(). - */ + * Mark buffer as dirty. This also starts a flush timer so that + * this buffer is not held too long. Our flush handler (set above) + * will be called when the timer goes off (or a bound DATA block + * indicates it needs to go out (or someone flushed the ZLOG beast)) + * via calls to defaultFlush(). + */ CACHE_MARK_DIRTY( buffer ); /* - * Order cached buffers by oldest(lowest LSN) to the youngest - * (highest LSN). The current buffer is the youngest (highest LSN) - * so we put at the end of the cached buffer list. Zlog_WriteBlkEnd() - * will use and then remove from list. - */ - + * Order cached buffers by oldest(lowest LSN) to the youngest + * (highest LSN). The current buffer is the youngest (highest LSN) + * so we put at the end of the cached buffer list. Zlog_WriteBlkEnd() + * will use and then remove from list. + */ + DQ_ENQ( &zlogBeast->ZLB_CachedBufferListHead, buffer, signalLink ); - + logBlockHeader = (ZLOGBlockHeader_s *)buffer->pBuf.data; #if NSS_ASSERT IS_ENABLED || ZLOG_DEBUG IS_ENABLED /* - * Fill complete block with explanation points. This puts - * them in the padding of log records so each log record can be found - * and allows for ASSERTs if someone writes past their log record end. - */ + * Fill complete block with explanation points. This puts + * them in the padding of log records so each log record can be found + * and allows for ASSERTs if someone writes past their log record end. + */ memset( logBlockHeader, 0x44, 1 << zlogBeast->ZFSLOGblkSizeShift ); #endif logBlockHeader->ZLBH_TimeStart = GetUTCTime(); logBlockHeader->ZLBH_Signature = ZLBH_S_SIGNATURE; - zASSERT( LB_GUIDValidate( &zlogBeast->ZFSLOGroot.ROOTinternalID ) ); + zASSERT( LB_GUIDValidate( &zlogBeast->ZFSLOGroot.ROOTinternalID ) ); logBlockHeader->ZLBH_InternalID = zlogBeast->ZFSLOGroot.ROOTinternalID; #if ZLOG_DEBUG IS_ENABLED logBlockHeader->ZLBH_FileBlockNumber = @@ -2553,9 +2534,9 @@ void zlog_ORCommon( logRecordHeader->ZLRH_Zxr.ZXR_PoolBlockCount = 0xBEEFu; #endif // logRecordHeader->ZLRH_Zxr.ZXR_BeastClass = -// rootBeast->beastClass->classID; +// rootBeast->beastClass->classID; logRecordHeader->ZLRH_Zxr.ZXR_TransactionState = zlogXaction->xstate; - /* Update the Pool Log Block Header */ + /* Update the Pool Log Block Header */ logBlockHeader->ZLBH_NumberOfUnusedLongs -= (LONG)neededLongs; logBlockHeader->ZLBH_NumberOfRecords += 1; zlogBeast->ZLB_LogRecordFilledInCount += 1; @@ -2563,37 +2544,37 @@ void zlog_ORCommon( if ( zlogXaction->xstate & XAS_XR_TS_START ) { /* Store LSN and Block number to make moving home easy */ /* - * If already on seniority list then assume a NESTED - * transaction and skip most START items. - */ + * If already on seniority list then assume a NESTED + * transaction and skip most START items. + */ if ( !QMEMBER( &zlogXaction->ZX_seniorityList ) ) { /* Not NESTED */ zlogXaction->ZX_lsn = logRecordHeader->ZLRH_Zxr.ZXR_Lsn; zlogXaction->ZX_logBlockNumber = zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; /* - * Store ZLOG Beast so we can directly access when - * ZLOGTransactionHomed gets called. - */ + * Store ZLOG Beast so we can directly access when + * ZLOGTransactionHomed gets called. + */ zlogXaction->ZX_zlogBeast = zlogBeast; /* - * Order transactions by oldest(lowest LSN) to the - * youngest(highest LSN). The current transaction - * is the youngest (highest LSN) so we put at the - * end of the transaction list. ZLOG_TransactionHomed() will - * use and then remove from list. - */ + * Order transactions by oldest(lowest LSN) to the + * youngest(highest LSN). The current transaction + * is the youngest (highest LSN) so we put at the + * end of the transaction list. ZLOG_TransactionHomed() will + * use and then remove from list. + */ // NULLIFY( &zlogXaction->ZX_seniorityList ); DQ_ENQ( &zlogBeast->ZLB_SeniorityListHead, zlogXaction, ZX_seniorityList ); } /* - * API definition requires us to turn off the start bit. Note - * that we have already stored into log record header. It is - * possible that end bit is set so do not destory because - * ZLOG_ReleaseRecord needs - */ + * API definition requires us to turn off the start bit. Note + * that we have already stored into log record header. It is + * possible that end bit is set so do not destory because + * ZLOG_ReleaseRecord needs + */ zlogXaction->xstate &= ~XAS_XR_TS_START; } /* Set up user return values */ @@ -2609,8 +2590,8 @@ void zlog_ORCommon( * This routine makes copies of logical undo records, tags them as being * copies, and gives them newer LSNs. * - * The code for this routine has been copied from ZLOG_ObtainRecord, - * zlog_ORCommon and ZLOG_ReleaseRecord, and the unwanted pieces + * The code for this routine has been copied from ZLOG_ObtainRecord, + * zlog_ORCommon and ZLOG_ReleaseRecord, and the unwanted pieces * deleted. Any changes to ZLOG_ObtainRecord zlog_ORCommon ZLOG_ReleaseRecord * need to be considered and checked to see if they need to be made in this * routine also. @@ -2635,64 +2616,64 @@ void ZLOG_CopyLogicalUndoRecord( /* Make local copy */ if ( zlogBeast->ZLB_ActiveHasBeenRead == FALSE ) { /* - * This test is only TRUE the first time Obtain is called. At - * which time ZLB_Buffer is also NULL (which is required). - */ + * This test is only TRUE the first time Obtain is called. At + * which time ZLB_Buffer is also NULL (which is required). + */ zlogBeast->ZLB_ActiveHasBeenRead = TRUE; goto GetCurrentBlock; } /* - * Now check if defaultFlush (caused by timer pop or a DATA buffer - * wanting to go out or a beast flush) has been called on the - * buffer we are currently using. If any of the above have occurred - * our flush block start handler NULLs out our buffer pointer. We - * useMPKNSS_LOCK() for protection because our handler can not - * get a latch on the ZLOG beast to protect ZLB_Buffer. Because - * our signal handler has a shared latch on the buffers agent latch - * and aMPKNSS_LOCK() we can use either latch method to protect - * ZLB_Buffer. - */ - + * Now check if defaultFlush (caused by timer pop or a DATA buffer + * wanting to go out or a beast flush) has been called on the + * buffer we are currently using. If any of the above have occurred + * our flush block start handler NULLs out our buffer pointer. We + * useMPKNSS_LOCK() for protection because our handler can not + * get a latch on the ZLOG beast to protect ZLB_Buffer. Because + * our signal handler has a shared latch on the buffers agent latch + * and aMPKNSS_LOCK() we can use either latch method to protect + * ZLB_Buffer. + */ + if ( zlogBeast->ZLB_Buffer == NULL ) { /* - * defaultFlush() has been called on our buffer. Just go get - * the next block. - */ - + * defaultFlush() has been called on our buffer. Just go get + * the next block. + */ + goto GetNextBlock; } else - { + { NINT waitFlag; buffer = zlogBeast->ZLB_Buffer; /* - * We will use the XLATCH code that will not block is we can - * not get an X Latch. - */ + * We will use the XLATCH code that will not block is we can + * not get an X Latch. + */ X_NOWAIT( &buffer->agent.latch, waitFlag ); /* Is the latch owned by someone else? */ if ( waitFlag == WAITED ) { /* - * Yes - then we will just go to the next buffer. Note that - * this works because we have marked the buffer dirty and - * filled in one record in it when we first grabbed it. The - * timer in it will defaultFlush it at some point and our - * signal handler will checksum it. - */ + * Yes - then we will just go to the next buffer. Note that + * this works because we have marked the buffer dirty and + * filled in one record in it when we first grabbed it. The + * timer in it will defaultFlush it at some point and our + * signal handler will checksum it. + */ zlogBeast->ZLB_Buffer = NULL; - + goto GetNextBlock; } - + zASSERT( zlogBeast->ZLB_Buffer != NULL ); } /* - * It is O.K. to use the current ZLOG buffer!!! - */ + * It is O.K. to use the current ZLOG buffer!!! + */ /* O.K. to give out log record */ logBlockHeader = (ZLOGBlockHeader_s *)buffer->pBuf.data; - if ( (NINT)logBlockHeader->ZLBH_NumberOfUnusedLongs >= neededLongs ) + if ( (NINT)logBlockHeader->ZLBH_NumberOfUnusedLongs >= neededLongs ) { /* Current log block has enough room for request */ goto doTheActualCopy; } @@ -2701,49 +2682,49 @@ void ZLOG_CopyLogicalUndoRecord( logBlockHeader->ZLBH_Status = ZLBH_S_TOOBIG | ZLBH_S_DEBUG | ZLBH_S_CHECKSUM; /* - * Indicate that we are done with the buffer, before we allow - * shared access which would allow our signal handler access to - * ZLB_Buffer. We do not needMPKNSS_LOCK() here because we have the - * ZLB_Buffer latched. - */ + * Indicate that we are done with the buffer, before we allow + * shared access which would allow our signal handler access to + * ZLB_Buffer. We do not needMPKNSS_LOCK() here because we have the + * ZLB_Buffer latched. + */ zlogBeast->ZLB_Buffer = NULL; /* - * We are now done with this buffer, unlatch and then flush it. - */ + * We are now done with this buffer, unlatch and then flush it. + */ CACHE_UNXLATCH( buffer ); /* - * To write we simply note that we would like to do a flush of - * our buffer. - */ + * To write we simply note that we would like to do a flush of + * our buffer. + */ defaultFlush( &buffer->agent ); /* Why is there no barrier in this code like in ZLOG_ObtainRecord? - * Because: This code creates new journal blocks that are on a - * timer. When we return from this code, it will result in - * ZLOG_ZB_S_NEEDTODO_COMPENSATION. And XactionRecover will take - * 4 clean checkpoints. A clean checkpoint causes the journal to - * be flushed, and checkpointtake will do the barrier flush. - */ + * Because: This code creates new journal blocks that are on a + * timer. When we return from this code, it will result in + * ZLOG_ZB_S_NEEDTODO_COMPENSATION. And XactionRecover will take + * 4 clean checkpoints. A clean checkpoint causes the journal to + * be flushed, and checkpointtake will do the barrier flush. + */ /* - * Write errors show up in our done signal handler. - */ + * Write errors show up in our done signal handler. + */ /*** Get the next log block in the file ***/ /************/ GetNextBlock:; /************/ /* - * We are back the buffer may or may not be flushed, but we - * don't care. - */ + * We are back the buffer may or may not be flushed, but we + * don't care. + */ /* - * The ZLOG code is very dependent that this is the ONLY place a log - * block is obtained for transaction logging. - * - */ + * The ZLOG code is very dependent that this is the ONLY place a log + * block is obtained for transaction logging. + * + */ /* Accounting */ zlogBeast->ZLB_LogBlockFilledInCount++; - + /* Update to next log block number */ ZLOG_NEXT_POOL_LOG_BLOCK( zlogBeast, zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber ); @@ -2751,94 +2732,94 @@ GetNextBlock:; GetCurrentBlock:; /***************/ /* - * Because we always write the full block we do not need to do - * a pre-read. So we are only getting a buffer from the cache system. - * We will have this buffer X latched so our signal handler will not be - * trying to poke ZLB_Buffer so we do not need MPKNSS_LOCK here. - */ + * Because we always write the full block we do not need to do + * a pre-read. So we are only getting a buffer from the cache system. + * We will have this buffer X latched so our signal handler will not be + * trying to poke ZLB_Buffer so we do not need MPKNSS_LOCK here. + */ /* - * Must look on mycache list because we do not toss ALL the time. - * 1). Recovery. - * 2). Other people reading file. - */ - buffer = cacheLookup(&zlogBeast->ZFSLOGmycache, - zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber, - CACHE_WRITE); + * Must look on mycache list because we do not toss ALL the time. + * 1). Recovery. + * 2). Other people reading file. + */ + buffer = cacheLookup(&zlogBeast->ZFSLOGmycache, + zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber, + CACHE_WRITE); if ( buffer == NULL ) { Blknum_t volBlk = 0; Fmap_s *fmap = &zlogBeast->ZFSLOGzfsStInfo->fmap; Blknum_t fileBlk = zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; NINT i; - zASSERT(fmap->numRecs > 1); + zASSERT(fmap->numRecs > 1); for (i = 1; i < fmap->numRecs; i++) { if (fmap->dirExt[i].count > fileBlk) { - volBlk = fmap->dirExt[i].poolBlk + - (fileBlk - fmap->dirExt[i-1].count); + volBlk = fmap->dirExt[i].poolBlk + + (fileBlk - fmap->dirExt[i-1].count); break; } } zASSERT(volBlk != 0); /* - * We must know when the cache system flushes our buffer so we - * insert our own handler into the flush path verses the standard - * signal handler. - */ + * We must know when the cache system flushes our buffer so we + * insert our own handler into the flush path verses the standard + * signal handler. + */ buffer = cacheAllocBuffer( &zlogBeast->ZFSLOGmycache, - zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber, - volBlk, &Zlog_FlushBlockStartSignalHandler, - CACHE_WRITE); + zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber, + volBlk, &Zlog_FlushBlockStartSignalHandler, + CACHE_WRITE); zASSERT( buffer != NULL ); } else { /* - * The poke is needed just in case the buffer was originally - * obtained by our recovery code or some one reading the file. - * In these cases the signal handler is the default block handler. - */ + * The poke is needed just in case the buffer was originally + * obtained by our recovery code or some one reading the file. + * In these cases the signal handler is the default block handler. + */ Inst.cache.ioHitSystem++; POKE_SIGNAL_HANDLER( buffer, &Zlog_FlushBlockStartSignalHandler ); } /* - * Note that we have an exclusive latch on the buffer since we - * will be writing to it. - */ + * Note that we have an exclusive latch on the buffer since we + * will be writing to it. + */ zASSERT( zlogBeast->ZLB_Buffer == NULL ); zlogBeast->ZLB_Buffer = buffer; /* - * Mark buffer as dirty. This also starts a flush timer so that - * this buffer is not held too long. Our flush handler (set above) - * will be called when the timer goes off (or a bound DATA block - * indicates it needs to go out (or someone flushed the ZLOG beast)) - * via calls to defaultFlush(). - */ + * Mark buffer as dirty. This also starts a flush timer so that + * this buffer is not held too long. Our flush handler (set above) + * will be called when the timer goes off (or a bound DATA block + * indicates it needs to go out (or someone flushed the ZLOG beast)) + * via calls to defaultFlush(). + */ CACHE_MARK_DIRTY( buffer ); /* - * Order cached buffers by oldest(lowest LSN) to the youngest - * (highest LSN). The current buffer is the youngest (highest LSN) - * so we put at the end of the cached buffer list. Zlog_WriteBlkEnd() - * will use and then remove from list. - */ - + * Order cached buffers by oldest(lowest LSN) to the youngest + * (highest LSN). The current buffer is the youngest (highest LSN) + * so we put at the end of the cached buffer list. Zlog_WriteBlkEnd() + * will use and then remove from list. + */ + DQ_ENQ( &zlogBeast->ZLB_CachedBufferListHead, buffer, signalLink ); - + logBlockHeader = (ZLOGBlockHeader_s *)buffer->pBuf.data; #if NSS_ASSERT IS_ENABLED || ZLOG_DEBUG IS_ENABLED /* - * Fill complete block with explanation points. This puts - * them in the padding of log records so each log record can be found - * and allows for ASSERTs if someone writes past their log record end. - */ + * Fill complete block with explanation points. This puts + * them in the padding of log records so each log record can be found + * and allows for ASSERTs if someone writes past their log record end. + */ memset( logBlockHeader, 0x44, 1 << zlogBeast->ZFSLOGblkSizeShift ); #endif logBlockHeader->ZLBH_TimeStart = GetUTCTime(); logBlockHeader->ZLBH_Signature = ZLBH_S_SIGNATURE; - zASSERT( LB_GUIDValidate( &zlogBeast->ZFSLOGroot.ROOTinternalID ) ); + zASSERT( LB_GUIDValidate( &zlogBeast->ZFSLOGroot.ROOTinternalID ) ); logBlockHeader->ZLBH_InternalID = zlogBeast->ZFSLOGroot.ROOTinternalID; #if ZLOG_DEBUG IS_ENABLED logBlockHeader->ZLBH_FileBlockNumber = @@ -2869,10 +2850,10 @@ doTheActualCopy: dstLogRecordHeader->ZLRH_Zxr.ZXR_Lsn = (zlogBeast->ZLB_P.ZLBP_ActivePointerLsn)++; - dstLogRecordHeader->ZLRH_Zxr.ZXR_TransactionState |= + dstLogRecordHeader->ZLRH_Zxr.ZXR_TransactionState |= XAS_XR_TS_UNDO_LOGICAL_COPY; - /* Update the Pool Log Block Header */ + /* Update the Pool Log Block Header */ logBlockHeader->ZLBH_NumberOfUnusedLongs -= (LONG)neededLongs; logBlockHeader->ZLBH_NumberOfRecords += 1; zlogBeast->ZLB_LogRecordFilledInCount += 1; @@ -2886,17 +2867,17 @@ doTheActualCopy: #endif /* - * Calculate checksum on all bytes in log record. This includes - * the bytes that are used to align us to the proper boundary. This - * is done because ZLOG does not track how many of these bytes - * are present in each log record. In addition, our checksum - * routine does LONGs so to be fast. - */ + * Calculate checksum on all bytes in log record. This includes + * the bytes that are used to align us to the proper boundary. This + * is done because ZLOG does not track how many of these bytes + * are present in each log record. In addition, our checksum + * routine does LONGs so to be fast. + */ dstLogRecordHeader->ZLRH_Checksum = 0; /* - * The checksum we store is the value that makes a good - * block's checksum equal to zero. - */ + * The checksum we store is the value that makes a good + * block's checksum equal to zero. + */ #if ZLOG_CHECKSUM_LOG_RECORDS IS_ENABLED dstLogRecordHeader->ZLRH_Checksum = 0 - zlog_CalculateChecksum( (LONG *)dstLogRecordHeader, @@ -2921,7 +2902,7 @@ doTheActualCopy: * * Execution Requirements/Assumptions * Synchronous and blocking - * + * */ @@ -2964,33 +2945,33 @@ STATUS Zlog_PoolInitialize( pool = zlogBeast->ZFSLOGroot.vol.zfsVol->pool; zASSERT( pool->zfsLogBeast == zlogBeast ); /* We create a ZLOG file with between 200 and 2500 log blocks. The - * exact number is determined by using 0.5% of the pool's blocks for - * the ZLOG file. If this number is not within range then we force - * it into range. - */ + * exact number is determined by using 0.5% of the pool's blocks for + * the ZLOG file. If this number is not within range then we force + * it into range. + */ #if NSS_DEBUG IS_ENABLED /* - * This is real dirty and does not work real well if more than one - * pool, but we turn off write prevention so we can init the ZLOG - * file. - */ + * This is real dirty and does not work real well if more than one + * pool, but we turn off write prevention so we can init the ZLOG + * file. + */ temp = CrashPools; CrashPools = FALSE; #endif - X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); if (!rebuild) { - /* FixFixFix6(Design) - we need a better formula and/or to be configurable */ + /* FixFixFix6(Design) - we need a better formula and/or to be configurable */ zlogFileSize = ( (QUAD)pool->ZFSPOOLtotalBlocks << zlogBeast->ZFSLOGblkSizeShift ) / ZLOG_FILE_SIZE_FRACTION; if ( zlogFileSize > ZLOG_FILE_SIZE_CROSS_OVER ) { /* Rebuild may need to have a larger ZLOG file - * than what ZLOG requires. If so make the ZLOG - * file bigger. - */ + * than what ZLOG requires. If so make the ZLOG + * file bigger. + */ zlogFileSize = (QUAD)pool->ZFSPOOLtotalBlocks * ZLOG_REBUILD_BYTES_PER_BLOCK; if ( zlogFileSize < ZLOG_FILE_SIZE_CROSS_OVER ) @@ -3007,13 +2988,13 @@ STATUS Zlog_PoolInitialize( } zlogFileSize += ZLOG_REBUILD_FUDGE_BLOCKS * 4096; /* A little round up so Rebuild can - * have two areas that can both be - * rounded to 4K. - */ + * have two areas that can both be + * rounded to 4K. + */ #if NSS_DEBUG IS_ENABLED /* On debug systems with pools over 256MB make the Journal - * at least 128MB for debugging. - */ + * at least 128MB for debugging. + */ if ( (zlogFileSize < (128*1024*1024uL)) && (pool->ZFSPOOLtotalBlocks > (256*1024*1024uL) ) ) { zlogFileSize = 128*1024*1024uL; @@ -3021,13 +3002,13 @@ STATUS Zlog_PoolInitialize( #endif zASSERT( zlogBeast->ZFSLOGblkSizeShift != 0 ); blocksInLogFile = (zlogFileSize+(1 << zlogBeast->ZFSLOGblkSizeShift)-1) - >> zlogBeast->ZFSLOGblkSizeShift; + >> zlogBeast->ZFSLOGblkSizeShift; /* - * Because this is create time for the pool we have to use special - * code to allocate the blocks of the ZLOG file. Once the blocks - * are allocated we can use COMN_... routines as long as we do - * not extend the file (which ZLOG does not do). - */ + * Because this is create time for the pool we have to use special + * code to allocate the blocks of the ZLOG file. Once the blocks + * are allocated we can use COMN_... routines as long as we do + * not extend the file (which ZLOG does not do). + */ len = blocksInLogFile; extentsize = (len + ZLOG_EXTENT_MIN - 1)/ ZLOG_EXTENT_MIN; @@ -3053,17 +3034,17 @@ STATUS Zlog_PoolInitialize( /*- make a min. extent count of 8 to spread the log activity -*/ if (len >= extentsize) - { + { extent.lengthOfExtent = extentsize; extent.poolBlkNum = seed[dirIndex - 1]; } else - { + { extent.lengthOfExtent = len; extent.poolBlkNum = 0; } - if ( zfsAllocExtent(genMsg, &pool->ZFSPOOLzfsVol, &extent, + if ( zfsAllocExtent(genMsg, &pool->ZFSPOOLzfsVol, &extent, XTREE_SYSTEM_REQUEST, NULL) != zOK ) { #if NSS_DEBUG IS_ENABLED @@ -3073,10 +3054,10 @@ STATUS Zlog_PoolInitialize( RTN_STATUS(zFAILURE); } zlogBeast->ZFSLOGroot.storage.zfsInfo->fmap.dirExt[dirIndex].count = - extent.lengthOfExtent + - zlogBeast->ZFSLOGroot.storage.zfsInfo->fmap.dirExt[dirIndex-1].count; + extent.lengthOfExtent + + zlogBeast->ZFSLOGroot.storage.zfsInfo->fmap.dirExt[dirIndex-1].count; zlogBeast->ZFSLOGroot.storage.zfsInfo->fmap.dirExt[dirIndex].poolBlk = - extent.poolBlkNum; + extent.poolBlkNum; zlogBeast->ZFSLOGroot.storage.zfsInfo->fmap.numRecs++; len -= extent.lengthOfExtent; ++dirIndex; @@ -3088,9 +3069,9 @@ STATUS Zlog_PoolInitialize( // COMN_MARK_BEAST_DIRTY( &zlogBeast->ZFSLOGroot ); Don't do as checkpoints write. /* - * Update EOF - We use number of blocks and not zlogFileSize - * because of possible rounding error in file size to block conversion. - */ + * Update EOF - We use number of blocks and not zlogFileSize + * because of possible rounding error in file size to block conversion. + */ zlogBeast->ZFSLOGroot.eof = (QUAD)zlogBeast->ZFSLOGroot.storage.zfsInfo->fmapDataBlks << zlogBeast->ZFSLOGblkSizeShift; @@ -3150,8 +3131,8 @@ STATUS Zlog_PoolInitialize( if (rebuild) { /* Rebuild specific initialization - * - Track last 16 rebuild times. - */ + * - Track last 16 rebuild times. + */ ZLOG_HISTORY_EVENT( &zlogBeast->ZLB_History[ZH16_REBUILD_UTC], (QUAD)(GetUTCTime()) ); } @@ -3161,13 +3142,13 @@ STATUS Zlog_PoolInitialize( #if NSS_DEBUG IS_ENABLED CrashPools = temp; #endif - UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); RTN_STATUS(status); } /* - * Wait until here for Pre Oldest because the MACRO uses items - * that are filled in in common create and open. - */ + * Wait until here for Pre Oldest because the MACRO uses items + * that are filled in in common create and open. + */ ZLOG_PREVIOUS_POOL_LOG_BLOCK( zlogBeast, zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber ); ZLOG_PREVIOUS_POOL_LOG_BLOCK( zlogBeast, @@ -3180,22 +3161,22 @@ STATUS Zlog_PoolInitialize( /* Since recovery is not needed on create we can say we are done with recovery. */ zlogBeast->ZLB_DebugState = ZLOG_ZB_DS_RECOVERY_END; - UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); /* Wait for the LOG buffers to write, then toss everything. Since - * we no longer INIT zlog blocks this should not be needed. But - * since there are no blocks on cache there is no HARM in leaving - * in code. - */ + * we no longer INIT zlog blocks this should not be needed. But + * since there are no blocks on cache there is no HARM in leaving + * in code. + */ cacheFlushMyCache( &zlogBeast->ZFSLOGmycache ); X_BARRIER( &zlogBeast->ZFSLOGbeastLatch ); cacheTossAll( &zlogBeast->ZFSLOGmycache ); /* - * We do not take a checkpoint because are caller will do when - * 'create pool' is done. This is good because if we crash before - * finishing create then there will not be an incomplete pool. Note - * that the caller we write all CHECKPOINT_NUMBER checkpoints when done. - */ + * We do not take a checkpoint because are caller will do when + * 'create pool' is done. This is good because if we crash before + * finishing create then there will not be an incomplete pool. Note + * that the caller we write all CHECKPOINT_NUMBER checkpoints when done. + */ RTN_STATUS(status); } /* End of Zlog_PoolInitialize() */ @@ -3223,7 +3204,7 @@ STATUS Zlog_PoolInitialize( * */ -STATUS zlog_RAPProcessSingleLogBlock( +STATUS zlog_RAPProcessSingleLogBlock( GeneralMsg_s *genMsg, ZlogBeast_s *zlogBeast, NINT *done ) @@ -3247,15 +3228,15 @@ STATUS zlog_RAPProcessSingleLogBlock( zASSERT( zlogBeast->ZFSLOGroot.vol.zfsVol->pool != NULL ); pool = zlogBeast->ZFSLOGroot.vol.zfsVol->pool; FILEBLK_IO_MSG(ioMsg, zlogBeast, - zlogBeast->ZLB_RecoveryActivePointerBlockNumber, - 1, CACHE_READ ); + zlogBeast->ZLB_RecoveryActivePointerBlockNumber, + 1, CACHE_READ ); buffer = COMN_GetFileBlk(genMsg, &ioMsg); /* - * Note that COMN_GetFileBlk() has obtained an shared latch on - * the buffer for us since we will only be reading it. We - * release this latch right after processing the block. This - * latch is only obtained if zOK is returned. - */ + * Note that COMN_GetFileBlk() has obtained an shared latch on + * the buffer for us since we will only be reading it. We + * release this latch right after processing the block. This + * latch is only obtained if zOK is returned. + */ /* Did get block work? */ if ( buffer == NULL ) { /* NO - An error occurred we just leave genMsg alone. */ @@ -3266,13 +3247,13 @@ STATUS zlog_RAPProcessSingleLogBlock( logBlockHeader = (ZLOGBlockHeader_s *)buffer->pBuf.data; /* - * Better verify length field used for checksumming. All log blocks - * must have a log block header. Log blocks do not have to have a log - * record header because install does not fill in. The ZLOG - * specification says that checksum errors can only occur if we did - * a partial write of a log block. A partial write of a log block - * indicates that we have found our active pointer. - */ + * Better verify length field used for checksumming. All log blocks + * must have a log block header. Log blocks do not have to have a log + * record header because install does not fill in. The ZLOG + * specification says that checksum errors can only occur if we did + * a partial write of a log block. A partial write of a log block + * indicates that we have found our active pointer. + */ if ( logBlockHeader->ZLBH_NumberOfUnusedLongs > (((1 << zlogBeast->ZFSLOGblkSizeShift) - sizeof(ZLOGBlockHeader_s) )/4)) { @@ -3329,7 +3310,7 @@ STATUS zlog_RAPProcessSingleLogBlock( goto zlog_RAPGBerror2; } /*** Start looking at 1st log record within block ***/ - logRecordHeader = (ZLOGRecordHeader_s *)(logBlockHeader + 1); + logRecordHeader = (ZLOGRecordHeader_s *)(logBlockHeader + 1); if ( logRecordHeader->ZLRH_LongLength > ( ( (1 << zlogBeast->ZFSLOGblkSizeShift) - @@ -3353,29 +3334,29 @@ STATUS zlog_RAPProcessSingleLogBlock( /*** Checksum is good - Finally lets look at the LSN ***/ zASSERT( logRecordHeader->ZLRH_Zxr.ZXR_Lsn != 0 ); /* - * Does this block have a bigger LSN? Note the > part of check is - * needed because of our magic big add to get a new LSN at recovery - * time. - */ - if ( (logRecordHeader->ZLRH_Zxr.ZXR_Lsn + + * Does this block have a bigger LSN? Note the > part of check is + * needed because of our magic big add to get a new LSN at recovery + * time. + */ + if ( (logRecordHeader->ZLRH_Zxr.ZXR_Lsn + logBlockHeader->ZLBH_NumberOfRecords) >= zlogBeast->ZLB_RecoveryActivePointerLsn ) { /* YES - Then this is NOT the end of the log file */ /* - * Update LSN to next expected LSN. This may look weird, - * but every log record WITHIN A LOG BLOCK gets assigned a LSN - * one higher than the next so we can just add the number of - * log records in the log block. Note our magic add a lot - * to the previous LSN only occurs at recovery and ONLY - * between LSNs in different log blocks. - */ - zlogBeast->ZLB_RecoveryActivePointerLsn = - logRecordHeader->ZLRH_Zxr.ZXR_Lsn + + * Update LSN to next expected LSN. This may look weird, + * but every log record WITHIN A LOG BLOCK gets assigned a LSN + * one higher than the next so we can just add the number of + * log records in the log block. Note our magic add a lot + * to the previous LSN only occurs at recovery and ONLY + * between LSNs in different log blocks. + */ + zlogBeast->ZLB_RecoveryActivePointerLsn = + logRecordHeader->ZLRH_Zxr.ZXR_Lsn + logBlockHeader->ZLBH_NumberOfRecords; /* - * Release shared access on buffer --- buffer, logBlockHeader - * and logRecordHeader are now invalid to access. - */ + * Release shared access on buffer --- buffer, logBlockHeader + * and logRecordHeader are now invalid to access. + */ CACHE_RELEASE( buffer ); /* Update to next block number */ ZLOG_NEXT_POOL_LOG_BLOCK( zlogBeast, @@ -3385,17 +3366,17 @@ STATUS zlog_RAPProcessSingleLogBlock( } else { /* - * NO - Then we have found the first log block that does not - * need to be recovered. We will use this log block as the - * location to set the current active pointer to. - */ + * NO - Then we have found the first log block that does not + * need to be recovered. We will use this log block as the + * location to set the current active pointer to. + */ /***************************/ zlog_RAPGBFoundActivePointer:; /***************************/ /* - * Release shared access on buffer --- buffer, logBlockHeader - * and logRecordHeader are now invalid to access. - */ + * Release shared access on buffer --- buffer, logBlockHeader + * and logRecordHeader are now invalid to access. + */ CACHE_RELEASE( buffer ); #if ZLOG_DEBUG IS_ENABLED /* ZAP pointers that point into buffer */ @@ -3403,38 +3384,38 @@ zlog_RAPGBFoundActivePointer:; logRecordHeader = NULL; logBlockHeader = NULL; #endif - /* - * Update Active Pointer block and LSN. - * - * From Specification - ZLOG will add a gigabyte to this - * LSN to get the new current LSN. This is done as a proactive - * measure to reduce chances of duplicate LSNs. There really - * is no reason not to add such a number because it is only ~1 - * second if LSN increases once per nanosecond (which wraps - * a QUAD in 586 years). Also we must add a gigabyte for - * each checkpoint that could not be read. This will prevent - * us from using a LSN that one of the BAD checkpoints indicated. - * - */ - if ( zlogBeast->ZLB_P.ZLBP_ActivePointerLsn > + /* + * Update Active Pointer block and LSN. + * + * From Specification - ZLOG will add a gigabyte to this + * LSN to get the new current LSN. This is done as a proactive + * measure to reduce chances of duplicate LSNs. There really + * is no reason not to add such a number because it is only ~1 + * second if LSN increases once per nanosecond (which wraps + * a QUAD in 586 years). Also we must add a gigabyte for + * each checkpoint that could not be read. This will prevent + * us from using a LSN that one of the BAD checkpoints indicated. + * + */ + if ( zlogBeast->ZLB_P.ZLBP_ActivePointerLsn > zlogBeast->ZLB_RecoveryActivePointerLsn ) { /* The checkpoint has a higher LSN than what we found. */ #if 0 /* This just means we wrote a checkpoint before a log - * buffer made it to the media so I removed. - */ + * buffer made it to the media so I removed. + */ zASSERT( "Active pointer LSN greater than ZLOG EOF LSN" == NULL ); #endif - zlogBeast->ZLB_RecoveryActivePointerLsn = - zlogBeast->ZLB_P.ZLBP_ActivePointerLsn; + zlogBeast->ZLB_RecoveryActivePointerLsn = + zlogBeast->ZLB_P.ZLBP_ActivePointerLsn; } zASSERT( pool->ZP_BadCheckpoints < CHECKPOINT_NUMBER ); zASSERT( pool->ZP_BadCheckpoints >= 0 ); /* - * Defensive code - we really do not want to add - * too much to our LSN. - */ + * Defensive code - we really do not want to add + * too much to our LSN. + */ if ( (pool->ZP_BadCheckpoints < 0) || (pool->ZP_BadCheckpoints > CHECKPOINT_NUMBER) ) { /* Defensive case */ @@ -3445,13 +3426,13 @@ zlog_RAPGBFoundActivePointer:; specialAdd = (Lsn_t)0x40000000ul * (1 + pool->ZP_BadCheckpoints); } /* - * Now that we are happy with the active pointer found - * by recovery we can set the real active pointer to the found - * values. - */ - zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber = + * Now that we are happy with the active pointer found + * by recovery we can set the real active pointer to the found + * values. + */ + zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber = zlogBeast->ZLB_RecoveryActivePointerBlockNumber; - zlogBeast->ZLB_P.ZLBP_ActivePointerLsn = + zlogBeast->ZLB_P.ZLBP_ActivePointerLsn = zlogBeast->ZLB_RecoveryActivePointerLsn + specialAdd; /*** This is a happy recovery EXIT ***/ *done = TRUE; @@ -3519,8 +3500,8 @@ zlog_RAPGBerror1:; * */ - -STATUS zlog_RecoverActivePointer( + +STATUS zlog_RecoverActivePointer( GeneralMsg_s *genMsg, ZlogBeast_s *zlogBeast ) @@ -3534,9 +3515,9 @@ STATUS zlog_RecoverActivePointer( zASSERT( zlogBeast->ZFSLOGroot.eof >= ZLOG_FILE_SIZE_MINIMUM ); zASSERT( zlogBeast->ZLB_P.ZLBP_Signature == ZLOG_ZLBP_S_SIGNATURE ); /* - * Mark that we made it to recovery - we waited until - * we got our exclusive access to the ZLOG system. - */ + * Mark that we made it to recovery - we waited until + * we got our exclusive access to the ZLOG system. + */ zlogBeast->ZLB_DebugState = ZLOG_ZB_DS_RAP_START; do { @@ -3554,17 +3535,17 @@ STATUS zlog_RecoverActivePointer( } /* End of zlog_RecoverActivePointer */ -/* - * void ZLOG_RecoveryClose( ZlogRecoveryKey_s *zlogRecoveryKey ) - * - * zlogRecoveryKey Pointer to key that user is done using. - * - * This function releases resources that ZLOG has associated with the key. - * This function must be called for each ZLOG_RecoveryOpen() call. This - * call notifies ZLOG that the caller is done with the key. After calling - * this function, the caller must not pass the key into any ZLOG recovery - * functions. - */ +/* + * void ZLOG_RecoveryClose( ZlogRecoveryKey_s *zlogRecoveryKey ) + * + * zlogRecoveryKey Pointer to key that user is done using. + * + * This function releases resources that ZLOG has associated with the key. + * This function must be called for each ZLOG_RecoveryOpen() call. This + * call notifies ZLOG that the caller is done with the key. After calling + * this function, the caller must not pass the key into any ZLOG recovery + * functions. + */ void ZLOG_RecoveryClose( ZlogRecoveryKey_s *zlogKey ) @@ -3603,46 +3584,46 @@ void ZLOG_RecoveryClose( } /* End of ZLOG_RecoveryClose() */ -/* - * STATUS ZLOG_RecoveryGet(GeneralMsg_s *genMsg, - * ZlogRecoveryKey_s *zlogRecoveryKey, NINT direction ) - * - * genMsg Contains thread specific error information. - * ZLOG will set the errno field when zOK is not - * returned. The errno value of - * zERR_ZLOG_NO_MORE_RECORDS indicates there are no - * log records. - * zlogRecoveryKey Pointer to key information for get. On - * successful returns, the ZRK_ZfsXasRecovery - * pointer will contain recovery information for - * the last recovery log record. This key must of - * been initialized with a single call to - * ZLOG_RecoveryOpen(). +/* + * STATUS ZLOG_RecoveryGet(GeneralMsg_s *genMsg, + * ZlogRecoveryKey_s *zlogRecoveryKey, NINT direction ) + * + * genMsg Contains thread specific error information. + * ZLOG will set the errno field when zOK is not + * returned. The errno value of + * zERR_ZLOG_NO_MORE_RECORDS indicates there are no + * log records. + * zlogRecoveryKey Pointer to key information for get. On + * successful returns, the ZRK_ZfsXasRecovery + * pointer will contain recovery information for + * the last recovery log record. This key must of + * been initialized with a single call to + * ZLOG_RecoveryOpen(). * direction Indicates if this is a next or previous. Set to * ZLOG_RG_NEXT for next log record. Set to * ZLOG_RG_PREVIOUS for previous log record. Previous * indicates a 'backwards' traversal of log records. - * - * This function returns the recovery information associated with the - * 'direction' recovery log record. This information is valid as long has no - * other ZLOG_RecoveryGet() functions are called. This function is used to - * traverse backwards or forwards through the recovery log records. - * - * The status return value of zOK indicates the call succeeded and that the - * other return values can be used. All other returns indicate an error in - * obtaining the previous recovery log record. The genMsg field errno - * contains extended error information. The genMsg errno value of - * zERR_ZLOG_NO_MORE_RECORDS indicates there are no log records. - * - * ZLOG_RecoveryGet() returns the following information in the ZLOG - * recovery key. - * - * ZRK_ZfsXasRecovery Pointer to a ZfsXasRecovery_s. See above - * for a description of the ZfsXasRecovery_s - * structure. The caller€s beast specific - * information is at zlogRecoveryKey- - * >ZRK_ZfsXasRecovery+1. - */ + * + * This function returns the recovery information associated with the + * 'direction' recovery log record. This information is valid as long has no + * other ZLOG_RecoveryGet() functions are called. This function is used to + * traverse backwards or forwards through the recovery log records. + * + * The status return value of zOK indicates the call succeeded and that the + * other return values can be used. All other returns indicate an error in + * obtaining the previous recovery log record. The genMsg field errno + * contains extended error information. The genMsg errno value of + * zERR_ZLOG_NO_MORE_RECORDS indicates there are no log records. + * + * ZLOG_RecoveryGet() returns the following information in the ZLOG + * recovery key. + * + * ZRK_ZfsXasRecovery Pointer to a ZfsXasRecovery_s. See above + * for a description of the ZfsXasRecovery_s + * structure. The caller€s beast specific + * information is at zlogRecoveryKey- + * >ZRK_ZfsXasRecovery+1. + */ STATUS ZLOG_RecoveryGet( GeneralMsg_s *genMsg, @@ -3652,13 +3633,13 @@ STATUS ZLOG_RecoveryGet( STATUS status; /* Ignore the log records that are tagged as records that were copied - * for logical undo's. - */ - do + * for logical undo's. + */ + do { status = ZLOG_InternalRecoveryGet(genMsg, zlogKey, direction); - } while ((status == zOK) && - (zlogKey->ZRK_ZfsXasRecovery->ZXR_TransactionState & + } while ((status == zOK) && + (zlogKey->ZRK_ZfsXasRecovery->ZXR_TransactionState & XAS_XR_TS_UNDO_LOGICAL_COPY)); return status; } @@ -3671,15 +3652,15 @@ STATUS ZLOG_RecoveryGetLogicalOnly( STATUS status; /* Ignore the log records that are tagged as records that were copied - * for logical undo's. - */ - do + * for logical undo's. + */ + do { status = ZLOG_InternalRecoveryGet(genMsg, zlogKey, direction); zASSERT(zlogKey->ZRK_ZfsXasRecovery->ZXR_TransactionState & XAS_XR_TS_UNDO_LOGICAL_COPY); - } while ((status == zOK) && - (!(zlogKey->ZRK_ZfsXasRecovery->ZXR_TransactionState & + } while ((status == zOK) && + (!(zlogKey->ZRK_ZfsXasRecovery->ZXR_TransactionState & XAS_XR_TS_UNDO_LOGICAL_COPY))); return status; } @@ -3704,18 +3685,18 @@ STATUS ZLOG_InternalRecoveryGet( zASSERT( zlogBeast->ZFSLOGroot.eof >= ZLOG_FILE_SIZE_MINIMUM ); zASSERT( zlogBeast->ZLB_P.ZLBP_Signature == ZLOG_ZLBP_S_SIGNATURE ); /* - * This loop ensures that we only redo/undo log records that have - * not had their METADATA homed. On most crashes the home block - * will have some log records that do not need to be played back. - * This code skips the log records whose LSN indicate that they - * have been homed. - * Note that it would be O.K. to redo/undo these - * log records because they redo routines should say that they have - * already been homed. - * Note that now that we have an undo pointer concept for the - * purge block code we MUST NOT redo/undo any log records that - * we have said will not be recovered! September 2, 1997 - */ + * This loop ensures that we only redo/undo log records that have + * not had their METADATA homed. On most crashes the home block + * will have some log records that do not need to be played back. + * This code skips the log records whose LSN indicate that they + * have been homed. + * Note that it would be O.K. to redo/undo these + * log records because they redo routines should say that they have + * already been homed. + * Note that now that we have an undo pointer concept for the + * purge block code we MUST NOT redo/undo any log records that + * we have said will not be recovered! September 2, 1997 + */ do { #if NSS_DEBUG IS_ENABLED @@ -3743,7 +3724,7 @@ STATUS ZLOG_InternalRecoveryGet( } while ( (status == zOK) && (zlogKey->ZRK_ZfsXasRecovery->ZXR_Lsn < zlogKey->ZRK_LsnFirst)); #if NSS_DEBUG IS_ENABLED - if ( status == zOK ) + if ( status == zOK ) { logRecordHeader = STRUCT( zlogKey->ZRK_ZfsXasRecovery, ZLOGRecordHeader_s, ZLRH_Zxr ); @@ -3759,13 +3740,13 @@ STATUS ZLOG_InternalRecoveryGet( } /* End of ZLOG_RecoveryGet() */ -/* - * Does the actual work of most of the ZLOG_RecoveryGet calls. - * - * If zlogKey->ZRK_Buffer != NULL then the log record is assumed to be - * within the buffer. Otherwise, the log block ZRK_LogBufferNumber is - * read and then the log record is retrieved from it. - */ +/* + * Does the actual work of most of the ZLOG_RecoveryGet calls. + * + * If zlogKey->ZRK_Buffer != NULL then the log record is assumed to be + * within the buffer. Otherwise, the log block ZRK_LogBufferNumber is + * read and then the log record is retrieved from it. + */ STATUS zlog_RecoveryGet( GeneralMsg_s *genMsg, @@ -3774,7 +3755,7 @@ STATUS zlog_RecoveryGet( { - int currentRecord; + int currentRecord; ZLOGBlockHeader_s *logBlockHeader; ZLOGRecordHeader_s *logRecordHeader; @@ -3792,11 +3773,11 @@ STATUS zlog_RecoveryGet( zlogKey->ZRK_Buffer = zlog_RGReadAndVerifyBlock( genMsg, zlogBeast, zlogKey->ZRK_LogBufferNumber ); /* - * Note that a NON-NULL return also obtains an shared latch on - * the buffer for us. We release this latch when we go to - * the next block or at done. - * - */ + * Note that a NON-NULL return also obtains an shared latch on + * the buffer for us. We release this latch when we go to + * the next block or at done. + * + */ if ( zlogKey->ZRK_Buffer == NULL ) { RTN_STATUS( zFAILURE ); @@ -3817,7 +3798,7 @@ STATUS zlog_RecoveryGet( { /* Point to next log record within block */ logRecordHeader = (ZLOGRecordHeader_s *)( ((LONG *)logRecordHeader) - + logRecordHeader->ZLRH_LongLength); + + logRecordHeader->ZLRH_LongLength); zASSERT( ((BYTE *)(logRecordHeader + 1)) <= (((BYTE *)logBlockHeader) + (1 << zlogBeast->ZFSLOGblkSizeShift)) ); } @@ -3832,7 +3813,7 @@ STATUS zlog_RecoveryGet( * * This function must only be used by FTEST. Used so FTEST demo can * display how many redo(s) and undo(s) occured during recovery. - * + * * Returns * TRUE - Recovery Information filled in. * FALSE - Volume not found @@ -3877,29 +3858,29 @@ NINT ZLOG_RecoveryInfoGet( } -/* - * void ZLOG_RecoveryOpen( NINT getMode, ZfsPool_s *zfsPool, - * ZlogRecoveryKey_s *zlogRecoveryKey ) - * - * getMode - Location to start log record retrievals from. - * Must be either ZLOG_RECOVERY_BEGIN or +/* + * void ZLOG_RecoveryOpen( NINT getMode, ZfsPool_s *zfsPool, + * ZlogRecoveryKey_s *zlogRecoveryKey ) + * + * getMode - Location to start log record retrievals from. + * Must be either ZLOG_RECOVERY_BEGIN or * ZLOG_RECOVERY_END. * - 'Get' area to do retrival from. Must be either - * ZLOG_RECOVERY_NORMAL or ZLOG_RECOVERY_EXPANDED. - * zfsPool Pointer to ZFS pool that the log file belongs to. - * zlogRecoveryKey Pointer to key information. The internal items - * in this structure are initialized by this call. - * - * This function opens the ZLOG file for recovery record retrieval. The - * define ZLOG_RECOVERY_BEGIN indicates that retrieval will start at the - * beginning of the recovery area. The define ZLOG_RECOVERY_END indicates - * that retrieval will start at the end of the recovery area. - * - * For every call to ZLOG_RecoveryOpen() there must be a call to - * ZLOG_RecoveryClose() with the same key. Before ZLOG_RecoveryOpen() can - * be called with a used key the key must be closed with a call to - * ZLOG_RecoveryClose(). - */ + * ZLOG_RECOVERY_NORMAL or ZLOG_RECOVERY_EXPANDED. + * zfsPool Pointer to ZFS pool that the log file belongs to. + * zlogRecoveryKey Pointer to key information. The internal items + * in this structure are initialized by this call. + * + * This function opens the ZLOG file for recovery record retrieval. The + * define ZLOG_RECOVERY_BEGIN indicates that retrieval will start at the + * beginning of the recovery area. The define ZLOG_RECOVERY_END indicates + * that retrieval will start at the end of the recovery area. + * + * For every call to ZLOG_RecoveryOpen() there must be a call to + * ZLOG_RecoveryClose() with the same key. Before ZLOG_RecoveryOpen() can + * be called with a used key the key must be closed with a call to + * ZLOG_RecoveryClose(). + */ void ZLOG_RecoveryOpen( NINT getMode, @@ -3936,36 +3917,36 @@ void ZLOG_RecoveryOpen( checkpointIndex = zlog_GetNewestCheckpointIndex( zlogBeast ); /* The number of checkpoints we go back is related - * to the number of checkpoints that are bad. - * - * Bad Checkpoints Previous checkpoint to use - * 0 2 - * 1 1 - * 2 0 (newest/current) - * 3+ 0 (newest/current) - * - * This algorithm is needed so that we NEVER include log - * blocks that have been promised not to be recovered. This - * is required because the purge block code is told when a - * purged block is guaranteed not to appear in any recovery - * area. Currently the purge code is told this when ALL - * checkpoints are past the purged block. This is in spite - * of the fact we generally only will go back to the 3rd oldest - * checkpoint when doing recovery. Currently, the only exception - * to this is when we there are 3+ bad checkpoints. - */ + * to the number of checkpoints that are bad. + * + * Bad Checkpoints Previous checkpoint to use + * 0 2 + * 1 1 + * 2 0 (newest/current) + * 3+ 0 (newest/current) + * + * This algorithm is needed so that we NEVER include log + * blocks that have been promised not to be recovered. This + * is required because the purge block code is told when a + * purged block is guaranteed not to appear in any recovery + * area. Currently the purge code is told this when ALL + * checkpoints are past the purged block. This is in spite + * of the fact we generally only will go back to the 3rd oldest + * checkpoint when doing recovery. Currently, the only exception + * to this is when we there are 3+ bad checkpoints. + */ zASSERT( zfsPool->ZP_BadCheckpoints >= 0 ); for ( count = 0; count < (2 - zfsPool->ZP_BadCheckpoints); ++count ) - { + { CHECKPOINT_GET_PREVIOUS( &checkpointIndex ); } zASSERT( checkpointIndex >= 0 ); zASSERT( checkpointIndex < CHECKPOINT_NUMBER ); zlogKey->ZRK_LsnFirst = - zlogBeast->ZLB_P.ZLBP_OldHomePointerLsn[checkpointIndex]; - zlogKey->ZRK_BlockFirst = - zlogBeast->ZLB_P.ZLBP_OldHomePointerBlockNumber[checkpointIndex]; - zlogKey->ZRK_BlockLast = + zlogBeast->ZLB_P.ZLBP_OldHomePointerLsn[checkpointIndex]; + zlogKey->ZRK_BlockFirst = + zlogBeast->ZLB_P.ZLBP_OldHomePointerBlockNumber[checkpointIndex]; + zlogKey->ZRK_BlockLast = zlogBeast->ZLB_RecoveryActivePointerBlockNumber; } else if ( getMode & ZLOG_RECOVERY_LOGICAL ) @@ -3978,21 +3959,21 @@ void ZLOG_RecoveryOpen( { zlogKey->ZRK_BlockFirst = zlogBeast->ZLB_RecoveryAreaFirstBlockNumber; zlogKey->ZRK_LsnFirst = zlogBeast->ZLB_P.ZLBP_HomePointerLsn; - zlogKey->ZRK_BlockLast = + zlogKey->ZRK_BlockLast = zlogBeast->ZLB_RecoveryActivePointerBlockNumber; } if ( getMode & ZLOG_RECOVERY_BEGIN ) { zlogKey->ZRK_LogBufferNumber = zlogKey->ZRK_BlockFirst; - zlogKey->ZRK_LogRecordNumber = 0; + zlogKey->ZRK_LogRecordNumber = 0; } else - { /* - * The last block is the first block that is past - * the recovery area. To get the last block within the area get - * the previous block. - */ - zlogKey->ZRK_LogBufferNumber = zlogKey->ZRK_BlockLast; + { /* + * The last block is the first block that is past + * the recovery area. To get the last block within the area get + * the previous block. + */ + zlogKey->ZRK_LogBufferNumber = zlogKey->ZRK_BlockLast; ZLOG_PREVIOUS_POOL_LOG_BLOCK( zlogBeast, zlogKey->ZRK_LogBufferNumber ); /* A -1 as a record number means the last record */ zlogKey->ZRK_LogRecordNumber = -1; @@ -4031,7 +4012,7 @@ void ZLOG_RecoveryOpen( * blocks have been used up to this point because we may be changing * their contents here. For example, we could be changing the media * version and the beast tree special block number. - */ + */ STATUS ZLOG_RecoveryPhase( GeneralMsg_s *genMsg, @@ -4050,17 +4031,17 @@ STATUS ZLOG_RecoveryPhase( zASSERT( zlogBeast->ZLB_P.ZLBP_Signature == ZLOG_ZLBP_S_SIGNATURE ); /* Serialize recovery code */ - X_LATCH( &zlogBeast->ZLB_RecoveryLatch ); + X_LATCH( &zlogBeast->ZLB_RecoveryLatch ); /* Serialize ZLOG system */ - X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); /* This implies we will allow several recovery attempts */ zASSERT( zlogBeast->ZLB_DebugState <= ZLOG_ZB_DS_RECOVERY_END ); zASSERT( zlogBeast->ZLB_DebugState >= ZLOG_ZB_DS_CONSTRUCT_END ); /* - * Mark that we made it to recovery - we waited until - * we got our exclusive access to the ZLOG system. - */ + * Mark that we made it to recovery - we waited until + * we got our exclusive access to the ZLOG system. + */ zlogBeast->ZLB_DebugState = ZLOG_ZB_DS_RECOVERY_START; /* Set here as called on every recovery attempt */ @@ -4069,15 +4050,15 @@ STATUS ZLOG_RecoveryPhase( /* Update number of times we have been called */ zlogBeast->ZLB_P.ZLBP_RecoveryActivationCount += 1; /* - * Initialize Recovery's active pointer. - */ + * Initialize Recovery's active pointer. + */ zlogBeast->ZLB_RecoveryActivePointerBlockNumber = zlogBeast->ZLB_P.ZLBP_HomePointerBlockNumber; zlogBeast->ZLB_RecoveryActivePointerLsn = zlogBeast->ZLB_P.ZLBP_HomePointerLsn; /* - * Calculate the pre oldest home pointer. - */ + * Calculate the pre oldest home pointer. + */ oldestIndex = zlog_GetOldestCheckpointIndex( zlogBeast ); zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber = zlogBeast->ZLB_P.ZLBP_OldHomePointerBlockNumber[ oldestIndex ]; @@ -4116,17 +4097,17 @@ STATUS ZLOG_RecoveryPhase( aprintf(LRED,MSGNot("Activation is being prevented because of switch /PoolRestoreImage.\n")); zlogBeast->ZLB_DebugState = ZLOG_ZB_DS_RECOVERY_ERROR; SetErrno( genMsg, zERR_NOT_SUPPORTED ); - UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); - UNX_LATCH( &zlogBeast->ZLB_RecoveryLatch ); + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNX_LATCH( &zlogBeast->ZLB_RecoveryLatch ); PoolRestoreImage[0] = 0; RTN_STATUS( zFAILURE ); } #endif #endif /* - * Persistently store the current time. This time will also be - * used is we have to do recovery. - */ + * Persistently store the current time. This time will also be + * used is we have to do recovery. + */ zlogBeast->ZLB_P.ZLBP_TimeActivation = GetUTCTime(); /* Recover the active pointer - synchronously */ status = zlog_RecoverActivePointer( genMsg, zlogBeast ); @@ -4134,17 +4115,17 @@ STATUS ZLOG_RecoveryPhase( if ( status != zOK) { /* YES - We were unable to update the active pointer */ zlogBeast->ZLB_DebugState = ZLOG_ZB_DS_RECOVERY_ERROR; - UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); - UNX_LATCH( &zlogBeast->ZLB_RecoveryLatch ); + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNX_LATCH( &zlogBeast->ZLB_RecoveryLatch ); RTN_STATUS( status ); } - + /* - * We have just crossed a very intersting point in our lives. - * Before this point transaction logging is illegal, now - * we must allow it so components doing recovery can - * log changes. - */ + * We have just crossed a very intersting point in our lives. + * Before this point transaction logging is illegal, now + * we must allow it so components doing recovery can + * log changes. + */ /* We start recovery at the home pointer */ zlogBeast->ZLB_RecoveryAreaFirstBlockNumber = @@ -4157,12 +4138,12 @@ STATUS ZLOG_RecoveryPhase( #endif ) { /* - * Yes - No blocks to recover. Should be normal code path - * if ZSTORE was shutdown properly. Note that we can get a - * checksum error on first block when looking for current - * active pointer that would make us think we did a clean - * shutdown when we really did not. - */ + * Yes - No blocks to recover. Should be normal code path + * if ZSTORE was shutdown properly. Note that we can get a + * checksum error on first block when looking for current + * active pointer that would make us think we did a clean + * shutdown when we really did not. + */ if ( zlogBeast->ZLB_RecoveryActivePointerLsn == zlogBeast->ZLB_P.ZLBP_HomePointerLsn ) { @@ -4170,11 +4151,11 @@ STATUS ZLOG_RecoveryPhase( "(consistency check OK)\n", 341)); DEBUG_PRINTF(TZLOG, DBG_NOINDENT, (TZLOG_COLOR, MSGNot("Previous clean shutdown detected (ZLOG recovery not needed).\n")) ); /* - * Start checkpoint timer here, because we will not be - * taking any checkpoints in this code path. Taking a - * checkpoint is the other way this routine starts the - * checkpoint timer. - */ + * Start checkpoint timer here, because we will not be + * taking any checkpoints in this code path. Taking a + * checkpoint is the other way this routine starts the + * checkpoint timer. + */ setOneShot(&zlogBeast->ZLB_CheckpointTakeWorkToDoTimer, ZstoreConfig.tick.chkpt, ZFSPOOL_CheckpointTimerPop); status = zOK; @@ -4194,18 +4175,18 @@ STATUS ZLOG_RecoveryPhase( status = zFAILURE; } /* - * We do not have to do a checkpoint because the current - * checkpoint is good enough (excluding possible checksum - * error). - */ + * We do not have to do a checkpoint because the current + * checkpoint is good enough (excluding possible checksum + * error). + */ zlogBeast->ZLB_DebugState = ZLOG_ZB_DS_RECOVERY_END; - UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); - UNX_LATCH( &zlogBeast->ZLB_RecoveryLatch ); + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNX_LATCH( &zlogBeast->ZLB_RecoveryLatch ); /* - * Update the ZLOG file version if recovery is not needed. - * Required when the file version changes after a clean - * shutdown. - */ + * Update the ZLOG file version if recovery is not needed. + * Required when the file version changes after a clean + * shutdown. + */ zlogBeast->ZLB_P.ZLBP_FileVersion = ZLOG_ZLBP_FV_VERSION; RTN_STATUS( status ); } @@ -4238,14 +4219,14 @@ STATUS ZLOG_RecoveryPhase( // zlogBeast->ProcessCompensationRecords = TRUE; // } - zlogBeast->ZLB_RecoveryInitialActivePointerLsn = + zlogBeast->ZLB_RecoveryInitialActivePointerLsn = zlogBeast->ZLB_P.ZLBP_ActivePointerLsn; - zlogBeast->ZLB_RecoveryInitialActivePointerBlockNumber = + zlogBeast->ZLB_RecoveryInitialActivePointerBlockNumber = zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; /* Update number of time we had to do recovery */ zlogBeast->ZLB_P.ZLBP_RecoveryRecoverCount += 1; - zlogBeast->ZLB_P.ZLBP_LastRecoveryTimeStart = + zlogBeast->ZLB_P.ZLBP_LastRecoveryTimeStart = zlogBeast->ZLB_P.ZLBP_TimeActivation; zlogBeast->ZLB_P.ZLBP_LastRecoveryActivationCount = @@ -4253,7 +4234,7 @@ STATUS ZLOG_RecoveryPhase( zASSERT( zlogBeast->ZFSLOGroot.vol.zfsVol->pool != NULL ); /* Call Transaction Recovery Engine */ if (zlogBeast->ZFSLOGroot.vol.zfsVol->pool->ZP_super-> - SB_Header.hdr.SBH_VersionMediaMajor <= AIPU_1ST_6PACK_MEDIA_VERSION) + SB_Header.hdr.SBH_VersionMediaMajor <= AIPU_1ST_6PACK_MEDIA_VERSION) { status = XactionRecover( genMsg, zlogBeast->ZFSLOGroot.vol.zfsVol->pool, mode ); @@ -4271,35 +4252,35 @@ STATUS ZLOG_RecoveryPhase( if ( status == zOK) { /* - * Update home pointer using active pointer. The active pointer - * was updated by our recover active pointer code. I.E. the - * call to zlog_RecoverActivePointer() at the start of - * this routine. The active pointer has had our magic very big - * number added to it. - */ + * Update home pointer using active pointer. The active pointer + * was updated by our recover active pointer code. I.E. the + * call to zlog_RecoverActivePointer() at the start of + * this routine. The active pointer has had our magic very big + * number added to it. + */ if (zlogBeast->ZLB_State & ZLOG_ZB_S_NEEDTODO_COMPENSATION) { - zASSERT(zlogBeast->ZLB_P.ZLBP_ActivePointerLsn != + zASSERT(zlogBeast->ZLB_P.ZLBP_ActivePointerLsn != zlogBeast->ZLB_RecoveryInitialActivePointerLsn); /* We did at least one logical undo copy - * Before taking a checkpoint set: - * LogicalUndoPtr (LUP) = IAP - * CompensationPtr (COMP) = AP - * Home Pointer = LogicalUndoPtr (LUP) - */ + * Before taking a checkpoint set: + * LogicalUndoPtr (LUP) = IAP + * CompensationPtr (COMP) = AP + * Home Pointer = LogicalUndoPtr (LUP) + */ zlogBeast->ZLB_P.ZLBP_LogicalUndoPtrLsn = zlogBeast->ZLB_RecoveryInitialActivePointerLsn; zlogBeast->ZLB_P.ZLBP_LogicalUndoPtrBlkNum = zlogBeast->ZLB_RecoveryInitialActivePointerBlockNumber; /* The COMP pointer block number is set to be 1 greater than the - * ACT pointer because we are now going to flush the ZLOG file, - * and the block that the active pointer currently points to will - * get flushed, and the next time somebody does an obtain record, - * the record will be in the next block. We want COMP to point to - * this next block - */ + * ACT pointer because we are now going to flush the ZLOG file, + * and the block that the active pointer currently points to will + * get flushed, and the next time somebody does an obtain record, + * the record will be in the next block. We want COMP to point to + * this next block + */ zlogBeast->ZLB_P.ZLBP_CompensationPtrLsn = zlogBeast->ZLB_P.ZLBP_ActivePointerLsn; zlogBeast->ZLB_P.ZLBP_CompensationPtrBlkNum = @@ -4312,18 +4293,18 @@ STATUS ZLOG_RecoveryPhase( zlogBeast->ZLB_P.ZLBP_HomePointerBlockNumber = zlogBeast->ZLB_RecoveryInitialActivePointerBlockNumber; - /* This checkpoint taken by ZFSPOOL_CheckpointTake waits until - * the ZLOG blocks to which the - * logical undo records are written are flushed. - * It does a defaultFlushWait on the zlogbeast. - * This will cause the dirty buffers of the zlog file to be written - * including the blocks to which we just copied the new logical undo - * records. It then waits for the buffers to be flushed. - */ + /* This checkpoint taken by ZFSPOOL_CheckpointTake waits until + * the ZLOG blocks to which the + * logical undo records are written are flushed. + * It does a defaultFlushWait on the zlogbeast. + * This will cause the dirty buffers of the zlog file to be written + * including the blocks to which we just copied the new logical undo + * records. It then waits for the buffers to be flushed. + */ } else { - zASSERT(zlogBeast->ZLB_P.ZLBP_ActivePointerLsn == + zASSERT(zlogBeast->ZLB_P.ZLBP_ActivePointerLsn == zlogBeast->ZLB_RecoveryInitialActivePointerLsn); zASSERT(zlogBeast->ZLB_P.ZLBP_LogicalUndoPtrLsn == 0); @@ -4332,73 +4313,73 @@ STATUS ZLOG_RecoveryPhase( zASSERT(zlogBeast->ZLB_P.ZLBP_CompensationPtrBlkNum == 0); - /* We set HOME = ACT only if there were no Logical Undo's. - * If we had logical undo records/compensation records the - * the ZLOG_ZB_S_NEEDTODO_COMPENSATION will be set in the - * the ZLB_State - */ + /* We set HOME = ACT only if there were no Logical Undo's. + * If we had logical undo records/compensation records the + * the ZLOG_ZB_S_NEEDTODO_COMPENSATION will be set in the + * the ZLB_State + */ zlogBeast->ZLB_P.ZLBP_HomePointerLsn = zlogBeast->ZLB_P.ZLBP_ActivePointerLsn; - zlogBeast->ZLB_P.ZLBP_HomePointerBlockNumber = + zlogBeast->ZLB_P.ZLBP_HomePointerBlockNumber = zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; } zASSERT( zlogBeast->ZFSLOGroot.vol.zfsVol->pool != NULL ); /* - * Take a clean checkpoint. This puts a checkpoint with a - * home pointer that will prevent us from recovery buffers - * that we have already recovered. If we crash before the - * checkpoint is written we will have to recover the items - * we just recovered. This is a clean checkpoint because - * the transaction system flushes all buffers before returning - * to us. This is a requirement. - * - * We take four checkpoints here so that if the crash occurred - * at ZLOG File Full Condition we will move past the condition. - * This is required because ZLOG_ObtainRecord() does not handle - * a file full condition on the VERY FIRST call to it. - * - * The purge block code also requires us to take four checkpoints. - * This moves our 'undo pointer' far enough that the purge - * code can release on the purge blocks in its log into the - * Free B-Tree. The purge log started doing this September 1997. - * - */ + * Take a clean checkpoint. This puts a checkpoint with a + * home pointer that will prevent us from recovery buffers + * that we have already recovered. If we crash before the + * checkpoint is written we will have to recover the items + * we just recovered. This is a clean checkpoint because + * the transaction system flushes all buffers before returning + * to us. This is a requirement. + * + * We take four checkpoints here so that if the crash occurred + * at ZLOG File Full Condition we will move past the condition. + * This is required because ZLOG_ObtainRecord() does not handle + * a file full condition on the VERY FIRST call to it. + * + * The purge block code also requires us to take four checkpoints. + * This moves our 'undo pointer' far enough that the purge + * code can release on the purge blocks in its log into the + * Free B-Tree. The purge log started doing this September 1997. + * + */ #if NSS_DEBUG IS_ENABLED /* Need so obtain record will not ASSERT */ zlogBeast->ZLB_DebugState = ZLOG_ZB_DS_RECOVERY_END; #endif /* Can not own ZLOG latch when taking a checkpoint. */ - UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); for ( checkpoint=0; checkpoint < CHECKPOINT_NUMBER; ++checkpoint ) { STATUS tempStatus; - tempStatus = ZFSPOOL_CheckpointTake( genMsg, - zlogBeast->ZFSLOGroot.vol.zfsVol->pool, - CHECKPOINT_CT_S_CLEAN|CHECKPOINT_CT_S_RECOVERY); + tempStatus = ZFSPOOL_CheckpointTake( genMsg, + zlogBeast->ZFSLOGroot.vol.zfsVol->pool, + CHECKPOINT_CT_S_CLEAN|CHECKPOINT_CT_S_RECOVERY); if ( (tempStatus != zOK) && (status ==zOK) ) { /* Report first error only, but try to write rest - * of checkpoints. Zrepair will have to make it so - * we can write the checkpoint before we will ever - * succeed at recovery. Note that if user tries - * to re-activate the pool it will succeed as long - * as one checkpoint got written. This is caused - * by the fact that we are happy if we can read one - * checkpoint. And since it is a clean checkpoint - * recovery will not be needed. Therefore we will - * not try to write the checkpoint we got an error - * on. - */ + * of checkpoints. Zrepair will have to make it so + * we can write the checkpoint before we will ever + * succeed at recovery. Note that if user tries + * to re-activate the pool it will succeed as long + * as one checkpoint got written. This is caused + * by the fact that we are happy if we can read one + * checkpoint. And since it is a clean checkpoint + * recovery will not be needed. Therefore we will + * not try to write the checkpoint we got an error + * on. + */ status = tempStatus; } } - X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); /* We now re-load the volumes persistent data because REDO/UNDO - * may have updated the persistent copy. The same is now - * true with the pool's persistent data. - */ + * may have updated the persistent copy. The same is now + * true with the pool's persistent data. + */ if ( status == zOK ) { status = ZFSVOL_ReadPersistentVolumeData( genMsg, @@ -4406,8 +4387,8 @@ STATUS ZLOG_RecoveryPhase( } if ( status == zOK ) { /* Pool blocks do not exist until media 40.03 so skip - * reading pool blocks until then. - */ + * reading pool blocks until then. + */ ZfsPool_s *zfsPool; Pool_s *pool; @@ -4455,9 +4436,9 @@ STATUS ZLOG_RecoveryPhase( (QUAD)(zlogBeast->ZLB_P.ZLBP_LastRecoveryTimeEnd - zlogBeast->ZLB_P.ZLBP_LastRecoveryTimeStart + 1u) ); /* Log time_t of recovery start (we do start as part - * of a log is the event time which will be very close - * to the recovery end time). - */ + * of a log is the event time which will be very close + * to the recovery end time). + */ ZLOG_HISTORY_EVENT( (ZlogHistory_s *)&zlogBeast->ZLB_History[ZH16_RECOVERY_UTC], (QUAD)zlogBeast->ZLB_P.ZLBP_LastRecoveryTimeStart ); #if 0 @@ -4469,7 +4450,7 @@ STATUS ZLOG_RecoveryPhase( { /* YES - We were unable to process log file */ errPrintf(WHERE, Module, 1456, MSG("** System verification failed.\n" - "You may have to rebuild your volume. If this happens again,\n" + "You may have to rebuild your volume. If this happens again,\n" "contact your Novell Technical Support Provider.", 873)); DEBUG_PRINTF(TZLOG, DBG_NOINDENT, (TZLOG_COLOR, MSGNot("Recovery complete - failure.\n")) ); @@ -4482,8 +4463,8 @@ STATUS ZLOG_RecoveryPhase( zlogBeast->ZLB_DebugState = ZLOG_ZB_DS_RECOVERY_END; } - UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); - UNX_LATCH( &zlogBeast->ZLB_RecoveryLatch ); + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNX_LATCH( &zlogBeast->ZLB_RecoveryLatch ); RTN_STATUS(status); @@ -4494,7 +4475,7 @@ STATUS ZLOG_RecoveryPhase( * * void ZLOG_ReleaseRecord( ZfsXaction_s *zlogXaction ) * - * Informs ZLOG logging subsystem that the caller has completed the following + * Informs ZLOG logging subsystem that the caller has completed the following * requirements. * * Filled in the data portion of the pool log record. @@ -4530,7 +4511,7 @@ Time_t ZLOG_RecoveryTimeGet( } -void ZLOG_ReleaseRecord( +void ZLOG_ReleaseRecord( ZfsXaction_s *zlogXaction ) { @@ -4548,14 +4529,14 @@ void ZLOG_ReleaseRecord( zASSERT( zlogBeast->ZLB_P.ZLBP_Signature == ZLOG_ZLBP_S_SIGNATURE ); /* Caller must own beastLatch (via ZLOG_ObtainRecord) */ - ASSERT_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + ASSERT_LATCH( &zlogBeast->ZFSLOGbeastLatch ); /* Must have called ZLOGObtainRecord which sets to non-NULL */ zASSERT( zlogBeast->ZLB_ZfsXasRecovery != NULL ); /* - * The ZLOG record header contains a ZfsXasRecovery_s structure, - * therefore we can obtain the ZLOG record header from the stored - * address of the ZfsXasRecovery_s structure. - */ + * The ZLOG record header contains a ZfsXasRecovery_s structure, + * therefore we can obtain the ZLOG record header from the stored + * address of the ZfsXasRecovery_s structure. + */ logRecordHeader = STRUCT( zlogBeast->ZLB_ZfsXasRecovery, ZLOGRecordHeader_s, ZLRH_Zxr ); #if NSS_ASSERT IS_ENABLED @@ -4566,7 +4547,7 @@ void ZLOG_ReleaseRecord( logBlockHeader = (ZLOGBlockHeader_s *)zlogBeast->ZLB_Buffer->pBuf.data; len = logBlockHeader->ZLBH_NumberOfUnusedLongs; - checkArea = ((LONG *)logBlockHeader) + + checkArea = ((LONG *)logBlockHeader) + (( (1 << zlogBeast->ZFSLOGblkSizeShift))/4) - len; for( ; len > 0; --len ) { @@ -4574,25 +4555,25 @@ void ZLOG_ReleaseRecord( { zASSERT("Someone is writing past log record end" == NULL); break; - } + } checkArea += 1; } - } + } #endif #if NSS_ASSERT IS_ENABLED /* - * We ZAP so if caller uses after release they may crash. Note - * that if they use between someones elses ZLOG_ObtainRecord() and - * ZLOG_ReleaseRecord THEY will not be caught. Note we must zero - * out if ASSERTs are in our code. - */ + * We ZAP so if caller uses after release they may crash. Note + * that if they use between someones elses ZLOG_ObtainRecord() and + * ZLOG_ReleaseRecord THEY will not be caught. Note we must zero + * out if ASSERTs are in our code. + */ zlogBeast->ZLB_ZfsXasRecovery = NULL; #endif #if ZLOG_DEBUG IS_ENABLED /* - * Callers must initialize after return from ZLOG_ObtainRecord() - * and before call to this function. - */ + * Callers must initialize after return from ZLOG_ObtainRecord() + * and before call to this function. + */ zASSERT( logRecordHeader->ZLRH_Zxr.ZXR_FunctionIndex != 0xBEEFBEEFuL ); zASSERT( logRecordHeader->ZLRH_Zxr.ZXR_PoolBlockCount != 0xBEEFu ); /* Verify index is within range */ @@ -4603,9 +4584,9 @@ void ZLOG_ReleaseRecord( zlogBeast->ZLB_P.ZLBP_ActivePointerReferenceBlockCount += logRecordHeader->ZLRH_Zxr.ZXR_PoolBlockCount; /* - * OR in current states so we do not loss states added in obtain. - * Note this OR adds in extra debug information. - */ + * OR in current states so we do not loss states added in obtain. + * Note this OR adds in extra debug information. + */ logRecordHeader->ZLRH_Zxr.ZXR_TransactionState |= zlogXaction->xstate; #if ZLOG_DEBUG IS_ENABLED /** Fill in end time **/ @@ -4614,7 +4595,7 @@ void ZLOG_ReleaseRecord( #if LOG_TEST IS_ENABLED if ( LogTest && (logRecordHeader->ZLRH_Zxr.ZXR_FunctionIndex >= xfirst) && - (logRecordHeader->ZLRH_Zxr.ZXR_FunctionIndex <= xlast) ) + (logRecordHeader->ZLRH_Zxr.ZXR_FunctionIndex <= xlast) ) { XRecovery_f func; GeneralMsg_s genMsg; @@ -4703,23 +4684,23 @@ void ZLOG_ReleaseRecord( } /* - * Turn off the bit that causes several routines to act special - * so that our undo/redo tests can work. - */ + * Turn off the bit that causes several routines to act special + * so that our undo/redo tests can work. + */ zlogXaction->xstate &= ~X_REDO_THEN_UNDO; #endif /* - * Calculate checksum on all bytes in log record. This includes - * the bytes that are used to align us to the proper boundary. This - * is done because ZLOG does not track how many of these bytes - * are present in each log record. In addition, our checksum - * routine does LONGs so to be fast. - */ + * Calculate checksum on all bytes in log record. This includes + * the bytes that are used to align us to the proper boundary. This + * is done because ZLOG does not track how many of these bytes + * are present in each log record. In addition, our checksum + * routine does LONGs so to be fast. + */ logRecordHeader->ZLRH_Checksum = 0; /* - * The checksum we store is the value that makes a good - * block's checksum equal to zero. - */ + * The checksum we store is the value that makes a good + * block's checksum equal to zero. + */ #if ZLOG_CHECKSUM_LOG_RECORDS IS_ENABLED logRecordHeader->ZLRH_Checksum = 0 - zlog_CalculateChecksum( (LONG *)logRecordHeader, @@ -4751,9 +4732,9 @@ void ZLOG_ReleaseRecord( is in can now be released by other ZLOG code. **/ /* Since UNX_LATCH are non blocking calls we know nobody can get the - * ZLB_Buffer before we yield. So I can call defaultFlushWait here - * on ZLB_Buffer if I want to wait for the xaction to commit - */ + * ZLB_Buffer before we yield. So I can call defaultFlushWait here + * on ZLB_Buffer if I want to wait for the xaction to commit + */ defaultFlushWait(&waitAgent); } else @@ -4936,15 +4917,15 @@ Buffer_s *zlog_RGReadAndVerifyBlock( zASSERT( zlogBeast->ZLB_Signature == ZLOG_ZLB_S_SIGNATURE ); zASSERT( zlogBeast->ZFSLOGroot.eof >= ZLOG_FILE_SIZE_MINIMUM ); zASSERT( zlogBeast->ZLB_P.ZLBP_Signature == ZLOG_ZLBP_S_SIGNATURE ); - + FILEBLK_IO_MSG(ioMsg, zlogBeast, blockToRead, 1, CACHE_READ ); buffer = COMN_GetFileBlk(genMsg, &ioMsg); /* - * Note that COMN_GetFileBlk() has obtained an shared latch on - * the buffer for us since we will only be reading it. We - * release this latch right after processing the block. This - * latch is only obtained if zOK is returned. - */ + * Note that COMN_GetFileBlk() has obtained an shared latch on + * the buffer for us since we will only be reading it. We + * release this latch right after processing the block. This + * latch is only obtained if zOK is returned. + */ /* Did our read succeed? */ if (buffer == NULL) { /* NO - An error occurred. Note buffer latch is not owned. */ @@ -4955,21 +4936,21 @@ Buffer_s *zlog_RGReadAndVerifyBlock( /*** Setup log block header pointer ***/ /* - * FixFixFix6(Future,Performance,Paul,Neal) - many of these - * test were done in RAP, do we really need to do again? - * This comes down to ZSTORE rule of if I read a block and - * verify then read again (no writes to blocks in between) - * do I have to re-verify? - * - * As of September 1997, we have no problems with recovery time - * requirement of less then 15 seconds. - */ + * FixFixFix6(Future,Performance,Paul,Neal) - many of these + * test were done in RAP, do we really need to do again? + * This comes down to ZSTORE rule of if I read a block and + * verify then read again (no writes to blocks in between) + * do I have to re-verify? + * + * As of September 1997, we have no problems with recovery time + * requirement of less then 15 seconds. + */ logBlockHeader = (ZLOGBlockHeader_s *)buffer->pBuf.data; /* - * Better verify length field used for checksumming. All log blocks - * must have a log block header. Log blocks do not have to have a log - * record header because install does not fill in. - */ + * Better verify length field used for checksumming. All log blocks + * must have a log block header. Log blocks do not have to have a log + * record header because install does not fill in. + */ if ( logBlockHeader->ZLBH_NumberOfUnusedLongs > ( ( (1 << zlogBeast->ZFSLOGblkSizeShift) - sizeof(ZLOGBlockHeader_s) )/4) ) @@ -4979,13 +4960,13 @@ Buffer_s *zlog_RGReadAndVerifyBlock( goto zlogRGRAVBStopProcessing2; } /* - * Calculate the checksum. The checksum code was removed because - * the Transaction System changes the logging state element - * of log records during recovery. Not doing checksums - * here is O.K. because the buffers have already made it - * past one checksum when the log buffer was read in during - * the Recover Active Pointer pass. - */ + * Calculate the checksum. The checksum code was removed because + * the Transaction System changes the logging state element + * of log records during recovery. Not doing checksums + * here is O.K. because the buffers have already made it + * past one checksum when the log buffer was read in during + * the Recover Active Pointer pass. + */ /* Verify that this is a log block */ if ( logBlockHeader->ZLBH_Signature != ZLBH_S_SIGNATURE ) @@ -4997,24 +4978,24 @@ Buffer_s *zlog_RGReadAndVerifyBlock( /*** Checksum is good and this is a ZLOG block ***/ if ( logBlockHeader->ZLBH_Status & ZLBH_S_INSTALL ) { /* - * Install wrote which means we must be done processing - * the log file. Note that the only time we should see a - * install log block is if we have a "hole" in between - * the home pointer and active pointer that was stored in the - * checkpoint. A "hole" is caused by some log blocks not - * being written before we crash. This hole implies that - * we did not recovery ALL metadata (although we do not know - * if we failed on committed or non-committed data recovery). - */ + * Install wrote which means we must be done processing + * the log file. Note that the only time we should see a + * install log block is if we have a "hole" in between + * the home pointer and active pointer that was stored in the + * checkpoint. A "hole" is caused by some log blocks not + * being written before we crash. This hole implies that + * we did not recovery ALL metadata (although we do not know + * if we failed on committed or non-committed data recovery). + */ zASSERT( "LOG BLOCK - hole detected" == NULL ); status = zERR_ZLOG_BAD_BLOCK_SIGNATURE; goto zlogRGRAVBStopProcessing2; } /*** Checksum is good and this is a ZLOG block and not install - * written - ***/ + * written + ***/ recordNumber = logBlockHeader->ZLBH_NumberOfRecords; - if ( ( recordNumber < 1 ) || + if ( ( recordNumber < 1 ) || (recordNumber > ((zlog_MAXIMUM_RECORD_SIZE/sizeof(ZLOGRecordHeader_s)+1)) )) { zASSERT( "LOG BLOCK - Log Record count error" == NULL ); @@ -5025,10 +5006,10 @@ Buffer_s *zlog_RGReadAndVerifyBlock( /*** Verify all log records in the log block ***/ /* - * Call our code that verifies all the log records in a single - * log block - */ - status = zlog_RGVerifyRecords( genMsg, zlogBeast, buffer, recordNumber ); + * Call our code that verifies all the log records in a single + * log block + */ + status = zlog_RGVerifyRecords( genMsg, zlogBeast, buffer, recordNumber ); if ( status != zOK ) { /* Release shared access on log block buffer */ @@ -5051,7 +5032,7 @@ zlogRGRAVBStopProcessing2:; /* * * Verify ALL log records of the current log block. - * + * * Latches owned - ZLOG beast latch * ZLB_RecoveryLatch * Buffer's latch @@ -5067,7 +5048,7 @@ zlogRGRAVBStopProcessing2:; */ STATUS zlog_RGVerifyRecords( - GeneralMsg_s *genMsg, + GeneralMsg_s *genMsg, ZlogBeast_s *zlogBeast, Buffer_s *buffer, NINT recordNumber ) @@ -5109,7 +5090,7 @@ STATUS zlog_RGVerifyRecords( { /* Point to next log record within block */ logRecordHeader = (ZLOGRecordHeader_s *)( ((BYTE *)logBlockHeader) - + processedBytes); + + processedBytes); /* Verify that length is not to short for even just the header */ if ( logRecordHeader->ZLRH_LongLength < (sizeof(ZLOGRecordHeader_s)/4) ) { @@ -5128,13 +5109,13 @@ STATUS zlog_RGVerifyRecords( } /* - * Calculate the checksum. The checksum code was removed because - * the Transaction System changes the logging state element - * of log records during recovery. Not doing checksums - * here is O.K. because the buffers have already made it - * past one checksum when the log buffer was read in during - * the Recover Active Pointer pass. - */ + * Calculate the checksum. The checksum code was removed because + * the Transaction System changes the logging state element + * of log records during recovery. Not doing checksums + * here is O.K. because the buffers have already made it + * past one checksum when the log buffer was read in during + * the Recover Active Pointer pass. + */ /*** Finally lets look at the LSN ***/ @@ -5180,9 +5161,9 @@ void zlog_THSerialized( FsmLite_s *fsmLite ) zASSERT( zlogBeast->ZFSLOGroot.eof >= ZLOG_FILE_SIZE_MINIMUM ); zASSERT( zlogBeast->ZLB_P.ZLBP_Signature == ZLOG_ZLBP_S_SIGNATURE ); /* - * Not all transactions have log records. So only check the - * seniority list if we made it past start. - */ + * Not all transactions have log records. So only check the + * seniority list if we made it past start. + */ if ( !(homedZXaction->xstate & XAS_XR_TS_START) ) { /* This transaction has a log record */ zlogBeast->ZLB_TransactionsHomedSinceCheckpointCount++; @@ -5192,25 +5173,25 @@ void zlog_THSerialized( FsmLite_s *fsmLite ) ZfsXaction_s, ZX_seniorityList ); zASSERT( oldestZXaction != NULL ); /* - * Remove homed transaction from ZLOG Beast seniority - * list (ZX_SeniorityListHead) - */ + * Remove homed transaction from ZLOG Beast seniority + * list (ZX_SeniorityListHead) + */ DQ_RMV( homedZXaction, ZX_seniorityList ); /* Is the homed transaction also the oldest transaction? */ if ( oldestZXaction == homedZXaction ) { /* - * YES - The homed transaction was the oldest transaction so - * the home pointer can be moved. - */ + * YES - The homed transaction was the oldest transaction so + * the home pointer can be moved. + */ /* Get the new oldest transaction */ DQ_PEEK( &zlogBeast->ZLB_SeniorityListHead, oldestZXaction, ZfsXaction_s, ZX_seniorityList ); #if NSS_DEBUG IS_ENABLED /* - * For /nodata to work we must not update home otherwise - * we will not do recovery on the metadata blocks that we - * did not really write. - */ + * For /nodata to work we must not update home otherwise + * we will not do recovery on the metadata blocks that we + * did not really write. + */ if ( !CrashPools ) { #endif @@ -5218,19 +5199,19 @@ void zlog_THSerialized( FsmLite_s *fsmLite ) if ( oldestZXaction == NULL ) { /* NO -- update home pointer using active pointer */ zlogBeast->ZLB_P.ZLBP_HomePointerLsn = - zlogBeast->ZLB_P.ZLBP_ActivePointerLsn; - zlogBeast->ZLB_P.ZLBP_HomePointerBlockNumber = - zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; + zlogBeast->ZLB_P.ZLBP_ActivePointerLsn; + zlogBeast->ZLB_P.ZLBP_HomePointerBlockNumber = + zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; /* - * I thought about taking a checkpoint whenever we - * have no transactions left on our list. This would - * get a checkpoint out everytime we where 'clean', - * but this may occur too often during the normal - * running case and would only gain us less recovery - * time if we crash. We will just drop through to - * code that will do a checkpoint if home moved a - * lot since the last checkpoint. - */ + * I thought about taking a checkpoint whenever we + * have no transactions left on our list. This would + * get a checkpoint out everytime we where 'clean', + * but this may occur too often during the normal + * running case and would only gain us less recovery + * time if we crash. We will just drop through to + * code that will do a checkpoint if home moved a + * lot since the last checkpoint. + */ } else { /* YES, update home pointer using oldest Xaction info */ @@ -5244,18 +5225,18 @@ void zlog_THSerialized( FsmLite_s *fsmLite ) #endif { /* - * If the home pointer has moved a lot since our last - * checkpoint OR if we are in throttle back mode - * then schedule another checkpoint. Note that - * checkpoint schedule code will not schedule a - * checkpoint if one is already scheduled. - */ + * If the home pointer has moved a lot since our last + * checkpoint OR if we are in throttle back mode + * then schedule another checkpoint. Note that + * checkpoint schedule code will not schedule a + * checkpoint if one is already scheduled. + */ NINT checkpoint; Blknum_t blocks; checkpoint = zlog_GetNewestCheckpointIndex( zlogBeast ); if ( zlogBeast->ZLB_P.ZLBP_OldHomePointerBlockNumber[checkpoint] > - zlogBeast->ZLB_P.ZLBP_HomePointerBlockNumber ) + zlogBeast->ZLB_P.ZLBP_HomePointerBlockNumber ) { blocks = (zlogBeast->ZLB_NumberOfLogBlocks - zlogBeast->ZLB_P.ZLBP_OldHomePointerBlockNumber[checkpoint]) + @@ -5284,20 +5265,20 @@ void zlog_THSerialized( FsmLite_s *fsmLite ) } } /* - * There is no reason to wake up waiters here because for them to - * stay awake the pre oldest home pointer block must move. This - * block ONLY moves when checkpoints are taken. Therefore the check - * that is in the checkpoint code for waiters is all that is needed. - * Noticed this when adding 'too' full waiting code on June 17, 1997. - */ + * There is no reason to wake up waiters here because for them to + * stay awake the pre oldest home pointer block must move. This + * block ONLY moves when checkpoints are taken. Therefore the check + * that is in the checkpoint code for waiters is all that is needed. + * Noticed this when adding 'too' full waiting code on June 17, 1997. + */ } } /** Release our exclusive latch over the ZLOG system **/ - UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); /* - * Instead of calling transaction system to let it finish processing - * transaction ZLOG finishes for it. - */ + * Instead of calling transaction system to let it finish processing + * transaction ZLOG finishes for it. + */ defaultSignal( &homedZXaction->xaction.agent); freeXaction( homedZXaction); RTN_VOID(); @@ -5310,11 +5291,11 @@ void zlog_THSerialized( FsmLite_s *fsmLite ) * * * Used to tell ZLOG that it can move the home pointer forward. The - * Transaction System calls off a pointer in the ZfsXaction_s structure + * Transaction System calls off a pointer in the ZfsXaction_s structure * everytime a transaction is homed. ZLOG has placed this routine * into the pointer (in ZLOG_ObtainRecord). ZLOG must check to see if * the ZLOG home pointer can be moved. - * + * * The Transaction System allows ZLOG to use the FsmLite_s within the home * agent within the XAS. * @@ -5334,7 +5315,7 @@ void ZLOG_TransactionHomed( ZfsXaction_s *xaction ) zASSERT( zlogBeast->ZFSLOGroot.eof >= ZLOG_FILE_SIZE_MINIMUM ); zASSERT( zlogBeast->ZLB_P.ZLBP_Signature == ZLOG_ZLBP_S_SIGNATURE ); /* Serialize the ZLOG system for this beast */ - FSM_X_LATCH( &zlogBeast->ZFSLOGbeastLatch, fsmLite, zlog_THSerialized ); + FSM_X_LATCH( &zlogBeast->ZFSLOGbeastLatch, fsmLite, zlog_THSerialized ); RTN_VOID(); } /* End of ZLOGTransactionHomed */ @@ -5363,7 +5344,7 @@ void ZLOG_TransactionHomed( ZfsXaction_s *xaction ) /* Requirements: Synchronous and non-blocking Entry state: Shared lock on beast latch - Zlog_ZfsPackedSize - + Zlog_ZfsPackedSize - */ STATIC NINT Zlog_ZfsPackedSize( @@ -5422,33 +5403,33 @@ STATIC BYTE *Zlog_ZfsPack( mcp = &zfsPool->ZP_super->SB_Checkpoint; /* - * Update the ZLOG beasts copy of the four checkpoint's home - * pointer. This can be done now (before we know checkpoint makes - * it to the media) because our code that uses the old home pointer - * only executes if the checkpoint gets written (see - * (ZFSPOOL_CheckpointTake()). This values are also used when we - * come up in the recovery code. By updating here the checkpoint - * will have the latest information when we come up next time. - */ + * Update the ZLOG beasts copy of the four checkpoint's home + * pointer. This can be done now (before we know checkpoint makes + * it to the media) because our code that uses the old home pointer + * only executes if the checkpoint gets written (see + * (ZFSPOOL_CheckpointTake()). This values are also used when we + * come up in the recovery code. By updating here the checkpoint + * will have the latest information when we come up next time. + */ nextCheckpoint = zfsPool->ZP_NextCheckpoint + 1; if ( nextCheckpoint >= CHECKPOINT_NUMBER ) { - nextCheckpoint = 0; + nextCheckpoint = 0; } /* - * - */ + * + */ { LONG diff; if ( !(mcp->chkPnt.CP_State & CHECKPOINT_CT_S_DEBUG) ) { /* Do not update histogram if this is a debug checkpoint. In - * the debug system we take 2 checkpoints each time - * checkpoint take is called. The debug checkpoint messes - * up our histogram information. - */ + * the debug system we take 2 checkpoints each time + * checkpoint take is called. The debug checkpoint messes + * up our histogram information. + */ if ( zlogBeast->ZLB_P.ZLBP_OldHomePointerBlockNumber[nextCheckpoint] - <= zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber ) + <= zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber ) { diff = zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber - zlogBeast->ZLB_P.ZLBP_OldHomePointerBlockNumber[nextCheckpoint]; @@ -5459,7 +5440,7 @@ STATIC BYTE *Zlog_ZfsPack( diff = zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber + zlogBeast->ZLB_NumberOfLogBlocks - - zlogBeast->ZLB_P.ZLBP_OldHomePointerBlockNumber[nextCheckpoint]; + zlogBeast->ZLB_P.ZLBP_OldHomePointerBlockNumber[nextCheckpoint]; } ZLOG_HISTOGRAM_EVENT( &zlogBeast->ZLB_BlockInuseCountHistogram, diff ); @@ -5469,7 +5450,7 @@ STATIC BYTE *Zlog_ZfsPack( } #if NSS_DEBUG IS_ENABLED /* Store the time we packed the checkpoint - */ + */ zlogBeast->ZLB_CheckpointTime[nextCheckpoint] = GetUTCTime(); #endif zlogBeast->ZLB_P.ZLBP_OldHomePointerLsn[nextCheckpoint] = @@ -5477,16 +5458,16 @@ STATIC BYTE *Zlog_ZfsPack( zlogBeast->ZLB_P.ZLBP_OldHomePointerBlockNumber[nextCheckpoint] = zlogBeast->ZLB_P.ZLBP_HomePointerBlockNumber; /* - * Record/track information about how many blocks are being referenced - * from the previous home pointer to the active pointer. This - * tracks the 'normal' worst case block references that recovery - * will have to access. I.E. if we crashed now recovery would - * start at the previous home pointer (it is the newest copy - * on the media) and stop at the current active pointer (if - * the log blocks have made it to the media already). This is the - * 'normal' worst case because we assume that we are able to - * use the newest checkpoint when we do recovery. - */ + * Record/track information about how many blocks are being referenced + * from the previous home pointer to the active pointer. This + * tracks the 'normal' worst case block references that recovery + * will have to access. I.E. if we crashed now recovery would + * start at the previous home pointer (it is the newest copy + * on the media) and stop at the current active pointer (if + * the log blocks have made it to the media already). This is the + * 'normal' worst case because we assume that we are able to + * use the newest checkpoint when we do recovery. + */ if ( !(mcp->chkPnt.CP_State & CHECKPOINT_CT_S_DEBUG) ) { /* See previous if comment above */ ZLOG_HISTOGRAM_EVENT( &zlogBeast->ZLB_ReferenceBlockCountHistogram, @@ -5502,11 +5483,11 @@ STATIC BYTE *Zlog_ZfsPack( zlogBeast->ZLB_P.ZLBP_ActivePointerReferenceBlockCount; /* Now grab the ZLSS POOL's physical I/O statistics and - * throw into ZLOG. This way we get a fairly persistent - * information in ZLOG. - */ + * throw into ZLOG. This way we get a fairly persistent + * information in ZLOG. + */ zASSERT( sizeof( zlssPool->ZP_PRS ) == sizeof(zlogBeast->ZLB_P.ZLBP_StatisticsRead) ); - memcpy( &zlogBeast->ZLB_P.ZLBP_StatisticsRead, + memcpy( &zlogBeast->ZLB_P.ZLBP_StatisticsRead, &zlssPool->ZP_PRS, sizeof ( zlogBeast->ZLB_P.ZLBP_StatisticsRead ) ); zASSERT( sizeof( zlssPool->ZP_PWS ) == sizeof(zlogBeast->ZLB_P.ZLBP_StatisticsWrite) ); @@ -5561,10 +5542,10 @@ STATIC BYTE *Zlog_ZfsUnpack( ZlogBeastPersistent_1Dot0_s *zlogP1Dot0 = (ZlogBeastPersistent_1Dot0_s *)storeBuffer; /** Copy ALL the items at the beginning of the persistent - ** areas as they match in both versions 1.0 and 3.0. - ** After this we MUST assign items as they no longer match - ** up(i.e. offsets within structures are differrent). - **/ + ** areas as they match in both versions 1.0 and 3.0. + ** After this we MUST assign items as they no longer match + ** up(i.e. offsets within structures are differrent). + **/ if ( zlogP1Dot0->ZLBP_1Dot0_Signature2 != ZLOG_ZLBP_S_SIGNATURE ) { @@ -5581,14 +5562,14 @@ STATIC BYTE *Zlog_ZfsUnpack( ZLBP_1Dot0_PreHomePointerReferenceBlockCount) ); /** Init new persistnent histograms... - **/ + **/ zlog_initAllPersistentStatistics( zlogBeast ); /** Assign and convert any histograms that we care - ** about. We do the following histograms. - ** - ** 1) Function Histogram. - **/ + ** about. We do the following histograms. + ** + ** 1) Function Histogram. + **/ zlogBeast->ZLB_P.ZLBP_FunctionHistogramPersistent.ZHP_CurrentEvent = zlogP1Dot0->ZLBP_1Dot0_FunctionHistogram.ZH_1Dot0_CurrentEvent; @@ -5601,11 +5582,11 @@ STATIC BYTE *Zlog_ZfsUnpack( sizeof( zlogP1Dot0->ZLBP_1Dot0_FunctionBucket ) ); /** These four items only exist in some early (pre-October - ** 2000 versions of Six-Pack media). We handle so that - ** these six-pack volumes will not have to be destroyed. - ** On MOAB/Cobra system this lines just copy some - ** zeros around. - **/ + ** 2000 versions of Six-Pack media). We handle so that + ** these six-pack volumes will not have to be destroyed. + ** On MOAB/Cobra system this lines just copy some + ** zeros around. + **/ zlogBeast->ZLB_P.ZLBP_CompensationPtrLsn = zlogP1Dot0->ZLBP_1Dot0_CompensationPtrLsn; zlogBeast->ZLB_P.ZLBP_LogicalUndoPtrLsn = zlogP1Dot0->ZLBP_1Dot0_LogicalUndoPtrLsn; zlogBeast->ZLB_P.ZLBP_CompensationPtrBlkNum = zlogP1Dot0->ZLBP_1Dot0_CompensationPtrBlkNum; @@ -5614,14 +5595,14 @@ STATIC BYTE *Zlog_ZfsUnpack( // bzero( &zlogBeast->ZLB_P.ZLBP_Reserved, sizeof(zlogBeast->ZLB_P.ZLBP_Reserved) ); /** Assign the last TWO items of the persistent - ** areas as they do NOT match in versions 1.0 and 3.0. - **/ + ** areas as they do NOT match in versions 1.0 and 3.0. + **/ zlogBeast->ZLB_P.ZLBP_Signature = zlogP1Dot0->ZLBP_1Dot0_Signature; // zlogBeast->ZLB_P.ZLBP_Pad2 = zlogP1Dot0->ZLBP_1Dot0_Pad2; /* Now that we have unpacked, update version so - * that it will be persistent on next PACK. - */ + * that it will be persistent on next PACK. + */ zlogBeast->ZLB_P.ZLBP_VersionMajor = ZLOG_ZLBP_VM_MAJOR; storeBuffer += sizeof( *zlogP1Dot0 ); break; @@ -5652,16 +5633,16 @@ STATIC BYTE *Zlog_ZfsUnpack( } } zASSERT( zlogBeast->ZFSLOGroot.eof >= ZLOG_FILE_SIZE_MINIMUM ); - /* - * Restore persistent items back to default values. Usaully the items - * being retored have only been placed in the persistent area so - * that they can be viewed by the user or developer. - */ + /* + * Restore persistent items back to default values. Usaully the items + * being retored have only been placed in the persistent area so + * that they can be viewed by the user or developer. + */ zlogBeast->ZLB_P.ZLBP_Mode = ZLOG_MODE_DEFAULT; /* - * Initialize common non-persistent items that are dependent on - * persistent information. - */ + * Initialize common non-persistent items that are dependent on + * persistent information. + */ if ( zlog_CommonCreateAndOpen( genMsg, zlogBeast ) != zOK ) { zASSERT("Please get Greg (or Vandana)"==NULL); @@ -5678,7 +5659,7 @@ STATIC BYTE *Zlog_ZfsUnpack( zASSERT( zlogBeast->ZLB_RecoveryTimeHistogram.ZH_Bucket == &zlogBeast->ZLB_P.ZLBP_RecoveryTimeBucket ); zASSERT( zlogBeast->ZLB_DeferredWritesHistogram.ZH_Bucket == - &zlogBeast->ZLB_P.ZLBP_DeferredWritesBucket ); + &zlogBeast->ZLB_P.ZLBP_DeferredWritesBucket ); RTN_PTR(storeBuffer); } /* End of Zlog_ZfsUnpack() */ @@ -5689,22 +5670,22 @@ STATIC BYTE *Zlog_ZfsUnpack( *---------------------------------------------------------------------------*/ LSSSpecificPackUnpackOps_s ZLOG_lssOps[] = { - /* - * State on entry - * - * beastLatch - * PackedSize Shared(Owned) - * Pack Shared(Owned) - * Unpack None - * - * Requirements placed on code - * - * Synchronous Non-Blocking - * PackedSize Yes Yes - * Pack Yes Yes - * Unpack Yes No - * - */ + /* + * State on entry + * + * beastLatch + * PackedSize Shared(Owned) + * Pack Shared(Owned) + * Unpack None + * + * Requirements placed on code + * + * Synchronous Non-Blocking + * PackedSize Yes Yes + * Pack Yes Yes + * Unpack Yes No + * + */ {zLSS_ID_ZLSS,Zlog_ZfsPackedSize,Zlog_ZfsPack,NULL,Zlog_ZfsUnpack}, {zLSS_ID_INVALID} @@ -5727,13 +5708,13 @@ void Zlog_Throttle( Volume_s *volume, ZfsXaction_s *zlogXaction ) zASSERT( zlogBeast->ZFSLOGroot.eof >= ZLOG_FILE_SIZE_MINIMUM ); zASSERT( zlogBeast->ZLB_P.ZLBP_Signature == ZLOG_ZLBP_S_SIGNATURE ); /* - * Verify that we are not about to give out a block when in - * throttle mode. If in throttle mode we do not allow any NEW - * common layer transactions obtain a first log record. - * - * Is the file 'too' full? - */ - + * Verify that we are not about to give out a block when in + * throttle mode. If in throttle mode we do not allow any NEW + * common layer transactions obtain a first log record. + * + * Is the file 'too' full? + */ + if ( zlogBeast->ZLB_P.ZLBP_Mode & ZLOG_THROTTLE_BACK ) { /* In throttle back mode */ NINT blocksInuse; @@ -5741,15 +5722,15 @@ void Zlog_Throttle( Volume_s *volume, ZfsXaction_s *zlogXaction ) SNINT delayAmount = 0; /* In milliseconds */ ++zlogBeast->ZLB_P.ZLBP_FileThrottleWaitCount; - - X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); - - if ( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber <= + + X_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + + if ( zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber <= zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber ) { /* Do wrap math calculation */ blocksInuse = (NINT)zlogBeast->ZLB_NumberOfLogBlocks - (NINT)zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber + - (NINT)zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; + (NINT)zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber; zASSERT(zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber != zlogBeast->ZLB_P.ZLBP_PreOldestHomePointerBlockNumber ); } @@ -5760,23 +5741,23 @@ void Zlog_Throttle( Volume_s *volume, ZfsXaction_s *zlogXaction ) } if ( blocksInuse >= zlogBeast->ZLB_P.ZLBP_FileThrottleBack ) { /* Yes - The file is 'too' full */ - /** August 9, 2001 - - ** A recent fix to rebuild causes the ZLOG to - ** throttle rebuild. On my volume I saw that this - ** throttle was TOO extreme because we did not - ** take enough checkpoints to move PRE oldest home - ** pointer. On a 1GB volume with 7000 files we - ** would wait for the 30 second timer to move the - ** fourth checkpoint (the one that would make the - ** ZLOG file less than 1/2 full). In the long run - ** we may wish to remove that logic that says the - ** ZLOG fullness is measured from ACTIVE to OLDEST HOME. - ** This is no longer TRUE since we no longer UNDO - ** committed transactions. I.E. we never have to go - ** past the 1st checkpoint. BUT BUT BUT if we can not - ** read a checkpoint then the previous checkpoint(s) - ** need to still have a valid home. - **/ + /** August 9, 2001 - + ** A recent fix to rebuild causes the ZLOG to + ** throttle rebuild. On my volume I saw that this + ** throttle was TOO extreme because we did not + ** take enough checkpoints to move PRE oldest home + ** pointer. On a 1GB volume with 7000 files we + ** would wait for the 30 second timer to move the + ** fourth checkpoint (the one that would make the + ** ZLOG file less than 1/2 full). In the long run + ** we may wish to remove that logic that says the + ** ZLOG fullness is measured from ACTIVE to OLDEST HOME. + ** This is no longer TRUE since we no longer UNDO + ** committed transactions. I.E. we never have to go + ** past the 1st checkpoint. BUT BUT BUT if we can not + ** read a checkpoint then the previous checkpoint(s) + ** need to still have a valid home. + **/ zlog_CheckpointTakeSchedule( zlogBeast, CHECKPOINT_CT_S_NORMAL|CHECKPOINT_CT_S_THROTTLE_BACK ); percent = (100u * blocksInuse) / @@ -5791,39 +5772,39 @@ void Zlog_Throttle( Volume_s *volume, ZfsXaction_s *zlogXaction ) if ( percent < 60u ) { delayAmount = 1000u/2u; /* .5 sec */ - ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait2Count; + ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait2Count; } else { if ( percent < 70u ) { delayAmount = 1000u*1u; /* 1 sec */ - ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait3Count; + ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait3Count; } else { if ( percent < 80u ) { delayAmount = 1000u*10u; /* 10 sec */ - ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait4Count; + ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait4Count; } else { - if ( percent < 90u ) - { - delayAmount = 1000u*100u; /* 100 sec */ - ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait5Count; - } - else - { + if ( percent < 90u ) + { + delayAmount = 1000u*100u; /* 100 sec */ + ++zlogBeast->ZLB_P.ZLBP_FileThrottleWait5Count; + } + else + { /** On March 1, 2001 - * Paul, Vandana have decided that - * we should DISBALE pools that have a full - * ZLOG file. We do this at 90% so to - * leave room for logical undo (it needs - * to copy logical undo records at - * REDO/UNDO time). - */ + * Paul, Vandana have decided that + * we should DISBALE pools that have a full + * ZLOG file. We do this at 90% so to + * leave room for logical undo (it needs + * to copy logical undo records at + * REDO/UNDO time). + */ GeneralMsg_s dummyGenMsg; LONG flags; @@ -5832,35 +5813,36 @@ void Zlog_Throttle( Volume_s *volume, ZfsXaction_s *zlogXaction ) (void)COMN_VolumeAlert( &dummyGenMsg, NULL, volume, NULL, 0, 0, zERR_ZLOG_FILE_FULL, WHERE, flags ); - } + } } } } } - UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); /* The specificaiton requires us not to sleep for - * a long time so that if the throttle mode changes - * our thread gets to run 'right' away. We therefore - * delay 0.1 seconds and then see if still in throttle - * back mode. We also let run when thread has waited - * required amount(remember this prevents deadlocks). - */ + * a long time so that if the throttle mode changes + * our thread gets to run 'right' away. We therefore + * delay 0.1 seconds and then see if still in throttle + * back mode. We also let run when thread has waited + * required amount(remember this prevents deadlocks). + */ do { - LB_delay( 1000u/10u ); + LB_delay( 1000u/10u ); delayAmount -= 1000u/10u; /* Note that we normally are in a MPKNSS_LOCK region - * when looking at the throttle bit. We ignore here - * because it will not cause any serious problems. - */ + * when looking at the throttle bit. We ignore here + * because it will not cause any serious problems. + */ } while ( (delayAmount > 0) && (zlogBeast->ZLB_P.ZLBP_Mode & ZLOG_THROTTLE_BACK) ); - RTN_VOID(); + RTN_VOID(); } - - UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); - RTN_VOID(); + + UNX_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + RTN_VOID(); } - + RTN_VOID(); } + diff --git a/src/nwnss/zlss/zlog.h b/src/nwnss/zlss/zlog.h index 0da1de9..8955b26 100644 --- a/src/nwnss/zlss/zlog.h +++ b/src/nwnss/zlss/zlog.h @@ -34,7 +34,7 @@ | This module is used to: | Definitions used by ZLOG. | For detailed information about the ZLOG see the ZLOG Specification. - | + | +-------------------------------------------------------------------------*/ #ifndef _ZLOG_H_ #define _ZLOG_H_ @@ -64,15 +64,15 @@ #endif - /* ZLOG_CHECKSUM_LOG_RECORDS is used if we decide to turn off - * checksumming of each ZLOG log record (the whole buffer is - * checksummed also). If we set ZLOG_CHECKSUM_LOG_RECORDS to - * DISABLE then we can NOT turn it back on as there will be - * ZLOG files without checksum (although I am putting zeros - * in the checksum so we could look at it). At this point in - * time Six-Pack I do not fell we need to checksum each - * log record. - */ + /* ZLOG_CHECKSUM_LOG_RECORDS is used if we decide to turn off + * checksumming of each ZLOG log record (the whole buffer is + * checksummed also). If we set ZLOG_CHECKSUM_LOG_RECORDS to + * DISABLE then we can NOT turn it back on as there will be + * ZLOG files without checksum (although I am putting zeros + * in the checksum so we could look at it). At this point in + * time Six-Pack I do not fell we need to checksum each + * log record. + */ #define ZLOG_CHECKSUM_LOG_RECORDS DISABLE /* DISABLE has not been TESTED */ /* @@ -82,181 +82,181 @@ */ - /* The next three defines are used to specify the ZLOG file size. The - file size is the total file size. Be careful if ZLOG has both original - and duplicate blocks. */ + /* The next three defines are used to specify the ZLOG file size. The + file size is the total file size. Be careful if ZLOG has both original + and duplicate blocks. */ #define ZLOG_FILE_SIZE_FRACTION (50) /* Was 100 in MOAB and COBRA */ - /* ZLOG file size is at least 1/50 (2.0%) of total pool size - * when the pool size <= 3.13GB. Otherwise, the ZLOG file size is - * th greater of 64MB or 12.5/4096 (.296%) of pool size. - * The .296% is a requirement of rebuild (to rebuild the Beast Tree). - * - * Pool sizes when a K is 1024. The table is only valid for - * pools created under 6Pack with the initial sizes given. If space - * is added to a POOL the ZLOG file does NOT grow. - * - * Pool Size Journal Size - * ----------------------------- -------------------- - * Less than 400MB 8MB - * Between 400MB and 3.13GB 2% of Pool Size - * Between 3.13GB and 21.11GB 64MB - * Over 21.1GB .296% of Pool Size - * - */ + /* ZLOG file size is at least 1/50 (2.0%) of total pool size + * when the pool size <= 3.13GB. Otherwise, the ZLOG file size is + * th greater of 64MB or 12.5/4096 (.296%) of pool size. + * The .296% is a requirement of rebuild (to rebuild the Beast Tree). + * + * Pool sizes when a K is 1024. The table is only valid for + * pools created under 6Pack with the initial sizes given. If space + * is added to a POOL the ZLOG file does NOT grow. + * + * Pool Size Journal Size + * ----------------------------- -------------------- + * Less than 400MB 8MB + * Between 400MB and 3.13GB 2% of Pool Size + * Between 3.13GB and 21.11GB 64MB + * Over 21.1GB .296% of Pool Size + * + */ #define ZLOG_REBUILD_BYTES_PER_BLOCK (96+1)/(8) - /* Don't add () because need left to right multiplication - * so not to get massive rounding errors. - * ZLOG file size is 12.5/4096 (.296%) of total pool size. - * 1 bit per block for crossed linked blocks. - * 96 bits (12 bytes) per block for beast tree branch repair. - */ + /* Don't add () because need left to right multiplication + * so not to get massive rounding errors. + * ZLOG file size is 12.5/4096 (.296%) of total pool size. + * 1 bit per block for crossed linked blocks. + * 96 bits (12 bytes) per block for beast tree branch repair. + */ #define ZLOG_REBUILD_FUDGE_BLOCKS 2 /* Number of extra blocks that the - * rebuild needs because it divides - * the file into two sections each - * on 4k boundary. - */ + * rebuild needs because it divides + * the file into two sections each + * on 4k boundary. + */ #define ZLOG_FILE_SIZE_MINIMUM (1024*4096uL) #define ZLOG_FILE_SIZE_MINIMUM_AT_CREATE (2048*4096uL) /* Not in MOAB/COBRA */ - /* Minimum size if 4 Meg because that was the minimum in - * MOAB and COBRA. For Six-Pack the minimum size was - * double to 8 Megs. This was done as 4 Meg is a pretty small - * ZLOG file. Added the define ZLOG_FILE_SIZE_MINIMUM_AT_CREATE - * because we do not grow MOAB/COBRA zlog files so ASSERTS - * and the likes still need the 4 Meg value. - */ + /* Minimum size if 4 Meg because that was the minimum in + * MOAB and COBRA. For Six-Pack the minimum size was + * double to 8 Megs. This was done as 4 Meg is a pretty small + * ZLOG file. Added the define ZLOG_FILE_SIZE_MINIMUM_AT_CREATE + * because we do not grow MOAB/COBRA zlog files so ASSERTS + * and the likes still need the 4 Meg value. + */ #define ZLOG_FILE_SIZE_CROSS_OVER (4*4096*4096uL) /* No 4 in MOAB/COBRA */ - /* The cross over point is where ZLOG is happy with the size - * of the ZLOG file, but if because of the beast tree rebuild - * requirements (.296% of disk space) rebuild needs more space - * then ZLOG is not going to complain if this space is ADDED - * to the ZLOG file. - */ + /* The cross over point is where ZLOG is happy with the size + * of the ZLOG file, but if because of the beast tree rebuild + * requirements (.296% of disk space) rebuild needs more space + * then ZLOG is not going to complain if this space is ADDED + * to the ZLOG file. + */ - /* - * Maximum number of homed transactions (ones with log records) that - * will occur before a checkpoint is taken. - */ + /* + * Maximum number of homed transactions (ones with log records) that + * will occur before a checkpoint is taken. + */ #define ZLOG_CHECKPOINT_HOMED_TRANSACTIONS_MAXIMUM 500 - /* Maximum number of blocks to fill in before a checkpoint is taken */ + /* Maximum number of blocks to fill in before a checkpoint is taken */ #define ZLOG_CHECKPOINT_BLOCK_FILLED_IN_MAXIMUM 500 - /* - * Percent of ZLOG file that must be in use before going into the - * respective throttle. The throttle full percent is used to - * indicate when we should leave throttle back mode and enter throttle - * full. Throttle full means we are NOT delaying anyone. The throttle - * back percent is used to indicate when we should start throttling - * back transactions. This number must be >= the throttle full - * percent. - */ + /* + * Percent of ZLOG file that must be in use before going into the + * respective throttle. The throttle full percent is used to + * indicate when we should leave throttle back mode and enter throttle + * full. Throttle full means we are NOT delaying anyone. The throttle + * back percent is used to indicate when we should start throttling + * back transactions. This number must be >= the throttle full + * percent. + */ #define ZLOG_THROTTLE_BACK_PERCENT 50 /* If the number of in use blocks - * is >= to this percent of total - * zlog blocks then we enter - * throttle back mode and start - * delaying new common layer - * transactions. - */ + * is >= to this percent of total + * zlog blocks then we enter + * throttle back mode and start + * delaying new common layer + * transactions. + */ #define ZLOG_THROTTLE_FULL_PERCENT 50 /* If in use is less than we - * are in throttle full mode. DO - * NOT SET TO 0. Should not be set to - * less than 25 because the number - * of checkpoints writes will start - * slowing down the system. - */ - /* - * Minimum number of checkpoints to take per pass through ZLOG file. - * This number must be high enough that we that we take six checkpoints - * before the throttle full point in the file. Otherwise, we will stay - * in throttle back mode longer than needed. If throttle full is - * 50% then the following define equals 12. - */ + * are in throttle full mode. DO + * NOT SET TO 0. Should not be set to + * less than 25 because the number + * of checkpoints writes will start + * slowing down the system. + */ + /* + * Minimum number of checkpoints to take per pass through ZLOG file. + * This number must be high enough that we that we take six checkpoints + * before the throttle full point in the file. Otherwise, we will stay + * in throttle back mode longer than needed. If throttle full is + * 50% then the following define equals 12. + */ #define ZLOG_CHECKPOINTS_BEFORE_WARP_MINIMUM(_percent) \ - (((6*1000/(_percent))+9)/10) + (((6*1000/(_percent))+9)/10) - /* - * Number of millisecs to delay between each check of if a ZLOG - * scheduled checkpoint has completed, This is only used in shutdown. - */ + /* + * Number of millisecs to delay between each check of if a ZLOG + * scheduled checkpoint has completed, This is only used in shutdown. + */ #define ZLOG_WORK_CHECKPOINT_WAIT_DELAY 20 - /* - * Number of millisecs to delay between each check of if the ZLOG - * buffer flush has completed, This is only used in shutdown. - */ + /* + * Number of millisecs to delay between each check of if the ZLOG + * buffer flush has completed, This is only used in shutdown. + */ #define ZLOG_WORK_FLUSH_WAIT_DELAY 100 - /* - * Set ZLOG_USE_SYSTEMS_WORK_TO_DO to TRUE if async checkpoints - * should directly use ScheduleWork(). Set to FALSE if async - * checkpoints should use WORK_Schedule(). The WORK_Schedule() - * routine limits the number of work-to-do threads that NSS uses. - * - * September 18, 1997 - We are going with ScheduleWork() because - * on MOAB running a lot of PFM tests checkpoints would not be - * scheduled for 10+ minutes. - */ + /* + * Set ZLOG_USE_SYSTEMS_WORK_TO_DO to TRUE if async checkpoints + * should directly use ScheduleWork(). Set to FALSE if async + * checkpoints should use WORK_Schedule(). The WORK_Schedule() + * routine limits the number of work-to-do threads that NSS uses. + * + * September 18, 1997 - We are going with ScheduleWork() because + * on MOAB running a lot of PFM tests checkpoints would not be + * scheduled for 10+ minutes. + */ #define ZLOG_USE_SYSTEMS_WORK_TO_DO TRUE #define ZLOG_HISTOGRAM_EVENT( _histogram, _event ) \ - zlog_HistogramEvent( (_histogram), (_event) ) + zlog_HistogramEvent( (_histogram), (_event) ) typedef struct ZlogHistogramPersistent_s { - QUAD ZHP_CurrentEvent; /* Current event */ - QUAD ZHP_EventCount; /* Total number of events */ + QUAD ZHP_CurrentEvent; /* Current event */ + QUAD ZHP_EventCount; /* Total number of events */ } NSS_MEDIA_STRUCTURE(ZlogHistogramPersistent_s,ZHP_EventCount) ZlogHistogramPersistent_s; typedef struct ZlogHistogram_s { - LONG ZH_BucketCount; /* Number of buckets */ - LONG ZH_BucketSize; /* Number of events a bucket holds */ - LONG ZH_Flags; /* Flags as follows */ + LONG ZH_BucketCount; /* Number of buckets */ + LONG ZH_BucketSize; /* Number of events a bucket holds */ + LONG ZH_Flags; /* Flags as follows */ #define ZH_F_LONG 0x0001 /* Track with LONGs */ #define ZH_F_QUAD 0x0002 /* Track with QUADs */ - ZlogHistogramPersistent_s *ZH_P; - void *ZH_Bucket; /* Pointer to bucket area (buckets are persistent)*/ + ZlogHistogramPersistent_s *ZH_P; + void *ZH_Bucket; /* Pointer to bucket area (buckets are persistent)*/ } ZlogHistogram_s; #define ZLOG_HISTORY_EVENT( _histogram, _event ) \ - zlog_HistoryEvent( (_histogram), (_event) ) + zlog_HistoryEvent( (_histogram), (_event) ) typedef struct ZlogHighWatermarkSlot_s { - Time_t ZHWB_Time; - QUAD ZHWB_Event; + Time_t ZHWB_Time; + QUAD ZHWB_Event; } NSS_MEDIA_STRUCTURE(ZlogHighWatermarkSlot_s,ZHWB_Event) ZlogHighWatermarkSlot_s; typedef struct ZlogHistory_s { - LONG ZH_WatermarkCount; /* # of high watermark slots */ - ZlogHighWatermarkSlot_s *ZH_Slots; + LONG ZH_WatermarkCount; /* # of high watermark slots */ + ZlogHighWatermarkSlot_s *ZH_Slots; } ZlogHistory_s; #define ZLOG_COUNT_INIT( _count, _value ) \ - { \ - (_count)->ZC_Count = _value; \ - (_count)->ZC_CountTime = GetUTCTime(); \ - (_count)->ZC_CountResetTime = (_count)->ZC_CountTime; \ - } + { \ + (_count)->ZC_Count = _value; \ + (_count)->ZC_CountTime = GetUTCTime(); \ + (_count)->ZC_CountResetTime = (_count)->ZC_CountTime; \ + } typedef struct ZlogCounts_s { - QUAD ZC_Count; /* The count */ - Time_t ZC_CountTime; /* When the count was recorded */ - Time_t ZC_CountResetTime; /* When the count was last reset */ + QUAD ZC_Count; /* The count */ + Time_t ZC_CountTime; /* When the count was recorded */ + Time_t ZC_CountResetTime; /* When the count was last reset */ } ZlogCounts_s; /* @@ -275,43 +275,43 @@ typedef struct ZlogCounts_s #if 0 typedef struct ZlogZfsAsyncio_s { #if ZLOG_TEST IS_ENABLED - NINT ZZA_logRecordsLeft; - /* Used by unit test code to randomly generate different - * number of log records within a transactions. - */ - NINT ZZA_bufferLength; - /* Used by unit test code. Amount of data space - * required by caller of ZLOG_ObtainRecord() in BYTEs. - */ + NINT ZZA_logRecordsLeft; + /* Used by unit test code to randomly generate different + * number of log records within a transactions. + */ + NINT ZZA_bufferLength; + /* Used by unit test code. Amount of data space + * required by caller of ZLOG_ObtainRecord() in BYTEs. + */ #else - NINT ZAA_happy; - /* Keep the compiler happy by having a dummy element. */ + NINT ZAA_happy; + /* Keep the compiler happy by having a dummy element. */ #endif } ZlogZfsAsyncio_s; - /* - * Below are the defines to use when referencing ZLOG specific - * ZFS Asynchronous I/O items. They must be combined with - * a pointer to a ZfsAsyncio_s structure. For example. - * - * ZfsAsyncio_s *zio; - * Lsn_t myLsn; - * - * zio->ZLOG_ZaTransactionState = XAS_XR_TS_START; - * myLsn = zio->ZLOG_ZaLsn; - * - */ + /* + * Below are the defines to use when referencing ZLOG specific + * ZFS Asynchronous I/O items. They must be combined with + * a pointer to a ZfsAsyncio_s structure. For example. + * + * ZfsAsyncio_s *zio; + * Lsn_t myLsn; + * + * zio->ZLOG_ZaTransactionState = XAS_XR_TS_START; + * myLsn = zio->ZLOG_ZaLsn; + * + */ - /* - * Internal direct references - these are undocumented elements that - * reside within ZlogZfsAsyncio_s. - */ + /* + * Internal direct references - these are undocumented elements that + * reside within ZlogZfsAsyncio_s. + */ #define ZLOG_zaBuffer zza.ZZA_buffer - /* Public direct references - the are documented elements that - * reside within ZlogZfsAsyncio_s. - */ + /* Public direct references - the are documented elements that + * reside within ZlogZfsAsyncio_s. + */ #define ZLOG_ZaBufferLength zza.ZZA_bufferLength //#define ZLOG_ZaZfsXasRecovery zza.ZZA_zfsXasRecovery @@ -319,40 +319,40 @@ typedef struct ZlogZfsAsyncio_s { #define ZLOG_ZaTransactionState xaction->xstate #define ZLOG_ZaHomeBond zza.ZZA_homeBond - /* Public indirect references - these are documented elements that - * do not reside within ZlogZfsAsyncio_s. - */ + /* Public indirect references - these are documented elements that + * do not reside within ZlogZfsAsyncio_s. + */ #define ZLOG_ZaCommitAgent ZLOG_zaBuffer->agent - /* Output. ZLOG's Commit Agent used by callers to bind - * with ZLOG. ZLOG will use to signal that the log - * block has been flushed. Commit agent used to bind the log - * block to a transaction so that the transaction can be - * signaled when the log block has been flushed. This - * indicates to the transaction that it has been committed. - * Note that technically, ZLOG does not care what it's commit - * agent is bond to. A signal will be sent to whoever is - * bond to the log block when the block is written - * (committed). The PLB_CommitAgent is actually stored - * in the agent that is in the Buffer_s structure. - */ + /* Output. ZLOG's Commit Agent used by callers to bind + * with ZLOG. ZLOG will use to signal that the log + * block has been flushed. Commit agent used to bind the log + * block to a transaction so that the transaction can be + * signaled when the log block has been flushed. This + * indicates to the transaction that it has been committed. + * Note that technically, ZLOG does not care what it's commit + * agent is bond to. A signal will be sent to whoever is + * bond to the log block when the block is written + * (committed). The PLB_CommitAgent is actually stored + * in the agent that is in the Buffer_s structure. + */ #define ZLOG_ZaLsn ZLB_ZfsXasRecovery->ZXR_Lsn - /* Output. LSN of log record. This points into the - * log record header location that stores the LSN. The - * define will unpack the value if it is required. - */ + /* Output. LSN of log record. This points into the + * log record header location that stores the LSN. The + * define will unpack the value if it is required. + */ - /* Internal direct references - these are undocumented elements that - * reside within ZlogZfsAsyncio_s. - */ + /* Internal direct references - these are undocumented elements that + * reside within ZlogZfsAsyncio_s. + */ #define ZLOG_zaTransactionId io.xaction->localXid - /* Transaction ID of data owner. The transaction - * ID is obtained from the Transaction System. This is in the - * XAS structure. ZLOG uses to fill in the log record header. - */ + /* Transaction ID of data owner. The transaction + * ID is obtained from the Transaction System. This is in the + * XAS structure. ZLOG uses to fill in the log record header. + */ #define ZLOG_zaLogRecordsLeft zza.ZZA_logRecordsLeft - /* Unit test code uses. */ + /* Unit test code uses. */ #endif /* #if 0 */ /* @@ -367,78 +367,78 @@ typedef struct ZLOGBlockHeader_s { // // ZLBH_VolumeID at OFFSET 16 must stay there!!! // - LONG ZLBH_Signature; - /* Signature that identifies this as a pool log file - * header of a pool log block. Can be used by zrepair - * and debug/ASSERT. The signature is 'ZLBH'. - */ - LONG ZLBH_Checksum; - /* Checksum for the pool log block header and - * all of the log records. Does not include unused longs - * at the end of the log block. - */ - Time_t ZLBH_TimeStart; - /* When block started to be used. Right after - * we obtain the buffer. - */ - Time_t ZLBH_TimeEnd; - /* Right before checksum calculated. Which occurs - * right before we tell system to write the log - * block. Note that we do not know when the actual - * write occurs. - */ - GUID_t ZLBH_InternalID; - /* MUST BE AT OFFSET 16 - Internal ID of the volume - * that 'owns' this metadata. Because ZLOG is only - * in a POOL this is the Internal ID of the ZfsPool_s - * beast. - */ - WORD ZLBH_NumberOfUnusedLongs; - /* Number of LONGs left at end of block. Used while - * in memory to see if have room for a new log record. - * Placed on disk for debugging. - */ - WORD ZLBH_NumberOfRecords; - /* Number of log records in the block. */ - WORD ZLBH_Status; - /* Why block was written. - * ZLBH_S_TOOBIG - Next record too big. - * ZLBH_S_TIMEOUT - Time-out occurred. - * ZLBH_S_SHUTDOWN - Shutdown wrote. - * ZLBH_S_CHECKPOINT - Checkpoint wrote. - * ZLBH_S_INSTALL - Install created. - * Are Log Record time values meaningful? - * ZLBH_S_DEBUG - Yes. - */ - WORD ZLBH_Reserved; - /* Used to make sizeof our structure a QUAD value */ - LONG ZLBH_RebuildCount; - /* Pool's rebuilt count when the block was written. - * This is used to determine if a ZLOG block is old. - * This was added, Feb 1998, so that ReBuild does not - * have to initialize all the ZLOG blocks. Note this - * became an issue because ZLOG no longer needs to - * initialize blocks because the GUID is unigue. In - * addition when we added the ReBuild beast tree .296% - * of pool needs to be reserved to the ZLOG we really - * did not want to spend time initializing the ZLOG - * when a pool was created. - */ - LONG ZLBH_FileBlockNumber; - /* Debug - File block number (low LONG portion) */ - /* Keep us on a QUAD alignment */ + LONG ZLBH_Signature; + /* Signature that identifies this as a pool log file + * header of a pool log block. Can be used by zrepair + * and debug/ASSERT. The signature is 'ZLBH'. + */ + LONG ZLBH_Checksum; + /* Checksum for the pool log block header and + * all of the log records. Does not include unused longs + * at the end of the log block. + */ + Time_t ZLBH_TimeStart; + /* When block started to be used. Right after + * we obtain the buffer. + */ + Time_t ZLBH_TimeEnd; + /* Right before checksum calculated. Which occurs + * right before we tell system to write the log + * block. Note that we do not know when the actual + * write occurs. + */ + GUID_t ZLBH_InternalID; + /* MUST BE AT OFFSET 16 - Internal ID of the volume + * that 'owns' this metadata. Because ZLOG is only + * in a POOL this is the Internal ID of the ZfsPool_s + * beast. + */ + WORD ZLBH_NumberOfUnusedLongs; + /* Number of LONGs left at end of block. Used while + * in memory to see if have room for a new log record. + * Placed on disk for debugging. + */ + WORD ZLBH_NumberOfRecords; + /* Number of log records in the block. */ + WORD ZLBH_Status; + /* Why block was written. + * ZLBH_S_TOOBIG - Next record too big. + * ZLBH_S_TIMEOUT - Time-out occurred. + * ZLBH_S_SHUTDOWN - Shutdown wrote. + * ZLBH_S_CHECKPOINT - Checkpoint wrote. + * ZLBH_S_INSTALL - Install created. + * Are Log Record time values meaningful? + * ZLBH_S_DEBUG - Yes. + */ + WORD ZLBH_Reserved; + /* Used to make sizeof our structure a QUAD value */ + LONG ZLBH_RebuildCount; + /* Pool's rebuilt count when the block was written. + * This is used to determine if a ZLOG block is old. + * This was added, Feb 1998, so that ReBuild does not + * have to initialize all the ZLOG blocks. Note this + * became an issue because ZLOG no longer needs to + * initialize blocks because the GUID is unigue. In + * addition when we added the ReBuild beast tree .296% + * of pool needs to be reserved to the ZLOG we really + * did not want to spend time initializing the ZLOG + * when a pool was created. + */ + LONG ZLBH_FileBlockNumber; + /* Debug - File block number (low LONG portion) */ + /* Keep us on a QUAD alignment */ } NSS_MEDIA_STRUCTURE(ZLOGBlockHeader_s,ZLBH_FileBlockNumber) ZLOGBlockHeader_s; /* Defines used in Pool Log Block Header elements. */ - /* ZLBH_Signature value */ + /* ZLBH_Signature value */ #define ZLBH_S_SIGNATURE (0x48424c5AuL) /* 'ZLBH' on Little Endian */ - /* ZLBH_Status values */ + /* ZLBH_Status values */ - /* The first five defines are mutually exclusive and indicate - * why a log block was written (what code wrote). - */ + /* The first five defines are mutually exclusive and indicate + * why a log block was written (what code wrote). + */ #define ZLBH_S_TOOBIG 0x0001 /* Debug */ //#define ZLBH_S_TIMEOUT 0x0002 /* Debug */ //#define ZLBH_S_SHUTDOWN 0x0004 /* Debug */ @@ -446,22 +446,22 @@ typedef struct ZLOGBlockHeader_s { #define ZLBH_S_INSTALL 0x0010 /* Required. */ #define ZLBH_S_TIME_OR_BOND 0x0020 /* Debug */ #define ZLBH_S_CHECKSUM 0x0040 /* Required - checksum not calculated. - * FixFixFix6(Future,If reading ZLOG file - * supported) - This bit is not - * implemented or in spec at this time. It - * would be needed so that reader knows - * that the log buffer's checksum has - * not been calculated because we are - * not done filling it in. OR we could - * cause it to be flushed and checksummed - * when user wishes to read it. - */ + * FixFixFix6(Future,If reading ZLOG file + * supported) - This bit is not + * implemented or in spec at this time. It + * would be needed so that reader knows + * that the log buffer's checksum has + * not been calculated because we are + * not done filling it in. OR we could + * cause it to be flushed and checksummed + * when user wishes to read it. + */ #if ZLOG_DEBUG IS_ENABLED #define ZLBH_S_DEBUG 0x0100 /* Required. Debug fields of block and - * log headers are valid. Do not change - * this bit mask dumpzlog uses hard - * coded 0x0100. - */ + * log headers are valid. Do not change + * this bit mask dumpzlog uses hard + * coded 0x0100. + */ #else #define ZLBH_S_DEBUG 0x0000 #endif @@ -486,34 +486,34 @@ typedef struct ZLOGBlockHeader_s { */ typedef struct ZfsXasRecovery_s { - Lsn_t ZXR_Lsn; - /* - * Log Sequence Number. This number does not ever - * wrap (it does but it takes ~586 years when incremented - * once every nanosecond). The LSN needs to be this - * big for users of ZLOG and not ZLOG itself. The users - * of ZLOG will be storing LSN into metadata blocks to - * make these blocks idempotent. So even if the LSN is not - * currently in the log file we must ensure that we do - * not reuse a LSN. - */ - LocalXid_t ZXR_LocalXid; /* Transaction ID. */ - LONG ZXR_FunctionIndex; /* Function index */ - WORD ZXR_TransactionState; - /* - * State of transaction. - * XAS_XR_TS_START - * XAS_XR_TS_MIDDLE - * XAS_XR_TS_END - */ - WORD ZXR_PoolBlockCount; + Lsn_t ZXR_Lsn; + /* + * Log Sequence Number. This number does not ever + * wrap (it does but it takes ~586 years when incremented + * once every nanosecond). The LSN needs to be this + * big for users of ZLOG and not ZLOG itself. The users + * of ZLOG will be storing LSN into metadata blocks to + * make these blocks idempotent. So even if the LSN is not + * currently in the log file we must ensure that we do + * not reuse a LSN. + */ + LocalXid_t ZXR_LocalXid; /* Transaction ID. */ + LONG ZXR_FunctionIndex; /* Function index */ + WORD ZXR_TransactionState; + /* + * State of transaction. + * XAS_XR_TS_START + * XAS_XR_TS_MIDDLE + * XAS_XR_TS_END + */ + WORD ZXR_PoolBlockCount; // BYTE ZXR_Padding[0]; - /* - * Because the next item may have 0 items we do not actually include - * in our definition. In addition, the user must ask ZLOG_ObtainRecord - * for the space in the log file to handle the number of BlockInfo_s that - * they need. - */ + /* + * Because the next item may have 0 items we do not actually include + * in our definition. In addition, the user must ask ZLOG_ObtainRecord + * for the space in the log file to handle the number of BlockInfo_s that + * they need. + */ // BlockInfo_s ZXR_BlockInfo[ZXR_PoolBlockCount] } NSS_MEDIA_STRUCTURE(ZfsXasRecovery_s,ZXR_PoolBlockCount) ZfsXasRecovery_s; @@ -531,76 +531,76 @@ typedef struct ZfsXasRecovery_s { typedef struct ZLOGRecordHeader_s { - /**** The following items are ZLOG specific. Only ZLOG - * can access. - */ + /**** The following items are ZLOG specific. Only ZLOG + * can access. + */ - LONG ZLRH_Checksum; - /* Calculated after ZLOG caller has filled in data - * portion of log record. Checksum is for log header - * and data portion. Checksum is valid if the block - * contents (including this field) add up to zero. Use - * zlog_CalculateChecksum() to perform checksumming. - */ - LONG ZLRH_StartTime; - /* Debug. When ZLOG_ObtainRecord() was called. This - * time is in 100s of microseconds. Is not relative - * to anything. - */ - LONG ZLRH_EndTime; - /* Debug. When ZLOG_RecordFilledIn() was called. Used - * with StartTime to verify callers of ZLOG are not - * holding records too long. We have specified a 1/2 - * second maximum hold time. - */ - WORD ZLRH_LongLength; - /* Number of packed LONGs in this record. This - * length includes the log record header LONG length. - */ - BYTE ZLRH_Reserved1[2]; /* Get structure aligned again */ + LONG ZLRH_Checksum; + /* Calculated after ZLOG caller has filled in data + * portion of log record. Checksum is for log header + * and data portion. Checksum is valid if the block + * contents (including this field) add up to zero. Use + * zlog_CalculateChecksum() to perform checksumming. + */ + LONG ZLRH_StartTime; + /* Debug. When ZLOG_ObtainRecord() was called. This + * time is in 100s of microseconds. Is not relative + * to anything. + */ + LONG ZLRH_EndTime; + /* Debug. When ZLOG_RecordFilledIn() was called. Used + * with StartTime to verify callers of ZLOG are not + * holding records too long. We have specified a 1/2 + * second maximum hold time. + */ + WORD ZLRH_LongLength; + /* Number of packed LONGs in this record. This + * length includes the log record header LONG length. + */ + BYTE ZLRH_Reserved1[2]; /* Get structure aligned again */ - /**** The following items are ZFS/XAS specific. They are - * given to XAS at recovery time (XAS will give - * to ZFS). ZLOG assumes that it does not have - * to pack/unpack these items. A pointer to - * this is also return from ZLOG_ObtainRecord() so - * that the caller can access needed information. - ****/ + /**** The following items are ZFS/XAS specific. They are + * given to XAS at recovery time (XAS will give + * to ZFS). ZLOG assumes that it does not have + * to pack/unpack these items. A pointer to + * this is also return from ZLOG_ObtainRecord() so + * that the caller can access needed information. + ****/ - ZfsXasRecovery_s ZLRH_Zxr; - /* ZFS and ZAS specific items. ZLOG has no real - * interest in these items, but it is required to - * fill them in when logging and return them on recovery. - * It is documented that the user data portion of the - * log record start immediatily after this element. - */ - /*** Do not add items here. Read above comment ***/ + ZfsXasRecovery_s ZLRH_Zxr; + /* ZFS and ZAS specific items. ZLOG has no real + * interest in these items, but it is required to + * fill them in when logging and return them on recovery. + * It is documented that the user data portion of the + * log record start immediatily after this element. + */ + /*** Do not add items here. Read above comment ***/ } NSS_MEDIA_STRUCTURE(ZLOGRecordHeader_s,ZLRH_Zxr) ZLOGRecordHeader_s; typedef struct LogTest_s { - Buffer_s *LT_Buffer; - void *LT_Copy; + Buffer_s *LT_Buffer; + void *LT_Copy; } LogTest_s; - /* The 128 is for future growth in the headers. By - * substracting off 128 the define size will not change though - * numerous ZFS releases. This should make life easier on us. - * Currently, we need 72 bytes for our two required headers. This - * gives us 56 bytes of growth. Our constructor has ASSERT code - * to note when actual required size is smaller than published - * required size. - */ + /* The 128 is for future growth in the headers. By + * substracting off 128 the define size will not change though + * numerous ZFS releases. This should make life easier on us. + * Currently, we need 72 bytes for our two required headers. This + * gives us 56 bytes of growth. Our constructor has ASSERT code + * to note when actual required size is smaller than published + * required size. + */ - /* Documented in ZLOG specification. */ + /* Documented in ZLOG specification. */ #define ZLOG_MAXIMUM_RECORD_SIZE (4096 - 128) - /* Internal actual record size. */ + /* Internal actual record size. */ #define zlog_MAXIMUM_RECORD_SIZE ( 4096 - sizeof(ZLOGBlockHeader_s) - \ - sizeof(ZLOGRecordHeader_s) ) + sizeof(ZLOGRecordHeader_s) ) /*=========================================================================== *=========================================================================== @@ -610,456 +610,456 @@ typedef struct LogTest_s { *=========================================================================== *===========================================================================*/ - /* These are all of ZLOG specific persistent items within a ZLOG Beast. - * The items should be fixed size (e.g. don't declare as a int), but they - * can be stored in native format. - */ + /* These are all of ZLOG specific persistent items within a ZLOG Beast. + * The items should be fixed size (e.g. don't declare as a int), but they + * can be stored in native format. + */ - /* This structure helps in determining the length of persistent - * data in our beast. It also makes the coder aware of exactly - * what items are persistent and which are not. - */ + /* This structure helps in determining the length of persistent + * data in our beast. It also makes the coder aware of exactly + * what items are persistent and which are not. + */ - /* Warning - This is a persistent data structure. If you change it - * in a way that makes it incompatible with older systems you must - * update the media version in the superblock OR the major version number - * of the checkpoint. You should also update the major version number - * of the ZLOG Beast below. - */ + /* Warning - This is a persistent data structure. If you change it + * in a way that makes it incompatible with older systems you must + * update the media version in the superblock OR the major version number + * of the checkpoint. You should also update the major version number + * of the ZLOG Beast below. + */ typedef struct ZlogBeastPersistent_s { - LONG ZLBP_Signature2; - /* Signature that identifies this is a log file header - * of a pool log block. Can be used by zrepair and - * debug/ASSERT. The signature is 'ZLOG' on Little - * Endian CPUs. - */ - WORD ZLBP_VersionMajor; - /* The major version of the pool log file. Changes when - * ZLOG is no longer compatible with an older version - * of the pool log file. The first release will have this - * set to 1. When changing see if ZLBP_Reserved should - * be changed. - */ - WORD ZLBP_VersionMinor; - /* The minor version of the pool log file. Changes when - * old ZFS are still compatible. This will be 0 in the - * first release. - */ - LONG ZLBP_ZSTOREMajorVersion; - LONG ZLBP_ZSTOREMinorVersion; - LONG ZLBP_ZSTORESubVersion; - LONG ZLBP_ZSTOREBuildNumber; - /* The above four items hold values of the current running - * ZSTORE system. By storing them in the ZLOG they will be - * made persistent in the checkpoint. Currently, only used - * by Novell internal ZAD (ZLOG Analysis Dumper) utility. - */ - Lsn_t ZLBP_ActivePointerLsn; - /* Can never be zero or wrap. During Logging this - * LSN is the next LSN to assign to a log record. - * - * During - * Recovery this value is used to verify if log records - * where written after a checkpoint was taken. Recovery - * figures out the current value of this LSN by scanning - * the log and adding a fudge factor. See ZLOG - * specification for more information. - */ - Lsn_t ZLBP_HomePointerLsn; - /* Current home pointer LSN. Indicates what LSNs - * have made it to home. LSN numbers LESS THAN this value - * have had their transactions homed. This value is used - * to quickly see - * if recovery is needed. When ZLBP_ActivePointerLSN - * equals ZLBP_HomePointerLSN we took a clean checkpoint. - * Note - taking a clean checkpoint does not mean that there - * is no recovery to be done. ZLBP_HomePointerLSN is - * compared with the LSN of the first record of the - * ZLBP_HomePointerBlockNumber to see if recovery is - * needed. If we did not store this value we would have - * to read the block before ZLBP_HomePointerBlockNumber - * so we could retrieve the highest LSN in that block. We - * would then add one to that value to get - * ZLBP_HomePointerLsn. We do not do this because of - * performance and code simplification reasons. - */ - Lsn_t ZLBP_OldHomePointerLsn[CHECKPOINT_NUMBER]; - Blknum_t ZLBP_FileThrottleFull; /* Use NSS_LOCK to protect */ - /* Number of in use blocks that we switch from - * ZLOG_THROTTLE_BACK into ZLOG_THROTTLE_FULL mode. This - * number is set using ZLBP_FileThrottleFullPercent. In - * persistent area for debug only. - */ - Blknum_t ZLBP_FileThrottleBack; /* Use NSS_LOCK to protect */ - /* Number of in use blocks that we switch from - * ZLOG_THROTTLE_FULL into ZLOG_THROTTLE_BACK mode. this - * number is set by ZLBP_FileThrottleBackPercent. - */ - QUAD ZLBP_FileThrottleWaitCount; /* Use NSS_LOCK to protect */ - /* Accounting. Number of times we delayed a BeginXLocal - * when in ZLOG_THROTTLE_BACK mode. - */ - QUAD ZLBP_FileThrottleWait1Count; /* Use NSS_LOCK to protect */ - QUAD ZLBP_FileThrottleWait2Count; /* Use NSS_LOCK to protect */ - QUAD ZLBP_FileThrottleWait3Count; /* Use NSS_LOCK to protect */ - QUAD ZLBP_FileThrottleWait4Count; /* Use NSS_LOCK to protect */ - QUAD ZLBP_FileThrottleWait5Count; /* Use NSS_LOCK to protect */ - /* Accounting. Number of times we delayed a BeginXLocal - * by a specific amount when in ZLOG_THROTTLE_BACK mode. - */ - QUAD ZLBP_FileThrottleFullCount; /* Use NSS_LOCK to protect */ - /* Accounting. Number of times we left ZLOG_THROTTLE_BACK - * mode and went back to ZLOG_THROTTLE_FULL. Should be - * equal to ZLB_FileThrottleBackCount when mode is - * ZLOG_THROTTLE_FULL. Otherwise, should be one less than - * ZLB_FileThrottleBackCount. - */ - QUAD ZLBP_FileThrottleCheckpointCount; /* Use NSS_LOCK to protect */ - /* Accounting. Number of checkpoints taken while - * in ZLOG_THROTTLE_BACK mode. - */ - QUAD ZLBP_FileThrottleSkipCount; /* Use NSS_LOCK to protect */ - /* Accounting(debug systems only). Number of times we let - * an obtain pass through when in ZLOG_THROTTLE_BACK mode. - */ - QUAD ZLBP_FileThrottleBackCount; /* Use NSS_LOCK to protect */ - /* Accounting. Number of times that we had to throttle - * back. Note that one throttle back can cause many - * obtains to have to 'wait'. - */ - Time_t ZLBP_FileThrottleTimeStart; /* Use NSS_LOCK to protect */ - /* UTC time of last time ZLOG went into throttle - * back mode. If we have never been in throttle back - * mode then this time is 0. - */ - Time_t ZLBP_FileThrottleTimeEnd; /* Use NSS_LOCK to protect */ - /* UTC time of last time ZLOG went into throttle - * full mode from throttle back mode. Note if we never - * have been in throotle back mode then this time is 0. - */ - Blknum_t ZLBP_OldHomePointerBlockNumber[CHECKPOINT_NUMBER]; - Blknum_t ZLBP_ActivePointerBlockNumber; - /* Logical number of current buffer/block. This is - * always the original block number which is even all of - * the time. The first logical block number of the pool - * log file is 0. This is the lowest block number - * that we have not tried to write. - * - * During Recovery this - * value is used to start the scan for the current - * active pointer. Recovery sets this value before it - * completes to the current active pointer. - */ - Blknum_t ZLBP_HomePointerBlockNumber; - /* Current home pointer block number. Indicates what - * has made it to home. Block numbers LESS THAN this value - * have had all of their transactions homed. - * - * During Recovery this - * value is used to start the scan for the current - * active pointer. Recovery sets this value before it - * completes to the current active pointer. - */ - Blknum_t ZLBP_PreOldestHomePointerBlockNumber; - /* This will be one before the oldest home pointer. This - * solves the headache of detecting empty verses full. I.E. - * the only time oldest home and active pointer are - * the same is when the file is one block from being - * full (we will say the file is full at this point). - * The pre block to block 0 is NOT -1 it is the last - * original block in the file! - */ - Time_t ZLBP_TimeActivation; - /* UTC of last activation of the pool */ - Time_t ZLBP_TimeDeactivation; - /* UTC of last deactivation of the pool */ - Time_t ZLBP_TimePoolCreate; - /* UTC of when the pool was created */ - LONG ZLBP_RecoveryRecoverCount; - /* Number of times recovery performed. */ - LONG ZLBP_RecoveryActivationCount; - /* Number of times we checked if recovery needed. */ + LONG ZLBP_Signature2; + /* Signature that identifies this is a log file header + * of a pool log block. Can be used by zrepair and + * debug/ASSERT. The signature is 'ZLOG' on Little + * Endian CPUs. + */ + WORD ZLBP_VersionMajor; + /* The major version of the pool log file. Changes when + * ZLOG is no longer compatible with an older version + * of the pool log file. The first release will have this + * set to 1. When changing see if ZLBP_Reserved should + * be changed. + */ + WORD ZLBP_VersionMinor; + /* The minor version of the pool log file. Changes when + * old ZFS are still compatible. This will be 0 in the + * first release. + */ + LONG ZLBP_ZSTOREMajorVersion; + LONG ZLBP_ZSTOREMinorVersion; + LONG ZLBP_ZSTORESubVersion; + LONG ZLBP_ZSTOREBuildNumber; + /* The above four items hold values of the current running + * ZSTORE system. By storing them in the ZLOG they will be + * made persistent in the checkpoint. Currently, only used + * by Novell internal ZAD (ZLOG Analysis Dumper) utility. + */ + Lsn_t ZLBP_ActivePointerLsn; + /* Can never be zero or wrap. During Logging this + * LSN is the next LSN to assign to a log record. + * + * During + * Recovery this value is used to verify if log records + * where written after a checkpoint was taken. Recovery + * figures out the current value of this LSN by scanning + * the log and adding a fudge factor. See ZLOG + * specification for more information. + */ + Lsn_t ZLBP_HomePointerLsn; + /* Current home pointer LSN. Indicates what LSNs + * have made it to home. LSN numbers LESS THAN this value + * have had their transactions homed. This value is used + * to quickly see + * if recovery is needed. When ZLBP_ActivePointerLSN + * equals ZLBP_HomePointerLSN we took a clean checkpoint. + * Note - taking a clean checkpoint does not mean that there + * is no recovery to be done. ZLBP_HomePointerLSN is + * compared with the LSN of the first record of the + * ZLBP_HomePointerBlockNumber to see if recovery is + * needed. If we did not store this value we would have + * to read the block before ZLBP_HomePointerBlockNumber + * so we could retrieve the highest LSN in that block. We + * would then add one to that value to get + * ZLBP_HomePointerLsn. We do not do this because of + * performance and code simplification reasons. + */ + Lsn_t ZLBP_OldHomePointerLsn[CHECKPOINT_NUMBER]; + Blknum_t ZLBP_FileThrottleFull; /* Use NSS_LOCK to protect */ + /* Number of in use blocks that we switch from + * ZLOG_THROTTLE_BACK into ZLOG_THROTTLE_FULL mode. This + * number is set using ZLBP_FileThrottleFullPercent. In + * persistent area for debug only. + */ + Blknum_t ZLBP_FileThrottleBack; /* Use NSS_LOCK to protect */ + /* Number of in use blocks that we switch from + * ZLOG_THROTTLE_FULL into ZLOG_THROTTLE_BACK mode. this + * number is set by ZLBP_FileThrottleBackPercent. + */ + QUAD ZLBP_FileThrottleWaitCount; /* Use NSS_LOCK to protect */ + /* Accounting. Number of times we delayed a BeginXLocal + * when in ZLOG_THROTTLE_BACK mode. + */ + QUAD ZLBP_FileThrottleWait1Count; /* Use NSS_LOCK to protect */ + QUAD ZLBP_FileThrottleWait2Count; /* Use NSS_LOCK to protect */ + QUAD ZLBP_FileThrottleWait3Count; /* Use NSS_LOCK to protect */ + QUAD ZLBP_FileThrottleWait4Count; /* Use NSS_LOCK to protect */ + QUAD ZLBP_FileThrottleWait5Count; /* Use NSS_LOCK to protect */ + /* Accounting. Number of times we delayed a BeginXLocal + * by a specific amount when in ZLOG_THROTTLE_BACK mode. + */ + QUAD ZLBP_FileThrottleFullCount; /* Use NSS_LOCK to protect */ + /* Accounting. Number of times we left ZLOG_THROTTLE_BACK + * mode and went back to ZLOG_THROTTLE_FULL. Should be + * equal to ZLB_FileThrottleBackCount when mode is + * ZLOG_THROTTLE_FULL. Otherwise, should be one less than + * ZLB_FileThrottleBackCount. + */ + QUAD ZLBP_FileThrottleCheckpointCount; /* Use NSS_LOCK to protect */ + /* Accounting. Number of checkpoints taken while + * in ZLOG_THROTTLE_BACK mode. + */ + QUAD ZLBP_FileThrottleSkipCount; /* Use NSS_LOCK to protect */ + /* Accounting(debug systems only). Number of times we let + * an obtain pass through when in ZLOG_THROTTLE_BACK mode. + */ + QUAD ZLBP_FileThrottleBackCount; /* Use NSS_LOCK to protect */ + /* Accounting. Number of times that we had to throttle + * back. Note that one throttle back can cause many + * obtains to have to 'wait'. + */ + Time_t ZLBP_FileThrottleTimeStart; /* Use NSS_LOCK to protect */ + /* UTC time of last time ZLOG went into throttle + * back mode. If we have never been in throttle back + * mode then this time is 0. + */ + Time_t ZLBP_FileThrottleTimeEnd; /* Use NSS_LOCK to protect */ + /* UTC time of last time ZLOG went into throttle + * full mode from throttle back mode. Note if we never + * have been in throotle back mode then this time is 0. + */ + Blknum_t ZLBP_OldHomePointerBlockNumber[CHECKPOINT_NUMBER]; + Blknum_t ZLBP_ActivePointerBlockNumber; + /* Logical number of current buffer/block. This is + * always the original block number which is even all of + * the time. The first logical block number of the pool + * log file is 0. This is the lowest block number + * that we have not tried to write. + * + * During Recovery this + * value is used to start the scan for the current + * active pointer. Recovery sets this value before it + * completes to the current active pointer. + */ + Blknum_t ZLBP_HomePointerBlockNumber; + /* Current home pointer block number. Indicates what + * has made it to home. Block numbers LESS THAN this value + * have had all of their transactions homed. + * + * During Recovery this + * value is used to start the scan for the current + * active pointer. Recovery sets this value before it + * completes to the current active pointer. + */ + Blknum_t ZLBP_PreOldestHomePointerBlockNumber; + /* This will be one before the oldest home pointer. This + * solves the headache of detecting empty verses full. I.E. + * the only time oldest home and active pointer are + * the same is when the file is one block from being + * full (we will say the file is full at this point). + * The pre block to block 0 is NOT -1 it is the last + * original block in the file! + */ + Time_t ZLBP_TimeActivation; + /* UTC of last activation of the pool */ + Time_t ZLBP_TimeDeactivation; + /* UTC of last deactivation of the pool */ + Time_t ZLBP_TimePoolCreate; + /* UTC of when the pool was created */ + LONG ZLBP_RecoveryRecoverCount; + /* Number of times recovery performed. */ + LONG ZLBP_RecoveryActivationCount; + /* Number of times we checked if recovery needed. */ #if 0 - LONG ZLBP_LastRecoveryStatus; - /* Error code from last recovery. This is always zOK - * because on activation errors we do not write the - * checkpoints(i.e. ZLOG beast) - */ + LONG ZLBP_LastRecoveryStatus; + /* Error code from last recovery. This is always zOK + * because on activation errors we do not write the + * checkpoints(i.e. ZLOG beast) + */ #endif - Time_t ZLBP_LastRecoveryTimeStart; /* Date/Time that last recovery - * started. - */ - Time_t ZLBP_LastRecoveryTimeEnd; /* Date/Time that last recovery - * ended. - */ - LONG ZLBP_LastRecoveryActivationCount; - /* The ActivationCount value when - * recovery was performed. - */ - WORD ZLBP_Mode; - /* Current mode. This is a persistent item currently - * so ZAD can view. BEWARE that our unpack routine - * sets the persistent copy of this item to - * ZLOG_MODE_DEFAULT! This is important for the - * THROTTLE specific item, but may be wrong for other - * items added in the future. - * - * THROTTLE specific - * BACK means that the ZLOG file is getting too full - * so we are backing off on the number of - * transactions that are being allowed to - * obtain log records. The design here is to - * let transactions that are already started - * to home. New transaction will be delayed. - */ + Time_t ZLBP_LastRecoveryTimeStart; /* Date/Time that last recovery + * started. + */ + Time_t ZLBP_LastRecoveryTimeEnd; /* Date/Time that last recovery + * ended. + */ + LONG ZLBP_LastRecoveryActivationCount; + /* The ActivationCount value when + * recovery was performed. + */ + WORD ZLBP_Mode; + /* Current mode. This is a persistent item currently + * so ZAD can view. BEWARE that our unpack routine + * sets the persistent copy of this item to + * ZLOG_MODE_DEFAULT! This is important for the + * THROTTLE specific item, but may be wrong for other + * items added in the future. + * + * THROTTLE specific + * BACK means that the ZLOG file is getting too full + * so we are backing off on the number of + * transactions that are being allowed to + * obtain log records. The design here is to + * let transactions that are already started + * to home. New transaction will be delayed. + */ #define ZLOG_MODE_DEFAULT 0 /* Default for when pool is initialize - * and when unpacked! - */ + * and when unpacked! + */ #define ZLOG_THROTTLE_BACK 1 /* Let current transactions home */ - WORD ZLBP_FileVersion; - /* Used to see if the ZLOG File format has changed - * (I.E. ZLOG's block header, record header, the - * block info or any beast specific information). If the - * format has changed and we need to do a recovery then - * ZLOG will fail the recovery. The user can then run an - * old nss.nlm to get a clean shutdown and then re-run - * the new nss.nlm. By having this file version the - * user can do the above verses being forced to do a - * /reset to the pool. - * Note this variable only works on the ZLOG file - * and NOT the ZLOG Beast. If the beast changes - * then the checkpoint changes and we still must - * force the user to do a /reset. Note we could modify - * the checkpoint code to allow for in place checkpoint - * update. An error will occur when this number does not - * match ZLOG_ZLBP_FV_VERSION during recovery. - */ - BYTE ZLBP_FileThrottleFullPercent; - /* Percent that the file must be at to exit BACK mode - * and to enter FULL mode. In persistent area so - * utilities can set. Does not address setting while - * pool is up. - */ - BYTE ZLBP_FileThrottleBackPercent; - /* Percent that the file must be at to exit FULL mode - * and to enter BACK mode. In persistent area so - * utilities can set. Does not address setting while - * pool is up. - */ - BYTE ZLBP_Padding[6]; - /* Our persistent items are required to be on a QUAD - * boundary so add some padding. Our constructor has - * ASSERT code to verify that this is correct. - */ + WORD ZLBP_FileVersion; + /* Used to see if the ZLOG File format has changed + * (I.E. ZLOG's block header, record header, the + * block info or any beast specific information). If the + * format has changed and we need to do a recovery then + * ZLOG will fail the recovery. The user can then run an + * old nss.nlm to get a clean shutdown and then re-run + * the new nss.nlm. By having this file version the + * user can do the above verses being forced to do a + * /reset to the pool. + * Note this variable only works on the ZLOG file + * and NOT the ZLOG Beast. If the beast changes + * then the checkpoint changes and we still must + * force the user to do a /reset. Note we could modify + * the checkpoint code to allow for in place checkpoint + * update. An error will occur when this number does not + * match ZLOG_ZLBP_FV_VERSION during recovery. + */ + BYTE ZLBP_FileThrottleFullPercent; + /* Percent that the file must be at to exit BACK mode + * and to enter FULL mode. In persistent area so + * utilities can set. Does not address setting while + * pool is up. + */ + BYTE ZLBP_FileThrottleBackPercent; + /* Percent that the file must be at to exit FULL mode + * and to enter BACK mode. In persistent area so + * utilities can set. Does not address setting while + * pool is up. + */ + BYTE ZLBP_Padding[6]; + /* Our persistent items are required to be on a QUAD + * boundary so add some padding. Our constructor has + * ASSERT code to verify that this is correct. + */ /*** *** This is the point that version 4.0 differs from version 1.0. *** ***/ - /* - * The following items are all instrucmentation items. The current - * view is that they add very little overhead to the system - * therefore we will not compile out of the production system. - */ + /* + * The following items are all instrucmentation items. The current + * view is that they add very little overhead to the system + * therefore we will not compile out of the production system. + */ - /* - * The Reference Block Count histogram tracks the number of - * blocks that are referenced by the log records that would - * have to be played if we crashed immediately before - * writing the current checkpoint. This item is updated - * when we write a checkpoint. - */ - QUAD ZLBP_PreHomePointerReferenceBlockCount; - QUAD ZLBP_HomePointerReferenceBlockCount; - QUAD ZLBP_ActivePointerReferenceBlockCount; + /* + * The Reference Block Count histogram tracks the number of + * blocks that are referenced by the log records that would + * have to be played if we crashed immediately before + * writing the current checkpoint. This item is updated + * when we write a checkpoint. + */ + QUAD ZLBP_PreHomePointerReferenceBlockCount; + QUAD ZLBP_HomePointerReferenceBlockCount; + QUAD ZLBP_ActivePointerReferenceBlockCount; // ZlogHistory_s ZLBP_ReferenceBlockCountHistory; - ZlogHighWatermarkSlot_s ZLBP_ReferenceBlockCountHistorySlots[10]; + ZlogHighWatermarkSlot_s ZLBP_ReferenceBlockCountHistorySlots[10]; // ZlogHistogram_s ZLBP_ReferenceBlockCountHistogram; - ZlogHistogramPersistent_s ZLBP_ReferenceBlockCountHistogramPersistent; - QUAD ZLBP_ReferenceBlockCountBucket[10]; + ZlogHistogramPersistent_s ZLBP_ReferenceBlockCountHistogramPersistent; + QUAD ZLBP_ReferenceBlockCountBucket[10]; #define ZLOG_RBCB_BUCKET_SIZE (4000) #define ZLOG_RBCB_BUCKET_TYPE ZH_F_QUAD - /* - * The Function histogram tracks the number of time each - * redo/undo function index is used in a log record. This - * could be a debug only item as it has limited use in - * viewing in a end-user system. - */ - ZlogHistogramPersistent_s ZLBP_FunctionHistogramPersistent; - QUAD ZLBP_FunctionBucket[50+85]; + /* + * The Function histogram tracks the number of time each + * redo/undo function index is used in a log record. This + * could be a debug only item as it has limited use in + * viewing in a end-user system. + */ + ZlogHistogramPersistent_s ZLBP_FunctionHistogramPersistent; + QUAD ZLBP_FunctionBucket[50+85]; #define ZLOG_FB_BUCKET_SIZE 1 #define ZLOG_FB_BUCKET_TYPE ZH_F_QUAD - /* The Size histogram tracks the sizes of all log records. The - * size tracked is the total log record size (header, block - * info and user specific info) rounded to a 8 byte bondary. - */ - ZlogHistogramPersistent_s ZLBP_SizeHistogramPersistent; - QUAD ZLBP_SizeBucket[8]; + /* The Size histogram tracks the sizes of all log records. The + * size tracked is the total log record size (header, block + * info and user specific info) rounded to a 8 byte bondary. + */ + ZlogHistogramPersistent_s ZLBP_SizeHistogramPersistent; + QUAD ZLBP_SizeBucket[8]; #define ZLOG_SB_BUCKET_SIZE (512) #define ZLOG_SB_BUCKET_TYPE ZH_F_QUAD - /* - * The Block In-use Count histogram tracks the block size of the - * in-use portion of the ZLOG file. By looking at the high - * watermarks of this histogram one can determine if the ZLOG - * file is too small. NSS does not handle the ZLOG file becoming - * full. - */ + /* + * The Block In-use Count histogram tracks the block size of the + * in-use portion of the ZLOG file. By looking at the high + * watermarks of this histogram one can determine if the ZLOG + * file is too small. NSS does not handle the ZLOG file becoming + * full. + */ // ZlogHistory_s ZLBP_BlockInuseCountHistory; - ZlogHighWatermarkSlot_s ZLBP_BlockInuseCountHistorySlots[10]; - ZlogHistogramPersistent_s ZLBP_BlockInuseCountHistogramPersistent; + ZlogHighWatermarkSlot_s ZLBP_BlockInuseCountHistorySlots[10]; + ZlogHistogramPersistent_s ZLBP_BlockInuseCountHistogramPersistent; // ZlogHistogram_s ZLBP_BlockInuseCountHistogram; - LONG ZLBP_BlockInuseCountBucket[12]; + LONG ZLBP_BlockInuseCountBucket[12]; #define ZLOG_BICB_BUCKET_SIZE (1000) #define ZLOG_BICB_BUCKET_TYPE ZH_F_LONG - /* - * The Recovery Time histogram tracks the time it took to - * do recovery. The time does not include runnning the - * Purge Log. - */ + /* + * The Recovery Time histogram tracks the time it took to + * do recovery. The time does not include runnning the + * Purge Log. + */ // ZlogHistory_s ZLBP_RecoveryTimeHistory; - ZlogHighWatermarkSlot_s ZLBP_RecoveryTimeHistorySlots[10]; + ZlogHighWatermarkSlot_s ZLBP_RecoveryTimeHistorySlots[10]; // ZlogHistogram_s ZLBP_RecoveryTimeHistogram; - ZlogHistogramPersistent_s ZLBP_RecoveryTimeHistogramPersistent; - Time_t ZLBP_RecoveryTimeBucket[4]; + ZlogHistogramPersistent_s ZLBP_RecoveryTimeHistogramPersistent; + Time_t ZLBP_RecoveryTimeBucket[4]; #define ZLOG_RTB_BUCKET_SIZE (30) #define ZLOG_RTB_BUCKET_TYPE ZH_F_LONG - /* - * The Out-of-order Writes histogram tracks the number of - * out-of-order blocks we have when an out-of-order write - * occurs. - */ + /* + * The Out-of-order Writes histogram tracks the number of + * out-of-order blocks we have when an out-of-order write + * occurs. + */ // ZlogHistory_s ZLBP_DeferredWritesHistory; - ZlogHighWatermarkSlot_s ZLBP_DeferredWritesHistorySlots[10]; + ZlogHighWatermarkSlot_s ZLBP_DeferredWritesHistorySlots[10]; // ZlogHistogram_s ZLBP_DeferredWritesHistogram; - ZlogHistogramPersistent_s ZLBP_DeferredWritesHistogramPersistent; - QUAD ZLBP_DeferredWritesBucket[5]; + ZlogHistogramPersistent_s ZLBP_DeferredWritesHistogramPersistent; + QUAD ZLBP_DeferredWritesBucket[5]; #define ZLOG_DWB_BUCKET_SIZE 10 #define ZLOG_DWB_BUCKET_TYPE ZH_F_QUAD - /* - * The Recovery History histogram tracks when we did - * recoveries. We track 16 instead of the normal 10 - * and do not have any buckets. - */ + /* + * The Recovery History histogram tracks when we did + * recoveries. We track 16 instead of the normal 10 + * and do not have any buckets. + */ // ZlogHistogram20_s ZLBP_RecoveryUTCHistory; - /* - * The Recovery History histogram tracks when we did - * recoveries. We track 16 instead of the normal 10 - * and do not have any buckets. - */ + /* + * The Recovery History histogram tracks when we did + * recoveries. We track 16 instead of the normal 10 + * and do not have any buckets. + */ // ZlogHistogram20_s ZLBP_PendingIOHighHistory; - /* - * The highest 16 pending I/Os. - */ + /* + * The highest 16 pending I/Os. + */ // ZlogHistogram20_s ZLBP_RebuildUTCHistory; // ZlogHistory_s ZLBP_History[4]; #define ZLOG_HISTORY_SLOTS 16 - ZlogHighWatermarkSlot_s ZLBP_HistorySlots[4*ZLOG_HISTORY_SLOTS]; + ZlogHighWatermarkSlot_s ZLBP_HistorySlots[4*ZLOG_HISTORY_SLOTS]; #define ZH16_RECOVERY_UTC 0 #define ZH16_REBUILD_UTC 1 #define ZH16_PENDING_IO_HIGH 2 /* Not implemented */ #define ZH16_LAST_USED 2 /* The index of the last used element - * in the ZLBP_History arrary. - */ + * in the ZLBP_History arrary. + */ // ZlogCounts_s ZLBP_Count[6]; //#define ZC_IO_READS 0 /* Not implemented */ //#define ZC_IO_WRITES 1 /* Not implemented */ //#define ZC_IO_CACHE_HITS 2 /* Not implemented */ //#define ZC_IO_CACHE_MISS 3 /* Not implemented */ -//#define ZC_LAST_USED 3 - /* The index of the last used element - * in the ZLBP_Counts arrary. - */ +//#define ZC_LAST_USED 3 + /* The index of the last used element + * in the ZLBP_Counts arrary. + */ /*** *** ***/ - Lsn_t ZLBP_CompensationPtrLsn; - /* This is the LSN value where the compensation records - * begin. It is NULL initially and once we are done - * writing compensation records and they have been - * flushed to disk - */ - Lsn_t ZLBP_LogicalUndoPtrLsn; - /* The logical undo records are copies of the original - * undo records. They have newer LSNs. This is the - * LSN where the Logical Undo records begin. - */ - Blknum_t ZLBP_CompensationPtrBlkNum; - /* This is the blknum which has the first compensation - * record. - */ - Blknum_t ZLBP_LogicalUndoPtrBlkNum; - /* The block number that points to the first - * Logical Undo record. - */ - PoolReadStatistics_s ZLBP_StatisticsRead; - PoolWriteStatistics_s ZLBP_StatisticsWrite; - /* Numerous persistent statistics about physical I/O - * to this pool. Vandana and I decided to store in - * ZLOG as a cheap way of making persistent. ZLOG - * is written to all of the time (unless no changes - * to pool occuring. - * - * Note that their is some reserved space in the - * PoolWriteStatistics_s and PoolReadStatistics_s - * structures that can be used for new counters. - */ - QUAD ZLBP_Reserved[12]; - /* This space is reserved for use of minor changes - * to the ZLOG Beast. When changing major version number - * increase the size of this back to 10. - */ + Lsn_t ZLBP_CompensationPtrLsn; + /* This is the LSN value where the compensation records + * begin. It is NULL initially and once we are done + * writing compensation records and they have been + * flushed to disk + */ + Lsn_t ZLBP_LogicalUndoPtrLsn; + /* The logical undo records are copies of the original + * undo records. They have newer LSNs. This is the + * LSN where the Logical Undo records begin. + */ + Blknum_t ZLBP_CompensationPtrBlkNum; + /* This is the blknum which has the first compensation + * record. + */ + Blknum_t ZLBP_LogicalUndoPtrBlkNum; + /* The block number that points to the first + * Logical Undo record. + */ + PoolReadStatistics_s ZLBP_StatisticsRead; + PoolWriteStatistics_s ZLBP_StatisticsWrite; + /* Numerous persistent statistics about physical I/O + * to this pool. Vandana and I decided to store in + * ZLOG as a cheap way of making persistent. ZLOG + * is written to all of the time (unless no changes + * to pool occuring. + * + * Note that their is some reserved space in the + * PoolWriteStatistics_s and PoolReadStatistics_s + * structures that can be used for new counters. + */ + QUAD ZLBP_Reserved[12]; + /* This space is reserved for use of minor changes + * to the ZLOG Beast. When changing major version number + * increase the size of this back to 10. + */ - LONG ZLBP_Signature; - /* Signature that identifies this is a log file header - * of a pool log block. The signature is 'ZLOG' on Little - * Endian CPUs. This signature is the one that ZAD - * verifies while running. Because it is at the end - * of the persistent area ZAD can detect more changes - * than the signature at the beginning of the persistent - * area. During development the version numbers we - * have set up do not tend to get updated everytime a - * change is made. ZAD uses this signature to catch - * these changes so that ZAD can be re-compiled. - */ - LONG ZLBP_StatisticsResetUTCTime; - /* When the read and write statistics where last set - * to zero. - */ + LONG ZLBP_Signature; + /* Signature that identifies this is a log file header + * of a pool log block. The signature is 'ZLOG' on Little + * Endian CPUs. This signature is the one that ZAD + * verifies while running. Because it is at the end + * of the persistent area ZAD can detect more changes + * than the signature at the beginning of the persistent + * area. During development the version numbers we + * have set up do not tend to get updated everytime a + * change is made. ZAD uses this signature to catch + * these changes so that ZAD can be re-compiled. + */ + LONG ZLBP_StatisticsResetUTCTime; + /* When the read and write statistics where last set + * to zero. + */ // LONG ZLBP_Pad2; /* QUAD alignment */ } NSS_MEDIA_STRUCTURE(ZlogBeastPersistent_s,ZLBP_StatisticsResetUTCTime) ZlogBeastPersistent_s; #define ZLOG_ZLBP_S_SIGNATURE (0x474f4c5auL) /* 'ZLOG' on Little Endian */ #define ZLOG_ZLBP_VM_MAJOR 4 /* Version 2 & 3 have been skipped - * just in case MOAB/Corba needs. - */ + * just in case MOAB/Corba needs. + */ #define ZLOG_ZLBP_VM_MINOR 0 - /* ZLBP_FileVersion value. */ + /* ZLBP_FileVersion value. */ #define ZLOG_ZLBP_FV_VERSION 5 /* - * Update this value if the ZLOG File - * changes. E.G. if the ZLOG Beast's - * block header or record header change - * and you do not wish to require the user - * to /reset their pool then add one to - * this define. You can also - * update this value if the block - * information structure or any of the - * beast specific information changes - * in the ZLOG File Format. See the - * ZLOG Physical File Format diagram - * in the ZLOG Specification for a diagram - * of the items that can change the - * ZLOG file. - */ + * Update this value if the ZLOG File + * changes. E.G. if the ZLOG Beast's + * block header or record header change + * and you do not wish to require the user + * to /reset their pool then add one to + * this define. You can also + * update this value if the block + * information structure or any of the + * beast specific information changes + * in the ZLOG File Format. See the + * ZLOG Physical File Format diagram + * in the ZLOG Specification for a diagram + * of the items that can change the + * ZLOG file. + */ @@ -1075,123 +1075,123 @@ typedef struct ZlogBeastPersistent_s { typedef struct ZlogHighWatermarkBucket_1Dot0_s { - QUAD ZHWB_1Dot0_Event; - Time_t ZHWB_1Dot0_Time; - LONG ZHWB_1Dot0_Padding[1]; + QUAD ZHWB_1Dot0_Event; + Time_t ZHWB_1Dot0_Time; + LONG ZHWB_1Dot0_Padding[1]; } NSS_MEDIA_STRUCTURE(ZlogHighWatermarkBucket_1Dot0_s,ZHWB_1Dot0_Padding[1]) ZlogHighWatermarkBucket_1Dot0_s; typedef struct ZlogHighWatermark_1Dot0_s { - ZlogHighWatermarkBucket_1Dot0_s ZHW_1Dot0_Bucket[ZLOG_HWB_DEFAULT_1Dot0]; + ZlogHighWatermarkBucket_1Dot0_s ZHW_1Dot0_Bucket[ZLOG_HWB_DEFAULT_1Dot0]; } NSS_MEDIA_STRUCTURE(ZlogHighWatermark_1Dot0_s,ZHW_1Dot0_Bucket[ZLOG_HWB_DEFAULT_1Dot0]) ZlogHighWatermark_1Dot0_s; typedef struct ZlogHistogram_1Dot0_s { - ZlogHighWatermark_1Dot0_s ZH_1Dot0_Watermarks; - QUAD ZH_1Dot0_CurrentEvent; - QUAD ZH_1Dot0_EventCount; - LONG ZH_1Dot0_BucketCount; - LONG ZH_1Dot0_BucketSize; - LONG ZH_1Dot0_Flags; + ZlogHighWatermark_1Dot0_s ZH_1Dot0_Watermarks; + QUAD ZH_1Dot0_CurrentEvent; + QUAD ZH_1Dot0_EventCount; + LONG ZH_1Dot0_BucketCount; + LONG ZH_1Dot0_BucketSize; + LONG ZH_1Dot0_Flags; #define ZH_F_LONG 0x0001 #define ZH_F_QUAD 0x0002 #define ZH_F_HIGH_WATERMARK 0x8000 - LONG ZH_1Dot0_Bucket; + LONG ZH_1Dot0_Bucket; } NSS_MEDIA_STRUCTURE(ZlogHistogram_1Dot0_s,ZH_1Dot0_Bucket) ZlogHistogram_1Dot0_s; typedef struct ZlogBeastPersistent_1Dot0_s { - LONG ZLBP_1Dot0_Signature2; - WORD ZLBP_1Dot0_VersionMajor; - WORD ZLBP_1Dot0_VersionMinor; - LONG ZLBP_1Dot0_ZSTOREMajorVersion; - LONG ZLBP_1Dot0_ZSTOREMinorVersion; - LONG ZLBP_1Dot0_ZSTORESubVersion; - LONG ZLBP_1Dot0_ZSTOREBuildNumber; - Lsn_t ZLBP_1Dot0_ActivePointerLsn; - Lsn_t ZLBP_1Dot0_HomePointerLsn; - Lsn_t ZLBP_1Dot0_OldHomePointerLsn[CHECKPOINT_NUMBER]; - Blknum_t ZLBP_1Dot0_FileThrottleFull; /* Use NSS_LOCK to protect */ - Blknum_t ZLBP_1Dot0_FileThrottleBack; /* Use NSS_LOCK to protect */ - QUAD ZLBP_1Dot0_FileThrottleWaitCount; /* Use NSS_LOCK to protect */ - QUAD ZLBP_1Dot0_FileThrottleWait1Count; /* Use NSS_LOCK to protect */ - QUAD ZLBP_1Dot0_FileThrottleWait2Count; /* Use NSS_LOCK to protect */ - QUAD ZLBP_1Dot0_FileThrottleWait3Count; /* Use NSS_LOCK to protect */ - QUAD ZLBP_1Dot0_FileThrottleWait4Count; /* Use NSS_LOCK to protect */ - QUAD ZLBP_1Dot0_FileThrottleWait5Count; /* Use NSS_LOCK to protect */ - QUAD ZLBP_1Dot0_FileThrottleFullCount; /* Use NSS_LOCK to protect */ - QUAD ZLBP_1Dot0_FileThrottleCheckpointCount; /* Use NSS_LOCK to protect */ - QUAD ZLBP_1Dot0_FileThrottleSkipCount; /* Use NSS_LOCK to protect */ - QUAD ZLBP_1Dot0_FileThrottleBackCount; /* Use NSS_LOCK to protect */ - Time_t ZLBP_1Dot0_FileThrottleTimeStart; /* Use NSS_LOCK to protect */ - Time_t ZLBP_1Dot0_FileThrottleTimeEnd; /* Use NSS_LOCK to protect */ - Blknum_t ZLBP_1Dot0_OldHomePointerBlockNumber[CHECKPOINT_NUMBER]; - Blknum_t ZLBP_1Dot0_ActivePointerBlockNumber; - Blknum_t ZLBP_1Dot0_HomePointerBlockNumber; - Blknum_t ZLBP_1Dot0_PreOldestHomePointerBlockNumber; - Time_t ZLBP_1Dot0_TimeActivation; - Time_t ZLBP_1Dot0_TimeDeactivation; - Time_t ZLBP_1Dot0_TimePoolCreate; - LONG ZLBP_1Dot0_RecoveryRecoverCount; - LONG ZLBP_1Dot0_RecoveryActivationCount; - Time_t ZLBP_1Dot0_LastRecoveryTimeStart; - Time_t ZLBP_1Dot0_LastRecoveryTimeEnd; - LONG ZLBP_1Dot0_LastRecoveryActivationCount; - WORD ZLBP_1Dot0_Mode; - WORD ZLBP_1Dot0_FileVersion; - BYTE ZLBP_1Dot0_FileThrottleFullPercent; - BYTE ZLBP_1Dot0_FileThrottleBackPercent; - BYTE ZLBP_1Dot0_Padding[6]; - QUAD ZLBP_1Dot0_PreHomePointerReferenceBlockCount; - QUAD ZLBP_1Dot0_HomePointerReferenceBlockCount; - QUAD ZLBP_1Dot0_ActivePointerReferenceBlockCount; - ZlogHistogram_1Dot0_s ZLBP_1Dot0_ReferenceBlockCountHistogram; - QUAD ZLBP_1Dot0_ReferenceBlockCountBucket[50]; - ZlogHistogram_1Dot0_s ZLBP_1Dot0_FunctionHistogram; - QUAD ZLBP_1Dot0_FunctionBucket[50]; - ZlogHistogram_1Dot0_s ZLBP_1Dot0_SizeHistogram; - QUAD ZLBP_1Dot0_SizeBucket[41]; - ZlogHistogram_1Dot0_s ZLBP_1Dot0_BlockInuseCountHistogram; - LONG ZLBP_1Dot0_BlockInuseCountBucket[40]; - ZlogHistogram_1Dot0_s ZLBP_1Dot0_RecoveryTimeHistogram; - Time_t ZLBP_1Dot0_RecoveryTimeBucket[12]; - ZlogHistogram_1Dot0_s ZLBP_1Dot0_DeferredWritesHistogram; - QUAD ZLBP_1Dot0_DeferredWritesBucket[30]; - /*** Note that the next 4 items (3 quads) are not present in - *** MOAB/Cobra. They are present in the numerous Six-Pack - *** volumes. Our 1Dot0 unpack code will assume that they - *** are present so that we do not have to blow away - *** pre-existing Six-Pack volumes. All this means for - *** the real AIPU is that 3 QUADs worth of zeros will be - *** moved. - ***/ - Lsn_t ZLBP_1Dot0_CompensationPtrLsn; - Lsn_t ZLBP_1Dot0_LogicalUndoPtrLsn; - Blknum_t ZLBP_1Dot0_CompensationPtrBlkNum; - Blknum_t ZLBP_1Dot0_LogicalUndoPtrBlkNum; - QUAD ZLBP_1Dot0_Reserved[37]; - LONG ZLBP_1Dot0_Signature; - LONG ZLBP_1Dot0_Pad2; /* QUAD alignment */ + LONG ZLBP_1Dot0_Signature2; + WORD ZLBP_1Dot0_VersionMajor; + WORD ZLBP_1Dot0_VersionMinor; + LONG ZLBP_1Dot0_ZSTOREMajorVersion; + LONG ZLBP_1Dot0_ZSTOREMinorVersion; + LONG ZLBP_1Dot0_ZSTORESubVersion; + LONG ZLBP_1Dot0_ZSTOREBuildNumber; + Lsn_t ZLBP_1Dot0_ActivePointerLsn; + Lsn_t ZLBP_1Dot0_HomePointerLsn; + Lsn_t ZLBP_1Dot0_OldHomePointerLsn[CHECKPOINT_NUMBER]; + Blknum_t ZLBP_1Dot0_FileThrottleFull; /* Use NSS_LOCK to protect */ + Blknum_t ZLBP_1Dot0_FileThrottleBack; /* Use NSS_LOCK to protect */ + QUAD ZLBP_1Dot0_FileThrottleWaitCount; /* Use NSS_LOCK to protect */ + QUAD ZLBP_1Dot0_FileThrottleWait1Count; /* Use NSS_LOCK to protect */ + QUAD ZLBP_1Dot0_FileThrottleWait2Count; /* Use NSS_LOCK to protect */ + QUAD ZLBP_1Dot0_FileThrottleWait3Count; /* Use NSS_LOCK to protect */ + QUAD ZLBP_1Dot0_FileThrottleWait4Count; /* Use NSS_LOCK to protect */ + QUAD ZLBP_1Dot0_FileThrottleWait5Count; /* Use NSS_LOCK to protect */ + QUAD ZLBP_1Dot0_FileThrottleFullCount; /* Use NSS_LOCK to protect */ + QUAD ZLBP_1Dot0_FileThrottleCheckpointCount; /* Use NSS_LOCK to protect */ + QUAD ZLBP_1Dot0_FileThrottleSkipCount; /* Use NSS_LOCK to protect */ + QUAD ZLBP_1Dot0_FileThrottleBackCount; /* Use NSS_LOCK to protect */ + Time_t ZLBP_1Dot0_FileThrottleTimeStart; /* Use NSS_LOCK to protect */ + Time_t ZLBP_1Dot0_FileThrottleTimeEnd; /* Use NSS_LOCK to protect */ + Blknum_t ZLBP_1Dot0_OldHomePointerBlockNumber[CHECKPOINT_NUMBER]; + Blknum_t ZLBP_1Dot0_ActivePointerBlockNumber; + Blknum_t ZLBP_1Dot0_HomePointerBlockNumber; + Blknum_t ZLBP_1Dot0_PreOldestHomePointerBlockNumber; + Time_t ZLBP_1Dot0_TimeActivation; + Time_t ZLBP_1Dot0_TimeDeactivation; + Time_t ZLBP_1Dot0_TimePoolCreate; + LONG ZLBP_1Dot0_RecoveryRecoverCount; + LONG ZLBP_1Dot0_RecoveryActivationCount; + Time_t ZLBP_1Dot0_LastRecoveryTimeStart; + Time_t ZLBP_1Dot0_LastRecoveryTimeEnd; + LONG ZLBP_1Dot0_LastRecoveryActivationCount; + WORD ZLBP_1Dot0_Mode; + WORD ZLBP_1Dot0_FileVersion; + BYTE ZLBP_1Dot0_FileThrottleFullPercent; + BYTE ZLBP_1Dot0_FileThrottleBackPercent; + BYTE ZLBP_1Dot0_Padding[6]; + QUAD ZLBP_1Dot0_PreHomePointerReferenceBlockCount; + QUAD ZLBP_1Dot0_HomePointerReferenceBlockCount; + QUAD ZLBP_1Dot0_ActivePointerReferenceBlockCount; + ZlogHistogram_1Dot0_s ZLBP_1Dot0_ReferenceBlockCountHistogram; + QUAD ZLBP_1Dot0_ReferenceBlockCountBucket[50]; + ZlogHistogram_1Dot0_s ZLBP_1Dot0_FunctionHistogram; + QUAD ZLBP_1Dot0_FunctionBucket[50]; + ZlogHistogram_1Dot0_s ZLBP_1Dot0_SizeHistogram; + QUAD ZLBP_1Dot0_SizeBucket[41]; + ZlogHistogram_1Dot0_s ZLBP_1Dot0_BlockInuseCountHistogram; + LONG ZLBP_1Dot0_BlockInuseCountBucket[40]; + ZlogHistogram_1Dot0_s ZLBP_1Dot0_RecoveryTimeHistogram; + Time_t ZLBP_1Dot0_RecoveryTimeBucket[12]; + ZlogHistogram_1Dot0_s ZLBP_1Dot0_DeferredWritesHistogram; + QUAD ZLBP_1Dot0_DeferredWritesBucket[30]; + /*** Note that the next 4 items (3 quads) are not present in + *** MOAB/Cobra. They are present in the numerous Six-Pack + *** volumes. Our 1Dot0 unpack code will assume that they + *** are present so that we do not have to blow away + *** pre-existing Six-Pack volumes. All this means for + *** the real AIPU is that 3 QUADs worth of zeros will be + *** moved. + ***/ + Lsn_t ZLBP_1Dot0_CompensationPtrLsn; + Lsn_t ZLBP_1Dot0_LogicalUndoPtrLsn; + Blknum_t ZLBP_1Dot0_CompensationPtrBlkNum; + Blknum_t ZLBP_1Dot0_LogicalUndoPtrBlkNum; + QUAD ZLBP_1Dot0_Reserved[37]; + LONG ZLBP_1Dot0_Signature; + LONG ZLBP_1Dot0_Pad2; /* QUAD alignment */ } NSS_MEDIA_STRUCTURE(ZlogBeastPersistent_1Dot0_s,ZLBP_1Dot0_Pad2) ZlogBeastPersistent_1Dot0_s; -/* - struct ZlssBarrier_s - Used to ensure that a device flush (barrier) is done prior to - signaling that journal blocks have been written. This object is needed - because some devices cache writes, but do not ensure the writes - get written. The Journal MUST ensure that journal blocks are written - prior to meta-data otherwise corruption may occur. See the journal - specification for more information. +/* + struct ZlssBarrier_s + Used to ensure that a device flush (barrier) is done prior to + signaling that journal blocks have been written. This object is needed + because some devices cache writes, but do not ensure the writes + get written. The Journal MUST ensure that journal blocks are written + prior to meta-data otherwise corruption may occur. See the journal + specification for more information. */ typedef struct ZlssBarrier_s { - NINT ZB_Signature; + NINT ZB_Signature; #define ZLSS_BARRIER_SIGNATURE 0x785e7f79 SQlink_t ZB_BarrierLink; /* Barrier agents that are ready for barrier flush. The head of this list is ZlogBeast_s.ZLB_BarrierListHead */ - struct ZlogBeast_s *ZB_Zlog; /* The Journal/Pool that barrier is for */ - Agent_s ZB_Agent; /* For bonds, latching and oneshot timer */ + struct ZlogBeast_s *ZB_Zlog; /* The Journal/Pool that barrier is for */ + Agent_s ZB_Agent; /* For bonds, latching and oneshot timer */ } ZlssBarrier_s; @@ -1232,235 +1232,235 @@ typedef struct ZlogBeast_s * only it. Yes we have cscope, but let's not assume everyone does. */ - File_s file; /* Derived from file */ + File_s file; /* Derived from file */ - /*** Items in this area are not persistent ***/ - QUAD ZLB_LogRecordFilledInCount; - /* Accouting. Number of log record filled in since - * activation. - */ - QUAD ZLB_LogBlockFilledInCount; - /* Accounting. Number of blocks filled in since - * activation. - */ - QUAD ZLB_TransactionsHomedSinceCheckpointCount; - /* Accounting. Number of transactions homed since last - * checkpoint. We only count transactions with log - * records. - */ - QUAD ZLB_TransactionsHomedCount; - /* Accounting. Number of transactions homed since - * activation. We only count transactions with log records. - */ - Blknum_t ZLB_LogBlockFilledInSinceCheckpointCount; - /* NSS_LOCK protected! Number of log blocks filled - * in since we took our last checkpoint. - */ - Blknum_t ZLB_LogBlockFilledInMaximum; - /* Number of log blocks that - * will be filled in prior to taking a new - * checkpoint. - */ - struct Buffer_s *ZLB_Buffer; - /* Current buffer that ZLOG is using. - ******** - * Because Zlog_FlushBlockStartSignalHandler accesses - * this item without latching the ZLOG's beast beastLatch - * we have special access rules. - * 1) Signal Handler will have shared latch on buffer - * and a NSS_LOCK. - * 2) ZLOG_ObtainRecord will NSS_LOCK when R/W if it - * does not have a exclusive latch on the buffer. - ******** - */ - Blknum_t ZLB_NumberOfLogBlocks; - /* Number of log blocks (originals and - * duplicates) in the pool log file. - */ - DQhead_t ZLB_SeniorityListHead; - /* DQ of all active transactions order by oldest - * to youngest. Used to determine when the home pointer - * and home pointer LSN can be moved forward. Transactions - * get placed on list by ZLOG_ObtainRecord() and removed - * by ZLOG_TransactionHomed(). - */ - DQhead_t ZLB_CachedBufferListHead; - /* DQ of all ZLOG buffers that need to be flushed. Ordered - * by oldest to youngest. Used to determine when signal - * to the bound DATA buffers can be passed through. - * Buffers get placed on list by ZLOG_ObtainRecord() and - * removed by Zlog_FlushBlockEndSignalHandler(). This - * link list implements the ZLOG specification requirement - * that NO DATA buffers be flushed before ALL log buffers - * less than the last log buffer the DATA is bond to have - * been flushed. - */ - ZfsXasRecovery_s *ZLB_ZfsXasRecovery; - /* Return value from ZLOG_ObtainRecord(). */ - Latch_s ZLB_FileFullLatch; - /* Used to block threads that are doing ZLOG_ObtainRecord - * when the ZLOG file is full. Under normal use, the ZLOG - * file should never become full. - */ - Latch_s ZLB_RecoveryLatch; - /* Used by recovery system to protect recovery phase - * from re-entry. All items within - * the ZLOG beast that start with ZLB_Recovery are - * protected by this latch. - */ - Latch_s ZLB_CheckpointTakeLatch; - /* Used to serialize taking checkpoints. We do not skip - * taking a checkpoint because someone else is currently - * taking one, because the 'snapshot' of the ZLOG beast - * may not contain the information that the current - * checkpoint take requestor needs. - */ + /*** Items in this area are not persistent ***/ + QUAD ZLB_LogRecordFilledInCount; + /* Accouting. Number of log record filled in since + * activation. + */ + QUAD ZLB_LogBlockFilledInCount; + /* Accounting. Number of blocks filled in since + * activation. + */ + QUAD ZLB_TransactionsHomedSinceCheckpointCount; + /* Accounting. Number of transactions homed since last + * checkpoint. We only count transactions with log + * records. + */ + QUAD ZLB_TransactionsHomedCount; + /* Accounting. Number of transactions homed since + * activation. We only count transactions with log records. + */ + Blknum_t ZLB_LogBlockFilledInSinceCheckpointCount; + /* NSS_LOCK protected! Number of log blocks filled + * in since we took our last checkpoint. + */ + Blknum_t ZLB_LogBlockFilledInMaximum; + /* Number of log blocks that + * will be filled in prior to taking a new + * checkpoint. + */ + struct Buffer_s *ZLB_Buffer; + /* Current buffer that ZLOG is using. + ******** + * Because Zlog_FlushBlockStartSignalHandler accesses + * this item without latching the ZLOG's beast beastLatch + * we have special access rules. + * 1) Signal Handler will have shared latch on buffer + * and a NSS_LOCK. + * 2) ZLOG_ObtainRecord will NSS_LOCK when R/W if it + * does not have a exclusive latch on the buffer. + ******** + */ + Blknum_t ZLB_NumberOfLogBlocks; + /* Number of log blocks (originals and + * duplicates) in the pool log file. + */ + DQhead_t ZLB_SeniorityListHead; + /* DQ of all active transactions order by oldest + * to youngest. Used to determine when the home pointer + * and home pointer LSN can be moved forward. Transactions + * get placed on list by ZLOG_ObtainRecord() and removed + * by ZLOG_TransactionHomed(). + */ + DQhead_t ZLB_CachedBufferListHead; + /* DQ of all ZLOG buffers that need to be flushed. Ordered + * by oldest to youngest. Used to determine when signal + * to the bound DATA buffers can be passed through. + * Buffers get placed on list by ZLOG_ObtainRecord() and + * removed by Zlog_FlushBlockEndSignalHandler(). This + * link list implements the ZLOG specification requirement + * that NO DATA buffers be flushed before ALL log buffers + * less than the last log buffer the DATA is bond to have + * been flushed. + */ + ZfsXasRecovery_s *ZLB_ZfsXasRecovery; + /* Return value from ZLOG_ObtainRecord(). */ + Latch_s ZLB_FileFullLatch; + /* Used to block threads that are doing ZLOG_ObtainRecord + * when the ZLOG file is full. Under normal use, the ZLOG + * file should never become full. + */ + Latch_s ZLB_RecoveryLatch; + /* Used by recovery system to protect recovery phase + * from re-entry. All items within + * the ZLOG beast that start with ZLB_Recovery are + * protected by this latch. + */ + Latch_s ZLB_CheckpointTakeLatch; + /* Used to serialize taking checkpoints. We do not skip + * taking a checkpoint because someone else is currently + * taking one, because the 'snapshot' of the ZLOG beast + * may not contain the information that the current + * checkpoint take requestor needs. + */ - Blknum_t ZLB_RecoveryAreaFirstBlockNumber; - /* Logical number of first recovery block. This - * is the first block that is needed for recovery. - * The first logical block number of the pool - * log file is 0. - */ + Blknum_t ZLB_RecoveryAreaFirstBlockNumber; + /* Logical number of first recovery block. This + * is the first block that is needed for recovery. + * The first logical block number of the pool + * log file is 0. + */ - Blknum_t ZLB_RecoveryActivePointerBlockNumber; - /* The true active pointer of the ZLOG file at recovery - * time. This may be the active pointer stored in the - * checkpoint OR it could be further in the file. The - * Recover Active Pointer(RAP) code determines this value - * at recovery time by scanning the ZLOG file from - * the home pointer until it locates a block with a LESSER - * LSN. The value is used to determine where the end - * of the recovery area is. Also the current active - * pointer is set to this value. - */ - Lsn_t ZLB_RecoveryActivePointerLsn; - /* Used by Recover Active Pointer code to track what - * RAP has found as the active pointer. Initially set to - * the home pointer and then moved when the next blocks - * contains a higher LSN. This value is also used to know - * when to stop processing blocks during recovery. LSNs - * equal to or greater than must not be recovered (they - * are log records that we logged during the recovery - * phase.) - */ + Blknum_t ZLB_RecoveryActivePointerBlockNumber; + /* The true active pointer of the ZLOG file at recovery + * time. This may be the active pointer stored in the + * checkpoint OR it could be further in the file. The + * Recover Active Pointer(RAP) code determines this value + * at recovery time by scanning the ZLOG file from + * the home pointer until it locates a block with a LESSER + * LSN. The value is used to determine where the end + * of the recovery area is. Also the current active + * pointer is set to this value. + */ + Lsn_t ZLB_RecoveryActivePointerLsn; + /* Used by Recover Active Pointer code to track what + * RAP has found as the active pointer. Initially set to + * the home pointer and then moved when the next blocks + * contains a higher LSN. This value is also used to know + * when to stop processing blocks during recovery. LSNs + * equal to or greater than must not be recovered (they + * are log records that we logged during the recovery + * phase.) + */ - Blknum_t ZLB_RecoveryInitialActivePointerBlockNumber; - /* This is the value of the Active pointer Block number - * after the recoveryactivepointer has been founded and - * the active pointer has been updated to point to it - * before we start redo/undo. With logical undo the - * active pointer value can change, so we save the initial - * value - */ + Blknum_t ZLB_RecoveryInitialActivePointerBlockNumber; + /* This is the value of the Active pointer Block number + * after the recoveryactivepointer has been founded and + * the active pointer has been updated to point to it + * before we start redo/undo. With logical undo the + * active pointer value can change, so we save the initial + * value + */ - Lsn_t ZLB_RecoveryInitialActivePointerLsn; - /* This is the value of the Active pointer LSN - * after the recoveryactivepointer has been founded and - * the active pointer has been updated to point to it - * before we start redo/undo. With logical undo the - * active pointer value can change, so we save the initial - * value - */ + Lsn_t ZLB_RecoveryInitialActivePointerLsn; + /* This is the value of the Active pointer LSN + * after the recoveryactivepointer has been founded and + * the active pointer has been updated to point to it + * before we start redo/undo. With logical undo the + * active pointer value can change, so we save the initial + * value + */ - Lsn_t ZLB_RecoveryCompensationPointerLsn; - /* During redo/undo of compensation records, this - * keeps track of which logical undo records were - * already played and committed. Pass 6 uses this - * value to determine which logical undo records were - * already committed and need not be copied. - */ + Lsn_t ZLB_RecoveryCompensationPointerLsn; + /* During redo/undo of compensation records, this + * keeps track of which logical undo records were + * already played and committed. Pass 6 uses this + * value to determine which logical undo records were + * already committed and need not be copied. + */ // BOOL ZLB_ProcessCompensationRecords; // /* This tells us whether we are doing redo/undo on normal -// * records or compensation records. If we are doing -// * redo/undo on compensation records, we force undo +// * records or compensation records. If we are doing +// * redo/undo on compensation records, we force undo // * all the records. // */ - NINT ZLB_Signature; - /* Debug - So when we do STRUCT magic we can verify - * that this really is a ZLOG beast. The ID is 615960 - */ + NINT ZLB_Signature; + /* Debug - So when we do STRUCT magic we can verify + * that this really is a ZLOG beast. The ID is 615960 + */ - LONG ZLB_State; - /* State bits - * 0x0001 - No more checkpoints should be taken. - * - */ + LONG ZLB_State; + /* State bits + * 0x0001 - No more checkpoints should be taken. + * + */ #if ZLOG_USE_SYSTEMS_WORK_TO_DO - zWorkProc_s ZLB_CheckpointTakeWorkToDoStructure; - /* Protected by ZLB_CheckpointTakeWorkToDoScheduled flag. - * WorkToDo for NSS Library schedule API - ScheduleWork(). - */ + zWorkProc_s ZLB_CheckpointTakeWorkToDoStructure; + /* Protected by ZLB_CheckpointTakeWorkToDoScheduled flag. + * WorkToDo for NSS Library schedule API - ScheduleWork(). + */ #else - FsmLite_s ZLB_CheckpointTakeWorkToDoFsm; - /* Protected by ZLB_CheckpointTakeWorkToDoScheduled flag. - * Lite FSM to pass to WORK_Schedule(). - */ + FsmLite_s ZLB_CheckpointTakeWorkToDoFsm; + /* Protected by ZLB_CheckpointTakeWorkToDoScheduled flag. + * Lite FSM to pass to WORK_Schedule(). + */ #endif #if NSS_DEBUG IS_ENABLED - Time_t ZLB_CheckpointTakeWorkToDoTiming; - /* Times how long it takes the schedule code to actually - * start the checkpoint routine. - */ + Time_t ZLB_CheckpointTakeWorkToDoTiming; + /* Times how long it takes the schedule code to actually + * start the checkpoint routine. + */ #endif - OneShot_s ZLB_CheckpointTakeWorkToDoTimer; - /* Protected by ZLB_CheckpointTakeWorkToDoScheduled flag. - * One Shot timer used to implement '30 second' checkpoint - * logic. - */ + OneShot_s ZLB_CheckpointTakeWorkToDoTimer; + /* Protected by ZLB_CheckpointTakeWorkToDoScheduled flag. + * One Shot timer used to implement '30 second' checkpoint + * logic. + */ - BYTE ZLB_CheckpointTakeWorkToDoScheduled; - /* NSS_LOCK() protection required! TRUE if we have - * scheduled a checkpoint via our work-to-do logic. We - * track this because we can only have (and want) one item - * scheduled at a time. - */ + BYTE ZLB_CheckpointTakeWorkToDoScheduled; + /* NSS_LOCK() protection required! TRUE if we have + * scheduled a checkpoint via our work-to-do logic. We + * track this because we can only have (and want) one item + * scheduled at a time. + */ - BYTE ZLB_DebugState; - /* Debug. State that ZLOG is in. Used to do some - * ASSERT code. - */ + BYTE ZLB_DebugState; + /* Debug. State that ZLOG is in. Used to do some + * ASSERT code. + */ - BYTE ZLB_ActiveHasBeenRead; - /* FALSE if we need to read the current active pointer - * block. TRUE if we already have read the current active - * pointer block. This item is normally set to TRUE. - */ - BYTE ZLB_FileFullWaiters; - /* 0 if no one is waiting for the ZLOG file to become - * un-full. 1 if the file is full and someone is waiting - * to use it. Under normal use, the ZLOG file should - * never become full. - */ + BYTE ZLB_ActiveHasBeenRead; + /* FALSE if we need to read the current active pointer + * block. TRUE if we already have read the current active + * pointer block. This item is normally set to TRUE. + */ + BYTE ZLB_FileFullWaiters; + /* 0 if no one is waiting for the ZLOG file to become + * un-full. 1 if the file is full and someone is waiting + * to use it. Under normal use, the ZLOG file should + * never become full. + */ #if LOG_TEST IS_ENABLED - LogTest_s ZLB_LT[LOG_TEST_MAX]; + LogTest_s ZLB_LT[LOG_TEST_MAX]; #endif - /* Our persistent items are required to be on a QUAD - * boundary so add some padding. Our constructor has - * ASSERT code to verify that this is correct. - */ - LONG ZLB_WorkToDoParameter1; + /* Our persistent items are required to be on a QUAD + * boundary so add some padding. Our constructor has + * ASSERT code to verify that this is correct. + */ + LONG ZLB_WorkToDoParameter1; #if NSS_DEBUG IS_ENABLED - /* Track the thread that is doing the current checkpoint. - */ - LONG ZLB_CheckpointThreadId; - LONG ZLB_CheckpointThreadIdLast; - /* The times that the last 4 checkpoints where taken. - */ - Time_t ZLB_CheckpointTime[CHECKPOINT_NUMBER]; + /* Track the thread that is doing the current checkpoint. + */ + LONG ZLB_CheckpointThreadId; + LONG ZLB_CheckpointThreadIdLast; + /* The times that the last 4 checkpoints where taken. + */ + Time_t ZLB_CheckpointTime[CHECKPOINT_NUMBER]; #endif - /* Parameter passed to ZLOG's work-to-do checkpoint routine. - * This is currently the 'state' value that the function - * ZFSPOOL_CheckpointTake() requires. - */ - ZlogXactionStats_s ZLB_Ftest; // Currently 4 LONGs - STATUS ZLB_RedoUndoStatus; - char *ZLB_RedoUndoStatusSetter; - /* Set to zFAILURE when REDO/UNDO fails. Used to prevent - * a taking a checkpoint when we REDO/UNDO fails. - */ + /* Parameter passed to ZLOG's work-to-do checkpoint routine. + * This is currently the 'state' value that the function + * ZFSPOOL_CheckpointTake() requires. + */ + ZlogXactionStats_s ZLB_Ftest; // Currently 4 LONGs + STATUS ZLB_RedoUndoStatus; + char *ZLB_RedoUndoStatusSetter; + /* Set to zFAILURE when REDO/UNDO fails. Used to prevent + * a taking a checkpoint when we REDO/UNDO fails. + */ ZlssBarrier_s *ZLB_Barrier; /* Current barrier that ZLOG is using. @@ -1488,42 +1488,42 @@ typedef struct ZlogBeast_s FsmLite_s ZLB_BarrierWorkToDoFsm; /* FSM to use to schedule barrier agent writes. */ - /* Histograms track all events. This is done by placing a - * event into one of many 'buckets'. - */ - ZlogHistogram_s ZLB_FunctionHistogram; + /* Histograms track all events. This is done by placing a + * event into one of many 'buckets'. + */ + ZlogHistogram_s ZLB_FunctionHistogram; - ZlogHistogram_s ZLB_SizeHistogram; + ZlogHistogram_s ZLB_SizeHistogram; - /* Historys track specific number of events. This is done - * by logging specific events. - */ - ZlogHistory_s ZLB_History[4]; + /* Historys track specific number of events. This is done + * by logging specific events. + */ + ZlogHistory_s ZLB_History[4]; #define ZH16_RECOVERY_UTC 0 #define ZH16_REBUILD_UTC 1 #define ZH16_PENDING_IO_HIGH 2 #define ZH16_LAST_USED 2 /* The index of the last used element - * in the ZLB_History arrary. - */ + * in the ZLB_History arrary. + */ - ZlogHistogram_s ZLB_ReferenceBlockCountHistogram; - ZlogHistory_s ZLB_ReferenceBlockCountHistory; + ZlogHistogram_s ZLB_ReferenceBlockCountHistogram; + ZlogHistory_s ZLB_ReferenceBlockCountHistory; - ZlogHistogram_s ZLB_BlockInuseCountHistogram; - ZlogHistory_s ZLB_BlockInuseCountHistory; + ZlogHistogram_s ZLB_BlockInuseCountHistogram; + ZlogHistory_s ZLB_BlockInuseCountHistory; - ZlogHistogram_s ZLB_RecoveryTimeHistogram; - ZlogHistory_s ZLB_RecoveryTimeHistory; + ZlogHistogram_s ZLB_RecoveryTimeHistogram; + ZlogHistory_s ZLB_RecoveryTimeHistory; - ZlogHistogram_s ZLB_DeferredWritesHistogram; - ZlogHistory_s ZLB_DeferredWritesHistory; + ZlogHistogram_s ZLB_DeferredWritesHistogram; + ZlogHistory_s ZLB_DeferredWritesHistory; // BYTE ZLB_Reserved[4]; - /*** Our persistent items ***/ - ZlogBeastPersistent_s ZLB_P; + /*** Our persistent items ***/ + ZlogBeastPersistent_s ZLB_P; } ZlogBeast_s; - /* Needed because documented for ZLOGObtainRecord API */ + /* Needed because documented for ZLOGObtainRecord API */ #define ZLB_CommitAgent ZLB_Barrier->ZB_Agent /* @@ -1540,20 +1540,20 @@ typedef struct ZlogBeast_s * */ #define ZLOG_ZB_S_DEFAULT_STATE 0x00000000uL - /* State to use when pool is activated */ + /* State to use when pool is activated */ #define ZLOG_ZB_S_NO_MORE_CHECKPOINTS 0x00000001uL - /* State to indicate that we must not take any more checkpoints */ + /* State to indicate that we must not take any more checkpoints */ #define ZLOG_ZB_S_TAKING_CHECKPOINT 0x00000004uL - /* FYI - Currently in the process of taking a checkpoint */ + /* FYI - Currently in the process of taking a checkpoint */ #define ZLOG_ZB_S_DOING_COMPENSATION 0x00000010uL - /* We are processing logical undo records, and the log records - * being written at this time are compensation records - */ + /* We are processing logical undo records, and the log records + * being written at this time are compensation records + */ #define ZLOG_ZB_S_NEEDTODO_COMPENSATION 0x00000020uL - /* We have finished the physical redo/undo passes and there are - * some records that were copied and we need to do logical - * undo resulting in generation of compensation records - */ + /* We have finished the physical redo/undo passes and there are + * some records that were copied and we need to do logical + * undo resulting in generation of compensation records + */ /* * @@ -1561,26 +1561,26 @@ typedef struct ZlogBeast_s * */ #define ZLOG_ZB_DS_CONSTRUCT_PRE 0 - /* The code assumes this is zero and an ASSERT - * verifies it in our constructor. - */ + /* The code assumes this is zero and an ASSERT + * verifies it in our constructor. + */ #define ZLOG_ZB_DS_CONSTRUCT_START 1 /* In constructor */ #define ZLOG_ZB_DS_CONSTRUCT_ERROR 2 /* Error from constructor. */ #define ZLOG_ZB_DS_CONSTRUCT_END 3 /* Success form constructor. */ - /* Have made it through our constructor successfully. */ + /* Have made it through our constructor successfully. */ #define ZLOG_ZB_DS_RECOVERY_START 4 - #define ZLOG_ZB_DS_RAP_START 5 /* Recover Active Pointer */ - #define ZLOG_ZB_DS_RAP_ERROR 6 /* Recover Active Pointer(error)*/ - #define ZLOG_ZB_DS_RAP_END 7 /* Recover Active Pointer */ - #define ZLOG_ZB_DS_PT_START 8 /* Process Transaction */ - #define ZLOG_ZB_DS_PT_ERROR 9 /* Process Transaction (error) */ - #define ZLOG_ZB_DS_PT_END 10 /* Process Transaction */ + #define ZLOG_ZB_DS_RAP_START 5 /* Recover Active Pointer */ + #define ZLOG_ZB_DS_RAP_ERROR 6 /* Recover Active Pointer(error)*/ + #define ZLOG_ZB_DS_RAP_END 7 /* Recover Active Pointer */ + #define ZLOG_ZB_DS_PT_START 8 /* Process Transaction */ + #define ZLOG_ZB_DS_PT_ERROR 9 /* Process Transaction (error) */ + #define ZLOG_ZB_DS_PT_END 10 /* Process Transaction */ #define ZLOG_ZB_DS_RECOVERY_ERROR 11 #define ZLOG_ZB_DS_RECOVERY_END 12 #define ZLOG_ZB_DS_LOG_TEST 127 /* Doing a log record undo/redo - * or undo/redo test. - */ + * or undo/redo test. + */ #define ZLOG_ZB_DS_DESTRUCT_START 253 #define ZLOG_ZB_DS_DESTRUCT_ERROR 254 @@ -1600,79 +1600,79 @@ typedef struct ZlogBeast_s #define ZFSLOGzfsStInfo ZFSLOGroot.storage.zfsInfo #define ZFSLOGstInfo ZFSLOGroot.storage.info #define ZFSLOGzid ZFSLOGroot.zid -//#define ZFSLOGvolumeID ZFSLOGroot.vol.volume->p.volumeID +//#define ZFSLOGvolumeID ZFSLOGroot.vol.volume->p.volumeID #define ZFSLOGrebuildCount ZFSLOGroot.vol.volume->p.rebuildCount typedef struct ZlogRecoveryKey_s { - ZfsXasRecovery_s *ZRK_ZfsXasRecovery; - /* External. Points to the Recovery information of - * current log record. Callers use to locate needed - * Memory pointed to can not be used after the next - * recovery find API call. - */ - Buffer_s *ZRK_Buffer; - /* Internal. Buffer_s that contains the recovery - * information. - */ - ZlogBeast_s *ZRK_ZlogBeast; - /* Internal. ZLOG beast that owns this key. */ - Blknum_t ZRK_LogBufferNumber; - /* Internal. Current file logical log buffer number. - * Zero relative to beginning of ZLOG file. Used to - * find the next or previous log buffer number. Also - * used to see when find has returned all of recovery - * log records. - */ - Lsn_t ZRK_LsnFirst; - /* Internal. The first LSN that can appear in the - * recovery area. - */ - Blknum_t ZRK_BlockFirst; - /* Internal. First block of the 'get' area. On a - * forward get this is the first block used. On a - * backwards get this is the last block used. - */ - Blknum_t ZRK_BlockLast; - /* Internal. Last block of the 'get' area. On a - * forward get this is the first block not used. On a - * backwards get this block is the first block not used. - */ - int ZRK_LogRecordNumber; - /* Internal. Current log record number. Zero relative - * to beginning of current log buffer. Used to find the - * next or previous log record. - */ + ZfsXasRecovery_s *ZRK_ZfsXasRecovery; + /* External. Points to the Recovery information of + * current log record. Callers use to locate needed + * Memory pointed to can not be used after the next + * recovery find API call. + */ + Buffer_s *ZRK_Buffer; + /* Internal. Buffer_s that contains the recovery + * information. + */ + ZlogBeast_s *ZRK_ZlogBeast; + /* Internal. ZLOG beast that owns this key. */ + Blknum_t ZRK_LogBufferNumber; + /* Internal. Current file logical log buffer number. + * Zero relative to beginning of ZLOG file. Used to + * find the next or previous log buffer number. Also + * used to see when find has returned all of recovery + * log records. + */ + Lsn_t ZRK_LsnFirst; + /* Internal. The first LSN that can appear in the + * recovery area. + */ + Blknum_t ZRK_BlockFirst; + /* Internal. First block of the 'get' area. On a + * forward get this is the first block used. On a + * backwards get this is the last block used. + */ + Blknum_t ZRK_BlockLast; + /* Internal. Last block of the 'get' area. On a + * forward get this is the first block not used. On a + * backwards get this block is the first block not used. + */ + int ZRK_LogRecordNumber; + /* Internal. Current log record number. Zero relative + * to beginning of current log buffer. Used to find the + * next or previous log record. + */ #if NSS_ASSERT IS_ENABLED - /* These items are used to in ASSERTs only */ - unsigned int ZRK_Signature; + /* These items are used to in ASSERTs only */ + unsigned int ZRK_Signature; #define ZLOG_ZRK_S_SIGNATURE 801861 - unsigned int ZRK_Flag; + unsigned int ZRK_Flag; #define ZLOG_ZRK_F_KEY_VALID 8368742 #endif } ZlogRecoveryKey_s; - /* Flags for ZLOG_RecoveryOpen() */ + /* Flags for ZLOG_RecoveryOpen() */ #define ZLOG_RECOVERY_BEGIN 0x0001 #define ZLOG_RECOVERY_END 0x0000 // Begin or End must be selected #define ZLOG_RECOVERY_EXPANDED 0x0004 #define ZLOG_RECOVERY_LOGICAL 0x0008 -#define ZLOG_RECOVERY_NORMAL 0x0000 // Expanded or Normal or Logical - //must be selected +#define ZLOG_RECOVERY_NORMAL 0x0000 // Expanded or Normal or Logical + //must be selected - /* Direction flag for ZLOG_RecoveryGet() */ + /* Direction flag for ZLOG_RecoveryGet() */ #define ZLOG_RG_NEXT 1 #define ZLOG_RG_PREVIOUS -1 #define ZLOG_ReleaseRecordAndLogEnd( _xaction ) \ { \ - if (DQ_EMPTY( &_xaction->ZX_deleteBlkQ)) \ - { \ - _xaction->xstate |= XAS_XR_TS_END; \ - } \ - ZLOG_ReleaseRecord( _xaction ); \ + if (DQ_EMPTY( &_xaction->ZX_deleteBlkQ)) \ + { \ + _xaction->xstate |= XAS_XR_TS_END; \ + } \ + ZLOG_ReleaseRecord( _xaction ); \ } @@ -1682,10 +1682,10 @@ typedef struct ZlogRecoveryKey_s { */ typedef struct BlockInfo_s { - Blknum_t blkNum; /* the block number */ - WORD logState; /* state information used while logging */ - WORD replayState; /* state information used during playback */ - Lsn_t previousLsn; /* the previous log sequence number */ + Blknum_t blkNum; /* the block number */ + WORD logState; /* state information used while logging */ + WORD replayState; /* state information used during playback */ + Lsn_t previousLsn; /* the previous log sequence number */ } NSS_MEDIA_STRUCTURE(BlockInfo_s,previousLsn) BlockInfo_s; /* defines for logState */ @@ -1698,44 +1698,44 @@ typedef struct BlockInfo_s /* macro to assign information to the block info structure */ #if LOG_TEST IS_ENABLED #define ZLOG_ASSIGN_BLOCK_INFO(_entry, _blknum, _prevLsn, \ - _buffer, _xaction, _index) \ - ((_entry).blkNum = (_blknum), \ - (_entry).previousLsn = (_prevLsn), \ - (_entry).logState = 0, \ - (_xaction)->ZX_Buffers[(_index)] = (_buffer), \ - ((_xaction)->ZX_Compare[(_index)]) = (LogTestCompareFunc_t)zlog_LogTestCompare, \ - zASSERT((_index) < LOG_TEST_MAX )) + _buffer, _xaction, _index) \ + ((_entry).blkNum = (_blknum), \ + (_entry).previousLsn = (_prevLsn), \ + (_entry).logState = 0, \ + (_xaction)->ZX_Buffers[(_index)] = (_buffer), \ + ((_xaction)->ZX_Compare[(_index)]) = (LogTestCompareFunc_t)zlog_LogTestCompare, \ + zASSERT((_index) < LOG_TEST_MAX )) #else #define ZLOG_ASSIGN_BLOCK_INFO(_entry, _blknum, _prevLsn, \ - _notUsed1, _notUsed2, _notUsed3) \ - ((_entry).blkNum = (_blknum), \ - (_entry).previousLsn = (_prevLsn), \ - (_entry).logState = 0) + _notUsed1, _notUsed2, _notUsed3) \ + ((_entry).blkNum = (_blknum), \ + (_entry).previousLsn = (_prevLsn), \ + (_entry).logState = 0) #endif /* macro to assign information to the block info structure AND supplies - a non-standard compare routine.*/ + a non-standard compare routine.*/ #if LOG_TEST IS_ENABLED #define ZLOG_ASSIGN_BLOCK_INFO2(_entry, _blknum, _prevLsn, \ - _buffer, _xaction, _index, _func) \ - ((_entry).blkNum = (_blknum), \ - (_entry).previousLsn = (_prevLsn), \ - (_entry).logState = 0, \ - (_xaction)->ZX_Buffers[(_index)] = (_buffer), \ - (_xaction)->ZX_Compare[(_index)] = ((LogTestCompareFunc_t)(_func)), \ - zASSERT((_index) < LOG_TEST_MAX )) + _buffer, _xaction, _index, _func) \ + ((_entry).blkNum = (_blknum), \ + (_entry).previousLsn = (_prevLsn), \ + (_entry).logState = 0, \ + (_xaction)->ZX_Buffers[(_index)] = (_buffer), \ + (_xaction)->ZX_Compare[(_index)] = ((LogTestCompareFunc_t)(_func)), \ + zASSERT((_index) < LOG_TEST_MAX )) #else #define ZLOG_ASSIGN_BLOCK_INFO2(_entry, _blknum, _prevLsn, \ - _notUsed1, _notUsed2, _notUsed3, _notUsed4) \ - ((_entry).blkNum = (_blknum), \ - (_entry).previousLsn = (_prevLsn), \ - (_entry).logState = 0) + _notUsed1, _notUsed2, _notUsed3, _notUsed4) \ + ((_entry).blkNum = (_blknum), \ + (_entry).previousLsn = (_prevLsn), \ + (_entry).logState = 0) #endif #if LOG_TEST IS_ENABLED #define ZLOG_TEST_REDO( _xaction ) \ - ((_xaction)->xstate |= X_REDO_THEN_UNDO) + ((_xaction)->xstate |= X_REDO_THEN_UNDO) #else #define ZLOG_TEST_REDO( _xaction ) /* We do nothing */ #endif @@ -1745,8 +1745,8 @@ typedef struct BlockInfo_s */ #define ZLOG_DELETE_BLOCK(_xaction, _entry) \ { \ - (_entry).logState = LOG_FREE_NODE; \ - XdeferPoolBlk((_xaction), (_entry).blkNum); \ + (_entry).logState = LOG_FREE_NODE; \ + XdeferPoolBlk((_xaction), (_entry).blkNum); \ } /* @@ -1756,78 +1756,78 @@ typedef struct BlockInfo_s #define ZLOG_ALLOC_BLOCK(_entry) \ { \ - (_entry).logState = LOG_ALLOC_NODE; \ + (_entry).logState = LOG_ALLOC_NODE; \ } /* macro to compute where the pool block section of the log record starts */ #define ZLOG_START_OF_POOL_BLOCKS(_header) \ - (BlockInfo_s *)((ADDR)(_header) + sizeof(ZfsXasRecovery_s)) + (BlockInfo_s *)((ADDR)(_header) + sizeof(ZfsXasRecovery_s)) /* macro to compute where the logged information in the log record starts */ #define ZLOG_START_OF_LOG_RECORD(_header) \ - (void *)((ADDR)(_header) + sizeof(ZfsXasRecovery_s) + \ - ((_header)->ZXR_PoolBlockCount * sizeof(BlockInfo_s))) + (void *)((ADDR)(_header) + sizeof(ZfsXasRecovery_s) + \ + ((_header)->ZXR_PoolBlockCount * sizeof(BlockInfo_s))) /* macro to set the log sequence number during replay of the log */ #define ZLOG_SET_LSN(_logBuf, _lsn, _entry, _action) \ - { \ - if ((_action) == X_REDO) \ - { \ - if (((_entry).blkNum != 0) && !((_entry).logState & \ - LOG_ALLOC_NODE)) \ - zASSERT((_lsn) == (_entry).previousLsn); \ - (_lsn) = (_logBuf)->ZXR_Lsn; \ - } \ - else \ - { \ - (_lsn) = (_entry).previousLsn; \ - } \ - } + { \ + if ((_action) == X_REDO) \ + { \ + if (((_entry).blkNum != 0) && !((_entry).logState & \ + LOG_ALLOC_NODE)) \ + zASSERT((_lsn) == (_entry).previousLsn); \ + (_lsn) = (_logBuf)->ZXR_Lsn; \ + } \ + else \ + { \ + (_lsn) = (_entry).previousLsn; \ + } \ + } - /* - * This macro determines if a Block already contains the information - * stored in the Log Record. It works for both REDO and UNDO. - * In addition, it 'tells' the xaction code if a REDO/UNDO is - * actually being done (via zp_stats.redid). - */ + /* + * This macro determines if a Block already contains the information + * stored in the Log Record. It works for both REDO and UNDO. + * In addition, it 'tells' the xaction code if a REDO/UNDO is + * actually being done (via zp_stats.redid). + */ #if NSS_DEBUG IS_ENABLED #define ZLOG_ALREADY_DONE(_zfsPool, _logBuf, _lsn, _action) \ - ((((_action == X_REDO) && (_lsn) >= (_logBuf)->ZXR_Lsn) \ - || ((_action == X_UNDO) && (_lsn) < (_logBuf)->ZXR_Lsn)) \ - ? ( DBG_DebugPrintf(CYAN,"S"), TRUE ) \ - : ( DBG_DebugPrintf(RED,"P"), _zfsPool->zp_stats.redid++, FALSE) ) + ((((_action == X_REDO) && (_lsn) >= (_logBuf)->ZXR_Lsn) \ + || ((_action == X_UNDO) && (_lsn) < (_logBuf)->ZXR_Lsn)) \ + ? ( DBG_DebugPrintf(CYAN,"S"), TRUE ) \ + : ( DBG_DebugPrintf(RED,"P"), _zfsPool->zp_stats.redid++, FALSE) ) #else #define ZLOG_ALREADY_DONE(_zfsPool, _logBuf, _lsn, _action) \ - ((((_action == X_REDO) && (_lsn) >= (_logBuf)->ZXR_Lsn) \ - || ((_action == X_UNDO) && (_lsn) < (_logBuf)->ZXR_Lsn)) \ - ? TRUE : (_zfsPool->zp_stats.redid++, FALSE) ) + ((((_action == X_REDO) && (_lsn) >= (_logBuf)->ZXR_Lsn) \ + || ((_action == X_UNDO) && (_lsn) < (_logBuf)->ZXR_Lsn)) \ + ? TRUE : (_zfsPool->zp_stats.redid++, FALSE) ) #endif /* macro to determine the size of the block info section of the log record */ #define ZLOG_BLOCK_INFO_SIZE(_numblks) \ - ((_numblks) * sizeof(BlockInfo_s)) + ((_numblks) * sizeof(BlockInfo_s)) - // This is the old bad name for the PLAY block test + // This is the old bad name for the PLAY block test #define ZLOG_VALID_BLOCK ZLOG_BLOCK_PROCESS - // Should the log record be processed (REDO/UNDO) + // Should the log record be processed (REDO/UNDO) #define ZLOG_BLOCK_PROCESS(_blkinfo) \ - ( ZLOG_BLOCK_VALID(_blkinfo) && !ZLOG_BLOCK_SKIP_FLAG(_blkinfo) ) + ( ZLOG_BLOCK_VALID(_blkinfo) && !ZLOG_BLOCK_SKIP_FLAG(_blkinfo) ) - // Is the block flagged as skip? + // Is the block flagged as skip? #define ZLOG_BLOCK_SKIP_FLAG(_blkinfo) \ - ((_blkinfo).replayState & REPLAY_DONT_PROCESS) + ((_blkinfo).replayState & REPLAY_DONT_PROCESS) - // Does the block have a valid number? + // Does the block have a valid number? #define ZLOG_BLOCK_VALID(_blkinfo) ((_blkinfo).blkNum != 0) /* macro to init information always needed after doing a ZLOG_ObtainRecord */ #define ZLOG_INIT_LOG_RECORD(_operation, _xaction, _buffer, _numblks, _poolblks, _logrecord) \ - ((_buffer) = (_xaction)->ZX_zlogBeast->ZLB_ZfsXasRecovery, \ - (_buffer)->ZXR_PoolBlockCount = (_numblks), \ - (_buffer)->ZXR_FunctionIndex = (_operation), \ - (_poolblks) = ZLOG_START_OF_POOL_BLOCKS(_buffer), \ - (_logrecord) = ZLOG_START_OF_LOG_RECORD(_buffer)) + ((_buffer) = (_xaction)->ZX_zlogBeast->ZLB_ZfsXasRecovery, \ + (_buffer)->ZXR_PoolBlockCount = (_numblks), \ + (_buffer)->ZXR_FunctionIndex = (_operation), \ + (_poolblks) = ZLOG_START_OF_POOL_BLOCKS(_buffer), \ + (_logrecord) = ZLOG_START_OF_LOG_RECORD(_buffer)) /* macro to do binding for transactions */ @@ -1836,136 +1836,136 @@ typedef struct BlockInfo_s { \ /* extern NINT MaxXactionTicks; */\ /* (bind(&(_data)->agent, &(_xaction)->ZX_zlogBeast->ZLB_Buffer->agent), */\ - (bind(&(_data)->agent, &(_xaction)->ZX_zlogBeast->ZLB_Barrier->ZB_Agent), \ - bind(&(_xaction)->xaction.agent, &(_data)->agent), \ - (_data)->state |= CACHE_DIRTY); \ + (bind(&(_data)->agent, &(_xaction)->ZX_zlogBeast->ZLB_Barrier->ZB_Agent), \ + bind(&(_xaction)->xaction.agent, &(_data)->agent), \ + (_data)->state |= CACHE_DIRTY); \ /* if ((Time.in - (_xaction)->timeStamp) >= (MaxXactionTicks >> 1)) */\ /* zASSERT("Too much time has elasped since the begin of Xaction"== NULL);*/\ -} +} #else #define ZLOG_BIND(_xaction, _data) \ /* (bind(&(_data)->agent, &(_xaction)->ZX_zlogBeast->ZLB_Buffer->agent), */\ - (bind(&(_data)->agent, &(_xaction)->ZX_zlogBeast->ZLB_Barrier->ZB_Agent), \ - bind(&(_xaction)->xaction.agent, &(_data)->agent), \ - (_data)->state |= CACHE_DIRTY) + (bind(&(_data)->agent, &(_xaction)->ZX_zlogBeast->ZLB_Barrier->ZB_Agent), \ + bind(&(_xaction)->xaction.agent, &(_data)->agent), \ + (_data)->state |= CACHE_DIRTY) #endif - /* FixFixFix6(Future,If ZLOG mirror becomes a requirement) - * We may have lower layers do the cheap mirroring for us. If - * we must do then +2 is correct plus change code to do 2nd - * block write/read and modify asserts and errors on specific - * file size. - */ + /* FixFixFix6(Future,If ZLOG mirror becomes a requirement) + * We may have lower layers do the cheap mirroring for us. If + * we must do then +2 is correct plus change code to do 2nd + * block write/read and modify asserts and errors on specific + * file size. + */ - /* Get next log block */ + /* Get next log block */ #define ZLOG_NEXT_POOL_LOG_BLOCK( _zlogBeast, _blockNumber ) \ { \ - _blockNumber += 1; \ - zASSERT( _zlogBeast->ZLB_NumberOfLogBlocks > 0 ); \ - if ( _blockNumber >= _zlogBeast->ZLB_NumberOfLogBlocks ) \ - { \ - _blockNumber = 0; \ - } \ + _blockNumber += 1; \ + zASSERT( _zlogBeast->ZLB_NumberOfLogBlocks > 0 ); \ + if ( _blockNumber >= _zlogBeast->ZLB_NumberOfLogBlocks ) \ + { \ + _blockNumber = 0; \ + } \ } - /* Get previous log block */ + /* Get previous log block */ #define ZLOG_PREVIOUS_POOL_LOG_BLOCK( _zlogBeast, _blockNumber ) \ { \ - zASSERT( _zlogBeast->ZLB_NumberOfLogBlocks > 0 ); \ - if ( _blockNumber == 0 ) \ - { \ - _blockNumber = _zlogBeast->ZLB_NumberOfLogBlocks -1; \ - } \ - else \ - { \ - _blockNumber -= 1; \ - } \ + zASSERT( _zlogBeast->ZLB_NumberOfLogBlocks > 0 ); \ + if ( _blockNumber == 0 ) \ + { \ + _blockNumber = _zlogBeast->ZLB_NumberOfLogBlocks -1; \ + } \ + else \ + { \ + _blockNumber -= 1; \ + } \ } #if NSS_DEBUG IS_ENABLED - /* - * This is the header that is placed into '.ZLF' and '.ZLB' files - * so that ZAD can detect version/build information. - */ + /* + * This is the header that is placed into '.ZLF' and '.ZLB' files + * so that ZAD can detect version/build information. + */ typedef struct ZlogZadHeader_s { - LONG ZZH_VersionNumber; /* Version 2 supports ZHH_PoolState */ - LONG ZZH_ZSTOREMajorVersion; - LONG ZZH_ZSTOREMinorVersion; - LONG ZZH_ZSTORESubVersion; - LONG ZZH_ZSTOREBuildNumber; - char ZZH_Description[1000]; /* Area for descriptive user message. - * ZAD can let user fill in - */ - BYTE ZZH_PoolState; /* State of pool when Journal Read. - * Added in Version 2 because we - * can read Journal on an ACTIVE - * pool. - */ - BYTE ZZH_Reserved3; - WORD ZZH_Reserved2; - LONG ZZH_Reserved1[5]; + LONG ZZH_VersionNumber; /* Version 2 supports ZHH_PoolState */ + LONG ZZH_ZSTOREMajorVersion; + LONG ZZH_ZSTOREMinorVersion; + LONG ZZH_ZSTORESubVersion; + LONG ZZH_ZSTOREBuildNumber; + char ZZH_Description[1000]; /* Area for descriptive user message. + * ZAD can let user fill in + */ + BYTE ZZH_PoolState; /* State of pool when Journal Read. + * Added in Version 2 because we + * can read Journal on an ACTIVE + * pool. + */ + BYTE ZZH_Reserved3; + WORD ZZH_Reserved2; + LONG ZZH_Reserved1[5]; } ZlogZadHeader_s; #endif - /*** Global variables ***/ + /*** Global variables ***/ extern CommonBeastOps_s ZlogComnBeastOps; extern LSSSpecificPackUnpackOps_s ZLOG_lssOps[]; - /*** Prototypes ***/ + /*** Prototypes ***/ - /** Public ZLOG functions (requirements of ZLOG specification) **/ + /** Public ZLOG functions (requirements of ZLOG specification) **/ void ZLOG_ObtainRecord( - ZfsXaction_s *zlogXaction, - NINT recordSize ); + ZfsXaction_s *zlogXaction, + NINT recordSize ); void ZLOG_ReleaseRecord( - ZfsXaction_s *zlogXaction ); + ZfsXaction_s *zlogXaction ); void ZLOG_CopyLogicalUndoRecord( - struct ZlogBeast_s *zlogBeast, - struct ZfsXasRecovery_s *zxr); + struct ZlogBeast_s *zlogBeast, + struct ZfsXasRecovery_s *zxr); STATUS ZLOG_RecoveryPhase( - struct GeneralMsg_s *genMsg, - struct ZlogBeast_s *zlogBeast, - NINT mode); + struct GeneralMsg_s *genMsg, + struct ZlogBeast_s *zlogBeast, + NINT mode); void ZLOG_TransactionHomed( - struct ZfsXaction_s *xaction ); + struct ZfsXaction_s *xaction ); void ZLOG_RecoveryClose( - ZlogRecoveryKey_s *zlogKey ); + ZlogRecoveryKey_s *zlogKey ); void ZLOG_RecoveryOpen( - NINT startingPosition, - struct ZfsPool_s *zfsPool, - ZlogRecoveryKey_s *zlogKey ); + NINT startingPosition, + struct ZfsPool_s *zfsPool, + ZlogRecoveryKey_s *zlogKey ); STATUS ZLOG_RecoveryGet( - GeneralMsg_s *genMsg, - ZlogRecoveryKey_s *zlogKey, - NINT direction ); + GeneralMsg_s *genMsg, + ZlogRecoveryKey_s *zlogKey, + NINT direction ); STATUS ZLOG_RecoveryGetLogicalOnly( - GeneralMsg_s *genMsg, - ZlogRecoveryKey_s *zlogKey, - NINT direction ); + GeneralMsg_s *genMsg, + ZlogRecoveryKey_s *zlogKey, + NINT direction ); STATUS ZLOG_InternalRecoveryGet( - GeneralMsg_s *genMsg, - ZlogRecoveryKey_s *zlogKey, - NINT direction ); + GeneralMsg_s *genMsg, + ZlogRecoveryKey_s *zlogKey, + NINT direction ); Time_t ZLOG_RecoveryTimeGet( - ZlogRecoveryKey_s *zlogKey ); + ZlogRecoveryKey_s *zlogKey ); - /** Public ZLOG functions (requirements of other components) **/ + /** Public ZLOG functions (requirements of other components) **/ STATUS Zlog_Construct( struct GeneralMsg_s *genMsg, void *zlogBeast); void Zlog_Destruct( void *zlogBeast ); @@ -1974,42 +1974,42 @@ void Zlog_FlushBlockDoneSignalHandler( struct Agent_s *agent); STATIC NINT Zlog_ZfsPackedSize( void *zlogBeast ); STATIC BYTE *Zlog_ZfsPack( void *zlogBeast, BYTE *storeBuffer ); STATIC BYTE *Zlog_ZfsUnpack( struct GeneralMsg_s *genMsg, - void *zlogBeast, BYTE *storeBuffer); + void *zlogBeast, BYTE *storeBuffer); STATUS Zlog_PoolInitialize( struct GeneralMsg_s *genMsg, - struct ZlogBeast_s *zlogBeast, - BOOL rebuild ); + struct ZlogBeast_s *zlogBeast, + BOOL rebuild ); void Zlog_Throttle( Volume_s *volume, ZfsXaction_s *zlogXaction ); - /** Internal functions **/ + /** Internal functions **/ #if LOG_TEST IS_ENABLED STATUS zlog_LogTestCompare( - BYTE *src1, - BYTE *src2, - NINT len); + BYTE *src1, + BYTE *src2, + NINT len); #endif void zlog_CheckpointTakeSchedule( - ZlogBeast_s *zlogBeast, - NINT state ); + ZlogBeast_s *zlogBeast, + NINT state ); void zlog_CheckpointTakeWorkToDoRoutine( #if ZLOG_USE_SYSTEMS_WORK_TO_DO - zWorkProc_s *work); + zWorkProc_s *work); #else - FsmLite_s *workToDoFsm ); + FsmLite_s *workToDoFsm ); #endif void zlog_ORCommon( - NINT neededLongs, - ZlogBeast_s *zlogBeast, - ZLOGBlockHeader_s *logBlockHeader, - ZfsXaction_s *zlogXaction ); + NINT neededLongs, + ZlogBeast_s *zlogBeast, + ZLOGBlockHeader_s *logBlockHeader, + ZfsXaction_s *zlogXaction ); LONG zlog_CalculateChecksum( LONG *Buffer, NINT NumberOfLONGs ); -STATUS zlog_CommonCreateAndOpen( struct GeneralMsg_s *genMsg, - struct ZlogBeast_s *zlogBeast ); +STATUS zlog_CommonCreateAndOpen( struct GeneralMsg_s *genMsg, + struct ZlogBeast_s *zlogBeast ); NINT zlog_GetNewestCheckpointIndex( ZlogBeast_s *zlogBeast ); @@ -2017,125 +2017,125 @@ NINT zlog_GetOldestCheckpointIndex( ZlogBeast_s *zlogBeast ); void zlog_THSerialized( struct FsmLite_s *fsmLite ); -STATUS zlog_RecoverActivePointer( - GeneralMsg_s *genMsg, - ZlogBeast_s *zlogBeast ); +STATUS zlog_RecoverActivePointer( + GeneralMsg_s *genMsg, + ZlogBeast_s *zlogBeast ); -STATUS zlog_RAPProcessSingleLogBlock( - GeneralMsg_s *genMsg, - ZlogBeast_s *zlogBeast, - NINT *done ); +STATUS zlog_RAPProcessSingleLogBlock( + GeneralMsg_s *genMsg, + ZlogBeast_s *zlogBeast, + NINT *done ); void zlog_LogRecordDump( - ZLOGRecordHeader_s *logRecordHeader, - char *headerMsg, - NINT headerColor ); + ZLOGRecordHeader_s *logRecordHeader, + char *headerMsg, + NINT headerColor ); STATUS zlog_RecoveryVerifyBlock( - GeneralMsg_s *genMsg, - ZlogBeast_s *zlogBeast ); + GeneralMsg_s *genMsg, + ZlogBeast_s *zlogBeast ); STATUS zlog_RGNReal( - GeneralMsg_s *genMsg, - ZlogRecoveryKey_s *zlogKey ); + GeneralMsg_s *genMsg, + ZlogRecoveryKey_s *zlogKey ); STATUS zlog_RGPReal( - GeneralMsg_s *genMsg, - ZlogRecoveryKey_s *zlogKey ); + GeneralMsg_s *genMsg, + ZlogRecoveryKey_s *zlogKey ); STATUS zlog_RecoveryGet( - GeneralMsg_s *genMsg, - ZlogBeast_s *zlogBeast, - ZlogRecoveryKey_s *zlogKey ); + GeneralMsg_s *genMsg, + ZlogBeast_s *zlogBeast, + ZlogRecoveryKey_s *zlogKey ); - STATUS zlog_RGReal( - GeneralMsg_s *genMsg, - ZlogBeast_s *zlogBeast, - ZlogRecoveryKey_s *zlogKey ); + STATUS zlog_RGReal( + GeneralMsg_s *genMsg, + ZlogBeast_s *zlogBeast, + ZlogRecoveryKey_s *zlogKey ); - Buffer_s *zlog_RGReadAndVerifyBlock( - GeneralMsg_s *genMsg, - ZlogBeast_s *zlogBeast, - Blknum_t blockToRead ); + Buffer_s *zlog_RGReadAndVerifyBlock( + GeneralMsg_s *genMsg, + ZlogBeast_s *zlogBeast, + Blknum_t blockToRead ); - STATUS zlog_RGVerifyRecords( - GeneralMsg_s *genMsg, - ZlogBeast_s *zlogBeast, - Buffer_s *buffer, - NINT recordNumber ); + STATUS zlog_RGVerifyRecords( + GeneralMsg_s *genMsg, + ZlogBeast_s *zlogBeast, + Buffer_s *buffer, + NINT recordNumber ); STATUS zlog_ProcessLogBlocks( - GeneralMsg_s *genMsg, - ZlogBeast_s *zlogBeast ); + GeneralMsg_s *genMsg, + ZlogBeast_s *zlogBeast ); STATUS zlog_PLBSingle( - GeneralMsg_s *genMsg, - ZlogBeast_s *zlogBeast, - NINT *done ); + GeneralMsg_s *genMsg, + ZlogBeast_s *zlogBeast, + NINT *done ); STATUS zlog_PLBLogRecords( - GeneralMsg_s *genMsg, - ZlogBeast_s *zlogBeast, - Buffer_s *buffer, - NINT recordNumber, - NINT *done ); + GeneralMsg_s *genMsg, + ZlogBeast_s *zlogBeast, + Buffer_s *buffer, + NINT recordNumber, + NINT *done ); void zlog_CopyLogFileToVolume( - GeneralMsg_s *genMsg, - ZlogBeast_s *zlogBeast, - char *volumeName, - int flags ); + GeneralMsg_s *genMsg, + ZlogBeast_s *zlogBeast, + char *volumeName, + int flags ); STATUS ZLOG_GenerateXML( - ZlogBeast_s *zlogBeast, - NINT bufferLength, - BYTE **bufferAddress, - NINT *retLen ); + ZlogBeast_s *zlogBeast, + NINT bufferLength, + BYTE **bufferAddress, + NINT *retLen ); void zlog_HistogramEvent( - ZlogHistogram_s *histogram, - QUAD event); + ZlogHistogram_s *histogram, + QUAD event); STATUS zlog_PoolSave( - GeneralMsg_s *genMsg, - struct ZfsPool_s *zfsPool ); + GeneralMsg_s *genMsg, + struct ZfsPool_s *zfsPool ); STATUS zlog_PoolRestoreImage( - GeneralMsg_s *genMsg, - struct ZfsPool_s *zfsPool ); + GeneralMsg_s *genMsg, + struct ZfsPool_s *zfsPool ); STATUS zlog_PoolRestoreScan( - GeneralMsg_s *genMsg, - ZlssPool_s *zlssPool, - unicode_t *poolName, - unicode_t *sourceVolumeName ); + GeneralMsg_s *genMsg, + ZlssPool_s *zlssPool, + unicode_t *poolName, + unicode_t *sourceVolumeName ); STATUS zlog_PoolCompare( - GeneralMsg_s *genMsg, - struct ZfsPool_s *zfsPool ); + GeneralMsg_s *genMsg, + struct ZfsPool_s *zfsPool ); STATUS zlog_RecoveryGetNextBlock( - GeneralMsg_s *genMsg, - ZlogRecoveryKey_s *zlogKey ); + GeneralMsg_s *genMsg, + ZlogRecoveryKey_s *zlogKey ); - /** Testing functions **/ + /** Testing functions **/ #if ZLOG_TEST IS_ENABLED void ZLOG_TestMain( - ZlogBeast_s *, - GeneralMsg_s *, - RootBeast_s * ); + ZlogBeast_s *, + GeneralMsg_s *, + RootBeast_s * ); void zlog_TestLoggingApi( - GeneralMsg_s *genMsg, - RootBeast_s *rootBeast, - LocalXid_t localXid, - NINT numberOfRecords ); + GeneralMsg_s *genMsg, + RootBeast_s *rootBeast, + LocalXid_t localXid, + NINT numberOfRecords ); STATUS zlog_TLAWriteSingleRecord( - GeneralMsg_s *genMsg, - RootBeast_s *rootBeast, - ZfsXaction_s *zlogXaction, - NINT recordLength, - WORD state ); + GeneralMsg_s *genMsg, + RootBeast_s *rootBeast, + ZfsXaction_s *zlogXaction, + NINT recordLength, + WORD state ); void zlog_Seed(long seed); NINT zlog_Rnd(NINT range); diff --git a/src/nwnss/zlss/zlogDebug.c b/src/nwnss/zlss/zlogDebug.c new file mode 100644 index 0000000..0c26785 --- /dev/null +++ b/src/nwnss/zlss/zlogDebug.c @@ -0,0 +1,333 @@ +/**************************************************************************** + | + | (C) Copyright 1995-2000 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | The ZFS Log (ZLOG) component of ZSTORE + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2006-12-22 04:32:59 +0530 (Fri, 22 Dec 2006) $ + | + | $RCSfile$ + | $Revision: 1796 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | ZLOG's major debug functions. + | For detailed information about ZLOG see the ZLOG Specification. + | + +-------------------------------------------------------------------------*/ +#include /* NetWare includes */ +#include +#include +#include +#include +#include + +#include /* NSS Library includes */ +#include +#include +#include +#include +#include /* For ZLOG debug */ +#include +#include + +#include "parse.h" +#include "zParams.h" +#include "zfsAsyncio.h" +#include "zfsSuperBlk.h" +#include "zfs.h" +#include "fsm.h" +#include "zlog.h" +#include "comnIO.h" +#include "comnPublics.h" +#include "zfsXTree.h" +#include "pssDebug.h" +#include "zlssStartup.h" +#include "zlssLogicalVolume.h" +#include "xAdminVolume.h" +#include "nssOSAPIs.h" + +#if NSS_DEBUG IS_ENABLED + +/* + * FT_NodeVisit() - + * Recursively visit each node in the free B-Tree to count the + * blocks in the tree. If 'countExtents' is TRUE then the extents + * that the leaves contain will also be counted. + * + * Parameters - + * 'leafLevel' is for internal use. I.E. It is use so we do not read + * in leaves when we are not counting extents. Initial caller + * must point this to a ZERO. + * 'validateTree' when TRUE the complete tree is validated. This + * causes us to read in all the LEAFs so we can validate them. + * To ONLY count the blocks in the tree you can set to FALSE. + */ + +STATUS FT_NodeVisit( + GeneralMsg_s *genMsg, + BOOL countExtents, + BOOL validateTree, + WORD currentLevel, + ZfsPool_s *pool, + Buffer_s *parentBuffer, + Blknum_t *blockCount, + WORD *leafLevel ) +{ + NINT i; + Blknum_t childBlock; + LONG status; + xNode_s *childNode; + Buffer_s *buffer; + xNode_s *node; + IoMsg_s iomsg; + + node = (xNode_s*)parentBuffer->pBuf.data; + currentLevel++; + if ( currentLevel > 20 ) + { + SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); + return zFAILURE; + } + status = ZLVAIPU_FTValidate( genMsg, parentBuffer ); + if ( status != zOK ) + { + return( zFAILURE ); + } + + if (node->header.magic == FXLEAF_MAGIC) + { + DBG_DebugPrintf(CYAN,MSGNot(" FT Leaf %ld(0x%lx)\n"), + parentBuffer->volBlk, parentBuffer->volBlk ); + if (countExtents) + { + for (i = 0; i < node->header.numRecs; i++) + { + *blockCount += node->n.extents[i].lengthOfExtent; + } + } + if ( *leafLevel == 0 ) + { + DBG_DebugPrintf(MAGENTA, + MSGNot("The FT leaves are on level %d (1 relative)\n"), + currentLevel ); + } + *leafLevel = currentLevel; /* The level that leafs are on */ + if ( validateTree ) + { + for (i = 0; i < node->header.numRecs; i++) + { + DBG_DebugPrintf(MAGENTA, MSGNot(" FTE %ld, %ld\n"), + node->n.extents[i].poolBlkNum, + node->n.extents[i].lengthOfExtent); + } + } + } + else if (node->header.magic == FXBRANCH_MAGIC) + { + WORD count; + + count = node->header.numRecs - 1; + *blockCount += count; + + DBG_DebugPrintf(CYAN,MSGNot("FT branch %ld(0x%lx)\n"), + parentBuffer->volBlk, parentBuffer->volBlk ); + /* Visit each child in this branch node */ + for (i = 1; i < node->header.numRecs; i++) + { + if ( !countExtents && !validateTree && (currentLevel+1 == *leafLevel) ) + { /* This is here so we ONLY read one leaf. I.E. the + * first leaf of the lowest left branch. This is + * the leaf that finnaly sets the leafLevel variable. + */ + break; + } + childBlock = node->n.branch[i].child; + READBLK_IO_MSG(iomsg, pool->freeExtent, childBlock, CACHE_UPDATE); + buffer = ZFS_ReadPoolBlk( genMsg, &iomsg ); + if (buffer == NULL) + { + DBG_DebugPrintf(LRED, + MSGNot("VERIFY ERR: VisitFreeNode, readbuffer alloc error\n")); + return( zFAILURE ); + } + DBG_DebugPrintf(CYAN,MSGNot("FT branch %ld(0x%lx) index %u\n"), + parentBuffer->volBlk, parentBuffer->volBlk, i ); + childNode = (xNode_s*)buffer->pBuf.data; + status = FT_NodeVisit( genMsg, countExtents, validateTree, + currentLevel, pool, buffer, blockCount, leafLevel ); + if ( status != zOK) + { + CACHE_RELEASE(buffer); + return status; + } + CACHE_RELEASE(buffer); + } + } + else + { + DBG_DebugPrintf( + LRED,MSGNot("VERIFY ERR: FT_NodeVisit, Not leaf or branch\n")); + SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); + return zFAILURE; + } + + return zOK; +} /* End of FT_NodeVisit() */ + + + +/* + * FT_WalkValidate() - + * Gets the root of the freeTreeBeast btree and begins left + * traversal of the tree to count the number of BLOCKs in the B-Tree. + * + * Parameters - + * 'blockCount' - (Output)The number of blocks that the B-Tree portion + * of the free tree contains. + */ + +STATUS FT_WalkValidate( GeneralMsg_s *genMsg, ZfsPool_s *pool, Blknum_t *blockCount ) +{ + xNode_s *rootNode; + Blknum_t rootBlock; + LONG ccode = zOK; + Buffer_s *buffer; + IoMsg_s iomsg; + WORD leafLevel; /* Zero indicates leaf level is unknown. + * The root of the tree is Level 1. + */ + + *blockCount = 0; + rootBlock = pool->freeExtent->zfsBtree.p.btRoot; + + if ( (rootBlock == 0) || (rootBlock == INVALID_BLK) ) + { + DBG_DebugPrintf( + LRED,MSGNot("%s FT_WalkValidate rootblock is %ld\n"), WHERE, + (unsigned long)rootBlock); + return( zOK ); + } + + /*** We do cache update to lock the tree ***/ + + READBLK_IO_MSG(iomsg, pool->freeExtent, rootBlock, CACHE_UPDATE); + buffer = ZFS_ReadPoolBlk( genMsg, &iomsg ); + if (buffer == NULL) + { + DBG_DebugPrintf(LRED,MSGNot("FT_WalkValidate read error\n")); + return zFAILURE; + } + rootNode = (xNode_s*)buffer->pBuf.data; + + *blockCount += 1; + leafLevel = 0; + if ((ccode = FT_NodeVisit( genMsg, FALSE, TRUE, 0, pool, buffer, blockCount, &leafLevel) ) != zOK) + { + CACHE_RELEASE(buffer); + return ccode; + } + CACHE_RELEASE(buffer); + return ccode; + +} /* End of FT_WalkValidate() */ + + +/**************************************************************************** + * Called from command line parser to display the given Free tree + ****************************************************************************/ +NINT ZfsDisplayFreeTree( + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm) +{ + GeneralMsg_s genMsg; + Pool_s *pool; + STATUS status; + Blknum_t blockCount; + + MPKNSS_LOCK(); + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + pool = COMN_PoolNameLookup( &genMsg, + (unicode_t *)switchDef->ret_value, FALSE, NULL ); + if (pool != NULL) + { + ZlssPool_s *zlssPool; + + if ( !COMN_IsDerivedFrom(pool, zFTYPE_ZLSS_LOGICAL_POOL) ) + { /* Not a ZLSS pool so exit */ + printf(MSGNot("Pool not a ZLSS pool.\n")); + COMN_Release( &pool ); + MPKNSS_UNLOCK(); + return zOK; + } + zlssPool = (ZlssPool_s *)pool; + /* By locking internal volume state to DEACTIVE we + * can ensure the pool state will not change on us. + * Currently, NSS does not have a pool deactive lock!!! + */ + status = COMN_LockVolumeActive( &genMsg, &zlssPool->ZP_ZfsPool->ZFSPOOLvol, FALSE ); + if ( status != zOK ) + { /* Not DEACTIVE */ + printf(MSGNot("Pool not in the ACTIVE state.\n")); + COMN_Release( &pool ); + MPKNSS_UNLOCK(); + return zOK; + } + + DBG_DebugPrintf( LBLUE, MSGNot("***** Pool %U *****\n"), (unicode_t *)switchDef->ret_value ); + status = FT_WalkValidate( &genMsg, zlssPool->ZP_ZfsPool, &blockCount ); + + COMN_UnlockVolumeActive( &zlssPool->ZP_ZfsPool->ZFSPOOLvol, FALSE ); + COMN_Release( &pool ); + + if ( status == zOK ) + { + DBG_DebugPrintf( LBLUE, MSGNot("Free Tree uses %ld blocks\n"), + (unsigned long)blockCount ); + } + else + { + DBG_DebugPrintf( LRED, + MSGNot("FT_WalkValidate returned %ld\n"), + (unsigned long)GetErrno( &genMsg ) ); + } + } + else + { + printf(MSGNot("Pool \"%U\" not found.\n"), + (unicode_t *)switchDef->ret_value ); + } + MPKNSS_UNLOCK(); + return zOK; + +} /* End of ZfsDisplayFreeTree() */ + + + +#endif /* #if NSS_DEBUG IS_ENABLED */ + + + diff --git a/src/nwnss/zlss/zlogFtest.h b/src/nwnss/zlss/zlogFtest.h index f0ddd15..f73dcd5 100644 --- a/src/nwnss/zlss/zlogFtest.h +++ b/src/nwnss/zlss/zlogFtest.h @@ -33,7 +33,7 @@ |--------------------------------------------------------------------------- | This module is used to: | Definitions used by ZLOG and FTEST. - | + | +-------------------------------------------------------------------------*/ #ifndef _ZLOGFTEST_H_ #define _ZLOGFTEST_H_ @@ -43,19 +43,19 @@ struct ZlogRecoveryInfo_s; NINT ZLOG_RecoveryInfoGet( - unicode_t *volumeName, - struct ZlogRecoveryInfo_s *info ); + unicode_t *volumeName, + struct ZlogRecoveryInfo_s *info ); typedef struct ZlogXactionStats_s { - LONG ZRI_RedoMax; /* Maximum redo(s) that we could have done */ - LONG ZRI_RedoActual; /* Actual redo(s) that we did */ - LONG ZRI_UndoMax; /* Maximum undo(s) that we could have done */ - LONG ZRI_UndoActual; /* Actual undo(s) that we did */ + LONG ZRI_RedoMax; /* Maximum redo(s) that we could have done */ + LONG ZRI_RedoActual; /* Actual redo(s) that we did */ + LONG ZRI_UndoMax; /* Maximum undo(s) that we could have done */ + LONG ZRI_UndoActual; /* Actual undo(s) that we did */ } ZlogXactionStats_s; typedef struct ZlogRecoveryInfo_s { - ZlogXactionStats_s ZRI_Zxs;/* Xaction stats */ - Time_t ZRI_ActivationTime; /* Time activation started (UTC) */ + ZlogXactionStats_s ZRI_Zxs;/* Xaction stats */ + Time_t ZRI_ActivationTime; /* Time activation started (UTC) */ } ZlogRecoveryInfo_s; #endif /* #ifndef _ZLOGFTEST_H_ */ diff --git a/src/nwnss/zlss/zlogUnitTest.c b/src/nwnss/zlss/zlogUnitTest.c new file mode 100644 index 0000000..3e94ec7 --- /dev/null +++ b/src/nwnss/zlss/zlogUnitTest.c @@ -0,0 +1,646 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | The ZFS Log (ZLOG) component of ZFS + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Perform all ZLOG unit tests. + | + +-------------------------------------------------------------------------*/ +#include +#include +#include + +#if NSS_DEBUG IS_ENABLED + +#include /* NSS Library */ +#include +#include +#include +#include + +#include "zParams.h" + +#include "zfs.h" +#include "zlog.h" +#include "comnIO.h" +#include "comnPublics.h" +#include "zlssStartup.h" + +#if ZLOG_TEST IS_ENABLED + +/****** + + + This contains ZLOG's unit test code. The code was used + with mempool.c to test most of the functions before we had persistent + storage. The code may be of use when changes are made to the ZLOG API. + This code works with zfspool.c + + Execution Requirements/Assumptions + Synchronous and blocking + + September 2, 1997 + This file was removed from NSS build because it has not been + kept up-to-date with ZLOG changes. + +******/ + +// /* Used to pass a useable rootbeast to XAS part of test in zlog.c */ +//RootBeast_s *ZLOGMess; + +int ZLOGTMCount; /* Global to prevent re-entry */ +//extern NINT ZlogUnitTest; /* Is /ZLOG on command line? */ + + +void ZLOG_TestMain( ZlogBeast_s *zlogBeast, + GeneralMsg_s *genMsg, + RootBeast_s *rootBeast ) + +{ + + LocalXid_t localXid; + + ASSERT_MPKNSS_LOCK(); + ++ZLOGTMCount; +#if 0 + /* Kludge - so we only run once */ + if (ZLOGTMCount > 1) + { /* We only run our tests once because of global variables + and once is enough. */ + return; + } +#endif + localXid.unique = 2; + localXid.restartCount = 343; + aprintf(CYAN,MSGNot("\nZLOG unit test code started for the %d time\n"), ZLOGTMCount); + + /*** Log a mutliple record transaction ***/ + + aprintf(CYAN,MSGNot(" ZLOG unit test code - Logging API test\n")); + zlog_TestLoggingApi( genMsg, rootBeast, localXid, 0 ); + +#if 0 + /*** Shutdown the transaction system ***/ + + /* Recovery will only be run when the logging system is inactive, + because the logging system is not inactive in this test we must + shut it down. The only thing that we must do (since only our + test uses the logging system) is to force the current log block + out without getting a new log block. */ + +#if 0 + /* The delay is a kludge because logging API test is async + and I do not want to add sync code. */ + delay( 4*1000 ); +#endif + /* Do we need to flush the current log block? */ + if ( zlogBeast->ZLB_Buffer != NULL ) + { /* Yes - We must flush current log block because the timeout + code has not yet been written. This code simulates a + timeout. */ + + ZLOGBlockHeader_s *logBlockHeader; +#if ZLOG_DEBUG IS_ENABLED + LONG *unusedArea; +#endif + + logBlockHeader = (ZLOGBlockHeader_s *)zlogBeast->ZLB_Buffer->pBuf.data; + /* Mark why we are writing and ensure debug bit set correctly */ +#if ZLOG_DEBUG IS_ENABLED + logBlockHeader->ZLBH_Status = ZLBH_S_TIMEOUT | ZLBH_S_DEBUG; +#else + logBlockHeader->ZLBH_Status = ZLBH_S_TIMEOUT; +#endif + +#if ZLOG_DEBUG IS_ENABLED + /* Debug. Zero all of the unused longs */ + if ( logBlockHeader->ZLBH_NumberOfUnusedLongs != 0 ) + { /* My doc does not say what memset() does if length is zero + so best not to find out. */ + unusedArea = ((LONG *)logBlockHeader) + + (((1 << zlogBeast->ZFSLOGblkSizeShift)/4) - logBlockHeader->ZLBH_NumberOfUnusedLongs); + memset( unusedArea, 0, + ( (size_t)logBlockHeader->ZLBH_NumberOfUnusedLongs) * + ( sizeof(LONG)/sizeof( unsigned char) ) ); + } + logBlockHeader->ZLBH_EndTime = (LONG)microSecondTimer(); +#endif + logBlockHeader->ZLBH_Checksum = 0; + logBlockHeader->ZLBH_Checksum = 0 - zlog_CalculateChecksum( + (LONG *)logBlockHeader, + ((1 << zlogBeast->ZFSLOGblkSizeShift)/4) - logBlockHeader->ZLBH_NumberOfUnusedLongs ); + /* Done updating buffer so we can now release exclusive + latch. defaultFlushWait must be able to get a shared latch + on the buffer to write it. */ + CACHE_DIRTY_RELEASE( zlogBeast->ZLB_Buffer ); + cacheFlushMyCache(&zlogBeast->ZFSLOGroot.storage.info->mycache); + /* Zap so next caller to ZLOGObtainRecord will know to get the + next block. */ + zlogBeast->ZLB_Buffer = NULL; + /* To write we simply note that we would like to do a flush of + our buffer. */ + defaultFlushWait(&zlogBeast->ZFSLOGroot.storage.info->mycache.agent); + /* Track blocks used for checkpointing determination */ + zlogBeast->ZLB_LogBlockFilledInSinceCheckpointCount++; + zlogBeast->ZLB_LogBlockFilledInCount++; + /* Update the active pointer */ + ZLOG_NEXT_POOL_LOG_BLOCK( zlogBeast, + zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber ); + } + + /*** Recover the transactions we logged ***/ + + /* Set up the active pointer to fake a checkpoint read */ + zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber = 0; + zlogBeast->ZLB_P.ZLBP_ActivePointerLsn = 0; + /* Run though the recover code */ +// aprintf(CYAN,MSGNot(" ZLOG unit test code - Recovery Phase test 1\n")); + if ( ZLOG_RecoveryPhase( genMsg, zlogBeast ) != zOK ) + { + WARN( "Error from ZLOGRecoveryPhase" == NULL ); + } +// aprintf(CYAN,MSGNot(" ZLOG unit test code - Recovery Phase Test 1 back\n")); + + /*** Recover the transaction we logged again ***/ + + /*** Shutdown the transaction system ***/ + + /* Recovery will only be run when the logging system is inactive, + because the logging system is not inactive in this test we must + shut it down. The only thing that we must do (since only our + test uses the logging system) is to force the current log block + out without getting a new log block. */ + +#if 0 + /* The delay is a kludge because logging API test is async + and I do not want to add sync code. */ + delay( 4*1000 ); +#endif + + /* Do we need to flush the current log block? */ + if ( zlogBeast->ZLB_Buffer != NULL ) + { /* Yes - We must flush current log block because the timeout + code has not yet been written. This code simulates a + timeout. */ + + ZLOGBlockHeader_s *logBlockHeader; +#if ZLOG_DEBUG IS_ENABLED + LONG *unusedArea; +#endif + + logBlockHeader = (ZLOGBlockHeader_s *)zlogBeast->ZLB_Buffer->pBuf.data; + /* Mark why we are writing and ensure debug bit set correctly */ +#if ZLOG_DEBUG IS_ENABLED + logBlockHeader->ZLBH_Status = ZLBH_S_TIMEOUT | ZLBH_S_DEBUG; +#else + logBlockHeader->ZLBH_Status = ZLBH_S_TIMEOUT; +#endif + +#if ZLOG_DEBUG IS_ENABLED + /* Debug. Zero all of the unused longs */ + if ( logBlockHeader->ZLBH_NumberOfUnusedLongs != 0 ) + { /* My doc does not say what memset() does if length is zero + so best not to find out. */ + unusedArea = ((LONG *)logBlockHeader) + + (((1 << zlogBeast->ZFSLOGblkSizeShift)/4) - logBlockHeader->ZLBH_NumberOfUnusedLongs); + memset( unusedArea, 0, + ( (size_t)logBlockHeader->ZLBH_NumberOfUnusedLongs) * + ( sizeof(LONG)/sizeof( unsigned char) ) ); + } + logBlockHeader->ZLBH_EndTime = (LONG)microSecondTimer(); +#endif + logBlockHeader->ZLBH_Checksum = 0; + logBlockHeader->ZLBH_Checksum = 0 - zlog_CalculateChecksum( + (LONG *)logBlockHeader, + ((1 << zlogBeast->ZFSLOGblkSizeShift)/4) - logBlockHeader->ZLBH_NumberOfUnusedLongs ); + /* Done updating buffer so we can now release exclusive + latch. defaultFlushWait must be able to get a shared latch + on the buffer to write it. */ + CACHE_DIRTY_RELEASE( zlogBeast->ZLB_Buffer ); + cacheFlushMyCache(&zlogBeast->ZFSLOGroot.storage.info->mycache); + /* Zap so next caller to ZLOGObtainRecord will know to get the + next block. */ + zlogBeast->ZLB_Buffer = NULL; + /* To write we simply note that we would like to do a flush of + our buffer. */ + defaultFlushWait(&zlogBeast->ZFSLOGroot.storage.info->mycache.agent); + /* Track blocks used for checkpointing determination */ + zlogBeast->ZLB_LogBlockFilledInSinceCheckpointCount++; + zlogBeast->ZLB_LogBlockFilledInCount++; + /* Update the active pointer */ + ZLOG_NEXT_POOL_LOG_BLOCK( zlogBeast, + zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber ); + } + +// aprintf(CYAN,MSGNot(" ZLOG unit test code - Recovery Phase Test 1 back 3\n")); + /* Do we need to flush the current log block? */ + + /* Set up the active pointer to fake a checkpoint read */ + zlogBeast->ZLB_P.ZLBP_ActivePointerBlockNumber = 0; + zlogBeast->ZLB_P.ZLBP_ActivePointerLsn = 0; + /* Run though the recover code */ +// aprintf(CYAN,MSGNot(" ZLOG unit test code - Recovery Phase test 2\n")); + if ( ZLOG_RecoveryPhase( genMsg, zlogBeast ) != zOK ) + { + WARN( "Error from ZLOGRecoveryPhase" == NULL ); + } +#endif /* #if 0 */ + + aprintf(CYAN,MSGNot("ZLOG unit test code completed\n")); +#if 0 + /* Leave results on screen for a little while */ + delay( 4*1000 ); +#endif + +} /* End of ZLOG_TestMain */ + + +/**** + + + This unit test verifies the logging API. + + +****/ + + + +/* + + zlog_TestLoggingApi( RootBeast_s *rootBeast, LocalXid_t localXid, NINT numberOfRecords ); + + + Can only be called once because of use of ZlogXas global above. This + unit test calls all 4 logging functions and fills the log file with + numerous log records. + + If numberOfRecords == 0 then the number will be randomly generated. + + Input + Latches + beast Not owned + recovery Not owned + + +*/ + + +void zlog_TestLoggingApi( + GeneralMsg_s *genMsg, + RootBeast_s *rootBeast, + LocalXid_t localXid, + NINT numberOfRecords ) + +{ + + ZfsXaction_s *zlogTestXas; /* Transaction System not done so fake it */ + STATUS status; + NINT recordLength; + WORD state; + + ASSERT_MPKNSS_LOCK(); +// ZLOGMess = rootBeast; + /*** Dummy up ZfsXaction_s and ZioLog_s structures ***/ + + if ( numberOfRecords == 0 ) + { /* Produces 1000 to 3000 */ + numberOfRecords = zlog_Rnd(2000) + 1000; + /* Produces 1 to 10 */ +// numberOfRecords = zlog_NumberOfLogRecords(); + } + + zlogTestXas = BeginXLocal( rootBeast->vol.volume ,BXL_DEFAULT); + if ( zlogTestXas == NULL ) + { + WARN("Unable to obtain memory for Xaction Test"==NULL); + return ; + } + /* Dummy up a XID */ +// zlogTestXas->localXid = localXid; + + /*** Now we can test ZLOG transaction logging API */ + state = XAS_XR_TS_START; + recordLength = zlog_SizeofRecord(); + + for ( ; numberOfRecords > 1; numberOfRecords-- ) + { + + status = zlog_TLAWriteSingleRecord( genMsg, + rootBeast, + zlogTestXas, + recordLength, + state ); + if ( status != zOK ) + { + goto error; + } + /* Start on next information */ + recordLength = zlog_SizeofRecord(); + /* Items that must be setup for each ZLOGObtainRecord call */ + state = XAS_XR_TS_MIDDLE; + } + + state |= XAS_XR_TS_END; + status = zlog_TLAWriteSingleRecord( genMsg, + rootBeast, + zlogTestXas, + recordLength, + state ); +// free( zlogTestXas ); + EndXlocal( zlogTestXas ); + return; + +error:; + /* Free the transaction block that we got for this test */ +// free( zlogTestXas ); + EndXlocal( zlogTestXas ); + return; + +} + + +STATUS zlog_TLAWriteSingleRecord( + GeneralMsg_s *genMsg, + RootBeast_s *rootBeast, + ZfsXaction_s *zlogXaction, + NINT recordLength, + WORD state ) + +{ + + NINT longLength; + BYTE *userArea; + ZlogBeast_s *zlogBeast; + + ASSERT_MPKNSS_LOCK(); +#if 1 + /* Items that must be setup for each ZLOGObtainRecord call */ +// XAS_SetTransactionState( zlogXaction, state ); +#endif + + /* Go out an get the record */ + ZLOG_ObtainRecord( zlogXaction, recordLength ); + zlogBeast = zlogXaction->ZX_zlogBeast; + + /* Fill in next information */ +// ... Xid record number state size? + /* Do required binds. See Transaction System documentation. Because + the unit test has no 'metadata' it simply binds the log buffer to + the transaction. */ + bind( &zlogBeast->ZLB_CommitAgent, &zlogXaction->xaction.agent ); +// ... + + userArea = (BYTE *)(zlogBeast->ZLB_ZfsXasRecovery + 1); + + /* Callers must initialize after return form this function. */ + zlogBeast->ZLB_ZfsXasRecovery->ZXR_FunctionIndex = 0xBEEEBEEEuL; + zlogBeast->ZLB_ZfsXasRecovery->ZXR_PoolBlockCount = 0; + + longLength = recordLength / 4; + /* NOTE that assuming that you own every thing in the length field + is bogus. The Unit Test is taking advantage of undocumented + implementation dependent information. If you do the same you may + have bugs in your code. */ +#if 0 + for ( ; longLength > 0; longLength-- ) + { /* Fill area with verification information. We force + into BYTEs because that should be enough information to + unit test code. */ + /* This is a internal element */ + *userArea = (BYTE)zfsAsyncIO->ZLOG_zaLogRecordsLeft; + userArea++; + *userArea = (BYTE)zlogBeast->ZLOG_ZaLsn; + userArea++; + *userArea = (BYTE)zfsAsyncIO->ZLOG_ZaBufferLength; + userArea++; + /* This is a internal element */ + *userArea = (BYTE)zfsAsyncIO->ZLOG_zaTransactionId.unique; + userArea++; + } +#endif + + if ( state &= XAS_XR_TS_END ) + { + ZLOG_ReleaseRecordAndLogEnd( zlogXaction ); + } + else + { + ZLOG_ReleaseRecord( zlogXaction ); + } + /* This ends calls related to current information */ + + return zOK; +} + + +/* + + Produces a number from 1 to 10 with the following frequency. + + 0 - 0% + 1 - 51% + 2 - 20% + 3 - 10% + 4 - 5% + 5 - 4% + 6 - 4% + 7 - 2% + 8 - 2% + 9 - 1% + 10 - 1% + + This function MUST NEVER return 0. + +*/ + +static int zlogLRChances[11] = { 0, 51, 71, 81, 86, 90, 94, 96, 98, 99, 100 }; + +NINT zlog_NumberOfLogRecords() + +{ + + NINT rn,i; + + ASSERT_MPKNSS_LOCK(); + rn = zlog_Rnd(100); + for ( i=1; i < 11; i++ ) + { + if ( rn < zlogLRChances[i] ) + { + return i; + } + } + /* Will not get here, but compiler does not know this */ + return 1; + +} + + +NINT zlog_SizeofRecord() + +{ + + NINT rn; + + ASSERT_MPKNSS_LOCK(); + rn = zlog_Rnd(10); /* Produces 0 through 9 */ + if ( rn < 7 ) + { /* 70% chance */ + rn = zlog_Rnd(90)+10; /* Produces 10 to 99 */ + return( rn ); + } + rn = zlog_Rnd(10); + if ( rn < 8 ) + { /* 24% chance */ + rn = zlog_Rnd( ZLOG_MAXIMUM_RECORD_SIZE/3 ); + return( rn ); + } + /* 6% chance */ + rn = zlog_Rnd( ZLOG_MAXIMUM_RECORD_SIZE + 1 ); + return( rn ); + + +} + + + +/* + + Stole from rnd.c. ZLOG does not use rnd.c because we need to + be able to re-generate random order. I.E. Based on if other components + are using rnd.c then we will not get same sequence of random numbers. + +*/ + + +static SNINT zlogNextRnd = 2; + +void zlog_Seed (long seed) +{ + zlogNextRnd = (seed == 0) ? 1 : seed; +} + +NINT zlog_Rnd (NINT range) +{ + SNINT b, r; + + ASSERT_MPKNSS_LOCK(); + r = b = zlogNextRnd; + r <<= 1; + if (b >= 0) + { + r ^= 0x140A0445; + } + zlogNextRnd = r; + return (range == 0) ? r : (r % range); +} + +#endif /* #if ZLOG_TEST IS_ENABLED */ + + +/* + * This is a unit test of the new ZLOG XAS Recovery API. This code + * should be left here for future generations. The name will be + * changed when the real XactionRecover() is completed. Also + * move to above #endif above so that no code is generated when + * ZLOG_TEST is disabled. + */ + +STATUS tstXactionRecover( + GeneralMsg_s *genMsg, + struct ZfsPool_s *pool ) +{ + +#if ZLOG_TEST IS_ENABLED + + STATUS status; + ZlogRecoveryKey_s zlogKey; /*** This is a STRUCTURE (not a pointer) ***/ + ZfsXasRecovery_s *recoveryInfo; + unsigned long lastLsn; + unsigned int count; + + + ASSERT_MPKNSS_LOCK(); + if ( ZlogUnitTest ) + { +// aprintf( CYAN, MSGNot("Start backward traversal\n")); + ZLOG_RecoveryOpen( ZLOG_RECOVERY_END, pool, &zlogKey ); + while ( (status = ZLOG_RecoveryGet( genMsg, &zlogKey, ZLOG_RG_PREVIOUS )) == zOK ) + { /* Process log record here */ + recoveryInfo = zlogKey.ZRK_ZfsXasRecovery; +// aprintf(CYAN,MSGNot("LSN - %ld\n"),(unsigned long)recoveryInfo->ZXR_Lsn); + /* ... */ + } + ZLOG_RecoveryClose( &zlogKey); + if ( GetErrno(genMsg) != zERR_ZLOG_NO_MORE_RECORDS ) + { /* Fail if not expected error */ + return zFAILURE; + } +// aprintf( CYAN, MSGNot("End backward traversal\n")); +// delay( 1 * 1000 ); + + ZLOG_RecoveryOpen( ZLOG_RECOVERY_BEGIN, pool, &zlogKey ); + count = 0; + lastLsn = 0; + while ( (status = ZLOG_RecoveryGet( genMsg, &zlogKey, ZLOG_RG_NEXT )) == zOK ) + { /* Process log record here */ + recoveryInfo = zlogKey.ZRK_ZfsXasRecovery; + count++; + lastLsn = (unsigned long)recoveryInfo->ZXR_Lsn; +// aprintf(CYAN,MSGNot("LSN - %ld\n"),(unsigned long)recoveryInfo->ZXR_Lsn); + /* ... */ + } + + ZLOG_RecoveryClose( &zlogKey); +// aprintf( CYAN, MSGNot("End forward traversal\n")); +// delay( 1 * 1000 ); + + if ( GetErrno(genMsg) == zERR_ZLOG_NO_MORE_RECORDS ) + { /* Undo the error */ + ClearErrno( genMsg ); + status = zOK; + } + else + { + aprintf(CYAN,MSGNot("Recovery Unit Test failed\n")); + } + aprintf(CYAN,MSGNot("Highest LSN - %ld\n"), lastLsn ); + aprintf(CYAN,MSGNot("Number of recovery log records - %d\n"),count); + return status; + + } +#endif + return zOK; + +} /* End of XactionRecover() */ + +#endif diff --git a/src/nwnss/zlss/zlssCmdline.c b/src/nwnss/zlss/zlssCmdline.c index 439f065..6951cf7 100644 --- a/src/nwnss/zlss/zlssCmdline.c +++ b/src/nwnss/zlss/zlssCmdline.c @@ -1902,7 +1902,7 @@ STATUS doMSAPRebuild( else { printf( MSG("Could not rebuild MSAP block - NSS error %d.\n",602), - GetErrno(&dummyGenMsg) ); + GetErrno(&dummyGenMsg) ); } } else @@ -1917,7 +1917,7 @@ STATUS doMSAPRebuild( printf(MSG("Pool \"%U\" not found.\n",604), (unicode_t *)switchDef->ret_value ); } - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return zOK; } /* End of doMSAPRebuild() */ @@ -1977,7 +1977,7 @@ STATUS doSpeedTest( { printk("<1>Read error %ld\n", (unsigned long)GetErrno(&dummyGenMsg) ); } - else + else { cacheReleaseToss(buffer); } @@ -1990,7 +1990,7 @@ STATUS doSpeedTest( printf(MSG("Pool \"%U\" not found.\n",604), (unicode_t *)switchDef->ret_value ); } - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return zOK; } /* End of doSpeedTest() */ @@ -2026,7 +2026,7 @@ NINT gCancelWait = FALSE; /* * Hangs console thread until specific volume is DEACTIVE state. This is done - * via "nss /waitfordeactive=volname" in debug systems. Used to test + * via "nss /waitfordeactive=volname" in debug systems. Used to test * disabling volumes via I/O errors. * * Warning: THIS will hang main console so you will not be able to type @@ -2092,7 +2092,7 @@ again: } /* * Hangs console thread until specific volume is in ACTIVE state. This is done - * via "nss /waitforactive=volname" in debug systems. Used to test + * via "nss /waitforactive=volname" in debug systems. Used to test * disabling volumes via I/O errors. * * Warning: THIS will hang main console so you will not be able to type @@ -2157,7 +2157,7 @@ again: } /************************************************************************** - * + * ***************************************************************************/ STATUS doOutOfSpace( struct PCLSwitchDef_s *switchDef, @@ -2290,7 +2290,7 @@ void zDebugHexDump( viewLine[column*3*size + DHD_COLUMN_HEX + 0] = '|'; viewLine[column*3*size + DHD_COLUMN_HEX + 1] = ' '; } - + switch ( size ) { case 4: @@ -2358,7 +2358,7 @@ void DebugDisplayBlock( ZfsPool_s *pool, Buffer_s *buffer ) { /* Dump in Human form */ switch (*(LONG *)buffer->pBuf.data) { - case NAMETREE_MAGIC: + case NAMETREE_MAGIC: { NameTreeParms_s parms; Node_s *node = (Node_s *)buffer->pBuf.data; @@ -2463,17 +2463,17 @@ NINT DebugCompareBlock( } else { - node = (LONG *)buffer->pBuf.data; - - if ( *(node+location) != value ) - { - cacheReleaseToss(buffer); - return zOK; - } - DBG_DebugPrintf( CYAN, MSGNot("Match block %Lx (%Ld.)\r\n"), - (SQUAD)block, (SQUAD)block ); - DebugDisplayBlock( pool, buffer ); - cacheReleaseToss(buffer); + node = (LONG *)buffer->pBuf.data; + + if ( *(node+location) != value ) + { + cacheReleaseToss(buffer); + return zOK; + } + DBG_DebugPrintf( CYAN, MSGNot("Match block %Lx (%Ld.)\r\n"), + (SQUAD)block, (SQUAD)block ); + DebugDisplayBlock( pool, buffer ); + cacheReleaseToss(buffer); } return zOK; @@ -2517,7 +2517,7 @@ STATUS doBlkNumToRead( printErrorAndReturn: printf(MSGNot("Volume not found or specifed.\n")); } - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return zOK; } @@ -2629,7 +2629,7 @@ void ZLSSVOL_DisplayVolumeIDs(void) { lv = TRUE; } - + COMN_GetVolumeName(&genMsg,volume,vname,NELEMS(vname)); active = FALSE; @@ -2754,17 +2754,17 @@ STATUS GetNSSVolumeHostPool(BYTE *volumeName, BYTE *poolName) COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); // Change volume name to unicode. - if ((status = COMN_NameToUnicode(&genMsg, NSS_UNI_CONVERSION_RAW, volumeName, + if ((status = COMN_NameToUnicode(&genMsg, NSS_UNI_CONVERSION_RAW, volumeName, uni_volName, unisizeof(uni_volName))) != zOK) { - DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, + DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, MSGNot("Problems converting volume name to unicode.\n"))); goto Exit; } // Check if volume is an NSS volume. if((volume = COMN_VolumeNameLookup(&genMsg,uni_volName,FALSE,NULL)) == NULL) { - DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, + DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, MSGNot("Problem looking up the volume information in COMN_VolumeNameLookup.\n"))); status = zFAILURE; goto Exit; @@ -2786,7 +2786,7 @@ STATUS GetNSSVolumeHostPool(BYTE *volumeName, BYTE *poolName) if (status == zOK) { - status = LB_UnicodeToByte( NSS_UNI_CONVERSION_RAW, poolName, + status = LB_UnicodeToByte( NSS_UNI_CONVERSION_RAW, poolName, sizeof(pname), pname, NULL); } } @@ -2801,8 +2801,8 @@ Exit: #define ADMIN_VOL_PATH MSGNot("_ADMIN:/Volumes/") #define ADMIN_POOL_PATH MSGNot("_ADMIN:/Pools/") -#define VolAttrBlockSize "VOLUME BLOCK SIZE" -#define VolAttrMounted "MOUNTED" +#define VolAttrBlockSize "VOLUME BLOCK SIZE" +#define VolAttrMounted "MOUNTED" #define VolAttrLastModified "LASTMODIFIED" #define PoolNumberVols "POOL_NUM_VOLS:" @@ -2853,7 +2853,7 @@ Exit: #define NSSVolSlvgPurgeableBytes "VOL_SLVG_PURGE:" #define NSSVolSlvgNonPurgeable "VOL_SLVG_NON_PURGE:" -#define NSSVolSlvgDeletedFiles "VOL_SLVG_DELETED_FILES:" +#define NSSVolSlvgDeletedFiles "VOL_SLVG_DELETED_FILES:" #define NSSVolSlvgOldestTime "VOL_SLVG_OLDEST_TIME:" #define NSSVolSlvgMinKeep "VOL_SLVG_MIN_KEEP_SECS:" #define NSSVolSlvgMaxKeep "VOL_SLVG_MAX_KEEP_SECS:" @@ -2873,7 +2873,7 @@ Exit: #define FileArchived "FILE_LAST_ARCHIVE:" const char FIELD_SEPARATOR = '\n'; -#define GET_VOLUME_PROPERTIES 0x00000089 +#define GET_VOLUME_PROPERTIES 0x00000089 /******************************************************************************* * GetNSSPoolProperties * @@ -2885,7 +2885,7 @@ const char FIELD_SEPARATOR = '\n'; STATUS GetNSSPoolProperties(BYTE *poolName, NINT retBufLen, BYTE *retBuffer, NINT *retLen) { - BYTE *retBuf = NULL; + BYTE *retBuf = NULL; size_t len = 0; BYTE path[zMAX_FULL_NAME]; Key_t rootKey = 0, fileKey = 0; @@ -2905,7 +2905,7 @@ STATUS GetNSSPoolProperties(BYTE *poolName, NINT retBufLen, BYTE *retBuffer, NIN MPKNSS_UNLOCK(); if ((status = zRootKey(0, &rootKey)) != zOK) { - DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, + DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, MSGNot("Failed to get key, status = %d\n."), status)); printf("\nGetNSSPoolProperties - Failed to get root key, status = %d\n.", status); MPKNSS_LOCK(); @@ -2915,14 +2915,14 @@ STATUS GetNSSPoolProperties(BYTE *poolName, NINT retBufLen, BYTE *retBuffer, NIN // NSS admin pools directory. sprintf(path, "%s%s", ADMIN_POOL_PATH, poolName); printf("\nGetNSSPoolProperties - before zOpen, path = %s\n", path); - if ((status = zOpen(rootKey, - zNSS_TASK, - zNSPACE_LONG|zMODE_UTF8, - path, - zRR_READ_ACCESS, + if ((status = zOpen(rootKey, + zNSS_TASK, + zNSPACE_LONG|zMODE_UTF8, + path, + zRR_READ_ACCESS, &fileKey)) != zOK) { - DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, + DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, MSGNot("Failed to open file, status = %d\n."), status)); printf("\nGetNSSPoolProperties - Failed to get file, status = %d\n.", status); MPKNSS_LOCK(); @@ -2930,65 +2930,65 @@ STATUS GetNSSPoolProperties(BYTE *poolName, NINT retBufLen, BYTE *retBuffer, NIN } getInfoMask = zGET_TIMES_IN_SECS | zGET_IDS | zGET_VOLUME_INFO | zGET_POOL_INFO | zGET_VOL_SALVAGE_INFO; - if ((status = zGetInfo(fileKey, getInfoMask, sizeof(info), + if ((status = zGetInfo(fileKey, getInfoMask, sizeof(info), zINFO_VERSION_A, &info)) != zOK) { - DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, + DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, MSGNot("Failed in zGetInfo, status = %d\n."), status)); printf("\nGetNSSPoolProperties - Failed in zGetInfo, status = %d\n.", status); MPKNSS_LOCK(); goto Exit; } MPKNSS_LOCK(); - // Pool State - sprintf(&retBuf[len], "Pool ID : " ); + // Pool State + sprintf(&retBuf[len], "Pool ID : " ); len += strlen(&retBuf[len]); (void)LB_GUIDToString( &info.pool.poolID, retBufLen-len, &retBuf[len] ); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%c", FIELD_SEPARATOR); + sprintf(&retBuf[len], "%c", FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "NDS Object ID : " ); + sprintf(&retBuf[len], "NDS Object ID : " ); len += strlen(&retBuf[len]); (void)LB_GUIDToString( &info.pool.ndsObjectID, retBufLen-len, &retBuf[len] ); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%c", FIELD_SEPARATOR); + sprintf(&retBuf[len], "%c", FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%ld%c", "Pool "NSSVolState, - info.pool.poolState, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%ld%c", "Pool "NSSVolState, + info.pool.poolState, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%lx%c", "Pool Namespaces : ", - info.pool.nameSpaceMask, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%lx%c", "Pool Namespaces : ", + info.pool.nameSpaceMask, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%Ld%c", "Pool total space : ", - info.pool.totalSpace, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Pool total space : ", + info.pool.totalSpace, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%016Lx%c", "Features enabled : ", - info.pool.features.enabled, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%016Lx%c", "Features enabled : ", + info.pool.features.enabled, FIELD_SEPARATOR); len += strlen(&retBuf[len]); -// sprintf(&retBuf[len], "%s%016Lx%c", "Features enableModMask :", -// info.pool.features.enableModMask, FIELD_SEPARATOR); +// sprintf(&retBuf[len], "%s%016Lx%c", "Features enableModMask :", +// info.pool.features.enableModMask, FIELD_SEPARATOR); // len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%016Lx%c", "Features supported : ", - info.pool.features.supported, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%016Lx%c", "Features supported : ", + info.pool.features.supported, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%Ld%c", "Pool Used Space:", - info.pool.numUsedBytes, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Pool Used Space:", + info.pool.numUsedBytes, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%Ld%c", "Pool purgeable Space:", - info.pool.purgeableBytes, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Pool purgeable Space:", + info.pool.purgeableBytes, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%Ld%c", "Pool non-purgeable Space:", - info.pool.nonPurgeableBytes, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Pool non-purgeable Space:", + info.pool.nonPurgeableBytes, FIELD_SEPARATOR); len += strlen(&retBuf[len]); status = zOK; @@ -3030,7 +3030,7 @@ Exit: STATUS GetNSSVolumeProperties(BYTE *volumeName, NINT retBufLen, BYTE *retBuffer, NINT *retLen) { BYTE poolName[zMAX_COMPONENT_NAME]; - BYTE *retBuf = NULL; + BYTE *retBuf = NULL; size_t len = 0; BYTE path[zMAX_FULL_NAME]; Key_t rootKey = 0, fileKey = 0; @@ -3039,7 +3039,7 @@ STATUS GetNSSVolumeProperties(BYTE *volumeName, NINT retBufLen, BYTE *retBuffer, STATUS status; ASSERT_MPKNSS_LOCK(); - + status = zOK; // Let's allocate retBuf, a large buffer. When we copy retBuf to retBuffer, @@ -3052,12 +3052,12 @@ STATUS GetNSSVolumeProperties(BYTE *volumeName, NINT retBufLen, BYTE *retBuffer, printf("\nGetNSSVolumeProperties - zalloc failed returning zFAILURE"); goto Exit; } - + // Get the root key MPKNSS_UNLOCK(); if ((status = zRootKey(0, &rootKey)) != zOK) { - DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, + DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, MSGNot("Failed to get key, status = %d\n."), status)); printf("\nGetNSSVolumeProperties - Failed to get root key, status = %d\n.", status); MPKNSS_LOCK(); @@ -3068,24 +3068,24 @@ STATUS GetNSSVolumeProperties(BYTE *volumeName, NINT retBufLen, BYTE *retBuffer, // NSS admin volumes directory. sprintf(path, "%s%s", ADMIN_VOL_PATH, volumeName); printf("\nGetNSSVolumeProperties - before zOpen, path = %s\n", path); - if ((status = zOpen(rootKey, zNSS_TASK, zNSPACE_LONG|zMODE_UTF8, + if ((status = zOpen(rootKey, zNSS_TASK, zNSPACE_LONG|zMODE_UTF8, path, zRR_READ_ACCESS, &fileKey)) != zOK) { - DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, + DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, MSGNot("Failed to open file, status = %d\n."), status)); printf("\nGetNSSVolumeProperties - Failed to get file, status = %d\n.", status); MPKNSS_LOCK(); goto Exit; } - getInfoMask = zGET_TIMES_IN_SECS | zGET_IDS | + getInfoMask = zGET_TIMES_IN_SECS | zGET_IDS | zGET_VOLUME_INFO | zGET_POOL_INFO | zGET_VOL_SALVAGE_INFO; - if ((status = zGetInfo(fileKey, - getInfoMask, - sizeof(info), - zINFO_VERSION_A, + if ((status = zGetInfo(fileKey, + getInfoMask, + sizeof(info), + zINFO_VERSION_A, &info)) != zOK) { - DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, + DEBUG_PRINTF(TBIO, DBG_INDENT, (LCYAN, MSGNot("Failed in zGetInfo, status = %d\n."), status)); printf("\nGetNSSVolumeProperties - Failed in zGetInfo, status = %d\n.", status); MPKNSS_LOCK(); @@ -3097,18 +3097,18 @@ STATUS GetNSSVolumeProperties(BYTE *volumeName, NINT retBufLen, BYTE *retBuffer, // Pool name in which this volume resides. if ((status = GetNSSVolumeHostPool(volumeName, poolName)) == zOK) { - sprintf(&retBuf[len], "%s%s%c", NSSVolPoolName, - poolName, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%s%c", NSSVolPoolName, + poolName, FIELD_SEPARATOR); len += strlen(&retBuf[len]); } else { - sprintf(&retBuf[len], "%s%s%c", NSSVolPoolName, - "", FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%s%c", NSSVolPoolName, + "", FIELD_SEPARATOR); len += strlen(&retBuf[len]); } - // Pool State + // Pool State #if 0 typedef struct zPoolInfo_s { @@ -3127,40 +3127,40 @@ typedef struct zPoolInfo_s QUAD nonPurgeableBytes; } zPoolInfo_s; #endif - sprintf(&retBuf[len], "Pool ID : " ); + sprintf(&retBuf[len], "Pool ID : " ); len += strlen(&retBuf[len]); (void)LB_GUIDToString( &info.pool.poolID, retBufLen-len, &retBuf[len] ); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%c", FIELD_SEPARATOR); + sprintf(&retBuf[len], "%c", FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "NDS Object ID : " ); + sprintf(&retBuf[len], "NDS Object ID : " ); len += strlen(&retBuf[len]); (void)LB_GUIDToString( &info.pool.ndsObjectID, retBufLen-len, &retBuf[len] ); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%c", FIELD_SEPARATOR); + sprintf(&retBuf[len], "%c", FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%d%c", "Pool "NSSVolState, - info.pool.poolState, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%d%c", "Pool "NSSVolState, + info.pool.poolState, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%Ld%c", "Pool Space:", - info.pool.totalSpace, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Pool Space:", + info.pool.totalSpace, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%Ld%c", "Pool Used Space:", - info.pool.numUsedBytes, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Pool Used Space:", + info.pool.numUsedBytes, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%016Lx%c", "Vol Features enabled : ", - info.vol.features.enabled, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%016Lx%c", "Vol Features enabled : ", + info.vol.features.enabled, FIELD_SEPARATOR); len += strlen(&retBuf[len]); -// sprintf(&retBuf[len], "%s%016Lx%c", "Vol Features enableModMask :", -// info.vol.features.enableModMask, FIELD_SEPARATOR); +// sprintf(&retBuf[len], "%s%016Lx%c", "Vol Features enableModMask :", +// info.vol.features.enableModMask, FIELD_SEPARATOR); // len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%016Lx%c", "Vol Features supported : ", - info.vol.features.supported, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%016Lx%c", "Vol Features supported : ", + info.vol.features.supported, FIELD_SEPARATOR); len += strlen(&retBuf[len]); #if 0 @@ -3176,55 +3176,55 @@ typedef struct zPoolInfo_s } salvage; #endif - sprintf(&retBuf[len], "%s%Ld%c", "Vol purgeable Space:", - info.vol.salvage.purgeableBytes, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Vol purgeable Space:", + info.vol.salvage.purgeableBytes, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%Ld%c", "Vol non-purgeable Space:", - info.vol.salvage.nonPurgeableBytes, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Vol non-purgeable Space:", + info.vol.salvage.nonPurgeableBytes, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%Ld%c", "Vol numDeletedFiles:", - info.vol.salvage.numDeletedFiles, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Vol numDeletedFiles:", + info.vol.salvage.numDeletedFiles, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%Ld%c", "Pool purgeable Space:", - info.pool.purgeableBytes, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Pool purgeable Space:", + info.pool.purgeableBytes, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%Ld%c", "Pool non-purgeable Space:", - info.pool.nonPurgeableBytes, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Pool non-purgeable Space:", + info.pool.nonPurgeableBytes, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "Volume ID : " ); + sprintf(&retBuf[len], "Volume ID : " ); len += strlen(&retBuf[len]); (void)LB_GUIDToString( &info.vol.volumeID, retBufLen-len, &retBuf[len] ); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%c", FIELD_SEPARATOR); + sprintf(&retBuf[len], "%c", FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "NDS Object ID : " ); + sprintf(&retBuf[len], "NDS Object ID : " ); len += strlen(&retBuf[len]); (void)LB_GUIDToString( &info.vol.ndsObjectID, retBufLen-len, &retBuf[len] ); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%c", FIELD_SEPARATOR); + sprintf(&retBuf[len], "%c", FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%d%c", NSSVolState, - info.vol.volumeState, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%d%c", NSSVolState, + info.vol.volumeState, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%x%c", NSSVolNamespace, + sprintf(&retBuf[len], "%s%x%c", NSSVolNamespace, info.vol.nameSpaceMask, FIELD_SEPARATOR); len += strlen(&retBuf[len]); // Total Quota sprintf(&retBuf[len], "%s%Lu%c", NSSVolQuotaSize, info.vol.totalSpaceQuota, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%Ld%c", "Volume Used Space:", - info.vol.numUsedBytes, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Volume Used Space:", + info.vol.numUsedBytes, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%Ld%c", "Volume purgeable Space:", - info.vol.salvage.purgeableBytes, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Volume purgeable Space:", + info.vol.salvage.purgeableBytes, FIELD_SEPARATOR); len += strlen(&retBuf[len]); - sprintf(&retBuf[len], "%s%Ld%c", "Volume non-purgeable Space:", - info.vol.salvage.nonPurgeableBytes, FIELD_SEPARATOR); + sprintf(&retBuf[len], "%s%Ld%c", "Volume non-purgeable Space:", + info.vol.salvage.nonPurgeableBytes, FIELD_SEPARATOR); len += strlen(&retBuf[len]); Exit: if (status == zOK) @@ -3253,7 +3253,7 @@ Exit: return status; } // GetNSSVolumeProperties() - + STATUS doLVGetInfo( PCLSwitchDef_s *switchDef, @@ -3328,7 +3328,7 @@ STATUS doUpgradeCurrentVolumeMediaFormat( MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); - + if (switchDef->ret_value && (uniicmp(switchDef->ret_value, MSGNot(L"all")) == 0)) { HL_StartUpgradeProcess(NULL, COMN_CmdSwitchIncludeGet()); @@ -3347,7 +3347,7 @@ STATUS doUpgradeCurrentVolumeMediaFormat( /* This is to set two globals, for version numbers to set into new pools/volumes depending on whether they are local pools or global pools. - Valid syntax includes: + Valid syntax includes: nss /UpgradeNewVolumeMediaFormat=all /include=local nss /UpgradeNewVolumeMediaFormat=all /include=shared nss /UpgradeNewVolumeMediaFormat=all /include=local,shared @@ -3369,7 +3369,7 @@ STATUS doUpgradeNewVolumeMediaFormat(PCLSwitchDef_s *switchDef, { HL_NewSharedVolumeBeastVersion = CURRENT_BEAST_VERSION; } - return zOK; + return zOK; } @@ -4426,3 +4426,6 @@ PCLSwitchDef_s ZSTORE_CommandLineSwitches[] = {PCMDLINE_ENDOFLIST} }; + + + diff --git a/src/nwnss/zlss/zlssConsumer.c b/src/nwnss/zlss/zlssConsumer.c new file mode 100644 index 0000000..97e3d1a --- /dev/null +++ b/src/nwnss/zlss/zlssConsumer.c @@ -0,0 +1,920 @@ +/**************************************************************************** + | + | (C) Copyright 1995-2002 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | Novell Storage Services (NSS)module + | + |--------------------------------------------------------------------------- + | + | $Author: gpachner $ + | $Date: 2007-08-10 00:40:09 +0530 (Fri, 10 Aug 2007) $ + | + | $RCSfile$ + | $Revision: 2129 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | + | + +-------------------------------------------------------------------------*/ +#include +#include +#include + +#include /* nss */ +#include /* nss */ +#include /* nss */ +#include /* nss */ +#include +#include + +#include "xError.h" +#include "comnPublics.h" +#include "zlssConsumer.h" +#include "zlssStartup.h" +#include "zfsSuperBlk.h" +#include "zfsXTree.h" +#include "zfsFileMap.h" +#include "zfs.h" +#include "zlssLogicalVolume.h" +#include "zPool.h" +#include "eventSys.h" + +/* Variable for events. */ +extern NINT EnterExitEventID; + +/*- storage queue for deposits taken (physical pool master list) -*/ +DQhead_t zlssConTakeList = DQ_STATIC_INIT(zlssConTakeList); + + +/*- unicode_t zlss consumer name -*/ +unicode_t zlssConName[] = {MSGNot(L"ZLSS NetWare's Object Store")}; + +unicode_t UndefinedPoolName[] = {MSGNot(L"Undefined_Name")}; + +/*- basic configuration info -*/ +LONG ShutDownFlag; + + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*------------------ START OF ROUTINES ------------------------------------*/ + +/*- (FUNCTION) ----- CONSUMER_Startup() ------------------------------------- + | + | initialize the nss consumer services + | + +-------------------------------------------------------------------------*/ +STATUS CONSUMER_Startup() +{ + STATUS status; + + ASSERT_MPKNSS_LOCK(); +// zASSERT(" zlss consumer start" == NULL); + + /*- check if already registered -*/ + status = Phypool_Startup(); + if ( status != zOK ) + { + return( status ); + } + DQ_INIT(&zlssConTakeList); + + ShutDownFlag = 0; + ZLSSPOOL_Startup(); + + return(zOK); +} + +/*- (FUNCTION) ----- CONSUMER_Shutdown() ------------------------------------ + | + | uninitialize the nss consumer services + | + +-------------------------------------------------------------------------*/ +void CONSUMER_Shutdown() +{ + zConPool_s *phypool; + PhyKey_t phyKey; + + ShutDownFlag = 1; + + ASSERT_MPKNSS_LOCK(); + + + ZLSSPOOL_Shutdown(); + + /*- remove all take elements -*/ + DQ_PEEK(&zlssConTakeList, phypool, zConPool_s, stolink); + while(phypool != NULL) + { + if(phypool->ZCP_dev != 0) + { + phyKey = phypool_Obtain( phypool, WHERE ); + /* Save off the id and key before being deleted. */ + /*- remove given element, return deposit -*/ + zlssRemovePool(phypool); + phypool_Release( phyKey, phypool, WHERE ); // Must not use phypool after this call + + } + else + { + DQ_DROP(&zlssConTakeList/*, phypool, stolink*/); + // I do not know why we do not call zlssRemovePool, but if on the + // zlssConTakeList list then we have a 'load' inuse count and + // need to release and not do a free ourselves. + phypool_Release( phypool->ZCP_LoadKey, phypool, WHERE ); // Must not use phypool after this call + } + DQ_PEEK(&zlssConTakeList, phypool, zConPool_s, stolink); + } + + Phypool_Shutdown(); + DQ_INIT(&zlssConTakeList); + ShutDownFlag = 0; + return; +} + + +/* + * ZLSSCON_Upgrade() - + * Upgrade from NSS 2.x to NSS 3.00 (ZLSS media version 40.06). + * The caller must not use zfsPool after we return. + * + * Notes - + * Caller must ensure that the pool's version is less than 40.06. + * + */ +#ifdef NW5X_UPGRADE +STATUS ZLSSCON_Upgrade( + GeneralMsg_s *genMsg, + ZfsPool_s *zfsPool ) + +{ + StorPool_s *storagePool; + + storagePool = zfsPool->storagepool; + if ( storagePool == NULL ) + { + SetErrno( genMsg, zERR_ZLSSPOOL_NO_PHYSICAL_POOL ); + return( zFAILURE ); + } + + ZFSPOOL_ShutdownPool( zfsPool ); + storagePool->zfspool = NULL; + + storagePool->zfspool = ZFSPOOL_LoadPool(genMsg, storagePool, + TRUE, ZLSS_PLF_UPGRADE, FALSE, NULL, FALSE ); + if ( storagePool->zfspool == NULL ) + { /* Since we got a error that prevent the pool from + * loading(and seen by user) we retry a much simpler + * load so the user can still see the pool. + */ + ClearErrno( genMsg ); + storagePool->zfspool = ZFSPOOL_LoadPool(genMsg, storagePool, + TRUE, ZLSS_PLF_NO_UPGRADE, FALSE, NULL, FALSE ); + if ( storagePool->zfspool == NULL ) + { /* This is a BAD place as no way to force another + * load. /ZLSSPoolScan will not work as we have not + * given back to MAL. They will have to unload zlss.nss + * for things to work if we get here. + */ + storagePool->poolstatus = POL_STAT_ORPHAN; + return(zFAILURE); + } + } + + return zOK; + +} /* End of ZLSSCON_Upgrade() */ +#endif + + +STATUS GetUniquePoolName( + unicode_t *name) +{ + STATUS cCode; + LONG length, suffix; + NINT digit, temp; + unicode_t oldname[MAL_MAXNAME]; + STATIC unicode_t *unicodeDigit[] = { + L"0", + L"1", + L"2", + L"3", + L"4", + L"5", + L"6", + L"7", + L"8", + L"9" + }; + + + if(ZFSPOOL_CmpName(name) == zOK) + return(zOK); + + length = unilen(name); + + /* Make sure there are 3 characters at the end for _1 null */ + if((length == 0) || (length > (MAL_MAXNAME-3))) + { + return(zFAILURE); + } + + length += 2; + suffix = 1; + unicpy(oldname, name); + unicat(oldname, L"_"); /* add the '_' to the end of the string. */ + do + { + /* Start with the original name and add the suffix */ + unicpy(name, oldname); + temp = suffix; + if (suffix >= 100) + { + digit = temp/100; + temp -= (digit * 100); + unicat( name, unicodeDigit[ digit ] ); + } + if (suffix >= 10) + { + digit = temp/10; + temp -= (digit * 10); + unicat( name, unicodeDigit[ digit ] ); + } + unicat( name, unicodeDigit[ temp ] ); + suffix++; + + /* Add 1 to the length for the new digit. */ + if (suffix == 10) + length++; + + /* Add 1 to the length for the new digit. */ + if (suffix == 100) + length++; + + cCode = ZFSPOOL_CmpName(name); + + }while ((cCode != zOK) && (suffix < 1000) && (length < MAL_MAXNAME)); + + return(cCode); +} + +/* This function finds a pool with the same name and checks if it also +** has the same GUID. If so, an error is returned. If GUIDs are different, +** a 0 is returned. +*/ +STATUS CheckForDuplicateGUID( + zConPool_s *phypool) +{ + zConPool_s *pool; + + + ASSERT_MPKNSS_LOCK(); + + /*- now search for storage entry -*/ + DQ_FOREACH(&zlssConTakeList, pool, zConPool_s, stolink) + { + if (unicmp(pool->pol.poolname, phypool->pol.poolname) == 0) + { + if (memcmp(&pool->phy.guid, &phypool->phy.guid, 16) == 0) + { + return(zERR_DUPLICATE_POOL_NAME); + } + else + { + return(0); + } + } + } + + return(0); +} +/*- prototype of misc. routines for size conversion + | + | unitsize = number of bytes (one sector == 512 bytes) + | units = number of units + | meg = number of megabytes (5meg = (5 * 1024 * 1024)bytes) + | + | LONG = returns the number of meg + | QUAD = returns the number of units + | + +-------------------------------------------------------------------------*/ +LONG zMALUnitsToMeg(QUAD sectors, LONG unitsize) +{ + if(unitsize != 0) + { + return(sectors / (MAL_ONEMEG / unitsize)); + } + return(0); +} + +/*- (FUNCTION) ----- ZLSSCON_AutoReceiveDeposit() --------------------------- + | + | the MAL object bank will call this routine if it detects that a deposit + | has a consumer id matching this registered consumer. + | + +-------------------------------------------------------------------------*/ +STATUS ZLSSCON_AutoReceiveDeposit(Deposit_s *info, LONG flags) +{ + zConPool_s *phypool; + STATUS status = zFAILURE; + typedef struct Stack_s { + unicode_t oldname[64]; + GeneralMsg_s genMsg; + } Stack_s; + + STACK_ALLOC(); + + ASSERT_MPKNSS_LOCK(); + + + /*- check if we already have received this deposit id -*/ + if(ZLSSCON_RetDepositInfo(info->dp_dev, &phypool) != zOK) + { + /*- not on list yet -*/ + if((phypool = zalloc(sizeof(zConPool_s))) != NULL) + { + PhyKey_t phyKey; + + phypool->ZCP_dev = info->dp_dev; + phypool->ZCP_BarrierCommandlineSetting = (flags & ZLSS_DEV_FLAG_BARRIER) ? TRUE : FALSE; + phypool->ZCP_BarrierWritesRequired = phypool->ZCP_BarrierCommandlineSetting; + phypool->cp_inode = info->dp_inode; + phypool->phy.unitsize = info->unitsize; + phypool->pol.poolblocksize = MAL_DEFAULTBLKSIZE; + phypool->pol.poolblkshift = findHighBit(phypool->pol.poolblocksize); + phypool->pol.sharedStatus = (flags & ZLSS_DEV_FLAG_SHARED) ? TRUE : FALSE; + phypool->pol.phypool = phypool; + phypool->pol.zfspool = NULL; + DQ_INIT( &phypool->ZCP_CookieHead ); + phypool->ZCP_UnloadSpinners = 0; + phypool->ZCP_InUseCount = 0; + phypool->ZCP_LoadKey.pk_cookie = PHYKEY_INVALID; + phypool->ZCP_LoadKey.pk_unique = PHYKEY_INVALID; + + phyKey = phypool_Obtain( phypool, WHERE ); + if (flags & ZLSS_DEV_FLAG_NEW) + { + if ((status = GetUniquePoolName(info->name)) == zOK) + { + phypool->phy.sizeinunits = info->sizeinunits; + phypool->phy.sizeinmeg = info->sizeinmeg; + phypool->phy.createtime = GetUTCTime(); + LB_GUIDGenerate( &phypool->phy.guid ); + phypool->pol.pooltotalblocks = phypool->phy.sizeinmeg * MAL_BLKSPER1MEG; + phypool->pol.poolstatus = POL_STAT_NEW; + unicpy(phypool->pol.poolname, info->name); + + // This is the official 'load' InUse count - + // zlssRemovePool will remove + phypool->ZCP_LoadKey = phypool_Obtain( phypool, WHERE ); + DQ_ENQ(&zlssConTakeList, phypool, stolink); + + if ((status = zlssInsertPool(phypool, NULL)) != zOK) + { + zlssRemovePool(phypool); + } + /* On error we have already been removed from + * zlssConTakeList and the phypool memory has + * been freed. Take out the pool stamp. + * Aug2003 - phypool not freed until we call + * phypool_Release(). + */ + // Must not use phypool after this call + phypool_Release( phyKey, phypool, WHERE ); + STACK_FREE(); + return( status ); + } + } + else if (flags & ZLSS_DEV_FLAG_SNAPSHOT) + { + if ((status = GetUniquePoolName(info->snapname)) == zOK) + { + phypool->phy.sizeinunits = info->sizeinunits; + phypool->phy.sizeinmeg = info->sizeinmeg; + phypool->phy.createtime = GetUTCTime(); + LB_GUIDGenerate( &phypool->phy.guid ); + phypool->pol.pooltotalblocks = phypool->phy.sizeinmeg * MAL_BLKSPER1MEG; + phypool->pol.poolstatus = POL_STAT_NEW_SNAPSHOT; + unicpy(aStack->oldname, info->name); /* save off the old name */ + unicpy(phypool->pol.poolname, info->snapname); + + // This is the official 'load' InUse count - + // zlssRemovePool will remove + phypool->ZCP_LoadKey = phypool_Obtain( phypool, WHERE ); + DQ_ENQ(&zlssConTakeList, phypool, stolink); + + if ((status = zlssInsertPool(phypool, aStack->oldname)) != zOK) + { + zlssRemovePool(phypool); + } + /* On errors we have already been removed from + * zlssConTakeList and the phypool memory has + * been freed. Take out the pool stamp. + * Aug2003 - phypool not freed until we call + * phypool_Release(). + */ + // Must not use phypool after this call + phypool_Release( phyKey, phypool, WHERE ); + STACK_FREE(); + return( status ); + } + } + else + { + status = zOK; + phypool->phy.sizeinunits = info->sizeinunits; + unicpy(phypool->pol.poolname, info->name); + phypool->phy.createtime = 0; + phypool->phy.sizeinmeg = info->sizeinmeg; + phypool->pol.pooltotalblocks = + phypool->phy.sizeinmeg * MAL_BLKSPER1MEG; + phypool->phy.guid = info->guid; + + /* Make sure that the pool name is still unique. */ + if(ZFSPOOL_CmpName(phypool->pol.poolname) != zOK) + { // Must not use phypool after this call + phypool_Release( phyKey, phypool, WHERE ); + STACK_FREE(); + return(zERR_DUPLICATE_POOL_NAME); + /* As of May 2007 we no longer attempt to auto rename + pools. This does not work in Linux because the LSA + is unaware of the name change. It stores the name + to do some zAPI calls. If a customer sticks a drive + that has a duplicate name then they have to rename + from EVMS anyway. I.E. this code is not needed. */ +#if 0 + if ( (flags & ZLSS_DEV_FLAG_SHARED) + || (CheckForDuplicateGUID(phypool))) + { + // Must not use phypool after this call + phypool_Release( phyKey, phypool, WHERE ); + STACK_FREE(); + return(zERR_DUPLICATE_POOL_NAME); + } + + unicpy(aStack->oldname, phypool->pol.poolname); /* save off the old name */ + if ((status = GetUniquePoolName(phypool->pol.poolname)) != zOK) + { + // Must not use phypool after this call + phypool_Release( phyKey, phypool, WHERE ); + STACK_FREE(); + return(status); + } + phypool->pol.poolstatus = POL_STAT_NEW_NAME; +#endif + } + else + { + phypool->pol.poolstatus = POL_STAT_READY; + aStack->oldname[0] = 0; + } + + // This is the official 'load' InUse count - + // zlssRemovePool will remove + phypool->ZCP_LoadKey = phypool_Obtain( phypool, WHERE ); + DQ_ENQ(&zlssConTakeList, phypool, stolink); + + if ((status = zlssInsertPool(phypool, aStack->oldname)) != zOK) + { + zlssRemovePool(phypool); + } + /* On errors we have already been removed from + * zlssConTakeList and the phypool memory has + * been freed. + * Aug2003 - phypool not freed until we call phypool_Release(). + */ + // Must not use phypool after this call + phypool_Release( phyKey, phypool, WHERE ); + STACK_FREE(); + return( status ); + } + // Must not use phypool after this call + phypool_Release( phyKey, phypool, WHERE ); + } + } + else + { + /* Just update the structures */ + phypool->ZCP_BarrierCommandlineSetting = (flags & ZLSS_DEV_FLAG_BARRIER) ? TRUE : FALSE; + phypool->ZCP_BarrierWritesRequired = phypool->ZCP_BarrierCommandlineSetting; + phypool->cp_inode = info->dp_inode; + phypool->phy.unitsize = info->unitsize; + phypool->pol.sharedStatus = (flags & ZLSS_DEV_FLAG_SHARED) ? TRUE : FALSE; + if (phypool->phy.sizeinunits < info->sizeinunits) + { + phypool->phy.sizeinunits = info->sizeinunits; + phypool->phy.sizeinmeg = zMALUnitsToMeg(info->sizeinunits, phypool->phy.unitsize); + + /*- change block count -*/ + + phypool->pol.pooltotalblocks = phypool->phy.sizeinmeg * MAL_BLKSPER1MEG; + + /* Change the guid so we know the pool changed. */ + LB_GUIDGenerate( &phypool->phy.guid ); + + /*- if zfspool attached, then update the zfspool -*/ + if(phypool->pol.zfspool != NULL) + { + COMN_SETUP_GENERAL_MSG_NOSA(&aStack->genMsg); + (void)ZFSPOOL_SetNewPoolSizeWhileActive( &aStack->genMsg, &phypool->pol); + } + } + } + + STACK_FREE(); + return(status); +} + +/*- (FUNCTION) ----- ZLSSCON_AutoReturnDeposit() ---------------------------- + | + | the deposit manager will call this routine if it detects an error, the + | deposit status has changed and will require that the current owership + | be return to the storage object bank. + | + +-------------------------------------------------------------------------*/ +STATUS ZLSSCON_AutoReturnDeposit(struct block_device *dev, LONG reason) +{ + STATUS status; + zConPool_s *phypool; + PhyKey_t phyKey; + + ASSERT_MPKNSS_LOCK(); + + DQ_FOREACH(&zlssConTakeList, phypool, zConPool_s, stolink) + { + if(phypool->ZCP_dev == dev) + { + phyKey = phypool_Obtain( phypool, WHERE ); + status = zlssRemovePool(phypool); + // Must not use phypool after this call + phypool_Release( phyKey, phypool, WHERE ); + return(status); + } + } + return(zFAILURE); +} + +/*- (FUNCTION) ----- ZLSSCON_RetDepositInfo() ------------------------------- + | + | search the consumer deposit queue and return the deposit info + | + +-------------------------------------------------------------------------*/ +STATUS ZLSSCON_RetDepositInfo(struct block_device *dev, zConPool_s **retphypool) +{ + zConPool_s *phypool; + + ASSERT_MPKNSS_LOCK(); + + /*- now search for provider -*/ + DQ_FOREACH(&zlssConTakeList, phypool, zConPool_s, stolink) + { + if(phypool->ZCP_dev == dev) + { + *retphypool = phypool; + return(zOK); + } + } + + *retphypool = 0; + + return(zFAILURE); +} + + +/*- (FUNCTION) ----- ZLSS_GetPoolDev() -------------------------------- + | + +-------------------------------------------------------------------------*/ +STATUS ZLSS_GetPoolDev(unicode_t *uniName, struct block_device **dev) +{ + zConPool_s *phypool; + + ASSERT_MPKNSS_LOCK(); + + /*- now search for storage entry -*/ + DQ_FOREACH(&zlssConTakeList, phypool, zConPool_s, stolink) + { + if (unicmp(phypool->pol.poolname, uniName) == 0) + { + *dev = phypool->ZCP_dev; + return(zOK); + } + } + return(zFAILURE); +} +EXPORT_SYMBOL(ZLSS_GetPoolDev); + + +static inline QUAD devSize (struct block_device *bdev, NINT unitsize) +{ + QUAD size; + + size = i_size_read(bdev->bd_inode); + size = size / unitsize; + + return size; +} + + +/*- (FUNCTION) ----- ZLSS_SetPoolSize() ------------------------------ + | + +-------------------------------------------------------------------------*/ +STATUS ZLSS_SetPoolSize(struct block_device *dev, QUAD newSizeInBlocks) +{ + zConPool_s *phypool; + STATUS cCode = zOK; + GeneralMsg_s genMsg; + + ASSERT_MPKNSS_LOCK(); + + if ( devSize(dev, 4096) < newSizeInBlocks ) + { /* Lets reject size changes that are larger than the device size!!! */ + printk(KERN_WARNING "NSS: Pool expand request (%Lx) larger than block device size (%Lx)\n", + newSizeInBlocks, devSize(dev, 4096) ); + return zERR_POOL_EXPAND_PAST_EOF; + } + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + + DQ_FOREACH(&zlssConTakeList, phypool, zConPool_s, stolink) + { + if(phypool->ZCP_dev == dev) + { + /*- found deposit -*/ + /*- increase size of deposit -*/ + if(newSizeInBlocks > phypool->phy.sizeinunits) + { + /*- change the size and do an alert -*/ + phypool->phy.sizeinunits = newSizeInBlocks; + phypool->phy.sizeinmeg = zMALUnitsToMeg(newSizeInBlocks, phypool->phy.unitsize); + + /*- change block count -*/ + + phypool->pol.pooltotalblocks = phypool->phy.sizeinmeg * MAL_BLKSPER1MEG; + + /* Change the guid so we know the pool changed. */ + LB_GUIDGenerate( &phypool->phy.guid ); + + /*- if zfspool attached, then update the zfspool -*/ + if(phypool->pol.zfspool != NULL) + { + (void)ZFSPOOL_SetNewPoolSizeWhileActive( &genMsg, &phypool->pol); + } + } + else if ( newSizeInBlocks < phypool->phy.sizeinunits ) + { + printk(KERN_WARNING "NSS: Pool expand request (%Lx) less than physical pool size (%Lx)\n", + newSizeInBlocks, phypool->phy.sizeinunits ); + cCode = zERR_POOL_EXPAND_LESS; + } + else + { + cCode = zERR_POOL_EXPAND_SAME; + } + return cCode; + } + } + return(zERR_POOL_EXPAND_NOT_FOUND); +} + +EXPORT_SYMBOL(ZLSS_SetPoolSize); + + +/*- (FUNCTION) ----- ZLSS_SetPoolShared() --------------------------------- + | + +-------------------------------------------------------------------------*/ +STATUS ZLSS_SetPoolShared(struct block_device *dev, BOOL sharedstate) +{ + PhyKey_t phyKey; + STATUS status; + zConPool_s *phypool; + LONG cCode; + EventChangePoolSharedEnter_s sharedEnter; + EventChangePoolSharedExit_s sharedExit; + + ASSERT_MPKNSS_LOCK(); + /*- now search for storage entry -*/ + DQ_FOREACH(&zlssConTakeList, phypool, zConPool_s, stolink) + { + if(phypool->ZCP_dev == dev) + { + phyKey = phypool_Obtain( phypool, WHERE ); + sharedEnter.enterExitID = sharedExit.enterExitID = EnterExitEventID++; + sharedEnter.poolName = sharedExit.poolName = phypool->pol.poolname; + if (phypool->pol.zfspool != NULL) + { + sharedEnter.poolID = sharedExit.poolID = + phypool->pol.zfspool->ZFSPOOLvol.v_pool->volumeID; + } + else + { + sharedEnter.poolID = sharedExit.poolID = zINVALID_GUID; + } + + sharedEnter.shared = phypool->pol.sharedStatus; + /* Send the event. */ + status = COMN_SendNSSEvent(EVENT_ChangePoolShared_Enter, &sharedEnter, sizeof(sharedEnter), &cCode); + if (status != OPERATION_DENIED) + { + /* Everything should be OK to update the pool, so do it. */ + + sharedExit.enterRetStatus = status; + + /* Change the shared status bit */ + phypool->pol.sharedStatus = sharedstate; + + if (phypool->pol.zfspool == NULL) + { + status = zlssInsertPool(phypool, NULL); + if (status != zOK) + { + zlssRemovePool(phypool); + } + } + else + { + /* Change the shared status bit within the pool */ + if (sharedstate) + { + phypool->pol.zfspool->ZFSPOOLvol.v_pool->POOLenabledFeatures |= + zPOOL_FEATURE_SHARED_CLUSTER; + } + else + { + phypool->pol.zfspool->ZFSPOOLvol.v_pool->POOLenabledFeatures &= + ~zPOOL_FEATURE_SHARED_CLUSTER; + } + + status = zOK; + } + + sharedExit.opRetCode = status; + sharedExit.shared = sharedstate; + status = COMN_SendNSSEvent(EVENT_ChangePoolShared_Enter, &sharedEnter, sizeof(sharedEnter), &cCode); + } + else + status = cCode; + + // Must not use phypool after this call + phypool_Release( phyKey, phypool, WHERE ); + return(status); + } + } + return(zFAILURE); +} + +EXPORT_SYMBOL(ZLSS_SetPoolShared); + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + + + +#define MAL_INIT_REQ(_req, _id, _unitSize ) \ +{ \ + (_req)->dp_dev = _id; \ + (_req)->unitsize = _unitSize; \ + (_req)->sizeinunits = devSize(_id, _unitSize); \ + (_req)->sizeinmeg = (_req)->sizeinunits / \ + ((1<<20) / (_req)->unitsize); \ +} + + +LONG MAL_ForwardDepositToConsumer(struct block_device *dev, LONG unitSize, char *poolName, LONG flags, char *snapName, void *inode) +{ + Deposit_s *req; + LONG rc; + + MPKNSS_LOCK(); + req = malloc(sizeof(*req)); + zASSERT(req != NULL); + + MAL_INIT_REQ(req, dev, unitSize); + req->dp_inode = inode; + + bzero( &req->guid, sizeof(GUID_t)); + utf2uni(poolName, req->name, sizeof(req->name)); + uniupr(req->name); + // Mal should not be in the business of + // getting names for pools. That is the + // job of zlss. + if (flags & ZLSS_DEV_FLAG_SNAPSHOT) + { + utf2uni(snapName, req->snapname, sizeof(req->snapname)); + uniupr(req->snapname); + } + + if (ZLSSCON_AutoReceiveDeposit(req, flags) == zOK) + { + rc = zOK; + goto exit; + } + rc = zERR_OBJECT_NOT_FOUND; // __linux__ need better error code +exit: + free(req); + MPKNSS_UNLOCK(); + return rc; +} + +LONG MAL_RemoveDeposit (struct block_device *dev) +{ + LONG rc; + + MPKNSS_LOCK(); + if (ZLSSCON_AutoReturnDeposit(dev, 0) == zOK) + { + rc = zOK; + goto exit; + } + rc = zERR_OBJECT_NOT_FOUND; // __linux__ need better error code +exit: + MPKNSS_UNLOCK(); + return rc; +} + +LONG MAL_CreateDeposit (struct block_device *dev, LONG unitSize, char *poolName) +{ + Deposit_s *req; + LONG rc; + + if (set_blocksize(dev, PAGE_SIZE) != 0) + { + return zERR_READ_FAILURE_MEDIA; + } + + MPKNSS_LOCK(); + req = malloc(sizeof(*req)); + zASSERT(req != NULL); + + MAL_INIT_REQ(req, dev, unitSize); + req->dp_inode = 0; + + bzero( &req->guid, sizeof(GUID_t)); + utf2uni(poolName, req->name, sizeof(req->name)); + uniupr(req->name); + // Mal should not be in the business of + // getting names for pools. That is the + // job of zlss. + if (ZLSSCON_AutoReceiveDeposit(req, ZLSS_DEV_FLAG_NEW) == zOK) + { + ZLSSCON_AutoReturnDeposit(dev, 0); + rc = zOK; + goto exit; + } + rc = zERR_OBJECT_NOT_FOUND; // __linux__ need better error code +exit: + free(req); + MPKNSS_UNLOCK(); + return rc; +} + +STATUS MAL_GetPoolNameFromDevice( + struct block_device *dev, + char *poolName, + NINT poolNameSize) +{ + zConPool_s *phypool; + + ASSERT_MPKNSS_LOCK(); + + /*- now search for storage entry -*/ + DQ_FOREACH(&zlssConTakeList, phypool, zConPool_s, stolink) + { + if (phypool->ZCP_dev == dev) + { + if (uni2utf(phypool->pol.poolname, poolName, poolNameSize) == -1) + { + return(zFAILURE); + } + return(zOK); + } + } + return(zFAILURE); +} +EXPORT_SYMBOL(MAL_GetPoolNameFromDevice); + + +EXPORT_SYMBOL(MAL_RemoveDeposit); +EXPORT_SYMBOL(MAL_ForwardDepositToConsumer); +EXPORT_SYMBOL(MAL_CreateDeposit); + diff --git a/src/nwnss/zlss/zlssConsumer.h b/src/nwnss/zlss/zlssConsumer.h index 4568ebf..99219f5 100644 --- a/src/nwnss/zlss/zlssConsumer.h +++ b/src/nwnss/zlss/zlssConsumer.h @@ -102,11 +102,11 @@ +-------------------------------------------------------------------------*/ typedef struct StorPhy_s { - LONG unitsize; /*- smallest IO unit size in bytes -*/ - QUAD sizeinunits; /*- number of units for this storage deposit -*/ - LONG sizeinmeg; /*- number of meg for this storage deposit -*/ - Time_t createtime; /*- utc time when storage was create -*/ - GUID_t guid; /*- GUID (128 bits) when storage was created -*/ + LONG unitsize; /*- smallest IO unit size in bytes -*/ + QUAD sizeinunits; /*- number of units for this storage deposit -*/ + LONG sizeinmeg; /*- number of meg for this storage deposit -*/ + Time_t createtime; /*- utc time when storage was create -*/ + GUID_t guid; /*- GUID (128 bits) when storage was created -*/ } StorPhy_s; /*--------------------------------------------------------------------------- @@ -114,22 +114,22 @@ typedef struct StorPhy_s +-------------------------------------------------------------------------*/ typedef struct StorPool_s { - LONG poolstatus; /*- free, used, orphan - operational status of pool -*/ - LONG poolblocksize; /*- size of blocks used (cache block) for pool -*/ - LONG poolblkshift; /*- block shift factor for bytes -*/ - BOOL sharedStatus; - /* The SP_LoadStatus bits where added September 2003 to prevent multiple unloads, - * and unloads while loading. Mike Ohran and Rob Green where seeing these - * issues while testing their snapshot utilities. The end results where ABENDs. - */ - LONG SP_LoadStatus; /* Bit masks of load or unload of a pool */ + LONG poolstatus; /*- free, used, orphan - operational status of pool -*/ + LONG poolblocksize; /*- size of blocks used (cache block) for pool -*/ + LONG poolblkshift; /*- block shift factor for bytes -*/ + BOOL sharedStatus; + /* The SP_LoadStatus bits where added September 2003 to prevent multiple unloads, + * and unloads while loading. Mike Ohran and Rob Green where seeing these + * issues while testing their snapshot utilities. The end results where ABENDs. + */ + LONG SP_LoadStatus; /* Bit masks of load or unload of a pool */ #define LS_LOADING 0x00000001 /* Someone is currently loading the pool */ #define LS_UNLOADING 0x00000002 /* Someone is unloading a phypool (or waiting to unload if LS_LOADING is set) */ #define LS_UNLOADED 0x00000004 /* Someone has unloaded the phypool */ - QUAD pooltotalblocks; /*- total number of blocks in storage -*/ - struct zConPool_s *phypool; /*- local storage element for this pool -*/ - ZfsPool_s *zfspool; /*- if member, memory pointer to zlss pool beast -*/ - unicode_t poolname[64]; /*- if member, name of pool -*/ + QUAD pooltotalblocks; /*- total number of blocks in storage -*/ + struct zConPool_s *phypool; /*- local storage element for this pool -*/ + ZfsPool_s *zfspool; /*- if member, memory pointer to zlss pool beast -*/ + unicode_t poolname[64]; /*- if member, name of pool -*/ } StorPool_s; @@ -138,41 +138,41 @@ typedef struct StorPool_s // typedef struct PhyCookie_s { - DQlink_t PC_CookieLink; /* Link use to track ALL cookies of a phypool. The - * head is ZCP_CookieHead in zConPool_s. - */ - LONG PC_Magic; /* Magic that indicate if the cookie is good */ + DQlink_t PC_CookieLink; /* Link use to track ALL cookies of a phypool. The + * head is ZCP_CookieHead in zConPool_s. + */ + LONG PC_Magic; /* Magic that indicate if the cookie is good */ #define PC_MAGIC_GOOD 0x48465765 /* Cookie in use */ #define PC_MAGIC_GOOD_SHARED 0x48465768 /* The SharedCookie */ #define PC_MAGIC_GOOD_INIT 0x48466a6a /* Cookie has NEVER been used */ #define PC_MAGIC_FREED 0x4a475866 /* Cookie no longer in use */ - ADDR PC_ObtainedThread; /* Thread ID of obtainer */ - char *PC_ObtainedWhere; /* WHERE of caller to phypool_Obtain */ - Time_t PC_ObtainedUTCTime; /* Time of phypool_Obtain call */ - ADDR PC_ReleasedThread; /* Thread ID of releaser */ - char *PC_ReleasedWhere; /* WHERE of caller to phypool_Obtain */ - Time_t PC_ReleasedUTCTime; /* Time of phypool_Release call */ - LONG PC_KeyValidCurrent; /* Current valid key. TheSharedCookie does not - * use to validate because it is shared. It does - * use to generate unique keys for each of its - * keys. This may help in debugging issues. - */ - struct zConPool_s *PC_Phypool; /* Use to validate release except in the - * case of TheSharedCookie. - */ + ADDR PC_ObtainedThread; /* Thread ID of obtainer */ + char *PC_ObtainedWhere; /* WHERE of caller to phypool_Obtain */ + Time_t PC_ObtainedUTCTime; /* Time of phypool_Obtain call */ + ADDR PC_ReleasedThread; /* Thread ID of releaser */ + char *PC_ReleasedWhere; /* WHERE of caller to phypool_Obtain */ + Time_t PC_ReleasedUTCTime; /* Time of phypool_Release call */ + LONG PC_KeyValidCurrent; /* Current valid key. TheSharedCookie does not + * use to validate because it is shared. It does + * use to generate unique keys for each of its + * keys. This may help in debugging issues. + */ + struct zConPool_s *PC_Phypool; /* Use to validate release except in the + * case of TheSharedCookie. + */ } PhyCookie_s; typedef struct PhyKey_s { - LONG pk_unique; /* The pk_unique is an unique count given to the cookie */ - ADDR pk_cookie; /* The pk_cookie is a PTR to a PhyCookie_s. */ + LONG pk_unique; /* The pk_unique is an unique count given to the cookie */ + ADDR pk_cookie; /* The pk_cookie is a PTR to a PhyCookie_s. */ } PhyKey_s; - /* This allows us to detect when - * a key is released twice. - * We are assuming that our users are not trying to - * guess keys (we will abend in most cases as cookie - * will be an invalid address). - */ + /* This allows us to detect when + * a key is released twice. + * We are assuming that our users are not trying to + * guess keys (we will abend in most cases as cookie + * will be an invalid address). + */ typedef PhyKey_s PhyKey_t; #define PHYKEY_INVALID 0 @@ -182,24 +182,24 @@ typedef PhyKey_s PhyKey_t; +-------------------------------------------------------------------------*/ typedef struct zConPool_s { - DQlink_t stolink; /*- master link of owned storage deposits -*/ - DQlink_t pollink; /*- master link of created pools -*/ - struct block_device *ZCP_dev; /*- Linux Block Device ID -*/ - StorPhy_s phy; /*- description of storage deposit area -*/ - StorPool_s pol; /*- if member, pool information -*/ + DQlink_t stolink; /*- master link of owned storage deposits -*/ + DQlink_t pollink; /*- master link of created pools -*/ + struct block_device *ZCP_dev; /*- Linux Block Device ID -*/ + StorPhy_s phy; /*- description of storage deposit area -*/ + StorPool_s pol; /*- if member, pool information -*/ - BOOL ZCP_BarrierWritesRequired; /* Current barrier setting. This may be - FALSE even if ZCP_BarrierCommandlineSetting - is TRUE. E.G. if device does not - support then we do not do barrier writes. */ - BOOL ZCP_BarrierCommandlineSetting; /* User request for barrier setting. */ - void *cp_inode; /* pointer to a root inode for the pool */ - DQhead_t ZCP_CookieHead; /* Head of link list of active cookies(users of a - * specific zConPool_s). - */ - PhyKey_t ZCP_LoadKey; /* Key that identifies our 'load' use count. */ - int ZCP_InUseCount; /* Number of threads using this phypool. */ - int ZCP_UnloadSpinners; /* Number of threads waiting for unload */ + BOOL ZCP_BarrierWritesRequired; /* Current barrier setting. This may be + FALSE even if ZCP_BarrierCommandlineSetting + is TRUE. E.G. if device does not + support then we do not do barrier writes. */ + BOOL ZCP_BarrierCommandlineSetting; /* User request for barrier setting. */ + void *cp_inode; /* pointer to a root inode for the pool */ + DQhead_t ZCP_CookieHead; /* Head of link list of active cookies(users of a + * specific zConPool_s). + */ + PhyKey_t ZCP_LoadKey; /* Key that identifies our 'load' use count. */ + int ZCP_InUseCount; /* Number of threads using this phypool. */ + int ZCP_UnloadSpinners; /* Number of threads waiting for unload */ } zConPool_s; @@ -249,3 +249,5 @@ STATUS phypool_Release( PhyKey_t phyKey, zConPool_s *phypool, char *where ); PhyKey_t phypool_Obtain( zConPool_s *phypool, char *where ); #endif /* _ZLSSCONSUMER_H_ */ + + diff --git a/src/nwnss/zlss/zlssDev.c b/src/nwnss/zlss/zlssDev.c index e5a5703..31eaba5 100644 --- a/src/nwnss/zlss/zlssDev.c +++ b/src/nwnss/zlss/zlssDev.c @@ -35,7 +35,6 @@ | | +-------------------------------------------------------------------------*/ -#if !defined(NSS_USERSPACE) #include #include #include @@ -194,7 +193,7 @@ static STATUS zlss_bio_error_check( /************************************************************************** - * Do synchronous IO using the Bio structure. + * Do synchronous IO using the Bio structure. * This code was moved from malDev.c to here. **************************************************************************/ static inline int zlss_end_bio_io ( @@ -209,7 +208,7 @@ static inline int zlss_end_bio_io ( if (bio->bi_size) { atomic_inc( &ZlssDevIO.error); - return 1; + return 1; } if (err == -EOPNOTSUPP) { @@ -226,7 +225,7 @@ static inline int zlss_end_bio_io ( } unlock_page(page); } - else + else { atomic_inc( &ZlssDevIO.writes_finished); } @@ -255,7 +254,7 @@ static int zlss_end_bio_write ( /* * In OES2SP1 Beta3, we are changing the default to TRUE so that - * we unplug the device queue always on reads and this helps improve + * we unplug the device queue always on reads and this helps improve * the performance of certain workloads (such as cp) significantly. * Otherwise lot of time was spent waiting at the IO scheduler queue. * We are changing this in Beta3 in order to receive feedback. @@ -317,8 +316,8 @@ STATUS zlssBioIOSync( #ifdef ZLSS_DISPLAY_ALL_IO printk(IO_COMMON,"RStartSync",(unsigned long long)aStack->bio->bi_sector, cTime, currentStuff); #endif - } - else + } + else { aStack->bio->bi_end_io = zlss_end_bio_write; atomic_inc( &ZlssDevIO.writes_started); @@ -352,9 +351,9 @@ STATUS zlssBioIOSync( /************************************************************************** * Do synchronous IO using the Bio structure. The input parameters is - * a pointer to some data in memory. We need to allocate a page to + * a pointer to some data in memory. We need to allocate a page to * represent this data. This should only be called from routines that - * are not fast path and only called infrequently. The current places + * are not fast path and only called infrequently. The current places * this is called from is superblock read/write and msap read/write. **************************************************************************/ STATUS zlssBioIOData( @@ -439,11 +438,11 @@ STATUS zlssBioIOPages ( } /************************************************************************** - * Do asynchronous IO using the Bio structure. + * Do asynchronous IO using the Bio structure. * This code was moved from malDev.c to here. **************************************************************************/ static inline void zlssBlockRComplete( - BioReq_s *bioReq) + BioReq_s *bioReq) { BOOL semSignal = FALSE; unsigned long spinLockFlags; @@ -463,7 +462,7 @@ static inline void zlssBlockRComplete( } static inline void zlssBlockWComplete( - BioReq_s *bioReq) + BioReq_s *bioReq) { BOOL semSignal = FALSE; unsigned long spinLockFlags; @@ -499,7 +498,7 @@ static inline int zlss_end_bio_io_async ( if (bio->bi_size) { atomic_inc( &ZlssDevIO.error); - return 1; + return 1; } if (err == -EOPNOTSUPP) { @@ -515,20 +514,20 @@ static inline int zlss_end_bio_io_async ( SetPageUptodate(page); } unlock_page(page); - } - else + } + else { atomic_inc( &ZlssDevIO.writes_finished); } bioReq->br_status = zlss_bio_error_check(bio, rw); - if (rw == WRITE) + if (rw == WRITE) { #ifdef ZLSS_DISPLAY_ALL_IO printk(IO_COMMON,"WDone",(unsigned long long)bio->bi_sector-8, cTime, currentStuff); //TODO- the -8 is marginal #endif zlssBlockWComplete(bioReq); } - else + else { #ifdef ZLSS_DISPLAY_ALL_IO printk(IO_COMMON,"RDone",(unsigned long long)bio->bi_sector-8, cTime, currentStuff); //TODO: the -8 is bogus @@ -595,8 +594,8 @@ static inline void zlssBioIOAsync( #ifdef ZLSS_DISPLAY_ALL_IO printk(IO_COMMON,"RStart",(unsigned long long)bio->bi_sector, cTime, currentStuff); #endif - } - else + } + else { bio->bi_end_io = zlss_end_bio_write_async; atomic_inc( &ZlssDevIO.writes_started); @@ -638,7 +637,7 @@ void zlssBioIOBufferAsync( page = buffer->b_page; } zlssBioIOAsync(rw, blockDevice, page, bioReq, buffer->volBlk, - (1 << buffer->bufSizeShift)); + (1 << buffer->bufSizeShift)); MPKNSS_LOCK(); return; } @@ -687,5 +686,3 @@ void ZLSS_BioProcessStop() } } - -#endif /* !NSS_USERSPACE */ diff --git a/src/nwnss/zlss/zlssIOPerformance.c b/src/nwnss/zlss/zlssIOPerformance.c index 38e28aa..3abf888 100644 --- a/src/nwnss/zlss/zlssIOPerformance.c +++ b/src/nwnss/zlss/zlssIOPerformance.c @@ -57,9 +57,6 @@ #include #include #include -#include -#include -#include "nssPubs.h" #include "nCache.h" #include "utc.h" @@ -293,7 +290,7 @@ void doRBOrder( Blknum_t *ordered, Blknum_t range, NINT blocks ) void ZIOP_ReadAheadAlgo_Random_Display( - ZIOP_Random_ReadAhead_s *rRA ) + ZIOP_Random_ReadAhead_s *rRA ) { printf( "S %lu E %lu SP %u SEQ %u\n", @@ -308,7 +305,7 @@ void ZIOP_ReadAheadAlgo_Random_Display( void ZIOP_ReadAheadAlgo_Sequential_Display( - ZIOP_Sequential_ReadAhead_s *sRA ) + ZIOP_Sequential_ReadAhead_s *sRA ) { printf( "S %lu E %lu SP %u\n", @@ -355,7 +352,7 @@ void ZIOP_ReadAhead_Destruct( void ZIOP_ReadAheadAlgo_Sequential_Destruct( - ZIOP_Sequential_ReadAhead_s *sRA ) + ZIOP_Sequential_ReadAhead_s *sRA ) { @@ -365,7 +362,7 @@ void ZIOP_ReadAheadAlgo_Sequential_Destruct( void ZIOP_ReadAheadAlgo_Random_Destruct( - ZIOP_Random_ReadAhead_s *rRA ) + ZIOP_Random_ReadAhead_s *rRA ) { @@ -375,9 +372,9 @@ void ZIOP_ReadAheadAlgo_Random_Destruct( BOOL ZIOP_ReadAheadAlgo_Sequential_NextBlock( - ZIOP_Sequential_ReadAhead_s *sRA, + ZIOP_Sequential_ReadAhead_s *sRA, BOOL readAhead, - Blknum_t *nextBlock) + Blknum_t *nextBlock) { @@ -393,7 +390,7 @@ BOOL ZIOP_ReadAheadAlgo_Sequential_NextBlock( Blknum_t ZIOP_Random_Seek( - ZIOP_Random_s *object, + ZIOP_Random_s *object, Blknum_t start, Blknum_t end ) { @@ -408,12 +405,12 @@ Blknum_t ZIOP_Random_Seek( BOOL ZIOP_ReadAheadAlgo_Random_NextBlock( - ZIOP_Random_ReadAhead_s *rRA, + ZIOP_Random_ReadAhead_s *rRA, BOOL readAhead, - Blknum_t *nextBlock) + Blknum_t *nextBlock) { - ZIOP_Random_s *object; + ZIOP_Random_s *object; if ( readAhead ) { @@ -444,7 +441,7 @@ BOOL ZIOP_ReadAheadAlgo_Random_NextBlock( ZIOP_ReadAheadAlgoNextBlock_t ZIOP_ReadAheadAlgo_Sequential_Construct( - ZIOP_Sequential_ReadAhead_s *sRA, + ZIOP_Sequential_ReadAhead_s *sRA, Blknum_t bStart, Blknum_t bEnd, Blknum_t bSpaceing ) /* Must be > 0 */ @@ -461,7 +458,7 @@ ZIOP_ReadAheadAlgoNextBlock_t ZIOP_ReadAheadAlgo_Sequential_Construct( ZIOP_ReadAheadAlgoNextBlock_t ZIOP_ReadAheadAlgo_Random_Construct( - ZIOP_Random_ReadAhead_s *rRA, + ZIOP_Random_ReadAhead_s *rRA, Blknum_t bStart, /* Must be > 0 */ Blknum_t bEnd, /* Must be > bStart */ Blknum_t bSpaceing, /* Must be > 0 */ @@ -647,7 +644,7 @@ void ZIOP_Statistics_Average( * ZS_RecordTime to determine if it is time to 'track' another rate. * */ -BOOL ZIOP_Statistics_Rate( +BOOL ZIOP_Statistics_Rate( ZIOP_Statistics_s *statObject, Blknum_t block, QUAD usCurrent, @@ -685,7 +682,7 @@ BOOL ZIOP_Statistics_Rate( * */ -void ZIOP_Rate_Display( +void ZIOP_Rate_Display( ZIOP_Rate_s *rateObject ) { @@ -797,7 +794,7 @@ LONG ZIOP_Rate_Store( LONG ZIOP_CVS_Header_Random( unicode_t *poolName, - ZIOP_Random_ReadAhead_s *rRA ) + ZIOP_Random_ReadAhead_s *rRA ) { unsigned int amount=0; @@ -833,7 +830,7 @@ LONG ZIOP_CVS_Header_Random( LONG ZIOP_CVS_Header_Sequential( unicode_t *poolName, - ZIOP_Sequential_ReadAhead_s *sRA ) + ZIOP_Sequential_ReadAhead_s *sRA ) { unsigned int amount=0; @@ -926,7 +923,7 @@ STATUS ZIOP_Sequential_Test( if ( status != zOK ) { free( rateObject ); - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); COMN_Release( &zlssPool ); } @@ -1014,9 +1011,9 @@ STATUS ZIOP_Sequential_Test2( unicpy( ZIOP_ThreadInfo.ZTI_poolName, poolName ); ZIOP_ThreadInfo.ZTI_zlssPool = zlssPool; /* WE OWN THIS NOW */ - ZOS_StartThreadWithModuleHandle(ZIOP_ThreadID, "ZLSS Performance", - (void *(*)(THREAD, void *))ZIOP_Sequential_Thread, - 0, 0, &ZIOP_ThreadInfo, (LONG)ZSTORE_ModuleHandle); + ZOS_StartThreadWithModuleHandle(ZIOP_ThreadID, "ZLSS Performance", + (void *(*)(THREAD, void *))ZIOP_Sequential_Thread, + 0, 0, &ZIOP_ThreadInfo, (LONG)ZSTORE_ModuleHandle); if ( !ZIOP_ThreadID ) { VIRT_ssprintf( virtInfo, MSGNot("Could not create thread.\n")); @@ -1049,7 +1046,7 @@ STATUS ZIOP_Sequential_Test3( ZIOP_ReadAhead_s readAheadObject; ZIOP_Statistics_s statObject; ZIOP_ReadAheadAlgoNextBlock_t stuff; - ZIOP_Sequential_ReadAhead_s sRAObject; + ZIOP_Sequential_ReadAhead_s sRAObject; numSeeks = numBlocks/bSequential; @@ -1147,7 +1144,7 @@ void ZIOP_Sequential_Thread( MSGNot("...Work to do done with ZIOP_Sequential_Thread\n") )); #endif free( ti->ZTI_rateObject ); - UNX_LATCH( &ti->ZTI_zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &ti->ZTI_zlssPool->ZLSSPOOLpool.cvsLatch ); COMN_Release( &ti->ZTI_zlssPool ); /* Mark that we are 'almost' done running. */ zASSERT( ti->ZTI_scheduled ); @@ -1187,7 +1184,7 @@ BOOL ZIOP_Random_Test( ZIOP_ReadAhead_s readAheadObject; ZIOP_Statistics_s statObject; ZIOP_ReadAheadAlgoNextBlock_t stuff; - ZIOP_Random_ReadAhead_s rRAObject; + ZIOP_Random_ReadAhead_s rRAObject; VIRT_ssprintf( virtInfo, MSGNot(" Random read test\n")); VIRT_ssprintf( virtInfo, MSGNot(" Block Area - %u to %u\n"), bAreaStart, bAreaEnd); @@ -1566,7 +1563,7 @@ NINT gGood, gBad; /* * - * NOTE - + * NOTE - * This routine must not block as called as a FAST WORK TO DO. * */ @@ -1579,9 +1576,9 @@ void ZIOP_asyncReadComplete(Asyncio_s *aio) if (aio->status != zOK) { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(CYAN,MSGNot(" %Lu Read error %u\n"),microSecondTimer(),aio->buffer->volBlk); + DBG_DebugPrintf(CYAN,MSGNot(" %Lu Read error %u\n"),microSecondTimer(),aio->buffer->volBlk); #endif - aio->buffer->agent.status = aio->status; + aio->buffer->agent.status = aio->status; CACHE_RELEASE(aio->buffer); // rAO->ZRA_ReadAheadCurrent -= 1; aio->buffer = NULL; @@ -1591,7 +1588,7 @@ void ZIOP_asyncReadComplete(Asyncio_s *aio) else { #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(CYAN,MSGNot(" %Lu Read %u\n"),microSecondTimer(),aio->buffer->volBlk); + DBG_DebugPrintf(CYAN,MSGNot(" %Lu Read %u\n"),microSecondTimer(),aio->buffer->volBlk); #endif CACHE_RELEASE(aio->buffer); // rAO->ZRA_ReadAheadCurrent -= 1; @@ -1641,7 +1638,7 @@ BOOL ZIOP_ReadAheadNextReadAhead( { Inst.cache.ioHitSystem++; #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(CYAN,MSGNot(" %Lu Read not %u\n"),microSecondTimer(), block ); + DBG_DebugPrintf(CYAN,MSGNot(" %Lu Read not %u\n"),microSecondTimer(), block ); #endif /* Buffer already read in so we are done */ cacheRelease( buf ); @@ -1658,15 +1655,15 @@ BOOL ZIOP_ReadAheadNextReadAhead( asyncio = getAsyncio(); INIT_AIO(asyncio, mycache, block, CACHE_READ); INIT_AIO_ASYNCREAD( (AioAsyncRead_s *)asyncio, - (voidfunc_t)ZIOP_asyncReadComplete, + ZIOP_asyncReadComplete, (ADDR)rAO, - 0, + NULL, 4096 ); asyncio->buffer = buf; asyncio->volBlk = block; FSM_PUSH( &asyncio->fsm, ZIOP_asyncReadComplete ); #if NSS_DEBUG IS_ENABLED - DBG_DebugPrintf(CYAN,MSGNot(" %Lu Reading %u\n"),microSecondTimer(),block); + DBG_DebugPrintf(CYAN,MSGNot(" %Lu Reading %u\n"),microSecondTimer(),block); #endif ZFSMAL_asyncReadBlk( asyncio ); return( TRUE ); @@ -1851,7 +1848,7 @@ printf("Open/Create has not been called (or a close already done).\n"); } /* End of LB_FileWrite() */ -#endif +#endif #endif /* #ifdef VCF)READTEST */ @@ -2204,14 +2201,14 @@ void ziop_HistogramEvent( { /* Lowest to higest ordered list sorted by event value */ for ( index = 0; index < ZIOP_HWB_DEFAULT-1; index++ ) - { + { if ( event < histogram->ZH_Watermarks.ZHW_Bucket[index+1].ZHWB_Event ) { break; } - histogram->ZH_Watermarks.ZHW_Bucket[index] = - histogram->ZH_Watermarks.ZHW_Bucket[index+1]; + histogram->ZH_Watermarks.ZHW_Bucket[index] = + histogram->ZH_Watermarks.ZHW_Bucket[index+1]; } histogram->ZH_Watermarks.ZHW_Bucket[index].ZHWB_Event = event; // histogram->ZH_Watermarks.ZHW_Bucket[index].ZHWB_Time = GetUTCTime(); @@ -2430,10 +2427,10 @@ void zDisplayHistogramSpread( hist->ZH_BucketSize[count], percent/100, percent - (percent/100)*100, ((QUAD *)buckets)[count] ); - VIRT_ssprintf( virtInfo, "%u.%02u, %Lu, ", + VIRT_ssprintf( virtInfo, "%u.%02u, %Lu, ", percent2/100, percent2 - (percent2/100)*100, ((QUAD *)totals)[count] ); - VIRT_ssprintf( virtInfo, "%u.%02u, %Lu\n", + VIRT_ssprintf( virtInfo, "%u.%02u, %Lu\n", percentFAT/100, percentFAT - (percentFAT/100)*100, ((QUAD *)fatTotals)[count] ); } @@ -2448,3 +2445,5 @@ void zDisplayHistogramSpread( } /* End of zDisplayHistogramSpread() */ #endif /* #ifdef VCF_BROWSE */ + + diff --git a/src/nwnss/zlss/zlssIOPerformance.h b/src/nwnss/zlss/zlssIOPerformance.h index cd5a958..3b87bb2 100644 --- a/src/nwnss/zlss/zlssIOPerformance.h +++ b/src/nwnss/zlss/zlssIOPerformance.h @@ -224,7 +224,7 @@ typedef struct ZiopHighWatermarkBucket_s { QUAD ZHWB_Event; // time_t ZHWB_Time; - QUAD ZHWB_FileSize; + QUAD ZHWB_FileSize; QUAD ZHWB_FATSize; LONG ZHWB_Padding[1]; } ZiopHighWatermarkBucket_s; @@ -232,7 +232,7 @@ typedef struct ZiopHighWatermarkBucket_s #define ZIOP_HWB_DEFAULT 10 -typedef struct ZiopHighWatermark_s +typedef struct ZiopHighWatermark_s { ZiopHighWatermarkBucket_s ZHW_Bucket[ZIOP_HWB_DEFAULT]; } ZiopHighWatermark_s; diff --git a/src/nwnss/zlss/zlssLKM.c b/src/nwnss/zlss/zlssLKM.c new file mode 100644 index 0000000..5da098a --- /dev/null +++ b/src/nwnss/zlss/zlssLKM.c @@ -0,0 +1,245 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $ + | + | $RCSfile$ + | $Revision: 1177 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Initialize ZSTORE + +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include + +#include + +#include /* FixFixFix(_linux__) Will not need after Linux port is done */ +//#include +#include +//#include +#include "zOmni.h" +#include "parse.h" +//#include "nssOSAPIs.h" +#include "zfs.h" +#include "zlssStartup.h" + +/*------------------------------------------------------------------------- + * Global variables + *-------------------------------------------------------------------------*/ +char **NSSMessageTable; + +void *ZSTORE_ModuleHandle; +void *ZSTORE_DefaultScreen; + +static LONG ZSTORE_ModuleIsLoaded = 0; +# define LOADED_MAGIC 0x54494E4a + + +/*------------------------------------------------------------------------- + * Defines the CallBacks for NSS + *-------------------------------------------------------------------------*/ +NSSRegistrationCallBacks_s ZSTORE_CallBacks = +{ + ZSTORE_GlobalStartup, + NULL +}; + +/*------------------------------------------------------------------------- + * Defines the name of this MODULE. + *-------------------------------------------------------------------------*/ +STATIC char myNLMName[] = MODULE_NAME; +//#ifdef UNOPT +// MSGNot("u") MODULE_NAME; +//#else +// MODULE_NAME; +//#endif + +const char Module[] = MODULE_NAME; + + +/************************************************************************** + * Load function for the NLM initialization process + ***************************************************************************/ +LONG GenericStartRoutine( + void *handle, + void *errorScreen, + BYTE *cmdLine) +{ + STATUS status; +#ifndef __linux__ + LONG numMessages; + LONG languageID; + BYTE *helpFile; + LONG result; +#endif + char zstore_CommandLine[128]; + +/*------------------------------------------------------------------------- + * Init global variables + *-------------------------------------------------------------------------*/ + MPKNSS_LOCK(); + ZSTORE_ModuleHandle = handle; + ZSTORE_DefaultScreen = errorScreen; + strmcpy(zstore_CommandLine,cmdLine,sizeof(zstore_CommandLine)); +/*------------------------------------------------------------------------- + * setup message file + *-------------------------------------------------------------------------*/ +#ifndef __linux__ + ZOS_ReturnMessageInformation(result,(LONG)handle, (BYTE ***)&NSSMessageTable, + &numMessages, &languageID, &helpFile); + if ( result != zOK) + { + ERROR_LOADING_MSG_TABLES(errorScreen); + MPKNSS_UNLOCK(); + return zFAILURE; + } +#endif +/*------------------------------------------------------------------------- + * See if the module is already loaded, if so, return now. If not init + * the SYSTEM. + *-------------------------------------------------------------------------*/ + /*- ck if module is already loaded, yet return now -*/ + if(ZSTORE_ModuleIsLoaded == LOADED_MAGIC) + { + MPKNSS_UNLOCK(); + return zOK; + } + /* mark module loaded */ + ZSTORE_ModuleIsLoaded = LOADED_MAGIC; + + LB_ParseCmdline(ZSTORE_CommandLineSwitches, POPT_AT_STARTUP, + zstore_CommandLine, NULL); + { + // sksmith - this version and copyright string are for the MSG file + char *ver = MSG("VeRsIoN=2.70 Novell Storage Services (NSS) LSS",115); + char *copyR = MSG("CoPyRiGhT=(c) 1995-1998 Novell, Inc. All rights reserved.",931); + if (ver && copyR) + { + } + } +/*------------------------------------------------------------------------- + * Register with NSS and tell them we are HERE. + *-------------------------------------------------------------------------*/ + status = NSS_RegisterExternalNLM( + myNLMName, + ZSTORE_ModuleHandle, + NSSMessageTable, + NSSMODULETYPE_LSS, + NSSREGFLAG_REQUIRED, + &ZSTORE_VersionInfo, + NSSAPI_VERSION, + NSS_SNAPDATE, + NSS_DEBUG_STATE, + NSS_MP_FLAG, + ZSTORE_CommandLineSwitches, + &ZSTORE_CallBacks); + + if (status != zOK) + { + MPKNSS_UNLOCK(); + return zFAILURE; + } + MPKNSS_UNLOCK(); + return zOK; +} + + +/************************************************************************** + * This routine is called to UNLOAD the nlm + ***************************************************************************/ +LONG GenericExitRoutine(void) +{ + MPKNSS_LOCK(); + + if (ZSTORE_ModuleIsLoaded == LOADED_MAGIC) + { + ZSTORE_GlobalShutdown(); + NSS_UnRegisterExternalNLM(myNLMName); + } + MPKNSS_UNLOCK(); + return zOK; +} + + +void __cyg_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void __cyg_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_enter (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); +void nss_profile_func_exit (void *this_fn, void *call_site) + __attribute__ ((no_instrument_function)); + + +void __cyg_profile_func_enter (void *this_fn, void *call_site) +{ + nss_profile_func_enter(this_fn, call_site); + return; +} + +void __cyg_profile_func_exit (void *this_fn, void *call_site) +{ + nss_profile_func_exit(this_fn, call_site); + return; +} + +static int __init zlss_init(void) +{ + LONG retc; + + mpkEnter(); + printk("<1>" "ZLSS::%s[%d]\n", __FILE__, __LINE__ ); + retc = GenericStartRoutine( &init_module, "", "" ); + printk("<1>" "ZLSS::%s[%d]\n", __FILE__, __LINE__ ); + mpkExit(); + return(retc); // TODO: Is this correct for LINUX +} + + +static void __exit zlss_exit(void) +{ + mpkEnter(); + printk("<1>" "ZLSS::%s[%d]\n", __FILE__, __LINE__ ); + GenericExitRoutine(); + printk("<1>" "ZLSS::%s[%d]\n", __FILE__, __LINE__ ); + mpkExit(); +} + + +MODULE_AUTHOR("Novell, Inc."); +MODULE_DESCRIPTION("ZLSS"); +MODULE_LICENSE("GPL v2"); + +module_init(zlss_init) +module_exit(zlss_exit) diff --git a/src/nwnss/zlss/zlssLSSOps.c b/src/nwnss/zlss/zlssLSSOps.c new file mode 100644 index 0000000..eb157d7 --- /dev/null +++ b/src/nwnss/zlss/zlssLSSOps.c @@ -0,0 +1,1924 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1999 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advanced File Services (NSS) Initialization module + | + |--------------------------------------------------------------------------- + | + | $Author: mvijai $ + | $Date: 2008-03-18 14:53:48 +0530 (Tue, 18 Mar 2008) $ + | + | $RCSfile$ + | $Revision: 2302 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | This contains all of the PACK and UNPACK routines for ZSTORE. + +-------------------------------------------------------------------------*/ +#include + +#include +#include +#include +#include +#include + +#include "comnBeasts.h" +#include "comnZAS.h" +#include "beastTree.h" +#include "comnAuthorize.h" +#include "extAttrBeast.h" +#include "comnPublics.h" +#include "zlssStartup.h" +#include "comnVariableData.h" +#include "objectIDStore.h" +#include + + +/*=========================================================================== + *=========================================================================== + * + * LSSOps for RootBeast_s + * + *=========================================================================== + *===========================================================================*/ + + +/**************************************************************************** + * Returns size of File Map in bytes + *****************************************************************************/ + +STATIC NINT rootZFSFmapSize (Fmap_s *fmap) +{ + ASSERT_MPKNSS_LOCK(); + zASSERT( fmap->numRecs <= MAX_DIRECT ); + return (sizeof(Blknum_t) + (sizeof(LONG)) + + (2 * sizeof(Blknum_t) * fmap->numRecs)); +} + +/**************************************************************************** + * Return the current size of a PACKED root. + *****************************************************************************/ + +STATIC NINT rootZFSPackedSize( + void *beast_LX) +{ + RootBeast_s *beast = (RootBeast_s *)beast_LX; + NINT packedSize; + + ASSERT_MPKNSS_LOCK(); + packedSize = (sizeof(ZFSPackedRoot_s) + + (rootZFSFmapSize( &beast->storage.zfsInfo->fmap))); + + if (beast->ROOTvariableData) + packedSize += COMN_PackedSizeRootVariableData(beast); + + return(packedSize); +} + + +/**************************************************************************** + * EXTENT BASED storage pack routine + *****************************************************************************/ +STATIC BYTE *rootZFSPack( + void *beast_LX, + BYTE *storeBuffer) +{ + RootBeast_s *beast = (RootBeast_s *)beast_LX; + ZFSPackedRoot_s *phys; + ZFSStorageInfo_s *stinfo; + BYTE *tempPtr; + + ASSERT_MPKNSS_LOCK(); + zASSERT(beast->storage.zfsInfo != NULL); + stinfo = beast->storage.zfsInfo; + +//DBG_DebugPrintf(LCYAN, "PACK: beast %Ld\n", beast->zid); + phys = (ZFSPackedRoot_s *)storeBuffer; + zASSERT(phys->header.zid == beast->zid); +/* These fields are filled in by the b-tree insert routine + phys->header.length = beast->packedMetadataSize; + phys->header.magic = NODE_MAGIC; + phys->header.zid = beast->zid; +*/ + + phys->header.type = beast->beastClass->classID; + phys->blkSizeShift = beast->blkSizeShift; + phys->eof = beast->ROOTeof; + phys->ownerID = beast->ROOTownerID; + phys->metaDataSeqNum = beast->ROOTmetaDataSeqNum; + /* We only write the newest beast version whenever we write a + beast out. This was true because all memory copies of the beast + are the newest version (the UNPACK routines ensure this). However, + upgrade to version 3 happens at runtime, not beast unpack time. + phys->beastLayout = CURRENT_BEAST_VERSION; */ + phys->beastLayout = beast->ROOTbeastVersion > BEAST_VERSION_2 ? + beast->ROOTbeastVersion : BEAST_VERSION_2; // cnt + +#if ZSTORE_BEAST_LAYOUT != 1 + /* Once we have 2+ layout versions we must also update + * in-memory (stinfo) to indicate that the beast is of + * new type. + */ + stinfo->beastLayout = ZSTORE_BEAST_LAYOUT; +#endif + phys->nextBlk = stinfo->nextBlk; + phys->fmapDataBlks = stinfo->fmapDataBlks; + phys->fmapTreeBlks = stinfo->fmapTreeBlks; + phys->sizeFmap = rootZFSFmapSize( &stinfo->fmap); + phys->variableSize = 0; /* Default to no variable data */ + phys->rebuildMagic = stinfo->rebuildMagic; + + + /* increment store buffer, leaving phys pointing to ZFSPackedRoot_s */ + storeBuffer += sizeof(ZFSPackedRoot_s); + + /* Deal with the variable data */ + if (beast->ROOTvariableData) + { + /* Pack the variable data, and update the phys->variableSize */ + tempPtr = COMN_PackRootVariableData(beast,storeBuffer); + if (tempPtr == NULL) + return(NULL); + + phys->variableSize = tempPtr - storeBuffer; + storeBuffer = tempPtr; + } + + memcpy(storeBuffer, &stinfo->fmap, phys->sizeFmap); + + return (storeBuffer + phys->sizeFmap); +} + + +/**************************************************************************** + * EXTENT BASED storage pack routines + *****************************************************************************/ +STATIC BYTE *rootZFSUnpack( + GeneralMsg_s *genMsg, + void *beast_LX, + BYTE *storeBuffer) +{ + RootBeast_s *beast = (RootBeast_s *)beast_LX; + ZFSPackedRoot_s *phys; + ZFSStorageInfo_s *stinfo; + BYTE *tempPtr; + BOOL copyFmap = TRUE; + LONG adjustPhysFmapSize = 0; + + ASSERT_MPKNSS_LOCK(); + zASSERT(beast->storage.info != NULL); + stinfo = beast->storage.zfsInfo; + + /* This field must always be at the front of the packed root */ + phys = (ZFSPackedRoot_s *)storeBuffer; + beast->ROOTbeastVersion = phys->beastLayout; +//DBG_DebugPrintf(LBLUE, "UNPACK: version=%d beast=%Ld\n", phys->beastLayout, +// phys->header.zid); + +// cnt if (beast->ROOTbeastVersion == CURRENT_BEAST_VERSION) + if (beast->ROOTbeastVersion == BEAST_VERSION_1) // cnt + { + V1_ZFSPackedRoot_s *physV1; + +#if (CURRENT_BEAST_VERSION != BEAST_VERSION_3) +#error "Check to see if the beastVersion code below is still correct." +#endif + + physV1 = (V1_ZFSPackedRoot_s *)storeBuffer; + zASSERT(physV1->header.magic == NODE_MAGIC); + zASSERT(physV1->header.type == beast->beastClass->classID); + + beast->zid = physV1->header.zid; +#if NSS_DEBUG IS_ENABLED +DBG_DebugPrintf(LMAGENTA, "On-the-fly convert of root beast %Ld.\n", beast->zid); +#endif + beast->eof = physV1->eof; + beast->blkSizeShift = physV1->blkSizeShift; + beast->metaDataSeqNum = physV1->metaDataSeqNum; + +#if ZSTORE_BEAST_LAYOUT != 1 + /* We must store the persistent beast layout number so that + * other unpack routines can look at and unpack correctly. + * + * Only need to unpack when it is possible that beast layout is + * not 1. So do not need this line until after version 1. + */ + stinfo->beastLayout = physV1->beastLayout; +#endif + if ((genMsg->flags & DO_NOT_UNPACK_FMAP) && + (beast->ROOTvolume->VOLenabledAttributes & zATTR_COW)) + { + stinfo->nextBlk = 0; + stinfo->fmapDataBlks = 0; + stinfo->fmapTreeBlks = 0; + copyFmap = FALSE; + stinfo->rebuildMagic = REBUILD_FILE_IS_SNAPSHOT; + } + else + { + stinfo->nextBlk = physV1->nextBlk; + stinfo->fmapDataBlks = physV1->fmapDataBlks; + stinfo->fmapTreeBlks = physV1->fmapTreeBlks; + stinfo->rebuildMagic = physV1->rebuildMagic; + } + + beast->ownerID = zINVALID_USERID; + storeBuffer += sizeof(V1_ZFSPackedRoot_s); + + /* Deal with the variable data */ + if (physV1->variableSize) + { //fixfixfix - shoul also subtract off phys->sizeFmap also + if ( physV1->variableSize > ((physV1->header.length) - (sizeof(*physV1))) ) + { + zASSERT( "physV1->variableSize size too big to be legal" == NULL ); + SetErrno( genMsg, zERR_BEAST_CORRUPTED ); + return(NULL); + } + + /* Unpack the variable data */ + tempPtr = COMN_UnpackRootVariableData(genMsg,beast,storeBuffer, + physV1->variableSize); + if (tempPtr == NULL) + return(NULL); + + zASSERT(physV1->variableSize == (tempPtr - storeBuffer)); + storeBuffer = tempPtr; + } + /* Outside 'if copyFmap' because we use size in + * our return statement. + */ + if ( physV1->sizeFmap > ((sizeof(Blknum_t) + (sizeof(LONG)) + + (2 * sizeof(Blknum_t) * MAX_DIRECT)) ) ) + { + zASSERT( "physV1->sizeFmap size too big to be legal" == NULL ); + SetErrno( genMsg, zERR_BEAST_CORRUPTED ); + return(NULL); + } + if (copyFmap) + { + memcpy( &stinfo->fmap, storeBuffer, physV1->sizeFmap); + if ( stinfo->fmap.numRecs > MAX_DIRECT) + { + zASSERT( stinfo->fmap.numRecs <= MAX_DIRECT ); + SetErrno( genMsg, zERR_BEAST_CORRUPTED ); + return(NULL); + } + if ( stinfo->fmap.numRecs > 0 ) + { + if ( stinfo->fmap.dirExt[0].count != 0 ) + { + zASSERT( stinfo->fmap.dirExt[0].count == 0 ); + SetErrno( genMsg, zERR_BEAST_CORRUPTED ); + return(NULL); + } + if ( stinfo->fmap.dirExt[0].poolBlk != 0 ) + { + zASSERT( stinfo->fmap.dirExt[0].poolBlk == 0 ); + SetErrno( genMsg, zERR_BEAST_CORRUPTED ); + return(NULL); + } + } + } + /* + * The beast is not marked dirty here because we do not want some + * beasts written back out. Instead the beast is marked dirty in + * BEASTHASH_insert. + */ +// if (beast->ROOTvolume->state == zVOLSTATE_ACTIVE) +// { +// COMN_MARK_BEAST_DIRTY_NOLATCH(beast); +// } + return (storeBuffer + physV1->sizeFmap); + } + else + { /* no conversion */ + zASSERT(phys->header.magic == NODE_MAGIC); + zASSERT(phys->header.type == beast->beastClass->classID); + + beast->zid = phys->header.zid; + beast->eof = phys->eof; + beast->blkSizeShift = phys->blkSizeShift; + beast->metaDataSeqNum = phys->metaDataSeqNum; + +#if ZSTORE_BEAST_LAYOUT != 1 + /* We must store the persistent beast layout number so that + * other unpack routines can look at and unpack correctly. + * + * Only need to unpack when it is possible that beast layout is + * not 1. So do not need this line until after version 1. + */ + stinfo->beastLayout = phys->beastLayout; +#endif + if ((genMsg->flags & DO_NOT_UNPACK_FMAP) && + (beast->ROOTvolume->VOLenabledAttributes & zATTR_COW)) + { + stinfo->nextBlk = 0; + stinfo->fmapDataBlks = 0; + stinfo->fmapTreeBlks = 0; + stinfo->rebuildMagic = REBUILD_FILE_IS_SNAPSHOT; + copyFmap = FALSE; + } + else + { + stinfo->nextBlk = phys->nextBlk; + stinfo->fmapDataBlks = phys->fmapDataBlks; + stinfo->fmapTreeBlks = phys->fmapTreeBlks; + stinfo->rebuildMagic = phys->rebuildMagic; + } + + beast->ownerID = phys->ownerID; + storeBuffer += sizeof(ZFSPackedRoot_s); + + /* Deal with the variable data */ + if (phys->variableSize) + { //fixfixfix - shoul also subtract off phys->sizeFmap also + if ( phys->variableSize > ((phys->header.length) - (sizeof(*phys))) ) + { + zASSERT( "phys->variableSize size too big to be legal" == NULL ); + SetErrno( genMsg, zERR_BEAST_CORRUPTED ); + return(NULL); + } + + /* Unpack the variable data */ + tempPtr = COMN_UnpackRootVariableData(genMsg,beast,storeBuffer, + phys->variableSize); + if (tempPtr == NULL) + return(NULL); + + zASSERT(phys->variableSize == (tempPtr - storeBuffer)); + storeBuffer = tempPtr; + } + /* Outside 'if copyFmap' because we use size in + * our return statement. + */ + if (phys->sizeFmap > (sizeof(Fmap_s) + sizeof(LONG))) + { + /* + * 363079 - On 64-bit servers, OES2 code had copied 4 extra bytes at the + * end of Fmap and sizeFmap was also updated to indicate 4 extra bytes. + * + * If sizeFmap from disk indicates 4 extra bytes (irrespective of whether it + * was due to the above issue, reduce it to the right size. When this is done, + * storeBuffer is updated to ignore the 4 extra bytes. + * + * Not making this change for V1 style beasts as beasts packed by 64-bit + * OES2 should at least be v3. + */ + if(phys->sizeFmap == (sizeof(Fmap_s) + sizeof(LONG))) + { + phys->sizeFmap -= sizeof(LONG); + adjustPhysFmapSize = sizeof(LONG); + } + else + { + zASSERT( "phys->sizeFmap size too big to be legal" == NULL ); + SetErrno( genMsg, zERR_BEAST_CORRUPTED ); + return(NULL); + } + } + + if (copyFmap) + { + memcpy( &stinfo->fmap, storeBuffer, phys->sizeFmap); + if ( stinfo->fmap.numRecs > MAX_DIRECT) + { + zASSERT( stinfo->fmap.numRecs <= MAX_DIRECT ); + SetErrno( genMsg, zERR_BEAST_CORRUPTED ); + return(NULL); + } + if ( stinfo->fmap.numRecs > 0 ) + { + if ( stinfo->fmap.dirExt[0].count != 0 ) + { + zASSERT( stinfo->fmap.dirExt[0].count == 0 ); + SetErrno( genMsg, zERR_BEAST_CORRUPTED ); + return(NULL); + } + if ( stinfo->fmap.dirExt[0].poolBlk != 0 ) + { + zASSERT( stinfo->fmap.dirExt[0].poolBlk == 0 ); + SetErrno( genMsg, zERR_BEAST_CORRUPTED ); + return(NULL); + } + } + } + return (storeBuffer + phys->sizeFmap + adjustPhysFmapSize); + } +} + +/*--------------------------------------------------------------------------- + * Root beast STORAGE ops definition + *---------------------------------------------------------------------------*/ +LSSSpecificPackUnpackOps_s ROOTBEAST_lssOps = + {zLSS_ID_ZLSS,rootZFSPackedSize,rootZFSPack,NULL,rootZFSUnpack}; + + + + +/*=========================================================================== + *=========================================================================== + * + * LSSOps for NamedBeast_s + * + *=========================================================================== + *===========================================================================*/ + +/**************************************************************************** + * Get the PACKED size of a parent entry + *****************************************************************************/ +STATIC NINT ZFSpackedParentSize( + ParentEntry_s *pentry) +{ + NINT packedSize; + LinkedNameEntry_s *nentry; + + ASSERT_MPKNSS_LOCK(); + packedSize = sizeof(PersistentParentEntry_s); + switch (pentry->p.nameType) + { + case zNTYPE_DELETED_FILE: + /* If we are deleted, but have zero names, we are a hardlink INODE + * beast. In this case, the INODE has a deleted name type, but + * DOES NOT have a DeletedPersistentParentEntry_s associated with + * it. + */ + if (pentry->p.numNames != 0) + { + packedSize += sizeof(DeletedPersistentParentEntry_s); + } + break; + default: + break; + } + + zASSERT(pentry->p.numNames == DQ_CNT(&pentry->names)); + DQ_FOREACH(&pentry->names,nentry,LinkedNameEntry_s,nlink) + { + packedSize += (REALSIZE_PersistentNameEntry_s + NAMED_GET_NSIZE(&nentry->p)); + } + return packedSize; +} + +#if (CURRENT_BEAST_VERSION != BEAST_VERSION_3) +#error "Check to see if the beastVersion code below is still correct." +#endif +/**************************************************************************** + * ZFS storage pack routine + *****************************************************************************/ +STATIC NINT namedZFSPackedSize( + void *beast_LX) +{ + NamedBeast_s *beast = (NamedBeast_s *)beast_LX; + + LinkedParentEntry_s *lpentry; + NINT packedSize; + + ASSERT_MPKNSS_LOCK(); + +#ifndef ONE_OFF_FOR_KEIPPER + if(beast->NAMEDbeastVersion > BEAST_VERSION_2) + { + packedSize = sizeof(PersistentNamed3_s); + if (beast->NAMEDnumParents > 0) + { + packedSize += ZFSpackedParentSize(&beast->firstParent); + } + } + else + { + packedSize = sizeof(PersistentNamed2_s); + if (beast->NAMEDnumParents > 0) + { + packedSize += ZFSpackedParentSize(&beast->firstParent); + zASSERT((beast->NAMEDnumParents-1) == DQ_CNT(&beast->NAMEDreserved)); /* old style hardlinks */ + DQ_FOREACH(&beast->NAMEDreserved,lpentry,LinkedParentEntry_s,plink) + { + packedSize += ZFSpackedParentSize(&lpentry->pentry); + } + } + } +#endif + +#ifdef ONE_OFF_FOR_KEIPPER + if((beast->NAMEDvolume->VOLmediaFormatMajor < 38) || + ((beast->NAMEDvolume->VOLmediaFormatMajor == 38) && (beast->NAMEDvolume->VOLmediaFormatMinor <= 3))) + { + if(beast->NAMEDbeastVersion == BEAST_VERSION_KEIPPER) + { + packedSize = sizeof(PersistentNamed3_s); + if (beast->NAMEDnumParents > 0) + { + packedSize += ZFSpackedParentSize(&beast->firstParent); + } + } + else if(beast->NAMEDbeastVersion == BEAST_VERSION_3) + { + packedSize = sizeof(PersistentNamed2_s); + if (beast->NAMEDnumParents > 0) + { + packedSize += ZFSpackedParentSize(&beast->firstParent); + } + } + else if(beast->NAMEDbeastVersion == BEAST_VERSION_2) + { + packedSize = sizeof(PersistentNamed2_s); + if (beast->NAMEDnumParents > 0) + { + packedSize += ZFSpackedParentSize(&beast->firstParent); + zASSERT((beast->NAMEDnumParents-1) == DQ_CNT(&beast->NAMEDreserved)); /* old style hardlinks */ + DQ_FOREACH(&beast->NAMEDreserved,lpentry,LinkedParentEntry_s,plink) + { + packedSize += ZFSpackedParentSize(&lpentry->pentry); + } + } + } + else + { + zASSERT("Found unfamiliar version beast in namedZFSPackedSize" == NULL); + } + } + else if((beast->NAMEDvolume->VOLmediaFormatMajor > 38) || + ((beast->NAMEDvolume->VOLmediaFormatMajor == 38) && (beast->NAMEDvolume->VOLmediaFormatMinor >= 4))) + { + if((beast->NAMEDbeastVersion == BEAST_VERSION_KEIPPER) || (beast->NAMEDbeastVersion == BEAST_VERSION_3)) + { + packedSize = sizeof(PersistentNamed3_s); + if (beast->NAMEDnumParents > 0) + { + packedSize += ZFSpackedParentSize(&beast->firstParent); + } + } + else if(beast->NAMEDbeastVersion == BEAST_VERSION_2) + { + packedSize = sizeof(PersistentNamed2_s); + if (beast->NAMEDnumParents > 0) + { + packedSize += ZFSpackedParentSize(&beast->firstParent); + zASSERT((beast->NAMEDnumParents-1) == DQ_CNT(&beast->NAMEDreserved)); /* old style hardlinks */ + DQ_FOREACH(&beast->NAMEDreserved,lpentry,LinkedParentEntry_s,plink) + { + packedSize += ZFSpackedParentSize(&lpentry->pentry); + } + } + } + else + { + zASSERT("Found unfamiliar version beast in namedZFSPackedSize" == NULL); + } + } +#endif + return packedSize; +} + + +/**************************************************************************** + * + *****************************************************************************/ +STATIC BYTE *ZFSpackParent( + BYTE *buf, + ParentEntry_s *pentry) +{ + NINT size; + LinkedNameEntry_s *nentry; + + ASSERT_MPKNSS_LOCK(); + zASSERT(pentry->p.numNames == DQ_CNT(&pentry->names)); + memcpy(buf,&pentry->p,sizeof(PersistentParentEntry_s)); + buf += sizeof(PersistentParentEntry_s); + switch (pentry->p.nameType) + { + case zNTYPE_DELETED_FILE: + /* If we are deleted, but have zero names, we are a hardlink INODE + * beast. In this case, the INODE has a deleted name type, but + * DOES NOT have a DeletedPersistentParentEntry_s associated with + * it. + */ + if (pentry->p.numNames != 0) + { + zASSERT(pentry->t != NULL); /* cnt - If this happens, fix the cause. This is a required field. */ + memcpy(buf,&pentry->t->u.deleted, + sizeof(DeletedPersistentParentEntry_s)); + buf += sizeof(DeletedPersistentParentEntry_s); + } + break; + default: + break; + } + DQ_FOREACH(&pentry->names,nentry,LinkedNameEntry_s,nlink) + { + size = REALSIZE_PersistentNameEntry_s + NAMED_GET_NSIZE(&nentry->p); + memcpy(buf,&nentry->p,size); /* this does NOT copy the NULL*/ + buf += size; + } + return buf; +} + + +/**************************************************************************** + * ZFS storage pack routine + *****************************************************************************/ +STATIC BYTE *namedZFSPack( + void *beast_LX, + BYTE *storeBuffer) +{ + NamedBeast_s *beast = (NamedBeast_s *)beast_LX; + LinkedParentEntry_s *lpentry; + + ASSERT_MPKNSS_LOCK(); + +#ifndef ONE_OFF_FOR_KEIPPER + if(beast->NAMEDbeastVersion > BEAST_VERSION_2) + { + memcpy(storeBuffer,&beast->p,sizeof(PersistentNamed3_s)); + storeBuffer += sizeof(PersistentNamed3_s); + if (beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSpackParent(storeBuffer,&beast->firstParent); + } + } + else + { + memcpy(storeBuffer,&beast->p,sizeof(PersistentNamed2_s)); + storeBuffer += sizeof(PersistentNamed2_s); + if (beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSpackParent(storeBuffer,&beast->firstParent); + zASSERT(beast->NAMEDnumParents == (DQ_CNT(&beast->NAMEDreserved)+1)); + DQ_FOREACH(&beast->NAMEDreserved,lpentry,LinkedParentEntry_s,plink) + { + storeBuffer = ZFSpackParent(storeBuffer,&lpentry->pentry); + } + } + } +#endif + +#ifdef ONE_OFF_FOR_KEIPPER + if((beast->NAMEDvolume->VOLmediaFormatMajor < 38) || + ((beast->NAMEDvolume->VOLmediaFormatMajor == 38) && (beast->NAMEDvolume->VOLmediaFormatMinor <= 3))) + { + if(beast->NAMEDbeastVersion == BEAST_VERSION_KEIPPER) + { + memcpy(storeBuffer,&beast->p,sizeof(PersistentNamed3_s)); + storeBuffer += sizeof(PersistentNamed3_s); + if (beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSpackParent(storeBuffer,&beast->firstParent); + } + + } + else if(beast->NAMEDbeastVersion == BEAST_VERSION_3) + { + memcpy(storeBuffer,&beast->p,sizeof(PersistentNamed2_s)); + storeBuffer += sizeof(PersistentNamed2_s); + if (beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSpackParent(storeBuffer,&beast->firstParent); + } + } + else if(beast->NAMEDbeastVersion == BEAST_VERSION_2) + { + memcpy(storeBuffer,&beast->p,sizeof(PersistentNamed2_s)); + storeBuffer += sizeof(PersistentNamed2_s); + if (beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSpackParent(storeBuffer,&beast->firstParent); + zASSERT(beast->NAMEDnumParents == (DQ_CNT(&beast->NAMEDreserved)+1)); + DQ_FOREACH(&beast->NAMEDreserved,lpentry,LinkedParentEntry_s,plink) + { + storeBuffer = ZFSpackParent(storeBuffer,&lpentry->pentry); + } + } + } + else + { + zASSERT("Found unfamiliar beast in namedZFSPack" == NULL); + } + } + else if((beast->NAMEDvolume->VOLmediaFormatMajor == 38) && (beast->NAMEDvolume->VOLmediaFormatMinor >= 4)) + { + if((beast->NAMEDbeastVersion == BEAST_VERSION_KEIPPER) || (beast->NAMEDbeastVersion == BEAST_VERSION_3)) + { + memcpy(storeBuffer,&beast->p,sizeof(PersistentNamed3_s)); + storeBuffer += sizeof(PersistentNamed3_s); + if (beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSpackParent(storeBuffer,&beast->firstParent); + } + } + else if(beast->NAMEDbeastVersion == BEAST_VERSION_2) + { + memcpy(storeBuffer,&beast->p,sizeof(PersistentNamed2_s)); + storeBuffer += sizeof(PersistentNamed2_s); + if (beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSpackParent(storeBuffer,&beast->firstParent); + zASSERT(beast->NAMEDnumParents == (DQ_CNT(&beast->NAMEDreserved)+1)); + DQ_FOREACH(&beast->NAMEDreserved,lpentry,LinkedParentEntry_s,plink) + { + storeBuffer = ZFSpackParent(storeBuffer,&lpentry->pentry); + } + } + } + } +#endif + + + return storeBuffer; +} + + +/**************************************************************************** + * This unpacks all of the names associated with a given parent. + *****************************************************************************/ +BYTE *ZFSunpackParent( + GeneralMsg_s *genMsg, + NamedBeast_s *beast, + BYTE *storeBuffer, + ParentEntry_s *pentry) +{ + NINT i; + NINT len; + NINT size; + STATUS status; + LinkedNameEntry_s *lnentry; + V1_DeletedPersistentParentEntry_s *oldEntry; + + ASSERT_MPKNSS_LOCK(); + DQ_INIT(&pentry->names); + + memcpy(&pentry->p,storeBuffer,sizeof(PersistentParentEntry_s)); + storeBuffer += sizeof(PersistentParentEntry_s); + switch (pentry->p.nameType) + { + case zNTYPE_DELETED_FILE: + /* If we are deleted, but have zero names, we are a hardlink INODE + * beast. In this case, the INODE has a deleted name type, but + * DOES NOT have a DeletedPersistentParentEntry_s associated with + * it. + */ + if (pentry->p.numNames != 0) + { + pentry->t = malloc(sizeof(TypeSpecificPersistentParentEntry_s)); + if (pentry->t == NULL) + { + SetErrno(genMsg,zERR_NO_MEMORY); + goto error_cleanup; + } + + /* + * Do on-the-fly conversion if the data has not been converted. + */ + if (beast->NAMEDbeastVersion == BEAST_VERSION_1) + { /* convert to the new format */ + oldEntry = (V1_DeletedPersistentParentEntry_s *)storeBuffer; + pentry->t->u.deleted.time = oldEntry->time; +#if zNETWARE + COMN_MapNDSIDToGUID(&status, oldEntry->ID, + &pentry->t->u.deleted.ID); +#endif +#if zLINUX + status = zFAILURE; + pentry->t->u.deleted.ID = zINVALID_USERID; + printk(KERN_ALERT "ZFSunpackParent: Processed an old-version deleted.ID\n"); +#endif + storeBuffer += sizeof(V1_DeletedPersistentParentEntry_s); + OID_SaveObjectID(beast->NAMEDvolume, &pentry->t->u.deleted.ID); + } + else + { /* no conversion */ + memcpy(&pentry->t->u.deleted,storeBuffer, + sizeof(DeletedPersistentParentEntry_s)); + storeBuffer += sizeof(DeletedPersistentParentEntry_s); + } + } + break; + default: + pentry->t = NULL; + break; + } +// zASSERT(pentry->p.magic == NAMED_TEMP_MAGIC); + + for (i=0; i < pentry->p.numNames; i++) + { + len = NAMED_GET_NLENGTH(((PersistentNameEntry_s *)storeBuffer)); + + lnentry = malloc(REALSIZE_LinkedNameEntry_s + ((len+1)*sizeof(unicode_t))/*space for NULL*/); + if (lnentry == NULL) + { + SetErrno(genMsg,zERR_NO_MEMORY); + goto error_cleanup; + } + + size = REALSIZE_PersistentNameEntry_s + (len * sizeof(unicode_t)); + memcpy(&lnentry->p,storeBuffer,size); + lnentry->p.name[len] = 0; /* null terminate the string*/ + + storeBuffer += size; + NULLIFY(&lnentry->nlink); + DQ_ENQ(&pentry->names,lnentry,nlink); + } + zASSERT(pentry->p.numNames == DQ_CNT(&pentry->names)); + return storeBuffer; + +/*--------------------------------------------------------------------------- + * Delete all of the names we have allocated so far + *---------------------------------------------------------------------------*/ +error_cleanup: + for (;;) + { + DQ_DEQ(&pentry->names,lnentry,LinkedNameEntry_s,nlink) + if (lnentry == NULL) + break; + free(lnentry); + } + pentry->p.numNames = 0; + return NULL; +} + + +/**************************************************************************** + * ZFS storage pack routines. This unpacks all of the parent entries and + * names. + *****************************************************************************/ +STATIC BYTE *namedZFSUnpack( + GeneralMsg_s *genMsg, + void *beast_LX, + BYTE *storeBuffer) +{ + NamedBeast_s *beast = (NamedBeast_s *)beast_LX; + LinkedParentEntry_s *lpentry; + NINT i; + + ASSERT_MPKNSS_LOCK(); +#ifndef ONE_OFF_FOR_KEIPPER + if(beast->NAMEDbeastVersion > BEAST_VERSION_2) + { + memcpy(&beast->p,storeBuffer,sizeof(PersistentNamed3_s)); + storeBuffer += sizeof(PersistentNamed3_s); + if(beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSunpackParent(genMsg,beast,storeBuffer, &beast->firstParent); + } + else + { + DQ_INIT(&beast->firstParent.names); + } + } + else + { + memcpy(&beast->p,storeBuffer,sizeof(PersistentNamed2_s)); + beast->NAMEDhardLinkZid = zINVALID_ZID; + storeBuffer += sizeof(PersistentNamed2_s); + DQ_INIT(&beast->NAMEDreserved); + if (beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSunpackParent(genMsg,beast,storeBuffer, + &beast->firstParent); + if (storeBuffer == NULL) + return NULL; + + for (i=1; i < beast->NAMEDnumParents;i++) + { + lpentry = malloc(sizeof(LinkedParentEntry_s)); + if (lpentry == NULL) + goto error_cleanup; + + NULLIFY(&lpentry->plink); + DQ_ENQ(&beast->NAMEDreserved,lpentry,plink); + storeBuffer = ZFSunpackParent(genMsg,beast,storeBuffer, + &lpentry->pentry); + if (storeBuffer == NULL) + goto error_cleanup; + } + zASSERT(beast->NAMEDnumParents == (DQ_CNT(&beast->NAMEDreserved)+1)); + } + else + { + DQ_INIT(&beast->firstParent.names); + } + } +#endif + +#ifdef ONE_OFF_FOR_KEIPPER + + if((beast->NAMEDvolume->VOLmediaFormatMajor < 38) || + ((beast->NAMEDvolume->VOLmediaFormatMajor == 38) && (beast->NAMEDvolume->VOLmediaFormatMinor <= 3))) + { + if(beast->NAMEDbeastVersion == BEAST_VERSION_KEIPPER) // PersistentNamed3_s on disk, and in memory + { + memcpy(&beast->p,storeBuffer,sizeof(PersistentNamed3_s)); + storeBuffer += sizeof(PersistentNamed3_s); + if(beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSunpackParent(genMsg,beast,storeBuffer, &beast->firstParent); + } + else + { + DQ_INIT(&beast->firstParent.names); + } + + } + else if(beast->NAMEDbeastVersion == BEAST_VERSION_3) // PersistentNamed2_s on disk, PersistentNamed3_s in memory + { + memcpy(&beast->p,storeBuffer,sizeof(PersistentNamed2_s)); + storeBuffer += sizeof(PersistentNamed2_s); + beast->NAMEDhardLinkZid = zINVALID_ZID; + if(beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSunpackParent(genMsg,beast,storeBuffer, &beast->firstParent); + } + else + { + DQ_INIT(&beast->firstParent.names); + } + } + else if(beast->NAMEDbeastVersion <= BEAST_VERSION_2) // PersistentNamed2_s on disk, PersistentNamed3_s in memory + { + memcpy(&beast->p,storeBuffer,sizeof(PersistentNamed2_s)); + beast->NAMEDhardLinkZid = zINVALID_ZID; + storeBuffer += sizeof(PersistentNamed2_s); + DQ_INIT(&beast->NAMEDreserved); + if (beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSunpackParent(genMsg,beast,storeBuffer, + &beast->firstParent); + if (storeBuffer == NULL) + return NULL; + + for (i=1; i < beast->NAMEDnumParents;i++) + { + lpentry = malloc(sizeof(LinkedParentEntry_s)); + if (lpentry == NULL) + goto error_cleanup; + + NULLIFY(&lpentry->plink); + DQ_ENQ(&beast->NAMEDreserved,lpentry,plink); + storeBuffer = ZFSunpackParent(genMsg,beast,storeBuffer, + &lpentry->pentry); + if (storeBuffer == NULL) + goto error_cleanup; + } + zASSERT(beast->NAMEDnumParents == (DQ_CNT(&beast->NAMEDreserved)+1)); + } + else + { + DQ_INIT(&beast->firstParent.names); + } + } + else + { + zASSERT("Found unfamiliar beast in namedZFSUnpack" == NULL); + } + } + else if((beast->NAMEDvolume->VOLmediaFormatMajor > 38) || + ((beast->NAMEDvolume->VOLmediaFormatMajor == 38) && (beast->NAMEDvolume->VOLmediaFormatMinor >= 4))) + { + if((beast->NAMEDbeastVersion == BEAST_VERSION_3) || (beast->NAMEDbeastVersion == BEAST_VERSION_KEIPPER)) + { + memcpy(&beast->p,storeBuffer,sizeof(PersistentNamed3_s)); + storeBuffer += sizeof(PersistentNamed3_s); + if(beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSunpackParent(genMsg,beast,storeBuffer, &beast->firstParent); + } + else + { + DQ_INIT(&beast->firstParent.names); + } + } + else if(beast->NAMEDbeastVersion <= BEAST_VERSION_2) + { + memcpy(&beast->p,storeBuffer,sizeof(PersistentNamed2_s)); + beast->NAMEDhardLinkZid = zINVALID_ZID; + storeBuffer += sizeof(PersistentNamed2_s); + DQ_INIT(&beast->NAMEDreserved); + if (beast->NAMEDnumParents > 0) + { + storeBuffer = ZFSunpackParent(genMsg,beast,storeBuffer, + &beast->firstParent); + if (storeBuffer == NULL) + return NULL; + + for (i=1; i < beast->NAMEDnumParents;i++) + { + lpentry = malloc(sizeof(LinkedParentEntry_s)); + if (lpentry == NULL) + goto error_cleanup; + + NULLIFY(&lpentry->plink); + DQ_ENQ(&beast->NAMEDreserved,lpentry,plink); + storeBuffer = ZFSunpackParent(genMsg,beast,storeBuffer, + &lpentry->pentry); + if (storeBuffer == NULL) + goto error_cleanup; + } + zASSERT(beast->NAMEDnumParents == (DQ_CNT(&beast->NAMEDreserved)+1)); + } + else + { + DQ_INIT(&beast->firstParent.names); + } + } + else + { + zASSERT("Found unfamiliar beast in namedZFSUnpack" == NULL); + } + } +#endif + return storeBuffer; + +/*=========================================================================*/ +error_cleanup: + for (;;) + { + DQ_DEQ(&beast->NAMEDreserved,lpentry,LinkedParentEntry_s,plink) + if (lpentry == NULL) + break; + zASSERT(DQ_EMPTY(&lpentry->pentry.names)); + free(lpentry); + } + SetErrno(genMsg,zERR_NO_MEMORY); + return NULL; +} + + +/*--------------------------------------------------------------------------- + * named beast STORAGE ops definition + *---------------------------------------------------------------------------*/ +LSSSpecificPackUnpackOps_s NAMEDBEAST_lssOps = + {zLSS_ID_ZLSS,namedZFSPackedSize,namedZFSPack,NULL,namedZFSUnpack}; + + +/**************************************************************************** + * ZFS HardLink pack routines + *****************************************************************************/ +STATIC NINT hardLinkZFSPackedSize( + void *beast_LX) +{ + ASSERT_MPKNSS_LOCK(); + return sizeof(PersistentHardLink_s) ; +} + +STATIC BYTE *hardLinkZFSPack( + void *beast_LX, + BYTE *storeBuffer) +{ + HardLinkBeast_s *beast = (HardLinkBeast_s *)beast_LX; + + ASSERT_MPKNSS_LOCK(); + memcpy(storeBuffer,&beast->p,sizeof(PersistentHardLink_s)); + storeBuffer += sizeof(PersistentHardLink_s); + return storeBuffer; +} + +STATIC BYTE *hardLinkZFSUnpack( + GeneralMsg_s *genMsg, + void *beast_LX, + BYTE *storeBuffer) +{ + HardLinkBeast_s *beast = (HardLinkBeast_s *)beast_LX; + + ASSERT_MPKNSS_LOCK(); + memcpy(&beast->p,storeBuffer,sizeof(PersistentHardLink_s)); + storeBuffer += sizeof(PersistentHardLink_s); + return storeBuffer; +} +LSSSpecificPackUnpackOps_s HARDLINK_lssOps = + {zLSS_ID_ZLSS,hardLinkZFSPackedSize,hardLinkZFSPack,NULL,hardLinkZFSUnpack}; + + +/**************************************************************************** + * EXTENT BASED storage pack routine + *****************************************************************************/ +STATIC NINT authZFSPackedSize( + void *beast_LX) +{ + AuthBeast_s *beast = (AuthBeast_s *)beast_LX; +/* + return sizeof(PersistentAuthBeast_s) + + beast->AUTHauthModelOps->packedSize(beast); +*/ + ASSERT_MPKNSS_LOCK(); + return beast->AUTHauthModelOps->packedSize(beast); +} + +/**************************************************************************** + * EXTENT BASED storage pack routine + *****************************************************************************/ +STATIC BYTE *authZFSPack( + void *beast_LX, + BYTE *storeBuffer) +{ + AuthBeast_s *beast = (AuthBeast_s *)beast_LX; +/* + Commented out because there are no fields currently to copy + memcpy(storeBuffer,&beast->p,sizeof(PersistentAuthBeast_s)); + return (beast->AUTHauthModelOps->packAuthBeast(beast, storeBuffer + + sizeof(PersistentAuthBeast_s))); +*/ + ASSERT_MPKNSS_LOCK(); + return (beast->AUTHauthModelOps->packAuthBeast(beast, storeBuffer)); +} + +/**************************************************************************** + * EXTENT BASED noPack cleanup routine + *****************************************************************************/ +STATIC void authZFSNoPackCleanup( + void *beast_LX) +{ + AuthBeast_s *beast = (AuthBeast_s *)beast_LX; + + ASSERT_MPKNSS_LOCK(); + beast->AUTHauthModelOps->noPackAuthBeastCleanup(beast); +} + +/**************************************************************************** + * EXTENT BASED storage pack routines + *****************************************************************************/ +STATIC BYTE *authZFSUnpack( + GeneralMsg_s *genMsg, + void *beast_LX, + BYTE *storeBuffer) +{ + AuthBeast_s *beast = (AuthBeast_s *)beast_LX; + STATUS status; + + ASSERT_MPKNSS_LOCK(); + /* + * This is code to do on-the-fly conversion of beast version 1 to + * beast version 2. + */ +#if (CURRENT_BEAST_VERSION != BEAST_VERSION_3) +#error "Check to see if the beastVersion code below is still correct." +#endif + if (beast->AUTHbeastVersion == BEAST_VERSION_1) + { +#if NSS_DEBUG IS_ENABLED +DBG_DebugPrintf(LMAGENTA,"On-the-fly: owner ID\n"); +#endif + +#if zNETWARE + /* convert the old ID to the new GUID and move it to the root beast */ + COMN_MapNDSIDToGUID(&status, *(LONG *)storeBuffer, + &beast->AUTHownerID); +#endif +#if zLINUX + status = zFAILURE; + beast->AUTHownerID = zINVALID_USERID; + printk(KERN_ALERT "authZFSunpack: Processed an old-version ownerID\n"); +#endif + OID_SaveObjectID(beast->AUTHvolume, &beast->AUTHownerID); + + storeBuffer += sizeof(LONG); + } + else + { +/* Commented out because there are no fields currently to copy + memcpy(&beast->p,storeBuffer,sizeof(PersistentAuthBeast_s)); + storeBuffer += sizeof(PersistentAuthBeast_s); +*/ + } + return (beast->AUTHauthModelOps->unpackAuthBeast(genMsg, beast, storeBuffer)); +} + +/*--------------------------------------------------------------------------- + * auth beast STORAGE ops definition + *---------------------------------------------------------------------------*/ +LSSSpecificPackUnpackOps_s AUTHBEAST_lssOps = + {zLSS_ID_ZLSS,authZFSPackedSize,authZFSPack,authZFSNoPackCleanup,authZFSUnpack}; + + + + +/*=========================================================================== + *=========================================================================== + * + * LSSOps for ExtAttrBeast_s + * + *=========================================================================== + *===========================================================================*/ + +/**************************************************************************** + * EXTENT BASED storage pack routine + *****************************************************************************/ +STATIC NINT extAttrZFSPackedSize( + void *beast_LX) +{ + ASSERT_MPKNSS_LOCK(); + return sizeof(PersistentExtAttrBeast_s); +} + +/**************************************************************************** + * EXTENT BASED storage pack routine + *****************************************************************************/ +STATIC BYTE *extAttrZFSPack( + void *beast_LX, + BYTE *storeBuffer) +{ + ExtAttrBeast_s *beast = (ExtAttrBeast_s *)beast_LX; + + ASSERT_MPKNSS_LOCK(); + memcpy(storeBuffer,&beast->p,sizeof(PersistentExtAttrBeast_s)); + return (storeBuffer + sizeof(PersistentExtAttrBeast_s)); +} + +/**************************************************************************** + * EXTENT BASED storage pack routines + *****************************************************************************/ +STATIC BYTE *extAttrZFSUnpack( + GeneralMsg_s *genMsg, + void *beast_LX, + BYTE *storeBuffer) +{ + ExtAttrBeast_s *beast = (ExtAttrBeast_s *)beast_LX; + + ASSERT_MPKNSS_LOCK(); + memcpy(&beast->p,storeBuffer,sizeof(PersistentExtAttrBeast_s)); + return (storeBuffer + sizeof(PersistentExtAttrBeast_s)); +} + +/*--------------------------------------------------------------------------- + * file beast STORAGE ops definition + *---------------------------------------------------------------------------*/ +LSSSpecificPackUnpackOps_s EXTATTRBEAST_lssOps = + {zLSS_ID_ZLSS,extAttrZFSPackedSize,extAttrZFSPack,NULL,extAttrZFSUnpack}; + + + + +/*=========================================================================== + *=========================================================================== + * + * LSSOps for File_s + * + *=========================================================================== + *===========================================================================*/ + +/**************************************************************************** + * EXTENT BASED storage pack routine + *****************************************************************************/ +STATIC NINT fileZFSPackedSize( + void *beast_LX) +{ +#ifdef ONE_OFF_FOR_KEIPPER + File_s *beast = (File_s *)beast_LX; +#endif + + ASSERT_MPKNSS_LOCK(); + +#ifdef ONE_OFF_FOR_KEIPPER + if((beast->FILEvolume->VOLmediaFormatMajor < 38) || + ((beast->FILEvolume->VOLmediaFormatMajor == 38) && (beast->FILEvolume->VOLmediaFormatMinor <= 3))) + { + if((beast->FILEattributes & zFA_HARDLINK) && (beast->FILEbeastVersion == BEAST_VERSION_3)) + { + return 0; // keipper version threes didn't have a file_s in them, they were authbeasts + } + } +#endif + return sizeof(PersistentFile_s); +} + +/**************************************************************************** + * EXTENT BASED storage pack routine + *****************************************************************************/ +STATIC BYTE *fileZFSPack( + void *beast_LX, + BYTE *storeBuffer) +{ + File_s *beast = (File_s *)beast_LX; + + ASSERT_MPKNSS_LOCK(); +#ifdef ONE_OFF_FOR_KEIPPER + if((beast->FILEvolume->VOLmediaFormatMajor < 38) || + ((beast->FILEvolume->VOLmediaFormatMajor == 38) && (beast->FILEvolume->VOLmediaFormatMinor <= 3))) + { + if((beast->FILEattributes & zFA_HARDLINK) && (beast->FILEbeastVersion == BEAST_VERSION_3)) + { + return storeBuffer; // keipper version threes didn't have a file_s in them, they were authbeasts + } + } +#endif + memcpy(storeBuffer,&beast->p,sizeof(PersistentFile_s)); + return (storeBuffer + sizeof(PersistentFile_s)); +} + +/**************************************************************************** + * EXTENT BASED storage pack routines + *****************************************************************************/ +STATIC BYTE *fileZFSUnpack( + GeneralMsg_s *genMsg, + void *beast_LX, + BYTE *storeBuffer) +{ + File_s *beast = (File_s *)beast_LX; + STATUS status; + V1_PersistentFile_s *oldEntry; + ASSERT_MPKNSS_LOCK(); + + +#ifdef ONE_OFF_FOR_KEIPPER + if((beast->FILEvolume->VOLmediaFormatMajor < 38) || + ((beast->FILEvolume->VOLmediaFormatMajor == 38) && (beast->FILEvolume->VOLmediaFormatMinor <= 3))) + { + if((beast->FILEattributes & zFA_HARDLINK) && (beast->FILEbeastVersion == BEAST_VERSION_3)) + { + bzero(&beast->p, sizeof(PersistentFile_s)); + return storeBuffer; // keipper version threes didn't have a file_s in them, they were authbeasts + } + } +#endif + + /* + * This is code to do on-the-fly conversion of beast version 1 to + * beast version 2. + */ + if (beast->FILEbeastVersion == BEAST_VERSION_1) + { +#if NSS_DEBUG IS_ENABLED +DBG_DebugPrintf(LMAGENTA,"On-the-fly: file\n"); +#endif +#if (CURRENT_BEAST_VERSION != BEAST_VERSION_3) +#error "Check to see if the beastVersion code below is still correct." +#endif + oldEntry = (V1_PersistentFile_s *)storeBuffer; + beast->p.accessedTime = oldEntry->accessedTime; + beast->p.createdTime = oldEntry->createdTime; + beast->p.modifiedTime = oldEntry->modifiedTime; + beast->p.metaDataModifiedTime = oldEntry->metaDataModifiedTime; + beast->p.archivedTime = oldEntry->archivedTime; +#if zNETWARE + COMN_MapNDSIDToGUID(&status, oldEntry->modifierID, + &beast->p.modifierID); +#endif +#if zLINUX + status = zFAILURE; + beast->p.modifierID = zINVALID_USERID; + printk(KERN_ALERT "fileZFSunpack: Processed an old-version beasts file IDs\n"); +#endif + + OID_SaveObjectID(beast->FILEvolume, &beast->p.modifierID); +#if zNETWARE + COMN_MapNDSIDToGUID(&status, oldEntry->metaDataModifierID, + &beast->p.metaDataModifierID); +#endif +#if zLINUX + beast->p.metaDataModifierID = zINVALID_USERID; +#endif + OID_SaveObjectID(beast->FILEvolume, &beast->p.metaDataModifierID); +#if zNETWARE + COMN_MapNDSIDToGUID(&status, oldEntry->archiverID, + &beast->p.archiverID); +#endif +#if zLINUX + beast->p.archiverID = zINVALID_USERID; +#endif + OID_SaveObjectID(beast->FILEvolume, &beast->p.archiverID); + storeBuffer += sizeof(V1_PersistentFile_s); + } + else + { + memcpy(&beast->p,storeBuffer,sizeof(PersistentFile_s)); + storeBuffer += sizeof(PersistentFile_s); + } + return (storeBuffer); +} + +/*--------------------------------------------------------------------------- + * file beast STORAGE ops definition + *---------------------------------------------------------------------------*/ +LSSSpecificPackUnpackOps_s FILEBEAST_lssOps = + {zLSS_ID_ZLSS,fileZFSPackedSize,fileZFSPack,NULL,fileZFSUnpack}; + + + + + + + + +/*=========================================================================== + *=========================================================================== + * + * LSSOps for ZasVisOverflowBeast_s + * + *=========================================================================== + *===========================================================================*/ + +/*************************************************************************** + * This routine is called when an overflow beast is written to storage + ***************************************************************************/ +NINT VISO_PackedSize( + void *overflowBeast_LX) +{ + ZasVisOverflowBeast_s *overflowBeast = (ZasVisOverflowBeast_s *)overflowBeast_LX; + + ASSERT_MPKNSS_LOCK(); + ENTER(TAUTH, VISO_PackedSize); + RTN_NINT(sizeof(PersistentZasVisOverflowBeast_s) + + (overflowBeast->p.numEntries * sizeof(VisEntry_s))); +} + +/*************************************************************************** + * This routine is called when an overflow beast is written to storage + ***************************************************************************/ +BYTE *VISO_PackBeast( + void *overflowBeast_LX, + BYTE *storeBuffer) +{ + ZasVisOverflowBeast_s *overflowBeast = (ZasVisOverflowBeast_s *)overflowBeast_LX; + NINT len; + + ASSERT_MPKNSS_LOCK(); + ENTER(TAUTH, VISO_PackBeast); + len = overflowBeast->p.numEntries * sizeof(VisEntry_s); + memcpy(storeBuffer, &overflowBeast->p, sizeof(PersistentZasVisOverflowBeast_s)); + storeBuffer += sizeof(PersistentZasVisOverflowBeast_s); + zASSERT(overflowBeast->vis != NULL); + memcpy(storeBuffer, overflowBeast->vis, len); + RTN_PTR(storeBuffer + len); +} + +/*************************************************************************** + * This routine is called when an overflow beast is read from storage + * + * Note that the vis pointer is already non-zero because the VISO + * beast's constructor allocates the default size. The realloc will + * size the memory correctly. + * + * Change made October 23, 1998 by Greg Pachner (SPD 211631) + * When this routine was changed to handle the fact that some VISO + * beasts can have 0 entries I decided that these beasts would + * have memory allocated for the VisEntry (I.E. we do not free up + * the memory allocated by our constructor). This was done because + * all the AUTH code was originally written assuming that beasts + * had this pointer. I felt that by allocating the memory fewer + * bugs would be introduced with this change. This wastes a little + * memory, but there should be VERY FEW overflow beasts with 0 entries. + ***************************************************************************/ +BYTE *VISO_UnpackBeast( + GeneralMsg_s *genMsg, + void *overflowBeast_LX, + BYTE *storeBuffer) +{ + ZasVisOverflowBeast_s *overflowBeast = (ZasVisOverflowBeast_s *)overflowBeast_LX; + NINT len; + VisEntry_s *vis; + V1_VisEntry_s *oldVis; + NINT index; + STATUS status; + + ASSERT_MPKNSS_LOCK(); + ENTER(TAUTH, VISO_UnpackBeast); + memcpy(&overflowBeast->p, storeBuffer, sizeof(PersistentZasVisOverflowBeast_s)); + storeBuffer += sizeof(PersistentZasVisOverflowBeast_s); + len = overflowBeast->p.numEntries * sizeof(VisEntry_s); + /* Under heavy REDO/UNDO testing I have seen p.numEntries set to 0 */ + if (len == 0 ) + { /*** NOT AN ERROR EXIT ***/ + RTN_PTR(storeBuffer); + } + vis = LB_realloc(overflowBeast->vis, len); + if (vis == NULL) + { /* Out of memory - overflowBeast->vis was not freed by realloc */ + SetErrno(genMsg, zERR_NO_MEMORY); + RTN_PTR(NULL); + } + overflowBeast->numAlloced = overflowBeast->p.numEntries; + overflowBeast->vis = vis; + if (overflowBeast->VISObeastVersion == BEAST_VERSION_1) + { +#if NSS_DEBUG IS_ENABLED +DBG_DebugPrintf(LMAGENTA,"On-the-fly: visibility overflow\n"); +#endif +#if (CURRENT_BEAST_VERSION != BEAST_VERSION_3) +#error "Check to see if the beastVersion code below is still correct." +#endif + for (index = 0; index < overflowBeast->p.numEntries; index++) + { + oldVis = (V1_VisEntry_s *)storeBuffer; +#if zNETWARE + COMN_MapNDSIDToGUID(&status, oldVis->trusteeID, + &overflowBeast->vis[index].trusteeID); +#endif +#if zLINUX + status = zFAILURE; + overflowBeast->vis[index].trusteeID = zINVALID_USERID; + printk(KERN_ALERT "VISO_unpackBeast: Processed an old-version overflow trusteeID\n"); +#endif + OID_SaveObjectID(overflowBeast->VISOvolume, + &overflowBeast->vis[index].trusteeID); + overflowBeast->vis[index].count = oldVis->count; + storeBuffer += sizeof(V1_VisEntry_s); + } + /* + * Do not mark this beast dirty. It may be too big and the entries + * are unsorted. This will be taken care of by the ZAS auth model + * routines + */ + } + else + { + memcpy(overflowBeast->vis, storeBuffer, len); + storeBuffer += len; + } + RTN_PTR(storeBuffer); +} + +/*--------------------------------------------------------------------------- + * beast STORAGE ops definition + *---------------------------------------------------------------------------*/ +LSSSpecificPackUnpackOps_s VISO_LssOps = + {zLSS_ID_ZLSS, VISO_PackedSize, VISO_PackBeast, NULL, VISO_UnpackBeast}; + + + +/*=========================================================================== + *=========================================================================== + * + * LSSOps for ZasAclOverflowBeast_s + * + *=========================================================================== + *===========================================================================*/ + +/*************************************************************************** + * This routine is called when an overflow beast is written to storage + ***************************************************************************/ +NINT ACLO_PackedSize( + void *overflowBeast_LX) +{ + ZasAclOverflowBeast_s *overflowBeast = (ZasAclOverflowBeast_s *)overflowBeast_LX; + + ENTER(TAUTH, ACLO_PackedSize); + ASSERT_MPKNSS_LOCK(); + RTN_NINT (sizeof(PersistentZasAclOverflowBeast_s) + + (overflowBeast->p.numEntries * sizeof(ACLEntry_s))); +} + +/*************************************************************************** + * This routine is called when an overflow beast is written to storage + ***************************************************************************/ +BYTE *ACLO_PackBeast( + void *overflowBeast_LX, + BYTE *storeBuffer) +{ + ZasAclOverflowBeast_s *overflowBeast = (ZasAclOverflowBeast_s *)overflowBeast_LX; + NINT len; + + ENTER(TAUTH, ACLO_PackBeast); + ASSERT_MPKNSS_LOCK(); + len = overflowBeast->p.numEntries * sizeof(ACLEntry_s); + memcpy(storeBuffer, &overflowBeast->p, sizeof(PersistentZasAclOverflowBeast_s)); + storeBuffer += sizeof(PersistentZasAclOverflowBeast_s); + zASSERT(overflowBeast->acl != NULL); + memcpy(storeBuffer, overflowBeast->acl, len); + RTN_PTR(storeBuffer + len); +} + +/*************************************************************************** + * This routine is called when an overflow beast is read from storage + * + * Note that the acl pointer is already non-zero because the ACLO + * beast's constructor allocates the default size. The realloc will + * size the memory correctly. + * + * Change made October 1, 1998 by Greg Pachner (SPD 211631) + * When this routine was changed to handle the fact that some ACL + * beasts can have 0 entries I decided that these beasts would + * have memory allocated for the ACLEntry (I.E. we do not free up + * the memory allocated by our constructor). This was done because + * all the AUTH code was originally written assuming that beasts + * had this pointer. I felt that by allocating the memory fewer + * bugs would be introduced with this change. This wastes a little + * memory, but there should be VERY FEW overflow beasts with 0 entries. + ***************************************************************************/ +BYTE *ACLO_UnpackBeast( + GeneralMsg_s *genMsg, + void *overflowBeast_LX, + BYTE *storeBuffer) +{ + ZasAclOverflowBeast_s *overflowBeast = (ZasAclOverflowBeast_s *)overflowBeast_LX; + NINT len; + ACLEntry_s *acl; + V1_ACLEntry_s *oldACL; + NINT index; + STATUS status; + BOOL badID; + NINT packedIndex; + + ENTER(TAUTH, ACLO_UnpackBeast); + ASSERT_MPKNSS_LOCK(); + memcpy(&overflowBeast->p, storeBuffer, sizeof(PersistentZasAclOverflowBeast_s)); + storeBuffer += sizeof(PersistentZasAclOverflowBeast_s); + len = overflowBeast->p.numEntries * sizeof(ACLEntry_s); + if ( len == 0 ) + { /*** NOT AN ERROR EXIT ***/ + RTN_PTR(storeBuffer); + } + acl = realloc(overflowBeast->acl, len); + if (acl == NULL) + { /* Out of memory - overflowBeast->acl was not freed by realloc */ + SetErrno(genMsg, zERR_NO_MEMORY); + RTN_PTR(NULL); + } + overflowBeast->acl = acl; + overflowBeast->numAlloced = overflowBeast->p.numEntries; + if (overflowBeast->ACLObeastVersion == BEAST_VERSION_1) + { +#if NSS_DEBUG IS_ENABLED +DBG_DebugPrintf(LMAGENTA,"On-the-fly: ACL overflow\n"); +#endif +#if (CURRENT_BEAST_VERSION != BEAST_VERSION_3) +#error "Check to see if the beastVersion code below is still correct." +#endif + badID = FALSE; + for (index = 0; index < overflowBeast->p.numEntries; index++) + { + oldACL = (V1_ACLEntry_s *)storeBuffer; +#if zNETWARE + if (COMN_MapNDSIDToGUID(&status, oldACL->trusteeID, + &overflowBeast->acl[index].trusteeID) != zOK) + { +// DBG_DebugPrintf(YELLOW, "Bad ID during ACL overflow on-the-fly upgrade.\n"); + badID = TRUE; + } +#endif +#if zLINUX + status = zFAILURE; + overflowBeast->acl[index].trusteeID = zINVALID_USERID; + badID = TRUE; + printk(KERN_ALERT "ACLO_unpackBeast: Processed an old-version ACL overflow trusteeID\n"); +#endif + overflowBeast->acl[index].rights = oldACL->rights; + overflowBeast->acl[index].attributes = oldACL->attributes; + OID_SaveObjectID(overflowBeast->ACLOvolume, + &overflowBeast->acl[index].trusteeID); + + storeBuffer += sizeof(V1_ACLEntry_s); + } + + /* + * If we have bad IDs then remove them and pack the + * rest of the entries. + */ + if (badID) + { +// DBG_DebugPrintf(YELLOW, "Fixing up an ACL overflow with a bad ID\n"); + packedIndex = 0; + for (index = 0; index < overflowBeast->p.numEntries; index++) + { + if (LB_GUIDCompare(&overflowBeast->acl[index].trusteeID, + &zINVALID_USERID) != 0) + { + overflowBeast->acl[packedIndex++] = overflowBeast->acl[index]; + } +#if NSS_DEBUG IS_ENABLED + else + { + DBG_DebugPrintf(LRED, "ACLO_UnpackBeast: Ignored an invalid ACL overflow entry\n"); + } +#endif + } + overflowBeast->p.numEntries = packedIndex; + } + /* + * Do not mark this beast dirty. It may be too big. + * This will be taken care of by the ZAS auth model routines. + */ + } + else + { + memcpy(overflowBeast->acl, storeBuffer, len); + storeBuffer += len; + } + RTN_PTR(storeBuffer); +} + +/*--------------------------------------------------------------------------- + * beast STORAGE ops definition + *---------------------------------------------------------------------------*/ +LSSSpecificPackUnpackOps_s ACLO_LssOps = + {zLSS_ID_ZLSS, ACLO_PackedSize, ACLO_PackBeast, NULL, ACLO_UnpackBeast}; + + +/*=========================================================================== + *=========================================================================== + * + * LSSOps for CompBeast_s + * + *=========================================================================== + *===========================================================================*/ + +/*************************************************************************** + * This routine is called when an compression beast is written to storage + ***************************************************************************/ +NINT COMP_PackedSize( + void *compBeast_LX) +{ + ENTER(TAUTH, COMP_PackedSize); + ASSERT_MPKNSS_LOCK(); + RTN_NINT (sizeof(PersistentComp_s)); +} + +/*************************************************************************** + * This routine is called when an compression beast is written to storage + ***************************************************************************/ +BYTE *COMP_PackBeast( + void *compBeast_LX, + BYTE *storeBuffer) +{ + CompBeast_s *compBeast = (CompBeast_s *)compBeast_LX; + NINT len; + + ENTER(TAUTH, COMP_PackBeast); + ASSERT_MPKNSS_LOCK(); + + len = sizeof(PersistentComp_s); + memcpy(storeBuffer, &compBeast->p, len); + + RTN_PTR(storeBuffer + len); +} + +/*************************************************************************** + * This routine is called when an compression beast is read from storage + ***************************************************************************/ +BYTE *COMP_UnpackBeast( + GeneralMsg_s *genMsg, + void *compBeast_LX, + BYTE *storeBuffer) +{ + CompBeast_s *compBeast = (CompBeast_s *)compBeast_LX; + + ENTER(TAUTH, COMP_UnpackBeast); + ASSERT_MPKNSS_LOCK(); + memcpy(&compBeast->p, storeBuffer, sizeof(PersistentComp_s)); + storeBuffer += sizeof(PersistentComp_s); + + RTN_PTR(storeBuffer); +} + +/*--------------------------------------------------------------------------- + * compression beast ops definition + *---------------------------------------------------------------------------*/ +LSSSpecificPackUnpackOps_s COMP_LssOps = + {zLSS_ID_ZLSS, COMP_PackedSize, COMP_PackBeast, NULL, COMP_UnpackBeast}; + + +/*=========================================================================== + *=========================================================================== + * + * LSSOps for CompBeast_s (intermediate) + * + *=========================================================================== + *===========================================================================*/ + +/*************************************************************************** + * This routine is called when an compression beast is written to storage + ***************************************************************************/ +NINT COMP_INTER_PackedSize( + void *compBeast_LX) +{ + ENTER(TAUTH, COMP_INTER_PackedSize); + ASSERT_MPKNSS_LOCK(); + RTN_NINT (0); +} + +/*************************************************************************** + * This routine is called when an compression beast is written to storage + ***************************************************************************/ +BYTE *COMP_INTER_PackBeast( + void *compBeast_LX, + BYTE *storeBuffer) +{ + ENTER(TAUTH, COMP_INTER_PackBeast); + ASSERT_MPKNSS_LOCK(); + + RTN_PTR(storeBuffer); +} + +/*************************************************************************** + * This routine is called when an compression beast is read from storage + ***************************************************************************/ +BYTE *COMP_INTER_UnpackBeast( + GeneralMsg_s *genMsg, + void *compBeast_LX, + BYTE *storeBuffer) +{ + ENTER(TAUTH, COMP_INTER_UnpackBeast); + ASSERT_MPKNSS_LOCK(); + + RTN_PTR(storeBuffer); +} + +/*--------------------------------------------------------------------------- + * intermediate compression beast ops definition + *---------------------------------------------------------------------------*/ +LSSSpecificPackUnpackOps_s COMP_INTER_LssOps = + {zLSS_ID_ZLSS, COMP_INTER_PackedSize, COMP_INTER_PackBeast, NULL, COMP_INTER_UnpackBeast}; + + +/************************************************************************** + * + ***************************************************************************/ +struct LSSOpsToRegister_s +{ + NINT classID; + LSSSpecificPackUnpackOps_s *ops; +}; + +static struct LSSOpsToRegister_s opsToRegister[] = +{ + {zFTYPE_ROOT_BEAST,&ROOTBEAST_lssOps}, + {zFTYPE_NAMED_DATA_STREAM,&NAMEDBEAST_lssOps}, + {zFTYPE_AUTH_BEAST,&AUTHBEAST_lssOps}, + {zFTYPE_FILE,&FILEBEAST_lssOps}, +// {zFTYPE_ADMIN_VOL_FILE,&AVFILE_lssOps}, + {zFTYPE_EXTENDED_ATTRIBUTE,&EXTATTRBEAST_lssOps}, + {zFTYPE_ZAS_ACL_OVERFLOW,&ACLO_LssOps}, + {zFTYPE_ZAS_VIS_OVERFLOW,&VISO_LssOps}, + {zFTYPE_COMPRESSION, &COMP_LssOps}, + {zFTYPE_COMPRESSION_INTERMEDIATE, &COMP_INTER_LssOps}, + {zFTYPE_HARDLINK_BEAST, &HARDLINK_lssOps}, + {zFTYPE_INVALID} +}; + + +/************************************************************************** + * This will register all of the well know classes that we store + ***************************************************************************/ +STATUS ZSTORE_RegisterLSSOperations( + GeneralMsg_s *genMsg) +{ + NINT i; + struct LSSInfo_s lssInfo; + + ASSERT_MPKNSS_LOCK(); + for (i=0;opsToRegister[i].classID != zFTYPE_INVALID;i++) + { + if (COMN_SetLSSOpsForBeastClass(genMsg, + opsToRegister[i].classID, + opsToRegister[i].ops) != zOK) + { + zASSERT("ZFS_RegisterLSSOperations: Could not set the LSS ops" == 0); + return zFAILURE; + } + } + + lssInfo.lssID = zLSS_ID_ZLSS; + lssInfo.canCreateNew = TRUE; + lssInfo.poolSupportedFeatures = ZLSSPOOL_SUPPORTED_FEATURES; + lssInfo.poolDefaultEnabledFeatures = ZLSSPOOL_DEFAULT_ENABLED_FEATURES; + lssInfo.poolChangableFeatures = (ZLSSPOOL_SUPPORTED_FEATURES & + ~ZLSSPOOL_NON_CHANGEABLE_FEATURES); + lssInfo.volSupportedFeatures = ZLSS_SUPPORTED_ATTRIBUTES; + lssInfo.volDefaultEnabledFeatures = ZLSS_DEFAULT_ENABLED_ATTRIBUTES; + lssInfo.volChangableFeatures = (ZLSS_SUPPORTED_ATTRIBUTES & + ~ZLSS_NON_CHANGABLE_ATTRIBUTES); + + if (COMN_RegisterLSSFeatures(genMsg, &lssInfo) != zOK) + { + zASSERT("COMN_RegisterLSSFeatures could not set the LSS Attributes"==0); + ZSTORE_ClearLSSOperations(); + return(zFAILURE); + } + return zOK; +} + + +/************************************************************************** + * This will register all of the well know classes that we store + ***************************************************************************/ +void ZSTORE_ClearLSSOperations(void) +{ + NINT i; + + ASSERT_MPKNSS_LOCK(); + for (i=0;opsToRegister[i].classID != zFTYPE_INVALID;i++) + { + COMN_ClearLSSOpsForBeastClass( + opsToRegister[i].classID, + zLSS_ID_ZLSS); + } + + COMN_UnregisterLSSFeatures( zLSS_ID_ZLSS ); +} diff --git a/src/nwnss/zlss/zlssLVAIPU.c b/src/nwnss/zlss/zlssLVAIPU.c index 2b71e17..b0f0999 100644 --- a/src/nwnss/zlss/zlssLVAIPU.c +++ b/src/nwnss/zlss/zlssLVAIPU.c @@ -42,9 +42,9 @@ #include #include -#include "zParams.h" #include "nssPubs.h" #include "zfs.h" +#include "zParams.h" #include "zPublics.h" #include "comnPublics.h" #include "beastTree.h" @@ -71,12 +71,12 @@ STATIC STATUS ZLVAIPU_Step4( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ); /** - * ZLSSVOL_IPUZidsToMove contains the ZIDs that must be moved from - * the current ZfsPool_s beast tree. These ZIDs are moved to a LV - * that will then be converted into the NEW ZfsPool_s while the old - * ZfsPool_s will be converted to a LV. This is done so that all - * the users current files in the ZfsPool_s are accessible via a LV. - */ + * ZLSSVOL_IPUZidsToMove contains the ZIDs that must be moved from + * the current ZfsPool_s beast tree. These ZIDs are moved to a LV + * that will then be converted into the NEW ZfsPool_s while the old + * ZfsPool_s will be converted to a LV. This is done so that all + * the users current files in the ZfsPool_s are accessible via a LV. + */ STATIC Zid_t ZLSSVOL_IPUZidsToMove[4] = { ZFSPOOL_FREETREE_ZID, @@ -84,9 +84,9 @@ STATIC Zid_t ZLSSVOL_IPUZidsToMove[4] = { ZFSPOOL_PURGETREE_ZID, ZFSPOOL_REBUILDFILE_ZID /* If something gets added to this table check out - * ZLVAIPU_BlocksMoveCalculate() to see if it needs to be - * fixed. - */ + * ZLVAIPU_BlocksMoveCalculate() to see if it needs to be + * fixed. + */ }; @@ -128,16 +128,16 @@ STATUS ZnodeCopy( znodeLen = znode->header.length; if ( findZnodeByZid( dst, zid, &i) ) { /* ZID already exists in dst node. We do not let - * Beast b-tree code detect as it ASSERTs and returns - * an error. By not returning an error we will cause - * 'itemcount' to be updated. - */ + * Beast b-tree code detect as it ASSERTs and returns + * an error. By not returning an error we will cause + * 'itemcount' to be updated. + */ #ifdef USER_GPACHNER #if NSS_DEBUG IS_ENABLED zASSERT("Found a ZID that has already been moved (OK if we crashed during a previous upgrade)"==NULL); #endif #endif - return zOK; + return zOK; } if (insertZnode(genMsg, dst, zid, znodeLen, &pack) != zOK) { @@ -198,7 +198,7 @@ STATUS ZnodeRemove( * Else error code. */ -static STATUS MNSS_GetNextTagString( +STATUS MNSS_GetNextTagString( utf8_t *tagString, /* ... */ utf8_t **tagStringOut, /* Output - Next 'tagString' */ NINT tagLen, /* Length of 'tagName' buffer. */ @@ -279,7 +279,7 @@ STATUS MNSS_GetSpecificTemplate( for (;; ) { - status = MNSS_GetNextTagString( currentTags, ¤tTags, + status = MNSS_GetNextTagString( currentTags, ¤tTags, sizeof(tagName), tagName ); // if ( resultInfo->dataLen != 0 ) @@ -296,7 +296,7 @@ STATUS MNSS_GetSpecificTemplate( status = XML_GetTagElementAtCurrentLevel( tagName, resultInfo->dataStart, resultInfo->dataEnd, resultInfo ); - + if ( status != zOK ) { return( status ); @@ -392,8 +392,8 @@ STATUS MNSS_GetResultValueAttribute( NINT templateLen, utf8_t *template, SQUAD *sqValue ) /* Output - Value of Results 'value' - * attribute. - */ + * attribute. + */ { STATUS status; @@ -481,7 +481,7 @@ STATUS ZLVAIPU_NDSPoolObjectResultsParse( DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, MSGNot("ZLVAIPU_NDSPoolObjectResultsParse - addPool(NDS) result value is %Ld\n"),sqValue)); if ( sqValue != zOK ) - { + { /* THIS IS NOT A zERR_!!!! Some errors comes from NDS */ return( (STATUS)sqValue ); } @@ -492,15 +492,15 @@ STATUS ZLVAIPU_NDSPoolObjectResultsParse( STATIC BYTE *ZLVAIPU_NDSPoolObjectXMLCommand = "" "" - "" - "" - "" - "" - "" - "%s" - "%s" - "" - "" + "" + "" + "" + "" + "" + "%s" + "%s" + "" + "" ""; @@ -536,7 +536,7 @@ STATUS ZLVAIPU_NDSPoolObjectAdd( } ZOS_zOpen(status, rootKey, zNSS_TASK, zNSPACE_LONG | zMODE_UTF8, - aStack->pathThenCommandThenResults, + aStack->pathThenCommandThenResults, zRR_WRITE_ACCESS | zRR_READ_ACCESS, &fileKey); if ( status != zOK ) @@ -594,7 +594,7 @@ STATUS ZLVAIPU_NDSPoolObjectAdd( aStack->pathThenCommandThenResults[ bytesRead ] = 0; aprintf(CYAN, "Results = %s\n", aStack->pathThenCommandThenResults ); #endif - status = ZLVAIPU_NDSPoolObjectResultsParse( bytesRead, + status = ZLVAIPU_NDSPoolObjectResultsParse( bytesRead, aStack->pathThenCommandThenResults ); if ( status != zOK ) { @@ -613,7 +613,7 @@ ExitFile: ExitRoot: ZOS_zClose(status1, rootKey); zASSERT( status1 == zOK ); - + STACK_FREE(); return status; @@ -647,14 +647,14 @@ STATUS ZLVAIPU_BlocksMoveCalculate( poolVolume = zlssPool->ZLSSPOOLzfsPool; zASSERT( poolVolume != NULL ); /** - * Count up all the blocks in the Pool's specific system beasts. - * This count is used to adjust the number of in use blocks in - * the LV's and Pool Volume's logged volume data blocks. - */ + * Count up all the blocks in the Pool's specific system beasts. + * This count is used to adjust the number of in use blocks in + * the LV's and Pool Volume's logged volume data blocks. + */ /* We start the count with the 64 blocks that are in the - * 4 superblocks. - */ + * 4 superblocks. + */ blocksMoved = SUPERBLOCK_BLKCOUNT * SUPERBLOCK_NUMBER; DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, MSGNot("Counting blocks in POOL specific beasts (to adjust in use counts)\n"))); @@ -662,8 +662,8 @@ STATUS ZLVAIPU_BlocksMoveCalculate( MSGNot("SUPERBLOCK blocks count is %ld\n"),blocksMoved)); /* Zlog Beast is loaded and uses a FMAP so get total block - * use from the FMAP. - */ + * use from the FMAP. + */ blockCount = poolVolume->zfsLogBeast->ZFSLOGroot.storage.zfsInfo->fmapDataBlks; blockCount += poolVolume->zfsLogBeast->ZFSLOGroot.storage.zfsInfo->fmapTreeBlks; blocksMoved += blockCount; @@ -671,10 +671,10 @@ STATUS ZLVAIPU_BlocksMoveCalculate( (MAGENTA,MSGNot("ZLOG block count is %ld\n"),blockCount)); /* Rebuild file is not loaded and MAY not exist, but it does have - * a FMAP. If file exist use FMAP to get block usage. - */ + * a FMAP. If file exist use FMAP to get block usage. + */ rebuildBeast = COMN_LookupByZid(genMsg, &poolVolume->ZFSPOOLvol, - ZFSPOOL_REBUILDFILE_ZID, XLATCHED, TRUE); + ZFSPOOL_REBUILDFILE_ZID, XLATCHED, TRUE); /* On success the rebuildBeast is XLATCHED */ if ( rebuildBeast != NULL ) { @@ -738,9 +738,9 @@ STATUS ZLSSPOOL_Unload( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) STATUS status; /* - * Go through the link list of LVs that this pool - * owns and shut them down first. - */ + * Go through the link list of LVs that this pool + * owns and shut them down first. + */ for (;;) { X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); @@ -758,10 +758,10 @@ STATUS ZLSSPOOL_Unload( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); } /* By removing from the master volume link list we prevent - * this volume from being found. This prevents any new - * operations from starting which is a requirement since - * we will be freeing the volume. - */ + * this volume from being found. This prevents any new + * operations from starting which is a requirement since + * we will be freeing the volume. + */ if (QMEMBER(&zlssPool->ZLSSPOOLzfsPool->ZFSPOOLvol.masterVolLink)) { SET_RMV(zlssPool->ZLSSPOOLzfsPool,ZFSPOOLvol.masterVolLink); @@ -776,31 +776,31 @@ STATUS ZLSSPOOL_Unload( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) } /* This will deactivate the ZLSS Pool and its physical volume. - * The call will not return an error. - */ - status = COMN_ChangePoolState(genMsg, &zlssPool->ZLSSPOOLpool, - zVOLSTATE_UNKNOWN, 0/*VOLMODE_VERBOSE*/ ); + * The call will not return an error. + */ + status = COMN_ChangePoolState(genMsg, &zlssPool->ZLSSPOOLpool, + zVOLSTATE_UNKNOWN, 0/*VOLMODE_VERBOSE*/ ); zASSERT( GetErrno(genMsg) == 0 ); zASSERT(status == zOK); ClearErrno( genMsg ); /* We ignore errors */ WORK_WaitForPending(); /* Before freeing the poolVolume structure, wait - * for all pending WORK to complete. This - * gives a chance for all outstanding - * operations and transactions to complete.*/ + * for all pending WORK to complete. This + * gives a chance for all outstanding + * operations and transactions to complete.*/ zASSERT( zlssPool->ZLSSPOOLzfsPool != NULL ); zASSERT( zlssPool->ZLSSPOOLzfsPool->storagepool != NULL ); /* This can happen if loadpool - * fails really early on */ + * fails really early on */ if ( zlssPool->ZLSSPOOLzfsPool->storagepool != NULL ) { /* Added this to clean up. Mike's stuff has a pointer - * to use (no use count though). During LV AIPU I re-load - * amd unload the zfsPool_s several times and would get - * confussed when looking a freed memory. E.G. in low level - * I/O disable code we have storagepool and if points to - * a zfsPool we use to see if I/O has been disabled. - */ + * to use (no use count though). During LV AIPU I re-load + * amd unload the zfsPool_s several times and would get + * confussed when looking a freed memory. E.G. in low level + * I/O disable code we have storagepool and if points to + * a zfsPool we use to see if I/O has been disabled. + */ zlssPool->ZLSSPOOLzfsPool->storagepool->zfspool = NULL; } BST_releaseAndFree( zlssPool->ZLSSPOOLzfsPool ); @@ -1003,10 +1003,10 @@ STATUS ZLVAIPU_AIPU4001To4006( GeneralMsg_s *genMsg, ZfsPool_s *zfsPool, NINT mo zASSERT( GetErrno(genMsg) == 0 ); /** - * Unload the pool because it is too hard to - * pass the new pool pointer back. The caller - * will have to re-load the pool one last time. - */ + * Unload the pool because it is too hard to + * pass the new pool pointer back. The caller + * will have to re-load the pool one last time. + */ (void)ZFSPOOL_AIPUPoolUnload( genMsg, zfsPool ); return( status ); @@ -1028,17 +1028,17 @@ STATIC STATUS ZLVAIPU_Step1( GeneralMsg_s *genMsg, ZfsPool_s *zfsPool ) (LRED,MSGNot("In ZLVAIPU_Step1\n"))); zASSERT( zfsPool->ZP_super != NULL ); /** - * The 'Create' media version does not really need to be set - * here because it should be done when going from media - * version 34 to 35. I have here, with a check, to see if it has - * been done for internal machines that may have been upgraded - * to media 35 before adding in the 'Create' media version - * field. Note, Ben has said we do not need to support upgrades - * from these intermediate versions as no customers will have. - */ + * The 'Create' media version does not really need to be set + * here because it should be done when going from media + * version 34 to 35. I have here, with a check, to see if it has + * been done for internal machines that may have been upgraded + * to media 35 before adding in the 'Create' media version + * field. Note, Ben has said we do not need to support upgrades + * from these intermediate versions as no customers will have. + */ if ( zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajorCreate == 0 ) { - zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajorCreate = + zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajorCreate = zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor; zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinorCreate = zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor; @@ -1048,10 +1048,10 @@ STATIC STATUS ZLVAIPU_Step1( GeneralMsg_s *genMsg, ZfsPool_s *zfsPool ) zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinorCreate )); } /** - * We store off the time that Auto In-place-upgrade started - * for debugging purposes only. This can tell us if the AIPU - * is to slow. - */ + * We store off the time that Auto In-place-upgrade started + * for debugging purposes only. This can tell us if the AIPU + * is to slow. + */ zfsPool->ZP_super->SB_Header.hdr.SBH_PoolToLVStartUTC = GetUTCTime(); zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor = AIPU_LV_MEDIA_MAJOR; @@ -1095,9 +1095,9 @@ STATIC STATUS ZLVAIPU_Step2A( ZfsXaction_s *xactionPool; Extent_s seedext; unicode_t *volumeName; /* Logical Volume name to use for the - * LV we are creating (i.e the internal - * volume name without the "_IV_") - */ + * LV we are creating (i.e the internal + * volume name without the "_IV_") + */ ZlssPool_s *zlssPool; Blknum_t poolBlocks[LV_POOL_BLOCKS]; @@ -1119,10 +1119,10 @@ STATIC STATUS ZLVAIPU_Step2A( zASSERT( zlssPool->ZLSSPOOLzfsPool != NULL ); COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); /* This gets the name of the Internal Volume which ALWAYS has a "_IV_" - * appended on it. - */ + * appended on it. + */ status = COMN_GetVolumeName( &dummyGenMsg, &zfsPool->ZFSPOOLvol, volumeName, - zMAX_COMPONENT_NAME ); + zMAX_COMPONENT_NAME ); zASSERT( status == zOK ); /* Above routine should never fail */ len = unilen( volumeName ); zASSERT( len > 4 ); @@ -1132,12 +1132,12 @@ STATIC STATUS ZLVAIPU_Step2A( X_LATCH( &zfsPool->ZP_SuperblockHeaderLatch ); xactionPool = BeginXLocal( &zfsPool->ZFSPOOLvol, BXL_DEFAULT ); /** - * First, allocate and init the two pool data blocks. One stores - * non-logged pool information, while the other stores logged pool - * information. We also update our ZLSS Pool to contains these - * block numbers. - */ - seedext.poolBlkNum = (zfsPool->ZP_super->SB_Header.hdr.totalblocks / 2) + 3; + * First, allocate and init the two pool data blocks. One stores + * non-logged pool information, while the other stores logged pool + * information. We also update our ZLSS Pool to contains these + * block numbers. + */ + seedext.poolBlkNum = (zfsPool->ZP_super->SB_Header.hdr.totalblocks / 2) + 3; seedext.lengthOfExtent = sizeof(poolBlocks)/sizeof(poolBlocks[0]); status = ZFT_BlockAlloc(genMsg, &zfsPool->ZFSPOOLzfsVol, &seedext, TRUE, xactionPool, &poolBlocks[0]); if ( status != zOK ) @@ -1150,42 +1150,42 @@ STATIC STATUS ZLVAIPU_Step2A( } /* Fill in most persistent pool data */ zASSERT( zfsPool->ZFSPOOLtotalBlocks > 1000 ); - zASSERT( zfsPool->ZFSPOOLbookedInUseBlocks < zfsPool->ZFSPOOLtotalBlocks ); + zASSERT( zfsPool->ZFSPOOLbookedInUseBlocks < zfsPool->ZFSPOOLtotalBlocks ); zASSERT( LB_GUIDValidate( &zlssPool->ZLSSPOOLmInternalID ) ); zASSERT( LB_GUIDValidate( &zlssPool->ZLSSPOOLmVolumeID ) ); zASSERT( zfsPool->storagepool != NULL ); - ZLSSPOOL_PoolDataInitialize( zlssPool, + ZLSSPOOL_PoolDataInitialize( zlssPool, zfsPool->ZFSPOOLtotalBlocks, zfsPool->ZFSPOOLblockShift, zfsPool->storagepool->sharedStatus ? zPOOL_FEATURE_SHARED_CLUSTER : 0 ); - zASSERT( zfsPool->ZFSPOOLbookedInUseBlocks < zfsPool->ZFSPOOLtotalBlocks ); + zASSERT( zfsPool->ZFSPOOLbookedInUseBlocks < zfsPool->ZFSPOOLtotalBlocks ); /* Fill in some othe persistent pool data */ zfsPool->ZP_super->SB_Header.hdr.SBH_LoggedPoolDataBlk = poolBlocks[0]; zlssPool->ZP_p.PZP_loggedPoolDataBlk = poolBlocks[0]; zfsPool->ZP_super->SB_Header.hdr.SBH_PoolDataBlk = poolBlocks[1]; zlssPool->ZP_p.PZP_poolDataBlk = poolBlocks[1]; /* Fix the values of the persistent pool data to account - * for the fact that this is an Logical Volume upgrade - * and not a init. - */ + * for the fact that this is an Logical Volume upgrade + * and not a init. + */ zlssPool->ZLSSPOOLpurgeableBlocks = zfsPool->ZFSPOOLpurgeableBlocks; zlssPool->ZLSSPOOLnonPurgeableBlocks = zfsPool->ZFSPOOLvol.VOLnonPurgeableBlocks; zlssPool->ZLSSPOOLinUseBlocks = zfsPool->ZFSPOOLinUseBlocks; zlssPool->ZLSSPOOLbookedInUseBlocks = zfsPool->ZFSPOOLbookedInUseBlocks; /* Set the Pool's media version to that of what we WILL store in the - * superblock header. Technically, we do not need to store - * persistently in two places. - */ + * superblock header. Technically, we do not need to store + * persistently in two places. + */ zlssPool->ZLSSPOOLmediaFormatMajor = AIPU_LV_MEDIA_MAJOR; /* 40 */ zlssPool->ZLSSPOOLmediaFormatMinor = AIPU_LV_STEP_5_DONE; /* 7 */ /* We use INIT versions of LPDB and PDB write routines - * as BOTH are transactioned and the log records contain - * all the correct information to REDO the xaction. - */ + * as BOTH are transactioned and the log records contain + * all the correct information to REDO the xaction. + */ status = ZLSSPOOL_WriteInitialPDB( genMsg, zlssPool, xactionPool ); if ( status != zOK ) { @@ -1198,10 +1198,10 @@ STATIC STATUS ZLVAIPU_Step2A( } /** - * Create a volume purge log in the pool. This beast will be given to - * the LV later on. The pool will get a replacement volume purge log - * from the LV at the same time (i.e. when Beast B-Trees are swapped). - */ + * Create a volume purge log in the pool. This beast will be given to + * the LV later on. The pool will get a replacement volume purge log + * from the LV at the same time (i.e. when Beast B-Trees are swapped). + */ status = ZLVAIPU_VolumePurgeLogCreate( genMsg, &zfsPool->ZFSPOOLzfsvol, xactionPool ); if ( status != zOK ) { @@ -1213,13 +1213,13 @@ STATIC STATUS ZLVAIPU_Step2A( return( status ); } - X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); /** - * Create the logical volume. Volume creation does not load - * the volume. This call also creates the Logical Volume Locator Beast - * on the Internal Volume. - */ + * Create the logical volume. Volume creation does not load + * the volume. This call also creates the Logical Volume Locator Beast + * on the Internal Volume. + */ status = ZLSSVOL_LV_Create( genMsg, &zfsPool->ZFSPOOLvol, volumeName /*ZLSSVOL_IPU_NAME_UNIQUE*/, // zLV_NO_QUOTA_SIZE, @@ -1230,20 +1230,20 @@ STATIC STATUS ZLVAIPU_Step2A( xactionPool, TRUE ); /* The (QUAD) cast above works here only because, even though - * total blocks is a signed value, it can not be negative. - */ + * total blocks is a signed value, it can not be negative. + */ free( volumeName ); volumeName = NULL; - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); if ( status != zOK ) { /* FixFixFix(LV,ACI,11) after onlypo=nss1 we get here because error - * 20412 as volume name already exists. Also got here if abend in - * calculating number of blocks to move (PTWalk). - * Since orignal problems I have STOPPED using the define - * ZLSSVOL_IPU_NAME_UNIQUE for the volume name. Instead each - * LV AIPU uses its own unique volume name. This should have - * fixed this fix fix fix item. - */ + * 20412 as volume name already exists. Also got here if abend in + * calculating number of blocks to move (PTWalk). + * Since orignal problems I have STOPPED using the define + * ZLSSVOL_IPU_NAME_UNIQUE for the volume name. Instead each + * LV AIPU uses its own unique volume name. This should have + * fixed this fix fix fix item. + */ zASSERT("ZLSSVOL_LV_Create failed" == NULL ); // free( volumeName ); ZLVAIPU_AbortXLocal( genMsg, zfsPool ); @@ -1253,8 +1253,8 @@ STATIC STATUS ZLVAIPU_Step2A( } /* Set and write correct media version into the current pool/volume - * as this block will be owned by the LV when AIPU is done. - */ + * as this block will be owned by the LV when AIPU is done. + */ X_LATCH( &zfsPool->ZFSPOOLzfsvol.ZV_vdbLatch ); zfsPool->ZFSPOOLmediaFormatMajor = ZLSS_LV_MEDIA_MAJOR; zfsPool->ZFSPOOLmediaFormatMinor = ZLSS_LV_MEDIA_MINOR; @@ -1262,10 +1262,10 @@ STATIC STATUS ZLVAIPU_Step2A( zfsPool->ZFSPOOLmediaFormatMinorCreate = 1; zfsPool->ZFSPOOLvol.p.PV_createTimeUTC = zfsPool->ZFSPOOLrootdir->FILEcreatedTime; /* FixFixFix(LV,ACI,11) - I think ALL VDB writes need to be - * xactioned at some point. It would be best to put the - * VDB information into the ZVL Beast. This way easy to - * XACTION and can change when volume is DEACTIVE. - */ + * xactioned at some point. It would be best to put the + * VDB information into the ZVL Beast. This way easy to + * XACTION and can change when volume is DEACTIVE. + */ ZFSVOL_WritePersistentVolumeDataXactioned( &zfsPool->ZFSPOOLzfsvol, xactionPool ); zASSERT( zfsPool->ZP_super != NULL ); @@ -1358,15 +1358,15 @@ STATIC STATUS ZLVAIPU_Step2B( LONG itemsCopied = 0; ZfsXaction_s *xactionPool; unicode_t *volumeName; /* Logical Volume name (i.e internal - * volume name without the "_IV_") - */ + * volume name without the "_IV_") + */ ZlssPool_s *zlssPool; // NINT mangleKey; Blknum_t blocksMoved; NINT len; typedef struct Stack_s { GeneralMsg_s dummyGenMsg; - IoMsg_s iomsg; + IoMsg_s iomsg; Agent_s agent; } Stack_s; STACK_ALLOC(); @@ -1392,18 +1392,18 @@ STATIC STATUS ZLVAIPU_Step2B( COMN_GetVolumeName( &aStack->dummyGenMsg, &zfsPool->ZFSPOOLvol, volumeName, zMAX_COMPONENT_NAME ); /* All internal volume names have a _IV_ added to them - * by ZFSPOOL_LoadPool. To get the logical volume name - * remove the "_IV_" - */ + * by ZFSPOOL_LoadPool. To get the logical volume name + * remove the "_IV_" + */ len = unilen( volumeName ); zASSERT( len > 4 ); zASSERT( len < zMAX_COMPONENT_NAME ); volumeName[ len-4 ] = 0; /* Replace the "IV_" with a NULL */ /** - * Load and activate the logical volume so that we have access - * to the NT and BT. We need to place a Volume Locator Beast on it. - */ + * Load and activate the logical volume so that we have access + * to the NT and BT. We need to place a Volume Locator Beast on it. + */ status = ZLSSVOL_LV_LoadAll( genMsg, zfsPool, FALSE, TRUE, FALSE ); if ( status != zOK ) { @@ -1412,14 +1412,14 @@ STATIC STATUS ZLVAIPU_Step2B( STACK_FREE(); return( status ); } - X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); POOL_FOR_EACH_LOADED_VOLUME( zfsPool->ZFSPOOLvol.v_pool, volume ) { zVolume = (ZfsVolume_s *)volume; zASSERT( zVolume->zv_bookedInUseBlocks == zVolume->ZFSVOLinUseBlocks); count++; } - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); zASSERT( count == 1 ); /* Should only be the one LV that we just created */ if ( count != 1 ) { @@ -1439,14 +1439,14 @@ STATIC STATUS ZLVAIPU_Step2B( xactionPool = BeginXLocal( &zfsPool->ZFSPOOLvol, BXL_DEFAULT ); /** - * Create a Volume Location Beast(VLB) in the LV that contains - * information about the Pool's ZfsVolume_s. When the current LV - * becomes the Pool's physical volume then we will use the VLB - * we are creating now to find the final LV (which is currently - * the Pool's ZfsVolume_s). We will delete the original Volume - * Locator Beast once the switch is done. This is the one that - * is CURRENTLY on the ZfsPool_s. - */ + * Create a Volume Location Beast(VLB) in the LV that contains + * information about the Pool's ZfsVolume_s. When the current LV + * becomes the Pool's physical volume then we will use the VLB + * we are creating now to find the final LV (which is currently + * the Pool's ZfsVolume_s). We will delete the original Volume + * Locator Beast once the switch is done. This is the one that + * is CURRENTLY on the ZfsPool_s. + */ zvlBeast = ZLSSVOL_LV_ZVLCreate( genMsg, volumeName, @@ -1466,13 +1466,13 @@ STATIC STATUS ZLVAIPU_Step2B( } /*** - *** Update the ZVL beast with the correct block numbers - *** and change its STATE to indicate that the LV - *** has been created successfully. - *** Note the the 'correct' blocks are the block numbers - *** from the POOL and NOT the LV. This is because - *** we will be swapping the POOL and LV in a little bit. - ***/ + *** Update the ZVL beast with the correct block numbers + *** and change its STATE to indicate that the LV + *** has been created successfully. + *** Note the the 'correct' blocks are the block numbers + *** from the POOL and NOT the LV. This is because + *** we will be swapping the POOL and LV in a little bit. + ***/ ASSERT_XLATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); zvlBeast->ZVL_p.PZVL_loggedVolumeDataBlk = zfsPool->ZFSPOOLzfsvol.p.PZV_loggedVolumeDataBlk; @@ -1489,23 +1489,23 @@ STATIC STATUS ZLVAIPU_Step2B( // EndXlocal( xaction ); UNX_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); /* UNX_LATCH above is not legal with Logical UNDO as the rule - * is that we must wait until after xaction ends. Vandana and - * I say this is O.K. as no other thread should be running - * during LV AIPU so we will not get into the problem of - * having someone elses COMMITTED changes in a beast at - * crash time. - */ + * is that we must wait until after xaction ends. Vandana and + * I say this is O.K. as no other thread should be running + * during LV AIPU so we will not get into the problem of + * having someone elses COMMITTED changes in a beast at + * crash time. + */ COMN_Release( &zvlBeast ); /** - * Now we calculate the total number of blocks that are in the - * pool/volumes in use block count that will be staying with the - * pool (verses going to the LV). This number is used to adjust - * the pool's volume and the LV in use block counts. Because - * the LV_POOL_BLOCKS are allocated against the VOLUME we have - * to include them in the blocks moved count even though we - * technically do not move them. - */ + * Now we calculate the total number of blocks that are in the + * pool/volumes in use block count that will be staying with the + * pool (verses going to the LV). This number is used to adjust + * the pool's volume and the LV in use block counts. Because + * the LV_POOL_BLOCKS are allocated against the VOLUME we have + * to include them in the blocks moved count even though we + * technically do not move them. + */ status = ZLVAIPU_BlocksMoveCalculate( genMsg, zlssPool, &blocksMoved ); if ( status != zOK ) @@ -1515,23 +1515,23 @@ STATIC STATUS ZLVAIPU_Step2B( blocksMoved += LV_POOL_BLOCKS; /** - * Switch all the logical volume's system beasts with their couterparts - * in the pool. This means the Beast Tree, Name Tree, Volume Data Block - * and the Logged Volume data block. The switch is done to the in memory - * beasts and the relavent persistent data. The relavent persistent data - * are the Blknum_t of the Beast Tree, VDB and LVDB that are stored in the - * Superblocks of the pool. - */ + * Switch all the logical volume's system beasts with their couterparts + * in the pool. This means the Beast Tree, Name Tree, Volume Data Block + * and the Logged Volume data block. The switch is done to the in memory + * beasts and the relavent persistent data. The relavent persistent data + * are the Blknum_t of the Beast Tree, VDB and LVDB that are stored in the + * Superblocks of the pool. + */ DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN, MSGNot(" ** (Debug)Automatic conversion to pool layout v%u.%02u\n"), AIPU_LV_MEDIA_MAJOR,AIPU_LV_STEP_LAST_DONE )); /** - * Ensure that all the Beasts that we are moving - * have been flushed. I.E. if they are dirty and we move them - * they will stilled be flushed to their OLD beast tree. - */ + * Ensure that all the Beasts that we are moving + * have been flushed. I.E. if they are dirty and we move them + * they will stilled be flushed to their OLD beast tree. + */ status = ZFSPOOL_DoFlushSystemBeasts( genMsg, zfsPool, TRUE ); if ( status != zOK ) { @@ -1543,18 +1543,18 @@ STATIC STATUS ZLVAIPU_Step2B( return( status ); } /** - * Just to be cool we ensure that the LV system beasts are all - * flushed out. Really, should not have to do as the LV - * is only receiving beasts, but better safe than sorry. - */ + * Just to be cool we ensure that the LV system beasts are all + * flushed out. Really, should not have to do as the LV + * is only receiving beasts, but better safe than sorry. + */ zASSERT( zVolume->zv_bookedInUseBlocks == zVolume->ZFSVOLinUseBlocks); status = ZLSSVOL_DoFlushSystemBeasts( genMsg, zVolume, TRUE ); if ( status != zOK ) { zASSERT("ZLSSVOL_DoFlushSystemBeasts failed" == NULL ); /* We exit as whatever the error it will just cause us - * trouble later when we deactivate. - */ + * trouble later when we deactivate. + */ // free( volumeName ); ZLVAIPU_AbortXLocal( genMsg, zfsPool ); EndXlocal( xactionPool ); @@ -1564,9 +1564,9 @@ STATIC STATUS ZLVAIPU_Step2B( zASSERT( zVolume->zv_bookedInUseBlocks == zVolume->ZFSVOLinUseBlocks); /** - * Read in the pool and LV beast tree node that contains the system - * beasts. - */ + * Read in the pool and LV beast tree node that contains the system + * beasts. + */ poolSystemBeastBlock = zfsPool->ZFSPOOLzfsvol.p.PZV_systemBeastBlkNum; poolBeastTree = zfsPool->ZFSPOOLbeastTree; zASSERT( poolBeastTree != NULL ); @@ -1583,7 +1583,7 @@ STATIC STATUS ZLVAIPU_Step2B( return( zFAILURE ); } poolNode = (BeastTreeNode_s *)poolBuffer->pBuf.data; - + lvSystemBeastBlock = zVolume->p.PZV_systemBeastBlkNum; lvBeastTree = zVolume->beastTree; zASSERT( lvBeastTree != NULL ); @@ -1603,22 +1603,22 @@ STATIC STATUS ZLVAIPU_Step2B( lvNode = (BeastTreeNode_s *)lvBuffer->pBuf.data; /** - * Copy the system POOL beasts from the pool to the LV. The next - * time we activate the POOL will become the LV and the LV will - * become the pool. - */ + * Copy the system POOL beasts from the pool to the LV. The next + * time we activate the POOL will become the LV and the LV will + * become the pool. + */ for ( i=0; i < (sizeof(ZLSSVOL_IPUZidsToMove)/sizeof(ZLSSVOL_IPUZidsToMove[0])); ++i ) { - status = ZnodeCopy(genMsg, poolNode/*SRC*/, lvNode, ZLSSVOL_IPUZidsToMove[i] ); + status = ZnodeCopy(genMsg, poolNode/*SRC*/, lvNode, ZLSSVOL_IPUZidsToMove[i] ); if ( status == zOK ) { ++itemsCopied; } else { /* We will assume that if we get an error it is because we did - * not find the system beast because it has already been moved - * or does not exist. The Rebuild File general does not exist. - */ + * not find the system beast because it has already been moved + * or does not exist. The Rebuild File general does not exist. + */ ClearErrno( genMsg ); } } @@ -1626,9 +1626,9 @@ STATIC STATUS ZLVAIPU_Step2B( DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, (LRED,MSGNot("%d items copied\n\n"), itemsCopied )); /* - * Sync write the LV beast tree system block leaf. This ensures - * that the LV has a copy of all the system POOL beasts. - */ + * Sync write the LV beast tree system block leaf. This ensures + * that the LV has a copy of all the system POOL beasts. + */ initAgent( &aStack->agent, NULL, MSGNot("Upgrade media") ); bind(&aStack->agent, &lvBuffer->agent); CACHE_DIRTY_RELEASE( lvBuffer ); @@ -1640,9 +1640,9 @@ STATIC STATUS ZLVAIPU_Step2B( zfsPool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor = AIPU_LV_STEP_2B_DONE; /** - * Fix superbblock so that next time the pool is loaded that we start - * using the LV we created in STEP 2A as the pool. - */ + * Fix superbblock so that next time the pool is loaded that we start + * using the LV we created in STEP 2A as the pool. + */ DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, (LRED,MSGNot(" POOL INFO LVDB %ld VDB %ld BT %ld\n"), zfsPool->ZP_super->SB_Header.hdr.SBH_LoggedVolumeDataBlk, @@ -1665,9 +1665,9 @@ STATIC STATUS ZLVAIPU_Step2B( zfsPool->ZP_super->SB_Header.hdr.SBH_InternalID = zVolume->p.PZV_internalID; zfsPool->ZP_super->SB_Header.hdr.SBH_VolumeID = zVolume->p.PZV_volumeID; /* Update memory copies od OLD and New Internal IDs. This - * helps DEBUG ASSERT code that checks if a written blocks - * internal ID (at offset 16) is correct. - */ + * helps DEBUG ASSERT code that checks if a written blocks + * internal ID (at offset 16) is correct. + */ zfsPool->ZFSPOOLoldInternalID = zfsPool->ZP_super->SB_Header.hdr.SBH_OldInternalID; zfsPool->ZFSPOOLinternalID = zfsPool->ZP_super->SB_Header.hdr.SBH_InternalID; @@ -1677,7 +1677,7 @@ STATIC STATUS ZLVAIPU_Step2B( status = LB_VolumeNameToPoolName( &zfsPool->ZP_super->SB_Header.hdr.SBH_Name[0], &mangleKey, sizeof( zfsPool->ZP_super->SB_Header.hdr.SBH_Name ), - &zfsPool->ZP_super->SB_Header.hdr.SBH_Name[0] ); + &zfsPool->ZP_super->SB_Header.hdr.SBH_Name[0] ); if ( status != zOK ) { SetErrno( genMsg, status ); @@ -1696,13 +1696,13 @@ STATIC STATUS ZLVAIPU_Step2B( zfsPool->ZP_super->SB_Header.hdr.SBH_SystemBeastBlkNum )); /** - * Keep the MAL name of the pool the same - * as the ZLSS name of the pool. Here we tell the MAL - * the new name. We do not care a lot about errors - * as the names do not have to match. Although, this means - * that the menu code (which uses the MAL name) will not - * match the Pool's name. - */ + * Keep the MAL name of the pool the same + * as the ZLSS name of the pool. Here we tell the MAL + * the new name. We do not care a lot about errors + * as the names do not have to match. Although, this means + * that the menu code (which uses the MAL name) will not + * match the Pool's name. + */ { msgUpdateDeposit_s update_req; @@ -1800,9 +1800,9 @@ STATIC STATUS ZLVAIPU_Step3( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) poolVolume = zlssPool->ZLSSPOOLzfsPool; zASSERT( poolVolume != NULL ); /** - * Ensure that the LV is loaded no matter what the current - * policy's of the pool are. - */ + * Ensure that the LV is loaded no matter what the current + * policy's of the pool are. + */ status = ZLSSVOL_LV_LoadAll( genMsg, poolVolume, FALSE, TRUE, FALSE ); if ( status != zOK ) { @@ -1810,13 +1810,13 @@ STATIC STATUS ZLVAIPU_Step3( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) STACK_FREE(); return( status ); } - X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); POOL_FOR_EACH_LOADED_VOLUME( poolVolume->ZFSPOOLvol.v_pool, volume ) { zVolume = (ZfsVolume_s *)volume; count++; } - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); zASSERT( count == 1 ); /* Should only be the one LV that we just created */ if ( count != 1 ) @@ -1846,41 +1846,41 @@ STATIC STATUS ZLVAIPU_Step3( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) } lvNode = (BeastTreeNode_s *)lvBuffer->pBuf.data; /** - * Remove the system POOL beasts from the LV. - */ + * Remove the system POOL beasts from the LV. + */ for ( i=0; i < (sizeof(ZLSSVOL_IPUZidsToMove)/sizeof(ZLSSVOL_IPUZidsToMove[0])); ++i ) { - status = ZnodeRemove(genMsg, lvNode, ZLSSVOL_IPUZidsToMove[i] ); + status = ZnodeRemove(genMsg, lvNode, ZLSSVOL_IPUZidsToMove[i] ); /* We will assume that if we get an error it is because we did not - * find the system beast because it has already been removed or - * does not exist. The Rebuild File generally does not exist. - */ + * find the system beast because it has already been removed or + * does not exist. The Rebuild File generally does not exist. + */ ClearErrno( genMsg ); } /** - * Sync write the LV beast tree system block leaf. This ensures - * that the LV no longer has copies of the system POOL beasts. - */ + * Sync write the LV beast tree system block leaf. This ensures + * that the LV no longer has copies of the system POOL beasts. + */ initAgent( &aStack->agent, NULL, MSGNot("Upgrade media") ); bind(&aStack->agent, &lvBuffer->agent); CACHE_DIRTY_RELEASE( lvBuffer ); defaultFlushWait( &aStack->agent ); /** - * Update the count of the number of files and objects in - * the LV by the number of system beasts we removed from - * its Beast Tree. The beasts removed are the Pool's specific - * system beasts as defined by ZLSSVOL_IPUZidsToMove. - */ + * Update the count of the number of files and objects in + * the LV by the number of system beasts we removed from + * its Beast Tree. The beasts removed are the Pool's specific + * system beasts as defined by ZLSSVOL_IPUZidsToMove. + */ blocksMoved = (Blknum_t)poolVolume->ZP_super->SB_Header.hdr.SBH_BlocksMoved; itemsMoved = poolVolume->ZP_super->SB_Header.hdr.SBH_ItemsMoved; DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, MSGNot("%d items moved\n\n"), itemsMoved )); blk = zVolume->p.PZV_loggedVolumeDataBlk; /* If the block is zero then we must not write this information. - * Generally, this means that the persistent information has - * not been initialized (or read) in yet. - */ + * Generally, this means that the persistent information has + * not been initialized (or read) in yet. + */ if ( (blk == 0) || (blk == INVALID_BLK) ) { SetErrno( genMsg, zERR_ZFSVOL_AIPU_LVDB_CORRUPTED ); @@ -1891,21 +1891,21 @@ STATIC STATUS ZLVAIPU_Step3( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) lvdbBuffer = ZFS_ReadPoolBlk( genMsg, &aStack->iomsg ); /*** We are sliding in the persistent setting of the Epoch - *** field for Sai and Ed. The LVDB does not write reserved - *** fields. Instead of requiring a seperate AIPU I just - *** did as part of LV AIPU. Note that this was done 1/31/2000 - *** even though the LV AIPU had been checked in for months. - *** We got away with this because when I added LV Delete - *** code I required all current LVs to be blown away. - ***/ + *** field for Sai and Ed. The LVDB does not write reserved + *** fields. Instead of requiring a seperate AIPU I just + *** did as part of LV AIPU. Note that this was done 1/31/2000 + *** even though the LV AIPU had been checked in for months. + *** We got away with this because when I added LV Delete + *** code I required all current LVs to be blown away. + ***/ zVolume->ZLSSVOLvol.logged.epoch = 0; zVolume->ZLSSVOLvol.logged.reservedEpoch = 0; /* - * Note that we do not adjust the Pool's in use blocks because the Pool's - * in use blocks is not changing (we are just moving ownership from the - * LV to the Internal Volume). - */ + * Note that we do not adjust the Pool's in use blocks because the Pool's + * in use blocks is not changing (we are just moving ownership from the + * LV to the Internal Volume). + */ DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, MSGNot("LV number of objects and files after conversion %Ld, %Ld\n"), @@ -1913,11 +1913,11 @@ STATIC STATUS ZLVAIPU_Step3( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) zVolume->ZFSVOLnumFiles )); block = ((ZfsLoggedVolumeBlock_s *)lvdbBuffer->pBuf.data); /** - * This takes the memory copy of active data that is logged - * in the Volume_s and places into the volume's data block. - * Note that we do not copy the reserved area. This area - * is initially set to zero in pool init. - */ + * This takes the memory copy of active data that is logged + * in the Volume_s and places into the volume's data block. + * Note that we do not copy the reserved area. This area + * is initially set to zero in pool init. + */ /* This is the PACK code for a ZFS Volume (logged data) */ memcpy( &block->ZLVD_zfsVol, &zVolume->logged, @@ -1925,12 +1925,12 @@ STATIC STATUS ZLVAIPU_Step3( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) sizeof(zVolume->logged.LPZV_reserved) ); /* This is the PACK code for a Volume (logged data) */ memcpy(&block->ZLVD_volume, &zVolume->ZFSVOLvol.logged, - sizeof(LoggedPersistentVolume_s) - + sizeof(LoggedPersistentVolume_s) - sizeof(zVolume->ZFSVOLvol.logged.LPV_reserved) ); /** - * Sync write the LV LVDB. This ensures that the LV has the - * correct counts persistently. - */ + * Sync write the LV LVDB. This ensures that the LV has the + * correct counts persistently. + */ initAgent( &aStack->agent, NULL, MSGNot("Upgrade media") ); bind( &aStack->agent, &lvdbBuffer->agent ); CACHE_DIRTY_RELEASE( lvdbBuffer ); @@ -1938,18 +1938,18 @@ STATIC STATUS ZLVAIPU_Step3( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) xactionPool = BeginXLocal( &poolVolume->ZFSPOOLvol, BXL_DEFAULT ); /* This can be a CACHE_WRITE because we update all of the - * portion of the block we use. - */ + * portion of the block we use. + */ /* We have decided that the orignal volume should have no quota - * so make it so. - */ + * so make it so. + */ zVolume->ZLSSVOLtotalBlocks = zLV_NO_QUOTA_SIZE >> 12; /* FixFixFix(LV,ACI,10) - this is bad as 12 and will not get REDO/UNDO - * which is the case anyway as we do not Log if we change disk quota. - * Can not do commented code below because delta is a SLONG and - * not a SQUAD!!! So if we crash the LV will not be NO QUOTA. - */ + * which is the case anyway as we do not Log if we change disk quota. + * Can not do commented code below because delta is a SLONG and + * not a SQUAD!!! So if we crash the LV will not be NO QUOTA. + */ // zVolume->ZFSVOLnumObjects -= itemsMoved; // zVolume->ZFSVOLnumFiles -= itemsMoved; @@ -1965,8 +1965,8 @@ STATIC STATUS ZLVAIPU_Step3( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) ZFSVOL_VOL_WriteVolumeLoggedData( &zVolume->ZFSVOLvol, &xactionPool->xaction, &volLog ); /* We have decided that the orignal volume should have no quota - * so make it so. - */ + * so make it so. + */ // zASSERT( "Doing No QUOTA work"==NULL); // volLog.delta = (zLV_NO_QUOTA_SIZE >> 12)- zVolume->ZLSSVOLtotalBlocks; // volLog.action = VOLINFO_CHANGE_TOT_BLOCKS; @@ -1974,9 +1974,9 @@ STATIC STATUS ZLVAIPU_Step3( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) // &xactionPool->xaction, &volLog ); /** - * Update media version to indicate current state of - * AIPU. - */ + * Update media version to indicate current state of + * AIPU. + */ zASSERT( poolVolume->ZP_super != NULL ); X_LATCH( &poolVolume->ZP_SuperblockHeaderLatch ); poolVolume->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor = AIPU_LV_MEDIA_MAJOR; @@ -2041,9 +2041,9 @@ STATIC STATUS ZLVAIPU_Step4( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) poolZfsVolume = (ZfsVolume_s *)poolVolume; zASSERT( poolVolume != NULL ); /** - * Regardless of the Pool's current policy ensure that the LV - * is loaded. - */ + * Regardless of the Pool's current policy ensure that the LV + * is loaded. + */ status = ZLSSVOL_LV_LoadAll( genMsg, poolVolume, FALSE, TRUE, FALSE ); if ( status != zOK ) { @@ -2051,19 +2051,19 @@ STATIC STATUS ZLVAIPU_Step4( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) STACK_FREE(); return( status ); } - X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); POOL_FOR_EACH_LOADED_VOLUME( poolVolume->ZFSPOOLvol.v_pool, volume ) { count++; /** - * Delete the AIPU ZVL beast that is now in the - * logical volume. This beast got here when we switched - * the Pool's BT with the LV's BT. We ignore errors in - * this process because all it means is that we have - * left some files/directories on the user volume. Not - * serious enough to stop the upgrade! - */ + * Delete the AIPU ZVL beast that is now in the + * logical volume. This beast got here when we switched + * the Pool's BT with the LV's BT. We ignore errors in + * this process because all it means is that we have + * left some files/directories on the user volume. Not + * serious enough to stop the upgrade! + */ (void)COMN_GetVolumeName( &dummyGenMsg, volume, aStack->containerVolumeName, NELEMS(aStack->containerVolumeName) ); @@ -2076,22 +2076,22 @@ STATIC STATUS ZLVAIPU_Step4( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) aStack->containerVolumeName ); ClearErrno( &dummyGenMsg ); } - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); zASSERT( count == 1 ); /* Should only be the one LV that we just created */ /** - * Update the count of the number of files and objects in - * the Pool by the number of system beasts we moved to - * its Beast Tree. The beasts moved are the Pool's specific - * system beasts as defined by ZLSSVOL_IPUZidsToMove. - */ + * Update the count of the number of files and objects in + * the Pool by the number of system beasts we moved to + * its Beast Tree. The beasts moved are the Pool's specific + * system beasts as defined by ZLSSVOL_IPUZidsToMove. + */ blocksMoved = poolVolume->ZP_super->SB_Header.hdr.SBH_BlocksMoved; itemsMoved = poolVolume->ZP_super->SB_Header.hdr.SBH_ItemsMoved; DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED,MSGNot("%d items moved\n\n"), itemsMoved )); xactionPool = BeginXLocal( &poolZfsVolume->ZFSVOLvol, BXL_DEFAULT ); /* This can be a CACHE_WRITE because we update all of the - * portion of the block we use. - */ + * portion of the block we use. + */ // poolZfsVolume->ZFSVOLnumObjects += itemsMoved; // poolZfsVolume->ZFSVOLnumFiles += itemsMoved; @@ -2117,18 +2117,18 @@ STATIC STATUS ZLVAIPU_Step4( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) X_LATCH( &poolVolume->ZP_SuperblockHeaderLatch ); /** - * We store off the time that Auto In-place-upgrade ended - * for debugging purposes only. This can tell us if the AIPU - * is too slow. It also can be used to determine if a specific - * beast has been changed/created/accessed before or after - * logical volumes were added to the system. - */ + * We store off the time that Auto In-place-upgrade ended + * for debugging purposes only. This can tell us if the AIPU + * is too slow. It also can be used to determine if a specific + * beast has been changed/created/accessed before or after + * logical volumes were added to the system. + */ poolVolume->ZP_super->SB_Header.hdr.SBH_PoolToLVEndUTC = GetUTCTime(); /** - * Update media version to indicate current state of - * AIPU. - */ + * Update media version to indicate current state of + * AIPU. + */ zASSERT( poolVolume->ZP_super != NULL ); poolVolume->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor = AIPU_LV_MEDIA_MAJOR; poolVolume->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor = AIPU_LV_STEP_4_DONE; @@ -2226,27 +2226,27 @@ STATUS ZLVAIPU_Step5_Async( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) status = COMN_PoolActiveLock( genMsg, pool ); if ( status != zOK ) { /* We only work on ACTIVE pools */ - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLVAIPU_Step5_Async -- Pool not ACTIVE\n")); /* Return zOK because we do not wish another timer to be - * scheduled. Timer will be scheduled next time POOL is - * activated. - */ + * scheduled. Timer will be scheduled next time POOL is + * activated. + */ ClearErrno( genMsg ); STACK_FREE(); return zOK; } /* A non-zero NDS Pool Object ID indicates that the pool - * already has a NDS Pool Object. In this case we just - * skip creating another pool object. - * - * This code should handle the case of having BETA Pools - * that are at 40.06 which already have NDS pool objects. - * I.E. the pool was created by ConsoleOne. - * - * In addition, it handles the case that the user created - * a NDS pool object before the upgrade completed. - */ + * already has a NDS Pool Object. In this case we just + * skip creating another pool object. + * + * This code should handle the case of having BETA Pools + * that are at 40.06 which already have NDS pool objects. + * I.E. the pool was created by ConsoleOne. + * + * In addition, it handles the case that the user created + * a NDS pool object before the upgrade completed. + */ if ( LB_GUIDCompare( &pool->POOLndsObjectID, &zZERO_GUID) == 0) { @@ -2282,9 +2282,9 @@ STATUS ZLVAIPU_Step5_Async( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ) } #endif /** - * Update media version to indicate current state of - * AIPU. - */ + * Update media version to indicate current state of + * AIPU. + */ zASSERT( poolVolume->ZP_super != NULL ); poolVolume->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor = AIPU_LV_MEDIA_MAJOR; poolVolume->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor = AIPU_LV_STEP_5_DONE; @@ -2368,7 +2368,7 @@ STATUS ZLVAIPU_FTValidate( SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); return zFAILURE; } - + for (cnt = 1; cnt < node->header.numRecs; cnt++ ) { e_curr = &node->EXT[cnt]; @@ -2529,9 +2529,9 @@ STATUS ZLVAIPU_FTNodeVisit( CACHE_RELEASE(buffer); if ( currentLevel == *leafLevel ) { /* This is here so we ONLY read one leaf. I.E. the - * first leaf of the lowest left branch. This is - * the leaf that finnaly sets the leafLevel variable. - */ + * first leaf of the lowest left branch. This is + * the leaf that finnaly sets the leafLevel variable. + */ break; } } @@ -2540,11 +2540,11 @@ STATUS ZLVAIPU_FTNodeVisit( else { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, - (LRED,MSGNot("VERIFY ERR: ZLVAIPU_FTNodeVisit, Not leaf or branch\n"))); + (LRED,MSGNot("VERIFY ERR: ZLVAIPU_FTNodeVisit, Not leaf or branch\n"))); SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); return zFAILURE; } - + return zOK; } /* End of ZLVAIPU_FTNodeVisit() */ @@ -2559,7 +2559,7 @@ STATUS ZLVAIPU_FTNodeVisit( * 'blockCount' - (Output)The number of blocks that the B-Tree portion * of the free tree contains. */ - + STATUS ZLVAIPU_FTWalk( GeneralMsg_s *genMsg, ZfsPool_s *pool, Blknum_t *blockCount ) { xNode_s *rootNode; @@ -2570,8 +2570,8 @@ STATUS ZLVAIPU_FTWalk( GeneralMsg_s *genMsg, ZfsPool_s *pool, Blknum_t *blockCou Buffer_s *buffer; IoMsg_s iomsg; WORD leafLevel; /* Zero indicates leaf level is unknown. - * The root of the tree is Level 1. - */ + * The root of the tree is Level 1. + */ *blockCount = 0; specialBlock = pool->freeExtent->zfsBtree.p.btFree; @@ -2579,8 +2579,8 @@ STATUS ZLVAIPU_FTWalk( GeneralMsg_s *genMsg, ZfsPool_s *pool, Blknum_t *blockCou if ( (specialBlock == 0) || (specialBlock == INVALID_BLK) ) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, - (LRED,MSGNot("%s ZLVAIPU_FTWalk specialblock is %ld\n"), WHERE, - (unsigned long)specialBlock)); + (LRED,MSGNot("%s ZLVAIPU_FTWalk specialblock is %ld\n"), WHERE, + (unsigned long)specialBlock)); } else { @@ -2589,7 +2589,7 @@ STATUS ZLVAIPU_FTWalk( GeneralMsg_s *genMsg, ZfsPool_s *pool, Blknum_t *blockCou if (buffer == NULL) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, - (LRED,MSGNot("ZLVAIPU_FTWalk, read buffer alloc error\n"))); + (LRED,MSGNot("ZLVAIPU_FTWalk, read buffer alloc error\n"))); return zFAILURE; } specialNode = (xNode_s*)buffer->pBuf.data; @@ -2604,14 +2604,14 @@ STATUS ZLVAIPU_FTWalk( GeneralMsg_s *genMsg, ZfsPool_s *pool, Blknum_t *blockCou CACHE_RELEASE(buffer); } DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, - (LRED,MSGNot("Special Leaf has %ld blocks\n"), - (unsigned long)(*blockCount))); + (LRED,MSGNot("Special Leaf has %ld blocks\n"), + (unsigned long)(*blockCount))); if ( (rootBlock == 0) || (rootBlock == INVALID_BLK) ) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, - (LRED,MSGNot("%s ZLVAIPU_FTWalk rootblock is %ld\n"), WHERE, - (unsigned long)rootBlock)); + (LRED,MSGNot("%s ZLVAIPU_FTWalk rootblock is %ld\n"), WHERE, + (unsigned long)rootBlock)); return( zOK ); } @@ -2622,7 +2622,7 @@ STATUS ZLVAIPU_FTWalk( GeneralMsg_s *genMsg, ZfsPool_s *pool, Blknum_t *blockCou if (buffer == NULL) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, - (LRED,MSGNot("ZLVAIPU_FTWalk read error\n"))); + (LRED,MSGNot("ZLVAIPU_FTWalk read error\n"))); return zFAILURE; } rootNode = (xNode_s*)buffer->pBuf.data; @@ -2656,7 +2656,7 @@ STATUS ZLVAIPU_PTValidate( if (PBT_NEW_IS_LEAF(node)) { - if (! ((node->magic == PURGETREE_NEW_MAGIC) || + if (! ((node->magic == PURGETREE_NEW_MAGIC) || (node->magic == PURGETREE_MAGIC))) { SetErrno( genMsg, zERR_MEDIA_CORRUPTED ); @@ -2727,7 +2727,7 @@ STATUS ZLVAIPU_PTNodeVisit( GeneralMsg_s *genMsg, WORD level, ZfsPool_s *pool, B return zFAILURE; } DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, - (CYAN,MSGNot("reading PT branch %ld\n"),childBlock)); + (CYAN,MSGNot("reading PT branch %ld\n"),childBlock)); childNode = (PurgeTreeNewNode_s*)buffer->pBuf.data; status = ZLVAIPU_PTNodeVisit( genMsg, level, pool, buffer, blockCount, leafLevel ); @@ -2738,8 +2738,8 @@ STATUS ZLVAIPU_PTNodeVisit( GeneralMsg_s *genMsg, WORD level, ZfsPool_s *pool, B return( zFAILURE ); } /* This next check helps a little in that we only - * look at ONE leaf block in the left most branch. - */ + * look at ONE leaf block in the left most branch. + */ if ( (level + 1) == *leafLevel ) break; } } @@ -2758,7 +2758,7 @@ STATUS ZLVAIPU_PTNodeVisit( GeneralMsg_s *genMsg, WORD level, ZfsPool_s *pool, B * 'blockCount' - (Output)The number of blocks that the B-Tree portion * of the purge tree contains. */ - + STATUS ZLVAIPU_PTWalk( GeneralMsg_s *genMsg, ZfsPool_s *pool, Blknum_t *blockCount ) { Blknum_t rootBlock = 0; @@ -2904,8 +2904,8 @@ STATIC STATUS ZLVAIPU_VolumePurgeLogCreate( beast->FILEfirstParentZid = zINVALID_ZID; /* Do not put any of the SYSTEM beasts into the LV linked list - * because we need to control when the files are flushed. - */ + * because we need to control when the files are flushed. + */ BEASTHASH_Insert(&beast->FILEroot); DQ_RMV(beast,FILEvolLink); @@ -2914,7 +2914,7 @@ STATIC STATUS ZLVAIPU_VolumePurgeLogCreate( packedSize = BST_getPackedSize(&beast->FILEroot); - seedExt.poolBlkNum = 0; + seedExt.poolBlkNum = 0; seedExt.lengthOfExtent = sizeof(lvBlocks)/sizeof(lvBlocks[0]); // xaction = BeginXLocal(beast->FILEvolume,BXL_DEFAULT); @@ -2955,13 +2955,13 @@ STATIC STATUS ZLVAIPU_VolumePurgeLogCreate( goto error_beastNewed; } /* MUST wait to fill in ZLSSVOLvolumePurgeLog because if the block - * allocate above causes a JOIN in the free tree then we will - * deadlock on the trying to use the purge log to log the block - * being freed in the JOIN. Purge log code already handles - * switching to the POOL's purge log when the volume - * purge log does not exist. Anyway, we really should not - * set until the Volume Purge log is fully created. - */ + * allocate above causes a JOIN in the free tree then we will + * deadlock on the trying to use the purge log to log the block + * being freed in the JOIN. Purge log code already handles + * switching to the POOL's purge log when the volume + * purge log does not exist. Anyway, we really should not + * set until the Volume Purge log is fully created. + */ zVolume->ZLSSVOLvolumePurgeLog = volumePurgeLog; UNX_LATCH(&beast->FILEbeastLatch); DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN, @@ -2976,7 +2976,7 @@ error_noNew: DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN, MSGNot("ZLVAIPU_VolumePurgeLogCreate zFAILURE exit\n"))); return( zFAILURE ); - + } @@ -3054,7 +3054,7 @@ STATUS ZLVAIPU_TestAndSetBlock( if ( (bitMap == NULL) || (bitMap->BM_Map == NULL) ) { - zASSERT("Fix the caller of ZLVAIPU_TestAndSetBlock()"==NULL); + zASSERT("Fix the caller of ZLVAIPU_TestAndSetBlock()"==NULL); SetErrno( genMsg, zERR_BAD_PARAMETER_VALUE ); return zFAILURE; } diff --git a/src/nwnss/zlss/zlssLogicalVolume.c b/src/nwnss/zlss/zlssLogicalVolume.c index 96213fe..c1941af 100644 --- a/src/nwnss/zlss/zlssLogicalVolume.c +++ b/src/nwnss/zlss/zlssLogicalVolume.c @@ -55,12 +55,6 @@ #include "zfsXTree.h" #include "zlssStartup.h" #include "zlssLogicalVolume.h" - -#ifdef NSS_USERSPACE -#ifndef current -#define current ((void *)0) -#endif -#endif #include "msgName.h" #include "purgeTree_if.h" #include "msg.h" @@ -97,7 +91,7 @@ void bbtCompare(BeastTreeNode_s *node1, BeastTreeNode_s *node2,NINT len); FixFixFix(LVFixed,ACI,1) - Still some issues with turning off salvage at the volume layer and not purgeing ALL the files in the pool. Note that under v34.0 and LV that every other files gets purged when salvage is turned off!!! This is a bug. I have decided not to purge ANY files when salvage is turned off. This was a time verses benefit decision. FixFixFix(LVFixed,ACI,2) - If no free blocks then LV AIPU will leave media in a state that user can not free space!!!! Pre-Rebuild is addressing. FixFixFix(LVFixed,ACI,2) - Does auto purge work on files deleted before upgrade? Yes. Also why is LogicalVolumes and ZVL beast still around? COMN_Delete does not implement purge flag. This has been fixed!!! - FixFixFix(LVFixed,ACI,2) - Purge tree changes??? (seems at some point Sai and I thought Purge Tree had to change for LVs) This may be related to if we had non-purgeable files which ZLSS does not currently support (see ZLSS LV spec) + FixFixFix(LVFixed,ACI,2) - Purge tree changes??? (seems at some point Sai and I thought Purge Tree had to change for LVs) This may be related to if we had non-purgeable files which ZLSS does not currently support (see ZLSS LV spec) FixFixFix(LVFixed,ACI,2) - Handling disable LV and its effect on pools and other LVs. (2 weeks) (Added June 24, 1999) FixFixFix(LVFixed,ACI,2) - Must be able to re-start volume delete without re-loading pool!!!!! Is this relative to getting an error? What about using the continue command? Do I need a command line option on the server? Can ConsoleOne do? Added the command /NSS LVScan=Poolname that will cause all LVs to be loaded. I am assuming that you can continue deleted LVs that are paused. FixFixFix(LVFixed,ACI,3) - Implement zGetInfo and zModifyInfo for Pool_s and ZlssPool_s. @@ -184,13 +178,13 @@ ZfsVolume_s *gZVolume = NULL; /* Last LV loaded */ NINT ZLSSVOL_LVD_PurgeThreadCount = 0; /* Number of Deleted LVs that - * have purge threads activily - * purging the LV. The count - * is set a little before the - * actual thread is created so - * that we do not get a window - * and allow more than 5 threads. - */ + * have purge threads activily + * purging the LV. The count + * is set a little before the + * actual thread is created so + * that we do not get a window + * and allow more than 5 threads. + */ /* * This internal structure contains all the system beasts that a ZLSS logical @@ -201,12 +195,12 @@ NINT ZLSSVOL_LVD_PurgeThreadCount = 0; /* Number of Deleted LVs that ZLSSVolumeBeastCtrl_s ZLSSVolumeSuperBeasts[] = { /*** - *** Do not change the order, some initialization is based on - *** this order. For example, The beast tree must be before any - *** other system beasts that are stored within the beast tree. - *** This allows the beast tree to allocate its system beast - *** block before other beasts are inserted into the beast B-tree. - ***/ + *** Do not change the order, some initialization is based on + *** this order. For example, The beast tree must be before any + *** other system beasts that are stored within the beast tree. + *** This allows the beast tree to allocate its system beast + *** block before other beasts are inserted into the beast B-tree. + ***/ {zFTYPE_ZLSS_BEAST_TREE,ZFSPOOL_VOLBSTTREE_ZID, offsetof(ZfsVolume_s,ZLSSVOLbeastTree), MSGNot(L"volumeBeastTree"), @@ -255,8 +249,8 @@ ZLSSVolumeBeastCtrl_s ZLSSVolumeSuperBeasts[] = zvlBeast must be XLATCHED. */ void ZLSSVOL_LV_MakeZVLUpgradePersistent( - GeneralMsg_s *genMsg, - ZlssVolumeLocator_s *zvlBeast ) + GeneralMsg_s *genMsg, + ZlssVolumeLocator_s *zvlBeast ) { ASSERT_XLATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); if ( (zvlBeast->ZVL_UnpackVersionMajor != zvlBeast->ZVL_p.PZVL_versionMajor) || @@ -306,15 +300,15 @@ STATUS ZLSSVOL_LV_SnapshotVolumeAndID( { STATUS status; int retry; /* Number of time MORE we should - * call LB_GUIDTimeToShortVolumeName - * before giving up. - */ + * call LB_GUIDTimeToShortVolumeName + * before giving up. + */ NINT mangleKey; /* Number of times we have tried to get - * a good name for the volume. If - * we are unable to get a good name then - * we will try LB_GUIDTimeToShortVolumeName - * to generate a name. - */ + * a good name for the volume. If + * we are unable to get a good name then + * we will try LB_GUIDTimeToShortVolumeName + * to generate a name. + */ zASSERT( 16 <= nElemsVolName ); @@ -324,9 +318,9 @@ STATUS ZLSSVOL_LV_SnapshotVolumeAndID( Again: if ( (mangleKey > MAX_MANGLE) || deletedVolume ) { /* Deleted volumes get standard GUID name AND - * non-deleted files that have failed mangle - * snapshot name too many times. - */ + * non-deleted files that have failed mangle + * snapshot name too many times. + */ LB_GUIDGenerate( volID ); status = LB_GUIDTimeToShortVolumeName( volID, nElemsVolName, volName ); @@ -451,11 +445,11 @@ STATUS ZLSSVOL_LV_Snapshot( if ( LB_GUIDCompare( &zlssPool->ZP_SnapshotID, &zvlBeast->ZVL_p.PZVL_snapshotID ) != 0 ) { /* Snapshot IDs do not match so we need to get a new - * volume name. The zvlBeast name will be updated - * later in ZLSSVOL_LV_Load via a call to the function - * ZLSSVOL_RenameZVLBAsync when ZLSSVOL_LV_Load detects - * the volume name does not match the zvlBeast name. - */ + * volume name. The zvlBeast name will be updated + * later in ZLSSVOL_LV_Load via a call to the function + * ZLSSVOL_RenameZVLBAsync when ZLSSVOL_LV_Load detects + * the volume name does not match the zvlBeast name. + */ LONG retCode; LONG denyCode; @@ -467,8 +461,8 @@ STATUS ZLSSVOL_LV_Snapshot( aStack->enterEvent.enterExitID = aStack->exitEvent.enterExitID = ++EnterExitEventID; aStack->enterEvent.volPersistentState = aStack->exitEvent.volPersistentState = zvlBeast->ZVL_p.PZVL_state; /* Must make local copy as PZVL_volumeName will change - * between enter and exit event. - */ + * between enter and exit event. + */ memcpy( aStack->oldVolName, zvlBeast->ZVL_p.PZVL_volumeName, sizeof( aStack->oldVolName ) ); aStack->enterEvent.oldVolName = aStack->exitEvent.oldVolName = aStack->oldVolName; aStack->enterEvent.oldPoolName = aStack->exitEvent.oldPoolName = poolVolume->ZP_super->SB_Header.hdr.SBH_SS_OriginalName; @@ -492,12 +486,12 @@ STATUS ZLSSVOL_LV_Snapshot( { /* Fill in DELETED specific fields */ LB_GUIDGenerate( &aStack->enterEvent.deletedVolID ); /* We supply the original name of the deleted volume - * as the suggested deleted volume name because - * it is only a suggested and if UI does not - * replace then if the User salvages the snapshot - * deleted volume they will be presented with the - * original name of the volume. - */ + * as the suggested deleted volume name because + * it is only a suggested and if UI does not + * replace then if the User salvages the snapshot + * deleted volume they will be presented with the + * original name of the volume. + */ zASSERT( sizeof(aStack->enterEvent.deletedVolName) == sizeof(zvlBeast->ZVL_p.PZVL_volumeNameOriginal) ); memcpy( aStack->enterEvent.deletedVolName, zvlBeast->ZVL_p.PZVL_volumeNameOriginal, sizeof(aStack->exitEvent.deletedVolName) ); } @@ -506,11 +500,11 @@ STATUS ZLSSVOL_LV_Snapshot( if (retCode != OPERATION_DENIED) { aStack->exitEvent.enterRetStatus = retCode; - /** - * Since enter event handler can change the values - * of the next four items we wait until now to set - * the fields in the Exit event structure. - */ + /** + * Since enter event handler can change the values + * of the next four items we wait until now to set + * the fields in the Exit event structure. + */ aStack->exitEvent.volID = aStack->enterEvent.volID; zASSERT( sizeof(aStack->exitEvent.volName) == sizeof(aStack->enterEvent.volName) ); memcpy( aStack->exitEvent.volName, aStack->enterEvent.volName, sizeof(aStack->exitEvent.volName) ); @@ -518,8 +512,8 @@ STATUS ZLSSVOL_LV_Snapshot( zASSERT( sizeof(aStack->exitEvent.deletedVolName) == sizeof(aStack->enterEvent.deletedVolName) ); memcpy( aStack->exitEvent.deletedVolName, aStack->enterEvent.deletedVolName, sizeof(aStack->exitEvent.deletedVolName) ); /** - * Save off current items. - */ + * Save off current items. + */ zvlBeast->ZVL_p.PZVL_snapshotID = zlssPool->ZP_SnapshotID; zvlBeast->ZVL_p.PZVL_stateSnapshot = zvlBeast->ZVL_p.PZVL_state; @@ -533,8 +527,8 @@ STATUS ZLSSVOL_LV_Snapshot( zvlBeast->ZVL_p.PZVL_volumeNameOriginal, sizeof( zvlBeast->ZVL_p.PZVL_volumeNameOriginal ) ); /** - * Replace current items. - */ + * Replace current items. + */ zASSERT( sizeof(zvlBeast->ZVL_p.PZVL_volumeName) == sizeof(aStack->enterEvent.volName) ); memcpy( zvlBeast->ZVL_p.PZVL_volumeName, aStack->enterEvent.volName, @@ -549,8 +543,8 @@ STATUS ZLSSVOL_LV_Snapshot( zvlBeast->ZVL_p.PZVL_volumeIDOriginal = aStack->enterEvent.deletedVolID; } /* In Nakoma we clear the LV's NDS Object. This was done as it is - * much easier to do here verses in the MM Snapshot API routine. - */ + * much easier to do here verses in the MM Snapshot API routine. + */ status = ZFSVOL_VDBNDSObjectClear( genMsg, poolVolume->storagepool, (Blknum_t)zvlBeast->ZVL_p.PZVL_volumeDataBlk ); zASSERT( status == zOK ); if ( status != zOK ) @@ -561,8 +555,8 @@ STATUS ZLSSVOL_LV_Snapshot( ClearErrno( genMsg ); } /** - * Write out modified locator beast. - */ + * Write out modified locator beast. + */ xaction = BeginXLocal(zvlBeast->ZVLfile.FILEvolume,BXL_DEFAULT); COMN_MARK_BEAST_XLOCAL( &zvlBeast->ZVLfile.FILEroot, &xaction->xaction ); @@ -642,11 +636,11 @@ STATUS ZLSSVOL_LV_Snapshot( unicat( /*dest*/fullName, zVolumeName ); fileType = zFTYPE_ZLSS_VOLUME_LOCATOR; /* We set the 'inhibit bits' just to make it a little harder to - * delete this file. It would be VERY bad to delete this file because - * we would loss track of a logical volume. - * At this time the volume that contains the file is hidden - * and can not be seen by ANY user. - */ + * delete this file. It would be VERY bad to delete this file because + * we would loss track of a logical volume. + * At this time the volume that contains the file is hidden + * and can not be seen by ANY user. + */ DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, ( CYAN, MSGNot("ZLSSVOL_LV_ZVLOpen is opening %U\n"), fullName )); @@ -725,7 +719,7 @@ STATUS ZLSSVOL_LV_Snapshot( // // status = COMN_GetNameFromBeast( &dummyGenMsg, (NamedBeast_s *)poolVolume, // zFNU_FIRST_PARENT, -// zNSPACE_LONG, NELEMS(containerVolumeName), +// zNSPACE_LONG, NELEMS(containerVolumeName), // containerVolumeName, NULL); // UNX_LATCH( &poolVolume->ZFSPOOLbeastLatch ); // if ( status != zOK ) @@ -785,7 +779,7 @@ ZfsVolume_s *ZLSSVOL_LV_LoadByName( poolVolume = zlssPool->ZLSSPOOLzfsPool; zASSERT( COMN_IsDerivedFrom( poolVolume, zFTYPE_ZLSS_ZFSPOOL ) ); - ASSERT_XLATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + ASSERT_XLATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); if ( poolVolume->ZFSPOOLstate == zVOLSTATE_ACTIVE ) { /* We only work if the pool is ACTIVE. */ zvlBeast = ZLSSVOL_LV_ZVLOpen( genMsg, zVolumeName, @@ -824,8 +818,8 @@ ZfsVolume_s *ZLSSVOL_LV_LoadByName( ZLSSVOL_LVD_DeleteListAddAndInit( dqi, zvlBeast, zVolume ); } /** Note we ignore out of memory errors. The - * LV will just not get on the dqi. - */ + * LV will just not get on the dqi. + */ } } } @@ -838,11 +832,11 @@ ZfsVolume_s *ZLSSVOL_LV_LoadByName( TRUE /* verbose */, TRUE /* Activate no matter what policy says */ ); if ( zVolume != NULL ) { /* This is a debug global that is nice in - * non-debug system. Use if so if volume - * is being deleted(normal reason to return NULL) - * then we do not set global to non useful - * volume pointer. - */ + * non-debug system. Use if so if volume + * is being deleted(normal reason to return NULL) + * then we do not set global to non useful + * volume pointer. + */ gZVolume = zVolume; } } @@ -885,7 +879,7 @@ File_s *ZVL_Open( OpenMsg_s openMsg; } Stack_s; STACK_ALLOC(); - + COMN_INIT_NAMING_MSG(&aStack->nameMsg); COMN_SETUP_NAMING_MSG_SIMPLE(&aStack->nameMsg, fullName, zPFMT_UNICODE, NAMPMODE_Undefined, XLATCHED, @@ -946,23 +940,23 @@ File_s *ZVL_Open( ZfsVolume_s *ZLSSVOL_LV_LoadModeCreated( GeneralMsg_s *genMsg, ZlssVolumeLocator_s *zvlBeast, /* Beast that describes the Logical - * volume to be loaded. This beast - * must reside in the pVolume supplied - * below. - */ + * volume to be loaded. This beast + * must reside in the pVolume supplied + * below. + */ ZfsVolume_s *zVolume, /* */ Volume_s *pVolume, /* Physical Volume. This is the volume - * that ZLSS Pool uses to store Logical - * Volume Locator beasts. Sometimes - * referred to as the Pool's Volume. - */ + * that ZLSS Pool uses to store Logical + * Volume Locator beasts. Sometimes + * referred to as the Pool's Volume. + */ BOOL verbose, BOOL activate ) /* Activate (even if not the policy) - * This is used in LV AIPU. It is OK - * to activate even in ORION because - * the POOL is the object that ORION - * cares about. - */ + * This is used in LV AIPU. It is OK + * to activate even in ORION because + * the POOL is the object that ORION + * cares about. + */ { unicode_t *zVolumeName; ZlssPool_s *zlssPool; @@ -978,15 +972,15 @@ ZfsVolume_s *ZLSSVOL_LV_LoadModeCreated( poolVolume = (ZfsPool_s *)pVolume; zlssPool = (ZlssPool_s *)(poolVolume->ZFSPOOLvol.v_pool); - ASSERT_XLATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + ASSERT_XLATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); if ( zlssPool->ZP_Version < (AIPU_LV_MEDIA_MAJOR*0x100L+AIPU_LV_STEP_4_DONE) ) { /* All LVs are marked internal until after LV AIPU - * has completed. This prevents the outside world from - * using them even though they are in the ACTIVE state. - * For example, NWSA will not mount them as it will not see - * them. - */ + * has completed. This prevents the outside world from + * using them even though they are in the ACTIVE state. + * For example, NWSA will not mount them as it will not see + * them. + */ #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(CYAN,"%s LV being marked internal because in LV AIPU\n",WHERE); #endif @@ -995,11 +989,11 @@ ZfsVolume_s *ZLSSVOL_LV_LoadModeCreated( } /*** - *** Give control over to NSS. This allows NSS to implement any - *** policies that apply to this volume. Under normal conditions NSS - *** will change the volume's state to DEACTIVE. The SYS volume - *** will go to the ACTIVE state. - ***/ + *** Give control over to NSS. This allows NSS to implement any + *** policies that apply to this volume. Under normal conditions NSS + *** will change the volume's state to DEACTIVE. The SYS volume + *** will go to the ACTIVE state. + ***/ (void)COMN_VolumeEvent( genMsg, &zVolume->ZLSSVOLvol, zVolumeName, VOLEVENT_LOAD, verbose ); if ( activate ) { @@ -1018,7 +1012,7 @@ ZfsVolume_s *ZLSSVOL_LV_LoadModeCreated( } /* End of ZLSSVOL_LV_LoadModeCreated() */ -/************************************************************************** +/************************************************************************** * * This routine will allocate the logical volume beast, initialize it * and put it on the Pool's linked list. @@ -1036,55 +1030,55 @@ ZfsVolume_s *ZLSSVOL_NewLVBeast( ZfsVolume_s *zVolume; /*** - *** New the LV beast - Use the special VOLUME beast new call. This - *** places the volume into the admin volume directory. The - *** AVFILE_destruct() will remove from the admin volume when our - *** volume is freed via COMN_Release(). Note we need to call - *** the release version because VOL_BstNew() returns with an in-use - *** count of one. - ***/ + *** New the LV beast - Use the special VOLUME beast new call. This + *** places the volume into the admin volume directory. The + *** AVFILE_destruct() will remove from the admin volume when our + *** volume is freed via COMN_Release(). Note we need to call + *** the release version because VOL_BstNew() returns with an in-use + *** count of one. + ***/ zVolume = VOL_BstNew2( genMsg, zFTYPE_ZLSS_VOL, COMN_GetAdminVolume(), zVolumeName, &zvlBeast->ZVL_p.PZVL_volumeID, - zLSS_ID_ZLSS, zvlBeast->ZVL_p.PZVL_authModelID, + zLSS_ID_ZLSS, zvlBeast->ZVL_p.PZVL_authModelID, zvlBeast->ZVL_p.PZVL_state ); if ( zVolume == NULL ) { zASSERT("Why?"==NULL); return NULL; } - zASSERT( zVolume->ZFSVOLfile.FILEuseCount > 0 ); - ++(zVolume->ZFSVOLfile.FILEuseCount); /* One for load and - * One for us using */ - zASSERT( zVolume->ZFSVOLfile.FILEuseCount > 1 ); + zASSERT( zVolume->ZFSVOLfile.FILEuseCount > 0 ); + ++(zVolume->ZFSVOLfile.FILEuseCount); /* One for load and + * One for us using */ + zASSERT( zVolume->ZFSVOLfile.FILEuseCount > 1 ); - /* Set up the PHYSICAL pool(ZfsPool_s) that owns us. - * All I/O needs this */ + /* Set up the PHYSICAL pool(ZfsPool_s) that owns us. + * All I/O needs this */ zVolume->ZFSVOLpool = pool; - /* Set up the LOGICAL pool(ZlssPool_s) that owns us. - * All I/O needs this */ + /* Set up the LOGICAL pool(ZlssPool_s) that owns us. + * All I/O needs this */ ++(zlssPool->ZP_Pool.POOLroot.useCount); zVolume->ZLSSVOLv_pool = (Pool_s *)zlssPool; /* Set up the internal ID. Most I/O (debug) and most REDO/UNDO needs - * as this is the stamp ZLSS places at offset 16 off all system blks - */ + * as this is the stamp ZLSS places at offset 16 off all system blks + */ /* This does a structure COPY */ zVolume->ZLSSVOLinternalID = zvlBeast->ZVL_p.PZVL_internalID; /* The LVs restart count is simply the internal volumes restart count. - * This is done (verses using the activation count) because then - * rebuild does not need to worry about re-creating an accurate - * activation count if the VDB is bad. The persistent restart - * count is stored in the checkpoints (which we have FOUR of) and - * therefore rebuild trusts. Also note that if the checkpoints - * are all bad then rebuild is not able to run. - */ + * This is done (verses using the activation count) because then + * rebuild does not need to worry about re-creating an accurate + * activation count if the VDB is bad. The persistent restart + * count is stored in the checkpoints (which we have FOUR of) and + * therefore rebuild trusts. Also note that if the checkpoints + * are all bad then rebuild is not able to run. + */ zVolume->ZLSSVOLvol.v_restartCount = pVolume->v_restartCount; #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(GREEN,MSGNot("%s restart count %ld\n"), WHERE, - (unsigned long)zVolume->ZLSSVOLvol.v_restartCount); + (unsigned long)zVolume->ZLSSVOLvol.v_restartCount); #endif switch ( zvlBeast->ZVL_p.PZVL_state ) { @@ -1106,7 +1100,7 @@ ZfsVolume_s *ZLSSVOL_NewLVBeast( } -/************************************************************************** +/************************************************************************** * * This routine will allocate the logical volume beast, initialize it * and put it on the Pool's linked list. @@ -1128,8 +1122,8 @@ ZfsVolume_s *ZLSSVOL_NewFakeLVBeast( STATUS status; /*** - *** For 'fake' volumes we ALWAYS non-persistently rename them. - ***/ + *** For 'fake' volumes we ALWAYS non-persistently rename them. + ***/ status = ZLSSVOL_LV_SnapshotVolumeAndID( genMsg, zVolumeName, zvlBeast->ZVL_p.PZVL_state == PZVL_S_DELETION ? TRUE : FALSE, TRUE /*Fake*/, NELEMS( volName ), volName, &volID ); @@ -1140,55 +1134,55 @@ ZfsVolume_s *ZLSSVOL_NewFakeLVBeast( } /*** - *** New the LV beast - Use the special VOLUME beast new call. This - *** places the volume into the admin volume directory. The - *** AVFILE_destruct() will remove from the admin volume when our - *** volume is freed via COMN_Release(). Note we need to call - *** the release version because VOL_BstNew() returns with an in-use - *** count of one. - ***/ + *** New the LV beast - Use the special VOLUME beast new call. This + *** places the volume into the admin volume directory. The + *** AVFILE_destruct() will remove from the admin volume when our + *** volume is freed via COMN_Release(). Note we need to call + *** the release version because VOL_BstNew() returns with an in-use + *** count of one. + ***/ zVolume = VOL_BstNew2( genMsg, zFTYPE_ZLSS_VOL, COMN_GetAdminVolume(), - volName, &volID, - zLSS_ID_ZLSS, zvlBeast->ZVL_p.PZVL_authModelID, - zvlBeast->ZVL_p.PZVL_state ); + volName, &volID, + zLSS_ID_ZLSS, zvlBeast->ZVL_p.PZVL_authModelID, + zvlBeast->ZVL_p.PZVL_state ); if ( zVolume == NULL ) { zASSERT("Why?"==NULL); return NULL; } - zASSERT( zVolume->ZFSVOLfile.FILEuseCount > 0 ); - ++(zVolume->ZFSVOLfile.FILEuseCount); /* One for load and - * One for us using */ - zASSERT( zVolume->ZFSVOLfile.FILEuseCount > 1 ); + zASSERT( zVolume->ZFSVOLfile.FILEuseCount > 0 ); + ++(zVolume->ZFSVOLfile.FILEuseCount); /* One for load and + * One for us using */ + zASSERT( zVolume->ZFSVOLfile.FILEuseCount > 1 ); - /* Set up the PHYSICAL pool(ZfsPool_s) that owns us. - * All I/O needs this */ + /* Set up the PHYSICAL pool(ZfsPool_s) that owns us. + * All I/O needs this */ zVolume->ZFSVOLpool = pool; - /* Set up the LOGICAL pool(ZlssPool_s) that owns us. - * All I/O needs this */ + /* Set up the LOGICAL pool(ZlssPool_s) that owns us. + * All I/O needs this */ ++(zlssPool->ZP_Pool.POOLroot.useCount); zVolume->ZLSSVOLv_pool = (Pool_s *)zlssPool; /* Set up the internal ID. Most I/O (debug) and most REDO/UNDO needs - * as this is the stamp ZLSS places at offset 16 off all system blks - */ + * as this is the stamp ZLSS places at offset 16 off all system blks + */ /* This does a structure COPY */ zVolume->ZLSSVOLinternalID = zvlBeast->ZVL_p.PZVL_internalID; /* The LVs restart count is simply the internal volumes restart count. - * This is done (verses using the activation count) because then - * rebuild does not need to worry about re-creating an accurate - * activation count if the VDB is bad. The persistent restart - * count is stored in the checkpoints (which we have FOUR of) and - * therefore rebuild trusts. Also note that if the checkpoints - * are all bad then rebuild is not able to run. - */ + * This is done (verses using the activation count) because then + * rebuild does not need to worry about re-creating an accurate + * activation count if the VDB is bad. The persistent restart + * count is stored in the checkpoints (which we have FOUR of) and + * therefore rebuild trusts. Also note that if the checkpoints + * are all bad then rebuild is not able to run. + */ zVolume->ZLSSVOLvol.v_restartCount = pVolume->v_restartCount; #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(GREEN,MSGNot("%s restart count %ld\n"), WHERE, - (unsigned long)zVolume->ZLSSVOLvol.v_restartCount); + (unsigned long)zVolume->ZLSSVOLvol.v_restartCount); #endif switch ( zvlBeast->ZVL_p.PZVL_state ) { @@ -1225,7 +1219,7 @@ typedef struct ZVL_RenameInfo_t { */ void ZVL_RenameThread( - FsmLite_s *fsmLite, + FsmLite_s *fsmLite, ZVL_RenameInfo_t *ri ) { @@ -1299,7 +1293,7 @@ STATUS ZLSSVOL_RenameZVLBAsync( FSMLITE_INIT( &ri->RI_fsmLite, MSGNot("ZLSSVOL_RenameZVLBAsync"), ZLSSVOL_RenameZVLBAsyncInstance++ ); - WORK_Schedule( &ri->RI_fsmLite, (voidfunc_t)ZVL_RenameThread, (ADDR)ri); + WORK_Schedule( &ri->RI_fsmLite, ZVL_RenameThread, (ADDR)ri); return( zOK ); } /* End of ZLSSVOL_RenameZVLBAsync() */ @@ -1327,19 +1321,19 @@ STATUS ZLSSVOL_RenameZVLBAsync( ZfsVolume_s *ZLSSVOL_LV_Load( GeneralMsg_s *genMsg, ZlssVolumeLocator_s *zvlBeast, /* Beast that describes the Logical - * volume to be loaded. This beast - * must reside in the pVolume supplied - * below. - */ + * volume to be loaded. This beast + * must reside in the pVolume supplied + * below. + */ Volume_s *pVolume, /* Physical Volume. This is the volume - * that ZLSS Pool uses to store Logical - * Volume Locator beasts. Sometimes - * referred to as the Pool's Volume. - */ + * that ZLSS Pool uses to store Logical + * Volume Locator beasts. Sometimes + * referred to as the Pool's Volume. + */ BOOL verbose, BOOL activate ) /* Activate (even if not the policy) - * This is used in LV AIPU. - */ + * This is used in LV AIPU. + */ { ZfsVolume_s *zVolume; @@ -1365,11 +1359,11 @@ ZfsVolume_s *ZLSSVOL_LV_Load( zASSERT( poolVolume->ZFSPOOLvol.v_pool != NULL ); zlssPool = (ZlssPool_s *)(poolVolume->ZFSPOOLvol.v_pool); - ASSERT_XLATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + ASSERT_XLATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); /* Above is required because we do not want the POOL to - * go away on us while we are loading a LV. Loading - * does not take long so no problem!!! - */ + * go away on us while we are loading a LV. Loading + * does not take long so no problem!!! + */ DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(NSS_VOLUME_COLOR, MSGNot("Loading volume \"%U\" with mode is %d(2 is normal)\n"), @@ -1381,21 +1375,21 @@ ZfsVolume_s *ZLSSVOL_LV_Load( } /*** Handle LVs that are in the creation state - *** by simply deleting the ZLSS locator beast. Because - *** LV creation is transactioned we can be ensured that if - *** the zvlBeast is in the PZVL_S_CREATION state the - *** LV is not around so we only need to delete the zvlBeast. - *** The check for PZVL_S_CREATION_DELETE(zero) is needed just in case - *** we crashed before the zvlBeast creation code could fill in the - *** PZVL_state field. I have elected not to set PZVL_S_CREATION - *** to zero so that one can detect at what point we crashed - *** in LV create (although this is only used in debug). - *** Note that we can not really continue creation as if crashed - *** really early in LV create then we do not know desired size, - *** Volume ID etc. Since crashing during LV creation will be - *** infrequent we will just require the user to re-submit the - *** request. - ***/ + *** by simply deleting the ZLSS locator beast. Because + *** LV creation is transactioned we can be ensured that if + *** the zvlBeast is in the PZVL_S_CREATION state the + *** LV is not around so we only need to delete the zvlBeast. + *** The check for PZVL_S_CREATION_DELETE(zero) is needed just in case + *** we crashed before the zvlBeast creation code could fill in the + *** PZVL_state field. I have elected not to set PZVL_S_CREATION + *** to zero so that one can detect at what point we crashed + *** in LV create (although this is only used in debug). + *** Note that we can not really continue creation as if crashed + *** really early in LV create then we do not know desired size, + *** Volume ID etc. Since crashing during LV creation will be + *** infrequent we will just require the user to re-submit the + *** request. + ***/ if ( (zvlBeast->ZVL_p.PZVL_state == PZVL_S_CREATION) || (zvlBeast->ZVL_p.PZVL_state == PZVL_S_CREATION_DELETE) ) { @@ -1407,7 +1401,7 @@ ZfsVolume_s *ZLSSVOL_LV_Load( X_LATCH( &poolVolume->ZFSPOOLbeastLatch); status = COMN_GetNameFromBeast( genMsg, (NamedBeast_s *)poolVolume, // cnt zFNU_FIRST_PARENT, - zNSPACE_LONG, NELEMS(aStack->containerVolumeName), + zNSPACE_LONG, NELEMS(aStack->containerVolumeName), aStack->containerVolumeName, NULL); UNX_LATCH( &poolVolume->ZFSPOOLbeastLatch ); if ( status != zOK ) @@ -1417,12 +1411,12 @@ ZfsVolume_s *ZLSSVOL_LV_Load( RTN_PTR( NULL ); } /** Get the zvlBeast name because if in PZVL_S_CREATION_DELETE - ** state the zVolumeName has not been set. In any case, we - ** will be deleting the ZVL Beast so we needs its name. - **/ + ** state the zVolumeName has not been set. In any case, we + ** will be deleting the ZVL Beast so we needs its name. + **/ status = COMN_GetNameFromBeast( genMsg, &zvlBeast->ZVLfile.FILEnamed, // cnt zFNU_FIRST_PARENT, - zNSPACE_LONG, NELEMS(aStack->zvlName), + zNSPACE_LONG, NELEMS(aStack->zvlName), aStack->zvlName, NULL); if ( status != zOK ) { @@ -1431,15 +1425,15 @@ ZfsVolume_s *ZLSSVOL_LV_Load( RTN_PTR( NULL ); } /** Because our caller owns the zvlBeast latch we must - ** async delete the beast so that it occurs after - ** our caller releases the latch. - **/ + ** async delete the beast so that it occurs after + ** our caller releases the latch. + **/ status = ZLSSVOL_LV_ZVLDeleteAsync( genMsg, aStack->zvlName, aStack->containerVolumeName ); if ( status == zOK ) { /* On sucessful deletion we return the expected zERR - * for a load that failed because the volume was - * in the creation state. - */ + * for a load that failed because the volume was + * in the creation state. + */ SetErrno( genMsg, zERR_VOLUME_CREATION_MODE ); } STACK_FREE(); @@ -1463,7 +1457,7 @@ ZfsVolume_s *ZLSSVOL_LV_Load( { DBG_DebugPrintf(LRED,MSGNot(" Not loading volume \"%U\" because /OnlyPoolName=%U switch\n"),zVolumeName,&gZCL_OnlyPoolName[0]); aprintf(LRED,MSGNot(" Not loading volume \"%U\" because /OnlyPoolName=%U switch\n"),zVolumeName,&gZCL_OnlyPoolName[0]); - SetErrno(genMsg,zERR_NO_MEMORY); + SetErrno(genMsg,zERR_NO_MEMORY); STACK_FREE(); RTN_PTR(NULL); } @@ -1495,13 +1489,13 @@ ZfsVolume_s *ZLSSVOL_LV_Load( } /** Get the zvlBeast name because we need to see if the zvlBeast - ** name is the same as what is store in the zvlBeast. They - ** can get off as the LV rename code renames each one in - ** seperate transactions. - **/ + ** name is the same as what is store in the zvlBeast. They + ** can get off as the LV rename code renames each one in + ** seperate transactions. + **/ status = COMN_GetNameFromBeast( genMsg, &zvlBeast->ZVLfile.FILEnamed, // cnt zFNU_FIRST_PARENT, - zNSPACE_LONG, NELEMS(aStack->zvlName), + zNSPACE_LONG, NELEMS(aStack->zvlName), aStack->zvlName, NULL); if ( status == zOK ) { @@ -1523,7 +1517,7 @@ ZfsVolume_s *ZLSSVOL_LV_Load( X_LATCH( &poolVolume->ZFSPOOLbeastLatch); status = COMN_GetNameFromBeast( genMsg, (NamedBeast_s *)poolVolume, // cnt zFNU_FIRST_PARENT, - zNSPACE_LONG, NELEMS(aStack->containerVolumeName), + zNSPACE_LONG, NELEMS(aStack->containerVolumeName), aStack->containerVolumeName, NULL); UNX_LATCH( &poolVolume->ZFSPOOLbeastLatch ); if ( status != zOK ) @@ -1533,9 +1527,9 @@ ZfsVolume_s *ZLSSVOL_LV_Load( } else { /** Because our caller owns the zvlBeast latch we must - ** async rename the beast so that it occurs after - ** our caller releases the latch. - **/ + ** async rename the beast so that it occurs after + ** our caller releases the latch. + **/ status = ZLSSVOL_RenameZVLBAsync( genMsg, aStack->zvlName, zVolumeName, aStack->containerVolumeName ); if ( status != zOK ) @@ -1566,8 +1560,8 @@ ZfsVolume_s *ZLSSVOL_LV_Load( status = ZLSSVOL_LVD_LoadModeDeletion( genMsg, zvlBeast, zVolume, poolVolume, verbose ); /* The zVolume pointer is invalid on return and - * our use count has been released. - */ + * our use count has been released. + */ zVolume = NULL; if ( status == zOK ) { @@ -1609,19 +1603,19 @@ ZfsVolume_s *ZLSSVOL_LV_Load( ZfsVolume_s *ZLSSVOL_LV_LoadVerify( GeneralMsg_s *genMsg, ZlssVolumeLocator_s *zvlBeast, /* Beast that describes the Logical - * volume to be loaded. This beast - * must reside in the pVolume supplied - * below. - */ + * volume to be loaded. This beast + * must reside in the pVolume supplied + * below. + */ Volume_s *pVolume, /* Physical Volume. This is the volume - * that ZLSS Pool uses to store Logical - * Volume Locator beasts. Sometimes - * referred to as the Pool's Volume. - */ + * that ZLSS Pool uses to store Logical + * Volume Locator beasts. Sometimes + * referred to as the Pool's Volume. + */ BOOL verbose, BOOL activate ) /* Activate (even if not the policy) - * This is used in LV AIPU. - */ + * This is used in LV AIPU. + */ { ZfsVolume_s *zVolume; @@ -1640,11 +1634,11 @@ ZfsVolume_s *ZLSSVOL_LV_LoadVerify( zASSERT( poolVolume->ZFSPOOLvol.v_pool != NULL ); zlssPool = (ZlssPool_s *)(poolVolume->ZFSPOOLvol.v_pool); - ASSERT_XLATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + ASSERT_XLATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); /* Above is required because we do not want the POOL to - * go away on us while we are loading a LV. Loading - * does not take long so no problem!!! - */ + * go away on us while we are loading a LV. Loading + * does not take long so no problem!!! + */ DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(NSS_VOLUME_COLOR, MSGNot("Loading volume \"%U\" with mode is %d(2 is normal)\n"), @@ -1671,10 +1665,10 @@ ZfsVolume_s *ZLSSVOL_LV_LoadVerify( switch ( zvlBeast->ZVL_p.PZVL_state ) { /* For verify we load the both deleted and created volume - * as though they are created. This is done as verify needs - * to verify the delted volumes. Verify will handle the - * fact that the deleted volume may be purging. - */ + * as though they are created. This is done as verify needs + * to verify the delted volumes. Verify will handle the + * fact that the deleted volume may be purging. + */ case PZVL_S_DELETION: case PZVL_S_CREATED: zVolume = ZLSSVOL_LV_LoadModeCreated( genMsg, zvlBeast, zVolume, @@ -1769,7 +1763,7 @@ ZfsVolume_s *ZLSSVOL_LV_LoadVerify( /* releases. We will have to consider how to prevent future rollbacks from proceeding */ /* beyond this point. Right now we are overwriting the version numbers that we assigned */ /* in ZLSSVOL_InitVDB because we didn't know at that time the volume was encrypted. */ - version = (zVolume->ZLSSVOLmediaFormatMajor * 0x100 ) + zVolume->ZLSSVOLmediaFormatMinor; + version = (zVolume->ZLSSVOLmediaFormatMajor * 0x100 ) + zVolume->ZLSSVOLmediaFormatMinor; if(version <= ((ZLSS_LV_MEDIA_MAJOR_NAKOMA * 0x100) + ZLSS_LV_MEDIA_MINOR_NAKOMA_COMP)) { @@ -1796,9 +1790,9 @@ ZfsVolume_s *ZLSSVOL_LV_LoadVerify( } else { /* We ignore errors because the error should be FILE ALREADY - * EXISTS. Any way, we will report an error if we can't create - * the ZVL Beast a little later - */ + * EXISTS. Any way, we will report an error if we can't create + * the ZVL Beast a little later + */ zASSERT( GetErrno(genMsg) == zERR_FILE_ALREADY_EXISTS ); ClearErrno( genMsg ); } @@ -1810,14 +1804,14 @@ ZfsVolume_s *ZLSSVOL_LV_LoadVerify( unicat( /*dest*/fullName, zVolumeName ); fileType = zFTYPE_ZLSS_VOLUME_LOCATOR; /* We set the 'inhibit bits' just to make it a little harder to - * delete this file. It would be VERY bad to delete this file because - * we would loss track of a logical volume. - * At this time the volume that contains the file is hidden - * and can not be seen by ANY user. - */ + * delete this file. It would be VERY bad to delete this file because + * we would loss track of a logical volume. + * At this time the volume that contains the file is hidden + * and can not be seen by ANY user. + */ fileAttributes = (zFA_RENAME_INHIBIT | - zFA_DELETE_INHIBIT | - zFA_COPY_INHIBIT); + zFA_DELETE_INHIBIT | + zFA_COPY_INHIBIT); if ( autoIPU ) { @@ -1853,10 +1847,10 @@ ZfsVolume_s *ZLSSVOL_LV_LoadVerify( zASSERT( COMN_IsDerivedFrom(file, zFTYPE_ZLSS_VOLUME_LOCATOR) ); zvlBeast = (ZlssVolumeLocator_s *)file; /* The next ASSERT is a test that if in autoIPU mode that - * the we found the file because the create of the ZVL Beast - * is not part of the LV create xxaction (because ZVL_Create - * does not support passing in a xaction). - */ + * the we found the file because the create of the ZVL Beast + * is not part of the LV create xxaction (because ZVL_Create + * does not support passing in a xaction). + */ zASSERT( zvlBeast->ZVL_p.PZVL_state == 0 ); zvlBeast->ZVL_p.PZVL_state = PZVL_S_CREATION; zvlBeast->ZVLfile.FILEeof = 0; @@ -1867,14 +1861,14 @@ ZfsVolume_s *ZLSSVOL_LV_LoadVerify( zASSERT( sizeof(zvlBeast->ZVL_p.PZVL_reserved) == 800-(71*4) ); /* If you added a new field to the zvlBeast then - * be sure to init here. Also check LV delete, - * rename and snapshot code to see if they need - * to be updated to handle your new field. - */ + * be sure to init here. Also check LV delete, + * rename and snapshot code to see if they need + * to be updated to handle your new field. + */ if ( zlssPool->ZP_Snapshot ) { /* Set the snapshot ID so that we do not 'snapshot' - * this volume the first time we load it. - */ + * this volume the first time we load it. + */ zvlBeast->ZVL_p.PZVL_snapshotID = zlssPool->ZP_SnapshotID; } @@ -1923,11 +1917,11 @@ ZfsVolume_s *ZLSSVOL_LV_LoadVerify( GeneralMsg_s *genMsg, unicode_t *containerVolumeName, ZfsXaction_s *xaction, /* FixFixFix(LV,ACI,10) - would be nice - * to be able to use this. If we create - * something later in the directory then - * ZLOG would already have directory - * records in it? - */ + * to be able to use this. If we create + * something later in the directory then + * ZLOG would already have directory + * records in it? + */ BOOL autoIPU ) { @@ -1951,14 +1945,14 @@ ZfsVolume_s *ZLSSVOL_LV_LoadVerify( unicat( /*dest*/fullName, ZLSSVOL_DIRECTORY_NAME_UNICODE ); fileType = zFTYPE_FILE; /* We set the inhibit bits just to make it a little harder to - * delete this directory. It would be VERY bad to delete/rename this - * directory. At this time the volume that contains the directory is - * hidden and can not be seen by ANY user. - */ + * delete this directory. It would be VERY bad to delete/rename this + * directory. At this time the volume that contains the directory is + * hidden and can not be seen by ANY user. + */ fileAttributes = (zFA_SUBDIRECTORY | - zFA_RENAME_INHIBIT | - zFA_DELETE_INHIBIT | - zFA_COPY_INHIBIT); + zFA_RENAME_INHIBIT | + zFA_DELETE_INHIBIT | + zFA_COPY_INHIBIT); retKey = NULL; COMN_INCLUDE_INTERNAL_VOLUMES( genMsg ); DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, (CYAN, @@ -2074,9 +2068,9 @@ STATUS ZFT_BlockAlloc( blockArray[block] = INVALID_BLK; } allocatedBlocks = 0; - do + do { - status = zfsAllocExtent(genMsg, zVolume, &localExt, + status = zfsAllocExtent(genMsg, zVolume, &localExt, systemRequest ? XTREE_SYSTEM_REQUEST : 0, xaction); if ( (status != zOK) || (localExt.lengthOfExtent == 0) ) { /* Free all the blocks we have allocated and return an error */ @@ -2134,7 +2128,7 @@ void ZLSSVOL_LV_CreatePurgeLog( COMN_MARK_BEAST_XLOCAL( &volPL->ZFSPURGELOGroot, &xaction->xaction); /* log the init record */ ZLOG_ObtainRecord(xaction, - ZLOG_BLOCK_INFO_SIZE(1) + sizeof(BeastTreeInit_s) ); + ZLOG_BLOCK_INFO_SIZE(1) + sizeof(BeastTreeInit_s) ); ZLOG_INIT_LOG_RECORD( XFUNC_LV_PL_INIT, xaction, logBuffer, 1, poolBlks, logRecord ); @@ -2185,7 +2179,7 @@ void ZLSSVOL_LV_CreateBeastTree( btree->zfsBtree.p.btRoot = blockRoot; btree->specialSystemBstsBlk = zVolume->p.PZV_systemBeastBlkNum; - READBLK_IO_MSG( iomsg, btree, btree->specialSystemBstsBlk, CACHE_WRITE); + READBLK_IO_MSG( iomsg, btree, btree->specialSystemBstsBlk, CACHE_WRITE); bufferSpecial = ZFS_ReadPoolBlk( NULL, &iomsg ); zASSERT( bufferSpecial != NULL ); /* Can not get error with CACHE_WRITE parameter */ nodeSpecial = (BeastTreeNode_s *)bufferSpecial->pBuf.data; @@ -2209,7 +2203,7 @@ void ZLSSVOL_LV_CreateBeastTree( COMN_MARK_BEAST_XLOCAL(&btree->ZFSBEASTTREEroot, &xaction->xaction); /* log the init record */ ZLOG_ObtainRecord(xaction, - ZLOG_BLOCK_INFO_SIZE(2) + sizeof(BeastTreeInit_s) ); + ZLOG_BLOCK_INFO_SIZE(2) + sizeof(BeastTreeInit_s) ); ZLOG_INIT_LOG_RECORD(XFUNC_LV_BT_INIT, xaction, logBuffer, 2, poolBlks, logRecord); @@ -2227,7 +2221,7 @@ void ZLSSVOL_LV_CreateBeastTree( ZLOG_BIND(xaction, bufferSpecial); ZLOG_ReleaseRecord(xaction); } - + CACHE_DIRTY_RELEASE(bufferRoot); CACHE_DIRTY_RELEASE(bufferSpecial); @@ -2260,13 +2254,13 @@ void ZLSSVOL_InitLVDB( zASSERT( LB_GUIDValidate( &zVolume->ZLSSVOLvolumeID ) ); zASSERT( LB_GUIDValidate( &zVolume->ZLSSVOLinternalID ) ); /***** - * Initialize ALL LoggedPersistentZfsVolume_s - *****/ + * Initialize ALL LoggedPersistentZfsVolume_s + *****/ zASSERT( offsetof( LoggedPersistentZfsVolume_s, LPZV_reserved ) == 32 ); /* If you hit the above ASSERT be sure to add the item - * that changed the size to the initialization code below. - * Then update the ASSERT - */ + * that changed the size to the initialization code below. + * Then update the ASSERT + */ zVolume->logged.LPZV_magic = ZFSLOGGEDVOLUMEINFO_MAGIC; zVolume->logged.LPZV_version = ZFSLOGGEDVOLUMEINFO_VERSION; zVolume->logged.LPZV_lsn = 0; @@ -2275,21 +2269,21 @@ void ZLSSVOL_InitLVDB( /* zVolume->logged.LPZV_reserved = ...; We do not do as not persistently saved */ /***** - * Initialize ALL LoggedPersistentVolume_s - *****/ + * Initialize ALL LoggedPersistentVolume_s + *****/ zASSERT( offsetof( LoggedPersistentVolume_s, LPV_reserved ) == 120 ); /* If you hit the above ASSERT be sure to add the item - * that changed the size to the initialization code below. - * Then update the ASSERT - */ + * that changed the size to the initialization code below. + * Then update the ASSERT + */ COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); COMN_GetVolumeName( &dummyGenMsg, &zVolume->ZFSVOLvol, aStack->volumeName, NELEMS(aStack->volumeName) ); /* - * If we are creating the PERSISTENT admin volume then adjust its - * allocatable zid range. - */ + * If we are creating the PERSISTENT admin volume then adjust its + * allocatable zid range. + */ if ( uniicmp( aStack->volumeName, PersistAdminVolUnicodeName ) == 0 ) { zVolume->ZLSSVOLvol.logged.nextZid = AVOL_FIRST_PERSISTENT_ZID; @@ -2321,8 +2315,8 @@ void ZLSSVOL_InitLVDB( /* NON - PERSISTENT items */ /* This is kludgie as not a true logged item, but an - * item that is directly related to a logged item - */ + * item that is directly related to a logged item + */ zVolume->ZLSSVOLbookedInUseBlocks = zVolume->ZLSSVOLinUseBlocks; STACK_FREE(); return; @@ -2339,20 +2333,20 @@ void ZLSSVOL_InitLVDB( * * WARNING - * zVolume->ZFSVOLvol.p.authModelID must already be set (VOL_BstNew2 should have done) - * + * */ -void ZLSSVOL_InitVDB( +void ZLSSVOL_InitVDB( ZfsVolume_s *zVolume, Blknum_t lvdb, Blknum_t vdb, Blknum_t btSpecialBlock, Time_t createTime, LONG rebuildCount, /* 0 if Create, else indicates Rebuild */ - Time_t rebuildTime, + Time_t rebuildTime, BOOL virtualFileFlag ) -{ +{ ZlssPool_s *zlssPool; zASSERT( zVolume->ZFSVOLpool != NULL ); @@ -2371,13 +2365,13 @@ void ZLSSVOL_InitVDB( } /***** - * Initialize ALL PersistentVolume_s - *****/ + * Initialize ALL PersistentVolume_s + *****/ zASSERT( offsetof( PersistentVolume_s, PV_reserved3 ) == 184 ); /* If you hit the above ASSERT be sure to add the item - * that changed the size to the initialization code below. - * Then update the ASSERT - */ + * that changed the size to the initialization code below. + * Then update the ASSERT + */ zVolume->ZFSVOLvol.p.NUvolumeID = zINVALID_GUID; zVolume->ZFSVOLvol.p.beastVersionMask = 1 << (CURRENT_BEAST_VERSION - 1); @@ -2397,7 +2391,7 @@ void ZLSSVOL_InitVDB( // cnt zVolume->ZFSVOLvol.p.beastVersion = CURRENT_BEAST_VERSION; if(zlssPool->ZP_Version >= ZLSS_MEDIA_VERSION_4303) { - zVolume->ZFSVOLvol.p.beastVersion = BEAST_VERSION_3; // if the pool is upgraded, for the volume to be the same + zVolume->ZFSVOLvol.p.beastVersion = BEAST_VERSION_3; // if the pool is upgraded, for the volume to be the same } else { @@ -2407,21 +2401,21 @@ void ZLSSVOL_InitVDB( { zVolume->ZFSVOLvol.p.beastVersion = HL_ClusterApprovesUpgrade() ? HL_NewSharedVolumeBeastVersion : BEAST_VERSION_2; } - else + else { zVolume->ZFSVOLvol.p.beastVersion = HL_NewLocalVolumeBeastVersion; } } else { /* We are rebuild and the pool is not yet 43.03+, therefore the volume's media - * number will be set to pre-HardLink, therefore BV needs to be 2. I.E. we - * do not care about HL_NewSharedVolumeBeastVersion or HL_NewLocalVolumeBeastVersion - * because they are for NEW volumes and we need to be set to what we ARE. - */ - zVolume->ZFSVOLvol.p.beastVersion = BEAST_VERSION_2; + * number will be set to pre-HardLink, therefore BV needs to be 2. I.E. we + * do not care about HL_NewSharedVolumeBeastVersion or HL_NewLocalVolumeBeastVersion + * because they are for NEW volumes and we need to be set to what we ARE. + */ + zVolume->ZFSVOLvol.p.beastVersion = BEAST_VERSION_2; } } - + zVolume->ZFSVOLvol.p.stateAttributes = 0; zVolume->ZFSVOLvol.p.rebuildCount = rebuildCount; zVolume->ZFSVOLvol.p.ndsObjectID = zINVALID_GUID; @@ -2441,10 +2435,10 @@ void ZLSSVOL_InitVDB( else { /* Compression OFF */ /* The compAttributes items are not used until someone - * turns on compression on the volume. When compression - * is turned on then these items will be inited properly. - * I fill in just so that this routine INITs all items. - */ + * turns on compression on the volume. When compression + * is turned on then these items will be inited properly. + * I fill in just so that this routine INITs all items. + */ zVolume->ZFSVOLvol.p.compAttributes.ImplMajorVersion = NSS_COMP_IMPL_MAJOR_VERSION; zVolume->ZFSVOLvol.p.compAttributes.ImplMinorVersion = NSS_COMP_IMPL_MINOR_VERSION; zVolume->ZFSVOLvol.p.compAttributes.algoID = 0; @@ -2455,15 +2449,15 @@ void ZLSSVOL_InitVDB( } /* We create new style LVs if pool is at 43.00 or higher. Since - * rebuild is not creating a new LV it must wait until 43.02. - * When a pool is at 43.02 it means that ALL of its LVs have - * made it to 36.03 or 37.03. Therefore, rebuild can init VDB in the 36.03 - * format. - * If a Volume happens to be at 36.01 and rebuild puts it back - * to 35.00 nothing bad will happen. I.E. the upgrade from - * LV version 35.00 to 36.01 has been written to assume that - * it may be called even after it has completed. - */ + * rebuild is not creating a new LV it must wait until 43.02. + * When a pool is at 43.02 it means that ALL of its LVs have + * made it to 36.03 or 37.03. Therefore, rebuild can init VDB in the 36.03 + * format. + * If a Volume happens to be at 36.01 and rebuild puts it back + * to 35.00 nothing bad will happen. I.E. the upgrade from + * LV version 35.00 to 36.01 has been written to assume that + * it may be called even after it has completed. + */ #if ZLSS_LV_MEDIA_MAJOR_CURRENT != 36 #error Rebuild may be better off if you also change the pool version. #endif @@ -2480,7 +2474,7 @@ void ZLSSVOL_InitVDB( zVolume->ZFSVOLvol.p.compAttributes.compFlags |= (VOL_COMP_FLAGS_UPGRADE_START | VOL_COMP_FLAGS_UPGRADE_FINISHED); } else if ( ( (rebuildCount == 0) && (zlssPool->ZP_Version >= ZLSS_MEDIA_VERSION_4300) ) || - ( (rebuildCount != 0) && (zlssPool->ZP_Version >= ZLSS_MEDIA_VERSION_4301) ) ) + ( (rebuildCount != 0) && (zlssPool->ZP_Version >= ZLSS_MEDIA_VERSION_4301) ) ) { /*** New Style LVs ***/ /* For Create, Pool is 43.00 or 43.02 (or newer) so create Nakoma LVs (i.e. 36.03) */ /* For Rebuild, Pool is 43.02 (or newer) so create Nakoma LVs (i.e. 36.03) */ @@ -2517,17 +2511,17 @@ void ZLSSVOL_InitVDB( zVolume->ZFSVOLvol.p.PV_activationTimeUTC = 0; zVolume->ZFSVOLvol.p.PV_shredCount = 1; zVolume->ZFSVOLvol.p.PV_reserved2 = 0; - bzero(zVolume->ZFSVOLvol.p.PV_reserved3, - sizeof(zVolume->ZFSVOLvol.p.PV_reserved3)); + bzero(zVolume->ZFSVOLvol.p.PV_reserved3, + sizeof(zVolume->ZFSVOLvol.p.PV_reserved3)); /***** - * Initialize ALL PersistentZfsVolume_s - *****/ + * Initialize ALL PersistentZfsVolume_s + *****/ zASSERT( offsetof( PersistentZfsVolume_s, PZV_reserved ) == 88 ); /* If you hit the above ASSERT be sure to add the item - * that changed the size to the initialization code below. - * Then update the ASSERT - */ + * that changed the size to the initialization code below. + * Then update the ASSERT + */ zVolume->p.PZV_magic = ZFSVOLUMEINFO_MAGIC; zVolume->p.PZV_version = ZFSVOLUMEINFO_VERSION; zVolume->p.PZV_checksum = 0; /* The writer must calculate @@ -2547,8 +2541,8 @@ void ZLSSVOL_InitVDB( bzero(zVolume->p.PZV_reserved, sizeof(zVolume->p.PZV_reserved)); /***** - * NON - PERSISTENT items - ****/ + * NON - PERSISTENT items + ****/ zVolume->ZLSSVOLvol.VOLmaximumFileSize = UI64_CONST(0xFFFFFFFFFFFFFFFF); zVolume->ZLSSVOLvol.VOLsupportedAttributes = ZLSS_SUPPORTED_ATTRIBUTES; zVolume->ZLSSVOLvol.VOLroot.beastVersion = zVolume->ZFSVOLvol.p.beastVersion; @@ -2629,9 +2623,9 @@ STATUS ZLSSVOL_LV_Create( if (retCode != OPERATION_DENIED) { exitEvent.enterRetStatus = retCode; - status = ZLSSVOL_LV_CreateInternal(genMsg, pVolume, zVolumeName, - zVolumeSize, authModelID, requestedVolumeID, virtualFileFlag, - xaction, autoIPU, &exitEvent.volID); + status = ZLSSVOL_LV_CreateInternal(genMsg, pVolume, zVolumeName, + zVolumeSize, authModelID, requestedVolumeID, virtualFileFlag, + xaction, autoIPU, &exitEvent.volID); exitEvent.opRetCode = (status == zOK) ? zOK : GetErrno(genMsg); COMN_SendNSSEvent(EVENT_LVolCreate_Exit, &exitEvent, sizeof(exitEvent), &denyCode); } @@ -2673,10 +2667,10 @@ STATUS ZLSSVOL_LV_CreateInternal( typedef struct Stack_s { unicode_t containerVolumeName[zMAX_COMPONENT_NAME]; /* Volume that ZLSS Volume Locator beast - * should be created on. This is the - * name of the Pool's physical volume (no - * colon)! - */ + * should be created on. This is the + * name of the Pool's physical volume (no + * colon)! + */ } Stack_s; STACK_ALLOC(); @@ -2696,7 +2690,7 @@ STATUS ZLSSVOL_LV_CreateInternal( poolVolume = (ZfsPool_s *)pVolume; zASSERT( poolVolume->ZFSPOOLvol.v_pool != NULL ); zlssPool = (ZlssPool_s *)(poolVolume->ZFSPOOLvol.v_pool); - ASSERT_XLATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + ASSERT_XLATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); zASSERT( zlssPool->ZLSSPOOLstate == zVOLSTATE_ACTIVE ); COMN_INCLUDE_INTERNAL_VOLUMES( genMsg ); (void)COMN_GetVolumeName( genMsg, pVolume, aStack->containerVolumeName, NELEMS(aStack->containerVolumeName) ); @@ -2704,7 +2698,7 @@ STATUS ZLSSVOL_LV_CreateInternal( /* Generate or use the passed in volume GUID */ if ( LB_GUIDCompare( requestedVolumeID, &zINVALID_GUID ) == 0 ) - { + { LB_GUIDGenerate( &zVolumeID ); } else @@ -2742,27 +2736,27 @@ STATUS ZLSSVOL_LV_CreateInternal( MSGNot("LV_Create gen'ed GUID*timeLow only) %8lx\n"), zVolumeID.timeLow) ); /* - * New the LV beast - Use the special VOLUME beast new call. This - * places the volume into the admin volume directory. The - * AVFILE_destruct() will remove from the admin volume when our - * volume is freed via COMN_Release(). Note we need to call - * the release version because VOL_BstNew() returns with an inuse - * count of one. - */ + * New the LV beast - Use the special VOLUME beast new call. This + * places the volume into the admin volume directory. The + * AVFILE_destruct() will remove from the admin volume when our + * volume is freed via COMN_Release(). Note we need to call + * the release version because VOL_BstNew() returns with an inuse + * count of one. + */ zVolume = VOL_BstNew2( genMsg, zFTYPE_ZLSS_VOL, COMN_GetAdminVolume(), - zVolumeName, &zVolumeID, zLSS_ID_ZLSS, authModelID, + zVolumeName, &zVolumeID, zLSS_ID_ZLSS, authModelID, zVOL_PSTATE_CREATION ); if ( zVolume == NULL ) { goto error_exit; } /* - * Set up the PHYSICAL pool(ZfsPool_s) and the LOGICAL - * pool(ZlssPool_s) that owns us. All I/O needs this as well - * as xactions. The zv_zfsLogBeast is also needed for xactions. - * ZLSSVOLinternalID is used by debug I/O and many REDO/UNDO - * routines. - */ + * Set up the PHYSICAL pool(ZfsPool_s) and the LOGICAL + * pool(ZlssPool_s) that owns us. All I/O needs this as well + * as xactions. The zv_zfsLogBeast is also needed for xactions. + * ZLSSVOLinternalID is used by debug I/O and many REDO/UNDO + * routines. + */ zASSERT(poolVolume->ZFSPOOLroot.beastVersion == zlssPool->ZLSSPOOLroot.beastVersion); zVolume->ZFSVOLpool = (ZfsPool_s *)pVolume; ++(zlssPool->ZP_Pool.POOLroot.useCount); @@ -2772,16 +2766,16 @@ STATUS ZLSSVOL_LV_CreateInternal( zVolume->ZLSSVOLvol.v_restartCount = pVolume->v_restartCount; #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(GREEN,MSGNot("%s restart count %ld\n"), WHERE, - (unsigned long)zVolume->ZLSSVOLvol.v_restartCount); + (unsigned long)zVolume->ZLSSVOLvol.v_restartCount); #endif /**************************************************/ /*** Set up all the persistent fields in the LV ***/ /**************************************************/ /* We round up here so that the volume is at least the size user - * requested. - */ - ZLSSVOL_InitLVDB( zVolume, + * requested. + */ + ZLSSVOL_InitLVDB( zVolume, (zVolumeSize + poolVolume->ZFSPOOLblockSize - 1 ) >> poolVolume->ZFSPOOLblockShift, 0, 0, FALSE ); @@ -2789,8 +2783,8 @@ STATUS ZLSSVOL_LV_CreateInternal( GetUTCTime() , 0, 0, virtualFileFlag ); /* - * This will loop through to NEW all of the LV system beasts. - */ + * This will loop through to NEW all of the LV system beasts. + */ for ( i=0; ZLSSVolumeSuperBeasts[i].ZVBC_beastClass != -1; i++ ) { if (ZLSSVolumeSuperBeasts[i].ZVBC_flags & ZVBC_FLAG_CREATE_BEAST) @@ -2808,24 +2802,24 @@ STATUS ZLSSVOL_LV_CreateInternal( beast->FILEfirstParentZid = zINVALID_ZID; /* Do not put any of the SYSTEM beasts into the LV linked list - * because we need to control when the files are flushed. - */ + * because we need to control when the files are flushed. + */ BEASTHASH_Insert(&beast->FILEroot); DQ_RMV(beast,FILEvolLink); } } /** - * Create the Volume Location Beast now. Note that this is the - * first time in this routine that we are doing anything - * PERSISTENTLY. I.E. from here on out we have to handle cleaning - * up PERSISTENT items. The PERSISTENT cleanup is done in our - * error paths if we get an error. If we crash then when - * we try to load the LV in the future we will detect that the - * ZLSS Volume Locator Beast PZVL_state is PZVL_S_CREATION and then - * we delete the LV and the locator beast. - */ - zvlBeast = ZLSSVOL_LV_ZVLCreate( genMsg, zVolumeName, zVolume, + * Create the Volume Location Beast now. Note that this is the + * first time in this routine that we are doing anything + * PERSISTENTLY. I.E. from here on out we have to handle cleaning + * up PERSISTENT items. The PERSISTENT cleanup is done in our + * error paths if we get an error. If we crash then when + * we try to load the LV in the future we will detect that the + * ZLSS Volume Locator Beast PZVL_state is PZVL_S_CREATION and then + * we delete the LV and the locator beast. + */ + zvlBeast = ZLSSVOL_LV_ZVLCreate( genMsg, zVolumeName, zVolume, zVolumeID, aStack->containerVolumeName, xaction, autoIPU, authModelID ); if ( zvlBeast == NULL ) { @@ -2834,19 +2828,19 @@ STATUS ZLSSVOL_LV_CreateInternal( ASSERT_XLATCH(&zvlBeast->ZVLfile.FILEbeastLatch); /* - * Allocate FIVE blocks - * ONE for the Logged Volume Data Block (LVDB). - * ONE for the Volume Data Block (VDB). - * ONE for the Beast Tree Special Leaf Block. - * ONE for the Beast Tree Leaf Most Block. - * ONE for the Volume Purge Log First Block. - * - * Note that the logged volume data block is the most written - * block on most volumes, but it is rarely read because of - * caching. We try to allocate blocks in the center of the - * disk so that all LV have their LVDB near each other. - */ - seedext.poolBlkNum = poolVolume->ZP_super->SB_Header.hdr.totalblocks / 2; + * Allocate FIVE blocks + * ONE for the Logged Volume Data Block (LVDB). + * ONE for the Volume Data Block (VDB). + * ONE for the Beast Tree Special Leaf Block. + * ONE for the Beast Tree Leaf Most Block. + * ONE for the Volume Purge Log First Block. + * + * Note that the logged volume data block is the most written + * block on most volumes, but it is rarely read because of + * caching. We try to allocate blocks in the center of the + * disk so that all LV have their LVDB near each other. + */ + seedext.poolBlkNum = poolVolume->ZP_super->SB_Header.hdr.totalblocks / 2; seedext.lengthOfExtent = sizeof(lvBlocks)/sizeof(lvBlocks[0]); zASSERT( zVolume->ZLSSVOLv_pool != NULL ); status = ZFT_BlockAlloc(genMsg, zVolume, &seedext, TRUE, xaction, &lvBlocks[0]); @@ -2859,12 +2853,12 @@ STATUS ZLSSVOL_LV_CreateInternal( zVolume->p.PZV_systemBeastBlkNum = lvBlocks[2]; /*** Now some interesting code. Before the Endlocal and before - *** the LVDB is bonded to any ZLOG log records - *** we persistently init the VDB and LVDB. This - *** ensures that if we crash after the xaction commits that - *** the VDB and LVDB are inited. This is done as it - *** is much easier than creatind a new LR for LVDB and VDB. - ***/ + *** the LVDB is bonded to any ZLOG log records + *** we persistently init the VDB and LVDB. This + *** ensures that if we crash after the xaction commits that + *** the VDB and LVDB are inited. This is done as it + *** is much easier than creatind a new LR for LVDB and VDB. + ***/ status = ZFSVOL_WriteInitialVDB( genMsg, zVolume, xaction ); if ( status != zOK ) { @@ -2877,15 +2871,15 @@ STATUS ZLSSVOL_LV_CreateInternal( } /* - * All beasts are placed in the beast tree including the beast - * tree itself. We now need to write all of the system files into - * the beastTree so that the space for them will be allocated. - */ + * All beasts are placed in the beast tree including the beast + * tree itself. We now need to write all of the system files into + * the beastTree so that the space for them will be allocated. + */ for ( i=0; ZLSSVolumeSuperBeasts[i].ZVBC_beastClass != -1; i++ ) { if (ZLSSVolumeSuperBeasts[i].ZVBC_flags & ZVBC_FLAG_CREATE_BEAST) { - beast = *((File_s **)((ADDR)zVolume + + beast = *((File_s **)((ADDR)zVolume + ZLSSVolumeSuperBeasts[i].ZVBC_offset)); X_LATCH(&beast->FILEbeastLatch); @@ -2915,8 +2909,8 @@ STATUS ZLSSVOL_LV_CreateInternal( } /* - * Create and init the root directory of the LV - */ + * Create and init the root directory of the LV + */ rootdir = (File_s *)BST_new(genMsg,zFTYPE_FILE,zVolume); if (rootdir == NULL) @@ -2926,8 +2920,8 @@ STATUS ZLSSVOL_LV_CreateInternal( X_LATCH(&rootdir->FILEbeastLatch); /* Do not put any of the SYSTEM beasts into the Volume's list because - * we need to control when the files are flushed. - */ + * we need to control when the files are flushed. + */ if (ZFSPOOL_InitNewRootDir(genMsg, rootdir, zVolume) != zOK) { UNX_LATCH(&rootdir->FILEbeastLatch); @@ -2946,10 +2940,10 @@ STATUS ZLSSVOL_LV_CreateInternal( } /*** - *** Update the ZVL beast with the correct block numbers - *** and change its STATE to indicate that the LV - *** has been created successfully. - ***/ + *** Update the ZVL beast with the correct block numbers + *** and change its STATE to indicate that the LV + *** has been created successfully. + ***/ // X_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); zvlBeast->ZVL_p.PZVL_loggedVolumeDataBlk = zVolume->p.PZV_loggedVolumeDataBlk; zvlBeast->ZVL_p.PZVL_volumeDataBlk = zVolume->p.PZV_volumeDataBlk; @@ -2981,20 +2975,20 @@ STATUS ZLSSVOL_LV_CreateInternal( COMN_Release( &zvlBeast ); /*** - *** Flush and Toss all ZLSSVOL system beasts. - *** The deactivate also flushes the Volume Data Block and - *** Logged Volume Data Block. - ***/ + *** Flush and Toss all ZLSSVOL system beasts. + *** The deactivate also flushes the Volume Data Block and + *** Logged Volume Data Block. + ***/ (void)VOL_Deactivate( &dummyGenMsg, (Volume_s *)zVolume, 0 ); /* Can not return an error */ ClearErrno( &dummyGenMsg ); (void)ZFSVOL_Deactivate( &dummyGenMsg, zVolume, 0 ); /* Can not return an error */ ClearErrno( &dummyGenMsg ); ZLSSVOL_UnloadPersistentPool( zVolume, 0 ); /* By removing from the master volume link list we prevent - * this volume from being found. This prevents any new - * operations from starting which is a requirement since - * we will be freeing the volume's in-memory information. - */ + * this volume from being found. This prevents any new + * operations from starting which is a requirement since + * we will be freeing the volume's in-memory information. + */ if (QMEMBER(&zVolume->ZLSSVOLvol.masterVolLink)) { SET_RMV(zVolume,ZLSSVOLvol.masterVolLink); @@ -3008,7 +3002,7 @@ STATUS ZLSSVOL_LV_CreateInternal( error_zvlBeastUpdate: /********************/ /* No code here because we delete the zvlBeast later anyway - */ + */ /*******************/ error_rootdirCreated: @@ -3049,10 +3043,10 @@ error_zVolumeAndSystemBeastNewed: ZLSSVOL_UnloadPersistentPool( zVolume, 0 ); /* By removing from the master volume link list we prevent - * this volume from being found. This prevents any new - * operations from starting which is a requirement since - * we will be freeing the volume. - */ + * this volume from being found. This prevents any new + * operations from starting which is a requirement since + * we will be freeing the volume. + */ if (QMEMBER(&zVolume->ZLSSVOLvol.masterVolLink)) { SET_RMV(zVolume,ZLSSVOLvol.masterVolLink); @@ -3083,12 +3077,12 @@ error_exit: * so don't call this routine with a casted ZfsPool_s. * * Note - - * Function name is a little wierd, but left so that it matched the + * Function name is a little wierd, but left so that it matched the * ZFSPOOL function name. * */ -void ZLSSVOL_UnloadPersistentPool( +void ZLSSVOL_UnloadPersistentPool( ZfsVolume_s *zVolume, NINT mode ) @@ -3113,14 +3107,14 @@ void ZLSSVOL_UnloadPersistentPool( // beast every time we activate a LV. /* - * zVolume->p.PZV_loggedVolumeDataBlk = 0; - * zVolume->p.PZV_volumeDataBlk = 0; - * - * Zero all the persistent data - required for two commented - * out lines above, but a very good idea for all other fields. - * Note we zero the above fields because we will not write - * either volume data block if their block number is 0. - */ + * zVolume->p.PZV_loggedVolumeDataBlk = 0; + * zVolume->p.PZV_volumeDataBlk = 0; + * + * Zero all the persistent data - required for two commented + * out lines above, but a very good idea for all other fields. + * Note we zero the above fields because we will not write + * either volume data block if their block number is 0. + */ /* ZfsVolume_s persistent information */ // bzero( &zVolume->p, sizeof( zVolume->p) ); @@ -3318,7 +3312,7 @@ STATUS ZLSSVOL_DoFlushSystemBeasts( * so don't call this routine with a casted ZfsPool_s! */ -STATUS ZLSSVOL_LoadPersistentPool( +STATUS ZLSSVOL_LoadPersistentPool( GeneralMsg_s *genMsg, ZfsVolume_s *zVolume, NINT mode, /* Must be VOLMODE_xxx define */ @@ -3351,14 +3345,14 @@ STATUS ZLSSVOL_LoadPersistentPool( RTN_STATUS( zFAILURE ); } - /* We want the shredCount to always be a value between 1 and - * MAX_DATA_SHRED_PATTERNS. This is a kludgy way to upgrade - * existing volumes to the default value = 1 - */ - if ((zVolume->ZFSVOLshredCount == 0) || + /* We want the shredCount to always be a value between 1 and + * MAX_DATA_SHRED_PATTERNS. This is a kludgy way to upgrade + * existing volumes to the default value = 1 + */ + if ((zVolume->ZFSVOLshredCount == 0) || (zVolume->ZFSVOLshredCount > MAX_DATA_SHRED_PATTERNS)) { - zVolume->ZFSVOLshredCount = 1; + zVolume->ZFSVOLshredCount = 1; } /** * We must write the volume data information before playing @@ -3428,7 +3422,7 @@ STATUS ZLSSVOL_LoadPersistentPool( MSG("ZLSS supports volume layout v%u.%02u to v%u.%02u, \"%U\" is v%lu.%02lu.\n" "Run the correct NSS version, or recreate this volume.\n", 445), - ZLSS_LV_MEDIA_MAJOR, ZLSS_LV_MEDIA_MINOR, + ZLSS_LV_MEDIA_MAJOR, ZLSS_LV_MEDIA_MINOR, ZLSS_LV_MEDIA_MAJOR_NAKOMA_HARDLINK, ZLSS_LV_MEDIA_MINOR_NAKOMA_HARDLINK_DONE, aStack->volumeName, zVolume->ZLSSVOLmediaFormatMajor, @@ -3444,10 +3438,10 @@ STATUS ZLSSVOL_LoadPersistentPool( zASSERT( LB_GUIDValidate( &zVolume->ZLSSVOLvolumeID ) ); // zASSERT( LB_GUIDCompare( &zVolume->p.PZV_volumeID, &zVolume->ZLSSVOLvolumeID ) == 0 ); /* Ensure that the duplicate copy of the GUID is in the VDB. - * Specifically this helps the LV delete code because the delete - * code does not update the GUID in the VDB. Note that the GUID - * in the VDB is really a backup that re-link could use. - */ + * Specifically this helps the LV delete code because the delete + * code does not update the GUID in the VDB. Note that the GUID + * in the VDB is really a backup that re-link could use. + */ zVolume->p.PZV_volumeID = zVolume->ZLSSVOLvolumeID; /* Don't write until we KNOWN that we understand the media */ ZFSVOL_WritePersistentVolumeData(zVolume); @@ -3491,11 +3485,11 @@ STATUS ZLSSVOL_LoadSystemBeasts( if (ZLSSVolumeSuperBeasts[i].ZVBC_zid == ZFSPOOL_VOLBSTTREE_ZID) { /*** - *** Read the special BT block (which is known to contain - *** the Beast Tree beast because of the BT well known LOW - *** ZID). Then create the BT beast from the this persistent - *** information. - ***/ + *** Read the special BT block (which is known to contain + *** the Beast Tree beast because of the BT well known LOW + *** ZID). Then create the BT beast from the this persistent + *** information. + ***/ ZfsBeastTreeBeast_s *beastTree; blk = zVolume->p.PZV_systemBeastBlkNum; @@ -3515,8 +3509,8 @@ STATUS ZLSSVOL_LoadSystemBeasts( { errPrintf(WHERE, Module, 1418, MSG("Error reading beast tree block %d, status=%d.\n" - "Check the status, you may need to run Rebuild.", 447), - blk, GetErrno(genMsg)); + "Check the status, you may need to run Rebuild.", 447), + blk, GetErrno(genMsg)); } RTN_STATUS(zFAILURE); } @@ -3562,7 +3556,7 @@ STATUS ZLSSVOL_LoadSystemBeasts( else { if ((GetErrno(genMsg) != zERR_ZID_NOT_FOUND) || - (ZLSSVolumeSuperBeasts[i].ZVBC_flags & + (ZLSSVolumeSuperBeasts[i].ZVBC_flags & ZVBC_FLAG_CREATE_BEAST)) { errPrintf(WHERE, Module, 1422, @@ -3580,16 +3574,16 @@ STATUS ZLSSVOL_LoadSystemBeasts( if (beast != NULL) { BEASTHASH_Insert(beast); - /* We do not want these special system beasts to be in the - * linked list of files because they are System Beasts. E.G. - * when we flush user files we do not need system beasts flushed. - */ + /* We do not want these special system beasts to be in the + * linked list of files because they are System Beasts. E.G. + * when we flush user files we do not need system beasts flushed. + */ DQ_RMV(beast,volLink); /* - * If we have just loaded up the purge log then go through its setup - * so that entries can be added in later phases of activation, - * before it has a chance to be played. - */ + * If we have just loaded up the purge log then go through its setup + * so that entries can be added in later phases of activation, + * before it has a chance to be played. + */ if (ZLSSVolumeSuperBeasts[i].ZVBC_zid == ZFSVOL_PURGELOG_ZID) { if (ZFSPURGELOG_Setup(genMsg, (ZfsPurgeLogBeast_s *)beast) != zOK) @@ -3707,7 +3701,7 @@ cleanup: /* Requirements: Synchronous and non-blocking Entry state: Shared lock on beast latch - ZVLB_ZfsPackedSize - + ZVLB_ZfsPackedSize - */ STATIC NINT ZVL_ZlssPackedSize( @@ -3771,16 +3765,16 @@ STATIC BYTE *ZVL_ZlssUnpack( ZlssVolumeLocator_s *zvlBeast = (ZlssVolumeLocator_s *)zvlBeast_LX; PersistentZlssVolumeLocator_s *zvlBeastPForV; PersistentZlssVolumeLocator_2Dot0_s *zvlBeastP2Dot0; - + zvlBeastP2Dot0 = (PersistentZlssVolumeLocator_2Dot0_s *)storeBuffer; - - + + ENTER(TLVOLUMES, ZVL_ZlssUnpack); /** Until we known if this is a 2.00 or 3.00 ZLSS Volume Locator - * beast can only ACCESS common fields. It is best just - * to access signature and version numbers. - */ + * beast can only ACCESS common fields. It is best just + * to access signature and version numbers. + */ zvlBeastPForV = (PersistentZlssVolumeLocator_s *)storeBuffer; if ( zvlBeastPForV->PZVL_signature != ZVL_PZVL_S_SIGNATURE ) @@ -3816,8 +3810,8 @@ STATIC BYTE *ZVL_ZlssUnpack( zvlBeast->ZVL_p.PZVL_volumeIDOriginal = zvlBeastP2Dot0->PZVL_2Dot0_volumeIDOriginal; bzero( zvlBeast->ZVL_p.PZVL_reserved, sizeof(zvlBeast->ZVL_p.PZVL_reserved) ); /* Note that name gets truncated down to 64 unicode characters - * including a NULL. - */ + * including a NULL. + */ memcpy( zvlBeast->ZVL_p.PZVL_volumeName, zvlBeastP2Dot0->PZVL_2Dot0_volumeName, sizeof( zvlBeast->ZVL_p.PZVL_volumeName ) - 1); @@ -3828,8 +3822,8 @@ STATIC BYTE *ZVL_ZlssUnpack( zvlBeastP2Dot0->PZVL_2Dot0_volumeNameOriginal, sizeof( zvlBeast->ZVL_p.PZVL_volumeNameOriginal ) - 1); /* Note that name gets truncated down to 64 unicode characters - * including a NULL. - */ + * including a NULL. + */ zvlBeast->ZVL_p.PZVL_volumeNameOriginal[sizeof(zvlBeast->ZVL_p.PZVL_volumeNameOriginal)-1] = 0; zvlBeast->ZVL_p.PZVL_errno = zvlBeastP2Dot0->PZVL_2Dot0_errno; memcpy( zvlBeast->ZVL_p.PZVL_errnoSetter, zvlBeastP2Dot0->PZVL_2Dot0_errnoSetter, 48 ); @@ -3837,11 +3831,11 @@ STATIC BYTE *ZVL_ZlssUnpack( zvlBeast->ZVL_p.PZVL_purgeTimeLastStart = zvlBeastP2Dot0->PZVL_2Dot0_purgeTimeLastStart; zvlBeast->ZVL_p.PZVL_purgeTimeLastEnd = zvlBeastP2Dot0->PZVL_2Dot0_purgeTimeLastEnd; zvlBeast->ZVL_p.PZVL_purgeLogBlocks = zvlBeastP2Dot0->PZVL_2Dot0_purgeLogBlocks; - zvlBeast->ZVL_p.PZVL_lastZidTruncated = zvlBeastP2Dot0->PZVL_2Dot0_lastZidTruncated; + zvlBeast->ZVL_p.PZVL_lastZidTruncated = zvlBeastP2Dot0->PZVL_2Dot0_lastZidTruncated; /** - * Initialize the NEW fields that where added to - * the ZLV Beast from version 2.00 to 3.00. - */ + * Initialize the NEW fields that where added to + * the ZLV Beast from version 2.00 to 3.00. + */ zvlBeast->ZVL_p.PZVL_stateSnapshot = 0; zvlBeast->ZVL_p.PZVL_snapshotID = zINVALID_GUID; zvlBeast->ZVL_p.PZVL_volumeIDSnapshot = zINVALID_GUID; @@ -3916,7 +3910,7 @@ STATIC BYTE *ZVL_ZlssUnpack( } /* End of ZVL_ZlssUnpack */ /**************************************************************************** - * ZLSS volume locator beast constructor + * ZLSS volume locator beast constructor *****************************************************************************/ STATIC STATUS ZVL_Construct( GeneralMsg_s *genMsg, @@ -3930,21 +3924,21 @@ STATIC STATUS ZVL_Construct( zvlBeast->ZVL_purgeThreadID = (ADDR)0; zvlBeast->ZVL_deleteStateChangeTime = 0; - /* By setting to current supported value we prevent + /* By setting to current supported value we prevent ZLSSVOL_LV_MakeZVLUpgradePersistent() from thinking we did an upgrade at LV create time. */ zvlBeast->ZVL_UnpackVersionMajor = ZVL_PZVL_VM_MAJOR; zvlBeast->ZVL_UnpackVersionMinor = ZVL_PZVL_VM_MINOR; /* We set up this fields here because when a - * ZVL is created via the common layer we do - * not get a chance to update until after the commnon - * layer has done a force beast write. Therefore, - * we like to have these next field filled in - * with useful information. Although, I do not - * like the fact that we have a PZVL_state that - * indicates we should delete the LV. - */ + * ZVL is created via the common layer we do + * not get a chance to update until after the commnon + * layer has done a force beast write. Therefore, + * we like to have these next field filled in + * with useful information. Although, I do not + * like the fact that we have a PZVL_state that + * indicates we should delete the LV. + */ zvlBeast->ZVL_p.PZVL_volumeID = zINVALID_GUID; /* Does a structure copy */ zvlBeast->ZVL_p.PZVL_internalID = zINVALID_GUID; /* Does a structure copy */ zvlBeast->ZVL_p.PZVL_loggedVolumeDataBlk = INVALID_BLK; @@ -3957,7 +3951,7 @@ STATIC STATUS ZVL_Construct( } /**************************************************************************** - * ZLSS volume locator beast destructor + * ZLSS volume locator beast destructor *****************************************************************************/ STATIC void ZVL_Destruct( void *zvlBeast_LX) @@ -3970,22 +3964,22 @@ STATIC void ZVL_Destruct( *---------------------------------------------------------------------------*/ LSSSpecificPackUnpackOps_s ZVL_lssOps[] = { - /* - * State on entry - * - * beastLatch - * PackedSize Shared(Owned) - * Pack Shared(Owned) - * Unpack None - * - * Requirements placed on code - * - * Synchronous Non-Blocking - * PackedSize Yes Yes - * Pack Yes Yes - * Unpack Yes No - * - */ + /* + * State on entry + * + * beastLatch + * PackedSize Shared(Owned) + * Pack Shared(Owned) + * Unpack None + * + * Requirements placed on code + * + * Synchronous Non-Blocking + * PackedSize Yes Yes + * Pack Yes Yes + * Unpack Yes No + * + */ {zLSS_ID_ZLSS,ZVL_ZlssPackedSize,ZVL_ZlssPack,NULL,ZVL_ZlssUnpack}, {zLSS_ID_INVALID} @@ -4104,7 +4098,7 @@ STATUS ZFSVOL_VOL_MakeVolumeFreeSpace( // zASSERT( poolVolume != NULL ); // status = ZLSSVOL_LV_LoadAll( genMsg, poolVolume, verbose, FALSE, FALSE); // return( status ); -// +// //} /* End of ZLSSVOL_LV_LoadAll2() */ #endif @@ -4171,7 +4165,7 @@ typedef struct { #endif if ( !cvsLatched ) { - X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); } if ( zlssPool->ZLSSPOOLstate == zVOLSTATE_ACTIVE ) { /* We only work if the pool is active ACTIVE state. */ @@ -4186,7 +4180,7 @@ typedef struct { status = COMN_GetNameFromBeast( genMsg, (NamedBeast_s *)poolVolume, // cnt zFNU_FIRST_PARENT, - zNSPACE_LONG, NELEMS(as->containerVolumeName), + zNSPACE_LONG, NELEMS(as->containerVolumeName), as->containerVolumeName, NULL); UNX_LATCH( &poolVolume->ZFSPOOLbeastLatch ); if ( status != zOK ) @@ -4232,8 +4226,8 @@ typedef struct { volume = COMN_VolumeNameLookup( genMsg,zvlBeast->ZVL_p.PZVL_volumeName,FALSE,NULL); if (volume != NULL) { /* Volume already loaded so skip loading again. Although, - * we have to handle the 'activate' flag. - */ + * we have to handle the 'activate' flag. + */ #if NSS_DEBUG IS_ENABLED DBG_ScreenAPrintf( "ZLSS.Greg.Pool.Volume", WHERE, LRED, MSGNot("Logical Volume \"%U\" zid=%u ALREADY LOADED\n"),zvlBeast->ZVL_p.PZVL_volumeName,(unsigned int)(((RootBeast_s *)zvlBeast)->zid) ); @@ -4259,8 +4253,8 @@ typedef struct { ZLSSVOL_LVD_DeleteListAddAndInit( dqi, zvlBeast, zVolume ); } /** Note we ignore out of memory errors. The - * LV will just not get on the dqi. - */ + * LV will just not get on the dqi. + */ } } else @@ -4342,7 +4336,7 @@ NoMoreLogicalVolumes2: } if ( !cvsLatched ) { - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); } free( as ); return( status ); @@ -4355,7 +4349,7 @@ NoMoreLogicalVolumes2: * * Notes - * Nice to have for debug. Can be used to list all the LVs of a pool. - * + * * Implements 'NSS /LVScan=poolName' */ @@ -4409,7 +4403,7 @@ STATUS doChangePoolState( NINT mode; NINT includeType; GeneralMsg_s genMsg; - + MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); mode = COMN_ChangeStateCommandLineSwitches(); @@ -4431,7 +4425,7 @@ STATUS doChangePoolState( " damage might occur. Pool state not changed. Suggest use of \n" " /OverrideType=SHARED,QUESTIONS\n", 000)); MPKNSS_UNLOCK(); - return zOK; + return zOK; } } @@ -4459,7 +4453,7 @@ STATUS doChangePoolState( // GeneralMsg_s genMsg; // NINT includeType; // NINT mode; -// +// // MPKNSS_LOCK(); // COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); // @@ -4477,7 +4471,7 @@ STATUS doChangePoolState( // } // MPKNSS_UNLOCK(); // return zOK; -//} +//} #endif /* @@ -4495,13 +4489,13 @@ void ZLSSPOOL_InitLPDB( zASSERT( LB_GUIDValidate( &zlssPool->ZLSSPOOLmInternalID ) ); zASSERT( offsetof( LoggedPersistentZlssPool_s, LPZP_reserved ) == 32 ); /* If you hit the above ASSERT be sure to add the item - * that changed the size to the initialization code below. - * Then update the ASSERT - */ + * that changed the size to the initialization code below. + * Then update the ASSERT + */ /***** - * Initialize ALL LoggedPersistentZlssPool_s - *****/ + * Initialize ALL LoggedPersistentZlssPool_s + *****/ zlssPool->ZP_logged.LPZP_magic = ZLSSLOGGEDPOOLINFO_MAGIC; zlssPool->ZP_logged.LPZP_version = ZLSSLOGGEDPOOLINFO_VERSION; zlssPool->ZP_logged.LPZP_lsn = 0; @@ -4510,13 +4504,13 @@ void ZLSSPOOL_InitLPDB( zASSERT( offsetof( LoggedPersistentPool_s, LPP_reserved ) == 32 ); /* If you hit the above ASSERT be sure to add the item - * that changed the size to the initialization code below. - * Then update the ASSERT - */ + * that changed the size to the initialization code below. + * Then update the ASSERT + */ /***** - * Initialize ALL LoggedPersistentPool_s - *****/ + * Initialize ALL LoggedPersistentPool_s + *****/ zlssPool->ZP_Pool.logged.LPP_totalBlocks = totalBlocks; zlssPool->ZP_Pool.logged.LPP_inUseBlocks = totalBlocks; zlssPool->ZP_Pool.logged.LPP_purgeableBlocks = 0; @@ -4524,8 +4518,8 @@ void ZLSSPOOL_InitLPDB( bzero(zlssPool->ZP_Pool.logged.LPP_reserved, sizeof(zlssPool->ZP_Pool.logged.LPP_reserved)); /***** - * Now do some quasi persistent items - *****/ + * Now do some quasi persistent items + *****/ zlssPool->ZP_bookedInUseBlocks = zlssPool->ZLSSPOOLinUseBlocks; // zlssPool->ZP_Pool.supportedFeatures = ZLSSPOOL_SUPPORTED_FEATURES; zASSERT(zlssPool->ZP_Pool.supportedFeatures == ZLSSPOOL_SUPPORTED_FEATURES); @@ -4548,13 +4542,13 @@ void ZLSSPOOL_InitPDB( zASSERT( LB_GUIDValidate( &zlssPool->ZLSSPOOLmInternalID ) ); zASSERT( offsetof( PersistentZlssPool_s, PZP_reserved ) == 80 ); /* If you hit the above ASSERT be sure to add the item - * that changed the size to the initialization code below. - * Then update the ASSERT - */ + * that changed the size to the initialization code below. + * Then update the ASSERT + */ /***** - * Initialize ALL PersistentZlssPool_s - *****/ + * Initialize ALL PersistentZlssPool_s + *****/ zlssPool->ZP_p.PZP_magic = ZLSSPOOLINFO_MAGIC; zlssPool->ZP_p.PZP_version = ZLSSPOOLINFO_VERSION; zlssPool->ZP_p.PZP_checksum = 0; @@ -4578,13 +4572,13 @@ void ZLSSPOOL_InitPDB( zASSERT( offsetof( PersistentPool_s, PP_reserved ) == 104 ); /* If you hit the above ASSERT be sure to add the item - * that changed the size to the initialization code below. - * Then update the ASSERT - */ + * that changed the size to the initialization code below. + * Then update the ASSERT + */ /***** - * Initialize ALL PersistentVolume_s - *****/ + * Initialize ALL PersistentVolume_s + *****/ zlssPool->ZP_Pool.p.PP_blockSize = (1 << blockShift); zlssPool->ZP_Pool.p.PP_blockShift = blockShift; //#error we pass in rebuild count in VDB routine why not here? @@ -4599,10 +4593,10 @@ void ZLSSPOOL_InitPDB( zlssPool->ZP_Pool.p.PP_stateAttributes = 0; zlssPool->ZP_Pool.p.PP_freeToUse = 0; /* Persistent elsewhere bits are stored by others. For example, - * the shared bit is stored by the media manager in device - * objects. We inherit this bit on create/rebuild so - * set the bit based on passed in flag. - */ + * the shared bit is stored by the media manager in device + * objects. We inherit this bit on create/rebuild so + * set the bit based on passed in flag. + */ zlssPool->ZP_Pool.p.PP_enabledFeatures = (persistentElsewhere | ZLSSPOOL_DEFAULT_ENABLED_FEATURES); zlssPool->ZP_Pool.p.PP_mediaFormatMajor = 0; zlssPool->ZP_Pool.p.PP_mediaFormatMinor = 0; @@ -4674,8 +4668,8 @@ LONG ZLSSPOOL_CalculateChecksum( LONG *buffer, NINT numberOfLONGs ) /* * ZLSSPOOL_ReadPersistentPoolData() - - * - * Reads the persistent pool data block. Called by + * + * Reads the persistent pool data block. Called by * ZFSPOOL_LoadPersistentPool() as part of POOL activate. I.E. the * persistent fields of the Pool_s are only valid when a pool is * ACTIVE. @@ -4695,7 +4689,7 @@ STATUS ZLSSPOOL_ReadPersistentPoolData( LONG checksum; ZlssPoolBlock_s *block; ZlssLoggedPoolBlock_s *loggedBlock; - ZfsPool_s *poolVolume; + ZfsPool_s *poolVolume; ENTER(TZPOOL, ZLSSPOOL_ReadPersistentPoolData); @@ -4709,14 +4703,14 @@ STATUS ZLSSPOOL_ReadPersistentPoolData( zlssPool->ZLSSPOOLzfsPool,&zlssPool->ZLSSPOOLzfsPool)); blkPDB = zlssPool->ZP_p.PZP_poolDataBlk; /* Get the Logged PDB up front so that when we read the PDB - * we do not overwrite the blk number we use for it. - */ + * we do not overwrite the blk number we use for it. + */ blkLPDB = zlssPool->ZP_p.PZP_loggedPoolDataBlk; zASSERT( (blkPDB != 0) ); /* We do all reads on the Pool's Internal volume because - * Low level ZLSS I/O routines like volumes more than - * pools. - */ + * Low level ZLSS I/O routines like volumes more than + * pools. + */ READBLK_IO_MSG(iomsg,poolVolume,blkPDB,CACHE_READ); SET_DEBUG_ID(iomsg, 55+100); buffer = ZFS_ReadPoolBlk(genMsg,&iomsg); @@ -4730,16 +4724,16 @@ STATUS ZLSSPOOL_ReadPersistentPoolData( { persistentElsewhere = zlssPool->ZLSSPOOLenabledFeatures & ZLSSPOOL_PERSISTENT_ELSEWHERE; ZLSSPOOL_InitPDB(zlssPool, - poolVolume->storagepool->pooltotalblocks, - poolVolume->storagepool->poolblkshift, - persistentElsewhere, - ZP_REPAIRFLAGS_MANUAL_POOL_LOAD); + poolVolume->storagepool->pooltotalblocks, + poolVolume->storagepool->poolblkshift, + persistentElsewhere, + ZP_REPAIRFLAGS_MANUAL_POOL_LOAD); } else { zlssPool->ZP_p.PZP_rebuildUTCTime = GetUTCTime(); } - ClearErrno(genMsg); + ClearErrno(genMsg); goto ReadLoggedBlock; } else @@ -4753,10 +4747,10 @@ STATUS ZLSSPOOL_ReadPersistentPoolData( } block = ((ZlssPoolBlock_s *)buffer->pBuf.data); /* The shared bit is stored by the media manager in device - * objects. We use this bit instead of want we have stored. - * Since this bit is set at load/init/rebuild time we save - * off and then set back after our 'unpack' - */ + * objects. We use this bit instead of want we have stored. + * Since this bit is set at load/init/rebuild time we save + * off and then set back after our 'unpack' + */ persistentElsewhere = zlssPool->ZLSSPOOLenabledFeatures & ZLSSPOOL_PERSISTENT_ELSEWHERE; /* This is the UNPACK code for a ZLSS Pool */ memcpy( &zlssPool->ZP_p, &block->ZPB_zlssPool, sizeof(block->ZPB_zlssPool) ); @@ -4764,11 +4758,11 @@ STATUS ZLSSPOOL_ReadPersistentPoolData( memcpy( &zlssPool->ZLSSPOOLpool.p, &block->ZPB_pool, sizeof(block->ZPB_pool) ); zASSERT( sizeof(*block) == ALIGN( sizeof( *block ), 4 )); - zASSERT( sizeof(ZlssLoggedPoolBlock_s) == + zASSERT( sizeof(ZlssLoggedPoolBlock_s) == ALIGN( sizeof( ZlssLoggedPoolBlock_s ), 4 )); - checksum = ZLSSPOOL_CalculateChecksum( (LONG *)block, sizeof(*block)/4 ); - + checksum = ZLSSPOOL_CalculateChecksum( (LONG *)block, sizeof(*block)/4 ); + zlssPool->ZLSSPOOLenabledFeatures &= ~(ZLSSPOOL_PERSISTENT_ELSEWHERE); zlssPool->ZLSSPOOLenabledFeatures |= persistentElsewhere; @@ -4786,10 +4780,10 @@ STATUS ZLSSPOOL_ReadPersistentPoolData( { persistentElsewhere = zlssPool->ZLSSPOOLenabledFeatures & ZLSSPOOL_PERSISTENT_ELSEWHERE; ZLSSPOOL_InitPDB(zlssPool, - poolVolume->storagepool->pooltotalblocks, - poolVolume->storagepool->poolblkshift, - persistentElsewhere, - ZP_REPAIRFLAGS_MANUAL_POOL_LOAD); + poolVolume->storagepool->pooltotalblocks, + poolVolume->storagepool->poolblkshift, + persistentElsewhere, + ZP_REPAIRFLAGS_MANUAL_POOL_LOAD); } else { @@ -4808,13 +4802,13 @@ STATUS ZLSSPOOL_ReadPersistentPoolData( } } /* The pool data block checked out OK, so clear repair's - * flag. - */ + * flag. + */ poolVolume->ZP_RepairFlags &= ~ZP_REPAIRFLAGS_REBUILD_POOL_DATA_BLOCKS; /* - * Read in the 'logged' pool data from its block. - */ + * Read in the 'logged' pool data from its block. + */ ReadLoggedBlock: DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT, (LRED,MSGNot("ZLSS Pool's Log blk is %lu(0x%lx)\n"), @@ -4832,8 +4826,8 @@ ReadLoggedBlock: if(poolVolume->ZP_RepairFlags & ZP_REPAIRFLAGS_REBUILD_POOL_LDATA_BLOCKS ) { ZLSSPOOL_InitLPDB(zlssPool, - poolVolume->storagepool->pooltotalblocks, - ZP_REPAIRFLAGS_MANUAL_POOL_LOAD); + poolVolume->storagepool->pooltotalblocks, + ZP_REPAIRFLAGS_MANUAL_POOL_LOAD); } goto CleanUpAndReturn; } @@ -4863,8 +4857,8 @@ ReadLoggedBlock: if(poolVolume->ZP_RepairFlags & ZP_REPAIRFLAGS_REBUILD_POOL_LDATA_BLOCKS ) { ZLSSPOOL_InitLPDB(zlssPool, - poolVolume->storagepool->pooltotalblocks, - ZP_REPAIRFLAGS_MANUAL_POOL_LOAD); + poolVolume->storagepool->pooltotalblocks, + ZP_REPAIRFLAGS_MANUAL_POOL_LOAD); } goto CleanUpAndReturn; } @@ -4877,30 +4871,30 @@ ReadLoggedBlock: } /* The logged pool data block checked out OK, so clear repair's - * flag. - */ + * flag. + */ poolVolume->ZP_RepairFlags &= ~ZP_REPAIRFLAGS_REBUILD_POOL_LDATA_BLOCKS; CleanUpAndReturn: /** - * Update items that are directly based on persistent items. - * These updates are done here verses ACTIVATE calls because - * rebuild does not call ACTIVATE functions. - */ + * Update items that are directly based on persistent items. + * These updates are done here verses ACTIVATE calls because + * rebuild does not call ACTIVATE functions. + */ zlssPool->ZLSSPOOLbookedInUseBlocks = zlssPool->ZLSSPOOLinUseBlocks; #if NSS_DEBUG IS_ENABLED /*** Here we are just setting the enabled features to - *** the default because they exist in six-pack as - *** random bits (from when we stored zATTR bits). - *** We are doing this so no media change on SIx-Pack servers - *** although it means that features are not persistent - *** until Feb 6, 2001 (UTC time = 0x3a800000). - ***/ + *** the default because they exist in six-pack as + *** random bits (from when we stored zATTR bits). + *** We are doing this so no media change on SIx-Pack servers + *** although it means that features are not persistent + *** until Feb 6, 2001 (UTC time = 0x3a800000). + ***/ DBG_DebugPrintf(CYAN,"%s ZLSSPOOLenabledFeatures is 0x%Lx\n",WHERE,zlssPool->ZLSSPOOLenabledFeatures); /*** Now that Beta II snapshot has been taken I am removing - *** the code to upgrade attributes to features. - ***/ + *** the code to upgrade attributes to features. + ***/ // if ( GetUTCTime() < 0x3a800000 ) // { // if ( (zlssPool->ZLSSPOOLenabledFeatures & ~zPOOL_FEATURE_LIST) != 0 ) @@ -4912,9 +4906,9 @@ CleanUpAndReturn: #if NSS_ASSERT IS_ENABLED /* Check that a illegal bit is not on. Either the pool - * is corrupt or someone added a new feature - * without updating the define zPOOL_FEATURE_LIST. - */ + * is corrupt or someone added a new feature + * without updating the define zPOOL_FEATURE_LIST. + */ if ( (zlssPool->ZLSSPOOLenabledFeatures & ~zPOOL_FEATURE_LIST) != 0 ) { zASSERT( "This pool has an illegal feature set. Did someone add a feature without putting it into the ZPOOL_FEATURE_LIST define?(O.K. to do a go)" == NULL ); @@ -4931,9 +4925,9 @@ CleanUpAndReturn: } #endif /* The OFFICIAL keeper of the persistent PDB and LPDB - * is the superblock therefore reset the values back - * to what came in. - */ + * is the superblock therefore reset the values back + * to what came in. + */ zlssPool->ZP_p.PZP_poolDataBlk = blkPDB; zlssPool->ZP_p.PZP_loggedPoolDataBlk = blkLPDB; @@ -4976,17 +4970,17 @@ void ZLSSPOOL_WritePersistentPoolData( /* writing and set persistent volume information */ blk = zlssPool->ZP_p.PZP_poolDataBlk; /* If the block is zero then we must not write this information. - * Generally, this means that the persistent information has - * not been initialized (or read) in yet. - */ + * Generally, this means that the persistent information has + * not been initialized (or read) in yet. + */ if (blk != 0 && blk != INVALID_BLK) { LONG checksum; ZlssPoolBlock_s *block; /* Non-logged blocked */ - + /* This can be a CACHE_WRITE because we update all of the - * portion of the block we use. - */ + * portion of the block we use. + */ READBLK_IO_MSG(iomsg,poolVolume,blk,CACHE_UPDATE); SET_DEBUG_ID(iomsg, 39+100); buffer = ZFS_ReadPoolBlk(&genMsg,&iomsg); @@ -5007,21 +5001,21 @@ void ZLSSPOOL_WritePersistentPoolData( memcpy( &block->ZPB_pool, &zlssPool->ZLSSPOOLpool.p, sizeof(block->ZPB_pool) ); /* Calculate the checksum in the BLOCK because all - * of the non-logged data is next to each other. - */ + * of the non-logged data is next to each other. + */ block->ZPB_zlssPool.PZP_checksum = 0; - checksum = ZLSSPOOL_CalculateChecksum((LONG*)block,sizeof(*block)/4 ); + checksum = ZLSSPOOL_CalculateChecksum((LONG*)block,sizeof(*block)/4 ); block->ZPB_zlssPool.PZP_checksum = 0 - checksum; /* This is not really required because the logged - * write uses the VolumeData buffer and not in - * memory copy for its writes. I set the IN-MEMORY - * checksum just because it feels right! - */ + * write uses the VolumeData buffer and not in + * memory copy for its writes. I set the IN-MEMORY + * checksum just because it feels right! + */ zlssPool->ZP_p.PZP_checksum = 0 - checksum; /* Wait for this buffer to be synchronously written before we - * return from here - */ + * return from here + */ initAgent( &waitAgent, NULL, "Write Pool Data Agent" ); bind( &waitAgent, &buffer->agent ); CACHE_DIRTY_RELEASE( buffer ); @@ -5075,14 +5069,14 @@ STATIC void ZLSSPOOL_VOL_WritePoolLoggedData( blk = zlssPool->ZP_p.PZP_loggedPoolDataBlk; /* If the block is zero then we must not write this information. - * Generally, this means that the persistent information has - * not been initialized (or read) in yet. - */ + * Generally, this means that the persistent information has + * not been initialized (or read) in yet. + */ if (blk != 0 && blk != INVALID_BLK) { /* This can be a CACHE_WRITE because we update all of the - * portion of the block we use. - */ + * portion of the block we use. + */ READBLK_IO_MSG(iomsg,poolVolume,blk,CACHE_WRITE); SET_DEBUG_ID(iomsg, 54+100); buffer = ZFS_ReadPoolBlk(&genMsg,&iomsg); @@ -5117,10 +5111,10 @@ STATIC void ZLSSPOOL_VOL_WritePoolLoggedData( ZLOG_TEST_REDO((ZfsXaction_s *)xaction); ZLOG_ReleaseRecord((ZfsXaction_s *)xaction); /* Update block copy - watied until now because the - * when LOG_TEST is enabled the release above runs - * special debug code that requires the old copy - * of the LSN. - */ + * when LOG_TEST is enabled the release above runs + * special debug code that requires the old copy + * of the LSN. + */ #if LOG_TEST IS_ENABLED zlssPool->ZP_logged.LPZP_lsn = savedLsn; // Waited because REDO/UNDO test pokes block->ZLPB_zlssPool.LPZP_lsn = savedLsn; @@ -5129,10 +5123,10 @@ STATIC void ZLSSPOOL_VOL_WritePoolLoggedData( #endif /* #if 0 */ } /* This takes the memory copy of active data that is logged - * in the Volume_s and places into the volume's data block. - * Note that we do not copy the reserved area. This area - * is initially set to zero in pool init. - */ + * in the Volume_s and places into the volume's data block. + * Note that we do not copy the reserved area. This area + * is initially set to zero in pool init. + */ /* This is the PACK code for a ZLSS Pool (logged data) */ memcpy( &block->ZLPB_zlssPool, &zlssPool->ZP_logged, @@ -5140,7 +5134,7 @@ STATIC void ZLSSPOOL_VOL_WritePoolLoggedData( sizeof(zlssPool->ZP_logged.LPZP_reserved) ); /* This is the PACK code for a Pool (logged data) */ memcpy(&block->ZLPB_pool, &zlssPool->ZLSSPOOLpool.logged, - sizeof(LoggedPersistentPool_s) - + sizeof(LoggedPersistentPool_s) - sizeof(zlssPool->ZLSSPOOLpool.logged.LPP_reserved) ); // DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(MAGENTA, // MSGNot("At write with in use blocks set to %Ld\n"), @@ -5152,7 +5146,7 @@ STATIC void ZLSSPOOL_VOL_WritePoolLoggedData( /* - * ZLSSPOOL_RecoveryPoolInfo() - + * ZLSSPOOL_RecoveryPoolInfo() - * REDO/UNDO routine for the pool's Logged Pool Data Block (LPDB). * * Notes - @@ -5178,10 +5172,10 @@ STATUS ZLSSPOOL_RecoveryPoolInfo( #if 0 /* Was going to share the Volume's Log Record and then just - * do the same 'action' to the pool. This will not work because - * the previous LSN of the volume block may not be the previous LSN - * of the pool's logged block. - */ + * do the same 'action' to the pool. This will not work because + * the previous LSN of the volume block may not be the previous LSN + * of the pool's logged block. + */ zASSERT( pool->ZFSPOOLvol.v_pool != NULL ); zlssPool = (ZlssPool_s *)(pool->ZFSPOOLvol.v_pool); zASSERT( zlssPool->ZP_p.PZP_loggedPoolDataBlk != NULL && @@ -5191,8 +5185,8 @@ STATUS ZLSSPOOL_RecoveryPoolInfo( poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); if (ZLOG_VALID_BLOCK(poolBlks[0])) { /* This MUST be a CACHE_UPDATE because we only update part of - * the block we use. - */ + * the block we use. + */ READBLK_IO_MSG(iomsg, pool, poolBlks[0].blkNum, CACHE_UPDATE) SET_DEBUG_ID(iomsg, 0); if ((buffer = ZFS_ReadPoolBlk(genMsg, &iomsg)) == NULL) @@ -5223,16 +5217,16 @@ STATUS ZLSSPOOL_RecoveryPoolInfo( { block->ZLPB_pool.LPP_inUseBlocks += delta; /* Even though we have loaded the Pool's persistent - * VDB or LVDB we do not need to keep 'book' value - * in sync. This is because ZLOG will RE-LOAD - * the persistent information after a successful - * REDO/UNDO. This is already a requirement because - * all of our REDO/UNDO code in this routine only - * updates the physical block and not the information - * stored in the Pool's beast. Note that the Pool - * and ZLOG beasts are the only beasts 'loaded' when - * doing REDO/UNDO. - */ + * VDB or LVDB we do not need to keep 'book' value + * in sync. This is because ZLOG will RE-LOAD + * the persistent information after a successful + * REDO/UNDO. This is already a requirement because + * all of our REDO/UNDO code in this routine only + * updates the physical block and not the information + * stored in the Pool's beast. Note that the Pool + * and ZLOG beasts are the only beasts 'loaded' when + * doing REDO/UNDO. + */ /* pool->ZFSPOOLbookedInUseBlocks += delta; */ break; } @@ -5295,7 +5289,7 @@ typedef struct ZLSSVOL_ZVL_RenameInfo_t { */ void ZLSSVOL_LV_ZVLDeleteThread( - FsmLite_s *fsmLite, + FsmLite_s *fsmLite, ZLSSVOL_ZVL_DeleteInfo_t *di ) { @@ -5303,7 +5297,7 @@ void ZLSSVOL_LV_ZVLDeleteThread( STATUS status; COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); - status = ZLSSVOL_LV_ZVLDelete( &dummyGenMsg, &di->DI_zVolumeName[0], + status = ZLSSVOL_LV_ZVLDelete( &dummyGenMsg, &di->DI_zVolumeName[0], &di->DI_containerVolumeName[0] ); if ( status != zOK ) { @@ -5322,7 +5316,7 @@ void ZLSSVOL_LV_ZVLDeleteThread( */ void ZLSSVOL_LV_ZVLRenameThread( - FsmLite_s *fsmLite, + FsmLite_s *fsmLite, ZLSSVOL_ZVL_RenameInfo_t *ri ) { @@ -5378,7 +5372,7 @@ STATUS ZLSSVOL_LV_ZVLRenameAsync( MSGNot("ZLSSVOL_LV_ZVLRenameAsync"), ZLSSVOL_LV_ZVLRenameAsyncInstance++ ); - WORK_Schedule( &ri->RI_fsmLite, (voidfunc_t)ZLSSVOL_LV_ZVLRenameThread, (ADDR)ri); + WORK_Schedule( &ri->RI_fsmLite, ZLSSVOL_LV_ZVLRenameThread, (ADDR)ri); return( zOK ); } /* End of ZLSSVOL_LV_ZVLRenameAsync() */ @@ -5416,7 +5410,7 @@ STATUS ZLSSVOL_LV_ZVLDeleteAsync( MSGNot("ZLSSVOL_LV_ZVLDeleteAsync"), ZLSSVOL_LV_ZVLDeleteAsyncInstance++ ); - WORK_Schedule( &di->DI_fsmLite, (voidfunc_t)ZLSSVOL_LV_ZVLDeleteThread, (ADDR)di); + WORK_Schedule( &di->DI_fsmLite, ZLSSVOL_LV_ZVLDeleteThread, (ADDR)di); return( zOK ); } /* End of ZLSSVOL_LV_ZVLDeleteAsync() */ @@ -5799,7 +5793,7 @@ File_s *ZVL_Create( X_LATCH( &file->FILEbeastLatch ); STACK_FREE(); return file; - + } /* End of ZVL_Create() */ @@ -5836,7 +5830,7 @@ STATUS ZVL_Delete( COMN_CleanupNameMsg( genMsg, &aStack->nameMsg ); STACK_FREE(); return( status ); - + } /* End of ZVL_Delete() */ @@ -5876,8 +5870,8 @@ STATUS ZLSSVOL_LV_RemoveDICIRI( GeneralMsg_s *genMsg, unicode_t *fullName ) if (status != 0) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, - MSGNot("ERROR: ZLSSVOL_LV_RemoveDICIRI() Status=%d\n"), - GetErrno( genMsg ) )); + MSGNot("ERROR: ZLSSVOL_LV_RemoveDICIRI() Status=%d\n"), + GetErrno( genMsg ) )); } #endif STACK_FREE(); @@ -5919,8 +5913,8 @@ STATUS ZLSSVOL_LV_RemoveRI( GeneralMsg_s *genMsg, unicode_t *fullName ) if (status != 0) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, - MSGNot("ERROR: ZLSSVOL_LV_RemoveRI() Status=%d\n"), - GetErrno( genMsg ) )); + MSGNot("ERROR: ZLSSVOL_LV_RemoveRI() Status=%d\n"), + GetErrno( genMsg ) )); } #endif STACK_FREE(); @@ -5963,8 +5957,8 @@ STATUS ZLSSVOL_LV_AddRI( if (status != 0) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, - MSGNot("ERROR: ZLSSVOL_LV_AddRI() Status=%d\n"), - GetErrno( genMsg ) )); + MSGNot("ERROR: ZLSSVOL_LV_AddRI() Status=%d\n"), + GetErrno( genMsg ) )); } #endif STACK_FREE(); @@ -6027,7 +6021,7 @@ typedef struct ZLSSVOL_LVR_RenameAPINames_t { * NWSA uses this information to change the name in the NetWare volume * array. * - * Notes - + * Notes - * ZLSS can rename any volume as long as the POOL is active. This * is because the volumes name is stored in the ZVL Beast that is in the * pool. @@ -6057,9 +6051,9 @@ STATUS ZLSSVOL_LVR_RenameAPI( #endif COMN_EXCLUDE_INTERNAL_VOLUMES( genMsg ); /* Verify that volume exists. Note that we will not find volumes - * that are already being deleted because they are marked INTERNAL - * and we do not have the INTERNAL bit set in the genMsg - */ + * that are already being deleted because they are marked INTERNAL + * and we do not have the INTERNAL bit set in the genMsg + */ zVolume = (ZfsVolume_s *)COMN_VolumeNameLookup(genMsg,oldVolumeName,FALSE,NULL); if ( zVolume == NULL ) { @@ -6090,13 +6084,13 @@ STATUS ZLSSVOL_LVR_RenameAPI( return( zFAILURE ); } /*** - *** Get the name of the poolVolume. This is used by several APIs - *** that need to be called later. - ***/ + *** Get the name of the poolVolume. This is used by several APIs + *** that need to be called later. + ***/ X_LATCH( &poolVolume->ZFSPOOLbeastLatch); status = COMN_GetNameFromBeast( genMsg, (NamedBeast_s *)poolVolume, // cnt zFNU_FIRST_PARENT, - zNSPACE_LONG, NELEMS(names->containerVolumeName), + zNSPACE_LONG, NELEMS(names->containerVolumeName), names->containerVolumeName, NULL); UNX_LATCH( &poolVolume->ZFSPOOLbeastLatch ); if ( status != zOK ) @@ -6106,26 +6100,26 @@ STATUS ZLSSVOL_LVR_RenameAPI( return( zFAILURE ); } - X_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + X_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); /*** Renames the ZVL Beast and the volume name stored - *** in the ZVL Beast. This is the persistent names - *** of the volume. - ***/ + *** in the ZVL Beast. This is the persistent names + *** of the volume. + ***/ status = ZLSSVOL_LV_ZVLRename( genMsg, oldVolumeName, - newVolumeName, names->containerVolumeName ); + newVolumeName, names->containerVolumeName ); if ( status != zOK ) { - UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); COMN_Release( &zVolume ); free( names ); return( zFAILURE ); } /*** Renames the volume object, ADMIN files. Then tell the - *** SAs that the volume was renamed. The NWSA changes the - *** name of the volume in the NetWare volume tables. All - *** of these actions are done by VOL_Rename(). - ***/ + *** SAs that the volume was renamed. The NWSA changes the + *** name of the volume in the NetWare volume tables. All + *** of these actions are done by VOL_Rename(). + ***/ status = VOL_Rename( genMsg, &zVolume->ZLSSVOLvol, oldVolumeName, newVolumeName ); @@ -6134,18 +6128,18 @@ STATUS ZLSSVOL_LVR_RenameAPI( status1 = ZLSSVOL_LV_ZVLRename( &dummyGenMsg, newVolumeName, oldVolumeName, names->containerVolumeName ); zASSERT( status1 != zOK ); /* If we get an error here then the - * volume will be renamed the next time - * we re-load it even though we are - * returning an error on rename. - */ + * volume will be renamed the next time + * we re-load it even though we are + * returning an error on rename. + */ ClearErrno( &dummyGenMsg ); } - UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); COMN_Release( &zVolume ); free( names ); return( status ); -} /* End of ZLSSVOL_LVR_RenameAPI() */ +} /* End of ZLSSVOL_LVR_RenameAPI() */ /* @@ -6198,7 +6192,7 @@ STATUS ZLSSVOL_LV_CreateAPI( zfsPool->ZFSPOOLroot.useCount++; status = COMN_GetNameFromBeast( genMsg, (NamedBeast_s *)zfsPool, // cnt zFNU_FIRST_PARENT, - zNSPACE_LONG, NELEMS(aStack->poolsIVName), + zNSPACE_LONG, NELEMS(aStack->poolsIVName), aStack->poolsIVName, NULL); UNX_LATCH( &zfsPool->ZFSPOOLbeastLatch ); if ( status != zOK ) @@ -6210,7 +6204,7 @@ STATUS ZLSSVOL_LV_CreateAPI( } /* FixFixFix(LV,ACI,11) latching order problem. */ - X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); if ( zfsPool->ZFSPOOLstate == zVOLSTATE_ACTIVE ) { /* We only work if the pool is ACTIVE. */ status = ZLSSVOL_LV_Create( genMsg, @@ -6223,12 +6217,12 @@ STATUS ZLSSVOL_LV_CreateAPI( NULL, FALSE ); /* The (QUAD) cast works here only because, even though - * total blocks is a signed value, it can not be negative. - */ + * total blocks is a signed value, it can not be negative. + */ } else { - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); COMN_Release( &zfsPool ); COMN_Release( &zlssPool ); SetErrno( genMsg, zERR_VOLUME_NOT_IN_ACTIVE_STATE ); @@ -6246,14 +6240,14 @@ STATUS ZLSSVOL_LV_CreateAPI( DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, MSGNot("Error %lu while trying to create Logical Volume.\n"), GetErrno(genMsg))); - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); COMN_Release( &zlssPool ); STACK_FREE(); return( zFAILURE ); } zVolume = ZLSSVOL_LV_LoadByName( genMsg, aStack->poolsIVName, volumeName, zlssPool, NULL); - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); if ( zVolume == NULL ) { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, @@ -6292,16 +6286,16 @@ STATUS ZLSSVOL_LVD_DeleteActionPause( zASSERT( zlssPool != NULL ); poolVolume = zlssPool->ZLSSPOOLzfsPool; -// X_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// X_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); dqi = zVolume->ZV_dqi; zASSERT( dqi != NULL ); ZLSS_DQI_INUSE( dqi ); zvlBeast = dqi->DQI_zvlBeast; zASSERT( zvlBeast != NULL ); /* Since we own delete list latch we can just use zvlBeast - * without inc use count because it is know to be at least - * two when on its volume is on the LV delete list. - */ + * without inc use count because it is know to be at least + * two when on its volume is on the LV delete list. + */ zASSERT( zvlBeast != NULL ); X_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); @@ -6313,12 +6307,12 @@ STATUS ZLSSVOL_LVD_DeleteActionPause( case ZVL_DS_UNDELETE_ERROR: status = ZLSSVOL_LVD_DeleteStateUpdate( genMsg, zvlBeast, zVolume, ZVL_DS_SALVAGEABLE_PAUSED ); - break; + break; case ZVL_DS_SALVAGEABLE: status = ZLSSVOL_LVD_DeleteStateUpdate( genMsg, zvlBeast, zVolume, ZVL_DS_SALVAGEABLE_PAUSED ); - break; + break; case ZVL_DS_SALVAGEABLE_PAUSED: case ZVL_DS_PURGEING_PAUSED: @@ -6334,7 +6328,7 @@ STATUS ZLSSVOL_LVD_DeleteActionPause( // zVolume->ZV_stopPurge = TRUE; status = ZLSSVOL_LVD_DeleteStateUpdate( genMsg, zvlBeast, zVolume, ZVL_DS_PURGEING_PAUSED ); - break; + break; case ZVL_DS_SALVAGED: case ZVL_DS_UNDELETE: @@ -6352,7 +6346,7 @@ STATUS ZLSSVOL_LVD_DeleteActionPause( UNX_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); ZLSS_DQI_UNUSE( dqi ); -// UNX_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// UNX_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); return( status ); } /* End of ZLSSVOL_LVD_DeleteActionPause() */ @@ -6379,16 +6373,16 @@ STATUS ZLSSVOL_LVD_DeleteActionContinue( zASSERT( zlssPool != NULL ); poolVolume = zlssPool->ZLSSPOOLzfsPool; -// X_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// X_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); dqi = zVolume->ZV_dqi; zASSERT( dqi != NULL ); ZLSS_DQI_INUSE( dqi ); zvlBeast = dqi->DQI_zvlBeast; zASSERT( zvlBeast != NULL ); /* Since we own delete list latch we can just use zvlBeast - * without inc use count because it is know to be at least - * two when on its volume is on the LV delete list. - */ + * without inc use count because it is know to be at least + * two when on its volume is on the LV delete list. + */ zASSERT( zvlBeast != NULL ); X_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); @@ -6412,7 +6406,7 @@ STATUS ZLSSVOL_LVD_DeleteActionContinue( case ZVL_DS_PURGEING_PAUSED: status = ZLSSVOL_LVD_DeleteStateUpdate( genMsg, zvlBeast, zVolume, ZVL_DS_PURGEING ); - break; + break; case ZVL_DS_SALVAGED: case ZVL_DS_UNDELETE: @@ -6429,7 +6423,7 @@ STATUS ZLSSVOL_LVD_DeleteActionContinue( UNX_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); ZLSS_DQI_UNUSE( dqi ); -// UNX_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// UNX_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); return( status ); } /* End of ZLSSVOL_LVD_DeleteActionContinue() */ @@ -6522,7 +6516,7 @@ STATUS ZLSSVOL_LVD_DeleteActionContinue( // COMN_Release( &zVolume ); // return( status ); // -//} /* End of ZLSSVOL_LVD_DeleteActionAPI() */ +//} /* End of ZLSSVOL_LVD_DeleteActionAPI() */ #endif /* ZLSSVOL_LV_GetInfoAPI() - @@ -6558,8 +6552,8 @@ STATUS ZLSSVOL_LV_GetInfoAPI( return( zFAILURE ); } /* Since deleted volumes are marked as INTERNAL we need to - * indicate that we wish to look for internal volumes. - */ + * indicate that we wish to look for internal volumes. + */ COMN_INCLUDE_INTERNAL_VOLUMES( genMsg ); /* Verify that volume exists. */ zVolume = (ZfsVolume_s *)COMN_VolumeNameLookup(genMsg,volumeName,FALSE,NULL); @@ -6584,8 +6578,8 @@ STATUS ZLSSVOL_LV_GetInfoAPI( zlssPool = (ZlssPool_s *)(zVolume->ZFSVOLvol.v_pool); if ( zlssPool == NULL ) { /* Needed as we get called during VOL_BSTNew() before we - * are really ready to be called. - */ + * are really ready to be called. + */ COMN_Release( &zVolume ); SetErrno( genMsg, zERR_NOT_SUPPORTED ); DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT, (LRED, @@ -6697,8 +6691,8 @@ STATUS ZLSSVOL_LV_GetInfoCreated( loc = loc + strlen( loc ); /** - * This is where ZLSS specific TAGS would go. - */ + * This is where ZLSS specific TAGS would go. + */ switch ( zVolume->ZLSSVOLvol.state ) { case zVOLSTATE_MAINTENANCE: @@ -6713,7 +6707,7 @@ STATUS ZLSSVOL_LV_GetInfoCreated( (void)LB_GUIDToString( &zVolume->ZLSSVOLinternalID, retBufLen - (loc - retBuf), loc ); loc = loc + strlen( loc ); - sprintf( loc, MSGNot("\r\n"), + sprintf( loc, MSGNot("\r\n"), TAG_INTERNALVOLUMEID ); loc = loc + strlen( loc ); break; @@ -6729,7 +6723,7 @@ STATUS ZLSSVOL_LV_GetInfoCreated( COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); COMN_INCLUDE_INTERNAL_VOLUMES( &dummyGenMsg ); - (void)COMN_GetVolumeName( &dummyGenMsg, &poolVolume->ZFSPOOLvol, + (void)COMN_GetVolumeName( &dummyGenMsg, &poolVolume->ZFSPOOLvol, aStack->containerVolumeName, NELEMS(aStack->containerVolumeName) ); zvlBeast = ZLSSVOL_LV_ZVLOpen( genMsg, volumeName, @@ -6801,7 +6795,7 @@ STATUS ZLSSVOL_LV_GetInfoCreated( COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); COMN_INCLUDE_INTERNAL_VOLUMES( &dummyGenMsg ); - (void)COMN_GetVolumeName( &dummyGenMsg, &poolVolume->ZFSPOOLvol, + (void)COMN_GetVolumeName( &dummyGenMsg, &poolVolume->ZFSPOOLvol, aStack->containerVolumeName, NELEMS(aStack->containerVolumeName) ); zvlBeast = ZLSSVOL_LV_ZVLOpen( genMsg, volumeName, @@ -6920,9 +6914,9 @@ STATUS ZLSSVOL_LV_GetInfoDeletion( zvlBeast = dqi->DQI_zvlBeast; zASSERT( zvlBeast != NULL ); /* Since we own delete list latch we can just use zvlBeast - * without inc use count because it is know to be at least - * two when on its volume is on the LV delete list. - */ + * without inc use count because it is know to be at least + * two when on its volume is on the LV delete list. + */ X_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); zASSERT( zvlBeast->ZVLfile.FILEuseCount > 0 ); @@ -6933,8 +6927,8 @@ STATUS ZLSSVOL_LV_GetInfoDeletion( loc = loc + strlen( loc ); /** - * This is where ZLSS specific TAGS go. - */ + * This is where ZLSS specific TAGS go. + */ @@ -6980,8 +6974,8 @@ STATUS ZLSSVOL_LV_GetInfoDeletion( stateString = MSGNot("salvaged"); break; } - sprintf( loc, MSGNot(" <%s value=\"%u\">%s\r\n"), - TAG_DELETESTATE, (unsigned int)zvlBeast->ZVL_p.PZVL_deleteState, + sprintf( loc, MSGNot(" <%s value=\"%u\">%s\r\n"), + TAG_DELETESTATE, (unsigned int)zvlBeast->ZVL_p.PZVL_deleteState, stateString, TAG_DELETESTATE); loc = loc + strlen( loc ); @@ -7114,8 +7108,8 @@ STATUS ZLSSVOL_LVD_DeleteActionPurge( if (retCode != OPERATION_DENIED) { exitEvent.enterRetStatus = retCode; - status = ZLSSVOL_LVD_DeleteActionPurgeInternal(genMsg, volumeName, - zVolume); + status = ZLSSVOL_LVD_DeleteActionPurgeInternal(genMsg, volumeName, + zVolume); exitEvent.opRetCode = (status == zOK) ? zOK : GetErrno(genMsg); COMN_SendNSSEvent(EVENT_LVolPurge_Exit, &exitEvent, sizeof(exitEvent), &denyCode); } @@ -7147,16 +7141,16 @@ STATUS ZLSSVOL_LVD_DeleteActionPurgeInternal( zASSERT( zlssPool != NULL ); poolVolume = zlssPool->ZLSSPOOLzfsPool; -// X_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// X_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); dqi = zVolume->ZV_dqi; zASSERT( dqi != NULL ); ZLSS_DQI_INUSE( dqi ); zvlBeast = dqi->DQI_zvlBeast; zASSERT( zvlBeast != NULL ); /* Since we own delete list latch we can just use zvlBeast - * without inc use count because it is know to be at least - * two when on its volume is on the LV delete list. - */ + * without inc use count because it is know to be at least + * two when on its volume is on the LV delete list. + */ zASSERT( zvlBeast != NULL ); X_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); @@ -7178,7 +7172,7 @@ STATUS ZLSSVOL_LVD_DeleteActionPurgeInternal( case ZVL_DS_PURGEING_PAUSED: status = ZLSSVOL_LVD_DeleteStateUpdate( genMsg, zvlBeast, zVolume , ZVL_DS_PURGEING ); - break; + break; case ZVL_DS_SALVAGED: case ZVL_DS_UNDELETE: @@ -7197,7 +7191,7 @@ STATUS ZLSSVOL_LVD_DeleteActionPurgeInternal( UNX_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); ZLSS_DQI_UNUSE( dqi ); -// UNX_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// UNX_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); return( status ); } /* End of ZLSSVOL_LVD_DeleteActionPurge() */ @@ -7226,8 +7220,8 @@ STATUS ZLSSVOL_LVD_DeleteActionSalvage( if (retCode != OPERATION_DENIED) { exitEvent.enterRetStatus = retCode; - status = ZLSSVOL_LVD_DeleteActionSalvageInternal(genMsg, volumeName, - zVolume); + status = ZLSSVOL_LVD_DeleteActionSalvageInternal(genMsg, volumeName, + zVolume); exitEvent.opRetCode = (status == zOK) ? zOK : GetErrno(genMsg); COMN_SendNSSEvent(EVENT_LVolSalvage_Exit, &exitEvent, sizeof(exitEvent), &denyCode); } @@ -7251,7 +7245,7 @@ STATUS ZLSSVOL_LVD_DeleteActionSalvageInternal( ZLSSVOL_LVD_DeleteQueueInfo_t *dqi; DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT, (CYAN, - MSGNot("zVOL_LV_DELETE_ACTION_SALVAGE action\n"))); + MSGNot("zVOL_LV_DELETE_ACTION_SALVAGE action\n"))); zASSERT( genMsg->flags & GM_FLAGS_INTERNAL_VOLUME ); zASSERT( zVolume->ZLSSVOLfile.FILEuseCount > 0 ); @@ -7260,16 +7254,16 @@ STATUS ZLSSVOL_LVD_DeleteActionSalvageInternal( zASSERT( zlssPool != NULL ); poolVolume = zlssPool->ZLSSPOOLzfsPool; -// X_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// X_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); dqi = zVolume->ZV_dqi; zASSERT( dqi != NULL ); ZLSS_DQI_INUSE( dqi ); zvlBeast = dqi->DQI_zvlBeast; zASSERT( zvlBeast != NULL ); /* Since we own delete list latch we can just use zvlBeast - * without inc use count because it is know to be at least - * two when on its volume is on the LV delete list. - */ + * without inc use count because it is know to be at least + * two when on its volume is on the LV delete list. + */ zASSERT( zvlBeast != NULL ); X_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); @@ -7283,11 +7277,11 @@ STATUS ZLSSVOL_LVD_DeleteActionSalvageInternal( case ZVL_DS_SALVAGEABLE: case ZVL_DS_SALVAGEABLE_PAUSED: /* The delete scan thread will detect the state change and - * then undelete the volume. - */ + * then undelete the volume. + */ status = ZLSSVOL_LVD_DeleteStateUpdate( genMsg, zvlBeast, zVolume , ZVL_DS_UNDELETE ); - break; + break; case ZVL_DS_PURGEING: case ZVL_DS_PURGEING_PAUSED: @@ -7307,7 +7301,7 @@ STATUS ZLSSVOL_LVD_DeleteActionSalvageInternal( UNX_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); ZLSS_DQI_UNUSE( dqi ); -// UNX_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// UNX_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); return( status ); } /* End of ZLSSVOL_LVD_DeleteActionSalvage() */ @@ -7332,8 +7326,8 @@ STATUS ZLSSVOL_LVD_DeleteActionAPI( ZfsVolume_s *zVolume; /* Since deleted volumes are marked as INTERNAL we need to - * indicate that we wish to look for internal volumes. - */ + * indicate that we wish to look for internal volumes. + */ COMN_INCLUDE_INTERNAL_VOLUMES( genMsg ); /* Verify that volume exists. */ zVolume = (ZfsVolume_s *)COMN_VolumeNameLookup(genMsg,volumeName,FALSE,NULL); @@ -7356,8 +7350,8 @@ STATUS ZLSSVOL_LVD_DeleteActionAPI( } /* To perform a delete action the LV must be in the - * delete state. - */ + * delete state. + */ if ( zVolume->ZLSSVOLvol.VOLpState != zVOL_PSTATE_DELETION ) { /* Not in Delete state! */ COMN_Release( &zVolume ); @@ -7397,7 +7391,7 @@ STATUS ZLSSVOL_LVD_DeleteActionAPI( COMN_Release( &zVolume ); return( status ); -} /* End of ZLSSVOL_LVD_DeleteActionAPI() */ +} /* End of ZLSSVOL_LVD_DeleteActionAPI() */ /* ZLSSVOL_LV_TruncateABeast() - @@ -7420,7 +7414,7 @@ STATIC STATUS ZLSSVOL_LV_TruncateABeast( if ( rootBeast->ROOTeof > 0 ) { - QUAD purgeBlkCnt = 0; + QUAD purgeBlkCnt = 0; rootBeast->ROOTeof = 0; COMN_MARK_BEAST_DIRTY(rootBeast); @@ -7428,16 +7422,16 @@ STATIC STATUS ZLSSVOL_LV_TruncateABeast( if ( namedBeast != NULL ) { if ( (namedBeast->NAMEDnameFlags & NFL_ADDED_TO_SALVAGE_TREE) && - (!(namedBeast->NAMEDnameFlags & NFL_BLKS_NOT_IN_PURGEABLE_CNT))) + (!(namedBeast->NAMEDnameFlags & NFL_BLKS_NOT_IN_PURGEABLE_CNT))) { if ( COMN_GetPurgeableBlksCnt(genMsg, rootBeast, &purgeBlkCnt) != zOK) - { + { DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(LRED, - MSGNot("%s ZLSSVOL_LV_TruncateABeast %ld set at %s\n"), + MSGNot("%s ZLSSVOL_LV_TruncateABeast %ld set at %s\n"), WHERE,GetErrno(genMsg),GetErrnoSetter(genMsg) )); zASSERT("ERROR getting purgeable count for file that is to be auto-purged during volume delete" == NULL); - ClearErrno(genMsg); - } + ClearErrno(genMsg); + } } } DEBUG_PRINTF(TLVOLUMES,DBG_NOINDENT,(CYAN, @@ -7482,7 +7476,7 @@ STATUS ZLSSVOL_LVD_DeleteUSRAndDSRAndMFLAndEFLTrees( zASSERT( volume->VOLv_keepActiveUseCount > 0 ); bzero( &aStack->volInfo, sizeof(aStack->volInfo) ); - aStack->volInfo.features.enabled = 0; + aStack->volInfo.features.enabled = 0; aStack->volInfo.features.enableModMask = zATTR_USER_SPACE_RESTRICTIONS | zATTR_DIR_QUOTAS | zATTR_MFL; @@ -7495,9 +7489,9 @@ STATUS ZLSSVOL_LVD_DeleteUSRAndDSRAndMFLAndEFLTrees( status = volume->VOLcomnBeastOps.BST_modifyInfo(genMsg, &volume->VOLroot, &aStack->modInfoMsg, NULL); /* - * Modify info only turns off restrictions. We must now blow away the - * entire user tree and invalidate the cache for this volume. (16 Aug 01) - */ + * Modify info only turns off restrictions. We must now blow away the + * entire user tree and invalidate the cache for this volume. (16 Aug 01) + */ if (status != zOK) { UNX_LATCH(&volume->VOLbeastLatch); @@ -7512,14 +7506,14 @@ STATUS ZLSSVOL_LVD_DeleteUSRAndDSRAndMFLAndEFLTrees( STACK_FREE(); return zFAILURE; } - + OID_InvalidateObjectIDCache(volume); + - - /* - * Remove the EFL tree - * - */ + /* + * Remove the EFL tree + * + */ status = volume->VOLcomnVolOps.VOL_resetEFL(genMsg, volume); if (status != zOK) { @@ -7527,7 +7521,7 @@ STATUS ZLSSVOL_LVD_DeleteUSRAndDSRAndMFLAndEFLTrees( STACK_FREE(); return zFAILURE; } - + UNX_LATCH(&volume->VOLbeastLatch); @@ -7565,10 +7559,10 @@ STATUS ZLSSVOL_LVD_DeleteAllUserObjects( { #define ZLSS_LV_DELETE_ZIDS 2000 /* Number of ZIDs to get in one browse - * call. Also determines the number of ZIDs - * behind our PZVL_lastZidTruncated will - * be set to. - */ + * call. Also determines the number of ZIDs + * behind our PZVL_lastZidTruncated will + * be set to. + */ STATUS status; NINT index; NINT numReturnedZids; @@ -7619,10 +7613,10 @@ STATUS ZLSSVOL_LVD_DeleteAllUserObjects( status = ZLSSVOL_LV_TruncateABeast( genMsg, rootBeast ); if ( status != zOK ) { /* I have seen this hit because COMPression - * code tries to remove a Purge Log entry - * that does not exist. In this case the - * 'rootBeast' does not get TRUNCATED. - */ + * code tries to remove a Purge Log entry + * that does not exist. In this case the + * 'rootBeast' does not get TRUNCATED. + */ DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(LRED, MSGNot("Error %d from %s truncating object (zid=%Ld) while deleting a LV.\n"), GetErrno(genMsg), GetErrnoSetter(genMsg), @@ -7634,17 +7628,17 @@ STATUS ZLSSVOL_LVD_DeleteAllUserObjects( } else { /* May have UNACCOUNTABLE BLOCKS, but we should - * go forward. - * Logic flaw in assumeing that this is - * always an error. When we truncate a file - * that is compressed the compressed object will - * get deleted. If the compressed object ZID is - * in our browse buffer then when we try to - * look it up it will be gone. - * Could look up if beast is compressed and if - * we have its ZID in our browse buffer and - * we could remove. - */ + * go forward. + * Logic flaw in assumeing that this is + * always an error. When we truncate a file + * that is compressed the compressed object will + * get deleted. If the compressed object ZID is + * in our browse buffer then when we try to + * look it up it will be gone. + * Could look up if beast is compressed and if + * we have its ZID in our browse buffer and + * we could remove. + */ DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(LRED, MSGNot("WARNING(or error) %d from %s looking up an object (zid=%Ld) while deleting a LV.\n"), GetErrno(genMsg), GetErrnoSetter(genMsg), @@ -7655,16 +7649,16 @@ STATUS ZLSSVOL_LVD_DeleteAllUserObjects( if ( ((ZfsVolume_s *)volume)->ZV_stopPurge ) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(MAGENTA, - MSGNot("ZV_stopPurge request - stopping LV delete (in DAUO)\n"))); + MSGNot("ZV_stopPurge request - stopping LV delete (in DAUO)\n"))); free(zidArray); SetErrno( genMsg, zERR_VOLUME_STOP_REQUESTED ); return( zFAILURE ); } /** Check to see if someone is wanting to deactivate the volume. - * If so we stop our thread so than the volume can be deactivated. - * This presents a small problem because if the deactivate fails - * we will not restart the LV Delete until the volume is re-loaded. - */ + * If so we stop our thread so than the volume can be deactivated. + * This presents a small problem because if the deactivate fails + * we will not restart the LV Delete until the volume is re-loaded. + */ if ( volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP ) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(MAGENTA, @@ -7675,31 +7669,31 @@ STATUS ZLSSVOL_LVD_DeleteAllUserObjects( } } /*** - *** Now that we are done with this set of ZIDs, store - *** progress information into zvlBeast - *** so we do not have to start browse from the start if we - *** crash or we get deactivated. We need to be very careful - *** here because ZLSS can UNDO committed transactions. So - *** even though we can be assured that the truncates will - *** commit before we update our ZID index because of the - *** ordering that ZLOG guarntees we must worry about the - *** uncommit of committed xactions. - *** We will simply store a ZID index that we truncated - *** long ago. Worse case, is that we may generate UNACCOUNTED - *** FOR BLOCKS. - ***/ + *** Now that we are done with this set of ZIDs, store + *** progress information into zvlBeast + *** so we do not have to start browse from the start if we + *** crash or we get deactivated. We need to be very careful + *** here because ZLSS can UNDO committed transactions. So + *** even though we can be assured that the truncates will + *** commit before we update our ZID index because of the + *** ordering that ZLOG guarntees we must worry about the + *** uncommit of committed xactions. + *** We will simply store a ZID index that we truncated + *** long ago. Worse case, is that we may generate UNACCOUNTED + *** FOR BLOCKS. + ***/ X_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); xaction = BeginXLocal(zvlBeast->ZVLfile.FILEvolume, BXL_DEFAULT); zvlBeast->ZVL_p.PZVL_lastZidTruncated = lastZid; - + COMN_MARK_BEAST_XLOCAL(&zvlBeast->ZVLfile.FILEroot,&xaction->xaction); status = COMN_ForceBeastWrite(genMsg, &zvlBeast->ZVLfile.FILEroot, &xaction->xaction ); if ( status != zOK ) { /* Will only cause us to browse more objects that - * we have already truncated. Therefor ignore the - * error. - */ + * we have already truncated. Therefor ignore the + * error. + */ zASSERT( "ZVLB log not updated" == NULL ); ClearErrno( genMsg ); } @@ -7713,26 +7707,26 @@ STATUS ZLSSVOL_LVD_DeleteAllUserObjects( free(zidArray); /* Oct 2002, We (Ying, Vandana, Greg) saw an issue that - * compression was purging a comp beast, but got an - * error because the BT was gone. This caused issues - * with the beast not being freed. Greg says this - * is a bug in that code path, but at the same time - * we do not want things to be going on when we start - * ripping the NT and BT apart. Therefore, before - * completing the truncate phase we deactivate and - * activate the volume so that all the COMP purges are - * done before we truncate the BT. - */ + * compression was purging a comp beast, but got an + * error because the BT was gone. This caused issues + * with the beast not being freed. Greg says this + * is a bug in that code path, but at the same time + * we do not want things to be going on when we start + * ripping the NT and BT apart. Therefore, before + * completing the truncate phase we deactivate and + * activate the volume so that all the COMP purges are + * done before we truncate the BT. + */ { ZfsVolume_s *zVolume = VOLUME_TO_ZLSS_VOLUME(volume); COMN_UnlockVolumeActive( &zVolume->ZLSSVOLvol, FALSE ); status = ZLSSVOL_LVD_ChangeVolumeStateWhenPoolLockedActive(genMsg, zVolume, zVOLSTATE_DEACTIVE, 0 ); - X_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + X_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); if ( zVolume->ZFSVOLstate != zVOLSTATE_DEACTIVE ) { - UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); zASSERT("Deletion of LV failed"==NULL ); if ( status == zOK ) { @@ -7741,7 +7735,7 @@ STATUS ZLSSVOL_LVD_DeleteAllUserObjects( return( zFAILURE ); } ClearErrno( genMsg ); - UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); (void)ZLSSVOL_LVD_ChangeVolumeStateWhenPoolLockedActive(genMsg, zVolume, zVOLSTATE_ACTIVE, 0 ); ClearErrno( genMsg ); @@ -7831,16 +7825,16 @@ Time_t ZLSSVOL_LVD_SalvageableTimeGet( salvageableTime = zvlBeast->ZVL_p.PZVL_deleteTimeStart; salvageableTime += Config.lv.PurgeDelayAfterDeleteSeconds; /* If we are still SALVAGEABLE only because we recently - * loaded ZLSS then use that time. - */ + * loaded ZLSS then use that time. + */ if ( salvageableTime < (UpTimeToUTCTime(ZLSSStartUpTime) + Config.lv.PurgeDelayAfterLoadSeconds) ) { salvageableTime = UpTimeToUTCTime(ZLSSStartUpTime) + Config.lv.PurgeDelayAfterLoadSeconds; } /* If we are still SALVAGEABLE only because we recently - * entered SALVAGEABLE state then use that time. - */ + * entered SALVAGEABLE state then use that time. + */ if ( salvageableTime < (zvlBeast->ZVL_deleteStateChangeTime + Config.lv.PurgeDelayAfterLastEntrySeconds) ) { salvageableTime = (zvlBeast->ZVL_deleteStateChangeTime + Config.lv.PurgeDelayAfterLastEntrySeconds); @@ -7877,7 +7871,7 @@ void ZLSSVOL_LVD_UISalvageable( ) (zvlBeast->ZVL_p.PZVL_deleteState == ZVL_DS_SALVAGEABLE_PAUSED) ) { Time_t salvageableTime; - + doLine = TRUE; ++count; salvageableTime = ZLSSVOL_LVD_SalvageableTimeGet( zvlBeast ); @@ -7894,8 +7888,8 @@ void ZLSSVOL_LVD_UISalvageable( ) UNS_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch); ZLSS_DQI_UNUSE( dqi ); /* We do printing while not owning any resources so that if - * we 'pause' it does not effect any other code. - */ + * we 'pause' it does not effect any other code. + */ if ( doLine ) { if ( doHeader ) @@ -7977,8 +7971,8 @@ void ZLSSVOL_LVD_UIBasic( ) UNS_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch); ZLSS_DQI_UNUSE( dqi ); /* We do printing while not owning any resources so that if - * we 'pause' it does not effect any other code. - */ + * we 'pause' it does not effect any other code. + */ if ( doHeader ) { aprintf(GREEN,MSG("Volume Name Original Name Delete Time Status\n",912)); @@ -8105,7 +8099,7 @@ STATUS doZLSSVOL_LV_Truncate( // // status = COMN_GetNameFromBeast( &dummyGenMsg, (NamedBeast_s *)poolVolume, // zFNU_FIRST_PARENT, -// zNSPACE_LONG, NELEMS(containerVolumeName), +// zNSPACE_LONG, NELEMS(containerVolumeName), // containerVolumeName, NULL); // UNX_LATCH( &poolVolume->ZFSPOOLbeastLatch ); // if ( status != zOK ) @@ -8117,7 +8111,7 @@ STATUS doZLSSVOL_LV_Truncate( // X_LATCH( &zVolume->ZFSVOLbeastLatch); // status = COMN_GetNameFromBeast( &dummyGenMsg, (NamedBeast_s *)zVolume, // zFNU_FIRST_PARENT, -// zNSPACE_LONG, NELEMS(zVolumeName), +// zNSPACE_LONG, NELEMS(zVolumeName), // zVolumeName, NULL); // UNX_LATCH( &zVolume->ZFSVOLbeastLatch ); // if ( status != zOK ) @@ -8181,8 +8175,8 @@ STATUS ZLSSVOL_LVD_ChangeVolumeStateWhenPoolLockedActive( if ( mode & iVOLMODE_POOL_LACTHED ) { /* If caller already owns POOL latch then we can just - * do the CVS request. - */ + * do the CVS request. + */ status = COMN_ChangeVolumeState(genMsg, &zVolume->ZLSSVOLvol, destState, mode ); return( status ); @@ -8192,22 +8186,22 @@ STATUS ZLSSVOL_LVD_ChangeVolumeStateWhenPoolLockedActive( /* Is the latch owned by someone else? */ for( ; waitFlag == WAITED; ) { /* - * Yes - then we will just see if they wish for us to - * release our ACTIVE lock. - */ + * Yes - then we will just see if they wish for us to + * release our ACTIVE lock. + */ if ( zVolume->ZV_stopPurge ) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(MAGENTA, - MSGNot("ZV_stopPurge request - stopping LV delete (in ZLSSVOL_LVD_ChangeVolumeState)\n"))); + MSGNot("ZV_stopPurge request - stopping LV delete (in ZLSSVOL_LVD_ChangeVolumeState)\n"))); SetErrno( genMsg, zERR_VOLUME_STOP_REQUESTED ); return( zFAILURE ); } /** Check to see if someone is wanting to deactivate the pool. - * If so we stop our thread so than the pool can be deactivated. - * This presents a small problem because if the deactivate fails - * we will not restart the LV Delete until the volume is re-loaded. - */ + * If so we stop our thread so than the pool can be deactivated. + * This presents a small problem because if the deactivate fails + * we will not restart the LV Delete until the volume is re-loaded. + */ if ( zVolume->ZLSSVOLvol.v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP ) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(MAGENTA, @@ -8285,35 +8279,35 @@ STATUS ZLSSVOL_LVD_MovePurgeLog( zASSERT( poolVolume->ZFSPOOLvol.VOLv_keepActiveUseCount > 0 ); /* This prevents the need for new REDO/UNDO code. - * Instead of using ZLOG_DELETE_BLOCK (in the next step of LV - * deletion) we will just wait a while for checkpoints to be written. - * This also helps to ensure that any current PL entries are freed. - * The PL will have lots of delete block entries in it normally - * from the tree deletes we have just done because they use - * ZLOG_DELETE_BLOCK. By doing a DEACTIVATE we cause a wait - * for all deleted system blocks to be dequeued. - */ + * Instead of using ZLOG_DELETE_BLOCK (in the next step of LV + * deletion) we will just wait a while for checkpoints to be written. + * This also helps to ensure that any current PL entries are freed. + * The PL will have lots of delete block entries in it normally + * from the tree deletes we have just done because they use + * ZLOG_DELETE_BLOCK. By doing a DEACTIVATE we cause a wait + * for all deleted system blocks to be dequeued. + */ /* Must release our ACTIVE lock on POOL or we can deadlock - * if someone is deactivating the POOL and we do a - * cahnge volume state. I.E. they own POOL cvsLatch - * and we try to get, but we have POOL (zfsPool_s) locked - * ACTIVE so they DELAY until we release. - */ + * if someone is deactivating the POOL and we do a + * cahnge volume state. I.E. they own POOL cvsLatch + * and we try to get, but we have POOL (zfsPool_s) locked + * ACTIVE so they DELAY until we release. + */ // COMN_UnlockVolumeActive( &poolVolume->ZFSPOOLvol, FALSE ); COMN_UnlockVolumeActive( &zVolume->ZLSSVOLvol, FALSE ); (void)ZLSSVOL_LVD_ChangeVolumeStateWhenPoolLockedActive(genMsg, zVolume, zVOLSTATE_DEACTIVE, 0 ); - X_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + X_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); if ( zVolume->ZFSVOLstate != zVOLSTATE_DEACTIVE ) { - UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); zASSERT(" Deletion of LV failed (can do a GO (unless running ORION!!!))"==NULL ); return( zFAILURE ); } - UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); (void)ZLSSVOL_LVD_ChangeVolumeStateWhenPoolLockedActive(genMsg, zVolume, zVOLSTATE_ACTIVE, 0 ); @@ -8332,20 +8326,20 @@ STATUS ZLSSVOL_LVD_MovePurgeLog( return(zFAILURE); } - /** Our DEACTIVATE and ACTIVATE ensures that all the queued up - * deleted system blocks get deleted. This means that we have - * ONE checkpoint taken after the last delete completed. To - * ensure that the EVIL undo of committed xactions does not - * occur on these deleted blocks we take 3 more checkpoints. - * This will prevent the undo of committed xactions because - * REDO/UNDO can not go back past the oldest checkpoint! - * - * Whats so wrong with UNDO these xactions? Because the update - * of the zvlBeast is not connected with them via a xaction or - * via a system block. This means that the deletes may be - * UNDOne but not the update to the zvlBeast that indicates - * we have completed a subState. - */ + /** Our DEACTIVATE and ACTIVATE ensures that all the queued up + * deleted system blocks get deleted. This means that we have + * ONE checkpoint taken after the last delete completed. To + * ensure that the EVIL undo of committed xactions does not + * occur on these deleted blocks we take 3 more checkpoints. + * This will prevent the undo of committed xactions because + * REDO/UNDO can not go back past the oldest checkpoint! + * + * Whats so wrong with UNDO these xactions? Because the update + * of the zvlBeast is not connected with them via a xaction or + * via a system block. This means that the deletes may be + * UNDOne but not the update to the zvlBeast that indicates + * we have completed a subState. + */ for ( checkpoint = 0; checkpoint < CHECKPOINT_NUMBER-1; ++checkpoint ) { @@ -8358,7 +8352,7 @@ STATUS ZLSSVOL_LVD_MovePurgeLog( } } - purgeLog = zVolume->ZFSVOLvolumePurgeLog; + purgeLog = zVolume->ZFSVOLvolumePurgeLog; if ( purgeLog == NULL ) { /* Defensive code */ COMN_UnlockVolumeActive( &zVolume->ZLSSVOLvol, FALSE ); @@ -8371,30 +8365,30 @@ STATUS ZLSSVOL_LVD_MovePurgeLog( X_LATCH(&purgeLog->ZFSPURGELOGbeastLatch); /* Note that we finally set the sub-state to indicate - * that NO MORE activations are allowed. This is - * REQUIRED as the purge log code (that is executed in - * ACTIVE STATE) assumes that the purge log always has - * at least one block in it. - */ + * that NO MORE activations are allowed. This is + * REQUIRED as the purge log code (that is executed in + * ACTIVE STATE) assumes that the purge log always has + * at least one block in it. + */ zvlBeast->ZVL_p.PZVL_purgeLogBlocks = purgeLog->p.firstBlock; zvlBeast->ZVL_p.PZVL_subState = PZVL_SS_DELETE_STEP_PLOG_MOVE+1; purgeLog->p.firstBlock = 0; /* Purge log code likes 0 more than - * INVALID_BLK. In any case, the - * purge log code should NEVER see as - * we will never activate the volume - * again. Verify/Rebuild needs this - * field cleared. - */ + * INVALID_BLK. In any case, the + * purge log code should NEVER see as + * we will never activate the volume + * again. Verify/Rebuild needs this + * field cleared. + */ /** A XACTION must supply a volume and - * we are really over TWO volumes. The volume is used - * for queueing free blocks which we do not have. - * Two volumes is OK as not freeing blocks AND the volumes - * are on the same POOL. The zVolume is used because LV - * are always used everywhere else. I.E. the LV is used - * for all xactions even though many operations use pool - * systems beasts that reside on the poolVolume). - */ + * we are really over TWO volumes. The volume is used + * for queueing free blocks which we do not have. + * Two volumes is OK as not freeing blocks AND the volumes + * are on the same POOL. The zVolume is used because LV + * are always used everywhere else. I.E. the LV is used + * for all xactions even though many operations use pool + * systems beasts that reside on the poolVolume). + */ xaction = BeginXLocal( &zVolume->ZLSSVOLvol, BXL_DEFAULT); COMN_MARK_BEAST_XLOCAL(&zvlBeast->ZVLfile.FILEroot,&xaction->xaction); @@ -8461,8 +8455,8 @@ STATUS ZLSSVOL_LVD_TruncatePurgeLog( zASSERT( zvlBeast->ZVL_p.PZVL_subState == PZVL_SS_DELETE_STEP_PLOG_TRUNCATE ); /* PZVL_purgeLogBlocks is protected by the FACT that - * only the LV delete code can play with. - */ + * only the LV delete code can play with. + */ purgeBlock = zvlBeast->ZVL_p.PZVL_purgeLogBlocks; while ( (purgeBlock != 0) && (purgeBlock != INVALID_BLK) ) @@ -8470,18 +8464,18 @@ STATUS ZLSSVOL_LVD_TruncatePurgeLog( if ( zVolume->ZV_stopPurge ) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(MAGENTA, - MSGNot("ZV_stopPurge request - stopping LV delete (in TPL)\n"))); + MSGNot("ZV_stopPurge request - stopping LV delete (in TPL)\n"))); SetErrno( genMsg, zERR_VOLUME_STOP_REQUESTED ); return( zFAILURE ); } /* Exit if either the POOL VOLUME or the LV as a CVS - * request against them. - */ + * request against them. + */ if ( poolVolume->ZFSPOOLvol.v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP ) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(MAGENTA, - MSGNot("CVS from ACTIVE state requested of INTERNAL VOLUME - stopping LV delete (in TPL)\n"))); + MSGNot("CVS from ACTIVE state requested of INTERNAL VOLUME - stopping LV delete (in TPL)\n"))); SetErrno( genMsg, zERR_VOLUME_STATE_CHANGE_REQUESTED ); return( zFAILURE ); } @@ -8489,7 +8483,7 @@ STATUS ZLSSVOL_LVD_TruncatePurgeLog( VOL_SF_LEAVING_DEACTIVE_STATE_CLEANUP ) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(MAGENTA, - MSGNot("CVS from DEACTIVE state requested - stopping LV delete (in TPL)\n"))); + MSGNot("CVS from DEACTIVE state requested - stopping LV delete (in TPL)\n"))); SetErrno( genMsg, zERR_VOLUME_STATE_CHANGE_REQUESTED ); return( zFAILURE ); } @@ -8526,12 +8520,12 @@ STATUS ZLSSVOL_LVD_TruncatePurgeLog( ClearErrno( genMsg ); } /* We do not do the standard ZLOG_DELETE_BLOCK even - * though we are freeing a SYSTEM block. We get away with - * this as the LV volume is deactive so we have already waited - * for three checkpoints. Note we could do ZLOG_DELETE_BLOCK - * on the poolVolume, but I felt it was not worth doing the - * code for a new REDO/UNDO routine. - */ + * though we are freeing a SYSTEM block. We get away with + * this as the LV volume is deactive so we have already waited + * for three checkpoints. Note we could do ZLOG_DELETE_BLOCK + * on the poolVolume, but I felt it was not worth doing the + * code for a new REDO/UNDO routine. + */ zfsFreePoolExtent(genMsg, poolVolume, &extent, xaction); /* Does not adjust any VOLUME in use counts */ EndXlocal(xaction); @@ -8577,12 +8571,12 @@ STATUS ZLSSVOL_LVD_FreeLastBlocks( zvlBeast->ZVL_p.PZVL_volumeDataBlk = INVALID_BLK; if ( (extent.poolBlkNum != 0) && (extent.poolBlkNum != INVALID_BLK) ) { /* We do not do the standard ZLOG_DELETE_BLOCK even - * though we are freeing a SYSTEM block. We get away with - * this as the LV volume is deactive so we have already waited - * for three checkpoints. Note we could do ZLOG_DELETE_BLOCK - * on the poolVolume, but I felt it was not worth doing the - * code for a new REDO/UNDO routine. - */ + * though we are freeing a SYSTEM block. We get away with + * this as the LV volume is deactive so we have already waited + * for three checkpoints. Note we could do ZLOG_DELETE_BLOCK + * on the poolVolume, but I felt it was not worth doing the + * code for a new REDO/UNDO routine. + */ (void)zfsFreePoolExtent(genMsg, poolVolume, &extent, xaction); } @@ -8652,7 +8646,7 @@ STATUS ZLSSVOL_LVD_DeleteZVLB( status = COMN_GetNameFromBeast( genMsg, (NamedBeast_s *)poolVolume, // cnt zFNU_FIRST_PARENT, - zNSPACE_LONG, NELEMS(aStack->containerVolumeName), + zNSPACE_LONG, NELEMS(aStack->containerVolumeName), aStack->containerVolumeName, NULL); UNX_LATCH( &poolVolume->ZFSPOOLbeastLatch ); if ( status != zOK ) @@ -8664,7 +8658,7 @@ STATUS ZLSSVOL_LVD_DeleteZVLB( X_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); status = COMN_GetNameFromBeast( genMsg, (NamedBeast_s *)zvlBeast, // cnt zFNU_FIRST_PARENT, - zNSPACE_LONG, NELEMS(aStack->zVolumeName), + zNSPACE_LONG, NELEMS(aStack->zVolumeName), aStack->zVolumeName, NULL); UNX_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); if ( status != zOK ) @@ -8690,14 +8684,14 @@ STATUS ZLSSVOL_LVD_DeleteZVLB( * dqi item to the master list. */ -void ZLSSVOL_LVD_DeleteListAddAndInit( +void ZLSSVOL_LVD_DeleteListAddAndInit( ZLSSVOL_LVD_DeleteQueueInfo_t *dqi, ZlssVolumeLocator_s *zvlBeast, ZfsVolume_s *zVolume ) { -// X_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// X_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); dqi->DQI_useCount = 0; ZLSS_DQI_INUSE( dqi ); dqi->DQI_activePurgeing = FALSE; @@ -8710,7 +8704,7 @@ void ZLSSVOL_LVD_DeleteListAddAndInit( dqi->DQI_zVolume = zVolume; SET_ENQ( &ZLSSLVDeleteList.ZDL_list, dqi, DQI_Link ); ZLSSLVDeleteList.ZDL_cnt += 1; -// UN_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// UN_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); } /* End of ZLSSVOL_LVD_DeleteListAddAndInit() */ @@ -8844,8 +8838,8 @@ STATUS ZLSSVOL_LVD_LoadModeDeletion( COMN_INCLUDE_INTERNAL_VOLUMES( genMsg ); /* Since we are deleting the LV we do not wish anyone - * to find it. - */ + * to find it. + */ zVolume->ZFSVOLvol.VOLv_statusFlag |= VOL_SF_INTERNAL_VOLUME; zVolume->ZFSVOLfile.FILEattributes = zFA_SYSTEM|zFA_HIDDEN; @@ -8857,9 +8851,9 @@ STATUS ZLSSVOL_LVD_LoadModeDeletion( return( zFAILURE ); } /* By adding to the list we have ensured that the scan thread - * will see at some point and it will ensure that the correct - * actions occur based on the delete state. - */ + * will see at some point and it will ensure that the correct + * actions occur based on the delete state. + */ ZLSSVOL_LVD_DeleteListAddAndInit( dqi, zvlBeast, zVolume ); COMN_Release( &zVolume ); return( zOK ); @@ -8919,8 +8913,8 @@ STATUS ZLSSVOL_LVD_DeletePurge( mode |= iVOLMODE_POOL_LACTHED; /* Lock the poolVolume in ACTIVE state. Our purge thread will release - * from ACTIVE state. - */ + * from ACTIVE state. + */ if ( zvlBeast->ZVL_p.PZVL_subState <= PZVL_SS_DELETE_STEP_ACTIVATE ) { (void)COMN_ChangeVolumeState(genMsg, &zVolume->ZLSSVOLvol, zVOLSTATE_ACTIVE, mode ); @@ -8931,12 +8925,12 @@ STATUS ZLSSVOL_LVD_DeletePurge( return(zFAILURE); } /** Lock the volume in ACTIVE state. This is being done for - * our thread. Our thread will release the ACTIVE lock on - * the following conditions. - * 1) The thread wishes to DEACTIVATE the volume. - * 2) The thread detects someone else is DEACTIVATING - * the volume. - */ + * our thread. Our thread will release the ACTIVE lock on + * the following conditions. + * 1) The thread wishes to DEACTIVATE the volume. + * 2) The thread detects someone else is DEACTIVATING + * the volume. + */ /* We are locking LOGICAL VOLUME here */ if (COMN_LockVolumeActive(genMsg, &zVolume->ZLSSVOLvol, FALSE) != zOK) { @@ -8964,37 +8958,37 @@ STATUS ZLSSVOL_LVD_DeletePurge( } } /* We do not use the inUse count on the zvlBeast to ensure that - * the 'poolVolume' does not get DEACTIVATED because that would - * allow the CVS code to progress pretty far into DEACTIVE and - * the inUse count as a timeOut on it. Plus I felt that it - * would be kludgie!!! - */ + * the 'poolVolume' does not get DEACTIVATED because that would + * allow the CVS code to progress pretty far into DEACTIVE and + * the inUse count as a timeOut on it. Plus I felt that it + * would be kludgie!!! + */ dqi->DQI_Dti.DTI_zVolume = zVolume; dqi->DQI_Dti.DTI_poolVolume = poolVolume; dqi->DQI_Dti.DTI_verbose = verbose; FSMLITE_INIT(&dqi->DQI_Dti.DTI_fsmLite, "FSM for LV truncate", ++fsmInstance); DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(MAGENTA, - MSGNot("Starting thread to delete volume \"%U\" instance = %d dqi = 0x%lx.\n"), + MSGNot("Starting thread to delete volume \"%U\" instance = %d dqi = 0x%lx.\n"), zvlBeast->ZVL_p.PZVL_volumeName, fsmInstance, dqi ) ); /* Since we and the thread will still be using zvlBeast, - * volume and dqi we increase the use count for the thread. The - * thread will do a COMN_Release will it is done with the beasts. - * Our deletion thread will need to latch on it own. - */ + * volume and dqi we increase the use count for the thread. The + * thread will do a COMN_Release will it is done with the beasts. + * Our deletion thread will need to latch on it own. + */ ZLSS_DQI_INUSE( dqi ); - ++zvlBeast->ZVLfile.FILEuseCount; + ++zvlBeast->ZVLfile.FILEuseCount; ++zVolume->ZFSVOLfile.FILEuseCount; zVolume->ZV_stopPurge = FALSE; WORK_Schedule( &dqi->DQI_Dti.DTI_fsmLite, - (voidfunc_t)ZLSSVOL_LVD_DeletePurgeThread, (ADDR)dqi); + ZLSSVOL_LVD_DeletePurgeThread, (ADDR)dqi); /* Thread will release zVolume use count */ return( zOK ); } /* End of ZLSSVOL_LVD_DeletePurge() */ -void ZLSSVOL_LVD_ErrorRecord( +void ZLSSVOL_LVD_ErrorRecord( ZlssVolumeLocator_s *zvlBeast, GeneralMsg_s *genMsg ) @@ -9029,7 +9023,7 @@ void ZLSSVOL_LVD_ErrorRecord( } /* End of ZLSSVOL_LVD_ErrorRecord() */ -void ZLSSVOL_LVD_ErrorRecordClear( +void ZLSSVOL_LVD_ErrorRecordClear( ZlssVolumeLocator_s *zvlBeast ) { @@ -9047,7 +9041,7 @@ void ZLSSVOL_LVD_ErrorRecordClear( * the LV is ready then this routine will move state to PURGEING state. * The actual purgeing does not start until the scan thread starts the * purgeing which is based on having free purge threads. See the - * routine + * routine * * Returns - * Std STATUS except on errors the errno has been stored persistently @@ -9066,7 +9060,7 @@ void ZLSSVOL_LVD_DeleteScanSalvageable( zASSERT( dqi->DQI_useCount > 1 ); ASSERT_XLATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); -// ASSERT_XLATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// ASSERT_XLATCH( &ZLSSLVDeleteList.ZDL_listLatch ); zASSERT( zvlBeast->ZVL_p.PZVL_deleteState == ZVL_DS_SALVAGEABLE ); COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); @@ -9075,8 +9069,8 @@ void ZLSSVOL_LVD_DeleteScanSalvageable( salvageableTime = ZLSSVOL_LVD_SalvageableTimeGet( zvlBeast ); cTime = GetUTCTime(); /* If LV has pasted its SALVEABLE time then - * move the LV into PURGEING state. - */ + * move the LV into PURGEING state. + */ if ( cTime > salvageableTime ) { /* Time for this volume to be purged */ #ifdef USER_GPACHNER @@ -9124,7 +9118,7 @@ STATUS ZLSSVOL_LVD_DeleteScanUndelete( zASSERT( dqi->DQI_useCount > 1 ); ASSERT_XLATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); -// ASSERT_XLATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// ASSERT_XLATCH( &ZLSSLVDeleteList.ZDL_listLatch ); zASSERT( zvlBeast->ZVL_p.PZVL_deleteState == ZVL_DS_UNDELETE ); zASSERT( zvlBeast->ZVL_p.PZVL_state == PZVL_S_DELETION ); zASSERT( zvlBeast->ZVL_p.PZVL_subState == PZVL_SS_DELETE_SALVAGEABLE ); @@ -9133,7 +9127,7 @@ STATUS ZLSSVOL_LVD_DeleteScanUndelete( COMN_INCLUDE_INTERNAL_VOLUMES( &dummyGenMsg ); DEBUG_PRINTF(TLVDELETE,DBG_BOTH_NOINDENT,(CYAN, MSGNot("ZLSSVOL_LVD_DeleteScanUndelete() SETTING thread volume %U (Thread=%08x) STATE from %d to %d\n"), - zvlBeast->ZVL_p.PZVL_volumeName, ThreadId(), + zvlBeast->ZVL_p.PZVL_volumeName, ThreadId(), zvlBeast->ZVL_p.PZVL_state, PZVL_S_CREATED)); ZLSSVOL_LVD_ErrorRecordClear( zvlBeast ); @@ -9156,26 +9150,26 @@ STATUS ZLSSVOL_LVD_DeleteScanUndelete( zASSERT( zVolume != NULL ); zASSERT( COMN_IsDerivedFrom(zVolume, zFTYPE_ZLSS_VOL) ); /* Unhide the volume from COMN_VolumeLookup... and the - * _ADMIN volume and mark as CREATED. - */ + * _ADMIN volume and mark as CREATED. + */ zVolume->ZFSVOLvol.VOLv_statusFlag &= ~VOL_SF_INTERNAL_VOLUME; zVolume->ZFSVOLfile.FILEattributes &= ~(zFA_SYSTEM|zFA_HIDDEN); zVolume->ZLSSVOLvol.VOLpState = zVOL_PSTATE_CREATED; ZLSS_DQI_INUSE( dqi ); /* Schedule thread to remove dqi from list async */ WORK_Schedule( &dqi->DQI_Dti.DTI_fsmLite, - (voidfunc_t)ZLSSVOL_LVD_DeleteUndeleteThread, (ADDR)dqi); + ZLSSVOL_LVD_DeleteUndeleteThread, (ADDR)dqi); } else { zASSERT("This could be bad"==NULL); /* We set the memory copy of the state back, we assume - * that persistently it did not get written since we - * got an error. We don't write as the write above is the - * cause of the errno. Which means the next time ZLSS comes - * up the LV will be salvaged again. If it fails again - * then we have done no harm. - */ + * that persistently it did not get written since we + * got an error. We don't write as the write above is the + * cause of the errno. Which means the next time ZLSS comes + * up the LV will be salvaged again. If it fails again + * then we have done no harm. + */ ZLSSVOL_LVD_ErrorRecord( zvlBeast, &dummyGenMsg ); zvlBeast->ZVL_p.PZVL_state = PZVL_S_DELETION; zvlBeast->ZVL_p.PZVL_subState = PZVL_SS_DELETE_SALVAGEABLE; @@ -9209,7 +9203,7 @@ STATUS ZLSSVOL_LVD_DeleteScanPurgeing( // ASSERT_XLATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); ASSERT_XLATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); -// ASSERT_XLATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// ASSERT_XLATCH( &ZLSSLVDeleteList.ZDL_listLatch ); zASSERT( dqi->DQI_useCount > 1 ); if ( dqi->DQI_activePurgeing ) @@ -9239,11 +9233,11 @@ STATUS ZLSSVOL_LVD_DeleteScanPurgeing( COMN_INCLUDE_INTERNAL_VOLUMES( &dummyGenMsg ); if ( zvlBeast->ZVL_p.PZVL_subState == PZVL_SS_DELETE_SALVAGEABLE ) { /* Have not done ANY purging on this volume so move into - * first purgeing subState. - */ + * first purgeing subState. + */ DEBUG_PRINTF(TLVDELETE,DBG_BOTH_NOINDENT,(MAGENTA, MSGNot("ZLSSVOL_LVD_DeleteScanThread() SETTING thread volume %U (Thread=%08x) substate from %d to %d\n"), - zvlBeast->ZVL_p.PZVL_volumeName, ThreadId(), + zvlBeast->ZVL_p.PZVL_volumeName, ThreadId(), zvlBeast->ZVL_p.PZVL_subState, PZVL_SS_DELETE_SALVAGEABLE+1)); @@ -9257,7 +9251,7 @@ STATUS ZLSSVOL_LVD_DeleteScanPurgeing( { /* Have done purging on this volume so leave in current subState */ DEBUG_PRINTF(TLVDELETE,DBG_BOTH_NOINDENT,(MAGENTA, MSGNot("ZLSSVOL_LVD_DeleteScanThread() SETTING thread volume %U (Thread=%08x) substate from %d to %d\n"), - zvlBeast->ZVL_p.PZVL_volumeName, ThreadId(), + zvlBeast->ZVL_p.PZVL_volumeName, ThreadId(), zvlBeast->ZVL_p.PZVL_subState, zvlBeast->ZVL_p.PZVL_subState)); } @@ -9304,8 +9298,8 @@ STATUS ZLSSVOL_LVD_DeleteScanPurgeing( else { /* We set the memory copy of the state back, we assume - * that persistently it did not get written. - */ + * that persistently it did not get written. + */ ZLSSVOL_LVD_ErrorRecord( zvlBeast, &dummyGenMsg ); zvlBeast->ZVL_p.PZVL_subState = PZVL_SS_DELETE_SALVAGEABLE; /* zvlBeast->ZVL_p.PZVL_state = PZVL_S_DELETION; */ @@ -9334,7 +9328,7 @@ STATUS ZLSSVOL_LVD_DeleteScanPurgeing( */ void ZLSSVOL_LVD_DeleteScanThread( - FsmLite_s *fsmLite, + FsmLite_s *fsmLite, void *notUsed ) { @@ -9347,7 +9341,7 @@ void ZLSSVOL_LVD_DeleteScanThread( ZLSSLVDeleteList.ZDL_timesRun += 1; UNX_LATCH( &ZLSSLVDeleteList.ZDL_beastLatch ); -/* DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (CYAN, +/* DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (CYAN, MSGNot("ZLSSVOL_LVD_DeleteScanThread is now running\n")));*/ @@ -9370,12 +9364,12 @@ void ZLSSVOL_LVD_DeleteScanThread( X_NOWAIT( &zlssPool->ZLSSPOOLpool.cvsLatch, waitFlag ); if ( waitFlag == WAITED ) { /* Yet another deadlock rule. Can not wait on the - * cvsLatch while we have a use count on a DQI. This - * is really just a extension to the rule -- can not - * have useCount on the zvlBeast when we try for the - * POOLs cvsLatch. This is because the DQI holds a use - * count on the zvlVBeast. - */ + * cvsLatch while we have a use count on a DQI. This + * is really just a extension to the rule -- can not + * have useCount on the zvlBeast when we try for the + * POOLs cvsLatch. This is because the DQI holds a use + * count on the zvlVBeast. + */ goto skipThisTime; } @@ -9389,11 +9383,11 @@ void ZLSSVOL_LVD_DeleteScanThread( break; case ZVL_DS_PURGEING: /* This routine use to get the Pool's cvsLatch - * this can cause a deadlock if we own the zvlBeast - * latch. I.E. In flush volume during pool deactivate - * we get the latches in the other order. Pool's cvsLatch - * first and then any beast that needs to flush. - */ + * this can cause a deadlock if we own the zvlBeast + * latch. I.E. In flush volume during pool deactivate + * we get the latches in the other order. Pool's cvsLatch + * first and then any beast that needs to flush. + */ (void)ZLSSVOL_LVD_DeleteScanPurgeing( dqi, zvlBeast ); break; case ZVL_DS_UNDELETE: @@ -9402,8 +9396,8 @@ void ZLSSVOL_LVD_DeleteScanThread( case ZVL_DS_SALVAGED: /* We do nothing as a thread has already been scheduled - * to remove this dqi from the list. - */ + * to remove this dqi from the list. + */ break; case ZVL_DS_PURGE_ERROR: @@ -9415,7 +9409,7 @@ void ZLSSVOL_LVD_DeleteScanThread( /* in PZVL_deleteState state change deactivate LV */ break; default: - DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (CYAN, + DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (CYAN, MSGNot("ZLSSVOL_LVD_DeleteScanThread invalid PZVL_deleteState\n"))); break; } @@ -9426,29 +9420,29 @@ skipThisTime: SET_FOREACHBLOCKINGEND(&ZLSSLVDeleteList.ZDL_list, dqi, ZLSSVOL_LVD_DeleteQueueInfo_t, DQI_Link); } /* End of DQ_FOREACH() */ -// UNX_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); +// UNX_LATCH( &ZLSSLVDeleteList.ZDL_listLatch ); /* Re-schedule timer (most of the time) */ X_LATCH( &ZLSSLVDeleteList.ZDL_beastLatch ); if ( !ZLSSLVDeleteList.ZDL_stop ) { /* Set a new timer because scanning still allowed. */ -/* DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (CYAN, +/* DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (CYAN, MSGNot("ZLSSVOL_LVD_DeleteScanThread is re-scheduling\n")));*/ setOneShot(&ZLSSLVDeleteList.ZDL_timer, ZLSSVOL_LVD_SCAN_TICKS, ZLSSVOL_LVD_DeleteScanTimer); } else { - DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (MAGENTA, + DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (MAGENTA, MSGNot("ZLSSVOL_LVD_DeleteScanThread is NOT re-scheduling\n"))); } /* Indicate that no one is scanning */ ZLSSLVDeleteList.ZDL_scheduled = FALSE; - + ZLSSLVDeleteList.ZDL_threadIdLast = ZLSSLVDeleteList.ZDL_threadId; ZLSSLVDeleteList.ZDL_threadId = 0; UNX_LATCH( &ZLSSLVDeleteList.ZDL_beastLatch ); -/* DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (CYAN, +/* DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (CYAN, MSGNot("ZLSSVOL_LVD_DeleteScanThread is complete\n")));*/ return; @@ -9467,23 +9461,23 @@ void ZLSSVOL_LVD_DeleteScanTimer( ASSERT_MPKNSS_LOCK(); if ( ZLSSLVDeleteList.ZDL_scheduled == TRUE ) { /** Just return because the thread will do the reschedule **/ - DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (CYAN, + DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (CYAN, MSGNot("Asynchronous LV DELETE SCAN already scheduled\n"))); return; } /* - * Mark that we are scheduling our work to do. We use this flag - * to prevent mulitple schedules and to prevent unloading of the - * beast with a work-to-do scheduled (see ZFSPOOL_Shutdown()). - */ + * Mark that we are scheduling our work to do. We use this flag + * to prevent mulitple schedules and to prevent unloading of the + * beast with a work-to-do scheduled (see ZFSPOOL_Shutdown()). + */ ZLSSLVDeleteList.ZDL_scheduled = TRUE; /* DEBUG_PRINTF(TZPOOL,DBG_INDENT,(CYAN, MSGNot("Timer: Scheduling LV DELETE SCAN\n")));*/ ZLSSLVDeleteList.ZDL_scheduledTime = GetUTCTime(); /* Schedule a thread to do the work later (so we will not block) */ WORK_Schedule( &ZLSSLVDeleteList.ZDL_fsmLite, - (voidfunc_t)ZLSSVOL_LVD_DeleteScanThread, 0); + ZLSSVOL_LVD_DeleteScanThread, 0); return; } /* End of ZLSSVOL_LVD_DeleteScanTimer() */ @@ -9511,7 +9505,7 @@ STATUS ZLSSVOL_LVD_DeleteAPI( EventLVolDeleteEnter_s enterEvent; EventLVolDeleteExit_s exitEvent; ZlssPool_s *zlssPool; - ZfsVolume_s *zVolume; + ZfsVolume_s *zVolume; zASSERT( mode == 0 ); enterEvent.enterExitID = exitEvent.enterExitID = ++EnterExitEventID; @@ -9519,12 +9513,12 @@ STATUS ZLSSVOL_LVD_DeleteAPI( COMN_EXCLUDE_INTERNAL_VOLUMES( genMsg ); zVolume = (ZfsVolume_s *)COMN_VolumeNameLookup(genMsg, oldVolumeName, - FALSE, NULL); + FALSE, NULL); // COMN_INCLUDE_INTERNAL_VOLUMES( genMsg ); if ( zVolume == NULL ) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT, (LRED, - MSGNot("%s ZLSSVOL_LVD_DeleteAPI failed with %ld at %s\n"), + MSGNot("%s ZLSSVOL_LVD_DeleteAPI failed with %ld at %s\n"), WHERE, GetErrno( genMsg ),GetErrnoSetter( genMsg ))); return( zFAILURE ); } @@ -9534,12 +9528,12 @@ STATUS ZLSSVOL_LVD_DeleteAPI( COMN_Release( &zVolume ); SetErrno( genMsg, zERR_NOT_SUPPORTED ); DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT, (LRED, - MSGNot("%s ZLSSVOL_LVD_DeleteAPI failed with %ld at %s\n"), + MSGNot("%s ZLSSVOL_LVD_DeleteAPI failed with %ld at %s\n"), WHERE, GetErrno( genMsg ),GetErrnoSetter( genMsg ))); return( zFAILURE ); } - enterEvent.volID = exitEvent.oldVolID = - exitEvent.newVolID = zVolume->ZFSVOLvolumeID; + enterEvent.volID = exitEvent.oldVolID = + exitEvent.newVolID = zVolume->ZFSVOLvolumeID; zlssPool = ZLSS_VOLUME_TO_ZLSS_POOL(zVolume); enterEvent.poolID = exitEvent.poolID = zlssPool->ZLSSPOOLmVolumeID; COMN_Release( &zVolume ); @@ -9548,8 +9542,8 @@ STATUS ZLSSVOL_LVD_DeleteAPI( if (retCode != OPERATION_DENIED) { exitEvent.enterRetStatus = retCode; - status = ZLSSVOL_LVD_DeleteAPIInternal(genMsg, oldVolumeName, - mode, &exitEvent.newVolID); + status = ZLSSVOL_LVD_DeleteAPIInternal(genMsg, oldVolumeName, + mode, &exitEvent.newVolID); exitEvent.opRetCode = (status == zOK) ? zOK : GetErrno(genMsg); COMN_SendNSSEvent(EVENT_LVolDelete_Exit, &exitEvent, sizeof(exitEvent), &denyCode); } @@ -9559,7 +9553,7 @@ STATUS ZLSSVOL_LVD_DeleteAPI( status = (denyCode == zOK) ? zOK : zFAILURE; } return status; -} /* End of ZLSSVOL_LVD_DeleteAPI() */ +} /* End of ZLSSVOL_LVD_DeleteAPI() */ STATUS ZLSSVOL_LVD_DeleteAPIInternal( @@ -9584,9 +9578,9 @@ STATUS ZLSSVOL_LVD_DeleteAPIInternal( zASSERT( !(genMsg->flags & GM_FLAGS_INTERNAL_VOLUME) ); COMN_EXCLUDE_INTERNAL_VOLUMES( genMsg ); /* Verify that volume exists. Note that we will not find volumes - * that are already being deleted because they are marked INTERNAL - * and we do not have the INTERNAL bit set in the genMsg - */ + * that are already being deleted because they are marked INTERNAL + * and we do not have the INTERNAL bit set in the genMsg + */ zVolume = (ZfsVolume_s *)COMN_VolumeNameLookup(genMsg,oldVolumeName,FALSE,NULL); if ( zVolume == NULL ) { @@ -9632,16 +9626,16 @@ STATUS ZLSSVOL_LVD_DeleteAPIInternal( return( zFAILURE ); } /*** - *** Get the name of the poolVolume. This is used by several APIs - *** that need to be called later. - ***/ - status = COMN_GetVolumeName( genMsg, &poolVolume->ZFSPOOLvol, + *** Get the name of the poolVolume. This is used by several APIs + *** that need to be called later. + ***/ + status = COMN_GetVolumeName( genMsg, &poolVolume->ZFSPOOLvol, names->containerVolumeName, NELEMS(names->containerVolumeName) ); // X_LATCH( &poolVolume->ZFSPOOLbeastLatch); // status = COMN_GetNameFromBeast( genMsg, (NamedBeast_s *)poolVolume, // zFNU_FIRST_PARENT, -// zNSPACE_LONG, NELEMS(names->containerVolumeName), +// zNSPACE_LONG, NELEMS(names->containerVolumeName), // names->containerVolumeName, NULL); // UNX_LATCH( &poolVolume->ZFSPOOLbeastLatch ); if ( status != zOK ) @@ -9654,9 +9648,9 @@ STATUS ZLSSVOL_LVD_DeleteAPIInternal( } /*** - *** Deactivate the volume. This will force open files - *** to be closed. - ***/ + *** Deactivate the volume. This will force open files + *** to be closed. + ***/ status = ZLSSVOL_LVD_ChangeVolumeStateWhenPoolLockedActive(genMsg, zVolume, zVOLSTATE_DEACTIVE, iVOLMODE_POOL_LACTHED); if ( status != zOK ) @@ -9667,10 +9661,10 @@ STATUS ZLSSVOL_LVD_DeleteAPIInternal( free( names ); return( zFAILURE ); } - X_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + X_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); if ( zVolume->ZFSVOLstate != zVOLSTATE_DEACTIVE ) { - UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); SetErrno( genMsg, zERR_VOLUME_NOT_IN_DEACTIVE_STATE ); COMN_PoolActiveUnlock( &zlssPool->ZLSSPOOLpool ); UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); @@ -9679,19 +9673,19 @@ STATUS ZLSSVOL_LVD_DeleteAPIInternal( return( zFAILURE ); } /*** - *** Hold volume in DEACTIVE state (via cvsLatch) until - *** we rename it and make it a hidden(internal) volume and - *** mark it for deletion. Part of rename includes changing - *** the volume ID (DFS considers this the volume's name). - ***/ + *** Hold volume in DEACTIVE state (via cvsLatch) until + *** we rename it and make it a hidden(internal) volume and + *** mark it for deletion. Part of rename includes changing + *** the volume ID (DFS considers this the volume's name). + ***/ - /* We use a newly generated volume GUID for the volume name - * and Volume ID because the Volume ID may not be unique. This - * can occur if DFS deletes a LV, re-creates it with - * same GUID and then deletes the re-created LV while the - * first LV is still being deleted. With mirroring even - * the Internal Guid is not unique. - */ + /* We use a newly generated volume GUID for the volume name + * and Volume ID because the Volume ID may not be unique. This + * can occur if DFS deletes a LV, re-creates it with + * same GUID and then deletes the re-created LV while the + * first LV is still being deleted. With mirroring even + * the Internal Guid is not unique. + */ retry = 200; Again: --retry; @@ -9705,7 +9699,7 @@ Again: if ( retry < 0 ) { zASSERT("Someone needs to check out how we got here"==NULL); - UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); SetErrno( genMsg, status ); COMN_PoolActiveUnlock( &zlssPool->ZLSSPOOLpool ); UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); @@ -9726,7 +9720,7 @@ Again: if ( retry < 0 ) { zASSERT("Someone needs to check out how we got here"==NULL); - UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); SetErrno( genMsg, status ); COMN_PoolActiveUnlock( &zlssPool->ZLSSPOOLpool ); UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); @@ -9737,14 +9731,14 @@ Again: Yield(); /* This will help our next generated GUID */ goto Again; } - + COMN_INCLUDE_INTERNAL_VOLUMES( genMsg ); zvlBeast = ZLSSVOL_LV_ZVLOpen( genMsg, oldVolumeName, names->containerVolumeName, &key ); if ( zvlBeast == NULL ) { - UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); COMN_PoolActiveUnlock( &zlssPool->ZLSSPOOLpool ); UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); COMN_Release( &zVolume ); @@ -9764,18 +9758,18 @@ Again: /* FixFixFix(LV,ACI,10) - what if this name matches one we have */ /** - * Because the volume is not ACTIVE we can not update - * the VDB (it is not in memory). Instead of writing a lot - * of code to read and write the VDB I will delay the update - * of the VLD volume ID until it is activated next. This is - * a little bad as the VDB's volume ID will be incorrect if - * re-link is run BEFORE the volume is ACTIVEd, but this will - * be very rare so ... - * Note that PZV_volumeID is simply a 'copy' of the volume - * ID that is stored in the Volume Locator Beast(VLB). The - * VLB copy is the copy that ZLSS uses. The VDB copy is meant - * for re-link if the VLB is destroyed. - */ + * Because the volume is not ACTIVE we can not update + * the VDB (it is not in memory). Instead of writing a lot + * of code to read and write the VDB I will delay the update + * of the VLD volume ID until it is activated next. This is + * a little bad as the VDB's volume ID will be incorrect if + * re-link is run BEFORE the volume is ACTIVEd, but this will + * be very rare so ... + * Note that PZV_volumeID is simply a 'copy' of the volume + * ID that is stored in the Volume Locator Beast(VLB). The + * VLB copy is the copy that ZLSS uses. The VDB copy is meant + * for re-link if the VLB is destroyed. + */ // zVolume->p.PZV_volumeID = zVolume->ZLSSVOLvolumeID; zVolume->ZLSSVOLvol.VOLpState = zVOL_PSTATE_DELETION; @@ -9793,7 +9787,7 @@ Again: UNX_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); if ( status != zOK ) { - UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); COMN_Release( &zvlBeast ); MSG_DestroyKey(key); COMN_PoolActiveUnlock( &zlssPool->ZLSSPOOLpool ); @@ -9805,20 +9799,20 @@ Again: COMN_Release( &zvlBeast ); MSG_DestroyKey(key); /*** At this point we have marked the ZLSS Volume Locator - *** beast in the deletion state. Sooner or later the - *** volume WILL BE deleted. - ***/ + *** beast in the deletion state. Sooner or later the + *** volume WILL BE deleted. + ***/ status = ZLSSVOL_LV_ZVLRename( genMsg, oldVolumeName, - names->newVolumeName, names->containerVolumeName ); + names->newVolumeName, names->containerVolumeName ); // COMN_EXCLUDE_INTERNAL_VOLUMES( genMsg ); if ( status != zOK ) { /* We can ignore the error because on re-load of the volume - * the load code will rename the ZVLB since the beast name - * will not match the name stored in it. - */ + * the load code will rename the ZVLB since the beast name + * will not match the name stored in it. + */ ClearErrno( genMsg ); reloadVolumeName = oldVolumeName; } @@ -9827,7 +9821,7 @@ Again: reloadVolumeName = names->newVolumeName; } - UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); + UNX_LATCH( &zVolume->ZFSVOLvol.cvsLatch ); /* X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); Had to remove this Latch * because it is illegal if WE have the pool locked active. It causes @@ -9845,11 +9839,11 @@ Again: } /*** Reload under new name (will be hidden file in _ADMIN as we - *** marked as internal volume). ZLSSVOL_LV_LoadByName will see - *** that the volume is in the DELETION state and go about deleting - *** the LV async. It will pass us an error so we ignore and tell - *** user we are done. - ***/ + *** marked as internal volume). ZLSSVOL_LV_LoadByName will see + *** that the volume is in the DELETION state and go about deleting + *** the LV async. It will pass us an error so we ignore and tell + *** user we are done. + ***/ zVolume = ZLSSVOL_LV_LoadByName( genMsg, names->containerVolumeName, reloadVolumeName, zlssPool, NULL); COMN_PoolActiveUnlock( &zlssPool->ZLSSPOOLpool ); @@ -9865,7 +9859,7 @@ Again: free( names ); return( zOK ); -} /* End of ZLSSVOL_LVD_DeleteAPIInternal() */ +} /* End of ZLSSVOL_LVD_DeleteAPIInternal() */ /************************************************************************** @@ -9898,8 +9892,8 @@ STATUS ZLSSVOL_LV_UnloadAll( } #endif /* - * Go through the link list of LVs that this pool owns and unload them. - */ + * Go through the link list of LVs that this pool owns and unload them. + */ for (;;) { DQ_DEQ(&zlssPool->ZP_Pool.P_VolumeList,volume,Volume_s,v_poolVolLink); @@ -9966,9 +9960,9 @@ STATUS ZLSSVOL_LV_Unload( GeneralMsg_s *genMsg, ZfsVolume_s *zVolume ) return( zFAILURE ); } /* Set unload bit so we can catch multiple unloads AND - * the so the common layer will prevent change volume - * states to higher states. - */ + * the so the common layer will prevent change volume + * states to higher states. + */ zVolume->ZLSSVOLvol.VOLv_statusFlag |= VOL_SF_UNLOADING; // zlssPool = (ZlssPool_s *)poolVolume->ZFSPOOLvol.v_pool; @@ -9983,15 +9977,15 @@ STATUS ZLSSVOL_LV_Unload( GeneralMsg_s *genMsg, ZfsVolume_s *zVolume ) #endif /* No one can find the volume, but some threads will already - * have a pointer to the Volume_s. They must also have a - * use count. We will change state to UNKNOWN (which will - * give threads a clue that they need to finish their work). - * - * Change the volume to a state that it can be unloaded from. - * Because we are going to a lower state the below function - * ensures that no errors are returned. Also we do not have - * user aborted set so user cannot abort. - */ + * have a pointer to the Volume_s. They must also have a + * use count. We will change state to UNKNOWN (which will + * give threads a clue that they need to finish their work). + * + * Change the volume to a state that it can be unloaded from. + * Because we are going to a lower state the below function + * ensures that no errors are returned. Also we do not have + * user aborted set so user cannot abort. + */ status = COMN_ChangeVolumeState(genMsg, &zVolume->ZFSVOLvol, zVOLSTATE_UNKNOWN, iVOLMODE_POOL_LACTHED ); zASSERT(status == zOK); @@ -10001,10 +9995,10 @@ STATUS ZLSSVOL_LV_Unload( GeneralMsg_s *genMsg, ZfsVolume_s *zVolume ) } /* By removing from the master volume link list we prevent - * this volume from being found. This prevents any new - * operations from starting which is a requirement since - * we will be freeing the volume soon. - */ + * this volume from being found. This prevents any new + * operations from starting which is a requirement since + * we will be freeing the volume soon. + */ if (QMEMBER(&zVolume->ZLSSVOLvol.masterVolLink)) { ZfsVolume_s *masterVolume = zVolume; @@ -10015,8 +10009,8 @@ STATUS ZLSSVOL_LV_Unload( GeneralMsg_s *genMsg, ZfsVolume_s *zVolume ) COMN_RemoveVolumeFromAllLists( &zVolume->ZLSSVOLvol ); /* Do up front so other threads will no longer be able - * to get to volume via DQI links. - */ + * to get to volume via DQI links. + */ dqi = zVolume->ZV_dqi; if ( dqi != NULL ) { @@ -10033,15 +10027,15 @@ STATUS ZLSSVOL_LV_Unload( GeneralMsg_s *genMsg, ZfsVolume_s *zVolume ) } /** I have removed the the call to WORK_WaitForPending() because - * when we delete a volume we qualify as a pending work thread - * and therefore causes the routine to return only after its - * timeout. In addition, it would appear to be a BAD idea to - * wait for all threads when most are working on OTHER volumes. - */ + * when we delete a volume we qualify as a pending work thread + * and therefore causes the routine to return only after its + * timeout. In addition, it would appear to be a BAD idea to + * wait for all threads when most are working on OTHER volumes. + */ COMN_Release(&zVolume); /* Callers use count. When use count goes to - * zero then the beast memory is freed. - */ + * zero then the beast memory is freed. + */ #if NSS_DEBUG IS_ENABLED STACK_FREE(); #endif @@ -10120,7 +10114,7 @@ STATUS ZVL_Rename( * zMAX_COMPONENT_NAME in length. * newVolumeName - New Logical Volume's name (unicode). Must be less * than zMAX_COMPONENT_NAME in length. - * containerVolume - Unicode name that ZLSS Volume Locator beast + * containerVolume - Unicode name that ZLSS Volume Locator beast * resides on. Must be less than zMAX_COMPONENT_NAME in length. * Note - * The ZVL beast is created with RENAME_INHIBIT so we must clear @@ -10139,7 +10133,7 @@ STATUS ZLSSVOL_LV_ZVLRename( EventLVolRenameEnter_s enterEvent; EventLVolRenameExit_s exitEvent; ZlssPool_s *zlssPool; - ZfsVolume_s *zVolume; + ZfsVolume_s *zVolume; enterEvent.enterExitID = exitEvent.enterExitID = ++EnterExitEventID; enterEvent.oldName = oldVolumeName; @@ -10147,12 +10141,12 @@ STATUS ZLSSVOL_LV_ZVLRename( // COMN_EXCLUDE_INTERNAL_VOLUMES( genMsg ); zVolume = (ZfsVolume_s *)COMN_VolumeNameLookup(genMsg, oldVolumeName, - FALSE, NULL); + FALSE, NULL); // COMN_INCLUDE_INTERNAL_VOLUMES( genMsg ); if ( zVolume == NULL ) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT, (LRED, - MSGNot("%s ZLSSVOL_LV_ZVLRename failed with %ld at %s\n"), + MSGNot("%s ZLSSVOL_LV_ZVLRename failed with %ld at %s\n"), WHERE, GetErrno( genMsg ),GetErrnoSetter( genMsg ))); return( zFAILURE ); } @@ -10162,7 +10156,7 @@ STATUS ZLSSVOL_LV_ZVLRename( COMN_Release( &zVolume ); SetErrno( genMsg, zERR_NOT_SUPPORTED ); DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT, (LRED, - MSGNot("%s ZLSSVOL_LV_ZVLRename failed with %ld at %s\n"), + MSGNot("%s ZLSSVOL_LV_ZVLRename failed with %ld at %s\n"), WHERE, GetErrno( genMsg ),GetErrnoSetter( genMsg ))); return( zFAILURE ); } @@ -10175,8 +10169,8 @@ STATUS ZLSSVOL_LV_ZVLRename( if (retCode != OPERATION_DENIED) { exitEvent.enterRetStatus = retCode; - status = ZLSSVOL_LV_ZVLRenameInternal(genMsg, oldVolumeName, - newVolumeName, containerVolumeName); + status = ZLSSVOL_LV_ZVLRenameInternal(genMsg, oldVolumeName, + newVolumeName, containerVolumeName); exitEvent.opRetCode = (status == zOK) ? zOK : GetErrno(genMsg); exitEvent.volName = (status == zOK) ? newVolumeName : oldVolumeName; COMN_SendNSSEvent(EVENT_LVolRename_Exit, &exitEvent, sizeof(exitEvent), &denyCode); @@ -10243,12 +10237,12 @@ STATUS ZLSSVOL_LV_ZVLRenameInternal( ASSERT_XLATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); /* FixFixFix(LV,ACI,11) - Should I rename Volume ID here - * so that if a snapshot breaks and the user has to rename - * volumes via ConsoleOne we can still load second pool's - * volumes. We have to have SOME WAY of changeing volume - * IDs or IDs on the two volume sets will conflict. It seems - * wrong to rename Volume ID when a volume name rename is done. - */ + * so that if a snapshot breaks and the user has to rename + * volumes via ConsoleOne we can still load second pool's + * volumes. We have to have SOME WAY of changeing volume + * IDs or IDs on the two volume sets will conflict. It seems + * wrong to rename Volume ID when a volume name rename is done. + */ unicpy( zvlBeast->ZVL_p.PZVL_volumeName, newVolumeName ); xaction = BeginXLocal(zvlBeast->ZVLfile.FILEvolume,BXL_DEFAULT); COMN_MARK_BEAST_XLOCAL( &zvlBeast->ZVLfile.FILEroot, &xaction->xaction ); @@ -10321,19 +10315,19 @@ STATUS ZLSSVOL_LVD_SubStateUpdate( { #if 0 /** If we are LOCAL then we need to worry about ZLSS UNDOing - * committed transactions on us. Since the update of the ZVL - * beast is not tied to the xactions that has completed - * a step we must wait until we are sure that this xactions - * will not be UNDOne. I.E. if our ZVL beast does not - * get UNDO with the previous xactions then we will think - * we can go to the next STEP (because ZVL Beast says so). - * This will only cause UNACCOUNTED BLOCKS error, but since - * we are in no real hurry to delete every bit of the - * LV we can just delay for a little bit. - */ + * committed transactions on us. Since the update of the ZVL + * beast is not tied to the xactions that has completed + * a step we must wait until we are sure that this xactions + * will not be UNDOne. I.E. if our ZVL beast does not + * get UNDO with the previous xactions then we will think + * we can go to the next STEP (because ZVL Beast says so). + * This will only cause UNACCOUNTED BLOCKS error, but since + * we are in no real hurry to delete every bit of the + * LV we can just delay for a little bit. + */ // for ( i = 0; i < 1*120; ++i ) // { -// LB_delay( 1 * (1000/5) ); +// LB_delay( 1 * (1000/5) ); // if ( ((ZfsVolume_s *)volume)->ZV_stopPurge ) // { // DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(MAGENTA, @@ -10363,7 +10357,7 @@ STATUS ZLSSVOL_LVD_SubStateUpdate( zASSERT( zvlBeast->ZVL_p.PZVL_subState == (newSubState-1) ); DEBUG_PRINTF(TLVDELETE,DBG_BOTH_NOINDENT,(MAGENTA, MSGNot("ZLSSVOL_LVD_SubStateUpdate() SETTING thread volume %U (Thread=%08x) substate from %d to %d\n"), - zvlBeast->ZVL_p.PZVL_volumeName, ThreadId(), + zvlBeast->ZVL_p.PZVL_volumeName, ThreadId(), zvlBeast->ZVL_p.PZVL_subState, newSubState)); zvlBeast->ZVL_p.PZVL_subState = newSubState; @@ -10396,8 +10390,8 @@ STATUS ZLSSVOL_LVD_DeleteStateUpdate( GeneralMsg_s *genMsg, ZlssVolumeLocator_s *zvlBeast, ZfsVolume_s *zVolume, /* Can be NULL unless new state is - * ZVL_DS_PURGEING_PAUSED - */ + * ZVL_DS_PURGEING_PAUSED + */ LONG newDeleteState ) { STATUS status; @@ -10411,7 +10405,7 @@ STATUS ZLSSVOL_LVD_DeleteStateUpdate( DEBUG_PRINTF(TLVDELETE,DBG_BOTH_NOINDENT,(CYAN, MSGNot("ZLSSVOL_LVD_DeleteStateUpdate() SETTING volume %U (Thread=%08x) delete state from %d to %d\n"), - zvlBeast->ZVL_p.PZVL_volumeName, ThreadId(), + zvlBeast->ZVL_p.PZVL_volumeName, ThreadId(), zvlBeast->ZVL_p.PZVL_deleteState, newDeleteState)); COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); @@ -10430,8 +10424,8 @@ STATUS ZLSSVOL_LVD_DeleteStateUpdate( case ZVL_DS_UNDELETE: ZLSSVOL_LVD_ErrorRecordClear( zvlBeast ); /* The scan thread does all the work when we enter the - * above persistent states. - */ + * above persistent states. + */ break; case ZVL_DS_PURGEING_PAUSED: @@ -10440,7 +10434,7 @@ STATUS ZLSSVOL_LVD_DeleteStateUpdate( ZLSSVOL_LVD_ErrorRecordClear( zvlBeast ); break; default: - DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (CYAN, + DEBUG_PRINTF(TLVDELETE,DBG_INDENT, (CYAN, MSGNot("ZLSSVOL_LVD_DeleteScanThread invalid PZVL_deleteState\n"))); break; } @@ -10454,14 +10448,14 @@ STATUS ZLSSVOL_LVD_DeleteStateUpdate( zvlBeast->ZVL_deleteStateChangeTime = GetUTCTime(); if ( status != zOK ) { /* On errors we do not restore delete state because - * it is better that the memory copy of beast does the - * state change. - */ + * it is better that the memory copy of beast does the + * state change. + */ ZLSSVOL_LVD_ErrorRecord( zvlBeast, &dummyGenMsg ); /* FYI - we just recorded an error without knowing - * that we are in an error state. This is the only place - * we do this. - */ + * that we are in an error state. This is the only place + * we do this. + */ } return( status ); @@ -10469,7 +10463,7 @@ STATUS ZLSSVOL_LVD_DeleteStateUpdate( void ZLSSVOL_LVD_DeleteUndeleteThread( - FsmLite_s *fsmLite, + FsmLite_s *fsmLite, ZLSSVOL_LVD_DeleteQueueInfo_t *dqi ) { @@ -10520,7 +10514,7 @@ void ZLSSVOL_LVD_DeleteUndeleteThread( */ void ZLSSVOL_LVD_DeletePurgeThread( - FsmLite_s *fsmLite, + FsmLite_s *fsmLite, ZLSSVOL_LVD_DeleteQueueInfo_t *dqi ) { @@ -10544,20 +10538,20 @@ void ZLSSVOL_LVD_DeletePurgeThread( zvlBeast = dqi->DQI_zvlBeast; /* We have an IN-USE count on beast, but - * this thread does NOT have a latch. We - * must release count when done with beast. - */ + * this thread does NOT have a latch. We + * must release count when done with beast. + */ zVolume = dqi->DQI_Dti.DTI_zVolume; /* We have an IN-USE count on beast, but - * this thread does NOT have a latch. We - * must release count when done with beast. - * We have an ACTIVE or DEACTIVE lock on - * volume (depends on required state - * on entry). We must release the lock - * before we complete. - */ + * this thread does NOT have a latch. We + * must release count when done with beast. + * We have an ACTIVE or DEACTIVE lock on + * volume (depends on required state + * on entry). We must release the lock + * before we complete. + */ poolVolume = dqi->DQI_Dti.DTI_poolVolume; /* We have an ACTIVE lock on it. - * We must release ACTIVE lock. - */ + * We must release ACTIVE lock. + */ verbose = dqi->DQI_Dti.DTI_verbose; zASSERT( poolVolume->ZFSPOOLvol.VOLv_keepActiveUseCount > 0 ); @@ -10651,9 +10645,9 @@ void ZLSSVOL_LVD_DeletePurgeThread( case PZVL_SS_DELETE_STEP_PLOG_MOVE: zASSERT( zVolume->ZLSSVOLvol.VOLv_keepActiveUseCount > 0 ); /** This next routine UNLOCKS both the VOL and POOL - ** ACTIVE locks. It will re-lock the POOLs ACTIVE - ** lock, but not the volumes. - **/ + ** ACTIVE locks. It will re-lock the POOLs ACTIVE + ** lock, but not the volumes. + **/ status = ZLSSVOL_LVD_MovePurgeLog( &genMsg, zVolume, zvlBeast ); zASSERT( zVolume->ZLSSVOLvol.VOLv_keepActiveUseCount == 0 ); if ( status != zOK ) @@ -10662,16 +10656,16 @@ void ZLSSVOL_LVD_DeletePurgeThread( } zASSERT( PZVL_SS_DELETE_STEP_PLOG_MOVE == PZVL_SS_DELETE_STEP_ACTIVATE ); /* The above ASSERT is needed so that we put the deactivate call - * below in the right place. In addition, a call to - * COMN_UnlockVolumeActive may need to be added or removed. - */ + * below in the right place. In addition, a call to + * COMN_UnlockVolumeActive may need to be added or removed. + */ (void)ZLSSVOL_LVD_ChangeVolumeStateWhenPoolLockedActive(&dummyGenMsg, zVolume, zVOLSTATE_DEACTIVE, mode ); ClearErrno( &dummyGenMsg ); /* Prevent someone from changing state on us. We will - * check for someone requesting a state change and will - * terminate our thread if detected. - */ + * check for someone requesting a state change and will + * terminate our thread if detected. + */ status = COMN_LockVolumeDeactive( &genMsg, &zVolume->ZLSSVOLvol ); if ( status != zOK ) { @@ -10686,7 +10680,7 @@ void ZLSSVOL_LVD_DeletePurgeThread( if ( status != zOK ) { COMN_UnlockVolumeDeactive( &zVolume->ZLSSVOLvol ); - break; + break; } /****************************/ /*** We will drop through ***/ @@ -10772,9 +10766,9 @@ void ZLSSVOL_LVD_DeletePurgeThread( /* All errors get recorded and we are not active purgeing */ switch ( GetErrno( &genMsg ) ) { /* The following errors are ignored as they are generally - * caused by the ADMIN doing a deactivate on the pool that - * has volumes being purged. - */ + * caused by the ADMIN doing a deactivate on the pool that + * has volumes being purged. + */ case zERR_VOLUME_STATE_CHANGE_REQUESTED: case zERR_VOLUME_STOP_REQUESTED: break; @@ -10792,23 +10786,23 @@ void ZLSSVOL_LVD_DeletePurgeThread( subState2 = zvlBeast->ZVL_p.PZVL_subState; UNX_LATCH( &zvlBeast->ZVLfile.FILEbeastLatch ); /** Must release zvlBeast here or we deadlock. This occurs when - * a NSS /PoolDeactivate caused our thread to notice that - * its volume is being deactivated. The same is TRUE with - * active count on 'poolVolume'. - */ + * a NSS /PoolDeactivate caused our thread to notice that + * its volume is being deactivated. The same is TRUE with + * active count on 'poolVolume'. + */ zvlBeast->ZVL_purgeThreadID = (ADDR)0; COMN_Release( &zvlBeast ); zVolumeName = NULL; /* Don't use as pointed into zvlBeast */ /* Update DQI_activePurgeing BEFORE release of volume - * as having our use count on volume ensures that DQI - * is still valid. - */ + * as having our use count on volume ensures that DQI + * is still valid. + */ dqi->DQI_activePurgeing = FALSE; ZLSS_DQI_UNUSE( dqi ); /* By releaseing resources here we allow a CVS that has - * caused us to stop the purge thread to complete and - * not wait for use to say we are done with the DQI. - */ + * caused us to stop the purge thread to complete and + * not wait for use to say we are done with the DQI. + */ COMN_UnlockVolumeActive( &poolVolume->ZFSPOOLvol, FALSE ); if ( subState2 < PZVL_SS_DELETE_STEP_ACTIVATE ) { @@ -10823,15 +10817,15 @@ void ZLSSVOL_LVD_DeletePurgeThread( MSGNot("LV delete thread exit volume (Thread=%08x)\n"), ThreadId() )); /* Update DQI_activePurgeing BEFORE release of volume - * as having our use count on volume ensures that DQI - * is still valid. - */ + * as having our use count on volume ensures that DQI + * is still valid. + */ // dqi->DQI_activePurgeing = FALSE; // ZLSS_DQI_UNUSE( dqi ); COMN_Release( &zVolume ); /** No cleanup of dqi here because we MUST keep it around - ** for status and possible re-attempt of purge. - **/ + ** for status and possible re-attempt of purge. + **/ --ZLSSVOL_LVD_PurgeThreadCount; return; @@ -10839,7 +10833,7 @@ void ZLSSVOL_LVD_DeletePurgeThread( /* - * ZLSSVOL_LVD_BTNodeValidate() - + * ZLSSVOL_LVD_BTNodeValidate() - * Validate leaf nodes in beast btree AND checks for a request for * a volume STATE change. * @@ -10868,14 +10862,14 @@ STATUS ZLSSVOL_LVD_BTNodeValidate( if ( zVolume->ZV_stopPurge ) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(MAGENTA, - MSGNot("ZV_stopPurge request - stopping LV delete (in BT)\n"))); + MSGNot("ZV_stopPurge request - stopping LV delete (in BT)\n"))); SetErrno( genMsg, zERR_VOLUME_STOP_REQUESTED ); return( zFAILURE ); } if ( zVolume->ZLSSVOLvol.v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP ) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(MAGENTA, - MSGNot("Deactivate request - stopping LV delete (in BT)\n"))); + MSGNot("Deactivate request - stopping LV delete (in BT)\n"))); SetErrno( genMsg, zERR_VOLUME_STATE_CHANGE_REQUESTED ); return( zFAILURE ); } @@ -10995,7 +10989,7 @@ STATIC STATUS ZLSSVOL_LVD_BTShrinkVisit( if ( ccode != zOK ) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(LRED, - MSGNot(">>>>Invalid Beast tree node %d\n"),blknum)); + MSGNot(">>>>Invalid Beast tree node %d\n"),blknum)); DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(LRED, MSGNot(" >>Current BT level %d\n"),*level)); (*level)--; @@ -11015,8 +11009,8 @@ STATIC STATUS ZLSSVOL_LVD_BTShrinkVisit( return( zFAILURE ); } /*** - *** The rest of this code is BRANCH node specific - ***/ + *** The rest of this code is BRANCH node specific + ***/ if ( *level == (leafLevel - 1) ) { xaction = BeginXLocal( beastTree->ZFSBEASTTREEfile.FILEvolume, @@ -11027,11 +11021,11 @@ STATIC STATUS ZLSSVOL_LVD_BTShrinkVisit( childBlock = nodeParent->n.branch[i].child; if ( *level == (leafLevel - 1) ) { /* On the last branch level so update branch - * and free the leaves it points to. We check - * for invalid blocks just in case. SHould not see any - * as if we crash we use ONE xaction for each branch - * shrink. No harm in checking! - */ + * and free the leaves it points to. We check + * for invalid blocks just in case. SHould not see any + * as if we crash we use ONE xaction for each branch + * shrink. No harm in checking! + */ if ( childBlock != INVALID_BLK ) { ZfsXasRecovery_s *logBuffer; @@ -11047,10 +11041,10 @@ STATIC STATUS ZLSSVOL_LVD_BTShrinkVisit( ZLOG_INIT_LOG_RECORD(XFUNC_LV_BT_SHRINK, xaction, logBuffer, 2, poolBlks, logRecord); /* Because we do not modify block that is being deleted - * we really do not need to store informaiton about - * it. We will just to have info in ZLOG. Note that - * REDO/UNDO does not look at the block being deleted. - */ + * we really do not need to store informaiton about + * it. We will just to have info in ZLOG. Note that + * REDO/UNDO does not look at the block being deleted. + */ ZLOG_ASSIGN_BLOCK_INFO( poolBlks[0], childBlock, 0/*prev lsn*/, NULL/*buffer_s*/, xaction, 0); ZLOG_DELETE_BLOCK( xaction, poolBlks[0]); @@ -11093,7 +11087,7 @@ STATIC STATUS ZLSSVOL_LVD_BTShrinkVisit( } } ccode = zOK; - + VISIT_DONE: if ( *level == (leafLevel - 1) ) { @@ -11255,7 +11249,7 @@ STATIC STATUS ZLSSVOL_LVD_BTDepthVisitRight( if ( status != zOK) { DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(LRED, - MSGNot(">>>>Invalid Beast tree node %d\n"),blknum)); + MSGNot(">>>>Invalid Beast tree node %d\n"),blknum)); DEBUG_PRINTF(TLVDELETE,DBG_NOINDENT,(LRED, MSGNot(" >>Current BT level %d\n"),*depth)); return( zFAILURE ); @@ -11265,23 +11259,23 @@ STATIC STATUS ZLSSVOL_LVD_BTDepthVisitRight( { case LEAF_MAGIC: /* Normal depth detection when the real leaves - * are still present in the B-Tree. - */ + * are still present in the B-Tree. + */ return( zOK ); case BRANCH_MAGIC: if ( node->numRecs == 0 ) { /* Should not occur, but better than an - * abend on [0-1]. - */ + * abend on [0-1]. + */ zASSERT("BT branch bad"==NULL); return( zOK ); } childBlock = node->n.branch[node->numRecs - 1].child; if ( (childBlock == INVALID_BLK) || (childBlock == 0) ) { /* Normal depth detection when the real leaves - * have already been pruned from the B-Tree. - */ + * have already been pruned from the B-Tree. + */ return( zOK ); } READBLK_IO_MSG(iomsg, beastTree, childBlock, CACHE_READ); @@ -11399,10 +11393,10 @@ STATUS ZLSSVOL_LVD_ShrinkRoot( bTree->p.btRoot = INVALID_BLK; localXaction = BeginXLocal( bTree->ZFSBTREEfile.FILEvolume, BXL_DEFAULT ); COMN_MARK_BEAST_XLOCAL(&bTree->ZFSBTREEroot, &localXaction->xaction); - if (COMN_ForceBeastWrite(genMsg, &bTree->ZFSBTREEroot, - &localXaction->xaction) != zOK) + if (COMN_ForceBeastWrite(genMsg, &bTree->ZFSBTREEroot, + &localXaction->xaction) != zOK) { - EndXlocal(localXaction); + EndXlocal(localXaction); return( zFAILURE ); } @@ -11441,14 +11435,14 @@ STATUS ZLSSVOL_LVD_RecoveryBTShrink( poolBlks = ZLOG_START_OF_POOL_BLOCKS(logBuffer); /* Since poolBlks[0] is the block we deleted and - * because we did nothing to it on delete we do the - * same here. - */ + * because we did nothing to it on delete we do the + * same here. + */ if (ZLOG_VALID_BLOCK(poolBlks[1])) { /* Update the parent entry that pointed to the - * block we deleted. - */ + * block we deleted. + */ READBLK_IO_MSG(iomsg, pool, poolBlks[1].blkNum, CACHE_UPDATE) if ((buffer = ZFS_ReadPoolBlk(genMsg, &iomsg)) == NULL) { @@ -11504,9 +11498,9 @@ STATUS ZLSSVOL_LVD_RecoveryBTShrinkRoot( ENTER(TZVOL,ZLSSVOL_LVD_RecoveryBTShrink); /* Since poolBlks[0] is the block we deleted and - * because we did nothing to it on delete we do the - * same here. - */ + * because we did nothing to it on delete we do the + * same here. + */ RTN_STATUS(zOK); } /* End of ZLSSVOL_LVD_RecoveryBTShrinkRoot() */ @@ -11559,23 +11553,23 @@ STATUS ZLSSPOOL_WriteInitialPDB( /* This is the PACK code for a Pool (NON-logged data) */ memcpy( &poolBlock->ZPB_pool, &zlssPool->ZLSSPOOLpool.p, - sizeof(poolBlock->ZPB_pool) /* - + sizeof(poolBlock->ZPB_pool) /* - sizeof(zlssPool->ZLSSPOOLpool.p.PP_reserved) */); /* Calculate the checksum in the BLOCK because all - * of the non-logged data is next to each other AND it will - * be used to fill in the Log Record. NOTE - that the checksum - * includes the reserved fields that ARE NOT part of the PACKs - * above. I changed this so that we get clean log records AND - * a corect checksum! - */ + * of the non-logged data is next to each other AND it will + * be used to fill in the Log Record. NOTE - that the checksum + * includes the reserved fields that ARE NOT part of the PACKs + * above. I changed this so that we get clean log records AND + * a corect checksum! + */ poolBlock->ZPB_zlssPool.PZP_checksum = 0; - checksum = ZLSSPOOL_CalculateChecksum((LONG*)poolBlock,sizeof(*poolBlock)/4 ); + checksum = ZLSSPOOL_CalculateChecksum((LONG*)poolBlock,sizeof(*poolBlock)/4 ); poolBlock->ZPB_zlssPool.PZP_checksum = 0 - checksum; /* This is not really required because the logged - * write uses the VolumeData buffer and not in - * memory copy for its writes. I set the IN-MEMORY - * checksum just because it feels right! - */ + * write uses the VolumeData buffer and not in + * memory copy for its writes. I set the IN-MEMORY + * checksum just because it feels right! + */ zlssPool->ZP_p.PZP_checksum = 0 - checksum; if ( xaction != NULL ) @@ -11596,16 +11590,16 @@ STATUS ZLSSPOOL_WriteInitialPDB( /* LSN is not used because this is an ALLOCed block */ /* node->lsn = logBuffer->ZXR_Lsn; */ /* I use zlssPool and not data so that the reserved fields - * are zero. This makes the Log Record cleaner when viewing - * with ZLOG ZAD utility. THIS IS NOT FLY as checksum is not - * correct then!!! I elected to PACK all of the reserved items - * in this code. - */ - zASSERT( sizeof( logRecord->ZPB_zlssPool ) == sizeof(poolBlock->ZPB_zlssPool) ); + * are zero. This makes the Log Record cleaner when viewing + * with ZLOG ZAD utility. THIS IS NOT FLY as checksum is not + * correct then!!! I elected to PACK all of the reserved items + * in this code. + */ + zASSERT( sizeof( logRecord->ZPB_zlssPool ) == sizeof(poolBlock->ZPB_zlssPool) ); memcpy( &logRecord->ZPB_zlssPool, &poolBlock->ZPB_zlssPool, sizeof(poolBlock->ZPB_zlssPool) ); - zASSERT( sizeof( logRecord->ZPB_pool ) == sizeof(poolBlock->ZPB_pool) ); + zASSERT( sizeof( logRecord->ZPB_pool ) == sizeof(poolBlock->ZPB_pool) ); memcpy( &logRecord->ZPB_pool, &poolBlock->ZPB_pool, sizeof(poolBlock->ZPB_pool) ); @@ -11663,7 +11657,7 @@ STATUS ZLSSPOOL_WriteInitialLPDB( /* This is the PACK code for a Pool (logged data) */ memcpy( &poolBlock->ZLPB_pool, &zlssPool->ZLSSPOOLpool.logged, - sizeof(poolBlock->ZLPB_pool) - + sizeof(poolBlock->ZLPB_pool) - sizeof(zlssPool->ZLSSPOOLpool.logged.LPP_reserved) ); if ( xaction != NULL ) @@ -11684,14 +11678,14 @@ STATUS ZLSSPOOL_WriteInitialLPDB( /* LSN is not used because this is an ALLOCed block */ /* node->lsn = logBuffer->ZXR_Lsn; */ /* I use zlssPool and not data so that the reserved fields - * are zero. This makes the Log Record cleaner when viewing - * with ZLOG ZAD utility. - */ - zASSERT( sizeof( logRecord->ZLPB_zlssPool ) == sizeof(zlssPool->ZP_logged) ); + * are zero. This makes the Log Record cleaner when viewing + * with ZLOG ZAD utility. + */ + zASSERT( sizeof( logRecord->ZLPB_zlssPool ) == sizeof(zlssPool->ZP_logged) ); memcpy( &logRecord->ZLPB_zlssPool, &zlssPool->ZP_logged, sizeof(zlssPool->ZP_logged) ); - zASSERT( sizeof( logRecord->ZLPB_pool ) == sizeof(zlssPool->ZLSSPOOLpool.logged) ); + zASSERT( sizeof( logRecord->ZLPB_pool ) == sizeof(zlssPool->ZLSSPOOLpool.logged) ); memcpy( &logRecord->ZLPB_pool, &zlssPool->ZLSSPOOLpool.logged, sizeof(zlssPool->ZLSSPOOLpool.logged) ); @@ -11705,7 +11699,7 @@ STATUS ZLSSPOOL_WriteInitialLPDB( CACHE_DIRTY_RELEASE(poolBuffer); RTN_STATUS(zOK); -} /* End of ZLSSPOOL_WriteInitialLPDB() */ +} /* End of ZLSSPOOL_WriteInitialLPDB() */ /* @@ -11735,15 +11729,15 @@ STATUS ZLSSVOL_LV_AutoRenameVolumeAndID( { STATUS status; int retry; /* Number of time MORE we should - * call LB_GUIDTimeToShortVolumeName - * before giving up. - */ + * call LB_GUIDTimeToShortVolumeName + * before giving up. + */ NINT mangleKey; /* Number of times we have tried to get - * a good name for the volume. If - * we are unable to get a good name then - * we will try LB_GUIDTimeToShortVolumeName - * to generate a name. - */ + * a good name for the volume. If + * we are unable to get a good name then + * we will try LB_GUIDTimeToShortVolumeName + * to generate a name. + */ zASSERT( 16 <= nElemsVolName ); @@ -11753,9 +11747,9 @@ STATUS ZLSSVOL_LV_AutoRenameVolumeAndID( Again: if ( (mangleKey > MAX_MANGLE) || deletedVolume ) { /* Deleted volumes get standard GUID name AND - * non-deleted files that have failed mangle - * AutoRename name too many times. - */ + * non-deleted files that have failed mangle + * AutoRename name too many times. + */ LB_GUIDGenerate( volID ); status = LB_GUIDTimeToShortVolumeName( volID, nElemsVolName, volName ); @@ -11855,9 +11849,9 @@ STATUS ZLSSVOL_LV_AutoRename( return( zOK ); } /* Someone is aware of volume, the most likily cause is - * that the volume has been previousily loaded. In which - * case we do NOT want to rename. - */ + * that the volume has been previousily loaded. In which + * case we do NOT want to rename. + */ /* See if volume indicated by zvlBeast is already loaded by NSS */ volume = COMN_VolumeNameLookup( genMsg, zvlBeast->ZVL_p.PZVL_volumeName, FALSE, NULL ); @@ -11871,11 +11865,11 @@ STATUS ZLSSVOL_LV_AutoRename( loadingPool = ZFS_POOL_TO_POOL( poolVolume ); if ( volume->v_pool == loadingPool ) { /* The volume is on the same pool as we are attempting to - * load the current volume from. We assume that it is - * the same volume. This means that if a pool gets - * two volumes by the same name that we load only one - * and NOT rename the other. - */ + * load the current volume from. We assume that it is + * the same volume. This means that if a pool gets + * two volumes by the same name that we load only one + * and NOT rename the other. + */ COMN_Release( &volume ); #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(CYAN,"ZLSSVOL_LV_AutoRename - Load but same volume exit %s\n",WHERE); @@ -11886,12 +11880,12 @@ STATUS ZLSSVOL_LV_AutoRename( } /* A different volume with the SAME name has already - * been loaded so we will 'auto rename' the volume - * being loaded. The zvlBeast name will be updated - * later in ZLSSVOL_LV_Load via a call to the function - * ZLSSVOL_RenameZVLBAsync when ZLSSVOL_LV_Load detects - * the volume name does not match the zvlBeast name. - */ + * been loaded so we will 'auto rename' the volume + * being loaded. The zvlBeast name will be updated + * later in ZLSSVOL_LV_Load via a call to the function + * ZLSSVOL_RenameZVLBAsync when ZLSSVOL_LV_Load detects + * the volume name does not match the zvlBeast name. + */ #if NSS_DEBUG IS_ENABLED DBG_DebugPrintf(CYAN,"ZLSSVOL_LV_AutoRename - LV is being 'auto renamed'\n"); @@ -11912,12 +11906,12 @@ STATUS ZLSSVOL_LV_AutoRename( return( zFAILURE ); } /** - * Save off 'auto rename' items. ONLY if they have not - * been saved off before. This is done as most likily - * the best original name is the first time we auto renamed. - * If we go crazy and rename a volume 20 times I do not - * think they want the previous name of the volume. - */ + * Save off 'auto rename' items. ONLY if they have not + * been saved off before. This is done as most likily + * the best original name is the first time we auto renamed. + * If we go crazy and rename a volume 20 times I do not + * think they want the previous name of the volume. + */ zvlBeast->ZVL_p.PZVL_timeAutoRename = GetUTCTime(); if ( zvlBeast->ZVL_p.PZVL_timeAutoRenameFirst == 0 ) { @@ -11928,14 +11922,14 @@ STATUS ZLSSVOL_LV_AutoRename( sizeof( zvlBeast->ZVL_p.PZVL_volumeNameAutoRename ) ); } /** - * Replace old name and id with new name and id. - */ + * Replace old name and id with new name and id. + */ zASSERT( sizeof(zvlBeast->ZVL_p.PZVL_volumeName) == sizeof(newVolName) ); memcpy( zvlBeast->ZVL_p.PZVL_volumeName, newVolName, sizeof(zvlBeast->ZVL_p.PZVL_volumeName) ); zvlBeast->ZVL_p.PZVL_volumeID = newVolID; /** - * Write out modified locator beast. - */ + * Write out modified locator beast. + */ xaction = BeginXLocal(zvlBeast->ZVLfile.FILEvolume,BXL_DEFAULT); COMN_MARK_BEAST_XLOCAL( &zvlBeast->ZVLfile.FILEroot, &xaction->xaction ); @@ -11952,3 +11946,4 @@ STATUS ZLSSVOL_LV_AutoRename( #endif } /* End of ZLSSVOL_LV_AutoRename() */ + diff --git a/src/nwnss/zlss/zlssLogicalVolume.h b/src/nwnss/zlss/zlssLogicalVolume.h index e18b907..8ca43ad 100644 --- a/src/nwnss/zlss/zlssLogicalVolume.h +++ b/src/nwnss/zlss/zlssLogicalVolume.h @@ -40,7 +40,7 @@ #define _ZLSSLOGICALVOLUME_H_ #ifndef _XCACHE_H_ -#include +#include #endif #ifndef _COMNBEASTS_H_ @@ -65,32 +65,32 @@ struct ZLSSVOL_ZVL_RenameInfo_t; struct Node_s; struct BeastTreeNode_s; - /* Information about bitmaps used to ensure that the Purge Log - * is not hooked into itself. Used to prevent hangs. - */ + /* Information about bitmaps used to ensure that the Purge Log + * is not hooked into itself. Used to prevent hangs. + */ #ifndef HAVE_BLOCK_MAP_s #define HAVE_BLOCK_MAP_s typedef struct BlockMap_s { - char *BM_Startup; /* Who allocated (I.E. WHERE macro) */ - char *BM_Shutdown; /* Who allocated (I.E. WHERE macro) */ - Blkcnt_t BM_NumberOfBits; /* Number of bits in map */ - NINT *BM_Map; /* Actual bitmap */ + char *BM_Startup; /* Who allocated (I.E. WHERE macro) */ + char *BM_Shutdown; /* Who allocated (I.E. WHERE macro) */ + Blkcnt_t BM_NumberOfBits; /* Number of bits in map */ + NINT *BM_Map; /* Actual bitmap */ } BlockMap_s; - // - // Caller must ensure that bitmap is legal and block is within - // range before using this MACROS. - // + // + // Caller must ensure that bitmap is legal and block is within + // range before using this MACROS. + // #define BM_TST_BIT( _bitMap, _blockNum ) (TST_BIT( (_bitMap)->BM_Map, _blockNum )) #define BM_SET_BIT( _bitMap, _blockNum ) (SET_BIT( (_bitMap)->BM_Map, _blockNum )) #define BM_CLR_BIT( _bitMap, _blockNum ) (CLR_BIT( (_bitMap)->BM_Map, _blockNum )) #define BM_XOR_BIT( _bitMap, _blockNum ) (XOR_BIT( (_bitMap)->BM_Map, _blockNum )) #endif - /* The zVOL_LV_DELETE_ACTION_xxx defines can not be redefined. This - * values are hard coded into the XML files used to export this - * API to clients. - */ + /* The zVOL_LV_DELETE_ACTION_xxx defines can not be redefined. This + * values are hard coded into the XML files used to export this + * API to clients. + */ #define zVOL_LV_DELETE_ACTION_SALVAGE 1 #define zVOL_LV_DELETE_ACTION_PAUSE 2 #define zVOL_LV_DELETE_ACTION_CONTINUE 3 @@ -99,9 +99,9 @@ typedef struct BlockMap_s { #define AIPU_1ST_6PACK_MEDIA_VERSION 39 - /* Major number that LV upgrade uses. */ + /* Major number that LV upgrade uses. */ #define AIPU_LV_MEDIA_MAJOR 40 - /* Minor number that step finishes in */ + /* Minor number that step finishes in */ #define AIPU_LV_STEP_1_DONE 2 #define AIPU_LV_STEP_2A_DONE 3 #define AIPU_LV_STEP_2B_DONE 4 @@ -113,13 +113,13 @@ typedef struct BlockMap_s { #define AIPU_LV_STEP_PVPL_DONE AIPU_LV_STEP_2A_DONE /* Pool's Volume Purge Log exists */ - /* We start with LV version 35 because the first release of ZLSS - * used version 34.00 for the media version of the POOL/Volume. - * Note that the POOL media version and the LV media version - * are not the same. The POOL version is stored in the superblock - * and the Pool Data Block (PDB). The LV version is stored in - * the Volume Data Block(VDB). - */ + /* We start with LV version 35 because the first release of ZLSS + * used version 34.00 for the media version of the POOL/Volume. + * Note that the POOL media version and the LV media version + * are not the same. The POOL version is stored in the superblock + * and the Pool Data Block (PDB). The LV version is stored in + * the Volume Data Block(VDB). + */ #define ZLSS_LV_MEDIA_MAJOR 35 /* The LOGICAL VOLUME media version */ #define ZLSS_LV_MEDIA_MINOR 0 @@ -132,69 +132,69 @@ typedef struct BlockMap_s { #endif - /* Postfix added to the name of a LV that is being - * deleted. We go with a short name so that it will - * not cause NSS /volumes or NSS /Pools a problem. - */ + /* Postfix added to the name of a LV that is being + * deleted. We go with a short name so that it will + * not cause NSS /volumes or NSS /Pools a problem. + */ #define ZLSSVOL_DELETE_NAME_UNICODE MSGNot(L"_DV") - /* Directory name that all ZLSS Volume Locator beasts are stored. */ + /* Directory name that all ZLSS Volume Locator beasts are stored. */ #define ZLSSVOL_DIRECTORY_UNICODE MSGNot(L"LogicalVolumes") #define ZLSSVOL_DIRECTORY_NAME_UNICODE MSGNot(L"LogicalVolumes/") - /* Name used to create a temporary unique logical volume used - * when upgrading a ZfsPool_s into the Logical Volume world. We - * do not use the pool name because this would cause two volumes - * to have the same name during step 2 of AIPU. - */ + /* Name used to create a temporary unique logical volume used + * when upgrading a ZfsPool_s into the Logical Volume world. We + * do not use the pool name because this would cause two volumes + * to have the same name during step 2 of AIPU. + */ #define ZLSSVOL_IPU_NAME_UNIQUE MSGNot(L"_BIPHIUQVUNE_BIPHIUQVUNE_") typedef struct PersistentZlssVolumeLocator_s { - LONG PZVL_signature; - /* Signature that identifies this is a ZLSS Volume - * locator beast. Can be used by zrepair and - * debug/ASSERT. The signature is 'ZVL ' on Little - * Endian CPUs. - */ - WORD PZVL_versionMajor; - /* The major version of the ZVL file. Changes when - * ZLV is no longer compatible with an older version - * of the ZLV file. The first release will have this - * set to 1. - */ - WORD PZVL_versionMinor; - /* The minor version of the ZVL file. Changes when - * old ZLSS are still compatible. This will be 0 in the - * first release. - */ - /* The next three items must match the values that are - * stored in the PersistentZfsVolume_s area of the - * ZfsVolume area. - */ - SQUAD PZVL_loggedVolumeDataBlk; - SQUAD PZVL_volumeDataBlk; - SQUAD PZVL_systemBeastBlkNum; - VolumeID_t PZVL_volumeID; + LONG PZVL_signature; + /* Signature that identifies this is a ZLSS Volume + * locator beast. Can be used by zrepair and + * debug/ASSERT. The signature is 'ZVL ' on Little + * Endian CPUs. + */ + WORD PZVL_versionMajor; + /* The major version of the ZVL file. Changes when + * ZLV is no longer compatible with an older version + * of the ZLV file. The first release will have this + * set to 1. + */ + WORD PZVL_versionMinor; + /* The minor version of the ZVL file. Changes when + * old ZLSS are still compatible. This will be 0 in the + * first release. + */ + /* The next three items must match the values that are + * stored in the PersistentZfsVolume_s area of the + * ZfsVolume area. + */ + SQUAD PZVL_loggedVolumeDataBlk; + SQUAD PZVL_volumeDataBlk; + SQUAD PZVL_systemBeastBlkNum; + VolumeID_t PZVL_volumeID; - LONG PZVL_state; + LONG PZVL_state; #define PZVL_S_CREATION_DELETE 0 /* Volume is being created, but if at load - * time we find such a Volume Locator - * beast we should not continue - * volume creation. - */ + * time we find such a Volume Locator + * beast we should not continue + * volume creation. + */ #define PZVL_S_CREATION 1 /* Volume is being created. - * This will have to delete also because - * we may have gotten some wierd error - * and therefore should remove the LV - * as error may occur again and again. - */ + * This will have to delete also because + * we may have gotten some wierd error + * and therefore should remove the LV + * as error may occur again and again. + */ #define PZVL_S_CREATED 2 /* Volume is created (this is the normal - * state of a LV) - */ + * state of a LV) + */ #define PZVL_S_DELETION 3 /* Volume is being deleted */ - LONG PZVL_subState; /* Sub-state of the state. */ + LONG PZVL_subState; /* Sub-state of the state. */ /* Sub-States of PZVL_S_DELETION */ #define PZVL_SS_DELETE_SALVAGEABLE 0 @@ -208,229 +208,229 @@ typedef struct PersistentZlssVolumeLocator_s { #define PZVL_SS_DELETE_STEP_DELETE_ZVLB 8 #define PZVL_SS_DELETE_STEP_ACTIVATE PZVL_SS_DELETE_STEP_PLOG_MOVE - /* The above define is used to determine if a LV in - * the PZVL_S_DELETION state should be left in the - * deactive state or activated. All sub states LESS THAN - * OR EQUAL must activate the volume EXCEPT for - * PZVL_SS_DELETE_SALVAGEABLE which is in its own world. - */ + /* The above define is used to determine if a LV in + * the PZVL_S_DELETION state should be left in the + * deactive state or activated. All sub states LESS THAN + * OR EQUAL must activate the volume EXCEPT for + * PZVL_SS_DELETE_SALVAGEABLE which is in its own world. + */ - GUID_t PZVL_internalID; - /* This is the GUID that is written to every ZLSS - * system block. We no longer use the Volume's - * ID as it may change. For example, when a mirror - * is split apart into two pools. The internal - * ID is initially set to the volume ID, but it - * then never changes. - */ - VolumeID_t PZVL_volumeIDOriginal; - /* GUID of volume before it was deleted. */ - unicode_t PZVL_volumeName[64]; - /* By storing the name inside the Volume Location beast - * we do not need to worry if the volume location beast's - * name is the same as the LV. This allows the volume - * location beast to be renamed without effecting the - * name of the logical volume. Although, at LOAD time - * we will rename the ZVL Beast to agree with this - * item. This is REQUIRED because we use the volume - * name to lookup the ZVL Beast in LV rename and LV - * delete. - */ + GUID_t PZVL_internalID; + /* This is the GUID that is written to every ZLSS + * system block. We no longer use the Volume's + * ID as it may change. For example, when a mirror + * is split apart into two pools. The internal + * ID is initially set to the volume ID, but it + * then never changes. + */ + VolumeID_t PZVL_volumeIDOriginal; + /* GUID of volume before it was deleted. */ + unicode_t PZVL_volumeName[64]; + /* By storing the name inside the Volume Location beast + * we do not need to worry if the volume location beast's + * name is the same as the LV. This allows the volume + * location beast to be renamed without effecting the + * name of the logical volume. Although, at LOAD time + * we will rename the ZVL Beast to agree with this + * item. This is REQUIRED because we use the volume + * name to lookup the ZVL Beast in LV rename and LV + * delete. + */ - /*******************************************/ - /*** Information about DELETE of the LV ****/ - /*******************************************/ - Time_t PZVL_deleteTimeStart; /* When we initially started - * the LV delete. Used as FYI and - * to determine if LV is still SALVAGEABLE. - */ + /*******************************************/ + /*** Information about DELETE of the LV ****/ + /*******************************************/ + Time_t PZVL_deleteTimeStart; /* When we initially started + * the LV delete. Used as FYI and + * to determine if LV is still SALVAGEABLE. + */ - LONG PZVL_deleteState; + LONG PZVL_deleteState; #define ZVL_DS_SALVAGEABLE 0 /* Waiting for purge time */ #define ZVL_DS_PURGEING 1 /* LV is being purged. May not mean being - * activily purged as we only have 5 - * threads and the scan thread may have - * not seen in this new STATE. See - * ZVL_purgeThreadID for more information. - */ + * activily purged as we only have 5 + * threads and the scan thread may have + * not seen in this new STATE. See + * ZVL_purgeThreadID for more information. + */ #define ZVL_DS_PURGEING_PAUSED 2 /* Paused by user AFTER purge started */ #define ZVL_DS_SALVAGEABLE_PAUSED 3 /* Paused by user BEFORE purge started */ #define ZVL_DS_PURGE_ERROR 4 /* Last purge did not complete */ #define ZVL_DS_UNDELETE 5 /* Thread actively undeleting LV. */ #define ZVL_DS_UNDELETE_ERROR 6 /* Last undelete did not complete */ #define ZVL_DS_SALVAGED 7 /* LV has been salvaged. This state is - * really brief, because as soon as - * we enter it we schedule a thread - * to remove LV for the dqi. - */ + * really brief, because as soon as + * we enter it we schedule a thread + * to remove LV for the dqi. + */ #define ZVL_DS_UNKNOWN 8 /* Unknown state (should not happen - * but UI uses. - */ + * but UI uses. + */ - unicode_t PZVL_volumeNameOriginal[64]; - /* This is the name the volume had before we started - * to delete it. - */ - LONG PZVL_errno; - char PZVL_errnoSetter[48]; /* The LAST 48 characters of - * errno setter. Includes a NULL. - */ + unicode_t PZVL_volumeNameOriginal[64]; + /* This is the name the volume had before we started + * to delete it. + */ + LONG PZVL_errno; + char PZVL_errnoSetter[48]; /* The LAST 48 characters of + * errno setter. Includes a NULL. + */ - /*****************************************/ - /*** ***/ - /*** Information about PURGE of the LV ***/ - /*** ***/ - /*****************************************/ - Time_t PZVL_purgeTimeStart; /* When we initially started purgeing - * the LV. Used for FYI. - */ - Time_t PZVL_purgeTimeLastStart; - Time_t PZVL_purgeTimeLastEnd; - SQUAD PZVL_purgeLogBlocks; /* Used by LV delete to store - * the chain of purge log blocks so - * that they can be deleted AFTER - * the volume has been deactivated and - * destroyed for the last time. This - * is done so that we KNOWN that the - * purge log is not being used (I.E. - * deactivate waits for things to clean up). - */ - Zid_t PZVL_lastZidTruncated; + /*****************************************/ + /*** ***/ + /*** Information about PURGE of the LV ***/ + /*** ***/ + /*****************************************/ + Time_t PZVL_purgeTimeStart; /* When we initially started purgeing + * the LV. Used for FYI. + */ + Time_t PZVL_purgeTimeLastStart; + Time_t PZVL_purgeTimeLastEnd; + SQUAD PZVL_purgeLogBlocks; /* Used by LV delete to store + * the chain of purge log blocks so + * that they can be deleted AFTER + * the volume has been deactivated and + * destroyed for the last time. This + * is done so that we KNOWN that the + * purge log is not being used (I.E. + * deactivate waits for things to clean up). + */ + Zid_t PZVL_lastZidTruncated; - /********************************************/ - /*** ***/ - /*** Information about SNAPSHOT of the LV ***/ - /*** ***/ - /*** Added in version 3.0 of ZVLBeast ***/ - /*** ***/ - /********************************************/ + /********************************************/ + /*** ***/ + /*** Information about SNAPSHOT of the LV ***/ + /*** ***/ + /*** Added in version 3.0 of ZVLBeast ***/ + /*** ***/ + /********************************************/ + + GUID_t PZVL_snapshotID; /* Unique ID given to a 'snapshot'. Used + * by ZLSS to see if a volume needs a + * snapshot. A snapshot is done if + * this GUID does not match the POOL's + * snapshot GUID. Ofcourse, the POOL + * must also have ZP_Snapshot set to + * TRUE. + */ - GUID_t PZVL_snapshotID; /* Unique ID given to a 'snapshot'. Used - * by ZLSS to see if a volume needs a - * snapshot. A snapshot is done if - * this GUID does not match the POOL's - * snapshot GUID. Ofcourse, the POOL - * must also have ZP_Snapshot set to - * TRUE. - */ + /********************************************/ + /*** ***/ + /*** The below information is only valid ***/ + /*** if PZVL_snapshotID is the same as ***/ + /*** the pool's snapshot ID. ***/ + /*** ***/ + /********************************************/ + VolumeID_t PZVL_volumeIDSnapshot; + /* Volume ID of volume before 'snapshot' + * taken. This MAY be useful for + * user interfaces. If this is ZERO + * then volume was created after the + * snapshot was taken. + */ + VolumeID_t PZVL_volumeIDOriginalSnapshot; + /* Original volume ID of volume before + * 'snapshot' taken. This only applies + * to deleted volumes. + */ - /********************************************/ - /*** ***/ - /*** The below information is only valid ***/ - /*** if PZVL_snapshotID is the same as ***/ - /*** the pool's snapshot ID. ***/ - /*** ***/ - /********************************************/ - VolumeID_t PZVL_volumeIDSnapshot; - /* Volume ID of volume before 'snapshot' - * taken. This MAY be useful for - * user interfaces. If this is ZERO - * then volume was created after the - * snapshot was taken. - */ - VolumeID_t PZVL_volumeIDOriginalSnapshot; - /* Original volume ID of volume before - * 'snapshot' taken. This only applies - * to deleted volumes. - */ + unicode_t PZVL_volumeNameSnapshot[64]; + /* Volume name of volume before 'snapshot' + * taken. This MAY be useful for + * user interfaces. + */ - unicode_t PZVL_volumeNameSnapshot[64]; - /* Volume name of volume before 'snapshot' - * taken. This MAY be useful for - * user interfaces. - */ + LONG PZVL_stateSnapshot; + /* PZVL_state at time the snapshot was + * taken. Useful in determining that + * PZVL_volumeNameSnapshot is a deleted + * name and that + * PZVL_volumeNameOriginalSnapshot is + * the name prior to deletion. + */ + unicode_t PZVL_volumeNameOriginalSnapshot[64]; + /* Original volume name of volume before + * 'snapshot' taken. This only applies + * to deleted volumes. + */ + /********************************************/ + /*** End OF ***/ + /*** Information about SNAPSHOT of the LV ***/ + /********************************************/ - LONG PZVL_stateSnapshot; - /* PZVL_state at time the snapshot was - * taken. Useful in determining that - * PZVL_volumeNameSnapshot is a deleted - * name and that - * PZVL_volumeNameOriginalSnapshot is - * the name prior to deletion. - */ - unicode_t PZVL_volumeNameOriginalSnapshot[64]; - /* Original volume name of volume before - * 'snapshot' taken. This only applies - * to deleted volumes. - */ - /********************************************/ - /*** End OF ***/ - /*** Information about SNAPSHOT of the LV ***/ - /********************************************/ + /*****************************************/ + /*** ***/ + /*** Information about auto LV rename ***/ + /*** Added in version 3.1 of ZVLBeast ***/ + /*** ***/ + /*****************************************/ - /*****************************************/ - /*** ***/ - /*** Information about auto LV rename ***/ - /*** Added in version 3.1 of ZVLBeast ***/ - /*** ***/ - /*****************************************/ + Time_t PZVL_timeAutoRename; /* UTC of when last 'auto rename' was + * done. 0 would indicate no auto + * rename has ever beend done. + */ + Time_t PZVL_timeAutoRenameFirst; /* UTC of when first 'auto rename' was + * done. 0 would indicate no auto + * rename has ever been done. + */ + VolumeID_t PZVL_volumeIDAutoRename; + /* Volume ID of volume before FIRST 'auto rename' + * done. This MAY be useful for user interfaces. + */ - Time_t PZVL_timeAutoRename; /* UTC of when last 'auto rename' was - * done. 0 would indicate no auto - * rename has ever beend done. - */ - Time_t PZVL_timeAutoRenameFirst; /* UTC of when first 'auto rename' was - * done. 0 would indicate no auto - * rename has ever been done. - */ - VolumeID_t PZVL_volumeIDAutoRename; - /* Volume ID of volume before FIRST 'auto rename' - * done. This MAY be useful for user interfaces. - */ + unicode_t PZVL_volumeNameAutoRename[64]; + /* Volume name of volume before FIRST 'auto rename' + * done. This MAY be useful for user interfaces. + */ - unicode_t PZVL_volumeNameAutoRename[64]; - /* Volume name of volume before FIRST 'auto rename' - * done. This MAY be useful for user interfaces. - */ + /*****************************************/ + /*** End OF ***/ + /*** Information about auto LV rename ***/ + /*** ***/ + /*****************************************/ - /*****************************************/ - /*** End OF ***/ - /*** Information about auto LV rename ***/ - /*** ***/ - /*****************************************/ + /*** Added in version 3.02 of ZVLBeast by Craig ***/ + PersistentVolumeCrypt_s PZVL_volumeCryptData; + /*** Added in version 3.03 of ZVLBeast by Randy ***/ + LONG PZVL_authModelID; + /*** 3.04 versions have eof set to 0 (no new fields added) by Greg ***/ - /*** Added in version 3.02 of ZVLBeast by Craig ***/ - PersistentVolumeCrypt_s PZVL_volumeCryptData; - /*** Added in version 3.03 of ZVLBeast by Randy ***/ - LONG PZVL_authModelID; - /*** 3.04 versions have eof set to 0 (no new fields added) by Greg ***/ - - LONG PZVL_reserved[200-1-1-4-32-32-1]; - /* Was 32 in 2.0 version of beast. Made - * real big as if I need to add another - * unicode volume name I will have room. - */ + LONG PZVL_reserved[200-1-1-4-32-32-1]; + /* Was 32 in 2.0 version of beast. Made + * real big as if I need to add another + * unicode volume name I will have room. + */ } NSS_MEDIA_STRUCTURE(PersistentZlssVolumeLocator_s,PZVL_reserved[200-1-1-4-32-32-1]) PersistentZlssVolumeLocator_s; typedef struct ZlssVolumeLocator_s { - File_s ZVL_file; - PersistentZlssVolumeLocator_s ZVL_p; /* Persistent Information */ - Time_t ZVL_deleteStateChangeTime; - /* Time of last DELETE state change. - * One use is to prevent - * an immediate purge after a CONTINUE - * delete action causes us to re-enter - * SALVAGEABLE state. - */ - ADDR ZVL_purgeThreadID; /* Non-NULL value indicates that this - * LV is being activily purged by - * the thread specified. For a little + File_s ZVL_file; + PersistentZlssVolumeLocator_s ZVL_p; /* Persistent Information */ + Time_t ZVL_deleteStateChangeTime; + /* Time of last DELETE state change. + * One use is to prevent + * an immediate purge after a CONTINUE + * delete action causes us to re-enter + * SALVAGEABLE state. + */ + ADDR ZVL_purgeThreadID; /* Non-NULL value indicates that this + * LV is being activily purged by + * the thread specified. For a little * period of time it is who is starting * the thread. - */ - WORD ZVL_UnpackVersionMajor; /* Major version of beast on media */ - WORD ZVL_UnpackVersionMinor; /* Minor version of beast on media */ + */ + WORD ZVL_UnpackVersionMajor; /* Major version of beast on media */ + WORD ZVL_UnpackVersionMinor; /* Minor version of beast on media */ } ZlssVolumeLocator_s; typedef struct ZLSSVOL_LVD_PurgeThreadInfo_t { - ZfsVolume_s *DTI_zVolume; /* We inherit the use count */ - ZfsPool_s *DTI_poolVolume; - BOOL DTI_verbose; - FsmLite_s DTI_fsmLite; + ZfsVolume_s *DTI_zVolume; /* We inherit the use count */ + ZfsPool_s *DTI_poolVolume; + BOOL DTI_verbose; + FsmLite_s DTI_fsmLite; } ZLSSVOL_LVD_PurgeThreadInfo_t; @@ -438,88 +438,88 @@ typedef struct ZLSSVOL_LVD_PurgeThreadInfo_t { * undeleted? The items may be waiting but already started. */ - /*** The LV Delete Queue is used to store information about - *** ALL the LVs that are being deleted. The pool that the - *** volume resides on is found by looking at the pool that - *** the zvlBeast resides on. - *** The list is formed when the LVs are loaded. The - *** list is destroyed when the ZfsPool_s is deactivated. - *** This is required because I have elected to keep most of - *** the information we need in the zvlBeast which can only - *** be around if the ZfsPool_s is ACTIVE. Note that the - *** zvlBeast is stored in the ZfsPool_s. - ***/ + /*** The LV Delete Queue is used to store information about + *** ALL the LVs that are being deleted. The pool that the + *** volume resides on is found by looking at the pool that + *** the zvlBeast resides on. + *** The list is formed when the LVs are loaded. The + *** list is destroyed when the ZfsPool_s is deactivated. + *** This is required because I have elected to keep most of + *** the information we need in the zvlBeast which can only + *** be around if the ZfsPool_s is ACTIVE. Note that the + *** zvlBeast is stored in the ZfsPool_s. + ***/ typedef struct ZLSSVOL_LVD_DeleteQueueInfo_t { - SETlink_t DQI_Link; - NINT DQI_useCount; /* Purge thread is only one - * that can set for a long time. All other - * users must be quick in their use - * of a DQI. - */ - ZfsVolume_s *DQI_zVolume; - /* We have a InUseCount on this beast. */ - ZlssVolumeLocator_s *DQI_zvlBeast; - /* We have a InUseCount on this beast. */ - BOOL DQI_activePurgeing; - /* TRUE when one of the 5 purgeing threads is activily - * purgeing the LV. Used to prevent assigning multiple - * purge threads to the same LV. - */ - ZLSSVOL_LVD_PurgeThreadInfo_t DQI_Dti; - /** Information about the thread that is purgeing the LV - * this information is only valid while the thread is - * running. - */ + SETlink_t DQI_Link; + NINT DQI_useCount; /* Purge thread is only one + * that can set for a long time. All other + * users must be quick in their use + * of a DQI. + */ + ZfsVolume_s *DQI_zVolume; + /* We have a InUseCount on this beast. */ + ZlssVolumeLocator_s *DQI_zvlBeast; + /* We have a InUseCount on this beast. */ + BOOL DQI_activePurgeing; + /* TRUE when one of the 5 purgeing threads is activily + * purgeing the LV. Used to prevent assigning multiple + * purge threads to the same LV. + */ + ZLSSVOL_LVD_PurgeThreadInfo_t DQI_Dti; + /** Information about the thread that is purgeing the LV + * this information is only valid while the thread is + * running. + */ } ZLSSVOL_LVD_DeleteQueueInfo_t; #define ZLSS_DQI_INUSE( _dqi ) ( (_dqi)->DQI_useCount++ ) #define ZLSS_DQI_UNUSE( _dqi ) \ - (_dqi)->DQI_useCount--; \ - if ( (dqi)->DQI_useCount == 0 ) \ - { \ - ZLSSVOL_LVD_DeleteListRemove( dqi ); \ - } + (_dqi)->DQI_useCount--; \ + if ( (dqi)->DQI_useCount == 0 ) \ + { \ + ZLSSVOL_LVD_DeleteListRemove( dqi ); \ + } #define ZVL_PZVL_S_SIGNATURE (0x204c565auL) /* 'ZVL ' on Little Endian */ #define ZVL_PZVL_VM_MAJOR 3 /* On November 9, 1999 Greg changed - * from a 1 to a 2. This was done when - * all the persistent information for - * LV delete was added to the beast. All - * current users of LV will have to blow - * away there current volumes. - * On Jan 26, 2001 Greg changed from 2 to - * 3. This was done after BETA II of - * 6Pack. Change required for snapshot - * support that Product Management - * ask for. - */ + * from a 1 to a 2. This was done when + * all the persistent information for + * LV delete was added to the beast. All + * current users of LV will have to blow + * away there current volumes. + * On Jan 26, 2001 Greg changed from 2 to + * 3. This was done after BETA II of + * 6Pack. Change required for snapshot + * support that Product Management + * ask for. + */ #define ZVL_PZVL_VM_MINOR 4 /* On Aug 6, 2005 Greg changed to 3.04 to - * indicate that EOF no longer contains - * the volume's persistent state. Needed - * to do so that COMN read-a-head code - * would not get confussed. Also made - * ZVL upgrade persistent see - * ZLSSVOL_LV_MakeZVLUpgradePersistent() - * - * - * On Jan 28, 2004 Randy changed to 3.03 to - * add the authorization model ID. This - * is the primary copy of the Auth ID. The - * VDB has a backup copy. - * - * On Dec 15, 2003 Craig changed to indicate - * that Locator Beast has a 'backup' copy - * of the Encryption Information. The primary - * copy is in the volume's VDB. Unencrypted - * volumes are also at 3.02. - * - * On May 9, 2002 Greg changed from 0 to 1. - * This was done when 'auto rename' fields - * where added. Not a major change as - * new fields from reserve area that is - * ZEROed. - */ + * indicate that EOF no longer contains + * the volume's persistent state. Needed + * to do so that COMN read-a-head code + * would not get confussed. Also made + * ZVL upgrade persistent see + * ZLSSVOL_LV_MakeZVLUpgradePersistent() + * + * + * On Jan 28, 2004 Randy changed to 3.03 to + * add the authorization model ID. This + * is the primary copy of the Auth ID. The + * VDB has a backup copy. + * + * On Dec 15, 2003 Craig changed to indicate + * that Locator Beast has a 'backup' copy + * of the Encryption Information. The primary + * copy is in the volume's VDB. Unencrypted + * volumes are also at 3.02. + * + * On May 9, 2002 Greg changed from 0 to 1. + * This was done when 'auto rename' fields + * where added. Not a major change as + * new fields from reserve area that is + * ZEROed. + */ #define ZVLfile ZVL_file @@ -543,7 +543,7 @@ typedef struct ZLSSVOL_LVD_DeleteQueueInfo_t { #define ZLSSVOLlsn logged.LPZV_lsn - + #define ZLSSVOLroot vol.avfile.file.auth.named.root #define ZLSSVOLnamed vol.avfile.file.auth.named #define ZLSSVOLauth vol.avfile.file.auth @@ -595,11 +595,11 @@ typedef struct ZLSSVOL_LVD_DeleteQueueInfo_t { typedef struct ZLSSVolumeBeastCtrl_s { - NINT ZVBC_beastClass; /* class ID*/ - Zid_t ZVBC_zid; /* desired zid of the beast */ - NINT ZVBC_offset; /* offset into "ZfsVolume_s" beast where this goes*/ - unicode_t *ZVBC_name; - LONG ZVBC_flags; + NINT ZVBC_beastClass; /* class ID*/ + Zid_t ZVBC_zid; /* desired zid of the beast */ + NINT ZVBC_offset; /* offset into "ZfsVolume_s" beast where this goes*/ + unicode_t *ZVBC_name; + LONG ZVBC_flags; } ZLSSVolumeBeastCtrl_s; /* Defines for ZVBC_flags */ @@ -610,36 +610,36 @@ extern ZLSSVolumeBeastCtrl_s ZLSSVolumeSuperBeasts[]; extern LSSSpecificPackUnpackOps_s ZVL_lssOps[]; extern CommonBeastOps_s ZVL_ComnBeastOps; - /** The link list of all LVs that are being deleted or purged. Must - ** be empty when all pools are deactive. I.E. if the pool an - ** LV is on is not ACTIVE then we do NOT have any information - ** about the LV in this list. - **/ + /** The link list of all LVs that are being deleted or purged. Must + ** be empty when all pools are deactive. I.E. if the pool an + ** LV is on is not ACTIVE then we do NOT have any information + ** about the LV in this list. + **/ typedef struct ZLSSLVDeleteList_s { - SEThead_t ZDL_list; /* SYNC Non-Pre-emptive. Head of list of - * all items. Was a item has been located - * then a use count can must set on it if - * the user will be allowing blocking. - */ + SEThead_t ZDL_list; /* SYNC Non-Pre-emptive. Head of list of + * all items. Was a item has been located + * then a use count can must set on it if + * the user will be allowing blocking. + */ // Latch_s ZDL_listLatch; /* Latch for sync of ZDL_list */ - Latch_s ZDL_beastLatch; /* Latch for default sync */ - SNINT ZDL_cnt; /* SYNC Non-Pre-emptive. Num of items in list */ - FsmLite_s ZDL_fsmLite; /* SYNC ZDL_scheduled flag. Thread to scan - * list to keep everything going. - */ - BOOL ZDL_stop; /* Used to tell scan thread that it needs to - * stop. - */ - BOOL ZDL_scheduled; - OneShot_s ZDL_timer; /* SYNC ZDL_scheduled flag. One Shot - * timer used to implement '60 second' - * LV Delete scanner logic. - */ - QUAD ZDL_timesRun; - ADDR ZDL_threadId; - ADDR ZDL_threadIdLast; - Time_t ZDL_scheduledTime; - Time_t ZDL_runTime; + Latch_s ZDL_beastLatch; /* Latch for default sync */ + SNINT ZDL_cnt; /* SYNC Non-Pre-emptive. Num of items in list */ + FsmLite_s ZDL_fsmLite; /* SYNC ZDL_scheduled flag. Thread to scan + * list to keep everything going. + */ + BOOL ZDL_stop; /* Used to tell scan thread that it needs to + * stop. + */ + BOOL ZDL_scheduled; + OneShot_s ZDL_timer; /* SYNC ZDL_scheduled flag. One Shot + * timer used to implement '60 second' + * LV Delete scanner logic. + */ + QUAD ZDL_timesRun; + ADDR ZDL_threadId; + ADDR ZDL_threadIdLast; + Time_t ZDL_scheduledTime; + Time_t ZDL_runTime; } ZLSSLVDeleteList_s; extern ZLSSLVDeleteList_s ZLSSLVDeleteList; @@ -656,504 +656,504 @@ extern ZLSSLVDeleteList_s ZLSSLVDeleteList; ***/ typedef struct PersistentZlssVolumeLocator_2Dot0_s { - LONG PZVL_2Dot0_signature; - WORD PZVL_2Dot0_versionMajor; - WORD PZVL_2Dot0_versionMinor; - SQUAD PZVL_2Dot0_loggedVolumeDataBlk; - SQUAD PZVL_2Dot0_volumeDataBlk; - SQUAD PZVL_2Dot0_systemBeastBlkNum; - VolumeID_t PZVL_2Dot0_volumeID; - LONG PZVL_2Dot0_state; - LONG PZVL_2Dot0_subState; /* Sub-state of the state. */ - GUID_t PZVL_2Dot0_internalID; - VolumeID_t PZVL_2Dot0_volumeIDOriginal; - LONG PZVL_2Dot0_reserved[32]; + LONG PZVL_2Dot0_signature; + WORD PZVL_2Dot0_versionMajor; + WORD PZVL_2Dot0_versionMinor; + SQUAD PZVL_2Dot0_loggedVolumeDataBlk; + SQUAD PZVL_2Dot0_volumeDataBlk; + SQUAD PZVL_2Dot0_systemBeastBlkNum; + VolumeID_t PZVL_2Dot0_volumeID; + LONG PZVL_2Dot0_state; + LONG PZVL_2Dot0_subState; /* Sub-state of the state. */ + GUID_t PZVL_2Dot0_internalID; + VolumeID_t PZVL_2Dot0_volumeIDOriginal; + LONG PZVL_2Dot0_reserved[32]; #if zMAX_COMPONENT_NAME != 256 #error This buffer is persistent so changes will be needed. #endif - unicode_t PZVL_2Dot0_volumeName[zMAX_COMPONENT_NAME]; - Time_t PZVL_2Dot0_deleteTimeStart; - LONG PZVL_2Dot0_deleteState; + unicode_t PZVL_2Dot0_volumeName[zMAX_COMPONENT_NAME]; + Time_t PZVL_2Dot0_deleteTimeStart; + LONG PZVL_2Dot0_deleteState; #if zMAX_COMPONENT_NAME != 256 #error This buffer is persistent so changes will be needed. #endif - unicode_t PZVL_2Dot0_volumeNameOriginal[zMAX_COMPONENT_NAME]; - LONG PZVL_2Dot0_errno; - char PZVL_2Dot0_errnoSetter[48]; - Time_t PZVL_2Dot0_purgeTimeStart; - Time_t PZVL_2Dot0_purgeTimeLastStart; - Time_t PZVL_2Dot0_purgeTimeLastEnd; - SQUAD PZVL_2Dot0_purgeLogBlocks; - Zid_t PZVL_2Dot0_lastZidTruncated; + unicode_t PZVL_2Dot0_volumeNameOriginal[zMAX_COMPONENT_NAME]; + LONG PZVL_2Dot0_errno; + char PZVL_2Dot0_errnoSetter[48]; + Time_t PZVL_2Dot0_purgeTimeStart; + Time_t PZVL_2Dot0_purgeTimeLastStart; + Time_t PZVL_2Dot0_purgeTimeLastEnd; + SQUAD PZVL_2Dot0_purgeLogBlocks; + Zid_t PZVL_2Dot0_lastZidTruncated; } NSS_MEDIA_STRUCTURE(PersistentZlssVolumeLocator_2Dot0_s,PZVL_2Dot0_lastZidTruncated) PersistentZlssVolumeLocator_2Dot0_s; void ZLSSVOL_LVD_DeleteScanThread( - FsmLite_s *fsmLite, - void *notUsed ); + FsmLite_s *fsmLite, + void *notUsed ); void ZLSSVOL_LVD_DeleteScanTimer( - OneShot_s *alarm); + OneShot_s *alarm); File_s *ZVL_Create( - GeneralMsg_s *genMsg, - unicode_t *fullName, - NINT fileType, - NINT fileAttributes, - NINT createFlags, - Key_t *retKey); + GeneralMsg_s *genMsg, + unicode_t *fullName, + NINT fileType, + NINT fileAttributes, + NINT createFlags, + Key_t *retKey); void ZFSPOOL_ShutdownPool( - ZfsPool_s *poolVolume ); + ZfsPool_s *poolVolume ); -STATUS ZLSSVOL_PoolNameMangle( - CONST unicode_t *poolName, /* Current pool name */ - NINT *mangleKey, /* Mangle Key, must point to 0 on first call */ - NINT uniSize, /* Number of unicode newPoolName can hold */ - unicode_t *newPoolName ); /* New mangled name */ +STATUS ZLSSVOL_PoolNameMangle( + CONST unicode_t *poolName, /* Current pool name */ + NINT *mangleKey, /* Mangle Key, must point to 0 on first call */ + NINT uniSize, /* Number of unicode newPoolName can hold */ + unicode_t *newPoolName ); /* New mangled name */ -STATUS ZLSSVOL_LoadPersistentPool( - GeneralMsg_s *genMsg, - ZfsVolume_s *zVolume, - NINT mode, /* Must be VOLMODE_xxx define */ - NINT flags); /* Must be LPP_FLAGS_xxx define (or 0) */ +STATUS ZLSSVOL_LoadPersistentPool( + GeneralMsg_s *genMsg, + ZfsVolume_s *zVolume, + NINT mode, /* Must be VOLMODE_xxx define */ + NINT flags); /* Must be LPP_FLAGS_xxx define (or 0) */ STATUS ZLSSVOL_LoadSystemBeasts( - GeneralMsg_s *genMsg, - ZfsVolume_s *zVolume); + GeneralMsg_s *genMsg, + ZfsVolume_s *zVolume); STATUS ZLSSVOL_LVD_DeleteActionAPI( - GeneralMsg_s *genMsg, - unicode_t *volumeName, - unsigned long action ); + GeneralMsg_s *genMsg, + unicode_t *volumeName, + unsigned long action ); STATUS ZLSSVOL_LV_GetInfoAPI( - GeneralMsg_s *genMsg, - unicode_t *volumeName, - unsigned long action, - NINT offset, - NINT retBufLen, - BYTE *retBuf, - NINT *retLen ); + GeneralMsg_s *genMsg, + unicode_t *volumeName, + unsigned long action, + NINT offset, + NINT retBufLen, + BYTE *retBuf, + NINT *retLen ); -void ZLSSVOL_LVD_DeleteListAddAndInit( - ZLSSVOL_LVD_DeleteQueueInfo_t *dqi, - ZlssVolumeLocator_s *zvlBeast, - ZfsVolume_s *zVolume ); +void ZLSSVOL_LVD_DeleteListAddAndInit( + ZLSSVOL_LVD_DeleteQueueInfo_t *dqi, + ZlssVolumeLocator_s *zvlBeast, + ZfsVolume_s *zVolume ); void ZLSSVOL_LVD_DeleteListRemove( - ZLSSVOL_LVD_DeleteQueueInfo_t *dqi ); + ZLSSVOL_LVD_DeleteQueueInfo_t *dqi ); void ZLSSVOL_LVD_DeleteListRemoveAllFromPool( - Volume_s *volume ); + Volume_s *volume ); ZfsVolume_s *ZLSSVOL_NewLVBeast( - GeneralMsg_s *genMsg, - ZlssVolumeLocator_s *zvlBeast, - ZfsPool_s *pool, - unicode_t *zVolumeName); + GeneralMsg_s *genMsg, + ZlssVolumeLocator_s *zvlBeast, + ZfsPool_s *pool, + unicode_t *zVolumeName); ZfsVolume_s *ZLSSVOL_NewFakeLVBeast( - GeneralMsg_s *genMsg, - ZlssVolumeLocator_s *zvlBeast, - ZfsPool_s *pool, - unicode_t *zVolumeName); + GeneralMsg_s *genMsg, + ZlssVolumeLocator_s *zvlBeast, + ZfsPool_s *pool, + unicode_t *zVolumeName); STATUS ZLSSVOL_LV_AutoRename( - GeneralMsg_s *genMsg, - ZlssVolumeLocator_s *zvlBeast); + GeneralMsg_s *genMsg, + ZlssVolumeLocator_s *zvlBeast); STATUS ZLSSVOL_LV_Snapshot( - GeneralMsg_s *genMsg, - ZlssVolumeLocator_s *zvlBeast ); + GeneralMsg_s *genMsg, + ZlssVolumeLocator_s *zvlBeast ); STATUS ZLSSVOL_LV_Create( - GeneralMsg_s *genMsg, - Volume_s *pVolume, - unicode_t *zVolumeName, - QUAD zVolumeSize, - NINT authModelID, - const VolumeID_t *requestedVolumeID, - BOOL virtualFileFlag, - struct ZfsXaction_s *xactiom, - BOOL autoIPU ); + GeneralMsg_s *genMsg, + Volume_s *pVolume, + unicode_t *zVolumeName, + QUAD zVolumeSize, + NINT authModelID, + const VolumeID_t *requestedVolumeID, + BOOL virtualFileFlag, + struct ZfsXaction_s *xactiom, + BOOL autoIPU ); STATUS ZLSSVOL_LVD_DeleteActionPause( - GeneralMsg_s *genMsg, - unicode_t *volumeName, - ZfsVolume_s *zVolume ); + GeneralMsg_s *genMsg, + unicode_t *volumeName, + ZfsVolume_s *zVolume ); STATUS ZLSSVOL_LVD_DeletePurge( - GeneralMsg_s *genMsg, - ZLSSVOL_LVD_DeleteQueueInfo_t *dqi, - ZlssVolumeLocator_s *zvlBeast, - ZfsVolume_s *zVolume, - ZfsPool_s *poolVolume, - BOOL verbose ); + GeneralMsg_s *genMsg, + ZLSSVOL_LVD_DeleteQueueInfo_t *dqi, + ZlssVolumeLocator_s *zvlBeast, + ZfsVolume_s *zVolume, + ZfsPool_s *poolVolume, + BOOL verbose ); void ZLSSVOL_LVD_DeleteUndeleteThread( - FsmLite_s *fsmLite, - ZLSSVOL_LVD_DeleteQueueInfo_t *dqi ); + FsmLite_s *fsmLite, + ZLSSVOL_LVD_DeleteQueueInfo_t *dqi ); void ZLSSVOL_LVD_DeletePurgeThread( - FsmLite_s *fsmLite, - ZLSSVOL_LVD_DeleteQueueInfo_t *dqi ); + FsmLite_s *fsmLite, + ZLSSVOL_LVD_DeleteQueueInfo_t *dqi ); STATUS ZLSSVOL_LV_ZVLDeleteDirectory( - GeneralMsg_s *genMsg, - unicode_t *containerVolumeName ); + GeneralMsg_s *genMsg, + unicode_t *containerVolumeName ); File_s *ZLSSVOL_LV_ZVLCreateDirectory( - GeneralMsg_s *genMsg, - unicode_t *containerVolumeName, - struct ZfsXaction_s *xaction, - BOOL autoIPU ); + GeneralMsg_s *genMsg, + unicode_t *containerVolumeName, + struct ZfsXaction_s *xaction, + BOOL autoIPU ); ZlssVolumeLocator_s *ZLSSVOL_LV_ZVLCreate( - GeneralMsg_s *genMsg, - unicode_t *zVolumeName, - ZfsVolume_s *zVolume, - VolumeID_t zVolumeID, - unicode_t *containerVolumeName, - struct ZfsXaction_s *xaction, - BOOL autoIPU, - NINT authModelID ); + GeneralMsg_s *genMsg, + unicode_t *zVolumeName, + ZfsVolume_s *zVolume, + VolumeID_t zVolumeID, + unicode_t *containerVolumeName, + struct ZfsXaction_s *xaction, + BOOL autoIPU, + NINT authModelID ); #if NSS_DEBUG IS_ENABLED STATUS doZLSSVOL_LV_NameCheck( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); #endif Time_t ZLSSVOL_LVD_SalvageableTimeGet( - ZlssVolumeLocator_s *zvlBeast ); + ZlssVolumeLocator_s *zvlBeast ); STATUS ZLSSVOL_LVD_NTTruncate( - GeneralMsg_s *genMsg, - ZfsVolume_s *zVolume, - ZlssVolumeLocator_s *zvlBeast ); + GeneralMsg_s *genMsg, + ZfsVolume_s *zVolume, + ZlssVolumeLocator_s *zvlBeast ); STATUS ZLSSVOL_LVD_NTNodeValidate( - GeneralMsg_s *genMsg, - struct ZfsNameTree_s *nameTree, - struct Node_s *node, - NINT level); + GeneralMsg_s *genMsg, + struct ZfsNameTree_s *nameTree, + struct Node_s *node, + NINT level); STATIC STATUS ZLSSVOL_LVD_NTShrinkLeafOverflow( - GeneralMsg_s *genMsg, - ZfsNameTree_s *nameTree, - NINT eIndex, /* index of DUP LEAF entry */ - Buffer_s *eBuffer, - Blknum_t ovFlowBlk ); /* 1st LEAF OVERFLOW block */ + GeneralMsg_s *genMsg, + ZfsNameTree_s *nameTree, + NINT eIndex, /* index of DUP LEAF entry */ + Buffer_s *eBuffer, + Blknum_t ovFlowBlk ); /* 1st LEAF OVERFLOW block */ STATIC STATUS ZLSSVOL_LVD_NTDepthRightVisit( - GeneralMsg_s *genMsg, - ZfsNameTree_s *nameTree, - Buffer_s *parentBuffer, - NINT *depth ); + GeneralMsg_s *genMsg, + ZfsNameTree_s *nameTree, + Buffer_s *parentBuffer, + NINT *depth ); STATIC STATUS ZLSSVOL_LVD_NTShrinkVisit( - GeneralMsg_s *genMsg, - ZfsNameTree_s *nameTree, - Buffer_s *parentBuffer, - NINT *level, - NINT leafLevel ); + GeneralMsg_s *genMsg, + ZfsNameTree_s *nameTree, + Buffer_s *parentBuffer, + NINT *level, + NINT leafLevel ); STATIC STATUS ZLSSVOL_LVD_NTDepthRightBranchNode( - GeneralMsg_s *genMsg, - ZfsNameTree_s *nameTree, - Buffer_s *brBuffer, - Buffer_s *ovBuffer, - NINT *depth ); + GeneralMsg_s *genMsg, + ZfsNameTree_s *nameTree, + Buffer_s *brBuffer, + Buffer_s *ovBuffer, + NINT *depth ); STATIC STATUS ZLSSVOL_LVD_NTShrinkBranchNode( - GeneralMsg_s *genMsg, - ZfsNameTree_s *nameTree, - Buffer_s *brBuffer, - Buffer_s *ovBuffer, - NINT *level, - NINT leafLevel ); + GeneralMsg_s *genMsg, + ZfsNameTree_s *nameTree, + Buffer_s *brBuffer, + Buffer_s *ovBuffer, + NINT *level, + NINT leafLevel ); STATIC STATUS ZLSSVOL_LVD_NTShrinkLast( - GeneralMsg_s *genMsg, - ZfsNameTree_s *nameTree ); + GeneralMsg_s *genMsg, + ZfsNameTree_s *nameTree ); STATIC STATUS ZLSSVOL_LVD_NTShrink( - GeneralMsg_s *genMsg, - ZfsNameTree_s *nameTree, - NINT leafLevel ); + GeneralMsg_s *genMsg, + ZfsNameTree_s *nameTree, + NINT leafLevel ); STATIC STATUS ZLSSVOL_LVD_NTDepthRightBranchChild( - GeneralMsg_s *genMsg, - ZfsNameTree_s *nameTree, - Buffer_s *parentBuffer, - Blknum_t childBlock, - NINT *depth ); + GeneralMsg_s *genMsg, + ZfsNameTree_s *nameTree, + Buffer_s *parentBuffer, + Blknum_t childBlock, + NINT *depth ); STATIC STATUS ZLSSVOL_LVD_NTShrinkBranchChild( - GeneralMsg_s *genMsg, - ZfsNameTree_s *nameTree, - Buffer_s *parentBuffer, - Blknum_t *childBlockPtr, - NINT *level, - NINT leafLevel ); + GeneralMsg_s *genMsg, + ZfsNameTree_s *nameTree, + Buffer_s *parentBuffer, + Blknum_t *childBlockPtr, + NINT *level, + NINT leafLevel ); STATIC STATUS ZLSSVOL_LVD_NTDepthRight( - GeneralMsg_s *genMsg, - ZfsNameTree_s *nameTree, - NINT *depth ); + GeneralMsg_s *genMsg, + ZfsNameTree_s *nameTree, + NINT *depth ); STATIC STATUS ZLSSVOL_LVD_BTShrinkLast( - GeneralMsg_s *genMsg, - ZfsBeastTreeBeast_s *beastTree ); + GeneralMsg_s *genMsg, + ZfsBeastTreeBeast_s *beastTree ); STATIC STATUS ZLSSVOL_LVD_BTDepthRight( - GeneralMsg_s *genMsg, - struct ZfsBeastTreeBeast_s *beastTree, - SNINT *depth ); + GeneralMsg_s *genMsg, + struct ZfsBeastTreeBeast_s *beastTree, + SNINT *depth ); STATIC STATUS ZLSSVOL_LVD_BTDepthVisitRight( - GeneralMsg_s *genMsg, - SNINT *depth, - struct ZfsBeastTreeBeast_s *beastTree, - struct BeastTreeNode_s *node, - Blknum_t blknum ); + GeneralMsg_s *genMsg, + SNINT *depth, + struct ZfsBeastTreeBeast_s *beastTree, + struct BeastTreeNode_s *node, + Blknum_t blknum ); STATUS ZLSSVOL_LVD_ShrinkRoot( - GeneralMsg_s *genMsg, - ZfsBtreeBeast_s *bTree ); + GeneralMsg_s *genMsg, + ZfsBtreeBeast_s *bTree ); STATIC STATUS ZLSSVOL_LVD_BTShrink( - GeneralMsg_s *genMsg, - struct ZfsBeastTreeBeast_s *beastTree, - SNINT leafLevel ); + GeneralMsg_s *genMsg, + struct ZfsBeastTreeBeast_s *beastTree, + SNINT leafLevel ); STATUS ZLSSVOL_LVD_BTTruncate( - GeneralMsg_s *genMsg, - ZfsVolume_s *zVolume, - ZlssVolumeLocator_s *zvlBeast ); + GeneralMsg_s *genMsg, + ZfsVolume_s *zVolume, + ZlssVolumeLocator_s *zvlBeast ); STATIC STATUS ZLSSVOL_LVD_BTShrinkVisit( - GeneralMsg_s *genMsg, - struct ZfsBeastTreeBeast_s *beastTree, - struct BeastTreeNode_s *nodeParent, - Buffer_s *bufferParent, - SNINT *level, - SNINT leafLevel, - Blknum_t blknum ); + GeneralMsg_s *genMsg, + struct ZfsBeastTreeBeast_s *beastTree, + struct BeastTreeNode_s *nodeParent, + Buffer_s *bufferParent, + SNINT *level, + SNINT leafLevel, + Blknum_t blknum ); STATUS ZLSSVOL_LVD_BTNodeValidate( - GeneralMsg_s *genMsg, - struct ZfsBeastTreeBeast_s *beastTree, - struct BeastTreeNode_s *node, - SNINT level ); + GeneralMsg_s *genMsg, + struct ZfsBeastTreeBeast_s *beastTree, + struct BeastTreeNode_s *node, + SNINT level ); STATUS ZLSSVOL_LVD_MovePurgeLog( - GeneralMsg_s *genMsg, - ZfsVolume_s *zVolume, - ZlssVolumeLocator_s *zvlBeast ); + GeneralMsg_s *genMsg, + ZfsVolume_s *zVolume, + ZlssVolumeLocator_s *zvlBeast ); ZlssVolumeLocator_s *ZLSSVOL_LV_ZVLOpen2( - GeneralMsg_s *returnGenMsg, - ZfsVolume_s *zVolume, - Key_t *retKey ); + GeneralMsg_s *returnGenMsg, + ZfsVolume_s *zVolume, + Key_t *retKey ); void ZLSS_LV_DeleteAllUserObjectsThread( - FsmLite_s *fsmLite, - Volume_s *vol); + FsmLite_s *fsmLite, + Volume_s *vol); STATUS ZLSSVOL_LV_TruncateABeast( - GeneralMsg_s *genMsg, - RootBeast_s *rootBeast ); - + GeneralMsg_s *genMsg, + RootBeast_s *rootBeast ); + STATUS ZLSSVOL_LV_CreateAPI( - GeneralMsg_s *genMsg, - unicode_t *poolName, - unicode_t *volumeName, - NINT authModelID, - QUAD diskQuota, - GUID_t *guid, - BOOL virtualFileFlag ); + GeneralMsg_s *genMsg, + unicode_t *poolName, + unicode_t *volumeName, + NINT authModelID, + QUAD diskQuota, + GUID_t *guid, + BOOL virtualFileFlag ); STATIC STATUS ZVL_ModifyInfo( - GeneralMsg_s *genMsg, - unicode_t *fullName, - NINT modifyInfoMask, - NINT modifyTypeInfoMask, - zInfo_s *modifyInfo, - void *modifyTypeInfo); + GeneralMsg_s *genMsg, + unicode_t *fullName, + NINT modifyInfoMask, + NINT modifyTypeInfoMask, + zInfo_s *modifyInfo, + void *modifyTypeInfo); STATUS ZLSSVOL_LV_AddRI( - GeneralMsg_s *genMsg, - unicode_t *fullName ); + GeneralMsg_s *genMsg, + unicode_t *fullName ); STATUS ZLSSVOL_LV_RemoveRI( - GeneralMsg_s *genMsg, - unicode_t *fullName ); + GeneralMsg_s *genMsg, + unicode_t *fullName ); STATUS ZLSSVOL_LV_RemoveDICIRI( - GeneralMsg_s *genMsg, - unicode_t *fullName ); + GeneralMsg_s *genMsg, + unicode_t *fullName ); STATUS ZVL_Delete( - GeneralMsg_s *genMsg, - unicode_t *fullName, - NINT deleteFlags); + GeneralMsg_s *genMsg, + unicode_t *fullName, + NINT deleteFlags); STATUS doZLSSVOL_LV_Scan( - PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); STATUS doZLSSVOL_LVD_UISalvageable( - PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); STATUS doZLSSVOL_LVD_UIBasic( - PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); STATUS doZLSSVOL_LV_Truncate( - PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); STATUS ZLSSVOL_LVD_TruncatePurgeLog( - GeneralMsg_s *genMsg, - ZfsVolume_s *zVolume, - ZfsPool_s *poolVolume, - ZlssVolumeLocator_s *zvlBeast ); + GeneralMsg_s *genMsg, + ZfsVolume_s *zVolume, + ZfsPool_s *poolVolume, + ZlssVolumeLocator_s *zvlBeast ); STATUS ZLSSVOL_LVD_FreeLastBlocks( - GeneralMsg_s *genMsg, - ZfsPool_s *poolVolume, - ZlssVolumeLocator_s *zvlBeast ); + GeneralMsg_s *genMsg, + ZfsPool_s *poolVolume, + ZlssVolumeLocator_s *zvlBeast ); STATUS ZLSSVOL_LVD_DeleteZVLB( - GeneralMsg_s *genMsg, - ZfsPool_s *poolVolume, - ZlssVolumeLocator_s *zvlBeast ); + GeneralMsg_s *genMsg, + ZfsPool_s *poolVolume, + ZlssVolumeLocator_s *zvlBeast ); STATUS ZLSSVOL_LVD_LoadModeDeletion( - GeneralMsg_s *genMsg, - ZlssVolumeLocator_s *zvlBeast, - ZfsVolume_s *zVolume, - ZfsPool_s *poolVolume, - BOOL verbose ); + GeneralMsg_s *genMsg, + ZlssVolumeLocator_s *zvlBeast, + ZfsVolume_s *zVolume, + ZfsPool_s *poolVolume, + BOOL verbose ); STATUS ZLSSVOL_LVD_DeleteAPI( - GeneralMsg_s *genMsg, - unicode_t *volumeName, - NINT mode ); + GeneralMsg_s *genMsg, + unicode_t *volumeName, + NINT mode ); STATUS ZLSSVOL_LVR_RenameAPI( - GeneralMsg_s *genMsg, - unicode_t *volumeName, - unicode_t *newVolumeNam ); + GeneralMsg_s *genMsg, + unicode_t *volumeName, + unicode_t *newVolumeNam ); STATUS ZLSSVOL_LVD_SubStateUpdate( - GeneralMsg_s *genMsg, - struct ZfsXaction_s *xaction, - Volume_s *volume, - ZlssVolumeLocator_s *zvlBeast, - LONG newSubState ); + GeneralMsg_s *genMsg, + struct ZfsXaction_s *xaction, + Volume_s *volume, + ZlssVolumeLocator_s *zvlBeast, + LONG newSubState ); STATUS ZVL_Rename( - GeneralMsg_s *genMsg, - unicode_t *oldFullName, - unicode_t *newFullName, - NINT renameFlags ); + GeneralMsg_s *genMsg, + unicode_t *oldFullName, + unicode_t *newFullName, + NINT renameFlags ); STATUS ZLSSVOL_LV_ZVLRename( - GeneralMsg_s *genMsg, - unicode_t *oldVolumeName, - unicode_t *newVolumeName, - unicode_t *containerVolumeName ); + GeneralMsg_s *genMsg, + unicode_t *oldVolumeName, + unicode_t *newVolumeName, + unicode_t *containerVolumeName ); STATUS ZLSSVOL_LV_UnloadAll( - GeneralMsg_s *genMsg, - ZlssPool_s *zlssPool ); + GeneralMsg_s *genMsg, + ZlssPool_s *zlssPool ); STATUS ZLSSVOL_LV_Unload( - GeneralMsg_s *genMsg, - ZfsVolume_s *zVolume ); + GeneralMsg_s *genMsg, + ZfsVolume_s *zVolume ); ZfsVolume_s *ZLSSVOL_LV_LoadVerify( - GeneralMsg_s *genMsg, - ZlssVolumeLocator_s *zvlBeast, - Volume_s *storageVolume, - BOOL verbose, - BOOL activate ); + GeneralMsg_s *genMsg, + ZlssVolumeLocator_s *zvlBeast, + Volume_s *storageVolume, + BOOL verbose, + BOOL activate ); ZfsVolume_s *ZLSSVOL_LV_Load( - GeneralMsg_s *genMsg, - ZlssVolumeLocator_s *zvlBeast, - Volume_s *storageVolume, - BOOL verbose, - BOOL activate ); + GeneralMsg_s *genMsg, + ZlssVolumeLocator_s *zvlBeast, + Volume_s *storageVolume, + BOOL verbose, + BOOL activate ); STATUS ZLSSVOL_LV_LoadAll( - GeneralMsg_s *genMsg, - ZfsPool_s *pool, - BOOL verbose, - BOOL activate, - BOOL cvsLatched ); + GeneralMsg_s *genMsg, + ZfsPool_s *pool, + BOOL verbose, + BOOL activate, + BOOL cvsLatched ); STATUS ZLSSVOL_LV_Scan( - GeneralMsg_s *genMsg, - NamingMsg_s *nameMsg, - SearchMsg_s *searchMsg, - ZfsPool_s *zlssPool, - ZlssVolumeLocator_s **ret_zvlBeast ); + GeneralMsg_s *genMsg, + NamingMsg_s *nameMsg, + SearchMsg_s *searchMsg, + ZfsPool_s *zlssPool, + ZlssVolumeLocator_s **ret_zvlBeast ); STATUS ZLSSVOL_DoFlushSystemBeasts( - GeneralMsg_s *genMsg, - ZfsVolume_s *zVolume, - BOOL deactivating); /* if TRUE we are deactivating the volume, else flushing*/ + GeneralMsg_s *genMsg, + ZfsVolume_s *zVolume, + BOOL deactivating); /* if TRUE we are deactivating the volume, else flushing*/ -void ZLSSVOL_UnloadPersistentPool( - ZfsVolume_s *zVolume, - NINT mode ); +void ZLSSVOL_UnloadPersistentPool( + ZfsVolume_s *zVolume, + NINT mode ); void ZLSSVOL_UnloadSystemBeasts( - ZfsVolume_s *zVolume); + ZfsVolume_s *zVolume); STATUS ZFSVOL_VOL_MakeVolumeFreeSpace( - GeneralMsg_s *genMsg, - void *volume_LX, - BOOL purgeAllDeletedFiles, - BOOL asyncPurge, - QUAD numberOfBlocks); + GeneralMsg_s *genMsg, + void *volume_LX, + BOOL purgeAllDeletedFiles, + BOOL asyncPurge, + QUAD numberOfBlocks); STATUS doChangePoolState( - PCLSwitchDef_s *switchDef, - NINT options, - void *userParm); + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); STATUS doChangePoolStateForce( - PCLSwitchDef_s *switchDef, - NINT options, - void *userParm); + PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); void ZFT_BlockFree( - ZfsVolume_s *zVolume, - struct ZfsXaction_s *xaction, - NINT blockCount, - Blknum_t *blockArray); /* in/out */ + ZfsVolume_s *zVolume, + struct ZfsXaction_s *xaction, + NINT blockCount, + Blknum_t *blockArray); /* in/out */ STATUS ZFT_BlockAlloc( - GeneralMsg_s *genMsg, - ZfsVolume_s *zVolume, - Extent_s *request, - BOOL systemRequest, - struct ZfsXaction_s *xaction, - Blknum_t *blockArray); /* out */ + GeneralMsg_s *genMsg, + ZfsVolume_s *zVolume, + Extent_s *request, + BOOL systemRequest, + struct ZfsXaction_s *xaction, + Blknum_t *blockArray); /* out */ //STATUS ZLSSVOL_LV_Delete( @@ -1162,174 +1162,174 @@ STATUS ZFT_BlockAlloc( // ZfsVolume_s *zVolume ); STATUS ZLSSVOL_LV_ZVLDelete( - GeneralMsg_s *genMsg, - unicode_t *zVolumeName, - unicode_t *containerVolumeName ); + GeneralMsg_s *genMsg, + unicode_t *zVolumeName, + unicode_t *containerVolumeName ); File_s *ZVL_Open( - GeneralMsg_s *genMsg, - unicode_t *fullName, - Key_t *retKey); + GeneralMsg_s *genMsg, + unicode_t *fullName, + Key_t *retKey); ZfsVolume_s *ZLSSVOL_LV_LoadByName( - GeneralMsg_s *genMsg, - unicode_t *containerVolumeName, - unicode_t *zVolumeName, - ZlssPool_s *zlssPool, - Xaction_s *xation); + GeneralMsg_s *genMsg, + unicode_t *containerVolumeName, + unicode_t *zVolumeName, + ZlssPool_s *zlssPool, + Xaction_s *xation); -void ZLSSVOL_LVD_ErrorRecordClear( - ZlssVolumeLocator_s *zvlBeast ); +void ZLSSVOL_LVD_ErrorRecordClear( + ZlssVolumeLocator_s *zvlBeast ); - /*** ZLSS Logical Volume Auto In Place Upgrade Routines ***/ + /*** ZLSS Logical Volume Auto In Place Upgrade Routines ***/ STATUS ZLVAIPU_FTWalk( GeneralMsg_s *genMsg, ZfsPool_s *pool, Blknum_t *blockCount ); STATUS ZLVAIPU_PLWalk( GeneralMsg_s *genMsg, ZfsPool_s *pool, Blknum_t *blockCount ); STATUS ZLVAIPU_PTWalk( GeneralMsg_s *genMsg, ZfsPool_s *pool, Blknum_t *blockCount ); STATUS ZLVAIPU_VolumePurgeLogCreate( - GeneralMsg_s *genMsg, - ZfsVolume_s *zVolume, - struct ZfsXaction_s *xaction ); + GeneralMsg_s *genMsg, + ZfsVolume_s *zVolume, + struct ZfsXaction_s *xaction ); STATUS ZLVAIPU_TestAndSetBlock( - GeneralMsg_s *genMsg, - Blknum_t blockNum, - BlockMap_s *bitMap ); + GeneralMsg_s *genMsg, + Blknum_t blockNum, + BlockMap_s *bitMap ); void ZLVAIPU_TestAndSetBlockShutdown( - char *where, - BlockMap_s *bitMap ); + char *where, + BlockMap_s *bitMap ); STATUS ZLVAIPU_TestAndSetBlockStartup( - GeneralMsg_s *genMsg, - char *where, - Blknum_t numberOfBlocks, - BlockMap_s *bitMap ); + GeneralMsg_s *genMsg, + char *where, + Blknum_t numberOfBlocks, + BlockMap_s *bitMap ); void ZLVAIPU_DisplayError( GeneralMsg_s *genMsg, char *where ); STATUS ZLSSPOOL_WriteInitialLPDB( - GeneralMsg_s *genMsg, - ZlssPool_s *zlssPool, - struct ZfsXaction_s *xaction); + GeneralMsg_s *genMsg, + ZlssPool_s *zlssPool, + struct ZfsXaction_s *xaction); STATUS ZLSSPOOL_WriteInitialPDB( - GeneralMsg_s *genMsg, - ZlssPool_s *zlssPool, - struct ZfsXaction_s *xaction); + GeneralMsg_s *genMsg, + ZlssPool_s *zlssPool, + struct ZfsXaction_s *xaction); STATUS ZLSSVOL_LV_ZVLRenameAsync( - GeneralMsg_s *genMsg, - unicode_t *oldName, - unicode_t *newName, - unicode_t *containerVolumeName ); + GeneralMsg_s *genMsg, + unicode_t *oldName, + unicode_t *newName, + unicode_t *containerVolumeName ); void ZLSSVOL_LV_ZVLRenameThread( - FsmLite_s *fsmLite, - struct ZLSSVOL_ZVL_RenameInfo_t *ri ); + FsmLite_s *fsmLite, + struct ZLSSVOL_ZVL_RenameInfo_t *ri ); STATUS ZLSSVOL_LV_GetInfoCreated( - GeneralMsg_s *genMsg, - unicode_t *volumeName, - ZfsVolume_s *zVolume, - NINT offset, - NINT retBufLen, - BYTE *retBuf, - NINT *retLen ); + GeneralMsg_s *genMsg, + unicode_t *volumeName, + ZfsVolume_s *zVolume, + NINT offset, + NINT retBufLen, + BYTE *retBuf, + NINT *retLen ); STATUS ZLSSVOL_LV_GetInfoDeletion( - GeneralMsg_s *genMsg, - unicode_t *volumeName, - ZfsVolume_s *zVolume, - NINT offset, - NINT retBufLen, - BYTE *retBuf, - NINT *retLen ); + GeneralMsg_s *genMsg, + unicode_t *volumeName, + ZfsVolume_s *zVolume, + NINT offset, + NINT retBufLen, + BYTE *retBuf, + NINT *retLen ); void ZLSSVOL_InitLVDB( - ZfsVolume_s *zVolume, - QUAD totalBlocks, - Time_t epoch, - QUAD inUseBlocks, - BOOL resetCountsOnly ); + ZfsVolume_s *zVolume, + QUAD totalBlocks, + Time_t epoch, + QUAD inUseBlocks, + BOOL resetCountsOnly ); -void ZLSSVOL_InitVDB( - ZfsVolume_s *zVolume, - Blknum_t lvdb, - Blknum_t vdb, - Blknum_t btSpecialBlock, - Time_t createTime, - LONG rebuildCount, - Time_t rebuildTime, - BOOL virtualFileFlag ); +void ZLSSVOL_InitVDB( + ZfsVolume_s *zVolume, + Blknum_t lvdb, + Blknum_t vdb, + Blknum_t btSpecialBlock, + Time_t createTime, + LONG rebuildCount, + Time_t rebuildTime, + BOOL virtualFileFlag ); void ZLSSPOOL_PoolVolDataInitialize( - ZfsPool_s *pool, - StorPool_s *storagepool); + ZfsPool_s *pool, + StorPool_s *storagepool); void ZLSSPOOL_InitLPDB( - ZlssPool_s *zlssPool, - Blknum_t totalBlocks, - BOOL repairFlag ); + ZlssPool_s *zlssPool, + Blknum_t totalBlocks, + BOOL repairFlag ); void ZLSSPOOL_InitPDB( - ZlssPool_s *zlssPool, - Blknum_t totalBlocks, - LONG blockShift, - QUAD persistentElsewhere, - BOOL repairFlag ); + ZlssPool_s *zlssPool, + Blknum_t totalBlocks, + LONG blockShift, + QUAD persistentElsewhere, + BOOL repairFlag ); STATUS ZLVAIPU_FTValidate( - GeneralMsg_s *genMsg, - Buffer_s *parentBuffer ); + GeneralMsg_s *genMsg, + Buffer_s *parentBuffer ); STATUS ZLSSVOL_LV_ZVLDeleteAsync( - GeneralMsg_s *genMsg, - unicode_t *zVolumeName, - unicode_t *containerVolumeName ); + GeneralMsg_s *genMsg, + unicode_t *zVolumeName, + unicode_t *containerVolumeName ); STATUS ZLSSVOL_LVD_DeleteStateUpdate( - GeneralMsg_s *genMsg, - ZlssVolumeLocator_s *zvlBeast, - ZfsVolume_s *zVolume, - LONG newDeleteState ); + GeneralMsg_s *genMsg, + ZlssVolumeLocator_s *zvlBeast, + ZfsVolume_s *zVolume, + LONG newDeleteState ); STATUS ZLSSVOL_LVD_DeleteActionPurgeInternal( - GeneralMsg_s *genMsg, - unicode_t *volumeName, - ZfsVolume_s *zVolume ); + GeneralMsg_s *genMsg, + unicode_t *volumeName, + ZfsVolume_s *zVolume ); STATUS ZLSSVOL_LVD_DeleteActionSalvageInternal( - GeneralMsg_s *genMsg, - unicode_t *volumeName, - ZfsVolume_s *zVolume ); + GeneralMsg_s *genMsg, + unicode_t *volumeName, + ZfsVolume_s *zVolume ); STATUS ZLSSVOL_LVD_ChangeVolumeStateWhenPoolLockedActive( - GeneralMsg_s *genMsg, - ZfsVolume_s *zVolume, - NINT destState, - NINT mode ); + GeneralMsg_s *genMsg, + ZfsVolume_s *zVolume, + NINT destState, + NINT mode ); STATUS ZLSSVOL_LVD_DeleteAPIInternal( - GeneralMsg_s *genMsg, - unicode_t *oldVolumeName, - NINT mode, - VolumeID_t *retVolumeID); + GeneralMsg_s *genMsg, + unicode_t *oldVolumeName, + NINT mode, + VolumeID_t *retVolumeID); STATUS ZLSSVOL_LV_ZVLRenameInternal( - GeneralMsg_s *genMsg, - unicode_t *oldVolumeName, - unicode_t *newVolumeName, - unicode_t *containerVolumeName ); + GeneralMsg_s *genMsg, + unicode_t *oldVolumeName, + unicode_t *newVolumeName, + unicode_t *containerVolumeName ); void ZLSSVOL_LVD_UIBasic( void ); void ZLSSVOL_LVD_UISalvageable( void ); STATUS ZLVAIPU_Step5_Async( - GeneralMsg_s *genMsg, - ZlssPool_s *zlssPool ); + GeneralMsg_s *genMsg, + ZlssPool_s *zlssPool ); void ZLVAIPU_AbortXLocal( - GeneralMsg_s *genMsg, - ZfsPool_s *zfsPool ); + GeneralMsg_s *genMsg, + ZfsPool_s *zfsPool ); #endif /* #ifndef _ZLSSLOGICALVOLUME_H_ */ diff --git a/src/nwnss/zlss/zlssMSAP.c b/src/nwnss/zlss/zlssMSAP.c index 02d37d0..2714d57 100644 --- a/src/nwnss/zlss/zlssMSAP.c +++ b/src/nwnss/zlss/zlssMSAP.c @@ -67,8 +67,8 @@ LONG ZLSSPOOL_CalculateChecksum( LONG *buffer, NINT numberOfLONGs ); BOOL MSAP_Enabled = TRUE; /* Command line option to enable/disable MSAP - * at the server level. - */ + * at the server level. + */ NINT MSAP_OwnershipRevalidateAsyncInstance = 0; /* Validates the size is correct at compile time */ @@ -257,9 +257,9 @@ void MSAP_BlockInitialize( msap->MSAP_InternalID = zlssPool->ZP_InternalID; msap->MSAP_ServerIDFlags = MSAP_FLAGS_INIT; /* We will take ownership so that when we activate the - * first time on physically local pools we do not have - * to wait one minute for a probe request timeout. - */ + * first time on physically local pools we do not have + * to wait one minute for a probe request timeout. + */ COMN_ServerIDGet( &msap->MSAP_ServerID ); return; @@ -419,20 +419,20 @@ STATUS MSAP_SectorWrite( zfsPool = ZLSS_POOL_TO_ZFS_POOL( zlssPool ); if ( zfsPool == NULL ) { - zASSERT("Pool is no longer valid" == NULL); + zASSERT("Pool is no longer valid" == NULL); return(zERR_POOL_NOT_ACCESSIBLE); } storagepool = zfsPool->storagepool; if ( storagepool == NULL ) { - zASSERT("Pool is no longer valid" == NULL); + zASSERT("Pool is no longer valid" == NULL); return(zERR_POOL_NOT_ACCESSIBLE); } phypool = storagepool->phypool; if ( phypool == NULL ) { - zASSERT("Pool is no longer valid" == NULL); + zASSERT("Pool is no longer valid" == NULL); return(zERR_POOL_NOT_ACCESSIBLE); } @@ -591,20 +591,20 @@ STATUS MSAP_SectorRead( zfsPool = ZLSS_POOL_TO_ZFS_POOL( zlssPool ); if ( zfsPool == NULL ) { - zASSERT("Pool is no longer valid" == NULL); + zASSERT("Pool is no longer valid" == NULL); return(zERR_POOL_NOT_ACCESSIBLE); } storagepool = zfsPool->storagepool; if ( storagepool == NULL ) { - zASSERT("Pool is no longer valid" == NULL); + zASSERT("Pool is no longer valid" == NULL); return(zERR_POOL_NOT_ACCESSIBLE); } phypool = storagepool->phypool; if ( phypool == NULL ) { - zASSERT("Pool is no longer valid" == NULL); + zASSERT("Pool is no longer valid" == NULL); return(zERR_POOL_NOT_ACCESSIBLE); } @@ -696,23 +696,23 @@ void MSAP_PoolStateInfoDestruct( zASSERT( pSI != NULL ); /* Should not be NULL, but routine supports */ if ( pSI != NULL ) { /* Because we set the MPSI_scheduled flag in the timer routine - * which runs synchronous to being removed from the timer list - * we can safily cancel the timer and then wait if the thread was - * already scheduled. - */ + * which runs synchronous to being removed from the timer list + * we can safily cancel the timer and then wait if the thread was + * already scheduled. + */ pSI->MPSI_terminate = TRUE; /* Must not have a running thread place itself back on - * the timer list after we do a CANCEL. - */ + * the timer list after we do a CANCEL. + */ CANCEL_ALARM( pSI->MPSI_timer ); while ( pSI->MPSI_scheduled ) { LB_delay( 200 ); } /* Bug Fix(03Mar13) - Must wait until AFTER the Owner Thread has treminated - * to clear the Pool's MSAP pointer. The owner thread assumes that - * the thread can access the MSAP via the ZlssPool_s.ZP_MSAPInfo. - */ + * to clear the Pool's MSAP pointer. The owner thread assumes that + * the thread can access the MSAP via the ZlssPool_s.ZP_MSAPInfo. + */ pSI->MPSI_zlssPool->ZP_MSAPInfo = NULL; COMN_Release( &pSI->MPSI_zlssPool ); } @@ -810,7 +810,7 @@ BOOL MSAP_AreWeClearOwnerCluster( * MSAP_AreWeClearOwner() - * Returns TRUE if the caller clearly owns the pool. This means that we * are the owner and that there are not outstanding probes. A probe indicates - * that another server MAY be ready to take ownership. + * that another server MAY be ready to take ownership. * */ BOOL MSAP_AreWeClearOwner( @@ -885,9 +885,9 @@ STATUS MSAP_OwnershipTakePhysical( MSAP_PoolStateInfo_s *pSI; MSAP_Block_s *mSAP; - zASSERT( zlssPool->ZP_MSAPInfo != NULL ); - pSI = zlssPool->ZP_MSAPInfo; - mSAP = &pSI->MPSI_mSAP; + zASSERT( zlssPool->ZP_MSAPInfo != NULL ); + pSI = zlssPool->ZP_MSAPInfo; + mSAP = &pSI->MPSI_mSAP; MSAP_OwnershipTake( mSAP, &pSI->MPSI_serverID, &pSI->MPSI_clusterID, mSAPFlags ); status = MSAP_BlockWrite( zlssPool, mSAP, MSAP_BW_DEFAULT ); @@ -910,9 +910,9 @@ STATUS MSAP_ClusterIDPhysical( MSAP_PoolStateInfo_s *pSI; MSAP_Block_s *mSAP; - zASSERT( zlssPool->ZP_MSAPInfo != NULL ); - pSI = zlssPool->ZP_MSAPInfo; - mSAP = &pSI->MPSI_mSAP; + zASSERT( zlssPool->ZP_MSAPInfo != NULL ); + pSI = zlssPool->ZP_MSAPInfo; + mSAP = &pSI->MPSI_mSAP; mSAP->MSAP_ClusterID = pSI->MPSI_clusterID; status = MSAP_BlockWrite( zlssPool, mSAP, MSAP_BW_DEFAULT ); @@ -936,20 +936,20 @@ STATUS MSAP_OwnershipTakeBackPhysical( MSAP_Block_s *mSAP; STATUS status; - zASSERT( zlssPool->ZP_MSAPInfo != NULL ); - pSI = zlssPool->ZP_MSAPInfo; - mSAP = &pSI->MPSI_mSAP; - /* Mark us as owner */ + zASSERT( zlssPool->ZP_MSAPInfo != NULL ); + pSI = zlssPool->ZP_MSAPInfo; + mSAP = &pSI->MPSI_mSAP; + /* Mark us as owner */ MSAP_OwnershipTake( mSAP, &pSI->MPSI_serverID, &pSI->MPSI_clusterID, MSAP_FLAGS_STEAL ); /* Indicate that we are doing a Probe. This will force us to go through - * the Probe Request State when pool is re-activated. This is desired - * as it ensures that we sync up with the server that stole the pool. - */ + * the Probe Request State when pool is re-activated. This is desired + * as it ensures that we sync up with the server that stole the pool. + */ MSAP_ProbeRequest( mSAP, &pSI->MPSI_serverID, &pSI->MPSI_clusterID ); /* We must use MSAP_BW_IGNORE_DISABLE bit so that we can - * do the physical write after we have 'disabled the pool' in - * STATE 3. - */ + * do the physical write after we have 'disabled the pool' in + * STATE 3. + */ status = MSAP_BlockWrite( zlssPool, mSAP, MSAP_BW_IGNORE_DISABLE ); return( status ); @@ -1074,12 +1074,12 @@ STATUS MSAP_OwnershipValidateProbe( COMN_SETUP_GENERAL_MSG_NOSA( &dummyGenMsg ); (void)COMN_GetPoolName( &dummyGenMsg, &zlssPool->ZP_Pool, aStack->poolName, NELEMS(aStack->poolName) ); - zASSERT( zlssPool->ZP_MSAPInfo != NULL ); - pSI = zlssPool->ZP_MSAPInfo; - mSAP = &pSI->MPSI_mSAP; + zASSERT( zlssPool->ZP_MSAPInfo != NULL ); + pSI = zlssPool->ZP_MSAPInfo; + mSAP = &pSI->MPSI_mSAP; /*** STATE - PROBE REQUEST ***/ - MSAP_EventLog4( WHERE, zlssPool, LOG_WARNING, + MSAP_EventLog4( WHERE, zlssPool, LOG_WARNING, &pSI->MPSI_serverID, &pSI->MPSI_clusterID, /* Who we are */ &mSAP->MSAP_ServerID, &mSAP->MSAP_ClusterID, /* Who they are */ MSGNot("Probe request generated.") ); @@ -1092,14 +1092,14 @@ STATUS MSAP_OwnershipValidateProbe( waitTime = mSAP->MSAP_ProbeReponseSeconds; if ( waitTime < ((NINT)mSAP->MSAP_ProbeSeconds + MSAP_IO_DELAY) ) { /* We must wait at least MSAP_IO_DELAY seconds more than how often owner - * does a detect. This is required as the owner needs to - * complete a read and a write I/O after their delay. - */ + * does a detect. This is required as the owner needs to + * complete a read and a write I/O after their delay. + */ waitTime = (NINT)mSAP->MSAP_ProbeSeconds + MSAP_IO_DELAY; } /* Round up because we divide to get count of time periods (we can not wrap as - * original time stored in a WORD). - */ + * original time stored in a WORD). + */ waitTime += (MSAP_RESPONSE_CHECK_SECONDS-1); aprintf( NSS_POOL_COLOR, MSG(" ** Pool ownership detection (this may take %d seconds to complete).\n",639), waitTime ); @@ -1194,11 +1194,11 @@ STATUS MSAP_PoolActivateLogic( if ( clearOwner ) { /*** STATE - MARK AS OWNER ***/ /* We must do a 'Mark As Owner' because it updates the ServerID which may have - * changed from zZERR_GUID to a real value since we last took ownership. - * For example, the pool was mark as zPOOL_FEATURE_SHARED_CLUSTER. - * - * The 'Mark As Owner' also updates our ownership stats which we like. - */ + * changed from zZERR_GUID to a real value since we last took ownership. + * For example, the pool was mark as zPOOL_FEATURE_SHARED_CLUSTER. + * + * The 'Mark As Owner' also updates our ownership stats which we like. + */ status = MSAP_OwnershipTakePhysical( zlssPool, MSAP_FLAGS_DEFAULT ); if ( status != zOK ) { @@ -1317,9 +1317,9 @@ STATUS MSAP_ClusterIDUpdate( MSAP_EventLog2( WHERE, zlssPool, LOG_NOTICE, &zlssPool->ZP_MSAPInfo->MPSI_serverID, &compareID, /* Who we are */ MSGNot("New cluster ID.") ); - /* We have a new Cluster ID - update memory copy and MSAP - * block with our new ClusterID - */ + /* We have a new Cluster ID - update memory copy and MSAP + * block with our new ClusterID + */ zlssPool->ZP_MSAPInfo->MPSI_clusterID = compareID; /* Struct copy */ status = MSAP_ClusterIDPhysical( zlssPool ); return( status ); @@ -1367,8 +1367,8 @@ STATUS MSAP_AIPU4007To4008PDB( return( zFAILURE ); } block = ((ZlssPoolBlock_s *)buffer->pBuf.data); - checksum = ZLSSPOOL_CalculateChecksum( (LONG *)block, sizeof(*block)/4 ); - + checksum = ZLSSPOOL_CalculateChecksum( (LONG *)block, sizeof(*block)/4 ); + zASSERT( block->ZPB_zlssPool.PZP_magic == ZLSSPOOLINFO_MAGIC ); if ( (checksum != 0) || (block->ZPB_zlssPool.PZP_magic != ZLSSPOOLINFO_MAGIC) ) { @@ -1377,19 +1377,19 @@ STATUS MSAP_AIPU4007To4008PDB( } block->ZPB_pool.PP_enabledFeatures |= zPOOL_FEATURE_MSAP; block->ZPB_zlssPool.PZP_checksum = 0; - checksum = ZLSSPOOL_CalculateChecksum((LONG*)block,sizeof(*block)/4 ); + checksum = ZLSSPOOL_CalculateChecksum((LONG*)block,sizeof(*block)/4 ); block->ZPB_zlssPool.PZP_checksum = 0 - checksum; /* Wait for this buffer to be synchronously written before we - * return from here - */ + * return from here + */ initAgent( &waitAgent, NULL, MSGNot("Write Pool Data Agent") ); bind( &waitAgent, &buffer->agent ); CACHE_DIRTY_RELEASE( buffer ); defaultFlushWait( &waitAgent ); /* Turn on in memory because - * 1) This is where code checks if on. - * 2) If PDB is re-written then it needs to be correct. - */ + * 1) This is where code checks if on. + * 2) If PDB is re-written then it needs to be correct. + */ zlssPool->ZLSSPOOLenabledFeatures |= zPOOL_FEATURE_MSAP; return( zOK ); @@ -1514,7 +1514,7 @@ STATUS MSAP_MSAPActivate( // */ // } #endif - /* Determine if this is a pool that we need to watch */ + /* Determine if this is a pool that we need to watch */ watchPool = MSAP_PoolInhibitorLogicRequired( zlssPool ); zASSERT( zlssPool->ZP_MSAPInfo == NULL ); @@ -1540,8 +1540,8 @@ STATUS MSAP_MSAPActivate( { (void)MSAP_OwnershipTakePhysical( zlssPool, MSAP_FLAGS_DEFAULT & ~MSAP_FLAGS_MSAP ); /* We ignore errors as we are only trying to track - * that the pool is not being watched. - */ + * that the pool is not being watched. + */ } } MSAP_PoolStateInfoZlssPoolFree( zlssPool ); @@ -1555,8 +1555,8 @@ STATUS MSAP_MSAPActivate( return( zFAILURE ); } /* Starts up 'background' process to handle revalidates and - * probes. - */ + * probes. + */ status = MSAP_PoolOwnerLogic( zlssPool ); if ( status != zOK ) { /* Unable to get main 'background' logic going. */ @@ -1652,7 +1652,7 @@ STATUS MSAP_ProbeResponsePhysical( * */ void MSAP_OwnerThread( - FsmLite_s *fsmLite, + FsmLite_s *fsmLite, MSAP_PoolStateInfo_s *pSI ) { @@ -1662,17 +1662,17 @@ void MSAP_OwnerThread( zASSERT( pSI->MPSI_zlssPool != NULL ); zlssPool = pSI->MPSI_zlssPool; zASSERT( zlssPool->ZP_MSAPInfo != NULL ); - + pSI->MPSI_lastPreOwnerUTC = GetUTCTime(); (void)MSAP_PoolOwnerLogic( zlssPool ); pSI->MPSI_lastPostOwnerUTC = GetUTCTime(); /* Our oneshot should already be rescheduled. It has not run - * because we own the NSS SPIN lock have have not YIELDED!!! - * Note that if we get an error then oneshot not scheduled, but - * we have requested the pool to be disabled. This will cause - * MSAP_MSAPDeactivate to be called at some point to clean up. - */ + * because we own the NSS SPIN lock have have not YIELDED!!! + * Note that if we get an error then oneshot not scheduled, but + * we have requested the pool to be disabled. This will cause + * MSAP_MSAPDeactivate to be called at some point to clean up. + */ pSI->MPSI_scheduled = FALSE; return; @@ -1703,7 +1703,7 @@ void MSAP_WorkScheduleTimer( pSI->MPSI_scheduled = TRUE; pSI->MPSI_scheduledUTC = GetUTCTime(); /* Schedule a thread to do the work later (so we will not block) */ - WORK_Schedule( &pSI->MPSI_fsmLite, (voidfunc_t)MSAP_OwnerThread, (ADDR)pSI ); + WORK_Schedule( &pSI->MPSI_fsmLite, MSAP_OwnerThread, (ADDR)pSI ); return; } /* End of MSAP_WorkScheduleTimer() */ @@ -1726,8 +1726,8 @@ void MSAP_OwnershipRevalidateAsync( pSI = zlssPool->ZP_MSAPInfo; if ( pSI->MPSI_terminate ) { /* Terminate request so do not set one shot as caller has already - * canceled and can not handle us setting. - */ + * canceled and can not handle us setting. + */ pSI->MPSI_lastTerminateUTC = GetUTCTime(); return; } @@ -1806,7 +1806,7 @@ void MSAP_OwnershipFatal( zfsPool = ZLSS_POOL_TO_ZFS_POOL( zlssPool ); volume = ZFS_POOL_TO_VOLUME( zfsPool ); /* Tell the common layer that we wish to disable this pool. - */ + */ COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); (void)COMN_VolumeAlert( &dummyGenMsg, NULL, volume, NULL, 0, 0, fatalStatus, WHERE, @@ -1835,9 +1835,9 @@ STATUS MSAP_OwnershipPoolDisable( zfsPool = ZLSS_POOL_TO_ZFS_POOL( zlssPool ); volume = ZFS_POOL_TO_VOLUME( zfsPool ); /* Tell the common layer that we wish to disable this pool. - * This is done before TAKE BACK because it allows use to - * stop I/O quicker and therefore reduce pool corruption. - */ + * This is done before TAKE BACK because it allows use to + * stop I/O quicker and therefore reduce pool corruption. + */ COMN_SETUP_GENERAL_MSG_NOSA(&dummyGenMsg); (void)COMN_VolumeAlert( &dummyGenMsg, NULL, volume, NULL, 0, 0, zERR_MSAP_MULTIPLE_SERVER_ACCESS_DETECTED, WHERE, @@ -1872,7 +1872,7 @@ STATUS MSAP_OwnershipRevalidate( } Stack_s; STACK_ALLOC(); - zASSERT( zlssPool->ZP_MSAPInfo != NULL ); + zASSERT( zlssPool->ZP_MSAPInfo != NULL ); mSAP = &zlssPool->ZP_MSAPInfo->MPSI_mSAP; /*** STATE 2 - REVALIDATE ***/ @@ -1943,3 +1943,6 @@ STATUS MSAP_PoolOwnerLogic( return( fatalStatus ); } /* End of MSAP_PoolOwnerLogic() */ + + + diff --git a/src/nwnss/zlss/zlssMSAP.h b/src/nwnss/zlss/zlssMSAP.h index 2c71946..134f9a0 100644 --- a/src/nwnss/zlss/zlssMSAP.h +++ b/src/nwnss/zlss/zlssMSAP.h @@ -46,104 +46,104 @@ #define MSAP_RESPONSE_CHECK_SECONDS 2 /* Check for a probe response every 2 seconds */ #define MAX_IO_RETRY_COUNT_ALLEN 3 /* Allens says three is the most we should retry */ #define MSAP_IO_DELAY 15 /* Amount of time that a read and then a write - * must be able to complete in. Used by servers - * waiting for a probe request to ensure that they - * have given a 'owner' enough time to respond. - */ + * must be able to complete in. Used by servers + * waiting for a probe request to ensure that they + * have given a 'owner' enough time to respond. + */ typedef struct MSAP_Block_s { - LONG MSAP_SignatureMinor; + LONG MSAP_SignatureMinor; #define MSAP_SIGNATURE 0x4d534150 /* "MSAP" */ - LONG MSAP_SignatureMajor; /* By having second; scan can use current logic and - * if not a known match can find unknown blocks - * by looking at 2nd long of block. - */ - Lsn_t MSAP_LsnNotUsed; /* Not currently used as block is not transactioned. */ - GUID_t MSAP_InternalID; /* Must be at offset 16. This is set to the pool's - * internal ID at init time. This value is never - * changed. - */ - GUID_t MSAP_ServerID; /* This indicates the server that currently owns - * access to the pool. See specification for - * details. The server calls this field the pool id. - */ - GUID_t MSAP_ClusterID; /* This indicates the cluster that we are active in. - * The value zZERO_GUID indicates we are not part - * of a cluster at this time. I.E. if we are part - * of a cluster, but not running cluster software - * then this field has zZERO_GUID in it. - */ - GUID_t MSAP_ProbeRequestID; /* If non-zero then the Server ID of the server that - * is doing a probe. When doing a probe set this field - * to the Server ID and the MSAP_ProbeResponse field - * to zero. Also update all other MSAP_ProbeRequestxxx fields. - */ - GUID_t MSAP_ProbeResponseID; /* If non-zero then the Server ID of the server that - * did the probe response. When responding to a probe - * this field is set to MSAP_ProbeRequestID and then - * MSAP_ProbeRequestID is set to 0. All other - * MSAP_ProbeResponsexxx fields are set. - */ - LONG MSAP_InitialUTC; /* UTC of time that block was initialized */ - LONG MSAP_WroteUTC; /* UTC of time that last write occurred */ - WORD MSAP_VersionMajor; + LONG MSAP_SignatureMajor; /* By having second; scan can use current logic and + * if not a known match can find unknown blocks + * by looking at 2nd long of block. + */ + Lsn_t MSAP_LsnNotUsed; /* Not currently used as block is not transactioned. */ + GUID_t MSAP_InternalID; /* Must be at offset 16. This is set to the pool's + * internal ID at init time. This value is never + * changed. + */ + GUID_t MSAP_ServerID; /* This indicates the server that currently owns + * access to the pool. See specification for + * details. The server calls this field the pool id. + */ + GUID_t MSAP_ClusterID; /* This indicates the cluster that we are active in. + * The value zZERO_GUID indicates we are not part + * of a cluster at this time. I.E. if we are part + * of a cluster, but not running cluster software + * then this field has zZERO_GUID in it. + */ + GUID_t MSAP_ProbeRequestID; /* If non-zero then the Server ID of the server that + * is doing a probe. When doing a probe set this field + * to the Server ID and the MSAP_ProbeResponse field + * to zero. Also update all other MSAP_ProbeRequestxxx fields. + */ + GUID_t MSAP_ProbeResponseID; /* If non-zero then the Server ID of the server that + * did the probe response. When responding to a probe + * this field is set to MSAP_ProbeRequestID and then + * MSAP_ProbeRequestID is set to 0. All other + * MSAP_ProbeResponsexxx fields are set. + */ + LONG MSAP_InitialUTC; /* UTC of time that block was initialized */ + LONG MSAP_WroteUTC; /* UTC of time that last write occurred */ + WORD MSAP_VersionMajor; #define MSAP_VERSION_MAJOR 1 - WORD MSAP_VersionMinor; + WORD MSAP_VersionMinor; #define MSAP_VERSION_MINOR 0 - WORD MSAP_ProbeRequestIDListSlot; /* 0 to 7. SLot to use next in Probe request ID list */ - WORD MSAP_ProbeResponseIDListSlot; /* 0 to 7. SLot to use next in Probe response ID list */ - WORD MSAP_ServerIDListSlot; /* 0 to 19. Slot to use next in Owner ID list */ - WORD MSAP_ProbeSeconds; /* Amount of time that owner lets go by before doing a - * check for porbe requests. - */ + WORD MSAP_ProbeRequestIDListSlot; /* 0 to 7. SLot to use next in Probe request ID list */ + WORD MSAP_ProbeResponseIDListSlot; /* 0 to 7. SLot to use next in Probe response ID list */ + WORD MSAP_ServerIDListSlot; /* 0 to 19. Slot to use next in Owner ID list */ + WORD MSAP_ProbeSeconds; /* Amount of time that owner lets go by before doing a + * check for porbe requests. + */ #define MSAP_PROBE_SECONDS_DEFAULT (14) /* Originally 45 in specification */ - WORD MSAP_ProbeSecondsMinimum; /* Minimum value for above */ + WORD MSAP_ProbeSecondsMinimum; /* Minimum value for above */ #define MSAP_PROBE_SECONDS_MINIMUM (1) - WORD MSAP_ProbeSecondsMaximum; /* Maximum value for above */ + WORD MSAP_ProbeSecondsMaximum; /* Maximum value for above */ #define MSAP_PROBE_SECONDS_MAXIMUM (5*60) - QUAD MSAP_ServerIDCount; /* Total number of owner updates that have ever been done. */ - QUAD MSAP_ProbeRequestCount; /* Total number of probe request ever done. */ - QUAD MSAP_ProbeResponseCount; /* Total number of probe response ever done. */ + QUAD MSAP_ServerIDCount; /* Total number of owner updates that have ever been done. */ + QUAD MSAP_ProbeRequestCount; /* Total number of probe request ever done. */ + QUAD MSAP_ProbeResponseCount; /* Total number of probe response ever done. */ #define MSAP_REQUEST_COUNT 12 - GUID_t MSAP_ProbeRequestIDList[MSAP_REQUEST_COUNT]; /* Last z probe requestors. If items - * are in this list then either someone has their SAN set up - * wrong (I.E. allowing mulitple servers to access a POOL - * without clustering software) OR the Server ID has changed. - */ - GUID_t MSAP_ProbeRequestIDClusterList[MSAP_REQUEST_COUNT]; - LONG MSAP_ProbeRequestIDListUTC[MSAP_REQUEST_COUNT]; /* UTC of above probes ID List */ + GUID_t MSAP_ProbeRequestIDList[MSAP_REQUEST_COUNT]; /* Last z probe requestors. If items + * are in this list then either someone has their SAN set up + * wrong (I.E. allowing mulitple servers to access a POOL + * without clustering software) OR the Server ID has changed. + */ + GUID_t MSAP_ProbeRequestIDClusterList[MSAP_REQUEST_COUNT]; + LONG MSAP_ProbeRequestIDListUTC[MSAP_REQUEST_COUNT]; /* UTC of above probes ID List */ #define MSAP_RESPONSE_COUNT 12 - GUID_t MSAP_ProbeResponseIDList[MSAP_RESPONSE_COUNT]; /* Last x probe responders (owner who did response). */ - GUID_t MSAP_ProbeResponseIDTargetList[MSAP_RESPONSE_COUNT]; /* Last x probe responders targets (who reponse was directed to). */ - LONG MSAP_ProbeResponseIDListUTC[MSAP_RESPONSE_COUNT]; /* UTC of above probe responses ID List */ + GUID_t MSAP_ProbeResponseIDList[MSAP_RESPONSE_COUNT]; /* Last x probe responders (owner who did response). */ + GUID_t MSAP_ProbeResponseIDTargetList[MSAP_RESPONSE_COUNT]; /* Last x probe responders targets (who reponse was directed to). */ + LONG MSAP_ProbeResponseIDListUTC[MSAP_RESPONSE_COUNT]; /* UTC of above probe responses ID List */ #define MSAP_POOL_COUNT 24 - GUID_t MSAP_ServerIDList[MSAP_POOL_COUNT]; /* Last y pool owners. This is updated every time - * a pool is activated. - */ - GUID_t MSAP_ClusterIDList[MSAP_POOL_COUNT]; /* The cluster that the above owners are part of */ - LONG MSAP_ServerIDListUTC[MSAP_POOL_COUNT]; /* UTC of when above took ownership */ - BYTE MSAP_ServerIDListFlags[MSAP_POOL_COUNT];/* 0x01 indicates that the owner is not running revalidate - * logic. Either the pool is marked as no MSAP or MSAP - * is turned off at the server. This information is - * useful on scanned pools to detect if the pool should - * have had MSAP enabled. - */ - BYTE MSAP_ServerIDFlags; + GUID_t MSAP_ServerIDList[MSAP_POOL_COUNT]; /* Last y pool owners. This is updated every time + * a pool is activated. + */ + GUID_t MSAP_ClusterIDList[MSAP_POOL_COUNT]; /* The cluster that the above owners are part of */ + LONG MSAP_ServerIDListUTC[MSAP_POOL_COUNT]; /* UTC of when above took ownership */ + BYTE MSAP_ServerIDListFlags[MSAP_POOL_COUNT];/* 0x01 indicates that the owner is not running revalidate + * logic. Either the pool is marked as no MSAP or MSAP + * is turned off at the server. This information is + * useful on scanned pools to detect if the pool should + * have had MSAP enabled. + */ + BYTE MSAP_ServerIDFlags; #define MSAP_FLAGS_DEFAULT MSAP_FLAGS_MSAP #define MSAP_FLAGS_MSAP 0x01 #define MSAP_FLAGS_STEAL 0x02 /* Set when owner steals back a stolen pool */ #define MSAP_FLAGS_INIT 0x04 /* Block initialized/rebuilt */ - BYTE MSAP_Reserver4[1]; - WORD MSAP_ProbeReponseSeconds; + BYTE MSAP_Reserver4[1]; + WORD MSAP_ProbeReponseSeconds; #define MSAP_PROBE_RESPONSE_SECONDS_DEFAULT (MSAP_PROBE_SECONDS_DEFAULT+MSAP_IO_DELAY) - LONG MSAP_Reserved3[36]; - LONG MSAP_SignatureMinor2; - /* MSAP block is only 2K - Went to 4K in Feb 2004 for NSS 4.x as Paul - * is requiring all I/O to be 4K. */ - BYTE MSAP_Junk[2048]; /* Since block was 2K at some point this part of block - * will have random data in it. - */ + LONG MSAP_Reserved3[36]; + LONG MSAP_SignatureMinor2; + /* MSAP block is only 2K - Went to 4K in Feb 2004 for NSS 4.x as Paul + * is requiring all I/O to be 4K. */ + BYTE MSAP_Junk[2048]; /* Since block was 2K at some point this part of block + * will have random data in it. + */ } NSS_MEDIA_STRUCTURE(MSAP_Block_s,MSAP_Junk[2048]) MSAP_Block_s; @@ -157,149 +157,149 @@ typedef struct MSAP_Block_s * to this allocated structure. */ typedef struct MSAP_PoolStateInfo_s { - LONG MPSI_signature; + LONG MPSI_signature; #define MSAP_MPSI_SIGNATURE 0x49586378 - ZlssPool_s *MPSI_zlssPool; - Time_t MPSI_scheduledUTC; /* Last time scheduled */ - /* In December 2003, I saw that MSAP would not - * destruct because MPSI_scheduled never went FALSE. The - * MPSI_scheduledUTC was about 6 hours before curent time. - * I only saw this on my Nakoma SP1 server. - */ - Time_t MPSI_lastDoubleScheduledUTC; /* Debug */ - Time_t MPSI_lastTerminateUTC; /* Debug */ - Time_t MPSI_lastOneShotUTC; /* Debug */ - Time_t MPSI_lastPreOwnerUTC; /* Debug */ - Time_t MPSI_lastPostOwnerUTC; /* Debug */ + ZlssPool_s *MPSI_zlssPool; + Time_t MPSI_scheduledUTC; /* Last time scheduled */ + /* In December 2003, I saw that MSAP would not + * destruct because MPSI_scheduled never went FALSE. The + * MPSI_scheduledUTC was about 6 hours before curent time. + * I only saw this on my Nakoma SP1 server. + */ + Time_t MPSI_lastDoubleScheduledUTC; /* Debug */ + Time_t MPSI_lastTerminateUTC; /* Debug */ + Time_t MPSI_lastOneShotUTC; /* Debug */ + Time_t MPSI_lastPreOwnerUTC; /* Debug */ + Time_t MPSI_lastPostOwnerUTC; /* Debug */ - BOOL MPSI_scheduled; /* TRUE if our thread is running */ - BOOL MPSI_terminate; /* Someone wishes for the thread to terminate. - * The thread must not schedule a new timer - * pop when a terminate is requested. - */ - LONG MPSI_reserved; - GUID_t MPSI_serverID; /* Server ID at time of Pool Activate Logic. - * We store and use because if the real - * server ID changes on us while the pool - * is active we will disable it. - */ - GUID_t MPSI_clusterID; /* Cluster ID at time of Pool Activate Logic. - */ - OneShot_s MPSI_timer; - FsmLite_s MPSI_fsmLite; - MSAP_Block_s MPSI_mSAP; + BOOL MPSI_scheduled; /* TRUE if our thread is running */ + BOOL MPSI_terminate; /* Someone wishes for the thread to terminate. + * The thread must not schedule a new timer + * pop when a terminate is requested. + */ + LONG MPSI_reserved; + GUID_t MPSI_serverID; /* Server ID at time of Pool Activate Logic. + * We store and use because if the real + * server ID changes on us while the pool + * is active we will disable it. + */ + GUID_t MPSI_clusterID; /* Cluster ID at time of Pool Activate Logic. + */ + OneShot_s MPSI_timer; + FsmLite_s MPSI_fsmLite; + MSAP_Block_s MPSI_mSAP; } MSAP_PoolStateInfo_s; STATUS MSAP_OwnershipRevalidate( - ZlssPool_s *zlssPool ); + ZlssPool_s *zlssPool ); STATUS MSAP_OwnershipPoolDisable( - ZlssPool_s *zlssPool ); + ZlssPool_s *zlssPool ); void MSAP_OwnershipFatal( - ZlssPool_s *zlssPool, - STATUS fatalStatus ); + ZlssPool_s *zlssPool, + STATUS fatalStatus ); STATUS MSAP_ProbeResponseNeeded( - ZlssPool_s *zlssPool ); + ZlssPool_s *zlssPool ); void MSAP_OwnershipRevalidateAsync( - ZlssPool_s *zlssPool, - NINT seconds ); + ZlssPool_s *zlssPool, + NINT seconds ); void MSAP_WorkScheduleTimer( - OneShot_s *alarm); + OneShot_s *alarm); void MSAP_OwnerThread( - FsmLite_s *fsmLite, - MSAP_PoolStateInfo_s *pSI ); + FsmLite_s *fsmLite, + MSAP_PoolStateInfo_s *pSI ); STATUS MSAP_ProbeResponsePhysical( - ZlssPool_s *zlssPool, - MSAP_Block_s *mSAP, - GUID_t *serverID ); + ZlssPool_s *zlssPool, + MSAP_Block_s *mSAP, + GUID_t *serverID ); void MSAP_ProbeResponse( - MSAP_Block_s *mSAP, - GUID_t *serverID ); + MSAP_Block_s *mSAP, + GUID_t *serverID ); STATUS MSAP_PoolOwnerLogic( - ZlssPool_s *zlssPool ); + ZlssPool_s *zlssPool ); STATUS MSAP_ClusterIDUpdate( - ZlssPool_s *zlssPool ); + ZlssPool_s *zlssPool ); BOOL MSAP_PoolInhibitorLogicRequired( - ZlssPool_s *zlssPool ); + ZlssPool_s *zlssPool ); STATUS MSAP_PoolActivateLogic( - ZlssPool_s *zlssPool, - GeneralMsg_s *genMsg ); + ZlssPool_s *zlssPool, + GeneralMsg_s *genMsg ); void MSAP_PoolStateInfoZlssPoolFree( - ZlssPool_s *zlssPool ); + ZlssPool_s *zlssPool ); STATUS MSAP_OwnershipValidateProbe( - ZlssPool_s *zlssPool ); + ZlssPool_s *zlssPool ); STATUS MSAP_ProbeRequestPhysical( - ZlssPool_s *zlssPool, - MSAP_Block_s *mSAP, - GUID_t *serverID, - GUID_t *clusterID ); + ZlssPool_s *zlssPool, + MSAP_Block_s *mSAP, + GUID_t *serverID, + GUID_t *clusterID ); void MSAP_ProbeRequest( - MSAP_Block_s *mSAP, - GUID_t *serverID, - GUID_t *clusterID ); + MSAP_Block_s *mSAP, + GUID_t *serverID, + GUID_t *clusterID ); STATUS MSAP_OwnerStatsUpdatePhysical( - ZlssPool_s *zlssPool, - MSAP_Block_s *mSAP, - GUID_t *serverID, - GUID_t *clusterID ); + ZlssPool_s *zlssPool, + MSAP_Block_s *mSAP, + GUID_t *serverID, + GUID_t *clusterID ); void MSAP_OwnerStatsUpdate( - MSAP_Block_s *mSAP, - GUID_t *serverID, - GUID_t *clusterID, - BYTE mSAPFlags ); + MSAP_Block_s *mSAP, + GUID_t *serverID, + GUID_t *clusterID, + BYTE mSAPFlags ); STATUS MSAP_OwnershipTakeBackPhysical( - ZlssPool_s *zlssPool ); + ZlssPool_s *zlssPool ); STATUS MSAP_ClusterIDPhysical( - ZlssPool_s *zlssPool ); + ZlssPool_s *zlssPool ); STATUS MSAP_OwnershipTakePhysical( - ZlssPool_s *zlssPool, - BYTE mSAPFlags ); + ZlssPool_s *zlssPool, + BYTE mSAPFlags ); void MSAP_OwnershipTake( - MSAP_Block_s *mSAP, - GUID_t *serverID, - GUID_t *clusterID, - BYTE mSAPFlags ); + MSAP_Block_s *mSAP, + GUID_t *serverID, + GUID_t *clusterID, + BYTE mSAPFlags ); BOOL MSAP_AreWeOwner( - MSAP_Block_s *mSAP, - GUID_t *serverID ); + MSAP_Block_s *mSAP, + GUID_t *serverID ); BOOL MSAP_AreWeClearOwner( - MSAP_Block_s *mSAP, - GUID_t *serverID ); + MSAP_Block_s *mSAP, + GUID_t *serverID ); BOOL MSAP_AreWeClearOwnerCluster( - ZlssPool_s *zlssPool, - MSAP_Block_s *mSAP, - GUID_t *serverID, - GUID_t *clusterID ); + ZlssPool_s *zlssPool, + MSAP_Block_s *mSAP, + GUID_t *serverID, + GUID_t *clusterID ); MSAP_PoolStateInfo_s *MSAP_PoolStateInfoNew( - ZlssPool_s *zlssPool, - GUID_t *serverID, - GUID_t *clusterID ); + ZlssPool_s *zlssPool, + GUID_t *serverID, + GUID_t *clusterID ); void MSAP_PoolStateInfoFree( - MSAP_PoolStateInfo_s *pSI ); + MSAP_PoolStateInfo_s *pSI ); void MSAP_PoolStateInfoDestruct( - MSAP_PoolStateInfo_s *pSI ); + MSAP_PoolStateInfo_s *pSI ); void MSAP_PoolStateInfoConstruct( - MSAP_PoolStateInfo_s *pSI, - ZlssPool_s *zlssPool, - GUID_t *serverID, - GUID_t *clusterID ); + MSAP_PoolStateInfo_s *pSI, + ZlssPool_s *zlssPool, + GUID_t *serverID, + GUID_t *clusterID ); STATUS MSAP_SectorRead( - ZlssPool_s *zlssPool, - void *ioBuffer ); /* Must be at least 512*4 in size */ + ZlssPool_s *zlssPool, + void *ioBuffer ); /* Must be at least 512*4 in size */ STATUS MSAP_BlockReadAndValidate( - ZlssPool_s *zlssPool, - MSAP_Block_s *mSAP ); + ZlssPool_s *zlssPool, + MSAP_Block_s *mSAP ); STATUS MSAP_BlockRead( - ZlssPool_s *zlssPool, - void *ioBuffer ); + ZlssPool_s *zlssPool, + void *ioBuffer ); STATUS MSAP_SectorWrite( - ZlssPool_s *zlssPool, - void *ioBuffer, /* Must be at least 512*4 in size */ - NINT flags ); + ZlssPool_s *zlssPool, + void *ioBuffer, /* Must be at least 512*4 in size */ + NINT flags ); STATUS MSAP_BlockWrite( - ZlssPool_s *zlssPool, - MSAP_Block_s *mSAP, - NINT flags ); + ZlssPool_s *zlssPool, + MSAP_Block_s *mSAP, + NINT flags ); extern BOOL MSAP_Enabled; diff --git a/src/nwnss/zlss/zlssManage.c b/src/nwnss/zlss/zlssManage.c index 9647a7a..30e9a15 100644 --- a/src/nwnss/zlss/zlssManage.c +++ b/src/nwnss/zlss/zlssManage.c @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** | | (C) Copyright 1995 - 2002, 2004 Novell, Inc. | All Rights Reserved. @@ -35,11 +35,9 @@ | Handle all ZLSS virtual file (XML normally) requests. For example, | the virtual files in _ADMIN:\Manage_NSS\LSS\ZLSS code is in this file. +-------------------------------------------------------------------------*/ -#ifndef NSS_USERSPACE #include #include #include -#endif #include #include @@ -47,7 +45,6 @@ #include #include "nwreg.h" -#include "zParams.h" #include "nssPubs.h" #include "maintenance.h" @@ -231,7 +228,7 @@ STATUS ZLSS_Read4KBlock( ZlssPool_s *zlssPool, Blknum_t blockToRead, struct page } status = zlssBioIOSync (READ, phypool->ZCP_dev, page, blockToRead, - 1, PAGE_SIZE); + 1, PAGE_SIZE); return(status); } /* End of ZLSS_Read4KBlock() */ @@ -289,14 +286,14 @@ STATUS ZLSS_VF_ReadBlock( SIZE = 4, MODE = 5, }; - + ASSERT_MPKNSS_LOCK(); DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (CYAN, "In ZLSS_VF_ReadBlock\n")); /* Resize the output buffer to ensure that we have enough - * space for all the block information data. - */ + * space for all the block information data. + */ status = VIRT_CheckResultSize( virtInfo, 64*1024 ); if ( status != zOK ) { @@ -401,22 +398,22 @@ STATUS ZLSS_VF_ReadBlock( pool = COMN_PoolNameLookup( genMsg, poolName, FALSE, NULL ); if (pool == NULL) { - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_VF_ReadBlock -- Pool not found.\n") ); goto exitNoResources; } if ( !COMN_IsDerivedFrom(pool, zFTYPE_ZLSS_LOGICAL_POOL) ) { /* Not a ZLSS pool so exit */ - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_VF_ReadBlock -- zERR_ZLSSPOOL_NOT_A_ZLSS_POOL\n")); SetErrno( genMsg, zERR_ZLSSPOOL_NOT_A_ZLSS_POOL ); goto exitWithPoolInUse; } zlssPool = (ZlssPool_s *)pool; - X_LATCH( &pool->cvsLatch ); + X_LATCH( &pool->cvsLatch ); /* Prevent pool from leaving CURRENT state on us. - */ + */ if ( pool->POOLstate != state ) { DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_VF_ReadBlock -- Pool not in correct state\n")); @@ -463,7 +460,7 @@ exitWithBuffer4K: __free_page( page ); MPKNSS_UNLOCK(); exitWithCVSLatch: - UNX_LATCH( &pool->cvsLatch ); + UNX_LATCH( &pool->cvsLatch ); exitWithPoolInUse: COMN_Release( &pool ); exitNoResources: @@ -478,7 +475,7 @@ exitNoResources: #ifdef VCF_READTEST /* * ZLSS_VF_ReadTest() - - * + * * * Notes - * This is a ADMIN volume function API. @@ -531,7 +528,7 @@ STATUS ZLSS_VF_ReadTest( TEST = 4, // MODE = 5, }; - + ASSERT_MPKNSS_LOCK(); DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (CYAN, "In ZLSS_VF_ReadTest\n")); @@ -604,14 +601,14 @@ STATUS ZLSS_VF_ReadTest( pool = COMN_PoolNameLookup( genMsg, poolName, FALSE, NULL ); if (pool == NULL) { - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_VF_ReadTest -- Pool not found.\n") ); goto errorExit; } if ( !COMN_IsDerivedFrom(pool, zFTYPE_ZLSS_LOGICAL_POOL) ) { /* Not a ZLSS pool so exit */ - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_VF_ReadTest -- zERR_ZLSSPOOL_NOT_A_ZLSS_POOL\n")); COMN_Release( &pool ); SetErrno( genMsg, zERR_ZLSSPOOL_NOT_A_ZLSS_POOL ); @@ -619,12 +616,12 @@ STATUS ZLSS_VF_ReadTest( } zlssPool = (ZlssPool_s *)pool; /* Prevent pool from leaving current state on us. */ - X_LATCH( &pool->cvsLatch ); + X_LATCH( &pool->cvsLatch ); if ( pool->POOLstate != state ) { - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_VF_ReadTest -- Pool not in correct state\n")); - UNX_LATCH( &pool->cvsLatch ); + UNX_LATCH( &pool->cvsLatch ); COMN_Release( &pool ); SetErrno( genMsg, zERR_POOL_STATE_INCOMPATIBLE ); goto errorExit; @@ -642,16 +639,16 @@ STATUS ZLSS_VF_ReadTest( if ( (blockStart < 0) || ( (state == zVOLSTATE_ACTIVE) && (blockStart >= pool->POOLtotalBlocks) ) ) { - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_VF_ReadTest -- Block out of range\n")); - UNX_LATCH( &pool->cvsLatch ); + UNX_LATCH( &pool->cvsLatch ); COMN_Release( &pool ); SetErrno( genMsg, zERR_BAD_PARAMETER_VALUE ); goto errorExit; } - printf( MSGNot("Starting Read test of %lu blocks.\n"), (unsigned long)numBlocks ); + printf( MSGNot("Starting Read test of %lu blocks.\n"), (unsigned long)numBlocks ); blockEnd = blockStart + numBlocks - 1; zlssPool = (ZlssPool_s *)pool; @@ -662,7 +659,7 @@ STATUS ZLSS_VF_ReadTest( printf(MSGNot(" Pool Blocks - %lu\n"),(unsigned long)pool->POOLtotalBlocks); printf(MSGNot(" Blocks to read - %lu\n"),(unsigned long) numBlocks); - rateObject = malloc( (sizeof(*rateObject)) * rateObjectCount ); + rateObject = malloc( (sizeof(*rateObject)) * rateObjectCount ); if ( rateObject == NULL ) { printf(MSGNot("Could not allocate memory for rateObjectCount\n")); @@ -736,7 +733,7 @@ errorExit: #ifdef VCF_BROWSE /* * ZLSS_VF_Browse() - - * + * * * Notes - * This is a ADMIN volume function API. @@ -779,14 +776,14 @@ STATUS ZLSS_VF_Browse( BROWSEINCREMENT = 2, TEST = 3, }; - + ASSERT_MPKNSS_LOCK(); DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (CYAN, "In ZLSS_VF_Browse\n")); /* Resize the output buffer to ensure that we have enough - * space for all the histogram information. - */ + * space for all the histogram information. + */ status = VIRT_CheckResultSize( virtInfo, 64*1024 ); if ( status != zOK ) { @@ -836,7 +833,7 @@ STATUS ZLSS_VF_Browse( { tagContent[VOLUMENAME].content[i] = LB_toupper(tagContent[VOLUMENAME].content[i]); } - status = utf2uni(tagContent[VOLUMENAME].content, volumeName, + status = utf2uni(tagContent[VOLUMENAME].content, volumeName, sizeof(volumeName)); if ( status == -1 ) { @@ -847,14 +844,14 @@ STATUS ZLSS_VF_Browse( volume = COMN_VolumeNameLookup( genMsg, volumeName, FALSE, NULL ); if (volume == NULL) { - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_VF_Browse -- volume not found.\n") ); goto errorExit; } if ( !COMN_IsDerivedFrom(volume, zFTYPE_ZLSS_VOL) ) { /* Not a ZLSS volume so exit */ - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_VF_Browse -- zERR_ZLSSPOOL_NOT_A_ZLSS_VOLUME\n")); COMN_Release( &volume ); SetErrno( genMsg, zERR_ZFSVOL_NOT_A_ZLSS_VOLUME ); @@ -863,7 +860,7 @@ STATUS ZLSS_VF_Browse( status = COMN_LockVolumeActive( genMsg, volume, FALSE ); if ( status != zOK ) { /* Not ACTIVE */ - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_VF_Browse -- volume not ACTIVE\n")); COMN_Release( &volume ); SetErrno( genMsg, zERR_VOLUME_NOT_IN_ACTIVE_STATE ); @@ -908,8 +905,8 @@ STATUS ZLSS_MGMT_MakeReadFunctionVirtualFile( goto errorExit; } - if ((status = VIRT_MakeReadWriteFuncDataStream(key, NULL, - readRoutine, readParm, writeRoutine, writeParm, cookie, + if ((status = VIRT_MakeReadWriteFuncDataStream(key, NULL, + readRoutine, readParm, writeRoutine, writeParm, cookie, &filePos)) != zOK) { goto errorExit; @@ -947,7 +944,7 @@ STATUS ZLSS_PoolNameGetFromMgmtPath( loc += strlen( "Pool\\" ); if ( loc >= pathLen ) { - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_PoolNameGetFromMgmtPath -- zERR_BAD_PARAMETER_VALUE\n")); SetErrno( genMsg, zERR_BAD_PARAMETER_VALUE ); return( zFAILURE ); @@ -966,7 +963,7 @@ STATUS ZLSS_PoolNameGetFromMgmtPath( if ( backslash == NULL ) { - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_PoolNameGetFromMgmtPath -- zERR_BAD_PARAMETER_VALUE\n")); SetErrno( genMsg, zERR_BAD_PARAMETER_VALUE ); return( zFAILURE ); @@ -974,7 +971,7 @@ STATUS ZLSS_PoolNameGetFromMgmtPath( len = backslash - poolStart; /* Len does not include NULL */ if ( len >= poolNameSize ) { - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_PoolNameGetFromMgmtPath -- zERR_BUFFER_TOO_SMALL\n")); SetErrno( genMsg, zERR_BUFFER_TOO_SMALL ); return( zFAILURE ); @@ -1049,7 +1046,7 @@ typedef struct { *(QUAD *)(retBuf+*retLen) = GetErrno( genMsg ); *retLen += sizeof( QUAD ); bufLenLeft -= sizeof( QUAD ); - + errnoSetter = GetErrnoSetter( genMsg ); len = strlen( errnoSetter ); maxString = zMIN( bufLenLeft, 40 ); @@ -1102,8 +1099,8 @@ STATUS ZLSS_ZLogReadMetadata( virtInfo->resultEOF = 0; if ( (bufferLength - *retLen) < ZLSS_PACK_FROM_ADMIN_VOLUME ) { /* We do not have enough space for our header so - * the read will fail. - */ + * the read will fail. + */ DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (LRED, "Exit ZLSS_ZLogReadMetadata(zFAILURE)\n")); MPKNSS_UNLOCK(); return( zFAILURE ); @@ -1111,10 +1108,10 @@ STATUS ZLSS_ZLogReadMetadata( bzero( header, ZLSS_PACK_FROM_ADMIN_VOLUME ); *retLen += ZLSS_PACK_FROM_ADMIN_VOLUME; /* We are taking first 128 bytes so indicate - * now. We fill in AFTER rest of code does - * its work as we do not yet have the information - * we need to fill in. - */ + * now. We fill in AFTER rest of code does + * its work as we do not yet have the information + * we need to fill in. + */ status = ZLSS_ZLogReadMetadata2( &genMsg, parmLen, parm, bufferLength, buffer, retLen, virtInfo ); @@ -1123,8 +1120,8 @@ STATUS ZLSS_ZLogReadMetadata( DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (CYAN, "Exit ZLSS_ZLogReadMetadata(zOK)\n")); MPKNSS_UNLOCK(); return zOK; /* This indicates the read succeeded althought - * an error no may be set in the read buffer. - */ + * an error no may be set in the read buffer. + */ } /* End of ZLSS_ZLogReadMetadata() */ @@ -1135,7 +1132,7 @@ STATUS ZLSS_ZLogReadMetadata( * Returns - * zOK - Caller must release pool and Active lock. * else error code. - * + * */ Pool_s *ZLSS_ZLogSetup( GeneralMsg_s *genMsg, @@ -1146,7 +1143,7 @@ Pool_s *ZLSS_ZLogSetup( { STATUS status; Pool_s *pool; - char poolName[zMAX_COMPONENT_NAME]; + char poolName[zMAX_COMPONENT_NAME]; unicode_t pname[zMAX_COMPONENT_NAME]; DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (CYAN, "In ZLSS_ZLogSetup\n")); @@ -1154,7 +1151,7 @@ Pool_s *ZLSS_ZLogSetup( status = ZLSS_PoolNameGetFromMgmtPath( genMsg, parm, parmLen, poolName, sizeof( poolName) ); if ( status != zOK ) { - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_ZLogSetup -- Missing pool name in path\n")); return( NULL ); } @@ -1170,14 +1167,14 @@ Pool_s *ZLSS_ZLogSetup( pool = COMN_PoolNameLookup( genMsg, pname, FALSE /*NOT Active Only*/, NULL ); if (pool == NULL) { - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_ZLogSetup -- Pool not found.\n") ); return( NULL ); } if ( !COMN_IsDerivedFrom(pool, zFTYPE_ZLSS_LOGICAL_POOL) ) { /* Not a ZLSS pool so exit */ - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_ZLogSetup -- zERR_ZLSSPOOL_NOT_A_ZLSS_POOL\n")); COMN_Release( &pool ); SetErrno( genMsg, zERR_ZLSSPOOL_NOT_A_ZLSS_POOL); @@ -1186,16 +1183,16 @@ Pool_s *ZLSS_ZLogSetup( if ( activeOnly ) { /* Prevent pool from leaving ACTIVE state on us. We will - * get an error if pool not in ACTIVE state. This is fine - * as the error will be passed back to caller. - */ + * get an error if pool not in ACTIVE state. This is fine + * as the error will be passed back to caller. + */ status = COMN_PoolActiveLock( genMsg, pool ); if ( status != zOK ) { - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_ZLogSetup -- Pool not ACTIVE\n")); - COMN_Release( &pool ); - return NULL; + COMN_Release( &pool ); + return NULL; } } return( pool ); @@ -1217,8 +1214,8 @@ STATUS ZLSS_ZLogReadMetadata2( NINT bufferLength, BYTE **bufferAddress, NINT *retLen, /* This idicates how much of buffer is - * already filled in. - */ + * already filled in. + */ VirtInfo_s *virtInfo) { Pool_s *pool; @@ -1250,30 +1247,30 @@ STATUS ZLSS_ZLogReadMetadata2( SetErrno( genMsg, zERR_ZFSVOL_NOT_A_ZLSS_VOLUME ); return zFAILURE; } - S_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + S_LATCH( &zlogBeast->ZFSLOGbeastLatch ); packedSize = BST_getPackedSize( &zlogBeast->ZFSLOGroot ); if ( packedSize > (bufferLength - *retLen) ) { - DEBUG_PRINTF(TVIRT, DBG_NOINDENT, + DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (RED, "ZLSS_ZLogReadMetadata -- buffer to small\n")); - UNS_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNS_LATCH( &zlogBeast->ZFSLOGbeastLatch ); COMN_PoolActiveUnlock( pool ); COMN_Release( &pool ); SetErrno( genMsg, zERR_BUFFER_TOO_SMALL); return zFAILURE; } - + /* The ZLSS rootbeast pack routine does NOT fill in the next - * three items. The beast tree code does before calling - * the pack routines. Also ZFSPOOL_CheckpointFillin does when - * packing for a checkpoint. - */ + * three items. The beast tree code does before calling + * the pack routines. Also ZFSPOOL_CheckpointFillin does when + * packing for a checkpoint. + */ packedHeader->length = packedSize; packedHeader->magic = NODE_MAGIC; packedHeader->zid = zlogBeast->ZFSLOGzid; BST_doPack( &zlogBeast->ZFSLOGroot, packedHeader, packedSize ); - UNS_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNS_LATCH( &zlogBeast->ZFSLOGbeastLatch ); COMN_PoolActiveUnlock( pool ); COMN_Release( &pool ); @@ -1301,17 +1298,17 @@ STATUS VFS_ssprintf( bufferLength - *retLen, format, args ); if ( added < 0 ) { /* Encoding error in format string */ - return( zERR_BAD_PARAMETER_VALUE ); + return( zERR_BAD_PARAMETER_VALUE ); } if ( added >= (bufferLength - *retLen) ) { /* Could do a re-alloc here and then error on out of memory */ *retLen = bufferLength; /* Say we are using whole buffer so - * that next call to us returns no - * space left. This way callers can call - * us many times in a row and only need - * to check for an error after the last - * call. - */ + * that next call to us returns no + * space left. This way callers can call + * us many times in a row and only need + * to check for an error after the last + * call. + */ return( zERR_BUFFER_TOO_SMALL ); } *retLen += added; @@ -1329,9 +1326,9 @@ STATUS ZLSSPOOL_IOCountTag( NINT bufferLength, BYTE **bufferAddress, NINT *retLen, /* This indicates how much of buffer is - * already filled in. We must update - * as we fill things in. - */ + * already filled in. We must update + * as we fill things in. + */ char *objectName, QUAD rCount, QUAD wCount ) @@ -1348,7 +1345,7 @@ STATUS ZLSSPOOL_IOCountTag( /* * ZLSSPOOL_DisplayIOStatisticsXML() - * This dumps ZLSS Physical I/O statistics into a buffer in XML format. - * + * */ STATUS ZLSSPOOL_DisplayIOStatisticsXML( PoolReadStatistics_s *read, @@ -1357,9 +1354,9 @@ STATUS ZLSSPOOL_DisplayIOStatisticsXML( NINT bufferLength, BYTE **bufferAddress, NINT *retLen ) /* This indicates how much of buffer is - * already filled in. We must update - * as we fill things in. - */ + * already filled in. We must update + * as we fill things in. + */ { STATUS status; @@ -1380,7 +1377,7 @@ STATUS ZLSSPOOL_DisplayIOStatisticsXML( read->PRS_SystemBeast[i], write->PWS_SystemBeast[i]); totalReads += read->PRS_SystemBeast[i]; totalWrites += write->PWS_SystemBeast[i]; - } + } ZLSSPOOL_IOCountTag(bufferLength, bufferAddress, retLen, MSGNot("Superblocks"), read->PRS_SuperBlock, write->PWS_SuperBlock); totalReads += read->PRS_SuperBlock; @@ -1428,8 +1425,8 @@ STATUS ZLSSPOOL_DisplayIOStatisticsXML( /* - ZLSSPOOL_DisplayZLSSPoolSettingsXML() - - This adds pool setting items into the PhysicalIO.xml file. Should + ZLSSPOOL_DisplayZLSSPoolSettingsXML() - + This adds pool setting items into the PhysicalIO.xml file. Should have added to PoolInfo.xml, but that file is not set up to have LSS specific items added to it like VolumeInfo.xml. @@ -1437,16 +1434,16 @@ STATUS ZLSSPOOL_DisplayIOStatisticsXML( If you add lots of settings in here be sure to up the value passed to VIRT_CheckResultSize() in ZLSS_PhysicalIOXML(). I upped from 16K to 20K when I added this routine in Feb 2007. - + */ STATUS ZLSSPOOL_DisplayZLSSPoolSettingsXML( ZlssPool_s *zlssPool, NINT bufferLength, BYTE **bufferAddress, NINT *retLen ) /* This indicates how much of buffer is - * already filled in. We must update - * as we fill things in. - */ + * already filled in. We must update + * as we fill things in. + */ { STATUS status; Time_t now; @@ -1487,9 +1484,9 @@ STATUS ZLSSPOOL_DisplayIOStatisticsPoolXML( NINT bufferLength, BYTE **bufferAddress, NINT *retLen ) /* This indicates how much of buffer is - * already filled in. We must update - * as we fill things in. - */ + * already filled in. We must update + * as we fill things in. + */ { STATUS status; @@ -1505,9 +1502,9 @@ STATUS ZLSSPOOL_DisplayIOStatisticsPoolXMLGlobal( NINT bufferLength, BYTE **bufferAddress, NINT *retLen ) /* This indicates how much of buffer is - * already filled in. We must update - * as we fill things in. - */ + * already filled in. We must update + * as we fill things in. + */ { STATUS status; @@ -1533,8 +1530,8 @@ STATUS ZLSS_PhysicalIO2XMLGlobal( NINT bufferLength, BYTE **bufferAddress, NINT *retLen, /* This idicates how much of buffer is - * already filled in. - */ + * already filled in. + */ VirtInfo_s *virtInfo ) { STATUS status; @@ -1564,8 +1561,8 @@ STATUS ZLSSUT_DisplayAll2( NINT bufferLength, BYTE **bufferAddress, NINT *retLen, /* This idicates how much of buffer is - * already filled in. - */ + * already filled in. + */ VirtInfo_s *virtInfo ) { STATUS status = zOK; @@ -1601,8 +1598,8 @@ STATUS ZLSS_PhysicalIOXMLGlobal( /* We always fill our data at the beginning of the buffer */ virtInfo->resultEOF = 0; /* Resize the output buffer to ensure that we have enough - * space for all the Physical IO stats. - */ + * space for all the Physical IO stats. + */ status = VIRT_CheckResultSize( virtInfo, 16*8*1024 ); if ( status != zOK ) { @@ -1623,7 +1620,7 @@ STATUS ZLSS_PhysicalIOXMLGlobal( status = ZLSSUT_DisplayAll2(&genMsg, parmLen, parm, bufferLength, buffer, retLen, virtInfo ); #endif - + ZLSS_ErrNoAndErrNoSetterSet( virtInfo, &genMsg ); status = ZLSS_XML_Tail( virtInfo, &genMsg ); @@ -1649,8 +1646,8 @@ STATUS ZLSS_PhysicalIO2XML( NINT bufferLength, BYTE **bufferAddress, NINT *retLen, /* This idicates how much of buffer is - * already filled in. - */ + * already filled in. + */ VirtInfo_s *virtInfo ) { STATUS status; @@ -1703,8 +1700,8 @@ STATUS ZLSS_PhysicalIOXML( /* We always fill our data at the beginning of the buffer */ virtInfo->resultEOF = 0; /* Resize the output buffer to ensure that we have enough - * space for all the Physical IO stats. - */ + * space for all the Physical IO stats. + */ status = VIRT_CheckResultSize( virtInfo, 20*1024 ); if ( status != zOK ) { @@ -1753,17 +1750,17 @@ STATUS ZLSS_ZLogReadMetadataXML( DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (CYAN, "In ZLSS_ZLogReadMetadataXML\n")); /* We always fill our data at the beginning of the buffer. - * This is required as if a program does mulitple reads - * at offset 0 (ZLSS_ZLogReadMetadataXML) gets called - * mulitple times. If we do not reset resultEOF then - * we append our results to the previous read. This - * would cause us to increase the result buffer for - * each read. Many reads would eat many bytes! - */ + * This is required as if a program does mulitple reads + * at offset 0 (ZLSS_ZLogReadMetadataXML) gets called + * mulitple times. If we do not reset resultEOF then + * we append our results to the previous read. This + * would cause us to increase the result buffer for + * each read. Many reads would eat many bytes! + */ virtInfo->resultEOF = 0; /* Resize the output buffer to ensure that we have enough - * space for all the ZLOG data. - */ + * space for all the ZLOG data. + */ status = VIRT_CheckResultSize( virtInfo, 64*1024 ); if ( status != zOK ) { @@ -1861,7 +1858,7 @@ void ZLSS_DebugHexDumpNoASCII( virtInfo->resultEOF += strlen("\n"); column = 0; } - + switch ( size ) { case 4: @@ -1958,7 +1955,7 @@ void ZLSS_DebugHexDump( viewLine[column*3*size + DHD_COLUMN_HEX + 0] = '|'; viewLine[column*3*size + DHD_COLUMN_HEX + 1] = ' '; } - + switch ( size ) { case 4: @@ -2092,8 +2089,8 @@ STATUS ZLSS_ZLogReadMetadata2XML( NINT bufferLength, BYTE **bufferAddress, NINT *retLen, /* This idicates how much of buffer is - * already filled in. - */ + * already filled in. + */ VirtInfo_s *virtInfo) { STATUS status; @@ -2119,11 +2116,11 @@ STATUS ZLSS_ZLogReadMetadata2XML( SetErrno( genMsg, zERR_ZFSVOL_NOT_A_ZLSS_VOLUME ); return zFAILURE; } - S_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + S_LATCH( &zlogBeast->ZFSLOGbeastLatch ); status = ZLOG_GenerateXML( zlogBeast, bufferLength, bufferAddress, retLen ); - UNS_LATCH( &zlogBeast->ZFSLOGbeastLatch ); + UNS_LATCH( &zlogBeast->ZFSLOGbeastLatch ); COMN_PoolActiveUnlock( pool ); COMN_Release( &pool ); @@ -2222,18 +2219,18 @@ STATUS ZLSS_addPoolMgmtFile( { createAttr |= zFA_VOLATILE; } - ZOS_zCreate(status, rootKey, zNO_TASK, 0, - zNSPACE_LONG | zMODE_UTF8, pathStr, zFILE_REGULAR, + ZOS_zCreate(status, rootKey, zNO_TASK, 0, + zNSPACE_LONG | zMODE_UTF8, pathStr, zFILE_REGULAR, createAttr, zCREATE_OPEN_IF_THERE, zRR_WRITE_ACCESS, &retKey); if (status != zOK) - { + { zASSERT("Error during create" == NULL); continue; } if (!ZLSS_PoolInst[i].isDir) { - if (ZLSS_MGMT_MakeReadFunctionVirtualFile(genMsg, retKey, + if (ZLSS_MGMT_MakeReadFunctionVirtualFile(genMsg, retKey, ZLSS_PoolInst[i].readFunctionName, pathStr, NULL, NULL, ZLSS_PoolInst[i].useCookieRead) != zOK) { @@ -2251,7 +2248,7 @@ STATUS ZLSS_addPoolMgmtFile( zASSERT(status == zOK); free(pathStr); DEBUG_PRINTF(TVIRT, DBG_NOINDENT, (CYAN, "Exit ZLSS_addPoolMgmtFile(zOK)\n")); - return zOK; + return zOK; //errorClose: // ZOS_zClose(status, rootKey); @@ -2307,8 +2304,8 @@ void ZLSS_removePoolMgmtFile( unicode_t *poolName ) return; } /* Go through our list backwards so that files get - * deleted before the directory that they are in. - */ + * deleted before the directory that they are in. + */ for ( i = NELEMS( ZLSS_PoolInst ) - 1 ; i >= 0; i-- ) { sprintf(&pathStr[AVFileMgmtDirLen], ZLSS_PoolInst[i].path, (BYTE *)name); @@ -2340,9 +2337,9 @@ STATUS ZLOG_GenerateXML( NINT bufferLength, BYTE **bufferAddress, NINT *retLen ) /* This indicates how much of buffer is - * already filled in. We must update - * as we fill things in. - */ + * already filled in. We must update + * as we fill things in. + */ { STATUS status; ZlogBeastPersistent_s *zlogP; @@ -2352,7 +2349,7 @@ STATUS ZLOG_GenerateXML( zlogP = &zlogBeast->ZLB_P; for ( index = 0; index < (sizeof(zlogP->ZLBP_Reserved)/sizeof(QUAD)); - ++index ) + ++index ) { if ( zlogP->ZLBP_Reserved[0] != 0uL ) { @@ -2388,7 +2385,7 @@ STATUS ZLOG_GenerateXML( VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", (unsigned long)zlogP->ZLBP_OldHomePointerBlockNumber[3]); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - (unsigned long)zlogP->ZLBP_ActivePointerBlockNumber); + (unsigned long)zlogP->ZLBP_ActivePointerBlockNumber); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", (unsigned long)zlogP->ZLBP_HomePointerBlockNumber); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", @@ -2436,11 +2433,11 @@ STATUS ZLOG_GenerateXML( (unsigned long)zlogBeast->ZLB_CheckpointTakeWorkToDoScheduled); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - zlogBeast->ZLB_Barrier); + zlogBeast->ZLB_Barrier); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - (unsigned long)zlogBeast->ZLB_BarrierWorkToDoScheduled); + (unsigned long)zlogBeast->ZLB_BarrierWorkToDoScheduled); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - zlogBeast->ZLB_BarrierListHead.next); + zlogBeast->ZLB_BarrierListHead.next); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", (unsigned long)zlogBeast->ZLB_ActiveHasBeenRead); @@ -2483,31 +2480,31 @@ STATUS ZLOG_GenerateXML( VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", (unsigned long)zlogBeast->ZLB_FileFullWaiters); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - (unsigned long)zlogP->ZLBP_FileThrottleFull ); //blknum_t + (unsigned long)zlogP->ZLBP_FileThrottleFull ); //blknum_t VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - (unsigned long)zlogP->ZLBP_FileThrottleBack ); //blknum_t + (unsigned long)zlogP->ZLBP_FileThrottleBack ); //blknum_t VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", (unsigned int)zlogP->ZLBP_FileThrottleFullPercent ); //BYTE VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", (unsigned int)zlogP->ZLBP_FileThrottleBackPercent ); //BYTE VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - zlogP->ZLBP_FileThrottleWaitCount ); //QUAD + zlogP->ZLBP_FileThrottleWaitCount ); //QUAD VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - zlogP->ZLBP_FileThrottleWait1Count ); //QUAD + zlogP->ZLBP_FileThrottleWait1Count ); //QUAD VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - zlogP->ZLBP_FileThrottleWait2Count ); //QUAD + zlogP->ZLBP_FileThrottleWait2Count ); //QUAD VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - zlogP->ZLBP_FileThrottleWait3Count ); //QUAD + zlogP->ZLBP_FileThrottleWait3Count ); //QUAD VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - zlogP->ZLBP_FileThrottleWait4Count ); //QUAD + zlogP->ZLBP_FileThrottleWait4Count ); //QUAD VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - zlogP->ZLBP_FileThrottleWait5Count ); //QUAD + zlogP->ZLBP_FileThrottleWait5Count ); //QUAD VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - zlogP->ZLBP_FileThrottleFullCount ); //QUAD + zlogP->ZLBP_FileThrottleFullCount ); //QUAD VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - zlogP->ZLBP_FileThrottleSkipCount ); //QUAD + zlogP->ZLBP_FileThrottleSkipCount ); //QUAD VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", - zlogP->ZLBP_FileThrottleBackCount ); //QUAD + zlogP->ZLBP_FileThrottleBackCount ); //QUAD VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", zlogP->ZLBP_FileThrottleTimeStart, UTCTime2Str(zlogP->ZLBP_FileThrottleTimeStart, &timeBuffer[0]) ); @@ -2517,7 +2514,7 @@ STATUS ZLOG_GenerateXML( VFS_ssprintf(bufferLength, bufferAddress, retLen, "", (unsigned long)zlogP->ZLBP_Mode); if ( zlogP->ZLBP_Mode & ZLOG_THROTTLE_BACK ) - { + { VFS_ssprintf(bufferLength, bufferAddress, retLen, "THROTTLE_BACK"); } else @@ -2545,9 +2542,9 @@ STATUS ZLOG_DisplayHistograms( NINT bufferLength, BYTE **bufferAddress, NINT *retLen ) /* This indicates how much of buffer is - * already filled in. We must update - * as we fill things in. - */ + * already filled in. We must update + * as we fill things in. + */ { STATUS status; @@ -2699,7 +2696,7 @@ STATUS ZLOG_DisplayHistograms( //} #endif -STATUS sDisplayHistory( +STATUS sDisplayHistory( NINT bufferLength, BYTE **bufferAddress, NINT *retLen, @@ -2887,8 +2884,8 @@ STATUS ZLSS_VFCCreate( GeneralMsg_s *genMsg ) strcat(pathStr, ZLSS_VitrualFileCommands[i].ZVFC_Path); createAttr = ZLSS_VitrualFileCommands[i].ZVFC_CreateAttr | zFA_DELETE_INHIBIT | zFA_RENAME_INHIBIT | zFA_COPY_INHIBIT; - ZOS_zCreate(status, rootKey, zNO_TASK, 0, - zNSPACE_LONG | zMODE_UTF8, pathStr, zFILE_REGULAR, + ZOS_zCreate(status, rootKey, zNO_TASK, 0, + zNSPACE_LONG | zMODE_UTF8, pathStr, zFILE_REGULAR, createAttr, zCREATE_OPEN_IF_THERE, zRR_WRITE_ACCESS, &retKey); if (status != zOK) { @@ -2900,7 +2897,7 @@ STATUS ZLSS_VFCCreate( GeneralMsg_s *genMsg ) { if ( ZLSS_VitrualFileCommands[i].ZVFC_IsReadFunction ) { /* READ function */ - status = ZLSS_MGMT_MakeReadFunctionVirtualFile(genMsg, retKey, + status = ZLSS_MGMT_MakeReadFunctionVirtualFile(genMsg, retKey, ZLSS_VitrualFileCommands[i].ZVFC_CommandOrReadFunctionName, pathStr, NULL, NULL, ZLSS_VitrualFileCommands[i].ZVFC_ReadUseCookieRead); } @@ -2948,7 +2945,7 @@ STATUS ZLSS_VFCDelete( GeneralMsg_s *genMsg ) strcpy(pathStr, AdminVolAsciiName); strcat(pathStr, ":\\"); strcat(pathStr, ZLSS_VitrualFileCommands[i].ZVFC_Path); - ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, pathStr, + ZOS_zDelete(status, rootKey, 0, zNSPACE_LONG | zMODE_UTF8, pathStr, zMATCH_ALL, zDELETE_FORCE_DELETE); zASSERT(status == zOK); if ( status != zOK ) @@ -2966,7 +2963,7 @@ noRoot: /* * ZLSS_MSAPDisplayXML() - * This dumps a MSAP statistics into a buffer in XML format. - * + * */ STATUS ZLSS_MSAPDisplayXML( ZlssPool_s *zlssPool, @@ -2974,9 +2971,9 @@ STATUS ZLSS_MSAPDisplayXML( NINT bufferLength, BYTE **bufferAddress, NINT *retLen ) /* This indicates how much of buffer is - * already filled in. We must update - * as we fill things in. - */ + * already filled in. We must update + * as we fill things in. + */ { STATUS status; @@ -3049,7 +3046,7 @@ STATUS ZLSS_MSAPDisplayXML( VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", mSAP->MSAP_ServerIDListFlags[i] & MSAP_FLAGS_INIT ? "true" : "false" ); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n" ); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n" ); - } + } VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n" ); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n"); @@ -3071,7 +3068,7 @@ STATUS ZLSS_MSAPDisplayXML( VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", mSAP->MSAP_ProbeRequestIDListUTC[i], UTCTime2Str(mSAP->MSAP_ProbeRequestIDListUTC[i], &timeBuffer[0]) ); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n" ); - } + } VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n" ); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n"); @@ -3093,7 +3090,7 @@ STATUS ZLSS_MSAPDisplayXML( VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n", mSAP->MSAP_ProbeResponseIDListUTC[i], UTCTime2Str(mSAP->MSAP_ProbeResponseIDListUTC[i], &timeBuffer[0]) ); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n" ); - } + } VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n" ); VFS_ssprintf(bufferLength, bufferAddress, retLen, "\n"); @@ -3118,8 +3115,8 @@ STATUS ZLSS_MSAPItems2XML( NINT bufferLength, BYTE **bufferAddress, NINT *retLen, /* This idicates how much of buffer is - * already filled in. - */ + * already filled in. + */ VirtInfo_s *virtInfo ) { STATUS status; @@ -3188,8 +3185,8 @@ STATUS ZLSS_RAVItems2XML( NINT bufferLength, BYTE **bufferAddress, NINT *retLen, /* This idicates how much of buffer is - * already filled in. - */ + * already filled in. + */ VirtInfo_s *virtInfo ) { STATUS status; @@ -3197,8 +3194,8 @@ STATUS ZLSS_RAVItems2XML( ZlssPool_s *zlssPool; /* Resize the output buffer to ensure that we have enough - * space for all the block information data. - */ + * space for all the block information data. + */ pool = ZLSS_ZLogSetup( genMsg, parmLen, parm, FALSE ); if ( pool == NULL ) { @@ -3234,8 +3231,8 @@ STATUS ZLSS_RAVStatisticsItems2Bin( NINT *bufferLength, BYTE **bufferAddress, NINT *retLen, /* This idicates how much of buffer is - * already filled in. - */ + * already filled in. + */ VirtInfo_s *virtInfo ) { STATUS status; @@ -3295,8 +3292,8 @@ STATUS ZLSS_RAVStatus( return 0x6666; // FixFixFix(ZVP,2,2) - is the _ADMIN fixed???? } /* Resize the output buffer to ensure that we have enough - * space for all the stats. - */ + * space for all the stats. + */ if ( flags & RAV_DX_DETAIL_FILE ) { // FixFixFix(ZRPDone,4,.5) - lower this? - Yes, because UI will consume all items that make this file big status = VIRT_CheckResultSize( virtInfo, (NINT)RAVGSInitItems.ZRP_FILE_SIZE_DETAIL ); @@ -3616,8 +3613,8 @@ STATUS ZLSS_MSAPItemsXML( /* We always fill our data at the beginning of the buffer */ virtInfo->resultEOF = 0; /* Resize the output buffer to ensure that we have enough - * space for all the Physical IO stats. - */ + * space for all the Physical IO stats. + */ status = VIRT_CheckResultSize( virtInfo, 64*1024 ); if ( status != zOK ) { @@ -3655,20 +3652,20 @@ errorExit: * Three Sample Outputs * * - * Error creating pool - * managePool.c[5706] - * MM_ADAPTER_ERROR + * Error creating pool + * managePool.c[5706] + * MM_ADAPTER_ERROR * * * - * Fake Pool Error - * managePool.c[5707] - * zERR_NO_MEMORY - * managePool.c[5705] + * Fake Pool Error + * managePool.c[5707] + * zERR_NO_MEMORY + * managePool.c[5705] * * * - * Fake No Error + * Fake No Error * * */ @@ -3678,13 +3675,13 @@ void MNSS_BuildResult2( utf8_t *desc, char *reporter, /* Where MNSS_Build... was called from */ char *origin) /* Where 'result' was set. Can be NULL - * because MM and other callers may not - * track. For NSS, generally called - * with GetErrnoSetter(). - */ + * because MM and other callers may not + * track. For NSS, generally called + * with GetErrnoSetter(). + */ { utf8_t tempBuf[256]; - + ASSERT_MPKNSS_LOCK(); sprintf(tempBuf, MSGNot("<"TAG_RESULT" "ATR_VALUE @@ -3723,24 +3720,24 @@ void MNSS_BuildResult2( * * * - * Error creating pool - * managePool.c[5706] - * MM_ADAPTER_ERROR + * Error creating pool + * managePool.c[5706] + * MM_ADAPTER_ERROR * * * * * - * Fake Pool Error - * managePool.c[5707] - * zERR_NO_MEMORY - * managePool.c[5705] + * Fake Pool Error + * managePool.c[5707] + * zERR_NO_MEMORY + * managePool.c[5705] * * * * * - * Fake No Error + * Fake No Error * * */ @@ -3794,9 +3791,9 @@ STATUS MNSS_GetTagContents( { if (!(requestedTags[i].flags & TR_OPTIONAL)) { - sprintf(tempBuf, "%s%s", + sprintf(tempBuf, "%s%s", MSGNot("Missing required attribute: "), tagName); - MNSS_ReturnResult777(virtInfo, parentTag, zERR_XML_IS_BAD, + MNSS_ReturnResult777(virtInfo, parentTag, zERR_XML_IS_BAD, tempBuf, WHERE, NULL); status = zERR_XML_IS_BAD; break; @@ -3811,14 +3808,14 @@ STATUS MNSS_GetTagContents( } else { - if (XML_GetTagElement(tagName, element->dataStart, + if (XML_GetTagElement(tagName, element->dataStart, element->dataEnd, &parmElement) != zOK) { if (!(requestedTags[i].flags & TR_OPTIONAL)) { - sprintf(tempBuf, MSGNot("Missing required tag: %s"), + sprintf(tempBuf, MSGNot("Missing required tag: %s"), tagName); - MNSS_ReturnResult777(virtInfo, parentTag, zERR_XML_IS_BAD, + MNSS_ReturnResult777(virtInfo, parentTag, zERR_XML_IS_BAD, tempBuf, WHERE, NULL); status = zERR_XML_IS_BAD; break; @@ -3833,9 +3830,9 @@ STATUS MNSS_GetTagContents( { if (requestedTags[i].flags & TR_CONTENT_REQUIRED) { - sprintf(tempBuf, + sprintf(tempBuf, MSGNot("Missing required tag content: %s"), tagName); - MNSS_ReturnResult777(virtInfo, parentTag, zERR_XML_IS_BAD, + MNSS_ReturnResult777(virtInfo, parentTag, zERR_XML_IS_BAD, tempBuf, WHERE, NULL); status = zERR_XML_IS_BAD; break; diff --git a/src/nwnss/zlss/zlssManage.h b/src/nwnss/zlss/zlssManage.h index 7dbc550..d50206f 100644 --- a/src/nwnss/zlss/zlssManage.h +++ b/src/nwnss/zlss/zlssManage.h @@ -41,76 +41,76 @@ #include "zlssIOPerformance.h" /* Need VCF_BROWSE */ STATUS ZLSS_ErrNoAndErrNoSetterSet( - VirtInfo_s *virtInfo, - GeneralMsg_s *genMsg ); + VirtInfo_s *virtInfo, + GeneralMsg_s *genMsg ); void ZLSS_DebugHexDump( - void *userArea, - int length, - int size, - VirtInfo_s *virtInfo ); + void *userArea, + int length, + int size, + VirtInfo_s *virtInfo ); void ZLSS_DebugHexDumpNoASCII( - void *userArea, - int length, - int size, - VirtInfo_s *virtInfo ); + void *userArea, + int length, + int size, + VirtInfo_s *virtInfo ); STATUS ZLSS_VF_ReadBlock( - GeneralMsg_s *genMsg, - NINT parmLen, - utf8_t *parm, - NINT dataLen, - BYTE *data, - NINT offset, - VirtInfo_s *virtInfo ); + GeneralMsg_s *genMsg, + NINT parmLen, + utf8_t *parm, + NINT dataLen, + BYTE *data, + NINT offset, + VirtInfo_s *virtInfo ); STATUS ZLSS_VF_ReadTest( - GeneralMsg_s *genMsg, - NINT parmLen, - utf8_t *parm, - NINT dataLen, - BYTE *data, - NINT offset, - VirtInfo_s *virtInfo ); + GeneralMsg_s *genMsg, + NINT parmLen, + utf8_t *parm, + NINT dataLen, + BYTE *data, + NINT offset, + VirtInfo_s *virtInfo ); STATUS ZLSS_XML_Head( - VirtInfo_s *virtInfo, - GeneralMsg_s *genMsg ); + VirtInfo_s *virtInfo, + GeneralMsg_s *genMsg ); STATUS ZLSS_XML_Tail( - VirtInfo_s *virtInfo, - GeneralMsg_s *genMsg ); + VirtInfo_s *virtInfo, + GeneralMsg_s *genMsg ); STATUS sDisplayHistogram( - NINT bufferLength, - BYTE **bufferAddress, - NINT *retLen, - ZlogHistogram_s *hist ); + NINT bufferLength, + BYTE **bufferAddress, + NINT *retLen, + ZlogHistogram_s *hist ); STATUS ZLOG_DisplayHistograms( - ZlogBeast_s *zlogBeast, - NINT bufferLength, - BYTE **bufferAddress, - NINT *retLen ); + ZlogBeast_s *zlogBeast, + NINT bufferLength, + BYTE **bufferAddress, + NINT *retLen ); STATUS ZLSS_XML_HeadReadBlock( - unicode_t *poolName, - Blknum_t blockNumber, - VirtInfo_s *virtInfo ); + unicode_t *poolName, + Blknum_t blockNumber, + VirtInfo_s *virtInfo ); STATUS ZLSS_XML_TailReadBlock( - VirtInfo_s *virtInfo ); + VirtInfo_s *virtInfo ); #ifdef VCF_BROWSE STATUS ZLSS_VF_Browse( - GeneralMsg_s *genMsg, - NINT parmLen, - utf8_t *parm, - NINT dataLen, - BYTE *data, - NINT offset, - VirtInfo_s *virtInfo ); + GeneralMsg_s *genMsg, + NINT parmLen, + utf8_t *parm, + NINT dataLen, + BYTE *data, + NINT offset, + VirtInfo_s *virtInfo ); #endif STATUS ZLSS_RebuildFileDetails( NINT parmLen, utf8_t *parm, struct VirtInfo_s *virtInfo ); @@ -125,27 +125,27 @@ STATUS ZLSS_VerifyFileLog( NINT parmLen, utf8_t *parm, struct VirtInfo_s *virtIn STATUS ZLSS_VerifyFileDebug( NINT parmLen, utf8_t *parm, struct VirtInfo_s *virtInfo ); STATUS ZLSS_ZLogReadMetadata2( - GeneralMsg_s *genMsg, - NINT parmLen, - utf8_t *parm, - NINT bufferLength, - BYTE **bufferAddress, - NINT *retLen, - VirtInfo_s *virtInfo); + GeneralMsg_s *genMsg, + NINT parmLen, + utf8_t *parm, + NINT bufferLength, + BYTE **bufferAddress, + NINT *retLen, + VirtInfo_s *virtInfo); STATUS ZLSS_ZLogReadMetadata2XML( - GeneralMsg_s *genMsg, - NINT parmLen, - utf8_t *parm, - NINT bufferLength, - BYTE **bufferAddress, - NINT *retLen, - VirtInfo_s *virtInfo); + GeneralMsg_s *genMsg, + NINT parmLen, + utf8_t *parm, + NINT bufferLength, + BYTE **bufferAddress, + NINT *retLen, + VirtInfo_s *virtInfo); -STATUS sDisplayHistory( - NINT bufferLength, - BYTE **bufferAddress, - NINT *retLen, - ZlogHistory_s *hist ); +STATUS sDisplayHistory( + NINT bufferLength, + BYTE **bufferAddress, + NINT *retLen, + ZlogHistory_s *hist ); #endif /* _ZLSSMANAGE_H_ */ diff --git a/src/nwnss/zlss/zlssModules.mk b/src/nwnss/zlss/zlssModules.mk new file mode 100644 index 0000000..1220486 --- /dev/null +++ b/src/nwnss/zlss/zlssModules.mk @@ -0,0 +1,385 @@ +############################################################################## +# +# (C) Copyright 2003 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +############################################################################## + +########################################################################## +# This defines what MODULES are being built for this NLM +# +# $Author: bbhanuprakash $ +# $Date: 2008-03-04 15:24:09 +0530 (Tue, 04 Mar 2008) $ +# +# $RCSfile$ +# $Revision: 2291 $ +# +########################################################################## + +MODULE_VERSION=15 + +#------------------------------------------------------------------------- +# If the version number is not defined here, the general product version +# number will be used (defined in bldVersion.bld) +# +# major version 1 to 99 +# minor version 1 to 99 +# sub version 1 to 26 +#------------------------------------------------------------------------- +#MAJOR_VERSION= +#MINOR_VERSION= +#SUB_VERSION= + +#------------------------------------------------------------------------- +# Build OPTIONS +#------------------------------------------------------------------------- + +BUILD_WITH_KERNEL_FLAGS=1 + +#set to 0 if you are NOT using source code control +IS_USING_SOURCE_CONTROL=1 + +#Set to ONE if you want the linked files to be copied to the SDK\BIN directory. +COPY_TO_SDK_BIN=1 + + #set to ONE if you only want to copy the OPTIMIZED version to SDK\BIN. + COPY_OPTIMIZED_ONLY=0 + +#Set this to ONE if you are building a NETWARE version independent NLM +#(not NETWARE version specific) +NETWARE_VERSION_INDEPENDENT=1 + + #if ONE include the NETWARE .H files in the compiler search paths. + USE_NETWARE_INCLUDES=1 + + #if ONE include the NETWARE import file at LINK time + USE_NETWARE_IMPORTS=1 + +#If ONE IMPORT the LIBNSS APIs and include in the search path SDK\LIBRARY +#and SDK\PUBLIC +IMPORT_INDEPENDENT_LIBNSS=1 + +#If ONE include in the search path SDK\LIBRARY and SDK\PUBLIC +USE_LIBNSS_INCLUDES=1 + +#If ONE then LINK with the NSS library and include all of the NSS library +#directories in the compiler search paths. This includes the SDK/PUBLIC, +#SDK/INCLUDE, SDK/INTERNAL, LIBRARY/SRC directories. +LINK_WITH_NSSLIB=0 + +#if ONE then IMPORT the NSS library and COMN layer APIS and include the +#SDK/PUBLIC directory in the compiler search paths. +IMPORT_NSSLIB=1 + + #If ONE and (LINK_WITH_NSSLIB==1 or IMPORT_NSSLIB==1) then do the same + #operation to the NSSLIB area you are doing to the local area. + CHECK_NSSLIB=0 + + #If ONE and (CHECK_NSSLIB==1) then we will clean the NSSLIB area when we + #clean the local area. + CLEAN_NSSLIB=0 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INCLUDE directory in + #the compiler search paths + USE_NSS_SDK_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/COMNSA directory in + #the compiler search paths + USE_NSS_SDK_COMNSA_INCLUDES=1 + + #if ONE and (IMPORT_NSSLIB==1) then include the SDK/INTERNAL directory in + #the compiler search paths + USE_NSS_SDK_INTERNAL_INCLUDES=1 + +#if ONE then do NOT import the NSS COMMON layer APIs +DONT_IMPORT_COMMON_LAYER=0 + +#if ONE, compile and link with the NETWARE sdk environment. +USE_NETWARE_SDK=0 + +#if ONE, include DS headers. +USE_NDS_INCLUDES=1 + +#if ONE, do LANGUAGE ENABLING processing +DO_LANGUAGE_ENABLING=1 + +#Set to null (i.e. no value) to not add XDC data to the NLM. For most +#NetWare 5.0 NLMs, the value should be -u. +MOAB_XDC_TOOL_OPTION=-n + +#************************************************************************* +# List of source directories for NSS +#************************************************************************* +SOURCE_DIRECTORIES= + +#************************************************************************* +# Source Modules for NSS (.C .386) +#************************************************************************* +SOURCE_FILES=\ + zlssLKM.c \ + zlssStartup.c \ + zlssCmdline.c \ + zstoreConfig.c \ + zlssLSSOps.c \ + zlssLogicalVolume.c \ + zlssLVAIPU.c \ + zlssConsumer.c \ + zlssStorPool.c \ + zlssUpgrade.c \ + beastTree.c \ + purgeTree.c \ + btree.c \ + dfsIO.c \ + dir_ops.c \ + dlog.c \ + nameTree.c \ + node.c \ + overflow.c \ + qdiv.c \ + purgeLog.c \ + repairMain.c \ + repairBtree.c \ + repairFMtree.c \ + repairFtree.c \ + repairMap.c \ + repairMFL.c \ + repairNames.c \ + repairNtree.c \ + repairPtree.c \ + repairReZid.c \ + repairSRTree.c \ + repairUpgrade.c \ + repairRAV.c \ + repairRAVDebug.c \ + repairZRP.c \ + repairZVP.c \ + salvageLog.c \ + underflow.c \ + xaction.c \ + zfs.c \ + zfsFileMap.c \ + zfsPool.c \ + zfsSuperBlk.c \ + zfsVol.c \ + zfsVolumeData.c \ + zfsXTree.c \ + zio.c \ + zlog.c \ + zlogDebug.c \ + zlogUnitTest.c \ + zedExport.c \ + userTree.c \ + dirTree.c \ + myBTree.c \ + purgeTree_new.c \ + mfl_if.c \ + eflTree.c \ + eflLog.c \ + zlssManage.c \ + sbi.c \ + sbiNT.c \ + sdZLSS.c \ + zlssDev.c \ + zlssIOPerformance.c \ + zlssMSAP.c \ + zlssVersion.c \ + nssZLSSSym.c \ + z_aes_cbc.c \ + z_aes_core.c + + +SOURCE_FILES_NODEBUG= + +#************************************************************************* +# Source Include files for NSS (.H .inc) +#************************************************************************* +INCLUDE_FILES=\ + dfsIO.h \ + dir.h \ + dlog.h \ + mscIDE.h \ + nameTree.h \ + node.h \ + zlssConsumer.h \ + zlssLogicalVolume.h \ + zfsAsyncio.h \ + zfsdefs.h \ + beastTree.h \ + purgeTree.h \ + purgeTree_if.h \ + purgeTree_new.h \ + purgeLog.h \ + repairMain.h \ + repairBtree.h \ + repairMap.h \ + sdZLSS.h \ + xaction.h \ + zfs.h \ + zfsSuperBlk.h \ + zfsXTree.h \ + zfsFileMap.h \ + zlog.h \ + zlogFtest.h \ + zlssStartup.h \ + zlssUpgrade.h \ + zstoreConfig.h \ + zedExport.h \ + userTree.h \ + dirTree.h \ + myBTree.h \ + mfl_if.h \ + eflTree.h \ + eflLog.h \ + mflBTree.h \ + zlssManage.h \ + zlssIOPerformance.h \ + zlssMSAP.h \ + z_aes.h \ + z_aes_locl.h + + +#------------------------------------------------------------------------- +# Additional source files that need to be checked out +#------------------------------------------------------------------------- +OTHER_FILES=\ + Module.supported + +#------------------------------------------------------------------------- +# This defines what routines are being EXPORTED. You should put .IMP +# files in the "UTILITY_EXPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_EXPORTS= + +UTILITY_EXPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# This defines what routines are being IMPORTED. You should put .IMP +# files in the "UTILITY_IMPORTS_VIA_FILE" field because it will properly +# insert seperators based on what linker you are using and it will make +# the link dependent on these files. +#------------------------------------------------------------------------- +UTILITY_IMPORTS= + +UTILITY_IMPORTS_VIA_FILE= + +#------------------------------------------------------------------------- +# Library definitions +# This defines additional libraries to LINK with and additional +# directories to put on out INCLUDE path. +#------------------------------------------------------------------------- +#additional libraries to link with +EXTRA_LIBRARIES= +EXTRA_STATIC_LIBRARIES= +EXTRA_DYNAMIC_LIBRARIES= +EXTRA_LIBRARY_INCLPATH= + +#------------------------------------------------------------------------- +# Include path +# This defines additional include path to compile with +#------------------------------------------------------------------------- +#additional include path +EXTRA_INCLUDE_PATH= + + +#------------------------------------------------------------------------- +# Additional C and ASSEMBLY options to use +#------------------------------------------------------------------------- +EXTRA_C_OPTIONS= +EXTRA_ASM_OPTIONS= +EXTRA_LINK_OPTIONS= + +#------------------------------------------------------------------------- +# Additional module attributes +#------------------------------------------------------------------------- +MODULE_DESCRIPTION='NSS Journaled Storage System (ZLSS)' +MODULE_ADDITIONAL_COPYRIGHT=Patents 5,787,439; 5,903,720; 5,915,253 Other Patents Pending. +MODULE_OPTIONS=OPTION reentrant +MODULE_DEPENDENCIES= +MODULE_TYPE= +MODULE_NAME=nsszlss +MODULE_EXTENSION= +MODULE_START_ROUTINE= +MODULE_EXIT_ROUTINE= +#set to 1 if you want the optimized NLM to be packed +MODULE_PACK_NLM=1 + +#========================================================================= +#========================================================================= +# LOCAL BUILD RULES +#========================================================================= +#========================================================================= + +#------------------------------------------------------------------------- +# Default BUILD rule +#------------------------------------------------------------------------- +DEFAULT: DEFAULT_BUILD + +#------------------------------------------------------------------------- +# Additional rules +#------------------------------------------------------------------------- + +#BUILD_GREENRIVER_OPT: +# @echo "...This NLM does not have an OPTIMIZED GREENRIVER specific version" + +#BUILD_GREENRIVER_UNOPT: +# @echo "...This NLM does not have an UNOPTIMIZED GREENRIVER specific version" + +BUILD_MOAB_MP_UNOPT: \ + COMPILE_UNOPT_MP_MOAB \ + LINK_UNOPT_MP_MOAB + +BUILD_MOAB_MP_OPT: \ + COMPILE_OPT_MP_MOAB \ + LINK_OPT_MP_MOAB + +BUILD_MOAB_SP_UNOPT: + @echo "...This NLM does not have an UNOPTIMIZED SP specific version" + +BUILD_MOAB_SP_OPT: + @echo "...This NLM does not have an OPTIMIZED SP specific version" + + +#BUILD_MOAB_SP_UNOPT: \ +# COMPILE_UNOPT_SP_MOAB \ +# LINK_UNOPT_SP_MOAB +# +#BUILD_MOAB_SP_OPT: \ +# COMPILE_OPT_SP_MOAB \ +# LINK_OPT_SP_MOAB + +#------------------------------------------------------------------------- +# Language Enabling rules +#------------------------------------------------------------------------- +mdb: \ + DEFAULT_MDB + +umdb: \ + LOCAL_MDB + +mdbcreate: \ + DEFAULT_CREATE_MDB_FILE + +#------------------------------------------------------------------------- +# Other rules +#------------------------------------------------------------------------- +deps: DEFAULT_DEPS + +cscope: DEFAULT_CSCOPE + diff --git a/src/nwnss/zlss/zlssNLM.c b/src/nwnss/zlss/zlssNLM.c new file mode 100644 index 0000000..3fe551b --- /dev/null +++ b/src/nwnss/zlss/zlssNLM.c @@ -0,0 +1,195 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: taysom $ + | $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $ + | + | $RCSfile$ + | $Revision: 465 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Initialize ZSTORE + +-------------------------------------------------------------------------*/ +#include /* netware */ + +//#include /* SDK include */ +#include +//#include +//#include +//#include +//#include +//#include +#include +#include +#include +#include "nssOSAPIs.h" +#include "zlssStartup.h" +//#include "zstoreConfig.h" +//#include "zedExport.h" + + +/*------------------------------------------------------------------------- + * Global variables + *-------------------------------------------------------------------------*/ +char **NSSMessageTable; + +struct LoadDefinitionStructure *ZSTORE_ModuleHandle; +struct ScreenStruct *ZSTORE_DefaultScreen; + +static LONG ZSTORE_ModuleIsLoaded = 0; +# define LOADED_MAGIC 0x54494E4a + + +/*------------------------------------------------------------------------- + * Defines the CallBacks for NSS + *-------------------------------------------------------------------------*/ +NSSRegistrationCallBacks_s ZSTORE_CallBacks = +{ + ZSTORE_GlobalStartup, + NULL +}; + +/*------------------------------------------------------------------------- + * Defines the name of this MODULE. + *-------------------------------------------------------------------------*/ +STATIC char myNLMName[] = MODULE_NAME; +//#ifdef UNOPT +// MSGNot("u") MODULE_NAME; +//#else +// MODULE_NAME; +//#endif + +const char Module[] = MODULE_NAME; + + +/************************************************************************** + * Load function for the NLM initialization process + ***************************************************************************/ +LONG GenericStartRoutine( + struct LoadDefinitionStructure *handle, + struct ScreenStruct *errorScreen, + BYTE *cmdLine) +{ + STATUS status; + LONG numMessages; + LONG languageID; + BYTE *helpFile; + LONG result; + char zstore_CommandLine[128]; + +/*------------------------------------------------------------------------- + * Init global variables + *-------------------------------------------------------------------------*/ + Enable(); /* Because interrupts comes in masked*/ + MPKNSS_LOCK(); + ZSTORE_ModuleHandle = handle; + ZSTORE_DefaultScreen = errorScreen; + strmcpy(zstore_CommandLine,cmdLine,sizeof(zstore_CommandLine)); +/*------------------------------------------------------------------------- + * setup message file + *-------------------------------------------------------------------------*/ + ZOS_ReturnMessageInformation(result,(LONG)handle, &NSSMessageTable, + &numMessages, &languageID, &helpFile); + if ( result != zOK) + { + ERROR_LOADING_MSG_TABLES(errorScreen); + MPKNSS_UNLOCK(); + return zFAILURE; + } +/*------------------------------------------------------------------------- + * See if the module is already loaded, if so, return now. If not init + * the SYSTEM. + *-------------------------------------------------------------------------*/ + /*- ck if module is already loaded, yet return now -*/ + if(ZSTORE_ModuleIsLoaded == LOADED_MAGIC) + { + MPKNSS_UNLOCK(); + return zOK; + } + /* mark module loaded */ + ZSTORE_ModuleIsLoaded = LOADED_MAGIC; + + LB_ParseCmdline(ZSTORE_CommandLineSwitches, POPT_AT_STARTUP, + zstore_CommandLine, NULL); + { + // sksmith - this version and copyright string are for the MSG file + char *ver = MSG("VeRsIoN=2.70 Novell Storage Services (NSS) LSS",115); + char *copyR = MSG("CoPyRiGhT=(c) 1995-1998 Novell, Inc. All rights reserved.",931); + if (ver && copyR) + { + } + } +/*------------------------------------------------------------------------- + * Register with NSS and tell them we are HERE. + *-------------------------------------------------------------------------*/ + status = NSS_RegisterExternalNLM( + myNLMName, + (NINT)ZSTORE_ModuleHandle, + NSSMessageTable, + NSSMODULETYPE_LSS, + NSSREGFLAG_REQUIRED, + &ZSTORE_VersionInfo, + NSSAPI_VERSION, + NSS_SNAPDATE, + NSS_DEBUG_STATE, + NSS_MP_FLAG, + ZSTORE_CommandLineSwitches, + &ZSTORE_CallBacks); + + if (status != zOK) + { + MPKNSS_UNLOCK(); + return zFAILURE; + } + MPKNSS_UNLOCK(); + return zOK; +} + + +/************************************************************************** + * This routine is called to UNLOAD the nlm + ***************************************************************************/ +LONG GenericExitRoutine(void) +{ +// NINT row,col; + + Enable(); /* Because it comes in masked*/ + MPKNSS_LOCK(); + + if (ZSTORE_ModuleIsLoaded == LOADED_MAGIC) + { +// wGetPos(stdout,&row,&col); +// wSetPos(stdout,row,0); /* position to the front of the current line*/ + + ZSTORE_GlobalShutdown(); + NSS_UnRegisterExternalNLM(myNLMName); + +// aprintf(LGREEN,MSG("ZSTORE" " Terminated\n", 2)); + } + MPKNSS_UNLOCK(); + return zOK; +} diff --git a/src/nwnss/zlss/zlssStartup.c b/src/nwnss/zlss/zlssStartup.c new file mode 100644 index 0000000..3bc4a05 --- /dev/null +++ b/src/nwnss/zlss/zlssStartup.c @@ -0,0 +1,554 @@ +/**************************************************************************** + | + | (C) Copyright 1995-1997, 2004 Novell, Inc. + | All Rights Reserved. + | + | This program is free software; you can redistribute it and/or + | modify it under the terms of version 2 of the GNU General Public + | License as published by the Free Software Foundation. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, contact Novell, Inc. + | + | To contact Novell about this file by physical or electronic mail, + | you may find current contact information at www.novell.com + | + |*************************************************************************** + | + | NetWare Advance File Services (NSS) module + | + |--------------------------------------------------------------------------- + | + | $Author: vandana $ + | $Date: 2007-04-18 23:26:20 +0530 (Wed, 18 Apr 2007) $ + | + | $RCSfile$ + | $Revision: 1954 $ + | + |--------------------------------------------------------------------------- + | This module is used to: + | Initialize ZSTORE + +-------------------------------------------------------------------------*/ +#include /* netware */ +#include + +#include +#include + +#include +#include + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "zlssStartup.h" +#include "zstoreConfig.h" +#include "zedExport.h" +#include "dfsIO.h" +#include "comnPublics.h" +#include "register.h" +#include "sdZLSS.h" +#include "dbgView.h" + +#if zLINUX +void ZLSS_AdminFunctionsStartup(); +void ZLSS_AdminFunctionsShutdown(); +#endif + +STATUS ZLSSUT_MediaFormatTestAllSizes(); +#if MEDIA_FORMAT_DISPLAY_SIZES +void ZLSSUT_DisplayAll(); +#endif + +#include "node.h" +#include "dir.h" + + +/*------------------------------------------------------------------------- + * Global variables + *-------------------------------------------------------------------------*/ +static int ZSTORE_StartupCompleted = FALSE; /* used to know if initialization completed */ + + +CommandViewInfo_s CommandViewInfoZLSS; + +/************************************************************************** + * The will initialize the system + ***************************************************************************/ +STATUS ZSTORE_GlobalStartup(void) +{ + GeneralMsg_s genMsg; + STATUS status; + + ASSERT_MPKNSS_LOCK(); + Enable(); /* Because interrupts come in masked*/ + + status = ZLSSUT_MediaFormatTestAllSizes(); + if ( status != zOK ) + { + return status; + } + + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); + +/*--------------------------------------------------------------------------- + * Setup the system + *---------------------------------------------------------------------------*/ + ZstoreConfigStartup(); + + if ( ZLSS_BarrierStart( &genMsg ) != zOK ) + { + printk("<1> ZLSS_BarrierStart failed error = %d\n", GetErrno(&genMsg)); + goto BARRIER_Failed; + } + + ZLSS_BioProcessStart(); + + if (ZSTORE_RegisterLSSOperations(&genMsg) != zOK) + { + printk("<1> ZSTORE_RegisterLSSOperations failed error = %d\n", GetErrno(&genMsg)); + goto REGISTER_LSS_OPS_Failed; + } + + if (ZSTORE_Startup(&genMsg) != zOK) + { + printk("<1> ZSTORE_Startup failed error = %d\n", GetErrno(&genMsg)); + goto ZFS_Failed; + } + + if (CONSUMER_Startup() != zOK) + { + printk("<1> CONSUMER_Startup failed\n"); + goto CONSUMER_Failed; + } + + if (DIO_Startup() != zOK) + { + printk("<1> DIO_Startup failed\n"); + goto DIO_Failed; + } + + /* Register that we ASSEMBLY DEBUGGER structures + * that can be displayed. + */ + CommandViewInfoZLSS.CVI_OwnerName = "ZLSS"; + CommandViewInfoZLSS.CVI_Table = SDM_TableZLSS; + DBG_CV_Register( &CommandViewInfoZLSS ); + + + ZedStuffInit(); + +/*------------------------------------------------------------------------- + * + *-------------------------------------------------------------------------*/ + +#if zLINUX + ZLSS_AdminFunctionsStartup(); +#endif + + ZSTORE_StartupCompleted = TRUE; + + return zOK; + +/*========================================================================= + * Error handling + *=========================================================================*/ + +// DIO_Shutdown(); + +DIO_Failed: + CONSUMER_Shutdown(); + +CONSUMER_Failed: + ZSTORE_Shutdown(); + +ZFS_Failed: + ZSTORE_ClearLSSOperations(); + +REGISTER_LSS_OPS_Failed: + DataShredCleanup(); + ZLSS_BioProcessStop(); + ZLSS_BarrierStop(); + +BARRIER_Failed: + + return zFAILURE; +} + + +///************************************************************************** +// * Display Version Information +// ***************************************************************************/ +//STATUS ZSTORE_DisplayVersion(void) +//{ +// DisplayVersionInformation(MSGNot("ZLSS"),&ZSTORE_VersionInfo,NULL); +// return zOK; +//} + + +/************************************************************************** + * Uninitilaize the system + ***************************************************************************/ +void ZSTORE_GlobalShutdown(void) +{ + ASSERT_MPKNSS_LOCK(); + if (ZSTORE_StartupCompleted) + { +#if zLINUX + ZLSS_AdminFunctionsShutdown(); +#endif + ZSTORE_Shutdown(); + ZSTORE_ClearLSSOperations(); + CONSUMER_Shutdown(); + DIO_Shutdown(); + ZSTORE_StartupCompleted = FALSE; /* flag not inited */ + } + DataShredCleanup(); + ZLSS_BioProcessStop(); + ZLSS_BarrierStop(); +#if NSS_DEBUG IS_ENABLED + free(ReadBlkVolumeName); +#endif + (void)DBG_CV_Unregister( &CommandViewInfoZLSS ); + + +} + + +typedef struct ZLSSPersistentItems_s { + char *ZPI_Name; + int ZPI_Size; + char *ZPI_LastItemName; + int ZPI_LastItem; + int ZPI_SizePacked; + int ZPI_LastItemPacked; +} ZLSSPersistentItems_s; + + +ZLSSPersistentItems_s ZPIList[] = { + // 1) Looked for users of ZLOG_INIT_LOG_RECORD. + // 2) Looked for users of COMN_RegisterRootVariableDataType (RVD_MAC_META_DATA, + // RVD_UNIX_META_DATA, RVD_VIRTUAL_DATA, RVD_COMP_META_DATA , and RVD_UNCOMP_DATA ) + // 3) Look for LSS packing routines via LSSOpsToRegister_s + // a) Looked at ALL pack/unpack routines in zlssLSSOps.c + // b) Ignored all other LSS routines (FAT32, CD, etc). + // 4) Look for LSSSpecificPackUnpackOps_s (also BeastClassRegisterInfo_s). Skipped all LSSes except ZLSS! + // 5) Both Auth models (ZASAuthorizeModelOps, UnixAuthorizeModelOps) + // 6) Purge log - All items in PurgeLogInfo_s + // 7) Compression - Ying + // 8) TTS - Craig + // dirTree.h + { "DirBranchEntry_s", sizeof(DirBranchEntry_s), "child", offsetof(DirBranchEntry_s,child), 12, 8 }, + { "DirBranch_s", sizeof(DirBranch_s), "entry[DBT_MAX_BRANCH_ENTRIES]", offsetof(DirBranch_s,entry[DBT_MAX_BRANCH_ENTRIES]), 4056, 4056 }, + { "DirLeafEntry_s", sizeof(DirLeafEntry_s), "quota", offsetof(DirLeafEntry_s,quota), 24, 16 }, + { "DirLeaf_s", sizeof(DirLeaf_s), "entry[DBT_MAX_LEAF_ENTRIES]", offsetof(DirLeaf_s,entry[DBT_MAX_LEAF_ENTRIES]), 4060, 4060 }, + { "DirTreeNode_s", sizeof(DirTreeNode_s), "n.leaf", offsetof(DirTreeNode_s,n.leaf), 4092, 32 }, + { "DBTEntry_s", sizeof(DBTEntry_s), "internalID", offsetof(DBTEntry_s,internalID), 32, 16 }, + { "DBTModify_s", sizeof(DBTModify_s), "internalID", offsetof(DBTModify_s,internalID), 44, 28 }, + { "DBTSplit_s", sizeof(DBTSplit_s), "data", offsetof(DBTSplit_s,data), 45, 44 }, + { "DBTOverflow_s", sizeof(DBTOverflow_s), "data", offsetof(DBTOverflow_s,data), 9, 8 }, + { "DBTGrow_s", sizeof(DBTGrow_s), "blockForParent", offsetof(DBTGrow_s,blockForParent), 20, 16 }, + { "DBTBalance_s", sizeof(DBTBalance_s), "data", offsetof(DBTBalance_s,data), 27, 26 }, + { "DBTTreeInit_s", sizeof(DBTTreeInit_s), "internalID", offsetof(DBTTreeInit_s,internalID), 16, 0 }, + { "DirLog_s", sizeof(DirLog_s), "u.initTree", offsetof(DirLog_s,u.initTree), 45, 0 }, + { "NTShrinkLogRecord_s", sizeof(NTShrinkLogRecord_s), "valueOfPoke", offsetof(NTShrinkLogRecord_s,valueOfPoke), 8, 4 }, + // dlog.h + { "dlog_move_s", sizeof(dlog_move_s), "nrecs", offsetof(dlog_move_s,nrecs), 14, 12 }, + { "dlog_replkey_s", sizeof(dlog_replkey_s), "ovflow_data", offsetof(dlog_replkey_s,ovflow_data), 16, 14 }, + { "dlog_repl_s", sizeof(dlog_repl_s), "newlog", offsetof(dlog_repl_s,newlog), 12, 10 }, + { "dlog_expand_s", sizeof(dlog_expand_s), "log", offsetof(dlog_expand_s,log), 10, 8 }, + { "dlog_set_ovflow_s", sizeof(dlog_set_ovflow_s), "ovflow_blk", offsetof(dlog_set_ovflow_s,ovflow_blk), 8, 4 }, + { "dlog_chmask_s", sizeof(dlog_chmask_s), "newmask", offsetof(dlog_chmask_s,newmask), 16, 12 }, + { "dlog_chmatchAttr_s", sizeof(dlog_chmatchAttr_s), "newmatchAttr", offsetof(dlog_chmatchAttr_s,newmatchAttr), 16, 12 }, + { "dlog_chroot_s", sizeof(dlog_chroot_s), "newblki", offsetof(dlog_chroot_s,newblki), 6, 4 }, + { "dlog_ch_lchild_s", sizeof(dlog_ch_lchild_s), "newblk", offsetof(dlog_ch_lchild_s,newblk), 12, 8 }, + { "dlog_leaflist_s", sizeof(dlog_leaflist_s), "nextblk", offsetof(dlog_leaflist_s,nextblk), 12, 8 }, + { "dlog_op_s", sizeof(dlog_op_s), "op", offsetof(dlog_op_s,op), 16, 0 }, + { "struct blk_alloc_s", sizeof(struct blk_alloc_s), "is_ovflow", offsetof(struct blk_alloc_s, is_ovflow), 4, 2 }, + { "dlog_s", sizeof(dlog_s), "reserved", offsetof(dlog_s,reserved), 8, 6 }, + { "dlog_newhdr_s", sizeof(dlog_newhdr_s), "hdr", offsetof(dlog_newhdr_s,hdr), 24, 16 }, + // zfs.h + { "PoolReadStatistics_s", sizeof(PoolReadStatistics_s), "PRS_Reserved[5]", offsetof(PoolReadStatistics_s,PRS_Reserved[5]), 192, 192 }, + { "PoolWriteStatistics_s", sizeof(PoolWriteStatistics_s), "PWS_Reserved[5]", offsetof(PoolWriteStatistics_s,PWS_Reserved[5]), 192, 192 }, + { "ZfsPurgeLogLoc_s", sizeof(ZfsPurgeLogLoc_s), "slot", offsetof(ZfsPurgeLogLoc_s,slot), 8, 4 }, + { "Extent_s", sizeof(Extent_s), "poolBlkNum", offsetof(Extent_s,poolBlkNum), 8, 4 }, + { "FmapExt_s", sizeof(FmapExt_s), "poolBlk", offsetof(FmapExt_s,poolBlk), 8, 4 }, + { "Fmap_s", sizeof(Fmap_s), "dirExt[MAX_DIRECT]", offsetof(Fmap_s,dirExt[MAX_DIRECT]), 136, 136 }, + { "PersistentZfsVolume_s", sizeof(PersistentZfsVolume_s), "PZV_reserved[32-8-6-1-4-2-1]", offsetof(PersistentZfsVolume_s,PZV_reserved[32-8-6-1-4-2-1]), 128, 128 }, + { "LoggedPersistentZfsVolume_s", sizeof(LoggedPersistentZfsVolume_s), "LPZV_reserved[32-8]", offsetof(LoggedPersistentZfsVolume_s,LPZV_reserved[32-8]), 128, 128 }, + { "ZfsVolumeBlock_s", sizeof(ZfsVolumeBlock_s), "ZVD_volume", offsetof(ZfsVolumeBlock_s,ZVD_volume), 384, 128 }, + { "Zfs4KVolumeBlock_s", sizeof(Zfs4KVolumeBlock_s), "reserved[0x1000 - sizeof(ZfsVolumeBlock_s) - (0x100*sizeof(unicode_t)) - sizeof(PersistentVolumeCrypt_s)]", offsetof(Zfs4KVolumeBlock_s,reserved[0x1000 - sizeof(ZfsVolumeBlock_s) - (0x100*sizeof(unicode_t)) - sizeof(PersistentVolumeCrypt_s)]), 4096, 4096 }, + { "ZfsLoggedVolumeBlock_s", sizeof(ZfsLoggedVolumeBlock_s), "ZLVD_volume", offsetof(ZfsLoggedVolumeBlock_s,ZLVD_volume), 256, 128 }, + { "ZfsVDBUpdateLogRecord_s", sizeof(ZfsVDBUpdateLogRecord_s), "ZVULR_ValuesNew", offsetof(ZfsVDBUpdateLogRecord_s,ZVULR_ValuesNew), 768, 384 }, + { "ZfsVDBInitLogRecord_s", sizeof(ZfsVDBInitLogRecord_s), "ZVILR_ValuesNew", offsetof(ZfsVDBInitLogRecord_s,ZVILR_ValuesNew), 384, 0 }, + { "PersistentZfsPurgeLog_s", sizeof(PersistentZfsPurgeLog_s), "firstBlock", offsetof(PersistentZfsPurgeLog_s,firstBlock), 4, 0 }, + { "PersistentZfsBtree_s", sizeof(PersistentZfsBtree_s), "btLeftMostLeaf", offsetof(PersistentZfsBtree_s,btLeftMostLeaf), 12, 8 }, + { "PersistentZfsBeastTree_s", sizeof(PersistentZfsBeastTree_s), "deletevolumeDataBlk", offsetof(PersistentZfsBeastTree_s,deletevolumeDataBlk), 4, 0 }, + { "ZfsEFLEpoch_s", sizeof(ZfsEFLEpoch_s), "lastAlive", offsetof(ZfsEFLEpoch_s,lastAlive), 20, 16 }, + { "PersistentZfsEFLTree_s", sizeof(PersistentZfsEFLTree_s), "epochs[MAX_ZFS_EFL_EPOCHS]", offsetof(PersistentZfsEFLTree_s,epochs[MAX_ZFS_EFL_EPOCHS]), 672, 672 }, + { "ZnodeHeader_s", sizeof(ZnodeHeader_s), "zid", offsetof(ZnodeHeader_s,zid), 16, 8 }, + { "Znode_s", sizeof(Znode_s), "data[1]", offsetof(Znode_s,data[1]), 17, 17 }, + { "V1_ZFSPackedRoot_s", sizeof(V1_ZFSPackedRoot_s), "variableSize", offsetof(V1_ZFSPackedRoot_s,variableSize), 56, 54 }, + { "ZFSPackedRoot_s", sizeof(ZFSPackedRoot_s), "variableSize", offsetof(ZFSPackedRoot_s,variableSize), 72, 70 }, + { "PersistentZlssPool_s", sizeof(PersistentZlssPool_s), "PZP_reserved[64-16-4]", offsetof(PersistentZlssPool_s,PZP_reserved[64-16-4]), 256, 256 }, + { "LoggedPersistentZlssPool_s", sizeof(LoggedPersistentZlssPool_s), "LPZP_reserved[64-8]", offsetof(LoggedPersistentZlssPool_s,LPZP_reserved[64-8]), 256, 256 }, + { "ZlssLoggedPoolBlock_s", sizeof(ZlssLoggedPoolBlock_s), "ZLPB_pool", offsetof(ZlssLoggedPoolBlock_s,ZLPB_pool), 512, 256 }, + { "ZlssPoolBlock_s", sizeof(ZlssPoolBlock_s), "ZPB_pool", offsetof(ZlssPoolBlock_s,ZPB_pool), 512, 256 }, + { "BTShrinkLogRecord_s", sizeof(BTShrinkLogRecord_s), "slot", offsetof(BTShrinkLogRecord_s,slot), 6, 4 }, + // zfsXTree.h + { "xNodeHeader_s", sizeof(xNodeHeader_s), "pad2", offsetof(xNodeHeader_s,pad2), 40, 36 }, + { "xBranch_s", sizeof(xBranch_s), "child", offsetof(xBranch_s,child), 8, 4 }, + { "xNode_s", sizeof(xNode_s), "n.branch[FXBT_MAXBRANCHES]", offsetof(xNode_s,n.branch[FXBT_MAXBRANCHES]), 4096, 4096 }, + { "FXdelete_s", sizeof(FXdelete_s), "delExt", offsetof(FXdelete_s,delExt), 56, 48 }, + { "FXbalance_s", sizeof(FXbalance_s), "data[1]", offsetof(FXbalance_s,data[1]), 31, 31 }, + { "FXjoin_s", sizeof(FXjoin_s), "data[1]", offsetof(FXjoin_s,data[1]), 49, 49 }, + { "FXgrow_s", sizeof(FXgrow_s), "oribra", offsetof(FXgrow_s,oribra), 14, 6 }, + { "FXsplit_s", sizeof(FXsplit_s), "data[1]", offsetof(FXsplit_s,data[1]), 19, 19 }, + { "FXinsert_s", sizeof(FXinsert_s), "insExt", offsetof(FXinsert_s,insExt), 56, 48 }, + { "FXlog_s", sizeof(FXlog_s), "u.insert", offsetof(FXlog_s,u.insert), 56, 0 }, + // zlog.h + { "ZlogHistogramPersistent_s", sizeof(ZlogHistogramPersistent_s), "ZHP_EventCount", offsetof(ZlogHistogramPersistent_s,ZHP_EventCount), 16, 8 }, + { "ZlogHighWatermarkSlot_s", sizeof(ZlogHighWatermarkSlot_s), "ZHWB_Event", offsetof(ZlogHighWatermarkSlot_s,ZHWB_Event), 12, 4 }, + { "ZfsXasRecovery_s", sizeof(ZfsXasRecovery_s), "ZXR_PoolBlockCount", offsetof(ZfsXasRecovery_s,ZXR_PoolBlockCount), 24, 22 }, + { "ZLOGRecordHeader_s", sizeof(ZLOGRecordHeader_s), "ZLRH_Zxr", offsetof(ZLOGRecordHeader_s,ZLRH_Zxr), 40, 16 }, + { "ZlogBeastPersistent_s", sizeof(ZlogBeastPersistent_s), "ZLBP_StatisticsResetUTCTime", offsetof(ZlogBeastPersistent_s,ZLBP_StatisticsResetUTCTime), 3448, 3444 }, + { "ZlogHighWatermarkBucket_1Dot0_s", sizeof(ZlogHighWatermarkBucket_1Dot0_s), "ZHWB_1Dot0_Padding[1]", offsetof(ZlogHighWatermarkBucket_1Dot0_s,ZHWB_1Dot0_Padding[1]), 16, 16 }, + { "ZlogHighWatermark_1Dot0_s", sizeof(ZlogHighWatermark_1Dot0_s), "ZHW_1Dot0_Bucket[ZLOG_HWB_DEFAULT_1Dot0]", offsetof(ZlogHighWatermark_1Dot0_s,ZHW_1Dot0_Bucket[ZLOG_HWB_DEFAULT_1Dot0]), 160, 160 }, + { "ZlogHistogram_1Dot0_s", sizeof(ZlogHistogram_1Dot0_s), "ZH_1Dot0_Bucket", offsetof(ZlogHistogram_1Dot0_s,ZH_1Dot0_Bucket), 192, 188 }, + { "ZlogBeastPersistent_1Dot0_s", sizeof(ZlogBeastPersistent_1Dot0_s), "ZLBP_1Dot0_Pad2", offsetof(ZlogBeastPersistent_1Dot0_s,ZLBP_1Dot0_Pad2), 3320, 3316 }, + { "BlockInfo_s", sizeof(BlockInfo_s), "previousLsn", offsetof(BlockInfo_s,previousLsn), 16, 8 }, + { "ZLOGBlockHeader_s", sizeof(ZLOGBlockHeader_s), "ZLBH_FileBlockNumber", offsetof(ZLOGBlockHeader_s,ZLBH_FileBlockNumber), 48, 44 }, /* Added for OES SP1 */ + // zlssMSAP.h + { "MSAP_Block_s", sizeof(MSAP_Block_s), "MSAP_Junk[2048]", offsetof(MSAP_Block_s,MSAP_Junk[2048]), 4096, 4096 }, /* Added for OES SP1 */ + // xaction.h + { "LocalXid_t", sizeof(LocalXid_t), "restartCount", offsetof(LocalXid_t,restartCount), 8, 4 }, /* Added for OES SP1 */ + // sdZLSS.c + { "PersistentAuthBeast_1Dot0_s", sizeof(PersistentAuthBeast_1Dot0_s), "ownerID", offsetof(PersistentAuthBeast_1Dot0_s,ownerID), 4, 0 }, /* Added for OES SP1 */ + // node.h + { "Branch_s", sizeof(Branch_s), "k", offsetof(Branch_s,k), 30, 8 }, /* Added for OES SP1 */ +// { "Ldata_s", sizeof(Ldata_s), "matchAttributes", offsetof(Ldata_s,matchAttributes), 0, 0 }, /* Added for OES SP1 */ + { "Leaf_s", sizeof(Leaf_s), "k", offsetof(Leaf_s,k), 46, 24 }, /* Added for OES SP1 */ + { "Dupinfo_s", sizeof(Dupinfo_s), "nduplicates", offsetof(Dupinfo_s,nduplicates), 8, 0 }, /* Added for OES SP1 */ + { "Node_s", sizeof(Node_s), "padbytes[1]", offsetof(Node_s,padbytes[1]), 49, 49 }, /* Added for OES SP1 */ + { "Ovflow_op_data_t", sizeof(Ovflow_op_data_t), "replace", offsetof(Ovflow_op_data_t,replace), 8, 4 }, /* Added for OES SP1 */ + // dir.h + { "dir_key_s", sizeof(dir_key_s), "name[1]", offsetof(dir_key_s,name[1]), 22, 22 }, /* Added for OES SP1 */ + // beastTree.h + { "BTBranch_s", sizeof(BTBranch_s), "child", offsetof(BTBranch_s,child), 12, 8 }, + { "BTLeaf_s", sizeof(BTLeaf_s), "space.znodePtr[MAX_LEAF_FREE/sizeof(NodeLen_t)]", offsetof(BTLeaf_s,space.znodePtr[MAX_LEAF_FREE/sizeof(NodeLen_t)]), 4064, 4064 }, + { "BeastTreeNode_s", sizeof(BeastTreeNode_s), "n.branch[MAX_BRANCHES]", offsetof(BeastTreeNode_s,n.branch[MAX_BRANCHES]), 4096, 4088 }, + { "Split_s", sizeof(Split_s), "data[1]", offsetof(Split_s,data[1]), 45, 45 }, + { "Overflow_s", sizeof(Overflow_s), "data[1]", offsetof(Overflow_s,data[1]), 9, 9 }, + { "Grow_s", sizeof(Grow_s), "blockForParent", offsetof(Grow_s,blockForParent), 20, 16 }, + { "Balance_s", sizeof(Balance_s), "data[1]", offsetof(Balance_s,data[1]), 27, 27 }, + { "BeastTreeInit_s", sizeof(BeastTreeInit_s), "bti_internalID", offsetof(BeastTreeInit_s,bti_internalID), 16, 0 }, + { "BeastLog_s", sizeof(BeastLog_s), "u.bl_init", offsetof(BeastLog_s,u.bl_init), 45, 0 }, + // eflLog.h + { "ELogLink_s", sizeof(ELogLink_s), "offset", offsetof(ELogLink_s,offset), 12, 8 }, + { "ELogEntry_s", sizeof(ELogEntry_s), "names[1]", offsetof(ELogEntry_s,names[1]), 38, 38 }, + { "ELogHeader_s", sizeof(ELogHeader_s), "resBlk", offsetof(ELogHeader_s,resBlk), 8, 4 }, + { "ELogLog_s", sizeof(ELogLog_s), "data[1]", offsetof(ELogLog_s,data[1]), 9, 9 }, + { "ELogNode_s", sizeof(ELogNode_s), "u.log", offsetof(ELogNode_s,u.log), 49, 40 }, + { "ELogAddNode_s", sizeof(ELogAddNode_s), "oldLastLink", offsetof(ELogAddNode_s,oldLastLink), 28, 24 }, + { "ELogAddEntry_s", sizeof(ELogAddEntry_s), "numGoodLogEntries", offsetof(ELogAddEntry_s,numGoodLogEntries), 82, 78 }, + { "ELogAddEntryName_s", sizeof(ELogAddEntryName_s), "name[1]", offsetof(ELogAddEntryName_s,name[1]), 10, 10 }, + { "ELogRemoveNode_s", sizeof(ELogRemoveNode_s), "nextBlock", offsetof(ELogRemoveNode_s,nextBlock), 8, 4 }, + { "ELogModifyEpochs_s", sizeof(ELogModifyEpochs_s), "firstEntryAdjustment", offsetof(ELogModifyEpochs_s,firstEntryAdjustment), 12, 8 }, + { "EFLRecoveryLog_s", sizeof(EFLRecoveryLog_s), "u.modifyEpochs", offsetof(EFLRecoveryLog_s,u.modifyEpochs), 82, 0 }, + // eflTree.h + { "EFLBranchEntry_s", sizeof(EFLBranchEntry_s), "resBlk", offsetof(EFLBranchEntry_s,resBlk), 16, 12 }, + { "EFLBranch_s", sizeof(EFLBranch_s), "entry[EFL_MAX_BRANCH_ENTRIES]", offsetof(EFLBranch_s,entry[EFL_MAX_BRANCH_ENTRIES]), 4064, 4064 }, + { "EFLLeafEntry_s", sizeof(EFLLeafEntry_s), "extra[4]", offsetof(EFLLeafEntry_s,extra[4]), 72, 72 }, + { "EFLLeaf_s", sizeof(EFLLeaf_s), "entry[EFL_MAX_LEAF_ENTRIES]", offsetof(EFLLeaf_s,entry[EFL_MAX_LEAF_ENTRIES]), 4040, 4040 }, + { "EFLTreeNode_s", sizeof(EFLTreeNode_s), "n.leaf", offsetof(EFLTreeNode_s,n.leaf), 4096, 32 }, + { "EFLSplit_s", sizeof(EFLSplit_s), "data[1]", offsetof(EFLSplit_s,data[1]), 45, 45 }, + { "EFLGrow_s", sizeof(EFLGrow_s), "blockForParent", offsetof(EFLGrow_s,blockForParent), 20, 16 }, + { "EFLBalance_s", sizeof(EFLBalance_s), "data[1]", offsetof(EFLBalance_s,data[1]), 27, 27 }, + { "EFLTreeInit_s", sizeof(EFLTreeInit_s), "internalID", offsetof(EFLTreeInit_s,internalID), 16, 0 }, + { "EFLModify_s", sizeof(EFLModify_s), "newEntry", offsetof(EFLModify_s,newEntry), 160, 88 }, + { "EFLInsert_s", sizeof(EFLInsert_s), "newEntry", offsetof(EFLInsert_s,newEntry), 88, 16 }, + { "EFLDelete_s", sizeof(EFLDelete_s), "entry", offsetof(EFLDelete_s,entry), 88, 16 }, + { "EFLRemoveLog_s", sizeof(EFLRemoveLog_s), "internalID", offsetof(EFLRemoveLog_s,internalID), 16, 0 }, + { "EFLLog_s", sizeof(EFLLog_s), "u.removeLog", offsetof(EFLLog_s,u.removeLog), 160, 0 }, + // myBTree.h + { "MYBTBranchEntry_s", sizeof(MYBTBranchEntry_s), "key[1]", offsetof(MYBTBranchEntry_s,key[1]), 9, 9 }, + { "struct NSSFakeNameRJ4", sizeof(struct NSSFakeNameRJ4), "v_entry", offsetof(struct NSSFakeNameRJ4,v_entry), 4, 0 }, + { "struct NSSFakeNameHU8", sizeof(struct NSSFakeNameHU8), "vv_entry", offsetof(struct NSSFakeNameHU8,vv_entry), 12, 8 }, + { "MYBTreeNode_s", sizeof(MYBTreeNode_s), "n.leaf.vv_entry", offsetof(MYBTreeNode_s,n.leaf.vv_entry), 44, 40 }, + { "MYBTEntry_s", sizeof(MYBTEntry_s), "data[1]", offsetof(MYBTEntry_s,data[1]), 1, 1 }, + { "MYBTSplit_s", sizeof(MYBTSplit_s), "data[1]", offsetof(MYBTSplit_s,data[1]), 41, 41 }, + { "MYBTGrow_s", sizeof(MYBTGrow_s), "blockForParent", offsetof(MYBTGrow_s,blockForParent), 20, 16 }, + { "MYBTBalance_s", sizeof(MYBTBalance_s), "data[1]", offsetof(MYBTBalance_s,data[1]), 17, 17 }, + { "MYBTTreeInit_s", sizeof(MYBTTreeInit_s), "internalID", offsetof(MYBTTreeInit_s,internalID), 16, 0 }, + { "MybtInternalLog_s", sizeof(MybtInternalLog_s), "u.balance.data[1]", offsetof(MybtInternalLog_s,u.balance.data[1]), 41, 17 }, + { "MybtLogicalLog_s", sizeof(MybtLogicalLog_s), "u.entry[1]", offsetof(MybtLogicalLog_s,u.entry[1]), 25, 25 }, + // purgeTree.h: + { "PurgeKey_s", sizeof(PurgeKey_s), "reserved", offsetof(PurgeKey_s,reserved), 30, 28 }, + { "PurgeInfo_s", sizeof(PurgeInfo_s), "length", offsetof(PurgeInfo_s,length), 40, 38 }, + { "PbtBranch_s", sizeof(PbtBranch_s), "reserved2", offsetof(PbtBranch_s,reserved2), 40, 36 }, + { "PbtLeaf_s", sizeof(PbtLeaf_s), "space.pinfoPtr[1]", offsetof(PbtLeaf_s,space.pinfoPtr[1]), 10, 10 }, + { "PurgeTreeNode_s", sizeof(PurgeTreeNode_s), "n.branch[1]", offsetof(PurgeTreeNode_s,n.branch[1]), 72, 72 }, + { "PbtSplit_s", sizeof(PbtSplit_s), "data[1]", offsetof(PbtSplit_s,data[1]), 51, 51 }, + { "PbtOverflow_s", sizeof(PbtOverflow_s), "data[1]", offsetof(PbtOverflow_s,data[1]), 9, 9 }, + { "PbtGrow_s", sizeof(PbtGrow_s), "blockForParent", offsetof(PbtGrow_s,blockForParent), 4, 0 }, + { "PbtBalance_s", sizeof(PbtBalance_s), "data[1]", offsetof(PbtBalance_s,data[1]), 71, 71 }, + { "PbtLog_s", sizeof(PbtLog_s), "u.balance.data[1]", offsetof(PbtLog_s,u.balance.data[1]), 71, 71 }, + // purgeTree_new.h: + { "PurgeQNewKey_s", sizeof(PurgeQNewKey_s), "reserved", offsetof(PurgeQNewKey_s,reserved), 32, 28 }, + { "PurgeQNewValue_s", sizeof(PurgeQNewValue_s), "pzid", offsetof(PurgeQNewValue_s,pzid), 8, 0 }, + { "PurgeNewInfo_s", sizeof(PurgeNewInfo_s), "key.reserved", offsetof(PurgeNewInfo_s,key.reserved), 40, 28 }, + // purgeLog.h + { "FreeEntry_s", sizeof(FreeEntry_s), "link", offsetof(FreeEntry_s,link), 8, 0 }, + { "PurgeBlockEntry_s", sizeof(PurgeBlockEntry_s), "blockNumber", offsetof(PurgeBlockEntry_s,blockNumber), 4, 0 }, + { "PurgeBeastEntry_s", sizeof(PurgeBeastEntry_s), "dirZid", offsetof(PurgeBeastEntry_s,dirZid), 32, 24 }, + { "TruncateEntry_s", sizeof(TruncateEntry_s), "len", offsetof(TruncateEntry_s,len), 32, 28 }, + { "FixVisEntry_s", sizeof(FixVisEntry_s), "action", offsetof(FixVisEntry_s,action), 28, 24 }, + { "UserEntry_s", sizeof(UserEntry_s), "volumeID", offsetof(UserEntry_s,volumeID), 16, 0 }, + { "UserScanEntry_s", sizeof(UserScanEntry_s), "volumeID", offsetof(UserScanEntry_s,volumeID), 16, 0 }, + { "UserClearEntry_s", sizeof(UserClearEntry_s), "volumeID", offsetof(UserClearEntry_s,volumeID), 16, 0 }, + { "DirEntry_s", sizeof(DirEntry_s), "volumeID", offsetof(DirEntry_s,volumeID), 16, 0 }, + { "DirUsed_s", sizeof(DirUsed_s), "dirZid", offsetof(DirUsed_s,dirZid), 24, 16 }, + { "EFLEpochRemove_s", sizeof(EFLEpochRemove_s), "epoch", offsetof(EFLEpochRemove_s,epoch), 32, 16 }, + { "EFLTreeReset_s", sizeof(EFLTreeReset_s), "volumeID", offsetof(EFLTreeReset_s,volumeID), 16, 0 }, + { "PurgeLogEntry_s", sizeof(PurgeLogEntry_s), "info.trunc.len", offsetof(PurgeLogEntry_s,info.trunc.len), 40, 36 }, + { "PurgeLogBlock_s", sizeof(PurgeLogBlock_s), "logEntry[MAX_PURGE_LOG_ENTRIES]", offsetof(PurgeLogBlock_s,logEntry[MAX_PURGE_LOG_ENTRIES]), 4072, 4072 }, + { "LogPurgeLog_s", sizeof(LogPurgeLog_s), "entry.info.trunc.len", offsetof(LogPurgeLog_s,entry.info.trunc.len), 44, 40 }, + { "LogPurgeLogGrow_s", sizeof(LogPurgeLogGrow_s), "lplg_internalID", offsetof(LogPurgeLogGrow_s,lplg_internalID), 16, 0 }, + // userTree.h + { "OldUserBranchEntry_s", sizeof(OldUserBranchEntry_s), "child", offsetof(OldUserBranchEntry_s,child), 8, 4 }, + { "OldUserBranch_s", sizeof(OldUserBranch_s), "entry[OLD_UBT_MAX_BRANCH_ENTRIES]", offsetof(OldUserBranch_s,entry[OLD_UBT_MAX_BRANCH_ENTRIES]), 4064, 4064 }, + { "OldUserLeafEntry_s", sizeof(OldUserLeafEntry_s), "restrictionAmount", offsetof(OldUserLeafEntry_s,restrictionAmount), 20, 12 }, + { "OldUserLeaf_s", sizeof(OldUserLeaf_s), "entry[OLD_UBT_MAX_LEAF_ENTRIES]", offsetof(OldUserLeaf_s,entry[OLD_UBT_MAX_LEAF_ENTRIES]), 4064, 4064 }, + { "OldUserTreeNode_s", sizeof(OldUserTreeNode_s), "n.leaf.entry[OLD_UBT_MAX_LEAF_ENTRIES]", offsetof(OldUserTreeNode_s,n.leaf.entry[OLD_UBT_MAX_LEAF_ENTRIES]), 4096, 4096 }, + { "UserBranchEntry_s", sizeof(UserBranchEntry_s), "child", offsetof(UserBranchEntry_s,child), 20, 16 }, + { "UserBranch_s", sizeof(UserBranch_s), "entry[UBT_MAX_BRANCH_ENTRIES]", offsetof(UserBranch_s,entry[UBT_MAX_BRANCH_ENTRIES]), 4060, 4060 }, + { "UserLeafEntry_s", sizeof(UserLeafEntry_s), "reserved", offsetof(UserLeafEntry_s,reserved), 40, 38 }, + { "UserLeaf_s", sizeof(UserLeaf_s), "entry[UBT_MAX_LEAF_ENTRIES]", offsetof(UserLeaf_s,entry[UBT_MAX_LEAF_ENTRIES]), 4044, 4044 }, + { "UserTreeNode_s", sizeof(UserTreeNode_s), "n.leaf.entry[UBT_MAX_LEAF_ENTRIES]", offsetof(UserTreeNode_s,n.leaf.entry[UBT_MAX_LEAF_ENTRIES]), 4092, 4076 }, + { "ObjectNameEntry_s", sizeof(ObjectNameEntry_s), "reserved[152]", offsetof(ObjectNameEntry_s,reserved[152]), 676, 676 }, + { "ObjectNameNode_s", sizeof(ObjectNameNode_s), "entry[UBT_MAX_NAME_ENTRIES]", offsetof(ObjectNameNode_s,entry[UBT_MAX_NAME_ENTRIES]), 3444, 3444 }, + { "UBTEntry_s", sizeof(UBTEntry_s), "internalID", offsetof(UBTEntry_s,internalID), 48, 32 }, + { "UBTModify_s", sizeof(UBTModify_s), "internalID", offsetof(UBTModify_s,internalID), 52, 36 }, + { "UBTSplit_s", sizeof(UBTSplit_s), "data[1]", offsetof(UBTSplit_s,data[1]), 53, 53 }, + { "UBTOverflow_s", sizeof(UBTOverflow_s), "data[1]", offsetof(UBTOverflow_s,data[1]), 9, 9 }, + { "UBTGrow_s", sizeof(UBTGrow_s), "blockForParent", offsetof(UBTGrow_s,blockForParent), 20, 16 }, + { "UBTBalance_s", sizeof(UBTBalance_s), "data[1]", offsetof(UBTBalance_s,data[1]), 43, 43 }, + { "UBTTreeInit_s", sizeof(UBTTreeInit_s), "internalID", offsetof(UBTTreeInit_s,internalID), 16, 0 }, + { "UBTModifyName_s", sizeof(UBTModifyName_s), "internalID", offsetof(UBTModifyName_s,internalID), 1060, 1044 }, + { "UBTModifyNameEntry_s", sizeof(UBTModifyNameEntry_s), "internalID", offsetof(UBTModifyNameEntry_s,internalID), 1388, 1372 }, + { "UBTAddNameRecord_s", sizeof(UBTAddNameRecord_s), "internalID", offsetof(UBTAddNameRecord_s,internalID), 16, 0 }, + { "UBTAddName_s", sizeof(UBTAddName_s), "internalID", offsetof(UBTAddName_s,internalID), 556, 540 }, + { "UBTRemoveNameRecord_s", sizeof(UBTRemoveNameRecord_s), "nameIndex", offsetof(UBTRemoveNameRecord_s,nameIndex), 4, 0 }, + { "UBTRemove_s", sizeof(UBTRemove_s), "name[MAX_DN_CHARS]", offsetof(UBTRemove_s,name[MAX_DN_CHARS]), 564, 564 }, + { "UBTRemoveName_s", sizeof(UBTRemoveName_s), "name[MAX_DN_CHARS]", offsetof(UBTRemoveName_s,name[MAX_DN_CHARS]), 548, 548 }, + { "UserLog_s", sizeof(UserLog_s), "u.remove.name[MAX_DN_CHARS]", offsetof(UserLog_s,u.remove.name[MAX_DN_CHARS]), 1388, 564 }, + // zfsFileMap.h: + { "FmapNodeHead_s", sizeof(FmapNodeHead_s), "leafLink", offsetof(FmapNodeHead_s,leafLink), 44, 40 }, + { "FmapNode_s", sizeof(FmapNode_s), "extent[FMAP_MAX]", offsetof(FmapNode_s,extent[FMAP_MAX]), 4092, 4092 }, + { "FmapRoot_s", sizeof(FmapRoot_s), "extent[2]", offsetof(FmapRoot_s,extent[2]), 42, 42 }, + { "FmapInsert_s", sizeof(FmapInsert_s), "extent.poolBlk", offsetof(FmapInsert_s,extent.poolBlk), 14, 10 }, + { "FmapInsertSparse_s", sizeof(FmapInsertSparse_s), "index", offsetof(FmapInsertSparse_s,index), 56, 52 }, + { "FmapGrow_s", sizeof(FmapGrow_s), "extent[2].count", offsetof(FmapGrow_s,extent[2].count), 40, 40 }, + { "FmapSplit_s", sizeof(FmapSplit_s), "data[1]", offsetof(FmapSplit_s,data[1]), 61, 61 }, + { "FmapRemove_s", sizeof(FmapRemove_s), "numRecs", offsetof(FmapRemove_s,numRecs), 18, 16 }, + { "FmapJoin_s", sizeof(FmapJoin_s), "childNumRecs", offsetof(FmapJoin_s,childNumRecs), 56, 54 }, + { "FmapToss_s", sizeof(FmapToss_s), "numRecs", offsetof(FmapToss_s,numRecs), 48, 46 }, + { "FmapLog_s", sizeof(FmapLog_s), "u.join.childNumRecs", offsetof(FmapLog_s,u.join.childNumRecs), 61, 54 }, + // zfsSuperBlk.h: + { "Checkpoint_s", sizeof(Checkpoint_s), "CP_PackedData[8]", offsetof(Checkpoint_s,CP_PackedData[8]), 128, 128 }, + { "MediaCheckpoint_s", sizeof(MediaCheckpoint_s), "reserved[SUPERBLOCK_SECTION_SIZE - sizeof(Checkpoint_s)]", offsetof(MediaCheckpoint_s,reserved[SUPERBLOCK_SECTION_SIZE - sizeof(Checkpoint_s)]), 4096, 4096 }, + { "SuperBlockHeader_s", sizeof(SuperBlockHeader_s), "reserved2[64-(2+46)]", offsetof(SuperBlockHeader_s,reserved2[64-(2+46)]), 636, 636 }, + { "MediaSuperBlockHeader_s", sizeof(MediaSuperBlockHeader_s), "reserved[SUPERBLOCK_SECTION_SIZE-sizeof(SuperBlockHeader_s)]", offsetof(MediaSuperBlockHeader_s,reserved[SUPERBLOCK_SECTION_SIZE-sizeof(SuperBlockHeader_s)]), 4096, 4096 }, + { "SuperBlockDebug_s", sizeof(SuperBlockDebug_s), "reserved2[4096-32-8]", offsetof(SuperBlockDebug_s,reserved2[4096-32-8]), 4096, 4096 }, + { "SuperBlockDebugXaction_s", sizeof(SuperBlockDebugXaction_s), "reserved2[4096-32]", offsetof(SuperBlockDebugXaction_s,reserved2[4096-32]), 4096, 4096 }, + { "MediaReservedHeader_s", sizeof(MediaReservedHeader_s), "reserved[SUPERBLOCK_SECTION_SIZE/4]", offsetof(MediaReservedHeader_s,reserved[SUPERBLOCK_SECTION_SIZE/4]), 4096, 4096 }, + { "ZFSMediaSuperBlk_s", sizeof(ZFSMediaSuperBlk_s), "SB_HeaderCopy.reserved[SUPERBLOCK_SECTION_SIZE-sizeof(SuperBlockHeader_s)]", offsetof(ZFSMediaSuperBlk_s,SB_HeaderCopy.reserved[SUPERBLOCK_SECTION_SIZE-sizeof(SuperBlockHeader_s)]), 65536, 65536 }, + { "SbhLogRecord_s", sizeof(SbhLogRecord_s), "SLR_ValuesNew[3*512]", offsetof(SbhLogRecord_s,SLR_ValuesNew[3*512]), 3072, 3072 }, + // zlssLogicalVolume.h + { "PersistentZlssVolumeLocator_s", sizeof(PersistentZlssVolumeLocator_s), "PZVL_reserved[200-1-1-4-32-32-1]", offsetof(PersistentZlssVolumeLocator_s,PZVL_reserved[200-1-1-4-32-32-1]), 1540, 1540 }, + { "PersistentZlssVolumeLocator_2Dot0_s", sizeof(PersistentZlssVolumeLocator_2Dot0_s), "PZVL_2Dot0_lastZidTruncated", offsetof(PersistentZlssVolumeLocator_2Dot0_s,PZVL_2Dot0_lastZidTruncated), 1328, 1320 }, +}; + +#if MEDIA_FORMAT_DISPLAY_SIZES +STATUS ZLOG_ssprintf( + NINT bufferLength, + BYTE **bufferAddress, + NINT *retLen, + const char *format, + ...); +#endif + + +#if MEDIA_FORMAT_DISPLAY_SIZES +void ZLSSUT_DisplayAll( + NINT bufferLength, + BYTE **bufferAddress, + NINT *retLen ) +{ + int i; + + ZLOG_ssprintf(bufferLength, bufferAddress, retLen, "\n"); + NSSUT_DisplayAll(bufferLength,bufferAddress,retLen); + ZLOG_ssprintf(bufferLength, bufferAddress, retLen, "\n"); + for ( i = 0; i < NELEMS(ZPIList); ++i ) + { +#if 1 // XML + ZLOG_ssprintf(bufferLength, bufferAddress, retLen, "\n", ZPIList[i].ZPI_Name, ZPIList[i].ZPI_Size, ZPIList[i].ZPI_LastItem); +#else // In format to place into "ZLSSPersistentItems_s ZPIList[]" + ZLOG_ssprintf(bufferLength, bufferAddress, retLen, "\t{ \"%s\", sizeof(%s), \"%s\", offsetof(%s,%s), %u, %u },\n", + ZPIList[i].ZPI_Name, ZPIList[i].ZPI_Name, + ZPIList[i].ZPI_LastItemName, ZPIList[i].ZPI_Name, ZPIList[i].ZPI_LastItemName, + ZPIList[i].ZPI_Size, ZPIList[i].ZPI_LastItem); +#endif + if ( ZPIList[i].ZPI_Size != ZPIList[i].ZPI_SizePacked ) + { + zASSERT("Persistent structure size is not correct"==NULL); + } + if ( ZPIList[i].ZPI_LastItem != ZPIList[i].ZPI_LastItemPacked ) + { + zASSERT("Persistent structure offsetof is not correct"==NULL); + } + } + ZLOG_ssprintf(bufferLength, bufferAddress, retLen, "\n"); + ZLOG_ssprintf(bufferLength, bufferAddress, retLen, "\n"); +} +#endif + + +STATUS ZLSSUT_MediaFormatTestAllSizes( ) +{ + int i; + STATUS status = zOK; + + for ( i = 0; i < NELEMS(ZPIList); ++i ) + { + if ( ZPIList[i].ZPI_Size != ZPIList[i].ZPI_SizePacked ) + { + printk("<1>\n", ZPIList[i].ZPI_Name, ZPIList[i].ZPI_Size, ZPIList[i].ZPI_SizePacked); + zASSERT("Persistent structure size is not correct"==NULL); + status = zERR_MEDIA_CORRUPTED; + } + if ( ZPIList[i].ZPI_LastItem != ZPIList[i].ZPI_LastItemPacked ) + { + printk("<1>\n", ZPIList[i].ZPI_Name, ZPIList[i].ZPI_LastItem, ZPIList[i].ZPI_LastItemPacked); + zASSERT("Persistent structure offsetof is not correct"==NULL); + status = zERR_MEDIA_CORRUPTED; + } + } + return status; +} + diff --git a/src/nwnss/zlss/zlssStartup.h b/src/nwnss/zlss/zlssStartup.h index d1390f1..cdb17b2 100644 --- a/src/nwnss/zlss/zlssStartup.h +++ b/src/nwnss/zlss/zlssStartup.h @@ -61,36 +61,36 @@ extern VersionInformation_s ZSTORE_VersionInfo; extern struct PCLSwitchDef_s ZSTORE_CommandLineSwitches[]; #if NSS_DEBUG IS_ENABLED - extern BOOL ResetPools; - extern BOOL SkipCheckpoints; - extern BOOL SkipRecovery; - extern NINT CrashPools; /* Prevents shutdown code from being called - * at ZSTORE /EXIT time. */ - extern NINT zfsDebugBtree; - extern BOOL gZCL_SkipWrites; - extern BOOL GenerateOutOfDiskSpaceErrors; - extern NINT GenerateOutOfDiskSpaceErrorsBreakCount; + extern BOOL ResetPools; + extern BOOL SkipCheckpoints; + extern BOOL SkipRecovery; + extern NINT CrashPools; /* Prevents shutdown code from being called + * at ZSTORE /EXIT time. */ + extern NINT zfsDebugBtree; + extern BOOL gZCL_SkipWrites; + extern BOOL GenerateOutOfDiskSpaceErrors; + extern NINT GenerateOutOfDiskSpaceErrorsBreakCount; #ifndef __linux__ // LINUX_ZlogDebug - /* These items are to supply the Netware Volume to commands */ - extern char GCL_ZlogFileCopy[16]; /* GCL_ Global Command Line */ - extern char GCL_ZlogBeastCopy[16]; /* GCL_ Global Command Line */ - extern char PoolSave[16]; - extern char PoolRestoreImage[16]; - extern char PoolCompare[16]; + /* These items are to supply the Netware Volume to commands */ + extern char GCL_ZlogFileCopy[16]; /* GCL_ Global Command Line */ + extern char GCL_ZlogBeastCopy[16]; /* GCL_ Global Command Line */ + extern char PoolSave[16]; + extern char PoolRestoreImage[16]; + extern char PoolCompare[16]; #endif //__linux__ #if LOG_TEST IS_ENABLED - extern BOOL LogTest; + extern BOOL LogTest; #endif #if FMAP_TEST IS_ENABLED - extern BOOL FmapTest; - extern BOOL OneBlockExtents; + extern BOOL FmapTest; + extern BOOL OneBlockExtents; #endif #if ZLOG_TEST IS_ENABLED - extern BOOL ZlogUnitTest; + extern BOOL ZlogUnitTest; #endif #endif @@ -119,62 +119,62 @@ extern STATUS ZSTORE_DisplayVersion(void); * ZFSPOOL commands *-------------------------------------------------------------------------*/ extern STATUS ZFSPOOL_Startup( - struct GeneralMsg_s *genMsg); + struct GeneralMsg_s *genMsg); extern void ZFSPOOL_Shutdown(void); void EFL_DisplayEFLTree( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); void EFL_DisplayEFLLog( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); #if NSS_DEBUG IS_ENABLED void ZFSPOOL_Layout32( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); void ZFSVOL_CorruptLVDB( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); #ifndef __linux__ // LINUX_ZlogDebug void ZFSVOL_CorruptToggle( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); #endif void ZfsDisplayBeastTree( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); void DisplayPurgeLogInfo( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); void DBT_DisplayDirTree( - struct PCLSwitchDef_s *switchDef, - NINT index, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT index, + void *userParm); STATUS doPoolRestoreScan( - struct PCLSwitchDef_s *switchDef, - NINT options, - void *userParm); + struct PCLSwitchDef_s *switchDef, + NINT options, + void *userParm); extern unicode_t *ReadBlkVolumeName; /* Generic volume name used by \RB - * commands and \PoolRestoreScan and etc. - */ + * commands and \PoolRestoreScan and etc. + */ #endif @@ -184,12 +184,12 @@ extern unicode_t *ReadBlkVolumeName; /* Generic volume name used by \RB * Routines INIT/UNINIT the memory storage system code *---------------------------------------------------------------------------*/ extern STATUS ZSTORE_Startup( - struct GeneralMsg_s *genMsg); + struct GeneralMsg_s *genMsg); extern void ZSTORE_Shutdown(void); extern STATUS ZSTORE_RegisterLSSOperations( - struct GeneralMsg_s *genMsg); + struct GeneralMsg_s *genMsg); extern void ZSTORE_ClearLSSOperations(void); diff --git a/src/nwnss/zlss/zlssStorPool.c b/src/nwnss/zlss/zlssStorPool.c index 6cad8d9..5e33ea6 100644 --- a/src/nwnss/zlss/zlssStorPool.c +++ b/src/nwnss/zlss/zlssStorPool.c @@ -82,7 +82,7 @@ DQhead_t ZLSSPhyPoolList = DQ_STATIC_INIT(ZLSSPhyPoolList); /*------------------ START OF ROUTINES ------------------------------------*/ ControlStore_s Phypool_Control; /* We have 256 NON-shared cookies. If we run - * out then we give out 'TheSharedCookie'. + * out then we give out 'TheSharedCookie'. */ BOOL Phypool_ControlInit = FALSE; /* TRUE is we need to free Phypool_Control during * shutdown. @@ -231,7 +231,7 @@ STATUS zlssInsertPool( zConPool_s *phypool, unicode_t *oldPoolName ) { STATUS status; GeneralMsg_s genMsg; - + ASSERT_MPKNSS_LOCK(); COMN_SETUP_GENERAL_MSG_NOSA( &genMsg ); @@ -272,7 +272,7 @@ STATUS zlssInsertPool( zConPool_s *phypool, unicode_t *oldPoolName ) #endif #endif phypool->pol.zfspool = ZFSPOOL_LoadPool( &genMsg, &phypool->pol, - TRUE, ZLSS_PLF_NORMAL, snapshot, oldPoolName, + TRUE, ZLSS_PLF_NORMAL, snapshot, oldPoolName, (phypool->pol.poolstatus == POL_STAT_NEW_NAME) ? TRUE : FALSE ); if ( phypool->pol.zfspool == NULL) { @@ -330,7 +330,7 @@ STATUS zlssInsertPool( zConPool_s *phypool, unicode_t *oldPoolName ) phypool->pol.SP_LoadStatus &= ~LS_LOADING; return( zFAILURE ); } - } + } phypool->pol.SP_LoadStatus &= ~LS_LOADING; return(zOK); } @@ -505,7 +505,7 @@ PhyKey_t phypool_KeyGenerate( PhyCookie_s *phyCookie ) // could get 2+ phypool_KeyGenerate before a release. ++phyCookie->PC_KeyValidCurrent; } - key.pk_unique = phyCookie->PC_KeyValidCurrent; + key.pk_unique = phyCookie->PC_KeyValidCurrent; key.pk_cookie = (ADDR)phyCookie; return( key ); @@ -532,7 +532,7 @@ PhyKey_t phypool_KeyGenerate( PhyCookie_s *phyCookie ) * TheSharedCookie which then must be handled with some special code. * * Warnings - - * This routine is NOT allowed to block BEFORE incrementing + * This routine is NOT allowed to block BEFORE incrementing * ZCP_InUseCount since our callers have the phypool PTR already. * If we block then the phypool could be freed by another process. */ @@ -566,7 +566,7 @@ PhyKey_t phypool_Obtain( zConPool_s *phypool, char *where ) phyCookie->PC_Phypool = phypool; DQ_ENQ( &phypool->ZCP_CookieHead, phyCookie, PC_CookieLink ); } - key = phypool_KeyGenerate( phyCookie ); + key = phypool_KeyGenerate( phyCookie ); return( key ); } /* End of phypool_Obtain() */ @@ -654,3 +654,6 @@ STATUS phypool_Release( PhyKey_t key, zConPool_s *phypool, char *where ) /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + + + diff --git a/src/nwnss/zlss/zlssUpgrade.c b/src/nwnss/zlss/zlssUpgrade.c index cefbf60..54ede54 100644 --- a/src/nwnss/zlss/zlssUpgrade.c +++ b/src/nwnss/zlss/zlssUpgrade.c @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** | | (C) Copyright 1995-2000, 2003 Novell, Inc. | All Rights Reserved. @@ -63,10 +63,10 @@ STATUS HL_UpgradePoolMediaVersion(GeneralMsg_s *genMsg, ZlssPool_s *zlssPool); /* Amount of time to delay before going to Nakoma format. The - * actual delay is three times this amount as the delay is - * done three times. The 1 hour is for testing, the specification - * value is 7 days for a total of 21 days to complete upgrade. - */ + * actual delay is three times this amount as the delay is + * done three times. The 1 hour is for testing, the specification + * value is 7 days for a total of 21 days to complete upgrade. + */ NINT ZLSS_UpgradeNakomaDelay = (7 * 24 * 60 * 60); /* 7 Days */ //NINT ZLSS_UpgradeNakomaDelay = (1 * 1 * 60 * 60); /* 1 Hour */ @@ -74,7 +74,7 @@ NINT ZLSS_UpgradeNakomaDelay = (7 * 24 * 60 * 60); /* 7 Days */ | ZFSPOOL_AIPU34To35() - | Performs an auto in-place-upgrade of media version 34 to media | version 35. The actual change of adding the User Space Restriction - | B-Tree is done at ... + | B-Tree is done at ... | | Notes - | The purpose of changing the meda version is to prevent @@ -99,9 +99,9 @@ STATUS ZFSPOOL_AIPU34Or35To36( GeneralMsg_s *genMsg, ZfsPool_s *pool ) pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor == 35 ); if (pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor < 34 ) { /* Should not happen, but better safe than sorry. I.E. a - * version check is done real early in the ACTIVATE process - * for legal media formats. - */ + * version check is done real early in the ACTIVATE process + * for legal media formats. + */ SetErrno( genMsg, zERR_SUPERBLOCK_UNSUPPORTED_MEDIA ); errPrintf(WHERE, Module, 1411, MSG("Media layout %d not supported\n", 932), @@ -118,10 +118,10 @@ STATUS ZFSPOOL_AIPU34Or35To36( GeneralMsg_s *genMsg, ZfsPool_s *pool ) zASSERT( LB_GUIDValidate( &pool->ZP_super->SB_Header.hdr.SBH_VolumeID ) ); /* Note that the checksum will be updated by the SuperBlock write - * header code below. Having the checksum correct in the - * ZP_Super is not REQUIRED because we always calculate it - * when writing the header. - */ + * header code below. Having the checksum correct in the + * ZP_Super is not REQUIRED because we always calculate it + * when writing the header. + */ if (ZFSPOOL_SuperBlockUpdate(genMsg, pool) != zOK) { return(zFAILURE); @@ -152,7 +152,7 @@ STATUS ZFSPOOL_fixDirTreeNode( { zASSERT("Error upgrading directory tree\n" == NULL); errPrintf(WHERE, Module, 1477, - MSG("Error upgrading directory tree, status=%d. ", 522), + MSG("Error upgrading directory tree, status=%d. ", 522), GetErrno(genMsg)); return zFAILURE; } @@ -187,11 +187,11 @@ STATUS ZFSPOOL_fixDirTreeNode( /* process each entry in the branch */ for (i = 0; i < node->numRecs; i++) { - if (ZFSPOOL_fixDirTreeNode(genMsg, dirTreeBeast, + if (ZFSPOOL_fixDirTreeNode(genMsg, dirTreeBeast, node->DBRANCH(i).child, agent) != zOK) { cacheReleaseToss(buffer); - return zFAILURE; + return zFAILURE; } } node->magic = DBT_BRANCH_MAGIC; @@ -215,16 +215,16 @@ STATUS ZFSPOOL_upgradeDirectoryTree( Agent_s agent; /* - * If there is no tree then don't bother. - */ + * If there is no tree then don't bother. + */ if (dirTreeBeast == NULL) { return zOK; } /* - * Get an exclusive latch on the Directory Tree Beast - */ + * Get an exclusive latch on the Directory Tree Beast + */ X_LATCH(&dirTreeBeast->ZFSDIRTREEbeastLatch); if (dirTreeBeast->zfsBtree.p.btRoot == INVALID_BLK) @@ -236,9 +236,9 @@ STATUS ZFSPOOL_upgradeDirectoryTree( /* recurse through the tree starting at the root */ initAgent(&agent, NULL, "Convert Dir Tree"); - if ((status = ZFSPOOL_fixDirTreeNode(genMsg, dirTreeBeast, + if ((status = ZFSPOOL_fixDirTreeNode(genMsg, dirTreeBeast, dirTreeBeast->zfsBtree.p.btRoot, &agent)) == zOK) - { + { defaultFlushWait(&agent); } @@ -273,9 +273,9 @@ STATUS ZFSPOOL_AIPU36To39( GeneralMsg_s *genMsg, ZfsPool_s *pool ) zASSERT( pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor == 36 ); if (pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor < 36 ) { /* Should not happen, but better safe than sorry. I.E. a - * version check is done real early in the ACTIVATE process - * for legal media formats. - */ + * version check is done real early in the ACTIVATE process + * for legal media formats. + */ SetErrno( genMsg, zERR_SUPERBLOCK_UNSUPPORTED_MEDIA ); errPrintf(WHERE, Module, 1411, MSG("Media layout %d not supported\n", 934), @@ -288,8 +288,8 @@ STATUS ZFSPOOL_AIPU36To39( GeneralMsg_s *genMsg, ZfsPool_s *pool ) #endif /* - * Upgrade the directory tree if it needs it - */ + * Upgrade the directory tree if it needs it + */ if (pool->ZFSPOOLzfsvol.ZLSSVOLdirTree != NULL) { #if NSS_DEBUG IS_ENABLED @@ -305,11 +305,11 @@ STATUS ZFSPOOL_AIPU36To39( GeneralMsg_s *genMsg, ZfsPool_s *pool ) #endif /* - * Convert the volume to the new volume structure. This includes changing - * the beastVersionMask so that both beast versions 1 and 2 are valid, - * reseting the volAttributes so only the salvage bit is left, and - * updating the NDS VOLUME ID to a GUID. - */ + * Convert the volume to the new volume structure. This includes changing + * the beastVersionMask so that both beast versions 1 and 2 are valid, + * reseting the volAttributes so only the salvage bit is left, and + * updating the NDS VOLUME ID to a GUID. + */ #if (CURRENT_BEAST_VERSION != BEAST_VERSION_3) #error "Check to see if the beastVersion code below is still needed." @@ -320,15 +320,15 @@ STATUS ZFSPOOL_AIPU36To39( GeneralMsg_s *genMsg, ZfsPool_s *pool ) aprintf(CYAN," ** (Debug)Upgrading the volume to have GUID IDs\n"); #endif /* - * Setting the beast mask to 3 indicates that both version 1 and - * version 2 beast may be found in the volume. It should be set - * to 2 when all version 1 beasts have been converted. - */ + * Setting the beast mask to 3 indicates that both version 1 and + * version 2 beast may be found in the volume. It should be set + * to 2 when all version 1 beasts have been converted. + */ pool->zfsVol.vol.p.beastVersionMask = 3; pool->zfsVol.vol.p.beastVersion = BEAST_VERSION_2; /* - * Change the NDS ID for the NDS volume object to a GUID - */ + * Change the NDS ID for the NDS volume object to a GUID + */ DEBUG_PRINTF(TPOOL,DBG_NOINDENT,(YELLOW, MSGNot("Changing volume nds object ID to a GUID\n"))); if (COMN_MapNDSIDToGUID(&status, *(LONG *)&pool->zfsVol.vol.p.ndsObjectID, @@ -349,12 +349,12 @@ STATUS ZFSPOOL_AIPU36To39( GeneralMsg_s *genMsg, ZfsPool_s *pool ) MSGNot(" Setting activation count of pool/volume to %ld\n"), pool->zfsLogBeast->ZLB_P.ZLBP_RecoveryActivationCount )); /** - * Update the volumes activation count to agree with the pools - * count. This is needed so the purge log gets played correctly. - * + 1 is because we now increment the activationCount the very - * first time we read persistent volume data, which is before - * this. - */ + * Update the volumes activation count to agree with the pools + * count. This is needed so the purge log gets played correctly. + * + 1 is because we now increment the activationCount the very + * first time we read persistent volume data, which is before + * this. + */ pool->ZFSPOOLzfsvol.ZFSVOLactivationCount = pool->zfsLogBeast->ZLB_P.ZLBP_RecoveryActivationCount + 1; #if NSS_DEBUG IS_ENABLED @@ -365,10 +365,10 @@ STATUS ZFSPOOL_AIPU36To39( GeneralMsg_s *genMsg, ZfsPool_s *pool ) zASSERT( pool->ZP_super != NULL ); /* Save off the current media version into the 'Create' media - * version so that we have 'some' idea as to the media version - * that the pool was created at. - */ - pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajorCreate = + * version so that we have 'some' idea as to the media version + * that the pool was created at. + */ + pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajorCreate = pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor; pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinorCreate = pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor; @@ -376,10 +376,10 @@ STATUS ZFSPOOL_AIPU36To39( GeneralMsg_s *genMsg, ZfsPool_s *pool ) pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor = 0; zASSERT( LB_GUIDValidate( &pool->ZP_super->SB_Header.hdr.SBH_VolumeID ) ); /* Note that the checksum will be updated by the SuperBlock write - * header code below. Having the checksum correct in the - * ZP_Super is not REQUIRED because we always calculate it - * when writing the header. - */ + * header code below. Having the checksum correct in the + * ZP_Super is not REQUIRED because we always calculate it + * when writing the header. + */ if (ZFSPOOL_SuperBlockUpdate(genMsg, pool) != zOK) { @@ -418,23 +418,23 @@ STATUS CompleteTheUpgradeTo4001( ZfsBeastTreeBeast_s *beastTree = pool->ZFSPOOLzfsvol.beastTree; if ( pool->ZP_super->SB_Header.hdr.SBH_SystemBeastBlkNum != - pool->ZFSPOOLzfsvol.p.PZV_systemBeastBlkNum ) + pool->ZFSPOOLzfsvol.p.PZV_systemBeastBlkNum ) { /* The SB got updated, but the volume Data block did not get - * updated with the new special block number */ + * updated with the new special block number */ pool->ZFSPOOLzfsvol.p.PZV_systemBeastBlkNum = pool->ZP_super->SB_Header.hdr.SBH_SystemBeastBlkNum; /* Update the copy in the beastTree beast in memory */ - beastTree->specialSystemBstsBlk = + beastTree->specialSystemBstsBlk = pool->ZFSPOOLzfsvol.p.PZV_systemBeastBlkNum; ZFSVOL_WritePersistentVolumeData(&pool->ZFSPOOLzfsvol); } - - READBLK_IO_MSG(iomsg, beastTree, beastTree->specialSystemBstsBlk, - CACHE_UPDATE); + + READBLK_IO_MSG(iomsg, beastTree, beastTree->specialSystemBstsBlk, + CACHE_UPDATE); spcBuf = ZFS_ReadPoolBlk(genMsg, &iomsg); if (spcBuf == NULL) { @@ -487,10 +487,10 @@ STATUS CompleteTheUpgradeTo4001( zASSERT(pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor == 0); pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMinor = 1; /* Note that the checksum will be updated by the SuperBlock write - * header code below. Having the checksum correct in the - * ZP_Super is not REQUIRED because we always calculate it - * when writing the header. - */ + * header code below. Having the checksum correct in the + * ZP_Super is not REQUIRED because we always calculate it + * when writing the header. + */ if (ZFSPOOL_SuperBlockUpdate(genMsg, pool) != zOK) { return( zFAILURE ); @@ -511,12 +511,12 @@ Blknum_t CheckSavedBlkNumAndAlloc( seedext.lengthOfExtent = 1; - if (((seedext.poolBlkNum = *savedSBHTempBlk) == 0) || + if (((seedext.poolBlkNum = *savedSBHTempBlk) == 0) || (FT_ExtentIsStillFree(pool, &seedext))) { - /* There is no saved block OR (there is saved block AND it is still in - in the free tree) */ - zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, + /* There is no saved block OR (there is saved block AND it is still in + in the free tree) */ + zfsAllocExtent( genMsg, &pool->ZFSPOOLzfsVol, &seedext, XTREE_SYSTEM_REQUEST, NULL); if (seedext.lengthOfExtent != 1) { @@ -586,9 +586,9 @@ STATUS ZFSPOOL_AIPU39To4001( zASSERT( pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor == (AIPU_LV_MEDIA_MAJOR-1) ); if (pool->ZP_super->SB_Header.hdr.SBH_VersionMediaMajor < (AIPU_LV_MEDIA_MAJOR-1) ) { /* Should not happen, but better safe than sorry. I.E. a - * version check is done real early in the ACTIVATE process - * for legal media formats. - */ + * version check is done real early in the ACTIVATE process + * for legal media formats. + */ SetErrno( genMsg, zERR_SUPERBLOCK_UNSUPPORTED_MEDIA ); errPrintf(WHERE, Module, 1411, MSG("Media layout %d not supported\n", 937), @@ -598,16 +598,16 @@ STATUS ZFSPOOL_AIPU39To4001( } /*------------------------------------------------------------------------ - | Allocate ONE block for system beasts. - | We force the allocation to the middle of the volume (which means - | nothing if multiple drives make up the volume). - *----------------------------------------------------------------------*/ + | Allocate ONE block for system beasts. + | We force the allocation to the middle of the volume (which means + | nothing if multiple drives make up the volume). + *----------------------------------------------------------------------*/ /* | read superblock saved off block. - | if not zero + | if not zero | if exists in free tree - | Allocate a block + | Allocate a block | spc block is saved block | copy block to superblock saved block | write superblock @@ -635,46 +635,46 @@ STATUS ZFSPOOL_AIPU39To4001( */ freeTree->xtreeFlags |= XTREE_OK_TODO_LOCAL_XACTION; - if ((spBTBlk = CheckSavedBlkNumAndAlloc(genMsg, pool, - &pool->ZP_super->SB_Header.hdr.SBH_TempBTSpBlk)) == 0) + if ((spBTBlk = CheckSavedBlkNumAndAlloc(genMsg, pool, + &pool->ZP_super->SB_Header.hdr.SBH_TempBTSpBlk)) == 0) { freeTree->xtreeFlags &= ~XTREE_OK_TODO_LOCAL_XACTION; STACK_FREE(); return( zFAILURE ); } - - if ((spFTBlk = CheckSavedBlkNumAndAlloc(genMsg, pool, - &pool->ZP_super->SB_Header.hdr.SBH_TempFTSpBlk)) == 0) + + if ((spFTBlk = CheckSavedBlkNumAndAlloc(genMsg, pool, + &pool->ZP_super->SB_Header.hdr.SBH_TempFTSpBlk)) == 0) { freeTree->xtreeFlags &= ~XTREE_OK_TODO_LOCAL_XACTION; STACK_FREE(); return( zFAILURE ); } - - if ((spFTBlkBlk1 = CheckSavedBlkNumAndAlloc(genMsg, pool, - &pool->ZP_super->SB_Header.hdr.SBH_TempFTSpBlk1)) == 0) + + if ((spFTBlkBlk1 = CheckSavedBlkNumAndAlloc(genMsg, pool, + &pool->ZP_super->SB_Header.hdr.SBH_TempFTSpBlk1)) == 0) { freeTree->xtreeFlags &= ~XTREE_OK_TODO_LOCAL_XACTION; STACK_FREE(); return( zFAILURE ); } - - if ((spFTBlkBlk2 = CheckSavedBlkNumAndAlloc(genMsg, pool, - &pool->ZP_super->SB_Header.hdr.SBH_TempFTSpBlk2)) == 0) + + if ((spFTBlkBlk2 = CheckSavedBlkNumAndAlloc(genMsg, pool, + &pool->ZP_super->SB_Header.hdr.SBH_TempFTSpBlk2)) == 0) { freeTree->xtreeFlags &= ~XTREE_OK_TODO_LOCAL_XACTION; STACK_FREE(); return( zFAILURE ); } - + freeTree->xtreeFlags &= ~XTREE_OK_TODO_LOCAL_XACTION; /** This field used to point to the left leaf of the beast tree beast. - ** (Before the upgrade to media format 40.01) - ** It is being reset to point to the location of the special blk - ** where the system beasts will be moved to. - **/ + ** (Before the upgrade to media format 40.01) + ** It is being reset to point to the location of the special blk + ** where the system beasts will be moved to. + **/ leftBstTreeBlk = pool->ZFSPOOLzfsvol.p.PZV_systemBeastBlkNum; zASSERT(beastTree->specialSystemBstsBlk == leftBstTreeBlk); pool->ZP_super->SB_Header.hdr.SBH_SystemBeastBlkNum = spBTBlk; @@ -682,15 +682,15 @@ STATUS ZFSPOOL_AIPU39To4001( /* The above block ie VDB needs to be written */ beastTree->specialSystemBstsBlk = spBTBlk; - READBLK_IO_MSG(aStack->iomsg, beastTree, spBTBlk, CACHE_WRITE); + READBLK_IO_MSG(aStack->iomsg, beastTree, spBTBlk, CACHE_WRITE); spcBuf = ZFS_ReadPoolBlk(genMsg, &aStack->iomsg); if (spcBuf == NULL) { STACK_FREE(); return( zFAILURE ); } - initNode(spcBuf, BBT_LEAF|BBT_SYSTEM_BSTS_BLK, - &pool->zfsVol.logged.LPZV_internalID); + initNode(spcBuf, BBT_LEAF|BBT_SYSTEM_BSTS_BLK, + &pool->zfsVol.logged.LPZV_internalID); spcNode = (BeastTreeNode_s *)spcBuf->pBuf.data; insertZeroNode(spcNode); spcNode->n.leaf.nextLeaf = leftBstTreeBlk; @@ -733,25 +733,25 @@ STATUS ZFSPOOL_AIPU39To4001( X_LATCH(&freeTree->ZFSFXbeastLatch); InitSpecialNode(genMsg, freeTree, spFTBlk); /* we add 2 blks to the special free tree node. this allows us to - * do allocExtents transactioned from here onwards. In case we crash - * alloc extent will be logically undone which is a logical free, which - * may cause a split or a grow, and this requires there be some blks - * in the special block. the routine to add the 20 blks is called later - * in a xactioned way - */ + * do allocExtents transactioned from here onwards. In case we crash + * alloc extent will be logically undone which is a logical free, which + * may cause a split or a grow, and this requires there be some blks + * in the special block. the routine to add the 20 blks is called later + * in a xactioned way + */ Add2BlksToSpecialNode(genMsg, freeTree, spFTBlk, spFTBlkBlk1, spFTBlkBlk2); freeTree->ZFSFXroot.bstState |= BST_STATE_DIRTY; UNX_LATCH(&freeTree->ZFSFXbeastLatch); BST_flush(freeTree); /* This waits for all the free tree buffers and - * the free tree beast to be written. It does - * not wait for the beast tree node to which the - * free tree is updated to be flushed. - * But we know that it is written to the new - * special system beast block in the free tree. - */ + * the free tree beast to be written. It does + * not wait for the beast tree node to which the + * free tree is updated to be flushed. + * But we know that it is written to the new + * special system beast block in the free tree. + */ - READBLK_IO_MSG(aStack->iomsg, beastTree, spBTBlk, CACHE_UPDATE); + READBLK_IO_MSG(aStack->iomsg, beastTree, spBTBlk, CACHE_UPDATE); spcBuf = ZFS_ReadPoolBlk(genMsg, &aStack->iomsg); if (spcBuf == NULL) { @@ -762,8 +762,8 @@ STATUS ZFSPOOL_AIPU39To4001( bind(&aStack->agent, &spcBuf->agent); CACHE_DIRTY_RELEASE(spcBuf); defaultFlushWait(&aStack->agent); /* This waits for the beast tree special - * systems block to get written. - */ + * systems block to get written. + */ /* Second write the superblock header that points to the special block */ zASSERT( pool->ZP_super != NULL ); @@ -783,12 +783,12 @@ STATUS ZFSPOOL_AIPU39To4001( ZFSVOL_WritePersistentVolumeData(&pool->ZFSPOOLzfsvol); /* Third make sure the left leaf of the beast tree gets flushed to disk */ - + /* The moveZnode has actually moved the systems beasts out of the left - * block of the beast tree, but we continue to hold the latch on the - * left blk of the btree so that it cannot get flushed to the disk - * until after the suberblock header uptade to AIPU_LV_MEDIA_MAJOR - */ + * block of the beast tree, but we continue to hold the latch on the + * left blk of the btree so that it cannot get flushed to the disk + * until after the suberblock header uptade to AIPU_LV_MEDIA_MAJOR + */ initAgent(&aStack->agent, NULL, "Upgrade media"); bind(&aStack->agent, &leftBuf->agent); CACHE_DIRTY_RELEASE(leftBuf); @@ -940,11 +940,11 @@ STATUS ZFSPOOL_AutoInPlaceUpgrade( // status = ZFSVOL_VOL_UpdateBeastToVolume(genMsg, // &salvageBeast->ZFSPURGETREEroot, packedSize, &xaction->xaction); // if ( status != zOK ) -// { +// { ///** I removed noPackCleanup because we are totally unaware // ** if a the error was before or after update beast got // ** an error. I.E. I believe that update beast should -// ** call the noPackCleanup! +// ** call the noPackCleanup! // ** Update beast now does the cleanup. -- Vandana. // ** // ** BST_noPackCleanup(&salvageBeast->ZFSPURGETREEroot); @@ -1073,7 +1073,7 @@ STATUS ZFSPOOL_LayoutEFL( if ( pool->POOLstate == zVOLSTATE_DEACTIVE ) { MediaSuperBlockHeader_s *super; - + /* The super block memory is freed in the ZfsPool destructor */ super = (MediaSuperBlockHeader_s *)zalloc(sizeof(*super)); if ( super != NULL ) @@ -1107,7 +1107,7 @@ STATUS ZFSPOOL_LayoutEFL( } else { - printf( MSGNot("Pool must be in DEACTIVE state.\n") ); + printf( MSGNot("Pool must be in DEACTIVE state.\n") ); } } COMN_Release( &pool ); @@ -1117,7 +1117,7 @@ STATUS ZFSPOOL_LayoutEFL( printf(MSGNot("Pool \"%U\" not found.\n"), (unicode_t *)switchDef->ret_value ); } - MPKNSS_UNLOCK(); + MPKNSS_UNLOCK(); return zOK; } /* End of ZFSPOOL_LayoutEFL() */ @@ -1149,7 +1149,7 @@ void ZFSVOL_CorruptLVDB( if (volume != NULL) { - + if ( !COMN_IsDerivedFrom(volume, zFTYPE_ZLSS_VOL) ) { /* Not a ZLSS volume so exit */ printf(MSGNot("Volume not a ZLSS volume.\n")); @@ -1161,15 +1161,15 @@ void ZFSVOL_CorruptLVDB( volume->VOLinUseBlocks += 10; volume->VOLnumObjects += 10; volume->VOLnumFiles += 10; - /* Update the ZLSS special 'booked' item as it is - * associated with the in use blocks we just modified. - */ + /* Update the ZLSS special 'booked' item as it is + * associated with the in use blocks we just modified. + */ zfsVolume = (ZfsVolume_s *)volume; zfsVolume->zv_bookedInUseBlocks += 10; /* Saves all changes made to block (since this is debug code we - * just skip the transactioning part of the code that normal - * code would have to do). - */ + * just skip the transactioning part of the code that normal + * code would have to do). + */ volLog.delta = 10; volLog.action = VOLINFO_CHANGE_NUM_OBJECTS; ZFSVOL_VOL_WriteVolumeLoggedData(volume, NULL, &volLog); @@ -1189,7 +1189,7 @@ void ZFSVOL_CorruptLVDB( /*--------------------------------------------------------------------------- | | Toggle the Corrupt bit on a ZLSS volume. This is done - | via "nss /corruptToggle=volname" in debug systems. Used to test + | via "nss /corruptToggle=volname" in debug systems. Used to test | activation and in-place-upgrade code (32 to 33) | +-------------------------------------------------------------------------*/ @@ -1216,9 +1216,9 @@ void ZFSVOL_CorruptToggle( } /* Hack three items that will get verify mad at us */ /* Saves all changes made to block (since this is debug code we - * just skip the transactioning part of the code that normal - * code would have to do. - */ + * just skip the transactioning part of the code that normal + * code would have to do. + */ if ( volume->p.stateAttributes & VOLSTATEATTR_CORRUPT ) { /* On so turn off */ volume->p.stateAttributes &= ~VOLSTATEATTR_CORRUPT; @@ -1280,8 +1280,8 @@ BOOL HL_UpgradePoolMediaVersion_Ready(ZlssPool_s *zlssPool) if (latchStatus == WAITED) { return FALSE; - } - + } + /* Check the Internal Volume first. Since pool is active the IV is active. */ vol = ZFS_POOL_TO_VOLUME( zfsPool ); if(vol->VOLmediaFormatMajor < ZLSS_LV_MEDIA_MAJOR_NAKOMA_HARDLINK) @@ -1290,7 +1290,7 @@ BOOL HL_UpgradePoolMediaVersion_Ready(ZlssPool_s *zlssPool) } if((vol->VOLmediaFormatMajor == ZLSS_LV_MEDIA_MAJOR_NAKOMA_HARDLINK) && - (vol->VOLmediaFormatMinor < ZLSS_LV_MEDIA_MINOR_NAKOMA_HARDLINK_DONE)) + (vol->VOLmediaFormatMinor < ZLSS_LV_MEDIA_MINOR_NAKOMA_HARDLINK_DONE)) { goto done; } @@ -1308,7 +1308,7 @@ BOOL HL_UpgradePoolMediaVersion_Ready(ZlssPool_s *zlssPool) } if((vol->VOLmediaFormatMajor == ZLSS_LV_MEDIA_MAJOR_NAKOMA_HARDLINK) && - (vol->VOLmediaFormatMinor < ZLSS_LV_MEDIA_MINOR_NAKOMA_HARDLINK_DONE)) + (vol->VOLmediaFormatMinor < ZLSS_LV_MEDIA_MINOR_NAKOMA_HARDLINK_DONE)) { goto done; } @@ -1316,7 +1316,7 @@ BOOL HL_UpgradePoolMediaVersion_Ready(ZlssPool_s *zlssPool) ready = TRUE; done: - UNX_LATCH( &zfsPool->ZFSPOOLvol.v_pool->cvsLatch ); + UNX_LATCH( &zfsPool->ZFSPOOLvol.v_pool->cvsLatch ); return ready; } @@ -1335,8 +1335,8 @@ BOOL ZFSPOOL_AIPU4008Through4049To4084_Ready( return( FALSE ); } /* Hidden command line option to prevent upgrades of pools - * on servers that run both Nakoma and 6Pack NSS. - */ + * on servers that run both Nakoma and 6Pack NSS. + */ if ( !ZLSS_UpgradeMediaFormat ) { return( FALSE ); @@ -1563,7 +1563,7 @@ BOOL ZFSPOOL_AIPU4085To4086_Ready( return( TRUE ); } return( FALSE ); - + } /* End of ZFSPOOL_AIPU4085To4086_Ready() */ @@ -1635,7 +1635,7 @@ BOOL ZFSPOOL_AIPU4087To4088_Ready( return( TRUE ); } return( FALSE ); - + } /* End of ZFSPOOL_AIPU4087To4088_Ready() */ @@ -1668,7 +1668,7 @@ BOOL ZFSPOOL_AIPU4088To4300_Ready( } return( TRUE ); - + } /* End of ZFSPOOL_AIPU4088To4300_Ready() */ @@ -1735,7 +1735,7 @@ BOOL ZFSPOOL_AIPU4300To4302_Ready( return( FALSE ); } - X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); /* Do the _IV_ first */ completed = ZLSS_VolumeUpgradedToNakoma( ZFS_POOL_TO_ZLSS_VOLUME( zfsPool ) ); if ( !completed ) @@ -1751,14 +1751,14 @@ BOOL ZFSPOOL_AIPU4300To4302_Ready( ++notUpgraded; } } - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); if ( notUpgraded > 0 ) { return( FALSE ); } return( TRUE ); - + } /* End of ZFSPOOL_AIPU4300To4302_Ready() */ @@ -1929,15 +1929,15 @@ STATUS ZLSSVOL_AIPU3500Through3549To3600( } else { /* Since COMP is not on volume we MUST mark as done because - * COMN will not. - */ + * COMN will not. + */ zVolume->ZLSSVOLvol.VOLcompAttributes.compFlags |= (VOL_COMP_FLAGS_UPGRADE_START | VOL_COMP_FLAGS_UPGRADE_FINISHED); } ZFSVOL_WritePersistentVolumeData(zVolume); /* Tell common layer that they should upgrade the comp beasts. If - * we crash the common layer also checks bit at activation time. - */ + * we crash the common layer also checks bit at activation time. + */ if (zVolume->ZLSSVOLvol.VOLenabledAttributes & zATTR_COMPRESSION) { CM_StartUpgradeProcess(); @@ -1967,10 +1967,10 @@ BOOL ZLSSVOL_AIPU0000To3500_Ready( } if ( zlssPool->ZP_Version >= ZLSS_MEDIA_VERSION_4300 ) { /* If the pool is at least 43.00 then its volumes - * can go to 35.00. No real reason to wait - * for pool version 43.00, we do to be consistent with - * other volume upgrades that wait until pool is 43.00. - */ + * can go to 35.00. No real reason to wait + * for pool version 43.00, we do to be consistent with + * other volume upgrades that wait until pool is 43.00. + */ version = (zVolume->ZLSSVOLmediaFormatMajor*0x100)+zVolume->ZLSSVOLmediaFormatMinor; if ( version == ZLSS_VOLUME_MEDIA_VERSION_0000 ) { @@ -2010,8 +2010,8 @@ STATUS ZLSSVOL_AIPU0000To3500( (void)NSSLOG_EventLogWithVolume( &zVolume->ZLSSVOLvol, ZSTORE_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_MEDIA_UPGRADE, MSGNot("Upgrade from 00.00 to 35.00.") ); /* See if shred count is still wrong. Someone could have - * set the shread count since the volume was inited. - */ + * set the shread count since the volume was inited. + */ if ( zVolume->ZLSSVOLvol.p.PV_shredCount == 0 ) { zVolume->ZLSSVOLvol.p.PV_shredCount = 1; @@ -2068,11 +2068,11 @@ BOOL ZLSSVOL_AIPU3603To3604_Ready( } if ( zlssPool->ZP_Version >= ZLSS_MEDIA_VERSION_4302 ) { /* If the pool is at least 43.02 then its volumes - * can go to 36.04. We can not change volumes - * to 36.04 before this because rebuild will be totally - * confussed as to how to rebuild a volumes VDB. - * See ZLSSVOL_InitVDB. - */ + * can go to 36.04. We can not change volumes + * to 36.04 before this because rebuild will be totally + * confussed as to how to rebuild a volumes VDB. + * See ZLSSVOL_InitVDB. + */ version = (zVolume->ZLSSVOLmediaFormatMajor*0x100)+zVolume->ZLSSVOLmediaFormatMinor; if ( version == ZLSS_VOLUME_MEDIA_VERSION_3603 ) { @@ -2105,12 +2105,12 @@ BOOL ZLSSVOL_AIPU3500Through3549To3600_Ready( } if ( zlssPool->ZP_Version >= ZLSS_MEDIA_VERSION_4300 ) { /* If the pool is at least 43.00 then its volumes - * can go to 36.00. We can not change volumes - * before this as NetWare 6.0 NSS rebuild will - * delete them if rolled backed to FCS, SP1, SP2 or SP3. - */ + * can go to 36.00. We can not change volumes + * before this as NetWare 6.0 NSS rebuild will + * delete them if rolled backed to FCS, SP1, SP2 or SP3. + */ if ( (zVolume->ZLSSVOLmediaFormatMajor == ZLSS_LV_MEDIA_MAJOR) && - (zVolume->ZLSSVOLmediaFormatMinor < 50) ) + (zVolume->ZLSSVOLmediaFormatMinor < 50) ) { return( TRUE ); } @@ -2133,9 +2133,9 @@ BOOL ZLSSVOL_AIPU3600To3603_Ready( NINT version; /* We do not do the POOL version check for 43.00 here - * because to get to volume version 36.00 the pool - * must be at least 43.00. - */ + * because to get to volume version 36.00 the pool + * must be at least 43.00. + */ version = (zVolume->ZLSSVOLmediaFormatMajor*0x100)+zVolume->ZLSSVOLmediaFormatMinor; if ( version == ZLSS_VOLUME_MEDIA_VERSION_3600 ) { /* Correct media type to upgrade */ @@ -2184,14 +2184,14 @@ BOOL ZLSSVOL_AIPU3601To3602( ZfsVolume_s *zVolume ) { /* We do not do the POOL version check for 43.00 here - * because to get to volume version 36.01 the pool - * must be at least 43.00. - */ + * because to get to volume version 36.01 the pool + * must be at least 43.00. + */ /* defect 373025: new volumes created on NW65 (version 36.01 and version 37.00) - * don't have (VOL_COMP_FLAGS_UPGRADE_START | VOL_COMP_FLAGS_UPGRADE_FINISHED) - * set by default - */ + * don't have (VOL_COMP_FLAGS_UPGRADE_START | VOL_COMP_FLAGS_UPGRADE_FINISHED) + * set by default + */ (void)NSSLOG_EventLogWithVolume( &zVolume->ZLSSVOLvol, ZSTORE_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_MEDIA_UPGRADE, MSGNot("Upgrade from 36.01 to 36.02.") ); @@ -2200,22 +2200,22 @@ BOOL ZLSSVOL_AIPU3601To3602( if (zVolume->ZLSSVOLvol.VOLenabledAttributes & zATTR_COMPRESSION) { - zVolume->ZLSSVOLvol.VOLcompAttributes.compFlags &= + zVolume->ZLSSVOLvol.VOLcompAttributes.compFlags &= ~(VOL_COMP_FLAGS_UPGRADE_START | VOL_COMP_FLAGS_UPGRADE_FINISHED); - + zVolume->ZLSSVOLvol.VOLcompAttributes.compFlags |= VOL_COMP_FLAGS_UPGRADE_START; } else { /* Since COMP is not on volume we MUST mark as done because - * COMN will not. - */ + * COMN will not. + */ zVolume->ZLSSVOLvol.VOLcompAttributes.compFlags |= (VOL_COMP_FLAGS_UPGRADE_START | VOL_COMP_FLAGS_UPGRADE_FINISHED); } ZFSVOL_WritePersistentVolumeData(zVolume); /* Tell common layer that they should upgrade the comp beasts. If - * we crash the common layer also checks bit at activation time. - */ + * we crash the common layer also checks bit at activation time. + */ if (zVolume->ZLSSVOLvol.VOLenabledAttributes & zATTR_COMPRESSION) { CM_StartUpgradeProcess(); @@ -2238,9 +2238,9 @@ BOOL ZLSSVOL_AIPU3602To3603_Ready( NINT version; /* We do not do the POOL version check for 43.00 here - * because to get to volume version 36.02 the pool - * must be at least 43.00. - */ + * because to get to volume version 36.02 the pool + * must be at least 43.00. + */ version = (zVolume->ZLSSVOLmediaFormatMajor*0x100)+zVolume->ZLSSVOLmediaFormatMinor; if ( version == ZLSS_VOLUME_MEDIA_VERSION_3602 ) { /* Correct media type to upgrade */ @@ -2289,14 +2289,14 @@ BOOL ZLSSVOL_AIPU3700To3702( ZfsVolume_s *zVolume ) { /* We do not do the POOL version check for 43.00 here - * because to get to volume version 37.00 the pool - * must be at least 43.00. - */ + * because to get to volume version 37.00 the pool + * must be at least 43.00. + */ /* defect 373025: new volumes created on NW65 (version 36.01 and version 37.00) - * won't have (VOL_COMP_FLAGS_UPGRADE_START | VOL_COMP_FLAGS_UPGRADE_FINISHED) - * set by default - */ + * won't have (VOL_COMP_FLAGS_UPGRADE_START | VOL_COMP_FLAGS_UPGRADE_FINISHED) + * set by default + */ (void)NSSLOG_EventLogWithVolume( &zVolume->ZLSSVOLvol, ZSTORE_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_MEDIA_UPGRADE, MSGNot("Upgrade from 37.00 to 37.02.") ); @@ -2305,22 +2305,22 @@ BOOL ZLSSVOL_AIPU3700To3702( if (zVolume->ZLSSVOLvol.VOLenabledAttributes & zATTR_COMPRESSION) { - zVolume->ZLSSVOLvol.VOLcompAttributes.compFlags &= + zVolume->ZLSSVOLvol.VOLcompAttributes.compFlags &= ~(VOL_COMP_FLAGS_UPGRADE_START | VOL_COMP_FLAGS_UPGRADE_FINISHED); - + zVolume->ZLSSVOLvol.VOLcompAttributes.compFlags |= VOL_COMP_FLAGS_UPGRADE_START; } else { /* Since COMP is not on volume we MUST mark as done because - * COMN will not. - */ + * COMN will not. + */ zVolume->ZLSSVOLvol.VOLcompAttributes.compFlags |= (VOL_COMP_FLAGS_UPGRADE_START | VOL_COMP_FLAGS_UPGRADE_FINISHED); } ZFSVOL_WritePersistentVolumeData(zVolume); /* Tell common layer that they should upgrade the comp beasts. If - * we crash the common layer also checks bit at activation time. - */ + * we crash the common layer also checks bit at activation time. + */ if (zVolume->ZLSSVOLvol.VOLenabledAttributes & zATTR_COMPRESSION) { CM_StartUpgradeProcess(); @@ -2343,9 +2343,9 @@ BOOL ZLSSVOL_AIPU3702To3703_Ready( NINT version; /* We do not do the POOL version check for 43.00 here - * because to get to volume version 37.02 the pool - * must be at least 43.00. - */ + * because to get to volume version 37.02 the pool + * must be at least 43.00. + */ version = (zVolume->ZLSSVOLmediaFormatMajor*0x100)+zVolume->ZLSSVOLmediaFormatMinor; if ( version == ZLSS_VOLUME_MEDIA_VERSION_3702 ) { /* Correct media type to upgrade */ @@ -2437,9 +2437,9 @@ STATUS ZFSPOOL_AIPU4085_4086_4087_4088To4300( if ( zlssPool->ZP_Version < ZLSS_MEDIA_VERSION_4085 ) { /* Media must be at least 40.85 to allow for 'quick' - * upgrade. 40.85 means that clustering has given - * NSS permission to fully upgrade. - */ + * upgrade. 40.85 means that clustering has given + * NSS permission to fully upgrade. + */ SetErrno( genMsg, zERR_NOT_SUPPORTED ); return( zFAILURE ); } @@ -2531,7 +2531,7 @@ BOOL ZFSPOOL_AIPU4301To4302_Ready( return( FALSE ); } - X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); /* Do the _IV_ first */ completed = ZLSS_VolumeUpgradedToNakoma( ZFS_POOL_TO_ZLSS_VOLUME( zfsPool ) ); if ( !completed ) @@ -2547,14 +2547,14 @@ BOOL ZFSPOOL_AIPU4301To4302_Ready( ++notUpgraded; } } - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); if ( notUpgraded > 0 ) { return( FALSE ); } return( TRUE ); - + } /* End of ZFSPOOL_AIPU4301To4302_Ready() */ @@ -2621,8 +2621,8 @@ BOOL ZLSS_AIPUNakomaVolume_Ready( version = (zVolume->ZLSSVOLmediaFormatMajor*0x100)+zVolume->ZLSSVOLmediaFormatMinor; if ( version == ZLSS_VOLUME_MEDIA_VERSION_0000 ) { /* 6Pack internal volumes do not have a version number. This - * is a bug in ZLSS in NetWare 6.0. - */ + * is a bug in ZLSS in NetWare 6.0. + */ return( TRUE ); } if ( version < ZLSS_VOLUME_MEDIA_VERSION_3500 ) @@ -2634,7 +2634,7 @@ BOOL ZLSS_AIPUNakomaVolume_Ready( return( FALSE ); } if ( version < ZLSS_VOLUME_MEDIA_VERSION_3700 - && version >= ZLSS_VOLUME_MEDIA_VERSION_3603 ) + && version >= ZLSS_VOLUME_MEDIA_VERSION_3603 ) { /* Volume already upgraded */ return( FALSE ); } @@ -2678,8 +2678,8 @@ STATUS ZLSS_AIPUNakomaVolume( switch ( version ) { case ZLSS_VOLUME_MEDIA_VERSION_0000: /* The IVs of pools generated under NetWare 6.0 - * have media versions of 0.0 (this is a bug). - */ + * have media versions of 0.0 (this is a bug). + */ if ( !ZLSSVOL_AIPU0000To3500_Ready( zVolume ) ) { return( zOK ); @@ -2737,7 +2737,7 @@ STATUS ZLSS_AIPUNakomaVolume( } version = (zVolume->ZLSSVOLmediaFormatMajor*0x100)+zVolume->ZLSSVOLmediaFormatMinor; zASSERT( version == ZLSS_VOLUME_MEDIA_VERSION_3603 ); -#ifdef ZLSS_VOLUME_MEDIA_VERSION_3604 +#ifdef ZLSS_VOLUME_MEDIA_VERSION_3604 #error If 36.04 is added, need to add a line "goto ZLSS_VOLUME_MEDIA_VERSION_3604" #endif return( zOK ); @@ -2763,7 +2763,7 @@ STATUS ZLSS_AIPUNakomaVolume( } version = (zVolume->ZLSSVOLmediaFormatMajor*0x100)+zVolume->ZLSSVOLmediaFormatMinor; zASSERT( version == ZLSS_VOLUME_MEDIA_VERSION_3603 ); -#ifdef ZLSS_VOLUME_MEDIA_VERSION_3604 +#ifdef ZLSS_VOLUME_MEDIA_VERSION_3604 #error If 36.04 is added, need to add a "goto ZLSS_VOLUME_MEDIA_VERSION_3604" or drop through #endif return( zOK ); @@ -2948,7 +2948,7 @@ STATUS ZLSS_AIPUNakomaPool( /*** Drop through ***/ /*** Drop through ***/ case ZLSS_MEDIA_VERSION_4085: - if ( !ZFSPOOL_AIPU4085To4086_Ready( zlssPool ) ) + if ( !ZFSPOOL_AIPU4085To4086_Ready( zlssPool ) ) { return( zOK ); } @@ -3064,15 +3064,15 @@ typedef struct ZLSS_AIPUNakomaUpgrade_s BOOL ZANU_threadRunning; BOOL ZANU_sleeping; NINT ZANU_newRequest; /* Number of callers that requested - * a volume or pool to be upgraded - * while the upgrade thread was running. - * Used to ensure that upgrade thread - * does not terminate before all - * requests are handled. - */ + * a volume or pool to be upgraded + * while the upgrade thread was running. + * Used to ensure that upgrade thread + * does not terminate before all + * requests are handled. + */ OneShot_s ZANU_alarm; -} ZLSS_AIPUNakomaUpgrade_s; - +} ZLSS_AIPUNakomaUpgrade_s; + ZLSS_AIPUNakomaUpgrade_s ZLSS_AIPUThread; /*************************************************************************** @@ -3100,7 +3100,7 @@ void ZLSS_UpgradeTimedOut( } /*************************************************************************** - * This function puts the Upgrader to sleep for the specified number of + * This function puts the Upgrader to sleep for the specified number of * seconds. ***************************************************************************/ void ZLSS_UpgradeSleep( @@ -3125,8 +3125,8 @@ void ZLSS_UpgradeShutdownNakoma() } ZLSS_AIPUThread.ZANU_shutdownRequested = TRUE; /* Just in case it is sleeping wake it up so - * it will see our request. - */ + * it will see our request. + */ ZLSS_UpgradeWakeup(); for ( ;; ) { @@ -3234,24 +3234,24 @@ void *ZLSS_AIPUNakomaUpgradeThread( THREAD notUsed1, void *notUsed2 ) for (;;) { /*** - *** - *** Run through all the ZLSS pools to see if one is ready - *** to upgrade. - *** - ***/ + *** + *** Run through all the ZLSS pools to see if one is ready + *** to upgrade. + *** + ***/ poolsToUpgrade = 0; SET_FOREACHBLOCKING( &NSSMasterPoolList, pool, Pool_s, masterPoolLink ) { /*** You MUST NOT use continue in this loop because the macro - *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called - *** every time through the loop. Technically, you - *** can use a continue BEFORE any blocking calls. - ***/ + *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called + *** every time through the loop. Technically, you + *** can use a continue BEFORE any blocking calls. + ***/ COMN_USE_BEAST( &pool->POOLroot ); - if ( COMN_IsDerivedFrom(pool, zFTYPE_ZLSS_LOGICAL_POOL) ) - { /* Is ZLSS pool */ - if ( COMN_PoolActiveLock( &dummyGenMsg, pool ) == zOK ) - { /* Is ACTIVE */ + if ( COMN_IsDerivedFrom(pool, zFTYPE_ZLSS_LOGICAL_POOL) ) + { /* Is ZLSS pool */ + if ( COMN_PoolActiveLock( &dummyGenMsg, pool ) == zOK ) + { /* Is ACTIVE */ zlssPool = (ZlssPool_s *)pool; if ( ZLSS_AIPUNakomaPool_Ready( zlssPool ) ) { /* Pool meets all requirements */ @@ -3267,13 +3267,13 @@ void *ZLSS_AIPUNakomaUpgradeThread( THREAD notUsed1, void *notUsed2 ) poolsToUpgrade += 1; } } - COMN_PoolActiveUnlock(pool); + COMN_PoolActiveUnlock(pool); } else { ClearErrno(&dummyGenMsg); } - } + } COMN_Release( &pool ); if ( ZLSS_AIPUThread.ZANU_shutdownRequested ) @@ -3284,29 +3284,29 @@ void *ZLSS_AIPUNakomaUpgradeThread( THREAD notUsed1, void *notUsed2 ) MPKNSS_UNLOCK(); return NULL; } - SET_FOREACHBLOCKINGEND(&NSSMasterPoolList, pool, Pool_s, + SET_FOREACHBLOCKINGEND(&NSSMasterPoolList, pool, Pool_s, masterPoolLink); } /*** - *** - *** Run through all the ZLSS volumes to see if one is ready - *** to upgrade. - *** - ***/ + *** + *** Run through all the ZLSS volumes to see if one is ready + *** to upgrade. + *** + ***/ volumesToUpgrade = 0; SET_FOREACHBLOCKING( &NSSMasterPoolList, pool, Pool_s, masterPoolLink ) { /*** You MUST NOT use continue in this loop because the macro - *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called - *** every time through the loop. Technically, you - *** can use a continue BEFORE any blocking calls. - ***/ + *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called + *** every time through the loop. Technically, you + *** can use a continue BEFORE any blocking calls. + ***/ COMN_USE_BEAST( &pool->POOLroot ); - if ( COMN_IsDerivedFrom(pool, zFTYPE_ZLSS_LOGICAL_POOL) ) - { /* Is ZLSS pool */ - if ( COMN_PoolActiveLock( &dummyGenMsg, pool ) == zOK ) - { /* Is ACTIVE */ + if ( COMN_IsDerivedFrom(pool, zFTYPE_ZLSS_LOGICAL_POOL) ) + { /* Is ZLSS pool */ + if ( COMN_PoolActiveLock( &dummyGenMsg, pool ) == zOK ) + { /* Is ACTIVE */ zlssPool = (ZlssPool_s *)pool; zfsPool = zlssPool->ZLSSPOOLzfsPool; if ( zfsPool != NULL ) @@ -3314,9 +3314,9 @@ void *ZLSS_AIPUNakomaUpgradeThread( THREAD notUsed1, void *notUsed2 ) Volume_s *volume; /* Hurry any ACTIVE volumes to 36.00 format, other - * volumes will be done when they activate. - */ - X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + * volumes will be done when they activate. + */ + X_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); /* Do the _IV_ first */ completed = ZLSS_UpgradeAVolume( &dummyGenMsg, ZFS_POOL_TO_VOLUME( zfsPool ) ); if ( !completed ) @@ -3325,10 +3325,10 @@ void *ZLSS_AIPUNakomaUpgradeThread( THREAD notUsed1, void *notUsed2 ) } POOL_FOR_EACH_LOADED_VOLUME( zfsPool->ZFSPOOLvol.v_pool, volume ) { /* Skip hidden volumes (which in ZLSS our deleted volumes). - * If the user undeletes the volume then it will be - * upgraded. We do not upgrade deleted volumes as they - * may be 1/2 through purge. - */ + * If the user undeletes the volume then it will be + * upgraded. We do not upgrade deleted volumes as they + * may be 1/2 through purge. + */ if ( !VOL_ACCESSIBLE1(volume) ) { continue; @@ -3339,15 +3339,15 @@ void *ZLSS_AIPUNakomaUpgradeThread( THREAD notUsed1, void *notUsed2 ) volumesToUpgrade += 1; } } - UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); + UNX_LATCH( &zlssPool->ZLSSPOOLpool.cvsLatch ); } - COMN_PoolActiveUnlock(pool); + COMN_PoolActiveUnlock(pool); } else { ClearErrno(&dummyGenMsg); } - } + } COMN_Release( &pool ); if ( ZLSS_AIPUThread.ZANU_shutdownRequested ) @@ -3358,7 +3358,7 @@ void *ZLSS_AIPUNakomaUpgradeThread( THREAD notUsed1, void *notUsed2 ) MPKNSS_UNLOCK(); return NULL; } - SET_FOREACHBLOCKINGEND(&NSSMasterPoolList, pool, Pool_s, + SET_FOREACHBLOCKINGEND(&NSSMasterPoolList, pool, Pool_s, masterPoolLink); } @@ -3390,10 +3390,10 @@ void *ZLSS_AIPUNakomaUpgradeThread( THREAD notUsed1, void *notUsed2 ) if ( ZLSS_AIPUThread.ZANU_newRequest > 0 ) { /* If someone requested us to upgrade volume/pool then make sure - * that the pool/volume has time to activate. Also because the - * request may have came in after we looped past volume/pool on master - * list we need to ignore xxxToUpgrade counts. - */ + * that the pool/volume has time to activate. Also because the + * request may have came in after we looped past volume/pool on master + * list we need to ignore xxxToUpgrade counts. + */ ZLSS_AIPUThread.ZANU_newRequest = 0; ZLSS_UpgradeSleep( 1*60 ); /* Give pool/volume time to complete activation */ /* See if we came out of our sleep early to terminate. */ @@ -3445,7 +3445,7 @@ void ZLSS_UpgradeStartupNakoma() ZLSS_AIPUThread.ZANU_threadRunning = TRUE; ZLSS_AIPUThread.ZANU_newRequest = 0; INIT_ONESHOT( ZLSS_AIPUThread.ZANU_alarm ); - + #if zNETWARE ZOS_StartThreadWithModuleHandle( ZLSS_AIPUThread.ZANU_threadID, "ZLSS Media Upgrade", @@ -3456,7 +3456,7 @@ void ZLSS_UpgradeStartupNakoma() #if zLINUX ZOS_StartThread( ZLSS_AIPUThread.ZANU_threadID, "ZLSS Media Upgrade", - ZLSS_AIPUNakomaUpgradeThread, + ZLSS_AIPUNakomaUpgradeThread, 0, 0, NULL); #endif @@ -3487,7 +3487,7 @@ typedef struct HLUpgrade_s BOOL volumeScan; } HLUpgrade_s; - + HLUpgrade_s HL_Upgrade = {0}; @@ -3512,12 +3512,12 @@ HL_latchList_s *HL_CreateParentsLatchList(NamedBeast_s *beast, HL_latchList_s ** elem = zalloc(sizeof(HL_latchList_s) * numElems); if (elem != NULL) - { + { elem[i].zid = beast->NAMEDzid; ASSERT_XLATCH(&beast->NAMEDbeastLatch); elem[i].latched = TRUE; elem[i++].bst = beast; - elem[i++].zid = beast->NAMEDfirstParentZid; + elem[i++].zid = beast->NAMEDfirstParentZid; DQ_FOREACH(&beast->reserved, lpentry, LinkedParentEntry_s, plink) { for(j=0; ((jpentry.p.zid)); j++); @@ -3582,7 +3582,7 @@ STATUS HL_UpgradeBeast(GeneralMsg_s *genMsg, NamedBeast_s *beast) beast->NAMEDbstState |= BST_STATE_RENAMING; -/* go create a list of all the parent zids we need, plus ourself*/ +/* go create a list of all the parent zids we need, plus ourself*/ if((latchList = HL_CreateParentsLatchList(beast, &nextEntry)) == NULL) { SetErrno( genMsg, zERR_NO_MEMORY ); @@ -3596,9 +3596,9 @@ STATUS HL_UpgradeBeast(GeneralMsg_s *genMsg, NamedBeast_s *beast) if(latchList[i].bst == NULL) { if((latchList[i].bst = COMN_LookupByZid(genMsg, - beast->NAMEDvolume, - latchList[i].zid, - NOTLATCHED, TRUE)) == NULL) + beast->NAMEDvolume, + latchList[i].zid, + NOTLATCHED, TRUE)) == NULL) { zASSERT("Invalid parent zid not found on COMN_LookkupByZid during HL_UpgradeBeast" == 0); goto cleanup1; @@ -3646,7 +3646,7 @@ STATUS HL_UpgradeBeast(GeneralMsg_s *genMsg, NamedBeast_s *beast) /* Below here, we have a list of control structures. If the pointer is present, it points to - a beast. If the latched flag is true, we have latched this beast. Last entry has a zid and bst of 0; */ + a beast. If the latched flag is true, we have latched this beast. Last entry has a zid and bst of 0; */ xaction = COMN_BeginXLocal(beast); /* we're about to start modifying stuff. Xlocal the whole bunch of them */ @@ -3655,7 +3655,7 @@ STATUS HL_UpgradeBeast(GeneralMsg_s *genMsg, NamedBeast_s *beast) { COMN_MARK_BEAST_XLOCAL((RootBeast_s*)latchList[i].bst, xaction); } - + /* now start moving names */ for (;;) /* for each OtherParent entry */ { @@ -3666,11 +3666,11 @@ STATUS HL_UpgradeBeast(GeneralMsg_s *genMsg, NamedBeast_s *beast) } pentry = &lpentry->pentry; - + hlBeast = HL_doCreateHardLinkBeast(genMsg, beast, NULL, pentry, xaction); if(hlBeast == NULL) COMN_AbortXLocal(genMsg,beast->NAMEDvolume,xaction, WHERE); - + free(lpentry); pentry = &hlBeast->HARDLfirstParent; @@ -3683,7 +3683,7 @@ STATUS HL_UpgradeBeast(GeneralMsg_s *genMsg, NamedBeast_s *beast) COMN_MARK_BEAST_XLOCAL((RootBeast_s*)hlBeast, xaction); removeNameFlags = NF_FIRST_NAME; - DQ_FOREACH(&pentry->names, nentry, LinkedNameEntry_s, nlink) + DQ_FOREACH(&pentry->names, nentry, LinkedNameEntry_s, nlink) { if(DQ_ISHEADNEXT(&pentry->names, nentry, LinkedNameEntry_s, nlink)) removeNameFlags |= NF_LAST_NAME; @@ -3705,7 +3705,7 @@ STATUS HL_UpgradeBeast(GeneralMsg_s *genMsg, NamedBeast_s *beast) } if(beast->NAMEDcomnOps.BST_removeNameFromDirectory(genMsg, beast->NAMEDzid, parentDir, - nentry->p.nameSpaceMask, pentry->p.nameType, nentry->p.name, + nentry->p.nameSpaceMask, pentry->p.nameType, nentry->p.name, removeNameFlags, xaction, pentry->t) != zOK) { zASSERT("Error removing name from directory in HardLInk upgrade. Now what?" == NULL); @@ -3713,7 +3713,7 @@ STATUS HL_UpgradeBeast(GeneralMsg_s *genMsg, NamedBeast_s *beast) } - if (beast->NAMEDcomnOps.BST_addNameToDirectory(genMsg, (NamedBeast_s*)hlBeast, parentDir, + if (beast->NAMEDcomnOps.BST_addNameToDirectory(genMsg, (NamedBeast_s*)hlBeast, parentDir, nentry->p.nameSpaceMask, pentry->p.nameType, nentry->p.name, nsFlag, removeNameFlags, MA_ATTR_SET_MASK(beast->NAMEDattributes), xaction, pentry->t) != zOK) { @@ -3798,7 +3798,7 @@ STATUS HL_UpgradeBeast(GeneralMsg_s *genMsg, NamedBeast_s *beast) COMN_AbortXLocal(genMsg,beast->NAMEDvolume,xaction, WHERE); } - if (beast->NAMEDcomnOps.BST_addNameToDirectory(genMsg, (NamedBeast_s*)hlBeast, parentDir, + if (beast->NAMEDcomnOps.BST_addNameToDirectory(genMsg, (NamedBeast_s*)hlBeast, parentDir, nentry->p.nameSpaceMask, pentry->p.nameType, nentry->p.name, nsFlag, removeNameFlags, MA_ATTR_SET_MASK(beast->NAMEDattributes), xaction, pentry->t) != zOK) { @@ -3912,9 +3912,9 @@ STATUS HLUpgradeOnVolume(GeneralMsg_s *genMsg, Volume_s *volume) { Zid_t beastZids[MAX_ZIDS_PER_SCOOP]; Zid_t lastZidReturned; - RootBeast_s *beast = NULL; + RootBeast_s *beast = NULL; NINT i; - NINT numBeastsReturned; + NINT numBeastsReturned; BOOL markVolumeDone = TRUE; STATUS status; STATUS saveStatus = zOK; @@ -3933,16 +3933,16 @@ STATUS HLUpgradeOnVolume(GeneralMsg_s *genMsg, Volume_s *volume) return zFAILURE; } - + if((volume->VOLmediaFormatMajor == ZLSS_LV_MEDIA_MAJOR_NAKOMA) && // if 36, it must be completed - (volume->VOLmediaFormatMinor != ZLSS_LV_MEDIA_MINOR_NAKOMA_COMP)) + (volume->VOLmediaFormatMinor != ZLSS_LV_MEDIA_MINOR_NAKOMA_COMP)) { SetErrno( genMsg, zERR_ZLSSPOOL_UPGRADE_POOL_FIRST ); return zFAILURE; } if((volume->VOLmediaFormatMajor == ZLSS_LV_MEDIA_MAJOR_NAKOMA_ENCRYPTED) && // if 37, it must be completed - (volume->VOLmediaFormatMinor != ZLSS_LV_MEDIA_MINOR_NAKOMA_ENCRYPTED_COMP)) + (volume->VOLmediaFormatMinor != ZLSS_LV_MEDIA_MINOR_NAKOMA_ENCRYPTED_COMP)) { SetErrno( genMsg, zERR_ZLSSPOOL_UPGRADE_POOL_FIRST ); return zFAILURE; @@ -3952,8 +3952,8 @@ STATUS HLUpgradeOnVolume(GeneralMsg_s *genMsg, Volume_s *volume) { return zOK; } - - if((volume->VOLmediaFormatMajor == ZLSS_LV_MEDIA_MAJOR_NAKOMA_HARDLINK) && + + if((volume->VOLmediaFormatMajor == ZLSS_LV_MEDIA_MAJOR_NAKOMA_HARDLINK) && (volume->VOLmediaFormatMinor >= ZLSS_LV_MEDIA_MINOR_NAKOMA_HARDLINK_DONE)) { return zOK; @@ -3973,15 +3973,15 @@ STATUS HLUpgradeOnVolume(GeneralMsg_s *genMsg, Volume_s *volume) volume->VOLbeastVersion = volume->VOLroot.beastVersion = BEAST_VERSION_3; volume->VOLmediaFormatMajor = ZLSS_LV_MEDIA_MAJOR_NAKOMA_HARDLINK; volume->VOLmediaFormatMinor = ZLSS_LV_MEDIA_MINOR_NAKOMA_HARDLINK_START; // starting the upgrade - + if ( COMN_IsDerivedFrom(volume, zFTYPE_ZLSS_ZFSPOOL) ) { ZfsPool_s *zfsPool = (ZfsPool_s *)volume; /* The Journal (zfsLogBeast(Zid 3)) is not stored in the beast tree. Just slam - * the BV to 3 and when the journal is packed during taking a checkpoint it - * will become persistent. We know checkpoints will occur because - * we are going to COMN_MARK_BEAST_XLOCAL our other BV 3 changes below. - */ + * the BV to 3 and when the journal is packed during taking a checkpoint it + * will become persistent. We know checkpoints will occur because + * we are going to COMN_MARK_BEAST_XLOCAL our other BV 3 changes below. + */ beast = (RootBeast_s*)zfsPool->zfsLogBeast; if ( beast != NULL ) { @@ -3999,7 +3999,7 @@ STATUS HLUpgradeOnVolume(GeneralMsg_s *genMsg, Volume_s *volume) { if(sysZid != 3) { - if((beast = BEASTHASH_LookupByZid(genMsg, volume, sysZid, XLATCHED)) != NULL) + if((beast = BEASTHASH_LookupByZid(genMsg, volume, sysZid, XLATCHED)) != NULL) { xaction = COMN_BeginXLocal(beast); COMN_MARK_BEAST_XLOCAL(beast, xaction); @@ -4021,8 +4021,8 @@ STATUS HLUpgradeOnVolume(GeneralMsg_s *genMsg, Volume_s *volume) do { /* Obtain a scoop of ZIDs to examine */ - if (volume->VOLcomnVolOps.VOL_browseBeastsInVolume(genMsg, volume, - SELECT_BEASTS_ALL, MAX_ZIDS_PER_SCOOP, + if (volume->VOLcomnVolOps.VOL_browseBeastsInVolume(genMsg, volume, + SELECT_BEASTS_ALL, MAX_ZIDS_PER_SCOOP, &lastZidReturned, beastZids, &numBeastsReturned) != zOK) { return zFAILURE; @@ -4031,8 +4031,8 @@ STATUS HLUpgradeOnVolume(GeneralMsg_s *genMsg, Volume_s *volume) /* Process each of the above beasts in turn */ for (i = 0; i < numBeastsReturned; i++) { - if (volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) - { + if (volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) + { /* if volume is deactivating */ (void)NSSLOG_EventLogWithVolume( volume, ZSTORE_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_MEDIA_UPGRADE, MSGNot("Hardlink upgrade deactivation.") ); @@ -4045,14 +4045,14 @@ STATUS HLUpgradeOnVolume(GeneralMsg_s *genMsg, Volume_s *volume) /* Ignore most all errors */ if (beast == NULL) { - ClearErrno(genMsg); + ClearErrno(genMsg); markVolumeDone = FALSE; continue; } if(beast->ROOTbeastVersion >= 3) /* no need to process version 3 beasts */ { - COMN_UnlatchAndRelease(&beast, XLATCHED); + COMN_UnlatchAndRelease(&beast, XLATCHED); continue; } @@ -4061,7 +4061,7 @@ STATUS HLUpgradeOnVolume(GeneralMsg_s *genMsg, Volume_s *volume) beast->ROOTbeastVersion = volume->VOLroot.beastVersion; COMN_MARK_BEAST_DIRTY(beast); } - + if((!COMN_IsDerivedFrom(beast, zFTYPE_FILE)) || /* only look at file beasts */ (((NamedBeast_s *)beast)->NAMEDnumParents <= 1)) /* only look at beasts with multiple parents, i.e. old hardlinks */ { @@ -4071,9 +4071,9 @@ STATUS HLUpgradeOnVolume(GeneralMsg_s *genMsg, Volume_s *volume) } /* We now have a latched primary beast. Go through the list of other parents here and create a hardlink beast - * for each. We eventually need three beasts latched, the original beast, the parent directory beast, - * and the new hardlink beast. For deadlock prevention the order MUST BE parent directory, then beast, - * then HardLink. To do this we may have to do considerable hand waving. */ + * for each. We eventually need three beasts latched, the original beast, the parent directory beast, + * and the new hardlink beast. For deadlock prevention the order MUST BE parent directory, then beast, + * then HardLink. To do this we may have to do considerable hand waving. */ /* we are going to modify the primary beast, and add one or more hardlink beasts. Start a transaction */ status = HL_UpgradeBeast(genMsg, (NamedBeast_s*)beast); @@ -4084,14 +4084,14 @@ STATUS HLUpgradeOnVolume(GeneralMsg_s *genMsg, Volume_s *volume) } else { - markVolumeDone = FALSE; + markVolumeDone = FALSE; } - + } /* for each zid) */ PERIODIC_YIELD(); } while(numBeastsReturned > 0); /* for each group of zids */ - + /* all beasts on this volume has been upgraded */ if (markVolumeDone) { @@ -4100,7 +4100,7 @@ STATUS HLUpgradeOnVolume(GeneralMsg_s *genMsg, Volume_s *volume) #error "Check to see if the beastVersion code below is still needed." #endif - volume->VOLmediaFormatMinor = ZLSS_LV_MEDIA_MINOR_NAKOMA_HARDLINK_DONE; // finished with the upgrade + volume->VOLmediaFormatMinor = ZLSS_LV_MEDIA_MINOR_NAKOMA_HARDLINK_DONE; // finished with the upgrade volume->VOLbeastVersionMask = (1<<(BEAST_VERSION_3-1)); // we are version 3 beasts now status = VOL_FlushVolume(genMsg, volume); if (status != zOK) @@ -4125,8 +4125,8 @@ STATUS HLUpgradeOnVolume(GeneralMsg_s *genMsg, Volume_s *volume) } else { /* Got an error converting at least one hardlink - * object so will have to retry later. - */ + * object so will have to retry later. + */ volume->VOLcomnVolOps.VOL_flushSystemBeasts(genMsg, volume); (void)NSSLOG_EventLogWithVolume( volume, ZSTORE_ModuleHandle, WHERE, LOG_WARNING, NSSLOG_TYPE_MEDIA_UPGRADE, MSGNot("Hardlink volume upgrade failed.") ); @@ -4149,11 +4149,11 @@ BOOL HL_ClusterApprovesUpgrade() safe = mNWCLSTR_SafeToUpgradeFS( MSGNot("OES-SP1") ); MPKNSS_LOCK(); ZOS_UnImportPublicSymbol( (LONG)ZSTORE_ModuleHandle, (BYTE *)MSGNot("\x17" "NWCLSTR_SafeToUpgradeFS") ); - } + } else { - safe = FALSE; - } + safe = FALSE; + } return safe; } @@ -4172,7 +4172,7 @@ void HL_UpgradeThread( MPKNSS_LOCK(); HL_Upgrade.threadRunning = TRUE; - + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); /* allow as many specified single volume upgrades to proceed as are requested */ @@ -4194,7 +4194,7 @@ void HL_UpgradeThread( else { aprintf( LGREEN, MSG("VolumeMediaFormat upgrade for volume \"%U\" succeeded.\n", 622),vname ); - + } } else @@ -4221,10 +4221,10 @@ void HL_UpgradeThread( SET_FOREACHBLOCKING(&NSSMasterVolumeList, vol, Volume_s, masterVolLink) { /*** You MUST NOT use continue in this loop because the macro - *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called - *** every time through the loop. Technically, you - *** can use a continue BEFORE any blocking calls. - ***/ + *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called + *** every time through the loop. Technically, you + *** can use a continue BEFORE any blocking calls. + ***/ if(vol->state == zVOLSTATE_ACTIVE) { @@ -4238,13 +4238,13 @@ void HL_UpgradeThread( } else if((HL_Upgrade.shareFlags & COMN_IT_LOCAL) && !(pool->POOLenabledFeatures & zPOOL_FEATURE_SHARED_CLUSTER)) { - safeToUpgradeVol = TRUE; + safeToUpgradeVol = TRUE; } } else if(HL_Upgrade.shareFlags & COMN_IT_LOCAL) // if there is no pool, by definition the volume must be local { - safeToUpgradeVol = TRUE; - } + safeToUpgradeVol = TRUE; + } @@ -4265,13 +4265,13 @@ void HL_UpgradeThread( else { aprintf( LGREEN, MSGNot("VolumeMediaFormat upgrade for volume \"%U\" succeeded.\n"),vname ); - + } } COMN_UnlockVolumeActive(vol, FALSE); } - COMN_Release(&vol); - } + COMN_Release(&vol); + } } SET_FOREACHBLOCKINGEND(&NSSMasterVolumeList, vol, Volume_s, masterVolLink); } @@ -4283,7 +4283,7 @@ void HL_UpgradeThread( return; } - + /************************************************************************************ * This function schedules a background thread to check and upgrade compressed beast* * from RootBeast_s type to CompBeast_s type * @@ -4296,7 +4296,7 @@ void HL_StartUpgradeProcess(Volume_s *vol, NINT shareFlags) HL_Upgrade.threadRestart = TRUE; // request a restart if there is already a pool scan in progress HL_Upgrade.shareFlags = shareFlags; #if zNETWARE - ZOS_StartThreadWithModuleHandle(HL_Upgrade.threadID, "NSS HardLinks Upgrade", + ZOS_StartThreadWithModuleHandle(HL_Upgrade.threadID, "NSS HardLinks Upgrade", HL_UpgradeThread, 0, 0, vol, (LONG)ZSTORE_ModuleHandle); #endif @@ -4319,10 +4319,10 @@ typedef struct HLUpgradeBeastVersion3_s BOOL threadRestart; } HLUpgradeBeastVersion3_s; - + HLUpgradeBeastVersion3_s HL_UpgradeBeast3 = {0}; -/* Beast is already latched and is a version 3 hardlink beast +/* Beast is already latched and is a version 3 hardlink beast 1. unlatch the hardlink 2. lookup and latch the primary 3. If primary has a primary name @@ -4370,7 +4370,7 @@ STATUS HL_UpgradeVersion3Hardlink(GeneralMsg_s *genMsg, HardLinkBeast_s *beast) return zFAILURE; } X_LATCH(&inodeBeast->NAMEDbeastLatch); - + xaction = COMN_BeginXLocal(inodeBeast); COMN_MARK_BEAST_XLOCAL((RootBeast_s*)inodeBeast, xaction); COMN_MARK_BEAST_XLOCAL((RootBeast_s*)parentDir, xaction); @@ -4384,7 +4384,7 @@ STATUS HL_UpgradeVersion3Hardlink(GeneralMsg_s *genMsg, HardLinkBeast_s *beast) removeNameFlags = NF_FIRST_NAME; pentry = &hlBeast->HARDLfirstParent; - DQ_FOREACH(&pentry->names, nentry, LinkedNameEntry_s, nlink) + DQ_FOREACH(&pentry->names, nentry, LinkedNameEntry_s, nlink) { if(DQ_ISHEADNEXT(&pentry->names, nentry, LinkedNameEntry_s, nlink)) removeNameFlags |= NF_LAST_NAME; @@ -4396,14 +4396,14 @@ STATUS HL_UpgradeVersion3Hardlink(GeneralMsg_s *genMsg, HardLinkBeast_s *beast) nentry->p.name, nsFlag); if(((NamedBeast_s*)beast)->NAMEDcomnOps.BST_removeNameFromDirectory(genMsg, inodeBeast->NAMEDzid, parentDir, - nentry->p.nameSpaceMask, pentry->p.nameType, nentry->p.name, + nentry->p.nameSpaceMask, pentry->p.nameType, nentry->p.name, removeNameFlags, xaction, pentry->t) != zOK) { zASSERT("Error removing name from directory in HardLInk upgrade. Now what?" == NULL); COMN_AbortXLocal(genMsg,inodeBeast->NAMEDvolume,xaction, WHERE); } - if (((NamedBeast_s*)beast)->NAMEDcomnOps.BST_addNameToDirectory(genMsg, (NamedBeast_s*)hlBeast, parentDir, + if (((NamedBeast_s*)beast)->NAMEDcomnOps.BST_addNameToDirectory(genMsg, (NamedBeast_s*)hlBeast, parentDir, nentry->p.nameSpaceMask, pentry->p.nameType, nentry->p.name, nsFlag, removeNameFlags, MA_ATTR_SET_MASK(inodeBeast->NAMEDattributes), xaction, pentry->t) != zOK) { @@ -4431,8 +4431,8 @@ STATUS HL_UpgradeVersion3Hardlink(GeneralMsg_s *genMsg, HardLinkBeast_s *beast) { zASSERT("Could not write firstparent during version3 hardlink upgrade. Now what?"==0); COMN_AbortXLocal(genMsg,inodeBeast->NAMEDvolume,xaction, WHERE); - } - + } + COMN_EndXLocal(inodeBeast, &xaction); COMN_UnlatchAndRelease(&parentDir, XLATCHED); // COMN_UnlatchAndRelease(&hlBeast, XLATCHED); // if we already have this, just hang onto it @@ -4470,8 +4470,8 @@ STATUS HL_UpgradeVersion3Hardlink(GeneralMsg_s *genMsg, HardLinkBeast_s *beast) { zASSERT("Could not write hardlinkbeast during version3 hardlink upgrade. Now what?"==0); COMN_AbortXLocal(genMsg,inodeBeast->NAMEDvolume,xaction, WHERE); - } - + } + COMN_EndXLocal(inodeBeast, &xaction); COMN_UnlatchAndRelease(&inodeBeast, XLATCHED); @@ -4489,9 +4489,9 @@ STATUS HLUpgradeVersion3OnVolume( { Zid_t beastZids[MAX_ZIDS_PER_SCOOP]; Zid_t lastZidReturned; - RootBeast_s *beast = NULL; + RootBeast_s *beast = NULL; NINT i; - NINT numBeastsReturned; + NINT numBeastsReturned; BOOL markVolumeDone = TRUE; Zid_t sysZid; NamedBeast_s *namedBeast; @@ -4524,8 +4524,8 @@ STATUS HLUpgradeVersion3OnVolume( volume->VOLmediaFormatMinor = 3; // starting the upgrade, need to use a define here volume->VOLcomnVolOps.VOL_flushSystemBeasts(genMsg, volume); - - + + /* since browseBeastinVolume won't return system beasts, we need to look system beasts up by zid and convert them explicitly */ @@ -4533,7 +4533,7 @@ STATUS HLUpgradeVersion3OnVolume( { if(sysZid != 3) { - if((beast = BEASTHASH_LookupByZid(genMsg, volume, sysZid, XLATCHED)) != NULL) + if((beast = BEASTHASH_LookupByZid(genMsg, volume, sysZid, XLATCHED)) != NULL) { xaction = COMN_BeginXLocal(beast); COMN_MARK_BEAST_XLOCAL(beast, xaction); @@ -4552,33 +4552,33 @@ STATUS HLUpgradeVersion3OnVolume( do { - /* Obtain a scoop of ZIDs to examine */ - if (volume->VOLcomnVolOps.VOL_browseBeastsInVolume(genMsg, volume, - SELECT_BEASTS_ALL, MAX_ZIDS_PER_SCOOP, - &lastZidReturned, beastZids, &numBeastsReturned) != zOK) - { + /* Obtain a scoop of ZIDs to examine */ + if (volume->VOLcomnVolOps.VOL_browseBeastsInVolume(genMsg, volume, + SELECT_BEASTS_ALL, MAX_ZIDS_PER_SCOOP, + &lastZidReturned, beastZids, &numBeastsReturned) != zOK) + { return zFAILURE; - } + } - /* Process each of the above beasts in turn */ - for (i = 0; i < numBeastsReturned; i++) - { - if (volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) - { + /* Process each of the above beasts in turn */ + for (i = 0; i < numBeastsReturned; i++) + { + if (volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) + { /* if volume is deactivating */ (void)NSSLOG_EventLogWithVolume( volume, CMN_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_MEDIA_UPGRADE, MSGNot("Hardlink upgrade deactivation.") ); return zFAILURE; } - /* Obtain the beast */ - beast = COMN_LookupByZid(genMsg, volume, beastZids[i], XLATCHED, TRUE); + /* Obtain the beast */ + beast = COMN_LookupByZid(genMsg, volume, beastZids[i], XLATCHED, TRUE); - /* Ignore most all errors */ - if (beast == NULL) { - ClearErrno(genMsg); + /* Ignore most all errors */ + if (beast == NULL) { + ClearErrno(genMsg); markVolumeDone = FALSE; - continue; + continue; } if((beast->ROOTbeastVersion == BEAST_VERSION_2) || @@ -4599,11 +4599,11 @@ STATUS HLUpgradeVersion3OnVolume( } - COMN_UnlatchAndRelease(&beast, XLATCHED); - } /* for each zid) */ + COMN_UnlatchAndRelease(&beast, XLATCHED); + } /* for each zid) */ PERIODIC_YIELD(); - } while(numBeastsReturned > 0); /* for each group of zids */ + } while(numBeastsReturned > 0); /* for each group of zids */ if(!markVolumeDone) { @@ -4621,11 +4621,11 @@ STATUS HLUpgradeVersion3OnVolume( volume->VOLbeastVersion = volume->VOLroot.beastVersion = BEAST_VERSION_3; // any new beasts that are created are now really threes volume->VOLcomnVolOps.VOL_flushSystemBeasts(genMsg, volume); } - + /* Start of pass2 is marked by a 38.4 in the volume media version */ - + /* since browseBeastinVolume won't return system beasts, we need to look system beasts up by zid and convert them explicitly */ @@ -4633,7 +4633,7 @@ STATUS HLUpgradeVersion3OnVolume( { if(sysZid != 3) { - if((beast = BEASTHASH_LookupByZid(genMsg, volume, sysZid, XLATCHED)) != NULL) + if((beast = BEASTHASH_LookupByZid(genMsg, volume, sysZid, XLATCHED)) != NULL) { xaction = COMN_BeginXLocal(beast); COMN_MARK_BEAST_XLOCAL(beast, xaction); @@ -4649,14 +4649,14 @@ STATUS HLUpgradeVersion3OnVolume( } } } - + lastZidReturned = zINVALID_ZID; do { /* Obtain a scoop of ZIDs to examine */ - if (volume->VOLcomnVolOps.VOL_browseBeastsInVolume(genMsg, volume, - SELECT_BEASTS_ALL, MAX_ZIDS_PER_SCOOP, + if (volume->VOLcomnVolOps.VOL_browseBeastsInVolume(genMsg, volume, + SELECT_BEASTS_ALL, MAX_ZIDS_PER_SCOOP, &lastZidReturned, beastZids, &numBeastsReturned) != zOK) { return zFAILURE; @@ -4665,8 +4665,8 @@ STATUS HLUpgradeVersion3OnVolume( /* Process each of the above beasts in turn */ for (i = 0; i < numBeastsReturned; i++) { - if (volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) - { + if (volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) + { /* if volume is deactivating */ (void)NSSLOG_EventLogWithVolume( volume, CMN_ModuleHandle, WHERE, LOG_INFO, NSSLOG_TYPE_MEDIA_UPGRADE, MSGNot("Hardlink upgrade deactivation.")); @@ -4680,7 +4680,7 @@ STATUS HLUpgradeVersion3OnVolume( /* Ignore most all errors */ if (beast == NULL) { - ClearErrno(genMsg); + ClearErrno(genMsg); markVolumeDone = FALSE; continue; } @@ -4716,24 +4716,24 @@ STATUS HLUpgradeVersion3OnVolume( COMN_MARK_BEAST_DIRTY(beast); status = zOK; } - + COMN_UnlatchAndRelease(&beast, XLATCHED); if(status != zOK) { - markVolumeDone = FALSE; + markVolumeDone = FALSE; } - + } /* for each zid) */ PERIODIC_YIELD(); } while(numBeastsReturned > 0); /* for each group of zids */ - - + + if(markVolumeDone) { /* all beasts on this volume has been upgraded */ - volume->VOLmediaFormatMinor = 5; // finished with the upgrade + volume->VOLmediaFormatMinor = 5; // finished with the upgrade volume->VOLbeastVersionMask = (1<<(BEAST_VERSION_3-1)); // we are version 3 beasts now volume->VOLcomnVolOps.VOL_flushSystemBeasts(genMsg, volume); @@ -4746,7 +4746,7 @@ STATUS HLUpgradeVersion3OnVolume( WHERE, LOG_WARNING, NSSLOG_TYPE_MEDIA_UPGRADE, MSGNot("Hardlink volume upgrade failed.") ); } return zOK; -} +} @@ -4760,7 +4760,7 @@ void *HL_UpgradeBeast3Thread( MPKNSS_LOCK(); - + COMN_SETUP_GENERAL_MSG_NOSA(&genMsg); @@ -4771,34 +4771,34 @@ void *HL_UpgradeBeast3Thread( { /*** You MUST NOT use continue in this loop because the macro - *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called - *** every time through the loop. Technically, you - *** can use a continue BEFORE any blocking calls. - ***/ + *** SET_FOREACHBLOCKINGEND (at end of for loop) must be called + *** every time through the loop. Technically, you + *** can use a continue BEFORE any blocking calls. + ***/ COMN_USE_BEAST(&pool->POOLroot ); - X_LATCH(&pool->cvsLatch ); + X_LATCH(&pool->cvsLatch ); /* The Pool's volume list can not change on us - * even though we are doing blocks and 'pageing' - * as we own the Pool's cvsLatch. - */ + * even though we are doing blocks and 'pageing' + * as we own the Pool's cvsLatch. + */ POOL_FOR_EACH_LOADED_VOLUME( pool, volume ) { COMN_USE_BEAST(&volume->VOLroot); - if ((volume->state == zVOLSTATE_ACTIVE) && - !(volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) && - ((volume->VOLmediaFormatMajor < 38) || + if ((volume->state == zVOLSTATE_ACTIVE) && + !(volume->v_statusFlag & VOL_SF_LEAVING_ACTIVE_STATE_CLEANUP) && + ((volume->VOLmediaFormatMajor < 38) || ((volume->VOLmediaFormatMajor == 38) && (volume->VOLmediaFormatMinor < 5))) ) { - HLUpgradeVersion3OnVolume(&genMsg, volume); + HLUpgradeVersion3OnVolume(&genMsg, volume); } COMN_Release(&volume); } - - - UNX_LATCH(&pool->cvsLatch ); + + + UNX_LATCH(&pool->cvsLatch ); COMN_Release(&pool ); SET_FOREACHBLOCKINGEND(&NSSMasterPoolList, pool, Pool_s, masterPoolLink) } @@ -4817,7 +4817,7 @@ void HL_StartUpgradeVersion3BeastProcess() if(!HL_UpgradeBeast3.threadRunning) { HL_UpgradeBeast3.threadRunning = TRUE; - ZOS_StartThreadWithModuleHandle(HL_UpgradeBeast3.threadID, "NSS HardLinks Upgrade", + ZOS_StartThreadWithModuleHandle(HL_UpgradeBeast3.threadID, "NSS HardLinks Upgrade", HL_UpgradeBeast3Thread, 0, 0, 0, (LONG)CMN_ModuleHandle); } } diff --git a/src/nwnss/zlss/zlssUpgrade.h b/src/nwnss/zlss/zlssUpgrade.h index 5be96ad..c3155c9 100644 --- a/src/nwnss/zlss/zlssUpgrade.h +++ b/src/nwnss/zlss/zlssUpgrade.h @@ -45,40 +45,40 @@ | Global definitions +-------------------------------------------------------------------------*/ - /* - * **** VOLUME verson of media. **** - * - * Media 00.00 - Internal Volumes created in 6Pack FCS, SP1, SP2 - * or SP3. Bug was fixed in Nakoma and 6Pack SP4. The following - * VDB items where not inited correctly in these IVs. - * beastVersionMask Should be 2 was 0. - * beastVersion Should be 2 was 0. - * PV_mediaFormatMajor Should be 35 was 0. - * PV_mediaFormatMajorCreate Should be 35 was 0. - * PV_shredCount Should be 1 was 0. - * - * Media 35.00 - Original LV version. - * - * Media 36.00 - EFL Tree blocks can exist on volume. New COMP beasts - * can exist on volume. - * - * Media 36.01 - No old COMP beasts exist on volume (not true due to a bug). - * + /* + * **** VOLUME verson of media. **** + * + * Media 00.00 - Internal Volumes created in 6Pack FCS, SP1, SP2 + * or SP3. Bug was fixed in Nakoma and 6Pack SP4. The following + * VDB items where not inited correctly in these IVs. + * beastVersionMask Should be 2 was 0. + * beastVersion Should be 2 was 0. + * PV_mediaFormatMajor Should be 35 was 0. + * PV_mediaFormatMajorCreate Should be 35 was 0. + * PV_shredCount Should be 1 was 0. + * + * Media 35.00 - Original LV version. + * + * Media 36.00 - EFL Tree blocks can exist on volume. New COMP beasts + * can exist on volume. + * + * Media 36.01 - No old COMP beasts exist on volume (not true due to a bug). + * * From the end of 2004 (to fix the above bug): - * Media 36.02, 37.02 - Old style COMP beasts may exist on volume. + * Media 36.02, 37.02 - Old style COMP beasts may exist on volume. + * + * Media 36.03, 37.03 (encrypted volume), or 40.03 (auth unix) - + * No old style COMP beasts exist on volume. * - * Media 36.03, 37.03 (encrypted volume), or 40.03 (auth unix) - - * No old style COMP beasts exist on volume. + * **** VOLUME verson of media. **** * - * **** VOLUME verson of media. **** + * **** POOL verson of media. **** * - * **** POOL verson of media. **** + * Media 43.01 - All volumes have upgraded to 36.01, 37.00, 40.00 * - * Media 43.01 - All volumes have upgraded to 36.01, 37.00, 40.00 - * - * Media 43.02 - All volumes have upgraded to 36.03, 37.03, 40.03 - * **** POOL verson of media. **** - */ + * Media 43.02 - All volumes have upgraded to 36.03, 37.03, 40.03 + * **** POOL verson of media. **** + */ #define AIPU_NAKOMA_MEDIA_MAJOR 43 @@ -99,7 +99,7 @@ #define ZLSS_LV_MEDIA_MAJOR_NAKOMA_AUTH_UNIX 40 //#define ZLSS_LV_MEDIA_MINOR_NAKOMA_AUTH_UNIX 00 /* This minor number is never released to public */ -#define ZLSS_LV_MEDIA_MINOR_NAKOMA_AUTH_UNIX_COMP 03 +#define ZLSS_LV_MEDIA_MINOR_NAKOMA_AUTH_UNIX_COMP 03 #define ZLSS_MEDIA_VERSION_4006 0x2806 #define ZLSS_MEDIA_VERSION_4007 0x2807 @@ -158,10 +158,10 @@ #define ZLSS_VOLUME_MEDIA_VERSION_0000 0x0000 /* A bug in NetWare 6.0 ZLSS causes ALL internal - * volumes create by ZLSS to have their version - * inited to 0. Upgraded pools from 5.x do not - * have this bug. - */ + * volumes create by ZLSS to have their version + * inited to 0. Upgraded pools from 5.x do not + * have this bug. + */ #define ZLSS_VOLUME_MEDIA_VERSION_3500 0x2300 #define ZLSS_VOLUME_MEDIA_VERSION_3501 0x2301 #define ZLSS_VOLUME_MEDIA_VERSION_3502 0x2302 @@ -237,13 +237,13 @@ | Function Prototypes needed +-------------------------------------------------------------------------*/ #ifdef NW5X_UPGRADE -extern STATUS ZFSPOOL_AutoInPlaceUpgradeNoXactions( - GeneralMsg_s *genMsg, - ZfsPool_s *pool ); +extern STATUS ZFSPOOL_AutoInPlaceUpgradeNoXactions( + GeneralMsg_s *genMsg, + ZfsPool_s *pool ); #endif -extern STATUS ZFSPOOL_AutoInPlaceUpgrade( - GeneralMsg_s *genMsg, - ZfsPool_s *pool ); +extern STATUS ZFSPOOL_AutoInPlaceUpgrade( + GeneralMsg_s *genMsg, + ZfsPool_s *pool ); STATUS ZFSPOOL_AIPU4008Through4049To4084( GeneralMsg_s *genMsg, ZlssPool_s *zlssPool ); BOOL ZLSS_ClusterReadyForNakoma( ); diff --git a/src/nwnss/zlss/zlssVersion.c b/src/nwnss/zlss/zlssVersion.c index dac1c27..923dc75 100644 --- a/src/nwnss/zlss/zlssVersion.c +++ b/src/nwnss/zlss/zlssVersion.c @@ -36,7 +36,7 @@ +-------------------------------------------------------------------------*/ #include -VersionInformation_s ZSTORE_VersionInfo = +VersionInformation_s ZSTORE_VersionInfo = { ZMAJV, ZMINV, diff --git a/src/nwnss/zlss/zstoreConfig.c b/src/nwnss/zlss/zstoreConfig.c index b8da99b..bd1993d 100644 --- a/src/nwnss/zlss/zstoreConfig.c +++ b/src/nwnss/zlss/zstoreConfig.c @@ -38,12 +38,6 @@ #include "pssmpk.h" #include "zstoreConfig.h" -#ifdef NSS_USERSPACE -void *ZSTORE_ModuleHandle; -#else -void *ZSTORE_ModuleHandle; -#endif - ZstoreConfig_s ZstoreConfig = { // {DEFAULT_NUM_BUFFERS, DEFAULT_NUM_BONDS, DEFAULT_NUM_ASYNCIOS, @@ -61,7 +55,7 @@ ZstoreConfig_s ZstoreConfig = void ZstoreConfigStartup(void) { ASSERT_MPKNSS_LOCK(); - + ZstoreConfig.tick.xaction = SEC2TICK(ZstoreConfig.sec.xaction); ZstoreConfig.tick.chkpt = SEC2TICK(ZstoreConfig.sec.chkpt); } diff --git a/src/nwnss/zlss/zstoreConfig.h b/src/nwnss/zlss/zstoreConfig.h index c43bec5..b9133f3 100644 --- a/src/nwnss/zlss/zstoreConfig.h +++ b/src/nwnss/zlss/zstoreConfig.h @@ -45,7 +45,7 @@ /** Set Minimum value to zero if the variable can be set to zero **/ /* Range definitions*/ -//#define MIN_NUM_BUFFERS 8 +//#define MIN_NUM_BUFFERS 8 //#define MAX_NUM_BUFFERS 262144 // //#define MIN_NUM_ASYNCIOS 4 @@ -70,20 +70,20 @@ //#define MAX_SEC 1000 // //#define MIN_WORK_LIMIT 5 -//#define MAX_WORK_LIMIT 100 +//#define MAX_WORK_LIMIT 100 // //#define MIN_NUM_XACTIONS 4 //#define MAX_NUM_XACTIONS 65536 // //#define MIN_NUM_XDELETES 4 //#define MAX_NUM_XDELETES 65536 -// +// // //#if NSS_DEBUG IS_ENABLED /* debug default values*/ //#define DEFAULT_NUM_BONDS 5000 /*(2 * DEFAULT_NUM_BUFFERS)*/ //#define DEFAULT_NUM_BUFFERS 1024 //#define DEFAULT_NUM_ASYNCIOS 2048 -//#define DEFAULT_NUM_DELAYED_BEASTS 40 +//#define DEFAULT_NUM_DELAYED_BEASTS 40 //#define DEFAULT_CACHE_HASH_SHIFT 10 //#define DEFAULT_NOT_IN_USE_BEASTS 256 //#define DEFAULT_BEAST_HASH_SHIFT 10 @@ -141,33 +141,33 @@ typedef struct ZstoreConfig_s // NINT hashSize; // NINT hashMask; // } bst; - struct zSec_s - { + struct zSec_s + { // NINT beast; - NINT xaction; - NINT chkpt; + NINT xaction; + NINT chkpt; // NINT buffer; - } sec; + } sec; // struct Msec_s // { // NINT workWait; // } msec_s; - struct zTick_s - { + struct zTick_s + { // NINT beast; - NINT xaction; - NINT chkpt; + NINT xaction; + NINT chkpt; // NINT buffer; - } tick; - struct zXact_s - { - NINT numDelayed; - } xact; - struct zZfs_s - { - NINT numXactions; - NINT numXdeletes; - } zfs; + } tick; + struct zXact_s + { + NINT numDelayed; + } xact; + struct zZfs_s + { + NINT numXactions; + NINT numXdeletes; + } zfs; } ZstoreConfig_s; extern ZstoreConfig_s ZstoreConfig;