ReactOS  0.4.15-dev-1018-g0695ecb
fileinfo.c File Reference
#include "btrfs_drv.h"
#include "crc32c.h"
Include dependency graph for fileinfo.c:

Go to the source code of this file.

Classes

struct  _FILE_ID_INFORMATION
 
struct  _FILE_STAT_INFORMATION
 
struct  _FILE_STAT_LX_INFORMATION
 
struct  _FILE_RENAME_INFORMATION_EX
 
struct  _FILE_DISPOSITION_INFORMATION_EX
 
struct  _FILE_LINK_INFORMATION_EX
 
struct  _FILE_CASE_SENSITIVE_INFORMATION
 
struct  _FILE_LINK_ENTRY_FULL_ID_INFORMATION
 
struct  _FILE_LINKS_FULL_ID_INFORMATION
 
struct  _move_entry
 

Macros

#define FileIdInformation   (enum _FILE_INFORMATION_CLASS)59
 
#define FileHardLinkFullIdInformation   (enum _FILE_INFORMATION_CLASS)62
 
#define FileDispositionInformationEx   (enum _FILE_INFORMATION_CLASS)64
 
#define FileRenameInformationEx   (enum _FILE_INFORMATION_CLASS)65
 
#define FileStatInformation   (enum _FILE_INFORMATION_CLASS)68
 
#define FileStatLxInformation   (enum _FILE_INFORMATION_CLASS)70
 
#define FileCaseSensitiveInformation   (enum _FILE_INFORMATION_CLASS)71
 
#define FileLinkInformationEx   (enum _FILE_INFORMATION_CLASS)72
 
#define FileStorageReserveIdInformation   (enum _FILE_INFORMATION_CLASS)74
 
#define LX_FILE_METADATA_HAS_UID   0x01
 
#define LX_FILE_METADATA_HAS_GID   0x02
 
#define LX_FILE_METADATA_HAS_MODE   0x04
 
#define LX_FILE_METADATA_HAS_DEVICE_ID   0x08
 
#define LX_FILE_CASE_SENSITIVE_DIR   0x10
 
#define FILE_RENAME_REPLACE_IF_EXISTS   0x001
 
#define FILE_RENAME_POSIX_SEMANTICS   0x002
 
#define FILE_RENAME_SUPPRESS_PIN_STATE_INHERITANCE   0x004
 
#define FILE_RENAME_SUPPRESS_STORAGE_RESERVE_INHERITANCE   0x008
 
#define FILE_RENAME_NO_INCREASE_AVAILABLE_SPACE   0x010
 
#define FILE_RENAME_NO_DECREASE_AVAILABLE_SPACE   0x020
 
#define FILE_RENAME_IGNORE_READONLY_ATTRIBUTE   0x040
 
#define FILE_RENAME_FORCE_RESIZE_TARGET_SR   0x080
 
#define FILE_RENAME_FORCE_RESIZE_SOURCE_SR   0x100
 
#define FILE_DISPOSITION_DELETE   0x1
 
#define FILE_DISPOSITION_POSIX_SEMANTICS   0x2
 
#define FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK   0x4
 
#define FILE_DISPOSITION_ON_CLOSE   0x8
 
#define FILE_LINK_REPLACE_IF_EXISTS   0x001
 
#define FILE_LINK_POSIX_SEMANTICS   0x002
 
#define FILE_LINK_SUPPRESS_STORAGE_RESERVE_INHERITANCE   0x008
 
#define FILE_LINK_NO_INCREASE_AVAILABLE_SPACE   0x010
 
#define FILE_LINK_NO_DECREASE_AVAILABLE_SPACE   0x020
 
#define FILE_LINK_IGNORE_READONLY_ATTRIBUTE   0x040
 
#define FILE_LINK_FORCE_RESIZE_TARGET_SR   0x080
 
#define FILE_LINK_FORCE_RESIZE_SOURCE_SR   0x100
 

Typedefs

typedef struct _FILE_ID_INFORMATION FILE_ID_INFORMATION
 
typedef struct _FILE_ID_INFORMATIONPFILE_ID_INFORMATION
 
typedef struct _FILE_STAT_INFORMATION FILE_STAT_INFORMATION
 
typedef struct _FILE_STAT_INFORMATIONPFILE_STAT_INFORMATION
 
typedef struct _FILE_STAT_LX_INFORMATION FILE_STAT_LX_INFORMATION
 
typedef struct _FILE_STAT_LX_INFORMATIONPFILE_STAT_LX_INFORMATION
 
typedef struct _FILE_RENAME_INFORMATION_EX FILE_RENAME_INFORMATION_EX
 
typedef struct _FILE_RENAME_INFORMATION_EXPFILE_RENAME_INFORMATION_EX
 
typedef struct _FILE_DISPOSITION_INFORMATION_EX FILE_DISPOSITION_INFORMATION_EX
 
typedef struct _FILE_DISPOSITION_INFORMATION_EXPFILE_DISPOSITION_INFORMATION_EX
 
typedef struct _FILE_LINK_INFORMATION_EX FILE_LINK_INFORMATION_EX
 
typedef struct _FILE_LINK_INFORMATION_EXPFILE_LINK_INFORMATION_EX
 
typedef struct _FILE_CASE_SENSITIVE_INFORMATION FILE_CASE_SENSITIVE_INFORMATION
 
typedef struct _FILE_CASE_SENSITIVE_INFORMATIONPFILE_CASE_SENSITIVE_INFORMATION
 
typedef struct _FILE_LINK_ENTRY_FULL_ID_INFORMATION FILE_LINK_ENTRY_FULL_ID_INFORMATION
 
typedef struct _FILE_LINK_ENTRY_FULL_ID_INFORMATIONPFILE_LINK_ENTRY_FULL_ID_INFORMATION
 
typedef struct _FILE_LINKS_FULL_ID_INFORMATION FILE_LINKS_FULL_ID_INFORMATION
 
typedef struct _FILE_LINKS_FULL_ID_INFORMATIONPFILE_LINKS_FULL_ID_INFORMATION
 
typedef struct _move_entry move_entry
 

Functions

static NTSTATUS set_basic_information (device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject)
 
static NTSTATUS set_disposition_information (device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject, bool ex)
 
bool has_open_children (file_ref *fileref)
 
static NTSTATUS duplicate_fcb (fcb *oldfcb, fcb **pfcb)
 
static NTSTATUS add_children_to_move_list (device_extension *Vcb, move_entry *me, PIRP Irp)
 
void remove_dir_child_from_hash_lists (fcb *fcb, dir_child *dc)
 
static NTSTATUS create_directory_fcb (device_extension *Vcb, root *r, fcb *parfcb, fcb **pfcb)
 
static NTSTATUS move_across_subvols (file_ref *fileref, ccb *ccb, file_ref *destdir, PANSI_STRING utf8, PUNICODE_STRING fnus, PIRP Irp, LIST_ENTRY *rollback)
 
void insert_dir_child_into_hash_lists (fcb *fcb, dir_child *dc)
 
static NTSTATUS rename_stream_to_file (device_extension *Vcb, file_ref *fileref, ccb *ccb, ULONG flags, PIRP Irp, LIST_ENTRY *rollback)
 
static NTSTATUS rename_stream (device_extension *Vcb, file_ref *fileref, ccb *ccb, FILE_RENAME_INFORMATION_EX *fri, ULONG flags, PIRP Irp, LIST_ENTRY *rollback)
 
static NTSTATUS rename_file_to_stream (device_extension *Vcb, file_ref *fileref, ccb *ccb, FILE_RENAME_INFORMATION_EX *fri, ULONG flags, PIRP Irp, LIST_ENTRY *rollback)
 
static NTSTATUS set_rename_information (device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject, PFILE_OBJECT tfo, bool ex)
 
NTSTATUS stream_set_end_of_file_information (device_extension *Vcb, uint16_t end, fcb *fcb, file_ref *fileref, bool advance_only)
 
static NTSTATUS set_end_of_file_information (device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject, bool advance_only, bool prealloc)
 
static NTSTATUS set_position_information (PFILE_OBJECT FileObject, PIRP Irp)
 
static NTSTATUS set_link_information (device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject, PFILE_OBJECT tfo, bool ex)
 
static NTSTATUS set_valid_data_length_information (device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject)
 
static NTSTATUS set_case_sensitive_information (PIRP Irp)
 
 _Dispatch_type_ (IRP_MJ_SET_INFORMATION)
 
static NTSTATUS fill_in_file_basic_information (FILE_BASIC_INFORMATION *fbi, INODE_ITEM *ii, LONG *length, fcb *fcb, file_ref *fileref)
 
static NTSTATUS fill_in_file_network_open_information (FILE_NETWORK_OPEN_INFORMATION *fnoi, fcb *fcb, file_ref *fileref, LONG *length)
 
static NTSTATUS fill_in_file_standard_information (FILE_STANDARD_INFORMATION *fsi, fcb *fcb, file_ref *fileref, LONG *length)
 
static NTSTATUS fill_in_file_internal_information (FILE_INTERNAL_INFORMATION *fii, fcb *fcb, LONG *length)
 
static NTSTATUS fill_in_file_ea_information (FILE_EA_INFORMATION *eai, fcb *fcb, LONG *length)
 
static NTSTATUS fill_in_file_position_information (FILE_POSITION_INFORMATION *fpi, PFILE_OBJECT FileObject, LONG *length)
 
NTSTATUS fileref_get_filename (file_ref *fileref, PUNICODE_STRING fn, USHORT *name_offset, ULONG *preqlen)
 
static NTSTATUS fill_in_file_name_information (FILE_NAME_INFORMATION *fni, fcb *fcb, file_ref *fileref, LONG *length)
 
static NTSTATUS fill_in_file_attribute_information (FILE_ATTRIBUTE_TAG_INFORMATION *ati, fcb *fcb, ccb *ccb, LONG *length)
 
static NTSTATUS fill_in_file_stream_information (FILE_STREAM_INFORMATION *fsi, file_ref *fileref, LONG *length)
 
static NTSTATUS fill_in_file_standard_link_information (FILE_STANDARD_LINK_INFORMATION *fsli, fcb *fcb, file_ref *fileref, LONG *length)
 
static NTSTATUS fill_in_hard_link_information (FILE_LINKS_INFORMATION *fli, file_ref *fileref, PIRP Irp, LONG *length)
 
static NTSTATUS fill_in_hard_link_full_id_information (FILE_LINKS_FULL_ID_INFORMATION *flfii, file_ref *fileref, PIRP Irp, LONG *length)
 
static NTSTATUS fill_in_file_id_information (FILE_ID_INFORMATION *fii, fcb *fcb, LONG *length)
 
static NTSTATUS fill_in_file_stat_information (FILE_STAT_INFORMATION *fsi, fcb *fcb, ccb *ccb, LONG *length)
 
static NTSTATUS fill_in_file_stat_lx_information (FILE_STAT_LX_INFORMATION *fsli, fcb *fcb, ccb *ccb, LONG *length)
 
static NTSTATUS fill_in_file_case_sensitive_information (FILE_CASE_SENSITIVE_INFORMATION *fcsi, fcb *fcb, LONG *length)
 
static NTSTATUS fill_in_file_compression_information (FILE_COMPRESSION_INFORMATION *fci, LONG *length, fcb *fcb)
 
static NTSTATUS query_info (device_extension *Vcb, PFILE_OBJECT FileObject, PIRP Irp)
 
 _Dispatch_type_ (IRP_MJ_QUERY_INFORMATION)
 
 _Dispatch_type_ (IRP_MJ_QUERY_EA)
 
 _Dispatch_type_ (IRP_MJ_SET_EA)
 

Macro Definition Documentation

◆ FILE_DISPOSITION_DELETE

#define FILE_DISPOSITION_DELETE   0x1

Definition at line 130 of file fileinfo.c.

◆ FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK

#define FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK   0x4

Definition at line 132 of file fileinfo.c.

◆ FILE_DISPOSITION_ON_CLOSE

#define FILE_DISPOSITION_ON_CLOSE   0x8

Definition at line 133 of file fileinfo.c.

◆ FILE_DISPOSITION_POSIX_SEMANTICS

#define FILE_DISPOSITION_POSIX_SEMANTICS   0x2

Definition at line 131 of file fileinfo.c.

◆ FILE_LINK_FORCE_RESIZE_SOURCE_SR

#define FILE_LINK_FORCE_RESIZE_SOURCE_SR   0x100

Definition at line 142 of file fileinfo.c.

◆ FILE_LINK_FORCE_RESIZE_TARGET_SR

#define FILE_LINK_FORCE_RESIZE_TARGET_SR   0x080

Definition at line 141 of file fileinfo.c.

◆ FILE_LINK_IGNORE_READONLY_ATTRIBUTE

#define FILE_LINK_IGNORE_READONLY_ATTRIBUTE   0x040

Definition at line 140 of file fileinfo.c.

◆ FILE_LINK_NO_DECREASE_AVAILABLE_SPACE

#define FILE_LINK_NO_DECREASE_AVAILABLE_SPACE   0x020

Definition at line 139 of file fileinfo.c.

◆ FILE_LINK_NO_INCREASE_AVAILABLE_SPACE

#define FILE_LINK_NO_INCREASE_AVAILABLE_SPACE   0x010

Definition at line 138 of file fileinfo.c.

◆ FILE_LINK_POSIX_SEMANTICS

#define FILE_LINK_POSIX_SEMANTICS   0x002

Definition at line 136 of file fileinfo.c.

◆ FILE_LINK_REPLACE_IF_EXISTS

#define FILE_LINK_REPLACE_IF_EXISTS   0x001

Definition at line 135 of file fileinfo.c.

◆ FILE_LINK_SUPPRESS_STORAGE_RESERVE_INHERITANCE

#define FILE_LINK_SUPPRESS_STORAGE_RESERVE_INHERITANCE   0x008

Definition at line 137 of file fileinfo.c.

◆ FILE_RENAME_FORCE_RESIZE_SOURCE_SR

#define FILE_RENAME_FORCE_RESIZE_SOURCE_SR   0x100

Definition at line 128 of file fileinfo.c.

◆ FILE_RENAME_FORCE_RESIZE_TARGET_SR

#define FILE_RENAME_FORCE_RESIZE_TARGET_SR   0x080

Definition at line 127 of file fileinfo.c.

◆ FILE_RENAME_IGNORE_READONLY_ATTRIBUTE

#define FILE_RENAME_IGNORE_READONLY_ATTRIBUTE   0x040

Definition at line 126 of file fileinfo.c.

◆ FILE_RENAME_NO_DECREASE_AVAILABLE_SPACE

#define FILE_RENAME_NO_DECREASE_AVAILABLE_SPACE   0x020

Definition at line 125 of file fileinfo.c.

◆ FILE_RENAME_NO_INCREASE_AVAILABLE_SPACE

#define FILE_RENAME_NO_INCREASE_AVAILABLE_SPACE   0x010

Definition at line 124 of file fileinfo.c.

◆ FILE_RENAME_POSIX_SEMANTICS

#define FILE_RENAME_POSIX_SEMANTICS   0x002

Definition at line 121 of file fileinfo.c.

◆ FILE_RENAME_REPLACE_IF_EXISTS

#define FILE_RENAME_REPLACE_IF_EXISTS   0x001

Definition at line 120 of file fileinfo.c.

