/** * get_name_to_buffer - get the pathname to a buffer ensure dir / is appended * @path: path to get name for (NOT NULL) * @flags: flags controlling path lookup * @buffer: buffer to put name in (NOT NULL) * @size: size of buffer * @name: Returns - contains position of path name in @buffer (NOT NULL) * * Returns: %0 else error on failure */ static int get_name_to_buffer(struct path *path, int flags, char *buffer, int size, char **name, const char **info) { int adjust = (flags & PATH_IS_DIR) ? 1 : 0; int error = d_namespace_path(path, buffer, size - adjust, name, flags); if (!error && (flags & PATH_IS_DIR) && (*name)[1] != '\0') /* * Append "/" to the pathname. The root directory is a special * case; it already ends in slash. */ strcpy(&buffer[size - 2], "/"); if (info && error) { if (error == -ENOENT) *info = "Failed name lookup - deleted entry"; else if (error == -ESTALE) *info = "Failed name lookup - disconnected path"; else if (error == -ENAMETOOLONG) *info = "Failed name lookup - name too long"; else *info = "Failed name lookup"; } return error; }
/** * aa_path_name - get the pathname to a buffer ensure dir / is appended * @path: path the file (NOT NULL) * @flags: flags controlling path name generation * @buffer: buffer to put name in (NOT NULL) * @name: Returns - the generated path name if !error (NOT NULL) * @info: Returns - information on why the path lookup failed (MAYBE NULL) * * @name is a pointer to the beginning of the pathname (which usually differs * from the beginning of the buffer), or NULL. If there is an error @name * may contain a partial or invalid name that can be used for audit purposes, * but it can not be used for mediation. * * We need PATH_IS_DIR to indicate whether the file is a directory or not * because the file may not yet exist, and so we cannot check the inode's * file type. * * Returns: %0 else error code if could retrieve name */ int aa_path_name(struct path *path, int flags, char *buffer, const char **name, const char **info) { char *str = NULL; int adjust = (flags & PATH_IS_DIR) ? 1 : 0; int error = d_namespace_path(path, buffer, aa_g_path_max - adjust, &str, flags); if (!error && (flags & PATH_IS_DIR) && str[1] != '\0') /* * Append "/" to the pathname. The root directory is a special * case; it already ends in slash. */ strcpy(&buffer[aa_g_path_max - 2], "/"); if (info && error) { if (error == -ENOENT) *info = "Failed name lookup - deleted entry"; else if (error == -EACCES) *info = "Failed name lookup - disconnected path"; else if (error == -ENAMETOOLONG) *info = "Failed name lookup - name too long"; else *info = "Failed name lookup"; } *name = str; return error; }
/** * get_name_to_buffer - get the pathname to a buffer ensure dir / is appended * @path: path to get name for (NOT NULL) * @flags: flags controlling path lookup * @buffer: buffer to put name in (NOT NULL) * @size: size of buffer * @name: Returns - contains position of path name in @buffer (NOT NULL) * * Returns: %0 else error on failure */ static int get_name_to_buffer(struct path *path, int flags, char *buffer, int size, char **name) { int adjust = (flags & PATH_IS_DIR) ? 1 : 0; int error = d_namespace_path(path, buffer, size - adjust, name, flags); if (!error && (flags & PATH_IS_DIR) && (*name)[1] != '\0') /* * Append "/" to the pathname. The root directory is a special * case; it already ends in slash. */ strcpy(&buffer[size - 2], "/"); return error; }