src/dbfs/link.c
author Tero Marttila <terom@fixme.fi>
Wed, 22 Oct 2008 18:14:24 +0300
changeset 38 1fd4da071575
parent 37 c3880f3b4de8
child 40 03017f5f0087
permissions -rw-r--r--
rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
32
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
#include "dbfs.h"
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
38
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
     3
/*
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
     4
 * Handling simple ino-related ops, like lookup, readlink, unlink and link
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
     5
 */
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
     6
32
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
#include "../lib/log.h"
38
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
     8
#include "../lib/misc.h"
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
     9
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    10
/*
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    11
 * Used for lookup and link
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    12
 */
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    13
void dbfs_entry_res (const struct evsql_result_info *res, void *arg) {
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    14
    struct fuse_req *req = arg;
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    15
    struct fuse_entry_param e; ZINIT(e);
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    16
    int err = 0;
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    17
    
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    18
    uint32_t ino;
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    19
    
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    20
    // check the results
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    21
    if ((err = _dbfs_check_res(res, 1, 5)))
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    22
        SERROR(err = (err ==  1 ? ENOENT : EIO));
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    23
    
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    24
    // get the data
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    25
    if (0
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    26
        ||  evsql_result_uint32(res, 0, 0, &ino,        0 ) // inodes.ino
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    27
    )
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    28
        EERROR(err = EIO, "invalid db data");
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    29
        
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    30
    INFO("\t[dbfs.lookup] -> ino=%u", ino);
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    31
    
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    32
    // stat attrs
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    33
    if ((err = _dbfs_stat_info(&e.attr, res, 0, 1)))
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    34
        goto error;
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    35
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    36
    // other attrs
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    37
    e.ino = e.attr.st_ino = ino;
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    38
    e.attr_timeout = CACHE_TIMEOUT;
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    39
    e.entry_timeout = CACHE_TIMEOUT;
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    40
        
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    41
    // reply
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    42
    if ((err = fuse_reply_entry(req, &e)))
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    43
        EERROR(err, "fuse_reply_entry");
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    44
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    45
error:
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    46
    if (err && (err = fuse_reply_err(req, err)))
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    47
        EWARNING(err, "fuse_reply_err");
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    48
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    49
    // free
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    50
    evsql_result_free(res);
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    51
}
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    52
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    53
void dbfs_lookup (struct fuse_req *req, fuse_ino_t parent, const char *name) {
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    54
    struct dbfs *ctx = fuse_req_userdata(req);
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    55
    int err;
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    56
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    57
    INFO("[dbfs.lookup] parent=%lu name=%s", parent, name);
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    58
    
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    59
    // query and params
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    60
    const char *sql = 
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    61
        "SELECT"
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    62
        " inodes.ino, " DBFS_STAT_COLS
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    63
        " FROM file_tree INNER JOIN inodes ON (file_tree.ino = inodes.ino)"
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    64
        " WHERE file_tree.parent = $1::int4 AND file_tree.name = $2::varchar";
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    65
    
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    66
    static struct evsql_query_params params = EVSQL_PARAMS(EVSQL_FMT_BINARY) {
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    67
        EVSQL_PARAM ( UINT32 ),
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    68
        EVSQL_PARAM ( STRING ),
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    69
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    70
        EVSQL_PARAMS_END
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    71
    };
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    72
    
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    73
    // build params
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    74
    if (0
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    75
        ||  evsql_param_uint32(&params, 0, parent)
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    76
        ||  evsql_param_string(&params, 1, name)
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    77
    )
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    78
        EERROR(err = EIO, "evsql_param_*");
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    79
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    80
    // query
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    81
    if (evsql_query_params(ctx->db, NULL, sql, &params, dbfs_entry_res, req) == NULL)
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    82
        EERROR(err = EIO, "evsql_query_params");
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    83
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    84
    // XXX: handle interrupts
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    85
    
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    86
    // wait
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    87
    return;
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    88
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    89
error:
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    90
    if ((err = fuse_reply_err(req, err)))
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    91
        EWARNING(err, "fuse_reply_err");
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    92
}
32
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    93
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    94
void _dbfs_readlink_res (const struct evsql_result_info *res, void *arg) {
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    95
    struct fuse_req *req = arg;
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    96
    int err = 0;
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    97
    
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    98
    uint32_t ino;
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    99
    const char *type, *link;
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   100
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   101
    // check the results
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   102
    if ((err = _dbfs_check_res(res, 1, 3)))
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   103
        SERROR(err = (err ==  1 ? ENOENT : EIO));
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   104
        
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   105
    // get our data
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   106
    if (0
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   107
        ||  evsql_result_uint32(res, 0, 0, &ino,        0 ) // inodes.ino
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   108
        ||  evsql_result_string(res, 0, 1, &type,       0 ) // inodes.type
33
c71f3053c714 working symlink
Tero Marttila <terom@fixme.fi>
parents: 32
diff changeset
   109
        ||  evsql_result_string(res, 0, 2, &link,       1 ) // inodes.link_path
32
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   110
    )
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   111
        EERROR(err = EIO, "invalid db data");
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   112
    
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   113
    // is it a symlink?
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   114
    if (_dbfs_mode(type) != S_IFLNK)
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   115
        EERROR(err = EINVAL, "wrong type: %s", type);
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   116
    
36
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   117
    INFO("\t[dbfs.readlink %p] -> ino=%lu, type=%s, link=%s", req, (unsigned long int) ino, type, link);
32
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   118
    
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   119
    // reply
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   120
    if ((err = fuse_reply_readlink(req, link)))
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   121
        EERROR(err, "fuse_reply_readlink");
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   122
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   123
error:
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   124
    if (err && (err = fuse_reply_err(req, err)))
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   125
        EWARNING(err, "fuse_reply_err");
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   126
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   127
    // free
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   128
    evsql_result_free(res);
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   129
}
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   130
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   131
void dbfs_readlink (struct fuse_req *req, fuse_ino_t ino) {
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   132
    struct dbfs *ctx = fuse_req_userdata(req);
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   133
    int err;
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   134
    
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   135
    INFO("[dbfs.readlink %p] ino=%lu", req, ino);
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   136
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   137
    const char *sql =
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   138
        "SELECT"
33
c71f3053c714 working symlink
Tero Marttila <terom@fixme.fi>
parents: 32
diff changeset
   139
        " inodes.ino, inodes.type, inodes.link_path"
32
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   140
        " FROM inodes"
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   141
        " WHERE inodes.ino = $1::int4";
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   142
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   143
    static struct evsql_query_params params = EVSQL_PARAMS(EVSQL_FMT_BINARY) {
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   144
        EVSQL_PARAM ( UINT32 ),
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   145
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   146
        EVSQL_PARAMS_END
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   147
    };
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   148
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   149
    // build params
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   150
    if (0
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   151
        ||  evsql_param_uint32(&params, 0, ino)
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   152
    )
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   153
        SERROR(err = EIO);
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   154
        
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   155
    // query
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   156
    if (evsql_query_params(ctx->db, NULL, sql, &params, _dbfs_readlink_res, req) == NULL)
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   157
        SERROR(err = EIO);
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   158
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   159
    // XXX: handle interrupts
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   160
    
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   161
    // wait
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   162
    return;
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   163
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   164
error:
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   165
    if ((err = fuse_reply_err(req, err)))
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   166
        EWARNING(err, "fuse_reply_err");
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   167
90e14e0df133 working readlink
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   168
}
33
c71f3053c714 working symlink
Tero Marttila <terom@fixme.fi>
parents: 32
diff changeset
   169