◆ FILE_RENAME_SUPPRESS_PIN_STATE_INHERITANCE

#define FILE_RENAME_SUPPRESS_PIN_STATE_INHERITANCE   0x004

Definition at line 122 of file fileinfo.c.

◆ FILE_RENAME_SUPPRESS_STORAGE_RESERVE_INHERITANCE

#define FILE_RENAME_SUPPRESS_STORAGE_RESERVE_INHERITANCE   0x008

Definition at line 123 of file fileinfo.c.

◆ FileCaseSensitiveInformation

#define FileCaseSensitiveInformation   (enum _FILE_INFORMATION_CLASS)71

Definition at line 30 of file fileinfo.c.

◆ FileDispositionInformationEx

#define FileDispositionInformationEx   (enum _FILE_INFORMATION_CLASS)64

Definition at line 26 of file fileinfo.c.

◆ FileHardLinkFullIdInformation

#define FileHardLinkFullIdInformation   (enum _FILE_INFORMATION_CLASS)62

Definition at line 25 of file fileinfo.c.

◆ FileIdInformation

#define FileIdInformation   (enum _FILE_INFORMATION_CLASS)59

Definition at line 24 of file fileinfo.c.

◆ FileLinkInformationEx

#define FileLinkInformationEx   (enum _FILE_INFORMATION_CLASS)72

Definition at line 31 of file fileinfo.c.

◆ FileRenameInformationEx

#define FileRenameInformationEx   (enum _FILE_INFORMATION_CLASS)65

Definition at line 27 of file fileinfo.c.

◆ FileStatInformation

#define FileStatInformation   (enum _FILE_INFORMATION_CLASS)68

Definition at line 28 of file fileinfo.c.

◆ FileStatLxInformation

#define FileStatLxInformation   (enum _FILE_INFORMATION_CLASS)70

Definition at line 29 of file fileinfo.c.

◆ FileStorageReserveIdInformation

#define FileStorageReserveIdInformation   (enum _FILE_INFORMATION_CLASS)74

Definition at line 32 of file fileinfo.c.

◆ LX_FILE_CASE_SENSITIVE_DIR

#define LX_FILE_CASE_SENSITIVE_DIR   0x10

Definition at line 77 of file fileinfo.c.

◆ LX_FILE_METADATA_HAS_DEVICE_ID

#define LX_FILE_METADATA_HAS_DEVICE_ID   0x08

Definition at line 76 of file fileinfo.c.

◆ LX_FILE_METADATA_HAS_GID

#define LX_FILE_METADATA_HAS_GID   0x02

Definition at line 74 of file fileinfo.c.

◆ LX_FILE_METADATA_HAS_MODE

#define LX_FILE_METADATA_HAS_MODE   0x04

Definition at line 75 of file fileinfo.c.

◆ LX_FILE_METADATA_HAS_UID

#define LX_FILE_METADATA_HAS_UID   0x01

Definition at line 73 of file fileinfo.c.

Typedef Documentation

◆ FILE_CASE_SENSITIVE_INFORMATION

◆ FILE_DISPOSITION_INFORMATION_EX

◆ FILE_ID_INFORMATION

◆ FILE_LINK_ENTRY_FULL_ID_INFORMATION

◆ FILE_LINK_INFORMATION_EX

◆ FILE_LINKS_FULL_ID_INFORMATION

◆ FILE_RENAME_INFORMATION_EX

◆ FILE_STAT_INFORMATION

◆ FILE_STAT_LX_INFORMATION

◆ move_entry

◆ PFILE_CASE_SENSITIVE_INFORMATION

◆ PFILE_DISPOSITION_INFORMATION_EX

◆ PFILE_ID_INFORMATION

◆ PFILE_LINK_ENTRY_FULL_ID_INFORMATION

◆ PFILE_LINK_INFORMATION_EX

◆ PFILE_LINKS_FULL_ID_INFORMATION

◆ PFILE_RENAME_INFORMATION_EX

◆ PFILE_STAT_INFORMATION

◆ PFILE_STAT_LX_INFORMATION

Function Documentation

◆ _Dispatch_type_() [1/4]

_Dispatch_type_ ( IRP_MJ_SET_INFORMATION  )

Definition at line 3812 of file fileinfo.c.

3814  {
3815  NTSTATUS Status;
3818  fcb* fcb = IrpSp->FileObject->FsContext;
3819  ccb* ccb = IrpSp->FileObject->FsContext2;
3820  bool top_level;
3821 
3823 
3824  top_level = is_top_level(Irp);
3825 
3826  Irp->IoStatus.Information = 0;
3827 
3828  if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
3830  goto end;
3831  } else if (!Vcb || Vcb->type != VCB_TYPE_FS) {
3833  goto end;
3834  }
3835 
3836  if (!(Vcb->Vpb->Flags & VPB_MOUNTED)) {
3838  goto end;
3839  }
3840 
3841  if (Vcb->readonly && IrpSp->Parameters.SetFile.FileInformationClass != FilePositionInformation) {
3843  goto end;
3844  }
3845 
3846  if (!fcb) {
3847  ERR("no fcb\n");
3849  goto end;
3850  }
3851 
3852  if (!ccb) {
3853  ERR("no ccb\n");
3855  goto end;
3856  }
3857 
3858  if (fcb != Vcb->dummy_fcb && is_subvol_readonly(fcb->subvol, Irp) && IrpSp->Parameters.SetFile.FileInformationClass != FilePositionInformation &&
3859 #ifndef __REACTOS__
3860  (fcb->inode != SUBVOL_ROOT_INODE || (IrpSp->Parameters.SetFile.FileInformationClass != FileBasicInformation && IrpSp->Parameters.SetFile.FileInformationClass != FileRenameInformation && IrpSp->Parameters.SetFile.FileInformationClass != FileRenameInformationEx))) {
3861 #else
3862  (fcb->inode != SUBVOL_ROOT_INODE || (IrpSp->Parameters.SetFile.FileInformationClass != FileBasicInformation && IrpSp->Parameters.SetFile.FileInformationClass != FileRenameInformation))) {
3863 #endif
3865  goto end;
3866  }
3867 
3869 
3870  TRACE("set information\n");
3871 
3873 
3874  switch (IrpSp->Parameters.SetFile.FileInformationClass) {
3876  {
3877  TRACE("FileAllocationInformation\n");
3878 
3879  if (Irp->RequestorMode == UserMode && !(ccb->access & FILE_WRITE_DATA)) {
3880  WARN("insufficient privileges\n");
3882  break;
3883  }
3884 
3886  break;
3887  }
3888 
3889  case FileBasicInformation:
3890  {
3891  TRACE("FileBasicInformation\n");
3892 
3893  if (Irp->RequestorMode == UserMode && !(ccb->access & FILE_WRITE_ATTRIBUTES)) {
3894  WARN("insufficient privileges\n");
3896  break;
3897  }
3898 
3900 
3901  break;
3902  }
3903 
3905  {
3906  TRACE("FileDispositionInformation\n");
3907 
3908  if (Irp->RequestorMode == UserMode && !(ccb->access & DELETE)) {
3909  WARN("insufficient privileges\n");
3911  break;
3912  }
3913 
3915 
3916  break;
3917  }
3918 
3920  {
3921  TRACE("FileEndOfFileInformation\n");
3922 
3923  if (Irp->RequestorMode == UserMode && !(ccb->access & (FILE_WRITE_DATA | FILE_APPEND_DATA))) {
3924  WARN("insufficient privileges\n");
3926  break;
3927  }
3928 
3929  Status = set_end_of_file_information(Vcb, Irp, IrpSp->FileObject, IrpSp->Parameters.SetFile.AdvanceOnly, false);
3930 
3931  break;
3932  }
3933 
3934  case FileLinkInformation:
3935  TRACE("FileLinkInformation\n");
3936  Status = set_link_information(Vcb, Irp, IrpSp->FileObject, IrpSp->Parameters.SetFile.FileObject, false);
3937  break;
3938 
3940  TRACE("FilePositionInformation\n");
3942  break;
3943 
3944  case FileRenameInformation:
3945  TRACE("FileRenameInformation\n");
3946  Status = set_rename_information(Vcb, Irp, IrpSp->FileObject, IrpSp->Parameters.SetFile.FileObject, false);
3947  break;
3948 
3950  {
3951  TRACE("FileValidDataLengthInformation\n");
3952 
3953  if (Irp->RequestorMode == UserMode && !(ccb->access & (FILE_WRITE_DATA | FILE_APPEND_DATA))) {
3954  WARN("insufficient privileges\n");
3956  break;
3957  }
3958 
3960 
3961  break;
3962  }
3963 
3964 #ifndef __REACTOS__
3965 #ifndef _MSC_VER
3966 #pragma GCC diagnostic push
3967 #pragma GCC diagnostic ignored "-Wswitch"
3968 #endif
3970  {
3971  TRACE("FileDispositionInformationEx\n");
3972 
3973  if (Irp->RequestorMode == UserMode && !(ccb->access & DELETE)) {
3974  WARN("insufficient privileges\n");
3976  break;
3977  }
3978 
3980 
3981  break;
3982  }
3983 
3985  TRACE("FileRenameInformationEx\n");
3986  Status = set_rename_information(Vcb, Irp, IrpSp->FileObject, IrpSp->Parameters.SetFile.FileObject, true);
3987  break;
3988 
3989  case FileLinkInformationEx:
3990  TRACE("FileLinkInformationEx\n");
3991  Status = set_link_information(Vcb, Irp, IrpSp->FileObject, IrpSp->Parameters.SetFile.FileObject, true);
3992  break;
3993 
3995  TRACE("FileCaseSensitiveInformation\n");
3996 
3997  if (Irp->RequestorMode == UserMode && !(ccb->access & FILE_WRITE_ATTRIBUTES)) {
3998  WARN("insufficient privileges\n");
4000  break;
4001  }
4002 
4004  break;
4005 
4007  WARN("unimplemented FileInformationClass FileStorageReserveIdInformation\n");
4008  break;
4009 
4010 #ifndef _MSC_VER
4011 #pragma GCC diagnostic pop
4012 #endif
4013 #endif
4014 
4015  default:
4016  WARN("unknown FileInformationClass %u\n", IrpSp->Parameters.SetFile.FileInformationClass);
4017  }
4018 
4019 end:
4020  Irp->IoStatus.Status = Status;
4021 
4022  TRACE("returning %08lx\n", Status);
4023 
4025 
4026  if (top_level)
4028 
4030 
4031  return Status;
4032 }
static NTSTATUS set_basic_information(device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject)
Definition: fileinfo.c:190
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
static NTSTATUS set_case_sensitive_information(PIRP Irp)
Definition: fileinfo.c:3779
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define SUBVOL_ROOT_INODE
Definition: propsheet.cpp:42
#define WARN(fmt,...)
Definition: debug.h:112
LONG NTSTATUS
Definition: precomp.h:26
#define VCB_TYPE_FS
Definition: btrfs_drv.h:695
#define FileDispositionInformationEx
Definition: fileinfo.c:26
GLuint GLuint end
Definition: gl.h:1545
ACCESS_MASK access
Definition: btrfs_drv.h:398
#define FILE_APPEND_DATA
Definition: nt_native.h:634
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:279
#define FileStorageReserveIdInformation
Definition: fileinfo.c:32
static NTSTATUS set_valid_data_length_information(device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject)
Definition: fileinfo.c:3683
#define FILE_WRITE_ATTRIBUTES
Definition: nt_native.h:649
static NTSTATUS set_position_information(PFILE_OBJECT FileObject, PIRP Irp)
Definition: fileinfo.c:3322
static __inline bool is_subvol_readonly(root *r, PIRP Irp)
Definition: btrfs_drv.h:1041
static NTSTATUS set_disposition_information(device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject, bool ex)
Definition: fileinfo.c:357
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define TRACE(s)
Definition: solgame.cpp:4
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:697
uint64_t inode
Definition: btrfs_drv.h:300
#define Vcb
Definition: cdprocs.h:1415
static NTSTATUS set_rename_information(device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject, PFILE_OBJECT tfo, bool ex)
Definition: fileinfo.c:2454
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
static NTSTATUS set_end_of_file_information(device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject, bool advance_only, bool prealloc)
Definition: fileinfo.c:3177
static NTSTATUS set_link_information(device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject, PFILE_OBJECT tfo, bool ex)
Definition: fileinfo.c:3334
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
NTSTATUS vol_set_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:312
#define ERR(fmt,...)
Definition: debug.h:110
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PFILE_OBJECT FileObject
Definition: iotypes.h:2820
#define FileRenameInformationEx
Definition: fileinfo.c:27
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
struct _root * subvol
Definition: btrfs_drv.h:299
static __inline POPLOCK fcb_oplock(fcb *fcb)
Definition: btrfs_drv.h:1683
#define FileLinkInformationEx
Definition: fileinfo.c:31
#define IO_NO_INCREMENT
Definition: iotypes.h:570
NTSTATUS NTAPI FsRtlCheckOplock(IN POPLOCK Oplock, IN PIRP Irp, IN PVOID Context, IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL)
Definition: oplock.c:1172
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2779
#define VPB_MOUNTED
Definition: iotypes.h:1771
#define DELETE
Definition: nt_native.h:57
#define FileCaseSensitiveInformation
Definition: fileinfo.c:30

◆ _Dispatch_type_() [2/4]

_Dispatch_type_ ( IRP_MJ_QUERY_INFORMATION  )

Definition at line 5334 of file fileinfo.c.

5336  {
5338  NTSTATUS Status;
5339  fcb* fcb;
5341  bool top_level;
5342 
5344 
5345  top_level = is_top_level(Irp);
5346 
5347  if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
5349  goto end;
5350  } else if (!Vcb || Vcb->type != VCB_TYPE_FS) {
5352  goto end;
5353  }
5354 
5355  Irp->IoStatus.Information = 0;
5356 
5357  TRACE("query information\n");
5358 
5360 
5361  fcb = IrpSp->FileObject->FsContext;
5362  TRACE("fcb = %p\n", fcb);
5363  TRACE("fcb->subvol = %p\n", fcb->subvol);
5364 
5366 
5367 end:
5368  TRACE("returning %08lx\n", Status);
5369 
5370  Irp->IoStatus.Status = Status;
5371 
5373 
5374  if (top_level)
5376 
5378 
5379  return Status;
5380 }
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define VCB_TYPE_FS
Definition: btrfs_drv.h:695
GLuint GLuint end
Definition: gl.h:1545
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:279
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
#define TRACE(s)
Definition: solgame.cpp:4
struct _fcb fcb
Definition: btrfs_drv.h:1357
NTSTATUS vol_query_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:306
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:697
#define Vcb
Definition: cdprocs.h:1415
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PFILE_OBJECT FileObject
Definition: iotypes.h:2820
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
struct _root * subvol
Definition: btrfs_drv.h:299
#define IO_NO_INCREMENT
Definition: iotypes.h:570
static NTSTATUS query_info(device_extension *Vcb, PFILE_OBJECT FileObject, PIRP Irp)
Definition: fileinfo.c:4958
struct _device_extension * Vcb
Definition: btrfs_drv.h:298

◆ _Dispatch_type_() [3/4]

_Dispatch_type_ ( IRP_MJ_QUERY_EA  )

