Пример #1
0
		private static extern int ToTimeval (IntPtr source, out Timeval destination);
Пример #2
0
		public static bool TryCopy (IntPtr source, out Timeval destination)
		{
			return ToTimeval (source, out destination) == 0;
		}
Пример #3
0
		private static extern int FromTimeval (ref Timeval source, IntPtr destination);
Пример #4
0
		public static bool TryCopy (ref Timeval source, IntPtr destination)
		{
			return FromTimeval (ref source, destination) == 0;
		}
		private static int FromTimeval (ref Timeval source, IntPtr destination)
		{
			throw new System.NotImplementedException();
		}
		private static int ToTimeval (IntPtr source, out Timeval destination)
		{
			throw new System.NotImplementedException();
		}
		private static int sys_futimes (int fd, Timeval[] tvp)
		{
			throw new System.NotImplementedException();
		}
Пример #8
0
        public void SetResponseTimeout(int usecTimeout)
        {
            CheckContext();

            if (modbusResponseTimeout == IntPtr.Zero) {
                // At the moment I not know how to get the size of timeval struct so use a value big enought to contains timeval struct
                modbusResponseTimeout = Marshal.AllocHGlobal (32);
            }

            Timeval timeout = new Timeval();
            timeout.tv_usec = usecTimeout % 1000000;
            timeout.tv_sec = usecTimeout / 1000000;

            Mono.Unix.Native.NativeConvert.TryCopy (ref timeout, modbusResponseTimeout);

            ModbusPinvoke.SetResponseTimeout (modbusContext,modbusResponseTimeout);
        }
		private static int settimeofday (ref Timeval tv, IntPtr ignore)
		{
			throw new System.NotImplementedException();
		}
Пример #10
0
		private static int sys_lutimes (
		string filename, Timeval[] tvp)
		{
			throw new System.NotImplementedException();
		}
Пример #11
0
		public static int settimeofday (ref Timeval tv, ref Timezone tz)
		{
			throw new System.NotImplementedException();
		}
Пример #12
0
 public Timex(uint Modes = default, int Offset = default, int Freq = default, int Maxerror = default, int Esterror = default, int Status = default, int Constant = default, int Precision = default, int Tolerance = default, Timeval Time = default, int Tick = default, int Ppsfreq = default, int Jitter = default, int Shift = default, int Stabil = default, int Jitcnt = default, int Calcnt = default, int Errcnt = default, int Stbcnt = default, int Tai = default, array <byte> Pad_cgo_0 = default)
 {
     this.Modes     = Modes;
     this.Offset    = Offset;
     this.Freq      = Freq;
     this.Maxerror  = Maxerror;
     this.Esterror  = Esterror;
     this.Status    = Status;
     this.Constant  = Constant;
     this.Precision = Precision;
     this.Tolerance = Tolerance;
     this.Time      = Time;
     this.Tick      = Tick;
     this.Ppsfreq   = Ppsfreq;
     this.Jitter    = Jitter;
     this.Shift     = Shift;
     this.Stabil    = Stabil;
     this.Jitcnt    = Jitcnt;
     this.Calcnt    = Calcnt;
     this.Errcnt    = Errcnt;
     this.Stbcnt    = Stbcnt;
     this.Tai       = Tai;
     this.Pad_cgo_0 = Pad_cgo_0;
 }
