/* ***************************************************************************** * storage/optimize.c -- optimize a filesystem on the calculator. * Copyright (C) 2016-2017 Thomas "Cakeisalie5" Touhey * * This file is part of libp7. * libp7 is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 3.0 of the License, * or (at your option) any later version. * * libp7 is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with libp7; if not, see . * ************************************************************************** */ #include /** * p7_optimize: * Optimize distant flash memory. * * @arg handle the libp7 handle * @arg devname the device name * @return if it worked */ int p7_optimize(p7_handle_t *handle, const char *devname) { int err; /* make checks */ chk_handle(handle); chk_active(handle); /* send command */ log_info("sending command"); if ((err = p7_send_cmdfls_opt(handle, devname))) { log_fatal("couldn't send command/receive its answer"); return (err); } else if (response.type == p7_pt_error && response.code == p7_err_other) { log_fatal("storage device does not exist"); return (p7_error_unsupported_device); } else if (response.type != p7_pt_ack) { log_fatal("response wasn't ack"); return (p7_error_unknown); } /* we're done */ return (0); }