Ejemplo n.º 1
0
 public UnixSocket(string path, uint?permissions) : this(CreateEndPoint(path))
 {
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     this.path = path;
     try {
         if (path.StartsWith("\0"))
         {
             inode = null;
         }
         else
         {
             inode = new UnixFileInfo(path).Inode;
             if (permissions != null)
             {
                 Syscall.chmod(path, NativeConvert.ToFilePermissions(permissions.Value));
             }
         }
     } catch (InvalidOperationException) {
         Logger.Write(LogLevel.Error, "Path \"{0}\" doesn't exist?", path);
         throw;
     }
 }
Ejemplo n.º 2
0
        static void CreateWithPerm(string path, string permissions, string groupName = null)
        {
            Directory.CreateDirectory(path);
            uint perm = Convert.ToUInt32(permissions, 8);

            Syscall.chmod(path, NativeConvert.ToFilePermissions(perm));
            if (groupName == null)
            {
                return;
            }
            var group = new UnixGroupInfo(groupName);

            Syscall.chown(path, 0, (uint)group.GroupId);
        }
Ejemplo n.º 3
0
        private int _OnChangePathPermissions(string path, uint mode)
        {
            Errno errno;

            try
            {
                FilePermissions _mode = NativeConvert.ToFilePermissions(mode);
                errno = _filesystem.OnChangePathPermissions(path, _mode);
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.ToString());
                errno = Errno.EIO;
            }
            return(Interop.ConvertErrno(errno));
        }
Ejemplo n.º 4
0
        private int _OnCreateSpecialFile(string path, uint perms, ulong dev)
        {
            Errno errno;

            try
            {
                FilePermissions _perms = NativeConvert.ToFilePermissions(perms);
                errno = _filesystem.OnCreateSpecialFile(path, _perms, dev);
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.ToString());
                errno = Errno.EIO;
            }
            return(Interop.ConvertErrno(errno));
        }
Ejemplo n.º 5
0
        private int _OnCreateHandle(string path, uint mode, IntPtr fi)
        {
            Errno errno;

            try
            {
                PathInfo info = new PathInfo();
                PathInfo.CopyFromPtr(fi, info);
                FilePermissions _mode = NativeConvert.ToFilePermissions(mode);
                errno = _filesystem.OnCreateHandle(path, info, _mode);
                if (errno == 0)
                {
                    PathInfo.CopyToPtr(info, fi);
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.ToString());
                errno = Errno.EIO;
            }
            return(Interop.ConvertErrno(errno));
        }
Ejemplo n.º 6
0
 public override void Listen(int backlog)
 {
     base.Listen(backlog);
     try {
         if (path.StartsWith("\0", StringComparison.Ordinal))
         {
             inode = null;
         }
         else
         {
             var info = new UnixFileInfo(path);
             inode = info.Inode;
             if (permissions != null)
             {
                 Syscall.chmod(path, NativeConvert.ToFilePermissions(permissions.Value));
             }
         }
     } catch (InvalidOperationException e) {
         Logger.Write(LogLevel.Error, e.Message);
         Logger.Write(LogLevel.Error, "Path \"{0}\" doesn't exist?", path);
         throw;
     }
 }