Fix return value of 'set-file-extended-attributes'

* lisp/files.el (set-file-extended-attributes): Return non-nil
when setting either ACLs or SELinux context succeeds.  Document
the return value.  (Bug#21699)

* doc/lispref/files.texi (Changing Files): Document the return
value of set-file-extended-attributes.
This commit is contained in:
Eli Zaretskii 2015-10-19 10:04:50 +03:00
parent 552482d41d
commit f1575763c0
2 changed files with 15 additions and 8 deletions

View file

@ -1758,6 +1758,8 @@ time and must be in the format returned by @code{current-time}
This function sets the Emacs-recognized extended file attributes for This function sets the Emacs-recognized extended file attributes for
@code{filename}. The second argument @var{attribute-alist} should be @code{filename}. The second argument @var{attribute-alist} should be
an alist of the same form returned by @code{file-extended-attributes}. an alist of the same form returned by @code{file-extended-attributes}.
The return value is @code{t} if the attributes are successfully set,
otherwise it is @code{nil}.
@xref{Extended Attributes}. @xref{Extended Attributes}.
@end defun @end defun

View file

@ -4055,14 +4055,19 @@ such as SELinux context, list of ACL entries, etc."
"Set extended attributes of file FILENAME to ATTRIBUTES. "Set extended attributes of file FILENAME to ATTRIBUTES.
ATTRIBUTES must be an alist of file attributes as returned by ATTRIBUTES must be an alist of file attributes as returned by
`file-extended-attributes'." `file-extended-attributes'.
(dolist (elt attributes) Value is t if the function succeeds in setting the attributes."
(let ((attr (car elt)) (let (result rv)
(val (cdr elt))) (dolist (elt attributes)
(cond ((eq attr 'acl) (let ((attr (car elt))
(set-file-acl filename val)) (val (cdr elt)))
((eq attr 'selinux-context) (cond ((eq attr 'acl)
(set-file-selinux-context filename val)))))) (setq rv (set-file-acl filename val)))
((eq attr 'selinux-context)
(setq rv (set-file-selinux-context filename val))))
(setq result (or result rv))))
result))
(defun backup-buffer () (defun backup-buffer ()
"Make a backup of the disk file visited by the current buffer, if appropriate. "Make a backup of the disk file visited by the current buffer, if appropriate.