summaryrefslogtreecommitdiffstats
path: root/tests/basic/gfapi/gfapi-statx-basic.c
blob: a4943fa0fd139bfd8f0d333b2ce0e85ed2ecfa46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <glusterfs/api/glfs.h>

#define VALIDATE_AND_GOTO_LABEL_ON_ERROR(func, ret, label)                     \
    do {                                                                       \
        if (ret < 0) {                                                         \
            fprintf(stderr, "%s : returned error %d (%s)\n", func, ret,        \
                    strerror(errno));                                          \
            goto label;                                                        \
        }                                                                      \
    } while (0)

#define GOTO_LABEL_ON_FALSE(compstr, ret, label)                               \
    do {                                                                       \
        if (ret == false) {                                                    \
            fprintf(stderr, "%s : comparison failed!\n", compstr);             \
            goto label;                                                        \
        }                                                                      \
    } while (0)

#define WRITE_SIZE 513
#define TRUNC_SIZE 4096

/* Using private function and hence providing a forward declation in sync with
code in glfs-internal.h */
int
glfs_statx(struct glfs *fs, const char *path, unsigned int mask,
           struct glfs_stat *statxbuf);

int
main(int argc, char *argv[])
{
    int ret = -1;
    int flags = O_RDWR | O_SYNC;
    glfs_t *fs = NULL;
    glfs_fd_t *fd1 = NULL;
    char *volname = NULL;
    char *logfile = NULL;
    const char *filename = "file_tmp";
    const char buff[WRITE_SIZE];
    struct stat sb;
    unsigned int mask;
    struct glfs_stat statx;
    bool bret;

    if (argc != 3) {
        fprintf(stderr, "Invalid argument\n");
        fprintf(stderr, "Usage: %s <volname> <logfile>\n", argv[0]);
        return 1;
    }

    volname = argv[1];
    logfile = argv[2];

    fs = glfs_new(volname);
    if (!fs)
        VALIDATE_AND_GOTO_LABEL_ON_ERROR("glfs_new", ret, out);

    ret = glfs_set_volfile_server(fs, "tcp", "localhost", 24007);
    VALIDATE_AND_GOTO_LABEL_ON_ERROR("glfs_set_volfile_server", ret, out);

    ret = glfs_set_logging(fs, logfile, 7);
    VALIDATE_AND_GOTO_LABEL_ON_ERROR("glfs_set_logging", ret, out);

    ret = glfs_init(fs);
    VALIDATE_AND_GOTO_LABEL_ON_ERROR("glfs_init", ret, out);

    fd1 = glfs_creat(fs, filename, flags, 0644);
    if (fd1 == NULL) {
        ret = -1;
        VALIDATE_AND_GOTO_LABEL_ON_ERROR("glfs_creat", ret, out);
    }

    ret = glfs_truncate(fs, filename, TRUNC_SIZE);
    VALIDATE_AND_GOTO_LABEL_ON_ERROR("glfs_truncate", ret, out);

    ret = glfs_write(fd1, buff, WRITE_SIZE, flags);
    VALIDATE_AND_GOTO_LABEL_ON_ERROR("glfs_write", ret, out);

    ret = glfs_fstat(fd1, &sb);
    VALIDATE_AND_GOTO_LABEL_ON_ERROR("glfs_fstat", ret, out);

    if (sb.st_size != TRUNC_SIZE) {
        fprintf(stderr, "wrong size %jd should be %jd\n", (intmax_t)sb.st_size,
                (intmax_t)2048);
        ret = -1;
        goto out;
    }

    glfs_close(fd1);
    fd1 = NULL;

    /* TEST 1: Invalid mask to statx */
    mask = 0xfafadbdb;
    ret = glfs_statx(fs, filename, mask, NULL);
    if (ret == 0 || ((ret == -1) && (errno != EINVAL))) {
        fprintf(stderr,
                "Invalid args passed, but error returned is"
                " incorrect (ret - %d, errno - %d)\n",
                ret, errno);
        ret = -1;
        goto out;
    }
    ret = 0;

    /* TEST 2: Call statx and validate fields against prior fstat data */
    /* NOTE: This fails, as iatt->ia_flags are not carried through the stack,
     * for example if mdc_to_iatt is invoked to serve cached stat, we will loose
     * the flags. */
    mask = GLFS_STAT_ALL;
    ret = glfs_statx(fs, filename, mask, &statx);
    VALIDATE_AND_GOTO_LABEL_ON_ERROR("glfs_statx", ret, out);

    if ((statx.glfs_st_mask & GLFS_STAT_BASIC_STATS) != GLFS_STAT_BASIC_STATS) {
        fprintf(stderr, "Invalid glfs_st_mask, expecting 0x%x got 0x%x\n",
                GLFS_STAT_ALL, statx.glfs_st_mask);
        ret = -1;
        goto out;
    }

    bret = (sb.st_ino == statx.glfs_st_ino);
    GOTO_LABEL_ON_FALSE("(sb.st_ino == statx.glfs_st_ino)", bret, out);

    bret = (sb.st_mode == statx.glfs_st_mode);
    GOTO_LABEL_ON_FALSE("(sb.st_mode == statx.glfs_st_mode)", bret, out);

    bret = (sb.st_nlink == statx.glfs_st_nlink);
    GOTO_LABEL_ON_FALSE("(sb.st_nlink == statx.glfs_st_nlink)", bret, out);

    bret = (sb.st_uid == statx.glfs_st_uid);
    GOTO_LABEL_ON_FALSE("(sb.st_uid == statx.glfs_st_uid)", bret, out);

    bret = (sb.st_gid == statx.glfs_st_gid);
    GOTO_LABEL_ON_FALSE("(sb.st_gid == statx.glfs_st_gid)", bret, out);

    bret = (sb.st_size == statx.glfs_st_size);
    GOTO_LABEL_ON_FALSE("(sb.st_size == statx.glfs_st_size)", bret, out);

    bret = (sb.st_blksize == statx.glfs_st_blksize);
    GOTO_LABEL_ON_FALSE("(sb.st_blksize == statx.glfs_st_blksize)", bret, out);

    bret = (sb.st_blocks == statx.glfs_st_blocks);
    GOTO_LABEL_ON_FALSE("(sb.st_blocks == statx.glfs_st_blocks)", bret, out);

    bret = (!memcmp(&sb.st_atim, &statx.glfs_st_atime,
                    sizeof(struct timespec)));
    GOTO_LABEL_ON_FALSE("(sb.st_atim == statx.glfs_st_atime)", bret, out);

    bret = (!memcmp(&sb.st_mtim, &statx.glfs_st_mtime,
                    sizeof(struct timespec)));
    GOTO_LABEL_ON_FALSE("(sb.st_mtim == statx.glfs_st_mtime)", bret, out);

    bret = (!memcmp(&sb.st_ctim, &statx.glfs_st_ctime,
                    sizeof(struct timespec)));
    GOTO_LABEL_ON_FALSE("(sb.st_ctim == statx.glfs_st_ctime)", bret, out);

    /* TEST 3: Check if partial masks are accepted */
    mask = GLFS_STAT_TYPE | GLFS_STAT_UID | GLFS_STAT_GID;
    ret = glfs_statx(fs, filename, mask, &statx);
    VALIDATE_AND_GOTO_LABEL_ON_ERROR("glfs_statx", ret, out);

    /* We currently still return all stats, as is acceptable based on the API
     * definition in the header (and in statx as well) */
    if ((statx.glfs_st_mask & GLFS_STAT_BASIC_STATS) != GLFS_STAT_BASIC_STATS) {
        fprintf(stderr, "Invalid glfs_st_mask, expecting 0x%x got 0x%x\n",
                GLFS_STAT_ALL, statx.glfs_st_mask);
        ret = -1;
        goto out;
    }
out:
    if (fd1 != NULL)
        glfs_close(fd1);
    if (fs) {
        (void)glfs_fini(fs);
    }

    return ret;
}
nWindow.py:215 msgid "<b>This crash has been reported, you can find the report(s) at:</b>\n" msgstr "<b>இந்த சேதம் அறிக்கையிடப்பட்டுள்ளது, நீங்கள் அறிக்கை(களை) இதில் தேடலாம்:</b>\n" #: src/Gui/CCMainWindow.py:275 msgid "" "Unable to get report!\n" "Debuginfo is missing?" msgstr "" "அறிக்கையை பெற முடியவில்லை!\n" "Debuginfo விடுபட்டுள்ளதா?" #: src/Gui/CCMainWindow.py:287 #, python-format msgid "" "Reporting failed!\n" "%s" msgstr "" "அறிக்கையிடுதல் தோல்வியுற்றது!\n" "%s" #: src/Gui/CCMainWindow.py:319 #, python-format msgid "Error getting the report: %s" msgstr "அறிக்கையை பெறும் போது பிழை: %s" #: src/Gui/CCReporterDialog.py:98 #, python-format msgid "" "<b>WARNING</b>, you're about to send data which might contain sensitive " "information.\n" "Do you really want to send <b>%s</b>?\n" msgstr "" "<b>எச்சரிக்கை</b>, நீங்கள் அனுப்ப இருக்கும் தரவு சில உணர்வார்ந்த தகவல்களை கொண்டிருக்கும்.\n" "நீங்கள் <b>%s</b>ஐ அனுப்ப வேண்டும்?\n" #: src/Gui/CCReporterDialog.py:111 msgid "Brief description how to reproduce this or what you did..." msgstr "இதனை மீண்டும் உருவாக்குவதற்கான சுருக்க விளக்கம் அல்லது நீங்கள் என்ன செய்தீர்கள்..." #: src/Gui/PluginSettingsUI.py:17 msgid "Can't find PluginDialog widget in UI description!" msgstr "PluginDialog விட்ஜெட்டை UI விளக்கத்தில் தேட முடியவில்லை!" #: src/Gui/PluginSettingsUI.py:21 #, python-format msgid "No UI for plugin %s" msgstr "UI கூடுதல் இணைப்பு %sஇல் இல்லை" #: src/Gui/PluginSettingsUI.py:38 src/Gui/PluginSettingsUI.py:64 msgid "combo box is not implemented" msgstr "காம்போ பெட்டி செயல்படுத்தப்படவில்லை" #: src/Gui/PluginSettingsUI.py:47 msgid "Nothing to hydrate!" msgstr "hydrate செய்ய ஒன்றுமில்லை!" #: src/Gui/report.glade:64 msgid "Comment" msgstr "குறிப்பு" #: src/Gui/report.glade:103 msgid "gtk-cancel" msgstr "gtk-cancel" #: src/Gui/report.glade:118 msgid "Send" msgstr "அனுப்பு" #: src/Gui/SettingsDialog.py:35 src/Gui/SettingsDialog.py:52 msgid "<b>Select plugin</b>" msgstr "<b>கூடுதல் இணைப்பை தேர்ந்தெடு</b>" #: src/Gui/SettingsDialog.py:38 msgid "<b>Select database backend</b>" msgstr "<b>தரவுத்தள பின்தளத்தை தேர்ந்தெடு</b>" #: src/Gui/SettingsDialog.py:170 msgid "Remove this job" msgstr "இந்த பணியை நீக்கு" #: src/Gui/SettingsDialog.py:213 msgid "Remove this action" msgstr "இந்த செயலை நீக்கு" #: src/Applet/Applet.cpp:45 #, c-format msgid "A crash in package %s has been detected!" msgstr "தொகுப்பு %s இல் ஒரு சேதம் கண்டறியப்பட்டது!" #: src/Applet/Applet.cpp:89 msgid "Applet is already running." msgstr "ஆப்லெட் ஏற்கனவே இயங்குகிறது." #: src/Applet/Applet.cpp:104 src/Applet/Applet.cpp:105 #: src/Applet/CCApplet.cpp:221 msgid "ABRT service is not running" msgstr "ABRT சேவை இயங்கவில்லை" #: src/Applet/CCApplet.cpp:136 src/Applet/CCApplet.cpp:368 #, c-format msgid "Pending events: %i" msgstr "விடுபட்ட நிகழ்வுகள்: %i" #: src/Applet/CCApplet.cpp:161 #, c-format msgid "Can't create menu from the description, popup won't be available!\n" msgstr "விளக்கத்திலிருதநு மெனுவை உருவாக்க முடியவில்லை, பாப்அப் இல்லை!\n" #: src/Applet/CCApplet.cpp:190 msgid "" "This is default handler, you should register your own with " "ConnectCrashHandler" msgstr "" "இது முன்னிருப்பு கையாளி, உங்களுக்கு உள்ளதை ConnectCrashHandlerஉடன் பதிவு செய்ய " "வேண்டும்" #: src/Applet/CCApplet.cpp:210 #, fuzzy msgid "" "This is default handler, you should register your own with " "ConnectQuotaExceedHandler" msgstr "" "இது முன்னிருப்பு கையாளி, உங்களுக்கு உள்ளதை ConnectCrashHandlerஉடன் பதிவு செய்ய " "வேண்டும்" #: src/Applet/CCApplet.cpp:225 msgid "ABRT service has been started" msgstr "ABRT சேவை துவக்கப்பட்டது" #: src/Applet/CCApplet.cpp:256 msgid "Out of memory" msgstr "நினைவகம் போதவில்லை" #: src/Applet/CCApplet.cpp:272 msgid "Warning" msgstr "எச்சரிக்கை" #: src/Daemon/Daemon.cpp:527 msgid "" "Quota exceeded. Please check your MaxCrashReportsSize value in abrt.conf." msgstr "" #: lib/Plugins/Bugzilla.cpp:84 msgid "Empty login and password. Please check Bugzilla.conf" msgstr "வெற்று புகுபதிவு மற்றும் கடவுச்சொல். Bugzilla.confஐ சரி பார்க்கவும்" #: lib/Plugins/Bugzilla.cpp:228 msgid "Bug is already reported: " msgstr "பிழை ஏற்கனவே அறிக்கையிடப்பட்டது:" #: lib/Plugins/Bugzilla.cpp:283 #, c-format msgid "Binary file %s will not be reported." msgstr "பைனரி கோப்பு %s அறிக்கையிடப்படாது." #: lib/Plugins/Bugzilla.cpp:353 msgid "New bug id: " msgstr "புதிய பிழை குறியீடு: " #: lib/Plugins/Bugzilla.cpp:422 msgid "Checking for duplicates..." msgstr "போலிகளுக்கு சரிபார்க்கிறது..." #: lib/Plugins/Bugzilla.cpp:425 lib/Plugins/Bugzilla.cpp:437 msgid "Logging into bugzilla..." msgstr "bugzillaவில் உள்நுழைகிறது..." #: lib/Plugins/Bugzilla.cpp:428 msgid "Check CC and add coment +1..." msgstr "CC aமற்றும் add coment +1க்கு சோதிக்கிறது..." #: lib/Plugins/Bugzilla.cpp:449 msgid "Creating new bug..." msgstr "புதிய பிழையை உருவாக்குகிறது..." #: lib/Plugins/Bugzilla.cpp:454 msgid "Logging out..." msgstr "வெளியேறுகிறது..." #: lib/Plugins/Kerneloops.cpp:38 msgid "Getting local/global universal unique identification..." msgstr "உள்ளமை/முழுமையான உலகளாவிய தனி அடையாளத்தை பெறுகிறது..." #: lib/Plugins/CCpp.cpp:147 msgid "Getting backtrace..." msgstr "backtraceஐ பெறுகிறது..." #: lib/Plugins/CCpp.cpp:385 msgid "Searching for debug-info packages..." msgstr "debug-info தொகுப்புகளுக்கு தேடுகிறது..." #: lib/Plugins/CCpp.cpp:419 msgid "Downloading and installing debug-info packages..." msgstr "debug-info தொகுப்புகளை பதிவிறக்கி நிறுவுகிறது..." #: lib/Plugins/CCpp.cpp:481 msgid "Getting local universal unique identification..." msgstr "உள்ளமை உலகளாவிய தனி அடையாளத்தை பெறுகிறது..." #: lib/Plugins/CCpp.cpp:500 msgid "Getting global universal unique identification..." msgstr "முழுமையான உலகளாவிய தனி அடையாளத்தை பெறுகிறது..." #: lib/Plugins/CCpp.cpp:552 msgid "Starting report creation..." msgstr "அறிக்கை உருவாக்கத்தை துவக்குகிறது..." #: lib/Plugins/CCpp.cpp:581 #, fuzzy msgid "Skipping debuginfo installation" msgstr "தொகுப்பு %sக்கு debuginfo நிறுவலை தவிர்த்தது" #: lib/Plugins/KerneloopsReporter.cpp:101 msgid "Creating and submitting a report..." msgstr "ஒரு அறிக்கையை உருவாக்கி சமர்ப்பிக்கிறது..." #: lib/Plugins/Logger.cpp:58 lib/Plugins/Mailx.cpp:124 msgid "Creating a report..." msgstr "ஒரு அறிக்கையை உருவாக்குகிறது..." #: lib/Plugins/RunApp.cpp:62 msgid "Executing RunApp plugin..." msgstr "RunApp கூடுதல் இணைப்பை இயக்குகிறது..." #: lib/Plugins/FileTransfer.cpp:52 lib/Plugins/FileTransfer.cpp:247 msgid "FileTransfer: URL not specified" msgstr "கோப்பு இடமாற்றம்: URL குறிப்பிடப்படவில்லை" #: lib/Plugins/FileTransfer.cpp:69 #, c-format msgid "Sending archive %s via %s" msgstr "காப்பு %s %sவழியாக அனுப்புகிறது" #: lib/Plugins/FileTransfer.cpp:121 msgid "Creating an archive..." msgstr "ஒரு காப்பினை உருவாக்குகிறது..." #: lib/Plugins/FileTransfer.cpp:176 msgid "File Transfer: Creating a report..." msgstr "கோப்பு இடமாற்றம்: ஒரு அறிக்கை உருவாக்குகிறது..." #: lib/Plugins/FileTransfer.cpp:197 lib/Plugins/FileTransfer.cpp:226 msgid "CFileTransfer::Run(): Cannot create and send an archive: " msgstr "CFileTransfer::Run(): ஒரு காப்பினை உருவாக்க மற்றும் அனுப்ப முடியவில்லை: " #: lib/Plugins/KerneloopsScanner.cpp:79 msgid "Creating kernel oops crash reports..." msgstr "கர்னல் oops க்ரஷ்களை அறிக்கைகளை உருவாக்குகிறது..." #: lib/Plugins/Mailx.cpp:110 msgid "Sending an email..." msgstr "ஒரு மின்னஞ்சல் அனுப்புகிறது..." #: lib/Plugins/SOSreport.cpp:116 msgid "Executing SOSreport plugin..." msgstr "SOSreport கூடுதல் இணைப்பை இயக்குகிறது..." #: lib/Plugins/SOSreport.cpp:138 msgid "running sosreport: " msgstr "sosreportஐ இயக்குகிறது: " #: lib/Plugins/SOSreport.cpp:153 msgid "done running sosreport" msgstr "sosreportஐ இயக்கியது"