+
+ at = id;
+ while (at && at[0] != '@' && at[0] != '\0' && at++);
+ if (at && at[0] == '@' && at[1] != '\0') {
+ char *dsnode = at + 1;
+ int id_2_at_len = at - id + 1;
+ char *nfs4domain, *new_id;
+ MALLOC(nfs4domain, char*, MAXPATHLEN, M_NAMEI, M_WAITOK);
+ if (nfs4domain) {
+ int domain_len;
+ char *mapped_domain;
+ memset(nfs4domain, 0, MAXPATHLEN);
+ error = kauth_cred_dsnode2nfs4domain(dsnode, nfs4domain);
+ if (!error) {
+ domain_len = strnlen(nfs4domain, MAXPATHLEN);
+ mapped_domain = nfs4domain;
+ } else {
+ domain_len = strnlen(nfs4_domain, MAXPATHLEN);
+ mapped_domain = nfs4_domain;
+ }
+ if (domain_len) {
+ MALLOC(new_id, char*, MAXPATHLEN, M_NAMEI, M_WAITOK);
+ if (new_id) {
+ strlcpy(new_id, id, id_2_at_len + 1);
+ strlcpy(new_id + id_2_at_len, mapped_domain, domain_len + 1);
+ strlcpy(id, new_id, strnlen(new_id, MAXPATHLEN) + 1);
+ *idlen = strnlen(id, MAXPATHLEN);
+ FREE(new_id, M_NAMEI);
+ }
+ }
+ FREE(nfs4domain, M_NAMEI);
+ }
+ } else if (at && at[0] == '\0') {
+ int default_domain_len = strnlen(nfs4_domain, MAXPATHLEN);
+
+ if (default_domain_len && MAXPATHLEN - *idlen > default_domain_len) {
+ at[0] = '@';
+ strlcpy(at + 1, nfs4_domain, default_domain_len + 1);
+ *idlen = strnlen(id, MAXPATHLEN);
+ }
+ }
+
+ if (nfs_idmap_ctrl & NFS_IDMAP_CTRL_LOG_SUCCESSFUL_MAPPINGS)
+ printf("nfs4_guid2id: id after nfs4 domain map: %s[%d].\n", id, *idlen);
+