ReactOS  0.4.15-dev-4921-g25fcdc5
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)
 
void add_fcb_to_subvol (_In_ _Requires_exclusive_lock_held_(_Curr_->Vcb->fcb_lock) fcb *fcb)
 
void remove_fcb_from_subvol (_In_ _Requires_exclusive_lock_held_(_Curr_->Vcb->fcb_lock) fcb *fcb)
 
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 3880 of file fileinfo.c.

3882  {
3883  NTSTATUS Status;
3885  device_extension* Vcb = DeviceObject->DeviceExtension;
3886  fcb* fcb = IrpSp->FileObject->FsContext;
3887  ccb* ccb = IrpSp->FileObject->FsContext2;
3888  bool top_level;
3889 
3891 
3892  top_level = is_top_level(Irp);
3893 
3894  Irp->IoStatus.Information = 0;
3895 
3896  if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
3898  goto end;
3899  } else if (!Vcb || Vcb->type != VCB_TYPE_FS) {
3901  goto end;
3902  }
3903 
3904  if (!(Vcb->Vpb->Flags & VPB_MOUNTED)) {
3906  goto end;
3907  }
3908 
3909  if (Vcb->readonly && IrpSp->Parameters.SetFile.FileInformationClass != FilePositionInformation) {
3911  goto end;
3912  }
3913 
3914  if (!fcb) {
3915  ERR("no fcb\n");
3917  goto end;
3918  }
3919 
3920  if (!ccb) {
3921  ERR("no ccb\n");
3923  goto end;
3924  }
3925 
3926  if (fcb != Vcb->dummy_fcb && is_subvol_readonly(fcb->subvol, Irp) && IrpSp->Parameters.SetFile.FileInformationClass != FilePositionInformation &&
3927 #ifndef __REACTOS__
3928  (fcb->inode != SUBVOL_ROOT_INODE || (IrpSp->Parameters.SetFile.FileInformationClass != FileBasicInformation && IrpSp->Parameters.SetFile.FileInformationClass != FileRenameInformation && IrpSp->Parameters.SetFile.FileInformationClass != FileRenameInformationEx))) {
3929 #else
3930  (fcb->inode != SUBVOL_ROOT_INODE || (IrpSp->Parameters.SetFile.FileInformationClass != FileBasicInformation && IrpSp->Parameters.SetFile.FileInformationClass != FileRenameInformation))) {
3931 #endif
3933  goto end;
3934  }
3935 
3937 
3938  TRACE("set information\n");
3939 
3941 
3942  switch (IrpSp->Parameters.SetFile.FileInformationClass) {
3944  {
3945  TRACE("FileAllocationInformation\n");
3946 
3947  if (Irp->RequestorMode == UserMode && !(ccb->access & FILE_WRITE_DATA)) {
3948  WARN("insufficient privileges\n");
3950  break;
3951  }
3952 
3954  break;
3955  }
3956 
3957  case FileBasicInformation:
3958  {
3959  TRACE("FileBasicInformation\n");
3960 
3961  if (Irp->RequestorMode == UserMode && !(ccb->access & FILE_WRITE_ATTRIBUTES)) {
3962  WARN("insufficient privileges\n");
3964  break;
3965  }
3966 
3968 
3969  break;
3970  }
3971 
3973  {
3974  TRACE("FileDispositionInformation\n");
3975 
3976  if (Irp->RequestorMode == UserMode && !(ccb->access & DELETE)) {
3977  WARN("insufficient privileges\n");
3979  break;
3980  }
3981 
3983 
3984  break;
3985  }
3986 
3988  {
3989  TRACE("FileEndOfFileInformation\n");
3990 
3991  if (Irp->RequestorMode == UserMode && !(ccb->access & (FILE_WRITE_DATA | FILE_APPEND_DATA))) {
3992  WARN("insufficient privileges\n");
3994  break;
3995  }
3996 
3997  Status = set_end_of_file_information(Vcb, Irp, IrpSp->FileObject, IrpSp->Parameters.SetFile.AdvanceOnly, false);
3998 
3999  break;
4000  }
4001 
4002  case FileLinkInformation:
4003  TRACE("FileLinkInformation\n");
4004  Status = set_link_information(Vcb, Irp, IrpSp->FileObject, IrpSp->Parameters.SetFile.FileObject, false);
4005  break;
4006 
4008  TRACE("FilePositionInformation\n");
4010  break;
4011 
4012  case FileRenameInformation:
4013  TRACE("FileRenameInformation\n");
4014  Status = set_rename_information(Vcb, Irp, IrpSp->FileObject, IrpSp->Parameters.SetFile.FileObject, false);
4015  break;
4016 
4018  {
4019  TRACE("FileValidDataLengthInformation\n");
4020 
4021  if (Irp->RequestorMode == UserMode && !(ccb->access & (FILE_WRITE_DATA | FILE_APPEND_DATA))) {
4022  WARN("insufficient privileges\n");
4024  break;
4025  }
4026 
4028 
4029  break;
4030  }
4031 
4032 #ifndef __REACTOS__
4033 #ifndef _MSC_VER
4034 #pragma GCC diagnostic push
4035 #pragma GCC diagnostic ignored "-Wswitch"
4036 #endif
4038  {
4039  TRACE("FileDispositionInformationEx\n");
4040 
4041  if (Irp->RequestorMode == UserMode && !(ccb->access & DELETE)) {
4042  WARN("insufficient privileges\n");
4044  break;
4045  }
4046 
4048 
4049  break;
4050  }
4051 
4053  TRACE("FileRenameInformationEx\n");
4054  Status = set_rename_information(Vcb, Irp, IrpSp->FileObject, IrpSp->Parameters.SetFile.FileObject, true);
4055  break;
4056 
4057  case FileLinkInformationEx:
4058  TRACE("FileLinkInformationEx\n");
4059  Status = set_link_information(Vcb, Irp, IrpSp->FileObject, IrpSp->Parameters.SetFile.FileObject, true);
4060  break;
4061 
4063  TRACE("FileCaseSensitiveInformation\n");
4064 
4065  if (Irp->RequestorMode == UserMode && !(ccb->access & FILE_WRITE_ATTRIBUTES)) {
4066  WARN("insufficient privileges\n");
4068  break;
4069  }
4070 
4072  break;
4073 
4075  WARN("unimplemented FileInformationClass FileStorageReserveIdInformation\n");
4076  break;
4077 
4078 #ifndef _MSC_VER
4079 #pragma GCC diagnostic pop
4080 #endif
4081 #endif
4082 
4083  default:
4084  WARN("unknown FileInformationClass %u\n", IrpSp->Parameters.SetFile.FileInformationClass);
4085  }
4086 
4087 end:
4088  Irp->IoStatus.Status = Status;
4089 
4090  TRACE("returning %08lx\n", Status);
4091 
4093 
4094  if (top_level)
4096 
4098 
4099  return Status;
4100 }
static NTSTATUS set_basic_information(device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject)
Definition: fileinfo.c:190
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
static NTSTATUS set_case_sensitive_information(PIRP Irp)
Definition: fileinfo.c:3847
#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 STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define VCB_TYPE_FS
Definition: btrfs_drv.h:679
#define FileDispositionInformationEx
Definition: fileinfo.c:26
ACCESS_MASK access
Definition: btrfs_drv.h:382
#define FILE_APPEND_DATA
Definition: nt_native.h:634
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:277
#define FileStorageReserveIdInformation
Definition: fileinfo.c:32
static NTSTATUS set_valid_data_length_information(device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject)
Definition: fileinfo.c:3751
#define FILE_WRITE_ATTRIBUTES
Definition: nt_native.h:649
static NTSTATUS set_position_information(PFILE_OBJECT FileObject, PIRP Irp)
Definition: fileinfo.c:3385
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
_In_ PIRP Irp
Definition: csq.h:116
static __inline bool is_subvol_readonly(root *r, PIRP Irp)
Definition: btrfs_drv.h:1025
static NTSTATUS set_disposition_information(device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject, bool ex)
Definition: fileinfo.c:357
#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
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:681
uint64_t inode
Definition: btrfs_drv.h:289
#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:2527
#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:3240
GLuint GLuint end
Definition: gl.h:1545
static NTSTATUS set_link_information(device_extension *Vcb, PIRP Irp, PFILE_OBJECT FileObject, PFILE_OBJECT tfo, bool ex)
Definition: fileinfo.c:3397
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
#define ERR(fmt,...)
Definition: debug.h:110
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
#define FileRenameInformationEx
Definition: fileinfo.c:27
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
struct _root * subvol
Definition: btrfs_drv.h:288
#define NULL
Definition: types.h:112
static __inline POPLOCK fcb_oplock(fcb *fcb)
Definition: btrfs_drv.h:1670
#define FileLinkInformationEx
Definition: fileinfo.c:31
#define IO_NO_INCREMENT
Definition: iotypes.h:598
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:1170
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define VPB_MOUNTED
Definition: iotypes.h:1807
#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 5409 of file fileinfo.c.

5411  {
5413  NTSTATUS Status;
5414  fcb* fcb;
5415  device_extension* Vcb = DeviceObject->DeviceExtension;
5416  bool top_level;
5417 
5419 
5420  top_level = is_top_level(Irp);
5421 
5422  if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
5424  goto end;
5425  } else if (!Vcb || Vcb->type != VCB_TYPE_FS) {
5427  goto end;
5428  }
5429 
5430  Irp->IoStatus.Information = 0;
5431 
5432  TRACE("query information\n");
5433 
5435 
5436  fcb = IrpSp->FileObject->FsContext;
5437  TRACE("fcb = %p\n", fcb);
5438  TRACE("fcb->subvol = %p\n", fcb->subvol);
5439 
5441 
5442 end:
5443  TRACE("returning %08lx\n", Status);
5444 
5445  Irp->IoStatus.Status = Status;
5446 
5448 
5449  if (top_level)
5451 
5453 
5454  return Status;
5455 }
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define VCB_TYPE_FS
Definition: btrfs_drv.h:679
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:277
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
struct _fcb fcb
Definition: btrfs_drv.h:1355
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:681
#define Vcb
Definition: cdprocs.h:1415
GLuint GLuint end
Definition: gl.h:1545
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
struct _root * subvol
Definition: btrfs_drv.h:288
#define NULL
Definition: types.h:112
#define IO_NO_INCREMENT
Definition: iotypes.h:598
static NTSTATUS query_info(device_extension *Vcb, PFILE_OBJECT FileObject, PIRP Irp)
Definition: fileinfo.c:5033
struct _device_extension * Vcb
Definition: btrfs_drv.h:287

