From 347e9e5f284100a290195675fc5695a50a7b23f5 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 7 May 2015 06:13:58 +0100 Subject: [PATCH] Changed everything to use base API type definitions, with "using" as alias to .NET types. --- Claunia.IO/ChangeLog | 18 ++ .../FreeBSD/Interop.FreeBSD.extattr.cs | 107 ++----- .../Interop/FreeBSD/Interop.FreeBSD.stat.cs | 281 ++---------------- .../Interop/FreeBSD/Interop.FreeBSD.statfs.cs | 55 ++-- .../Interop/FreeBSD/Interop.FreeBSD.types.cs | 169 +++++++++++ .../Interop/FreeBSD/Interop.FreeBSD.uname.cs | 2 +- .../Interop/Linux/Interop.Linux.Libraries.cs | 3 +- .../Interop/Linux/Interop.Linux.stat.cs | 37 ++- .../Interop/Linux/Interop.Linux.stat64.cs | 37 ++- .../Interop/Linux/Interop.Linux.statfs.cs | 39 ++- .../Interop/Linux/Interop.Linux.statfs64.cs | 39 ++- .../Interop/Linux/Interop.Linux.types.cs | 2 +- .../Interop/Linux/Interop.Linux.xattr.cs | 25 +- .../Interop/Linux/Interop.Linux.xattr64.cs | 25 +- 14 files changed, 438 insertions(+), 401 deletions(-) diff --git a/Claunia.IO/ChangeLog b/Claunia.IO/ChangeLog index ec1aa5b..85edf28 100644 --- a/Claunia.IO/ChangeLog +++ b/Claunia.IO/ChangeLog @@ -1,3 +1,21 @@ +2015-05-07 Natalia Portillo + + * Interop/Linux/Interop.Linux.stat.cs: + * Interop/Linux/Interop.Linux.xattr.cs: + * Interop/Linux/Interop.Linux.types.cs: + * Interop/Linux/Interop.Linux.statfs.cs: + * Interop/Linux/Interop.Linux.stat64.cs: + * Interop/Linux/Interop.Linux.xattr64.cs: + * Interop/FreeBSD/Interop.FreeBSD.stat.cs: + * Interop/Linux/Interop.Linux.statfs64.cs: + * Interop/FreeBSD/Interop.FreeBSD.types.cs: + * Interop/FreeBSD/Interop.FreeBSD.uname.cs: + * Interop/Linux/Interop.Linux.Libraries.cs: + * Interop/FreeBSD/Interop.FreeBSD.statfs.cs: + * Interop/FreeBSD/Interop.FreeBSD.extattr.cs: + Changed everything to use base API type definitions, with + "using" as alias to .NET types. + 2015-05-07 Natalia Portillo * Claunia.IO.csproj: diff --git a/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.extattr.cs b/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.extattr.cs index 3a81de5..a48984c 100644 --- a/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.extattr.cs +++ b/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.extattr.cs @@ -1,5 +1,5 @@ // -// Interop.Apple.xattr.cs +// Interop.FreeBSD.extattr.cs // // Author: // Natalia Portillo @@ -26,93 +26,43 @@ using System; using System.Runtime.InteropServices; +#region FreeBSD 32-bit type definitions +using blkcnt_t = System.Int64; +using blksize_t = System.Int32; +using gid_t = System.UInt32; +using ino_t = System.UInt32; +using int64_t = System.Int64; +using nlink_t = System.UInt16; +using off_t = System.Int64; +using size_t = System.Int32; +using ssize_t = System.Int32; +using uid_t = System.UInt32; +using uint32_t = System.UInt32; +using uint64_t = System.UInt64; +using __dev_t = System.UInt32; +using __int32_t = System.Int32; +using __uint32_t = System.UInt32; + +#endregion + + internal static partial class Interop { internal static partial class FreeBSD { - public enum attrNamespace - { - /// - /// Empty namespace - /// - EXTATTR_NAMESPACE_EMPTY = 0x00000000, - /// - /// User namespace - /// - EXTATTR_NAMESPACE_USER = 0x00000001, - /// - /// System namespace - /// - EXTATTR_NAMESPACE_SYSTEM = 0x00000002 - } - - /// - /// Gets an extended attribute value - /// Calls to system's extattr_get_file(2) - /// - /// Number of bytes read. If is , then the size for the buffer to store the data. - /// Path to the file. - /// Extended attribute namespace, . - /// Extended attribute name. - /// Pointer to buffer where to store the data. - /// Size of the buffer. - [DllImport(Libraries.Libc, SetLastError = true, CharSet = CharSet.Ansi)] - public static extern Int64 extattr_get_file(string path, attrNamespace attrnamespace, string attrname, IntPtr data, Int64 nbytes); - - /// - /// Sets an extended attribute value - /// Calls to system's extattr_set_file(2) - /// - /// Number of bytes written. - /// Path to the file. - /// Extended attribute namespace, . - /// Extended attribute name. - /// Pointer where the data is stored. - /// Size of the data. - [DllImport(Libraries.Libc, SetLastError = true, CharSet = CharSet.Ansi)] - public static extern Int64 extattr_set_file(string path, attrNamespace attrnamespace, string attrname, IntPtr data, Int64 nbytes); - - /// - /// Deletes an extended attribute value - /// Calls to system's extattr_delete_file(2) - /// - /// 0 if successful, -1 if failure. - /// Path to the file. - /// Extended attribute namespace, . - /// Extended attribute name. - /// Pointer to buffer where the data is stored. - /// Size of the pointer. - [DllImport(Libraries.Libc, SetLastError = true, CharSet = CharSet.Ansi)] - public static extern Int64 extattr_delete_file(string path, attrNamespace attrnamespace, string attrname); - - /// - /// Gets a list of extended attributes that the file has in that namespace - /// The list is stored in the buffer as an undetermined length of Pascal strings, - /// 1 byte tells the size of the extended attribute name in bytes, and is followed by the name. - /// Calls to system's extattr_list_file(2) - /// - /// Size of the list in bytes. If is , then the size for the buffer to store the list. - /// Path to the file. - /// Extended attribute namespace, . - /// Extended attribute name. - /// Pointer to buffer where to store the list. - /// Size of the buffer. - [DllImport(Libraries.Libc, SetLastError = true, CharSet = CharSet.Ansi)] - public static extern Int64 extattr_list_file(string path, attrNamespace attrnamespace, IntPtr data, Int64 nbytes); - /// /// Gets an extended attribute value /// Calls to system's extattr_get_file(2) /// For 32-bit systems /// - /// Number of bytes read. If is , then the size for the buffer to store the data. + /// Number of bytes read. If is null, then the size for the buffer to store the data. /// Path to the file. /// Extended attribute namespace, . /// Extended attribute name. /// Pointer to buffer where to store the data. /// Size of the buffer. [DllImport(Libraries.Libc, SetLastError = true, CharSet = CharSet.Ansi, EntryPoint = "extattr_get_file")] - public static extern Int32 extattr_get_file32(string path, attrNamespace attrnamespace, string attrname, IntPtr data, Int32 nbytes); + public static extern ssize_t extattr_get_file32(string path, attrNamespace attrnamespace, string attrname, IntPtr data, size_t nbytes); /// /// Sets an extended attribute value @@ -126,7 +76,7 @@ internal static partial class Interop /// Pointer where the data is stored. /// Size of the data. [DllImport(Libraries.Libc, SetLastError = true, CharSet = CharSet.Ansi, EntryPoint = "extattr_set_file")] - public static extern Int32 extattr_set_file32(string path, attrNamespace attrnamespace, string attrname, IntPtr data, Int32 nbytes); + public static extern ssize_t extattr_set_file32(string path, attrNamespace attrnamespace, string attrname, IntPtr data, size_t nbytes); /// /// Deletes an extended attribute value @@ -137,10 +87,8 @@ internal static partial class Interop /// Path to the file. /// Extended attribute namespace, . /// Extended attribute name. - /// Pointer to buffer where the data is stored. - /// Size of the pointer. [DllImport(Libraries.Libc, SetLastError = true, CharSet = CharSet.Ansi, EntryPoint = "extattr_delete_file")] - public static extern Int32 extattr_delete_file32(string path, attrNamespace attrnamespace, string attrname); + public static extern ssize_t extattr_delete_file32(string path, attrNamespace attrnamespace, string attrname); /// /// Gets a list of extended attributes that the file has in that namespace @@ -149,14 +97,13 @@ internal static partial class Interop /// Calls to system's extattr_list_file(2) /// For 32-bit systems /// - /// Size of the list in bytes. If is , then the size for the buffer to store the list. + /// Size of the list in bytes. If is null, then the size for the buffer to store the list. /// Path to the file. /// Extended attribute namespace, . - /// Extended attribute name. /// Pointer to buffer where to store the list. /// Size of the buffer. [DllImport(Libraries.Libc, SetLastError = true, CharSet = CharSet.Ansi, EntryPoint = "extattr_list_file")] - public static extern Int32 extattr_list_file32(string path, attrNamespace attrnamespace, IntPtr data, Int32 nbytes); + public static extern ssize_t extattr_list_file32(string path, attrNamespace attrnamespace, IntPtr data, size_t nbytes); } } diff --git a/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.stat.cs b/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.stat.cs index 4778879..6ca1179 100644 --- a/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.stat.cs +++ b/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.stat.cs @@ -1,5 +1,5 @@ // -// Interop.Apple.stat.cs +// Interop.FreeBSD.stat.cs // // Author: // Natalia Portillo @@ -23,86 +23,32 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.Runtime.InteropServices; using System; +using System.Runtime.InteropServices; + +#region FreeBSD 32-bit type definitions +using blkcnt_t = System.Int64; +using blksize_t = System.Int32; +using gid_t = System.UInt32; +using ino_t = System.UInt32; +using int64_t = System.Int64; +using nlink_t = System.UInt16; +using off_t = System.Int64; +using size_t = System.Int32; +using ssize_t = System.Int32; +using uid_t = System.UInt32; +using uint32_t = System.UInt32; +using uint64_t = System.UInt64; +using __dev_t = System.UInt32; +using __int32_t = System.Int32; +using __uint32_t = System.UInt32; + +#endregion internal static partial class Interop { internal static partial class FreeBSD { - /// - /// stat(2) structure when 64 bit - /// - [StructLayout(LayoutKind.Sequential)] - internal struct Stat64 - { - /// - /// inode's device - /// - UInt32 st_dev; - /// - /// inode's number - /// - UInt32 st_ino; - /// - /// inode protection mode - /// - mode_t st_mode; - /// - /// number of hard links - /// - UInt16 st_nlink; - /// - /// user ID of the file's owner - /// - UInt32 st_uid; - /// - /// group ID of the file's group - /// - UInt32 st_gid; - /// - /// device type - /// - UInt32 st_rdev; - /// - /// time of last access - /// - Timespec64 st_atim; - /// - /// time of last data modification - /// - Timespec64 st_mtim; - /// - /// time of last file status change - /// - Timespec64 st_ctim; - /// - /// file size, in bytes - /// - Int64 st_size; - /// - /// blocks allocated for file - /// - Int64 st_blocks; - /// - /// optimal blocksize for I/O - /// - Int32 st_blksize; - /// - /// user defined flags for file - /// - flags_t st_flags; - /// - /// file generation number - /// - UInt32 st_gen; - Int32 st_lspare; - /// - /// time of file creation - /// - Timespec64 st_birthtim; - } - /// /// stat(2) structure when 32 bit /// @@ -112,11 +58,11 @@ internal static partial class Interop /// /// inode's device /// - UInt32 st_dev; + __dev_t st_dev; /// /// inode's number /// - UInt32 st_ino; + ino_t st_ino; /// /// inode protection mode /// @@ -124,19 +70,19 @@ internal static partial class Interop /// /// number of hard links /// - UInt16 st_nlink; + nlink_t st_nlink; /// /// user ID of the file's owner /// - UInt32 st_uid; + uid_t st_uid; /// /// group ID of the file's group /// - UInt32 st_gid; + gid_t st_gid; /// /// device type /// - UInt32 st_rdev; + __dev_t st_rdev; /// /// time of last access /// @@ -152,15 +98,15 @@ internal static partial class Interop /// /// file size, in bytes /// - Int64 st_size; + off_t st_size; /// /// blocks allocated for file /// - Int64 st_blocks; + blkcnt_t st_blocks; /// /// optimal blocksize for I/O /// - Int32 st_blksize; + blksize_t st_blksize; /// /// user defined flags for file /// @@ -168,167 +114,14 @@ internal static partial class Interop /// /// file generation number /// - UInt32 st_gen; - Int32 st_lspare; + __uint32_t st_gen; + __int32_t st_lspare; /// /// time of file creation /// Timespec st_birthtim; } - /// - /// File mode and permissions - /// - [Flags] - internal enum mode_t : ushort - { - /// type of file mask - S_IFMT = 0xF000, - /// named pipe (fifo) - S_IFIFO = 0x1000, - /// character special - S_IFCHR = 0x2000, - /// directory - S_IFDIR = 0x4000, - /// block special - S_IFBLK = 0x6000, - /// regular - S_IFREG = 0x8000, - /// symbolic link - S_IFLNK = 0xA000, - /// socket - S_IFSOCK = 0xC000, - /// whiteout - S_IFWHT = 0xE000, - /// set user id on execution - S_ISUID = 0x0800, - /// set group id on execution - S_ISGID = 0x0400, - /// save swapped text even after use - S_ISVTX = 0x0200, - /// RWX mask for owner - S_IRWXU = 0x01C0, - /// read permission, owner - S_IRUSR = 0x0100, - /// write permission, owner - S_IWUSR = 0x0080, - /// execute/search permission, owner - S_IXUSR = 0x0040, - /// RWX mask for group - S_IRWXG = 0x0038, - /// read permission, group - S_IRGRP = 0x0020, - /// write permission, group - S_IWGRP = 0x0010, - /// execute/search permission, group - S_IXGRP = 0x0008, - /// RWX mask for other - S_IRWXO = 0x0007, - /// read permission, other - S_IROTH = 0x0004, - /// write permission, other - S_IWOTH = 0x0002, - /// execute/search permission, other - S_IXOTH = 0x0001 - } - - /// - /// User-set flags - /// - [Flags] - internal enum flags_t : uint - { - /// - /// Mask of owner changeable flags - /// - UF_SETTABLE = 0x0000FFFF, - /// - /// Do not dump file - /// - UF_NODUMP = 0x00000001, - /// - /// File may not be changed - /// - UF_IMMUTABLE = 0x00000002, - /// - /// Writes to file may only append - /// - UF_APPEND = 0x00000004, - /// - /// The directory is opaque when viewed through a union stack. - /// - UF_OPAQUE = 0x00000008, - /// - /// File may not be removed or renamed. - /// - UF_NOUNLINK = 0x00000010, - /// - /// File is compressed in HFS+ (>=10.6) - /// - [Obsolete("Unimplemented in FreeBSD")] - UF_COMPRESSED = 0x00000020, - /// - /// OBSOLETE: No longer used. - /// Issue notifications for deletes or renames of files with this flag set - /// - [Obsolete("Unimplemented in FreeBSD")] - UF_TRACKED = 0x00000040, - /// - /// Windows system file bit - /// - UF_SYSTEM = 0x00000080, - /// - /// Sparse file - /// - UF_SPARSE = 0x00000100, - /// - /// File is offline - /// - UF_OFFLINE = 0x00000200, - /// - /// Windows reparse point file bit - /// - UF_REPARSE = 0x00000400, - /// - /// File needs to be archived - /// - UF_ARCHIVE = 0x00000800, - /// - /// Windows readonly file bit - /// - UF_READONLY = 0x00001000, - - /// - /// File is hidden - /// - UF_HIDDEN = 0x00008000, - - /// - /// Mask of superuser changeable flags - /// - SF_SETTABLE = 0xffff0000, - /// - /// File is archived - /// - SF_ARCHIVED = 0x00010000, - /// - /// File may not be changed - /// - SF_IMMUTABLE = 0x00020000, - /// - /// Writes to file may only append - /// - SF_APPEND = 0x00040000, - /// - /// File may not be removed or renamed - /// - SF_NOUNLINK = 0x00100000, - /// - /// Snapshot inode - /// - SF_SNAPSHOT = 0x00200000 - } - /// /// Obtains information of the file pointed by . /// Calls to system's stat(2) @@ -338,15 +131,5 @@ internal static partial class Interop /// On success, 0. On failure, -1, and errno is set. [DllImport(Libraries.Libc, SetLastError = true)] public static extern int stat(string path, out Stat buf); - - /// - /// Obtains information of the file pointed by . - /// Calls to system's stat64(2) - /// - /// Path to the file. - /// . - /// On success, 0. On failure, -1, and errno is set. - [DllImport(Libraries.Libc, SetLastError = true, EntryPoint="stat")] - public static extern int stat64(string path, out Stat64 buf); } } \ No newline at end of file diff --git a/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.statfs.cs b/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.statfs.cs index 3653944..a4720ef 100644 --- a/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.statfs.cs +++ b/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.statfs.cs @@ -1,5 +1,5 @@ // -// Interop.FreeBSD.stat.cs +// Interop.FreeBSD.statfs.cs // // Author: // Natalia Portillo @@ -23,8 +23,27 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.Runtime.InteropServices; using System; +using System.Runtime.InteropServices; + +#region FreeBSD 64-bit type definitions +using blkcnt_t = System.Int64; +using blksize_t = System.Int32; +using gid_t = System.UInt32; +using ino_t = System.UInt32; +using int64_t = System.Int64; +using nlink_t = System.UInt16; +using off_t = System.Int64; +using size_t = System.Int64; +using ssize_t = System.Int64; +using uid_t = System.UInt32; +using uint32_t = System.UInt32; +using uint64_t = System.UInt64; +using __dev_t = System.UInt32; +using __int32_t = System.Int32; +using __uint32_t = System.UInt32; + +#endregion internal static partial class Interop { @@ -37,42 +56,42 @@ internal static partial class Interop internal struct StatFS { /// structure version number - UInt32 f_version; + uint32_t f_version; /// type of filesystem - UInt32 f_type; + uint32_t f_type; /// copy of mount exported flags mntflags_t f_flags; /// filesystem fragment size - UInt64 f_bsize; + uint64_t f_bsize; /// optimal transfer block size - UInt64 f_iosize; + uint64_t f_iosize; /// total data blocks in filesystem - UInt64 f_blocks; + uint64_t f_blocks; /// free blocks in filesystem - UInt64 f_bfree; + uint64_t f_bfree; /// free blocks avail to non-superuser - Int64 f_bavail; + int64_t f_bavail; /// total file nodes in filesystem - UInt64 f_files; + uint64_t f_files; /// free nodes avail to non-superuser - Int64 f_ffree; + int64_t f_ffree; /// count of sync writes since mount - UInt64 f_syncwrites; + uint64_t f_syncwrites; /// count of async writes since mount - UInt64 f_asyncwrites; + uint64_t f_asyncwrites; /// count of sync reads since mount - UInt64 f_syncreads; + uint64_t f_syncreads; /// count of async reads since mount - UInt64 f_asyncreads; + uint64_t f_asyncreads; /// unused spare [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.U8, SizeConst = 10)] [Obsolete("RESERVED: DO NOT USE")] - UInt64[] f_spare; + uint64_t[] f_spare; /// maximum filename length - UInt32 f_namemax; + uint32_t f_namemax; /// user that mounted the filesystem - UInt32 f_owner; + uid_t f_owner; /// filesystem id fsid_t f_fsid; /// spare string space diff --git a/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.types.cs b/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.types.cs index da63d5c..7f86b23 100644 --- a/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.types.cs +++ b/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.types.cs @@ -141,5 +141,174 @@ internal static partial class Interop /// do not show entry in df MNT_IGNORE = 0x0000000000800000 } + + public enum attrNamespace + { + /// + /// Empty namespace + /// + EXTATTR_NAMESPACE_EMPTY = 0x00000000, + /// + /// User namespace + /// + EXTATTR_NAMESPACE_USER = 0x00000001, + /// + /// System namespace + /// + EXTATTR_NAMESPACE_SYSTEM = 0x00000002 + } + + /// + /// File mode and permissions + /// + [Flags] + internal enum mode_t : ushort + { + /// type of file mask + S_IFMT = 0xF000, + /// named pipe (fifo) + S_IFIFO = 0x1000, + /// character special + S_IFCHR = 0x2000, + /// directory + S_IFDIR = 0x4000, + /// block special + S_IFBLK = 0x6000, + /// regular + S_IFREG = 0x8000, + /// symbolic link + S_IFLNK = 0xA000, + /// socket + S_IFSOCK = 0xC000, + /// whiteout + S_IFWHT = 0xE000, + /// set user id on execution + S_ISUID = 0x0800, + /// set group id on execution + S_ISGID = 0x0400, + /// save swapped text even after use + S_ISVTX = 0x0200, + /// RWX mask for owner + S_IRWXU = 0x01C0, + /// read permission, owner + S_IRUSR = 0x0100, + /// write permission, owner + S_IWUSR = 0x0080, + /// execute/search permission, owner + S_IXUSR = 0x0040, + /// RWX mask for group + S_IRWXG = 0x0038, + /// read permission, group + S_IRGRP = 0x0020, + /// write permission, group + S_IWGRP = 0x0010, + /// execute/search permission, group + S_IXGRP = 0x0008, + /// RWX mask for other + S_IRWXO = 0x0007, + /// read permission, other + S_IROTH = 0x0004, + /// write permission, other + S_IWOTH = 0x0002, + /// execute/search permission, other + S_IXOTH = 0x0001 + } + + /// + /// User-set flags + /// + [Flags] + internal enum flags_t : uint + { + /// + /// Mask of owner changeable flags + /// + UF_SETTABLE = 0x0000FFFF, + /// + /// Do not dump file + /// + UF_NODUMP = 0x00000001, + /// + /// File may not be changed + /// + UF_IMMUTABLE = 0x00000002, + /// + /// Writes to file may only append + /// + UF_APPEND = 0x00000004, + /// + /// The directory is opaque when viewed through a union stack. + /// + UF_OPAQUE = 0x00000008, + /// + /// File may not be removed or renamed. + /// + UF_NOUNLINK = 0x00000010, + /// + /// File is compressed in HFS+ (>=10.6) + /// + [Obsolete("Unimplemented in FreeBSD")] + UF_COMPRESSED = 0x00000020, + /// + /// OBSOLETE: No longer used. + /// Issue notifications for deletes or renames of files with this flag set + /// + [Obsolete("Unimplemented in FreeBSD")] + UF_TRACKED = 0x00000040, + /// + /// Windows system file bit + /// + UF_SYSTEM = 0x00000080, + /// + /// Sparse file + /// + UF_SPARSE = 0x00000100, + /// + /// File is offline + /// + UF_OFFLINE = 0x00000200, + /// + /// Windows reparse point file bit + /// + UF_REPARSE = 0x00000400, + /// + /// File needs to be archived + /// + UF_ARCHIVE = 0x00000800, + /// + /// Windows readonly file bit + /// + UF_READONLY = 0x00001000, + + /// + /// File is hidden + /// + UF_HIDDEN = 0x00008000, + + /// + /// Mask of superuser changeable flags + /// + SF_SETTABLE = 0xffff0000, + /// + /// File is archived + /// + SF_ARCHIVED = 0x00010000, + /// + /// File may not be changed + /// + SF_IMMUTABLE = 0x00020000, + /// + /// Writes to file may only append + /// + SF_APPEND = 0x00040000, + /// + /// File may not be removed or renamed + /// + SF_NOUNLINK = 0x00100000, + /// + /// Snapshot inode + /// + SF_SNAPSHOT = 0x00200000 + } } } \ No newline at end of file diff --git a/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.uname.cs b/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.uname.cs index 9896350..6500cc4 100644 --- a/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.uname.cs +++ b/Claunia.IO/Interop/FreeBSD/Interop.FreeBSD.uname.cs @@ -69,7 +69,7 @@ internal static partial class Interop /// /// . /// On success, 0. On failure, -1, and errno is set. - [DllImport("libc", SetLastError = true)] + [DllImport(Libraries.Libc, SetLastError = true)] internal static extern int uname(out utsname name); } } diff --git a/Claunia.IO/Interop/Linux/Interop.Linux.Libraries.cs b/Claunia.IO/Interop/Linux/Interop.Linux.Libraries.cs index 77de514..860a79f 100644 --- a/Claunia.IO/Interop/Linux/Interop.Linux.Libraries.cs +++ b/Claunia.IO/Interop/Linux/Interop.Linux.Libraries.cs @@ -32,5 +32,4 @@ internal static partial class Interop internal const string Libc = "libc"; } } -} - +} \ No newline at end of file diff --git a/Claunia.IO/Interop/Linux/Interop.Linux.stat.cs b/Claunia.IO/Interop/Linux/Interop.Linux.stat.cs index d699623..972ffdb 100644 --- a/Claunia.IO/Interop/Linux/Interop.Linux.stat.cs +++ b/Claunia.IO/Interop/Linux/Interop.Linux.stat.cs @@ -23,8 +23,25 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.Runtime.InteropServices; using System; +using System.Runtime.InteropServices; + +#region Linux 32-bit type definitions +using blkcnt_t = System.Int32; +using blksize_t = System.Int32; +using dev_t = System.UInt64; +using fsblkcnt_t = System.UInt32; +using fsfilcnt_t = System.UInt32; +using gid_t = System.UInt32; +using ino_t = System.UInt32; +using nlink_t = System.UInt32; +using off_t = System.Int32; +using size_t = System.UInt32; +using ssize_t = System.Int32; +using uid_t = System.UInt32; +using __fsword_t = System.UInt32; + +#endregion internal static partial class Interop { @@ -39,7 +56,7 @@ internal static partial class Interop /// /// ID of device containing file /// - UInt64 st_dev; + dev_t st_dev; /// /// padding /// @@ -47,7 +64,7 @@ internal static partial class Interop /// /// inode number /// - UInt32 st_ino; + ino_t st_ino; /// /// protection /// @@ -55,19 +72,19 @@ internal static partial class Interop /// /// number of hard links /// - UInt32 st_nlink; + nlink_t st_nlink; /// /// user ID of owner /// - UInt32 st_uid; + uid_t st_uid; /// /// group ID of owner /// - UInt32 st_gid; + gid_t st_gid; /// /// device ID (if special file) /// - UInt64 st_rdev; + dev_t st_rdev; /// /// padding /// @@ -75,15 +92,15 @@ internal static partial class Interop /// /// total size, in bytes /// - Int32 st_size; + off_t st_size; /// /// blocksize for filesystem I/O /// - Int32 st_blksize; + blksize_t st_blksize; /// /// number of 512B blocks allocated /// - Int32 st_blocks; + blkcnt_t st_blocks; /// /// time of last access /// diff --git a/Claunia.IO/Interop/Linux/Interop.Linux.stat64.cs b/Claunia.IO/Interop/Linux/Interop.Linux.stat64.cs index a48a722..986ba5f 100644 --- a/Claunia.IO/Interop/Linux/Interop.Linux.stat64.cs +++ b/Claunia.IO/Interop/Linux/Interop.Linux.stat64.cs @@ -23,8 +23,25 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.Runtime.InteropServices; using System; +using System.Runtime.InteropServices; + +#region Linux 64-bit type definitions +using blkcnt_t = System.Int64; +using blksize_t = System.Int64; +using dev_t = System.UInt64; +using fsblkcnt_t = System.UInt64; +using fsfilcnt_t = System.UInt64; +using gid_t = System.UInt32; +using ino_t = System.UInt64; +using nlink_t = System.UInt64; +using off_t = System.Int64; +using size_t = System.UInt64; +using ssize_t = System.Int64; +using uid_t = System.UInt32; +using __fsword_t = System.Int64; + +#endregion internal static partial class Interop { @@ -39,15 +56,15 @@ internal static partial class Interop /// /// ID of device containing file /// - UInt64 st_dev; + dev_t st_dev; /// /// inode number /// - UInt64 st_ino; + ino_t st_ino; /// /// number of hard links /// - UInt64 st_nlink; + nlink_t st_nlink; /// /// protection /// @@ -55,11 +72,11 @@ internal static partial class Interop /// /// user ID of owner /// - UInt32 st_uid; + uid_t st_uid; /// /// group ID of owner /// - UInt32 st_gid; + gid_t st_gid; /// /// padding /// @@ -67,19 +84,19 @@ internal static partial class Interop /// /// device ID (if special file) /// - UInt64 st_rdev; + dev_t st_rdev; /// /// total size, in bytes /// - Int64 st_size; + off_t st_size; /// /// blocksize for filesystem I/O /// - Int64 st_blksize; + blksize_t st_blksize; /// /// number of 512B blocks allocated /// - Int64 st_blocks; + blkcnt_t st_blocks; /// /// time of last access /// diff --git a/Claunia.IO/Interop/Linux/Interop.Linux.statfs.cs b/Claunia.IO/Interop/Linux/Interop.Linux.statfs.cs index e3c3855..1bbdf85 100644 --- a/Claunia.IO/Interop/Linux/Interop.Linux.statfs.cs +++ b/Claunia.IO/Interop/Linux/Interop.Linux.statfs.cs @@ -23,8 +23,25 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.Runtime.InteropServices; using System; +using System.Runtime.InteropServices; + +#region Linux 32-bit type definitions +using blkcnt_t = System.Int32; +using blksize_t = System.Int32; +using dev_t = System.UInt64; +using fsblkcnt_t = System.UInt32; +using fsfilcnt_t = System.UInt32; +using gid_t = System.UInt32; +using ino_t = System.UInt32; +using nlink_t = System.UInt32; +using off_t = System.Int32; +using size_t = System.UInt32; +using ssize_t = System.Int32; +using uid_t = System.UInt32; +using __fsword_t = System.UInt32; + +#endregion internal static partial class Interop { @@ -39,31 +56,31 @@ internal static partial class Interop /// /// Type of filesystem (see below) /// - Int32 f_type; + __fsword_t f_type; /// /// Optimal transfer block size /// - Int32 f_bsize; + __fsword_t f_bsize; /// /// Total data blocks in filesystem /// - UInt32 f_blocks; + fsblkcnt_t f_blocks; /// /// Free blocks in filesystem /// - UInt32 f_bfree; + fsblkcnt_t f_bfree; /// /// Free blocks available to unprivileged user /// - UInt32 f_bavail; + fsblkcnt_t f_bavail; /// /// Total file nodes in filesystem /// - UInt32 f_files; + fsfilcnt_t f_files; /// /// Free file nodes in filesystem /// - UInt32 f_ffree; + fsfilcnt_t f_ffree; /// /// Filesystem ID /// @@ -71,11 +88,11 @@ internal static partial class Interop /// /// Maximum length of filenames /// - Int32 f_namelen; + __fsword_t f_namelen; /// /// Fragment size (since Linux 2.6) /// - Int32 f_frsize; + __fsword_t f_frsize; /// /// Mount flags of filesystem (since Linux 2.6.36) /// @@ -85,7 +102,7 @@ internal static partial class Interop /// [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.I4, SizeConst = 4)] - Int32[] f_spare; + __fsword_t[] f_spare; } /// diff --git a/Claunia.IO/Interop/Linux/Interop.Linux.statfs64.cs b/Claunia.IO/Interop/Linux/Interop.Linux.statfs64.cs index 4126074..27e194b 100644 --- a/Claunia.IO/Interop/Linux/Interop.Linux.statfs64.cs +++ b/Claunia.IO/Interop/Linux/Interop.Linux.statfs64.cs @@ -23,8 +23,25 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.Runtime.InteropServices; using System; +using System.Runtime.InteropServices; + +#region Linux 64-bit type definitions +using blkcnt_t = System.Int64; +using blksize_t = System.Int64; +using dev_t = System.UInt64; +using fsblkcnt_t = System.UInt64; +using fsfilcnt_t = System.UInt64; +using gid_t = System.UInt32; +using ino_t = System.UInt64; +using nlink_t = System.UInt64; +using off_t = System.Int64; +using size_t = System.UInt64; +using ssize_t = System.Int64; +using uid_t = System.UInt32; +using __fsword_t = System.Int64; + +#endregion internal static partial class Interop { @@ -39,31 +56,31 @@ internal static partial class Interop /// /// Type of filesystem (see below) /// - Int64 f_type; + __fsword_t f_type; /// /// Optimal transfer block size /// - Int64 f_bsize; + __fsword_t f_bsize; /// /// Total data blocks in filesystem /// - UInt64 f_blocks; + fsblkcnt_t f_blocks; /// /// Free blocks in filesystem /// - UInt64 f_bfree; + fsblkcnt_t f_bfree; /// /// Free blocks available to unprivileged user /// - UInt64 f_bavail; + fsblkcnt_t f_bavail; /// /// Total file nodes in filesystem /// - UInt64 f_files; + fsfilcnt_t f_files; /// /// Free file nodes in filesystem /// - UInt64 f_ffree; + fsfilcnt_t f_ffree; /// /// Filesystem ID /// @@ -71,11 +88,11 @@ internal static partial class Interop /// /// Maximum length of filenames /// - Int64 f_namelen; + __fsword_t f_namelen; /// /// Fragment size (since Linux 2.6) /// - Int64 f_frsize; + __fsword_t f_frsize; /// /// Mount flags of filesystem (since Linux 2.6.36) /// @@ -85,7 +102,7 @@ internal static partial class Interop /// [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.I8, SizeConst = 4)] - Int64[] f_spare; + __fsword_t[] f_spare; } /// diff --git a/Claunia.IO/Interop/Linux/Interop.Linux.types.cs b/Claunia.IO/Interop/Linux/Interop.Linux.types.cs index 2e39e20..995c214 100644 --- a/Claunia.IO/Interop/Linux/Interop.Linux.types.cs +++ b/Claunia.IO/Interop/Linux/Interop.Linux.types.cs @@ -23,8 +23,8 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.Runtime.InteropServices; using System; +using System.Runtime.InteropServices; internal static partial class Interop { diff --git a/Claunia.IO/Interop/Linux/Interop.Linux.xattr.cs b/Claunia.IO/Interop/Linux/Interop.Linux.xattr.cs index c8909da..915488b 100644 --- a/Claunia.IO/Interop/Linux/Interop.Linux.xattr.cs +++ b/Claunia.IO/Interop/Linux/Interop.Linux.xattr.cs @@ -26,6 +26,23 @@ using System; using System.Runtime.InteropServices; +#region Linux 32-bit type definitions +using blkcnt_t = System.Int32; +using blksize_t = System.Int32; +using dev_t = System.UInt64; +using fsblkcnt_t = System.UInt32; +using fsfilcnt_t = System.UInt32; +using gid_t = System.UInt32; +using ino_t = System.UInt32; +using nlink_t = System.UInt32; +using off_t = System.Int32; +using size_t = System.UInt32; +using ssize_t = System.Int32; +using uid_t = System.UInt32; +using __fsword_t = System.UInt32; + +#endregion + internal static partial class Interop { internal static partial class Linux @@ -40,7 +57,7 @@ internal static partial class Interop /// Size of the allocated buffer. /// Size of the extended attribute. On failure, -1, and errno is set [DllImport(Libraries.Libc, SetLastError = true, EntryPoint = "getxattr", CharSet = CharSet.Ansi)] - public static extern int getxattr32(string path, string name, IntPtr value, UInt32 size); + public static extern ssize_t getxattr32(string path, string name, IntPtr value, size_t size); /// /// Sets an extended attribute value @@ -52,7 +69,7 @@ internal static partial class Interop /// Size of the allocated buffer. /// On success, 0. On failure, -1, and errno is set [DllImport(Libraries.Libc, SetLastError = true, EntryPoint = "setxattr", CharSet = CharSet.Ansi)] - public static extern int setxattr32(string path, string name, IntPtr value, UInt32 size, xattrFlags options); + public static extern ssize_t setxattr32(string path, string name, IntPtr value, size_t size, xattrFlags options); /// /// Removes an extended attribute @@ -62,7 +79,7 @@ internal static partial class Interop /// Name of the extended attribute. /// On success, 0. On failure, -1, and errno is set [DllImport(Libraries.Libc, SetLastError = true, EntryPoint = "removexattr", CharSet = CharSet.Ansi)] - public static extern int removexattr32(string path, string name); + public static extern ssize_t removexattr32(string path, string name); /// /// Lists the extended attributes from a file @@ -76,7 +93,7 @@ internal static partial class Interop /// If the file has no extended attributes, 0. /// On failure, -1, and errno is set [DllImport(Libraries.Libc, SetLastError = true, EntryPoint = "listxattr", CharSet = CharSet.Ansi)] - public static extern int listxattr32(string path, IntPtr namebuf, UInt32 size); + public static extern ssize_t listxattr32(string path, IntPtr namebuf, size_t size); } } diff --git a/Claunia.IO/Interop/Linux/Interop.Linux.xattr64.cs b/Claunia.IO/Interop/Linux/Interop.Linux.xattr64.cs index a698a05..23fd5bd 100644 --- a/Claunia.IO/Interop/Linux/Interop.Linux.xattr64.cs +++ b/Claunia.IO/Interop/Linux/Interop.Linux.xattr64.cs @@ -26,6 +26,23 @@ using System; using System.Runtime.InteropServices; +#region Linux 64-bit type definitions +using blkcnt_t = System.Int64; +using blksize_t = System.Int64; +using dev_t = System.UInt64; +using fsblkcnt_t = System.UInt64; +using fsfilcnt_t = System.UInt64; +using gid_t = System.UInt32; +using ino_t = System.UInt64; +using nlink_t = System.UInt64; +using off_t = System.Int64; +using size_t = System.UInt64; +using ssize_t = System.Int64; +using uid_t = System.UInt32; +using __fsword_t = System.Int64; + +#endregion + internal static partial class Interop { internal static partial class Linux @@ -40,7 +57,7 @@ internal static partial class Interop /// Size of the allocated buffer. /// Size of the extended attribute. On failure, -1, and errno is set [DllImport(Libraries.Libc, SetLastError = true, CharSet = CharSet.Ansi)] - public static extern Int64 getxattr(string path, string name, IntPtr value, UInt64 size); + public static extern ssize_t getxattr(string path, string name, IntPtr value, size_t size); /// /// Sets an extended attribute value @@ -52,7 +69,7 @@ internal static partial class Interop /// Size of the allocated buffer. /// On success, 0. On failure, -1, and errno is set [DllImport(Libraries.Libc, SetLastError = true, CharSet = CharSet.Ansi)] - public static extern Int64 setxattr(string path, string name, IntPtr value, UInt64 size, xattrFlags options); + public static extern ssize_t setxattr(string path, string name, IntPtr value, size_t size, xattrFlags options); /// /// Removes an extended attribute @@ -62,7 +79,7 @@ internal static partial class Interop /// Name of the extended attribute. /// On success, 0. On failure, -1, and errno is set [DllImport(Libraries.Libc, SetLastError = true, CharSet = CharSet.Ansi)] - public static extern Int64 removexattr(string path, string name); + public static extern ssize_t removexattr(string path, string name); /// /// Lists the extended attributes from a file @@ -76,6 +93,6 @@ internal static partial class Interop /// If the file has no extended attributes, 0. /// On failure, -1, and errno is set [DllImport(Libraries.Libc, SetLastError = true, CharSet = CharSet.Ansi)] - public static extern Int64 listxattr(string path, IntPtr namebuf, UInt64 size); + public static extern ssize_t listxattr(string path, IntPtr namebuf, size_t size); } } \ No newline at end of file