t2ex/t2ex_source/t2ex/fs/fs/src/fs_regist.c | bare source | permlink (0.01 seconds) |
1: /* 2: *---------------------------------------------------------------------- 3: * T2EX Software Package 4: * 5: * Copyright 2012 by Ken Sakamura. 6: * This software is distributed under the latest version of T-License 2.x. 7: *---------------------------------------------------------------------- 8: * 9: * Released by T-Engine Forum(http://www.t-engine.org/) at 2012/12/12. 10: * Modified by TRON Forum(http://www.tron.org/) at 2015/06/04. 11: * 12: *---------------------------------------------------------------------- 13: */ 14: /* 15: * This software package is available for use, modification, 16: * and redistribution in accordance with the terms of the attached 17: * T-License 2.x. 18: * If you want to redistribute the source code, you need to attach 19: * the T-License 2.x document. 20: * There's no obligation to publish the content, and no obligation 21: * to disclose it to the TRON Forum if you have modified the 22: * software package. 23: * You can also distribute the modified source code. In this case, 24: * please register the modification to T-Kernel traceability service. 25: * People can know the history of modifications by the service, 26: * and can be sure that the version you have inherited some 27: * modification of a particular version or not. 28: * 29: * http://trace.tron.org/tk/?lang=en 30: * http://trace.tron.org/tk/?lang=ja 31: * 32: * As per the provisions of the T-License 2.x, TRON Forum ensures that 33: * the portion of the software that is copyrighted by Ken Sakamura or 34: * the TRON Forum does not infringe the copyrights of a third party. 35: * However, it does not make any warranty other than this. 36: * DISCLAIMER: TRON Forum and Ken Sakamura shall not be held 37: * responsible for any consequences or damages caused directly or 38: * indirectly by the use of this software package. 39: * 40: * The source codes in bsd_source.tar.gz in this software package are 41: * derived from NetBSD or OpenBSD and not covered under T-License 2.x. 42: * They need to be changed or redistributed according to the 43: * representation of each source header. 44: */ 45: 46: /* 47: * @(#)fs_regist.c 48: * 49: */ 50: 51: #include "fsdefs.h" 52: 53: /* 54: * Check FIMP name : returns 0: valid, -1: invalid 55: */ 56: EXPORT INT fs_check_fimpnm(const B *fimpnm) 57: { 58: INT i; 59: B c; 60: 61: if (fimpnm != NULL) { 62: /* valid characters are 0-9 A-Z a-z _ */ 63: for (i = 0; (c = fimpnm[i]) != '\0' && i < L_FIMPNM; i++) { 64: if ( (c >= '0' && c <= '9') || 65: (c >= 'a' && c <= 'z') || 66: (c >= 'A' && c <= 'Z') || 67: (c == '_' ) )continue; 68: break; 69: } 70: if (i > 0 && c == '\0') return 0; 71: } 72: return -1; 73: } 74: 75: /* 76: * fs_regist() - FIMP registration 77: */ 78: EXPORT INT xfs_regist(fs_env_t *env, const B *fimpnm, 79: const fs_fimp_t *fimp, void *exinf, void *tsd) 80: { 81: INT sts; 82: fs_fimpd_t *fimpd; 83: 84: /* Check FIMP name */ 85: if (fs_check_fimpnm(fimpnm) != 0) { 86: sts = EX_INVAL; 87: goto exit0; 88: } 89: 90: /* Regist FIMP */ 91: sts = fs_fimp_regist(fimpnm, &fimpd); 92: if (sts != 0) goto exit0; 93: 94: /* Initialize FIMP descriptor */ 95: (void)memcpy(&fimpd->p_fimp, fimp, sizeof(fs_fimp_t)); 96: 97: /* Call FIMP registration service */ 98: fimpd->p_fimpinf.fimpsd = tsd; 99: sts = fimp->registfn(&fimpd->p_fimpinf, exinf); 100: 101: /* End of registration */ 102: fs_fimp_end_regist(fimpd, sts); 103: if (sts == 0) return 0; 104: exit0: 105: env->t_errno = sts; 106: return -1; 107: } 108: