800
801 xmlFree(name);
802 xmlFree(set);
803 xmlFree(iptype);
804
805 if (ret != 0)
806 return (-1);
807 }
808
809 return (0);
810 }
811
812 static int
813 i_brand_platform_iter_mounts(struct brand_handle *bhp, const char *zonename,
814 const char *zonepath, int (*func)(void *, const char *, const char *,
815 const char *, const char *), void *data, const xmlChar *mount_type)
816 {
817 xmlNodePtr node;
818 xmlChar *special, *dir, *type, *opt;
819 char special_exp[MAXPATHLEN];
820 char opt_exp[MAXPATHLEN];
821 int ret;
822
823 if ((node = xmlDocGetRootElement(bhp->bh_platform)) == NULL)
824 return (-1);
825
826 for (node = node->xmlChildrenNode; node != NULL; node = node->next) {
827
828 if (xmlStrcmp(node->name, mount_type) != 0)
829 continue;
830
831 special = xmlGetProp(node, DTD_ATTR_SPECIAL);
832 dir = xmlGetProp(node, DTD_ATTR_DIRECTORY);
833 type = xmlGetProp(node, DTD_ATTR_TYPE);
834 opt = xmlGetProp(node, DTD_ATTR_OPT);
835 if ((special == NULL) || (dir == NULL) || (type == NULL) ||
836 (opt == NULL)) {
837 ret = -1;
838 goto next;
839 }
840
841 /* Substitute token values as needed. */
842 if ((ret = i_substitute_tokens((char *)special,
843 special_exp, sizeof (special_exp),
844 zonename, zonepath, NULL, NULL)) != 0)
845 goto next;
846
847 /* opt might not be defined */
848 if (strlen((const char *)opt) == 0) {
849 xmlFree(opt);
850 opt = NULL;
851 } else {
852 if ((ret = i_substitute_tokens((char *)opt,
853 opt_exp, sizeof (opt_exp),
854 zonename, zonepath, NULL, NULL)) != 0)
855 goto next;
856 }
857
858 ret = func(data, (char *)special_exp, (char *)dir,
859 (char *)type, ((opt != NULL) ? opt_exp : NULL));
860
861 next:
862 if (special != NULL)
863 xmlFree(special);
864 if (dir != NULL)
865 xmlFree(dir);
866 if (type != NULL)
867 xmlFree(type);
868 if (opt != NULL)
869 xmlFree(opt);
870 if (ret != 0)
871 return (-1);
872 }
873 return (0);
874 }
875
876
877 /*
878 * Iterate over global platform filesystems
|
800
801 xmlFree(name);
802 xmlFree(set);
803 xmlFree(iptype);
804
805 if (ret != 0)
806 return (-1);
807 }
808
809 return (0);
810 }
811
812 static int
813 i_brand_platform_iter_mounts(struct brand_handle *bhp, const char *zonename,
814 const char *zonepath, int (*func)(void *, const char *, const char *,
815 const char *, const char *), void *data, const xmlChar *mount_type)
816 {
817 xmlNodePtr node;
818 xmlChar *special, *dir, *type, *opt;
819 char special_exp[MAXPATHLEN];
820 char dir_exp[MAXPATHLEN];
821 char opt_exp[MAXPATHLEN];
822 int ret;
823
824 if ((node = xmlDocGetRootElement(bhp->bh_platform)) == NULL)
825 return (-1);
826
827 for (node = node->xmlChildrenNode; node != NULL; node = node->next) {
828
829 if (xmlStrcmp(node->name, mount_type) != 0)
830 continue;
831
832 special = xmlGetProp(node, DTD_ATTR_SPECIAL);
833 dir = xmlGetProp(node, DTD_ATTR_DIRECTORY);
834 type = xmlGetProp(node, DTD_ATTR_TYPE);
835 opt = xmlGetProp(node, DTD_ATTR_OPT);
836 if ((special == NULL) || (dir == NULL) || (type == NULL) ||
837 (opt == NULL)) {
838 ret = -1;
839 goto next;
840 }
841
842 /* Substitute token values as needed. */
843 if ((ret = i_substitute_tokens((char *)special,
844 special_exp, sizeof (special_exp),
845 zonename, zonepath, NULL, NULL)) != 0)
846 goto next;
847 if ((ret = i_substitute_tokens((char *)dir,
848 dir_exp, sizeof (dir_exp),
849 zonename, zonepath, NULL, NULL)) != 0)
850 goto next;
851
852 /* opt might not be defined */
853 if (strlen((const char *)opt) == 0) {
854 xmlFree(opt);
855 opt = NULL;
856 } else {
857 if ((ret = i_substitute_tokens((char *)opt,
858 opt_exp, sizeof (opt_exp),
859 zonename, zonepath, NULL, NULL)) != 0)
860 goto next;
861 }
862
863 ret = func(data, (char *)special_exp, (char *)dir_exp,
864 (char *)type, ((opt != NULL) ? opt_exp : NULL));
865
866 next:
867 if (special != NULL)
868 xmlFree(special);
869 if (dir != NULL)
870 xmlFree(dir);
871 if (type != NULL)
872 xmlFree(type);
873 if (opt != NULL)
874 xmlFree(opt);
875 if (ret != 0)
876 return (-1);
877 }
878 return (0);
879 }
880
881
882 /*
883 * Iterate over global platform filesystems
|