#include <cafe/fs.h>

/* Attach notification callback */
typedef void (*FSStateChangeCallback)(FSClient *client, FSVolumeState state, void *context);

struct FSStateChangeParams
    FSStateChangeCallback  userCallback;
    void                   *userContext;
    OSMessageQueue*        ioMsgQueue;

void FSSetStateChangeNotification(FSClient *client, FSStateChangeParams *changeParams);


client Pointer to the client buffer.
changeParams Notification parameters when a media error or fatal error occurs.

Return Values



Sets the notification parameters for when an unexpected, media, or fatal error occurs and the volume state is changed subsequently.

When the volume state of the client is changed after FSSetStateChangeNotification is called, userCallback is invoked or notification message (FSMessage) is returned to the ioMsgQueue. The specified userContext is passed to the userCallback or the ioMsgQueue. FSGetStateChangeInfo retrieves information from the notification message.

The callback function and user message queues are exclusive. Only one of userCallback and ioMsgQueue may be non-null and the other must be null.

API calls that return an unexpected value (not provided as part of an API call in FSRetFlag) will also invoke the volume state change (unexpected return values are considered fatal errors).

Whenever a volume state change occurs, the message "FS: Volume State Changed to X" will be printed. X refers to the FSVolumeState enum value. Whether a callback has been provided or not, the API calling core will enter a spinlock. If a callback is registered additional information can be retrieved in the callback code to determine the cause of the volume state change.

Do Not Call From


See Also


Revision History

2013/05/08 Automated cleanup pass.
2012/10/10 Additional information on state changes.
2012/07/20 Readability cleanup.
2012/04/10 Fixed Description.
2011/12/12 Initial version.