ReactOS 0.4.15-dev-8417-gb6b82fe
getattr.c File Reference
#include <windows.h>
#include <stdio.h>
#include <strsafe.h>
#include "nfs41_ops.h"
#include "name_cache.h"
#include "upcall.h"
#include "daemon_debug.h"
Include dependency graph for getattr.c:

Go to the source code of this file.

Functions

int nfs41_cached_getattr (IN nfs41_session *session, IN nfs41_path_fh *file, OUT nfs41_file_info *info)
 
static int parse_getattr (unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
 
static int handle_getattr (nfs41_upcall *upcall)
 
static int marshall_getattr (unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
 

Variables

const nfs41_upcall_op nfs41_op_getattr
 

Function Documentation

◆ handle_getattr()

static int handle_getattr ( nfs41_upcall upcall)
static

Definition at line 76 of file getattr.c.

77{
78 int status;
79 getattr_upcall_args *args = &upcall->args.getattr;
80 nfs41_open_state *state = upcall->state_ref;
81 nfs41_file_info info = { 0 };
82
83 status = nfs41_cached_getattr(state->session, &state->file, &info);
84 if (status) {
85 eprintf("nfs41_cached_getattr() failed with %d\n", status);
86 goto out;
87 }
88
89 if (info.type == NF4LNK) {
91 int target_status = nfs41_symlink_follow(upcall->root_ref,
92 state->session, &state->file, &target_info);
93 if (target_status == NO_ERROR && target_info.type == NF4DIR)
94 info.symlink_dir = TRUE;
95 }
96
97 switch (args->query_class) {
99 nfs_to_basic_info(&info, &args->basic_info);
100 args->ctime = info.change;
101 break;
103 nfs_to_standard_info(&info, &args->std_info);
104 break;
106 args->tag_info.FileAttributes = nfs_file_info_to_attributes(&info);
107 args->tag_info.ReparseTag = info.type == NF4LNK ?
109 break;
111 args->intr_info.IndexNumber.QuadPart = info.fileid;
112 break;
114 nfs_to_network_openinfo(&info, &args->network_info);
115 break;
116 default:
117 eprintf("unhandled file query class %d\n", args->query_class);
119 break;
120 }
121out:
122 return status;
123}
static int state
Definition: maze.c:121
void nfs_to_standard_info(IN const nfs41_file_info *info, OUT PFILE_STANDARD_INFO std_out)
Definition: util.c:175
ULONG nfs_file_info_to_attributes(IN const nfs41_file_info *info)
Definition: util.c:137
void nfs_to_network_openinfo(IN const nfs41_file_info *info, OUT PFILE_NETWORK_OPEN_INFORMATION net_out)
Definition: util.c:189
void nfs_to_basic_info(IN const nfs41_file_info *info, OUT PFILE_BASIC_INFO basic_out)
Definition: util.c:163
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
#define NO_ERROR
Definition: dderror.h:5
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
@ FileInternalInformation
Definition: from_kernel.h:67
@ FileAttributeTagInformation
Definition: from_kernel.h:96
@ FileNetworkOpenInformation
Definition: from_kernel.h:95
@ FileBasicInformation
Definition: from_kernel.h:65
int nfs41_cached_getattr(IN nfs41_session *session, IN nfs41_path_fh *file, OUT nfs41_file_info *info)
Definition: getattr.c:32
@ NF4DIR
Definition: nfs41_const.h:295
@ NF4LNK
Definition: nfs41_const.h:298
nfs41_updowncall_list upcall
Definition: nfs41_driver.c:273
int nfs41_symlink_follow(IN nfs41_root *root, IN nfs41_session *session, IN nfs41_path_fh *symlink, OUT nfs41_file_info *info)
Definition: symlink.c:146
#define FileStandardInformation
Definition: propsheet.cpp:61
static FILE * out
Definition: regtests2xml.c:44
Definition: match.c:390
Definition: ps.c:97
enum shader_type type
Definition: compiler.c:659
#define IO_REPARSE_TAG_SYMLINK
Definition: iotypes.h:7240

◆ marshall_getattr()

static int marshall_getattr ( unsigned char buffer,
uint32_t length,
nfs41_upcall upcall 
)
static

Definition at line 125 of file getattr.c.

126{
127 int status;
128 getattr_upcall_args *args = &upcall->args.getattr;
129 uint32_t info_len;
130
131 switch (args->query_class) {
133 info_len = sizeof(args->basic_info);
134 status = safe_write(&buffer, length, &info_len, sizeof(info_len));
135 if (status) goto out;
136 status = safe_write(&buffer, length, &args->basic_info, info_len);
137 if (status) goto out;
138 break;
140 info_len = sizeof(args->std_info);
141 status = safe_write(&buffer, length, &info_len, sizeof(info_len));
142 if (status) goto out;
143 status = safe_write(&buffer, length, &args->std_info, info_len);
144 if (status) goto out;
145 break;
147 info_len = sizeof(args->tag_info);
148 status = safe_write(&buffer, length, &info_len, sizeof(info_len));
149 if (status) goto out;
150 status = safe_write(&buffer, length, &args->tag_info, info_len);
151 if (status) goto out;
152 break;
154 info_len = sizeof(args->intr_info);
155 status = safe_write(&buffer, length, &info_len, sizeof(info_len));
156 if (status) goto out;
157 status = safe_write(&buffer, length, &args->intr_info, info_len);
158 if (status) goto out;
159 break;
161 info_len = sizeof(args->network_info);
162 status = safe_write(&buffer, length, &info_len, sizeof(info_len));
163 if (status) goto out;
164 status = safe_write(&buffer, length, &args->network_info, info_len);
165 if (status) goto out;
166 break;
167 default:
168 eprintf("unknown file query class %d\n", args->query_class);
169 status = 103;
170 goto out;
171 }
172 status = safe_write(&buffer, length, &args->ctime, sizeof(args->ctime));
173 if (status) goto out;
174 dprintf(1, "NFS41_FILE_QUERY: downcall changattr=%llu\n", args->ctime);
175out:
176 return status;
177}
int safe_write(unsigned char **pos, uint32_t *remaining, void *src, uint32_t src_len)
Definition: util.c:44
UINT32 uint32_t
Definition: types.h:75
GLuint buffer
Definition: glext.h:5915
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define dprintf
Definition: regdump.c:33

◆ nfs41_cached_getattr()

int nfs41_cached_getattr ( IN nfs41_session session,
IN nfs41_path_fh file,
OUT nfs41_file_info info 
)

Definition at line 32 of file getattr.c.

36{
37 int status;
38
39 /* first look for cached attributes */
41 file->fh.fileid, info);
42
43 if (status) {
44 /* fetch attributes from the server */
45 bitmap4 attr_request;
46 nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
47
48 status = nfs41_getattr(session, file, &attr_request, info);
49 if (status) {
50 eprintf("nfs41_getattr() failed with %s\n",
53 }
54 }
55 return status;
56}
int nfs_to_windows_error(int status, int default_error)
Definition: util.c:235
const char * nfs_error_string(int status)
Definition: daemon_debug.c:370
int nfs41_attr_cache_lookup(IN struct nfs41_name_cache *cache, IN uint64_t fileid, OUT nfs41_file_info *info_out)
Definition: name_cache.c:859
static __inline struct nfs41_name_cache * session_name_cache(IN nfs41_session *session)
Definition: name_cache.h:34
static __inline void nfs41_superblock_getattr_mask(IN const nfs41_superblock *superblock, OUT bitmap4 *attrs)
Definition: nfs41.h:448
int nfs41_getattr(IN nfs41_session *session, IN OPTIONAL nfs41_path_fh *file, IN bitmap4 *attr_request, OUT nfs41_file_info *info)
Definition: nfs41_ops.c:1063
Definition: fci.c:127
#define ERROR_BAD_NET_RESP
Definition: winerror.h:150

Referenced by handle_getattr(), and readdir_add_dots().

◆ parse_getattr()

static int parse_getattr ( unsigned char buffer,
uint32_t  length,
nfs41_upcall upcall 
)
static

Definition at line 59 of file getattr.c.

60{
61 int status;
62 getattr_upcall_args *args = &upcall->args.getattr;
63
64 status = safe_read(&buffer, &length, &args->query_class, sizeof(args->query_class));
65 if (status) goto out;
66 status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
67 if (status) goto out;
68
69 dprintf(1, "parsing NFS41_FILE_QUERY: info_class=%d buf_len=%d file=%.*s\n",
70 args->query_class, args->buf_len, upcall->state_ref->path.len,
71 upcall->state_ref->path.path);
72out:
73 return status;
74}
int safe_read(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len)
Definition: util.c:33

Variable Documentation

◆ nfs41_op_getattr

const nfs41_upcall_op nfs41_op_getattr
Initial value:
= {
}
static int marshall_getattr(unsigned char *buffer, uint32_t *length, nfs41_upcall *upcall)
Definition: getattr.c:125
static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall)
Definition: getattr.c:59
static int handle_getattr(nfs41_upcall *upcall)
Definition: getattr.c:76

Definition at line 180 of file getattr.c.