Ejemplo n.º 1
0
/*
 * parse for option path overrides
 */
static boolean_t
hasoptionalpath(char *options, char *opt, char *buf, size_t buflen)
{
	char tmpopts[MNT_LINE_MAX];
	char *f, *opts = tmpopts;

	if (options == NULL || options[0] == '\0')
		return (B_FALSE);

	(void) strcpy(opts, options);
	f = mntopt(&opts);
	for (; *f; f = mntopt(&opts)) {
		if (strncmp(opt, f, strlen(opt)) == 0) {
			f += strlen(opt);
			/* strip any quoting */
			if (*f == '\"') {
				++f;
				f[strlen(f) - 1] = '\0';
			}
			(void) strlcpy(buf, f, buflen);
			return (B_TRUE);
		}
	}
	return (B_FALSE);
}
Ejemplo n.º 2
0
char *
hasmntopt(struct mnttab *mnt, char *opt)
{
        char tmpopts[MNT_LINE_MAX];
        char *f, *opts = tmpopts;

        if (mnt->mnt_mntopts == NULL)
                return (NULL);
        (void) strcpy(opts, mnt->mnt_mntopts);
        f = mntopt(&opts);
        for (; *f; f = mntopt(&opts)) {
                if (strncmp(opt, f, strlen(opt)) == 0)
                        return (f - tmpopts + mnt->mnt_mntopts);
        }
        return (NULL);
}
Ejemplo n.º 3
0
char *
hasmntopt(struct mntent *mnt, char *opt)
{
	char *f, *opts;
	static char *tmpopts;

	if (tmpopts == 0) {
		tmpopts = (char *)calloc(256, sizeof (char));
		if (tmpopts == 0)
			return (0);
	}
	strcpy(tmpopts, mnt->mnt_opts);
	opts = tmpopts;
	f = mntopt(&opts);
	for (; *f; f = mntopt(&opts)) {
		if (strncmp(opt, f, strlen(opt)) == 0)
			return (f - tmpopts + mnt->mnt_opts);
	} 
	return (NULL);
}
Ejemplo n.º 4
0
    char*
    hasmntopt(struct mnttab *mnt, char *opt)
    {
        char tmpopts[MNT_LINE_MAX];
        char *f, *opts = tmpopts;
        size_t	len;

        if (mnt->mnt_mntopts == NULL)
            return (NULL);
        (void) strcpy(opts, mnt->mnt_mntopts);
        len = strlen(opt);
        f = mntopt(&opts);
        for (; *f; f = mntopt(&opts)) {
            /*
             * Match only complete substrings. For options
             * which use a delimiter (such as 'retry=3'),
             * treat the delimiter as the end of the substring.
             */
            if (strncmp(opt, f, len) == 0 &&
                    (f[len] == '\0' || !isalnum(f[len])))
                return (f - tmpopts + mnt->mnt_mntopts);
        }
        return (NULL);
    }
Ejemplo n.º 5
0
char * __hasmntopt_sun (struct mnttab *mt, char *opt)
{
  /* We make a copy of mnt_mntopts since we modify it.  */
  char buf[MNT_LINE_MAX + 1];
  strncpy (buf, mt->mnt_mntopts, sizeof (buf))[MNT_LINE_MAX] = '\0';

  char *opts = buf;
  char *optp;
  size_t len = strlen (opt);
  while (*(optp = mntopt (&opts)))
    {
      /* Check if opt matched, taking into account delimiters (e.g. '=').  */
      if (strncmp (optp, opt, len) == 0 && !isalnum (optp[len]))
        return mt->mnt_mntopts + (optp - buf);
    }

  return NULL;
}