diff options
| -rw-r--r-- | contrib/mount/mntent.c | 71 | ||||
| -rw-r--r-- | contrib/mount/mntent_compat.h | 6 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 6 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 14 | 
4 files changed, 75 insertions, 22 deletions
diff --git a/contrib/mount/mntent.c b/contrib/mount/mntent.c index 5ab5ac19e84..991e694f1cd 100644 --- a/contrib/mount/mntent.c +++ b/contrib/mount/mntent.c @@ -35,7 +35,7 @@   * SUCH DAMAGE.   */ -#ifdef GF_DARWIN_HOST_OS +#if defined(GF_DARWIN_HOST_OS) || defined(__NetBSD__)  #include <stdlib.h>  #include <string.h>  #include <sys/param.h> @@ -43,6 +43,12 @@  #include <sys/mount.h>  #include "mntent_compat.h" +#ifdef __NetBSD__ +typedef struct statvfs gf_statfs_t; +#else +typedef struct statfs gf_statfs_t; +#endif +  static int pos = -1;  static int mntsize = -1;  static struct mntent _mntent; @@ -102,23 +108,32 @@ flags2opts (int flags)          if (flags & MNT_ASYNC)          res = concatopt(res, "async");  #if !defined(GF_DARWIN_HOST_OS)          if (flags & MNT_NOATIME)        res = concatopt(res, "noatime"); +#if !defined(__NetBSD__)          if (flags & MNT_NOCLUSTERR)     res = concatopt(res, "noclusterr");          if (flags & MNT_NOCLUSTERW)     res = concatopt(res, "noclusterw");          if (flags & MNT_NOSYMFOLLOW)    res = concatopt(res, "nosymfollow");          if (flags & MNT_SUIDDIR)        res = concatopt(res, "suiddir"); -#endif +#endif /* !__NetBSD__ */ +#endif /* !GF_DARWIN_HOS_OS */          return res;  }  static struct mntent * -statfs_to_mntent (struct statfs *mntbuf) +statfs_to_mntent (gf_statfs_t *mntbuf)  {          static char opts_buf[40], *tmp; +        int f_flags;          _mntent.mnt_fsname = mntbuf->f_mntfromname;          _mntent.mnt_dir = mntbuf->f_mntonname;          _mntent.mnt_type = mntbuf->f_fstypename; -        tmp = flags2opts (mntbuf->f_flags); + +#ifdef __NetBSD__ +        f_flags = mntbuf->f_flag; +#else +        f_flags = mntbuf->f_flags; +#endif +        tmp = flags2opts (f_flags);          if (tmp) {                  opts_buf[sizeof(opts_buf)-1] = '\0';                  strncpy (opts_buf, tmp, sizeof(opts_buf)-1); @@ -134,7 +149,10 @@ statfs_to_mntent (struct statfs *mntbuf)  struct mntent *  getmntent (FILE *fp)  { -        struct statfs *mntbuf; +        gf_statfs_t *mntbuf; + +        if (!fp) +                return NULL;          if (pos == -1 || mntsize == -1)                  mntsize = getmntinfo (&mntbuf, MNT_NOWAIT); @@ -148,16 +166,49 @@ getmntent (FILE *fp)          return (statfs_to_mntent (&mntbuf[pos]));  } -/* Dummy functions */ +/* +  Careful using this function ``buffer`` and ``bufsize`` are +  ignored since there is no stream with strings to populate +  them on OSX or NetBSD, if one wishes to populate them then +  perhaps a new function should be written in this source file +  which uses 'getmntinfo()' to stringify the mntent's +*/ + +struct mntent *getmntent_r (FILE *fp, struct mntent *result, +                            char *buffer, int bufsize) +{ +        struct mntent *ment = NULL; + +        if (!fp) +                return NULL; + +        flockfile (fp); +        ment = getmntent (fp); +        memcpy (result, ment, sizeof(*ment)); +        funlockfile (fp); + +        return result; +} +  FILE * -setmntent(const char *filename, const char *type) +setmntent (const char *filename, const char *type)  { -        return (FILE *)0x1; +        FILE *fp = NULL; +#ifdef GF_DARWIN_HOST_OS +        fp = fopen (filename, "w"); +#else +        fp = fopen (filename, type); +#endif +        return fp;  }  int  endmntent (FILE *fp)  { -        return 1; +        if (fp) +                fclose (fp); + +        return 1; /* endmntent() always returns 1 */  } -#endif /* GF_DARWIN_HOST_OS */ + +#endif /* GF_DARWIN_HOST_OS || __NetBSD__ */ diff --git a/contrib/mount/mntent_compat.h b/contrib/mount/mntent_compat.h index 76a75754b1c..3f9cc931266 100644 --- a/contrib/mount/mntent_compat.h +++ b/contrib/mount/mntent_compat.h @@ -11,7 +11,7 @@  #ifndef _MNTENT_H  #define _MNTENT_H -#ifdef GF_DARWIN_HOST_OS +#if defined(GF_DARWIN_HOST_OS) || defined(__NetBSD__)  #include <stdio.h>  struct mntent { @@ -24,6 +24,8 @@ struct mntent {  };  struct mntent *getmntent (FILE *fp); +struct mntent *getmntent_r (FILE *fp, struct mntent *result, +                            char *buffer, int bufsize);  FILE *setmntent (const char *filename, const char *type);  int endmntent(FILE *fp);  char * hasmntopt (const struct mntent *mnt, const char *option); @@ -31,5 +33,5 @@ char * hasmntopt (const struct mntent *mnt, const char *option);  /* Dummy - /etc/mtab has no meaning on OSX platform */  #define _PATH_MOUNTED "/etc/mtab" -#endif /* GF_DARWIN_HOST_OS */ +#endif /* GF_DARWIN_HOST_OS || __NetBSD__ */  #endif /* _MNTENT_H */ diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index e47f85f7ff4..e4aa838acaf 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -1272,7 +1272,7 @@ glusterd_snap_create_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)                          }                          snprintf (key, sizeof (key), -                                  "vol%ld.brick%ld.status", i+1, brick_order); +                                  "vol%"PRId64".brick%"PRId64".status", i+1, brick_order);                          ret = dict_get_int32 (src, key, &brick_online);                          if (ret) {                                  gf_log (this->name, GF_LOG_ERROR, "failed to " @@ -1700,7 +1700,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,                                  goto out;                          } -                        snprintf (key, sizeof (key), "vol%ld.brick%ld.status", +                        snprintf (key, sizeof (key), "vol%"PRId64".brick%"PRId64".status",                                    i, brick_order);                          ret = glusterd_add_brick_status_to_dict (rsp_dict, @@ -3720,7 +3720,7 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict,          GF_ASSERT (snap_vol);          GF_ASSERT (original_brickinfo); -        snprintf (key, sizeof(key), "vol%ld.origin_brickpath%d", +        snprintf (key, sizeof(key), "vol%"PRId64".origin_brickpath%d",                    volcount, brick_count);          ret = dict_set_dynstr_with_alloc (dict, key, original_brickinfo->path);          if (ret) { diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 4615a12fa6f..8d23f4a29b0 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -4329,7 +4329,7 @@ glusterd_volinfo_stop_stale_bricks (glusterd_volinfo_t *new_volinfo,                          ret = glusterd_brick_stop (old_volinfo, old_brickinfo,                                                     _gf_false);                          if (ret) -                                gf_msg ("glusterd", GF_LOG_ERROR, 0,  +                                gf_msg ("glusterd", GF_LOG_ERROR, 0,                                          GD_MSG_BRICK_STOP_FAIL, "Failed to stop"                                          " brick %s:%s", old_brickinfo->hostname,                                          old_brickinfo->path); @@ -10369,7 +10369,7 @@ glusterd_merge_brick_status (dict_t *dst, dict_t *src)          for (index = 0; index < volume_count; index++) {                  ret = snprintf (snapbrckcnt, sizeof(snapbrckcnt) - 1, -                                "snap-vol%ld_brickcount", index+1); +                                "snap-vol%"PRId64"_brickcount", index+1);                  ret = dict_get_int64 (src, snapbrckcnt, &brick_count);                  if (ret) {                          gf_log (this->name, GF_LOG_TRACE, @@ -10381,7 +10381,7 @@ glusterd_merge_brick_status (dict_t *dst, dict_t *src)                  for (j = 0; j < brick_count; j++) {                          /* Fetching data from source dict */                          snprintf (snapbrckord, sizeof(snapbrckord) - 1, -                                  "snap-vol%ld.brick%ld.order", index+1, j); +                                  "snap-vol%"PRId64".brick%"PRId64".order", index+1, j);                          ret = dict_get_int64 (src, snapbrckord, &brick_order);                          if (ret) { @@ -10392,7 +10392,7 @@ glusterd_merge_brick_status (dict_t *dst, dict_t *src)                          }                          snprintf (key, sizeof (key) - 1, -                                  "snap-vol%ld.brick%ld.status", index+1, +                                  "snap-vol%"PRId64".brick%"PRId64".status", index+1,                                    brick_order);                          ret = dict_get_int32 (src, key, &brick_online);                          if (ret) { @@ -12478,7 +12478,7 @@ glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index,                             with replica count 2, quorum is not met if even                             one of its subvolumes is down                          */ -                        snprintf (key, sizeof (key), "%s%ld.brick%ld.status", +                        snprintf (key, sizeof (key), "%s%"PRId64".brick%"PRId64".status",                                    key_prefix, index, i);                          ret = dict_get_int32 (dict, key, &brick_online);                          if (ret || !brick_online) { @@ -12505,7 +12505,7 @@ glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index,                          quorum_met = _gf_false;                          for (i = 0; i < volinfo->replica_count; i++) {                                  snprintf (key, sizeof (key), -                                          "%s%ld.brick%ld.status", key_prefix, +                                          "%s%"PRId64".brick%"PRId64".status", key_prefix,                                            index,                                            (j * volinfo->replica_count) + i);                                  ret = dict_get_int32 (dict, key, &brick_online); @@ -12620,7 +12620,7 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume,          }          for (i = 1; i <= volcount; i++) { -                snprintf (key, sizeof (key), "%s%ld", +                snprintf (key, sizeof (key), "%s%"PRId64,                            snap_volume?"snap-volname":"volname", i);                  ret = dict_get_str (dict, key, &volname);                  if (ret) {  | 
