Changeset 79b77ce in mainline for uspace/lib


Ignore:
Timestamp:
2025-12-17T00:00:01Z (3 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
81805e0
Parents:
2309891
Message:

Allow retrying failed file/dir creation and file open.

Location:
uspace/lib/fmgt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/fmgt/include/types/fmgt.h

    r2309891 r79b77ce  
    6565        fmgt_io_read,
    6666        /** Write */
    67         fmgt_io_write
     67        fmgt_io_write,
     68        /** Open */
     69        fmgt_io_open,
     70        /** Create */
     71        fmgt_io_create
    6872} fmgt_io_op_type_t;
    6973
  • uspace/lib/fmgt/src/copy.c

    r2309891 r79b77ce  
    9797{
    9898        fmgt_t *fmgt = (fmgt_t *)arg;
    99         errno_t rc;
    100 
    101         rc = vfs_link_path(dest, KIND_DIRECTORY, NULL);
    102 
    103         /* It is okay if the directory exists. */
    104         if (rc != EOK && rc != EEXIST)
    105                 return rc; // XXX error recovery?
    106 
    107         (void)fmgt;
    108         return EOK;
     99        fmgt_io_error_t err;
     100        fmgt_error_action_t action;
     101        errno_t rc;
     102
     103        do {
     104                rc = vfs_link_path(dest, KIND_DIRECTORY, NULL);
     105
     106                /* It is okay if the directory exists. */
     107                if (rc == EOK || rc == EEXIST)
     108                        break;
     109
     110                /* I/O error */
     111                err.fname = dest;
     112                err.optype = fmgt_io_create;
     113                err.rc = rc;
     114
     115                fmgt_timer_stop(fmgt);
     116                action = fmgt_io_error_query(fmgt, &err);
     117                fmgt_timer_start(fmgt);
     118        } while (action == fmgt_er_retry);
     119
     120        return rc;
    109121}
    110122
     
    133145                return ENOMEM;
    134146
    135         rc = vfs_lookup_open(src, WALK_REGULAR, MODE_READ, &rfd);
     147        do {
     148                rc = vfs_lookup_open(src, WALK_REGULAR, MODE_READ, &rfd);
     149                if (rc == EOK)
     150                        break;
     151
     152                /* I/O error */
     153                err.fname = src;
     154                err.optype = fmgt_io_open;
     155                err.rc = rc;
     156                fmgt_timer_stop(fmgt);
     157                action = fmgt_io_error_query(fmgt, &err);
     158                fmgt_timer_start(fmgt);
     159        } while (action == fmgt_er_retry);
     160
     161        /* Not recovered? */
    136162        if (rc != EOK) {
    137163                free(buffer);
    138                 return rc; // XXX error recovery?
     164                return rc;
    139165        }
    140166
    141         rc = vfs_lookup_open(dest, WALK_REGULAR | WALK_MAY_CREATE, MODE_WRITE,
    142             &wfd);
     167        do {
     168                rc = vfs_lookup_open(dest, WALK_REGULAR | WALK_MAY_CREATE,
     169                    MODE_WRITE, &wfd);
     170                if (rc == EOK)
     171                        break;
     172
     173                /* I/O error */
     174                err.fname = dest;
     175                err.optype = fmgt_io_create;
     176                err.rc = rc;
     177                fmgt_timer_stop(fmgt);
     178                action = fmgt_io_error_query(fmgt, &err);
     179                fmgt_timer_start(fmgt);
     180        } while (action == fmgt_er_retry);
     181
    143182        if (rc != EOK) {
    144183                free(buffer);
Note: See TracChangeset for help on using the changeset viewer.