◆ _Dispatch_type_() [3/4]

_Dispatch_type_ ( IRP_MJ_QUERY_EA  )

Definition at line 5457 of file fileinfo.c.

5459  {
5460  NTSTATUS Status;
5461  bool top_level;
5462  device_extension* Vcb = DeviceObject->DeviceExtension;
5465  fcb* fcb;
5466  ccb* ccb;
5468  ULONG retlen = 0;
5469 
5471 
5472  TRACE("(%p, %p)\n", DeviceObject, Irp);
5473 
5474  top_level = is_top_level(Irp);
5475 
5476  if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
5478  goto end;
5479  } else if (!Vcb || Vcb->type != VCB_TYPE_FS) {
5481  goto end;
5482  }
5483 
5485  if (!ffei) {
5486  ERR("could not get output buffer\n");
5488  goto end;
5489  }
5490 
5491  if (!FileObject) {
5492  ERR("no file object\n");
5494  goto end;
5495  }
5496 
5497  fcb = FileObject->FsContext;
5498 
5499  if (!fcb) {
5500  ERR("no fcb\n");
5502  goto end;
5503  }
5504 
5505  ccb = FileObject->FsContext2;
5506 
5507  if (!ccb) {
5508  ERR("no ccb\n");
5510  goto end;
5511  }
5512 
5513  if (Irp->RequestorMode == UserMode && !(ccb->access & (FILE_READ_EA | FILE_WRITE_EA))) {
5514  WARN("insufficient privileges\n");
5516  goto end;
5517  }
5518 
5519  if (fcb->ads)
5520  fcb = ccb->fileref->parent->fcb;
5521 
5522  ExAcquireResourceSharedLite(fcb->Header.Resource, true);
5523 
5524  if (fcb->ea_xattr.Length == 0) {
5526  goto end2;
5527  }
5528 
5530 
5531  if (IrpSp->Parameters.QueryEa.EaList) {
5534 
5535  in = IrpSp->Parameters.QueryEa.EaList;
5536  do {
5537  STRING s;
5538 
5539  s.Length = s.MaximumLength = in->EaNameLength;
5540  s.Buffer = in->EaName;
5541 
5542  RtlUpperString(&s, &s);
5543 
5544  if (in->NextEntryOffset == 0)
5545  break;
5546 
5547  in = (FILE_GET_EA_INFORMATION*)(((uint8_t*)in) + in->NextEntryOffset);
5548  } while (true);
5549 
5551  out = NULL;
5552 
5553  do {
5554  bool found = false;
5555 
5556  in = IrpSp->Parameters.QueryEa.EaList;
5557  do {
5558  if (in->EaNameLength == ea->EaNameLength &&
5559  RtlCompareMemory(in->EaName, ea->EaName, in->EaNameLength) == in->EaNameLength) {
5560  found = true;
5561  break;
5562  }
5563 
5564  if (in->NextEntryOffset == 0)
5565  break;
5566 
5567  in = (FILE_GET_EA_INFORMATION*)(((uint8_t*)in) + in->NextEntryOffset);
5568  } while (true);
5569 
5570  if (found) {
5571  uint8_t padding = retlen % 4 > 0 ? (4 - (retlen % 4)) : 0;
5572 
5573  if (offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + ea->EaNameLength + 1 + ea->EaValueLength > IrpSp->Parameters.QueryEa.Length - retlen - padding) {
5575  retlen = 0;
5576  goto end2;
5577  }
5578 
5579  retlen += padding;
5580 
5581  if (out) {
5582  out->NextEntryOffset = (ULONG)offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + out->EaNameLength + 1 + out->EaValueLength + padding;
5583  out = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)out) + out->NextEntryOffset);
5584  } else
5585  out = ffei;
5586 
5587  out->NextEntryOffset = 0;
5588  out->Flags = ea->Flags;
5589  out->EaNameLength = ea->EaNameLength;
5590  out->EaValueLength = ea->EaValueLength;
5591  RtlCopyMemory(out->EaName, ea->EaName, ea->EaNameLength + ea->EaValueLength + 1);
5592 
5593  retlen += (ULONG)offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + ea->EaNameLength + 1 + ea->EaValueLength;
5594 
5596  break;
5597  }
5598 
5599  if (ea->NextEntryOffset == 0)
5600  break;
5601 
5602  ea = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)ea) + ea->NextEntryOffset);
5603  } while (true);
5604  } else {
5606  ULONG index;
5607 
5608  if (IrpSp->Flags & SL_INDEX_SPECIFIED) {
5609  // The index is 1-based
5610  if (IrpSp->Parameters.QueryEa.EaIndex == 0) {
5612  goto end2;
5613  } else
5614  index = IrpSp->Parameters.QueryEa.EaIndex - 1;
5615  } else if (IrpSp->Flags & SL_RESTART_SCAN)
5616  index = ccb->ea_index = 0;
5617  else
5618  index = ccb->ea_index;
5619 
5621 
5622  if (index > 0) {
5623  ULONG i;
5624 
5625  for (i = 0; i < index; i++) {
5626  if (ea->NextEntryOffset == 0) { // last item
5628  goto end2;
5629  }
5630 
5631  ea = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)ea) + ea->NextEntryOffset);
5632  }
5633  }
5634 
5635  out = NULL;
5636 
5637  do {
5638  uint8_t padding = retlen % 4 > 0 ? (4 - (retlen % 4)) : 0;
5639 
5640  if (offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + ea->EaNameLength + 1 + ea->EaValueLength > IrpSp->Parameters.QueryEa.Length - retlen - padding) {
5642  goto end2;
5643  }
5644 
5645  retlen += padding;
5646 
5647  if (out) {
5648  out->NextEntryOffset = (ULONG)offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + out->EaNameLength + 1 + out->EaValueLength + padding;
5649  out = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)out) + out->NextEntryOffset);
5650  } else
5651  out = ffei;
5652 
5653  out->NextEntryOffset = 0;
5654  out->Flags = ea->Flags;
5655  out->EaNameLength = ea->EaNameLength;
5656  out->EaValueLength = ea->EaValueLength;
5657  RtlCopyMemory(out->EaName, ea->EaName, ea->EaNameLength + ea->EaValueLength + 1);
5658 
5659  retlen += (ULONG)offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + ea->EaNameLength + 1 + ea->EaValueLength;
5660 
5661  if (!(IrpSp->Flags & SL_INDEX_SPECIFIED))
5662  ccb->ea_index++;
5663 
5665  break;
5666 
5667  ea = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)ea) + ea->NextEntryOffset);
5668  } while (true);
5669  }
5670 
5671 end2:
5672  ExReleaseResourceLite(fcb->Header.Resource);
5673 
5674 end:
5675  TRACE("returning %08lx\n", Status);
5676 
5677  Irp->IoStatus.Status = Status;
5678  Irp->IoStatus.Information = NT_SUCCESS(Status) || Status == STATUS_BUFFER_OVERFLOW ? retlen : 0;
5679 
5681 
5682  if (top_level)
5684 
5686 
5687  return Status;
5688 }
struct _file_ref * parent
Definition: btrfs_drv.h:352
NTSYSAPI VOID NTAPI RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
#define FILE_WRITE_EA
Definition: nt_native.h:640
#define FsRtlEnterFileSystem
#define SL_INDEX_SPECIFIED
Definition: iotypes.h:1837
#define FsRtlExitFileSystem
#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:302
#define STATUS_NO_EAS_ON_FILE
Definition: ntstatus.h:318
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define VCB_TYPE_FS
Definition: btrfs_drv.h:679
ACCESS_MASK access
Definition: btrfs_drv.h:382
if(dx==0 &&dy==0)
Definition: linetemp.h:174
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:277
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define offsetof(TYPE, MEMBER)
#define IoCompleteRequest
Definition: irp.c:1240
GLuint index
Definition: glext.h:6031
ULONG ea_index
Definition: btrfs_drv.h:385
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
#define STATUS_NO_MORE_EAS
Definition: ntstatus.h:198
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int padding
Definition: isohybrid.c:50
struct _fcb fcb
Definition: btrfs_drv.h:1355
#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:681
#define Vcb
Definition: cdprocs.h:1415
static __inline void * map_user_buffer(PIRP Irp, ULONG priority)
Definition: btrfs_drv.h:969
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:1998
GLuint GLuint end
Definition: gl.h:1545
std::wstring STRING
Definition: fontsub.cpp:33
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
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
#define SL_RETURN_SINGLE_ENTRY
Definition: iotypes.h:1836
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
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
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 NULL
Definition: types.h:112
#define SL_RESTART_SCAN
Definition: iotypes.h:1835
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
bool ads
Definition: btrfs_drv.h:330
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _ccb ccb
file_ref * fileref
Definition: btrfs_drv.h:383
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465

◆ _Dispatch_type_() [4/4]

_Dispatch_type_ ( IRP_MJ_SET_EA  )

Definition at line 5690 of file fileinfo.c.