Definition at line 5382 of file fileinfo.c.

5384  {
5385  NTSTATUS Status;
5386  bool top_level;
5390  fcb* fcb;
5391  ccb* ccb;
5393  ULONG retlen = 0;
5394 
5396 
5397  TRACE("(%p, %p)\n", DeviceObject, Irp);
5398 
5399  top_level = is_top_level(Irp);
5400 
5401  if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
5403  goto end;
5404  } else if (!Vcb || Vcb->type != VCB_TYPE_FS) {
5406  goto end;
5407  }
5408 
5410  if (!ffei) {
5411  ERR("could not get output buffer\n");
5413  goto end;
5414  }
5415 
5416  if (!FileObject) {
5417  ERR("no file object\n");
5419  goto end;
5420  }
5421 
5422  fcb = FileObject->FsContext;
5423 
5424  if (!fcb) {
5425  ERR("no fcb\n");
5427  goto end;
5428  }
5429 
5430  ccb = FileObject->FsContext2;
5431 
5432  if (!ccb) {
5433  ERR("no ccb\n");
5435  goto end;
5436  }
5437 
5438  if (Irp->RequestorMode == UserMode && !(ccb->access & (FILE_READ_EA | FILE_WRITE_EA))) {
5439  WARN("insufficient privileges\n");
5441  goto end;
5442  }
5443 
5444  if (fcb->ads)
5445  fcb = ccb->fileref->parent->fcb;
5446 
5447  ExAcquireResourceSharedLite(fcb->Header.Resource, true);
5448 
5450 
5451  if (fcb->ea_xattr.Length == 0)
5452  goto end2;
5453 
5454  if (IrpSp->Parameters.QueryEa.EaList) {
5457 
5458  in = IrpSp->Parameters.QueryEa.EaList;
5459  do {
5460  STRING s;
5461 
5462  s.Length = s.MaximumLength = in->EaNameLength;
5463  s.Buffer = in->EaName;
5464 
5465  RtlUpperString(&s, &s);
5466 
5467  if (in->NextEntryOffset == 0)
5468  break;
5469 
5470  in = (FILE_GET_EA_INFORMATION*)(((uint8_t*)in) + in->NextEntryOffset);
5471  } while (true);
5472 
5474  out = NULL;
5475 
5476  do {
5477  bool found = false;
5478 
5479  in = IrpSp->Parameters.QueryEa.EaList;
5480  do {
5481  if (in->EaNameLength == ea->EaNameLength &&
5482  RtlCompareMemory(in->EaName, ea->EaName, in->EaNameLength) == in->EaNameLength) {
5483  found = true;
5484  break;
5485  }
5486 
5487  if (in->NextEntryOffset == 0)
5488  break;
5489 
5490  in = (FILE_GET_EA_INFORMATION*)(((uint8_t*)in) + in->NextEntryOffset);
5491  } while (true);
5492 
5493  if (found) {
5494  uint8_t padding = retlen % 4 > 0 ? (4 - (retlen % 4)) : 0;
5495 
5496  if (offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + ea->EaNameLength + 1 + ea->EaValueLength > IrpSp->Parameters.QueryEa.Length - retlen - padding) {
5498  retlen = 0;
5499  goto end2;
5500  }
5501 
5502  retlen += padding;
5503 
5504  if (out) {
5505  out->NextEntryOffset = (ULONG)offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + out->EaNameLength + 1 + out->EaValueLength + padding;
5506  out = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)out) + out->NextEntryOffset);
5507  } else
5508  out = ffei;
5509 
5510  out->NextEntryOffset = 0;
5511  out->Flags = ea->Flags;
5512  out->EaNameLength = ea->EaNameLength;
5513  out->EaValueLength = ea->EaValueLength;
5514  RtlCopyMemory(out->EaName, ea->EaName, ea->EaNameLength + ea->EaValueLength + 1);
5515 
5516  retlen += (ULONG)offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + ea->EaNameLength + 1 + ea->EaValueLength;
5517 
5519  break;
5520  }
5521 
5522  if (ea->NextEntryOffset == 0)
5523  break;
5524 
5525  ea = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)ea) + ea->NextEntryOffset);
5526  } while (true);
5527  } else {
5529  ULONG index;
5530 
5531  if (IrpSp->Flags & SL_INDEX_SPECIFIED) {
5532  // The index is 1-based
5533  if (IrpSp->Parameters.QueryEa.EaIndex == 0) {
5535  goto end2;
5536  } else
5537  index = IrpSp->Parameters.QueryEa.EaIndex - 1;
5538  } else if (IrpSp->Flags & SL_RESTART_SCAN)
5539  index = ccb->ea_index = 0;
5540  else
5541  index = ccb->ea_index;
5542 
5544 
5545  if (index > 0) {
5546  ULONG i;
5547 
5548  for (i = 0; i < index; i++) {
5549  if (ea->NextEntryOffset == 0) // last item
5550  goto end2;
5551 
5552  ea = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)ea) + ea->NextEntryOffset);
5553  }
5554  }
5555 
5556  out = NULL;
5557 
5558  do {
5559  uint8_t padding = retlen % 4 > 0 ? (4 - (retlen % 4)) : 0;
5560 
5561  if (offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + ea->EaNameLength + 1 + ea->EaValueLength > IrpSp->Parameters.QueryEa.Length - retlen - padding) {
5563  goto end2;
5564  }
5565 
5566  retlen += padding;
5567 
5568  if (out) {
5569  out->NextEntryOffset = (ULONG)offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + out->EaNameLength + 1 + out->EaValueLength + padding;
5570  out = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)out) + out->NextEntryOffset);
5571  } else
5572  out = ffei;
5573 
5574  out->NextEntryOffset = 0;
5575  out->Flags = ea->Flags;
5576  out->EaNameLength = ea->EaNameLength;
5577  out->EaValueLength = ea->EaValueLength;
5578  RtlCopyMemory(out->EaName, ea->EaName, ea->EaNameLength + ea->EaValueLength + 1);
5579 
5580  retlen += (ULONG)offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + ea->EaNameLength + 1 + ea->EaValueLength;
5581 
5582  if (!(IrpSp->Flags & SL_INDEX_SPECIFIED))
5583  ccb->ea_index++;
5584 
5586  break;
5587 
5588  ea = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)ea) + ea->NextEntryOffset);
5589  } while (true);
5590  }
5591 
5592 end2:
5593  ExReleaseResourceLite(fcb->Header.Resource);
5594 
5595 end:
5596  TRACE("returning %08lx\n", Status);
5597 
5598  Irp->IoStatus.Status = Status;
5599  Irp->IoStatus.Information = NT_SUCCESS(Status) || Status == STATUS_BUFFER_OVERFLOW ? retlen : 0;
5600 
5602 
5603  if (top_level)
5605 
5607 
5608  return Status;
5609 }
struct _file_ref * parent
Definition: btrfs_drv.h:368
NTSYSAPI VOID NTAPI RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
#define FILE_WRITE_EA
Definition: nt_native.h:640
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define FsRtlEnterFileSystem
#define SL_INDEX_SPECIFIED
Definition: iotypes.h:1801
#define FsRtlExitFileSystem
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define WARN(fmt,...)
Definition: debug.h:112
LONG NTSTATUS
Definition: precomp.h:26
ANSI_STRING ea_xattr
Definition: btrfs_drv.h:313
#define VCB_TYPE_FS
Definition: btrfs_drv.h:695
GLuint GLuint end
Definition: gl.h:1545
ACCESS_MASK access
Definition: btrfs_drv.h:398
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:279
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define offsetof(TYPE, MEMBER)
#define IoCompleteRequest
Definition: irp.c:1240
GLuint index
Definition: glext.h:6031
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:588
ULONG ea_index
Definition: btrfs_drv.h:401
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:294
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int padding
Definition: isohybrid.c:50
struct _fcb fcb
Definition: btrfs_drv.h:1357
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NONEXISTENT_EA_ENTRY
Definition: ntstatus.h:317
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:697
#define Vcb
Definition: cdprocs.h:1415
static __inline void * map_user_buffer(PIRP Irp, ULONG priority)
Definition: btrfs_drv.h:985
static FILE * out
Definition: regtests2xml.c:44
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1962
std::wstring STRING
Definition: fontsub.cpp:33
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
#define index(s, c)
Definition: various.h:29
GLdouble s
Definition: gl.h:2039
BYTE uint8_t
Definition: msvideo1.c:66
#define ERR(fmt,...)
Definition: debug.h:110
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PFILE_OBJECT FileObject
Definition: iotypes.h:2820
#define SL_RETURN_SINGLE_ENTRY
Definition: iotypes.h:1800
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
GLuint in
Definition: glext.h:9616
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define FILE_READ_EA
Definition: nt_native.h:638
#define SL_RESTART_SCAN
Definition: iotypes.h:1799
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
bool ads
Definition: btrfs_drv.h:341
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:570
struct _ccb ccb
file_ref * fileref
Definition: btrfs_drv.h:399
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2779
return STATUS_SUCCESS
Definition: btrfs.c:3014
NTSTATUS vol_query_ea(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:318
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465

◆ _Dispatch_type_() [4/4]

_Dispatch_type_ ( IRP_MJ_SET_EA  )

Definition at line 5611 of file fileinfo.c.

5613  {
5615  NTSTATUS Status;
5616  bool top_level;
5619  fcb* fcb;
5620  ccb* ccb;
5621  file_ref* fileref;
5623  ULONG offset;
5624  LIST_ENTRY ealist;
5625  ea_item* item;
5627  LIST_ENTRY* le;
5629  BTRFS_TIME now;
5630 
5632 
5633  TRACE("(%p, %p)\n", DeviceObject, Irp);
5634 
5635  top_level = is_top_level(Irp);
5636 
5637  if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
5639  goto end;
5640  } else if (!Vcb || Vcb->type != VCB_TYPE_FS) {
5642  goto end;
5643  }
5644 
5645  if (Vcb->readonly) {
5647  goto end;
5648  }
5649 
5651  if (!ffei) {
5652  ERR("could not get output buffer\n");
5654  goto end;
5655  }
5656 
5657  Status = IoCheckEaBufferValidity(ffei, IrpSp->Parameters.SetEa.Length, &offset);
5658  if (!NT_SUCCESS(Status)) {
5659  ERR("IoCheckEaBufferValidity returned %08lx (error at offset %lu)\n", Status, offset);
5660  goto end;
5661  }
5662 
5663  if (!FileObject) {
5664  ERR("no file object\n");
5666  goto end;
5667  }
5668 
5669  fcb = FileObject->FsContext;
5670 
5671  if (!fcb) {
5672  ERR("no fcb\n");
5674  goto end;
5675  }
5676 
5677  ccb = FileObject->FsContext2;
5678 
5679  if (!ccb) {
5680  ERR("no ccb\n");
5682  goto end;
5683  }
5684 
5685  if (Irp->RequestorMode == UserMode && !(ccb->access & FILE_WRITE_EA)) {
5686  WARN("insufficient privileges\n");
5688  goto end;
5689  }
5690 
5691  if (fcb->ads) {
5692  fileref = ccb->fileref->parent;
5693  fcb = fileref->fcb;
5694  } else
5695  fileref = ccb->fileref;
5696 
5697  InitializeListHead(&ealist);
5698 
5699  ExAcquireResourceExclusiveLite(fcb->Header.Resource, true);
5700 
5701  if (fcb->ea_xattr.Length > 0) {
5703 
5704  do {
5706  if (!item) {
5707  ERR("out of memory\n");
5709  goto end2;
5710  }
5711 
5712  item->name.Length = item->name.MaximumLength = ea->EaNameLength;
5713  item->name.Buffer = ea->EaName;
5714 
5715  item->value.Length = item->value.MaximumLength = ea->EaValueLength;
5716  item->value.Buffer = &ea->EaName[ea->EaNameLength + 1];
5717 
5718  item->flags = ea->Flags;
5719 
5720  InsertTailList(&ealist, &item->list_entry);
5721 
5722  if (ea->NextEntryOffset == 0)
5723  break;
5724 
5725  ea = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)ea) + ea->NextEntryOffset);
5726  } while (true);
5727  }
5728 
5729  ea = ffei;
5730 
5731  do {
5732  STRING s;
5733  bool found = false;
5734 
5735  s.Length = s.MaximumLength = ea->EaNameLength;
5736  s.Buffer = ea->EaName;
5737 
5738  RtlUpperString(&s, &s);
5739 
5740  le = ealist.Flink;
5741  while (le != &ealist) {
5743 
5744  if (item->name.Length == s.Length &&
5745  RtlCompareMemory(item->name.Buffer, s.Buffer, s.Length) == s.Length) {
5746  item->flags = ea->Flags;
5747  item->value.Length = item->value.MaximumLength = ea->EaValueLength;
5748  item->value.Buffer = &ea->EaName[ea->EaNameLength + 1];
5749  found = true;
5750  break;
5751  }
5752 
5753  le = le->Flink;
5754  }
5755 
5756  if (!found) {
5758  if (!item) {
5759  ERR("out of memory\n");
5761  goto end2;
5762  }
5763 
5764  item->name.Length = item->name.MaximumLength = ea->EaNameLength;
5765  item->name.Buffer = ea->EaName;
5766 
5767  item->value.Length = item->value.MaximumLength = ea->EaValueLength;
5768  item->value.Buffer = &ea->EaName[ea->EaNameLength + 1];
5769 
5770  item->flags = ea->Flags;
5771 
5772  InsertTailList(&ealist, &item->list_entry);
5773  }
5774 
5775  if (ea->NextEntryOffset == 0)
5776  break;
5777 
5778  ea = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)ea) + ea->NextEntryOffset);
5779  } while (true);
5780 
5781  // remove entries with zero-length value
5782  le = ealist.Flink;
5783  while (le != &ealist) {
5784  LIST_ENTRY* le2 = le->Flink;
5785 
5787 
5788  if (item->value.Length == 0) {
5789  RemoveEntryList(&item->list_entry);
5790  ExFreePool(item);
5791  }
5792 
5793  le = le2;
5794  }
5795 
5796  // handle LXSS values
5797  le = ealist.Flink;
5798  while (le != &ealist) {
5799  LIST_ENTRY* le2 = le->Flink;
5800 
5802 
5803  if (item->name.Length == sizeof(lxuid) - 1 && RtlCompareMemory(item->name.Buffer, lxuid, item->name.Length) == item->name.Length) {
5804  if (item->value.Length < sizeof(uint32_t)) {
5805  ERR("uid value was shorter than expected\n");
5807  goto end2;
5808  }
5809 
5810  if (Irp->RequestorMode == KernelMode) {
5811  RtlCopyMemory(&fcb->inode_item.st_uid, item->value.Buffer, sizeof(uint32_t));
5812  fcb->sd_dirty = true;
5813  fcb->sd_deleted = false;
5814  }
5815 
5816  RemoveEntryList(&item->list_entry);
5817  ExFreePool(item);
5818  } else if (item->name.Length == sizeof(lxgid) - 1 && RtlCompareMemory(item->name.Buffer, lxgid, item->name.Length) == item->name.Length) {
5819  if (item->value.Length < sizeof(uint32_t)) {
5820  ERR("gid value was shorter than expected\n");
5822  goto end2;
5823  }
5824 
5825  if (Irp->RequestorMode == KernelMode)
5826  RtlCopyMemory(&fcb->inode_item.st_gid, item->value.Buffer, sizeof(uint32_t));
5827 
5828  RemoveEntryList(&item->list_entry);
5829  ExFreePool(item);
5830  } else if (item->name.Length == sizeof(lxmod) - 1 && RtlCompareMemory(item->name.Buffer, lxmod, item->name.Length) == item->name.Length) {
5831  if (item->value.Length < sizeof(uint32_t)) {
5832  ERR("mode value was shorter than expected\n");
5834  goto end2;
5835  }
5836 
5837  if (Irp->RequestorMode == KernelMode) {
5839  uint32_t val;
5840 
5841  RtlCopyMemory(&val, item->value.Buffer, sizeof(uint32_t));
5842 
5843  fcb->inode_item.st_mode &= ~allowed;
5844  fcb->inode_item.st_mode |= val & allowed;
5845  }
5846 
5847  RemoveEntryList(&item->list_entry);
5848  ExFreePool(item);
5849  }
5850 
5851  le = le2;
5852  }
5853 
5854  if (IsListEmpty(&ealist)) {
5855  fcb->ealen = 0;
5856 
5857  if (fcb->ea_xattr.Buffer)
5859 
5861  fcb->ea_xattr.Buffer = NULL;
5862  } else {
5863  uint16_t size = 0;
5864  char *buf, *oldbuf;
5865 
5866  le = ealist.Flink;
5867  while (le != &ealist) {
5869 
5870  if (size % 4 > 0)
5871  size += 4 - (size % 4);
5872 
5873  size += (uint16_t)offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + item->name.Length + 1 + item->value.Length;
5874 
5875  le = le->Flink;
5876  }
5877 
5879  if (!buf) {
5880  ERR("out of memory\n");
5882  goto end2;
5883  }
5884 
5885  oldbuf = fcb->ea_xattr.Buffer;
5886 
5888  fcb->ea_xattr.Buffer = buf;
5889 
5890  fcb->ealen = 4;
5891  ea = NULL;
5892 
5893  le = ealist.Flink;
5894  while (le != &ealist) {
5896 
5897  if (ea) {
5899 
5900  if (ea->NextEntryOffset % 4 > 0)
5901  ea->NextEntryOffset += 4 - (ea->NextEntryOffset % 4);
5902 
5903  ea = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)ea) + ea->NextEntryOffset);
5904  } else
5906 
5907  ea->NextEntryOffset = 0;
5908  ea->Flags = item->flags;
5909  ea->EaNameLength = (UCHAR)item->name.Length;
5910  ea->EaValueLength = item->value.Length;
5911 
5912  RtlCopyMemory(ea->EaName, item->name.Buffer, item->name.Length);
5913  ea->EaName[item->name.Length] = 0;
5914  RtlCopyMemory(&ea->EaName[item->name.Length + 1], item->value.Buffer, item->value.Length);
5915 
5916  fcb->ealen += 5 + item->name.Length + item->value.Length;
5917 
5918  le = le->Flink;
5919  }
5920 
5921  if (oldbuf)
5922  ExFreePool(oldbuf);
5923  }
5924 
5925  fcb->ea_changed = true;
5926 
5929 
5930  fcb->inode_item.transid = Vcb->superblock.generation;
5931  fcb->inode_item.sequence++;
5932 
5933  if (!ccb->user_set_change_time)
5935 
5936  fcb->inode_item_changed = true;
5938 
5940 
5942 
5943 end2:
5944  ExReleaseResourceLite(fcb->Header.Resource);
5945 
5946  while (!IsListEmpty(&ealist)) {
5947  le = RemoveHeadList(&ealist);
5948 
5950 
5951  ExFreePool(item);
5952  }
5953 
5954 end:
5955  TRACE("returning %08lx\n", Status);
5956 
5957  Irp->IoStatus.Status = Status;
5958  Irp->IoStatus.Information = 0;
5959 
5961 
5962  if (top_level)
5964 
5966 
5967  return Status;
5968 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
struct _file_ref * parent
Definition: btrfs_drv.h:368
NTSYSAPI VOID NTAPI RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
#define FILE_WRITE_EA
Definition: nt_native.h:640
static const char lxuid[]
Definition: btrfs_drv.h:1287
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define S_ISGID
Definition: propsheet.h:69
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define WARN(fmt,...)
Definition: debug.h:112
LONG NTSTATUS
Definition: precomp.h:26
bool sd_deleted
Definition: btrfs_drv.h:332
GLintptr offset
Definition: glext.h:5920
ANSI_STRING ea_xattr
Definition: btrfs_drv.h:313
NTSTATUS vol_set_ea(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:324
#define VCB_TYPE_FS
Definition: btrfs_drv.h:695
GLuint GLuint end
Definition: gl.h:1545
__u16 time
Definition: mkdosfs.c:366
ACCESS_MASK access
Definition: btrfs_drv.h:398
unsigned short int uint16_t
Definition: acefiex.h:54
#define uint16_t
Definition: nsiface.idl:60
#define InsertTailList(ListHead, Entry)
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:279
void send_notification_fileref(_In_ file_ref *fileref, _In_ ULONG filter_match, _In_ ULONG action, _In_opt_ PUNICODE_STRING stream)
Definition: btrfs.c:1449
BTRFS_TIME st_ctime
Definition: btrfs.h:294
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define ALLOC_TAG
Definition: btrfs_drv.h:91
bool ea_changed
Definition: btrfs_drv.h:336
uint32_t st_gid
Definition: btrfs.h:287
#define S_IRGRP
Definition: propsheet.h:41
#define S_IXOTH
Definition: propsheet.h:61
uint64_t sequence
Definition: btrfs.h:291
time_t now
Definition: finger.c:65
#define FILE_ACTION_MODIFIED
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define offsetof(TYPE, MEMBER)
void mark_fcb_dirty(_In_ fcb *fcb)
Definition: btrfs.c:1625
NTSTATUS NTAPI IoCheckEaBufferValidity(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: util.c:191
#define IoCompleteRequest
Definition: irp.c:1240
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:588
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
GLuint GLfloat * val
Definition: glext.h:7180
ULONG ealen
Definition: btrfs_drv.h:314
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:294
USHORT MaximumLength
Definition: env_spec_w32.h:377
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define S_IWGRP
Definition: propsheet.h:45
#define S_IXGRP
Definition: propsheet.h:49
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define S_IWUSR
Definition: propsheet.h:33
struct _fcb fcb
Definition: btrfs_drv.h:1357
bool sd_dirty
Definition: btrfs_drv.h:332
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:697
bool user_set_change_time
Definition: btrfs_drv.h:406
#define Vcb
Definition: cdprocs.h:1415
static __inline void * map_user_buffer(PIRP Irp, ULONG priority)
Definition: btrfs_drv.h:985
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1962
std::wstring STRING
Definition: fontsub.cpp:33
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
unsigned char UCHAR
Definition: xmlstorage.h:181
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
#define S_IXUSR
Definition: propsheet.h:37
#define S_IROTH
Definition: propsheet.h:53
GLdouble s
Definition: gl.h:2039
fcb * fcb
Definition: btrfs_drv.h:357
Definition: typedefs.h:119
INODE_ITEM inode_item
Definition: btrfs_drv.h:303
BYTE uint8_t
Definition: msvideo1.c:66
#define S_IWOTH
Definition: propsheet.h:57
#define ERR(fmt,...)
Definition: debug.h:110
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PFILE_OBJECT FileObject
Definition: iotypes.h:2820
static ATOM item
Definition: dde.c:856
#define FILE_NOTIFY_CHANGE_EA
static const char lxgid[]
Definition: btrfs_drv.h:1288
#define S_ISUID
Definition: propsheet.h:65
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
uint64_t transid
Definition: btrfs.h:281
static const char lxmod[]
Definition: btrfs_drv.h:1289
#define S_IRUSR
Definition: propsheet.h:29
Definition: list.h:27
UINT32 uint32_t
Definition: types.h:75
bool ads
Definition: btrfs_drv.h:341
static __inline void win_time_to_unix(LARGE_INTEGER t, BTRFS_TIME *out)
Definition: btrfs_drv.h:997
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:570
struct _ccb ccb
file_ref * fileref
Definition: btrfs_drv.h:399
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2779
uint32_t st_uid
Definition: btrfs.h:286
return STATUS_SUCCESS
Definition: btrfs.c:3014
bool inode_item_changed
Definition: btrfs_drv.h:317
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define S_ISVTX
Definition: propsheet.h:73
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
uint32_t st_mode
Definition: btrfs.h:288

◆ add_children_to_move_list()

static NTSTATUS add_children_to_move_list ( device_extension Vcb,
move_entry me,
PIRP  Irp 
)
static

Definition at line 701 of file fileinfo.c.

701  {
703  LIST_ENTRY* le;
704 
705  ExAcquireResourceSharedLite(&me->fileref->fcb->nonpaged->dir_children_lock, true);
706 
707  le = me->fileref->fcb->dir_children_index.Flink;
708 
709  while (le != &me->fileref->fcb->dir_children_index) {
710  dir_child* dc = CONTAINING_RECORD(le, dir_child, list_entry_index);
711  file_ref* fr;
712  move_entry* me2;
713 
714  Status = open_fileref_child(Vcb, me->fileref, &dc->name, true, true, dc->index == 0 ? true : false, PagedPool, &fr, Irp);
715 
716  if (!NT_SUCCESS(Status)) {
717  ERR("open_fileref_child returned %08lx\n", Status);
718  ExReleaseResourceLite(&me->fileref->fcb->nonpaged->dir_children_lock);
719  return Status;
720  }
721 
723  if (!me2) {
724  ERR("out of memory\n");
725  ExReleaseResourceLite(&me->fileref->fcb->nonpaged->dir_children_lock);
727  }
728 
729  me2->fileref = fr;
730  me2->dummyfcb = NULL;
731  me2->dummyfileref = NULL;
732  me2->parent = me;
733 
734  InsertHeadList(&me->list_entry, &me2->list_entry);
735 
736  le = le->Flink;
737  }
738 
739  ExReleaseResourceLite(&me->fileref->fcb->nonpaged->dir_children_lock);
740 
741  return STATUS_SUCCESS;
742 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
LONG NTSTATUS
Definition: precomp.h:26
file_ref * fileref
Definition: fileinfo.c:694
NTSTATUS open_fileref_child(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lock_held_(_Curr_->fcb_lock) _In_ device_extension *Vcb, _In_ file_ref *sf, _In_ PUNICODE_STRING name, _In_ bool case_sensitive, _In_ bool lastpart, _In_ bool streampart, _In_ POOL_TYPE pooltype, _Out_ file_ref **psf2, _In_opt_ PIRP Irp)
Definition: create.c:1452
file_ref * dummyfileref
Definition: fileinfo.c:696
#define ALLOC_TAG
Definition: btrfs_drv.h:91
struct _move_entry * parent
Definition: fileinfo.c:697
fcb * dummyfcb
Definition: fileinfo.c:695
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY dir_children_index
Definition: btrfs_drv.h:325
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1415
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
Definition: fileinfo.c:693
fcb * fcb
Definition: btrfs_drv.h:357
Definition: typedefs.h:119
LIST_ENTRY list_entry
Definition: fileinfo.c:698
#define ERR(fmt,...)
Definition: debug.h:110
struct _fcb_nonpaged * nonpaged
Definition: btrfs_drv.h:295
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
static const WCHAR dc[]
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by move_across_subvols().

◆ create_directory_fcb()

static NTSTATUS create_directory_fcb ( device_extension Vcb,
root r,
fcb parfcb,
fcb **  pfcb 
)
static

Definition at line 782 of file fileinfo.c.

782  {
784  fcb* fcb;
785  SECURITY_SUBJECT_CONTEXT subjcont;
786  PSID owner;
787  BOOLEAN defaulted;
789  BTRFS_TIME now;
790 
792  if (!fcb) {
793  ERR("out of memory\n");
795  }
796 
799 
800  fcb->Vcb = Vcb;
801 
802  fcb->subvol = r;
803  fcb->inode = InterlockedIncrement64(&r->lastinode);
805 
806  fcb->inode_item.generation = Vcb->superblock.generation;
807  fcb->inode_item.transid = Vcb->superblock.generation;
808  fcb->inode_item.st_nlink = 1;
809  fcb->inode_item.st_mode = __S_IFDIR | inherit_mode(parfcb, true);
812 
813  fcb->atts = get_file_attributes(Vcb, fcb->subvol, fcb->inode, fcb->type, false, true, NULL);
814 
815  SeCaptureSubjectContext(&subjcont);
816 
817  Status = SeAssignSecurity(parfcb->sd, NULL, (void**)&fcb->sd, true, &subjcont, IoGetFileObjectGenericMapping(), PagedPool);
818 
819  if (!NT_SUCCESS(Status)) {
820  reap_fcb(fcb);
821  ERR("SeAssignSecurity returned %08lx\n", Status);
822  return Status;
823  }
824 
825  if (!fcb->sd) {
826  reap_fcb(fcb);
827  ERR("SeAssignSecurity returned NULL security descriptor\n");
828  return STATUS_INTERNAL_ERROR;
829  }
830 
831  Status = RtlGetOwnerSecurityDescriptor(fcb->sd, &owner, &defaulted);
832  if (!NT_SUCCESS(Status)) {
833  ERR("RtlGetOwnerSecurityDescriptor returned %08lx\n", Status);
835  fcb->sd_dirty = true;
836  } else {
837  fcb->inode_item.st_uid = sid_to_uid(owner);
839  }
840 
841  find_gid(fcb, parfcb, &subjcont);
842 
843  fcb->inode_item_changed = true;
844 
845  fcb->Header.IsFastIoPossible = fast_io_possible(fcb);
846  fcb->Header.AllocationSize.QuadPart = 0;
847  fcb->Header.FileSize.QuadPart = 0;
848  fcb->Header.ValidDataLength.QuadPart = 0;
849 
850  fcb->created = true;
851 
852  if (parfcb->inode_item.flags & BTRFS_INODE_COMPRESS)
854 
857 
859  if (!fcb->hash_ptrs) {
860  ERR("out of memory\n");
862  }
863 
864  RtlZeroMemory(fcb->hash_ptrs, sizeof(LIST_ENTRY*) * 256);
865 
867  if (!fcb->hash_ptrs_uc) {
868  ERR("out of memory\n");
870  }
871 
872  RtlZeroMemory(fcb->hash_ptrs_uc, sizeof(LIST_ENTRY*) * 256);
873 
874  acquire_fcb_lock_exclusive(Vcb);
875  InsertTailList(&r->fcbs, &fcb->list_entry);
876  InsertTailList(&Vcb->all_fcbs, &fcb->list_entry_all);
877  r->fcbs_version++;
878  release_fcb_lock(Vcb);
879 
881 
882  *pfcb = fcb;
883 
884  return STATUS_SUCCESS;
885 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
PGENERIC_MAPPING NTAPI IoGetFileObjectGenericMapping(VOID)
Definition: file.c:3266
VOID NTAPI SeCaptureSubjectContext(OUT PSECURITY_SUBJECT_CONTEXT SubjectContext)
Definition: access.c:301
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
BTRFS_TIME otime
Definition: btrfs.h:296
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
fcb * create_fcb(device_extension *Vcb, POOL_TYPE pool_type)
Definition: create.c:79
LONG NTSTATUS
Definition: precomp.h:26
enum prop_compression_type prop_compression
Definition: btrfs_drv.h:318
__u16 time
Definition: mkdosfs.c:366
#define InsertTailList(ListHead, Entry)
BTRFS_TIME st_ctime
Definition: btrfs.h:294
LIST_ENTRY list_entry_all
Definition: btrfs_drv.h:348
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
uint32_t sid_to_uid(PSID sid)
Definition: security.c:310
#define ALLOC_TAG
Definition: btrfs_drv.h:91
uint32_t st_gid
Definition: btrfs.h:287
SECURITY_DESCRIPTOR * sd
Definition: btrfs_drv.h:304
#define BTRFS_INODE_COMPRESS
Definition: propsheet.h:87
LIST_ENTRY list_entry
Definition: btrfs_drv.h:347
uint32_t st_nlink
Definition: btrfs.h:285
time_t now
Definition: finger.c:65
#define BTRFS_TYPE_DIRECTORY
Definition: shellext.h:86
unsigned char BOOLEAN
void reap_fcb(fcb *fcb)
Definition: btrfs.c:1673
LIST_ENTRY ** hash_ptrs_uc
Definition: btrfs_drv.h:329
smooth NULL
Definition: ftsmooth.c:416
void mark_fcb_dirty(_In_ fcb *fcb)
Definition: btrfs.c:1625
uint8_t type
Definition: btrfs_drv.h:302
BTRFS_TIME st_mtime
Definition: btrfs.h:295
bool prop_compression_changed
Definition: btrfs_drv.h:337
void find_gid(struct _fcb *fcb, struct _fcb *parfcb, PSECURITY_SUBJECT_CONTEXT subjcont)
Definition: security.c:924
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:294
#define InterlockedIncrement64
Definition: interlocked.h:211
struct _fcb fcb
Definition: btrfs_drv.h:1357
bool sd_dirty
Definition: btrfs_drv.h:332
ULONG get_file_attributes(_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_ root *r, _In_ uint64_t inode, _In_ uint8_t type, _In_ bool dotfile, _In_ bool ignore_xa, _In_opt_ PIRP Irp)
Definition: btrfs.c:2600
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t inode
Definition: btrfs_drv.h:300
#define Vcb
Definition: cdprocs.h:1415
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
BTRFS_TIME st_atime
Definition: btrfs.h:293
Status
Definition: gdiplustypes.h:24
bool created
Definition: btrfs_drv.h:339
Definition: typedefs.h:119
static __inline FAST_IO_POSSIBLE fast_io_possible(fcb *fcb)
Definition: btrfs_drv.h:1690
INODE_ITEM inode_item
Definition: btrfs_drv.h:303
uint64_t generation
Definition: btrfs.h:280
uint64_t flags
Definition: btrfs.h:290
#define ERR(fmt,...)
Definition: debug.h:110
ULONG atts
Definition: btrfs_drv.h:308
uint32_t inherit_mode(fcb *parfcb, bool is_dir)
Definition: create.c:1936
uint64_t transid
Definition: btrfs.h:281
struct _root * subvol
Definition: btrfs_drv.h:299
NTSYSAPI NTSTATUS NTAPI RtlGetOwnerSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor, OUT PSID *Owner, OUT PBOOLEAN OwnerDefaulted)
Definition: sd.c:257
#define __S_IFDIR
Definition: btrfs_drv.h:1800
static __inline void win_time_to_unix(LARGE_INTEGER t, BTRFS_TIME *out)
Definition: btrfs_drv.h:997
LIST_ENTRY ** hash_ptrs
Definition: btrfs_drv.h:328
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t st_uid
Definition: btrfs.h:286
return STATUS_SUCCESS
Definition: btrfs.c:3014
bool inode_item_changed
Definition: btrfs_drv.h:317
#define GID_NOBODY
Definition: btrfs_drv.h:95
struct _device_extension * Vcb
Definition: btrfs_drv.h:298
#define UID_NOBODY
Definition: btrfs_drv.h:94
uint32_t st_mode
Definition: btrfs.h:288

Referenced by move_across_subvols().

◆ duplicate_fcb()

static NTSTATUS duplicate_fcb ( fcb oldfcb,
fcb **  pfcb 
)
static

Definition at line 463 of file fileinfo.c.

463  {
464  device_extension* Vcb = oldfcb->Vcb;
465  fcb* fcb;
466  LIST_ENTRY* le;
467 
468  // FIXME - we can skip a lot of this if the inode is about to be deleted
469 
470  fcb = create_fcb(Vcb, PagedPool); // FIXME - what if we duplicate the paging file?
471  if (!fcb) {
472  ERR("out of memory\n");
474  }
475 
476  fcb->Vcb = Vcb;
477 
478  fcb->Header.IsFastIoPossible = fast_io_possible(fcb);
479  fcb->Header.AllocationSize = oldfcb->Header.AllocationSize;
480  fcb->Header.FileSize = oldfcb->Header.FileSize;
481  fcb->Header.ValidDataLength = oldfcb->Header.ValidDataLength;
482 
483  fcb->type = oldfcb->type;
484 
485  if (oldfcb->ads) {
486  fcb->ads = true;
487  fcb->adshash = oldfcb->adshash;
488  fcb->adsmaxlen = oldfcb->adsmaxlen;
489 
490  if (oldfcb->adsxattr.Buffer && oldfcb->adsxattr.Length > 0) {
491  fcb->adsxattr.Length = oldfcb->adsxattr.Length;
494 
495  if (!fcb->adsxattr.Buffer) {
496  ERR("out of memory\n");
497  free_fcb(fcb);
499  }
500 
503  }
504 
505  if (oldfcb->adsdata.Buffer && oldfcb->adsdata.Length > 0) {
508 
509  if (!fcb->adsdata.Buffer) {
510  ERR("out of memory\n");
511  free_fcb(fcb);
513  }
514 
516  }
517 
518  goto end;
519  }
520 
521  RtlCopyMemory(&fcb->inode_item, &oldfcb->inode_item, sizeof(INODE_ITEM));
522  fcb->inode_item_changed = true;
523 
524  if (oldfcb->sd && RtlLengthSecurityDescriptor(oldfcb->sd) > 0) {
526  if (!fcb->sd) {
527  ERR("out of memory\n");
528  free_fcb(fcb);
530  }
531 
532  RtlCopyMemory(fcb->sd, oldfcb->sd, RtlLengthSecurityDescriptor(oldfcb->sd));
533  }
534 
535  fcb->atts = oldfcb->atts;
536 
537  le = oldfcb->extents.Flink;
538  while (le != &oldfcb->extents) {
540 
541  if (!ext->ignore) {
542  extent* ext2 = ExAllocatePoolWithTag(PagedPool, offsetof(extent, extent_data) + ext->datalen, ALLOC_TAG);
543 
544  if (!ext2) {
545  ERR("out of memory\n");
546  free_fcb(fcb);
548  }
549 
550  ext2->offset = ext->offset;
551  ext2->datalen = ext->datalen;
552 
553  if (ext2->datalen > 0)
554  RtlCopyMemory(&ext2->extent_data, &ext->extent_data, ext2->datalen);
555 
556  ext2->unique = false;
557  ext2->ignore = false;
558  ext2->inserted = true;
559 
560  if (ext->csum) {
561  ULONG len;
562  EXTENT_DATA2* ed2 = (EXTENT_DATA2*)ext->extent_data.data;
563 
564  if (ext->extent_data.compression == BTRFS_COMPRESSION_NONE)
565  len = (ULONG)ed2->num_bytes;
566  else
567  len = (ULONG)ed2->size;
568 
569  len = len * sizeof(uint32_t) / Vcb->superblock.sector_size;
570 
572  if (!ext2->csum) {
573  ERR("out of memory\n");
574  free_fcb(fcb);
576  }
577 
578  RtlCopyMemory(ext2->csum, ext->csum, len);
579  } else
580  ext2->csum = NULL;
581 
582  InsertTailList(&fcb->extents, &ext2->list_entry);
583  }
584 
585  le = le->Flink;
586  }
587 
588  le = oldfcb->hardlinks.Flink;
589  while (le != &oldfcb->hardlinks) {
590  hardlink *hl = CONTAINING_RECORD(le, hardlink, list_entry), *hl2;
591 
593 
594  if (!hl2) {
595  ERR("out of memory\n");
596  free_fcb(fcb);
598  }
599 
600  hl2->parent = hl->parent;
601  hl2->index = hl->index;
602 
603  hl2->name.Length = hl2->name.MaximumLength = hl->name.Length;
604  hl2->name.Buffer = ExAllocatePoolWithTag(PagedPool, hl2->name.MaximumLength, ALLOC_TAG);
605 
606  if (!hl2->name.Buffer) {
607  ERR("out of memory\n");
608  ExFreePool(hl2);
609  free_fcb(fcb);
611  }
612 
613  RtlCopyMemory(hl2->name.Buffer, hl->name.Buffer, hl->name.Length);
614 
615  hl2->utf8.Length = hl2->utf8.MaximumLength = hl->utf8.Length;
616  hl2->utf8.Buffer = ExAllocatePoolWithTag(PagedPool, hl2->utf8.MaximumLength, ALLOC_TAG);
617 
618  if (!hl2->utf8.Buffer) {
619  ERR("out of memory\n");
620  ExFreePool(hl2->name.Buffer);
621  ExFreePool(hl2);
622  free_fcb(fcb);
624  }
625 
626  RtlCopyMemory(hl2->utf8.Buffer, hl->utf8.Buffer, hl->utf8.Length);
627 
628  InsertTailList(&fcb->hardlinks, &hl2->list_entry);
629 
630  le = le->Flink;
631  }
632 
633  if (oldfcb->reparse_xattr.Buffer && oldfcb->reparse_xattr.Length > 0) {
635 
637  if (!fcb->reparse_xattr.Buffer) {
638  ERR("out of memory\n");
639  free_fcb(fcb);
641  }
642 
644  }
645 
646  if (oldfcb->ea_xattr.Buffer && oldfcb->ea_xattr.Length > 0) {
648 
650  if (!fcb->ea_xattr.Buffer) {
651  ERR("out of memory\n");
652  free_fcb(fcb);
654  }
655 
657  }
658 
660 
661  le = oldfcb->xattrs.Flink;
662  while (le != &oldfcb->xattrs) {
664 
665  if (xa->valuelen > 0) {
666  xattr* xa2;
667 
669 
670  if (!xa2) {
671  ERR("out of memory\n");
672  free_fcb(fcb);
674  }
675 
676  xa2->namelen = xa->namelen;
677  xa2->valuelen = xa->valuelen;
678  xa2->dirty = xa->dirty;
679  memcpy(xa2->data, xa->data, xa->namelen + xa->valuelen);
680 
682  }
683 
684  le = le->Flink;
685  }
686 
687 end:
688  *pfcb = fcb;
689 
690  return STATUS_SUCCESS;
691 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
uint32_t adshash
Definition: btrfs_drv.h:342
void free_fcb(_Inout_ fcb *fcb)
Definition: btrfs.c:1664
#define BTRFS_COMPRESSION_NONE
Definition: btrfs.h:61
EXTENT_DATA2 * ed2
Definition: write.c:2805
fcb * create_fcb(device_extension *Vcb, POOL_TYPE pool_type)
Definition: create.c:79
enum prop_compression_type prop_compression
Definition: btrfs_drv.h:318
ANSI_STRING ea_xattr
Definition: btrfs_drv.h:313
ANSI_STRING reparse_xattr
Definition: btrfs_drv.h:312
GLuint GLuint end
Definition: gl.h:1545
#define InsertTailList(ListHead, Entry)
NTSYSAPI ULONG WINAPI RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR)
#define ALLOC_TAG
Definition: btrfs_drv.h:91
SECURITY_DESCRIPTOR * sd
Definition: btrfs_drv.h:304
smooth NULL
Definition: ftsmooth.c:416
#define offsetof(TYPE, MEMBER)
char ext[3]
Definition: mkdosfs.c:358
uint64_t size
Definition: btrfs.h:357
uint8_t type
Definition: btrfs_drv.h:302
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:294
USHORT MaximumLength
Definition: env_spec_w32.h:377
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
struct _fcb fcb
Definition: btrfs_drv.h:1357
if(!(yy_init))
Definition: macro.lex.yy.c:714
LIST_ENTRY xattrs
Definition: btrfs_drv.h:319
#define Vcb
Definition: cdprocs.h:1415
LIST_ENTRY hardlinks
Definition: btrfs_drv.h:315
LIST_ENTRY extents
Definition: btrfs_drv.h:311
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const BYTE ext2[]
Definition: encode.c:2699
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
Definition: typedefs.h:119
static __inline FAST_IO_POSSIBLE fast_io_possible(fcb *fcb)
Definition: btrfs_drv.h:1690
INODE_ITEM inode_item
Definition: btrfs_drv.h:303
USHORT valuelen
Definition: btrfs_drv.h:288
uint64_t num_bytes
Definition: btrfs.h:359
#define ERR(fmt,...)
Definition: debug.h:110
ULONG atts
Definition: btrfs_drv.h:308
bool dirty
Definition: btrfs_drv.h:289
Definition: list.h:27
ULONG adsmaxlen
Definition: btrfs_drv.h:343
ANSI_STRING adsdata
Definition: btrfs_drv.h:345
LIST_ENTRY list_entry
Definition: btrfs_drv.h:286
bool ads
Definition: btrfs_drv.h:341
USHORT namelen
Definition: btrfs_drv.h:287
unsigned int ULONG
Definition: retypes.h:1
#define uint32_t
Definition: nsiface.idl:61
return STATUS_SUCCESS
Definition: btrfs.c:3014
char data[1]
Definition: btrfs_drv.h:290
bool inode_item_changed
Definition: btrfs_drv.h:317
struct _device_extension * Vcb
Definition: btrfs_drv.h:298
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
ANSI_STRING adsxattr
Definition: btrfs_drv.h:344

Referenced by move_across_subvols(), and rename_file_to_stream().

◆ fileref_get_filename()

NTSTATUS fileref_get_filename ( file_ref fileref,
PUNICODE_STRING  fn,
USHORT name_offset,
ULONG preqlen 
)

Definition at line 4168 of file fileinfo.c.

4168  {
4169  file_ref* fr;
4170  NTSTATUS Status;
4171  ULONG reqlen = 0;
4172  USHORT offset;
4173  bool overflow = false;
4174 
4175  // FIXME - we need a lock on filerefs' filepart
4176 
4177  if (fileref == fileref->fcb->Vcb->root_fileref) {
4178  if (fn->MaximumLength >= sizeof(WCHAR)) {
4179  fn->Buffer[0] = '\\';
4180  fn->Length = sizeof(WCHAR);
4181 
4182  if (name_offset)
4183  *name_offset = 0;
4184 
4185  return STATUS_SUCCESS;
4186  } else {
4187  if (preqlen)
4188  *preqlen = sizeof(WCHAR);
4189  fn->Length = 0;
4190 
4191  return STATUS_BUFFER_OVERFLOW;
4192  }
4193  }
4194 
4195  fr = fileref;
4196  offset = 0;
4197 
4198  while (fr->parent) {
4199  USHORT movelen;
4200 
4201  if (!fr->dc)
4202  return STATUS_INTERNAL_ERROR;
4203 
4204  if (!overflow) {
4205  if (fr->dc->name.Length + sizeof(WCHAR) + fn->Length > fn->MaximumLength)
4206  overflow = true;
4207  }
4208 
4209  if (overflow)
4210  movelen = fn->MaximumLength - fr->dc->name.Length - sizeof(WCHAR);
4211  else
4212  movelen = fn->Length;
4213 
4214  if ((!overflow || fn->MaximumLength > fr->dc->name.Length + sizeof(WCHAR)) && movelen > 0) {
4215  RtlMoveMemory(&fn->Buffer[(fr->dc->name.Length / sizeof(WCHAR)) + 1], fn->Buffer, movelen);
4216  offset += fr->dc->name.Length + sizeof(WCHAR);
4217  }
4218 
4219  if (fn->MaximumLength >= sizeof(WCHAR)) {
4220  fn->Buffer[0] = fr->fcb->ads ? ':' : '\\';
4221  fn->Length += sizeof(WCHAR);
4222 
4223  if (fn->MaximumLength > sizeof(WCHAR)) {
4224  RtlCopyMemory(&fn->Buffer[1], fr->dc->name.Buffer, min(fr->dc->name.Length, fn->MaximumLength - sizeof(WCHAR)));
4225  fn->Length += fr->dc->name.Length;
4226  }
4227 
4228  if (fn->Length > fn->MaximumLength) {
4229  fn->Length = fn->MaximumLength;
4230  overflow = true;
4231  }
4232  }
4233 
4234  reqlen += sizeof(WCHAR) + fr->dc->name.Length;
4235 
4236  fr = fr->parent;
4237  }
4238 
4239  offset += sizeof(WCHAR);
4240 
4241  if (overflow) {
4242  if (preqlen)
4243  *preqlen = reqlen;
4245  } else {
4246  if (name_offset)
4247  *name_offset = offset;
4248 
4250  }
4251 
4252  return Status;
4253 }
struct _file_ref * parent
Definition: btrfs_drv.h:368
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
LONG NTSTATUS
Definition: precomp.h:26
GLintptr offset
Definition: glext.h:5920
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
dir_child * dc
Definition: btrfs_drv.h:369
Status
Definition: gdiplustypes.h:24
fcb * fcb
Definition: btrfs_drv.h:357
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned short USHORT
Definition: pedump.c:61
#define min(a, b)
Definition: monoChain.cc:55
bool ads
Definition: btrfs_drv.h:341
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:3014
struct _device_extension * Vcb
Definition: btrfs_drv.h:298
UNICODE_STRING name
Definition: btrfs_drv.h:267

Referenced by fill_in_file_name_information(), get_subvol_path(), notify_change_directory(), send_notification_fcb(), send_notification_fileref(), and set_rename_information().

◆ fill_in_file_attribute_information()

static NTSTATUS fill_in_file_attribute_information ( FILE_ATTRIBUTE_TAG_INFORMATION ati,
fcb fcb,
ccb ccb,
LONG length 
)
static

Definition at line 4312 of file fileinfo.c.

4312  {
4314 
4315  if (fcb->ads) {
4316  if (!ccb->fileref || !ccb->fileref->parent) {
4317  ERR("no fileref for stream\n");
4318  return STATUS_INTERNAL_ERROR;
4319  }
4320 
4321  ati->FileAttributes = ccb->fileref->parent->fcb->atts;
4322  } else
4323  ati->FileAttributes = fcb->atts;
4324 
4326  ati->ReparseTag = 0;
4327  else
4329 
4330  return STATUS_SUCCESS;
4331 }
struct _file_ref * parent
Definition: btrfs_drv.h:368
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
#define FILE_ATTRIBUTE_REPARSE_POINT
Definition: ntifs_ex.h:381
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
struct _FILE_ATTRIBUTE_TAG_INFORMATION FILE_ATTRIBUTE_TAG_INFORMATION
#define ERR(fmt,...)
Definition: debug.h:110
ULONG get_reparse_tag_fcb(fcb *fcb)
Definition: dirctrl.c:83
ULONG atts
Definition: btrfs_drv.h:308
bool ads
Definition: btrfs_drv.h:341
file_ref * fileref
Definition: btrfs_drv.h:399
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by query_info().

◆ fill_in_file_basic_information()

static NTSTATUS fill_in_file_basic_information ( FILE_BASIC_INFORMATION fbi,
INODE_ITEM ii,
LONG length,
fcb fcb,
file_ref fileref 
)
static

Definition at line 4034 of file fileinfo.c.

4034  {
4035  RtlZeroMemory(fbi, sizeof(FILE_BASIC_INFORMATION));
4036 
4037  *length -= sizeof(FILE_BASIC_INFORMATION);
4038 
4039  if (fcb == fcb->Vcb->dummy_fcb) {
4041 
4043  fbi->CreationTime = fbi->LastAccessTime = fbi->LastWriteTime = fbi->ChangeTime = time;
4044  } else {
4049  }
4050 
4051  if (fcb->ads) {
4052  if (!fileref || !fileref->parent) {
4053  ERR("no fileref for stream\n");
4054  return STATUS_INTERNAL_ERROR;
4055  } else
4056  fbi->FileAttributes = fileref->parent->fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : fileref->parent->fcb->atts;
4057  } else
4059 
4060  return STATUS_SUCCESS;
4061 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
struct _file_ref * parent
Definition: btrfs_drv.h:368
BTRFS_TIME otime
Definition: btrfs.h:296
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
__u16 time
Definition: mkdosfs.c:366
BTRFS_TIME st_ctime
Definition: btrfs.h:294
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
BTRFS_TIME st_mtime
Definition: btrfs.h:295
static __inline uint64_t unix_time_to_win(BTRFS_TIME *t)
Definition: recv.cpp:1180
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
BTRFS_TIME st_atime
Definition: btrfs.h:293
LARGE_INTEGER CreationTime
Definition: nt_native.h:939
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
LARGE_INTEGER ChangeTime
Definition: nt_native.h:942
#define ERR(fmt,...)
Definition: debug.h:110
ULONG atts
Definition: btrfs_drv.h:308
bool ads
Definition: btrfs_drv.h:341
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
return STATUS_SUCCESS
Definition: btrfs.c:3014
struct _device_extension * Vcb
Definition: btrfs_drv.h:298
LONGLONG QuadPart
Definition: typedefs.h:114
#define FILE_BASIC_INFORMATION
Definition: disk.h:53

Referenced by query_info().

◆ fill_in_file_case_sensitive_information()

static NTSTATUS fill_in_file_case_sensitive_information ( FILE_CASE_SENSITIVE_INFORMATION fcsi,
fcb fcb,
LONG length 
)
static

Definition at line 4935 of file fileinfo.c.

4935  {
4937 
4939 
4940  return STATUS_SUCCESS;
4941 }
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
struct _FILE_CASE_SENSITIVE_INFORMATION FILE_CASE_SENSITIVE_INFORMATION
#define FILE_CS_FLAG_CASE_SENSITIVE_DIR
Definition: btrfs_drv.h:167
bool case_sensitive
Definition: btrfs_drv.h:321
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by query_info().

◆ fill_in_file_compression_information()

static NTSTATUS fill_in_file_compression_information ( FILE_COMPRESSION_INFORMATION fci,
LONG length,
fcb fcb 
)
static

Definition at line 4945 of file fileinfo.c.

4945  {
4947 
4948  memset(fci, 0, sizeof(FILE_COMPRESSION_INFORMATION));
4949 
4950  if (fcb->ads)
4952  else if (!S_ISDIR(fcb->inode_item.st_mode))
4954 
4955  return STATUS_SUCCESS;
4956 }
struct _FILE_COMPRESSION_INFORMATION FILE_COMPRESSION_INFORMATION
LARGE_INTEGER CompressedFileSize
Definition: iotypes.h:5500
uint64_t st_size
Definition: btrfs.h:282
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define S_ISDIR(mode)
Definition: various.h:18
INODE_ITEM inode_item
Definition: btrfs_drv.h:303
ANSI_STRING adsdata
Definition: btrfs_drv.h:345
bool ads
Definition: btrfs_drv.h:341
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define memset(x, y, z)
Definition: compat.h:39
LONGLONG QuadPart
Definition: typedefs.h:114
uint32_t st_mode
Definition: btrfs.h:288

Referenced by query_info().

◆ fill_in_file_ea_information()

static NTSTATUS fill_in_file_ea_information ( FILE_EA_INFORMATION eai,
fcb fcb,
LONG length 
)
static

Definition at line 4145 of file fileinfo.c.

4145  {
4146  *length -= sizeof(FILE_EA_INFORMATION);
4147 
4148  /* This value appears to be the size of the structure NTFS stores on disk, and not,
4149  * as might be expected, the size of FILE_FULL_EA_INFORMATION (which is what we store).
4150  * The formula is 4 bytes as a header, followed by 5 + NameLength + ValueLength for each
4151  * item. */
4152 
4153  eai->EaSize = fcb->ealen;
4154 
4155  return STATUS_SUCCESS;
4156 }
ULONG ealen
Definition: btrfs_drv.h:314
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
struct _FILE_EA_INFORMATION FILE_EA_INFORMATION
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by query_info().

◆ fill_in_file_id_information()

static NTSTATUS fill_in_file_id_information ( FILE_ID_INFORMATION fii,
fcb fcb,
LONG length 
)
static

Definition at line 4791 of file fileinfo.c.

4791  {
4792  RtlCopyMemory(&fii->VolumeSerialNumber, &fcb->Vcb->superblock.uuid.uuid[8], sizeof(uint64_t));
4793  RtlCopyMemory(&fii->FileId.Identifier[0], &fcb->inode, sizeof(uint64_t));
4794  RtlCopyMemory(&fii->FileId.Identifier[sizeof(uint64_t)], &fcb->subvol->id, sizeof(uint64_t));
4795 
4796  *length -= sizeof(FILE_ID_INFORMATION);
4797 
4798  return STATUS_SUCCESS;
4799 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
uint64_t inode
Definition: btrfs_drv.h:300
ULONGLONG VolumeSerialNumber
Definition: fileinfo.c:35
struct _FILE_ID_INFORMATION FILE_ID_INFORMATION
UCHAR Identifier[16]
Definition: btrfs_drv.h:164
UINT64 uint64_t
Definition: types.h:77
struct _root * subvol
Definition: btrfs_drv.h:299
FILE_ID_128 FileId
Definition: fileinfo.c:36
return STATUS_SUCCESS
Definition: btrfs.c:3014
struct _device_extension * Vcb
Definition: btrfs_drv.h:298

Referenced by query_info().

◆ fill_in_file_internal_information()

static NTSTATUS fill_in_file_internal_information ( FILE_INTERNAL_INFORMATION fii,
fcb fcb,
LONG length 
)
static

Definition at line 4137 of file fileinfo.c.

4137  {
4138  *length -= sizeof(FILE_INTERNAL_INFORMATION);
4139 
4141 
4142  return STATUS_SUCCESS;
4143 }
struct _FILE_INTERNAL_INFORMATION FILE_INTERNAL_INFORMATION
static __inline uint64_t make_file_id(root *r, uint64_t inode)
Definition: btrfs_drv.h:1020
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
uint64_t inode
Definition: btrfs_drv.h:300
struct _root * subvol
Definition: btrfs_drv.h:299
return STATUS_SUCCESS
Definition: btrfs.c:3014
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by query_info().

◆ fill_in_file_name_information()

static NTSTATUS fill_in_file_name_information ( FILE_NAME_INFORMATION fni,
fcb fcb,
file_ref fileref,
LONG length 
)
static

Definition at line 4255 of file fileinfo.c.

4255  {
4256  ULONG reqlen;
4258  NTSTATUS Status;
4259  static const WCHAR datasuf[] = {':','$','D','A','T','A',0};
4260  uint16_t datasuflen = sizeof(datasuf) - sizeof(WCHAR);
4261 
4262  if (!fileref) {
4263  ERR("called without fileref\n");
4264  return STATUS_INVALID_PARAMETER;
4265  }
4266 
4268 
4269  TRACE("maximum length is %li\n", *length);
4270  fni->FileNameLength = 0;
4271 
4272  fni->FileName[0] = 0;
4273 
4274  fn.Buffer = fni->FileName;
4275  fn.Length = 0;
4276  fn.MaximumLength = (uint16_t)*length;
4277 
4278  Status = fileref_get_filename(fileref, &fn, NULL, &reqlen);
4280  ERR("fileref_get_filename returned %08lx\n", Status);
4281  return Status;
4282  }
4283 
4284  if (fcb->ads) {
4286  reqlen += datasuflen;
4287  else {
4288  if (fn.Length + datasuflen > fn.MaximumLength) {
4289  RtlCopyMemory(&fn.Buffer[fn.Length / sizeof(WCHAR)], datasuf, fn.MaximumLength - fn.Length);
4290  reqlen += datasuflen;
4292  } else {
4293  RtlCopyMemory(&fn.Buffer[fn.Length / sizeof(WCHAR)], datasuf, datasuflen);
4294  fn.Length += datasuflen;
4295  }
4296  }
4297  }
4298 
4299  if (Status == STATUS_BUFFER_OVERFLOW) {
4300  *length = -1;
4301  fni->FileNameLength = reqlen;
4302  TRACE("%.*S (truncated)\n", (int)(fn.Length / sizeof(WCHAR)), fn.Buffer);
4303  } else {
4304  *length -= fn.Length;
4305  fni->FileNameLength = fn.Length;
4306  TRACE("%.*S\n", (int)(fn.Length / sizeof(WCHAR)), fn.Buffer);
4307  }
4308 
4309  return Status;
4310 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
unsigned short int uint16_t
Definition: acefiex.h:54
#define uint16_t
Definition: nsiface.idl:60
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define offsetof(TYPE, MEMBER)
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
NTSTATUS fileref_get_filename(file_ref *fileref, PUNICODE_STRING fn, USHORT *name_offset, ULONG *preqlen)
Definition: fileinfo.c:4168
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:110
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
bool ads
Definition: btrfs_drv.h:341
unsigned int ULONG
Definition: retypes.h:1

Referenced by query_info().

◆ fill_in_file_network_open_information()

static NTSTATUS fill_in_file_network_open_information ( FILE_NETWORK_OPEN_INFORMATION fnoi,
fcb fcb,
file_ref fileref,
LONG length 
)
static

Definition at line 4063 of file fileinfo.c.

4063  {
4064  INODE_ITEM* ii;
4065 
4066  if (*length < (LONG)sizeof(FILE_NETWORK_OPEN_INFORMATION)) {
4067  WARN("overflow\n");
4068  return STATUS_BUFFER_OVERFLOW;
4069  }
4070 
4072 
4074 
4075  if (fcb->ads) {
4076  if (!fileref || !fileref->parent) {
4077  ERR("no fileref for stream\n");
4078  return STATUS_INTERNAL_ERROR;
4079  }
4080 
4081  ii = &fileref->parent->fcb->inode_item;
4082  } else
4083  ii = &fcb->inode_item;
4084 
4085  if (fcb == fcb->Vcb->dummy_fcb) {
4087 
4089  fnoi->CreationTime = fnoi->LastAccessTime = fnoi->LastWriteTime = fnoi->ChangeTime = time;
4090  } else {
4095  }
4096 
4097  if (fcb->ads) {
4099  fnoi->FileAttributes = fileref->parent->fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : fileref->parent->fcb->atts;
4100  } else {
4103  fnoi->FileAttributes = fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : fcb->atts;
4104  }
4105 
4106  return STATUS_SUCCESS;
4107 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
struct _file_ref * parent
Definition: btrfs_drv.h:368
BTRFS_TIME otime
Definition: btrfs.h:296
#define WARN(fmt,...)
Definition: debug.h:112
__u16 time
Definition: mkdosfs.c:366
BTRFS_TIME st_ctime
Definition: btrfs.h:294
struct _FILE_NETWORK_OPEN_INFORMATION FILE_NETWORK_OPEN_INFORMATION
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
long LONG
Definition: pedump.c:60
BTRFS_TIME st_mtime
Definition: btrfs.h:295
static __inline uint64_t unix_time_to_win(BTRFS_TIME *t)
Definition: recv.cpp:1180
uint64_t st_size
Definition: btrfs.h:282
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define S_ISDIR(mode)
Definition: various.h:18
BTRFS_TIME st_atime
Definition: btrfs.h:293
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
INODE_ITEM inode_item
Definition: btrfs_drv.h:303
#define ERR(fmt,...)
Definition: debug.h:110
ULONG atts
Definition: btrfs_drv.h:308
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
static __inline uint64_t fcb_alloc_size(fcb *fcb)
Definition: btrfs_drv.h:1870
ANSI_STRING adsdata
Definition: btrfs_drv.h:345
bool ads
Definition: btrfs_drv.h:341
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
return STATUS_SUCCESS
Definition: btrfs.c:3014
struct _device_extension * Vcb
Definition: btrfs_drv.h:298
LONGLONG QuadPart
Definition: typedefs.h:114
uint32_t st_mode
Definition: btrfs.h:288

Referenced by query_info().

◆ fill_in_file_position_information()

static NTSTATUS fill_in_file_position_information ( FILE_POSITION_INFORMATION fpi,
PFILE_OBJECT  FileObject,
LONG length 
)
static

Definition at line 4158 of file fileinfo.c.

4158  {
4160 
4161  *length -= sizeof(FILE_POSITION_INFORMATION);
4162 
4163  fpi->CurrentByteOffset = FileObject->CurrentByteOffset;
4164 
4165  return STATUS_SUCCESS;
4166 }
struct _FILE_POSITION_INFORMATION FILE_POSITION_INFORMATION
LARGE_INTEGER CurrentByteOffset
Definition: nt_native.h:955
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:588
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by query_info().

◆ fill_in_file_standard_information()

static NTSTATUS fill_in_file_standard_information ( FILE_STANDARD_INFORMATION fsi,
fcb fcb,
file_ref fileref,
LONG length 
)
static

Definition at line 4109 of file fileinfo.c.

4109  {
4111 
4112  *length -= sizeof(FILE_STANDARD_INFORMATION);
4113 
4114  if (fcb->ads) {
4115  if (!fileref || !fileref->parent) {
4116  ERR("no fileref for stream\n");
4117  return STATUS_INTERNAL_ERROR;
4118  }
4119 
4121  fsi->NumberOfLinks = fileref->parent->fcb->inode_item.st_nlink;
4122  fsi->Directory = false;
4123  } else {
4128  }
4129 
4130  TRACE("length = %I64u\n", fsi->EndOfFile.QuadPart);
4131 
4132  fsi->DeletePending = fileref ? fileref->delete_on_close : false;
4133 
4134  return STATUS_SUCCESS;
4135 }
struct _file_ref * parent
Definition: btrfs_drv.h:368
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
uint32_t st_nlink
Definition: btrfs.h:285
uint64_t st_size
Definition: btrfs.h:282
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define S_ISDIR(mode)
Definition: various.h:18
LARGE_INTEGER AllocationSize
Definition: propsheet.cpp:54
#define FILE_STANDARD_INFORMATION
Definition: disk.h:54
INODE_ITEM inode_item
Definition: btrfs_drv.h:303
#define ERR(fmt,...)
Definition: debug.h:110
static __inline uint64_t fcb_alloc_size(fcb *fcb)
Definition: btrfs_drv.h:1870
ANSI_STRING adsdata
Definition: btrfs_drv.h:345
bool ads
Definition: btrfs_drv.h:341
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
return STATUS_SUCCESS
Definition: btrfs.c:3014
LONGLONG QuadPart
Definition: typedefs.h:114
uint32_t st_mode
Definition: btrfs.h:288
bool delete_on_close
Definition: btrfs_drv.h:360

Referenced by query_info().

◆ fill_in_file_standard_link_information()

static NTSTATUS fill_in_file_standard_link_information ( FILE_STANDARD_LINK_INFORMATION fsli,
fcb fcb,
file_ref fileref,
LONG length 
)
static

Definition at line 4443 of file fileinfo.c.

4443  {
4444  TRACE("FileStandardLinkInformation\n");
4445 
4446  // FIXME - NumberOfAccessibleLinks should subtract open links which have been marked as delete_on_close
4447 
4450  fsli->DeletePending = fileref ? fileref->delete_on_close : false;
4451  fsli->Directory = (!fcb->ads && fcb->type == BTRFS_TYPE_DIRECTORY) ? true : false;
4452 
4454 
4455  return STATUS_SUCCESS;
4456 }
uint32_t st_nlink
Definition: btrfs.h:285
#define BTRFS_TYPE_DIRECTORY
Definition: shellext.h:86
uint8_t type
Definition: btrfs_drv.h:302
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
INODE_ITEM inode_item
Definition: btrfs_drv.h:303
bool ads
Definition: btrfs_drv.h:341
return STATUS_SUCCESS
Definition: btrfs.c:3014
struct _FILE_STANDARD_LINK_INFORMATION FILE_STANDARD_LINK_INFORMATION
bool delete_on_close
Definition: btrfs_drv.h:360

Referenced by query_info().

◆ fill_in_file_stat_information()

static NTSTATUS fill_in_file_stat_information ( FILE_STAT_INFORMATION fsi,
fcb fcb,
ccb ccb,
LONG length 
)
static

Definition at line 4801 of file fileinfo.c.

4801  {
4802  INODE_ITEM* ii;
4803 
4805 
4806  if (fcb->ads)
4807  ii = &ccb->fileref->parent->fcb->inode_item;
4808  else
4809  ii = &fcb->inode_item;
4810 
4811  if (fcb == fcb->Vcb->dummy_fcb) {
4813 
4815  fsi->CreationTime = fsi->LastAccessTime = fsi->LastWriteTime = fsi->ChangeTime = time;
4816  } else {
4821  }
4822 
4823  if (fcb->ads) {
4825  fsi->FileAttributes = ccb->fileref->parent->fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : ccb->fileref->parent->fcb->atts;
4826  } else {
4830  }
4831 
4832  if (fcb->type == BTRFS_TYPE_SOCKET)
4834  else if (fcb->type == BTRFS_TYPE_FIFO)
4836  else if (fcb->type == BTRFS_TYPE_CHARDEV)
4838  else if (fcb->type == BTRFS_TYPE_BLOCKDEV)
4840  else if (!(fsi->FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
4841  fsi->ReparseTag = 0;
4842  else
4844 
4847 
4848  if (fcb->ads)
4849  fsi->NumberOfLinks = ccb->fileref->parent->fcb->inode_item.st_nlink;
4850  else
4852 
4853  fsi->EffectiveAccess = ccb->access;
4854 
4855  *length -= sizeof(FILE_STAT_INFORMATION);
4856 
4857  return STATUS_SUCCESS;
4858 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
LARGE_INTEGER EndOfFile
Definition: fileinfo.c:46
struct _file_ref * parent
Definition: btrfs_drv.h:368
#define BTRFS_TYPE_SOCKET
Definition: shellext.h:90
BTRFS_TIME otime
Definition: btrfs.h:296
#define IO_REPARSE_TAG_LX_FIFO
Definition: btrfs_drv.h:125
#define BTRFS_TYPE_BLOCKDEV
Definition: shellext.h:88
#define BTRFS_TYPE_FIFO
Definition: shellext.h:89
LARGE_INTEGER ChangeTime
Definition: fileinfo.c:44
__u16 time
Definition: mkdosfs.c:366
ACCESS_MASK access
Definition: btrfs_drv.h:398
#define BTRFS_TYPE_CHARDEV
Definition: shellext.h:87
LARGE_INTEGER LastAccessTime
Definition: fileinfo.c:42
BTRFS_TIME st_ctime
Definition: btrfs.h:294
static __inline uint64_t make_file_id(root *r, uint64_t inode)
Definition: btrfs_drv.h:1020
struct _FILE_STAT_INFORMATION FILE_STAT_INFORMATION
uint32_t st_nlink
Definition: btrfs.h:285
LARGE_INTEGER FileId
Definition: fileinfo.c:40
uint8_t type
Definition: btrfs_drv.h:302
LARGE_INTEGER CreationTime
Definition: fileinfo.c:41
#define FILE_ATTRIBUTE_REPARSE_POINT
Definition: ntifs_ex.h:381
BTRFS_TIME st_mtime
Definition: btrfs.h:295
static __inline uint64_t unix_time_to_win(BTRFS_TIME *t)
Definition: recv.cpp:1180
uint64_t st_size
Definition: btrfs.h:282
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
uint64_t inode
Definition: btrfs_drv.h:300
#define S_ISDIR(mode)
Definition: various.h:18
#define IO_REPARSE_TAG_LX_BLK
Definition: btrfs_drv.h:127
BTRFS_TIME st_atime
Definition: btrfs.h:293
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
LARGE_INTEGER AllocationSize
Definition: fileinfo.c:45
INODE_ITEM inode_item
Definition: btrfs_drv.h:303
ULONG get_reparse_tag_fcb(fcb *fcb)
Definition: dirctrl.c:83
ULONG atts
Definition: btrfs_drv.h:308
#define IO_REPARSE_TAG_AF_UNIX
Definition: btrfs_drv.h:124
static __inline uint64_t fcb_alloc_size(fcb *fcb)
Definition: btrfs_drv.h:1870
struct _root * subvol
Definition: btrfs_drv.h:299
ANSI_STRING adsdata
Definition: btrfs_drv.h:345
#define IO_REPARSE_TAG_LX_CHR
Definition: btrfs_drv.h:126
bool ads
Definition: btrfs_drv.h:341
LARGE_INTEGER LastWriteTime
Definition: fileinfo.c:43
file_ref * fileref
Definition: btrfs_drv.h:399
return STATUS_SUCCESS
Definition: btrfs.c:3014
ACCESS_MASK EffectiveAccess
Definition: fileinfo.c:50
struct _device_extension * Vcb
Definition: btrfs_drv.h:298
LONGLONG QuadPart
Definition: typedefs.h:114
uint32_t st_mode
Definition: btrfs.h:288

Referenced by query_info().

◆ fill_in_file_stat_lx_information()

static NTSTATUS fill_in_file_stat_lx_information ( FILE_STAT_LX_INFORMATION fsli,
fcb fcb,
ccb ccb,
LONG length 
)
static

Definition at line 4860 of file fileinfo.c.

4860  {
4861  INODE_ITEM* ii;
4862 
4864 
4865  if (fcb->ads)
4866  ii = &ccb->fileref->parent->fcb->inode_item;
4867  else
4868  ii = &fcb->inode_item;
4869 
4870  if (fcb == fcb->Vcb->dummy_fcb) {
4872 
4874  fsli->CreationTime = fsli->LastAccessTime = fsli->LastWriteTime = fsli->ChangeTime = time;
4875  } else {
4880  }
4881 
4882  if (fcb->ads) {
4884  fsli->FileAttributes = ccb->fileref->parent->fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : ccb->fileref->parent->fcb->atts;
4885  } else {
4888  fsli->FileAttributes = fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : fcb->atts;
4889  }
4890 
4891  if (fcb->type == BTRFS_TYPE_SOCKET)
4893  else if (fcb->type == BTRFS_TYPE_FIFO)
4895  else if (fcb->type == BTRFS_TYPE_CHARDEV)
4897  else if (fcb->type == BTRFS_TYPE_BLOCKDEV)
4899  else if (!(fsli->FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
4900  fsli->ReparseTag = 0;
4901  else
4903 
4906 
4907  if (fcb->ads)
4908  fsli->NumberOfLinks = ccb->fileref->parent->fcb->inode_item.st_nlink;
4909  else
4911 
4912  fsli->EffectiveAccess = ccb->access;
4914 
4915  if (fcb->case_sensitive)
4917 
4918  fsli->LxUid = ii->st_uid;
4919  fsli->LxGid = ii->st_gid;
4920  fsli->LxMode = ii->st_mode;
4921 
4922  if (ii->st_mode & __S_IFBLK || ii->st_mode & __S_IFCHR) {
4923  fsli->LxDeviceIdMajor = (ii->st_rdev & 0xFFFFFFFFFFF00000) >> 20;
4924  fsli->LxDeviceIdMinor = (ii->st_rdev & 0xFFFFF);
4925  } else {
4926  fsli->LxDeviceIdMajor = 0;
4927  fsli->LxDeviceIdMinor = 0;
4928  }
4929 
4930  *length -= sizeof(FILE_STAT_LX_INFORMATION);
4931 
4932  return STATUS_SUCCESS;
4933 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
struct _file_ref * parent
Definition: btrfs_drv.h:368
#define LX_FILE_METADATA_HAS_DEVICE_ID
Definition: fileinfo.c:76
#define BTRFS_TYPE_SOCKET
Definition: shellext.h:90
BTRFS_TIME otime
Definition: btrfs.h:296
#define IO_REPARSE_TAG_LX_FIFO
Definition: btrfs_drv.h:125
#define BTRFS_TYPE_BLOCKDEV
Definition: shellext.h:88
LARGE_INTEGER CreationTime
Definition: fileinfo.c:55
#define BTRFS_TYPE_FIFO
Definition: shellext.h:89
__u16 time
Definition: mkdosfs.c:366
ACCESS_MASK access
Definition: btrfs_drv.h:398
#define BTRFS_TYPE_CHARDEV
Definition: shellext.h:87
BTRFS_TIME st_ctime
Definition: btrfs.h:294
#define LX_FILE_METADATA_HAS_MODE
Definition: fileinfo.c:75
static __inline uint64_t make_file_id(root *r, uint64_t inode)
Definition: btrfs_drv.h:1020
uint32_t st_gid
Definition: btrfs.h:287
uint32_t st_nlink
Definition: btrfs.h:285
LARGE_INTEGER LastAccessTime
Definition: fileinfo.c:56
uint8_t type
Definition: btrfs_drv.h:302
#define FILE_ATTRIBUTE_REPARSE_POINT
Definition: ntifs_ex.h:381
BTRFS_TIME st_mtime
Definition: btrfs.h:295
static __inline uint64_t unix_time_to_win(BTRFS_TIME *t)
Definition: recv.cpp:1180
uint64_t st_size
Definition: btrfs.h:282
#define LX_FILE_CASE_SENSITIVE_DIR
Definition: fileinfo.c:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
uint64_t inode
Definition: btrfs_drv.h:300
uint64_t st_rdev
Definition: btrfs.h:289
#define S_ISDIR(mode)
Definition: various.h:18
#define IO_REPARSE_TAG_LX_BLK
Definition: btrfs_drv.h:127
bool case_sensitive
Definition: btrfs_drv.h:321
#define __S_IFCHR
Definition: btrfs_drv.h:1801
BTRFS_TIME st_atime
Definition: btrfs.h:293
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define LX_FILE_METADATA_HAS_GID
Definition: fileinfo.c:74
INODE_ITEM inode_item
Definition: btrfs_drv.h:303
LARGE_INTEGER EndOfFile
Definition: fileinfo.c:60
ULONG get_reparse_tag_fcb(fcb *fcb)
Definition: dirctrl.c:83
ULONG atts
Definition: btrfs_drv.h:308
#define IO_REPARSE_TAG_AF_UNIX
Definition: btrfs_drv.h:124
static __inline uint64_t fcb_alloc_size(fcb *fcb)
Definition: btrfs_drv.h:1870
struct _root * subvol
Definition: btrfs_drv.h:299
ANSI_STRING adsdata
Definition: btrfs_drv.h:345
#define IO_REPARSE_TAG_LX_CHR
Definition: btrfs_drv.h:126
struct _FILE_STAT_LX_INFORMATION FILE_STAT_LX_INFORMATION
LARGE_INTEGER ChangeTime
Definition: fileinfo.c:58
bool ads
Definition: btrfs_drv.h:341
#define LX_FILE_METADATA_HAS_UID
Definition: fileinfo.c:73
LARGE_INTEGER AllocationSize
Definition: fileinfo.c:59
LARGE_INTEGER LastWriteTime
Definition: fileinfo.c:57
#define __S_IFBLK
Definition: btrfs_drv.h:1802
file_ref * fileref
Definition: btrfs_drv.h:399
uint32_t st_uid
Definition: btrfs.h:286
return STATUS_SUCCESS
Definition: btrfs.c:3014
struct _device_extension * Vcb
Definition: btrfs_drv.h:298
ACCESS_MASK EffectiveAccess
Definition: fileinfo.c:64
LONGLONG QuadPart
Definition: typedefs.h:114
LARGE_INTEGER FileId
Definition: fileinfo.c:54
uint32_t st_mode
Definition: btrfs.h:288

Referenced by query_info().

◆ fill_in_file_stream_information()

static NTSTATUS fill_in_file_stream_information ( FILE_STREAM_INFORMATION fsi,
file_ref fileref,
LONG length 
)
static

Definition at line 4333 of file fileinfo.c.

4333  {
4334  LONG reqsize;
4335  LIST_ENTRY* le;
4336  FILE_STREAM_INFORMATION *entry, *lastentry;
4337  NTSTATUS Status;
4338 
4339  static const WCHAR datasuf[] = L":$DATA";
4340  UNICODE_STRING suf;
4341 
4342  if (!fileref) {
4343  ERR("fileref was NULL\n");
4344  return STATUS_INVALID_PARAMETER;
4345  }
4346 
4347  suf.Buffer = (WCHAR*)datasuf;
4348  suf.Length = suf.MaximumLength = sizeof(datasuf) - sizeof(WCHAR);
4349 
4350  if (fileref->fcb->type != BTRFS_TYPE_DIRECTORY)
4351  reqsize = sizeof(FILE_STREAM_INFORMATION) - sizeof(WCHAR) + suf.Length + sizeof(WCHAR);
4352  else
4353  reqsize = 0;
4354 
4355  ExAcquireResourceSharedLite(&fileref->fcb->nonpaged->dir_children_lock, true);
4356 
4357  le = fileref->fcb->dir_children_index.Flink;
4358  while (le != &fileref->fcb->dir_children_index) {
4359  dir_child* dc = CONTAINING_RECORD(le, dir_child, list_entry_index);
4360 
4361  if (dc->index == 0) {
4362  reqsize = (ULONG)sector_align(reqsize, sizeof(LONGLONG));
4363  reqsize += sizeof(FILE_STREAM_INFORMATION) - sizeof(WCHAR) + suf.Length + sizeof(WCHAR) + dc->name.Length;
4364  } else
4365  break;
4366 
4367  le = le->Flink;
4368  }
4369 
4370  TRACE("length = %li, reqsize = %lu\n", *length, reqsize);
4371 
4372  if (reqsize > *length) {
4374  goto end;
4375  }
4376 
4377  entry = fsi;
4378  lastentry = NULL;
4379 
4380  if (fileref->fcb->type != BTRFS_TYPE_DIRECTORY) {
4381  ULONG off;
4382 
4383  entry->NextEntryOffset = 0;
4384  entry->StreamNameLength = suf.Length + sizeof(WCHAR);
4385  entry->StreamSize.QuadPart = fileref->fcb->inode_item.st_size;
4386  entry->StreamAllocationSize.QuadPart = fcb_alloc_size(fileref->fcb);
4387 
4388  entry->StreamName[0] = ':';
4389  RtlCopyMemory(&entry->StreamName[1], suf.Buffer, suf.Length);
4390 
4391  off = (ULONG)sector_align(sizeof(FILE_STREAM_INFORMATION) - sizeof(WCHAR) + suf.Length + sizeof(WCHAR), sizeof(LONGLONG));
4392 
4393  lastentry = entry;
4395  }
4396 
4397  le = fileref->fcb->dir_children_index.Flink;
4398  while (le != &fileref->fcb->dir_children_index) {
4399  dir_child* dc = CONTAINING_RECORD(le, dir_child, list_entry_index);
4400 
4401  if (dc->index == 0) {
4402  ULONG off;
4403 
4404  entry->NextEntryOffset = 0;
4405  entry->StreamNameLength = dc->name.Length + suf.Length + sizeof(WCHAR);
4406 
4407  if (dc->fileref)
4408  entry->StreamSize.QuadPart = dc->fileref->fcb->adsdata.Length;
4409  else
4410  entry->StreamSize.QuadPart = dc->size;
4411 
4412  entry->StreamAllocationSize.QuadPart = entry->StreamSize.QuadPart;
4413 
4414  entry->StreamName[0] = ':';
4415 
4416  RtlCopyMemory(&entry->StreamName[1], dc->name.Buffer, dc->name.Length);
4417  RtlCopyMemory(&entry->StreamName[1 + (dc->name.Length / sizeof(WCHAR))], suf.Buffer, suf.Length);
4418 
4419  if (lastentry)
4420  lastentry->NextEntryOffset = (uint32_t)((uint8_t*)entry - (uint8_t*)lastentry);
4421 
4422  off = (ULONG)sector_align(sizeof(FILE_STREAM_INFORMATION) - sizeof(WCHAR) + suf.Length + sizeof(WCHAR) + dc->name.Length, sizeof(LONGLONG));
4423 
4424  lastentry = entry;
4426  } else
4427  break;
4428 
4429  le = le->Flink;
4430  }
4431 
4432  *length -= reqsize;
4433 
4435 
4436 end:
4437  ExReleaseResourceLite(&fileref->fcb->nonpaged->dir_children_lock);
4438 
4439  return Status;
4440 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
struct _FILE_STREAM_INFORMATION FILE_STREAM_INFORMATION
GLuint GLuint end
Definition: gl.h:1545
long LONG
Definition: pedump.c:60
#define BTRFS_TYPE_DIRECTORY
Definition: shellext.h:86
smooth NULL
Definition: ftsmooth.c:416
uint8_t type
Definition: btrfs_drv.h:302
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
int64_t LONGLONG
Definition: typedefs.h:68
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
uint64_t st_size
Definition: btrfs.h:282
#define TRACE(s)
Definition: solgame.cpp:4
LIST_ENTRY dir_children_index
Definition: btrfs_drv.h:325
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
Status
Definition: gdiplustypes.h:24
static const WCHAR L[]
Definition: oid.c:1250
uint32_t entry
Definition: isohybrid.c:63
fcb * fcb
Definition: btrfs_drv.h:357
Definition: typedefs.h:119
INODE_ITEM inode_item
Definition: btrfs_drv.h:303
BYTE uint8_t
Definition: msvideo1.c:66
#define ERR(fmt,...)
Definition: debug.h:110
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
struct _fcb_nonpaged * nonpaged
Definition: btrfs_drv.h:295
static __inline uint64_t fcb_alloc_size(fcb *fcb)
Definition: btrfs_drv.h:1870
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
unsigned int ULONG
Definition: retypes.h:1
static const WCHAR dc[]
#define uint32_t
Definition: nsiface.idl:61
return STATUS_SUCCESS
Definition: btrfs.c:3014
static uint64_t __inline sector_align(uint64_t n, uint64_t a)
off
Definition: i386-dis.c:3909

Referenced by query_info().

◆ fill_in_hard_link_full_id_information()

static NTSTATUS fill_in_hard_link_full_id_information ( FILE_LINKS_FULL_ID_INFORMATION flfii,
file_ref fileref,
PIRP  Irp,
LONG length 
)
static

Definition at line 4620 of file fileinfo.c.

4620  {
4621  NTSTATUS Status;
4622  LIST_ENTRY* le;
4623  LONG bytes_needed;
4625  bool overflow = false;
4626  fcb* fcb = fileref->fcb;
4627  ULONG len;
4628 
4629  if (fcb->ads)
4630  return STATUS_INVALID_PARAMETER;
4631 
4633  return STATUS_INVALID_PARAMETER;
4634 
4635  RtlZeroMemory(flfii, *length);
4636 
4638  len = bytes_needed;
4639  flefii = NULL;
4640 
4641  ExAcquireResourceSharedLite(fcb->Header.Resource, true);
4642 
4643  if (fcb->inode == SUBVOL_ROOT_INODE) {
4644  ULONG namelen;
4645 
4646  if (fcb == fcb->Vcb->root_fileref->fcb)
4647  namelen = sizeof(WCHAR);
4648  else
4649  namelen = fileref->dc->name.Length;
4650 
4652 
4653  if (bytes_needed > *length)
4654  overflow = true;
4655 
4656  if (!overflow) {
4657  flefii = &flfii->Entry;
4658 
4659  flefii->NextEntryOffset = 0;
4660 
4661  if (fcb == fcb->Vcb->root_fileref->fcb) {
4662  RtlZeroMemory(&flefii->ParentFileId.Identifier[0], sizeof(FILE_ID_128));
4663  flefii->FileNameLength = 1;
4664  flefii->FileName[0] = '.';
4665  } else {
4666  RtlCopyMemory(&flefii->ParentFileId.Identifier[0], &fileref->parent->fcb->inode, sizeof(uint64_t));
4667  RtlCopyMemory(&flefii->ParentFileId.Identifier[sizeof(uint64_t)], &fileref->parent->fcb->subvol->id, sizeof(uint64_t));
4668 
4669  flefii->FileNameLength = fileref->dc->name.Length / sizeof(WCHAR);
4670  RtlCopyMemory(flefii->FileName, fileref->dc->name.Buffer, fileref->dc->name.Length);
4671  }
4672 
4673  flfii->EntriesReturned++;
4674 
4675  len = bytes_needed;
4676  }
4677  } else {
4678  ExAcquireResourceExclusiveLite(&fcb->Vcb->fileref_lock, true);
4679 
4680  if (IsListEmpty(&fcb->hardlinks)) {
4681  bytes_needed += offsetof(FILE_LINK_ENTRY_FULL_ID_INFORMATION, FileName[0]) + fileref->dc->name.Length;
4682 
4683  if (bytes_needed > *length)
4684  overflow = true;
4685 
4686  if (!overflow) {
4687  flefii = &flfii->Entry;
4688 
4689  flefii->NextEntryOffset = 0;
4690 
4691  RtlCopyMemory(&flefii->ParentFileId.Identifier[0], &fileref->parent->fcb->inode, sizeof(uint64_t));
4692  RtlCopyMemory(&flefii->ParentFileId.Identifier[sizeof(uint64_t)], &fileref->parent->fcb->subvol->id, sizeof(uint64_t));
4693 
4694  flefii->FileNameLength = fileref->dc->name.Length / sizeof(WCHAR);
4695  RtlCopyMemory(flefii->FileName, fileref->dc->name.Buffer, fileref->dc->name.Length);
4696 
4697  flfii->EntriesReturned++;
4698 
4699  len = bytes_needed;
4700  }
4701  } else {
4702  le = fcb->hardlinks.Flink;
4703  while (le != &fcb->hardlinks) {
4705  file_ref* parfr;
4706 
4707  TRACE("parent %I64x, index %I64x, name %.*S\n", hl->parent, hl->index, (int)(hl->name.Length / sizeof(WCHAR)), hl->name.Buffer);
4708 
4709  Status = open_fileref_by_inode(fcb->Vcb, fcb->subvol, hl->parent, &parfr, Irp);
4710 
4711  if (!NT_SUCCESS(Status)) {
4712  ERR("open_fileref_by_inode returned %08lx\n", Status);
4713  } else if (!parfr->deleted) {
4714  LIST_ENTRY* le2;
4715  bool found = false, deleted = false;
4716  UNICODE_STRING* fn = NULL;
4717 
4718  le2 = parfr->children.Flink;
4719  while (le2 != &parfr->children) {
4721 
4722  if (fr2->dc->index == hl->index) {
4723  found = true;
4724  deleted = fr2->deleted;
4725 
4726  if (!deleted)
4727  fn = &fr2->dc->name;
4728 
4729  break;
4730  }
4731 
4732  le2 = le2->Flink;
4733  }
4734 
4735  if (!found)
4736  fn = &hl->name;
4737 
4738  if (!deleted) {
4739  TRACE("fn = %.*S (found = %u)\n", (int)(fn->Length / sizeof(WCHAR)), fn->Buffer, found);
4740 
4741  if (flefii)
4742  bytes_needed = (LONG)sector_align(bytes_needed, 8);
4743 
4744  bytes_needed += offsetof(FILE_LINK_ENTRY_FULL_ID_INFORMATION, FileName[0]) + fn->Length;
4745 
4746  if (bytes_needed > *length)
4747  overflow = true;
4748 
4749  if (!overflow) {
4750  if (flefii) {
4752  flefii = (FILE_LINK_ENTRY_FULL_ID_INFORMATION*)((uint8_t*)flefii + flefii->NextEntryOffset);
4753  } else
4754  flefii = &flfii->Entry;
4755 
4756  flefii->NextEntryOffset = 0;
4757 
4758  RtlCopyMemory(&flefii->ParentFileId.Identifier[0], &parfr->fcb->inode, sizeof(uint64_t));
4759  RtlCopyMemory(&flefii->ParentFileId.Identifier[sizeof(uint64_t)], &parfr->fcb->subvol->id, sizeof(uint64_t));
4760 
4761  flefii->FileNameLength = fn->Length / sizeof(WCHAR);
4762  RtlCopyMemory(flefii->FileName, fn->Buffer, fn->Length);
4763 
4764  flfii->EntriesReturned++;
4765 
4766  len = bytes_needed;
4767  }
4768  }
4769 
4770  free_fileref(parfr);
4771  }
4772 
4773  le = le->Flink;
4774  }
4775  }
4776 
4777  ExReleaseResourceLite(&fcb->Vcb->fileref_lock);
4778  }
4779 
4780  flfii->BytesNeeded = bytes_needed;
4781 
4782  *length -=