s3 OneFS: Add vfs implementation for SMB_VFS_GET_REAL_FILE_NAME
authorAravind Srinivasan <aravind.srinivasan@isilon.com>
Fri, 13 Feb 2009 19:07:46 +0000 (11:07 -0800)
committerTim Prouty <tprouty@samba.org>
Fri, 13 Feb 2009 20:59:30 +0000 (12:59 -0800)
source3/modules/vfs_onefs.c

index 860a3ae7d985f95cf3151f46d84d1461b6279845..123139f729a6b1a0c47a4807e6a419425c1b4336 100644 (file)
@@ -205,6 +205,45 @@ static int onefs_statvfs(vfs_handle_struct *handle, const char *path,
         return result;
 }
 
+static int onefs_get_real_filename(vfs_handle_struct *handle, const char *path,
+                                  const char *name, TALLOC_CTX *mem_ctx,
+                                  char **found_name)
+{
+       SMB_STRUCT_STAT sb;
+       struct stat_extra se;
+       int result;
+       char *full_name = NULL;
+
+       ZERO_STRUCT(se);
+       se.se_version = ESTAT_CURRENT_VERSION;
+       se.se_flags = ESTAT_CASE_INSENSITIVE | ESTAT_SYMLINK_NOFOLLOW;
+
+       if (*path != '\0') {
+               if (!(full_name = talloc_asprintf(mem_ctx, "%s/%s", path, name))) {
+                       errno = ENOMEM;
+                       DEBUG(2, ("talloc_asprintf failed\n"));
+                       result = -1;
+                       goto done;
+               }
+       }
+
+       if ((result = estat(full_name ? full_name : name, &sb, &se)) != 0) {
+               DEBUG(2, ("error calling estat: %s\n", strerror(errno)));
+               goto done;
+       }
+
+       *found_name = talloc_strdup(mem_ctx, se.se_realname);
+       if (*found_name == NULL) {
+               errno = ENOMEM;
+               result = -1;
+               goto done;
+       }
+
+done:
+       TALLOC_FREE(full_name);
+       return result;
+}
+
 static int onefs_ntimes(vfs_handle_struct *handle, const char *fname,
                        struct smb_file_time *ft)
 {
@@ -302,6 +341,8 @@ static vfs_op_tuple onefs_ops[] = {
         SMB_VFS_LAYER_OPAQUE},
        {SMB_VFS_OP(onefs_statvfs), SMB_VFS_OP_STATVFS,
         SMB_VFS_LAYER_OPAQUE},
+       {SMB_VFS_OP(onefs_get_real_filename), SMB_VFS_OP_GET_REAL_FILENAME,
+        SMB_VFS_LAYER_OPAQUE},
        {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
 };