5692  {
5693  device_extension* Vcb = DeviceObject->DeviceExtension;
5694  NTSTATUS Status;
5695  bool top_level;
5698  fcb* fcb;
5699  ccb* ccb;
5700  file_ref* fileref;
5702  ULONG offset;
5703  LIST_ENTRY ealist;
5704  ea_item* item;
5706  LIST_ENTRY* le;
5708  BTRFS_TIME now;
5709 
5711 
5712  TRACE("(%p, %p)\n", DeviceObject, Irp);
5713 
5714  top_level = is_top_level(Irp);
5715 
5716  if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
5718  goto end;
5719  } else if (!Vcb || Vcb->type != VCB_TYPE_FS) {
5721  goto end;
5722  }
5723 
5724  if (Vcb->readonly) {
5726  goto end;
5727  }
5728 
5730  if (!ffei) {
5731  ERR("could not get output buffer\n");
5733  goto end;
5734  }
5735 
5736  Status = IoCheckEaBufferValidity(ffei, IrpSp->Parameters.SetEa.Length, &offset);
5737  if (!NT_SUCCESS(Status)) {
5738  ERR("IoCheckEaBufferValidity returned %08lx (error at offset %lu)\n", Status, offset);
5739  goto end;
5740  }
5741 
5742  if (!FileObject) {
5743  ERR("no file object\n");
5745  goto end;
5746  }
5747 
5748  fcb = FileObject->FsContext;
5749 
5750  if (!fcb) {
5751  ERR("no fcb\n");
5753  goto end;
5754  }
5755 
5756  ccb = FileObject->FsContext2;
5757 
5758  if (!ccb) {
5759  ERR("no ccb\n");
5761  goto end;
5762  }
5763 
5764  if (Irp->RequestorMode == UserMode && !(ccb->access & FILE_WRITE_EA)) {
5765  WARN("insufficient privileges\n");
5767  goto end;
5768  }
5769 
5770  if (fcb->ads) {
5771  fileref = ccb->fileref->parent;
5772  fcb = fileref->fcb;
5773  } else
5774  fileref = ccb->fileref;
5775 
5776  InitializeListHead(&ealist);
5777 
5778  ExAcquireResourceExclusiveLite(fcb->Header.Resource, true);
5779 
5780  if (fcb->ea_xattr.Length > 0) {
5782 
5783  do {
5785  if (!item) {
5786  ERR("out of memory\n");
5788  goto end2;
5789  }
5790 
5791  item->name.Length = item->name.MaximumLength = ea->EaNameLength;
5792  item->name.Buffer = ea->EaName;
5793 
5794  item->value.Length = item->value.MaximumLength = ea->EaValueLength;
5795  item->value.Buffer = &ea->EaName[ea->EaNameLength + 1];
5796 
5797  item->flags = ea->Flags;
5798 
5799  InsertTailList(&ealist, &item->list_entry);
5800 
5801  if (ea->NextEntryOffset == 0)
5802  break;
5803 
5804  ea = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)ea) + ea->NextEntryOffset);
5805  } while (true);
5806  }
5807 
5808  ea = ffei;
5809 
5810  do {
5811  STRING s;
5812  bool found = false;
5813 
5814  s.Length = s.MaximumLength = ea->EaNameLength;
5815  s.Buffer = ea->EaName;
5816 
5817  RtlUpperString(&s, &s);
5818 
5819  le = ealist.Flink;
5820  while (le != &ealist) {
5822 
5823  if (item->name.Length == s.Length &&
5824  RtlCompareMemory(item->name.Buffer, s.Buffer, s.Length) == s.Length) {
5825  item->flags = ea->Flags;
5826  item->value.Length = item->value.MaximumLength = ea->EaValueLength;
5827  item->value.Buffer = &ea->EaName[ea->EaNameLength + 1];
5828  found = true;
5829  break;
5830  }
5831 
5832  le = le->Flink;
5833  }
5834 
5835  if (!found) {
5837  if (!item) {
5838  ERR("out of memory\n");
5840  goto end2;
5841  }
5842 
5843  item->name.Length = item->name.MaximumLength = ea->EaNameLength;
5844  item->name.Buffer = ea->EaName;
5845 
5846  item->value.Length = item->value.MaximumLength = ea->EaValueLength;
5847  item->value.Buffer = &ea->EaName[ea->EaNameLength + 1];
5848 
5849  item->flags = ea->Flags;
5850 
5851  InsertTailList(&ealist, &item->list_entry);
5852  }
5853 
5854  if (ea->NextEntryOffset == 0)
5855  break;
5856 
5857  ea = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)ea) + ea->NextEntryOffset);
5858  } while (true);
5859 
5860  // remove entries with zero-length value
5861  le = ealist.Flink;
5862  while (le != &ealist) {
5863  LIST_ENTRY* le2 = le->Flink;
5864 
5866 
5867  if (item->value.Length == 0) {
5868  RemoveEntryList(&item->list_entry);
5869  ExFreePool(item);
5870  }
5871 
5872  le = le2;
5873  }
5874 
5875  // handle LXSS values
5876  le = ealist.Flink;
5877  while (le != &ealist) {
5878  LIST_ENTRY* le2 = le->Flink;
5879 
5881 
5882  if (item->name.Length == sizeof(lxuid) - 1 && RtlCompareMemory(item->name.Buffer, lxuid, item->name.Length) == item->name.Length) {
5883  if (item->value.Length < sizeof(uint32_t)) {
5884  ERR("uid value was shorter than expected\n");
5886  goto end2;
5887  }
5888 
5889  if (Irp->RequestorMode == KernelMode || ccb->access & FILE_WRITE_ATTRIBUTES) {
5890  RtlCopyMemory(&fcb->inode_item.st_uid, item->value.Buffer, sizeof(uint32_t));
5891  fcb->sd_dirty = true;
5892  fcb->sd_deleted = false;
5893  }
5894 
5895  RemoveEntryList(&item->list_entry);
5896  ExFreePool(item);
5897  } else if (item->name.Length == sizeof(lxgid) - 1 && RtlCompareMemory(item->name.Buffer, lxgid, item->name.Length) == item->name.Length) {
5898  if (item->value.Length < sizeof(uint32_t)) {
5899  ERR("gid value was shorter than expected\n");
5901  goto end2;
5902  }
5903 
5904  if (Irp->RequestorMode == KernelMode || ccb->access & FILE_WRITE_ATTRIBUTES)
5905  RtlCopyMemory(&fcb->inode_item.st_gid, item->value.Buffer, sizeof(uint32_t));
5906 
5907  RemoveEntryList(&item->list_entry);
5908  ExFreePool(item);
5909  } else if (item->name.Length == sizeof(lxmod) - 1 && RtlCompareMemory(item->name.Buffer, lxmod, item->name.Length) == item->name.Length) {
5910  if (item->value.Length < sizeof(uint32_t)) {
5911  ERR("mode value was shorter than expected\n");
5913  goto end2;
5914  }
5915 
5916  if (Irp->RequestorMode == KernelMode || ccb->access & FILE_WRITE_ATTRIBUTES) {
5918  uint32_t val;
5919 
5920  RtlCopyMemory(&val, item->value.Buffer, sizeof(uint32_t));
5921 
5922  fcb->inode_item.st_mode &= ~allowed;
5923  fcb->inode_item.st_mode |= val & allowed;
5924  }
5925 
5926  RemoveEntryList(&item->list_entry);
5927  ExFreePool(item);
5928  }
5929 
5930  le = le2;
5931  }
5932 
5933  if (IsListEmpty(&ealist)) {
5934  fcb->ealen = 0;
5935 
5936  if (fcb->ea_xattr.Buffer)
5938 
5940  fcb->ea_xattr.Buffer = NULL;
5941  } else {
5942  uint16_t size = 0;
5943  char *buf, *oldbuf;
5944 
5945  le = ealist.Flink;
5946  while (le != &ealist) {
5948 
5949  if (size % 4 > 0)
5950  size += 4 - (size % 4);
5951 
5952  size += (uint16_t)offsetof(FILE_FULL_EA_INFORMATION, EaName[0]) + item->name.Length + 1 + item->value.Length;
5953 
5954  le = le->Flink;
5955  }
5956 
5958  if (!buf) {
5959  ERR("out of memory\n");
5961  goto end2;
5962  }
5963 
5964  oldbuf = fcb->ea_xattr.Buffer;
5965 
5967  fcb->ea_xattr.Buffer = buf;
5968 
5969  fcb->ealen = 4;
5970  ea = NULL;
5971 
5972  le = ealist.Flink;
5973  while (le != &ealist) {
5975 
5976  if (ea) {
5978 
5979  if (ea->NextEntryOffset % 4 > 0)
5980  ea->NextEntryOffset += 4 - (ea->NextEntryOffset % 4);
5981 
5982  ea = (FILE_FULL_EA_INFORMATION*)(((uint8_t*)ea) + ea->NextEntryOffset);
5983  } else
5985 
5986  ea->NextEntryOffset = 0;
5987  ea->Flags = item->flags;
5988  ea->EaNameLength = (UCHAR)item->name.Length;
5989  ea->EaValueLength = item->value.Length;
5990 
5991  RtlCopyMemory(ea->EaName, item->name.Buffer, item->name.Length);
5992  ea->EaName[item->name.Length] = 0;
5993  RtlCopyMemory(&ea->EaName[item->name.Length + 1], item->value.Buffer, item->value.Length);
5994 
5995  fcb->ealen += 5 + item->name.Length + item->value.Length;
5996 
5997  le = le->Flink;
5998  }
5999 
6000  if (oldbuf)
6001  ExFreePool(oldbuf);
6002  }
6003 
6004  fcb->ea_changed = true;
6005 
6008 
6009  fcb->inode_item.transid = Vcb->superblock.generation;
6010  fcb->inode_item.sequence++;
6011 
6012  if (!ccb->user_set_change_time)
6014 
6015  fcb->inode_item_changed = true;
6017 
6019 
6021 
6022 end2:
6023  ExReleaseResourceLite(fcb->Header.Resource);
6024 
6025  while (!IsListEmpty(&ealist)) {
6026  le = RemoveHeadList(&ealist);
6027 
6029 
6030  ExFreePool(item);
6031  }
6032 
6033 end:
6034  TRACE("returning %08lx\n", Status);
6035 
6036  Irp->IoStatus.Status = Status;
6037  Irp->IoStatus.Information = 0;
6038 
6040 
6041  if (top_level)
6043 
6045 
6046  return Status;
6047 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
struct _file_ref * parent
Definition: btrfs_drv.h:352
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:1278
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define S_ISGID
Definition: propsheet.h:69
#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:321
ANSI_STRING ea_xattr
Definition: btrfs_drv.h:302
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define VCB_TYPE_FS
Definition: btrfs_drv.h:679
__u16 time
Definition: mkdosfs.c:366
ACCESS_MASK access
Definition: btrfs_drv.h:382
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:277
void send_notification_fileref(_In_ file_ref *fileref, _In_ ULONG filter_match, _In_ ULONG action, _In_opt_ PUNICODE_STRING stream)
Definition: btrfs.c:1486
BTRFS_TIME st_ctime
Definition: btrfs.h:302
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define FILE_WRITE_ATTRIBUTES
Definition: nt_native.h:649
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:87
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
bool ea_changed
Definition: btrfs_drv.h:325
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
uint32_t st_gid
Definition: btrfs.h:294
_In_ PIRP Irp
Definition: csq.h:116
#define S_IRGRP
Definition: propsheet.h:41
#define S_IXOTH
Definition: propsheet.h:61
uint64_t sequence
Definition: btrfs.h:299
time_t now
Definition: finger.c:65
#define FILE_ACTION_MODIFIED
#define offsetof(TYPE, MEMBER)
void mark_fcb_dirty(_In_ fcb *fcb)
Definition: btrfs.c:1664
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
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
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
GLuint GLfloat * val
Definition: glext.h:7180
ULONG ealen
Definition: btrfs_drv.h:303
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
Status
Definition: gdiplustypes.h:24
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:1355
bool sd_dirty
Definition: btrfs_drv.h:321
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:681
GLintptr offset
Definition: glext.h:5920
bool user_set_change_time
Definition: btrfs_drv.h:390
#define Vcb
Definition: cdprocs.h:1415
static __inline void * map_user_buffer(PIRP Irp, ULONG priority)
Definition: btrfs_drv.h:969
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1998
GLuint GLuint end
Definition: gl.h:1545
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
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:342
Definition: typedefs.h:119
INODE_ITEM inode_item
Definition: btrfs_drv.h:292
BYTE uint8_t
Definition: msvideo1.c:66
#define S_IWOTH
Definition: propsheet.h:57
#define ERR(fmt,...)
Definition: debug.h:110
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
static ATOM item
Definition: dde.c:856
#define FILE_NOTIFY_CHANGE_EA
static const char lxgid[]
Definition: btrfs_drv.h:1279
#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:288
static const char lxmod[]
Definition: btrfs_drv.h:1280
#define S_IRUSR
Definition: propsheet.h:29
Definition: list.h:27
#define NULL
Definition: types.h:112
UINT32 uint32_t
Definition: types.h:75
bool ads
Definition: btrfs_drv.h:330
static __inline void win_time_to_unix(LARGE_INTEGER t, BTRFS_TIME *out)
Definition: btrfs_drv.h:981
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _ccb ccb
file_ref * fileref
Definition: btrfs_drv.h:383
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
uint32_t st_uid
Definition: btrfs.h:293
bool inode_item_changed
Definition: btrfs_drv.h:306
#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:295

