From 3083390e63220de4b52a31c55a43c6987faa982e Mon Sep 17 00:00:00 2001 From: Jarkko Sakkinen Date: Mon, 3 Jun 2013 11:31:02 +0300 Subject: [PATCH] Return length of the label on success in smack_new_label_from* Return length of the label on success and negative value on failure. Signed-off-by: Jarkko Sakkinen --- libsmack/libsmack.c | 13 ++++++------- libsmack/sys/smack.h | 21 ++++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/libsmack/libsmack.c b/libsmack/libsmack.c index 30a1ebf..a33887b 100644 --- a/libsmack/libsmack.c +++ b/libsmack/libsmack.c @@ -489,7 +489,7 @@ const char *smack_smackfs_path(void) return smack_mnt; } -int smack_new_label_from_self(char **label) +ssize_t smack_new_label_from_self(char **label) { char *result; int fd; @@ -513,10 +513,10 @@ int smack_new_label_from_self(char **label) } *label = result; - return 0; + return ret; } -int smack_new_label_from_socket(int fd, char **label) +ssize_t smack_new_label_from_socket(int fd, char **label) { char dummy; int ret; @@ -538,11 +538,11 @@ int smack_new_label_from_socket(int fd, char **label) } *label = result; - return 0; + return length; } -int smack_new_label_from_path(const char *path, const char *xattr, int follow, - const char **label) +ssize_t smack_new_label_from_path(const char *path, const char *xattr, + int follow, const char **label) { char *result; ssize_t ret = 0; @@ -569,7 +569,6 @@ int smack_new_label_from_path(const char *path, const char *xattr, int follow, return 0; } - int smack_set_label_for_self(const char *label) { int len; diff --git a/libsmack/sys/smack.h b/libsmack/sys/smack.h index c736a53..cf045d7 100644 --- a/libsmack/sys/smack.h +++ b/libsmack/sys/smack.h @@ -184,9 +184,10 @@ const char *smack_smackfs_path(void); * Caller is responsible of freeing the returned label. * * @param label returned label - * @return 0 on success and negative value on failure. + * @return Returns lenght of the label on success and negative value + * on failure. */ -int smack_new_label_from_self(char **label); +ssize_t smack_new_label_from_self(char **label); /*! * Get the label that is associated with a peer on the other end of an @@ -195,9 +196,10 @@ int smack_new_label_from_self(char **label); * * @param fd socket file descriptor * @param label returned label - * @return 0 on success and negative value on failure. + * @return Returns lenght of the label on success and negative value + * on failure. */ -int smack_new_label_from_socket(int fd, char **label); +ssize_t smack_new_label_from_socket(int fd, char **label); /*! * Get the SMACK label that is contained in an extended attribute. @@ -207,12 +209,13 @@ int smack_new_label_from_socket(int fd, char **label); * @param xattr extended attribute containing the SMACK label * @param follow whether or not to follow symbolic link * @param label returned label - * @return 0 on success and negative value on failure. + * @return Returns lenght of the label on success and negative value + * on failure. */ -int smack_new_label_from_path(const char *path, - const char *xattr, - int follow, - const char **label); +ssize_t smack_new_label_from_path(const char *path, + const char *xattr, + int follow, + const char **label); /*! * Set the label associated with the callers process. -- 2.7.4