FreeBSD ZFS
The Zettabyte File System
Data Structures | Defines | Typedefs | Functions | Variables

zfs_fuid.c File Reference

FUID Domain table(s). More...

#include <sys/zfs_context.h>
#include <sys/dmu.h>
#include <sys/avl.h>
#include <sys/zap.h>
#include <sys/refcount.h>
#include <sys/nvpair.h>
#include <sys/kidmap.h>
#include <sys/sid.h>
#include <sys/zfs_vfsops.h>
#include <sys/zfs_znode.h>
#include <sys/zfs_fuid.h>
Include dependency graph for zfs_fuid.c:

Go to the source code of this file.

Data Structures

struct  fuid_domain

Defines

#define FUID_IDX   "fuid_idx"
#define FUID_DOMAIN   "fuid_domain"
#define FUID_OFFSET   "fuid_offset"
#define FUID_NVP_ARRAY   "fuid_nvlist"

Typedefs

typedef struct fuid_domain fuid_domain_t

Functions

static int idx_compare (const void *arg1, const void *arg2)
 Compare two indexes.
static int domain_compare (const void *arg1, const void *arg2)
 Compare two domain strings.
void zfs_fuid_avl_tree_create (avl_tree_t *idx_tree, avl_tree_t *domain_tree)
uint64_t zfs_fuid_table_load (objset_t *os, uint64_t fuid_obj, avl_tree_t *idx_tree, avl_tree_t *domain_tree)
 load initial fuid domain and idx trees.
void zfs_fuid_table_destroy (avl_tree_t *idx_tree, avl_tree_t *domain_tree)
char * zfs_fuid_idx_domain (avl_tree_t *idx_tree, uint32_t idx)
static void zfs_fuid_init (zfsvfs_t *zfsvfs)
 Load the fuid table(s) into memory.
void zfs_fuid_sync (zfsvfs_t *zfsvfs, dmu_tx_t *tx)
 sync out AVL trees to persistent storage.
int zfs_fuid_find_by_domain (zfsvfs_t *zfsvfs, const char *domain, char **retdomain, boolean_t addok)
 Query domain table for a given domain.
const char * zfs_fuid_find_by_idx (zfsvfs_t *zfsvfs, uint32_t idx)
 Query domain table by index, returning domain string.
void zfs_fuid_map_ids (znode_t *zp, cred_t *cr, uid_t *uidp, uid_t *gidp)
uid_t zfs_fuid_map_id (zfsvfs_t *zfsvfs, uint64_t fuid, cred_t *cr, zfs_fuid_type_t type)
void zfs_fuid_node_add (zfs_fuid_info_t **fuidpp, const char *domain, uint32_t rid, uint64_t idx, uint64_t id, zfs_fuid_type_t type)
 Add a FUID node to the list of fuid's being created for this ACL.
uint64_t zfs_fuid_create_cred (zfsvfs_t *zfsvfs, zfs_fuid_type_t type, cred_t *cr, zfs_fuid_info_t **fuidp)
 Create a file system FUID, based on information in the users cred.
uint64_t zfs_fuid_create (zfsvfs_t *zfsvfs, uint64_t id, cred_t *cr, zfs_fuid_type_t type, zfs_fuid_info_t **fuidpp)
 Create a file system FUID for an ACL ace or a chown/chgrp of the file.
void zfs_fuid_destroy (zfsvfs_t *zfsvfs)
zfs_fuid_info_tzfs_fuid_info_alloc (void)
 Allocate zfs_fuid_info for tracking FUIDs created during zfs_mknode, VOP_SETATTR() or VOP_SETSECATTR()
void zfs_fuid_info_free (zfs_fuid_info_t *fuidp)
 Release all memory associated with zfs_fuid_info_t.
boolean_t zfs_groupmember (zfsvfs_t *zfsvfs, uint64_t id, cred_t *cr)
 Check to see if id is a groupmember.
void zfs_fuid_txhold (zfsvfs_t *zfsvfs, dmu_tx_t *tx)

Variables

static char * nulldomain = ""

Detailed Description

FUID Domain table(s).

The FUID table is stored as a packed nvlist of an array of nvlists which contain an index, domain string and offset

During file system initialization the nvlist(s) are read and two AVL trees are created. One tree is keyed by the index number and the other by the domain string. Nodes are never removed from trees, but new entries may be added. If a new entry is added then the zfsvfs->z_fuid_dirty flag is set to true and the caller will then be responsible for calling zfs_fuid_sync() to sync the changes to disk.

Definition in file zfs_fuid.c.


Define Documentation

#define FUID_DOMAIN   "fuid_domain"

Definition at line 56 of file zfs_fuid.c.

#define FUID_IDX   "fuid_idx"

Definition at line 55 of file zfs_fuid.c.

#define FUID_NVP_ARRAY   "fuid_nvlist"

Definition at line 58 of file zfs_fuid.c.

#define FUID_OFFSET   "fuid_offset"

Definition at line 57 of file zfs_fuid.c.


Typedef Documentation

typedef struct fuid_domain fuid_domain_t

Function Documentation

static int domain_compare ( const void *  arg1,
const void *  arg2 
) [static]

Compare two domain strings.

Definition at line 89 of file zfs_fuid.c.