◆ 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
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:1459
file_ref * dummyfileref
Definition: fileinfo.c:696
#define ALLOC_TAG
Definition: btrfs_drv.h:87
struct _move_entry * parent
Definition: fileinfo.c:697
_In_ PIRP Irp
Definition: csq.h:116
fcb * dummyfcb
Definition: fileinfo.c:695
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
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY dir_children_index
Definition: btrfs_drv.h:314
#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
Definition: fileinfo.c:693
fcb * fcb
Definition: btrfs_drv.h:342
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:284
#define NULL
Definition: types.h:112
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
static const WCHAR dc[]
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by move_across_subvols().

◆ add_fcb_to_subvol()

void add_fcb_to_subvol ( _In_ _Requires_exclusive_lock_held_(_Curr_->Vcb->fcb_lock) fcb fcb)

Definition at line 888 of file fileinfo.c.

888  {
889  LIST_ENTRY* lastle = NULL;
890  uint32_t hash = fcb->hash;
891 
892  if (fcb->subvol->fcbs_ptrs[hash >> 24]) {
893  LIST_ENTRY* le = fcb->subvol->fcbs_ptrs[hash >> 24];
894 
895  while (le != &fcb->subvol->fcbs) {
896  struct _fcb* fcb2 = CONTAINING_RECORD(le, struct _fcb, list_entry);
897 
898  if (fcb2->hash > hash) {
899  lastle = le->Blink;
900  break;
901  }
902 
903  le = le->Flink;
904  }
905  }
906 
907  if (!lastle) {
908  uint8_t c = hash >> 24;
909 
910  if (c != 0xff) {
911  uint8_t d = c + 1;
912 
913  do {
914  if (fcb->subvol->fcbs_ptrs[d]) {
915  lastle = fcb->subvol->fcbs_ptrs[d]->Blink;
916  break;
917  }
918 
919  d++;
920  } while (d != 0);
921  }
922  }
923 
924  if (lastle) {
925  InsertHeadList(lastle, &fcb->list_entry);
926 
927  if (lastle == &fcb->subvol->fcbs || (CONTAINING_RECORD(lastle, struct _fcb, list_entry)->hash >> 24) != (hash >> 24))
928  fcb->subvol->fcbs_ptrs[hash >> 24] = &fcb->list_entry;
929  } else {
930  InsertTailList(&fcb->subvol->fcbs, &fcb->list_entry);
931 
932  if (fcb->list_entry.Blink == &fcb->subvol->fcbs || (CONTAINING_RECORD(fcb->list_entry.Blink, struct _fcb, list_entry)->hash >> 24) != (hash >> 24))
933  fcb->subvol->fcbs_ptrs[hash >> 24] = &fcb->list_entry;
934  }
935 }
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
#define InsertTailList(ListHead, Entry)
LIST_ENTRY list_entry
Definition: btrfs_drv.h:336
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
const GLubyte * c
Definition: glext.h:8905
uint32_t hash
Definition: btrfs_drv.h:290
Definition: typedefs.h:119
BYTE uint8_t
Definition: msvideo1.c:66
struct _root * subvol
Definition: btrfs_drv.h:288
Definition: list.h:27
#define NULL
Definition: types.h:112
UINT32 uint32_t
Definition: types.h:75
Definition: _hash_fun.h:40
#define d
Definition: ke_i.h:81

Referenced by allocate_cache_chunk(), create_directory_fcb(), create_subvol(), mknod(), move_across_subvols(), rename_stream(), and rename_stream_to_file().

◆ 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);
804  fcb->hash = calc_crc32c(0xffffffff, (uint8_t*)&fcb->inode, sizeof(uint64_t));
806 
807  fcb->inode_item.generation = Vcb->superblock.generation;
808  fcb->inode_item.transid = Vcb->superblock.generation;
809  fcb->inode_item.st_nlink = 1;
810  fcb->inode_item.st_mode = __S_IFDIR | inherit_mode(parfcb, true);
813 
814  fcb->atts = get_file_attributes(Vcb, fcb->subvol, fcb->inode, fcb->type, false, true, NULL);
815 
816  SeCaptureSubjectContext(&subjcont);
817 
818  Status = SeAssignSecurity(parfcb->sd, NULL, (void**)&fcb->sd, true, &subjcont, IoGetFileObjectGenericMapping(), PagedPool);
819 
820  if (!NT_SUCCESS(Status)) {
821  reap_fcb(fcb);
822  ERR("SeAssignSecurity returned %08lx\n", Status);
823  return Status;
824  }
825 
826  if (!fcb->sd) {
827  reap_fcb(fcb);
828  ERR("SeAssignSecurity returned NULL security descriptor\n");
829  return STATUS_INTERNAL_ERROR;
830  }
831 
832  Status = RtlGetOwnerSecurityDescriptor(fcb->sd, &owner, &defaulted);
833  if (!NT_SUCCESS(Status)) {
834  ERR("RtlGetOwnerSecurityDescriptor returned %08lx\n", Status);
836  fcb->sd_dirty = true;
837  } else {
838  fcb->inode_item.st_uid = sid_to_uid(owner);
840  }
841 
842  find_gid(fcb, parfcb, &subjcont);
843 
844  fcb->inode_item_changed = true;
845 
846  fcb->Header.IsFastIoPossible = fast_io_possible(fcb);
847  fcb->Header.AllocationSize.QuadPart = 0;
848  fcb->Header.FileSize.QuadPart = 0;
849  fcb->Header.ValidDataLength.QuadPart = 0;
850 
851  fcb->created = true;
852 
853  if (parfcb->inode_item.flags & BTRFS_INODE_COMPRESS)
855 
858 
860  if (!fcb->hash_ptrs) {
861  ERR("out of memory\n");
863  }
864 
865  RtlZeroMemory(fcb->hash_ptrs, sizeof(LIST_ENTRY*) * 256);
866 
868  if (!fcb->hash_ptrs_uc) {
869  ERR("out of memory\n");
871  }
872 
873  RtlZeroMemory(fcb->hash_ptrs_uc, sizeof(LIST_ENTRY*) * 256);
874 
875  acquire_fcb_lock_exclusive(Vcb);
877  InsertTailList(&Vcb->all_fcbs, &fcb->list_entry_all);
878  r->fcbs_version++;
879  release_fcb_lock(Vcb);
880 
882 
883  *pfcb = fcb;
884 
885  return STATUS_SUCCESS;
886 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
PGENERIC_MAPPING NTAPI IoGetFileObjectGenericMapping(VOID)
Definition: file.c:3266
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
BTRFS_TIME otime
Definition: btrfs.h:304
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
fcb * create_fcb(device_extension *Vcb, POOL_TYPE pool_type)
Definition: create.c:91
LONG NTSTATUS
Definition: precomp.h:26
enum prop_compression_type prop_compression
Definition: btrfs_drv.h:307
__u16 time
Definition: mkdosfs.c:366
#define InsertTailList(ListHead, Entry)
uint32_t flags
Definition: btrfs.h:297
BTRFS_TIME st_ctime
Definition: btrfs.h:302
LIST_ENTRY list_entry_all
Definition: btrfs_drv.h:337
#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:87
uint32_t st_gid
Definition: btrfs.h:294
SECURITY_DESCRIPTOR * sd
Definition: btrfs_drv.h:293
#define BTRFS_INODE_COMPRESS
Definition: propsheet.h:87
uint32_t st_nlink
Definition: btrfs.h:292
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:1712
LIST_ENTRY ** hash_ptrs_uc
Definition: btrfs_drv.h:318
void mark_fcb_dirty(_In_ fcb *fcb)
Definition: btrfs.c:1664
uint8_t type
Definition: btrfs_drv.h:291
BTRFS_TIME st_mtime
Definition: btrfs.h:303
bool prop_compression_changed
Definition: btrfs_drv.h:326
void find_gid(struct _fcb *fcb, struct _fcb *parfcb, PSECURITY_SUBJECT_CONTEXT subjcont)
Definition: security.c:924
void add_fcb_to_subvol(_In_ _Requires_exclusive_lock_held_(_Curr_->Vcb->fcb_lock) fcb *fcb)
Definition: fileinfo.c:888
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
Status
Definition: gdiplustypes.h:24
struct _fcb fcb
Definition: btrfs_drv.h:1355
bool sd_dirty
Definition: btrfs_drv.h:321
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:2633
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t inode
Definition: btrfs_drv.h:289
#define Vcb
Definition: cdprocs.h:1415
#define InterlockedIncrement64(a)
Definition: btrfs_drv.h:143
uint32_t hash
Definition: btrfs_drv.h:290
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
BTRFS_TIME st_atime
Definition: btrfs.h:301
crc_func calc_crc32c
Definition: crc32c.c:23
bool created
Definition: btrfs_drv.h:328
Definition: typedefs.h:119
static __inline FAST_IO_POSSIBLE fast_io_possible(fcb *fcb)
Definition: btrfs_drv.h:1677
INODE_ITEM inode_item
Definition: btrfs_drv.h:292
uint64_t generation
Definition: btrfs.h:287
BYTE uint8_t
Definition: msvideo1.c:66
#define ERR(fmt,...)
Definition: debug.h:110
VOID NTAPI SeCaptureSubjectContext(_Out_ PSECURITY_SUBJECT_CONTEXT SubjectContext)
Captures the security subject context of the calling thread and calling process.
Definition: subject.c:85
UINT64 uint64_t
Definition: types.h:77
ULONG atts
Definition: btrfs_drv.h:297
uint32_t inherit_mode(fcb *parfcb, bool is_dir)
Definition: create.c:1948
uint64_t transid
Definition: btrfs.h:288
struct _root * subvol
Definition: btrfs_drv.h:288
#define NULL
Definition: types.h:112
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:1744
static __inline void win_time_to_unix(LARGE_INTEGER t, BTRFS_TIME *out)
Definition: btrfs_drv.h:981
LIST_ENTRY ** hash_ptrs
Definition: btrfs_drv.h:317
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t st_uid
Definition: btrfs.h:293
bool inode_item_changed
Definition: btrfs_drv.h:306
#define GID_NOBODY
Definition: btrfs_drv.h:91
struct _device_extension * Vcb
Definition: btrfs_drv.h:287
#define UID_NOBODY
Definition: btrfs_drv.h:90
uint32_t st_mode
Definition: btrfs.h:295

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->sector_shift;
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 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
uint32_t adshash
Definition: btrfs_drv.h:331
void free_fcb(_Inout_ fcb *fcb)
Definition: btrfs.c:1703
#define BTRFS_COMPRESSION_NONE
Definition: btrfs.h:65
fcb * create_fcb(device_extension *Vcb, POOL_TYPE pool_type)
Definition: create.c:91
enum prop_compression_type prop_compression
Definition: btrfs_drv.h:307
ANSI_STRING ea_xattr
Definition: btrfs_drv.h:302
ANSI_STRING reparse_xattr
Definition: btrfs_drv.h:301
#define InsertTailList(ListHead, Entry)
if(dx==0 &&dy==0)
Definition: linetemp.h:174
NTSYSAPI ULONG WINAPI RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR)
#define ALLOC_TAG
Definition: btrfs_drv.h:87
SECURITY_DESCRIPTOR * sd
Definition: btrfs_drv.h:293
#define offsetof(TYPE, MEMBER)
char ext[3]
Definition: mkdosfs.c:358
uint64_t size
Definition: btrfs.h:369
uint8_t type
Definition: btrfs_drv.h:291
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:283
USHORT MaximumLength
Definition: env_spec_w32.h:377
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
struct _fcb fcb
Definition: btrfs_drv.h:1355
LIST_ENTRY xattrs
Definition: btrfs_drv.h:308
#define Vcb
Definition: cdprocs.h:1415
LIST_ENTRY hardlinks
Definition: btrfs_drv.h:304
LIST_ENTRY extents
Definition: btrfs_drv.h:300
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint GLuint end
Definition: gl.h:1545
#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:1677
INODE_ITEM inode_item
Definition: btrfs_drv.h:292
USHORT valuelen
Definition: btrfs_drv.h:277
uint64_t num_bytes
Definition: btrfs.h:371
#define ERR(fmt,...)
Definition: debug.h:110
ULONG atts
Definition: btrfs_drv.h:297
bool dirty
Definition: btrfs_drv.h:278
Definition: list.h:27
ULONG adsmaxlen
Definition: btrfs_drv.h:332
#define NULL
Definition: types.h:112
ANSI_STRING adsdata
Definition: btrfs_drv.h:334
LIST_ENTRY list_entry
Definition: btrfs_drv.h:275
bool ads
Definition: btrfs_drv.h:330
USHORT namelen
Definition: btrfs_drv.h:276
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
#define uint32_t
Definition: nsiface.idl:61
char data[1]
Definition: btrfs_drv.h:279
bool inode_item_changed
Definition: btrfs_drv.h:306
struct _device_extension * Vcb
Definition: btrfs_drv.h:287
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
ANSI_STRING adsxattr
Definition: btrfs_drv.h:333

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 4236 of file fileinfo.c.

