Example #1
0
 public int Release(FileDescriptor fds)
 {
     return(0);
 }
Example #2
0
 public int Write(FileDescriptor fds, ulong off, ReadOnlySpan <byte> span)
 {
     return(-LibC.EROFS);  // Read only file system
 }
Example #3
0
 public int Open(FileDescriptor fds, int flags)
 {
     throw new NotImplementedException();
 }
Example #4
0
 public int Read(FileDescriptor fds, ulong offset, Span <byte> buffer)
 {
     throw new NotImplementedException();
 }
        public override int Create(ReadOnlySpan <byte> path, mode_t mode, ref FuseFileInfo fi)
        {
            if (verbosity > 5)
            {
                Console.WriteLine($"Create {path.GetString()} Flags={flagString(fi.flags)}");
            }

            int error = 0, level = 0;
            var procs = ProcPath(path, ref error, ref level, mustExist: false);

            if (error != 0)
            {
                Console.WriteLine($"Path gets error {error}");
                return(-LibC.ENOENT);
            }

            // New files are always cache files, but might have existing file that needs to be deleted

            int version = 0;
            var newFile = procs.Pop();

            if (newFile.Item2 != null)
            {
                // Must delete the file
                version = newFile.Item2.Version;
                Console.WriteLine($"File Deleted: {newFile.Item2.Name.GetString()} id={newFile.Item2._id} Version={version}");

                fileDelete(newFile.Item2, DeleteTypes.CREATE);
            }

            var parentRec = procs.Pop();

            if (parentRec.Item2 == null)
            {
                return(-LibC.ENOENT);
            }
            var par = parentRec.Item2;

            if (par.MaintLevel)
            {
                return(-LibC.EPERM);
            }

            // Create new record (new id) and insert
            var newRec = NeoAssets.Mongo.NeoVirtFS.CreateNewFile(par._id, par.VolumeId, newFile.Item1, path, mode);

            newRec.Version = version + 1;

            NeoVirtFSCol.InsertOne(newRec);

            //var filter = Builders<NeoAssets.Mongo.NeoVirtFS>.Filter.Eq(x => x._id, newRec._id);
            //var insert = NeoVirtFSDeletedCol.ReplaceOneAsync(filter, newRec, options: new ReplaceOptions { IsUpsert = true });

            Console.WriteLine($"File Created: {newRec.Name.GetString()} id={newRec._id}");

            fi.fh = storeHandler(FileDescriptor.FileHandlerFactory(newRec, db, bac, bvol));

            var fds = DescriptorStore[fi.fh];

            return(fds.Handler.Create(fds, mode, fi.flags));
        }
Example #6
0
 public int Create(FileDescriptor fds, mode_t mode, int flags)
 {
     return(-LibC.EROFS);  // Read only file system
 }
Example #7
0
 public int Release(FileDescriptor fds)
 {
     return(0);   // Close always suceeds
 }
Example #8
0
 public int Write(FileDescriptor fds, ulong off, ReadOnlySpan <byte> span)
 {
     return(-LibC.EPERM);  // Can't write notfile
 }
Example #9
0
 public int Read(FileDescriptor fds, ulong offset, Span <byte> buffer)
 {
     return(0);   // Read always gets eof
 }
Example #10
0
 public int Open(FileDescriptor fds, int flags)
 {
     return(0);   // Open always succeeds
 }
Example #11
0
 public int Create(FileDescriptor fds, mode_t mode, int flags)
 {
     return(-LibC.EPERM);   // Can't create NotFile
 }
Example #12
0
 public int Write(FileDescriptor fds, ulong off, ReadOnlySpan <byte> span)
 {
     return(base.Write(iot, off, span));
 }
Example #13
0
 public int Read(FileDescriptor fds, ulong offset, Span <byte> buffer)
 {
     return(base.Read(iot, offset, buffer));
 }