Lines Matching +full:os +full:- +full:manifest +full:- +full:offset

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
53 zfs_objset_t *os;
55 /* Offset table for system attributes, indexed by a zpl_attr_t. */
62 * The order of the attributes doesn't matter, this is simply the one hard-coded
123 * layout and just hard-codes attribute offsets.
177 return (strcmp(cur->name, ".") == 0);
183 return (cur->type == S_IFREG || cur->type == S_IFDIR ||
184 cur->type == S_IFLNK);
188 * Visit each node in a directory hierarchy, in pre-order depth-first order.
193 assert(root->type == S_IFDIR);
195 for (fsnode *cur = root; cur != NULL; cur = cur->next) {
198 inode_type(cur->type), cur->path, cur->name);
203 if (cur->type == S_IFDIR && cur->child != NULL)
204 fsnode_foreach(cur->child, cb, arg);
214 switch (cur->type) {
228 dir = SLIST_FIRST(&arg->dirs);
229 zap_add_uint64(dir->zap, cur->name, ZFS_DIRENT_MAKE(type, dnid));
236 assert(ind < fs->sacnt);
237 assert(fs->saoffs[ind] != 0xffff);
239 memcpy(attrbuf + fs->saoffs[ind], val, fs->satab[ind].size);
240 *szp += fs->satab[ind].size;
247 assert(ind < fs->sacnt);
248 assert(fs->saoffs[ind] != 0xffff);
249 assert(fs->satab[ind].size == 0);
251 memcpy(attrbuf + fs->saoffs[ind] + varoff, val, valsz);
261 * dealing with an mtree manifest, so both mechanisms are implemented.
267 if (cur->contents != NULL) {
271 n = strlcpy(path, cur->contents, sz);
273 } else if (cur->root == NULL) {
276 *dirfdp = SLIST_FIRST(&arg->dirs)->dirfd;
277 n = strlcpy(path, cur->name, sz);
284 cur->root, cur->path, cur->name);
322 if (cur->symlink != NULL) {
325 n = strlcpy(buf, cur->symlink, bufsz);
332 n = readlinkat(fd, path, buf, bufsz - 1);
333 if (n == -1)
334 err(1, "readlinkat(%s)", cur->name);
345 assert(ind < fs->sacnt);
346 assert(fs->saoffs[ind] != 0xffff);
347 assert(fs->satab[ind].size == sizeof(timebuf));
349 timebuf[0] = ts->tv_sec;
350 timebuf[1] = ts->tv_nsec;
368 assert(dnode->dn_bonustype == DMU_OT_SA);
369 assert(dnode->dn_nblkptr == 1);
371 fs = arg->fs;
372 sb = &cur->inode->st;
374 switch (cur->type) {
377 links = cur->inode->nlink;
378 objsize = sb->st_size;
379 parent = SLIST_FIRST(&arg->dirs)->objid;
391 for (fsnode *c = fsnode_isroot(cur) ? cur->next : cur->child;
392 c != NULL; c = c->next) {
393 switch (c->type) {
405 parent = SLIST_EMPTY(&arg->dirs) ?
406 arg->rootdirid : SLIST_FIRST(&arg->dirs)->objid;
414 parent = SLIST_FIRST(&arg->dirs)->objid;
424 gid = sb->st_gid;
425 mode = sb->st_mode;
426 uid = sb->st_uid;
465 /* At most one variable-length attribute. */
469 /* At most five variable-length attributes. */
477 sahdr->sa_magic = SA_MAGIC;
478 SA_HDR_LAYOUT_INFO_ENCODE(sahdr->sa_layout_info, layout, hdrsz);
497 fs_populate_time(fs, attrbuf, &sb->st_mtim, ZPL_ATIME, &bonussz);
498 fs_populate_time(fs, attrbuf, &sb->st_ctim, ZPL_CTIME, &bonussz);
499 fs_populate_time(fs, attrbuf, &sb->st_mtim, ZPL_MTIME, &bonussz);
502 fs_populate_time(fs, attrbuf, &sb->st_ctim, ZPL_CRTIME, &bonussz);
504 fs_populate_time(fs, attrbuf, &sb->st_birthtim, ZPL_CRTIME, &bonussz);
509 sahdr->sa_lengths[0] = sizeof(aces);
511 if (cur->type == S_IFLNK) {
516 sahdr->sa_lengths[0], ZPL_SYMLINK, &bonussz);
517 sahdr->sa_lengths[1] = (uint16_t)objsize;
520 dnode->dn_bonuslen = bonussz;
536 assert(cur->type == S_IFREG);
537 assert((cur->inode->flags & FI_ROOT) == 0);
539 zfs = arg->zfs;
541 assert(cur->inode->ino != 0);
542 if ((cur->inode->flags & FI_ALLOCATED) != 0) {
546 * XXX-MJ need to check whether it crosses datasets, add a test
549 fs_populate_dirent(arg, cur, cur->inode->ino);
553 dnode = objset_dnode_bonus_alloc(arg->fs->os,
555 cur->inode->ino = dnid;
556 cur->inode->flags |= FI_ALLOCATED;
560 buf = zfs->filebuf;
561 bufsz = sizeof(zfs->filebuf);
562 size = cur->inode->st.st_size;
563 c = dnode_cursor_init(zfs, arg->fs->os, dnode, size, 0);
571 nbytes = MIN(size - foff, (off_t)bufsz);
575 err(1, "reading from '%s'", cur->name);
578 cur->name);
583 memset(buf + nbytes, 0, bufsz - nbytes);
586 loc = objset_space_alloc(zfs, arg->fs->os, &reqbytes);
601 zfs_objset_t *os;
605 assert(cur->type == S_IFDIR);
606 assert((cur->inode->flags & FI_ALLOCATED) == 0);
608 os = arg->fs->os;
610 dnode = objset_dnode_bonus_alloc(os, DMU_OT_DIRECTORY_CONTENTS,
616 if (!SLIST_EMPTY(&arg->dirs)) {
625 arg->rootdirid = dnid;
626 dirfd = arg->rootdirfd;
627 arg->rootdirfd = -1;
639 if ((cur->inode->flags & FI_ROOT) == 0) {
643 dir->dirfd = dirfd;
644 dir->objid = dnid;
645 dir->zap = zap_alloc(os, dnode);
646 SLIST_INSERT_HEAD(&arg->dirs, dir, next);
648 zap_write(arg->zfs, zap_alloc(os, dnode));
649 fs_build_one(arg->zfs, cur->inode->param, cur->child, dirfd);
659 assert(cur->type == S_IFLNK);
660 assert((cur->inode->flags & (FI_ALLOCATED | FI_ROOT)) == 0);
662 dnode = objset_dnode_bonus_alloc(arg->fs->os,
673 for (cur = cur->next; cur != NULL; cur = cur->next) {
688 switch (cur->type) {
704 ret = (cur->inode->flags & FI_ROOT) != 0 ? 0 : 1;
707 (cur->child == NULL || (cur->inode->flags & FI_ROOT) != 0)) {
715 dir = SLIST_FIRST(&arg->dirs);
716 SLIST_REMOVE_HEAD(&arg->dirs, next);
717 zap_write(arg->zfs, dir->zap);
718 if (dir->dirfd != -1)
719 eclose(dir->dirfd);
721 cur = cur->parent;
723 (cur->inode->flags & FI_ROOT) == 0);
753 zfs_objset_t *os;
756 uint16_t offset;
758 os = fs->os;
761 * The on-disk tables are stored in two ZAP objects, the registry object
769 saobj = objset_dnode_alloc(os, DMU_OT_SA_MASTER_NODE, &saobjid);
770 salobj = objset_dnode_alloc(os, DMU_OT_SA_ATTR_LAYOUTS, &salobjid);
771 sarobj = objset_dnode_alloc(os, DMU_OT_SA_ATTR_REGISTRATION, &sarobjid);
773 sarzap = zap_alloc(os, sarobj);
780 SA_ATTR_ENCODE(attr, (uint64_t)i, sa->size, sa->bs);
781 zap_add_uint64(sarzap, sa->name, attr);
787 * layouts for use by the ZPL, one for non-symlinks and one for
791 salzap = zap_alloc(os, salobj);
792 assert(zpl_attr_layout[nitems(zpl_attr_layout) - 1] == ZPL_SYMLINK);
794 zpl_attr_layout, nitems(zpl_attr_layout) - 1);
799 sazap = zap_alloc(os, saobj);
809 * Build the offset table used when setting file attributes. File
811 * provides the buffer offset of attributes referenced by the layout
814 fs->sacnt = nitems(zpl_attrs);
815 fs->saoffs = ecalloc(fs->sacnt, sizeof(*fs->saoffs));
816 for (size_t i = 0; i < fs->sacnt; i++)
817 fs->saoffs[i] = 0xffff;
818 offset = 0;
822 assert(zpl_attr_layout[i] < fs->sacnt);
824 fs->saoffs[zpl_attr_layout[i]] = offset;
826 offset += size;
828 fs->satab = zpl_attrs;
852 if (zfs->bootfs != NULL && strcmp(zfs->bootfs,
854 zap_add_uint64(zfs->poolprops, "bootfs",
865 if (strcmp(mountpoint, zfs->rootpath) != 0) {
866 mountpoint += strlen(zfs->rootpath);
881 for (; cur != NULL && strcmp(cur->name, name) != 0;
882 cur = cur->next)
890 if (cur->type != S_IFDIR) {
896 cur = cur->child;
901 assert(cur->type == S_IFDIR);
908 assert((cur->inode->flags & FI_ROOT) == 0);
910 cur->inode->flags |= FI_ROOT;
911 assert(cur->inode->param == NULL);
912 cur->inode->param = dsldir;
924 if (cur->type == S_IFDIR && fsnode_isroot(cur))
927 if (cur->inode->ino == 0) {
928 cur->inode->ino = ++(*countp);
929 cur->inode->nlink = 1;
931 cur->inode->nlink++;
934 return ((cur->inode->flags & FI_ROOT) != 0 ? 0 : 1);
939 * - create an object set for the dataset,
940 * - add required metadata (SA tables, property definitions, etc.) to that
942 * - optionally populate the object set with file objects, using "root" as the
954 zfs_objset_t *os;
968 assert(dirfd == -1);
971 root->inode = ecalloc(1, sizeof(*root->inode));
972 root->name = estrdup(".");
973 root->type = S_IFDIR;
975 stp = &root->inode->st;
976 stp->st_uid = 0;
977 stp->st_gid = 0;
978 stp->st_mode = S_IFDIR | 0755;
980 assert(root->type == S_IFDIR);
986 os = objset_alloc(zfs, DMU_OST_ZFS);
987 masterobj = objset_dnode_alloc(os, DMU_OT_MASTER_NODE, &moid);
991 fs.os = os;
1024 deleteq = objset_dnode_alloc(os, DMU_OT_UNLINKED_SET, &deleteqid);
1025 zap_write(zfs, zap_alloc(os, deleteq));
1032 masterzap = zap_alloc(os, masterobj);
1048 dsl_dir_dataset_write(zfs, os, dsldir);
1051 free(root->inode);
1052 free(root->name);
1066 fs_build_one(zfs, dsldir, NULL, -1);
1080 dsl_dir_foreach(zfs, zfs->rootdsldir, fs_layout_one, root);
1085 if (zfs->bootfs != NULL && !zap_entry_exists(zfs->poolprops, "bootfs"))
1087 zfs->bootfs);
1099 fs_build_one(zfs, root->inode->param, root, dirfd);
1106 dsl_dir_foreach(zfs, zfs->rootdsldir, fs_build_unmounted, NULL);