4236  {
4237  file_ref* fr;
4238  NTSTATUS Status;
4239  ULONG reqlen = 0;
4240  USHORT offset;
4241  bool overflow = false;
4242 
4243  // FIXME - we need a lock on filerefs' filepart
4244 
4245  if (fileref == fileref->fcb->Vcb->root_fileref) {
4246  if (fn->MaximumLength >= sizeof(WCHAR)) {
4247  fn->Buffer[0] = '\\';
4248  fn->Length = sizeof(WCHAR);
4249 
4250  if (name_offset)
4251  *name_offset = 0;
4252 
4253  return STATUS_SUCCESS;
4254  } else {
4255  if (preqlen)
4256  *preqlen = sizeof(WCHAR);
4257  fn->Length = 0;
4258 
4259  return STATUS_BUFFER_OVERFLOW;
4260  }
4261  }
4262 
4263  fr = fileref;
4264  offset = 0;
4265 
4266  while (fr->parent) {
4267  USHORT movelen;
4268 
4269  if (!fr->dc)
4270  return STATUS_INTERNAL_ERROR;
4271 
4272  if (!overflow) {
4273  if (fr->dc->name.Length + sizeof(WCHAR) + fn->Length > fn->MaximumLength)
4274  overflow = true;
4275  }
4276 
4277  if (overflow)
4278  movelen = fn->MaximumLength - fr->dc->name.Length - sizeof(WCHAR);
4279  else
4280  movelen = fn->Length;
4281 
4282  if ((!overflow || fn->MaximumLength > fr->dc->name.Length + sizeof(WCHAR)) && movelen > 0) {
4283  RtlMoveMemory(&fn->Buffer[(fr->dc->name.Length / sizeof(WCHAR)) + 1], fn->Buffer, movelen);
4284  offset += fr->dc->name.Length + sizeof(WCHAR);
4285  }
4286 
4287  if (fn->MaximumLength >= sizeof(WCHAR)) {
4288  fn->Buffer[0] = fr->fcb->ads ? ':' : '\\';
4289  fn->Length += sizeof(WCHAR);
4290 
4291  if (fn->MaximumLength > sizeof(WCHAR)) {
4292  RtlCopyMemory(&fn->Buffer[1], fr->dc->name.Buffer, min(fr->dc->name.Length, fn->MaximumLength - sizeof(WCHAR)));
4293  fn->Length += fr->dc->name.Length;
4294  }
4295 
4296  if (fn->Length > fn->MaximumLength) {
4297  fn->Length = fn->MaximumLength;
4298  overflow = true;
4299  }
4300  }
4301 
4302  reqlen += sizeof(WCHAR) + fr->dc->name.Length;
4303 
4304  fr = fr->parent;
4305  }
4306 
4307  offset += sizeof(WCHAR);
4308 
4309  if (overflow) {
4310  if (preqlen)
4311  *preqlen = reqlen;
4313  } else {
4314  if (name_offset)
4315  *name_offset = offset;
4316 
4318  }
4319 
4320  return Status;
4321 }
struct _file_ref * parent
Definition: btrfs_drv.h:352
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
LONG NTSTATUS
Definition: precomp.h:26
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLintptr offset
Definition: glext.h:5920
struct _file_ref * fileref
Definition: btrfs_drv.h:305
dir_child * dc
Definition: btrfs_drv.h:353
fcb * fcb
Definition: btrfs_drv.h:342
#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:330
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
UNICODE_STRING name
Definition: btrfs_drv.h:256

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 4380 of file fileinfo.c.

4380  {
4382 
4383  if (fcb->ads) {
4384  if (!ccb->fileref || !ccb->fileref->parent) {
4385  ERR("no fileref for stream\n");
4386  return STATUS_INTERNAL_ERROR;
4387  }
4388 
4389  ati->FileAttributes = ccb->fileref->parent->fcb->atts;
4390  } else
4391  ati->FileAttributes = fcb->atts;
4392 
4394  ati->ReparseTag = 0;
4395  else
4397 
4398  return STATUS_SUCCESS;
4399 }
struct _file_ref * parent
Definition: btrfs_drv.h:352
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define FILE_ATTRIBUTE_REPARSE_POINT
Definition: ntifs_ex.h:381
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:297
bool ads
Definition: btrfs_drv.h:330
#define STATUS_SUCCESS
Definition: shellext.h:65
file_ref * fileref
Definition: btrfs_drv.h:383

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 4102 of file fileinfo.c.