Пример #13
0
 public Timex(uint Modes = default, array <byte> Pad_cgo_0 = default, long Offset = default, long Freq = default, long Maxerror = default, long Esterror = default, int Status = default, array <byte> Pad_cgo_1 = default, long Constant = default, long Precision = default, long Tolerance = default, Timeval Time = default, long Tick = default, long Ppsfreq = default, long Jitter = default, int Shift = default, array <byte> Pad_cgo_2 = default, long Stabil = default, long Jitcnt = default, long Calcnt = default, long Errcnt = default, long Stbcnt = default, int Tai = default, array <byte> Pad_cgo_3 = default)
 {
     this.Modes     = Modes;
     this.Pad_cgo_0 = Pad_cgo_0;
     this.Offset    = Offset;
     this.Freq      = Freq;
     this.Maxerror  = Maxerror;
     this.Esterror  = Esterror;
     this.Status    = Status;
     this.Pad_cgo_1 = Pad_cgo_1;
     this.Constant  = Constant;
     this.Precision = Precision;
     this.Tolerance = Tolerance;
     this.Time      = Time;
     this.Tick      = Tick;
     this.Ppsfreq   = Ppsfreq;
     this.Jitter    = Jitter;
     this.Shift     = Shift;
     this.Pad_cgo_2 = Pad_cgo_2;
     this.Stabil    = Stabil;
     this.Jitcnt    = Jitcnt;
     this.Calcnt    = Calcnt;
     this.Errcnt    = Errcnt;
     this.Stbcnt    = Stbcnt;
     this.Tai       = Tai;
     this.Pad_cgo_3 = Pad_cgo_3;
 }
Пример #14
0
        bool CopyFile(string source_absolute_path, string target_path)
        {
            bool ret           = false;
            bool target_exists = false;
            // Stat target
            Stat tstat;

            lock (this)
                ProcessedFiles++;

            while (Syscall.stat(target_path, out tstat) == 0)
            {
                if (tstat.st_mode.HasFlag(FilePermissions.S_IFDIR))
                {
                    if (ShouldRetryOperation("Target file is a directory", "Source file \"{0}\"",
                                             Path.GetFileName(source_absolute_path)))
                    {
                        continue;
                    }
                    return(false);
                }
                else
                {
                    target_exists = true;
                }
                break;
            }

            // Open Source
            int source_fd;

            while (true)
            {
                source_fd = Syscall.open(source_absolute_path, OpenFlags.O_RDONLY, (FilePermissions)0);
                if (source_fd != -1)
                {
                    break;
                }

                if (ShouldRetryOperation("While opening \"{0}\"", target_path))
                {
                    continue;
                }
                return(false);
            }
            Stat stat;

            while (true)
            {
                if (Syscall.fstat(source_fd, out stat) != -1)
                {
                    break;
                }

                if (ShouldRetryOperation("While probing for state of \"{0}\"", target_path))
                {
                    continue;
                }
                goto close_source;
            }

            // Make sure we are not overwriting the same file
            if (stat.st_dev == tstat.st_dev && stat.st_ino == tstat.st_ino)
            {
                Interaction.Error("Can not copy a file into itself");
                skip = true;
                goto close_source;
            }

            lock (this){
                CurrentFileProgress = 0;
                CurrentFileSize     = tstat.st_size;
            }

            if (target_exists)
            {
                if (target_exists_action < TargetExistsAction.AlwaysOverwrite)
                {
                    target_exists_action = Interaction.TargetExists(
                        target_path,
                        NativeConvert.ToDateTime(stat.st_mtime), stat.st_size,
                        NativeConvert.ToDateTime(tstat.st_mtime), tstat.st_size, Interaction.Count > 1);
                }

                if (target_exists_action == TargetExistsAction.Cancel)
                {
                    goto close_source;
                }

                if (target_exists_action == TargetExistsAction.Skip)
                {
                    goto close_source;
                }
            }

            // Open target
            int target_fd;

            switch (target_exists_action)
            {
            case TargetExistsAction.AlwaysUpdate:
                if (stat.st_mtime > tstat.st_mtime)
                {
                    goto case TargetExistsAction.Overwrite;
                }
                skip = true;
                goto close_source;

            case TargetExistsAction.AlwaysUpdateOnSizeMismatch:
                if (stat.st_size != tstat.st_size)
                {
                    goto case TargetExistsAction.Overwrite;
                }
                skip = true;
                goto close_source;


            // Real cancels are taken care of immediately after the dialog
            // this means: never used, target does not exist.
            case TargetExistsAction.Cancel:
            case TargetExistsAction.AlwaysOverwrite:
            case TargetExistsAction.Overwrite:
                target_fd = Syscall.open(target_path, OpenFlags.O_CREAT | OpenFlags.O_WRONLY, FilePermissions.S_IWUSR);
                break;

            case TargetExistsAction.Append:
                target_fd = Syscall.open(target_path, OpenFlags.O_APPEND, FilePermissions.S_IWUSR);
                break;

            default:
                throw new Exception(String.Format("Internal error: unhandled TargetExistsAction value {0}", target_exists_action));
            }

            while (true)
            {
                if (target_fd != -1)
                {
                    break;
                }
                if (ShouldRetryOperation("While creating \"{0}\"", target_path))
                {
                    continue;
                }
                goto close_source;
            }

            AllocateBuffer();
            long n;

            do
            {
                while (true)
                {
                    n = Syscall.read(source_fd, io_buffer, COPY_BUFFER_SIZE);

                    if (n != -1)
                    {
                        break;
                    }

                    if (ShouldRetryOperation("While reading \"{0}\"", Path.GetFileName(source_absolute_path)))
                    {
                        continue;
                    }
                    goto close_both;
                }
                while (true)
                {
                    long count = Syscall.write(target_fd, io_buffer, (ulong)n);
                    if (count != -1)
                    {
                        break;
                    }

                    if (ShouldRetryOperation("While writing \"{0}\"", target_path))
                    {
                        continue;
                    }
                    goto close_both;
                }
                lock (this){
                    ProcessedBytes  += n;
                    CurrentFileSize += n;
                }
            } while (n != 0);

            // File mode
            while (true)
            {
                n = Syscall.fchmod(target_fd, stat.st_mode);
                if (n == 0)
                {
                    break;
                }

                if (ShouldRetryOperation("Setting permissions on \"{0}\"", target_path))
                {
                    continue;
                }

                goto close_both;
            }

            // The following are not considered errors if we can not set them
            ret = true;

            // preserve owner and group if running as root
            if (Syscall.geteuid() == 0)
            {
                Syscall.fchown(target_fd, stat.st_uid, stat.st_gid);
            }

            // Set file time
            Timeval [] dates = new Timeval [2] {
                new Timeval()
                {
                    tv_sec = stat.st_atime
                },
                new Timeval()
                {
                    tv_sec = stat.st_mtime
                }
            };
            Syscall.futimes(target_fd, dates);

close_both:
            Syscall.close(target_fd);
close_source:
            Syscall.close(source_fd);
            return(ret);
        }
