blob: 69e39b30d2f1af8eedbd0b887c68c69cf9835348 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
internal static partial class Interop
{
internal static partial class Sys
{
internal enum FileAdvice : int
{
POSIX_FADV_NORMAL = 0, /* no special advice, the default value */
POSIX_FADV_RANDOM = 1, /* random I/O access */
POSIX_FADV_SEQUENTIAL = 2, /* sequential I/O access */
POSIX_FADV_WILLNEED = 3, /* will need specified pages */
POSIX_FADV_DONTNEED = 4, /* don't need the specified pages */
POSIX_FADV_NOREUSE = 5, /* data will only be acessed once */
}
/// <summary>
/// Notifies the OS kernel that the specified file will be accessed in a particular way soon; this allows the kernel to
/// potentially optimize the access pattern of the file.
/// </summary>
/// <param name="fd">The file descriptor of the file</param>
/// <param name="offset">The start of the region to advise about</param>
/// <param name="length">The number of bytes of the region (until the end of the file if 0)</param>
/// <param name="advice">The type of advice to give the kernel about the specified region</param>
/// <returns>
/// Returns 0 on success; otherwise, the error code is returned
/// </returns>
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PosixFAdvise", SetLastError = false /* this is explicitly called out in the man page */)]
internal static extern int PosixFAdvise(SafeFileHandle fd, long offset, long length, FileAdvice advice);
}
}
|