diff options
author | Sverker Eriksson <[email protected]> | 2017-08-23 13:33:29 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2017-08-23 13:33:29 +0200 |
commit | 8453bda5805bc8a2d4709b5d15643fb0512a8a23 (patch) | |
tree | bd8306dbfac6eca83ea2eac81ef399953b085e34 /lib/ssh/src/ssh_sftp.erl | |
parent | 9513aed6c04c34f06bd594b771ee9471a5264ac0 (diff) | |
parent | 26416b5430795f3a27913931afbb7ef1dc51d4bd (diff) | |
download | otp-8453bda5805bc8a2d4709b5d15643fb0512a8a23.tar.gz otp-8453bda5805bc8a2d4709b5d15643fb0512a8a23.tar.bz2 otp-8453bda5805bc8a2d4709b5d15643fb0512a8a23.zip |
Merge branch 'maint'
Diffstat (limited to 'lib/ssh/src/ssh_sftp.erl')
-rw-r--r-- | lib/ssh/src/ssh_sftp.erl | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/ssh/src/ssh_sftp.erl b/lib/ssh/src/ssh_sftp.erl index c1558a19b1..9e1229dc85 100644 --- a/lib/ssh/src/ssh_sftp.erl +++ b/lib/ssh/src/ssh_sftp.erl @@ -1050,7 +1050,7 @@ attr_to_info(A) when is_record(A, ssh_xfer_attr) -> #file_info{ size = A#ssh_xfer_attr.size, type = A#ssh_xfer_attr.type, - access = read_write, %% FIXME: read/write/read_write/none + access = file_mode_to_owner_access(A#ssh_xfer_attr.permissions), atime = unix_to_datetime(A#ssh_xfer_attr.atime), mtime = unix_to_datetime(A#ssh_xfer_attr.mtime), ctime = unix_to_datetime(A#ssh_xfer_attr.createtime), @@ -1062,6 +1062,28 @@ attr_to_info(A) when is_record(A, ssh_xfer_attr) -> uid = A#ssh_xfer_attr.owner, gid = A#ssh_xfer_attr.group}. +file_mode_to_owner_access(FileMode) + when is_integer(FileMode) -> + %% The file mode contains the access permissions. + %% The read and write access permission of file owner + %% are located in 8th and 7th bit of file mode respectively. + + ReadPermission = ((FileMode bsr 8) band 1), + WritePermission = ((FileMode bsr 7) band 1), + case {ReadPermission, WritePermission} of + {1, 1} -> + read_write; + {1, 0} -> + read; + {0, 1} -> + write; + {0, 0} -> + none; + _ -> + undefined + end; +file_mode_to_owner_access(_) -> + undefined. unix_to_datetime(undefined) -> undefined; |