4102  {
4103  RtlZeroMemory(fbi, sizeof(FILE_BASIC_INFORMATION));
4104 
4105  *length -= sizeof(FILE_BASIC_INFORMATION);
4106 
4107  if (fcb == fcb->Vcb->dummy_fcb) {
4109 
4111  fbi->CreationTime = fbi->LastAccessTime = fbi->LastWriteTime = fbi->ChangeTime = time;
4112  } else {
4117  }
4118 
4119  if (fcb->ads) {
4120  if (!fileref || !fileref->parent) {
4121  ERR("no fileref for stream\n");
4122  return STATUS_INTERNAL_ERROR;
4123  } else
4124  fbi->FileAttributes = fileref->parent->fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : fileref->parent->fcb->atts;
4125  } else
4127 
4128  return STATUS_SUCCESS;
4129 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
BTRFS_TIME otime
Definition: btrfs.h:304
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
__u16 time
Definition: mkdosfs.c:366
BTRFS_TIME st_ctime
Definition: btrfs.h:302
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
BTRFS_TIME st_mtime
Definition: btrfs.h:303
static __inline uint64_t unix_time_to_win(BTRFS_TIME *t)
Definition: recv.cpp:1067
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
struct _file_ref * fileref
Definition: btrfs_drv.h:305
BTRFS_TIME st_atime
Definition: btrfs.h:301
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:297
bool ads
Definition: btrfs_drv.h:330
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _device_extension * Vcb
Definition: btrfs_drv.h:287
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 5010 of file fileinfo.c.

5010  {
5012 
5014 
5015  return STATUS_SUCCESS;
5016 }
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:165
bool case_sensitive
Definition: btrfs_drv.h:310
#define STATUS_SUCCESS
Definition: shellext.h:65

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 5020 of file fileinfo.c.

5020  {
5022 
5023  memset(fci, 0, sizeof(FILE_COMPRESSION_INFORMATION));
5024 
5025  if (fcb->ads)
5027  else if (!S_ISDIR(fcb->inode_item.st_mode))
5029 
5030  return STATUS_SUCCESS;
5031 }
struct _FILE_COMPRESSION_INFORMATION FILE_COMPRESSION_INFORMATION
LARGE_INTEGER CompressedFileSize
Definition: iotypes.h:5849
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
uint64_t st_size
Definition: btrfs.h:289
#define S_ISDIR(mode)
Definition: various.h:18
INODE_ITEM inode_item
Definition: btrfs_drv.h:292
ANSI_STRING adsdata
Definition: btrfs_drv.h:334
bool ads
Definition: btrfs_drv.h:330
#define STATUS_SUCCESS
Definition: shellext.h:65
#define memset(x, y, z)
Definition: compat.h:39
LONGLONG QuadPart
Definition: typedefs.h:114
uint32_t st_mode
Definition: btrfs.h:295

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 4213 of file fileinfo.c.

4213  {
4214  *length -= sizeof(FILE_EA_INFORMATION);
4215 
4216  /* This value appears to be the size of the structure NTFS stores on disk, and not,
4217  * as might be expected, the size of FILE_FULL_EA_INFORMATION (which is what we store).
4218  * The formula is 4 bytes as a header, followed by 5 + NameLength + ValueLength for each
4219  * item. */
4220 
4221  eai->EaSize = fcb->ealen;
4222 
4223  return STATUS_SUCCESS;
4224 }
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
ULONG ealen
Definition: btrfs_drv.h:303
struct _FILE_EA_INFORMATION FILE_EA_INFORMATION
#define STATUS_SUCCESS
Definition: shellext.h:65

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 4866 of file fileinfo.c.

4866  {
4867  RtlCopyMemory(&fii->VolumeSerialNumber, &fcb->Vcb->superblock.uuid.uuid[8], sizeof(uint64_t));
4868  RtlCopyMemory(&fii->FileId.Identifier[0], &fcb->inode, sizeof(uint64_t));
4869  RtlCopyMemory(&fii->FileId.Identifier[sizeof(uint64_t)], &fcb->subvol->id, sizeof(uint64_t));
4870 
4871  *length -= sizeof(FILE_ID_INFORMATION);
4872 
4873  return STATUS_SUCCESS;
4874 }
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
uint64_t inode
Definition: btrfs_drv.h:289
ULONGLONG VolumeSerialNumber
Definition: fileinfo.c:35
struct _FILE_ID_INFORMATION FILE_ID_INFORMATION
UCHAR Identifier[16]
Definition: btrfs_drv.h:162
UINT64 uint64_t
Definition: types.h:77
struct _root * subvol
Definition: btrfs_drv.h:288
FILE_ID_128 FileId
Definition: fileinfo.c:36
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _device_extension * Vcb
Definition: btrfs_drv.h:287

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 4205 of file fileinfo.c.

4205  {
4206  *length -= sizeof(FILE_INTERNAL_INFORMATION);
4207 
4209 
4210  return STATUS_SUCCESS;
4211 }
struct _FILE_INTERNAL_INFORMATION FILE_INTERNAL_INFORMATION
static __inline uint64_t make_file_id(root *r, uint64_t inode)
Definition: btrfs_drv.h:1004
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
uint64_t inode
Definition: btrfs_drv.h:289
struct _root * subvol
Definition: btrfs_drv.h:288
#define STATUS_SUCCESS
Definition: shellext.h:65
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 4323 of file fileinfo.c.

4323  {
4324  ULONG reqlen;
4326  NTSTATUS Status;
4327  static const WCHAR datasuf[] = {':','$','D','A','T','A',0};
4328  uint16_t datasuflen = sizeof(datasuf) - sizeof(WCHAR);
4329 
4330  if (!fileref) {
4331  ERR("called without fileref\n");
4332  return STATUS_INVALID_PARAMETER;
4333  }
4334 
4336 
4337  TRACE("maximum length is %li\n", *length);
4338  fni->FileNameLength = 0;
4339 
4340  fni->FileName[0] = 0;
4341 
4342  fn.Buffer = fni->FileName;
4343  fn.Length = 0;
4344  fn.MaximumLength = (uint16_t)*length;
4345 
4346  Status = fileref_get_filename(fileref, &fn, NULL, &reqlen);
4348  ERR("fileref_get_filename returned %08lx\n", Status);
4349  return Status;
4350  }
4351 
4352  if (fcb->ads) {
4354  reqlen += datasuflen;
4355  else {
4356  if (fn.Length + datasuflen > fn.MaximumLength) {
4357  RtlCopyMemory(&fn.Buffer[fn.Length / sizeof(WCHAR)], datasuf, fn.MaximumLength - fn.Length);
4358  reqlen += datasuflen;
4360  } else {
4361  RtlCopyMemory(&fn.Buffer[fn.Length / sizeof(WCHAR)], datasuf, datasuflen);
4362  fn.Length += datasuflen;
4363  }
4364  }
4365  }
4366 
4367  if (Status == STATUS_BUFFER_OVERFLOW) {
4368  *length = -1;
4369  fni->FileNameLength = reqlen;
4370  TRACE("%.*S (truncated)\n", (int)(fn.Length / sizeof(WCHAR)), fn.Buffer);
4371  } else {
4372  *length -= fn.Length;
4373  fni->FileNameLength = fn.Length;
4374  TRACE("%.*S\n", (int)(fn.Length / sizeof(WCHAR)), fn.Buffer);
4375  }
4376 
4377  return Status;
4378 }
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
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define offsetof(TYPE, MEMBER)
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _file_ref * fileref
Definition: btrfs_drv.h:305
NTSTATUS fileref_get_filename(file_ref *fileref, PUNICODE_STRING fn, USHORT *name_offset, ULONG *preqlen)
Definition: fileinfo.c:4236
#define ERR(fmt,...)
Definition: debug.h:110
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define NULL
Definition: types.h:112
bool ads
Definition: btrfs_drv.h:330
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

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 4131 of file fileinfo.c.

