| | | 1 | | using Renci.SshNet.Common; |
| | | 2 | | |
| | | 3 | | namespace Renci.SshNet.Sftp |
| | | 4 | | { |
| | | 5 | | /// <summary> |
| | | 6 | | /// Contains File system information exposed by statvfs@openssh.com request. |
| | | 7 | | /// </summary> |
| | | 8 | | #pragma warning disable SA1649 // File name should match first type name |
| | | 9 | | public class SftpFileSytemInformation |
| | | 10 | | #pragma warning restore SA1649 // File name should match first type name |
| | | 11 | | { |
| | | 12 | | #pragma warning disable SA1310 // Field names should not contain underscore |
| | | 13 | | internal const ulong SSH_FXE_STATVFS_ST_RDONLY = 0x1; |
| | | 14 | | internal const ulong SSH_FXE_STATVFS_ST_NOSUID = 0x2; |
| | | 15 | | #pragma warning restore SA1310 // Field names should not contain underscore |
| | | 16 | | |
| | | 17 | | private readonly ulong _flag; |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Gets the file system block size. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <value> |
| | | 23 | | /// The file system block size. |
| | | 24 | | /// </value> |
| | 30 | 25 | | public ulong FileSystemBlockSize { get; private set; } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Gets the fundamental file system size of the block. |
| | | 29 | | /// </summary> |
| | | 30 | | /// <value> |
| | | 31 | | /// The fundamental file system block size. |
| | | 32 | | /// </value> |
| | 30 | 33 | | public ulong BlockSize { get; private set; } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Gets the total blocks. |
| | | 37 | | /// </summary> |
| | | 38 | | /// <value> |
| | | 39 | | /// The total blocks. |
| | | 40 | | /// </value> |
| | 30 | 41 | | public ulong TotalBlocks { get; private set; } |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Gets the free blocks. |
| | | 45 | | /// </summary> |
| | | 46 | | /// <value> |
| | | 47 | | /// The free blocks. |
| | | 48 | | /// </value> |
| | 30 | 49 | | public ulong FreeBlocks { get; private set; } |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Gets the available blocks. |
| | | 53 | | /// </summary> |
| | | 54 | | /// <value> |
| | | 55 | | /// The available blocks. |
| | | 56 | | /// </value> |
| | 33 | 57 | | public ulong AvailableBlocks { get; private set; } |
| | | 58 | | |
| | | 59 | | /// <summary> |
| | | 60 | | /// Gets the total nodes. |
| | | 61 | | /// </summary> |
| | | 62 | | /// <value> |
| | | 63 | | /// The total nodes. |
| | | 64 | | /// </value> |
| | 30 | 65 | | public ulong TotalNodes { get; private set; } |
| | | 66 | | |
| | | 67 | | /// <summary> |
| | | 68 | | /// Gets the free nodes. |
| | | 69 | | /// </summary> |
| | | 70 | | /// <value> |
| | | 71 | | /// The free nodes. |
| | | 72 | | /// </value> |
| | 30 | 73 | | public ulong FreeNodes { get; private set; } |
| | | 74 | | |
| | | 75 | | /// <summary> |
| | | 76 | | /// Gets the available nodes. |
| | | 77 | | /// </summary> |
| | | 78 | | /// <value> |
| | | 79 | | /// The available nodes. |
| | | 80 | | /// </value> |
| | 30 | 81 | | public ulong AvailableNodes { get; private set; } |
| | | 82 | | |
| | | 83 | | /// <summary> |
| | | 84 | | /// Gets the sid. |
| | | 85 | | /// </summary> |
| | | 86 | | /// <value> |
| | | 87 | | /// The sid. |
| | | 88 | | /// </value> |
| | 30 | 89 | | public ulong Sid { get; private set; } |
| | | 90 | | |
| | | 91 | | /// <summary> |
| | | 92 | | /// Gets a value indicating whether this instance is read only. |
| | | 93 | | /// </summary> |
| | | 94 | | /// <value> |
| | | 95 | | /// <see langword="true"/> if this instance is read only; otherwise, <see langword="false"/>. |
| | | 96 | | /// </value> |
| | | 97 | | public bool IsReadOnly |
| | | 98 | | { |
| | 18 | 99 | | get { return (_flag & SSH_FXE_STATVFS_ST_RDONLY) == SSH_FXE_STATVFS_ST_RDONLY; } |
| | | 100 | | } |
| | | 101 | | |
| | | 102 | | /// <summary> |
| | | 103 | | /// Gets a value indicating whether [supports set uid]. |
| | | 104 | | /// </summary> |
| | | 105 | | /// <value> |
| | | 106 | | /// <see langword="true"/> if [supports set uid]; otherwise, <see langword="false"/>. |
| | | 107 | | /// </value> |
| | | 108 | | public bool SupportsSetUid |
| | | 109 | | { |
| | 18 | 110 | | get { return (_flag & SSH_FXE_STATVFS_ST_NOSUID) == 0; } |
| | | 111 | | } |
| | | 112 | | |
| | | 113 | | /// <summary> |
| | | 114 | | /// Gets the max name lenght. |
| | | 115 | | /// </summary> |
| | | 116 | | /// <value> |
| | | 117 | | /// The max name lenght. |
| | | 118 | | /// </value> |
| | 30 | 119 | | public ulong MaxNameLenght { get; private set; } |
| | | 120 | | |
| | | 121 | | /// <summary> |
| | | 122 | | /// Initializes a new instance of the <see cref="SftpFileSytemInformation" /> class. |
| | | 123 | | /// </summary> |
| | | 124 | | /// <param name="bsize">The bsize.</param> |
| | | 125 | | /// <param name="frsize">The frsize.</param> |
| | | 126 | | /// <param name="blocks">The blocks.</param> |
| | | 127 | | /// <param name="bfree">The bfree.</param> |
| | | 128 | | /// <param name="bavail">The bavail.</param> |
| | | 129 | | /// <param name="files">The files.</param> |
| | | 130 | | /// <param name="ffree">The ffree.</param> |
| | | 131 | | /// <param name="favail">The favail.</param> |
| | | 132 | | /// <param name="sid">The sid.</param> |
| | | 133 | | /// <param name="flag">The flag.</param> |
| | | 134 | | /// <param name="namemax">The namemax.</param> |
| | 18 | 135 | | internal SftpFileSytemInformation(ulong bsize, ulong frsize, ulong blocks, ulong bfree, ulong bavail, ulong file |
| | 18 | 136 | | { |
| | 18 | 137 | | FileSystemBlockSize = bsize; |
| | 18 | 138 | | BlockSize = frsize; |
| | 18 | 139 | | TotalBlocks = blocks; |
| | 18 | 140 | | FreeBlocks = bfree; |
| | 18 | 141 | | AvailableBlocks = bavail; |
| | 18 | 142 | | TotalNodes = files; |
| | 18 | 143 | | FreeNodes = ffree; |
| | 18 | 144 | | AvailableNodes = favail; |
| | 18 | 145 | | Sid = sid; |
| | 18 | 146 | | _flag = flag; |
| | 18 | 147 | | MaxNameLenght = namemax; |
| | 18 | 148 | | } |
| | | 149 | | |
| | | 150 | | internal void SaveData(SshDataStream stream) |
| | 6 | 151 | | { |
| | 6 | 152 | | stream.Write(FileSystemBlockSize); |
| | 6 | 153 | | stream.Write(BlockSize); |
| | 6 | 154 | | stream.Write(TotalBlocks); |
| | 6 | 155 | | stream.Write(FreeBlocks); |
| | 6 | 156 | | stream.Write(AvailableBlocks); |
| | 6 | 157 | | stream.Write(TotalNodes); |
| | 6 | 158 | | stream.Write(FreeNodes); |
| | 6 | 159 | | stream.Write(AvailableNodes); |
| | 6 | 160 | | stream.Write(Sid); |
| | 6 | 161 | | stream.Write(_flag); |
| | 6 | 162 | | stream.Write(MaxNameLenght); |
| | 6 | 163 | | } |
| | | 164 | | } |
| | | 165 | | } |