[llvm] r298326 - [Support] Fill the file_status struct with link count.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 20 16:55:20 PDT 2017
Author: zturner
Date: Mon Mar 20 18:55:20 2017
New Revision: 298326
URL: http://llvm.org/viewvc/llvm-project?rev=298326&view=rev
Log:
[Support] Fill the file_status struct with link count.
Differential Revision: https://reviews.llvm.org/D31110
Modified:
llvm/trunk/include/llvm/Support/FileSystem.h
llvm/trunk/lib/Support/Unix/Path.inc
llvm/trunk/lib/Support/Windows/Path.inc
Modified: llvm/trunk/include/llvm/Support/FileSystem.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileSystem.h?rev=298326&r1=298325&r2=298326&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/FileSystem.h (original)
+++ llvm/trunk/include/llvm/Support/FileSystem.h Mon Mar 20 18:55:20 2017
@@ -147,6 +147,7 @@ class file_status
#if defined(LLVM_ON_UNIX)
dev_t fs_st_dev = 0;
+ nlink_t fs_st_nlinks = 0;
ino_t fs_st_ino = 0;
time_t fs_st_atime = 0;
time_t fs_st_mtime = 0;
@@ -154,6 +155,7 @@ class file_status
gid_t fs_st_gid = 0;
off_t fs_st_size = 0;
#elif defined (LLVM_ON_WIN32)
+ uint32_t NumLinks = 0;
uint32_t LastAccessedTimeHigh = 0;
uint32_t LastAccessedTimeLow = 0;
uint32_t LastWriteTimeHigh = 0;
@@ -173,22 +175,24 @@ public:
file_status(file_type Type) : Type(Type) {}
- file_status(file_type Type, perms Perms, dev_t Dev, ino_t Ino, time_t ATime,
- time_t MTime, uid_t UID, gid_t GID, off_t Size)
- : fs_st_dev(Dev), fs_st_ino(Ino), fs_st_atime(ATime), fs_st_mtime(MTime),
- fs_st_uid(UID), fs_st_gid(GID), fs_st_size(Size), Type(Type),
- Perms(Perms) {}
+ file_status(file_type Type, perms Perms, dev_t Dev, nlink_t Links, ino_t Ino,
+ time_t ATime, time_t MTime, uid_t UID, gid_t GID, off_t Size)
+ : fs_st_dev(Dev), fs_st_nlinks(Links), fs_st_ino(Ino), fs_st_atime(ATime),
+ fs_st_mtime(MTime), fs_st_uid(UID), fs_st_gid(GID), fs_st_size(Size),
+ Type(Type), Perms(Perms) {}
#elif defined(LLVM_ON_WIN32)
file_status() = default;
file_status(file_type Type) : Type(Type) {}
- file_status(file_type Type, perms Perms, uint32_t LastAccessTimeHigh,
- uint32_t LastAccessTimeLow, uint32_t LastWriteTimeHigh,
- uint32_t LastWriteTimeLow, uint32_t VolumeSerialNumber,
- uint32_t FileSizeHigh, uint32_t FileSizeLow,
- uint32_t FileIndexHigh, uint32_t FileIndexLow)
- : LastAccessedTimeHigh(LastAccessTimeHigh), LastAccessedTimeLow(LastAccessTimeLow),
+ file_status(file_type Type, perms Perms, uint32_t LinkCount,
+ uint32_t LastAccessTimeHigh, uint32_t LastAccessTimeLow,
+ uint32_t LastWriteTimeHigh, uint32_t LastWriteTimeLow,
+ uint32_t VolumeSerialNumber, uint32_t FileSizeHigh,
+ uint32_t FileSizeLow, uint32_t FileIndexHigh,
+ uint32_t FileIndexLow)
+ : NumLinks(LinkCount), LastAccessedTimeHigh(LastAccessTimeHigh),
+ LastAccessedTimeLow(LastAccessTimeLow),
LastWriteTimeHigh(LastWriteTimeHigh),
LastWriteTimeLow(LastWriteTimeLow),
VolumeSerialNumber(VolumeSerialNumber), FileSizeHigh(FileSizeHigh),
@@ -202,6 +206,7 @@ public:
TimePoint<> getLastAccessedTime() const;
TimePoint<> getLastModificationTime() const;
UniqueID getUniqueID() const;
+ uint32_t getLinkCount() const;
#if defined(LLVM_ON_UNIX)
uint32_t getUser() const { return fs_st_uid; }
Modified: llvm/trunk/lib/Support/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=298326&r1=298325&r2=298326&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Path.inc (original)
+++ llvm/trunk/lib/Support/Unix/Path.inc Mon Mar 20 18:55:20 2017
@@ -230,6 +230,10 @@ UniqueID file_status::getUniqueID() cons
return UniqueID(fs_st_dev, fs_st_ino);
}
+uint32_t file_status::getLinkCount() const {
+ return fs_st_nlinks;
+}
+
ErrorOr<space_info> disk_space(const Twine &Path) {
struct STATVFS Vfs;
if (::STATVFS(Path.str().c_str(), &Vfs))
@@ -549,10 +553,9 @@ static std::error_code fillStatus(int St
Type = file_type::symlink_file;
perms Perms = static_cast<perms>(Status.st_mode) & all_perms;
- Result =
- file_status(Type, Perms, Status.st_dev, Status.st_ino, Status.st_atime,
- Status.st_mtime, Status.st_uid, Status.st_gid,
- Status.st_size);
+ Result = file_status(Type, Perms, Status.st_dev, Status.st_nlink,
+ Status.st_ino, Status.st_atime, Status.st_mtime,
+ Status.st_uid, Status.st_gid, Status.st_size);
return std::error_code();
}
Modified: llvm/trunk/lib/Support/Windows/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Path.inc?rev=298326&r1=298325&r2=298326&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Path.inc (original)
+++ llvm/trunk/lib/Support/Windows/Path.inc Mon Mar 20 18:55:20 2017
@@ -179,6 +179,10 @@ TimePoint<> file_status::getLastModifica
return toTimePoint(Time);
}
+uint32_t file_status::getLinkCount() const {
+ return NumLinks;
+}
+
std::error_code current_path(SmallVectorImpl<char> &result) {
SmallVector<wchar_t, MAX_PATH> cur_path;
DWORD len = MAX_PATH;
@@ -534,7 +538,8 @@ static std::error_code getStatus(HANDLE
? (all_read | all_exe)
: all_all;
Result = file_status(
- Type, Permissions, Info.ftLastAccessTime.dwHighDateTime,
+ Type, Permissions, Info.nNumberOfLinks,
+ Info.ftLastAccessTime.dwHighDateTime,
Info.ftLastAccessTime.dwLowDateTime,
Info.ftLastWriteTime.dwHighDateTime, Info.ftLastWriteTime.dwLowDateTime,
Info.dwVolumeSerialNumber, Info.nFileSizeHigh, Info.nFileSizeLow,
More information about the llvm-commits
mailing list