1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
2 /*
3 *
4 * Copyright (C) 2003 University of Chicago.
5 * See COPYRIGHT notice in top-level directory.
6 */
7
8 #include "ad_pvfs2.h"
9 #include "adio.h"
10
11 #include "ad_pvfs2_common.h"
12
ADIOI_PVFS2_Delete(char * filename,int * error_code)13 void ADIOI_PVFS2_Delete(char *filename, int *error_code)
14 {
15 PVFS_credentials credentials;
16 PVFS_sysresp_getparent resp_getparent;
17 int ret;
18 PVFS_fs_id cur_fs;
19 static char myname[] = "ADIOI_PVFS2_DELETE";
20 char pvfs_path[PVFS_NAME_MAX] = {0};
21
22 ADIOI_PVFS2_Init(error_code);
23 /* --BEGIN ERROR HANDLING-- */
24 if (*error_code != MPI_SUCCESS)
25 {
26 /* ADIOI_PVFS2_INIT handles creating error codes itself */
27 return;
28 }
29 /* --END ERROR HANDLING-- */
30
31 /* in most cases we'll store the credentials in the fs struct, but we don't
32 * have one of those in Delete */
33 ADIOI_PVFS2_makecredentials(&credentials);
34
35 /* given the filename, figure out which pvfs filesystem it is on */
36 ret = PVFS_util_resolve(filename, &cur_fs, pvfs_path, PVFS_NAME_MAX);
37 /* --BEGIN ERROR HANDLING-- */
38 if (ret != 0) {
39 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
40 MPIR_ERR_RECOVERABLE,
41 myname, __LINE__,
42 ADIOI_PVFS2_error_convert(ret),
43 "Error in PVFS_util_resolve", 0);
44 return;
45 }
46 /* --END ERROR HANDLING-- */
47
48 ret = PVFS_sys_getparent(cur_fs, pvfs_path, &credentials, &resp_getparent);
49
50 ret = PVFS_sys_remove(resp_getparent.basename,
51 resp_getparent.parent_ref, &credentials);
52 /* --BEGIN ERROR HANDLING-- */
53 if (ret != 0) {
54 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
55 MPIR_ERR_RECOVERABLE,
56 myname, __LINE__,
57 ADIOI_PVFS2_error_convert(ret),
58 "Error in PVFS_sys_remove", 0);
59 return;
60 }
61 /* --END ERROR HANDLING-- */
62
63 *error_code = MPI_SUCCESS;
64 return;
65 }
66
67 /*
68 * vim: ts=8 sts=4 sw=4 noexpandtab
69 */
70