XMMS2
src/xmms/compat/statfs_linux.c
Go to the documentation of this file.
00001 /*  XMMS2 - X Music Multiplexer System
00002  *  Copyright (C) 2003-2011 XMMS2 Team
00003  *
00004  *  PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!!
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2.1 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Lesser General Public License for more details.
00015  */
00016 
00017 
00018 /** @file
00019  *  Linux statfs
00020  */
00021 
00022 #include <stdio.h>
00023 #include <unistd.h>
00024 #include <stdlib.h>
00025 #include <glib.h>
00026 
00027 
00028 #include <sys/vfs.h>
00029 
00030 #include "xmms/xmms_log.h"
00031 #include "xmmspriv/xmms_statfs.h"
00032 
00033 /**
00034  * This function uses the statfs() call to
00035  * check if the path is on a remote filesystem
00036  * or not.
00037  *
00038  * @returns TRUE if path is on a remote filesystem
00039  */
00040 gboolean
00041 xmms_statfs_is_remote (const gchar *path)
00042 {
00043     struct statfs st;
00044 
00045     if (statfs (path, &st) == -1) {
00046         xmms_log_error ("Failed to run statfs, will not guess.");
00047         return FALSE;
00048     }
00049 
00050     if (st.f_type == 0xFF534D42 || /* cifs */
00051         st.f_type == 0x6969 || /* nfs */
00052         st.f_type == 0x517B) { /* smb */
00053         return TRUE;
00054     }
00055 
00056     return FALSE;
00057 }