/* * nfs4_set_fattr4_attr translates a vattr attribute into a fattr4 attribute * for use by nfs4_setattr. For setting atime or mtime use the entry for * time_XX_set rather than time_XX (XX == access or modify). * Return TRUE if arg was set (even if there was an error) and FALSE * otherwise. Also set error code. The caller should not continue * if error was set, whether or not the return is TRUE or FALSE. Returning * FALSE does not mean there was an error, only that the attr was not set. */ static bool_t nfs4_set_fattr4_attr(vattr_t *vap, vsecattr_t *vsap, struct nfs4_ntov_map *ntovp, union nfs4_attr_u *nap, int flags, int *errorp) { bool_t retval = TRUE; /* * Special case for time set: if setting the * time, ignore entry for time access/modify * and instead use that of time access/modify set. */ *errorp = 0; /* * Bit matches the mask */ switch (ntovp->vbit & vap->va_mask) { case AT_SIZE: nap->size = vap->va_size; break; case AT_MODE: nap->mode = vap->va_mode; break; case AT_UID: /* * if no mapping, uid will be mapped to a number string, * e.g. "12345" */ if (*errorp = nfs_idmap_uid_str(vap->va_uid, &nap->owner, FALSE)) retval = FALSE; break; case AT_GID: /* * if no mapping, gid will be mapped to a number string, * e.g. "12345" */ if (*errorp = nfs_idmap_gid_str(vap->va_gid, &nap->owner_group, FALSE)) retval = FALSE; break; case AT_ATIME: if ((ntovp->nval != FATTR4_TIME_ACCESS_SET) || (*errorp = timestruc_to_settime4(&vap->va_atime, &nap->time_access_set, flags))) { /* FATTR4_TIME_ACCESS - not used for verify */ retval = FALSE; } break; case AT_MTIME: if ((ntovp->nval != FATTR4_TIME_MODIFY_SET) || (*errorp = timestruc_to_settime4(&vap->va_mtime, &nap->time_modify_set, flags))) { /* FATTR4_TIME_MODIFY - not used for verify */ retval = FALSE; } break; default: /* * If the ntovp->vbit == 0 this is most likely the ACL. */ if (ntovp->vbit == 0 && ntovp->fbit == FATTR4_ACL_MASK) { ASSERT(vsap->vsa_mask == (VSA_ACE | VSA_ACECNT)); nap->acl.fattr4_acl_len = vsap->vsa_aclcnt; nap->acl.fattr4_acl_val = vsap->vsa_aclentp; } else retval = FALSE; } return (retval); }
/* ARGSUSED */ static bool_t nfs4_ver_fattr4_attr(vattr_t *vap, struct nfs4_ntov_map *ntovp, union nfs4_attr_u *nap, int flags, int *errorp) { bool_t retval = TRUE; /* * Special case for time set: if setting the * time, ignore entry for time access/modify set (setattr) * and instead use that of time access/modify. */ *errorp = 0; /* * Bit matches the mask */ switch (ntovp->vbit & vap->va_mask) { case AT_SIZE: nap->size = vap->va_size; break; case AT_MODE: nap->mode = vap->va_mode; break; case AT_UID: /* * if no mapping, uid could be mapped to a numeric string, * e.g. 12345->"12345" */ if (*errorp = nfs_idmap_uid_str(vap->va_uid, &nap->owner, FALSE)) retval = FALSE; break; case AT_GID: /* * if no mapping, gid will be mapped to a number string, * e.g. "12345" */ if (*errorp = nfs_idmap_gid_str(vap->va_gid, &nap->owner_group, FALSE)) retval = FALSE; break; case AT_ATIME: if ((ntovp->nval != FATTR4_TIME_ACCESS) || (*errorp = nfs4_time_vton(&vap->va_ctime, &nap->time_access))) { /* * either asked for FATTR4_TIME_ACCESS_SET - * not used for setattr * or system time invalid for otw transfers */ retval = FALSE; } break; case AT_MTIME: if ((ntovp->nval != FATTR4_TIME_MODIFY) || (*errorp = nfs4_time_vton(&vap->va_mtime, &nap->time_modify))) { /* * either asked for FATTR4_TIME_MODIFY_SET - * not used for setattr * or system time invalid for otw transfers */ retval = FALSE; } break; case AT_CTIME: if (*errorp = nfs4_time_vton(&vap->va_ctime, &nap->time_metadata)) { /* * system time invalid for otw transfers */ retval = FALSE; } break; default: retval = FALSE; } return (retval); }
int do_test(char *input_buf) { int argc, seal_argc; char **argv, **argv_array; char *cmd; int i, bufsize = 512; char str_buf[512]; utf8string str; uid_t uid; gid_t gid; int stat; argv = 0; if (parse_input_line(input_buf, &argc, &argv) == 0) { printf(gettext("\n")); return (1); } /* * remember argv_array address, which is memory calloc'd by * parse_input_line, so it can be free'd at the end of the loop. */ argv_array = argv; if (argc < 1) { usage(); free(argv_array); return (0); } cmd = argv[0]; if (strcmp(cmd, "str2uid") == 0) { if (argc < 2) { usage(); free(argv_array); return (0); } str.utf8string_val = argv[1]; str.utf8string_len = strlen(argv[1]); stat = nfs_idmap_str_uid(&str, &uid); printf(gettext("%d stat=%s \n"), uid, mapstat(stat)); } else if (strcmp(cmd, "str2gid") == 0) { if (argc < 2) { usage(); free(argv_array); return (0); } str.utf8string_val = argv[1]; str.utf8string_len = strlen(argv[1]); stat = nfs_idmap_str_gid(&str, &gid); printf(gettext("%d stat=%s \n"), gid, mapstat(stat)); } else if (strcmp(cmd, "uid2str") == 0) { if (argc < 2) { usage(); free(argv_array); return (0); } uid = atoi(argv[1]); bzero(str_buf, bufsize); str.utf8string_val = str_buf; stat = nfs_idmap_uid_str(uid, &str); printf(gettext("%s stat=%s\n"), str.utf8string_val, mapstat(stat)); } else if (strcmp(cmd, "gid2str") == 0) { if (argc < 2) { usage(); free(argv_array); return (0); } gid = atoi(argv[1]); bzero(str_buf, bufsize); str.utf8string_val = str_buf; stat = nfs_idmap_gid_str(gid, &str); printf(gettext("%s stat=%s\n"), str.utf8string_val, mapstat(stat)); } else if (strcmp(cmd, "echo") == 0) { for (i = 1; i < argc; i++) printf("%s ", argv[i]); printf("\n"); } else if (strcmp(cmd, "exit") == 0 || strcmp(cmd, "quit") == 0) { printf(gettext("\n")); free(argv_array); return (1); } else usage(); /* free argv array */ free(argv_array); return (0); }