Пример #15
0
 public IfData(byte Type = default, byte Physical = default, byte Addrlen = default, byte Hdrlen = default, byte Link_state = default, byte Spare_char1 = default, byte Spare_char2 = default, byte Datalen = default, ulong Mtu = default, ulong Metric = default, ulong Baudrate = default, ulong Ipackets = default, ulong Ierrors = default, ulong Opackets = default, ulong Oerrors = default, ulong Collisions = default, ulong Ibytes = default, ulong Obytes = default, ulong Imcasts = default, ulong Omcasts = default, ulong Iqdrops = default, ulong Noproto = default, ulong Hwassist = default, long Epoch = default, Timeval Lastchange = default)
 {
     this.Type        = Type;
     this.Physical    = Physical;
     this.Addrlen     = Addrlen;
     this.Hdrlen      = Hdrlen;
     this.Link_state  = Link_state;
     this.Spare_char1 = Spare_char1;
     this.Spare_char2 = Spare_char2;
     this.Datalen     = Datalen;
     this.Mtu         = Mtu;
     this.Metric      = Metric;
     this.Baudrate    = Baudrate;
     this.Ipackets    = Ipackets;
     this.Ierrors     = Ierrors;
     this.Opackets    = Opackets;
     this.Oerrors     = Oerrors;
     this.Collisions  = Collisions;
     this.Ibytes      = Ibytes;
     this.Obytes      = Obytes;
     this.Imcasts     = Imcasts;
     this.Omcasts     = Omcasts;
     this.Iqdrops     = Iqdrops;
     this.Noproto     = Noproto;
     this.Hwassist    = Hwassist;
     this.Epoch       = Epoch;
     this.Lastchange  = Lastchange;
 }