+ inode_type = 'l';
+
+ /* Use the reported file size to allocate a buffer large enough to read
+ * the symlink. Allocate slightly more space, so that we ask for more
+ * bytes than we expect and so check for truncation. */
+ buf = new char[stat_buf.st_size + 2];
+ len = readlink(path.c_str(), buf, stat_buf.st_size + 1);
+ if (len < 0) {
+ printf("error reading symlink: %m\n");
+ } else if (len <= stat_buf.st_size) {
+ buf[len] = '\0';
+ printf(" contents=%s\n", buf);
+ } else if (len > stat_buf.st_size) {
+ printf("error reading symlink: name truncated\n");
+ }
+
+ file_info["contents"] = buf;
+
+ delete[] buf;