36
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   170
#define SETERR(err_var, err_val, bool_val) ((err_var) = bool_val ? (err_val) : 0)
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   171
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   172
void dbfs_unlink_res (const struct evsql_result_info *res, void *arg) {
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   173
    struct fuse_req *req = arg;
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   174
    int err = 0;
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   175
    
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   176
    // check the results
37
c3880f3b4de8 update fuse_db.sql, just use dbfs_unlink for rmdir (no special handling)
Tero Marttila <terom@fixme.fi>
parents: 36
diff changeset
   177
    // XXX: reply with ENOTEMPTY if it fails due to this inode being a dir
36
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   178
    if ((err = dbfs_check_result(res, 1, 0)))
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   179
        goto error;
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   180
        
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   181
    INFO("\t[dbfs.unlink %p] -> OK", req);
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   182
    
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   183
    // reply
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   184
    if ((err = fuse_reply_err(req, 0)))
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   185
        EERROR(err, "fuse_reply_readlink");
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   186
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   187
error:
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   188
    if (err && (err = fuse_reply_err(req, err)))
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   189
        EWARNING(err, "fuse_reply_err");
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   190
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   191
    // free
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   192
    evsql_result_free(res);
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   193
}
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   194
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   195
void dbfs_unlink (struct fuse_req *req, fuse_ino_t parent, const char *name) {
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   196
    struct dbfs *ctx = fuse_req_userdata(req);
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   197
    int err;
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   198
    
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   199
    INFO("[dbfs.unlink %p] parent=%lu, name=%s", req, parent, name);
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   200
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   201
    const char *sql =
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   202
        "DELETE"
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   203
        " FROM file_tree"
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   204
        " WHERE parent = $1::int4 AND name = $2::varchar";
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   205
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   206
    static struct evsql_query_params params = EVSQL_PARAMS(EVSQL_FMT_BINARY) {
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   207
        EVSQL_PARAM ( UINT32 ),
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   208
        EVSQL_PARAM ( STRING ),
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   209
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   210
        EVSQL_PARAMS_END
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   211
    };
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   212
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   213
    // build params
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   214
    if (SETERR(err, (0
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   215
        ||  evsql_param_uint32(&params, 0, parent)
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   216
        ||  evsql_param_string(&params, 1, name)
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   217
    ), EIO))
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   218
        goto error;
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   219
        
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   220
    // query
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   221
    if (SETERR(err, evsql_query_params(ctx->db, NULL, sql, &params, dbfs_unlink_res, req) == NULL, EIO))
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   222
        goto error;
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   223
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   224
    // XXX: handle interrupts
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   225
    
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   226
    // wait
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   227
    return;
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   228
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   229
error:
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   230
    if ((err = fuse_reply_err(req, err)))
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   231
        EWARNING(err, "fuse_reply_err");
56427f22e969 tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents: 35
diff changeset
   232
}
37
c3880f3b4de8 update fuse_db.sql, just use dbfs_unlink for rmdir (no special handling)
Tero Marttila <terom@fixme.fi>
parents: 36
diff changeset
   233
