Whamcloud - gitweb
Branch: HEAD
[fs/lustre-release.git] / lustre / liblustre / tests / test_common.c
index a87f0fa..a216d07 100644 (file)
@@ -313,3 +313,16 @@ void t_ls(int fd, char *buf, int size)
                EXIT(-1);
        }
 }
+
+char *safe_strncpy(char *dst, char *src, int max_size)
+{
+       int src_size;
+       src_size=strlen(src);
+       if (src_size >= max_size) {
+        src_size=max_size-1;
+       }
+       memcpy(dst, src, src_size);
+       dst[src_size]=0;
+
+       return(dst);
+}