4131  {
4132  INODE_ITEM* ii;
4133 
4134  if (*length < (LONG)sizeof(FILE_NETWORK_OPEN_INFORMATION)) {
4135  WARN("overflow\n");
4136  return STATUS_BUFFER_OVERFLOW;
4137  }
4138 
4140 
4142 
4143  if (fcb->ads) {
4144  if (!fileref || !fileref->parent) {
4145  ERR("no fileref for stream\n");
4146  return STATUS_INTERNAL_ERROR;
4147  }
4148 
4149  ii = &fileref->parent->fcb->inode_item;
4150  } else
4151  ii = &fcb->inode_item;
4152 
4153  if (fcb == fcb->Vcb->dummy_fcb) {
4155 
4157  fnoi->CreationTime = fnoi->LastAccessTime = fnoi->LastWriteTime = fnoi->ChangeTime = time;
4158  } else {
4163  }
4164 
4165  if (fcb->ads) {
4167  fnoi->FileAttributes = fileref->parent->fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : fileref->parent->fcb->atts;
4168  } else {
4171  fnoi->FileAttributes = fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : fcb->atts;
4172  }
4173 
4174  return STATUS_SUCCESS;
4175 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
BTRFS_TIME otime
Definition: btrfs.h:304
#define WARN(fmt,...)
Definition: debug.h:112
__u16 time
Definition: mkdosfs.c:366
BTRFS_TIME st_ctime
Definition: btrfs.h:302
struct _FILE_NETWORK_OPEN_INFORMATION FILE_NETWORK_OPEN_INFORMATION
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
long LONG
Definition: pedump.c:60
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
BTRFS_TIME st_mtime
Definition: btrfs.h:303
static __inline uint64_t unix_time_to_win(BTRFS_TIME *t)
Definition: recv.cpp:1067
uint64_t st_size
Definition: btrfs.h:289
#define S_ISDIR(mode)
Definition: various.h:18
struct _file_ref * fileref
Definition: btrfs_drv.h:305
BTRFS_TIME st_atime
Definition: btrfs.h:301
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
INODE_ITEM inode_item
Definition: btrfs_drv.h:292
#define ERR(fmt,...)
Definition: debug.h:110
ULONG atts
Definition: btrfs_drv.h:297
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
static __inline uint64_t fcb_alloc_size(fcb *fcb)
Definition: btrfs_drv.h:1814
ANSI_STRING adsdata
Definition: btrfs_drv.h:334
bool ads
Definition: btrfs_drv.h:330
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _device_extension * Vcb
Definition: btrfs_drv.h:287
LONGLONG QuadPart
Definition: typedefs.h:114
uint32_t st_mode
Definition: btrfs.h:295

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 4226 of file fileinfo.c.

4226  {
4228 
4229  *length -= sizeof(FILE_POSITION_INFORMATION);
4230 
4231  fpi->CurrentByteOffset = FileObject->CurrentByteOffset;
4232 
4233  return STATUS_SUCCESS;
4234 }
struct _FILE_POSITION_INFORMATION FILE_POSITION_INFORMATION
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
LARGE_INTEGER CurrentByteOffset
Definition: nt_native.h:955
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65

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 4177 of file fileinfo.c.

4177  {
4179 
4180  *length -= sizeof(FILE_STANDARD_INFORMATION);
4181 
4182  if (fcb->ads) {
4183  if (!fileref || !fileref->parent) {
4184  ERR("no fileref for stream\n");
4185  return STATUS_INTERNAL_ERROR;
4186  }
4187 
4189  fsi->NumberOfLinks = fileref->parent->fcb->inode_item.st_nlink;
4190  fsi->Directory = false;
4191  } else {
4196  }
4197 
4198  TRACE("length = %I64u\n", fsi->EndOfFile.QuadPart);
4199 
4200  fsi->DeletePending = fileref ? fileref->delete_on_close : false;
4201 
4202  return STATUS_SUCCESS;
4203 }
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
uint32_t st_nlink
Definition: btrfs.h:292
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
uint64_t st_size
Definition: btrfs.h:289
#define TRACE(s)
Definition: solgame.cpp:4
#define S_ISDIR(mode)
Definition: various.h:18
struct _file_ref * fileref
Definition: btrfs_drv.h:305
LARGE_INTEGER AllocationSize
Definition: propsheet.cpp:54
#define FILE_STANDARD_INFORMATION
Definition: disk.h:54
INODE_ITEM inode_item
Definition: btrfs_drv.h:292
#define ERR(fmt,...)
Definition: debug.h:110
static __inline uint64_t fcb_alloc_size(fcb *fcb)
Definition: btrfs_drv.h:1814
ANSI_STRING adsdata
Definition: btrfs_drv.h:334
bool ads
Definition: btrfs_drv.h:330
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
LONGLONG QuadPart
Definition: typedefs.h:114
uint32_t st_mode
Definition: btrfs.h:295

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 4511 of file fileinfo.c.

4511  {
4512  TRACE("FileStandardLinkInformation\n");
4513 
4514  // FIXME - NumberOfAccessibleLinks should subtract open links which have been marked as delete_on_close
4515 
4518  fsli->DeletePending = fileref ? fileref->delete_on_close : false;
4519  fsli->Directory = (!fcb->ads && fcb->type == BTRFS_TYPE_DIRECTORY) ? true : false;
4520 
4522 
4523  return STATUS_SUCCESS;
4524 }
uint32_t st_nlink
Definition: btrfs.h:292
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define BTRFS_TYPE_DIRECTORY
Definition: shellext.h:86
uint8_t type
Definition: btrfs_drv.h:291
#define TRACE(s)
Definition: solgame.cpp:4
struct _file_ref * fileref
Definition: btrfs_drv.h:305
INODE_ITEM inode_item
Definition: btrfs_drv.h:292
bool ads
Definition: btrfs_drv.h:330
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _FILE_STANDARD_LINK_INFORMATION FILE_STANDARD_LINK_INFORMATION

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 4876 of file fileinfo.c.

4876  {
4877  INODE_ITEM* ii;
4878 
4880 
4881  if (fcb->ads)
4882  ii = &ccb->fileref->parent->fcb->inode_item;
4883  else
4884  ii = &fcb->inode_item;
4885 
4886  if (fcb == fcb->Vcb->dummy_fcb) {
4888 
4890  fsi->CreationTime = fsi->LastAccessTime = fsi->LastWriteTime = fsi->ChangeTime = time;
4891  } else {
4896  }
4897 
4898  if (fcb->ads) {
4900  fsi->FileAttributes = ccb->fileref->parent->fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : ccb->fileref->parent->fcb->atts;
4901  } else {
4905  }
4906 
4907  if (fcb->type == BTRFS_TYPE_SOCKET)
4909  else if (fcb->type == BTRFS_TYPE_FIFO)
4911  else if (fcb->type == BTRFS_TYPE_CHARDEV)
4913  else if (fcb->type == BTRFS_TYPE_BLOCKDEV)
4915  else if (!(fsi->FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
4916  fsi->ReparseTag = 0;
4917  else
4919 
4922 
4923  if (fcb->ads)
4924  fsi->NumberOfLinks = ccb->fileref->parent->fcb->inode_item.st_nlink;
4925  else
4927 
4928  fsi->EffectiveAccess = ccb->access;
4929 
4930  *length -= sizeof(FILE_STAT_INFORMATION);
4931 
4932  return STATUS_SUCCESS;
4933 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
LARGE_INTEGER EndOfFile
Definition: fileinfo.c:46
struct _file_ref * parent
Definition: btrfs_drv.h:352
#define BTRFS_TYPE_SOCKET
Definition: shellext.h:90
BTRFS_TIME otime
Definition: btrfs.h:304
#define IO_REPARSE_TAG_LX_FIFO
Definition: btrfs_drv.h:121
#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:382
#define BTRFS_TYPE_CHARDEV
Definition: shellext.h:87
LARGE_INTEGER LastAccessTime
Definition: fileinfo.c:42
BTRFS_TIME st_ctime
Definition: btrfs.h:302
static __inline uint64_t make_file_id(root *r, uint64_t inode)
Definition: btrfs_drv.h:1004
struct _FILE_STAT_INFORMATION FILE_STAT_INFORMATION
uint32_t st_nlink
Definition: btrfs.h:292
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
LARGE_INTEGER FileId
Definition: fileinfo.c:40
uint8_t type
Definition: btrfs_drv.h:291
LARGE_INTEGER CreationTime
Definition: fileinfo.c:41
#define FILE_ATTRIBUTE_REPARSE_POINT
Definition: ntifs_ex.h:381
BTRFS_TIME st_mtime
Definition: btrfs.h:303
static __inline uint64_t unix_time_to_win(BTRFS_TIME *t)
Definition: recv.cpp:1067
uint64_t st_size
Definition: btrfs.h:289
uint64_t inode
Definition: btrfs_drv.h:289
#define S_ISDIR(mode)
Definition: various.h:18
#define IO_REPARSE_TAG_LX_BLK
Definition: btrfs_drv.h:123
BTRFS_TIME st_atime
Definition: btrfs.h:301
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
LARGE_INTEGER AllocationSize
Definition: fileinfo.c:45
INODE_ITEM inode_item
Definition: btrfs_drv.h:292
ULONG get_reparse_tag_fcb(fcb *fcb)
Definition: dirctrl.c:83
ULONG atts
Definition: btrfs_drv.h:297
#define IO_REPARSE_TAG_AF_UNIX
Definition: btrfs_drv.h:120
static __inline uint64_t fcb_alloc_size(fcb *fcb)
Definition: btrfs_drv.h:1814
struct _root * subvol
Definition: btrfs_drv.h:288
ANSI_STRING adsdata
Definition: btrfs_drv.h:334
#define IO_REPARSE_TAG_LX_CHR
Definition: btrfs_drv.h:122
bool ads
Definition: btrfs_drv.h:330
LARGE_INTEGER LastWriteTime
Definition: fileinfo.c:43
#define STATUS_SUCCESS
Definition: shellext.h:65
file_ref * fileref
Definition: btrfs_drv.h:383
ACCESS_MASK EffectiveAccess
Definition: fileinfo.c:50
struct _device_extension * Vcb
Definition: btrfs_drv.h:287
LONGLONG QuadPart
Definition: typedefs.h:114
uint32_t st_mode
Definition: btrfs.h:295

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 4935 of file fileinfo.c.

4935  {
4936  INODE_ITEM* ii;
4937 
4939 
4940  if (fcb->ads)
4941  ii = &ccb->fileref->parent->fcb->inode_item;
4942  else
4943  ii = &fcb->inode_item;
4944 
4945  if (fcb == fcb->Vcb->dummy_fcb) {
4947 
4949  fsli->CreationTime = fsli->LastAccessTime = fsli->LastWriteTime = fsli->ChangeTime = time;
4950  } else {
4955  }
4956 
4957  if (fcb->ads) {
4959  fsli->FileAttributes = ccb->fileref->parent->fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : ccb->fileref->parent->fcb->atts;
4960  } else {
4963  fsli->FileAttributes = fcb->atts == 0 ? FILE_ATTRIBUTE_NORMAL : fcb->atts;
4964  }
4965 
4966  if (fcb->type == BTRFS_TYPE_SOCKET)
4968  else if (fcb->type == BTRFS_TYPE_FIFO)
4970  else if (fcb->type == BTRFS_TYPE_CHARDEV)
4972  else if (fcb->type == BTRFS_TYPE_BLOCKDEV)
4974  else if (!(fsli->FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
4975  fsli->ReparseTag = 0;
4976  else
4978 
4981 
4982  if (fcb->ads)
4983  fsli->NumberOfLinks = ccb->fileref->parent->fcb->inode_item.st_nlink;
4984  else
4986 
4987  fsli->EffectiveAccess = ccb->access;
4989 
4990  if (fcb->case_sensitive)
4992 
4993  fsli->LxUid = ii->st_uid;
4994  fsli->LxGid = ii->st_gid;
4995  fsli->LxMode = ii->st_mode;
4996 
4997  if (ii->st_mode & __S_IFBLK || ii->st_mode & __S_IFCHR) {
4998  fsli->LxDeviceIdMajor = (ii->st_rdev & 0xFFFFFFFFFFF00000) >> 20;
4999  fsli->LxDeviceIdMinor = (ii->st_rdev & 0xFFFFF);
5000  } else {
5001  fsli->LxDeviceIdMajor = 0;
5002  fsli->LxDeviceIdMinor = 0;
5003  }
5004 
5005  *length -= sizeof(FILE_STAT_LX_INFORMATION);
5006 
5007  return STATUS_SUCCESS;
5008 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
struct _file_ref * parent
Definition: btrfs_drv.h:352
#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:304
#define IO_REPARSE_TAG_LX_FIFO
Definition: btrfs_drv.h:121
#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:382
#define BTRFS_TYPE_CHARDEV
Definition: shellext.h:87
BTRFS_TIME st_ctime
Definition: btrfs.h:302
#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:1004
uint32_t st_gid
Definition: btrfs.h:294
uint32_t st_nlink
Definition: btrfs.h:292
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
LARGE_INTEGER LastAccessTime
Definition: fileinfo.c:56
uint8_t type
Definition: btrfs_drv.h:291
#define FILE_ATTRIBUTE_REPARSE_POINT
Definition: ntifs_ex.h:381
BTRFS_TIME st_mtime
Definition: btrfs.h:303
static __inline uint64_t unix_time_to_win(BTRFS_TIME *t)
Definition: recv.cpp:1067
uint64_t st_size
Definition: btrfs.h:289
#define LX_FILE_CASE_SENSITIVE_DIR
Definition: fileinfo.c:77
uint64_t inode
Definition: btrfs_drv.h:289
uint64_t st_rdev
Definition: btrfs.h:296
#define S_ISDIR(mode)
Definition: various.h:18
#define IO_REPARSE_TAG_LX_BLK
Definition: btrfs_drv.h:123
bool case_sensitive
Definition: btrfs_drv.h:310
#define __S_IFCHR
Definition: btrfs_drv.h:1745
BTRFS_TIME st_atime
Definition: btrfs.h:301
#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:292
LARGE_INTEGER EndOfFile
Definition: fileinfo.c:60
ULONG get_reparse_tag_fcb(fcb *fcb)
Definition: dirctrl.c:83
ULONG atts
Definition: btrfs_drv.h:297
#define IO_REPARSE_TAG_AF_UNIX
Definition: btrfs_drv.h:120
static __inline uint64_t fcb_alloc_size(fcb *fcb)
Definition: btrfs_drv.h:1814
struct _root * subvol
Definition: btrfs_drv.h:288
ANSI_STRING adsdata
Definition: btrfs_drv.h:334
#define IO_REPARSE_TAG_LX_CHR
Definition: btrfs_drv.h:122
struct _FILE_STAT_LX_INFORMATION FILE_STAT_LX_INFORMATION
LARGE_INTEGER ChangeTime
Definition: fileinfo.c:58
bool ads
Definition: btrfs_drv.h:330
#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:1746
#define STATUS_SUCCESS
Definition: shellext.h:65
file_ref * fileref
Definition: btrfs_drv.h:383
uint32_t st_uid
Definition: btrfs.h:293
struct _device_extension * Vcb
Definition: btrfs_drv.h:287
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:295

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 4401 of file fileinfo.c.

4401  {
4402  LONG reqsize;
4403  LIST_ENTRY* le;
4404  FILE_STREAM_INFORMATION *entry, *lastentry;
4405  NTSTATUS Status;
4406 
4407  static const WCHAR datasuf[] = L":$DATA";
4408  UNICODE_STRING suf;
4409 
4410  if (!fileref) {
4411  ERR("fileref was NULL\n");
4412  return STATUS_INVALID_PARAMETER;
4413  }
4414 
4415  suf.Buffer = (WCHAR*)datasuf;
4416  suf.Length = suf.MaximumLength = sizeof(datasuf) - sizeof(WCHAR);
4417 
4418  if (fileref->fcb->type != BTRFS_TYPE_DIRECTORY)
4419  reqsize = sizeof(FILE_STREAM_INFORMATION) - sizeof(WCHAR) + suf.Length + sizeof(WCHAR);
4420  else
4421  reqsize = 0;
4422 
4423  ExAcquireResourceSharedLite(&fileref->fcb->nonpaged->dir_children_lock, true);
4424 
4425  le = fileref->fcb->dir_children_index.Flink;
4426  while (le != &fileref->fcb->dir_children_index) {
4427  dir_child* dc = CONTAINING_RECORD(le, dir_child, list_entry_index);
4428 
4429  if (dc->index == 0) {
4430  reqsize = (ULONG)sector_align(reqsize, sizeof(LONGLONG));
4431  reqsize += sizeof(FILE_STREAM_INFORMATION) - sizeof(WCHAR) + suf.Length + sizeof(WCHAR) + dc->name.Length;
4432  } else
4433  break;
4434 
4435  le = le->Flink;
4436  }
4437 
4438  TRACE("length = %li, reqsize = %lu\n", *length, reqsize);
4439 
4440  if (reqsize > *length) {
4442  goto end;
4443  }
4444 
4445  entry = fsi;
4446  lastentry = NULL;
4447 
4448  if (fileref->fcb->type != BTRFS_TYPE_DIRECTORY) {
4449  ULONG off;
4450 
4451  entry->NextEntryOffset = 0;
4452  entry->StreamNameLength = suf.Length + sizeof(WCHAR);
4453  entry->StreamSize.QuadPart = fileref->fcb->inode_item.st_size;
4454  entry->StreamAllocationSize.QuadPart = fcb_alloc_size(fileref->fcb);
4455 
4456  entry->StreamName[0] = ':';
4457  RtlCopyMemory(&entry->StreamName[1], suf.Buffer, suf.Length);
4458 
4459  off = (ULONG)sector_align(sizeof(FILE_STREAM_INFORMATION) - sizeof(WCHAR) + suf.Length + sizeof(WCHAR), sizeof(LONGLONG));
4460 
4461  lastentry = entry;
4463  }
4464 
4465  le = fileref->fcb->dir_children_index.Flink;
4466  while (le != &fileref->fcb->dir_children_index) {
4467  dir_child* dc = CONTAINING_RECORD(le, dir_child, list_entry_index);
4468 
4469  if (dc->index == 0) {
4470  ULONG off;
4471 
4472  entry->NextEntryOffset = 0;
4473  entry->StreamNameLength = dc->name.Length + suf.Length + sizeof(WCHAR);
4474 
4475  if (dc->fileref)
4476  entry->StreamSize.QuadPart = dc->fileref->fcb->adsdata.Length;
4477  else
4478  entry->StreamSize.QuadPart = dc->size;
4479 
4480  entry->StreamAllocationSize.QuadPart = entry->StreamSize.QuadPart;
4481 
4482  entry->StreamName[0] = ':';
4483 
4484  RtlCopyMemory(&entry->StreamName[1], dc->name.Buffer, dc->name.Length);
4485  RtlCopyMemory(&entry->StreamName[1 + (dc->name.Length / sizeof(WCHAR))], suf.Buffer, suf.Length);
4486 
4487  if (lastentry)
4488  lastentry->NextEntryOffset = (uint32_t)((uint8_t*)entry - (uint8_t*)lastentry);
4489 
4490  off = (ULONG)sector_align(sizeof(FILE_STREAM_INFORMATION) - sizeof(WCHAR) + suf.Length + sizeof(WCHAR) + dc->name.Length, sizeof(LONGLONG));
4491 
4492  lastentry = entry;
4494  } else
4495  break;
4496 
4497  le = le->Flink;
4498  }
4499 
4500  *length -= reqsize;
4501 
4503 
4504 end:
4505  ExReleaseResourceLite(&fileref->fcb->nonpaged->dir_children_lock);
4506 
4507  return Status;
4508 }
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
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define BTRFS_TYPE_DIRECTORY
Definition: shellext.h:86
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
Status
Definition: gdiplustypes.h:24
int64_t LONGLONG
Definition: typedefs.h:68
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct _file_ref * fileref
Definition: btrfs_drv.h:305
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
GLuint GLuint end
Definition: gl.h:1545
uint32_t entry
Definition: isohybrid.c:63
Definition: typedefs.h:119
BYTE uint8_t
Definition: msvideo1.c:66
#define ERR(fmt,...)
Definition: debug.h:110
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
static __inline uint64_t fcb_alloc_size(fcb *fcb)
Definition: btrfs_drv.h:1814
#define NULL
Definition: types.h:112
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 RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
#define uint32_t
Definition: nsiface.idl:61
static uint64_t __inline sector_align(uint64_t n, uint64_t a)

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 4695 of file fileinfo.c.

4695  {
4696  NTSTATUS Status;
4697  LIST_ENTRY* le;
4698  LONG bytes_needed;
4700  bool overflow = false;
4701  fcb* fcb = fileref->fcb;
4702  ULONG len;
4703 
4704  if (fcb->ads)
4705  return STATUS_INVALID_PARAMETER;
4706 
4708  return STATUS_INVALID_PARAMETER;
4709 
4710  RtlZeroMemory(flfii, *length);
4711 
4713  len = bytes_needed;
4714  flefii = NULL;
4715 
4716  ExAcquireResourceSharedLite(fcb->Header.Resource, true);
4717 
4718  if (fcb->inode == SUBVOL_ROOT_INODE) {
4719  ULONG namelen;
4720 
4721  if (fcb == fcb->Vcb->root_fileref->fcb)
4722  namelen = sizeof(WCHAR);
4723  else
4724  namelen = fileref->dc->name.Length;
4725 
4727 
4728  if (bytes_needed > *length)
4729  overflow = true;
4730 
4731  if (!overflow) {
4732  flefii = &flfii->Entry;
4733 
4734  flefii->NextEntryOffset = 0;
4735 
4736  if (fcb == fcb->Vcb->root_fileref->fcb) {
4737  RtlZeroMemory(&flefii->ParentFileId.Identifier[0], sizeof(FILE_ID_128));
4738  flefii->FileNameLength = 1;
4739  flefii->FileName[0] = '.';
4740  } else {
4741  RtlCopyMemory(&flefii->ParentFileId.Identifier[0], &fileref->parent->fcb->inode, sizeof(uint64_t));
4742  RtlCopyMemory(&flefii->ParentFileId.Identifier[sizeof(uint64_t)], &fileref->parent->fcb->subvol->id, sizeof(uint64_t));
4743 
4744  flefii->FileNameLength = fileref->dc->name.Length / sizeof(WCHAR);
4745  RtlCopyMemory(flefii->FileName, fileref->dc->name.Buffer, fileref->dc->name.Length);
4746  }
4747 
4748  flfii->EntriesReturned++;
4749 
4750  len = bytes_needed;
4751  }
4752  } else {
4753  ExAcquireResourceExclusiveLite(&fcb->Vcb->fileref_lock, true);
4754 
4755  if (IsListEmpty(&fcb->hardlinks)) {
4756  bytes_needed += offsetof(FILE_LINK_ENTRY_FULL_ID_INFORMATION, FileName[0]) + fileref->dc->name.Length;
4757 
4758  if (bytes_needed > *length)
4759  overflow = true;
4760 
4761  if (!overflow) {
4762  flefii = &flfii->Entry;
4763 
4764  flefii->NextEntryOffset = 0;
4765 
4766  RtlCopyMemory(&flefii->ParentFileId.Identifier[0], &fileref->parent->fcb->inode, sizeof(uint64_t));
4767  RtlCopyMemory(&flefii->ParentFileId.Identifier[sizeof(uint64_t)], &fileref->parent->fcb->subvol->id, sizeof(uint64_t));
4768 
4769  flefii->FileNameLength = fileref->dc->name.Length / sizeof(WCHAR);
4770  RtlCopyMemory(flefii->FileName, fileref->dc->name.Buffer, fileref->dc->name.Length);
4771 
4772  flfii->EntriesReturned++;
4773 
4774  len = bytes_needed;
4775  }
4776  } else {
4777  le = fcb->hardlinks.Flink;
4778  while (le != &fcb->hardlinks) {
4780  file_ref* parfr;
4781 
4782  TRACE("parent %I64x, index %I64x, name %.*S\n", hl->parent, hl->index, (int)(hl->name.Length / sizeof(WCHAR)), hl->name.Buffer);
4783