Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-8854

liblustre should not define strlcpy or strlcat

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • Lustre 2.11.0
    • None
    • None
    • 3
    • 9223372036854775807

    Description

      Currently, liblustre defines strlcpy and strlcat. This is problematic because some other libraries (which also shouldn't...) do this too, and then we can't link against them. (Notably, linking against SLURM libraries gets you libmunge, which defines them. So you can't link against liblustre and slurm.)

      nm output for a recent-ish version of liblustre (the problem is the symbols marked "T", which are defined):
      nm /lib64/liblustreapi.a | grep strl
      U strlcat
      U strlcpy
      U strlen
      U strlcpy
      U strlen
      U strlen
      0000000000000060 T strlcat
      0000000000000000 T strlcpy
      U strlen

      The solution is a fairly simple trick with #define, which lets us keep using the normal names without defining the symbols:
      -size_t strlcpy(char *tgt, const char *src, size_t tgt_len);
      +size_t ll_strlcpy(char *tgt, const char *src, size_t tgt_len);
      +/* We must not export the strlcpy symbol from liblustre, hence this weirdness *
      +#define strlcpy(a, b, c) ll_strlcpy(a, b, c)

      Here's the resulting nm output:
      nm ./lustre/utils/liblustreapi.a | grep strl
      U ll_strlcat
      U ll_strlcpy
      U strlen
      U ll_strlcpy
      U strlen
      U strlen
      0000000000000000 T ll_strlcat
      0000000000000090 T ll_strlcpy
      U strlen

      Patch coming shortly.

      Attachments

        Issue Links

          Activity

            People

              paf Patrick Farrell
              paf Patrick Farrell
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: