Check-in [f7f4d0aee8]
Overview
SHA1:f7f4d0aee8dd8df0d3322bea4891c5c108e0020e
Date: 2015-04-07 17:36:16
User: rkeene
Comment:Added more functionality to the "reboot" syscall wrapper
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
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)
2015-02-18
02:45
[4ea5feb1d3] Added more whitespace separators to module argument parameters (user: rkeene, tags: trunk)
Changes

Modified tuapi.c from [2a68e00137] to [197b72911d].

   793    793   		return(TCL_ERROR);
   794    794   	}
   795    795   
   796    796   	return(TCL_OK);
   797    797   }
   798    798   
   799    799   static int tuapi_reboot(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
   800         -	sync();
   801         -	reboot(RB_AUTOBOOT);
   802         -
   803         -	Tcl_SetObjResult(interp, Tcl_NewStringObj(strerror(errno), -1));
   804         -
   805         -	return(TCL_ERROR);
          800  +	Tcl_Obj *cmd_obj;
          801  +	int cmd;
          802  +	int reboot_ret;
          803  +
          804  +	if (objc == 2) {
          805  +		cmd_obj = objv[1];
          806  +
          807  +		switch (tuapi_internal_simplehash_obj(cmd_obj)) {
          808  +			case 0x2be1946: /* LINUX_REBOOT_CMD_CAD_OFF */
          809  +			case 0x666e6344: /* RB_DISABLE_CAD */
          810  +			case 0x9e3ce644: /* DISABLE_CAD */
          811  +				cmd = RB_DISABLE_CAD;
          812  +
          813  +				break;
          814  +			case 0xe8057c4e: /* LINUX_REBOOT_CMD_CAD_ON */
          815  +			case 0xf8dc444: /* RB_ENABLE_CAD */
          816  +			case 0x1a7d6144: /* ENABLE_CAD */
          817  +				cmd = RB_ENABLE_CAD;
          818  +
          819  +				break;
          820  +			case 0x95bfa454: /* LINUX_REBOOT_CMD_HALT */
          821  +			case 0x3210da4d: /* RB_HALT_SYSTEM */
          822  +			case 0xca425f4d: /* HALT_SYSTEM */
          823  +			case 0x9106654: /* HALT */
          824  +				cmd = RB_HALT_SYSTEM;
          825  +
          826  +				break;
          827  +			case 0xdb55d8c6: /* LINUX_REBOOT_CMD_POWER_OFF */
          828  +			case 0xf07700c6: /* RB_POWER_OFF */
          829  +			case 0x645ce1c6: /* POWER_OFF */
          830  +				cmd = 0x4321fedc;
          831  +
          832  +				break;
          833  +			case 0x73ff83d4: /* LINUX_REBOOT_CMD_RESTART */
          834  +			case 0x3cd0e254: /* RB_AUTOBOOT */
          835  +			case 0xb9f8b5d4: /* AUTOBOOT */
          836  +			case 0x3a357fd4: /* RESTART */
          837  +			case 0x5852add4: /* REBOOT */
          838  +				cmd = RB_AUTOBOOT;
          839  +
          840  +				break;
          841  +			default:
          842  +				Tcl_SetObjResult(interp, Tcl_NewStringObj("unknown or ambiguous subcommand: must be DISABLE_CAD, ENABLE_CAD, HALT, POWER_OFF, or RESTART", -1));
          843  +
          844  +				return(TCL_ERROR);
          845  +		}
          846  +	} else if (objc == 1) {
          847  +		cmd = RB_AUTOBOOT;
          848  +	} else {
          849  +		Tcl_SetObjResult(interp, Tcl_NewStringObj("wrong # args: should be \"::tuapi::syscall::reboot ?command?", -1));
          850  +
          851  +		return(TCL_ERROR);
          852  +	}
          853  +
          854  +	switch (cmd) {
          855  +		case RB_ENABLE_CAD:
          856  +		case RB_DISABLE_CAD:
          857  +			/* No need to sync for these operations */
          858  +			break;
          859  +		default:
          860  +			sync();
          861  +			break;
          862  +	}
          863  +
          864  +	reboot_ret = reboot(cmd);
          865  +	if (reboot_ret != 0) {
          866  +		Tcl_SetObjResult(interp, Tcl_NewStringObj(strerror(errno), -1));
          867  +
          868  +		return(TCL_ERROR);
          869  +	}
          870  +
          871  +	return(TCL_OK);
   806    872   }
   807    873   
   808    874   static int tuapi_eject(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
   809    875   	Tcl_SetObjResult(interp, Tcl_NewStringObj("not implemented", -1));
   810    876   
   811    877   	return(TCL_ERROR);
   812    878   }