/* Allocates and initializes an ivector. Returns the initialized ivector, * or NULL on failiure. */ au_iarray * au_iarray_new() { au_iarray * result = NULL; au_iarray * aid = au_iarray_alloc(); if(!aid) { return NULL; } result = au_iarray_initialize(result); /* If initialization fails, free the vector and return NULL indicating error. */ if(!result) { return au_iarray_free(result); } return result; }
static int test_inode_busy(struct super_block *sb, aufs_bindex_t bindex, unsigned int sigen, const unsigned int verbose) { int err; unsigned long long max, ull; struct inode *i, **array; aufs_bindex_t bstart, bend; array = au_iarray_alloc(sb, &max); err = PTR_ERR(array); if (IS_ERR(array)) goto out; err = 0; AuDbg("b%d\n", bindex); for (ull = 0; !err && ull < max; ull++) { i = array[ull]; if (i->i_ino == AUFS_ROOT_INO) continue; /* AuDbgInode(i); */ if (au_iigen(i) == sigen) ii_read_lock_child(i); else { ii_write_lock_child(i); err = au_refresh_hinode_self(i); au_iigen_dec(i); if (!err) ii_downgrade_lock(i); else { ii_write_unlock(i); break; } } bstart = au_ibstart(i); bend = au_ibend(i); if (bstart <= bindex && bindex <= bend && au_h_iptr(i, bindex) && au_test_ibusy(i, bstart, bend)) { err = -EBUSY; AuVerbose(verbose, "busy i%lu\n", i->i_ino); AuDbgInode(i); } ii_read_unlock(i); } au_iarray_free(array, max); out: return err; }