Changeset c3db721 in mainline for uspace/lib


Ignore:
Timestamp:
2025-10-10T20:35:05Z (3 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
c1383cd
Parents:
0cf3d5f
Message:

Allow aborting file management operation.

Location:
uspace/lib/fmgt
Files:
2 edited

Legend:

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

    r0cf3d5f rc3db721  
    4040#include <capa.h>
    4141#include <fibril_synch.h>
     42#include <stdbool.h>
    4243
    4344/** File management progress update */
     
    5354/** File management callbacks */
    5455typedef struct {
     56        bool (*abort_query)(void *);
    5557        void (*progress)(void *, fmgt_progress_t *);
    5658} fmgt_cb_t;
  • uspace/lib/fmgt/src/fmgt.c

    r0cf3d5f rc3db721  
    221221}
    222222
     223/** Query caller whether operation should be aborted.
     224 *
     225 * @param fmgt File management object
     226 * @return @c true iff operation should be aborted
     227 */
     228static bool fmgt_abort_query(fmgt_t *fmgt)
     229{
     230        if (fmgt->cb != NULL && fmgt->cb->abort_query!= NULL)
     231                return fmgt->cb->abort_query(fmgt->cb_arg);
     232        else
     233                return false;
     234}
     235
    223236/** Create new file.
    224237 *
     
    276289
    277290                fmgt->curf_procb += nw;
     291
     292                /* User requested abort? */
     293                if (fmgt_abort_query(fmgt)) {
     294                        free(buffer);
     295                        vfs_put(fd);
     296                        fmgt_final_progress_update(fmgt);
     297                        return EINTR;
     298                }
    278299        }
    279300
Note: See TracChangeset for help on using the changeset viewer.