- /* Write small symlink to inode body as we need to maintain correct
- * on-disk symlinks for ldiskfs.
- */
- if (S_ISLNK(dt->do_lu.lo_header->loh_attr) &&
- (buf->lb_len < sizeof(LDISKFS_I(inode)->i_data)))
- result = osd_ldiskfs_writelink(inode, buf->lb_buf, buf->lb_len);
- else
- result = osd_ldiskfs_write_record(inode, buf->lb_buf,
- buf->lb_len, pos,
- oh->ot_handle);
+ /* Write small symlink to inode body as we need to maintain correct
+ * on-disk symlinks for ldiskfs.
+ * Note: the buf->lb_buf contains a NUL terminator while buf->lb_len
+ * does not count it in.
+ */
+ is_link = S_ISLNK(dt->do_lu.lo_header->loh_attr);
+ if (is_link && (buf->lb_len < sizeof(LDISKFS_I(inode)->i_data)))
+ result = osd_ldiskfs_writelink(inode, buf->lb_buf, buf->lb_len);
+ else
+ result = osd_ldiskfs_write_record(inode, buf->lb_buf,
+ buf->lb_len, is_link, pos,
+ oh->ot_handle);