Check-in [20d82b1585]
Overview
SHA1:20d82b1585e898bcae6227bb4d420e1d727e3dec
Date: 2015-05-17 04:16:41
User: rkeene
Comment:Implemented "rmmod"
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2016-03-30
03:04
[49fcda9f97] Added ifdef around CAN, needed for RHEL5 (user: rkeene, tags: trunk)
2015-05-17
04:16
[20d82b1585] Implemented "rmmod" (user: rkeene, tags: trunk)
2015-04-07
17:36
[f7f4d0aee8] Added more functionality to the "reboot" syscall wrapper (user: rkeene, tags: trunk)
Changes

Modified tuapi.c from [197b72911d] to [a8bc74d0c2].

    79     79   extern char **environ;
    80     80   
    81     81   /* Re-implement these if needed */
    82     82   #ifdef SYS_init_module
    83     83   static int init_module(void *val, unsigned long len, const char *args) {
    84     84   	return(syscall(SYS_init_module, val, len, args));
    85     85   }
           86  +#endif
           87  +#ifdef SYS_delete_module
           88  +static int delete_module(const char *name, int flags) {
           89  +	return(syscall(SYS_delete_module, name, flags));
           90  +}
    86     91   #endif
    87     92   #ifdef SYS_pivot_root
    88     93   static int pivot_root(const char *new_root, const char *put_old) {
    89     94   	return(syscall(SYS_pivot_root, new_root, put_old));
    90     95   }
    91     96   #endif
    92     97   
................................................................................
   504    509   		return(TCL_ERROR);
   505    510   	}
   506    511   
   507    512   	return(TCL_OK);
   508    513   }
   509    514   
   510    515   static int tuapi_rmmod(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
   511         -	Tcl_SetObjResult(interp, Tcl_NewStringObj("not implemented", -1));
          516  +	char *module;
          517  +	int idx;
          518  +	int delete_module_ret;
   512    519   
   513         -	return(TCL_ERROR);
          520  +	if (objc < 2) {
          521  +		Tcl_SetObjResult(interp, Tcl_NewStringObj("wrong # args: should be \"tuapi::syscall::rmmod module ?module...?", -1));
          522  +
          523  +		return(TCL_ERROR);
          524  +	}
          525  +
          526  +	for (idx = 1; idx < objc; idx++) {
          527  +		module = Tcl_GetString(objv[idx]);
          528  +
          529  +		delete_module_ret = delete_module(module, O_NONBLOCK);
          530  +		if (delete_module_ret != 0) {
          531  +			Tcl_SetObjResult(interp, Tcl_ObjPrintf("unable to remove \"%s\": %s", module, strerror(errno)));
          532  +
          533  +			return(TCL_ERROR);
          534  +		}
          535  +	}
          536  +
          537  +	return(TCL_OK);
   514    538   }
   515    539   
   516    540   static int tuapi_lsmod(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
   517    541   	Tcl_SetObjResult(interp, Tcl_NewStringObj("not implemented", -1));
   518    542   
   519    543   	return(TCL_ERROR);
   520    544   }