38
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   234
void dbfs_link (struct fuse_req *req, fuse_ino_t ino, fuse_ino_t newparent, const char *newname) {
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   235
    struct dbfs *ctx = fuse_req_userdata(req);
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   236
    int err;
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   237
    
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   238
    INFO("[dbfs.link %p] ino=%lu, newparent=%lu, newname=%s", req, ino, newparent, newname);
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   239
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   240
    const char *sql =
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   241
        "SELECT ino, type, mode, size, nlink FROM dbfs_link($1::int4, $2::int4, $3::varchar)";
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   242
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   243
    static struct evsql_query_params params = EVSQL_PARAMS(EVSQL_FMT_BINARY) {
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   244
        EVSQL_PARAM ( UINT32 ),
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   245
        EVSQL_PARAM ( UINT32 ),
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   246
        EVSQL_PARAM ( STRING ),
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   247
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   248
        EVSQL_PARAMS_END
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   249
    };
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   250
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   251
    // build params
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   252
    if (0
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   253
        ||  evsql_param_uint32(&params, 0, ino)
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   254
        ||  evsql_param_uint32(&params, 1, newparent)
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   255
        ||  evsql_param_string(&params, 2, newname)
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   256
    )
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   257
        SERROR(err = EIO);
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   258
        
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   259
    // query
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   260
    if (evsql_query_params(ctx->db, NULL, sql, &params, dbfs_entry_res, req) == NULL)
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   261
        SERROR(err = EIO);
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   262
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   263
    // XXX: handle interrupts
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   264
    
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   265
    // wait
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   266
    return;
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   267
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   268
error:
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   269
    if ((err = fuse_reply_err(req, err)))
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   270
        EWARNING(err, "fuse_reply_err");   
1fd4da071575 rework/hack parent to be a FOREIGN KEY (add a dir_ino col), implement dbfs_link
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
   271
}