static int idx_compare ( const void *  arg1,
const void *  arg2 
) [static]

Compare two indexes.

Definition at line 73 of file zfs_fuid.c.

void zfs_fuid_avl_tree_create ( avl_tree_t *  idx_tree,
avl_tree_t *  domain_tree 
)

Definition at line 102 of file zfs_fuid.c.

uint64_t zfs_fuid_create ( zfsvfs_t zfsvfs,
uint64_t  id,
cred_t *  cr,
zfs_fuid_type_t  type,
zfs_fuid_info_t **  fuidpp 
)

Create a file system FUID for an ACL ace or a chown/chgrp of the file.

This is similar to zfs_fuid_create_cred, except that we can't find the domain + rid information in the cred. Instead we have to query Winchester for the domain and rid.

During replay operations the domain+rid information is found in the zfs_fuid_info_t that the replay code has attached to the zfsvfs of the file system.

Definition at line 556 of file zfs_fuid.c.

uint64_t zfs_fuid_create_cred ( zfsvfs_t zfsvfs,
zfs_fuid_type_t  type,
cred_t *  cr,
zfs_fuid_info_t **  fuidp 
)

Create a file system FUID, based on information in the users cred.

If cred contains KSID_OWNER then it should be used to determine the uid otherwise cred's uid will be used. By default cred's gid is used unless it's an ephemeral ID in which case KSID_GROUP will be used if it exists.

Definition at line 499 of file zfs_fuid.c.

void zfs_fuid_destroy ( zfsvfs_t zfsvfs)

Definition at line 640 of file zfs_fuid.c.

int zfs_fuid_find_by_domain ( zfsvfs_t zfsvfs,
const char *  domain,
char **  retdomain,
boolean_t  addok 
)

Query domain table for a given domain.

If domain isn't found and addok is set, it is added to AVL trees and the zfsvfs->z_fuid_dirty flag will be set to TRUE. It will then be necessary for the caller or another thread to detect the dirty table and sync out the changes.

Definition at line 302 of file zfs_fuid.c.

const char* zfs_fuid_find_by_idx ( zfsvfs_t zfsvfs,
uint32_t  idx 
)

Query domain table by index, returning domain string.

Returns:
A pointer from an avl node of the domain string.

Definition at line 367 of file zfs_fuid.c.

char* zfs_fuid_idx_domain ( avl_tree_t *  idx_tree,
uint32_t  idx 
)

Definition at line 183 of file zfs_fuid.c.

zfs_fuid_info_t* zfs_fuid_info_alloc ( void  )

Allocate zfs_fuid_info for tracking FUIDs created during zfs_mknode, VOP_SETATTR() or VOP_SETSECATTR()

Definition at line 656 of file zfs_fuid.c.

void zfs_fuid_info_free ( zfs_fuid_info_t fuidp)

Release all memory associated with zfs_fuid_info_t.

Definition at line 672 of file zfs_fuid.c.

static void zfs_fuid_init ( zfsvfs_t zfsvfs) [static]

Load the fuid table(s) into memory.

Definition at line 200 of file zfs_fuid.c.

uid_t zfs_fuid_map_id ( zfsvfs_t zfsvfs,
uint64_t  fuid,
cred_t *  cr,
zfs_fuid_type_t  type 
)

Definition at line 397 of file zfs_fuid.c.

void zfs_fuid_map_ids ( znode_t zp,
cred_t *  cr,
uid_t *  uidp,
uid_t *  gidp 
)

Definition at line 390 of file zfs_fuid.c.

void zfs_fuid_node_add ( zfs_fuid_info_t **  fuidpp,
const char *  domain,
uint32_t  rid,
uint64_t  idx,
uint64_t  id,
zfs_fuid_type_t  type 
)

Add a FUID node to the list of fuid's being created for this ACL.

If ACL has multiple domains, then keep only one copy of each unique domain.

Definition at line 432 of file zfs_fuid.c.

void zfs_fuid_sync ( zfsvfs_t zfsvfs,
dmu_tx_t tx 
)

sync out AVL trees to persistent storage.

Definition at line 227 of file zfs_fuid.c.

void zfs_fuid_table_destroy ( avl_tree_t *  idx_tree,
avl_tree_t *  domain_tree 
)

Definition at line 166 of file zfs_fuid.c.

uint64_t zfs_fuid_table_load ( objset_t os,
uint64_t  fuid_obj,
avl_tree_t *  idx_tree,
avl_tree_t *  domain_tree 
)

load initial fuid domain and idx trees.

This function is used by both the kernel and zdb.

Definition at line 115 of file zfs_fuid.c.

void zfs_fuid_txhold ( zfsvfs_t zfsvfs,
dmu_tx_t tx 
)

Definition at line 752 of file zfs_fuid.c.

boolean_t zfs_groupmember ( zfsvfs_t zfsvfs,
uint64_t  id,
cred_t *  cr 
)

Check to see if id is a groupmember.

If cred has ksid info then sidlist is checked first and if still not found then POSIX groups are checked

Will use a straight FUID compare when possible.

Definition at line 702 of file zfs_fuid.c.


Variable Documentation

char* nulldomain = "" [static]

Definition at line 67 of file zfs_fuid.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines