#define VIRTIO_FS_FUSE_MODE_PERM_RWXU 0000700u\r
#define VIRTIO_FS_FUSE_MODE_PERM_RUSR 0000400u\r
#define VIRTIO_FS_FUSE_MODE_PERM_WUSR 0000200u\r
+#define VIRTIO_FS_FUSE_MODE_PERM_XUSR 0000100u\r
#define VIRTIO_FS_FUSE_MODE_PERM_RWXG 0000070u\r
#define VIRTIO_FS_FUSE_MODE_PERM_RGRP 0000040u\r
#define VIRTIO_FS_FUSE_MODE_PERM_WGRP 0000020u\r
+#define VIRTIO_FS_FUSE_MODE_PERM_XGRP 0000010u\r
#define VIRTIO_FS_FUSE_MODE_PERM_RWXO 0000007u\r
#define VIRTIO_FS_FUSE_MODE_PERM_ROTH 0000004u\r
#define VIRTIO_FS_FUSE_MODE_PERM_WOTH 0000002u\r
+#define VIRTIO_FS_FUSE_MODE_PERM_XOTH 0000001u\r
\r
//\r
// Flags for VirtioFsFuseOpSetAttr, in the VIRTIO_FS_FUSE_SETATTR_REQUEST.Valid\r
\r
return EFI_SUCCESS;\r
}\r
+\r
+/**\r
+ Given an EFI_FILE_INFO object received in an EFI_FILE_PROTOCOL.SetInfo()\r
+ call, determine whether updating the file mode bits of the file is necessary,\r
+ relative to an EFI_FILE_INFO object describing the current state of the file.\r
+\r
+ @param[in] Info The EFI_FILE_INFO describing the current state of the\r
+ file. The caller is responsible for populating Info on\r
+ input with VirtioFsFuseAttrToEfiFileInfo(), from the\r
+ current FUSE attributes of the file. The Info->Size and\r
+ Info->FileName members are ignored.\r
+\r
+ @param[in] NewInfo The EFI_FILE_INFO object received in the\r
+ EFI_FILE_PROTOCOL.SetInfo() call.\r
+\r
+ @param[out] Update Set to TRUE on output if the file mode bits need to be\r
+ updated. Set to FALSE otherwise.\r
+\r
+ @param[out] Mode If Update is set to TRUE, then Mode provides the file\r
+ mode bits to set. Otherwise, Mode is not written to.\r
+\r
+ @retval EFI_SUCCESS Output parameters have been set successfully.\r
+\r
+ @retval EFI_ACCESS_DENIED NewInfo requests toggling an unknown bit in the\r
+ Attribute bitmask.\r
+\r
+ @retval EFI_ACCESS_DENIED NewInfo requests toggling EFI_FILE_DIRECTORY in\r
+ the Attribute bitmask.\r
+**/\r
+EFI_STATUS\r
+VirtioFsGetFuseModeUpdate (\r
+ IN EFI_FILE_INFO *Info,\r
+ IN EFI_FILE_INFO *NewInfo,\r
+ OUT BOOLEAN *Update,\r
+ OUT UINT32 *Mode\r
+ )\r
+{\r
+ UINT64 Toggle;\r
+ BOOLEAN IsDirectory;\r
+ BOOLEAN IsWriteable;\r
+ BOOLEAN WillBeWriteable;\r
+\r
+ Toggle = Info->Attribute ^ NewInfo->Attribute;\r
+ if ((Toggle & ~EFI_FILE_VALID_ATTR) != 0) {\r
+ //\r
+ // Unknown attribute requested.\r
+ //\r
+ return EFI_ACCESS_DENIED;\r
+ }\r
+ if ((Toggle & EFI_FILE_DIRECTORY) != 0) {\r
+ //\r
+ // EFI_FILE_DIRECTORY cannot be toggled.\r
+ //\r
+ return EFI_ACCESS_DENIED;\r
+ }\r
+\r
+ IsDirectory = (BOOLEAN)((Info->Attribute & EFI_FILE_DIRECTORY) != 0);\r
+ IsWriteable = (BOOLEAN)((Info->Attribute & EFI_FILE_READ_ONLY) == 0);\r
+ WillBeWriteable = (BOOLEAN)((NewInfo->Attribute & EFI_FILE_READ_ONLY) == 0);\r
+\r
+ if (IsWriteable == WillBeWriteable) {\r
+ *Update = FALSE;\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ if (IsDirectory) {\r
+ if (WillBeWriteable) {\r
+ *Mode = (VIRTIO_FS_FUSE_MODE_PERM_RWXU |\r
+ VIRTIO_FS_FUSE_MODE_PERM_RWXG |\r
+ VIRTIO_FS_FUSE_MODE_PERM_RWXO);\r
+ } else {\r
+ *Mode = (VIRTIO_FS_FUSE_MODE_PERM_RUSR |\r
+ VIRTIO_FS_FUSE_MODE_PERM_XUSR |\r
+ VIRTIO_FS_FUSE_MODE_PERM_RGRP |\r
+ VIRTIO_FS_FUSE_MODE_PERM_XGRP |\r
+ VIRTIO_FS_FUSE_MODE_PERM_ROTH |\r
+ VIRTIO_FS_FUSE_MODE_PERM_XOTH);\r
+ }\r
+ } else {\r
+ if (WillBeWriteable) {\r
+ *Mode = (VIRTIO_FS_FUSE_MODE_PERM_RUSR |\r
+ VIRTIO_FS_FUSE_MODE_PERM_WUSR |\r
+ VIRTIO_FS_FUSE_MODE_PERM_RGRP |\r
+ VIRTIO_FS_FUSE_MODE_PERM_WGRP |\r
+ VIRTIO_FS_FUSE_MODE_PERM_ROTH |\r
+ VIRTIO_FS_FUSE_MODE_PERM_WOTH);\r
+ } else {\r
+ *Mode = (VIRTIO_FS_FUSE_MODE_PERM_RUSR |\r
+ VIRTIO_FS_FUSE_MODE_PERM_RGRP |\r
+ VIRTIO_FS_FUSE_MODE_PERM_ROTH);\r
+ }\r
+ }\r
+ *Update = TRUE;\r
+ return EFI_SUCCESS;\r
+}\r