Ejemplo n.º 1
0
        public unsafe static byte[] GetSha1(byte[] path)
        {
            var ps    = PenguinSanitizer.Extensions.ToBytePtr(path);
            var newFd = LibC.open(ps, LibC.O_RDONLY);

            // Tap the stream so we can get a hash on it.

            var hash = HashAlgorithm.Create("SHA1");

            var buf = new Byte[32 * 1024 * 1024];

            while (true)
            {
                ssize_t rd = 0;
                fixed(void *b = buf)
                {
                    rd = LibC.read(newFd, b, buf.Length);

                    hash.TransformBlock(buf, 0, (int)rd, buf, 0);
                }

                if (rd < 1)
                {
                    break;
                }
            }

            LibC.close(newFd);
            buf = null;

            hash.TransformFinalBlock(buf, 0, 0);
            return(hash.Hash);
        }
        public override void Release(ReadOnlySpan <byte> path, ref FuseFileInfo fi, Guid fileGuid)
        {
            path = base.TransformPath(path);

            if (debug)
            {
                Console.WriteLine($"NeoFS::Release({RawDirs.HR(path)})");
            }

            if (FileContexts.TryGetValue(fi.fh, out var context))
            {
                if (context.ExtAssetSha1 != null)  // Asset Mode
                {
                    base.AssetRelease(path, ref fi, fileGuid);
                }
                FileContexts.Remove(fi.fh);
            }

            if (fi.fh > 0)
            {
                LibC.close((int)fi.fh);
            }

            fi.fh = 0;
        }
Ejemplo n.º 3
0
        protected override bool ReleaseHandle()
        {
            var rv = LibC.close(handle.ToInt32());

            if (rv == -1)
            {
                PlatformException.Throw();
            }
            return(true);
        }
Ejemplo n.º 4
0
        private void CallClose()
        {
            int current_status = LibC.close((int)fd.Value);

            status.Value = (uint)current_status;
            if (current_status == -1)
            {
                SetErrorNumber();
            }
            call = Call.Done;
        }